import{r as t,c as s,a as i,h as n,d as e}from"./p-Cby2wKoI.js";import{g as o}from"./p-4yOyuXca.js";import{i as r}from"./p-CtINY9El.js";import{d as c,t as h}from"./p-DNHOWgWh.js";const a=()=>`ifx-icon{display:inline-flex;justify-content:center}ifx-icon:empty{display:none}`;const l=class{constructor(i){t(this,i);this.consoleError=s(this,"consoleError",7)}get el(){return i(this)}icon="";ifxIcon;internalIcon;consoleError;updateIcon(t){this.internalIcon=t;this.setIcon()}convertStringToHtml(t){const s=document.createElement("div");s.innerHTML=t;return s.firstChild}convertHtmlToObject(t){const s=Array.from(t.attributes,(({name:t,value:s})=>({name:t,value:s}))).reduce(((t,s)=>{t[s.name]=s.value;return t}),{});return s}convertPathsToVnode(t){const s=[];const i=this.convertHtmlToObject(t);const e=n("path",i);s.push(e);if(t.firstChild){const i=t.querySelectorAll("path");const e=t.querySelectorAll("path").length;for(let t=0;t<e;t++){const e=this.convertHtmlToObject(i[t]);const o=n("path",e);s.push(o)}}return s}getSVG(t){const s=this.convertStringToHtml(this.ifxIcon);const i=s.getAttribute("width");const e=s.getAttribute("height");const o=s.getAttribute("fill");const r=s.getAttribute("viewBox");return n("svg",{class:"inline-svg",width:i,height:e,xmlns:"http://www.w3.org/2000/svg",fill:o,viewBox:r,tabindex:-1},...t)}constructIcon(){if(this.ifxIcon){const t=this.convertStringToHtml(this.ifxIcon);const s=this.convertPathsToVnode(t);const i=this.getSVG(s);return i}else if(this.icon!==""){this.consoleError.emit(true);return}else{return}}setIcon(){const t=t=>t.replace(/[-_]+(.)/g,((t,s)=>s.toUpperCase())).replace(/^(.)/,(t=>t.toLowerCase()));const s=t(this.internalIcon);this.ifxIcon=o(s)}isInsideAgGrid(t){let s=t;while(s){if(s.className?.toLowerCase().startsWith("ag-")){return true}s=s.parentElement}return false}isInsideChoices(t){let s=t;while(s){if(s.className?.toLowerCase().startsWith("choices__")){return true}s=s.parentElement}return false}componentWillLoad(){this.internalIcon=this.icon;this.setIcon()}async componentDidLoad(){if(!r(this.el)){if(!this.isInsideAgGrid(this.el)&&!this.isInsideChoices(this.el)){const t=c();h("ifx-icon",await t)}}}render(){return n(e,{key:"1cde1e46171793a513842cacc3e593c9b21ecf89"},this.constructIcon())}static get watchers(){return{icon:[{updateIcon:0}]}}};l.style=a();export{l as ifx_icon};
//# sourceMappingURL=p-6bd0a402.entry.js.map