/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import{b as z}from"./WKR7R7AZ.js";import{a as I}from"./R6QHGRLY.js";import{a as y}from"./ENDXE7YY.js";import{e as C}from"./EH5Y2TRK.js";import"./UANLRLKZ.js";import{G as b,H as g,S as v,T as x,g as f,h as m,i as p,l as h}from"./PGOMURMZ.js";var $={flipRtl:"flip-rtl",svg:"svg"},D={},d={},k={s:16,m:24,l:32};function w({icon:e,scale:t}){let s=k[t],i=B(e),n=i.charAt(i.length-1)==="F";return`${n?i.substring(0,i.length-1):i}${s}${n?"F":""}`}async function O(e){let t=w(e),s=N(t);if(s)return s;d[t]||(d[t]=fetch(x(`./assets/icon/${t}.json`)).then(n=>n.json()).catch(()=>(I.error(`${e.icon} (${e.scale}) icon failed to load`),"")));let i=await d[t];return D[t]=i,i}function U(e){return N(w(e))}function N(e){return D[e]}function B(e){let t=!isNaN(Number(e.charAt(0))),s=e.split("-");if(s.length>0){let n=/[a-z]/i;e=s.map((r,a)=>r.replace(n,function(l,o){return a===0&&o===0?l:l.toUpperCase()})).join("")}return t?`i${e}`:e}var L=f`:host{display:inline-flex;color:var(--calcite-icon-color, var(--calcite-ui-icon-color, currentColor))}:host([scale=s]){inline-size:16px;block-size:16px;min-inline-size:16px;min-block-size:16px}:host([scale=m]){inline-size:24px;block-size:24px;min-inline-size:24px;min-block-size:24px}:host([scale=l]){inline-size:32px;block-size:32px;min-inline-size:32px;min-block-size:32px}.flip-rtl{transform:scaleX(-1)}.svg{display:block}:host([hidden]){display:none}[hidden]{display:none}`,u=class extends b{constructor(){super(...arguments),this.direction=C(),this.visible=!1,this.flipRtl=!1,this.icon=null,this.preload=!1,this.scale="m"}static{this.properties={pathData:[16,{},{state:!0}],visible:[16,{},{state:!0}],flipRtl:[7,{},{reflect:!0,type:Boolean}],icon:[3,{type:String},{reflect:!0}],preload:[7,{},{reflect:!0,type:Boolean}],scale:[3,{},{reflect:!0}],textLabel:1}}static{this.styles=L}connectedCallback(){if(super.connectedCallback(),this.preload){this.visible=!0,this.loadIconPathData();return}this.visible||this.waitUntilVisible(()=>{this.visible=!0,this.loadIconPathData()})}willUpdate(t){(t.has("icon")&&(this.hasUpdated||this.icon!==null)||t.has("scale")&&(this.hasUpdated||this.scale!=="m"))&&this.loadIconPathData()}disconnectedCallback(){super.disconnectedCallback(),this.intersectionObserver?.disconnect(),this.intersectionObserver=null}async loadIconPathData(){let{icon:t,scale:s,visible:i}=this;if(!t||!i)return;let n={icon:t,scale:s},r=U(n)||await O(n);t===this.icon&&(this.pathData=r)}waitUntilVisible(t){if(this.intersectionObserver=y("intersection",s=>{s.forEach(i=>{i.isIntersecting&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null,t())})},{rootMargin:"50px"}),!this.intersectionObserver){t();return}this.intersectionObserver.observe(this.el)}render(){let{flipRtl:t,pathData:s,scale:i,textLabel:n}=this,r=this.direction,a=k[i],c=!!n,l=[].concat(s||"");return this.el.ariaHidden=z(!c),this.el.ariaLabel=c?n:null,this.el.role=c?"img":null,m`<svg aria-hidden=true class=${g({[$.flipRtl]:r==="rtl"&&t,[$.svg]:!0})} fill=currentColor height=100% viewBox=${`0 0 ${a} ${a}`} width=100% xmlns=http://www.w3.org/2000/svg>${l.map(o=>typeof o=="string"?p`<path d=${o??h} />`:p`<path d=${o.d??h} opacity=${("opacity"in o?o.opacity:1)??h} />`)}</svg>`}};v("calcite-icon",u);export{u as Icon};
