/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{c as g,f as u}from"./ZNBKMZP7.js";import{p as c}from"./IWZQMWZ5.js";var f="ar,bg,bs,ca,cs,da,de,el,en,es,et,fi,fr,he,hr,hu,id,it,ja,ko,lt,lv,nl,nb,no,pl,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-CN,zh-HK,zh-TW".split(","),L=new Set(f),i="en",$={pt:"pt-PT",nb:"no",nn:"no",zh:"zh-CN"},b=async(n,o,r="")=>{let e=`${o}/${r}`,t=`${e}${n}.json`;return l[t]??(l[t]=p(n,e)),await l[t]},l={},p=async(n,o)=>{let r=`${o}${n}.json`;try{let e=await fetch(r);if(e.ok)return await e.json()}catch(e){return c("error","intl",`An unknown error occurred while fetching localization strings at ${r}`,{detail:{error:e}}),{}}return n===i?{}:await p(i,o)},k=n=>{let o=u(n,"lang",globalThis.navigator?.language||i);return{lang:o,t9nLocale:h(o)}},h=n=>{let[o,r]=n.split("-"),e=o.toLowerCase(),t=e;return r&&(t=`${e}-${r.toUpperCase()}`),t=$[t]??t,L.has(t)?t:r?h(e):i},C=(n,o,r,e)=>{let t,s=()=>v(n,o(),e).then(a=>{(t?.lang!==a.lang||t.t9nLocale!==a.t9nLocale||t.t9nStrings!==a.t9nStrings)&&r(a),t=a}).catch(a=>{c("error","intl","Error updating component locale state",{detail:{error:a}})});return queueMicrotask(s),g(n,["lang"],s)},v=async(n,o,r=n.localName.split("-").slice(1).join("-"))=>{let{lang:e,t9nLocale:t}=k(n),s=`${o}/${r}/t9n`,d=r===null?{}:await b(t,s,"messages.");return{lang:e,t9nLocale:t,t9nStrings:d}};export{k as a,C as b};
