@nemme/js-sdk 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,5 +35,5 @@
35
35
 
36
36
  `).split(`
37
37
 
38
- `).map((i,o)=>k.jsx(X,{children:i.trim()},o))]}),a]}),r&&k.jsx("div",{className:"flex flex-col justify-center order-1 md:order-2",children:k.jsx("div",{className:"rounded-lg overflow-hidden mb-6 md:mb-0",children:k.jsx("img",{className:"w-full h-full object-cover aspect-video md:aspect-square",src:r,alt:"image"})})})]}),Zr=({title:n,icon:e,description:t,image:r,quitText:a,onQuit:s,externalLink:i})=>k.jsxs(xt,{title:n,icon:e,description:t,image:r,children:[k.jsx("div",{className:"flex justify-end gap-2",children:i?k.jsx(J,{variant:"secondary",text:a,iconAfter:k.jsx(Xe,{}),onClick:()=>{window.open(i,"_blank"),s()}}):k.jsx(J,{variant:"secondary",onClick:s,text:a})}),i&&k.jsx(J,{className:"absolute -top-2 -right-2 md:-top-4 md:-right-4",variant:"secondary",size:"small",onClick:s,iconAfter:k.jsx(he,{}),"aria-label":"quit"})]}),Gr=({title:n,icon:e,description:t,image:r,quitText:a,onQuit:s,startText:i,onStart:o})=>k.jsxs(xt,{title:n,icon:e,description:t,image:r,wrapperClassName:"relative",children:[k.jsxs("div",{className:"flex justify-end gap-2",children:[s&&a&&k.jsx(J,{variant:"subtle",text:a,onClick:s}),k.jsx(J,{variant:"secondary",text:i,onClick:o})]}),s&&k.jsx(J,{className:"absolute top-0 right-1 md:top-1",variant:"subtle",size:"small",onClick:s,iconAfter:k.jsx(he,{}),"aria-label":"quit"})]});let wt={};function Yr(){return wt}function Jr(n){wt=n}const Xr={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Qr=(n,e,t)=>{let r;const a=Xr[n];return typeof a=="string"?r=a:e===1?r=a.one:r=a.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+r:r+" ago":r};function je(n){return(e={})=>{const t=e.width?String(e.width):n.defaultWidth;return n.formats[t]||n.formats[n.defaultWidth]}}const ea={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ta=(n,e,t,r)=>ea[n];function ce(n){return(e,t)=>{const r=t?.context?String(t.context):"standalone";let a;if(r==="formatting"&&n.formattingValues){const i=n.defaultFormattingWidth||n.defaultWidth,o=t?.width?String(t.width):i;a=n.formattingValues[o]||n.formattingValues[i]}else{const i=n.defaultWidth,o=t?.width?String(t.width):n.defaultWidth;a=n.values[o]||n.values[i]}const s=n.argumentCallback?n.argumentCallback(e):e;return a[s]}}const na={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ra={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},aa={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},sa={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ia={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},oa={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},la={ordinalNumber:(n,e)=>{const t=Number(n),r=t%100;if(r>20||r<10)switch(r%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:ce({values:na,defaultWidth:"wide"}),quarter:ce({values:ra,defaultWidth:"wide",argumentCallback:n=>n-1}),month:ce({values:aa,defaultWidth:"wide"}),day:ce({values:sa,defaultWidth:"wide"}),dayPeriod:ce({values:ia,defaultWidth:"wide",formattingValues:oa,defaultFormattingWidth:"wide"})};function ue(n){return(e,t={})=>{const r=t.width,a=r&&n.matchPatterns[r]||n.matchPatterns[n.defaultMatchWidth],s=e.match(a);if(!s)return null;const i=s[0],o=r&&n.parsePatterns[r]||n.parsePatterns[n.defaultParseWidth],c=Array.isArray(o)?ua(o,d=>d.test(i)):ca(o,d=>d.test(i));let l;l=n.valueCallback?n.valueCallback(c):c,l=t.valueCallback?t.valueCallback(l):l;const u=e.slice(i.length);return{value:l,rest:u}}}function ca(n,e){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&e(n[t]))return t}function ua(n,e){for(let t=0;t<n.length;t++)if(e(n[t]))return t}function da(n){return(e,t={})=>{const r=e.match(n.matchPattern);if(!r)return null;const a=r[0],s=e.match(n.parsePattern);if(!s)return null;let i=n.valueCallback?n.valueCallback(s[0]):s[0];i=t.valueCallback?t.valueCallback(i):i;const o=e.slice(a.length);return{value:i,rest:o}}}const pa=/^(\d+)(th|st|nd|rd)?/i,ga=/\d+/i,fa={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ha={any:[/^b/i,/^(a|c)/i]},ma={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ya={any:[/1/i,/2/i,/3/i,/4/i]},ba={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},xa={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},wa={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},va={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},ka={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Sa={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ea={ordinalNumber:da({matchPattern:pa,parsePattern:ga,valueCallback:n=>parseInt(n,10)}),era:ue({matchPatterns:fa,defaultMatchWidth:"wide",parsePatterns:ha,defaultParseWidth:"any"}),quarter:ue({matchPatterns:ma,defaultMatchWidth:"wide",parsePatterns:ya,defaultParseWidth:"any",valueCallback:n=>n+1}),month:ue({matchPatterns:ba,defaultMatchWidth:"wide",parsePatterns:xa,defaultParseWidth:"any"}),day:ue({matchPatterns:wa,defaultMatchWidth:"wide",parsePatterns:va,defaultParseWidth:"any"}),dayPeriod:ue({matchPatterns:ka,defaultMatchWidth:"any",parsePatterns:Sa,defaultParseWidth:"any"})};function La(n){const e={},t=Yr();for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]===void 0?delete e[r]:e[r]=n[r]);Jr(e)}const Fa={full:"EEEE, d MMMM yyyy",long:"d MMMM yyyy",medium:"d MMM yyyy",short:"dd/MM/yyyy"},Aa={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Oa={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Na={date:je({formats:Fa,defaultWidth:"full"}),time:je({formats:Aa,defaultWidth:"full"}),dateTime:je({formats:Oa,defaultWidth:"full"})},Ta={code:"en-GB",formatDistance:Qr,formatLong:Na,formatRelative:ta,localize:la,match:Ea,options:{weekStartsOn:1,firstWeekContainsDate:4}},L=n=>typeof n=="string",de=()=>{let n,e;const t=new Promise((r,a)=>{n=r,e=a});return t.resolve=n,t.reject=e,t},vt=n=>n==null?"":""+n,Ra=(n,e,t)=>{n.forEach(r=>{e[r]&&(t[r]=e[r])})},Ca=/###/g,kt=n=>n&&n.indexOf("###")>-1?n.replace(Ca,"."):n,St=n=>!n||L(n),pe=(n,e,t)=>{const r=L(e)?e.split("."):e;let a=0;for(;a<r.length-1;){if(St(n))return{};const s=kt(r[a]);!n[s]&&t&&(n[s]=new t),Object.prototype.hasOwnProperty.call(n,s)?n=n[s]:n={},++a}return St(n)?{}:{obj:n,k:kt(r[a])}},Et=(n,e,t)=>{const{obj:r,k:a}=pe(n,e,Object);if(r!==void 0||e.length===1){r[a]=t;return}let s=e[e.length-1],i=e.slice(0,e.length-1),o=pe(n,i,Object);for(;o.obj===void 0&&i.length;)s=`${i[i.length-1]}.${s}`,i=i.slice(0,i.length-1),o=pe(n,i,Object),o?.obj&&typeof o.obj[`${o.k}.${s}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${s}`]=t},Pa=(n,e,t,r)=>{const{obj:a,k:s}=pe(n,e,Object);a[s]=a[s]||[],a[s].push(t)},we=(n,e)=>{const{obj:t,k:r}=pe(n,e);if(t&&Object.prototype.hasOwnProperty.call(t,r))return t[r]},ja=(n,e,t)=>{const r=we(n,t);return r!==void 0?r:we(e,t)},Lt=(n,e,t)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in n?L(n[r])||n[r]instanceof String||L(e[r])||e[r]instanceof String?t&&(n[r]=e[r]):Lt(n[r],e[r],t):n[r]=e[r]);return n},te=n=>n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ia={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Da=n=>L(n)?n.replace(/[&<>"'\/]/g,e=>Ia[e]):n;class _a{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const $a=[" ",",","?","!",";"],Ma=new _a(20),Ba=(n,e,t)=>{e=e||"",t=t||"";const r=$a.filter(i=>e.indexOf(i)<0&&t.indexOf(i)<0);if(r.length===0)return!0;const a=Ma.getRegExp(`(${r.map(i=>i==="?"?"\\?":i).join("|")})`);let s=!a.test(n);if(!s){const i=n.indexOf(t);i>0&&!a.test(n.substring(0,i))&&(s=!0)}return s},Ie=(n,e,t=".")=>{if(!n)return;if(n[e])return Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;const r=e.split(t);let a=n;for(let s=0;s<r.length;){if(!a||typeof a!="object")return;let i,o="";for(let c=s;c<r.length;++c)if(c!==s&&(o+=t),o+=r[c],i=a[o],i!==void 0){if(["string","number","boolean"].indexOf(typeof i)>-1&&c<r.length-1)continue;s+=c-s+1;break}a=i}return a},ge=n=>n?.replace("_","-"),za={type:"logger",log(n){this.output("log",n)},warn(n){this.output("warn",n)},error(n){this.output("error",n)},output(n,e){console?.[n]?.apply?.(console,e)}};let Ua=class Ue{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||za,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,r,a){return a&&!this.debug?null:(L(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new Ue(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Ue(this.logger,e)}};var G=new Ua;class ve{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const a=this.observers[r].get(t)||0;this.observers[r].set(t,a+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(([a,s])=>{for(let i=0;i<s;i++)a(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([a,s])=>{for(let i=0;i<s;i++)a.apply(a,[e,...t])})}}class Ft extends ve{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,a={}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,i=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],r&&(Array.isArray(r)?o.push(...r):L(r)&&s?o.push(...r.split(s)):o.push(r)));const c=we(this.data,o);return!c&&!t&&!r&&e.indexOf(".")>-1&&(e=o[0],t=o[1],r=o.slice(2).join(".")),c||!i||!L(r)?c:Ie(this.data?.[e]?.[t],r,s)}addResource(e,t,r,a,s={silent:!1}){const i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let o=[e,t];r&&(o=o.concat(i?r.split(i):r)),e.indexOf(".")>-1&&(o=e.split("."),a=t,t=o[1]),this.addNamespaces(t),Et(this.data,o,a),s.silent||this.emit("added",e,t,r,a)}addResources(e,t,r,a={silent:!1}){for(const s in r)(L(r[s])||Array.isArray(r[s]))&&this.addResource(e,t,s,r[s],{silent:!0});a.silent||this.emit("added",e,t,r)}addResourceBundle(e,t,r,a,s,i={silent:!1,skipCopy:!1}){let o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),a=r,r=t,t=o[1]),this.addNamespaces(t);let c=we(this.data,o)||{};i.skipCopy||(r=JSON.parse(JSON.stringify(r))),a?Lt(c,r,s):c={...c,...r},Et(this.data,o,c),i.silent||this.emit("added",e,t,r)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(a=>t[a]&&Object.keys(t[a]).length>0)}toJSON(){return this.data}}var At={processors:{},addPostProcessor(n){this.processors[n.name]=n},handle(n,e,t,r,a){return n.forEach(s=>{e=this.processors[s]?.process(e,t,r,a)??e}),e}};const Ot=Symbol("i18next/PATH_KEY");function Va(){const n=[],e=Object.create(null);let t;return e.get=(r,a)=>(t?.revoke?.(),a===Ot?n:(n.push(a),t=Proxy.revocable(r,e),t.proxy)),Proxy.revocable(Object.create(null),e).proxy}function De(n,e){const{[Ot]:t}=n(Va());return t.join(e?.keySeparator??".")}const Nt={},Tt=n=>!L(n)&&typeof n!="boolean"&&typeof n!="number";class ke extends ve{constructor(e,t={}){super(),Ra(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=G.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const r={...t};return e==null?!1:this.resolve(e,r)?.res!==void 0}extractFromKey(e,t){let r=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const a=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let s=t.ns||this.options.defaultNS||[];const i=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Ba(e,r,a);if(i&&!o){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:L(s)?[s]:s};const l=e.split(r);(r!==a||r===a&&this.options.ns.indexOf(l[0])>-1)&&(s=l.shift()),e=l.join(a)}return{key:e,namespaces:L(s)?[s]:s}}translate(e,t,r){let a=typeof t=="object"?{...t}:t;if(typeof a!="object"&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a=="object"&&(a={...a}),a||(a={}),e==null)return"";typeof e=="function"&&(e=De(e,{...this.options,...a})),Array.isArray(e)||(e=[String(e)]);const s=a.returnDetails!==void 0?a.returnDetails:this.options.returnDetails,i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],a),l=c[c.length-1];let u=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const d=a.lng||this.language,h=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()==="cimode")return h?s?{res:`${l}${u}${o}`,usedKey:o,exactUsedKey:o,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:`${l}${u}${o}`:s?{res:o,usedKey:o,exactUsedKey:o,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:o;const m=this.resolve(e,a);let p=m?.res;const g=m?.usedKey||o,f=m?.exactUsedKey||o,x=["[object Number]","[object Function]","[object RegExp]"],b=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,S=a.count!==void 0&&!L(a.count),E=ke.hasDefaultValue(a),O=S?this.pluralResolver.getSuffix(d,a.count,a):"",A=a.ordinal&&S?this.pluralResolver.getSuffix(d,a.count,{ordinal:!1}):"",P=S&&!a.ordinal&&a.count===0,T=P&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${O}`]||a[`defaultValue${A}`]||a.defaultValue;let R=p;v&&!p&&E&&(R=T);const q=Tt(R),V=Object.prototype.toString.apply(R);if(v&&R&&q&&x.indexOf(V)<0&&!(L(b)&&Array.isArray(R))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const z=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,R,{...a,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return s?(m.res=z,m.usedParams=this.getUsedParamsDetails(a),m):z}if(i){const z=Array.isArray(R),N=z?[]:{},U=z?f:g;for(const I in R)if(Object.prototype.hasOwnProperty.call(R,I)){const _=`${U}${i}${I}`;E&&!p?N[I]=this.translate(_,{...a,defaultValue:Tt(T)?T[I]:void 0,joinArrays:!1,ns:c}):N[I]=this.translate(_,{...a,joinArrays:!1,ns:c}),N[I]===_&&(N[I]=R[I])}p=N}}else if(v&&L(b)&&Array.isArray(p))p=p.join(b),p&&(p=this.extendTranslation(p,e,a,r));else{let z=!1,N=!1;!this.isValidLookup(p)&&E&&(z=!0,p=T),this.isValidLookup(p)||(N=!0,p=o);const I=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&N?void 0:p,_=E&&T!==p&&this.options.updateMissing;if(N||z||_){if(this.logger.log(_?"updateKey":"missingKey",d,l,o,_?T:p),i){const C=this.resolve(o,{...a,keySeparator:!1});C&&C.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 D=[];const ae=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ae&&ae[0])for(let C=0;C<ae.length;C++)D.push(ae[C]);else this.options.saveMissingTo==="all"?D=this.languageUtils.toResolveHierarchy(a.lng||this.language):D.push(a.lng||this.language);const W=(C,H,Y)=>{const se=E&&Y!==p?Y:I;this.options.missingKeyHandler?this.options.missingKeyHandler(C,l,H,se,_,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(C,l,H,se,_,a),this.emit("missingKey",C,l,H,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&S?D.forEach(C=>{const H=this.pluralResolver.getSuffixes(C,a);P&&a[`defaultValue${this.options.pluralSeparator}zero`]&&H.indexOf(`${this.options.pluralSeparator}zero`)<0&&H.push(`${this.options.pluralSeparator}zero`),H.forEach(Y=>{W([C],o+Y,a[`defaultValue${Y}`]||T)})}):W(D,o,T))}p=this.extendTranslation(p,e,a,m,r),N&&p===o&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${o}`),(N||z)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${o}`:o,z?p:void 0,a))}return s?(m.res=p,m.usedParams=this.getUsedParamsDetails(a),m):p}extendTranslation(e,t,r,a,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=L(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let l;if(c){const d=e.match(this.interpolator.nestingRegexp);l=d&&d.length}let u=r.replace&&!L(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,r.lng||this.language||a.usedLng,r),c){const d=e.match(this.interpolator.nestingRegexp),h=d&&d.length;l<h&&(r.nest=!1)}!r.lng&&a&&a.res&&(r.lng=this.language||a.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>s?.[0]===d[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`),null):this.translate(...d,t),r)),r.interpolation&&this.interpolator.reset()}const i=r.postProcess||this.options.postProcess,o=L(i)?[i]:i;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=At.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,a,s,i,o;return L(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const l=this.extractFromKey(c,t),u=l.key;a=u;let d=l.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const h=t.count!==void 0&&!L(t.count),m=h&&!t.ordinal&&t.count===0,p=t.context!==void 0&&(L(t.context)||typeof t.context=="number")&&t.context!=="",g=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);d.forEach(f=>{this.isValidLookup(r)||(o=f,!Nt[`${g[0]}-${f}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(Nt[`${g[0]}-${f}`]=!0,this.logger.warn(`key "${a}" for languages "${g.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach(x=>{if(this.isValidLookup(r))return;i=x;const b=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(b,u,x,f,t);else{let S;h&&(S=this.pluralResolver.getSuffix(x,t.count,t));const E=`${this.options.pluralSeparator}zero`,O=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(t.ordinal&&S.indexOf(O)===0&&b.push(u+S.replace(O,this.options.pluralSeparator)),b.push(u+S),m&&b.push(u+E)),p){const A=`${u}${this.options.contextSeparator||"_"}${t.context}`;b.push(A),h&&(t.ordinal&&S.indexOf(O)===0&&b.push(A+S.replace(O,this.options.pluralSeparator)),b.push(A+S),m&&b.push(A+E))}}let v;for(;v=b.pop();)this.isValidLookup(r)||(s=v,r=this.getResource(x,f,v,t))}))})}),{res:r,usedKey:a,exactUsedKey:s,usedLng:i,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,r,a={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,r,a):this.resourceStore.getResource(e,t,r,a)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!L(e.replace);let a=r?e.replace:e;if(r&&typeof e.count<"u"&&(a.count=e.count),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!r){a={...a};for(const s of t)delete a[s]}return a}static hasDefaultValue(e){const t="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&e[r]!==void 0)return!0;return!1}}class Rt{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=G.create("languageUtils")}getScriptPartFromCode(e){if(e=ge(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=ge(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(L(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(r=>{if(t)return;const a=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(a))&&(t=a)}),!t&&this.options.supportedLngs&&e.forEach(r=>{if(t)return;const a=this.getScriptPartFromCode(r);if(this.isSupportedCode(a))return t=a;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return t=s;t=this.options.supportedLngs.find(i=>{if(i===s)return i;if(!(i.indexOf("-")<0&&s.indexOf("-")<0)&&(i.indexOf("-")>0&&s.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===s||i.indexOf(s)===0&&s.length>1))return i})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),L(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}toResolveHierarchy(e,t){const r=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),a=[],s=i=>{i&&(this.isSupportedCode(i)?a.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return L(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):L(e)&&s(this.formatLanguageCode(e)),r.forEach(i=>{a.indexOf(i)<0&&s(this.formatLanguageCode(i))}),a}}const Ct={zero:0,one:1,two:2,few:3,many:4,other:5},Pt={select:n=>n===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Ha{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=G.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const r=ge(e==="dev"?"en":e),a=t.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:a});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let i;try{i=new Intl.PluralRules(r,{type:a})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Pt;if(!e.match(/-|_/))return Pt;const c=this.languageUtils.getLanguagePartFromCode(e);i=this.getRule(c,t)}return this.pluralRulesCache[s]=i,i}needsPlural(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,r={}){return this.getSuffixes(e,r).map(a=>`${t}${a}`)}getSuffixes(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?r.resolvedOptions().pluralCategories.sort((a,s)=>Ct[a]-Ct[s]).map(a=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(e,t,r={}){const a=this.getRule(e,r);return a?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${a.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,r))}}const jt=(n,e,t,r=".",a=!0)=>{let s=ja(n,e,t);return!s&&a&&L(t)&&(s=Ie(n,t,r),s===void 0&&(s=Ie(e,t,r))),s},_e=n=>n.replace(/\$/g,"$$$$");class Ka{constructor(e={}){this.logger=G.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(t=>t),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:r,useRawValueToEscape:a,prefix:s,prefixEscaped:i,suffix:o,suffixEscaped:c,formatSeparator:l,unescapeSuffix:u,unescapePrefix:d,nestingPrefix:h,nestingPrefixEscaped:m,nestingSuffix:p,nestingSuffixEscaped:g,nestingOptionsSeparator:f,maxReplaces:x,alwaysFormat:b}=e.interpolation;this.escape=t!==void 0?t:Da,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=a!==void 0?a:!1,this.prefix=s?te(s):i||"{{",this.suffix=o?te(o):c||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":d||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=h?te(h):m||te("$t("),this.nestingSuffix=p?te(p):g||te(")"),this.nestingOptionsSeparator=f||",",this.maxReplaces=x||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,r)=>t?.source===r?(t.lastIndex=0,t):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,r,a){let s,i,o;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=m=>{if(m.indexOf(this.formatSeparator)<0){const x=jt(t,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...a,...t,interpolationkey:m}):x}const p=m.split(this.formatSeparator),g=p.shift().trim(),f=p.join(this.formatSeparator).trim();return this.format(jt(t,c,g,this.options.keySeparator,this.options.ignoreJSONStructure),f,r,{...a,...t,interpolationkey:g})};this.resetRegExp();const u=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,d=a?.interpolation?.skipOnVariables!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>_e(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?_e(this.escape(m)):_e(m)}].forEach(m=>{for(o=0;s=m.regex.exec(e);){const p=s[1].trim();if(i=l(p),i===void 0)if(typeof u=="function"){const f=u(e,s,a);i=L(f)?f:""}else if(a&&Object.prototype.hasOwnProperty.call(a,p))i="";else if(d){i=s[0];continue}else this.logger.warn(`missed to pass in variable ${p} for interpolating ${e}`),i="";else!L(i)&&!this.useRawValueToEscape&&(i=vt(i));const g=m.safeValue(i);if(e=e.replace(s[0],g),d?(m.regex.lastIndex+=i.length,m.regex.lastIndex-=s[0].length):m.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,r={}){let a,s,i;const o=(c,l)=>{const u=this.nestingOptionsSeparator;if(c.indexOf(u)<0)return c;const d=c.split(new RegExp(`${u}[ ]*{`));let h=`{${d[1]}`;c=d[0],h=this.interpolate(h,i);const m=h.match(/'/g),p=h.match(/"/g);((m?.length??0)%2===0&&!p||p.length%2!==0)&&(h=h.replace(/'/g,'"'));try{i=JSON.parse(h),l&&(i={...l,...i})}catch(g){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,g),`${c}${u}${h}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,c};for(;a=this.nestingRegexp.exec(e);){let c=[];i={...r},i=i.replace&&!L(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const l=/{.*}/.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(l!==-1&&(c=a[1].slice(l).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),a[1]=a[1].slice(0,l)),s=t(o.call(this,a[1].trim(),i),i),s&&a[0]===e&&!L(s))return s;L(s)||(s=vt(s)),s||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((u,d)=>this.format(u,d,r.lng,{...r,interpolationkey:a[1].trim()}),s.trim())),e=e.replace(a[0],s),this.regexp.lastIndex=0}return e}}const qa=n=>{let e=n.toLowerCase().trim();const t={};if(n.indexOf("(")>-1){const r=n.split("(");e=r[0].toLowerCase().trim();const a=r[1].substring(0,r[1].length-1);e==="currency"&&a.indexOf(":")<0?t.currency||(t.currency=a.trim()):e==="relativetime"&&a.indexOf(":")<0?t.range||(t.range=a.trim()):a.split(";").forEach(i=>{if(i){const[o,...c]=i.split(":"),l=c.join(":").trim().replace(/^'+|'+$/g,""),u=o.trim();t[u]||(t[u]=l),l==="false"&&(t[u]=!1),l==="true"&&(t[u]=!0),isNaN(l)||(t[u]=parseInt(l,10))}})}return{formatName:e,formatOptions:t}},It=n=>{const e={};return(t,r,a)=>{let s=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(s={...s,[a.interpolationkey]:void 0});const i=r+JSON.stringify(s);let o=e[i];return o||(o=n(ge(r),a),e[i]=o),o(t)}},Wa=n=>(e,t,r)=>n(ge(t),r)(e);class Za{constructor(e={}){this.logger=G.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const r=t.cacheInBuiltFormats?It:Wa;this.formats={number:r((a,s)=>{const i=new Intl.NumberFormat(a,{...s});return o=>i.format(o)}),currency:r((a,s)=>{const i=new Intl.NumberFormat(a,{...s,style:"currency"});return o=>i.format(o)}),datetime:r((a,s)=>{const i=new Intl.DateTimeFormat(a,{...s});return o=>i.format(o)}),relativetime:r((a,s)=>{const i=new Intl.RelativeTimeFormat(a,{...s});return o=>i.format(o,s.range||"day")}),list:r((a,s)=>{const i=new Intl.ListFormat(a,{...s});return o=>i.format(o)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=It(t)}format(e,t,r,a={}){const s=t.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(o=>o.indexOf(")")>-1)){const o=s.findIndex(c=>c.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,o)].join(this.formatSeparator)}return s.reduce((o,c)=>{const{formatName:l,formatOptions:u}=qa(c);if(this.formats[l]){let d=o;try{const h=a?.formatParams?.[a.interpolationkey]||{},m=h.locale||h.lng||a.locale||a.lng||r;d=this.formats[l](o,m,{...u,...a,...h})}catch(h){this.logger.warn(h)}return d}else this.logger.warn(`there was no format function for ${l}`);return o},e)}}const Ga=(n,e)=>{n.pending[e]!==void 0&&(delete n.pending[e],n.pendingCount--)};class Ya extends ve{constructor(e,t,r,a={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=a,this.logger=G.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,a.backend,a)}queueLoad(e,t,r,a){const s={},i={},o={},c={};return e.forEach(l=>{let u=!0;t.forEach(d=>{const h=`${l}|${d}`;!r.reload&&this.store.hasResourceBundle(l,d)?this.state[h]=2:this.state[h]<0||(this.state[h]===1?i[h]===void 0&&(i[h]=!0):(this.state[h]=1,u=!1,i[h]===void 0&&(i[h]=!0),s[h]===void 0&&(s[h]=!0),c[d]===void 0&&(c[d]=!0)))}),u||(o[l]=!0)}),(Object.keys(s).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(s),pending:Object.keys(i),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(c)}}loaded(e,t,r){const a=e.split("|"),s=a[0],i=a[1];t&&this.emit("failedLoading",s,i,t),!t&&r&&this.store.addResourceBundle(s,i,r,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&r&&(this.state[e]=0);const o={};this.queue.forEach(c=>{Pa(c.loaded,[s],i),Ga(c,e),t&&c.errors.push(t),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(l=>{o[l]||(o[l]={});const u=c.loaded[l];u.length&&u.forEach(d=>{o[l][d]===void 0&&(o[l][d]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(c=>!c.done)}read(e,t,r,a=0,s=this.retryTimeout,i){if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:r,tried:a,wait:s,callback:i});return}this.readingCalls++;const o=(l,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const d=this.waitingReads.shift();this.read(d.lng,d.ns,d.fcName,d.tried,d.wait,d.callback)}if(l&&u&&a<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,r,a+1,s*2,i)},s);return}i(l,u)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const l=c(e,t);l&&typeof l.then=="function"?l.then(u=>o(null,u)).catch(o):o(null,l)}catch(l){o(l)}return}return c(e,t,o)}prepareLoading(e,t,r={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();L(e)&&(e=this.languageUtils.toResolveHierarchy(e)),L(t)&&(t=[t]);const s=this.queueLoad(e,t,r,a);if(!s.toLoad.length)return s.pending.length||a(),null;s.toLoad.forEach(i=>{this.loadOne(i)})}load(e,t,r){this.prepareLoading(e,t,{},r)}reload(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}loadOne(e,t=""){const r=e.split("|"),a=r[0],s=r[1];this.read(a,s,"read",void 0,void 0,(i,o)=>{i&&this.logger.warn(`${t}loading namespace ${s} for language ${a} failed`,i),!i&&o&&this.logger.log(`${t}loaded namespace ${s} for language ${a}`,o),this.loaded(e,i,o)})}saveMissing(e,t,r,a,s,i={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${r}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...i,isUpdate:s},l=this.backend.create.bind(this.backend);if(l.length<6)try{let u;l.length===5?u=l(e,t,r,a,c):u=l(e,t,r,a),u&&typeof u.then=="function"?u.then(d=>o(null,d)).catch(o):o(null,u)}catch(u){o(u)}else l(e,t,r,a,o,c)}!e||!e[0]||this.store.addResource(e[0],t,r,a)}}}const Dt=()=>({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:n=>{let e={};if(typeof n[1]=="object"&&(e=n[1]),L(n[1])&&(e.defaultValue=n[1]),L(n[2])&&(e.tDescription=n[2]),typeof n[2]=="object"||typeof n[3]=="object"){const t=n[3]||n[2];Object.keys(t).forEach(r=>{e[r]=t[r]})}return e},interpolation:{escapeValue:!0,format:n=>n,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),_t=n=>(L(n.ns)&&(n.ns=[n.ns]),L(n.fallbackLng)&&(n.fallbackLng=[n.fallbackLng]),L(n.fallbackNS)&&(n.fallbackNS=[n.fallbackNS]),n.supportedLngs?.indexOf?.("cimode")<0&&(n.supportedLngs=n.supportedLngs.concat(["cimode"])),typeof n.initImmediate=="boolean"&&(n.initAsync=n.initImmediate),n),Se=()=>{},Ja=n=>{Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach(t=>{typeof n[t]=="function"&&(n[t]=n[t].bind(n))})};class fe extends ve{constructor(e={},t){if(super(),this.options=_t(e),this.services={},this.logger=G,this.modules={external:[]},Ja(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&&(L(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=Dt();this.options={...r,...this.options,..._t(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const a=l=>l?typeof l=="function"?new l:l:null;if(!this.options.isClone){this.modules.logger?G.init(a(this.modules.logger),this.options):G.init(null,this.options);let l;this.modules.formatter?l=this.modules.formatter:l=Za;const u=new Rt(this.options);this.store=new Ft(this.options.resources,this.options);const d=this.services;d.logger=G,d.resourceStore=this.store,d.languageUtils=u,d.pluralResolver=new Ha(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),l&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(d.formatter=a(l),d.formatter.init&&d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new Ka(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new Ya(a(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",(m,...p)=>{this.emit(m,...p)}),this.modules.languageDetector&&(d.languageDetector=a(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=a(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new ke(this.services,this.options),this.translator.on("*",(m,...p)=>{this.emit(m,...p)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,t||(t=Se),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&l[0]!=="dev"&&(this.options.lng=l[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(l=>{this[l]=(...u)=>this.store[l](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(l=>{this[l]=(...u)=>(this.store[l](...u),this)});const o=de(),c=()=>{const l=(u,d)=>{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),o.resolve(d),t(u,d)};if(this.languages&&!this.isInitialized)return l(null,this.t.bind(this));this.changeLanguage(this.options.lng,l)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),o}loadResources(e,t=Se){let r=t;const a=L(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(a?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],i=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(l=>{l!=="cimode"&&s.indexOf(l)<0&&s.push(l)})};a?i(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>i(c)),this.options.preload?.forEach?.(o=>i(o)),this.services.backendConnector.load(s,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,t,r){const a=de();return typeof e=="function"&&(r=e,e=void 0),typeof t=="function"&&(r=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),r||(r=Se),this.services.backendConnector.reload(e,t,s=>{a.resolve(),r(s)}),a}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"&&At.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){const r=this.languages[t];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const r=de();this.emit("languageChanging",e);const a=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},s=(o,c)=>{c?this.isLanguageChangingTo===e&&(a(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...l)=>this.t(...l)),t&&t(o,(...l)=>this.t(...l))},i=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const c=L(o)?o:o&&o[0],l=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(L(o)?[o]:o);l&&(this.language||a(l),this.translator.language||this.translator.changeLanguage(l),this.services.languageDetector?.cacheUserLanguage?.(l)),this.loadResources(l,u=>{s(u,l)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(e),r}getFixedT(e,t,r){const a=(s,i,...o)=>{let c;typeof i!="object"?c=this.options.overloadTranslationOptionHandler([s,i].concat(o)):c={...i},c.lng=c.lng||a.lng,c.lngs=c.lngs||a.lngs,c.ns=c.ns||a.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||a.keyPrefix);const l=this.options.keySeparator||".";let u;return c.keyPrefix&&Array.isArray(s)?u=s.map(d=>(typeof d=="function"&&(d=De(d,{...this.options,...i})),`${c.keyPrefix}${l}${d}`)):(typeof s=="function"&&(s=De(s,{...this.options,...i})),u=c.keyPrefix?`${c.keyPrefix}${l}${s}`:s),this.t(u,c)};return L(e)?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=r,a}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 r=t.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const i=(o,c)=>{const l=this.services.backendConnector.state[`${o}|${c}`];return l===-1||l===0||l===2};if(t.precheck){const o=t.precheck(this,i);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(r,e)&&(!a||i(s,e)))}loadNamespaces(e,t){const r=de();return this.options.ns?(L(e)&&(e=[e]),e.forEach(a=>{this.options.ns.indexOf(a)<0&&this.options.ns.push(a)}),this.loadResources(a=>{r.resolve(),t&&t(a)}),r):(t&&t(),Promise.resolve())}loadLanguages(e,t){const r=de();L(e)&&(e=[e]);const a=this.options.preload||[],s=e.filter(i=>a.indexOf(i)<0&&this.services.languageUtils.isSupportedCode(i));return s.length?(this.options.preload=a.concat(s),this.loadResources(i=>{r.resolve(),t&&t(i)}),r):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const a=new Intl.Locale(e);if(a&&a.getTextInfo){const s=a.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const 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"],r=this.services?.languageUtils||new Rt(Dt());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new fe(e,t)}cloneInstance(e={},t=Se){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const a={...this.options,...e,isClone:!0},s=new fe(a);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(o=>{s[o]=this[o]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const o=Object.keys(this.store.data).reduce((c,l)=>(c[l]={...this.store.data[l]},c[l]=Object.keys(c[l]).reduce((u,d)=>(u[d]={...c[l][d]},u),c[l]),c),{});s.store=new Ft(o,a),s.services.resourceStore=s.store}return s.translator=new ke(s.services,a),s.translator.on("*",(o,...c)=>{s.emit(o,...c)}),s.init(a,t),s.translator.options=a,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const j=fe.createInstance();j.createInstance=fe.createInstance,j.createInstance,j.dir,j.init,j.loadResources,j.reloadResources,j.use,j.changeLanguage,j.getFixedT,j.t,j.exists,j.setDefaultNamespace,j.hasLoadedNamespace,j.loadNamespaces,j.loadLanguages;const{slice:Xa,forEach:Qa}=[];function es(n){return Qa.call(Xa.call(arguments,1),e=>{if(e)for(const t in e)n[t]===void 0&&(n[t]=e[t])}),n}function ts(n){return typeof n!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(t=>t.test(n))}const $t=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,ns=function(n,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},a=encodeURIComponent(e);let s=`${n}=${a}`;if(r.maxAge>0){const i=r.maxAge-0;if(Number.isNaN(i))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(i)}`}if(r.domain){if(!$t.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!$t.test(r.path))throw new TypeError("option path is invalid");s+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(s+="; HttpOnly"),r.secure&&(s+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(s+="; Partitioned"),s},Mt={create(n,e,t,r){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};t&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+t*60*1e3)),r&&(a.domain=r),document.cookie=ns(n,e,a)},read(n){const e=`${n}=`,t=document.cookie.split(";");for(let r=0;r<t.length;r++){let a=t[r];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(e)===0)return a.substring(e.length,a.length)}return null},remove(n,e){this.create(n,"",-1,e)}};var rs={name:"cookie",lookup(n){let{lookupCookie:e}=n;if(e&&typeof document<"u")return Mt.read(e)||void 0},cacheUserLanguage(n,e){let{lookupCookie:t,cookieMinutes:r,cookieDomain:a,cookieOptions:s}=e;t&&typeof document<"u"&&Mt.create(t,n,r,a,s)}},as={name:"querystring",lookup(n){let{lookupQuerystring:e}=n,t;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const s=r.substring(1).split("&");for(let i=0;i<s.length;i++){const o=s[i].indexOf("=");o>0&&s[i].substring(0,o)===e&&(t=s[i].substring(o+1))}}return t}},ss={name:"hash",lookup(n){let{lookupHash:e,lookupFromHashIndex:t}=n,r;if(typeof window<"u"){const{hash:a}=window.location;if(a&&a.length>2){const s=a.substring(1);if(e){const i=s.split("&");for(let o=0;o<i.length;o++){const c=i[o].indexOf("=");c>0&&i[o].substring(0,c)===e&&(r=i[o].substring(c+1))}}if(r)return r;if(!r&&t>-1){const i=a.match(/\/([a-zA-Z-]*)/g);return Array.isArray(i)?i[typeof t=="number"?t:0]?.replace("/",""):void 0}}}return r}};let ne=null;const Bt=()=>{if(ne!==null)return ne;try{if(ne=typeof window<"u"&&window.localStorage!==null,!ne)return!1;const n="i18next.translate.boo";window.localStorage.setItem(n,"foo"),window.localStorage.removeItem(n)}catch{ne=!1}return ne};var is={name:"localStorage",lookup(n){let{lookupLocalStorage:e}=n;if(e&&Bt())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(n,e){let{lookupLocalStorage:t}=e;t&&Bt()&&window.localStorage.setItem(t,n)}};let re=null;const zt=()=>{if(re!==null)return re;try{if(re=typeof window<"u"&&window.sessionStorage!==null,!re)return!1;const n="i18next.translate.boo";window.sessionStorage.setItem(n,"foo"),window.sessionStorage.removeItem(n)}catch{re=!1}return re};var os={name:"sessionStorage",lookup(n){let{lookupSessionStorage:e}=n;if(e&&zt())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(n,e){let{lookupSessionStorage:t}=e;t&&zt()&&window.sessionStorage.setItem(t,n)}},ls={name:"navigator",lookup(n){const e=[];if(typeof navigator<"u"){const{languages:t,userLanguage:r,language:a}=navigator;if(t)for(let s=0;s<t.length;s++)e.push(t[s]);r&&e.push(r),a&&e.push(a)}return e.length>0?e:void 0}},cs={name:"htmlTag",lookup(n){let{htmlTag:e}=n,t;const r=e||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(t=r.getAttribute("lang")),t}},us={name:"path",lookup(n){let{lookupFromPathIndex:e}=n;if(typeof window>"u")return;const t=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(t)?t[typeof e=="number"?e:0]?.replace("/",""):void 0}},ds={name:"subdomain",lookup(n){let{lookupFromSubdomainIndex:e}=n;const t=typeof e=="number"?e+1:1,r=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[t]}};let Ut=!1;try{document.cookie,Ut=!0}catch{}const Vt=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Ut||Vt.splice(1,1);const ps=()=>({order:Vt,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:n=>n});class Ht{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,t)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=es(t,this.options||{},ps()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=a=>a.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(rs),this.addDetector(as),this.addDetector(is),this.addDetector(os),this.addDetector(ls),this.addDetector(cs),this.addDetector(us),this.addDetector(ds),this.addDetector(ss)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,t=[];return e.forEach(r=>{if(this.detectors[r]){let a=this.detectors[r].lookup(this.options);a&&typeof a=="string"&&(a=[a]),a&&(t=t.concat(a))}}),t=t.filter(r=>r!=null&&!ts(r)).map(r=>this.options.convertDetectedLanguage(r)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach(r=>{this.detectors[r]&&this.detectors[r].cacheUserLanguage(e,this.options)}))}}Ht.type="languageDetector";const Kt={apiBaseUrl:"https://api.nemme.io",debug:!1},gs={Previous:"Previous",Next:"Next",Done:"Done",Submit:"Submit","Type your answer here":"Type your answer here","Max {{maxCharacters}} characters":"Max {{maxCharacters}} characters"},fs={};La({locale:Ta}),j.use(Ht).use(pn).init({debug:Kt.debug,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:{translation:gs},nb:{tranlation:fs}}});const qt={debug:0,info:1,warn:2,error:3};class $e{prefix;enabled;level;constructor(e={}){this.prefix=e.prefix||"Nemme SDK",this.enabled=e.enabled!==void 0?e.enabled:!0,this.level=e.level||"info"}shouldLog(e){return this.enabled&&qt[e]>=qt[this.level]}formatMessage(e){return`[${this.prefix}] ${e}`}debug(e,...t){this.shouldLog("debug")&&console.debug(this.formatMessage(e),...t)}info(e,...t){this.shouldLog("info")&&console.info(this.formatMessage(e),...t)}warn(e,...t){this.shouldLog("warn")&&console.warn(this.formatMessage(e),...t)}error(e,...t){this.shouldLog("error")&&console.error(this.formatMessage(e),...t)}child(e){return new $e({prefix:`${this.prefix}:${e}`,enabled:this.enabled,level:this.level})}configure(e){e.prefix!==void 0&&(this.prefix=e.prefix),e.enabled!==void 0&&(this.enabled=e.enabled),e.level!==void 0&&(this.level=e.level)}}const Wt=new $e,Zt=Wt.child("network"),hs=3e4,ms=(n,e)=>{const t=new URL(n,Kt.apiBaseUrl);return e&&Object.entries(e).forEach(([r,a])=>{a!=null&&t.searchParams.append(r,String(a))}),t.toString()},Q={async request(n,e={}){const{method:t="GET",headers:r={},body:a,params:s,timeout:i=hs}=e,o=ms(n,s),c={"Content-Type":"application/json",Accept:"application/json",...r},l={method:t,headers:c,body:a?JSON.stringify(a):void 0},u=new AbortController,d=setTimeout(()=>u.abort(),i);l.signal=u.signal;try{const h=await fetch(o,l);let m;const p=h.headers.get("content-type");if(p&&p.includes("application/json"))m=await h.json();else{const f=await h.text();try{m=JSON.parse(f)}catch{m=f}}const g={data:m,status:h.status,statusText:h.statusText,headers:h.headers,ok:h.ok};if(h.ok)g.ok=!0;else{const f=`Request failed with status ${h.status}: ${h.statusText}`;Zt.error(f,{url:o,method:t,status:h.status,data:g.data}),g.ok=!1,g.error={message:f,details:g.data}}return g}catch(h){let m="Network request failed",p={};return h instanceof DOMException&&h.name==="AbortError"?(m=`Request timeout after ${i}ms`,p={timeout:i,url:o}):p={message:h instanceof Error?h.message:String(h),url:o,method:t},Zt.error(m,p),{data:{},status:0,statusText:m,headers:new Headers,ok:!1,error:{message:m,details:p}}}finally{clearTimeout(d)}},async get(n,e={}){return this.request(n,{...e,method:"GET"})},async post(n,e,t={}){return this.request(n,{...t,method:"POST",body:e})},async put(n,e,t={}){return this.request(n,{...t,method:"PUT",body:e})},async patch(n,e,t={}){return this.request(n,{...t,method:"PATCH",body:e})},async delete(n,e={}){return this.request(n,{...e,method:"DELETE"})}};class ys{logger;headers;config;constructor(e,t,r={}){this.logger=e,this.headers=t,this.config=r}async fetchAndDisplayForm(e,t,r){this.logger.debug(`Fetching form config for: ${e}`);try{const a=await Q.get(`/external/forms/${e}`,{headers:this.headers});a.ok&&a.data?(this.logger.info(`Form config loaded for: ${e}`,a.data),this.displayForm(a.data,t,r)):this.logger.warn(`No form config found for: ${e}`)}catch(a){this.logger.error(`Failed to fetch form config for: ${e}`,a)}}displayForm(e,t,r){const a=document.createElement("div");a.id="nm",document.body.appendChild(a);const s=Qt.createRoot(a),i=F.createElement(mn,{i18n:j},F.createElement(wn,{form:e,onDismiss:async o=>{await t(),s.unmount(),a.remove(),this.logger.info("Form dismissed",o)},onComplete:async o=>{await r(),await this.postFormResponse(e,o),s.unmount(),a.remove(),this.logger.info("Form completed",o)},zIndex:this.config.zIndex}));s.render(i)}async postFormResponse(e,t){this.logger.info("Posting form response",t);const r=await Q.post(`/external/forms/${e.slug}`,t,{headers:this.headers});this.logger.info("Form response posted",r.data)}}class bs{logger;headers;formManager;deliveries=[];constructor(e,t,r){this.logger=e,this.headers=t,this.formManager=new ys(e,t,r)}async loadDeliveries(){try{this.logger.debug("Loading deliveries");const e=await Q.get("/external/deliveries",{headers:this.headers});this.deliveries=e.data,this.logger.info(`Loaded ${this.deliveries.length} deliveries`)}catch(e){this.logger.error("Failed to load deliveries",e),this.deliveries=[]}}async evaluateDeliveryTriggers(e){for(const t of this.deliveries)for(const r of t.triggers)if(this.shouldTriggerDelivery(r,e)){if(!await this.isDeliveryValid(t)){this.logger.debug(`Delivery ${t.id} is not valid, skipping`);continue}await this.executeDelivery(t,r);return}}shouldTriggerDelivery(e,t){if(this.hasActiveDelivery())return!1;switch(e.triggerType){case"page_url":return e.urlPattern?this.matchesUrlPattern(t.url,e.urlPattern):!0;case"custom_event":return e.eventKey?t.eventKey===e.eventKey:!1;default:return!1}}hasActiveDelivery(){return document.getElementById("nm")!==null}async executeDelivery(e,t){if(e.productType==="FRM"){this.logger.debug(`Triggering form delivery: ${e.productSlug}`,{triggerType:t.triggerType,urlPattern:t.urlPattern,eventKey:t.eventKey});try{const a=await this.createDeliveryResponse(e);await this.formManager.fetchAndDisplayForm(e.productSlug,async()=>{this.logger.debug(`Form for delivery: ${e.productSlug} was cancelled`),a&&await this.updateDeliveryResponse(e.id,a.id,!0)},async()=>{this.logger.debug(`Form for delivery: ${e.productSlug} was completed`),a&&await this.updateDeliveryResponse(e.id,a.id,!1,!0)})}catch(a){this.logger.error(`Failed to load form for delivery: ${e.productSlug}`,a)}}}matchesUrlPattern(e,t){let r;try{r=new URL(e).pathname}catch{r=e.startsWith("/")?e:`/${e}`}const a=u=>{if(!u)return"/";let d=u.startsWith("/")?u:`/${u}`;return d.length>1&&d.endsWith("/")&&(d=d.slice(0,-1)),d},s=a(r),i=a(t),o=i.replace(/\*\*/g,"§DOUBLE_STAR§").replace(/\*/g,"[^/]*").replace(/§DOUBLE_STAR§/g,".*").replace(/\?/g,"."),l=new RegExp(`^${o}$`).test(s);return this.logger.debug("URL pattern matching",{originalUrl:e,pathname:r,normalizedPathname:s,pattern:t,normalizedPattern:i,regexPattern:o,matches:l}),l}async createDeliveryResponse(e){try{return(await Q.post(`/external/deliveries/${e.id}/responses`,{},{headers:this.headers})).data}catch(t){this.logger.error(`Failed to create delivery response for delivery: ${e.id}`,t)}}async updateDeliveryResponse(e,t,r=!1,a=!1){try{await Q.patch(`/external/deliveries/${e}/responses/${t}`,{wasDismissed:r,wasCompleted:a},{headers:this.headers})}catch(s){this.logger.error(`Failed to update delivery response: ${t} for delivery: ${e}`,s)}}async isDeliveryValid(e){try{return(await Q.get(`/external/deliveries/${e.id}/should-deliver`,{headers:this.headers})).data}catch(t){return this.logger.error(`Failed to get delivery should-deliver for delivery: ${e.id}`,t),!1}}}class xs{logger;headers;sessionId;eventDefinitions=[];onPageView;onEvent;backlog=[];flushTimeout=null;batchConfig={enabled:!0,size:10,delayMs:1e4,sendOnUnload:!0};originalHistoryMethods=null;EVENT_PAGE_VIEW="page_view";constructor({logger:e,headers:t,sessionId:r,eventDefinitions:a,batchConfig:s,onPageView:i,onEvent:o}){this.logger=e,this.headers=t,this.sessionId=r,this.eventDefinitions=a,this.onPageView=i,this.onEvent=o,this.flushEvents=this.flushEvents.bind(this),this.handlePopState=this.handlePopState.bind(this),this.handleVisibilityChange=this.handleVisibilityChange.bind(this),this.setupBatching(s)}setupBatching(e){typeof e=="boolean"?this.batchConfig.enabled=e:e&&(this.batchConfig={...this.batchConfig,...e}),this.batchConfig.enabled&&this.batchConfig.sendOnUnload&&typeof window<"u"&&(window.addEventListener("beforeunload",this.flushEvents),window.addEventListener("pagehide",this.flushEvents))}async setupPageViewTracking(){if(typeof window>"u")return;this.originalHistoryMethods={pushState:history.pushState,replaceState:history.replaceState};const e=history.pushState;history.pushState=async(...r)=>{e.apply(history,r),await this.trackPageView()};const t=history.replaceState;history.replaceState=async(...r)=>{t.apply(history,r),await this.trackPageView()},window.addEventListener("popstate",this.handlePopState),document.addEventListener("visibilitychange",this.handleVisibilityChange)}async track(e){if(!this.sessionId){this.logger.warn("Tracking manager not initialized, cannot track event");return}const{eventKey:t,data:r={}}=e;this.logger.debug("Tracking event",{eventKey:t,data:r});const a=window.location.href,s={sessionId:this.sessionId,eventKey:t,data:r||{},timestamp:new Date().toISOString(),page:a};this.validateEvent(s),this.batchConfig.enabled?(this.backlog.push(s),this.scheduleFlush()):await this.sendEvents([s]),t===this.EVENT_PAGE_VIEW?this.onPageView?.(window.location.href):this.onEvent?.(s,a)}async trackPageView(){typeof window>"u"||await this.track({eventKey:this.EVENT_PAGE_VIEW,data:{title:document.title}})}async flush(){return this.flushEvents()}destroy(){this.originalHistoryMethods&&(history.pushState=this.originalHistoryMethods.pushState,history.replaceState=this.originalHistoryMethods.replaceState,this.originalHistoryMethods=null),typeof window<"u"&&(window.removeEventListener("popstate",this.handlePopState),document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.flushEvents),window.removeEventListener("pagehide",this.flushEvents)),this.flushTimeout&&(clearTimeout(this.flushTimeout),this.flushTimeout=null)}validateEvent(e){if(e.eventKey===this.EVENT_PAGE_VIEW)return;const t=this.eventDefinitions.find(s=>s.eventKey===e.eventKey);if(!t){this.logger.warn(`Event ${e.eventKey} is not registered`);return}const r=t.properties,a=e.data;if(a)for(const s of Object.keys(a)){const i=a[s],o=r.find(c=>c.name===s);if(!o){this.logger.warn(`Property ${s} is not registered for event ${e.eventKey}`);return}o.type==="string"&&typeof i!="string"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof i}`),o.type==="boolean"&&typeof i!="boolean"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof i}`),o.type==="number"&&typeof i!="number"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof i}`)}}async handlePopState(){await this.trackPageView()}async handleVisibilityChange(){document.visibilityState==="visible"&&await this.trackPageView()}scheduleFlush(){if(this.backlog.length>=this.batchConfig.size){this.flushEvents();return}this.flushTimeout||(this.flushTimeout=window.setTimeout(()=>{this.flushEvents()},this.batchConfig.delayMs))}async flushEvents(){if(this.flushTimeout&&(clearTimeout(this.flushTimeout),this.flushTimeout=null),this.backlog.length===0)return;const e=[...this.backlog];this.backlog=[];try{await this.sendEvents(e)}catch(t){this.backlog.unshift(...e),this.logger.error("Failed to send batched events",t)}}async sendEvents(e){if(e.length!==0)if(e.length===1){const t=e[0];await Q.post("/external/trackings/track",t,{headers:this.headers})}else await Q.post("/external/trackings/batch",e,{headers:this.headers})}}class Ee{clientKey;userIdentifier;initialized=!1;clientLogger=Wt.child("client");headers={};formConfig;constructor(e){this.clientKey=e}trackingManager;async init({userIdentifier:e,debug:t=!1,batch:r,formConfig:a}){if(!e)throw new Error("userIdentifier is required parameter");this.userIdentifier=e,this.clientLogger.configure({enabled:t,level:t?"debug":"info"}),this.headers={"X-Client-Key":this.clientKey,"X-User-Id":this.userIdentifier},this.formConfig=a;try{const s=await this.initializeSession();await this.initializeManagers(s,r),this.initialized=!0,this.clientLogger.info("Nemme client initialized",{clientKey:this.clientKey,userIdentifier:this.userIdentifier})}catch(s){this.clientLogger.error("Error during initialization:",s)}return this}async flush(){return this.trackingManager?.flush()}destroy(){this.trackingManager?.destroy()}async track(e){if(!this.initialized||!this.trackingManager){this.clientLogger.warn("Nemme client not initialized, some operations may fail");return}return this.trackingManager.track(e)}async initializeSession(){try{const e=await Q.post("/external/trackings/initialize",{},{headers:this.headers});if(!e.ok)throw new Error(e.error?.message||"Request for initialising session failed");return e.data}catch(e){throw this.clientLogger.error("Error during initialization",e),e}}async initializeManagers(e,t){const r=new bs(this.clientLogger,this.headers,this.formConfig),a=new xs({logger:this.clientLogger,headers:this.headers,sessionId:e.sessionId,eventDefinitions:e.eventDefinitions,batchConfig:t,onPageView:async s=>{await r.evaluateDeliveryTriggers({url:s})},onEvent:async(s,i)=>{await r.evaluateDeliveryTriggers({eventKey:s.eventKey,eventData:s.data,url:i})}});await r.loadDeliveries(),typeof window<"u"&&(await a.setupPageViewTracking(),await a.trackPageView(),await a.flush()),this.trackingManager=a}}const Gt=n=>new Ee(n),Yt=F.createContext(void 0),ws=({clientKey:n,config:e,children:t})=>{const[r,a]=F.useState(null),[s,i]=F.useState(!1),[o,c]=F.useState(null);F.useEffect(()=>{let u=null,d=!1;const h=async()=>{try{const m=new Ee(n);if(await m.init(e),d){m.destroy();return}u=m,a(m),i(!0),c(null)}catch(m){d||(c(m instanceof Error?m.message:"Failed to initialize Nemme client"),i(!1))}};return a(null),i(!1),c(null),h(),()=>{d=!0,u&&u.destroy()}},[n,e]);const l={client:r,isInitialized:s,error:o};return k.jsx(Yt.Provider,{value:l,children:t})},Jt=()=>{const n=F.useContext(Yt);if(n===void 0)throw new Error("useNemmeContext must be used within a NemmeProvider");return n},vs=()=>{const{client:n,isInitialized:e,error:t}=Jt(),r=F.useCallback(async s=>{if(!n||!e){console.warn("Nemme client not initialized");return}return n.track(s)},[n,e]),a=F.useCallback(async()=>{if(!n||!e){console.warn("Nemme client not initialized");return}return n.flush()},[n,e]);return{track:r,flush:a,isInitialized:e,error:t,client:n}},ks=n=>Gt(n),Me=Object.assign(n=>ks(n),{NemmeClient:Ee,init:async n=>{const{clientKey:e,...t}=n;return await Gt(e).init(t)}});typeof window<"u"&&(window.NemmeSDK=Me),$.NemmeClient=Ee,$.NemmeProvider=ws,$.NemmeSDK=Me,$.default=Me,$.useNemme=vs,$.useNemmeContext=Jt,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
38
+ `).map((i,o)=>k.jsx(X,{children:i.trim()},o))]}),a]}),r&&k.jsx("div",{className:"flex flex-col justify-center order-1 md:order-2",children:k.jsx("div",{className:"rounded-lg overflow-hidden mb-6 md:mb-0",children:k.jsx("img",{className:"w-full h-full object-cover aspect-video md:aspect-square",src:r,alt:"image"})})})]}),Zr=({title:n,icon:e,description:t,image:r,quitText:a,onQuit:s,externalLink:i})=>k.jsxs(xt,{title:n,icon:e,description:t,image:r,children:[k.jsx("div",{className:"flex justify-end gap-2",children:i?k.jsx(J,{variant:"secondary",text:a,iconAfter:k.jsx(Xe,{}),onClick:()=>{window.open(i,"_blank"),s()}}):k.jsx(J,{variant:"secondary",onClick:s,text:a})}),i&&k.jsx(J,{className:"absolute -top-2 -right-2 md:-top-4 md:-right-4",variant:"secondary",size:"small",onClick:s,iconAfter:k.jsx(he,{}),"aria-label":"quit"})]}),Gr=({title:n,icon:e,description:t,image:r,quitText:a,onQuit:s,startText:i,onStart:o})=>k.jsxs(xt,{title:n,icon:e,description:t,image:r,wrapperClassName:"relative",children:[k.jsxs("div",{className:"flex justify-end gap-2",children:[s&&a&&k.jsx(J,{variant:"subtle",text:a,onClick:s}),k.jsx(J,{variant:"secondary",text:i,onClick:o})]}),s&&k.jsx(J,{className:"absolute top-0 right-1 md:top-1",variant:"subtle",size:"small",onClick:s,iconAfter:k.jsx(he,{}),"aria-label":"quit"})]});let wt={};function Yr(){return wt}function Jr(n){wt=n}const Xr={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Qr=(n,e,t)=>{let r;const a=Xr[n];return typeof a=="string"?r=a:e===1?r=a.one:r=a.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+r:r+" ago":r};function je(n){return(e={})=>{const t=e.width?String(e.width):n.defaultWidth;return n.formats[t]||n.formats[n.defaultWidth]}}const ea={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ta=(n,e,t,r)=>ea[n];function ce(n){return(e,t)=>{const r=t?.context?String(t.context):"standalone";let a;if(r==="formatting"&&n.formattingValues){const i=n.defaultFormattingWidth||n.defaultWidth,o=t?.width?String(t.width):i;a=n.formattingValues[o]||n.formattingValues[i]}else{const i=n.defaultWidth,o=t?.width?String(t.width):n.defaultWidth;a=n.values[o]||n.values[i]}const s=n.argumentCallback?n.argumentCallback(e):e;return a[s]}}const na={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ra={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},aa={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},sa={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ia={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},oa={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},la={ordinalNumber:(n,e)=>{const t=Number(n),r=t%100;if(r>20||r<10)switch(r%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:ce({values:na,defaultWidth:"wide"}),quarter:ce({values:ra,defaultWidth:"wide",argumentCallback:n=>n-1}),month:ce({values:aa,defaultWidth:"wide"}),day:ce({values:sa,defaultWidth:"wide"}),dayPeriod:ce({values:ia,defaultWidth:"wide",formattingValues:oa,defaultFormattingWidth:"wide"})};function ue(n){return(e,t={})=>{const r=t.width,a=r&&n.matchPatterns[r]||n.matchPatterns[n.defaultMatchWidth],s=e.match(a);if(!s)return null;const i=s[0],o=r&&n.parsePatterns[r]||n.parsePatterns[n.defaultParseWidth],c=Array.isArray(o)?ua(o,d=>d.test(i)):ca(o,d=>d.test(i));let l;l=n.valueCallback?n.valueCallback(c):c,l=t.valueCallback?t.valueCallback(l):l;const u=e.slice(i.length);return{value:l,rest:u}}}function ca(n,e){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&e(n[t]))return t}function ua(n,e){for(let t=0;t<n.length;t++)if(e(n[t]))return t}function da(n){return(e,t={})=>{const r=e.match(n.matchPattern);if(!r)return null;const a=r[0],s=e.match(n.parsePattern);if(!s)return null;let i=n.valueCallback?n.valueCallback(s[0]):s[0];i=t.valueCallback?t.valueCallback(i):i;const o=e.slice(a.length);return{value:i,rest:o}}}const pa=/^(\d+)(th|st|nd|rd)?/i,ga=/\d+/i,fa={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ha={any:[/^b/i,/^(a|c)/i]},ma={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ya={any:[/1/i,/2/i,/3/i,/4/i]},ba={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},xa={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},wa={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},va={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},ka={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Sa={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ea={ordinalNumber:da({matchPattern:pa,parsePattern:ga,valueCallback:n=>parseInt(n,10)}),era:ue({matchPatterns:fa,defaultMatchWidth:"wide",parsePatterns:ha,defaultParseWidth:"any"}),quarter:ue({matchPatterns:ma,defaultMatchWidth:"wide",parsePatterns:ya,defaultParseWidth:"any",valueCallback:n=>n+1}),month:ue({matchPatterns:ba,defaultMatchWidth:"wide",parsePatterns:xa,defaultParseWidth:"any"}),day:ue({matchPatterns:wa,defaultMatchWidth:"wide",parsePatterns:va,defaultParseWidth:"any"}),dayPeriod:ue({matchPatterns:ka,defaultMatchWidth:"any",parsePatterns:Sa,defaultParseWidth:"any"})};function La(n){const e={},t=Yr();for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]===void 0?delete e[r]:e[r]=n[r]);Jr(e)}const Fa={full:"EEEE, d MMMM yyyy",long:"d MMMM yyyy",medium:"d MMM yyyy",short:"dd/MM/yyyy"},Aa={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Oa={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Na={date:je({formats:Fa,defaultWidth:"full"}),time:je({formats:Aa,defaultWidth:"full"}),dateTime:je({formats:Oa,defaultWidth:"full"})},Ta={code:"en-GB",formatDistance:Qr,formatLong:Na,formatRelative:ta,localize:la,match:Ea,options:{weekStartsOn:1,firstWeekContainsDate:4}},L=n=>typeof n=="string",de=()=>{let n,e;const t=new Promise((r,a)=>{n=r,e=a});return t.resolve=n,t.reject=e,t},vt=n=>n==null?"":""+n,Ra=(n,e,t)=>{n.forEach(r=>{e[r]&&(t[r]=e[r])})},Ca=/###/g,kt=n=>n&&n.indexOf("###")>-1?n.replace(Ca,"."):n,St=n=>!n||L(n),pe=(n,e,t)=>{const r=L(e)?e.split("."):e;let a=0;for(;a<r.length-1;){if(St(n))return{};const s=kt(r[a]);!n[s]&&t&&(n[s]=new t),Object.prototype.hasOwnProperty.call(n,s)?n=n[s]:n={},++a}return St(n)?{}:{obj:n,k:kt(r[a])}},Et=(n,e,t)=>{const{obj:r,k:a}=pe(n,e,Object);if(r!==void 0||e.length===1){r[a]=t;return}let s=e[e.length-1],i=e.slice(0,e.length-1),o=pe(n,i,Object);for(;o.obj===void 0&&i.length;)s=`${i[i.length-1]}.${s}`,i=i.slice(0,i.length-1),o=pe(n,i,Object),o?.obj&&typeof o.obj[`${o.k}.${s}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${s}`]=t},Pa=(n,e,t,r)=>{const{obj:a,k:s}=pe(n,e,Object);a[s]=a[s]||[],a[s].push(t)},we=(n,e)=>{const{obj:t,k:r}=pe(n,e);if(t&&Object.prototype.hasOwnProperty.call(t,r))return t[r]},ja=(n,e,t)=>{const r=we(n,t);return r!==void 0?r:we(e,t)},Lt=(n,e,t)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in n?L(n[r])||n[r]instanceof String||L(e[r])||e[r]instanceof String?t&&(n[r]=e[r]):Lt(n[r],e[r],t):n[r]=e[r]);return n},te=n=>n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ia={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Da=n=>L(n)?n.replace(/[&<>"'\/]/g,e=>Ia[e]):n;class _a{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const $a=[" ",",","?","!",";"],Ma=new _a(20),Ba=(n,e,t)=>{e=e||"",t=t||"";const r=$a.filter(i=>e.indexOf(i)<0&&t.indexOf(i)<0);if(r.length===0)return!0;const a=Ma.getRegExp(`(${r.map(i=>i==="?"?"\\?":i).join("|")})`);let s=!a.test(n);if(!s){const i=n.indexOf(t);i>0&&!a.test(n.substring(0,i))&&(s=!0)}return s},Ie=(n,e,t=".")=>{if(!n)return;if(n[e])return Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;const r=e.split(t);let a=n;for(let s=0;s<r.length;){if(!a||typeof a!="object")return;let i,o="";for(let c=s;c<r.length;++c)if(c!==s&&(o+=t),o+=r[c],i=a[o],i!==void 0){if(["string","number","boolean"].indexOf(typeof i)>-1&&c<r.length-1)continue;s+=c-s+1;break}a=i}return a},ge=n=>n?.replace("_","-"),za={type:"logger",log(n){this.output("log",n)},warn(n){this.output("warn",n)},error(n){this.output("error",n)},output(n,e){console?.[n]?.apply?.(console,e)}};let Ua=class Ue{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||za,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,r,a){return a&&!this.debug?null:(L(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new Ue(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Ue(this.logger,e)}};var G=new Ua;class ve{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const a=this.observers[r].get(t)||0;this.observers[r].set(t,a+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(([a,s])=>{for(let i=0;i<s;i++)a(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([a,s])=>{for(let i=0;i<s;i++)a.apply(a,[e,...t])})}}class Ft extends ve{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,a={}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,i=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],r&&(Array.isArray(r)?o.push(...r):L(r)&&s?o.push(...r.split(s)):o.push(r)));const c=we(this.data,o);return!c&&!t&&!r&&e.indexOf(".")>-1&&(e=o[0],t=o[1],r=o.slice(2).join(".")),c||!i||!L(r)?c:Ie(this.data?.[e]?.[t],r,s)}addResource(e,t,r,a,s={silent:!1}){const i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let o=[e,t];r&&(o=o.concat(i?r.split(i):r)),e.indexOf(".")>-1&&(o=e.split("."),a=t,t=o[1]),this.addNamespaces(t),Et(this.data,o,a),s.silent||this.emit("added",e,t,r,a)}addResources(e,t,r,a={silent:!1}){for(const s in r)(L(r[s])||Array.isArray(r[s]))&&this.addResource(e,t,s,r[s],{silent:!0});a.silent||this.emit("added",e,t,r)}addResourceBundle(e,t,r,a,s,i={silent:!1,skipCopy:!1}){let o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),a=r,r=t,t=o[1]),this.addNamespaces(t);let c=we(this.data,o)||{};i.skipCopy||(r=JSON.parse(JSON.stringify(r))),a?Lt(c,r,s):c={...c,...r},Et(this.data,o,c),i.silent||this.emit("added",e,t,r)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(a=>t[a]&&Object.keys(t[a]).length>0)}toJSON(){return this.data}}var At={processors:{},addPostProcessor(n){this.processors[n.name]=n},handle(n,e,t,r,a){return n.forEach(s=>{e=this.processors[s]?.process(e,t,r,a)??e}),e}};const Ot=Symbol("i18next/PATH_KEY");function Va(){const n=[],e=Object.create(null);let t;return e.get=(r,a)=>(t?.revoke?.(),a===Ot?n:(n.push(a),t=Proxy.revocable(r,e),t.proxy)),Proxy.revocable(Object.create(null),e).proxy}function De(n,e){const{[Ot]:t}=n(Va());return t.join(e?.keySeparator??".")}const Nt={},Tt=n=>!L(n)&&typeof n!="boolean"&&typeof n!="number";class ke extends ve{constructor(e,t={}){super(),Ra(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=G.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const r={...t};return e==null?!1:this.resolve(e,r)?.res!==void 0}extractFromKey(e,t){let r=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const a=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let s=t.ns||this.options.defaultNS||[];const i=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Ba(e,r,a);if(i&&!o){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:L(s)?[s]:s};const l=e.split(r);(r!==a||r===a&&this.options.ns.indexOf(l[0])>-1)&&(s=l.shift()),e=l.join(a)}return{key:e,namespaces:L(s)?[s]:s}}translate(e,t,r){let a=typeof t=="object"?{...t}:t;if(typeof a!="object"&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a=="object"&&(a={...a}),a||(a={}),e==null)return"";typeof e=="function"&&(e=De(e,{...this.options,...a})),Array.isArray(e)||(e=[String(e)]);const s=a.returnDetails!==void 0?a.returnDetails:this.options.returnDetails,i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],a),l=c[c.length-1];let u=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const d=a.lng||this.language,h=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()==="cimode")return h?s?{res:`${l}${u}${o}`,usedKey:o,exactUsedKey:o,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:`${l}${u}${o}`:s?{res:o,usedKey:o,exactUsedKey:o,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:o;const m=this.resolve(e,a);let p=m?.res;const g=m?.usedKey||o,f=m?.exactUsedKey||o,x=["[object Number]","[object Function]","[object RegExp]"],b=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,S=a.count!==void 0&&!L(a.count),E=ke.hasDefaultValue(a),O=S?this.pluralResolver.getSuffix(d,a.count,a):"",A=a.ordinal&&S?this.pluralResolver.getSuffix(d,a.count,{ordinal:!1}):"",P=S&&!a.ordinal&&a.count===0,T=P&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${O}`]||a[`defaultValue${A}`]||a.defaultValue;let R=p;v&&!p&&E&&(R=T);const q=Tt(R),V=Object.prototype.toString.apply(R);if(v&&R&&q&&x.indexOf(V)<0&&!(L(b)&&Array.isArray(R))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const z=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,R,{...a,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return s?(m.res=z,m.usedParams=this.getUsedParamsDetails(a),m):z}if(i){const z=Array.isArray(R),N=z?[]:{},U=z?f:g;for(const I in R)if(Object.prototype.hasOwnProperty.call(R,I)){const _=`${U}${i}${I}`;E&&!p?N[I]=this.translate(_,{...a,defaultValue:Tt(T)?T[I]:void 0,joinArrays:!1,ns:c}):N[I]=this.translate(_,{...a,joinArrays:!1,ns:c}),N[I]===_&&(N[I]=R[I])}p=N}}else if(v&&L(b)&&Array.isArray(p))p=p.join(b),p&&(p=this.extendTranslation(p,e,a,r));else{let z=!1,N=!1;!this.isValidLookup(p)&&E&&(z=!0,p=T),this.isValidLookup(p)||(N=!0,p=o);const I=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&N?void 0:p,_=E&&T!==p&&this.options.updateMissing;if(N||z||_){if(this.logger.log(_?"updateKey":"missingKey",d,l,o,_?T:p),i){const C=this.resolve(o,{...a,keySeparator:!1});C&&C.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 D=[];const ae=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ae&&ae[0])for(let C=0;C<ae.length;C++)D.push(ae[C]);else this.options.saveMissingTo==="all"?D=this.languageUtils.toResolveHierarchy(a.lng||this.language):D.push(a.lng||this.language);const W=(C,H,Y)=>{const se=E&&Y!==p?Y:I;this.options.missingKeyHandler?this.options.missingKeyHandler(C,l,H,se,_,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(C,l,H,se,_,a),this.emit("missingKey",C,l,H,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&S?D.forEach(C=>{const H=this.pluralResolver.getSuffixes(C,a);P&&a[`defaultValue${this.options.pluralSeparator}zero`]&&H.indexOf(`${this.options.pluralSeparator}zero`)<0&&H.push(`${this.options.pluralSeparator}zero`),H.forEach(Y=>{W([C],o+Y,a[`defaultValue${Y}`]||T)})}):W(D,o,T))}p=this.extendTranslation(p,e,a,m,r),N&&p===o&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${o}`),(N||z)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${o}`:o,z?p:void 0,a))}return s?(m.res=p,m.usedParams=this.getUsedParamsDetails(a),m):p}extendTranslation(e,t,r,a,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=L(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let l;if(c){const d=e.match(this.interpolator.nestingRegexp);l=d&&d.length}let u=r.replace&&!L(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,r.lng||this.language||a.usedLng,r),c){const d=e.match(this.interpolator.nestingRegexp),h=d&&d.length;l<h&&(r.nest=!1)}!r.lng&&a&&a.res&&(r.lng=this.language||a.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>s?.[0]===d[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`),null):this.translate(...d,t),r)),r.interpolation&&this.interpolator.reset()}const i=r.postProcess||this.options.postProcess,o=L(i)?[i]:i;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=At.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,a,s,i,o;return L(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const l=this.extractFromKey(c,t),u=l.key;a=u;let d=l.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const h=t.count!==void 0&&!L(t.count),m=h&&!t.ordinal&&t.count===0,p=t.context!==void 0&&(L(t.context)||typeof t.context=="number")&&t.context!=="",g=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);d.forEach(f=>{this.isValidLookup(r)||(o=f,!Nt[`${g[0]}-${f}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(Nt[`${g[0]}-${f}`]=!0,this.logger.warn(`key "${a}" for languages "${g.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach(x=>{if(this.isValidLookup(r))return;i=x;const b=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(b,u,x,f,t);else{let S;h&&(S=this.pluralResolver.getSuffix(x,t.count,t));const E=`${this.options.pluralSeparator}zero`,O=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(t.ordinal&&S.indexOf(O)===0&&b.push(u+S.replace(O,this.options.pluralSeparator)),b.push(u+S),m&&b.push(u+E)),p){const A=`${u}${this.options.contextSeparator||"_"}${t.context}`;b.push(A),h&&(t.ordinal&&S.indexOf(O)===0&&b.push(A+S.replace(O,this.options.pluralSeparator)),b.push(A+S),m&&b.push(A+E))}}let v;for(;v=b.pop();)this.isValidLookup(r)||(s=v,r=this.getResource(x,f,v,t))}))})}),{res:r,usedKey:a,exactUsedKey:s,usedLng:i,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,r,a={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,r,a):this.resourceStore.getResource(e,t,r,a)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!L(e.replace);let a=r?e.replace:e;if(r&&typeof e.count<"u"&&(a.count=e.count),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!r){a={...a};for(const s of t)delete a[s]}return a}static hasDefaultValue(e){const t="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&e[r]!==void 0)return!0;return!1}}class Rt{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=G.create("languageUtils")}getScriptPartFromCode(e){if(e=ge(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=ge(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(L(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(r=>{if(t)return;const a=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(a))&&(t=a)}),!t&&this.options.supportedLngs&&e.forEach(r=>{if(t)return;const a=this.getScriptPartFromCode(r);if(this.isSupportedCode(a))return t=a;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return t=s;t=this.options.supportedLngs.find(i=>{if(i===s)return i;if(!(i.indexOf("-")<0&&s.indexOf("-")<0)&&(i.indexOf("-")>0&&s.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===s||i.indexOf(s)===0&&s.length>1))return i})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),L(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}toResolveHierarchy(e,t){const r=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),a=[],s=i=>{i&&(this.isSupportedCode(i)?a.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return L(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):L(e)&&s(this.formatLanguageCode(e)),r.forEach(i=>{a.indexOf(i)<0&&s(this.formatLanguageCode(i))}),a}}const Ct={zero:0,one:1,two:2,few:3,many:4,other:5},Pt={select:n=>n===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Ha{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=G.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const r=ge(e==="dev"?"en":e),a=t.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:a});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let i;try{i=new Intl.PluralRules(r,{type:a})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Pt;if(!e.match(/-|_/))return Pt;const c=this.languageUtils.getLanguagePartFromCode(e);i=this.getRule(c,t)}return this.pluralRulesCache[s]=i,i}needsPlural(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,r={}){return this.getSuffixes(e,r).map(a=>`${t}${a}`)}getSuffixes(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?r.resolvedOptions().pluralCategories.sort((a,s)=>Ct[a]-Ct[s]).map(a=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(e,t,r={}){const a=this.getRule(e,r);return a?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${a.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,r))}}const jt=(n,e,t,r=".",a=!0)=>{let s=ja(n,e,t);return!s&&a&&L(t)&&(s=Ie(n,t,r),s===void 0&&(s=Ie(e,t,r))),s},_e=n=>n.replace(/\$/g,"$$$$");class Ka{constructor(e={}){this.logger=G.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(t=>t),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:r,useRawValueToEscape:a,prefix:s,prefixEscaped:i,suffix:o,suffixEscaped:c,formatSeparator:l,unescapeSuffix:u,unescapePrefix:d,nestingPrefix:h,nestingPrefixEscaped:m,nestingSuffix:p,nestingSuffixEscaped:g,nestingOptionsSeparator:f,maxReplaces:x,alwaysFormat:b}=e.interpolation;this.escape=t!==void 0?t:Da,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=a!==void 0?a:!1,this.prefix=s?te(s):i||"{{",this.suffix=o?te(o):c||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":d||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=h?te(h):m||te("$t("),this.nestingSuffix=p?te(p):g||te(")"),this.nestingOptionsSeparator=f||",",this.maxReplaces=x||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,r)=>t?.source===r?(t.lastIndex=0,t):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,r,a){let s,i,o;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=m=>{if(m.indexOf(this.formatSeparator)<0){const x=jt(t,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...a,...t,interpolationkey:m}):x}const p=m.split(this.formatSeparator),g=p.shift().trim(),f=p.join(this.formatSeparator).trim();return this.format(jt(t,c,g,this.options.keySeparator,this.options.ignoreJSONStructure),f,r,{...a,...t,interpolationkey:g})};this.resetRegExp();const u=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,d=a?.interpolation?.skipOnVariables!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>_e(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?_e(this.escape(m)):_e(m)}].forEach(m=>{for(o=0;s=m.regex.exec(e);){const p=s[1].trim();if(i=l(p),i===void 0)if(typeof u=="function"){const f=u(e,s,a);i=L(f)?f:""}else if(a&&Object.prototype.hasOwnProperty.call(a,p))i="";else if(d){i=s[0];continue}else this.logger.warn(`missed to pass in variable ${p} for interpolating ${e}`),i="";else!L(i)&&!this.useRawValueToEscape&&(i=vt(i));const g=m.safeValue(i);if(e=e.replace(s[0],g),d?(m.regex.lastIndex+=i.length,m.regex.lastIndex-=s[0].length):m.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,r={}){let a,s,i;const o=(c,l)=>{const u=this.nestingOptionsSeparator;if(c.indexOf(u)<0)return c;const d=c.split(new RegExp(`${u}[ ]*{`));let h=`{${d[1]}`;c=d[0],h=this.interpolate(h,i);const m=h.match(/'/g),p=h.match(/"/g);((m?.length??0)%2===0&&!p||p.length%2!==0)&&(h=h.replace(/'/g,'"'));try{i=JSON.parse(h),l&&(i={...l,...i})}catch(g){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,g),`${c}${u}${h}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,c};for(;a=this.nestingRegexp.exec(e);){let c=[];i={...r},i=i.replace&&!L(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const l=/{.*}/.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(l!==-1&&(c=a[1].slice(l).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),a[1]=a[1].slice(0,l)),s=t(o.call(this,a[1].trim(),i),i),s&&a[0]===e&&!L(s))return s;L(s)||(s=vt(s)),s||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((u,d)=>this.format(u,d,r.lng,{...r,interpolationkey:a[1].trim()}),s.trim())),e=e.replace(a[0],s),this.regexp.lastIndex=0}return e}}const qa=n=>{let e=n.toLowerCase().trim();const t={};if(n.indexOf("(")>-1){const r=n.split("(");e=r[0].toLowerCase().trim();const a=r[1].substring(0,r[1].length-1);e==="currency"&&a.indexOf(":")<0?t.currency||(t.currency=a.trim()):e==="relativetime"&&a.indexOf(":")<0?t.range||(t.range=a.trim()):a.split(";").forEach(i=>{if(i){const[o,...c]=i.split(":"),l=c.join(":").trim().replace(/^'+|'+$/g,""),u=o.trim();t[u]||(t[u]=l),l==="false"&&(t[u]=!1),l==="true"&&(t[u]=!0),isNaN(l)||(t[u]=parseInt(l,10))}})}return{formatName:e,formatOptions:t}},It=n=>{const e={};return(t,r,a)=>{let s=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(s={...s,[a.interpolationkey]:void 0});const i=r+JSON.stringify(s);let o=e[i];return o||(o=n(ge(r),a),e[i]=o),o(t)}},Wa=n=>(e,t,r)=>n(ge(t),r)(e);class Za{constructor(e={}){this.logger=G.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const r=t.cacheInBuiltFormats?It:Wa;this.formats={number:r((a,s)=>{const i=new Intl.NumberFormat(a,{...s});return o=>i.format(o)}),currency:r((a,s)=>{const i=new Intl.NumberFormat(a,{...s,style:"currency"});return o=>i.format(o)}),datetime:r((a,s)=>{const i=new Intl.DateTimeFormat(a,{...s});return o=>i.format(o)}),relativetime:r((a,s)=>{const i=new Intl.RelativeTimeFormat(a,{...s});return o=>i.format(o,s.range||"day")}),list:r((a,s)=>{const i=new Intl.ListFormat(a,{...s});return o=>i.format(o)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=It(t)}format(e,t,r,a={}){const s=t.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(o=>o.indexOf(")")>-1)){const o=s.findIndex(c=>c.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,o)].join(this.formatSeparator)}return s.reduce((o,c)=>{const{formatName:l,formatOptions:u}=qa(c);if(this.formats[l]){let d=o;try{const h=a?.formatParams?.[a.interpolationkey]||{},m=h.locale||h.lng||a.locale||a.lng||r;d=this.formats[l](o,m,{...u,...a,...h})}catch(h){this.logger.warn(h)}return d}else this.logger.warn(`there was no format function for ${l}`);return o},e)}}const Ga=(n,e)=>{n.pending[e]!==void 0&&(delete n.pending[e],n.pendingCount--)};class Ya extends ve{constructor(e,t,r,a={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=a,this.logger=G.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,a.backend,a)}queueLoad(e,t,r,a){const s={},i={},o={},c={};return e.forEach(l=>{let u=!0;t.forEach(d=>{const h=`${l}|${d}`;!r.reload&&this.store.hasResourceBundle(l,d)?this.state[h]=2:this.state[h]<0||(this.state[h]===1?i[h]===void 0&&(i[h]=!0):(this.state[h]=1,u=!1,i[h]===void 0&&(i[h]=!0),s[h]===void 0&&(s[h]=!0),c[d]===void 0&&(c[d]=!0)))}),u||(o[l]=!0)}),(Object.keys(s).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(s),pending:Object.keys(i),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(c)}}loaded(e,t,r){const a=e.split("|"),s=a[0],i=a[1];t&&this.emit("failedLoading",s,i,t),!t&&r&&this.store.addResourceBundle(s,i,r,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&r&&(this.state[e]=0);const o={};this.queue.forEach(c=>{Pa(c.loaded,[s],i),Ga(c,e),t&&c.errors.push(t),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(l=>{o[l]||(o[l]={});const u=c.loaded[l];u.length&&u.forEach(d=>{o[l][d]===void 0&&(o[l][d]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(c=>!c.done)}read(e,t,r,a=0,s=this.retryTimeout,i){if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:r,tried:a,wait:s,callback:i});return}this.readingCalls++;const o=(l,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const d=this.waitingReads.shift();this.read(d.lng,d.ns,d.fcName,d.tried,d.wait,d.callback)}if(l&&u&&a<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,r,a+1,s*2,i)},s);return}i(l,u)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const l=c(e,t);l&&typeof l.then=="function"?l.then(u=>o(null,u)).catch(o):o(null,l)}catch(l){o(l)}return}return c(e,t,o)}prepareLoading(e,t,r={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();L(e)&&(e=this.languageUtils.toResolveHierarchy(e)),L(t)&&(t=[t]);const s=this.queueLoad(e,t,r,a);if(!s.toLoad.length)return s.pending.length||a(),null;s.toLoad.forEach(i=>{this.loadOne(i)})}load(e,t,r){this.prepareLoading(e,t,{},r)}reload(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}loadOne(e,t=""){const r=e.split("|"),a=r[0],s=r[1];this.read(a,s,"read",void 0,void 0,(i,o)=>{i&&this.logger.warn(`${t}loading namespace ${s} for language ${a} failed`,i),!i&&o&&this.logger.log(`${t}loaded namespace ${s} for language ${a}`,o),this.loaded(e,i,o)})}saveMissing(e,t,r,a,s,i={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${r}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...i,isUpdate:s},l=this.backend.create.bind(this.backend);if(l.length<6)try{let u;l.length===5?u=l(e,t,r,a,c):u=l(e,t,r,a),u&&typeof u.then=="function"?u.then(d=>o(null,d)).catch(o):o(null,u)}catch(u){o(u)}else l(e,t,r,a,o,c)}!e||!e[0]||this.store.addResource(e[0],t,r,a)}}}const Dt=()=>({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:n=>{let e={};if(typeof n[1]=="object"&&(e=n[1]),L(n[1])&&(e.defaultValue=n[1]),L(n[2])&&(e.tDescription=n[2]),typeof n[2]=="object"||typeof n[3]=="object"){const t=n[3]||n[2];Object.keys(t).forEach(r=>{e[r]=t[r]})}return e},interpolation:{escapeValue:!0,format:n=>n,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),_t=n=>(L(n.ns)&&(n.ns=[n.ns]),L(n.fallbackLng)&&(n.fallbackLng=[n.fallbackLng]),L(n.fallbackNS)&&(n.fallbackNS=[n.fallbackNS]),n.supportedLngs?.indexOf?.("cimode")<0&&(n.supportedLngs=n.supportedLngs.concat(["cimode"])),typeof n.initImmediate=="boolean"&&(n.initAsync=n.initImmediate),n),Se=()=>{},Ja=n=>{Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach(t=>{typeof n[t]=="function"&&(n[t]=n[t].bind(n))})};class fe extends ve{constructor(e={},t){if(super(),this.options=_t(e),this.services={},this.logger=G,this.modules={external:[]},Ja(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&&(L(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=Dt();this.options={...r,...this.options,..._t(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const a=l=>l?typeof l=="function"?new l:l:null;if(!this.options.isClone){this.modules.logger?G.init(a(this.modules.logger),this.options):G.init(null,this.options);let l;this.modules.formatter?l=this.modules.formatter:l=Za;const u=new Rt(this.options);this.store=new Ft(this.options.resources,this.options);const d=this.services;d.logger=G,d.resourceStore=this.store,d.languageUtils=u,d.pluralResolver=new Ha(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),l&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(d.formatter=a(l),d.formatter.init&&d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new Ka(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new Ya(a(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",(m,...p)=>{this.emit(m,...p)}),this.modules.languageDetector&&(d.languageDetector=a(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=a(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new ke(this.services,this.options),this.translator.on("*",(m,...p)=>{this.emit(m,...p)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,t||(t=Se),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&l[0]!=="dev"&&(this.options.lng=l[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(l=>{this[l]=(...u)=>this.store[l](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(l=>{this[l]=(...u)=>(this.store[l](...u),this)});const o=de(),c=()=>{const l=(u,d)=>{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),o.resolve(d),t(u,d)};if(this.languages&&!this.isInitialized)return l(null,this.t.bind(this));this.changeLanguage(this.options.lng,l)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),o}loadResources(e,t=Se){let r=t;const a=L(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(a?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],i=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(l=>{l!=="cimode"&&s.indexOf(l)<0&&s.push(l)})};a?i(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>i(c)),this.options.preload?.forEach?.(o=>i(o)),this.services.backendConnector.load(s,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,t,r){const a=de();return typeof e=="function"&&(r=e,e=void 0),typeof t=="function"&&(r=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),r||(r=Se),this.services.backendConnector.reload(e,t,s=>{a.resolve(),r(s)}),a}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"&&At.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){const r=this.languages[t];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const r=de();this.emit("languageChanging",e);const a=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},s=(o,c)=>{c?this.isLanguageChangingTo===e&&(a(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...l)=>this.t(...l)),t&&t(o,(...l)=>this.t(...l))},i=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const c=L(o)?o:o&&o[0],l=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(L(o)?[o]:o);l&&(this.language||a(l),this.translator.language||this.translator.changeLanguage(l),this.services.languageDetector?.cacheUserLanguage?.(l)),this.loadResources(l,u=>{s(u,l)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(e),r}getFixedT(e,t,r){const a=(s,i,...o)=>{let c;typeof i!="object"?c=this.options.overloadTranslationOptionHandler([s,i].concat(o)):c={...i},c.lng=c.lng||a.lng,c.lngs=c.lngs||a.lngs,c.ns=c.ns||a.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||a.keyPrefix);const l=this.options.keySeparator||".";let u;return c.keyPrefix&&Array.isArray(s)?u=s.map(d=>(typeof d=="function"&&(d=De(d,{...this.options,...i})),`${c.keyPrefix}${l}${d}`)):(typeof s=="function"&&(s=De(s,{...this.options,...i})),u=c.keyPrefix?`${c.keyPrefix}${l}${s}`:s),this.t(u,c)};return L(e)?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=r,a}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 r=t.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const i=(o,c)=>{const l=this.services.backendConnector.state[`${o}|${c}`];return l===-1||l===0||l===2};if(t.precheck){const o=t.precheck(this,i);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(r,e)&&(!a||i(s,e)))}loadNamespaces(e,t){const r=de();return this.options.ns?(L(e)&&(e=[e]),e.forEach(a=>{this.options.ns.indexOf(a)<0&&this.options.ns.push(a)}),this.loadResources(a=>{r.resolve(),t&&t(a)}),r):(t&&t(),Promise.resolve())}loadLanguages(e,t){const r=de();L(e)&&(e=[e]);const a=this.options.preload||[],s=e.filter(i=>a.indexOf(i)<0&&this.services.languageUtils.isSupportedCode(i));return s.length?(this.options.preload=a.concat(s),this.loadResources(i=>{r.resolve(),t&&t(i)}),r):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const a=new Intl.Locale(e);if(a&&a.getTextInfo){const s=a.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const 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"],r=this.services?.languageUtils||new Rt(Dt());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new fe(e,t)}cloneInstance(e={},t=Se){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const a={...this.options,...e,isClone:!0},s=new fe(a);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(o=>{s[o]=this[o]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const o=Object.keys(this.store.data).reduce((c,l)=>(c[l]={...this.store.data[l]},c[l]=Object.keys(c[l]).reduce((u,d)=>(u[d]={...c[l][d]},u),c[l]),c),{});s.store=new Ft(o,a),s.services.resourceStore=s.store}return s.translator=new ke(s.services,a),s.translator.on("*",(o,...c)=>{s.emit(o,...c)}),s.init(a,t),s.translator.options=a,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const j=fe.createInstance();j.createInstance=fe.createInstance,j.createInstance,j.dir,j.init,j.loadResources,j.reloadResources,j.use,j.changeLanguage,j.getFixedT,j.t,j.exists,j.setDefaultNamespace,j.hasLoadedNamespace,j.loadNamespaces,j.loadLanguages;const{slice:Xa,forEach:Qa}=[];function es(n){return Qa.call(Xa.call(arguments,1),e=>{if(e)for(const t in e)n[t]===void 0&&(n[t]=e[t])}),n}function ts(n){return typeof n!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(t=>t.test(n))}const $t=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,ns=function(n,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},a=encodeURIComponent(e);let s=`${n}=${a}`;if(r.maxAge>0){const i=r.maxAge-0;if(Number.isNaN(i))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(i)}`}if(r.domain){if(!$t.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!$t.test(r.path))throw new TypeError("option path is invalid");s+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(s+="; HttpOnly"),r.secure&&(s+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(s+="; Partitioned"),s},Mt={create(n,e,t,r){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};t&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+t*60*1e3)),r&&(a.domain=r),document.cookie=ns(n,e,a)},read(n){const e=`${n}=`,t=document.cookie.split(";");for(let r=0;r<t.length;r++){let a=t[r];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(e)===0)return a.substring(e.length,a.length)}return null},remove(n,e){this.create(n,"",-1,e)}};var rs={name:"cookie",lookup(n){let{lookupCookie:e}=n;if(e&&typeof document<"u")return Mt.read(e)||void 0},cacheUserLanguage(n,e){let{lookupCookie:t,cookieMinutes:r,cookieDomain:a,cookieOptions:s}=e;t&&typeof document<"u"&&Mt.create(t,n,r,a,s)}},as={name:"querystring",lookup(n){let{lookupQuerystring:e}=n,t;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const s=r.substring(1).split("&");for(let i=0;i<s.length;i++){const o=s[i].indexOf("=");o>0&&s[i].substring(0,o)===e&&(t=s[i].substring(o+1))}}return t}},ss={name:"hash",lookup(n){let{lookupHash:e,lookupFromHashIndex:t}=n,r;if(typeof window<"u"){const{hash:a}=window.location;if(a&&a.length>2){const s=a.substring(1);if(e){const i=s.split("&");for(let o=0;o<i.length;o++){const c=i[o].indexOf("=");c>0&&i[o].substring(0,c)===e&&(r=i[o].substring(c+1))}}if(r)return r;if(!r&&t>-1){const i=a.match(/\/([a-zA-Z-]*)/g);return Array.isArray(i)?i[typeof t=="number"?t:0]?.replace("/",""):void 0}}}return r}};let ne=null;const Bt=()=>{if(ne!==null)return ne;try{if(ne=typeof window<"u"&&window.localStorage!==null,!ne)return!1;const n="i18next.translate.boo";window.localStorage.setItem(n,"foo"),window.localStorage.removeItem(n)}catch{ne=!1}return ne};var is={name:"localStorage",lookup(n){let{lookupLocalStorage:e}=n;if(e&&Bt())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(n,e){let{lookupLocalStorage:t}=e;t&&Bt()&&window.localStorage.setItem(t,n)}};let re=null;const zt=()=>{if(re!==null)return re;try{if(re=typeof window<"u"&&window.sessionStorage!==null,!re)return!1;const n="i18next.translate.boo";window.sessionStorage.setItem(n,"foo"),window.sessionStorage.removeItem(n)}catch{re=!1}return re};var os={name:"sessionStorage",lookup(n){let{lookupSessionStorage:e}=n;if(e&&zt())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(n,e){let{lookupSessionStorage:t}=e;t&&zt()&&window.sessionStorage.setItem(t,n)}},ls={name:"navigator",lookup(n){const e=[];if(typeof navigator<"u"){const{languages:t,userLanguage:r,language:a}=navigator;if(t)for(let s=0;s<t.length;s++)e.push(t[s]);r&&e.push(r),a&&e.push(a)}return e.length>0?e:void 0}},cs={name:"htmlTag",lookup(n){let{htmlTag:e}=n,t;const r=e||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(t=r.getAttribute("lang")),t}},us={name:"path",lookup(n){let{lookupFromPathIndex:e}=n;if(typeof window>"u")return;const t=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(t)?t[typeof e=="number"?e:0]?.replace("/",""):void 0}},ds={name:"subdomain",lookup(n){let{lookupFromSubdomainIndex:e}=n;const t=typeof e=="number"?e+1:1,r=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[t]}};let Ut=!1;try{document.cookie,Ut=!0}catch{}const Vt=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Ut||Vt.splice(1,1);const ps=()=>({order:Vt,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:n=>n});class Ht{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,t)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=es(t,this.options||{},ps()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=a=>a.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(rs),this.addDetector(as),this.addDetector(is),this.addDetector(os),this.addDetector(ls),this.addDetector(cs),this.addDetector(us),this.addDetector(ds),this.addDetector(ss)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,t=[];return e.forEach(r=>{if(this.detectors[r]){let a=this.detectors[r].lookup(this.options);a&&typeof a=="string"&&(a=[a]),a&&(t=t.concat(a))}}),t=t.filter(r=>r!=null&&!ts(r)).map(r=>this.options.convertDetectedLanguage(r)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach(r=>{this.detectors[r]&&this.detectors[r].cacheUserLanguage(e,this.options)}))}}Ht.type="languageDetector";const Kt={apiBaseUrl:"https://api.nemme.io",debug:!1},gs={Previous:"Previous",Next:"Next",Done:"Done",Submit:"Submit","Type your answer here":"Type your answer here","Max {{maxCharacters}} characters":"Max {{maxCharacters}} characters"},fs={};La({locale:Ta}),j.use(Ht).use(pn).init({debug:Kt.debug,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:{translation:gs},nb:{tranlation:fs}}});const qt={debug:0,info:1,warn:2,error:3};class $e{prefix;enabled;level;constructor(e={}){this.prefix=e.prefix||"Nemme SDK",this.enabled=e.enabled!==void 0?e.enabled:!0,this.level=e.level||"info"}shouldLog(e){return this.enabled&&qt[e]>=qt[this.level]}formatMessage(e){return`[${this.prefix}] ${e}`}debug(e,...t){this.shouldLog("debug")&&console.debug(this.formatMessage(e),...t)}info(e,...t){this.shouldLog("info")&&console.info(this.formatMessage(e),...t)}warn(e,...t){this.shouldLog("warn")&&console.warn(this.formatMessage(e),...t)}error(e,...t){this.shouldLog("error")&&console.error(this.formatMessage(e),...t)}child(e){return new $e({prefix:`${this.prefix}:${e}`,enabled:this.enabled,level:this.level})}configure(e){e.prefix!==void 0&&(this.prefix=e.prefix),e.enabled!==void 0&&(this.enabled=e.enabled),e.level!==void 0&&(this.level=e.level)}}const Wt=new $e,Zt=Wt.child("network"),hs=3e4,ms=(n,e)=>{const t=new URL(n,Kt.apiBaseUrl);return e&&Object.entries(e).forEach(([r,a])=>{a!=null&&t.searchParams.append(r,String(a))}),t.toString()},Q={async request(n,e={}){const{method:t="GET",headers:r={},body:a,params:s,timeout:i=hs}=e,o=ms(n,s),c={"Content-Type":"application/json",Accept:"application/json",...r},l={method:t,headers:c,body:a?JSON.stringify(a):void 0},u=new AbortController,d=setTimeout(()=>u.abort(),i);l.signal=u.signal;try{const h=await fetch(o,l);let m;const p=h.headers.get("content-type");if(p&&p.includes("application/json"))m=await h.json();else{const f=await h.text();try{m=JSON.parse(f)}catch{m=f}}const g={data:m,status:h.status,statusText:h.statusText,headers:h.headers,ok:h.ok};if(h.ok)g.ok=!0;else{const f=`Request failed with status ${h.status}: ${h.statusText}`;Zt.error(f,{url:o,method:t,status:h.status,data:g.data}),g.ok=!1,g.error={message:f,details:g.data}}return g}catch(h){let m="Network request failed",p={};return h instanceof DOMException&&h.name==="AbortError"?(m=`Request timeout after ${i}ms`,p={timeout:i,url:o}):p={message:h instanceof Error?h.message:String(h),url:o,method:t},Zt.error(m,p),{data:{},status:0,statusText:m,headers:new Headers,ok:!1,error:{message:m,details:p}}}finally{clearTimeout(d)}},async get(n,e={}){return this.request(n,{...e,method:"GET"})},async post(n,e,t={}){return this.request(n,{...t,method:"POST",body:e})},async put(n,e,t={}){return this.request(n,{...t,method:"PUT",body:e})},async patch(n,e,t={}){return this.request(n,{...t,method:"PATCH",body:e})},async delete(n,e={}){return this.request(n,{...e,method:"DELETE"})}};class ys{logger;headers;config;constructor(e,t,r={}){this.logger=e,this.headers=t,this.config=r}async fetchAndDisplayForm(e,t,r){this.logger.debug(`Fetching form config for: ${e}`);try{const a=await Q.get(`/external/forms/${e}`,{headers:this.headers});a.ok&&a.data?(this.logger.info(`Form config loaded for: ${e}`,a.data),this.displayForm(a.data,t,r)):this.logger.warn(`No form config found for: ${e}`)}catch(a){this.logger.error(`Failed to fetch form config for: ${e}`,a)}}displayForm(e,t,r){const a=document.createElement("div");a.id="nm",document.body.appendChild(a);const s=Qt.createRoot(a),i=F.createElement(mn,{i18n:j},F.createElement(wn,{form:e,onDismiss:async o=>{await t(),s.unmount(),a.remove(),this.logger.info("Form dismissed",o)},onComplete:async o=>{await r(),await this.postFormResponse(e,o),s.unmount(),a.remove(),this.logger.info("Form completed",o)},zIndex:this.config.zIndex}));s.render(i)}async postFormResponse(e,t){this.logger.info("Posting form response",t);const r=await Q.post(`/external/forms/${e.slug}`,t,{headers:this.headers});this.logger.info("Form response posted",r.data)}}class bs{logger;headers;formManager;deliveries=[];constructor(e,t,r){this.logger=e,this.headers=t,this.formManager=new ys(e,t,r)}async loadDeliveries(){try{this.logger.debug("Loading deliveries");const e=await Q.get("/external/deliveries",{headers:this.headers});this.deliveries=e.data,this.logger.info(`Loaded ${this.deliveries.length} deliveries`)}catch(e){this.logger.error("Failed to load deliveries",e),this.deliveries=[]}}async evaluateDeliveryTriggers(e){for(const t of this.deliveries)for(const r of t.triggers)if(this.shouldTriggerDelivery(r,e)){if(!await this.isDeliveryValid(t)){this.logger.debug(`Delivery ${t.id} is not valid, skipping`);continue}await this.executeDelivery(t,r);return}}shouldTriggerDelivery(e,t){if(this.hasActiveDelivery())return!1;switch(e.triggerType){case"page_url":return e.urlPattern?this.matchesUrlPattern(t.url,e.urlPattern):!0;case"custom_event":return e.eventKey?t.eventKey===e.eventKey:!1;default:return!1}}hasActiveDelivery(){return document.getElementById("nm")!==null}async executeDelivery(e,t){if(e.productType==="FRM"){this.logger.debug(`Triggering form delivery: ${e.productSlug}`,{triggerType:t.triggerType,urlPattern:t.urlPattern,eventKey:t.eventKey});try{const a=await this.createDeliveryResponse(e);await this.formManager.fetchAndDisplayForm(e.productSlug,async()=>{this.logger.debug(`Form for delivery: ${e.productSlug} was cancelled`),a&&await this.updateDeliveryResponse(e.id,a.id,!0)},async()=>{this.logger.debug(`Form for delivery: ${e.productSlug} was completed`),a&&await this.updateDeliveryResponse(e.id,a.id,!1,!0)})}catch(a){this.logger.error(`Failed to load form for delivery: ${e.productSlug}`,a)}}}matchesUrlPattern(e,t){let r;try{r=new URL(e).pathname}catch{r=e.startsWith("/")?e:`/${e}`}const a=u=>{if(!u)return"/";let d=u.startsWith("/")?u:`/${u}`;return d.length>1&&d.endsWith("/")&&(d=d.slice(0,-1)),d},s=a(r),i=a(t),o=i.replace(/\*\*/g,"§DOUBLE_STAR§").replace(/\*/g,"[^/]*").replace(/§DOUBLE_STAR§/g,".*").replace(/\?/g,"."),l=new RegExp(`^${o}$`).test(s);return this.logger.debug("URL pattern matching",{originalUrl:e,pathname:r,normalizedPathname:s,pattern:t,normalizedPattern:i,regexPattern:o,matches:l}),l}async createDeliveryResponse(e){try{return(await Q.post(`/external/deliveries/${e.id}/responses`,{},{headers:this.headers})).data}catch(t){this.logger.error(`Failed to create delivery response for delivery: ${e.id}`,t)}}async updateDeliveryResponse(e,t,r=!1,a=!1){try{await Q.patch(`/external/deliveries/${e}/responses/${t}`,{wasDismissed:r,wasCompleted:a},{headers:this.headers})}catch(s){this.logger.error(`Failed to update delivery response: ${t} for delivery: ${e}`,s)}}async isDeliveryValid(e){try{return(await Q.get(`/external/deliveries/${e.id}/should-deliver`,{headers:this.headers})).data}catch(t){return this.logger.error(`Failed to get delivery should-deliver for delivery: ${e.id}`,t),!1}}}class xs{logger;headers;sessionId;eventDefinitions=[];onPageView;onEvent;backlog=[];flushTimeout=null;batchConfig={enabled:!0,size:10,delayMs:1e4,sendOnUnload:!0};originalHistoryMethods=null;EVENT_PAGE_VIEW="page_view";constructor({logger:e,headers:t,sessionId:r,eventDefinitions:a,batchConfig:s,onPageView:i,onEvent:o}){this.logger=e,this.headers=t,this.sessionId=r,this.eventDefinitions=a,this.onPageView=i,this.onEvent=o,this.flushEvents=this.flushEvents.bind(this),this.handlePopState=this.handlePopState.bind(this),this.handleVisibilityChange=this.handleVisibilityChange.bind(this),this.setupBatching(s)}setupBatching(e){typeof e=="boolean"?this.batchConfig.enabled=e:e&&(this.batchConfig={...this.batchConfig,...e}),this.batchConfig.enabled&&this.batchConfig.sendOnUnload&&typeof window<"u"&&(window.addEventListener("beforeunload",this.flushEvents),window.addEventListener("pagehide",this.flushEvents))}async setupPageViewTracking(){if(typeof window>"u")return;this.originalHistoryMethods={pushState:history.pushState,replaceState:history.replaceState};const e=history.pushState;history.pushState=async(...r)=>{e.apply(history,r),await this.trackPageView()};const t=history.replaceState;history.replaceState=async(...r)=>{t.apply(history,r),await this.trackPageView()},window.addEventListener("popstate",this.handlePopState),document.addEventListener("visibilitychange",this.handleVisibilityChange)}async track(e){if(!this.sessionId){this.logger.warn("Tracking manager not initialized, cannot track event");return}const{eventKey:t,data:r={}}=e;this.logger.debug("Tracking event",{eventKey:t,data:r});const a=window.location.href,s={sessionId:this.sessionId,eventKey:t,data:r||{},timestamp:new Date().toISOString(),page:a};this.validateEvent(s),this.batchConfig.enabled?(this.backlog.push(s),this.scheduleFlush()):await this.sendEvents([s]),t===this.EVENT_PAGE_VIEW?this.onPageView?.(window.location.href):this.onEvent?.(s,a)}async trackPageView(){typeof window>"u"||await this.track({eventKey:this.EVENT_PAGE_VIEW,data:{title:document.title}})}async flush(){return this.flushEvents()}destroy(){this.originalHistoryMethods&&(history.pushState=this.originalHistoryMethods.pushState,history.replaceState=this.originalHistoryMethods.replaceState,this.originalHistoryMethods=null),typeof window<"u"&&(window.removeEventListener("popstate",this.handlePopState),document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.flushEvents),window.removeEventListener("pagehide",this.flushEvents)),this.flushTimeout&&(clearTimeout(this.flushTimeout),this.flushTimeout=null)}validateEvent(e){if(e.eventKey===this.EVENT_PAGE_VIEW)return;const t=this.eventDefinitions.find(s=>s.eventKey===e.eventKey);if(!t){this.logger.warn(`Event ${e.eventKey} is not registered`);return}const r=t.properties,a=e.data;if(a)for(const s of Object.keys(a)){const i=a[s],o=r.find(c=>c.name===s);if(!o){this.logger.warn(`Property ${s} is not registered for event ${e.eventKey}`);return}o.type==="string"&&typeof i!="string"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof i}`),o.type==="boolean"&&typeof i!="boolean"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof i}`),o.type==="number"&&typeof i!="number"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof i}`)}}async handlePopState(){await this.trackPageView()}async handleVisibilityChange(){document.visibilityState==="visible"&&await this.trackPageView()}scheduleFlush(){if(this.backlog.length>=this.batchConfig.size){this.flushEvents();return}this.flushTimeout||(this.flushTimeout=window.setTimeout(()=>{this.flushEvents()},this.batchConfig.delayMs))}async flushEvents(){if(this.flushTimeout&&(clearTimeout(this.flushTimeout),this.flushTimeout=null),this.backlog.length===0)return;const e=[...this.backlog];this.backlog=[];try{await this.sendEvents(e)}catch(t){this.backlog.unshift(...e),this.logger.error("Failed to send batched events",t)}}async sendEvents(e){if(e.length!==0)if(e.length===1){const t=e[0];await Q.post("/external/trackings/track",t,{headers:this.headers})}else await Q.post("/external/trackings/batch",e,{headers:this.headers})}}class Ee{clientKey;userIdentifier;initialized=!1;clientLogger=Wt.child("client");headers={};formConfig;constructor(e){this.clientKey=e}trackingManager;async init({userIdentifier:e,debug:t=!1,batch:r,formConfig:a,deactivate:s=!1}){if(s)return this.clientLogger.info("Nemme client deactivated and will stop initialization."),this.initialized=!0,this.clientLogger.configure({enabled:!1}),this;if(!e)throw new Error("userIdentifier is required parameter");this.userIdentifier=e,this.clientLogger.configure({enabled:t,level:t?"debug":"info"}),this.headers={"X-Client-Key":this.clientKey,"X-User-Id":this.userIdentifier},this.formConfig=a;try{const i=await this.initializeSession();await this.initializeManagers(i,r),this.initialized=!0,this.clientLogger.info("Nemme client initialized",{clientKey:this.clientKey,userIdentifier:this.userIdentifier})}catch(i){this.clientLogger.error("Error during initialization:",i)}return this}async flush(){return this.trackingManager?.flush()}destroy(){this.trackingManager?.destroy()}async track(e){if(!this.initialized||!this.trackingManager){this.clientLogger.warn("Nemme client not initialized, some operations may fail");return}return this.trackingManager.track(e)}async initializeSession(){try{const e=await Q.post("/external/trackings/initialize",{},{headers:this.headers});if(!e.ok)throw new Error(e.error?.message||"Request for initialising session failed");return e.data}catch(e){throw this.clientLogger.error("Error during initialization",e),e}}async initializeManagers(e,t){const r=new bs(this.clientLogger,this.headers,this.formConfig),a=new xs({logger:this.clientLogger,headers:this.headers,sessionId:e.sessionId,eventDefinitions:e.eventDefinitions,batchConfig:t,onPageView:async s=>{await r.evaluateDeliveryTriggers({url:s})},onEvent:async(s,i)=>{await r.evaluateDeliveryTriggers({eventKey:s.eventKey,eventData:s.data,url:i})}});await r.loadDeliveries(),typeof window<"u"&&(await a.setupPageViewTracking(),await a.trackPageView(),await a.flush()),this.trackingManager=a}}const Gt=n=>new Ee(n),Yt=F.createContext(void 0),ws=({clientKey:n,config:e,children:t})=>{const[r,a]=F.useState(null),[s,i]=F.useState(!1),[o,c]=F.useState(null);F.useEffect(()=>{let u=null,d=!1;const h=async()=>{try{const m=new Ee(n);if(await m.init(e),d){m.destroy();return}u=m,a(m),i(!0),c(null)}catch(m){d||(c(m instanceof Error?m.message:"Failed to initialize Nemme client"),i(!1))}};return a(null),i(!1),c(null),h(),()=>{d=!0,u&&u.destroy()}},[n,e]);const l={client:r,isInitialized:s,error:o};return k.jsx(Yt.Provider,{value:l,children:t})},Jt=()=>{const n=F.useContext(Yt);if(n===void 0)throw new Error("useNemmeContext must be used within a NemmeProvider");return n},vs=()=>{const{client:n,isInitialized:e,error:t}=Jt(),r=F.useCallback(async s=>{if(!n||!e){console.warn("Nemme client not initialized");return}return n.track(s)},[n,e]),a=F.useCallback(async()=>{if(!n||!e){console.warn("Nemme client not initialized");return}return n.flush()},[n,e]);return{track:r,flush:a,isInitialized:e,error:t,client:n}},ks=n=>Gt(n),Me=Object.assign(n=>ks(n),{NemmeClient:Ee,init:async n=>{const{clientKey:e,...t}=n;return await Gt(e).init(t)}});typeof window<"u"&&(window.NemmeSDK=Me),$.NemmeClient=Ee,$.NemmeProvider=ws,$.NemmeSDK=Me,$.default=Me,$.useNemme=vs,$.useNemmeContext=Jt,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
39
39
  //# sourceMappingURL=nemme-sdk.umd.js.map