import{r as e}from"./client.ySKnF1Cn.js";import{I as n,g as t,R as s,b as a}from"./context.ZwV2gUb-.js";const r={},o=(e,n,t,s)=>{c(t)&&r[t]||(c(t)&&(r[t]=new Date),((e,n,t,s)=>{const a=[t,{code:n,...s||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(a,"warn","react-i18next::",!0);c(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...a):console?.warn&&console.warn(...a)})(e,n,t,s))},i=(e,n)=>()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout(()=>{e.off("initialized",t)},0),n()};e.on("initialized",t)}},l=(e,n,t)=>{e.loadNamespaces(n,i(e,t))},u=(e,n,t,s)=>{if(c(t)&&(t=[t]),e.options.preload&&e.options.preload.indexOf(n)>-1)return l(e,t,s);t.forEach(n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)}),e.loadLanguages(n,i(e,s))},c=e=>"string"==typeof e,g=(e,n,t,s)=>e.getFixedT(n,t,s),f=(r,i={})=>{const{i18n:f}=i,{i18n:d,defaultNS:p}=e.useContext(n)||{},m=f||d||t();if(m&&!m.reportNamespaces&&(m.reportNamespaces=new s),!m){o(m,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>{return c(n)?n:"object"==typeof(t=n)&&null!==t&&c(n.defaultValue)?n.defaultValue:Array.isArray(e)?e[e.length-1]:e;var t},n=[e,{},!1];return n.t=e,n.i18n={},n.ready=!1,n}m.options.react?.wait&&o(m,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const w={...a(),...m.options.react,...i},{useSuspense:h,keyPrefix:N}=w;let b=p||m.options?.defaultNS;b=c(b)?[b]:b||["translation"],m.reportNamespaces.addUsedNamespaces?.(b);const y=(m.isInitialized||m.initializedStoreOnce)&&b.every(e=>((e,n,t={})=>n.languages&&n.languages.length?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,s)=>{if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!s(n.isLanguageChangingTo,e))return!1}}):(o(n,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:n.languages}),!0))(e,m,w)),x=((n,t,s,a)=>e.useCallback(g(n,t,s,a),[n,t,s,a]))(m,i.lng||null,"fallback"===w.nsMode?b:b[0],N),E=()=>x,I=()=>g(m,i.lng||null,"fallback"===w.nsMode?b:b[0],N),[T,S]=e.useState(E);let v=b.join();i.lng&&(v=`${i.lng}${v}`);const C=((n,t)=>{const s=e.useRef();return e.useEffect(()=>{s.current=n},[n,t]),s.current})(v),O=e.useRef(!0);e.useEffect(()=>{const{bindI18n:e,bindI18nStore:n}=w;O.current=!0,y||h||(i.lng?u(m,i.lng,b,()=>{O.current&&S(I)}):l(m,b,()=>{O.current&&S(I)})),y&&C&&C!==v&&O.current&&S(I);const t=()=>{O.current&&S(I)};return e&&m?.on(e,t),n&&m?.store.on(n,t),()=>{O.current=!1,m&&e&&e?.split(" ").forEach(e=>m.off(e,t)),n&&m&&n.split(" ").forEach(e=>m.store.off(e,t))}},[m,v]),e.useEffect(()=>{O.current&&y&&S(E)},[m,N,y]);const k=[T,m,y];if(k.t=T,k.i18n=m,k.ready=y,y)return k;if(!y&&!h)return k;throw new Promise(e=>{i.lng?u(m,i.lng,b,()=>e()):l(m,b,()=>e())})};export{f as u};
