@manyducks.co/dolla 2.0.0-alpha.57 → 2.0.0-alpha.59

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.
Files changed (39) hide show
  1. package/dist/core/app.d.ts +17 -0
  2. package/dist/core/context.d.ts +71 -19
  3. package/dist/core/index.d.ts +3 -3
  4. package/dist/core/logger.d.ts +2 -2
  5. package/dist/core/markup.d.ts +14 -13
  6. package/dist/core/mount.d.ts +2 -2
  7. package/dist/core/nodes/dom.d.ts +3 -2
  8. package/dist/core/nodes/dynamic.d.ts +2 -1
  9. package/dist/core/nodes/html.d.ts +7 -5
  10. package/dist/core/nodes/portal.d.ts +4 -3
  11. package/dist/core/nodes/repeat.d.ts +5 -3
  12. package/dist/core/nodes/view.d.ts +6 -8
  13. package/dist/core/signals.d.ts +3 -23
  14. package/dist/core/views/default-crash-view.d.ts +12 -1
  15. package/dist/i18n.js +1 -1
  16. package/dist/index.js +87 -88
  17. package/dist/index.js.map +1 -1
  18. package/dist/jsx-dev-runtime.d.ts +2 -1
  19. package/dist/jsx-dev-runtime.js +4 -11
  20. package/dist/jsx-dev-runtime.js.map +1 -1
  21. package/dist/jsx-runtime.d.ts +3 -2
  22. package/dist/jsx-runtime.js +7 -13
  23. package/dist/jsx-runtime.js.map +1 -1
  24. package/dist/logger-Ck_9LCem.js +516 -0
  25. package/dist/logger-Ck_9LCem.js.map +1 -0
  26. package/dist/markup-BBa4WBj1.js +1019 -0
  27. package/dist/markup-BBa4WBj1.js.map +1 -0
  28. package/dist/{router-ClSFnmRK.js → router-CaR7Xd4T.js} +77 -76
  29. package/dist/router-CaR7Xd4T.js.map +1 -0
  30. package/dist/router.js +1 -1
  31. package/dist/types.d.ts +7 -0
  32. package/docs/markup.md +4 -4
  33. package/notes/observable.md +180 -0
  34. package/package.json +2 -2
  35. package/dist/logger-sSxIw5od.js +0 -626
  36. package/dist/logger-sSxIw5od.js.map +0 -1
  37. package/dist/markup-CAJd0zdA.js +0 -937
  38. package/dist/markup-CAJd0zdA.js.map +0 -1
  39. package/dist/router-ClSFnmRK.js.map +0 -1
@@ -0,0 +1,1019 @@
1
+ var at = Object.defineProperty;
2
+ var B = (o) => {
3
+ throw TypeError(o);
4
+ };
5
+ var ht = (o, t, e) => t in o ? at(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
6
+ var c = (o, t, e) => ht(o, typeof t != "symbol" ? t + "" : t, e), W = (o, t, e) => t.has(o) || B("Cannot " + e);
7
+ var L = (o, t, e) => (W(o, t, "read from private field"), e ? e.call(o) : t.get(o)), D = (o, t, e) => t.has(o) ? B("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e), $ = (o, t, e, s) => (W(o, t, "write to private field"), s ? s.call(o, e) : t.set(o, e), e);
8
+ import { c as f, t as ut, g as X, b as U, i as tt } from "./typeChecking-BJ-ymQ2F.js";
9
+ import { u as S, h as lt, g as w, k as et, e as g, c as dt, l as ft, b as mt, $ as T, d as pt } from "./logger-Ck_9LCem.js";
10
+ const A = Symbol("name"), u = Symbol("lifecycle"), p = Symbol("parent"), y = Symbol("stores"), b = Symbol("state");
11
+ class bt {
12
+ constructor(t) {
13
+ c(this, "context");
14
+ c(this, "state", 0);
15
+ c(this, "listeners", /* @__PURE__ */ new Map());
16
+ c(this, "bound");
17
+ this.context = t;
18
+ }
19
+ /**
20
+ * Listen for a certain event to be emitted. Listeners are called when the event results in a state change.
21
+ */
22
+ on(t, e) {
23
+ const s = this.listeners.get(t);
24
+ s ? s.add(e) : this.listeners.set(t, /* @__PURE__ */ new Set([e]));
25
+ }
26
+ /**
27
+ * Stop a particular listener from being called when an event is emitted.
28
+ */
29
+ off(t, e) {
30
+ const s = this.listeners.get(t);
31
+ s && (s.delete(e), s.size === 0 && this.listeners.delete(t));
32
+ }
33
+ /**
34
+ * Advance the lifecycle state machine.
35
+ */
36
+ emit(t) {
37
+ switch (t) {
38
+ case 0: {
39
+ this.state < 1 ? (this.state = 1, this.notify(t)) : this.context.crash(new Error(`Tried to WILL_MOUNT context at state ${this.state}`));
40
+ break;
41
+ }
42
+ case 1: {
43
+ this.state >= 1 && this.state < 2 ? (this.state = 2, this.notify(t)) : this.context.crash(new Error(`Tried to WILL_UNMOUNT context at state ${this.state}`));
44
+ break;
45
+ }
46
+ case 2: {
47
+ this.state >= 2 && this.state < 3 ? (this.notify(t), this.state = 3) : this.context.crash(new Error(`Tried to WILL_UNMOUNT context at state ${this.state}`));
48
+ break;
49
+ }
50
+ case 3: {
51
+ this.state >= 3 && this.state < 4 ? (this.state = 4 % 4, this.notify(t)) : this.context.crash(new Error(`Tried to DID_UNMOUNT context at state ${this.state}`));
52
+ break;
53
+ }
54
+ case 4: {
55
+ this.state === 0 ? (this.notify(t), this.listeners.clear(), this.bound = void 0, this.state = 5) : this.context.crash(new Error(`Tried to DISPOSE context at state ${this.state}`));
56
+ break;
57
+ }
58
+ }
59
+ }
60
+ /**
61
+ * Bind `context` to this lifecycle; when any event is emitted here it will be emitted for `context` as well.
62
+ */
63
+ bind(t) {
64
+ this.bound ? this.bound.add(t) : this.bound = /* @__PURE__ */ new Set([t]);
65
+ }
66
+ /**
67
+ * Call all the event's listeners and re-emit to bound contexts.
68
+ */
69
+ notify(t) {
70
+ const e = this.listeners.get(t);
71
+ if (e)
72
+ for (const s of e)
73
+ s();
74
+ if (this.bound)
75
+ for (const s of this.bound)
76
+ s[u].emit(t);
77
+ }
78
+ }
79
+ var j, q, G, H, z, v;
80
+ z = A, H = u, G = p, q = y, j = b;
81
+ const N = class N {
82
+ constructor(t, e) {
83
+ D(this, v);
84
+ c(this, z);
85
+ c(this, H, new bt(this));
86
+ c(this, G);
87
+ c(this, q);
88
+ c(this, j);
89
+ $(this, v, t), this[A] = S(t);
90
+ const s = lt(() => w(L(this, v)), e == null ? void 0 : e.logger), i = Object.getOwnPropertyDescriptors(s);
91
+ for (const n in i)
92
+ Object.defineProperty(this, n, i[n]);
93
+ }
94
+ get isMounted() {
95
+ const { state: t } = this[u];
96
+ return t >= 2 && t < 4;
97
+ }
98
+ /**
99
+ * Returns a new Context with this one as its parent.
100
+ */
101
+ static linked(t, e, s) {
102
+ const i = new N(e, s);
103
+ return i[p] = t, s != null && s.bindLifecycleToParent && t[u].bind(i), i;
104
+ }
105
+ /**
106
+ * Emit "will mount" lifecycle event to `context`.
107
+ */
108
+ static willMount(t) {
109
+ t[u].emit(
110
+ 0
111
+ /* WILL_MOUNT */
112
+ );
113
+ }
114
+ /**
115
+ * Emit "did mount" lifecycle event to `context`.
116
+ */
117
+ static didMount(t) {
118
+ t[u].emit(
119
+ 1
120
+ /* DID_MOUNT */
121
+ );
122
+ }
123
+ /**
124
+ * Emit "will unmount" lifecycle event to `context`.
125
+ */
126
+ static willUnmount(t) {
127
+ t[u].emit(
128
+ 2
129
+ /* WILL_UNMOUNT */
130
+ );
131
+ }
132
+ /**
133
+ * Emit "did unmount" lifecycle event to `context`.
134
+ */
135
+ static didUnmount(t) {
136
+ t[u].emit(
137
+ 3
138
+ /* DID_UNMOUNT */
139
+ );
140
+ }
141
+ /**
142
+ * Emit "dispose" lifecycle event to `context`.
143
+ */
144
+ static dispose(t) {
145
+ t[u].emit(
146
+ 4
147
+ /* DISPOSE */
148
+ ), t[b] = void 0, t[y] = void 0;
149
+ }
150
+ /**
151
+ * Traverses _parent contexts until arriving at one that doesn't have a parent itself.
152
+ * Returns null if this context is the parent.
153
+ */
154
+ static getRoot(t) {
155
+ let e = t[p];
156
+ for (; e != null && e[p]; )
157
+ e = e[p];
158
+ return e ?? null;
159
+ }
160
+ /**
161
+ * Returns the current name of this context.
162
+ */
163
+ getName() {
164
+ return S(L(this, v));
165
+ }
166
+ /**
167
+ * Sets a new name for this context.
168
+ */
169
+ setName(t) {
170
+ $(this, v, t), this[A] = S(t);
171
+ }
172
+ /**
173
+ * Creates an instance of a store and attaches it to this context.
174
+ */
175
+ addStore(t, e) {
176
+ var i;
177
+ if ((i = this[y]) != null && i.get(t)) {
178
+ let n = t.name ? `'${t.name}'` : "this store";
179
+ throw this.crash(new I(`An instance of ${n} was already added on this context.`));
180
+ }
181
+ const s = N.linked(this, t.name, {
182
+ bindLifecycleToParent: !0,
183
+ logger: { tag: et(), tagName: "uid" }
184
+ });
185
+ try {
186
+ this[y] || (this[y] = /* @__PURE__ */ new Map());
187
+ const n = t.call(s, e, s);
188
+ this[y].set(t, n);
189
+ } catch (n) {
190
+ throw this.crash(n);
191
+ }
192
+ return this;
193
+ }
194
+ /**
195
+ * Retrieves the nearest instance of `store`. If this context doesn't have it, the parent context is checked. This process continues until either:
196
+ * 1. An instance of the store is found and returned.
197
+ * 2. No instance is found and an error is thrown.
198
+ */
199
+ getStore(t) {
200
+ var i;
201
+ if (!f(t))
202
+ throw new I("Invalid store.");
203
+ let e = this, s;
204
+ for (; s = (i = e[y]) == null ? void 0 : i.get(t), s == null && e[p] != null; )
205
+ e = e[p];
206
+ if (s == null)
207
+ throw this.crash(new I(`Store '${t.name}' is not provided by this context.`));
208
+ return s;
209
+ }
210
+ /**
211
+ * Schedule a callback function to run just before this context is mounted.
212
+ */
213
+ beforeMount(t) {
214
+ return this[u].on(0, t), () => this[u].off(0, t);
215
+ }
216
+ /**
217
+ * Schedule a callback function to run after this context is mounted.
218
+ */
219
+ onMount(t) {
220
+ return this[u].on(1, t), () => this[u].off(1, t);
221
+ }
222
+ /**
223
+ * Schedule a callback function to run just before this context is unmounted.
224
+ */
225
+ beforeUnmount(t) {
226
+ return this[u].on(2, t), () => this[u].off(2, t);
227
+ }
228
+ /**
229
+ * Schedule a callback function to run after this context is unmounted.
230
+ */
231
+ onUnmount(t) {
232
+ return this[u].on(3, t), () => this[u].off(3, t);
233
+ }
234
+ effect(t) {
235
+ const e = () => {
236
+ try {
237
+ return t();
238
+ } catch (s) {
239
+ this.error(s), s instanceof Error ? this.crash(s) : typeof s == "string" ? this.crash(new Error(s)) : this.crash(new Error("Unknown error thrown in effect callback"));
240
+ }
241
+ };
242
+ if (this[u].state >= 1) {
243
+ const s = g(e);
244
+ return this[u].on(3, s), s;
245
+ } else {
246
+ let s, i = !1;
247
+ return this[u].on(0, () => {
248
+ i || (s = g(e), this[u].on(3, s));
249
+ }), () => {
250
+ s != null && (i = !0, s());
251
+ };
252
+ }
253
+ }
254
+ getState(t, e) {
255
+ var s;
256
+ if (arguments.length > 0) {
257
+ let i = this, n;
258
+ for (; n = (s = i[b]) == null ? void 0 : s.get(t), n === void 0 && i[p] != null; )
259
+ i = i[p];
260
+ if (n === void 0) {
261
+ if (arguments.length > 1)
262
+ return e;
263
+ throw new Error(`Expected a value for '${String(t)}' but got undefined.`);
264
+ }
265
+ return n;
266
+ } else {
267
+ let i = this;
268
+ const n = [];
269
+ for (; i[b] && n.push(...i[b].entries()), i[p] != null; )
270
+ i = i[p];
271
+ return new Map(n.reverse());
272
+ }
273
+ }
274
+ setState() {
275
+ if (this[b] || (this[b] = /* @__PURE__ */ new Map()), arguments.length === 2)
276
+ this[b].set(arguments[0], arguments[1]);
277
+ else if (ut(arguments[0]) === "array")
278
+ for (const [t, e] of arguments[0])
279
+ e === void 0 ? this[b].delete(t) : this[b].set(t, e);
280
+ else
281
+ throw new Error("Invalid arguments.");
282
+ return this;
283
+ }
284
+ };
285
+ v = new WeakMap();
286
+ let l = N;
287
+ function At(o, t) {
288
+ return new l(o, t);
289
+ }
290
+ class I extends Error {
291
+ }
292
+ const x = Symbol.for("dollaMarkupNode");
293
+ var F;
294
+ F = x;
295
+ class E {
296
+ constructor(t) {
297
+ c(this, F, !0);
298
+ c(this, "root");
299
+ this.root = t;
300
+ }
301
+ isMounted() {
302
+ return this.root.parentNode != null;
303
+ }
304
+ mount(t, e) {
305
+ t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null);
306
+ }
307
+ unmount(t = !1) {
308
+ this.root.parentNode && !t && this.root.parentNode.removeChild(this.root);
309
+ }
310
+ move(t, e) {
311
+ if ("moveBefore" in t && this.root instanceof Element)
312
+ try {
313
+ t.moveBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null);
314
+ } catch {
315
+ this.mount(t, e);
316
+ }
317
+ else
318
+ this.mount(t, e);
319
+ }
320
+ }
321
+ var Z;
322
+ Z = x;
323
+ class C {
324
+ constructor(t, e) {
325
+ c(this, Z, !0);
326
+ c(this, "root", document.createTextNode(""));
327
+ c(this, "children", []);
328
+ c(this, "context");
329
+ c(this, "$slot");
330
+ c(this, "unsubscribe");
331
+ this.context = t, this.$slot = e;
332
+ }
333
+ isMounted() {
334
+ return this.root.parentElement != null;
335
+ }
336
+ mount(t, e) {
337
+ this.isMounted() || (t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.unsubscribe = g(() => {
338
+ try {
339
+ const s = this.$slot();
340
+ S(() => {
341
+ this.update(X(s) ? s : [s]);
342
+ });
343
+ } catch (s) {
344
+ this.context.crash(s);
345
+ }
346
+ }));
347
+ }
348
+ unmount(t = !1) {
349
+ var e, s;
350
+ (e = this.unsubscribe) == null || e.call(this), this.isMounted() && (this.cleanup(t), (s = this.root.parentNode) == null || s.removeChild(this.root));
351
+ }
352
+ move(t, e) {
353
+ var s, i, n;
354
+ if ("moveBefore" in t)
355
+ try {
356
+ t.moveBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null);
357
+ for (let r = 0; r < this.children.length; r++)
358
+ this.children[r].move(t, ((s = this.children[r - 1]) == null ? void 0 : s.root) ?? this.root);
359
+ t.moveBefore(this.root, ((n = (i = this.children.at(-1)) == null ? void 0 : i.root) == null ? void 0 : n.nextSibling) ?? null);
360
+ } catch {
361
+ this.mount(t, e);
362
+ }
363
+ else
364
+ this.mount(t, e);
365
+ }
366
+ cleanup(t) {
367
+ for (const e of this.children)
368
+ e.isMounted() && e.unmount(t);
369
+ this.children.length = 0;
370
+ }
371
+ update(t) {
372
+ var s;
373
+ if (this.cleanup(!1), t.length === 0 || !this.isMounted()) return;
374
+ const e = _(this.context, t);
375
+ for (const i of e) {
376
+ const n = ((s = this.children.at(-1)) == null ? void 0 : s.root) || this.root;
377
+ i.mount(this.root.parentElement, n), this.children.push(i);
378
+ }
379
+ this.moveMarker();
380
+ }
381
+ /**
382
+ * Move marker node to end of children.
383
+ */
384
+ moveMarker() {
385
+ var s, i;
386
+ const t = this.root.parentElement, e = ((i = (s = this.children.at(-1)) == null ? void 0 : s.root) == null ? void 0 : i.nextSibling) ?? null;
387
+ "moveBefore" in t ? t.moveBefore(this.root, e) : t.insertBefore(this.root, e);
388
+ }
389
+ }
390
+ const st = Symbol("View");
391
+ var K;
392
+ K = x;
393
+ class it {
394
+ constructor(t, e, s) {
395
+ c(this, K, !0);
396
+ c(this, "uniqueId", et());
397
+ c(this, "context");
398
+ c(this, "props");
399
+ c(this, "view");
400
+ c(this, "node");
401
+ this.context = l.linked(t, e.name ?? "anonymous view", {
402
+ logger: {
403
+ tag: this.uniqueId,
404
+ tagName: "uid"
405
+ }
406
+ }), this.context.setState(st, this), this.props = s, this.view = e;
407
+ }
408
+ get root() {
409
+ var t;
410
+ return (t = this.node) == null ? void 0 : t.root;
411
+ }
412
+ isMounted() {
413
+ var t;
414
+ return ((t = this.node) == null ? void 0 : t.isMounted()) ?? !1;
415
+ }
416
+ mount(t, e) {
417
+ const s = this.isMounted();
418
+ if (!s) {
419
+ const { context: i, props: n, view: r } = this;
420
+ try {
421
+ const a = r.call(i, n, i);
422
+ a != null && a !== !1 && (this.node = ct(a, i));
423
+ } catch (a) {
424
+ throw a instanceof Error && i.crash(a), a;
425
+ }
426
+ l.willMount(this.context);
427
+ }
428
+ this.node && this.node.mount(t, e), s || l.didMount(this.context);
429
+ }
430
+ unmount(t = !1) {
431
+ l.willUnmount(this.context), this.node && this.node.unmount(t), l.didUnmount(this.context), l.dispose(this.context);
432
+ }
433
+ move(t, e) {
434
+ var s;
435
+ (s = this.node) == null || s.move(t, e);
436
+ }
437
+ }
438
+ const gt = (o) => /^on[A-Z]/.test(o), P = Symbol("HTML.isSVG");
439
+ var Y;
440
+ Y = x;
441
+ class wt {
442
+ constructor(t, e, s) {
443
+ c(this, Y, !0);
444
+ c(this, "root");
445
+ c(this, "parentContext");
446
+ c(this, "context");
447
+ c(this, "tag");
448
+ c(this, "props");
449
+ c(this, "childNodes", []);
450
+ c(this, "unsubscribers", []);
451
+ // Track the ref so we can nullify it on unmount.
452
+ c(this, "ref");
453
+ // Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
454
+ c(this, "canClickAway", !1);
455
+ if (this.parentContext = t, this.tag = e, this.props = s, this.context = l.linked(this.parentContext, V.bind(this)), e.toLowerCase() === "svg" && this.context.setState(P, !0), this.context.getState(P, !1) ? this.root = document.createElementNS("http://www.w3.org/2000/svg", e) : this.root = document.createElement(e), dt() === "development") {
456
+ const n = this.context.getState(st, null);
457
+ n && (this.root.dataset.view = n.context.getName());
458
+ }
459
+ if (s.mixin) {
460
+ const n = X(s.mixin) ? s.mixin : [s.mixin];
461
+ for (const r of n)
462
+ r(
463
+ this.root,
464
+ l.linked(this.context, V.bind(this), {
465
+ bindLifecycleToParent: !0,
466
+ logger: { tagName: r.name === "mixin" ? void 0 : "mixin", tag: r.name }
467
+ })
468
+ );
469
+ }
470
+ const i = s.className ?? s.class;
471
+ if (this.applyProps(this.root, ft(["class", "className", "ref", "mixin", "children"], s)), s.style && this.applyStyles(this.root, s.style, this.unsubscribers), i && this.applyClasses(this.root, i, this.unsubscribers), s.ref)
472
+ if (f(s.ref))
473
+ this.ref = s.ref, this.ref(this.root);
474
+ else
475
+ throw new Error("Expected ref to be a function. Got: " + s.ref);
476
+ s.children && (this.childNodes = _(this.context, s.children));
477
+ }
478
+ isMounted() {
479
+ return this.context.isMounted;
480
+ }
481
+ mount(t, e) {
482
+ const s = this.isMounted();
483
+ if (!s) {
484
+ l.willMount(this.context);
485
+ for (let i = 0; i < this.childNodes.length; i++) {
486
+ const n = this.childNodes[i], r = i > 0 ? this.childNodes[i - 1].root : void 0;
487
+ n.mount(this.root, r);
488
+ }
489
+ }
490
+ t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.canClickAway = !0, s || l.didMount(this.context);
491
+ }
492
+ unmount(t = !1) {
493
+ var e;
494
+ l.willUnmount(this.context), t || (e = this.root.parentNode) == null || e.removeChild(this.root);
495
+ for (const s of this.childNodes)
496
+ s.unmount(!0);
497
+ this.canClickAway = !1;
498
+ for (const s of this.unsubscribers)
499
+ s();
500
+ this.unsubscribers.length = 0, this.ref && this.ref(void 0), l.didUnmount(this.context), l.dispose(this.context);
501
+ }
502
+ move(t, e) {
503
+ if ("moveBefore" in t)
504
+ try {
505
+ t.moveBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null);
506
+ } catch {
507
+ this.mount(t, e);
508
+ }
509
+ else
510
+ this.mount(t, e);
511
+ }
512
+ attachProp(t, e) {
513
+ f(t) ? this.unsubscribers.push(
514
+ g(() => {
515
+ try {
516
+ e(t());
517
+ } catch (s) {
518
+ this.context.error(s), this.context.crash(s);
519
+ }
520
+ })
521
+ ) : e(t);
522
+ }
523
+ applyProps(t, e) {
524
+ const s = this.context;
525
+ for (const i in e) {
526
+ const n = e[i];
527
+ if (i === "on:clickoutside" || i === "onClickOutside" || i === "onclickoutside") {
528
+ const r = (d) => {
529
+ this.canClickAway && !t.contains(d.target) && n(d);
530
+ }, a = { capture: !0 };
531
+ window.addEventListener("click", r, a), this.unsubscribers.push(() => {
532
+ window.removeEventListener("click", r, a);
533
+ });
534
+ } else if (f(n) && gt(i)) {
535
+ const r = i.slice(2).toLowerCase(), a = n;
536
+ t.addEventListener(r, a), this.unsubscribers.push(() => {
537
+ t.removeEventListener(r, a);
538
+ });
539
+ } else if (i.startsWith("on") && f(n) && vt.includes(i.substring(2)))
540
+ t[i] = n, this.unsubscribers.push(() => {
541
+ t[i] = void 0;
542
+ });
543
+ else if (i.includes("-"))
544
+ this.attachProp(n, (r) => {
545
+ r == null ? t.removeAttribute(i) : t.setAttribute(i, String(r));
546
+ });
547
+ else if (!yt.includes(i))
548
+ if (s.getState(P, !1))
549
+ this.attachProp(n, (r) => {
550
+ r != null ? t.setAttribute(i, String(e[i])) : t.removeAttribute(i);
551
+ });
552
+ else
553
+ switch (i) {
554
+ case "contentEditable":
555
+ case "value":
556
+ this.attachProp(n, (r) => {
557
+ t[i] = String(r);
558
+ });
559
+ break;
560
+ case "for":
561
+ this.attachProp(n, (r) => {
562
+ t.htmlFor = r;
563
+ });
564
+ break;
565
+ case "innerHTML":
566
+ this.attachProp(n, (r) => {
567
+ t.innerHTML = r;
568
+ });
569
+ break;
570
+ case "title":
571
+ this.attachProp(n, (r) => {
572
+ r == null ? t.removeAttribute(i) : t.setAttribute(i, String(r));
573
+ });
574
+ case "checked":
575
+ this.attachProp(n, (r) => {
576
+ t.checked = r, r ? t.setAttribute("checked", "") : t.removeAttribute("checked");
577
+ });
578
+ break;
579
+ case "autocomplete":
580
+ case "autocapitalize":
581
+ this.attachProp(n, (r) => {
582
+ typeof r == "string" ? t[i] = r : r ? t[i] = "on" : t[i] = "off";
583
+ });
584
+ break;
585
+ default: {
586
+ if (i.startsWith("prop:")) {
587
+ const r = i.substring(5);
588
+ this.attachProp(n, (a) => {
589
+ t[r] = a;
590
+ });
591
+ } else if (i.startsWith("on:")) {
592
+ const r = i.substring(3);
593
+ let a;
594
+ f(n) ? (t.addEventListener(r, n), this.unsubscribers.push(() => {
595
+ t.removeEventListener(r, n);
596
+ })) : this.attachProp(n, (d) => {
597
+ !d && a ? t.removeEventListener(r, a) : d != null && (a && a !== d && t.removeEventListener(r, a), t.addEventListener(r, d)), a = d;
598
+ });
599
+ } else if (i.startsWith("attr:")) {
600
+ const r = i.substring(5).toLowerCase();
601
+ this.attachProp(n, (a) => {
602
+ a != null ? t.setAttribute(r, String(a)) : t.removeAttribute(r);
603
+ });
604
+ } else
605
+ this.attachProp(n, (r) => {
606
+ t[i] = r;
607
+ });
608
+ break;
609
+ }
610
+ }
611
+ }
612
+ }
613
+ applyStyles(t, e, s) {
614
+ const i = [];
615
+ if (f(e)) {
616
+ let n;
617
+ const r = g(() => {
618
+ f(n) && n(), t.style.cssText = "", n = this.applyStyles(t, w(e), s);
619
+ });
620
+ s.push(r), i.push(r);
621
+ } else {
622
+ const n = ot(e);
623
+ for (const r in n) {
624
+ const { value: a, priority: d } = n[r];
625
+ if (f(a)) {
626
+ const h = g(() => {
627
+ w(a) ? t.style.setProperty(r, String(w(a)), d) : t.style.removeProperty(r);
628
+ });
629
+ s.push(h), i.push(h);
630
+ } else a != null && t.style.setProperty(r, String(a));
631
+ }
632
+ }
633
+ return function() {
634
+ for (const r of i)
635
+ r(), s.splice(s.indexOf(r), 1);
636
+ };
637
+ }
638
+ applyClasses(t, e, s) {
639
+ const i = [];
640
+ if (f(e)) {
641
+ let n;
642
+ const r = g(() => {
643
+ f(n) && n(), t.removeAttribute("class"), n = this.applyClasses(t, w(e), s);
644
+ });
645
+ s.push(r), i.push(r);
646
+ } else {
647
+ const n = nt(e);
648
+ for (const r in n) {
649
+ const a = n[r];
650
+ if (f(a)) {
651
+ const d = g(() => {
652
+ w(a) ? t.classList.add(r) : t.classList.remove(r);
653
+ });
654
+ s.push(d), i.push(d);
655
+ } else a && t.classList.add(r);
656
+ }
657
+ }
658
+ return function() {
659
+ for (const r of i)
660
+ r(), s.splice(s.indexOf(r), 1);
661
+ };
662
+ }
663
+ }
664
+ function nt(o) {
665
+ let t = {};
666
+ if (U(o)) {
667
+ const e = o.split(" ");
668
+ for (const s of e)
669
+ t[s] = !0;
670
+ } else tt(o) ? Object.assign(t, o) : Array.isArray(o) && Array.from(o).filter(Boolean).forEach((e) => {
671
+ Object.assign(t, nt(e));
672
+ });
673
+ return delete t.undefined, t;
674
+ }
675
+ function ot(o) {
676
+ let t = {};
677
+ if (U(o)) {
678
+ const e = o.split(";").filter((s) => s.trim() !== "");
679
+ for (const s of e) {
680
+ const [i, n] = s.split(":"), r = {
681
+ value: n
682
+ };
683
+ n.includes("!important") ? (r.priority = "important", r.value = n.replace("!important", "").trim()) : r.value = n.trim(), t[R(i.trim())] = r;
684
+ }
685
+ }
686
+ if (tt(o))
687
+ for (const e in o)
688
+ e.startsWith("--") ? t[e] = { value: o[e] } : t[R(e)] = { value: o[e] };
689
+ else Array.isArray(o) && Array.from(o).filter((e) => e != null).forEach((e) => {
690
+ Object.assign(t, ot(e));
691
+ });
692
+ return t;
693
+ }
694
+ function V() {
695
+ if (this.root == null) return this.tag;
696
+ let o = this.root.tagName.toLowerCase();
697
+ if (this.root.id && (o += `#${this.root.id}`), this.root.classList.length > 0)
698
+ for (const t of this.root.classList.values())
699
+ o += `.${t}`;
700
+ return o;
701
+ }
702
+ function R(o) {
703
+ return o.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, e) => (e ? "-" : "") + t.toLowerCase());
704
+ }
705
+ const yt = ["ref", "children", "class", "style", "data", "mixin"], vt = [
706
+ // Element
707
+ "animationcancel",
708
+ "animationend",
709
+ "animationiteration",
710
+ "animationstart",
711
+ "auxclick",
712
+ "beforeinput",
713
+ "beforematch",
714
+ "beforexrselect",
715
+ "blur",
716
+ "click",
717
+ "compositionend",
718
+ "compositionstart",
719
+ "compositionupdate",
720
+ "contentvisibilityautostatechange",
721
+ "contextmenu",
722
+ "copy",
723
+ "cut",
724
+ "dblclick",
725
+ "focus",
726
+ "focusin",
727
+ "focusout",
728
+ "fullscreenchange",
729
+ "fullscreenerror",
730
+ "gotpointercapture",
731
+ "input",
732
+ "keydown",
733
+ "keyup",
734
+ "lostpointercapture",
735
+ "mousedown",
736
+ "mouseenter",
737
+ "mouseleave",
738
+ "mousemove",
739
+ "mouseout",
740
+ "mouseover",
741
+ "mouseup",
742
+ "paste",
743
+ "pointercancel",
744
+ "pointerdown",
745
+ "pointerenter",
746
+ "pointerleave",
747
+ "pointermove",
748
+ "pointerout",
749
+ "pointerover",
750
+ "pointerrawupdate",
751
+ "pointerup",
752
+ "scroll",
753
+ "scrollend",
754
+ "scrollsnapchange",
755
+ "scrollsnapchanging",
756
+ "securitypolicyviolation",
757
+ "touchcancel",
758
+ "touchend",
759
+ "touchmove",
760
+ "touchstart",
761
+ "transitioncancel",
762
+ "transitionend",
763
+ "transitionrun",
764
+ "transitionstart",
765
+ "webkitmouseforcechanged",
766
+ "webkitmouseforcedown",
767
+ "webkitmouseforceup",
768
+ "webkimouseforcewillbegin",
769
+ "wheel",
770
+ // HTMLElement
771
+ "beforetoggle",
772
+ "change",
773
+ "command",
774
+ "drag",
775
+ "dragend",
776
+ "dragenter",
777
+ "dragleave",
778
+ "dragover",
779
+ "dragstart",
780
+ "drop",
781
+ "error",
782
+ "load",
783
+ "toggle",
784
+ // HTMLInputElement
785
+ "cancel",
786
+ "invalid",
787
+ "search",
788
+ "select",
789
+ "selectionchange",
790
+ // HTMLFormElement
791
+ "formdata",
792
+ "reset",
793
+ "submit"
794
+ ];
795
+ var J;
796
+ J = x;
797
+ class xt {
798
+ constructor(t, e, s) {
799
+ c(this, J, !0);
800
+ c(this, "context");
801
+ c(this, "content");
802
+ c(this, "parent");
803
+ c(this, "element");
804
+ this.context = t, this.content = e, this.parent = s;
805
+ }
806
+ isMounted() {
807
+ return this.element ? this.element.isMounted() : !1;
808
+ }
809
+ mount(t, e) {
810
+ this.element = ct(this.content, this.context), this.element.mount(this.parent);
811
+ }
812
+ unmount(t = !1) {
813
+ var e;
814
+ (e = this.element) != null && e.isMounted() && this.element.unmount(!1);
815
+ }
816
+ move(t, e) {
817
+ }
818
+ }
819
+ var Q;
820
+ Q = x;
821
+ class kt {
822
+ constructor(t, e, s, i) {
823
+ c(this, Q, !0);
824
+ c(this, "root", document.createTextNode(""));
825
+ c(this, "context");
826
+ c(this, "items");
827
+ c(this, "key");
828
+ c(this, "render");
829
+ c(this, "unsubscribe", null);
830
+ c(this, "connectedItems", /* @__PURE__ */ new Map());
831
+ this.context = t, this.items = e, this.key = s, this.render = i;
832
+ }
833
+ isMounted() {
834
+ return this.root.parentElement != null;
835
+ }
836
+ mount(t, e) {
837
+ this.isMounted() || (t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.unsubscribe = g(() => {
838
+ let s = this.items();
839
+ s == null && (s = [], this.context.warn("repeat() received empty value for items", s)), S(() => {
840
+ this._update(Array.from(s));
841
+ });
842
+ }));
843
+ }
844
+ unmount(t = !1) {
845
+ var e;
846
+ this.unsubscribe && (this.unsubscribe(), this.unsubscribe = null), !t && this.isMounted() && ((e = this.root.parentNode) == null || e.removeChild(this.root)), this._cleanup(t);
847
+ }
848
+ move(t, e) {
849
+ return this.mount(t, e);
850
+ }
851
+ _cleanup(t) {
852
+ for (const e of this.connectedItems.values())
853
+ e.node.unmount(t);
854
+ this.connectedItems.clear();
855
+ }
856
+ _update(t) {
857
+ var r, a, d;
858
+ if (t.length === 0 || !this.isMounted())
859
+ return this._cleanup(!1);
860
+ const e = /* @__PURE__ */ new Map();
861
+ let s = 0;
862
+ for (const h of t) {
863
+ const m = this.key(h, s);
864
+ e.set(m, {
865
+ key: m,
866
+ value: h,
867
+ index: s++
868
+ });
869
+ }
870
+ const i = [];
871
+ for (const h of this.connectedItems.values())
872
+ !e.has(h.key) && h.node.isMounted() && h.node.unmount(!1);
873
+ mt(() => {
874
+ for (const h of e.values()) {
875
+ const m = this.connectedItems.get(h.key);
876
+ if (m && m.node.isMounted())
877
+ m.$item(h.value), m.$index(h.index), i[h.index] = m;
878
+ else {
879
+ const k = T(h.value, { equals: pt }), M = T(h.index);
880
+ i[h.index] = {
881
+ key: h.key,
882
+ $item: k,
883
+ $index: M,
884
+ node: new it(this.context, Mt, {
885
+ $item: () => k(),
886
+ $index: () => M(),
887
+ render: this.render
888
+ })
889
+ };
890
+ }
891
+ }
892
+ });
893
+ for (let h = 0; h < i.length; h++) {
894
+ const m = i[h], k = ((r = i[h - 1]) == null ? void 0 : r.node.root) ?? this.root, M = this.connectedItems.get(m.key);
895
+ M && M.node.isMounted() ? m.node.move(this.root.parentElement, k) : m.node.mount(this.root.parentElement, k);
896
+ }
897
+ this.connectedItems.clear();
898
+ for (const h of i)
899
+ this.connectedItems.set(h.key, h);
900
+ const n = ((a = i.at(-1)) == null ? void 0 : a.node.root) ?? this.root;
901
+ (d = this.root.parentNode) == null || d.insertBefore(this.root, n.nextSibling);
902
+ }
903
+ }
904
+ function Mt(o, t) {
905
+ return t.setName("@RepeatItemView"), o.render.call(t, o.$item, o.$index, t);
906
+ }
907
+ class rt {
908
+ constructor(t, e) {
909
+ /**
910
+ * In the case of a view, type will be the View function itself. It can also hold an identifier for special nodes like "$cond", "$repeat", etc.
911
+ * DOM nodes can be created by name, such as HTML elements like "div", "ul" or "span", SVG elements like ""
912
+ */
913
+ c(this, "type");
914
+ /**
915
+ * Data that will be passed to a new MarkupNode instance when it is constructed.
916
+ * Includes a `children` prop if children were passed.
917
+ */
918
+ c(this, "props");
919
+ this.type = t, this.props = e;
920
+ }
921
+ }
922
+ function St(o) {
923
+ return (o == null ? void 0 : o[x]) === !0;
924
+ }
925
+ function O(o, t) {
926
+ return new rt(o, t ?? {});
927
+ }
928
+ function Et(o, t, e) {
929
+ return O("$dynamic", {
930
+ source: T(() => {
931
+ const s = w(o);
932
+ return s && t ? t : !s && e ? e : null;
933
+ })
934
+ });
935
+ }
936
+ function It(o, t, e) {
937
+ return Et(o, e, t);
938
+ }
939
+ function Pt(o, t, e) {
940
+ return O("$repeat", { items: () => w(o), key: t, render: e });
941
+ }
942
+ function Tt(o, t) {
943
+ return O("$portal", { parent: o, content: t });
944
+ }
945
+ function ct(o, t = new l("$")) {
946
+ const e = _(t, [o]);
947
+ return e.length === 1 ? e[0] : new C(t, () => e);
948
+ }
949
+ function _(o, ...t) {
950
+ const e = t.flat(1 / 0), s = [];
951
+ for (const i of e)
952
+ if (!(i == null || i === !1)) {
953
+ if (i instanceof Node) {
954
+ s.push(new E(i));
955
+ continue;
956
+ }
957
+ if (i instanceof rt)
958
+ if (f(i.type)) {
959
+ s.push(new it(o, i.type, i.props));
960
+ continue;
961
+ } else if (U(i.type))
962
+ switch (i.type) {
963
+ case "$dom": {
964
+ const n = i.props;
965
+ s.push(new E(n.value));
966
+ continue;
967
+ }
968
+ case "$text": {
969
+ const n = i.props;
970
+ s.push(new E(document.createTextNode(String(n.value))));
971
+ continue;
972
+ }
973
+ case "$repeat": {
974
+ const n = i.props;
975
+ s.push(new kt(o, n.items, n.key, n.render));
976
+ continue;
977
+ }
978
+ case "$dynamic": {
979
+ const n = i.props;
980
+ s.push(new C(o, n.source));
981
+ continue;
982
+ }
983
+ case "$portal": {
984
+ const n = i.props;
985
+ s.push(new xt(o, n.content, n.parent));
986
+ continue;
987
+ }
988
+ default:
989
+ s.push(new wt(o, i.type, i.props));
990
+ continue;
991
+ }
992
+ else
993
+ throw new TypeError(`Expected a string or view function. Got: ${i.type}`);
994
+ if (St(i)) {
995
+ s.push(i);
996
+ continue;
997
+ }
998
+ if (f(i)) {
999
+ s.push(new C(o, i));
1000
+ continue;
1001
+ }
1002
+ s.push(new E(document.createTextNode(String(i))));
1003
+ }
1004
+ return s;
1005
+ }
1006
+ export {
1007
+ l as C,
1008
+ C as D,
1009
+ rt as M,
1010
+ it as V,
1011
+ Pt as a,
1012
+ At as c,
1013
+ O as m,
1014
+ Tt as p,
1015
+ ct as r,
1016
+ It as u,
1017
+ Et as w
1018
+ };
1019
+ //# sourceMappingURL=markup-BBa4WBj1.js.map