(function(){jQuery(function(e){return window.SV_WC_Payment_Methods_Handler_v5_15_10=class{constructor(t){this.replace_method_column=this.replace_method_column.bind(this),this.remove_duplicate_default_marks=this.remove_duplicate_default_marks.bind(this),this.edit_method=this.edit_method.bind(this),this.save_method=this.save_method.bind(this),this.cancel_edit=this.cancel_edit.bind(this),this.id=t.id,this.slug=t.slug,this.i18n=t.i18n,this.ajax_url=t.ajax_url,this.ajax_nonce=t.ajax_nonce,this.replace_method_column(),this.remove_duplicate_default_marks(),e(".woocommerce-MyAccount-paymentMethods").on("click",".woocommerce-PaymentMethod--actions .button.edit",e=>this.edit_method(e)),e(".woocommerce-MyAccount-paymentMethods").on("click",".woocommerce-PaymentMethod--actions .button.save",e=>this.save_method(e)),e(".woocommerce-MyAccount-paymentMethods").on("click",".woocommerce-PaymentMethod--actions .cancel-edit",e=>this.cancel_edit(e)),e(".woocommerce-MyAccount-paymentMethods").on("click",".woocommerce-PaymentMethod--actions .button.delete",t=>{if(0!==e(t.currentTarget).parents("tr").find(`input[name=plugin-id][value=${this.slug}]`).length&&!confirm(this.i18n.delete_ays))return t.preventDefault()}),e('.button[href*="add-payment-method"]').on("click",event(function(){if(e(this).hasClass("disabled"))return event.preventDefault()}))}replace_method_column(){return e(".woocommerce-MyAccount-paymentMethods").find("tr").each((t,n)=>{var i;if(0!==e(n).find(`input[name=plugin-id][value=${this.slug}]`).length)return e(n).find("th.woocommerce-PaymentMethod--title").remove(),(i=e(n).find("td.woocommerce-PaymentMethod--title")).children().length>0&&e(n).find("td.woocommerce-PaymentMethod--method").html(i.html()),e(n).find("td.woocommerce-PaymentMethod--title").remove()})}remove_duplicate_default_marks(){return e(".woocommerce-MyAccount-paymentMethods").find("tr").each((t,n)=>e(n).find("td.woocommerce-PaymentMethod--default").find("mark.default:not(:first-child)").remove())}edit_method(t){var n,i;if(t.preventDefault(),0!==(i=(n=e(t.currentTarget)).parents("tr")).find(`input[name=plugin-id][value=${this.slug}]`).length)return i.find("div.view").hide(),i.find("div.edit").show(),i.addClass("editing"),n.text(this.i18n.cancel_button).removeClass("edit").addClass("cancel-edit").removeClass("button"),this.enable_editing_ui()}save_method(t){var n,i,o;if(t.preventDefault(),0!==(o=(n=e(t.currentTarget)).parents("tr")).find(`input[name=plugin-id][value=${this.slug}]`).length)return this.block_ui(),o.next(".error").remove(),i={action:`wc_${this.id}_save_payment_method`,nonce:this.ajax_nonce,token_id:o.find("input[name=token-id]").val(),data:o.find("input[name]").serialize()},e.post(this.ajax_url,i).done(e=>e.success?(null!=e.data.title&&o.find(".woocommerce-PaymentMethod--method").html(e.data.title),null!=e.data.nonce&&(this.ajax_nonce=e.data.nonce),n.siblings(".cancel-edit").removeClass("cancel-edit").addClass("edit").text(this.i18n.edit_button).addClass("button"),o.removeClass("editing"),this.disable_editing_ui()):this.display_error(o,e.data)).fail((e,t,n)=>this.display_error(o,n)).always(()=>this.unblock_ui())}cancel_edit(t){var n,i;if(t.preventDefault(),0!==(i=(n=e(t.currentTarget)).parents("tr")).find(`input[name=plugin-id][value=${this.slug}]`).length)return i.find("div.view").show(),i.find("div.edit").hide(),i.removeClass("editing"),n.removeClass("cancel-edit").addClass("edit").text(this.i18n.edit_button).addClass("button"),this.disable_editing_ui()}enable_editing_ui(){return e(".woocommerce-MyAccount-paymentMethods").addClass("editing"),e('.button[href*="add-payment-method"]').addClass("disabled")}disable_editing_ui(){return e(".woocommerce-MyAccount-paymentMethods").removeClass("editing"),e('.button[href*="add-payment-method"]').removeClass("disabled")}block_ui(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}unblock_ui(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").unblock()}display_error(t,n,i=""){var o;return console.error(n),i||(i=this.i18n.save_error),o=e(".woocommerce-MyAccount-paymentMethods thead tr th").length,e('<tr class="error"><td colspan="'+o+'">'+i+"</td></tr>").insertAfter(t).find("td").delay(8e3).slideUp(200)}},e(document.body).trigger("sv_wc_payment_methods_handler_v5_15_10_loaded")})}).call({});
//# sourceMappingURL=sv-wc-payment-gateway-my-payment-methods.js.map
