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

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,29 +1,29 @@
1
- var Ft = Object.defineProperty;
2
- var et = (n) => {
1
+ var Ut = Object.defineProperty;
2
+ var ot = (n) => {
3
3
  throw TypeError(n);
4
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) {
5
+ var Lt = (n, t, e) => t in n ? Ut(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
+ var o = (n, t, e) => Lt(n, typeof t != "symbol" ? t + "" : t, e), ut = (n, t, e) => t.has(n) || ot("Cannot " + e);
7
+ var O = (n, t, e) => (ut(n, t, "read from private field"), e ? e.call(n) : t.get(n)), F = (n, t, e) => t.has(n) ? ot("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), P = (n, t, e, r) => (ut(n, t, "write to private field"), r ? r.call(n, e) : t.set(n, e), e);
8
+ function kt(n) {
9
9
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
10
10
  }
11
- var W = { exports: {} }, rt;
12
- function It() {
13
- return rt || (rt = 1, function(n, t) {
11
+ var T = { exports: {} }, ct;
12
+ function Rt() {
13
+ return ct || (ct = 1, function(n, t) {
14
14
  Object.defineProperty(t, "__esModule", { value: !0 });
15
15
  var e = /* @__PURE__ */ function() {
16
16
  function h(a, f) {
17
- var l = [], d = !0, p = !1, g = void 0;
17
+ var l = [], d = !0, p = !1, _ = void 0;
18
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;
19
+ for (var x, y = a[Symbol.iterator](); !(d = (x = y.next()).done) && (l.push(x.value), !(f && l.length === f)); d = !0) ;
20
+ } catch (g) {
21
+ p = !0, _ = g;
22
22
  } finally {
23
23
  try {
24
- !d && _.return && _.return();
24
+ !d && y.return && y.return();
25
25
  } finally {
26
- if (p) throw g;
26
+ if (p) throw _;
27
27
  }
28
28
  }
29
29
  return l;
@@ -38,29 +38,29 @@ function It() {
38
38
  return 16 > f ? a + "0" + f.toString(16) : a + f.toString(16);
39
39
  }, "#");
40
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, _];
41
+ var l = 0.5 > f ? f * (1 + a) : f + a - f * a, d = 2 * f - l, p = function(g, C, S) {
42
+ var D = Math.round, w = 0 > S ? S + 1 : 1 < S ? S - 1 : S;
43
+ return w = w < 1 / 6 ? g + 6 * (C - g) * w : w < 1 / 2 ? C : w < 2 / 3 ? g + 6 * (C - g) * (2 / 3 - w) : g, D(255 * w);
44
+ }, _ = p(d, l, h + 1 / 3), x = p(d, l, h), y = p(d, l, h - 1 / 3);
45
+ return [_, x, y];
46
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) {
47
+ var d = h % 1007 / 1007, p = function(g, C, S) {
48
+ return g * (S - C) + C;
49
+ }, _ = p(d, a.min, a.max), x = p(d, f.min, f.max), y = p(d, l.max, l.min);
50
+ return [_, x, y];
51
+ }, u = function(h) {
52
52
  return h.split("").reduce(function(a, f, l) {
53
53
  return a * f.charCodeAt(0) * l + 1;
54
54
  }, 1);
55
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;
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, _ = h.light, x = _ === void 0 ? { min: 0.3, max: 0.7 } : _, y = h.hashFunction, g = y === void 0 ? u : y, C = h.scheme, S = C === void 0 ? "hex" : C, D = i(g(a), l, p, x), w = e(D, 3), nt = w[0], rt = w[1], st = w[2], it = s(nt / 360, rt, st), jt = r(it);
57
+ return S === "hsl" ? [nt, rt, st] : S === "rgb" ? it : jt;
58
58
  };
59
59
  t.default = c, n.exports = t.default;
60
- }(W, W.exports)), W.exports;
60
+ }(T, T.exports)), T.exports;
61
61
  }
62
- var jt = It();
63
- const Lt = /* @__PURE__ */ _t(jt);
62
+ var Dt = Rt();
63
+ const zt = /* @__PURE__ */ kt(Dt);
64
64
  function N(n) {
65
65
  const t = typeof n;
66
66
  switch (t) {
@@ -76,63 +76,63 @@ function N(n) {
76
76
  return t;
77
77
  }
78
78
  }
79
- function pe(n, t) {
79
+ function xe(n, t) {
80
80
  if (!n)
81
81
  throw new TypeError(
82
- I(n, t || "Failed assertion. Value is not truthy. Got type: %t, value: %v")
82
+ R(n, t || "Failed assertion. Value is not truthy. Got type: %t, value: %v")
83
83
  );
84
84
  }
85
85
  function A(n) {
86
86
  return Array.isArray(n);
87
87
  }
88
- function vt(...n) {
88
+ function Mt(...n) {
89
89
  const t = n[0], e = (r) => A(r) && r.every((s) => t(s));
90
90
  return n.length < 2 ? e : e(n[1]);
91
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) => {
92
+ function ke(...n) {
93
+ const t = n[0], e = b(n[2]) ? n[2] : "Expected an array of valid items. Got type: %t, value: %v", r = (s) => {
94
94
  if (A(s) && s.every((i) => t(i)))
95
95
  return !0;
96
- throw new TypeError(I(s, e));
96
+ throw new TypeError(R(s, e));
97
97
  };
98
98
  return n.length < 2 ? r : r(n[1]);
99
99
  }
100
- function E(n) {
100
+ function b(n) {
101
101
  return typeof n == "string";
102
102
  }
103
- function ge(n, t) {
104
- if (E(n))
103
+ function Me(n, t) {
104
+ if (b(n))
105
105
  return !0;
106
- throw new TypeError(I(n, t ?? "Expected a string. Got type: %t, value: %v"));
106
+ throw new TypeError(R(n, t ?? "Expected a string. Got type: %t, value: %v"));
107
107
  }
108
- function q(n) {
109
- return typeof n == "function" && !Rt(n);
108
+ function I(n) {
109
+ return typeof n == "function" && !Kt(n);
110
110
  }
111
- function Ut(n) {
111
+ function Gt(n) {
112
112
  return typeof n == "number" && !isNaN(n);
113
113
  }
114
- function Rt(n) {
114
+ function Kt(n) {
115
115
  return typeof n == "function" && /^\s*class\s+/.test(n.toString());
116
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) => {
117
+ function be(...n) {
118
+ const t = n[0], e = b(n[2]) ? n[2] : `Expected instance of ${t.name}. Got type: %t, value: %v`, r = (s) => {
119
119
  if (s instanceof t)
120
120
  return !0;
121
- throw new TypeError(I(s, e));
121
+ throw new TypeError(R(s, e));
122
122
  };
123
123
  return n.length < 2 ? r : r(n[1]);
124
124
  }
125
- function St(n) {
125
+ function bt(n) {
126
126
  return n != null && typeof n == "object" && !A(n);
127
127
  }
128
- function I(n, t) {
128
+ function R(n, t) {
129
129
  var s;
130
130
  const e = N(n), r = ((s = n == null ? void 0 : n.toString) == null ? void 0 : s.call(n)) || String(n);
131
131
  return t.replaceAll("%t", e).replaceAll("%v", r);
132
132
  }
133
- var R, st;
134
- function zt() {
135
- return st || (st = 1, R = function n(t, e) {
133
+ var z, at;
134
+ function Bt() {
135
+ return at || (at = 1, z = function n(t, e) {
136
136
  if (t === e) return !0;
137
137
  if (t && e && typeof t == "object" && typeof e == "object") {
138
138
  if (t.constructor !== e.constructor) return !1;
@@ -170,26 +170,26 @@ function zt() {
170
170
  for (s = r; s-- !== 0; )
171
171
  if (!Object.prototype.hasOwnProperty.call(e, i[s])) return !1;
172
172
  for (s = r; s-- !== 0; ) {
173
- var o = i[s];
174
- if (!n(t[o], e[o])) return !1;
173
+ var u = i[s];
174
+ if (!n(t[u], e[u])) return !1;
175
175
  }
176
176
  return !0;
177
177
  }
178
178
  return t !== t && e !== e;
179
- }), R;
179
+ }), z;
180
180
  }
181
- var Gt = zt();
182
- const Dt = /* @__PURE__ */ _t(Gt), Kt = () => {
181
+ var Ht = Bt();
182
+ const Yt = /* @__PURE__ */ kt(Ht), Zt = () => {
183
183
  };
184
- let z = 1;
185
- function Ct() {
186
- return z = z % Number.MAX_SAFE_INTEGER + 1, z.toString(36) + Date.now().toString(36);
184
+ let G = 1;
185
+ function Y() {
186
+ return G = G % Number.MAX_SAFE_INTEGER + 1, G.toString(36) + Date.now().toString(36);
187
187
  }
188
- function Mt(n, t) {
189
- return n === t;
188
+ function Et(n, t) {
189
+ return Object.is(n, t);
190
190
  }
191
- function ye(n, t) {
192
- if (n === t) return !0;
191
+ function Ee(n, t) {
192
+ if (Object.is(n, t)) return !0;
193
193
  const e = N(n);
194
194
  if (e !== N(t))
195
195
  return !1;
@@ -212,7 +212,7 @@ function ye(n, t) {
212
212
  if (n[s] !== t[s]) return !1;
213
213
  return !0;
214
214
  case "set":
215
- if (q(n.symmetricDifference))
215
+ if (I(n.symmetricDifference))
216
216
  return n.symmetricDifference(t).size === 0;
217
217
  for (const s of n.keys())
218
218
  if (n[s] !== t.get(s)) return !1;
@@ -220,8 +220,8 @@ function ye(n, t) {
220
220
  }
221
221
  return !1;
222
222
  }
223
- const _e = Dt;
224
- function Bt(n, t) {
223
+ const Ae = Yt;
224
+ function Jt(n, t) {
225
225
  const e = (r) => {
226
226
  const s = {};
227
227
  for (const i in r)
@@ -230,14 +230,14 @@ function Bt(n, t) {
230
230
  };
231
231
  return t == null ? e : e(t);
232
232
  }
233
- function ve(n) {
234
- return Lt({
233
+ function Oe(n) {
234
+ return zt({
235
235
  str: n,
236
236
  sat: { min: 0.35, max: 0.55 },
237
237
  light: { min: 0.6, max: 0.6 }
238
238
  });
239
239
  }
240
- function Se(n) {
240
+ function Ne(n) {
241
241
  if (n instanceof RegExp)
242
242
  return (r) => n.test(r);
243
243
  const t = {
@@ -256,13 +256,13 @@ function Se(n) {
256
256
  }
257
257
  return function(r) {
258
258
  const { positive: s, negative: i } = t;
259
- return !(i.some((o) => o(r)) || s.length > 0 && !s.some((o) => o(r)));
259
+ return !(i.some((u) => u(r)) || s.length > 0 && !s.some((u) => u(r)));
260
260
  };
261
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 {
262
+ var Xt = Object.defineProperty, Qt = (n, t, e) => t in n ? Xt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, ht = (n, t, e) => Qt(n, typeof t != "symbol" ? t + "" : t, e);
263
+ class j {
264
264
  constructor() {
265
- it(this, "_l", /* @__PURE__ */ new Map()), it(this, "_a", (t) => {
265
+ ht(this, "_l", /* @__PURE__ */ new Map()), ht(this, "_a", (t) => {
266
266
  if (typeof t != "string" && !(t instanceof Symbol))
267
267
  throw new TypeError("Emitter: eventName should be a string or symbol");
268
268
  });
@@ -273,9 +273,9 @@ class kt {
273
273
  try {
274
274
  s(...e);
275
275
  } catch (i) {
276
- let o = this._l.get("error");
277
- if (o != null && o.length)
278
- for (const c of o)
276
+ let u = this._l.get("error");
277
+ if (u != null && u.length)
278
+ for (const c of u)
279
279
  c(i, t, s, ...e);
280
280
  else throw i;
281
281
  }
@@ -303,25 +303,25 @@ class kt {
303
303
  return [...this._l.entries()].filter(([, t]) => t.length).map(([t]) => t);
304
304
  }
305
305
  }
306
- var O, b;
307
- class Ce {
306
+ var V, E;
307
+ class Ve {
308
308
  constructor(t) {
309
309
  // #dolla;
310
- L(this, O);
311
- L(this, b);
312
- U(this, O, t.createLogger("Dolla.stats")), U(this, b, V());
310
+ F(this, V);
311
+ F(this, E);
312
+ P(this, V, t.createLogger("Dolla.stats")), P(this, E, W());
313
313
  let e;
314
- $(this, b).emitter.on("statsChanged", () => {
314
+ O(this, E).emitter.on("statsChanged", () => {
315
315
  e && clearTimeout(e), e = setTimeout(() => {
316
- $(this, O).info($(this, b).stats);
316
+ O(this, V).info(O(this, E).stats);
317
317
  }, 200);
318
318
  });
319
319
  }
320
320
  }
321
- O = new WeakMap(), b = new WeakMap();
322
- const G = "__DOLLA_STATS_STORE__";
323
- function ot() {
324
- const n = new kt(), t = {
321
+ V = new WeakMap(), E = new WeakMap();
322
+ const K = Symbol.for("DollaStatsStore");
323
+ function lt() {
324
+ const n = new j(), t = {
325
325
  watcherCount: 0,
326
326
  viewCount: 0
327
327
  };
@@ -331,43 +331,43 @@ function ot() {
331
331
  t.watcherCount += e, n.emit("statsChanged");
332
332
  }), { emitter: n, stats: t };
333
333
  }
334
- function V() {
335
- return typeof window < "u" ? (window[G] || (window[G] = ot()), window[G]) : ot();
334
+ function W() {
335
+ return typeof window < "u" ? (window[K] || (window[K] = lt()), window[K]) : lt();
336
336
  }
337
- function xt() {
338
- V().emitter.emit("_incrementWatcherCount", 1);
337
+ function At() {
338
+ W().emitter.emit("_incrementWatcherCount", 1);
339
339
  }
340
- function Et() {
341
- V().emitter.emit("_incrementWatcherCount", -1);
340
+ function Ot() {
341
+ W().emitter.emit("_incrementWatcherCount", -1);
342
342
  }
343
- function Yt() {
344
- V().emitter.emit("_incrementViewCount", 1);
343
+ function te() {
344
+ W().emitter.emit("_incrementViewCount", 1);
345
345
  }
346
- function Xt() {
347
- V().emitter.emit("_incrementViewCount", -1);
346
+ function ee() {
347
+ W().emitter.emit("_incrementViewCount", -1);
348
348
  }
349
- const bt = Symbol.for("DollaState"), At = Symbol.for("DollaRef"), Nt = Symbol.for("DollaMarkup"), k = Symbol.for("DollaMarkupElement");
349
+ const Nt = Symbol.for("DollaState"), Vt = Symbol.for("DollaRef"), $t = Symbol.for("DollaMarkup"), k = Symbol.for("DollaMarkupElement"), ne = Symbol.for("DollaStore"), Wt = Symbol.for("DollaStoreFactory");
350
350
  function m(n) {
351
- return (n == null ? void 0 : n[bt]) === !0;
351
+ return (n == null ? void 0 : n[Nt]) === !0;
352
352
  }
353
- function Jt(n) {
353
+ function re(n) {
354
354
  return m(n) ? n.get() : n;
355
355
  }
356
- function K(n) {
357
- return m(n) ? n : new B({
356
+ function Z(n) {
357
+ return m(n) ? n : new J({
358
358
  get() {
359
359
  return n;
360
360
  },
361
361
  watch(t, e = {}) {
362
- return e != null && e.lazy || t(n), Kt;
362
+ return e != null && e.lazy || t(n), Zt;
363
363
  }
364
364
  });
365
365
  }
366
- class Qt {
366
+ class se {
367
367
  constructor(t, e) {
368
- u(this, "value");
369
- u(this, "watchers", []);
370
- u(this, "equals", Mt);
368
+ o(this, "value");
369
+ o(this, "watchers", []);
370
+ o(this, "equals", Et);
371
371
  this.value = t, e != null && e.equals && (this.equals = e.equals);
372
372
  }
373
373
  get() {
@@ -385,18 +385,18 @@ class Qt {
385
385
  }
386
386
  }
387
387
  watch(t, e) {
388
- return this.watchers.push(t), e != null && e.lazy || t(this.value), xt(), () => {
388
+ return this.watchers.push(t), e != null && e.lazy || t(this.value), At(), () => {
389
389
  const r = this.watchers.indexOf(t);
390
- r > -1 && this.watchers.splice(r, 1), Et();
390
+ r > -1 && this.watchers.splice(r, 1), Ot();
391
391
  };
392
392
  }
393
393
  }
394
- var ht;
395
- ht = bt;
396
- class B {
394
+ var mt;
395
+ mt = Nt;
396
+ class J {
397
397
  constructor(t) {
398
- u(this, ht, !0);
399
- u(this, "__value");
398
+ o(this, mt, !0);
399
+ o(this, "__value");
400
400
  this.__value = t;
401
401
  }
402
402
  get() {
@@ -406,51 +406,51 @@ class B {
406
406
  return this.__value.watch(t, e);
407
407
  }
408
408
  }
409
- function D(n, t) {
410
- const e = new Qt(n, t);
411
- return [new B(e), (s) => e.set(s)];
409
+ function H(n, t) {
410
+ const e = new se(n, t);
411
+ return [new J(e), (s) => e.set(s)];
412
412
  }
413
- const ut = Symbol("EMPTY");
414
- class te {
413
+ const ft = Symbol("EMPTY");
414
+ class ie {
415
415
  constructor(t, e, r) {
416
- u(this, "equals", Mt);
416
+ o(this, "equals", Et);
417
417
  /**
418
418
  * Array of states this holder's value is derived from.
419
419
  */
420
- u(this, "sources", []);
420
+ o(this, "sources", []);
421
421
  /**
422
422
  * The function that does the deriving. Receives source values and returns a derived value.
423
423
  */
424
- u(this, "fn");
424
+ o(this, "fn");
425
425
  /**
426
426
  *
427
427
  */
428
- u(this, "sourceWatcher", H());
428
+ o(this, "sourceWatcher", X());
429
429
  /**
430
430
  * Array of functions awaiting notification when this holder's value changes.
431
431
  */
432
- u(this, "watchers", []);
432
+ o(this, "watchers", []);
433
433
  /**
434
434
  * True when this holder is actively watching sources.
435
435
  */
436
- u(this, "isWatchingSources", !1);
436
+ o(this, "isWatchingSources", !1);
437
437
  /**
438
438
  * Latest values as received from sources.
439
439
  */
440
- u(this, "previousSourceValues");
440
+ o(this, "previousSourceValues");
441
441
  /**
442
442
  * The current value as returned from `fn` (may be a State)
443
443
  */
444
- u(this, "value", ut);
444
+ o(this, "value", ft);
445
445
  /**
446
446
  * The current unwrapped value.
447
447
  */
448
- u(this, "rawValue");
448
+ o(this, "rawValue");
449
449
  /**
450
450
  * When value is a State, this function will stop watching its value.
451
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);
452
+ o(this, "stopWatchingCurrentValue");
453
+ this.sources = t.map(Z), this.fn = e, r != null && r.equals && (this.equals = r.equals), this.previousSourceValues = new Array(t.length).fill(ft, 0, t.length);
454
454
  }
455
455
  /*==========================*\
456
456
  || "Public" methods ||
@@ -461,8 +461,8 @@ class te {
461
461
  watch(t, e) {
462
462
  this.isWatchingSources || this.startWatchingSources();
463
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();
464
+ return r.push(t), e != null && e.lazy || t(this.rawValue), At(), () => {
465
+ r.splice(r.indexOf(t), 1), this.isWatchingSources && r.length === 0 && this.stopWatchingSources(), Ot();
466
466
  };
467
467
  }
468
468
  /*==========================*\
@@ -483,7 +483,7 @@ class te {
483
483
  return this.isWatchingSources || this.update(), this.rawValue;
484
484
  }
485
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) => {
486
+ this.stopWatchingCurrentValue && (this.stopWatchingCurrentValue(), this.stopWatchingCurrentValue = void 0), this.value = t, this.rawValue = re(t), this.isWatchingSources && m(t) ? this.stopWatchingCurrentValue = t.watch((e) => {
487
487
  this.rawValue = e, this.notify(e);
488
488
  }) : this.notify(this.rawValue);
489
489
  }
@@ -504,19 +504,19 @@ class te {
504
504
  this.sourceWatcher.stopAll(), this.stopWatchingCurrentValue && (this.stopWatchingCurrentValue(), this.stopWatchingCurrentValue = void 0), this.isWatchingSources = !1;
505
505
  }
506
506
  }
507
- function ee(n, t, e) {
508
- const r = new te(n, t, e);
509
- return new B(r);
507
+ function oe(n, t, e) {
508
+ const r = new ie(n, t, e);
509
+ return new J(r);
510
510
  }
511
- function H() {
511
+ function X() {
512
512
  const n = [];
513
513
  return {
514
514
  watch(t, e) {
515
515
  if (t.length === 0)
516
516
  throw new TypeError("Expected at least one state to watch.");
517
- t = t.map(K);
517
+ t = t.map(Z);
518
518
  let r;
519
- return t.length > 1 ? r = ee(t, e).watch(() => null) : r = t[0].watch(e), n.push(r), () => {
519
+ return t.length > 1 ? r = oe(t, e).watch(() => null) : r = t[0].watch(e), n.push(r), () => {
520
520
  let s = n.indexOf(r);
521
521
  s > -1 && n.splice(s, 1), r();
522
522
  };
@@ -527,35 +527,148 @@ function H() {
527
527
  }
528
528
  };
529
529
  }
530
- function Me(n) {
531
- const t = function() {
530
+ function $e(n) {
531
+ function t() {
532
532
  if (arguments.length === 1)
533
533
  n = arguments[0];
534
534
  else if (arguments.length > 1)
535
535
  throw new Error(`Too many arguments. Expected 0 or 1. Got: ${arguments.length}`);
536
536
  return n;
537
- };
538
- return t[At] = !0, t;
537
+ }
538
+ return t[Vt] = !0, t;
539
539
  }
540
- function ne(n) {
541
- return (n == null ? void 0 : n[At]) === !0;
540
+ function ue(n) {
541
+ return (n == null ? void 0 : n[Vt]) === !0;
542
542
  }
543
- function re(n) {
544
- for (var t, e, r = arguments, s = 1, i = "", o = "", c = [0], h = function(l) {
543
+ var $;
544
+ class Q {
545
+ constructor(t, e) {
546
+ o(this, "type");
547
+ o(this, "detail");
548
+ F(this, $, !1);
549
+ this.type = t, this.detail = e;
550
+ }
551
+ get propagationStopped() {
552
+ return O(this, $);
553
+ }
554
+ stopPropagation() {
555
+ P(this, $, !0);
556
+ }
557
+ get [Symbol.toStringTag]() {
558
+ return "ContextEvent";
559
+ }
560
+ // stopImmediatePropagation() {}
561
+ }
562
+ $ = new WeakMap();
563
+ let ce = class {
564
+ constructor(t) {
565
+ o(this, "__store");
566
+ this.__store = t;
567
+ const e = Object.getOwnPropertyDescriptors(this.__store._logger);
568
+ for (const r in e)
569
+ r !== "setName" && Object.defineProperty(this, r, e[r]);
570
+ }
571
+ setName(t) {
572
+ return this.__store._logger.setName(t), this;
573
+ }
574
+ set(t, e) {
575
+ return this.__store._elementContext.data[t] = e, e;
576
+ }
577
+ get(t) {
578
+ let e = this.__store._elementContext;
579
+ for (; ; ) {
580
+ if (t in e.data)
581
+ return e.data[t];
582
+ if (e.parent)
583
+ e = e.parent;
584
+ else
585
+ break;
586
+ }
587
+ return null;
588
+ }
589
+ on(t, e) {
590
+ this.__store._elementContext.emitter.on(t, e);
591
+ }
592
+ off(t, e) {
593
+ this.__store._elementContext.emitter.off(t, e);
594
+ }
595
+ once(t, e) {
596
+ this.__store._elementContext.emitter.once(t, e);
597
+ }
598
+ emit(t, e) {
599
+ return this.__store._elementContext.emitter.emit(t, new Q(t, e));
600
+ }
601
+ onMount(t) {
602
+ this.__store._emitter.on("mounted", t);
603
+ }
604
+ onUnmount(t) {
605
+ this.__store._emitter.on("unmounted", t);
606
+ }
607
+ };
608
+ class ae {
609
+ constructor(t, e, r) {
610
+ o(this, "key");
611
+ o(this, "_fn");
612
+ o(this, "_options");
613
+ /**
614
+ * Value is guaranteed to be set after `attach` is called.
615
+ */
616
+ o(this, "value");
617
+ o(this, "_elementContext");
618
+ o(this, "_emitter", new j());
619
+ o(this, "_logger");
620
+ this.key = t, this._fn = e, this._options = r;
621
+ }
622
+ attach(t) {
623
+ this._elementContext = t, this._logger = t.root.createLogger(this._fn.name), this._emitter.on("error", (r, s, ...i) => {
624
+ console.log({ error: r, eventName: s, args: i }), this._logger.crash(r);
625
+ });
626
+ const e = new ce(this);
627
+ try {
628
+ this.value = this._fn.call(e, this._options, e);
629
+ } catch (r) {
630
+ this._logger.crash(r);
631
+ }
632
+ t.stores.set(this.key, this);
633
+ }
634
+ handleMount() {
635
+ this._emitter.emit("mounted");
636
+ }
637
+ handleUnmount() {
638
+ this._emitter.emit("unmounted"), this._emitter.clear();
639
+ }
640
+ }
641
+ function he(n) {
642
+ return (n == null ? void 0 : n[Wt]) === !0;
643
+ }
644
+ function le(n) {
645
+ return (n == null ? void 0 : n[ne]) === !0;
646
+ }
647
+ function Fe(n) {
648
+ const t = Y();
649
+ function e(r) {
650
+ return new ae(t, n, r);
651
+ }
652
+ return e[Wt] = !0, e.key = t, e;
653
+ }
654
+ class B extends Error {
655
+ }
656
+ function fe(n) {
657
+ for (var t, e, r = arguments, s = 1, i = "", u = "", c = [0], h = function(l) {
545
658
  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
659
  }, a = 0; a < n.length; a++) {
547
660
  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 === `
661
+ 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] : u ? t === u ? u = "" : i += t : t === '"' || t === "'" ? u = 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
662
  ` || t === "\r" ? (h(), s = 2) : i += t), s === 3 && i === "!--" && (s = 4, c = c[0]);
550
663
  }
551
664
  return h(), c.length > 2 ? c.slice(1) : c[1];
552
665
  }
553
- var lt;
554
- lt = k;
555
- class ct {
666
+ var _t;
667
+ _t = k;
668
+ class dt {
556
669
  constructor(t) {
557
- u(this, lt, !0);
558
- u(this, "node");
670
+ o(this, _t, !0);
671
+ o(this, "node");
559
672
  this.node = t;
560
673
  }
561
674
  get isMounted() {
@@ -568,33 +681,33 @@ class ct {
568
681
  this.node.parentNode && !t && this.node.parentNode.removeChild(this.node);
569
682
  }
570
683
  }
571
- const se = (n) => /^on[A-Z]/.test(n);
572
- var ft;
573
- ft = k;
574
- class ie {
684
+ const de = (n) => /^on[A-Z]/.test(n);
685
+ var gt;
686
+ gt = k;
687
+ class pe {
575
688
  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");
689
+ o(this, gt, !0);
690
+ o(this, "node");
691
+ o(this, "props");
692
+ o(this, "childMarkup", []);
693
+ o(this, "children", []);
694
+ o(this, "stopCallbacks", []);
695
+ o(this, "elementContext");
696
+ o(this, "uniqueId", Y());
697
+ o(this, "_batchWrite");
585
698
  // Track the ref so we can nullify it on unmount.
586
- u(this, "ref");
699
+ o(this, "ref");
587
700
  // Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
588
- u(this, "canClickAway", !1);
701
+ o(this, "canClickAway", !1);
589
702
  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))
703
+ if (ue(e.ref))
591
704
  this.ref = e.ref, this.ref(this.node);
592
705
  else
593
706
  throw new Error("Expected ref to be a function. Got: " + e.ref);
594
707
  this.props = {
595
- ...Bt(["ref", "class", "className"], e),
708
+ ...Jt(["ref", "class", "className"], e),
596
709
  class: e.className ?? e.class
597
- }, r && (this.childMarkup = r), this.elementContext = s, this.children = x(this.elementContext, this.childMarkup);
710
+ }, r && (this.childMarkup = r), this.elementContext = s, this.children = M(this.elementContext, this.childMarkup);
598
711
  }
599
712
  get isMounted() {
600
713
  return this.node.parentNode != null;
@@ -642,33 +755,33 @@ class ie {
642
755
  const s = e[r];
643
756
  if (r === "attributes") {
644
757
  const i = s;
645
- for (const o in i)
758
+ for (const u in i)
646
759
  this.attachProp(
647
- i[o],
760
+ i[u],
648
761
  (c) => {
649
- c == null ? t.removeAttribute(o) : t.setAttribute(o, String(c));
762
+ c == null ? t.removeAttribute(u) : t.setAttribute(u, String(c));
650
763
  },
651
- this.getUpdateKey("attr", o)
764
+ this.getUpdateKey("attr", u)
652
765
  );
653
766
  } else if (r === "eventListeners") {
654
767
  const i = s;
655
- for (const o in i) {
768
+ for (const u in i) {
656
769
  const c = m(s) ? (h) => s.get()(h) : s;
657
- t.addEventListener(o, c), this.stopCallbacks.push(() => {
658
- t.removeEventListener(o, c);
770
+ t.addEventListener(u, c), this.stopCallbacks.push(() => {
771
+ t.removeEventListener(u, c);
659
772
  });
660
773
  }
661
774
  } else if (r === "onClickOutside" || r === "onclickoutside") {
662
775
  const i = (c) => {
663
776
  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);
777
+ }, u = { capture: !0 };
778
+ window.addEventListener("click", i, u), this.stopCallbacks.push(() => {
779
+ window.removeEventListener("click", i, u);
667
780
  });
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);
781
+ } else if (de(r)) {
782
+ const i = r.slice(2).toLowerCase(), u = m(s) ? (c) => s.get()(c) : s;
783
+ t.addEventListener(i, u), this.stopCallbacks.push(() => {
784
+ t.removeEventListener(i, u);
672
785
  });
673
786
  } else if (r.includes("-"))
674
787
  this.attachProp(
@@ -678,7 +791,7 @@ class ie {
678
791
  },
679
792
  this.getUpdateKey("attr", r)
680
793
  );
681
- else if (!oe.includes(r))
794
+ else if (!me.includes(r))
682
795
  if (this.elementContext.isSVG)
683
796
  this.attachProp(
684
797
  s,
@@ -726,8 +839,8 @@ class ie {
726
839
  const i = r.toLowerCase();
727
840
  this.attachProp(
728
841
  s,
729
- (o) => {
730
- o == null ? t.removeAttribute(i) : t.setAttribute(i, String(o));
842
+ (u) => {
843
+ u == null ? t.removeAttribute(i) : t.setAttribute(i, String(u));
731
844
  },
732
845
  this.getUpdateKey("attr", i)
733
846
  );
@@ -760,112 +873,112 @@ class ie {
760
873
  const s = [];
761
874
  if (m(e)) {
762
875
  let i;
763
- const o = e.watch((c) => {
876
+ const u = e.watch((c) => {
764
877
  this._mutate(
765
878
  () => {
766
- q(i) && i(), t.style.cssText = "", i = this.applyStyles(t, c, r);
879
+ I(i) && i(), t.style.cssText = "", i = this.applyStyles(t, c, r);
767
880
  },
768
881
  this.getUpdateKey("styles", "*")
769
882
  );
770
883
  });
771
- r.push(o), s.push(o);
884
+ r.push(u), s.push(u);
772
885
  } else {
773
- const i = Vt(e);
774
- for (const o in i) {
775
- const { value: c, priority: h } = i[o];
886
+ const i = Pt(e);
887
+ for (const u in i) {
888
+ const { value: c, priority: h } = i[u];
776
889
  if (m(c)) {
777
890
  const a = c.watch((f) => {
778
891
  this._mutate(() => {
779
- f ? t.style.setProperty(o, String(f), h) : t.style.removeProperty(o);
892
+ f ? t.style.setProperty(u, String(f), h) : t.style.removeProperty(u);
780
893
  });
781
894
  });
782
895
  r.push(a), s.push(a);
783
- } else c != null && t.style.setProperty(o, String(c));
896
+ } else c != null && t.style.setProperty(u, String(c));
784
897
  }
785
898
  }
786
899
  return function() {
787
- for (const o of s)
788
- o(), r.splice(r.indexOf(o), 1);
900
+ for (const u of s)
901
+ u(), r.splice(r.indexOf(u), 1);
789
902
  };
790
903
  }
791
904
  applyClasses(t, e, r) {
792
905
  const s = [];
793
906
  if (m(e)) {
794
907
  let i;
795
- const o = e.watch((c) => {
908
+ const u = e.watch((c) => {
796
909
  this._mutate(
797
910
  () => {
798
- q(i) && i(), t.removeAttribute("class"), i = this.applyClasses(t, c, r);
911
+ I(i) && i(), t.removeAttribute("class"), i = this.applyClasses(t, c, r);
799
912
  },
800
913
  this.getUpdateKey("attr", "class")
801
914
  );
802
915
  });
803
- r.push(o), s.push(o);
916
+ r.push(u), s.push(u);
804
917
  } else {
805
- const i = Ot(e);
806
- for (const o in i) {
807
- const c = i[o];
918
+ const i = Ft(e);
919
+ for (const u in i) {
920
+ const c = i[u];
808
921
  if (m(c)) {
809
922
  const h = c.watch((a) => {
810
923
  this._mutate(() => {
811
- a ? t.classList.add(o) : t.classList.remove(o);
924
+ a ? t.classList.add(u) : t.classList.remove(u);
812
925
  });
813
926
  });
814
927
  r.push(h), s.push(h);
815
- } else c && t.classList.add(o);
928
+ } else c && t.classList.add(u);
816
929
  }
817
930
  }
818
931
  return function() {
819
- for (const o of s)
820
- o(), r.splice(r.indexOf(o), 1);
932
+ for (const u of s)
933
+ u(), r.splice(r.indexOf(u), 1);
821
934
  };
822
935
  }
823
936
  }
824
- function Ot(n) {
937
+ function Ft(n) {
825
938
  let t = {};
826
- if (E(n)) {
939
+ if (b(n)) {
827
940
  const e = n.split(" ");
828
941
  for (const r of e)
829
942
  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));
943
+ } else bt(n) ? Object.assign(t, n) : Array.isArray(n) && Array.from(n).filter(Boolean).forEach((e) => {
944
+ Object.assign(t, Ft(e));
832
945
  });
833
946
  return delete t.undefined, t;
834
947
  }
835
- function Vt(n) {
948
+ function Pt(n) {
836
949
  let t = {};
837
- if (E(n)) {
950
+ if (b(n)) {
838
951
  const e = n.split(";").filter((r) => r.trim() !== "");
839
952
  for (const r of e) {
840
- const [s, i] = r.split(":"), o = {
953
+ const [s, i] = r.split(":"), u = {
841
954
  value: i
842
955
  };
843
- i.includes("!important") ? (o.priority = "important", o.value = i.replace("!important", "").trim()) : o.value = i.trim(), t[at(s.trim())] = o;
956
+ i.includes("!important") ? (u.priority = "important", u.value = i.replace("!important", "").trim()) : u.value = i.trim(), t[pt(s.trim())] = u;
844
957
  }
845
958
  }
846
- if (St(n))
959
+ if (bt(n))
847
960
  for (const e in n)
848
- e.startsWith("--") ? t[e] = { value: n[e] } : t[at(e)] = { value: n[e] };
961
+ e.startsWith("--") ? t[e] = { value: n[e] } : t[pt(e)] = { value: n[e] };
849
962
  else Array.isArray(n) && Array.from(n).filter((e) => e != null).forEach((e) => {
850
- Object.assign(t, Vt(e));
963
+ Object.assign(t, Pt(e));
851
964
  });
852
965
  return t;
853
966
  }
854
- function at(n) {
967
+ function pt(n) {
855
968
  return n.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, e) => (e ? "-" : "") + t.toLowerCase());
856
969
  }
857
- const oe = ["ref", "children", "class", "style", "data"];
858
- var dt;
859
- dt = k;
860
- class ue {
970
+ const me = ["ref", "children", "class", "style", "data"];
971
+ var wt;
972
+ wt = k;
973
+ class _e {
861
974
  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");
975
+ o(this, wt, !0);
976
+ o(this, "node", document.createTextNode(""));
977
+ o(this, "children", []);
978
+ o(this, "renderFn");
979
+ o(this, "elementContext");
980
+ o(this, "watcher", X());
981
+ o(this, "sources");
869
982
  this.sources = t, this.renderFn = e, this.elementContext = r;
870
983
  }
871
984
  get isMounted() {
@@ -874,7 +987,7 @@ class ue {
874
987
  mount(t, e) {
875
988
  this.isMounted || (t.insertBefore(this.node, (e == null ? void 0 : e.nextSibling) ?? null), this.watcher.watch(this.sources, (...r) => {
876
989
  const s = this.renderFn(...r);
877
- if (!Tt(s))
990
+ if (!It(s))
878
991
  throw console.error(s, r), new TypeError(
879
992
  `Observer received invalid value to render. Got type: ${N(s)}, value: ${s}`
880
993
  );
@@ -891,28 +1004,28 @@ class ue {
891
1004
  this.children = [];
892
1005
  }
893
1006
  update(t) {
894
- var i, o, c;
1007
+ var i, u, c;
895
1008
  if (this.cleanup(!1), t == null || t.length === 0 || !this.isMounted)
896
1009
  return;
897
- const e = t.flatMap((h) => Wt(h) ? h : x(this.elementContext, Z(h)));
1010
+ const e = t.flatMap((h) => qt(h) ? h : M(this.elementContext, tt(h)));
898
1011
  for (const h of e) {
899
1012
  const a = ((i = this.children.at(-1)) == null ? void 0 : i.node) || this.node;
900
1013
  h.mount(this.node.parentNode, a), this.children.push(h);
901
1014
  }
902
- const r = this.node.parentNode, s = ((c = (o = this.children.at(-1)) == null ? void 0 : o.node) == null ? void 0 : c.nextSibling) ?? null;
1015
+ const r = this.node.parentNode, s = ((c = (u = this.children.at(-1)) == null ? void 0 : u.node) == null ? void 0 : c.nextSibling) ?? null;
903
1016
  r.insertBefore(this.node, s);
904
1017
  }
905
1018
  }
906
- var pt;
907
- pt = k;
908
- class $t {
1019
+ var yt;
1020
+ yt = k;
1021
+ class Tt {
909
1022
  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");
1023
+ o(this, yt, !0);
1024
+ o(this, "node", document.createTextNode(""));
1025
+ o(this, "isMounted", !1);
1026
+ o(this, "source");
1027
+ o(this, "elements", []);
1028
+ o(this, "stopCallback");
916
1029
  this.source = t;
917
1030
  }
918
1031
  mount(t, e) {
@@ -932,20 +1045,20 @@ class $t {
932
1045
  var e, r;
933
1046
  if (this.cleanup(!1), t.length > 0) {
934
1047
  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);
1048
+ const i = t[s], u = s > 0 ? this.elements[s - 1] : void 0;
1049
+ i.mount(this.node.parentElement, u == null ? void 0 : u.node), this.elements.push(i);
937
1050
  }
938
1051
  (r = this.node.parentNode) == null || r.insertBefore(this.node, ((e = this.elements.at(-1)) == null ? void 0 : e.node) ?? null);
939
1052
  }
940
1053
  }
941
1054
  }
942
- var mt;
943
- mt = k;
944
- class ce {
1055
+ var St;
1056
+ St = k;
1057
+ class ge {
945
1058
  constructor(t) {
946
- u(this, mt, !0);
947
- u(this, "config");
948
- u(this, "element");
1059
+ o(this, St, !0);
1060
+ o(this, "config");
1061
+ o(this, "element");
949
1062
  this.config = t;
950
1063
  }
951
1064
  get isMounted() {
@@ -953,20 +1066,23 @@ class ce {
953
1066
  }
954
1067
  mount(t, e) {
955
1068
  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);
1069
+ qt(r) ? this.element = r : this.element = q(M(this.config.elementContext, tt(r))), this.element.mount(s);
957
1070
  }
958
1071
  unmount(t = !1) {
959
1072
  var e;
960
1073
  (e = this.element) != null && e.isMounted && this.element.unmount(t);
961
1074
  }
962
1075
  }
963
- class ae {
1076
+ function Pe(n) {
1077
+ return n;
1078
+ }
1079
+ class we {
964
1080
  constructor(t) {
965
- u(this, "__view");
1081
+ o(this, "__view");
966
1082
  this.__view = t;
967
1083
  const e = Object.getOwnPropertyDescriptors(this.__view._logger);
968
1084
  for (const r in e)
969
- r !== "getName" && Object.defineProperty(this, r, e[r]);
1085
+ r !== "setName" && Object.defineProperty(this, r, e[r]);
970
1086
  }
971
1087
  get uid() {
972
1088
  return this.__view.uniqueId;
@@ -989,15 +1105,37 @@ class ae {
989
1105
  }
990
1106
  return null;
991
1107
  }
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;
1108
+ on(t, e) {
1109
+ this.__view._elementContext.emitter.on(t, e);
1110
+ }
1111
+ off(t, e) {
1112
+ this.__view._elementContext.emitter.off(t, e);
1113
+ }
1114
+ once(t, e) {
1115
+ this.__view._elementContext.emitter.once(t, e);
1116
+ }
1117
+ emit(t, e) {
1118
+ return this.__view._elementContext.emitter.emit(t, new Q(t, e));
1119
+ }
1120
+ attachStore(t) {
1121
+ t.attach(this.__view._elementContext), this.__view._emitter.on("mounted", () => {
1122
+ t.handleMount();
1123
+ }), this.__view._emitter.on("unmounted", () => {
1124
+ t.handleUnmount();
1125
+ });
1126
+ }
1127
+ useStore(t) {
1128
+ if (he(t)) {
1129
+ const e = t.key;
1130
+ let r = this.__view._elementContext, s;
1131
+ for (; s = r.stores.get(e), s == null && r.parent != null; )
1132
+ r = r.parent;
1133
+ if (s == null)
1134
+ throw new B("Store not found on this context.");
1135
+ return s.value;
1136
+ } else throw le(t) ? new B(
1137
+ "Received a Store instance. Please pass the Store factory function to useStore without calling it."
1138
+ ) : new B("Invalid store.");
1001
1139
  }
1002
1140
  beforeMount(t) {
1003
1141
  this.__view._emitter.on("beforeMount", t);
@@ -1025,27 +1163,39 @@ class ae {
1025
1163
  }
1026
1164
  }
1027
1165
  outlet() {
1028
- return S("$outlet", { $children: this.__view._$children });
1166
+ return v("$outlet", { $children: this.__view._$children });
1029
1167
  }
1030
1168
  }
1031
- var gt;
1032
- gt = k;
1033
- const Y = class Y {
1169
+ var vt;
1170
+ vt = k;
1171
+ const et = class et {
1034
1172
  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([]);
1173
+ o(this, vt, !0);
1174
+ o(this, "uniqueId", Y());
1175
+ o(this, "_elementContext");
1176
+ o(this, "_logger");
1177
+ o(this, "_view");
1178
+ o(this, "_props");
1179
+ o(this, "_element");
1180
+ o(this, "_childMarkup");
1181
+ o(this, "_$children");
1182
+ o(this, "_setChildren");
1183
+ o(this, "_watcher", X());
1184
+ o(this, "_emitter", new j());
1185
+ o(this, "isMounted", !1);
1186
+ this._elementContext = {
1187
+ ...t,
1188
+ data: {},
1189
+ parent: t,
1190
+ viewName: e.name,
1191
+ emitter: new j(),
1192
+ stores: /* @__PURE__ */ new Map()
1193
+ }, this._logger = t.root.createLogger(e.name, { uid: this.uniqueId }), this._view = e, this._props = r, this._childMarkup = s, [this._$children, this._setChildren] = H([]), this._emitter.on("error", (i, u, ...c) => {
1194
+ this._logger.error({ error: i, eventName: u, args: c }), this._logger.crash(i);
1195
+ }), this._elementContext.emitter.on("*", (i, u) => {
1196
+ var c;
1197
+ u instanceof Q && (u.propagationStopped || (c = this._elementContext.parent) == null || c.emitter.emit(i, u));
1198
+ });
1049
1199
  }
1050
1200
  /*===============================*\
1051
1201
  || "Public" API ||
@@ -1056,36 +1206,36 @@ const Y = class Y {
1056
1206
  }
1057
1207
  mount(t, e) {
1058
1208
  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(() => {
1209
+ r || (this._initialize(), this._emitter.emit("beforeMount")), this._element && this._element.mount(t, e), r || (this.isMounted = !0, te(), requestAnimationFrame(() => {
1060
1210
  this._emitter.emit("mounted");
1061
1211
  }));
1062
1212
  }
1063
1213
  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();
1214
+ this._emitter.emit("beforeUnmount"), this._element && this._element.unmount(t), this.isMounted && ee(), this.isMounted = !1, this._emitter.emit("unmounted"), this._emitter.clear(), this._watcher.stopAll();
1065
1215
  }
1066
1216
  setChildView(t) {
1067
1217
  this._childMarkup = [];
1068
- const e = new Y(this._elementContext, t, {});
1218
+ const e = new et(this._elementContext, t, {});
1069
1219
  return this._setChildren([e]), e;
1070
1220
  }
1071
1221
  /*===============================*\
1072
1222
  || Internal ||
1073
1223
  \*===============================*/
1074
1224
  _initialize() {
1075
- const t = new ae(this);
1225
+ const t = new we(this);
1076
1226
  let e;
1077
1227
  try {
1078
- this._childMarkup.length && this._setChildren(x(this._elementContext, this._childMarkup)), e = this._view(this._props, t);
1228
+ this._childMarkup.length && this._setChildren(M(this._elementContext, this._childMarkup)), e = this._view.call(t, this._props, t);
1079
1229
  } catch (r) {
1080
1230
  throw r instanceof Error && this._logger.crash(r), r;
1081
1231
  }
1082
1232
  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));
1233
+ this._element = q(M(this._elementContext, v("$node", { value: e })));
1234
+ else if (L(e) || Mt(L, e))
1235
+ this._element = q(M(this._elementContext, e));
1086
1236
  else if (m(e))
1087
- this._element = T(
1088
- x(this._elementContext, S("$observer", { sources: [e], renderFn: (r) => r }))
1237
+ this._element = q(
1238
+ M(this._elementContext, v("$observer", { sources: [e], renderFn: (r) => r }))
1089
1239
  );
1090
1240
  else {
1091
1241
  const r = new TypeError(
@@ -1095,19 +1245,19 @@ const Y = class Y {
1095
1245
  }
1096
1246
  }
1097
1247
  };
1098
- let F = Y;
1099
- var wt;
1100
- wt = k;
1101
- class he {
1248
+ let U = et;
1249
+ var Ct;
1250
+ Ct = k;
1251
+ class ye {
1102
1252
  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");
1253
+ o(this, Ct, !0);
1254
+ o(this, "node", document.createTextNode(""));
1255
+ o(this, "$items");
1256
+ o(this, "stopCallback");
1257
+ o(this, "connectedItems", []);
1258
+ o(this, "elementContext");
1259
+ o(this, "renderFn");
1260
+ o(this, "keyFn");
1111
1261
  this.elementContext = t, this.$items = e, this.renderFn = r, this.keyFn = s;
1112
1262
  }
1113
1263
  get isMounted() {
@@ -1130,7 +1280,7 @@ class he {
1130
1280
  this.connectedItems = [];
1131
1281
  }
1132
1282
  _update(t) {
1133
- var o, c, h;
1283
+ var u, c, h;
1134
1284
  if (t.length === 0 || !this.isMounted)
1135
1285
  return this._cleanup(!1);
1136
1286
  const e = [];
@@ -1149,14 +1299,14 @@ class he {
1149
1299
  if (f)
1150
1300
  f.setValue(a.value), f.setIndex(a.index), s[a.index] = f;
1151
1301
  else {
1152
- const [l, d] = D(a.value), [p, g] = D(a.index);
1302
+ const [l, d] = H(a.value), [p, _] = H(a.index);
1153
1303
  s[a.index] = {
1154
1304
  key: a.key,
1155
1305
  $value: l,
1156
1306
  setValue: d,
1157
1307
  $index: p,
1158
- setIndex: g,
1159
- element: new F(this.elementContext, le, {
1308
+ setIndex: _,
1309
+ element: new U(this.elementContext, Se, {
1160
1310
  $value: l,
1161
1311
  $index: p,
1162
1312
  renderFn: this.renderFn
@@ -1165,7 +1315,7 @@ class he {
1165
1315
  }
1166
1316
  }
1167
1317
  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;
1318
+ const f = s[a], l = ((u = s[a - 1]) == null ? void 0 : u.element.node) ?? this.node;
1169
1319
  f.element.mount(this.node.parentNode, l);
1170
1320
  }
1171
1321
  this.connectedItems = s;
@@ -1173,66 +1323,66 @@ class he {
1173
1323
  (h = this.node.parentNode) == null || h.insertBefore(this.node, i.nextSibling);
1174
1324
  }
1175
1325
  }
1176
- function le({ $value: n, $index: t, renderFn: e }, r) {
1326
+ function Se({ $value: n, $index: t, renderFn: e }, r) {
1177
1327
  return e(n, t, r);
1178
1328
  }
1179
- function P(n) {
1180
- return (n == null ? void 0 : n[Nt]) === !0;
1329
+ function L(n) {
1330
+ return (n == null ? void 0 : n[$t]) === !0;
1181
1331
  }
1182
- function Wt(n) {
1332
+ function qt(n) {
1183
1333
  return (n == null ? void 0 : n[k]) === !0;
1184
1334
  }
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", {
1335
+ function tt(n) {
1336
+ return A(n) || (n = [n]), n.flat(1 / 0).filter((t) => t != null && t !== !1).map((t) => L(t) ? t : t instanceof Node ? v("$node", { value: t }) : m(t) ? v("$observer", {
1187
1337
  sources: [t],
1188
1338
  renderFn: (e) => e
1189
- }) : S("$text", { value: t }));
1339
+ }) : v("$text", { value: t }));
1190
1340
  }
1191
- function S(n, t, ...e) {
1192
- return new fe(n, t, ...e);
1341
+ function v(n, t, ...e) {
1342
+ return new ve(n, t, ...e);
1193
1343
  }
1194
- var yt;
1195
- yt = Nt;
1196
- class fe {
1344
+ var xt;
1345
+ xt = $t;
1346
+ class ve {
1197
1347
  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);
1348
+ o(this, xt, !0);
1349
+ o(this, "type");
1350
+ o(this, "props");
1351
+ o(this, "children");
1352
+ this.type = t, this.props = e, this.children = tt(r);
1203
1353
  }
1204
1354
  }
1205
- const ke = re.bind(S);
1206
- function xe(n, t, e) {
1207
- return S("$observer", {
1355
+ const Te = fe.bind(v);
1356
+ function qe(n, t, e) {
1357
+ return v("$observer", {
1208
1358
  sources: [n],
1209
1359
  renderFn: (r) => r && t ? t : !r && e ? e : null
1210
1360
  });
1211
1361
  }
1212
- function Ee(n, t, e) {
1213
- const r = K(n);
1214
- return S("$repeat", { $items: r, keyFn: t, renderFn: e });
1362
+ function Ie(n, t, e) {
1363
+ const r = Z(n);
1364
+ return v("$repeat", { $items: r, keyFn: t, renderFn: e });
1215
1365
  }
1216
- function be(n, t) {
1217
- return S("$portal", { parent: n, content: t });
1366
+ function je(n, t) {
1367
+ return v("$portal", { parent: n, content: t });
1218
1368
  }
1219
- function x(n, t) {
1369
+ function M(n, t) {
1220
1370
  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))
1371
+ if (I(r.type))
1372
+ return new U(n, r.type, r.props, r.children);
1373
+ if (b(r.type))
1224
1374
  switch (r.type) {
1225
1375
  case "$node": {
1226
1376
  const s = r.props;
1227
- return new ct(s.value);
1377
+ return new dt(s.value);
1228
1378
  }
1229
1379
  case "$text": {
1230
1380
  const s = r.props;
1231
- return new ct(document.createTextNode(String(s.value)));
1381
+ return new dt(document.createTextNode(String(s.value)));
1232
1382
  }
1233
1383
  case "$repeat": {
1234
1384
  const s = r.props;
1235
- return new he({
1385
+ return new ye({
1236
1386
  $items: s.$items,
1237
1387
  keyFn: s.keyFn,
1238
1388
  renderFn: s.renderFn,
@@ -1241,7 +1391,7 @@ function x(n, t) {
1241
1391
  }
1242
1392
  case "$observer": {
1243
1393
  const s = r.props;
1244
- return new ue({
1394
+ return new _e({
1245
1395
  sources: s.sources,
1246
1396
  renderFn: s.renderFn,
1247
1397
  elementContext: n
@@ -1249,11 +1399,11 @@ function x(n, t) {
1249
1399
  }
1250
1400
  case "$outlet": {
1251
1401
  const s = r.props;
1252
- return new $t(s.$children);
1402
+ return new Tt(s.$children);
1253
1403
  }
1254
1404
  case "$portal": {
1255
1405
  const s = r.props;
1256
- return new ce({
1406
+ return new ge({
1257
1407
  content: s.content,
1258
1408
  parent: s.parent,
1259
1409
  elementContext: n
@@ -1262,7 +1412,7 @@ function x(n, t) {
1262
1412
  default:
1263
1413
  if (r.type.startsWith("$"))
1264
1414
  throw new Error(`Unknown markup type: ${r.type}`);
1265
- return new ie({
1415
+ return new pe({
1266
1416
  tag: r.type,
1267
1417
  props: r.props ?? {},
1268
1418
  children: r.children,
@@ -1273,47 +1423,54 @@ function x(n, t) {
1273
1423
  throw new TypeError(`Expected a string or view function. Got: ${r.type}`);
1274
1424
  });
1275
1425
  }
1276
- function T(n) {
1277
- return n.length === 1 ? n[0] : new $t(n);
1426
+ function q(n) {
1427
+ return n.length === 1 ? n[0] : new Tt(n);
1278
1428
  }
1279
- function Tt(n) {
1280
- return n == null || n === !1 || E(n) || Ut(n) || P(n) || m(n) || vt(Tt, n);
1429
+ function It(n) {
1430
+ return n == null || n === !1 || b(n) || Gt(n) || L(n) || m(n) || Mt(It, n);
1281
1431
  }
1282
- function Ae(n, t) {
1432
+ function Ue(n, t) {
1283
1433
  return t.outlet();
1284
1434
  }
1285
1435
  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,
1436
+ Zt as A,
1437
+ Oe as B,
1438
+ Q as C,
1439
+ q as D,
1440
+ M as E,
1441
+ Fe as F,
1442
+ Et as G,
1443
+ je as H,
1444
+ Ie as I,
1445
+ Pe as J,
1446
+ Ue as P,
1447
+ Ve as S,
1448
+ U as V,
1449
+ b as a,
1450
+ Ae as b,
1451
+ H as c,
1452
+ oe as d,
1453
+ I as e,
1454
+ Me as f,
1455
+ ke as g,
1456
+ xe as h,
1457
+ bt as i,
1458
+ Te as j,
1459
+ qe as k,
1460
+ X as l,
1461
+ Ne as m,
1462
+ Z as n,
1463
+ re as o,
1464
+ j as p,
1465
+ m as q,
1466
+ $e as r,
1467
+ Ee as s,
1311
1468
  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
1469
+ ue as u,
1470
+ he as v,
1471
+ B as w,
1472
+ le as x,
1473
+ be as y,
1474
+ v as z
1318
1475
  };
1319
- //# sourceMappingURL=passthrough-D9NjRov5.js.map
1476
+ //# sourceMappingURL=passthrough-1MySicTa.js.map