import{R as n}from"./jsx-runtime-B2SNG7MK.js";const I=/<([a-zA-Z0-9]+)>(.*?)<\/\1>|<([a-zA-Z0-9]+)\/>/,k=/(?:\r\n|\r|\n)/g,R={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0};function E(e,t={}){const s=$(0,"$lingui$"),r=e.replace(k,"").split(I);if(r.length===1)return e;const o=[],i=r.shift();i&&o.push(i);for(const[u,l,a]of b(r)){let c=typeof u<"u"?t[u]:void 0;(!c||R[c.type]&&l)&&(console.error(c?`${c.type} is a void element tag therefore it must have no children`:`Can't use element at index '${u}' as it is not declared in the original translation`),c=n.createElement(n.Fragment)),Array.isArray(c)&&(c=n.createElement(n.Fragment,{},c)),o.push(n.cloneElement(c,{key:s()},l?E(l,t):c.props.children)),a&&o.push(a)}return o}function b(e){if(!e.length)return[];const[t,s,r,o]=e.slice(0,4);return[[t||r,s||"",o]].concat(b(e.slice(4,e.length)))}const $=(e=0,t="")=>()=>`${t}_${e++}`;function A(e){const{render:t,component:s,id:r,message:o,formats:i,lingui:{i18n:u,defaultComponent:l}}=e,a={...e.values},c={...e.components};a&&Object.keys(a).forEach(h=>{const m=a[h];if(!(n.isValidElement(m)||Array.isArray(m)&&m.every(n.isValidElement)))return;const v=Object.keys(c).length;c[v]=m,a[h]=`<${v}/>`});const p=u&&typeof u._=="function"?u._(r,a,{message:o,formats:i}):r,f=p?E(p,c):null;if(t===null||s===null)return f;const g=l||F,d={id:r,message:o,translation:f,isTranslated:r!==f&&o!==f,children:f};if(t&&s)console.error("You can't use both `component` and `render` prop at the same time. `component` is ignored.");else if(t&&typeof t!="function")console.error(`Invalid value supplied to prop \`render\`. It must be a function, provided ${t}`);else if(s&&typeof s!="function")return console.error(`Invalid value supplied to prop \`component\`. It must be a React component, provided ${s}`),n.createElement(g,d,f);if(typeof t=="function")return t(d);const C=s||g;return n.createElement(C,d,f)}const F=({children:e})=>n.createElement(n.Fragment,null,e),y=n.createContext(null),x=e=>n.useContext(y);function L(){return x()}const P=({i18n:e,defaultComponent:t,children:s})=>{const r=n.useRef(e.locale),o=n.useCallback(()=>({i18n:e,defaultComponent:t,_:e.t.bind(e)}),[e,t]),[i,u]=n.useState(o());return n.useEffect(()=>{const l=()=>{r.current=e.locale,u(o())},a=e.on("change",l);return r.current!==e.locale&&l(),a},[e,o]),r.current?n.createElement(y.Provider,{value:i},s):null};function j(e){const t=x();return n.createElement(A,{...e,lingui:t})}export{P as I,j as T,L as u};
