"use strict";var KTLayoutBuilder=function(){var e,t={init:function(){e=$("#form-builder").attr("action")},startLoad:function(e){$("#builder_export").addClass("spinner spinner-right spinner-primary").find("span").text("Exporting...").closest(".card-footer").find(".btn").attr("disabled",!0),toastr.info(e.title,e.message)},doneLoad:function(){$("#builder_export").removeClass("spinner spinner-right spinner-primary").find("span").text("Export").closest(".card-footer").find(".btn").attr("disabled",!1)},exportHtml:function(a){t.startLoad({title:"Generate HTML Partials",message:"Process started and it may take a while."}),$.ajax(e,{method:"POST",data:{builder_export:1,export_type:"partial",demo:a,theme:"metronic"}}).done((function(r){var i=JSON.parse(r);if(i.message)t.stopWithNotify(i.message);else var n=setInterval((function(){$.ajax(e,{method:"POST",data:{builder_export:1,demo:a,builder_check:i.id}}).done((function(r){var i=JSON.parse(r);void 0!==i&&1===i.export_status&&$("<iframe/>").attr({src:e+"?builder_export&builder_download&id="+i.id+"&demo="+a,style:"visibility:hidden;display:none"}).ready((function(){toastr.success("Export HTML Version Layout","HTML version exported."),t.doneLoad(),clearInterval(n)})).appendTo("body")}))}),15e3)}))},stopWithNotify:function(e,a){a=a||"danger",void 0!==toastr[a]&&toastr[a]("Verification failed",e),t.doneLoad()}},a={reCaptchaVerified:function(){return $.ajax("/metronic/theme/html/tools/builder/recaptcha.php?recaptcha",{method:"POST",data:{response:$("#g-recaptcha-response").val()}}).fail((function(){grecaptcha.reset(),$("#alert-message").removeClass("alert-success d-hide").addClass("alert-danger").html("Invalid reCaptcha validation")}))},init:function(){var e;$("#builder_export").click((function(t){t.preventDefault(),e=$(this),$("#kt-modal-purchase").modal("show"),$("#alert-message").addClass("d-hide"),grecaptcha.reset()})),$("#submit-verify").click((function(r){r.preventDefault(),$("#g-recaptcha-response").val()?a.reCaptchaVerified().done((function(a){if(a.success){$('[data-dismiss="modal"]').trigger("click");var r=$(e).data("demo");switch($(e).attr("id")){case"builder_export":case"builder_export_html":t.exportHtml(r)}}else grecaptcha.reset(),$("#alert-message").removeClass("alert-success d-hide").addClass("alert-danger").html("Invalid reCaptcha validation")})):$("#alert-message").removeClass("alert-success d-hide").addClass("alert-danger").html("Invalid reCaptcha validation")}))}},r=function(){t.init(),$('[name="builder_submit"]').click((function(t){t.preventDefault();var a=$(this);$(a).addClass("spinner spinner-right spinner-white").closest(".card-footer").find(".btn").attr("disabled",!0),$(".nav[data-remember-tab]").each((function(){var e=$(this).data("remember-tab"),t=$(this).find('.nav-link.active[data-toggle="tab"]').attr("href");$("#"+e).val(t)})),$.ajax(e+"?demo="+$(a).data("demo"),{method:"POST",data:$("[name]").serialize()}).done((function(e){toastr.success("Preview updated","Preview has been updated with current configured layout.")})).always((function(){setTimeout((function(){location.reload()}),600)}))})),$('[name="builder_reset"]').click((function(t){t.preventDefault();var a=$(this);$(a).addClass("spinner spinner-right spinner-primary").closest(".card-footer").find(".btn").attr("disabled",!0),$.ajax(e+"?demo="+$(a).data("demo"),{method:"POST",data:{builder_reset:1,demo:$(a).data("demo")}}).done((function(e){})).always((function(){location.reload()}))}))};return{init:function(){a.init(),r()}}}();jQuery(document).ready((function(){KTLayoutBuilder.init()}));