var __awaiter=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{l(r.next(t))}catch(t){o(t)}}function a(t){try{l(r["throw"](t))}catch(t){o(t)}}function l(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(s,a)}l((r=r.apply(t,e||[])).next())})};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(t){return function(e){return l([t,e])}}function l(s){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;i=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1];o=s;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(s);break}if(o[2])n.ops.pop();n.trys.pop();continue}s=e.call(t,n)}catch(t){s=[6,t];i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};System.register(["./p-dde863a3.system.js","./p-1095b4e8.system.js","./p-ed9e4708.system.js"],function(t){"use strict";var e,n,r,i,o,s;return{setters:[function(t){e=t.r;n=t.c;r=t.h;i=t.g},function(){},function(t){o=t.D;s=t.S}],execute:function(){var a=function(){function t(t){e(this,t);this.type="template";this.svgElementClick=n(this,"svgElementClick",7)}t.prototype.componentDidLoad=function(){};t.prototype.componentDidUpdate=function(){};t.prototype.loadSvg=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:this.loading=true;return[4,fetch(""+this.src).then(function(t){return t.text()}).catch(function(t){return console.error("Error:",t)})];case 1:t=e.sent();this.loading=false;return[2,t]}})})};t.prototype.parseSvg=function(t){var e=this;var n=s;this._svg=t;t=t.replace("]>","");t=n.replaceAll(t,"{{ ","{{");t=n.replaceAll(t,"{{  ","{{");t=n.replaceAll(t," }}","}}");t=n.replaceAll(t,"  }}","}}");if(this.data){Object.keys(this.data).forEach(function(r){t=n.replaceAll(t,"{{"+r+"}}",e.data[r])})}this.svgResult=t;setTimeout(function(n){e.el.querySelector(".embedded").innerHTML=t;e.getElements();if(e.el.querySelector("svg")){e._svgElement=e.el.querySelector("svg");e.renderSvg()}},20)};t.prototype.getElements=function(){return __awaiter(this,void 0,void 0,function(){var t,e;var n=this;return __generator(this,function(r){this.elements=[];t=["Shape","Oval","Rectangle","Line","Group"];e=this.el.querySelectorAll("*");Array.prototype.forEach.call(e,function(e){if(o.getAttributes(e)["id"]){var r=o.getAttributes(e)["id"];var i=false;t.forEach(function(t){if(r.match(t)){i=true}});if(!i){if(r.match("btn-")){e.style.cursor="pointer";e.style.opacity="0"}n.elements.push({id:r,el:e})}}});this.setClickHandlers();return[2,this.elements]})})};t.prototype.svgElementClickHandler=function(t){var e;t.stopPropagation();this.elements.forEach(function(n){if(n.el===t.target){e=n}});if(e){this.svgElementClick.emit(e)}};t.prototype.setClickHandlers=function(){var t=this;this.elements.forEach(function(e){if(document.getElementById(e.id)){document.getElementById(e.id).addEventListener("click",function(e){t.svgElementClickHandler(e)});if(e.id.match("btn-"));}})};t.prototype.renderSvg=function(){var t=this._svgElement;var e=!(this.el.className.indexOf("img-responsive")===-1);var n;if(t.getAttribute("viewBox")){n=t.getAttribute("viewBox")}var r,i;if(n){r=n.split(" ")[2];i=n.split(" ")[3];if(e===false){this.el.style.width=r+"px";this.el.style.maxWidth=r+"px";this.el.style.height=i+"px";this.el.style.maxHeight=i+"px";t.style.width=r+"px";t.style.maxWidth=r+"px";t.style.height=i+"px";t.style.maxHeight=i+"px";var o=void 0;o=document.createAttribute("width");o.value=r;t.setAttributeNode(o);o=document.createAttribute("height");o.value=i;t.setAttributeNode(o)}}};t.prototype.render=function(){var t=this;if(this.dataJson){this.data=JSON.parse(this.dataJson)}if(this.src){this.loadSvg().then(function(e){t.parseSvg(e)})}return r("div",{class:"svg-container embedded"})};Object.defineProperty(t.prototype,"el",{get:function(){return i(this)},enumerable:true,configurable:true});return t}();t("ema_svg",a)}}});