(function(w,a,b,c,e,f){ var d,self,ui,state,appid=a,domain=b,ssoUrl=c,sdkDomain=e,appdomain=f,isReady=!1;if(null==appid||null==domain||null==ssoUrl||null==sdkDomain)throw"Cannot instantiate SDK";var cb=null;function init(){var e;if(e=document.currentScript?document.currentScript:document.querySelector('script[src*="'+sdkDomain+'/platform/sdk.js"]')){var t=new URLSearchParams(e.src.split("?")[1]);t.has("callback")&&(cb=t.get("callback"))}var o=document.createElement("link");o.setAttribute("rel","stylesheet"),o.setAttribute("href",location.protocol+"//"+sdkDomain+"/assets/css/sdk.css?"+Math.random()),document.head.appendChild(o);var i=document.createElement("div");i.classList.add("desplateditor-wrapper","inactive"),ui=i.appendChild(document.createElement("iframe")),document.body.append(i)}d=function(){var e={},t={};function o(e){state=e,ui.parentNode.classList.remove("active","loading","inactive"),ui.parentNode.classList.add(e)}function n(e){e&&void 0!==e.data.id?(o("inactive"),self.lastProjectID=e.data.id,delete self.lastProjectInfo,d("/projectinfo",{id:self.lastProjectID}).then((function(e){if(e.error)t.editornope(e);else{if("object"!=typeof e.result.size){var o=e.result.size.split("x");e.result.size={width:parseFloat(o[0]),height:parseFloat(o[1])}}t.editorok(e)}})).catch((function(e){t.editornope(e)}))):o("inactive")}function a(e,t){if(t||(t={}),t.headers||(t.headers={}),t.headers["X-Requested-With"]="XMLHttpRequest",w.fetch&&"function"==typeof w.fetch)return w.fetch(e,t).then((function(e){return e.json()}));var o=new XMLHttpRequest,n=t&&t.method?t.method:"GET";if(o.promiseCallback=function(e,t){o.success=e,o.failed=t},o.onreadystatechange=function(){this.readyState===XMLHttpRequest.DONE&&200===this.status&&this.success?this.success(JSON.parse(this.responseText)):this.readyState===XMLHttpRequest.DONE&&this.failed&&this.failed(this.responseText)},o.open(n,e),t&&t.headers){var a=Object.keys(t.headers);for(i=0;a.length>i;i++)k=a[i],o.setRequestHeader(k,t.headers[k])}return t&&t.body?o.send(t.body):o.send(),new Promise(o.promiseCallback)}function r(e,t){var o=[];return Object.keys(e).forEach((function(i,n,a){"object"==typeof(a=e[i])?(a=r(a,void 0!==t?t+"["+i+"]":i),o.push(a)):(a=encodeURIComponent(a),void 0!==t?o.push(encodeURIComponent(t+"["+i+"]")+"="+a):o.push(encodeURIComponent(i)+"="+a))})),o.join("&")}function d(e,t){return a(location.protocol+"//"+sdkDomain+"/sdk"+e,{method:"POST",mode:"cors",headers:{"Content-Type":"application/x-www-form-urlencoded",clientID:appid,apiDomain:appdomain},body:null===t?"":r(t)})}this.exportProject=function(e,t,o){if(null===e&&!this.lastProjectInfo)throw"Project not specified";-1===["png","jpg","gif","mp4"].indexOf(t)&&(t="jpg"),null===e&&(e=this.lastProjectInfo.id);var i=location.protocol+"//"+sdkDomain+"/cdn/export/"+e+"."+t;return o&&"string"==typeof o&&(i+="?callback="+o),a(i)},this.logInEditor=function(i,n){delete this.lastProjectID;var a={type:"sdk",domain:window.location.origin,appdomain:appdomain};if(n&&"object"==typeof n?(n.type=a.type,n.domain=a.domain,n.appdomain=a.appdomain):n=a,void 0!==n.size&&0==("string"==typeof n.size&&n.size.match(/[\d\.]+x[\d\.]+/))){throw"Invalid Option [size]";return!1}if(void 0!==n.q&&-1===["string","number"].indexOf(typeof n.q)){throw"Invalid Option [q]";return!1}if(void 0!==n.tpl&&-1===["string","number"].indexOf(typeof n.tpl)){throw"Invalid Option [tpl]";return!1}if(void 0!==n.url&&"string"!=typeof n.url){throw"Invalid Option [url]";return!1}if(void 0!==n.tags&&"string"!=typeof n.tags){throw"Invalid Option [tags]";return!1}if(void 0!==n.isTemplate&&"boolean"!=typeof n.isTemplate){throw"Invalid Option [isTemplate]";return!1}if(void 0!==n.background&&"string"!=typeof n.background){throw"Invalid Option [background]";return!1}return e.editor&&!1!==n.inline&&0==e.editor.closed?(o("loading"),e.editor.postMessage({task:"open",options:n},location.protocol+"//"+domain)):(a=new URLSearchParams(n),!1===n.inline?e.editor=ui.contentWindow=window.open(location.protocol+"//"+domain+"/sso/in/"+i+"?"+a.toString(),"_blank"):(ui.setAttribute("src",location.protocol+"//"+domain+"/sso/in/"+i+"?"+a.toString()),o("loading"),e.editor=ui.contentWindow,e.stateCheck=window.setTimeout((function(){isReady||"inactive"!==state&&(o("inactive"),delete e.editor,ui.removeAttribute("src"),alert("DesignStudioPlatform is taking longer to load. Please check your connection and try again"))}),5e4))),new Promise((function(e,o){t.editorok=e,t.editornope=o}))},this.logOutEditor=function(e){a(location.protocol+"//"+domain+"/sso/out/"+e,{headers:{clientID:appid,apiDomain:appdomain}})},this.getProjects=function(e,t){return d("/userprojects",{id:e,pageoffset:t||0})},this.searchTemplate=function(e,t){var o={pageoffset:t||0};return e&&"object"==typeof e&&(o.filter=e),d("/usertemplates",o)},this.deleteProject=function(e){return d("/deleteproject",{id:e})},function(){window.addEventListener("unload",(function(){e.editor&&e.editor.close()})),window.addEventListener("message",(function(i){!function(i){if(!i.origin.match(new RegExp("http[s]{0,1}://"+domain)))return;if("autherror"===i.data.task)return delete e.editor,o("inactive"),t.editornope&&t.editornope(i.data.error),void alert(i.data.error);"close"==i.data.task?n(i):"loaded"==i.data.task?(isReady||(isReady=!0,window.clearTimeout(e.stateCheck)),"loading"==state&&o("active")):"error"===i.data.task?(o("inactive"),i.data.error&&(t.editornope&&t.editornope(i.data.error),alert("Could not load editor: "+i.data.error.message+": Please try again"))):"fullscreen"==i.data.task?ui.parentNode.classList.toggle("fullscreen"):i.data.id?self.lastProjectID=i.data.id:o("inactive")}(i)}));let i=ui.parentNode.appendChild(document.createElement("div"));i.classList.add("toolbar");let a=i.appendChild(document.createElement("div"));a.classList.add("ballons");for(let e=0;3>e;e++)a.appendChild(document.createElement("span"));let r=i.appendChild(document.createElement("div"));r.classList.add("actions");let d=r.appendChild(document.createElement("button"));d.dataset.action="fullscreen",d.classList.add("fullscreen"),d.title="Toggle fullscreen",d.innerHTML='';let s=r.appendChild(document.createElement("button"));s.classList.add("close"),s.title="Close editor dialog",s.dataset.action="close",s.append("✕"),s.addEventListener("click",(()=>{n()})),d.addEventListener("click",(e=>ui.parentNode.classList.toggle("fullscreen")))}()},init(),w.DesignStudioPlatform=self=new d,cb&&("complete"===document.readyState?window[cb](w.DesignStudioPlatform):window.addEventListener("load",(function(){window[cb](w.DesignStudioPlatform)}))); })(window,"VmU4ZnduWGdFWkpxQjh4eEo5cW1hRFk5cStUL253UHJDY2oxb2JBU1M0NWhMMEZTMXNDTkhKQTVBTFp2b29jVQ==","via.designeditor-as-service.cloud","demo.designrstudio.cloud/ssoin/null","designeditor-as-service.cloud","demo.designrstudio.cloud")