@manyducks.co/dolla 2.0.0-alpha.25 → 2.0.0-alpha.27

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