UNPKG

132 kBJavaScriptView Raw
1var __create = Object.create;
2var __defProp = Object.defineProperty;
3var __getProtoOf = Object.getPrototypeOf;
4var __hasOwnProp = Object.prototype.hasOwnProperty;
5var __getOwnPropNames = Object.getOwnPropertyNames;
6var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
8var __commonJS = (callback2, module) => () => {
9 if (!module) {
10 module = {exports: {}};
11 callback2(module.exports, module);
12 }
13 return module.exports;
14};
15var __exportStar = (target, module, desc) => {
16 if (module && typeof module === "object" || typeof module === "function") {
17 for (let key of __getOwnPropNames(module))
18 if (!__hasOwnProp.call(target, key) && key !== "default")
19 __defProp(target, key, {get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable});
20 }
21 return target;
22};
23var __toModule = (module) => {
24 return __exportStar(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? {get: () => module.default, enumerable: true} : {value: module, enumerable: true})), module);
25};
26
27// vendor/events.js
28var require_events = __commonJS((exports, module) => {
29 "use strict";
30 var R = typeof Reflect === "object" ? Reflect : null;
31 var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply2(target, receiver, args) {
32 return Function.prototype.apply.call(target, receiver, args);
33 };
34 var ReflectOwnKeys;
35 if (R && typeof R.ownKeys === "function") {
36 ReflectOwnKeys = R.ownKeys;
37 } else if (Object.getOwnPropertySymbols) {
38 ReflectOwnKeys = function ReflectOwnKeys2(target) {
39 return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
40 };
41 } else {
42 ReflectOwnKeys = function ReflectOwnKeys2(target) {
43 return Object.getOwnPropertyNames(target);
44 };
45 }
46 function ProcessEmitWarning(warning) {
47 if (console && console.warn)
48 console.warn(warning);
49 }
50 var NumberIsNaN = Number.isNaN || function NumberIsNaN2(value) {
51 return value !== value;
52 };
53 function EventEmitter2() {
54 EventEmitter2.init.call(this);
55 }
56 module.exports = EventEmitter2;
57 module.exports.once = once2;
58 EventEmitter2.EventEmitter = EventEmitter2;
59 EventEmitter2.prototype._events = void 0;
60 EventEmitter2.prototype._eventsCount = 0;
61 EventEmitter2.prototype._maxListeners = void 0;
62 var defaultMaxListeners = 10;
63 function checkListener(listener) {
64 if (typeof listener !== "function") {
65 throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
66 }
67 }
68 Object.defineProperty(EventEmitter2, "defaultMaxListeners", {
69 enumerable: true,
70 get: function() {
71 return defaultMaxListeners;
72 },
73 set: function(arg) {
74 if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) {
75 throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + ".");
76 }
77 defaultMaxListeners = arg;
78 }
79 });
80 EventEmitter2.init = function() {
81 if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) {
82 this._events = Object.create(null);
83 this._eventsCount = 0;
84 }
85 this._maxListeners = this._maxListeners || void 0;
86 };
87 EventEmitter2.prototype.setMaxListeners = function setMaxListeners(n) {
88 if (typeof n !== "number" || n < 0 || NumberIsNaN(n)) {
89 throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + ".");
90 }
91 this._maxListeners = n;
92 return this;
93 };
94 function _getMaxListeners(that) {
95 if (that._maxListeners === void 0)
96 return EventEmitter2.defaultMaxListeners;
97 return that._maxListeners;
98 }
99 EventEmitter2.prototype.getMaxListeners = function getMaxListeners() {
100 return _getMaxListeners(this);
101 };
102 EventEmitter2.prototype.emit = function emit2(type) {
103 var args = [];
104 for (var i = 1; i < arguments.length; i++)
105 args.push(arguments[i]);
106 var doError = type === "error";
107 var events2 = this._events;
108 if (events2 !== void 0)
109 doError = doError && events2.error === void 0;
110 else if (!doError)
111 return false;
112 if (doError) {
113 var er;
114 if (args.length > 0)
115 er = args[0];
116 if (er instanceof Error) {
117 throw er;
118 }
119 var err = new Error("Unhandled error." + (er ? " (" + er.message + ")" : ""));
120 err.context = er;
121 throw err;
122 }
123 var handler = events2[type];
124 if (handler === void 0)
125 return false;
126 if (typeof handler === "function") {
127 ReflectApply(handler, this, args);
128 } else {
129 var len = handler.length;
130 var listeners = arrayClone(handler, len);
131 for (var i = 0; i < len; ++i)
132 ReflectApply(listeners[i], this, args);
133 }
134 return true;
135 };
136 function _addListener(target, type, listener, prepend) {
137 var m;
138 var events2;
139 var existing;
140 checkListener(listener);
141 events2 = target._events;
142 if (events2 === void 0) {
143 events2 = target._events = Object.create(null);
144 target._eventsCount = 0;
145 } else {
146 if (events2.newListener !== void 0) {
147 target.emit("newListener", type, listener.listener ? listener.listener : listener);
148 events2 = target._events;
149 }
150 existing = events2[type];
151 }
152 if (existing === void 0) {
153 existing = events2[type] = listener;
154 ++target._eventsCount;
155 } else {
156 if (typeof existing === "function") {
157 existing = events2[type] = prepend ? [listener, existing] : [existing, listener];
158 } else if (prepend) {
159 existing.unshift(listener);
160 } else {
161 existing.push(listener);
162 }
163 m = _getMaxListeners(target);
164 if (m > 0 && existing.length > m && !existing.warned) {
165 existing.warned = true;
166 var w = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type) + " listeners added. Use emitter.setMaxListeners() to increase limit");
167 w.name = "MaxListenersExceededWarning";
168 w.emitter = target;
169 w.type = type;
170 w.count = existing.length;
171 ProcessEmitWarning(w);
172 }
173 }
174 return target;
175 }
176 EventEmitter2.prototype.addListener = function addListener(type, listener) {
177 return _addListener(this, type, listener, false);
178 };
179 EventEmitter2.prototype.on = EventEmitter2.prototype.addListener;
180 EventEmitter2.prototype.prependListener = function prependListener(type, listener) {
181 return _addListener(this, type, listener, true);
182 };
183 function onceWrapper() {
184 if (!this.fired) {
185 this.target.removeListener(this.type, this.wrapFn);
186 this.fired = true;
187 if (arguments.length === 0)
188 return this.listener.call(this.target);
189 return this.listener.apply(this.target, arguments);
190 }
191 }
192 function _onceWrap(target, type, listener) {
193 var state = {fired: false, wrapFn: void 0, target, type, listener};
194 var wrapped = onceWrapper.bind(state);
195 wrapped.listener = listener;
196 state.wrapFn = wrapped;
197 return wrapped;
198 }
199 EventEmitter2.prototype.once = function once3(type, listener) {
200 checkListener(listener);
201 this.on(type, _onceWrap(this, type, listener));
202 return this;
203 };
204 EventEmitter2.prototype.prependOnceListener = function prependOnceListener(type, listener) {
205 checkListener(listener);
206 this.prependListener(type, _onceWrap(this, type, listener));
207 return this;
208 };
209 EventEmitter2.prototype.removeListener = function removeListener(type, listener) {
210 var list, events2, position, i, originalListener;
211 checkListener(listener);
212 events2 = this._events;
213 if (events2 === void 0)
214 return this;
215 list = events2[type];
216 if (list === void 0)
217 return this;
218 if (list === listener || list.listener === listener) {
219 if (--this._eventsCount === 0)
220 this._events = Object.create(null);
221 else {
222 delete events2[type];
223 if (events2.removeListener)
224 this.emit("removeListener", type, list.listener || listener);
225 }
226 } else if (typeof list !== "function") {
227 position = -1;
228 for (i = list.length - 1; i >= 0; i--) {
229 if (list[i] === listener || list[i].listener === listener) {
230 originalListener = list[i].listener;
231 position = i;
232 break;
233 }
234 }
235 if (position < 0)
236 return this;
237 if (position === 0)
238 list.shift();
239 else {
240 spliceOne(list, position);
241 }
242 if (list.length === 1)
243 events2[type] = list[0];
244 if (events2.removeListener !== void 0)
245 this.emit("removeListener", type, originalListener || listener);
246 }
247 return this;
248 };
249 EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener;
250 EventEmitter2.prototype.removeAllListeners = function removeAllListeners(type) {
251 var listeners, events2, i;
252 events2 = this._events;
253 if (events2 === void 0)
254 return this;
255 if (events2.removeListener === void 0) {
256 if (arguments.length === 0) {
257 this._events = Object.create(null);
258 this._eventsCount = 0;
259 } else if (events2[type] !== void 0) {
260 if (--this._eventsCount === 0)
261 this._events = Object.create(null);
262 else
263 delete events2[type];
264 }
265 return this;
266 }
267 if (arguments.length === 0) {
268 var keys = Object.keys(events2);
269 var key;
270 for (i = 0; i < keys.length; ++i) {
271 key = keys[i];
272 if (key === "removeListener")
273 continue;
274 this.removeAllListeners(key);
275 }
276 this.removeAllListeners("removeListener");
277 this._events = Object.create(null);
278 this._eventsCount = 0;
279 return this;
280 }
281 listeners = events2[type];
282 if (typeof listeners === "function") {
283 this.removeListener(type, listeners);
284 } else if (listeners !== void 0) {
285 for (i = listeners.length - 1; i >= 0; i--) {
286 this.removeListener(type, listeners[i]);
287 }
288 }
289 return this;
290 };
291 function _listeners(target, type, unwrap) {
292 var events2 = target._events;
293 if (events2 === void 0)
294 return [];
295 var evlistener = events2[type];
296 if (evlistener === void 0)
297 return [];
298 if (typeof evlistener === "function")
299 return unwrap ? [evlistener.listener || evlistener] : [evlistener];
300 return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
301 }
302 EventEmitter2.prototype.listeners = function listeners(type) {
303 return _listeners(this, type, true);
304 };
305 EventEmitter2.prototype.rawListeners = function rawListeners(type) {
306 return _listeners(this, type, false);
307 };
308 EventEmitter2.listenerCount = function(emitter, type) {
309 if (typeof emitter.listenerCount === "function") {
310 return emitter.listenerCount(type);
311 } else {
312 return listenerCount.call(emitter, type);
313 }
314 };
315 EventEmitter2.prototype.listenerCount = listenerCount;
316 function listenerCount(type) {
317 var events2 = this._events;
318 if (events2 !== void 0) {
319 var evlistener = events2[type];
320 if (typeof evlistener === "function") {
321 return 1;
322 } else if (evlistener !== void 0) {
323 return evlistener.length;
324 }
325 }
326 return 0;
327 }
328 EventEmitter2.prototype.eventNames = function eventNames() {
329 return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
330 };
331 function arrayClone(arr, n) {
332 var copy = new Array(n);
333 for (var i = 0; i < n; ++i)
334 copy[i] = arr[i];
335 return copy;
336 }
337 function spliceOne(list, index) {
338 for (; index + 1 < list.length; index++)
339 list[index] = list[index + 1];
340 list.pop();
341 }
342 function unwrapListeners(arr) {
343 var ret = new Array(arr.length);
344 for (var i = 0; i < ret.length; ++i) {
345 ret[i] = arr[i].listener || arr[i];
346 }
347 return ret;
348 }
349 function once2(emitter, name) {
350 return new Promise(function(resolve, reject) {
351 function eventListener() {
352 if (errorListener !== void 0) {
353 emitter.removeListener("error", errorListener);
354 }
355 resolve([].slice.call(arguments));
356 }
357 ;
358 var errorListener;
359 if (name !== "error") {
360 errorListener = function errorListener2(err) {
361 emitter.removeListener(name, eventListener);
362 reject(err);
363 };
364 emitter.once("error", errorListener);
365 }
366 emitter.once(name, eventListener);
367 });
368 }
369});
370
371// src/imba/utils.imba
372function iter$__(a) {
373 let v;
374 return a ? (v = a.toIterable) ? v.call(a) : a : [];
375}
376var φ1 = Symbol.for("#type");
377var φ20 = Symbol.for("#__listeners__");
378var dashRegex = /-./g;
379var LazyProxy = class {
380 static for(getter) {
381 return new Proxy({}, new this(getter));
382 }
383 constructor(getter) {
384 this.getter = getter;
385 }
386 get target() {
387 return this.getter();
388 }
389 get(_, key) {
390 return this.target[key];
391 }
392 set(_, key, value) {
393 this.target[key] = value;
394 return true;
395 }
396};
397function proxy(getter, placeholder = {}) {
398 return new Proxy(placeholder, new LazyProxy(getter));
399}
400function parseTime(value) {
401 let typ = typeof value;
402 if (typ == "number") {
403 return value;
404 }
405 ;
406 if (typ == "string") {
407 if (/^\d+fps$/.test(value)) {
408 return 1e3 / parseFloat(value);
409 } else if (/^([-+]?[\d\.]+)s$/.test(value)) {
410 return parseFloat(value) * 1e3;
411 } else if (/^([-+]?[\d\.]+)ms$/.test(value)) {
412 return parseFloat(value);
413 }
414 ;
415 }
416 ;
417 return null;
418}
419function serializeData(data) {
420 let map = new Map();
421 let arr = [];
422 let logging = false;
423 let replacer = function(key, value) {
424 if (value && value[φ1] && key !== "") {
425 let ref = map.get(value);
426 if (!map.has(value)) {
427 map.set(value, ref = "$$" + arr.length + "$$");
428 arr.push(value);
429 }
430 ;
431 return key == null ? value : ref;
432 }
433 ;
434 return value;
435 };
436 let json = JSON.stringify(data, replacer, 2);
437 let i = 0;
438 logging = true;
439 while (i < arr.length) {
440 arr[i] = JSON.stringify(arr[i], replacer, 2);
441 i++;
442 }
443 ;
444 let inject = "";
445 for (let i2 = 0, φ210 = iter$__(arr), φ35 = φ210.length; i2 < φ35; i2++) {
446 let item = φ210[i2];
447 inject += '"$$' + i2 + '$$":' + item + ",\n";
448 }
449 ;
450 json = "{" + inject + json.slice(1);
451 return json;
452}
453function deserializeData(data, reviver = null) {
454 let objects = {};
455 let reg = /\$\$\d+\$\$/;
456 let lookup = function(value) {
457 return objects[value] || (objects[value] = reviver ? reviver(value) : {});
458 };
459 let parser = function(key, value) {
460 if (typeof value == "string") {
461 if (value[0] == "$" && reg.test(value)) {
462 return lookup(value);
463 }
464 ;
465 } else if (typeof key == "string" && key[0] == "$" && reg.test(key)) {
466 let obj = lookup(key);
467 Object.assign(obj, value);
468 return obj;
469 }
470 ;
471 return value;
472 };
473 let parsed = JSON.parse(data, parser);
474 return parsed;
475}
476function patchManifest(prev, curr) {
477 var φ75, φ65, φ114, φ183;
478 let origs = {};
479 let diff = {
480 added: [],
481 changed: [],
482 removed: [],
483 all: [],
484 urls: {}
485 };
486 if (prev.assets) {
487 for (let φ45 = 0, φ56 = iter$__(prev.assets), φ84 = φ56.length; φ45 < φ84; φ45++) {
488 let item = φ5645];
489 let ref = item.originalPath || item.path;
490 origs[ref] = item;
491 if (item.url) {
49275 = curr.urls)[φ65 = item.url] || (φ7565] = item);
493 }
494 ;
495 }
496 ;
497 }
498 ;
499 for (let φ94 = 0, φ105 = iter$__(curr.assets || []), φ123 = φ105.length; φ94 < φ123; φ94++) {
500 let item = φ10594];
501 let ref = item.originalPath || item.path;
502 let orig = origs[ref];
503 if (item.url && prev.urls) {
504 prev.urls[item.url] = item;
505 }
506 ;
507 if (orig) {
508 if (orig.hash != item.hash) {
509 orig.invalidated = Date.now();
510 orig.replacedBy = item;
511 item.replaces = orig;
512 diff.changed.push(item);
513 diff.all.push(item);
514 if (orig == prev.main) {
515 diff.main = item;
516 }
517 ;
518 }
519 ;
520 φ114 = origs[ref], delete origs[ref], φ114;
521 } else {
522 diff.added.push(item);
523 diff.all.push(item);
524 }
525 ;
526 }
527 ;
528 for (let φ132 = 0, φ142 = Object.keys(origs), φ152 = φ142.length, path, item; φ132 < φ152; φ132++) {
529 path = φ142132];
530 item = origs[path];
531 item.removed = Date.now();
532 diff.all.push(item);
533 }
534 ;
535 for (let φ163 = 0, φ173 = iter$__(diff.all), φ193 = φ173.length; φ163 < φ193; φ163++) {
536 let item = φ173163];
537 let typ = diff[φ183 = item.type] || (diff[φ183] = []);
538 typ.push(item);
539 }
540 ;
541 diff.removed = Object.values(origs);
542 curr.changes = diff;
543 return curr;
544}
545function toCamelCase(str) {
546 if (str.indexOf("-") >= 0) {
547 return str.replace(dashRegex, function(_0) {
548 return _0.charAt(1).toUpperCase();
549 });
550 } else {
551 return str;
552 }
553 ;
554}
555function getDeepPropertyDescriptor(item, key, stop) {
556 if (!item) {
557 return void 0;
558 }
559 ;
560 let desc = Object.getOwnPropertyDescriptor(item, key);
561 if (desc || item == stop) {
562 return desc || void 0;
563 }
564 ;
565 return getDeepPropertyDescriptor(Reflect.getPrototypeOf(item), key, stop);
566}
567var emit__ = function(event, args, node) {
568 let prev;
569 let cb;
570 let ret;
571 while ((prev = node) && (node = node.next)) {
572 if (cb = node.listener) {
573 if (node.path && cb[node.path]) {
574 ret = args ? cb[node.path].apply(cb, args) : cb[node.path]();
575 } else {
576 ret = args ? cb.apply(node, args) : cb.call(node);
577 }
578 ;
579 }
580 ;
581 if (node.times && --node.times <= 0) {
582 prev.next = node.next;
583 node.listener = null;
584 }
585 ;
586 }
587 ;
588 return;
589};
590function listen(obj, event, listener, path) {
591 var φ213;
592 let cbs;
593 let list;
594 let tail;
595 cbs = obj[φ20] || (obj[φ20] = {});
596 list = cbs[event] || (cbs[event] = {});
597 tail = list.tail || (list.tail = list.next = {});
598 tail.listener = listener;
599 tail.path = path;
600 list.tail = tail.next = {};
601 return tail;
602}
603function once(obj, event, listener) {
604 let tail = listen(obj, event, listener);
605 tail.times = 1;
606 return tail;
607}
608function unlisten(obj, event, cb, meth) {
609 let node;
610 let prev;
611 let meta = obj[φ20];
612 if (!meta) {
613 return;
614 }
615 ;
616 if (node = meta[event]) {
617 while ((prev = node) && (node = node.next)) {
618 if (node == cb || node.listener == cb) {
619 prev.next = node.next;
620 node.listener = null;
621 break;
622 }
623 ;
624 }
625 ;
626 }
627 ;
628 return;
629}
630function emit(obj, event, params) {
631 let cb;
632 if (cb = obj[φ20]) {
633 if (cb[event]) {
634 emit__(event, params, cb[event]);
635 }
636 ;
637 if (cb.all) {
638 emit__(event, [event, params], cb.all);
639 }
640 ;
641 }
642 ;
643 return;
644}
645
646// src/imba/scheduler.imba
647function iter$__2(a) {
648 let v;
649 return a ? (v = a.toIterable) ? v.call(a) : a : [];
650}
651var φ12 = Symbol.for("#init");
652var φ2 = Symbol.for("#schedule");
653var φ4 = Symbol.for("#frames");
654var φ5 = Symbol.for("#interval");
655var φ6 = Symbol.for("#stage");
656var φ7 = Symbol.for("#scheduled");
657var φ8 = Symbol.for("#fps");
658var φ9 = Symbol.for("#ticker");
659var rAF = globalThis.requestAnimationFrame || function(blk) {
660 return setTimeout1(blk, 1e3 / 60);
661};
662var SPF = 1 / 60;
663var Scheduled = class {
664 constructor($$ = null) {
665 this12]($$);
666 }
66712]($$ = null) {
668 var φ35;
669 this.owner = $$ && (φ35 = $$.owner) !== void 0 ? φ35 : null;
670 this.target = $$ && (φ35 = $$.target) !== void 0 ? φ35 : null;
671 this.active = $$ && (φ35 = $$.active) !== void 0 ? φ35 : false;
672 this.value = $$ && (φ35 = $$.value) !== void 0 ? φ35 : void 0;
673 this.skip = $$ && (φ35 = $$.skip) !== void 0 ? φ35 : 0;
674 this.last = $$ && (φ35 = $$.last) !== void 0 ? φ35 : 0;
675 }
676 tick(scheduler2) {
677 this.last = this.owner[φ4];
678 this.target.tick(this.owner);
679 return 1;
680 }
681 update(o, activateΦ) {
682 let on = this.active;
683 let val = o.value;
684 let changed = this.value != val;
685 if (changed) {
686 this.deactivate();
687 this.value = val;
688 }
689 ;
690 if (this.value || on || activateΦ) {
691 this.activate();
692 }
693 ;
694 return this;
695 }
696 queue() {
697 this.owner.add(this);
698 return;
699 }
700 activate() {
701 if (this.value === true) {
702 this.owner.on("commit", this);
703 } else if (this.value === false) {
704 true;
705 } else if (typeof this.value == "number") {
706 let tock = this.value / (1e3 / 60);
707 if (tock <= 2) {
708 this.owner.on("raf", this);
709 } else {
710 this5] = globalThis.setInterval(this.queue.bind(this), this.value);
711 }
712 ;
713 }
714 ;
715 this.active = true;
716 return this;
717 }
718 deactivate() {
719 if (this.value === true) {
720 this.owner.un("commit", this);
721 }
722 ;
723 this.owner.un("raf", this);
724 if (this5]) {
725 globalThis.clearInterval(this5]);
726 this5] = null;
727 }
728 ;
729 this.active = false;
730 return this;
731 }
732};
733var Scheduler = class {
734 constructor() {
735 var self = this;
736 this.id = Symbol();
737 this.queue = [];
738 this.stage = -1;
739 this6] = -1;
740 this4] = 0;
741 this7] = false;
742 this.listeners = {};
743 this.intervals = {};
744 this.commit = function() {
745 self.add("commit");
746 return self;
747 };
748 this8] = 0;
749 this.$promise = null;
750 this.$resolve = null;
751 this9] = function(e) {
752 self[φ7] = false;
753 return self.tick(e);
754 };
755 this;
756 }
757 add(item, force) {
758 if (force || this.queue.indexOf(item) == -1) {
759 this.queue.push(item);
760 }
761 ;
762 if (!this7]) {
763 this2]();
764 }
765 ;
766 return this;
767 }
768 listen(ns, item) {
769 let set = this.listeners[ns];
770 let first = !set;
771 set || (set = this.listeners[ns] = new Set());
772 set.add(item);
773 if (ns == "raf" && first) {
774 this.add("raf");
775 }
776 ;
777 return this;
778 }
779 unlisten(ns, item) {
780 var φ105;
781 let set = this.listeners[ns];
782 set && set.delete(item);
783 if (ns == "raf" && set && set.size == 0) {
784 φ105 = this.listeners.raf, delete this.listeners.raf, φ105;
785 }
786 ;
787 return this;
788 }
789 on(ns, item) {
790 return this.listen(ns, item);
791 }
792 un(ns, item) {
793 return this.unlisten(ns, item);
794 }
795 get promise() {
796 var self = this;
797 return this.$promise || (this.$promise = new Promise(function(resolve) {
798 return self.$resolve = resolve;
799 }));
800 }
801 tick(timestamp) {
802 var self = this;
803 let items = this.queue;
804 let frame = this4]++;
805 if (!this.ts) {
806 this.ts = timestamp;
807 }
808 ;
809 this.dt = timestamp - this.ts;
810 this.ts = timestamp;
811 this.queue = [];
812 this6] = 1;
813 if (items.length) {
814 for (let i = 0, φ114 = iter$__2(items), φ123 = φ114.length; i < φ123; i++) {
815 let item = φ114[i];
816 if (typeof item === "string" && this.listeners[item]) {
817 this.listeners[item].forEach(function(item2) {
818 if (item2.tick instanceof Function) {
819 return item2.tick(self);
820 } else if (item2 instanceof Function) {
821 return item2(self);
822 }
823 ;
824 });
825 } else if (item instanceof Function) {
826 item(this.dt, this);
827 } else if (item.tick) {
828 item.tick(this.dt, this);
829 }
830 ;
831 }
832 ;
833 }
834 ;
835 this6] = this7] ? 0 : -1;
836 if (this.$promise) {
837 this.$resolve(this);
838 this.$promise = this.$resolve = null;
839 }
840 ;
841 if (this.listeners.raf && true) {
842 this.add("raf");
843 }
844 ;
845 return this;
846 }
8472]() {
848 if (!this7]) {
849 this7] = true;
850 if (this6] == -1) {
851 this6] = 0;
852 }
853 ;
854 rAF(this9]);
855 }
856 ;
857 return this;
858 }
859 schedule(item, o) {
860 var φ132, φ142;
861 o || (o = item[φ132 = this.id] || (item[φ132] = {value: true}));
862 let state = o[φ142 = this.id] || (o[φ142] = new Scheduled({owner: this, target: item}));
863 return state.update(o, true);
864 }
865 unschedule(item, o = {}) {
866 o || (o = item[this.id]);
867 let state = o && o[this.id];
868 if (state && state.active) {
869 state.deactivate();
870 }
871 ;
872 return this;
873 }
874};
875var scheduler = new Scheduler();
876function commit() {
877 return scheduler.add("commit").promise;
878}
879function setTimeout2(fn, ms) {
880 return globalThis.setTimeout(function() {
881 fn();
882 commit();
883 return;
884 }, ms);
885}
886function setInterval(fn, ms) {
887 return globalThis.setInterval(function() {
888 fn();
889 commit();
890 return;
891 }, ms);
892}
893var clearInterval = globalThis.clearInterval;
894var clearTimeout = globalThis.clearTimeout;
895var instance = globalThis.imba || (globalThis.imba = {});
896instance.commit = commit;
897instance.setTimeout = setTimeout2;
898instance.setInterval = setInterval;
899instance.clearInterval = clearInterval;
900instance.clearTimeout = clearTimeout;
901
902// src/imba/manifest.web.imba
903var Manifest = class {
904 constructor() {
905 this.data = {};
906 }
907};
908var manifest = new Manifest();
909
910// src/imba/process.web.imba
911var process = {};
912
913// src/imba/asset.imba
914var φ13 = Symbol.for("#init");
915var φ22 = Symbol.for("#warned");
916var φ72 = Symbol.for("#asset");
917var AssetProxy = class {
918 static wrap(meta) {
919 let handler = new AssetProxy(meta);
920 return new Proxy(handler, handler);
921 }
922 constructor(meta) {
923 this.meta = meta;
924 }
925 get input() {
926 return manifest.inputs[this.meta.input];
927 }
928 get asset() {
929 return globalThis._MF_ ? this.meta : this.input ? this.input.asset : null;
930 }
931 set(target, key, value) {
932 return true;
933 }
934 get(target, key) {
935 if (this.meta.meta && this.meta.meta[key] != void 0) {
936 return this.meta.meta[key];
937 }
938 ;
939 if (!this.asset) {
940 if (this.meta[φ22] != true ? (this.meta[φ22] = true, true) : false) {
941 console.warn("Asset for '" + this.meta.input + "' not found");
942 }
943 ;
944 if (key == "valueOf") {
945 return function() {
946 return "";
947 };
948 }
949 ;
950 return null;
951 }
952 ;
953 if (key == "absPath" && !this.asset.absPath) {
954 return this.asset.url;
955 }
956 ;
957 return this.asset[key];
958 }
959};
960var SVGAsset = class {
961 constructor($$ = null) {
962 this13]($$);
963 }
96413]($$ = null) {
965 this.url = $$ ? $$.url : void 0;
966 this.meta = $$ ? $$.meta : void 0;
967 }
968 adoptNode(node) {
969 var _a;
970 if ((_a = this.meta) == null ? void 0 : _a.content) {
971 for (let φ56 = this.meta.attributes, φ35 = 0, φ45 = Object.keys(φ56), φ65 = φ45.length, k, v; φ35 < φ65; φ35++) {
972 k = φ4535];
973 v = φ56[k];
974 node.setAttribute(k, v);
975 }
976 ;
977 node.innerHTML = this.meta.content;
978 }
979 ;
980 return this;
981 }
982 toString() {
983 return this.url;
984 }
985 toStyleString() {
986 return "url(" + this.url + ")";
987 }
988};
989function asset(data) {
990 var φ84, φ94;
991 if (data[φ72]) {
992 return data[φ72];
993 }
994 ;
995 if (data.type == "svg") {
996 return data[φ72] || (data[φ72] = new SVGAsset(data));
997 }
998 ;
999 if (data.input) {
1000 let extra = globalThis._MF_ && globalThis._MF_[data.input];
1001 if (extra) {
1002 Object.assign(data, extra);
1003 data.toString = function() {
1004 return this.absPath;
1005 };
1006 }
1007 ;
1008 return data[φ72] || (data[φ72] = AssetProxy.wrap(data));
1009 }
1010 ;
1011 return data;
1012}
1013
1014// src/imba/dom/flags.imba
1015var Flags = class {
1016 constructor(dom) {
1017 this.dom = dom;
1018 this.string = "";
1019 }
1020 contains(ref) {
1021 return this.dom.classList.contains(ref);
1022 }
1023 add(ref) {
1024 if (this.contains(ref)) {
1025 return this;
1026 }
1027 ;
1028 this.string += (this.string ? " " : "") + ref;
1029 this.dom.classList.add(ref);
1030 return this;
1031 }
1032 remove(ref) {
1033 if (!this.contains(ref)) {
1034 return this;
1035 }
1036 ;
1037 let regex = new RegExp("(^|\\s)*" + ref + "(\\s|$)*", "g");
1038 this.string = this.string.replace(regex, "");
1039 this.dom.classList.remove(ref);
1040 return this;
1041 }
1042 toggle(ref, bool) {
1043 if (bool === void 0) {
1044 bool = !this.contains(ref);
1045 }
1046 ;
1047 return bool ? this.add(ref) : this.remove(ref);
1048 }
1049 incr(ref) {
1050 let m = this.stacks || (this.stacks = {});
1051 let c = m[ref] || 0;
1052 if (c < 1) {
1053 this.add(ref);
1054 }
1055 ;
1056 return m[ref] = Math.max(c, 0) + 1;
1057 }
1058 decr(ref) {
1059 let m = this.stacks || (this.stacks = {});
1060 let c = m[ref] || 0;
1061 if (c == 1) {
1062 this.remove(ref);
1063 }
1064 ;
1065 return m[ref] = Math.max(c, 1) - 1;
1066 }
1067 valueOf() {
1068 return this.string;
1069 }
1070 toString() {
1071 return this.string;
1072 }
1073 sync() {
1074 return this.dom.flagSync$();
1075 }
1076};
1077
1078// src/imba/dom/core.web.imba
1079function extend$__(target, ext) {
1080 var descriptors = Object.getOwnPropertyDescriptors(ext);
1081 Object.defineProperties(target, descriptors);
1082 return target;
1083}
1084function iter$__3(a) {
1085 let v;
1086 return a ? (v = a.toIterable) ? v.call(a) : a : [];
1087}
1088var φ14 = Symbol.for("#parent");
1089var φ23 = Symbol.for("#context");
1090var φ3 = Symbol.for("#init");
1091var φ42 = Symbol.for("#placeholder__");
1092var φ52 = Symbol.for("#attachToParent");
1093var φ62 = Symbol.for("#detachFromParent");
1094var φ73 = Symbol.for("##parent");
1095var φ82 = Symbol.for("##up");
1096var φ92 = Symbol.for("##context");
1097var φ10 = Symbol.for("##placeholder__");
1098var φ122 = Symbol.for("#src");
1099var φ202 = Symbol.for("#htmlNodeName");
1100var φ21 = Symbol.for("#ImbaElement");
1101var {
1102 Event,
1103 UIEvent,
1104 MouseEvent,
1105 PointerEvent,
1106 KeyboardEvent,
1107 CustomEvent: CustomEvent2,
1108 Node,
1109 Comment,
1110 Text,
1111 Element,
1112 HTMLElement,
1113 HTMLHtmlElement,
1114 HTMLSelectElement,
1115 HTMLInputElement,
1116 HTMLTextAreaElement,
1117 HTMLButtonElement,
1118 HTMLOptionElement,
1119 HTMLScriptElement,
1120 SVGElement,
1121 DocumentFragment,
1122 ShadowRoot,
1123 Document,
1124 Window,
1125 customElements
1126} = globalThis.window;
1127var CustomTagConstructors = {};
1128var CustomTagToElementNames = {};
1129var TYPES = {};
1130var CUSTOM_TYPES = {};
1131function get_document() {
1132 return globalThis.document;
1133}
1134function use_window() {
1135 return true;
1136}
1137var contextHandler = {
1138 get(target, name) {
1139 let ctx = target;
1140 let val = void 0;
1141 while (ctx && val == void 0) {
1142 if (ctx = ctx[φ14]) {
1143 val = ctx[name];
1144 }
1145 ;
1146 }
1147 ;
1148 return val;
1149 }
1150};
1151var Extend$Document$af = class {
1152 get flags() {
1153 return this.documentElement.flags;
1154 }
1155};
1156extend$__(Document.prototype, Extend$Document$af.prototype);
1157var Extend$Node$ag = class {
1158 get [φ14]() {
1159 return this73] || this.parentNode || this82];
1160 }
1161 get [φ23]() {
1162 return this92] || (this92] = new Proxy(this, contextHandler));
1163 }
11643]() {
1165 return this;
1166 }
1167 replaceWith$(other) {
1168 if (!(other instanceof Node) && other.replace$) {
1169 other.replace$(this);
1170 } else {
1171 this.parentNode.replaceChild(other, this);
1172 }
1173 ;
1174 return other;
1175 }
1176 insertInto$(parent) {
1177 parent.appendChild$(this);
1178 return this;
1179 }
1180 insertBefore$(el, prev) {
1181 return this.insertBefore(el, prev);
1182 }
1183 insertBeforeBegin$(other) {
1184 return this.parentNode.insertBefore(other, this);
1185 }
1186 insertAfterEnd$(other) {
1187 if (this.nextSibling) {
1188 return this.nextSibling.insertBeforeBegin$(other);
1189 } else {
1190 return this.parentNode.appendChild(other);
1191 }
1192 ;
1193 }
1194 insertAfterBegin$(other) {
1195 if (this.childNodes[0]) {
1196 return this.childNodes[0].insertBeforeBegin$(other);
1197 } else {
1198 return this.appendChild(other);
1199 }
1200 ;
1201 }
1202 get [φ42]() {
1203 return this10] || (this10] = globalThis.document.createComment(""));
1204 }
1205 set [φ42](value) {
1206 let prev = this10];
1207 this10] = value;
1208 if (prev && prev != value && prev.parentNode) {
1209 prev.replaceWith$(value);
1210 }
1211 ;
1212 }
121352]() {
1214 let ph = this42];
1215 if (ph.parentNode && ph != this) {
1216 ph.replaceWith$(this);
1217 }
1218 ;
1219 return this;
1220 }
122162](route) {
1222 let ph = this42];
1223 if (this.parentNode && ph != this) {
1224 this.replaceWith$(ph);
1225 }
1226 ;
1227 return this;
1228 }
1229};
1230extend$__(Node.prototype, Extend$Node$ag.prototype);
1231var Extend$Element$ah = class {
1232 log(...params) {
1233 console.log(...params);
1234 return this;
1235 }
1236 emit(name, detail, o = {bubbles: true, cancelable: true}) {
1237 if (detail != void 0) {
1238 o.detail = detail;
1239 }
1240 ;
1241 let event = new CustomEvent2(name, o);
1242 let res = this.dispatchEvent(event);
1243 return event;
1244 }
1245 slot$(name, ctx) {
1246 return this;
1247 }
1248 text$(item) {
1249 this.textContent = item;
1250 return this;
1251 }
1252 insert$(item, f, prev) {
1253 let type = typeof item;
1254 if (type === "undefined" || item === null) {
1255 if (prev && prev instanceof Comment) {
1256 return prev;
1257 }
1258 ;
1259 let el = globalThis.document.createComment("");
1260 prev ? prev.replaceWith$(el) : el.insertInto$(this);
1261 return el;
1262 }
1263 ;
1264 if (item === prev) {
1265 return item;
1266 } else if (type !== "object") {
1267 let res;
1268 let txt = item;
1269 if (f & 128 && f & 256) {
1270 this.textContent = txt;
1271 return;
1272 }
1273 ;
1274 if (prev) {
1275 if (prev instanceof Text) {
1276 prev.textContent = txt;
1277 return prev;
1278 } else {
1279 res = globalThis.document.createTextNode(txt);
1280 prev.replaceWith$(res, this);
1281 return res;
1282 }
1283 ;
1284 } else {
1285 this.appendChild$(res = globalThis.document.createTextNode(txt));
1286 return res;
1287 }
1288 ;
1289 } else {
1290 prev ? prev.replaceWith$(item, this) : item.insertInto$(this);
1291 return item;
1292 }
1293 ;
1294 return;
1295 }
1296 open$() {
1297 return this;
1298 }
1299 close$() {
1300 return this;
1301 }
1302 end$() {
1303 if (this.render) {
1304 this.render();
1305 }
1306 ;
1307 return;
1308 }
1309 get flags() {
1310 if (!this.$flags) {
1311 this.$flags = new Flags(this);
1312 if (this.flag$ == Element.prototype.flag$) {
1313 this.flags$ext = this.className;
1314 }
1315 ;
1316 this.flagDeopt$();
1317 }
1318 ;
1319 return this.$flags;
1320 }
1321 flag$(str) {
1322 let ns = this.flags$ns;
1323 this.className = ns ? ns + (this.flags$ext = str) : this.flags$ext = str;
1324 return;
1325 }
1326 flagDeopt$() {
1327 var self = this;
1328 this.flag$ = this.flagExt$;
1329 this.flagSelf$ = function(str) {
1330 return self.flagSync$(self.flags$own = str);
1331 };
1332 return;
1333 }
1334 flagExt$(str) {
1335 return this.flagSync$(this.flags$ext = str);
1336 }
1337 flagSelf$(str) {
1338 this.flagDeopt$();
1339 return this.flagSelf$(str);
1340 }
1341 flagSync$() {
1342 return this.className = (this.flags$ns || "") + (this.flags$ext || "") + " " + (this.flags$own || "") + " " + (this.$flags || "");
1343 }
1344 set$(key, value) {
1345 let desc = getDeepPropertyDescriptor(this, key, Element);
1346 if (!desc || !desc.set) {
1347 this.setAttribute(key, value);
1348 } else {
1349 this[key] = value;
1350 }
1351 ;
1352 return;
1353 }
1354 get richValue() {
1355 return this.value;
1356 }
1357 set richValue(value) {
1358 this.value = value;
1359 }
1360};
1361extend$__(Element.prototype, Extend$Element$ah.prototype);
1362Element.prototype.appendChild$ = Element.prototype.appendChild;
1363Element.prototype.removeChild$ = Element.prototype.removeChild;
1364Element.prototype.insertBefore$ = Element.prototype.insertBefore;
1365Element.prototype.replaceChild$ = Element.prototype.replaceChild;
1366Element.prototype.setns$ = Element.prototype.setAttributeNS;
1367function createElement(name, parent, flags, text) {
1368 let el = globalThis.document.createElement(name);
1369 if (flags) {
1370 el.className = flags;
1371 }
1372 ;
1373 if (text !== null) {
1374 el.text$(text);
1375 }
1376 ;
1377 if (parent && parent instanceof Node) {
1378 el.insertInto$(parent);
1379 }
1380 ;
1381 return el;
1382}
1383var descriptorCache = {};
1384function getDescriptor(item, key, cache) {
1385 if (!item) {
1386 return cache[key] = null;
1387 }
1388 ;
1389 if (cache[key] !== void 0) {
1390 return cache[key];
1391 }
1392 ;
1393 let desc = Object.getOwnPropertyDescriptor(item, key);
1394 if (desc !== void 0 || item == SVGElement) {
1395 return cache[key] = desc || null;
1396 }
1397 ;
1398 return getDescriptor(Reflect.getPrototypeOf(item), key, cache);
1399}
1400var Extend$SVGElement$ai = class {
1401 set$(key, value) {
1402 var φ114;
1403 let cache = descriptorCache[φ114 = this.nodeName] || (descriptorCache[φ114] = {});
1404 let desc = getDescriptor(this, key, cache);
1405 if (!desc || !desc.set) {
1406 this.setAttribute(key, value);
1407 } else {
1408 this[key] = value;
1409 }
1410 ;
1411 return;
1412 }
1413 flag$(str) {
1414 let ns = this.flags$ns;
1415 this.className.baseVal = ns ? ns + (this.flags$ext = str) : this.flags$ext = str;
1416 return;
1417 }
1418 flagSelf$(str) {
1419 var self = this;
1420 this.flag$ = function(str2) {
1421 return self.flagSync$(self.flags$ext = str2);
1422 };
1423 this.flagSelf$ = function(str2) {
1424 return self.flagSync$(self.flags$own = str2);
1425 };
1426 return this.flagSelf$(str);
1427 }
1428 flagSync$() {
1429 return this.className.baseVal = (this.flags$ns || "") + (this.flags$ext || "") + " " + (this.flags$own || "") + " " + (this.$flags || "");
1430 }
1431};
1432extend$__(SVGElement.prototype, Extend$SVGElement$ai.prototype);
1433var Extend$SVGSVGElement$aj = class {
1434 set src(value) {
1435 if (this122] != value ? (this122] = value, true) : false) {
1436 if (value) {
1437 if (value.adoptNode) {
1438 value.adoptNode(this);
1439 } else if (value.content) {
1440 for (let φ152 = value.attributes, φ132 = 0, φ142 = Object.keys(φ152), φ163 = φ142.length, k, v; φ132 < φ163; φ132++) {
1441 k = φ142132];
1442 v = φ152[k];
1443 this.setAttribute(k, v);
1444 }
1445 ;
1446 this.innerHTML = value.content;
1447 }
1448 ;
1449 }
1450 ;
1451 }
1452 ;
1453 return;
1454 }
1455};
1456extend$__(SVGSVGElement.prototype, Extend$SVGSVGElement$aj.prototype);
1457function createSVGElement(name, parent, flags, text, ctx) {
1458 let el = globalThis.document.createElementNS("http://www.w3.org/2000/svg", name);
1459 if (flags) {
1460 el.className.baseVal = flags;
1461 }
1462 ;
1463 if (parent && parent instanceof Node) {
1464 el.insertInto$(parent);
1465 }
1466 ;
1467 if (text) {
1468 el.textContent = text;
1469 }
1470 ;
1471 return el;
1472}
1473function createComment(text) {
1474 return globalThis.document.createComment(text);
1475}
1476function createFragment() {
1477 return globalThis.document.createDocumentFragment();
1478}
1479var navigator = globalThis.navigator;
1480var vendor = navigator && navigator.vendor || "";
1481var ua = navigator && navigator.userAgent || "";
1482var isSafari = vendor.indexOf("Apple") > -1 || ua.indexOf("CriOS") >= 0 || ua.indexOf("FxiOS") >= 0;
1483var supportsCustomizedBuiltInElements = !isSafari;
1484var CustomDescriptorCache = new Map();
1485var CustomHook = class extends HTMLElement {
1486 connectedCallback() {
1487 if (supportsCustomizedBuiltInElements) {
1488 return this.parentNode.removeChild(this);
1489 } else {
1490 return this.parentNode.connectedCallback();
1491 }
1492 ;
1493 }
1494 disconnectedCallback() {
1495 if (!supportsCustomizedBuiltInElements) {
1496 return this.parentNode.disconnectedCallback();
1497 }
1498 ;
1499 }
1500};
1501window.customElements.define("i-hook", CustomHook);
1502function getCustomDescriptors(el, klass) {
1503 let props = CustomDescriptorCache.get(klass);
1504 if (!props) {
1505 props = {};
1506 let proto = klass.prototype;
1507 let protos = [proto];
1508 while (proto = proto && Object.getPrototypeOf(proto)) {
1509 if (proto.constructor == el.constructor) {
1510 break;
1511 }
1512 ;
1513 protos.unshift(proto);
1514 }
1515 ;
1516 for (let φ173 = 0, φ183 = iter$__3(protos), φ193 = φ183.length; φ173 < φ193; φ173++) {
1517 let item = φ183173];
1518 let desc = Object.getOwnPropertyDescriptors(item);
1519 Object.assign(props, desc);
1520 }
1521 ;
1522 CustomDescriptorCache.set(klass, props);
1523 }
1524 ;
1525 return props;
1526}
1527function createComponent(name, parent, flags, text, ctx) {
1528 let el;
1529 if (typeof name != "string") {
1530 if (name && name.nodeName) {
1531 name = name.nodeName;
1532 }
1533 ;
1534 }
1535 ;
1536 let cmpname = CustomTagToElementNames[name] || name;
1537 if (CustomTagConstructors[name]) {
1538 let cls = CustomTagConstructors[name];
1539 let typ = cls.prototype[φ202];
1540 if (typ && supportsCustomizedBuiltInElements) {
1541 el = globalThis.document.createElement(typ, {is: name});
1542 } else if (cls.create$ && typ) {
1543 el = globalThis.document.createElement(typ);
1544 el.setAttribute("is", cmpname);
1545 let props = getCustomDescriptors(el, cls);
1546 Object.defineProperties(el, props);
1547 el.__slots = {};
1548 el.appendChild(globalThis.document.createElement("i-hook"));
1549 } else if (cls.create$) {
1550 el = cls.create$(el);
1551 el.__slots = {};
1552 } else {
1553 console.warn("could not create tag " + name);
1554 }
1555 ;
1556 } else {
1557 el = globalThis.document.createElement(CustomTagToElementNames[name] || name);
1558 }
1559 ;
1560 el[φ73] = parent;
1561 el[φ3]();
1562 if (text !== null) {
1563 el.slot$("__").text$(text);
1564 }
1565 ;
1566 if (flags || el.flags$ns) {
1567 el.flag$(flags || "");
1568 }
1569 ;
1570 return el;
1571}
1572function getTagType(name, klass) {
1573 if (TYPES[name]) {
1574 return TYPES[name];
1575 }
1576 ;
1577 if (window[klass]) {
1578 return window[klass];
1579 }
1580 ;
1581 if (window[name]) {
1582 return window[name];
1583 }
1584 ;
1585}
1586function getSuperTagType(name, klass, cmp) {
1587 let typ = getTagType(name, klass);
1588 let custom = typ == cmp || typ.prototype instanceof cmp || typ.prototype[φ202];
1589 if (!custom) {
1590 let cls = typ.prototype[φ21];
1591 if (!cls) {
1592 cls = class CustomBuiltInElement extends typ {
1593 constructor() {
1594 super(...arguments);
1595 this.__slots = {};
1596 this.__F = 0;
1597 }
1598 };
1599 typ.prototype[φ21] = cls;
1600 let descriptors = Object.getOwnPropertyDescriptors(cmp.prototype);
1601 Object.defineProperties(cls.prototype, descriptors);
1602 cls.prototype[φ202] = name;
1603 }
1604 ;
1605 return cls;
1606 }
1607 ;
1608 return typ;
1609}
1610function defineTag(name, klass, options = {}) {
1611 TYPES[name] = CUSTOM_TYPES[name] = klass;
1612 klass.nodeName = name;
1613 let componentName = name;
1614 let proto = klass.prototype;
1615 if (name.indexOf("-") == -1) {
1616 componentName = "" + name + "-tag";
1617 CustomTagToElementNames[name] = componentName;
1618 }
1619 ;
1620 let basens = proto._ns_;
1621 if (options.ns) {
1622 let ns = options.ns;
1623 let flags = ns + " " + ns + "_ ";
1624 if (basens) {
1625 flags += proto.flags$ns;
1626 ns += " " + basens;
1627 }
1628 ;
1629 proto._ns_ = ns;
1630 proto.flags$ns = flags;
1631 }
1632 ;
1633 if (proto[φ202]) {
1634 options.extends = proto[φ202];
1635 }
1636 ;
1637 if (options.extends) {
1638 proto[φ202] = options.extends;
1639 CustomTagConstructors[name] = klass;
1640 if (supportsCustomizedBuiltInElements) {
1641 window.customElements.define(componentName, klass, {extends: options.extends});
1642 }
1643 ;
1644 } else {
1645 window.customElements.define(componentName, klass);
1646 }
1647 ;
1648 return klass;
1649}
1650var instance2 = globalThis.imba || (globalThis.imba = {});
1651instance2.document = globalThis.document;
1652
1653// src/imba/dom/fragment.imba
1654function extend$__2(target, ext) {
1655 var descriptors = Object.getOwnPropertyDescriptors(ext);
1656 Object.defineProperties(target, descriptors);
1657 return target;
1658}
1659function iter$__4(a) {
1660 let v;
1661 return a ? (v = a.toIterable) ? v.call(a) : a : [];
1662}
1663var φ15 = Symbol.for("#parent");
1664var φ24 = Symbol.for("##up");
1665var φ32 = Symbol.for("##parent");
1666var Extend$DocumentFragment$af = class {
1667 get [φ15]() {
1668 return this24] || this32];
1669 }
1670 setup$(flags, options) {
1671 this.$start = createComment("start");
1672 this.$end = createComment("end");
1673 this.$end.replaceWith$ = function(other) {
1674 this.parentNode.insertBefore(other, this);
1675 return other;
1676 };
1677 this.appendChild(this.$start);
1678 return this.appendChild(this.$end);
1679 }
1680 text$(item) {
1681 if (!this.$text) {
1682 this.$text = this.insert$(item);
1683 } else {
1684 this.$text.textContent = item;
1685 }
1686 ;
1687 return;
1688 }
1689 insert$(item, options, toReplace) {
1690 if (this32]) {
1691 return this32].insert$(item, options, toReplace || this.$end);
1692 } else {
1693 return Element.prototype.insert$.call(this, item, options, toReplace || this.$end);
1694 }
1695 ;
1696 }
1697 insertInto$(parent, before) {
1698 if (!this32]) {
1699 this32] = parent;
1700 parent.appendChild$(this);
1701 }
1702 ;
1703 return this;
1704 }
1705 replaceWith$(other, parent) {
1706 this.$start.insertBeforeBegin$(other);
1707 var el = this.$start;
1708 while (el) {
1709 let next = el.nextSibling;
1710 this.appendChild(el);
1711 if (el == this.$end) {
1712 break;
1713 }
1714 ;
1715 el = next;
1716 }
1717 ;
1718 return other;
1719 }
1720 appendChild$(child) {
1721 this.$end ? this.$end.insertBeforeBegin$(child) : this.appendChild(child);
1722 return child;
1723 }
1724 removeChild$(child) {
1725 child.parentNode && child.parentNode.removeChild(child);
1726 return this;
1727 }
1728 isEmpty$() {
1729 let el = this.$start;
1730 let end = this.$end;
1731 while (el = el.nextSibling) {
1732 if (el == end) {
1733 break;
1734 }
1735 ;
1736 if (el instanceof Element || el instanceof Text) {
1737 return false;
1738 }
1739 ;
1740 }
1741 ;
1742 return true;
1743 }
1744};
1745extend$__2(DocumentFragment.prototype, Extend$DocumentFragment$af.prototype);
1746var VirtualFragment = class {
1747 constructor(f, parent) {
1748 this.__F = f;
1749 this15] = parent;
1750 }
1751 appendChild$(item, index) {
1752 if (this.$end && this15]) {
1753 this.$end.insertBeforeBegin$(item);
1754 } else if (this15]) {
1755 this15].appendChild$(item);
1756 }
1757 ;
1758 return;
1759 }
1760 replaceWith$(other) {
1761 this.detachNodes();
1762 this.$end.insertBeforeBegin$(other);
1763 this15].removeChild$(this.$end);
1764 this15] = null;
1765 return;
1766 }
1767 joinBefore$(before) {
1768 return this.insertInto$(before.parentNode, before);
1769 }
1770 insertInto$(parent, before) {
1771 if (!this15]) {
1772 this15] = parent;
1773 before ? before.insertBeforeBegin$(this.$end) : parent.appendChild$(this.$end);
1774 this.attachNodes();
1775 }
1776 ;
1777 return this;
1778 }
1779 replace$(other) {
1780 if (!this15]) {
1781 this15] = other.parentNode;
1782 }
1783 ;
1784 other.replaceWith$(this.$end);
1785 this.attachNodes();
1786 return this;
1787 }
1788 setup() {
1789 return this;
1790 }
1791};
1792var KeyedTagFragment = class extends VirtualFragment {
1793 constructor(f, parent) {
1794 super(...arguments);
1795 if (!(f & 128)) {
1796 this.$start = createComment("start");
1797 if (parent) {
1798 parent.appendChild$(this.$start);
1799 }
1800 ;
1801 }
1802 ;
1803 if (!(f & 256)) {
1804 this.$end = createComment("end");
1805 if (parent) {
1806 parent.appendChild$(this.$end);
1807 }
1808 ;
1809 }
1810 ;
1811 this.setup();
1812 }
1813 setup() {
1814 this.array = [];
1815 this.changes = new Map();
1816 this.dirty = false;
1817 return this.$ = {};
1818 }
1819 push(item, idx) {
1820 if (!(this.__F & 1)) {
1821 this.array.push(item);
1822 this.appendChild$(item);
1823 return;
1824 }
1825 ;
1826 let toReplace = this.array[idx];
1827 if (toReplace === item) {
1828 true;
1829 } else {
1830 this.dirty = true;
1831 let prevIndex = this.array.indexOf(item);
1832 let changed = this.changes.get(item);
1833 if (prevIndex === -1) {
1834 this.array.splice(idx, 0, item);
1835 this.insertChild(item, idx);
1836 } else if (prevIndex === idx + 1) {
1837 if (toReplace) {
1838 this.changes.set(toReplace, -1);
1839 }
1840 ;
1841 this.array.splice(idx, 1);
1842 } else {
1843 if (prevIndex >= 0) {
1844 this.array.splice(prevIndex, 1);
1845 }
1846 ;
1847 this.array.splice(idx, 0, item);
1848 this.insertChild(item, idx);
1849 }
1850 ;
1851 if (changed == -1) {
1852 this.changes.delete(item);
1853 }
1854 ;
1855 }
1856 ;
1857 return;
1858 }
1859 insertChild(item, index) {
1860 if (index > 0) {
1861 let other = this.array[index - 1];
1862 other.insertAfterEnd$(item);
1863 } else if (this.$start) {
1864 this.$start.insertAfterEnd$(item);
1865 } else {
1866 this15].insertAfterBegin$(item);
1867 }
1868 ;
1869 return;
1870 }
1871 removeChild(item, index) {
1872 if (item.parentNode == this15]) {
1873 this15].removeChild(item);
1874 }
1875 ;
1876 return;
1877 }
1878 attachNodes() {
1879 for (let i = 0, φ45 = iter$__4(this.array), φ56 = φ45.length; i < φ56; i++) {
1880 let item = φ45[i];
1881 this.$end.insertBeforeBegin$(item);
1882 }
1883 ;
1884 return;
1885 }
1886 detachNodes() {
1887 for (let φ65 = 0, φ75 = iter$__4(this.array), φ84 = φ75.length; φ65 < φ84; φ65++) {
1888 let item = φ7565];
1889 this15].removeChild(item);
1890 }
1891 ;
1892 return;
1893 }
1894 end$(index) {
1895 var self = this;
1896 if (!(this.__F & 1)) {
1897 this.__F |= 1;
1898 return;
1899 }
1900 ;
1901 if (this.dirty) {
1902 this.changes.forEach(function(pos, item) {
1903 if (pos == -1) {
1904 return self.removeChild(item);
1905 }
1906 ;
1907 });
1908 this.changes.clear();
1909 this.dirty = false;
1910 }
1911 ;
1912 if (this.array.length > index) {
1913 while (this.array.length > index) {
1914 let item = this.array.pop();
1915 this.removeChild(item);
1916 }
1917 ;
1918 }
1919 ;
1920 return;
1921 }
1922};
1923var IndexedTagFragment = class extends VirtualFragment {
1924 constructor(f, parent) {
1925 super(...arguments);
1926 if (!(f & 256)) {
1927 this.$end = createComment("end");
1928 if (parent) {
1929 parent.appendChild$(this.$end);
1930 }
1931 ;
1932 }
1933 ;
1934 this.setup();
1935 }
1936 setup() {
1937 this.$ = [];
1938 return this.length = 0;
1939 }
1940 end$(len) {
1941 let from = this.length;
1942 if (from == len || !this15]) {
1943 return;
1944 }
1945 ;
1946 let array = this.$;
1947 let par = this15];
1948 if (from > len) {
1949 while (from > len) {
1950 par.removeChild$(array[--from]);
1951 }
1952 ;
1953 } else if (len > from) {
1954 while (len > from) {
1955 this.appendChild$(array[from++]);
1956 }
1957 ;
1958 }
1959 ;
1960 this.length = len;
1961 return;
1962 }
1963 attachNodes() {
1964 for (let i = 0, φ94 = iter$__4(this.$), φ105 = φ94.length; i < φ105; i++) {
1965 let item = φ94[i];
1966 if (i == this.length) {
1967 break;
1968 }
1969 ;
1970 this.$end.insertBeforeBegin$(item);
1971 }
1972 ;
1973 return;
1974 }
1975 detachNodes() {
1976 let i = 0;
1977 while (i < this.length) {
1978 let item = this.$[i++];
1979 this15].removeChild$(item);
1980 }
1981 ;
1982 return;
1983 }
1984};
1985function createLiveFragment(bitflags, options, par) {
1986 const el = createFragment();
1987 el.setup$(bitflags, options);
1988 if (par) {
1989 el[φ24] = par;
1990 }
1991 ;
1992 return el;
1993}
1994function createIndexedFragment(bitflags, parent) {
1995 return new IndexedTagFragment(bitflags, parent);
1996}
1997function createKeyedFragment(bitflags, parent) {
1998 return new KeyedTagFragment(bitflags, parent);
1999}
2000
2001// src/imba/dom/component.imba
2002function iter$__5(a) {
2003 let v;
2004 return a ? (v = a.toIterable) ? v.call(a) : a : [];
2005}
2006var φ16 = Symbol.for("#init");
2007var φ53 = Symbol.for("#count");
2008var φ102 = Symbol.for("#autorender");
2009var hydrator = new class {
2010 constructor($$ = null) {
2011 this16]($$);
2012 }
201316]($$ = null) {
2014 var φ210;
2015 this.items = $$ && (φ210 = $$.items) !== void 0 ? φ210 : [];
2016 this.current = $$ && (φ210 = $$.current) !== void 0 ? φ210 : null;
2017 this.lastQueued = $$ && (φ210 = $$.lastQueued) !== void 0 ? φ210 : null;
2018 this.tests = $$ && (φ210 = $$.tests) !== void 0 ? φ210 : 0;
2019 }
2020 flush() {
2021 let item = null;
2022 if (false) {
2023 }
2024 ;
2025 while (item = this.items.shift()) {
2026 if (!item.parentNode || item.hydratedΦ) {
2027 continue;
2028 }
2029 ;
2030 let prev = this.current;
2031 this.current = item;
2032 item.__F |= 1024;
2033 item.connectedCallback();
2034 this.current = prev;
2035 }
2036 ;
2037 return;
2038 }
2039 queue(item) {
2040 var self = this;
2041 let len = this.items.length;
2042 let idx = 0;
2043 let prev = this.lastQueued;
2044 this.lastQueued = item;
2045 let BEFORE = Node.DOCUMENT_POSITION_PRECEDING;
2046 let AFTER = Node.DOCUMENT_POSITION_FOLLOWING;
2047 if (len) {
2048 let prevIndex = this.items.indexOf(prev);
2049 let index = prevIndex;
2050 let compare = function(a, b) {
2051 self.tests++;
2052 return a.compareDocumentPosition(b);
2053 };
2054 if (prevIndex == -1 || prev.nodeName != item.nodeName) {
2055 index = prevIndex = 0;
2056 }
2057 ;
2058 let curr = this.items[index];
2059 while (curr && compare(curr, item) & AFTER) {
2060 curr = this.items[++index];
2061 }
2062 ;
2063 if (index != prevIndex) {
2064 curr ? this.items.splice(index, 0, item) : this.items.push(item);
2065 } else {
2066 while (curr && compare(curr, item) & BEFORE) {
2067 curr = this.items[--index];
2068 }
2069 ;
2070 if (index != prevIndex) {
2071 curr ? this.items.splice(index + 1, 0, item) : this.items.unshift(item);
2072 }
2073 ;
2074 }
2075 ;
2076 } else {
2077 this.items.push(item);
2078 if (!this.current) {
2079 globalThis.queueMicrotask(this.flush.bind(this));
2080 }
2081 ;
2082 }
2083 ;
2084 return;
2085 }
2086 run(item) {
2087 var φ84, φ65;
2088 if (this.active) {
2089 return;
2090 }
2091 ;
2092 this.active = true;
2093 let all = globalThis.document.querySelectorAll(".__ssr");
2094 console.log("running hydrator", item, all.length, Array.from(all));
2095 for (let φ35 = 0, φ45 = iter$__5(all), φ75 = φ45.length; φ35 < φ75; φ35++) {
2096 let item2 = φ4535];
2097 item2[φ53] || (item2[φ53] = 1);
2098 item2[φ53]++;
2099 let name = item2.nodeName;
2100 let typ = (φ65 = this.map)[name] || (φ65[name] = globalThis.window.customElements.get(name.toLowerCase()) || HTMLElement);
2101 console.log("item type", name, typ, !!CUSTOM_TYPES[name.toLowerCase()]);
2102 if (!item2.connectedCallback || !item2.parentNode || item2.hydratedΦ) {
2103 continue;
2104 }
2105 ;
2106 console.log("hydrate", item2);
2107 }
2108 ;
2109 return this.active = false;
2110 }
2111}();
2112function hydrate() {
2113 return hydrator.flush();
2114}
2115var ImbaElement = class extends HTMLElement {
2116 constructor() {
2117 super();
2118 if (this.flags$ns) {
2119 this.flag$ = this.flagExt$;
2120 }
2121 ;
2122 this.setup$();
2123 this.build();
2124 }
2125 setup$() {
2126 this.__slots = {};
2127 return this.__F = 0;
2128 }
212916]() {
2130 this.__F |= 1 | 2;
2131 return this;
2132 }
2133 flag$(str) {
2134 this.className = this.flags$ext = str;
2135 return;
2136 }
2137 slot$(name, ctx) {
2138 var φ94;
2139 if (name == "__" && !this.render) {
2140 return this;
2141 }
2142 ;
2143 return94 = this.__slots)[name] || (φ94[name] = createLiveFragment(0, null, this));
2144 }
2145 build() {
2146 return this;
2147 }
2148 awaken() {
2149 return this;
2150 }
2151 mount() {
2152 return this;
2153 }
2154 unmount() {
2155 return this;
2156 }
2157 rendered() {
2158 return this;
2159 }
2160 dehydrate() {
2161 return this;
2162 }
2163 hydrate() {
2164 this.autoschedule = true;
2165 return this;
2166 }
2167 tick() {
2168 return this.commit();
2169 }
2170 visit() {
2171 return this.commit();
2172 }
2173 commit() {
2174 if (!this.renderΦ) {
2175 this.__F |= 8192;
2176 return this;
2177 }
2178 ;
2179 this.__F |= 256;
2180 this.render && this.render();
2181 this.rendered();
2182 return this.__F = (this.__F | 512) & ~256 & ~8192;
2183 }
2184 get autoschedule() {
2185 return (this.__F & 64) != 0;
2186 }
2187 set autoschedule(value) {
2188 value ? this.__F |= 64 : this.__F &= ~64;
2189 }
2190 set autorender(value) {
2191 let o = this102] || (this102] = {});
2192 o.value = value;
2193 if (this.mountedΦ) {
2194 scheduler.schedule(this, o);
2195 }
2196 ;
2197 return;
2198 }
2199 get renderΦ() {
2200 return !this.suspendedΦ;
2201 }
2202 get mountingΦ() {
2203 return (this.__F & 16) != 0;
2204 }
2205 get mountedΦ() {
2206 return (this.__F & 32) != 0;
2207 }
2208 get awakenedΦ() {
2209 return (this.__F & 8) != 0;
2210 }
2211 get renderedΦ() {
2212 return (this.__F & 512) != 0;
2213 }
2214 get suspendedΦ() {
2215 return (this.__F & 4096) != 0;
2216 }
2217 get renderingΦ() {
2218 return (this.__F & 256) != 0;
2219 }
2220 get scheduledΦ() {
2221 return (this.__F & 128) != 0;
2222 }
2223 get hydratedΦ() {
2224 return (this.__F & 2) != 0;
2225 }
2226 get ssrΦ() {
2227 return (this.__F & 1024) != 0;
2228 }
2229 schedule() {
2230 scheduler.on("commit", this);
2231 this.__F |= 128;
2232 return this;
2233 }
2234 unschedule() {
2235 scheduler.un("commit", this);
2236 this.__F &= ~128;
2237 return this;
2238 }
2239 async suspend(cb = null) {
2240 let val = this.flags.incr("_suspended_");
2241 this.__F |= 4096;
2242 if (cb instanceof Function) {
2243 await cb();
2244 this.unsuspend();
2245 }
2246 ;
2247 return this;
2248 }
2249 unsuspend() {
2250 let val = this.flags.decr("_suspended_");
2251 if (val == 0) {
2252 this.__F &= ~4096;
2253 this.commit();
2254 }
2255 ;
2256 return this;
2257 }
2258 end$() {
2259 return this.visit();
2260 }
2261 open$() {
2262 if (this.__F & 1024) {
2263 this.__F = this.__F & ~1024;
2264 this.classList.remove("_ssr_");
2265 if (this.flags$ext && this.flags$ext.indexOf("_ssr_") == 0) {
2266 this.flags$ext = this.flags$ext.slice(5);
2267 }
2268 ;
2269 if (!(this.__F & 512)) {
2270 this.innerHTML = "";
2271 }
2272 ;
2273 }
2274 ;
2275 return this;
2276 }
2277 connectedCallback() {
2278 let flags = this.__F;
2279 let inited = flags & 1;
2280 let awakened = flags & 8;
2281 if (!inited && !(flags & 1024)) {
2282 hydrator.queue(this);
2283 return;
2284 }
2285 ;
2286 if (flags & (16 | 32)) {
2287 return;
2288 }
2289 ;
2290 this.__F |= 16;
2291 if (!inited) {
2292 this16]();
2293 }
2294 ;
2295 if (!(flags & 2)) {
2296 this.flags$ext = this.className;
2297 this.__F |= 2;
2298 this.hydrate();
2299 this.commit();
2300 }
2301 ;
2302 if (!awakened) {
2303 this.awaken();
2304 this.__F |= 8;
2305 }
2306 ;
2307 let res = this.mount();
2308 if (res && res.then instanceof Function) {
2309 res.then(scheduler.commit);
2310 }
2311 ;
2312 flags = this.__F = (this.__F | 32) & ~16;
2313 if (flags & 64) {
2314 this.schedule();
2315 }
2316 ;
2317 if (this102]) {
2318 scheduler.schedule(this, this102]);
2319 }
2320 ;
2321 return this;
2322 }
2323 disconnectedCallback() {
2324 this.__F = this.__F & (~32 & ~16);
2325 if (this.__F & 128) {
2326 this.unschedule();
2327 }
2328 ;
2329 this.unmount();
2330 if (this102]) {
2331 return scheduler.unschedule(this, this102]);
2332 }
2333 ;
2334 }
2335};
2336
2337// src/imba/dom/styles.imba
2338function extend$__3(target, ext) {
2339 var descriptors = Object.getOwnPropertyDescriptors(ext);
2340 Object.defineProperties(target, descriptors);
2341 return target;
2342}
2343var φ17 = Symbol.for("#init");
2344var VALID_CSS_UNITS = {
2345 cm: 1,
2346 mm: 1,
2347 Q: 1,
2348 pc: 1,
2349 pt: 1,
2350 px: 1,
2351 em: 1,
2352 ex: 1,
2353 ch: 1,
2354 rem: 1,
2355 vw: 1,
2356 vh: 1,
2357 vmin: 1,
2358 vmax: 1,
2359 s: 1,
2360 ms: 1,
2361 fr: 1,
2362 "%": 1,
2363 in: 1,
2364 turn: 1,
2365 grad: 1,
2366 rad: 1,
2367 deg: 1,
2368 Hz: 1,
2369 kHz: 1
2370};
2371var CSS_STR_PROPS = {
2372 prefix: 1,
2373 suffix: 1,
2374 content: 1
2375};
2376var CSS_COLORS = {
2377 rose: [[356, 100, 97], [356, 100, 95], [353, 96, 90], [353, 96, 82], [351, 95, 71], [350, 89, 60], [347, 77, 50], [345, 83, 41], [343, 80, 35], [342, 75, 30]],
2378 pink: [[327, 73, 97], [326, 78, 95], [326, 85, 90], [327, 87, 82], [329, 86, 70], [330, 81, 60], [333, 71, 51], [335, 78, 42], [336, 74, 35], [336, 69, 30]],
2379 fuchsia: [[289, 100, 98], [287, 100, 95], [288, 96, 91], [291, 93, 83], [292, 91, 73], [292, 84, 61], [293, 69, 49], [295, 72, 40], [295, 70, 33], [297, 64, 28]],
2380 purple: [[270, 100, 98], [269, 100, 95], [269, 100, 92], [269, 97, 85], [270, 95, 75], [271, 91, 65], [271, 81, 56], [272, 72, 47], [273, 67, 39], [274, 66, 32]],
2381 violet: [[250, 100, 98], [251, 91, 95], [251, 95, 92], [252, 95, 85], [255, 92, 76], [258, 90, 66], [262, 83, 58], [263, 70, 50], [263, 69, 42], [264, 67, 35]],
2382 indigo: [[226, 100, 97], [226, 100, 94], [228, 96, 89], [230, 94, 82], [234, 89, 74], [239, 84, 67], [243, 75, 59], [245, 58, 51], [244, 55, 41], [242, 47, 34]],
2383 blue: [[214, 100, 97], [214, 95, 93], [213, 97, 87], [212, 96, 78], [213, 94, 68], [217, 91, 60], [221, 83, 53], [224, 76, 48], [226, 71, 40], [224, 64, 33]],
2384 sky: [[204, 100, 97], [204, 94, 94], [201, 94, 86], [199, 95, 74], [198, 93, 60], [199, 89, 48], [200, 98, 39], [201, 96, 32], [201, 90, 27], [202, 80, 24]],
2385 cyan: [[183, 100, 96], [185, 96, 90], [186, 94, 82], [187, 92, 69], [188, 86, 53], [189, 94, 43], [192, 91, 36], [193, 82, 31], [194, 70, 27], [196, 64, 24]],
2386 teal: [[166, 76, 97], [167, 85, 89], [168, 84, 78], [171, 77, 64], [172, 66, 50], [173, 80, 40], [175, 84, 32], [175, 77, 26], [176, 69, 22], [176, 61, 19]],
2387 emerald: [[152, 81, 96], [149, 80, 90], [152, 76, 80], [156, 72, 67], [158, 64, 52], [160, 84, 39], [161, 94, 30], [163, 94, 24], [163, 88, 20], [164, 86, 16]],
2388 green: [[138, 76, 97], [141, 84, 93], [141, 79, 85], [142, 77, 73], [142, 69, 58], [142, 71, 45], [142, 76, 36], [142, 72, 29], [143, 64, 24], [144, 61, 20]],
2389 lime: [[78, 92, 95], [80, 89, 89], [81, 88, 80], [82, 85, 67], [83, 78, 55], [84, 81, 44], [85, 85, 35], [86, 78, 27], [86, 69, 23], [88, 61, 20]],
2390 yellow: [[55, 92, 95], [55, 97, 88], [53, 98, 77], [50, 98, 64], [48, 96, 53], [45, 93, 47], [41, 96, 40], [35, 92, 33], [32, 81, 29], [28, 73, 26]],
2391 amber: [[48, 100, 96], [48, 96, 89], [48, 97, 77], [46, 97, 65], [43, 96, 56], [38, 92, 50], [32, 95, 44], [26, 90, 37], [23, 83, 31], [22, 78, 26]],
2392 orange: [[33, 100, 96], [34, 100, 92], [32, 98, 83], [31, 97, 72], [27, 96, 61], [25, 95, 53], [21, 90, 48], [17, 88, 40], [15, 79, 34], [15, 75, 28]],
2393 red: [[0, 86, 97], [0, 93, 94], [0, 96, 89], [0, 94, 82], [0, 91, 71], [0, 84, 60], [0, 72, 51], [0, 74, 42], [0, 70, 35], [0, 63, 31]],
2394 warmer: [[60, 9, 98], [60, 5, 96], [20, 6, 90], [24, 6, 83], [24, 5, 64], [25, 5, 45], [33, 5, 32], [30, 6, 25], [12, 6, 15], [24, 10, 10]],
2395 warm: [[0, 0, 98], [0, 0, 96], [0, 0, 90], [0, 0, 83], [0, 0, 64], [0, 0, 45], [0, 0, 32], [0, 0, 25], [0, 0, 15], [0, 0, 9]],
2396 gray: [[0, 0, 98], [240, 5, 96], [240, 6, 90], [240, 5, 84], [240, 5, 65], [240, 4, 46], [240, 5, 34], [240, 5, 26], [240, 4, 16], [240, 6, 10]],
2397 cool: [[210, 20, 98], [220, 14, 96], [220, 13, 91], [216, 12, 84], [218, 11, 65], [220, 9, 46], [215, 14, 34], [217, 19, 27], [215, 28, 17], [221, 39, 11]],
2398 cooler: [[210, 40, 98], [210, 40, 96], [214, 32, 91], [213, 27, 84], [215, 20, 65], [215, 16, 47], [215, 19, 35], [215, 25, 27], [217, 33, 17], [222, 47, 11]]
2399};
2400var CSS_COLORS_REGEX = new RegExp("^(" + Object.keys(CSS_COLORS).join("|") + ")(\\d+(?:\\.\\d+)?)$");
2401var CSS_PX_PROPS = /^([xyz])$/;
2402var CSS_DIM_PROPS = /^([tlbr]|size|[whtlbr]|[mps][tlbrxy]?|[rcxy]?[gs])$/;
2403var resets = "*,::before,::after {\nbox-sizing: border-box;\nborder-width: 0;\nborder-style: solid;\nborder-color: currentColor;\n}";
2404var Styles = class {
2405 constructor($$ = null) {
2406 this17]($$);
2407 }
240817]($$ = null) {
2409 var φ210;
2410 this.entries = $$ && (φ210 = $$.entries) !== void 0 ? φ210 : {};
2411 }
2412 register(id, styles2) {
2413 let entry = this.entries[id];
2414 if (!entry) {
2415 entry = this.entries[id] = {sourceId: id, css: styles2};
2416 if (!this.entries.resets) {
2417 this.register("resets", resets);
2418 }
2419 ;
2420 entry.node = globalThis.document.createElement("style");
2421 entry.node.setAttribute("data-id", id);
2422 entry.node.textContent = entry.css;
2423 globalThis.document.head.appendChild(entry.node);
2424 } else if (entry) {
2425 entry.css = styles2;
2426 if (entry.node) {
2427 entry.node.textContent = styles2;
2428 }
2429 ;
2430 }
2431 ;
2432 return;
2433 }
2434 toString() {
2435 return Object.values(this.entries).map(function(_0) {
2436 return _0.css;
2437 }).join("\n\n");
2438 }
2439 toValue(value, unit, key, param = null) {
2440 let colormatch;
2441 if (CSS_STR_PROPS[key]) {
2442 value = String(value);
2443 }
2444 ;
2445 let typ = typeof value;
2446 if (typ == "number") {
2447 if (!unit) {
2448 if (CSS_PX_PROPS.test(key)) {
2449 unit = "px";
2450 } else if (CSS_DIM_PROPS.test(key)) {
2451 unit = "u";
2452 } else if (key == "rotate") {
2453 unit = "turn";
2454 value = value.toFixed(4);
2455 }
2456 ;
2457 }
2458 ;
2459 if (unit) {
2460 if (VALID_CSS_UNITS[unit]) {
2461 return value + unit;
2462 } else if (unit == "u") {
2463 return value * 4 + "px";
2464 } else {
2465 return "calc(var(--u_" + unit + ",1px) * " + value + ")";
2466 }
2467 ;
2468 } else {
2469 true;
2470 }
2471 ;
2472 } else if (typ == "string") {
2473 if (key && CSS_STR_PROPS[key] && value[0] != '"' && value[0] != "'") {
2474 if (value.indexOf('"') >= 0) {
2475 if (value.indexOf("'") == -1) {
2476 value = "'" + value + "'";
2477 } else {
2478 false;
2479 }
2480 ;
2481 } else {
2482 value = '"' + value + '"';
2483 }
2484 ;
2485 }
2486 ;
2487 if (colormatch = value.match(CSS_COLORS_REGEX)) {
2488 let color = CSS_COLORS[colormatch[1]];
2489 let level = color[parseInt(colormatch[2])];
2490 let a = "100%";
2491 if (typeof param == "number") {
2492 a = param + "%";
2493 } else if (typeof param == "string") {
2494 a = param;
2495 }
2496 ;
2497 if (level) {
2498 return "hsla(" + level[0] + "," + level[1] + "%," + level[2] + "%," + a + ")";
2499 }
2500 ;
2501 }
2502 ;
2503 } else if (value && value.toStyleString instanceof Function) {
2504 return value.toStyleString();
2505 }
2506 ;
2507 return value;
2508 }
2509 parseDimension(val) {
2510 if (typeof val == "string") {
2511 let [m, num, unit] = val.match(/^([-+]?[\d\.]+)(%|\w+)$/);
2512 return [parseFloat(num), unit];
2513 } else if (typeof val == "number") {
2514 return [val];
2515 }
2516 ;
2517 }
2518};
2519var styles = new Styles();
2520var colors = Object.keys(CSS_COLORS);
2521function use_styles() {
2522 return true;
2523}
2524var Extend$Element$af = class {
2525 css$(key, value, mods) {
2526 return this.style[key] = value;
2527 }
2528 css$var(name, value, unit, key, param = null) {
2529 let cssval = styles.toValue(value, unit, key, param);
2530 this.style.setProperty(name, cssval);
2531 return;
2532 }
2533};
2534extend$__3(Element.prototype, Extend$Element$af.prototype);
2535
2536// src/imba/dom/context.imba
2537var renderContext = {
2538 context: null
2539};
2540
2541// src/imba/dom/mount.imba
2542function render(blk, ctx = {}) {
2543 let prev = renderContext.context;
2544 renderContext.context = ctx;
2545 let res = blk(ctx);
2546 if (renderContext.context == ctx) {
2547 renderContext.context = prev;
2548 }
2549 ;
2550 return res;
2551}
2552function mount(mountable, into) {
2553 let parent = into || globalThis.document.body;
2554 let element = mountable;
2555 if (mountable instanceof Function) {
2556 let ctx = {_: parent};
2557 let tick = function() {
2558 let prev = renderContext.context;
2559 renderContext.context = ctx;
2560 let res = mountable(ctx);
2561 if (renderContext.context == ctx) {
2562 renderContext.context = prev;
2563 }
2564 ;
2565 return res;
2566 };
2567 element = tick();
2568 scheduler.listen("commit", tick);
2569 } else {
2570 element.__F |= 64;
2571 }
2572 ;
2573 return parent.appendChild(element);
2574}
2575
2576// src/imba/dom/bind.imba
2577function extend$__4(target, ext) {
2578 var descriptors = Object.getOwnPropertyDescriptors(ext);
2579 Object.defineProperties(target, descriptors);
2580 return target;
2581}
2582function iter$__6(a) {
2583 let v;
2584 return a ? (v = a.toIterable) ? v.call(a) : a : [];
2585}
2586function use_dom_bind() {
2587 return true;
2588}
2589var toBind = {
2590 INPUT: true,
2591 SELECT: true,
2592 TEXTAREA: true,
2593 BUTTON: true
2594};
2595var isGroup = function(obj) {
2596 return obj instanceof Array || obj && obj.has instanceof Function;
2597};
2598var bindHas = function(object, value) {
2599 if (object == value) {
2600 return true;
2601 } else if (object instanceof Array) {
2602 return object.indexOf(value) >= 0;
2603 } else if (object && object.has instanceof Function) {
2604 return object.has(value);
2605 } else if (object && object.contains instanceof Function) {
2606 return object.contains(value);
2607 } else {
2608 return false;
2609 }
2610 ;
2611};
2612var bindAdd = function(object, value) {
2613 if (object instanceof Array) {
2614 return object.push(value);
2615 } else if (object && object.add instanceof Function) {
2616 return object.add(value);
2617 }
2618 ;
2619};
2620var bindRemove = function(object, value) {
2621 if (object instanceof Array) {
2622 let idx = object.indexOf(value);
2623 if (idx >= 0) {
2624 return object.splice(idx, 1);
2625 }
2626 ;
2627 } else if (object && object.delete instanceof Function) {
2628 return object.delete(value);
2629 }
2630 ;
2631};
2632function createProxyProperty(target) {
2633 function getter() {
2634 return target[0] ? target[0][target[1]] : void 0;
2635 }
2636 ;
2637 function setter(v) {
2638 return target[0] ? target[0][target[1]] = v : null;
2639 }
2640 ;
2641 return {
2642 get: getter,
2643 set: setter
2644 };
2645}
2646var Extend$Element$af2 = class {
2647 getRichValue() {
2648 return this.value;
2649 }
2650 setRichValue(value) {
2651 return this.value = value;
2652 }
2653 bind$(key, value) {
2654 let o = value || [];
2655 if (key == "data" && !this.$$bound && toBind[this.nodeName]) {
2656 this.$$bound = true;
2657 if (this.change$) {
2658 this.addEventListener("change", this.change$ = this.change$.bind(this));
2659 }
2660 ;
2661 if (this.input$) {
2662 this.addEventListener("input", this.input$ = this.input$.bind(this), {capture: true});
2663 }
2664 ;
2665 if (this.click$) {
2666 this.addEventListener("click", this.click$ = this.click$.bind(this), {capture: true});
2667 }
2668 ;
2669 }
2670 ;
2671 Object.defineProperty(this, key, o instanceof Array ? createProxyProperty(o) : o);
2672 return o;
2673 }
2674};
2675extend$__4(Element.prototype, Extend$Element$af2.prototype);
2676Object.defineProperty(Element.prototype, "richValue", {
2677 get: function() {
2678 return this.getRichValue();
2679 },
2680 set: function(v) {
2681 return this.setRichValue(v);
2682 }
2683});
2684var Extend$HTMLSelectElement$ag = class {
2685 change$(e) {
2686 let model = this.data;
2687 let prev = this.$$value;
2688 this.$$value = void 0;
2689 let values = this.getRichValue();
2690 if (this.multiple) {
2691 if (prev) {
2692 for (let φ114 = 0, φ210 = iter$__6(prev), φ35 = φ210.length; φ114 < φ35; φ114++) {
2693 let value = φ210114];
2694 if (values.indexOf(value) != -1) {
2695 continue;
2696 }
2697 ;
2698 bindRemove(model, value);
2699 }
2700 ;
2701 }
2702 ;
2703 for (let φ45 = 0, φ56 = iter$__6(values), φ65 = φ56.length; φ45 < φ65; φ45++) {
2704 let value = φ5645];
2705 if (!prev || prev.indexOf(value) == -1) {
2706 bindAdd(model, value);
2707 }
2708 ;
2709 }
2710 ;
2711 } else {
2712 this.data = values[0];
2713 }
2714 ;
2715 commit();
2716 return this;
2717 }
2718 getRichValue() {
2719 var φ75;
2720 if (this.$$value) {
2721 return this.$$value;
2722 }
2723 ;
2724 φ75 = [];
2725 for (let φ84 = 0, φ94 = iter$__6(this.selectedOptions), φ105 = φ94.length; φ84 < φ105; φ84++) {
2726 let o = φ9484];
2727 φ75.push(o.richValue);
2728 }
2729 ;
2730 return this.$$value = φ75;
2731 }
2732 syncValue() {
2733 let model = this.data;
2734 if (this.multiple) {
2735 let vals = [];
2736 for (let i = 0, φ114 = iter$__6(this.options), φ123 = φ114.length; i < φ123; i++) {
2737 let option = φ114[i];
2738 let val = option.richValue;
2739 let sel = bindHas(model, val);
2740 option.selected = sel;
2741 if (sel) {
2742 vals.push(val);
2743 }
2744 ;
2745 }
2746 ;
2747 this.$$value = vals;
2748 } else {
2749 for (let i = 0, φ132 = iter$__6(this.options), φ142 = φ132.length; i < φ142; i++) {
2750 let option = φ132[i];
2751 let val = option.richValue;
2752 if (val == model) {
2753 this.$$value = [val];
2754 this.selectedIndex = i;
2755 break;
2756 }
2757 ;
2758 }
2759 ;
2760 }
2761 ;
2762 return;
2763 }
2764 end$() {
2765 return this.syncValue();
2766 }
2767};
2768extend$__4(HTMLSelectElement.prototype, Extend$HTMLSelectElement$ag.prototype);
2769var Extend$HTMLOptionElement$ah = class {
2770 setRichValue(value) {
2771 this.$$value = value;
2772 return this.value = value;
2773 }
2774 getRichValue() {
2775 if (this.$$value !== void 0) {
2776 return this.$$value;
2777 }
2778 ;
2779 return this.value;
2780 }
2781};
2782extend$__4(HTMLOptionElement.prototype, Extend$HTMLOptionElement$ah.prototype);
2783var Extend$HTMLTextAreaElement$ai = class {
2784 setRichValue(value) {
2785 this.$$value = value;
2786 return this.value = value;
2787 }
2788 getRichValue() {
2789 if (this.$$value !== void 0) {
2790 return this.$$value;
2791 }
2792 ;
2793 return this.value;
2794 }
2795 input$(e) {
2796 this.data = this.value;
2797 return commit();
2798 }
2799 end$() {
2800 if (this.$$bound && this.value != this.data) {
2801 return this.value = this.data;
2802 }
2803 ;
2804 }
2805};
2806extend$__4(HTMLTextAreaElement.prototype, Extend$HTMLTextAreaElement$ai.prototype);
2807var Extend$HTMLInputElement$aj = class {
2808 input$(e) {
2809 let typ = this.type;
2810 if (typ == "checkbox" || typ == "radio") {
2811 return;
2812 }
2813 ;
2814 this.$$value = void 0;
2815 this.data = this.richValue;
2816 return commit();
2817 }
2818 change$(e) {
2819 let model = this.data;
2820 let val = this.richValue;
2821 if (this.type == "checkbox" || this.type == "radio") {
2822 let checked = this.checked;
2823 if (isGroup(model)) {
2824 checked ? bindAdd(model, val) : bindRemove(model, val);
2825 } else {
2826 this.data = checked ? val : false;
2827 }
2828 ;
2829 }
2830 ;
2831 return commit();
2832 }
2833 setRichValue(value) {
2834 if (this.$$value !== value) {
2835 this.$$value = value;
2836 if (this.value !== value) {
2837 this.value = value;
2838 }
2839 ;
2840 }
2841 ;
2842 return;
2843 }
2844 getRichValue() {
2845 if (this.$$value !== void 0) {
2846 return this.$$value;
2847 }
2848 ;
2849 let value = this.value;
2850 let typ = this.type;
2851 if (typ == "range" || typ == "number") {
2852 value = this.valueAsNumber;
2853 if (Number.isNaN(value)) {
2854 value = null;
2855 }
2856 ;
2857 } else if (typ == "checkbox") {
2858 if (value == void 0 || value === "on") {
2859 value = true;
2860 }
2861 ;
2862 }
2863 ;
2864 return value;
2865 }
2866 end$() {
2867 if (this.$$bound) {
2868 let typ = this.type;
2869 if (typ == "checkbox" || typ == "radio") {
2870 let val = this.data;
2871 if (val === true || val === false || val == null) {
2872 this.checked = !!val;
2873 } else {
2874 this.checked = bindHas(val, this.richValue);
2875 }
2876 ;
2877 } else {
2878 this.richValue = this.data;
2879 }
2880 ;
2881 }
2882 ;
2883 return;
2884 }
2885};
2886extend$__4(HTMLInputElement.prototype, Extend$HTMLInputElement$aj.prototype);
2887var Extend$HTMLButtonElement$ak = class {
2888 get checked() {
2889 return this.$checked;
2890 }
2891 set checked(val) {
2892 if (val != this.$checked) {
2893 this.$checked = val;
2894 this.flags.toggle("checked", !!val);
2895 }
2896 ;
2897 }
2898 setRichValue(value) {
2899 this.$$value = value;
2900 return this.value = value;
2901 }
2902 getRichValue() {
2903 if (this.$$value !== void 0) {
2904 return this.$$value;
2905 }
2906 ;
2907 return this.value;
2908 }
2909 click$(e) {
2910 let data = this.data;
2911 let toggled = this.checked;
2912 let val = this.richValue;
2913 if (isGroup(data)) {
2914 toggled ? bindRemove(data, val) : bindAdd(data, val);
2915 } else {
2916 this.data = toggled ? null : val;
2917 }
2918 ;
2919 this.end$();
2920 return commit();
2921 }
2922 end$() {
2923 if (this.$$bound) {
2924 let val = this.data;
2925 if (val === true || val === false || val == null) {
2926 this.checked = !!val;
2927 } else {
2928 this.checked = bindHas(val, this.richValue);
2929 }
2930 ;
2931 }
2932 ;
2933 return;
2934 }
2935};
2936extend$__4(HTMLButtonElement.prototype, Extend$HTMLButtonElement$ak.prototype);
2937
2938// src/imba/dom/global-hook.imba
2939function iter$__7(a) {
2940 let v;
2941 return a ? (v = a.toIterable) ? v.call(a) : a : [];
2942}
2943var φ18 = Symbol.for("#slot");
2944var φ25 = Symbol.for("#listeners");
2945var φ33 = Symbol.for("##slot");
2946var φ103 = Symbol.for("#self");
2947var GlobalHook = class extends ImbaElement {
2948 build() {
2949 this25] = [];
2950 this.win = globalThis;
2951 return this.doc = globalThis.document;
2952 }
2953 setup() {
2954 return this.setAttribute("style", "display:none !important;");
2955 }
2956 slot$(name, ctx) {
2957 return this18];
2958 }
2959 get [φ18]() {
2960 if (!this33]) {
2961 let classes = this.className;
2962 this33] = this.doc.createElement("div");
2963 this33].className = classes;
2964 this33].style.cssText = "display:contents !important;";
2965 if (this.mountedΦ) {
2966 this.doc.body.appendChild(this33]);
2967 }
2968 ;
2969 }
2970 ;
2971 return this33];
2972 }
2973 get style() {
2974 return this33] ? this33].style : super.style;
2975 }
2976 get classList() {
2977 return this33] ? this33].classList : super.classList;
2978 }
2979 get className() {
2980 return this33] ? this33].className : super.className;
2981 }
2982 set className(val) {
2983 this33] ? this33].className = val : super.className = val;
2984 }
2985 setup() {
2986 return this.setAttribute("style", "display:none !important;");
2987 }
2988 mount() {
2989 for (let φ45 = 0, φ56 = iter$__7(this25]), φ65 = φ56.length; φ45 < φ65; φ45++) {
2990 let [name, handler, o] = φ5645];
2991 this.win.addEventListener(name, handler, o);
2992 }
2993 ;
2994 if (this33]) {
2995 this.doc.body.appendChild(this33]);
2996 }
2997 ;
2998 return;
2999 }
3000 unmount() {
3001 for (let φ75 = 0, φ84 = iter$__7(this25]), φ94 = φ84.length; φ75 < φ94; φ75++) {
3002 let [name, handler, o] = φ8475];
3003 this.win.removeEventListener(name, handler, o);
3004 }
3005 ;
3006 if (this33] && this33].parentNode) {
3007 this33].parentNode.removeChild(this33]);
3008 }
3009 ;
3010 return;
3011 }
3012 addEventListener(name, handler, o = {}) {
3013 handler[φ103] = this;
3014 this25].push([name, handler, o]);
3015 if (!this.mountedΦ && this.win.addEventListener) {
3016 return this.win.addEventListener(name, handler, o);
3017 }
3018 ;
3019 }
3020};
3021if (globalThis.customElements) {
3022 globalThis.customElements.define("i-global", GlobalHook);
3023}
3024function use_dom_global_hook() {
3025 return true;
3026}
3027
3028// src/imba/events/core.imba
3029function iter$__8(a) {
3030 let v;
3031 return a ? (v = a.toIterable) ? v.call(a) : a : [];
3032}
3033function extend$__5(target, ext) {
3034 var descriptors = Object.getOwnPropertyDescriptors(ext);
3035 Object.defineProperties(target, descriptors);
3036 return target;
3037}
3038var φ19 = Symbol.for("#self");
3039var keyCodes = {
3040 esc: [27],
3041 tab: [9],
3042 enter: [13],
3043 space: [32],
3044 up: [38],
3045 down: [40],
3046 left: [37],
3047 right: [39],
3048 del: [8, 46]
3049};
3050var events = {};
3051function use_events() {
3052 return true;
3053}
3054Event.log$mod = function(...params) {
3055 console.log(...params);
3056 return true;
3057};
3058Event.sel$mod = function(expr) {
3059 return !!this.event.target.matches(String(expr));
3060};
3061Event.outside$mod = function() {
3062 if (this.handler && this.handler[φ19]) {
3063 return !this.handler[φ19].parentNode.contains(this.event.target);
3064 }
3065 ;
3066 return false;
3067};
3068Event.if$mod = function(expr) {
3069 return !!expr;
3070};
3071Event.wait$mod = function(time = 250) {
3072 return new Promise(function(_0) {
3073 return setTimeout(_0, parseTime(time));
3074 });
3075};
3076Event.self$mod = function() {
3077 return this.event.target == this.element;
3078};
3079Event.throttle$mod = function(time = 250) {
3080 var self = this;
3081 if (this.handler.throttled) {
3082 return false;
3083 }
3084 ;
3085 this.handler.throttled = true;
3086 this.element.flags.incr("throttled");
3087 once(this.current, "end", function() {
3088 return setTimeout(function() {
3089 self.element.flags.decr("throttled");
3090 return self.handler.throttled = false;
3091 }, parseTime(time));
3092 });
3093 return true;
3094};
3095Event.debounce$mod = function(time = 250) {
3096 var self = this, φ210;
3097 let queue = (φ210 = this.state).debounced || (φ210.debounced = []);
3098 queue.push(queue.last = this.event);
3099 return new Promise(function(resolve) {
3100 return setTimeout(function() {
3101 if (queue.last == self.event) {
3102 self.event.debounced = queue;
3103 self.handler.state = {};
3104 return resolve(true);
3105 } else {
3106 return resolve(false);
3107 }
3108 ;
3109 }, parseTime(time));
3110 });
3111};
3112Event.flag$mod = function(name, sel) {
3113 let el = sel instanceof Element ? sel : sel ? this.element.closest(sel) : this.element;
3114 if (!el) {
3115 return true;
3116 }
3117 ;
3118 let step = this.step;
3119 this.state[step] = this.id;
3120 el.flags.incr(name);
3121 let ts = Date.now();
3122 once(this.current, "end", function() {
3123 let elapsed = Date.now() - ts;
3124 let delay = Math.max(250 - elapsed, 0);
3125 return setTimeout(function() {
3126 return el.flags.decr(name);
3127 }, delay);
3128 });
3129 return true;
3130};
3131Event.busy$mod = function(sel) {
3132 return Event.flag$mod.call(this, "busy", 250, sel);
3133};
3134Event.mod$mod = function(name) {
3135 return Event.flag$mod.call(this, "mod-" + name, globalThis.document.documentElement);
3136};
3137var EventHandler = class {
3138 constructor(params, closure) {
3139 this.params = params;
3140 this.closure = closure;
3141 }
3142 getHandlerForMethod(el, name) {
3143 if (!el) {
3144 return null;
3145 }
3146 ;
3147 return el[name] ? el : this.getHandlerForMethod(el.parentNode, name);
3148 }
3149 emit(name, ...params) {
3150 return emit(this, name, params);
3151 }
3152 on(name, ...params) {
3153 return listen(this, name, ...params);
3154 }
3155 once(name, ...params) {
3156 return once(this, name, ...params);
3157 }
3158 un(name, ...params) {
3159 return unlisten(this, name, ...params);
3160 }
3161 async handleEvent(event) {
3162 let target = event.target;
3163 let element = event.currentTarget;
3164 let mods = this.params;
3165 let i = 0;
3166 let awaited = false;
3167 let prevRes = void 0;
3168 this.count || (this.count = 0);
3169 this.state || (this.state = {});
3170 let state = {
3171 element,
3172 event,
3173 modifiers: mods,
3174 handler: this,
3175 id: ++this.count,
3176 step: -1,
3177 state: this.state,
3178 commit: null,
3179 current: null
3180 };
3181 state.current = state;
3182 if (event.handle$mod) {
3183 if (event.handle$mod.apply(state, mods.options || []) == false) {
3184 return;
3185 }
3186 ;
3187 }
3188 ;
3189 let guard = Event[this.type + "$handle"] || Event[event.type + "$handle"] || event.handle$mod;
3190 if (guard && guard.apply(state, mods.options || []) == false) {
3191 return;
3192 }
3193 ;
3194 this.currentEvents || (this.currentEvents = new Set());
3195 this.currentEvents.add(event);
3196 for (let φ35 = 0, φ45 = Object.keys(mods), φ94 = φ45.length, handler, val; φ35 < φ94; φ35++) {
3197 handler = φ4535];
3198 val = mods[handler];
3199 state.step++;
3200 if (handler[0] == "_") {
3201 continue;
3202 }
3203 ;
3204 if (handler.indexOf("~") > 0) {
3205 handler = handler.split("~")[0];
3206 }
3207 ;
3208 let modargs = null;
3209 let ismod = false;
3210 let args = [event, state];
3211 let res = void 0;
3212 let context = null;
3213 let m;
3214 let isstring = typeof handler == "string";
3215 if (handler[0] == "$" && handler[1] == "_" && val[0] instanceof Function) {
3216 handler = val[0];
3217 args = [event, state].concat(val.slice(1));
3218 context = element;
3219 } else if (val instanceof Array) {
3220 args = val.slice();
3221 modargs = args;
3222 for (let i2 = 0, φ56 = iter$__8(args), φ84 = φ56.length; i2 < φ84; i2++) {
3223 let par = φ56[i2];
3224 if (typeof par == "string" && par[0] == "~" && par[1] == "$") {
3225 let name = par.slice(2);
3226 let chain = name.split(".");
3227 let value = state[chain.shift()] || event;
3228 for (let i3 = 0, φ65 = iter$__8(chain), φ75 = φ65.length; i3 < φ75; i3++) {
3229 let part = φ65[i3];
3230 value = value ? value[part] : void 0;
3231 }
3232 ;
3233 args[i2] = value;
3234 }
3235 ;
3236 }
3237 ;
3238 }
3239 ;
3240 if (typeof handler == "string" && (m = handler.match(/^(emit|flag|mod|moved|pin|fit|refit|map|remap|css)-(.+)$/))) {
3241 if (!modargs) {
3242 modargs = args = [];
3243 }
3244 ;
3245 args.unshift(m[2]);
3246 handler = m[1];
3247 }
3248 ;
3249 if (handler == "stop") {
3250 event.stopImmediatePropagation();
3251 } else if (handler == "prevent") {
3252 event.preventDefault();
3253 } else if (handler == "commit") {
3254 state.commit = true;
3255 } else if (handler == "silence" || handler == "silent") {
3256 state.commit = false;
3257 } else if (handler == "ctrl") {
3258 if (!event.ctrlKey) {
3259 break;
3260 }
3261 ;
3262 } else if (handler == "alt") {
3263 if (!event.altKey) {
3264 break;
3265 }
3266 ;
3267 } else if (handler == "shift") {
3268 if (!event.shiftKey) {
3269 break;
3270 }
3271 ;
3272 } else if (handler == "meta") {
3273 if (!event.metaKey) {
3274 break;
3275 }
3276 ;
3277 } else if (handler == "once") {
3278 element.removeEventListener(event.type, this);
3279 } else if (handler == "options") {
3280 continue;
3281 } else if (keyCodes[handler]) {
3282 if (keyCodes[handler].indexOf(event.keyCode) < 0) {
3283 break;
3284 }
3285 ;
3286 } else if (handler == "emit") {
3287 let name = args[0];
3288 let detail = args[1];
3289 let e = new CustomEvent(name, {bubbles: true, detail});
3290 e.originalEvent = event;
3291 let customRes = element.dispatchEvent(e);
3292 } else if (typeof handler == "string") {
3293 let fn = this.type && Event[this.type + "$" + handler + "$mod"];
3294 fn || (fn = event[handler + "$mod"] || Event[event.type + "$" + handler] || Event[handler + "$mod"]);
3295 if (fn instanceof Function) {
3296 handler = fn;
3297 context = state;
3298 args = modargs || [];
3299 ismod = true;
3300 } else if (handler[0] == "_") {
3301 handler = handler.slice(1);
3302 context = this.closure;
3303 } else {
3304 context = this.getHandlerForMethod(element, handler);
3305 }
3306 ;
3307 }
3308 ;
3309 if (handler instanceof Function) {
3310 res = handler.apply(context || element, args);
3311 } else if (context) {
3312 res = context[handler].apply(context, args);
3313 }
3314 ;
3315 if (state.commit === null && !ismod) {
3316 state.commit = true;
3317 }
3318 ;
3319 if (res && res.then instanceof Function && res != scheduler.$promise) {
3320 if (state.commit) {
3321 scheduler.commit();
3322 }
3323 ;
3324 awaited = true;
3325 res = await res;
3326 }
3327 ;
3328 if (res === false) {
3329 break;
3330 }
3331 ;
3332 state.value = res;
3333 }
3334 ;
3335 emit(state, "end", state);
3336 if (state.commit) {
3337 scheduler.commit();
3338 }
3339 ;
3340 this.currentEvents.delete(event);
3341 if (this.currentEvents.size == 0) {
3342 this.emit("idle");
3343 }
3344 ;
3345 return;
3346 }
3347};
3348var Extend$Element$af3 = class {
3349 on$(type, mods, scope) {
3350 let check = "on$" + type;
3351 let handler;
3352 handler = new EventHandler(mods, scope);
3353 let capture = mods.capture;
3354 let passive = mods.passive;
3355 let o = capture;
3356 if (passive) {
3357 o = {passive, capture};
3358 }
3359 ;
3360 if (this[check] instanceof Function) {
3361 handler = this[check](mods, scope, handler);
3362 } else {
3363 this.addEventListener(type, handler, o);
3364 }
3365 ;
3366 return handler;
3367 }
3368};
3369extend$__5(Element.prototype, Extend$Element$af3.prototype);
3370
3371// src/imba/events/intersect.imba
3372function iter$__9(a) {
3373 let v;
3374 return a ? (v = a.toIterable) ? v.call(a) : a : [];
3375}
3376function extend$__6(target, ext) {
3377 var descriptors = Object.getOwnPropertyDescriptors(ext);
3378 Object.defineProperties(target, descriptors);
3379 return target;
3380}
3381function use_events_intersect() {
3382 return true;
3383}
3384var observers = new (globalThis.WeakMap || Map)();
3385var IntersectionEventDefaults = {threshold: [0]};
3386var viewport = {};
3387Event.intersect$handle = function() {
3388 let obs = this.event.detail.observer;
3389 return this.modifiers._observer == obs;
3390};
3391Event.intersect$in = function() {
3392 return this.event.delta >= 0 && this.event.entry.isIntersecting;
3393};
3394Event.intersect$out = function() {
3395 return this.event.delta < 0;
3396};
3397Event.intersect$css = function() {
3398 this.element.style.setProperty("--ratio", this.event.ratio);
3399 return true;
3400};
3401function callback(name, key) {
3402 return function(entries, observer) {
3403 let map = observer.prevRatios || (observer.prevRatios = new WeakMap());
3404 for (let φ114 = 0, φ210 = iter$__9(entries), φ35 = φ210.length; φ114 < φ35; φ114++) {
3405 let entry = φ210114];
3406 let prev = map.get(entry.target) || 0;
3407 let ratio = entry.intersectionRatio;
3408 let detail = {entry, ratio, from: prev, delta: ratio - prev, observer};
3409 let e = new CustomEvent2(name, {bubbles: false, detail});
3410 e.entry = entry;
3411 e.isIntersecting = entry.isIntersecting;
3412 e.delta = detail.delta;
3413 e.ratio = detail.ratio;
3414 map.set(entry.target, ratio);
3415 entry.target.dispatchEvent(e);
3416 }
3417 ;
3418 return;
3419 };
3420}
3421function getIntersectionObserver(opts = IntersectionEventDefaults) {
3422 let key = opts.threshold.join("-") + opts.rootMargin;
3423 if (!opts.root && IntersectionEventDefaults.root) {
3424 opts.root || (opts.root = IntersectionEventDefaults.root);
3425 }
3426 ;
3427 let target = opts.root || viewport;
3428 let map = observers.get(target);
3429 map || observers.set(target, map = {});
3430 return map[key] || (map[key] = new IntersectionObserver(callback("intersect", key), opts));
3431}
3432var Extend$Element$af4 = class {
3433 on$intersect(mods, context, handler, o) {
3434 let obs;
3435 if (mods.options) {
3436 let th = [];
3437 let opts = {threshold: th};
3438 for (let φ45 = 0, φ56 = iter$__9(mods.options), φ65 = φ56.length; φ45 < φ65; φ45++) {
3439 let arg = φ5645];
3440 if (arg instanceof Element || arg instanceof Document) {
3441 opts.root = arg;
3442 } else if (typeof arg == "number") {
3443 th.push(arg);
3444 } else if (typeof arg == "string") {
3445 opts.rootMargin = arg;
3446 } else if (typeof arg == "object") {
3447 Object.assign(opts, arg);
3448 }
3449 ;
3450 }
3451 ;
3452 if (th.length == 1) {
3453 let num = th[0];
3454 if (num > 1) {
3455 th[0] = 0;
3456 while (th.length < num) {
3457 th.push(th.length / (num - 1));
3458 }
3459 ;
3460 }
3461 ;
3462 }
3463 ;
3464 if (th.length == 0) {
3465 th.push(0);
3466 }
3467 ;
3468 obs = getIntersectionObserver(opts);
3469 } else {
3470 obs = getIntersectionObserver();
3471 }
3472 ;
3473 mods._observer = obs;
3474 obs.observe(this);
3475 this.addEventListener("intersect", handler, o);
3476 return handler;
3477 }
3478};
3479extend$__6(Element.prototype, Extend$Element$af4.prototype);
3480
3481// src/imba/events/pointer.imba
3482function extend$__7(target, ext) {
3483 var descriptors = Object.getOwnPropertyDescriptors(ext);
3484 Object.defineProperties(target, descriptors);
3485 return target;
3486}
3487function use_events_pointer() {
3488 return true;
3489}
3490function round(val, step = 1) {
3491 let inv = 1 / step;
3492 return Math.round(val * inv) / inv;
3493}
3494function clamp(val, min, max) {
3495 if (min > max) {
3496 return Math.max(max, Math.min(min, val));
3497 } else {
3498 return Math.min(max, Math.max(min, val));
3499 }
3500 ;
3501}
3502function parseDimension(val) {
3503 if (typeof val == "string") {
3504 let [m, num, unit] = val.match(/^([-+]?[\d\.]+)(%|\w+)$/);
3505 return [parseFloat(num), unit];
3506 } else if (typeof val == "number") {
3507 return [val];
3508 }
3509 ;
3510}
3511function scale(a0, a1, b0r, b1r, s = 0.1) {
3512 let [b0, b0u] = parseDimension(b0r);
3513 let [b1, b1u] = parseDimension(b1r);
3514 let [sv, su] = parseDimension(s);
3515 if (b0u == "%") {
3516 b0 = (a1 - a0) * (b0 / 100);
3517 }
3518 ;
3519 if (b1u == "%") {
3520 b1 = (a1 - a0) * (b1 / 100);
3521 }
3522 ;
3523 if (su == "%") {
3524 sv = (b1 - b0) * (sv / 100);
3525 }
3526 ;
3527 return function(value, fit) {
3528 let pct = (value - a0) / (a1 - a0);
3529 let val = b0 + (b1 - b0) * pct;
3530 if (s) {
3531 val = round(val, sv);
3532 }
3533 ;
3534 if (fit) {
3535 val = clamp(val, b0, b1);
3536 }
3537 ;
3538 return val;
3539 };
3540}
3541var Extend$PointerEvent$af = class {
3542 primary$mod() {
3543 return !!this.event.isPrimary;
3544 }
3545 mouse$mod() {
3546 return this.event.pointerType == "mouse";
3547 }
3548 pen$mod() {
3549 return this.event.pointerType == "pen";
3550 }
3551 touch$mod() {
3552 return this.event.pointerType == "touch";
3553 }
3554 pressure$mod(threshold = 0) {
3555 return this.event.pressure > threshold;
3556 }
3557 lock$mod(dr) {
3558 return true;
3559 }
3560};
3561extend$__7(PointerEvent.prototype, Extend$PointerEvent$af.prototype);
3562var Touch = class {
3563 constructor(e, handler, el) {
3564 this.phase = "init";
3565 this.events = [];
3566 this.originalEvent = e;
3567 this.handler = handler;
3568 this.target = this.currentTarget = el;
3569 }
3570 set event(value) {
3571 this.events.push(value);
3572 }
3573 get ctrlKey() {
3574 return this.originalEvent.ctrlKey;
3575 }
3576 get altKey() {
3577 return this.originalEvent.altKey;
3578 }
3579 get shiftKey() {
3580 return this.originalEvent.shiftKey;
3581 }
3582 get metaKey() {
3583 return this.originalEvent.metaKey;
3584 }
3585 get isPrimary() {
3586 return this.originalEvent.isPrimary;
3587 }
3588 get pointerType() {
3589 return this.originalEvent.pointerType;
3590 }
3591 get start() {
3592 return this.originalEvent;
3593 }
3594 get originalTarget() {
3595 return this.originalEvent.target;
3596 }
3597 get event() {
3598 return this.events[this.events.length - 1];
3599 }
3600 get elapsed() {
3601 return this.event.timeStamp - this.events[0].timeStamp;
3602 }
3603 get pointerId() {
3604 return this.event.pointerId;
3605 }
3606 get clientX() {
3607 return this.event.clientX;
3608 }
3609 get clientY() {
3610 return this.event.clientY;
3611 }
3612 get offsetX() {
3613 return this.event.offsetX;
3614 }
3615 get offsetY() {
3616 return this.event.offsetY;
3617 }
3618 get type() {
3619 return this.event.type;
3620 }
3621 get activeΦ() {
3622 return this.phase != "ended";
3623 }
3624 stopImmediatePropagation() {
3625 this.cancelBubble = true;
3626 this.event.stopImmediatePropagation();
3627 return this;
3628 }
3629 stopPropagation() {
3630 this.cancelBubble = true;
3631 this.event.stopPropagation();
3632 return this;
3633 }
3634 preventDefault() {
3635 this.defaultPrevented = true;
3636 return this.event.preventDefault();
3637 }
3638 emit(name, ...params) {
3639 return emit(this, name, params);
3640 }
3641 on(name, ...params) {
3642 return listen(this, name, ...params);
3643 }
3644 once(name, ...params) {
3645 return once(this, name, ...params);
3646 }
3647 un(name, ...params) {
3648 return unlisten(this, name, ...params);
3649 }
3650};
3651Event.touch$in$mod = function() {
3652 return Event.touch$reframe$mod.apply(this, arguments);
3653};
3654Event.touch$fit$mod = function() {
3655 var φ210, φ114;
3656 let o = (φ210 = this.state)[φ114 = this.step] || (φ210114] = {clamp: true});
3657 return Event.touch$reframe$mod.apply(this, arguments);
3658};
3659Event.touch$round$mod = function(sx = 1, sy = sx) {
3660 this.event.x = round(this.event.x, sx);
3661 this.event.y = round(this.event.y, sy);
3662 return true;
3663};
3664Event.touch$snap$mod = function(sx = 1, sy = sx) {
3665 this.event.x = round(this.event.x, sx);
3666 this.event.y = round(this.event.y, sy);
3667 return true;
3668};
3669Event.touch$moved$mod = function(a, b) {
3670 var self = this, φ45, φ35;
3671 let o = (φ45 = this.state)[φ35 = this.step] || (φ4535] = {});
3672 if (!o.setup) {
3673 let th2 = a || 4;
3674 if (typeof a == "string" && a.match(/^(up|down|left|right|x|y)$/)) {
3675 o.dir = a;
3676 th2 = b || 4;
3677 }
3678 ;
3679 o.setup = true;
3680 let [tv, tu] = parseDimension(th2);
3681 o.threshold = tv;
3682 o.sy = tv;
3683 o.x0 = this.event.x;
3684 o.y0 = this.event.y;
3685 if (tu && tu != "px") {
3686 console.warn("only px threshold allowed in @touch.moved");
3687 }
3688 ;
3689 }
3690 ;
3691 if (o.active) {
3692 return true;
3693 }
3694 ;
3695 let th = o.threshold;
3696 let dx = this.event.x - o.x0;
3697 let dy = this.event.y - o.y0;
3698 let hit = false;
3699 if (dx > th && (o.dir == "right" || o.dir == "x")) {
3700 hit = true;
3701 }
3702 ;
3703 if (!hit && dx < -th && (o.dir == "left" || o.dir == "x")) {
3704 hit = true;
3705 }
3706 ;
3707 if (!hit && dy > th && (o.dir == "down" || o.dir == "y")) {
3708 hit = true;
3709 }
3710 ;
3711 if (!hit && dy < -th && (o.dir == "up" || o.dir == "y")) {
3712 hit = true;
3713 }
3714 ;
3715 if (!hit) {
3716 let dr = Math.sqrt(dx * dx + dy * dy);
3717 if (dr > th && !o.dir) {
3718 hit = true;
3719 }
3720 ;
3721 }
3722 ;
3723 if (hit) {
3724 o.active = true;
3725 let pinned = this.state.pinTarget;
3726 this.element.flags.incr("_move_");
3727 if (pinned) {
3728 pinned.flags.incr("_move_");
3729 }
3730 ;
3731 once(this.current, "end", function() {
3732 if (pinned) {
3733 pinned.flags.decr("_move_");
3734 }
3735 ;
3736 return self.element.flags.decr("_move_");
3737 });
3738 }
3739 ;
3740 return !!o.active;
3741};
3742Event.touch$reframe$mod = function(...params) {
3743 var φ65, φ56;
3744 let o = (φ65 = this.state)[φ56 = this.step] || (φ6556] = {});
3745 if (!o.rect) {
3746 let el = this.element;
3747 let len = params.length;
3748 let box = params[0];
3749 let min = 0;
3750 let max = "100%";
3751 let snap = 1;
3752 let typ = typeof box;
3753 if (typ == "number" || typ == "string" && /^([-+]?\d[\d\.]*)(%|\w+)$/.test(box) || box instanceof Array) {
3754 box = null;
3755 } else if (typ == "string") {
3756 if (box == "this" || box == "") {
3757 box = this.element;
3758 } else if (box == "up") {
3759 box = this.element.parentNode;
3760 } else if (box == "op") {
3761 box = this.element.offsetParent;
3762 } else {
3763 box = el.closest(box) || el.querySelector(box);
3764 }
3765 ;
3766 }
3767 ;
3768 if (box == null) {
3769 len++;
3770 params.unshift(box = el);
3771 }
3772 ;
3773 if (len == 2) {
3774 snap = params[1];
3775 } else if (len > 2) {
3776 [min, max, snap = 1] = params.slice(1);
3777 }
3778 ;
3779 let rect = box.getBoundingClientRect();
3780 if (!(min instanceof Array)) {
3781 min = [min, min];
3782 }
3783 ;
3784 if (!(max instanceof Array)) {
3785 max = [max, max];
3786 }
3787 ;
3788 if (!(snap instanceof Array)) {
3789 snap = [snap, snap];
3790 }
3791 ;
3792 o.rect = rect;
3793 o.x = scale(rect.left, rect.right, min[0], max[0], snap[0]);
3794 o.y = scale(rect.top, rect.bottom, min[1], max[1], snap[1]);
3795 this.state.scaleX = o.x;
3796 this.state.scaleY = o.y;
3797 this.event.x0 = this.event.x = o.x(this.event.x, o.clamp);
3798 this.event.y0 = this.event.y = o.y(this.event.y, o.clamp);
3799 } else {
3800 let x = this.event.x = o.x(this.event.x, o.clamp);
3801 let y = this.event.y = o.y(this.event.y, o.clamp);
3802 this.event.dx = x - this.event.x0;
3803 this.event.dy = y - this.event.y0;
3804 }
3805 ;
3806 return true;
3807};
3808Event.touch$pin$mod = function(...params) {
3809 let o = this.state[this.step];
3810 if (!o) {
3811 let box = params[0];
3812 if (typeof box == "string") {
3813 box = this.element.closest(box) || this.element.querySelector(box);
3814 }
3815 ;
3816 if (!(box instanceof Element)) {
3817 params.unshift(box = this.state.target);
3818 }
3819 ;
3820 let ax = params[1] || 0;
3821 let ay = params[2] == null ? params[2] = ax : params[2];
3822 let rect = box.getBoundingClientRect();
3823 o = this.state[this.step] = {
3824 x: this.state.clientX - (rect.left + rect.width * ax),
3825 y: this.state.clientY - (rect.top + rect.height * ay)
3826 };
3827 if (box) {
3828 this.state.pinTarget = box;
3829 box.flags.incr("_touch_");
3830 this.state.once("end", function() {
3831 return box.flags.decr("_touch_");
3832 });
3833 }
3834 ;
3835 }
3836 ;
3837 this.event.x -= o.x;
3838 this.event.y -= o.y;
3839 return true;
3840};
3841Event.touch$lock$mod = function(...params) {
3842 let o = this.state[this.step];
3843 if (!o) {
3844 o = this.state[this.step] = this.state.target.style;
3845 let prev = o.touchAction;
3846 o.touchAction = "none";
3847 this.state.once("end", function() {
3848 return o.removeProperty("touch-action");
3849 });
3850 }
3851 ;
3852 return true;
3853};
3854Event.touch$sync$mod = function(item, xalias = "x", yalias = "y") {
3855 let o = this.state[this.step];
3856 if (!o) {
3857 o = this.state[this.step] = {
3858 x: item[xalias] || 0,
3859 y: item[yalias] || 0,
3860 tx: this.state.x,
3861 ty: this.state.y
3862 };
3863 }
3864 ;
3865 if (this.commit === null) {
3866 this.commit = true;
3867 }
3868 ;
3869 if (xalias) {
3870 item[xalias] = o.x + (this.state.x - o.tx);
3871 }
3872 ;
3873 if (yalias) {
3874 item[yalias] = o.y + (this.state.y - o.ty);
3875 }
3876 ;
3877 return true;
3878};
3879function isIOS() {
3880 let nav = globalThis.navigator.platform || "";
3881 if (nav.match(/iPhone|iPod|iPad/)) {
3882 return true;
3883 }
3884 ;
3885 if (nav == "MacIntel" && globalThis.navigator.maxTouchPoints > 2) {
3886 return true;
3887 }
3888 ;
3889 return false;
3890}
3891var Extend$Element$ag = class {
3892 on$touch(mods, context, handler, o) {
3893 handler.type = "touch";
3894 handler.isIOS = isIOS();
3895 this.addEventListener("pointerdown", handler, o);
3896 if (handler.isIOS && !mods.passive) {
3897 this.addEventListener("touchstart", handler);
3898 }
3899 ;
3900 return handler;
3901 }
3902};
3903extend$__7(Element.prototype, Extend$Element$ag.prototype);
3904Event.touch$handle = function() {
3905 var self = this, φ75;
3906 let e = this.event;
3907 let el = this.element;
3908 let id = this.state.pointerId;
3909 let m = this.modifiers;
3910 this.current = this.state;
3911 if (e.type == "touchstart") {
3912 try {
3913 if (id && id == e.targetTouches[0].identifier) {
3914 e.preventDefault();
3915 }
3916 ;
3917 } catch (e2) {
3918 }
3919 ;
3920 return false;
3921 }
3922 ;
3923 if (id != void 0) {
3924 return id == e.pointerId;
3925 }
3926 ;
3927 if (m.ctrl && !e.ctrlKey) {
3928 return;
3929 }
3930 ;
3931 if (m.alt && !e.altKey) {
3932 return;
3933 }
3934 ;
3935 if (m.meta && !e.metaKey) {
3936 return;
3937 }
3938 ;
3939 if (m.shift && !e.shiftKey) {
3940 return;
3941 }
3942 ;
3943 if (m.if && !!m.if[0] == false) {
3944 return;
3945 }
3946 ;
3947 if (m.self && e.target != el) {
3948 return;
3949 }
3950 ;
3951 if (m.primary && !e.isPrimary) {
3952 return;
3953 }
3954 ;
3955 if (m.pen && e.pointerType != "pen") {
3956 return;
3957 }
3958 ;
3959 if (m.mouse && e.pointerType != "mouse") {
3960 return;
3961 }
3962 ;
3963 if (m.touch && e.pointerType != "touch") {
3964 return;
3965 }
3966 ;
3967 if (m.sel && !e.target.matches(String(m.sel[0]))) {
3968 return;
3969 }
3970 ;
3971 let t = this.state = this.handler.state = this.current = new Touch(e, this.handler, el);
3972 let canceller = function(e2) {
3973 e2.preventDefault();
3974 return false;
3975 };
3976 let listener = function(e2) {
3977 let typ = e2.type;
3978 let ph = t.phase;
3979 t.event = e2;
3980 let end = typ == "pointerup" || typ == "pointercancel";
3981 if (typ != "pointercancel") {
3982 t.x = e2.clientX;
3983 t.y = e2.clientY;
3984 }
3985 ;
3986 if (end) {
3987 t.phase = "ended";
3988 }
3989 ;
3990 try {
3991 self.handler.handleEvent(t);
3992 } catch (e3) {
3993 }
3994 ;
3995 if (ph == "init") {
3996 t.phase = "active";
3997 }
3998 ;
3999 if (end && !self.handler.isIOS) {
4000 return el.releasePointerCapture(e2.pointerId);
4001 }
4002 ;
4003 };
4004 let disposed = false;
4005 let teardown = function(e2) {
4006 if (disposed) {
4007 return;
4008 }
4009 ;
4010 el.flags.decr("_touch_");
4011 t.emit("end");
4012 if (!m.passive) {
4013 if (--self.handler.prevents == 0) {
4014 el.style.removeProperty("touch-action");
4015 }
4016 ;
4017 }
4018 ;
4019 self.handler.state = {};
4020 el.removeEventListener("pointermove", listener);
4021 el.removeEventListener("pointerup", listener);
4022 el.removeEventListener("pointercancel", listener);
4023 globalThis.document.removeEventListener("selectstart", canceller, {capture: true});
4024 return disposed = true;
4025 };
4026 if (!m.passive) {
402775 = this.handler).prevents || (φ75.prevents = 0);
4028 this.handler.prevents++;
4029 el.style.setProperty("touch-action", "none");
4030 el.offsetWidth;
4031 }
4032 ;
4033 el.flags.incr("_touch_");
4034 el.addEventListener("pointermove", listener);
4035 el.addEventListener("pointerup", listener);
4036 el.addEventListener("pointercancel", listener);
4037 el.addEventListener("lostpointercapture", teardown, {once: true});
4038 if (!this.handler.isIOS) {
4039 el.setPointerCapture(e.pointerId);
4040 }
4041 ;
4042 globalThis.document.addEventListener("selectstart", canceller, {capture: true});
4043 listener(e);
4044 return false;
4045};
4046
4047// src/imba/events/resize.imba
4048function iter$__10(a) {
4049 let v;
4050 return a ? (v = a.toIterable) ? v.call(a) : a : [];
4051}
4052function extend$__8(target, ext) {
4053 var descriptors = Object.getOwnPropertyDescriptors(ext);
4054 Object.defineProperties(target, descriptors);
4055 return target;
4056}
4057function use_events_resize() {
4058 return true;
4059}
4060var resizeObserver = null;
4061function getResizeObserver() {
4062 if (!globalThis.ResizeObserver) {
4063 if (!resizeObserver) {
4064 console.warn(":resize not supported in this browser");
4065 resizeObserver = {observe: function() {
4066 return true;
4067 }};
4068 }
4069 ;
4070 }
4071 ;
4072 return resizeObserver || (resizeObserver = new ResizeObserver(function(entries) {
4073 for (let φ114 = 0, φ210 = iter$__10(entries), φ35 = φ210.length; φ114 < φ35; φ114++) {
4074 let entry = φ210114];
4075 let e = new CustomEvent2("resize", {bubbles: false, detail: entry});
4076 e.entry = entry;
4077 e.rect = entry.contentRect;
4078 e.width = entry.target.offsetWidth;
4079 e.height = entry.target.offsetHeight;
4080 entry.target.dispatchEvent(e);
4081 let e2 = new CustomEvent2("resized", {bubbles: true, detail: entry});
4082 entry.target.dispatchEvent(e2);
4083 }
4084 ;
4085 return;
4086 }));
4087}
4088var Extend$Element$af5 = class {
4089 on$resize(chain, context, handler, o) {
4090 getResizeObserver().observe(this);
4091 this.addEventListener("resize", handler, o);
4092 return handler;
4093 }
4094};
4095extend$__8(Element.prototype, Extend$Element$af5.prototype);
4096
4097// src/imba/events/selection.imba
4098function extend$__9(target, ext) {
4099 var descriptors = Object.getOwnPropertyDescriptors(ext);
4100 Object.defineProperties(target, descriptors);
4101 return target;
4102}
4103function use_events_selection() {
4104 return true;
4105}
4106var selHandler;
4107var handledSym = Symbol();
4108function activateSelectionHandler() {
4109 if (!selHandler) {
4110 selHandler = function(e) {
4111 if (e[handledSym]) {
4112 return;
4113 }
4114 ;
4115 e[handledSym] = true;
4116 let target = globalThis.document.activeElement;
4117 if (target && target.matches("input,textarea")) {
4118 let custom = new CustomEvent2("selection", {
4119 detail: {
4120 start: target.selectionStart,
4121 end: target.selectionEnd
4122 }
4123 });
4124 return target.dispatchEvent(custom);
4125 }
4126 ;
4127 };
4128 return globalThis.document.addEventListener("selectionchange", selHandler);
4129 }
4130 ;
4131}
4132var Extend$Element$af6 = class {
4133 on$selection(mods, context, handler, o) {
4134 activateSelectionHandler();
4135 this.addEventListener("selection", handler, o);
4136 return handler;
4137 }
4138};
4139extend$__9(Element.prototype, Extend$Element$af6.prototype);
4140
4141// src/imba/router/index.imba
4142var import_events = __toModule(require_events());
4143
4144// src/imba/router/location.imba
4145var φ110 = Symbol.for("#getQueryParam");
4146var φ26 = Symbol.for("#setQueryParam");
4147var φ63 = Symbol.for("#query");
4148var Location = class {
4149 static parse(url, router2) {
4150 if (url instanceof Location) {
4151 return url;
4152 }
4153 ;
4154 return new Location(url, router2);
4155 }
4156 constructor(url, router2) {
4157 this.router = router2;
4158 this.parse(url);
4159 }
4160 parse(url) {
4161 var _a;
4162 let alias;
4163 if (!(url instanceof URL)) {
4164 url = new URL(url, this.router.origin);
4165 }
4166 ;
4167 if (alias = (_a = this.router) == null ? void 0 : _a.aliases[url.pathname]) {
4168 url.pathname = alias;
4169 }
4170 ;
4171 this.url = url;
4172 return this;
4173 }
4174 get activeΦ() {
4175 return this.router.location == this;
4176 }
4177 reparse() {
4178 return this.parse(this.url);
4179 }
4180 get searchParams() {
4181 return this.url.searchParams;
4182 }
4183 search() {
4184 let str = this.searchParams ? this.searchParams.toString() : "";
4185 return str ? "?" + str : "";
4186 }
4187 update(value) {
4188 if (value instanceof Object) {
4189 for (let φ35 = 0, φ45 = Object.keys(value), φ56 = φ45.length, k, v; φ35 < φ56; φ35++) {
4190 k = φ4535];
4191 v = value[k];
4192 this.searchParams.set(k, v);
4193 }
4194 ;
4195 } else if (typeof value == "string") {
4196 this.parse(value);
4197 }
4198 ;
4199 return this;
4200 }
4201 clone() {
4202 return new Location(this.url.href, this.router);
4203 }
4204 equals(other) {
4205 return this.toString() == String(other);
4206 }
4207 get href() {
4208 return this.url.href;
4209 }
4210 get path() {
4211 return this.url.href.slice(this.url.origin.length);
4212 }
4213 get pathname() {
4214 return this.url.pathname;
4215 }
4216 get query() {
4217 return this63] || (this63] = new Proxy({}, {
4218 get: this[φ110].bind(this),
4219 set: this[φ26].bind(this)
4220 }));
4221 }
4222 toString() {
4223 return this.href;
4224 }
4225110](target, name) {
4226 return this.searchParams.get(name);
4227 }
422826](target, name, value) {
4229 let curr = this110](target, name);
4230 if (curr != value) {
4231 if (value == null || value == "") {
4232 this.searchParams.delete(name);
4233 } else {
4234 this.searchParams.set(name, value);
4235 }
4236 ;
4237 if (this.activeΦ) {
4238 this.router.history.replaceState({}, null, this.url.toString());
4239 this.router.touch();
4240 }
4241 ;
4242 }
4243 ;
4244 return true;
4245 }
4246};
4247
4248// src/imba/router/request.imba
4249var Request = class {
4250 constructor(router2, loc, referrer) {
4251 this.router = router2;
4252 if (loc) {
4253 this.location = Location.parse(loc);
4254 this.original = this.location.clone();
4255 }
4256 ;
4257 this.referrer = referrer;
4258 }
4259 redirect(path) {
4260 var _a, _b;
4261 (_b = (_a = this.location) == null ? void 0 : _a.update) == null ? void 0 : _b.call(_a, path);
4262 return this;
4263 }
4264 get path() {
4265 var _a;
4266 return (_a = this.location) == null ? void 0 : _a.path;
4267 }
4268 get url() {
4269 var _a, _b;
4270 return (_b = (_a = this.location) == null ? void 0 : _a.toString) == null ? void 0 : _b.call(_a);
4271 }
4272 set path(value) {
4273 this.location.path = value;
4274 }
4275 abort(forced = false) {
4276 this.aborted = true;
4277 if (forced) {
4278 this.forceAbort = forced;
4279 }
4280 ;
4281 return this;
4282 }
4283 match(str) {
4284 return this.location ? this.router.route(str).match(this.path) : null;
4285 }
4286};
4287
4288// src/imba/router/route.imba
4289function iter$__11(a) {
4290 let v;
4291 return a ? (v = a.toIterable) ? v.call(a) : a : [];
4292}
4293var φ111 = Symbol.for("#routes");
4294var φ27 = Symbol.for("#match");
4295var φ43 = Symbol.for("#symbol");
4296var φ54 = Symbol.for("#matches");
4297var cacheMap = new Map();
4298var urlCache = {};
4299var queryCache = {};
4300function cacheForMatch(match) {
4301 if (!cacheMap.has(match)) {
4302 let map = new Map();
4303 cacheMap.set(match, map);
4304 return map;
4305 }
4306 ;
4307 return cacheMap.get(match);
4308}
4309function combinedDeepMatch(parent, params) {
4310 let map = cacheForMatch(parent);
4311 if (!map.has(params)) {
4312 let item = Object.create(parent);
4313 Object.assign(item, params);
4314 map.set(params, item);
4315 return item;
4316 }
4317 ;
4318 return map.get(params);
4319}
4320var Match = class {
4321};
4322function parseUrl(str) {
4323 if (urlCache[str]) {
4324 return urlCache[str];
4325 }
4326 ;
4327 let url = urlCache[str] = {url: str};
4328 let qryidx = str.indexOf("?");
4329 let hshidx = str.indexOf("#");
4330 if (hshidx >= 0) {
4331 url.hash = str.slice(hshidx + 1);
4332 str = url.url = str.slice(0, hshidx);
4333 }
4334 ;
4335 if (qryidx >= 0) {
4336 let q = url.query = str.slice(qryidx + 1);
4337 str = str.slice(0, qryidx);
4338 url.query = queryCache[q] || (queryCache[q] = new URLSearchParams(q));
4339 }
4340 ;
4341 url.path = str;
4342 return url;
4343}
4344var RootRoute = class {
4345 constructor(router2) {
4346 this.router = router2;
4347 this.fullPath = "";
4348 this111] = {};
4349 this27] = new Match();
4350 this27].path = "";
4351 }
4352 route(pattern) {
4353 var φ35;
4354 return35 = this111])[pattern] || (φ35[pattern] = new Route(this.router, pattern, this));
4355 }
4356 match() {
4357 return this27];
4358 }
4359 resolve(url) {
4360 return "/";
4361 }
4362};
4363var Route = class {
4364 constructor(router2, str, parent) {
4365 this.parent = parent || router2.rootRoute;
4366 this.router = router2;
4367 this.status = 200;
4368 this.path = str;
4369 this43] = Symbol();
4370 this54] = {};
4371 this111] = {};
4372 }
4373 route(pattern) {
4374 var φ65;
4375 return65 = this111])[pattern] || (φ65[pattern] = new Route(this.router, pattern, this));
4376 }
4377 get fullPath() {
4378 return "" + this.parent.fullPath + "/" + this.$path;
4379 }
4380 load(cb) {
4381 return this.router.queue.add(cb);
4382 }
4383 set path(path) {
4384 var self = this;
4385 if (this.$path == path) {
4386 return;
4387 }
4388 ;
4389 this.raw = path;
4390 this.$path = path;
4391 this.groups = [];
4392 this.cache = {};
4393 this.dynamic = false;
4394 if (path.indexOf("?") >= 0) {
4395 let parts = path.split("?");
4396 path = parts.shift();
4397 this.query = {};
4398 for (let φ75 = 0, φ84 = iter$__11(parts.join("?").split("&")), φ94 = φ84.length; φ75 < φ94; φ75++) {
4399 let pair = φ8475];
4400 if (!pair) {
4401 continue;
4402 }
4403 ;
4404 let [k, v] = pair.split("=");
4405 if (k[0] == "!") {
4406 this.dynamic = true;
4407 k = k.slice(1);
4408 v = false;
4409 }
4410 ;
4411 if (v === "") {
4412 v = false;
4413 }
4414 ;
4415 if (v && v[0] == ":") {
4416 this.dynamic = true;
4417 }
4418 ;
4419 this.query[k] = v || (v === false ? false : true);
4420 }
4421 ;
4422 }
4423 ;
4424 path = path.replace(/\:(\w+|\*)(\.)?/g, function(m, id, dot) {
4425 self.dynamic = true;
4426 if (id != "*") {
4427 self.groups.push(id);
4428 }
4429 ;
4430 if (dot) {
4431 return "([^/#.?]+).";
4432 } else {
4433 return "([^/#?]+)";
4434 }
4435 ;
4436 });
4437 if (path == "" && this.query) {
4438 return;
4439 }
4440 ;
4441 path = "^" + path;
4442 let end = path[path.length - 1];
4443 if (end == "$") {
4444 path = path.slice(0, -1) + "(?=/?[#?]|/?$)";
4445 }
4446 ;
4447 if (end != "/" && end != "$" && path != "^/") {
4448 path = path + "(?=[/#?]|$)";
4449 }
4450 ;
4451 this.regex = new RegExp(path);
4452 this;
4453 }
4454 match(str = this.router.path) {
4455 var _a, _b;
4456 var match, φ163;
4457 let up = this.parent.match(str);
4458 if (!up) {
4459 return null;
4460 }
4461 ;
4462 let url = parseUrl(str);
4463 let matcher = url.url;
4464 let prefix = "";
4465 if (up.path && url.path.indexOf(up.path) == 0) {
4466 prefix = up.path + "/";
4467 matcher = matcher.slice(prefix.length);
4468 }
4469 ;
4470 if (match = this.regex ? matcher.match(this.regex) : [""]) {
4471 let fullpath = prefix + match[0];
4472 let matchid = [this.$path];
4473 let params = {};
4474 if (this.groups.length) {
4475 for (let i = 0, φ105 = iter$__11(match), φ114 = φ105.length, name; i < φ114; i++) {
4476 let item = φ105[i];
4477 if (name = this.groups[i - 1]) {
4478 params[name] = item;
4479 matchid.push(item);
4480 }
4481 ;
4482 }
4483 ;
4484 }
4485 ;
4486 if (this.query) {
4487 for (let φ142 = this.query, φ123 = 0, φ132 = Object.keys(φ142), φ152 = φ132.length, k, v; φ123 < φ152; φ123++) {
4488 k = φ132123];
4489 v = φ142[k];
4490 let name = k;
4491 let m = (_b = (_a = url.query) == null ? void 0 : _a.get) == null ? void 0 : _b.call(_a, k);
4492 if (v === false) {
4493 if (m) {
4494 return null;
4495 }
4496 ;
4497 matchid.push("1");
4498 continue;
4499 }
4500 ;
4501 if (v[0] == ":") {
4502 name = v.slice(1);
4503 v = true;
4504 }
4505 ;
4506 if (v == true && m || v == m) {
4507 params[name] = m;
4508 matchid.push(m);
4509 } else {
4510 return null;
4511 }
4512 ;
4513 }
4514 ;
4515 }
4516 ;
4517 let key = matchid.join("*");
4518 params = (φ163 = this54])[key] || (φ163[key] = params);
4519 let result = combinedDeepMatch(up, params);
4520 result.path = fullpath;
4521 return result;
4522 }
4523 ;
4524 return null;
4525 }
4526 resolve(url = this.router.path) {
4527 if (this.raw[0] == "/" && !this.dynamic) {
4528 return this.raw.replace(/\$/g, "");
4529 }
4530 ;
4531 let up = this.parent.match(url);
4532 let upres = this.parent.resolve(url);
4533 let out;
4534 if (this.dynamic) {
4535 let m = this.match(url);
4536 if (m) {
4537 return m.path;
4538 } else {
4539 return null;
4540 }
4541 ;
4542 }
4543 ;
4544 if (this.raw[0] == "?") {
4545 out = (upres || "/") + this.raw;
4546 } else {
4547 out = upres + "/" + this.raw;
4548 }
4549 ;
4550 return out.replace(/\$/g, "").replace(/\/\/+/g, "/");
4551 }
4552};
4553
4554// src/imba/queue.imba
4555var φ112 = Symbol.for("#idler");
4556var φ28 = Symbol.for("#resolve");
4557var Queue = class extends Set {
4558 constructor() {
4559 super();
4560 this112] = Promise.resolve(this);
4561 }
4562 emit(name, ...params) {
4563 return emit(this, name, params);
4564 }
4565 on(name, ...params) {
4566 return listen(this, name, ...params);
4567 }
4568 once(name, ...params) {
4569 return once(this, name, ...params);
4570 }
4571 un(name, ...params) {
4572 return unlisten(this, name, ...params);
4573 }
4574 add(value) {
4575 var self = this;
4576 if (value instanceof Function) {
4577 value = value();
4578 }
4579 ;
4580 if (!this.has(value)) {
4581 value.then(function() {
4582 return self.delete(value);
4583 });
4584 let first = this.size == 0;
4585 super.add(value);
4586 if (first) {
4587 this112] = this28] = null;
4588 this.emit("busy", this);
4589 }
4590 ;
4591 }
4592 ;
4593 return value;
4594 }
4595 delete(value) {
4596 if (super.delete(value)) {
4597 if (this.size == 0) {
4598 if (this28]) {
4599 this28](this);
4600 this28] = null;
4601 }
4602 ;
4603 this.emit("idle", this);
4604 }
4605 ;
4606 return true;
4607 }
4608 ;
4609 return false;
4610 }
4611 get idle() {
4612 var self = this;
4613 return this112] || (this112] = new Promise(function(resolve) {
4614 return self[φ28] = resolve;
4615 }));
4616 }
4617};
4618
4619// src/imba/router/index.imba
4620function extend$__10(target, ext) {
4621 var descriptors = Object.getOwnPropertyDescriptors(ext);
4622 Object.defineProperties(target, descriptors);
4623 return target;
4624}
4625var φ113 = Symbol.for("#enter");
4626var φ29 = Symbol.for("#resolved");
4627var φ34 = Symbol.for("#leave");
4628var φ44 = Symbol.for("#router");
4629var φ55 = Symbol.for("#routes");
4630var φ64 = Symbol.for("#version");
4631var φ74 = Symbol.for("#doc");
4632var φ83 = Symbol.for("#origin");
4633var φ93 = Symbol.for("#request");
4634var φ104 = Symbol.for("#hash");
4635var φ11 = Symbol.for("#routeTo");
4636var φ162 = Symbol.for("#path");
4637var φ172 = Symbol.for("#match");
4638var φ182 = Symbol.for("#options");
4639var φ192 = Symbol.for("#cache");
4640var φ203 = Symbol.for("#unmatched");
4641var φ212 = Symbol.for("#active");
4642var φ222 = Symbol.for("#resolvedPath");
4643var φ232 = Symbol.for("#dataKey");
4644var φ242 = Symbol.for("#activeKey");
4645var φ252 = Symbol.for("#urlKey");
4646var φ262 = Symbol.for("#dataMap");
4647var φ272 = Symbol.for("#href");
4648var φ282 = Symbol.for("#route");
4649var φ292 = Symbol.for("#context");
4650var φ30 = Symbol.for("#placeholder__");
4651var φ31 = Symbol.for("#routeHandler");
4652var φ322 = Symbol.for("#attachToParent");
4653var φ332 = Symbol.for("#detachFromParent");
4654var Extend$Document$af2 = class {
4655 get router() {
4656 return this44] || (this44] = new Router(this));
4657 }
4658};
4659extend$__10(Document.prototype, Extend$Document$af2.prototype);
4660function use_router() {
4661 return true;
4662}
4663var router = proxy(function() {
4664 return globalThis.document.router;
4665});
4666var Router = class extends import_events.EventEmitter {
4667 constructor(doc, o = {}) {
4668 super();
4669 this55] = {};
4670 this.aliases = {};
4671 this.redirects = {};
4672 this.rules = {};
4673 this.options = o;
4674 this.busy = [];
4675 this64] = 0;
4676 this74] = doc;
4677 this.queue = new Queue();
4678 this.webΦ = !!doc.defaultView;
4679 this.root = new RootRoute(this);
4680 this.history = globalThis.window.history;
4681 this.location = new Location(o.url || doc.location.href, this);
4682 this.mode = o.mode || "history";
4683 this.queue.on("busy", function() {
4684 return globalThis.document.flags.incr("_routing_");
4685 });
4686 this.queue.on("idle", function() {
4687 globalThis.document.flags.decr("_routing_");
4688 return commit();
4689 });
4690 this.setup();
4691 this;
4692 }
4693 get origin() {
4694 return this83] || (this83] = this74].location.origin);
4695 }
4696 get query() {
4697 return this.location.query;
4698 }
4699 init() {
4700 this.refresh({mode: "replace"});
4701 return this;
4702 }
4703 alias(from, to) {
4704 this.aliases[from] = to;
4705 this.location.reparse();
4706 return this;
4707 }
4708 touch() {
4709 return this64]++;
4710 }
4711 option(key, value) {
4712 if (value == void 0) {
4713 return this.options[key];
4714 } else {
4715 this.options[key] = value;
4716 }
4717 ;
4718 return this;
4719 }
4720 get realpath() {
4721 let loc = this74].location;
4722 return loc.href.slice(loc.origin.length);
4723 }
4724 get state() {
4725 return {};
4726 }
4727 get ctx() {
4728 return this93];
4729 }
4730 pushState(state, title, url) {
4731 return this.history.pushState(state, title || null, String(url));
4732 }
4733 replaceState(state, title, url) {
4734 return this.history.replaceState(state, title || null, String(url));
4735 }
4736 refresh(params = {}) {
4737 var self = this;
4738 if (this.refreshing) {
4739 return;
4740 }
4741 ;
4742 this.refreshing = true;
4743 let original = this.location;
4744 let loc = Location.parse(params.location || this.realpath, this);
4745 let mode = params.mode;
4746 let prev = this93];
4747 if (!loc.equals(original) || !prev) {
4748 let req = new Request(this, loc, original);
4749 req.mode = mode;
4750 this93] = req;
4751 this.emit("beforechange", req);
4752 if (req.aborted) {
4753 let res = !req.forceAbort && globalThis.window.confirm("Are you sure you want to leave? You might have unsaved changes");
4754 if (res) {
4755 req.aborted = false;
4756 } else if (mode == "pop") {
4757 this.pushState(this.state, null, String(original));
4758 } else if (mode == "replace") {
4759 this.replaceState(this.state, null, String(original));
4760 }
4761 ;
4762 }
4763 ;
4764 if (!req.aborted) {
4765 this.location = req.location;
4766 if (mode == "push") {
4767 this.pushState(params.state || this.state, null, String(this.location));
4768 } else if (mode == "replace") {
4769 this.replaceState(params.state || this.state, null, String(this.location));
4770 }
4771 ;
4772 this.location.state = globalThis.window.history.state;
4773 this.emit("change", req);
4774 this.touch();
4775 commit();
4776 }
4777 ;
4778 }
4779 ;
4780 scheduler.add(function() {
4781 let hash = self[φ74].location.hash;
4782 if (hash != self[φ104]) {
4783 return self.emit("hashchange", self[φ104] = hash);
4784 }
4785 ;
4786 });
4787 this.refreshing = false;
4788 return this;
4789 }
4790 onpopstate(e) {
4791 this.refresh({pop: true, mode: "pop"});
4792 return this;
4793 }
4794 onbeforeunload(e) {
4795 let req = new Request(this, null, this.location);
4796 this.emit("beforechange", req);
4797 if (req.aborted) {
4798 return true;
4799 }
4800 ;
4801 return;
4802 }
4803 onhashchange(e) {
4804 this.emit("hashchange", this104] = this74].location.hash);
4805 return commit();
4806 }
4807 setup() {
4808 this.onclick = this.onclick.bind(this);
4809 this.onhashchange = this.onhashchange.bind(this);
4810 let win = globalThis.window;
4811 this104] = this74].location.hash;
4812 this.location = Location.parse(this.realpath, this);
4813 this.history.replaceState(this.state, null, String(this.location));
4814 win.onpopstate = this.onpopstate.bind(this);
4815 win.onbeforeunload = this.onbeforeunload.bind(this);
4816 win.addEventListener("hashchange", this.onhashchange);
4817 win.addEventListener("click", this.onclick, {capture: true});
4818 win.document.documentElement.emit("routerinit", this);
4819 this.refresh;
4820 return this;
4821 }
4822 onclick(e) {
4823 if (e.metaKey || e.altKey) {
4824 return;
4825 }
4826 ;
4827 let a = null;
4828 let r = null;
4829 let t = e.target;
4830 while (t && (!a || !r)) {
4831 if (!a && t.nodeName == "A") {
4832 a = t;
4833 }
4834 ;
4835 if (!r && t[φ11]) {
4836 r = t;
4837 }
4838 ;
4839 t = t.parentNode;
4840 }
4841 ;
4842 if (a && r != a && (!r || r.contains(a))) {
4843 let href = a.getAttribute("href");
4844 if (href && !href.match(/\:\/\//) && !a.getAttribute("target") && !a.classList.contains("external")) {
4845 a.addEventListener("click", this.onclicklink.bind(this), {once: true});
4846 }
4847 ;
4848 }
4849 ;
4850 return true;
4851 }
4852 onclicklink(e) {
4853 let a = e.currentTarget || e.target;
4854 if (a[φ11]) {
4855 a[φ11].resolve();
4856 }
4857 ;
4858 let href = a.getAttribute("href");
4859 let url = new URL(a.href);
4860 let target = url.href.slice(url.origin.length);
4861 let currpath = this.realpath.split("#")[0];
4862 let newpath = target.split("#")[0];
4863 if (currpath == newpath) {
4864 globalThis.document.location.hash = url.hash;
4865 } else if (a[φ11]) {
4866 a[φ11].go();
4867 } else {
4868 this.go(target);
4869 }
4870 ;
4871 e.stopPropagation();
4872 return e.preventDefault();
4873 }
4874 get url() {
4875 return this.location.url;
4876 }
4877 get path() {
4878 let path = this.location.path;
4879 return this.aliases[path] || path;
4880 }
4881 get pathname() {
4882 return this.location.pathname;
4883 }
4884 serializeParams(params) {
4885 var φ123;
4886 if (params instanceof Object) {
4887 φ123 = [];
4888 for (let φ132 = 0, φ142 = Object.keys(params), φ152 = φ142.length, key, val; φ132 < φ152; φ132++) {
4889 key = φ142132];
4890 val = params[key];
4891 φ123.push([key, globalThis.encodeURI(val)].join("="));
4892 }
4893 ;
4894 let value = φ123;
4895 return value.join("&");
4896 }
4897 ;
4898 return params || "";
4899 }
4900 get hash() {
4901 return this104];
4902 }
4903 set hash(value) {
4904 this.history.replaceState({}, null, "#" + this.serializeParams(value));
4905 }
4906 match(pattern) {
4907 return this.route(pattern).match(this.path);
4908 }
4909 route(pattern) {
4910 return this.root.route(pattern);
4911 }
4912 go(url, state = {}) {
4913 let loc = this.location.clone().update(url, state);
4914 this.refresh({push: true, mode: "push", location: loc, state});
4915 return this;
4916 }
4917 replace(url, state = {}) {
4918 let loc = this.location.clone().update(url, state);
4919 return this.refresh({replace: true, mode: "replace", location: loc, state});
4920 }
4921};
4922var ElementRoute = class {
4923 constructor(node, path, parent, options = {}) {
4924 this.parent = parent;
4925 this.node = node;
4926 this162] = path;
4927 this172] = null;
4928 this182] = options;
4929 this192] = {};
4930 this203] = {};
4931 this212] = null;
4932 this222] = null;
4933 this232] = Symbol();
4934 this242] = Symbol();
4935 this252] = Symbol();
4936 }
4937 get router() {
4938 return this.node.ownerDocument.router;
4939 }
4940 get route() {
4941 let pr = this.parent ? this.parent.route : this.router;
4942 return pr.route(this162]);
4943 }
4944 get match() {
4945 return this172];
4946 }
4947 get params() {
4948 return this172] || this203];
4949 }
4950 get state() {
4951 let map = this262] || (this262] = new Map());
4952 let pars = this.params;
4953 let data = this262].get(pars);
4954 data || this262].set(pars, data = {});
4955 return data;
4956 }
4957 set state(value) {
4958 (this262] || (this262] = new Map())).set(this.params, value);
4959 }
4960 set path(value) {
4961 if (this162] != value ? (this162] = value, true) : false) {
4962 this.router.touch();
4963 }
4964 ;
4965 }
4966 get isActive() {
4967 return !!this212];
4968 }
4969 resolve() {
4970 let v = this.router[φ64];
4971 if (!(this64] != v ? (this64] = v, true) : false)) {
4972 return;
4973 }
4974 ;
4975 let r = this.route;
4976 let o = this182];
4977 let url = this.router.path;
4978 let match = r.match(url);
4979 let shown = this212];
4980 let last = this172];
4981 let changed = match != last;
4982 let prevUrl = match && match[this252]];
4983 if (match) {
4984 this212] = true;
4985 this172] = match;
4986 match[this252]] = url;
4987 }
4988 ;
4989 if (match) {
4990 if (changed || prevUrl != url) {
4991 this29](match, last, prevUrl);
4992 }
4993 ;
4994 }
4995 ;
4996 if (!shown && match) {
4997 this113]();
4998 }
4999 ;
5000 if (!match && (shown || shown === null)) {
5001 this212] = false;
5002 this34]();
5003 }
5004 ;
5005 return this172];
5006 }
5007113]() {
5008 var _a, _b;
5009 this.node.flags.remove("not-routed");
5010 this.node.flags.add("routed");
5011 return (_b = (_a = this.node) == null ? void 0 : _a.routeDidEnter) == null ? void 0 : _b.call(_a, this);
5012 }
501329](match, prev, prevUrl = "") {
5014 var _a, _b;
5015 return (_b = (_a = this.node) == null ? void 0 : _a.routeDidResolve) == null ? void 0 : _b.call(_a, this, match, prev, prevUrl);
5016 }
501734]() {
5018 var _a, _b;
5019 this.node.flags.add("not-routed");
5020 this.node.flags.remove("routed");
5021 return (_b = (_a = this.node) == null ? void 0 : _a.routeDidLeave) == null ? void 0 : _b.call(_a, this);
5022 }
5023};
5024var ElementRouteTo = class extends ElementRoute {
5025113]() {
5026 return this;
5027 }
502829]() {
5029 return this;
5030 }
503134]() {
5032 return this;
5033 }
5034 resolve() {
5035 let v = this.router[φ64];
5036 if (!(this64] != v ? (this64] = v, true) : false)) {
5037 return;
5038 }
5039 ;
5040 let o = this182];
5041 let r = this.route;
5042 let url = this.router.path;
5043 let href = this.route.resolve(url);
5044 let match = this.route.match(url);
5045 if (match) {
5046 this172] = match;
5047 this172][this252]] = url;
5048 }
5049 ;
5050 if (o.sticky && this172]) {
5051 href = this172][this252]];
5052 }
5053 ;
5054 if (this272] != href ? (this272] = href, true) : false) {
5055 if (this.node.nodeName == "A") {
5056 this.node.setAttribute("href", href);
5057 }
5058 ;
5059 }
5060 ;
5061 this.node.flags.toggle("active", !!match);
5062 return;
5063 }
5064 go() {
5065 this.resolve();
5066 if (this182] && this182].replace) {
5067 return this.router.replace(this272]);
5068 } else {
5069 return this.router.go(this272]);
5070 }
5071 ;
5072 }
5073};
5074var Extend$Node$ag2 = class {
5075 get router() {
5076 return this.ownerDocument.router;
5077 }
5078};
5079extend$__10(Node.prototype, Extend$Node$ag2.prototype);
5080var Extend$Element$ah2 = class {
5081 set route(value) {
5082 var self = this;
5083 if (this282]) {
5084 this282].path = value;
5085 return;
5086 }
5087 ;
5088 let par = value[0] != "/" ? this292].route : null;
5089 this282] = new ElementRoute(this, value, par, this.route__);
5090 this.end$ = this.end$routed;
5091 this.insertInto$ = function(parent) {
5092 return parent.appendChild$(self[φ282].isActive ? self : self[φ30]);
5093 };
5094 }
5095 get route() {
5096 return this282];
5097 }
5098 set routeΞto(value) {
5099 var self = this;
5100 if (this11]) {
5101 this11].path = value;
5102 return;
5103 }
5104 ;
5105 let par = value[0] != "/" ? this292].route : null;
5106 this282] = this11] = new ElementRouteTo(this, value, par, this.routeTo__);
5107 this.end$ = this.end$routeTo;
5108 this.onclick = function(e) {
5109 if (!e.altKey && !e.metaKey && !e[φ31]) {
5110 e.preventDefault();
5111 e[φ31] = self[φ11];
5112 return self[φ11].go();
5113 }
5114 ;
5115 };
5116 }
5117 end$routed() {
5118 if (this282]) {
5119 this282].resolve();
5120 if (!this282].isActive) {
5121 return;
5122 }
5123 ;
5124 }
5125 ;
5126 if (this.visit) {
5127 return this.visit();
5128 }
5129 ;
5130 }
5131 end$routeTo() {
5132 if (this11]) {
5133 this11].resolve();
5134 }
5135 ;
5136 if (this.visit) {
5137 return this.visit();
5138 }
5139 ;
5140 }
5141 routeDidEnter(route) {
5142 return this322]();
5143 }
5144 routeDidLeave(route) {
5145 return this332]();
5146 }
5147 routeDidResolve(route, match, prev) {
5148 var self = this;
5149 if (this.routed instanceof Function && match != prev) {
5150 this.router.queue.add(async function() {
5151 self.suspend();
5152 let res = await self.routed(match, route.state, prev);
5153 return self.unsuspend();
5154 });
5155 }
5156 ;
5157 return;
5158 }
5159};
5160extend$__10(Element.prototype, Extend$Element$ah2.prototype);
5161export {
5162 CUSTOM_TYPES,
5163 Comment,
5164 CustomEvent2 as CustomEvent,
5165 Document,
5166 DocumentFragment,
5167 Element,
5168 ElementRoute,
5169 ElementRouteTo,
5170 Event,
5171 EventHandler,
5172 HTMLButtonElement,
5173 HTMLElement,
5174 HTMLHtmlElement,
5175 HTMLInputElement,
5176 HTMLOptionElement,
5177 HTMLScriptElement,
5178 HTMLSelectElement,
5179 HTMLTextAreaElement,
5180 ImbaElement,
5181 IntersectionEventDefaults,
5182 KeyboardEvent,
5183 LazyProxy,
5184 MouseEvent,
5185 Node,
5186 PointerEvent,
5187 Router,
5188 SVGElement,
5189 Scheduler,
5190 ShadowRoot,
5191 TYPES,
5192 Text,
5193 UIEvent,
5194 Window,
5195 asset,
5196 clearInterval,
5197 clearTimeout,
5198 colors,
5199 commit,
5200 createComment,
5201 createComponent,
5202 createElement,
5203 createFragment,
5204 createIndexedFragment,
5205 createKeyedFragment,
5206 createLiveFragment,
5207 createSVGElement,
5208 customElements,
5209 defineTag,
5210 deserializeData,
5211 emit,
5212 events,
5213 getDeepPropertyDescriptor,
5214 getSuperTagType,
5215 getTagType,
5216 get_document,
5217 hydrate,
5218 listen,
5219 manifest,
5220 mount,
5221 once,
5222 parseTime,
5223 patchManifest,
5224 process,
5225 proxy,
5226 render,
5227 renderContext,
5228 router,
5229 scheduler,
5230 serializeData,
5231 setInterval,
5232 setTimeout2 as setTimeout,
5233 styles,
5234 toCamelCase,
5235 unlisten,
5236 use_dom_bind,
5237 use_dom_global_hook,
5238 use_events,
5239 use_events_intersect,
5240 use_events_pointer,
5241 use_events_resize,
5242 use_events_selection,
5243 use_router,
5244 use_styles,
5245 use_window
5246};