!function(e,t,o){"use strict";var n;if("undefined"==typeof window.parent)return;let r=window.parent;n={init:function(){(t=t||window.elementorFrontend).hooks.addAction("frontend/element_ready/metform.default",(function(o){var n,i,m,d;function f(e){e.jQuery("body").attr("data-metform-template-load","true"),e.jQuery(".metform-dynamic-content-modal").hide(),e.jQuery("#metform-open-content-editor").hide()}t.isEditMode()&&((n=o.find(".formpicker_warper_edit")).off("click.metform").on("click.metform",(function(){var t=r.jQuery("#metform-open-content-editor"),o=n.attr("data-metform-formpicker-key"),i=e(this).attr("data-nonce");t.find(".metform-error").remove(),t.find(".metform-content-editor-radio").on("click",(function(o){var n=e(this).closest("li").data("target");t.find("#"+n).fadeIn().siblings().hide(),r.jQuery("#metform-open-content-editor").find(".metform-picker-close").hide(),r.jQuery("#metform-open-content-editor").find(".metform-open-content-editor-button").removeClass("position-left")})),e.ajax({url:e(this).attr("resturl")+(o||0),type:"get",headers:{"X-WP-Nonce":i},dataType:"html",success:function(e){if(e)t.find(".metform-content-editor-radio").first().trigger("click"),t.find(".metform-open-content-editor-templates").html(e);else{t.find(".metform-content-editor-radio").last().trigger("click");let e=t.find(".metform-open-content-editor-templates").parent();0===e.find(".metform-error").length&&e.append("

No forms were created yet!

")}}}),t.show()})),r.jQuery("#metform-open-content-editor").off("click.metform").on("click.metform",".metform-open-content-editor-button",(function(){var t,o=r.jQuery(".metform-dynamic-content-modal"),n=o.find("#formpicker-control-iframe"),i=o.find(".dialog-lightbox-loading"),m=o.find(".dialog-type-lightbox"),d=e(this).parents(".metform-open-content-inner"),f=d.find(".metform-open-content-editor-templates").val(),a=d.find(".metform-content-editor-radio:checked").val(),c=d.find(".metform-template-radio:checked").val(),l=d.find(".metform-template-input-con input").val(),s=r.jQuery("#metform-form-modalinput-settings").data("nonce"),u=d.find("#metform-add-new-form-model__form-type option:selected").val();"saved"===a?r.jQuery("body").attr("data-metform-template-key",f):e.ajax({url:e(this).attr("resturl")+"builder_form_id/"+c+"?title="+l+"&form_type="+u,type:"GET",headers:{"X-WP-Nonce":s},success:function(e){r.jQuery("body").attr("data-metform-template-key",e),d.find(".metform-template-input-con input").val(""),d.find(".metform-template-radio").removeAttr("checked").first().attr("checked","checked"),f=e},async:!1}),t=e(this).attr("resturl")+"builder/"+f,r.jQuery("body").attr("data-metform-template-load","false"),m.show(),o.show(),i.show(),n.contents().find("#elementor-loading").show(),n.css("z-index","-1"),n.attr("src",t),n.on("load",(function(){i.hide(),n.show(),n.contents().find("#elementor-loading").hide(),n.css("z-index","1")}))})),r.jQuery("#elementor-editor-wrapper").on("click","#metform-inspactor-edit-button",(function(){})),"undefined"!=typeof r.jQuery&&r.jQuery(".metform-close-editor-modals").off("click.metform").on("click.metform",(function(){if(e(this).hasClass("metform-editor-close")){var t=r.jQuery(".metform-dynamic-content-modal").find("#formpicker-control-iframe"),o=t[0].contentWindow||t[0].contentDocument;o.jQuery("#elementor-panel-saver-button-publish").hasClass("elementor-disabled")?f(r):confirm("Leaving? Changes you made may not be saved.")?(o.jQuery(o).off("beforeunload"),f(r)):o.jQuery(o).off("beforeunload")}else e(this).hasClass("metform-picker-close")?(f(r),i=r.jQuery("#metform-open-content-editor"),m=i.find(".metform-content-editor-radio:checked").val(),d=i.find(".metform-open-content-editor-templates").val(),"saved"===m&&r.jQuery("body").attr("data-metform-template-key",d),f(r)):f(r);r.jQuery("#metform-open-content-editor").find(".metform-picker-close").hide(),r.jQuery("#metform-open-content-editor").find(".metform-open-content-editor-button").removeClass("position-left"),r.jQuery("#metform-open-content-editor").find(".metform-template-radio").removeAttr("checked").first().attr("checked","checked")})),r.jQuery("#metform-open-content-editor").find(".metform-open-content-editor-templates").on("change",(function(){r.jQuery("#metform-open-content-editor").find(".metform-picker-close").fadeIn(),r.jQuery("#metform-open-content-editor").find(".metform-open-content-editor-button").addClass("position-left")})),r.jQuery(".metform-form-update-close-btn").off("click.metform").on("click.metform",(function(){var e,t=r.jQuery(".metform-dynamic-content-modal").find("#formpicker-control-iframe"),o=t[0].contentWindow||t[0].contentDocument;o.jQuery("#elementor-panel-saver-button-publish:not([disabled])").hasClass("elementor-disabled")?r.jQuery(".metform-close-editor-modals").trigger("click.metform"):(o.jQuery("#elementor-panel-saver-button-publish:not([disabled])").trigger("click"),e=setInterval((function(){o.jQuery("#elementor-panel-saver-button-publish:not([disabled])").hasClass("elementor-disabled")&&(r.jQuery(".metform-close-editor-modals").trigger("click.metform"),clearInterval(e))}),100))})))}))}},e(window).on("elementor/frontend/init",n.init)}(jQuery,window.elementorFrontend);