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

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.
package/dist/index.js CHANGED
@@ -1,150 +1,29 @@
1
- var rt = Object.defineProperty;
2
- var Ve = (o) => {
1
+ var nt = Object.defineProperty;
2
+ var Ie = (o) => {
3
3
  throw TypeError(o);
4
4
  };
5
- var nt = (o, e, t) => e in o ? rt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
6
- var d = (o, e, t) => nt(o, typeof e != "symbol" ? e + "" : e, t), xe = (o, e, t) => e.has(o) || Ve("Cannot " + t);
7
- var i = (o, e, t) => (xe(o, e, "read from private field"), t ? t.call(o) : e.get(o)), l = (o, e, t) => e.has(o) ? Ve("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), m = (o, e, t, s) => (xe(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t), u = (o, e, t) => (xe(o, e, "access private method"), t);
5
+ var it = (o, e, t) => e in o ? nt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
6
+ var d = (o, e, t) => it(o, typeof e != "symbol" ? e + "" : e, t), Me = (o, e, t) => e.has(o) || Ie("Cannot " + t);
7
+ var i = (o, e, t) => (Me(o, e, "read from private field"), t ? t.call(o) : e.get(o)), l = (o, e, t) => e.has(o) ? Ie("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), m = (o, e, t, s) => (Me(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t), u = (o, e, t) => (Me(o, e, "access private method"), t);
8
8
  var Z = (o, e, t, s) => ({
9
- set _(n) {
10
- m(o, e, n, t);
9
+ set _(r) {
10
+ m(o, e, r, t);
11
11
  },
12
12
  get _() {
13
13
  return i(o, e, s);
14
14
  }
15
15
  });
16
- import { h as qe, c as it, i as Y, a as Ue, d as M, b as v, e as at, f as se, t as Ie, g as Ke, j as ot, s as We, k as Ae, P as Qe, l as Ge, m as Be, S as lt, n as ht, o as ct, p as ut, q as ft, r as dt, u as He, v as mt, w as be, x as $e, V as wt, y as pt, z as gt } from "./passthrough-D9NjRov5.js";
17
- import { B as zt, C as Kt, A as Qt } from "./passthrough-D9NjRov5.js";
18
- function yt(o) {
19
- return qe`
20
- <div
21
- style=${{
22
- backgroundColor: "#880000",
23
- color: "#fff",
24
- padding: "2rem",
25
- position: "fixed",
26
- inset: 0,
27
- fontSize: "20px"
28
- }}
29
- >
30
- <h1 style=${{ marginBottom: "0.5rem" }}>The app has crashed</h1>
31
- <p style=${{ marginBottom: "0.25rem" }}>
32
- <span style=${{ fontFamily: "monospace" }}>${o.loggerName}</span>
33
- ${it(o.uid, qe`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${o.uid}]</span>`)}
34
- ${" "}says:
35
- </p>
36
- <blockquote
37
- style=${{
38
- backgroundColor: "#991111",
39
- padding: "0.25em",
40
- borderRadius: "6px",
41
- fontFamily: "monospace",
42
- marginBottom: "1rem"
43
- }}
44
- >
45
- <span
46
- style=${{
47
- display: "inline-block",
48
- backgroundColor: "red",
49
- padding: "0.1em 0.4em",
50
- marginRight: "0.5em",
51
- borderRadius: "4px",
52
- fontSize: "0.9em",
53
- fontWeight: "bold"
54
- }}
55
- >
56
- ${o.error.name}
57
- </span>
58
- ${o.error.message}
59
- </blockquote>
60
-
61
- <p>Please see the browser console for details.</p>
62
- </div>
63
- `;
64
- }
65
- var re, K, F, V, q, Q, ke, _, ne, x, De, ve;
66
- class bt {
67
- constructor(e) {
68
- l(this, x);
69
- l(this, re);
70
- l(this, K);
71
- // Keys ensure only the most recent callback queued with a certain key
72
- // will be called, keeping DOM operations to a minimum.
73
- l(this, F, /* @__PURE__ */ new Map());
74
- // All unkeyed writes are run on every batch.
75
- l(this, V, []);
76
- // All read callbacks are run before updates on every batch.
77
- l(this, q, []);
78
- l(this, Q, !1);
79
- // When true, batches that would exceed 16ms will be split and deferred to a rAF.
80
- // This may not be desirable, because while it does prevent hitching it sometimes leaves
81
- // the state partially rendered for a brief second and certain elements can be seen to update after the fact.
82
- // But the tradeoff here is snappier navigation with possibly slightly out of date DOM updates on heavy pages.
83
- l(this, ke, !0);
84
- l(this, _, 0);
85
- l(this, ne, new Intl.NumberFormat("en-US", {
86
- maximumFractionDigits: 2,
87
- minimumFractionDigits: 0,
88
- style: "unit",
89
- unit: "millisecond",
90
- unitDisplay: "short"
91
- }));
92
- m(this, re, e), m(this, K, e.createLogger("Dolla.batch"));
93
- }
94
- /**
95
- * Queues a callback that runs before the next batch of writes.
96
- */
97
- read(e) {
98
- i(this, q).push(e), u(this, x, De).call(this);
99
- }
100
- /**
101
- * Queues a callback to run in the next render batch.
102
- * Always put DOM mutations in a write callback when possible to help Dolla batch them efficiently.
103
- */
104
- write(e, t) {
105
- t ? i(this, F).set(t, e) : i(this, V).push(e), u(this, x, De).call(this);
106
- }
107
- }
108
- re = new WeakMap(), K = new WeakMap(), F = new WeakMap(), V = new WeakMap(), q = new WeakMap(), Q = new WeakMap(), ke = new WeakMap(), _ = new WeakMap(), ne = new WeakMap(), x = new WeakSet(), De = function() {
109
- if (!i(this, Q)) {
110
- m(this, Q, !0);
111
- const e = i(this, re).getEnv() === "development";
112
- queueMicrotask(() => {
113
- u(this, x, ve).call(this, e);
114
- });
115
- }
116
- }, ve = function(e = !1) {
117
- const t = performance.now();
118
- let s = 0;
119
- const n = i(this, q).length + i(this, F).size + i(this, V).length;
120
- let r = 0;
121
- const a = () => (r++, s = performance.now() - t, i(this, ke) && s > 12 && r < n ? (Z(this, _)._++, e && i(this, K).warn(
122
- `⚠️ Deferring batch to next frame. Performed ${r} of ${n} batched operation${r === 1 ? "" : "s"} in ${i(this, ne).format(s)} (deferral ${i(this, _)}).`
123
- ), requestAnimationFrame(() => {
124
- u(this, x, ve).call(this, e);
125
- }), !0) : !1), f = [...i(this, F).entries()];
126
- let h, w;
127
- for (; w = i(this, q).shift(); )
128
- if (w(), a()) return;
129
- for ([h, w] of f)
130
- if (w(), i(this, F).delete(h), a()) return;
131
- for (; w = i(this, V).shift(); )
132
- if (w(), a()) return;
133
- e && i(this, K)[s > 16 ? "warn" : "info"](
134
- `${s > 16 ? "⚠️ (>=16ms) " : ""}Executed ${r} operation${r === 1 ? "" : "s"} in ${i(this, ne).format(s)}${i(this, _) > 0 ? ` (after ${i(this, _)} deferral${i(this, _) === 1 ? "" : "s"})` : ""}.`
135
- ), m(this, _, 0), i(this, q).length || i(this, F).size || i(this, V).length ? queueMicrotask(() => {
136
- u(this, x, ve).call(this, e);
137
- }) : m(this, Q, !1);
138
- };
139
- var I, Re, Se, ie, R, S;
140
- class $t {
16
+ import { i as Y, c as Ue, d as M, a as E, b as at, e as se, t as qe, f as Qe, g as ot, s as We, h as Ae, P as Je, j as Ge, k as lt, l as He, p as ht, m as Be, S as ct, n as ut, o as ft, q as dt, r as mt, u as wt, C as pt, v as gt, w as De, x as yt, y as ze, z as bt, A as be, B as $e, V as $t, D as vt, E as Et } from "./passthrough-eH8w4zJi.js";
17
+ import { F as Yt, J as Zt, H as es, I as ts, G as ss } from "./passthrough-eH8w4zJi.js";
18
+ var U, ke, Se, re, R, _;
19
+ class kt {
141
20
  constructor(e) {
142
21
  l(this, R);
143
- l(this, I, []);
144
- l(this, Re, vt());
22
+ l(this, U, []);
23
+ l(this, ke, St());
145
24
  l(this, Se);
146
- l(this, ie);
147
- m(this, Se, e), m(this, ie, e.createLogger("Dolla.http"));
25
+ l(this, re);
26
+ m(this, Se, e), m(this, re, e.createLogger("Dolla.http"));
148
27
  }
149
28
  /**
150
29
  * Adds a new middleware that will apply to subsequent requests.
@@ -153,61 +32,61 @@ class $t {
153
32
  * @param middleware - A middleware function that will intercept requests.
154
33
  */
155
34
  use(e) {
156
- return i(this, I).push(e), () => {
157
- i(this, I).splice(i(this, I).indexOf(e), 1);
35
+ return i(this, U).push(e), () => {
36
+ i(this, U).splice(i(this, U).indexOf(e), 1);
158
37
  };
159
38
  }
160
39
  async get(e, t) {
161
- return u(this, R, S).call(this, "get", e, t);
40
+ return u(this, R, _).call(this, "get", e, t);
162
41
  }
163
42
  async put(e, t) {
164
- return u(this, R, S).call(this, "put", e, t);
43
+ return u(this, R, _).call(this, "put", e, t);
165
44
  }
166
45
  async patch(e, t) {
167
- return u(this, R, S).call(this, "patch", e, t);
46
+ return u(this, R, _).call(this, "patch", e, t);
168
47
  }
169
48
  async post(e, t) {
170
- return u(this, R, S).call(this, "post", e, t);
49
+ return u(this, R, _).call(this, "post", e, t);
171
50
  }
172
51
  async delete(e, t) {
173
- return u(this, R, S).call(this, "delete", e, t);
52
+ return u(this, R, _).call(this, "delete", e, t);
174
53
  }
175
54
  async head(e, t) {
176
- return u(this, R, S).call(this, "head", e, t);
55
+ return u(this, R, _).call(this, "head", e, t);
177
56
  }
178
57
  async options(e, t) {
179
- return u(this, R, S).call(this, "options", e, t);
58
+ return u(this, R, _).call(this, "options", e, t);
180
59
  }
181
60
  async trace(e, t) {
182
- return u(this, R, S).call(this, "trace", e, t);
61
+ return u(this, R, _).call(this, "trace", e, t);
183
62
  }
184
63
  }
185
- I = new WeakMap(), Re = new WeakMap(), Se = new WeakMap(), ie = new WeakMap(), R = new WeakSet(), S = async function(e, t, s) {
186
- return new Rt({
64
+ U = new WeakMap(), ke = new WeakMap(), Se = new WeakMap(), re = new WeakMap(), R = new WeakSet(), _ = async function(e, t, s) {
65
+ return new Lt({
187
66
  ...s,
188
67
  method: e,
189
68
  uri: t,
190
- middleware: i(this, I),
191
- fetch: i(this, Re),
192
- logger: i(this, ie)
69
+ middleware: i(this, U),
70
+ fetch: i(this, ke),
71
+ logger: i(this, re)
193
72
  }).fetch();
194
73
  };
195
- function vt() {
74
+ function St() {
196
75
  if (typeof window < "u" && window.fetch)
197
76
  return window.fetch.bind(window);
198
77
  if (typeof global < "u" && global.fetch)
199
78
  return global.fetch.bind(global);
200
79
  throw new Error("Running in neither browser nor node. Please run this app in one of the supported environments.");
201
80
  }
202
- class Et extends Error {
81
+ class Rt extends Error {
203
82
  constructor(t) {
204
- const { status: s, statusText: n, method: r, url: a } = t, f = `${s} ${n}: Request failed (${r.toUpperCase()} ${a.toString()})`;
83
+ const { status: s, statusText: r, method: n, url: a } = t, f = `${s} ${r}: Request failed (${n.toUpperCase()} ${a.toString()})`;
205
84
  super(f);
206
85
  d(this, "response");
207
86
  this.response = t;
208
87
  }
209
88
  }
210
- class kt {
89
+ class _t {
211
90
  constructor(e) {
212
91
  d(this, "method");
213
92
  d(this, "url");
@@ -247,25 +126,25 @@ class kt {
247
126
  throw new TypeError(`Unknown query params type. Got: ${e}`);
248
127
  }
249
128
  }
250
- class Rt {
129
+ class Lt {
251
130
  constructor(e) {
252
131
  d(this, "_middleware");
253
132
  d(this, "_fetch");
254
133
  d(this, "_request");
255
134
  d(this, "_response");
256
- this._middleware = e.middleware, this._fetch = e.fetch, this._request = new kt(e);
135
+ this._middleware = e.middleware, this._fetch = e.fetch, this._request = new _t(e);
257
136
  }
258
137
  async fetch() {
259
138
  if (this._middleware.length > 0) {
260
139
  const e = (t = 0) => {
261
- const s = this._middleware[t], n = this._middleware[t + 1] ? e(t + 1) : this._handler.bind(this);
262
- return async () => s(this._request, async () => (await n(), this._response));
140
+ const s = this._middleware[t], r = this._middleware[t + 1] ? e(t + 1) : this._handler.bind(this);
141
+ return async () => s(this._request, async () => (await r(), this._response));
263
142
  };
264
143
  await e()();
265
144
  } else
266
145
  await this._handler();
267
146
  if (this._response.status < 200 || this._response.status >= 400)
268
- throw new Et(this._response);
147
+ throw new Rt(this._response);
269
148
  return this._response;
270
149
  }
271
150
  // This is the function that performs the actual request after the final middleware.
@@ -277,35 +156,35 @@ class Rt {
277
156
  method: t.method,
278
157
  headers: t.headers,
279
158
  body: e
280
- }), n = s.headers.get("content-type");
281
- let r;
282
- n != null && n.includes("application/json") ? r = await s.json() : n != null && n.includes("application/x-www-form-urlencoded") ? r = await s.formData() : r = await s.text(), this._response = {
159
+ }), r = s.headers.get("content-type");
160
+ let n;
161
+ r != null && r.includes("application/json") ? n = await s.json() : r != null && r.includes("application/x-www-form-urlencoded") ? n = await s.formData() : n = await s.text(), this._response = {
283
162
  method: t.method,
284
163
  url: t.url,
285
164
  status: s.status,
286
165
  statusText: s.statusText,
287
166
  headers: s.headers,
288
- body: r
167
+ body: n
289
168
  };
290
169
  }
291
170
  }
292
- var _e, J, H, Fe, Je;
293
- class St {
171
+ var Re, K, B, Fe, Xe;
172
+ class xt {
294
173
  constructor(e, t) {
295
- l(this, H);
174
+ l(this, B);
296
175
  d(this, "dolla");
297
176
  d(this, "config");
298
- l(this, _e, !1);
299
- l(this, J, /* @__PURE__ */ new Map());
177
+ l(this, Re, !1);
178
+ l(this, K, /* @__PURE__ */ new Map());
300
179
  this.config = e, this.dolla = t;
301
180
  }
302
181
  async load() {
303
182
  let e;
304
- if (!i(this, _e)) {
183
+ if (!i(this, Re)) {
305
184
  if (se(this.config.fetch)) {
306
185
  if (e = await this.config.fetch(), !Y(e))
307
186
  throw new Error(`Fetch function did not return an object of language strings: ${e}`);
308
- } else if (v(this.config.path)) {
187
+ } else if (E(this.config.path)) {
309
188
  const t = await fetch(this.config.path);
310
189
  if (t.ok) {
311
190
  const s = await t.json();
@@ -320,38 +199,38 @@ class St {
320
199
  }
321
200
  }
322
201
  if (e) {
323
- const t = u(this, H, Fe).call(this, e);
202
+ const t = u(this, B, Fe).call(this, e);
324
203
  for (const s of t)
325
- i(this, J).set(s[0], s[1]);
204
+ i(this, K).set(s[0], s[1]);
326
205
  } else
327
206
  throw new Error("Language could not be loaded.");
328
207
  }
329
208
  getTemplate(e) {
330
- return i(this, J).get(e) ?? {
209
+ return i(this, K).get(e) ?? {
331
210
  segments: [{ type: 0, text: `[MISSING: ${e}]` }]
332
211
  };
333
212
  }
334
213
  hasTemplate(e) {
335
- return i(this, J).has(e);
214
+ return i(this, K).has(e);
336
215
  }
337
216
  }
338
- _e = new WeakMap(), J = new WeakMap(), H = new WeakSet(), Fe = function(e, t = []) {
217
+ Re = new WeakMap(), K = new WeakMap(), B = new WeakSet(), Fe = function(e, t = []) {
339
218
  const s = [];
340
- for (const n in e)
341
- switch (Ie(e[n])) {
219
+ for (const r in e)
220
+ switch (qe(e[r])) {
342
221
  case "string":
343
- s.push([[...t, n].join("."), u(this, H, Je).call(this, e[n])]);
222
+ s.push([[...t, r].join("."), u(this, B, Xe).call(this, e[r])]);
344
223
  break;
345
224
  case "object":
346
- s.push(...u(this, H, Fe).call(this, e[n], [...t, n]));
225
+ s.push(...u(this, B, Fe).call(this, e[r], [...t, r]));
347
226
  break;
348
227
  default:
349
228
  throw new Error(
350
- `Expected to find a string or object at ${[...t, n].join(".")}. Got: ${Ie(e[n])}`
229
+ `Expected to find a string or object at ${[...t, r].join(".")}. Got: ${qe(e[r])}`
351
230
  );
352
231
  }
353
232
  return s;
354
- }, Je = function(e) {
233
+ }, Xe = function(e) {
355
234
  let t;
356
235
  ((c) => {
357
236
  c[c.Static = 0] = "Static", c[c.ValueName = 1] = "ValueName", c[c.FormatName = 2] = "FormatName", c[c.FormatOptionName = 3] = "FormatOptionName", c[c.FormatOptionValue = 4] = "FormatOptionValue", c[c.FormatOptionEnd = 5] = "FormatOptionEnd";
@@ -359,63 +238,63 @@ _e = new WeakMap(), J = new WeakMap(), H = new WeakSet(), Fe = function(e, t = [
359
238
  const s = {
360
239
  segments: []
361
240
  };
362
- let n = "", r = 0, a = 0, f, h, w;
363
- const $ = () => {
241
+ let r = "", n = 0, a = 0, f, h, w;
242
+ const v = () => {
364
243
  f = {
365
244
  type: 1,
366
245
  name: "",
367
246
  formats: []
368
247
  };
369
- }, E = () => {
248
+ }, k = () => {
370
249
  h = {
371
250
  name: "",
372
251
  options: {}
373
252
  };
374
253
  };
375
- for (; r < e.length; ) {
376
- if (a !== 0 && e[r] === " ") {
377
- r++;
254
+ for (; n < e.length; ) {
255
+ if (a !== 0 && e[n] === " ") {
256
+ n++;
378
257
  continue;
379
258
  }
380
259
  switch (a) {
381
260
  case 0:
382
- e[r] === "{" && e[r + 1] === "{" ? (a = 1, r += 2, n.length > 0 && (s.segments.push({ type: 0, text: n }), n = ""), $()) : (n += e[r], r++);
261
+ e[n] === "{" && e[n + 1] === "{" ? (a = 1, n += 2, r.length > 0 && (s.segments.push({ type: 0, text: r }), r = ""), v()) : (r += e[n], n++);
383
262
  break;
384
263
  case 1:
385
- e[r] === "|" ? (a = 2, r += 1, f.name = n, n = "", E()) : e[r] === "}" && e[r + 1] === "}" ? (a = 0, r += 2, f.name = n, n = "", s.segments.push(f)) : (n += e[r], r++);
264
+ e[n] === "|" ? (a = 2, n += 1, f.name = r, r = "", k()) : e[n] === "}" && e[n + 1] === "}" ? (a = 0, n += 2, f.name = r, r = "", s.segments.push(f)) : (r += e[n], n++);
386
265
  break;
387
266
  case 2:
388
- e[r] === "(" ? (a = 3, r += 1, h.name = n, n = "") : e[r] === "}" && e[r + 1] === "}" ? (a = 0, r += 2, f.formats.push(h), s.segments.push(f)) : (n += e[r], r++);
267
+ e[n] === "(" ? (a = 3, n += 1, h.name = r, r = "") : e[n] === "}" && e[n + 1] === "}" ? (a = 0, n += 2, f.formats.push(h), s.segments.push(f)) : (r += e[n], n++);
389
268
  break;
390
269
  case 3:
391
- e[r] === ")" || (e[r] === ":" ? (a = 4, r += 1, w = n, n = "") : e[r] === "}" && e[r + 1] === "}" || (n += e[r], r++));
270
+ e[n] === ")" || (e[n] === ":" ? (a = 4, n += 1, w = r, r = "") : e[n] === "}" && e[n + 1] === "}" || (r += e[n], n++));
392
271
  break;
393
272
  case 4:
394
- e[r] === ")" ? (a = 5, r += 1, h.options[w] = n, n = "", f.formats.push(h)) : e[r] === "," ? (a = 3, r += 1, h.options[w] = n, n = "") : e[r] === "}" && e[r + 1] === "}" || (n += e[r], r++);
273
+ e[n] === ")" ? (a = 5, n += 1, h.options[w] = r, r = "", f.formats.push(h)) : e[n] === "," ? (a = 3, n += 1, h.options[w] = r, r = "") : e[n] === "}" && e[n + 1] === "}" || (r += e[n], n++);
395
274
  break;
396
275
  case 5:
397
- e[r] === "|" ? (a = 2, r += 1, E()) : e[r] === "}" && e[r + 1] === "}" && (a = 0, r += 2, s.segments.push(f));
276
+ e[n] === "|" ? (a = 2, n += 1, k()) : e[n] === "}" && e[n + 1] === "}" && (a = 0, n += 2, s.segments.push(f));
398
277
  break;
399
278
  }
400
279
  }
401
- return a === 0 && n.length > 0 && s.segments.push({ type: 0, text: n }), s;
280
+ return a === 0 && r.length > 0 && s.segments.push({ type: 0, text: r }), s;
402
281
  };
403
- var ae, P, y, oe, le, he, ce, b, Xe, Pe, Ne, Te, Ye;
404
- class _t {
282
+ var ne, P, y, ie, ae, oe, le, b, Ye, Pe, Ne, Te, Ze;
283
+ class Mt {
405
284
  constructor(e) {
406
285
  l(this, b);
407
- l(this, ae);
286
+ l(this, ne);
408
287
  l(this, P);
409
288
  l(this, y, /* @__PURE__ */ new Map());
410
- l(this, oe, []);
411
- l(this, le, /* @__PURE__ */ new Map());
412
- l(this, he, "auto");
289
+ l(this, ie, []);
290
+ l(this, ae, /* @__PURE__ */ new Map());
291
+ l(this, oe, "auto");
413
292
  d(this, "$locale");
414
- l(this, ce);
415
- m(this, ae, e), m(this, P, e.createLogger("Dolla.i18n"));
293
+ l(this, le);
294
+ m(this, ne, e), m(this, P, e.createLogger("Dolla.i18n"));
416
295
  const [t, s] = Ue();
417
- this.$locale = t, m(this, ce, s), this.addFormat("number", (n, r, a) => u(this, b, Pe).call(this, Number(r), a)), this.addFormat("datetime", (n, r, a) => u(this, b, Ne).call(this, r, a)), this.addFormat("list", (n, r, a) => u(this, b, Te).call(this, r, a)), e.beforeMount(async () => {
418
- i(this, y).size > 0 && await this.setLocale(i(this, he));
296
+ this.$locale = t, m(this, le, s), this.addFormat("number", (r, n, a) => u(this, b, Pe).call(this, Number(n), a)), this.addFormat("datetime", (r, n, a) => u(this, b, Ne).call(this, n, a)), this.addFormat("list", (r, n, a) => u(this, b, Te).call(this, n, a)), e.beforeMount(async () => {
297
+ i(this, y).size > 0 && await this.setLocale(i(this, oe));
419
298
  });
420
299
  }
421
300
  get locales() {
@@ -423,40 +302,40 @@ class _t {
423
302
  }
424
303
  setup(e) {
425
304
  if (e.translations.forEach((t) => {
426
- i(this, y).set(t.locale, new St(t, i(this, ae)));
305
+ i(this, y).set(t.locale, new xt(t, i(this, ne)));
427
306
  }), e.locale && e.locale !== "auto") {
428
307
  if (!e.translations.some((s) => s.locale === e.locale))
429
308
  throw new Error(`Initial locale '${e.locale}' is not registered in the locales array.`);
430
- m(this, he, e.locale);
309
+ m(this, oe, e.locale);
431
310
  }
432
311
  i(this, P).info(
433
312
  `${i(this, y).size} language${i(this, y).size === 1 ? "" : "s"} supported: '${[...i(this, y).keys()].join("', '")}'`
434
313
  );
435
314
  }
436
315
  async setLocale(e) {
437
- var n;
316
+ var r;
438
317
  let t;
439
318
  if (e === "auto") {
440
- let r = [];
319
+ let n = [];
441
320
  if (typeof navigator < "u") {
442
321
  const a = navigator;
443
- ((n = a.languages) == null ? void 0 : n.length) > 0 ? r.push(...a.languages) : a.language ? r.push(a.language) : a.browserLanguage ? r.push(a.browserLanguage) : a.userLanguage && r.push(a.userLanguage);
322
+ ((r = a.languages) == null ? void 0 : r.length) > 0 ? n.push(...a.languages) : a.language ? n.push(a.language) : a.browserLanguage ? n.push(a.browserLanguage) : a.userLanguage && n.push(a.userLanguage);
444
323
  }
445
- for (const a of r)
324
+ for (const a of n)
446
325
  i(this, y).has(a) && (t = a);
447
326
  } else
448
327
  i(this, y).has(e) && (t = e);
449
328
  if (t == null) {
450
- const r = i(this, y).keys().next().value;
451
- r && (t = r);
329
+ const n = i(this, y).keys().next().value;
330
+ n && (t = n);
452
331
  }
453
332
  if (!t || !i(this, y).has(t))
454
333
  throw new Error(`Locale '${e}' has no translation.`);
455
334
  const s = i(this, y).get(t);
456
335
  try {
457
- await s.load(), m(this, oe, []), i(this, ce).call(this, t), i(this, P).info("set language to " + t);
458
- } catch (r) {
459
- r instanceof Error && i(this, P).crash(r);
336
+ await s.load(), m(this, ie, []), i(this, le).call(this, t), i(this, P).info("set language to " + t);
337
+ } catch (n) {
338
+ n instanceof Error && i(this, P).crash(n);
460
339
  }
461
340
  }
462
341
  /**
@@ -473,16 +352,16 @@ class _t {
473
352
  throw new Error(
474
353
  `The 't' function cannot be destructured. If you need a standalone version you can import it like so: 'import { t } from "@manyducks.co/dolla"'`
475
354
  );
476
- let s = [], n = [];
477
- for (const r in t)
478
- s.push(r), n.push(t[r]);
479
- return M([this.$locale, ...n], (r, ...a) => {
480
- if (r == null)
355
+ let s = [], r = [];
356
+ for (const n in t)
357
+ s.push(n), r.push(t[n]);
358
+ return M([this.$locale, ...r], (n, ...a) => {
359
+ if (n == null)
481
360
  return "[NO LOCALE SET]";
482
361
  const f = {};
483
362
  for (let h = 0; h < a.length; h++)
484
363
  f[s[h]] = a[h];
485
- return u(this, b, Xe).call(this, r, e, f);
364
+ return u(this, b, Ye).call(this, n, e, f);
486
365
  });
487
366
  }
488
367
  /**
@@ -500,7 +379,7 @@ class _t {
500
379
  * t("greeting", {name: "world"}); // State<"Hello, WORLD!">
501
380
  */
502
381
  addFormat(e, t) {
503
- i(this, le).set(e, t);
382
+ i(this, ae).set(e, t);
504
383
  }
505
384
  /**
506
385
  * Creates an `Intl.Collator` configured for the current locale.
@@ -517,7 +396,7 @@ class _t {
517
396
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
518
397
  */
519
398
  number(e, t) {
520
- return M([this.$locale, e], (s, n) => u(this, b, Pe).call(this, n, t));
399
+ return M([this.$locale, e], (s, r) => u(this, b, Pe).call(this, r, t));
521
400
  }
522
401
  /**
523
402
  * Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
@@ -529,7 +408,7 @@ class _t {
529
408
  * const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
530
409
  */
531
410
  dateTime(e, t) {
532
- return M([this.$locale, e], (s, n) => u(this, b, Ne).call(this, n, t));
411
+ return M([this.$locale, e], (s, r) => u(this, b, Ne).call(this, r, t));
533
412
  }
534
413
  /**
535
414
  * Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
@@ -541,68 +420,68 @@ class _t {
541
420
  * const $formatted = Dolla.i18n.list(list, { });
542
421
  */
543
422
  list(e, t) {
544
- return M([this.$locale, e], (s, n) => u(this, b, Te).call(this, n, t));
423
+ return M([this.$locale, e], (s, r) => u(this, b, Te).call(this, r, t));
545
424
  }
546
425
  }
547
- ae = new WeakMap(), P = new WeakMap(), y = new WeakMap(), oe = new WeakMap(), le = new WeakMap(), he = new WeakMap(), ce = new WeakMap(), b = new WeakSet(), Xe = function(e, t, s) {
426
+ ne = new WeakMap(), P = new WeakMap(), y = new WeakMap(), ie = new WeakMap(), ae = new WeakMap(), oe = new WeakMap(), le = new WeakMap(), b = new WeakSet(), Ye = function(e, t, s) {
548
427
  var h;
549
- const n = u(this, b, Ye).call(this, t, s);
550
- if (n) return n;
551
- const r = i(this, y).get(e);
428
+ const r = u(this, b, Ze).call(this, t, s);
429
+ if (r) return r;
430
+ const n = i(this, y).get(e);
552
431
  if (s.context != null && (t += "_" + s.context), s.count != null)
553
432
  if (s.ordinal) {
554
433
  const w = `${t}_ordinal_(=${s.count})`;
555
- r.hasTemplate(w) ? t = w : t += "_ordinal_" + new Intl.PluralRules(e, { type: "ordinal" }).select(s.count);
434
+ n.hasTemplate(w) ? t = w : t += "_ordinal_" + new Intl.PluralRules(e, { type: "ordinal" }).select(s.count);
556
435
  } else {
557
436
  const w = `${t}_(=${s.count})`;
558
- r.hasTemplate(w) ? t = w : t += "_" + new Intl.PluralRules(e).select(s.count);
437
+ n.hasTemplate(w) ? t = w : t += "_" + new Intl.PluralRules(e).select(s.count);
559
438
  }
560
- const a = r.getTemplate(t);
439
+ const a = n.getTemplate(t);
561
440
  let f = "";
562
441
  for (const w of a.segments)
563
442
  if (w.type === 0)
564
443
  f += w.text;
565
444
  else if (w.type === 1) {
566
- let $ = Lt(s, w.name);
567
- const E = ((h = s.formatOverrides) == null ? void 0 : h[w.name]) ?? [...w.formats];
568
- w.name === "count" && E.length === 0 && E.push({ name: "number", options: {} });
569
- for (const c of E) {
570
- const D = i(this, le).get(c.name);
571
- if (D == null) {
572
- const k = new Error(
445
+ let v = Dt(s, w.name);
446
+ const k = ((h = s.formatOverrides) == null ? void 0 : h[w.name]) ?? [...w.formats];
447
+ w.name === "count" && k.length === 0 && k.push({ name: "number", options: {} });
448
+ for (const c of k) {
449
+ const F = i(this, ae).get(c.name);
450
+ if (F == null) {
451
+ const S = new Error(
573
452
  `Failed to load format '${c.name}' when processing '${t}', template: ${a}`
574
453
  );
575
- throw i(this, P).crash(k), k;
454
+ throw i(this, P).crash(S), S;
576
455
  }
577
- $ = D(e, $, c.options);
456
+ v = F(e, v, c.options);
578
457
  }
579
- f += $;
458
+ f += v;
580
459
  }
581
460
  return f;
582
461
  }, Pe = function(e, t) {
583
462
  return new Intl.NumberFormat(this.$locale.get(), t).format(e);
584
463
  }, Ne = function(e, t) {
585
- return new Intl.DateTimeFormat(this.$locale.get(), t).format(v(e) ? new Date(e) : e);
464
+ return new Intl.DateTimeFormat(this.$locale.get(), t).format(E(e) ? new Date(e) : e);
586
465
  }, Te = function(e, t) {
587
466
  return new Intl.ListFormat(this.$locale.get(), t).format(e);
588
467
  }, // relativeTime(): State<string> {
589
468
  // }
590
- Ye = function(e, t) {
591
- for (const s of i(this, oe))
469
+ Ze = function(e, t) {
470
+ for (const s of i(this, ie))
592
471
  if (s[0] === e && at(s[1], t))
593
472
  return s[2];
594
473
  };
595
- function Lt(o, e) {
596
- const t = String(e).split(/[\.\[\]]/).filter((n) => n.trim() !== "");
474
+ function Dt(o, e) {
475
+ const t = String(e).split(/[\.\[\]]/).filter((r) => r.trim() !== "");
597
476
  let s = o;
598
477
  for (; t.length > 0; ) {
599
- const n = t.shift();
600
- s != null ? s = s[n] : s = void 0;
478
+ const r = t.shift();
479
+ s != null ? s = s[r] : s = void 0;
601
480
  }
602
481
  return s;
603
482
  }
604
483
  function te(o) {
605
- return Ke(o, "Expected `path` to be a string. Got type: %t, value: %v"), o.split("/").map((e) => e.trim()).filter((e) => e !== "");
484
+ return Qe(o, "Expected `path` to be a string. Got type: %t, value: %v"), o.split("/").map((e) => e.trim()).filter((e) => e !== "");
606
485
  }
607
486
  function z(o) {
608
487
  var t;
@@ -613,14 +492,14 @@ function z(o) {
613
492
  ), o = o.filter((s) => s).flatMap(String);
614
493
  let e = (t = o.shift()) == null ? void 0 : t.toString();
615
494
  if (e) {
616
- for (const s of o.map((n) => n.toString()))
617
- s.startsWith(".") ? e = Ee(e, s) : e[e.length - 1] !== "/" ? s[0] !== "/" ? e += "/" + s : e += s : s[0] === "/" ? e += s.slice(1) : e += s;
495
+ for (const s of o.map((r) => r.toString()))
496
+ s.startsWith(".") ? e = ve(e, s) : e[e.length - 1] !== "/" ? s[0] !== "/" ? e += "/" + s : e += s : s[0] === "/" ? e += s.slice(1) : e += s;
618
497
  e && e !== "/" && e.endsWith("/") && (e = e.slice(0, e.length - 1));
619
498
  }
620
499
  return e ?? "";
621
500
  }
622
- function Ee(o, e) {
623
- if (Ke(o, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = o, o = ""), e.startsWith("/"))
501
+ function ve(o, e) {
502
+ if (Qe(o, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = o, o = ""), e.startsWith("/"))
624
503
  return e;
625
504
  let t = o;
626
505
  for (; ; )
@@ -636,69 +515,69 @@ function Ee(o, e) {
636
515
  break;
637
516
  return z([t, e]);
638
517
  }
639
- function Mt(o) {
518
+ function Ft(o) {
640
519
  if (!o) return {};
641
520
  o.startsWith("?") && (o = o.slice(1));
642
521
  const e = o.split("&").filter((t) => t.trim() !== "").map((t) => {
643
- const [s, n] = t.split("=").map((r) => r.trim());
644
- return n.toLowerCase() === "true" ? [s, !0] : n.toLowerCase() === "false" ? [s, !1] : isNaN(Number(n)) ? [s, n] : [s, Number(n)];
522
+ const [s, r] = t.split("=").map((n) => n.trim());
523
+ return r.toLowerCase() === "true" ? [s, !0] : r.toLowerCase() === "false" ? [s, !1] : isNaN(Number(r)) ? [s, r] : [s, Number(r)];
645
524
  });
646
525
  return Object.fromEntries(e);
647
526
  }
648
- function Ze(o, e, t = {}) {
527
+ function et(o, e, t = {}) {
649
528
  var a;
650
- const [s, n] = e.split("?"), r = te(s);
529
+ const [s, r] = e.split("?"), n = te(s);
651
530
  e: for (const f of o) {
652
531
  const { fragments: h } = f;
653
- if (!(((a = h[h.length - 1]) == null ? void 0 : a.type) === 3) && h.length !== r.length || t.willMatch && !t.willMatch(f))
532
+ if (!(((a = h[h.length - 1]) == null ? void 0 : a.type) === 3) && h.length !== n.length || t.willMatch && !t.willMatch(f))
654
533
  continue e;
655
- const $ = [];
534
+ const v = [];
656
535
  t: for (let c = 0; c < h.length; c++) {
657
- const D = r[c], k = h[c];
658
- if (D == null && k.type !== 3)
536
+ const F = n[c], S = h[c];
537
+ if (F == null && S.type !== 3)
659
538
  continue e;
660
- switch (k.type) {
539
+ switch (S.type) {
661
540
  case 1:
662
- if (k.name.toLowerCase() === D.toLowerCase()) {
663
- $.push(k);
541
+ if (S.name.toLowerCase() === F.toLowerCase()) {
542
+ v.push(S);
664
543
  break;
665
544
  } else
666
545
  continue e;
667
546
  case 2:
668
- $.push({ ...k, value: D });
547
+ v.push({ ...S, value: F });
669
548
  break;
670
549
  case 3:
671
- $.push({ ...k, value: r.slice(c).join("/") });
550
+ v.push({ ...S, value: n.slice(c).join("/") });
672
551
  break t;
673
552
  case 4:
674
- if (isNaN(Number(D)))
553
+ if (isNaN(Number(F)))
675
554
  continue e;
676
- $.push({ ...k, value: Number(D) });
555
+ v.push({ ...S, value: Number(F) });
677
556
  break;
678
557
  default:
679
- throw new Error(`Unknown fragment type: ${k.type}`);
558
+ throw new Error(`Unknown fragment type: ${S.type}`);
680
559
  }
681
560
  }
682
- const E = {};
683
- for (const c of $)
684
- c.type === 2 && (E[c.name] = decodeURIComponent(c.value)), c.type === 4 && (E[c.name] = c.value), c.type === 3 && (E.wildcard = "/" + decodeURIComponent(c.value));
561
+ const k = {};
562
+ for (const c of v)
563
+ c.type === 2 && (k[c.name] = decodeURIComponent(c.value)), c.type === 4 && (k[c.name] = c.value), c.type === 3 && (k.wildcard = "/" + decodeURIComponent(c.value));
685
564
  return {
686
- path: "/" + $.map((c) => c.value).join("/"),
565
+ path: "/" + v.map((c) => c.value).join("/"),
687
566
  pattern: "/" + h.map((c) => c.type === 2 ? `{${c.name}}` : c.type === 4 ? `{#${c.name}}` : c.name).join("/"),
688
- params: E,
689
- query: Mt(n),
567
+ params: k,
568
+ query: Ft(r),
690
569
  meta: f.meta
691
570
  };
692
571
  }
693
572
  }
694
- function xt(o) {
695
- const e = [], t = [], s = [], n = [];
573
+ function Pt(o) {
574
+ const e = [], t = [], s = [], r = [];
696
575
  for (const a of o) {
697
576
  const { fragments: f } = a;
698
577
  f.some(
699
578
  (h) => h.type === 3
700
579
  /* Wildcard */
701
- ) ? n.push(a) : f.some(
580
+ ) ? r.push(a) : f.some(
702
581
  (h) => h.type === 4
703
582
  /* NumericParam */
704
583
  ) ? t.push(a) : f.some(
@@ -706,14 +585,14 @@ function xt(o) {
706
585
  /* Param */
707
586
  ) ? s.push(a) : e.push(a);
708
587
  }
709
- const r = (a, f) => a.fragments.length > f.fragments.length ? -1 : 1;
710
- return e.sort(r), t.sort(r), s.sort(r), n.sort(r), [...e, ...t, ...s, ...n];
588
+ const n = (a, f) => a.fragments.length > f.fragments.length ? -1 : 1;
589
+ return e.sort(n), t.sort(n), s.sort(n), r.sort(n), [...e, ...t, ...s, ...r];
711
590
  }
712
- function Dt(o) {
591
+ function Nt(o) {
713
592
  const e = te(o), t = [];
714
593
  for (let s = 0; s < e.length; s++) {
715
- const n = e[s];
716
- if (n === "*") {
594
+ const r = e[s];
595
+ if (r === "*") {
717
596
  if (s !== e.length - 1)
718
597
  throw new Error(`Wildcard must be at the end of a pattern. Received: ${o}`);
719
598
  t.push({
@@ -721,38 +600,38 @@ function Dt(o) {
721
600
  name: "*",
722
601
  value: null
723
602
  });
724
- } else n.at(0) === "{" && n.at(-1) === "}" ? t.push({
725
- type: n[1] === "#" ? 4 : 2,
726
- name: n[1] === "#" ? n.slice(2, -1) : n.slice(1, -1),
603
+ } else r.at(0) === "{" && r.at(-1) === "}" ? t.push({
604
+ type: r[1] === "#" ? 4 : 2,
605
+ name: r[1] === "#" ? r.slice(2, -1) : r.slice(1, -1),
727
606
  value: null
728
607
  }) : t.push({
729
608
  type: 1,
730
- name: n,
731
- value: n
609
+ name: r,
610
+ value: r
732
611
  });
733
612
  }
734
613
  return t;
735
614
  }
736
- var W, L, Le, N, X, A, G, T, ue, p, Ce, et, tt, ee, Oe, st, je;
737
- class Ft {
615
+ var I, L, _e, N, Q, q, W, T, he, p, Ce, tt, st, ee, Oe, rt, je;
616
+ class Tt {
738
617
  constructor(e) {
739
618
  l(this, p);
740
- l(this, W);
619
+ l(this, I);
741
620
  l(this, L);
742
- l(this, Le, 0);
621
+ l(this, _e, 0);
743
622
  l(this, N, []);
744
- l(this, X, []);
623
+ l(this, Q, []);
745
624
  /**
746
625
  * Use hash routing when true. Configured in router options.
747
626
  */
748
- l(this, A, !1);
627
+ l(this, q, !1);
749
628
  // Callbacks that need to be called on unmount.
750
- l(this, G, []);
629
+ l(this, W, []);
751
630
  /**
752
631
  * The current match object.
753
632
  */
754
633
  l(this, T);
755
- l(this, ue);
634
+ l(this, he);
756
635
  /**
757
636
  * The currently matched route pattern, if any.
758
637
  */
@@ -769,35 +648,35 @@ class Ft {
769
648
  * The current query params. Changes to this object will be reflected in the URL.
770
649
  */
771
650
  d(this, "$query");
772
- m(this, W, e), m(this, L, e.createLogger("Dolla.router")), [Z(this, T)._, Z(this, ue)._] = Ue(), this.$pattern = M([i(this, T)], (t) => t == null ? void 0 : t.pattern), this.$path = M([i(this, T)], (t) => (t == null ? void 0 : t.path) ?? window.location.pathname), this.$params = M([i(this, T)], (t) => (t == null ? void 0 : t.params) ?? {}, { equals: We }), this.$query = M([i(this, T)], (t) => (t == null ? void 0 : t.query) ?? {}, { equals: We }), e.beforeMount(async () => {
651
+ m(this, I, e), m(this, L, e.createLogger("Dolla.router")), [Z(this, T)._, Z(this, he)._] = Ue(), this.$pattern = M([i(this, T)], (t) => t == null ? void 0 : t.pattern), this.$path = M([i(this, T)], (t) => (t == null ? void 0 : t.path) ?? window.location.pathname), this.$params = M([i(this, T)], (t) => (t == null ? void 0 : t.params) ?? {}, { equals: We }), this.$query = M([i(this, T)], (t) => (t == null ? void 0 : t.query) ?? {}, { equals: We }), e.beforeMount(async () => {
773
652
  const t = () => {
774
653
  u(this, p, ee).call(this);
775
654
  };
776
- window.addEventListener("popstate", t), i(this, G).push(() => window.removeEventListener("popstate", t));
655
+ window.addEventListener("popstate", t), i(this, W).push(() => window.removeEventListener("popstate", t));
777
656
  const s = e.getRootElement();
778
- i(this, G).push(
779
- Tt(s, (n) => {
780
- let r = n.getAttribute("href");
781
- i(this, L).info("intercepted click on <a> tag", n), /^https?:\/\/|^\//.test(r) || (r = z([window.location.pathname, r])), u(this, p, Ce).call(this, r);
657
+ i(this, W).push(
658
+ jt(s, (r) => {
659
+ let n = r.getAttribute("href");
660
+ i(this, L).info("intercepted click on <a> tag", r), /^https?:\/\/|^\//.test(n) || (n = z([window.location.pathname, n])), u(this, p, Ce).call(this, n);
782
661
  })
783
662
  ), i(this, L).info("will intercept clicks on <a> tags within root element", s), await u(this, p, ee).call(this);
784
663
  }), e.onUnmount(() => {
785
- for (const t of i(this, G))
664
+ for (const t of i(this, W))
786
665
  t();
787
- m(this, G, []);
666
+ m(this, W, []);
788
667
  });
789
668
  }
790
669
  async setup(e) {
791
670
  Ae(e != null, "Options object must not be null. Got: %t"), Ae(
792
- !i(this, W).isMounted,
671
+ !i(this, I).isMounted,
793
672
  "Dolla is already mounted. Dolla.router.setup() must be called before Dolla.mount()."
794
- ), e.hash && m(this, A, !0), m(this, X, xt(
673
+ ), e.hash && m(this, q, !0), m(this, Q, Pt(
795
674
  e.routes.flatMap((t) => u(this, p, je).call(this, t)).map((t) => ({
796
675
  pattern: t.pattern,
797
676
  meta: t.meta,
798
- fragments: Dt(t.pattern)
677
+ fragments: Nt(t.pattern)
799
678
  }))
800
- )), Ot(i(this, X));
679
+ )), Ut(i(this, Q));
801
680
  }
802
681
  /**
803
682
  * Navigate backward. Pass a number of steps to hit the back button that many times.
@@ -819,21 +698,21 @@ class Ft {
819
698
  * Dolla.router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
820
699
  */
821
700
  go(e, t = {}) {
822
- if (i(this, W) == null)
701
+ if (i(this, I) == null)
823
702
  throw new Error("Routa methods won't work until you register it: Dolla.use(Routa, { /* ...options */ })");
824
703
  let s;
825
- Array.isArray(e) ? s = z(e) : s = e.toString(), s = Ee(window.location.pathname, s), t.preserveQuery && (s += window.location.search), t.replace ? u(this, p, et).call(this, s) : u(this, p, Ce).call(this, s);
704
+ Array.isArray(e) ? s = z(e) : s = e.toString(), s = ve(window.location.pathname, s), t.preserveQuery && (s += window.location.search), t.replace ? u(this, p, tt).call(this, s) : u(this, p, Ce).call(this, s);
826
705
  }
827
706
  }
828
- W = new WeakMap(), L = new WeakMap(), Le = new WeakMap(), N = new WeakMap(), X = new WeakMap(), A = new WeakMap(), G = new WeakMap(), T = new WeakMap(), ue = new WeakMap(), p = new WeakSet(), Ce = function(e, t) {
829
- i(this, L).info("(push)", e), window.history.pushState(t, "", i(this, A) ? "/#" + e : e), u(this, p, ee).call(this, e);
830
- }, et = function(e, t) {
831
- i(this, L).info("(replace)", e), window.history.replaceState(t, "", i(this, A) ? "/#" + e : e), u(this, p, ee).call(this, e);
832
- }, tt = function() {
833
- return i(this, A) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
707
+ I = new WeakMap(), L = new WeakMap(), _e = new WeakMap(), N = new WeakMap(), Q = new WeakMap(), q = new WeakMap(), W = new WeakMap(), T = new WeakMap(), he = new WeakMap(), p = new WeakSet(), Ce = function(e, t) {
708
+ i(this, L).info("(push)", e), window.history.pushState(t, "", i(this, q) ? "/#" + e : e), u(this, p, ee).call(this, e);
709
+ }, tt = function(e, t) {
710
+ i(this, L).info("(replace)", e), window.history.replaceState(t, "", i(this, q) ? "/#" + e : e), u(this, p, ee).call(this, e);
711
+ }, st = function() {
712
+ return i(this, q) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
834
713
  }, ee = async function(e) {
835
- const t = i(this, L), s = e ? new URL(e, window.location.origin) : u(this, p, tt).call(this), { match: n, journey: r } = await u(this, p, Oe).call(this, s);
836
- for (const a of r)
714
+ const t = i(this, L), s = e ? new URL(e, window.location.origin) : u(this, p, st).call(this), { match: r, journey: n } = await u(this, p, Oe).call(this, s);
715
+ for (const a of n)
837
716
  switch (a.kind) {
838
717
  case "match":
839
718
  t.info(`📍 ${a.message}`);
@@ -845,58 +724,58 @@ W = new WeakMap(), L = new WeakMap(), Le = new WeakMap(), N = new WeakMap(), X =
845
724
  t.info(`💀 ${a.message}`);
846
725
  break;
847
726
  }
848
- if (n) {
727
+ if (r) {
849
728
  const a = this.$pattern.get();
850
- i(this, ue).call(this, n), n.pattern !== a && u(this, p, st).call(this, n);
729
+ i(this, he).call(this, r), r.pattern !== a && u(this, p, rt).call(this, r);
851
730
  } else
852
- t.crash(new jt(`Failed to match route '${s.pathname}'`));
853
- return { match: n, journey: r };
731
+ t.crash(new It(`Failed to match route '${s.pathname}'`));
732
+ return { match: r, journey: n };
854
733
  }, Oe = async function(e, t = []) {
855
- const s = Ze(i(this, X), e.pathname);
734
+ const s = et(i(this, Q), e.pathname);
856
735
  if (!s)
857
736
  return {
858
737
  match: null,
859
738
  journey: [...t, { kind: "miss", message: `no match for '${e.pathname}'` }]
860
739
  };
861
- let n = s.meta.redirect;
740
+ let r = s.meta.redirect;
862
741
  if (s.meta.beforeMatch && await s.meta.beforeMatch({
863
742
  // TODO: Allow setting context variables from here? Would apply to the context of the matched view.
864
- redirect: (r) => {
865
- n = r;
743
+ redirect: (n) => {
744
+ r = n;
866
745
  }
867
- }), n != null) {
868
- let r;
869
- if (v(n))
870
- r = Ct(n, s.params);
871
- else if (se(n)) {
746
+ }), r != null) {
747
+ let n;
748
+ if (E(r))
749
+ n = Vt(r, s.params);
750
+ else if (se(r)) {
872
751
  const a = {
873
752
  path: s.path,
874
753
  pattern: s.pattern,
875
754
  params: s.params,
876
755
  query: s.query
877
756
  };
878
- if (r = await n(a), !v(r))
757
+ if (n = await r(a), !E(n))
879
758
  throw new Error("Redirect function must return a path to redirect to.");
880
- r.startsWith("/") || (r = Ee(s.path, r));
759
+ n.startsWith("/") || (n = ve(s.path, n));
881
760
  } else
882
761
  throw new TypeError("Redirect must either be a path string or a function.");
883
- return u(this, p, Oe).call(this, new URL(r, window.location.origin), [
762
+ return u(this, p, Oe).call(this, new URL(n, window.location.origin), [
884
763
  ...t,
885
- { kind: "redirect", message: `redirecting '${s.path}' -> '${r}'` }
764
+ { kind: "redirect", message: `redirecting '${s.path}' -> '${n}'` }
886
765
  ]);
887
766
  } else
888
767
  return { match: s, journey: [...t, { kind: "match", message: `matched route '${s.path}'` }] };
889
768
  }, /**
890
769
  * Takes a matched route and mounts it.
891
770
  */
892
- st = function(e) {
771
+ rt = function(e) {
893
772
  const t = e.meta.layers;
894
773
  for (let s = 0; s < t.length; s++) {
895
- const n = t[s], r = i(this, N)[s];
896
- if ((r == null ? void 0 : r.id) !== n.id) {
897
- m(this, N, i(this, N).slice(0, s)), r == null || r.view.unmount();
898
- const a = i(this, N).at(-1), h = ((a == null ? void 0 : a.view) ?? i(this, W).getRootView()).setChildView(n.view);
899
- i(this, N).push({ id: n.id, view: h });
774
+ const r = t[s], n = i(this, N)[s];
775
+ if ((n == null ? void 0 : n.id) !== r.id) {
776
+ m(this, N, i(this, N).slice(0, s)), n == null || n.view.unmount();
777
+ const a = i(this, N).at(-1), h = ((a == null ? void 0 : a.view) ?? i(this, I).getRootView()).setChildView(r.view);
778
+ i(this, N).push({ id: r.id, view: h });
900
779
  }
901
780
  }
902
781
  }, /**
@@ -906,7 +785,7 @@ st = function(e) {
906
785
  * @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
907
786
  */
908
787
  je = function(e, t = [], s = []) {
909
- if (!Y(e) || !v(e.path))
788
+ if (!Y(e) || !E(e.path))
910
789
  throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${e}`);
911
790
  if (e.redirect && e.routes)
912
791
  throw new Error("Route cannot have both a 'redirect' and nested 'routes'.");
@@ -914,31 +793,31 @@ je = function(e, t = [], s = []) {
914
793
  throw new Error("Route cannot have both a 'redirect' and a 'view'.");
915
794
  if (!e.view && !e.routes && !e.redirect)
916
795
  throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
917
- let n = [];
796
+ let r = [];
918
797
  for (const h of t)
919
- n.push(...te(h.path));
920
- n.push(...te(e.path)), n[n.length - 1] === "*" && n.pop();
921
- const r = [];
798
+ r.push(...te(h.path));
799
+ r.push(...te(e.path)), r[r.length - 1] === "*" && r.pop();
800
+ const n = [];
922
801
  if (e.redirect) {
923
802
  let h = e.redirect;
924
- return v(h) && (h = Ee(z(n), h), h.startsWith("/") || (h = "/" + h)), r.push({
925
- pattern: "/" + z([...n, ...te(e.path)]),
803
+ return E(h) && (h = ve(z(r), h), h.startsWith("/") || (h = "/" + h)), n.push({
804
+ pattern: "/" + z([...r, ...te(e.path)]),
926
805
  meta: {
927
806
  redirect: h
928
807
  }
929
- }), r;
808
+ }), n;
930
809
  }
931
- let a = Qe;
810
+ let a = Je;
932
811
  if (se(e.view))
933
812
  a = e.view;
934
813
  else if (e.view)
935
814
  throw new TypeError(`Route '${e.path}' expected a view function or undefined. Got: ${e.view}`);
936
- const f = { id: Z(this, Le)._++, view: a };
815
+ const f = { id: Z(this, _e)._++, view: a };
937
816
  if (e.routes)
938
817
  for (const h of e.routes)
939
- r.push(...u(this, p, je).call(this, h, [...t, e], [...s, f]));
818
+ n.push(...u(this, p, je).call(this, h, [...t, e], [...s, f]));
940
819
  else
941
- r.push({
820
+ n.push({
942
821
  pattern: parent ? z([...t.map((h) => h.path), e.path]) : e.path,
943
822
  meta: {
944
823
  pattern: e.path,
@@ -946,38 +825,38 @@ je = function(e, t = [], s = []) {
946
825
  beforeMatch: e.beforeMatch
947
826
  }
948
827
  });
949
- return r;
828
+ return n;
950
829
  };
951
- const Pt = /(noopener|noreferrer) (noopener|noreferrer)/, Nt = /^[\w-_]+:/;
952
- function Tt(o, e, t = window) {
953
- function s(r) {
954
- return !r || r === o ? null : r.localName !== "a" || r.href === void 0 ? s(r.parentNode) : r;
830
+ const Ct = /(noopener|noreferrer) (noopener|noreferrer)/, Ot = /^[\w-_]+:/;
831
+ function jt(o, e, t = window) {
832
+ function s(n) {
833
+ return !n || n === o ? null : n.localName !== "a" || n.href === void 0 ? s(n.parentNode) : n;
955
834
  }
956
- function n(r) {
957
- if (r.button && r.button !== 0 || r.ctrlKey || r.metaKey || r.altKey || r.shiftKey || r.defaultPrevented)
835
+ function r(n) {
836
+ if (n.button && n.button !== 0 || n.ctrlKey || n.metaKey || n.altKey || n.shiftKey || n.defaultPrevented)
958
837
  return;
959
- const a = s(r.target);
960
- a && (t.location.protocol !== a.protocol || t.location.hostname !== a.hostname || t.location.port !== a.port || a.hasAttribute("data-router-ignore") || a.hasAttribute("download") || a.getAttribute("target") === "_blank" && Pt.test(a.getAttribute("rel")) || Nt.test(a.getAttribute("href")) || (r.preventDefault(), e(a)));
838
+ const a = s(n.target);
839
+ a && (t.location.protocol !== a.protocol || t.location.hostname !== a.hostname || t.location.port !== a.port || a.hasAttribute("data-router-ignore") || a.hasAttribute("download") || a.getAttribute("target") === "_blank" && Ct.test(a.getAttribute("rel")) || Ot.test(a.getAttribute("href")) || (n.preventDefault(), e(a)));
961
840
  }
962
- return o.addEventListener("click", n), function() {
963
- o.removeEventListener("click", n);
841
+ return o.addEventListener("click", r), function() {
842
+ o.removeEventListener("click", r);
964
843
  };
965
844
  }
966
- function Ct(o, e) {
845
+ function Vt(o, e) {
967
846
  for (const t in e) {
968
847
  const s = e[t].toString();
969
848
  o = o.replace(`{${t}}`, s).replace(`{#${t}}`, s);
970
849
  }
971
850
  return o;
972
851
  }
973
- function Ot(o) {
852
+ function Ut(o) {
974
853
  for (const e of o)
975
854
  if (e.meta.redirect) {
976
855
  let t;
977
- if (!se(e.meta.redirect)) if (v(e.meta.redirect)) {
978
- if (t = e.meta.redirect, !Ze(o, t, {
979
- willMatch(n) {
980
- return n !== e;
856
+ if (!se(e.meta.redirect)) if (E(e.meta.redirect)) {
857
+ if (t = e.meta.redirect, !et(o, t, {
858
+ willMatch(r) {
859
+ return r !== e;
981
860
  }
982
861
  }))
983
862
  throw new Error(`Found a redirect to an undefined URL. From '${e.pattern}' to '${e.meta.redirect}'`);
@@ -985,10 +864,131 @@ function Ot(o) {
985
864
  throw new TypeError(`Expected a string or redirect function. Got: ${e.meta.redirect}`);
986
865
  }
987
866
  }
988
- class jt extends Error {
867
+ class It extends Error {
868
+ }
869
+ function qt(o) {
870
+ return Ge`
871
+ <div
872
+ style=${{
873
+ backgroundColor: "#880000",
874
+ color: "#fff",
875
+ padding: "2rem",
876
+ position: "fixed",
877
+ inset: 0,
878
+ fontSize: "20px"
879
+ }}
880
+ >
881
+ <h1 style=${{ marginBottom: "0.5rem" }}>The app has crashed</h1>
882
+ <p style=${{ marginBottom: "0.25rem" }}>
883
+ <span style=${{ fontFamily: "monospace" }}>${o.loggerName}</span>
884
+ ${lt(o.uid, Ge`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${o.uid}]</span>`)}
885
+ ${" "}says:
886
+ </p>
887
+ <blockquote
888
+ style=${{
889
+ backgroundColor: "#991111",
890
+ padding: "0.25em",
891
+ borderRadius: "6px",
892
+ fontFamily: "monospace",
893
+ marginBottom: "1rem"
894
+ }}
895
+ >
896
+ <span
897
+ style=${{
898
+ display: "inline-block",
899
+ backgroundColor: "red",
900
+ padding: "0.1em 0.4em",
901
+ marginRight: "0.5em",
902
+ borderRadius: "4px",
903
+ fontSize: "0.9em",
904
+ fontWeight: "bold"
905
+ }}
906
+ >
907
+ ${o.error.name}
908
+ </span>
909
+ ${o.error.message}
910
+ </blockquote>
911
+
912
+ <p>Please see the browser console for details.</p>
913
+ </div>
914
+ `;
915
+ }
916
+ var ce, J, C, A, G, X, Le, x, ue, D, Ve, Ee;
917
+ class Wt {
918
+ constructor(e) {
919
+ l(this, D);
920
+ l(this, ce);
921
+ l(this, J);
922
+ // Keys ensure only the most recent callback queued with a certain key
923
+ // will be called, keeping DOM operations to a minimum.
924
+ l(this, C, /* @__PURE__ */ new Map());
925
+ // All unkeyed writes are run on every batch.
926
+ l(this, A, []);
927
+ // All read callbacks are run before updates on every batch.
928
+ l(this, G, []);
929
+ l(this, X, !1);
930
+ // When true, batches that would exceed 16ms will be split and deferred to a rAF.
931
+ // This may not be desirable, because while it does prevent hitching it sometimes leaves
932
+ // the state partially rendered for a brief second and certain elements can be seen to update after the fact.
933
+ // But the tradeoff here is snappier navigation with possibly slightly out of date DOM updates on heavy pages.
934
+ l(this, Le, !0);
935
+ l(this, x, 0);
936
+ l(this, ue, new Intl.NumberFormat("en-US", {
937
+ maximumFractionDigits: 2,
938
+ minimumFractionDigits: 0,
939
+ style: "unit",
940
+ unit: "millisecond",
941
+ unitDisplay: "short"
942
+ }));
943
+ m(this, ce, e), m(this, J, e.createLogger("Dolla.batch"));
944
+ }
945
+ /**
946
+ * Queues a callback that runs before the next batch of writes.
947
+ */
948
+ read(e) {
949
+ i(this, G).push(e), u(this, D, Ve).call(this);
950
+ }
951
+ /**
952
+ * Queues a callback to run in the next render batch.
953
+ * Always put DOM mutations in a write callback when possible to help Dolla batch them efficiently.
954
+ */
955
+ write(e, t) {
956
+ t ? i(this, C).set(t, e) : i(this, A).push(e), u(this, D, Ve).call(this);
957
+ }
989
958
  }
990
- var C, fe, O, B, de, me, we, pe, ge, ye, j, g, U, Me;
991
- class Ut {
959
+ ce = new WeakMap(), J = new WeakMap(), C = new WeakMap(), A = new WeakMap(), G = new WeakMap(), X = new WeakMap(), Le = new WeakMap(), x = new WeakMap(), ue = new WeakMap(), D = new WeakSet(), Ve = function() {
960
+ if (!i(this, X)) {
961
+ m(this, X, !0);
962
+ const e = i(this, ce).getEnv() === "development";
963
+ queueMicrotask(() => {
964
+ u(this, D, Ee).call(this, e);
965
+ });
966
+ }
967
+ }, Ee = function(e = !1) {
968
+ const t = performance.now();
969
+ let s = 0;
970
+ const r = i(this, G).length + i(this, C).size + i(this, A).length;
971
+ let n = 0;
972
+ const a = () => (n++, s = performance.now() - t, i(this, Le) && s > 12 && n < r ? (Z(this, x)._++, e && i(this, J).warn(
973
+ `⚠️ Deferring batch to next frame. Performed ${n} of ${r} batched operation${n === 1 ? "" : "s"} in ${i(this, ue).format(s)} (deferral ${i(this, x)}).`
974
+ ), requestAnimationFrame(() => {
975
+ u(this, D, Ee).call(this, e);
976
+ }), !0) : !1), f = [...i(this, C).entries()];
977
+ let h, w;
978
+ for (; w = i(this, G).shift(); )
979
+ if (w(), a()) return;
980
+ for ([h, w] of f)
981
+ if (w(), i(this, C).delete(h), a()) return;
982
+ for (; w = i(this, A).shift(); )
983
+ if (w(), a()) return;
984
+ e && i(this, J)[s > 16 ? "warn" : "info"](
985
+ `${s > 16 ? "⚠️ (>=16ms) " : ""}Executed ${n} operation${n === 1 ? "" : "s"} in ${i(this, ue).format(s)}${i(this, x) > 0 ? ` (after ${i(this, x)} deferral${i(this, x) === 1 ? "" : "s"})` : ""}.`
986
+ ), m(this, x, 0), i(this, G).length || i(this, C).size || i(this, A).length ? queueMicrotask(() => {
987
+ u(this, D, Ee).call(this, e);
988
+ }) : m(this, X, !1);
989
+ };
990
+ var O, fe, j, H, de, me, we, pe, ge, ye, $, g, V, xe;
991
+ class At {
992
992
  constructor() {
993
993
  d(this, "batch");
994
994
  // Remove `private` when there are public methods to call.
@@ -996,19 +996,22 @@ class Ut {
996
996
  d(this, "http");
997
997
  d(this, "i18n");
998
998
  d(this, "router");
999
- l(this, C, !1);
999
+ l(this, O, !1);
1000
1000
  l(this, fe, "production");
1001
- l(this, O);
1002
- l(this, B);
1003
- l(this, de, yt);
1004
- l(this, me, Ge());
1001
+ l(this, j);
1002
+ l(this, H);
1003
+ l(this, de, qt);
1004
+ l(this, me, He());
1005
1005
  l(this, we, []);
1006
1006
  l(this, pe, []);
1007
1007
  l(this, ge, []);
1008
1008
  l(this, ye, []);
1009
- l(this, j, {
1009
+ l(this, $, {
1010
1010
  root: this,
1011
- data: {}
1011
+ data: {},
1012
+ emitter: new ht(),
1013
+ stores: /* @__PURE__ */ new Map(),
1014
+ viewName: "Dolla"
1012
1015
  });
1013
1016
  l(this, g, {
1014
1017
  info: "development",
@@ -1016,26 +1019,26 @@ class Ut {
1016
1019
  warn: "development",
1017
1020
  error: !0
1018
1021
  });
1019
- l(this, U, Be("*,-Dolla.*"));
1022
+ l(this, V, Be("*,-Dolla.*"));
1020
1023
  // Registration functions for modules.
1021
1024
  // All modules will be registered before mount.
1022
- l(this, Me, []);
1025
+ l(this, xe, []);
1023
1026
  d(this, "watch", i(this, me).watch);
1024
1027
  d(this, "createState", Ue);
1025
- d(this, "toState", ht);
1026
- d(this, "toValue", ct);
1027
- d(this, "isState", ut);
1028
+ d(this, "toState", ut);
1029
+ d(this, "toValue", ft);
1030
+ d(this, "isState", dt);
1028
1031
  d(this, "derive", M);
1029
- d(this, "createWatcher", Ge);
1030
- d(this, "createRef", ft);
1031
- d(this, "isRef", dt);
1032
- this.batch = new bt(this), this.stats = new lt(this), this.http = new $t(this), this.i18n = new _t(this), this.router = new Ft(this);
1032
+ d(this, "createWatcher", He);
1033
+ d(this, "createRef", mt);
1034
+ d(this, "isRef", wt);
1035
+ this.batch = new Wt(this), this.stats = new ct(this), this.http = new kt(this), this.i18n = new Mt(this), this.router = new Tt(this);
1033
1036
  }
1034
1037
  /**
1035
1038
  * True when the app is connected to a DOM node and displayed to the user.
1036
1039
  */
1037
1040
  get isMounted() {
1038
- return i(this, C);
1041
+ return i(this, O);
1039
1042
  }
1040
1043
  /**
1041
1044
  * Get the current environment that this app is running in.
@@ -1062,58 +1065,97 @@ class Ut {
1062
1065
  * Returns the HTMLElement Dolla is mounted to. This will return undefined until Dolla.mount() is called.
1063
1066
  */
1064
1067
  getRootElement() {
1065
- return i(this, O);
1068
+ return i(this, j);
1066
1069
  }
1067
1070
  /**
1068
1071
  * Returns the top level view Dolla is rendering inside the root element. This will return undefined until Dolla.mount() is called.
1069
1072
  */
1070
1073
  getRootView() {
1071
- return i(this, B);
1074
+ return i(this, H);
1072
1075
  }
1073
- /**
1074
- * Registers a Dolla module.
1075
- */
1076
- // use<O>(module: DollaModule<O>, options: O) {
1077
- // this.#modules.push(async () => {
1078
- // return module.register({ root: this, options });
1079
- // });
1080
- // return this;
1081
- // }
1082
1076
  /**
1083
1077
  * Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
1084
1078
  */
1085
1079
  set(e, t) {
1086
- return i(this, j).data[e] = t, t;
1080
+ return i(this, $).data[e] = t, t;
1087
1081
  }
1088
1082
  /**
1089
1083
  * Gets the value of a context variable. Returns null if the variable is not set.
1090
1084
  */
1091
1085
  get(e) {
1092
- return i(this, j).data[e] ?? null;
1086
+ return i(this, $).data[e] ?? null;
1093
1087
  }
1094
1088
  /**
1095
1089
  * Returns an object of all context variables stored at the app level.
1096
1090
  */
1097
- getAll() {
1098
- return { ...i(this, j).data };
1091
+ // getAll(): Record<string | symbol, unknown> {
1092
+ // return { ...this.#rootElementContext.data };
1093
+ // }
1094
+ /**
1095
+ * Adds a listener to be called when `eventName` is emitted.
1096
+ */
1097
+ on(e, t) {
1098
+ i(this, $).emitter.on(e, t);
1099
+ }
1100
+ /**
1101
+ * Removes a listener from the list to be called when `eventName` is emitted.
1102
+ */
1103
+ off(e, t) {
1104
+ i(this, $).emitter.off(e, t);
1105
+ }
1106
+ /**
1107
+ * Adds a listener to be called when `eventName` is emitted. The listener is immediately removed after being called once.
1108
+ */
1109
+ once(e, t) {
1110
+ i(this, $).emitter.once(e, t);
1111
+ }
1112
+ /**
1113
+ * Emits a new event to all listeners.
1114
+ */
1115
+ emit(e, t) {
1116
+ return i(this, $).emitter.emit(e, new pt(e, t));
1117
+ }
1118
+ /**
1119
+ * Attaches a new store to this context.
1120
+ */
1121
+ attachStore(e) {
1122
+ if (!e.attach(i(this, $))) {
1123
+ let s = e.name ? `'${e.name}'` : "this store";
1124
+ console.warn(`An instance of ${s} was already attached to this context.`);
1125
+ }
1126
+ }
1127
+ /**
1128
+ * Gets the nearest instance of a store. Throws an error if the store isn't provided higher in the tree.
1129
+ */
1130
+ useStore(e) {
1131
+ if (gt(e)) {
1132
+ const t = e.key, s = i(this, $).stores.get(t);
1133
+ if (s == null)
1134
+ throw new De("Store not found on this context.");
1135
+ return s.value;
1136
+ } else throw yt(e) ? new De(
1137
+ "Received a Store instance. Please pass the Store factory function to useStore without calling it."
1138
+ ) : new De("Invalid store.");
1099
1139
  }
1100
1140
  async mount(e, t) {
1101
- if (i(this, C))
1141
+ if (i(this, O))
1102
1142
  throw new Error("Dolla is already mounted.");
1103
- if (v(e)) {
1104
- const n = document.querySelector(e);
1105
- He(HTMLElement, n, `Selector '${e}' did not match any element.`), m(this, O, n);
1143
+ if (E(e)) {
1144
+ const r = document.querySelector(e);
1145
+ ze(HTMLElement, r, `Selector '${e}' did not match any element.`), m(this, j, r);
1106
1146
  } else
1107
- He(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), m(this, O, e);
1108
- const s = mt(t ?? Qe);
1109
- m(this, B, this.constructView(s.type, s.props)), await Promise.all(i(this, Me).map((n) => n())), await Promise.all(i(this, we).map((n) => n())), i(this, B).mount(i(this, O)), m(this, C, !0);
1110
- for (const n of i(this, pe))
1111
- n();
1147
+ ze(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), m(this, j, e);
1148
+ const s = bt(t ?? Je);
1149
+ m(this, H, this.constructView(s.type, s.props)), await Promise.all(i(this, xe).map((r) => r())), await Promise.all(i(this, we).map((r) => r())), i(this, H).mount(i(this, j)), m(this, O, !0);
1150
+ for (const r of i(this, $).stores.values())
1151
+ r.handleMount();
1152
+ for (const r of i(this, pe))
1153
+ r();
1112
1154
  }
1113
1155
  async unmount() {
1114
1156
  var e;
1115
- if (i(this, C)) {
1116
- await Promise.all(i(this, ge).map((t) => t())), (e = i(this, B)) == null || e.unmount(!1), i(this, me).stopAll(), m(this, C, !1);
1157
+ if (i(this, O)) {
1158
+ await Promise.all(i(this, ge).map((t) => t())), (e = i(this, H)) == null || e.unmount(!1), i(this, me).stopAll(), m(this, O, !1);
1117
1159
  for (const t of i(this, ye))
1118
1160
  t();
1119
1161
  }
@@ -1154,17 +1196,17 @@ class Ut {
1154
1196
  }
1155
1197
  }
1156
1198
  setLogFilter(e) {
1157
- m(this, U, Be(e));
1199
+ m(this, V, Be(e));
1158
1200
  }
1159
1201
  createLogger(e, t) {
1160
- const s = (t == null ? void 0 : t.console) ?? Vt(), n = this;
1202
+ const s = (t == null ? void 0 : t.console) ?? Gt(), r = this;
1161
1203
  return {
1162
- setName(r) {
1163
- return e = r, this;
1204
+ setName(n) {
1205
+ return e = n, this;
1164
1206
  },
1165
1207
  get info() {
1166
- var r;
1167
- if (i(n, g).info === !1 || v(i(n, g).info) && i(n, g).info !== n.getEnv() || !i(r = n, U).call(r, e))
1208
+ var n;
1209
+ if (i(r, g).info === !1 || E(i(r, g).info) && i(r, g).info !== r.getEnv() || !i(n = r, V).call(n, e))
1168
1210
  return be;
1169
1211
  {
1170
1212
  let a = `%c${e}`;
@@ -1179,8 +1221,8 @@ class Ut {
1179
1221
  }
1180
1222
  },
1181
1223
  get log() {
1182
- var r;
1183
- if (i(n, g).log === !1 || v(i(n, g).log) && i(n, g).log !== n.getEnv() || !i(r = n, U).call(r, e))
1224
+ var n;
1225
+ if (i(r, g).log === !1 || E(i(r, g).log) && i(r, g).log !== r.getEnv() || !i(n = r, V).call(n, e))
1184
1226
  return be;
1185
1227
  {
1186
1228
  let a = `%c${e}`;
@@ -1195,8 +1237,8 @@ class Ut {
1195
1237
  }
1196
1238
  },
1197
1239
  get warn() {
1198
- var r;
1199
- if (i(n, g).warn === !1 || v(i(n, g).warn) && i(n, g).warn !== n.getEnv() || !i(r = n, U).call(r, e))
1240
+ var n;
1241
+ if (i(r, g).warn === !1 || E(i(r, g).warn) && i(r, g).warn !== r.getEnv() || !i(n = r, V).call(n, e))
1200
1242
  return be;
1201
1243
  {
1202
1244
  let a = `%c${e}`;
@@ -1211,8 +1253,8 @@ class Ut {
1211
1253
  }
1212
1254
  },
1213
1255
  get error() {
1214
- var r;
1215
- if (i(n, g).error === !1 || v(i(n, g).error) && i(n, g).error !== n.getEnv() || !i(r = n, U).call(r, e))
1256
+ var n;
1257
+ if (i(r, g).error === !1 || E(i(r, g).error) && i(r, g).error !== r.getEnv() || !i(n = r, V).call(n, e))
1216
1258
  return be;
1217
1259
  {
1218
1260
  let a = `%c${e}`;
@@ -1226,12 +1268,12 @@ class Ut {
1226
1268
  );
1227
1269
  }
1228
1270
  },
1229
- crash(r) {
1230
- throw n.isMounted && (n.unmount(), n.constructView(i(n, de), {
1231
- error: r,
1271
+ crash(n) {
1272
+ throw r.isMounted && (r.unmount(), r.constructView(i(r, de), {
1273
+ error: n,
1232
1274
  loggerName: e,
1233
1275
  uid: t == null ? void 0 : t.uid
1234
- }).mount(i(n, O))), r;
1276
+ }).mount(i(r, j))), n;
1235
1277
  }
1236
1278
  };
1237
1279
  }
@@ -1239,48 +1281,50 @@ class Ut {
1239
1281
  *
1240
1282
  */
1241
1283
  constructView(e, t, s = []) {
1242
- return new wt(i(this, j), e, t, s);
1284
+ return new $t(i(this, $), e, t, s);
1243
1285
  }
1244
1286
  /**
1245
1287
  *
1246
1288
  */
1247
1289
  constructMarkup(e) {
1248
- return pt(gt(i(this, j), e));
1290
+ return vt(Et(i(this, $), e));
1249
1291
  }
1250
1292
  }
1251
- C = new WeakMap(), fe = new WeakMap(), O = new WeakMap(), B = new WeakMap(), de = new WeakMap(), me = new WeakMap(), we = new WeakMap(), pe = new WeakMap(), ge = new WeakMap(), ye = new WeakMap(), j = new WeakMap(), g = new WeakMap(), U = new WeakMap(), Me = new WeakMap();
1252
- function Vt() {
1293
+ O = new WeakMap(), fe = new WeakMap(), j = new WeakMap(), H = new WeakMap(), de = new WeakMap(), me = new WeakMap(), we = new WeakMap(), pe = new WeakMap(), ge = new WeakMap(), ye = new WeakMap(), $ = new WeakMap(), g = new WeakMap(), V = new WeakMap(), xe = new WeakMap();
1294
+ function Gt() {
1253
1295
  if (typeof window < "u" && window.console)
1254
1296
  return window.console;
1255
1297
  if (typeof global < "u" && global.console)
1256
1298
  return global.console;
1257
1299
  }
1258
- const ze = new Ut(), Wt = ze.i18n.t.bind(ze.i18n);
1259
- function At(o) {
1300
+ const Ke = new At(), zt = Ke.i18n.t.bind(Ke.i18n);
1301
+ function Kt(o) {
1260
1302
  typeof window < "u" && (window.DOLLA_DEV_DEBUG = o);
1261
1303
  }
1262
- function Gt() {
1304
+ function Qt() {
1263
1305
  return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
1264
1306
  }
1265
1307
  export {
1266
- it as cond,
1267
- mt as createMarkup,
1268
- ft as createRef,
1308
+ lt as cond,
1309
+ bt as createMarkup,
1310
+ mt as createRef,
1269
1311
  Ue as createState,
1312
+ Yt as createStore,
1313
+ Zt as createView,
1270
1314
  at as deepEqual,
1271
- ze as default,
1315
+ Ke as default,
1272
1316
  M as derive,
1273
- Gt as getDevDebug,
1274
- qe as html,
1275
- dt as isRef,
1276
- ut as isState,
1277
- zt as portal,
1278
- Kt as repeat,
1279
- At as setDevDebug,
1317
+ Qt as getDevDebug,
1318
+ Ge as html,
1319
+ wt as isRef,
1320
+ dt as isState,
1321
+ es as portal,
1322
+ ts as repeat,
1323
+ Kt as setDevDebug,
1280
1324
  We as shallowEqual,
1281
- Qt as strictEqual,
1282
- Wt as t,
1283
- ht as toState,
1284
- ct as toValue
1325
+ ss as strictEqual,
1326
+ zt as t,
1327
+ ut as toState,
1328
+ ft as toValue
1285
1329
  };
1286
1330
  //# sourceMappingURL=index.js.map