@manyducks.co/dolla 2.0.0-alpha.2 → 2.0.0-alpha.20

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