@manyducks.co/dolla 2.0.0-alpha.41 → 2.0.0-alpha.42

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,1447 +0,0 @@
1
- var ke = Object.defineProperty;
2
- var te = (t) => {
3
- throw TypeError(t);
4
- };
5
- var Te = (t, e, n) => e in t ? ke(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var f = (t, e, n) => Te(t, typeof e != "symbol" ? e + "" : e, n), ne = (t, e, n) => e.has(t) || te("Cannot " + n);
7
- var T = (t, e, n) => (ne(t, e, "read from private field"), n ? n.call(t) : e.get(t)), _ = (t, e, n) => e.has(t) ? te("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), U = (t, e, n, s) => (ne(t, e, "write to private field"), s ? s.call(t, n) : e.set(t, n), n);
8
- var S = /* @__PURE__ */ ((t) => (t[t.Computed = 1] = "Computed", t[t.Effect = 2] = "Effect", t[t.Tracking = 4] = "Tracking", t[t.Notified = 8] = "Notified", t[t.Recursed = 16] = "Recursed", t[t.Dirty = 32] = "Dirty", t[t.PendingComputed = 64] = "PendingComputed", t[t.PendingEffect = 128] = "PendingEffect", t[t.Propagated = 224] = "Propagated", t))(S || {});
9
- function he({
10
- updateComputed: t,
11
- notifyEffect: e
12
- }) {
13
- let n, s;
14
- return {
15
- /**
16
- * Links a given dependency and subscriber if they are not already linked.
17
- *
18
- * @param dep - The dependency to be linked.
19
- * @param sub - The subscriber that depends on this dependency.
20
- * @returns The newly created link object if the two are not already linked; otherwise `undefined`.
21
- */
22
- link(r, u) {
23
- const c = u.depsTail;
24
- if (c !== void 0 && c.dep === r)
25
- return;
26
- const d = c !== void 0 ? c.nextDep : u.deps;
27
- if (d !== void 0 && d.dep === r) {
28
- u.depsTail = d;
29
- return;
30
- }
31
- const h = r.subsTail;
32
- if (!(h !== void 0 && h.sub === u && a(h, u)))
33
- return i(r, u, d, c);
34
- },
35
- /**
36
- * Traverses and marks subscribers starting from the provided link.
37
- *
38
- * It sets flags (e.g., Dirty, PendingComputed, PendingEffect) on each subscriber
39
- * to indicate which ones require re-computation or effect processing.
40
- * This function should be called after a signal's value changes.
41
- *
42
- * @param link - The starting link from which propagation begins.
43
- */
44
- propagate(r) {
45
- let u = 32, c = r, d = 0;
46
- e: do {
47
- const h = r.sub, p = h.flags;
48
- if (!(p & 244) && (h.flags = p | u | 8, !0) || p & 16 && !(p & 4) && (h.flags = p & -17 | u | 8, !0) || !(p & 224) && a(r, h) && (h.flags = p | 16 | u | 8, h.subs !== void 0)) {
49
- const x = h.subs;
50
- if (x !== void 0) {
51
- x.nextSub !== void 0 ? (x.prevSub = c, r = c = x, u = 64, ++d) : (r = x, u = p & 2 ? 128 : 64);
52
- continue;
53
- }
54
- p & 2 && (s !== void 0 ? s.depsTail.nextDep = h.deps : n = h, s = h);
55
- } else p & (4 | u) ? !(p & u) && p & 224 && a(r, h) && (h.flags = p | u) : (h.flags = p | u | 8, (p & 10) === 2 && (s !== void 0 ? s.depsTail.nextDep = h.deps : n = h, s = h));
56
- if ((r = c.nextSub) !== void 0) {
57
- c = r, u = d ? 64 : 32;
58
- continue;
59
- }
60
- for (; d; ) {
61
- --d;
62
- const ee = c.dep.subs;
63
- if (c = ee.prevSub, ee.prevSub = void 0, (r = c.nextSub) !== void 0) {
64
- c = r, u = d ? 64 : 32;
65
- continue e;
66
- }
67
- }
68
- break;
69
- } while (!0);
70
- },
71
- /**
72
- * Prepares the given subscriber to track new dependencies.
73
- *
74
- * It resets the subscriber's internal pointers (e.g., depsTail) and
75
- * sets its flags to indicate it is now tracking dependency links.
76
- *
77
- * @param sub - The subscriber to start tracking.
78
- */
79
- startTracking(r) {
80
- r.depsTail = void 0, r.flags = r.flags & -249 | 4;
81
- },
82
- /**
83
- * Concludes tracking of dependencies for the specified subscriber.
84
- *
85
- * It clears or unlinks any tracked dependency information, then
86
- * updates the subscriber's flags to indicate tracking is complete.
87
- *
88
- * @param sub - The subscriber whose tracking is ending.
89
- */
90
- endTracking(r) {
91
- const u = r.depsTail;
92
- if (u !== void 0) {
93
- const c = u.nextDep;
94
- c !== void 0 && (m(c), u.nextDep = void 0);
95
- } else r.deps !== void 0 && (m(r.deps), r.deps = void 0);
96
- r.flags &= -5;
97
- },
98
- /**
99
- * Updates the dirty flag for the given subscriber based on its dependencies.
100
- *
101
- * If the subscriber has any pending computeds, this function sets the Dirty flag
102
- * and returns `true`. Otherwise, it clears the PendingComputed flag and returns `false`.
103
- *
104
- * @param sub - The subscriber to update.
105
- * @param flags - The current flag set for this subscriber.
106
- * @returns `true` if the subscriber is marked as Dirty; otherwise `false`.
107
- */
108
- updateDirtyFlag(r, u) {
109
- return o(r.deps) ? (r.flags = u | 32, !0) : (r.flags = u & -65, !1);
110
- },
111
- /**
112
- * Updates the computed subscriber if necessary before its value is accessed.
113
- *
114
- * If the subscriber is marked Dirty or PendingComputed, this function runs
115
- * the provided updateComputed logic and triggers a shallowPropagate for any
116
- * downstream subscribers if an actual update occurs.
117
- *
118
- * @param computed - The computed subscriber to update.
119
- * @param flags - The current flag set for this subscriber.
120
- */
121
- processComputedUpdate(r, u) {
122
- if ((u & 32 || (o(r.deps) || (r.flags = u & -65, !1))) && t(r)) {
123
- const c = r.subs;
124
- c !== void 0 && l(c);
125
- }
126
- },
127
- /**
128
- * Ensures all pending internal effects for the given subscriber are processed.
129
- *
130
- * This should be called after an effect decides not to re-run itself but may still
131
- * have dependencies flagged with PendingEffect. If the subscriber is flagged with
132
- * PendingEffect, this function clears that flag and invokes `notifyEffect` on any
133
- * related dependencies marked as Effect and Propagated, processing pending effects.
134
- *
135
- * @param sub - The subscriber which may have pending effects.
136
- * @param flags - The current flags on the subscriber to check.
137
- */
138
- processPendingInnerEffects(r, u) {
139
- if (u & 128) {
140
- r.flags = u & -129;
141
- let c = r.deps;
142
- do {
143
- const d = c.dep;
144
- "flags" in d && d.flags & 2 && d.flags & 224 && e(d), c = c.nextDep;
145
- } while (c !== void 0);
146
- }
147
- },
148
- /**
149
- * Processes queued effect notifications after a batch operation finishes.
150
- *
151
- * Iterates through all queued effects, calling notifyEffect on each.
152
- * If an effect remains partially handled, its flags are updated, and future
153
- * notifications may be triggered until fully handled.
154
- */
155
- processEffectNotifications() {
156
- for (; n !== void 0; ) {
157
- const r = n, u = r.depsTail, c = u.nextDep;
158
- c !== void 0 ? (u.nextDep = void 0, n = c.sub) : (n = void 0, s = void 0), e(r) || (r.flags &= -9);
159
- }
160
- }
161
- };
162
- function i(r, u, c, d) {
163
- const h = {
164
- dep: r,
165
- sub: u,
166
- nextDep: c,
167
- prevSub: void 0,
168
- nextSub: void 0
169
- };
170
- if (d === void 0 ? u.deps = h : d.nextDep = h, r.subs === void 0)
171
- r.subs = h;
172
- else {
173
- const p = r.subsTail;
174
- h.prevSub = p, p.nextSub = h;
175
- }
176
- return u.depsTail = h, r.subsTail = h, h;
177
- }
178
- function o(r) {
179
- let u = 0, c;
180
- e: do {
181
- c = !1;
182
- const d = r.dep;
183
- if ("flags" in d) {
184
- const h = d.flags;
185
- if ((h & 33) === 33) {
186
- if (t(d)) {
187
- const p = d.subs;
188
- p.nextSub !== void 0 && l(p), c = !0;
189
- }
190
- } else if ((h & 65) === 65) {
191
- const p = d.subs;
192
- p.nextSub !== void 0 && (p.prevSub = r), r = d.deps, ++u;
193
- continue;
194
- }
195
- }
196
- if (!c && r.nextDep !== void 0) {
197
- r = r.nextDep;
198
- continue;
199
- }
200
- if (u) {
201
- let h = r.sub;
202
- do {
203
- --u;
204
- const p = h.subs;
205
- if (c) {
206
- if (t(h)) {
207
- (r = p.prevSub) !== void 0 ? (p.prevSub = void 0, l(h.subs), h = r.sub) : h = p.sub;
208
- continue;
209
- }
210
- } else
211
- h.flags &= -65;
212
- if ((r = p.prevSub) !== void 0) {
213
- if (p.prevSub = void 0, r.nextDep !== void 0) {
214
- r = r.nextDep;
215
- continue e;
216
- }
217
- h = r.sub;
218
- } else {
219
- if ((r = p.nextDep) !== void 0)
220
- continue e;
221
- h = p.sub;
222
- }
223
- c = !1;
224
- } while (u);
225
- }
226
- return c;
227
- } while (!0);
228
- }
229
- function l(r) {
230
- do {
231
- const u = r.sub, c = u.flags;
232
- (c & 96) === 64 && (u.flags = c | 32 | 8, (c & 10) === 2 && (s !== void 0 ? s.depsTail.nextDep = u.deps : n = u, s = u)), r = r.nextSub;
233
- } while (r !== void 0);
234
- }
235
- function a(r, u) {
236
- const c = u.depsTail;
237
- if (c !== void 0) {
238
- let d = u.deps;
239
- do {
240
- if (d === r)
241
- return !0;
242
- if (d === c)
243
- break;
244
- d = d.nextDep;
245
- } while (d !== void 0);
246
- }
247
- return !1;
248
- }
249
- function m(r) {
250
- do {
251
- const u = r.dep, c = r.nextDep, d = r.nextSub, h = r.prevSub;
252
- if (d !== void 0 ? d.prevSub = h : u.subsTail = h, h !== void 0 ? h.nextSub = d : u.subs = d, u.subs === void 0 && "deps" in u) {
253
- const p = u.flags;
254
- p & 32 || (u.flags = p | 32);
255
- const x = u.deps;
256
- if (x !== void 0) {
257
- r = x, u.depsTail.nextDep = c, u.deps = void 0, u.depsTail = void 0;
258
- continue;
259
- }
260
- }
261
- r = c;
262
- } while (r !== void 0);
263
- }
264
- }
265
- var {
266
- link: nt,
267
- propagate: st,
268
- updateDirtyFlag: Ce,
269
- startTracking: de,
270
- endTracking: pe,
271
- processEffectNotifications: it,
272
- processComputedUpdate: rt,
273
- processPendingInnerEffects: me
274
- } = he({
275
- updateComputed(t) {
276
- de(t);
277
- try {
278
- const e = t.currentValue, n = t.getter(e);
279
- return e !== n ? (t.currentValue = n, !0) : !1;
280
- } finally {
281
- pe(t);
282
- }
283
- },
284
- notifyEffect(t) {
285
- return "isScope" in t ? Ae(t) : De(t);
286
- }
287
- });
288
- function Le(t) {
289
- de(t);
290
- try {
291
- t.fn();
292
- } finally {
293
- pe(t);
294
- }
295
- }
296
- function De(t) {
297
- const e = t.flags;
298
- return e & 32 || e & 64 && Ce(t, e) ? Le(t) : me(t, t.flags), !0;
299
- }
300
- function Ae(t) {
301
- return t.flags & 128 ? (me(t, t.flags), !0) : !1;
302
- }
303
- function L(t) {
304
- const e = typeof t;
305
- switch (e) {
306
- case "undefined":
307
- return e;
308
- case "number":
309
- return isNaN(t) ? "NaN" : e;
310
- case "function":
311
- return /^\s*class\s+/.test(t.toString()) ? "class" : e;
312
- case "object":
313
- return t === null ? "null" : t instanceof Promise ? "promise" : t instanceof Map ? "map" : t instanceof Set ? "set" : Array.isArray(t) ? "array" : e;
314
- default:
315
- return e;
316
- }
317
- }
318
- function P(t) {
319
- return Array.isArray(t);
320
- }
321
- function F(t, e) {
322
- return P(e) && e.every((n) => t(n));
323
- }
324
- function ot(t, e, n) {
325
- if (F(t, e))
326
- return !0;
327
- throw new TypeError(V(e, n));
328
- }
329
- function D(t) {
330
- return typeof t == "string";
331
- }
332
- function ut(t, e) {
333
- if (D(t))
334
- return !0;
335
- throw new TypeError(V(t, e ?? "Expected a string. Got type: %t, value: %v"));
336
- }
337
- function E(t) {
338
- return L(t) === "function";
339
- }
340
- function Pe(t) {
341
- return typeof t == "number" && !isNaN(t);
342
- }
343
- function ct(...t) {
344
- const e = t[0], n = D(t[2]) ? t[2] : `Expected instance of ${e.name}. Got type: %t, value: %v`, s = (i) => {
345
- if (i instanceof e)
346
- return !0;
347
- throw new TypeError(V(i, n));
348
- };
349
- return t.length < 2 ? s : s(t[1]);
350
- }
351
- function W(t) {
352
- return t != null && typeof t == "object" && !P(t);
353
- }
354
- function lt(t, e) {
355
- if (W(t))
356
- return !0;
357
- throw new TypeError(V(t, e));
358
- }
359
- function V(t, e) {
360
- var i;
361
- const n = L(t), s = ((i = t == null ? void 0 : t.toString) == null ? void 0 : i.call(t)) || String(t);
362
- return e.replaceAll("%t", n).replaceAll("%v", s);
363
- }
364
- const q = Symbol("dependency"), {
365
- link: ge,
366
- propagate: Oe,
367
- updateDirtyFlag: $e,
368
- startTracking: Z,
369
- endTracking: H,
370
- processEffectNotifications: Ie,
371
- processComputedUpdate: je,
372
- processPendingInnerEffects: Ve
373
- } = he({
374
- updateComputed(t) {
375
- const e = y;
376
- y = t, Z(t);
377
- try {
378
- const n = t.currentValue, s = t.getter(n);
379
- return t.equals(n, s) ? !1 : (t.currentValue = s, !0);
380
- } finally {
381
- y = e, H(t);
382
- }
383
- },
384
- notifyEffect(t) {
385
- const e = t.flags;
386
- return e & S.Dirty || e & S.PendingComputed && $e(t, e) ? ye(t) : Ve(t, t.flags), !0;
387
- }
388
- });
389
- let y;
390
- const C = [];
391
- let z = !1;
392
- function qe() {
393
- z || (z = !0, queueMicrotask(() => {
394
- z = !1;
395
- for (let t = 0; t < C.length; t++) {
396
- const e = C[t], n = y;
397
- y = e, Z(e);
398
- try {
399
- e.fn();
400
- } finally {
401
- y = n, H(e);
402
- }
403
- }
404
- C.length = 0;
405
- }));
406
- }
407
- function ye(t) {
408
- C.push(t), qe();
409
- }
410
- function _e() {
411
- Z(this), H(this), queueMicrotask(() => {
412
- C.splice(C.indexOf(this), 1);
413
- });
414
- }
415
- const ve = [];
416
- function K() {
417
- ve.push(y), y = void 0;
418
- }
419
- function X() {
420
- y = ve.pop();
421
- }
422
- var M, A;
423
- class Ue {
424
- constructor(e, n) {
425
- _(this, M);
426
- _(this, A);
427
- f(this, "name");
428
- U(this, M, e), U(this, A, (n == null ? void 0 : n.equals) ?? Object.is), n != null && n.name && (this.name = n.name), Object.defineProperty(this, q, {
429
- value: e,
430
- configurable: !1,
431
- enumerable: !1,
432
- writable: !1
433
- });
434
- }
435
- get value() {
436
- return T(this, M).currentValue;
437
- }
438
- set value(e) {
439
- if (!T(this, A).call(this, T(this, M).currentValue, e)) {
440
- T(this, M).currentValue = e;
441
- const n = T(this, M).subs;
442
- n !== void 0 && (Oe(n), Ie());
443
- }
444
- }
445
- }
446
- M = new WeakMap(), A = new WeakMap();
447
- class ze {
448
- constructor(e) {
449
- f(this, "computed");
450
- this.computed = e, Object.defineProperty(this, q, {
451
- value: e,
452
- configurable: !1,
453
- enumerable: !1,
454
- writable: !1
455
- });
456
- }
457
- get value() {
458
- const e = this.computed, n = e.flags;
459
- return n & (S.Dirty | S.PendingComputed) && je(e, n), e.currentValue;
460
- }
461
- }
462
- function g(t) {
463
- return t != null && t[q] != null;
464
- }
465
- function G(t, e) {
466
- return new Ue({ currentValue: t, subs: void 0, subsTail: void 0 }, e);
467
- }
468
- function Y(t, e) {
469
- return new ze({
470
- currentValue: void 0,
471
- equals: (e == null ? void 0 : e.equals) ?? Object.is,
472
- subs: void 0,
473
- subsTail: void 0,
474
- deps: void 0,
475
- depsTail: void 0,
476
- flags: S.Computed | S.Dirty,
477
- getter: (n) => {
478
- let s = t(n);
479
- return s = w(s), s;
480
- }
481
- });
482
- }
483
- function Re(t, e) {
484
- if (E(e))
485
- t.value = e(t.value);
486
- else if (arguments.length > 1)
487
- t.value = e;
488
- else
489
- return (n) => Re(t, n);
490
- }
491
- function w(t) {
492
- if (g(t)) {
493
- if (y !== void 0) {
494
- const e = t[q];
495
- ge(e, y);
496
- }
497
- return t.value;
498
- } else
499
- return t;
500
- }
501
- function ft(t) {
502
- return g(t) ? t.value : t;
503
- }
504
- function v(t) {
505
- const e = {
506
- fn: t,
507
- subs: void 0,
508
- subsTail: void 0,
509
- deps: void 0,
510
- depsTail: void 0,
511
- flags: S.Effect
512
- };
513
- return y !== void 0 && ge(e, y), ye(e), _e.bind(e);
514
- }
515
- const at = () => {
516
- };
517
- let R = 1;
518
- function we() {
519
- return R = R % Number.MAX_SAFE_INTEGER + 1, R.toString(36) + Date.now().toString(36);
520
- }
521
- function ht(t, e) {
522
- return Object.is(t, e);
523
- }
524
- function dt(t, e) {
525
- if (Object.is(t, e)) return !0;
526
- const n = L(t);
527
- if (n !== L(e))
528
- return !1;
529
- switch (n) {
530
- case "object":
531
- let s = 0;
532
- for (const i in t) {
533
- if (t[i] !== e[i]) return !1;
534
- s++;
535
- }
536
- return Object.keys(e).length === s;
537
- case "array":
538
- if (t.length !== e.length) return !1;
539
- for (let i = 0; i < t.length; i++)
540
- if (t[i] !== e[i]) return !1;
541
- return !0;
542
- case "map":
543
- if (t.size !== e.size) return !1;
544
- for (const i of t.keys())
545
- if (t[i] !== e[i]) return !1;
546
- return !0;
547
- case "set":
548
- if (E(t.symmetricDifference))
549
- return t.symmetricDifference(e).size === 0;
550
- for (const i of t.keys())
551
- if (t[i] !== e.get(i)) return !1;
552
- return !0;
553
- }
554
- return !1;
555
- }
556
- function B(t, e) {
557
- if (t === e) return !0;
558
- if (t && e && typeof t == "object" && typeof e == "object") {
559
- if (t.constructor !== e.constructor) return !1;
560
- var n, s, i;
561
- if (Array.isArray(t)) {
562
- if (n = t.length, n != e.length) return !1;
563
- for (s = n; s-- !== 0; ) if (!B(t[s], e[s])) return !1;
564
- return !0;
565
- }
566
- if (t instanceof Map && e instanceof Map) {
567
- if (t.size !== e.size) return !1;
568
- for (s of t.entries()) if (!e.has(s[0])) return !1;
569
- for (s of t.entries()) if (!B(s[1], e.get(s[0]))) return !1;
570
- return !0;
571
- }
572
- if (t instanceof Set && e instanceof Set) {
573
- if (t.size !== e.size) return !1;
574
- for (s of t.entries()) if (!e.has(s[0])) return !1;
575
- return !0;
576
- }
577
- if (ArrayBuffer.isView(t) && ArrayBuffer.isView(e)) {
578
- if (n = t.length, n != e.length) return !1;
579
- for (s = n; s-- !== 0; ) if (t[s] !== e[s]) return !1;
580
- return !0;
581
- }
582
- if (t.constructor === RegExp) return t.source === e.source && t.flags === e.flags;
583
- if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === e.valueOf();
584
- if (t.toString !== Object.prototype.toString) return t.toString() === e.toString();
585
- if (i = Object.keys(t), n = i.length, n !== Object.keys(e).length) return !1;
586
- for (s = n; s-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(e, i[s])) return !1;
587
- for (s = n; s-- !== 0; ) {
588
- var o = i[s];
589
- if (!B(t[o], e[o])) return !1;
590
- }
591
- return !0;
592
- }
593
- return t !== t && e !== e;
594
- }
595
- function Be(t, e) {
596
- const n = {};
597
- for (const s in e)
598
- t.includes(s) || (n[s] = e[s]);
599
- return n;
600
- }
601
- function pt(t) {
602
- let e = 0;
603
- for (let n = 0; n < t.length; n++)
604
- e = (e + t.charCodeAt(n) * 10) % 360;
605
- return `oklch(0.68 0.15 ${e}deg)`;
606
- }
607
- function mt(t) {
608
- if (t instanceof RegExp)
609
- return (s) => t.test(s);
610
- const e = {
611
- positive: [],
612
- negative: []
613
- }, n = t.split(",").map((s) => s.trim()).filter((s) => s !== "");
614
- for (let s of n) {
615
- let i = "positive";
616
- s.startsWith("-") && (i = "negative", s = s.slice(1)), s === "*" ? e[i].push(function() {
617
- return !0;
618
- }) : s.endsWith("*") ? e[i].push(function(o) {
619
- return o.startsWith(s.slice(0, s.length - 1));
620
- }) : e[i].push(function(o) {
621
- return o === s;
622
- });
623
- }
624
- return function(s) {
625
- const { positive: i, negative: o } = e;
626
- return !(o.some((l) => l(s)) || i.length > 0 && !i.some((l) => l(s)));
627
- };
628
- }
629
- const N = Symbol.for("DollaMarkupElement"), gt = Symbol.for("DollaRouter");
630
- function yt(t, e) {
631
- return e.outlet();
632
- }
633
- function Ge(t) {
634
- for (var e, n, s = arguments, i = 1, o = "", l = "", a = [0], m = function(c) {
635
- i === 1 && (c || (o = o.replace(/^\s*\n\s*|\s*\n\s*$/g, ""))) ? a.push(c ? s[c] : o) : i === 3 && (c || o) ? (a[1] = c ? s[c] : o, i = 2) : i === 2 && o === "..." && c ? a[2] = Object.assign(a[2] || {}, s[c]) : i === 2 && o && !c ? (a[2] = a[2] || {})[o] = !0 : i >= 5 && (i === 5 ? ((a[2] = a[2] || {})[n] = c ? o ? o + s[c] : s[c] : o, i = 6) : (c || o) && (a[2][n] += c ? o + s[c] : o)), o = "";
636
- }, r = 0; r < t.length; r++) {
637
- r && (i === 1 && m(), m(r));
638
- for (var u = 0; u < t[r].length; u++) e = t[r][u], i === 1 ? e === "<" ? (m(), a = [a, "", null], i = 3) : o += e : i === 4 ? o === "--" && e === ">" ? (i = 1, o = "") : o = e + o[0] : l ? e === l ? l = "" : o += e : e === '"' || e === "'" ? l = e : e === ">" ? (m(), i = 1) : i && (e === "=" ? (i = 5, n = o, o = "") : e === "/" && (i < 5 || t[r][u + 1] === ">") ? (m(), i === 3 && (a = a[0]), i = a, (a = a[0]).push(this.apply(null, i.slice(1))), i = 0) : e === " " || e === " " || e === `
639
- ` || e === "\r" ? (m(), i = 2) : o += e), i === 3 && o === "!--" && (i = 4, a = a[0]);
640
- }
641
- return m(), a.length > 2 ? a.slice(1) : a[1];
642
- }
643
- var re;
644
- re = N;
645
- class se {
646
- constructor(e) {
647
- f(this, re, !0);
648
- f(this, "node");
649
- this.node = e;
650
- }
651
- get isMounted() {
652
- return this.node.parentNode != null;
653
- }
654
- mount(e, n) {
655
- e.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null);
656
- }
657
- unmount(e = !1) {
658
- this.node.parentNode && !e && this.node.parentNode.removeChild(this.node);
659
- }
660
- }
661
- var oe;
662
- oe = N;
663
- class Fe {
664
- constructor(e) {
665
- f(this, oe, !0);
666
- f(this, "node", document.createTextNode(""));
667
- f(this, "children", []);
668
- f(this, "elementContext");
669
- f(this, "source");
670
- f(this, "unsubscribe");
671
- this.source = e.source, this.elementContext = e.elementContext;
672
- }
673
- get isMounted() {
674
- return this.node.parentNode != null;
675
- }
676
- mount(e, n) {
677
- this.isMounted || (e.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null), this.unsubscribe = v(() => {
678
- const s = w(this.source);
679
- if (!Ne(s))
680
- throw console.error(s), new TypeError(
681
- `Dynamic received invalid value to render. Got type: ${L(s)}, value: ${s}`
682
- );
683
- K(), this.update(P(s) ? s : [s]), X();
684
- }));
685
- }
686
- unmount(e = !1) {
687
- var n, s;
688
- (n = this.unsubscribe) == null || n.call(this), this.isMounted && (this.cleanup(e), (s = this.node.parentNode) == null || s.removeChild(this.node));
689
- }
690
- cleanup(e) {
691
- for (const n of this.children)
692
- n.unmount(e);
693
- this.children = [];
694
- }
695
- update(e) {
696
- var o, l, a;
697
- if (this.cleanup(!1), e == null || e.length === 0 || !this.isMounted)
698
- return;
699
- const n = e.flatMap((m) => Ee(m) ? m : k(this.elementContext, J(m)));
700
- for (const m of n) {
701
- const r = ((o = this.children.at(-1)) == null ? void 0 : o.node) || this.node;
702
- m.mount(this.node.parentNode, r), this.children.push(m);
703
- }
704
- const s = this.node.parentNode, i = ((a = (l = this.children.at(-1)) == null ? void 0 : l.node) == null ? void 0 : a.nextSibling) ?? null;
705
- s.insertBefore(this.node, i);
706
- }
707
- }
708
- const We = (t) => /^on[A-Z]/.test(t);
709
- var ue;
710
- ue = N;
711
- class Ze {
712
- constructor({ tag: e, props: n, children: s, elementContext: i }) {
713
- f(this, ue, !0);
714
- f(this, "node");
715
- f(this, "props");
716
- f(this, "childMarkup", []);
717
- f(this, "children", []);
718
- f(this, "unsubscribers", []);
719
- f(this, "elementContext");
720
- // Track the ref so we can nullify it on unmount.
721
- f(this, "ref");
722
- // Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
723
- f(this, "canClickAway", !1);
724
- if (e.toLowerCase() === "svg" && (i = {
725
- ...i,
726
- isSVG: !0
727
- }), i.isSVG ? this.node = document.createElementNS("http://www.w3.org/2000/svg", e) : this.node = document.createElement(e), i.root.getEnv() === "development" && i.viewName && (this.node.dataset.view = i.viewName), n.ref)
728
- if (E(n.ref))
729
- this.ref = n.ref, this.ref(this.node);
730
- else
731
- throw new Error("Expected ref to be a function. Got: " + n.ref);
732
- this.props = {
733
- ...Be(["ref", "class", "className"], n),
734
- class: n.className ?? n.class
735
- }, s && (this.childMarkup = s), this.elementContext = i;
736
- }
737
- get isMounted() {
738
- return this.node.parentNode != null;
739
- }
740
- mount(e, n) {
741
- if (e == null)
742
- throw new Error(`HTML element requires a parent element as the first argument to connect. Got: ${e}`);
743
- if (!this.isMounted) {
744
- this.childMarkup.length > 0 && (this.children = k(this.elementContext, this.childMarkup));
745
- for (let s = 0; s < this.children.length; s++) {
746
- const i = this.children[s], o = s > 0 ? this.children[s - 1].node : void 0;
747
- i.mount(this.node, o);
748
- }
749
- this.applyProps(this.node, this.props), this.props.style && this.applyStyles(this.node, this.props.style, this.unsubscribers), this.props.class && this.applyClasses(this.node, this.props.class, this.unsubscribers);
750
- }
751
- e.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null), setTimeout(() => {
752
- this.canClickAway = !0;
753
- }, 0);
754
- }
755
- unmount(e = !1) {
756
- var n;
757
- if (this.isMounted) {
758
- e || (n = this.node.parentNode) == null || n.removeChild(this.node);
759
- for (const s of this.children)
760
- s.unmount(!0);
761
- this.ref && this.ref(void 0), this.canClickAway = !1;
762
- for (const s of this.unsubscribers)
763
- s();
764
- this.unsubscribers.length = 0;
765
- }
766
- }
767
- attachProp(e, n) {
768
- g(e) ? this.unsubscribers.push(v(() => n(w(e)))) : n(e);
769
- }
770
- applyProps(e, n) {
771
- for (const s in n) {
772
- const i = n[s];
773
- if (s === "attributes") {
774
- const o = i;
775
- for (const l in o)
776
- this.attachProp(o[l], (a) => {
777
- a == null ? e.removeAttribute(l) : e.setAttribute(l, String(a));
778
- });
779
- } else if (s === "onClickOutside" || s === "onclickoutside") {
780
- const o = (a) => {
781
- this.canClickAway && !e.contains(a.target) && (g(i) ? i.value(a) : i(a));
782
- }, l = { capture: !0 };
783
- window.addEventListener("click", o, l), this.unsubscribers.push(() => {
784
- window.removeEventListener("click", o, l);
785
- });
786
- } else if (We(s)) {
787
- const o = s.slice(2).toLowerCase(), l = g(i) ? (a) => i.value(a) : i;
788
- e.addEventListener(o, l), this.unsubscribers.push(() => {
789
- e.removeEventListener(o, l);
790
- });
791
- } else if (s.includes("-"))
792
- this.attachProp(i, (o) => {
793
- o == null ? e.removeAttribute(s) : e.setAttribute(s, String(o));
794
- });
795
- else if (!He.includes(s))
796
- if (this.elementContext.isSVG)
797
- this.attachProp(i, (o) => {
798
- o != null ? e.setAttribute(s, String(n[s])) : e.removeAttribute(s);
799
- });
800
- else
801
- switch (s) {
802
- case "contentEditable":
803
- case "value":
804
- this.attachProp(i, (o) => {
805
- e[s] = String(o);
806
- });
807
- break;
808
- case "for":
809
- this.attachProp(i, (o) => {
810
- e.htmlFor = o;
811
- });
812
- break;
813
- case "checked":
814
- this.attachProp(i, (o) => {
815
- e.checked = o, o ? e.setAttribute("checked", "") : e.removeAttribute("checked");
816
- });
817
- break;
818
- // Attribute-aliased props
819
- case "exportParts":
820
- case "part":
821
- case "translate":
822
- case "type":
823
- case "title": {
824
- const o = s.toLowerCase();
825
- this.attachProp(i, (l) => {
826
- l == null ? e.removeAttribute(o) : e.setAttribute(o, String(l));
827
- });
828
- break;
829
- }
830
- case "autocomplete":
831
- case "autocapitalize":
832
- this.attachProp(i, (o) => {
833
- typeof o == "string" ? e.autocomplete = o : o ? e.autocomplete = "on" : e.autocomplete = "off";
834
- });
835
- break;
836
- default: {
837
- this.attachProp(i, (o) => {
838
- e[s] = o;
839
- });
840
- break;
841
- }
842
- }
843
- }
844
- }
845
- applyStyles(e, n, s) {
846
- const i = [];
847
- if (g(n)) {
848
- let o;
849
- const l = v(() => {
850
- E(o) && o(), e.style.cssText = "", o = this.applyStyles(e, w(n), s);
851
- });
852
- s.push(l), i.push(l);
853
- } else {
854
- const o = xe(n);
855
- for (const l in o) {
856
- const { value: a, priority: m } = o[l];
857
- if (g(a)) {
858
- const r = v(() => {
859
- w(a) ? e.style.setProperty(l, String(a.value), m) : e.style.removeProperty(l);
860
- });
861
- s.push(r), i.push(r);
862
- } else a != null && e.style.setProperty(l, String(a));
863
- }
864
- }
865
- return function() {
866
- for (const l of i)
867
- l(), s.splice(s.indexOf(l), 1);
868
- };
869
- }
870
- applyClasses(e, n, s) {
871
- const i = [];
872
- if (g(n)) {
873
- let o;
874
- const l = v(() => {
875
- E(o) && o(), e.removeAttribute("class"), o = this.applyClasses(e, w(n), s);
876
- });
877
- s.push(l), i.push(l);
878
- } else {
879
- const o = be(n);
880
- for (const l in o) {
881
- const a = o[l];
882
- if (g(a)) {
883
- const m = v(() => {
884
- w(a) ? e.classList.add(l) : e.classList.remove(l);
885
- });
886
- s.push(m), i.push(m);
887
- } else a && e.classList.add(l);
888
- }
889
- }
890
- return function() {
891
- for (const l of i)
892
- l(), s.splice(s.indexOf(l), 1);
893
- };
894
- }
895
- }
896
- function be(t) {
897
- let e = {};
898
- if (D(t)) {
899
- const n = t.split(" ");
900
- for (const s of n)
901
- e[s] = !0;
902
- } else W(t) ? Object.assign(e, t) : Array.isArray(t) && Array.from(t).filter(Boolean).forEach((n) => {
903
- Object.assign(e, be(n));
904
- });
905
- return delete e.undefined, e;
906
- }
907
- function xe(t) {
908
- let e = {};
909
- if (D(t)) {
910
- const n = t.split(";").filter((s) => s.trim() !== "");
911
- for (const s of n) {
912
- const [i, o] = s.split(":"), l = {
913
- value: o
914
- };
915
- o.includes("!important") ? (l.priority = "important", l.value = o.replace("!important", "").trim()) : l.value = o.trim(), e[ie(i.trim())] = l;
916
- }
917
- }
918
- if (W(t))
919
- for (const n in t)
920
- n.startsWith("--") ? e[n] = { value: t[n] } : e[ie(n)] = { value: t[n] };
921
- else Array.isArray(t) && Array.from(t).filter((n) => n != null).forEach((n) => {
922
- Object.assign(e, xe(n));
923
- });
924
- return e;
925
- }
926
- function ie(t) {
927
- return t.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (e, n) => (n ? "-" : "") + e.toLowerCase());
928
- }
929
- const He = ["ref", "children", "class", "style", "data"];
930
- let Ke = class {
931
- constructor(e) {
932
- f(this, "store");
933
- this.store = e;
934
- const n = Object.getOwnPropertyDescriptors(this.store.logger);
935
- for (const s in n)
936
- s !== "setName" && Object.defineProperty(this, s, n[s]);
937
- }
938
- get isMounted() {
939
- return this.store.isMounted;
940
- }
941
- get name() {
942
- return this.store.name || this.store.id;
943
- }
944
- set name(e) {
945
- this.store.name = e, this.store.logger.setName(e);
946
- }
947
- get(e) {
948
- if (E(e)) {
949
- let n = this.store.elementContext, s;
950
- for (; s = n.stores.get(e), s == null && n.parent != null; )
951
- n = n.parent;
952
- if (s == null)
953
- throw new $(`Store '${e.name}' is not provided on this context.`);
954
- return s.value;
955
- } else
956
- throw new $("Invalid store.");
957
- }
958
- onMount(e) {
959
- this.store.lifecycleListeners.mount.push(e);
960
- }
961
- onUnmount(e) {
962
- this.store.lifecycleListeners.unmount.push(e);
963
- }
964
- effect(e) {
965
- const n = this.store;
966
- if (n.isMounted) {
967
- const s = v(e);
968
- return n.lifecycleListeners.unmount.push(s), s;
969
- } else {
970
- let s, i = !1;
971
- return n.lifecycleListeners.mount.push(() => {
972
- i || (s = v(e), n.lifecycleListeners.unmount.push(s));
973
- }), () => {
974
- s != null && (i = !0, s());
975
- };
976
- }
977
- }
978
- };
979
- class Xe {
980
- constructor(e, n) {
981
- f(this, "fn");
982
- f(this, "_options");
983
- /**
984
- * Value is guaranteed to be set after `attach` is called.
985
- */
986
- f(this, "value");
987
- f(this, "isMounted", !1);
988
- f(this, "elementContext");
989
- f(this, "lifecycleListeners", { mount: [], unmount: [] });
990
- f(this, "logger");
991
- f(this, "id", we());
992
- f(this, "name");
993
- this.fn = e, this.name = e.name, this._options = n;
994
- }
995
- /**
996
- * Attaches this Store to the elementContext.
997
- * Returns false if there was already an instance attached, and true otherwise.
998
- */
999
- attach(e) {
1000
- if (e.stores.has(this.fn))
1001
- return !1;
1002
- this.elementContext = e, this.logger = e.root.createLogger(this.name);
1003
- const n = new Ke(this);
1004
- try {
1005
- this.value = this.fn.call(n, this._options, n);
1006
- } catch (s) {
1007
- throw this.logger.crash(s), s;
1008
- }
1009
- return e.stores.set(this.fn, this), !0;
1010
- }
1011
- handleMount() {
1012
- this.isMounted = !0;
1013
- for (const e of this.lifecycleListeners.mount)
1014
- e();
1015
- this.lifecycleListeners.mount.length = 0;
1016
- }
1017
- handleUnmount() {
1018
- this.isMounted = !1;
1019
- for (const e of this.lifecycleListeners.unmount)
1020
- e();
1021
- this.lifecycleListeners.unmount.length = 0;
1022
- }
1023
- }
1024
- class $ extends Error {
1025
- }
1026
- class Ye {
1027
- constructor(e) {
1028
- f(this, "view");
1029
- this.view = e;
1030
- const n = Object.getOwnPropertyDescriptors(this.view.logger);
1031
- for (const s in n)
1032
- s !== "setName" && Object.defineProperty(this, s, n[s]);
1033
- }
1034
- get uid() {
1035
- return this.view.uniqueId;
1036
- }
1037
- get isMounted() {
1038
- return this.view.isMounted;
1039
- }
1040
- get name() {
1041
- return this.view.elementContext.viewName || this.uid;
1042
- }
1043
- set name(e) {
1044
- this.view.elementContext.viewName = e, this.view.logger.setName(e);
1045
- }
1046
- provide(e, n) {
1047
- const s = new Xe(e, n);
1048
- if (s.attach(this.view.elementContext))
1049
- return this.view.lifecycleListeners.mount.push(() => {
1050
- s.handleMount();
1051
- }), this.view.lifecycleListeners.unmount.push(() => {
1052
- s.handleUnmount();
1053
- }), s.value;
1054
- {
1055
- let o = e.name ? `'${e.name}'` : "this store";
1056
- return this.view.logger.warn(`An instance of ${o} was already attached to this context.`), this.get(e);
1057
- }
1058
- }
1059
- get(e) {
1060
- if (E(e)) {
1061
- let n = this.view.elementContext, s;
1062
- for (; s = n.stores.get(e), s == null && n.parent != null; )
1063
- n = n.parent;
1064
- if (s == null)
1065
- throw new $(`Store '${e.name}' is not provided on this context.`);
1066
- return s.value;
1067
- } else
1068
- throw new $("Invalid store.");
1069
- }
1070
- beforeMount(e) {
1071
- this.view.lifecycleListeners.beforeMount.push(e);
1072
- }
1073
- onMount(e) {
1074
- this.view.lifecycleListeners.mount.push(e);
1075
- }
1076
- beforeUnmount(e) {
1077
- this.view.lifecycleListeners.beforeUnmount.push(e);
1078
- }
1079
- onUnmount(e) {
1080
- this.view.lifecycleListeners.unmount.push(e);
1081
- }
1082
- effect(e) {
1083
- if (this.view.isMounted) {
1084
- const n = v(e);
1085
- return this.view.lifecycleListeners.unmount.push(n), n;
1086
- } else {
1087
- let n, s = !1;
1088
- return this.view.lifecycleListeners.mount.push(() => {
1089
- s || (n = v(e), this.view.lifecycleListeners.unmount.push(n));
1090
- }), () => {
1091
- n != null && (s = !0, n());
1092
- };
1093
- }
1094
- }
1095
- outlet() {
1096
- return b("$outlet", { children: this.view.children });
1097
- }
1098
- }
1099
- var ce;
1100
- ce = N;
1101
- const Q = class Q {
1102
- constructor(e, n, s, i = []) {
1103
- f(this, ce, !0);
1104
- f(this, "uniqueId", we());
1105
- f(this, "elementContext");
1106
- f(this, "logger");
1107
- f(this, "props");
1108
- f(this, "fn");
1109
- f(this, "element");
1110
- f(this, "childMarkup");
1111
- f(this, "children", G([]));
1112
- f(this, "lifecycleListeners", { beforeMount: [], mount: [], beforeUnmount: [], unmount: [] });
1113
- f(this, "isMounted", !1);
1114
- this.elementContext = {
1115
- ...e,
1116
- parent: e,
1117
- viewName: n.name,
1118
- stores: /* @__PURE__ */ new Map()
1119
- }, this.logger = e.root.createLogger(n.name || "🌇 anonymous view", { uid: this.uniqueId }), this.props = s, this.fn = n, this.childMarkup = i;
1120
- }
1121
- /*===============================*\
1122
- || "Public" API ||
1123
- \*===============================*/
1124
- get node() {
1125
- var e;
1126
- return (e = this.element) == null ? void 0 : e.node;
1127
- }
1128
- mount(e, n) {
1129
- const s = this.isMounted;
1130
- if (!s) {
1131
- this._initialize();
1132
- for (const i of this.lifecycleListeners.beforeMount)
1133
- i();
1134
- }
1135
- this.element && this.element.mount(e, n), s || (this.isMounted = !0, requestAnimationFrame(() => {
1136
- for (const i of this.lifecycleListeners.mount)
1137
- i();
1138
- }));
1139
- }
1140
- unmount(e = !1) {
1141
- for (const n of this.lifecycleListeners.beforeUnmount)
1142
- n();
1143
- this.element && this.element.unmount(e), this.isMounted = !1;
1144
- for (const n of this.lifecycleListeners.unmount)
1145
- n();
1146
- this.lifecycleListeners.beforeMount.length = 0, this.lifecycleListeners.mount.length = 0, this.lifecycleListeners.beforeUnmount.length = 0, this.lifecycleListeners.unmount.length = 0;
1147
- }
1148
- setChildView(e) {
1149
- this.childMarkup = [];
1150
- const n = new Q(this.elementContext, e, {});
1151
- return this.children.value = [n], n;
1152
- }
1153
- /*===============================*\
1154
- || Internal ||
1155
- \*===============================*/
1156
- _initialize() {
1157
- const e = new Ye(this);
1158
- let n;
1159
- try {
1160
- n = this.fn.call(e, this.props, e), this.childMarkup.length && (this.children.value = k(this.elementContext, this.childMarkup));
1161
- } catch (s) {
1162
- throw s instanceof Error && this.logger.crash(s), s;
1163
- }
1164
- if (n !== null) if (n instanceof Node)
1165
- this.element = O(k(this.elementContext, b("$node", { value: n })));
1166
- else if (g(n))
1167
- this.element = O(
1168
- k(this.elementContext, b("$dynamic", { source: n }))
1169
- );
1170
- else if (j(n) || F(j, n))
1171
- this.element = O(k(this.elementContext, n));
1172
- else {
1173
- const s = new TypeError(
1174
- `Expected '${this.fn.name}' function to return a DOM node, Markup element, Readable or null. Got: ${L(n)}`
1175
- );
1176
- this.logger.crash(s);
1177
- }
1178
- }
1179
- };
1180
- let I = Q;
1181
- var le;
1182
- le = N;
1183
- class Je {
1184
- constructor({ elementContext: e, items: n, renderFn: s, keyFn: i }) {
1185
- f(this, le, !0);
1186
- f(this, "node", document.createTextNode(""));
1187
- f(this, "items");
1188
- f(this, "unsubscribe", null);
1189
- f(this, "connectedItems", []);
1190
- f(this, "elementContext");
1191
- f(this, "renderFn");
1192
- f(this, "keyFn");
1193
- this.elementContext = e, this.items = n, this.renderFn = s, this.keyFn = i;
1194
- }
1195
- get isMounted() {
1196
- return this.node.parentNode != null;
1197
- }
1198
- mount(e, n) {
1199
- this.isMounted || (e.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null), this.unsubscribe = v(() => {
1200
- let s = w(this.items);
1201
- s == null && (s = [], console.log("list received empty value", s, this)), K(), this._update(Array.from(s)), X();
1202
- }));
1203
- }
1204
- unmount(e = !1) {
1205
- var n;
1206
- this.unsubscribe && (this.unsubscribe(), this.unsubscribe = null), !e && this.isMounted && ((n = this.node.parentNode) == null || n.removeChild(this.node)), this._cleanup(e);
1207
- }
1208
- _cleanup(e) {
1209
- for (const n of this.connectedItems)
1210
- n.element.unmount(e);
1211
- this.connectedItems = [];
1212
- }
1213
- _update(e) {
1214
- var l, a, m;
1215
- if (e.length === 0 || !this.isMounted)
1216
- return this._cleanup(!1);
1217
- const n = [];
1218
- let s = 0;
1219
- for (const r of e)
1220
- n.push({
1221
- key: this.keyFn(r, s),
1222
- value: r,
1223
- index: s++
1224
- });
1225
- const i = [];
1226
- for (const r of this.connectedItems)
1227
- n.find((c) => c.key === r.key) || r.element.unmount(!1);
1228
- for (const r of n) {
1229
- const u = this.connectedItems.find((c) => c.key === r.key);
1230
- if (u)
1231
- u.item.value = r.value, u.index.value = r.index, i[r.index] = u;
1232
- else {
1233
- const c = G(r.value), d = G(r.index);
1234
- i[r.index] = {
1235
- key: r.key,
1236
- item: c,
1237
- index: d,
1238
- element: new I(this.elementContext, Qe, {
1239
- item: Y(() => c.value),
1240
- index: d,
1241
- renderFn: this.renderFn
1242
- })
1243
- };
1244
- }
1245
- }
1246
- for (let r = 0; r < i.length; r++) {
1247
- const u = i[r], c = ((l = i[r - 1]) == null ? void 0 : l.element.node) ?? this.node;
1248
- u.element.mount(this.node.parentNode, c);
1249
- }
1250
- this.connectedItems = i;
1251
- const o = ((a = i.at(-1)) == null ? void 0 : a.element.node) ?? this.node;
1252
- (m = this.node.parentNode) == null || m.insertBefore(this.node, o.nextSibling);
1253
- }
1254
- }
1255
- function Qe(t, e) {
1256
- return e.name = "@ListItem", t.renderFn.call(e, t.item, t.index, e);
1257
- }
1258
- var fe;
1259
- fe = N;
1260
- class Me {
1261
- constructor(e) {
1262
- f(this, fe, !0);
1263
- f(this, "node", document.createTextNode(""));
1264
- f(this, "isMounted", !1);
1265
- f(this, "source");
1266
- f(this, "elements", []);
1267
- f(this, "unsubscribe");
1268
- this.source = e;
1269
- }
1270
- mount(e, n) {
1271
- this.isMounted || (this.isMounted = !0, e.insertBefore(this.node, (n == null ? void 0 : n.nextSibling) ?? null), g(this.source) ? this.unsubscribe = v(() => {
1272
- const s = w(this.source);
1273
- K(), this.update(s), X();
1274
- }) : this.update(this.elements));
1275
- }
1276
- unmount(e = !1) {
1277
- this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0), this.isMounted && (this.cleanup(e), this.isMounted = !1);
1278
- }
1279
- cleanup(e) {
1280
- for (const n of this.elements)
1281
- n.unmount(e);
1282
- this.elements = [];
1283
- }
1284
- update(e) {
1285
- var n, s;
1286
- if (this.cleanup(!1), e.length > 0) {
1287
- for (let i = 0; i < e.length; i++) {
1288
- const o = e[i], l = i > 0 ? this.elements[i - 1] : void 0;
1289
- o.mount(this.node.parentElement, l == null ? void 0 : l.node), this.elements.push(o);
1290
- }
1291
- (s = this.node.parentNode) == null || s.insertBefore(this.node, ((n = this.elements.at(-1)) == null ? void 0 : n.node) ?? null);
1292
- }
1293
- }
1294
- }
1295
- var ae;
1296
- ae = N;
1297
- class et {
1298
- constructor(e) {
1299
- f(this, ae, !0);
1300
- f(this, "config");
1301
- f(this, "element");
1302
- this.config = e;
1303
- }
1304
- get isMounted() {
1305
- return this.element ? this.element.isMounted : !1;
1306
- }
1307
- mount(e, n) {
1308
- const { content: s, parent: i } = this.config;
1309
- Ee(s) ? this.element = s : this.element = O(k(this.config.elementContext, J(s))), this.element.mount(i);
1310
- }
1311
- unmount(e = !1) {
1312
- var n;
1313
- (n = this.element) != null && n.isMounted && this.element.unmount(e);
1314
- }
1315
- }
1316
- function j(t) {
1317
- return t instanceof Se;
1318
- }
1319
- function Ee(t) {
1320
- return (t == null ? void 0 : t[N]) === !0;
1321
- }
1322
- function J(t) {
1323
- return P(t) || (t = [t]), t.flat(1 / 0).filter((e) => e != null && e !== !1).map((e) => j(e) ? e : e instanceof Node ? b("$node", { value: e }) : g(e) ? b("$dynamic", { source: e }) : b("$text", { value: e }));
1324
- }
1325
- function b(t, e, ...n) {
1326
- return new Se(t, e, ...n);
1327
- }
1328
- class Se {
1329
- constructor(e, n, ...s) {
1330
- f(this, "type");
1331
- f(this, "props");
1332
- f(this, "children");
1333
- this.type = e, this.props = n, this.children = J(s);
1334
- }
1335
- }
1336
- const wt = Ge.bind(b);
1337
- function bt(t, e, n) {
1338
- return b("$dynamic", {
1339
- source: Y(() => {
1340
- const s = w(t);
1341
- return s && e ? e : !s && n ? n : null;
1342
- })
1343
- });
1344
- }
1345
- function xt(t, e, n) {
1346
- return b("$list", { items: Y(() => t), keyFn: e, renderFn: n });
1347
- }
1348
- function Mt(t, e) {
1349
- return b("$portal", { parent: t, content: e });
1350
- }
1351
- function k(t, e) {
1352
- return (P(e) ? e : [e]).map((s) => {
1353
- if (E(s.type))
1354
- return new I(t, s.type, s.props, s.children);
1355
- if (D(s.type))
1356
- switch (s.type) {
1357
- case "$node": {
1358
- const i = s.props;
1359
- return new se(i.value);
1360
- }
1361
- case "$text": {
1362
- const i = s.props;
1363
- return new se(document.createTextNode(String(i.value)));
1364
- }
1365
- case "$list": {
1366
- const i = s.props;
1367
- return new Je({
1368
- items: i.items,
1369
- keyFn: i.keyFn,
1370
- renderFn: i.renderFn,
1371
- elementContext: t
1372
- });
1373
- }
1374
- case "$dynamic": {
1375
- const i = s.props;
1376
- return new Fe({
1377
- source: i.source,
1378
- elementContext: t
1379
- });
1380
- }
1381
- case "$outlet": {
1382
- const i = s.props;
1383
- return new Me(i.children);
1384
- }
1385
- case "$portal": {
1386
- const i = s.props;
1387
- return new et({
1388
- content: i.content,
1389
- parent: i.parent,
1390
- elementContext: t
1391
- });
1392
- }
1393
- default:
1394
- if (s.type.startsWith("$"))
1395
- throw new Error(`Unknown markup type: ${s.type}`);
1396
- return new Ze({
1397
- tag: s.type,
1398
- props: s.props ?? {},
1399
- children: s.children,
1400
- elementContext: t
1401
- });
1402
- }
1403
- else
1404
- throw new TypeError(`Expected a string or view function. Got: ${s.type}`);
1405
- });
1406
- }
1407
- function O(t) {
1408
- return t.length === 1 ? t[0] : new Me(t);
1409
- }
1410
- function Ne(t) {
1411
- return t == null || t === !1 || D(t) || Pe(t) || j(t) || g(t) || F(Ne, t);
1412
- }
1413
- export {
1414
- Mt as A,
1415
- xt as B,
1416
- gt as I,
1417
- yt as P,
1418
- Xe as S,
1419
- I as V,
1420
- ot as a,
1421
- ut as b,
1422
- G as c,
1423
- Y as d,
1424
- lt as e,
1425
- D as f,
1426
- w as g,
1427
- W as h,
1428
- E as i,
1429
- B as j,
1430
- bt as k,
1431
- wt as l,
1432
- mt as m,
1433
- $ as n,
1434
- ct as o,
1435
- b as p,
1436
- O as q,
1437
- k as r,
1438
- dt as s,
1439
- L as t,
1440
- at as u,
1441
- pt as v,
1442
- v as w,
1443
- Re as x,
1444
- ft as y,
1445
- ht as z
1446
- };
1447
- //# sourceMappingURL=markup-DkQI155j.js.map