const e=window.webcomponents.h;import"./chunk-de721f0a.js";import"./chunk-fec5a75d.js";import"./chunk-d51357a9.js";import{e as t,j as s,o as a}from"./chunk-f9f1602a.js";import{a as i}from"./chunk-50f0a6d7.js";class l{constructor(){this.app=i.instance}iframeLoaded(e){console.log(e.detail)}componentWillLoad(){this.data={title:"js-base"},t.fetchJson("assets/documentation.json").then(e=>{this.docData=e})}componentDidLoad(){this.postRender()}componentDidUpdate(){this.postRender()}postRender(){this.docData&&s.fadeIn(this.el.querySelector(".jumbotron"),350,1400)}render(){return e("div",{class:"text-center"},e("ema-svg",{src:"../assets/sketch-index/home-content/images/home-content.svg","data-json":JSON.stringify(this.data),class:"img-responsive"}),this.docData&&e("div",{class:"jumbotron pt-3 pb-3 hidden"},e("h5",null,"webcomponents"),e("ul",{class:"list-inline"},this.app.components.map(t=>e("li",{class:"list-inline-item"},e("ema-route-link",{url:"/components/"+t.tag},"<"+t.tag+">")))),e("h5",null,"modules"),e("ul",{class:"list-inline"},this.docData.children.map(t=>{if(t.flags.isExported)return e("li",{class:"list-inline-item"},e("ema-route-link",{url:"/documentation/classes/"+t.name.toLowerCase()},t.name))}))))}static get is(){return"ema-app-home"}static get properties(){return{data:{state:!0},docData:{state:!0},el:{elementRef:!0}}}static get listeners(){return[{name:"iframeLoaded",method:"iframeLoaded"}]}static get style(){return"ema-app-home .jumbotron{color:#868e96;border-top:1px solid #c5c9cd;border-bottom:1px solid #c5c9cd;padding-left:3rem;padding-right:3rem}ema-app-home .jumbotron li{font-size:.86rem;padding:.25rem .33333rem}"}}class n{constructor(){this.type="template"}componentDidLoad(){}componentDidUpdate(){}async loadSvg(){this.loading=!0;const e=await fetch(`${this.src}`).then(e=>e.text()).catch(e=>console.error("Error:",e));return this.loading=!1,e}parseSvg(e){let t=a;this._svg=e,e=e.replace("]>",""),e=t.replaceAll(e,"{{ ","{{"),e=t.replaceAll(e,"{{  ","{{"),e=t.replaceAll(e," }}","}}"),e=t.replaceAll(e,"  }}","}}"),this.data&&Object.keys(this.data).forEach(s=>{e=t.replaceAll(e,"{{"+s+"}}",this.data[s])}),this.svgResult=e,setTimeout(t=>{this.el.querySelector(".embedded").innerHTML=e,setTimeout(e=>{this.el.querySelector("svg")&&(this._svgElement=this.el.querySelector("svg"),this.renderSvg())},40),this.getElements()},20)}async getElements(){this.elements=[];let e=["Shape","Oval","Rectangle","Line","Group"],t=this.el.querySelectorAll("*");return Array.prototype.forEach.call(t,t=>{if(s.getAttributes(t).id){let a=s.getAttributes(t).id,i=!1;e.forEach(e=>{a.match(e)&&(i=!0)}),i||(a.match("btn-")&&(t.style.cursor="pointer",t.style.opacity="0"),this.elements.push({id:a,el:t}))}}),this.setClickHandlers(),this.elements}svgElementClickHandler(e){let t;e.stopPropagation(),this.elements.forEach(s=>{s.el===e.target&&(t=s)}),t&&this.svgElementClick.emit(t)}setClickHandlers(){this.elements.forEach(e=>{document.getElementById(e.id).addEventListener("click",e=>{this.svgElementClickHandler(e)}),e.id.match("btn-")})}renderSvg(){const e=this._svgElement,t=!(-1===this.el.className.indexOf("img-responsive"));let s,a,i;if(e.getAttribute("viewBox")&&(s=e.getAttribute("viewBox")),s&&(a=s.split(" ")[2],i=s.split(" ")[3],!1===t)){let t;this.el.style.width=a+"px",this.el.style.maxWidth=a+"px",this.el.style.height=i+"px",this.el.style.maxHeight=i+"px",e.style.width=a+"px",e.style.maxWidth=a+"px",e.style.height=i+"px",e.style.maxHeight=i+"px",(t=document.createAttribute("width")).value=a,e.setAttributeNode(t),(t=document.createAttribute("height")).value=i,e.setAttributeNode(t)}}render(){return this.dataJson&&(this.data=JSON.parse(this.dataJson)),this.src&&this.loadSvg().then(e=>{this.parseSvg(e)}),e("div",null,e("div",{class:"svg-container embedded"}))}static get is(){return"ema-svg"}static get properties(){return{data:{state:!0},dataJson:{type:"Any",attr:"data-json"},el:{elementRef:!0},getElements:{method:!0},src:{type:String,attr:"src"},svgResult:{state:!0},type:{type:String,attr:"type"}}}static get events(){return[{name:"svgElementClick",method:"svgElementClick",bubbles:!0,cancelable:!0,composed:!0}]}}export{l as EmaAppHome,n as EmaSvg};