@jasonshimmy/custom-elements-runtime 2.5.1 → 2.5.5

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