@jasonshimmy/custom-elements-runtime 2.5.0 → 2.5.2

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.
Files changed (36) hide show
  1. package/dist/custom-elements-runtime.cjs.js +1 -18
  2. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  3. package/dist/custom-elements-runtime.es.js +150 -3644
  4. package/dist/custom-elements-runtime.es.js.map +1 -1
  5. package/dist/custom-elements-runtime.router.cjs.js +19 -19
  6. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  7. package/dist/custom-elements-runtime.router.es.js +762 -451
  8. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  9. package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
  10. package/dist/custom-elements-runtime.ssr.es.js +1 -1
  11. package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
  12. package/dist/custom-elements-runtime.transitions.es.js +1 -1
  13. package/dist/index.d.ts +2 -0
  14. package/dist/namespace-helpers-BCVTzhAO.cjs +5 -0
  15. package/dist/namespace-helpers-BCVTzhAO.cjs.map +1 -0
  16. package/dist/namespace-helpers-CF28TyaG.js +786 -0
  17. package/dist/namespace-helpers-CF28TyaG.js.map +1 -0
  18. package/dist/router.d.ts +82 -21
  19. package/dist/runtime/monitoring/health-monitor.d.ts +99 -0
  20. package/dist/runtime/render.d.ts +1 -1
  21. package/dist/runtime/scheduler.d.ts +46 -0
  22. package/dist/template-compiler-CXHEnaBh.cjs +17 -0
  23. package/dist/template-compiler-CXHEnaBh.cjs.map +1 -0
  24. package/dist/template-compiler-DD_VZrte.js +3729 -0
  25. package/dist/template-compiler-DD_VZrte.js.map +1 -0
  26. package/dist/{transitions-CZ21fzhh.js → transitions-Bx0Nc9zR.js} +256 -255
  27. package/dist/transitions-Bx0Nc9zR.js.map +1 -0
  28. package/dist/{transitions-RXe2brRm.cjs → transitions-DfcqL-X4.cjs} +4 -4
  29. package/dist/transitions-DfcqL-X4.cjs.map +1 -0
  30. package/package.json +9 -8
  31. package/dist/namespace-helpers-BsKQl3aH.cjs +0 -5
  32. package/dist/namespace-helpers-BsKQl3aH.cjs.map +0 -1
  33. package/dist/namespace-helpers-Dw1mgQab.js +0 -692
  34. package/dist/namespace-helpers-Dw1mgQab.js.map +0 -1
  35. package/dist/transitions-CZ21fzhh.js.map +0 -1
  36. package/dist/transitions-RXe2brRm.cjs.map +0 -1
@@ -1,169 +1,241 @@
1
- import { component as tt, html as z, useOnConnected as et, useOnDisconnected as nt, useProps as st, useStyle as it } from "./custom-elements-runtime.es.js";
2
- import { r as V, c as T } from "./namespace-helpers-Dw1mgQab.js";
3
- import { createStore as rt } from "./custom-elements-runtime.store.es.js";
4
- import { d as F, a as P } from "./logger-BuUYv7C_.js";
5
- import { match as ct } from "./custom-elements-runtime.directives.es.js";
6
- const Q = (o) => o ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(o)) : {}, lt = (o) => {
7
- if (!o || Object.keys(o).length === 0) return "";
1
+ import { c as st, h as L, a as ct, b as it, g as vt, f as bt } from "./template-compiler-DD_VZrte.js";
2
+ import { f as et, r as Y, c as T } from "./namespace-helpers-CF28TyaG.js";
3
+ import { createStore as lt } from "./custom-elements-runtime.store.es.js";
4
+ import { d as I, a as g } from "./logger-BuUYv7C_.js";
5
+ import { match as wt } from "./custom-elements-runtime.directives.es.js";
6
+ const ut = {
7
+ enabled: !0,
8
+ offset: 0,
9
+ timeoutMs: 2e3
10
+ }, at = (t) => t ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(t)) : {}, St = (t) => {
11
+ if (!t || Object.keys(t).length === 0) return "";
8
12
  try {
9
- return "?" + new URLSearchParams(o).toString();
13
+ return "?" + new URLSearchParams(t).toString();
10
14
  } catch {
11
15
  return "";
12
16
  }
13
- }, at = (o) => o ? /^\s*javascript\s*:/i.test(o) : !1, ot = /* @__PURE__ */ new WeakMap();
14
- function ut(o) {
15
- return o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17
+ }, ft = (t) => t ? /^\s*javascript\s*:/i.test(t) : !1, H = (t) => /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t) || t.startsWith("//"), Rt = (t) => {
18
+ try {
19
+ return decodeURIComponent(t);
20
+ } catch {
21
+ return t;
22
+ }
23
+ }, $t = (t) => {
24
+ if (!t) return "";
25
+ const r = x(t);
26
+ return r === "/" ? "" : r;
27
+ }, ht = /* @__PURE__ */ new WeakMap();
28
+ function Et(t) {
29
+ return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16
30
  }
17
- function k(o) {
18
- if (!o) return "/";
19
- let i = o.replace(/\/+/g, "/");
20
- return i.startsWith("/") || (i = "/" + i), i.length > 1 && i.endsWith("/") && (i = i.slice(0, -1)), i;
31
+ function x(t) {
32
+ if (!t) return "/";
33
+ let r = t.replace(/\/+/g, "/");
34
+ return r.startsWith("/") || (r = "/" + r), r.length > 1 && r.endsWith("/") && (r = r.slice(0, -1)), r;
21
35
  }
22
- function ft(o) {
23
- const i = o.path || "/", s = k(i), d = s === "/" ? [] : s.split("/").filter(Boolean), h = [], l = [];
24
- for (let c = 0; c < d.length; c++) {
25
- const p = d[c];
26
- if (p === "*") {
27
- if (c !== d.length - 1)
28
- return P(
29
- `Route '${o.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`
36
+ function Ct(t) {
37
+ const r = t.path || "/", a = x(r), y = a === "/" ? [] : a.split("/").filter(Boolean), o = [], i = [];
38
+ for (let u = 0; u < y.length; u++) {
39
+ const f = y[u];
40
+ if (f === "*") {
41
+ if (u !== y.length - 1)
42
+ return g(
43
+ `Route '${t.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`
30
44
  ), { invalid: !0 };
31
- const g = `splat${h.length}`;
32
- h.push(g), l.push("__SPLAT__");
45
+ const E = `splat${o.length}`;
46
+ o.push(E), i.push("__SPLAT__");
33
47
  continue;
34
48
  }
35
- const b = p.match(/^:([A-Za-z0-9_-]+)(\*)?$/);
49
+ const b = f.match(/^:([A-Za-z0-9_-]+)(\*)?$/);
36
50
  if (b) {
37
- const g = b[1], q = !!b[2];
38
- if (q && c !== d.length - 1)
39
- return P(
40
- `Route '${o.path}' contains a splat param ':${g}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`
51
+ const E = b[1], M = !!b[2];
52
+ if (M && u !== y.length - 1)
53
+ return g(
54
+ `Route '${t.path}' contains a splat param ':${E}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`
41
55
  ), { invalid: !0 };
42
- h.push(g), l.push(q ? "__SPLAT__" : "([^/]+)");
56
+ o.push(E), i.push(M ? "__SPLAT__" : "([^/]+)");
43
57
  continue;
44
58
  }
45
- l.push(ut(p));
59
+ i.push(Et(f));
46
60
  }
47
- let m;
48
- if (l.length === 0)
49
- m = "^/$";
50
- else if (l[l.length - 1] === "__SPLAT__") {
51
- const p = l.slice(0, -1).join("/");
52
- p ? m = `^/${p}(?:/(.*))?(?:/)?$` : m = "^(?:/(.*))?(?:/)?$";
61
+ let l;
62
+ if (i.length === 0)
63
+ l = "^/$";
64
+ else if (i[i.length - 1] === "__SPLAT__") {
65
+ const f = i.slice(0, -1).join("/");
66
+ f ? l = `^/${f}(?:/(.*))?(?:/)?$` : l = "^(?:/(.*))?(?:/)?$";
53
67
  } else
54
- m = `^/${l.join("/")}(?:/)?$`;
68
+ l = `^/${i.join("/")}(?:/)?$`;
55
69
  try {
56
- return { regex: new RegExp(m), paramNames: h };
57
- } catch (c) {
58
- return P(`Failed to compile route regex for '${o.path}': ${String(c)}`), { invalid: !0 };
70
+ return { regex: new RegExp(l), paramNames: o };
71
+ } catch (u) {
72
+ return g(`Failed to compile route regex for '${t.path}': ${String(u)}`), { invalid: !0 };
59
73
  }
60
74
  }
61
- const M = (o, i) => {
62
- const s = k(i);
63
- for (const d of o) {
64
- let h = ot.get(d);
65
- if (h || (h = ft(d), ot.set(d, h)), h.invalid) continue;
66
- const { regex: l, paramNames: m } = h, c = l.exec(s);
67
- if (c) {
68
- const p = {}, b = (g) => {
69
- try {
70
- return decodeURIComponent(g);
71
- } catch {
72
- return g;
73
- }
74
- };
75
- for (let g = 0; g < m.length; g++) {
76
- const q = c[g + 1] || "";
77
- p[m[g]] = q ? b(q) : "";
75
+ const Z = (t, r) => {
76
+ const a = x(r);
77
+ for (const y of t) {
78
+ let o = ht.get(y);
79
+ if (o || (o = Ct(y), ht.set(y, o)), o.invalid) continue;
80
+ const { regex: i, paramNames: l } = o, u = i.exec(a);
81
+ if (u) {
82
+ const f = {};
83
+ for (let b = 0; b < l.length; b++) {
84
+ const E = u[b + 1] || "";
85
+ f[l[b]] = E ? Rt(E) : "";
78
86
  }
79
- return { route: d, params: p };
87
+ return { route: y, params: f };
80
88
  }
81
89
  }
82
90
  return { route: null, params: {} };
83
91
  };
84
- function K(o, i) {
85
- for (const s of o)
86
- if (M([s], i).route !== null) return s;
92
+ function tt(t, r) {
93
+ for (const a of t)
94
+ if (Z([a], r).route !== null) return a;
87
95
  return null;
88
96
  }
89
- const H = {};
90
- async function ht(o) {
91
- if (o.component) return o.component;
92
- if (o.load) {
93
- if (H[o.path]) return H[o.path];
97
+ const pt = 50;
98
+ let Q = {}, W = {};
99
+ function xt() {
100
+ Q = {}, W = {};
101
+ }
102
+ function At() {
103
+ const t = Object.entries(Q);
104
+ if (t.length <= pt) return;
105
+ const a = t.sort(
106
+ ([, y], [, o]) => y.lastAccessed - o.lastAccessed
107
+ ).slice(
108
+ 0,
109
+ t.length - pt
110
+ );
111
+ for (const [y] of a)
112
+ delete Q[y];
113
+ }
114
+ async function kt(t) {
115
+ if (t.component) return t.component;
116
+ if (t.load) {
117
+ const r = Q[t.path];
118
+ if (r)
119
+ return r.lastAccessed = Date.now(), r.component;
120
+ if (W[t.path] !== void 0)
121
+ return W[t.path];
122
+ const a = typeof window > "u";
94
123
  try {
95
- const i = await o.load();
96
- return H[o.path] = i.default, i.default;
97
- } catch {
98
- throw new Error(`Failed to load component for route: ${o.path}`);
124
+ const y = t.load().then((o) => {
125
+ At();
126
+ const i = o.default;
127
+ return Q[t.path] = {
128
+ component: i,
129
+ lastAccessed: Date.now()
130
+ }, delete W[t.path], i;
131
+ }).catch((o) => {
132
+ delete W[t.path];
133
+ const i = o instanceof Error ? o.message : String(o);
134
+ throw a && I(
135
+ `SSR component load failed for route: ${t.path}. ${i}`
136
+ ), new Error(
137
+ `Failed to load component for route: ${t.path}. ${i}`
138
+ );
139
+ });
140
+ return W[t.path] = y, await y;
141
+ } catch (y) {
142
+ const o = y instanceof Error ? y.message : String(y);
143
+ throw new Error(
144
+ `Failed to load component for route: ${t.path}. ${o}`
145
+ );
99
146
  }
100
147
  }
101
- throw new Error(`No component or loader defined for route: ${o.path}`);
148
+ throw new Error(`No component or loader defined for route: ${t.path}`);
102
149
  }
103
- function pt(o) {
104
- const { routes: i, base: s = "", initialUrl: d, scrollToFragment: h = !0 } = o, l = (() => {
105
- if (!s) return "";
106
- const r = k(s);
107
- return r === "/" ? "" : r;
108
- })(), m = typeof h == "boolean" ? { enabled: !!h, offset: 0, timeoutMs: 2e3 } : {
109
- enabled: h.enabled ?? !0,
110
- offset: h.offset ?? 0,
111
- timeoutMs: h.timeoutMs ?? 2e3
112
- };
113
- let c, p, b, g, q, B, D;
114
- const Y = async (r, e) => {
115
- const t = K(i, r.path);
116
- if (!t || !t.beforeEnter) return !0;
150
+ function Pt(t) {
151
+ const { routes: r, base: a = "", initialUrl: y, scrollToFragment: o = !0 } = t, i = $t(a), l = typeof o == "boolean" ? { ...ut, enabled: o } : { ...ut, ...o };
152
+ let u, f, b, E, M, B, K;
153
+ const q = /* @__PURE__ */ new Set(), F = 10;
154
+ let P = 0;
155
+ const J = async (s, c) => {
156
+ const e = tt(r, s.path);
157
+ if (!e || !e.beforeEnter) return !0;
117
158
  try {
118
- const n = await t.beforeEnter(r, e);
119
- return typeof n == "string" ? (await y(n, !0), !1) : n !== !1;
159
+ const n = await e.beforeEnter(s, c);
160
+ if (typeof n == "string") {
161
+ const d = `${s.path}->${n}`;
162
+ return q.has(d) || P >= F ? (I(`Redirect loop detected: ${d}`), !1) : n;
163
+ }
164
+ return n !== !1;
120
165
  } catch (n) {
121
- return F("beforeEnter error", n), !1;
166
+ I("beforeEnter error", n);
167
+ try {
168
+ b.setState(c);
169
+ } catch {
170
+ }
171
+ throw n;
122
172
  }
123
- }, X = async (r, e) => {
124
- const t = K(i, r.path);
125
- if (!t || !t.onEnter) return !0;
173
+ }, rt = async (s, c) => {
174
+ const e = tt(r, s.path);
175
+ if (!e || !e.onEnter) return !0;
126
176
  try {
127
- const n = await t.onEnter(r, e);
128
- return typeof n == "string" ? (await y(n, !0), !1) : n !== !1;
177
+ const n = await e.onEnter(s, c);
178
+ if (typeof n == "string") {
179
+ const d = `${s.path}->${n}`;
180
+ return q.has(d) || P >= F ? (I(`Redirect loop detected: ${d}`), !1) : n;
181
+ }
182
+ return n !== !1;
129
183
  } catch (n) {
130
- return F("onEnter error", n), !1;
184
+ I("onEnter error", n);
185
+ try {
186
+ b.setState(c);
187
+ } catch {
188
+ }
189
+ throw n;
131
190
  }
132
- }, Z = (r, e) => {
133
- const t = K(i, r.path);
134
- if (!(!t || !t.afterEnter))
191
+ }, X = (s, c) => {
192
+ const e = tt(r, s.path);
193
+ if (!(!e || !e.afterEnter))
135
194
  try {
136
- t.afterEnter(r, e);
195
+ e.afterEnter(s, c);
137
196
  } catch (n) {
138
- F("afterEnter error", n);
197
+ I("afterEnter error", n);
139
198
  }
199
+ }, k = /* @__PURE__ */ new Map(), U = 100, O = (s) => {
200
+ if (k.has(s))
201
+ return k.get(s);
202
+ const c = Z(r, s);
203
+ if (k.size >= U) {
204
+ const e = Math.floor(U * 0.25), n = Array.from(k.keys());
205
+ for (let d = 0; d < e && d < n.length; d++)
206
+ k.delete(n[d]);
207
+ }
208
+ return k.set(s, c), c;
209
+ }, G = () => {
140
210
  };
141
- let w = 0, C = null, O = null, L = null;
142
- async function a(r, e = 0) {
211
+ async function p(s, c = 0) {
143
212
  try {
144
- const t = document.getElementById(r);
145
- if (!t) return !1;
146
- if (e && e > 0)
213
+ const e = document.getElementById(s);
214
+ if (!e)
215
+ return !1;
216
+ if (c > 0)
147
217
  try {
148
- const n = t.getBoundingClientRect(), E = Math.max(0, window.scrollY + n.top - e);
149
- typeof window.scrollTo == "function" && window.scrollTo({ top: E, behavior: "auto" });
218
+ const n = e.getBoundingClientRect(), d = Math.max(0, window.scrollY + n.top - c);
219
+ typeof window.scrollTo == "function" && window.scrollTo({ top: d, behavior: "auto" });
150
220
  } catch {
151
221
  try {
152
- t.scrollIntoView();
222
+ e.scrollIntoView();
153
223
  } catch {
224
+ return !1;
154
225
  }
155
226
  }
156
- else if (typeof t.scrollIntoView == "function")
227
+ else if (typeof e.scrollIntoView == "function")
157
228
  try {
158
- t.scrollIntoView({
229
+ e.scrollIntoView({
159
230
  behavior: "auto",
160
231
  block: "start",
161
232
  inline: "nearest"
162
233
  });
163
234
  } catch {
164
235
  try {
165
- t.scrollIntoView();
236
+ e.scrollIntoView();
166
237
  } catch {
238
+ return !1;
167
239
  }
168
240
  }
169
241
  return !0;
@@ -171,283 +243,456 @@ function pt(o) {
171
243
  return !1;
172
244
  }
173
245
  }
174
- function u() {
175
- if (C) {
176
- try {
177
- C.disconnect();
178
- } catch {
179
- }
180
- C = null;
181
- }
182
- if (O) {
183
- try {
184
- clearTimeout(O);
185
- } catch {
186
- }
187
- O = null;
188
- }
189
- }
190
- function v(r, e, t) {
191
- w += 1;
192
- const n = w;
193
- if (L) {
194
- try {
195
- L(!1);
196
- } catch {
197
- }
198
- L = null;
199
- }
200
- return u(), new Promise((E) => {
201
- L = E;
202
- const f = (A) => {
203
- if (n === w) {
204
- u();
246
+ function $(s, c = 0, e = 2e3) {
247
+ return new Promise((n) => {
248
+ let d = !1, v = null;
249
+ const w = Date.now(), S = (A) => {
250
+ d || (d = !0, v && clearTimeout(v), n(A));
251
+ }, R = async () => {
252
+ if (!d)
205
253
  try {
206
- E(A);
207
- } finally {
208
- L = null;
209
- }
210
- }
211
- };
212
- queueMicrotask(async () => {
213
- if (n !== w) return f(!1);
214
- if (await a(r, e)) return f(!0);
215
- if (typeof window.requestAnimationFrame == "function")
216
- window.requestAnimationFrame(async () => {
217
- if (n !== w) return f(!1);
218
- if (await a(r, e)) return f(!0);
219
- if (n !== w) return f(!1);
220
- const A = document.querySelector("router-view") || document.body;
221
- try {
222
- const x = new MutationObserver(async () => {
223
- n === w && await a(r, e) && f(!0);
224
- });
225
- C = x, x.observe(A, {
226
- childList: !0,
227
- subtree: !0,
228
- attributes: !1
229
- }), O = window.setTimeout(() => {
230
- if (n === w) {
231
- try {
232
- x.disconnect();
233
- } catch {
234
- }
235
- C = null, O = null, f(!1);
236
- }
237
- }, t ?? 2e3);
238
- } catch {
239
- let R = 0;
240
- const S = async () => {
241
- if (n !== w) return f(!1);
242
- if (await a(r, e)) return f(!0);
243
- R += 1, R < 40 ? window.setTimeout(S, 50) : f(!1);
244
- };
245
- S();
246
- }
247
- });
248
- else {
249
- const A = document.querySelector("router-view") || document.body;
250
- try {
251
- const x = new MutationObserver(async () => {
252
- n === w && await a(r, e) && f(!0);
253
- });
254
- C = x, x.observe(A, {
255
- childList: !0,
256
- subtree: !0,
257
- attributes: !1
258
- }), O = window.setTimeout(() => {
259
- if (n === w) {
260
- try {
261
- x.disconnect();
262
- } catch {
263
- }
264
- C = null, O = null, f(!1);
254
+ if (await p(s, c))
255
+ return S(!0);
256
+ const A = async () => {
257
+ if (d) return;
258
+ if (Date.now() - w >= e)
259
+ return S(!1);
260
+ try {
261
+ if (await p(s, c))
262
+ return S(!0);
263
+ requestAnimationFrame(A);
264
+ } catch (gt) {
265
+ g("Scroll retry attempt failed:", gt), requestAnimationFrame(A);
265
266
  }
266
- }, t ?? 2e3);
267
- } catch {
268
- let R = 0;
269
- const S = async () => {
270
- if (n !== w) return f(!1);
271
- if (await a(r, e)) return f(!0);
272
- R += 1, R < 40 ? window.setTimeout(S, 50) : f(!1);
273
267
  };
274
- S();
268
+ requestAnimationFrame(A);
269
+ } catch (A) {
270
+ g("Initial scroll attempt failed:", A), S(!1);
275
271
  }
276
- }
272
+ };
273
+ v = setTimeout(() => {
274
+ S(!1);
275
+ }, e), R().catch((A) => {
276
+ g("Scroll attempt failed:", A), S(!1);
277
277
  });
278
278
  });
279
279
  }
280
- const y = async (r, e = !1) => {
280
+ let h = !1;
281
+ const _ = async (s, c = !1) => {
282
+ if (h) {
283
+ g(`Navigation to ${s} blocked - navigation already in progress`);
284
+ return;
285
+ }
286
+ h = !0, P = 0, q.clear();
281
287
  try {
282
- const t = r.indexOf("#"), n = t >= 0 ? r.slice(t + 1) : "", E = t >= 0 ? r.slice(0, t) : r, f = E.indexOf("?"), $ = f >= 0 ? E.slice(0, f) : E, A = f >= 0 ? Q(E.slice(f)) : {}, x = $.startsWith(l) ? $.slice(l.length) : $, R = {
283
- path: k(x || "/"),
284
- query: A,
285
- fragment: n
286
- }, S = M(i, R.path);
287
- if (!S.route) throw new Error(`No route found for ${R.path}`);
288
- const N = b.getState(), W = {
289
- path: R.path,
290
- params: S.params,
291
- query: R.query,
292
- fragment: R.fragment
293
- };
294
- if (!await Y(W, N) || !await X(W, N)) return;
288
+ await D(s, c);
289
+ } finally {
290
+ h = !1, P = 0, q.clear();
291
+ }
292
+ }, N = (s) => {
293
+ const c = s.indexOf("#"), e = c >= 0 ? s.slice(c + 1) : "", n = c >= 0 ? s.slice(0, c) : s, d = n.indexOf("?"), v = d >= 0 ? n.slice(0, d) : n, w = d >= 0 ? at(n.slice(d)) : {}, S = v.startsWith(i) ? v.slice(i.length) : v;
294
+ return {
295
+ path: x(S || "/"),
296
+ query: w,
297
+ fragment: e
298
+ };
299
+ }, D = async (s, c = !1) => {
300
+ try {
301
+ const e = N(s), n = O(e.path);
302
+ if (!n.route) throw new Error(`No route found for ${e.path}`);
303
+ const d = b.getState(), v = {
304
+ path: e.path,
305
+ params: n.params,
306
+ query: e.query,
307
+ fragment: e.fragment
308
+ }, w = await J(v, d);
309
+ if (w === !1) return;
310
+ if (typeof w == "string") {
311
+ P++;
312
+ const R = `${v.path}->${w}`;
313
+ q.add(R), await D(w, !0);
314
+ return;
315
+ }
316
+ const S = await rt(v, d);
317
+ if (S === !1) return;
318
+ if (typeof S == "string") {
319
+ P++;
320
+ const R = `${v.path}->${S}`;
321
+ q.add(R), await D(S, !0);
322
+ return;
323
+ }
295
324
  if (typeof window < "u" && typeof document < "u") {
296
- const _ = lt(R.query), J = l + R.path + (_ || "") + (R.fragment ? "#" + R.fragment : "");
297
- e ? window.history.replaceState({}, "", J) : window.history.pushState({}, "", J);
325
+ const R = St(e.query), A = i + e.path + (R || "") + (e.fragment ? "#" + e.fragment : "");
326
+ c ? window.history.replaceState({}, "", A) : window.history.pushState({}, "", A);
298
327
  }
299
- b.setState(W), Z(W, N);
328
+ if (b.setState(v), X(v, d), typeof window < "u" && typeof document < "u")
329
+ try {
330
+ const R = v.fragment;
331
+ l.enabled && R && $(
332
+ String(R),
333
+ l.offset,
334
+ l.timeoutMs
335
+ ).catch(() => {
336
+ });
337
+ } catch {
338
+ }
339
+ } catch (e) {
340
+ if (I("Navigation error:", e), e instanceof Error && (e.stack?.includes("runBeforeEnter") || e.stack?.includes("runOnEnter")))
341
+ throw e;
300
342
  try {
301
- const _ = W.fragment;
302
- m.enabled && _ && typeof window < "u" && typeof document < "u" && v(
303
- String(_),
304
- m.offset,
305
- m.timeoutMs
306
- ).catch(() => {
307
- });
308
- } catch {
343
+ const n = b.getState();
344
+ if (!Z(r, n.path).route) {
345
+ let v = r.find((w) => w.path === "/");
346
+ if (v || (v = r.find(
347
+ (w) => !w.path.includes(":") && !w.path.includes("*")
348
+ )), !v && r.length > 0 && (v = r[0]), v) {
349
+ const w = Z(r, v.path);
350
+ b.setState({
351
+ path: v.path,
352
+ params: w.params,
353
+ query: {}
354
+ });
355
+ } else
356
+ I("No fallback route available for error recovery");
357
+ }
358
+ } catch (n) {
359
+ g(
360
+ "State recovery failed during navigation error:",
361
+ n
362
+ );
309
363
  }
310
- } catch (t) {
311
- F("Navigation error:", t);
312
364
  }
313
365
  };
314
- if (typeof window < "u" && typeof document < "u" && typeof d > "u") {
315
- c = () => {
316
- const e = new URL(window.location.href), t = e.pathname, n = t.startsWith(l) ? t.slice(l.length) : t, E = k(n || "/"), f = Q(e.search), $ = e.hash && e.hash.length ? e.hash.slice(1) : "";
317
- return { path: E, query: f, fragment: $ };
318
- }, p = c();
319
- const r = M(i, p.path);
320
- b = rt({
321
- path: p.path,
322
- params: r.params,
323
- query: p.query,
324
- fragment: p.fragment
325
- }), g = async (e = !1) => {
326
- const t = c();
327
- await y(t.path, e);
328
- }, window.addEventListener("popstate", () => g(!0)), q = (e) => y(e, !1), B = (e) => y(e, !0), D = () => window.history.back();
366
+ if (((s) => {
367
+ if (!s || s.length === 0)
368
+ return I("Router configuration error: No routes provided"), !1;
369
+ const c = /* @__PURE__ */ new Set();
370
+ for (const e of s) {
371
+ if (!e.path)
372
+ return I("Router configuration error: Route missing path", e), !1;
373
+ c.has(e.path) && g(`Duplicate route path detected: ${e.path}`), c.add(e.path), !e.component && !e.load && g(`Route '${e.path}' has no component or load function`);
374
+ }
375
+ return !0;
376
+ })(r), typeof window > "u" || typeof y < "u") {
377
+ for (const s of r)
378
+ O(s.path);
379
+ g(`Pre-compiled ${r.length} routes for SSR`);
380
+ }
381
+ if (typeof window < "u" && typeof document < "u" && typeof y > "u") {
382
+ u = () => {
383
+ try {
384
+ const e = new URL(window.location.href), n = e.pathname, d = n.startsWith(i) ? n.slice(i.length) : n, v = x(d || "/"), w = at(e.search), S = e.hash && e.hash.length ? e.hash.slice(1) : "";
385
+ return { path: v, query: w, fragment: S };
386
+ } catch (e) {
387
+ return g("Invalid URL detected, falling back to safe defaults", e), { path: "/", query: {}, fragment: "" };
388
+ }
389
+ }, f = u();
390
+ const s = O(f.path);
391
+ b = lt({
392
+ path: f.path,
393
+ params: s.params,
394
+ query: f.query,
395
+ fragment: f.fragment
396
+ }), E = async (e = !1) => {
397
+ const n = u();
398
+ await _(n.path, e);
399
+ };
400
+ const c = () => E(!0);
401
+ window.addEventListener("popstate", c), M = (e) => _(e, !1), B = (e) => _(e, !0), K = () => window.history.back();
329
402
  } else {
330
- c = () => {
331
- const t = new URL(d || "/", "http://localhost"), n = t.pathname, E = n.startsWith(l) ? n.slice(l.length) : n, f = k(E || "/"), $ = Q(t.search), A = t.hash && t.hash.length ? t.hash.slice(1) : "";
332
- return { path: f, query: $, fragment: A };
333
- }, p = c();
334
- const r = M(i, p.path);
335
- b = rt({
336
- path: p.path,
337
- params: r.params,
338
- query: p.query,
339
- fragment: p.fragment
340
- }), g = async () => {
341
- const t = c();
342
- await e(t.path);
403
+ u = () => {
404
+ try {
405
+ const e = new URL(y || "/", "http://localhost"), n = e.pathname, d = n.startsWith(i) ? n.slice(i.length) : n, v = x(d || "/"), w = at(e.search), S = e.hash && e.hash.length ? e.hash.slice(1) : "";
406
+ return { path: v, query: w, fragment: S };
407
+ } catch (e) {
408
+ return g(
409
+ "Invalid SSR URL detected, falling back to safe defaults",
410
+ e
411
+ ), { path: "/", query: {}, fragment: "" };
412
+ }
413
+ }, f = u();
414
+ const s = O(f.path);
415
+ b = lt({
416
+ path: f.path,
417
+ params: s.params,
418
+ query: f.query,
419
+ fragment: f.fragment
420
+ }), E = async () => {
421
+ const e = u();
422
+ await c(e.path);
343
423
  };
344
- const e = async (t) => {
424
+ const c = async (e) => {
425
+ if (P++, P > F) {
426
+ I(`SSR redirect depth exceeded for path: ${e}`);
427
+ return;
428
+ }
345
429
  try {
346
- const n = t.indexOf("#"), E = n >= 0 ? t.slice(n + 1) : "", f = n >= 0 ? t.slice(0, n) : t, $ = f.indexOf("?"), A = $ >= 0 ? f.slice(0, $) : f, x = $ >= 0 ? Q(f.slice($)) : {}, U = A.startsWith(l) ? A.slice(l.length) : A, S = {
347
- path: k(U || "/"),
348
- query: x,
349
- fragment: E
350
- }, N = M(i, S.path);
351
- if (!N.route) throw new Error(`No route found for ${S.path}`);
352
- const W = b.getState(), j = {
353
- path: S.path,
354
- params: N.params,
355
- query: S.query,
356
- fragment: S.fragment
357
- }, I = K(i, j.path);
358
- if (I?.beforeEnter) {
359
- const _ = await I.beforeEnter(j, W);
360
- if (typeof _ == "string") {
361
- await e(_);
430
+ const n = N(e), d = O(n.path);
431
+ if (!d.route) throw new Error(`No route found for ${n.path}`);
432
+ const v = b.getState(), w = {
433
+ path: n.path,
434
+ params: d.params,
435
+ query: n.query,
436
+ fragment: n.fragment
437
+ }, S = tt(r, w.path);
438
+ if (S?.beforeEnter) {
439
+ const R = await S.beforeEnter(w, v);
440
+ if (typeof R == "string") {
441
+ const A = `${w.path}->${R}`;
442
+ q.add(A), await c(R);
362
443
  return;
363
444
  }
364
- if (_ === !1) return;
445
+ if (R === !1) return;
365
446
  }
366
- if (I?.onEnter) {
367
- const _ = await I.onEnter(j, W);
368
- if (typeof _ == "string") {
369
- await e(_);
447
+ if (S?.onEnter) {
448
+ const R = await S.onEnter(w, v);
449
+ if (typeof R == "string") {
450
+ const A = `${w.path}->${R}`;
451
+ q.add(A), await c(R);
370
452
  return;
371
453
  }
372
- if (_ === !1) return;
454
+ if (R === !1) return;
373
455
  }
374
- b.setState(j), I?.afterEnter && I.afterEnter(j, W);
456
+ b.setState(w), S?.afterEnter && S.afterEnter(w, v);
375
457
  } catch (n) {
376
- throw F("SSR navigation error:", n), n;
458
+ throw I("SSR navigation error:", n), n;
377
459
  }
378
460
  };
379
- q = async (t) => e(t), B = async (t) => e(t), D = () => {
461
+ M = async (e) => (P = 0, q.clear(), c(e)), B = async (e) => (P = 0, q.clear(), c(e)), K = () => {
380
462
  };
381
463
  }
382
464
  return {
465
+ _cleanupScrollState: G,
383
466
  store: b,
384
- push: q,
467
+ push: M,
385
468
  replace: B,
386
- back: D,
469
+ back: K,
387
470
  subscribe: b.subscribe,
388
- matchRoute: (r) => M(i, r),
471
+ matchRoute: (s) => O(s),
389
472
  getCurrent: () => b.getState(),
390
- resolveRouteComponent: ht,
391
- base: l,
473
+ resolveRouteComponent: kt,
474
+ base: i,
392
475
  // Public API: allow components or tests to explicitly request scrolling to
393
476
  // a fragment when they know their DOM is ready. Returns true if scrolled.
394
- scrollToFragment: (r) => {
395
- const e = r || b.getState().fragment;
396
- return !e || typeof window > "u" || typeof document > "u" ? Promise.resolve(!1) : v(
397
- String(e),
398
- m.offset,
399
- m.timeoutMs
477
+ scrollToFragment: (s) => {
478
+ const c = s || b.getState().fragment;
479
+ return !c || typeof window > "u" || typeof document > "u" ? Promise.resolve(!1) : $(
480
+ c,
481
+ l.offset,
482
+ l.timeoutMs
400
483
  );
401
484
  }
402
485
  };
403
486
  }
404
- function vt(o, i) {
405
- return M(o, i);
487
+ function Nt(t, r) {
488
+ return Z(t, r);
406
489
  }
407
- let G = null;
408
- function bt(o) {
409
- const i = pt(o);
410
- return G = i, tt("router-view", async () => {
411
- const s = G || i;
412
- if (!s) return z`<div>Router not initialized.</div>`;
413
- const d = V(s.getCurrent());
414
- let h;
415
- et(() => {
490
+ let m = null;
491
+ const j = /* @__PURE__ */ new Set();
492
+ let z = null;
493
+ function mt() {
494
+ if (z) {
495
+ try {
496
+ z();
497
+ } catch {
498
+ }
499
+ z = null;
500
+ }
501
+ if (m)
502
+ try {
503
+ let t = !1;
504
+ z = m.subscribe((r) => {
505
+ t = !0;
506
+ for (const a of j)
507
+ try {
508
+ a(r);
509
+ } catch {
510
+ }
511
+ });
416
512
  try {
417
- s && typeof s.subscribe == "function" && (h = s.subscribe((m) => {
513
+ C.base = m.base;
514
+ } catch {
515
+ }
516
+ if (t) {
517
+ const r = m.getCurrent();
518
+ for (const a of j)
418
519
  try {
419
- d.value = m;
420
- } catch (c) {
421
- P("router-view subscription update failed", c);
520
+ a(r);
521
+ } catch {
522
+ }
523
+ } else {
524
+ const r = m.getCurrent();
525
+ for (const a of j)
526
+ try {
527
+ a(r);
528
+ } catch {
529
+ }
530
+ }
531
+ try {
532
+ typeof window < "u" && et();
533
+ } catch {
534
+ }
535
+ } catch {
536
+ z = null;
537
+ }
538
+ }
539
+ const C = {
540
+ store: {
541
+ subscribe(t) {
542
+ if (m) return m.store.subscribe(t);
543
+ try {
544
+ t({ path: "/", params: {}, query: {} });
545
+ } catch {
546
+ }
547
+ return () => {
548
+ };
549
+ },
550
+ getState() {
551
+ return m ? m.getCurrent() : { path: "/", params: {}, query: {} };
552
+ },
553
+ setState(t) {
554
+ if (m)
555
+ try {
556
+ m.store.setState(
557
+ t
558
+ );
559
+ } catch {
560
+ }
561
+ }
562
+ },
563
+ subscribe(t) {
564
+ if (typeof t != "function")
565
+ return g("activeRouterProxy.subscribe: listener must be a function"), () => {
566
+ };
567
+ if (j.add(t), m)
568
+ if (!z)
569
+ mt();
570
+ else
571
+ try {
572
+ const r = m.getCurrent();
573
+ r && t(r);
574
+ } catch (r) {
575
+ g("activeRouterProxy subscription failed", r);
576
+ }
577
+ else
578
+ try {
579
+ t({ path: "/", params: {}, query: {} });
580
+ } catch (r) {
581
+ g("activeRouterProxy fallback state delivery failed", r);
582
+ }
583
+ return () => {
584
+ try {
585
+ if (j.delete(t), j.size === 0 && z) {
586
+ try {
587
+ z();
588
+ } catch (r) {
589
+ g("activeRouterProxy inner unsubscribe failed", r);
590
+ }
591
+ z = null;
592
+ }
593
+ } catch (r) {
594
+ g("activeRouterProxy unsubscribe failed", r);
595
+ }
596
+ };
597
+ },
598
+ getCurrent() {
599
+ return m ? m.getCurrent() : { path: "/", params: {}, query: {} };
600
+ },
601
+ async push(t) {
602
+ return m ? m.push(t) : Promise.resolve();
603
+ },
604
+ async replace(t) {
605
+ return m ? m.replace(t) : Promise.resolve();
606
+ },
607
+ back() {
608
+ if (m)
609
+ return m.back();
610
+ },
611
+ matchRoute(t) {
612
+ return m ? m.matchRoute(t) : { route: null, params: {} };
613
+ },
614
+ resolveRouteComponent(t) {
615
+ return m ? m.resolveRouteComponent(t) : Promise.reject(new Error("No active router"));
616
+ },
617
+ base: "",
618
+ scrollToFragment(t) {
619
+ return m ? m.scrollToFragment(t) : Promise.resolve(!1);
620
+ }
621
+ };
622
+ function zt(t) {
623
+ xt();
624
+ const r = Pt(t);
625
+ if (m)
626
+ try {
627
+ m._cleanupScrollState?.();
628
+ } catch {
629
+ }
630
+ m = r;
631
+ try {
632
+ mt();
633
+ try {
634
+ typeof window < "u" && et();
635
+ } catch {
636
+ }
637
+ try {
638
+ typeof window < "u" && queueMicrotask(() => {
639
+ try {
640
+ et();
641
+ } catch {
642
+ }
643
+ });
644
+ } catch {
645
+ }
646
+ } catch {
647
+ }
648
+ return st("router-view", async () => {
649
+ if (!m) return L`<div>Router not initialized.</div>`;
650
+ const a = Y(C.getCurrent()), y = typeof window > "u";
651
+ let o;
652
+ y || (ct(() => {
653
+ try {
654
+ typeof C.subscribe == "function" && (o = C.subscribe((l) => {
655
+ try {
656
+ l && typeof l == "object" && typeof l.path == "string" ? a.value = l : (g("router-view received invalid state", l), a.value = { path: "/", params: {}, query: {} });
657
+ } catch (u) {
658
+ g("router-view subscription update failed", u);
659
+ try {
660
+ a.value = { path: "/", params: {}, query: {} };
661
+ } catch {
662
+ }
422
663
  }
423
664
  }));
424
- } catch (m) {
425
- P("router-view subscribe failed", m);
665
+ } catch (l) {
666
+ g("router-view subscribe failed", l);
426
667
  }
427
- }), nt(() => {
428
- if (typeof h == "function")
668
+ }), it(() => {
669
+ if (typeof o == "function") {
429
670
  try {
430
- h();
431
- } catch (m) {
432
- P("router-view unsubscribe failed", m);
671
+ o();
672
+ } catch (l) {
673
+ g("router-view unsubscribe failed", l);
433
674
  }
434
- });
435
- const l = s.matchRoute(d.value.path);
436
- if (!l || !l.route) return z`<div>Not found</div>`;
675
+ o = void 0;
676
+ }
677
+ }));
678
+ const i = C.matchRoute(a.value.path);
679
+ if (!i || !i.route) return L`<div>Not found</div>`;
437
680
  try {
438
- const c = await s.resolveRouteComponent(l.route);
439
- if (typeof c == "string")
440
- return { tag: c, props: {}, children: [] };
441
- if (typeof c == "function") {
442
- const p = c();
443
- return (p instanceof Promise ? p : Promise.resolve(p)).then((g) => typeof g == "string" ? { tag: g, props: {}, children: [] } : g);
681
+ const u = await C.resolveRouteComponent(
682
+ i.route
683
+ );
684
+ if (typeof u == "string")
685
+ return { tag: u, props: {}, children: [] };
686
+ if (typeof u == "function") {
687
+ const f = u();
688
+ return (f instanceof Promise ? f : Promise.resolve(f)).then((E) => typeof E == "string" ? { tag: E, props: {}, children: [] } : E);
444
689
  }
445
- return z`<div>Invalid route component</div>`;
690
+ return L`<div>Invalid route component</div>`;
446
691
  } catch {
447
- return z`<div>Invalid route component</div>`;
692
+ return L`<div>Invalid route component</div>`;
448
693
  }
449
- }), tt("router-link", () => {
450
- const s = st({
694
+ }), st("router-link", () => {
695
+ const a = vt({
451
696
  to: "",
452
697
  tag: "a",
453
698
  replace: !1,
@@ -460,154 +705,220 @@ function bt(o) {
460
705
  // allow host `class` and `style` attributes to be read via useProps
461
706
  class: "",
462
707
  style: ""
463
- }), d = G || i, h = V(d.getCurrent());
464
- let l;
465
- it(() => "a,button{display:inline-block;}");
466
- const m = V(s.class || ""), c = V(s.style || "");
467
- et((a) => {
468
- try {
469
- d && typeof d.subscribe == "function" && (l = d.subscribe((u) => {
470
- try {
471
- h.value = u;
472
- } catch (v) {
473
- P("router-link subscription update failed", v);
708
+ }), y = typeof window > "u", o = Y(C.getCurrent()), i = o.value?.path || "/", l = String(a.to || ""), u = y ? {
709
+ isExactActive: dt(
710
+ i,
711
+ l,
712
+ C.base
713
+ ),
714
+ isActive: yt(
715
+ i,
716
+ l,
717
+ C.base
718
+ ),
719
+ isExternal: H(l) || !!a.external
720
+ } : null;
721
+ let f;
722
+ bt(() => "a,button{display:inline-block;}");
723
+ const b = Y(a.class || ""), E = Y(a.style || "");
724
+ if (!y) {
725
+ let p = null;
726
+ ct(($) => {
727
+ try {
728
+ if (typeof C.subscribe == "function") {
729
+ f = C.subscribe((h) => {
730
+ try {
731
+ h && typeof h == "object" && typeof h.path == "string" ? o.value = h : (g("router-link received invalid state", h), o.value = { path: "/", params: {}, query: {} });
732
+ } catch (_) {
733
+ g("router-link subscription update failed", _);
734
+ try {
735
+ o.value = { path: "/", params: {}, query: {} };
736
+ } catch {
737
+ }
738
+ }
739
+ });
740
+ try {
741
+ const h = C.getCurrent();
742
+ h && typeof h.path == "string" && (o.value = h);
743
+ } catch (h) {
744
+ g("router-link initial state sync failed", h);
745
+ }
746
+ p = setInterval(() => {
747
+ try {
748
+ const h = C.getCurrent();
749
+ h && typeof h.path == "string" && JSON.stringify(o.value) !== JSON.stringify(h) && (o.value = h);
750
+ } catch {
751
+ }
752
+ }, 100);
474
753
  }
475
- }));
476
- } catch (u) {
477
- P("router-link subscribe failed", u);
478
- }
479
- try {
480
- const u = a?._host;
481
- if (u instanceof HTMLElement) {
482
- const v = u.getAttribute("class"), y = u.getAttribute("style");
483
- v && (m.value = v), y && (c.value = y), v !== null && u.removeAttribute("class"), y !== null && u.removeAttribute("style");
754
+ } catch (h) {
755
+ g("router-link subscribe failed", h);
484
756
  }
485
- } catch (u) {
486
- P("router-link host migration failed", u);
487
- }
488
- }), nt(() => {
489
- if (typeof l == "function")
490
757
  try {
491
- l();
492
- } catch (a) {
493
- P("router-link unsubscribe failed", a);
758
+ const h = $?._host;
759
+ if (h instanceof HTMLElement) {
760
+ const _ = h.getAttribute("class"), N = h.getAttribute("style");
761
+ _ && (b.value = _), N && (E.value = N), _ !== null && h.removeAttribute("class"), N !== null && h.removeAttribute("style");
762
+ try {
763
+ $?._requestRender?.();
764
+ try {
765
+ et();
766
+ } catch {
767
+ }
768
+ } catch {
769
+ }
770
+ }
771
+ } catch (h) {
772
+ g("router-link host migration failed", h);
494
773
  }
495
- });
496
- const p = T(() => {
497
- const a = d?.base ?? "", u = s.to || "";
498
- if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(u) || u.startsWith("//"))
499
- return !1;
500
- const v = (u.split("#")[0] || "/").split("?")[0];
774
+ }), it(() => {
775
+ if (typeof f == "function")
776
+ try {
777
+ f();
778
+ } catch ($) {
779
+ g("router-link unsubscribe failed", $);
780
+ } finally {
781
+ f = void 0;
782
+ }
783
+ if (p)
784
+ try {
785
+ clearInterval(p);
786
+ } catch ($) {
787
+ g("router-link sync interval cleanup failed", $);
788
+ } finally {
789
+ p = null;
790
+ }
791
+ });
792
+ }
793
+ const M = T(() => {
794
+ if (y && u)
795
+ return u.isExactActive;
501
796
  try {
502
- let y = v;
503
- a && y.startsWith(a) && (y = y.slice(a.length) || "/");
504
- const r = k(h.value.path), e = k(y);
505
- return r === e;
506
- } catch {
507
- return h.value.path === v;
797
+ const p = C.base ?? "", $ = a.to || "";
798
+ return !o.value || typeof o.value.path != "string" ? !1 : dt(o.value.path, $, p);
799
+ } catch (p) {
800
+ return g("isExactActive computation error", p), !1;
508
801
  }
509
- }), b = T(() => {
510
- const a = d?.base ?? "", u = s.to || "";
511
- if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(u) || u.startsWith("//"))
512
- return !1;
513
- const v = (u.split("#")[0] || "/").split("?")[0];
514
- if (s.exact) return p.value;
802
+ }), B = T(() => {
803
+ if (y && u)
804
+ return u.isActive;
515
805
  try {
516
- let y = v;
517
- a && y.startsWith(a) && (y = y.slice(a.length) || "/");
518
- const r = k(h.value.path), e = k(y);
519
- return e === "/" ? r === "/" : r === e ? !0 : r.startsWith(e.endsWith("/") ? e : e + "/");
520
- } catch {
521
- return h.value && typeof h.value.path == "string" && h.value.path.startsWith(v);
806
+ const p = C.base ?? "", $ = a.to || "";
807
+ return !o.value || typeof o.value.path != "string" ? !1 : a.exact ? M.value : yt(o.value.path, $, p);
808
+ } catch (p) {
809
+ return g("isActive computation error", p), !1;
522
810
  }
523
- }), g = T(() => {
524
- const a = String(s.to || "");
525
- if (at(a)) return null;
526
- if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(a) || a.startsWith("//"))
527
- return a;
528
- const [u, v] = a.split("#"), [y, r] = (u || "").split("?"), e = d?.base ?? "";
529
- let t = y || "/";
530
- e && t.startsWith(e) && (t = t.slice(e.length) || "/");
531
- const n = k(t || "/");
532
- return e + n + (r ? "?" + r : "") + (v ? "#" + v : "");
811
+ }), K = T(() => {
812
+ const p = String(a.to || "");
813
+ if (ft(p)) return null;
814
+ if (H(p)) return p;
815
+ const [$, h] = p.split("#"), [_, N] = ($ || "").split("?"), D = C.base ?? "";
816
+ let V = _ || "/";
817
+ if (D && D !== "/") {
818
+ const nt = x(D), s = x(V);
819
+ s.startsWith(nt) ? V = s.slice(nt.length) || "/" : V = s;
820
+ }
821
+ const ot = x(V || "/");
822
+ return D + ot + (N ? "?" + N : "") + (h ? "#" + h : "");
533
823
  }), q = T(() => {
534
- const u = (m && m.value || s.class || "").split(/\s+/).filter(Boolean), v = {};
535
- for (const y of u) v[y] = !0;
536
- return v;
537
- }), B = T(() => ({
824
+ const $ = (b && b.value || a.class || "").split(/\s+/).filter(Boolean), h = {};
825
+ for (const _ of $) h[_] = !0;
826
+ return h;
827
+ }), F = T(() => ({
538
828
  ...q.value,
539
- [s.activeClass || "active"]: b.value,
540
- [s.exactActiveClass || "exact-active"]: p.value
541
- })), D = T(
542
- () => Object.keys(B.value).filter((a) => B.value[a]).join(" ")
543
- ), Y = T(() => s.tag || "a"), X = T(() => Y.value === "button"), Z = T(
544
- () => p.value ? s.ariaCurrentValue : null
545
- ), w = T(() => !!s.disabled), C = T(() => {
546
- const a = String(s.to || "");
547
- return (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(a) || a.startsWith("//") || !!s.external) && Y.value === "a";
829
+ [a.activeClass || "active"]: B.value,
830
+ [a.exactActiveClass || "exact-active"]: M.value
831
+ })), P = T(
832
+ () => Object.keys(F.value).filter((p) => F.value[p]).join(" ")
833
+ ), J = T(() => a.tag || "a"), rt = T(() => J.value === "button"), X = T(
834
+ () => M.value ? a.ariaCurrentValue : null
835
+ ), k = T(() => !!a.disabled), U = T(() => {
836
+ const p = String(a.to || "");
837
+ return (H(p) || !!a.external) && J.value === "a";
548
838
  }), O = T(
549
- () => c && c.value || s.style || ""
550
- ), L = (a) => {
551
- if (a.defaultPrevented || a.button !== 0 || a.metaKey || a.altKey || a.ctrlKey || a.shiftKey)
839
+ () => E && E.value || a.style || ""
840
+ ), G = (p) => {
841
+ if (p.defaultPrevented || p.button !== 0 || p.metaKey || p.altKey || p.ctrlKey || p.shiftKey)
552
842
  return;
553
- if (w.value) {
554
- a.preventDefault();
843
+ if (k.value) {
844
+ p.preventDefault();
555
845
  return;
556
846
  }
557
- const u = String(s.to || "");
558
- if (at(u)) {
847
+ const $ = String(a.to || "");
848
+ if (ft($)) {
559
849
  try {
560
- a.preventDefault();
850
+ p.preventDefault();
561
851
  } catch {
562
852
  }
563
- P("Blocked unsafe javascript: URI in router-link.to");
853
+ g("Blocked unsafe javascript: URI in router-link.to");
564
854
  return;
565
855
  }
566
- C.value || (a.preventDefault(), s.replace ? d.replace(s.to) : d.push(s.to));
856
+ U.value || (p.preventDefault(), a.replace ? C.replace(a.to) : C.push(a.to));
567
857
  };
568
- return z`
569
- ${ct().when(
570
- X.value,
571
- z`
858
+ return L`
859
+ ${wt().when(
860
+ rt.value,
861
+ L`
572
862
  <button
573
863
  part="button"
574
- class="${D.value}"
864
+ class="${P.value}"
575
865
  style="${O.value || null}"
576
- aria-current="${Z.value}"
577
- disabled="${w.value ? "" : null}"
578
- aria-disabled="${w.value ? "true" : null}"
579
- tabindex="${w.value ? "-1" : null}"
580
- @click="${L}"
866
+ aria-current="${X.value}"
867
+ disabled="${k.value ? "" : null}"
868
+ aria-disabled="${k.value ? "true" : null}"
869
+ tabindex="${k.value ? "-1" : null}"
870
+ @click="${G}"
581
871
  >
582
872
  <slot></slot>
583
873
  </button>
584
874
  `
585
- ).otherwise(z`
875
+ ).otherwise(L`
586
876
  <a
587
877
  part="link"
588
- href="${w.value ? null : g.value}"
589
- class="${D.value}"
878
+ href="${k.value ? null : K.value}"
879
+ class="${P.value}"
590
880
  style="${O.value || null}"
591
- aria-current="${Z.value}"
592
- aria-disabled="${w.value ? "true" : null}"
593
- tabindex="${w.value ? "-1" : null}"
594
- target="${C.value ? "_blank" : null}"
595
- rel="${C.value ? "noopener noreferrer" : null}"
596
- @click="${L}"
881
+ aria-current="${X.value}"
882
+ aria-disabled="${k.value ? "true" : null}"
883
+ tabindex="${k.value ? "-1" : null}"
884
+ target="${U.value ? "_blank" : null}"
885
+ rel="${U.value ? "noopener noreferrer" : null}"
886
+ @click="${G}"
597
887
  ><slot></slot
598
888
  ></a>
599
889
  `).done()}
600
890
  `;
601
- }), i;
891
+ }), r;
892
+ }
893
+ function dt(t, r, a) {
894
+ if (H(r)) return !1;
895
+ let o = (r.split("#")[0] || "/").split("?")[0];
896
+ if (a && a !== "/") {
897
+ const u = x(a), f = x(o);
898
+ f.startsWith(u) ? o = f.slice(u.length) || "/" : o = f;
899
+ }
900
+ const i = x(t), l = x(o);
901
+ return i === l;
902
+ }
903
+ function yt(t, r, a) {
904
+ if (H(r)) return !1;
905
+ let o = (r.split("#")[0] || "/").split("?")[0];
906
+ if (a && a !== "/") {
907
+ const u = x(a), f = x(o);
908
+ f.startsWith(u) ? o = f.slice(u.length) || "/" : o = f;
909
+ }
910
+ const i = x(t), l = x(o);
911
+ return l === "/" ? i === "/" : i === l ? !0 : i.startsWith(l.endsWith("/") ? l : l + "/");
602
912
  }
603
913
  export {
604
- bt as initRouter,
605
- M as matchRoute,
606
- vt as matchRouteSSR,
607
- k as normalizePathForRoute,
608
- Q as parseQuery,
609
- ht as resolveRouteComponent,
610
- lt as serializeQuery,
611
- pt as useRouter
914
+ C as activeRouterProxy,
915
+ zt as initRouter,
916
+ Z as matchRoute,
917
+ Nt as matchRouteSSR,
918
+ x as normalizePathForRoute,
919
+ at as parseQuery,
920
+ kt as resolveRouteComponent,
921
+ St as serializeQuery,
922
+ Pt as useRouter
612
923
  };
613
924
  //# sourceMappingURL=custom-elements-runtime.router.es.js.map