@voltro/web 0.28.0 → 0.30.0

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.
@@ -1,6 +1,6 @@
1
1
  import { t as e } from "./globalContext-d4A-ugDg.js";
2
2
  import { c as t, n, t as r } from "./defaultFallbacks-Fik_Gcjh.js";
3
- import { f as i, i as a } from "./routerState-DDDBYFrI.js";
3
+ import { f as i, i as a } from "./routerState-DAT472IC.js";
4
4
  import { Component as o, useCallback as s, useContext as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
5
5
  import { jsx as p, jsxs as ee } from "react/jsx-runtime";
6
6
  //#region src/routeEventBus.ts
@@ -11,53 +11,53 @@ var m = {
11
11
  }, h = /* @__PURE__ */ new Set(), te = (e) => {
12
12
  m = e;
13
13
  for (let e of h) e();
14
- }, g = () => m, _ = (e) => (h.add(e), () => {
14
+ }, g = () => m, ne = (e) => (h.add(e), () => {
15
15
  h.delete(e);
16
- }), v = class extends Error {
16
+ }), _ = class extends Error {
17
17
  _voltroControl = "not-found";
18
18
  constructor(e) {
19
19
  super(e ? `Not found: ${e}` : "Not found"), this.name = "NotFoundError";
20
20
  }
21
- }, y = class extends Error {
21
+ }, v = class extends Error {
22
22
  _voltroControl = "redirect";
23
23
  location;
24
24
  status;
25
25
  constructor(e, t) {
26
26
  super(`Redirect: ${e}`), this.name = "RedirectError", this.location = e, this.status = t?.status ?? 303;
27
27
  }
28
- }, ne = (e) => {
29
- throw new v(e);
30
- }, b = (e, t) => {
31
- throw new y(e, t);
32
- }, re = (e) => e instanceof Error && e._voltroControl === "not-found", x = (e) => e instanceof Error && e._voltroControl === "redirect" && typeof e.location == "string", S = [
28
+ }, re = (e) => {
29
+ throw new _(e);
30
+ }, y = (e, t) => {
31
+ throw new v(e, t);
32
+ }, ie = (e) => e instanceof Error && e._voltroControl === "not-found", b = (e) => e instanceof Error && e._voltroControl === "redirect" && typeof e.location == "string", x = [
33
33
  "static",
34
34
  "spa",
35
35
  "ssr",
36
36
  "isr"
37
- ], ie = 0, C = 1, w = 2, T = 3, E = (e) => e.startsWith("[[...") && e.endsWith("]]") ? {
37
+ ], ae = 0, S = 1, C = 2, w = 3, T = (e) => e.startsWith("[[...") && e.endsWith("]]") ? {
38
38
  source: "(.*)",
39
39
  paramName: e.slice(5, -2),
40
- weight: w
40
+ weight: C
41
41
  } : e.startsWith("[...") && e.endsWith("]") ? {
42
42
  source: "(.+)",
43
43
  paramName: e.slice(4, -1),
44
- weight: T
44
+ weight: w
45
45
  } : e.startsWith("[") && e.endsWith("]") ? {
46
46
  source: "([^/]+)",
47
47
  paramName: e.slice(1, -1),
48
- weight: C
48
+ weight: S
49
49
  } : {
50
50
  source: e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
51
51
  paramName: null,
52
- weight: ie
53
- }, D = (e) => {
54
- let t = e.pattern.split("/").map(E);
52
+ weight: ae
53
+ }, E = (e) => {
54
+ let t = e.pattern.split("/").map(T);
55
55
  for (let n = 0; n < t.length - 1; n++) {
56
56
  let r = t[n];
57
- if (r.weight === T || r.weight === w) throw Error(`Route ${JSON.stringify(e.pattern)}: catch-all segment must be last. Anything after a catch-all is unreachable.`);
57
+ if (r.weight === w || r.weight === C) throw Error(`Route ${JSON.stringify(e.pattern)}: catch-all segment must be last. Anything after a catch-all is unreachable.`);
58
58
  }
59
59
  let n, r = t[t.length - 1];
60
- n = r && r.weight === w ? `${t.slice(0, -1).map((e) => e.source).join("/")}(?:/(.*))?` : t.map((e) => e.source).join("/");
60
+ n = r && r.weight === C ? `${t.slice(0, -1).map((e) => e.source).join("/")}(?:/(.*))?` : t.map((e) => e.source).join("/");
61
61
  let i = t.map((e) => e.paramName).filter((e) => e !== null), a = t.reduce((e, t) => e + t.weight, 0);
62
62
  return {
63
63
  ...e,
@@ -65,11 +65,11 @@ var m = {
65
65
  paramNames: i,
66
66
  priority: a
67
67
  };
68
- }, O = (e) => [...e].map((e, t) => ({
68
+ }, oe = (e) => [...e].map((e, t) => ({
69
69
  route: e,
70
70
  index: t
71
- })).sort((e, t) => e.route.priority === t.route.priority ? e.index - t.index : e.route.priority - t.route.priority).map(({ route: e }) => e), k = (e, t) => {
72
- let n = O(e);
71
+ })).sort((e, t) => e.route.priority === t.route.priority ? e.index - t.index : e.route.priority - t.route.priority).map(({ route: e }) => e), D = (e, t) => {
72
+ let n = oe(e);
73
73
  for (let e of n) {
74
74
  let n = e.regex.exec(t);
75
75
  if (n) {
@@ -85,7 +85,7 @@ var m = {
85
85
  }
86
86
  }
87
87
  return null;
88
- }, ae = (e, t, n) => A(`${e}__seg${t}`, n), A = (e, t) => `${e}\u0000${Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1).map(([e, t]) => `${e}=${t}`).join("")}`, oe = (e, t) => {
88
+ }, O = (e, t, n) => k(`${e}__seg${t}`, n), k = (e, t) => `${e}\u0000${Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1).map(([e, t]) => `${e}=${t}`).join("")}`, A = (e, t) => {
89
89
  let n = e(t);
90
90
  return n instanceof Promise ? n.then(i) : i(n);
91
91
  }, se = (e, t, n, r) => e === void 0 ? null : typeof e == "function" ? e({
@@ -96,12 +96,12 @@ var m = {
96
96
  let n = null, r = -1;
97
97
  for (let i of e) (i.prefix === "" || t === i.prefix || t.startsWith(`${i.prefix}/`)) && i.prefix.length > r && (n = i, r = i.prefix.length);
98
98
  return n;
99
- }, j = (e, t, n) => {
99
+ }, le = (e, t, n) => {
100
100
  if (e) for (let r = n; r >= 0; r--) {
101
101
  let n = e[r]?.[t];
102
102
  if (n !== void 0) return n;
103
103
  }
104
- }, le = class {
104
+ }, ue = class {
105
105
  entries = /* @__PURE__ */ new Map();
106
106
  get(e) {
107
107
  return this.entries.get(e);
@@ -149,63 +149,63 @@ var m = {
149
149
  clear() {
150
150
  this.entries.clear();
151
151
  }
152
- }, M = { kind: "native" }, ue = (e, t) => {
153
- if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return M;
152
+ }, j = { kind: "native" }, de = (e, t) => {
153
+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return j;
154
154
  let n = e.target, r = n instanceof Element ? n.closest("a") : null;
155
- if (!r) return M;
155
+ if (!r) return j;
156
156
  let i = r.getAttribute("href");
157
- if (i === null) return M;
157
+ if (i === null) return j;
158
158
  let a = r.getAttribute("target");
159
- if (a && a !== "_self" || r.hasAttribute("download") || r.hasAttribute("data-no-spa")) return M;
159
+ if (a && a !== "_self" || r.hasAttribute("download") || r.hasAttribute("data-no-spa")) return j;
160
160
  let o = r.getAttribute("rel");
161
- if (o && /(^|\s)external(\s|$)/i.test(o)) return M;
161
+ if (o && /(^|\s)external(\s|$)/i.test(o)) return j;
162
162
  let s, c;
163
163
  try {
164
164
  c = new URL(t), s = new URL(i, c);
165
165
  } catch {
166
- return M;
166
+ return j;
167
167
  }
168
- return s.origin !== c.origin || s.pathname === c.pathname && s.search === c.search && s.hash !== "" ? M : {
168
+ return s.origin !== c.origin || s.pathname === c.pathname && s.search === c.search && s.hash !== "" ? j : {
169
169
  kind: "spa",
170
170
  to: s.pathname + s.search + s.hash
171
171
  };
172
- }, N = (e) => {
172
+ }, fe = (e) => {
173
173
  let t = e.replace(/^#/, "");
174
174
  try {
175
175
  return decodeURIComponent(t);
176
176
  } catch {
177
177
  return t;
178
178
  }
179
- }, P = (e) => {
180
- let t = N(e);
179
+ }, M = (e) => {
180
+ let t = fe(e);
181
181
  return t ? document.getElementById(t) ?? document.getElementsByName(t)[0] ?? null : null;
182
- }, de = (e) => {
182
+ }, pe = (e) => {
183
183
  if (typeof window.requestAnimationFrame == "function") {
184
184
  window.requestAnimationFrame(e);
185
185
  return;
186
186
  }
187
187
  window.setTimeout(e, 0);
188
- }, fe = (e) => {
188
+ }, me = (e) => {
189
189
  if (!e.hash) {
190
190
  window.scrollTo(0, 0);
191
191
  return;
192
192
  }
193
- de(() => {
194
- let t = P(e.hash);
193
+ pe(() => {
194
+ let t = M(e.hash);
195
195
  if (t) {
196
196
  t.scrollIntoView();
197
197
  return;
198
198
  }
199
199
  window.scrollTo(0, 0);
200
200
  });
201
- }, F = 0, pe = () => {
201
+ }, N = 0, he = () => {
202
202
  let e = typeof crypto < "u" ? crypto : void 0;
203
- return e && typeof e.randomUUID == "function" ? e.randomUUID() : (F += 1, `k${Date.now().toString(36)}-${F}`);
204
- }, I = e("router", null), L = () => {
205
- let e = c(I);
203
+ return e && typeof e.randomUUID == "function" ? e.randomUUID() : (N += 1, `k${Date.now().toString(36)}-${N}`);
204
+ }, P = e("router", null), F = () => {
205
+ let e = c(P);
206
206
  if (!e) throw Error("Router hooks must be used inside <Router>.");
207
207
  return e;
208
- }, R = e("loaderData", void 0), me = (e, t) => {
208
+ }, I = Symbol.for("@voltro/web/loaderData:absent"), L = e("loaderData", I), ge = (e, t) => {
209
209
  if (!e || e.pathname !== t) return;
210
210
  let n = {};
211
211
  for (let [t, r] of e.segments) n[t] = r;
@@ -213,16 +213,16 @@ var m = {
213
213
  page: e.page,
214
214
  segments: n
215
215
  };
216
- }, he = (e, t) => {
216
+ }, _e = (e, t) => {
217
217
  if (e === t) return !0;
218
218
  if (!e || !t || !Object.is(e.page, t.page)) return !1;
219
219
  let n = Object.keys(e.segments), r = Object.keys(t.segments);
220
220
  return n.length === r.length && n.every((n) => Object.is(e.segments[Number(n)], t.segments[Number(n)]));
221
- }, ge = () => {
221
+ }, ve = () => {
222
222
  if (typeof document > "u") return;
223
- let e = document.cookie.match(/(?:^|;\s*)voltro:lang=([^;]*)/);
223
+ let e = document.cookie.match(/(?:^|;\s*)voltro:locale=([^;]*)/);
224
224
  return e ? decodeURIComponent(e[1]) : void 0;
225
- }, _e = (e) => {
225
+ }, ye = (e) => {
226
226
  if (e === null || typeof document > "u") return () => {};
227
227
  let t = document.title, n = [], r = [], i = [], a = [], o = [];
228
228
  typeof e.title == "string" && (document.title = e.title);
@@ -239,7 +239,7 @@ var m = {
239
239
  e.name && r.setAttribute("name", e.name), e.property && r.setAttribute("property", e.property), r.setAttribute("content", t), document.head.appendChild(r), n.push(r);
240
240
  }
241
241
  };
242
- if (typeof e.description == "string" && s({ name: "description" }, e.description), e.tags) for (let t of e.tags) s(t, t.content);
242
+ if (typeof e.description == "string" && s({ name: "description" }, e.description), e.noIndex && s({ name: "robots" }, "noindex, nofollow"), e.tags) for (let t of e.tags) s(t, t.content);
243
243
  if (e.canonical) {
244
244
  let t = document.head.querySelector("link[rel=\"canonical\"]");
245
245
  if (t) a.push({
@@ -257,7 +257,7 @@ var m = {
257
257
  }
258
258
  if (e.jsonLd) for (let t of e.jsonLd) {
259
259
  let e = document.createElement("script");
260
- e.type = "application/ld+json", e.setAttribute("data-voltro-page-jsonld", ""), e.textContent = z(t), document.head.appendChild(e), o.push(e);
260
+ e.type = "application/ld+json", e.setAttribute("data-voltro-page-jsonld", ""), e.textContent = R(t), document.head.appendChild(e), o.push(e);
261
261
  }
262
262
  return () => {
263
263
  document.title = t;
@@ -267,7 +267,7 @@ var m = {
267
267
  for (let { el: e, previous: t } of r) e.content = t;
268
268
  for (let { el: e, previous: t } of a) e.href = t;
269
269
  };
270
- }, z = (e) => JSON.stringify(e).replace(/<\/(script)/gi, "<\\/$1").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), B = class extends o {
270
+ }, R = (e) => JSON.stringify(e).replace(/<\/(script)/gi, "<\\/$1").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), be = class extends o {
271
271
  state = { error: null };
272
272
  static getDerivedStateFromError(e) {
273
273
  return { error: e };
@@ -291,10 +291,10 @@ var m = {
291
291
  }
292
292
  return this.props.children;
293
293
  }
294
- }, V = "data-voltro-page-slot", ve = () => /* @__PURE__ */ p("div", { [V]: "" }), ye = ({ routes: e, notFounds: i = [], notFound: o = n, errorFallback: c = r }) => {
295
- let [m, h] = f(() => window.location.pathname), [g, _] = f(() => window.location.pathname), [v, y] = f(() => window.location.search + window.location.hash), ne = v.split("#")[0] ?? "", b = d(new le()), S = d(/* @__PURE__ */ new Map()), [ie, C] = f(null), w = s((e, t) => (S.current.set(e, t), () => {
296
- S.current.delete(e);
297
- }), []), T = d(/* @__PURE__ */ new Map()), E = d(null), M = u(() => O(e.map(D)), [e]);
294
+ }, z = "data-voltro-page-slot", xe = () => /* @__PURE__ */ p("div", { [z]: "" }), Se = ({ routes: e, notFounds: i = [], notFound: o = n, errorFallback: c = r }) => {
295
+ let [m, h] = f(() => window.location.pathname), [g, ne] = f(() => window.location.pathname), [_, v] = f(() => window.location.search + window.location.hash), re = _.split("#")[0] ?? "", y = d(new ue()), x = d(/* @__PURE__ */ new Map()), [ae, S] = f(null), C = s((e, t) => (x.current.set(e, t), () => {
296
+ x.current.delete(e);
297
+ }), []), w = d(/* @__PURE__ */ new Map()), T = d(null), j = u(() => oe(e.map(E)), [e]);
298
298
  l(() => {
299
299
  if (typeof window > "u") return;
300
300
  let e = window.history.scrollRestoration;
@@ -303,144 +303,144 @@ var m = {
303
303
  } catch {}
304
304
  return window.history.state?.__vwebKey || window.history.replaceState({
305
305
  ...window.history.state,
306
- __vwebKey: pe()
306
+ __vwebKey: he()
307
307
  }, ""), () => {
308
308
  try {
309
309
  window.history.scrollRestoration = e;
310
310
  } catch {}
311
311
  };
312
312
  }, []);
313
- let N = () => window.history.state?.__vwebKey ?? "initial";
313
+ let fe = () => window.history.state?.__vwebKey ?? "initial";
314
314
  l(() => {
315
315
  let e = () => {
316
- let e = T.current.get(N());
317
- E.current = e ?? {
316
+ let e = w.current.get(fe());
317
+ T.current = e ?? {
318
318
  x: 0,
319
319
  y: 0
320
- }, h(window.location.pathname), y(window.location.search + window.location.hash);
320
+ }, h(window.location.pathname), v(window.location.search + window.location.hash);
321
321
  };
322
322
  return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
323
323
  }, []);
324
- let P = s((e, t, n) => {
325
- T.current.set(N(), {
324
+ let M = s((e, t, n) => {
325
+ w.current.set(fe(), {
326
326
  x: window.scrollX,
327
327
  y: window.scrollY
328
328
  });
329
- let r = { __vwebKey: pe() };
330
- n?.replace ? window.history.replaceState(r, "", e) : window.history.pushState(r, "", e), h(t.pathname), y(t.search + t.hash), n?.scroll !== !1 && fe(t);
331
- }, []), F = s((e, t) => {
329
+ let r = { __vwebKey: he() };
330
+ n?.replace ? window.history.replaceState(r, "", e) : window.history.pushState(r, "", e), h(t.pathname), v(t.search + t.hash), n?.scroll !== !1 && me(t);
331
+ }, []), N = s((e, t) => {
332
332
  let n = new URL(window.location.href), r = new URL(e, n);
333
333
  if (!(r.pathname === n.pathname && r.search === n.search && r.hash === n.hash)) {
334
- for (let n of S.current.values()) if (n({
334
+ for (let n of x.current.values()) if (n({
335
335
  to: e,
336
336
  ...t ? { opts: t } : {}
337
337
  })) {
338
- C({
338
+ S({
339
339
  to: e,
340
340
  ...t ? { opts: t } : {},
341
341
  retry: () => {
342
- C(null), P(e, r, t);
342
+ S(null), M(e, r, t);
343
343
  },
344
- reset: () => C(null)
344
+ reset: () => S(null)
345
345
  });
346
346
  return;
347
347
  }
348
- P(e, r, t);
348
+ M(e, r, t);
349
349
  }
350
- }, [P]);
350
+ }, [M]);
351
351
  l(() => {
352
352
  if (typeof document > "u") return;
353
353
  let e = (e) => {
354
- let t = ue(e, window.location.href);
355
- t.kind === "spa" && (e.preventDefault(), F(t.to));
354
+ let t = de(e, window.location.href);
355
+ t.kind === "spa" && (e.preventDefault(), N(t.to));
356
356
  };
357
357
  return document.addEventListener("click", e), () => document.removeEventListener("click", e);
358
- }, [F]);
359
- let L = u(() => k(M, m), [M, m]), z = d(/* @__PURE__ */ new Map()), [V, ye] = f(0);
358
+ }, [N]);
359
+ let F = u(() => D(j, m), [j, m]), R = d(/* @__PURE__ */ new Map()), [z, Se] = f(0);
360
360
  l(() => {
361
- let e = L?.route;
362
- if (!e?.load || z.current.has(e.pattern)) return;
361
+ let e = F?.route;
362
+ if (!e?.load || R.current.has(e.pattern)) return;
363
363
  let t = !1;
364
364
  return e.load().then((n) => {
365
- t || (z.current.set(e.pattern, n), ye((e) => e + 1));
365
+ t || (R.current.set(e.pattern, n), Se((e) => e + 1));
366
366
  }).catch(() => {}), () => {
367
367
  t = !0;
368
368
  };
369
- }, [L?.route.load ? L.route.pattern : null]);
370
- let H = u(() => {
371
- if (!L) return null;
372
- let e = L.route;
369
+ }, [F?.route.load ? F.route.pattern : null]);
370
+ let B = u(() => {
371
+ if (!F) return null;
372
+ let e = F.route;
373
373
  if (!e.load) return e;
374
- let t = z.current.get(e.pattern);
374
+ let t = R.current.get(e.pattern);
375
375
  return t ? {
376
376
  ...e,
377
- ...Oe(t),
377
+ ...je(t),
378
378
  load: void 0
379
379
  } : null;
380
- }, [L, V]), U = u(() => k(M, g), [M, g]), W = u(() => {
381
- if (!U) return null;
382
- let e = U.route;
380
+ }, [F, z]), V = u(() => D(j, g), [j, g]), H = u(() => {
381
+ if (!V) return null;
382
+ let e = V.route;
383
383
  if (!e.load) return e;
384
- let t = z.current.get(e.pattern);
384
+ let t = R.current.get(e.pattern);
385
385
  return t ? {
386
386
  ...e,
387
- ...Oe(t),
387
+ ...je(t),
388
388
  load: void 0
389
389
  } : null;
390
- }, [U, V]), Se = s((e) => {
391
- let t = new URL(e, window.location.origin), n = k(M, t.pathname);
390
+ }, [V, z]), Te = s((e) => {
391
+ let t = new URL(e, window.location.origin), n = D(j, t.pathname);
392
392
  if (!n) return;
393
393
  let r = (e, r) => {
394
- b.current.start(e, (e) => oe(r, {
394
+ y.current.start(e, (e) => A(r, {
395
395
  params: n.params,
396
396
  pathname: t.pathname,
397
397
  search: t.search,
398
398
  signal: e
399
399
  }));
400
400
  };
401
- n.route.loader && r(A(n.route.pattern, n.params), n.route.loader), n.route.chain?.forEach((e, t) => {
402
- e.loader && r(ae(n.route.pattern, t, n.params), e.loader);
401
+ n.route.loader && r(k(n.route.pattern, n.params), n.route.loader), n.route.chain?.forEach((e, t) => {
402
+ e.loader && r(O(n.route.pattern, t, n.params), e.loader);
403
403
  });
404
- }, [M]), [G, K] = f({ status: "idle" }), q = d(void 0);
405
- q.current === void 0 && (q.current = a());
406
- let Ce = d(!1), [we, Te] = f(() => q.current?.pageClientOnly === !0 && q.current.pathname === m);
404
+ }, [j]), [U, W] = f({ status: "idle" }), G = d(void 0);
405
+ G.current === void 0 && (G.current = a());
406
+ let Ee = d(!1), [De, Oe] = f(() => G.current?.pageClientOnly === !0 && G.current.pathname === m);
407
407
  l(() => {
408
- Te(!1);
408
+ Oe(!1);
409
409
  }, []);
410
- let [J, Ee] = f(() => ({
410
+ let [K, ke] = f(() => ({
411
411
  pathname: m,
412
- data: me(q.current ?? null, m),
413
- chain: L?.route.chain
412
+ data: ge(G.current ?? null, m),
413
+ chain: F?.route.chain
414
414
  }));
415
415
  l(() => {
416
416
  let e = (e) => {
417
- _(m), Ee((t) => t.pathname === m && he(t.data, e) ? t : {
417
+ ne(m), ke((t) => t.pathname === m && _e(t.data, e) ? t : {
418
418
  pathname: m,
419
419
  data: e,
420
- chain: L?.route.chain
420
+ chain: F?.route.chain
421
421
  });
422
422
  };
423
- if (!L) {
424
- K({ status: "idle" }), e(void 0);
423
+ if (!F) {
424
+ W({ status: "idle" }), e(void 0);
425
425
  return;
426
426
  }
427
- if (!H) {
428
- K({
427
+ if (!B) {
428
+ W({
429
429
  status: "pending",
430
- key: A(L.route.pattern, L.params)
430
+ key: k(F.route.pattern, F.params)
431
431
  });
432
432
  return;
433
433
  }
434
- let t = H, { params: n } = L, r = t.chain, i = (t.Pending ?? j(r, "Pending", r ? r.length - 1 : -1)) !== void 0, a = [];
434
+ let t = B, { params: n } = F, r = t.chain, i = (t.Pending ?? le(r, "Pending", r ? r.length - 1 : -1)) !== void 0, a = [];
435
435
  if (t.loader) {
436
436
  let e = t.loader;
437
437
  a.push({
438
- cacheKey: A(t.pattern, n),
438
+ cacheKey: k(t.pattern, n),
439
439
  target: "page",
440
- run: (t) => oe(e, {
440
+ run: (t) => A(e, {
441
441
  params: n,
442
442
  pathname: m,
443
- search: ne,
443
+ search: re,
444
444
  signal: t
445
445
  })
446
446
  });
@@ -449,32 +449,32 @@ var m = {
449
449
  if (e.loader) {
450
450
  let i = e.loader;
451
451
  a.push({
452
- cacheKey: ae(t.pattern, r, n),
452
+ cacheKey: O(t.pattern, r, n),
453
453
  target: r,
454
- run: (e) => oe(i, {
454
+ run: (e) => A(i, {
455
455
  params: n,
456
456
  pathname: m,
457
- search: ne,
457
+ search: re,
458
458
  signal: e
459
459
  })
460
460
  });
461
461
  }
462
462
  }), a.length === 0) {
463
- K({ status: "idle" }), e(void 0);
463
+ W({ status: "idle" }), e(void 0);
464
464
  return;
465
465
  }
466
- let o = A(t.pattern, n), s = q.current;
467
- if (s && !Ce.current && m === s.pathname) {
468
- Ce.current = !0;
469
- for (let e of a) e.target === "page" ? s.pageRan && b.current.seed(e.cacheKey, s.page) : s.segments.has(e.target) && b.current.seed(e.cacheKey, s.segments.get(e.target));
466
+ let o = k(t.pattern, n), s = G.current;
467
+ if (s && !Ee.current && m === s.pathname) {
468
+ Ee.current = !0;
469
+ for (let e of a) e.target === "page" ? s.pageRan && y.current.seed(e.cacheKey, s.page) : s.segments.has(e.target) && y.current.seed(e.cacheKey, s.segments.get(e.target));
470
470
  }
471
471
  let c = a.map((e) => ({
472
472
  spec: e,
473
- entry: b.current.start(e.cacheKey, e.run)
473
+ entry: y.current.start(e.cacheKey, e.run)
474
474
  })), l = () => {
475
475
  let e = {}, t;
476
476
  for (let { spec: n } of c) {
477
- let r = b.current.get(n.cacheKey);
477
+ let r = y.current.get(n.cacheKey);
478
478
  if (!r || r.status === "pending") return null;
479
479
  if (r.status === "error") return {
480
480
  ok: !1,
@@ -491,89 +491,89 @@ var m = {
491
491
  };
492
492
  }, u = l();
493
493
  if (u) {
494
- u.ok ? (K({
494
+ u.ok ? (W({
495
495
  status: "success",
496
496
  key: o,
497
497
  data: u.data
498
- }), e(u.data)) : (K({
498
+ }), e(u.data)) : (W({
499
499
  status: "error",
500
500
  key: o,
501
501
  error: u.error
502
- }), x(u.error) || e(void 0));
502
+ }), b(u.error) || e(void 0));
503
503
  return;
504
504
  }
505
- K({
505
+ W({
506
506
  status: "pending",
507
507
  key: o
508
- }), i && _(m);
508
+ }), i && ne(m);
509
509
  let d = !1, f = c.map(({ entry: e }) => e.status === "pending" ? e.promise : Promise.resolve());
510
510
  return Promise.all(f).then(() => {
511
511
  if (d) return;
512
512
  let t = l();
513
- t && (t.ok ? (K({
513
+ t && (t.ok ? (W({
514
514
  status: "success",
515
515
  key: o,
516
516
  data: t.data
517
- }), e(t.data)) : (K({
517
+ }), e(t.data)) : (W({
518
518
  status: "error",
519
519
  key: o,
520
520
  error: t.error
521
- }), x(t.error) || e(void 0)));
521
+ }), b(t.error) || e(void 0)));
522
522
  }), () => {
523
523
  d = !0;
524
524
  };
525
525
  }, [
526
- L,
527
- H,
526
+ F,
527
+ B,
528
528
  m
529
529
  ]);
530
- let Y = J.data?.page, X = g === m, De = J.pathname === g, ke = De ? J.data?.page : void 0, Ae = ge(), Z = u(() => {
531
- if (!U) return null;
532
- let e = U.params.locale ?? Ae;
533
- return se(W?.meta, U.params, Y, e);
530
+ let q = K.data?.page, J = g === m, Y = K.pathname === g, Ae = Y ? K.data?.page : void 0, Me = H?.loader === void 0 ? I : Ae, Ne = ve(), X = u(() => {
531
+ if (!V) return null;
532
+ let e = V.params.locale ?? Ne;
533
+ return se(H?.meta, V.params, q, e);
534
534
  }, [
535
- U,
536
- W,
537
- Y,
538
- Ae
535
+ V,
536
+ H,
537
+ q,
538
+ Ne
539
539
  ]);
540
- l(() => _e(Z), [Z]);
541
- let [Q, je] = f(""), Me = d(!1), [Ne, Pe] = f(!1);
540
+ l(() => ye(X), [X]);
541
+ let [Z, Q] = f(""), Pe = d(!1), [Fe, Ie] = f(!1);
542
542
  l(() => {
543
- if (!Me.current) {
544
- Me.current = !0, Pe(!0);
543
+ if (!Pe.current) {
544
+ Pe.current = !0, Ie(!0);
545
545
  return;
546
546
  }
547
- let e = Z?.title ?? (typeof document < "u" ? document.title : "");
548
- je(e && e.length > 0 ? e : g);
549
- }, [g, Z]), l(() => {
550
- let e = E.current;
551
- e && (E.current = null, de(() => window.scrollTo(e.x, e.y)));
547
+ let e = X?.title ?? (typeof document < "u" ? document.title : "");
548
+ Q(e && e.length > 0 ? e : g);
549
+ }, [g, X]), l(() => {
550
+ let e = T.current;
551
+ e && (T.current = null, pe(() => window.scrollTo(e.x, e.y)));
552
552
  }, [g]);
553
- let Fe = u(() => ({
553
+ let Le = u(() => ({
554
554
  pathname: g,
555
- search: v,
556
- navigate: F,
557
- params: U?.params ?? {},
558
- prefetch: Se,
559
- loaderData: Y,
560
- registerBlocker: w,
561
- blocked: ie
555
+ search: _,
556
+ navigate: N,
557
+ params: V?.params ?? {},
558
+ prefetch: Te,
559
+ loaderData: q,
560
+ registerBlocker: C,
561
+ blocked: ae
562
562
  }), [
563
563
  g,
564
- v,
565
- F,
566
- U,
567
- Se,
568
- Y,
569
- w,
570
- ie
564
+ _,
565
+ N,
566
+ V,
567
+ Te,
568
+ q,
569
+ C,
570
+ ae
571
571
  ]);
572
572
  l(() => {
573
573
  if (typeof window > "u") return;
574
574
  let e = (e) => {
575
575
  let t = !1;
576
- for (let e of S.current.values()) if (e({ to: window.location.pathname })) {
576
+ for (let e of x.current.values()) if (e({ to: window.location.pathname })) {
577
577
  t = !0;
578
578
  break;
579
579
  }
@@ -583,83 +583,83 @@ var m = {
583
583
  }, []), l(() => {
584
584
  te({
585
585
  pathname: g,
586
- params: U?.params ?? {},
587
- loaderData: Y
586
+ params: V?.params ?? {},
587
+ loaderData: q
588
588
  });
589
589
  }, [
590
590
  g,
591
- U,
592
- Y
591
+ V,
592
+ q
593
593
  ]), l(() => {
594
- if (G.status === "pending") return t({
594
+ if (U.status === "pending") return t({
595
595
  id: "voltro:router:loader",
596
596
  kind: "loading",
597
597
  label: "Loading…"
598
598
  });
599
- }, [G.status]), l(() => {
600
- if (G.status === "error") return t({
599
+ }, [U.status]), l(() => {
600
+ if (U.status === "error") return t({
601
601
  id: "voltro:router:loader-error",
602
602
  kind: "error",
603
603
  label: "Loader failed"
604
604
  });
605
- }, [G.status]), l(() => {
606
- G.status === "error" && x(G.error) && F(G.error.location, { replace: !0 });
607
- }, [G, F]);
608
- let Ie = () => {
605
+ }, [U.status]), l(() => {
606
+ U.status === "error" && b(U.error) && N(U.error.location, { replace: !0 });
607
+ }, [U, N]);
608
+ let Re = () => {
609
609
  let e = ce(i, g);
610
610
  if (e) {
611
611
  let { Component: t, chain: n } = e;
612
- return xe(n, /* @__PURE__ */ p(t, {}), g, c);
612
+ return we(n, /* @__PURE__ */ p(t, {}), g, c);
613
613
  }
614
614
  return /* @__PURE__ */ p(o, {});
615
- }, Le = X && U && G.status === "error" ? G.error : void 0, $;
616
- if (!U) $ = Ie();
617
- else if (re(Le)) $ = Ie();
615
+ }, ze = J && V && U.status === "error" ? U.error : void 0, $;
616
+ if (!V) $ = Re();
617
+ else if (ie(ze)) $ = Re();
618
618
  else {
619
- let e = U.route.chain, t = e ? e.length - 1 : -1, n = W?.ErrorBoundary ?? j(e, "Error", t) ?? c, r;
620
- if (we) r = /* @__PURE__ */ p(ve, {});
621
- else if (X && G.status === "error" && !x(G.error)) r = /* @__PURE__ */ p(n, {
622
- error: G.error,
619
+ let e = V.route.chain, t = e ? e.length - 1 : -1, n = H?.ErrorBoundary ?? le(e, "Error", t) ?? c, r;
620
+ if (De) r = /* @__PURE__ */ p(xe, {});
621
+ else if (J && U.status === "error" && !b(U.error)) r = /* @__PURE__ */ p(n, {
622
+ error: U.error,
623
623
  reset: () => {
624
- b.current.invalidate(U.route.pattern), h((e) => e), K({ status: "idle" });
624
+ y.current.invalidate(V.route.pattern), h((e) => e), W({ status: "idle" });
625
625
  }
626
626
  });
627
- else if (X && G.status === "pending") {
628
- let i = W?.Pending ?? j(e, "Pending", t);
627
+ else if (J && U.status === "pending") {
628
+ let i = H?.Pending ?? le(e, "Pending", t);
629
629
  if (i) r = /* @__PURE__ */ p(i, {});
630
- else if (W?.Component) {
631
- let e = W.Component;
632
- r = /* @__PURE__ */ p(B, {
630
+ else if (H?.Component) {
631
+ let e = H.Component;
632
+ r = /* @__PURE__ */ p(be, {
633
633
  resetKey: g,
634
634
  Fallback: n,
635
- children: /* @__PURE__ */ p(R.Provider, {
636
- value: ke,
635
+ children: /* @__PURE__ */ p(L.Provider, {
636
+ value: Me,
637
637
  children: /* @__PURE__ */ p(e, {})
638
638
  })
639
639
  });
640
640
  } else r = null;
641
641
  } else {
642
- let e = W?.Component;
643
- r = e ? /* @__PURE__ */ p(B, {
642
+ let e = H?.Component;
643
+ r = e ? /* @__PURE__ */ p(be, {
644
644
  resetKey: g,
645
645
  Fallback: n,
646
- children: /* @__PURE__ */ p(R.Provider, {
647
- value: ke,
646
+ children: /* @__PURE__ */ p(L.Provider, {
647
+ value: Me,
648
648
  children: /* @__PURE__ */ p(e, {})
649
649
  })
650
650
  }) : null;
651
651
  }
652
- $ = xe(e, r, g, c, (t) => {
653
- if (De) return J.data?.segments[t];
652
+ $ = we(e, r, g, c, (t) => {
653
+ if (Y) return K.data?.segments[t];
654
654
  let n = e?.[t]?.Layout;
655
- return n !== void 0 && n === J.chain?.[t]?.Layout ? J.data?.segments[t] : void 0;
655
+ return n !== void 0 && n === K.chain?.[t]?.Layout ? K.data?.segments[t] : void 0;
656
656
  });
657
657
  }
658
- return /* @__PURE__ */ ee(I.Provider, {
659
- value: Fe,
660
- children: [$, Ne ? /* @__PURE__ */ p(be, { message: Q }) : null]
658
+ return /* @__PURE__ */ ee(P.Provider, {
659
+ value: Le,
660
+ children: [$, Fe ? /* @__PURE__ */ p(Ce, { message: Z }) : null]
661
661
  });
662
- }, H = {
662
+ }, B = {
663
663
  position: "absolute",
664
664
  width: 1,
665
665
  height: 1,
@@ -669,28 +669,28 @@ var m = {
669
669
  clip: "rect(0, 0, 0, 0)",
670
670
  whiteSpace: "nowrap",
671
671
  border: 0
672
- }, be = ({ message: e }) => /* @__PURE__ */ p("div", {
672
+ }, Ce = ({ message: e }) => /* @__PURE__ */ p("div", {
673
673
  "data-vweb-route-announcer": "",
674
674
  role: "status",
675
675
  "aria-live": "assertive",
676
676
  "aria-atomic": "true",
677
- style: H,
677
+ style: B,
678
678
  children: e
679
- }), xe = (e, t, n, r, i) => {
679
+ }), we = (e, t, n, r, i) => {
680
680
  if (!e || e.length === 0) return t;
681
681
  let a = t;
682
682
  for (let t = e.length - 1; t >= 0; t--) {
683
683
  let r = e[t];
684
684
  if (r.Layout) {
685
685
  let e = r.Layout;
686
- a = /* @__PURE__ */ p(R.Provider, {
687
- value: i?.(t),
686
+ a = /* @__PURE__ */ p(L.Provider, {
687
+ value: r.loader === void 0 ? I : i?.(t),
688
688
  children: /* @__PURE__ */ p(e, { children: a })
689
689
  });
690
690
  }
691
691
  if (r.Error) {
692
692
  let e = r.Error;
693
- a = /* @__PURE__ */ p(B, {
693
+ a = /* @__PURE__ */ p(be, {
694
694
  resetKey: n,
695
695
  Fallback: e,
696
696
  children: a
@@ -698,8 +698,15 @@ var m = {
698
698
  }
699
699
  }
700
700
  return a;
701
- }, U = () => L().pathname, W = () => L().navigate, Se = () => L().params, G = () => c(R), K = () => L().prefetch, q = (e) => {
702
- let { registerBlocker: t, blocked: n } = L(), r = d(Symbol("voltro:blocker")), i = d(e);
701
+ }, V = () => F().pathname, H = () => F().navigate, Te = () => F().params, U = () => {
702
+ let e = c(L);
703
+ if (e === I) throw Error("useLoaderData() was called at a level that declares no `loader`. Export `loader` from this page/layout, or — if this component is shared between routes that have one and routes that do not — read it with `useOptionalLoaderData()`, which returns `undefined` here instead of throwing. The React component stack below names the component.");
704
+ return e;
705
+ }, W = () => {
706
+ let e = c(L);
707
+ return e === I ? void 0 : e;
708
+ }, G = () => F().prefetch, Ee = (e) => {
709
+ let { registerBlocker: t, blocked: n } = F(), r = d(Symbol("voltro:blocker")), i = d(e);
703
710
  return i.current = e, l(() => {
704
711
  let e = r.current;
705
712
  return t(e, (e) => {
@@ -712,22 +719,22 @@ var m = {
712
719
  retry: n.retry,
713
720
  reset: n.reset
714
721
  } : { blocked: !1 };
715
- }, Ce = (e) => e instanceof URLSearchParams ? e : new URLSearchParams(e), we = () => {
716
- let { navigate: e } = L();
722
+ }, De = (e) => e instanceof URLSearchParams ? e : new URLSearchParams(e), Oe = () => {
723
+ let { navigate: e } = F();
717
724
  return s((t, n) => {
718
- let r = new URLSearchParams(typeof window < "u" ? window.location.search : ""), i = Ce(typeof t == "function" ? t(r) : t).toString(), a = typeof window < "u" ? window.location.pathname : "/", o = i ? `${a}?${i}` : a;
725
+ let r = new URLSearchParams(typeof window < "u" ? window.location.search : ""), i = De(typeof t == "function" ? t(r) : t).toString(), a = typeof window < "u" ? window.location.pathname : "/", o = i ? `${a}?${i}` : a;
719
726
  e(o, {
720
727
  replace: !n?.push,
721
728
  ...n?.scroll === void 0 ? {} : { scroll: n.scroll }
722
729
  });
723
730
  }, [e]);
724
- }, Te = (e) => e, J = (e, t) => {
731
+ }, K = (e) => e, ke = (e, t) => {
725
732
  let n = new URLSearchParams();
726
733
  for (let [e, r] of Object.entries(t)) r !== void 0 && n.append(e, String(r));
727
734
  let r = n.toString();
728
735
  return r ? `${e}?${r}` : e;
729
- }, Ee = (e, t) => `${e}#${t.replace(/^#/, "")}`, Y = (e) => /^([a-z][a-z0-9+.-]*:|\/\/|#)/i.test(e), X = ({ to: e, children: t, onClick: n, prefetch: r = !1, replace: i = !1, onMouseEnter: a, onFocus: o, ...s }) => {
730
- let c = W(), l = K(), u = Y(e), d = (t) => {
736
+ }, q = (e, t) => `${e}#${t.replace(/^#/, "")}`, J = (e) => /^([a-z][a-z0-9+.-]*:|\/\/|#)/i.test(e), Y = ({ to: e, children: t, onClick: n, prefetch: r = !1, replace: i = !1, onMouseEnter: a, onFocus: o, ...s }) => {
737
+ let c = H(), l = G(), u = J(e), d = (t) => {
731
738
  u || t.metaKey || t.ctrlKey || t.shiftKey || t.altKey || t.button !== 0 || (t.preventDefault(), n?.(t), c(e, i ? { replace: i } : void 0));
732
739
  }, f = (t) => {
733
740
  r && !u && l(e), a?.(t);
@@ -742,10 +749,10 @@ var m = {
742
749
  onFocus: ee,
743
750
  children: t
744
751
  });
745
- }, De = (e) => X({
752
+ }, Ae = (e) => Y({
746
753
  ...e,
747
754
  to: e.to
748
- }), Oe = (e) => ({
755
+ }), je = (e) => ({
749
756
  Component: e.default,
750
757
  meta: e.meta,
751
758
  loader: e.loader,
@@ -753,30 +760,30 @@ var m = {
753
760
  Pending: e.Pending,
754
761
  renderMode: e.renderMode,
755
762
  interactive: e.interactive
756
- }), ke = (e, t, n = {}) => ({
763
+ }), Me = (e, t, n = {}) => ({
757
764
  pattern: e,
758
- ...Oe(t),
765
+ ...je(t),
759
766
  chain: n.chain
760
- }), Ae = (e, t, n = {}) => ({
767
+ }), Ne = (e, t, n = {}) => ({
761
768
  pattern: e,
762
769
  load: t,
763
770
  chain: n.chain
764
- }), Z = async (e, t) => {
765
- let n = k(e.map(D), t)?.route.load;
771
+ }), X = async (e, t) => {
772
+ let n = D(e.map(E), t)?.route.load;
766
773
  if (n) try {
767
774
  await n();
768
775
  } catch {}
769
- }, Q = e("serverRequest", null), je = () => c(Q), Me = () => {
770
- let e = je();
776
+ }, Z = e("serverRequest", null), Q = () => c(Z), Pe = () => {
777
+ let e = Q();
771
778
  if (e !== null) {
772
779
  let t = e.url.indexOf("?");
773
780
  return new URLSearchParams(t >= 0 ? e.url.slice(t + 1) : "");
774
781
  }
775
782
  return typeof window < "u" ? new URLSearchParams(window.location.search) : new URLSearchParams();
776
- }, Ne = ({ value: e, children: t }) => /* @__PURE__ */ p(Q.Provider, {
783
+ }, Fe = ({ value: e, children: t }) => /* @__PURE__ */ p(Z.Provider, {
777
784
  value: e,
778
785
  children: t
779
- }), Pe = (e) => {
786
+ }), Ie = (e) => {
780
787
  let t = {};
781
788
  if (!e) return t;
782
789
  for (let n of e.split(";")) {
@@ -794,4 +801,4 @@ var m = {
794
801
  return t;
795
802
  };
796
803
  //#endregion
797
- export { W as A, ne as B, ue as C, q as D, O as E, J as F, g as H, v as I, y as L, K as M, we as N, G as O, Ee as P, re as R, Z as S, ae as T, te as U, b as V, _ as W, ce as _, je as a, k as b, R as c, De as d, S as f, Te as g, D as h, Me as i, Se as j, U as k, V as l, I as m, Ne as n, X as o, ye as p, Pe as r, le as s, Q as t, ve as u, Ae as v, se as w, ke as x, A as y, x as z };
804
+ export { V as A, ie as B, X as C, oe as D, O as E, Oe as F, te as G, re as H, q as I, ne as K, ke as L, W as M, Te as N, Ee as O, G as P, _ as R, Me as S, se as T, y as U, b as V, g as W, K as _, Q as a, k as b, L as c, xe as d, Ae as f, E as g, P as h, Pe as i, H as j, U as k, I as l, Se as m, Fe as n, Y as o, x as p, Ie as r, ue as s, Z as t, z as u, ce as v, de as w, D as x, Ne as y, v as z };