var{defineProperty:W,getOwnPropertyNames:U,getOwnPropertyDescriptor:_}=Object,w=Object.prototype.hasOwnProperty;function C(q){return this[q]}var E=(q)=>{var z=($??=new WeakMap).get(q),B;if(z)return z;if(z=W({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var G of U(q))if(!w.call(z,G))W(z,G,{get:C.bind(q,G),enumerable:!(B=_(q,G))||B.enumerable})}return $.set(q,z),z},$;var O=(q)=>q;function F(q,z){this[q]=O.bind(null,z)}var I=(q,z)=>{for(var B in z)W(q,B,{get:z[B],enumerable:!0,configurable:!0,set:F.bind(z,B)})};var S=(q,z)=>()=>(q&&(z=q(q=0)),z);class X{specs=new Map;latestByLocale=new Map;locales=new Set;domains=new Set;constructor(q){if(q)for(let z of q)this.register(z)}register(q){let z=this.makeKey(q.meta.key,q.meta.version,q.locale);this.specs.set(z,q);let B=`${q.meta.key}:${q.locale}`,G=this.latestByLocale.get(B);if(!G||this.isNewerVersion(q.meta.version,G.meta.version))this.latestByLocale.set(B,q);this.locales.add(q.locale),this.domains.add(q.meta.domain)}get(q,z,B){return this.specs.get(this.makeKey(q,z,B))}getLatest(q,z){return this.latestByLocale.get(`${q}:${z}`)}getMessage(q,z,B,G){let H=G?this.get(q,G,B):this.getLatest(q,B);if(!H)return;return H.messages[z]}getWithFallback(q,z,B,G,H){let N=H?this.get(q,H,B):this.getLatest(q,B);if(N){let J=N.messages[z];if(J)return{spec:N,message:J,locale:B,fromFallback:!1};G=G??N.fallback}if(G&&G!==B){let J=H?this.get(q,H,G):this.getLatest(q,G);if(J){let Q=J.messages[z];if(Q)return{spec:J,message:Q,locale:G,fromFallback:!0}}}return}getValue(q,z,B,G){return this.getWithFallback(q,z,B)?.message.value??G??z}listLocales(q){let z=[];for(let[B,G]of this.specs.entries())if(B.startsWith(`${q}:`)){if(!z.includes(G.locale))z.push(G.locale)}return z}list(){return[...this.specs.values()]}listByLocale(q){return[...this.specs.values()].filter((z)=>z.locale===q)}listByDomain(q){return[...this.specs.values()].filter((z)=>z.meta.domain===q)}has(q,z,B){if(B)return this.specs.has(this.makeKey(q,B,z));return this.latestByLocale.has(`${q}:${z}`)}getLocales(){return this.locales}getDomains(){return this.domains}getStats(){let q=0;for(let z of this.specs.values())q+=Object.keys(z.messages).length;return{totalSpecs:this.specs.size,locales:[...this.locales],domains:[...this.domains],totalMessages:q}}clear(){this.specs.clear(),this.latestByLocale.clear(),this.locales.clear(),this.domains.clear()}makeKey(q,z,B){return`${q}:${z}:${B}`}isNewerVersion(q,z){let B=(N)=>{let J=N.split(".").map(Number);return{major:J[0]??0,minor:J[1]??0,patch:J[2]??0}},G=B(q),H=B(z);if(G.major!==H.major)return G.major>H.major;if(G.minor!==H.minor)return G.minor>H.minor;return G.patch>H.patch}}var Y="en",T=["en","fr","es"];function x(q,z){let B=z??q??Y;if(j(B))return B;let G=B.split("-")[0];if(G&&j(G))return G;return Y}function j(q){return T.includes(q)}function D(q,z){if(!z)return q;return q.replace(/\{(\w+)\}/g,(B,G)=>{if(G in z)return String(z[G]);return B})}function d(q){let z=null;function B(){if(!z)z=new X(q.catalogs);return z}let G={create(H,N){let J=x(H,N),Q=B();return{locale:J,t(Z,V){let P=Q.getValue(q.specKey,Z,J,Z);return D(P,V)}}},getDefault(){return G.create(Y)},resetRegistry(){z=null}};return G}export{x as resolveLocale,j as isSupportedLocale,D as interpolate,d as createI18nFactory,T as SUPPORTED_LOCALES,Y as DEFAULT_LOCALE};
