@manyducks.co/dolla 2.0.0-alpha.36 → 2.0.0-alpha.37

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