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

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