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