import{r as t,h as i,a as r}from"./p-DBTJNfo7.js";import{g as e}from"./p-Dnt5w_Bp.js";class s{constructor(t){this.promises={},this.cache=t}async get(t,i=""){const r=await this.cache,e=this.getUrl(t,i);let s=await r.match(e);return s||(s=await this.fetchData(e,r)),this.getIcon(s)}async fetchData(t,i){let r=this.promises[t];return void 0===r&&(r=i.add(t),this.promises[t]=r),await r,i.match(t)}async getIcon(t){let i=await t.text();if(i=i.replaceAll("#000000","currentColor"),!this.validSvg(i))throw new Error("Invalid SVG");return i}validSvg(t){return"svg"===(new DOMParser).parseFromString(t,"image/svg+xml").documentElement.tagName.toLowerCase()}getUrl(t,i){let r=i||"";return i&&!i.endsWith("/")&&(r=`${i}/`),`${r}assets/icons/${t}.svg`}}class n{constructor(){this.cache={},this.resolveFunctions={}}async get(t,i=""){return this.cache[t]||(this.cache[t]=await this.getIcon(t,i)),this.cache[t]}getIcon(t,i){return new Promise((r=>{this.resolveFunctions[t]||(this.resolveFunctions[t]=[],this.fetchData(t,i)),this.resolveFunctions[t].push(r)}))}async fetchData(t,i){let r=i||"";i&&!i.endsWith("/")&&(r=`${i}/`);const e=await fetch(`${r}assets/icons/${t}.svg`);let s=await e.text();if(s=s.replaceAll("#000000","currentColor"),!this.validSvg(s))throw new Error("Invalid SVG");this.resolvePromises(t,s)}validSvg(t){return"svg"===(new DOMParser).parseFromString(t,"image/svg+xml").documentElement.tagName.toLowerCase()}resolvePromises(t,i){const r=this.resolveFunctions[t];for(const t of r)t(i);this.resolveFunctions[t]=null}}var a=function(){try{const t=caches.open("@limetech/lime-elements/icons");return new s(t)}catch(t){return new n}}();const o=class{constructor(i){t(this,i)}componentDidLoad(){this.loadIcon(this.name)}render(){return i("div",{key:"1af49b178e75a2701d2362817c5f74614a4a900a",class:"container"})}async loadIcon(t){if(void 0===t||""===t)return;const i=await this.loadSvg(t);this.renderSvg(i)}loadSvg(t){return a.get(t,e.iconPath)}renderSvg(t){const i=this.host.shadowRoot.querySelector("div.container");i&&(i.innerHTML=t)}get host(){return r(this)}static get watchers(){return{name:[{loadIcon:0}]}}};o.style=":host{background-color:var(--icon-background-color, transparent);border-radius:50%;display:inline-block;line-height:0;box-sizing:border-box}:host svg{fill:currentColor;height:100%;pointer-events:none;width:100%}:host div{margin:var(--limel-icon-svg-margin, 0)}:host([hidden]){display:none}:host([size=x-small]){height:1rem !important;width:1rem !important}:host([size=small]){height:1.25rem !important;width:1.25rem !important}:host([size=medium]){height:1.5rem !important;width:1.5rem !important}:host([size=large]){height:1.75rem !important;width:1.75rem !important}:host([badge][size=x-small]){height:1.5rem !important;width:1.5rem !important;--limel-icon-svg-margin:0.25rem}:host([badge][size=small]){height:1.75rem !important;width:1.75rem !important;--limel-icon-svg-margin:0.25rem}:host([badge][size=medium]){height:2.5rem !important;width:2.5rem !important;--limel-icon-svg-margin:0.5rem}:host([badge][size=large]){height:2.75rem !important;width:2.75rem !important;--limel-icon-svg-margin:0.5rem}";export{o as limel_icon}