document-editor-key-template
Version:
A reusable React TypeScript component
2 lines • 55.9 kB
JavaScript
/*! For license information please see index.js.LICENSE.txt */
import*as e from"react";import*as t from"@syncfusion/ej2-react-documenteditor";import*as s from"@mui/material";import*as o from"@syncfusion/ej2-base";var i={20:(e,t,s)=>{var o=s(649),i=Symbol.for("react.element"),n=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var o,n={},c=null,u=null;for(o in void 0!==s&&(c=""+s),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,o)&&!l.hasOwnProperty(o)&&(n[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===n[o]&&(n[o]=t[o]);return{$$typeof:i,type:e,key:c,ref:u,props:n,_owner:r.current}}t.Fragment=n,t.jsx=c,t.jsxs=c},649:t=>{t.exports=e},848:(e,t,s)=>{e.exports=s(20)},915:e=>{e.exports={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}}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var s=n[e]={exports:{}};return i[e](s,s.exports,a),s.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var s in t)a.o(t,s)&&!a.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r=a(848);const l=(c={DocumentEditorContainerComponent:()=>t.DocumentEditorContainerComponent,Inject:()=>t.Inject,LineWidget:()=>t.LineWidget,ParagraphWidget:()=>t.ParagraphWidget,TableCellWidget:()=>t.TableCellWidget,TextElementBox:()=>t.TextElementBox,TextPosition:()=>t.TextPosition,Toolbar:()=>t.Toolbar},u={},a.d(u,c),u);var c,u,d,p,h=a(649);!function(e){e[e.Single=0]="Single",e[e.MultiLineText=1]="MultiLineText",e[e.Table=2]="Table"}(d||(d={})),function(e){e[e.Text=0]="Text",e[e.Image=1]="Image"}(p||(p={}));const g=(e=>{var t={};return a.d(t,e),t})({Autocomplete:()=>s.Autocomplete,Button:()=>s.Button,Dialog:()=>s.Dialog,DialogActions:()=>s.DialogActions,DialogContent:()=>s.DialogContent,DialogTitle:()=>s.DialogTitle,FormControl:()=>s.FormControl,FormControlLabel:()=>s.FormControlLabel,FormLabel:()=>s.FormLabel,Grid:()=>s.Grid,Radio:()=>s.Radio,RadioGroup:()=>s.RadioGroup,TextField:()=>s.TextField});a(915),Object.create(null);const f={},m=(...e)=>{v(e[0])&&f[e[0]]||(v(e[0])&&(f[e[0]]=new Date),((...e)=>{console?.warn&&(v(e[0])&&(e[0]=`react-i18next:: ${e[0]}`),console.warn(...e))})(...e))},y=(e,t)=>()=>{if(e.isInitialized)t();else{const s=()=>{setTimeout((()=>{e.off("initialized",s)}),0),t()};e.on("initialized",s)}},x=(e,t,s)=>{e.loadNamespaces(t,y(e,s))},b=(e,t,s,o)=>{if(v(s)&&(s=[s]),e.options.preload&&e.options.preload.indexOf(t)>-1)return x(e,s,o);s.forEach((t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)})),e.loadLanguages(t,y(e,o))},v=e=>"string"==typeof e,k=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,S={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},L=e=>S[e];let O,w={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(k,L)};const C={type:"3rdParty",init(e){((e={})=>{w={...w,...e}})(e.options.react),(e=>{O=e})(e)}},$=(0,h.createContext)();class R{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const j=(e,t,s,o)=>e.getFixedT(t,s,o),N=e=>"string"==typeof e,P=()=>{let e,t;const s=new Promise(((s,o)=>{e=s,t=o}));return s.resolve=e,s.reject=t,s},T=e=>null==e?"":""+e,E=/###/g,F=e=>e&&e.indexOf("###")>-1?e.replace(E,"."):e,_=e=>!e||N(e),I=(e,t,s)=>{const o=N(t)?t.split("."):t;let i=0;for(;i<o.length-1;){if(_(e))return{};const t=F(o[i]);!e[t]&&s&&(e[t]=new s),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return _(e)?{}:{obj:e,k:F(o[i])}},D=(e,t,s)=>{const{obj:o,k:i}=I(e,t,Object);if(void 0!==o||1===t.length)return void(o[i]=s);let n=t[t.length-1],a=t.slice(0,t.length-1),r=I(e,a,Object);for(;void 0===r.obj&&a.length;)n=`${a[a.length-1]}.${n}`,a=a.slice(0,a.length-1),r=I(e,a,Object),r?.obj&&void 0!==r.obj[`${r.k}.${n}`]&&(r.obj=void 0);r.obj[`${r.k}.${n}`]=s},V=(e,t)=>{const{obj:s,k:o}=I(e,t);if(s&&Object.prototype.hasOwnProperty.call(s,o))return s[o]},A=(e,t,s)=>{for(const o in t)"__proto__"!==o&&"constructor"!==o&&(o in e?N(e[o])||e[o]instanceof String||N(t[o])||t[o]instanceof String?s&&(e[o]=t[o]):A(e[o],t[o],s):e[o]=t[o]);return e},K=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var U={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const M=e=>N(e)?e.replace(/[&<>"'\/]/g,(e=>U[e])):e,B=[" ",",","?","!",";"],H=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),W=(e,t,s=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}const o=t.split(s);let i=e;for(let e=0;e<o.length;){if(!i||"object"!=typeof i)return;let t,n="";for(let a=e;a<o.length;++a)if(a!==e&&(n+=s),n+=o[a],t=i[n],void 0!==t){if(["string","number","boolean"].indexOf(typeof t)>-1&&a<o.length-1)continue;e+=a-e+1;break}i=t}return i},z=e=>e?.replace("_","-"),J={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 G{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||J,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,s,o){return o&&!this.debug?null:(N(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new G(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new G(this.logger,e)}}var q=new G;class Y{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])}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach((([e,s])=>{for(let o=0;o<s;o++)e(...t)})),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach((([s,o])=>{for(let i=0;i<o;i++)s.apply(s,[e,...t])}))}}class Q extends Y{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.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,s,o={}){const i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,n=void 0!==o.ignoreJSONStructure?o.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],s&&(Array.isArray(s)?a.push(...s):N(s)&&i?a.push(...s.split(i)):a.push(s)));const r=V(this.data,a);return!r&&!t&&!s&&e.indexOf(".")>-1&&(e=a[0],t=a[1],s=a.slice(2).join(".")),!r&&n&&N(s)?W(this.data?.[e]?.[t],s,i):r}addResource(e,t,s,o,i={silent:!1}){const n=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(n?s.split(n):s)),e.indexOf(".")>-1&&(a=e.split("."),o=t,t=a[1]),this.addNamespaces(t),D(this.data,a,o),i.silent||this.emit("added",e,t,s,o)}addResources(e,t,s,o={silent:!1}){for(const o in s)(N(s[o])||Array.isArray(s[o]))&&this.addResource(e,t,o,s[o],{silent:!0});o.silent||this.emit("added",e,t,s)}addResourceBundle(e,t,s,o,i,n={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),o=s,s=t,t=a[1]),this.addNamespaces(t);let r=V(this.data,a)||{};n.skipCopy||(s=JSON.parse(JSON.stringify(s))),o?A(r,s,i):r={...r,...s},D(this.data,a,r),n.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 X={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,s,o,i){return e.forEach((e=>{t=this.processors[e]?.process(t,s,o,i)??t})),t}};const Z={},ee=e=>!N(e)&&"boolean"!=typeof e&&"number"!=typeof e;class te extends Y{constructor(e,t={}){var s,o;super(),s=e,o=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((e=>{s[e]&&(o[e]=s[e])})),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=q.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(null==e)return!1;const o=this.resolve(e,s);return void 0!==o?.res}extractFromKey(e,t){let s=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");const o=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator;let i=t.ns||this.options.defaultNS||[];const n=s&&e.indexOf(s)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||((e,t,s)=>{t=t||"",s=s||"";const o=B.filter((e=>t.indexOf(e)<0&&s.indexOf(e)<0));if(0===o.length)return!0;const i=H.getRegExp(`(${o.map((e=>"?"===e?"\\?":e)).join("|")})`);let n=!i.test(e);if(!n){const t=e.indexOf(s);t>0&&!i.test(e.substring(0,t))&&(n=!0)}return n})(e,s,o));if(n&&!a){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:N(i)?[i]:i};const n=e.split(s);(s!==o||s===o&&this.options.ns.indexOf(n[0])>-1)&&(i=n.shift()),e=n.join(o)}return{key:e,namespaces:N(i)?[i]:i}}translate(e,t,s){let o="object"==typeof t?{...t}:t;if("object"!=typeof o&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof options&&(o={...o}),o||(o={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);const i=void 0!==o.returnDetails?o.returnDetails:this.options.returnDetails,n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,{key:a,namespaces:r}=this.extractFromKey(e[e.length-1],o),l=r[r.length-1];let c=void 0!==o.nsSeparator?o.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");const u=o.lng||this.language,d=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===u?.toLowerCase())return d?i?{res:`${l}${c}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:`${l}${c}${a}`:i?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:a;const p=this.resolve(e,o);let h=p?.res;const g=p?.usedKey||a,f=p?.exactUsedKey||a,m=void 0!==o.joinArrays?o.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,x=void 0!==o.count&&!N(o.count),b=te.hasDefaultValue(o),v=x?this.pluralResolver.getSuffix(u,o.count,o):"",k=o.ordinal&&x?this.pluralResolver.getSuffix(u,o.count,{ordinal:!1}):"",S=x&&!o.ordinal&&0===o.count,L=S&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${v}`]||o[`defaultValue${k}`]||o.defaultValue;let O=h;y&&!h&&b&&(O=L);const w=ee(O),C=Object.prototype.toString.apply(O);if(!(y&&O&&w&&["[object Number]","[object Function]","[object RegExp]"].indexOf(C)<0)||N(m)&&Array.isArray(O))if(y&&N(m)&&Array.isArray(h))h=h.join(m),h&&(h=this.extendTranslation(h,e,o,s));else{let t=!1,i=!1;!this.isValidLookup(h)&&b&&(t=!0,h=L),this.isValidLookup(h)||(i=!0,h=a);const r=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&i?void 0:h,d=b&&L!==h&&this.options.updateMissing;if(i||t||d){if(this.logger.log(d?"updateKey":"missingKey",u,l,a,d?L:h),n){const e=this.resolve(a,{...o,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,o.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(o.lng||this.language):e.push(o.lng||this.language);const s=(e,t,s)=>{const i=b&&s!==h?s:r;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,i,d,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,i,d,o),this.emit("missingKey",e,l,t,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&x?e.forEach((e=>{const t=this.pluralResolver.getSuffixes(e,o);S&&o[`defaultValue${this.options.pluralSeparator}zero`]&&t.indexOf(`${this.options.pluralSeparator}zero`)<0&&t.push(`${this.options.pluralSeparator}zero`),t.forEach((t=>{s([e],a+t,o[`defaultValue${t}`]||L)}))})):s(e,a,L))}h=this.extendTranslation(h,e,o,p,s),i&&h===a&&this.options.appendNamespaceToMissingKey&&(h=`${l}${c}${a}`),(i||t)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${a}`:a,t?h:void 0,o))}else{if(!o.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(g,O,{...o,ns:r}):`key '${a} (${this.language})' returned an object instead of string.`;return i?(p.res=e,p.usedParams=this.getUsedParamsDetails(o),p):e}if(n){const e=Array.isArray(O),t=e?[]:{},s=e?f:g;for(const e in O)if(Object.prototype.hasOwnProperty.call(O,e)){const i=`${s}${n}${e}`;t[e]=b&&!h?this.translate(i,{...o,defaultValue:ee(L)?L[e]:void 0,joinArrays:!1,ns:r}):this.translate(i,{...o,joinArrays:!1,ns:r}),t[e]===i&&(t[e]=O[e])}h=t}}return i?(p.res=h,p.usedParams=this.getUsedParamsDetails(o),p):h}extendTranslation(e,t,s,o,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const n=N(e)&&(void 0!==s?.interpolation?.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let a;if(n){const t=e.match(this.interpolator.nestingRegexp);a=t&&t.length}let r=s.replace&&!N(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),e=this.interpolator.interpolate(e,r,s.lng||this.language||o.usedLng,s),n){const t=e.match(this.interpolator.nestingRegexp);a<(t&&t.length)&&(s.nest=!1)}!s.lng&&o&&o.res&&(s.lng=this.language||o.usedLng),!1!==s.nest&&(e=this.interpolator.nest(e,((...e)=>i?.[0]!==e[0]||s.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null)),s)),s.interpolation&&this.interpolator.reset()}const n=s.postProcess||this.options.postProcess,a=N(n)?[n]:n;return null!=e&&a?.length&&!1!==s.applyPostProcessor&&(e=X.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e,t={}){let s,o,i,n,a;return N(e)&&(e=[e]),e.forEach((e=>{if(this.isValidLookup(s))return;const r=this.extractFromKey(e,t),l=r.key;o=l;let c=r.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const u=void 0!==t.count&&!N(t.count),d=u&&!t.ordinal&&0===t.count,p=void 0!==t.context&&(N(t.context)||"number"==typeof t.context)&&""!==t.context,h=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);c.forEach((e=>{this.isValidLookup(s)||(a=e,Z[`${h[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(a)||(Z[`${h[0]}-${e}`]=!0,this.logger.warn(`key "${o}" for languages "${h.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!!!")),h.forEach((o=>{if(this.isValidLookup(s))return;n=o;const a=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(a,l,o,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(o,t.count,t));const s=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(a.push(l+e),t.ordinal&&0===e.indexOf(i)&&a.push(l+e.replace(i,this.options.pluralSeparator)),d&&a.push(l+s)),p){const o=`${l}${this.options.contextSeparator}${t.context}`;a.push(o),u&&(a.push(o+e),t.ordinal&&0===e.indexOf(i)&&a.push(o+e.replace(i,this.options.pluralSeparator)),d&&a.push(o+s))}}let r;for(;r=a.pop();)this.isValidLookup(s)||(i=r,s=this.getResource(o,e,r,t))})))}))})),{res:s,usedKey:o,exactUsedKey:i,usedLng:n,usedNS:a}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,s,o={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,o):this.resourceStore.getResource(e,t,s,o)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!N(e.replace);let o=s?e.replace:e;if(s&&void 0!==e.count&&(o.count=e.count),this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),!s){o={...o};for(const e of t)delete o[e]}return o}static hasDefaultValue(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&"defaultValue"===t.substring(0,12)&&void 0!==e[t])return!0;return!1}}class se{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=q.create("languageUtils")}getScriptPartFromCode(e){if(!(e=z(e))||e.indexOf("-")<0)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=z(e))||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(N(e)&&e.indexOf("-")>-1){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.indexOf(e)>-1}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 o=this.getLanguagePartFromCode(e);if(this.isSupportedCode(o))return t=o;t=this.options.supportedLngs.find((e=>e===o?e:e.indexOf("-")<0&&o.indexOf("-")<0?void 0:e.indexOf("-")>0&&o.indexOf("-")<0&&e.substring(0,e.indexOf("-"))===o||0===e.indexOf(o)&&o.length>1?e:void 0))})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),N(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}toResolveHierarchy(e,t){const s=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),o=[],i=e=>{e&&(this.isSupportedCode(e)?o.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return N(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&i(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&i(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&i(this.getLanguagePartFromCode(e))):N(e)&&i(this.formatLanguageCode(e)),s.forEach((e=>{o.indexOf(e)<0&&i(this.formatLanguageCode(e))})),o}}const oe={zero:0,one:1,two:2,few:3,many:4,other:5},ie={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class ne{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=q.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=z("dev"===e?"en":e),o=t.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:s,type:o});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let n;try{n=new Intl.PluralRules(s,{type:o})}catch(s){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ie;if(!e.match(/-|_/))return ie;const o=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(o,t)}return this.pluralRulesCache[i]=n,n}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)=>oe[e]-oe[t])).map((e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`)):[]}getSuffix(e,t,s={}){const o=this.getRule(e,s);return o?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${o.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const ae=(e,t,s,o=".",i=!0)=>{let n=((e,t,s)=>{const o=V(e,s);return void 0!==o?o:V(t,s)})(e,t,s);return!n&&i&&N(s)&&(n=W(e,s,o),void 0===n&&(n=W(t,s,o))),n},re=e=>e.replace(/\$/g,"$$$$");class le{constructor(e={}){this.logger=q.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:o,prefix:i,prefixEscaped:n,suffix:a,suffixEscaped:r,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:p,nestingSuffix:h,nestingSuffixEscaped:g,nestingOptionsSeparator:f,maxReplaces:m,alwaysFormat:y}=e.interpolation;this.escape=void 0!==t?t:M,this.escapeValue=void 0===s||s,this.useRawValueToEscape=void 0!==o&&o,this.prefix=i?K(i):n||"{{",this.suffix=a?K(a):r||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=d?K(d):p||K("$t("),this.nestingSuffix=h?K(h):g||K(")"),this.nestingOptionsSeparator=f||",",this.maxReplaces=m||1e3,this.alwaysFormat=void 0!==y&&y,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,s,o){let i,n,a;const r=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(e.indexOf(this.formatSeparator)<0){const i=ae(t,r,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,s,{...o,...t,interpolationkey:e}):i}const i=e.split(this.formatSeparator),n=i.shift().trim(),a=i.join(this.formatSeparator).trim();return this.format(ae(t,r,n,this.options.keySeparator,this.options.ignoreJSONStructure),a,s,{...o,...t,interpolationkey:n})};this.resetRegExp();const c=o?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=void 0!==o?.interpolation?.skipOnVariables?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>re(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?re(this.escape(e)):re(e)}].forEach((t=>{for(a=0;i=t.regex.exec(e);){const s=i[1].trim();if(n=l(s),void 0===n)if("function"==typeof c){const t=c(e,i,o);n=N(t)?t:""}else if(o&&Object.prototype.hasOwnProperty.call(o,s))n="";else{if(u){n=i[0];continue}this.logger.warn(`missed to pass in variable ${s} for interpolating ${e}`),n=""}else N(n)||this.useRawValueToEscape||(n=T(n));const r=t.safeValue(n);if(e=e.replace(i[0],r),u?(t.regex.lastIndex+=n.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,a++,a>=this.maxReplaces)break}})),e}nest(e,t,s={}){let o,i,n;const a=(e,t)=>{const s=this.nestingOptionsSeparator;if(e.indexOf(s)<0)return e;const o=e.split(new RegExp(`${s}[ ]*{`));let i=`{${o[1]}`;e=o[0],i=this.interpolate(i,n);const a=i.match(/'/g),r=i.match(/"/g);((a?.length??0)%2==0&&!r||r.length%2!=0)&&(i=i.replace(/'/g,'"'));try{n=JSON.parse(i),t&&(n={...t,...n})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${s}${i}`}return n.defaultValue&&n.defaultValue.indexOf(this.prefix)>-1&&delete n.defaultValue,e};for(;o=this.nestingRegexp.exec(e);){let r=[];n={...s},n=n.replace&&!N(n.replace)?n.replace:n,n.applyPostProcessor=!1,delete n.defaultValue;let l=!1;if(-1!==o[0].indexOf(this.formatSeparator)&&!/{.*}/.test(o[1])){const e=o[1].split(this.formatSeparator).map((e=>e.trim()));o[1]=e.shift(),r=e,l=!0}if(i=t(a.call(this,o[1].trim(),n),n),i&&o[0]===e&&!N(i))return i;N(i)||(i=T(i)),i||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${e}`),i=""),l&&(i=r.reduce(((e,t)=>this.format(e,t,s.lng,{...s,interpolationkey:o[1].trim()})),i.trim())),e=e.replace(o[0],i),this.regexp.lastIndex=0}return e}}const ce=e=>{const t={};return(s,o,i)=>{let n=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(n={...n,[i.interpolationkey]:void 0});const a=o+JSON.stringify(n);let r=t[a];return r||(r=e(z(o),i),t[a]=r),r(s)}},ue=e=>(t,s,o)=>e(z(s),o)(t);class de{constructor(e={}){this.logger=q.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?ce:ue;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()]=ce(t)}format(e,t,s,o={}){const i=t.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find((e=>e.indexOf(")")>-1))){const e=i.findIndex((e=>e.indexOf(")")>-1));i[0]=[i[0],...i.splice(1,e)].join(this.formatSeparator)}return i.reduce(((e,t)=>{const{formatName:i,formatOptions:n}=(e=>{let t=e.toLowerCase().trim();const s={};if(e.indexOf("(")>-1){const o=e.split("(");t=o[0].toLowerCase().trim();const i=o[1].substring(0,o[1].length-1);"currency"===t&&i.indexOf(":")<0?s.currency||(s.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?s.range||(s.range=i.trim()):i.split(";").forEach((e=>{if(e){const[t,...o]=e.split(":"),i=o.join(":").trim().replace(/^'+|'+$/g,""),n=t.trim();s[n]||(s[n]=i),"false"===i&&(s[n]=!1),"true"===i&&(s[n]=!0),isNaN(i)||(s[n]=parseInt(i,10))}}))}return{formatName:t,formatOptions:s}})(t);if(this.formats[i]){let t=e;try{const a=o?.formatParams?.[o.interpolationkey]||{},r=a.locale||a.lng||o.locale||o.lng||s;t=this.formats[i](e,r,{...n,...o,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e}),e)}}class pe extends Y{constructor(e,t,s,o={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=o,this.logger=q.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=o.maxParallelReads||10,this.readingCalls=0,this.maxRetries=o.maxRetries>=0?o.maxRetries:5,this.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,o.backend,o)}queueLoad(e,t,s,o){const i={},n={},a={},r={};return e.forEach((e=>{let o=!0;t.forEach((t=>{const a=`${e}|${t}`;!s.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===n[a]&&(n[a]=!0):(this.state[a]=1,o=!1,void 0===n[a]&&(n[a]=!0),void 0===i[a]&&(i[a]=!0),void 0===r[t]&&(r[t]=!0)))})),o||(a[e]=!0)})),(Object.keys(i).length||Object.keys(n).length)&&this.queue.push({pending:n,pendingCount:Object.keys(n).length,loaded:{},errors:[],callback:o}),{toLoad:Object.keys(i),pending:Object.keys(n),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(r)}}loaded(e,t,s){const o=e.split("|"),i=o[0],n=o[1];t&&this.emit("failedLoading",i,n,t),!t&&s&&this.store.addResourceBundle(i,n,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach((s=>{((e,t,s)=>{const{obj:o,k:i}=I(e,t,Object);o[i]=o[i]||[],o[i].push(s)})(s.loaded,[i],n),((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=>{a[e]||(a[e]={});const t=s.loaded[e];t.length&&t.forEach((t=>{void 0===a[e][t]&&(a[e][t]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",a),this.queue=this.queue.filter((e=>!e.done))}read(e,t,s,o=0,i=this.retryTimeout,n){if(!e.length)return n(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:s,tried:o,wait:i,callback:n});this.readingCalls++;const a=(a,r)=>{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)}a&&r&&o<this.maxRetries?setTimeout((()=>{this.read.call(this,e,t,s,o+1,2*i,n)}),i):n(a,r)},r=this.backend[s].bind(this.backend);if(2!==r.length)return r(e,t,a);try{const s=r(e,t);s&&"function"==typeof s.then?s.then((e=>a(null,e))).catch(a):a(null,s)}catch(e){a(e)}}prepareLoading(e,t,s={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();N(e)&&(e=this.languageUtils.toResolveHierarchy(e)),N(t)&&(t=[t]);const i=this.queueLoad(e,t,s,o);if(!i.toLoad.length)return i.pending.length||o(),null;i.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("|"),o=s[0],i=s[1];this.read(o,i,"read",void 0,void 0,((s,n)=>{s&&this.logger.warn(`${t}loading namespace ${i} for language ${o} failed`,s),!s&&n&&this.logger.log(`${t}loaded namespace ${i} for language ${o}`,n),this.loaded(e,s,n)}))}saveMissing(e,t,s,o,i,n={},a=()=>{}){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(t)){if(null!=s&&""!==s){if(this.backend?.create){const r={...n,isUpdate:i},l=this.backend.create.bind(this.backend);if(l.length<6)try{let i;i=5===l.length?l(e,t,s,o,r):l(e,t,s,o),i&&"function"==typeof i.then?i.then((e=>a(null,e))).catch(a):a(null,i)}catch(e){a(e)}else l(e,t,s,o,a,r)}e&&e[0]&&this.store.addResource(e[0],t,s,o)}}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 he=()=>({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:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),N(e[1])&&(t.defaultValue=e[1]),N(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,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),ge=e=>(N(e.ns)&&(e.ns=[e.ns]),N(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),N(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),fe=()=>{};class me extends Y{constructor(e={},t){var s;if(super(),this.options=ge(e),this.services={},this.logger=q,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&&(N(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=he();this.options={...s,...this.options,...ge(e)},this.options.interpolation={...s.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);const o=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?q.init(o(this.modules.logger),this.options):q.init(null,this.options),e=this.modules.formatter?this.modules.formatter:de;const t=new se(this.options);this.store=new Q(this.options.resources,this.options);const i=this.services;i.logger=q,i.resourceStore=this.store,i.languageUtils=t,i.pluralResolver=new ne(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!e||this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format||(i.formatter=o(e),i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new le(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new pe(o(this.modules.backend),i.resourceStore,i,this.options),i.backendConnector.on("*",((e,...t)=>{this.emit(e,...t)})),this.modules.languageDetector&&(i.languageDetector=o(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=o(this.modules.i18nFormat),i.i18nFormat.init&&i.i18nFormat.init(this)),this.translator=new te(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=fe),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 i=P(),n=()=>{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),i.resolve(s),t(e,s)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?n():setTimeout(n,0),i}loadResources(e,t=fe){let s=t;const o=N(e)?e:this.language;if("function"==typeof e&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===o?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return s();const e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach((t=>{"cimode"!==t&&e.indexOf(t)<0&&e.push(t)}))};o?t(o):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),s(e)}))}else s(null)}reloadResources(e,t,s){const o=P();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=fe),this.services.backendConnector.reload(e,t,(e=>{o.resolve(),s(e)})),o}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&&X.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"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const s=P();this.emit("languageChanging",e);const o=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,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,s.resolve(((...e)=>this.t(...e))),t&&t(i,((...e)=>this.t(...e)))},n=t=>{e||t||!this.services.languageDetector||(t=[]);const s=N(t)?t:t&&t[0],n=this.store.hasLanguageSomeTranslations(s)?s:this.services.languageUtils.getBestMatchFromCodes(N(t)?[t]:t);n&&(this.language||o(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,(e=>{i(e,n)}))};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(n):this.services.languageDetector.detect(n):n(e):n(this.services.languageDetector.detect()),s}getFixedT(e,t,s){const o=(e,t,...i)=>{let n;n="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(i)):{...t},n.lng=n.lng||o.lng,n.lngs=n.lngs||o.lngs,n.ns=n.ns||o.ns,""!==n.keyPrefix&&(n.keyPrefix=n.keyPrefix||s||o.keyPrefix);const a=this.options.keySeparator||".";let r;return r=n.keyPrefix&&Array.isArray(e)?e.map((e=>`${n.keyPrefix}${a}${e}`)):n.keyPrefix?`${n.keyPrefix}${a}${e}`:e,this.t(r,n)};return N(e)?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=s,o}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],o=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const n=(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,n);if(void 0!==e)return e}return!(!this.hasResourceBundle(s,e)&&this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages)&&(!n(s,e)||o&&!n(i,e)))}loadNamespaces(e,t){const s=P();return this.options.ns?(N(e)&&(e=[e]),e.forEach((e=>{this.options.ns.indexOf(e)<0&&this.options.ns.push(e)})),this.loadResources((e=>{s.resolve(),t&&t(e)})),s):(t&&t(),Promise.resolve())}loadLanguages(e,t){const s=P();N(e)&&(e=[e]);const o=this.options.preload||[],i=e.filter((e=>o.indexOf(e)<0&&this.services.languageUtils.isSupportedCode(e)));return i.length?(this.options.preload=o.concat(i),this.loadResources((e=>{s.resolve(),t&&t(e)})),s):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";const t=this.services?.languageUtils||new se(he());return["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"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new me(e,t)}cloneInstance(e={},t=fe){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const o={...this.options,...e,isClone:!0},i=new me(o);if(void 0===e.debug&&void 0===e.prefix||(i.logger=i.logger.clone(e)),["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,o)=>(s[o]={...e[t][o]},s)),e[t]),e)),{});i.store=new Q(e,o),i.services.resourceStore=i.store}return i.translator=new te(i.services,o),i.translator.on("*",((e,...t)=>{i.emit(e,...t)})),i.init(o,t),i.translator.options=o,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 ye=me.createInstance();ye.createInstance=me.createInstance,ye.createInstance,ye.dir,ye.init,ye.loadResources,ye.reloadResources,ye.use,ye.changeLanguage,ye.getFixedT,ye.t,ye.exists,ye.setDefaultNamespace,ye.hasLoadedNamespace,ye.loadNamespaces,ye.loadLanguages;const xe=JSON.parse('{"document_message":{"document_not_found":"Document not found","document_load_failed":"Document load failed","document_save_success":"Document saved successfully","document_save_failed":"Document save failed"},"dialog_add_key":{"title":"Add Key","description":"Add a new key to the document","key":"Key","type":"Type","dataInsertType":"Data Insert Type","single_key":"Single Key","table_key":"Table Key","text":"Text","image":"Image"},"common":{"cancel":"Cancel","save":"Save","close":"Close","delete":"Delete","edit":"Edit","add":"Add"}}'),be=JSON.parse('{"document_message":{"document_not_found":"Tài liệu không tồn tại","document_load_failed":"Tài liệu không thể tải lên","document_save_success":"Tài liệu đã được lưu thành công","document_save_failed":"Tài liệu không thể lưu"},"dialog_add_key":{"title":"Thêm Khóa","description":"Thêm một khóa mới vào tài liệu","key":"Khóa","type":"Loại","dataInsertType":"Loại Chèn Dữ Liệu","single_key":"Khóa Đơn","table_key":"Khóa Bảng","text":"Văn Bản","image":"Hình Ảnh"},"common":{"cancel":"Hủy","save":"Lưu","close":"Đóng","delete":"Xóa","edit":"Sửa","add":"Thêm"}}');ye.use(C).init({resources:{en:{translation:xe},vi:{translation:be}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const ve=ye;const ke=(0,h.forwardRef)((({file:e,defaultKeys:t,language:s="en",callbackAddKey:o,callbackSaveFile:i,callbackCreated:n},a)=>{const{t:c}=((e,t={})=>{const{i18n:s}=t,{i18n:o,defaultNS:i}=(0,h.useContext)($)||{},n=s||o||O;if(n&&!n.reportNamespaces&&(n.reportNamespaces=new R),!n){m("You will need to pass in an i18next instance by using initReactI18next");const e=(e,t)=>{return v(t)?t:"object"==typeof(s=t)&&null!==s&&v(t.defaultValue)?t.defaultValue:Array.isArray(e)?e[e.length-1]:e;var s},t=[e,{},!1];return t.t=e,t.i18n={},t.ready=!1,t}n.options.react?.wait&&m("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...w,...n.options.react,...t},{useSuspense:r,keyPrefix:l}=a;let c=e||i||n.options?.defaultNS;c=v(c)?[c]:c||["translation"],n.reportNamespaces.addUsedNamespaces?.(c);const u=(n.isInitialized||n.initializedStoreOnce)&&c.every((e=>((e,t,s={})=>t.languages&&t.languages.length?t.hasLoadedNamespace(e,{lng:s.lng,precheck:(t,o)=>{if(s.bindI18n?.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!o(t.isLanguageChangingTo,e))return!1}}):(m("i18n.languages were undefined or empty",t.languages),!0))(e,n,a))),d=((e,t,s,o)=>(0,h.useCallback)(j(e,t,s,o),[e,t,s,o]))(n,t.lng||null,"fallback"===a.nsMode?c:c[0],l),p=()=>d,g=()=>j(n,t.lng||null,"fallback"===a.nsMode?c:c[0],l),[f,y]=(0,h.useState)(p);let k=c.join();t.lng&&(k=`${t.lng}${k}`);const S=((e,t)=>{const s=(0,h.useRef)();return(0,h.useEffect)((()=>{s.current=e}),[e,t]),s.current})(k),L=(0,h.useRef)(!0);(0,h.useEffect)((()=>{const{bindI18n:e,bindI18nStore:s}=a;L.current=!0,u||r||(t.lng?b(n,t.lng,c,(()=>{L.current&&y(g)})):x(n,c,(()=>{L.current&&y(g)}))),u&&S&&S!==k&&L.current&&y(g);const o=()=>{L.current&&y(g)};return e&&n?.on(e,o),s&&n?.store.on(s,o),()=>{L.current=!1,n&&e?.split(" ").forEach((e=>n.off(e,o))),s&&n&&s.split(" ").forEach((e=>n.store.off(e,o)))}}),[n,k]),(0,h.useEffect)((()=>{L.current&&u&&y(p)}),[n,l,u]);const C=[f,n,u];if(C.t=f,C.i18n=n,C.ready=u,u)return C;if(!u&&!r)return C;throw new Promise((e=>{t.lng?b(n,t.lng,c,(()=>e())):x(n,c,(()=>e()))}))})(),u=(0,h.useRef)(null),[f,y]=(0,h.useState)(!1),[k,S]=(0,h.useState)(null),[L,C]=(0,h.useState)(t),[N,P]=(0,h.useState)(!1);(0,h.useImperativeHandle)(a,(()=>({isDocumentLoaded:()=>N,getAllKeys:()=>{var e;if(!N)throw new Error(`${c("document_message.document_not_found")}`);return(null===(e=u.current)||void 0===e?void 0:e.documentEditor)?T(u.current.documentEditor):[]}}))),(0,h.useEffect)((()=>{setTimeout((()=>{u.current&&u.current.toolbarModule&&u.current.toolbarModule.toolbar&&u.current.toolbarModule.toolbar.addItems([{id:"dpu-save",text:`${c("common.save")}`,prefixIcon:"e-save",tooltipText:`${c("common.save")}`}])}),5e3)}),[]),(0,h.useEffect)((()=>{var t,s,o,i;u.current&&u.current.documentEditor&&e&&(t=void 0,s=void 0,i=function*(){if("string"==typeof e){const t=yield fetch(e),s=yield t.blob();u.current&&u.current.documentEditor&&u.current.documentEditor.open(s)}else u.current&&u.current.documentEditor&&u.current.documentEditor.open(e)},new((o=void 0)||(o=Promise))((function(e,n){function a(e){try{l(i.next(e))}catch(e){n(e)}}function r(e){try{l(i.throw(e))}catch(e){n(e)}}function l(t){var s;t.done?e(t.value):(s=t.value,s instanceof o?s:new o((function(e){e(s)}))).then(a,r)}l((i=i.apply(t,s||[])).next())})))}),[e]),(0,h.useEffect)((()=>{ve.changeLanguage(s)}),[s]);const T=e=>{const t=(e=>{const t=[];e.selection.selectAll();const s=e.selection.text;e.selection.moveToDocumentEnd();let o=s.match(/\{\{([^:{}\s]+)\}\}/g);if(o)for(const e of o){const s=e.replace("{{","").replace("}}","");t.push({key:s,type:d.Single})}return t})(e),s=(e=>{const t=/\{\{(.*?):(.*?)\}\}/,s=[],o=(e=>{var t,s;const o=[]