!function(e,t,o){"use strict";var r;if("undefined"==typeof window.parent)return;let n=window.parent;r={init:function(){(t=t||window.elementorFrontend).hooks.addAction("frontend/element_ready/metform.default",(function(o){var r,i,m,d;function a(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()&&((r=o.find(".formpicker_warper_edit")).off("click.metform").on("click.metform",(function(){var t=n.jQuery("#metform-open-content-editor"),o=r.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 r=e(this).closest("li").data("target");t.find("#"+r).fadeIn().siblings().hide()})),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("<p class='metform-error'>No forms were created yet!</p>")}}}),t.show()})),n.jQuery("#metform-open-content-editor").off("click.metform").on("click.metform",".metform-open-content-editor-button",(function(){var t,o=n.jQuery(".metform-dynamic-content-modal"),r=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"),a=d.find(".metform-open-content-editor-templates").val(),f=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=n.jQuery("#metform-form-modalinput-settings").data("nonce");"saved"===f?n.jQuery("body").attr("data-metform-template-key",a):e.ajax({url:e(this).attr("resturl")+"builder_form_id/"+c+"?title="+l,type:"GET",headers:{"X-WP-Nonce":s},success:function(e){n.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"),a=e},async:!1}),t=e(this).attr("resturl")+"builder/"+a,n.jQuery("body").attr("data-metform-template-load","false"),m.show(),o.show(),i.show(),r.contents().find("#elementor-loading").show(),r.css("z-index","-1"),r.attr("src",t),r.on("load",(function(){i.hide(),r.show(),r.contents().find("#elementor-loading").hide(),r.css("z-index","1")}))})),n.jQuery("#elementor-editor-wrapper").on("click","#metform-inspactor-edit-button",(function(){})),"undefined"!=typeof n.jQuery&&n.jQuery(".metform-close-editor-modals").off("click.metform").on("click.metform",(function(){if(e(this).hasClass("metform-editor-close")){var t=n.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")?a(n):confirm("Leaving? Changes you made may not be saved.")?(o.jQuery(o).off("beforeunload"),a(n)):o.jQuery(o).off("beforeunload")}else e(this).hasClass("metform-picker-close")?(a(n),i=n.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&&n.jQuery("body").attr("data-metform-template-key",d),a(n)):a(n);n.jQuery("#metform-open-content-editor").find(".metform-picker-close").hide(),n.jQuery("#metform-open-content-editor").find(".metform-template-radio").removeAttr("checked").first().attr("checked","checked")})),n.jQuery("#metform-open-content-editor").find(".metform-open-content-editor-templates").on("change",(function(){n.jQuery("#metform-open-content-editor").find(".metform-picker-close").fadeIn()})),n.jQuery(".metform-form-update-close-btn").off("click.metform").on("click.metform",(function(){var e,t=n.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")?n.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")&&(n.jQuery(".metform-close-editor-modals").trigger("click.metform"),clearInterval(e))}),100))})))}))}},e(window).on("elementor/frontend/init",r.init)}(jQuery,window.elementorFrontend);