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

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