import{a as t,r as n,h as i,H as e,g as s}from"./p-db677b4c.js";let r;const o=()=>{if(typeof window==="undefined"){return new Map}else{if(!r){const t=window;t.PdsIcons=t.PdsIcons||{};r=t.PdsIcons.map=t.PdsIcons.map||new Map}return r}};const c=(t,n)=>{if(!t&&n&&!u(n)){t=n}if(a(t)){t=h(t)}if(!a(t)||t.trim()===""){return null}const i=t.replace(/[a-z]|-|\d/gi,"");if(i!=""){return null}return t};const l=n=>{const i=o().get(n);if(i){return i}return t(`svg/${n}.svg`)};const f=t=>{if(a(t)){t=t.trim();if(u(t)){return t}}return null};const d=t=>{let n=f(t.src);if(n){return n}n=c(t.name,t.icon);if(n){return l(n)}if(t.icon){n=f(t.icon);if(n){return n}}return null};const u=t=>t.length>0&&/(\/|\.)/.test(t);const a=t=>typeof t==="string";const h=t=>t.toLowerCase();const p=(t,n=[])=>{const i={};n.forEach((n=>{if(t.hasAttribute(n)){const e=t.getAttribute(n);if(e!==null){i[n]=t.getAttribute(n)}t.removeAttribute(n)}}));return i};const g=t=>{const n=document.createElement("div");n.innerHTML=t;for(let t=n.childNodes.length-1;t>=0;t--){if(n.childNodes[t].nodeName.toLowerCase()!=="svg"){n.removeChild(n.childNodes[t])}}const i=n.firstElementChild;if(i&&i.nodeName.toLowerCase()==="svg"){const t=i.getAttribute("class")||"";i.setAttribute("class",(t+" s-pds-icon").trim());if(w(i)){return n.innerHTML}}return""};const w=t=>{if(t.nodeType===1){if(t.nodeName.toLowerCase()==="script"){return false}for(let n=0;n<t.attributes.length;n++){const i=t.attributes[n].name;if(a(i)&&i.toLowerCase().indexOf("on")===0){return false}}for(let n=0;n<t.childNodes.length;n++){if(!w(t.childNodes[n])){return false}}}return true};const m=t=>t.startsWith("data:image/svg+xml");const b=t=>t.indexOf(";utf8,")!==-1;const v=new Map;const x=new Map;let y;const M=(t,n=false)=>{let i=x.get(t);if(!i){if(typeof fetch!="undefined"&&typeof document!=="undefined"){if(m(t)&&b(t)){if(!y){y=new DOMParser}const n=y.parseFromString(t,"text/html");const i=n.querySelector("svg");if(i){v.set(t,i.outerHTML)}return Promise.resolve()}else{i=fetch(t).then((i=>{if(i.ok){return i.text().then((i=>{if(i&&n!==false){i=g(i)}v.set(t,i||"")}))}v.set(t,"")}));x.set(t,i)}}else{v.set(t,"");return Promise.resolve()}}return i};const k=":host{contain:strict;display:inline-block;fill:currentColor;height:1em;width:1em}:host .pdsicon{fill:currentColor}.pds-icon-fill-none{fill:none}.icon-inner,.pds-icon,svg{display:block;height:100%;width:100%}";const C=k;const I=class{constructor(t){n(this,t);this.inheritedAttributes={};this.hasAriaHidden=()=>{const{el:t}=this;return t.hasAttribute("aria-hidden")&&t.getAttribute("aria-hidden")==="true"};this.ariaLabel=undefined;this.isVisible=false;this.svgContent=undefined;this.color=undefined;this.icon=undefined;this.name=undefined;this.size="regular";this.src=undefined}iconSize(){const t={small:"12px",regular:"16px",medium:"20px",large:"24px"};if(t[this.size]){return t[this.size]}else{return this.size}}componentWillLoad(){this.inheritedAttributes=p(this.el,["aria-label"])}connectedCallback(){this.waitUntilVisible(this.el,"50px",(()=>{this.isVisible=true;this.loadIcon()}))}disconnectedCallback(){if(this.io){this.io.disconnect();this.io=undefined}}loadIcon(){if(this.isVisible){const t=d(this);if(t){if(v.has(t)){this.svgContent=v.get(t)}else{M(t).then((()=>this.svgContent=v.get(t)))}}}const t=c(this.name,this.icon);if(t){this.ariaLabel=t.replace(/\-/g," ")}}render(){const{ariaLabel:t,inheritedAttributes:n}=this;const s={height:this.iconSize(),width:this.iconSize(),color:this.color};return i(e,Object.assign({"aria-label":t!==undefined&&!this.hasAriaHidden()?t:null,role:"img",style:s,class:Object.assign({},j(this.color))},n),this.svgContent?i("div",{class:"icon-inner",innerHTML:this.svgContent}):i("div",{class:"icon-inner"}))}waitUntilVisible(t,n,i){if(typeof window!=="undefined"&&window.IntersectionObserver){const e=this.io=new window.IntersectionObserver((t=>{if(t[0].isIntersecting){e.disconnect();this.io=undefined;i()}}),{rootMargin:n});e.observe(t)}else{i()}}static get assetsDirs(){return["svg"]}get el(){return s(this)}static get watchers(){return{name:["loadIcon"],src:["loadIcon"],icon:["loadIcon"]}}};const j=t=>t?{"pds-color":true,[`pds-color-${t}`]:true}:null;I.style=C;export{I as pds_icon};
//# sourceMappingURL=p-d3d4661e.entry.js.map