@prosopo/cli 3.8.10 → 3.8.12

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.
@@ -12,11 +12,11 @@ var n = {
12
12
  e = n, t = r;
13
13
  });
14
14
  return n.resolve = e, n.reject = t, n;
15
- }, a = (e) => e == null ? "" : "" + e, o = (e, t, n) => {
15
+ }, a = (e) => e == null ? "" : String(e), o = (e, t, n) => {
16
16
  e.forEach((e) => {
17
17
  t[e] && (n[e] = t[e]);
18
18
  });
19
- }, s = /###/g, c = (e) => e && e.indexOf("###") > -1 ? e.replace(s, ".") : e, l = (e) => !e || r(e), u = (e, t, n) => {
19
+ }, s = /###/g, c = (e) => e && e.includes("###") ? e.replace(s, ".") : e, l = (e) => !e || r(e), u = (e, t, n) => {
20
20
  let i = r(t) ? t.split(".") : t, a = 0;
21
21
  for (; a < i.length - 1;) {
22
22
  if (l(e)) return {};
@@ -46,7 +46,7 @@ var n = {
46
46
  let r = p(e, n);
47
47
  return r === void 0 ? p(t, n) : r;
48
48
  }, h = (e, t, n) => {
49
- for (let i in t) i !== "__proto__" && i !== "constructor" && (i in e ? r(e[i]) || e[i] instanceof String || r(t[i]) || t[i] instanceof String ? n && (e[i] = t[i]) : h(e[i], t[i], n) : e[i] = t[i]);
49
+ for (let i in t) i !== "__proto__" && i !== "constructor" && (Object.prototype.hasOwnProperty.call(e, i) ? r(e[i]) || e[i] instanceof String || r(t[i]) || t[i] instanceof String ? n && (e[i] = t[i]) : h(e[i], t[i], n) : e[i] = t[i]);
50
50
  return e;
51
51
  }, g = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), _ = {
52
52
  "&": "&amp;",
@@ -73,7 +73,7 @@ var n = {
73
73
  ";"
74
74
  ], x = new y(20), S = (e, t, n) => {
75
75
  t ||= "", n ||= "";
76
- let r = b.filter((e) => t.indexOf(e) < 0 && n.indexOf(e) < 0);
76
+ let r = b.filter((e) => !t.includes(e) && !n.includes(e));
77
77
  if (r.length === 0) return !0;
78
78
  let i = x.getRegExp(`(${r.map((e) => e === "?" ? "\\?" : e).join("|")})`), a = !i.test(e);
79
79
  if (!a) {
@@ -81,8 +81,7 @@ var n = {
81
81
  t > 0 && !i.test(e.substring(0, t)) && (a = !0);
82
82
  }
83
83
  return a;
84
- }, C = function(e, t) {
85
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
84
+ }, C = (e, t, n = ".") => {
86
85
  if (!e) return;
87
86
  if (e[t]) return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
88
87
  let r = t.split(n), i = e;
@@ -94,14 +93,14 @@ var n = {
94
93
  "string",
95
94
  "number",
96
95
  "boolean"
97
- ].indexOf(typeof t) > -1 && o < r.length - 1) continue;
96
+ ].includes(typeof t) && o < r.length - 1) continue;
98
97
  e += o - e + 1;
99
98
  break;
100
99
  }
101
100
  i = t;
102
101
  }
103
102
  return i;
104
- }, w = (e) => e?.replace("_", "-"), T = {
103
+ }, w = (e) => e?.replace(/_/g, "-"), T = {
105
104
  type: "logger",
106
105
  log(e) {
107
106
  this.output("log", e);
@@ -116,32 +115,26 @@ var n = {
116
115
  console?.[e]?.apply?.(console, t);
117
116
  }
118
117
  }, E = new class e {
119
- constructor(e) {
120
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
118
+ constructor(e, t = {}) {
121
119
  this.init(e, t);
122
120
  }
123
- init(e) {
124
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
121
+ init(e, t = {}) {
125
122
  this.prefix = t.prefix || "i18next:", this.logger = e || T, this.options = t, this.debug = t.debug;
126
123
  }
127
- log() {
128
- var e = [...arguments];
124
+ log(...e) {
129
125
  return this.forward(e, "log", "", !0);
130
126
  }
131
- warn() {
132
- var e = [...arguments];
127
+ warn(...e) {
133
128
  return this.forward(e, "warn", "", !0);
134
129
  }
135
- error() {
136
- var e = [...arguments];
130
+ error(...e) {
137
131
  return this.forward(e, "error", "");
138
132
  }
139
- deprecate() {
140
- var e = [...arguments];
133
+ deprecate(...e) {
141
134
  return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
142
135
  }
143
136
  forward(e, t, n, i) {
144
- return i && !this.debug ? null : (r(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
137
+ return i && !this.debug ? null : (e = e.map((e) => r(e) ? e.replace(/[\r\n\x00-\x1F\x7F]/g, " ") : e), r(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
145
138
  }
146
139
  create(t) {
147
140
  return new e(this.logger, {
@@ -172,52 +165,53 @@ var n = {
172
165
  this.observers[e].delete(t);
173
166
  }
174
167
  }
175
- emit(e) {
176
- var t = [...arguments].slice(1);
177
- this.observers[e] && Array.from(this.observers[e].entries()).forEach((e) => {
178
- let [n, r] = e;
179
- for (let e = 0; e < r; e++) n(...t);
180
- }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach((n) => {
181
- let [r, i] = n;
182
- for (let n = 0; n < i; n++) r.apply(r, [e, ...t]);
168
+ once(e, t) {
169
+ let n = (...r) => {
170
+ t(...r), this.off(e, n);
171
+ };
172
+ return this.on(e, n), this;
173
+ }
174
+ emit(e, ...t) {
175
+ this.observers[e] && Array.from(this.observers[e].entries()).forEach(([e, n]) => {
176
+ for (let r = 0; r < n; r++) e(...t);
177
+ }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([n, r]) => {
178
+ for (let i = 0; i < r; i++) n(e, ...t);
183
179
  });
184
180
  }
185
181
  }, O = class extends D {
186
- constructor(e) {
187
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
188
- ns: ["translation"],
189
- defaultNS: "translation"
190
- };
182
+ constructor(e, t = {
183
+ ns: ["translation"],
184
+ defaultNS: "translation"
185
+ }) {
191
186
  super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
192
187
  }
193
188
  addNamespaces(e) {
194
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
189
+ this.options.ns.includes(e) || this.options.ns.push(e);
195
190
  }
196
191
  removeNamespaces(e) {
197
192
  let t = this.options.ns.indexOf(e);
198
193
  t > -1 && this.options.ns.splice(t, 1);
199
194
  }
200
- getResource(e, t, n) {
201
- let i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = i.ignoreJSONStructure === void 0 ? this.options.ignoreJSONStructure : i.ignoreJSONStructure, s;
202
- e.indexOf(".") > -1 ? s = e.split(".") : (s = [e, t], n && (Array.isArray(n) ? s.push(...n) : r(n) && a ? s.push(...n.split(a)) : s.push(n)));
195
+ getResource(e, t, n, i = {}) {
196
+ let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = i.ignoreJSONStructure === void 0 ? this.options.ignoreJSONStructure : i.ignoreJSONStructure, s;
197
+ e.includes(".") ? s = e.split(".") : (s = [e, t], n && (Array.isArray(n) ? s.push(...n) : r(n) && a ? s.push(...n.split(a)) : s.push(n)));
203
198
  let c = p(this.data, s);
204
- return !c && !t && !n && e.indexOf(".") > -1 && (e = s[0], t = s[1], n = s.slice(2).join(".")), c || !o || !r(n) ? c : C(this.data?.[e]?.[t], n, a);
199
+ return !c && !t && !n && e.includes(".") && (e = s[0], t = s[1], n = s.slice(2).join(".")), c || !o || !r(n) ? c : C(this.data?.[e]?.[t], n, a);
205
200
  }
206
- addResource(e, t, n, r) {
207
- let i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : { silent: !1 }, a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = [e, t];
208
- n && (o = o.concat(a ? n.split(a) : n)), e.indexOf(".") > -1 && (o = e.split("."), r = t, t = o[1]), this.addNamespaces(t), d(this.data, o, r), i.silent || this.emit("added", e, t, n, r);
201
+ addResource(e, t, n, r, i = { silent: !1 }) {
202
+ let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = [e, t];
203
+ n && (o = o.concat(a ? n.split(a) : n)), e.includes(".") && (o = e.split("."), r = t, t = o[1]), this.addNamespaces(t), d(this.data, o, r), i.silent || this.emit("added", e, t, n, r);
209
204
  }
210
- addResources(e, t, n) {
211
- let i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : { silent: !1 };
205
+ addResources(e, t, n, i = { silent: !1 }) {
212
206
  for (let i in n) (r(n[i]) || Array.isArray(n[i])) && this.addResource(e, t, i, n[i], { silent: !0 });
213
207
  i.silent || this.emit("added", e, t, n);
214
208
  }
215
- addResourceBundle(e, t, n, r, i) {
216
- let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
217
- silent: !1,
218
- skipCopy: !1
219
- }, o = [e, t];
220
- e.indexOf(".") > -1 && (o = e.split("."), r = n, n = t, t = o[1]), this.addNamespaces(t);
209
+ addResourceBundle(e, t, n, r, i, a = {
210
+ silent: !1,
211
+ skipCopy: !1
212
+ }) {
213
+ let o = [e, t];
214
+ e.includes(".") && (o = e.split("."), r = n, n = t, t = o[1]), this.addNamespaces(t);
221
215
  let s = p(this.data, o) || {};
222
216
  a.skipCopy || (n = JSON.parse(JSON.stringify(n))), r ? h(s, n, i) : s = {
223
217
  ...s,
@@ -253,9 +247,21 @@ var n = {
253
247
  t = this.processors[e]?.process(t, n, r, i) ?? t;
254
248
  }), t;
255
249
  }
256
- }, A = {}, j = (e) => !r(e) && typeof e != "boolean" && typeof e != "number", M = class e extends D {
257
- constructor(e) {
258
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
250
+ }, A = Symbol("i18next/PATH_KEY");
251
+ function j() {
252
+ let e = [], t = Object.create(null), n;
253
+ return t.get = (r, i) => (n?.revoke?.(), i === A ? e : (e.push(i), n = Proxy.revocable(r, t), n.proxy)), Proxy.revocable(Object.create(null), t).proxy;
254
+ }
255
+ function M(e, t) {
256
+ let { [A]: n } = e(j()), r = t?.keySeparator ?? ".", i = t?.nsSeparator ?? ":", a = t?.enableSelector === "strict";
257
+ if (n.length > 1 && i) {
258
+ let e = t?.ns, o = a ? Array.isArray(e) ? e : e ? [e] : null : Array.isArray(e) ? e : null;
259
+ if (o && (a ? o : o.length > 1 ? o.slice(1) : []).includes(n[0])) return `${n[0]}${i}${n.slice(1).join(r)}`;
260
+ }
261
+ return n.join(r);
262
+ }
263
+ var N = (e) => !r(e) && typeof e != "boolean" && typeof e != "number", P = class e extends D {
264
+ constructor(e, t = {}) {
259
265
  super(), o([
260
266
  "resourceStore",
261
267
  "languageUtils",
@@ -264,19 +270,23 @@ var n = {
264
270
  "backendConnector",
265
271
  "i18nFormat",
266
272
  "utils"
267
- ], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = E.create("translator");
273
+ ], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = E.create("translator"), this.checkedLoadedFor = {};
268
274
  }
269
275
  changeLanguage(e) {
270
276
  e && (this.language = e);
271
277
  }
272
- exists(e) {
273
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { interpolation: {} };
274
- return e != null && this.resolve(e, t)?.res !== void 0;
278
+ exists(e, t = { interpolation: {} }) {
279
+ let n = { ...t };
280
+ if (e == null) return !1;
281
+ let r = this.resolve(e, n);
282
+ if (r?.res === void 0) return !1;
283
+ let i = N(r.res);
284
+ return !(n.returnObjects === !1 && i);
275
285
  }
276
286
  extractFromKey(e, t) {
277
287
  let n = t.nsSeparator === void 0 ? this.options.nsSeparator : t.nsSeparator;
278
288
  n === void 0 && (n = ":");
279
- let i = t.keySeparator === void 0 ? this.options.keySeparator : t.keySeparator, a = t.ns || this.options.defaultNS || [], o = n && e.indexOf(n) > -1, s = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !S(e, n, i);
289
+ let i = t.keySeparator === void 0 ? this.options.keySeparator : t.keySeparator, a = t.ns || this.options.defaultNS || [], o = n && e.includes(n), s = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !S(e, n, i);
280
290
  if (o && !s) {
281
291
  let t = e.match(this.interpolator.nestingRegexp);
282
292
  if (t && t.length > 0) return {
@@ -284,7 +294,7 @@ var n = {
284
294
  namespaces: r(a) ? [a] : a
285
295
  };
286
296
  let o = e.split(n);
287
- (n !== i || n === i && this.options.ns.indexOf(o[0]) > -1) && (a = o.shift()), e = o.join(i);
297
+ (n !== i || n === i && this.options.ns.includes(o[0])) && (a = o.shift()), e = o.join(i);
288
298
  }
289
299
  return {
290
300
  key: e,
@@ -292,96 +302,98 @@ var n = {
292
302
  };
293
303
  }
294
304
  translate(t, n, i) {
295
- if (typeof n != "object" && this.options.overloadTranslationOptionHandler && (n = this.options.overloadTranslationOptionHandler(arguments)), typeof n == "object" && (n = { ...n }), n ||= {}, t == null) return "";
296
- Array.isArray(t) || (t = [String(t)]);
297
- let a = n.returnDetails === void 0 ? this.options.returnDetails : n.returnDetails, o = n.keySeparator === void 0 ? this.options.keySeparator : n.keySeparator, { key: s, namespaces: c } = this.extractFromKey(t[t.length - 1], n), l = c[c.length - 1], u = n.lng || this.language, d = n.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
298
- if (u?.toLowerCase() === "cimode") {
299
- if (d) {
300
- let e = n.nsSeparator || this.options.nsSeparator;
301
- return a ? {
302
- res: `${l}${e}${s}`,
303
- usedKey: s,
304
- exactUsedKey: s,
305
- usedLng: u,
306
- usedNS: l,
307
- usedParams: this.getUsedParamsDetails(n)
308
- } : `${l}${e}${s}`;
309
- }
310
- return a ? {
311
- res: s,
312
- usedKey: s,
313
- exactUsedKey: s,
314
- usedLng: u,
315
- usedNS: l,
316
- usedParams: this.getUsedParamsDetails(n)
317
- } : s;
318
- }
319
- let f = this.resolve(t, n), p = f?.res, m = f?.usedKey || s, h = f?.exactUsedKey || s, g = [
305
+ let a = typeof n == "object" ? { ...n } : n;
306
+ if (typeof a != "object" && this.options.overloadTranslationOptionHandler && (a = this.options.overloadTranslationOptionHandler(arguments)), typeof a == "object" && (a = { ...a }), a ||= {}, t == null) return "";
307
+ typeof t == "function" && (t = M(t, {
308
+ ...this.options,
309
+ ...a
310
+ })), Array.isArray(t) || (t = [String(t)]), t = t.map((e) => typeof e == "function" ? M(e, {
311
+ ...this.options,
312
+ ...a
313
+ }) : String(e));
314
+ let o = a.returnDetails === void 0 ? this.options.returnDetails : a.returnDetails, s = a.keySeparator === void 0 ? this.options.keySeparator : a.keySeparator, { key: c, namespaces: l } = this.extractFromKey(t[t.length - 1], a), u = l[l.length - 1], d = a.nsSeparator === void 0 ? this.options.nsSeparator : a.nsSeparator;
315
+ d === void 0 && (d = ":");
316
+ let f = a.lng || this.language, p = a.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
317
+ if (f?.toLowerCase() === "cimode") return p ? o ? {
318
+ res: `${u}${d}${c}`,
319
+ usedKey: c,
320
+ exactUsedKey: c,
321
+ usedLng: f,
322
+ usedNS: u,
323
+ usedParams: this.getUsedParamsDetails(a)
324
+ } : `${u}${d}${c}` : o ? {
325
+ res: c,
326
+ usedKey: c,
327
+ exactUsedKey: c,
328
+ usedLng: f,
329
+ usedNS: u,
330
+ usedParams: this.getUsedParamsDetails(a)
331
+ } : c;
332
+ let m = this.resolve(t, a), h = m?.res, g = m?.usedKey || c, _ = m?.exactUsedKey || c, v = [
320
333
  "[object Number]",
321
334
  "[object Function]",
322
335
  "[object RegExp]"
323
- ], _ = n.joinArrays === void 0 ? this.options.joinArrays : n.joinArrays, v = !this.i18nFormat || this.i18nFormat.handleAsObject, y = n.count !== void 0 && !r(n.count), b = e.hasDefaultValue(n), x = y ? this.pluralResolver.getSuffix(u, n.count, n) : "", S = n.ordinal && y ? this.pluralResolver.getSuffix(u, n.count, { ordinal: !1 }) : "", C = y && !n.ordinal && n.count === 0, w = C && n[`defaultValue${this.options.pluralSeparator}zero`] || n[`defaultValue${x}`] || n[`defaultValue${S}`] || n.defaultValue, T = p;
324
- v && !p && b && (T = w);
325
- let E = j(T), D = Object.prototype.toString.apply(T);
326
- if (v && T && E && g.indexOf(D) < 0 && !(r(_) && Array.isArray(T))) {
327
- if (!n.returnObjects && !this.options.returnObjects) {
336
+ ], y = a.joinArrays === void 0 ? this.options.joinArrays : a.joinArrays, b = !this.i18nFormat || this.i18nFormat.handleAsObject, x = a.count !== void 0 && !r(a.count), S = e.hasDefaultValue(a), C = x ? this.pluralResolver.getSuffix(f, a.count, a) : "", w = a.ordinal && x ? this.pluralResolver.getSuffix(f, a.count, { ordinal: !1 }) : "", T = x && !a.ordinal && a.count === 0, E = T && a[`defaultValue${this.options.pluralSeparator}zero`] || a[`defaultValue${C}`] || a[`defaultValue${w}`] || a.defaultValue, D = h;
337
+ b && !h && S && (D = E);
338
+ let O = N(D), k = Object.prototype.toString.apply(D);
339
+ if (b && D && O && !v.includes(k) && !(r(y) && Array.isArray(D))) {
340
+ if (!a.returnObjects && !this.options.returnObjects) {
328
341
  this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
329
- let e = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(m, T, {
330
- ...n,
331
- ns: c
332
- }) : `key '${s} (${this.language})' returned an object instead of string.`;
333
- return a ? (f.res = e, f.usedParams = this.getUsedParamsDetails(n), f) : e;
342
+ let e = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(g, D, {
343
+ ...a,
344
+ ns: l
345
+ }) : `key '${c} (${this.language})' returned an object instead of string.`;
346
+ return o ? (m.res = e, m.usedParams = this.getUsedParamsDetails(a), m) : e;
334
347
  }
335
- if (o) {
336
- let e = Array.isArray(T), t = e ? [] : {}, r = e ? h : m;
337
- for (let e in T) if (Object.prototype.hasOwnProperty.call(T, e)) {
338
- let i = `${r}${o}${e}`;
339
- b && !p ? t[e] = this.translate(i, {
340
- ...n,
341
- defaultValue: j(w) ? w[e] : void 0,
348
+ if (s) {
349
+ let e = Array.isArray(D), t = e ? [] : {}, n = e ? _ : g;
350
+ for (let e in D) if (Object.prototype.hasOwnProperty.call(D, e)) {
351
+ let r = `${n}${s}${e}`;
352
+ S && !h ? t[e] = this.translate(r, {
353
+ ...a,
354
+ defaultValue: N(E) ? E[e] : void 0,
342
355
  joinArrays: !1,
343
- ns: c
344
- }) : t[e] = this.translate(i, {
345
- ...n,
356
+ ns: l
357
+ }) : t[e] = this.translate(r, {
358
+ ...a,
346
359
  joinArrays: !1,
347
- ns: c
348
- }), t[e] === i && (t[e] = T[e]);
360
+ ns: l
361
+ }), t[e] === r && (t[e] = D[e]);
349
362
  }
350
- p = t;
363
+ h = t;
351
364
  }
352
- } else if (v && r(_) && Array.isArray(p)) p = p.join(_), p &&= this.extendTranslation(p, t, n, i);
365
+ } else if (b && r(y) && Array.isArray(h)) h = h.join(y), h &&= this.extendTranslation(h, t, a, i);
353
366
  else {
354
- let e = !1, r = !1;
355
- !this.isValidLookup(p) && b && (e = !0, p = w), this.isValidLookup(p) || (r = !0, p = s);
356
- let a = (n.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && r ? void 0 : p, c = b && w !== p && this.options.updateMissing;
357
- if (r || e || c) {
358
- if (this.logger.log(c ? "updateKey" : "missingKey", u, l, s, c ? w : p), o) {
359
- let e = this.resolve(s, {
360
- ...n,
367
+ let e = !1, n = !1;
368
+ !this.isValidLookup(h) && S && (e = !0, h = E), this.isValidLookup(h) || (n = !0, h = c);
369
+ let r = (a.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && n ? void 0 : h, o = S && E !== h && this.options.updateMissing;
370
+ if (n || e || o) {
371
+ if (this.logger.log(o ? "updateKey" : "missingKey", f, u, x && !o ? `${c}${this.pluralResolver.getSuffix(f, a.count, a)}` : c, o ? E : h), s) {
372
+ let e = this.resolve(c, {
373
+ ...a,
361
374
  keySeparator: !1
362
375
  });
363
376
  e && e.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
364
377
  }
365
- let e = [], t = this.languageUtils.getFallbackCodes(this.options.fallbackLng, n.lng || this.language);
378
+ let e = [], t = this.languageUtils.getFallbackCodes(this.options.fallbackLng, a.lng || this.language);
366
379
  if (this.options.saveMissingTo === "fallback" && t && t[0]) for (let n = 0; n < t.length; n++) e.push(t[n]);
367
- else this.options.saveMissingTo === "all" ? e = this.languageUtils.toResolveHierarchy(n.lng || this.language) : e.push(n.lng || this.language);
368
- let r = (e, t, r) => {
369
- let i = b && r !== p ? r : a;
370
- this.options.missingKeyHandler ? this.options.missingKeyHandler(e, l, t, i, c, n) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(e, l, t, i, c, n), this.emit("missingKey", e, l, t, p);
380
+ else this.options.saveMissingTo === "all" ? e = this.languageUtils.toResolveHierarchy(a.lng || this.language) : e.push(a.lng || this.language);
381
+ let n = (e, t, n) => {
382
+ let i = S && n !== h ? n : r;
383
+ this.options.missingKeyHandler ? this.options.missingKeyHandler(e, u, t, i, o, a) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(e, u, t, i, o, a), this.emit("missingKey", e, u, t, h);
371
384
  };
372
- this.options.saveMissing && (this.options.saveMissingPlurals && y ? e.forEach((e) => {
373
- let t = this.pluralResolver.getSuffixes(e, n);
374
- C && n[`defaultValue${this.options.pluralSeparator}zero`] && t.indexOf(`${this.options.pluralSeparator}zero`) < 0 && t.push(`${this.options.pluralSeparator}zero`), t.forEach((t) => {
375
- r([e], s + t, n[`defaultValue${t}`] || w);
385
+ this.options.saveMissing && (this.options.saveMissingPlurals && x ? e.forEach((e) => {
386
+ let t = this.pluralResolver.getSuffixes(e, a);
387
+ T && a[`defaultValue${this.options.pluralSeparator}zero`] && !t.includes(`${this.options.pluralSeparator}zero`) && t.push(`${this.options.pluralSeparator}zero`), t.forEach((t) => {
388
+ n([e], c + t, a[`defaultValue${t}`] || E);
376
389
  });
377
- }) : r(e, s, w));
390
+ }) : n(e, c, E));
378
391
  }
379
- p = this.extendTranslation(p, t, n, f, i), r && p === s && this.options.appendNamespaceToMissingKey && (p = `${l}:${s}`), (r || e) && this.options.parseMissingKeyHandler && (p = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${l}:${s}` : s, e ? p : void 0));
392
+ h = this.extendTranslation(h, t, a, m, i), n && h === c && this.options.appendNamespaceToMissingKey && (h = `${u}${d}${c}`), (n || e) && this.options.parseMissingKeyHandler && (h = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${d}${c}` : c, e ? h : void 0, a));
380
393
  }
381
- return a ? (f.res = p, f.usedParams = this.getUsedParamsDetails(n), f) : p;
394
+ return o ? (m.res = h, m.usedParams = this.getUsedParamsDetails(a), m) : h;
382
395
  }
383
396
  extendTranslation(e, t, n, i, a) {
384
- var o = this;
385
397
  if (this.i18nFormat?.parse) e = this.i18nFormat.parse(e, {
386
398
  ...this.options.interpolation.defaultVariables,
387
399
  ...n
@@ -394,26 +406,23 @@ var n = {
394
406
  ...n.interpolation
395
407
  }
396
408
  });
397
- let s = r(e) && (n?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : n.interpolation.skipOnVariables), c;
398
- if (s) {
409
+ let o = r(e) && (n?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : n.interpolation.skipOnVariables), s;
410
+ if (o) {
399
411
  let t = e.match(this.interpolator.nestingRegexp);
400
- c = t && t.length;
412
+ s = t && t.length;
401
413
  }
402
- let l = n.replace && !r(n.replace) ? n.replace : n;
403
- if (this.options.interpolation.defaultVariables && (l = {
414
+ let c = n.replace && !r(n.replace) ? n.replace : n;
415
+ if (this.options.interpolation.defaultVariables && (c = {
404
416
  ...this.options.interpolation.defaultVariables,
405
- ...l
406
- }), e = this.interpolator.interpolate(e, l, n.lng || this.language || i.usedLng, n), s) {
417
+ ...c
418
+ }), e = this.interpolator.interpolate(e, c, n.lng || this.language || i.usedLng, n), o) {
407
419
  let t = e.match(this.interpolator.nestingRegexp), r = t && t.length;
408
- c < r && (n.nest = !1);
420
+ s < r && (n.nest = !1);
409
421
  }
410
- !n.lng && i && i.res && (n.lng = this.language || i.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, function() {
411
- var e = [...arguments];
412
- return a?.[0] === e[0] && !n.context ? (o.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`), null) : o.translate(...e, t);
413
- }, n)), n.interpolation && this.interpolator.reset();
422
+ !n.lng && i && i.res && (n.lng = this.language || i.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, (...e) => a?.[0] === e[0] && !n.context ? (this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`), null) : this.translate(...e, t), n)), n.interpolation && this.interpolator.reset();
414
423
  }
415
- let s = n.postProcess || this.options.postProcess, c = r(s) ? [s] : s;
416
- return e != null && c?.length && n.applyPostProcessor !== !1 && (e = k.handle(c, e, t, this.options && this.options.postProcessPassResolved ? {
424
+ let o = n.postProcess || this.options.postProcess, s = r(o) ? [o] : o;
425
+ return e != null && s?.length && n.applyPostProcessor !== !1 && (e = k.handle(s, e, t, this.options && this.options.postProcessPassResolved ? {
417
426
  i18nResolved: {
418
427
  ...i,
419
428
  usedParams: this.getUsedParamsDetails(n)
@@ -421,9 +430,12 @@ var n = {
421
430
  ...n
422
431
  } : n, this)), e;
423
432
  }
424
- resolve(e) {
425
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n, i, a, o, s;
426
- return r(e) && (e = [e]), e.forEach((e) => {
433
+ resolve(e, t = {}) {
434
+ let n, i, a, o, s;
435
+ return r(e) && (e = [e]), Array.isArray(e) && (e = e.map((e) => typeof e == "function" ? M(e, {
436
+ ...this.options,
437
+ ...t
438
+ }) : e)), e.forEach((e) => {
427
439
  if (this.isValidLookup(n)) return;
428
440
  let c = this.extractFromKey(e, t), l = c.key;
429
441
  i = l;
@@ -431,7 +443,7 @@ var n = {
431
443
  this.options.fallbackNS && (u = u.concat(this.options.fallbackNS));
432
444
  let d = t.count !== void 0 && !r(t.count), f = d && !t.ordinal && t.count === 0, p = t.context !== void 0 && (r(t.context) || typeof t.context == "number") && t.context !== "", m = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
433
445
  u.forEach((e) => {
434
- this.isValidLookup(n) || (s = e, !A[`${m[0]}-${e}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(s) && (A[`${m[0]}-${e}`] = !0, this.logger.warn(`key "${i}" for languages "${m.join(", ")}" won't get resolved as namespace "${s}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), m.forEach((r) => {
446
+ this.isValidLookup(n) || (s = e, !this.checkedLoadedFor[`${m[0]}-${e}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(s) && (this.checkedLoadedFor[`${m[0]}-${e}`] = !0, this.logger.warn(`key "${i}" for languages "${m.join(", ")}" won't get resolved as namespace "${s}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), m.forEach((r) => {
435
447
  if (this.isValidLookup(n)) return;
436
448
  o = r;
437
449
  let i = [l];
@@ -440,9 +452,9 @@ var n = {
440
452
  let e;
441
453
  d && (e = this.pluralResolver.getSuffix(r, t.count, t));
442
454
  let n = `${this.options.pluralSeparator}zero`, a = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
443
- if (d && (i.push(l + e), t.ordinal && e.indexOf(a) === 0 && i.push(l + e.replace(a, this.options.pluralSeparator)), f && i.push(l + n)), p) {
444
- let r = `${l}${this.options.contextSeparator}${t.context}`;
445
- i.push(r), d && (i.push(r + e), t.ordinal && e.indexOf(a) === 0 && i.push(r + e.replace(a, this.options.pluralSeparator)), f && i.push(r + n));
455
+ if (d && (t.ordinal && e.startsWith(a) && i.push(l + e.replace(a, this.options.pluralSeparator)), i.push(l + e), f && i.push(l + n)), p) {
456
+ let r = `${l}${this.options.contextSeparator || "_"}${t.context}`;
457
+ i.push(r), d && (t.ordinal && e.startsWith(a) && i.push(r + e.replace(a, this.options.pluralSeparator)), i.push(r + e), f && i.push(r + n));
446
458
  }
447
459
  }
448
460
  let s;
@@ -460,12 +472,11 @@ var n = {
460
472
  isValidLookup(e) {
461
473
  return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
462
474
  }
463
- getResource(e, t, n) {
464
- let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
475
+ getResource(e, t, n, r = {}) {
465
476
  return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, n, r) : this.resourceStore.getResource(e, t, n, r);
466
477
  }
467
- getUsedParamsDetails() {
468
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = [
478
+ getUsedParamsDetails(e = {}) {
479
+ let t = [
469
480
  "defaultValue",
470
481
  "ordinal",
471
482
  "context",
@@ -482,7 +493,10 @@ var n = {
482
493
  "postProcess",
483
494
  "interpolation"
484
495
  ], n = e.replace && !r(e.replace), i = n ? e.replace : e;
485
- if (n && e.count !== void 0 && (i.count = e.count), this.options.interpolation.defaultVariables && (i = {
496
+ if (n && e.count !== void 0 && (i = {
497
+ ...i,
498
+ count: e.count
499
+ }), this.options.interpolation.defaultVariables && (i = {
486
500
  ...this.options.interpolation.defaultVariables,
487
501
  ...i
488
502
  }), !n) {
@@ -492,25 +506,28 @@ var n = {
492
506
  return i;
493
507
  }
494
508
  static hasDefaultValue(e) {
495
- for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && t.substring(0, 12) === "defaultValue" && e[t] !== void 0) return !0;
509
+ for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && t.startsWith("defaultValue") && e[t] !== void 0) return !0;
496
510
  return !1;
497
511
  }
498
- }, N = class {
512
+ }, F = class {
499
513
  constructor(e) {
500
- this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = E.create("languageUtils");
514
+ this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = E.create("languageUtils"), this.resolveHierarchyCache = {};
515
+ }
516
+ clearCache() {
517
+ this.resolveHierarchyCache = {};
501
518
  }
502
519
  getScriptPartFromCode(e) {
503
- if (e = w(e), !e || e.indexOf("-") < 0) return null;
520
+ if (e = w(e), !e || !e.includes("-")) return null;
504
521
  let t = e.split("-");
505
522
  return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
506
523
  }
507
524
  getLanguagePartFromCode(e) {
508
- if (e = w(e), !e || e.indexOf("-") < 0) return e;
525
+ if (e = w(e), !e || !e.includes("-")) return e;
509
526
  let t = e.split("-");
510
527
  return this.formatLanguageCode(t[0]);
511
528
  }
512
529
  formatLanguageCode(e) {
513
- if (r(e) && e.indexOf("-") > -1) {
530
+ if (r(e) && e.includes("-")) {
514
531
  let t;
515
532
  try {
516
533
  t = Intl.getCanonicalLocales(e)[0];
@@ -520,7 +537,7 @@ var n = {
520
537
  return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
521
538
  }
522
539
  isSupportedCode(e) {
523
- return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
540
+ return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.includes(e);
524
541
  }
525
542
  getBestMatchFromCodes(e) {
526
543
  if (!e) return null;
@@ -531,11 +548,11 @@ var n = {
531
548
  (!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n);
532
549
  }), !t && this.options.supportedLngs && e.forEach((e) => {
533
550
  if (t) return;
534
- let n = this.getLanguagePartFromCode(e);
551
+ let n = this.getScriptPartFromCode(e);
535
552
  if (this.isSupportedCode(n)) return t = n;
536
- t = this.options.supportedLngs.find((e) => {
537
- if (e === n || !(e.indexOf("-") < 0 && n.indexOf("-") < 0) && (e.indexOf("-") > 0 && n.indexOf("-") < 0 && e.substring(0, e.indexOf("-")) === n || e.indexOf(n) === 0 && n.length > 1)) return e;
538
- });
553
+ let r = this.getLanguagePartFromCode(e);
554
+ if (this.isSupportedCode(r)) return t = r;
555
+ t = this.options.supportedLngs.find((e) => e === r ? !0 : !e.includes("-") && !r.includes("-") ? !1 : !!(e.includes("-") && !r.includes("-") && e.slice(0, e.indexOf("-")) === r || e.startsWith(r) && r.length > 1));
539
556
  }), t ||= this.getFallbackCodes(this.options.fallbackLng)[0], t;
540
557
  }
541
558
  getFallbackCodes(e, t) {
@@ -546,36 +563,43 @@ var n = {
546
563
  return n ||= e[this.getScriptPartFromCode(t)], n ||= e[this.formatLanguageCode(t)], n ||= e[this.getLanguagePartFromCode(t)], n ||= e.default, n || [];
547
564
  }
548
565
  toResolveHierarchy(e, t) {
549
- let n = this.getFallbackCodes(t || this.options.fallbackLng || [], e), i = [], a = (e) => {
550
- e && (this.isSupportedCode(e) ? i.push(e) : this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`));
566
+ let n = this.options.fallbackLng, i = Array.isArray(n) ? n.join("|") : n;
567
+ i !== this._cachedFallbackLng && (this.resolveHierarchyCache = {}, this._cachedFallbackLng = i);
568
+ let a = t === void 0 || t === !1 || r(t), o = t === void 0 && typeof this.options.fallbackLng == "function", s = r(e) && a && !o, c = null;
569
+ if (s) {
570
+ let n;
571
+ n = t === void 0 ? "undefined" : t === !1 ? "boolean:false" : `string:${t}`, c = `${e.length}:${e}|${n}`;
572
+ }
573
+ if (c !== null) {
574
+ let e = this.resolveHierarchyCache[c];
575
+ if (e !== void 0) return e.slice();
576
+ }
577
+ let l = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), u = [], d = (e) => {
578
+ e && (this.isSupportedCode(e) ? u.push(e) : this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`));
551
579
  };
552
- return r(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && a(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && a(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && a(this.getLanguagePartFromCode(e))) : r(e) && a(this.formatLanguageCode(e)), n.forEach((e) => {
553
- i.indexOf(e) < 0 && a(this.formatLanguageCode(e));
554
- }), i;
580
+ return r(e) && (e.includes("-") || e.includes("_")) ? (this.options.load !== "languageOnly" && d(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && d(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && d(this.getLanguagePartFromCode(e))) : r(e) && d(this.formatLanguageCode(e)), l.forEach((e) => {
581
+ u.includes(e) || d(this.formatLanguageCode(e));
582
+ }), c === null ? u : (this.resolveHierarchyCache[c] = u, u.slice());
555
583
  }
556
- }, P = {
584
+ }, I = {
557
585
  zero: 0,
558
586
  one: 1,
559
587
  two: 2,
560
588
  few: 3,
561
589
  many: 4,
562
590
  other: 5
563
- }, F = {
591
+ }, L = {
564
592
  select: (e) => e === 1 ? "one" : "other",
565
593
  resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
566
- }, I = class {
567
- constructor(e) {
568
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
594
+ }, R = class {
595
+ constructor(e, t = {}) {
569
596
  this.languageUtils = e, this.options = t, this.logger = E.create("pluralResolver"), this.pluralRulesCache = {};
570
597
  }
571
- addRule(e, t) {
572
- this.rules[e] = t;
573
- }
574
598
  clearCache() {
575
599
  this.pluralRulesCache = {};
576
600
  }
577
- getRule(e) {
578
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = w(e === "dev" ? "en" : e), r = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
601
+ getRule(e, t = {}) {
602
+ let n = w(e === "dev" ? "en" : e), r = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
579
603
  cleanedCode: n,
580
604
  type: r
581
605
  });
@@ -584,54 +608,51 @@ var n = {
584
608
  try {
585
609
  a = new Intl.PluralRules(n, { type: r });
586
610
  } catch {
587
- if (!Intl) return this.logger.error("No Intl support, please use an Intl polyfill!"), F;
588
- if (!e.match(/-|_/)) return F;
611
+ if (typeof Intl > "u") return this.logger.error("No Intl support, please use an Intl polyfill!"), L;
612
+ if (!e.match(/-|_/)) return L;
589
613
  let n = this.languageUtils.getLanguagePartFromCode(e);
590
614
  a = this.getRule(n, t);
591
615
  }
592
616
  return this.pluralRulesCache[i] = a, a;
593
617
  }
594
- needsPlural(e) {
595
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(e, t);
618
+ needsPlural(e, t = {}) {
619
+ let n = this.getRule(e, t);
596
620
  return n ||= this.getRule("dev", t), n?.resolvedOptions().pluralCategories.length > 1;
597
621
  }
598
- getPluralFormsOfKey(e, t) {
599
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
622
+ getPluralFormsOfKey(e, t, n = {}) {
600
623
  return this.getSuffixes(e, n).map((e) => `${t}${e}`);
601
624
  }
602
- getSuffixes(e) {
603
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(e, t);
604
- return n ||= this.getRule("dev", t), n ? n.resolvedOptions().pluralCategories.sort((e, t) => P[e] - P[t]).map((e) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${e}`) : [];
625
+ getSuffixes(e, t = {}) {
626
+ let n = this.getRule(e, t);
627
+ return n ||= this.getRule("dev", t), n ? n.resolvedOptions().pluralCategories.sort((e, t) => I[e] - I[t]).map((e) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${e}`) : [];
605
628
  }
606
- getSuffix(e, t) {
607
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, r = this.getRule(e, n);
629
+ getSuffix(e, t, n = {}) {
630
+ let r = this.getRule(e, n);
608
631
  return r ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${r.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, n));
609
632
  }
610
- }, L = function(e, t, n) {
611
- let i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", a = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, o = m(e, t, n);
633
+ }, z = (e, t, n, i = ".", a = !0) => {
634
+ let o = m(e, t, n);
612
635
  return !o && a && r(n) && (o = C(e, n, i), o === void 0 && (o = C(t, n, i))), o;
613
- }, R = (e) => e.replace(/\$/g, "$$$$"), z = class {
614
- constructor() {
615
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
636
+ }, B = (e) => e.replace(/\$/g, "$$$$"), V = class {
637
+ constructor(e = {}) {
616
638
  this.logger = E.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((e) => e), this.init(e);
617
639
  }
618
- init() {
619
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
640
+ init(e = {}) {
620
641
  e.interpolation ||= { escapeValue: !0 };
621
642
  let { escape: t, escapeValue: n, useRawValueToEscape: r, prefix: i, prefixEscaped: a, suffix: o, suffixEscaped: s, formatSeparator: c, unescapeSuffix: l, unescapePrefix: u, nestingPrefix: d, nestingPrefixEscaped: f, nestingSuffix: p, nestingSuffixEscaped: m, nestingOptionsSeparator: h, maxReplaces: _, alwaysFormat: y } = e.interpolation;
622
- this.escape = t === void 0 ? v : t, this.escapeValue = n === void 0 || n, this.useRawValueToEscape = r !== void 0 && r, this.prefix = i ? g(i) : a || "{{", this.suffix = o ? g(o) : s || "}}", this.formatSeparator = c || ",", this.unescapePrefix = l ? "" : u || "-", this.unescapeSuffix = this.unescapePrefix ? "" : l || "", this.nestingPrefix = d ? g(d) : f || g("$t("), this.nestingSuffix = p ? g(p) : m || g(")"), this.nestingOptionsSeparator = h || ",", this.maxReplaces = _ || 1e3, this.alwaysFormat = y !== void 0 && y, this.resetRegExp();
643
+ this.escape = t === void 0 ? v : t, this.escapeValue = n === void 0 || n, this.useRawValueToEscape = r !== void 0 && r, this.prefix = i ? g(i) : a || "{{", this.suffix = o ? g(o) : s || "}}", this.formatSeparator = c || ",", this.unescapePrefix = l ? "" : u ? g(u) : "-", this.unescapeSuffix = this.unescapePrefix ? "" : l ? g(l) : "", this.nestingPrefix = d ? g(d) : f || g("$t("), this.nestingSuffix = p ? g(p) : m || g(")"), this.nestingOptionsSeparator = h || ",", this.maxReplaces = _ || 1e3, this.alwaysFormat = y !== void 0 && y, this.resetRegExp();
623
644
  }
624
645
  reset() {
625
646
  this.options && this.init(this.options);
626
647
  }
627
648
  resetRegExp() {
628
649
  let e = (e, t) => e?.source === t ? (e.lastIndex = 0, e) : new RegExp(t, "g");
629
- this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
650
+ this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
630
651
  }
631
652
  interpolate(e, t, n, i) {
632
653
  let o, s, c, l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (e) => {
633
- if (e.indexOf(this.formatSeparator) < 0) {
634
- let r = L(t, l, e, this.options.keySeparator, this.options.ignoreJSONStructure);
654
+ if (!e.includes(this.formatSeparator)) {
655
+ let r = z(t, l, e, this.options.keySeparator, this.options.ignoreJSONStructure);
635
656
  return this.alwaysFormat ? this.format(r, void 0, n, {
636
657
  ...i,
637
658
  ...t,
@@ -639,20 +660,20 @@ var n = {
639
660
  }) : r;
640
661
  }
641
662
  let r = e.split(this.formatSeparator), a = r.shift().trim(), o = r.join(this.formatSeparator).trim();
642
- return this.format(L(t, l, a, this.options.keySeparator, this.options.ignoreJSONStructure), o, n, {
663
+ return this.format(z(t, l, a, this.options.keySeparator, this.options.ignoreJSONStructure), o, n, {
643
664
  ...i,
644
665
  ...t,
645
666
  interpolationkey: a
646
667
  });
647
668
  };
648
- this.resetRegExp();
669
+ this.resetRegExp(), !this.escapeValue && typeof e == "string" && /\$t\([^)]*\{[^}]*\{\{/.test(e) && this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");
649
670
  let d = i?.missingInterpolationHandler || this.options.missingInterpolationHandler, f = i?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : i.interpolation.skipOnVariables;
650
671
  return [{
651
672
  regex: this.regexpUnescape,
652
- safeValue: (e) => R(e)
673
+ safeValue: (e) => e
653
674
  }, {
654
675
  regex: this.regexp,
655
- safeValue: (e) => this.escapeValue ? R(this.escape(e)) : R(e)
676
+ safeValue: (e) => this.escapeValue ? this.escape(e) : e
656
677
  }].forEach((t) => {
657
678
  for (c = 0; o = t.regex.exec(e);) {
658
679
  let n = o[1].trim();
@@ -666,18 +687,18 @@ var n = {
666
687
  } else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`), s = "";
667
688
  else !r(s) && !this.useRawValueToEscape && (s = a(s));
668
689
  let l = t.safeValue(s);
669
- if (e = e.replace(o[0], l), f ? (t.regex.lastIndex += s.length, t.regex.lastIndex -= o[0].length) : t.regex.lastIndex = 0, c++, c >= this.maxReplaces) break;
690
+ if (e = e.replace(o[0], B(l)), f ? (t.regex.lastIndex += l.length, t.regex.lastIndex -= o[0].length) : t.regex.lastIndex = 0, c++, c >= this.maxReplaces) break;
670
691
  }
671
692
  }), e;
672
693
  }
673
- nest(e, t) {
674
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, i, o, s, c = (e, t) => {
694
+ nest(e, t, n = {}) {
695
+ let i, o, s, c = (e, t) => {
675
696
  let n = this.nestingOptionsSeparator;
676
- if (e.indexOf(n) < 0) return e;
677
- let r = e.split(RegExp(`${n}[ ]*{`)), i = `{${r[1]}`;
697
+ if (!e.includes(n)) return e;
698
+ let r = e.split(RegExp(`${g(n)}[ ]*{`)), i = `{${r[1]}`;
678
699
  e = r[0], i = this.interpolate(i, s);
679
700
  let a = i.match(/'/g), o = i.match(/"/g);
680
- ((a?.length ?? 0) % 2 == 0 && !o || o.length % 2 != 0) && (i = i.replace(/'/g, "\""));
701
+ ((a?.length ?? 0) % 2 == 0 && !o || (o?.length ?? 0) % 2 != 0) && (i = i.replace(/'/g, "\""));
681
702
  try {
682
703
  s = JSON.parse(i), t && (s = {
683
704
  ...t,
@@ -686,31 +707,27 @@ var n = {
686
707
  } catch (t) {
687
708
  return this.logger.warn(`failed parsing options string in nesting for key ${e}`, t), `${e}${n}${i}`;
688
709
  }
689
- return s.defaultValue && s.defaultValue.indexOf(this.prefix) > -1 && delete s.defaultValue, e;
710
+ return s.defaultValue && s.defaultValue.includes(this.prefix) && delete s.defaultValue, e;
690
711
  };
691
712
  for (; i = this.nestingRegexp.exec(e);) {
692
713
  let l = [];
693
714
  s = { ...n }, s = s.replace && !r(s.replace) ? s.replace : s, s.applyPostProcessor = !1, delete s.defaultValue;
694
- let u = !1;
695
- if (i[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(i[1])) {
696
- let e = i[1].split(this.formatSeparator).map((e) => e.trim());
697
- i[1] = e.shift(), l = e, u = !0;
698
- }
699
- if (o = t(c.call(this, i[1].trim(), s), s), o && i[0] === e && !r(o)) return o;
700
- r(o) || (o = a(o)), o ||= (this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`), ""), u && (o = l.reduce((e, t) => this.format(e, t, n.lng, {
715
+ let u = /{.*}/s.test(i[1]) ? i[1].lastIndexOf("}") + 1 : i[1].indexOf(this.formatSeparator);
716
+ if (u !== -1 && (l = i[1].slice(u).split(this.formatSeparator).map((e) => e.trim()).filter(Boolean), i[1] = i[1].slice(0, u)), o = t(c.call(this, i[1].trim(), s), s), o && i[0] === e && !r(o)) return o;
717
+ r(o) || (o = a(o)), o ||= (this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`), ""), l.length && (o = l.reduce((e, t) => this.format(e, t, n.lng, {
701
718
  ...n,
702
719
  interpolationkey: i[1].trim()
703
- }), o.trim())), e = e.replace(i[0], o), this.regexp.lastIndex = 0;
720
+ }), o.trim())), e = e.replace(i[0], B(a(o))), this.regexp.lastIndex = 0;
704
721
  }
705
722
  return e;
706
723
  }
707
- }, B = (e) => {
724
+ }, H = (e) => {
708
725
  let t = e.toLowerCase().trim(), n = {};
709
- if (e.indexOf("(") > -1) {
726
+ if (e.includes("(")) {
710
727
  let r = e.split("(");
711
728
  t = r[0].toLowerCase().trim();
712
- let i = r[1].substring(0, r[1].length - 1);
713
- t === "currency" && i.indexOf(":") < 0 ? n.currency ||= i.trim() : t === "relativetime" && i.indexOf(":") < 0 ? n.range ||= i.trim() : i.split(";").forEach((e) => {
729
+ let i = r[1].slice(0, -1);
730
+ t === "currency" && !i.includes(":") ? n.currency ||= i.trim() : t === "relativetime" && !i.includes(":") ? n.range ||= i.trim() : i.split(";").forEach((e) => {
714
731
  if (e) {
715
732
  let [t, ...r] = e.split(":"), i = r.join(":").trim().replace(/^'+|'+$/g, ""), a = t.trim();
716
733
  n[a] || (n[a] = i), i === "false" && (n[a] = !1), i === "true" && (n[a] = !0), isNaN(i) || (n[a] = parseInt(i, 10));
@@ -721,7 +738,7 @@ var n = {
721
738
  formatName: t,
722
739
  formatOptions: n
723
740
  };
724
- }, V = (e) => {
741
+ }, U = (e) => {
725
742
  let t = {};
726
743
  return (n, r, i) => {
727
744
  let a = i;
@@ -732,53 +749,55 @@ var n = {
732
749
  let o = r + JSON.stringify(a), s = t[o];
733
750
  return s || (s = e(w(r), i), t[o] = s), s(n);
734
751
  };
735
- }, H = class {
736
- constructor() {
737
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
738
- this.logger = E.create("formatter"), this.options = e, this.formats = {
739
- number: V((e, t) => {
752
+ }, W = (e) => (t, n, r) => e(w(n), r)(t), G = class {
753
+ constructor(e = {}) {
754
+ this.logger = E.create("formatter"), this.options = e, this.init(e);
755
+ }
756
+ init(e, t = { interpolation: {} }) {
757
+ this.formatSeparator = t.interpolation.formatSeparator || ",";
758
+ let n = t.cacheInBuiltFormats ? U : W;
759
+ this.formats = {
760
+ number: n((e, t) => {
740
761
  let n = new Intl.NumberFormat(e, { ...t });
741
762
  return (e) => n.format(e);
742
763
  }),
743
- currency: V((e, t) => {
764
+ currency: n((e, t) => {
744
765
  let n = new Intl.NumberFormat(e, {
745
766
  ...t,
746
767
  style: "currency"
747
768
  });
748
769
  return (e) => n.format(e);
749
770
  }),
750
- datetime: V((e, t) => {
771
+ datetime: n((e, t) => {
751
772
  let n = new Intl.DateTimeFormat(e, { ...t });
752
773
  return (e) => n.format(e);
753
774
  }),
754
- relativetime: V((e, t) => {
775
+ relativetime: n((e, t) => {
755
776
  let n = new Intl.RelativeTimeFormat(e, { ...t });
756
777
  return (e) => n.format(e, t.range || "day");
757
778
  }),
758
- list: V((e, t) => {
779
+ list: n((e, t) => {
759
780
  let n = new Intl.ListFormat(e, { ...t });
760
781
  return (e) => n.format(e);
761
782
  })
762
- }, this.init(e);
763
- }
764
- init(e) {
765
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { interpolation: {} };
766
- this.formatSeparator = t.interpolation.formatSeparator || ",";
783
+ };
767
784
  }
768
785
  add(e, t) {
769
786
  this.formats[e.toLowerCase().trim()] = t;
770
787
  }
771
788
  addCached(e, t) {
772
- this.formats[e.toLowerCase().trim()] = V(t);
773
- }
774
- format(e, t, n) {
775
- let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, i = t.split(this.formatSeparator);
776
- if (i.length > 1 && i[0].indexOf("(") > 1 && i[0].indexOf(")") < 0 && i.find((e) => e.indexOf(")") > -1)) {
777
- let e = i.findIndex((e) => e.indexOf(")") > -1);
778
- i[0] = [i[0], ...i.splice(1, e)].join(this.formatSeparator);
789
+ this.formats[e.toLowerCase().trim()] = U(t);
790
+ }
791
+ format(e, t, n, r = {}) {
792
+ if (!t || e == null) return e;
793
+ let i = t.split(this.formatSeparator), a = [];
794
+ for (let e = 0; e < i.length; e++) {
795
+ let t = i[e];
796
+ for (; t.indexOf("(") > -1 && !t.includes(")") && e + 1 < i.length;) t = `${t}${this.formatSeparator}${i[++e]}`;
797
+ a.push(t);
779
798
  }
780
- return i.reduce((e, t) => {
781
- let { formatName: i, formatOptions: a } = B(t);
799
+ return a.reduce((e, t) => {
800
+ let { formatName: i, formatOptions: a } = H(t);
782
801
  if (this.formats[i]) {
783
802
  let t = e;
784
803
  try {
@@ -796,11 +815,10 @@ var n = {
796
815
  return e;
797
816
  }, e);
798
817
  }
799
- }, U = (e, t) => {
818
+ }, K = (e, t) => {
800
819
  e.pending[t] !== void 0 && (delete e.pending[t], e.pendingCount--);
801
- }, W = class extends D {
802
- constructor(e, t, n) {
803
- let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
820
+ }, q = class extends D {
821
+ constructor(e, t, n, r = {}) {
804
822
  super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = r, this.logger = E.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = r.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = r.maxRetries >= 0 ? r.maxRetries : 5, this.retryTimeout = r.retryTimeout >= 1 ? r.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(n, r.backend, r);
805
823
  }
806
824
  queueLoad(e, t, n, r) {
@@ -829,7 +847,7 @@ var n = {
829
847
  t && this.emit("failedLoading", i, a, t), !t && n && this.store.addResourceBundle(i, a, n, void 0, void 0, { skipCopy: !0 }), this.state[e] = t ? -1 : 2, t && n && (this.state[e] = 0);
830
848
  let o = {};
831
849
  this.queue.forEach((n) => {
832
- f(n.loaded, [i], a), U(n, e), t && n.errors.push(t), n.pendingCount === 0 && !n.done && (Object.keys(n.loaded).forEach((e) => {
850
+ f(n.loaded, [i], a), K(n, e), t && n.errors.push(t), n.pendingCount === 0 && !n.done && (Object.keys(n.loaded).forEach((e) => {
833
851
  o[e] || (o[e] = {});
834
852
  let t = n.loaded[e];
835
853
  t.length && t.forEach((t) => {
@@ -838,8 +856,7 @@ var n = {
838
856
  }), n.done = !0, n.errors.length ? n.callback(n.errors) : n.callback());
839
857
  }), this.emit("loaded", o), this.queue = this.queue.filter((e) => !e.done);
840
858
  }
841
- read(e, t, n) {
842
- let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout, a = arguments.length > 5 ? arguments[5] : void 0;
859
+ read(e, t, n, r = 0, i = this.retryTimeout, a) {
843
860
  if (!e.length) return a(null, {});
844
861
  if (this.readingCalls >= this.maxParallelReads) {
845
862
  this.waitingReads.push({
@@ -860,7 +877,7 @@ var n = {
860
877
  }
861
878
  if (o && s && r < this.maxRetries) {
862
879
  setTimeout(() => {
863
- this.read.call(this, e, t, n, r + 1, i * 2, a);
880
+ this.read(e, t, n, r + 1, i * 2, a);
864
881
  }, i);
865
882
  return;
866
883
  }
@@ -877,8 +894,7 @@ var n = {
877
894
  }
878
895
  return s(e, t, o);
879
896
  }
880
- prepareLoading(e, t) {
881
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, i = arguments.length > 3 ? arguments[3] : void 0;
897
+ prepareLoading(e, t, n = {}, i) {
882
898
  if (!this.backend) return this.logger.warn("No backend was added via i18next.use. Will not load resources."), i && i();
883
899
  r(e) && (e = this.languageUtils.toResolveHierarchy(e)), r(t) && (t = [t]);
884
900
  let a = this.queueLoad(e, t, n, i);
@@ -893,14 +909,13 @@ var n = {
893
909
  reload(e, t, n) {
894
910
  this.prepareLoading(e, t, { reload: !0 }, n);
895
911
  }
896
- loadOne(e) {
897
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", n = e.split("|"), r = n[0], i = n[1];
912
+ loadOne(e, t = "") {
913
+ let n = e.split("|"), r = n[0], i = n[1];
898
914
  this.read(r, i, "read", void 0, void 0, (n, a) => {
899
915
  n && this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`, n), !n && a && this.logger.log(`${t}loaded namespace ${i} for language ${r}`, a), this.loaded(e, n, a);
900
916
  });
901
917
  }
902
- saveMissing(e, t, n, r, i) {
903
- let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {}, o = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {};
918
+ saveMissing(e, t, n, r, i, a = {}, o = () => {}) {
904
919
  if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
905
920
  this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
906
921
  return;
@@ -922,7 +937,7 @@ var n = {
922
937
  !e || !e[0] || this.store.addResource(e[0], t, n, r);
923
938
  }
924
939
  }
925
- }, G = () => ({
940
+ }, J = () => ({
926
941
  debug: !1,
927
942
  initAsync: !0,
928
943
  ns: ["translation"],
@@ -933,11 +948,11 @@ var n = {
933
948
  nonExplicitSupportedLngs: !1,
934
949
  load: "all",
935
950
  preload: !1,
936
- simplifyPluralSuffix: !0,
937
951
  keySeparator: ".",
938
952
  nsSeparator: ":",
939
953
  pluralSeparator: "_",
940
954
  contextSeparator: "_",
955
+ enableSelector: !1,
941
956
  partialBundledLanguages: !1,
942
957
  saveMissing: !1,
943
958
  updateMissing: !1,
@@ -967,7 +982,6 @@ var n = {
967
982
  },
968
983
  interpolation: {
969
984
  escapeValue: !0,
970
- format: (e) => e,
971
985
  prefix: "{{",
972
986
  suffix: "}}",
973
987
  formatSeparator: ",",
@@ -977,56 +991,49 @@ var n = {
977
991
  nestingOptionsSeparator: ",",
978
992
  maxReplaces: 1e3,
979
993
  skipOnVariables: !0
980
- }
981
- }), K = (e) => (r(e.ns) && (e.ns = [e.ns]), r(e.fallbackLng) && (e.fallbackLng = [e.fallbackLng]), r(e.fallbackNS) && (e.fallbackNS = [e.fallbackNS]), e.supportedLngs?.indexOf?.("cimode") < 0 && (e.supportedLngs = e.supportedLngs.concat(["cimode"])), typeof e.initImmediate == "boolean" && (e.initAsync = e.initImmediate), e), q = () => {}, J = (e) => {
994
+ },
995
+ cacheInBuiltFormats: !0
996
+ }), Y = (e) => (r(e.ns) && (e.ns = [e.ns]), r(e.fallbackLng) && (e.fallbackLng = [e.fallbackLng]), r(e.fallbackNS) && (e.fallbackNS = [e.fallbackNS]), e.supportedLngs && !e.supportedLngs.includes("cimode") && (e.supportedLngs = e.supportedLngs.concat(["cimode"])), e), X = () => {}, Z = (e) => {
982
997
  Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((t) => {
983
998
  typeof e[t] == "function" && (e[t] = e[t].bind(e));
984
999
  });
985
- }, Y = class e extends D {
986
- constructor() {
987
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
988
- if (super(), this.options = K(e), this.services = {}, this.logger = E, this.modules = { external: [] }, J(this), t && !this.isInitialized && !e.isClone) {
1000
+ }, Q = class e extends D {
1001
+ constructor(e = {}, t) {
1002
+ if (super(), this.options = Y(e), this.services = {}, this.logger = E, this.modules = { external: [] }, Z(this), t && !this.isInitialized && !e.isClone) {
989
1003
  if (!this.options.initAsync) return this.init(e, t), this;
990
1004
  setTimeout(() => {
991
1005
  this.init(e, t);
992
1006
  }, 0);
993
1007
  }
994
1008
  }
995
- init() {
996
- var e = this;
997
- let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = arguments.length > 1 ? arguments[1] : void 0;
998
- this.isInitializing = !0, typeof t == "function" && (n = t, t = {}), t.defaultNS == null && t.ns && (r(t.ns) ? t.defaultNS = t.ns : t.ns.indexOf("translation") < 0 && (t.defaultNS = t.ns[0]));
999
- let a = G();
1009
+ init(e = {}, t) {
1010
+ this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (r(e.ns) ? e.defaultNS = e.ns : e.ns.includes("translation") || (e.defaultNS = e.ns[0]));
1011
+ let n = J();
1000
1012
  this.options = {
1001
- ...a,
1013
+ ...n,
1002
1014
  ...this.options,
1003
- ...K(t)
1015
+ ...Y(e)
1004
1016
  }, this.options.interpolation = {
1005
- ...a.interpolation,
1017
+ ...n.interpolation,
1006
1018
  ...this.options.interpolation
1007
- }, t.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = t.keySeparator), t.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = t.nsSeparator);
1008
- let o = (e) => e ? typeof e == "function" ? new e() : e : null;
1019
+ }, e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator), typeof this.options.overloadTranslationOptionHandler != "function" && (this.options.overloadTranslationOptionHandler = n.overloadTranslationOptionHandler);
1020
+ let a = (e) => e ? typeof e == "function" ? new e() : e : null;
1009
1021
  if (!this.options.isClone) {
1010
- this.modules.logger ? E.init(o(this.modules.logger), this.options) : E.init(null, this.options);
1011
- let t;
1012
- t = this.modules.formatter ? this.modules.formatter : H;
1013
- let n = new N(this.options);
1022
+ this.modules.logger ? E.init(a(this.modules.logger), this.options) : E.init(null, this.options);
1023
+ let e;
1024
+ e = this.modules.formatter ? this.modules.formatter : G;
1025
+ let t = new F(this.options);
1014
1026
  this.store = new O(this.options.resources, this.options);
1015
- let r = this.services;
1016
- r.logger = E, r.resourceStore = this.store, r.languageUtils = n, r.pluralResolver = new I(n, {
1017
- prepend: this.options.pluralSeparator,
1018
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1019
- }), t && (!this.options.interpolation.format || this.options.interpolation.format === a.interpolation.format) && (r.formatter = o(t), r.formatter.init(r, this.options), this.options.interpolation.format = r.formatter.format.bind(r.formatter)), r.interpolator = new z(this.options), r.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) }, r.backendConnector = new W(o(this.modules.backend), r.resourceStore, r, this.options), r.backendConnector.on("*", function(t) {
1020
- var n = [...arguments].slice(1);
1021
- e.emit(t, ...n);
1022
- }), this.modules.languageDetector && (r.languageDetector = o(this.modules.languageDetector), r.languageDetector.init && r.languageDetector.init(r, this.options.detection, this.options)), this.modules.i18nFormat && (r.i18nFormat = o(this.modules.i18nFormat), r.i18nFormat.init && r.i18nFormat.init(this)), this.translator = new M(this.services, this.options), this.translator.on("*", function(t) {
1023
- var n = [...arguments].slice(1);
1024
- e.emit(t, ...n);
1027
+ let n = this.services;
1028
+ n.logger = E, n.resourceStore = this.store, n.languageUtils = t, n.pluralResolver = new R(t, { prepend: this.options.pluralSeparator }), e && (n.formatter = a(e), n.formatter.init && n.formatter.init(n, this.options), this.options.interpolation.format = n.formatter.format.bind(n.formatter)), n.interpolator = new V(this.options), n.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) }, n.backendConnector = new q(a(this.modules.backend), n.resourceStore, n, this.options), n.backendConnector.on("*", (e, ...t) => {
1029
+ this.emit(e, ...t);
1030
+ }), this.modules.languageDetector && (n.languageDetector = a(this.modules.languageDetector), n.languageDetector.init && n.languageDetector.init(n, this.options.detection, this.options)), this.modules.i18nFormat && (n.i18nFormat = a(this.modules.i18nFormat), n.i18nFormat.init && n.i18nFormat.init(this)), this.translator = new P(this.services, this.options), this.translator.on("*", (e, ...t) => {
1031
+ this.emit(e, ...t);
1025
1032
  }), this.modules.external.forEach((e) => {
1026
1033
  e.init && e.init(this);
1027
1034
  });
1028
1035
  }
1029
- if (this.format = this.options.interpolation.format, n ||= q, this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1036
+ if (this.format = this.options.interpolation.format, t ||= X, this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1030
1037
  let e = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1031
1038
  e.length > 0 && e[0] !== "dev" && (this.options.lng = e[0]);
1032
1039
  }
@@ -1035,46 +1042,42 @@ var n = {
1035
1042
  "hasResourceBundle",
1036
1043
  "getResourceBundle",
1037
1044
  "getDataByLanguage"
1038
- ].forEach((t) => {
1039
- this[t] = function() {
1040
- return e.store[t](...arguments);
1041
- };
1045
+ ].forEach((e) => {
1046
+ this[e] = (...t) => this.store[e](...t);
1042
1047
  }), [
1043
1048
  "addResource",
1044
1049
  "addResources",
1045
1050
  "addResourceBundle",
1046
1051
  "removeResourceBundle"
1047
- ].forEach((t) => {
1048
- this[t] = function() {
1049
- return e.store[t](...arguments), e;
1050
- };
1052
+ ].forEach((e) => {
1053
+ this[e] = (...t) => (this.store[e](...t), this);
1051
1054
  });
1052
- let s = i(), c = () => {
1053
- let e = (e, t) => {
1054
- this.isInitializing = !1, this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), s.resolve(t), n(e, t);
1055
+ let o = i(), s = () => {
1056
+ let e = (e, n) => {
1057
+ this.isInitializing = !1, this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), o.resolve(n), t(e, n);
1055
1058
  };
1056
- if (this.languages && !this.isInitialized) return e(null, this.t.bind(this));
1059
+ if ((this.languages || this.isLanguageChangingTo) && !this.isInitialized) return e(null, this.t.bind(this));
1057
1060
  this.changeLanguage(this.options.lng, e);
1058
1061
  };
1059
- return this.options.resources || !this.options.initAsync ? c() : setTimeout(c, 0), s;
1062
+ return this.options.resources || !this.options.initAsync ? s() : setTimeout(s, 0), o;
1060
1063
  }
1061
- loadResources(e) {
1062
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : q, n = r(e) ? e : this.language;
1063
- if (typeof e == "function" && (t = e), !this.options.resources || this.options.partialBundledLanguages) {
1064
- if (n?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return t();
1065
- let e = [], r = (t) => {
1064
+ loadResources(e, t = X) {
1065
+ let n = t, i = r(e) ? e : this.language;
1066
+ if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
1067
+ if (i?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return n();
1068
+ let e = [], t = (t) => {
1066
1069
  t && t !== "cimode" && this.services.languageUtils.toResolveHierarchy(t).forEach((t) => {
1067
- t !== "cimode" && e.indexOf(t) < 0 && e.push(t);
1070
+ t !== "cimode" && (e.includes(t) || e.push(t));
1068
1071
  });
1069
1072
  };
1070
- n ? r(n) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e) => r(e)), this.options.preload?.forEach?.((e) => r(e)), this.services.backendConnector.load(e, this.options.ns, (e) => {
1071
- !e && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), t(e);
1073
+ i ? t(i) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e) => t(e)), this.options.preload?.forEach?.((e) => t(e)), this.services.backendConnector.load(e, this.options.ns, (e) => {
1074
+ !e && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(e);
1072
1075
  });
1073
- } else t(null);
1076
+ } else n(null);
1074
1077
  }
1075
1078
  reloadResources(e, t, n) {
1076
1079
  let r = i();
1077
- return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = void 0), e ||= this.languages, t ||= this.options.ns, n ||= q, this.services.backendConnector.reload(e, t, (e) => {
1080
+ return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = void 0), e ||= this.languages, t ||= this.options.ns, n ||= X, this.services.backendConnector.reload(e, t, (e) => {
1078
1081
  r.resolve(), n(e);
1079
1082
  }), r;
1080
1083
  }
@@ -1084,63 +1087,60 @@ var n = {
1084
1087
  return e.type === "backend" && (this.modules.backend = e), (e.type === "logger" || e.log && e.warn && e.error) && (this.modules.logger = e), e.type === "languageDetector" && (this.modules.languageDetector = e), e.type === "i18nFormat" && (this.modules.i18nFormat = e), e.type === "postProcessor" && k.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1085
1088
  }
1086
1089
  setResolvedLanguage(e) {
1087
- if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) for (let e = 0; e < this.languages.length; e++) {
1088
- let t = this.languages[e];
1089
- if (!(["cimode", "dev"].indexOf(t) > -1) && this.store.hasLanguageSomeTranslations(t)) {
1090
- this.resolvedLanguage = t;
1091
- break;
1090
+ if (!(!e || !this.languages) && !["cimode", "dev"].includes(e)) {
1091
+ for (let e = 0; e < this.languages.length; e++) {
1092
+ let t = this.languages[e];
1093
+ if (!["cimode", "dev"].includes(t) && this.store.hasLanguageSomeTranslations(t)) {
1094
+ this.resolvedLanguage = t;
1095
+ break;
1096
+ }
1092
1097
  }
1098
+ !this.resolvedLanguage && !this.languages.includes(e) && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
1093
1099
  }
1094
1100
  }
1095
1101
  changeLanguage(e, t) {
1096
- var n = this;
1097
1102
  this.isLanguageChangingTo = e;
1098
- let a = i();
1103
+ let n = i();
1099
1104
  this.emit("languageChanging", e);
1100
- let o = (e) => {
1105
+ let a = (e) => {
1101
1106
  this.language = e, this.languages = this.services.languageUtils.toResolveHierarchy(e), this.resolvedLanguage = void 0, this.setResolvedLanguage(e);
1102
- }, s = (e, r) => {
1103
- r ? (o(r), this.translator.changeLanguage(r), this.isLanguageChangingTo = void 0, this.emit("languageChanged", r), this.logger.log("languageChanged", r)) : this.isLanguageChangingTo = void 0, a.resolve(function() {
1104
- return n.t(...arguments);
1105
- }), t && t(e, function() {
1106
- return n.t(...arguments);
1107
- });
1108
- }, c = (t) => {
1107
+ }, o = (r, i) => {
1108
+ i ? this.isLanguageChangingTo === e && (a(i), this.translator.changeLanguage(i), this.isLanguageChangingTo = void 0, this.emit("languageChanged", i), this.logger.log("languageChanged", i)) : this.isLanguageChangingTo = void 0, n.resolve((...e) => this.t(...e)), t && t(r, (...e) => this.t(...e));
1109
+ }, s = (t) => {
1109
1110
  !e && !t && this.services.languageDetector && (t = []);
1110
- let n = r(t) ? t : this.services.languageUtils.getBestMatchFromCodes(t);
1111
- n && (this.language || o(n), this.translator.language || this.translator.changeLanguage(n), this.services.languageDetector?.cacheUserLanguage?.(n)), this.loadResources(n, (e) => {
1112
- s(e, n);
1111
+ let n = r(t) ? t : t && t[0], i = this.store.hasLanguageSomeTranslations(n) ? n : this.services.languageUtils.getBestMatchFromCodes(r(t) ? [t] : t);
1112
+ i && (this.language || a(i), this.translator.language || this.translator.changeLanguage(i), this.services.languageDetector?.cacheUserLanguage?.(i)), this.loadResources(i, (e) => {
1113
+ o(e, i);
1113
1114
  });
1114
1115
  };
1115
- return !e && this.services.languageDetector && !this.services.languageDetector.async ? c(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(c) : this.services.languageDetector.detect(c) : c(e), a;
1116
- }
1117
- getFixedT(e, t, n) {
1118
- var i = this;
1119
- let a = function(e, t) {
1120
- let r;
1121
- if (typeof t != "object") {
1122
- var o = [...arguments].slice(2);
1123
- r = i.options.overloadTranslationOptionHandler([e, t].concat(o));
1124
- } else r = { ...t };
1125
- r.lng = r.lng || a.lng, r.lngs = r.lngs || a.lngs, r.ns = r.ns || a.ns, r.keyPrefix !== "" && (r.keyPrefix = r.keyPrefix || n || a.keyPrefix);
1126
- let s = i.options.keySeparator || ".", c;
1127
- return c = r.keyPrefix && Array.isArray(e) ? e.map((e) => `${r.keyPrefix}${s}${e}`) : r.keyPrefix ? `${r.keyPrefix}${s}${e}` : e, i.t(c, r);
1116
+ return !e && this.services.languageDetector && !this.services.languageDetector.async ? s(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(s) : this.services.languageDetector.detect(s) : s(e), n;
1117
+ }
1118
+ getFixedT(e, t, n, i) {
1119
+ let a = i?.scopeNs, o = (e, t, ...r) => {
1120
+ let i;
1121
+ i = typeof t == "object" ? { ...t } : this.options.overloadTranslationOptionHandler([e, t].concat(r)), i.lng = i.lng || o.lng, i.lngs = i.lngs || o.lngs;
1122
+ let s = i.ns !== void 0 && i.ns !== null;
1123
+ i.ns = i.ns || o.ns, i.keyPrefix !== "" && (i.keyPrefix = i.keyPrefix || n || o.keyPrefix);
1124
+ let c = {
1125
+ ...this.options,
1126
+ ...i
1127
+ };
1128
+ Array.isArray(a) && !s && (c.ns = a), typeof i.keyPrefix == "function" && (i.keyPrefix = M(i.keyPrefix, c));
1129
+ let l = this.options.keySeparator || ".", u;
1130
+ return i.keyPrefix && Array.isArray(e) ? u = e.map((e) => (typeof e == "function" && (e = M(e, c)), `${i.keyPrefix}${l}${e}`)) : (typeof e == "function" && (e = M(e, c)), u = i.keyPrefix ? `${i.keyPrefix}${l}${e}` : e), this.t(u, i);
1128
1131
  };
1129
- return r(e) ? a.lng = e : a.lngs = e, a.ns = t, a.keyPrefix = n, a;
1132
+ return r(e) ? o.lng = e : o.lngs = e, o.ns = t, o.keyPrefix = n, o;
1130
1133
  }
1131
- t() {
1132
- var e = [...arguments];
1134
+ t(...e) {
1133
1135
  return this.translator?.translate(...e);
1134
1136
  }
1135
- exists() {
1136
- var e = [...arguments];
1137
+ exists(...e) {
1137
1138
  return this.translator?.exists(...e);
1138
1139
  }
1139
1140
  setDefaultNamespace(e) {
1140
1141
  this.options.defaultNS = e;
1141
1142
  }
1142
- hasLoadedNamespace(e) {
1143
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1143
+ hasLoadedNamespace(e, t = {}) {
1144
1144
  if (!this.isInitialized) return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
1145
1145
  if (!this.languages || !this.languages.length) return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1146
1146
  let n = t.lng || this.resolvedLanguage || this.languages[0], r = this.options ? this.options.fallbackLng : !1, i = this.languages[this.languages.length - 1];
@@ -1158,7 +1158,7 @@ var n = {
1158
1158
  loadNamespaces(e, t) {
1159
1159
  let n = i();
1160
1160
  return this.options.ns ? (r(e) && (e = [e]), e.forEach((e) => {
1161
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
1161
+ this.options.ns.includes(e) || this.options.ns.push(e);
1162
1162
  }), this.loadResources((e) => {
1163
1163
  n.resolve(), t && t(e);
1164
1164
  }), n) : (t && t(), Promise.resolve());
@@ -1166,36 +1166,53 @@ var n = {
1166
1166
  loadLanguages(e, t) {
1167
1167
  let n = i();
1168
1168
  r(e) && (e = [e]);
1169
- let a = this.options.preload || [], o = e.filter((e) => a.indexOf(e) < 0 && this.services.languageUtils.isSupportedCode(e));
1169
+ let a = this.options.preload || [], o = e.filter((e) => !a.includes(e) && this.services.languageUtils.isSupportedCode(e));
1170
1170
  return o.length ? (this.options.preload = a.concat(o), this.loadResources((e) => {
1171
1171
  n.resolve(), t && t(e);
1172
1172
  }), n) : (t && t(), Promise.resolve());
1173
1173
  }
1174
1174
  dir(e) {
1175
1175
  if (e ||= this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language), !e) return "rtl";
1176
- let t = /* @__PURE__ */ "ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb".split("."), n = this.services?.languageUtils || new N(G());
1177
- return t.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1176
+ try {
1177
+ let t = new Intl.Locale(e);
1178
+ if (t && t.getTextInfo) {
1179
+ let e = t.getTextInfo();
1180
+ if (e && e.direction) return e.direction;
1181
+ }
1182
+ } catch {}
1183
+ let t = /* @__PURE__ */ "ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb".split("."), n = this.services?.languageUtils || new F(J());
1184
+ return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.includes(n.getLanguagePartFromCode(e)) || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1178
1185
  }
1179
- static createInstance() {
1180
- let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = arguments.length > 1 ? arguments[1] : void 0;
1181
- return new e(t, n);
1186
+ static createInstance(t = {}, n) {
1187
+ let r = new e(t, n);
1188
+ return r.createInstance = e.createInstance, r;
1182
1189
  }
1183
- cloneInstance() {
1184
- let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : q, r = t.forkResourceStore;
1190
+ cloneInstance(t = {}, n = X) {
1191
+ let r = t.forkResourceStore;
1185
1192
  r && delete t.forkResourceStore;
1186
1193
  let i = {
1187
1194
  ...this.options,
1188
1195
  ...t,
1189
1196
  isClone: !0
1190
1197
  }, a = new e(i);
1191
- return (t.debug !== void 0 || t.prefix !== void 0) && (a.logger = a.logger.clone(t)), [
1198
+ if ((t.debug !== void 0 || t.prefix !== void 0) && (a.logger = a.logger.clone(t)), [
1192
1199
  "store",
1193
1200
  "services",
1194
1201
  "language"
1195
1202
  ].forEach((e) => {
1196
1203
  a[e] = this[e];
1197
- }), a.services = { ...this.services }, a.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, r && (a.store = new O(Object.keys(this.store.data).reduce((e, t) => (e[t] = { ...this.store.data[t] }, Object.keys(e[t]).reduce((n, r) => (n[r] = { ...e[t][r] }, n), {})), {}), i), a.services.resourceStore = a.store), a.translator = new M(a.services, i), a.translator.on("*", function(e) {
1198
- var t = [...arguments].slice(1);
1204
+ }), a.services = { ...this.services }, a.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, r && (a.store = new O(Object.keys(this.store.data).reduce((e, t) => (e[t] = { ...this.store.data[t] }, e[t] = Object.keys(e[t]).reduce((n, r) => (n[r] = { ...e[t][r] }, n), e[t]), e), {}), i), a.services.resourceStore = a.store), t.interpolation) {
1205
+ let e = {
1206
+ ...J().interpolation,
1207
+ ...this.options.interpolation,
1208
+ ...t.interpolation
1209
+ }, n = {
1210
+ ...i,
1211
+ interpolation: e
1212
+ };
1213
+ a.services.interpolator = new V(n);
1214
+ }
1215
+ return a.translator = new P(a.services, i), a.translator.on("*", (e, ...t) => {
1199
1216
  a.emit(e, ...t);
1200
1217
  }), a.init(i, n), a.translator.options = i, a.translator.backendConnector.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, a;
1201
1218
  }
@@ -1208,7 +1225,7 @@ var n = {
1208
1225
  resolvedLanguage: this.resolvedLanguage
1209
1226
  };
1210
1227
  }
1211
- }, X = Y.createInstance();
1212
- X.createInstance = Y.createInstance, X.createInstance, X.dir, X.init, X.loadResources, X.reloadResources, X.use, X.changeLanguage, X.getFixedT, X.t, X.exists, X.setDefaultNamespace, X.hasLoadedNamespace, X.loadNamespaces, X.loadLanguages;
1228
+ }.createInstance();
1229
+ Q.createInstance, Q.dir, Q.init, Q.loadResources, Q.reloadResources, Q.use, Q.changeLanguage, Q.getFixedT, Q.t, Q.exists, Q.setDefaultNamespace, Q.hasLoadedNamespace, Q.loadNamespaces, Q.loadLanguages;
1213
1230
  //#endregion
1214
- export { n, X as t };
1231
+ export { n, Q as t };