@jasonshimmy/custom-elements-runtime 2.8.2 → 3.1.0

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