!function(){var t,e;t=jQuery,e={slug:"",skipButton:"",formWrapper:"",radioButton:"",closeButton:"",buttonAction:"",feedbackForm:"",feedbackInput:"",deactivateUrl:"",buttonTrigger:"",deactivateButton:"",submitDeactivate:"",_cacheElements:function(){var e;this.slug=(null===(e=scUdsVars)||void 0===e?void 0:e._plugin_slug)||"",this.skipButton=t(".uds-feedback-skip"),this.submitDeactivate=t(".uds-feedback-submit"),this.deactivateButton=t("#the-list").find(".row-actions span.deactivate a"),this.feedbackForm=t(".sc-feedback-form"),this.feedbackInput=t(".uds-options-feedback"),this.formWrapper=t(".uds-feedback-form--wrapper"),this.closeButton=t(".uds-feedback-form--wrapper .uds-close"),this.radioButton=t(".uds-reason-input")},_showPopup:function(e){t("#deactivation-survey-".concat(e)).addClass("show_popup")},_hidePopup:function(){this.formWrapper.removeClass("show_popup")},_redirectOrReload:function(){this.deactivateUrl?window.location.href=this.deactivateUrl:location.reload()},_hideShowFeedbackAndCTA:function(e){var a="true"===t(e.target).attr("data-accept_feedback"),i="true"===t(e.target).attr("data-show_cta");t(e.target).closest(this.formWrapper).find(".uds-options-feedback").removeClass("hide").addClass(a?"show":"hide"),t(e.target).closest(this.formWrapper).find(".uds-option-feedback-cta").removeClass("hide").addClass(i?"show":"hide")},_changePlaceholderText:function(e){var a=e.target.getAttribute("data-placeholder");t(e.target).closest(this.formWrapper).find(this.feedbackInput).attr("placeholder",a||""),this._hideShowFeedbackAndCTA(e)},_submitFeedback:function(e,a){var i,s;if(e.preventDefault(),"skip"!==this.buttonAction){var o=t(e.target),n=o.closest(this.feedbackForm),c={action:"sc_plugin_deactivate_feedback",security:(null===(i=scUdsVars)||void 0===i?void 0:i._ajax_nonce)||"",reason:n.find(this.radioButton.filter(":checked")).val()||"",source:n.find('input[name="source"]').val()||"",referer:n.find('input[name="referer"]').val()||"",version:n.find('input[name="version"]').val()||"",feedback:n.find(this.feedbackInput).val()||""};o.find(".uds-feedback-"+this.buttonAction).text("Deactivating.").addClass("processing"),t.ajax({url:null===(s=scUdsVars)||void 0===s?void 0:s.ajaxurl,type:"POST",data:c,success:function(t){t.success&&a._redirectOrReload(),a._hidePopup()},error:function(t,e,i){a._redirectOrReload()}})}else this._redirectOrReload()},_handleClick:function(t){if(t.target.classList.contains("show_popup")&&t.target.closest(".uds-feedback-form--wrapper"))this._hidePopup();else if(t.target.classList.contains("activate")){var e,a;if(this.deactivateUrl=t.target.href,-1!==this.deactivateUrl.indexOf("stylesheet=".concat(null===(e=scUdsVars)||void 0===e?void 0:e._current_theme,"-child")))return;t.preventDefault(),this._showPopup(null===(a=scUdsVars)||void 0===a?void 0:a._current_theme)}},_init:function(){this._cacheElements(),this._bind()},_bind:function(){var e=this;this.deactivateButton.on("click",(function(a){var i=t(a.target).closest("tr").data("slug");e.slug.includes(i)&&(a.preventDefault(),e.deactivateUrl=t(a.target).attr("href"),e._showPopup(i))})),this.closeButton.on("click",(function(t){t.preventDefault(),e._hidePopup()})),this.radioButton.on("click",(function(t){e._changePlaceholderText(t)})),this.submitDeactivate.add(this.skipButton).on("click",(function(a){a.preventDefault(),e.buttonAction=t(a.target).attr("data-action"),t(a.target).closest(e.feedbackForm).submit()})),this.feedbackForm.on("submit",(function(t){e._submitFeedback(t,e)})),document.addEventListener("click",(function(t){e._handleClick(t)}))}},t((function(){e._init()}))}();