import{e as t,r as i,h as s,H as e,g as n}from"./p-268dca3f.js";import{g as a}from"./p-9c90d370.js";const o={},l={},c={s:16,m:24,l:32};const h=class{constructor(t){i(this,t),this.icon=null,this.mirrored=!1,this.scale="m",this.visible=!1}connectedCallback(){this.waitUntilVisible(()=>{this.visible=!0,this.loadIconPathData()})}disconnectedCallback(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null)}async componentWillLoad(){this.loadIconPathData()}render(){const{el:t,mirrored:i,pathData:n,scale:o,textLabel:l}=this,h=a(t),r=c[o],d=!!l,p=[].concat(n||"");return s(e,{"aria-label":d?l:null,role:d?"img":null},s("svg",{class:{mirrored:"rtl"===h&&i,svg:!0},xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",height:"100%",width:"100%",viewBox:`0 0 ${r} ${r}`},p.map(t=>s("path","string"==typeof t?{d:t}:{d:t.d,opacity:"opacity"in t?t.opacity:1}))))}async loadIconPathData(){const{icon:i,scale:s,visible:e}=this;i&&e&&(this.pathData=await async function({icon:i,scale:s}){const e=c[s],n=function(t){const i=!isNaN(Number(t.charAt(0))),s=t.split("-");return 1===s.length?i?"i"+t:t:s.map((t,s)=>0===s?i?"i"+t.toUpperCase():t:t.charAt(0).toUpperCase()+t.slice(1)).join("")}(i),a="F"===n.charAt(n.length-1),h=`${a?n.substring(0,n.length-1):n}${e}${a?"F":""}`;if(o[h])return o[h];l[h]||(l[h]=fetch(t(`./assets/${h}.json`)).then(t=>t.json()).catch(()=>(console.error(`"${h}" is not a valid calcite-ui-icon name`),"")));const r=await l[h];return o[h]=r,r}({icon:i,scale:s}))}waitUntilVisible(t){"undefined"!=typeof window&&window.IntersectionObserver?(this.intersectionObserver=new IntersectionObserver(i=>{i.forEach(i=>{i.isIntersecting&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null,t())})},{rootMargin:"50px"}),this.intersectionObserver.observe(this.el)):t()}static get assetsDirs(){return["assets"]}get el(){return n(this)}static get watchers(){return{icon:["loadIconPathData"],scale:["loadIconPathData"]}}};h.style=":host([hidden]){display:none}:host{display:-ms-inline-flexbox;display:inline-flex}:host([scale=s]){height:16px;min-height:16px;width:16px;min-width:16px}:host([scale=m]){height:24px;min-height:24px;width:24px;min-width:24px}:host([scale=l]){height:32px;min-height:32px;width:32px;min-width:32px}.mirrored{-webkit-transform:scaleX(-1);transform:scaleX(-1)}.svg{display:block}";export{h as calcite_icon}