@manyducks.co/dolla 2.0.0-alpha.16 → 2.0.0-alpha.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1398 +0,0 @@
1
- var yt = Object.defineProperty;
2
- var wt = (e, t, n) => t in e ? yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var u = (e, t, n) => wt(e, typeof t != "symbol" ? t + "" : t, n);
4
- function ot(e) {
5
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
6
- }
7
- var P = { exports: {} }, J;
8
- function Ct() {
9
- return J || (J = 1, function(e, t) {
10
- Object.defineProperty(t, "__esModule", { value: !0 });
11
- var n = /* @__PURE__ */ function() {
12
- function a(h, d) {
13
- var f = [], y = !0, w = !1, S = void 0;
14
- try {
15
- for (var v, b = h[Symbol.iterator](); !(y = (v = b.next()).done) && (f.push(v.value), !(d && f.length === d)); y = !0) ;
16
- } catch (m) {
17
- w = !0, S = m;
18
- } finally {
19
- try {
20
- !y && b.return && b.return();
21
- } finally {
22
- if (w) throw S;
23
- }
24
- }
25
- return f;
26
- }
27
- return function(h, d) {
28
- if (Array.isArray(h)) return h;
29
- if (Symbol.iterator in Object(h)) return a(h, d);
30
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
31
- };
32
- }(), s = function(a) {
33
- return a.reduce(function(h, d) {
34
- return 16 > d ? h + "0" + d.toString(16) : h + d.toString(16);
35
- }, "#");
36
- }, r = function(a, h, d) {
37
- var f = 0.5 > d ? d * (1 + h) : d + h - d * h, y = 2 * d - f, w = function(m, E, l) {
38
- var p = Math.round, g = 0 > l ? l + 1 : 1 < l ? l - 1 : l;
39
- return g = g < 1 / 6 ? m + 6 * (E - m) * g : g < 1 / 2 ? E : g < 2 / 3 ? m + 6 * (E - m) * (2 / 3 - g) : m, p(255 * g);
40
- }, S = w(y, f, a + 1 / 3), v = w(y, f, a), b = w(y, f, a - 1 / 3);
41
- return [S, v, b];
42
- }, o = function(a, h, d, f) {
43
- var y = a % 1007 / 1007, w = function(m, E, l) {
44
- return m * (l - E) + E;
45
- }, S = w(y, h.min, h.max), v = w(y, d.min, d.max), b = w(y, f.max, f.min);
46
- return [S, v, b];
47
- }, i = function(a) {
48
- return a.split("").reduce(function(h, d, f) {
49
- return h * d.charCodeAt(0) * f + 1;
50
- }, 1);
51
- }, c = function(a) {
52
- var h = a.str, d = a.hue, f = d === void 0 ? { min: 0, max: 360 } : d, y = a.sat, w = y === void 0 ? { min: 0.35, max: 0.65 } : y, S = a.light, v = S === void 0 ? { min: 0.3, max: 0.7 } : S, b = a.hashFunction, m = b === void 0 ? i : b, E = a.scheme, l = E === void 0 ? "hex" : E, p = o(m(h), f, w, v), g = n(p, 3), N = g[0], z = g[1], Y = g[2], Z = r(N / 360, z, Y), gt = s(Z);
53
- return l === "hsl" ? [N, z, Y] : l === "rgb" ? Z : gt;
54
- };
55
- t.default = c, e.exports = t.default;
56
- }(P, P.exports)), P.exports;
57
- }
58
- var bt = Ct();
59
- const vt = /* @__PURE__ */ ot(bt);
60
- function R(e) {
61
- if (e === void 0)
62
- return "undefined";
63
- if (e === null)
64
- return "null";
65
- const t = typeof e;
66
- switch (t) {
67
- case "number":
68
- return isNaN(e) ? "NaN" : "number";
69
- case "function":
70
- return ut(e) ? "class" : t;
71
- case "object":
72
- return M(e) ? "array" : Et(e) ? "promise" : t;
73
- default:
74
- return t;
75
- }
76
- }
77
- function M(e) {
78
- return Array.isArray(e);
79
- }
80
- function it(...e) {
81
- const t = e[0], n = (s) => M(s) && s.every((r) => t(r));
82
- return e.length < 2 ? n : n(e[1]);
83
- }
84
- function Yt(...e) {
85
- const t = e[0], n = A(e[2]) ? e[2] : "Expected an array of valid items. Got type: %t, value: %v", s = (r) => {
86
- if (M(r) && r.every((o) => t(o)))
87
- return !0;
88
- throw new TypeError(G(r, n));
89
- };
90
- return e.length < 2 ? s : s(e[1]);
91
- }
92
- function A(e) {
93
- return typeof e == "string";
94
- }
95
- function Zt(e, t) {
96
- if (A(e))
97
- return !0;
98
- throw new TypeError(G(e, t ?? "Expected a string. Got type: %t, value: %v"));
99
- }
100
- function $(e) {
101
- return typeof e == "function" && !ut(e);
102
- }
103
- function St(e) {
104
- return typeof e == "number" && !isNaN(e);
105
- }
106
- function Et(e) {
107
- if (e == null) return !1;
108
- const t = e;
109
- return t instanceof Promise || $(t.then) && $(t.catch) && $(t.finally);
110
- }
111
- function ut(e) {
112
- return typeof e == "function" && /^\s*class\s+/.test(e.toString());
113
- }
114
- function Jt(...e) {
115
- const t = e[0], n = A(e[2]) ? e[2] : `Expected instance of ${t.name}. Got type: %t, value: %v`, s = (r) => {
116
- if (r instanceof t)
117
- return !0;
118
- throw new TypeError(G(r, n));
119
- };
120
- return e.length < 2 ? s : s(e[1]);
121
- }
122
- function L(e) {
123
- return e != null && typeof e == "object" && !M(e);
124
- }
125
- function G(e, t) {
126
- var r;
127
- const n = R(e), s = ((r = e == null ? void 0 : e.toString) == null ? void 0 : r.call(e)) || String(e);
128
- return t.replaceAll("%t", n).replaceAll("%v", s);
129
- }
130
- var I, Q;
131
- function kt() {
132
- return Q || (Q = 1, I = function e(t, n) {
133
- if (t === n) return !0;
134
- if (t && n && typeof t == "object" && typeof n == "object") {
135
- if (t.constructor !== n.constructor) return !1;
136
- var s, r, o;
137
- if (Array.isArray(t)) {
138
- if (s = t.length, s != n.length) return !1;
139
- for (r = s; r-- !== 0; )
140
- if (!e(t[r], n[r])) return !1;
141
- return !0;
142
- }
143
- if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
144
- if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
145
- if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
146
- if (o = Object.keys(t), s = o.length, s !== Object.keys(n).length) return !1;
147
- for (r = s; r-- !== 0; )
148
- if (!Object.prototype.hasOwnProperty.call(n, o[r])) return !1;
149
- for (r = s; r-- !== 0; ) {
150
- var i = o[r];
151
- if (!e(t[i], n[i])) return !1;
152
- }
153
- return !0;
154
- }
155
- return t !== t && n !== n;
156
- }), I;
157
- }
158
- var xt = kt();
159
- const Qt = /* @__PURE__ */ ot(xt), Nt = () => {
160
- };
161
- function $t(e, t) {
162
- const n = (s) => {
163
- const r = {};
164
- for (const o in s)
165
- e.includes(o) || (r[o] = s[o]);
166
- return r;
167
- };
168
- return t == null ? n : n(t);
169
- }
170
- function Xt() {
171
- if (typeof window < "u" && window.console)
172
- return window.console;
173
- if (typeof global < "u" && global.console)
174
- return global.console;
175
- }
176
- function _t(e) {
177
- return vt({
178
- str: e,
179
- sat: { min: 0.35, max: 0.55 },
180
- light: { min: 0.6, max: 0.6 }
181
- });
182
- }
183
- function te(e) {
184
- if (e instanceof RegExp)
185
- return (s) => e.test(s);
186
- const t = {
187
- positive: [],
188
- negative: []
189
- }, n = e.split(",").map((s) => s.trim()).filter((s) => s !== "");
190
- for (let s of n) {
191
- let r = "positive";
192
- s.startsWith("-") && (r = "negative", s = s.slice(1)), s === "*" ? t[r].push(function() {
193
- return !0;
194
- }) : s.endsWith("*") ? t[r].push(function(o) {
195
- return o.startsWith(s.slice(0, s.length - 1));
196
- }) : t[r].push(function(o) {
197
- return o === s;
198
- });
199
- }
200
- return function(s) {
201
- const { positive: r, negative: o } = t;
202
- return !(o.some((i) => i(s)) || r.length > 0 && !r.some((i) => i(s)));
203
- };
204
- }
205
- const q = {
206
- watcherCount: 0,
207
- increment() {
208
- this.watcherCount++, this._log();
209
- },
210
- decrement() {
211
- this.watcherCount--, this._log();
212
- },
213
- _label: "dolla/state-tracker",
214
- _timeout: null,
215
- _log() {
216
- window.DOLLA_DEV_DEBUG === !0 && !this._timeout && (this._timeout = setTimeout(() => {
217
- console.log(
218
- `%c[DOLLA_DEV_DEBUG] %c${this._label}%c%c%c`,
219
- "color:#e44c4c;font-weight:bold",
220
- `color:${_t(this._label)};font-weight:bold`,
221
- "color:#777",
222
- "color:#aaa",
223
- "color:#777",
224
- { watcherCount: this.watcherCount }
225
- ), this._timeout = null;
226
- }, 200));
227
- }
228
- }, U = Symbol("State"), B = Symbol("SettableState"), ct = Symbol("Ref");
229
- function C(e) {
230
- return (e == null ? void 0 : e[U]) === !0;
231
- }
232
- function D(e) {
233
- return (e == null ? void 0 : e[B]) === !0;
234
- }
235
- function at(e) {
236
- return (e == null ? void 0 : e[ct]) === !0;
237
- }
238
- function At(e) {
239
- return C(e) ? e.get() : e;
240
- }
241
- function j(e) {
242
- return D(e) ? new F(e) : C(e) ? e : new F({
243
- get() {
244
- return e;
245
- },
246
- watch(t, n = {}) {
247
- return n != null && n.lazy || t(e), Nt;
248
- }
249
- });
250
- }
251
- class T {
252
- constructor(t, n) {
253
- u(this, "value");
254
- u(this, "watchers", []);
255
- u(this, "equals", T.defaultEquals);
256
- this.value = t, n != null && n.equals && (this.equals = n.equals);
257
- }
258
- static defaultEquals(t, n) {
259
- return t === n;
260
- }
261
- get() {
262
- return this.value;
263
- }
264
- set(t) {
265
- if (typeof t == "function" && (t = t(this.value)), !this.equals(t, this.value)) {
266
- this.value = t;
267
- try {
268
- for (const n of this.watchers)
269
- n(t);
270
- } catch (n) {
271
- throw console.error("Error in watcher", n), n;
272
- }
273
- }
274
- }
275
- watch(t, n) {
276
- return this.watchers.push(t), n != null && n.lazy || t(this.value), q.increment(), () => {
277
- const s = this.watchers.indexOf(t);
278
- s > -1 && this.watchers.splice(s, 1), q.decrement();
279
- };
280
- }
281
- }
282
- var et;
283
- et = U;
284
- class F {
285
- constructor(t) {
286
- // Instances will pass isState() with this symbol
287
- u(this, et, !0);
288
- u(this, "__value");
289
- if (t == null)
290
- throw new TypeError("Value is null");
291
- this.__value = t;
292
- }
293
- get() {
294
- return this.__value.get();
295
- }
296
- watch(t, n) {
297
- return this.__value.watch(t, n);
298
- }
299
- }
300
- function W(e, t) {
301
- const n = new T(e, t);
302
- return [new F(n), (r) => n.set(r)];
303
- }
304
- var nt, st;
305
- st = U, nt = B;
306
- class Vt {
307
- constructor(t) {
308
- // Instances will pass isState() and isSettableState() with these symbols
309
- u(this, st, !0);
310
- u(this, nt, !0);
311
- u(this, "__value");
312
- if (t == null)
313
- throw new TypeError("Value is null");
314
- this.__value = t;
315
- }
316
- get() {
317
- return this.__value.get();
318
- }
319
- set(t) {
320
- this.__value.set(t);
321
- }
322
- watch(t, n) {
323
- return this.__value.watch(t, n);
324
- }
325
- }
326
- function ee(e, t) {
327
- return new Vt(new T(e, t));
328
- }
329
- function ne(e, t) {
330
- return {
331
- [U]: !0,
332
- [B]: !0,
333
- get: e.get.bind(e),
334
- watch: e.watch.bind(e),
335
- set: t
336
- };
337
- }
338
- function se(e, t) {
339
- return function(s) {
340
- const r = e.get();
341
- let o;
342
- typeof s == "function" ? o = s(r) : o = s, t(o, r);
343
- };
344
- }
345
- const X = Symbol("EMPTY");
346
- class Mt {
347
- constructor(t, n, s) {
348
- u(this, "equals", T.defaultEquals);
349
- /**
350
- * Array of states this holder's value is derived from.
351
- */
352
- u(this, "sources", []);
353
- /**
354
- * The function that does the deriving. Receives source values and returns a derived value.
355
- */
356
- u(this, "fn");
357
- /**
358
- *
359
- */
360
- u(this, "sourceWatcher", K());
361
- /**
362
- * Array of functions awaiting notification when this holder's value changes.
363
- */
364
- u(this, "watchers", []);
365
- /**
366
- * True when this holder is actively watching sources.
367
- */
368
- u(this, "isWatchingSources", !1);
369
- /**
370
- * Latest values as received from sources.
371
- */
372
- u(this, "previousSourceValues");
373
- /**
374
- * The current value as returned from `fn` (may be a State)
375
- */
376
- u(this, "value", X);
377
- /**
378
- * The current unwrapped value.
379
- */
380
- u(this, "rawValue");
381
- /**
382
- * When value is a State, this function will stop watching its value.
383
- */
384
- u(this, "stopWatchingCurrentValue");
385
- this.sources = t.map(j), this.fn = n, s != null && s.equals && (this.equals = s.equals), this.previousSourceValues = new Array(t.length).fill(X, 0, t.length);
386
- }
387
- /*==========================*\
388
- || "Public" methods ||
389
- \*==========================*/
390
- get() {
391
- return this.getValue();
392
- }
393
- watch(t, n) {
394
- this.isWatchingSources || this.startWatchingSources();
395
- const s = this.watchers;
396
- return s.push(t), n != null && n.lazy || t(this.rawValue), q.increment(), () => {
397
- s.splice(s.indexOf(t), 1), this.isWatchingSources && s.length === 0 && this.stopWatchingSources(), q.decrement();
398
- };
399
- }
400
- /*==========================*\
401
- || Internal ||
402
- \*==========================*/
403
- notify(t) {
404
- for (const n of this.watchers)
405
- n(t);
406
- }
407
- update() {
408
- const t = this.sources, n = this.previousSourceValues;
409
- let s = !1, r;
410
- for (let o = 0; o < t.length; o++)
411
- r = t[o].get(), !s && !this.equals(r, n[o]) && (s = !0), n[o] = r;
412
- s && this.setValue(this.fn(...n));
413
- }
414
- getValue() {
415
- return this.isWatchingSources || this.update(), this.rawValue;
416
- }
417
- setValue(t) {
418
- this.stopWatchingCurrentValue && (this.stopWatchingCurrentValue(), this.stopWatchingCurrentValue = void 0), this.value = t, this.rawValue = At(t), this.isWatchingSources && C(t) ? this.stopWatchingCurrentValue = t.watch((n) => {
419
- this.rawValue = n, this.notify(n);
420
- }) : this.notify(this.rawValue);
421
- }
422
- startWatchingSources() {
423
- const t = this.previousSourceValues;
424
- for (let s = 0; s < this.sources.length; s++)
425
- this.sourceWatcher.watch([this.sources[s]], (r) => {
426
- if (t[s] = r, this.isWatchingSources) {
427
- const o = this.fn(...t);
428
- this.equals(o, this.value) || this.setValue(o);
429
- }
430
- });
431
- this.isWatchingSources = !0;
432
- const n = this.fn(...t);
433
- this.equals(n, this.value) || this.setValue(n);
434
- }
435
- stopWatchingSources() {
436
- this.sourceWatcher.stopAll(), this.stopWatchingCurrentValue && (this.stopWatchingCurrentValue(), this.stopWatchingCurrentValue = void 0), this.isWatchingSources = !1;
437
- }
438
- }
439
- function Tt(e, t, n) {
440
- const s = new Mt(e, t, n);
441
- return new F(s);
442
- }
443
- var rt;
444
- rt = ct;
445
- class Ot {
446
- constructor(t) {
447
- // Instances will pass isRef() with this symbol
448
- u(this, rt, !0);
449
- u(this, "__value");
450
- this.__value = t;
451
- }
452
- get() {
453
- return this.__value.get();
454
- }
455
- watch(t, n) {
456
- return this.__value.watch(t, n);
457
- }
458
- get node() {
459
- return this.__value.get();
460
- }
461
- set node(t) {
462
- this.__value.set(t);
463
- }
464
- }
465
- function re() {
466
- return new Ot(new T(void 0));
467
- }
468
- function K() {
469
- const e = [];
470
- return {
471
- watch(t, n) {
472
- if (t.length === 0)
473
- throw new TypeError("Expected at least one state to watch.");
474
- t = t.map(j);
475
- let s;
476
- return t.length > 1 ? s = Tt(t, n).watch(() => null) : s = t[0].watch(n), e.push(s), () => {
477
- let r = e.indexOf(s);
478
- r > -1 && e.splice(r, 1), s();
479
- };
480
- },
481
- stopAll() {
482
- for (; e.length > 0; )
483
- e.pop()();
484
- }
485
- };
486
- }
487
- function Pt(e) {
488
- for (var t, n, s = arguments, r = 1, o = "", i = "", c = [0], a = function(f) {
489
- r === 1 && (f || (o = o.replace(/^\s*\n\s*|\s*\n\s*$/g, ""))) ? c.push(f ? s[f] : o) : r === 3 && (f || o) ? (c[1] = f ? s[f] : o, r = 2) : r === 2 && o === "..." && f ? c[2] = Object.assign(c[2] || {}, s[f]) : r === 2 && o && !f ? (c[2] = c[2] || {})[o] = !0 : r >= 5 && (r === 5 ? ((c[2] = c[2] || {})[n] = f ? o ? o + s[f] : s[f] : o, r = 6) : (f || o) && (c[2][n] += f ? o + s[f] : o)), o = "";
490
- }, h = 0; h < e.length; h++) {
491
- h && (r === 1 && a(), a(h));
492
- for (var d = 0; d < e[h].length; d++) t = e[h][d], r === 1 ? t === "<" ? (a(), c = [c, "", null], r = 3) : o += t : r === 4 ? o === "--" && t === ">" ? (r = 1, o = "") : o = t + o[0] : i ? t === i ? i = "" : o += t : t === '"' || t === "'" ? i = t : t === ">" ? (a(), r = 1) : r && (t === "=" ? (r = 5, n = o, o = "") : t === "/" && (r < 5 || e[h][d + 1] === ">") ? (a(), r === 3 && (c = c[0]), r = c, (c = c[0]).push(this.apply(null, r.slice(1))), r = 0) : t === " " || t === " " || t === `
493
- ` || t === "\r" ? (a(), r = 2) : o += t), r === 3 && o === "!--" && (r = 4, c = c[0]);
494
- }
495
- return a(), c.length > 2 ? c.slice(1) : c[1];
496
- }
497
- class qt {
498
- constructor(t) {
499
- u(this, "node");
500
- u(this, "endNode");
501
- u(this, "$predicate");
502
- u(this, "stopCallback");
503
- u(this, "thenContent");
504
- u(this, "elseContent");
505
- u(this, "connectedContent", []);
506
- u(this, "elementContext");
507
- u(this, "initialUpdateHappened", !1);
508
- u(this, "previousValue");
509
- this.$predicate = t.$predicate, this.thenContent = t.thenContent ? O(t.thenContent) : void 0, this.elseContent = t.elseContent ? O(t.elseContent) : void 0, this.elementContext = t.elementContext, this.elementContext.root.getEnv() === "development" ? (this.node = document.createComment("Conditional"), this.endNode = document.createComment("/Conditional")) : (this.node = document.createTextNode(""), this.endNode = document.createTextNode(""));
510
- }
511
- get isMounted() {
512
- return this.node.parentNode != null;
513
- }
514
- mount(t, n) {
515
- this.isMounted || (t.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null), this.elementContext.root.getEnv() === "development" && t.insertBefore(this.endNode, this.node.nextSibling), this.stopCallback = this.$predicate.watch((s) => {
516
- (!this.initialUpdateHappened || s && !this.previousValue || !s && this.previousValue) && (this.update(s), this.initialUpdateHappened = !0, this.previousValue = s);
517
- }));
518
- }
519
- unmount() {
520
- var t, n;
521
- this.stopCallback && (this.stopCallback(), this.stopCallback = void 0);
522
- for (const s of this.connectedContent)
523
- s.unmount();
524
- this.connectedContent = [], this.isMounted && ((t = this.node.parentNode) == null || t.removeChild(this.node), (n = this.endNode.parentNode) == null || n.removeChild(this.endNode));
525
- }
526
- update(t) {
527
- var n;
528
- for (const s of this.connectedContent)
529
- s.unmount();
530
- if (this.connectedContent = [], this.node.parentNode != null) {
531
- t && this.thenContent ? this.connectedContent = x(this.elementContext, this.thenContent) : !t && this.elseContent && (this.connectedContent = x(this.elementContext, this.elseContent));
532
- for (let s = 0; s < this.connectedContent.length; s++) {
533
- const r = this.connectedContent[s], o = ((n = this.connectedContent[s - 1]) == null ? void 0 : n.node) ?? this.node;
534
- r.mount(this.node.parentNode, o);
535
- }
536
- this.elementContext.root.getEnv() === "development" && (this.node.textContent = `Conditional (${t ? "truthy" : "falsy"})`);
537
- }
538
- }
539
- }
540
- const Ft = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
541
- let lt = (e = 21) => {
542
- let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
543
- for (; e--; )
544
- t += Ft[n[e] & 63];
545
- return t;
546
- };
547
- const Wt = (e) => /^on[A-Z]/.test(e);
548
- class Lt {
549
- constructor({ tag: t, props: n, children: s, elementContext: r }) {
550
- u(this, "node");
551
- u(this, "props");
552
- u(this, "children");
553
- u(this, "stopCallbacks", []);
554
- u(this, "elementContext");
555
- u(this, "uniqueId", lt());
556
- // Track the ref so we can nullify it on unmount.
557
- u(this, "ref");
558
- // Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
559
- u(this, "canClickAway", !1);
560
- if (r = { ...r }, t.toLowerCase() === "svg" && (r.isSVG = !0), r.isSVG ? this.node = document.createElementNS("http://www.w3.org/2000/svg", t) : this.node = document.createElement(t), r.root.getEnv() === "development" && (this.node.dataset.uniqueId = this.uniqueId), n.ref)
561
- if (at(n.ref))
562
- this.ref = n.ref;
563
- else
564
- throw new Error("Expected ref to be a Ref object. Got: " + n.ref);
565
- this.props = {
566
- ...$t(["ref", "class", "className"], n),
567
- class: n.className ?? n.class
568
- }, this.children = s ? x(r, s) : [], this.elementContext = r;
569
- }
570
- get isMounted() {
571
- return this.node.parentNode != null;
572
- }
573
- mount(t, n) {
574
- if (t == null)
575
- throw new Error(`HTML element requires a parent element as the first argument to connect. Got: ${t}`);
576
- if (!this.isMounted) {
577
- for (const s of this.children)
578
- s.mount(this.node);
579
- this.applyProps(this.node, this.props), this.props.style && this.applyStyles(this.node, this.props.style, this.stopCallbacks), this.props.class && this.applyClasses(this.node, this.props.class, this.stopCallbacks);
580
- }
581
- t.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null), this.ref && (this.ref.node = this.node), setTimeout(() => {
582
- this.canClickAway = !0;
583
- }, 0);
584
- }
585
- unmount() {
586
- var t;
587
- if (this.isMounted) {
588
- for (const n of this.children)
589
- n.unmount();
590
- this.ref && (this.ref.node = void 0), (t = this.node.parentNode) == null || t.removeChild(this.node), this.canClickAway = !1;
591
- for (const n of this.stopCallbacks)
592
- n();
593
- this.stopCallbacks = [];
594
- }
595
- }
596
- getUpdateKey(t, n) {
597
- return `${this.uniqueId}:${t}:${n}`;
598
- }
599
- attachProp(t, n, s) {
600
- C(t) ? this.stopCallbacks.push(
601
- t.watch((r) => {
602
- this.elementContext.root.render.update(() => {
603
- n(r);
604
- }, s);
605
- })
606
- ) : this.elementContext.root.render.update(() => {
607
- n(t);
608
- }, s);
609
- }
610
- applyProps(t, n) {
611
- for (const s in n) {
612
- const r = n[s];
613
- if (s === "attributes") {
614
- const o = r;
615
- for (const i in o)
616
- this.attachProp(
617
- o[i],
618
- (c) => {
619
- c == null ? t.removeAttribute(i) : t.setAttribute(i, String(c));
620
- },
621
- this.getUpdateKey("attr", i)
622
- );
623
- } else if (s === "eventListeners") {
624
- const o = r;
625
- for (const i in o) {
626
- const c = C(r) ? (a) => r.get()(a) : r;
627
- t.addEventListener(i, c), this.stopCallbacks.push(() => {
628
- t.removeEventListener(i, c);
629
- });
630
- }
631
- } else if (s === "onClickOutside" || s === "onclickoutside") {
632
- const o = (c) => {
633
- this.canClickAway && !t.contains(c.target) && (C(r) ? r.get()(c) : r(c));
634
- }, i = { capture: !0 };
635
- window.addEventListener("click", o, i), this.stopCallbacks.push(() => {
636
- window.removeEventListener("click", o, i);
637
- });
638
- } else if (s === "$$value") {
639
- if (!D(r))
640
- throw new TypeError(`$$value attribute must be a settable state. Got: ${r}`);
641
- this.attachProp(
642
- r,
643
- (i) => {
644
- i == null ? t.value = "" : t.value = String(i);
645
- },
646
- this.getUpdateKey("attr", "value")
647
- );
648
- const o = (i) => {
649
- const c = Ut(r.get(), i.currentTarget.value);
650
- r.set(c);
651
- };
652
- t.addEventListener("input", o), this.stopCallbacks.push(() => {
653
- t.removeEventListener("input", o);
654
- });
655
- } else if (Wt(s)) {
656
- const o = s.slice(2).toLowerCase(), i = C(r) ? (c) => r.get()(c) : r;
657
- t.addEventListener(o, i), this.stopCallbacks.push(() => {
658
- t.removeEventListener(o, i);
659
- });
660
- } else if (s.includes("-"))
661
- this.attachProp(
662
- r,
663
- (o) => {
664
- o == null ? t.removeAttribute(s) : t.setAttribute(s, String(o));
665
- },
666
- this.getUpdateKey("attr", s)
667
- );
668
- else if (!jt.includes(s))
669
- if (this.elementContext.isSVG)
670
- this.attachProp(
671
- r,
672
- (o) => {
673
- o != null ? t.setAttribute(s, String(n[s])) : t.removeAttribute(s);
674
- },
675
- this.getUpdateKey("attr", s)
676
- );
677
- else
678
- switch (s) {
679
- case "contentEditable":
680
- case "value":
681
- this.attachProp(
682
- r,
683
- (o) => {
684
- t[s] = String(o);
685
- },
686
- this.getUpdateKey("prop", s)
687
- );
688
- break;
689
- case "for":
690
- this.attachProp(
691
- r,
692
- (o) => {
693
- t.htmlFor = o;
694
- },
695
- this.getUpdateKey("prop", "htmlFor")
696
- );
697
- break;
698
- case "checked":
699
- this.attachProp(
700
- r,
701
- (o) => {
702
- t.checked = o, o ? t.setAttribute("checked", "") : t.removeAttribute("checked");
703
- },
704
- this.getUpdateKey("prop", "checked")
705
- );
706
- break;
707
- // Attribute-aliased props
708
- case "exportParts":
709
- case "part":
710
- case "translate":
711
- case "type":
712
- case "title": {
713
- const o = s.toLowerCase();
714
- this.attachProp(
715
- r,
716
- (i) => {
717
- i == null ? t.removeAttribute(o) : t.setAttribute(o, String(i));
718
- },
719
- this.getUpdateKey("attr", o)
720
- );
721
- break;
722
- }
723
- case "autocomplete":
724
- case "autocapitalize":
725
- this.attachProp(
726
- r,
727
- (o) => {
728
- typeof o == "string" ? t.autocomplete = o : o ? t.autocomplete = "on" : t.autocomplete = "off";
729
- },
730
- this.getUpdateKey("prop", s)
731
- );
732
- break;
733
- default: {
734
- this.attachProp(
735
- r,
736
- (o) => {
737
- t[s] = o;
738
- },
739
- this.getUpdateKey("prop", s)
740
- );
741
- break;
742
- }
743
- }
744
- }
745
- }
746
- applyStyles(t, n, s) {
747
- const r = [];
748
- if (C(n)) {
749
- let o;
750
- const i = n.watch((c) => {
751
- this.elementContext.root.render.update(
752
- () => {
753
- $(o) && o(), t.style.cssText = "", o = this.applyStyles(t, c, s);
754
- },
755
- this.getUpdateKey("styles", "*")
756
- );
757
- });
758
- s.push(i), r.push(i);
759
- } else {
760
- const o = dt(n);
761
- for (const i in o) {
762
- const { value: c, priority: a } = o[i];
763
- if (C(c)) {
764
- const h = c.watch((d) => {
765
- this.elementContext.root.render.update(() => {
766
- d ? t.style.setProperty(i, String(d), a) : t.style.removeProperty(i);
767
- });
768
- });
769
- s.push(h), r.push(h);
770
- } else c != null && t.style.setProperty(i, String(c));
771
- }
772
- }
773
- return function() {
774
- for (const i of r)
775
- i(), s.splice(s.indexOf(i), 1);
776
- };
777
- }
778
- applyClasses(t, n, s) {
779
- const r = [];
780
- if (C(n)) {
781
- let o;
782
- const i = n.watch((c) => {
783
- this.elementContext.root.render.update(
784
- () => {
785
- $(o) && o(), t.removeAttribute("class"), o = this.applyClasses(t, c, s);
786
- },
787
- this.getUpdateKey("attr", "class")
788
- );
789
- });
790
- s.push(i), r.push(i);
791
- } else {
792
- const o = ht(n);
793
- for (const i in o) {
794
- const c = o[i];
795
- if (C(c)) {
796
- const a = c.watch((h) => {
797
- this.elementContext.root.render.update(() => {
798
- h ? t.classList.add(i) : t.classList.remove(i);
799
- });
800
- });
801
- s.push(a), r.push(a);
802
- } else c && t.classList.add(i);
803
- }
804
- }
805
- return function() {
806
- for (const i of r)
807
- i(), s.splice(s.indexOf(i), 1);
808
- };
809
- }
810
- }
811
- function ht(e) {
812
- let t = {};
813
- if (A(e)) {
814
- const n = e.split(" ");
815
- for (const s of n)
816
- t[s] = !0;
817
- } else L(e) ? Object.assign(t, e) : Array.isArray(e) && Array.from(e).filter(Boolean).forEach((n) => {
818
- Object.assign(t, ht(n));
819
- });
820
- return delete t.undefined, t;
821
- }
822
- function dt(e) {
823
- let t = {};
824
- if (A(e)) {
825
- const n = e.split(";").filter((s) => s.trim() !== "");
826
- for (const s of n) {
827
- const [r, o] = s.split(":"), i = {
828
- value: o
829
- };
830
- o.includes("!important") ? (i.priority = "important", i.value = o.replace("!important", "").trim()) : i.value = o.trim(), t[tt(r.trim())] = i;
831
- }
832
- }
833
- if (L(e))
834
- for (const n in e)
835
- n.startsWith("--") ? t[n] = { value: e[n] } : t[tt(n)] = { value: e[n] };
836
- else Array.isArray(e) && Array.from(e).filter((n) => n != null).forEach((n) => {
837
- Object.assign(t, dt(n));
838
- });
839
- return t;
840
- }
841
- function tt(e) {
842
- return e.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, n) => (n ? "-" : "") + t.toLowerCase());
843
- }
844
- function Ut(e, t) {
845
- const n = typeof e;
846
- return n === "string" ? String(t) : n === "number" ? Number(t) : n === "boolean" ? !!t : t;
847
- }
848
- const jt = ["ref", "children", "class", "style", "data"];
849
- class It {
850
- constructor({ states: t, renderFn: n, elementContext: s }) {
851
- u(this, "node");
852
- u(this, "endNode");
853
- u(this, "connectedViews", []);
854
- u(this, "renderFn");
855
- u(this, "elementContext");
856
- u(this, "observerControls");
857
- u(this, "watcher", K());
858
- this.elementContext = s, this.renderFn = n, this.node = document.createComment("Observer"), this.endNode = document.createComment("/Observer");
859
- let r;
860
- this.observerControls = {
861
- start: () => {
862
- r == null && (r = this.watcher.watch(t, (...o) => {
863
- const i = this.renderFn(...o);
864
- if (!mt(i))
865
- throw console.error(i), new TypeError(
866
- `Observer received invalid value to render. Got type: ${R(i)}, value: ${i}`
867
- );
868
- Array.isArray(i) ? this.update(...i) : this.update(i);
869
- }));
870
- },
871
- stop: () => {
872
- r != null && (r(), r = void 0);
873
- }
874
- };
875
- }
876
- get isMounted() {
877
- return this.node.parentNode != null;
878
- }
879
- mount(t, n) {
880
- this.isMounted || (t.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null), this.observerControls.start());
881
- }
882
- unmount() {
883
- var t;
884
- this.observerControls.stop(), this.watcher.stopAll(), this.isMounted && (this.cleanup(), (t = this.node.parentNode) == null || t.removeChild(this.node));
885
- }
886
- cleanup() {
887
- var t;
888
- for (; this.connectedViews.length > 0; )
889
- (t = this.connectedViews.pop()) == null || t.unmount();
890
- }
891
- update(...t) {
892
- var s, r;
893
- if (this.cleanup(), t == null || !this.isMounted)
894
- return;
895
- const n = t.map((o) => ft(o) ? o : V(o) ? _(x(this.elementContext, o)) : _(x(this.elementContext, O(o))));
896
- for (const o of n) {
897
- const i = ((s = this.connectedViews.at(-1)) == null ? void 0 : s.node) || this.node;
898
- o.mount(this.node.parentNode, i), this.connectedViews.push(o);
899
- }
900
- if (this.elementContext.root.getEnv() === "development") {
901
- const o = (r = this.connectedViews.at(-1)) == null ? void 0 : r.node;
902
- this.endNode.previousSibling !== o && this.node.parentNode.insertBefore(this.endNode, (o == null ? void 0 : o.nextSibling) ?? null);
903
- }
904
- }
905
- }
906
- class Rt {
907
- constructor(t) {
908
- u(this, "node");
909
- u(this, "endNode");
910
- u(this, "$children");
911
- u(this, "stopCallback");
912
- u(this, "mountedChildren", []);
913
- u(this, "elementContext");
914
- this.$children = t.$children, this.elementContext = t.elementContext, this.elementContext.root.getEnv() === "development" ? (this.node = document.createComment("Outlet"), this.endNode = document.createComment("/Outlet")) : (this.node = document.createTextNode(""), this.endNode = document.createTextNode(""));
915
- }
916
- get isMounted() {
917
- var t;
918
- return ((t = this.node) == null ? void 0 : t.parentNode) != null;
919
- }
920
- mount(t, n) {
921
- this.isMounted || (t.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null), this.stopCallback = this.$children.watch((s) => {
922
- this.update(s);
923
- }));
924
- }
925
- unmount() {
926
- var t;
927
- if (this.stopCallback && (this.stopCallback(), this.stopCallback = void 0), this.isMounted) {
928
- for (const n of this.mountedChildren)
929
- n.unmount();
930
- this.mountedChildren = [], (t = this.endNode.parentNode) == null || t.removeChild(this.endNode);
931
- }
932
- }
933
- update(t) {
934
- var n, s, r;
935
- for (const o of this.mountedChildren)
936
- o.unmount();
937
- for (let o = 0; o < t.length; o++) {
938
- const i = t[o], c = o > 0 ? t[o] : void 0;
939
- i.mount(this.node.parentElement, c == null ? void 0 : c.node);
940
- }
941
- this.mountedChildren = t, this.elementContext.root.getEnv() === "development" && (this.node.textContent = `Outlet (${t.length} ${t.length === 1 ? "child" : "children"})`, (r = this.node.parentElement) == null || r.insertBefore(
942
- this.endNode,
943
- ((s = (n = this.mountedChildren[this.mountedChildren.length - 1]) == null ? void 0 : n.node) == null ? void 0 : s.nextSibling) ?? null
944
- ));
945
- }
946
- }
947
- class Gt {
948
- constructor(t) {
949
- u(this, "config");
950
- u(this, "element");
951
- this.config = t;
952
- }
953
- get isMounted() {
954
- return this.element ? this.element.isMounted : !1;
955
- }
956
- mount(t, n) {
957
- const { content: s, parent: r } = this.config;
958
- ft(s) ? this.element = s : V(s) ? this.element = _(x(this.config.elementContext, s)) : this.element = _(x(this.config.elementContext, O(s))), this.element.mount(r);
959
- }
960
- unmount() {
961
- var t;
962
- (t = this.element) != null && t.isMounted && this.element.unmount();
963
- }
964
- }
965
- function H(e, t, n, s = []) {
966
- e = { ...e, data: {}, parent: e };
967
- const [r, o] = W(x(e, s));
968
- let i = !1;
969
- const c = K(), a = [], h = [], d = [], f = [], y = lt(), [w, S] = W(t.name), v = e.root.createLogger(w, { uid: y }), b = {
970
- get uid() {
971
- return y;
972
- },
973
- set(l, p) {
974
- return e.data[l] = p, p;
975
- },
976
- get(l) {
977
- let p = e;
978
- for (; ; ) {
979
- if (l in p.data)
980
- return p.data[l];
981
- if (p.parent)
982
- p = p.parent;
983
- else
984
- break;
985
- }
986
- return null;
987
- },
988
- getAll() {
989
- const l = [];
990
- let p = e;
991
- for (; l.push(p.data), p.parent; )
992
- p = p.parent;
993
- const g = {};
994
- for (const N of l.reverse())
995
- Object.assign(g, N);
996
- return g;
997
- },
998
- setName(l) {
999
- S(l);
1000
- },
1001
- beforeMount(l) {
1002
- a.push(l);
1003
- },
1004
- onMount(l) {
1005
- h.push(l);
1006
- },
1007
- beforeUnmount(l) {
1008
- d.push(l);
1009
- },
1010
- onUnmount(l) {
1011
- f.push(l);
1012
- },
1013
- watch(l, p) {
1014
- if (i)
1015
- return c.watch(l, p);
1016
- {
1017
- let g, N = !1;
1018
- return h.push(() => {
1019
- N || (g = c.watch(l, p));
1020
- }), () => {
1021
- g != null && (N = !0, g());
1022
- };
1023
- }
1024
- },
1025
- outlet() {
1026
- return k("$outlet", { $children: r });
1027
- }
1028
- };
1029
- Object.assign(b, v);
1030
- let m;
1031
- function E() {
1032
- let l;
1033
- try {
1034
- l = t(n, b);
1035
- } catch (p) {
1036
- throw p instanceof Error && v.crash(p), p;
1037
- }
1038
- if (l instanceof Promise)
1039
- throw new TypeError("View function cannot return a Promise.");
1040
- if (l !== null) if (l instanceof Node)
1041
- m = _(x(e, k("$node", { value: l })));
1042
- else if (V(l) || it(V, l))
1043
- m = _(x(e, l));
1044
- else if (C(l))
1045
- m = _(
1046
- x(e, k("$observer", { states: [l], renderFn: (p) => p }))
1047
- );
1048
- else {
1049
- const p = new TypeError(
1050
- `Expected '${t.name}' function to return a DOM node, Markup element, Readable or null. Got: ${R(l)}`
1051
- );
1052
- v.crash(p);
1053
- }
1054
- }
1055
- return {
1056
- get node() {
1057
- return m == null ? void 0 : m.node;
1058
- },
1059
- get isMounted() {
1060
- return i;
1061
- },
1062
- mount(l, p) {
1063
- const g = i;
1064
- if (!g)
1065
- for (E(); a.length > 0; )
1066
- a.shift()();
1067
- m && m.mount(l, p), g || (i = !0, requestAnimationFrame(() => {
1068
- for (; h.length > 0; )
1069
- h.shift()();
1070
- }));
1071
- },
1072
- unmount() {
1073
- for (; d.length > 0; )
1074
- d.shift()();
1075
- for (m && m.unmount(), i = !1; f.length > 0; )
1076
- f.shift()();
1077
- c.stopAll();
1078
- },
1079
- setChildView(l) {
1080
- const p = H(e, l, {});
1081
- return o([p]), p;
1082
- }
1083
- };
1084
- }
1085
- class Bt {
1086
- constructor({ elementContext: t, $items: n, renderFn: s, keyFn: r }) {
1087
- u(this, "node");
1088
- u(this, "endNode");
1089
- u(this, "$items");
1090
- u(this, "stopCallback");
1091
- u(this, "connectedItems", []);
1092
- u(this, "elementContext");
1093
- u(this, "renderFn");
1094
- u(this, "keyFn");
1095
- this.elementContext = t, this.$items = n, this.renderFn = s, this.keyFn = r, this.elementContext.root.getEnv() === "development" ? (this.node = document.createComment("Repeat"), this.endNode = document.createComment("/Repeat")) : (this.node = document.createTextNode(""), this.endNode = document.createTextNode(""));
1096
- }
1097
- get isMounted() {
1098
- return this.node.parentNode != null;
1099
- }
1100
- mount(t, n) {
1101
- this.isMounted || (t.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null), this.stopCallback = this.$items.watch((s) => {
1102
- this._update(Array.from(s));
1103
- }));
1104
- }
1105
- unmount() {
1106
- var t, n;
1107
- this.stopCallback && (this.stopCallback(), this.stopCallback = void 0), this.isMounted && ((t = this.node.parentNode) == null || t.removeChild(this.node), (n = this.endNode.parentNode) == null || n.removeChild(this.endNode)), this._cleanup();
1108
- }
1109
- _cleanup() {
1110
- for (const t of this.connectedItems)
1111
- t.element.unmount();
1112
- this.connectedItems = [];
1113
- }
1114
- _update(t) {
1115
- var o, i, c;
1116
- if (t.length === 0 || !this.isMounted)
1117
- return this._cleanup();
1118
- const n = [];
1119
- let s = 0;
1120
- for (const a of t)
1121
- n.push({
1122
- key: this.keyFn(a, s),
1123
- value: a,
1124
- index: s++
1125
- });
1126
- const r = [];
1127
- for (const a of this.connectedItems)
1128
- n.find((d) => d.key === a.key) || a.element.unmount();
1129
- for (const a of n) {
1130
- const h = this.connectedItems.find((d) => d.key === a.key);
1131
- if (h)
1132
- h.setValue(a.value), h.setIndex(a.index), r[a.index] = h;
1133
- else {
1134
- const [d, f] = W(a.value), [y, w] = W(a.index);
1135
- r[a.index] = {
1136
- key: a.key,
1137
- $value: d,
1138
- setValue: f,
1139
- $index: y,
1140
- setIndex: w,
1141
- element: H(this.elementContext, Dt, {
1142
- $value: d,
1143
- $index: y,
1144
- renderFn: this.renderFn
1145
- })
1146
- };
1147
- }
1148
- }
1149
- for (let a = 0; a < r.length; a++) {
1150
- const h = r[a], d = ((o = r[a - 1]) == null ? void 0 : o.element.node) ?? this.node;
1151
- h.element.mount(this.node.parentNode, d);
1152
- }
1153
- if (this.connectedItems = r, this.elementContext.root.getEnv() === "development") {
1154
- this.node.textContent = `Repeat (${r.length} item${r.length === 1 ? "" : "s"})`;
1155
- const a = ((i = r.at(-1)) == null ? void 0 : i.element.node) ?? this.node;
1156
- (c = this.node.parentNode) == null || c.insertBefore(this.endNode, a.nextSibling);
1157
- }
1158
- }
1159
- }
1160
- function Dt({ $value: e, $index: t, renderFn: n }, s) {
1161
- return n(e, t, s);
1162
- }
1163
- class Kt {
1164
- constructor({ value: t }) {
1165
- u(this, "node", document.createTextNode(""));
1166
- u(this, "value", "");
1167
- u(this, "stopCallback");
1168
- this.value = t;
1169
- }
1170
- get isMounted() {
1171
- return this.node.parentNode != null;
1172
- }
1173
- async mount(t, n = null) {
1174
- this.isMounted || (C(this.value) ? this.stopCallback = this.value.watch((s) => {
1175
- this.update(s);
1176
- }) : this.update(this.value)), t.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null);
1177
- }
1178
- async unmount() {
1179
- this.isMounted && (this.stopCallback && (this.stopCallback(), this.stopCallback = void 0), this.node.parentNode.removeChild(this.node));
1180
- }
1181
- update(t) {
1182
- t != null ? this.node.textContent = t.toString() : this.node.textContent = "";
1183
- }
1184
- }
1185
- function V(e) {
1186
- return L(e) && (typeof e.type == "string" || typeof e.type == "function") && Array.isArray(e.children);
1187
- }
1188
- function ft(e) {
1189
- return L(e) && $(e.connect) && $(e.disconnect);
1190
- }
1191
- function O(e) {
1192
- return M(e) || (e = [e]), e.flat(1 / 0).filter((t) => t != null && t !== !1).map((t) => {
1193
- if (t instanceof Node)
1194
- return k("$node", { value: t });
1195
- if (t instanceof pt)
1196
- return k("$node", { value: t.node });
1197
- if (V(t))
1198
- return t;
1199
- if (A(t) || St(t))
1200
- return k("$text", { value: t });
1201
- if (C(t))
1202
- return k("$observer", {
1203
- states: [t],
1204
- renderFn: (n) => n
1205
- });
1206
- throw console.error(t), new TypeError(`Unexpected child type. Got: ${t}`);
1207
- });
1208
- }
1209
- function k(e, t, ...n) {
1210
- return t != null && Ht(t), {
1211
- type: e,
1212
- props: t,
1213
- children: O(n)
1214
- };
1215
- }
1216
- function Ht(e) {
1217
- if (e.ref && !at(e.ref))
1218
- throw console.warn(e.ref), new TypeError(`Prop 'ref' must be a Ref object. Got: ${e.ref}`);
1219
- for (const t in e)
1220
- if (t.startsWith("$$") && e[t] !== void 0) {
1221
- if (!D(e[t]))
1222
- throw new TypeError(`Prop '${t}' is named as a SettableState but value is not. Got: ${e[t]}`);
1223
- } else if (t.startsWith("$") && e[t] !== void 0 && !C(e[t]))
1224
- throw new TypeError(`Prop '${t}' is named as a State but value is not. Got: ${e[t]}`);
1225
- }
1226
- const oe = Pt.bind(k);
1227
- function ie(e, t, n) {
1228
- const s = j(e);
1229
- return k("$cond", {
1230
- $predicate: s,
1231
- thenContent: t,
1232
- elseContent: n
1233
- });
1234
- }
1235
- function ue(e, t, n) {
1236
- const s = j(e);
1237
- return k("$repeat", { $items: s, keyFn: t, renderFn: n });
1238
- }
1239
- function ce(e, t) {
1240
- return k("$portal", { parent: e, content: t });
1241
- }
1242
- class pt {
1243
- constructor(t) {
1244
- u(this, "node");
1245
- this.node = t;
1246
- }
1247
- get isMounted() {
1248
- return this.node.parentNode != null;
1249
- }
1250
- async mount(t, n) {
1251
- t.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null);
1252
- }
1253
- async unmount() {
1254
- this.node.parentNode && this.node.parentNode.removeChild(this.node);
1255
- }
1256
- }
1257
- function x(e, t) {
1258
- return (M(t) ? t : [t]).map((s) => {
1259
- if ($(s.type))
1260
- return H(e, s.type, s.props, s.children);
1261
- if (A(s.type))
1262
- switch (s.type) {
1263
- case "$node": {
1264
- const r = s.props;
1265
- return new pt(r.value);
1266
- }
1267
- case "$text": {
1268
- const r = s.props;
1269
- return new Kt({
1270
- value: r.value
1271
- });
1272
- }
1273
- case "$cond": {
1274
- const r = s.props;
1275
- return new qt({
1276
- $predicate: r.$predicate,
1277
- thenContent: r.thenContent,
1278
- elseContent: r.elseContent,
1279
- elementContext: e
1280
- });
1281
- }
1282
- case "$repeat": {
1283
- const r = s.props;
1284
- return new Bt({
1285
- $items: r.$items,
1286
- keyFn: r.keyFn,
1287
- renderFn: r.renderFn,
1288
- elementContext: e
1289
- });
1290
- }
1291
- case "$observer": {
1292
- const r = s.props;
1293
- return new It({
1294
- states: r.states,
1295
- renderFn: r.renderFn,
1296
- elementContext: e
1297
- });
1298
- }
1299
- case "$outlet": {
1300
- const r = s.props;
1301
- return new Rt({
1302
- $children: r.$children,
1303
- elementContext: e
1304
- });
1305
- }
1306
- case "$portal": {
1307
- const r = s.props;
1308
- return new Gt({
1309
- content: r.content,
1310
- parent: r.parent,
1311
- elementContext: e
1312
- });
1313
- }
1314
- default:
1315
- if (s.type.startsWith("$"))
1316
- throw new Error(`Unknown markup type: ${s.type}`);
1317
- return new Lt({
1318
- tag: s.type,
1319
- props: s.props ?? {},
1320
- children: s.children,
1321
- elementContext: e
1322
- });
1323
- }
1324
- else
1325
- throw new TypeError(`Expected a string or view function. Got: ${s.type}`);
1326
- });
1327
- }
1328
- function _(e) {
1329
- if (e.length === 1)
1330
- return e[0];
1331
- const t = document.createComment("Fragment");
1332
- let n = !1;
1333
- return {
1334
- get node() {
1335
- return t;
1336
- },
1337
- get isMounted() {
1338
- return n;
1339
- },
1340
- mount(s, r) {
1341
- var o;
1342
- s.insertBefore(t, r || null);
1343
- for (const i of e) {
1344
- const c = ((o = e[e.length - 1]) == null ? void 0 : o.node) ?? t;
1345
- i.mount(s, c);
1346
- }
1347
- n = !0;
1348
- },
1349
- unmount() {
1350
- if (n) {
1351
- for (const s of e)
1352
- s.unmount();
1353
- t.remove();
1354
- }
1355
- n = !1;
1356
- }
1357
- };
1358
- }
1359
- function mt(e) {
1360
- return e == null || e === !1 || typeof e == "string" || typeof e == "number" || V(e) || C(e) || it(mt, e);
1361
- }
1362
- function ae(e, t) {
1363
- return t.outlet();
1364
- }
1365
- export {
1366
- x as A,
1367
- se as B,
1368
- ce as C,
1369
- ue as D,
1370
- ae as P,
1371
- W as a,
1372
- Qt as b,
1373
- ie as c,
1374
- Tt as d,
1375
- $ as e,
1376
- A as f,
1377
- Zt as g,
1378
- oe as h,
1379
- L as i,
1380
- Yt as j,
1381
- K as k,
1382
- te as l,
1383
- ee as m,
1384
- ne as n,
1385
- j as o,
1386
- re as p,
1387
- at as q,
1388
- Jt as r,
1389
- k as s,
1390
- R as t,
1391
- Xt as u,
1392
- At as v,
1393
- Nt as w,
1394
- _t as x,
1395
- H as y,
1396
- _ as z
1397
- };
1398
- //# sourceMappingURL=passthrough-DUh0_zQF.js.map