@manyducks.co/dolla 2.0.0-alpha.14 → 2.0.0-alpha.15

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