UNPKG

svgedit

Version:

Powerful SVG-Editor for your browser

1,193 lines 2.92 MB
const Dt = (o) => typeof o == "string", PA = () => { let o, e; const t = new Promise((r, n) => { o = r, e = n; }); return t.resolve = o, t.reject = e, t; }, s0 = (o) => o == null ? "" : "" + o, mF = (o, e, t) => { o.forEach((r) => { e[r] && (t[r] = e[r]); }); }, yF = /###/g, l0 = (o) => o && o.indexOf("###") > -1 ? o.replace(yF, ".") : o, c0 = (o) => !o || Dt(o), Au = (o, e, t) => { const r = Dt(e) ? e.split(".") : e; let n = 0; for (; n < r.length - 1; ) { if (c0(o)) return {}; const i = l0(r[n]); !o[i] && t && (o[i] = new t()), Object.prototype.hasOwnProperty.call(o, i) ? o = o[i] : o = {}, ++n; } return c0(o) ? {} : { obj: o, k: l0(r[n]) }; }, A0 = (o, e, t) => { const { obj: r, k: n } = Au(o, e, Object); if (r !== void 0 || e.length === 1) { r[n] = t; return; } let i = e[e.length - 1], a = e.slice(0, e.length - 1), s = Au(o, a, Object); for (; s.obj === void 0 && a.length; ) i = `${a[a.length - 1]}.${i}`, a = a.slice(0, a.length - 1), s = Au(o, a, Object), s?.obj && typeof s.obj[`${s.k}.${i}`] < "u" && (s.obj = void 0); s.obj[`${s.k}.${i}`] = t; }, bF = (o, e, t, r) => { const { obj: n, k: i } = Au(o, e, Object); n[i] = n[i] || [], n[i].push(t); }, uh = (o, e) => { const { obj: t, k: r } = Au(o, e); if (t && Object.prototype.hasOwnProperty.call(t, r)) return t[r]; }, vF = (o, e, t) => { const r = uh(o, t); return r !== void 0 ? r : uh(e, t); }, VB = (o, e, t) => { for (const r in e) r !== "__proto__" && r !== "constructor" && (r in o ? Dt(o[r]) || o[r] instanceof String || Dt(e[r]) || e[r] instanceof String ? t && (o[r] = e[r]) : VB(o[r], e[r], t) : o[r] = e[r]); return o; }, sc = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); var wF = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;", "/": "&#x2F;" }; const xF = (o) => Dt(o) ? o.replace(/[&<>"'\/]/g, (e) => wF[e]) : o; class kF { constructor(e) { this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = []; } getRegExp(e) { const t = this.regExpMap.get(e); if (t !== void 0) return t; const r = new RegExp(e); return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, r), this.regExpQueue.push(e), r; } } const CF = [" ", ",", "?", "!", ";"], SF = new kF(20), BF = (o, e, t) => { e = e || "", t = t || ""; const r = CF.filter((a) => e.indexOf(a) < 0 && t.indexOf(a) < 0); if (r.length === 0) return !0; const n = SF.getRegExp(`(${r.map((a) => a === "?" ? "\\?" : a).join("|")})`); let i = !n.test(o); if (!i) { const a = o.indexOf(t); a > 0 && !n.test(o.substring(0, a)) && (i = !0); } return i; }, zy = (o, e, t = ".") => { if (!o) return; if (o[e]) return Object.prototype.hasOwnProperty.call(o, e) ? o[e] : void 0; const r = e.split(t); let n = o; for (let i = 0; i < r.length; ) { if (!n || typeof n != "object") return; let a, s = ""; for (let l = i; l < r.length; ++l) if (l !== i && (s += t), s += r[l], a = n[s], a !== void 0) { if (["string", "number", "boolean"].indexOf(typeof a) > -1 && l < r.length - 1) continue; i += l - i + 1; break; } n = a; } return n; }, Eu = (o) => o?.replace("_", "-"), EF = { type: "logger", log(o) { this.output("log", o); }, warn(o) { this.output("warn", o); }, error(o) { this.output("error", o); }, output(o, e) { console?.[o]?.apply?.(console, e); } }; class dh { constructor(e, t = {}) { this.init(e, t); } init(e, t = {}) { this.prefix = t.prefix || "i18next:", this.logger = e || EF, this.options = t, this.debug = t.debug; } log(...e) { return this.forward(e, "log", "", !0); } warn(...e) { return this.forward(e, "warn", "", !0); } error(...e) { return this.forward(e, "error", ""); } deprecate(...e) { return this.forward(e, "warn", "WARNING DEPRECATED: ", !0); } forward(e, t, r, n) { return n && !this.debug ? null : (Dt(e[0]) && (e[0] = `${r}${this.prefix} ${e[0]}`), this.logger[t](e)); } create(e) { return new dh(this.logger, { prefix: `${this.prefix}:${e}:`, ...this.options }); } clone(e) { return e = e || this.options, e.prefix = e.prefix || this.prefix, new dh(this.logger, e); } } var sa = new dh(); class Mh { constructor() { this.observers = {}; } on(e, t) { return e.split(" ").forEach((r) => { this.observers[r] || (this.observers[r] = /* @__PURE__ */ new Map()); const n = this.observers[r].get(t) || 0; this.observers[r].set(t, n + 1); }), this; } off(e, t) { if (this.observers[e]) { if (!t) { delete this.observers[e]; return; } this.observers[e].delete(t); } } emit(e, ...t) { this.observers[e] && Array.from(this.observers[e].entries()).forEach(([n, i]) => { for (let a = 0; a < i; a++) n(...t); }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([n, i]) => { for (let a = 0; a < i; a++) n.apply(n, [e, ...t]); }); } } class u0 extends Mh { constructor(e, t = { ns: ["translation"], defaultNS: "translation" }) { super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0); } addNamespaces(e) { this.options.ns.indexOf(e) < 0 && this.options.ns.push(e); } removeNamespaces(e) { const t = this.options.ns.indexOf(e); t > -1 && this.options.ns.splice(t, 1); } getResource(e, t, r, n = {}) { const i = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator, a = n.ignoreJSONStructure !== void 0 ? n.ignoreJSONStructure : this.options.ignoreJSONStructure; let s; e.indexOf(".") > -1 ? s = e.split(".") : (s = [e, t], r && (Array.isArray(r) ? s.push(...r) : Dt(r) && i ? s.push(...r.split(i)) : s.push(r))); const l = uh(this.data, s); return !l && !t && !r && e.indexOf(".") > -1 && (e = s[0], t = s[1], r = s.slice(2).join(".")), l || !a || !Dt(r) ? l : zy(this.data?.[e]?.[t], r, i); } addResource(e, t, r, n, i = { silent: !1 }) { const a = i.keySeparator !== void 0 ? i.keySeparator : this.options.keySeparator; let s = [e, t]; r && (s = s.concat(a ? r.split(a) : r)), e.indexOf(".") > -1 && (s = e.split("."), n = t, t = s[1]), this.addNamespaces(t), A0(this.data, s, n), i.silent || this.emit("added", e, t, r, n); } addResources(e, t, r, n = { silent: !1 }) { for (const i in r) (Dt(r[i]) || Array.isArray(r[i])) && this.addResource(e, t, i, r[i], { silent: !0 }); n.silent || this.emit("added", e, t, r); } addResourceBundle(e, t, r, n, i, a = { silent: !1, skipCopy: !1 }) { let s = [e, t]; e.indexOf(".") > -1 && (s = e.split("."), n = r, r = t, t = s[1]), this.addNamespaces(t); let l = uh(this.data, s) || {}; a.skipCopy || (r = JSON.parse(JSON.stringify(r))), n ? VB(l, r, i) : l = { ...l, ...r }, A0(this.data, s, l), a.silent || this.emit("added", e, t, r); } removeResourceBundle(e, t) { this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t); } hasResourceBundle(e, t) { return this.getResource(e, t) !== void 0; } getResourceBundle(e, t) { return t || (t = this.options.defaultNS), this.getResource(e, t); } getDataByLanguage(e) { return this.data[e]; } hasLanguageSomeTranslations(e) { const t = this.getDataByLanguage(e); return !!(t && Object.keys(t) || []).find((n) => t[n] && Object.keys(t[n]).length > 0); } toJSON() { return this.data; } } var DB = { processors: {}, addPostProcessor(o) { this.processors[o.name] = o; }, handle(o, e, t, r, n) { return o.forEach((i) => { e = this.processors[i]?.process(e, t, r, n) ?? e; }), e; } }; const HB = /* @__PURE__ */ Symbol("i18next/PATH_KEY"); function jF() { const o = [], e = /* @__PURE__ */ Object.create(null); let t; return e.get = (r, n) => (t?.revoke?.(), n === HB ? o : (o.push(n), t = Proxy.revocable(r, e), t.proxy)), Proxy.revocable(/* @__PURE__ */ Object.create(null), e).proxy; } function Ky(o, e) { const { [HB]: t } = o(jF()); return t.join(e?.keySeparator ?? "."); } const d0 = {}, e_ = (o) => !Dt(o) && typeof o != "boolean" && typeof o != "number"; class ph extends Mh { constructor(e, t = {}) { super(), mF(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = sa.create("translator"); } changeLanguage(e) { e && (this.language = e); } exists(e, t = { interpolation: {} }) { const r = { ...t }; if (e == null) return !1; const n = this.resolve(e, r); if (n?.res === void 0) return !1; const i = e_(n.res); return !(r.returnObjects === !1 && i); } extractFromKey(e, t) { let r = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator; r === void 0 && (r = ":"); const n = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator; let i = t.ns || this.options.defaultNS || []; const a = r && e.indexOf(r) > -1, s = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !BF(e, r, n); if (a && !s) { const l = e.match(this.interpolator.nestingRegexp); if (l && l.length > 0) return { key: e, namespaces: Dt(i) ? [i] : i }; const c = e.split(r); (r !== n || r === n && this.options.ns.indexOf(c[0]) > -1) && (i = c.shift()), e = c.join(n); } return { key: e, namespaces: Dt(i) ? [i] : i }; } translate(e, t, r) { let n = typeof t == "object" ? { ...t } : t; if (typeof n != "object" && this.options.overloadTranslationOptionHandler && (n = this.options.overloadTranslationOptionHandler(arguments)), typeof n == "object" && (n = { ...n }), n || (n = {}), e == null) return ""; typeof e == "function" && (e = Ky(e, { ...this.options, ...n })), Array.isArray(e) || (e = [String(e)]); const i = n.returnDetails !== void 0 ? n.returnDetails : this.options.returnDetails, a = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator, { key: s, namespaces: l } = this.extractFromKey(e[e.length - 1], n), c = l[l.length - 1]; let A = n.nsSeparator !== void 0 ? n.nsSeparator : this.options.nsSeparator; A === void 0 && (A = ":"); const u = n.lng || this.language, p = n.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode; if (u?.toLowerCase() === "cimode") return p ? i ? { res: `${c}${A}${s}`, usedKey: s, exactUsedKey: s, usedLng: u, usedNS: c, usedParams: this.getUsedParamsDetails(n) } : `${c}${A}${s}` : i ? { res: s, usedKey: s, exactUsedKey: s, usedLng: u, usedNS: c, usedParams: this.getUsedParamsDetails(n) } : s; const d = this.resolve(e, n); let g = d?.res; const _ = d?.usedKey || s, f = d?.exactUsedKey || s, m = ["[object Number]", "[object Function]", "[object RegExp]"], b = n.joinArrays !== void 0 ? n.joinArrays : this.options.joinArrays, v = !this.i18nFormat || this.i18nFormat.handleAsObject, w = n.count !== void 0 && !Dt(n.count), C = ph.hasDefaultValue(n), E = w ? this.pluralResolver.getSuffix(u, n.count, n) : "", T = n.ordinal && w ? this.pluralResolver.getSuffix(u, n.count, { ordinal: !1 }) : "", F = w && !n.ordinal && n.count === 0, B = F && n[`defaultValue${this.options.pluralSeparator}zero`] || n[`defaultValue${E}`] || n[`defaultValue${T}`] || n.defaultValue; let P = g; v && !g && C && (P = B); const S = e_(P), L = Object.prototype.toString.apply(P); if (v && P && S && m.indexOf(L) < 0 && !(Dt(b) && Array.isArray(P))) { if (!n.returnObjects && !this.options.returnObjects) { this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!"); const U = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(_, P, { ...n, ns: l }) : `key '${s} (${this.language})' returned an object instead of string.`; return i ? (d.res = U, d.usedParams = this.getUsedParamsDetails(n), d) : U; } if (a) { const U = Array.isArray(P), O = U ? [] : {}, K = U ? f : _; for (const te in P) if (Object.prototype.hasOwnProperty.call(P, te)) { const Y = `${K}${a}${te}`; C && !g ? O[te] = this.translate(Y, { ...n, defaultValue: e_(B) ? B[te] : void 0, joinArrays: !1, ns: l }) : O[te] = this.translate(Y, { ...n, joinArrays: !1, ns: l }), O[te] === Y && (O[te] = P[te]); } g = O; } } else if (v && Dt(b) && Array.isArray(g)) g = g.join(b), g && (g = this.extendTranslation(g, e, n, r)); else { let U = !1, O = !1; !this.isValidLookup(g) && C && (U = !0, g = B), this.isValidLookup(g) || (O = !0, g = s); const te = (n.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && O ? void 0 : g, Y = C && B !== g && this.options.updateMissing; if (O || U || Y) { if (this.logger.log(Y ? "updateKey" : "missingKey", u, c, s, Y ? B : g), a) { const ae = this.resolve(s, { ...n, keySeparator: !1 }); ae && ae.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."); } let ee = []; const oe = this.languageUtils.getFallbackCodes(this.options.fallbackLng, n.lng || this.language); if (this.options.saveMissingTo === "fallback" && oe && oe[0]) for (let ae = 0; ae < oe.length; ae++) ee.push(oe[ae]); else this.options.saveMissingTo === "all" ? ee = this.languageUtils.toResolveHierarchy(n.lng || this.language) : ee.push(n.lng || this.language); const de = (ae, I, G) => { const H = C && G !== g ? G : te; this.options.missingKeyHandler ? this.options.missingKeyHandler(ae, c, I, H, Y, n) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(ae, c, I, H, Y, n), this.emit("missingKey", ae, c, I, g); }; this.options.saveMissing && (this.options.saveMissingPlurals && w ? ee.forEach((ae) => { const I = this.pluralResolver.getSuffixes(ae, n); F && n[`defaultValue${this.options.pluralSeparator}zero`] && I.indexOf(`${this.options.pluralSeparator}zero`) < 0 && I.push(`${this.options.pluralSeparator}zero`), I.forEach((G) => { de([ae], s + G, n[`defaultValue${G}`] || B); }); }) : de(ee, s, B)); } g = this.extendTranslation(g, e, n, d, r), O && g === s && this.options.appendNamespaceToMissingKey && (g = `${c}${A}${s}`), (O || U) && this.options.parseMissingKeyHandler && (g = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${c}${A}${s}` : s, U ? g : void 0, n)); } return i ? (d.res = g, d.usedParams = this.getUsedParamsDetails(n), d) : g; } extendTranslation(e, t, r, n, i) { if (this.i18nFormat?.parse) e = this.i18nFormat.parse(e, { ...this.options.interpolation.defaultVariables, ...r }, r.lng || this.language || n.usedLng, n.usedNS, n.usedKey, { resolved: n }); else if (!r.skipInterpolation) { r.interpolation && this.interpolator.init({ ...r, interpolation: { ...this.options.interpolation, ...r.interpolation } }); const l = Dt(e) && (r?.interpolation?.skipOnVariables !== void 0 ? r.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables); let c; if (l) { const u = e.match(this.interpolator.nestingRegexp); c = u && u.length; } let A = r.replace && !Dt(r.replace) ? r.replace : r; if (this.options.interpolation.defaultVariables && (A = { ...this.options.interpolation.defaultVariables, ...A }), e = this.interpolator.interpolate(e, A, r.lng || this.language || n.usedLng, r), l) { const u = e.match(this.interpolator.nestingRegexp), p = u && u.length; c < p && (r.nest = !1); } !r.lng && n && n.res && (r.lng = this.language || n.usedLng), r.nest !== !1 && (e = this.interpolator.nest(e, (...u) => i?.[0] === u[0] && !r.context ? (this.logger.warn(`It seems you are nesting recursively key: ${u[0]} in key: ${t[0]}`), null) : this.translate(...u, t), r)), r.interpolation && this.interpolator.reset(); } const a = r.postProcess || this.options.postProcess, s = Dt(a) ? [a] : a; return e != null && s?.length && r.applyPostProcessor !== !1 && (e = DB.handle(s, e, t, this.options && this.options.postProcessPassResolved ? { i18nResolved: { ...n, usedParams: this.getUsedParamsDetails(r) }, ...r } : r, this)), e; } resolve(e, t = {}) { let r, n, i, a, s; return Dt(e) && (e = [e]), e.forEach((l) => { if (this.isValidLookup(r)) return; const c = this.extractFromKey(l, t), A = c.key; n = A; let u = c.namespaces; this.options.fallbackNS && (u = u.concat(this.options.fallbackNS)); const p = t.count !== void 0 && !Dt(t.count), d = p && !t.ordinal && t.count === 0, g = t.context !== void 0 && (Dt(t.context) || typeof t.context == "number") && t.context !== "", _ = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng); u.forEach((f) => { this.isValidLookup(r) || (s = f, !d0[`${_[0]}-${f}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(s) && (d0[`${_[0]}-${f}`] = !0, this.logger.warn(`key "${n}" for languages "${_.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!!!")), _.forEach((m) => { if (this.isValidLookup(r)) return; a = m; const b = [A]; if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(b, A, m, f, t); else { let w; p && (w = this.pluralResolver.getSuffix(m, t.count, t)); const C = `${this.options.pluralSeparator}zero`, E = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`; if (p && (t.ordinal && w.indexOf(E) === 0 && b.push(A + w.replace(E, this.options.pluralSeparator)), b.push(A + w), d && b.push(A + C)), g) { const T = `${A}${this.options.contextSeparator || "_"}${t.context}`; b.push(T), p && (t.ordinal && w.indexOf(E) === 0 && b.push(T + w.replace(E, this.options.pluralSeparator)), b.push(T + w), d && b.push(T + C)); } } let v; for (; v = b.pop(); ) this.isValidLookup(r) || (i = v, r = this.getResource(m, f, v, t)); })); }); }), { res: r, usedKey: n, exactUsedKey: i, usedLng: a, usedNS: s }; } isValidLookup(e) { return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === ""); } getResource(e, t, r, n = {}) { return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, r, n) : this.resourceStore.getResource(e, t, r, n); } getUsedParamsDetails(e = {}) { const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], r = e.replace && !Dt(e.replace); let n = r ? e.replace : e; if (r && typeof e.count < "u" && (n.count = e.count), this.options.interpolation.defaultVariables && (n = { ...this.options.interpolation.defaultVariables, ...n }), !r) { n = { ...n }; for (const i of t) delete n[i]; } return n; } static hasDefaultValue(e) { const t = "defaultValue"; for (const r in e) if (Object.prototype.hasOwnProperty.call(e, r) && t === r.substring(0, t.length) && e[r] !== void 0) return !0; return !1; } } class p0 { constructor(e) { this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = sa.create("languageUtils"); } getScriptPartFromCode(e) { if (e = Eu(e), !e || e.indexOf("-") < 0) return null; const t = e.split("-"); return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-")); } getLanguagePartFromCode(e) { if (e = Eu(e), !e || e.indexOf("-") < 0) return e; const t = e.split("-"); return this.formatLanguageCode(t[0]); } formatLanguageCode(e) { if (Dt(e) && e.indexOf("-") > -1) { let t; try { t = Intl.getCanonicalLocales(e)[0]; } catch { } return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e); } return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e; } isSupportedCode(e) { return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1; } getBestMatchFromCodes(e) { if (!e) return null; let t; return e.forEach((r) => { if (t) return; const n = this.formatLanguageCode(r); (!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n); }), !t && this.options.supportedLngs && e.forEach((r) => { if (t) return; const n = this.getScriptPartFromCode(r); if (this.isSupportedCode(n)) return t = n; const i = this.getLanguagePartFromCode(r); if (this.isSupportedCode(i)) return t = i; t = this.options.supportedLngs.find((a) => { if (a === i) return a; if (!(a.indexOf("-") < 0 && i.indexOf("-") < 0) && (a.indexOf("-") > 0 && i.indexOf("-") < 0 && a.substring(0, a.indexOf("-")) === i || a.indexOf(i) === 0 && i.length > 1)) return a; }); }), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t; } getFallbackCodes(e, t) { if (!e) return []; if (typeof e == "function" && (e = e(t)), Dt(e) && (e = [e]), Array.isArray(e)) return e; if (!t) return e.default || []; let r = e[t]; return r || (r = e[this.getScriptPartFromCode(t)]), r || (r = e[this.formatLanguageCode(t)]), r || (r = e[this.getLanguagePartFromCode(t)]), r || (r = e.default), r || []; } toResolveHierarchy(e, t) { const r = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), n = [], i = (a) => { a && (this.isSupportedCode(a) ? n.push(a) : this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`)); }; return Dt(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && i(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && i(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && i(this.getLanguagePartFromCode(e))) : Dt(e) && i(this.formatLanguageCode(e)), r.forEach((a) => { n.indexOf(a) < 0 && i(this.formatLanguageCode(a)); }), n; } } const h0 = { zero: 0, one: 1, two: 2, few: 3, many: 4, other: 5 }, g0 = { select: (o) => o === 1 ? "one" : "other", resolvedOptions: () => ({ pluralCategories: ["one", "other"] }) }; class LF { constructor(e, t = {}) { this.languageUtils = e, this.options = t, this.logger = sa.create("pluralResolver"), this.pluralRulesCache = {}; } clearCache() { this.pluralRulesCache = {}; } getRule(e, t = {}) { const r = Eu(e === "dev" ? "en" : e), n = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({ cleanedCode: r, type: n }); if (i in this.pluralRulesCache) return this.pluralRulesCache[i]; let a; try { a = new Intl.PluralRules(r, { type: n }); } catch { if (!Intl) return this.logger.error("No Intl support, please use an Intl polyfill!"), g0; if (!e.match(/-|_/)) return g0; const l = this.languageUtils.getLanguagePartFromCode(e); a = this.getRule(l, t); } return this.pluralRulesCache[i] = a, a; } needsPlural(e, t = {}) { let r = this.getRule(e, t); return r || (r = this.getRule("dev", t)), r?.resolvedOptions().pluralCategories.length > 1; } getPluralFormsOfKey(e, t, r = {}) { return this.getSuffixes(e, r).map((n) => `${t}${n}`); } getSuffixes(e, t = {}) { let r = this.getRule(e, t); return r || (r = this.getRule("dev", t)), r ? r.resolvedOptions().pluralCategories.sort((n, i) => h0[n] - h0[i]).map((n) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${n}`) : []; } getSuffix(e, t, r = {}) { const n = this.getRule(e, r); return n ? `${this.options.prepend}${r.ordinal ? `ordinal${this.options.prepend}` : ""}${n.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, r)); } } const _0 = (o, e, t, r = ".", n = !0) => { let i = vF(o, e, t); return !i && n && Dt(t) && (i = zy(o, t, r), i === void 0 && (i = zy(e, t, r))), i; }, t_ = (o) => o.replace(/\$/g, "$$$$"); class f0 { constructor(e = {}) { this.logger = sa.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((t) => t), this.init(e); } init(e = {}) { e.interpolation || (e.interpolation = { escapeValue: !0 }); const { escape: t, escapeValue: r, useRawValueToEscape: n, prefix: i, prefixEscaped: a, suffix: s, suffixEscaped: l, formatSeparator: c, unescapeSuffix: A, unescapePrefix: u, nestingPrefix: p, nestingPrefixEscaped: d, nestingSuffix: g, nestingSuffixEscaped: _, nestingOptionsSeparator: f, maxReplaces: m, alwaysFormat: b } = e.interpolation; this.escape = t !== void 0 ? t : xF, this.escapeValue = r !== void 0 ? r : !0, this.useRawValueToEscape = n !== void 0 ? n : !1, this.prefix = i ? sc(i) : a || "{{", this.suffix = s ? sc(s) : l || "}}", this.formatSeparator = c || ",", this.unescapePrefix = A ? "" : u || "-", this.unescapeSuffix = this.unescapePrefix ? "" : A || "", this.nestingPrefix = p ? sc(p) : d || sc("$t("), this.nestingSuffix = g ? sc(g) : _ || sc(")"), this.nestingOptionsSeparator = f || ",", this.maxReplaces = m || 1e3, this.alwaysFormat = b !== void 0 ? b : !1, this.resetRegExp(); } reset() { this.options && this.init(this.options); } resetRegExp() { const e = (t, r) => t?.source === r ? (t.lastIndex = 0, t) : new RegExp(r, "g"); 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}`); } interpolate(e, t, r, n) { let i, a, s; const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, c = (d) => { if (d.indexOf(this.formatSeparator) < 0) { const m = _0(t, l, d, this.options.keySeparator, this.options.ignoreJSONStructure); return this.alwaysFormat ? this.format(m, void 0, r, { ...n, ...t, interpolationkey: d }) : m; } const g = d.split(this.formatSeparator), _ = g.shift().trim(), f = g.join(this.formatSeparator).trim(); return this.format(_0(t, l, _, this.options.keySeparator, this.options.ignoreJSONStructure), f, r, { ...n, ...t, interpolationkey: _ }); }; this.resetRegExp(); const A = n?.missingInterpolationHandler || this.options.missingInterpolationHandler, u = n?.interpolation?.skipOnVariables !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables; return [{ regex: this.regexpUnescape, safeValue: (d) => t_(d) }, { regex: this.regexp, safeValue: (d) => this.escapeValue ? t_(this.escape(d)) : t_(d) }].forEach((d) => { for (s = 0; i = d.regex.exec(e); ) { const g = i[1].trim(); if (a = c(g), a === void 0) if (typeof A == "function") { const f = A(e, i, n); a = Dt(f) ? f : ""; } else if (n && Object.prototype.hasOwnProperty.call(n, g)) a = ""; else if (u) { a = i[0]; continue; } else this.logger.warn(`missed to pass in variable ${g} for interpolating ${e}`), a = ""; else !Dt(a) && !this.useRawValueToEscape && (a = s0(a)); const _ = d.safeValue(a); if (e = e.replace(i[0], _), u ? (d.regex.lastIndex += a.length, d.regex.lastIndex -= i[0].length) : d.regex.lastIndex = 0, s++, s >= this.maxReplaces) break; } }), e; } nest(e, t, r = {}) { let n, i, a; const s = (l, c) => { const A = this.nestingOptionsSeparator; if (l.indexOf(A) < 0) return l; const u = l.split(new RegExp(`${A}[ ]*{`)); let p = `{${u[1]}`; l = u[0], p = this.interpolate(p, a); const d = p.match(/'/g), g = p.match(/"/g); ((d?.length ?? 0) % 2 === 0 && !g || g.length % 2 !== 0) && (p = p.replace(/'/g, '"')); try { a = JSON.parse(p), c && (a = { ...c, ...a }); } catch (_) { return this.logger.warn(`failed parsing options string in nesting for key ${l}`, _), `${l}${A}${p}`; } return a.defaultValue && a.defaultValue.indexOf(this.prefix) > -1 && delete a.defaultValue, l; }; for (; n = this.nestingRegexp.exec(e); ) { let l = []; a = { ...r }, a = a.replace && !Dt(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue; const c = /{.*}/.test(n[1]) ? n[1].lastIndexOf("}") + 1 : n[1].indexOf(this.formatSeparator); if (c !== -1 && (l = n[1].slice(c).split(this.formatSeparator).map((A) => A.trim()).filter(Boolean), n[1] = n[1].slice(0, c)), i = t(s.call(this, n[1].trim(), a), a), i && n[0] === e && !Dt(i)) return i; Dt(i) || (i = s0(i)), i || (this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`), i = ""), l.length && (i = l.reduce((A, u) => this.format(A, u, r.lng, { ...r, interpolationkey: n[1].trim() }), i.trim())), e = e.replace(n[0], i), this.regexp.lastIndex = 0; } return e; } } const TF = (o) => { let e = o.toLowerCase().trim(); const t = {}; if (o.indexOf("(") > -1) { const r = o.split("("); e = r[0].toLowerCase().trim(); const n = r[1].substring(0, r[1].length - 1); e === "currency" && n.indexOf(":") < 0 ? t.currency || (t.currency = n.trim()) : e === "relativetime" && n.indexOf(":") < 0 ? t.range || (t.range = n.trim()) : n.split(";").forEach((a) => { if (a) { const [s, ...l] = a.split(":"), c = l.join(":").trim().replace(/^'+|'+$/g, ""), A = s.trim(); t[A] || (t[A] = c), c === "false" && (t[A] = !1), c === "true" && (t[A] = !0), isNaN(c) || (t[A] = parseInt(c, 10)); } }); } return { formatName: e, formatOptions: t }; }, m0 = (o) => { const e = {}; return (t, r, n) => { let i = n; n && n.interpolationkey && n.formatParams && n.formatParams[n.interpolationkey] && n[n.interpolationkey] && (i = { ...i, [n.interpolationkey]: void 0 }); const a = r + JSON.stringify(i); let s = e[a]; return s || (s = o(Eu(r), n), e[a] = s), s(t); }; }, PF = (o) => (e, t, r) => o(Eu(t), r)(e); class FF { constructor(e = {}) { this.logger = sa.create("formatter"), this.options = e, this.init(e); } init(e, t = { interpolation: {} }) { this.formatSeparator = t.interpolation.formatSeparator || ","; const r = t.cacheInBuiltFormats ? m0 : PF; this.formats = { number: r((n, i) => { const a = new Intl.NumberFormat(n, { ...i }); return (s) => a.format(s); }), currency: r((n, i) => { const a = new Intl.NumberFormat(n, { ...i, style: "currency" }); return (s) => a.format(s); }), datetime: r((n, i) => { const a = new Intl.DateTimeFormat(n, { ...i }); return (s) => a.format(s); }), relativetime: r((n, i) => { const a = new Intl.RelativeTimeFormat(n, { ...i }); return (s) => a.format(s, i.range || "day"); }), list: r((n, i) => { const a = new Intl.ListFormat(n, { ...i }); return (s) => a.format(s); }) }; } add(e, t) { this.formats[e.toLowerCase().trim()] = t; } addCached(e, t) { this.formats[e.toLowerCase().trim()] = m0(t); } format(e, t, r, n = {}) { const i = t.split(this.formatSeparator); if (i.length > 1 && i[0].indexOf("(") > 1 && i[0].indexOf(")") < 0 && i.find((s) => s.indexOf(")") > -1)) { const s = i.findIndex((l) => l.indexOf(")") > -1); i[0] = [i[0], ...i.splice(1, s)].join(this.formatSeparator); } return i.reduce((s, l) => { const { formatName: c, formatOptions: A } = TF(l); if (this.formats[c]) { let u = s; try { const p = n?.formatParams?.[n.interpolationkey] || {}, d = p.locale || p.lng || n.locale || n.lng || r; u = this.formats[c](s, d, { ...A, ...n, ...p }); } catch (p) { this.logger.warn(p); } return u; } else this.logger.warn(`there was no format function for ${c}`); return s; }, e); } } const UF = (o, e) => { o.pending[e] !== void 0 && (delete o.pending[e], o.pendingCount--); }; class NF extends Mh { constructor(e, t, r, n = {}) { super(), this.backend = e, this.store = t, this.services = r, this.languageUtils = r.languageUtils, this.options = n, this.logger = sa.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = n.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = n.maxRetries >= 0 ? n.maxRetries : 5, this.retryTimeout = n.retryTimeout >= 1 ? n.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(r, n.backend, n); } queueLoad(e, t, r, n) { const i = {}, a = {}, s = {}, l = {}; return e.forEach((c) => { let A = !0; t.forEach((u) => { const p = `${c}|${u}`; !r.reload && this.store.hasResourceBundle(c, u) ? this.state[p] = 2 : this.state[p] < 0 || (this.state[p] === 1 ? a[p] === void 0 && (a[p] = !0) : (this.state[p] = 1, A = !1, a[p] === void 0 && (a[p] = !0), i[p] === void 0 && (i[p] = !0), l[u] === void 0 && (l[u] = !0))); }), A || (s[c] = !0); }), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({ pending: a, pendingCount: Object.keys(a).length, loaded: {}, errors: [], callback: n }), { toLoad: Object.keys(i), pending: Object.keys(a), toLoadLanguages: Object.keys(s), toLoadNamespaces: Object.keys(l) }; } loaded(e, t, r) { const n = e.split("|"), i = n[0], a = n[1]; t && this.emit("failedLoading", i, a, t), !t && r && this.store.addResourceBundle(i, a, r, void 0, void 0, { skipCopy: !0 }), this.state[e] = t ? -1 : 2, t && r && (this.state[e] = 0); const s = {}; this.queue.forEach((l) => { bF(l.loaded, [i], a), UF(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((c) => { s[c] || (s[c] = {}); const A = l.loaded[c]; A.length && A.forEach((u) => { s[c][u] === void 0 && (s[c][u] = !0); }); }), l.done = !0, l.errors.length ? l.callback(l.errors) : l.callback()); }), this.emit("loaded", s), this.queue = this.queue.filter((l) => !l.done); } read(e, t, r, n = 0, i = this.retryTimeout, a) { if (!e.length) return a(null, {}); if (this.readingCalls >= this.maxParallelReads) { this.waitingReads.push({ lng: e, ns: t, fcName: r, tried: n, wait: i, callback: a }); return; } this.readingCalls++; const s = (c, A) => { if (this.readingCalls--, this.waitingReads.length > 0) { const u = this.waitingReads.shift(); this.read(u.lng, u.ns, u.fcName, u.tried, u.wait, u.callback); } if (c && A && n < this.maxRetries) { setTimeout(() => { this.read.call(this, e, t, r, n + 1, i * 2, a); }, i); return; } a(c, A); }, l = this.backend[r].bind(this.backend); if (l.length === 2) { try { const c = l(e, t); c && typeof c.then == "function" ? c.then((A) => s(null, A)).catch(s) : s(null, c); } catch (c) { s(c); } return; } return l(e, t, s); } prepareLoading(e, t, r = {}, n) { if (!this.backend) return this.logger.warn("No backend was added via i18next.use. Will not load resources."), n && n(); Dt(e) && (e = this.languageUtils.toResolveHierarchy(e)), Dt(t) && (t = [t]); const i = this.queueLoad(e, t, r, n); if (!i.toLoad.length) return i.pending.length || n(), null; i.toLoad.forEach((a) => { this.loadOne(a); }); } load(e, t, r) { this.prepareLoading(e, t, {}, r); } reload(e, t, r) { this.prepareLoading(e, t, { reload: !0 }, r); } loadOne(e, t = "") { const r = e.split("|"), n = r[0], i = r[1]; this.read(n, i, "read", void 0, void 0, (a, s) => { a && this.logger.warn(`${t}loading namespace ${i} for language ${n} failed`, a), !a && s && this.logger.log(`${t}loaded namespace ${i} for language ${n}`, s), this.loaded(e, a, s); }); } saveMissing(e, t, r, n, i, a = {}, s = () => { }) { if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) { this.logger.warn(`did not save key "${r}" 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!!!"); return; } if (!(r == null || r === "")) { if (this.backend?.create) { const l = { ...a, isUpdate: i }, c = this.backend.create.bind(this.backend); if (c.length < 6) try { let A; c.length === 5 ? A = c(e, t, r, n, l) : A = c(e, t, r, n), A && typeof A.then == "function" ? A.then((u) => s(null, u)).catch(s) : s(null, A); } catch (A) { s(A); } else c(e, t, r, n, s, l); } !e || !e[0] || this.store.addResource(e[0], t, r, n); } } } const r_ = () => ({ debug: !1, initAsync: !0, ns: ["translation"], defaultNS: ["translation"], fallbackLng: ["dev"], fallbackNS: !1, supportedLngs: !1, nonExplicitSupportedLngs: !1, load: "all", preload: !1, simplifyPluralSuffix: !0, keySeparator: ".", nsSeparator: ":", pluralSeparator: "_", contextSeparator: "_", partialBundledLanguages: !1, saveMissing: !1, updateMissing: !1, saveMissingTo: "fallback", saveMissingPlurals: !0, missingKeyHandler: !1, missingInterpolationHandler: !1, postProcess: !1, postProcessPassResolved: !1, returnNull: !1, returnEmptyString: !0, returnObjects: !1, joinArrays: !1, returnedObjectHandler: !1, parseMissingKeyHandler: !1, appendNamespaceToMissingKey: !1, appendNamespaceToCIMode: !1, overloadTranslationOptionHandler: (o) => { let e = {}; if (typeof o[1] == "object" && (e = o[1]), Dt(o[1]) && (e.defaultValue = o[1]), Dt(o[2]) && (e.tDescription = o[2]), typeof o[2] == "object" || typeof o[3] == "object") { const t = o[3] || o[2]; Object.keys(t).forEach((r) => { e[r] = t[r]; }); } return e; }, interpolation: { escapeValue: !0, format: (o) => o, prefix: "{{", suffix: "}}", formatSeparator: ",", unescapePrefix: "-", nestingPrefix: "$t(", nestingSuffix: ")", nestingOptionsSeparator: ",", maxReplaces: 1e3, skipOnVariables: !0 }, cacheInBuiltFormats: !0 }), y0 = (o) => (Dt(o.ns) && (o.ns = [o.ns]), Dt(o.fallbackLng) && (o.fallbackLng = [o.fallbackLng]), Dt(o.fallbackNS) && (o.fallbackNS = [o.fallbackNS]), o.supportedLngs?.indexOf?.("cimode") < 0 && (o.supportedLngs = o.supportedLngs.concat(["cimode"])), typeof o.initImmediate == "boolean" && (o.initAsync = o.initImmediate), o), Xd = () => { }, IF = (o) => { Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach((t) => { typeof o[t] == "function" && (o[t] = o[t].bind(o)); }); }; class uu extends Mh { constructor(e = {}, t) { if (super(), this.options = y0(e), this.services = {}, this.logger = sa, this.modules = { external: [] }, IF(this), t && !this.isInitialized && !e.isClone) { if (!this.options.initAsync) return this.init(e, t), this; setTimeout(() => { this.init(e, t); }, 0); } } init(e = {}, t) { this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (Dt(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0])); const r = r_(); this.options = { ...r, ...this.options, ...y0(e) }, this.options.interpolation = { ...r.interpolation, ...this.options.interpolation }, 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 = r.overloadTranslationOptionHandler); const n = (c) => c ? typeof c == "function" ? new c() : c : null; if (!this.options.isClone) { this.modules.logger ? sa.init(n(this.modules.logger), this.options) : sa.init(null, this.options); let c; this.modules.formatter ? c = this.modules.formatter : c = FF; const A = new p0(this.options); this.store = new u0(this.options.resources, this.options); const u = this.services; u.logger = sa, u.resourceStore = this.store, u.languageUtils = A, u.pluralResolver = new LF(A, { prepend: this.options.pluralSeparator, simplifyPluralSuffix: this.options.simplifyPluralSuffix }), this.options.interpolation.format && this.options.interpolation.format !== r.interpolation.format && this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), c && (!this.options.interpolation.format || this.options.interpolation.format === r.interpolation.format) && (u.formatter = n(c), u.formatter.init && u.formatter.init(u, this.options), this.options.interpolation.format = u.formatter.format.bind(u.formatter)), u.interpolator = new f0(this.options), u.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) }, u.backendConnector = new NF(n(this.modules.backend), u.resourceStore, u, this.options), u.backendConnector.on("*", (d, ...g) => { this.emit(d, ...g); }), this.modules.languageDetector && (u.languageDetector = n(this.modules.languageDetector), u.languageDetector.init && u.languageDetector.init(u, this.options.detection, this.options)), this.modules.i18nFormat && (u.i18nFormat = n(this.modules.i18nFormat), u.i18nFormat.init && u.i18nFormat.init(this)), this.translator = new ph(this.services, this.options), this.translator.on("*", (d, ...g) => { this.emit(d, ...g); }), this.modules.external.forEach((d) => { d.init && d.init(this); }); } if (this.format = this.options.interpolation.format, t || (t = Xd), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) { const c = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng); c.length > 0 && c[0] !== "dev" && (this.options.lng = c[0]); } !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((c) => { this[c] = (...A) => this.store[c](...A); }), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((c) => { this[c] = (...A) => (this.store[c](...A), this); }); const s = PA(), l = () => { const c = (A, u) => { 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(u), t(A, u); }; if (this.languages && !this.isInitialized) return c(null, this.t.bind(this)); this.changeLanguage(this.options.lng, c); }; return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), s; } loadResources(e, t = Xd) { let r = t; const n = Dt(e) ? e : this.language; if (typeof e == "function" && (r = e), !this.options.resources || this.options.partialBundledLanguages) { if (n?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return r(); const i = [], a = (s) => { if (!s || s === "cimode") return; this.services.languageUtils.toResolveHierarchy(s).forEach((c) => { c !== "cimode" && i.indexOf(c) < 0 && i.push(c); }); }; n ? a(n) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((l) => a(l)), this.options.preload?.forEach?.((s) => a(s)), this.services.backendConnector.load(i, this.options.ns, (s) => { !s && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), r(s); }); } else r(null); } reloadResources(e, t, r) { const n = PA(); return typeof e == "function" && (r = e, e = void 0), typeof t == "function" && (r = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), r || (r = Xd), this.services.backendConnector.reload(e, t, (i) => { n.resolve(), r(i); }), n; } use(e) { if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()"); if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()"); 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" && DB.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this; } setResolvedLanguage(e) { if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) { for (let t = 0; t < this.languages.length; t++) { const r = this.languages[t]; if (!(["cimode", "dev"].indexOf(r) > -1) && this.store.hasLanguageSomeTranslations(r)) { this.resolvedLanguage = r; break; } } !this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e)); } } changeLanguage(e, t) { this.isLanguageChangingTo = e; const r = PA(); this.emit("languageChanging", e); const n = (s) => { this.language = s, this.languages = this.services.languageUtils.toResolveHierarchy(s), this.resolvedLanguage = void 0, this.setResolvedLanguage(s); }, i = (s, l) => { l ? this.isLanguageChangingTo === e && (n(l), this.translator.changeLanguage(l), this.isLanguageChangingTo = void 0, this.emit("languageChanged", l), this.logger.log("languageChanged", l)) : this.isLanguageChangingTo = void 0, r.resolve((...c) => this.t(...c)), t && t(s, (...c) => this.t(...c)); }, a = (s) => { !e && !s && this.services.languageDetector && (s = []); const l = Dt(s) ? s : s && s[0], c = this.store.hasLanguageSomeTranslations(l) ? l : this.services.languageUtils.getBestMatchFromCodes