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

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 Dt = 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 Nt = (i, e, t) => e in i ? Dt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
6
+ var P = (i, e, t) => Nt(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), b = (i, e, t, r) => (Ze(i, e, "write to private field"), r ? r.call(i, t) : e.set(i, t), t), v = (i, e, t) => (Ze(i, e, "access private method"), t);
8
+ var et = (i, e, t, r) => ({
9
+ set _(n) {
10
+ b(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 oe, d as be, b as dt, e as V, t as gt, f as kt, j as Mt, k as nt, P as St, l as wt, m as qt, n as Ft, o as At, v as _t, p as Ct, q as Vt, r as yt, s as It, u as Ut, w as Ce, x as Ve, V as Ht, y as Wt, z as Bt } from "./passthrough-6Lrg96Id.js";
17
+ import { A as kr, B as Sr, C as Pr } from "./passthrough-6Lrg96Id.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 J, Qe, j, F;
66
+ class zt {
67
67
  constructor() {
68
- u(this, N);
69
- u(this, J, []);
70
- u(this, _e, Tt());
68
+ h(this, j);
69
+ h(this, J, []);
70
+ h(this, Qe, Kt());
71
71
  }
72
72
  /**
73
73
  * Adds a new middleware that will apply to subsequent requests.
@@ -76,364 +76,557 @@ 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, J).push(e), () => {
80
+ s(this, J).splice(s(this, J).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 v(this, j, 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 v(this, j, 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 v(this, j, 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 v(this, j, 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 v(this, j, 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 v(this, j, 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 v(this, j, 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 v(this, j, 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
+ J = new WeakMap(), Qe = new WeakMap(), j = 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, J),
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, le, ne, at, Pt;
230
+ class er {
200
231
  constructor(e, t) {
201
- k(this, "dolla");
202
- k(this, "config");
203
- k(this, "strings");
232
+ h(this, ne);
233
+ P(this, "dolla");
234
+ P(this, "config");
235
+ h(this, Je, !1);
236
+ h(this, le, /* @__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 = v(this, ne, at).call(this, e);
260
+ for (const r of t)
261
+ s(this, le).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, le).get(e) ?? {
267
+ segments: [{ type: 0, text: `[MISSING: ${e}]` }]
268
+ };
269
+ }
270
+ hasTemplate(e) {
271
+ return s(this, le).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(), le = new WeakMap(), ne = 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("."), v(this, ne, Pt).call(this, e[n])]);
280
+ break;
281
+ case "object":
282
+ r.push(...v(this, ne, 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
+ }, Pt = 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 $e, I, L, Ee, ke, Se, Pe, R, xt, st, it, ot, Ot;
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, $e);
344
+ h(this, I);
345
+ h(this, L, /* @__PURE__ */ new Map());
346
+ h(this, Ee, []);
347
+ h(this, ke, /* @__PURE__ */ new Map());
348
+ h(this, Se, "auto");
349
+ P(this, "$locale");
350
+ h(this, Pe);
351
+ b(this, $e, e), b(this, I, e.createLogger("dolla/i18n"));
352
+ const [t, r] = oe();
353
+ this.$locale = t, b(this, Pe, r), this.addFormat("number", (n, a, o) => v(this, R, st).call(this, Number(a), o)), this.addFormat("datetime", (n, a, o) => v(this, R, it).call(this, a, o)), this.addFormat("list", (n, a, o) => v(this, R, ot).call(this, a, o)), e.beforeMount(async () => {
354
+ s(this, L).size > 0 && await this.setLocale(s(this, Se));
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, $e)));
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
+ b(this, Se, 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(), b(this, Ee, []), s(this, Pe).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 v(this, R, xt).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, ke).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) => v(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) => v(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) => v(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
+ $e = new WeakMap(), I = new WeakMap(), L = new WeakMap(), Ee = new WeakMap(), ke = new WeakMap(), Se = new WeakMap(), Pe = new WeakMap(), R = new WeakSet(), xt = function(e, t, r) {
484
+ var l;
485
+ const n = v(this, R, Ot).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, ke).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
+ Ot = function(e, t) {
529
+ for (const r of s(this, Ee))
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 xe, ce, U, Y, X, ue, 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, xe);
547
+ h(this, ce);
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, U, /* @__PURE__ */ new Map());
551
+ // All unkeyed writes are run on every batch.
552
+ h(this, Y, []);
553
+ // All read callbacks are run before updates on every batch.
554
+ h(this, X, []);
555
+ h(this, ue, !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
+ b(this, xe, e), b(this, ce, 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, X).push(e), v(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
+ t ? s(this, U).set(t, e) : s(this, Y).push(e), v(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;
579
+ xe = new WeakMap(), ce = new WeakMap(), U = new WeakMap(), Y = new WeakMap(), X = new WeakMap(), ue = new WeakMap(), Ye = new WeakMap(), A = new WeakMap(), Oe = new WeakMap(), _ = new WeakSet(), lt = function() {
580
+ if (!s(this, ue)) {
581
+ b(this, ue, !0);
582
+ const e = s(this, xe).getEnv() === "development";
583
+ queueMicrotask(() => {
584
+ v(this, _, Ie).call(this, e);
585
+ });
405
586
  }
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
- });
587
+ }, Ie = function(e = !1) {
588
+ const t = performance.now();
589
+ let r = 0;
590
+ const n = s(this, X).length + s(this, U).size + s(this, Y).length;
591
+ let a = 0;
592
+ const o = () => (a++, r = performance.now() - t, s(this, Ye) && r > 12 && a < n ? (et(this, A)._++, e && s(this, ce).warn(
593
+ `⚠️ 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)}).`
594
+ ), requestAnimationFrame(() => {
595
+ v(this, _, Ie).call(this, e);
596
+ }), !0) : !1), p = [...s(this, U).entries()];
597
+ let l;
598
+ for (; l = s(this, X).shift(); )
599
+ if (l(), o()) return;
600
+ for (const [f, m] of p)
601
+ if (m(), s(this, U).delete(f), o()) return;
602
+ for (; l = s(this, Y).shift(); )
603
+ if (l(), o()) return;
604
+ e && s(this, ce)[r > 16 ? "warn" : "info"](
605
+ `${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"})` : ""}.`
606
+ ), b(this, A, 0), s(this, X).length || s(this, U).size || s(this, Y).length ? queueMicrotask(() => {
607
+ v(this, _, Ie).call(this, e);
608
+ }) : b(this, ue, !1);
415
609
  };
416
- function fe() {
417
- return fe = Object.assign || function(n) {
610
+ function pe() {
611
+ return pe = Object.assign ? Object.assign.bind() : function(i) {
418
612
  for (var e = 1; e < arguments.length; e++) {
419
613
  var t = arguments[e];
420
- for (var r in t)
421
- Object.prototype.hasOwnProperty.call(t, r) && (n[r] = t[r]);
614
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (i[r] = t[r]);
422
615
  }
423
- return n;
424
- }, fe.apply(this, arguments);
616
+ return i;
617
+ }, pe.apply(null, arguments);
425
618
  }
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;
619
+ var M;
620
+ (function(i) {
621
+ i.Pop = "POP", i.Push = "PUSH", i.Replace = "REPLACE";
622
+ })(M || (M = {}));
623
+ var Be = process.env.NODE_ENV !== "production" ? function(i) {
624
+ return Object.freeze(i);
625
+ } : function(i) {
626
+ return i;
434
627
  };
435
- function je(n, e) {
436
- if (!n) {
628
+ function Ue(i, e) {
629
+ if (!i) {
437
630
  typeof console < "u" && console.warn(e);
438
631
  try {
439
632
  throw new Error(e);
@@ -441,38 +634,38 @@ function je(n, e) {
441
634
  }
442
635
  }
443
636
  }
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,
637
+ var Ge = "beforeunload", ar = "hashchange", Lt = "popstate";
638
+ function sr(i) {
639
+ i === void 0 && (i = {});
640
+ var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, n = r.history;
641
+ function a() {
642
+ var w = r.location, c = w.pathname, d = w.search, $ = w.hash, E = n.state || {};
643
+ return [E.idx, Be({
644
+ pathname: c,
645
+ search: d,
646
+ hash: $,
454
647
  state: E.usr || null,
455
648
  key: E.key || "default"
456
649
  })];
457
650
  }
458
651
  var o = null;
459
- function f() {
652
+ function p() {
460
653
  if (o)
461
- b.call(o), o = null;
654
+ y.call(o), o = null;
462
655
  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;
656
+ var w = M.Pop, c = a(), d = c[0], $ = c[1];
657
+ if (y.length)
658
+ if (d != null) {
659
+ var E = m - d;
467
660
  E && (o = {
468
- action: g,
469
- location: v,
661
+ action: w,
662
+ location: $,
470
663
  retry: function() {
471
- V(E * -1);
664
+ C(E * -1);
472
665
  }
473
- }, V(E));
666
+ }, C(E));
474
667
  } else
475
- process.env.NODE_ENV !== "production" && je(
668
+ process.env.NODE_ENV !== "production" && Ue(
476
669
  !1,
477
670
  // TODO: Write up a doc that explains our blocking strategy in
478
671
  // detail and link to it here so people can understand better what
@@ -480,137 +673,137 @@ function Ht(n) {
480
673
  "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
674
  );
482
675
  else
483
- re(g);
676
+ ae(w);
484
677
  }
485
678
  }
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
679
+ r.addEventListener(Lt, p);
680
+ var l = M.Pop, f = a(), m = f[0], g = f[1], u = Ke(), y = Ke();
681
+ m == null && (m = 0, n.replaceState(pe({}, n.state, {
682
+ idx: m
490
683
  }), ""));
491
- function $(g) {
492
- return typeof g == "string" ? g : Ce(g);
684
+ function k(w) {
685
+ return typeof w == "string" ? w : He(w);
493
686
  }
494
- function j(g, l) {
495
- return l === void 0 && (l = null), Ue(fe({
496
- pathname: p.pathname,
687
+ function me(w, c) {
688
+ return c === void 0 && (c = null), Be(pe({
689
+ pathname: g.pathname,
497
690
  hash: "",
498
691
  search: ""
499
- }, typeof g == "string" ? Qe(g) : g, {
500
- state: l,
501
- key: gt()
692
+ }, typeof w == "string" ? ct(w) : w, {
693
+ state: c,
694
+ key: Rt()
502
695
  }));
503
696
  }
504
- function de(g, l) {
697
+ function ge(w, c) {
505
698
  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
699
+ usr: w.state,
700
+ key: w.key,
701
+ idx: c
702
+ }, k(w)];
703
+ }
704
+ function we(w, c, d) {
705
+ return !y.length || (y.call({
706
+ action: w,
707
+ location: c,
708
+ retry: d
516
709
  }), !1);
517
710
  }
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
711
+ function ae(w) {
712
+ l = w;
713
+ var c = a();
714
+ m = c[0], g = c[1], u.call({
715
+ action: l,
716
+ location: g
524
717
  });
525
718
  }
526
- function ne(g, l) {
527
- var h = A.Push, v = j(g, l);
719
+ function se(w, c) {
720
+ var d = M.Push, $ = me(w, c);
528
721
  function E() {
529
- ne(g, l);
722
+ se(w, c);
530
723
  }
531
- if (ge(h, v, E)) {
532
- var S = de(v, w + 1), M = S[0], O = S[1];
724
+ if (we(d, $, E)) {
725
+ var x = ge($, m + 1), D = x[0], T = x[1];
533
726
  try {
534
- s.pushState(M, "", O);
727
+ n.pushState(D, "", T);
535
728
  } catch {
536
- r.location.assign(O);
729
+ r.location.assign(T);
537
730
  }
538
- re(h);
731
+ ae(d);
539
732
  }
540
733
  }
541
- function pe(g, l) {
542
- var h = A.Replace, v = j(g, l);
734
+ function ye(w, c) {
735
+ var d = M.Replace, $ = me(w, c);
543
736
  function E() {
544
- pe(g, l);
737
+ ye(w, c);
545
738
  }
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);
739
+ if (we(d, $, E)) {
740
+ var x = ge($, m), D = x[0], T = x[1];
741
+ n.replaceState(D, "", T), ae(d);
549
742
  }
550
743
  }
551
- function V(g) {
552
- s.go(g);
744
+ function C(w) {
745
+ n.go(w);
553
746
  }
554
747
  var Q = {
555
748
  get action() {
556
- return c;
749
+ return l;
557
750
  },
558
751
  get location() {
559
- return p;
752
+ return g;
560
753
  },
561
- createHref: $,
562
- push: ne,
563
- replace: pe,
564
- go: V,
754
+ createHref: k,
755
+ push: se,
756
+ replace: ye,
757
+ go: C,
565
758
  back: function() {
566
- V(-1);
759
+ C(-1);
567
760
  },
568
761
  forward: function() {
569
- V(1);
762
+ C(1);
570
763
  },
571
- listen: function(l) {
572
- return d.push(l);
764
+ listen: function(c) {
765
+ return u.push(c);
573
766
  },
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);
767
+ block: function(c) {
768
+ var d = y.push(c);
769
+ return y.length === 1 && r.addEventListener(Ge, ze), function() {
770
+ d(), y.length || r.removeEventListener(Ge, ze);
578
771
  };
579
772
  }
580
773
  };
581
774
  return Q;
582
775
  }
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"
776
+ function ir(i) {
777
+ i === void 0 && (i = {});
778
+ var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, n = r.history;
779
+ function a() {
780
+ 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, T = D === void 0 ? "" : D, q = n.state || {};
781
+ return [q.idx, Be({
782
+ pathname: $,
783
+ search: x,
784
+ hash: T,
785
+ state: q.usr || null,
786
+ key: q.key || "default"
594
787
  })];
595
788
  }
596
789
  var o = null;
597
- function f() {
790
+ function p() {
598
791
  if (o)
599
- b.call(o), o = null;
792
+ y.call(o), o = null;
600
793
  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,
794
+ var c = M.Pop, d = a(), $ = d[0], E = d[1];
795
+ if (y.length)
796
+ if ($ != null) {
797
+ var x = m - $;
798
+ x && (o = {
799
+ action: c,
607
800
  location: E,
608
801
  retry: function() {
609
- Q(S * -1);
802
+ Q(x * -1);
610
803
  }
611
- }, Q(S));
804
+ }, Q(x));
612
805
  } else
613
- process.env.NODE_ENV !== "production" && je(
806
+ process.env.NODE_ENV !== "production" && Ue(
614
807
  !1,
615
808
  // TODO: Write up a doc that explains our blocking strategy in
616
809
  // detail and link to it here so people can understand better
@@ -618,98 +811,98 @@ function _t(n) {
618
811
  "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
812
  );
620
813
  else
621
- ne(l);
814
+ se(c);
622
815
  }
623
816
  }
624
- r.addEventListener(dt, f), r.addEventListener(Dt, function() {
625
- var l = i(), h = l[1];
626
- Ce(h) !== Ce(p) && f();
817
+ r.addEventListener(Lt, p), r.addEventListener(ar, function() {
818
+ var c = a(), d = c[1];
819
+ He(d) !== He(g) && p();
627
820
  });
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
821
+ var l = M.Pop, f = a(), m = f[0], g = f[1], u = Ke(), y = Ke();
822
+ m == null && (m = 0, n.replaceState(pe({}, n.state, {
823
+ idx: m
631
824
  }), ""));
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);
825
+ function k() {
826
+ var c = document.querySelector("base"), d = "";
827
+ if (c && c.getAttribute("href")) {
828
+ var $ = r.location.href, E = $.indexOf("#");
829
+ d = E === -1 ? $ : $.slice(0, E);
637
830
  }
638
- return h;
831
+ return d;
639
832
  }
640
- function j(l) {
641
- return $() + "#" + (typeof l == "string" ? l : Ce(l));
833
+ function me(c) {
834
+ return k() + "#" + (typeof c == "string" ? c : He(c));
642
835
  }
643
- function de(l, h) {
644
- return h === void 0 && (h = null), Ue(fe({
645
- pathname: p.pathname,
836
+ function ge(c, d) {
837
+ return d === void 0 && (d = null), Be(pe({
838
+ pathname: g.pathname,
646
839
  hash: "",
647
840
  search: ""
648
- }, typeof l == "string" ? Qe(l) : l, {
649
- state: h,
650
- key: gt()
841
+ }, typeof c == "string" ? ct(c) : c, {
842
+ state: d,
843
+ key: Rt()
651
844
  }));
652
845
  }
653
- function ge(l, h) {
846
+ function we(c, d) {
654
847
  return [{
655
- usr: l.state,
656
- key: l.key,
657
- idx: h
658
- }, j(l)];
848
+ usr: c.state,
849
+ key: c.key,
850
+ idx: d
851
+ }, me(c)];
659
852
  }
660
- function re(l, h, v) {
661
- return !b.length || (b.call({
662
- action: l,
663
- location: h,
664
- retry: v
853
+ function ae(c, d, $) {
854
+ return !y.length || (y.call({
855
+ action: c,
856
+ location: d,
857
+ retry: $
665
858
  }), !1);
666
859
  }
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
860
+ function se(c) {
861
+ l = c;
862
+ var d = a();
863
+ m = d[0], g = d[1], u.call({
864
+ action: l,
865
+ location: g
673
866
  });
674
867
  }
675
- function pe(l, h) {
676
- var v = A.Push, E = de(l, h);
677
- function S() {
678
- pe(l, h);
868
+ function ye(c, d) {
869
+ var $ = M.Push, E = ge(c, d);
870
+ function x() {
871
+ ye(c, d);
679
872
  }
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];
873
+ if (process.env.NODE_ENV !== "production" && Ue(E.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"), ae($, E, x)) {
874
+ var D = we(E, m + 1), T = D[0], q = D[1];
682
875
  try {
683
- s.pushState(O, "", C);
876
+ n.pushState(T, "", q);
684
877
  } catch {
685
- r.location.assign(C);
878
+ r.location.assign(q);
686
879
  }
687
- ne(v);
880
+ se($);
688
881
  }
689
882
  }
690
- function V(l, h) {
691
- var v = A.Replace, E = de(l, h);
692
- function S() {
693
- V(l, h);
883
+ function C(c, d) {
884
+ var $ = M.Replace, E = ge(c, d);
885
+ function x() {
886
+ C(c, d);
694
887
  }
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);
888
+ if (process.env.NODE_ENV !== "production" && Ue(E.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"), ae($, E, x)) {
889
+ var D = we(E, m), T = D[0], q = D[1];
890
+ n.replaceState(T, "", q), se($);
698
891
  }
699
892
  }
700
- function Q(l) {
701
- s.go(l);
893
+ function Q(c) {
894
+ n.go(c);
702
895
  }
703
- var g = {
896
+ var w = {
704
897
  get action() {
705
- return c;
898
+ return l;
706
899
  },
707
900
  get location() {
708
- return p;
901
+ return g;
709
902
  },
710
- createHref: j,
711
- push: pe,
712
- replace: V,
903
+ createHref: me,
904
+ push: ye,
905
+ replace: C,
713
906
  go: Q,
714
907
  back: function() {
715
908
  Q(-1);
@@ -717,80 +910,80 @@ function _t(n) {
717
910
  forward: function() {
718
911
  Q(1);
719
912
  },
720
- listen: function(h) {
721
- return d.push(h);
913
+ listen: function(d) {
914
+ return u.push(d);
722
915
  },
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);
916
+ block: function(d) {
917
+ var $ = y.push(d);
918
+ return y.length === 1 && r.addEventListener(Ge, ze), function() {
919
+ $(), y.length || r.removeEventListener(Ge, ze);
727
920
  };
728
921
  }
729
922
  };
730
- return g;
923
+ return w;
731
924
  }
732
- function De(n) {
733
- n.preventDefault(), n.returnValue = "";
925
+ function ze(i) {
926
+ i.preventDefault(), i.returnValue = "";
734
927
  }
735
- function He() {
736
- var n = [];
928
+ function Ke() {
929
+ var i = [];
737
930
  return {
738
931
  get length() {
739
- return n.length;
932
+ return i.length;
740
933
  },
741
934
  push: function(t) {
742
- return n.push(t), function() {
743
- n = n.filter(function(r) {
935
+ return i.push(t), function() {
936
+ i = i.filter(function(r) {
744
937
  return r !== t;
745
938
  });
746
939
  };
747
940
  },
748
941
  call: function(t) {
749
- n.forEach(function(r) {
942
+ i.forEach(function(r) {
750
943
  return r && r(t);
751
944
  });
752
945
  }
753
946
  };
754
947
  }
755
- function gt() {
948
+ function Rt() {
756
949
  return Math.random().toString(36).substr(2, 8);
757
950
  }
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;
951
+ function He(i) {
952
+ 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;
953
+ return n && n !== "?" && (t += n.charAt(0) === "?" ? n : "?" + n), o && o !== "#" && (t += o.charAt(0) === "#" ? o : "#" + o), t;
761
954
  }
762
- function Qe(n) {
955
+ function ct(i) {
763
956
  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);
957
+ if (i) {
958
+ var t = i.indexOf("#");
959
+ t >= 0 && (e.hash = i.substr(t), i = i.substr(0, t));
960
+ var r = i.indexOf("?");
961
+ r >= 0 && (e.search = i.substr(r), i = i.substr(0, r)), i && (e.pathname = i);
769
962
  }
770
963
  return e;
771
964
  }
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 !== "");
965
+ function ve(i) {
966
+ return kt(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((e) => e.trim()).filter((e) => e !== "");
774
967
  }
775
- function ae(n) {
968
+ function ie(i) {
776
969
  var t;
777
- vt(
778
- (r) => Xe(r == null ? void 0 : r.toString),
779
- n,
970
+ Mt(
971
+ (r) => dt(r == null ? void 0 : r.toString),
972
+ i,
780
973
  "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();
974
+ ), i = i.filter((r) => r).flatMap(String);
975
+ let e = (t = i.shift()) == null ? void 0 : t.toString();
783
976
  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;
977
+ for (const r of i.map((n) => n.toString()))
978
+ 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
979
  e && e !== "/" && e.endsWith("/") && (e = e.slice(0, e.length - 1));
787
980
  }
788
981
  return e ?? "";
789
982
  }
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("/"))
983
+ function We(i, e) {
984
+ if (kt(i, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = i, i = ""), e.startsWith("/"))
792
985
  return e;
793
- let t = n;
986
+ let t = i;
794
987
  for (; ; )
795
988
  if (e.startsWith("..")) {
796
989
  for (let r = t.length; r > 0; --r)
@@ -802,179 +995,196 @@ function qe(n, e) {
802
995
  e = e.replace(/^\.\/?/, "");
803
996
  else
804
997
  break;
805
- return ae([t, e]);
998
+ return ie([t, e]);
806
999
  }
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)];
1000
+ function ut(i) {
1001
+ if (!i) return {};
1002
+ i.startsWith("?") && (i = i.slice(1));
1003
+ const e = i.split("&").filter((t) => t.trim() !== "").map((t) => {
1004
+ const [r, n] = t.split("=").map((a) => a.trim());
1005
+ return n.toLowerCase() === "true" ? [r, !0] : n.toLowerCase() === "false" ? [r, !1] : isNaN(Number(n)) ? [r, n] : [r, Number(n)];
813
1006
  });
814
1007
  return Object.fromEntries(e);
815
1008
  }
816
- function ot(n, e, t = {}) {
1009
+ function vt(i, e, t = {}) {
817
1010
  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))
1011
+ const [r, n] = e.split("?"), a = ve(r);
1012
+ e: for (const p of i) {
1013
+ const { fragments: l } = p;
1014
+ if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== a.length || t.willMatch && !t.willMatch(p))
822
1015
  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)
1016
+ const m = [];
1017
+ t: for (let u = 0; u < l.length; u++) {
1018
+ const y = a[u], k = l[u];
1019
+ if (y == null && k.type !== 3)
827
1020
  continue e;
828
- switch ($.type) {
1021
+ switch (k.type) {
829
1022
  case 1:
830
- if ($.name.toLowerCase() === b.toLowerCase()) {
831
- w.push($);
1023
+ if (k.name.toLowerCase() === y.toLowerCase()) {
1024
+ m.push(k);
832
1025
  break;
833
1026
  } else
834
1027
  continue e;
835
1028
  case 2:
836
- w.push({ ...$, value: b });
1029
+ m.push({ ...k, value: y });
837
1030
  break;
838
1031
  case 3:
839
- w.push({ ...$, value: i.slice(d).join("/") });
1032
+ m.push({ ...k, value: a.slice(u).join("/") });
840
1033
  break t;
841
1034
  case 4:
842
- if (isNaN(Number(b)))
1035
+ if (isNaN(Number(y)))
843
1036
  continue e;
844
- w.push({ ...$, value: Number(b) });
1037
+ m.push({ ...k, value: Number(y) });
845
1038
  break;
846
1039
  default:
847
- throw new Error(`Unknown fragment type: ${$.type}`);
1040
+ throw new Error(`Unknown fragment type: ${k.type}`);
848
1041
  }
849
1042
  }
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));
1043
+ const g = {};
1044
+ for (const u of m)
1045
+ 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
1046
  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
1047
+ path: "/" + m.map((u) => u.value).join("/"),
1048
+ pattern: "/" + l.map((u) => u.type === 2 ? `{${u.name}}` : u.type === 4 ? `{#${u.name}}` : u.name).join("/"),
1049
+ params: g,
1050
+ query: ut(n),
1051
+ meta: p.meta
859
1052
  };
860
1053
  }
861
1054
  }
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
1055
+ function or(i) {
1056
+ const e = [], t = [], r = [], n = [];
1057
+ for (const o of i) {
1058
+ const { fragments: p } = o;
1059
+ p.some(
1060
+ (l) => l.type === 3
868
1061
  /* Wildcard */
869
- ) ? s.push(o) : f.some(
870
- (c) => c.type === 4
1062
+ ) ? n.push(o) : p.some(
1063
+ (l) => l.type === 4
871
1064
  /* NumericParam */
872
- ) ? t.push(o) : f.some(
873
- (c) => c.type === 2
1065
+ ) ? t.push(o) : p.some(
1066
+ (l) => l.type === 2
874
1067
  /* Param */
875
1068
  ) ? r.push(o) : e.push(o);
876
1069
  }
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];
1070
+ const a = (o, p) => o.fragments.length > p.fragments.length ? -1 : 1;
1071
+ return e.sort(a), t.sort(a), r.sort(a), n.sort(a), [...e, ...t, ...r, ...n];
879
1072
  }
880
- function zt(n) {
881
- const e = me(n), t = [];
1073
+ function lr(i) {
1074
+ const e = ve(i), t = [];
882
1075
  for (let r = 0; r < e.length; r++) {
883
- const s = e[r];
884
- if (s === "*") {
1076
+ const n = e[r];
1077
+ if (n === "*") {
885
1078
  if (r !== e.length - 1)
886
- throw new Error(`Wildcard must be at the end of a pattern. Received: ${n}`);
1079
+ throw new Error(`Wildcard must be at the end of a pattern. Received: ${i}`);
887
1080
  t.push({
888
1081
  type: 3,
889
1082
  name: "*",
890
1083
  value: null
891
1084
  });
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),
1085
+ } else n.at(0) === "{" && n.at(-1) === "}" ? t.push({
1086
+ type: n[1] === "#" ? 4 : 2,
1087
+ name: n[1] === "#" ? n.slice(2, -1) : n.slice(1, -1),
895
1088
  value: null
896
1089
  }) : t.push({
897
1090
  type: 1,
898
- name: s,
899
- value: s
1091
+ name: n,
1092
+ value: n
900
1093
  });
901
1094
  }
902
1095
  return t;
903
1096
  }
904
- var Ee, T, Z, L, ze, W, ke, ee, z, le, he, ue, Le, B, Je, Ye;
905
- class Ft {
1097
+ const $t = (i, e) => {
1098
+ if (Object.keys(i).length !== Object.keys(e).length)
1099
+ return !1;
1100
+ for (const t in i)
1101
+ if (i[t] !== e[t])
1102
+ return !1;
1103
+ return !0;
1104
+ };
1105
+ var Le, N, Z, Re, S, Xe, H, De, ee, te, he, fe, de, Ne, K, ht, ft;
1106
+ class cr {
906
1107
  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, []);
1108
+ h(this, K);
1109
+ h(this, Le);
1110
+ h(this, N);
1111
+ h(this, Z);
1112
+ h(this, Re, nt());
1113
+ h(this, S);
1114
+ h(this, Xe, 0);
1115
+ h(this, H, []);
1116
+ h(this, De);
1117
+ h(this, ee, []);
916
1118
  // Callbacks that need to be called on unmount.
917
- u(this, z, []);
1119
+ h(this, te, []);
918
1120
  /**
919
1121
  * The currently matched route pattern, if any.
920
1122
  */
921
- k(this, "$pattern");
922
- u(this, le);
1123
+ P(this, "$pattern");
1124
+ h(this, he);
923
1125
  /**
924
1126
  * The current URL path.
925
1127
  */
926
- k(this, "$path");
927
- u(this, he);
1128
+ P(this, "$path");
1129
+ h(this, fe);
928
1130
  /**
929
1131
  * The current named path params.
930
1132
  */
931
- k(this, "$params");
932
- u(this, ue);
1133
+ P(this, "$params");
1134
+ h(this, de);
933
1135
  /**
934
1136
  * The current query params. Changes to this object will be reflected in the URL.
935
1137
  */
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);
1138
+ P(this, "$query");
1139
+ h(this, Ne);
1140
+ b(this, Le, e), b(this, N, e.createLogger("dolla/router")), b(this, Z, t);
1141
+ const [r, n] = oe(null), [a, o] = oe(""), [p, l] = oe({}, { equals: $t }), [f, m] = oe(
1142
+ ut(typeof window > "u" ? "" : window.location.search ?? ""),
1143
+ { equals: $t }
1144
+ );
1145
+ this.$pattern = r, b(this, he, n), this.$path = a, b(this, fe, o), this.$params = p, b(this, de, l), this.$query = f, b(this, Ne, m), e.beforeMount(() => {
1146
+ s(this, S) != null && (s(this, Re).watch([f], (g) => {
1147
+ const u = new URLSearchParams();
1148
+ for (const k in g)
1149
+ u.set(k, String(g[k]));
1150
+ const y = "?" + u.toString();
1151
+ y != s(this, S).location.search && s(this, S).replace({
1152
+ pathname: s(this, S).location.pathname,
1153
+ search: y
1154
+ });
1155
+ }), s(this, te).push(s(this, S).listen(v(this, K, ft).bind(this))), v(this, K, ft).call(this, s(this, S)), s(this, te).push(
1156
+ fr(s(this, Z).rootElement, (g) => {
1157
+ let u = g.getAttribute("href");
1158
+ s(this, N).info("Intercepted link click", g, u), /^https?:\/\/|^\//.test(u) || (u = ie([s(this, S).location.pathname, u])), s(this, S).push(u);
956
1159
  })
957
- ), a(this, T).info("Intercepting <a> clicks within root element:", a(this, Z).rootElement);
1160
+ ), s(this, N).info("Intercepting <a> clicks within root element:", s(this, Z).rootElement));
958
1161
  }), e.onUnmount(() => {
959
- for (; a(this, z).length > 0; )
960
- a(this, z).pop()();
1162
+ for (; s(this, te).length > 0; )
1163
+ s(this, te).pop()();
1164
+ s(this, Re).stopAll();
961
1165
  });
962
1166
  }
963
1167
  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) => ({
1168
+ if (s(this, Le).isMounted) {
1169
+ s(this, N).crash(
1170
+ new Error("Dolla is already mounted. Router setup must be called before Dolla.mount is called.")
1171
+ );
1172
+ return;
1173
+ }
1174
+ e.style === "hash" ? b(this, S, ir()) : b(this, S, sr()), b(this, ee, or(
1175
+ e.routes.flatMap((t) => v(this, K, ht).call(this, t)).map((t) => ({
966
1176
  pattern: t.pattern,
967
1177
  meta: t.meta,
968
- fragments: zt(t.pattern)
1178
+ fragments: lr(t.pattern)
969
1179
  }))
970
1180
  ));
971
- for (const t of a(this, ee))
1181
+ for (const t of s(this, ee))
972
1182
  if (t.meta.redirect) {
973
1183
  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;
1184
+ if (!dt(t.meta.redirect)) if (V(t.meta.redirect)) {
1185
+ if (r = t.meta.redirect, !vt(s(this, ee), r, {
1186
+ willMatch(a) {
1187
+ return a !== t;
978
1188
  }
979
1189
  }))
980
1190
  throw new Error(
@@ -988,33 +1198,57 @@ class Ft {
988
1198
  * Navigates to another route.
989
1199
  *
990
1200
  * @example
991
- * navigate("/login"); // navigate to `/login`
992
- * navigate(["/users", 215], { replace: true }); // replace current history entry with `/users/215`
1201
+ * Dolla.router.go("/login"); // navigate to `/login`
1202
+ * Dolla.router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
993
1203
  */
994
1204
  go(e, t = {}) {
1205
+ if (s(this, S) == null) {
1206
+ s(this, N).crash(
1207
+ new Error(
1208
+ "Router.go was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
1209
+ )
1210
+ );
1211
+ return;
1212
+ }
995
1213
  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);
1214
+ Array.isArray(e) ? r = ie(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
1215
  }
998
1216
  /**
999
1217
  * Navigate backward. Pass a number of steps to hit the back button that many times.
1000
1218
  */
1001
1219
  back(e = 1) {
1002
- a(this, L).go(-e);
1220
+ if (s(this, S) == null) {
1221
+ s(this, N).crash(
1222
+ new Error(
1223
+ "Router.back was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
1224
+ )
1225
+ );
1226
+ return;
1227
+ }
1228
+ s(this, S).go(-e);
1003
1229
  }
1004
1230
  /**
1005
1231
  * Navigate forward. Pass a number of steps to hit the forward button that many times.
1006
1232
  */
1007
1233
  forward(e = 1) {
1008
- a(this, L).go(e);
1234
+ if (s(this, S) == null) {
1235
+ s(this, N).crash(
1236
+ new Error(
1237
+ "Router.forward was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
1238
+ )
1239
+ );
1240
+ return;
1241
+ }
1242
+ s(this, S).go(e);
1009
1243
  }
1010
1244
  }
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(), /**
1245
+ Le = new WeakMap(), N = new WeakMap(), Z = new WeakMap(), Re = new WeakMap(), S = new WeakMap(), Xe = new WeakMap(), H = new WeakMap(), De = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), he = new WeakMap(), fe = new WeakMap(), de = new WeakMap(), Ne = new WeakMap(), K = new WeakSet(), /**
1012
1246
  * Parses a route definition object into a set of matchable routes.
1013
1247
  *
1014
1248
  * @param route - Route config object.
1015
1249
  * @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
1016
1250
  */
1017
- Je = function(e, t = [], r = []) {
1251
+ ht = function(e, t = [], r = []) {
1018
1252
  if (!(typeof e == "object" && !Array.isArray(e)) || typeof e.path != "string")
1019
1253
  throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${e}`);
1020
1254
  if (e.redirect && e.routes)
@@ -1023,56 +1257,57 @@ Je = function(e, t = [], r = []) {
1023
1257
  throw new Error("Route cannot have both a 'redirect' and a 'view'.");
1024
1258
  if (!e.view && !e.routes && !e.redirect)
1025
1259
  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 = [];
1260
+ let n = [];
1261
+ for (const l of t)
1262
+ n.push(...ve(l.path));
1263
+ n.push(...ve(e.path)), n[n.length - 1] === "*" && n.pop();
1264
+ const a = [];
1031
1265
  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)]),
1266
+ let l = e.redirect;
1267
+ return V(l) && (l = We(ie(n), l), l.startsWith("/") || (l = "/" + l)), a.push({
1268
+ pattern: "/" + ie([...n, ...ve(e.path)]),
1035
1269
  meta: {
1036
- redirect: c
1270
+ redirect: l
1037
1271
  }
1038
- }), i;
1272
+ }), a;
1039
1273
  }
1040
- let o = ut;
1274
+ let o = St;
1041
1275
  if (typeof e.view == "function")
1042
1276
  o = e.view;
1043
1277
  else if (e.view)
1044
1278
  throw new TypeError(`Route '${e.path}' expected a view function or undefined. Got: ${e.view}`);
1045
- const f = { id: et(this, ze)._++, view: o };
1279
+ const p = { id: et(this, Xe)._++, view: o };
1046
1280
  if (e.routes)
1047
- for (const c of e.routes)
1048
- i.push(...P(this, B, Je).call(this, c, [...t, e], [...r, f]));
1281
+ for (const l of e.routes)
1282
+ a.push(...v(this, K, ht).call(this, l, [...t, e], [...r, p]));
1049
1283
  else
1050
- i.push({
1051
- pattern: parent ? ae([...t.map((c) => c.path), e.path]) : e.path,
1284
+ a.push({
1285
+ pattern: parent ? ie([...t.map((l) => l.path), e.path]) : e.path,
1052
1286
  meta: {
1053
1287
  pattern: e.path,
1054
- layers: [...r, f],
1288
+ layers: [...r, p],
1055
1289
  beforeMatch: e.beforeMatch
1056
1290
  }
1057
1291
  });
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);
1292
+ return a;
1293
+ }, ft = async function({ location: e }) {
1294
+ e.search !== s(this, De) && (b(this, De, e.search), s(this, Ne).call(this, ut(e.search)));
1295
+ const t = vt(s(this, ee), e.pathname);
1062
1296
  if (!t) {
1063
- a(this, le).call(this, null), a(this, he).call(this, e.pathname), a(this, ue).call(this, {
1297
+ s(this, he).call(this, null), s(this, fe).call(this, e.pathname), s(this, de).call(this, {
1064
1298
  wildcard: e.pathname
1065
1299
  });
1066
1300
  return;
1067
1301
  }
1068
1302
  if (t.meta.beforeMatch && await t.meta.beforeMatch({
1303
+ // TODO: Allow setting context variables from here.
1069
1304
  redirect: (r) => {
1070
1305
  throw new Error("Redirect not yet implemented.");
1071
1306
  }
1072
- }), a(this, T).info(`Matched route: '${t.pattern}' ('${t.path}')`), t.meta.redirect != null)
1307
+ }), t.meta.redirect != null)
1073
1308
  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);
1309
+ const r = dr(t.meta.redirect, t.params);
1310
+ s(this, N).info(`↩️ redirecting from '${t.path}' to '${r}'`), s(this, S).replace(r);
1076
1311
  } else if (typeof t.meta.redirect == "function") {
1077
1312
  const r = {
1078
1313
  path: t.path,
@@ -1080,86 +1315,94 @@ Je = function(e, t = [], r = []) {
1080
1315
  params: t.params,
1081
1316
  query: t.query
1082
1317
  };
1083
- let s = await t.meta.redirect(r);
1084
- if (typeof s != "string")
1318
+ let n = await t.meta.redirect(r);
1319
+ if (typeof n != "string")
1085
1320
  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);
1321
+ n.startsWith("/") || (n = We(t.path, n)), s(this, N).info(`Redirecting to: '${n}'`), s(this, S).replace(n);
1087
1322
  } else
1088
1323
  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);
1324
+ else if (s(this, N).info(`📍 navigating to '${t.path}'`), s(this, fe).call(this, t.path), s(this, de).call(this, t.params), t.pattern !== this.$pattern.get()) {
1325
+ s(this, he).call(this, t.pattern);
1091
1326
  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 });
1327
+ for (let n = 0; n < r.length; n++) {
1328
+ const a = r[n], o = s(this, H)[n];
1329
+ if ((o == null ? void 0 : o.id) !== a.id) {
1330
+ b(this, H, s(this, H).slice(0, n));
1331
+ const p = s(this, H).at(-1);
1332
+ o && o.node.isMounted && o.node.unmount(!1);
1333
+ let l;
1334
+ p ? l = p.node.setChildView(a.view) : l = s(this, Z).rootView.setChildView(a.view), s(this, H).push({ id: a.id, node: l });
1098
1335
  }
1099
1336
  }
1100
1337
  }
1101
1338
  };
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;
1339
+ const ur = /(noopener|noreferrer) (noopener|noreferrer)/, hr = /^[\w-_]+:/;
1340
+ function fr(i, e, t = window) {
1341
+ function r(a) {
1342
+ return !a || a === i ? null : a.localName !== "a" || a.href === void 0 ? r(a.parentNode) : a;
1106
1343
  }
1107
- function s(i) {
1108
- if (i.button && i.button !== 0 || i.ctrlKey || i.metaKey || i.altKey || i.shiftKey || i.defaultPrevented)
1344
+ function n(a) {
1345
+ if (a.button && a.button !== 0 || a.ctrlKey || a.metaKey || a.altKey || a.shiftKey || a.defaultPrevented)
1109
1346
  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)));
1347
+ const o = r(a.target);
1348
+ 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
1349
  }
1113
- return n.addEventListener("click", s), function() {
1114
- n.removeEventListener("click", s);
1350
+ return i.addEventListener("click", n), function() {
1351
+ i.removeEventListener("click", n);
1115
1352
  };
1116
1353
  }
1117
- function Qt(n, e) {
1354
+ function dr(i, e) {
1118
1355
  for (const t in e) {
1119
1356
  const r = e[t].toString();
1120
- n = n.replace(`{${t}}`, r).replace(`{#${t}}`, r);
1357
+ i = i.replace(`{${t}}`, r).replace(`{#${t}}`, r);
1121
1358
  }
1122
- return n;
1359
+ return i;
1123
1360
  }
1124
- var F, Pe, I, te, Se, Re, xe, Me, Ne, R, G;
1125
- class Kt {
1361
+ var W, je, B, re, Te, Me, qe, Fe, Ae, _e, G, O, z;
1362
+ class pr {
1126
1363
  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, {
1364
+ P(this, "http");
1365
+ P(this, "i18n");
1366
+ P(this, "render");
1367
+ P(this, "router");
1368
+ h(this, W, !1);
1369
+ h(this, je, "production");
1370
+ h(this, B);
1371
+ h(this, re);
1372
+ h(this, Te, Gt);
1373
+ h(this, Me, nt());
1374
+ h(this, qe, []);
1375
+ h(this, Fe, []);
1376
+ h(this, Ae, []);
1377
+ h(this, _e, []);
1378
+ h(this, G, {
1379
+ root: this,
1380
+ data: {}
1381
+ });
1382
+ h(this, O, {
1141
1383
  info: "development",
1142
1384
  log: "development",
1143
1385
  warn: "development",
1144
1386
  error: !0
1145
1387
  });
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);
1388
+ h(this, z, wt("*,-dolla/*"));
1389
+ P(this, "watch", s(this, Me).watch);
1390
+ P(this, "createState", oe);
1391
+ P(this, "createSettableState", qt);
1392
+ P(this, "toSettableState", Ft);
1393
+ P(this, "toState", At);
1394
+ P(this, "valueOf", _t);
1395
+ P(this, "derive", be);
1396
+ P(this, "createWatcher", nt);
1397
+ P(this, "createRef", Ct);
1398
+ P(this, "isRef", Vt);
1156
1399
  const e = this;
1157
- this.http = new Ot(), this.language = new qt(this), this.render = new Vt(this), this.router = new Ft(this, {
1400
+ this.http = new zt(), this.i18n = new tr(this), this.render = new nr(this), this.router = new cr(this, {
1158
1401
  get rootElement() {
1159
- return a(e, I);
1402
+ return s(e, B);
1160
1403
  },
1161
1404
  get rootView() {
1162
- return a(e, te);
1405
+ return s(e, re);
1163
1406
  }
1164
1407
  });
1165
1408
  }
@@ -1167,47 +1410,65 @@ class Kt {
1167
1410
  * True when the app is connected to a DOM node and displayed to the user.
1168
1411
  */
1169
1412
  get isMounted() {
1170
- return a(this, F);
1413
+ return s(this, W);
1171
1414
  }
1172
1415
  /**
1173
1416
  * Get the current environment that this app is running in.
1174
1417
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
1175
1418
  */
1176
1419
  getEnv() {
1177
- return a(this, Pe);
1420
+ return s(this, je);
1178
1421
  }
1179
1422
  /**
1180
1423
  * Sets the environment that this app is running in.
1181
1424
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
1182
1425
  */
1183
1426
  setEnv(e) {
1184
- m(this, Pe, e);
1427
+ b(this, je, e);
1185
1428
  }
1186
1429
  /**
1187
1430
  * Sets the view that will be shown when the `crash` method is called on any logger.
1188
1431
  * When a crash is reported the app will be unmounted and replaced with this crash page.
1189
1432
  */
1190
1433
  setCrashView(e) {
1191
- m(this, Se, e);
1434
+ b(this, Te, e);
1435
+ }
1436
+ /**
1437
+ * Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
1438
+ */
1439
+ set(e, t) {
1440
+ return s(this, G).data[e] = t, t;
1441
+ }
1442
+ /**
1443
+ * Gets the value of a context variable. Returns null if the variable is not set.
1444
+ */
1445
+ get(e) {
1446
+ return s(this, G).data[e] ?? null;
1447
+ }
1448
+ /**
1449
+ * Returns an object of all context variables stored at the app level.
1450
+ */
1451
+ getAll() {
1452
+ return { ...s(this, G).data };
1192
1453
  }
1193
1454
  async mount(e, t) {
1194
- if (a(this, F))
1455
+ if (s(this, W))
1195
1456
  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);
1457
+ if (V(e)) {
1458
+ const n = document.querySelector(e);
1459
+ yt(HTMLElement, n, `Selector '${e}' did not match any element.`), b(this, B, n);
1199
1460
  } else
1200
- nt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), m(this, I, e);
1201
- 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
+ yt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this, B, e);
1462
+ const r = It(t ?? St);
1463
+ b(this, re, this.constructView(r.type, r.props)), await Promise.all(s(this, qe).map((n) => n())), s(this, re).mount(s(this, B)), b(this, W, !0);
1464
+ for (const n of s(this, Fe))
1465
+ n();
1205
1466
  }
1206
1467
  async unmount() {
1207
1468
  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))
1469
+ if (s(this, W)) {
1470
+ await Promise.all(s(this, Ae).map((t) => t())), (e = s(this, re)) == null || e.unmount(!1), s(this, Me).stopAll(), b(this, W, !1);
1471
+ for (const t of s(this, _e))
1211
1472
  t();
1212
1473
  }
1213
1474
  }
@@ -1216,26 +1477,26 @@ class Kt {
1216
1477
  * it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
1217
1478
  */
1218
1479
  beforeMount(e) {
1219
- a(this, Re).push(e);
1480
+ s(this, qe).push(e);
1220
1481
  }
1221
1482
  /**
1222
1483
  * Registers a `callback` to run after the app is mounted.
1223
1484
  */
1224
1485
  onMount(e) {
1225
- a(this, xe).push(e);
1486
+ s(this, Fe).push(e);
1226
1487
  }
1227
1488
  /**
1228
1489
  * Registers a `callback` to run after `Dolla.unmount` is called, before the app is unmounted. If `callback` returns a Promise,
1229
1490
  * it will be awaited before unmounting finishes. Use this to perform cleanup.
1230
1491
  */
1231
1492
  beforeUnmount(e) {
1232
- a(this, Me).push(e);
1493
+ s(this, Ae).push(e);
1233
1494
  }
1234
1495
  /**
1235
1496
  * Registers a `callback` to run after the app is unmounted.
1236
1497
  */
1237
1498
  onUnmount(e) {
1238
- a(this, Ne).push(e);
1499
+ s(this, _e).push(e);
1239
1500
  }
1240
1501
  /**
1241
1502
  * Update log type toggles. Values that are not passed will remain unchanged.
@@ -1243,26 +1504,28 @@ class Kt {
1243
1504
  setLoggles(e) {
1244
1505
  for (const t in e) {
1245
1506
  const r = e[t];
1246
- r && (a(this, R)[t] = r);
1507
+ r && (s(this, O)[t] = r);
1247
1508
  }
1248
1509
  }
1249
1510
  setLogFilter(e) {
1250
- m(this, G, rt(e));
1511
+ b(this, z, wt(e));
1251
1512
  }
1252
1513
  createLogger(e, t) {
1253
- const r = Ge(e), s = (t == null ? void 0 : t.console) ?? St(), i = this;
1514
+ const r = (t == null ? void 0 : t.console) ?? Ut(), n = this;
1254
1515
  return {
1516
+ setName(a) {
1517
+ return e = a, this;
1518
+ },
1255
1519
  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;
1520
+ var a;
1521
+ if (s(n, O).info === !1 || V(s(n, O).info) && s(n, O).info !== n.getEnv() || !s(a = n, z).call(a, e))
1522
+ return Ce;
1260
1523
  {
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`,
1524
+ let o = `%c${e}`;
1525
+ return t != null && t.uid ? o += ` %c[uid: %c${t.uid}%c]` : o += "%c%c%c", r.info.bind(
1526
+ r,
1527
+ o,
1528
+ `color:${Ve(o)};font-weight:bold`,
1266
1529
  "color:#777",
1267
1530
  "color:#aaa",
1268
1531
  "color:#777"
@@ -1270,16 +1533,15 @@ class Kt {
1270
1533
  }
1271
1534
  },
1272
1535
  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;
1536
+ var a;
1537
+ if (s(n, O).log === !1 || V(s(n, O).log) && s(n, O).log !== n.getEnv() || !s(a = n, z).call(a, e))
1538
+ return Ce;
1277
1539
  {
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`,
1540
+ let o = `%c${e}`;
1541
+ return t != null && t.uid ? o += ` %c[uid: %c${t.uid}%c]` : o += "%c%c%c", r.log.bind(
1542
+ r,
1543
+ o,
1544
+ `color:${Ve(o)};font-weight:bold`,
1283
1545
  "color:#777",
1284
1546
  "color:#aaa",
1285
1547
  "color:#777"
@@ -1287,16 +1549,15 @@ class Kt {
1287
1549
  }
1288
1550
  },
1289
1551
  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;
1552
+ var a;
1553
+ if (s(n, O).warn === !1 || V(s(n, O).warn) && s(n, O).warn !== n.getEnv() || !s(a = n, z).call(a, e))
1554
+ return Ce;
1294
1555
  {
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`,
1556
+ let o = `%c${e}`;
1557
+ return t != null && t.uid ? o += ` %c[uid: %c${t.uid}%c]` : o += "%c%c%c", r.warn.bind(
1558
+ r,
1559
+ o,
1560
+ `color:${Ve(o)};font-weight:bold`,
1300
1561
  "color:#777",
1301
1562
  "color:#aaa",
1302
1563
  "color:#777"
@@ -1304,28 +1565,27 @@ class Kt {
1304
1565
  }
1305
1566
  },
1306
1567
  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;
1568
+ var a;
1569
+ if (s(n, O).error === !1 || V(s(n, O).error) && s(n, O).error !== n.getEnv() || !s(a = n, z).call(a, e))
1570
+ return Ce;
1311
1571
  {
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`,
1572
+ let o = `%c${e}`;
1573
+ return t != null && t.uid ? o += ` %c[uid: %c${t.uid}%c]` : o += "%c%c%c", r.error.bind(
1574
+ r,
1575
+ o,
1576
+ `color:${Ve(o)};font-weight:bold`,
1317
1577
  "color:#777",
1318
1578
  "color:#aaa",
1319
1579
  "color:#777"
1320
1580
  );
1321
1581
  }
1322
1582
  },
1323
- crash(o) {
1324
- throw i.isMounted && (i.unmount(), i.constructView(a(i, Se), {
1325
- error: o,
1326
- loggerName: r.get(),
1583
+ crash(a) {
1584
+ throw n.isMounted && (n.unmount(), n.constructView(s(n, Te), {
1585
+ error: a,
1586
+ loggerName: e,
1327
1587
  uid: t == null ? void 0 : t.uid
1328
- }).mount(a(i, I))), o;
1588
+ }).mount(s(n, B))), a;
1329
1589
  }
1330
1590
  };
1331
1591
  }
@@ -1333,34 +1593,41 @@ class Kt {
1333
1593
  *
1334
1594
  */
1335
1595
  constructView(e, t, r = []) {
1336
- return Rt({ root: this }, e, t, r);
1596
+ return new Ht(s(this, G), e, t, r);
1337
1597
  }
1338
1598
  /**
1339
1599
  *
1340
1600
  */
1341
1601
  constructMarkup(e) {
1342
- return xt(Mt({ root: this }, e));
1602
+ return Wt(Bt(s(this, G), e));
1343
1603
  }
1344
1604
  }
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);
1605
+ W = new WeakMap(), je = new WeakMap(), B = new WeakMap(), re = new WeakMap(), Te = new WeakMap(), Me = new WeakMap(), qe = new WeakMap(), Fe = new WeakMap(), Ae = new WeakMap(), _e = new WeakMap(), G = new WeakMap(), O = new WeakMap(), z = new WeakMap();
1606
+ const Et = new pr(), yr = Et.i18n.t.bind(Et.i18n);
1607
+ function br(i) {
1608
+ typeof window < "u" && (window.DOLLA_DEV_DEBUG = i);
1609
+ }
1610
+ function vr() {
1611
+ return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
1612
+ }
1347
1613
  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
1614
+ jt as cond,
1615
+ It as createMarkup,
1616
+ Ct as createRef,
1617
+ qt as createSettableState,
1618
+ kr as createSetter,
1619
+ oe as createState,
1620
+ Et as default,
1621
+ be as derive,
1622
+ vr as getDevDebug,
1623
+ mt as html,
1624
+ Vt as isRef,
1625
+ Sr as portal,
1626
+ Pr as repeat,
1627
+ br as setDevDebug,
1628
+ yr as t,
1629
+ Ft as toSettableState,
1630
+ At as toState,
1631
+ _t as valueOf
1365
1632
  };
1366
1633
  //# sourceMappingURL=index.js.map