/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import{a as u}from"./BCUUVBXH.js";function M(e){return N(e)||C(e)}function v(e){return y(e).filter(t=>t.nodeType===Node.TEXT_NODE).map(t=>t.textContent).join("").trim()}function C(e){return v(e).length>0}function y(e){return e.currentTarget.assignedNodes({flatten:!0})}function N(e){return w(e).length>0}function w(e,t){return L(e.target,t)}function L(e,t){let n=e.assignedElements({flatten:!0});return t?n.filter(o=>o.matches(t)):n}var $=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;if(!n.parentNode)return!1;n.parentNode instanceof ShadowRoot?n=n.parentNode.host:n=n.parentNode}return!1},g=(e,t,n)=>{let o=A(t).subscribe;return o(r=>{r.some(s=>$(e,s.target))&&n()})},d={},A=e=>{let t=e.join(","),n=d[t];if(n!==void 0)return n;let o=new Set,r=new MutationObserver(s=>o.forEach(l=>l(s)));globalThis.document&&r.observe(document.documentElement,{attributes:!0,attributeFilter:e,subtree:!0});let i={subscribe:s=>(o.add(s),()=>{o.delete(s),o.size===0&&(r.disconnect(),d[t]=void 0)})};return d[t]=i,i},h=(e,t)=>{let n=e;for(;n;){let o=n.closest?.(t);if(o)return o;let r=n.getRootNode?.();if(r===globalThis.document)return;n=r?.host}};function F(e){let t=h(e,".calcite-mode-dark, .calcite-mode-light, .calcite-mode-auto");return t?.classList.contains("calcite-mode-dark")||t?.classList.contains("calcite-mode-auto")&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var m=(e,t,n)=>h(e,`[${t}]`)?.getAttribute(t)??n,P=async e=>{e!=null&&(p(e)?await e.setFocus():e.focus())},p=e=>typeof e.setFocus=="function",R=(e,t)=>{if(e?.shadowRoot){if(e.hasAttribute("hydrated")||e.hasAttribute("calcite-hydrated")){c(e,t);return}Promise.resolve(e.componentOnReady?.()).then(()=>c(e,t))}},T=e=>e.nodeType===Node.ELEMENT_NODE,c=(e,t="")=>{if(!T(e))return!1;if(e.matches(t))return p(e)&&setTimeout(()=>void e.setFocus(),0),!0;for(let o of e.children)if(c(o,t))return!0;let n=e.shadowRoot;if(n){for(let o of n.children)if(c(o,t))return!0}return!1};var k="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(","),S=new Set(k),a="en",x={pt:"pt-BR",nb:"no",nn:"no",zh:"zh-CN"},z=async(e,t,n="")=>{let o=`${t}/${n}`,r=`${o}${e}.json`;return f[r]??(f[r]=E(e,o)),await f[r]},f={},E=async(e,t)=>{let n=`${t}${e}.json`;try{let o=await fetch(n);if(o.ok)return await o.json()}catch(o){return u("error","intl",`An unknown error occurred while fetching localization strings at ${n}`,{detail:{error:o}}),{}}return e===a?{}:await E(a,t)},O=e=>{let t=m(e,"lang",globalThis.navigator?.language||a);return{lang:t,t9nLocale:b(t)}},b=e=>{let[t,n]=e.split("-"),o=t.toLowerCase(),r=o;return n&&(r=`${o}-${n.toUpperCase()}`),r=x[r]??r,S.has(r)?r:n?b(o):a},B=(e,t,n,o)=>{let r,i=()=>j(e,t(),o).then(s=>{(r?.lang!==s.lang||r.t9nLocale!==s.t9nLocale||r.t9nStrings!==s.t9nStrings)&&n(s),r=s}).catch(s=>{u("error","intl","Error updating component locale state",{detail:{error:s}})});return queueMicrotask(i),g(e,["lang"],i)},j=async(e,t,n=e.localName.split("-").slice(1).join("-"))=>{let{lang:o,t9nLocale:r}=O(e),i=`${t}/${n}/t9n`,l=n===null?{}:await z(r,i,"messages.");return{lang:o,t9nLocale:r,t9nStrings:l}};export{M as a,g as b,h as c,F as d,P as e,R as f,S as g,z as h,O as i,b as j,B as k};
