PageSourceSearch

https://www.hamienet.com/assets/vendor-i18n-R-bMoYp_.js

js hamienet.com collected 2026-09-24 18:58:54 UTC 126,214 bytes, 3,467 lines download raw bytes

1import { r as reactExports, c as commonjsGlobal, g as getDefaultExportFromCjs } from "./vendor-react-Bay9Y7Lb.js";
2import { s as shimExports, r as requireBrowserPonyfill } from "./vendor-dVNaLJx_.js";
3function _mergeNamespaces(n, m) {
4  for (var i = 0; i < m.length; i++) {
5    const e = m[i];
6    if (typeof e !== "string" && !Array.isArray(e)) {
7      for (const k in e) {
8        if (k !== "default" && !(k in n)) {
9          const d = Object.getOwnPropertyDescriptor(e, k);
10          if (d) {
11            Object.defineProperty(n, k, d.get ? d : {
12              enumerable: true,
13              get: () => e[k]
14            });
15          }
16        }
17      }
18    }
19  }
20  return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
21}
22const isString$1 = (obj) => typeof obj === "string";
23const defer = () => {
24  let res;
25  let rej;
26  const promise = new Promise((resolve, reject) => {
27    res = resolve;
28    rej = reject;
29  });
30  promise.resolve = res;
31  promise.reject = rej;
32  return promise;
33};
34const makeString = (object) => {
35  if (object == null) return "";
36  return String(object);
37};
38const copy = (a, s, t) => {
39  a.forEach((m) => {
40    if (s[m]) t[m] = s[m];
41  });
42};
43const lastOfPathSeparatorRegExp = /###/g;
44const cleanKey = (key) => key && key.includes("###") ? key.replace(lastOfPathSeparatorRegExp, ".") : key;
45const canNotTraverseDeeper = (object) => !object || isString$1(object);
46const getLastOfPath = (object, path2, Empty) => {
47  const stack = !isString$1(path2) ? path2 : path2.split(".");
48  let stackIndex = 0;
49  while (stackIndex < stack.length - 1) {
50    if (canNotTraverseDeeper(object)) return {};
51    const key = cleanKey(stack[stackIndex]);
52    if (!object[key] && Empty) object[key] = new Empty();
53    if (Object.prototype.hasOwnProperty.call(object, key)) {
54      object = object[key];
55    } else {
56      object = {};
57    }
58    ++stackIndex;
59  }
60  if (canNotTraverseDeeper(object)) return {};
61  return {
62    obj: object,
63    k: cleanKey(stack[stackIndex])
64  };
65};
66const setPath = (object, path2, newValue) => {
67  const {
68    obj,
69    k
70  } = getLastOfPath(object, path2, Object);
71  if (obj !== void 0 || path2.length === 1) {
72    obj[k] = newValue;
73    return;
74  }
75  let e = path2[path2.length - 1];
76  let p = path2.slice(0, path2.length - 1);
77  let last = getLastOfPath(object, p, Object);
78  while (last.obj === void 0 && p.length) {
79    e = `${p[p.length - 1]}.${e}`;
80    p = p.slice(0, p.length - 1);
81    last = getLastOfPath(object, p, Object);
82    if ((last == null ? void 0 : last.obj) && typeof last.obj[`${last.k}.${e}`] !== "undefined") {
83      last.obj = void 0;
84    }
85  }
86  last.obj[`${last.k}.${e}`] = newValue;
87};
88const pushPath = (object, path2, newValue, concat) => {
89  const {
90    obj,
91    k
92  } = getLastOfPath(object, path2, Object);
93  obj[k] = obj[k] || [];
94  obj[k].push(newValue);
95};
96const getPath = (object, path2) => {
97  const {
98    obj,
99    k
100  } = getLastOfPath(object, path2);
101  if (!obj) return void 0;
102  if (!Object.prototype.hasOwnProperty.call(obj, k)) return void 0;
103  return obj[k];
104};
105const getPathWithDefaults = (data, defaultData, key) => {
106  const value = getPath(data, key);
107  if (value !== void 0) {
108    return value;
109  }
110  return getPath(defaultData, key);
111};
112const deepExtend = (target, source, overwrite) => {
113  for (const prop in source) {
114    if (prop !== "__proto__" && prop !== "constructor") {
115      if (prop in target) {
116        if (isString$1(target[prop]) || target[prop] instanceof String || isString$1(source[prop]) || source[prop] instanceof String) {
117          if (overwrite) target[prop] = source[prop];
118        } else {
119          deepExtend(target[prop], source[prop], overwrite);
120        }
121      } else {
122        target[prop] = source[prop];
123      }
124    }
125  }
126  return target;
127};
128const regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
129const _entityMap = {
130  "&": "&amp;",
131  "<": "&lt;",
132  ">": "&gt;",
133  '"': "&quot;",
134  "'": "&#39;",
135  "/": "&#x2F;"
136};
137const escape = (data) => {
138  if (isString$1(data)) {
139    return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
140  }
141  return data;
142};
143class RegExpCache {
144  constructor(capacity) {
145    this.capacity = capacity;
146    this.regExpMap = /* @__PURE__ */ new Map();
147    this.regExpQueue = [];
148  }
149  getRegExp(pattern) {
150    const regExpFromCache = this.regExpMap.get(pattern);
151    if (regExpFromCache !== void 0) {
152      return regExpFromCache;
153    }
154    const regExpNew = new RegExp(pattern);
155    if (this.regExpQueue.length === this.capacity) {
156      this.regExpMap.delete(this.regExpQueue.shift());
157    }
158    this.regExpMap.set(pattern, regExpNew);
159    this.regExpQueue.push(pattern);
160    return regExpNew;
161  }
162}
163const chars = [" ", ",", "?", "!", ";"];
164const looksLikeObjectPathRegExpCache = new RegExpCache(20);
165const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
166  nsSeparator = nsSeparator || "";
167  keySeparator = keySeparator || "";
168  const possibleChars = chars.filter((c) => !nsSeparator.includes(c) && !keySeparator.includes(c));
169  if (possibleChars.length === 0) return true;
170  const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
171  let matched = !r.test(key);
172  if (!matched) {
vendor: 4,719 bytes, lines 173-346
173    const ki = key.indexOf(keySeparator);
174    if (ki > 0 && !r.test(key.substring(0, ki))) {
175      matched = true;
176    }
177  }
178  return matched;
179};
180const deepFind = (obj, path2, keySeparator = ".") => {
181  if (!obj) return void 0;
182  if (obj[path2]) {
183    if (!Object.prototype.hasOwnProperty.call(obj, path2)) return void 0;
184    return obj[path2];
185  }
186  const tokens = path2.split(keySeparator);
187  let current = obj;
188  for (let i = 0; i < tokens.length; ) {
189    if (!current || typeof current !== "object") {
190      return void 0;
191    }
192    let next;
193    let nextPath = "";
194    for (let j = i; j < tokens.length; ++j) {
195      if (j !== i) {
196        nextPath += keySeparator;
197      }
198      nextPath += tokens[j];
199      next = current[nextPath];
200      if (next !== void 0) {
201        if (["string", "number", "boolean"].includes(typeof next) && j < tokens.length - 1) {
202          continue;
203        }
204        i += j - i + 1;
205        break;
206      }
207    }
208    current = next;
209  }
210  return current;
211};
212const getCleanedCode = (code) => code == null ? void 0 : code.replace(/_/g, "-");
213const consoleLogger = {
214  type: "logger",
215  log(args) {
216    this.output("log", args);
217  },
218  warn(args) {
219    this.output("warn", args);
220  },
221  error(args) {
222    this.output("error", args);
223  },
224  output(type, args) {
225    var _a, _b;
226    (_b = (_a = console == null ? void 0 : console[type]) == null ? void 0 : _a.apply) == null ? void 0 : _b.call(_a, console, args);
227  }
228};
229class Logger {
230  constructor(concreteLogger, options = {}) {
231    this.init(concreteLogger, options);
232  }
233  init(concreteLogger, options = {}) {
234    this.prefix = options.prefix || "i18next:";
235    this.logger = concreteLogger || consoleLogger;
236    this.options = options;
237    this.debug = options.debug;
238  }
239  log(...args) {
240    return this.forward(args, "log", "", true);
241  }
242  warn(...args) {
243    return this.forward(args, "warn", "", true);
244  }
245  error(...args) {
246    return this.forward(args, "error", "");
247  }
248  deprecate(...args) {
249    return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
250  }
251  forward(args, lvl, prefix, debugOnly) {
252    if (debugOnly && !this.debug) return null;
253    args = args.map((a) => isString$1(a) ? a.replace(/[\r\n\x00-\x1F\x7F]/g, " ") : a);
254    if (isString$1(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
255    return this.logger[lvl](args);
256  }
257  create(moduleName) {
258    return new Logger(this.logger, {
259      ...{
260        prefix: `${this.prefix}:${moduleName}:`
261      },
262      ...this.options
263    });
264  }
265  clone(options) {
266    options = options || this.options;
267    options.prefix = options.prefix || this.prefix;
268    return new Logger(this.logger, options);
269  }
270}
271var baseLogger = new Logger();
272class EventEmitter {
273  constructor() {
274    this.observers = {};
275  }
276  on(events, listener) {
277    events.split(" ").forEach((event) => {
278      if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
279      const numListeners = this.observers[event].get(listener) || 0;
280      this.observers[event].set(listener, numListeners + 1);
281    });
282    return this;
283  }
284  off(event, listener) {
285    if (!this.observers[event]) return;
286    if (!listener) {
287      delete this.observers[event];
288      return;
289    }
290    this.observers[event].delete(listener);
291  }
292  once(event, listener) {
293    const wrapper = (...args) => {
294      listener(...args);
295      this.off(event, wrapper);
296    };
297    this.on(event, wrapper);
298    return this;
299  }
300  emit(event, ...args) {
301    if (this.observers[event]) {
302      const cloned = Array.from(this.observers[event].entries());
303      cloned.forEach(([observer, numTimesAdded]) => {
304        for (let i = 0; i < numTimesAdded; i++) {
305          observer(...args);
306        }
307      });
308    }
309    if (this.observers["*"]) {
310      const cloned = Array.from(this.observers["*"].entries());
311      cloned.forEach(([observer, numTimesAdded]) => {
312        for (let i = 0; i < numTimesAdded; i++) {
313          observer(event, ...args);
314        }
315      });
316    }
317  }
318}
319class ResourceStore extends EventEmitter {
320  constructor(data, options = {
321    ns: ["translation"],
322    defaultNS: "translation"
323  }) {
324    super();
325    this.data = data || {};
326    this.options = options;
327    if (this.options.keySeparator === void 0) {
328      this.options.keySeparator = ".";
329    }
330    if (this.options.ignoreJSONStructure === void 0) {
331      this.options.ignoreJSONStructure = true;
332    }
333  }
334  addNamespaces(ns) {
335    if (!this.options.ns.includes(ns)) {
336      this.options.ns.push(ns);
337    }
338  }
339  removeNamespaces(ns) {
340    const index = this.options.ns.indexOf(ns);
341    if (index > -1) {
342      this.options.ns.splice(index, 1);
343    }
344  }
345  getResource(lng, ns, key, options = {}) {
346    var _a, _b;
347    const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
348    const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
349    let path2;
350    if (lng.includes(".")) {
351      path2 = lng.split(".");
352    } else {
353      path2 = [lng, ns];
354      if (key) {
355        if (Array.isArray(key)) {
356          path2.push(...key);
357        } else if (isString$1(key) && keySeparator) {
358          path2.push(...key.split(keySeparator));
359        } else {
360          path2.push(key);
361        }
362      }
363    }
364    const result = getPath(this.data, path2);
365    if (!result && !ns && !key && lng.includes(".")) {
366      lng = path2[0];
367      ns = path2[1];
368      key = path2.slice(2).join(".");
369    }
370    if (result || !ignoreJSONStructure || !isString$1(key)) return result;
371    return deepFind((_b = (_a = this.data) == null ? void 0 : _a[lng]) == null ? void 0 : _b[ns], key, keySeparator);
372  }
373  addResource(lng, ns, key, value, options = {
374    silent: false
375  }) {
376    const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
377    let path2 = [lng, ns];
378    if (key) path2 = path2.concat(keySeparator ? key.split(keySeparator) : key);
379    if (lng.includes(".")) {
380      path2 = lng.split(".");
381      value = ns;
382      ns = path2[1];
383    }
384    this.addNamespaces(ns);
385    setPath(this.data, path2, value);
386    if (!options.silent) this.emit("added", lng, ns, key, value);
387  }
388  addResources(lng, ns, resources, options = {
389    silent: false
390  }) {
391    for (const m in resources) {
392      if (isString$1(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
393        silent: true
394      });
395    }
396    if (!options.silent) this.emit("added", lng, ns, resources);
397  }
398  addResourceBundle(lng, ns, resources, deep, overwrite, options = {
399    silent: false,
400    skipCopy: false
401  }) {
402    let path2 = [lng, ns];
403    if (lng.includes(".")) {
404      path2 = lng.split(".");
405      deep = resources;
406      resources = ns;
407      ns = path2[1];
408    }
409    this.addNamespaces(ns);
410    let pack = getPath(this.data, path2) || {};
411    if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
412    if (deep) {
413      deepExtend(pack, resources, overwrite);
414    } else {
415      pack = {
416        ...pack,
417        ...resources
418      };
419    }
420    setPath(this.data, path2, pack);
421    if (!options.silent) this.emit("added", lng, ns, resources);
422  }
423  removeResourceBundle(lng, ns) {
424    if (this.hasResourceBundle(lng, ns)) {
425      delete this.data[lng][ns];
426    }
427    this.removeNamespaces(ns);
428    this.emit("removed", lng, ns);
429  }
430  hasResourceBundle(lng, ns) {
431    return this.getResource(lng, ns) !== void 0;
432  }
433  getResourceBundle(lng, ns) {
434    if (!ns) ns = this.options.defaultNS;
435    return this.getResource(lng, ns);
436  }
437  getDataByLanguage(lng) {
438    return this.data[lng];
439  }
440  hasLanguageSomeTranslations(lng) {
441    const data = this.getDataByLanguage(lng);
442    const n = data && Object.keys(data) || [];
443    return !!n.find((v) => data[v] && Object.keys(data[v]).length > 0);
444  }
445  toJSON() {
446    return this.data;
447  }
448}
449var postProcessor = {
450  processors: {},
451  addPostProcessor(module) {
452    this.processors[module.name] = module;
453  },
454  handle(processors, value, key, options, translator) {
455    processors.forEach((processor) => {
456      var _a;
457      value = ((_a = this.processors[processor]) == null ? void 0 : _a.process(value, key, options, translator)) ?? value;
458    });
459    return value;
460  }
461};
462const PATH_KEY = Symbol("i18next/PATH_KEY");
463function createProxy() {
464  const state = [];
465  const handler = /* @__PURE__ */ Object.create(null);
466  let proxy;
467  handler.get = (target, key) => {
468    var _a;
469    (_a = proxy == null ? void 0 : proxy.revoke) == null ? void 0 : _a.call(proxy);
470    if (key === PATH_KEY) return state;
471    state.push(key);
472    proxy = Proxy.revocable(target, handler);
473    return proxy.proxy;
474  };
475  return Proxy.revocable(/* @__PURE__ */ Object.create(null), handler).proxy;
476}
477function keysFromSelector(selector, opts) {
478  const {
479    [PATH_KEY]: path2
480  } = selector(createProxy());
481  const keySeparator = (opts == null ? void 0 : opts.keySeparator) ?? ".";
482  const nsSeparator = (opts == null ? void 0 : opts.nsSeparator) ?? ":";
483  if (path2.length > 1 && nsSeparator) {
484    const ns = opts == null ? void 0 : opts.ns;
485    const nsArray = Array.isArray(ns) ? ns : null;
486    if (nsArray && nsArray.length > 1 && nsArray.slice(1).includes(path2[0])) {
487      return `${path2[0]}${nsSeparator}${path2.slice(1).join(keySeparator)}`;
488    }
489  }
490  return path2.join(keySeparator);
491}
492const shouldHandleAsObject = (res) => !isString$1(res) && typeof res !== "boolean" && typeof res !== "number";
vendor: 13,113 bytes, lines 493-783
493class Translator extends EventEmitter {
494  constructor(services, options = {}) {
495    super();
496    copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
497    this.options = options;
498    if (this.options.keySeparator === void 0) {
499      this.options.keySeparator = ".";
500    }
501    this.logger = baseLogger.create("translator");
502    this.checkedLoadedFor = {};
503  }
504  changeLanguage(lng) {
505    if (lng) this.language = lng;
506  }
507  exists(key, o = {
508    interpolation: {}
509  }) {
510    const opt = {
511      ...o
512    };
513    if (key == null) return false;
514    const resolved = this.resolve(key, opt);
515    if ((resolved == null ? void 0 : resolved.res) === void 0) return false;
516    const isObject2 = shouldHandleAsObject(resolved.res);
517    if (opt.returnObjects === false && isObject2) {
518      return false;
519    }
520    return true;
521  }
522  extractFromKey(key, opt) {
523    let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
524    if (nsSeparator === void 0) nsSeparator = ":";
525    const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
526    let namespaces = opt.ns || this.options.defaultNS || [];
527    const wouldCheckForNsInKey = nsSeparator && key.includes(nsSeparator);
528    const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
529    if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
530      const m = key.match(this.interpolator.nestingRegexp);
531      if (m && m.length > 0) {
532        return {
533          key,
534          namespaces: isString$1(namespaces) ? [namespaces] : namespaces
535        };
536      }
537      const parts = key.split(nsSeparator);
538      if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.includes(parts[0])) namespaces = parts.shift();
539      key = parts.join(keySeparator);
540    }
541    return {
542      key,
543      namespaces: isString$1(namespaces) ? [namespaces] : namespaces
544    };
545  }
546  translate(keys, o, lastKey) {
547    let opt = typeof o === "object" ? {
548      ...o
549    } : o;
550    if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
551      opt = this.options.overloadTranslationOptionHandler(arguments);
552    }
553    if (typeof opt === "object") opt = {
554      ...opt
555    };
556    if (!opt) opt = {};
557    if (keys == null) return "";
558    if (typeof keys === "function") keys = keysFromSelector(keys, {
559      ...this.options,
560      ...opt
561    });
562    if (!Array.isArray(keys)) keys = [String(keys)];
563    keys = keys.map((k) => typeof k === "function" ? keysFromSelector(k, {
564      ...this.options,
565      ...opt
566    }) : String(k));
567    const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
568    const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
569    const {
570      key,
571      namespaces
572    } = this.extractFromKey(keys[keys.length - 1], opt);
573    const namespace = namespaces[namespaces.length - 1];
574    let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
575    if (nsSeparator === void 0) nsSeparator = ":";
576    const lng = opt.lng || this.language;
577    const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
578    if ((lng == null ? void 0 : lng.toLowerCase()) === "cimode") {
579      if (appendNamespaceToCIMode) {
580        if (returnDetails) {
581          return {
582            res: `${namespace}${nsSeparator}${key}`,
583            usedKey: key,
584            exactUsedKey: key,
585            usedLng: lng,
586            usedNS: namespace,
587            usedParams: this.getUsedParamsDetails(opt)
588          };
589        }
590        return `${namespace}${nsSeparator}${key}`;
591      }
592      if (returnDetails) {
593        return {
594          res: key,
595          usedKey: key,
596          exactUsedKey: key,
597          usedLng: lng,
598          usedNS: namespace,
599          usedParams: this.getUsedParamsDetails(opt)
600        };
601      }
602      return key;
603    }
604    const resolved = this.resolve(keys, opt);
605    let res = resolved == null ? void 0 : resolved.res;
606    const resUsedKey = (resolved == null ? void 0 : resolved.usedKey) || key;
607    const resExactUsedKey = (resolved == null ? void 0 : resolved.exactUsedKey) || key;
608    const noObject = ["[object Number]", "[object Function]", "[object RegExp]"];
609    const joinArrays = opt.joinArrays !== void 0 ? opt.joinArrays : this.options.joinArrays;
610    const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
611    const needsPluralHandling = opt.count !== void 0 && !isString$1(opt.count);
612    const hasDefaultValue = Translator.hasDefaultValue(opt);
613    const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
614    const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
615      ordinal: false
616    }) : "";
617    const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
618    const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
619    let resForObjHndl = res;
620    if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
621      resForObjHndl = defaultValue;
622    }
623    const handleAsObject = shouldHandleAsObject(resForObjHndl);
624    const resType = Object.prototype.toString.apply(resForObjHndl);
625    if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString$1(joinArrays) && Array.isArray(resForObjHndl))) {
626      if (!opt.returnObjects && !this.options.returnObjects) {
627        if (!this.options.returnedObjectHandler) {
628          this.logger.warn("accessing an object - but returnObjects options is not enabled!");
629        }
630        const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
631          ...opt,
632          ns: namespaces
633        }) : `key '${key} (${this.language})' returned an object instead of string.`;
634        if (returnDetails) {
635          resolved.res = r;
636          resolved.usedParams = this.getUsedParamsDetails(opt);
637          return resolved;
638        }
639        return r;
640      }
641      if (keySeparator) {
642        const resTypeIsArray = Array.isArray(resForObjHndl);
643        const copy2 = resTypeIsArray ? [] : {};
644        const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
645        for (const m in resForObjHndl) {
646          if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
647            const deepKey = `${newKeyToUse}${keySeparator}${m}`;
648            if (hasDefaultValue && !res) {
649              copy2[m] = this.translate(deepKey, {
650                ...opt,
651                defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : void 0,
652                ...{
653                  joinArrays: false,
654                  ns: namespaces
655                }
656              });
657            } else {
658              copy2[m] = this.translate(deepKey, {
659                ...opt,
660                ...{
661                  joinArrays: false,
662                  ns: namespaces
663                }
664              });
665            }
666            if (copy2[m] === deepKey) copy2[m] = resForObjHndl[m];
667          }
668        }
669        res = copy2;
670      }
671    } else if (handleAsObjectInI18nFormat && isString$1(joinArrays) && Array.isArray(res)) {
672      res = res.join(joinArrays);
673      if (res) res = this.extendTranslation(res, keys, opt, lastKey);
674    } else {
675      let usedDefault = false;
676      let usedKey = false;
677      if (!this.isValidLookup(res) && hasDefaultValue) {
678        usedDefault = true;
679        res = defaultValue;
680      }
681      if (!this.isValidLookup(res)) {
682        usedKey = true;
683        res = key;
684      }
685      const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
686      const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
687      const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
688      if (usedKey || usedDefault || updateMissing) {
689        this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, needsPluralHandling && !updateMissing ? `${key}${this.pluralResolver.getSuffix(lng, opt.count, opt)}` : key, updateMissing ? defaultValue : res);
690        if (keySeparator) {
691          const fk = this.resolve(key, {
692            ...opt,
693            keySeparator: false
694          });
695          if (fk && fk.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.");
696        }
697        let lngs = [];
698        const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
699        if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) {
700          for (let i = 0; i < fallbackLngs.length; i++) {
701            lngs.push(fallbackLngs[i]);
702          }
703        } else if (this.options.saveMissingTo === "all") {
704          lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
705        } else {
706          lngs.push(opt.lng || this.language);
707        }
708        const send = (l, k, specificDefaultValue) => {
709          var _a;
710          const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
711          if (this.options.missingKeyHandler) {
712            this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
713          } else if ((_a = this.backendConnector) == null ? void 0 : _a.saveMissing) {
714            this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
715          }
716          this.emit("missingKey", l, namespace, k, res);
717        };
718        if (this.options.saveMissing) {
719          if (this.options.saveMissingPlurals && needsPluralHandling) {
720            lngs.forEach((language) => {
721              const suffixes = this.pluralResolver.getSuffixes(language, opt);
722              if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && !suffixes.includes(`${this.options.pluralSeparator}zero`)) {
723                suffixes.push(`${this.options.pluralSeparator}zero`);
724              }
725              suffixes.forEach((suffix) => {
726                send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
727              });
728            });
729          } else {
730            send(lngs, key, defaultValue);
731          }
732        }
733      }
734      res = this.extendTranslation(res, keys, opt, resolved, lastKey);
735      if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
736        res = `${namespace}${nsSeparator}${key}`;
737      }
738      if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
739        res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
740      }
741    }
742    if (returnDetails) {
743      resolved.res = res;
744      resolved.usedParams = this.getUsedParamsDetails(opt);
745      return resolved;
746    }
747    return res;
748  }
749  extendTranslation(res, key, opt, resolved, lastKey) {
750    var _a, _b;
751    if ((_a = this.i18nFormat) == null ? void 0 : _a.parse) {
752      res = this.i18nFormat.parse(res, {
753        ...this.options.interpolation.defaultVariables,
754        ...opt
755      }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
756        resolved
757      });
758    } else if (!opt.skipInterpolation) {
759      if (opt.interpolation) this.interpolator.init({
760        ...opt,
761        ...{
762          interpolation: {
763            ...this.options.interpolation,
764            ...opt.interpolation
765          }
766        }
767      });
768      const skipOnVariables = isString$1(res) && (((_b = opt == null ? void 0 : opt.interpolation) == null ? void 0 : _b.skipOnVariables) !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
769      let nestBef;
770      if (skipOnVariables) {
771        const nb = res.match(this.interpolator.nestingRegexp);
772        nestBef = nb && nb.length;
773      }
774      let data = opt.replace && !isString$1(opt.replace) ? opt.replace : opt;
775      if (this.options.interpolation.defaultVariables) data = {
776        ...this.options.interpolation.defaultVariables,
777        ...data
778      };
779      res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
780      if (skipOnVariables) {
781        const na = res.match(this.interpolator.nestingRegexp);
782        const nestAft = na && na.length;
783        if (nestBef < nestAft) opt.nest = false;
784      }
785      if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
786      if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
787        if ((lastKey == null ? void 0 : lastKey[0]) === args[0] && !opt.context) {
788          this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
789          return null;
790        }
791        return this.translate(...args, key);
792      }, opt);
793      if (opt.interpolation) this.interpolator.reset();
794    }
795    const postProcess = opt.postProcess || this.options.postProcess;
796    const postProcessorNames = isString$1(postProcess) ? [postProcess] : postProcess;
797    if (res != null && (postProcessorNames == null ? void 0 : postProcessorNames.length) && opt.applyPostProcessor !== false) {
798      res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
799        i18nResolved: {
800          ...resolved,
801          usedParams: this.getUsedParamsDetails(opt)
802        },
803        ...opt
804      } : opt, this);
805    }
806    return res;
807  }
808  resolve(keys, opt = {}) {
809    let found;
810    let usedKey;
811    let exactUsedKey;
812    let usedLng;
813    let usedNS;
814    if (isString$1(keys)) keys = [keys];
815    if (Array.isArray(keys)) keys = keys.map((k) => typeof k === "function" ? keysFromSelector(k, {
816      ...this.options,
817      ...opt
818    }) : k);
819    keys.forEach((k) => {
820      if (this.isValidLookup(found)) return;
821      const extracted = this.extractFromKey(k, opt);
822      const key = extracted.key;
823      usedKey = key;
824      let namespaces = extracted.namespaces;
825      if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
826      const needsPluralHandling = opt.count !== void 0 && !isString$1(opt.count);
827      const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
828      const needsContextHandling = opt.context !== void 0 && (isString$1(opt.context) || typeof opt.context === "number") && opt.context !== "";
829      const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
830      namespaces.forEach((ns) => {
831        var _a, _b;
832        if (this.isValidLookup(found)) return;
833        usedNS = ns;
834        if (!this.checkedLoadedFor[`${codes[0]}-${ns}`] && ((_a = this.utils) == null ? void 0 : _a.hasLoadedNamespace) && !((_b = this.utils) == null ? void 0 : _b.hasLoadedNamespace(usedNS))) {
835          this.checkedLoadedFor[`${codes[0]}-${ns}`] = true;
836          this.logger.warn(`key "${usedKey}" for languages "${codes.join(", ")}" won't get resolved as namespace "${usedNS}" 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!!!");
837        }
838        codes.forEach((code) => {
839          var _a2;
840          if (this.isValidLookup(found)) return;
841          usedLng = code;
842          const finalKeys = [key];
843          if ((_a2 = this.i18nFormat) == null ? void 0 : _a2.addLookupKeys) {
844            this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
845          } else {
846            let pluralSuffix;
847            if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
848            const zeroSuffix = `${this.options.pluralSeparator}zero`;
849            const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
850            if (needsPluralHandling) {
851              if (opt.ordinal && pluralSuffix.startsWith(ordinalPrefix)) {
852                finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
853              }
854              finalKeys.push(key + pluralSuffix);
855              if (needsZeroSuffixLookup) {
856                finalKeys.push(key + zeroSuffix);
857              }
858            }
859            if (needsContextHandling) {
860              const contextKey = `${key}${this.options.contextSeparator || "_"}${opt.context}`;
861              finalKeys.push(contextKey);
862              if (needsPluralHandling) {
863                if (opt.ordinal && pluralSuffix.startsWith(ordinalPrefix)) {
864                  finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
865                }
866                finalKeys.push(contextKey + pluralSuffix);
867                if (needsZeroSuffixLookup) {
868                  finalKeys.push(contextKey + zeroSuffix);
869                }
870              }
871            }
872          }
873          let possibleKey;
874          while (possibleKey = finalKeys.pop()) {
875            if (!this.isValidLookup(found)) {
876              exactUsedKey = possibleKey;
877              found = this.getResource(code, ns, possibleKey, opt);
878            }
879          }
880        });
881      });
882    });
883    return {
884      res: found,
885      usedKey,
886      exactUsedKey,
887      usedLng,
888      usedNS
889    };
890  }
891  isValidLookup(res) {
892    return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
893  }
894  getResource(code, ns, key, options = {}) {
895    var _a;
896    if ((_a = this.i18nFormat) == null ? void 0 : _a.getResource) return this.i18nFormat.getResource(code, ns, key, options);
897    return this.resourceStore.getResource(code, ns, key, options);
898  }
899  getUsedParamsDetails(options = {}) {
900    const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
901    const useOptionsReplaceForData = options.replace && !isString$1(options.replace);
902    let data = useOptionsReplaceForData ? options.replace : options;
903    if (useOptionsReplaceForData && typeof options.count !== "undefined") {
904      data.count = options.count;
905    }
906    if (this.options.interpolation.defaultVariables) {
907      data = {
908        ...this.options.interpolation.defaultVariables,
909        ...data
910      };
911    }
912    if (!useOptionsReplaceForData) {
913      data = {
914        ...data
915      };
916      for (const key of optionsKeys) {
917        delete data[key];
918      }
919    }
920    return data;
921  }
922  static hasDefaultValue(options) {
923    const prefix = "defaultValue";
924    for (const option in options) {
925      if (Object.prototype.hasOwnProperty.call(options, option) && option.startsWith(prefix) && void 0 !== options[option]) {
926        return true;
927      }
928    }
929    return false;
vendor: 7,151 bytes, lines 930-1117
930  }
931}
932class LanguageUtil {
933  constructor(options) {
934    this.options = options;
935    this.supportedLngs = this.options.supportedLngs || false;
936    this.logger = baseLogger.create("languageUtils");
937  }
938  getScriptPartFromCode(code) {
939    code = getCleanedCode(code);
940    if (!code || !code.includes("-")) return null;
941    const p = code.split("-");
942    if (p.length === 2) return null;
943    p.pop();
944    if (p[p.length - 1].toLowerCase() === "x") return null;
945    return this.formatLanguageCode(p.join("-"));
946  }
947  getLanguagePartFromCode(code) {
948    code = getCleanedCode(code);
949    if (!code || !code.includes("-")) return code;
950    const p = code.split("-");
951    return this.formatLanguageCode(p[0]);
952  }
953  formatLanguageCode(code) {
954    if (isString$1(code) && code.includes("-")) {
955      let formattedCode;
956      try {
957        formattedCode = Intl.getCanonicalLocales(code)[0];
958      } catch (e) {
959      }
960      if (formattedCode && this.options.lowerCaseLng) {
961        formattedCode = formattedCode.toLowerCase();
962      }
963      if (formattedCode) return formattedCode;
964      if (this.options.lowerCaseLng) {
965        return code.toLowerCase();
966      }
967      return code;
968    }
969    return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
970  }
971  isSupportedCode(code) {
972    if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
973      code = this.getLanguagePartFromCode(code);
974    }
975    return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.includes(code);
976  }
977  getBestMatchFromCodes(codes) {
978    if (!codes) return null;
979    let found;
980    codes.forEach((code) => {
981      if (found) return;
982      const cleanedLng = this.formatLanguageCode(code);
983      if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
984    });
985    if (!found && this.options.supportedLngs) {
986      codes.forEach((code) => {
987        if (found) return;
988        const lngScOnly = this.getScriptPartFromCode(code);
989        if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
990        const lngOnly = this.getLanguagePartFromCode(code);
991        if (this.isSupportedCode(lngOnly)) return found = lngOnly;
992        found = this.options.supportedLngs.find((supportedLng) => {
993          if (supportedLng === lngOnly) return true;
994          if (!supportedLng.includes("-") && !lngOnly.includes("-")) return false;
995          if (supportedLng.includes("-") && !lngOnly.includes("-") && supportedLng.slice(0, supportedLng.indexOf("-")) === lngOnly) return true;
996          if (supportedLng.startsWith(lngOnly) && lngOnly.length > 1) return true;
997          return false;
998        });
999      });
1000    }
1001    if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
1002    return found;
1003  }
1004  getFallbackCodes(fallbacks, code) {
1005    if (!fallbacks) return [];
1006    if (typeof fallbacks === "function") fallbacks = fallbacks(code);
1007    if (isString$1(fallbacks)) fallbacks = [fallbacks];
1008    if (Array.isArray(fallbacks)) return fallbacks;
1009    if (!code) return fallbacks.default || [];
1010    let found = fallbacks[code];
1011    if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
1012    if (!found) found = fallbacks[this.formatLanguageCode(code)];
1013    if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
1014    if (!found) found = fallbacks.default;
1015    return found || [];
1016  }
1017  toResolveHierarchy(code, fallbackCode) {
1018    const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
1019    const codes = [];
1020    const addCode = (c) => {
1021      if (!c) return;
1022      if (this.isSupportedCode(c)) {
1023        codes.push(c);
1024      } else {
1025        this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
1026      }
1027    };
1028    if (isString$1(code) && (code.includes("-") || code.includes("_"))) {
1029      if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
1030      if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
1031      if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
1032    } else if (isString$1(code)) {
1033      addCode(this.formatLanguageCode(code));
1034    }
1035    fallbackCodes.forEach((fc) => {
1036      if (!codes.includes(fc)) addCode(this.formatLanguageCode(fc));
1037    });
1038    return codes;
1039  }
1040}
1041const suffixesOrder = {
1042  zero: 0,
1043  one: 1,
1044  two: 2,
1045  few: 3,
1046  many: 4,
1047  other: 5
1048};
1049const dummyRule = {
1050  select: (count) => count === 1 ? "one" : "other",
1051  resolvedOptions: () => ({
1052    pluralCategories: ["one", "other"]
1053  })
1054};
1055class PluralResolver {
1056  constructor(languageUtils, options = {}) {
1057    this.languageUtils = languageUtils;
1058    this.options = options;
1059    this.logger = baseLogger.create("pluralResolver");
1060    this.pluralRulesCache = {};
1061  }
1062  clearCache() {
1063    this.pluralRulesCache = {};
1064  }
1065  getRule(code, options = {}) {
1066    const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
1067    const type = options.ordinal ? "ordinal" : "cardinal";
1068    const cacheKey = JSON.stringify({
1069      cleanedCode,
1070      type
1071    });
1072    if (cacheKey in this.pluralRulesCache) {
1073      return this.pluralRulesCache[cacheKey];
1074    }
1075    let rule;
1076    try {
1077      rule = new Intl.PluralRules(cleanedCode, {
1078        type
1079      });
1080    } catch (err) {
1081      if (typeof Intl === "undefined") {
1082        this.logger.error("No Intl support, please use an Intl polyfill!");
1083        return dummyRule;
1084      }
1085      if (!code.match(/-|_/)) return dummyRule;
1086      const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1087      rule = this.getRule(lngPart, options);
1088    }
1089    this.pluralRulesCache[cacheKey] = rule;
1090    return rule;
1091  }
1092  needsPlural(code, options = {}) {
1093    let rule = this.getRule(code, options);
1094    if (!rule) rule = this.getRule("dev", options);
1095    return (rule == null ? void 0 : rule.resolvedOptions().pluralCategories.length) > 1;
1096  }
1097  getPluralFormsOfKey(code, key, options = {}) {
1098    return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
1099  }
1100  getSuffixes(code, options = {}) {
1101    let rule = this.getRule(code, options);
1102    if (!rule) rule = this.getRule("dev", options);
1103    if (!rule) return [];
1104    return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
1105  }
1106  getSuffix(code, count, options = {}) {
1107    const rule = this.getRule(code, options);
1108    if (rule) {
1109      return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
1110    }
1111    this.logger.warn(`no plural rule found for: ${code}`);
1112    return this.getSuffix("dev", count, options);
1113  }
1114}
1115const deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
1116  let path2 = getPathWithDefaults(data, defaultData, key);
1117  if (!path2 && ignoreJSONStructure && isString$1(key)) {
1118    path2 = deepFind(data, key, keySeparator);
1119    if (path2 === void 0) path2 = deepFind(defaultData, key, keySeparator);
1120  }
1121  return path2;
1122};
1123const regexSafe = (val) => val.replace(/\$/g, "$$$$");
1124class Interpolator {
1125  constructor(options = {}) {
1126    var _a;
1127    this.logger = baseLogger.create("interpolator");
1128    this.options = options;
1129    this.format = ((_a = options == null ? void 0 : options.interpolation) == null ? void 0 : _a.format) || ((value) => value);
1130    this.init(options);
1131  }
1132  init(options = {}) {
1133    if (!options.interpolation) options.interpolation = {
1134      escapeValue: true
1135    };
1136    const {
1137      escape: escape$1,
1138      escapeValue,
1139      useRawValueToEscape,
1140      prefix,
1141      prefixEscaped,
1142      suffix,
1143      suffixEscaped,
1144      formatSeparator,
1145      unescapeSuffix,
1146      unescapePrefix,
1147      nestingPrefix,
1148      nestingPrefixEscaped,
1149      nestingSuffix,
1150      nestingSuffixEscaped,
1151      nestingOptionsSeparator,
1152      maxReplaces,
1153      alwaysFormat
1154    } = options.interpolation;
1155    this.escape = escape$1 !== void 0 ? escape$1 : escape;
1156    this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
1157    this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
1158    this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
1159    this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
1160    this.formatSeparator = formatSeparator || ",";
1161    this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix ? regexEscape(unescapePrefix) : "-";
1162    this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix ? regexEscape(unescapeSuffix) : "";
1163    this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
1164    this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
1165    this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
1166    this.maxReplaces = maxReplaces || 1e3;
1167    this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
1168    this.resetRegExp();
1169  }
1170  reset() {
1171    if (this.options) this.init(this.options);
1172  }
1173  resetRegExp() {
1174    const getOrResetRegExp = (existingRegExp, pattern) => {
1175      if ((existingRegExp == null ? void 0 : existingRegExp.source) === pattern) {
1176        existingRegExp.lastIndex = 0;
1177        return existingRegExp;
1178      }
1179      return new RegExp(pattern, "g");
1180    };
1181    this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1182    this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1183    this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
1184  }
1185  interpolate(str, data, lng, options) {
1186    var _a;
1187    let match;
1188    let value;
1189    let replaces;
1190    const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1191    const handleFormat = (key) => {
1192      if (!key.includes(this.formatSeparator)) {
1193        const path2 = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1194        return this.alwaysFormat ? this.format(path2, void 0, lng, {
1195          ...options,
1196          ...data,
1197          interpolationkey: key
1198        }) : path2;
1199      }
1200      const p = key.split(this.formatSeparator);
1201      const k = p.shift().trim();
1202      const f = p.join(this.formatSeparator).trim();
1203      return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1204        ...options,
1205        ...data,
1206        interpolationkey: k
1207      });
1208    };
1209    this.resetRegExp();
1210    if (!this.escapeValue && typeof str === "string" && /\$t\([^)]*\{[^}]*\{\{/.test(str)) {
1211      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.");
1212    }
1213    const missingInterpolationHandler = (options == null ? void 0 : options.missingInterpolationHandler) || this.options.missingInterpolationHandler;
1214    const skipOnVariables = ((_a = options == null ? void 0 : options.interpolation) == null ? void 0 : _a.skipOnVariables) !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1215    const todos = [{
1216      regex: this.regexpUnescape,
1217      safeValue: (val) => regexSafe(val)
1218    }, {
1219      regex: this.regexp,
1220      safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1221    }];
1222    todos.forEach((todo) => {
1223      replaces = 0;
1224      while (match = todo.regex.exec(str)) {
1225        const matchedVar = match[1].trim();
1226        value = handleFormat(matchedVar);
1227        if (value === void 0) {
1228          if (typeof missingInterpolationHandler === "function") {
1229            const temp = missingInterpolationHandler(str, match, options);
1230            value = isString$1(temp) ? temp : "";
1231          } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1232            value = "";
1233          } else if (skipOnVariables) {
1234            value = match[0];
1235            continue;
1236          } else {
1237            this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1238            value = "";
1239          }
1240        } else if (!isString$1(value) && !this.useRawValueToEscape) {
1241          value = makeString(value);
1242        }
1243        const safeValue = todo.safeValue(value);
1244        str = str.replace(match[0], safeValue);
1245        if (skipOnVariables) {
1246          todo.regex.lastIndex += value.length;
1247          todo.regex.lastIndex -= match[0].length;
1248        } else {
1249          todo.regex.lastIndex = 0;
1250        }
1251        replaces++;
1252        if (replaces >= this.maxReplaces) {
1253          break;
1254        }
1255      }
1256    });
1257    return str;
1258  }
1259  nest(str, fc, options = {}) {
1260    let match;
1261    let value;
vendor: 4,086 bytes, lines 1262-1360
1262    let clonedOptions;
1263    const handleHasOptions = (key, inheritedOptions) => {
1264      const sep = this.nestingOptionsSeparator;
1265      if (!key.includes(sep)) return key;
1266      const c = key.split(new RegExp(`${regexEscape(sep)}[ ]*{`));
1267      let optionsString = `{${c[1]}`;
1268      key = c[0];
1269      optionsString = this.interpolate(optionsString, clonedOptions);
1270      const matchedSingleQuotes = optionsString.match(/'/g);
1271      const matchedDoubleQuotes = optionsString.match(/"/g);
1272      if (((matchedSingleQuotes == null ? void 0 : matchedSingleQuotes.length) ?? 0) % 2 === 0 && !matchedDoubleQuotes || ((matchedDoubleQuotes == null ? void 0 : matchedDoubleQuotes.length) ?? 0) % 2 !== 0) {
1273        optionsString = optionsString.replace(/'/g, '"');
1274      }
1275      try {
1276        clonedOptions = JSON.parse(optionsString);
1277        if (inheritedOptions) clonedOptions = {
1278          ...inheritedOptions,
1279          ...clonedOptions
1280        };
1281      } catch (e) {
1282        this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1283        return `${key}${sep}${optionsString}`;
1284      }
1285      if (clonedOptions.defaultValue && clonedOptions.defaultValue.includes(this.prefix)) delete clonedOptions.defaultValue;
1286      return key;
1287    };
1288    while (match = this.nestingRegexp.exec(str)) {
1289      let formatters = [];
1290      clonedOptions = {
1291        ...options
1292      };
1293      clonedOptions = clonedOptions.replace && !isString$1(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1294      clonedOptions.applyPostProcessor = false;
1295      delete clonedOptions.defaultValue;
1296      const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf("}") + 1 : match[1].indexOf(this.formatSeparator);
1297      if (keyEndIndex !== -1) {
1298        formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
1299        match[1] = match[1].slice(0, keyEndIndex);
1300      }
1301      value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1302      if (value && match[0] === str && !isString$1(value)) return value;
1303      if (!isString$1(value)) value = makeString(value);
1304      if (!value) {
1305        this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1306        value = "";
1307      }
1308      if (formatters.length) {
1309        value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1310          ...options,
1311          interpolationkey: match[1].trim()
1312        }), value.trim());
1313      }
1314      str = str.replace(match[0], value);
1315      this.regexp.lastIndex = 0;
1316    }
1317    return str;
1318  }
1319}
1320const parseFormatStr = (formatStr) => {
1321  let formatName = formatStr.toLowerCase().trim();
1322  const formatOptions = {};
1323  if (formatStr.includes("(")) {
1324    const p = formatStr.split("(");
1325    formatName = p[0].toLowerCase().trim();
1326    const optStr = p[1].slice(0, -1);
1327    if (formatName === "currency" && !optStr.includes(":")) {
1328      if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1329    } else if (formatName === "relativetime" && !optStr.includes(":")) {
1330      if (!formatOptions.range) formatOptions.range = optStr.trim();
1331    } else {
1332      const opts = optStr.split(";");
1333      opts.forEach((opt) => {
1334        if (opt) {
1335          const [key, ...rest] = opt.split(":");
1336          const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
1337          const trimmedKey = key.trim();
1338          if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
1339          if (val === "false") formatOptions[trimmedKey] = false;
1340          if (val === "true") formatOptions[trimmedKey] = true;
1341          if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
1342        }
1343      });
1344    }
1345  }
1346  return {
1347    formatName,
1348    formatOptions
1349  };
1350};
1351const createCachedFormatter = (fn) => {
1352  const cache = {};
1353  return (v, l, o) => {
1354    let optForCache = o;
1355    if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
1356      optForCache = {
1357        ...optForCache,
1358        [o.interpolationkey]: void 0
1359      };
1360    }
1361    const key = l + JSON.stringify(optForCache);
1362    let frm = cache[key];
1363    if (!frm) {
1364      frm = fn(getCleanedCode(l), o);
1365      cache[key] = frm;
1366    }
1367    return frm(v);
1368  };
1369};
1370const createNonCachedFormatter = (fn) => (v, l, o) => fn(getCleanedCode(l), o)(v);
1371class Formatter {
1372  constructor(options = {}) {
1373    this.logger = baseLogger.create("formatter");
1374    this.options = options;
1375    this.init(options);
1376  }
1377  init(services, options = {
1378    interpolation: {}
1379  }) {
1380    this.formatSeparator = options.interpolation.formatSeparator || ",";
1381    const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
1382    this.formats = {
1383      number: cf((lng, opt) => {
1384        const formatter = new Intl.NumberFormat(lng, {
1385          ...opt
1386        });
1387        return (val) => formatter.format(val);
1388      }),
1389      currency: cf((lng, opt) => {
1390        const formatter = new Intl.NumberFormat(lng, {
1391          ...opt,
1392          style: "currency"
1393        });
1394        return (val) => formatter.format(val);
1395      }),
1396      datetime: cf((lng, opt) => {
1397        const formatter = new Intl.DateTimeFormat(lng, {
1398          ...opt
1399        });
1400        return (val) => formatter.format(val);
1401      }),
1402      relativetime: cf((lng, opt) => {
1403        const formatter = new Intl.RelativeTimeFormat(lng, {
1404          ...opt
1405        });
1406        return (val) => formatter.format(val, opt.range || "day");
1407      }),
1408      list: cf((lng, opt) => {
1409        const formatter = new Intl.ListFormat(lng, {
1410          ...opt
1411        });
1412        return (val) => formatter.format(val);
1413      })
1414    };
1415  }
1416  add(name, fc) {
1417    this.formats[name.toLowerCase().trim()] = fc;
1418  }
1419  addCached(name, fc) {
1420    this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1421  }
1422  format(value, format, lng, options = {}) {
1423    if (!format) return value;
1424    if (value == null) return value;
1425    const formats = format.split(this.formatSeparator);
1426    if (formats.length > 1 && formats[0].indexOf("(") > 1 && !formats[0].includes(")") && formats.find((f) => f.includes(")"))) {
1427      const lastIndex = formats.findIndex((f) => f.includes(")"));
1428      formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1429    }
1430    const result = formats.reduce((mem, f) => {
1431      var _a;
1432      const {
1433        formatName,
1434        formatOptions
1435      } = parseFormatStr(f);
1436      if (this.formats[formatName]) {
1437        let formatted = mem;
1438        try {
1439          const valOptions = ((_a = options == null ? void 0 : options.formatParams) == null ? void 0 : _a[options.interpolationkey]) || {};
1440          const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1441          formatted = this.formats[formatName](mem, l, {
1442            ...formatOptions,
1443            ...options,
1444            ...valOptions
1445          });
1446        } catch (error) {
1447          this.logger.warn(error);
1448        }
1449        return formatted;
1450      } else {
1451        this.logger.warn(`there was no format function for ${formatName}`);
1452      }
1453      return mem;
1454    }, value);
1455    return result;
1456  }
1457}
1458const removePending = (q, name) => {
1459  if (q.pending[name] !== void 0) {
1460    delete q.pending[name];
1461    q.pendingCount--;
1462  }
1463};
1464class Connector extends EventEmitter {
1465  constructor(backend, store, services, options = {}) {
1466    var _a, _b;
1467    super();
1468    this.backend = backend;
1469    this.store = store;
1470    this.services = services;
1471    this.languageUtils = services.languageUtils;
1472    this.options = options;
1473    this.logger = baseLogger.create("backendConnector");
1474    this.waitingReads = [];
1475    this.maxParallelReads = options.maxParallelReads || 10;
1476    this.readingCalls = 0;
1477    this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1478    this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1479    this.state = {};
1480    this.queue = [];
1481    (_b = (_a = this.backend) == null ? void 0 : _a.init) == null ? void 0 : _b.call(_a, services, options.backend, options);
1482  }
1483  queueLoad(languages, namespaces, options, callback) {
1484    const toLoad = {};
1485    const pending = {};
1486    const toLoadLanguages = {};
1487    const toLoadNamespaces = {};
1488    languages.forEach((lng) => {
1489      let hasAllNamespaces = true;
1490      namespaces.forEach((ns) => {
1491        const name = `${lng}|${ns}`;
1492        if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
1493          this.state[name] = 2;
1494        } else if (this.state[name] < 0) ;
1495        else if (this.state[name] === 1) {
1496          if (pending[name] === void 0) pending[name] = true;
1497        } else {
1498          this.state[name] = 1;
1499          hasAllNamespaces = false;
1500          if (pending[name] === void 0) pending[name] = true;
1501          if (toLoad[name] === void 0) toLoad[name] = true;
1502          if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
1503        }
1504      });
1505      if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1506    });
1507    if (Object.keys(toLoad).length || Object.keys(pending).length) {
1508      this.queue.push({
1509        pending,
1510        pendingCount: Object.keys(pending).length,
1511        loaded: {},
1512        errors: [],
1513        callback
1514      });
1515    }
1516    return {
1517      toLoad: Object.keys(toLoad),
1518      pending: Object.keys(pending),
1519      toLoadLanguages: Object.keys(toLoadLanguages),
1520      toLoadNamespaces: Object.keys(toLoadNamespaces)
1521    };
1522  }
1523  loaded(name, err, data) {
1524    const s = name.split("|");
1525    const lng = s[0];
1526    const ns = s[1];
1527    if (err) this.emit("failedLoading", lng, ns, err);
1528    if (!err && data) {
1529      this.store.addResourceBundle(lng, ns, data, void 0, void 0, {
1530        skipCopy: true
1531      });
1532    }
1533    this.state[name] = err ? -1 : 2;
1534    if (err && data) this.state[name] = 0;
1535    const loaded = {};
1536    this.queue.forEach((q) => {
1537      pushPath(q.loaded, [lng], ns);
1538      removePending(q, name);
1539      if (err) q.errors.push(err);
1540      if (q.pendingCount === 0 && !q.done) {
1541        Object.keys(q.loaded).forEach((l) => {
1542          if (!loaded[l]) loaded[l] = {};
1543          const loadedKeys = q.loaded[l];
1544          if (loadedKeys.length) {
1545            loadedKeys.forEach((n) => {
1546              if (loaded[l][n] === void 0) loaded[l][n] = true;
1547            });
1548          }
1549        });
1550        q.done = true;
1551        if (q.errors.length) {
1552          q.callback(q.errors);
1553        } else {
1554          q.callback();
1555        }
1556      }
1557    });
1558    this.emit("loaded", loaded);
1559    this.queue = this.queue.filter((q) => !q.done);
1560  }
1561  read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
1562    if (!lng.length) return callback(null, {});
1563    if (this.readingCalls >= this.maxParallelReads) {
1564      this.waitingReads.push({
1565        lng,
1566        ns,
1567        fcName,
1568        tried,
1569        wait,
1570        callback
1571      });
1572      return;
1573    }
1574    this.readingCalls++;
1575    const resolver = (err, data) => {
1576      this.readingCalls--;
1577      if (this.waitingReads.length > 0) {
1578        const next = this.waitingReads.shift();
1579        this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1580      }
1581      if (err && data && tried < this.maxRetries) {
1582        setTimeout(() => {
1583          this.read(lng, ns, fcName, tried + 1, wait * 2, callback);
1584        }, wait);
1585        return;
1586      }
1587      callback(err, data);
1588    };
1589    const fc = this.backend[fcName].bind(this.backend);
1590    if (fc.length === 2) {
1591      try {
1592        const r = fc(lng, ns);
1593        if (r && typeof r.then === "function") {
1594          r.then((data) => resolver(null, data)).catch(resolver);
1595        } else {
1596          resolver(null, r);
1597        }
1598      } catch (err) {
1599        resolver(err);
1600      }
1601      return;
1602    }
1603    return fc(lng, ns, resolver);
1604  }
1605  prepareLoading(languages, namespaces, options = {}, callback) {
1606    if (!this.backend) {
1607      this.logger.warn("No backend was added via i18next.use. Will not load resources.");
1608      return callback && callback();
1609    }
1610    if (isString$1(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1611    if (isString$1(namespaces)) namespaces = [namespaces];
1612    const toLoad = this.queueLoad(languages, namespaces, options, callback);
1613    if (!toLoad.toLoad.length) {
1614      if (!toLoad.pending.length) callback();
1615      return null;
1616    }
1617    toLoad.toLoad.forEach((name) => {
1618      this.loadOne(name);
1619    });
1620  }
1621  load(languages, namespaces, callback) {
1622    this.prepareLoading(languages, namespaces, {}, callback);
1623  }
1624  reload(languages, namespaces, callback) {
1625    this.prepareLoading(languages, namespaces, {
1626      reload: true
1627    }, callback);
1628  }
1629  loadOne(name, prefix = "") {
1630    const s = name.split("|");
1631    const lng = s[0];
1632    const ns = s[1];
1633    this.read(lng, ns, "read", void 0, void 0, (err, data) => {
1634      if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1635      if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1636      this.loaded(name, err, data);
1637    });
1638  }
1639  saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {
1640  }) {
1641    var _a, _b, _c, _d, _e;
1642    if (((_b = (_a = this.services) == null ? void 0 : _a.utils) == null ? void 0 : _b.hasLoadedNamespace) && !((_d = (_c = this.services) == null ? void 0 : _c.utils) == null ? void 0 : _d.hasLoadedNamespace(namespace))) {
1643      this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" 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!!!");
1644      return;
1645    }
1646    if (key === void 0 || key === null || key === "") return;
1647    if ((_e = this.backend) == null ? void 0 : _e.create) {
1648      const opts = {
1649        ...options,
1650        isUpdate
1651      };
1652      const fc = this.backend.create.bind(this.backend);
1653      if (fc.length < 6) {
1654        try {
1655          let r;
1656          if (fc.length === 5) {
1657            r = fc(languages, namespace, key, fallbackValue, opts);
1658          } else {
1659            r = fc(languages, namespace, key, fallbackValue);
1660          }
1661          if (r && typeof r.then === "function") {
1662            r.then((data) => clb(null, data)).catch(clb);
1663          } else {
1664            clb(null, r);
1665          }
1666        } catch (err) {
1667          clb(err);
1668        }
1669      } else {
1670        fc(languages, namespace, key, fallbackValue, clb, opts);
1671      }
1672    }
1673    if (!languages || !languages[0]) return;
1674    this.store.addResource(languages[0], namespace, key, fallbackValue);
1675  }
1676}
1677const get = () => ({
1678  debug: false,
1679  initAsync: true,
1680  ns: ["translation"],
1681  defaultNS: ["translation"],
1682  fallbackLng: ["dev"],
1683  fallbackNS: false,
1684  supportedLngs: false,
1685  nonExplicitSupportedLngs: false,
1686  load: "all",
1687  preload: false,
1688  keySeparator: ".",
1689  nsSeparator: ":",
1690  pluralSeparator: "_",
1691  contextSeparator: "_",
1692  partialBundledLanguages: false,
1693  saveMissing: false,
1694  updateMissing: false,
1695  saveMissingTo: "fallback",
1696  saveMissingPlurals: true,
1697  missingKeyHandler: false,
1698  missingInterpolationHandler: false,
1699  postProcess: false,
1700  postProcessPassResolved: false,
1701  returnNull: false,
1702  returnEmptyString: true,
1703  returnObjects: false,
1704  joinArrays: false,
1705  returnedObjectHandler: false,
1706  parseMissingKeyHandler: false,
1707  appendNamespaceToMissingKey: false,
1708  appendNamespaceToCIMode: false,
1709  overloadTranslationOptionHandler: (args) => {
1710    let ret = {};
1711    if (typeof args[1] === "object") ret = args[1];
1712    if (isString$1(args[1])) ret.defaultValue = args[1];
1713    if (isString$1(args[2])) ret.tDescription = args[2];
1714    if (typeof args[2] === "object" || typeof args[3] === "object") {
1715      const options = args[3] || args[2];
1716      Object.keys(options).forEach((key) => {
1717        ret[key] = options[key];
1718      });
1719    }
1720    return ret;
1721  },
1722  interpolation: {
1723    escapeValue: true,
1724    prefix: "{{",
1725    suffix: "}}",
1726    formatSeparator: ",",
1727    unescapePrefix: "-",
1728    nestingPrefix: "$t(",
1729    nestingSuffix: ")",
1730    nestingOptionsSeparator: ",",
1731    maxReplaces: 1e3,
1732    skipOnVariables: true
1733  },
1734  cacheInBuiltFormats: true
1735});
1736const transformOptions = (options) => {
1737  if (isString$1(options.ns)) options.ns = [options.ns];
1738  if (isString$1(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1739  if (isString$1(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1740  if (options.supportedLngs && !options.supportedLngs.includes("cimode")) {
1741    options.supportedLngs = options.supportedLngs.concat(["cimode"]);
1742  }
1743  return options;
1744};
1745const noop = () => {
1746};
1747const bindMemberFunctions = (inst) => {
1748  const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
vendor: 4,984 bytes, lines 1749-1885
1749  mems.forEach((mem) => {
1750    if (typeof inst[mem] === "function") {
1751      inst[mem] = inst[mem].bind(inst);
1752    }
1753  });
1754};
1755class I18n extends EventEmitter {
1756  constructor(options = {}, callback) {
1757    super();
1758    this.options = transformOptions(options);
1759    this.services = {};
1760    this.logger = baseLogger;
1761    this.modules = {
1762      external: []
1763    };
1764    bindMemberFunctions(this);
1765    if (callback && !this.isInitialized && !options.isClone) {
1766      if (!this.options.initAsync) {
1767        this.init(options, callback);
1768        return this;
1769      }
1770      setTimeout(() => {
1771        this.init(options, callback);
1772      }, 0);
1773    }
1774  }
1775  init(options = {}, callback) {
1776    this.isInitializing = true;
1777    if (typeof options === "function") {
1778      callback = options;
1779      options = {};
1780    }
1781    if (options.defaultNS == null && options.ns) {
1782      if (isString$1(options.ns)) {
1783        options.defaultNS = options.ns;
1784      } else if (!options.ns.includes("translation")) {
1785        options.defaultNS = options.ns[0];
1786      }
1787    }
1788    const defOpts = get();
1789    this.options = {
1790      ...defOpts,
1791      ...this.options,
1792      ...transformOptions(options)
1793    };
1794    this.options.interpolation = {
1795      ...defOpts.interpolation,
1796      ...this.options.interpolation
1797    };
1798    if (options.keySeparator !== void 0) {
1799      this.options.userDefinedKeySeparator = options.keySeparator;
1800    }
1801    if (options.nsSeparator !== void 0) {
1802      this.options.userDefinedNsSeparator = options.nsSeparator;
1803    }
1804    if (typeof this.options.overloadTranslationOptionHandler !== "function") {
1805      this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
1806    }
1807    const createClassOnDemand = (ClassOrObject) => {
1808      if (!ClassOrObject) return null;
1809      if (typeof ClassOrObject === "function") return new ClassOrObject();
1810      return ClassOrObject;
1811    };
1812    if (!this.options.isClone) {
1813      if (this.modules.logger) {
1814        baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1815      } else {
1816        baseLogger.init(null, this.options);
1817      }
1818      let formatter;
1819      if (this.modules.formatter) {
1820        formatter = this.modules.formatter;
1821      } else {
1822        formatter = Formatter;
1823      }
1824      const lu = new LanguageUtil(this.options);
1825      this.store = new ResourceStore(this.options.resources, this.options);
1826      const s = this.services;
1827      s.logger = baseLogger;
1828      s.resourceStore = this.store;
1829      s.languageUtils = lu;
1830      s.pluralResolver = new PluralResolver(lu, {
1831        prepend: this.options.pluralSeparator
1832      });
1833      if (formatter) {
1834        s.formatter = createClassOnDemand(formatter);
1835        if (s.formatter.init) s.formatter.init(s, this.options);
1836        this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1837      }
1838      s.interpolator = new Interpolator(this.options);
1839      s.utils = {
1840        hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1841      };
1842      s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1843      s.backendConnector.on("*", (event, ...args) => {
1844        this.emit(event, ...args);
1845      });
1846      if (this.modules.languageDetector) {
1847        s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1848        if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1849      }
1850      if (this.modules.i18nFormat) {
1851        s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1852        if (s.i18nFormat.init) s.i18nFormat.init(this);
1853      }
1854      this.translator = new Translator(this.services, this.options);
1855      this.translator.on("*", (event, ...args) => {
1856        this.emit(event, ...args);
1857      });
1858      this.modules.external.forEach((m) => {
1859        if (m.init) m.init(this);
1860      });
1861    }
1862    this.format = this.options.interpolation.format;
1863    if (!callback) callback = noop;
1864    if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1865      const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1866      if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
1867    }
1868    if (!this.services.languageDetector && !this.options.lng) {
1869      this.logger.warn("init: no languageDetector is used and no lng is defined");
1870    }
1871    const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
1872    storeApi.forEach((fcName) => {
1873      this[fcName] = (...args) => this.store[fcName](...args);
1874    });
1875    const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
1876    storeApiChained.forEach((fcName) => {
1877      this[fcName] = (...args) => {
1878        this.store[fcName](...args);
1879        return this;
1880      };
1881    });
1882    const deferred = defer();
1883    const load = () => {
1884      const finish = (err, t) => {
1885        this.isInitializing = false;
1886        if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
1887        this.isInitialized = true;
1888        if (!this.options.isClone) this.logger.log("initialized", this.options);
1889        this.emit("initialized", this.options);
1890        deferred.resolve(t);
1891        callback(err, t);
1892      };
1893      if ((this.languages || this.isLanguageChangingTo) && !this.isInitialized) return finish(null, this.t.bind(this));
1894      this.changeLanguage(this.options.lng, finish);
1895    };
1896    if (this.options.resources || !this.options.initAsync) {
1897      load();
1898    } else {
1899      setTimeout(load, 0);
1900    }
1901    return deferred;
1902  }
1903  loadResources(language, callback = noop) {
1904    var _a, _b;
1905    let usedCallback = callback;
1906    const usedLng = isString$1(language) ? language : this.language;
1907    if (typeof language === "function") usedCallback = language;
1908    if (!this.options.resources || this.options.partialBundledLanguages) {
1909      if ((usedLng == null ? void 0 : usedLng.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
1910      const toLoad = [];
1911      const append = (lng) => {
1912        if (!lng) return;
1913        if (lng === "cimode") return;
1914        const lngs = this.services.languageUtils.toResolveHierarchy(lng);
1915        lngs.forEach((l) => {
1916          if (l === "cimode") return;
1917          if (!toLoad.includes(l)) toLoad.push(l);
1918        });
1919      };
1920      if (!usedLng) {
1921        const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1922        fallbacks.forEach((l) => append(l));
1923      } else {
1924        append(usedLng);
1925      }
1926      (_b = (_a = this.options.preload) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (l) => append(l));
1927      this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
1928        if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
1929        usedCallback(e);
1930      });
1931    } else {
1932      usedCallback(null);
1933    }
1934  }
1935  reloadResources(lngs, ns, callback) {
1936    const deferred = defer();
1937    if (typeof lngs === "function") {
1938      callback = lngs;
1939      lngs = void 0;
1940    }
1941    if (typeof ns === "function") {
1942      callback = ns;
1943      ns = void 0;
1944    }
1945    if (!lngs) lngs = this.languages;
1946    if (!ns) ns = this.options.ns;
1947    if (!callback) callback = noop;
1948    this.services.backendConnector.reload(lngs, ns, (err) => {
1949      deferred.resolve();
1950      callback(err);
1951    });
1952    return deferred;
1953  }
1954  use(module) {
1955    if (!module) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1956    if (!module.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1957    if (module.type === "backend") {
1958      this.modules.backend = module;
1959    }
1960    if (module.type === "logger" || module.log && module.warn && module.error) {
1961      this.modules.logger = module;
1962    }
1963    if (module.type === "languageDetector") {
1964      this.modules.languageDetector = module;
1965    }
1966    if (module.type === "i18nFormat") {
1967      this.modules.i18nFormat = module;
1968    }
1969    if (module.type === "postProcessor") {
1970      postProcessor.addPostProcessor(module);
1971    }
1972    if (module.type === "formatter") {
1973      this.modules.formatter = module;
1974    }
1975    if (module.type === "3rdParty") {
1976      this.modules.external.push(module);
1977    }
1978    return this;
1979  }
1980  setResolvedLanguage(l) {
1981    if (!l || !this.languages) return;
1982    if (["cimode", "dev"].includes(l)) return;
1983    for (let li = 0; li < this.languages.length; li++) {
1984      const lngInLngs = this.languages[li];
1985      if (["cimode", "dev"].includes(lngInLngs)) continue;
1986      if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
1987        this.resolvedLanguage = lngInLngs;
1988        break;
1989      }
1990    }
1991    if (!this.resolvedLanguage && !this.languages.includes(l) && this.store.hasLanguageSomeTranslations(l)) {
1992      this.resolvedLanguage = l;
1993      this.languages.unshift(l);
1994    }
1995  }
1996  changeLanguage(lng, callback) {
1997    this.isLanguageChangingTo = lng;
1998    const deferred = defer();
vendor: 4,131 bytes, lines 1999-2112
1999    this.emit("languageChanging", lng);
2000    const setLngProps = (l) => {
2001      this.language = l;
2002      this.languages = this.services.languageUtils.toResolveHierarchy(l);
2003      this.resolvedLanguage = void 0;
2004      this.setResolvedLanguage(l);
2005    };
2006    const done = (err, l) => {
2007      if (l) {
2008        if (this.isLanguageChangingTo === lng) {
2009          setLngProps(l);
2010          this.translator.changeLanguage(l);
2011          this.isLanguageChangingTo = void 0;
2012          this.emit("languageChanged", l);
2013          this.logger.log("languageChanged", l);
2014        }
2015      } else {
2016        this.isLanguageChangingTo = void 0;
2017      }
2018      deferred.resolve((...args) => this.t(...args));
2019      if (callback) callback(err, (...args) => this.t(...args));
2020    };
2021    const setLng = (lngs) => {
2022      var _a, _b;
2023      if (!lng && !lngs && this.services.languageDetector) lngs = [];
2024      const fl = isString$1(lngs) ? lngs : lngs && lngs[0];
2025      const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString$1(lngs) ? [lngs] : lngs);
2026      if (l) {
2027        if (!this.language) {
2028          setLngProps(l);
2029        }
2030        if (!this.translator.language) this.translator.changeLanguage(l);
2031        (_b = (_a = this.services.languageDetector) == null ? void 0 : _a.cacheUserLanguage) == null ? void 0 : _b.call(_a, l);
2032      }
2033      this.loadResources(l, (err) => {
2034        done(err, l);
2035      });
2036    };
2037    if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2038      setLng(this.services.languageDetector.detect());
2039    } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2040      if (this.services.languageDetector.detect.length === 0) {
2041        this.services.languageDetector.detect().then(setLng);
2042      } else {
2043        this.services.languageDetector.detect(setLng);
2044      }
2045    } else {
2046      setLng(lng);
2047    }
2048    return deferred;
2049  }
2050  getFixedT(lng, ns, keyPrefix) {
2051    const fixedT = (key, opts, ...rest) => {
2052      let o;
2053      if (typeof opts !== "object") {
2054        o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2055      } else {
2056        o = {
2057          ...opts
2058        };
2059      }
2060      o.lng = o.lng || fixedT.lng;
2061      o.lngs = o.lngs || fixedT.lngs;
2062      o.ns = o.ns || fixedT.ns;
2063      if (o.keyPrefix !== "") o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
2064      const selectorOpts = {
2065        ...this.options,
2066        ...o
2067      };
2068      if (typeof o.keyPrefix === "function") o.keyPrefix = keysFromSelector(o.keyPrefix, selectorOpts);
2069      const keySeparator = this.options.keySeparator || ".";
2070      let resultKey;
2071      if (o.keyPrefix && Array.isArray(key)) {
2072        resultKey = key.map((k) => {
2073          if (typeof k === "function") k = keysFromSelector(k, selectorOpts);
2074          return `${o.keyPrefix}${keySeparator}${k}`;
2075        });
2076      } else {
2077        if (typeof key === "function") key = keysFromSelector(key, selectorOpts);
2078        resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
2079      }
2080      return this.t(resultKey, o);
2081    };
2082    if (isString$1(lng)) {
2083      fixedT.lng = lng;
2084    } else {
2085      fixedT.lngs = lng;
2086    }
2087    fixedT.ns = ns;
2088    fixedT.keyPrefix = keyPrefix;
2089    return fixedT;
2090  }
2091  t(...args) {
2092    var _a;
2093    return (_a = this.translator) == null ? void 0 : _a.translate(...args);
2094  }
2095  exists(...args) {
2096    var _a;
2097    return (_a = this.translator) == null ? void 0 : _a.exists(...args);
2098  }
2099  setDefaultNamespace(ns) {
2100    this.options.defaultNS = ns;
2101  }
2102  hasLoadedNamespace(ns, options = {}) {
2103    if (!this.isInitialized) {
2104      this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
2105      return false;
2106    }
2107    if (!this.languages || !this.languages.length) {
2108      this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
2109      return false;
2110    }
2111    const lng = options.lng || this.resolvedLanguage || this.languages[0];
2112    const fallbackLng = this.options ? this.options.fallbackLng : false;
vendor: 7,797 bytes, lines 2113-2327
2113    const lastLng = this.languages[this.languages.length - 1];
2114    if (lng.toLowerCase() === "cimode") return true;
2115    const loadNotPending = (l, n) => {
2116      const loadState = this.services.backendConnector.state[`${l}|${n}`];
2117      return loadState === -1 || loadState === 0 || loadState === 2;
2118    };
2119    if (options.precheck) {
2120      const preResult = options.precheck(this, loadNotPending);
2121      if (preResult !== void 0) return preResult;
2122    }
2123    if (this.hasResourceBundle(lng, ns)) return true;
2124    if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2125    if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2126    return false;
2127  }
2128  loadNamespaces(ns, callback) {
2129    const deferred = defer();
2130    if (!this.options.ns) {
2131      if (callback) callback();
2132      return Promise.resolve();
2133    }
2134    if (isString$1(ns)) ns = [ns];
2135    ns.forEach((n) => {
2136      if (!this.options.ns.includes(n)) this.options.ns.push(n);
2137    });
2138    this.loadResources((err) => {
2139      deferred.resolve();
2140      if (callback) callback(err);
2141    });
2142    return deferred;
2143  }
2144  loadLanguages(lngs, callback) {
2145    const deferred = defer();
2146    if (isString$1(lngs)) lngs = [lngs];
2147    const preloaded = this.options.preload || [];
2148    const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
2149    if (!newLngs.length) {
2150      if (callback) callback();
2151      return Promise.resolve();
2152    }
2153    this.options.preload = preloaded.concat(newLngs);
2154    this.loadResources((err) => {
2155      deferred.resolve();
2156      if (callback) callback(err);
2157    });
2158    return deferred;
2159  }
2160  dir(lng) {
2161    var _a, _b;
2162    if (!lng) lng = this.resolvedLanguage || (((_a = this.languages) == null ? void 0 : _a.length) > 0 ? this.languages[0] : this.language);
2163    if (!lng) return "rtl";
2164    try {
2165      const l = new Intl.Locale(lng);
2166      if (l && l.getTextInfo) {
2167        const ti = l.getTextInfo();
2168        if (ti && ti.direction) return ti.direction;
2169      }
2170    } catch (e) {
2171    }
2172    const rtlLngs = ["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"];
2173    const languageUtils = ((_b = this.services) == null ? void 0 : _b.languageUtils) || new LanguageUtil(get());
2174    if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
2175    return rtlLngs.includes(languageUtils.getLanguagePartFromCode(lng)) || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
2176  }
2177  static createInstance(options = {}, callback) {
2178    const instance2 = new I18n(options, callback);
2179    instance2.createInstance = I18n.createInstance;
2180    return instance2;
2181  }
2182  cloneInstance(options = {}, callback = noop) {
2183    const forkResourceStore = options.forkResourceStore;
2184    if (forkResourceStore) delete options.forkResourceStore;
2185    const mergedOptions = {
2186      ...this.options,
2187      ...options,
2188      ...{
2189        isClone: true
2190      }
2191    };
2192    const clone = new I18n(mergedOptions);
2193    if (options.debug !== void 0 || options.prefix !== void 0) {
2194      clone.logger = clone.logger.clone(options);
2195    }
2196    const membersToCopy = ["store", "services", "language"];
2197    membersToCopy.forEach((m) => {
2198      clone[m] = this[m];
2199    });
2200    clone.services = {
2201      ...this.services
2202    };
2203    clone.services.utils = {
2204      hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2205    };
2206    if (forkResourceStore) {
2207      const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
2208        prev[l] = {
2209          ...this.store.data[l]
2210        };
2211        prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
2212          acc[n] = {
2213            ...prev[l][n]
2214          };
2215          return acc;
2216        }, prev[l]);
2217        return prev;
2218      }, {});
2219      clone.store = new ResourceStore(clonedData, mergedOptions);
2220      clone.services.resourceStore = clone.store;
2221    }
2222    if (options.interpolation) {
2223      const defOpts = get();
2224      const mergedInterpolation = {
2225        ...defOpts.interpolation,
2226        ...this.options.interpolation,
2227        ...options.interpolation
2228      };
2229      const mergedForInterpolator = {
2230        ...mergedOptions,
2231        interpolation: mergedInterpolation
2232      };
2233      clone.services.interpolator = new Interpolator(mergedForInterpolator);
2234    }
2235    clone.translator = new Translator(clone.services, mergedOptions);
2236    clone.translator.on("*", (event, ...args) => {
2237      clone.emit(event, ...args);
2238    });
2239    clone.init(mergedOptions, callback);
2240    clone.translator.options = mergedOptions;
2241    clone.translator.backendConnector.services.utils = {
2242      hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2243    };
2244    return clone;
2245  }
2246  toJSON() {
2247    return {
2248      options: this.options,
2249      store: this.store,
2250      language: this.language,
2251      languages: this.languages,
2252      resolvedLanguage: this.resolvedLanguage
2253    };
2254  }
2255}
2256const instance = I18n.createInstance();
2257instance.createInstance;
2258instance.dir;
2259instance.init;
2260instance.loadResources;
2261instance.reloadResources;
2262instance.use;
2263instance.changeLanguage;
2264instance.getFixedT;
2265instance.t;
2266instance.exists;
2267instance.setDefaultNamespace;
2268instance.hasLoadedNamespace;
2269instance.loadNamespaces;
2270instance.loadLanguages;
2271const warn = (i18n, code, msg, rest) => {
2272  var _a, _b, _c, _d;
2273  const args = [msg, {
2274    code,
2275    ...rest || {}
2276  }];
2277  if ((_b = (_a = i18n == null ? void 0 : i18n.services) == null ? void 0 : _a.logger) == null ? void 0 : _b.forward) {
2278    return i18n.services.logger.forward(args, "warn", "react-i18next::", true);
2279  }
2280  if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
2281  if ((_d = (_c = i18n == null ? void 0 : i18n.services) == null ? void 0 : _c.logger) == null ? void 0 : _d.warn) {
2282    i18n.services.logger.warn(...args);
2283  } else if (console == null ? void 0 : console.warn) {
2284    console.warn(...args);
2285  }
2286};
2287const alreadyWarned = {};
2288const warnOnce = (i18n, code, msg, rest) => {
2289  if (isString(msg) && alreadyWarned[msg]) return;
2290  if (isString(msg)) alreadyWarned[msg] = /* @__PURE__ */ new Date();
2291  warn(i18n, code, msg, rest);
2292};
2293const loadedClb = (i18n, cb) => () => {
2294  if (i18n.isInitialized) {
2295    cb();
2296  } else {
2297    const initialized = () => {
2298      setTimeout(() => {
2299        i18n.off("initialized", initialized);
2300      }, 0);
2301      cb();
2302    };
2303    i18n.on("initialized", initialized);
2304  }
2305};
2306const loadNamespaces = (i18n, ns, cb) => {
2307  i18n.loadNamespaces(ns, loadedClb(i18n, cb));
2308};
2309const loadLanguages = (i18n, lng, ns, cb) => {
2310  if (isString(ns)) ns = [ns];
2311  if (i18n.options.preload && i18n.options.preload.indexOf(lng) > -1) return loadNamespaces(i18n, ns, cb);
2312  ns.forEach((n) => {
2313    if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
2314  });
2315  i18n.loadLanguages(lng, loadedClb(i18n, cb));
2316};
2317const hasLoadedNamespace = (ns, i18n, options = {}) => {
2318  if (!i18n.languages || !i18n.languages.length) {
2319    warnOnce(i18n, "NO_LANGUAGES", "i18n.languages were undefined or empty", {
2320      languages: i18n.languages
2321    });
2322    return true;
2323  }
2324  return i18n.hasLoadedNamespace(ns, {
2325    lng: options.lng,
2326    precheck: (i18nInstance2, loadNotPending) => {
2327      if (options.bindI18n && options.bindI18n.indexOf("languageChanging") > -1 && i18nInstance2.services.backendConnector.backend && i18nInstance2.isLanguageChangingTo && !loadNotPending(i18nInstance2.isLanguageChangingTo, ns)) return false;
2328    }
2329  });
2330};
2331const isString = (obj) => typeof obj === "string";
2332const isObject = (obj) => typeof obj === "object" && obj !== null;
2333const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
2334const htmlEntities = {
2335  "&amp;": "&",
2336  "&#38;": "&",
2337  "&lt;": "<",
2338  "&#60;": "<",
2339  "&gt;": ">",
2340  "&#62;": ">",
2341  "&apos;": "'",
2342  "&#39;": "'",
2343  "&quot;": '"',
2344  "&#34;": '"',
2345  "&nbsp;": " ",
2346  "&#160;": " ",
2347  "&copy;": "©",
2348  "&#169;": "©",
2349  "&reg;": "®",
2350  "&#174;": "®",
2351  "&hellip;": "…",
2352  "&#8230;": "…",
2353  "&#x2F;": "/",
2354  "&#47;": "/"
2355};
2356const unescapeHtmlEntity = (m) => htmlEntities[m];
2357const unescape = (text) => text.replace(matchHtmlEntity, unescapeHtmlEntity);
2358let defaultOptions = {
2359  bindI18n: "languageChanged",
2360  bindI18nStore: "",
2361  transEmptyNodeValue: "",
2362  transSupportBasicHtmlNodes: true,
2363  transWrapTextNodes: "",
2364  transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p"],
2365  useSuspense: true,
2366  unescape,
2367  transDefaultProps: void 0
2368};
2369const setDefaults = (options = {}) => {
2370  defaultOptions = {
2371    ...defaultOptions,
2372    ...options
2373  };
2374};
2375const getDefaults$2 = () => defaultOptions;
2376let i18nInstance;
2377const setI18n = (instance2) => {
2378  i18nInstance = instance2;
2379};
2380const getI18n = () => i18nInstance;
2381const initReactI18next = {
2382  type: "3rdParty",
2383  init(instance2) {
2384    setDefaults(instance2.options.react);
2385    setI18n(instance2);
2386  }
2387};
2388const I18nContext = reactExports.createContext();
2389class ReportNamespaces {
2390  constructor() {
2391    this.usedNamespaces = {};
2392  }
2393  addUsedNamespaces(namespaces) {
2394    namespaces.forEach((ns) => {
2395      if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
2396    });
2397  }
2398  getUsedNamespaces() {
2399    return Object.keys(this.usedNamespaces);
2400  }
2401}
2402const notReadyT = (k, optsOrDefaultValue) => {
2403  if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
2404  if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
2405  if (typeof k === "function") return "";
2406  if (Array.isArray(k)) {
2407    const last = k[k.length - 1];
2408    return typeof last === "function" ? "" : last;
2409  }
2410  return k;
2411};
2412const notReadySnapshot = {
2413  t: notReadyT,
2414  ready: false
2415};
2416const dummySubscribe = () => () => {
2417};
2418const useTranslation = (ns, props = {}) => {
2419  var _a, _b, _c;
2420  const {
2421    i18n: i18nFromProps
2422  } = props;
2423  const {
2424    i18n: i18nFromContext,
2425    defaultNS: defaultNSFromContext
2426  } = reactExports.useContext(I18nContext) || {};
2427  const i18n = i18nFromProps || i18nFromContext || getI18n();
2428  if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
2429  if (!i18n) {
2430    warnOnce(i18n, "NO_I18NEXT_INSTANCE", "useTranslation: You will need to pass in an i18next instance by using initReactI18next");
2431  }
2432  const i18nOptions = reactExports.useMemo(() => {
2433    var _a2;
2434    return {
2435      ...getDefaults$2(),
2436      ...(_a2 = i18n == null ? void 0 : i18n.options) == null ? void 0 : _a2.react,
2437      ...props
2438    };
2439  }, [i18n, props]);
2440  const {
2441    useSuspense,
2442    keyPrefix
2443  } = i18nOptions;
2444  const nsOrContext = ns || defaultNSFromContext || ((_a = i18n == null ? void 0 : i18n.options) == null ? void 0 : _a.defaultNS);
2445  const unstableNamespaces = isString(nsOrContext) ? [nsOrContext] : nsOrContext || ["translation"];
2446  const namespaces = reactExports.useMemo(() => unstableNamespaces, unstableNamespaces);
2447  (_c = (_b = i18n == null ? void 0 : i18n.reportNamespaces) == null ? void 0 : _b.addUsedNamespaces) == null ? void 0 : _c.call(_b, namespaces);
2448  const revisionRef = reactExports.useRef(0);
2449  const subscribe = reactExports.useCallback((callback) => {
2450    if (!i18n) return dummySubscribe;
2451    const {
2452      bindI18n,
2453      bindI18nStore
2454    } = i18nOptions;
2455    const wrappedCallback = () => {
2456      revisionRef.current += 1;
2457      callback();
2458    };
2459    if (bindI18n) i18n.on(bindI18n, wrappedCallback);
2460    if (bindI18nStore) i18n.store.on(bindI18nStore, wrappedCallback);
2461    return () => {
2462      if (bindI18n) bindI18n.split(" ").forEach((e) => i18n.off(e, wrappedCallback));
2463      if (bindI18nStore) bindI18nStore.split(" ").forEach((e) => i18n.store.off(e, wrappedCallback));
2464    };
2465  }, [i18n, i18nOptions]);
2466  const snapshotRef = reactExports.useRef();
2467  const getSnapshot = reactExports.useCallback(() => {
2468    if (!i18n) {
2469      return notReadySnapshot;
2470    }
2471    const calculatedReady = !!(i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every((n) => hasLoadedNamespace(n, i18n, i18nOptions));
2472    const currentLng = props.lng || i18n.language;
2473    const currentRevision = revisionRef.current;
2474    const lastSnapshot = snapshotRef.current;
2475    if (lastSnapshot && lastSnapshot.ready === calculatedReady && lastSnapshot.lng === currentLng && lastSnapshot.keyPrefix === keyPrefix && lastSnapshot.revision === currentRevision) {
2476      return lastSnapshot;
2477    }
2478    const calculatedT = i18n.getFixedT(currentLng, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix);
2479    const newSnapshot = {
2480      t: calculatedT,
2481      ready: calculatedReady,
2482      lng: currentLng,
2483      keyPrefix,
2484      revision: currentRevision
2485    };
2486    snapshotRef.current = newSnapshot;
2487    return newSnapshot;
2488  }, [i18n, namespaces, keyPrefix, i18nOptions, props.lng]);
2489  const [loadCount, setLoadCount] = reactExports.useState(0);
2490  const {
2491    t,
2492    ready
2493  } = shimExports.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
2494  reactExports.useEffect(() => {
2495    if (i18n && !ready && !useSuspense) {
2496      const onLoaded = () => setLoadCount((c) => c + 1);
2497      if (props.lng) {
2498        loadLanguages(i18n, props.lng, namespaces, onLoaded);
2499      } else {
2500        loadNamespaces(i18n, namespaces, onLoaded);
2501      }
2502    }
2503  }, [i18n, props.lng, namespaces, ready, useSuspense, loadCount]);
2504  const finalI18n = i18n || {};
2505  const wrapperRef = reactExports.useRef(null);
2506  const wrapperLangRef = reactExports.useRef();
2507  const createI18nWrapper = (original) => {
2508    const descriptors = Object.getOwnPropertyDescriptors(original);
2509    if (descriptors.__original) delete descriptors.__original;
2510    const wrapper = Object.create(Object.getPrototypeOf(original), descriptors);
2511    if (!Object.prototype.hasOwnProperty.call(wrapper, "__original")) {
2512      try {
2513        Object.defineProperty(wrapper, "__original", {
2514          value: original,
2515          writable: false,
2516          enumerable: false,
2517          configurable: false
2518        });
2519      } catch (_) {
2520      }
2521    }
2522    return wrapper;
2523  };
2524  const ret = reactExports.useMemo(() => {
2525    const original = finalI18n;
2526    const lang = original == null ? void 0 : original.language;
2527    let i18nWrapper = original;
2528    if (original) {
2529      if (wrapperRef.current && wrapperRef.current.__original === original) {
2530        if (wrapperLangRef.current !== lang) {
2531          i18nWrapper = createI18nWrapper(original);
2532          wrapperRef.current = i18nWrapper;
2533          wrapperLangRef.current = lang;
2534        } else {
2535          i18nWrapper = wrapperRef.current;
2536        }
2537      } else {
2538        i18nWrapper = createI18nWrapper(original);
2539        wrapperRef.current = i18nWrapper;
2540        wrapperLangRef.current = lang;
2541      }
2542    }
2543    const effectiveT = !ready && !useSuspense ? (...args) => {
2544      warnOnce(i18n, "USE_T_BEFORE_READY", "useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.");
2545      return t(...args);
2546    } : t;
2547    const arr = [effectiveT, i18nWrapper, ready];
2548    arr.t = effectiveT;
2549    arr.i18n = i18nWrapper;
2550    arr.ready = ready;
2551    return arr;
2552  }, [t, finalI18n, ready, finalI18n.resolvedLanguage, finalI18n.language, finalI18n.languages]);
2553  if (i18n && useSuspense && !ready) {
2554    throw new Promise((resolve) => {
2555      const onLoaded = () => resolve();
2556      if (props.lng) {
2557        loadLanguages(i18n, props.lng, namespaces, onLoaded);
2558      } else {
2559        loadNamespaces(i18n, namespaces, onLoaded);
2560      }
2561    });
2562  }
2563  return ret;
2564};
2565const {
2566  slice,
2567  forEach
2568} = [];
2569function defaults(obj) {
2570  forEach.call(slice.call(arguments, 1), (source) => {
2571    if (source) {
2572      for (const prop in source) {
2573        if (obj[prop] === void 0) obj[prop] = source[prop];
2574      }
2575    }
2576  });
2577  return obj;
2578}
2579function hasXSS(input) {
2580  if (typeof input !== "string") return false;
2581  const xssPatterns = [/<\s*script.*?>/i, /<\s*\/\s*script\s*>/i, /<\s*img.*?on\w+\s*=/i, /<\s*\w+\s*on\w+\s*=.*?>/i, /javascript\s*:/i, /vbscript\s*:/i, /expression\s*\(/i, /eval\s*\(/i, /alert\s*\(/i, /document\.cookie/i, /document\.write\s*\(/i, /window\.location/i, /innerHTML/i];
2582  return xssPatterns.some((pattern) => pattern.test(input));
2583}
2584const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
2585const serializeCookie = function(name, val) {
2586  let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
2587    path: "/"
2588  };
2589  const opt = options;
2590  const value = encodeURIComponent(val);
2591  let str = `${name}=${value}`;
2592  if (opt.maxAge > 0) {
2593    const maxAge = opt.maxAge - 0;
2594    if (Number.isNaN(maxAge)) throw new Error("maxAge should be a Number");
2595    str += `; Max-Age=${Math.floor(maxAge)}`;
2596  }
2597  if (opt.domain) {
2598    if (!fieldContentRegExp.test(opt.domain)) {
vendor: 1,162 bytes, lines 2599-2640
2599      throw new TypeError("option domain is invalid");
2600    }
2601    str += `; Domain=${opt.domain}`;
2602  }
2603  if (opt.path) {
2604    if (!fieldContentRegExp.test(opt.path)) {
2605      throw new TypeError("option path is invalid");
2606    }
2607    str += `; Path=${opt.path}`;
2608  }
2609  if (opt.expires) {
2610    if (typeof opt.expires.toUTCString !== "function") {
2611      throw new TypeError("option expires is invalid");
2612    }
2613    str += `; Expires=${opt.expires.toUTCString()}`;
2614  }
2615  if (opt.httpOnly) str += "; HttpOnly";
2616  if (opt.secure) str += "; Secure";
2617  if (opt.sameSite) {
2618    const sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
2619    switch (sameSite) {
2620      case true:
2621        str += "; SameSite=Strict";
2622        break;
2623      case "lax":
2624        str += "; SameSite=Lax";
2625        break;
2626      case "strict":
2627        str += "; SameSite=Strict";
2628        break;
2629      case "none":
2630        str += "; SameSite=None";
2631        break;
2632      default:
2633        throw new TypeError("option sameSite is invalid");
2634    }
2635  }
2636  if (opt.partitioned) str += "; Partitioned";
2637  return str;
2638};
2639const cookie = {
2640  create(name, value, minutes, domain) {
2641    let cookieOptions = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
2642      path: "/",
2643      sameSite: "strict"
2644    };
2645    if (minutes) {
2646      cookieOptions.expires = /* @__PURE__ */ new Date();
2647      cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1e3);
2648    }
2649    if (domain) cookieOptions.domain = domain;
2650    document.cookie = serializeCookie(name, value, cookieOptions);
2651  },
2652  read(name) {
2653    const nameEQ = `${name}=`;
2654    const ca = document.cookie.split(";");
2655    for (let i = 0; i < ca.length; i++) {
2656      let c = ca[i];
2657      while (c.charAt(0) === " ") c = c.substring(1, c.length);
2658      if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
2659    }
2660    return null;
2661  },
2662  remove(name, domain) {
2663    this.create(name, "", -1, domain);
2664  }
2665};
2666var cookie$1 = {
2667  name: "cookie",
2668  // Deconstruct the options object and extract the lookupCookie property
2669  lookup(_ref) {
2670    let {
2671      lookupCookie
2672    } = _ref;
2673    if (lookupCookie && typeof document !== "undefined") {
2674      return cookie.read(lookupCookie) || void 0;
2675    }
2676    return void 0;
2677  },
2678  // Deconstruct the options object and extract the lookupCookie, cookieMinutes, cookieDomain, and cookieOptions properties
2679  cacheUserLanguage(lng, _ref2) {
2680    let {
2681      lookupCookie,
2682      cookieMinutes,
2683      cookieDomain,
2684      cookieOptions
2685    } = _ref2;
2686    if (lookupCookie && typeof document !== "undefined") {
2687      cookie.create(lookupCookie, lng, cookieMinutes, cookieDomain, cookieOptions);
2688    }
2689  }
2690};
2691var querystring = {
2692  name: "querystring",
2693  // Deconstruct the options object and extract the lookupQuerystring property
2694  lookup(_ref) {
2695    var _a;
2696    let {
2697      lookupQuerystring
2698    } = _ref;
2699    let found;
2700    if (typeof window !== "undefined") {
2701      let {
2702        search
2703      } = window.location;
2704      if (!window.location.search && ((_a = window.location.hash) == null ? void 0 : _a.indexOf("?")) > -1) {
2705        search = window.location.hash.substring(window.location.hash.indexOf("?"));
2706      }
2707      const query = search.substring(1);
2708      const params = query.split("&");
2709      for (let i = 0; i < params.length; i++) {
2710        const pos = params[i].indexOf("=");
2711        if (pos > 0) {
2712          const key = params[i].substring(0, pos);
2713          if (key === lookupQuerystring) {
2714            found = params[i].substring(pos + 1);
2715          }
2716        }
2717      }
2718    }
2719    return found;
2720  }
2721};
2722var hash = {
2723  name: "hash",
2724  // Deconstruct the options object and extract the lookupHash property and the lookupFromHashIndex property
2725  lookup(_ref) {
2726    var _a;
2727    let {
2728      lookupHash,
2729      lookupFromHashIndex
2730    } = _ref;
2731    let found;
2732    if (typeof window !== "undefined") {
2733      const {
2734        hash: hash2
2735      } = window.location;
2736      if (hash2 && hash2.length > 2) {
2737        const query = hash2.substring(1);
2738        if (lookupHash) {
2739          const params = query.split("&");
2740          for (let i = 0; i < params.length; i++) {
2741            const pos = params[i].indexOf("=");
2742            if (pos > 0) {
2743              const key = params[i].substring(0, pos);
2744              if (key === lookupHash) {
2745                found = params[i].substring(pos + 1);
2746              }
2747            }
2748          }
2749        }
2750        if (found) return found;
2751        if (!found && lookupFromHashIndex > -1) {
2752          const language = hash2.match(/\/([a-zA-Z-]*)/g);
2753          if (!Array.isArray(language)) return void 0;
2754          const index = typeof lookupFromHashIndex === "number" ? lookupFromHashIndex : 0;
2755          return (_a = language[index]) == null ? void 0 : _a.replace("/", "");
2756        }
2757      }
2758    }
2759    return found;
2760  }
2761};
2762let hasLocalStorageSupport = null;
2763const localStorageAvailable = () => {
2764  if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
2765  try {
2766    hasLocalStorageSupport = typeof window !== "undefined" && window.localStorage !== null;
2767    if (!hasLocalStorageSupport) {
2768      return false;
2769    }
2770    const testKey = "i18next.translate.boo";
2771    window.localStorage.setItem(testKey, "foo");
2772    window.localStorage.removeItem(testKey);
2773  } catch (e) {
2774    hasLocalStorageSupport = false;
2775  }
2776  return hasLocalStorageSupport;
2777};
2778var localStorage = {
2779  name: "localStorage",
2780  // Deconstruct the options object and extract the lookupLocalStorage property
2781  lookup(_ref) {
2782    let {
2783      lookupLocalStorage
2784    } = _ref;
2785    if (lookupLocalStorage && localStorageAvailable()) {
2786      return window.localStorage.getItem(lookupLocalStorage) || void 0;
2787    }
2788    return void 0;
2789  },
2790  // Deconstruct the options object and extract the lookupLocalStorage property
2791  cacheUserLanguage(lng, _ref2) {
2792    let {
2793      lookupLocalStorage
2794    } = _ref2;
2795    if (lookupLocalStorage && localStorageAvailable()) {
2796      window.localStorage.setItem(lookupLocalStorage, lng);
2797    }
2798  }
2799};
2800let hasSessionStorageSupport = null;
2801const sessionStorageAvailable = () => {
2802  if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
2803  try {
2804    hasSessionStorageSupport = typeof window !== "undefined" && window.sessionStorage !== null;
2805    if (!hasSessionStorageSupport) {
2806      return false;
2807    }
2808    const testKey = "i18next.translate.boo";
2809    window.sessionStorage.setItem(testKey, "foo");
2810    window.sessionStorage.removeItem(testKey);
2811  } catch (e) {
2812    hasSessionStorageSupport = false;
2813  }
2814  return hasSessionStorageSupport;
2815};
2816var sessionStorage = {
2817  name: "sessionStorage",
2818  lookup(_ref) {
2819    let {
2820      lookupSessionStorage
2821    } = _ref;
2822    if (lookupSessionStorage && sessionStorageAvailable()) {
2823      return window.sessionStorage.getItem(lookupSessionStorage) || void 0;
2824    }
2825    return void 0;
2826  },
2827  cacheUserLanguage(lng, _ref2) {
2828    let {
2829      lookupSessionStorage
2830    } = _ref2;
2831    if (lookupSessionStorage && sessionStorageAvailable()) {
2832      window.sessionStorage.setItem(lookupSessionStorage, lng);
2833    }
2834  }
2835};
2836var navigator$1 = {
2837  name: "navigator",
2838  lookup(options) {
2839    const found = [];
2840    if (typeof navigator !== "undefined") {
2841      const {
2842        languages,
2843        userLanguage,
2844        language
2845      } = navigator;
2846      if (languages) {
2847        for (let i = 0; i < languages.length; i++) {
2848          found.push(languages[i]);
2849        }
2850      }
2851      if (userLanguage) {
2852        found.push(userLanguage);
2853      }
2854      if (language) {
2855        found.push(language);
2856      }
2857    }
2858    return found.length > 0 ? found : void 0;
2859  }
2860};
2861var htmlTag = {
2862  name: "htmlTag",
2863  // Deconstruct the options object and extract the htmlTag property
2864  lookup(_ref) {
2865    let {
2866      htmlTag: htmlTag2
2867    } = _ref;
2868    let found;
2869    const internalHtmlTag = htmlTag2 || (typeof document !== "undefined" ? document.documentElement : null);
2870    if (internalHtmlTag && typeof internalHtmlTag.getAttribute === "function") {
2871      found = internalHtmlTag.getAttribute("lang");
2872    }
2873    return found;
2874  }
2875};
2876var path = {
2877  name: "path",
2878  // Deconstruct the options object and extract the lookupFromPathIndex property
2879  lookup(_ref) {
2880    var _a;
2881    let {
2882      lookupFromPathIndex
2883    } = _ref;
2884    if (typeof window === "undefined") return void 0;
2885    const language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
2886    if (!Array.isArray(language)) return void 0;
2887    const index = typeof lookupFromPathIndex === "number" ? lookupFromPathIndex : 0;
2888    return (_a = language[index]) == null ? void 0 : _a.replace("/", "");
2889  }
2890};
2891var subdomain = {
2892  name: "subdomain",
2893  lookup(_ref) {
2894    var _a, _b;
2895    let {
2896      lookupFromSubdomainIndex
2897    } = _ref;
2898    const internalLookupFromSubdomainIndex = typeof lookupFromSubdomainIndex === "number" ? lookupFromSubdomainIndex + 1 : 1;
2899    const language = typeof window !== "undefined" && ((_b = (_a = window.location) == null ? void 0 : _a.hostname) == null ? void 0 : _b.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));
2900    if (!language) return void 0;
2901    return language[internalLookupFromSubdomainIndex];
2902  }
2903};
2904let canCookies = false;
2905try {
2906  document.cookie;
2907  canCookies = true;
2908} catch (e) {
2909}
2910const order = ["querystring", "cookie", "localStorage", "sessionStorage", "navigator", "htmlTag"];
2911if (!canCookies) order.splice(1, 1);
2912const getDefaults$1 = () => ({
2913  order,
2914  lookupQuerystring: "lng",
2915  lookupCookie: "i18next",
2916  lookupLocalStorage: "i18nextLng",
2917  lookupSessionStorage: "i18nextLng",
2918  // cache user language
2919  caches: ["localStorage"],
2920  excludeCacheFor: ["cimode"],
2921  // cookieMinutes: 10,
2922  // cookieDomain: 'myDomain'
2923  convertDetectedLanguage: (l) => l
2924});
2925class Browser {
2926  constructor(services) {
2927    let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2928    this.type = "languageDetector";
2929    this.detectors = {};
2930    this.init(services, options);
2931  }
2932  init() {
2933    let services = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
2934      languageUtils: {}
2935    };
2936    let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2937    let i18nOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2938    this.services = services;
2939    this.options = defaults(options, this.options || {}, getDefaults$1());
2940    if (typeof this.options.convertDetectedLanguage === "string" && this.options.convertDetectedLanguage.indexOf("15897") > -1) {
2941      this.options.convertDetectedLanguage = (l) => l.replace("-", "_");
2942    }
2943    if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
2944    this.i18nOptions = i18nOptions;
2945    this.addDetector(cookie$1);
2946    this.addDetector(querystring);
2947    this.addDetector(localStorage);
2948    this.addDetector(sessionStorage);
2949    this.addDetector(navigator$1);
2950    this.addDetector(htmlTag);
2951    this.addDetector(path);
2952    this.addDetector(subdomain);
2953    this.addDetector(hash);
2954  }
2955  addDetector(detector) {
2956    this.detectors[detector.name] = detector;
2957    return this;
2958  }
2959  detect() {
2960    let detectionOrder = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.order;
2961    let detected = [];
2962    detectionOrder.forEach((detectorName) => {
2963      if (this.detectors[detectorName]) {
2964        let lookup = this.detectors[detectorName].lookup(this.options);
2965        if (lookup && typeof lookup === "string") lookup = [lookup];
2966        if (lookup) detected = detected.concat(lookup);
2967      }
2968    });
2969    detected = detected.filter((d) => d !== void 0 && d !== null && !hasXSS(d)).map((d) => this.options.convertDetectedLanguage(d));
2970    if (this.services && this.services.languageUtils && this.services.languageUtils.getBestMatchFromCodes) return detected;
2971    return detected.length > 0 ? detected[0] : null;
2972  }
2973  cacheUserLanguage(lng) {
2974    let caches = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.options.caches;
2975    if (!caches) return;
2976    if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
2977    caches.forEach((cacheName) => {
2978      if (this.detectors[cacheName]) this.detectors[cacheName].cacheUserLanguage(lng, this.options);
2979    });
2980  }
2981}
2982Browser.type = "languageDetector";
2983function _typeof$2(o) {
2984  "@babel/helpers - typeof";
2985  return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
2986    return typeof o2;
2987  } : function(o2) {
2988    return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
2989  }, _typeof$2(o);
2990}
2991function hasXMLHttpRequest() {
2992  return typeof XMLHttpRequest === "function" || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof$2(XMLHttpRequest)) === "object";
2993}
2994function isPromise(maybePromise) {
2995  return !!maybePromise && typeof maybePromise.then === "function";
2996}
2997function makePromise(maybePromise) {
2998  if (isPromise(maybePromise)) {
2999    return maybePromise;
3000  }
3001  return Promise.resolve(maybePromise);
3002}
3003function commonjsRequire(path2) {
3004  throw new Error('Could not dynamically require "' + path2 + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
3005}
3006var getFetch = { exports: {} };
3007(function(module, exports$1) {
3008  var fetchApi2 = typeof fetch === "function" ? fetch : void 0;
3009  if (typeof commonjsGlobal !== "undefined" && commonjsGlobal.fetch) {
3010    fetchApi2 = commonjsGlobal.fetch;
3011  } else if (typeof window !== "undefined" && window.fetch) {
3012    fetchApi2 = window.fetch;
3013  }
3014  if (typeof commonjsRequire !== "undefined" && typeof window === "undefined") {
3015    var f = fetchApi2 || requireBrowserPonyfill();
3016    if (f.default) f = f.default;
3017    exports$1.default = f;
3018    module.exports = exports$1.default;
3019  }
3020}
3020)(getFetch, getFetch.exports);
3021var getFetchExports = getFetch.exports;
3022const getFetch_default = /* @__PURE__ */ getDefaultExportFromCjs(getFetchExports);
3023const fetchNode = /* @__PURE__ */ _mergeNamespaces({
3024  __proto__: null,
3025  default: getFetch_default
3026}, [getFetchExports]);
3027function ownKeys$1(e, r) {
3028  var t = Object.keys(e);
3029  if (Object.getOwnPropertySymbols) {
3030    var o = Object.getOwnPropertySymbols(e);
3031    r && (o = o.filter(function(r2) {
3032      return Object.getOwnPropertyDescriptor(e, r2).enumerable;
3033    })), t.push.apply(t, o);
3034  }
3035  return t;
3036}
3037function _objectSpread$1(e) {
3038  for (var r = 1; r < arguments.length; r++) {
3039    var t = null != arguments[r] ? arguments[r] : {};
3040    r % 2 ? ownKeys$1(Object(t), true).forEach(function(r2) {
3041      _defineProperty$1(e, r2, t[r2]);
3042    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r2) {
3043      Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
3044    });
3045  }
3046  return e;
3047}
3048function _defineProperty$1(e, r, t) {
3049  return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
3050}
3051function _toPropertyKey$1(t) {
3052  var i = _toPrimitive$1(t, "string");
3053  return "symbol" == _typeof$1(i) ? i : i + "";
3054}
3055function _toPrimitive$1(t, r) {
3056  if ("object" != _typeof$1(t) || !t) return t;
3057  var e = t[Symbol.toPrimitive];
3058  if (void 0 !== e) {
3059    var i = e.call(t, r);
3060    if ("object" != _typeof$1(i)) return i;
3061    throw new TypeError("@@toPrimitive must return a primitive value.");
3062  }
3063  return ("string" === r ? String : Number)(t);
3064}
3065function _typeof$1(o) {
3066  "@babel/helpers - typeof";
3067  return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
3068    return typeof o2;
3069  } : function(o2) {
3070    return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
3071  }, _typeof$1(o);
3072}
3073var fetchApi = typeof fetch === "function" ? fetch : void 0;
3074if (typeof global !== "undefined" && global.fetch) {
3075  fetchApi = global.fetch;
3076} else if (typeof window !== "undefined" && window.fetch) {
3077  fetchApi = window.fetch;
3078}
3079var XmlHttpRequestApi;
3080if (hasXMLHttpRequest()) {
3081  if (typeof global !== "undefined" && global.XMLHttpRequest) {
3082    XmlHttpRequestApi = global.XMLHttpRequest;
3083  } else if (typeof window !== "undefined" && window.XMLHttpRequest) {
3084    XmlHttpRequestApi = window.XMLHttpRequest;
3085  }
3086}
3087var ActiveXObjectApi;
3088if (typeof ActiveXObject === "function") {
3089  if (typeof global !== "undefined" && global.ActiveXObject) {
3090    ActiveXObjectApi = global.ActiveXObject;
3091  } else if (typeof window !== "undefined" && window.ActiveXObject) {
3092    ActiveXObjectApi = window.ActiveXObject;
3093  }
3094}
3095if (!fetchApi && fetchNode && !XmlHttpRequestApi && !ActiveXObjectApi) fetchApi = getFetch_default || fetchNode;
3096if (typeof fetchApi !== "function") fetchApi = void 0;
3097var addQueryString = function addQueryString2(url, params) {
3098  if (params && _typeof$1(params) === "object") {
3099    var queryString = "";
3100    for (var paramName in params) {
3101      queryString += "&" + encodeURIComponent(paramName) + "=" + encodeURIComponent(params[paramName]);
3102    }
3103    if (!queryString) return url;
3104    url = url + (url.indexOf("?") !== -1 ? "&" : "?") + queryString.slice(1);
3105  }
3106  return url;
3107};
3108var fetchIt = function fetchIt2(url, fetchOptions, callback, altFetch) {
3109  var resolver = function resolver2(response) {
3110    if (!response.ok) return callback(response.statusText || "Error", {
3111      status: response.status
3112    });
3113    response.text().then(function(data) {
3114      callback(null, {
3115        status: response.status,
3116        data
3117      });
3118    }).catch(callback);
3119  };
3120  if (altFetch) {
3121    var altResponse = altFetch(url, fetchOptions);
3122    if (altResponse instanceof Promise) {
3123      altResponse.then(resolver).catch(callback);
3124      return;
3125    }
3126  }
3127  if (typeof fetch === "function") {
3128    fetch(url, fetchOptions).then(resolver).catch(callback);
3129  } else {
3130    fetchApi(url, fetchOptions).then(resolver).catch(callback);
3131  }
3132};
3133var omitFetchOptions = false;
3134var requestWithFetch = function requestWithFetch2(options, url, payload, callback) {
3135  if (options.queryStringParams) {
3136    url = addQueryString(url, options.queryStringParams);
3137  }
3138  var headers = _objectSpread$1({}, typeof options.customHeaders === "function" ? options.customHeaders() : options.customHeaders);
3139  if (typeof window === "undefined" && typeof global !== "undefined" && typeof global.process !== "undefined" && global.process.versions && global.process.versions.node) {
3140    headers["User-Agent"] = "i18next-http-backend (node/".concat(global.process.version, "; ").concat(global.process.platform, " ").concat(global.process.arch, ")");
3141  }
3142  if (payload) headers["Content-Type"] = "application/json";
3143  var reqOptions = typeof options.requestOptions === "function" ? options.requestOptions(payload) : options.requestOptions;
3144  var fetchOptions = _objectSpread$1({
3145    method: payload ? "POST" : "GET",
3146    body: payload ? options.stringify(payload) : void 0,
3147    headers
3148  }, omitFetchOptions ? {} : reqOptions);
3149  var altFetch = typeof options.alternateFetch === "function" && options.alternateFetch.length >= 1 ? options.alternateFetch : void 0;
3150  try {
3151    fetchIt(url, fetchOptions, callback, altFetch);
3152  } catch (e) {
3153    if (!reqOptions || Object.keys(reqOptions).length === 0 || !e.message || e.message.indexOf("not implemented") < 0) {
3154      return callback(e);
3155    }
3156    try {
3157      Object.keys(reqOptions).forEach(function(opt) {
3158        delete fetchOptions[opt];
3159      });
3160      fetchIt(url, fetchOptions, callback, altFetch);
3161      omitFetchOptions = true;
3162    } catch (err) {
3163      callback(err);
3164    }
3165  }
3166};
3167var requestWithXmlHttpRequest = function requestWithXmlHttpRequest2(options, url, payload, callback) {
3168  if (payload && _typeof$1(payload) === "object") {
3169    payload = addQueryString("", payload).slice(1);
3170  }
3171  if (options.queryStringParams) {
3172    url = addQueryString(url, options.queryStringParams);
3173  }
3174  try {
3175    var x;
3176    if (XmlHttpRequestApi) {
3177      x = new XmlHttpRequestApi();
3178    } else {
3179      x = new ActiveXObjectApi("MSXML2.XMLHTTP.3.0");
3180    }
3181    x.open(payload ? "POST" : "GET", url, 1);
3182    if (!options.crossDomain) {
3183      x.setRequestHeader("X-Requested-With", "XMLHttpRequest");
3184    }
3185    x.withCredentials = !!options.withCredentials;
3186    if (payload) {
3187      x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
3188    }
3189    if (x.overrideMimeType) {
3190      x.overrideMimeType("application/json");
3191    }
3192    var h = options.customHeaders;
3193    h = typeof h === "function" ? h() : h;
3194    if (h) {
3195      for (var i in h) {
3196        x.setRequestHeader(i, h[i]);
3197      }
3198    }
3199    x.onreadystatechange = function() {
3200      x.readyState > 3 && callback(x.status >= 400 ? x.statusText : null, {
3201        status: x.status,
3202        data: x.responseText
3203      });
3204    };
3205    x.send(payload);
3206  } catch (e) {
3207    console && console.log(e);
3208  }
3209};
3210var request = function request2(options, url, payload, callback) {
3211  if (typeof payload === "function") {
3212    callback = payload;
3213    payload = void 0;
3214  }
3215  callback = callback || function() {
3216  };
3217  if (fetchApi && url.indexOf("file:") !== 0) {
3218    return requestWithFetch(options, url, payload, callback);
3219  }
3220  if (hasXMLHttpRequest() || typeof ActiveXObject === "function") {
3221    return requestWithXmlHttpRequest(options, url, payload, callback);
3222  }
3223  callback(new Error("No fetch and no xhr implementation found!"));
3224};
3225function _typeof(o) {
3226  "@babel/helpers - typeof";
3227  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
3228    return typeof o2;
3229  } : function(o2) {
3230    return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
3231  }, _typeof(o);
3232}
3233function ownKeys(e, r) {
3234  var t = Object.keys(e);
3235  if (Object.getOwnPropertySymbols) {
3236    var o = Object.getOwnPropertySymbols(e);
3237    r && (o = o.filter(function(r2) {
3238      return Object.getOwnPropertyDescriptor(e, r2).enumerable;
3239    })), t.push.apply(t, o);
3240  }
3241  return t;
3242}
3243function _objectSpread(e) {
3244  for (var r = 1; r < arguments.length; r++) {
3245    var t = null != arguments[r] ? arguments[r] : {};
3246    r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
3247      _defineProperty(e, r2, t[r2]);
3248    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEac
3248h(function(r2) {
3249      Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
3250    });
3251  }
3252  return e;
3253}
3254function _classCallCheck(a, n) {
3255  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
3256}
3257function _defineProperties(e, r) {
3258  for (var t = 0; t < r.length; t++) {
3259    var o = r[t];
3260    o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
3261  }
3262}
3263function _createClass(e, r, t) {
3264  return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e;
3265}
3266function _defineProperty(e, r, t) {
3267  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
3268}
3269function _toPropertyKey(t) {
3270  var i = _toPrimitive(t, "string");
3271  return "symbol" == _typeof(i) ? i : i + "";
3272}
3273function _toPrimitive(t, r) {
3274  if ("object" != _typeof(t) || !t) return t;
3275  var e = t[Symbol.toPrimitive];
3276  if (void 0 !== e) {
3277    var i = e.call(t, r);
3278    if ("object" != _typeof(i)) return i;
3279    throw new TypeError("@@toPrimitive must return a primitive value.");
3280  }
3281  return String(t);
3282}
3283var getDefaults = function getDefaults2() {
3284  return {
3285    loadPath: "/locales/{{lng}}/{{ns}}.json",
3286    addPath: "/locales/add/{{lng}}/{{ns}}",
3287    parse: function parse(data) {
3288      return JSON.parse(data);
3289    },
3290    stringify: JSON.stringify,
3291    parsePayload: function parsePayload(namespace, key, fallbackValue) {
3292      return _defineProperty({}, key, fallbackValue || "");
3293    },
3294    parseLoadPayload: function parseLoadPayload(languages, namespaces) {
3295      return void 0;
3296    },
3297    request,
3298    reloadInterval: typeof window !== "undefined" ? false : 60 * 60 * 1e3,
3299    customHeaders: {},
3300    queryStringParams: {},
3301    crossDomain: false,
3302    withCredentials: false,
3303    overrideMimeType: false,
3304    requestOptions: {
3305      mode: "cors",
3306      credentials: "same-origin",
3307      cache: "default"
3308    }
3309  };
3310};
3311var Backend = function() {
3312  function Backend2(services) {
3313    var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3314    var allOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3315    _classCallCheck(this, Backend2);
3316    this.services = services;
3317    this.options = options;
3318    this.allOptions = allOptions;
3319    this.type = "backend";
3320    this.init(services, options, allOptions);
3321  }
3322  return _createClass(Backend2, [{
3323    key: "init",
3324    value: function init(services) {
3325      var _this = this;
3326      var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3327      var allOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3328      this.services = services;
3329      this.options = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), this.options || {}), options);
3330      this.allOptions = allOptions;
3331      if (this.services && this.options.reloadInterval) {
3332        var timer = setInterval(function() {
3333          return _this.reload();
3334        }, this.options.reloadInterval);
3335        if (_typeof(timer) === "object" && typeof timer.unref === "function") timer.unref();
3336      }
3337    }
3338  }, {
3339    key: "readMulti",
3340    value: function readMulti(languages, namespaces, callback) {
3341      this._readAny(languages, languages, namespaces, namespaces, callback);
3342    }
3343  }, {
3344    key: "read",
3345    value: function read(language, namespace, callback) {
3346      this._readAny([language], language, [namespace], namespace, callback);
3347    }
3348  }, {
3349    key: "_readAny",
3350    value: function _readAny(languages, loadUrlLanguages, namespaces, loadUrlNamespaces, callback) {
3351      var _this2 = this;
3352      var loadPath = this.options.loadPath;
3353      if (typeof this.options.loadPath === "function") {
3354        loadPath = this.options.loadPath(languages, namespaces);
3355      }
3356      loadPath = makePromise(loadPath);
3357      loadPath.then(function(resolvedLoadPath) {
3358        if (!resolvedLoadPath) return callback(null, {});
3359        var url = _this2.services.interpolator.interpolate(resolvedLoadPath, {
3360          lng: languages.join("+"),
3361          ns: namespaces.join("+")
3362        });
3363        _this2.loadUrl(url, callback, loadUrlLanguages, loadUrlNamespaces);
3364      });
3365    }
3366  }, {
3367    key: "loadUrl",
3368    value: function loadUrl(url, callback, languages, namespaces) {
3369      var _this3 = this;
3370      var lng = typeof languages === "string" ? [languages] : languages;
3371      var ns = typeof namespaces === "string" ? [namespaces] : namespaces;
3372      var payload = this.options.parseLoadPayload(lng, ns);
3373      this.options.request(this.options, url, payload, function(err, res) {
3374        if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback("failed loading " + url + "; status code: " + res.status, true);
3375        if (res && res.status >= 400 && res.status < 500) return callback("failed loading " + url + "; status code: " + res.status, false);
3376        if (!res && err && err.message) {
3377          var errorMessage = err.message.toLowerCase();
3378          var isNetworkError = ["failed", "fetch", "network", "load"].find(function(term) {
3379            return errorMessage.indexOf(term) > -1;
3380          });
3381          if (isNetworkError) {
3382            return callback("failed loading " + url + ": " + err.message, true);
3383          }
3384        }
3385        if (err) return callback(err, false);
3386        var ret, parseErr;
3387        try {
3388          if (typeof res.data === "string") {
3389            ret = _this3.options.parse(res.data, languages, namespaces);
3390          } else {
3391            ret = res.data;
3392          }
3393        } catch (e) {
3394          parseErr = "failed parsing " + url + " to json";
3395        }
3396        if (parseErr) return callback(parseErr, false);
3397        callback(null, ret);
3398      });
3399    }
3400  }, {
3401    key: "create",
3402    value: function create(languages, namespace, key, fallbackValue, callback) {
3403      var _this4 = this;
3404      if (!this.options.addPath) return;
3405      if (typeof languages === "string") languages = [languages];
3406      var payload = this.options.parsePayload(namespace, key, fallbackValue);
3407      var finished = 0;
3408      var dataArray = [];
3409      var resArray = [];
vendor: 2,131 bytes, lines 3410-3467
3410      languages.forEach(function(lng) {
3411        var addPath = _this4.options.addPath;
3412        if (typeof _this4.options.addPath === "function") {
3413          addPath = _this4.options.addPath(lng, namespace);
3414        }
3415        var url = _this4.services.interpolator.interpolate(addPath, {
3416          lng,
3417          ns: namespace
3418        });
3419        _this4.options.request(_this4.options, url, payload, function(data, res) {
3420          finished += 1;
3421          dataArray.push(data);
3422          resArray.push(res);
3423          if (finished === languages.length) {
3424            if (typeof callback === "function") callback(dataArray, resArray);
3425          }
3426        });
3427      });
3428    }
3429  }, {
3430    key: "reload",
3431    value: function reload() {
3432      var _this5 = this;
3433      var _this$services = this.services, backendConnector = _this$services.backendConnector, languageUtils = _this$services.languageUtils, logger = _this$services.logger;
3434      var currentLanguage = backendConnector.language;
3435      if (currentLanguage && currentLanguage.toLowerCase() === "cimode") return;
3436      var toLoad = [];
3437      var append = function append2(lng) {
3438        var lngs = languageUtils.toResolveHierarchy(lng);
3439        lngs.forEach(function(l) {
3440          if (toLoad.indexOf(l) < 0) toLoad.push(l);
3441        });
3442      };
3443      append(currentLanguage);
3444      if (this.allOptions.preload) this.allOptions.preload.forEach(function(l) {
3445        return append(l);
3446      });
3447      toLoad.forEach(function(lng) {
3448        _this5.allOptions.ns.forEach(function(ns) {
3449          backendConnector.read(lng, ns, "read", null, null, function(err, data) {
3450            if (err) logger.warn("loading namespace ".concat(ns, " for language ").concat(lng, " failed"), err);
3451            if (!err && data) logger.log("loaded namespace ".concat(ns, " for language ").concat(lng), data);
3452            backendConnector.loaded("".concat(lng, "|").concat(ns), err, data);
3453          });
3454        });
3455      });
3456    }
3457  }]);
3458}();
3459Backend.type = "backend";
3460export {
3461  Backend as B,
3462  Browser as a,
3463  initReactI18next as b,
3464  commonjsRequire as c,
3465  instance as i,
3466  useTranslation as u
3467};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.