@nemme/js-sdk 0.2.3 → 0.3.0

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.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Nt=Object.defineProperty;var jt=(i,e,t)=>e in i?Nt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var v=(i,e,t)=>jt(i,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("react"),Tt=require("react-dom/client");function $t(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const p=$t(w),Rt=(i,e,t,n)=>{var s,a,o,c;const r=[t,{code:e,...n||{}}];if((a=(s=i==null?void 0:i.services)==null?void 0:s.logger)!=null&&a.forward)return i.services.logger.forward(r,"warn","react-i18next::",!0);_(r[0])&&(r[0]=`react-i18next:: ${r[0]}`),(c=(o=i==null?void 0:i.services)==null?void 0:o.logger)!=null&&c.warn?i.services.logger.warn(...r):console!=null&&console.warn&&console.warn(...r)},je={},ye=(i,e,t,n)=>{_(t)&&je[t]||(_(t)&&(je[t]=new Date),Rt(i,e,t,n))},it=(i,e)=>()=>{if(i.isInitialized)e();else{const t=()=>{setTimeout(()=>{i.off("initialized",t)},0),e()};i.on("initialized",t)}},xe=(i,e,t)=>{i.loadNamespaces(e,it(i,t))},Te=(i,e,t,n)=>{if(_(t)&&(t=[t]),i.options.preload&&i.options.preload.indexOf(e)>-1)return xe(i,t,n);t.forEach(r=>{i.options.ns.indexOf(r)<0&&i.options.ns.push(r)}),i.loadLanguages(e,it(i,n))},Ft=(i,e,t={})=>!e.languages||!e.languages.length?(ye(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(i,{lng:t.lng,precheck:(n,r)=>{if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,i))return!1}}),_=i=>typeof i=="string",Mt=i=>typeof i=="object"&&i!==null,Dt=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,At={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Vt=i=>At[i],It=i=>i.replace(Dt,Vt);let be={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:It};const Ht=(i={})=>{be={...be,...i}},Bt=()=>be;let st;const zt=i=>{st=i},Kt=()=>st,qt={type:"3rdParty",init(i){Ht(i.options.react),zt(i)}},at=w.createContext();class _t{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(t=>{this.usedNamespaces[t]||(this.usedNamespaces[t]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const Ut=(i,e)=>{const t=w.useRef();return w.useEffect(()=>{t.current=i},[i,e]),t.current},ot=(i,e,t,n)=>i.getFixedT(e,t,n),Wt=(i,e,t,n)=>w.useCallback(ot(i,e,t,n),[i,e,t,n]),ke=(i,e={})=>{var C,N,I,T;const{i18n:t}=e,{i18n:n,defaultNS:r}=w.useContext(at)||{},s=t||n||Kt();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new _t),!s){ye(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const P=(k,R)=>_(R)?R:Mt(R)&&_(R.defaultValue)?R.defaultValue:Array.isArray(k)?k[k.length-1]:k,O=[P,{},!1];return O.t=P,O.i18n={},O.ready=!1,O}(C=s.options.react)!=null&&C.wait&&ye(s,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...Bt(),...s.options.react,...e},{useSuspense:o,keyPrefix:c}=a;let l=r||((N=s.options)==null?void 0:N.defaultNS);l=_(l)?[l]:l||["translation"],(T=(I=s.reportNamespaces).addUsedNamespaces)==null||T.call(I,l);const u=(s.isInitialized||s.initializedStoreOnce)&&l.every(P=>Ft(P,s,a)),d=Wt(s,e.lng||null,a.nsMode==="fallback"?l:l[0],c),h=()=>d,f=()=>ot(s,e.lng||null,a.nsMode==="fallback"?l:l[0],c),[g,y]=w.useState(h);let b=l.join();e.lng&&(b=`${e.lng}${b}`);const S=Ut(b),L=w.useRef(!0);w.useEffect(()=>{const{bindI18n:P,bindI18nStore:O}=a;L.current=!0,!u&&!o&&(e.lng?Te(s,e.lng,l,()=>{L.current&&y(f)}):xe(s,l,()=>{L.current&&y(f)})),u&&S&&S!==b&&L.current&&y(f);const k=()=>{L.current&&y(f)};return P&&(s==null||s.on(P,k)),O&&(s==null||s.store.on(O,k)),()=>{L.current=!1,s&&P&&(P==null||P.split(" ").forEach(R=>s.off(R,k))),O&&s&&O.split(" ").forEach(R=>s.store.off(R,k))}},[s,b]),w.useEffect(()=>{L.current&&u&&y(h)},[s,c,u]);const E=[g,s,u];if(E.t=g,E.i18n=s,E.ready=u,u||!u&&!o)return E;throw new Promise(P=>{e.lng?Te(s,e.lng,l,()=>P()):xe(s,l,()=>P())})};function Zt({i18n:i,defaultNS:e,children:t}){const n=w.useMemo(()=>({i18n:i,defaultNS:e}),[i,e]);return w.createElement(at.Provider,{value:n},t)}var ge={exports:{}},Y={};/**
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("react"),Ot=require("react-dom/client");function Nt(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const g=Nt(w),Ct=(r,e,t,n)=>{const i=[t,{code:e,...n||{}}];if(r?.services?.logger?.forward)return r.services.logger.forward(i,"warn","react-i18next::",!0);B(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),r?.services?.logger?.warn?r.services.logger.warn(...i):console?.warn&&console.warn(...i)},Oe={},ge=(r,e,t,n)=>{B(t)&&Oe[t]||(B(t)&&(Oe[t]=new Date),Ct(r,e,t,n))},tt=(r,e)=>()=>{if(r.isInitialized)e();else{const t=()=>{setTimeout(()=>{r.off("initialized",t)},0),e()};r.on("initialized",t)}},pe=(r,e,t)=>{r.loadNamespaces(e,tt(r,t))},Ne=(r,e,t,n)=>{if(B(t)&&(t=[t]),r.options.preload&&r.options.preload.indexOf(e)>-1)return pe(r,t,n);t.forEach(i=>{r.options.ns.indexOf(i)<0&&r.options.ns.push(i)}),r.loadLanguages(e,tt(r,n))},jt=(r,e,t={})=>!e.languages||!e.languages.length?(ge(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(r,{lng:t.lng,precheck:(n,i)=>{if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!i(n.isLanguageChangingTo,r))return!1}}),B=r=>typeof r=="string",Tt=r=>typeof r=="object"&&r!==null,$t=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Rt={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Ft=r=>Rt[r],Mt=r=>r.replace($t,Ft);let me={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Mt};const Dt=(r={})=>{me={...me,...r}},At=()=>me;let nt;const It=r=>{nt=r},Vt=()=>nt,Ht={type:"3rdParty",init(r){Dt(r.options.react),It(r)}},it=w.createContext();class Kt{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(t=>{this.usedNamespaces[t]||(this.usedNamespaces[t]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const Bt=(r,e)=>{const t=w.useRef();return w.useEffect(()=>{t.current=r},[r,e]),t.current},rt=(r,e,t,n)=>r.getFixedT(e,t,n),qt=(r,e,t,n)=>w.useCallback(rt(r,e,t,n),[r,e,t,n]),we=(r,e={})=>{const{i18n:t}=e,{i18n:n,defaultNS:i}=w.useContext(it)||{},s=t||n||Vt();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new Kt),!s){ge(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const k=(P,O)=>B(O)?O:Tt(O)&&B(O.defaultValue)?O.defaultValue:Array.isArray(P)?P[P.length-1]:P,L=[k,{},!1];return L.t=k,L.i18n={},L.ready=!1,L}s.options.react?.wait&&ge(s,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...At(),...s.options.react,...e},{useSuspense:o,keyPrefix:c}=a;let l=i||s.options?.defaultNS;l=B(l)?[l]:l||["translation"],s.reportNamespaces.addUsedNamespaces?.(l);const u=(s.isInitialized||s.initializedStoreOnce)&&l.every(k=>jt(k,s,a)),d=qt(s,e.lng||null,a.nsMode==="fallback"?l:l[0],c),h=()=>d,f=()=>rt(s,e.lng||null,a.nsMode==="fallback"?l:l[0],c),[p,y]=w.useState(h);let b=l.join();e.lng&&(b=`${e.lng}${b}`);const S=Bt(b),v=w.useRef(!0);w.useEffect(()=>{const{bindI18n:k,bindI18nStore:L}=a;v.current=!0,!u&&!o&&(e.lng?Ne(s,e.lng,l,()=>{v.current&&y(f)}):pe(s,l,()=>{v.current&&y(f)})),u&&S&&S!==b&&v.current&&y(f);const P=()=>{v.current&&y(f)};return k&&s?.on(k,P),L&&s?.store.on(L,P),()=>{v.current=!1,s&&k&&k?.split(" ").forEach(O=>s.off(O,P)),L&&s&&L.split(" ").forEach(O=>s.store.off(O,P))}},[s,b]),w.useEffect(()=>{v.current&&u&&y(h)},[s,c,u]);const E=[p,s,u];if(E.t=p,E.i18n=s,E.ready=u,u||!u&&!o)return E;throw new Promise(k=>{e.lng?Ne(s,e.lng,l,()=>k()):pe(s,l,()=>k())})};function zt({i18n:r,defaultNS:e,children:t}){const n=w.useMemo(()=>({i18n:r,defaultNS:e}),[r,e]);return w.createElement(it.Provider,{value:n},t)}var de={exports:{}},Z={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var $e;function Jt(){if($e)return Y;$e=1;var i=w,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(o,c,l){var u,d={},h=null,f=null;l!==void 0&&(h=""+l),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(f=c.ref);for(u in c)n.call(c,u)&&!s.hasOwnProperty(u)&&(d[u]=c[u]);if(o&&o.defaultProps)for(u in c=o.defaultProps,c)d[u]===void 0&&(d[u]=c[u]);return{$$typeof:e,type:o,key:h,ref:f,props:d,_owner:r.current}}return Y.Fragment=t,Y.jsx=a,Y.jsxs=a,Y}var Re;function Gt(){return Re||(Re=1,ge.exports=Jt()),ge.exports}var m=Gt();const Yt=({step:i,form:e,formState:t,onDismiss:n,onNextStep:r,onPreviousStep:s,onUpdateResponse:a})=>{const{t:o}=ke(),l=(u=>{let d=0;if(e.startTransition){if(u===d)return{type:"start",transition:e.startTransition};d++}const h=u-d;return h>=0&&h<e.questions.length?{type:"question",questionIndex:h,question:e.questions[h]}:(d+=e.questions.length,e.endTransition&&u===d?{type:"end",transition:e.endTransition}:null)})(i);if((l==null?void 0:l.type)==="start"){const{title:u,description:d,image:h,includeOptOut:f,customStartButton:g,startButtonText:y,customOptOutButton:b,optOutButtonText:S}=l.transition;return m.jsx(mn,{title:u,description:d,icon:e.icon,image:h,quitText:f?b?S:o("Quit"):void 0,onQuit:f?()=>n(t):void 0,startText:g?y:o("Start"),onStart:r})}if((l==null?void 0:l.type)==="end"){const{title:u,description:d,image:h,customEndButton:f,endButtonText:g,customEndButtonLink:y,endButtonLink:b}=l.transition;return m.jsx(pn,{title:u,description:d,icon:e.icon,image:h,quitText:f?g:o("Done"),onQuit:r,externalLink:y?b:void 0})}if((l==null?void 0:l.type)==="question"){const{question:u}=l;if(u.questionType==="choice"){const{title:d,description:h,image:f,alternatives:g,maxSelections:y,required:b}=u,S=t.responses[u.id]||[],L=(y?S.length<=y||y===4:!0)&&(b?S.length>0:!0);return m.jsx(hn,{title:d,description:h,image:f,alternatives:g,onPrevious:s,onNext:r,icon:e.icon,maxAlternatives:y,onQuit:()=>n(t),selectedAlternatives:S,onAlternativeSelect:E=>{if(y>1){const N=S,I=N.includes(E)?N.filter(T=>T!==E):y&&N.length>=y&&y!=4?N:[...N,E];a(u.id,I)}else S.includes(E)?a(u.id,[]):a(u.id,[E])},isValid:L})}if(u.questionType==="text"){const{title:d,description:h,image:f,maxChars:g,limited:y,required:b}=u,S=t.responses[u.id]||"",L=(y&&g?S.length<=g:!0)&&(b?S.length>0:!0);return m.jsx(gn,{title:d,icon:e.icon,description:h,onNext:r,onPrevious:s,onQuit:()=>n(t),image:f,maxCharacters:y?g:void 0,inputText:S,setInputText:E=>{y&&g&&E.length>g||a(u.id,E)},isValid:L})}}return null},Xt=({form:i,onDismiss:e,onComplete:t,zIndex:n=100})=>{const s=(i.startTransition?1:0)+i.questions.length+(i.endTransition?1:0)-1,[a,o]=w.useState({responses:{},currentStep:0,startedAt:new Date}),c=w.useCallback((h,f)=>{o(g=>({...g,responses:{...g.responses,[h]:f}}))},[]),l=w.useCallback(h=>{o(f=>({...f,currentStep:h}))},[]),u=w.useCallback(()=>{if(a.currentStep<s)l(a.currentStep+1);else{const h={...a,completedAt:new Date};t(h)}},[a,s,l,t]),d=w.useCallback(()=>{a.currentStep>0&&l(a.currentStep-1)},[a.currentStep,l]);return m.jsx("div",{className:"flex flex-col justify-center items-center absolute inset-0 bg-overlay-background-default-light dark:bg-overlay-background-default-dark",style:{zIndex:n},children:m.jsx(Yt,{step:a.currentStep,form:i,formState:a,onDismiss:e,onNextStep:u,onPreviousStep:d,onUpdateResponse:c})})},Qt=new Map([["bold",p.createElement(p.Fragment,null,p.createElement("path",{d:"M228,104a12,12,0,0,1-24,0V69l-59.51,59.51a12,12,0,0,1-17-17L187,52H152a12,12,0,0,1,0-24h64a12,12,0,0,1,12,12Zm-44,24a12,12,0,0,0-12,12v64H52V84h64a12,12,0,0,0,0-24H48A20,20,0,0,0,28,80V208a20,20,0,0,0,20,20H176a20,20,0,0,0,20-20V140A12,12,0,0,0,184,128Z"}))],["duotone",p.createElement(p.Fragment,null,p.createElement("path",{d:"M184,80V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8H176A8,8,0,0,1,184,80Z",opacity:"0.2"}),p.createElement("path",{d:"M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z"}))],["fill",p.createElement(p.Fragment,null,p.createElement("path",{d:"M192,136v72a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V80A16,16,0,0,1,48,64h72a8,8,0,0,1,0,16H48V208H176V136a8,8,0,0,1,16,0Zm32-96a8,8,0,0,0-8-8H152a8,8,0,0,0-5.66,13.66L172.69,72l-42.35,42.34a8,8,0,0,0,11.32,11.32L184,83.31l26.34,26.35A8,8,0,0,0,224,104Z"}))],["light",p.createElement(p.Fragment,null,p.createElement("path",{d:"M222,104a6,6,0,0,1-12,0V54.49l-69.75,69.75a6,6,0,0,1-8.48-8.48L201.51,46H152a6,6,0,0,1,0-12h64a6,6,0,0,1,6,6Zm-38,26a6,6,0,0,0-6,6v72a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V80a2,2,0,0,1,2-2h72a6,6,0,0,0,0-12H48A14,14,0,0,0,34,80V208a14,14,0,0,0,14,14H176a14,14,0,0,0,14-14V136A6,6,0,0,0,184,130Z"}))],["regular",p.createElement(p.Fragment,null,p.createElement("path",{d:"M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z"}))],["thin",p.createElement(p.Fragment,null,p.createElement("path",{d:"M220,104a4,4,0,0,1-8,0V49.66l-73.16,73.17a4,4,0,0,1-5.66-5.66L206.34,44H152a4,4,0,0,1,0-8h64a4,4,0,0,1,4,4Zm-36,28a4,4,0,0,0-4,4v72a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V80a4,4,0,0,1,4-4h72a4,4,0,0,0,0-8H48A12,12,0,0,0,36,80V208a12,12,0,0,0,12,12H176a12,12,0,0,0,12-12V136A4,4,0,0,0,184,132Z"}))]]),en=new Map([["bold",p.createElement(p.Fragment,null,p.createElement("path",{d:"M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z"}))],["duotone",p.createElement(p.Fragment,null,p.createElement("path",{d:"M160,48V208L80,128Z",opacity:"0.2"}),p.createElement("path",{d:"M163.06,40.61a8,8,0,0,0-8.72,1.73l-80,80a8,8,0,0,0,0,11.32l80,80A8,8,0,0,0,168,208V48A8,8,0,0,0,163.06,40.61ZM152,188.69,91.31,128,152,67.31Z"}))],["fill",p.createElement(p.Fragment,null,p.createElement("path",{d:"M168,48V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,168,48Z"}))],["light",p.createElement(p.Fragment,null,p.createElement("path",{d:"M164.24,203.76a6,6,0,1,1-8.48,8.48l-80-80a6,6,0,0,1,0-8.48l80-80a6,6,0,0,1,8.48,8.48L88.49,128Z"}))],["regular",p.createElement(p.Fragment,null,p.createElement("path",{d:"M165.66,202.34a8,8,0,0,1-11.32,11.32l-80-80a8,8,0,0,1,0-11.32l80-80a8,8,0,0,1,11.32,11.32L91.31,128Z"}))],["thin",p.createElement(p.Fragment,null,p.createElement("path",{d:"M162.83,205.17a4,4,0,0,1-5.66,5.66l-80-80a4,4,0,0,1,0-5.66l80-80a4,4,0,1,1,5.66,5.66L85.66,128Z"}))]]),tn=new Map([["bold",p.createElement(p.Fragment,null,p.createElement("path",{d:"M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z"}))],["duotone",p.createElement(p.Fragment,null,p.createElement("path",{d:"M176,128,96,208V48Z",opacity:"0.2"}),p.createElement("path",{d:"M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z"}))],["fill",p.createElement(p.Fragment,null,p.createElement("path",{d:"M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z"}))],["light",p.createElement(p.Fragment,null,p.createElement("path",{d:"M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z"}))],["regular",p.createElement(p.Fragment,null,p.createElement("path",{d:"M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"}))],["thin",p.createElement(p.Fragment,null,p.createElement("path",{d:"M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z"}))]]),nn=new Map([["bold",p.createElement(p.Fragment,null,p.createElement("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"}))],["duotone",p.createElement(p.Fragment,null,p.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),p.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["fill",p.createElement(p.Fragment,null,p.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["light",p.createElement(p.Fragment,null,p.createElement("path",{d:"M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"}))],["regular",p.createElement(p.Fragment,null,p.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["thin",p.createElement(p.Fragment,null,p.createElement("path",{d:"M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"}))]]),lt=w.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),se=p.forwardRef((i,e)=>{const{alt:t,color:n,size:r,weight:s,mirrored:a,children:o,weights:c,...l}=i,{color:u="currentColor",size:d,weight:h="regular",mirrored:f=!1,...g}=p.useContext(lt);return p.createElement("svg",{ref:e,xmlns:"http://www.w3.org/2000/svg",width:r??d,height:r??d,fill:n??u,viewBox:"0 0 256 256",transform:a||f?"scale(-1, 1)":void 0,...g,...l},!!t&&p.createElement("title",null,t),o,c.get(s??h))});se.displayName="IconBase";const ct=p.forwardRef((i,e)=>p.createElement(se,{ref:e,...i,weights:Qt}));ct.displayName="ArrowSquareOutIcon";const ut=p.forwardRef((i,e)=>p.createElement(se,{ref:e,...i,weights:en}));ut.displayName="CaretLeftIcon";const dt=p.forwardRef((i,e)=>p.createElement(se,{ref:e,...i,weights:tn}));dt.displayName="CaretRightIcon";const de=p.forwardRef((i,e)=>p.createElement(se,{ref:e,...i,weights:nn}));de.displayName="XIcon";var Fe={exports:{}},X={};/**
9
+ */var Ce;function _t(){if(Ce)return Z;Ce=1;var r=w,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(o,c,l){var u,d={},h=null,f=null;l!==void 0&&(h=""+l),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(f=c.ref);for(u in c)n.call(c,u)&&!s.hasOwnProperty(u)&&(d[u]=c[u]);if(o&&o.defaultProps)for(u in c=o.defaultProps,c)d[u]===void 0&&(d[u]=c[u]);return{$$typeof:e,type:o,key:h,ref:f,props:d,_owner:i.current}}return Z.Fragment=t,Z.jsx=a,Z.jsxs=a,Z}var je;function Ut(){return je||(je=1,de.exports=_t()),de.exports}var m=Ut();const Wt=({step:r,form:e,formState:t,onDismiss:n,onNextStep:i,onPreviousStep:s,onUpdateResponse:a})=>{const{t:o}=we(),l=(u=>{let d=0;if(e.startTransition){if(u===d)return{type:"start",transition:e.startTransition,hasPreviousStep:!1,hasNextStep:e.questions.length>0||!!e.endTransition};d++}const h=u-d;if(h>=0&&h<e.questions.length)return{type:"question",questionIndex:h,question:e.questions[h],hasPreviousStep:u>0,hasNextStep:u<e.questions.length-1||!!e.endTransition};if(d+=e.questions.length,e.endTransition&&u===d)return{type:"end",transition:e.endTransition,hasPreviousStep:u>0,hasNextStep:!1};throw new Error("Invalid step order")})(r);if(l.type==="start"){const{title:u,description:d,image:h,includeOptOut:f,customStartButton:p,startButtonText:y,customOptOutButton:b,optOutButtonText:S}=l.transition;return m.jsx(hn,{title:u,description:d,icon:e.icon,image:h,quitText:f?b?S:o("Quit"):void 0,onQuit:f?()=>n(t):void 0,startText:p?y:o("Start"),onStart:i})}if(l.type==="end"){const{title:u,description:d,image:h,customEndButton:f,endButtonText:p,customEndButtonLink:y,endButtonLink:b}=l.transition;return m.jsx(dn,{title:u,description:d,icon:e.icon,image:h,quitText:f?p:o("Done"),onQuit:i,externalLink:y?b:void 0})}if(l.type==="question"){const{question:u}=l;if(!u)throw new Error("No question found");if(u.questionType==="choice"){const{title:d,description:h,image:f,alternatives:p,maxSelections:y,required:b}=u,S=t.responses[u.id]||[],v=(y?S.length<=y||y===4:!0)&&(b?S.length>0:!0);return m.jsx(ln,{title:d,description:h,image:f,alternatives:p,onPrevious:s,onNext:i,icon:e.icon,maxAlternatives:y,onQuit:()=>n(t),selectedAlternatives:S,onAlternativeSelect:E=>{if(y>1){const L=S,P=L.includes(E)?L.filter(O=>O!==E):y&&L.length>=y&&y!=4?L:[...L,E];a(u.id,P)}else S.includes(E)?a(u.id,[]):a(u.id,[E])},isValid:v,hasPreviousStep:l.hasPreviousStep,hasNextStep:l.hasNextStep})}if(u.questionType==="text"){const{title:d,description:h,image:f,maxChars:p,limited:y,required:b}=u,S=t.responses[u.id]||"",v=(y&&p?S.length<=p:!0)&&(b?S.length>0:!0);return m.jsx(un,{title:d,icon:e.icon,description:h,onNext:i,onPrevious:s,onQuit:()=>n(t),image:f,maxCharacters:y?p:void 0,inputText:S,setInputText:E=>{y&&p&&E.length>p||a(u.id,E)},isValid:v,hasPreviousStep:l.hasPreviousStep,hasNextStep:l.hasNextStep})}}return null},Zt=({form:r,onDismiss:e,onComplete:t,zIndex:n=100})=>{const s=(r.startTransition?1:0)+r.questions.length+(r.endTransition?1:0)-1,[a,o]=w.useState({responses:{},currentStep:0,startedAt:new Date}),c=w.useCallback((h,f)=>{o(p=>({...p,responses:{...p.responses,[h]:f}}))},[]),l=w.useCallback(h=>{o(f=>({...f,currentStep:h}))},[]),u=w.useCallback(()=>{if(a.currentStep<s)l(a.currentStep+1);else{const h={...a,completedAt:new Date};t(h)}},[a,s,l,t]),d=w.useCallback(()=>{a.currentStep>0&&l(a.currentStep-1)},[a.currentStep,l]);return m.jsx("div",{className:"flex flex-col justify-center items-center absolute inset-0 bg-overlay-background-default-light dark:bg-overlay-background-default-dark",style:{zIndex:n},children:m.jsx(Wt,{step:a.currentStep,form:r,formState:a,onDismiss:e,onNextStep:u,onPreviousStep:d,onUpdateResponse:c})})},Jt=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M228,104a12,12,0,0,1-24,0V69l-59.51,59.51a12,12,0,0,1-17-17L187,52H152a12,12,0,0,1,0-24h64a12,12,0,0,1,12,12Zm-44,24a12,12,0,0,0-12,12v64H52V84h64a12,12,0,0,0,0-24H48A20,20,0,0,0,28,80V208a20,20,0,0,0,20,20H176a20,20,0,0,0,20-20V140A12,12,0,0,0,184,128Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M184,80V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8H176A8,8,0,0,1,184,80Z",opacity:"0.2"}),g.createElement("path",{d:"M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M192,136v72a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V80A16,16,0,0,1,48,64h72a8,8,0,0,1,0,16H48V208H176V136a8,8,0,0,1,16,0Zm32-96a8,8,0,0,0-8-8H152a8,8,0,0,0-5.66,13.66L172.69,72l-42.35,42.34a8,8,0,0,0,11.32,11.32L184,83.31l26.34,26.35A8,8,0,0,0,224,104Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M222,104a6,6,0,0,1-12,0V54.49l-69.75,69.75a6,6,0,0,1-8.48-8.48L201.51,46H152a6,6,0,0,1,0-12h64a6,6,0,0,1,6,6Zm-38,26a6,6,0,0,0-6,6v72a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V80a2,2,0,0,1,2-2h72a6,6,0,0,0,0-12H48A14,14,0,0,0,34,80V208a14,14,0,0,0,14,14H176a14,14,0,0,0,14-14V136A6,6,0,0,0,184,130Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M220,104a4,4,0,0,1-8,0V49.66l-73.16,73.17a4,4,0,0,1-5.66-5.66L206.34,44H152a4,4,0,0,1,0-8h64a4,4,0,0,1,4,4Zm-36,28a4,4,0,0,0-4,4v72a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V80a4,4,0,0,1,4-4h72a4,4,0,0,0,0-8H48A12,12,0,0,0,36,80V208a12,12,0,0,0,12,12H176a12,12,0,0,0,12-12V136A4,4,0,0,0,184,132Z"}))]]),Qt=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M160,48V208L80,128Z",opacity:"0.2"}),g.createElement("path",{d:"M163.06,40.61a8,8,0,0,0-8.72,1.73l-80,80a8,8,0,0,0,0,11.32l80,80A8,8,0,0,0,168,208V48A8,8,0,0,0,163.06,40.61ZM152,188.69,91.31,128,152,67.31Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M168,48V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,168,48Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M164.24,203.76a6,6,0,1,1-8.48,8.48l-80-80a6,6,0,0,1,0-8.48l80-80a6,6,0,0,1,8.48,8.48L88.49,128Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M165.66,202.34a8,8,0,0,1-11.32,11.32l-80-80a8,8,0,0,1,0-11.32l80-80a8,8,0,0,1,11.32,11.32L91.31,128Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M162.83,205.17a4,4,0,0,1-5.66,5.66l-80-80a4,4,0,0,1,0-5.66l80-80a4,4,0,1,1,5.66,5.66L85.66,128Z"}))]]),Gt=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M176,128,96,208V48Z",opacity:"0.2"}),g.createElement("path",{d:"M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z"}))]]),Yt=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),g.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"}))]]),st=w.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),ne=g.forwardRef((r,e)=>{const{alt:t,color:n,size:i,weight:s,mirrored:a,children:o,weights:c,...l}=r,{color:u="currentColor",size:d,weight:h="regular",mirrored:f=!1,...p}=g.useContext(st);return g.createElement("svg",{ref:e,xmlns:"http://www.w3.org/2000/svg",width:i??d,height:i??d,fill:n??u,viewBox:"0 0 256 256",transform:a||f?"scale(-1, 1)":void 0,...p,...l},!!t&&g.createElement("title",null,t),o,c.get(s??h))});ne.displayName="IconBase";const at=g.forwardRef((r,e)=>g.createElement(ne,{ref:e,...r,weights:Jt}));at.displayName="ArrowSquareOutIcon";const ot=g.forwardRef((r,e)=>g.createElement(ne,{ref:e,...r,weights:Qt}));ot.displayName="CaretLeftIcon";const lt=g.forwardRef((r,e)=>g.createElement(ne,{ref:e,...r,weights:Gt}));lt.displayName="CaretRightIcon";const le=g.forwardRef((r,e)=>g.createElement(ne,{ref:e,...r,weights:Yt}));le.displayName="XIcon";var Te={exports:{}},J={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.production.min.js
12
12
  *
@@ -14,13 +14,13 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Me;function rn(){if(Me)return X;Me=1;var i=w,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(o,c,l){var u,d={},h=null,f=null;l!==void 0&&(h=""+l),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(f=c.ref);for(u in c)n.call(c,u)&&!s.hasOwnProperty(u)&&(d[u]=c[u]);if(o&&o.defaultProps)for(u in c=o.defaultProps,c)d[u]===void 0&&(d[u]=c[u]);return{$$typeof:e,type:o,key:h,ref:f,props:d,_owner:r.current}}return X.Fragment=t,X.jsx=a,X.jsxs=a,X}var De;function sn(){return De||(De=1,Fe.exports=rn()),Fe.exports}var le=sn();const z=({variant:i="primary",size:e="medium",text:t,iconBefore:n,iconAfter:r,className:s,disabled:a=!1,...o})=>le.jsx("button",{className:M("flex gap-2 justify-center items-center rounded-lg disabled:pointer-events-none",an(i),on(e),s),disabled:a,...o,children:le.jsxs(lt.Provider,{value:{size:e==="xsmall"?8:16,weight:"regular",className:M(Ae(i,a))},children:[n&&n,t&&le.jsx("span",{className:M(Ae(i,a),ln(e)),children:t}),r&&r]})}),an=i=>{switch(i){case"primary":return"border border-grey-0/0 bg-primary-action-button-light dark:bg-primary-action-button-dark hover:bg-primary-action-button-hover-light dark:hover:bg-primary-action-button-hover-dark disabled:bg-primary-action-disabled-light dark:disabled:bg-primary-action-disabled-dark";case"secondary":return"border border-grey-0/0 bg-secondary-action-base-light dark:bg-secondary-action-base-dark hover:bg-system-neutral-grey-8-light dark:hover:bg-system-neutral-grey-8-dark disabled:bg-secondary-action-disabled-light dark:disabled:bg-secondary-action-disabled-dark";case"neutral":return"border border-separator-regular-light dark:border-separator-regular-dark hover:bg-background-universal-overlay-light dark:hover:bg-background-universal-overlay-dark disabled:bg-secondary-action-disabled-light dark:disabled:bg-secondary-action-disabled-dark disabled:border-separator-opaque-light dark:disabled:border-separator-opaque-dark";case"subtle":return"border border-grey-0/0 hover:bg-background-universal-overlay-light dark:hover:bg-background-universal-overlay-dark"}},Ae=(i,e)=>{if(e)return"text-label-tertiary-light dark:text-label-tertiary-dark";switch(i){case"primary":return"text-nonadaptable-text-light";case"secondary":return"text-label-quaternary-light dark:text-label-quaternary-dark";case"neutral":return"text-label-primary-light dark:text-label-primary-dark";case"subtle":return"text-label-primary-light dark:text-label-primary-dark"}},on=i=>{switch(i){case"xsmall":return"p-1";case"small":return"p-2";case"medium":return"p-3"}},ln=i=>{switch(i){case"xsmall":return"text-[10px] leading-[14px]";case"small":return"text-[13px] leading-[14px]";case"medium":return"text-[15px] leading-[16px] -tracking-0,1"}};function ht(i){var e,t,n="";if(typeof i=="string"||typeof i=="number")n+=i;else if(typeof i=="object")if(Array.isArray(i)){var r=i.length;for(e=0;e<r;e++)i[e]&&(t=ht(i[e]))&&(n&&(n+=" "),n+=t)}else for(t in i)i[t]&&(n&&(n+=" "),n+=t);return n}function cn(){for(var i,e,t=0,n="",r=arguments.length;t<r;t++)(i=arguments[t])&&(e=ht(i))&&(n&&(n+=" "),n+=e);return n}const M=cn,K=({children:i,className:e,variant:t="B1",significance:n="primary",as:r})=>{const s=r??un[t],a=ft[t];return le.jsx(s,{className:M("font-sans",dn[n],e,a),children:i})},ft={Di1:"text-[72px] font-bold leading-[90px] -tracking-2,5",Di2:"text-[60px] font-bold leading-[72px] -tracking-2,0",Di3:"text-[48px] font-bold leading-[60px] -tracking-1,5",T1:"text-[40px] font-bold leading-[48px] -tracking-1,5",T2:"text-[32px] font-bold leading-[40px] -tracking-1",T3:"text-[24px] font-bold leading-[32px] -tracking-0,5",H1:"text-[24px] font-bold leading-[32px] -tracking-0,5",H2:"text-[20px] font-bold leading-[24px]",H3:"text-[15px] font-bold leading-[20px]",H4:"text-[13px] font-bold leading-[16px]",B1B:"text-[15px] font-bold leading-[24px] -tracking-0,1",B1:"text-[15px] leading-[24px] -tracking-0,1",B1Button:"text-[15px] leading-[16px] -tracking-0,1",B2:"text-[13px] leading-[20px]",B2Button:"text-[13px] leading-[16px]",D1B:"text-[12px] font-bold leading-[16px]",D1:"text-[12px] leading-[16px]",M:"text-[10px] leading-[16px]"},un={Di1:"h1",Di2:"h2",Di3:"h3",T1:"h1",T2:"h2",T3:"h3",H1:"h1",H2:"h2",H3:"h3",H4:"h4",B1B:"p",B1:"p",B1Button:"span",B2:"p",B2Button:"span",D1B:"p",D1:"p",M:"p"},dn={primary:"text-label-primary-light dark:text-label-primary-dark",secondary:"text-label-secondary-light dark:text-label-secondary-dark",tertiary:"text-label-tertiary-light dark:text-label-tertiary-dark",quaternary:"text-label-quaternary-light dark:text-label-quaternary-dark",placeholder:"text-label-placeholder-light dark:text-label-placeholder-dark","nonadaptable-text":"text-nonadaptable-text-light dark:text-nonadaptable-text-dark",disabled:"text-primary-action-disabled-light dark:text-primary-action-disabled-dark"},gt=({title:i,icon:e,description:t,image:n,children:r,onPrevious:s,onNext:a,onQuit:o,isValid:c})=>{const{t:l}=ke();return m.jsxs("div",{className:M("grid mx-4 my-8 rounded-xl border relative","grid-cols-1 p-4 pt-10","md:p-8 md:gap-16 md:max-w-[960px] md:min-w-[660px]",n?"md:grid-cols-2":"md:grid-cols-1","border-separator-opaque-light dark:border-separator-opaque-dark material-ultra-thick"),children:[m.jsxs("div",{className:"flex flex-col justify-between order-2 md:order-1",children:[m.jsxs("div",{className:"flex flex-col",children:[m.jsxs("div",{className:"flex flex-col gap-1 md:gap-2 pb-3",children:[e&&m.jsx("div",{className:M("h-8 w-8 rounded-lg overflow-hidden mb-1 md:mb-2",n?"hidden md:block":"block"),children:m.jsx("img",{className:"w-full h-full object-cover",src:e,alt:"icon"})}),m.jsx(K,{variant:"H2",children:i}),t&&t.trim().replace(/\n{3,}/g,`
17
+ */var $e;function Xt(){if($e)return J;$e=1;var r=w,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(o,c,l){var u,d={},h=null,f=null;l!==void 0&&(h=""+l),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(f=c.ref);for(u in c)n.call(c,u)&&!s.hasOwnProperty(u)&&(d[u]=c[u]);if(o&&o.defaultProps)for(u in c=o.defaultProps,c)d[u]===void 0&&(d[u]=c[u]);return{$$typeof:e,type:o,key:h,ref:f,props:d,_owner:i.current}}return J.Fragment=t,J.jsx=a,J.jsxs=a,J}var Re;function en(){return Re||(Re=1,Te.exports=Xt()),Te.exports}var se=en();const I=({variant:r="primary",size:e="medium",text:t,iconBefore:n,iconAfter:i,className:s,disabled:a=!1,...o})=>se.jsx("button",{className:T("flex gap-2 justify-center items-center rounded-lg disabled:pointer-events-none",tn(r),nn(e),s),disabled:a,...o,children:se.jsxs(st.Provider,{value:{size:e==="xsmall"?8:16,weight:"regular",className:T(Fe(r,a))},children:[n&&n,t&&se.jsx("span",{className:T(Fe(r,a),rn(e)),children:t}),i&&i]})}),tn=r=>{switch(r){case"primary":return"border border-grey-0/0 bg-primary-action-button-light dark:bg-primary-action-button-dark hover:bg-primary-action-button-hover-light dark:hover:bg-primary-action-button-hover-dark disabled:bg-primary-action-disabled-light dark:disabled:bg-primary-action-disabled-dark";case"secondary":return"border border-grey-0/0 bg-secondary-action-base-light dark:bg-secondary-action-base-dark hover:bg-system-neutral-grey-8-light dark:hover:bg-system-neutral-grey-8-dark disabled:bg-secondary-action-disabled-light dark:disabled:bg-secondary-action-disabled-dark";case"neutral":return"border border-separator-regular-light dark:border-separator-regular-dark hover:bg-background-universal-overlay-light dark:hover:bg-background-universal-overlay-dark disabled:bg-secondary-action-disabled-light dark:disabled:bg-secondary-action-disabled-dark disabled:border-separator-opaque-light dark:disabled:border-separator-opaque-dark";case"subtle":return"border border-grey-0/0 hover:bg-background-universal-overlay-light dark:hover:bg-background-universal-overlay-dark"}},Fe=(r,e)=>{if(e)return"text-label-tertiary-light dark:text-label-tertiary-dark";switch(r){case"primary":return"text-nonadaptable-text-light";case"secondary":return"text-label-quaternary-light dark:text-label-quaternary-dark";case"neutral":return"text-label-primary-light dark:text-label-primary-dark";case"subtle":return"text-label-primary-light dark:text-label-primary-dark"}},nn=r=>{switch(r){case"xsmall":return"p-1";case"small":return"p-2";case"medium":return"p-3"}},rn=r=>{switch(r){case"xsmall":return"text-[10px] leading-[14px]";case"small":return"text-[13px] leading-[14px]";case"medium":return"text-[15px] leading-[16px] -tracking-0,1"}};function ct(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r)){var i=r.length;for(e=0;e<i;e++)r[e]&&(t=ct(r[e]))&&(n&&(n+=" "),n+=t)}else for(t in r)r[t]&&(n&&(n+=" "),n+=t);return n}function sn(){for(var r,e,t=0,n="",i=arguments.length;t<i;t++)(r=arguments[t])&&(e=ct(r))&&(n&&(n+=" "),n+=e);return n}const T=sn,V=({children:r,className:e,variant:t="B1",significance:n="primary",as:i})=>{const s=i??an[t],a=ut[t];return se.jsx(s,{className:T("font-sans",on[n],e,a),children:r})},ut={Di1:"text-[72px] font-bold leading-[90px] -tracking-2,5",Di2:"text-[60px] font-bold leading-[72px] -tracking-2,0",Di3:"text-[48px] font-bold leading-[60px] -tracking-1,5",T1:"text-[40px] font-bold leading-[48px] -tracking-1,5",T2:"text-[32px] font-bold leading-[40px] -tracking-1",T3:"text-[24px] font-bold leading-[32px] -tracking-0,5",H1:"text-[24px] font-bold leading-[32px] -tracking-0,5",H2:"text-[20px] font-bold leading-[24px]",H3:"text-[15px] font-bold leading-[20px]",H4:"text-[13px] font-bold leading-[16px]",B1B:"text-[15px] font-bold leading-[24px] -tracking-0,1",B1:"text-[15px] leading-[24px] -tracking-0,1",B1Button:"text-[15px] leading-[16px] -tracking-0,1",B2:"text-[13px] leading-[20px]",B2Button:"text-[13px] leading-[16px]",D1B:"text-[12px] font-bold leading-[16px]",D1:"text-[12px] leading-[16px]",M:"text-[10px] leading-[16px]"},an={Di1:"h1",Di2:"h2",Di3:"h3",T1:"h1",T2:"h2",T3:"h3",H1:"h1",H2:"h2",H3:"h3",H4:"h4",B1B:"p",B1:"p",B1Button:"span",B2:"p",B2Button:"span",D1B:"p",D1:"p",M:"p"},on={primary:"text-label-primary-light dark:text-label-primary-dark",secondary:"text-label-secondary-light dark:text-label-secondary-dark",tertiary:"text-label-tertiary-light dark:text-label-tertiary-dark",quaternary:"text-label-quaternary-light dark:text-label-quaternary-dark",placeholder:"text-label-placeholder-light dark:text-label-placeholder-dark","nonadaptable-text":"text-nonadaptable-text-light dark:text-nonadaptable-text-dark",disabled:"text-primary-action-disabled-light dark:text-primary-action-disabled-dark"},dt=({title:r,icon:e,description:t,image:n,children:i,onPrevious:s,onNext:a,onQuit:o,isValid:c,hasPreviousStep:l,hasNextStep:u})=>{const{t:d}=we();return m.jsxs("div",{className:T("grid mx-4 my-8 rounded-xl border relative","grid-cols-1 p-4 pt-10","md:p-8 md:gap-16 md:max-w-[960px] md:min-w-[660px]",n?"md:grid-cols-2":"md:grid-cols-1","border-separator-opaque-light dark:border-separator-opaque-dark material-ultra-thick"),children:[m.jsxs("div",{className:"flex flex-col justify-between order-2 md:order-1",children:[m.jsxs("div",{className:"flex flex-col",children:[m.jsxs("div",{className:"flex flex-col gap-1 md:gap-2 pb-3",children:[e&&m.jsx("div",{className:T("h-8 w-8 rounded-lg overflow-hidden mb-1 md:mb-2",n?"hidden md:block":"block"),children:m.jsx("img",{className:"w-full h-full object-cover",src:e,alt:"icon"})}),m.jsx(V,{variant:"H2",children:r}),t&&t.trim().replace(/\n{3,}/g,`
18
18
 
19
19
  `).split(`
20
20
 
21
- `).map((u,d)=>m.jsx(K,{significance:"secondary",children:u.trim()},d))]}),r]}),m.jsxs("div",{className:"flex justify-end pt-4 gap-2",children:[m.jsx(z,{variant:"subtle",onClick:s,iconBefore:m.jsx(ut,{}),disabled:!s,text:l("Previous")}),m.jsx(z,{variant:"subtle",onClick:a,iconAfter:m.jsx(dt,{}),disabled:!a||!c,text:l("Next")})]}),o&&m.jsx(z,{className:"absolute top-0 right-1 md:top-1",variant:"subtle",size:"small",onClick:o,iconAfter:m.jsx(de,{}),"aria-label":"quit"})]}),n&&m.jsx("div",{className:"flex flex-col justify-center order-1 md:order-2",children:m.jsx("div",{className:"rounded-lg overflow-hidden mb-6 md:mb-0",children:m.jsx("img",{className:"w-full h-full object-cover aspect-video md:aspect-square",src:n,alt:"image"})})})]})},hn=({title:i,icon:e,description:t,image:n,onPrevious:r,onNext:s,onQuit:a,alternatives:o=[],onAlternativeSelect:c,selectedAlternatives:l,maxAlternatives:u,isValid:d})=>m.jsx(gt,{title:i,icon:e,description:t,image:n,onPrevious:r,onNext:s,onQuit:a,isValid:d,children:m.jsx("div",{className:"flex flex-col max-h-[272px] md:max-h-full overflow-y-auto",children:u===1?m.jsx("div",{className:"flex flex-col py-3 md:py-4 gap-2 items-end md:items-start",children:o.map(h=>m.jsxs("button",{onClick:()=>c(h.id),className:"flex items-center gap-2 p-3 justify-end rounded-lg border text-label-primary-light dark:text-label-primary-dark border-separator-regular-light dark:border-separator-regular-dark",children:[m.jsx(K,{variant:"B1Button",children:h.text}),m.jsx(fn,{size:20,selected:l.includes(h.id)})]},h.id))}):m.jsx("div",{className:"flex py-3 md:py-4 gap-2 justify-end md:justify-start flex-wrap",children:o.map(h=>m.jsx("button",{onClick:()=>c(h.id),className:M("flex items-center gap-2 p-3 justify-end rounded-lg border",l.includes(h.id)?"text-label-quaternary-light dark:text-label-quaternary-dark border-label-quaternary-light dark:border-label-quaternary-dark bg-secondary-action-base-light dark:bg-secondary-action-base-dark":"text-label-primary-light dark:text-label-primary-dark border-separator-regular-light dark:border-separator-regular-dark"),children:m.jsx(K,{variant:"B1Button",significance:l.includes(h.id)?"quaternary":"primary",children:h.text})},h.id))})})}),fn=({size:i=16,strokeColor:e="currentColor",fillColor:t="none",selected:n=!1})=>{const r=i+1,s=r/2,a=(i-2)/2;return m.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${r} ${r}`,fill:n?t:"none",xmlns:"http://www.w3.org/2000/svg",children:[m.jsx("circle",{cx:s,cy:s,r:a,stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),n&&m.jsx("circle",{cx:s,cy:s,r:a-3,fill:e})]})},gn=({title:i,icon:e,description:t,image:n,onPrevious:r,onNext:s,onQuit:a,inputText:o,setInputText:c,maxCharacters:l,isValid:u})=>{const{t:d}=ke();return m.jsx(gt,{title:i,icon:e,description:t,image:n,onPrevious:r,onNext:s,onQuit:a,isValid:u,children:m.jsxs("div",{className:"flex flex-col py-3 gap-2",children:[l&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(K,{significance:"secondary",children:d("Max {{maxCharacters}} characters",{maxCharacters:l})}),m.jsx(K,{significance:"secondary",children:`${o.length}/${l}`})]}),m.jsxs("div",{className:"flex flex-col relative",children:[m.jsx(K,{as:"div",className:M("overflow-y-hidden whitespace-pre-wrap invisible break-words rounded-lg py-3 px-4 min-h-20 border-separator-opaque-light dark:border-separator-opaque-dark"),children:o}),m.jsx("textarea",{id:"primary",placeholder:d("Type your answer here"),className:M("absolute inset-0 resize-none","overflow-hidden break-words outline-none resize-none material-medium","rounded-lg py-3 px-4 min-h-20 border border-separator-opaque-light dark:border-separator-opaque-dark","text-label-primary-light dark:text-label-primary-dark",ft.B1),value:o,onChange:h=>c(h.target.value)})]})]})})},pt=({title:i,icon:e,description:t,image:n,children:r,wrapperClassName:s})=>m.jsxs("div",{className:M("grid mx-4 my-8 rounded-xl border","grid-cols-1 p-4 pt-10","md:p-8 md:gap-16 md:max-w-[960px] md:min-w-[660px]",n?"md:grid-cols-2":"md:grid-cols-1","border-separator-opaque-light dark:border-separator-opaque-dark material-ultra-thick",s),children:[m.jsxs("div",{className:"flex flex-col justify-between gap-6 md:gap-8 order-2 md:order-1",children:[m.jsxs("div",{className:"flex flex-col gap-6 md:gap-8",children:[m.jsxs("div",{className:"flex flex-col gap-2 md:gap-4",children:[e&&m.jsx("div",{className:M("h-8 w-8 rounded-lg overflow-hidden",n?"hidden md:block":"block"),children:m.jsx("img",{className:"w-full h-full object-cover",src:e,alt:"icon"})}),m.jsx(K,{variant:"H2",children:i})]}),t&&t.trim().replace(/\n{3,}/g,`
21
+ `).map((h,f)=>m.jsx(V,{significance:"secondary",children:h.trim()},f))]}),i]}),m.jsxs("div",{className:"flex justify-end pt-4 gap-2",children:[l&&m.jsx(I,{variant:"subtle",onClick:s,iconBefore:m.jsx(ot,{}),disabled:!s,text:d("Previous")}),m.jsx(I,{variant:"subtle",onClick:a,iconAfter:m.jsx(lt,{}),disabled:!a||!c,text:d(u?"Next":"Submit")})]}),o&&m.jsx(I,{className:"absolute top-0 right-1 md:top-1",variant:"subtle",size:"small",onClick:o,iconAfter:m.jsx(le,{}),"aria-label":"quit"})]}),n&&m.jsx("div",{className:"flex flex-col justify-center order-1 md:order-2",children:m.jsx("div",{className:"rounded-lg overflow-hidden mb-6 md:mb-0",children:m.jsx("img",{className:"w-full h-full object-cover aspect-video md:aspect-square",src:n,alt:"image"})})})]})},ln=({title:r,icon:e,description:t,image:n,onPrevious:i,onNext:s,onQuit:a,alternatives:o=[],onAlternativeSelect:c,selectedAlternatives:l,maxAlternatives:u,isValid:d,hasPreviousStep:h,hasNextStep:f})=>m.jsx(dt,{title:r,icon:e,description:t,image:n,onPrevious:i,onNext:s,onQuit:a,isValid:d,hasPreviousStep:h,hasNextStep:f,children:m.jsx("div",{className:"flex flex-col max-h-[272px] md:max-h-full overflow-y-auto",children:u===1?m.jsx("div",{className:"flex flex-col py-3 md:py-4 gap-2 items-end md:items-start",children:o.map(p=>m.jsxs("button",{onClick:()=>c(p.id),className:"flex items-center gap-2 p-3 justify-end rounded-lg border text-label-primary-light dark:text-label-primary-dark border-separator-regular-light dark:border-separator-regular-dark",children:[m.jsx(V,{variant:"B1Button",children:p.text}),m.jsx(cn,{size:20,selected:l.includes(p.id)})]},p.id))}):m.jsx("div",{className:"flex py-3 md:py-4 gap-2 justify-end md:justify-start flex-wrap",children:o.map(p=>m.jsx("button",{onClick:()=>c(p.id),className:T("flex items-center gap-2 p-3 justify-end rounded-lg border",l.includes(p.id)?"text-label-quaternary-light dark:text-label-quaternary-dark border-label-quaternary-light dark:border-label-quaternary-dark bg-secondary-action-base-light dark:bg-secondary-action-base-dark":"text-label-primary-light dark:text-label-primary-dark border-separator-regular-light dark:border-separator-regular-dark"),children:m.jsx(V,{variant:"B1Button",significance:l.includes(p.id)?"quaternary":"primary",children:p.text})},p.id))})})}),cn=({size:r=16,strokeColor:e="currentColor",fillColor:t="none",selected:n=!1})=>{const i=r+1,s=i/2,a=(r-2)/2;return m.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${i} ${i}`,fill:n?t:"none",xmlns:"http://www.w3.org/2000/svg",children:[m.jsx("circle",{cx:s,cy:s,r:a,stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),n&&m.jsx("circle",{cx:s,cy:s,r:a-3,fill:e})]})},un=({title:r,icon:e,description:t,image:n,onPrevious:i,onNext:s,onQuit:a,inputText:o,setInputText:c,maxCharacters:l,isValid:u,hasPreviousStep:d,hasNextStep:h})=>{const{t:f}=we();return m.jsx(dt,{title:r,icon:e,description:t,image:n,onPrevious:i,onNext:s,onQuit:a,isValid:u,hasPreviousStep:d,hasNextStep:h,children:m.jsxs("div",{className:"flex flex-col py-3 gap-2",children:[l&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(V,{significance:"secondary",children:f("Max {{maxCharacters}} characters",{maxCharacters:l})}),m.jsx(V,{significance:"secondary",children:`${o.length}/${l}`})]}),m.jsxs("div",{className:"flex flex-col relative",children:[m.jsx(V,{as:"div",className:T("overflow-y-hidden whitespace-pre-wrap invisible break-words rounded-lg py-3 px-4 min-h-20 border-separator-opaque-light dark:border-separator-opaque-dark"),children:o}),m.jsx("textarea",{id:"primary",placeholder:f("Type your answer here"),className:T("absolute inset-0 resize-none","overflow-hidden break-words outline-hidden resize-none material-medium","rounded-lg py-3 px-4 min-h-20 border border-separator-opaque-light dark:border-separator-opaque-dark","text-label-primary-light dark:text-label-primary-dark",ut.B1),value:o,onChange:p=>c(p.target.value)})]})]})})},ht=({title:r,icon:e,description:t,image:n,children:i,wrapperClassName:s})=>m.jsxs("div",{className:T("grid mx-4 my-8 rounded-xl border","grid-cols-1 p-4 pt-10","md:p-8 md:gap-16 md:max-w-[960px] md:min-w-[660px]",n?"md:grid-cols-2":"md:grid-cols-1","border-separator-opaque-light dark:border-separator-opaque-dark material-ultra-thick",s),children:[m.jsxs("div",{className:"flex flex-col justify-between gap-6 md:gap-8 order-2 md:order-1",children:[m.jsxs("div",{className:"flex flex-col gap-6 md:gap-8",children:[m.jsxs("div",{className:"flex flex-col gap-2 md:gap-4",children:[e&&m.jsx("div",{className:T("h-8 w-8 rounded-lg overflow-hidden",n?"hidden md:block":"block"),children:m.jsx("img",{className:"w-full h-full object-cover",src:e,alt:"icon"})}),m.jsx(V,{variant:"H2",children:r})]}),t&&t.trim().replace(/\n{3,}/g,`
22
22
 
23
23
  `).split(`
24
24
 
25
- `).map((a,o)=>m.jsx(K,{children:a.trim()},o))]}),r]}),n&&m.jsx("div",{className:"flex flex-col justify-center order-1 md:order-2",children:m.jsx("div",{className:"rounded-lg overflow-hidden mb-6 md:mb-0",children:m.jsx("img",{className:"w-full h-full object-cover aspect-video md:aspect-square",src:n,alt:"image"})})})]}),pn=({title:i,icon:e,description:t,image:n,quitText:r,onQuit:s,externalLink:a})=>m.jsxs(pt,{title:i,icon:e,description:t,image:n,children:[m.jsx("div",{className:"flex justify-end gap-2",children:a?m.jsx(z,{variant:"secondary",text:r,iconAfter:m.jsx(ct,{}),onClick:()=>{window.open(a,"_blank"),s==null||s()}}):m.jsx(z,{variant:"secondary",onClick:s,text:r})}),s&&m.jsx(z,{className:"absolute -top-2 -right-2 md:-top-4 md:-right-4",variant:"secondary",size:"small",onClick:s,iconAfter:m.jsx(de,{}),"aria-label":"quit"})]}),mn=({title:i,icon:e,description:t,image:n,quitText:r,onQuit:s,startText:a,onStart:o})=>m.jsxs(pt,{title:i,icon:e,description:t,image:n,wrapperClassName:"relative",children:[m.jsxs("div",{className:"flex justify-end gap-2",children:[s&&r&&m.jsx(z,{variant:"subtle",text:r,onClick:s}),m.jsx(z,{variant:"secondary",text:a,onClick:o})]}),s&&m.jsx(z,{className:"absolute top-0 right-1 md:top-1",variant:"subtle",size:"small",onClick:s,iconAfter:m.jsx(de,{}),"aria-label":"quit"})]});let mt={};function yn(){return mt}function xn(i){mt=i}const bn={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"}},wn=(i,e,t)=>{let n;const r=bn[i];return typeof r=="string"?n=r:e===1?n=r.one:n=r.other.replace("{{count}}",e.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};function pe(i){return(e={})=>{const t=e.width?String(e.width):i.defaultWidth;return i.formats[t]||i.formats[i.defaultWidth]}}const vn={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Sn=(i,e,t,n)=>vn[i];function Q(i){return(e,t)=>{const n=t!=null&&t.context?String(t.context):"standalone";let r;if(n==="formatting"&&i.formattingValues){const a=i.defaultFormattingWidth||i.defaultWidth,o=t!=null&&t.width?String(t.width):a;r=i.formattingValues[o]||i.formattingValues[a]}else{const a=i.defaultWidth,o=t!=null&&t.width?String(t.width):i.defaultWidth;r=i.values[o]||i.values[a]}const s=i.argumentCallback?i.argumentCallback(e):e;return r[s]}}const kn={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Ln={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},En={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"]},On={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"]},Pn={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"}},Cn={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"}},Nn=(i,e)=>{const t=Number(i),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},jn={ordinalNumber:Nn,era:Q({values:kn,defaultWidth:"wide"}),quarter:Q({values:Ln,defaultWidth:"wide",argumentCallback:i=>i-1}),month:Q({values:En,defaultWidth:"wide"}),day:Q({values:On,defaultWidth:"wide"}),dayPeriod:Q({values:Pn,defaultWidth:"wide",formattingValues:Cn,defaultFormattingWidth:"wide"})};function ee(i){return(e,t={})=>{const n=t.width,r=n&&i.matchPatterns[n]||i.matchPatterns[i.defaultMatchWidth],s=e.match(r);if(!s)return null;const a=s[0],o=n&&i.parsePatterns[n]||i.parsePatterns[i.defaultParseWidth],c=Array.isArray(o)?$n(o,d=>d.test(a)):Tn(o,d=>d.test(a));let l;l=i.valueCallback?i.valueCallback(c):c,l=t.valueCallback?t.valueCallback(l):l;const u=e.slice(a.length);return{value:l,rest:u}}}function Tn(i,e){for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&e(i[t]))return t}function $n(i,e){for(let t=0;t<i.length;t++)if(e(i[t]))return t}function Rn(i){return(e,t={})=>{const n=e.match(i.matchPattern);if(!n)return null;const r=n[0],s=e.match(i.parsePattern);if(!s)return null;let a=i.valueCallback?i.valueCallback(s[0]):s[0];a=t.valueCallback?t.valueCallback(a):a;const o=e.slice(r.length);return{value:a,rest:o}}}const Fn=/^(\d+)(th|st|nd|rd)?/i,Mn=/\d+/i,Dn={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},An={any:[/^b/i,/^(a|c)/i]},Vn={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},In={any:[/1/i,/2/i,/3/i,/4/i]},Hn={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},Bn={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]},zn={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},Kn={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]},qn={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},_n={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}},Un={ordinalNumber:Rn({matchPattern:Fn,parsePattern:Mn,valueCallback:i=>parseInt(i,10)}),era:ee({matchPatterns:Dn,defaultMatchWidth:"wide",parsePatterns:An,defaultParseWidth:"any"}),quarter:ee({matchPatterns:Vn,defaultMatchWidth:"wide",parsePatterns:In,defaultParseWidth:"any",valueCallback:i=>i+1}),month:ee({matchPatterns:Hn,defaultMatchWidth:"wide",parsePatterns:Bn,defaultParseWidth:"any"}),day:ee({matchPatterns:zn,defaultMatchWidth:"wide",parsePatterns:Kn,defaultParseWidth:"any"}),dayPeriod:ee({matchPatterns:qn,defaultMatchWidth:"any",parsePatterns:_n,defaultParseWidth:"any"})};function Wn(i){const e={},t=yn();for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);for(const n in i)Object.prototype.hasOwnProperty.call(i,n)&&(i[n]===void 0?delete e[n]:e[n]=i[n]);xn(e)}const Zn={full:"EEEE, d MMMM yyyy",long:"d MMMM yyyy",medium:"d MMM yyyy",short:"dd/MM/yyyy"},Jn={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Gn={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Yn={date:pe({formats:Zn,defaultWidth:"full"}),time:pe({formats:Jn,defaultWidth:"full"}),dateTime:pe({formats:Gn,defaultWidth:"full"})},Xn={code:"en-GB",formatDistance:wn,formatLong:Yn,formatRelative:Sn,localize:jn,match:Un,options:{weekStartsOn:1,firstWeekContainsDate:4}},x=i=>typeof i=="string",te=()=>{let i,e;const t=new Promise((n,r)=>{i=n,e=r});return t.resolve=i,t.reject=e,t},Ve=i=>i==null?"":""+i,Qn=(i,e,t)=>{i.forEach(n=>{e[n]&&(t[n]=e[n])})},er=/###/g,Ie=i=>i&&i.indexOf("###")>-1?i.replace(er,"."):i,He=i=>!i||x(i),ne=(i,e,t)=>{const n=x(e)?e.split("."):e;let r=0;for(;r<n.length-1;){if(He(i))return{};const s=Ie(n[r]);!i[s]&&t&&(i[s]=new t),Object.prototype.hasOwnProperty.call(i,s)?i=i[s]:i={},++r}return He(i)?{}:{obj:i,k:Ie(n[r])}},Be=(i,e,t)=>{const{obj:n,k:r}=ne(i,e,Object);if(n!==void 0||e.length===1){n[r]=t;return}let s=e[e.length-1],a=e.slice(0,e.length-1),o=ne(i,a,Object);for(;o.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),o=ne(i,a,Object),o!=null&&o.obj&&typeof o.obj[`${o.k}.${s}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${s}`]=t},tr=(i,e,t,n)=>{const{obj:r,k:s}=ne(i,e,Object);r[s]=r[s]||[],r[s].push(t)},ce=(i,e)=>{const{obj:t,k:n}=ne(i,e);if(t&&Object.prototype.hasOwnProperty.call(t,n))return t[n]},nr=(i,e,t)=>{const n=ce(i,t);return n!==void 0?n:ce(e,t)},yt=(i,e,t)=>{for(const n in e)n!=="__proto__"&&n!=="constructor"&&(n in i?x(i[n])||i[n]instanceof String||x(e[n])||e[n]instanceof String?t&&(i[n]=e[n]):yt(i[n],e[n],t):i[n]=e[n]);return i},U=i=>i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var rr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const ir=i=>x(i)?i.replace(/[&<>"'\/]/g,e=>rr[e]):i;class sr{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 n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}}const ar=[" ",",","?","!",";"],or=new sr(20),lr=(i,e,t)=>{e=e||"",t=t||"";const n=ar.filter(a=>e.indexOf(a)<0&&t.indexOf(a)<0);if(n.length===0)return!0;const r=or.getRegExp(`(${n.map(a=>a==="?"?"\\?":a).join("|")})`);let s=!r.test(i);if(!s){const a=i.indexOf(t);a>0&&!r.test(i.substring(0,a))&&(s=!0)}return s},we=(i,e,t=".")=>{if(!i)return;if(i[e])return Object.prototype.hasOwnProperty.call(i,e)?i[e]:void 0;const n=e.split(t);let r=i;for(let s=0;s<n.length;){if(!r||typeof r!="object")return;let a,o="";for(let c=s;c<n.length;++c)if(c!==s&&(o+=t),o+=n[c],a=r[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<n.length-1)continue;s+=c-s+1;break}r=a}return r},re=i=>i==null?void 0:i.replace("_","-"),cr={type:"logger",log(i){this.output("log",i)},warn(i){this.output("warn",i)},error(i){this.output("error",i)},output(i,e){var t,n;(n=(t=console==null?void 0:console[i])==null?void 0:t.apply)==null||n.call(t,console,e)}};let ur=class ve{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||cr,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,n,r){return r&&!this.debug?null:(x(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new ve(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new ve(this.logger,e)}};var V=new ur;class he{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(n=>{this.observers[n]||(this.observers[n]=new Map);const r=this.observers[n].get(t)||0;this.observers[n].set(t,r+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(([r,s])=>{for(let a=0;a<s;a++)r(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,s])=>{for(let a=0;a<s;a++)r.apply(r,[e,...t])})}}class ze extends he{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,n,r={}){var l,u;const s=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,a=r.ignoreJSONStructure!==void 0?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):x(n)&&s?o.push(...n.split(s)):o.push(n)));const c=ce(this.data,o);return!c&&!t&&!n&&e.indexOf(".")>-1&&(e=o[0],t=o[1],n=o.slice(2).join(".")),c||!a||!x(n)?c:we((u=(l=this.data)==null?void 0:l[e])==null?void 0:u[t],n,s)}addResource(e,t,n,r,s={silent:!1}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.indexOf(".")>-1&&(o=e.split("."),r=t,t=o[1]),this.addNamespaces(t),Be(this.data,o,r),s.silent||this.emit("added",e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(const s in n)(x(n[s])||Array.isArray(n[s]))&&this.addResource(e,t,s,n[s],{silent:!0});r.silent||this.emit("added",e,t,n)}addResourceBundle(e,t,n,r,s,a={silent:!1,skipCopy:!1}){let o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),r=n,n=t,t=o[1]),this.addNamespaces(t);let c=ce(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?yt(c,n,s):c={...c,...n},Be(this.data,o,c),a.silent||this.emit("added",e,t,n)}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(r=>t[r]&&Object.keys(t[r]).length>0)}toJSON(){return this.data}}var xt={processors:{},addPostProcessor(i){this.processors[i.name]=i},handle(i,e,t,n,r){return i.forEach(s=>{var a;e=((a=this.processors[s])==null?void 0:a.process(e,t,n,r))??e}),e}};const bt=Symbol("i18next/PATH_KEY");function dr(){const i=[],e=Object.create(null);let t;return e.get=(n,r)=>{var s;return(s=t==null?void 0:t.revoke)==null||s.call(t),r===bt?i:(i.push(r),t=Proxy.revocable(n,e),t.proxy)},Proxy.revocable(Object.create(null),e).proxy}function Se(i,e){const{[bt]:t}=i(dr());return t.join((e==null?void 0:e.keySeparator)??".")}const Ke={},qe=i=>!x(i)&&typeof i!="boolean"&&typeof i!="number";class ue extends he{constructor(e,t={}){super(),Qn(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=V.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const n={...t};if(e==null)return!1;const r=this.resolve(e,n);return(r==null?void 0:r.res)!==void 0}extractFromKey(e,t){let n=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;n===void 0&&(n=":");const r=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let s=t.ns||this.options.defaultNS||[];const a=n&&e.indexOf(n)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!lr(e,n,r);if(a&&!o){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:x(s)?[s]:s};const l=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(l[0])>-1)&&(s=l.shift()),e=l.join(r)}return{key:e,namespaces:x(s)?[s]:s}}translate(e,t,n){let r=typeof t=="object"?{...t}:t;if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),e==null)return"";typeof e=="function"&&(e=Se(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);const s=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],r),l=c[c.length-1];let u=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const d=r.lng||this.language,h=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((d==null?void 0:d.toLowerCase())==="cimode")return h?s?{res:`${l}${u}${o}`,usedKey:o,exactUsedKey:o,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${u}${o}`:s?{res:o,usedKey:o,exactUsedKey:o,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:o;const f=this.resolve(e,r);let g=f==null?void 0:f.res;const y=(f==null?void 0:f.usedKey)||o,b=(f==null?void 0:f.exactUsedKey)||o,S=["[object Number]","[object Function]","[object RegExp]"],L=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,E=!this.i18nFormat||this.i18nFormat.handleAsObject,C=r.count!==void 0&&!x(r.count),N=ue.hasDefaultValue(r),I=C?this.pluralResolver.getSuffix(d,r.count,r):"",T=r.ordinal&&C?this.pluralResolver.getSuffix(d,r.count,{ordinal:!1}):"",P=C&&!r.ordinal&&r.count===0,O=P&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${I}`]||r[`defaultValue${T}`]||r.defaultValue;let k=g;E&&!g&&N&&(k=O);const R=qe(k),Ct=Object.prototype.toString.apply(k);if(E&&k&&R&&S.indexOf(Ct)<0&&!(x(L)&&Array.isArray(k))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const D=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,k,{...r,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return s?(f.res=D,f.usedParams=this.getUsedParamsDetails(r),f):D}if(a){const D=Array.isArray(k),F=D?[]:{},Oe=D?b:y;for(const A in k)if(Object.prototype.hasOwnProperty.call(k,A)){const H=`${Oe}${a}${A}`;N&&!g?F[A]=this.translate(H,{...r,defaultValue:qe(O)?O[A]:void 0,joinArrays:!1,ns:c}):F[A]=this.translate(H,{...r,joinArrays:!1,ns:c}),F[A]===H&&(F[A]=k[A])}g=F}}else if(E&&x(L)&&Array.isArray(g))g=g.join(L),g&&(g=this.extendTranslation(g,e,r,n));else{let D=!1,F=!1;!this.isValidLookup(g)&&N&&(D=!0,g=O),this.isValidLookup(g)||(F=!0,g=o);const A=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&F?void 0:g,H=N&&O!==g&&this.options.updateMissing;if(F||D||H){if(this.logger.log(H?"updateKey":"missingKey",d,l,o,H?O:g),a){const $=this.resolve(o,{...r,keySeparator:!1});$&&$.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 J=[];const ae=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ae&&ae[0])for(let $=0;$<ae.length;$++)J.push(ae[$]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(r.lng||this.language):J.push(r.lng||this.language);const Pe=($,q,G)=>{var Ne;const Ce=N&&G!==g?G:A;this.options.missingKeyHandler?this.options.missingKeyHandler($,l,q,Ce,H,r):(Ne=this.backendConnector)!=null&&Ne.saveMissing&&this.backendConnector.saveMissing($,l,q,Ce,H,r),this.emit("missingKey",$,l,q,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?J.forEach($=>{const q=this.pluralResolver.getSuffixes($,r);P&&r[`defaultValue${this.options.pluralSeparator}zero`]&&q.indexOf(`${this.options.pluralSeparator}zero`)<0&&q.push(`${this.options.pluralSeparator}zero`),q.forEach(G=>{Pe([$],o+G,r[`defaultValue${G}`]||O)})}):Pe(J,o,O))}g=this.extendTranslation(g,e,r,f,n),F&&g===o&&this.options.appendNamespaceToMissingKey&&(g=`${l}${u}${o}`),(F||D)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${o}`:o,D?g:void 0,r))}return s?(f.res=g,f.usedParams=this.getUsedParamsDetails(r),f):g}extendTranslation(e,t,n,r,s){var c,l;if((c=this.i18nFormat)!=null&&c.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});const u=x(e)&&(((l=n==null?void 0:n.interpolation)==null?void 0:l.skipOnVariables)!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(u){const f=e.match(this.interpolator.nestingRegexp);d=f&&f.length}let h=n.replace&&!x(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(h={...this.options.interpolation.defaultVariables,...h}),e=this.interpolator.interpolate(e,h,n.lng||this.language||r.usedLng,n),u){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;d<g&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>(s==null?void 0:s[0])===f[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${t[0]}`),null):this.translate(...f,t),n)),n.interpolation&&this.interpolator.reset()}const a=n.postProcess||this.options.postProcess,o=x(a)?[a]:a;return e!=null&&(o!=null&&o.length)&&n.applyPostProcessor!==!1&&(e=xt.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,s,a,o;return x(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(n))return;const l=this.extractFromKey(c,t),u=l.key;r=u;let d=l.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const h=t.count!==void 0&&!x(t.count),f=h&&!t.ordinal&&t.count===0,g=t.context!==void 0&&(x(t.context)||typeof t.context=="number")&&t.context!=="",y=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);d.forEach(b=>{var S,L;this.isValidLookup(n)||(o=b,!Ke[`${y[0]}-${b}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((L=this.utils)!=null&&L.hasLoadedNamespace(o))&&(Ke[`${y[0]}-${b}`]=!0,this.logger.warn(`key "${r}" for languages "${y.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!!!")),y.forEach(E=>{var I;if(this.isValidLookup(n))return;a=E;const C=[u];if((I=this.i18nFormat)!=null&&I.addLookupKeys)this.i18nFormat.addLookupKeys(C,u,E,b,t);else{let T;h&&(T=this.pluralResolver.getSuffix(E,t.count,t));const P=`${this.options.pluralSeparator}zero`,O=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(t.ordinal&&T.indexOf(O)===0&&C.push(u+T.replace(O,this.options.pluralSeparator)),C.push(u+T),f&&C.push(u+P)),g){const k=`${u}${this.options.contextSeparator||"_"}${t.context}`;C.push(k),h&&(t.ordinal&&T.indexOf(O)===0&&C.push(k+T.replace(O,this.options.pluralSeparator)),C.push(k+T),f&&C.push(k+P))}}let N;for(;N=C.pop();)this.isValidLookup(n)||(s=N,n=this.getResource(E,b,N,t))}))})}),{res:n,usedKey:r,exactUsedKey:s,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,n,r={}){var s;return(s=this.i18nFormat)!=null&&s.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],n=e.replace&&!x(e.replace);let r=n?e.replace:e;if(n&&typeof e.count<"u"&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(const s of t)delete r[s]}return r}static hasDefaultValue(e){const t="defaultValue";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&e[n]!==void 0)return!0;return!1}}class _e{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=V.create("languageUtils")}getScriptPartFromCode(e){if(e=re(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=re(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(x(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(n=>{if(t)return;const r=this.formatLanguageCode(n);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(n=>{if(t)return;const r=this.getScriptPartFromCode(n);if(this.isSupportedCode(r))return t=r;const s=this.getLanguagePartFromCode(n);if(this.isSupportedCode(s))return t=s;t=this.options.supportedLngs.find(a=>{if(a===s)return a;if(!(a.indexOf("-")<0&&s.indexOf("-")<0)&&(a.indexOf("-")>0&&s.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===s||a.indexOf(s)===0&&s.length>1))return a})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),x(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){const n=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),r=[],s=a=>{a&&(this.isSupportedCode(a)?r.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return x(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))):x(e)&&s(this.formatLanguageCode(e)),n.forEach(a=>{r.indexOf(a)<0&&s(this.formatLanguageCode(a))}),r}}const Ue={zero:0,one:1,two:2,few:3,many:4,other:5},We={select:i=>i===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class hr{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=V.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const n=re(e==="dev"?"en":e),r=t.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:n,type:r});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),We;if(!e.match(/-|_/))return We;const c=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(c,t)}return this.pluralRulesCache[s]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||(n=this.getRule("dev",t)),(n==null?void 0:n.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(r=>`${t}${r}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||(n=this.getRule("dev",t)),n?n.resolvedOptions().pluralCategories.sort((r,s)=>Ue[r]-Ue[s]).map(r=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${r}`):[]}getSuffix(e,t,n={}){const r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,n))}}const Ze=(i,e,t,n=".",r=!0)=>{let s=nr(i,e,t);return!s&&r&&x(t)&&(s=we(i,t,n),s===void 0&&(s=we(e,t,n))),s},me=i=>i.replace(/\$/g,"$$$$");class fr{constructor(e={}){var t;this.logger=V.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:s,prefixEscaped:a,suffix:o,suffixEscaped:c,formatSeparator:l,unescapeSuffix:u,unescapePrefix:d,nestingPrefix:h,nestingPrefixEscaped:f,nestingSuffix:g,nestingSuffixEscaped:y,nestingOptionsSeparator:b,maxReplaces:S,alwaysFormat:L}=e.interpolation;this.escape=t!==void 0?t:ir,this.escapeValue=n!==void 0?n:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=s?U(s):a||"{{",this.suffix=o?U(o):c||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":d||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=h?U(h):f||U("$t("),this.nestingSuffix=g?U(g):y||U(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=S||1e3,this.alwaysFormat=L!==void 0?L:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,n)=>(t==null?void 0:t.source)===n?(t.lastIndex=0,t):new RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){var f;let s,a,o;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=g=>{if(g.indexOf(this.formatSeparator)<0){const L=Ze(t,c,g,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(L,void 0,n,{...r,...t,interpolationkey:g}):L}const y=g.split(this.formatSeparator),b=y.shift().trim(),S=y.join(this.formatSeparator).trim();return this.format(Ze(t,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),S,n,{...r,...t,interpolationkey:b})};this.resetRegExp();const u=(r==null?void 0:r.missingInterpolationHandler)||this.options.missingInterpolationHandler,d=((f=r==null?void 0:r.interpolation)==null?void 0:f.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:g=>me(g)},{regex:this.regexp,safeValue:g=>this.escapeValue?me(this.escape(g)):me(g)}].forEach(g=>{for(o=0;s=g.regex.exec(e);){const y=s[1].trim();if(a=l(y),a===void 0)if(typeof u=="function"){const S=u(e,s,r);a=x(S)?S:""}else if(r&&Object.prototype.hasOwnProperty.call(r,y))a="";else if(d){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${e}`),a="";else!x(a)&&!this.useRawValueToEscape&&(a=Ve(a));const b=g.safeValue(a);if(e=e.replace(s[0],b),d?(g.regex.lastIndex+=a.length,g.regex.lastIndex-=s[0].length):g.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,s,a;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,a);const f=h.match(/'/g),g=h.match(/"/g);(((f==null?void 0:f.length)??0)%2===0&&!g||g.length%2!==0)&&(h=h.replace(/'/g,'"'));try{a=JSON.parse(h),l&&(a={...l,...a})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${u}${h}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;r=this.nestingRegexp.exec(e);){let c=[];a={...n},a=a.replace&&!x(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const l=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(l!==-1&&(c=r[1].slice(l).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),s=t(o.call(this,r[1].trim(),a),a),s&&r[0]===e&&!x(s))return s;x(s)||(s=Ve(s)),s||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((u,d)=>this.format(u,d,n.lng,{...n,interpolationkey:r[1].trim()}),s.trim())),e=e.replace(r[0],s),this.regexp.lastIndex=0}return e}}const gr=i=>{let e=i.toLowerCase().trim();const t={};if(i.indexOf("(")>-1){const n=i.split("(");e=n[0].toLowerCase().trim();const r=n[1].substring(0,n[1].length-1);e==="currency"&&r.indexOf(":")<0?t.currency||(t.currency=r.trim()):e==="relativetime"&&r.indexOf(":")<0?t.range||(t.range=r.trim()):r.split(";").forEach(a=>{if(a){const[o,...c]=a.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}},Je=i=>{const e={};return(t,n,r)=>{let s=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(s={...s,[r.interpolationkey]:void 0});const a=n+JSON.stringify(s);let o=e[a];return o||(o=i(re(n),r),e[a]=o),o(t)}},pr=i=>(e,t,n)=>i(re(t),n)(e);class mr{constructor(e={}){this.logger=V.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const n=t.cacheInBuiltFormats?Je:pr;this.formats={number:n((r,s)=>{const a=new Intl.NumberFormat(r,{...s});return o=>a.format(o)}),currency:n((r,s)=>{const a=new Intl.NumberFormat(r,{...s,style:"currency"});return o=>a.format(o)}),datetime:n((r,s)=>{const a=new Intl.DateTimeFormat(r,{...s});return o=>a.format(o)}),relativetime:n((r,s)=>{const a=new Intl.RelativeTimeFormat(r,{...s});return o=>a.format(o,s.range||"day")}),list:n((r,s)=>{const a=new Intl.ListFormat(r,{...s});return o=>a.format(o)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Je(t)}format(e,t,n,r={}){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)=>{var d;const{formatName:l,formatOptions:u}=gr(c);if(this.formats[l]){let h=o;try{const f=((d=r==null?void 0:r.formatParams)==null?void 0:d[r.interpolationkey])||{},g=f.locale||f.lng||r.locale||r.lng||n;h=this.formats[l](o,g,{...u,...r,...f})}catch(f){this.logger.warn(f)}return h}else this.logger.warn(`there was no format function for ${l}`);return o},e)}}const yr=(i,e)=>{i.pending[e]!==void 0&&(delete i.pending[e],i.pendingCount--)};class xr extends he{constructor(e,t,n,r={}){var s,a;super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=V.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],(a=(s=this.backend)==null?void 0:s.init)==null||a.call(s,n,r.backend,r)}queueLoad(e,t,n,r){const s={},a={},o={},c={};return e.forEach(l=>{let u=!0;t.forEach(d=>{const h=`${l}|${d}`;!n.reload&&this.store.hasResourceBundle(l,d)?this.state[h]=2:this.state[h]<0||(this.state[h]===1?a[h]===void 0&&(a[h]=!0):(this.state[h]=1,u=!1,a[h]===void 0&&(a[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(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(c)}}loaded(e,t,n){const r=e.split("|"),s=r[0],a=r[1];t&&this.emit("failedLoading",s,a,t),!t&&n&&this.store.addResourceBundle(s,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);const o={};this.queue.forEach(c=>{tr(c.loaded,[s],a),yr(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,n,r=0,s=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:s,callback:a});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&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,n,r+1,s*2,a)},s);return}a(l,u)},c=this.backend[n].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,n={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();x(e)&&(e=this.languageUtils.toResolveHierarchy(e)),x(t)&&(t=[t]);const s=this.queueLoad(e,t,n,r);if(!s.toLoad.length)return s.pending.length||r(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=""){const n=e.split("|"),r=n[0],s=n[1];this.read(r,s,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${t}loading namespace ${s} for language ${r} failed`,a),!a&&o&&this.logger.log(`${t}loaded namespace ${s} for language ${r}`,o),this.loaded(e,a,o)})}saveMissing(e,t,n,r,s,a={},o=()=>{}){var c,l,u,d,h;if((l=(c=this.services)==null?void 0:c.utils)!=null&&l.hasLoadedNamespace&&!((d=(u=this.services)==null?void 0:u.utils)!=null&&d.hasLoadedNamespace(t))){this.logger.warn(`did not save key "${n}" 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(!(n==null||n==="")){if((h=this.backend)!=null&&h.create){const f={...a,isUpdate:s},g=this.backend.create.bind(this.backend);if(g.length<6)try{let y;g.length===5?y=g(e,t,n,r,f):y=g(e,t,n,r),y&&typeof y.then=="function"?y.then(b=>o(null,b)).catch(o):o(null,y)}catch(y){o(y)}else g(e,t,n,r,o,f)}!e||!e[0]||this.store.addResource(e[0],t,n,r)}}}const Ge=()=>({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:i=>{let e={};if(typeof i[1]=="object"&&(e=i[1]),x(i[1])&&(e.defaultValue=i[1]),x(i[2])&&(e.tDescription=i[2]),typeof i[2]=="object"||typeof i[3]=="object"){const t=i[3]||i[2];Object.keys(t).forEach(n=>{e[n]=t[n]})}return e},interpolation:{escapeValue:!0,format:i=>i,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Ye=i=>{var e,t;return x(i.ns)&&(i.ns=[i.ns]),x(i.fallbackLng)&&(i.fallbackLng=[i.fallbackLng]),x(i.fallbackNS)&&(i.fallbackNS=[i.fallbackNS]),((t=(e=i.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(i.supportedLngs=i.supportedLngs.concat(["cimode"])),typeof i.initImmediate=="boolean"&&(i.initAsync=i.initImmediate),i},oe=()=>{},br=i=>{Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach(t=>{typeof i[t]=="function"&&(i[t]=i[t].bind(i))})};class ie extends he{constructor(e={},t){if(super(),this.options=Ye(e),this.services={},this.logger=V,this.modules={external:[]},br(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&&(x(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const n=Ge();this.options={...n,...this.options,...Ye(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const r=l=>l?typeof l=="function"?new l:l:null;if(!this.options.isClone){this.modules.logger?V.init(r(this.modules.logger),this.options):V.init(null,this.options);let l;this.modules.formatter?l=this.modules.formatter:l=mr;const u=new _e(this.options);this.store=new ze(this.options.resources,this.options);const d=this.services;d.logger=V,d.resourceStore=this.store,d.languageUtils=u,d.pluralResolver=new hr(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==n.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===n.interpolation.format)&&(d.formatter=r(l),d.formatter.init&&d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new fr(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new xr(r(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",(f,...g)=>{this.emit(f,...g)}),this.modules.languageDetector&&(d.languageDetector=r(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=r(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new ue(this.services,this.options),this.translator.on("*",(f,...g)=>{this.emit(f,...g)}),this.modules.external.forEach(f=>{f.init&&f.init(this)})}if(this.format=this.options.interpolation.format,t||(t=oe),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=te(),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=oe){var s,a;let n=t;const r=x(e)?e:this.language;if(typeof e=="function"&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if((r==null?void 0:r.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return n();const o=[],c=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&o.indexOf(d)<0&&o.push(d)})};r?c(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>c(u)),(a=(s=this.options.preload)==null?void 0:s.forEach)==null||a.call(s,l=>c(l)),this.services.backendConnector.load(o,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(l)})}else n(null)}reloadResources(e,t,n){const r=te();return typeof e=="function"&&(n=e,e=void 0),typeof t=="function"&&(n=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),n||(n=oe),this.services.backendConnector.reload(e,t,s=>{r.resolve(),n(s)}),r}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"&&xt.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 n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;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 n=te();this.emit("languageChanging",e);const r=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&&(r(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,n.resolve((...l)=>this.t(...l)),t&&t(o,(...l)=>this.t(...l))},a=o=>{var u,d;!e&&!o&&this.services.languageDetector&&(o=[]);const c=x(o)?o:o&&o[0],l=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(x(o)?[o]:o);l&&(this.language||r(l),this.translator.language||this.translator.changeLanguage(l),(d=(u=this.services.languageDetector)==null?void 0:u.cacheUserLanguage)==null||d.call(u,l)),this.loadResources(l,h=>{s(h,l)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),n}getFixedT(e,t,n){const r=(s,a,...o)=>{let c;typeof a!="object"?c=this.options.overloadTranslationOptionHandler([s,a].concat(o)):c={...a},c.lng=c.lng||r.lng,c.lngs=c.lngs||r.lngs,c.ns=c.ns||r.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||n||r.keyPrefix);const l=this.options.keySeparator||".";let u;return c.keyPrefix&&Array.isArray(s)?u=s.map(d=>(typeof d=="function"&&(d=Se(d,{...this.options,...a})),`${c.keyPrefix}${l}${d}`)):(typeof s=="function"&&(s=Se(s,{...this.options,...a})),u=c.keyPrefix?`${c.keyPrefix}${l}${s}`:s),this.t(u,c)};return x(e)?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=n,r}t(...e){var t;return(t=this.translator)==null?void 0:t.translate(...e)}exists(...e){var t;return(t=this.translator)==null?void 0:t.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 n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(n.toLowerCase()==="cimode")return!0;const a=(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,a);if(o!==void 0)return o}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(s,e)))}loadNamespaces(e,t){const n=te();return this.options.ns?(x(e)&&(e=[e]),e.forEach(r=>{this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}),this.loadResources(r=>{n.resolve(),t&&t(r)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){const n=te();x(e)&&(e=[e]);const r=this.options.preload||[],s=e.filter(a=>r.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=r.concat(s),this.loadResources(a=>{n.resolve(),t&&t(a)}),n):(t&&t(),Promise.resolve())}dir(e){var r,s;if(e||(e=this.resolvedLanguage||(((r=this.languages)==null?void 0:r.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const a=new Intl.Locale(e);if(a&&a.getTextInfo){const o=a.getTextInfo();if(o&&o.direction)return o.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"],n=((s=this.services)==null?void 0:s.languageUtils)||new _e(Ge());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new ie(e,t)}cloneInstance(e={},t=oe){const n=e.forkResourceStore;n&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},s=new ie(r);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)},n){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 ze(o,r),s.services.resourceStore=s.store}return s.translator=new ue(s.services,r),s.translator.on("*",(o,...c)=>{s.emit(o,...c)}),s.init(r,t),s.translator.options=r,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=ie.createInstance();j.createInstance=ie.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:wr,forEach:vr}=[];function Sr(i){return vr.call(wr.call(arguments,1),e=>{if(e)for(const t in e)i[t]===void 0&&(i[t]=e[t])}),i}function kr(i){return typeof i!="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(i))}const Xe=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Lr=function(i,e){const n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},r=encodeURIComponent(e);let s=`${i}=${r}`;if(n.maxAge>0){const a=n.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(a)}`}if(n.domain){if(!Xe.test(n.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${n.domain}`}if(n.path){if(!Xe.test(n.path))throw new TypeError("option path is invalid");s+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(s+="; HttpOnly"),n.secure&&(s+="; Secure"),n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.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 n.partitioned&&(s+="; Partitioned"),s},Qe={create(i,e,t,n){let r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};t&&(r.expires=new Date,r.expires.setTime(r.expires.getTime()+t*60*1e3)),n&&(r.domain=n),document.cookie=Lr(i,e,r)},read(i){const e=`${i}=`,t=document.cookie.split(";");for(let n=0;n<t.length;n++){let r=t[n];for(;r.charAt(0)===" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return r.substring(e.length,r.length)}return null},remove(i,e){this.create(i,"",-1,e)}};var Er={name:"cookie",lookup(i){let{lookupCookie:e}=i;if(e&&typeof document<"u")return Qe.read(e)||void 0},cacheUserLanguage(i,e){let{lookupCookie:t,cookieMinutes:n,cookieDomain:r,cookieOptions:s}=e;t&&typeof document<"u"&&Qe.create(t,i,n,r,s)}},Or={name:"querystring",lookup(i){var n;let{lookupQuerystring:e}=i,t;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&((n=window.location.hash)==null?void 0:n.indexOf("?"))>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let o=0;o<a.length;o++){const c=a[o].indexOf("=");c>0&&a[o].substring(0,c)===e&&(t=a[o].substring(c+1))}}return t}},Pr={name:"hash",lookup(i){var r;let{lookupHash:e,lookupFromHashIndex:t}=i,n;if(typeof window<"u"){const{hash:s}=window.location;if(s&&s.length>2){const a=s.substring(1);if(e){const o=a.split("&");for(let c=0;c<o.length;c++){const l=o[c].indexOf("=");l>0&&o[c].substring(0,l)===e&&(n=o[c].substring(l+1))}}if(n)return n;if(!n&&t>-1){const o=s.match(/\/([a-zA-Z-]*)/g);return Array.isArray(o)?(r=o[typeof t=="number"?t:0])==null?void 0:r.replace("/",""):void 0}}}return n}};let W=null;const et=()=>{if(W!==null)return W;try{if(W=typeof window<"u"&&window.localStorage!==null,!W)return!1;const i="i18next.translate.boo";window.localStorage.setItem(i,"foo"),window.localStorage.removeItem(i)}catch{W=!1}return W};var Cr={name:"localStorage",lookup(i){let{lookupLocalStorage:e}=i;if(e&&et())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(i,e){let{lookupLocalStorage:t}=e;t&&et()&&window.localStorage.setItem(t,i)}};let Z=null;const tt=()=>{if(Z!==null)return Z;try{if(Z=typeof window<"u"&&window.sessionStorage!==null,!Z)return!1;const i="i18next.translate.boo";window.sessionStorage.setItem(i,"foo"),window.sessionStorage.removeItem(i)}catch{Z=!1}return Z};var Nr={name:"sessionStorage",lookup(i){let{lookupSessionStorage:e}=i;if(e&&tt())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(i,e){let{lookupSessionStorage:t}=e;t&&tt()&&window.sessionStorage.setItem(t,i)}},jr={name:"navigator",lookup(i){const e=[];if(typeof navigator<"u"){const{languages:t,userLanguage:n,language:r}=navigator;if(t)for(let s=0;s<t.length;s++)e.push(t[s]);n&&e.push(n),r&&e.push(r)}return e.length>0?e:void 0}},Tr={name:"htmlTag",lookup(i){let{htmlTag:e}=i,t;const n=e||(typeof document<"u"?document.documentElement:null);return n&&typeof n.getAttribute=="function"&&(t=n.getAttribute("lang")),t}},$r={name:"path",lookup(i){var r;let{lookupFromPathIndex:e}=i;if(typeof window>"u")return;const t=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(t)?(r=t[typeof e=="number"?e:0])==null?void 0:r.replace("/",""):void 0}},Rr={name:"subdomain",lookup(i){var r,s;let{lookupFromSubdomainIndex:e}=i;const t=typeof e=="number"?e+1:1,n=typeof window<"u"&&((s=(r=window.location)==null?void 0:r.hostname)==null?void 0:s.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));if(n)return n[t]}};let wt=!1;try{document.cookie,wt=!0}catch{}const vt=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];wt||vt.splice(1,1);const Fr=()=>({order:vt,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:i=>i});class St{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]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=Sr(t,this.options||{},Fr()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=r=>r.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(Er),this.addDetector(Or),this.addDetector(Cr),this.addDetector(Nr),this.addDetector(jr),this.addDetector(Tr),this.addDetector($r),this.addDetector(Rr),this.addDetector(Pr)}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(n=>{if(this.detectors[n]){let r=this.detectors[n].lookup(this.options);r&&typeof r=="string"&&(r=[r]),r&&(t=t.concat(r))}}),t=t.filter(n=>n!=null&&!kr(n)).map(n=>this.options.convertDetectedLanguage(n)),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(n=>{this.detectors[n]&&this.detectors[n].cacheUserLanguage(e,this.options)}))}}St.type="languageDetector";const kt={apiBaseUrl:"https://api.nemme.io",debug:!1},Mr="Previous",Dr="Next",Ar={Previous:Mr,Next:Dr,"Type your answer here":"Type your answer here","Max {{maxCharacters}} characters":"Max {{maxCharacters}} characters"},Vr={};Wn({locale:Xn});j.use(St).use(qt).init({debug:kt.debug,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:{translation:Ar},nb:{tranlation:Vr}}});const nt={debug:0,info:1,warn:2,error:3};class Le{constructor(e={}){v(this,"prefix");v(this,"enabled");v(this,"level");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&&nt[e]>=nt[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 Le({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 Lt=new Le,rt=Lt.child("network"),Ir=3e4,Hr=(i,e)=>{const t=new URL(i,kt.apiBaseUrl);return e&&Object.entries(e).forEach(([n,r])=>{r!=null&&t.searchParams.append(n,String(r))}),t.toString()},B={async request(i,e={}){const{method:t="GET",headers:n={},body:r,params:s,timeout:a=Ir}=e,o=Hr(i,s),c={"Content-Type":"application/json",Accept:"application/json",...n},l={method:t,headers:c,body:r?JSON.stringify(r):void 0},u=new AbortController,d=setTimeout(()=>u.abort(),a);l.signal=u.signal;try{const h=await fetch(o,l);let f;const g=h.headers.get("content-type");if(g&&g.includes("application/json"))f=await h.json();else{const b=await h.text();try{f=JSON.parse(b)}catch{f=b}}const y={data:f,status:h.status,statusText:h.statusText,headers:h.headers,ok:h.ok};if(h.ok)y.ok=!0;else{const b=`Request failed with status ${h.status}: ${h.statusText}`;rt.error(b,{url:o,method:t,status:h.status,data:y.data}),y.ok=!1,y.error={message:b,details:y.data}}return y}catch(h){let f="Network request failed",g={};return h instanceof DOMException&&h.name==="AbortError"?(f=`Request timeout after ${a}ms`,g={timeout:a,url:o}):g={message:h instanceof Error?h.message:String(h),url:o,method:t},rt.error(f,g),{data:{},status:0,statusText:f,headers:new Headers,ok:!1,error:{message:f,details:g}}}finally{clearTimeout(d)}},async get(i,e={}){return this.request(i,{...e,method:"GET"})},async post(i,e,t={}){return this.request(i,{...t,method:"POST",body:e})},async put(i,e,t={}){return this.request(i,{...t,method:"PUT",body:e})},async patch(i,e,t={}){return this.request(i,{...t,method:"PATCH",body:e})},async delete(i,e={}){return this.request(i,{...e,method:"DELETE"})}};class Br{constructor(e,t,n={}){v(this,"logger");v(this,"headers");v(this,"config");this.logger=e,this.headers=t,this.config=n}async fetchAndDisplayForm(e,t,n){this.logger.debug(`Fetching form config for: ${e}`);try{const r=await B.get(`/external/forms/${e}`,{headers:this.headers});r.ok&&r.data?(this.logger.info(`Form config loaded for: ${e}`,r.data),this.displayForm(r.data,t,n)):this.logger.warn(`No form config found for: ${e}`)}catch(r){this.logger.error(`Failed to fetch form config for: ${e}`,r)}}displayForm(e,t,n){const r=document.createElement("div");r.id="nm",document.body.appendChild(r);const s=Tt.createRoot(r),a=w.createElement(Zt,{i18n:j},w.createElement(Xt,{form:e,onDismiss:async o=>{await t(),s.unmount(),r.remove(),this.logger.info("Form dismissed",o)},onComplete:async o=>{await n(),await this.postFormResponse(e,o),s.unmount(),r.remove(),this.logger.info("Form completed",o)},zIndex:this.config.zIndex}));s.render(a)}async postFormResponse(e,t){this.logger.info("Posting form response",t);const n=await B.post(`/external/forms/${e.slug}`,t,{headers:this.headers});this.logger.info("Form response posted",n.data)}}class zr{constructor(e,t,n){v(this,"logger");v(this,"headers");v(this,"formManager");v(this,"deliveries",[]);this.logger=e,this.headers=t,this.formManager=new Br(e,t,n)}async loadDeliveries(){try{this.logger.debug("Loading deliveries");const e=await B.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 n of t.triggers)if(this.shouldTriggerDelivery(n,e)){if(!await this.isDeliveryValid(t)){this.logger.debug(`Delivery ${t.id} is not valid, skipping`);continue}await this.executeDelivery(t,n);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 r=await this.createDeliveryResponse(e);await this.formManager.fetchAndDisplayForm(e.productSlug,async()=>{this.logger.debug(`Form for delivery: ${e.productSlug} was cancelled`),r&&await this.updateDeliveryResponse(e.id,r.id,!0)},async()=>{this.logger.debug(`Form for delivery: ${e.productSlug} was completed`),r&&await this.updateDeliveryResponse(e.id,r.id,!1,!0)})}catch(r){this.logger.error(`Failed to load form for delivery: ${e.productSlug}`,r)}}}matchesUrlPattern(e,t){let n;try{n=new URL(e).pathname}catch{n=e.startsWith("/")?e:`/${e}`}const r=u=>{if(!u)return"/";let d=u.startsWith("/")?u:`/${u}`;return d.length>1&&d.endsWith("/")&&(d=d.slice(0,-1)),d},s=r(n),a=r(t),o=a.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:n,normalizedPathname:s,pattern:t,normalizedPattern:a,regexPattern:o,matches:l}),l}async createDeliveryResponse(e){try{return(await B.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,n=!1,r=!1){try{await B.patch(`/external/deliveries/${e}/responses/${t}`,{wasDismissed:n,wasCompleted:r},{headers:this.headers})}catch(s){this.logger.error(`Failed to update delivery response: ${t} for delivery: ${e}`,s)}}async isDeliveryValid(e){try{return(await B.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 Kr{constructor({logger:e,headers:t,sessionId:n,eventDefinitions:r,batchConfig:s,onPageView:a,onEvent:o}){v(this,"logger");v(this,"headers");v(this,"sessionId");v(this,"eventDefinitions",[]);v(this,"onPageView");v(this,"onEvent");v(this,"backlog",[]);v(this,"flushTimeout",null);v(this,"batchConfig",{enabled:!0,size:10,delayMs:1e4,sendOnUnload:!0});v(this,"originalHistoryMethods",null);v(this,"EVENT_PAGE_VIEW","page_view");this.logger=e,this.headers=t,this.sessionId=n,this.eventDefinitions=r,this.onPageView=a,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(...n)=>{e.apply(history,n),await this.trackPageView()};const t=history.replaceState;history.replaceState=async(...n)=>{t.apply(history,n),await this.trackPageView()},window.addEventListener("popstate",this.handlePopState),document.addEventListener("visibilitychange",this.handleVisibilityChange)}async track(e){var a,o;if(!this.sessionId){this.logger.warn("Tracking manager not initialized, cannot track event");return}const{eventKey:t,data:n={}}=e;this.logger.debug("Tracking event",{eventKey:t,data:n});const r=window.location.href,s={sessionId:this.sessionId,eventKey:t,data:n||{},timestamp:new Date().toISOString(),page:r};this.validateEvent(s),this.batchConfig.enabled?(this.backlog.push(s),this.scheduleFlush()):await this.sendEvents([s]),t===this.EVENT_PAGE_VIEW?(a=this.onPageView)==null||a.call(this,window.location.href):(o=this.onEvent)==null||o.call(this,s,r)}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 n=t.properties,r=e.data;if(r)for(const s of Object.keys(r)){const a=r[s],o=n.find(c=>c.name===s);if(!o){this.logger.warn(`Property ${s} is not registered for event ${e.eventKey}`);return}o.type==="string"&&typeof a!="string"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof a}`),o.type==="boolean"&&typeof a!="boolean"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof a}`),o.type==="number"&&typeof a!="number"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof a}`)}}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 B.post("/external/trackings/track",t,{headers:this.headers})}else await B.post("/external/trackings/batch",e,{headers:this.headers})}}class fe{constructor(e){v(this,"clientKey");v(this,"userIdentifier");v(this,"initialized",!1);v(this,"clientLogger",Lt.child("client"));v(this,"headers",{});v(this,"formConfig");v(this,"trackingManager");this.clientKey=e}async init({userIdentifier:e,debug:t=!1,batch:n,formConfig:r}){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=r;try{const s=await this.initializeSession();await this.initializeManagers(s,n),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(){var e;return(e=this.trackingManager)==null?void 0:e.flush()}destroy(){var e;(e=this.trackingManager)==null||e.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(){var e;try{const t=await B.post("/external/trackings/initialize",{},{headers:this.headers});if(!t.ok)throw new Error(((e=t.error)==null?void 0:e.message)||"Request for initialising session failed");return t.data}catch(t){throw this.clientLogger.error("Error during initialization",t),t}}async initializeManagers(e,t){const n=new zr(this.clientLogger,this.headers,this.formConfig),r=new Kr({logger:this.clientLogger,headers:this.headers,sessionId:e.sessionId,eventDefinitions:e.eventDefinitions,batchConfig:t,onPageView:async s=>{await n.evaluateDeliveryTriggers({url:s})},onEvent:async(s,a)=>{await n.evaluateDeliveryTriggers({eventKey:s.eventKey,eventData:s.data,url:a})}});await n.loadDeliveries(),typeof window<"u"&&(await r.setupPageViewTracking(),await r.trackPageView(),await r.flush()),this.trackingManager=r}}const Et=i=>new fe(i),Ot=w.createContext(void 0),qr=({clientKey:i,config:e,children:t})=>{const[n,r]=w.useState(null),[s,a]=w.useState(!1),[o,c]=w.useState(null);w.useEffect(()=>{let u=null,d=!1;const h=async()=>{try{const f=new fe(i);if(await f.init(e),d){f.destroy();return}u=f,r(f),a(!0),c(null)}catch(f){d||(c(f instanceof Error?f.message:"Failed to initialize Nemme client"),a(!1))}};return r(null),a(!1),c(null),h(),()=>{d=!0,u&&u.destroy()}},[i,e]);const l={client:n,isInitialized:s,error:o};return m.jsx(Ot.Provider,{value:l,children:t})},Pt=()=>{const i=w.useContext(Ot);if(i===void 0)throw new Error("useNemmeContext must be used within a NemmeProvider");return i},_r=()=>{const{client:i,isInitialized:e,error:t}=Pt(),n=w.useCallback(async s=>{if(!i||!e){console.warn("Nemme client not initialized");return}return i.track(s)},[i,e]),r=w.useCallback(async()=>{if(!i||!e){console.warn("Nemme client not initialized");return}return i.flush()},[i,e]);return{track:n,flush:r,isInitialized:e,error:t,client:i}},Ur=i=>Et(i),Wr=async i=>{const{clientKey:e,...t}=i;return await Et(e).init(t)},Ee=Object.assign(i=>Ur(i),{NemmeClient:fe,init:Wr});typeof window<"u"&&(window.NemmeSDK=Ee);exports.NemmeClient=fe;exports.NemmeProvider=qr;exports.NemmeSDK=Ee;exports.default=Ee;exports.useNemme=_r;exports.useNemmeContext=Pt;
25
+ `).map((a,o)=>m.jsx(V,{children:a.trim()},o))]}),i]}),n&&m.jsx("div",{className:"flex flex-col justify-center order-1 md:order-2",children:m.jsx("div",{className:"rounded-lg overflow-hidden mb-6 md:mb-0",children:m.jsx("img",{className:"w-full h-full object-cover aspect-video md:aspect-square",src:n,alt:"image"})})})]}),dn=({title:r,icon:e,description:t,image:n,quitText:i,onQuit:s,externalLink:a})=>m.jsxs(ht,{title:r,icon:e,description:t,image:n,children:[m.jsx("div",{className:"flex justify-end gap-2",children:a?m.jsx(I,{variant:"secondary",text:i,iconAfter:m.jsx(at,{}),onClick:()=>{window.open(a,"_blank"),s()}}):m.jsx(I,{variant:"secondary",onClick:s,text:i})}),a&&m.jsx(I,{className:"absolute -top-2 -right-2 md:-top-4 md:-right-4",variant:"secondary",size:"small",onClick:s,iconAfter:m.jsx(le,{}),"aria-label":"quit"})]}),hn=({title:r,icon:e,description:t,image:n,quitText:i,onQuit:s,startText:a,onStart:o})=>m.jsxs(ht,{title:r,icon:e,description:t,image:n,wrapperClassName:"relative",children:[m.jsxs("div",{className:"flex justify-end gap-2",children:[s&&i&&m.jsx(I,{variant:"subtle",text:i,onClick:s}),m.jsx(I,{variant:"secondary",text:a,onClick:o})]}),s&&m.jsx(I,{className:"absolute top-0 right-1 md:top-1",variant:"subtle",size:"small",onClick:s,iconAfter:m.jsx(le,{}),"aria-label":"quit"})]});let ft={};function fn(){return ft}function gn(r){ft=r}const pn={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"}},mn=(r,e,t)=>{let n;const i=pn[r];return typeof i=="string"?n=i:e===1?n=i.one:n=i.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};function he(r){return(e={})=>{const t=e.width?String(e.width):r.defaultWidth;return r.formats[t]||r.formats[r.defaultWidth]}}const yn={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},xn=(r,e,t,n)=>yn[r];function Q(r){return(e,t)=>{const n=t?.context?String(t.context):"standalone";let i;if(n==="formatting"&&r.formattingValues){const a=r.defaultFormattingWidth||r.defaultWidth,o=t?.width?String(t.width):a;i=r.formattingValues[o]||r.formattingValues[a]}else{const a=r.defaultWidth,o=t?.width?String(t.width):r.defaultWidth;i=r.values[o]||r.values[a]}const s=r.argumentCallback?r.argumentCallback(e):e;return i[s]}}const bn={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},wn={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},vn={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"]},Sn={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"]},kn={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"}},Ln={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"}},En=(r,e)=>{const t=Number(r),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},Pn={ordinalNumber:En,era:Q({values:bn,defaultWidth:"wide"}),quarter:Q({values:wn,defaultWidth:"wide",argumentCallback:r=>r-1}),month:Q({values:vn,defaultWidth:"wide"}),day:Q({values:Sn,defaultWidth:"wide"}),dayPeriod:Q({values:kn,defaultWidth:"wide",formattingValues:Ln,defaultFormattingWidth:"wide"})};function G(r){return(e,t={})=>{const n=t.width,i=n&&r.matchPatterns[n]||r.matchPatterns[r.defaultMatchWidth],s=e.match(i);if(!s)return null;const a=s[0],o=n&&r.parsePatterns[n]||r.parsePatterns[r.defaultParseWidth],c=Array.isArray(o)?Nn(o,d=>d.test(a)):On(o,d=>d.test(a));let l;l=r.valueCallback?r.valueCallback(c):c,l=t.valueCallback?t.valueCallback(l):l;const u=e.slice(a.length);return{value:l,rest:u}}}function On(r,e){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&e(r[t]))return t}function Nn(r,e){for(let t=0;t<r.length;t++)if(e(r[t]))return t}function Cn(r){return(e,t={})=>{const n=e.match(r.matchPattern);if(!n)return null;const i=n[0],s=e.match(r.parsePattern);if(!s)return null;let a=r.valueCallback?r.valueCallback(s[0]):s[0];a=t.valueCallback?t.valueCallback(a):a;const o=e.slice(i.length);return{value:a,rest:o}}}const jn=/^(\d+)(th|st|nd|rd)?/i,Tn=/\d+/i,$n={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},Rn={any:[/^b/i,/^(a|c)/i]},Fn={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Mn={any:[/1/i,/2/i,/3/i,/4/i]},Dn={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},An={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]},In={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},Vn={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]},Hn={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},Kn={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}},Bn={ordinalNumber:Cn({matchPattern:jn,parsePattern:Tn,valueCallback:r=>parseInt(r,10)}),era:G({matchPatterns:$n,defaultMatchWidth:"wide",parsePatterns:Rn,defaultParseWidth:"any"}),quarter:G({matchPatterns:Fn,defaultMatchWidth:"wide",parsePatterns:Mn,defaultParseWidth:"any",valueCallback:r=>r+1}),month:G({matchPatterns:Dn,defaultMatchWidth:"wide",parsePatterns:An,defaultParseWidth:"any"}),day:G({matchPatterns:In,defaultMatchWidth:"wide",parsePatterns:Vn,defaultParseWidth:"any"}),dayPeriod:G({matchPatterns:Hn,defaultMatchWidth:"any",parsePatterns:Kn,defaultParseWidth:"any"})};function qn(r){const e={},t=fn();for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(r[n]===void 0?delete e[n]:e[n]=r[n]);gn(e)}const zn={full:"EEEE, d MMMM yyyy",long:"d MMMM yyyy",medium:"d MMM yyyy",short:"dd/MM/yyyy"},_n={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Un={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Wn={date:he({formats:zn,defaultWidth:"full"}),time:he({formats:_n,defaultWidth:"full"}),dateTime:he({formats:Un,defaultWidth:"full"})},Zn={code:"en-GB",formatDistance:mn,formatLong:Wn,formatRelative:xn,localize:Pn,match:Bn,options:{weekStartsOn:1,firstWeekContainsDate:4}},x=r=>typeof r=="string",Y=()=>{let r,e;const t=new Promise((n,i)=>{r=n,e=i});return t.resolve=r,t.reject=e,t},Me=r=>r==null?"":""+r,Jn=(r,e,t)=>{r.forEach(n=>{e[n]&&(t[n]=e[n])})},Qn=/###/g,De=r=>r&&r.indexOf("###")>-1?r.replace(Qn,"."):r,Ae=r=>!r||x(r),X=(r,e,t)=>{const n=x(e)?e.split("."):e;let i=0;for(;i<n.length-1;){if(Ae(r))return{};const s=De(n[i]);!r[s]&&t&&(r[s]=new t),Object.prototype.hasOwnProperty.call(r,s)?r=r[s]:r={},++i}return Ae(r)?{}:{obj:r,k:De(n[i])}},Ie=(r,e,t)=>{const{obj:n,k:i}=X(r,e,Object);if(n!==void 0||e.length===1){n[i]=t;return}let s=e[e.length-1],a=e.slice(0,e.length-1),o=X(r,a,Object);for(;o.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),o=X(r,a,Object),o?.obj&&typeof o.obj[`${o.k}.${s}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${s}`]=t},Gn=(r,e,t,n)=>{const{obj:i,k:s}=X(r,e,Object);i[s]=i[s]||[],i[s].push(t)},ae=(r,e)=>{const{obj:t,k:n}=X(r,e);if(t&&Object.prototype.hasOwnProperty.call(t,n))return t[n]},Yn=(r,e,t)=>{const n=ae(r,t);return n!==void 0?n:ae(e,t)},gt=(r,e,t)=>{for(const n in e)n!=="__proto__"&&n!=="constructor"&&(n in r?x(r[n])||r[n]instanceof String||x(e[n])||e[n]instanceof String?t&&(r[n]=e[n]):gt(r[n],e[n],t):r[n]=e[n]);return r},q=r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Xn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const ei=r=>x(r)?r.replace(/[&<>"'\/]/g,e=>Xn[e]):r;class ti{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 n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}}const ni=[" ",",","?","!",";"],ii=new ti(20),ri=(r,e,t)=>{e=e||"",t=t||"";const n=ni.filter(a=>e.indexOf(a)<0&&t.indexOf(a)<0);if(n.length===0)return!0;const i=ii.getRegExp(`(${n.map(a=>a==="?"?"\\?":a).join("|")})`);let s=!i.test(r);if(!s){const a=r.indexOf(t);a>0&&!i.test(r.substring(0,a))&&(s=!0)}return s},ye=(r,e,t=".")=>{if(!r)return;if(r[e])return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0;const n=e.split(t);let i=r;for(let s=0;s<n.length;){if(!i||typeof i!="object")return;let a,o="";for(let c=s;c<n.length;++c)if(c!==s&&(o+=t),o+=n[c],a=i[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<n.length-1)continue;s+=c-s+1;break}i=a}return i},ee=r=>r?.replace("_","-"),si={type:"logger",log(r){this.output("log",r)},warn(r){this.output("warn",r)},error(r){this.output("error",r)},output(r,e){console?.[r]?.apply?.(console,e)}};let ai=class xe{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||si,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,n,i){return i&&!this.debug?null:(x(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new xe(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new xe(this.logger,e)}};var M=new ai;class ce{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(n=>{this.observers[n]||(this.observers[n]=new Map);const i=this.observers[n].get(t)||0;this.observers[n].set(t,i+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(([i,s])=>{for(let a=0;a<s;a++)i(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let a=0;a<s;a++)i.apply(i,[e,...t])})}}class Ve extends ce{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,n,i={}){const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):x(n)&&s?o.push(...n.split(s)):o.push(n)));const c=ae(this.data,o);return!c&&!t&&!n&&e.indexOf(".")>-1&&(e=o[0],t=o[1],n=o.slice(2).join(".")),c||!a||!x(n)?c:ye(this.data?.[e]?.[t],n,s)}addResource(e,t,n,i,s={silent:!1}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.indexOf(".")>-1&&(o=e.split("."),i=t,t=o[1]),this.addNamespaces(t),Ie(this.data,o,i),s.silent||this.emit("added",e,t,n,i)}addResources(e,t,n,i={silent:!1}){for(const s in n)(x(n[s])||Array.isArray(n[s]))&&this.addResource(e,t,s,n[s],{silent:!0});i.silent||this.emit("added",e,t,n)}addResourceBundle(e,t,n,i,s,a={silent:!1,skipCopy:!1}){let o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),i=n,n=t,t=o[1]),this.addNamespaces(t);let c=ae(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),i?gt(c,n,s):c={...c,...n},Ie(this.data,o,c),a.silent||this.emit("added",e,t,n)}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(i=>t[i]&&Object.keys(t[i]).length>0)}toJSON(){return this.data}}var pt={processors:{},addPostProcessor(r){this.processors[r.name]=r},handle(r,e,t,n,i){return r.forEach(s=>{e=this.processors[s]?.process(e,t,n,i)??e}),e}};const mt=Symbol("i18next/PATH_KEY");function oi(){const r=[],e=Object.create(null);let t;return e.get=(n,i)=>(t?.revoke?.(),i===mt?r:(r.push(i),t=Proxy.revocable(n,e),t.proxy)),Proxy.revocable(Object.create(null),e).proxy}function be(r,e){const{[mt]:t}=r(oi());return t.join(e?.keySeparator??".")}const He={},Ke=r=>!x(r)&&typeof r!="boolean"&&typeof r!="number";class oe extends ce{constructor(e,t={}){super(),Jn(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=M.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const n={...t};return e==null?!1:this.resolve(e,n)?.res!==void 0}extractFromKey(e,t){let n=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;n===void 0&&(n=":");const i=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let s=t.ns||this.options.defaultNS||[];const a=n&&e.indexOf(n)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!ri(e,n,i);if(a&&!o){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:x(s)?[s]:s};const l=e.split(n);(n!==i||n===i&&this.options.ns.indexOf(l[0])>-1)&&(s=l.shift()),e=l.join(i)}return{key:e,namespaces:x(s)?[s]:s}}translate(e,t,n){let i=typeof t=="object"?{...t}:t;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=be(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],i),l=c[c.length-1];let u=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const d=i.lng||this.language,h=i.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(i)}:`${l}${u}${o}`:s?{res:o,usedKey:o,exactUsedKey:o,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:o;const f=this.resolve(e,i);let p=f?.res;const y=f?.usedKey||o,b=f?.exactUsedKey||o,S=["[object Number]","[object Function]","[object RegExp]"],v=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,E=!this.i18nFormat||this.i18nFormat.handleAsObject,k=i.count!==void 0&&!x(i.count),L=oe.hasDefaultValue(i),P=k?this.pluralResolver.getSuffix(d,i.count,i):"",O=i.ordinal&&k?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):"",ke=k&&!i.ordinal&&i.count===0,H=ke&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${P}`]||i[`defaultValue${O}`]||i.defaultValue;let $=p;E&&!p&&L&&($=H);const Et=Ke($),Pt=Object.prototype.toString.apply($);if(E&&$&&Et&&S.indexOf(Pt)<0&&!(x(v)&&Array.isArray($))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,$,{...i,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return s?(f.res=R,f.usedParams=this.getUsedParamsDetails(i),f):R}if(a){const R=Array.isArray($),j=R?[]:{},Le=R?b:y;for(const F in $)if(Object.prototype.hasOwnProperty.call($,F)){const D=`${Le}${a}${F}`;L&&!p?j[F]=this.translate(D,{...i,defaultValue:Ke(H)?H[F]:void 0,joinArrays:!1,ns:c}):j[F]=this.translate(D,{...i,joinArrays:!1,ns:c}),j[F]===D&&(j[F]=$[F])}p=j}}else if(E&&x(v)&&Array.isArray(p))p=p.join(v),p&&(p=this.extendTranslation(p,e,i,n));else{let R=!1,j=!1;!this.isValidLookup(p)&&L&&(R=!0,p=H),this.isValidLookup(p)||(j=!0,p=o);const F=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:p,D=L&&H!==p&&this.options.updateMissing;if(j||R||D){if(this.logger.log(D?"updateKey":"missingKey",d,l,o,D?H:p),a){const C=this.resolve(o,{...i,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 U=[];const ie=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ie&&ie[0])for(let C=0;C<ie.length;C++)U.push(ie[C]);else this.options.saveMissingTo==="all"?U=this.languageUtils.toResolveHierarchy(i.lng||this.language):U.push(i.lng||this.language);const Ee=(C,K,W)=>{const Pe=L&&W!==p?W:F;this.options.missingKeyHandler?this.options.missingKeyHandler(C,l,K,Pe,D,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(C,l,K,Pe,D,i),this.emit("missingKey",C,l,K,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&k?U.forEach(C=>{const K=this.pluralResolver.getSuffixes(C,i);ke&&i[`defaultValue${this.options.pluralSeparator}zero`]&&K.indexOf(`${this.options.pluralSeparator}zero`)<0&&K.push(`${this.options.pluralSeparator}zero`),K.forEach(W=>{Ee([C],o+W,i[`defaultValue${W}`]||H)})}):Ee(U,o,H))}p=this.extendTranslation(p,e,i,f,n),j&&p===o&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${o}`),(j||R)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${o}`:o,R?p:void 0,i))}return s?(f.res=p,f.usedParams=this.getUsedParamsDetails(i),f):p}extendTranslation(e,t,n,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});const c=x(e)&&(n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let l;if(c){const d=e.match(this.interpolator.nestingRegexp);l=d&&d.length}let u=n.replace&&!x(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,n.lng||this.language||i.usedLng,n),c){const d=e.match(this.interpolator.nestingRegexp),h=d&&d.length;l<h&&(n.nest=!1)}!n.lng&&i&&i.res&&(n.lng=this.language||i.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>s?.[0]===d[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`),null):this.translate(...d,t),n)),n.interpolation&&this.interpolator.reset()}const a=n.postProcess||this.options.postProcess,o=x(a)?[a]:a;return e!=null&&o?.length&&n.applyPostProcessor!==!1&&(e=pt.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,i,s,a,o;return x(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(n))return;const l=this.extractFromKey(c,t),u=l.key;i=u;let d=l.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const h=t.count!==void 0&&!x(t.count),f=h&&!t.ordinal&&t.count===0,p=t.context!==void 0&&(x(t.context)||typeof t.context=="number")&&t.context!=="",y=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);d.forEach(b=>{this.isValidLookup(n)||(o=b,!He[`${y[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(He[`${y[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${y.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!!!")),y.forEach(S=>{if(this.isValidLookup(n))return;a=S;const v=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(v,u,S,b,t);else{let k;h&&(k=this.pluralResolver.getSuffix(S,t.count,t));const L=`${this.options.pluralSeparator}zero`,P=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(t.ordinal&&k.indexOf(P)===0&&v.push(u+k.replace(P,this.options.pluralSeparator)),v.push(u+k),f&&v.push(u+L)),p){const O=`${u}${this.options.contextSeparator||"_"}${t.context}`;v.push(O),h&&(t.ordinal&&k.indexOf(P)===0&&v.push(O+k.replace(P,this.options.pluralSeparator)),v.push(O+k),f&&v.push(O+L))}}let E;for(;E=v.pop();)this.isValidLookup(n)||(s=E,n=this.getResource(S,b,E,t))}))})}),{res:n,usedKey:i,exactUsedKey:s,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,n,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,i):this.resourceStore.getResource(e,t,n,i)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],n=e.replace&&!x(e.replace);let i=n?e.replace:e;if(n&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!n){i={...i};for(const s of t)delete i[s]}return i}static hasDefaultValue(e){const t="defaultValue";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&e[n]!==void 0)return!0;return!1}}class Be{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=M.create("languageUtils")}getScriptPartFromCode(e){if(e=ee(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=ee(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(x(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(n=>{if(t)return;const i=this.formatLanguageCode(n);(!this.options.supportedLngs||this.isSupportedCode(i))&&(t=i)}),!t&&this.options.supportedLngs&&e.forEach(n=>{if(t)return;const i=this.getScriptPartFromCode(n);if(this.isSupportedCode(i))return t=i;const s=this.getLanguagePartFromCode(n);if(this.isSupportedCode(s))return t=s;t=this.options.supportedLngs.find(a=>{if(a===s)return a;if(!(a.indexOf("-")<0&&s.indexOf("-")<0)&&(a.indexOf("-")>0&&s.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===s||a.indexOf(s)===0&&s.length>1))return a})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),x(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){const n=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),i=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return x(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))):x(e)&&s(this.formatLanguageCode(e)),n.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const qe={zero:0,one:1,two:2,few:3,many:4,other:5},ze={select:r=>r===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class li{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=M.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const n=ee(e==="dev"?"en":e),i=t.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:n,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let a;try{a=new Intl.PluralRules(n,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ze;if(!e.match(/-|_/))return ze;const c=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(c,t)}return this.pluralRulesCache[s]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||(n=this.getRule("dev",t)),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(i=>`${t}${i}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||(n=this.getRule("dev",t)),n?n.resolvedOptions().pluralCategories.sort((i,s)=>qe[i]-qe[s]).map(i=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,t,n={}){const i=this.getRule(e,n);return i?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,n))}}const _e=(r,e,t,n=".",i=!0)=>{let s=Yn(r,e,t);return!s&&i&&x(t)&&(s=ye(r,t,n),s===void 0&&(s=ye(e,t,n))),s},fe=r=>r.replace(/\$/g,"$$$$");class ci{constructor(e={}){this.logger=M.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:n,useRawValueToEscape:i,prefix:s,prefixEscaped:a,suffix:o,suffixEscaped:c,formatSeparator:l,unescapeSuffix:u,unescapePrefix:d,nestingPrefix:h,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:y,nestingOptionsSeparator:b,maxReplaces:S,alwaysFormat:v}=e.interpolation;this.escape=t!==void 0?t:ei,this.escapeValue=n!==void 0?n:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?q(s):a||"{{",this.suffix=o?q(o):c||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":d||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=h?q(h):f||q("$t("),this.nestingSuffix=p?q(p):y||q(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=S||1e3,this.alwaysFormat=v!==void 0?v:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,n)=>t?.source===n?(t.lastIndex=0,t):new RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,i){let s,a,o;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=f=>{if(f.indexOf(this.formatSeparator)<0){const S=_e(t,c,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(S,void 0,n,{...i,...t,interpolationkey:f}):S}const p=f.split(this.formatSeparator),y=p.shift().trim(),b=p.join(this.formatSeparator).trim();return this.format(_e(t,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),b,n,{...i,...t,interpolationkey:y})};this.resetRegExp();const u=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,d=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:f=>fe(f)},{regex:this.regexp,safeValue:f=>this.escapeValue?fe(this.escape(f)):fe(f)}].forEach(f=>{for(o=0;s=f.regex.exec(e);){const p=s[1].trim();if(a=l(p),a===void 0)if(typeof u=="function"){const b=u(e,s,i);a=x(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,p))a="";else if(d){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${p} for interpolating ${e}`),a="";else!x(a)&&!this.useRawValueToEscape&&(a=Me(a));const y=f.safeValue(a);if(e=e.replace(s[0],y),d?(f.regex.lastIndex+=a.length,f.regex.lastIndex-=s[0].length):f.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,n={}){let i,s,a;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,a);const f=h.match(/'/g),p=h.match(/"/g);((f?.length??0)%2===0&&!p||p.length%2!==0)&&(h=h.replace(/'/g,'"'));try{a=JSON.parse(h),l&&(a={...l,...a})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${u}${h}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];a={...n},a=a.replace&&!x(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const l=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(l!==-1&&(c=i[1].slice(l).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),i[1]=i[1].slice(0,l)),s=t(o.call(this,i[1].trim(),a),a),s&&i[0]===e&&!x(s))return s;x(s)||(s=Me(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((u,d)=>this.format(u,d,n.lng,{...n,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const ui=r=>{let e=r.toLowerCase().trim();const t={};if(r.indexOf("(")>-1){const n=r.split("(");e=n[0].toLowerCase().trim();const i=n[1].substring(0,n[1].length-1);e==="currency"&&i.indexOf(":")<0?t.currency||(t.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?t.range||(t.range=i.trim()):i.split(";").forEach(a=>{if(a){const[o,...c]=a.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}},Ue=r=>{const e={};return(t,n,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const a=n+JSON.stringify(s);let o=e[a];return o||(o=r(ee(n),i),e[a]=o),o(t)}},di=r=>(e,t,n)=>r(ee(t),n)(e);class hi{constructor(e={}){this.logger=M.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const n=t.cacheInBuiltFormats?Ue:di;this.formats={number:n((i,s)=>{const a=new Intl.NumberFormat(i,{...s});return o=>a.format(o)}),currency:n((i,s)=>{const a=new Intl.NumberFormat(i,{...s,style:"currency"});return o=>a.format(o)}),datetime:n((i,s)=>{const a=new Intl.DateTimeFormat(i,{...s});return o=>a.format(o)}),relativetime:n((i,s)=>{const a=new Intl.RelativeTimeFormat(i,{...s});return o=>a.format(o,s.range||"day")}),list:n((i,s)=>{const a=new Intl.ListFormat(i,{...s});return o=>a.format(o)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Ue(t)}format(e,t,n,i={}){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}=ui(c);if(this.formats[l]){let d=o;try{const h=i?.formatParams?.[i.interpolationkey]||{},f=h.locale||h.lng||i.locale||i.lng||n;d=this.formats[l](o,f,{...u,...i,...h})}catch(h){this.logger.warn(h)}return d}else this.logger.warn(`there was no format function for ${l}`);return o},e)}}const fi=(r,e)=>{r.pending[e]!==void 0&&(delete r.pending[e],r.pendingCount--)};class gi extends ce{constructor(e,t,n,i={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=i,this.logger=M.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,i.backend,i)}queueLoad(e,t,n,i){const s={},a={},o={},c={};return e.forEach(l=>{let u=!0;t.forEach(d=>{const h=`${l}|${d}`;!n.reload&&this.store.hasResourceBundle(l,d)?this.state[h]=2:this.state[h]<0||(this.state[h]===1?a[h]===void 0&&(a[h]=!0):(this.state[h]=1,u=!1,a[h]===void 0&&(a[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(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(c)}}loaded(e,t,n){const i=e.split("|"),s=i[0],a=i[1];t&&this.emit("failedLoading",s,a,t),!t&&n&&this.store.addResourceBundle(s,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);const o={};this.queue.forEach(c=>{Gn(c.loaded,[s],a),fi(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,n,i=0,s=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:i,wait:s,callback:a});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&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,n,i+1,s*2,a)},s);return}a(l,u)},c=this.backend[n].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,n={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();x(e)&&(e=this.languageUtils.toResolveHierarchy(e)),x(t)&&(t=[t]);const s=this.queueLoad(e,t,n,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=""){const n=e.split("|"),i=n[0],s=n[1];this.read(i,s,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${t}loading namespace ${s} for language ${i} failed`,a),!a&&o&&this.logger.log(`${t}loaded namespace ${s} for language ${i}`,o),this.loaded(e,a,o)})}saveMissing(e,t,n,i,s,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" 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(!(n==null||n==="")){if(this.backend?.create){const c={...a,isUpdate:s},l=this.backend.create.bind(this.backend);if(l.length<6)try{let u;l.length===5?u=l(e,t,n,i,c):u=l(e,t,n,i),u&&typeof u.then=="function"?u.then(d=>o(null,d)).catch(o):o(null,u)}catch(u){o(u)}else l(e,t,n,i,o,c)}!e||!e[0]||this.store.addResource(e[0],t,n,i)}}}const We=()=>({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:r=>{let e={};if(typeof r[1]=="object"&&(e=r[1]),x(r[1])&&(e.defaultValue=r[1]),x(r[2])&&(e.tDescription=r[2]),typeof r[2]=="object"||typeof r[3]=="object"){const t=r[3]||r[2];Object.keys(t).forEach(n=>{e[n]=t[n]})}return e},interpolation:{escapeValue:!0,format:r=>r,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Ze=r=>(x(r.ns)&&(r.ns=[r.ns]),x(r.fallbackLng)&&(r.fallbackLng=[r.fallbackLng]),x(r.fallbackNS)&&(r.fallbackNS=[r.fallbackNS]),r.supportedLngs?.indexOf?.("cimode")<0&&(r.supportedLngs=r.supportedLngs.concat(["cimode"])),typeof r.initImmediate=="boolean"&&(r.initAsync=r.initImmediate),r),re=()=>{},pi=r=>{Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach(t=>{typeof r[t]=="function"&&(r[t]=r[t].bind(r))})};class te extends ce{constructor(e={},t){if(super(),this.options=Ze(e),this.services={},this.logger=M,this.modules={external:[]},pi(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&&(x(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const n=We();this.options={...n,...this.options,...Ze(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=l=>l?typeof l=="function"?new l:l:null;if(!this.options.isClone){this.modules.logger?M.init(i(this.modules.logger),this.options):M.init(null,this.options);let l;this.modules.formatter?l=this.modules.formatter:l=hi;const u=new Be(this.options);this.store=new Ve(this.options.resources,this.options);const d=this.services;d.logger=M,d.resourceStore=this.store,d.languageUtils=u,d.pluralResolver=new li(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==n.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===n.interpolation.format)&&(d.formatter=i(l),d.formatter.init&&d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new ci(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new gi(i(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",(f,...p)=>{this.emit(f,...p)}),this.modules.languageDetector&&(d.languageDetector=i(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=i(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new oe(this.services,this.options),this.translator.on("*",(f,...p)=>{this.emit(f,...p)}),this.modules.external.forEach(f=>{f.init&&f.init(this)})}if(this.format=this.options.interpolation.format,t||(t=re),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=Y(),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=re){let n=t;const i=x(e)?e:this.language;if(typeof e=="function"&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return n();const s=[],a=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(l=>{l!=="cimode"&&s.indexOf(l)<0&&s.push(l)})};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload?.forEach?.(o=>a(o)),this.services.backendConnector.load(s,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(o)})}else n(null)}reloadResources(e,t,n){const i=Y();return typeof e=="function"&&(n=e,e=void 0),typeof t=="function"&&(n=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),n||(n=re),this.services.backendConnector.reload(e,t,s=>{i.resolve(),n(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return 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"&&pt.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 n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;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 n=Y();this.emit("languageChanging",e);const i=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&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,n.resolve((...l)=>this.t(...l)),t&&t(o,(...l)=>this.t(...l))},a=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const c=x(o)?o:o&&o[0],l=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(x(o)?[o]:o);l&&(this.language||i(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?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),n}getFixedT(e,t,n){const i=(s,a,...o)=>{let c;typeof a!="object"?c=this.options.overloadTranslationOptionHandler([s,a].concat(o)):c={...a},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||n||i.keyPrefix);const l=this.options.keySeparator||".";let u;return c.keyPrefix&&Array.isArray(s)?u=s.map(d=>(typeof d=="function"&&(d=be(d,{...this.options,...a})),`${c.keyPrefix}${l}${d}`)):(typeof s=="function"&&(s=be(s,{...this.options,...a})),u=c.keyPrefix?`${c.keyPrefix}${l}${s}`:s),this.t(u,c)};return x(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}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 n=t.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(n.toLowerCase()==="cimode")return!0;const a=(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,a);if(o!==void 0)return o}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!i||a(s,e)))}loadNamespaces(e,t){const n=Y();return this.options.ns?(x(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{n.resolve(),t&&t(i)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){const n=Y();x(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=i.concat(s),this.loadResources(a=>{n.resolve(),t&&t(a)}),n):(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 i=new Intl.Locale(e);if(i&&i.getTextInfo){const s=i.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"],n=this.services?.languageUtils||new Be(We());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new te(e,t)}cloneInstance(e={},t=re){const n=e.forkResourceStore;n&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new te(i);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)},n){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 Ve(o,i),s.services.resourceStore=s.store}return s.translator=new oe(s.services,i),s.translator.on("*",(o,...c)=>{s.emit(o,...c)}),s.init(i,t),s.translator.options=i,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 N=te.createInstance();N.createInstance=te.createInstance;N.createInstance;N.dir;N.init;N.loadResources;N.reloadResources;N.use;N.changeLanguage;N.getFixedT;N.t;N.exists;N.setDefaultNamespace;N.hasLoadedNamespace;N.loadNamespaces;N.loadLanguages;const{slice:mi,forEach:yi}=[];function xi(r){return yi.call(mi.call(arguments,1),e=>{if(e)for(const t in e)r[t]===void 0&&(r[t]=e[t])}),r}function bi(r){return typeof r!="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(r))}const Je=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,wi=function(r,e){const n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let s=`${r}=${i}`;if(n.maxAge>0){const a=n.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(a)}`}if(n.domain){if(!Je.test(n.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${n.domain}`}if(n.path){if(!Je.test(n.path))throw new TypeError("option path is invalid");s+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(s+="; HttpOnly"),n.secure&&(s+="; Secure"),n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.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 n.partitioned&&(s+="; Partitioned"),s},Qe={create(r,e,t,n){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};t&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+t*60*1e3)),n&&(i.domain=n),document.cookie=wi(r,e,i)},read(r){const e=`${r}=`,t=document.cookie.split(";");for(let n=0;n<t.length;n++){let i=t[n];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null},remove(r,e){this.create(r,"",-1,e)}};var vi={name:"cookie",lookup(r){let{lookupCookie:e}=r;if(e&&typeof document<"u")return Qe.read(e)||void 0},cacheUserLanguage(r,e){let{lookupCookie:t,cookieMinutes:n,cookieDomain:i,cookieOptions:s}=e;t&&typeof document<"u"&&Qe.create(t,r,n,i,s)}},Si={name:"querystring",lookup(r){let{lookupQuerystring:e}=r,t;if(typeof window<"u"){let{search:n}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(n=window.location.hash.substring(window.location.hash.indexOf("?")));const s=n.substring(1).split("&");for(let a=0;a<s.length;a++){const o=s[a].indexOf("=");o>0&&s[a].substring(0,o)===e&&(t=s[a].substring(o+1))}}return t}},ki={name:"hash",lookup(r){let{lookupHash:e,lookupFromHashIndex:t}=r,n;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const s=i.substring(1);if(e){const a=s.split("&");for(let o=0;o<a.length;o++){const c=a[o].indexOf("=");c>0&&a[o].substring(0,c)===e&&(n=a[o].substring(c+1))}}if(n)return n;if(!n&&t>-1){const a=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(a)?a[typeof t=="number"?t:0]?.replace("/",""):void 0}}}return n}};let z=null;const Ge=()=>{if(z!==null)return z;try{if(z=typeof window<"u"&&window.localStorage!==null,!z)return!1;const r="i18next.translate.boo";window.localStorage.setItem(r,"foo"),window.localStorage.removeItem(r)}catch{z=!1}return z};var Li={name:"localStorage",lookup(r){let{lookupLocalStorage:e}=r;if(e&&Ge())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(r,e){let{lookupLocalStorage:t}=e;t&&Ge()&&window.localStorage.setItem(t,r)}};let _=null;const Ye=()=>{if(_!==null)return _;try{if(_=typeof window<"u"&&window.sessionStorage!==null,!_)return!1;const r="i18next.translate.boo";window.sessionStorage.setItem(r,"foo"),window.sessionStorage.removeItem(r)}catch{_=!1}return _};var Ei={name:"sessionStorage",lookup(r){let{lookupSessionStorage:e}=r;if(e&&Ye())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(r,e){let{lookupSessionStorage:t}=e;t&&Ye()&&window.sessionStorage.setItem(t,r)}},Pi={name:"navigator",lookup(r){const e=[];if(typeof navigator<"u"){const{languages:t,userLanguage:n,language:i}=navigator;if(t)for(let s=0;s<t.length;s++)e.push(t[s]);n&&e.push(n),i&&e.push(i)}return e.length>0?e:void 0}},Oi={name:"htmlTag",lookup(r){let{htmlTag:e}=r,t;const n=e||(typeof document<"u"?document.documentElement:null);return n&&typeof n.getAttribute=="function"&&(t=n.getAttribute("lang")),t}},Ni={name:"path",lookup(r){let{lookupFromPathIndex:e}=r;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}},Ci={name:"subdomain",lookup(r){let{lookupFromSubdomainIndex:e}=r;const t=typeof e=="number"?e+1:1,n=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(n)return n[t]}};let yt=!1;try{document.cookie,yt=!0}catch{}const xt=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];yt||xt.splice(1,1);const ji=()=>({order:xt,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:r=>r});class bt{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]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=xi(t,this.options||{},ji()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=i=>i.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(vi),this.addDetector(Si),this.addDetector(Li),this.addDetector(Ei),this.addDetector(Pi),this.addDetector(Oi),this.addDetector(Ni),this.addDetector(Ci),this.addDetector(ki)}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(n=>{if(this.detectors[n]){let i=this.detectors[n].lookup(this.options);i&&typeof i=="string"&&(i=[i]),i&&(t=t.concat(i))}}),t=t.filter(n=>n!=null&&!bi(n)).map(n=>this.options.convertDetectedLanguage(n)),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(n=>{this.detectors[n]&&this.detectors[n].cacheUserLanguage(e,this.options)}))}}bt.type="languageDetector";const wt={apiBaseUrl:"https://api.nemme.io",debug:!1},Ti="Previous",$i="Next",Ri="Done",Fi="Submit",Mi={Previous:Ti,Next:$i,Done:Ri,Submit:Fi,"Type your answer here":"Type your answer here","Max {{maxCharacters}} characters":"Max {{maxCharacters}} characters"},Di={};qn({locale:Zn});N.use(bt).use(Ht).init({debug:wt.debug,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:{translation:Mi},nb:{tranlation:Di}}});const Xe={debug:0,info:1,warn:2,error:3};class ve{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&&Xe[e]>=Xe[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 ve({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 vt=new ve,et=vt.child("network"),Ai=3e4,Ii=(r,e)=>{const t=new URL(r,wt.apiBaseUrl);return e&&Object.entries(e).forEach(([n,i])=>{i!=null&&t.searchParams.append(n,String(i))}),t.toString()},A={async request(r,e={}){const{method:t="GET",headers:n={},body:i,params:s,timeout:a=Ai}=e,o=Ii(r,s),c={"Content-Type":"application/json",Accept:"application/json",...n},l={method:t,headers:c,body:i?JSON.stringify(i):void 0},u=new AbortController,d=setTimeout(()=>u.abort(),a);l.signal=u.signal;try{const h=await fetch(o,l);let f;const p=h.headers.get("content-type");if(p&&p.includes("application/json"))f=await h.json();else{const b=await h.text();try{f=JSON.parse(b)}catch{f=b}}const y={data:f,status:h.status,statusText:h.statusText,headers:h.headers,ok:h.ok};if(h.ok)y.ok=!0;else{const b=`Request failed with status ${h.status}: ${h.statusText}`;et.error(b,{url:o,method:t,status:h.status,data:y.data}),y.ok=!1,y.error={message:b,details:y.data}}return y}catch(h){let f="Network request failed",p={};return h instanceof DOMException&&h.name==="AbortError"?(f=`Request timeout after ${a}ms`,p={timeout:a,url:o}):p={message:h instanceof Error?h.message:String(h),url:o,method:t},et.error(f,p),{data:{},status:0,statusText:f,headers:new Headers,ok:!1,error:{message:f,details:p}}}finally{clearTimeout(d)}},async get(r,e={}){return this.request(r,{...e,method:"GET"})},async post(r,e,t={}){return this.request(r,{...t,method:"POST",body:e})},async put(r,e,t={}){return this.request(r,{...t,method:"PUT",body:e})},async patch(r,e,t={}){return this.request(r,{...t,method:"PATCH",body:e})},async delete(r,e={}){return this.request(r,{...e,method:"DELETE"})}};class Vi{logger;headers;config;constructor(e,t,n={}){this.logger=e,this.headers=t,this.config=n}async fetchAndDisplayForm(e,t,n){this.logger.debug(`Fetching form config for: ${e}`);try{const i=await A.get(`/external/forms/${e}`,{headers:this.headers});i.ok&&i.data?(this.logger.info(`Form config loaded for: ${e}`,i.data),this.displayForm(i.data,t,n)):this.logger.warn(`No form config found for: ${e}`)}catch(i){this.logger.error(`Failed to fetch form config for: ${e}`,i)}}displayForm(e,t,n){const i=document.createElement("div");i.id="nm",i.className=this.config.theme==="dark"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"",document.body.appendChild(i);const s=Ot.createRoot(i),a=w.createElement(zt,{i18n:N},w.createElement(Zt,{form:e,onDismiss:async o=>{await t(),s.unmount(),i.remove(),this.logger.info("Form dismissed",o)},onComplete:async o=>{await n(),await this.postFormResponse(e,o),s.unmount(),i.remove(),this.logger.info("Form completed",o)},zIndex:this.config.zIndex}));s.render(a)}async postFormResponse(e,t){this.logger.info("Posting form response",t);const n=await A.post(`/external/forms/${e.slug}`,t,{headers:this.headers});this.logger.info("Form response posted",n.data)}}class Hi{logger;headers;formManager;deliveries=[];constructor(e,t,n){this.logger=e,this.headers=t,this.formManager=new Vi(e,t,n)}async loadDeliveries(){try{this.logger.debug("Loading deliveries");const e=await A.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 n of t.triggers)if(this.shouldTriggerDelivery(n,e)){if(!await this.isDeliveryValid(t)){this.logger.debug(`Delivery ${t.id} is not valid, skipping`);continue}await this.executeDelivery(t,n);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 i=await this.createDeliveryResponse(e);await this.formManager.fetchAndDisplayForm(e.productSlug,async()=>{this.logger.debug(`Form for delivery: ${e.productSlug} was cancelled`),i&&await this.updateDeliveryResponse(e.id,i.id,!0)},async()=>{this.logger.debug(`Form for delivery: ${e.productSlug} was completed`),i&&await this.updateDeliveryResponse(e.id,i.id,!1,!0)})}catch(i){this.logger.error(`Failed to load form for delivery: ${e.productSlug}`,i)}}}matchesUrlPattern(e,t){let n;try{n=new URL(e).pathname}catch{n=e.startsWith("/")?e:`/${e}`}const i=u=>{if(!u)return"/";let d=u.startsWith("/")?u:`/${u}`;return d.length>1&&d.endsWith("/")&&(d=d.slice(0,-1)),d},s=i(n),a=i(t),o=a.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:n,normalizedPathname:s,pattern:t,normalizedPattern:a,regexPattern:o,matches:l}),l}async createDeliveryResponse(e){try{return(await A.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,n=!1,i=!1){try{await A.patch(`/external/deliveries/${e}/responses/${t}`,{wasDismissed:n,wasCompleted:i},{headers:this.headers})}catch(s){this.logger.error(`Failed to update delivery response: ${t} for delivery: ${e}`,s)}}async isDeliveryValid(e){try{return(await A.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 Ki{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:n,eventDefinitions:i,batchConfig:s,onPageView:a,onEvent:o}){this.logger=e,this.headers=t,this.sessionId=n,this.eventDefinitions=i,this.onPageView=a,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(...n)=>{e.apply(history,n),await this.trackPageView()};const t=history.replaceState;history.replaceState=async(...n)=>{t.apply(history,n),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:n={}}=e;this.logger.debug("Tracking event",{eventKey:t,data:n});const i=window.location.href,s={sessionId:this.sessionId,eventKey:t,data:n||{},timestamp:new Date().toISOString(),page:i};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,i)}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 n=t.properties,i=e.data;if(i)for(const s of Object.keys(i)){const a=i[s],o=n.find(c=>c.name===s);if(!o){this.logger.warn(`Property ${s} is not registered for event ${e.eventKey}`);return}o.type==="string"&&typeof a!="string"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof a}`),o.type==="boolean"&&typeof a!="boolean"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof a}`),o.type==="number"&&typeof a!="number"&&this.logger.warn(`Property ${o.name} has type ${o.type} but value is of type ${typeof a}`)}}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 A.post("/external/trackings/track",t,{headers:this.headers})}else await A.post("/external/trackings/batch",e,{headers:this.headers})}}class ue{clientKey;userIdentifier;initialized=!1;clientLogger=vt.child("client");headers={};formConfig;constructor(e){this.clientKey=e}trackingManager;async init({userIdentifier:e,debug:t=!1,batch:n,formConfig:i}){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=i;try{const s=await this.initializeSession();await this.initializeManagers(s,n),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 A.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 n=new Hi(this.clientLogger,this.headers,this.formConfig),i=new Ki({logger:this.clientLogger,headers:this.headers,sessionId:e.sessionId,eventDefinitions:e.eventDefinitions,batchConfig:t,onPageView:async s=>{await n.evaluateDeliveryTriggers({url:s})},onEvent:async(s,a)=>{await n.evaluateDeliveryTriggers({eventKey:s.eventKey,eventData:s.data,url:a})}});await n.loadDeliveries(),typeof window<"u"&&(await i.setupPageViewTracking(),await i.trackPageView(),await i.flush()),this.trackingManager=i}}const St=r=>new ue(r),kt=w.createContext(void 0),Bi=({clientKey:r,config:e,children:t})=>{const[n,i]=w.useState(null),[s,a]=w.useState(!1),[o,c]=w.useState(null);w.useEffect(()=>{let u=null,d=!1;const h=async()=>{try{const f=new ue(r);if(await f.init(e),d){f.destroy();return}u=f,i(f),a(!0),c(null)}catch(f){d||(c(f instanceof Error?f.message:"Failed to initialize Nemme client"),a(!1))}};return i(null),a(!1),c(null),h(),()=>{d=!0,u&&u.destroy()}},[r,e]);const l={client:n,isInitialized:s,error:o};return m.jsx(kt.Provider,{value:l,children:t})},Lt=()=>{const r=w.useContext(kt);if(r===void 0)throw new Error("useNemmeContext must be used within a NemmeProvider");return r},qi=()=>{const{client:r,isInitialized:e,error:t}=Lt(),n=w.useCallback(async s=>{if(!r||!e){console.warn("Nemme client not initialized");return}return r.track(s)},[r,e]),i=w.useCallback(async()=>{if(!r||!e){console.warn("Nemme client not initialized");return}return r.flush()},[r,e]);return{track:n,flush:i,isInitialized:e,error:t,client:r}},zi=r=>St(r),_i=async r=>{const{clientKey:e,...t}=r;return await St(e).init(t)},Se=Object.assign(r=>zi(r),{NemmeClient:ue,init:_i});typeof window<"u"&&(window.NemmeSDK=Se);exports.NemmeClient=ue;exports.NemmeProvider=Bi;exports.NemmeSDK=Se;exports.default=Se;exports.useNemme=qi;exports.useNemmeContext=Lt;
26
26
  //# sourceMappingURL=index.cjs.map