UNPKG

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