UNPKG

41 kBJavaScriptView Raw
1function noop() { }
2const identity = x => x;
3function assign(tar, src) {
4 // @ts-ignore
5 for (const k in src)
6 tar[k] = src[k];
7 return tar;
8}
9function is_promise(value) {
10 return value && typeof value === 'object' && typeof value.then === 'function';
11}
12function add_location(element, file, line, column, char) {
13 element.__svelte_meta = {
14 loc: { file, line, column, char }
15 };
16}
17function run(fn) {
18 return fn();
19}
20function blank_object() {
21 return Object.create(null);
22}
23function run_all(fns) {
24 fns.forEach(run);
25}
26function is_function(thing) {
27 return typeof thing === 'function';
28}
29function safe_not_equal(a, b) {
30 return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
31}
32function not_equal(a, b) {
33 return a != a ? b == b : a !== b;
34}
35function validate_store(store, name) {
36 if (!store || typeof store.subscribe !== 'function') {
37 throw new Error(`'${name}' is not a store with a 'subscribe' method`);
38 }
39}
40function subscribe(component, store, callback) {
41 const unsub = store.subscribe(callback);
42 component.$$.on_destroy.push(unsub.unsubscribe
43 ? () => unsub.unsubscribe()
44 : unsub);
45}
46function create_slot(definition, ctx, fn) {
47 if (definition) {
48 const slot_ctx = get_slot_context(definition, ctx, fn);
49 return definition[0](slot_ctx);
50 }
51}
52function get_slot_context(definition, ctx, fn) {
53 return definition[1]
54 ? assign({}, assign(ctx.$$scope.ctx, definition[1](fn ? fn(ctx) : {})))
55 : ctx.$$scope.ctx;
56}
57function get_slot_changes(definition, ctx, changed, fn) {
58 return definition[1]
59 ? assign({}, assign(ctx.$$scope.changed || {}, definition[1](fn ? fn(changed) : {})))
60 : ctx.$$scope.changed || {};
61}
62function exclude_internal_props(props) {
63 const result = {};
64 for (const k in props)
65 if (k[0] !== '$')
66 result[k] = props[k];
67 return result;
68}
69function once(fn) {
70 let ran = false;
71 return function (...args) {
72 if (ran)
73 return;
74 ran = true;
75 fn.call(this, ...args);
76 };
77}
78const is_client = typeof window !== 'undefined';
79let now = is_client
80 ? () => window.performance.now()
81 : () => Date.now();
82let raf = is_client ? requestAnimationFrame : noop;
83// used internally for testing
84function set_now(fn) {
85 now = fn;
86}
87function set_raf(fn) {
88 raf = fn;
89}
90
91const tasks = new Set();
92let running = false;
93function run_tasks() {
94 tasks.forEach(task => {
95 if (!task[0](now())) {
96 tasks.delete(task);
97 task[1]();
98 }
99 });
100 running = tasks.size > 0;
101 if (running)
102 raf(run_tasks);
103}
104function clear_loops() {
105 // for testing...
106 tasks.forEach(task => tasks.delete(task));
107 running = false;
108}
109function loop(fn) {
110 let task;
111 if (!running) {
112 running = true;
113 raf(run_tasks);
114 }
115 return {
116 promise: new Promise(fulfil => {
117 tasks.add(task = [fn, fulfil]);
118 }),
119 abort() {
120 tasks.delete(task);
121 }
122 };
123}
124
125function append(target, node) {
126 target.appendChild(node);
127}
128function insert(target, node, anchor) {
129 target.insertBefore(node, anchor || null);
130}
131function detach(node) {
132 node.parentNode.removeChild(node);
133}
134function detach_between(before, after) {
135 while (before.nextSibling && before.nextSibling !== after) {
136 before.parentNode.removeChild(before.nextSibling);
137 }
138}
139function detach_before(after) {
140 while (after.previousSibling) {
141 after.parentNode.removeChild(after.previousSibling);
142 }
143}
144function detach_after(before) {
145 while (before.nextSibling) {
146 before.parentNode.removeChild(before.nextSibling);
147 }
148}
149function destroy_each(iterations, detaching) {
150 for (let i = 0; i < iterations.length; i += 1) {
151 if (iterations[i])
152 iterations[i].d(detaching);
153 }
154}
155function element(name) {
156 return document.createElement(name);
157}
158function object_without_properties(obj, exclude) {
159 // eslint-disable-next-line @typescript-eslint/no-object-literal-type-assertion
160 const target = {};
161 for (const k in obj) {
162 if (Object.prototype.hasOwnProperty.call(obj, k)
163 // @ts-ignore
164 && exclude.indexOf(k) === -1) {
165 // @ts-ignore
166 target[k] = obj[k];
167 }
168 }
169 return target;
170}
171function svg_element(name) {
172 return document.createElementNS('http://www.w3.org/2000/svg', name);
173}
174function text(data) {
175 return document.createTextNode(data);
176}
177function space() {
178 return text(' ');
179}
180function empty() {
181 return text('');
182}
183function listen(node, event, handler, options) {
184 node.addEventListener(event, handler, options);
185 return () => node.removeEventListener(event, handler, options);
186}
187function prevent_default(fn) {
188 return function (event) {
189 event.preventDefault();
190 // @ts-ignore
191 return fn.call(this, event);
192 };
193}
194function stop_propagation(fn) {
195 return function (event) {
196 event.stopPropagation();
197 // @ts-ignore
198 return fn.call(this, event);
199 };
200}
201function attr(node, attribute, value) {
202 if (value == null)
203 node.removeAttribute(attribute);
204 else
205 node.setAttribute(attribute, value);
206}
207function set_attributes(node, attributes) {
208 for (const key in attributes) {
209 if (key === 'style') {
210 node.style.cssText = attributes[key];
211 }
212 else if (key in node) {
213 node[key] = attributes[key];
214 }
215 else {
216 attr(node, key, attributes[key]);
217 }
218 }
219}
220function set_custom_element_data(node, prop, value) {
221 if (prop in node) {
222 node[prop] = value;
223 }
224 else {
225 attr(node, prop, value);
226 }
227}
228function xlink_attr(node, attribute, value) {
229 node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);
230}
231function get_binding_group_value(group) {
232 const value = [];
233 for (let i = 0; i < group.length; i += 1) {
234 if (group[i].checked)
235 value.push(group[i].__value);
236 }
237 return value;
238}
239function to_number(value) {
240 return value === '' ? undefined : +value;
241}
242function time_ranges_to_array(ranges) {
243 const array = [];
244 for (let i = 0; i < ranges.length; i += 1) {
245 array.push({ start: ranges.start(i), end: ranges.end(i) });
246 }
247 return array;
248}
249function children(element) {
250 return Array.from(element.childNodes);
251}
252function claim_element(nodes, name, attributes, svg) {
253 for (let i = 0; i < nodes.length; i += 1) {
254 const node = nodes[i];
255 if (node.nodeName === name) {
256 for (let j = 0; j < node.attributes.length; j += 1) {
257 const attribute = node.attributes[j];
258 if (!attributes[attribute.name])
259 node.removeAttribute(attribute.name);
260 }
261 return nodes.splice(i, 1)[0]; // TODO strip unwanted attributes
262 }
263 }
264 return svg ? svg_element(name) : element(name);
265}
266function claim_text(nodes, data) {
267 for (let i = 0; i < nodes.length; i += 1) {
268 const node = nodes[i];
269 if (node.nodeType === 3) {
270 node.data = data;
271 return nodes.splice(i, 1)[0];
272 }
273 }
274 return text(data);
275}
276function set_data(text, data) {
277 data = '' + data;
278 if (text.data !== data)
279 text.data = data;
280}
281function set_input_type(input, type) {
282 try {
283 input.type = type;
284 }
285 catch (e) {
286 // do nothing
287 }
288}
289function set_style(node, key, value) {
290 node.style.setProperty(key, value);
291}
292function select_option(select, value) {
293 for (let i = 0; i < select.options.length; i += 1) {
294 const option = select.options[i];
295 if (option.__value === value) {
296 option.selected = true;
297 return;
298 }
299 }
300}
301function select_options(select, value) {
302 for (let i = 0; i < select.options.length; i += 1) {
303 const option = select.options[i];
304 option.selected = ~value.indexOf(option.__value);
305 }
306}
307function select_value(select) {
308 const selected_option = select.querySelector(':checked') || select.options[0];
309 return selected_option && selected_option.__value;
310}
311function select_multiple_value(select) {
312 return [].map.call(select.querySelectorAll(':checked'), option => option.__value);
313}
314function add_resize_listener(element, fn) {
315 if (getComputedStyle(element).position === 'static') {
316 element.style.position = 'relative';
317 }
318 const object = document.createElement('object');
319 object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
320 object.type = 'text/html';
321 let win;
322 object.onload = () => {
323 win = object.contentDocument.defaultView;
324 win.addEventListener('resize', fn);
325 };
326 if (/Trident/.test(navigator.userAgent)) {
327 element.appendChild(object);
328 object.data = 'about:blank';
329 }
330 else {
331 object.data = 'about:blank';
332 element.appendChild(object);
333 }
334 return {
335 cancel: () => {
336 win && win.removeEventListener && win.removeEventListener('resize', fn);
337 element.removeChild(object);
338 }
339 };
340}
341function toggle_class(element, name, toggle) {
342 element.classList[toggle ? 'add' : 'remove'](name);
343}
344function custom_event(type, detail) {
345 const e = document.createEvent('CustomEvent');
346 e.initCustomEvent(type, false, false, detail);
347 return e;
348}
349
350let stylesheet;
351let active = 0;
352let current_rules = {};
353// https://github.com/darkskyapp/string-hash/blob/master/index.js
354function hash(str) {
355 let hash = 5381;
356 let i = str.length;
357 while (i--)
358 hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
359 return hash >>> 0;
360}
361function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
362 const step = 16.666 / duration;
363 let keyframes = '{\n';
364 for (let p = 0; p <= 1; p += step) {
365 const t = a + (b - a) * ease(p);
366 keyframes += p * 100 + `%{${fn(t, 1 - t)}}\n`;
367 }
368 const rule = keyframes + `100% {${fn(b, 1 - b)}}\n}`;
369 const name = `__svelte_${hash(rule)}_${uid}`;
370 if (!current_rules[name]) {
371 if (!stylesheet) {
372 const style = element('style');
373 document.head.appendChild(style);
374 stylesheet = style.sheet;
375 }
376 current_rules[name] = true;
377 stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
378 }
379 const animation = node.style.animation || '';
380 node.style.animation = `${animation ? `${animation}, ` : ``}${name} ${duration}ms linear ${delay}ms 1 both`;
381 active += 1;
382 return name;
383}
384function delete_rule(node, name) {
385 node.style.animation = (node.style.animation || '')
386 .split(', ')
387 .filter(name
388 ? anim => anim.indexOf(name) < 0 // remove specific animation
389 : anim => anim.indexOf('__svelte') === -1 // remove all Svelte animations
390 )
391 .join(', ');
392 if (name && !--active)
393 clear_rules();
394}
395function clear_rules() {
396 raf(() => {
397 if (active)
398 return;
399 let i = stylesheet.cssRules.length;
400 while (i--)
401 stylesheet.deleteRule(i);
402 current_rules = {};
403 });
404}
405
406function create_animation(node, from, fn, params) {
407 if (!from)
408 return noop;
409 const to = node.getBoundingClientRect();
410 if (from.left === to.left && from.right === to.right && from.top === to.top && from.bottom === to.bottom)
411 return noop;
412 const { delay = 0, duration = 300, easing = identity,
413 // @ts-ignore todo: should this be separated from destructuring? Or start/end added to public api and documentation?
414 start: start_time = now() + delay,
415 // @ts-ignore todo:
416 end = start_time + duration, tick = noop, css } = fn(node, { from, to }, params);
417 let running = true;
418 let started = false;
419 let name;
420 function start() {
421 if (css) {
422 name = create_rule(node, 0, 1, duration, delay, easing, css);
423 }
424 if (!delay) {
425 started = true;
426 }
427 }
428 function stop() {
429 if (css)
430 delete_rule(node, name);
431 running = false;
432 }
433 loop(now$$1 => {
434 if (!started && now$$1 >= start_time) {
435 started = true;
436 }
437 if (started && now$$1 >= end) {
438 tick(1, 0);
439 stop();
440 }
441 if (!running) {
442 return false;
443 }
444 if (started) {
445 const p = now$$1 - start_time;
446 const t = 0 + 1 * easing(p / duration);
447 tick(t, 1 - t);
448 }
449 return true;
450 });
451 start();
452 tick(0, 1);
453 return stop;
454}
455function fix_position(node) {
456 const style = getComputedStyle(node);
457 if (style.position !== 'absolute' && style.position !== 'fixed') {
458 const { width, height } = style;
459 const a = node.getBoundingClientRect();
460 node.style.position = 'absolute';
461 node.style.width = width;
462 node.style.height = height;
463 add_transform(node, a);
464 }
465}
466function add_transform(node, a) {
467 const b = node.getBoundingClientRect();
468 if (a.left !== b.left || a.top !== b.top) {
469 const style = getComputedStyle(node);
470 const transform = style.transform === 'none' ? '' : style.transform;
471 node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`;
472 }
473}
474
475let current_component;
476function set_current_component(component) {
477 current_component = component;
478}
479function get_current_component() {
480 if (!current_component)
481 throw new Error(`Function called outside component initialization`);
482 return current_component;
483}
484function beforeUpdate(fn) {
485 get_current_component().$$.before_render.push(fn);
486}
487function onMount(fn) {
488 get_current_component().$$.on_mount.push(fn);
489}
490function afterUpdate(fn) {
491 get_current_component().$$.after_render.push(fn);
492}
493function onDestroy(fn) {
494 get_current_component().$$.on_destroy.push(fn);
495}
496function createEventDispatcher() {
497 const component = current_component;
498 return (type, detail) => {
499 const callbacks = component.$$.callbacks[type];
500 if (callbacks) {
501 // TODO are there situations where events could be dispatched
502 // in a server (non-DOM) environment?
503 const event = custom_event(type, detail);
504 callbacks.slice().forEach(fn => {
505 fn.call(component, event);
506 });
507 }
508 };
509}
510function setContext(key, context) {
511 get_current_component().$$.context.set(key, context);
512}
513function getContext(key) {
514 return get_current_component().$$.context.get(key);
515}
516// TODO figure out if we still want to support
517// shorthand events, or if we want to implement
518// a real bubbling mechanism
519function bubble(component, event) {
520 const callbacks = component.$$.callbacks[event.type];
521 if (callbacks) {
522 callbacks.slice().forEach(fn => fn(event));
523 }
524}
525
526const dirty_components = [];
527const intros = { enabled: false };
528const resolved_promise = Promise.resolve();
529let update_scheduled = false;
530const binding_callbacks = [];
531const render_callbacks = [];
532const flush_callbacks = [];
533function schedule_update() {
534 if (!update_scheduled) {
535 update_scheduled = true;
536 resolved_promise.then(flush);
537 }
538}
539function tick() {
540 schedule_update();
541 return resolved_promise;
542}
543function add_binding_callback(fn) {
544 binding_callbacks.push(fn);
545}
546function add_render_callback(fn) {
547 render_callbacks.push(fn);
548}
549function add_flush_callback(fn) {
550 flush_callbacks.push(fn);
551}
552function flush() {
553 const seen_callbacks = new Set();
554 do {
555 // first, call beforeUpdate functions
556 // and update components
557 while (dirty_components.length) {
558 const component = dirty_components.shift();
559 set_current_component(component);
560 update(component.$$);
561 }
562 while (binding_callbacks.length)
563 binding_callbacks.shift()();
564 // then, once components are updated, call
565 // afterUpdate functions. This may cause
566 // subsequent updates...
567 while (render_callbacks.length) {
568 const callback = render_callbacks.pop();
569 if (!seen_callbacks.has(callback)) {
570 callback();
571 // ...so guard against infinite loops
572 seen_callbacks.add(callback);
573 }
574 }
575 } while (dirty_components.length);
576 while (flush_callbacks.length) {
577 flush_callbacks.pop()();
578 }
579 update_scheduled = false;
580}
581function update($$) {
582 if ($$.fragment) {
583 $$.update($$.dirty);
584 run_all($$.before_render);
585 $$.fragment.p($$.dirty, $$.ctx);
586 $$.dirty = null;
587 $$.after_render.forEach(add_render_callback);
588 }
589}
590
591let promise;
592function wait() {
593 if (!promise) {
594 promise = Promise.resolve();
595 promise.then(() => {
596 promise = null;
597 });
598 }
599 return promise;
600}
601function dispatch(node, direction, kind) {
602 node.dispatchEvent(custom_event(`${direction ? 'intro' : 'outro'}${kind}`));
603}
604let outros;
605function group_outros() {
606 outros = {
607 remaining: 0,
608 callbacks: []
609 };
610}
611function check_outros() {
612 if (!outros.remaining) {
613 run_all(outros.callbacks);
614 }
615}
616function on_outro(callback) {
617 outros.callbacks.push(callback);
618}
619function create_in_transition(node, fn, params) {
620 let config = fn(node, params);
621 let running = false;
622 let animation_name;
623 let task;
624 let uid = 0;
625 function cleanup() {
626 if (animation_name)
627 delete_rule(node, animation_name);
628 }
629 function go() {
630 const { delay = 0, duration = 300, easing = identity, tick: tick$$1 = noop, css } = config;
631 if (css)
632 animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++);
633 tick$$1(0, 1);
634 const start_time = now() + delay;
635 const end_time = start_time + duration;
636 if (task)
637 task.abort();
638 running = true;
639 add_render_callback(() => dispatch(node, true, 'start'));
640 task = loop(now$$1 => {
641 if (running) {
642 if (now$$1 >= end_time) {
643 tick$$1(1, 0);
644 dispatch(node, true, 'end');
645 cleanup();
646 return running = false;
647 }
648 if (now$$1 >= start_time) {
649 const t = easing((now$$1 - start_time) / duration);
650 tick$$1(t, 1 - t);
651 }
652 }
653 return running;
654 });
655 }
656 let started = false;
657 return {
658 start() {
659 if (started)
660 return;
661 delete_rule(node);
662 if (is_function(config)) {
663 config = config();
664 wait().then(go);
665 }
666 else {
667 go();
668 }
669 },
670 invalidate() {
671 started = false;
672 },
673 end() {
674 if (running) {
675 cleanup();
676 running = false;
677 }
678 }
679 };
680}
681function create_out_transition(node, fn, params) {
682 let config = fn(node, params);
683 let running = true;
684 let animation_name;
685 const group = outros;
686 group.remaining += 1;
687 function go() {
688 const { delay = 0, duration = 300, easing = identity, tick: tick$$1 = noop, css } = config;
689 if (css)
690 animation_name = create_rule(node, 1, 0, duration, delay, easing, css);
691 const start_time = now() + delay;
692 const end_time = start_time + duration;
693 add_render_callback(() => dispatch(node, false, 'start'));
694 loop(now$$1 => {
695 if (running) {
696 if (now$$1 >= end_time) {
697 tick$$1(0, 1);
698 dispatch(node, false, 'end');
699 if (!--group.remaining) {
700 // this will result in `end()` being called,
701 // so we don't need to clean up here
702 run_all(group.callbacks);
703 }
704 return false;
705 }
706 if (now$$1 >= start_time) {
707 const t = easing((now$$1 - start_time) / duration);
708 tick$$1(1 - t, t);
709 }
710 }
711 return running;
712 });
713 }
714 if (is_function(config)) {
715 wait().then(() => {
716 // @ts-ignore
717 config = config();
718 go();
719 });
720 }
721 else {
722 go();
723 }
724 return {
725 end(reset) {
726 if (reset && config.tick) {
727 config.tick(1, 0);
728 }
729 if (running) {
730 if (animation_name)
731 delete_rule(node, animation_name);
732 running = false;
733 }
734 }
735 };
736}
737function create_bidirectional_transition(node, fn, params, intro) {
738 let config = fn(node, params);
739 let t = intro ? 0 : 1;
740 let running_program = null;
741 let pending_program = null;
742 let animation_name = null;
743 function clear_animation() {
744 if (animation_name)
745 delete_rule(node, animation_name);
746 }
747 function init(program, duration) {
748 const d = program.b - t;
749 duration *= Math.abs(d);
750 return {
751 a: t,
752 b: program.b,
753 d,
754 duration,
755 start: program.start,
756 end: program.start + duration,
757 group: program.group
758 };
759 }
760 function go(b) {
761 const { delay = 0, duration = 300, easing = identity, tick: tick$$1 = noop, css } = config;
762 const program = {
763 start: now() + delay,
764 b
765 };
766 if (!b) {
767 // @ts-ignore todo: improve typings
768 program.group = outros;
769 outros.remaining += 1;
770 }
771 if (running_program) {
772 pending_program = program;
773 }
774 else {
775 // if this is an intro, and there's a delay, we need to do
776 // an initial tick and/or apply CSS animation immediately
777 if (css) {
778 clear_animation();
779 animation_name = create_rule(node, t, b, duration, delay, easing, css);
780 }
781 if (b)
782 tick$$1(0, 1);
783 running_program = init(program, duration);
784 add_render_callback(() => dispatch(node, b, 'start'));
785 loop(now$$1 => {
786 if (pending_program && now$$1 > pending_program.start) {
787 running_program = init(pending_program, duration);
788 pending_program = null;
789 dispatch(node, running_program.b, 'start');
790 if (css) {
791 clear_animation();
792 animation_name = create_rule(node, t, running_program.b, running_program.duration, 0, easing, config.css);
793 }
794 }
795 if (running_program) {
796 if (now$$1 >= running_program.end) {
797 tick$$1(t = running_program.b, 1 - t);
798 dispatch(node, running_program.b, 'end');
799 if (!pending_program) {
800 // we're done
801 if (running_program.b) {
802 // intro — we can tidy up immediately
803 clear_animation();
804 }
805 else {
806 // outro — needs to be coordinated
807 if (!--running_program.group.remaining)
808 run_all(running_program.group.callbacks);
809 }
810 }
811 running_program = null;
812 }
813 else if (now$$1 >= running_program.start) {
814 const p = now$$1 - running_program.start;
815 t = running_program.a + running_program.d * easing(p / running_program.duration);
816 tick$$1(t, 1 - t);
817 }
818 }
819 return !!(running_program || pending_program);
820 });
821 }
822 }
823 return {
824 run(b) {
825 if (is_function(config)) {
826 wait().then(() => {
827 // @ts-ignore
828 config = config();
829 go(b);
830 });
831 }
832 else {
833 go(b);
834 }
835 },
836 end() {
837 clear_animation();
838 running_program = pending_program = null;
839 }
840 };
841}
842
843function handle_promise(promise, info) {
844 const token = info.token = {};
845 function update(type, index, key, value) {
846 if (info.token !== token)
847 return;
848 info.resolved = key && { [key]: value };
849 const child_ctx = assign(assign({}, info.ctx), info.resolved);
850 const block = type && (info.current = type)(child_ctx);
851 if (info.block) {
852 if (info.blocks) {
853 info.blocks.forEach((block, i) => {
854 if (i !== index && block) {
855 group_outros();
856 on_outro(() => {
857 block.d(1);
858 info.blocks[i] = null;
859 });
860 block.o(1);
861 check_outros();
862 }
863 });
864 }
865 else {
866 info.block.d(1);
867 }
868 block.c();
869 if (block.i)
870 block.i(1);
871 block.m(info.mount(), info.anchor);
872 flush();
873 }
874 info.block = block;
875 if (info.blocks)
876 info.blocks[index] = block;
877 }
878 if (is_promise(promise)) {
879 promise.then(value => {
880 update(info.then, 1, info.value, value);
881 }, error => {
882 update(info.catch, 2, info.error, error);
883 });
884 // if we previously had a then/catch block, destroy it
885 if (info.current !== info.pending) {
886 update(info.pending, 0);
887 return true;
888 }
889 }
890 else {
891 if (info.current !== info.then) {
892 update(info.then, 1, info.value, promise);
893 return true;
894 }
895 info.resolved = { [info.value]: promise };
896 }
897}
898
899function destroy_block(block, lookup) {
900 block.d(1);
901 lookup.delete(block.key);
902}
903function outro_and_destroy_block(block, lookup) {
904 on_outro(() => {
905 destroy_block(block, lookup);
906 });
907 block.o(1);
908}
909function fix_and_destroy_block(block, lookup) {
910 block.f();
911 destroy_block(block, lookup);
912}
913function fix_and_outro_and_destroy_block(block, lookup) {
914 block.f();
915 outro_and_destroy_block(block, lookup);
916}
917function update_keyed_each(old_blocks, changed, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) {
918 let o = old_blocks.length;
919 let n = list.length;
920 let i = o;
921 const old_indexes = {};
922 while (i--)
923 old_indexes[old_blocks[i].key] = i;
924 const new_blocks = [];
925 const new_lookup = new Map();
926 const deltas = new Map();
927 i = n;
928 while (i--) {
929 const child_ctx = get_context(ctx, list, i);
930 const key = get_key(child_ctx);
931 let block = lookup.get(key);
932 if (!block) {
933 block = create_each_block(key, child_ctx);
934 block.c();
935 }
936 else if (dynamic) {
937 block.p(changed, child_ctx);
938 }
939 new_lookup.set(key, new_blocks[i] = block);
940 if (key in old_indexes)
941 deltas.set(key, Math.abs(i - old_indexes[key]));
942 }
943 const will_move = new Set();
944 const did_move = new Set();
945 function insert(block) {
946 if (block.i)
947 block.i(1);
948 block.m(node, next);
949 lookup.set(block.key, block);
950 next = block.first;
951 n--;
952 }
953 while (o && n) {
954 const new_block = new_blocks[n - 1];
955 const old_block = old_blocks[o - 1];
956 const new_key = new_block.key;
957 const old_key = old_block.key;
958 if (new_block === old_block) {
959 // do nothing
960 next = new_block.first;
961 o--;
962 n--;
963 }
964 else if (!new_lookup.has(old_key)) {
965 // remove old block
966 destroy(old_block, lookup);
967 o--;
968 }
969 else if (!lookup.has(new_key) || will_move.has(new_key)) {
970 insert(new_block);
971 }
972 else if (did_move.has(old_key)) {
973 o--;
974 }
975 else if (deltas.get(new_key) > deltas.get(old_key)) {
976 did_move.add(new_key);
977 insert(new_block);
978 }
979 else {
980 will_move.add(old_key);
981 o--;
982 }
983 }
984 while (o--) {
985 const old_block = old_blocks[o];
986 if (!new_lookup.has(old_block.key))
987 destroy(old_block, lookup);
988 }
989 while (n)
990 insert(new_blocks[n - 1]);
991 return new_blocks;
992}
993function measure(blocks) {
994 const rects = {};
995 let i = blocks.length;
996 while (i--)
997 rects[blocks[i].key] = blocks[i].node.getBoundingClientRect();
998 return rects;
999}
1000
1001function get_spread_update(levels, updates) {
1002 const update = {};
1003 const to_null_out = {};
1004 const accounted_for = { $$scope: 1 };
1005 let i = levels.length;
1006 while (i--) {
1007 const o = levels[i];
1008 const n = updates[i];
1009 if (n) {
1010 for (const key in o) {
1011 if (!(key in n))
1012 to_null_out[key] = 1;
1013 }
1014 for (const key in n) {
1015 if (!accounted_for[key]) {
1016 update[key] = n[key];
1017 accounted_for[key] = 1;
1018 }
1019 }
1020 levels[i] = n;
1021 }
1022 else {
1023 for (const key in o) {
1024 accounted_for[key] = 1;
1025 }
1026 }
1027 }
1028 for (const key in to_null_out) {
1029 if (!(key in update))
1030 update[key] = undefined;
1031 }
1032 return update;
1033}
1034
1035const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
1036// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
1037// https://infra.spec.whatwg.org/#noncharacter
1038function spread(args) {
1039 const attributes = Object.assign({}, ...args);
1040 let str = '';
1041 Object.keys(attributes).forEach(name => {
1042 if (invalid_attribute_name_character.test(name))
1043 return;
1044 const value = attributes[name];
1045 if (value === undefined)
1046 return;
1047 if (value === true)
1048 str += " " + name;
1049 const escaped = String(value)
1050 .replace(/"/g, '&#34;')
1051 .replace(/'/g, '&#39;');
1052 str += " " + name + "=" + JSON.stringify(escaped);
1053 });
1054 return str;
1055}
1056const escaped = {
1057 '"': '&quot;',
1058 "'": '&#39;',
1059 '&': '&amp;',
1060 '<': '&lt;',
1061 '>': '&gt;'
1062};
1063function escape(html) {
1064 return String(html).replace(/["'&<>]/g, match => escaped[match]);
1065}
1066function each(items, fn) {
1067 let str = '';
1068 for (let i = 0; i < items.length; i += 1) {
1069 str += fn(items[i], i);
1070 }
1071 return str;
1072}
1073const missing_component = {
1074 $$render: () => ''
1075};
1076function validate_component(component, name) {
1077 if (!component || !component.$$render) {
1078 if (name === 'svelte:component')
1079 name += ' this={...}';
1080 throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);
1081 }
1082 return component;
1083}
1084function debug(file, line, column, values) {
1085 console.log(`{@debug} ${file ? file + ' ' : ''}(${line}:${column})`); // eslint-disable-line no-console
1086 console.log(values); // eslint-disable-line no-console
1087 return '';
1088}
1089let on_destroy;
1090function create_ssr_component(fn) {
1091 function $$render(result, props, bindings, slots) {
1092 const parent_component = current_component;
1093 const $$ = {
1094 on_destroy,
1095 context: new Map(parent_component ? parent_component.$$.context : []),
1096 // these will be immediately discarded
1097 on_mount: [],
1098 before_render: [],
1099 after_render: [],
1100 callbacks: blank_object()
1101 };
1102 set_current_component({ $$ });
1103 const html = fn(result, props, bindings, slots);
1104 set_current_component(parent_component);
1105 return html;
1106 }
1107 return {
1108 render: (props = {}, options = {}) => {
1109 on_destroy = [];
1110 const result = { head: '', css: new Set() };
1111 const html = $$render(result, props, {}, options);
1112 run_all(on_destroy);
1113 return {
1114 html,
1115 css: {
1116 code: Array.from(result.css).map(css => css.code).join('\n'),
1117 map: null // TODO
1118 },
1119 head: result.head
1120 };
1121 },
1122 $$render
1123 };
1124}
1125function get_store_value(store) {
1126 let value;
1127 store.subscribe(_ => value = _)();
1128 return value;
1129}
1130
1131function bind(component, name, callback) {
1132 if (component.$$.props.indexOf(name) === -1)
1133 return;
1134 component.$$.bound[name] = callback;
1135 callback(component.$$.ctx[name]);
1136}
1137function mount_component(component, target, anchor) {
1138 const { fragment, on_mount, on_destroy, after_render } = component.$$;
1139 fragment.m(target, anchor);
1140 // onMount happens after the initial afterUpdate. Because
1141 // afterUpdate callbacks happen in reverse order (inner first)
1142 // we schedule onMount callbacks before afterUpdate callbacks
1143 add_render_callback(() => {
1144 const new_on_destroy = on_mount.map(run).filter(is_function);
1145 if (on_destroy) {
1146 on_destroy.push(...new_on_destroy);
1147 }
1148 else {
1149 // Edge case - component was destroyed immediately,
1150 // most likely as a result of a binding initialising
1151 run_all(new_on_destroy);
1152 }
1153 component.$$.on_mount = [];
1154 });
1155 after_render.forEach(add_render_callback);
1156}
1157function destroy(component, detaching) {
1158 if (component.$$) {
1159 run_all(component.$$.on_destroy);
1160 component.$$.fragment.d(detaching);
1161 // TODO null out other refs, including component.$$ (but need to
1162 // preserve final state?)
1163 component.$$.on_destroy = component.$$.fragment = null;
1164 component.$$.ctx = {};
1165 }
1166}
1167function make_dirty(component, key) {
1168 if (!component.$$.dirty) {
1169 dirty_components.push(component);
1170 schedule_update();
1171 component.$$.dirty = blank_object();
1172 }
1173 component.$$.dirty[key] = true;
1174}
1175function init(component, options, instance, create_fragment, not_equal$$1, prop_names) {
1176 const parent_component = current_component;
1177 set_current_component(component);
1178 const props = options.props || {};
1179 const $$ = component.$$ = {
1180 fragment: null,
1181 ctx: null,
1182 // state
1183 props: prop_names,
1184 update: noop,
1185 not_equal: not_equal$$1,
1186 bound: blank_object(),
1187 // lifecycle
1188 on_mount: [],
1189 on_destroy: [],
1190 before_render: [],
1191 after_render: [],
1192 context: new Map(parent_component ? parent_component.$$.context : []),
1193 // everything else
1194 callbacks: blank_object(),
1195 dirty: null
1196 };
1197 let ready = false;
1198 $$.ctx = instance
1199 ? instance(component, props, (key, value) => {
1200 if ($$.ctx && not_equal$$1($$.ctx[key], $$.ctx[key] = value)) {
1201 if ($$.bound[key])
1202 $$.bound[key](value);
1203 if (ready)
1204 make_dirty(component, key);
1205 }
1206 })
1207 : props;
1208 $$.update();
1209 ready = true;
1210 run_all($$.before_render);
1211 $$.fragment = create_fragment($$.ctx);
1212 if (options.target) {
1213 if (options.hydrate) {
1214 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1215 $$.fragment.l(children(options.target));
1216 }
1217 else {
1218 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1219 $$.fragment.c();
1220 }
1221 if (options.intro && component.$$.fragment.i)
1222 component.$$.fragment.i();
1223 mount_component(component, options.target, options.anchor);
1224 flush();
1225 }
1226 set_current_component(parent_component);
1227}
1228let SvelteElement;
1229if (typeof HTMLElement !== 'undefined') {
1230 SvelteElement = class extends HTMLElement {
1231 constructor() {
1232 super();
1233 this.attachShadow({ mode: 'open' });
1234 }
1235 connectedCallback() {
1236 // @ts-ignore todo: improve typings
1237 for (const key in this.$$.slotted) {
1238 // @ts-ignore todo: improve typings
1239 this.appendChild(this.$$.slotted[key]);
1240 }
1241 }
1242 attributeChangedCallback(attr$$1, _oldValue, newValue) {
1243 this[attr$$1] = newValue;
1244 }
1245 $destroy() {
1246 destroy(this, true);
1247 this.$destroy = noop;
1248 }
1249 $on(type, callback) {
1250 // TODO should this delegate to addEventListener?
1251 const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
1252 callbacks.push(callback);
1253 return () => {
1254 const index = callbacks.indexOf(callback);
1255 if (index !== -1)
1256 callbacks.splice(index, 1);
1257 };
1258 }
1259 $set() {
1260 // overridden by instance, if it has props
1261 }
1262 };
1263}
1264class SvelteComponent {
1265 $destroy() {
1266 destroy(this, true);
1267 this.$destroy = noop;
1268 }
1269 $on(type, callback) {
1270 const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
1271 callbacks.push(callback);
1272 return () => {
1273 const index = callbacks.indexOf(callback);
1274 if (index !== -1)
1275 callbacks.splice(index, 1);
1276 };
1277 }
1278 $set() {
1279 // overridden by instance, if it has props
1280 }
1281}
1282class SvelteComponentDev extends SvelteComponent {
1283 constructor(options) {
1284 if (!options || (!options.target && !options.$$inline)) {
1285 throw new Error(`'target' is a required option`);
1286 }
1287 super();
1288 }
1289 $destroy() {
1290 super.$destroy();
1291 this.$destroy = () => {
1292 console.warn(`Component was already destroyed`); // eslint-disable-line no-console
1293 };
1294 }
1295}
1296
1297export { create_animation, fix_position, add_transform, handle_promise, append, insert, detach, detach_between, detach_before, detach_after, destroy_each, element, object_without_properties, svg_element, text, space, empty, listen, prevent_default, stop_propagation, attr, set_attributes, set_custom_element_data, xlink_attr, get_binding_group_value, to_number, time_ranges_to_array, children, claim_element, claim_text, set_data, set_input_type, set_style, select_option, select_options, select_value, select_multiple_value, add_resize_listener, toggle_class, custom_event, destroy_block, outro_and_destroy_block, fix_and_destroy_block, fix_and_outro_and_destroy_block, update_keyed_each, measure, current_component, set_current_component, beforeUpdate, onMount, afterUpdate, onDestroy, createEventDispatcher, setContext, getContext, bubble, clear_loops, loop, dirty_components, intros, schedule_update, tick, add_binding_callback, add_render_callback, add_flush_callback, flush, get_spread_update, invalid_attribute_name_character, spread, escaped, escape, each, missing_component, validate_component, debug, create_ssr_component, get_store_value, group_outros, check_outros, on_outro, create_in_transition, create_out_transition, create_bidirectional_transition, noop, identity, assign, is_promise, add_location, run, blank_object, run_all, is_function, safe_not_equal, not_equal, validate_store, subscribe, create_slot, get_slot_context, get_slot_changes, exclude_internal_props, once, now, raf, set_now, set_raf, bind, mount_component, init, SvelteElement, SvelteComponent, SvelteComponentDev };