(()=>{"use strict";(function(){const t=function(t,e){return function(){return t.apply(e,arguments)}};jQuery(document).ready(function(e){return window.Square_Payment_Methods_Handler=function(){function n(n){var i;this.cancel_edit=t(this.cancel_edit,this),this.save_method=t(this.save_method,this),this.edit_method=t(this.edit_method,this),this.id=n.id,this.slug=n.slug,this.i18n=n.i18n,this.ajax_url=n.ajax_url,this.ajax_nonce=n.ajax_nonce,n.has_core_tokens||e(".wc-"+this.slug+"-my-payment-methods").prev(".woocommerce-Message.woocommerce-Message--info").hide(),e(".wc-"+this.slug+"-payment-method-actions .button.tip").tipTip(),e(".wc-"+this.slug+"-my-payment-methods").on("click",".wc-"+this.slug+"-payment-method-actions .edit-payment-method",(i=this,function(t){return i.edit_method(t)})),e(".wc-"+this.slug+"-my-payment-methods").on("click",".wc-"+this.slug+"-payment-method-actions .save-payment-method",function(t){return function(e){return t.save_method(e)}}(this)),e(".wc-"+this.slug+"-my-payment-methods").on("click",".wc-"+this.slug+"-payment-method-actions .cancel-edit-payment-method",function(t){return function(e){return t.cancel_edit(e)}}(this)),e(".wc-"+this.slug+"-my-payment-methods").on("click",".wc-"+this.slug+"-payment-method-actions .delete-payment-method",function(t){return function(n){if(e(n.currentTarget).hasClass("disabled")||!confirm(t.i18n.delete_ays))return n.preventDefault()}}(this)),e('.button[href*="add-payment-method"]').click(function(t){if(e(this).hasClass("disabled"))return t.preventDefault()})}return n.prototype.edit_method=function(t){let n,i;return t.preventDefault(),n=e(t.currentTarget),i=n.parents("tr"),i.find(".view").hide(),i.find(".edit").show(),i.addClass("editing"),n.text(this.i18n.cancel_button).removeClass("edit-payment-method").addClass("cancel-edit-payment-method").removeClass("button"),n.siblings(".save-payment-method").show(),n.siblings(".delete-payment-method").hide(),this.enable_editing_ui()},n.prototype.save_method=function(t){let n,i,s;return t.preventDefault(),n=e(t.currentTarget),s=n.parents("tr"),this.block_ui(),s.next(".error").remove(),i={action:"wc_"+this.id+"_save_payment_method",nonce:this.ajax_nonce,token_id:s.data("token-id"),data:s.find("input[name]").serialize()},e.post(this.ajax_url,i).done((a=this,function(t){return t.success?(t.data.is_default&&s.siblings().find(".wc-"+a.slug+"-payment-method-default .view").empty().siblings(".edit").find("input").prop("checked",!1),null!=t.data.html&&s.replaceWith(t.data.html),null!=t.data.nonce&&(a.ajax_nonce=t.data.nonce),a.disable_editing_ui()):a.display_error(s,t.data)})).fail(function(t){return function(e,n,i){return t.display_error(s,i)}}(this)).always(function(t){return function(){return t.unblock_ui()}}(this));var a},n.prototype.cancel_edit=function(t){let n,i;return t.preventDefault(),n=e(t.currentTarget),i=n.parents("tr"),i.find(".view").show(),i.find(".edit").hide(),i.removeClass("editing"),n.removeClass("cancel-edit-payment-method").addClass("edit-payment-method").text(this.i18n.edit_button).addClass("button"),n.siblings(".save-payment-method").hide(),n.siblings(".delete-payment-method").show(),this.disable_editing_ui()},n.prototype.enable_editing_ui=function(){return e(".wc-"+this.slug+"-my-payment-methods").addClass("editing"),e('.button[href*="add-payment-method"]').addClass("disabled")},n.prototype.disable_editing_ui=function(){return e(".wc-"+this.slug+"-my-payment-methods").removeClass("editing"),e('.button[href*="add-payment-method"]').removeClass("disabled")},n.prototype.block_ui=function(){return e(".wc-"+this.slug+"-my-payment-methods").parent("div").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},n.prototype.unblock_ui=function(){return e(".wc-"+this.slug+"-my-payment-methods").parent("div").unblock()},n.prototype.display_error=function(t,n,i){let s;return null==i&&(i=""),console.error(n),i||(i=this.i18n.save_error),s=e(".wc-"+this.slug+"-my-payment-methods thead tr th").size(),e('<tr class="error"><td colspan="'+s+'">'+i+"</td></tr>").insertAfter(t).find("td").delay(8e3).slideUp(200)},n}()})}).call(void 0)})();