@i18n-micro/path-strategy 1.1.2 → 1.2.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.
package/README.md CHANGED
@@ -95,7 +95,7 @@ export default defineNuxtPlugin((nuxtApp) => {
95
95
  locales: [/* ... */],
96
96
  localizedRouteNamePrefix: 'localized-',
97
97
  router: { hasRoute, resolve },
98
- // optional: globalLocaleRoutes, routeLocales, routesLocaleLinks, noPrefixRedirect, includeDefaultLocaleRoute
98
+ // optional: globalLocaleRoutes, routeLocales, routesLocaleLinks, noPrefixRedirect
99
99
  }
100
100
 
101
101
  const pathStrategy = new Strategy(context)
@@ -155,7 +155,6 @@ Import from `@i18n-micro/path-strategy/types`.
155
155
  | `globalLocaleRoutes` | `Record<string, Record<string, string> \| false>`: custom path per route/locale; `false` = unlocalized. |
156
156
  | `routeLocales` | `Record<string, string[]>`: route path or base name → list of locale codes; limits hreflang entries. |
157
157
  | `routesLocaleLinks` | `Record<string, string>`: base name → key for `routeLocales` lookup (e.g. `'products-id'` → `'products'`). |
158
- | `includeDefaultLocaleRoute` | When set, SEO and links can include the default locale variant. |
159
158
  | `noPrefixRedirect` | When `true` (default), `NoPrefixPathStrategy.getRedirect` strips a leading locale segment (e.g. `/en/about` → `/about`). Set to `false` to disable. |
160
159
  | `debug` | Enable debug logging. |
161
160
 
@@ -1,17 +1,17 @@
1
- const nt = /#/g, lt = /&/g, it = /\//g, ct = /=/g, w = /\+/g, H = /%5e/gi, ht = /%60/gi, ut = /%7b/gi, ft = /%7c/gi, dt = /%7d/gi, pt = /%20/gi;
1
+ const nt = /#/g, lt = /&/g, it = /\//g, ct = /=/g, C = /\+/g, H = /%5e/gi, ht = /%60/gi, ut = /%7b/gi, ft = /%7c/gi, dt = /%7d/gi, pt = /%20/gi;
2
2
  function G(o) {
3
3
  return encodeURI("" + o).replace(ft, "|");
4
4
  }
5
5
  function mt(o) {
6
6
  return G(o).replace(ut, "{").replace(dt, "}").replace(H, "^");
7
7
  }
8
- function C(o) {
9
- return G(typeof o == "string" ? o : JSON.stringify(o)).replace(w, "%2B").replace(pt, "+").replace(nt, "%23").replace(lt, "%26").replace(ht, "`").replace(H, "^").replace(it, "%2F");
8
+ function w(o) {
9
+ return G(typeof o == "string" ? o : JSON.stringify(o)).replace(C, "%2B").replace(pt, "+").replace(nt, "%23").replace(lt, "%26").replace(ht, "`").replace(H, "^").replace(it, "%2F");
10
10
  }
11
- function k(o) {
12
- return C(o).replace(ct, "%3D");
11
+ function U(o) {
12
+ return w(o).replace(ct, "%3D");
13
13
  }
14
- function A(o = "") {
14
+ function F(o = "") {
15
15
  try {
16
16
  return decodeURIComponent("" + o);
17
17
  } catch {
@@ -19,10 +19,10 @@ function A(o = "") {
19
19
  }
20
20
  }
21
21
  function gt(o) {
22
- return A(o.replace(w, " "));
22
+ return F(o.replace(C, " "));
23
23
  }
24
24
  function yt(o) {
25
- return A(o.replace(w, " "));
25
+ return F(o.replace(C, " "));
26
26
  }
27
27
  function Pt(o = "") {
28
28
  const t = /* @__PURE__ */ Object.create(null);
@@ -41,21 +41,21 @@ function Pt(o = "") {
41
41
  }
42
42
  function Rt(o, t) {
43
43
  return (typeof t == "number" || typeof t == "boolean") && (t = String(t)), t ? Array.isArray(t) ? t.map(
44
- (e) => `${k(o)}=${C(e)}`
45
- ).join("&") : `${k(o)}=${C(t)}` : k(o);
44
+ (e) => `${U(o)}=${w(e)}`
45
+ ).join("&") : `${U(o)}=${w(t)}` : U(o);
46
46
  }
47
47
  function Lt(o) {
48
48
  return Object.keys(o).filter((t) => o[t] !== void 0).map((t) => Rt(t, o[t])).filter(Boolean).join("&");
49
49
  }
50
- const xt = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/, bt = /^[\s\w\0+.-]{2,}:([/\\]{2})?/, Nt = /^([/\\]\s*){2,}[^/\\]/, vt = /^\.?\//;
51
- function z(o, t = {}) {
50
+ const xt = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/, bt = /^[\s\w\0+.-]{2,}:([/\\]{2})?/, Nt = /^([/\\]\s*){2,}[^/\\]/, zt = /^\.?\//;
51
+ function v(o, t = {}) {
52
52
  return typeof t == "boolean" && (t = { acceptRelative: t }), t.strict ? xt.test(o) : bt.test(o) || (t.acceptRelative ? Nt.test(o) : !1);
53
53
  }
54
- function zt(o = "", t) {
54
+ function vt(o = "", t) {
55
55
  return o.endsWith("/");
56
56
  }
57
57
  function S(o = "", t) {
58
- return (zt(o) ? o.slice(0, -1) : o) || "/";
58
+ return (vt(o) ? o.slice(0, -1) : o) || "/";
59
59
  }
60
60
  function St(o = "", t) {
61
61
  return o.endsWith("/") ? o : o + "/";
@@ -66,42 +66,42 @@ function E(o = "") {
66
66
  function Q(o = "") {
67
67
  return (E(o) ? o.slice(1) : o) || "/";
68
68
  }
69
- function K(o = "") {
69
+ function M(o = "") {
70
70
  return E(o) ? o : "/" + o;
71
71
  }
72
- function M(o = "") {
72
+ function K(o = "") {
73
73
  return o.split("://").map((t) => t.replace(/\/{2,}/g, "/")).join("://");
74
74
  }
75
75
  function Bt(o, t) {
76
76
  const e = j(o), s = { ...Pt(e.search), ...t };
77
- return e.search = Lt(s), X(e);
77
+ return e.search = Lt(s), V(e);
78
78
  }
79
79
  function Wt(o) {
80
80
  return !o || o === "/";
81
81
  }
82
- function Ft(o) {
82
+ function At(o) {
83
83
  return o && o !== "/";
84
84
  }
85
85
  function $(o, ...t) {
86
86
  let e = o || "";
87
- for (const s of t.filter((a) => Ft(a)))
87
+ for (const s of t.filter((a) => At(a)))
88
88
  if (e) {
89
- const a = s.replace(vt, "");
89
+ const a = s.replace(zt, "");
90
90
  e = St(e) + a;
91
91
  } else
92
92
  e = s;
93
93
  return e;
94
94
  }
95
95
  function $t(o, t) {
96
- return A(S(o)) === A(S(t));
96
+ return F(S(o)) === F(S(t));
97
97
  }
98
- function At(o, t) {
98
+ function Ft(o, t) {
99
99
  if (!t || t === "#")
100
100
  return o;
101
101
  const e = j(o);
102
- return e.hash = t === "" ? "" : "#" + mt(t), X(e);
102
+ return e.hash = t === "" ? "" : "#" + mt(t), V(e);
103
103
  }
104
- const V = /* @__PURE__ */ Symbol.for("ufo:protocolRelative");
104
+ const X = /* @__PURE__ */ Symbol.for("ufo:protocolRelative");
105
105
  function j(o = "", t) {
106
106
  const e = o.match(
107
107
  /^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
@@ -118,7 +118,7 @@ function j(o = "", t) {
118
118
  hash: ""
119
119
  };
120
120
  }
121
- if (!z(o, { acceptRelative: !0 }))
121
+ if (!v(o, { acceptRelative: !0 }))
122
122
  return _(o);
123
123
  const [, s = "", a, r = ""] = o.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
124
124
  let [, n = "", l = ""] = r.match(/([^#/?]*)(.*)?/) || [];
@@ -131,7 +131,7 @@ function j(o = "", t) {
131
131
  pathname: i,
132
132
  search: h,
133
133
  hash: u,
134
- [V]: !s
134
+ [X]: !s
135
135
  };
136
136
  }
137
137
  function _(o = "") {
@@ -142,9 +142,9 @@ function _(o = "") {
142
142
  hash: s
143
143
  };
144
144
  }
145
- function X(o) {
145
+ function V(o) {
146
146
  const t = o.pathname || "", e = o.search ? (o.search.startsWith("?") ? "" : "?") + o.search : "", s = o.hash || "", a = o.auth ? o.auth + "@" : "", r = o.host || "";
147
- return (o.protocol || o[V] ? (o.protocol || "") + "//" : "") + a + r + t + e + s;
147
+ return (o.protocol || o[X] ? (o.protocol || "") + "//" : "") + a + r + t + e + s;
148
148
  }
149
149
  const _t = /\/([^/]+)$/;
150
150
  function Et(o = "", t) {
@@ -154,16 +154,16 @@ function Et(o = "", t) {
154
154
  function D(o) {
155
155
  return (_(o.startsWith("/") ? o : `/${o}`).pathname || "").split("/").filter(Boolean);
156
156
  }
157
- const P = (o) => Wt(o ?? "") ? "/" : K(S(M(o))) || "/";
157
+ const P = (o) => Wt(o ?? "") ? "/" : M(S(K(o))) || "/";
158
158
  function jt(o) {
159
- const t = M(o || "/");
159
+ const t = K(o || "/");
160
160
  return S(t) || "/";
161
161
  }
162
162
  function y(...o) {
163
163
  const t = o.filter((r) => typeof r == "string" && r !== "");
164
164
  if (t.length === 0) return "/";
165
165
  const [e, ...s] = t, a = $(e, ...s) || "/";
166
- return z(a) ? a : K(a);
166
+ return v(a) ? a : M(a);
167
167
  }
168
168
  function J(o) {
169
169
  return o && _(o).pathname || "";
@@ -172,7 +172,7 @@ function T(o, t, e) {
172
172
  let s = Bt(o, t ?? {});
173
173
  if (e && e !== "#") {
174
174
  const a = e.startsWith("#") ? e.slice(1) : e;
175
- s = At(s, a);
175
+ s = Ft(s, a);
176
176
  }
177
177
  return s;
178
178
  }
@@ -216,7 +216,7 @@ function tt(o, t) {
216
216
  }
217
217
  return { pathWithoutLocale: s, localeFromPath: null };
218
218
  }
219
- function Ut(o, t) {
219
+ function kt(o, t) {
220
220
  const e = J(o);
221
221
  if (e === "/" || e === "" || !E(e)) return null;
222
222
  const s = e.indexOf("/", 1), a = s === -1 ? e.slice(1) : e.slice(1, s);
@@ -235,7 +235,7 @@ function et(o, t) {
235
235
  }
236
236
  return a;
237
237
  }
238
- function kt(o, t, e = "localized-") {
238
+ function Ut(o, t, e = "localized-") {
239
239
  return `${e}${o}-${t}`;
240
240
  }
241
241
  function I(o, t) {
@@ -247,26 +247,22 @@ function I(o, t) {
247
247
  const n = e.slice(r.length);
248
248
  return a.length === 0 ? n.length >= 2 : a.includes(n);
249
249
  }
250
- function Ct(o) {
251
- return o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
252
- }
253
- class wt {
250
+ const wt = /:(\w+)\(\)|:(\w+)(?!\w)|\[\.\.\.(\w+)\]/g;
251
+ class Ct {
254
252
  constructor(t) {
255
253
  this.ctx = t;
256
254
  }
257
255
  /**
258
256
  * Substitutes params into path template (:key, :key(), [...key]).
259
- * Uses one combined regex per key to avoid creating multiple RegExp in a loop.
257
+ * Uses a single pre-compiled regex for all keys in one pass no per-key RegExp allocation.
260
258
  */
261
259
  resolvePathWithParams(t, e = {}) {
262
- let s = t;
263
- for (const a in e) {
264
- const r = e[a];
265
- if (r == null || r === "") continue;
266
- const n = Array.isArray(r) ? r.join("/") : String(r), l = Ct(a), i = new RegExp(`:${l}\\(\\)|:${l}(?![\\w])|\\[\\.\\.\\.${l}\\]`, "g");
267
- s = s.replace(i, n);
268
- }
269
- return s;
260
+ return !e || Object.keys(e).length === 0 ? t : t.replace(wt, (s, a, r, n) => {
261
+ const l = a || r || n;
262
+ if (!l) return s;
263
+ const i = e[l];
264
+ return i == null || i === "" ? s : Array.isArray(i) ? i.join("/") : String(i);
265
+ });
270
266
  }
271
267
  /**
272
268
  * Analyzes route: path without locale and base name (normalizer + route-name).
@@ -382,7 +378,7 @@ class wt {
382
378
  }
383
379
  class Qt {
384
380
  constructor(t) {
385
- this.ctx = t, this.resolver = new wt(t);
381
+ this.ctx = t, this.resolver = new Ct(t);
386
382
  }
387
383
  setRouter(t) {
388
384
  this.ctx.router = t;
@@ -438,15 +434,15 @@ class Qt {
438
434
  return P(a || t);
439
435
  }
440
436
  buildLocalizedName(t, e) {
441
- return kt(t, e, this.getLocalizedRouteNamePrefix());
437
+ return Ut(t, e, this.getLocalizedRouteNamePrefix());
442
438
  }
443
439
  getLocaleObject(t) {
444
440
  return this.ctx.locales.find((e) => e.code === t);
445
441
  }
446
442
  applyBaseUrl(t, e) {
447
443
  if (typeof e == "string") {
448
- if (z(e)) return e;
449
- } else if (e.path && z(e.path))
444
+ if (v(e)) return e;
445
+ } else if (e.path && v(e.path))
450
446
  return e;
451
447
  const s = this.getLocaleObject(t);
452
448
  if (!s?.baseUrl)
@@ -457,7 +453,7 @@ class Qt {
457
453
  return y(a, l);
458
454
  }
459
455
  const r = P(e.path || ""), n = y(a, r);
460
- return z(n) ? n : {
456
+ return v(n) ? n : {
461
457
  ...e,
462
458
  path: n,
463
459
  fullPath: n
@@ -605,7 +601,7 @@ class Qt {
605
601
  );
606
602
  }
607
603
  getLocaleFromPath(t) {
608
- return Ut(
604
+ return kt(
609
605
  t,
610
606
  this.ctx.locales.map((e) => e.code)
611
607
  );
@@ -786,14 +782,14 @@ class Qt {
786
782
  const d = this.getCustomPathSegment(n, t);
787
783
  if (d !== null) {
788
784
  const c = n.name?.toString() ?? a ?? "", f = c ? Y(c) : "", p = c ? Z(c) : "", m = this.ctx.globalLocaleRoutes, N = f.includes("/") && m?.[f], x = p.includes("/") && m?.[p], st = N || x, at = x ? p : f;
789
- let F;
785
+ let A;
790
786
  if (st) {
791
- const U = D(at), v = U.length > 1 ? U.slice(0, -1).join("-") : "", O = v && m?.[v] && typeof m[v] == "object" && !Array.isArray(m[v]) ? m[v] : null, ot = O?.[t] ? P(O[t]) : y("/", ...U.slice(0, -1)), rt = d.startsWith("/") ? d.slice(1) : d;
792
- F = y(ot, rt);
787
+ const k = D(at), z = k.length > 1 ? k.slice(0, -1).join("-") : "", O = z && m?.[z] && typeof m[z] == "object" && !Array.isArray(m[z]) ? m[z] : null, ot = O?.[t] ? P(O[t]) : y("/", ...k.slice(0, -1)), rt = d.startsWith("/") ? d.slice(1) : d;
788
+ A = y(ot, rt);
793
789
  } else
794
- F = P(d);
795
- const q = this.buildLocalizedPath(F, t, !0);
796
- return this.debugLog("branch=customSegment", { customSegment: d, pathWithoutLocale: F, finalPath: q }), this.preserveQueryAndHash(this.applyBaseUrl(t, q), r);
790
+ A = P(d);
791
+ const q = this.buildLocalizedPath(A, t, !0);
792
+ return this.debugLog("branch=customSegment", { customSegment: d, pathWithoutLocale: A, finalPath: q }), this.preserveQueryAndHash(this.applyBaseUrl(t, q), r);
797
793
  }
798
794
  const g = i ?? a;
799
795
  if (this.debugLog("before effectiveBaseName check", { baseName: i, inputName: a, effectiveBaseName: g, resolvedName: n.name?.toString() }), !g)
@@ -883,11 +879,11 @@ class Qt {
883
879
  }
884
880
  /**
885
881
  * Returns the route name for plugin translation loading.
886
- * If disablePageLocales is true, returns 'general'.
882
+ * If disablePageLocales is true, returns 'index'.
887
883
  */
888
884
  getPluginRouteName(t, e) {
889
885
  if (this.ctx.disablePageLocales)
890
- return "general";
886
+ return "index";
891
887
  const s = this.getRouteBaseName(t);
892
888
  return s || (t.name ?? "").toString().replace(this.getLocalizedRouteNamePrefix(), "").replace(new RegExp(`-${e}$`), "");
893
889
  }
@@ -901,26 +897,26 @@ class Qt {
901
897
  }
902
898
  export {
903
899
  Qt as B,
904
- wt as R,
900
+ Ct as R,
905
901
  jt as a,
906
902
  Z as b,
907
- M as c,
903
+ K as c,
908
904
  I as d,
909
905
  Y as e,
910
906
  D as f,
911
907
  J as g,
912
- K as h,
908
+ M as h,
913
909
  $t as i,
914
910
  y as j,
915
911
  T as k,
916
912
  Ot as l,
917
- kt as m,
913
+ Ut as m,
918
914
  P as n,
919
- Ut as o,
915
+ kt as o,
920
916
  qt as p,
921
917
  tt as q,
922
918
  et as r,
923
919
  b as t,
924
920
  Q as w
925
921
  };
926
- //# sourceMappingURL=base-strategy-Cf39XK8k.js.map
922
+ //# sourceMappingURL=base-strategy-DDkINDnZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-strategy-DDkINDnZ.js","sources":["../../../node_modules/.pnpm/ufo@1.6.1/node_modules/ufo/dist/index.mjs","../src/utils/path.ts","../src/core/normalizer.ts","../src/utils/route-name.ts","../src/core/resolver.ts","../src/strategies/base-strategy.ts"],"sourcesContent":["const n = /[^\\0-\\x7E]/;\nconst t = /[\\x2E\\u3002\\uFF0E\\uFF61]/g;\nconst o = {\n overflow: \"Overflow Error\",\n \"not-basic\": \"Illegal Input\",\n \"invalid-input\": \"Invalid Input\"\n};\nconst e = Math.floor;\nconst r = String.fromCharCode;\nfunction s(n2) {\n throw new RangeError(o[n2]);\n}\nconst c = function(n2, t2) {\n return n2 + 22 + 75 * (n2 < 26) - ((t2 != 0) << 5);\n};\nconst u = function(n2, t2, o2) {\n let r2 = 0;\n for (n2 = o2 ? e(n2 / 700) : n2 >> 1, n2 += e(n2 / t2); n2 > 455; r2 += 36) {\n n2 = e(n2 / 35);\n }\n return e(r2 + 36 * n2 / (n2 + 38));\n};\nfunction toASCII(o2) {\n return function(n2, o3) {\n const e2 = n2.split(\"@\");\n let r2 = \"\";\n e2.length > 1 && (r2 = e2[0] + \"@\", n2 = e2[1]);\n const s2 = function(n3, t2) {\n const o4 = [];\n let e3 = n3.length;\n for (; e3--; ) {\n o4[e3] = t2(n3[e3]);\n }\n return o4;\n }((n2 = n2.replace(t, \".\")).split(\".\"), o3).join(\".\");\n return r2 + s2;\n }(o2, function(t2) {\n return n.test(t2) ? \"xn--\" + function(n2) {\n const t3 = [];\n const o3 = (n2 = function(n3) {\n const t4 = [];\n let o4 = 0;\n const e2 = n3.length;\n for (; o4 < e2; ) {\n const r2 = n3.charCodeAt(o4++);\n if (r2 >= 55296 && r2 <= 56319 && o4 < e2) {\n const e3 = n3.charCodeAt(o4++);\n (64512 & e3) == 56320 ? t4.push(((1023 & r2) << 10) + (1023 & e3) + 65536) : (t4.push(r2), o4--);\n } else {\n t4.push(r2);\n }\n }\n return t4;\n }(n2)).length;\n let f = 128;\n let i = 0;\n let l = 72;\n for (const o4 of n2) {\n o4 < 128 && t3.push(r(o4));\n }\n const h = t3.length;\n let p = h;\n for (h && t3.push(\"-\"); p < o3; ) {\n let o4 = 2147483647;\n for (const t4 of n2) {\n t4 >= f && t4 < o4 && (o4 = t4);\n }\n const a = p + 1;\n o4 - f > e((2147483647 - i) / a) && s(\"overflow\"), i += (o4 - f) * a, f = o4;\n for (const o5 of n2) {\n if (o5 < f && ++i > 2147483647 && s(\"overflow\"), o5 == f) {\n let n3 = i;\n for (let o6 = 36; ; o6 += 36) {\n const s2 = o6 <= l ? 1 : o6 >= l + 26 ? 26 : o6 - l;\n if (n3 < s2) {\n break;\n }\n const u2 = n3 - s2;\n const f2 = 36 - s2;\n t3.push(r(c(s2 + u2 % f2, 0))), n3 = e(u2 / f2);\n }\n t3.push(r(c(n3, 0))), l = u(i, a, p == h), i = 0, ++p;\n }\n }\n ++i, ++f;\n }\n return t3.join(\"\");\n }(t2) : t2;\n });\n}\n\nconst HASH_RE = /#/g;\nconst AMPERSAND_RE = /&/g;\nconst SLASH_RE = /\\//g;\nconst EQUAL_RE = /=/g;\nconst IM_RE = /\\?/g;\nconst PLUS_RE = /\\+/g;\nconst ENC_CARET_RE = /%5e/gi;\nconst ENC_BACKTICK_RE = /%60/gi;\nconst ENC_CURLY_OPEN_RE = /%7b/gi;\nconst ENC_PIPE_RE = /%7c/gi;\nconst ENC_CURLY_CLOSE_RE = /%7d/gi;\nconst ENC_SPACE_RE = /%20/gi;\nconst ENC_SLASH_RE = /%2f/gi;\nconst ENC_ENC_SLASH_RE = /%252f/gi;\nfunction encode(text) {\n return encodeURI(\"\" + text).replace(ENC_PIPE_RE, \"|\");\n}\nfunction encodeHash(text) {\n return encode(text).replace(ENC_CURLY_OPEN_RE, \"{\").replace(ENC_CURLY_CLOSE_RE, \"}\").replace(ENC_CARET_RE, \"^\");\n}\nfunction encodeQueryValue(input) {\n return encode(typeof input === \"string\" ? input : JSON.stringify(input)).replace(PLUS_RE, \"%2B\").replace(ENC_SPACE_RE, \"+\").replace(HASH_RE, \"%23\").replace(AMPERSAND_RE, \"%26\").replace(ENC_BACKTICK_RE, \"`\").replace(ENC_CARET_RE, \"^\").replace(SLASH_RE, \"%2F\");\n}\nfunction encodeQueryKey(text) {\n return encodeQueryValue(text).replace(EQUAL_RE, \"%3D\");\n}\nfunction encodePath(text) {\n return encode(text).replace(HASH_RE, \"%23\").replace(IM_RE, \"%3F\").replace(ENC_ENC_SLASH_RE, \"%2F\").replace(AMPERSAND_RE, \"%26\").replace(PLUS_RE, \"%2B\");\n}\nfunction encodeParam(text) {\n return encodePath(text).replace(SLASH_RE, \"%2F\");\n}\nfunction decode(text = \"\") {\n try {\n return decodeURIComponent(\"\" + text);\n } catch {\n return \"\" + text;\n }\n}\nfunction decodePath(text) {\n return decode(text.replace(ENC_SLASH_RE, \"%252F\"));\n}\nfunction decodeQueryKey(text) {\n return decode(text.replace(PLUS_RE, \" \"));\n}\nfunction decodeQueryValue(text) {\n return decode(text.replace(PLUS_RE, \" \"));\n}\nfunction encodeHost(name = \"\") {\n return toASCII(name);\n}\n\nfunction parseQuery(parametersString = \"\") {\n const object = /* @__PURE__ */ Object.create(null);\n if (parametersString[0] === \"?\") {\n parametersString = parametersString.slice(1);\n }\n for (const parameter of parametersString.split(\"&\")) {\n const s = parameter.match(/([^=]+)=?(.*)/) || [];\n if (s.length < 2) {\n continue;\n }\n const key = decodeQueryKey(s[1]);\n if (key === \"__proto__\" || key === \"constructor\") {\n continue;\n }\n const value = decodeQueryValue(s[2] || \"\");\n if (object[key] === void 0) {\n object[key] = value;\n } else if (Array.isArray(object[key])) {\n object[key].push(value);\n } else {\n object[key] = [object[key], value];\n }\n }\n return object;\n}\nfunction encodeQueryItem(key, value) {\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n value = String(value);\n }\n if (!value) {\n return encodeQueryKey(key);\n }\n if (Array.isArray(value)) {\n return value.map(\n (_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`\n ).join(\"&\");\n }\n return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;\n}\nfunction stringifyQuery(query) {\n return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join(\"&\");\n}\n\nconst PROTOCOL_STRICT_REGEX = /^[\\s\\w\\0+.-]{2,}:([/\\\\]{1,2})/;\nconst PROTOCOL_REGEX = /^[\\s\\w\\0+.-]{2,}:([/\\\\]{2})?/;\nconst PROTOCOL_RELATIVE_REGEX = /^([/\\\\]\\s*){2,}[^/\\\\]/;\nconst PROTOCOL_SCRIPT_RE = /^[\\s\\0]*(blob|data|javascript|vbscript):$/i;\nconst TRAILING_SLASH_RE = /\\/$|\\/\\?|\\/#/;\nconst JOIN_LEADING_SLASH_RE = /^\\.?\\//;\nfunction isRelative(inputString) {\n return [\"./\", \"../\"].some((string_) => inputString.startsWith(string_));\n}\nfunction hasProtocol(inputString, opts = {}) {\n if (typeof opts === \"boolean\") {\n opts = { acceptRelative: opts };\n }\n if (opts.strict) {\n return PROTOCOL_STRICT_REGEX.test(inputString);\n }\n return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);\n}\nfunction isScriptProtocol(protocol) {\n return !!protocol && PROTOCOL_SCRIPT_RE.test(protocol);\n}\nfunction hasTrailingSlash(input = \"\", respectQueryAndFragment) {\n if (!respectQueryAndFragment) {\n return input.endsWith(\"/\");\n }\n return TRAILING_SLASH_RE.test(input);\n}\nfunction withoutTrailingSlash(input = \"\", respectQueryAndFragment) {\n if (!respectQueryAndFragment) {\n return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || \"/\";\n }\n if (!hasTrailingSlash(input, true)) {\n return input || \"/\";\n }\n let path = input;\n let fragment = \"\";\n const fragmentIndex = input.indexOf(\"#\");\n if (fragmentIndex !== -1) {\n path = input.slice(0, fragmentIndex);\n fragment = input.slice(fragmentIndex);\n }\n const [s0, ...s] = path.split(\"?\");\n const cleanPath = s0.endsWith(\"/\") ? s0.slice(0, -1) : s0;\n return (cleanPath || \"/\") + (s.length > 0 ? `?${s.join(\"?\")}` : \"\") + fragment;\n}\nfunction withTrailingSlash(input = \"\", respectQueryAndFragment) {\n if (!respectQueryAndFragment) {\n return input.endsWith(\"/\") ? input : input + \"/\";\n }\n if (hasTrailingSlash(input, true)) {\n return input || \"/\";\n }\n let path = input;\n let fragment = \"\";\n const fragmentIndex = input.indexOf(\"#\");\n if (fragmentIndex !== -1) {\n path = input.slice(0, fragmentIndex);\n fragment = input.slice(fragmentIndex);\n if (!path) {\n return fragment;\n }\n }\n const [s0, ...s] = path.split(\"?\");\n return s0 + \"/\" + (s.length > 0 ? `?${s.join(\"?\")}` : \"\") + fragment;\n}\nfunction hasLeadingSlash(input = \"\") {\n return input.startsWith(\"/\");\n}\nfunction withoutLeadingSlash(input = \"\") {\n return (hasLeadingSlash(input) ? input.slice(1) : input) || \"/\";\n}\nfunction withLeadingSlash(input = \"\") {\n return hasLeadingSlash(input) ? input : \"/\" + input;\n}\nfunction cleanDoubleSlashes(input = \"\") {\n return input.split(\"://\").map((string_) => string_.replace(/\\/{2,}/g, \"/\")).join(\"://\");\n}\nfunction withBase(input, base) {\n if (isEmptyURL(base) || hasProtocol(input)) {\n return input;\n }\n const _base = withoutTrailingSlash(base);\n if (input.startsWith(_base)) {\n return input;\n }\n return joinURL(_base, input);\n}\nfunction withoutBase(input, base) {\n if (isEmptyURL(base)) {\n return input;\n }\n const _base = withoutTrailingSlash(base);\n if (!input.startsWith(_base)) {\n return input;\n }\n const trimmed = input.slice(_base.length);\n return trimmed[0] === \"/\" ? trimmed : \"/\" + trimmed;\n}\nfunction withQuery(input, query) {\n const parsed = parseURL(input);\n const mergedQuery = { ...parseQuery(parsed.search), ...query };\n parsed.search = stringifyQuery(mergedQuery);\n return stringifyParsedURL(parsed);\n}\nfunction filterQuery(input, predicate) {\n if (!input.includes(\"?\")) {\n return input;\n }\n const parsed = parseURL(input);\n const query = parseQuery(parsed.search);\n const filteredQuery = Object.fromEntries(\n Object.entries(query).filter(([key, value]) => predicate(key, value))\n );\n parsed.search = stringifyQuery(filteredQuery);\n return stringifyParsedURL(parsed);\n}\nfunction getQuery(input) {\n return parseQuery(parseURL(input).search);\n}\nfunction isEmptyURL(url) {\n return !url || url === \"/\";\n}\nfunction isNonEmptyURL(url) {\n return url && url !== \"/\";\n}\nfunction joinURL(base, ...input) {\n let url = base || \"\";\n for (const segment of input.filter((url2) => isNonEmptyURL(url2))) {\n if (url) {\n const _segment = segment.replace(JOIN_LEADING_SLASH_RE, \"\");\n url = withTrailingSlash(url) + _segment;\n } else {\n url = segment;\n }\n }\n return url;\n}\nfunction joinRelativeURL(..._input) {\n const JOIN_SEGMENT_SPLIT_RE = /\\/(?!\\/)/;\n const input = _input.filter(Boolean);\n const segments = [];\n let segmentsDepth = 0;\n for (const i of input) {\n if (!i || i === \"/\") {\n continue;\n }\n for (const [sindex, s] of i.split(JOIN_SEGMENT_SPLIT_RE).entries()) {\n if (!s || s === \".\") {\n continue;\n }\n if (s === \"..\") {\n if (segments.length === 1 && hasProtocol(segments[0])) {\n continue;\n }\n segments.pop();\n segmentsDepth--;\n continue;\n }\n if (sindex === 1 && segments[segments.length - 1]?.endsWith(\":/\")) {\n segments[segments.length - 1] += \"/\" + s;\n continue;\n }\n segments.push(s);\n segmentsDepth++;\n }\n }\n let url = segments.join(\"/\");\n if (segmentsDepth >= 0) {\n if (input[0]?.startsWith(\"/\") && !url.startsWith(\"/\")) {\n url = \"/\" + url;\n } else if (input[0]?.startsWith(\"./\") && !url.startsWith(\"./\")) {\n url = \"./\" + url;\n }\n } else {\n url = \"../\".repeat(-1 * segmentsDepth) + url;\n }\n if (input[input.length - 1]?.endsWith(\"/\") && !url.endsWith(\"/\")) {\n url += \"/\";\n }\n return url;\n}\nfunction withHttp(input) {\n return withProtocol(input, \"http://\");\n}\nfunction withHttps(input) {\n return withProtocol(input, \"https://\");\n}\nfunction withoutProtocol(input) {\n return withProtocol(input, \"\");\n}\nfunction withProtocol(input, protocol) {\n let match = input.match(PROTOCOL_REGEX);\n if (!match) {\n match = input.match(/^\\/{2,}/);\n }\n if (!match) {\n return protocol + input;\n }\n return protocol + input.slice(match[0].length);\n}\nfunction normalizeURL(input) {\n const parsed = parseURL(input);\n parsed.pathname = encodePath(decodePath(parsed.pathname));\n parsed.hash = encodeHash(decode(parsed.hash));\n parsed.host = encodeHost(decode(parsed.host));\n parsed.search = stringifyQuery(parseQuery(parsed.search));\n return stringifyParsedURL(parsed);\n}\nfunction resolveURL(base = \"\", ...inputs) {\n if (typeof base !== \"string\") {\n throw new TypeError(\n `URL input should be string received ${typeof base} (${base})`\n );\n }\n const filteredInputs = inputs.filter((input) => isNonEmptyURL(input));\n if (filteredInputs.length === 0) {\n return base;\n }\n const url = parseURL(base);\n for (const inputSegment of filteredInputs) {\n const urlSegment = parseURL(inputSegment);\n if (urlSegment.pathname) {\n url.pathname = withTrailingSlash(url.pathname) + withoutLeadingSlash(urlSegment.pathname);\n }\n if (urlSegment.hash && urlSegment.hash !== \"#\") {\n url.hash = urlSegment.hash;\n }\n if (urlSegment.search && urlSegment.search !== \"?\") {\n if (url.search && url.search !== \"?\") {\n const queryString = stringifyQuery({\n ...parseQuery(url.search),\n ...parseQuery(urlSegment.search)\n });\n url.search = queryString.length > 0 ? \"?\" + queryString : \"\";\n } else {\n url.search = urlSegment.search;\n }\n }\n }\n return stringifyParsedURL(url);\n}\nfunction isSamePath(p1, p2) {\n return decode(withoutTrailingSlash(p1)) === decode(withoutTrailingSlash(p2));\n}\nfunction isEqual(a, b, options = {}) {\n if (!options.trailingSlash) {\n a = withTrailingSlash(a);\n b = withTrailingSlash(b);\n }\n if (!options.leadingSlash) {\n a = withLeadingSlash(a);\n b = withLeadingSlash(b);\n }\n if (!options.encoding) {\n a = decode(a);\n b = decode(b);\n }\n return a === b;\n}\nfunction withFragment(input, hash) {\n if (!hash || hash === \"#\") {\n return input;\n }\n const parsed = parseURL(input);\n parsed.hash = hash === \"\" ? \"\" : \"#\" + encodeHash(hash);\n return stringifyParsedURL(parsed);\n}\nfunction withoutFragment(input) {\n return stringifyParsedURL({ ...parseURL(input), hash: \"\" });\n}\nfunction withoutHost(input) {\n const parsed = parseURL(input);\n return (parsed.pathname || \"/\") + parsed.search + parsed.hash;\n}\n\nconst protocolRelative = Symbol.for(\"ufo:protocolRelative\");\nfunction parseURL(input = \"\", defaultProto) {\n const _specialProtoMatch = input.match(\n /^[\\s\\0]*(blob:|data:|javascript:|vbscript:)(.*)/i\n );\n if (_specialProtoMatch) {\n const [, _proto, _pathname = \"\"] = _specialProtoMatch;\n return {\n protocol: _proto.toLowerCase(),\n pathname: _pathname,\n href: _proto + _pathname,\n auth: \"\",\n host: \"\",\n search: \"\",\n hash: \"\"\n };\n }\n if (!hasProtocol(input, { acceptRelative: true })) {\n return defaultProto ? parseURL(defaultProto + input) : parsePath(input);\n }\n const [, protocol = \"\", auth, hostAndPath = \"\"] = input.replace(/\\\\/g, \"/\").match(/^[\\s\\0]*([\\w+.-]{2,}:)?\\/\\/([^/@]+@)?(.*)/) || [];\n let [, host = \"\", path = \"\"] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];\n if (protocol === \"file:\") {\n path = path.replace(/\\/(?=[A-Za-z]:)/, \"\");\n }\n const { pathname, search, hash } = parsePath(path);\n return {\n protocol: protocol.toLowerCase(),\n auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : \"\",\n host,\n pathname,\n search,\n hash,\n [protocolRelative]: !protocol\n };\n}\nfunction parsePath(input = \"\") {\n const [pathname = \"\", search = \"\", hash = \"\"] = (input.match(/([^#?]*)(\\?[^#]*)?(#.*)?/) || []).splice(1);\n return {\n pathname,\n search,\n hash\n };\n}\nfunction parseAuth(input = \"\") {\n const [username, password] = input.split(\":\");\n return {\n username: decode(username),\n password: decode(password)\n };\n}\nfunction parseHost(input = \"\") {\n const [hostname, port] = (input.match(/([^/:]*):?(\\d+)?/) || []).splice(1);\n return {\n hostname: decode(hostname),\n port\n };\n}\nfunction stringifyParsedURL(parsed) {\n const pathname = parsed.pathname || \"\";\n const search = parsed.search ? (parsed.search.startsWith(\"?\") ? \"\" : \"?\") + parsed.search : \"\";\n const hash = parsed.hash || \"\";\n const auth = parsed.auth ? parsed.auth + \"@\" : \"\";\n const host = parsed.host || \"\";\n const proto = parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || \"\") + \"//\" : \"\";\n return proto + auth + host + pathname + search + hash;\n}\nconst FILENAME_STRICT_REGEX = /\\/([^/]+\\.[^/]+)$/;\nconst FILENAME_REGEX = /\\/([^/]+)$/;\nfunction parseFilename(input = \"\", opts) {\n const { pathname } = parseURL(input);\n const matches = opts?.strict ? pathname.match(FILENAME_STRICT_REGEX) : pathname.match(FILENAME_REGEX);\n return matches ? matches[1] : void 0;\n}\n\nclass $URL {\n protocol;\n host;\n auth;\n pathname;\n query = {};\n hash;\n constructor(input = \"\") {\n if (typeof input !== \"string\") {\n throw new TypeError(\n `URL input should be string received ${typeof input} (${input})`\n );\n }\n const parsed = parseURL(input);\n this.protocol = decode(parsed.protocol);\n this.host = decode(parsed.host);\n this.auth = decode(parsed.auth);\n this.pathname = decodePath(parsed.pathname);\n this.query = parseQuery(parsed.search);\n this.hash = decode(parsed.hash);\n }\n get hostname() {\n return parseHost(this.host).hostname;\n }\n get port() {\n return parseHost(this.host).port || \"\";\n }\n get username() {\n return parseAuth(this.auth).username;\n }\n get password() {\n return parseAuth(this.auth).password || \"\";\n }\n get hasProtocol() {\n return this.protocol.length;\n }\n get isAbsolute() {\n return this.hasProtocol || this.pathname[0] === \"/\";\n }\n get search() {\n const q = stringifyQuery(this.query);\n return q.length > 0 ? \"?\" + q : \"\";\n }\n get searchParams() {\n const p = new URLSearchParams();\n for (const name in this.query) {\n const value = this.query[name];\n if (Array.isArray(value)) {\n for (const v of value) {\n p.append(name, v);\n }\n } else {\n p.append(\n name,\n typeof value === \"string\" ? value : JSON.stringify(value)\n );\n }\n }\n return p;\n }\n get origin() {\n return (this.protocol ? this.protocol + \"//\" : \"\") + encodeHost(this.host);\n }\n get fullpath() {\n return encodePath(this.pathname) + this.search + encodeHash(this.hash);\n }\n get encodedAuth() {\n if (!this.auth) {\n return \"\";\n }\n const { username, password } = parseAuth(this.auth);\n return encodeURIComponent(username) + (password ? \":\" + encodeURIComponent(password) : \"\");\n }\n get href() {\n const auth = this.encodedAuth;\n const originWithAuth = (this.protocol ? this.protocol + \"//\" : \"\") + (auth ? auth + \"@\" : \"\") + encodeHost(this.host);\n return this.hasProtocol && this.isAbsolute ? originWithAuth + this.fullpath : this.fullpath;\n }\n append(url) {\n if (url.hasProtocol) {\n throw new Error(\"Cannot append a URL with protocol\");\n }\n Object.assign(this.query, url.query);\n if (url.pathname) {\n this.pathname = withTrailingSlash(this.pathname) + withoutLeadingSlash(url.pathname);\n }\n if (url.hash) {\n this.hash = url.hash;\n }\n }\n toJSON() {\n return this.href;\n }\n toString() {\n return this.href;\n }\n}\nfunction createURL(input) {\n return new $URL(input);\n}\n\nexport { $URL, cleanDoubleSlashes, createURL, decode, decodePath, decodeQueryKey, decodeQueryValue, encode, encodeHash, encodeHost, encodeParam, encodePath, encodeQueryItem, encodeQueryKey, encodeQueryValue, filterQuery, getQuery, hasLeadingSlash, hasProtocol, hasTrailingSlash, isEmptyURL, isEqual, isNonEmptyURL, isRelative, isSamePath, isScriptProtocol, joinRelativeURL, joinURL, normalizeURL, parseAuth, parseFilename, parseHost, parsePath, parseQuery, parseURL, resolveURL, stringifyParsedURL, stringifyQuery, withBase, withFragment, withHttp, withHttps, withLeadingSlash, withProtocol, withQuery, withTrailingSlash, withoutBase, withoutFragment, withoutHost, withoutLeadingSlash, withoutProtocol, withoutTrailingSlash };\n","/**\n * Path utilities: delegate to ufo for URL/paths; custom logic only for route names (kebab/slash).\n */\nimport type { QueryObject } from 'ufo'\nimport {\n cleanDoubleSlashes,\n hasProtocol,\n isEmptyURL,\n joinURL,\n parseFilename,\n parsePath,\n withFragment,\n withLeadingSlash,\n withoutTrailingSlash,\n withQuery,\n} from 'ufo'\n\n/** Path segments without leading/repeated slashes (ufo parsePath.pathname). */\nexport function getPathSegments(pathOrSlashKey: string): string[] {\n const pathname = parsePath(pathOrSlashKey.startsWith('/') ? pathOrSlashKey : `/${pathOrSlashKey}`).pathname || ''\n return pathname.split('/').filter(Boolean)\n}\n\nexport const normalizePath = (p: string): string => {\n if (isEmptyURL(p ?? '')) return '/'\n return withLeadingSlash(withoutTrailingSlash(cleanDoubleSlashes(p))) || '/'\n}\n\n/** Path for comparison: collapse slashes, remove trailing slash, empty -> '/'. */\nexport function normalizePathForCompare(p: string): string {\n const collapsed = cleanDoubleSlashes(p || '/')\n const trimmed = withoutTrailingSlash(collapsed)\n return trimmed || '/'\n}\n\n/**\n * Join URL segments (ufo handles protocols and slashes correctly).\n * For path-style (no protocol) result always has leading slash.\n */\nexport function joinUrl(...segments: (string | undefined | null)[]): string {\n const valid = segments.filter((s): s is string => typeof s === 'string' && s !== '')\n if (valid.length === 0) return '/'\n const [base, ...rest] = valid\n const joined = joinURL(base!, ...rest) || '/'\n if (hasProtocol(joined)) return joined\n return withLeadingSlash(joined)\n}\n\n/**\n * Safely strips query and hash from path (ufo parsePath).\n * /news?id=1#top -> /news\n */\nexport function getCleanPath(path: string | null | undefined): string {\n if (!path) return ''\n const parsed = parsePath(path)\n return parsed.pathname || ''\n}\n\n/**\n * Builds full URL from path, query and hash (ufo withQuery + withFragment).\n */\nexport function buildUrl(path: string, query?: Record<string, unknown>, hash?: string): string {\n let url = withQuery(path, (query ?? {}) as QueryObject)\n if (hash && hash !== '#') {\n const fragment = hash.startsWith('#') ? hash.slice(1) : hash\n url = withFragment(url, fragment)\n }\n return url\n}\n\n/**\n * Parent path. /a/b/c -> /a/b, /a -> /, / -> null\n */\nexport function getParentPath(routePath: string): string | null {\n const segments = getPathSegments(routePath)\n if (segments.length === 0) return null\n if (segments.length <= 1) return '/'\n return joinUrl('/', ...segments.slice(0, -1))\n}\n\n/**\n * kebab -> path key: activity-skiing-locale -> activity/skiing/locale\n */\nexport function transformNameKeyToPath(nameKey: string): string {\n if (!nameKey) return ''\n let out = ''\n for (let i = 0; i < nameKey.length; i++) {\n out += nameKey[i] === '-' ? '/' : nameKey[i]\n }\n return out\n}\n\n/** First hyphen -> slash: activity-skiing-locale -> activity/skiing-locale */\nexport function nameKeyFirstSlash(nameKey: string): string {\n if (!nameKey) return ''\n const idx = nameKey.indexOf('-')\n return idx === -1 ? nameKey : joinURL(nameKey.slice(0, idx), nameKey.slice(idx + 1))\n}\n\n/** Last hyphen -> slash: activity-locale-skiing -> activity-locale/skiing */\nexport function nameKeyLastSlash(nameKey: string): string {\n if (!nameKey) return ''\n const idx = nameKey.lastIndexOf('-')\n return idx === -1 ? nameKey : joinURL(nameKey.slice(0, idx), nameKey.slice(idx + 1))\n}\n\n/** Parent key from slash-key: activity-locale/hiking -> activity-locale; a/b/c -> a-b */\nexport function parentKeyFromSlashKey(keyWithSlash: string): string {\n const segments = getPathSegments(keyWithSlash)\n return segments.length > 1 ? segments.slice(0, -1).join('-') : ''\n}\n\n/** Last path segment: /change-activity/hiking -> hiking (ufo parseFilename). */\nexport function lastPathSegment(path: string): string {\n return parseFilename(path || '/') ?? ''\n}\n","/**\n * Path normalization: extract locale from path and pathWithoutLocale (ufo getCleanPath, hasLeadingSlash).\n */\nimport { hasLeadingSlash } from 'ufo'\nimport { getCleanPath, normalizePath } from '../utils/path'\n\nexport interface PathWithoutLocaleResult {\n pathWithoutLocale: string\n localeFromPath: string | null\n}\n\n/**\n * Parses path: if first segment is a known locale, returns path without it and locale code.\n */\nexport function getPathWithoutLocale(path: string, localeCodes: string[]): PathWithoutLocaleResult {\n const clean = getCleanPath(path)\n const normalized = normalizePath(clean)\n\n if (normalized === '/') {\n return { pathWithoutLocale: '/', localeFromPath: null }\n }\n\n if (!hasLeadingSlash(normalized)) {\n return { pathWithoutLocale: normalized, localeFromPath: null }\n }\n\n const nextSlash = normalized.indexOf('/', 1)\n const firstSegment = nextSlash === -1 ? normalized.slice(1) : normalized.slice(1, nextSlash)\n\n if (firstSegment && localeCodes.includes(firstSegment)) {\n const lengthToCut = 1 + firstSegment.length\n const remaining = normalized.slice(lengthToCut)\n return {\n pathWithoutLocale: normalizePath(remaining || '/'),\n localeFromPath: firstSegment,\n }\n }\n\n return { pathWithoutLocale: normalized, localeFromPath: null }\n}\n\n/**\n * Determines locale from first path segment.\n */\nexport function getLocaleFromPath(path: string, localeCodes: string[]): string | null {\n const clean = getCleanPath(path)\n\n if (clean === '/' || clean === '') return null\n\n if (!hasLeadingSlash(clean)) return null\n\n const nextSlash = clean.indexOf('/', 1)\n const segment = nextSlash === -1 ? clean.slice(1) : clean.slice(1, nextSlash)\n if (segment && localeCodes.includes(segment)) {\n return segment\n }\n\n return null\n}\n","/**\n * Route name utilities: base name, localized name.\n */\n\nimport type { Locale } from '@i18n-micro/types'\nimport type { RouteLike } from '../core/types'\n\nexport interface GetRouteBaseNameOptions {\n locales: Pick<Locale, 'code'>[]\n localizedRouteNamePrefix?: string\n}\n\n/**\n * Base route name without prefix (localized-) and suffix (-{locale}).\n * Suffix is stripped only when it is a full segment (preceded by hyphen),\n * so names like product-screen are not broken when locale is en.\n */\nexport function getRouteBaseName(route: RouteLike, options: GetRouteBaseNameOptions): string | null {\n const name = route.name?.toString()\n if (!name) return null\n\n const prefix = options.localizedRouteNamePrefix || 'localized-'\n const base = name.startsWith(prefix) ? name.slice(prefix.length) : name\n\n // Sort by length descending: en-US before en — otherwise we strip the wrong suffix\n const sortedLocales = [...options.locales].sort((a, b) => b.code.length - a.code.length)\n\n for (const locale of sortedLocales) {\n const suffix = `-${locale.code}`\n if (!base.endsWith(suffix)) continue\n // Strip only when locale code is a separate segment (preceded by hyphen: ...-en, not ...screen)\n const charBeforeLocale = base.length - locale.code.length - 1\n if (charBeforeLocale >= 0 && base[charBeforeLocale] === '-') {\n return base.slice(0, -suffix.length)\n }\n }\n return base\n}\n\n/** Builds localized name: localized-{baseName}-{locale}. */\nexport function buildLocalizedName(baseName: string, locale: string, prefix = 'localized-'): string {\n return `${prefix}${baseName}-${locale}`\n}\n\nexport interface IsIndexRouteNameOptions {\n localizedRouteNamePrefix?: string\n localeCodes?: string[]\n}\n\n/**\n * Returns true if the given route name or base name refers to the index (root) route.\n * - Base name: 'index' or ''.\n * - Full route name: 'index', or 'localized-index-{locale}' for any locale in localeCodes.\n * Use this instead of ad-hoc checks like (name === 'index' || name.endsWith('-index') || name === 'localized-index-' + defaultLocale).\n */\nexport function isIndexRouteName(name: string | null | undefined, options?: IsIndexRouteNameOptions): boolean {\n if (name == null) return false\n const s = String(name).trim()\n if (s === '' || s === 'index') return true\n const prefix = options?.localizedRouteNamePrefix ?? 'localized-'\n const localeCodes = options?.localeCodes ?? []\n const localizedIndexPrefix = `${prefix}index-`\n if (!s.startsWith(localizedIndexPrefix)) return false\n const localePart = s.slice(localizedIndexPrefix.length)\n return localeCodes.length === 0 ? localePart.length >= 2 : localeCodes.includes(localePart)\n}\n","/**\n * RouteResolver — single point for resolving custom paths from globalLocaleRoutes.\n * Uses normalizer and route-name utilities; lookup keys in one place (getLookupKeys).\n */\n\nimport { withoutLeadingSlash } from 'ufo'\nimport { joinUrl, nameKeyFirstSlash, nameKeyLastSlash, normalizePath, transformNameKeyToPath } from '../utils/path'\nimport { getRouteBaseName } from '../utils/route-name'\nimport { getPathWithoutLocale } from './normalizer'\nimport type { PathStrategyContext, ResolvedRouteLike } from './types'\n\n/**\n * Single pre-compiled regex that matches all Nuxt route param patterns in one pass:\n * :key() — optional param (group 1)\n * :key — required param (group 2, not followed by word char)\n * [...key] — catch-all param (group 3)\n */\nconst PARAM_PATTERN = /:(\\w+)\\(\\)|:(\\w+)(?!\\w)|\\[\\.\\.\\.(\\w+)\\]/g\n\nexport class RouteResolver {\n constructor(private ctx: PathStrategyContext) {}\n\n /**\n * Substitutes params into path template (:key, :key(), [...key]).\n * Uses a single pre-compiled regex for all keys in one pass — no per-key RegExp allocation.\n */\n resolvePathWithParams(path: string, params: Record<string, unknown> = {}): string {\n if (!params || Object.keys(params).length === 0) return path\n\n return path.replace(PARAM_PATTERN, (match, optKey?: string, reqKey?: string, catchAllKey?: string) => {\n const key = optKey || reqKey || catchAllKey\n if (!key) return match\n\n const value = params[key]\n if (value === undefined || value === null || value === '') return match\n\n return Array.isArray(value) ? (value as unknown[]).join('/') : String(value)\n })\n }\n\n /**\n * Analyzes route: path without locale and base name (normalizer + route-name).\n */\n private analyzeRoute(route: ResolvedRouteLike): { pathWithoutLocale: string; baseRouteName: string | null } {\n const localeCodes = this.ctx.locales.map((l) => l.code)\n const { pathWithoutLocale } = getPathWithoutLocale(route.path || '/', localeCodes)\n\n let baseRouteName: string | null = null\n if (route.name) {\n baseRouteName = getRouteBaseName(route, {\n locales: this.ctx.locales,\n localizedRouteNamePrefix: this.ctx.localizedRouteNamePrefix || 'localized-',\n })\n }\n\n return { pathWithoutLocale, baseRouteName }\n }\n\n /** Public access to route analysis (for strategies). */\n getPathWithoutLocaleAndBaseName(route: ResolvedRouteLike): { pathWithoutLocale: string; baseRouteName: string | null } {\n return this.analyzeRoute(route)\n }\n\n /**\n * Lookup keys for config (same order for resolveCustomPath, getPathForUnlocalizedRoute, getAllowedLocalesForRoute).\n */\n private getLookupKeys(pathWithoutLocale: string, baseRouteName: string | null): string[] {\n const keys: string[] = []\n\n keys.push(pathWithoutLocale)\n\n const pathKey = withoutLeadingSlash(pathWithoutLocale)\n if (pathKey && pathKey !== pathWithoutLocale) keys.push(pathKey)\n // Support root path lookup: '' as key when path is '/'\n if (pathWithoutLocale === '/' || pathKey === '') keys.push('')\n\n if (baseRouteName) {\n keys.push(`/${baseRouteName}`)\n keys.push(baseRouteName)\n\n const asPath = transformNameKeyToPath(baseRouteName)\n if (asPath && asPath !== baseRouteName) keys.push(asPath)\n\n const firstSlash = nameKeyFirstSlash(baseRouteName)\n if (firstSlash) keys.push(firstSlash)\n\n const lastSlash = nameKeyLastSlash(baseRouteName)\n if (lastSlash) keys.push(lastSlash)\n }\n\n return keys\n }\n\n /**\n * Resolves custom path for targetLocale from globalLocaleRoutes.\n */\n resolveCustomPath(route: ResolvedRouteLike, targetLocale: string): string | null {\n const gr = this.ctx.globalLocaleRoutes\n if (!gr || Object.keys(gr).length === 0) return null\n\n const { pathWithoutLocale, baseRouteName } = this.analyzeRoute(route)\n const keys = this.getLookupKeys(pathWithoutLocale, baseRouteName)\n\n for (const key of keys) {\n const rule = gr[key]\n if (rule && typeof rule === 'object' && !Array.isArray(rule)) {\n const customPath = (rule as Record<string, string>)[targetLocale]\n if (typeof customPath === 'string') {\n return this.resolvePathWithParams(customPath, route.params ?? {})\n }\n }\n }\n\n return null\n }\n\n /**\n * Unlocalized route (globalLocaleRoutes[key] === false) — returns path without locale.\n */\n getPathForUnlocalizedRoute(route: ResolvedRouteLike): string | null {\n const gr = this.ctx.globalLocaleRoutes\n if (!gr) return null\n\n const { pathWithoutLocale, baseRouteName } = this.analyzeRoute(route)\n const keys = this.getLookupKeys(pathWithoutLocale, baseRouteName)\n\n for (const key of keys) {\n if (gr[key] === false) {\n if (baseRouteName && (key === baseRouteName || key === `/${baseRouteName}`)) {\n const pathForm = transformNameKeyToPath(baseRouteName)\n return pathForm ? joinUrl('/', pathForm) : `/${baseRouteName}`\n }\n return pathWithoutLocale\n }\n }\n\n return null\n }\n\n /**\n * Unlocalized by name (when no route object available).\n */\n getPathForUnlocalizedRouteByName(routeName: string): string | null {\n const gr = this.ctx.globalLocaleRoutes\n if (!gr) return null\n\n const keys = [routeName, `/${routeName}`, withoutLeadingSlash(routeName)]\n\n for (const key of keys) {\n if (gr[key] === false) {\n const pathForm = transformNameKeyToPath(key.startsWith('/') ? key.slice(1) : key)\n return pathForm ? joinUrl('/', pathForm) : key.startsWith('/') ? key : `/${key}`\n }\n }\n return null\n }\n\n /**\n * Allowed locales for route (routeLocales).\n */\n getAllowedLocalesForRoute(route: ResolvedRouteLike): string[] {\n const rl = this.ctx.routeLocales\n if (!rl || Object.keys(rl).length === 0) {\n return this.ctx.locales.map((l) => l.code)\n }\n\n const { pathWithoutLocale, baseRouteName } = this.analyzeRoute(route)\n let keys = this.getLookupKeys(pathWithoutLocale, baseRouteName)\n\n if (baseRouteName && this.ctx.routesLocaleLinks?.[baseRouteName]) {\n const linkedName = this.ctx.routesLocaleLinks[baseRouteName]\n keys = [linkedName, ...keys]\n }\n\n for (const key of keys) {\n const allowed = rl[key]\n if (Array.isArray(allowed) && allowed.length > 0) {\n return allowed.filter((code) => this.ctx.locales.some((l) => l.code === code))\n }\n }\n\n return this.ctx.locales.map((l) => l.code)\n }\n\n /**\n * Parent path for nested route (parent key -> targetLocale path).\n */\n getParentPathForNested(nameSegments: string[], targetLocale: string): string {\n if (nameSegments.length <= 1) return '/'\n\n const parentKey = nameSegments.length > 1 ? nameSegments.slice(0, -1).join('-') : ''\n const gr = this.ctx.globalLocaleRoutes\n\n if (parentKey && gr?.[parentKey] && typeof gr[parentKey] === 'object') {\n const parentRules = gr[parentKey] as Record<string, string>\n if (parentRules[targetLocale]) {\n return normalizePath(parentRules[targetLocale])\n }\n }\n\n return joinUrl('/', ...nameSegments.slice(0, -1))\n }\n}\n","import type { Locale } from '@i18n-micro/types'\nimport { hasProtocol, withoutTrailingSlash } from 'ufo'\nimport { getLocaleFromPath as normalizerGetLocaleFromPath, getPathWithoutLocale as normalizerGetPathWithoutLocale } from '../core/normalizer'\nimport { RouteResolver } from '../core/resolver'\nimport type {\n NormalizedRouteInput,\n PathStrategy,\n PathStrategyContext,\n ResolvedRouteLike,\n RouteLike,\n RouterAdapter,\n SeoAttributes,\n SwitchLocaleOptions,\n} from '../core/types'\nimport { buildUrl, getPathSegments, joinUrl, nameKeyFirstSlash, nameKeyLastSlash, normalizePath, transformNameKeyToPath } from '../utils/path'\nimport { isIndexRouteName, buildLocalizedName as utilBuildLocalizedName, getRouteBaseName as utilGetRouteBaseName } from '../utils/route-name'\n\nexport abstract class BasePathStrategy implements PathStrategy {\n protected resolver: RouteResolver\n\n constructor(protected ctx: PathStrategyContext) {\n this.resolver = new RouteResolver(ctx)\n }\n\n setRouter(router: RouterAdapter): void {\n this.ctx.router = router\n }\n\n getDefaultLocale(): string {\n return this.ctx.defaultLocale\n }\n\n getLocales(): Locale[] {\n return this.ctx.locales\n }\n\n getStrategy(): PathStrategyContext['strategy'] {\n return this.ctx.strategy\n }\n\n getLocalizedRouteNamePrefix(): string {\n return this.ctx.localizedRouteNamePrefix || 'localized-'\n }\n\n getGlobalLocaleRoutes(): PathStrategyContext['globalLocaleRoutes'] {\n return this.ctx.globalLocaleRoutes\n }\n\n getRouteLocales(): PathStrategyContext['routeLocales'] {\n return this.ctx.routeLocales\n }\n\n getRoutesLocaleLinks(): PathStrategyContext['routesLocaleLinks'] {\n return this.ctx.routesLocaleLinks\n }\n\n getNoPrefixRedirect(): boolean | undefined {\n return this.ctx.noPrefixRedirect\n }\n\n /**\n * Returns base route name without locale prefix/suffix.\n * @param route - Route object\n * @param locale - Optional locale to strip suffix for (if not provided, tries all locales)\n */\n getRouteBaseName(route: RouteLike, locale?: string): string | null {\n const locales = locale ? [{ code: locale }] : this.ctx.locales\n return utilGetRouteBaseName(route, {\n locales,\n localizedRouteNamePrefix: this.getLocalizedRouteNamePrefix(),\n })\n }\n\n /** Alias for internal use - strips localization prefix/suffix for specific locale. */\n protected getBaseRouteName(route: RouteLike, locale: string): string | null {\n return this.getRouteBaseName(route, locale)\n }\n\n /** Resolves target path for a locale, checking globalLocaleRoutes first. */\n protected resolvePathForLocale(path: string, targetLocale: string): string {\n const mockRoute: ResolvedRouteLike = {\n path,\n name: null,\n fullPath: path,\n params: {},\n }\n const customSegment = this.resolver.resolveCustomPath(mockRoute, targetLocale)\n if (customSegment) return normalizePath(customSegment)\n return normalizePath(path)\n }\n\n protected buildLocalizedName(baseName: string, locale: string): string {\n return utilBuildLocalizedName(baseName, locale, this.getLocalizedRouteNamePrefix())\n }\n\n /** Builds path for target locale (strategy decides: with or without prefix). */\n protected abstract buildLocalizedPath(path: string, locale: string, isCustom: boolean): string\n\n /** Builds localized route name for target locale. */\n protected abstract buildLocalizedRouteName(baseName: string, locale: string): string\n\n protected getLocaleObject(code: string): Locale | undefined {\n return this.ctx.locales.find((l) => l.code === code)\n }\n\n protected applyBaseUrl(localeCode: string, route: RouteLike | string): RouteLike | string {\n if (typeof route === 'string') {\n if (hasProtocol(route)) return route\n } else if (route.path && hasProtocol(route.path)) {\n return route\n }\n\n const locale = this.getLocaleObject(localeCode)\n if (!locale?.baseUrl) {\n return route\n }\n\n const baseUrl = withoutTrailingSlash(locale.baseUrl)\n\n if (typeof route === 'string') {\n const path = normalizePath(route.startsWith('/') ? route : `/${route}`)\n return joinUrl(baseUrl, path)\n }\n\n const resolvedPath = normalizePath(route.path || '')\n const fullPath = joinUrl(baseUrl, resolvedPath)\n // For external URLs (with protocol), return string to prevent NuxtLink from adding base path\n if (hasProtocol(fullPath)) {\n return fullPath\n }\n return {\n ...route,\n path: fullPath,\n fullPath,\n }\n }\n\n /**\n * Merges target route (strategy result) with query and hash from source route.\n * Returns normalized RouteLike object.\n */\n protected preserveQueryAndHash(target: RouteLike | string, source?: RouteLike | null): RouteLike | string {\n if (!source || (!source.query && !source.hash)) {\n return target\n }\n\n const result: RouteLike = typeof target === 'string' ? { path: target } : { ...target }\n\n if (source.query) {\n result.query = { ...source.query, ...result.query }\n }\n if (!result.hash && source.hash) {\n result.hash = source.hash\n }\n\n const basePath = result.path ?? ''\n result.fullPath = buildUrl(basePath, result.query, result.hash)\n\n return result\n }\n\n protected resolvePathWithParams(path: string, params: Record<string, unknown> = {}): string {\n return this.resolver.resolvePathWithParams(path, params)\n }\n\n protected getPathWithoutLocaleAndBaseName(route: ResolvedRouteLike): { pathWithoutLocale: string; baseRouteName: string | null } {\n return this.resolver.getPathWithoutLocaleAndBaseName(route)\n }\n\n /** Look up custom path segment for targetLocale in globalLocaleRoutes. */\n protected getCustomPathSegment(route: ResolvedRouteLike, targetLocale: string): string | null {\n return this.resolver.resolveCustomPath(route, targetLocale)\n }\n\n protected getAllowedLocalesForRoute(route: ResolvedRouteLike): string[] {\n return this.resolver.getAllowedLocalesForRoute(route)\n }\n\n getCanonicalPath(_route: ResolvedRouteLike, _targetLocale: string): string | null {\n return null\n }\n\n protected getPathForUnlocalizedRouteByName(routeName: string): string | null {\n return this.resolver.getPathForUnlocalizedRouteByName(routeName)\n }\n\n /**\n * Try to resolve route by localized name. Returns RouteLike with query/hash from sourceRoute to preserve them.\n */\n protected tryResolveByLocalizedName(routeName: string, targetLocale: string, sourceRoute?: RouteLike): RouteLike | null {\n const prefix = this.getLocalizedRouteNamePrefix()\n // Try with locale suffix first (custom paths), then without (standard routes)\n const localizedNameWithSuffix = `${prefix}${routeName}-${targetLocale}`\n const localizedNameWithoutSuffix = `${prefix}${routeName}`\n\n let localizedName: string\n if (this.ctx.router.hasRoute(localizedNameWithSuffix)) {\n localizedName = localizedNameWithSuffix\n } else if (this.ctx.router.hasRoute(localizedNameWithoutSuffix)) {\n localizedName = localizedNameWithoutSuffix\n } else {\n this.debugLog('tryResolveByLocalizedName', {\n routeName,\n targetLocale,\n tried: [localizedNameWithSuffix, localizedNameWithoutSuffix],\n found: false,\n })\n return null\n }\n\n this.debugLog('tryResolveByLocalizedName', { routeName, targetLocale, localizedName, found: true })\n // If using route without locale suffix (e.g. localized-page), add locale param\n const params = { ...sourceRoute?.params }\n if (localizedName === localizedNameWithoutSuffix) {\n params.locale = targetLocale\n }\n let resolved: ReturnType<typeof this.ctx.router.resolve>\n try {\n resolved = this.ctx.router.resolve({\n name: localizedName,\n params,\n query: sourceRoute?.query,\n hash: sourceRoute?.hash,\n })\n } catch {\n // Router threw error (e.g. missing required param) - try path-based fallback\n this.debugLog('tryResolveByLocalizedName resolve error', { localizedName, params })\n return null\n }\n this.debugLog('tryResolveByLocalizedName resolved', { localizedName, path: resolved?.path, fullPath: resolved?.fullPath })\n if (!resolved?.path) return null\n return {\n name: localizedName,\n path: resolved.path,\n fullPath: resolved.fullPath,\n params: resolved.params,\n query: resolved.query ?? sourceRoute?.query,\n hash: resolved.hash ?? sourceRoute?.hash,\n }\n }\n\n /**\n * Try to resolve route by localized name with params. Returns RouteLike to preserve query/hash.\n */\n protected tryResolveByLocalizedNameWithParams(\n routeName: string,\n targetLocale: string,\n params: Record<string, unknown>,\n sourceRoute?: RouteLike,\n ): RouteLike | null {\n const prefix = this.getLocalizedRouteNamePrefix()\n // Try with locale suffix first (custom paths), then without (standard routes)\n const localizedNameWithSuffix = `${prefix}${routeName}-${targetLocale}`\n const localizedNameWithoutSuffix = `${prefix}${routeName}`\n\n let localizedName: string\n if (this.ctx.router.hasRoute(localizedNameWithSuffix)) {\n localizedName = localizedNameWithSuffix\n } else if (this.ctx.router.hasRoute(localizedNameWithoutSuffix)) {\n localizedName = localizedNameWithoutSuffix\n } else {\n this.debugLog('tryResolveByLocalizedNameWithParams', {\n routeName,\n targetLocale,\n params,\n tried: [localizedNameWithSuffix, localizedNameWithoutSuffix],\n found: false,\n })\n return null\n }\n\n this.debugLog('tryResolveByLocalizedNameWithParams', { routeName, targetLocale, params, localizedName, found: true })\n // If using route without locale suffix (e.g. localized-page), add locale param\n const resolveParams = { ...params }\n if (localizedName === localizedNameWithoutSuffix) {\n resolveParams.locale = targetLocale\n }\n let resolved: ReturnType<typeof this.ctx.router.resolve>\n try {\n resolved = this.ctx.router.resolve({\n name: localizedName,\n params: resolveParams,\n query: sourceRoute?.query,\n hash: sourceRoute?.hash,\n })\n } catch {\n // Router threw error (e.g. missing required param) - return null\n this.debugLog('tryResolveByLocalizedNameWithParams resolve error', { localizedName, resolveParams })\n return null\n }\n this.debugLog('tryResolveByLocalizedNameWithParams resolved', { path: resolved?.path, fullPath: resolved?.fullPath })\n if (!resolved?.path || resolved.path === '/') return null\n return {\n name: localizedName,\n path: resolved.path,\n fullPath: resolved.fullPath,\n params: resolved.params,\n query: resolved.query ?? sourceRoute?.query,\n hash: resolved.hash ?? sourceRoute?.hash,\n }\n }\n\n protected getPathForUnlocalizedRoute(route: ResolvedRouteLike): string | null {\n return this.resolver.getPathForUnlocalizedRoute(route)\n }\n\n /**\n * Builds localized path from baseName + params when router does not have the route.\n * Tries two conventions:\n * 1) Hyphen form (Nuxt test-[id].vue → /test-:id): when single param key equals last baseName segment (e.g. test-id + id → test-:id).\n * 2) Slash form (kebab→slash): path segments from baseName, last N replaced by :paramKey (e.g. test-id → /test/:id).\n */\n protected buildPathFromBaseNameAndParams(baseName: string, params: Record<string, unknown>, targetLocale: string): string | null {\n const paramKeys = Object.keys(params).filter((k) => params[k] !== undefined && params[k] !== null && params[k] !== '')\n if (paramKeys.length === 0) return null\n let pathTemplate: string\n const firstKey = paramKeys[0]\n if (paramKeys.length === 1 && firstKey !== undefined && baseName.endsWith(`-${firstKey}`)) {\n pathTemplate = joinUrl('/', `${baseName.slice(0, baseName.length - firstKey.length - 1)}-:${firstKey}`)\n } else {\n const pathForm = transformNameKeyToPath(baseName)\n const pathSegments = pathForm ? pathForm.split('/').filter(Boolean) : [baseName]\n const replaceCount = Math.min(paramKeys.length, pathSegments.length)\n const templateSegments = pathSegments.slice(0, pathSegments.length - replaceCount).concat(paramKeys.slice(0, replaceCount).map((k) => `:${k}`))\n pathTemplate = joinUrl('/', ...templateSegments)\n }\n const pathWithParams = this.resolvePathWithParams(pathTemplate, params)\n const finalPath = this.buildLocalizedPath(pathWithParams, targetLocale, false)\n const withBase = this.applyBaseUrl(targetLocale, finalPath)\n return typeof withBase === 'string' ? withBase : ((withBase as RouteLike).path ?? finalPath)\n }\n\n protected getPathWithoutLocale(path: string): { pathWithoutLocale: string; localeFromPath: string | null } {\n return normalizerGetPathWithoutLocale(\n path,\n this.ctx.locales.map((l) => l.code),\n )\n }\n\n getLocaleFromPath(path: string): string | null {\n return normalizerGetLocaleFromPath(\n path,\n this.ctx.locales.map((l) => l.code),\n )\n }\n\n abstract resolveLocaleFromPath(path: string): string | null\n\n /**\n * Returns path to redirect to, or null if no redirect needed.\n * Use in middleware: strategy.getRedirect(to.fullPath, detectedLocale)\n */\n abstract getRedirect(currentPath: string, targetLocale: string): string | null\n\n /**\n * Returns path to redirect to for client-side navigation based on preferred locale.\n * Returns null if no redirect needed. Each strategy implements its own logic.\n */\n abstract getClientRedirect(currentPath: string, preferredLocale: string): string | null\n\n /**\n * Checks if the current path should return 404.\n * Returns error message if 404 should be returned, null otherwise.\n * Base implementation checks unlocalized routes and routeLocales restrictions.\n */\n shouldReturn404(currentPath: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n\n // No locale in URL - no 404 from strategy perspective\n if (localeFromPath === null) return null\n\n const pathKey = pathWithoutLocale === '/' ? '/' : pathWithoutLocale.replace(/^\\//, '')\n const gr = this.ctx.globalLocaleRoutes\n\n // Unlocalized route with locale prefix is 404\n if (gr && (gr[pathWithoutLocale] === false || gr[pathKey] === false)) {\n return 'Unlocalized route cannot have locale prefix'\n }\n\n // Check routeLocales restrictions\n const rl = this.ctx.routeLocales\n if (rl && Object.keys(rl).length > 0) {\n const allowed = rl[pathWithoutLocale] ?? rl[pathKey]\n if (Array.isArray(allowed) && allowed.length > 0) {\n const validCodes = this.ctx.locales.map((l) => l.code)\n const allowedCodes = allowed.filter((code) => validCodes.includes(code))\n if (allowedCodes.length > 0 && !allowedCodes.includes(localeFromPath)) {\n return 'Locale not allowed for this route'\n }\n }\n }\n\n return null\n }\n\n /**\n * Builds SEO attributes (canonical + hreflangs) from current route.\n * Respects routeLocales: only allowed locales for this route get an hreflang entry.\n * routesLocaleLinks is used when resolving the route key for routeLocales lookup.\n */\n getSeoAttributes(currentRoute: ResolvedRouteLike): SeoAttributes {\n const currentLocale = this.resolveLocaleFromPath(currentRoute.path) ?? this.ctx.defaultLocale\n const canonicalPath = this.getCanonicalPath(currentRoute, currentLocale) ?? currentRoute.path\n const canonical = this.buildFullUrl(currentLocale, canonicalPath)\n\n const allowedCodes = this.getAllowedLocalesForRoute(currentRoute)\n const localesToEmit = this.ctx.locales.filter((l) => allowedCodes.includes(l.code))\n const hreflangs = localesToEmit.map((locale) => {\n const localized = this.localeRoute(locale.code, currentRoute, currentRoute)\n const pathStr = localized.path ?? localized.fullPath ?? ''\n const normalizedPath = pathStr || '/'\n return {\n rel: 'alternate' as const,\n hreflang: locale.code,\n href: this.buildFullUrl(locale.code, normalizedPath),\n }\n })\n\n return { canonical, hreflangs }\n }\n\n /**\n * Builds full URL (path + optional baseUrl for locale).\n */\n protected buildFullUrl(localeCode: string, path: string): string {\n const result = this.applyBaseUrl(localeCode, path)\n return typeof result === 'string' ? result : (result.path ?? path)\n }\n\n /** When router knows neither targetName nor baseName — what to return (strategy may override). */\n protected getSwitchLocaleFallbackWhenNoRoute(route: ResolvedRouteLike, targetName: string): RouteLike | string {\n return { ...route, name: targetName }\n }\n\n /**\n * Default: baseName → buildLocalizedRouteName → hasRoute → applyBaseUrl; fallback to baseName.\n */\n switchLocaleRoute(fromLocale: string, toLocale: string, route: ResolvedRouteLike, options: SwitchLocaleOptions): RouteLike | string {\n const baseName = this.getBaseRouteName(route, fromLocale)\n if (!baseName) return route\n\n // Try route name with locale suffix first (custom paths), then without suffix (standard routes)\n const nameWithSuffix = this.buildLocalizedRouteName(baseName, toLocale)\n const nameWithoutSuffix = `${this.getLocalizedRouteNamePrefix()}${baseName}`\n let targetName: string\n let needsLocaleParam = false\n\n if (this.ctx.router.hasRoute(nameWithSuffix)) {\n targetName = nameWithSuffix\n } else if (this.ctx.router.hasRoute(nameWithoutSuffix)) {\n targetName = nameWithoutSuffix\n needsLocaleParam = true\n } else if (this.ctx.router.hasRoute(baseName)) {\n targetName = baseName\n } else {\n return this.getSwitchLocaleFallbackWhenNoRoute(route, nameWithSuffix)\n }\n\n const i18nParams = options.i18nRouteParams?.[toLocale] || {}\n const newParams: Record<string, unknown> = { ...(route.params || {}), ...i18nParams }\n // Add locale param if using route without locale suffix (e.g. localized-index with /:locale param)\n if (needsLocaleParam) {\n newParams.locale = toLocale\n } else {\n delete (newParams as Record<string, unknown>).locale\n }\n\n const newRoute: RouteLike = {\n name: targetName,\n params: newParams,\n query: route.query,\n hash: route.hash,\n }\n return this.applyBaseUrl(toLocale, newRoute)\n }\n\n /**\n * Template Method: BaseStrategy knows \"how\" (normalize → delegate to strategy).\n * Always returns RouteLike with path and fullPath (never a string).\n */\n localeRoute(targetLocale: string, routeOrPath: RouteLike | string, currentRoute?: ResolvedRouteLike): RouteLike {\n const normalized = this.normalizeRouteInput(routeOrPath, currentRoute)\n const raw = this.resolveLocaleRoute(targetLocale, normalized, currentRoute)\n this.debugLog('localeRoute raw', {\n rawPath: typeof raw === 'string' ? raw : (raw as RouteLike).path,\n rawFullPath: typeof raw === 'string' ? raw : (raw as RouteLike).fullPath,\n })\n const result = this.ensureRouteLike(raw, normalized.kind === 'route' ? normalized.sourceRoute : undefined)\n this.debugLog('localeRoute after ensureRouteLike', { path: result.path, fullPath: result.fullPath })\n return result\n }\n\n /** Normalizes resolveLocaleRoute result into RouteLike (path and fullPath always set). */\n protected ensureRouteLike(value: RouteLike | string, source?: RouteLike | null): RouteLike {\n if (typeof value === 'string') {\n const path = value\n const fullPath = source?.query || source?.hash ? buildUrl(path, source?.query, source?.hash) : path\n return {\n path,\n fullPath,\n ...(source?.query && { query: source.query }),\n ...(source?.hash && { hash: source.hash }),\n }\n }\n let fullPath = value.fullPath ?? value.path ?? ''\n let path = value.path ?? fullPath.split('?')[0]?.split('#')[0] ?? fullPath\n if (!path && !fullPath) {\n const name = value.name?.toString() ?? source?.name?.toString() ?? ''\n if (\n isIndexRouteName(name, {\n localizedRouteNamePrefix: this.getLocalizedRouteNamePrefix(),\n localeCodes: this.ctx.locales.map((l) => l.code),\n })\n ) {\n path = '/'\n fullPath = '/'\n }\n }\n return { ...value, path, fullPath }\n }\n\n /**\n * Normalizes localeRoute input into a single structure (path string or route with resolved).\n */\n protected normalizeRouteInput(routeOrPath: RouteLike | string, _currentRoute?: ResolvedRouteLike): NormalizedRouteInput {\n if (typeof routeOrPath === 'string') {\n return { kind: 'path', path: routeOrPath }\n }\n const sourceRoute = routeOrPath as RouteLike\n const inputName = sourceRoute.name?.toString() ?? null\n let resolved: ResolvedRouteLike\n try {\n resolved = this.ctx.router.resolve(routeOrPath)\n this.debugLog('normalizeRouteInput router.resolve ok', { inputName, resolvedPath: resolved.path, resolvedName: resolved.name })\n } catch {\n resolved = {\n name: inputName,\n path: sourceRoute.path ?? '/',\n fullPath: sourceRoute.fullPath ?? sourceRoute.path ?? '/',\n params: sourceRoute.params ?? {},\n query: sourceRoute.query ?? {},\n hash: sourceRoute.hash ?? '',\n } as ResolvedRouteLike\n this.debugLog('normalizeRouteInput router.resolve catch fallback', { inputName, resolvedPath: resolved.path })\n }\n return { kind: 'route', inputName, sourceRoute, resolved }\n }\n\n /** Logging when ctx.debug (for localeRoute debugging). Disabled by default. */\n private debugLog(..._args: unknown[]): void {\n // if (this.ctx.debug) console.log('[i18n:resolveLocaleRoute]', ..._args)\n }\n\n /**\n * Default resolution: uses buildLocalizedPath and buildLocalizedRouteName.\n * Strategies with different logic (e.g. prefix-except-default) override this method.\n */\n protected resolveLocaleRoute(targetLocale: string, normalized: NormalizedRouteInput, _currentRoute?: ResolvedRouteLike): RouteLike | string {\n if (normalized.kind === 'path') {\n const resolvedPath = this.resolvePathForLocale(normalized.path, targetLocale)\n const finalPath = this.buildLocalizedPath(resolvedPath, targetLocale, false)\n const out = this.applyBaseUrl(targetLocale, finalPath)\n this.debugLog('branch=path', { targetLocale, path: normalized.path, finalPath, out: typeof out === 'string' ? out : (out as RouteLike).path })\n return out\n }\n\n const { inputName, sourceRoute: src, resolved } = normalized\n const hasParams = src.params && Object.keys(src.params ?? {}).length > 0\n const baseName = this.getRouteBaseName(resolved) ?? inputName ?? resolved.name?.toString() ?? null\n const resolvedNameStr = resolved.name?.toString()\n\n this.debugLog('input', {\n targetLocale,\n inputName,\n resolvedPath: resolved.path,\n resolvedName: resolved.name,\n params: src.params,\n hasParams,\n baseName,\n })\n\n if (inputName) {\n const unlocalizedByName = this.getPathForUnlocalizedRouteByName(inputName)\n if (unlocalizedByName !== null) {\n this.debugLog('branch=unlocalizedByName', { inputName, unlocalizedByName })\n return this.preserveQueryAndHash(unlocalizedByName, src)\n }\n }\n\n if (inputName && hasParams) {\n const routeWithParams = this.tryResolveByLocalizedNameWithParams(inputName, targetLocale, src.params ?? {}, src)\n if (routeWithParams !== null) {\n this.debugLog('branch=routeWithParams', { inputName, path: routeWithParams.path, fullPath: routeWithParams.fullPath })\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeWithParams), src)\n }\n }\n\n // Resolve by inputName first; if not found and inputName looks like a localized name (prefix-base-locale), try baseName.\n // Do not try baseName when user asked for base name 'index' (resolved route may be current page -> baseName 'page').\n if (inputName && !hasParams) {\n let routeByLocalizedName = this.tryResolveByLocalizedName(inputName, targetLocale, src)\n const prefix = this.getLocalizedRouteNamePrefix()\n if (routeByLocalizedName === null && baseName != null && baseName !== inputName && inputName.startsWith(prefix)) {\n routeByLocalizedName = this.tryResolveByLocalizedName(baseName, targetLocale, src)\n }\n if (routeByLocalizedName !== null) {\n this.debugLog('branch=routeByLocalizedName', { inputName, path: routeByLocalizedName.path, fullPath: routeByLocalizedName.fullPath })\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeByLocalizedName), src)\n }\n }\n\n const unlocalizedPath = this.getPathForUnlocalizedRoute(resolved)\n if (unlocalizedPath !== null) {\n const path = this.buildLocalizedPath(unlocalizedPath, targetLocale, false)\n this.debugLog('branch=unlocalizedPath', { unlocalizedPath, path })\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, path), src)\n }\n\n const customSegment = this.getCustomPathSegment(resolved, targetLocale)\n if (customSegment !== null) {\n const routeName = resolved.name?.toString() ?? inputName ?? ''\n const keyFirstSlash = routeName ? nameKeyFirstSlash(routeName) : ''\n const keyLastSlash = routeName ? nameKeyLastSlash(routeName) : ''\n const gr = this.ctx.globalLocaleRoutes\n const isNestedFirst = keyFirstSlash.includes('/') && gr?.[keyFirstSlash]\n const isNestedLast = keyLastSlash.includes('/') && gr?.[keyLastSlash]\n const isNested = isNestedFirst || isNestedLast\n const keyWithSlash = isNestedLast ? keyLastSlash : keyFirstSlash\n let pathWithoutLocale: string\n if (isNested) {\n const nameSegments = getPathSegments(keyWithSlash)\n const parentKey = nameSegments.length > 1 ? nameSegments.slice(0, -1).join('-') : ''\n const parentRules =\n parentKey && gr?.[parentKey] && typeof gr[parentKey] === 'object' && !Array.isArray(gr[parentKey])\n ? (gr[parentKey] as Record<string, string>)\n : null\n const parentPath = parentRules?.[targetLocale] ? normalizePath(parentRules[targetLocale]) : joinUrl('/', ...nameSegments.slice(0, -1))\n const segment = customSegment.startsWith('/') ? customSegment.slice(1) : customSegment\n pathWithoutLocale = joinUrl(parentPath, segment)\n } else {\n pathWithoutLocale = normalizePath(customSegment)\n }\n const finalPath = this.buildLocalizedPath(pathWithoutLocale, targetLocale, true)\n this.debugLog('branch=customSegment', { customSegment, pathWithoutLocale, finalPath })\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, finalPath), src)\n }\n\n const effectiveBaseName = baseName ?? inputName\n this.debugLog('before effectiveBaseName check', { baseName, inputName, effectiveBaseName, resolvedName: resolved.name?.toString() })\n if (!effectiveBaseName) {\n this.debugLog('branch=noBaseName', { return: 'src' })\n return src\n }\n\n if (!hasParams && resolved.path && resolved.path !== '/' && resolved.name) {\n const { pathWithoutLocale, baseRouteName } = this.getPathWithoutLocaleAndBaseName(resolved)\n if (pathWithoutLocale && pathWithoutLocale !== '/') {\n const pathToUse =\n baseRouteName && pathWithoutLocale === baseRouteName ? joinUrl('/', transformNameKeyToPath(baseRouteName)) : pathWithoutLocale\n const finalPath = this.buildLocalizedPath(pathToUse, targetLocale, false)\n this.debugLog('branch=pathFromResolved', { pathWithoutLocale, baseRouteName, pathToUse, finalPath })\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, finalPath), src)\n }\n }\n\n const baseNameForPath = resolvedNameStr === inputName ? effectiveBaseName : (inputName ?? effectiveBaseName)\n this.debugLog('fallback build', { resolvedNameStr, inputName, baseNameForPath, targetLocale, hasParams })\n const targetName = this.buildLocalizedRouteName(baseNameForPath, targetLocale)\n const newRoute: RouteLike = {\n ...src,\n name: targetName,\n params: { ...src.params },\n }\n if (!hasParams) {\n const pathWithoutLocale = isIndexRouteName(baseNameForPath) ? '/' : joinUrl('/', transformNameKeyToPath(baseNameForPath))\n const finalPath = this.buildLocalizedPath(pathWithoutLocale, targetLocale, false)\n const withBase = this.applyBaseUrl(targetLocale, finalPath)\n const pathStr = typeof withBase === 'string' ? withBase : ((withBase as RouteLike).path ?? finalPath)\n this.debugLog('fallback !hasParams', { pathWithoutLocale, finalPath, pathStr })\n newRoute.path = pathStr\n newRoute.fullPath = pathStr\n } else {\n let pathStr: string | null = null\n try {\n const resolvedWithParams = this.ctx.router.resolve({ name: baseNameForPath, params: src.params })\n if (resolvedWithParams?.path) {\n const pathToUse =\n resolvedWithParams.path === '/'\n ? '/'\n : (() => {\n const { pathWithoutLocale } = this.getPathWithoutLocale(resolvedWithParams.path)\n return pathWithoutLocale && pathWithoutLocale !== '/' ? pathWithoutLocale : resolvedWithParams.path\n })()\n const finalPath = this.buildLocalizedPath(pathToUse, targetLocale, false)\n const withBase = this.applyBaseUrl(targetLocale, finalPath)\n pathStr = typeof withBase === 'string' ? withBase : ((withBase as RouteLike).path ?? finalPath)\n }\n } catch {\n // Router does not have baseName route: build path from baseNameForPath + params (path template)\n pathStr = this.buildPathFromBaseNameAndParams(baseNameForPath, src.params ?? {}, targetLocale)\n }\n if (pathStr) {\n newRoute.path = pathStr\n newRoute.fullPath = pathStr\n }\n }\n // If we have a path, remove 'name' to prevent NuxtLink from calling router.resolve with non-existent route name\n if (newRoute.path) {\n delete newRoute.name\n }\n const out = this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, newRoute), src)\n this.debugLog('branch=fallbackNewRoute return', {\n baseName,\n targetName,\n hasParams,\n newRoutePath: newRoute.path,\n outPath: typeof out === 'string' ? out : (out as RouteLike).path,\n })\n return out\n }\n\n /**\n * Extracts locale from URL path by checking the first path segment.\n */\n private extractLocaleFromPath(path: string): string | null {\n if (!path) return null\n\n // Remove query params and hash\n const querySplit = path.split('?')\n const cleanPath = querySplit[0]?.split('#')[0]\n\n if (!cleanPath || cleanPath === '/') return null\n\n const pathSegments = cleanPath.split('/').filter(Boolean)\n if (pathSegments.length === 0) return null\n\n const firstSegment = pathSegments[0]\n if (!firstSegment) return null\n\n const availableLocales = this.ctx.locales.map((l) => l.code)\n if (availableLocales.includes(firstSegment)) {\n return firstSegment\n }\n\n return null\n }\n\n /**\n * Determines current locale from route, considering hashMode, noPrefix, prefix_and_default at /, etc.\n */\n getCurrentLocale(route: ResolvedRouteLike, getDefaultLocale?: () => string | null | undefined): string {\n const strategy = this.ctx.strategy\n\n // 1. Check hashMode\n if (this.ctx.hashMode) {\n const fromGetter = getDefaultLocale?.()\n if (fromGetter) return fromGetter\n return this.ctx.defaultLocale\n }\n\n // 2. Check no_prefix strategy\n if (strategy === 'no_prefix') {\n const fromGetter = getDefaultLocale?.()\n if (fromGetter) return fromGetter\n return this.ctx.defaultLocale\n }\n\n const path = route.path || route.fullPath || ''\n\n // 2b. prefix_and_default at /: useState/cookie can override — / is valid for any locale\n if (strategy === 'prefix_and_default' && (path === '/' || path === '')) {\n const fromGetter = getDefaultLocale?.()\n if (fromGetter) return fromGetter\n }\n\n // 3. Check route.params.locale (for existing routes)\n if (route.params?.locale) {\n return String(route.params.locale)\n }\n\n // 4. Extract locale from URL path (for non-existent routes)\n const localeFromPath = this.extractLocaleFromPath(path)\n if (localeFromPath) {\n return localeFromPath\n }\n\n // 5. For prefix_except_default: URL without locale prefix = defaultLocale\n if (strategy === 'prefix_except_default') {\n return this.ctx.defaultLocale\n }\n\n // 6. Check getter (for no_prefix and other strategies)\n const fromGetter = getDefaultLocale?.()\n if (fromGetter) return fromGetter\n\n // 7. Return defaultLocale as fallback\n return this.ctx.defaultLocale\n }\n\n /**\n * Returns the route name for plugin translation loading.\n * If disablePageLocales is true, returns 'index'.\n */\n getPluginRouteName(route: ResolvedRouteLike, locale: string): string {\n if (this.ctx.disablePageLocales) {\n return 'index'\n }\n const baseName = this.getRouteBaseName(route)\n if (!baseName) {\n // Fallback: extract from route name\n const name = (route.name ?? '').toString()\n return name.replace(this.getLocalizedRouteNamePrefix(), '').replace(new RegExp(`-${locale}$`), '')\n }\n return baseName\n }\n\n /**\n * Returns displayName of the current locale, or null if not found.\n */\n getCurrentLocaleName(route: ResolvedRouteLike): string | null {\n const currentLocaleCode = this.getCurrentLocale(route)\n const localeObj = this.ctx.locales.find((l) => l.code === currentLocaleCode)\n return localeObj?.displayName ?? null\n }\n\n /**\n * Formats path for router.resolve based on strategy.\n * Each strategy should override this with its own logic.\n */\n abstract formatPathForResolve(path: string, fromLocale: string, toLocale: string): string\n}\n"],"names":["HASH_RE","AMPERSAND_RE","SLASH_RE","EQUAL_RE","PLUS_RE","ENC_CARET_RE","ENC_BACKTICK_RE","ENC_CURLY_OPEN_RE","ENC_PIPE_RE","ENC_CURLY_CLOSE_RE","ENC_SPACE_RE","encode","text","encodeHash","encodeQueryValue","input","encodeQueryKey","decode","decodeQueryKey","decodeQueryValue","parseQuery","parametersString","object","parameter","key","value","encodeQueryItem","_value","stringifyQuery","query","k","PROTOCOL_STRICT_REGEX","PROTOCOL_REGEX","PROTOCOL_RELATIVE_REGEX","JOIN_LEADING_SLASH_RE","hasProtocol","inputString","opts","hasTrailingSlash","respectQueryAndFragment","withoutTrailingSlash","withTrailingSlash","hasLeadingSlash","withoutLeadingSlash","withLeadingSlash","cleanDoubleSlashes","string_","withQuery","parsed","parseURL","mergedQuery","stringifyParsedURL","isEmptyURL","url","isNonEmptyURL","joinURL","base","segment","url2","_segment","isSamePath","p1","p2","withFragment","hash","protocolRelative","defaultProto","_specialProtoMatch","_proto","_pathname","parsePath","protocol","auth","hostAndPath","host","path","pathname","search","FILENAME_REGEX","parseFilename","matches","getPathSegments","pathOrSlashKey","normalizePath","p","normalizePathForCompare","collapsed","joinUrl","segments","valid","s","rest","joined","getCleanPath","buildUrl","fragment","transformNameKeyToPath","nameKey","out","i","nameKeyFirstSlash","idx","nameKeyLastSlash","parentKeyFromSlashKey","keyWithSlash","lastPathSegment","getPathWithoutLocale","localeCodes","clean","normalized","nextSlash","firstSegment","lengthToCut","remaining","getLocaleFromPath","getRouteBaseName","route","options","name","prefix","sortedLocales","a","b","locale","suffix","charBeforeLocale","buildLocalizedName","baseName","isIndexRouteName","localizedIndexPrefix","localePart","PARAM_PATTERN","RouteResolver","ctx","params","match","optKey","reqKey","catchAllKey","l","pathWithoutLocale","baseRouteName","keys","pathKey","asPath","firstSlash","lastSlash","targetLocale","gr","rule","customPath","pathForm","routeName","rl","allowed","code","nameSegments","parentKey","parentRules","BasePathStrategy","router","locales","utilGetRouteBaseName","mockRoute","customSegment","utilBuildLocalizedName","localeCode","baseUrl","resolvedPath","fullPath","target","source","result","basePath","_route","_targetLocale","sourceRoute","localizedNameWithSuffix","localizedNameWithoutSuffix","localizedName","resolved","resolveParams","paramKeys","pathTemplate","firstKey","pathSegments","replaceCount","templateSegments","pathWithParams","finalPath","withBase","normalizerGetPathWithoutLocale","normalizerGetLocaleFromPath","currentPath","localeFromPath","validCodes","allowedCodes","currentRoute","currentLocale","canonicalPath","canonical","hreflangs","localized","normalizedPath","targetName","fromLocale","toLocale","nameWithSuffix","nameWithoutSuffix","needsLocaleParam","i18nParams","newParams","newRoute","routeOrPath","raw","_currentRoute","inputName","_args","src","hasParams","resolvedNameStr","unlocalizedByName","routeWithParams","routeByLocalizedName","unlocalizedPath","keyFirstSlash","keyLastSlash","isNestedFirst","isNestedLast","isNested","parentPath","effectiveBaseName","pathToUse","baseNameForPath","pathStr","resolvedWithParams","cleanPath","getDefaultLocale","strategy","fromGetter","currentLocaleCode"],"mappings":"AA2FA,MAAMA,KAAU,MACVC,KAAe,MACfC,KAAW,OACXC,KAAW,MAEXC,IAAU,OACVC,IAAe,SACfC,KAAkB,SAClBC,KAAoB,SACpBC,KAAc,SACdC,KAAqB,SACrBC,KAAe;AAGrB,SAASC,EAAOC,GAAM;AACpB,SAAO,UAAU,KAAKA,CAAI,EAAE,QAAQJ,IAAa,GAAG;AACtD;AACA,SAASK,GAAWD,GAAM;AACxB,SAAOD,EAAOC,CAAI,EAAE,QAAQL,IAAmB,GAAG,EAAE,QAAQE,IAAoB,GAAG,EAAE,QAAQJ,GAAc,GAAG;AAChH;AACA,SAASS,EAAiBC,GAAO;AAC/B,SAAOJ,EAAO,OAAOI,KAAU,WAAWA,IAAQ,KAAK,UAAUA,CAAK,CAAC,EAAE,QAAQX,GAAS,KAAK,EAAE,QAAQM,IAAc,GAAG,EAAE,QAAQV,IAAS,KAAK,EAAE,QAAQC,IAAc,KAAK,EAAE,QAAQK,IAAiB,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