jQuery(document).ready((function(e){"use strict";var t,i,o;let s;function a(){var t=e(this);t.addClass("mf-setting-spin");var i=e("#metform-form-modalinput-settings").attr("data-nonce"),o=e(".mf-google-spreadsheets-list");e.ajax({url:window.metform_api.resturl+"metform/v1/entries/google_spreadsheet_list/0",type:"get",headers:{"X-WP-Nonce":i},dataType:"json",success:function(i){try{o.empty();let t=JSON.parse(i);o.append(''),t.files.forEach((e=>{o.append("")})),1===t.files.length||(s=e(".mf-google-spreadsheets-list-id").val(),e(".mf-google-spreadsheets-list option").each(((t,i)=>{e(i).attr("selected",!1),i.value===s&&e(i).attr("selected",!0)})),e(".mf-google-spreadsheets-list").on("change",(t=>{e(".mf-google-spreadsheets-list-id").attr("value",t.target.value),n(t.target.value)})))}catch(a){}var s;t.removeClass("mf-setting-spin")},error:function(e){t.removeClass("mf-setting-spin")}})}function n(t=""){var i=e(this);i.addClass("mf-setting-spin");var o=e("#metform-form-modalinput-settings").attr("data-nonce");if(typeof t!==undefined&&""!=t)var s=t;else s=e(".mf-google-spreadsheets-list-id").val();""==s&&(s=0);var a=e(".mf-google-sheets-list");e.ajax({url:window.metform_api.resturl+"metform/v1/entries/google_sheet_list/0",type:"get",data:{sheetID:s},headers:{"X-WP-Nonce":o},dataType:"json",success:function(t){try{a.empty();let i=JSON.parse(t);i.sheets.forEach((e=>{a.append("")})),1===i.sheets.length?e(".mf-google-sheets-list-id").attr("value",i.sheets[0].properties.title):(o=e(".mf-google-sheets-list-id").val(),e(".mf-google-sheets-list option").each(((t,i)=>{e(i).attr("selected",!1),i.value===o&&e(i).attr("selected",!0)})),e(".mf-google-sheets-list").on("change",(t=>{e(".mf-google-sheets-list-id").attr("value",t.target.value)})))}catch(s){}var o;i.removeClass("mf-setting-spin")},error:function(e){i.removeClass("mf-setting-spin")}})}function r(){var t=e(".mf-mailchimp-list-id").val();e(".mailchimp_list option").each(((i,o)=>{e(o).attr("selected",!1),o.value===t&&e(o).attr("selected",!0)}))}e(".metfrom-btn-refresh-get-response-list").click((function(){var t=e(this);t.addClass("mf-setting-spin");var i,o=e("#metform_form_modal"),s=e("#metform-form-modalinput-settings").attr("data-nonce"),a=e(".get-response-campaign-list");i=o.find("form").attr("data-mf-id"),e.ajax({url:window.metform_api.resturl+"metform/v1/entries/store_get_response_list/"+i,type:"get",headers:{"X-WP-Nonce":s},dataType:"json",success:function(e){a.empty(),e.forEach((e=>{a.append('")})),t.removeClass("mf-setting-spin")},error:function(e){t.removeClass("mf-setting-spin")}})})),e(".metfrom-btn-refresh-mailchimp-list").on("click",(function(){var t=e(this);t.addClass("mf-setting-spin");var i,o=e("#metform_form_modal"),s=e("#metform-form-modalinput-settings").attr("data-nonce"),a=e(".mailchimp_list");i=o.find("form").attr("data-mf-id"),e.ajax({url:window.metform_api.resturl+"metform/v1/entries/store_mailchimp_list/"+i,type:"get",headers:{"X-WP-Nonce":s},dataType:"json",success:function(i){try{a.empty(),i.lists.forEach((e=>{a.append("")})),1===i.lists.length?e(".mf-mailchimp-list-id").attr("value",i.lists[0].id):(r(),e(".mailchimp_list").on("change",(t=>{e(".mf-mailchimp-list-id").attr("value",t.target.value)})))}catch(o){}t.removeClass("mf-setting-spin")},error:function(e){t.removeClass("mf-setting-spin")}})})),e(".metfrom-btn-refresh-google-spreadsheets-list").on("click",a),e(".metfrom-btn-refresh-google-sheets-list").on("click",(function(e){n("")})),e(".metfrom-btn-refresh-hubsopt-list").click((function(){var t=e(this);t.addClass("mf-setting-spin");var i,o=e("#metform_form_modal"),s=e("#metform-form-modalinput-settings").attr("data-nonce"),a=e(".hubspot_forms"),n=e("#mf-hubsopt-fileds");i=o.find("form").attr("data-mf-id"),e.ajax({url:window.metform_api.resturl+"metform/v1/forms/hubspot_forms/"+i,type:"get",headers:{"X-WP-Nonce":s},dataType:"json",beforeSend:function(t){e(n).text("Please wait....")},success:function(i){try{a.empty(),a.append(''),i.forEach((e=>{a.append("")}))}catch(o){}e(n).text(""),t.removeClass("mf-setting-spin")},error:function(i){e(n).text(""),t.removeClass("mf-setting-spin")}})})),e(".hubspot_forms").on("change",(function(){var t=e("option:selected",this).attr("guid"),i=e("option:selected",this).val();e(".mf_hubspot_form_guid").val(t),e(".mf_hubspot_form_portalId").val(i);var o,s=e("#metform_form_modal"),a=e("#metform-form-modalinput-settings").attr("data-nonce");o=s.find("form").attr("data-mf-id"),e("#mf-hubsopt-fileds").html("Please wait....");var n="";e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+o,type:"get",headers:{"X-WP-Nonce":a},dataType:"json",success:function(i){n=i,e.ajax({url:window.metform_api.resturl+"metform/v1/forms/hubspot_form_fields/"+o,type:"post",headers:{"X-WP-Nonce":a},dataType:"json",data:{guid:t},success:function(t){var i="",o="";Object.keys(n).map((function(e){return[n[e]]})).map((e=>{o+=""}));t.forEach((e=>{i+=""+e.label+""})),e("#mf-hubsopt-fileds").html(''+i+"
")},error:function(t){e("#mf-hubsopt-fileds").html("Please select a form.")}})},error:function(t){e("#mf-hubsopt-fileds").html("Sorry ! Something went wrong")}})})),e("#mf-remove-hubspot-access").on("click",(function(t){t.preventDefault();var i=e(this).attr("data-nonce");e.ajax({url:window.metform_api.resturl+"metform/v1/forms/disconnect_hubspot/1",type:"get",headers:{"X-WP-Nonce":i},dataType:"json",success:function(e){window.location.reload()},error:function(e){console.log("Sorry ! Something went wrong",e)}})})),e(".mf-mailchimp-list-id").attr("value",""),e(".page-title-action").on("click",(function(t){t.preventDefault(),e("#metform_new_form_modal").modal("show")}));let m=window.parent;function l(e){e.jQuery("body").attr("data-metform-template-load","true"),e.jQuery(".metform-dynamic-content-modal").hide(),e.jQuery("#metform-open-content-editor").hide()}function f(){e(".mf-btn-del-singl-field").click((function(){e(this).parent(".mf-cf-single-field").remove()}))}function c(){1===e(".mf-form-data-bypass-single-field").length?e(".mf-form-data-bypass-delete-btn").addClass("mf-single-field-delete-btn"):e(".mf-form-data-bypass-delete-btn").removeClass("mf-single-field-delete-btn")}function d(){1===e(".mf-zoho-crm-single-field").length?e(".mf-btn-del-single-field").addClass("mf-single-field-delete-btn"):e(".mf-btn-del-single-field").removeClass("mf-single-field-delete-btn")}function p(){e(".mf-btn-del-single-field, .mf-form-data-bypass-delete-btn").click((function(){if(this.className.includes("mf-form-data-bypass-delete-btn")){let t=this.closest("#paramFieldsrepeaterResult");e(t).find(".mf-form-data-bypass-single-field").length>1&&e(this).parent(".mf-cf-single-field").remove(),c()}else if(this.className.includes("mf-btn-del-single-field")){let t=this.closest("#mf-zoho-all-form-fields");e(t).find(".mf-zoho-crm-single-field").length>1&&e(this).parent(".mf-cf-single-field").remove(),d()}}))}e(".metform-open-new-form-editor-modal").on("click",(function(t){t.preventDefault();var i,o,s=m.jQuery(".metform-dynamic-content-modal"),a=s.find("#formpicker-control-iframe"),n=s.find(".dialog-lightbox-loading"),r=s.find(".dialog-type-lightbox"),l=jQuery(this).parents(".add-new-model__footer-button-group").siblings(".metform-add-new-form-model-contents"),f=l.find("#metform-add-new-form-model__form-type option:selected").val(),c=l.find(".metform-template-radio:checked").val(),d=l.find(".metform-template-input-con input").val(),p=m.jQuery("#metform-form-modalinput-settings").data("nonce");jQuery.ajax({url:jQuery(this).attr("resturl")+"builder_form_id/"+c+"?title="+d+"&form_type="+f,type:"GET",headers:{"X-WP-Nonce":p},success:function(t){m.jQuery("body").attr("data-metform-template-key",t),l.find(".metform-template-input-con input").val(""),l.find(".metform-template-radio").removeAttr("checked").first().attr("checked","checked"),o=t;var i=e("#metform_new_form_modal"),s=e(".modal-backdrop");i.hide(),s.hide()},async:!1}),i=jQuery(this).attr("resturl")+"builder/"+o,m.jQuery("body").attr("data-metform-template-load","false"),r.show(),s.show(),n.show(),a.contents().find("#elementor-loading").show(),a.css("z-index","-1"),a.attr("src",i),a.on("load",(function(){n.hide(),a.show(),a.contents().find("#elementor-loading").hide(),a.css("z-index","1")}))})),m.jQuery(".metform-form-update-close-btn").on("click",(function(t){if(t.preventDefault(),m.jQuery("body").hasClass("wp-admin")){var i,o=m.jQuery(".metform-dynamic-content-modal").find("#formpicker-control-iframe"),s=o[0].contentWindow||o[0].contentDocument;s.jQuery("#elementor-panel-saver-button-publish:not([disabled])").hasClass("elementor-disabled")?(m.jQuery(".metform-close-editor-modals").trigger("click"),window.location.reload()):e(s.jQuery("#elementor-panel-saver-button-publish")).length>0&&!e(s.jQuery("#elementor-panel-saver-button-publish"))[0].classList.contains("elementor-button-state")&&(s.jQuery("#elementor-panel-saver-button-publish:not([disabled])").trigger("click"),i=setInterval((function(){s.jQuery("#elementor-panel-saver-button-publish:not([disabled])").hasClass("elementor-disabled")&&(m.jQuery(".metform-close-editor-modals").trigger("click"),clearInterval(i),window.location.reload())}),100))}})),m.jQuery(".metform-close-editor-modals").on("click",(function(e){if(e.preventDefault(),jQuery(this).hasClass("metform-editor-close")){var s=m.jQuery(".metform-dynamic-content-modal").find("#formpicker-control-iframe"),a=s[0].contentWindow||s[0].contentDocument;a.jQuery("#elementor-panel-saver-button-publish").hasClass("elementor-disabled")?l(m):confirm("Leaving? Changes you made may not be saved.")?(a.jQuery(a).off("beforeunload"),l(m)):a.jQuery(a).off("beforeunload")}else jQuery(this).hasClass("metform-picker-close")?(l(m),t=m.jQuery("#metform-open-content-editor"),i=t.find(".metform-content-editor-radio:checked").val(),o=t.find(".metform-open-content-editor-templates").val(),"saved"===i&&m.jQuery("body").attr("data-metform-template-key",o),l(m)):l(m);m.jQuery("#metform-open-content-editor").find(".metform-picker-close").hide(),m.jQuery("#metform-open-content-editor").find(".metform-template-radio").removeAttr("checked").first().attr("checked","checked")})),e(".row-actions .edit a, .metform-form-edit-btn, body.post-type-metform-form a.row-title").on("click",(async function(t){t.preventDefault();var i=0,o=e("#metform_form_modal"),a=e(this).parents(".column-title"),n=e("body").attr("data-metform-template-key");o.addClass("loading"),o.modal("show");var m;if(a.length>0){i=e(this).attr("data-metform-form-id"),"undefined"!==n&&(i=n),i=i!==undefined?i:a.find(".hidden").attr("id").split("_")[1];var l=e("#metform-form-modalinput-settings").attr("data-nonce");const t=await fetch(window.metform_api.resturl+"metform/v1/forms/get/"+i,{method:"GET",headers:{"X-WP-Nonce":l}}),r=await t.json();window.mf_data=r,m=r,s=r,L(r,i),o.removeClass("loading");const f=new CustomEvent("metform-integration-settings-event",{detail:{data:r},bubbles:!0,cancelable:!0,composed:!1});document.querySelector("#metform-form-modalinput-settings").dispatchEvent(f),function(t,i,o){e(".mf-helpscout").length&&e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+t,type:"get",headers:{"X-WP-Nonce":i},dataType:"json",success:function(t){var i=t,s=Object.keys(i).map((function(e){return[i[e]]}));B="",H=[],s.map((e=>{let t={};t.mf_input_name=e[0].mf_input_name,t.mf_input_label=e[0].mf_input_label,H=[...H,t],B+=""}));var a='
'+('
")+'
'+('
")+'
'+('
")+'
'+('
")+'
'+('
")+"
";e("#mf-helpscout-fileds").html(a),o.mf_helpscout_conversation_subject&&(e('#mf_helpscout_conversation_subject option[value="'+o.mf_helpscout_conversation_subject+'"]').prop("selected",!0),e('#mf_helpscout_conversation_customer_email option[value="'+o.mf_helpscout_conversation_customer_email+'"]').prop("selected",!0),e('#mf_helpscout_conversation_customer_first_name option[value="'+o.mf_helpscout_conversation_customer_first_name+'"]').prop("selected",!0),e('#mf_helpscout_conversation_customer_last_name option[value="'+o.mf_helpscout_conversation_customer_last_name+'"]').prop("selected",!0),e('#mf_helpscout_conversation_customer_message option[value="'+o.mf_helpscout_conversation_customer_message+'"]').prop("selected",!0))},error:function(e){}})}(i,l,r),function(t,i,o){if(e(".mf-zoho").length>0){let s=metform_api.admin_url+"admin-ajax.php",a={action:"get_contact_fields",formId:t,nonce:i};e.ajax({url:s,type:"post",data:a,headers:{"X-WP-Nonce":i},dataType:"json",success:function(t){if(t&&!1===t?.success)return e(".mf-zoho-error-msg").show(),void e(".mf-zoho-error-msg").html(t?.data);e(".mf-zoho-error-msg").hide(),e(".mf-zoho-error-msg").html(""),"1"===o?.mf_zoho?e(".mf_zoho_forms_section").show():e(".mf_zoho_forms_section").hide();let i=JSON.parse(t?.data?.zoho_api_fields)||{},s="";t?.data?.zoho_existing_fields[0]&&(s=JSON.parse(t?.data?.zoho_existing_fields[0])||{});let a=[];if(i?.layouts){let t=i?.layouts[0]?.sections,o=[];t.forEach(((e,t)=>{0!==t&&(o=[...o,...e.fields])})),o.forEach(((e,t)=>{let i={};i.api_name=e?.api_name,i.display_label=e?.display_label,a=[...a,i]}));let s="";a.map(((e,t)=>{s+=``})),e(".mf-zoho-form-fields").html(s),e(".mf-zoho-custom-fields").html(B)}else o?.code;if(Object.keys(s).length>0){let t="";Object.keys(s).forEach(((e,i)=>{let o="",n="";H.forEach(((t,i)=>{e==t.mf_input_name?o+=``:o+=``}));let r=["Created_Time","Created_By","Modified_By","Modified_Time","Last_Activity_Time","Reporting_To","Unsubscribed_Mode","Unsubscribed_Time","Change_Log_Time__s","Vendor_Name","Owner"];a.filter((e=>!r.includes(e.api_name))).forEach(((t,i)=>{s[e]==t.api_name?n+=``:n+=``})),t+=`
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\tDelete\n\t\t\t\t\t
`})),e("#mf-zoho-all-form-fields").html(t),p()}else if(0===Object.keys(s).length){e(".mf-zoho-single-field").each(((e,t)=>{0!==e&&t.remove()}))}d()},error:function(e){console.log("Error: "+e)}})}}(i,l,r)}else{L({form_title:e(".mf-form-modalinput-title").attr("data-default-value"),admin_email_body:"",admin_email_from:"",admin_email_reply_to:"",admin_email_subject:"",capture_user_browser_data:"",enable_admin_notification:"",limit_total_entries_status:"",limit_total_entries:"0",redirect_to:"",success_url:"",failed_cancel_url:"",quiz_summery:"",require_login:"",store_entries:"1",user_email_attach_submission_copy:"1",entry_title:"",success_message:e(".mf-form-modalinput-success_message").attr("data-default-value"),user_email_body:"",user_email_from:"",user_email_reply_to:"",user_email_subject:"",input_names:"Example: [mf-inputname]"},i),o.removeClass("loading")}function u(e,t=""){let i="";return Array.isArray(e)&&e.map((e=>{const o=t===e[0].mf_input_name?" selected":"";i+=""})),i}e(".mf-register").length&&e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+i,type:"get",headers:{"X-WP-Nonce":l},dataType:"json",success:function(t){var o=t,s="";e.ajax({url:window.metform_api.resturl+"xs/register/settings/"+i,type:"get",headers:{"X-WP-Nonce":l},dataType:"json",success:function(t){Object.keys(o).map((function(e){return[o[e]]})).map((e=>{s+=""}));var i='
'+('
")+'
'+('
")+'
';e(".mf_register_form_fields").html(i),0!=t&&(e('#mf_auth_reg_user_name option[value="'+t.mf_auth_reg_user_name+'"]').prop("selected",!0),e('#mf_auth_reg_user_email option[value="'+t.mf_auth_reg_user_email+'"]').prop("selected",!0),e('#mf_auth_reg_role option[value="'+t.mf_auth_reg_role+'"]').prop("selected",!0))},error:function(e){}})},error:function(e){}}),e(".mf-login").length&&e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+i,type:"get",headers:{"X-WP-Nonce":l},dataType:"json",success:function(t){var o=t,s="";e.ajax({url:window.metform_api.resturl+"xs/login/settings/"+i,type:"get",headers:{"X-WP-Nonce":l},dataType:"json",success:function(t){Object.keys(o).map((function(e){return[o[e]]})).map((e=>{s+=""}));var i='
'+('
")+'
'+('
")+"
";e(".mf_login_form_fields").html(i),0!=t&&(e('#mf_auth_login_user_name option[value="'+t.mf_auth_login_user_name+'"]').prop("selected",!0),e('#mf_auth_login_user_password option[value="'+t.mf_auth_login_user_password+'"]').prop("selected",!0))},error:function(e){}})},error:function(e){}}),e(".mf-form-to-post").length&&e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+i,type:"get",headers:{"X-WP-Nonce":l},dataType:"json",success:function(t){var o=t,s="";e.ajax({url:window.metform_api.resturl+"xs/post/settings/"+i,type:"get",headers:{"X-WP-Nonce":l},dataType:"json",success:function(t){var i=Object.keys(o).map((function(e){return[o[e]]}));i.map((e=>{s+=""}));var a='
",n='
",r='
",m=h(s);if(0!=t.custom_fields_settings){m="";var l=Object.entries(t.custom_fields_settings);for(const[e,t]of l)m+=h(u(i,t),e,t)}var c='
'+a+'
'+n+'
'+r+'
'+function(e,t){return'\n
\n
\n
\n
\n \n \n
\n
\n \n \n
\n Delete\n
\n
\n
'+e+'
\n \n
'}(m,s)+"
";e(".mf-post-submission-fields-section").html(c);var d=0;e(".mf-add-cf").click((function(){var t=e("#mf-cf-single-field").clone();d++,t.attr("id","mf-repeater-field-"+d),e(".mf-btn-del-singl-field",t).attr("data-id",d),t.appendTo(e(".repeaterResult")),f()})),f(),0!=t.fields_settings&&(e('.mf_post_submission_post_type option[value="'+t.fields_settings.mf_post_submission_post_type+'"]').prop("selected",!0),e('.mf_post_submission_title option[value="'+t.fields_settings.mf_post_submission_title+'"]').prop("selected",!0),e('.mf_post_submission_content option[value="'+t.fields_settings.mf_post_submission_content+'"]').prop("selected",!0),e('.mf_post_submission_featured_image option[value="'+t.fields_settings.mf_post_submission_featured_image+'"]').prop("selected",!0),e('.mf_post_submission_author option[value="'+t.fields_settings.mf_post_submission_author+'"]').prop("selected",!0))},error:function(e){}})},error:function(e){}}),e("input.mf_redirect_params_status").length&&e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+i,type:"get",headers:{"X-WP-Nonce":l},dataType:"json",success:function(t){"true"==m.mf_redirect_params_status.trim()?(e("input.mf_redirect_params_status").prop("checked",!0),e("input.mf_redirect_params_status").val("true"),b.show(200)):(e("input.mf_redirect_params_status").prop("checked",!1),e("input.mf_redirect_params_status").val("false"),b.hide(200));var i="";if(Object.keys(t||{}).forEach((e=>{i+='"})),e("#mf-form-fields-url-copier").html(i),m?.mf_redirect_params!=undefined){var o="",s=Object.values(t||{});Object.keys(m.mf_redirect_params||{}).forEach((e=>{var t="";s.forEach((i=>{i.mf_input_name==m.mf_redirect_params[e]?t+='":t+='"})),o+=`
\n\t\t\t\t\t
\n\t\t\t\t\t\t \n\t\t\t\t\t\t \n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t \n\t\t\t\t\t\t \n\t\t\t\t\t\t
\n\t\t\t\t\t\tDelete\n\t\t\t\t\t\t
\n\t\t\t\t\t `})),e("#paramFieldsrepeaterResult").html(o)}else if(m?.mf_redirect_params===undefined||0===Object.keys(m.mf_redirect_params).length){e(".mf-form-data-bypass-single-field").each(((e,t)=>{0!==e&&t.remove()})),e(".mf-form-data-bypass-input").val(""),e(".mf-form-data-bypass-select").html(i)}p(),c()},error:function(e){}});var _=0;e(".mf-add-rf").click((function(){var t=e("#mf-rf-single-field-copier").clone();_++,t.attr("id","mr-repeater-field-"+_),e(".mf-rf-single-field",t).attr("data-id",_),t.appendTo(e(".rf-repeaterResult"))})),e(".mf-btn-del-url-field").click((function(){e(this).parent(".mf-rf-single-field-input").remove()})),function(t){var i=e("#metform-form-modalinput-settings").attr("data-nonce"),o=e(".get-response-campaign-list");e.ajax({url:window.metform_api.resturl+"metform/v1/entries/get_response_list/"+t,type:"get",headers:{"X-WP-Nonce":i},dataType:"json",success:function(e){o.empty(),e.length&&e.forEach((e=>{o.append("")}))},error:function(e){}})}(i),function(t){var i=e(".metfrom-btn-refresh-hubsopt-list");i.addClass("mf-setting-spin");var o=e("#metform-form-modalinput-settings").attr("data-nonce"),s=e(".hubspot_forms"),a=e("#mf-hubsopt-fileds"),n=t;e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_hubspot_forms/"+n,type:"get",headers:{"X-WP-Nonce":o},dataType:"json",beforeSend:function(t){e(a).text("Please wait....")},success:function(t){if(Array.isArray(t)){var i=e(".mf_hubspot_form_guid").val();try{s.empty(),s.append(''),t.forEach((e=>{var t="";e.guid===i&&(t='selected="selected"'),s.append("")}))}catch(o){}}else s.empty(),s.append('')},error:function(e){console.log(e)},complete:function(t){i.removeClass("mf-setting-spin"),e(a).text("")}})}(i),function(t,i){var o=e(".mf_hubspot_form_guid").val(),s=e("#metform-form-modalinput-settings").attr("data-nonce");if(e("#mf-hubsopt-fileds").html("Please wait...."),"1"!==i.mf_hubspot_forms)return!1;e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+t,type:"get",headers:{"X-WP-Nonce":s},dataType:"json",success:function(a){e.ajax({url:window.metform_api.resturl+"metform/v1/forms/hubspot_form_fields/"+t,type:"post",headers:{"X-WP-Nonce":s},dataType:"json",data:{guid:o},success:function(t){var o="",s="mf_hubspot_form_field_name_";t.forEach((e=>{var t=s+e.name;if(t in i){var n="";for(const e in a){var r="";i[t]===a[e].mf_input_name&&(r='selected="selected"'),n+=``}o+=""+e.label+""}})),e("#mf-hubsopt-fileds").html(''+o+"
")},error:function(t){401===t?.responseJSON?.code?(e("#mf-hubsopt-fileds").html("Please connect your HubSpot account."),e(".hubspot_forms").empty()):e("#mf-hubsopt-fileds").html("Please click the button to fetch forms and then select a form from the list.")}})},error:function(t){e("#mf-hubsopt-fileds").html("Sorry ! Something went wrong")}})}(i,m),function(t){e("#metform_form_modal");var i,o=e("#metform-form-modalinput-settings").attr("data-nonce"),s=e(".mailchimp_list");i=t,e.ajax({url:window.metform_api.resturl+"metform/v1/entries/get_mailchimp_list/"+i,type:"get",headers:{"X-WP-Nonce":o},dataType:"json",success:function(t){try{s.empty(),t.lists.forEach((e=>{s.append("")})),1===t.lists.length?e(".mf-mailchimp-list-id").attr("value",t.lists[0].id):(r(),e(".mailchimp_list").on("change",(t=>{e(".mf-mailchimp-list-id").attr("value",t.target.value)})))}catch(i){}},error:function(e){}})}(i),function(t,i){let o=e("#mf-aweber-fields"),s=e("option:selected",this).val();if(!s)return void o.html("");o.html("Please wait....");let a=e("#metform-form-modalinput-settings").attr("data-nonce"),n="";e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+t,type:"get",headers:{"X-WP-Nonce":a},dataType:"json",success:function(r){n=r;let m=metform_api.admin_url+"admin-ajax.php",l={action:"get_aweber_custom_fields",selectedValue:s,formId:t,nonce:a};e.ajax({url:m,type:"post",data:l,headers:{"X-WP-Nonce":a},dataType:"json",success:function(e){let t=e.data;if("ok"===t.result)if(t.custom_fields.error)o.html("");else{let e,s="",a=Object.keys(n).map((function(e){return[n[e]]})),r="mf_aweber_custom_field_name_",m="mf_aweber_custom_field_label_";t.custom_fields.entries.forEach((t=>{let o;e="",a.map((s=>{o="";let a=i[r+t.id];a&&s[0].mf_input_name===a.field_key&&(o='selected="selected"'),e+=""})),s+=""+t.name+'"})),o.html(''+s+"
")}else o.html("")},error:function(e){o.html(""),console.log("Error: "+e)}})},error:function(t){e("#mf-aweber-fields").html("Sorry ! Something went wrong")}})}(i,m),o.find("form").attr("data-mf-id",i),o.find(".get-response-campaign-list").attr("get-response-list-id",i)}));var u=0;e(".mf-add-param_fields").click((function(){var t=e("#mf-cf-single-field-data-bypass").clone();u++,t.attr("id","mf-repeater-field-"+u),e(".mf-btn-del-singl-field",t).attr("data-id",u),t.appendTo(e("#paramFieldsrepeaterResult")),p(),setTimeout((()=>{c()}),10)}));let _=0;function h(e,t="",i=""){return'
\n
\n \n \n
\n
\n \n \n
\n Delete\n
'}e(".mf-add-zoho_fields").click((function(){var t=e("#mf-zoho-single-field").clone();_++,t.attr("id","mf-zoho-single-field"),e(".mf-btn-del-singl-field",t).attr("data-id",_),t.appendTo(e("#mf-zoho-all-form-fields")),p(),setTimeout((()=>{d()}),10)})),e("#metform-add-new-form-model__form-type").on("change",(function(){var t=this.value,i=e(this).attr("data-nonce"),o=e(this).parent(".metform-template-form-type").siblings(".metform-templates-list");e.ajax({url:window.metform_api.resturl+"metform/v1/forms/gel_form_templates/new?formtype="+t,type:"get",headers:{"X-WP-Nonce":i},dataType:"json",beforeSend:function(){o.css({opacity:"0.3","pointer-events":"none"})},success:function(e){o.find("li").not(":first").remove(),o.find("li").after(e),o.css({opacity:"1","pointer-events":"auto"})},error:function(e){console.log(e)}})})),e(".metform-form-save-btn-editor").on("click",(function(){e(".metform-form-save-btn-editor").attr("disabled",!0);var t=e("#metform-form-modalinput-settings");t.attr("data-open-editor","1"),t.trigger("submit")})),e("#metform-form-modalinput-settings").on("submit",(function(t){t.preventDefault();var i=e("#metform-form-modal"),o=e(this);i.addClass("loading"),e(".metform-form-save-btn-editor").attr("disabled",!0),e(".metform-form-save-btn").attr("disabled",!0),e("#rm-before-send").is(":hidden")&&jQuery("#rm-before-send").remove();var s=e(this).serialize(),a=e(this).attr("data-mf-id"),n=e(this).attr("data-open-editor"),r=e(this).attr("data-editor-url"),m=e(this).attr("data-nonce");e.ajax({url:window.metform_api.resturl+"metform/v1/forms/update/"+a,type:"post",data:s,headers:{"X-WP-Nonce":m},dataType:"json",success:function(t){e("#message").css("display","block"),1==t.saved?(e("#post-"+t.data.id).find(".row-title").html(t.data.title),e("#message").removeClass("attr-alert-warning").addClass("attr-alert-success").html(t.status)):e("#message").removeClass("attr-alert-success").addClass("attr-alert-warning").html(t.status),setTimeout((function(){e("#message").css("display","none"),o.find(".attr-close").trigger("click")}),1e3),i.removeClass("loading"),"1"==n&&1==t.saved?setTimeout((function(){window.location.href=r+"?post="+t.data.id+"&action=elementor"}),1e3):"0"!=a?(e(".metform-form-save-btn-editor").removeAttr("disabled"),e(".metform-form-save-btn").removeAttr("disabled")):"0"==a&&setTimeout((function(){location.reload()}),1e3)}})}));var v=e(".mf-entry-title"),g=e(".mf-form-user-confirmation"),b=e(".mf-form-redirect-confirmation"),y=e(".mf-form-admin-notification"),k=e(".mf-input-rest-api-group"),w=e(".mf-mailchimp"),j=e(".mf-get_response"),x=e(".mf-zapier"),T=e(".mf-slack"),C=e(".mf-fluent"),A=e(".mf-sms"),z=e(".mf-sms-user"),P=e(".mf-sms-admin"),N=e(".mf-form-modalinput-sms"),W=e(".mf-form-modalinput-sms-user"),S=e(".mf-form-modalinput-sms-admin"),X=e(".mf-paypal"),E=e(".mf-stripe"),Q=e(".mf-ckit"),O=e(".mf-aweber"),D=e(".mf-mail-poet"),I=e(".mf-form-email-verification");let $=".mf-active-campaign",F=e("input"+$),R=e("div"+$);var q=e(".mf-google-spreadsheets-selection-div");function U(t,i=null){var o=e("#metform-form-modalinput-settings").attr("data-nonce");e('.mf-mailster-list-id option[value="'+t+'"]').prop("selected",!0),e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+i,type:"get",headers:{"X-WP-Nonce":o},dataType:"json",success:function(o){var s=o,a="";Object.keys(s).map((function(e){return[s[e]]})).map((e=>{a+=""})),function(t,i,o){var s=e("#metform-form-modalinput-settings").attr("data-nonce");e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_mailster_form/"+t,type:"get",headers:{"X-WP-Nonce":s},dataType:"json",success:function(t){var s="";for(const[e,o]of Object.entries(t))if("fields"==e)for(const[e,t]of Object.entries(o))s+='
";e(".mf-mailster-settings-section").html(s),function(t,i){var o=window.mf_mailster_list_id;if(e(".mf-mailster-list-id").val()==o){var s=e("#metform-form-modalinput-settings").attr("data-nonce");e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_mailster_form_data/"+i,type:"get",headers:{"X-WP-Nonce":s},dataType:"json",success:function(t){for(const[i,o]of Object.entries(t))for(const[t,i]of Object.entries(o))e("#"+t+' option[value="'+i+'"]').prop("selected",!0)},error:function(e){}})}}(0,o)},error:function(e){}})}(t,a,i)},error:function(e){}})}function L(t,i){if(v.hide(),g.hide(),y.hide(),b.hide(),k.hide(),w.hide(),x.hide(),T.hide(),X.hide(),E.hide(),Q.hide(),O.hide(),D.hide(),q.hide(),""!=t.form_title){e(".mf-form-modalinput-title").val(t.form_title),e(".mf-form-modalinput-success_message").val(t.success_message),e(".mf-entry-title-input").val("undefined"!=typeof t.entry_title&&""!=t.entry_title?t.entry_title:"undefined"==typeof t.entry_title||""==t.entry_title?"Entry # [mf_id]":""),e(".mf-form-modalinput-redirect_to").val(t.redirect_to),e(".mf-form-modalinput-success_url").val(t.success_url),e(".mf-form-modalinput-failed_cancel_url").val(t.failed_cancel_url),e(".mf-form-modalinput-limit_total_entries").val(t.limit_total_entries),e(".mf-form-email-verification-email-subject").val(t.email_verification_email_subject),e(".mf-form-email-verification-email-redirect").val(t.email_verification_confirm_redirect),e(".mf-form-email-verification-heading").val(t.email_verification_heading),e(".mf-form-email-verification-paragraph").val(t.email_verification_paragraph);let i=e(".mf-form-email-verification-enable");"1"==t.email_verification_enable?(i.attr("checked",!0),I.show()):(i.removeAttr("checked"),I.hide());let k=e(".mf_automizy_list_id");k&&k.val(t.mf_automizy_list_id);var o=e(".mf-form-modalinput-store_entries");"1"==t.store_entries?(o.attr("checked",!0),v.show()):(o.removeAttr("checked"),v.hide());var s=e(".mf-form-modalinput-hide_form_after_submission");"1"==t.hide_form_after_submission?s.attr("checked",!0):s.removeAttr("checked");var m=e(".mf-form-modalinput-require_login");"1"==t.require_login?m.attr("checked",!0):m.removeAttr("checked");var l=e(".mf-form-modalinput-quiz_result_show");"1"==t.quiz_summery?l.attr("checked",!0):l.removeAttr("checked");var f=e(".mf-form-modalinput-limit_status");"1"==t.limit_total_entries_status?f.attr("checked",!0):f.removeAttr("checked");var c=e(".mf-form-modalinput-count_views");"1"==t.count_views?c.attr("checked",!0):c.removeAttr("checked");var d=e(".mf-form-modalinput-stop_vertical_scrolling");"1"==t.mf_stop_vertical_scrolling?d.attr("checked",!0):d.removeAttr("checked");var p=e(".mf-form-modalinput-multiple_submission");"1"==t.multiple_submission?p.attr("checked",!0):p.removeAttr("checked");var u=e(".mf-form-modalinput-enable_recaptcha");"1"==t.enable_recaptcha?u.attr("checked",!0):u.removeAttr("checked");var _=e(".mf-form-modalinput-capture_user_browser_data");"1"==t.capture_user_browser_data?(_.attr("checked",!0),e("#multiple_submission").removeClass("hide_input"),e("#multiple_submission").addClass("show_input")):_.removeAttr("checked"),e(".mf-form-user-email-subject").val(t.user_email_subject),e(".mf-form-user-email-from").val(t.user_email_from),e(".mf-form-user-reply-to").val(t.user_email_reply_to),e(".mf-form-user-email-body").val(t.user_email_body);var h=e(".mf-form-user-enable");"1"==t.enable_user_notification?(h.attr("checked",!0),g.show()):(h.removeAttr("checked"),g.hide());var j=e(".mf-form-redirect-enable");"1"==t.enable_form_redirect_notification?(j.attr("checked",!0),b.show()):(j.removeAttr("checked"),b.hide());var $=e(".mf-form-user-submission-copy");"1"==t.user_email_attach_submission_copy?$.attr("checked",!0):$.removeAttr("checked"),e(".mf-form-admin-email-subject").val(t.admin_email_subject),e(".mf-form-admin-email-from").val(t.admin_email_from),e(".mf-form-admin-email-to").val(t.admin_email_to),e(".mf-form-admin-reply-to").val(t.admin_email_reply_to),e(".mf-form-admin-email-body").val(t.admin_email_body);var L=e(".mf-form-admin-enable");"1"==t.enable_admin_notification?(L.attr("checked",!0),y.show()):(L.removeAttr("checked"),y.hide());var G=e(".mf-form-admin-submission-copy");"1"==t.admin_email_attach_submission_copy?G.attr("checked",!0):G.removeAttr("checked");var J=e(".mf-form-modalinput-rest_api");"1"==t.mf_rest_api?(J.attr("checked",!0),e(".mf-rest-api").show()):(J.removeAttr("checked"),e(".mf-rest-api").hide());var M=e(".mf-form-modalinput-mail_chimp");"1"==t.mf_mail_chimp?(M.attr("checked",!0),w.show()):(M.removeAttr("checked"),w.hide());var V=e(".mf-form-modal_input-google_sheet");"1"==t.mf_google_sheet?(V.attr("checked",!0),q.show()):V.removeAttr("checked");let U=e(".mf-form-modalinput-ckit"),ue=e(".mf-form-modalinput-mail_aweber"),_e=e(".mf-form-modalinput-mail_poet");if("1"==t.mf_convert_kit?(U.attr("checked",!0),Q.show()):(U.removeAttr("checked"),Q.hide()),"1"==t.mf_mail_aweber?(ue.attr("checked",!0),O.show()):(ue.removeAttr("checked"),O.hide()),"1"==t.mf_mail_poet?(_e.attr("checked",!0),D.show()):(_e.removeAttr("checked"),D.hide()),t.ckit_opt){let i=e("select.mf-ckit-list-id").first(),o=t.mf_ckit_list_id||"";i.html(),t.ckit_opt.forEach((function(e){i.append('")})),i.val(o)}if(t.aweber_opt){let i=e("select.mf-aweber-list-id").first(),o=t.mf_aweber_list_id||"";i.html(i.find("option.mf_aweber_default_option").clone());for(let e in t.aweber_opt)i.append('");i.val(o)}if(t.mp_opt){let i=e("select.mf-mail-poet-list-id").first(),o=t.mf_mail_poet_list_id||"";i.html();for(let e in t.mp_opt)i.append('");i.val(o)}if("1"===t.mf_active_campaign){F.attr("checked",!0),R.show();let i=t.mf_active_campaign_list_id||"",o=t.mf_active_campaign_tag_id||"";e("select[name=mf_active_campaign_list_id]").val(i),e("select[name=mf_active_campaign_tag_id]").val(o)}else F.removeAttr("checked"),R.hide();var B=e(".mf-form-modalinput-get_response");"1"==t.mf_get_response?(B.attr("checked",!0),e(".mf-get_response").show()):(B.removeAttr("checked"),e(".mf-get_response").hide());var H=e(".mf-hubsopt");"1"==t.mf_hubspot?H.attr("checked",!0):H.removeAttr("checked");var K=e(".mf-hubspot-forms"),Z=e(".hubspot_forms_section");"1"==t.mf_hubspot_forms?(K.attr("checked",!0),Z.show()):(K.removeAttr("checked"),Z.hide()),e(".mf_hubspot_form_portalId").val(t.mf_hubspot_form_portalId),e(".mf_hubspot_form_guid").val(t.mf_hubspot_form_guid);var Y=e(".mf-zoho");"1"==t.mf_zoho?Y.attr("checked",!0):Y.removeAttr("checked");var ee=e(".mf-helpscout");"1"==t.mf_helpscout?(ee.attr("checked",!0),e(".helpscout_forms_section").show()):(ee.removeAttr("chekced"),e(".helpscout_forms_section").hide()),t.mf_helpscout_mailbox&&e('#mf_helpscout_mailbox option[value="'+t.mf_helpscout_mailbox+'"]').prop("selected",!0);var te=e(".mf-form-modalinput-mailster"),ie=e(".mf-mailster-settings-section");"1"==t.mf_mailster?(te.attr("checked",!0),ie.show(),e(".mf-mailster-forms").show()):(te.removeAttr("checked"),ie.hide(),e(".mf-mailster-forms").hide());var oe=e(".mf-register");1==t.mf_registration?(oe.attr("checked",!0),e(".mf_register_form_fields").show()):(oe.removeAttr("checked"),e(".mf_register_form_fields").hide());var se=e(".mf-login");1==t.mf_login?(se.attr("checked",!0),e(".mf_login_form_fields").show()):(e(".mf_login_form_fields").hide(),se.removeAttr("checked"));var ae=e(".mf-form-to-post"),ne=e(".mf-form-to-post-fields");1==t.mf_form_to_post?(ae.attr("checked",!0),ne.show()):(ae.removeAttr("checked"),ne.hide());var re=e(".mf-form-modalinput-zapier");"1"==t.mf_zapier?(re.attr("checked",!0),x.show()):(re.removeAttr("checked",!0),x.hide());var me=e(".mf-form-modalinput-slack");"1"==t.mf_slack?(me.attr("checked",!0),T.show()):(me.removeAttr("checked",!0),T.hide());var le=e(".mf-form-modalinput-fluent");if("1"==t.mf_fluent?(le.attr("checked",!0),C.show()):(le.removeAttr("checked",!0),C.hide()),"1"==t.mf_sms_user_status?(W.attr("checked",!0),z.show()):(W.removeAttr("checked",!0),z.hide()),"1"==t.mf_sms_admin_status?(S.attr("checked",!0),P.show()):(S.removeAttr("checked",!0),P.hide()),"1"==t.mf_sms_status?(N.attr("checked",!0),A.show()):(N.removeAttr("checked",!0),A.hide(),W.removeAttr("checked",!0),z.hide(),S.removeAttr("checked",!0),P.hide()),t.mf_payment_currency){e("select.mf_payment_currency").val(t.mf_payment_currency)}let he=e(".mf-form-modalinput-paypal");"1"==t.mf_paypal?(he.attr("checked",!0),X.show()):(he.removeAttr("checked",!0),X.hide());var fe=e(".mf-form-modalinput-stripe");"1"==t.mf_stripe?(fe.attr("checked",!0),E.show()):(fe.removeAttr("checked",!0),E.hide());fe=e(".mf-form-modalinput-stripe");"1"==t.mf_stripe?(fe.attr("checked",!0),E.show()):(fe.removeAttr("checked",!0),E.hide());var ce=e(".mf-form-modalinput-paypal_sandbox");"1"==t.mf_paypal_sandbox?ce.attr("checked",!0):ce.removeAttr("checked",!0);var de=e(".mf-form-modalinput-stripe_sandbox");"1"==t.mf_stripe_sandbox?de.attr("checked",!0):de.removeAttr("checked",!0);var pe=t.mf_rest_api_method&&t.mf_rest_api_method.length?t.mf_rest_api_method:"POST";e('.mf-rest-api-method option[value="'+pe+'"]').prop("selected",!0),e(".mf-rest-api-url").val(t.mf_rest_api_url),e(".mf-mailchimp-api-key").val(t.mf_mailchimp_api_key),e(".mf-mailchimp-list-id").val(t.mf_mailchimp_list_id),e(".mf-google-spreadsheets-list-id").val(t.mf_google_spreadsheets_list_id),e(".mf-google-sheets-list-id").val(t.mf_google_sheets_list_id),""==t.mf_google_spreadsheets_list_id&&e(".mf-google-spreadsheets-list-id").val(e(".mf-google-spreadsheets-list").find(":selected").val()),0!=t.mf_google_spreadsheets_list_id&&(a(),n(t.mf_google_spreadsheets_list_id),e('.mf-google-spreadsheets-list option[value="'+t.mf_google_spreadsheets_list_id+'"]').prop("selected",!0)),""==t.mf_google_sheets_list_id&&e(".mf-google-sheets-list-id").val(e(".mf-google-sheets-list").find(":selected").val()),0!=t.mf_google_sheets_list_id&&e('.mf-google-sheets-list option[value="'+t.mf_google_sheets_list_id+'"]').prop("selected",!0),""==t.mf_mailchimp_list_id&&e(".mf-mailchimp-list-id").val(e(".mailchimp_list").find(":selected").val()),0!=t.mf_mailchimp_list_id&&e('.mailchimp_list option[value="'+t.mf_get_response_list_id+'"]').prop("selected",!0),r(),e(".mf-get_response-list-id").val(t.mf_get_response_list_id),0!=t.mf_get_response_list_id&&e('.get-response-campaign-list option[value="'+t.mf_get_response_list_id+'"]').prop("selected",!0),e(".mf-zapier-web-hook").val(t.mf_zapier_webhook),e(".mf-slack-web-hook").val(t.mf_slack_webhook),e(".mf-fluent-web-hook").val(t.mf_fluent_webhook),e(".mf-sms-from").val(t.mf_sms_from),e(".mf-sms-twilio-account-sid").val(t.mf_sms_twilio_account_sid),e(".mf-sms-twilio-auth-token").val(t.mf_sms_twilio_auth_token),e(".mf-sms-user-body").val(t.mf_sms_user_body),e(".mf-sms-admin-body").val(t.mf_sms_admin_body),e(".mf-sms-admin-to").val(t.mf_sms_admin_to),e(".mf-paypal-email").val(t.mf_paypal_email),e(".mf-paypal-token").val(t.mf_paypal_token),e(".mf-stripe-image-url").val(t.mf_stripe_image_url),e(".mf-stripe-live-publishiable-key").val(t.mf_stripe_live_publishiable_key),e(".mf-stripe-live-secret-key").val(t.mf_stripe_live_secret_key),e(".mf-stripe-test-publishiable-key").val(t.mf_stripe_test_publishiable_key),e(".mf-stripe-test-secret-key").val(t.mf_stripe_test_secret_key),e(".mf-recaptcha-site-key").val(t.mf_recaptcha_site_key),e(".mf-recaptcha-secret-key").val(t.mf_recaptcha_secret_key),e("input.mf-form-modalinput-limit_status, .mf-form-modalinput-rest_api").trigger("change")}(window.mf_mailster_list_id=t.mf_mailster_list_id,e('.mf-mailster-list-id option[value="'+t.mf_mailster_list_id+'"]').prop("selected",!0),e(".mf-form-modalinput-mailster").length)&&U(e(".mf-mailster-list-id").find(":selected").val(),e("#metform_form_modal").find("form").attr("data-mf-id"))}e("input.mf-form-modalinput-store_entries").on("change",(function(){e(this).is(":checked")?v.show():e(this).is(":not(:checked)")&&v.hide()})),e("input.mf-form-modalinput-limit_status").on("change",(function(){e(this).is(":checked")?e("#limit_status").find("input").removeAttr("disabled"):e(this).is(":not(:checked)")&&e("#limit_status").find("input").attr("disabled","disabled")})),e("input.mf-form-user-enable").on("change",(function(){e(this).is(":checked")?g.show():e(this).is(":not(:checked)")&&g.hide()})),e("input.mf-form-redirect-enable").on("change",(function(){e(this).is(":checked")?(b.show(200),e("input.mf_redirect_params_status").val("true")):e(this).is(":not(:checked)")&&(b.hide(200),e("input.mf_redirect_params_status").val("false"))})),e("input.mf-form-admin-enable").on("change",(function(){e(this).is(":checked")?y.show():e(this).is(":not(:checked)")&&y.hide()})),e("input.mf-form-modalinput-rest_api").on("change",(function(){e(this).is(":checked")?k.show():e(this).is(":not(:checked)")&&k.hide()})),e("input.mf-form-modalinput-mail_chimp").on("change",(function(){e(this).is(":checked")?w.show():e(this).is(":not(:checked)")&&w.hide()})),e("input.mf-form-modal_input-google_sheet").on("change",(function(){e(this).is(":checked")?(q.show(),a()):e(this).is(":not(:checked)")&&q.hide()})),e(".mf-form-modalinput-get_response").on("change",(function(){e(this).is(":checked")?j.show():j.hide()})),e("input.mf-form-email-verification-enable").on("change",(function(){e(this).is(":checked")?I.show():e(this).is(":not(:checked)")&&I.hide()})),F.on("change",(function(){e(this).is(":checked")?R.show():R.hide()})),e("input.mf-form-modalinput-mail_aweber").on("change",(function(){e(this).is(":checked")?O.show():e(this).is(":not(:checked)")&&O.hide()})),e("input.mf-form-modalinput-mail_poet").on("change",(function(){e(this).is(":checked")?D.show():e(this).is(":not(:checked)")&&D.hide()})),e("input.mf-form-modalinput-ckit").on("change",(function(){e(this).is(":checked")?Q.show():e(this).is(":not(:checked)")&&Q.hide()})),e("input.mf-form-modalinput-zapier").on("change",(function(){e(this).is(":checked")?x.show():e(this).is(":not(:checked)")&&x.hide()})),e("input.mf-form-modalinput-slack").on("change",(function(){e(this).is(":checked")?T.show():e(this).is(":not(:checked)")&&T.hide()})),e("input.mf-form-modalinput-fluent").on("change",(function(){e(this).is(":checked")?C.show():e(this).is(":not(:checked)")&&C.hide()})),e("input.mf-form-modalinput-sms-user").on("change",(function(){e(this).is(":checked")?z.show():e(this).is(":not(:checked)")&&z.hide()})),e("input.mf-form-modalinput-sms-admin").on("change",(function(){e(this).is(":checked")?P.show():e(this).is(":not(:checked)")&&P.hide()})),e("input.mf-form-modalinput-sms").on("change",(function(){e(this).is(":checked")?A.show():e(this).is(":not(:checked)")&&(A.hide(),W.removeAttr("checked",!0),z.hide(),S.removeAttr("checked",!0),P.hide())})),e("input.mf-form-modalinput-paypal").on("change",(function(){e(this).is(":checked")?X.show():e(this).is(":not(:checked)")&&X.hide()})),e("input.mf-form-modalinput-stripe").on("change",(function(){e(this).is(":checked")?stripe.show():e(this).is(":not(:checked)")&&stripe.hide()})),e("input.mf-form-modalinput-stripe_sandbox").on("change",(function(){e(this).is(":checked")?e(".mf_stripe_sandbox").show():e(this).is(":not(:checked)")&&e(".mf_stripe_sandbox").hide()})),e(".mf-hubspot-forms").on("change",(function(){e(this).is(":checked")?e(".hubspot_forms_section").show():e(".hubspot_forms_section").hide()})),e(".mf-register").on("change",(function(){e(this).is(":checked")?e(".mf_register_form_fields").show():e(".mf_register_form_fields").hide()})),e(".mf-login").on("change",(function(){e(this).is(":checked")?e(".mf_login_form_fields").show():e(".mf_login_form_fields").hide()})),e(".mf-form-to-post").on("change",(function(){e(this).is(":checked")?e(".mf-form-to-post-fields").show():e(".mf-form-to-post-fields").hide()})),e(".mf-zoho").on("change",(function(){e(this).is(":checked")?e(".mf_zoho_forms_section").show():e(".mf_zoho_forms_section").hide()})),e(".mf-helpscout").on("change",(function(){e(this).is(":checked")?e(".helpscout_forms_section").show():e(".helpscout_forms_section").hide()})),e(".mf-form-modalinput-mailster").on("change",(function(){e(this).is(":checked")?(e(".mf-mailster-settings-section").show(),e(".mf-mailster-forms").show()):(e(".mf-mailster-settings-section").hide(),e(".mf-mailster-forms").hide())})),e(".mf-mailster-list-id").on("change",(function(){e(this).val(),e("#metform-form-modalinput-settings").attr("data-mf-id")})),e(".get-response-campaign-list").on("change",(function(){e(".mf-get_response-list-id ").val(e(this).val())})),e("input.mf-form-modalinput-capture_user_browser_data").click((function(){e(this).is(":checked")?(e("#multiple_submission").removeClass("hide_input"),e("#multiple_submission").addClass("show_input")):e(this).is(":not(:checked)")&&(e("#multiple_submission").removeClass("show_input"),e("#multiple_submission").addClass("hide_input"))})),e(".mf-settings-tab .mf-setting-nav-link").on("click",(function(t){if(!e(this).hasClass("mf-setting-nav-hidden")){t.preventDefault();var i=e(this).attr("href");window.location.hash=i,e(this).parent().addClass("nav-tab-active").siblings().removeClass("nav-tab-active"),e(i).addClass("active").siblings().removeClass("active")}})),e(".mf-setting-nav-link").on("click",(function(t){e(this).hasClass("mf-setting-nav-hidden")?t.preventDefault():(e(this).parents(".nav-tab-wrapper").find("a").removeClass("top").removeClass("bottom"),e(this).parents("li").prev().find("a").addClass("top"),e(this).parents("li").next().find("a").addClass("bottom"))}));var G=e(".mf-settings-tab .mf-setting-nav-link").eq(1).attr("href");if(window.location.hash&&(G=window.location.hash),e('.mf-settings-tab .mf-setting-nav-link[href="'+G+'"]').trigger("click"),e(window).on("resize.mfSettings",(function(){e(".mf-setting-sidebar").css("width",e(".mf-setting-sidebar-column").width())})).trigger("resize.mfSettings"),e(".mf-setting-header").length>0){var J=e(".mf-setting-header").offset().top;e(window).scroll((function(){var t=e(".mf-setting-header");e(window).scrollTop()>=J?t.addClass("fixed").css({width:jQuery(".metform-admin-container").width()}):t.removeClass("fixed").css({width:"auto"})}))}function M(){return e("#metform-form-modalinput-settings").attr("data-nonce")}function V(){return e("#mf_wp_rest_nonce").val()}let B;e(".mf-admin-single-accordion").on("click",".mf-admin-single-accordion--heading",(function(){e(this).next().slideToggle().parent().toggleClass("active").siblings().removeClass("active").find(".mf-admin-single-accordion--body").slideUp()})),e(".mf-admin-single-accordion:first-child .mf-admin-single-accordion--heading").trigger("click"),e(".mf-recaptcha-version").on("change",(function(){var t=e(this).val();e("#mf-"+t).fadeIn().siblings().hide()})),e(".mf-recaptcha-version").trigger("change"),e(".mf-form-modalinput-stripe_sandbox").on("change",(function(){var t=e(this).parents(".attr-form-group").eq(0).next(".mf-form-modalinput-stripe_sandbox_keys");e(this).is(":checked")?t.fadeIn():t.fadeOut()})),e(".mf-form-modalinput-stripe_sandbox").trigger("change"),e(document).on("click","#met_pro_aweber_authorize",(function(t){t.preventDefault();let i=e(this).closest("p.description");i.html("Wait....");var o=metform_api.admin_url+"admin-ajax.php",s={action:"get_aweber_authorization_url",api_key:e("#mf_aweber_dev_api_key").val(),api_sec:e("#mf_aweber_dev_api_sec").val()};e.ajax({url:o,method:"POST",data:s,headers:{"X-WP-Nonce":V()},dataType:"json",success:function(e){if(!0===e.success){let t='Authorize The App ';i.html(t)}else if(e.data){let t=e.data;i.html(''+t.msg+"")}},error:function(e){i.html(' ajax error occurred, please check your internet connection..')},complete:function(){}})})),e(document).on("click","#met_pro_aweber_propmpt_re_auth",(function(t){t.preventDefault(),e("#mf_aweber_dev_api_key").val("").prop("disabled",!1),e("#mf_aweber_dev_api_sec").val("").prop("disabled",!1),e(this).closest("p.description").html(' Get Re - Authorization URL ')})),e(document).on("click","#met_pro_aweber_re_authorize",(function(t){t.preventDefault();let i=e(this).closest("p.description");i.html("Wait....");let o=e("#mf_aweber_dev_api_key").val();if(!o||o.length<1)return i.html('API Key can not be empty..'),!1;var s=metform_api.admin_url+"admin-ajax.php",a={action:"get_aweber_re_authorization_url",api_key:o,api_sec:e("#mf_aweber_dev_api_sec").val()};e.ajax({url:s,method:"POST",data:a,headers:{"X-WP-Nonce":V()},dataType:"json",success:function(e){if(!0===e.success){let t=e.data;if("ok"==t.result){let e='Authorize The App ';i.html(e)}else i.html(""+t.msg+"")}else if(e.data){let t=e.data;i.html(''+t.msg+"")}},error:function(e){i.html(' ajax error occurred, please check your internet connection..')},complete:function(){}})})),e(document).on("click","#met_form_aweber_get_list",(function(t){t.preventDefault();let i=e(this),o=e("#mf_aweber_info"),s=metform_api.admin_url+"admin-ajax.php";e.ajax({url:s,method:"POST",data:{action:"get_list_lists"},headers:{"X-WP-Nonce":M()},dataType:"json",beforeSend:function(){o.html('Loading')},success:function(e){if(!0===e.success){let t=e.data,s=i.parent(".mf-input-help").siblings("select.mf-aweber-list-id"),a=s.find("option.mf_aweber_default_option").clone();if(s.html(a),t.lists)for(let e in t.lists)s.append('");o.html(""),i.parent(".mf-input-help").siblings("#mf-aweber-fields").html("")}else if(e.data){let t=e.data;o.html(''+t.msg+"")}},error:function(e){o.html(' ajax error occurred, please check your internet connection..')},complete:function(){}})})),e(".mf-aweber-list-id").on("change",(function(){let t=e("#mf-aweber-fields"),i=e("option:selected",this).val();if(!i)return void t.html("");t.html("Please wait....");let o=e("#metform-form-modalinput-settings").attr("data-nonce"),a=e("#metform_form_modal").find("form").attr("data-mf-id"),n="";e.ajax({url:window.metform_api.resturl+"metform/v1/forms/get_fields_data/"+a,type:"get",headers:{"X-WP-Nonce":o},dataType:"json",success:function(r){n=r;let m=metform_api.admin_url+"admin-ajax.php",l={action:"get_aweber_custom_fields",selectedValue:i,formId:a,nonce:o};e.ajax({url:m,type:"post",data:l,headers:{"X-WP-Nonce":o},dataType:"json",success:function(e){let i=e.data;if("ok"===i.result&&i.custom_fields){let e,o="",a=Object.keys(n).map((function(e){return[n[e]]})),r="mf_aweber_custom_field_name_",m="mf_aweber_custom_field_label_";i.custom_fields.entries.forEach((t=>{let i;e="",a.map((o=>{i="",o[0].mf_input_name===s[r+t.id]&&(i='selected="selected"'),e+=""})),o+=""+t.name+'"})),t.html(''+o+"
")}},error:function(e){console.log("Error: "+e)}})},error:function(t){e("#mf-aweber-fields").html("Sorry ! Something went wrong")}})})),e(document).on("click","#met_form_mail_poet_get_list",(function(t){t.preventDefault();let i=e(this),o=e("#mf_mail_poet_info"),s=metform_api.admin_url+"admin-ajax.php";e.ajax({url:s,method:"POST",data:{action:"mail_poet_get_email_list_lists"},headers:{"X-WP-Nonce":M()},dataType:"json",success:function(e){if(!0===e.success){let t=e.data,s=i.closest("div.mf-mail-poet").find("select");if(s.html(""),t.lists)for(let e in t.lists)s.append('");o.html("")}else if(e.data){let t=e.data;o.html(''+t.msg+"")}},error:function(e){o.html(' ajax error occurred, please check your internet connection..')},complete:function(){}})})),e(document).on("click","#met_form_ckit_get_list",(function(t){t.preventDefault();var i=metform_api.admin_url+"admin-ajax.php";let o=e(this);e.ajax({url:i,method:"POST",data:{action:"get_form_lists"},headers:{"X-WP-Nonce":M()},dataType:"json",success:function(e){if(!0===e.success){let t=e.data,i=o.closest("div.mf-ckit").find("select");i.html(""),t.forms&&t.forms.forEach((function(e){i.append('")}))}else alert("Error occurred when trying to check for aweber authorization.")},error:function(e){},complete:function(){}})})),e(document).on("click","#met_form_act_camp_get_list",(function(t){t.preventDefault();let i=window.metform_api.resturl+"metform-pro/v1/active-campaign/email_lists",o=M(),s=e(this),a=e("#mf_act_camp_info");e.ajax({url:i,method:"GET",data:[],headers:{"X-WP-Nonce":o},dataType:"json",success:function(e){if(!0===e.success){let t=e.data,i=s.closest("div.mf-input-group").find("select");i.html(""),t.list&&t.list.forEach((function(e){i.append('")})),a.html(e.data.msg)}else a.html(e.data.msg)},error:function(e){a.html(' ajax error occurred, please check your internet connection..')},complete:function(){}})})),e(document).on("click","#met_form_act_camp_get_tags",(function(t){t.preventDefault();let i=window.metform_api.resturl+"metform-pro/v1/active-campaign/tag_lists",o=M(),s=e(this),a=e("#mf_act_camp_tag_info");e.ajax({url:i,method:"GET",data:[],headers:{"X-WP-Nonce":o},dataType:"json",success:function(e){if(!0===e.success){let t=e.data,i=s.closest("div.mf-input-group").find("select");i.html(""),t.list&&t.list.forEach((function(e){i.append('")})),a.html(e.data.msg)}else a.html(e.data.msg)},error:function(e){a.html(' ajax error occurred, please check your internet connection..')},complete:function(){}})})),e("#mf-helpscout-btn-token").click((function(){let t=window.metform_api.resturl+"metform/v1/forms/get_helpscout_access_token/123";e.ajax({url:t,type:"get",headers:{"X-WP-Nonce":V()},success:function(e){200==e.status&&location.reload()},error:function(e){alert("Something went wrong")}})}));let H=[]}));