jQuery(document).ready(function(e){var r=e(".fluentcrm_public_pref_form");r.length&&(r.find("input[name=reason]").on("change",function(){"other"===r.find("input[name=reason]:checked").val()?r.find("#fluentcrm_other_reason_wrapper").show():r.find("#fluentcrm_other_reason_wrapper").hide()}),r.on("submit",function(r){r.preventDefault();var s=e(this).serialize();e(".fluentcrm_form_responses").html(""),e.post(window.fluentcrm_public_pref.ajaxurl,s).then(r=>{e(".fluentcrm_un_form_wrapper").html('<div class="fluentcrm_success">'+r.data.message+"</div>"),r.data.redirect_url&&(window.location.href=r.data.redirect_url)}).fail(r=>{let s="Sorry! Something is wrong. Please try again";r.responseJSON&&r.responseJSON.data&&r.responseJSON.data.message&&(s=r.responseJSON.data.message),e(".fluentcrm_form_responses").html('<div class="fluentcrm_error">'+s+"</div>")}).always(()=>{})}),"yes"==window.fluentcrm_public_pref.auto_unsubscribe&&setTimeout(function(){e("#fluentcrm_unsubscribe_submit").click()},500));var s=e("#pref_unsubscribe");if(s.length){var a=!1;s.on("click",function(r){if(r.preventDefault(),!a){a=!0,s.css("pointer-events","none").attr("aria-disabled","true");var n={action:"fluentcrm_unsubscribe_ajax",secure_hash:e("#fluentcrm_preferences_form").find('input[name="_secure_hash"]').val()};e(".fluentcrm_form_responses").html(""),e.post(window.fluentcrm_public_pref.ajaxurl,n).then(r=>{e(".fc_manage_sub_form").html('<div class="fluentcrm_success">'+r.data.message+"</div>"),r.data.redirect_url&&(window.location.href=r.data.redirect_url)}).fail(r=>{let s="Sorry! Something went wrong. Please try again";r.responseJSON&&r.responseJSON.data&&r.responseJSON.data.message&&(s=r.responseJSON.data.message),e(".fluentcrm_form_responses").html('<div class="fluentcrm_error">'+s+"</div>")}).always(()=>{a=!1,s.css("pointer-events","").removeAttr("aria-disabled")})}})}var n=e("#fc_pref_form");n.length&&n.on("submit",function(r){r.preventDefault();var s=e(this).serialize(),a=e("#fluentcrm_preferences_submit");e(".fluentcrm_form_responses").html(""),a.attr("disabled",!0).addClass("fc_btn_loading"),e.post(window.fluentcrm_sub_pref.ajaxurl,s).then(r=>{e(".fluentcrm_form_responses").html('<div class="fluentcrm_success">'+r.data.message+"</div>")}).fail(r=>{let s="Sorry! Something is wrong. Please try again";r.responseJSON&&r.responseJSON.data&&r.responseJSON.data.message&&(s=r.responseJSON.data.message),e(".fluentcrm_form_responses").html('<div class="fluentcrm_error">'+s+"</div>")}).always(()=>{a.attr("disabled",!1).removeClass("fc_btn_loading")})})});
