@manyducks.co/dolla 2.0.0-alpha.12 → 2.0.0-alpha.14

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,22 +1,22 @@
1
- var kt = Object.defineProperty;
2
- var st = (i) => {
1
+ var Pt = Object.defineProperty;
2
+ var ot = (i) => {
3
3
  throw TypeError(i);
4
4
  };
5
- var Et = (i, e, t) => e in i ? kt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
6
- var S = (i, e, t) => Et(i, typeof e != "symbol" ? e + "" : e, t), Be = (i, e, t) => e.has(i) || st("Cannot " + t);
7
- var s = (i, e, t) => (Be(i, e, "read from private field"), t ? t.call(i) : e.get(i)), d = (i, e, t) => e.has(i) ? st("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), b = (i, e, t, n) => (Be(i, e, "write to private field"), n ? n.call(i, t) : e.set(i, t), t), k = (i, e, t) => (Be(i, e, "access private method"), t);
8
- var it = (i, e, t, n) => ({
5
+ var St = (i, e, t) => e in i ? Pt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
6
+ var S = (i, e, t) => St(i, typeof e != "symbol" ? e + "" : e, t), Qe = (i, e, t) => e.has(i) || ot("Cannot " + t);
7
+ var s = (i, e, t) => (Qe(i, e, "read from private field"), t ? t.call(i) : e.get(i)), f = (i, e, t) => e.has(i) ? ot("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), b = (i, e, t, r) => (Qe(i, e, "write to private field"), r ? r.call(i, t) : e.set(i, t), t), E = (i, e, t) => (Qe(i, e, "access private method"), t);
8
+ var lt = (i, e, t, r) => ({
9
9
  set _(a) {
10
10
  b(i, e, a, t);
11
11
  },
12
12
  get _() {
13
- return s(i, e, n);
13
+ return s(i, e, r);
14
14
  }
15
15
  });
16
- import { h as ot, c as Pt, i as Ke, t as Qe, d as ye, a as St, b as at, e as q, f as lt, g as oe, j as pt, k as Rt, w as gt, P as mt, l as ct, m as xt, n as Lt, v as Nt, o as Ot, p as Mt, q as ut, r as ht, s as Tt, u as Ae, x as De, y as jt, z as At, A as Dt } from "./passthrough-Bz5ZF4jn.js";
17
- import { B as cr, C as ur, D as hr } from "./passthrough-Bz5ZF4jn.js";
18
- function _t(i) {
19
- return ot`
16
+ import { h as ct, c as Lt, i as Je, d as we, a as Rt, b as it, e as V, t as ut, f as se, g as wt, j as xt, k as Ye, P as yt, l as ht, m as Ot, n as Nt, o as ft, v as Mt, p as Tt, q as Dt, r as dt, s as pt, u as _t, w as je, x as Fe, y as At, z as jt, A as Ft } from "./passthrough-MfPKbG0F.js";
17
+ import { B as fr, C as dr, D as pr } from "./passthrough-MfPKbG0F.js";
18
+ function Ct(i) {
19
+ return ct`
20
20
  <div
21
21
  style=${{
22
22
  backgroundColor: "#880000",
@@ -30,7 +30,7 @@ function _t(i) {
30
30
  <h1 style=${{ marginBottom: "0.5rem" }}>The app has crashed</h1>
31
31
  <p style=${{ marginBottom: "0.25rem" }}>
32
32
  <span style=${{ fontFamily: "monospace" }}>${i.loggerName}</span>
33
- ${Pt(i.uid, ot`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${i.uid}]</span>`)}
33
+ ${Lt(i.uid, ct`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${i.uid}]</span>`)}
34
34
  ${" "}says:
35
35
  </p>
36
36
  <blockquote
@@ -62,12 +62,12 @@ function _t(i) {
62
62
  </div>
63
63
  `;
64
64
  }
65
- var X, Ge, T, _;
66
- class Ct {
65
+ var Q, Be, T, j;
66
+ class Vt {
67
67
  constructor() {
68
- d(this, T);
69
- d(this, X, []);
70
- d(this, Ge, Vt());
68
+ f(this, T);
69
+ f(this, Q, []);
70
+ f(this, Be, qt());
71
71
  }
72
72
  /**
73
73
  * Adds a new middleware that will apply to subsequent requests.
@@ -76,65 +76,65 @@ class Ct {
76
76
  * @param middleware - A middleware function that will intercept requests.
77
77
  */
78
78
  use(e) {
79
- return s(this, X).push(e), () => {
80
- s(this, X).splice(s(this, X).indexOf(e), 1);
79
+ return s(this, Q).push(e), () => {
80
+ s(this, Q).splice(s(this, Q).indexOf(e), 1);
81
81
  };
82
82
  }
83
83
  async get(e, t) {
84
- return k(this, T, _).call(this, "get", e, t);
84
+ return E(this, T, j).call(this, "get", e, t);
85
85
  }
86
86
  async put(e, t) {
87
- return k(this, T, _).call(this, "put", e, t);
87
+ return E(this, T, j).call(this, "put", e, t);
88
88
  }
89
89
  async patch(e, t) {
90
- return k(this, T, _).call(this, "patch", e, t);
90
+ return E(this, T, j).call(this, "patch", e, t);
91
91
  }
92
92
  async post(e, t) {
93
- return k(this, T, _).call(this, "post", e, t);
93
+ return E(this, T, j).call(this, "post", e, t);
94
94
  }
95
95
  async delete(e, t) {
96
- return k(this, T, _).call(this, "delete", e, t);
96
+ return E(this, T, j).call(this, "delete", e, t);
97
97
  }
98
98
  async head(e, t) {
99
- return k(this, T, _).call(this, "head", e, t);
99
+ return E(this, T, j).call(this, "head", e, t);
100
100
  }
101
101
  async options(e, t) {
102
- return k(this, T, _).call(this, "options", e, t);
102
+ return E(this, T, j).call(this, "options", e, t);
103
103
  }
104
104
  async trace(e, t) {
105
- return k(this, T, _).call(this, "trace", e, t);
105
+ return E(this, T, j).call(this, "trace", e, t);
106
106
  }
107
107
  }
108
- X = new WeakMap(), Ge = new WeakMap(), T = new WeakSet(), _ = async function(e, t, n) {
109
- return qt({
110
- ...n,
108
+ Q = new WeakMap(), Be = new WeakMap(), T = new WeakSet(), j = async function(e, t, r) {
109
+ return Ht({
110
+ ...r,
111
111
  method: e,
112
112
  uri: t,
113
- middleware: s(this, X),
114
- fetch: s(this, Ge)
113
+ middleware: s(this, Q),
114
+ fetch: s(this, Be)
115
115
  });
116
116
  };
117
- function Vt() {
117
+ function qt() {
118
118
  if (typeof window < "u" && window.fetch)
119
119
  return window.fetch.bind(window);
120
120
  if (typeof global < "u" && global.fetch)
121
121
  return global.fetch.bind(global);
122
122
  throw new Error("Running in neither browser nor node. Please run this app in one of the supported environments.");
123
123
  }
124
- class Ft extends Error {
124
+ class Ut extends Error {
125
125
  constructor(t) {
126
- const { status: n, statusText: a, method: r, uri: o } = t, h = `${n} ${a}: Request failed (${r.toUpperCase()} ${o})`;
126
+ const { status: r, statusText: a, method: n, uri: o } = t, h = `${r} ${a}: Request failed (${n.toUpperCase()} ${o})`;
127
127
  super(h);
128
128
  S(this, "response");
129
129
  this.response = t;
130
130
  }
131
131
  }
132
- async function qt(i) {
133
- const { headers: e, query: t, fetch: n, middleware: a } = i, r = {
132
+ async function Ht(i) {
133
+ const { headers: e, query: t, fetch: r, middleware: a } = i, n = {
134
134
  method: i.method,
135
135
  uri: i.uri,
136
136
  get sameOrigin() {
137
- return !r.uri.startsWith("http");
137
+ return !n.uri.startsWith("http");
138
138
  },
139
139
  query: new URLSearchParams(),
140
140
  headers: new Headers(),
@@ -142,81 +142,80 @@ async function qt(i) {
142
142
  };
143
143
  if (e)
144
144
  if (e instanceof Map || e instanceof Headers)
145
- e.forEach((l, m) => {
146
- r.headers.set(m, l);
145
+ e.forEach((l, d) => {
146
+ n.headers.set(d, l);
147
147
  });
148
148
  else if (e != null && typeof e == "object" && !Array.isArray(e))
149
149
  for (const l in e) {
150
- const m = e[l];
151
- m instanceof Date ? r.headers.set(l, m.toISOString()) : m != null && r.headers.set(l, String(m));
150
+ const d = e[l];
151
+ d instanceof Date ? n.headers.set(l, d.toISOString()) : d != null && n.headers.set(l, String(d));
152
152
  }
153
153
  else
154
154
  throw new TypeError(`Unknown headers type. Got: ${e}`);
155
155
  if (t)
156
156
  if (t instanceof Map || t instanceof URLSearchParams)
157
- t.forEach((l, m) => {
158
- r.query.set(m, l);
157
+ t.forEach((l, d) => {
158
+ n.query.set(d, l);
159
159
  });
160
160
  else if (t != null && typeof t == "object" && !Array.isArray(t))
161
161
  for (const l in t) {
162
- const m = t[l];
163
- m instanceof Date ? r.query.set(l, m.toISOString()) : m != null && r.query.set(l, String(m));
162
+ const d = t[l];
163
+ d instanceof Date ? n.query.set(l, d.toISOString()) : d != null && n.query.set(l, String(d));
164
164
  }
165
165
  else
166
166
  throw new TypeError(`Unknown query params type. Got: ${t}`);
167
167
  let o;
168
168
  const h = async () => {
169
- const l = r.query.toString(), m = l.length > 0 ? r.uri + "?" + l : r.uri;
170
- let f;
171
- !r.headers.has("content-type") && Ke(r.body) ? (r.headers.set("content-type", "application/json"), f = JSON.stringify(r.body)) : f = r.body;
172
- const g = await n(m, {
173
- method: r.method,
174
- headers: r.headers,
175
- body: f
176
- }), u = Object.fromEntries(g.headers.entries()), y = u["content-type"];
177
- let E;
178
- y != null && y.includes("application/json") ? E = await g.json() : y != null && y.includes("application/x-www-form-urlencoded") ? E = await g.formData() : E = await g.text(), o = {
179
- method: r.method,
180
- uri: r.uri,
181
- status: g.status,
182
- statusText: g.statusText,
169
+ const l = n.query.toString(), d = l.length > 0 ? n.uri + "?" + l : n.uri;
170
+ let g;
171
+ !n.headers.has("content-type") && Je(n.body) ? (n.headers.set("content-type", "application/json"), g = JSON.stringify(n.body)) : g = n.body;
172
+ const m = await r(d, {
173
+ method: n.method,
174
+ headers: n.headers,
175
+ body: g
176
+ }), u = Object.fromEntries(m.headers.entries()), y = u["content-type"];
177
+ let k;
178
+ y != null && y.includes("application/json") ? k = await m.json() : y != null && y.includes("application/x-www-form-urlencoded") ? k = await m.formData() : k = await m.text(), o = {
179
+ method: n.method,
180
+ uri: n.uri,
181
+ status: m.status,
182
+ statusText: m.statusText,
183
183
  headers: u,
184
- body: E
184
+ body: k
185
185
  };
186
186
  };
187
187
  if (a.length > 0) {
188
- const l = (m = 0) => {
189
- const f = a[m], g = a[m + 1] ? l(m + 1) : h;
190
- return async () => f(r, async () => (await g(), o));
188
+ const l = (d = 0) => {
189
+ const g = a[d], m = a[d + 1] ? l(d + 1) : h;
190
+ return async () => g(n, async () => (await m(), o));
191
191
  };
192
192
  await l()();
193
193
  } else
194
194
  await h();
195
195
  if (o.status < 200 || o.status >= 400)
196
- throw new Ft(o);
196
+ throw new Ut(o);
197
197
  return o;
198
198
  }
199
- const Ut = Qe("[NO LANGUAGE SET]");
200
- var We, le, ne, Je, wt;
201
- class Ht {
199
+ var ze, ie, te, Xe, bt;
200
+ class It {
202
201
  constructor(e, t) {
203
- d(this, ne);
202
+ f(this, te);
204
203
  S(this, "dolla");
205
204
  S(this, "config");
206
- d(this, We, !1);
207
- d(this, le, /* @__PURE__ */ new Map());
205
+ f(this, ze, !1);
206
+ f(this, ie, /* @__PURE__ */ new Map());
208
207
  this.config = e, this.dolla = t;
209
208
  }
210
209
  async load() {
211
210
  let e;
212
- if (!s(this, We)) {
213
- if (at(this.config.fetch)) {
214
- if (e = await this.config.fetch(), !Ke(e))
211
+ if (!s(this, ze)) {
212
+ if (it(this.config.fetch)) {
213
+ if (e = await this.config.fetch(), !Je(e))
215
214
  throw new Error(`Fetch function did not return an object of language strings: ${e}`);
216
- } else if (q(this.config.path)) {
215
+ } else if (V(this.config.path)) {
217
216
  const t = await this.dolla.http.get(this.config.path);
218
217
  if (t.status >= 200 && t.status < 300)
219
- if (Ke(t.body))
218
+ if (Je(t.body))
220
219
  e = t.body;
221
220
  else
222
221
  throw new Error(
@@ -226,144 +225,144 @@ class Ht {
226
225
  throw new Error("HTTP request failed.");
227
226
  }
228
227
  }
229
- if (e == null)
228
+ if (e) {
229
+ const t = E(this, te, Xe).call(this, e);
230
+ for (const r of t)
231
+ s(this, ie).set(r[0], r[1]);
232
+ } else
230
233
  throw new Error("Language could not be loaded.");
231
- {
232
- const t = k(this, ne, Je).call(this, e);
233
- for (const n of t)
234
- s(this, le).set(n[0], n[1]);
235
- console.log(t);
236
- }
237
234
  }
238
235
  getTemplate(e) {
239
- return s(this, le).get(e) ?? null;
236
+ return s(this, ie).get(e) ?? {
237
+ segments: [{ type: 0, text: `[MISSING: ${e}]` }]
238
+ };
240
239
  }
241
240
  hasTemplate(e) {
242
- return s(this, le).has(e);
241
+ return s(this, ie).has(e);
243
242
  }
244
243
  }
245
- We = new WeakMap(), le = new WeakMap(), ne = new WeakSet(), Je = function(e, t = []) {
246
- const n = [];
244
+ ze = new WeakMap(), ie = new WeakMap(), te = new WeakSet(), Xe = function(e, t = []) {
245
+ const r = [];
247
246
  for (const a in e)
248
- switch (lt(e[a])) {
247
+ switch (ut(e[a])) {
249
248
  case "string":
250
- n.push([[...t, a].join("."), k(this, ne, wt).call(this, e[a])]);
249
+ r.push([[...t, a].join("."), E(this, te, bt).call(this, e[a])]);
251
250
  break;
252
251
  case "object":
253
- n.push(...k(this, ne, Je).call(this, e[a], [...t, a]));
252
+ r.push(...E(this, te, Xe).call(this, e[a], [...t, a]));
254
253
  break;
255
254
  default:
256
255
  throw new Error(
257
- `Expected to find a string or object at ${[...t, a].join(".")}. Got: ${lt(e[a])}`
256
+ `Expected to find a string or object at ${[...t, a].join(".")}. Got: ${ut(e[a])}`
258
257
  );
259
258
  }
260
- return n;
261
- }, wt = function(e) {
259
+ return r;
260
+ }, bt = function(e) {
262
261
  let t;
263
262
  ((u) => {
264
263
  u[u.Static = 0] = "Static", u[u.ValueName = 1] = "ValueName", u[u.FormatName = 2] = "FormatName", u[u.FormatOptionName = 3] = "FormatOptionName", u[u.FormatOptionValue = 4] = "FormatOptionValue", u[u.FormatOptionEnd = 5] = "FormatOptionEnd";
265
264
  })(t || (t = {}));
266
- const n = {
265
+ const r = {
267
266
  segments: []
268
267
  };
269
- let a = "", r = 0, o = 0, h, l, m;
270
- const f = () => {
268
+ let a = "", n = 0, o = 0, h, l, d;
269
+ const g = () => {
271
270
  h = {
272
271
  type: 1,
273
272
  name: "",
274
273
  formats: []
275
274
  };
276
- }, g = () => {
275
+ }, m = () => {
277
276
  l = {
278
277
  name: "",
279
278
  options: {}
280
279
  };
281
280
  };
282
- for (; r < e.length; ) {
283
- if (o !== 0 && e[r] === " ") {
284
- r++;
281
+ for (; n < e.length; ) {
282
+ if (o !== 0 && e[n] === " ") {
283
+ n++;
285
284
  continue;
286
285
  }
287
286
  switch (o) {
288
287
  case 0:
289
- e[r] === "{" && e[r + 1] === "{" ? (o = 1, r += 2, a.length > 0 && (n.segments.push({ type: 0, text: a }), a = ""), f()) : (a += e[r], r++);
288
+ e[n] === "{" && e[n + 1] === "{" ? (o = 1, n += 2, a.length > 0 && (r.segments.push({ type: 0, text: a }), a = ""), g()) : (a += e[n], n++);
290
289
  break;
291
290
  case 1:
292
- e[r] === "|" ? (o = 2, r += 1, h.name = a, a = "", g()) : e[r] === "}" && e[r + 1] === "}" ? (o = 0, r += 2, h.name = a, a = "", n.segments.push(h)) : (a += e[r], r++);
291
+ e[n] === "|" ? (o = 2, n += 1, h.name = a, a = "", m()) : e[n] === "}" && e[n + 1] === "}" ? (o = 0, n += 2, h.name = a, a = "", r.segments.push(h)) : (a += e[n], n++);
293
292
  break;
294
293
  case 2:
295
- e[r] === "(" ? (o = 3, r += 1, l.name = a, a = "") : e[r] === "}" && e[r + 1] === "}" ? (o = 0, r += 2, h.formats.push(l), n.segments.push(h)) : (a += e[r], r++);
294
+ e[n] === "(" ? (o = 3, n += 1, l.name = a, a = "") : e[n] === "}" && e[n + 1] === "}" ? (o = 0, n += 2, h.formats.push(l), r.segments.push(h)) : (a += e[n], n++);
296
295
  break;
297
296
  case 3:
298
- e[r] === ")" || (e[r] === ":" ? (o = 4, r += 1, m = a, a = "") : e[r] === "}" && e[r + 1] === "}" || (a += e[r], r++));
297
+ e[n] === ")" || (e[n] === ":" ? (o = 4, n += 1, d = a, a = "") : e[n] === "}" && e[n + 1] === "}" || (a += e[n], n++));
299
298
  break;
300
299
  case 4:
301
- e[r] === ")" ? (o = 5, r += 1, l.options[m] = a, a = "", h.formats.push(l)) : e[r] === "," ? (o = 3, r += 1, l.options[m] = a, a = "") : e[r] === "}" && e[r + 1] === "}" || (a += e[r], r++);
300
+ e[n] === ")" ? (o = 5, n += 1, l.options[d] = a, a = "", h.formats.push(l)) : e[n] === "," ? (o = 3, n += 1, l.options[d] = a, a = "") : e[n] === "}" && e[n + 1] === "}" || (a += e[n], n++);
302
301
  break;
303
302
  case 5:
304
- e[r] === "|" ? (o = 2, r += 1, g()) : e[r] === "}" && e[r + 1] === "}" && (o = 0, r += 2, n.segments.push(h));
303
+ e[n] === "|" ? (o = 2, n += 1, m()) : e[n] === "}" && e[n + 1] === "}" && (o = 0, n += 2, r.segments.push(h));
305
304
  break;
306
305
  }
307
306
  }
308
- return o === 0 && a.length > 0 && n.segments.push({ type: 0, text: a }), n;
307
+ return o === 0 && a.length > 0 && r.segments.push({ type: 0, text: a }), r;
309
308
  };
310
- var ve, U, L, $e, H, ke, Ee, N, yt, Ye, Xe, Ze, bt;
311
- class It {
309
+ var be, q, x, ve, $e, Ee, ke, O, vt, Ze, et, tt, $t;
310
+ class Wt {
312
311
  constructor(e) {
313
- d(this, N);
314
- d(this, ve);
315
- d(this, U);
316
- d(this, L, /* @__PURE__ */ new Map());
317
- d(this, $e, []);
318
- d(this, H, /* @__PURE__ */ new Map());
319
- d(this, ke, "auto");
312
+ f(this, O);
313
+ f(this, be);
314
+ f(this, q);
315
+ f(this, x, /* @__PURE__ */ new Map());
316
+ f(this, ve, []);
317
+ f(this, $e, /* @__PURE__ */ new Map());
318
+ f(this, Ee, "auto");
320
319
  S(this, "$locale");
321
- d(this, Ee);
322
- b(this, ve, e), b(this, U, e.createLogger("dolla/i18n"));
323
- const [t, n] = oe();
324
- this.$locale = t, b(this, Ee, n), s(this, H).set("number", (a, r, o) => k(this, N, Ye).call(this, Number(r), o)), s(this, H).set("datetime", (a, r, o) => k(this, N, Xe).call(this, r, o)), s(this, H).set("list", (a, r, o) => k(this, N, Ze).call(this, r, o)), e.beforeMount(async () => {
325
- s(this, L).size > 0 && await this.setLocale(s(this, ke));
320
+ f(this, ke);
321
+ b(this, be, e), b(this, q, e.createLogger("dolla/i18n"));
322
+ const [t, r] = se();
323
+ this.$locale = t, b(this, ke, r), this.addFormat("number", (a, n, o) => E(this, O, Ze).call(this, Number(n), o)), this.addFormat("datetime", (a, n, o) => E(this, O, et).call(this, n, o)), this.addFormat("list", (a, n, o) => E(this, O, tt).call(this, n, o)), e.beforeMount(async () => {
324
+ s(this, x).size > 0 && await this.setLocale(s(this, Ee));
326
325
  });
327
326
  }
328
327
  get locales() {
329
- return [...s(this, L).keys()];
328
+ return [...s(this, x).keys()];
330
329
  }
331
330
  setup(e) {
332
331
  if (e.translations.forEach((t) => {
333
- s(this, L).set(t.locale, new Ht(t, s(this, ve)));
332
+ s(this, x).set(t.locale, new It(t, s(this, be)));
334
333
  }), e.locale && e.locale !== "auto") {
335
- if (!e.translations.some((n) => n.locale === e.locale))
334
+ if (!e.translations.some((r) => r.locale === e.locale))
336
335
  throw new Error(`Initial locale '${e.locale}' is not registered in the locales array.`);
337
- b(this, ke, e.locale);
336
+ b(this, Ee, e.locale);
338
337
  }
339
- s(this, U).info(
340
- `${s(this, L).size} language${s(this, L).size === 1 ? "" : "s"} supported: '${[...s(this, L).keys()].join("', '")}'`
338
+ s(this, q).info(
339
+ `${s(this, x).size} language${s(this, x).size === 1 ? "" : "s"} supported: '${[...s(this, x).keys()].join("', '")}'`
341
340
  );
342
341
  }
343
342
  async setLocale(e) {
344
343
  var a;
345
344
  let t;
346
345
  if (e === "auto") {
347
- let r = [];
346
+ let n = [];
348
347
  if (typeof navigator == "object") {
349
348
  const o = navigator;
350
- ((a = o.languages) == null ? void 0 : a.length) > 0 ? r.push(...o.languages) : o.language ? r.push(o.language) : o.browserLanguage ? r.push(o.browserLanguage) : o.userLanguage && r.push(o.userLanguage);
349
+ ((a = o.languages) == null ? void 0 : a.length) > 0 ? n.push(...o.languages) : o.language ? n.push(o.language) : o.browserLanguage ? n.push(o.browserLanguage) : o.userLanguage && n.push(o.userLanguage);
351
350
  }
352
- for (const o of r)
353
- s(this, L).has(o) && (t = o);
351
+ for (const o of n)
352
+ s(this, x).has(o) && (t = o);
354
353
  } else
355
- s(this, L).has(e) && (t = e);
354
+ s(this, x).has(e) && (t = e);
356
355
  if (t == null) {
357
- const r = s(this, L).keys().next().value;
358
- r && (t = r);
356
+ const n = s(this, x).keys().next().value;
357
+ n && (t = n);
359
358
  }
360
- if (!t || !s(this, L).has(t))
361
- throw new Error(`Language '${e}' is not configured for this app.`);
362
- const n = s(this, L).get(t);
359
+ if (!t || !s(this, x).has(t))
360
+ throw new Error(`Locale '${e}' has no translation.`);
361
+ const r = s(this, x).get(t);
363
362
  try {
364
- await n.load(), b(this, $e, []), s(this, Ee).call(this, t), s(this, U).info("set language to " + t);
365
- } catch (r) {
366
- r instanceof Error && s(this, U).crash(r);
363
+ await r.load(), b(this, ve, []), s(this, ke).call(this, t), s(this, q).info("set language to " + t);
364
+ } catch (n) {
365
+ n instanceof Error && s(this, q).crash(n);
367
366
  }
368
367
  }
369
368
  /**
@@ -380,32 +379,34 @@ class It {
380
379
  throw new Error(
381
380
  `The 't' function cannot be destructured. If you need a standalone version you can import it like so: 'import { t } from "@manyducks.co/dolla"'`
382
381
  );
383
- if (!this.$locale.get())
384
- return Ut;
385
- let n = [], a = [];
386
- for (const r in t)
387
- n.push(r), a.push(t[r]);
388
- return ye(
389
- [this.$locale, ...a],
390
- (r, ...o) => k(this, N, yt).call(this, r, e, n, ...o)
391
- );
382
+ let r = [], a = [];
383
+ for (const n in t)
384
+ r.push(n), a.push(t[n]);
385
+ return we([this.$locale, ...a], (n, ...o) => {
386
+ if (n == null)
387
+ return "[NO LOCALE SET]";
388
+ const h = {};
389
+ for (let l = 0; l < o.length; l++)
390
+ h[r[l]] = o[l];
391
+ return E(this, O, vt).call(this, n, e, h);
392
+ });
392
393
  }
393
394
  /**
394
395
  * Add a custom format callback.
395
396
  *
396
397
  * @example
397
- * Dolla.i18n.addFormat("myCurrency", (locale, value, options) => {
398
- * // ...
398
+ * Dolla.i18n.addFormat("uppercase", (locale, value, options) => {
399
+ * return value.toUpperCase();
399
400
  * });
400
401
  *
401
402
  * {
402
- * "exampleKey": "{{count | myCurrency}} dollars"
403
+ * "greeting": "Hello, {{name|uppercase}}!"
403
404
  * }
404
405
  *
405
- * t("exampleKey", {count: 5}); // State<"&5 dollars">
406
+ * t("greeting", {name: "world"}); // State<"Hello, WORLD!">
406
407
  */
407
408
  addFormat(e, t) {
408
- s(this, H).set(e, t);
409
+ s(this, $e).set(e, t);
409
410
  }
410
411
  /**
411
412
  * Creates an `Intl.Collator` configured for the current locale.
@@ -422,7 +423,7 @@ class It {
422
423
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
423
424
  */
424
425
  number(e, t) {
425
- return ye([this.$locale, e], (n, a) => k(this, N, Ye).call(this, a, t));
426
+ return we([this.$locale, e], (r, a) => E(this, O, Ze).call(this, a, t));
426
427
  }
427
428
  /**
428
429
  * Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
@@ -434,7 +435,7 @@ class It {
434
435
  * const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
435
436
  */
436
437
  dateTime(e, t) {
437
- return ye([this.$locale, e], (n, a) => k(this, N, Xe).call(this, a, t));
438
+ return we([this.$locale, e], (r, a) => E(this, O, et).call(this, a, t));
438
439
  }
439
440
  /**
440
441
  * Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
@@ -446,87 +447,83 @@ class It {
446
447
  * const $formatted = Dolla.i18n.list(list, { });
447
448
  */
448
449
  list(e, t) {
449
- return ye([this.$locale, e], (n, a) => k(this, N, Ze).call(this, a, t));
450
+ return we([this.$locale, e], (r, a) => E(this, O, tt).call(this, a, t));
450
451
  }
451
452
  }
452
- ve = new WeakMap(), U = new WeakMap(), L = new WeakMap(), $e = new WeakMap(), H = new WeakMap(), ke = new WeakMap(), Ee = new WeakMap(), N = new WeakSet(), yt = function(e, t, n, ...a) {
453
- const r = {};
454
- for (let f = 0; f < a.length; f++)
455
- r[n[f]] = a[f];
456
- const o = k(this, N, bt).call(this, t, r);
457
- if (o) return o;
458
- const h = s(this, L).get(e);
453
+ be = new WeakMap(), q = new WeakMap(), x = new WeakMap(), ve = new WeakMap(), $e = new WeakMap(), Ee = new WeakMap(), ke = new WeakMap(), O = new WeakSet(), vt = function(e, t, r) {
454
+ var l;
455
+ const a = E(this, O, $t).call(this, t, r);
456
+ if (a) return a;
457
+ const n = s(this, x).get(e);
459
458
  if (r.context != null && (t += "_" + r.context), r.count != null)
460
459
  if (r.ordinal) {
461
- const f = `${t}_ordinal_(=${r.count})`;
462
- h.hasTemplate(f) ? t = f : t += "_ordinal_" + new Intl.PluralRules(e, { type: "ordinal" }).select(r.count);
460
+ const d = `${t}_ordinal_(=${r.count})`;
461
+ n.hasTemplate(d) ? t = d : t += "_ordinal_" + new Intl.PluralRules(e, { type: "ordinal" }).select(r.count);
463
462
  } else {
464
- const f = `${t}_(=${r.count})`;
465
- h.hasTemplate(f) ? t = f : t += "_" + new Intl.PluralRules(e).select(r.count);
463
+ const d = `${t}_(=${r.count})`;
464
+ n.hasTemplate(d) ? t = d : t += "_" + new Intl.PluralRules(e).select(r.count);
466
465
  }
467
- const l = h.getTemplate(t) || {
468
- segments: [{ type: 0, text: `[MISSING: ${t}]` }]
469
- };
470
- let m = "";
471
- for (const f of l.segments)
472
- if (f.type === 0)
473
- m += f.text;
474
- else if (f.type === 1) {
475
- const g = [...f.formats];
476
- let u = Gt(r, f.name);
477
- f.name === "count" && g.length === 0 && g.push({ name: "number", options: {} });
478
- for (const y of g) {
479
- const E = s(this, H).get(y.name);
480
- if (E == null) {
481
- const V = new Error(
482
- `Failed to load format '${y.name}' when processing '${t}', template: ${l}`
466
+ const o = n.getTemplate(t);
467
+ let h = "";
468
+ for (const d of o.segments)
469
+ if (d.type === 0)
470
+ h += d.text;
471
+ else if (d.type === 1) {
472
+ let g = Gt(r, d.name);
473
+ const m = ((l = r.formatOverrides) == null ? void 0 : l[d.name]) ?? [...d.formats];
474
+ d.name === "count" && m.length === 0 && m.push({ name: "number", options: {} });
475
+ for (const u of m) {
476
+ const y = s(this, $e).get(u.name);
477
+ if (y == null) {
478
+ const k = new Error(
479
+ `Failed to load format '${u.name}' when processing '${t}', template: ${o}`
483
480
  );
484
- throw s(this, U).crash(V), V;
481
+ throw s(this, q).crash(k), k;
485
482
  }
486
- u = E(e, u, y.options);
483
+ g = y(e, g, u.options);
487
484
  }
488
- m += u;
485
+ h += g;
489
486
  }
490
- return m;
491
- }, Ye = function(e, t) {
487
+ return h;
488
+ }, Ze = function(e, t) {
492
489
  return new Intl.NumberFormat(this.$locale.get(), t).format(e);
493
- }, Xe = function(e, t) {
490
+ }, et = function(e, t) {
494
491
  return new Intl.DateTimeFormat(this.$locale.get(), t).format(
495
492
  typeof e == "string" ? new Date(e) : e
496
493
  );
497
- }, Ze = function(e, t) {
494
+ }, tt = function(e, t) {
498
495
  return new Intl.ListFormat(this.$locale.get(), t).format(e);
499
496
  }, // relativeTime(): State<string> {
500
497
  // }
501
- bt = function(e, t) {
502
- for (const n of s(this, $e))
503
- if (n[0] === e && St(n[1], t))
504
- return n[2];
498
+ $t = function(e, t) {
499
+ for (const r of s(this, ve))
500
+ if (r[0] === e && Rt(r[1], t))
501
+ return r[2];
505
502
  };
506
503
  function Gt(i, e) {
507
504
  const t = String(e).split(/[\.\[\]]/).filter((a) => a.trim() !== "");
508
- let n = i;
505
+ let r = i;
509
506
  for (; t.length > 0; ) {
510
507
  const a = t.shift();
511
- n != null ? n = n[a] : n = void 0;
508
+ r != null ? r = r[a] : r = void 0;
512
509
  }
513
- return n;
510
+ return r;
514
511
  }
515
- var Z, Pe, I, G, ce, C, ue, _e;
516
- class Wt {
512
+ var J, Pe, U, H, oe, F, le, Ce;
513
+ class Bt {
517
514
  constructor(e) {
518
- d(this, ue);
519
- d(this, Z);
520
- d(this, Pe);
515
+ f(this, le);
516
+ f(this, J);
517
+ f(this, Pe);
521
518
  // Keyed updates ensure only the most recent callback queued with a certain key
522
519
  // will be called, keeping DOM operations to a minimum.
523
- d(this, I, /* @__PURE__ */ new Map());
520
+ f(this, U, /* @__PURE__ */ new Map());
524
521
  // All unkeyed updates are run on every batch.
525
- d(this, G, []);
522
+ f(this, H, []);
526
523
  // All read callbacks are run before updates on every batch.
527
- d(this, ce, []);
528
- d(this, C, !1);
529
- b(this, Z, e), b(this, Pe, e.createLogger("dolla/render"));
524
+ f(this, oe, []);
525
+ f(this, F, !1);
526
+ b(this, J, e), b(this, Pe, e.createLogger("dolla/render"));
530
527
  }
531
528
  /**
532
529
  * Queues a callback to run in the next render batch.
@@ -534,12 +531,12 @@ class Wt {
534
531
  * Returns a Promise that resolves once the callback has run.
535
532
  */
536
533
  update(e, t) {
537
- return new Promise((n) => {
538
- t ? s(this, I).set(t, () => {
539
- e(), n();
540
- }) : s(this, G).push(() => {
541
- e(), n();
542
- }), !s(this, C) && s(this, Z).isMounted && (b(this, C, !0), k(this, ue, _e).call(this));
534
+ return new Promise((r) => {
535
+ t ? s(this, U).set(t, () => {
536
+ e(), r();
537
+ }) : s(this, H).push(() => {
538
+ e(), r();
539
+ }), !s(this, F) && s(this, J).isMounted && (b(this, F, !0), E(this, le, Ce).call(this));
543
540
  });
544
541
  }
545
542
  /**
@@ -549,49 +546,49 @@ class Wt {
549
546
  */
550
547
  read(e) {
551
548
  return new Promise((t) => {
552
- s(this, ce).push(() => {
549
+ s(this, oe).push(() => {
553
550
  e(), t();
554
- }), !s(this, C) && s(this, Z).isMounted && (b(this, C, !0), k(this, ue, _e).call(this));
551
+ }), !s(this, F) && s(this, J).isMounted && (b(this, F, !0), E(this, le, Ce).call(this));
555
552
  });
556
553
  }
557
554
  }
558
- Z = new WeakMap(), Pe = new WeakMap(), I = new WeakMap(), G = new WeakMap(), ce = new WeakMap(), C = new WeakMap(), ue = new WeakSet(), _e = function() {
559
- const e = s(this, I).size + s(this, G).length;
560
- if ((!s(this, Z).isMounted || e === 0) && b(this, C, !1), !s(this, C)) {
561
- for (const t of s(this, ce))
555
+ J = new WeakMap(), Pe = new WeakMap(), U = new WeakMap(), H = new WeakMap(), oe = new WeakMap(), F = new WeakMap(), le = new WeakSet(), Ce = function() {
556
+ const e = s(this, U).size + s(this, H).length;
557
+ if ((!s(this, J).isMounted || e === 0) && b(this, F, !1), !s(this, F)) {
558
+ for (const t of s(this, oe))
562
559
  t();
563
- b(this, ce, []);
560
+ b(this, oe, []);
564
561
  return;
565
562
  }
566
563
  requestAnimationFrame(() => {
567
- s(this, Pe).info(`Batching ${s(this, I).size + s(this, G).length} queued DOM update(s).`);
568
- for (const t of s(this, I).values())
564
+ s(this, Pe).info(`Batching ${s(this, U).size + s(this, H).length} queued DOM update(s).`);
565
+ for (const t of s(this, U).values())
569
566
  t();
570
- s(this, I).clear();
571
- for (const t of s(this, G))
567
+ s(this, U).clear();
568
+ for (const t of s(this, H))
572
569
  t();
573
- b(this, G, []), k(this, ue, _e).call(this);
570
+ b(this, H, []), E(this, le, Ce).call(this);
574
571
  });
575
572
  };
576
- function pe() {
577
- return pe = Object.assign ? Object.assign.bind() : function(i) {
573
+ function fe() {
574
+ return fe = Object.assign ? Object.assign.bind() : function(i) {
578
575
  for (var e = 1; e < arguments.length; e++) {
579
576
  var t = arguments[e];
580
- for (var n in t) ({}).hasOwnProperty.call(t, n) && (i[n] = t[n]);
577
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (i[r] = t[r]);
581
578
  }
582
579
  return i;
583
- }, pe.apply(null, arguments);
580
+ }, fe.apply(null, arguments);
584
581
  }
585
- var A;
582
+ var _;
586
583
  (function(i) {
587
584
  i.Pop = "POP", i.Push = "PUSH", i.Replace = "REPLACE";
588
- })(A || (A = {}));
589
- var qe = process.env.NODE_ENV !== "production" ? function(i) {
585
+ })(_ || (_ = {}));
586
+ var He = process.env.NODE_ENV !== "production" ? function(i) {
590
587
  return Object.freeze(i);
591
588
  } : function(i) {
592
589
  return i;
593
590
  };
594
- function Ce(i, e) {
591
+ function Ve(i, e) {
595
592
  if (!i) {
596
593
  typeof console < "u" && console.warn(e);
597
594
  try {
@@ -600,13 +597,13 @@ function Ce(i, e) {
600
597
  }
601
598
  }
602
599
  }
603
- var Ue = "beforeunload", zt = "hashchange", vt = "popstate";
604
- function Bt(i) {
600
+ var Ie = "beforeunload", zt = "hashchange", Et = "popstate";
601
+ function Kt(i) {
605
602
  i === void 0 && (i = {});
606
- var e = i, t = e.window, n = t === void 0 ? document.defaultView : t, a = n.history;
607
- function r() {
608
- var w = n.location, c = w.pathname, p = w.search, v = w.hash, $ = a.state || {};
609
- return [$.idx, qe({
603
+ var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, a = r.history;
604
+ function n() {
605
+ var w = r.location, c = w.pathname, p = w.search, v = w.hash, $ = a.state || {};
606
+ return [$.idx, He({
610
607
  pathname: c,
611
608
  search: p,
612
609
  hash: v,
@@ -619,19 +616,19 @@ function Bt(i) {
619
616
  if (o)
620
617
  y.call(o), o = null;
621
618
  else {
622
- var w = A.Pop, c = r(), p = c[0], v = c[1];
619
+ var w = _.Pop, c = n(), p = c[0], v = c[1];
623
620
  if (y.length)
624
621
  if (p != null) {
625
- var $ = f - p;
622
+ var $ = g - p;
626
623
  $ && (o = {
627
624
  action: w,
628
625
  location: v,
629
626
  retry: function() {
630
- F($ * -1);
627
+ C($ * -1);
631
628
  }
632
- }, F($));
629
+ }, C($));
633
630
  } else
634
- process.env.NODE_ENV !== "production" && Ce(
631
+ process.env.NODE_ENV !== "production" && Ve(
635
632
  !1,
636
633
  // TODO: Write up a doc that explains our blocking strategy in
637
634
  // detail and link to it here so people can understand better what
@@ -639,33 +636,33 @@ function Bt(i) {
639
636
  "You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation."
640
637
  );
641
638
  else
642
- ae(w);
639
+ re(w);
643
640
  }
644
641
  }
645
- n.addEventListener(vt, h);
646
- var l = A.Pop, m = r(), f = m[0], g = m[1], u = Ie(), y = Ie();
647
- f == null && (f = 0, a.replaceState(pe({}, a.state, {
648
- idx: f
642
+ r.addEventListener(Et, h);
643
+ var l = _.Pop, d = n(), g = d[0], m = d[1], u = Ge(), y = Ge();
644
+ g == null && (g = 0, a.replaceState(fe({}, a.state, {
645
+ idx: g
649
646
  }), ""));
650
- function E(w) {
651
- return typeof w == "string" ? w : Ve(w);
647
+ function k(w) {
648
+ return typeof w == "string" ? w : qe(w);
652
649
  }
653
- function V(w, c) {
654
- return c === void 0 && (c = null), qe(pe({
655
- pathname: g.pathname,
650
+ function de(w, c) {
651
+ return c === void 0 && (c = null), He(fe({
652
+ pathname: m.pathname,
656
653
  hash: "",
657
654
  search: ""
658
- }, typeof w == "string" ? et(w) : w, {
655
+ }, typeof w == "string" ? rt(w) : w, {
659
656
  state: c,
660
- key: $t()
657
+ key: kt()
661
658
  }));
662
659
  }
663
- function ge(w, c) {
660
+ function pe(w, c) {
664
661
  return [{
665
662
  usr: w.state,
666
663
  key: w.key,
667
664
  idx: c
668
- }, E(w)];
665
+ }, k(w)];
669
666
  }
670
667
  function me(w, c, p) {
671
668
  return !y.length || (y.call({
@@ -674,82 +671,82 @@ function Bt(i) {
674
671
  retry: p
675
672
  }), !1);
676
673
  }
677
- function ae(w) {
674
+ function re(w) {
678
675
  l = w;
679
- var c = r();
680
- f = c[0], g = c[1], u.call({
676
+ var c = n();
677
+ g = c[0], m = c[1], u.call({
681
678
  action: l,
682
- location: g
679
+ location: m
683
680
  });
684
681
  }
685
- function se(w, c) {
686
- var p = A.Push, v = V(w, c);
682
+ function ne(w, c) {
683
+ var p = _.Push, v = de(w, c);
687
684
  function $() {
688
- se(w, c);
685
+ ne(w, c);
689
686
  }
690
687
  if (me(p, v, $)) {
691
- var R = ge(v, f + 1), O = R[0], j = R[1];
688
+ var L = pe(v, g + 1), N = L[0], D = L[1];
692
689
  try {
693
- a.pushState(O, "", j);
690
+ a.pushState(N, "", D);
694
691
  } catch {
695
- n.location.assign(j);
692
+ r.location.assign(D);
696
693
  }
697
- ae(p);
694
+ re(p);
698
695
  }
699
696
  }
700
- function we(w, c) {
701
- var p = A.Replace, v = V(w, c);
697
+ function ge(w, c) {
698
+ var p = _.Replace, v = de(w, c);
702
699
  function $() {
703
- we(w, c);
700
+ ge(w, c);
704
701
  }
705
702
  if (me(p, v, $)) {
706
- var R = ge(v, f), O = R[0], j = R[1];
707
- a.replaceState(O, "", j), ae(p);
703
+ var L = pe(v, g), N = L[0], D = L[1];
704
+ a.replaceState(N, "", D), re(p);
708
705
  }
709
706
  }
710
- function F(w) {
707
+ function C(w) {
711
708
  a.go(w);
712
709
  }
713
- var Y = {
710
+ var K = {
714
711
  get action() {
715
712
  return l;
716
713
  },
717
714
  get location() {
718
- return g;
715
+ return m;
719
716
  },
720
- createHref: E,
721
- push: se,
722
- replace: we,
723
- go: F,
717
+ createHref: k,
718
+ push: ne,
719
+ replace: ge,
720
+ go: C,
724
721
  back: function() {
725
- F(-1);
722
+ C(-1);
726
723
  },
727
724
  forward: function() {
728
- F(1);
725
+ C(1);
729
726
  },
730
727
  listen: function(c) {
731
728
  return u.push(c);
732
729
  },
733
730
  block: function(c) {
734
731
  var p = y.push(c);
735
- return y.length === 1 && n.addEventListener(Ue, He), function() {
736
- p(), y.length || n.removeEventListener(Ue, He);
732
+ return y.length === 1 && r.addEventListener(Ie, We), function() {
733
+ p(), y.length || r.removeEventListener(Ie, We);
737
734
  };
738
735
  }
739
736
  };
740
- return Y;
737
+ return K;
741
738
  }
742
- function Kt(i) {
739
+ function Qt(i) {
743
740
  i === void 0 && (i = {});
744
- var e = i, t = e.window, n = t === void 0 ? document.defaultView : t, a = n.history;
745
- function r() {
746
- var c = et(n.location.hash.substr(1)), p = c.pathname, v = p === void 0 ? "/" : p, $ = c.search, R = $ === void 0 ? "" : $, O = c.hash, j = O === void 0 ? "" : O, D = a.state || {};
747
- return [D.idx, qe({
741
+ var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, a = r.history;
742
+ function n() {
743
+ var c = rt(r.location.hash.substr(1)), p = c.pathname, v = p === void 0 ? "/" : p, $ = c.search, L = $ === void 0 ? "" : $, N = c.hash, D = N === void 0 ? "" : N, A = a.state || {};
744
+ return [A.idx, He({
748
745
  pathname: v,
749
- search: R,
750
- hash: j,
751
- state: D.usr || null,
752
- key: D.key || "default"
746
+ search: L,
747
+ hash: D,
748
+ state: A.usr || null,
749
+ key: A.key || "default"
753
750
  })];
754
751
  }
755
752
  var o = null;
@@ -757,19 +754,19 @@ function Kt(i) {
757
754
  if (o)
758
755
  y.call(o), o = null;
759
756
  else {
760
- var c = A.Pop, p = r(), v = p[0], $ = p[1];
757
+ var c = _.Pop, p = n(), v = p[0], $ = p[1];
761
758
  if (y.length)
762
759
  if (v != null) {
763
- var R = f - v;
764
- R && (o = {
760
+ var L = g - v;
761
+ L && (o = {
765
762
  action: c,
766
763
  location: $,
767
764
  retry: function() {
768
- Y(R * -1);
765
+ K(L * -1);
769
766
  }
770
- }, Y(R));
767
+ }, K(L));
771
768
  } else
772
- process.env.NODE_ENV !== "production" && Ce(
769
+ process.env.NODE_ENV !== "production" && Ve(
773
770
  !1,
774
771
  // TODO: Write up a doc that explains our blocking strategy in
775
772
  // detail and link to it here so people can understand better
@@ -777,36 +774,36 @@ function Kt(i) {
777
774
  "You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation."
778
775
  );
779
776
  else
780
- se(c);
777
+ ne(c);
781
778
  }
782
779
  }
783
- n.addEventListener(vt, h), n.addEventListener(zt, function() {
784
- var c = r(), p = c[1];
785
- Ve(p) !== Ve(g) && h();
780
+ r.addEventListener(Et, h), r.addEventListener(zt, function() {
781
+ var c = n(), p = c[1];
782
+ qe(p) !== qe(m) && h();
786
783
  });
787
- var l = A.Pop, m = r(), f = m[0], g = m[1], u = Ie(), y = Ie();
788
- f == null && (f = 0, a.replaceState(pe({}, a.state, {
789
- idx: f
784
+ var l = _.Pop, d = n(), g = d[0], m = d[1], u = Ge(), y = Ge();
785
+ g == null && (g = 0, a.replaceState(fe({}, a.state, {
786
+ idx: g
790
787
  }), ""));
791
- function E() {
788
+ function k() {
792
789
  var c = document.querySelector("base"), p = "";
793
790
  if (c && c.getAttribute("href")) {
794
- var v = n.location.href, $ = v.indexOf("#");
791
+ var v = r.location.href, $ = v.indexOf("#");
795
792
  p = $ === -1 ? v : v.slice(0, $);
796
793
  }
797
794
  return p;
798
795
  }
799
- function V(c) {
800
- return E() + "#" + (typeof c == "string" ? c : Ve(c));
796
+ function de(c) {
797
+ return k() + "#" + (typeof c == "string" ? c : qe(c));
801
798
  }
802
- function ge(c, p) {
803
- return p === void 0 && (p = null), qe(pe({
804
- pathname: g.pathname,
799
+ function pe(c, p) {
800
+ return p === void 0 && (p = null), He(fe({
801
+ pathname: m.pathname,
805
802
  hash: "",
806
803
  search: ""
807
- }, typeof c == "string" ? et(c) : c, {
804
+ }, typeof c == "string" ? rt(c) : c, {
808
805
  state: p,
809
- key: $t()
806
+ key: kt()
810
807
  }));
811
808
  }
812
809
  function me(c, p) {
@@ -814,49 +811,49 @@ function Kt(i) {
814
811
  usr: c.state,
815
812
  key: c.key,
816
813
  idx: p
817
- }, V(c)];
814
+ }, de(c)];
818
815
  }
819
- function ae(c, p, v) {
816
+ function re(c, p, v) {
820
817
  return !y.length || (y.call({
821
818
  action: c,
822
819
  location: p,
823
820
  retry: v
824
821
  }), !1);
825
822
  }
826
- function se(c) {
823
+ function ne(c) {
827
824
  l = c;
828
- var p = r();
829
- f = p[0], g = p[1], u.call({
825
+ var p = n();
826
+ g = p[0], m = p[1], u.call({
830
827
  action: l,
831
- location: g
828
+ location: m
832
829
  });
833
830
  }
834
- function we(c, p) {
835
- var v = A.Push, $ = ge(c, p);
836
- function R() {
837
- we(c, p);
831
+ function ge(c, p) {
832
+ var v = _.Push, $ = pe(c, p);
833
+ function L() {
834
+ ge(c, p);
838
835
  }
839
- if (process.env.NODE_ENV !== "production" && Ce($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"), ae(v, $, R)) {
840
- var O = me($, f + 1), j = O[0], D = O[1];
836
+ if (process.env.NODE_ENV !== "production" && Ve($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"), re(v, $, L)) {
837
+ var N = me($, g + 1), D = N[0], A = N[1];
841
838
  try {
842
- a.pushState(j, "", D);
839
+ a.pushState(D, "", A);
843
840
  } catch {
844
- n.location.assign(D);
841
+ r.location.assign(A);
845
842
  }
846
- se(v);
843
+ ne(v);
847
844
  }
848
845
  }
849
- function F(c, p) {
850
- var v = A.Replace, $ = ge(c, p);
851
- function R() {
852
- F(c, p);
846
+ function C(c, p) {
847
+ var v = _.Replace, $ = pe(c, p);
848
+ function L() {
849
+ C(c, p);
853
850
  }
854
- if (process.env.NODE_ENV !== "production" && Ce($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"), ae(v, $, R)) {
855
- var O = me($, f), j = O[0], D = O[1];
856
- a.replaceState(j, "", D), se(v);
851
+ if (process.env.NODE_ENV !== "production" && Ve($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"), re(v, $, L)) {
852
+ var N = me($, g), D = N[0], A = N[1];
853
+ a.replaceState(D, "", A), ne(v);
857
854
  }
858
855
  }
859
- function Y(c) {
856
+ function K(c) {
860
857
  a.go(c);
861
858
  }
862
859
  var w = {
@@ -864,34 +861,34 @@ function Kt(i) {
864
861
  return l;
865
862
  },
866
863
  get location() {
867
- return g;
864
+ return m;
868
865
  },
869
- createHref: V,
870
- push: we,
871
- replace: F,
872
- go: Y,
866
+ createHref: de,
867
+ push: ge,
868
+ replace: C,
869
+ go: K,
873
870
  back: function() {
874
- Y(-1);
871
+ K(-1);
875
872
  },
876
873
  forward: function() {
877
- Y(1);
874
+ K(1);
878
875
  },
879
876
  listen: function(p) {
880
877
  return u.push(p);
881
878
  },
882
879
  block: function(p) {
883
880
  var v = y.push(p);
884
- return y.length === 1 && n.addEventListener(Ue, He), function() {
885
- v(), y.length || n.removeEventListener(Ue, He);
881
+ return y.length === 1 && r.addEventListener(Ie, We), function() {
882
+ v(), y.length || r.removeEventListener(Ie, We);
886
883
  };
887
884
  }
888
885
  };
889
886
  return w;
890
887
  }
891
- function He(i) {
888
+ function We(i) {
892
889
  i.preventDefault(), i.returnValue = "";
893
890
  }
894
- function Ie() {
891
+ function Ge() {
895
892
  var i = [];
896
893
  return {
897
894
  get length() {
@@ -899,127 +896,127 @@ function Ie() {
899
896
  },
900
897
  push: function(t) {
901
898
  return i.push(t), function() {
902
- i = i.filter(function(n) {
903
- return n !== t;
899
+ i = i.filter(function(r) {
900
+ return r !== t;
904
901
  });
905
902
  };
906
903
  },
907
904
  call: function(t) {
908
- i.forEach(function(n) {
909
- return n && n(t);
905
+ i.forEach(function(r) {
906
+ return r && r(t);
910
907
  });
911
908
  }
912
909
  };
913
910
  }
914
- function $t() {
911
+ function kt() {
915
912
  return Math.random().toString(36).substr(2, 8);
916
913
  }
917
- function Ve(i) {
918
- var e = i.pathname, t = e === void 0 ? "/" : e, n = i.search, a = n === void 0 ? "" : n, r = i.hash, o = r === void 0 ? "" : r;
914
+ function qe(i) {
915
+ var e = i.pathname, t = e === void 0 ? "/" : e, r = i.search, a = r === void 0 ? "" : r, n = i.hash, o = n === void 0 ? "" : n;
919
916
  return a && a !== "?" && (t += a.charAt(0) === "?" ? a : "?" + a), o && o !== "#" && (t += o.charAt(0) === "#" ? o : "#" + o), t;
920
917
  }
921
- function et(i) {
918
+ function rt(i) {
922
919
  var e = {};
923
920
  if (i) {
924
921
  var t = i.indexOf("#");
925
922
  t >= 0 && (e.hash = i.substr(t), i = i.substr(0, t));
926
- var n = i.indexOf("?");
927
- n >= 0 && (e.search = i.substr(n), i = i.substr(0, n)), i && (e.pathname = i);
923
+ var r = i.indexOf("?");
924
+ r >= 0 && (e.search = i.substr(r), i = i.substr(0, r)), i && (e.pathname = i);
928
925
  }
929
926
  return e;
930
927
  }
931
- function be(i) {
932
- return pt(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((e) => e.trim()).filter((e) => e !== "");
928
+ function ye(i) {
929
+ return wt(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((e) => e.trim()).filter((e) => e !== "");
933
930
  }
934
- function ie(i) {
931
+ function ae(i) {
935
932
  var t;
936
- Rt(
937
- (n) => at(n == null ? void 0 : n.toString),
933
+ xt(
934
+ (r) => it(r == null ? void 0 : r.toString),
938
935
  i,
939
936
  "Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
940
- ), i = i.filter((n) => n).flatMap(String);
937
+ ), i = i.filter((r) => r).flatMap(String);
941
938
  let e = (t = i.shift()) == null ? void 0 : t.toString();
942
939
  if (e) {
943
- for (const n of i.map((a) => a.toString()))
944
- n.startsWith(".") ? e = Fe(e, n) : e[e.length - 1] !== "/" ? n[0] !== "/" ? e += "/" + n : e += n : n[0] === "/" ? e += n.slice(1) : e += n;
940
+ for (const r of i.map((a) => a.toString()))
941
+ r.startsWith(".") ? e = Ue(e, r) : e[e.length - 1] !== "/" ? r[0] !== "/" ? e += "/" + r : e += r : r[0] === "/" ? e += r.slice(1) : e += r;
945
942
  e && e !== "/" && e.endsWith("/") && (e = e.slice(0, e.length - 1));
946
943
  }
947
944
  return e ?? "";
948
945
  }
949
- function Fe(i, e) {
950
- if (pt(i, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = i, i = ""), e.startsWith("/"))
946
+ function Ue(i, e) {
947
+ if (wt(i, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = i, i = ""), e.startsWith("/"))
951
948
  return e;
952
949
  let t = i;
953
950
  for (; ; )
954
951
  if (e.startsWith("..")) {
955
- for (let n = t.length; n > 0; --n)
956
- if (t[n] === "/" || n === 0) {
957
- t = t.slice(0, n), e = e.replace(/^\.\.\/?/, "");
952
+ for (let r = t.length; r > 0; --r)
953
+ if (t[r] === "/" || r === 0) {
954
+ t = t.slice(0, r), e = e.replace(/^\.\.\/?/, "");
958
955
  break;
959
956
  }
960
957
  } else if (e.startsWith("."))
961
958
  e = e.replace(/^\.\/?/, "");
962
959
  else
963
960
  break;
964
- return ie([t, e]);
961
+ return ae([t, e]);
965
962
  }
966
- function tt(i) {
963
+ function nt(i) {
967
964
  if (!i) return {};
968
965
  i.startsWith("?") && (i = i.slice(1));
969
966
  const e = i.split("&").filter((t) => t.trim() !== "").map((t) => {
970
- const [n, a] = t.split("=").map((r) => r.trim());
971
- return a.toLowerCase() === "true" ? [n, !0] : a.toLowerCase() === "false" ? [n, !1] : isNaN(Number(a)) ? [n, a] : [n, Number(a)];
967
+ const [r, a] = t.split("=").map((n) => n.trim());
968
+ return a.toLowerCase() === "true" ? [r, !0] : a.toLowerCase() === "false" ? [r, !1] : isNaN(Number(a)) ? [r, a] : [r, Number(a)];
972
969
  });
973
970
  return Object.fromEntries(e);
974
971
  }
975
- function ft(i, e, t = {}) {
972
+ function mt(i, e, t = {}) {
976
973
  var o;
977
- const [n, a] = e.split("?"), r = be(n);
974
+ const [r, a] = e.split("?"), n = ye(r);
978
975
  e: for (const h of i) {
979
976
  const { fragments: l } = h;
980
- if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== r.length || t.willMatch && !t.willMatch(h))
977
+ if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== n.length || t.willMatch && !t.willMatch(h))
981
978
  continue e;
982
- const f = [];
979
+ const g = [];
983
980
  t: for (let u = 0; u < l.length; u++) {
984
- const y = r[u], E = l[u];
985
- if (y == null && E.type !== 3)
981
+ const y = n[u], k = l[u];
982
+ if (y == null && k.type !== 3)
986
983
  continue e;
987
- switch (E.type) {
984
+ switch (k.type) {
988
985
  case 1:
989
- if (E.name.toLowerCase() === y.toLowerCase()) {
990
- f.push(E);
986
+ if (k.name.toLowerCase() === y.toLowerCase()) {
987
+ g.push(k);
991
988
  break;
992
989
  } else
993
990
  continue e;
994
991
  case 2:
995
- f.push({ ...E, value: y });
992
+ g.push({ ...k, value: y });
996
993
  break;
997
994
  case 3:
998
- f.push({ ...E, value: r.slice(u).join("/") });
995
+ g.push({ ...k, value: n.slice(u).join("/") });
999
996
  break t;
1000
997
  case 4:
1001
998
  if (isNaN(Number(y)))
1002
999
  continue e;
1003
- f.push({ ...E, value: Number(y) });
1000
+ g.push({ ...k, value: Number(y) });
1004
1001
  break;
1005
1002
  default:
1006
- throw new Error(`Unknown fragment type: ${E.type}`);
1003
+ throw new Error(`Unknown fragment type: ${k.type}`);
1007
1004
  }
1008
1005
  }
1009
- const g = /* @__PURE__ */ Object.create(null);
1010
- for (const u of f)
1011
- u.type === 2 && (g[u.name] = decodeURIComponent(u.value)), u.type === 4 && (g[u.name] = u.value), u.type === 3 && (g.wildcard = "/" + decodeURIComponent(u.value));
1006
+ const m = /* @__PURE__ */ Object.create(null);
1007
+ for (const u of g)
1008
+ u.type === 2 && (m[u.name] = decodeURIComponent(u.value)), u.type === 4 && (m[u.name] = u.value), u.type === 3 && (m.wildcard = "/" + decodeURIComponent(u.value));
1012
1009
  return {
1013
- path: "/" + f.map((u) => u.value).join("/"),
1010
+ path: "/" + g.map((u) => u.value).join("/"),
1014
1011
  pattern: "/" + l.map((u) => u.type === 2 ? `{${u.name}}` : u.type === 4 ? `{#${u.name}}` : u.name).join("/"),
1015
- params: g,
1016
- query: tt(a),
1012
+ params: m,
1013
+ query: nt(a),
1017
1014
  meta: h.meta
1018
1015
  };
1019
1016
  }
1020
1017
  }
1021
- function Qt(i) {
1022
- const e = [], t = [], n = [], a = [];
1018
+ function Jt(i) {
1019
+ const e = [], t = [], r = [], a = [];
1023
1020
  for (const o of i) {
1024
1021
  const { fragments: h } = o;
1025
1022
  h.some(
@@ -1031,17 +1028,17 @@ function Qt(i) {
1031
1028
  ) ? t.push(o) : h.some(
1032
1029
  (l) => l.type === 2
1033
1030
  /* Param */
1034
- ) ? n.push(o) : e.push(o);
1031
+ ) ? r.push(o) : e.push(o);
1035
1032
  }
1036
- const r = (o, h) => o.fragments.length > h.fragments.length ? -1 : 1;
1037
- return e.sort(r), t.sort(r), n.sort(r), a.sort(r), [...e, ...t, ...n, ...a];
1033
+ const n = (o, h) => o.fragments.length > h.fragments.length ? -1 : 1;
1034
+ return e.sort(n), t.sort(n), r.sort(n), a.sort(n), [...e, ...t, ...r, ...a];
1038
1035
  }
1039
- function Jt(i) {
1040
- const e = be(i), t = [];
1041
- for (let n = 0; n < e.length; n++) {
1042
- const a = e[n];
1036
+ function Yt(i) {
1037
+ const e = ye(i), t = [];
1038
+ for (let r = 0; r < e.length; r++) {
1039
+ const a = e[r];
1043
1040
  if (a === "*") {
1044
- if (n !== e.length - 1)
1041
+ if (r !== e.length - 1)
1045
1042
  throw new Error(`Wildcard must be at the end of a pattern. Received: ${i}`);
1046
1043
  t.push({
1047
1044
  type: 3,
@@ -1060,65 +1057,65 @@ function Jt(i) {
1060
1057
  }
1061
1058
  return t;
1062
1059
  }
1063
- var Se, M, ee, P, ze, W, Re, te, z, he, fe, de, xe, J, rt, nt;
1064
- class Yt {
1060
+ var Se, M, Y, Le, P, Ke, I, Re, X, Z, ce, ue, he, xe, z, at, st;
1061
+ class Xt {
1065
1062
  constructor(e, t) {
1066
- d(this, J);
1067
- d(this, Se);
1068
- d(this, M);
1069
- d(this, ee);
1070
- d(this, P);
1071
- d(this, ze, 0);
1072
- d(this, W, []);
1073
- d(this, Re);
1074
- d(this, te, []);
1063
+ f(this, z);
1064
+ f(this, Se);
1065
+ f(this, M);
1066
+ f(this, Y);
1067
+ f(this, Le, Ye());
1068
+ f(this, P);
1069
+ f(this, Ke, 0);
1070
+ f(this, I, []);
1071
+ f(this, Re);
1072
+ f(this, X, []);
1075
1073
  // Callbacks that need to be called on unmount.
1076
- d(this, z, []);
1074
+ f(this, Z, []);
1077
1075
  /**
1078
1076
  * The currently matched route pattern, if any.
1079
1077
  */
1080
1078
  S(this, "$pattern");
1081
- d(this, he);
1079
+ f(this, ce);
1082
1080
  /**
1083
1081
  * The current URL path.
1084
1082
  */
1085
1083
  S(this, "$path");
1086
- d(this, fe);
1084
+ f(this, ue);
1087
1085
  /**
1088
1086
  * The current named path params.
1089
1087
  */
1090
1088
  S(this, "$params");
1091
- d(this, de);
1089
+ f(this, he);
1092
1090
  /**
1093
1091
  * The current query params. Changes to this object will be reflected in the URL.
1094
1092
  */
1095
1093
  S(this, "$query");
1096
- d(this, xe);
1097
- b(this, Se, e), b(this, M, e.createLogger("dolla/router")), b(this, ee, t);
1098
- const [n, a] = oe(null), [r, o] = oe(""), [h, l] = oe({}), [m, f] = oe(
1099
- tt(typeof window > "u" ? "" : window.location.search ?? "")
1094
+ f(this, xe);
1095
+ b(this, Se, e), b(this, M, e.createLogger("dolla/router")), b(this, Y, t);
1096
+ const [r, a] = se(null), [n, o] = se(""), [h, l] = se({}), [d, g] = se(
1097
+ nt(typeof window > "u" ? "" : window.location.search ?? "")
1100
1098
  );
1101
- this.$pattern = n, b(this, he, a), this.$path = r, b(this, fe, o), this.$params = h, b(this, de, l), this.$query = m, b(this, xe, f), e.beforeMount(() => {
1102
- s(this, P) != null && (s(this, z).push(
1103
- gt([m], (g) => {
1104
- const u = new URLSearchParams();
1105
- for (const E in g)
1106
- u.set(E, String(g[E]));
1107
- const y = "?" + u.toString();
1108
- y != s(this, P).location.search && s(this, P).replace({
1109
- pathname: s(this, P).location.pathname,
1110
- search: y
1111
- });
1112
- })
1113
- ), s(this, z).push(s(this, P).listen(k(this, J, nt).bind(this))), k(this, J, nt).call(this, s(this, P)), s(this, z).push(
1114
- er(s(this, ee).rootElement, (g) => {
1115
- let u = g.getAttribute("href");
1116
- s(this, M).info("Intercepted link click", g, u), /^https?:\/\/|^\//.test(u) || (u = ie([s(this, P).location.pathname, u])), s(this, P).push(u);
1099
+ this.$pattern = r, b(this, ce, a), this.$path = n, b(this, ue, o), this.$params = h, b(this, he, l), this.$query = d, b(this, xe, g), e.beforeMount(() => {
1100
+ s(this, P) != null && (s(this, Le).watch([d], (m) => {
1101
+ const u = new URLSearchParams();
1102
+ for (const k in m)
1103
+ u.set(k, String(m[k]));
1104
+ const y = "?" + u.toString();
1105
+ y != s(this, P).location.search && s(this, P).replace({
1106
+ pathname: s(this, P).location.pathname,
1107
+ search: y
1108
+ });
1109
+ }), s(this, Z).push(s(this, P).listen(E(this, z, st).bind(this))), E(this, z, st).call(this, s(this, P)), s(this, Z).push(
1110
+ tr(s(this, Y).rootElement, (m) => {
1111
+ let u = m.getAttribute("href");
1112
+ s(this, M).info("Intercepted link click", m, u), /^https?:\/\/|^\//.test(u) || (u = ae([s(this, P).location.pathname, u])), s(this, P).push(u);
1117
1113
  })
1118
- ), s(this, M).info("Intercepting <a> clicks within root element:", s(this, ee).rootElement));
1114
+ ), s(this, M).info("Intercepting <a> clicks within root element:", s(this, Y).rootElement));
1119
1115
  }), e.onUnmount(() => {
1120
- for (; s(this, z).length > 0; )
1121
- s(this, z).pop()();
1116
+ for (; s(this, Z).length > 0; )
1117
+ s(this, Z).pop()();
1118
+ s(this, Le).stopAll();
1122
1119
  });
1123
1120
  }
1124
1121
  setup(e) {
@@ -1128,20 +1125,20 @@ class Yt {
1128
1125
  );
1129
1126
  return;
1130
1127
  }
1131
- e.style === "hash" ? b(this, P, Kt()) : b(this, P, Bt()), b(this, te, Qt(
1132
- e.routes.flatMap((t) => k(this, J, rt).call(this, t)).map((t) => ({
1128
+ e.style === "hash" ? b(this, P, Qt()) : b(this, P, Kt()), b(this, X, Jt(
1129
+ e.routes.flatMap((t) => E(this, z, at).call(this, t)).map((t) => ({
1133
1130
  pattern: t.pattern,
1134
1131
  meta: t.meta,
1135
- fragments: Jt(t.pattern)
1132
+ fragments: Yt(t.pattern)
1136
1133
  }))
1137
1134
  ));
1138
- for (const t of s(this, te))
1135
+ for (const t of s(this, X))
1139
1136
  if (t.meta.redirect) {
1140
- let n;
1141
- if (!at(t.meta.redirect)) if (q(t.meta.redirect)) {
1142
- if (n = t.meta.redirect, !ft(s(this, te), n, {
1143
- willMatch(r) {
1144
- return r !== t;
1137
+ let r;
1138
+ if (!it(t.meta.redirect)) if (V(t.meta.redirect)) {
1139
+ if (r = t.meta.redirect, !mt(s(this, X), r, {
1140
+ willMatch(n) {
1141
+ return n !== t;
1145
1142
  }
1146
1143
  }))
1147
1144
  throw new Error(
@@ -1167,8 +1164,8 @@ class Yt {
1167
1164
  );
1168
1165
  return;
1169
1166
  }
1170
- let n;
1171
- Array.isArray(e) ? n = ie(e) : n = e.toString(), n = Fe(s(this, P).location.pathname, n), t.preserveQuery && (n += s(this, P).location.search), t.replace ? s(this, P).replace(n) : s(this, P).push(n);
1167
+ let r;
1168
+ Array.isArray(e) ? r = ae(e) : r = e.toString(), r = Ue(s(this, P).location.pathname, r), t.preserveQuery && (r += s(this, P).location.search), t.replace ? s(this, P).replace(r) : s(this, P).push(r);
1172
1169
  }
1173
1170
  /**
1174
1171
  * Navigate backward. Pass a number of steps to hit the back button that many times.
@@ -1199,13 +1196,13 @@ class Yt {
1199
1196
  s(this, P).go(e);
1200
1197
  }
1201
1198
  }
1202
- Se = new WeakMap(), M = new WeakMap(), ee = new WeakMap(), P = new WeakMap(), ze = new WeakMap(), W = new WeakMap(), Re = new WeakMap(), te = new WeakMap(), z = new WeakMap(), he = new WeakMap(), fe = new WeakMap(), de = new WeakMap(), xe = new WeakMap(), J = new WeakSet(), /**
1199
+ Se = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), Le = new WeakMap(), P = new WeakMap(), Ke = new WeakMap(), I = new WeakMap(), Re = new WeakMap(), X = new WeakMap(), Z = new WeakMap(), ce = new WeakMap(), ue = new WeakMap(), he = new WeakMap(), xe = new WeakMap(), z = new WeakSet(), /**
1203
1200
  * Parses a route definition object into a set of matchable routes.
1204
1201
  *
1205
1202
  * @param route - Route config object.
1206
1203
  * @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
1207
1204
  */
1208
- rt = function(e, t = [], n = []) {
1205
+ at = function(e, t = [], r = []) {
1209
1206
  if (!(typeof e == "object" && !Array.isArray(e)) || typeof e.path != "string")
1210
1207
  throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${e}`);
1211
1208
  if (e.redirect && e.routes)
@@ -1216,144 +1213,146 @@ rt = function(e, t = [], n = []) {
1216
1213
  throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
1217
1214
  let a = [];
1218
1215
  for (const l of t)
1219
- a.push(...be(l.path));
1220
- a.push(...be(e.path)), a[a.length - 1] === "*" && a.pop();
1221
- const r = [];
1216
+ a.push(...ye(l.path));
1217
+ a.push(...ye(e.path)), a[a.length - 1] === "*" && a.pop();
1218
+ const n = [];
1222
1219
  if (e.redirect) {
1223
1220
  let l = e.redirect;
1224
- return q(l) && (l = Fe(ie(a), l), l.startsWith("/") || (l = "/" + l)), r.push({
1225
- pattern: "/" + ie([...a, ...be(e.path)]),
1221
+ return V(l) && (l = Ue(ae(a), l), l.startsWith("/") || (l = "/" + l)), n.push({
1222
+ pattern: "/" + ae([...a, ...ye(e.path)]),
1226
1223
  meta: {
1227
1224
  redirect: l
1228
1225
  }
1229
- }), r;
1226
+ }), n;
1230
1227
  }
1231
- let o = mt;
1228
+ let o = yt;
1232
1229
  if (typeof e.view == "function")
1233
1230
  o = e.view;
1234
1231
  else if (e.view)
1235
1232
  throw new TypeError(`Route '${e.path}' expected a view function or undefined. Got: ${e.view}`);
1236
- const h = { id: it(this, ze)._++, view: o };
1233
+ const h = { id: lt(this, Ke)._++, view: o };
1237
1234
  if (e.routes)
1238
1235
  for (const l of e.routes)
1239
- r.push(...k(this, J, rt).call(this, l, [...t, e], [...n, h]));
1236
+ n.push(...E(this, z, at).call(this, l, [...t, e], [...r, h]));
1240
1237
  else
1241
- r.push({
1242
- pattern: parent ? ie([...t.map((l) => l.path), e.path]) : e.path,
1238
+ n.push({
1239
+ pattern: parent ? ae([...t.map((l) => l.path), e.path]) : e.path,
1243
1240
  meta: {
1244
1241
  pattern: e.path,
1245
- layers: [...n, h],
1242
+ layers: [...r, h],
1246
1243
  beforeMatch: e.beforeMatch
1247
1244
  }
1248
1245
  });
1249
- return r;
1250
- }, nt = async function({ location: e }) {
1251
- e.search !== s(this, Re) && (b(this, Re, e.search), s(this, xe).call(this, tt(e.search)));
1252
- const t = ft(s(this, te), e.pathname);
1246
+ return n;
1247
+ }, st = async function({ location: e }) {
1248
+ e.search !== s(this, Re) && (b(this, Re, e.search), s(this, xe).call(this, nt(e.search)));
1249
+ const t = mt(s(this, X), e.pathname);
1253
1250
  if (!t) {
1254
- s(this, he).call(this, null), s(this, fe).call(this, e.pathname), s(this, de).call(this, {
1251
+ s(this, ce).call(this, null), s(this, ue).call(this, e.pathname), s(this, he).call(this, {
1255
1252
  wildcard: e.pathname
1256
1253
  });
1257
1254
  return;
1258
1255
  }
1259
1256
  if (t.meta.beforeMatch && await t.meta.beforeMatch({
1260
1257
  // TODO: Allow setting context variables from here.
1261
- redirect: (n) => {
1258
+ redirect: (r) => {
1262
1259
  throw new Error("Redirect not yet implemented.");
1263
1260
  }
1264
1261
  }), t.meta.redirect != null)
1265
1262
  if (typeof t.meta.redirect == "string") {
1266
- const n = tr(t.meta.redirect, t.params);
1267
- s(this, M).info(`↩️ redirecting from '${t.path}' to '${n}'`), s(this, P).replace(n);
1263
+ const r = rr(t.meta.redirect, t.params);
1264
+ s(this, M).info(`↩️ redirecting from '${t.path}' to '${r}'`), s(this, P).replace(r);
1268
1265
  } else if (typeof t.meta.redirect == "function") {
1269
- const n = {
1266
+ const r = {
1270
1267
  path: t.path,
1271
1268
  pattern: t.pattern,
1272
1269
  params: t.params,
1273
1270
  query: t.query
1274
1271
  };
1275
- let a = await t.meta.redirect(n);
1272
+ let a = await t.meta.redirect(r);
1276
1273
  if (typeof a != "string")
1277
1274
  throw new Error("Redirect function must return a path to redirect to.");
1278
- a.startsWith("/") || (a = Fe(t.path, a)), s(this, M).info(`Redirecting to: '${a}'`), s(this, P).replace(a);
1275
+ a.startsWith("/") || (a = Ue(t.path, a)), s(this, M).info(`Redirecting to: '${a}'`), s(this, P).replace(a);
1279
1276
  } else
1280
1277
  throw new TypeError("Redirect must either be a path string or a function.");
1281
- else if (s(this, M).info(`📍 navigating to '${t.path}'`), s(this, fe).call(this, t.path), s(this, de).call(this, t.params), t.pattern !== this.$pattern.get()) {
1282
- s(this, he).call(this, t.pattern);
1283
- const n = t.meta.layers;
1284
- for (let a = 0; a < n.length; a++) {
1285
- const r = n[a], o = s(this, W)[a];
1286
- if ((o == null ? void 0 : o.id) !== r.id) {
1287
- b(this, W, s(this, W).slice(0, a));
1288
- const h = s(this, W).at(-1);
1278
+ else if (s(this, M).info(`📍 navigating to '${t.path}'`), s(this, ue).call(this, t.path), s(this, he).call(this, t.params), t.pattern !== this.$pattern.get()) {
1279
+ s(this, ce).call(this, t.pattern);
1280
+ const r = t.meta.layers;
1281
+ for (let a = 0; a < r.length; a++) {
1282
+ const n = r[a], o = s(this, I)[a];
1283
+ if ((o == null ? void 0 : o.id) !== n.id) {
1284
+ b(this, I, s(this, I).slice(0, a));
1285
+ const h = s(this, I).at(-1);
1289
1286
  o && o.node.isMounted && o.node.unmount();
1290
1287
  let l;
1291
- h ? l = h.node.setChildView(r.view) : l = s(this, ee).rootView.setChildView(r.view), s(this, W).push({ id: r.id, node: l });
1288
+ h ? l = h.node.setChildView(n.view) : l = s(this, Y).rootView.setChildView(n.view), s(this, I).push({ id: n.id, node: l });
1292
1289
  }
1293
1290
  }
1294
1291
  }
1295
1292
  };
1296
- const Xt = /(noopener|noreferrer) (noopener|noreferrer)/, Zt = /^[\w-_]+:/;
1297
- function er(i, e, t = window) {
1298
- function n(r) {
1299
- return !r || r === i ? null : r.localName !== "a" || r.href === void 0 ? n(r.parentNode) : r;
1293
+ const Zt = /(noopener|noreferrer) (noopener|noreferrer)/, er = /^[\w-_]+:/;
1294
+ function tr(i, e, t = window) {
1295
+ function r(n) {
1296
+ return !n || n === i ? null : n.localName !== "a" || n.href === void 0 ? r(n.parentNode) : n;
1300
1297
  }
1301
- function a(r) {
1302
- if (r.button && r.button !== 0 || r.ctrlKey || r.metaKey || r.altKey || r.shiftKey || r.defaultPrevented)
1298
+ function a(n) {
1299
+ if (n.button && n.button !== 0 || n.ctrlKey || n.metaKey || n.altKey || n.shiftKey || n.defaultPrevented)
1303
1300
  return;
1304
- const o = n(r.target);
1305
- o && (t.location.protocol !== o.protocol || t.location.hostname !== o.hostname || t.location.port !== o.port || o.hasAttribute("data-router-ignore") || o.hasAttribute("download") || o.getAttribute("target") === "_blank" && Xt.test(o.getAttribute("rel")) || Zt.test(o.getAttribute("href")) || (r.preventDefault(), e(o)));
1301
+ const o = r(n.target);
1302
+ o && (t.location.protocol !== o.protocol || t.location.hostname !== o.hostname || t.location.port !== o.port || o.hasAttribute("data-router-ignore") || o.hasAttribute("download") || o.getAttribute("target") === "_blank" && Zt.test(o.getAttribute("rel")) || er.test(o.getAttribute("href")) || (n.preventDefault(), e(o)));
1306
1303
  }
1307
1304
  return i.addEventListener("click", a), function() {
1308
1305
  i.removeEventListener("click", a);
1309
1306
  };
1310
1307
  }
1311
- function tr(i, e) {
1308
+ function rr(i, e) {
1312
1309
  for (const t in e) {
1313
- const n = e[t].toString();
1314
- i = i.replace(`{${t}}`, n).replace(`{#${t}}`, n);
1310
+ const r = e[t].toString();
1311
+ i = i.replace(`{${t}}`, r).replace(`{#${t}}`, r);
1315
1312
  }
1316
1313
  return i;
1317
1314
  }
1318
- var B, Le, K, re, Ne, Oe, Me, Te, je, x, Q;
1319
- class rr {
1315
+ var W, Oe, G, ee, Ne, Me, Te, De, _e, Ae, R, B;
1316
+ class nr {
1320
1317
  constructor() {
1321
1318
  S(this, "http");
1322
1319
  S(this, "i18n");
1323
1320
  S(this, "render");
1324
1321
  S(this, "router");
1325
- d(this, B, !1);
1326
- d(this, Le, "production");
1327
- d(this, K);
1328
- d(this, re);
1329
- d(this, Ne, _t);
1330
- d(this, Oe, []);
1331
- d(this, Me, []);
1332
- d(this, Te, []);
1333
- d(this, je, []);
1334
- d(this, x, {
1322
+ f(this, W, !1);
1323
+ f(this, Oe, "production");
1324
+ f(this, G);
1325
+ f(this, ee);
1326
+ f(this, Ne, Ct);
1327
+ f(this, Me, Ye());
1328
+ f(this, Te, []);
1329
+ f(this, De, []);
1330
+ f(this, _e, []);
1331
+ f(this, Ae, []);
1332
+ f(this, R, {
1335
1333
  info: "development",
1336
1334
  log: "development",
1337
1335
  warn: "development",
1338
1336
  error: !0
1339
1337
  });
1340
- d(this, Q, ct("*,-dolla/*"));
1341
- S(this, "createState", oe);
1342
- S(this, "createSettableState", xt);
1343
- S(this, "toSettableState", Lt);
1344
- S(this, "toState", Qe);
1345
- S(this, "valueOf", Nt);
1346
- S(this, "derive", ye);
1347
- S(this, "watch", gt);
1348
- S(this, "createRef", Ot);
1349
- S(this, "isRef", Mt);
1338
+ f(this, B, ht("*,-dolla/*"));
1339
+ S(this, "watch", s(this, Me).watch);
1340
+ S(this, "createState", se);
1341
+ S(this, "createSettableState", Ot);
1342
+ S(this, "toSettableState", Nt);
1343
+ S(this, "toState", ft);
1344
+ S(this, "valueOf", Mt);
1345
+ S(this, "derive", we);
1346
+ S(this, "createWatcher", Ye);
1347
+ S(this, "createRef", Tt);
1348
+ S(this, "isRef", Dt);
1350
1349
  const e = this;
1351
- this.http = new Ct(), this.i18n = new It(this), this.render = new Wt(this), this.router = new Yt(this, {
1350
+ this.http = new Vt(), this.i18n = new Wt(this), this.render = new Bt(this), this.router = new Xt(this, {
1352
1351
  get rootElement() {
1353
- return s(e, K);
1352
+ return s(e, G);
1354
1353
  },
1355
1354
  get rootView() {
1356
- return s(e, re);
1355
+ return s(e, ee);
1357
1356
  }
1358
1357
  });
1359
1358
  }
@@ -1361,21 +1360,21 @@ class rr {
1361
1360
  * True when the app is connected to a DOM node and displayed to the user.
1362
1361
  */
1363
1362
  get isMounted() {
1364
- return s(this, B);
1363
+ return s(this, W);
1365
1364
  }
1366
1365
  /**
1367
1366
  * Get the current environment that this app is running in.
1368
1367
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
1369
1368
  */
1370
1369
  getEnv() {
1371
- return s(this, Le);
1370
+ return s(this, Oe);
1372
1371
  }
1373
1372
  /**
1374
1373
  * Sets the environment that this app is running in.
1375
1374
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
1376
1375
  */
1377
1376
  setEnv(e) {
1378
- b(this, Le, e);
1377
+ b(this, Oe, e);
1379
1378
  }
1380
1379
  /**
1381
1380
  * Sets the view that will be shown when the `crash` method is called on any logger.
@@ -1385,23 +1384,23 @@ class rr {
1385
1384
  b(this, Ne, e);
1386
1385
  }
1387
1386
  async mount(e, t) {
1388
- if (s(this, B))
1387
+ if (s(this, W))
1389
1388
  throw new Error("Dolla is already mounted.");
1390
- if (q(e)) {
1389
+ if (V(e)) {
1391
1390
  const a = document.querySelector(e);
1392
- ut(HTMLElement, a, `Selector '${e}' did not match any element.`), b(this, K, a);
1391
+ dt(HTMLElement, a, `Selector '${e}' did not match any element.`), b(this, G, a);
1393
1392
  } else
1394
- ut(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this, K, e);
1395
- let n;
1396
- t ? n = ht(t) : n = ht(mt), b(this, re, this.constructView(n.type, n.props)), await Promise.all(s(this, Oe).map((a) => a())), s(this, re).mount(s(this, K)), b(this, B, !0);
1397
- for (const a of s(this, Me))
1393
+ dt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this, G, e);
1394
+ let r;
1395
+ t ? r = pt(t) : r = pt(yt), b(this, ee, this.constructView(r.type, r.props)), await Promise.all(s(this, Te).map((a) => a())), s(this, ee).mount(s(this, G)), b(this, W, !0);
1396
+ for (const a of s(this, De))
1398
1397
  a();
1399
1398
  }
1400
1399
  async unmount() {
1401
1400
  var e;
1402
- if (s(this, B)) {
1403
- await Promise.all(s(this, Te).map((t) => t())), (e = s(this, re)) == null || e.unmount(), b(this, B, !1);
1404
- for (const t of s(this, je))
1401
+ if (s(this, W)) {
1402
+ await Promise.all(s(this, _e).map((t) => t())), (e = s(this, ee)) == null || e.unmount(), s(this, Me).stopAll(), b(this, W, !1);
1403
+ for (const t of s(this, Ae))
1405
1404
  t();
1406
1405
  }
1407
1406
  }
@@ -1410,53 +1409,53 @@ class rr {
1410
1409
  * it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
1411
1410
  */
1412
1411
  beforeMount(e) {
1413
- s(this, Oe).push(e);
1412
+ s(this, Te).push(e);
1414
1413
  }
1415
1414
  /**
1416
1415
  * Registers a `callback` to run after the app is mounted.
1417
1416
  */
1418
1417
  onMount(e) {
1419
- s(this, Me).push(e);
1418
+ s(this, De).push(e);
1420
1419
  }
1421
1420
  /**
1422
1421
  * Registers a `callback` to run after `Dolla.unmount` is called, before the app is unmounted. If `callback` returns a Promise,
1423
1422
  * it will be awaited before unmounting finishes. Use this to perform cleanup.
1424
1423
  */
1425
1424
  beforeUnmount(e) {
1426
- s(this, Te).push(e);
1425
+ s(this, _e).push(e);
1427
1426
  }
1428
1427
  /**
1429
1428
  * Registers a `callback` to run after the app is unmounted.
1430
1429
  */
1431
1430
  onUnmount(e) {
1432
- s(this, je).push(e);
1431
+ s(this, Ae).push(e);
1433
1432
  }
1434
1433
  /**
1435
1434
  * Update log type toggles. Values that are not passed will remain unchanged.
1436
1435
  */
1437
1436
  setLoggles(e) {
1438
1437
  for (const t in e) {
1439
- const n = e[t];
1440
- n && (s(this, x)[t] = n);
1438
+ const r = e[t];
1439
+ r && (s(this, R)[t] = r);
1441
1440
  }
1442
1441
  }
1443
1442
  setLogFilter(e) {
1444
- b(this, Q, ct(e));
1443
+ b(this, B, ht(e));
1445
1444
  }
1446
1445
  createLogger(e, t) {
1447
- const n = Qe(e), a = (t == null ? void 0 : t.console) ?? Tt(), r = this;
1446
+ const r = ft(e), a = (t == null ? void 0 : t.console) ?? _t(), n = this;
1448
1447
  return {
1449
1448
  get info() {
1450
1449
  var h;
1451
- const o = n.get();
1452
- if (s(r, x).info === !1 || q(s(r, x).info) && s(r, x).info !== r.getEnv() || !s(h = r, Q).call(h, o))
1453
- return Ae;
1450
+ const o = r.get();
1451
+ if (s(n, R).info === !1 || V(s(n, R).info) && s(n, R).info !== n.getEnv() || !s(h = n, B).call(h, o))
1452
+ return je;
1454
1453
  {
1455
1454
  let l = `%c${o}`;
1456
1455
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.info.bind(
1457
1456
  a,
1458
1457
  l,
1459
- `color:${De(l)};font-weight:bold`,
1458
+ `color:${Fe(l)};font-weight:bold`,
1460
1459
  "color:#777",
1461
1460
  "color:#aaa",
1462
1461
  "color:#777"
@@ -1465,15 +1464,15 @@ class rr {
1465
1464
  },
1466
1465
  get log() {
1467
1466
  var h;
1468
- const o = n.get();
1469
- if (s(r, x).log === !1 || q(s(r, x).log) && s(r, x).log !== r.getEnv() || !s(h = r, Q).call(h, o))
1470
- return Ae;
1467
+ const o = r.get();
1468
+ if (s(n, R).log === !1 || V(s(n, R).log) && s(n, R).log !== n.getEnv() || !s(h = n, B).call(h, o))
1469
+ return je;
1471
1470
  {
1472
1471
  let l = `%c${o}`;
1473
1472
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.log.bind(
1474
1473
  a,
1475
1474
  l,
1476
- `color:${De(l)};font-weight:bold`,
1475
+ `color:${Fe(l)};font-weight:bold`,
1477
1476
  "color:#777",
1478
1477
  "color:#aaa",
1479
1478
  "color:#777"
@@ -1482,15 +1481,15 @@ class rr {
1482
1481
  },
1483
1482
  get warn() {
1484
1483
  var h;
1485
- const o = n.get();
1486
- if (s(r, x).warn === !1 || q(s(r, x).warn) && s(r, x).warn !== r.getEnv() || !s(h = r, Q).call(h, o))
1487
- return Ae;
1484
+ const o = r.get();
1485
+ if (s(n, R).warn === !1 || V(s(n, R).warn) && s(n, R).warn !== n.getEnv() || !s(h = n, B).call(h, o))
1486
+ return je;
1488
1487
  {
1489
1488
  let l = `%c${o}`;
1490
1489
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.warn.bind(
1491
1490
  a,
1492
1491
  l,
1493
- `color:${De(l)};font-weight:bold`,
1492
+ `color:${Fe(l)};font-weight:bold`,
1494
1493
  "color:#777",
1495
1494
  "color:#aaa",
1496
1495
  "color:#777"
@@ -1499,15 +1498,15 @@ class rr {
1499
1498
  },
1500
1499
  get error() {
1501
1500
  var h;
1502
- const o = n.get();
1503
- if (s(r, x).error === !1 || q(s(r, x).error) && s(r, x).error !== r.getEnv() || !s(h = r, Q).call(h, o))
1504
- return Ae;
1501
+ const o = r.get();
1502
+ if (s(n, R).error === !1 || V(s(n, R).error) && s(n, R).error !== n.getEnv() || !s(h = n, B).call(h, o))
1503
+ return je;
1505
1504
  {
1506
1505
  let l = `%c${o}`;
1507
1506
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.error.bind(
1508
1507
  a,
1509
1508
  l,
1510
- `color:${De(l)};font-weight:bold`,
1509
+ `color:${Fe(l)};font-weight:bold`,
1511
1510
  "color:#777",
1512
1511
  "color:#aaa",
1513
1512
  "color:#777"
@@ -1515,45 +1514,53 @@ class rr {
1515
1514
  }
1516
1515
  },
1517
1516
  crash(o) {
1518
- throw r.isMounted && (r.unmount(), r.constructView(s(r, Ne), {
1517
+ throw n.isMounted && (n.unmount(), n.constructView(s(n, Ne), {
1519
1518
  error: o,
1520
- loggerName: n.get(),
1519
+ loggerName: r.get(),
1521
1520
  uid: t == null ? void 0 : t.uid
1522
- }).mount(s(r, K))), o;
1521
+ }).mount(s(n, G))), o;
1523
1522
  }
1524
1523
  };
1525
1524
  }
1526
1525
  /**
1527
1526
  *
1528
1527
  */
1529
- constructView(e, t, n = []) {
1530
- return jt({ root: this, data: {} }, e, t, n);
1528
+ constructView(e, t, r = []) {
1529
+ return At({ root: this, data: {} }, e, t, r);
1531
1530
  }
1532
1531
  /**
1533
1532
  *
1534
1533
  */
1535
1534
  constructMarkup(e) {
1536
- return At(Dt({ root: this, data: {} }, e));
1535
+ return jt(Ft({ root: this, data: {} }, e));
1537
1536
  }
1538
1537
  }
1539
- B = new WeakMap(), Le = new WeakMap(), K = new WeakMap(), re = new WeakMap(), Ne = new WeakMap(), Oe = new WeakMap(), Me = new WeakMap(), Te = new WeakMap(), je = new WeakMap(), x = new WeakMap(), Q = new WeakMap();
1540
- const dt = new rr(), ir = dt.i18n.t.bind(dt.i18n);
1538
+ W = new WeakMap(), Oe = new WeakMap(), G = new WeakMap(), ee = new WeakMap(), Ne = new WeakMap(), Me = new WeakMap(), Te = new WeakMap(), De = new WeakMap(), _e = new WeakMap(), Ae = new WeakMap(), R = new WeakMap(), B = new WeakMap();
1539
+ const gt = new nr(), or = gt.i18n.t.bind(gt.i18n);
1540
+ function lr(i) {
1541
+ typeof window < "u" && (window.DOLLA_DEV_DEBUG = i);
1542
+ }
1543
+ function cr() {
1544
+ return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
1545
+ }
1541
1546
  export {
1542
- Pt as cond,
1543
- ht as createMarkup,
1544
- Ot as createRef,
1545
- xt as createSettableState,
1546
- cr as createSetter,
1547
- oe as createState,
1548
- dt as default,
1549
- ye as derive,
1550
- ot as html,
1551
- Mt as isRef,
1552
- ur as portal,
1553
- hr as repeat,
1554
- ir as t,
1555
- Lt as toSettableState,
1556
- Qe as toState,
1557
- Nt as valueOf
1547
+ Lt as cond,
1548
+ pt as createMarkup,
1549
+ Tt as createRef,
1550
+ Ot as createSettableState,
1551
+ fr as createSetter,
1552
+ se as createState,
1553
+ gt as default,
1554
+ we as derive,
1555
+ cr as getDevDebug,
1556
+ ct as html,
1557
+ Dt as isRef,
1558
+ dr as portal,
1559
+ pr as repeat,
1560
+ lr as setDevDebug,
1561
+ or as t,
1562
+ Nt as toSettableState,
1563
+ ft as toState,
1564
+ Mt as valueOf
1558
1565
  };
1559
1566
  //# sourceMappingURL=index.js.map