@i18n-micro/vue 1.3.12 → 1.4.4

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/dist/index.mjs CHANGED
@@ -1,786 +1,683 @@
1
- import { defineComponent as q, inject as S, h as g, computed as k, ref as Q, onMounted as ae, onUnmounted as oe, nextTick as re, shallowRef as z } from "vue";
2
- import { BaseI18n as le } from "@i18n-micro/core";
3
- import { FormatService as Pe, defaultPlural as $e, interpolate as Re } from "@i18n-micro/core";
4
- import { RouterLink as ie } from "vue-router";
5
- const W = /* @__PURE__ */ Symbol("i18n"), Y = /* @__PURE__ */ Symbol("i18n-locales"), ee = /* @__PURE__ */ Symbol("i18n-default-locale"), U = /* @__PURE__ */ Symbol("i18n-router-strategy"), ce = q({
6
- name: "I18nGroup",
7
- props: {
8
- prefix: {
9
- type: String,
10
- required: !0
11
- },
12
- groupClass: {
13
- type: String,
14
- default: ""
15
- }
16
- },
17
- setup(t, { slots: e }) {
18
- const a = S(W);
19
- if (!a)
20
- throw new Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
21
- const o = (c, r) => a.t(`${t.prefix}.${c}`, r, void 0, a.getRoute());
22
- return () => g(
23
- "div",
24
- {
25
- class: ["i18n-group", t.groupClass]
26
- },
27
- e.default?.({ prefix: t.prefix, t: o })
28
- );
29
- }
30
- }), se = q({
31
- name: "I18nLink",
32
- props: {
33
- to: {
34
- type: [String, Object],
35
- required: !0
36
- },
37
- activeStyle: {
38
- type: Object,
39
- default: () => ({})
40
- },
41
- localeRoute: {
42
- type: Function,
43
- default: void 0
44
- }
45
- },
46
- setup(t, { slots: e }) {
47
- const a = S(W), o = S(U, void 0);
48
- if (!a)
49
- throw new Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");
50
- const c = k(() => typeof t.to == "string" ? /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to) : !1), r = k(() => {
51
- if (c.value)
52
- return t.to;
53
- if (t.localeRoute) {
54
- const n = t.localeRoute(t.to);
55
- return typeof n == "string" ? n : n.path || "/";
56
- }
57
- if (!o?.resolvePath)
58
- return typeof t.to == "string" ? t.to : t.to.path || "/";
59
- const i = o.resolvePath(t.to, a.locale.value);
60
- return typeof i == "string" ? i : i.path || "/";
61
- }), s = k(() => {
62
- if (c.value || !o)
63
- return !1;
64
- const i = o.getCurrentPath().replace(/#.*$/, "").replace(/\/$/, ""), n = r.value.replace(/#.*$/, "").replace(/\/$/, "");
65
- return i === n;
66
- }), f = k(() => s.value ? t.activeStyle : {});
67
- return () => c.value ? g(
68
- "a",
69
- {
70
- href: r.value,
71
- target: "_blank",
72
- rel: "noopener noreferrer",
73
- style: f.value
74
- },
75
- e.default?.()
76
- ) : o?.linkComponent ? g(
77
- o.linkComponent,
78
- {
79
- to: r.value,
80
- style: f.value
81
- },
82
- { default: e.default }
83
- ) : g(
84
- "a",
85
- {
86
- href: r.value,
87
- style: f.value,
88
- onClick: (i) => {
89
- i.preventDefault(), o ? o.push({ path: r.value }) : window.location.href = r.value;
90
- }
91
- },
92
- e.default?.()
93
- );
94
- }
95
- }), ue = q({
96
- name: "I18nSwitcher",
97
- props: {
98
- customLabels: {
99
- type: Object,
100
- default: () => ({})
101
- },
102
- customWrapperStyle: {
103
- type: Object,
104
- default: () => ({})
105
- },
106
- customButtonStyle: {
107
- type: Object,
108
- default: () => ({})
109
- },
110
- customDropdownStyle: {
111
- type: Object,
112
- default: () => ({})
113
- },
114
- customItemStyle: {
115
- type: Object,
116
- default: () => ({})
117
- },
118
- customLinkStyle: {
119
- type: Object,
120
- default: () => ({})
121
- },
122
- customActiveLinkStyle: {
123
- type: Object,
124
- default: () => ({})
125
- },
126
- /**
127
- * Inline style applied to the switcher button when the *current* locale is
128
- * marked as `disabled: true` in the locale config.
129
- *
130
- * Note: disabled locales are omitted from the dropdown list, but the current
131
- * locale label is still shown on the button.
132
- */
133
- customDisabledLinkStyle: {
134
- type: Object,
135
- default: () => ({})
136
- },
137
- customIconStyle: {
138
- type: Object,
139
- default: () => ({})
140
- },
141
- locales: {
142
- type: Array,
143
- default: void 0
144
- },
145
- currentLocale: {
146
- type: [String, Function],
147
- default: void 0
148
- },
149
- getLocaleName: {
150
- type: Function,
151
- default: void 0
152
- },
153
- switchLocale: {
154
- type: Function,
155
- default: void 0
156
- },
157
- localeRoute: {
158
- type: Function,
159
- default: void 0
160
- }
161
- },
162
- setup(t, { slots: e }) {
163
- const a = S(W), o = S(U, void 0), c = S(Y, void 0);
164
- if (!a)
165
- throw new Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");
166
- if (!c && !t.locales)
167
- throw new Error(
168
- "[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop."
169
- );
170
- const r = k(() => t.locales || c || []), s = k(() => r.value.filter((u) => !u.disabled)), f = k(() => t.currentLocale !== void 0 ? typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale : a.locale.value), i = k(() => r.value.some((u) => u.code === f.value && u.disabled)), n = k(() => t.getLocaleName ? t.getLocaleName() || null : r.value.find((p) => p.code === a.locale.value)?.displayName || null), l = Q(!1), m = Q(null), v = (u) => {
171
- u && (u.stopPropagation(), u.preventDefault()), l.value = !l.value;
172
- }, L = (u) => t.customLabels[u.code] || u.displayName || u.code, T = k(() => {
173
- const u = r.value.find((p) => p.code === f.value);
174
- return u ? L(u) : n.value || f.value;
175
- }), P = async (u) => {
176
- if (l.value = !1, await re(), t.switchLocale) {
177
- t.switchLocale(u);
178
- return;
179
- }
180
- if (a.locale.value = u, !o)
181
- return;
182
- const p = o.getCurrentPath(), b = t.localeRoute ? (() => {
183
- const d = t.localeRoute(p, u);
184
- return typeof d == "string" ? d : d.path || "/";
185
- })() : o?.resolvePath ? (() => {
186
- const d = o.resolvePath(p, u);
187
- return typeof d == "string" ? d : d.path || "/";
188
- })() : p;
189
- o.push({ path: b });
190
- }, $ = {
191
- position: "relative",
192
- display: "inline-block",
193
- verticalAlign: "middle"
194
- }, M = {
195
- padding: "4px 12px",
196
- fontSize: "16px",
197
- cursor: "pointer",
198
- backgroundColor: "#fff",
199
- border: "1px solid #333",
200
- transition: "background-color 0.3s ease",
201
- display: "flex",
202
- alignItems: "center",
203
- justifyContent: "space-between"
204
- }, D = {
205
- position: "absolute",
206
- top: "100%",
207
- left: "0",
208
- zIndex: 1e3,
209
- backgroundColor: "#fff",
210
- border: "1px solid #333",
211
- listStyle: "none",
212
- padding: "0",
213
- margin: "4px 0 0 0",
214
- minWidth: "150px",
215
- boxShadow: "0 2px 8px rgba(0,0,0,0.15)"
216
- }, _ = {
217
- margin: "0",
218
- padding: "0"
219
- }, C = {
220
- display: "block",
221
- padding: "8px 12px",
222
- color: "#333",
223
- textDecoration: "none",
224
- transition: "background-color 0.3s ease",
225
- cursor: "pointer"
226
- }, G = {
227
- fontWeight: "bold",
228
- color: "#007bff",
229
- // Current locale is not a meaningful switch target
230
- cursor: "not-allowed"
231
- }, V = {
232
- marginLeft: "8px",
233
- display: "inline-block",
234
- transition: "transform 0.3s ease"
235
- }, F = {
236
- transform: "rotate(180deg)"
237
- }, y = (u) => u ? Array.isArray(u) ? u : [u] : [], O = (u) => {
238
- if (!l.value) return;
239
- const p = u.target;
240
- if (!p || !m.value) return;
241
- const b = m.value.contains(p), d = p.closest(".i18n-switcher-button") !== null;
242
- !b && !d && (l.value = !1);
243
- };
244
- return ae(() => {
245
- document.addEventListener("click", O);
246
- }), oe(() => {
247
- document.removeEventListener("click", O);
248
- }), () => {
249
- const u = [];
250
- e["before-button"] && u.push(...y(e["before-button"]()));
251
- const p = [];
252
- if (e["before-selected-locale"] && p.push(...y(e["before-selected-locale"]())), p.push(g("span", T.value)), e["after-selected-locale"] && p.push(...y(e["after-selected-locale"]())), p.push(
253
- g(
254
- "span",
255
- {
256
- style: {
257
- ...V,
258
- ...l.value ? F : {},
259
- ...t.customIconStyle
260
- }
261
- },
262
- "▼"
263
- )
264
- ), u.push(
265
- g(
266
- "button",
267
- {
268
- class: "i18n-switcher-button",
269
- style: {
270
- ...M,
271
- ...t.customButtonStyle,
272
- ...i.value ? t.customDisabledLinkStyle : {}
273
- },
274
- onClick: (b) => {
275
- b.preventDefault(), b.stopPropagation(), v(b);
276
- },
277
- type: "button",
278
- ariaHaspopup: !0,
279
- ariaExpanded: l.value
280
- },
281
- p
282
- )
283
- ), e["before-dropdown"] && u.push(...y(e["before-dropdown"]())), l.value) {
284
- const b = [];
285
- e["before-dropdown-items"] && b.push(...y(e["before-dropdown-items"]())), s.value.forEach((d) => {
286
- const A = [];
287
- e["before-item"] && A.push(...y(e["before-item"]({ locale: d })));
288
- const E = [];
289
- e["before-link-content"] && E.push(...y(e["before-link-content"]({ locale: d }))), E.push(L(d)), e["after-link-content"] && E.push(...y(e["after-link-content"]({ locale: d })));
290
- const B = typeof window < "u" ? window.location.pathname : "/", H = t.localeRoute ? t.localeRoute(B, d.code) : o?.resolvePath ? o.resolvePath(B, d.code) : B, j = typeof H == "string" ? H : H.path || "#", N = d.code === f.value;
291
- A.push(
292
- g(
293
- "a",
294
- {
295
- class: `switcher-locale-${d.code}`,
296
- href: typeof j == "string" ? j : "#",
297
- style: {
298
- ...C,
299
- ...N ? G : {},
300
- ...t.customLinkStyle,
301
- // active-specific customization wins over the generic link style
302
- // (matches the React/Preact/Solid switchers)
303
- ...N ? t.customActiveLinkStyle : {}
304
- },
305
- // Prevent default navigation, use only handleSwitchLocale
306
- onClick: (K) => {
307
- K.preventDefault(), K.stopPropagation(), P(d.code);
308
- }
309
- },
310
- E
311
- )
312
- ), e["after-item"] && A.push(...y(e["after-item"]({ locale: d }))), b.push(
313
- g(
314
- "li",
315
- {
316
- key: d.code,
317
- style: { ..._, ...t.customItemStyle }
318
- },
319
- A
320
- )
321
- );
322
- }), e["after-dropdown-items"] && b.push(...y(e["after-dropdown-items"]())), u.push(
323
- g(
324
- "ul",
325
- {
326
- class: "i18n-switcher-dropdown",
327
- style: { ...D, ...t.customDropdownStyle }
328
- },
329
- b
330
- )
331
- );
332
- }
333
- return e["after-dropdown"] && u.push(...y(e["after-dropdown"]())), g(
334
- "div",
335
- {
336
- ref: m,
337
- class: "i18n-switcher-wrapper",
338
- style: { ...$, ...t.customWrapperStyle }
339
- },
340
- u
341
- );
342
- };
343
- }
344
- }), fe = q({
345
- name: "I18nT",
346
- props: {
347
- keypath: {
348
- type: String,
349
- required: !0
350
- },
351
- plural: {
352
- type: [Number, String]
353
- },
354
- tag: {
355
- type: String,
356
- default: "span"
357
- },
358
- params: {
359
- type: Object,
360
- default: () => ({})
361
- },
362
- defaultValue: {
363
- type: String,
364
- default: ""
365
- },
366
- html: {
367
- type: Boolean,
368
- default: !1
369
- },
370
- hideIfEmpty: {
371
- type: Boolean,
372
- default: !1
373
- },
374
- customPluralRule: {
375
- type: Function,
376
- default: null
377
- },
378
- number: {
379
- type: [Number, String]
380
- },
381
- date: {
382
- type: [Date, String, Number]
383
- },
384
- relativeDate: {
385
- type: [Date, String, Number]
386
- }
387
- },
388
- setup(t, { slots: e, attrs: a }) {
389
- const o = S(W);
390
- if (!o)
391
- throw new Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
392
- return () => {
393
- const c = {}, r = o.getRoute();
394
- if (t.number !== void 0) {
395
- const n = Number(t.number), l = o.tn(n), m = o.t(t.keypath, { number: l, ...t.params }, void 0, r);
396
- return g(t.tag, { ...a, innerHTML: m });
397
- }
398
- if (t.date !== void 0) {
399
- const n = o.td(t.date), l = o.t(t.keypath, { date: n, ...t.params }, void 0, r);
400
- return g(t.tag, { ...a, innerHTML: l });
401
- }
402
- if (t.relativeDate !== void 0) {
403
- const n = o.tdr(t.relativeDate), l = o.t(t.keypath, { relativeDate: n, ...t.params }, void 0, r);
404
- return g(t.tag, { ...a, innerHTML: l });
405
- }
406
- if (t.plural !== void 0) {
407
- const n = Number.parseInt(t.plural.toString(), 10);
408
- if (t.customPluralRule) {
409
- const l = t.customPluralRule(
410
- t.keypath,
411
- n,
412
- t.params,
413
- o.locale.value,
414
- (m, v, L) => o.t(m, v, L, r)
415
- );
416
- return g(t.tag, { ...a, innerHTML: l || "" });
417
- } else {
418
- const l = o.tc(t.keypath, { count: n, ...t.params });
419
- return g(t.tag, { ...a, innerHTML: l });
420
- }
421
- }
422
- const s = (o.t(t.keypath, { ...t.params, ...c }, void 0, r) ?? "").toString();
423
- if (t.hideIfEmpty && !s.trim())
424
- return t.defaultValue ?? null;
425
- if (t.html)
426
- return g(t.tag, { ...a, innerHTML: s });
427
- if (e.default)
428
- return g(t.tag, a, e.default({ translation: s }));
429
- const f = [];
430
- let i = 0;
431
- for (const [n, l] of Object.entries(e)) {
432
- if (n === "default") continue;
433
- const m = `{${n}}`, v = s.indexOf(m, i);
434
- v !== -1 && (v > i && f.push(s.slice(i, v)), l && f.push(g(l)), i = v + m.length);
435
- }
436
- return i < s.length && f.push(s.slice(i)), e.default ? g(t.tag, a, e.default({ children: f })) : f.length > 0 ? g(t.tag, a, f) : g(t.tag, a, s);
437
- };
438
- }
1
+ import { computed as e, defineComponent as t, h as n, inject as r, nextTick as i, onMounted as a, onUnmounted as o, ref as s, shallowRef as c } from "vue";
2
+ import { BaseI18n as l, FormatService as u, defaultPlural as d, interpolate as f } from "@i18n-micro/core";
3
+ //#region src/injection.ts
4
+ var p = Symbol("i18n"), m = Symbol("i18n-locales"), h = Symbol("i18n-default-locale"), g = Symbol("i18n-router-strategy"), _ = t({
5
+ name: "I18nGroup",
6
+ props: {
7
+ prefix: {
8
+ type: String,
9
+ required: !0
10
+ },
11
+ groupClass: {
12
+ type: String,
13
+ default: ""
14
+ }
15
+ },
16
+ setup(e, { slots: t }) {
17
+ let i = r(p);
18
+ if (!i) throw Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
19
+ let a = (t, n) => i.t(`${e.prefix}.${t}`, n, void 0, i.getRoute());
20
+ return () => n("div", { class: ["i18n-group", e.groupClass] }, t.default?.({
21
+ prefix: e.prefix,
22
+ t: a
23
+ }));
24
+ }
25
+ }), v = t({
26
+ name: "I18nLink",
27
+ props: {
28
+ to: {
29
+ type: [String, Object],
30
+ required: !0
31
+ },
32
+ activeStyle: {
33
+ type: Object,
34
+ default: () => ({})
35
+ },
36
+ localeRoute: {
37
+ type: Function,
38
+ default: void 0
39
+ }
40
+ },
41
+ setup(t, { slots: i }) {
42
+ let a = r(p), o = r(g, void 0);
43
+ if (!a) throw Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");
44
+ let s = e(() => typeof t.to == "string" && /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to)), c = e(() => {
45
+ if (s.value) return t.to;
46
+ if (t.localeRoute) {
47
+ let e = t.localeRoute(t.to);
48
+ return typeof e == "string" ? e : e.path || "/";
49
+ }
50
+ if (!o?.resolvePath) return typeof t.to == "string" ? t.to : t.to.path || "/";
51
+ let e = o.resolvePath(t.to, a.locale.value);
52
+ return typeof e == "string" ? e : e.path || "/";
53
+ }), l = e(() => s.value || !o ? !1 : o.getCurrentPath().replace(/#.*$/, "").replace(/\/$/, "") === c.value.replace(/#.*$/, "").replace(/\/$/, "")), u = e(() => l.value ? t.activeStyle : {});
54
+ return () => s.value ? n("a", {
55
+ href: c.value,
56
+ target: "_blank",
57
+ rel: "noopener noreferrer",
58
+ style: u.value
59
+ }, i.default?.()) : o?.linkComponent ? n(o.linkComponent, {
60
+ to: c.value,
61
+ style: u.value
62
+ }, { default: i.default }) : n("a", {
63
+ href: c.value,
64
+ style: u.value,
65
+ onClick: (e) => {
66
+ e.preventDefault(), o ? o.push({ path: c.value }) : window.location.href = c.value;
67
+ }
68
+ }, i.default?.());
69
+ }
70
+ }), y = t({
71
+ name: "I18nSwitcher",
72
+ props: {
73
+ customLabels: {
74
+ type: Object,
75
+ default: () => ({})
76
+ },
77
+ customWrapperStyle: {
78
+ type: Object,
79
+ default: () => ({})
80
+ },
81
+ customButtonStyle: {
82
+ type: Object,
83
+ default: () => ({})
84
+ },
85
+ customDropdownStyle: {
86
+ type: Object,
87
+ default: () => ({})
88
+ },
89
+ customItemStyle: {
90
+ type: Object,
91
+ default: () => ({})
92
+ },
93
+ customLinkStyle: {
94
+ type: Object,
95
+ default: () => ({})
96
+ },
97
+ customActiveLinkStyle: {
98
+ type: Object,
99
+ default: () => ({})
100
+ },
101
+ customDisabledLinkStyle: {
102
+ type: Object,
103
+ default: () => ({})
104
+ },
105
+ customIconStyle: {
106
+ type: Object,
107
+ default: () => ({})
108
+ },
109
+ locales: {
110
+ type: Array,
111
+ default: void 0
112
+ },
113
+ currentLocale: {
114
+ type: [String, Function],
115
+ default: void 0
116
+ },
117
+ getLocaleName: {
118
+ type: Function,
119
+ default: void 0
120
+ },
121
+ switchLocale: {
122
+ type: Function,
123
+ default: void 0
124
+ },
125
+ localeRoute: {
126
+ type: Function,
127
+ default: void 0
128
+ }
129
+ },
130
+ setup(t, { slots: c }) {
131
+ let l = r(p), u = r(g, void 0), d = r(m, void 0);
132
+ if (!l) throw Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");
133
+ if (!d && !t.locales) throw Error("[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop.");
134
+ let f = e(() => t.locales || d || []), h = e(() => f.value.filter((e) => !e.disabled)), _ = e(() => t.currentLocale === void 0 ? l.locale.value : typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale), v = e(() => f.value.some((e) => e.code === _.value && e.disabled)), y = e(() => t.getLocaleName ? t.getLocaleName() || null : f.value.find((e) => e.code === l.locale.value)?.displayName || null), b = s(!1), x = s(null), S = (e) => {
135
+ e && (e.stopPropagation(), e.preventDefault()), b.value = !b.value;
136
+ }, C = (e) => t.customLabels[e.code] || e.displayName || e.code, w = e(() => {
137
+ let e = f.value.find((e) => e.code === _.value);
138
+ return e ? C(e) : y.value || _.value;
139
+ }), T = async (e) => {
140
+ if (b.value = !1, await i(), t.switchLocale) {
141
+ t.switchLocale(e);
142
+ return;
143
+ }
144
+ if (l.locale.value = e, !u) return;
145
+ let n = u.getCurrentPath(), r = t.localeRoute ? (() => {
146
+ let r = t.localeRoute(n, e);
147
+ return typeof r == "string" ? r : r.path || "/";
148
+ })() : u?.resolvePath ? (() => {
149
+ let t = u.resolvePath(n, e);
150
+ return typeof t == "string" ? t : t.path || "/";
151
+ })() : n;
152
+ u.push({ path: r });
153
+ }, E = {
154
+ position: "relative",
155
+ display: "inline-block",
156
+ verticalAlign: "middle"
157
+ }, D = {
158
+ padding: "4px 12px",
159
+ fontSize: "16px",
160
+ cursor: "pointer",
161
+ backgroundColor: "#fff",
162
+ border: "1px solid #333",
163
+ transition: "background-color 0.3s ease",
164
+ display: "flex",
165
+ alignItems: "center",
166
+ justifyContent: "space-between"
167
+ }, O = {
168
+ position: "absolute",
169
+ top: "100%",
170
+ left: "0",
171
+ zIndex: 1e3,
172
+ backgroundColor: "#fff",
173
+ border: "1px solid #333",
174
+ listStyle: "none",
175
+ padding: "0",
176
+ margin: "4px 0 0 0",
177
+ minWidth: "150px",
178
+ boxShadow: "0 2px 8px rgba(0,0,0,0.15)"
179
+ }, k = {
180
+ margin: "0",
181
+ padding: "0"
182
+ }, A = {
183
+ display: "block",
184
+ padding: "8px 12px",
185
+ color: "#333",
186
+ textDecoration: "none",
187
+ transition: "background-color 0.3s ease",
188
+ cursor: "pointer"
189
+ }, j = {
190
+ fontWeight: "bold",
191
+ color: "#007bff",
192
+ cursor: "not-allowed"
193
+ }, M = {
194
+ marginLeft: "8px",
195
+ display: "inline-block",
196
+ transition: "transform 0.3s ease"
197
+ }, N = { transform: "rotate(180deg)" }, P = (e) => e ? Array.isArray(e) ? e : [e] : [], F = (e) => {
198
+ if (!b.value) return;
199
+ let t = e.target;
200
+ if (!t || !x.value) return;
201
+ let n = x.value.contains(t), r = t.closest(".i18n-switcher-button") !== null;
202
+ !n && !r && (b.value = !1);
203
+ };
204
+ return a(() => {
205
+ document.addEventListener("click", F);
206
+ }), o(() => {
207
+ document.removeEventListener("click", F);
208
+ }), () => {
209
+ let e = [];
210
+ c["before-button"] && e.push(...P(c["before-button"]()));
211
+ let r = [];
212
+ if (c["before-selected-locale"] && r.push(...P(c["before-selected-locale"]())), r.push(n("span", w.value)), c["after-selected-locale"] && r.push(...P(c["after-selected-locale"]())), r.push(n("span", { style: {
213
+ ...M,
214
+ ...b.value ? N : {},
215
+ ...t.customIconStyle
216
+ } }, "▼")), e.push(n("button", {
217
+ class: "i18n-switcher-button",
218
+ style: {
219
+ ...D,
220
+ ...t.customButtonStyle,
221
+ ...v.value ? t.customDisabledLinkStyle : {}
222
+ },
223
+ onClick: (e) => {
224
+ e.preventDefault(), e.stopPropagation(), S(e);
225
+ },
226
+ type: "button",
227
+ ariaHaspopup: !0,
228
+ ariaExpanded: b.value
229
+ }, r)), c["before-dropdown"] && e.push(...P(c["before-dropdown"]())), b.value) {
230
+ let r = [];
231
+ c["before-dropdown-items"] && r.push(...P(c["before-dropdown-items"]())), h.value.forEach((e) => {
232
+ let i = [];
233
+ c["before-item"] && i.push(...P(c["before-item"]({ locale: e })));
234
+ let a = [];
235
+ c["before-link-content"] && a.push(...P(c["before-link-content"]({ locale: e }))), a.push(C(e)), c["after-link-content"] && a.push(...P(c["after-link-content"]({ locale: e })));
236
+ let o = typeof window < "u" ? window.location.pathname : "/", s = t.localeRoute ? t.localeRoute(o, e.code) : u?.resolvePath ? u.resolvePath(o, e.code) : o, l = typeof s == "string" ? s : s.path || "#", d = e.code === _.value;
237
+ i.push(n("a", {
238
+ class: `switcher-locale-${e.code}`,
239
+ href: typeof l == "string" ? l : "#",
240
+ style: {
241
+ ...A,
242
+ ...d ? j : {},
243
+ ...t.customLinkStyle,
244
+ ...d ? t.customActiveLinkStyle : {}
245
+ },
246
+ onClick: (t) => {
247
+ t.preventDefault(), t.stopPropagation(), T(e.code);
248
+ }
249
+ }, a)), c["after-item"] && i.push(...P(c["after-item"]({ locale: e }))), r.push(n("li", {
250
+ key: e.code,
251
+ style: {
252
+ ...k,
253
+ ...t.customItemStyle
254
+ }
255
+ }, i));
256
+ }), c["after-dropdown-items"] && r.push(...P(c["after-dropdown-items"]())), e.push(n("ul", {
257
+ class: "i18n-switcher-dropdown",
258
+ style: {
259
+ ...O,
260
+ ...t.customDropdownStyle
261
+ }
262
+ }, r));
263
+ }
264
+ return c["after-dropdown"] && e.push(...P(c["after-dropdown"]())), n("div", {
265
+ ref: x,
266
+ class: "i18n-switcher-wrapper",
267
+ style: {
268
+ ...E,
269
+ ...t.customWrapperStyle
270
+ }
271
+ }, e);
272
+ };
273
+ }
274
+ }), b = t({
275
+ name: "I18nT",
276
+ inheritAttrs: !1,
277
+ props: {
278
+ keypath: {
279
+ type: String,
280
+ required: !0
281
+ },
282
+ plural: { type: [Number, String] },
283
+ tag: {
284
+ type: String,
285
+ default: "span"
286
+ },
287
+ params: {
288
+ type: Object,
289
+ default: () => ({})
290
+ },
291
+ defaultValue: {
292
+ type: String,
293
+ default: ""
294
+ },
295
+ html: {
296
+ type: Boolean,
297
+ default: !1
298
+ },
299
+ hideIfEmpty: {
300
+ type: Boolean,
301
+ default: !1
302
+ },
303
+ customPluralRule: {
304
+ type: Function,
305
+ default: null
306
+ },
307
+ number: { type: [Number, String] },
308
+ date: { type: [
309
+ Date,
310
+ String,
311
+ Number
312
+ ] },
313
+ relativeDate: { type: [
314
+ Date,
315
+ String,
316
+ Number
317
+ ] }
318
+ },
319
+ setup(e, { slots: t, attrs: i }) {
320
+ let a = r(p);
321
+ if (!a) throw Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
322
+ return () => {
323
+ let r = {}, o = a.getRoute(), s = { ...i };
324
+ delete s.innerHTML;
325
+ let c = (t) => e.html ? n(e.tag, {
326
+ ...s,
327
+ innerHTML: t
328
+ }) : n(e.tag, s, t);
329
+ if (e.number !== void 0) {
330
+ let t = Number(e.number), n = a.tn(t), r = a.t(e.keypath, {
331
+ number: n,
332
+ ...e.params
333
+ }, void 0, o);
334
+ return c(String(r ?? ""));
335
+ }
336
+ if (e.date !== void 0) {
337
+ let t = a.td(e.date), n = a.t(e.keypath, {
338
+ date: t,
339
+ ...e.params
340
+ }, void 0, o);
341
+ return c(String(n ?? ""));
342
+ }
343
+ if (e.relativeDate !== void 0) {
344
+ let t = a.tdr(e.relativeDate), n = a.t(e.keypath, {
345
+ relativeDate: t,
346
+ ...e.params
347
+ }, void 0, o);
348
+ return c(String(n ?? ""));
349
+ }
350
+ if (e.plural !== void 0) {
351
+ let t = Number.parseInt(e.plural.toString(), 10);
352
+ return e.customPluralRule ? c(e.customPluralRule(e.keypath, t, e.params, a.locale.value, (e, t, n) => a.t(e, t, n, o)) || "") : c(a.tc(e.keypath, {
353
+ count: t,
354
+ ...e.params
355
+ }));
356
+ }
357
+ let l = (a.t(e.keypath, {
358
+ ...e.params,
359
+ ...r
360
+ }, void 0, o) ?? "").toString();
361
+ if (e.hideIfEmpty && !l.trim()) return e.defaultValue ?? null;
362
+ if (e.html) return c(l);
363
+ if (t.default) return n(e.tag, s, t.default({ translation: l }));
364
+ let u = [], d = 0;
365
+ for (let [e, r] of Object.entries(t)) {
366
+ if (e === "default") continue;
367
+ let t = `{${e}}`, i = l.indexOf(t, d);
368
+ i !== -1 && (i > d && u.push(l.slice(d, i)), r && u.push(n(r)), d = i + t.length);
369
+ }
370
+ return d < l.length && u.push(l.slice(d)), t.default ? n(e.tag, s, t.default({ children: u })) : u.length > 0 ? n(e.tag, s, u) : n(e.tag, s, l);
371
+ };
372
+ }
439
373
  });
440
- function J(t) {
441
- return t.iso?.trim() || String(t.code);
374
+ //#endregion
375
+ //#region ../utils/dist/resolve-hreflang.mjs
376
+ function x(e) {
377
+ return e.iso?.trim() || String(e.code);
442
378
  }
443
- function te(t) {
444
- const e = t.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);
445
- return e ? { language: e[1], region: e[2] } : { language: t };
379
+ function S(e) {
380
+ let t = e.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);
381
+ return t ? {
382
+ language: t[1],
383
+ region: t[2]
384
+ } : { language: e };
446
385
  }
447
- function de(t, e = {}) {
448
- const { hreflangBaseLanguage: a = !1 } = e;
449
- if (!a)
450
- return t.map((s) => {
451
- const f = String(s.code);
452
- return { hreflang: J(s), localeCode: f };
453
- });
454
- const o = /* @__PURE__ */ new Map();
455
- for (const s of t) {
456
- const f = String(s.code), i = J(s), { language: n, region: l } = te(i);
457
- n && l && !o.has(n) && o.set(n, f), o.set(i, f);
458
- }
459
- const c = /* @__PURE__ */ new Set(), r = [];
460
- for (const s of t) {
461
- const f = String(s.code), i = J(s), { language: n, region: l } = te(i);
462
- n && l && o.get(n) === f && !c.has(n) && (c.add(n), r.push({ hreflang: n, localeCode: f })), c.has(i) || (c.add(i), r.push({ hreflang: i, localeCode: f }));
463
- }
464
- return r;
386
+ function C(e, t = {}) {
387
+ let { hreflangBaseLanguage: n = !1 } = t;
388
+ if (!n) return e.map((e) => {
389
+ let t = String(e.code);
390
+ return {
391
+ hreflang: x(e),
392
+ localeCode: t
393
+ };
394
+ });
395
+ let r = /* @__PURE__ */ new Map();
396
+ for (let t of e) {
397
+ let e = String(t.code), n = x(t), { language: i, region: a } = S(n);
398
+ i && a && !r.has(i) && r.set(i, e), r.set(n, e);
399
+ }
400
+ let i = /* @__PURE__ */ new Set(), a = [];
401
+ for (let t of e) {
402
+ let e = String(t.code), n = x(t), { language: o, region: s } = S(n);
403
+ o && s && r.get(o) === e && !i.has(o) && (i.add(o), a.push({
404
+ hreflang: o,
405
+ localeCode: e
406
+ })), i.has(n) || (i.add(n), a.push({
407
+ hreflang: n,
408
+ localeCode: e
409
+ }));
410
+ }
411
+ return a;
465
412
  }
466
- function X(t) {
467
- const e = t.og?.trim();
468
- if (e) return e;
469
- const a = t.iso?.trim();
470
- if (!a) return null;
471
- const o = a.indexOf("_");
472
- if (o > 0) {
473
- const r = a.slice(0, o), s = a.slice(o + 1);
474
- if (r.length >= 2 && s.length === 2)
475
- return `${r.toLowerCase()}_${s.toUpperCase()}`;
476
- }
477
- const c = a.indexOf("-");
478
- if (c > 0) {
479
- const r = a.slice(0, c), s = a.slice(c + 1);
480
- if (r.length >= 2 && s.length === 2 && /^[A-Za-z]{2}$/.test(s))
481
- return `${r.toLowerCase()}_${s.toUpperCase()}`;
482
- }
483
- return null;
413
+ //#endregion
414
+ //#region ../utils/dist/resolve-og-locale.mjs
415
+ function w(e) {
416
+ let t = e.og?.trim();
417
+ if (t) return t;
418
+ let n = e.iso?.trim();
419
+ if (!n) return null;
420
+ let r = n.indexOf("_");
421
+ if (r > 0) {
422
+ let e = n.slice(0, r), t = n.slice(r + 1);
423
+ if (e.length >= 2 && t.length === 2) return `${e.toLowerCase()}_${t.toUpperCase()}`;
424
+ }
425
+ let i = n.indexOf("-");
426
+ if (i > 0) {
427
+ let e = n.slice(0, i), t = n.slice(i + 1);
428
+ if (e.length >= 2 && t.length === 2 && /^[A-Za-z]{2}$/.test(t)) return `${e.toLowerCase()}_${t.toUpperCase()}`;
429
+ }
430
+ return null;
484
431
  }
485
- function ne(t, e = {}) {
486
- if (X(t) !== null || e.missingWarn === !1 || process.env.NODE_ENV === "production") return;
487
- const a = e.tag ?? "og:locale", o = String(t.code ?? "unknown"), c = t.iso ? `, iso: '${t.iso}'` : "";
488
- console.warn(
489
- `[i18n] Cannot derive ${a} for locale '${o}'${c}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`
490
- );
432
+ function T(e, t = {}) {
433
+ if (w(e) !== null || t.missingWarn === !1 || process.env.NODE_ENV === "production") return;
434
+ let n = t.tag ?? "og:locale", r = String(e.code ?? "unknown"), i = e.iso ? `, iso: '${e.iso}'` : "";
435
+ console.warn(`[i18n] Cannot derive ${n} for locale '${r}'${i}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`);
491
436
  }
492
- function he(t) {
493
- const e = S(W), a = S(U, void 0), o = S(Y, void 0), c = S(ee, void 0);
494
- if (!e)
495
- throw new Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");
496
- if (!o)
497
- throw new Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");
498
- if (!c)
499
- throw new Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");
500
- const r = t?.locales || o, s = t?.defaultLocale || c, f = (i, n) => a?.resolvePath ? a.resolvePath(i, n || e.locale.value) : i;
501
- return {
502
- // Direct access to instance
503
- instance: e,
504
- // Locale (reactive)
505
- locale: k({
506
- get: () => e.locale.value,
507
- set: (i) => {
508
- e.locale.value = i;
509
- }
510
- }),
511
- // Locale helpers
512
- getLocales: () => r,
513
- defaultLocale: () => s,
514
- getLocaleName: () => r.find((n) => n.code === e.locale.value)?.displayName || null,
515
- // Routing helpers
516
- localeRoute: f,
517
- localePath: (i, n) => {
518
- const l = f(i, n);
519
- return typeof l == "string" ? l : l.path || "/";
520
- },
521
- switchLocale: (i) => {
522
- if (e.locale.value = i, a) {
523
- const n = a.getCurrentPath(), l = f(n, i);
524
- a.push(typeof l == "string" ? { path: l } : { path: l.path || "/" });
525
- }
526
- },
527
- // Translation methods (delegate to instance)
528
- t: e.t.bind(e),
529
- ts: e.ts.bind(e),
530
- tc: e.tc.bind(e),
531
- tn: e.tn.bind(e),
532
- td: e.td.bind(e),
533
- tdr: e.tdr.bind(e),
534
- has: e.has.bind(e),
535
- resolveTranslations: e.resolveTranslations.bind(e),
536
- setTranslation: e.setTranslation.bind(e),
537
- // Route management
538
- setRoute: e.setRoute.bind(e),
539
- getRoute: e.getRoute.bind(e),
540
- getLocale: () => e.locale.value,
541
- // Translation management
542
- addTranslations: e.addTranslations.bind(e),
543
- addRouteTranslations: e.addRouteTranslations.bind(e),
544
- mergeTranslations: e.mergeTranslations.bind(e),
545
- clearCache: e.clearCache.bind(e)
546
- };
437
+ //#endregion
438
+ //#region src/use-i18n.ts
439
+ function E(t) {
440
+ let n = r(p), i = r(g, void 0), a = r(m, void 0), o = r(h, void 0);
441
+ if (!n) throw Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");
442
+ if (!a) throw Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");
443
+ if (!o) throw Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");
444
+ let s = t?.locales || a, c = t?.defaultLocale || o, l = (e, t) => i?.resolvePath ? i.resolvePath(e, t || n.locale.value) : e;
445
+ return {
446
+ instance: n,
447
+ locale: e({
448
+ get: () => n.locale.value,
449
+ set: (e) => {
450
+ n.locale.value = e;
451
+ }
452
+ }),
453
+ getLocales: () => s,
454
+ defaultLocale: () => c,
455
+ getLocaleName: () => s.find((e) => e.code === n.locale.value)?.displayName || null,
456
+ localeRoute: l,
457
+ localePath: (e, t) => {
458
+ let n = l(e, t);
459
+ return typeof n == "string" ? n : n.path || "/";
460
+ },
461
+ switchLocale: (e) => {
462
+ if (n.locale.value = e, i) {
463
+ let t = i.getCurrentPath(), n = l(t, e);
464
+ i.push(typeof n == "string" ? { path: n } : { path: n.path || "/" });
465
+ }
466
+ },
467
+ t: n.t.bind(n),
468
+ ts: n.ts.bind(n),
469
+ tc: n.tc.bind(n),
470
+ tn: n.tn.bind(n),
471
+ td: n.td.bind(n),
472
+ tdr: n.tdr.bind(n),
473
+ has: n.has.bind(n),
474
+ resolveTranslations: n.resolveTranslations.bind(n),
475
+ setTranslation: n.setTranslation.bind(n),
476
+ setRoute: n.setRoute.bind(n),
477
+ getRoute: n.getRoute.bind(n),
478
+ getLocale: () => n.locale.value,
479
+ addTranslations: n.addTranslations.bind(n),
480
+ addRouteTranslations: n.addRouteTranslations.bind(n),
481
+ mergeTranslations: n.mergeTranslations.bind(n),
482
+ clearCache: n.clearCache.bind(n)
483
+ };
547
484
  }
548
- function be(t = {}) {
549
- const { addDirAttribute: e = !0, identifierAttribute: a = "id", addSeoAttributes: o = !0, baseUrl: c = "/", hreflangBaseLanguage: r = !1 } = t, { getLocale: s, getLocales: f, localeRoute: i } = he(), n = S(U, void 0), l = Q({
550
- htmlAttrs: {},
551
- link: [],
552
- meta: []
553
- });
554
- function m(L, T) {
555
- const P = new URL(L, "http://localhost"), $ = new URLSearchParams(P.search), M = {};
556
- for (const _ of T)
557
- $.has(_) && (M[_] = $.get(_));
558
- const D = new URLSearchParams(M);
559
- return D.toString() ? `${P.pathname}?${D.toString()}` : P.pathname;
560
- }
561
- function v(L = []) {
562
- if (!n) {
563
- l.value = { htmlAttrs: {}, link: [], meta: [] };
564
- return;
565
- }
566
- const T = s(), P = f(), $ = P.find((h) => h.code === T);
567
- if (!$)
568
- return;
569
- const M = $.iso || T, D = X($), _ = $.dir || "auto";
570
- let C = n.getCurrentPath();
571
- C.startsWith("/") || (C = `/${C}`);
572
- const G = C.split("/").filter(Boolean), V = P.find((h) => G[0] === h.code);
573
- let F = C, y, O;
574
- const u = typeof c == "function" ? c() : c;
575
- if (V) {
576
- F = C.slice(V.code.length + 1) || "/", y = m(F, L);
577
- const h = `/${T}`;
578
- O = `${u}${h}${y.startsWith("/") ? "" : "/"}${y}`;
579
- } else
580
- y = m(C, L), O = `${u}${y.startsWith("/") ? "" : "/"}${y}`;
581
- const p = {
582
- lang: M,
583
- ...e ? { dir: _ } : {}
584
- };
585
- if (!o) {
586
- l.value = { htmlAttrs: p, link: [], meta: [] };
587
- return;
588
- }
589
- const b = P.filter((h) => !h.disabled && h.seo !== !1);
590
- D || ne($, { tag: "og:locale" });
591
- const d = D ? {
592
- [a]: "i18n-og",
593
- property: "og:locale",
594
- content: D
595
- } : null, A = {
596
- [a]: "i18n-og-url",
597
- property: "og:url",
598
- content: O
599
- }, E = b.filter((h) => h.code !== T).map((h) => {
600
- const x = X(h);
601
- return x ? {
602
- [a]: `i18n-og-alt-${x}`,
603
- property: "og:locale:alternate",
604
- content: x
605
- } : (ne(h, { tag: "og:locale:alternate" }), null);
606
- }).filter((h) => h !== null), B = {
607
- [a]: "i18n-can",
608
- rel: "canonical",
609
- href: O
610
- }, H = (() => {
611
- if (!i || !n)
612
- return [];
613
- const h = /* @__PURE__ */ new Map(), x = n.getCurrentPath();
614
- for (const w of b) {
615
- const I = i(x, w.code), R = typeof I == "string" ? I : I?.path || "/";
616
- if (!R) continue;
617
- let Z;
618
- R.startsWith("http://") || R.startsWith("https://") ? Z = R : Z = `${typeof c == "function" ? c() : c}${R.startsWith("/") ? "" : "/"}${R}`, h.set(String(w.code), Z);
619
- }
620
- return de(b, { hreflangBaseLanguage: r }).flatMap(({ hreflang: w, localeCode: I }) => {
621
- const R = h.get(I);
622
- return R ? [
623
- {
624
- [a]: `i18n-alternate-${w}`,
625
- rel: "alternate",
626
- href: R,
627
- hreflang: w
628
- }
629
- ] : [];
630
- });
631
- })(), j = S(ee, void 0);
632
- let N = null;
633
- const K = j ? P.find((h) => h.code === j) : void 0;
634
- if (i && n && j && K?.seo !== !1) {
635
- const h = n.getCurrentPath(), x = i(h, j), w = typeof x == "string" ? x : x?.path || "/";
636
- if (w) {
637
- let I;
638
- w.startsWith("http://") || w.startsWith("https://") ? I = w : I = `${typeof c == "function" ? c() : c}${w.startsWith("/") ? "" : "/"}${w}`, N = {
639
- [a]: "i18n-xd",
640
- rel: "alternate",
641
- href: I,
642
- hreflang: "x-default"
643
- };
644
- }
645
- }
646
- l.value = {
647
- htmlAttrs: p,
648
- meta: [...d ? [d] : [], A, ...E],
649
- link: [B, ...H, ...N ? [N] : []]
650
- };
651
- }
652
- return {
653
- metaObject: l,
654
- updateMeta: v
655
- };
485
+ //#endregion
486
+ //#region src/composables/use-locale-head.ts
487
+ function D(e = {}) {
488
+ let { addDirAttribute: t = !0, identifierAttribute: n = "id", addSeoAttributes: i = !0, baseUrl: a = "/", hreflangBaseLanguage: o = !1 } = e, { getLocale: c, getLocales: l, localeRoute: u } = E(), d = r(g, void 0), f = s({
489
+ htmlAttrs: {},
490
+ link: [],
491
+ meta: []
492
+ });
493
+ function p(e, t) {
494
+ let n = new URL(e, "http://localhost"), r = new URLSearchParams(n.search), i = {};
495
+ for (let e of t) r.has(e) && (i[e] = r.get(e));
496
+ let a = new URLSearchParams(i);
497
+ return a.toString() ? `${n.pathname}?${a.toString()}` : n.pathname;
498
+ }
499
+ function m(e = []) {
500
+ if (!d) {
501
+ f.value = {
502
+ htmlAttrs: {},
503
+ link: [],
504
+ meta: []
505
+ };
506
+ return;
507
+ }
508
+ let s = c(), m = l(), g = m.find((e) => e.code === s);
509
+ if (!g) return;
510
+ let _ = g.iso || s, v = w(g), y = g.dir || "auto", b = d.getCurrentPath();
511
+ b.startsWith("/") || (b = `/${b}`);
512
+ let x = b.split("/").filter(Boolean), S = m.find((e) => x[0] === e.code), E = b, D, O, k = typeof a == "function" ? a() : a;
513
+ S ? (E = b.slice(S.code.length + 1) || "/", D = p(E, e), O = `${k}${`/${s}`}${D.startsWith("/") ? "" : "/"}${D}`) : (D = p(b, e), O = `${k}${D.startsWith("/") ? "" : "/"}${D}`);
514
+ let A = {
515
+ lang: _,
516
+ ...t ? { dir: y } : {}
517
+ };
518
+ if (!i) {
519
+ f.value = {
520
+ htmlAttrs: A,
521
+ link: [],
522
+ meta: []
523
+ };
524
+ return;
525
+ }
526
+ let j = m.filter((e) => !e.disabled && e.seo !== !1);
527
+ v || T(g, { tag: "og:locale" });
528
+ let M = v ? {
529
+ [n]: "i18n-og",
530
+ property: "og:locale",
531
+ content: v
532
+ } : null, N = {
533
+ [n]: "i18n-og-url",
534
+ property: "og:url",
535
+ content: O
536
+ }, P = j.filter((e) => e.code !== s).map((e) => {
537
+ let t = w(e);
538
+ return t ? {
539
+ [n]: `i18n-og-alt-${t}`,
540
+ property: "og:locale:alternate",
541
+ content: t
542
+ } : (T(e, { tag: "og:locale:alternate" }), null);
543
+ }).filter((e) => e !== null), F = {
544
+ [n]: "i18n-can",
545
+ rel: "canonical",
546
+ href: O
547
+ }, I = (() => {
548
+ if (!u || !d) return [];
549
+ let e = /* @__PURE__ */ new Map(), t = d.getCurrentPath();
550
+ for (let n of j) {
551
+ let r = u(t, n.code), i = typeof r == "string" ? r : r?.path || "/";
552
+ if (!i) continue;
553
+ let o;
554
+ o = i.startsWith("http://") || i.startsWith("https://") ? i : `${typeof a == "function" ? a() : a}${i.startsWith("/") ? "" : "/"}${i}`, e.set(String(n.code), o);
555
+ }
556
+ return C(j, { hreflangBaseLanguage: o }).flatMap(({ hreflang: t, localeCode: r }) => {
557
+ let i = e.get(r);
558
+ return i ? [{
559
+ [n]: `i18n-alternate-${t}`,
560
+ rel: "alternate",
561
+ href: i,
562
+ hreflang: t
563
+ }] : [];
564
+ });
565
+ })(), L = r(h, void 0), R = null, z = L ? m.find((e) => e.code === L) : void 0;
566
+ if (u && d && L && z?.seo !== !1) {
567
+ let e = d.getCurrentPath(), t = u(e, L), r = typeof t == "string" ? t : t?.path || "/";
568
+ if (r) {
569
+ let e;
570
+ e = r.startsWith("http://") || r.startsWith("https://") ? r : `${typeof a == "function" ? a() : a}${r.startsWith("/") ? "" : "/"}${r}`, R = {
571
+ [n]: "i18n-xd",
572
+ rel: "alternate",
573
+ href: e,
574
+ hreflang: "x-default"
575
+ };
576
+ }
577
+ }
578
+ f.value = {
579
+ htmlAttrs: A,
580
+ meta: [
581
+ ...M ? [M] : [],
582
+ N,
583
+ ...P
584
+ ],
585
+ link: [
586
+ F,
587
+ ...I,
588
+ ...R ? [R] : []
589
+ ]
590
+ };
591
+ }
592
+ return {
593
+ metaObject: f,
594
+ updateMeta: m
595
+ };
656
596
  }
657
- class ge extends le {
658
- constructor(e) {
659
- const a = {
660
- translations: /* @__PURE__ */ new Map()
661
- };
662
- if (super({
663
- storage: a,
664
- plural: e.plural,
665
- missingWarn: e.missingWarn,
666
- missingHandler: e.missingHandler
667
- }), this.listeners = /* @__PURE__ */ new Set(), this.storage = a, this._locale = z(e.locale), this._fallbackLocale = z(e.fallbackLocale || e.locale), this._currentRoute = z("index"), this._revision = z(0), e.messages)
668
- for (const [o, c] of Object.entries(e.messages))
669
- this.helper.loadTranslations(o, c);
670
- }
671
- get locale() {
672
- return this._locale;
673
- }
674
- set locale(e) {
675
- typeof e == "string" ? this._locale.value = e : this._locale = e;
676
- }
677
- get fallbackLocale() {
678
- return this._fallbackLocale;
679
- }
680
- set fallbackLocale(e) {
681
- typeof e == "string" ? this._fallbackLocale.value = e : this._fallbackLocale = e;
682
- }
683
- get currentRoute() {
684
- return this._currentRoute;
685
- }
686
- setRoute(e) {
687
- this._currentRoute.value = e;
688
- }
689
- getLocale() {
690
- return this._locale.value;
691
- }
692
- getFallbackLocale() {
693
- return this._fallbackLocale.value;
694
- }
695
- getRoute() {
696
- return this._currentRoute.value;
697
- }
698
- addTranslations(e, a, o = !0) {
699
- super.loadTranslationsCore(e, a, o), this._revision.value++, this.notifyListeners();
700
- }
701
- addRouteTranslations(e, a, o, c = !0) {
702
- super.loadRouteTranslationsCore(e, a, o, c), this._revision.value++, this.notifyListeners();
703
- }
704
- mergeTranslations(e, a, o) {
705
- this.helper.mergeTranslation(e, a, o, !0), this._revision.value++, this.notifyListeners();
706
- }
707
- clearCache() {
708
- super.clearCache(), this._revision.value++, this.notifyListeners();
709
- }
710
- onTranslationsChanged() {
711
- this._revision.value++, this.notifyListeners();
712
- }
713
- subscribeToChanges(e) {
714
- return this.listeners.add(e), () => this.listeners.delete(e);
715
- }
716
- notifyListeners() {
717
- this.listeners.forEach((e) => e());
718
- }
719
- getStorage() {
720
- return this.storage;
721
- }
722
- getRouteCache() {
723
- const e = {};
724
- for (const [a, o] of this.storage.translations)
725
- e[a] = o;
726
- return e;
727
- }
728
- }
729
- function Le(t) {
730
- const { routingStrategy: e, locales: a, defaultLocale: o, ...c } = t, r = new ge(c);
731
- let s = null, f = e || null;
732
- return {
733
- global: r,
734
- // Access to instance outside components
735
- setRoutingStrategy: (n) => {
736
- f = n, s && s.provide(U, n);
737
- },
738
- // Method for setting adapter after creation
739
- install(n) {
740
- s = n, n.provide(W, r), f && n.provide(U, f), a && n.provide(Y, a), o && n.provide(ee, o), n.config.globalProperties.$t = (l, m, v, L) => r.t(l, m, v, L), n.config.globalProperties.$ts = (l, m, v, L) => r.ts(l, m, v, L), n.config.globalProperties.$tc = (l, m, v) => r.tc(l, m, v), n.config.globalProperties.$tn = r.tn.bind(r), n.config.globalProperties.$td = r.td.bind(r), n.config.globalProperties.$tdr = r.tdr.bind(r), n.config.globalProperties.$has = (l, m) => r.has(l, m), n.config.globalProperties.$i18n = r, n.component("I18nT", fe), n.component("I18nLink", se), n.component("I18nGroup", ce), n.component("I18nSwitcher", ue);
741
- }
742
- };
743
- }
744
- function Se(t, e, a) {
745
- const o = e.map((r) => r.code), c = (r, s) => {
746
- const i = (typeof r == "string" ? r : r.path || "/").split("/").filter(Boolean), n = i[0];
747
- n !== void 0 && o.includes(n) && i.shift();
748
- const l = `/${i.join("/")}`;
749
- return s === a ? l : `/${s}${l === "/" ? "" : l}`;
750
- };
751
- return {
752
- linkComponent: ie,
753
- getCurrentPath: () => t.currentRoute.value.path,
754
- push: (r) => {
755
- t.push(r.path).catch(() => {
756
- });
757
- },
758
- replace: (r) => {
759
- t.replace(r.path).catch(() => {
760
- });
761
- },
762
- resolvePath: (r, s) => c(r, s),
763
- getRoute: () => ({
764
- fullPath: t.currentRoute.value.fullPath,
765
- query: t.currentRoute.value.query
766
- })
767
- };
768
- }
769
- export {
770
- Pe as FormatService,
771
- ee as I18nDefaultLocaleKey,
772
- ce as I18nGroup,
773
- W as I18nInjectionKey,
774
- se as I18nLink,
775
- Y as I18nLocalesKey,
776
- ue as I18nSwitcher,
777
- fe as I18nT,
778
- ge as VueI18n,
779
- Le as createI18n,
780
- Se as createVueRouterAdapter,
781
- $e as defaultPlural,
782
- Re as interpolate,
783
- he as useI18n,
784
- be as useLocaleHead
597
+ //#endregion
598
+ //#region src/composer.ts
599
+ var O = class extends l {
600
+ constructor(e) {
601
+ let t = { translations: /* @__PURE__ */ new Map() };
602
+ if (super({
603
+ storage: t,
604
+ plural: e.plural,
605
+ missingWarn: e.missingWarn,
606
+ missingHandler: e.missingHandler
607
+ }), this.listeners = /* @__PURE__ */ new Set(), this.storage = t, this._locale = c(e.locale), this._fallbackLocale = c(e.fallbackLocale || e.locale), this._currentRoute = c("index"), this._revision = c(0), e.messages) for (let [t, n] of Object.entries(e.messages)) this.helper.loadTranslations(t, n);
608
+ }
609
+ get locale() {
610
+ return this._locale;
611
+ }
612
+ set locale(e) {
613
+ typeof e == "string" ? this._locale.value = e : this._locale = e;
614
+ }
615
+ get fallbackLocale() {
616
+ return this._fallbackLocale;
617
+ }
618
+ set fallbackLocale(e) {
619
+ typeof e == "string" ? this._fallbackLocale.value = e : this._fallbackLocale = e;
620
+ }
621
+ get currentRoute() {
622
+ return this._currentRoute;
623
+ }
624
+ setRoute(e) {
625
+ this._currentRoute.value = e;
626
+ }
627
+ getLocale() {
628
+ return this._locale.value;
629
+ }
630
+ getFallbackLocale() {
631
+ return this._fallbackLocale.value;
632
+ }
633
+ getRoute() {
634
+ return this._currentRoute.value;
635
+ }
636
+ addTranslations(e, t, n = !0) {
637
+ super.loadTranslationsCore(e, t, n), this._revision.value++, this.notifyListeners();
638
+ }
639
+ addRouteTranslations(e, t, n, r = !0) {
640
+ super.loadRouteTranslationsCore(e, t, n, r), this._revision.value++, this.notifyListeners();
641
+ }
642
+ mergeTranslations(e, t, n) {
643
+ this.helper.mergeTranslation(e, t, n, !0), this._revision.value++, this.notifyListeners();
644
+ }
645
+ clearCache() {
646
+ super.clearCache(), this._revision.value++, this.notifyListeners();
647
+ }
648
+ onTranslationsChanged() {
649
+ this._revision.value++, this.notifyListeners();
650
+ }
651
+ subscribeToChanges(e) {
652
+ return this.listeners.add(e), () => this.listeners.delete(e);
653
+ }
654
+ notifyListeners() {
655
+ this.listeners.forEach((e) => e());
656
+ }
657
+ getStorage() {
658
+ return this.storage;
659
+ }
660
+ getRouteCache() {
661
+ let e = {};
662
+ for (let [t, n] of this.storage.translations) e[t] = n;
663
+ return e;
664
+ }
785
665
  };
786
- //# sourceMappingURL=index.mjs.map
666
+ //#endregion
667
+ //#region src/plugin.ts
668
+ function k(e) {
669
+ let { routingStrategy: t, locales: n, defaultLocale: r, ...i } = e, a = new O(i), o = null, s = t || null;
670
+ return {
671
+ global: a,
672
+ setRoutingStrategy: (e) => {
673
+ s = e, o && o.provide(g, e);
674
+ },
675
+ install(e) {
676
+ o = e, e.provide(p, a), s && e.provide(g, s), n && e.provide(m, n), r && e.provide(h, r), e.config.globalProperties.$t = (e, t, n, r) => a.t(e, t, n, r), e.config.globalProperties.$ts = (e, t, n, r) => a.ts(e, t, n, r), e.config.globalProperties.$tc = (e, t, n) => a.tc(e, t, n), e.config.globalProperties.$tn = a.tn.bind(a), e.config.globalProperties.$td = a.td.bind(a), e.config.globalProperties.$tdr = a.tdr.bind(a), e.config.globalProperties.$has = (e, t) => a.has(e, t), e.config.globalProperties.$i18n = a, e.component("I18nT", b), e.component("I18nLink", v), e.component("I18nGroup", _), e.component("I18nSwitcher", y);
677
+ }
678
+ };
679
+ }
680
+ //#endregion
681
+ export { u as FormatService, h as I18nDefaultLocaleKey, _ as I18nGroup, p as I18nInjectionKey, v as I18nLink, m as I18nLocalesKey, y as I18nSwitcher, b as I18nT, O as VueI18n, k as createI18n, d as defaultPlural, f as interpolate, E as useI18n, D as useLocaleHead };
682
+
683
+ //# sourceMappingURL=index.mjs.map