UNPKG

@sap/generator-fiori

Version:

Create an SAPUI5 application using SAP Fiori elements or a freestyle approach

3 lines (2 loc) 44.5 kB
const __esmImportMetaUrl = require('node:url').pathToFileURL(__filename).href; "use strict";var Pe=Object.defineProperty;var c=(o,e)=>Pe(o,"name",{value:e,configurable:!0});var p=c(o=>typeof o=="string","isString"),A=c(()=>{let o,e,t=new Promise((i,s)=>{o=i,e=s});return t.resolve=o,t.reject=e,t},"defer"),fe=c(o=>o==null?"":""+o,"makeString"),Re=c((o,e,t)=>{o.forEach(i=>{e[i]&&(t[i]=e[i])})},"copy"),Ne=/###/g,he=c(o=>o&&o.indexOf("###")>-1?o.replace(Ne,"."):o,"cleanKey"),ce=c(o=>!o||p(o),"canNotTraverseDeeper"),U=c((o,e,t)=>{let i=p(e)?e.split("."):e,s=0;for(;s<i.length-1;){if(ce(o))return{};let n=he(i[s]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++s}return ce(o)?{}:{obj:o,k:he(i[s])}},"getLastOfPath"),de=c((o,e,t)=>{let{obj:i,k:s}=U(o,e,Object);if(i!==void 0||e.length===1){i[s]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=U(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=U(o,r,Object),a?.obj&&typeof a.obj[`${a.k}.${n}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${n}`]=t},"setPath"),ke=c((o,e,t,i)=>{let{obj:s,k:n}=U(o,e,Object);s[n]=s[n]||[],s[n].push(t)},"pushPath"),B=c((o,e)=>{let{obj:t,k:i}=U(o,e);if(t&&Object.prototype.hasOwnProperty.call(t,i))return t[i]},"getPath"),je=c((o,e,t)=>{let i=B(o,t);return i!==void 0?i:B(e,t)},"getPathWithDefaults"),be=c((o,e,t)=>{for(let i in e)i!=="__proto__"&&i!=="constructor"&&(i in o?p(o[i])||o[i]instanceof String||p(e[i])||e[i]instanceof String?t&&(o[i]=e[i]):be(o[i],e[i],t):o[i]=e[i]);return o},"deepExtend"),E=c(o=>o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),"regexEscape"),Fe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},Ee=c(o=>p(o)?o.replace(/[&<>"'\/]/g,e=>Fe[e]):o,"escape"),q=class{static{c(this,"RegExpCache")}constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}},Te=[" ",",","?","!",";"],Ie=new q(20),De=c((o,e,t)=>{e=e||"",t=t||"";let i=Te.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(i.length===0)return!0;let s=Ie.getRegExp(`(${i.map(r=>r==="?"?"\\?":r).join("|")})`),n=!s.test(o);if(!n){let r=o.indexOf(t);r>0&&!s.test(o.substring(0,r))&&(n=!0)}return n},"looksLikeObjectPath"),ee=c((o,e,t=".")=>{if(!o)return;if(o[e])return Object.prototype.hasOwnProperty.call(o,e)?o[e]:void 0;let i=e.split(t),s=o;for(let n=0;n<i.length;){if(!s||typeof s!="object")return;let r,a="";for(let l=n;l<i.length;++l)if(l!==n&&(a+=t),a+=i[l],r=s[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<i.length-1)continue;n+=l-n+1;break}s=r}return s},"deepFind"),H=c(o=>o?.replace(/_/g,"-"),"getCleanedCode"),Ke={type:"logger",log(o){this.output("log",o)},warn(o){this.output("warn",o)},error(o){this.output("error",o)},output(o,e){console?.[o]?.apply?.(console,e)}},te=class o{static{c(this,"Logger")}constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Ke,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,i,s){return s&&!this.debug?null:(p(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new o(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new o(this.logger,e)}},P=new te,D=class{static{c(this,"EventEmitter")}constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);let s=this.observers[i].get(t)||0;this.observers[i].set(t,s+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s.apply(s,[e,...t])})}},J=class extends D{static{c(this,"ResourceStore")}constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,i,s={}){let n=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,r=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure,a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],i&&(Array.isArray(i)?a.push(...i):p(i)&&n?a.push(...i.split(n)):a.push(i)));let l=B(this.data,a);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=a[0],t=a[1],i=a.slice(2).join(".")),l||!r||!p(i)?l:ee(this.data?.[e]?.[t],i,n)}addResource(e,t,i,s,n={silent:!1}){let r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,a=[e,t];i&&(a=a.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(a=e.split("."),s=t,t=a[1]),this.addNamespaces(t),de(this.data,a,s),n.silent||this.emit("added",e,t,i,s)}addResources(e,t,i,s={silent:!1}){for(let n in i)(p(i[n])||Array.isArray(i[n]))&&this.addResource(e,t,n,i[n],{silent:!0});s.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,s,n,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),s=i,i=t,t=a[1]),this.addNamespaces(t);let l=B(this.data,a)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?be(l,i,n):l={...l,...i},de(this.data,a,l),r.silent||this.emit("added",e,t,i)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(s=>t[s]&&Object.keys(t[s]).length>0)}toJSON(){return this.data}},Oe={processors:{},addPostProcessor(o){this.processors[o.name]=o},handle(o,e,t,i,s){return o.forEach(n=>{e=this.processors[n]?.process(e,t,i,s)??e}),e}},Le=Symbol("i18next/PATH_KEY");function Ve(){let o=[],e=Object.create(null),t;return e.get=(i,s)=>(t?.revoke?.(),s===Le?o:(o.push(s),t=Proxy.revocable(i,e),t.proxy)),Proxy.revocable(Object.create(null),e).proxy}c(Ve,"createProxy");function _(o,e){let{[Le]:t}=o(Ve()),i=e?.keySeparator??".",s=e?.nsSeparator??":";if(t.length>1&&s){let n=e?.ns;if((n?Array.isArray(n)?n:[n]:[]).includes(t[0]))return`${t[0]}${s}${t.slice(1).join(i)}`}return t.join(i)}c(_,"keysFromSelector");var pe={},G=c(o=>!p(o)&&typeof o!="boolean"&&typeof o!="number","shouldHandleAsObject"),W=class o extends D{static{c(this,"Translator")}constructor(e,t={}){super(),Re(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=P.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let i={...t};if(e==null)return!1;let s=this.resolve(e,i);if(s?.res===void 0)return!1;let n=G(s.res);return!(i.returnObjects===!1&&n)}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");let s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator,n=t.ns||this.options.defaultNS||[],r=i&&e.indexOf(i)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!De(e,i,s);if(r&&!a){let l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:p(n)?[n]:n};let u=e.split(i);(i!==s||i===s&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(s)}return{key:e,namespaces:p(n)?[n]:n}}translate(e,t,i){let s=typeof t=="object"?{...t}:t;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof s=="object"&&(s={...s}),s||(s={}),e==null)return"";typeof e=="function"&&(e=_(e,{...this.options,...s})),Array.isArray(e)||(e=[String(e)]);let n=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],s),u=l[l.length-1],h=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");let f=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?n?{res:`${u}${h}${a}`,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:a;let g=this.resolve(e,s),d=g?.res,x=g?.usedKey||a,S=g?.exactUsedKey||a,L=["[object Number]","[object Function]","[object RegExp]"],y=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,j=!this.i18nFormat||this.i18nFormat.handleAsObject,O=s.count!==void 0&&!p(s.count),N=o.hasDefaultValue(s),T=O?this.pluralResolver.getSuffix(f,s.count,s):"",I=s.ordinal&&O?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",ae=O&&!s.ordinal&&s.count===0,k=ae&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${T}`]||s[`defaultValue${I}`]||s.defaultValue,v=d;j&&!d&&N&&(v=k);let Ce=G(v),$e=Object.prototype.toString.apply(v);if(j&&v&&Ce&&L.indexOf($e)<0&&!(p(y)&&Array.isArray(v))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let C=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,v,{...s,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return n?(g.res=C,g.usedParams=this.getUsedParamsDetails(s),g):C}if(r){let C=Array.isArray(v),w=C?[]:{},oe=C?S:x;for(let $ in v)if(Object.prototype.hasOwnProperty.call(v,$)){let R=`${oe}${r}${$}`;N&&!d?w[$]=this.translate(R,{...s,defaultValue:G(k)?k[$]:void 0,joinArrays:!1,ns:l}):w[$]=this.translate(R,{...s,joinArrays:!1,ns:l}),w[$]===R&&(w[$]=v[$])}d=w}}else if(j&&p(y)&&Array.isArray(d))d=d.join(y),d&&(d=this.extendTranslation(d,e,s,i));else{let C=!1,w=!1;!this.isValidLookup(d)&&N&&(C=!0,d=k),this.isValidLookup(d)||(w=!0,d=a);let $=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&w?void 0:d,R=N&&k!==d&&this.options.updateMissing;if(w||C||R){if(this.logger.log(R?"updateKey":"missingKey",f,u,a,R?k:d),r){let b=this.resolve(a,{...s,keySeparator:!1});b&&b.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 K=[],M=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&M&&M[0])for(let b=0;b<M.length;b++)K.push(M[b]);else this.options.saveMissingTo==="all"?K=this.languageUtils.toResolveHierarchy(s.lng||this.language):K.push(s.lng||this.language);let le=c((b,F,V)=>{let ue=N&&V!==d?V:$;this.options.missingKeyHandler?this.options.missingKeyHandler(b,u,F,ue,R,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(b,u,F,ue,R,s),this.emit("missingKey",b,u,F,d)},"send");this.options.saveMissing&&(this.options.saveMissingPlurals&&O?K.forEach(b=>{let F=this.pluralResolver.getSuffixes(b,s);ae&&s[`defaultValue${this.options.pluralSeparator}zero`]&&F.indexOf(`${this.options.pluralSeparator}zero`)<0&&F.push(`${this.options.pluralSeparator}zero`),F.forEach(V=>{le([b],a+V,s[`defaultValue${V}`]||k)})}):le(K,a,k))}d=this.extendTranslation(d,e,s,g,i),w&&d===a&&this.options.appendNamespaceToMissingKey&&(d=`${u}${h}${a}`),(w||C)&&this.options.parseMissingKeyHandler&&(d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,C?d:void 0,s))}return n?(g.res=d,g.usedParams=this.getUsedParamsDetails(s),g):d}extendTranslation(e,t,i,s,n){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});let l=p(e)&&(i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables),u;if(l){let f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let h=i.replace&&!p(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(h={...this.options.interpolation.defaultVariables,...h}),e=this.interpolator.interpolate(e,h,i.lng||this.language||s.usedLng,i),l){let f=e.match(this.interpolator.nestingRegexp),m=f&&f.length;u<m&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>n?.[0]===f[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${t[0]}`),null):this.translate(...f,t),i)),i.interpolation&&this.interpolator.reset()}let r=i.postProcess||this.options.postProcess,a=p(r)?[r]:r;return e!=null&&a?.length&&i.applyPostProcessor!==!1&&(e=Oe.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),e}resolve(e,t={}){let i,s,n,r,a;return p(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;let u=this.extractFromKey(l,t),h=u.key;s=h;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));let m=t.count!==void 0&&!p(t.count),g=m&&!t.ordinal&&t.count===0,d=t.context!==void 0&&(p(t.context)||typeof t.context=="number")&&t.context!=="",x=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);f.forEach(S=>{this.isValidLookup(i)||(a=S,!pe[`${x[0]}-${S}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(pe[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${s}" for languages "${x.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!!!")),x.forEach(L=>{if(this.isValidLookup(i))return;r=L;let y=[h];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(y,h,L,S,t);else{let O;m&&(O=this.pluralResolver.getSuffix(L,t.count,t));let N=`${this.options.pluralSeparator}zero`,T=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(t.ordinal&&O.indexOf(T)===0&&y.push(h+O.replace(T,this.options.pluralSeparator)),y.push(h+O),g&&y.push(h+N)),d){let I=`${h}${this.options.contextSeparator||"_"}${t.context}`;y.push(I),m&&(t.ordinal&&O.indexOf(T)===0&&y.push(I+O.replace(T,this.options.pluralSeparator)),y.push(I+O),g&&y.push(I+N))}}let j;for(;j=y.pop();)this.isValidLookup(i)||(n=j,i=this.getResource(L,S,j,t))}))})}),{res:i,usedKey:s,exactUsedKey:n,usedLng:r,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,i,s):this.resourceStore.getResource(e,t,i,s)}getUsedParamsDetails(e={}){let t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!p(e.replace),s=i?e.replace:e;if(i&&typeof e.count<"u"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!i){s={...s};for(let n of t)delete s[n]}return s}static hasDefaultValue(e){let t="defaultValue";for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==void 0)return!0;return!1}},Y=class{static{c(this,"LanguageUtil")}constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=P.create("languageUtils")}getScriptPartFromCode(e){if(e=H(e),!e||e.indexOf("-")<0)return null;let t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=H(e),!e||e.indexOf("-")<0)return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(p(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(i=>{if(t)return;let s=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(s))&&(t=s)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;let s=this.getScriptPartFromCode(i);if(this.isSupportedCode(s))return t=s;let n=this.getLanguagePartFromCode(i);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(r=>{if(r===n)return r;if(!(r.indexOf("-")<0&&n.indexOf("-")<0)&&(r.indexOf("-")>0&&n.indexOf("-")<0&&r.substring(0,r.indexOf("-"))===n||r.indexOf(n)===0&&n.length>1))return r})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),p(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){let i=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),s=[],n=c(r=>{r&&(this.isSupportedCode(r)?s.push(r):this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`))},"addCode");return p(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):p(e)&&n(this.formatLanguageCode(e)),i.forEach(r=>{s.indexOf(r)<0&&n(this.formatLanguageCode(r))}),s}},ge={zero:0,one:1,two:2,few:3,many:4,other:5},me={select:c(o=>o===1?"one":"other","select"),resolvedOptions:c(()=>({pluralCategories:["one","other"]}),"resolvedOptions")},se=class{static{c(this,"PluralResolver")}constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=P.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let i=H(e==="dev"?"en":e),s=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),me;if(!e.match(/-|_/))return me;let l=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(l,t)}return this.pluralRulesCache[n]=r,r}needsPlural(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,i={}){return this.getSuffixes(e,i).map(s=>`${t}${s}`)}getSuffixes(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((s,n)=>ge[s]-ge[n]).map(s=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,t,i={}){let s=this.getRule(e,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}},xe=c((o,e,t,i=".",s=!0)=>{let n=je(o,e,t);return!n&&s&&p(t)&&(n=ee(o,t,i),n===void 0&&(n=ee(e,t,i))),n},"deepFindWithDefaults"),Z=c(o=>o.replace(/\$/g,"$$$$"),"regexSafe"),Q=class{static{c(this,"Interpolator")}constructor(e={}){this.logger=P.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(t=>t),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:t,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:r,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:h,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:g,nestingSuffix:d,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:L,alwaysFormat:y}=e.interpolation;this.escape=t!==void 0?t:Ee,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=n?E(n):r||"{{",this.suffix=a?E(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=h?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=m?E(m):g||E("$t("),this.nestingSuffix=d?E(d):x||E(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=L||1e3,this.alwaysFormat=y!==void 0?y:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=c((t,i)=>t?.source===i?(t.lastIndex=0,t):new RegExp(i,"g"),"getOrResetRegExp");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,i,s){let n,r,a,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c(g=>{if(g.indexOf(this.formatSeparator)<0){let L=xe(t,l,g,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(L,void 0,i,{...s,...t,interpolationkey:g}):L}let d=g.split(this.formatSeparator),x=d.shift().trim(),S=d.join(this.formatSeparator).trim();return this.format(xe(t,l,x,this.options.keySeparator,this.options.ignoreJSONStructure),S,i,{...s,...t,interpolationkey:x})},"handleFormat");this.resetRegExp();let h=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c(g=>Z(g),"safeValue")},{regex:this.regexp,safeValue:c(g=>this.escapeValue?Z(this.escape(g)):Z(g),"safeValue")}].forEach(g=>{for(a=0;n=g.regex.exec(e);){let d=n[1].trim();if(r=u(d),r===void 0)if(typeof h=="function"){let S=h(e,n,s);r=p(S)?S:""}else if(s&&Object.prototype.hasOwnProperty.call(s,d))r="";else if(f){r=n[0];continue}else this.logger.warn(`missed to pass in variable ${d} for interpolating ${e}`),r="";else!p(r)&&!this.useRawValueToEscape&&(r=fe(r));let x=g.safeValue(r);if(e=e.replace(n[0],x),f?(g.regex.lastIndex+=r.length,g.regex.lastIndex-=n[0].length):g.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,t,i={}){let s,n,r,a=c((l,u)=>{let h=this.nestingOptionsSeparator;if(l.indexOf(h)<0)return l;let f=l.split(new RegExp(`${E(h)}[ ]*{`)),m=`{${f[1]}`;l=f[0],m=this.interpolate(m,r);let g=m.match(/'/g),d=m.match(/"/g);((g?.length??0)%2===0&&!d||(d?.length??0)%2!==0)&&(m=m.replace(/'/g,'"'));try{r=JSON.parse(m),u&&(r={...u,...r})}catch(x){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,x),`${l}${h}${m}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,l},"handleHasOptions");for(;s=this.nestingRegexp.exec(e);){let l=[];r={...i},r=r.replace&&!p(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;let u=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(u!==-1&&(l=s[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),s[1]=s[1].slice(0,u)),n=t(a.call(this,s[1].trim(),r),r),n&&s[0]===e&&!p(n))return n;p(n)||(n=fe(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,i.lng,{...i,interpolationkey:s[1].trim()}),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}},Ae=c(o=>{let e=o.toLowerCase().trim(),t={};if(o.indexOf("(")>-1){let i=o.split("(");e=i[0].toLowerCase().trim();let s=i[1].substring(0,i[1].length-1);e==="currency"&&s.indexOf(":")<0?t.currency||(t.currency=s.trim()):e==="relativetime"&&s.indexOf(":")<0?t.range||(t.range=s.trim()):s.split(";").forEach(r=>{if(r){let[a,...l]=r.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),h=a.trim();t[h]||(t[h]=u),u==="false"&&(t[h]=!1),u==="true"&&(t[h]=!0),isNaN(u)||(t[h]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},"parseFormatStr"),ye=c(o=>{let e={};return(t,i,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n={...n,[s.interpolationkey]:void 0});let r=i+JSON.stringify(n),a=e[r];return a||(a=o(H(i),s),e[r]=a),a(t)}},"createCachedFormatter"),Ue=c(o=>(e,t,i)=>o(H(t),i)(e),"createNonCachedFormatter"),ie=class{static{c(this,"Formatter")}constructor(e={}){this.logger=P.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let i=t.cacheInBuiltFormats?ye:Ue;this.formats={number:i((s,n)=>{let r=new Intl.NumberFormat(s,{...n});return a=>r.format(a)}),currency:i((s,n)=>{let r=new Intl.NumberFormat(s,{...n,style:"currency"});return a=>r.format(a)}),datetime:i((s,n)=>{let r=new Intl.DateTimeFormat(s,{...n});return a=>r.format(a)}),relativetime:i((s,n)=>{let r=new Intl.RelativeTimeFormat(s,{...n});return a=>r.format(a,n.range||"day")}),list:i((s,n)=>{let r=new Intl.ListFormat(s,{...n});return a=>r.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ye(t)}format(e,t,i,s={}){let n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(a=>a.indexOf(")")>-1)){let a=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,a)].join(this.formatSeparator)}return n.reduce((a,l)=>{let{formatName:u,formatOptions:h}=Ae(l);if(this.formats[u]){let f=a;try{let m=s?.formatParams?.[s.interpolationkey]||{},g=m.locale||m.lng||s.locale||s.lng||i;f=this.formats[u](a,g,{...h,...s,...m})}catch(m){this.logger.warn(m)}return f}else this.logger.warn(`there was no format function for ${u}`);return a},e)}},He=c((o,e)=>{o.pending[e]!==void 0&&(delete o.pending[e],o.pendingCount--)},"removePending"),ne=class extends D{static{c(this,"Connector")}constructor(e,t,i,s={}){super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=P.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(i,s.backend,s)}queueLoad(e,t,i,s){let n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{let m=`${u}|${f}`;!i.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?r[m]===void 0&&(r[m]=!0):(this.state[m]=1,h=!1,r[m]===void 0&&(r[m]=!0),n[m]===void 0&&(n[m]=!0),l[f]===void 0&&(l[f]=!0)))}),h||(a[u]=!0)}),(Object.keys(n).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){let s=e.split("|"),n=s[0],r=s[1];t&&this.emit("failedLoading",n,r,t),!t&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);let a={};this.queue.forEach(l=>{ke(l.loaded,[n],r),He(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});let h=l.loaded[u];h.length&&h.forEach(f=>{a[u][f]===void 0&&(a[u][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,t,i,s=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:s,wait:n,callback:r});return}this.readingCalls++;let a=c((u,h)=>{if(this.readingCalls--,this.waitingReads.length>0){let f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&h&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,s+1,n*2,r)},n);return}r(u,h)},"resolver"),l=this.backend[i].bind(this.backend);if(l.length===2){try{let u=l(e,t);u&&typeof u.then=="function"?u.then(h=>a(null,h)).catch(a):a(null,u)}catch(u){a(u)}return}return l(e,t,a)}prepareLoading(e,t,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();p(e)&&(e=this.languageUtils.toResolveHierarchy(e)),p(t)&&(t=[t]);let n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(r=>{this.loadOne(r)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e,t=""){let i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${s}`,a),this.loaded(e,r,a)})}saveMissing(e,t,i,s,n,r={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${i}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(i==null||i==="")){if(this.backend?.create){let l={...r,isUpdate:n},u=this.backend.create.bind(this.backend);if(u.length<6)try{let h;u.length===5?h=u(e,t,i,s,l):h=u(e,t,i,s),h&&typeof h.then=="function"?h.then(f=>a(null,f)).catch(a):a(null,h)}catch(h){a(h)}else u(e,t,i,s,a,l)}!e||!e[0]||this.store.addResource(e[0],t,i,s)}}},X=c(()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:c(o=>{let e={};if(typeof o[1]=="object"&&(e=o[1]),p(o[1])&&(e.defaultValue=o[1]),p(o[2])&&(e.tDescription=o[2]),typeof o[2]=="object"||typeof o[3]=="object"){let t=o[3]||o[2];Object.keys(t).forEach(i=>{e[i]=t[i]})}return e},"overloadTranslationOptionHandler"),interpolation:{escapeValue:!0,format:c(o=>o,"format"),prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),"get"),Se=c(o=>(p(o.ns)&&(o.ns=[o.ns]),p(o.fallbackLng)&&(o.fallbackLng=[o.fallbackLng]),p(o.fallbackNS)&&(o.fallbackNS=[o.fallbackNS]),o.supportedLngs?.indexOf?.("cimode")<0&&(o.supportedLngs=o.supportedLngs.concat(["cimode"])),typeof o.initImmediate=="boolean"&&(o.initAsync=o.initImmediate),o),"transformOptions"),z=c(()=>{},"noop"),Me=c(o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})},"bindMemberFunctions"),we="__i18next_supportNoticeShown",ze=c(()=>typeof globalThis<"u"&&!!globalThis[we],"getSupportNoticeShown"),Be=c(()=>{typeof globalThis<"u"&&(globalThis[we]=!0)},"setSupportNoticeShown"),Je=c(o=>!!(o?.modules?.backend?.name?.indexOf("Locize")>0||o?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||o?.options?.backend?.backends&&o.options.backend.backends.some(e=>e?.name?.indexOf("Locize")>0||e?.constructor?.name?.indexOf("Locize")>0)||o?.options?.backend?.projectId||o?.options?.backend?.backendOptions&&o.options.backend.backendOptions.some(e=>e?.projectId)),"usesLocize"),re=class o extends D{static{c(this,"I18n")}constructor(e={},t){if(super(),this.options=Se(e),this.services={},this.logger=P,this.modules={external:[]},Me(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(p(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));let i=X();this.options={...i,...this.options,...Se(e)},this.options.interpolation={...i.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=i.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!Je(this)&&!ze()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("\u{1F310} i18next is made possible by our own product, Locize \u2014 consider powering your project with managed localization (AI, CDN, integrations): https://locize.com \u{1F499}"),Be());let s=c(u=>u?typeof u=="function"?new u:u:null,"createClassOnDemand");if(!this.options.isClone){this.modules.logger?P.init(s(this.modules.logger),this.options):P.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=ie;let h=new Y(this.options);this.store=new J(this.options.resources,this.options);let f=this.services;f.logger=P,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new se(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(f.formatter=s(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Q(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new ne(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(g,...d)=>{this.emit(g,...d)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new W(this.services,this.options),this.translator.on("*",(g,...d)=>{this.emit(g,...d)}),this.modules.external.forEach(g=>{g.init&&g.init(this)})}if(this.format=this.options.interpolation.format,t||(t=z),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...h)=>this.store[u](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...h)=>(this.store[u](...h),this)});let a=A(),l=c(()=>{let u=c((h,f)=>{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),a.resolve(f),t(h,f)},"finish");if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)},"load");return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),a}loadResources(e,t=z){let i=t,s=p(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if(s?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();let n=[],r=c(a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(u=>{u!=="cimode"&&n.indexOf(u)<0&&n.push(u)})},"append");s?r(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>r(l)),this.options.preload?.forEach?.(a=>r(a)),this.services.backendConnector.load(n,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),i(a)})}else i(null)}reloadResources(e,t,i){let s=A();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=z),this.services.backendConnector.reload(e,t,n=>{s.resolve(),i(n)}),s}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Oe.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){let i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let i=A();this.emit("languageChanging",e);let s=c(a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},"setLngProps"),n=c((a,l)=>{l?this.isLanguageChangingTo===e&&(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.resolve((...u)=>this.t(...u)),t&&t(a,(...u)=>this.t(...u))},"done"),r=c(a=>{!e&&!a&&this.services.languageDetector&&(a=[]);let l=p(a)?a:a&&a[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(p(a)?[a]:a);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,h=>{n(h,u)})},"setLng");return!e&&this.services.languageDetector&&!this.services.languageDetector.async?r(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e),i}getFixedT(e,t,i){let s=c((n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l={...r},l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.keyPrefix);let u=this.options.keySeparator||".",h;return l.keyPrefix&&Array.isArray(n)?h=n.map(f=>(typeof f=="function"&&(f=_(f,{...this.options,...r})),`${l.keyPrefix}${u}${f}`)):(typeof n=="function"&&(n=_(n,{...this.options,...r})),h=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n),this.t(h,l)},"fixedT");return p(e)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}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;let i=t.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;let r=c((a,l)=>{let u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===0||u===2},"loadNotPending");if(t.precheck){let a=t.precheck(this,r);if(a!==void 0)return a}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(i,e)&&(!s||r(n,e)))}loadNamespaces(e,t){let i=A();return this.options.ns?(p(e)&&(e=[e]),e.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{i.resolve(),t&&t(s)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){let i=A();p(e)&&(e=[e]);let s=this.options.preload||[],n=e.filter(r=>s.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=s.concat(n),this.loadResources(r=>{i.resolve(),t&&t(r)}),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{let s=new Intl.Locale(e);if(s&&s.getTextInfo){let n=s.getTextInfo();if(n&&n.direction)return n.direction}}catch{}let t=["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"],i=this.services?.languageUtils||new Y(X());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){let i=new o(e,t);return i.createInstance=o.createInstance,i}cloneInstance(e={},t=z){let i=e.forkResourceStore;i&&delete e.forkResourceStore;let s={...this.options,...e,isClone:!0},n=new o(s);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(a=>{n[a]=this[a]}),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){let a=Object.keys(this.store.data).reduce((l,u)=>(l[u]={...this.store.data[u]},l[u]=Object.keys(l[u]).reduce((h,f)=>(h[f]={...l[u][f]},h),l[u]),l),{});n.store=new J(a,s),n.services.resourceStore=n.store}if(e.interpolation){let l={...X().interpolation,...this.options.interpolation,...e.interpolation},u={...s,interpolation:l};n.services.interpolator=new Q(u)}return n.translator=new W(n.services,s),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(s,t),n.translator.options=s,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},ve=re.createInstance();ve.keyFromSelector=_;module.exports=ve;