!function(t){"use strict";const i={init:function(){"undefined"!=typeof lbaicDeactivation&&(this.deactivateLink=t('tr[data-plugin="'+lbaicDeactivation.pluginBasename+'"] .deactivate a'),this.modal=t("#lbaic-deactivation-modal"),this.form=t("#lbaic-deactivation-form"),this.submitBtn=t("#lbaic-deactivation-submit"),this.skipBtn=t("#lbaic-deactivation-skip"),this.closeBtn=t(".lbaic-deactivation-modal-close"),this.deactivateUrl="",this.bindEvents())},bindEvents:function(){const i=this;this.deactivateLink.on("click",(function(e){e.preventDefault(),i.deactivateUrl=t(this).attr("href"),i.openModal()})),this.submitBtn.on("click",(function(t){t.preventDefault(),i.submitFeedback()})),this.skipBtn.on("click",(function(t){t.preventDefault(),i.submitFeedback(!0)})),this.closeBtn.on("click",(function(t){t.preventDefault(),i.closeModal()})),this.form.on("change",'input[name="lbaic_deactivation_reason"]',(function(){const e=t(this).val(),a=i.form.find('textarea[name="lbaic_deactivation_reason_other"]');"other"===e?a.show():a.hide()})),this.modal.on("click",(function(e){t(e.target).hasClass("lbaic-deactivation-modal-overlay")&&i.closeModal()})),t(document).on("keyup",(function(t){"Escape"===t.key&&i.modal.is(":visible")&&i.closeModal()}))},openModal:function(){this.modal.show(),this.form.find('input[type="radio"]').prop("checked",!1),this.form.find("textarea").hide().val("")},closeModal:function(){this.modal.hide()},submitFeedback:function(i=!1){const e=this;let a="no_reason",n="";if(!i){const t=this.form.find('input[name="lbaic_deactivation_reason"]:checked').val();t&&(a=t),"other"===a&&(n=this.form.find('textarea[name="lbaic_deactivation_reason_other"]').val())}const o={site_url:lbaicDeactivation.siteUrl,site_mode:lbaicDeactivation.siteMode,reason:a,additional_details:n,date:(new Date).toISOString()};this.submitBtn.prop("disabled",!0),this.skipBtn.prop("disabled",!0),this.submitBtn.addClass("updating-message"),t.ajax({url:lbaicDeactivation.restUrl+"plugin/deactivation",method:"POST",data:JSON.stringify(o),contentType:"application/json",beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",lbaicDeactivation.nonce)},timeout:5e3,complete:function(){window.location.href=e.deactivateUrl}})}};t(document).ready((function(){i.init()}))}(jQuery);