UNPKG

react-i18next

Version:

Internationalization for react done right. Using the i18next i18n ecosystem.

1 lines 69.4 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactI18next={},e.React)}(this,(function(e,t){"use strict";const s=e=>"string"==typeof e,n=()=>{let e,t;const s=new Promise(((s,n)=>{e=s,t=n}));return s.resolve=e,s.reject=t,s},i=e=>null==e?"":String(e),o=/###/g,r=e=>e&&e.includes("###")?e.replace(o,"."):e,a=e=>!e||s(e),l=(e,t,n)=>{const i=s(t)?t.split("."):t;let o=0;for(;o<i.length-1;){if(a(e))return{};const t=r(i[o]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++o}return a(e)?{}:{obj:e,k:r(i[o])}},c=(e,t,s)=>{const{obj:n,k:i}=l(e,t,Object);if(void 0!==n||1===t.length)return void(n[i]=s);let o=t[t.length-1],r=t.slice(0,t.length-1),a=l(e,r,Object);for(;void 0===a.obj&&r.length;)o=`${r[r.length-1]}.${o}`,r=r.slice(0,r.length-1),a=l(e,r,Object),a?.obj&&void 0!==a.obj[`${a.k}.${o}`]&&(a.obj=void 0);a.obj[`${a.k}.${o}`]=s},u=(e,t)=>{const{obj:s,k:n}=l(e,t);if(s&&Object.prototype.hasOwnProperty.call(s,n))return s[n]},p=(e,t,n)=>{for(const i in t)"__proto__"!==i&&"constructor"!==i&&(Object.prototype.hasOwnProperty.call(e,i)?s(e[i])||e[i]instanceof String||s(t[i])||t[i]instanceof String?n&&(e[i]=t[i]):p(e[i],t[i],n):e[i]=t[i]);return e},h=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},g=e=>s(e)?e.replace(/[&<>"'\/]/g,(e=>d[e])):e;const f=[" ",",","?","!",";"],m=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(void 0!==t)return t;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}(20),y=(e,t,s=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}const n=t.split(s);let i=e;for(let e=0;e<n.length;){if(!i||"object"!=typeof i)return;let t,o="";for(let r=e;r<n.length;++r)if(r!==e&&(o+=s),o+=n[r],t=i[o],void 0!==t){if(["string","number","boolean"].includes(typeof t)&&r<n.length-1)continue;e+=r-e+1;break}i=t}return i},b=e=>e?.replace(/_/g,"-"),v={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class x{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||v,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,n,i){return i&&!this.debug?null:(e=e.map((e=>s(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g," "):e)),s(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new x(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new x(this.logger,e)}}var S=new x;class k{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach((e=>{this.observers[e]||(this.observers[e]=new Map);const s=this.observers[e].get(t)||0;this.observers[e].set(t,s+1)})),this}off(e,t){this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])}once(e,t){const s=(...n)=>{t(...n),this.off(e,s)};return this.on(e,s),this}emit(e,...t){if(this.observers[e]){Array.from(this.observers[e].entries()).forEach((([e,s])=>{for(let n=0;n<s;n++)e(...t)}))}if(this.observers["*"]){Array.from(this.observers["*"].entries()).forEach((([s,n])=>{for(let i=0;i<n;i++)s(e,...t)}))}}}class O extends k{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,i={}){const o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,r=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.includes(".")?a=e.split("."):(a=[e,t],n&&(Array.isArray(n)?a.push(...n):s(n)&&o?a.push(...n.split(o)):a.push(n)));const l=u(this.data,a);return l||t||n||!e.includes(".")||(e=a[0],t=a[1],n=a.slice(2).join(".")),!l&&r&&s(n)?y(this.data?.[e]?.[t],n,o):l}addResource(e,t,s,n,i={silent:!1}){const o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator;let r=[e,t];s&&(r=r.concat(o?s.split(o):s)),e.includes(".")&&(r=e.split("."),n=t,t=r[1]),this.addNamespaces(t),c(this.data,r,n),i.silent||this.emit("added",e,t,s,n)}addResources(e,t,n,i={silent:!1}){for(const i in n)(s(n[i])||Array.isArray(n[i]))&&this.addResource(e,t,i,n[i],{silent:!0});i.silent||this.emit("added",e,t,n)}addResourceBundle(e,t,s,n,i,o={silent:!1,skipCopy:!1}){let r=[e,t];e.includes(".")&&(r=e.split("."),n=s,s=t,t=r[1]),this.addNamespaces(t);let a=u(this.data,r)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),n?p(a,s,i):a={...a,...s},c(this.data,r,a),o.silent||this.emit("added",e,t,s)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((e=>t[e]&&Object.keys(t[e]).length>0))}toJSON(){return this.data}}var N={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,s,n,i){return e.forEach((e=>{t=this.processors[e]?.process(t,s,n,i)??t})),t}};const w=Symbol("i18next/PATH_KEY");function L(e,t){const{[w]:s}=e(function(){const e=[],t=Object.create(null);let s;return t.get=(n,i)=>(s?.revoke?.(),i===w?e:(e.push(i),s=Proxy.revocable(n,t),s.proxy)),Proxy.revocable(Object.create(null),t).proxy}()),n=t?.keySeparator??".",i=t?.nsSeparator??":",o="strict"===t?.enableSelector;if(s.length>1&&i){const e=t?.ns,r=o?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(r){if((o?r:r.length>1?r.slice(1):[]).includes(s[0]))return`${s[0]}${i}${s.slice(1).join(n)}`}}return s.join(n)}const E=e=>!s(e)&&"boolean"!=typeof e&&"number"!=typeof e;class $ extends k{constructor(e,t={}){var s,n;super(),s=e,n=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((e=>{s[e]&&(n[e]=s[e])})),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=S.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(null==e)return!1;const n=this.resolve(e,s);if(void 0===n?.res)return!1;const i=E(n.res);return!1!==s.returnObjects||!i}extractFromKey(e,t){let n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");const i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator;let o=t.ns||this.options.defaultNS||[];const r=n&&e.includes(n),a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||((e,t,s)=>{t=t||"",s=s||"";const n=f.filter((e=>!t.includes(e)&&!s.includes(e)));if(0===n.length)return!0;const i=m.getRegExp(`(${n.map((e=>"?"===e?"\\?":e)).join("|")})`);let o=!i.test(e);if(!o){const t=e.indexOf(s);t>0&&!i.test(e.substring(0,t))&&(o=!0)}return o})(e,n,i));if(r&&!a){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:s(o)?[o]:o};const r=e.split(n);(n!==i||n===i&&this.options.ns.includes(r[0]))&&(o=r.shift()),e=r.join(i)}return{key:e,namespaces:s(o)?[o]:o}}translate(e,t,n){let i="object"==typeof t?{...t}:t;if("object"!=typeof i&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof i&&(i={...i}),i||(i={}),null==e)return"";"function"==typeof e&&(e=L(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]),e=e.map((e=>"function"==typeof e?L(e,{...this.options,...i}):String(e)));const o=void 0!==i.returnDetails?i.returnDetails:this.options.returnDetails,r=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],i),c=l[l.length-1];let u=void 0!==i.nsSeparator?i.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");const p=i.lng||this.language,h=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===p?.toLowerCase())return h?o?{res:`${c}${u}${a}`,usedKey:a,exactUsedKey:a,usedLng:p,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${u}${a}`:o?{res:a,usedKey:a,exactUsedKey:a,usedLng:p,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:a;const d=this.resolve(e,i);let g=d?.res;const f=d?.usedKey||a,m=d?.exactUsedKey||a,y=void 0!==i.joinArrays?i.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==i.count&&!s(i.count),x=$.hasDefaultValue(i),S=v?this.pluralResolver.getSuffix(p,i.count,i):"",k=i.ordinal&&v?this.pluralResolver.getSuffix(p,i.count,{ordinal:!1}):"",O=v&&!i.ordinal&&0===i.count,N=O&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${S}`]||i[`defaultValue${k}`]||i.defaultValue;let w=g;b&&!g&&x&&(w=N);const R=E(w),C=Object.prototype.toString.apply(w);if(!(b&&w&&R)||["[object Number]","[object Function]","[object RegExp]"].includes(C)||s(y)&&Array.isArray(w))if(b&&s(y)&&Array.isArray(g))g=g.join(y),g&&(g=this.extendTranslation(g,e,i,n));else{let t=!1,s=!1;!this.isValidLookup(g)&&x&&(t=!0,g=N),this.isValidLookup(g)||(s=!0,g=a);const o=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&s?void 0:g,l=x&&N!==g&&this.options.updateMissing;if(s||t||l){if(this.logger.log(l?"updateKey":"missingKey",p,c,v&&!l?`${a}${this.pluralResolver.getSuffix(p,i.count,i)}`:a,l?N:g),r){const e=this.resolve(a,{...i,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[];const t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let s=0;s<t.length;s++)e.push(t[s]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);const s=(e,t,s)=>{const n=x&&s!==g?s:o;this.options.missingKeyHandler?this.options.missingKeyHandler(e,c,t,n,l,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,c,t,n,l,i),this.emit("missingKey",e,c,t,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach((e=>{const t=this.pluralResolver.getSuffixes(e,i);O&&i[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach((t=>{s([e],a+t,i[`defaultValue${t}`]||N)}))})):s(e,a,N))}g=this.extendTranslation(g,e,i,d,n),s&&g===a&&this.options.appendNamespaceToMissingKey&&(g=`${c}${u}${a}`),(s||t)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${u}${a}`:a,t?g:void 0,i))}else{if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,w,{...i,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return o?(d.res=e,d.usedParams=this.getUsedParamsDetails(i),d):e}if(r){const e=Array.isArray(w),t=e?[]:{},s=e?m:f;for(const e in w)if(Object.prototype.hasOwnProperty.call(w,e)){const n=`${s}${r}${e}`;t[e]=x&&!g?this.translate(n,{...i,defaultValue:E(N)?N[e]:void 0,joinArrays:!1,ns:l}):this.translate(n,{...i,joinArrays:!1,ns:l}),t[e]===n&&(t[e]=w[e])}g=t}}return o?(d.res=g,d.usedParams=this.getUsedParamsDetails(i),d):g}extendTranslation(e,t,n,i,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});const r=s(e)&&(void 0!==n?.interpolation?.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let a;if(r){const t=e.match(this.interpolator.nestingRegexp);a=t&&t.length}let l=n.replace&&!s(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),e=this.interpolator.interpolate(e,l,n.lng||this.language||i.usedLng,n),r){const t=e.match(this.interpolator.nestingRegexp);a<(t&&t.length)&&(n.nest=!1)}!n.lng&&i&&i.res&&(n.lng=this.language||i.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,((...e)=>o?.[0]!==e[0]||n.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null)),n)),n.interpolation&&this.interpolator.reset()}const r=n.postProcess||this.options.postProcess,a=s(r)?[r]:r;return null!=e&&a?.length&&!1!==n.applyPostProcessor&&(e=N.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,i,o,r,a;return s(e)&&(e=[e]),Array.isArray(e)&&(e=e.map((e=>"function"==typeof e?L(e,{...this.options,...t}):e))),e.forEach((e=>{if(this.isValidLookup(n))return;const l=this.extractFromKey(e,t),c=l.key;i=c;let u=l.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const p=void 0!==t.count&&!s(t.count),h=p&&!t.ordinal&&0===t.count,d=void 0!==t.context&&(s(t.context)||"number"==typeof t.context)&&""!==t.context,g=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach((e=>{this.isValidLookup(n)||(a=e,this.checkedLoadedFor[`${g[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(a)||(this.checkedLoadedFor[`${g[0]}-${e}`]=!0,this.logger.warn(`key "${i}" for languages "${g.join(", ")}" won't get resolved as namespace "${a}" 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!!!")),g.forEach((s=>{if(this.isValidLookup(n))return;r=s;const i=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(i,c,s,e,t);else{let e;p&&(e=this.pluralResolver.getSuffix(s,t.count,t));const n=`${this.options.pluralSeparator}zero`,o=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(t.ordinal&&e.startsWith(o)&&i.push(c+e.replace(o,this.options.pluralSeparator)),i.push(c+e),h&&i.push(c+n)),d){const s=`${c}${this.options.contextSeparator||"_"}${t.context}`;i.push(s),p&&(t.ordinal&&e.startsWith(o)&&i.push(s+e.replace(o,this.options.pluralSeparator)),i.push(s+e),h&&i.push(s+n))}}let a;for(;a=i.pop();)this.isValidLookup(n)||(o=a,n=this.getResource(s,e,a,t))})))}))})),{res:n,usedKey:i,exactUsedKey:o,usedLng:r,usedNS:a}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,s,n={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,n):this.resourceStore.getResource(e,t,s,n)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],n=e.replace&&!s(e.replace);let i=n?e.replace:e;if(n&&void 0!==e.count&&(i={...i,count:e.count}),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!n){i={...i};for(const e of t)delete i[e]}return i}static hasDefaultValue(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith("defaultValue")&&void 0!==e[t])return!0;return!1}}class R{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=S.create("languageUtils")}getScriptPartFromCode(e){if(!(e=b(e))||!e.includes("-"))return null;const t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}getLanguagePartFromCode(e){if(!(e=b(e))||!e.includes("-"))return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(s(e)&&e.includes("-")){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach((e=>{if(t)return;const s=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(s)||(t=s)})),!t&&this.options.supportedLngs&&e.forEach((e=>{if(t)return;const s=this.getScriptPartFromCode(e);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find((e=>e===n||!(!e.includes("-")&&!n.includes("-"))&&(!(!e.includes("-")||n.includes("-")||e.slice(0,e.indexOf("-"))!==n)||!!(e.startsWith(n)&&n.length>1))))})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),s(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){const n=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),i=[],o=e=>{e&&(this.isSupportedCode(e)?i.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return s(e)&&(e.includes("-")||e.includes("_"))?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):s(e)&&o(this.formatLanguageCode(e)),n.forEach((e=>{i.includes(e)||o(this.formatLanguageCode(e))})),i}}const C={zero:0,one:1,two:2,few:3,many:4,other:5},j={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class P{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=S.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=b("dev"===e?"en":e),n=t.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:s,type:n});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let o;try{o=new Intl.PluralRules(s,{type:n})}catch(s){if("undefined"==typeof Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),j;if(!e.match(/-|_/))return j;const n=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(n,t)}return this.pluralRulesCache[i]=o,o}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map((e=>`${t}${e}`))}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort(((e,t)=>C[e]-C[t])).map((e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`)):[]}getSuffix(e,t,s={}){const n=this.getRule(e,s);return n?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${n.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const I=(e,t,n,i=".",o=!0)=>{let r=((e,t,s)=>{const n=u(e,s);return void 0!==n?n:u(t,s)})(e,t,n);return!r&&o&&s(n)&&(r=y(e,n,i),void 0===r&&(r=y(t,n,i))),r};class T{constructor(e={}){this.logger=S.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:n,prefix:i,prefixEscaped:o,suffix:r,suffixEscaped:a,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:y,maxReplaces:b,alwaysFormat:v}=e.interpolation;this.escape=void 0!==t?t:g,this.escapeValue=void 0===s||s,this.useRawValueToEscape=void 0!==n&&n,this.prefix=i?h(i):o||"{{",this.suffix=r?h(r):a||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u?h(u):"-",this.unescapeSuffix=this.unescapePrefix?"":c?h(c):"",this.nestingPrefix=p?h(p):d||h("$t("),this.nestingSuffix=f?h(f):m||h(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=b||1e3,this.alwaysFormat=void 0!==v&&v,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,o){let r,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){const s=I(t,c,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(s,void 0,n,{...o,...t,interpolationkey:e}):s}const s=e.split(this.formatSeparator),i=s.shift().trim(),r=s.join(this.formatSeparator).trim();return this.format(I(t,c,i,this.options.keySeparator,this.options.ignoreJSONStructure),r,n,{...o,...t,interpolationkey:i})};this.resetRegExp(),!this.escapeValue&&"string"==typeof e&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const p=o?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=void 0!==o?.interpolation?.skipOnVariables?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e):e}].forEach((t=>{for(l=0;r=t.regex.exec(e);){const n=r[1].trim();if(a=u(n),void 0===a)if("function"==typeof p){const t=p(e,r,o);a=s(t)?t:""}else if(o&&Object.prototype.hasOwnProperty.call(o,n))a="";else{if(h){a=r[0];continue}this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=""}else s(a)||this.useRawValueToEscape||(a=i(a));const c=t.safeValue(a);if(e=e.replace(r[0],c.replace(/\$/g,"$$$$")),h?(t.regex.lastIndex+=c.length,t.regex.lastIndex-=r[0].length):t.regex.lastIndex=0,l++,l>=this.maxReplaces)break}})),e}nest(e,t,n={}){let o,r,a;const l=(e,t)=>{const s=this.nestingOptionsSeparator;if(!e.includes(s))return e;const n=e.split(new RegExp(`${h(s)}[ ]*{`));let i=`{${n[1]}`;e=n[0],i=this.interpolate(i,a);const o=i.match(/'/g),r=i.match(/"/g);((o?.length??0)%2==0&&!r||(r?.length??0)%2!=0)&&(i=i.replace(/'/g,'"'));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${s}${i}`}return a.defaultValue&&a.defaultValue.includes(this.prefix)&&delete a.defaultValue,e};for(;o=this.nestingRegexp.exec(e);){let c=[];a={...n},a=a.replace&&!s(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const u=/{.*}/s.test(o[1])?o[1].lastIndexOf("}")+1:o[1].indexOf(this.formatSeparator);if(-1!==u&&(c=o[1].slice(u).split(this.formatSeparator).map((e=>e.trim())).filter(Boolean),o[1]=o[1].slice(0,u)),r=t(l.call(this,o[1].trim(),a),a),r&&o[0]===e&&!s(r))return r;s(r)||(r=i(r)),r||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${e}`),r=""),c.length&&(r=c.reduce(((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:o[1].trim()})),r.trim())),e=e.replace(o[0],r),this.regexp.lastIndex=0}return e}}const A=e=>{const t={};return(s,n,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});const r=n+JSON.stringify(o);let a=t[r];return a||(a=e(b(n),i),t[r]=a),a(s)}},V=e=>(t,s,n)=>e(b(s),n)(t);class F{constructor(e={}){this.logger=S.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?A:V;this.formats={number:s(((e,t)=>{const s=new Intl.NumberFormat(e,{...t});return e=>s.format(e)})),currency:s(((e,t)=>{const s=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>s.format(e)})),datetime:s(((e,t)=>{const s=new Intl.DateTimeFormat(e,{...t});return e=>s.format(e)})),relativetime:s(((e,t)=>{const s=new Intl.RelativeTimeFormat(e,{...t});return e=>s.format(e,t.range||"day")})),list:s(((e,t)=>{const s=new Intl.ListFormat(e,{...t});return e=>s.format(e)}))}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=A(t)}format(e,t,s,n={}){if(!t)return e;if(null==e)return e;const i=t.split(this.formatSeparator),o=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf("(")>-1&&!t.includes(")")&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;o.push(t)}return o.reduce(((e,t)=>{const{formatName:i,formatOptions:o}=(e=>{let t=e.toLowerCase().trim();const s={};if(e.includes("(")){const n=e.split("(");t=n[0].toLowerCase().trim();const i=n[1].slice(0,-1);"currency"!==t||i.includes(":")?"relativetime"!==t||i.includes(":")?i.split(";").forEach((e=>{if(e){const[t,...n]=e.split(":"),i=n.join(":").trim().replace(/^'+|'+$/g,""),o=t.trim();s[o]||(s[o]=i),"false"===i&&(s[o]=!1),"true"===i&&(s[o]=!0),isNaN(i)||(s[o]=parseInt(i,10))}})):s.range||(s.range=i.trim()):s.currency||(s.currency=i.trim())}return{formatName:t,formatOptions:s}})(t);if(this.formats[i]){let t=e;try{const r=n?.formatParams?.[n.interpolationkey]||{},a=r.locale||r.lng||n.locale||n.lng||s;t=this.formats[i](e,a,{...o,...n,...r})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e}),e)}}class D extends k{constructor(e,t,s,n={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=n,this.logger=S.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,n.backend,n)}queueLoad(e,t,s,n){const i={},o={},r={},a={};return e.forEach((e=>{let n=!0;t.forEach((t=>{const r=`${e}|${t}`;!s.reload&&this.store.hasResourceBundle(e,t)?this.state[r]=2:this.state[r]<0||(1===this.state[r]?void 0===o[r]&&(o[r]=!0):(this.state[r]=1,n=!1,void 0===o[r]&&(o[r]=!0),void 0===i[r]&&(i[r]=!0),void 0===a[t]&&(a[t]=!0)))})),n||(r[e]=!0)})),(Object.keys(i).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(i),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(a)}}loaded(e,t,s){const n=e.split("|"),i=n[0],o=n[1];t&&this.emit("failedLoading",i,o,t),!t&&s&&this.store.addResourceBundle(i,o,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const r={};this.queue.forEach((s=>{((e,t,s,n)=>{const{obj:i,k:o}=l(e,t,Object);i[o]=i[o]||[],i[o].push(s)})(s.loaded,[i],o),((e,t)=>{void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)})(s,e),t&&s.errors.push(t),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach((e=>{r[e]||(r[e]={});const t=s.loaded[e];t.length&&t.forEach((t=>{void 0===r[e][t]&&(r[e][t]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",r),this.queue=this.queue.filter((e=>!e.done))}read(e,t,s,n=0,i=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:s,tried:n,wait:i,callback:o});this.readingCalls++;const r=(r,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}r&&a&&n<this.maxRetries?setTimeout((()=>{this.read(e,t,s,n+1,2*i,o)}),i):o(r,a)},a=this.backend[s].bind(this.backend);if(2!==a.length)return a(e,t,r);try{const s=a(e,t);s&&"function"==typeof s.then?s.then((e=>r(null,e))).catch(r):r(null,s)}catch(e){r(e)}}prepareLoading(e,t,n={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();s(e)&&(e=this.languageUtils.toResolveHierarchy(e)),s(t)&&(t=[t]);const o=this.queueLoad(e,t,n,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach((e=>{this.loadOne(e)}))}load(e,t,s){this.prepareLoading(e,t,{},s)}reload(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}loadOne(e,t=""){const s=e.split("|"),n=s[0],i=s[1];this.read(n,i,"read",void 0,void 0,((s,o)=>{s&&this.logger.warn(`${t}loading namespace ${i} for language ${n} failed`,s),!s&&o&&this.logger.log(`${t}loaded namespace ${i} for language ${n}`,o),this.loaded(e,s,o)}))}saveMissing(e,t,s,n,i,o={},r=(()=>{})){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(t)){if(null!=s&&""!==s){if(this.backend?.create){const a={...o,isUpdate:i},l=this.backend.create.bind(this.backend);if(l.length<6)try{let i;i=5===l.length?l(e,t,s,n,a):l(e,t,s,n),i&&"function"==typeof i.then?i.then((e=>r(null,e))).catch(r):r(null,i)}catch(e){r(e)}else l(e,t,s,n,r,a)}e&&e[0]&&this.store.addResource(e[0],t,s,n)}}else this.logger.warn(`did not save key "${s}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const U=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),s(e[1])&&(t.defaultValue=e[1]),s(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){const s=e[3]||e[2];Object.keys(s).forEach((e=>{t[e]=s[e]}))}return t},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),K=e=>(s(e.ns)&&(e.ns=[e.ns]),s(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),s(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),_=()=>{};class M extends k{constructor(e={},t){var s;if(super(),this.options=K(e),this.services={},this.logger=S,this.modules={external:[]},s=this,Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach((e=>{"function"==typeof s[e]&&(s[e]=s[e].bind(s))})),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout((()=>{this.init(e,t)}),0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(s(e.ns)?e.defaultNS=e.ns:e.ns.includes("translation")||(e.defaultNS=e.ns[0]));const i=U();this.options={...i,...this.options,...K(e)},this.options.interpolation={...i.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=i.overloadTranslationOptionHandler);const o=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?S.init(o(this.modules.logger),this.options):S.init(null,this.options),e=this.modules.formatter?this.modules.formatter:F;const t=new R(this.options);this.store=new O(this.options.resources,this.options);const s=this.services;s.logger=S,s.resourceStore=this.store,s.languageUtils=t,s.pluralResolver=new P(t,{prepend:this.options.pluralSeparator}),e&&(s.formatter=o(e),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new T(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new D(o(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",((e,...t)=>{this.emit(e,...t)})),this.modules.languageDetector&&(s.languageDetector=o(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=o(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new $(this.services,this.options),this.translator.on("*",((e,...t)=>{this.emit(e,...t)})),this.modules.external.forEach((e=>{e.init&&e.init(this)}))}if(this.format=this.options.interpolation.format,t||(t=_),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((e=>{this[e]=(...t)=>this.store[e](...t)}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((e=>{this[e]=(...t)=>(this.store[e](...t),this)}));const r=n(),a=()=>{const e=(e,s)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),r.resolve(s),t(e,s)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?a():setTimeout(a,0),r}loadResources(e,t=_){let n=t;const i=s(e)?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===i?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return n();const e=[],t=t=>{if(!t)return;if("cimode"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach((t=>{"cimode"!==t&&(e.includes(t)||e.push(t))}))};if(i)t(i);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e=>t(e)))}this.options.preload?.forEach?.((e=>t(e))),this.services.backendConnector.load(e,this.options.ns,(e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),n(e)}))}else n(null)}reloadResources(e,t,s){const i=n();return"function"==typeof e&&(s=e,e=void 0),"function"==typeof t&&(s=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),s||(s=_),this.services.backendConnector.reload(e,t,(e=>{i.resolve(),s(e)})),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&N.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!["cimode","dev"].includes(e)){for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!["cimode","dev"].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}this.resolvedLanguage||this.languages.includes(e)||!this.store.hasLanguageSomeTranslations(e)||(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=n();this.emit("languageChanging",e);const o=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},r=(s,n)=>{n?this.isLanguageChangingTo===e&&(o(n),this.translator.changeLanguage(n),this.isLanguageChangingTo=void 0,this.emit("languageChanged",n),this.logger.log("languageChanged",n)):this.isLanguageChangingTo=void 0,i.resolve(((...e)=>this.t(...e))),t&&t(s,((...e)=>this.t(...e)))},a=t=>{e||t||!this.services.languageDetector||(t=[]);const n=s(t)?t:t&&t[0],i=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(s(t)?[t]:t);i&&(this.language||o(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,(e=>{r(e,i)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),i}getFixedT(e,t,n,i){const o=i?.scopeNs,r=(e,t,...s)=>{let i;i="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(s)):{...t},i.lng=i.lng||r.lng,i.lngs=i.lngs||r.lngs;const a=void 0!==i.ns&&null!==i.ns;i.ns=i.ns||r.ns,""!==i.keyPrefix&&(i.keyPrefix=i.keyPrefix||n||r.keyPrefix);const l={...this.options,...i};Array.isArray(o)&&!a&&(l.ns=o),"function"==typeof i.keyPrefix&&(i.keyPrefix=L(i.keyPrefix,l));const c=this.options.keySeparator||".";let u;return i.keyPrefix&&Array.isArray(e)?u=e.map((e=>("function"==typeof e&&(e=L(e,l)),`${i.keyPrefix}${c}${e}`))):("function"==typeof e&&(e=L(e,l)),u=i.keyPrefix?`${i.keyPrefix}${c}${e}`:e),this.t(u,i)};return s(e)?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=n,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=t.lng||this.resolvedLanguage||this.languages[0],n=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const o=(e,t)=>{const s=this.services.backendConnector.state[`${e}|${t}`];return-1===s||0===s||2===s};if(t.precheck){const e=t.precheck(this,o);if(void 0!==e)return e}return!!this.hasResourceBundle(s,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,e)||n&&!o(i,e)))}loadNamespaces(e,t){const i=n();return this.options.ns?(s(e)&&(e=[e]),e.forEach((e=>{this.options.ns.includes(e)||this.options.ns.push(e)})),this.loadResources((e=>{i.resolve(),t&&t(e)})),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=n();s(e)&&(e=[e]);const o=this.options.preload||[],r=e.filter((e=>!o.includes(e)&&this.services.languageUtils.isSupportedCode(e)));return r.length?(this.options.preload=o.concat(r),this.loadResources((e=>{i.resolve(),t&&t(e)})),i):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const t=new Intl.Locale(e);if(t&&t.getTextInfo){const e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}const t=this.services?.languageUtils||new R(U());return e.toLowerCase().indexOf("-latn")>1?"ltr":["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"].includes(t.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const s=new M(e,t);return s.createInstance=M.createInstance,s}cloneInstance(e={},t=_){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const n={...this.options,...e,isClone:!0},i=new M(n);void 0===e.debug&&void 0===e.prefix||(i.logger=i.logger.clone(e));if(["store","services","language"].forEach((e=>{i[e]=this[e]})),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},s){const e=Object.keys(this.store.data).reduce(((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce(((s,n)=>(s[n]={...e[t][n]},s)),e[t]),e)),{});i.store=new O(e,n),i.services.resourceStore=i.store}if(e.interpolation){const t={...U().interpolation,...this.options.interpolation,...e.interpolation},s={...n,interpolation:t};i.services.interpolator=new T(s)}return i.translator=new $(i.services,n),i.translator.on("*",((e,...t)=>{i.emit(e,...t)})),i.init(n,t),i.translator.options=n,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const z=M.createInstance();z.createInstance,z.dir,z.init,z.loadResources,z.reloadResources,z.use,z.changeLanguage,z.getFixedT,z.t,z.exists,z.setDefaultNamespace,z.hasLoadedNamespace,z.loadNamespaces,z.loadLanguages;const H={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},B=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function q(e){const t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},s=e.match(/<\/?([^\s]+?)[/\s>]/);if(s&&(t.name=s[1],(H[s[1]]||"/"===e.charAt(e.length-2))&&(t.voidElement=!0),t.name.startsWith("!--"))){const t=e.indexOf("--\x3e");return{type:"comment",comment:-1!==t?e.slice(4,t):""}}const n=new RegExp(B);let i=null;for(;i=n.exec(e),null!==i;)if(i[0].trim())if(i[1]){const e=i[1].trim();let s=[e,null];const o=e.indexOf("=");o>-1&&(s=[e.slice(0,o),e.slice(o+1)]),t.attrs[s[0]]=s[1],n.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}const W=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,J=/<\/?([^\s]+?)[/\s>]/,Y=/^\s*$/,G=/^(script|style)$/i,X="\0",Q=Object.create(null);function Z(e){e.forEach((function(e){if("text"!==e.type)if("comment"!==e.type){for(const t in e.attrs){const s=e.attrs[t];"string"==typeof s&&s.indexOf(X)>-1&&(e.attrs[t]=s.split(X).join("<"))}e.children.length&&Z(e.children)}else e.comment=e.comment.split(X).join("<");else e.content=e.content.split(X).join("<")}))}function ee(e,t){switch(t.type){case"text":return e+t.content;case"tag":{const s=t.voidElement&&"!doctype"!==t.name.toLowerCase()?"/>":">";return e+="<"+t.name+(t.attrs?function(e){const t=[];for(const s in e)null===e[s]?t.push(s):t.push(s+'="'+String(e[s]).replace(/"/g,"&quot;")+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+s,t.voidElement?e:e+t.children.reduce(ee,"")+"</"+t.name+">"}case"comment":return e+="\x3c!--"+t.comment+"--\x3e"}}var te={parse:function(e,t){const s=t&&t.components||Q,n=t&&t.allowedTags;let i=!1;if(n){const t="function"==typeof n?n:function(e){return n.indexOf(e)>-1};let s,o="",r=0;for(W.lastIndex=0;s=W.exec(e);){const n=s[0];o+=e.slice(r,s.index);const a=n.match(J);n.startsWith("\x3c!--")||a&&t(a[1])?(o+=n,r=s.index+n.length):(i=!0,o+=X,r=s.index+1,W.lastIndex=r)}e=o+e.slice(r)}const o=[],r=[];let a,l,c=-1,u=!1,p=0;if(0!==e.indexOf("<")){const t=e.indexOf("<");o.push({type:"text",content:-1===t?e:e.substring(0,t)})}const h=[];let d;for(;d=W.exec(e);)h.push(d);return h.forEach((function(e,t){const s=e[0];if(!s)return;if(s.startsWith("\x3c!--"))return;let n=0,i=0,o=-1,r=null;for(let e=0;e<s.length;e++){const t=s.charAt(e);r?t===r&&(r=null):'"'===t||"'"===t?r=t:"<"===t?(n++,2===n&&(o=e)):">"===t&&i++}const a=o>-1&&/[a-zA-Z0-9\-!/]/.test(s.charAt(o+1));if(n>i&&a){const e=s.substring(0,o),n=s.substring(e.length);h[t][0]=n,h[t].index+=e.length}})),h.forEach((function(t,n){const i=t[0];if(!i)return;const d=t.index;if(d<p)return;if(u){if(i!=="</"+a.name+">")return;u=!1}const g="/"!==i.charAt(1),f=i.startsWith("\x3c!--"),m=d+i.length,y=e.charAt(m),b=h[n+1];let v,x;if("<"===y&&b){const t=e.substring(m,b.index);v=t.split("<").length>t.split(">").length}if(f){const t=q(i);if(c<0)return o.push(t),o;x=r[c],x.children.push(t);const s=e.slice(m,b?b.index:void 0);return s.length>0&&x.children.push({type:"text",content:s}),o}if(g){c++,a=q(i),"tag"===a.type&&s[a.name]&&(a.type="component",u=!0);let t=!1;if(!u&&!a.voidElement&&G.test(a.name)){t=!0,l||(l=e.toLowerCase());const s=l.indexOf("</"+a.name.toLowerCase()+">",m),n=-1===s?e.length:s,i=e.slice(m,n);i&&a.children.push({type:"text",content:i}),p=n}a.voidElement||u||t||!y||"<"===y||a.children.push({type:"text",content:e.slice(m,b?b.index:void 0)}),0===c&&o.push(a),x=r[c-1],x&&x.children.push(a),r[c]=a}if((!g||a.voidElement)&&(c>-1&&(a.voidElement||a.name===i.slice(2,-1))&&(c--,a=-1===c?o:r[c]),!u&&("<"!==y||v)&&y)){x=-1===c?o:r[c].children;const t=b?b.index:-1;let s=e.slice(m,-1===t?void 0:t);Y.test(s)&&(s=" "),(t>-1&&c+x.length>=0||" "!==s)&&x.push({type:"text",content:s})}})),i&&Z(o),o},stringify:function(e){return e.reduce((function(e,t){return e+ee("",t)}),"")}};const se=(e,t,s,n)=>{const i=[s,{code:t,...n||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,"warn","react-i18next::",!0);ce(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},ne={},ie=(e,t,s,n)=>{ce(s)&&ne[s]||(ce(s)&&(ne[s]=new Date),se(e,t,s,n))},oe=(e,t)=>()=>{if(e.isInitialized)t();else{const s=()=>{setTimeout((()=>{e.off("initialized",s)}),0),t()};e.on("initialized",s)}},re=(e,t,s)=>{e.loadNamespaces(t,oe(e,s))},ae=(e,t,s,n)=>{if(ce(s)&&(s=[s]),e.options.preload&&e.options.preload.indexOf(t)>-1)return re(e,s,n);s.forEach((t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)})),e.loadLanguages(t,oe(e,n))},le=e=>e.displayName||e.name||(ce(e)&&e.length>0?e:"Unknown"),ce=e=>"string"==typeof e,ue=e=>"object"==typeof e&&null!==e,pe=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,he={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},de=e=>he[e],ge=e=>e.replace(pe,de);let fe={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:ge,transDefaultProps:void 0};const me=(e={})=>{fe={...fe,...e}},ye=()=>fe;let be;const ve=e=>{be=e},xe=()=>be,Se=(e,t)=>{if(!e)return!1;const s=e.props?.children??e.children;return t?s.length>0:!!s},ke=e=>{if(!e)return[];const t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?Oe(t):t},Oe=e=>Array.isArray(e)?e:[e],Ne=e=>{const s={};if(!e)return s;const n=e=>{Oe(e).forEach((e=>{ce(e)||(Se(e)?n(ke(e)):ue(e)&&!t.isValidElement(e)&&Object.assign(s,e))}))};return n(e),s},we=(e,s,n,i)=>{if(!e)return"";let o="";const r=Oe(e),a=s?.transSupportBasicHtmlNodes?s.transKeepBasicHtmlNodesFor??[]:[];return r.forEach(((e,r)=>{if(ce(e))o+=`${e}`;else if(t.isValidElement(e)){const{props:t,type:l}=e,c=Object.keys(t).length,u=a.indexOf(l)>-1,p=t.children;if(!p&&u&&!c)return void(o+=`<${l}/>`);if(!p&&(!u||c)||t.i18nIsDynamicList)return void(o+=`<${r}></${r}>`);if(u&&c<=1){const e=ce(p)?p:we(p,s,n,i);return void(o+=`<${l}>${e}</${l}>`)}const h=we(p,s,n,i);o+=`<${r}>${h}</${r}>`}else if(null!==e)if(ue(e)){const{format:t,...s}=e,r=Object.keys(s);if(1===r.length){const e=t?`${r[0]}, ${t}`:r[0];return void(o+=`{{${e}}}`)}se(n,"TRANS_INVALID_OBJ