").css({height:this.getSettings("crop.height"),width:this.getSettings("crop.width"),display:"flex",alignItems:"center",justifyContent:"center"}),this.elements.$elementor.append(jQuery("
").css({fontSize:"85px"}).html(this.getSettings("empty_content_headline"))),document.body.prepend(this.elements.$elementor)}},{key:"loadExternalCss",value:function loadExternalCss(){var e=this,r=[this.getSettings("home_url")].concat((0,t.default)(this.getSettings("excluded_external_css_urls"))).map((function(e){return'[href^="'.concat(e,'"]')})).join(", ");jQuery("link").not(r).each((function(t,r){var o=jQuery(r),n=o.clone();n.attr("href",e.getScreenshotProxyUrl(o.attr("href"))),e.elements.$head.append(n),o.remove()}))}},{key:"loadExternalImages",value:function loadExternalImages(){var e=this,t=this.getSettings("external_images_urls").map((function(e){return'img[src^="'.concat(e,'"]')})).join(", ");jQuery(t).each((function(t,r){var o=jQuery(r);o.attr("src",e.getScreenshotProxyUrl(o.attr("src")))}))}},{key:"handleIFrames",value:function handleIFrames(){this.elements.$elementor.find("iframe").each((function(e,t){var r=jQuery(t),o=jQuery("
",{css:{background:"gray",width:r.width(),height:r.height()}});r.before(o),r.remove()}))}},{key:"removeUnnecessaryElements",value:function removeUnnecessaryElements(){var e=this,t=0;this.elements.$sections.filter((function(r,o){var n=!1;return t>=e.getSettings("crop.height")&&(n=!0),t+=jQuery(o).outerHeight(),n})).each((function(e,t){t.remove()})),this.elements.$notElementorElements.remove()}},{key:"handleLinks",value:function handleLinks(){elementorCommon.elements.$body.find("a").attr("href","/")}},{key:"removeFirstSectionMargin",value:function removeFirstSectionMargin(){this.elements.$firstSection.css({marginTop:0})}},{key:"createImage",value:function createImage(){var e=this,t=new Promise((function(e){window.addEventListener("load",(function(){e()}))})),r=new Promise((function(t){setTimeout((function(){t()}),e.getSettings("render_timeout"))}));return Promise.race([t,r]).then((function(){return e.log("Start creating screenshot."),e.getSettings("isDebugSvg")?(domtoimage.toSvg(document.body,{imagePlaceholder:e.getSettings("image_placeholder")}).then((function(t){return e.download(t)})),Promise.reject("Debug SVG.")):/^((?!chrome|android).)*safari/i.test(window.userAgent)?(e.log('Creating screenshot with "html2canvas"'),html2canvas(document.body).then((function(e){return e.toDataURL("image/png")}))):(e.log('Creating screenshot with "dom-to-image"'),domtoimage.toPng(document.body,{imagePlaceholder:e.getSettings("image_placeholder")}))}))}},{key:"download",value:function download(e){var t=jQuery("",{href:e,download:"debugSvg.svg",html:"Download SVG"});elementorCommon.elements.$body.append(t),t.trigger("click")}},{key:"createImageElement",value:function createImageElement(e){var t=new Image;return t.src=e,new Promise((function(e){t.onload=function(){return e(t)}}))}},{key:"cropCanvas",value:function cropCanvas(e){var t=this.getSettings("crop.width"),r=this.getSettings("crop.height"),cropCanvas=document.createElement("canvas"),o=cropCanvas.getContext("2d"),n=t/e.width;return cropCanvas.width=t,cropCanvas.height=r>e.height?e.height:r,o.drawImage(e,0,0,e.width,e.height,0,0,e.width*n,e.height*n),Promise.resolve(cropCanvas)}},{key:"save",value:function save(e){var t=this,r=this.getSettings("template_id"),o=r?"save_template_screenshot":"screenshot_save",n=_objectSpread(_objectSpread({},r?{template_id:this.getSettings("template_id")}:{post_id:this.getSettings("post_id")}),{},{screenshot:e.toDataURL("image/png")});return new Promise((function(e,r){elementorCommon.ajax.addRequest(o,{data:n,success:function success(r){t.log("Screenshot created: ".concat(encodeURI(r))),e(r)},error:function error(){t.log("Failed to create screenshot."),r()}})}))}},{key:"markAsFailed",value:function markAsFailed(e){var t=this;return new Promise((function(r,o){var n=t.getSettings("template_id"),s=t.getSettings("post_id"),i=n?"template_screenshot_failed":"screenshot_failed",a=n?{template_id:n,error:e.message||e.toString()}:{post_id:s};elementorCommon.ajax.addRequest(i,{data:a,success:function success(){t.log("Marked as failed."),r()},error:function error(){t.log("Failed to mark this screenshot as failed."),o()}})}))}},{key:"getScreenshotProxyUrl",value:function getScreenshotProxyUrl(e){return"".concat(this.getSettings("home_url"),"?screenshot_proxy&nonce=").concat(this.getSettings("nonce"),"&href=").concat(e)}},{key:"screenshotSucceed",value:function screenshotSucceed(e){this.screenshotDone(!0,e)}},{key:"screenshotFailed",value:function screenshotFailed(e){var t=this;this.log(e,null),this.markAsFailed(e).then((function(){return t.screenshotDone(!1)}))}},{key:"screenshotDone",value:function screenshotDone(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;clearTimeout(this.timeoutTimer),this.timeoutTimer=null;var r=this.getSettings("template_id"),o=this.getSettings("post_id"),n=r?"library/capture-screenshot-done":"capture-screenshot-done";window.parent.postMessage({name:n,success:e,id:r||o,imageUrl:t},"*"),this.log("Screenshot ".concat(e?"Succeed":"Failed","."),"timeEnd")}},{key:"log",value:function log(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"timeLog";this.getSettings("isDebug")&&(console.log("string"==typeof e?"".concat(this.getSettings("post_id")," - ").concat(e):e),t&&console[t](this.getSettings("timer_label")))}}])}(elementorModules.ViewModule);jQuery((function(){new u}))})()})();