!function(e){"use strict";window.wc=window.wc||{},window.wc.customPlaceOrderButton=window.wc.customPlaceOrderButton||{},function(){var e="wc-custom-place-order-button-styles";if(!document.getElementById(e)){var t=document.createElement("style");t.id=e,t.textContent="form.has-custom-place-order-button #place_order { display: none !important; }",document.head.appendChild(t)}}();var t={},o=null,r=null;function n(){return e("form.checkout").length?e("form.checkout").first():e("#order_review").length?e("#order_review").first():e("#add_payment_method").length?e("#add_payment_method").first():e([])}function c(e){return-1!==("undefined"!=typeof wc_checkout_params&&wc_checkout_params.gateways_with_custom_place_order_button?wc_checkout_params.gateways_with_custom_place_order_button:"undefined"!=typeof wc_add_payment_method_params&&wc_add_payment_method_params.gateways_with_custom_place_order_button?wc_add_payment_method_params.gateways_with_custom_place_order_button:[]).indexOf(e)}function a(){r&&r.length&&(r.remove(),r=null)}window.wc.customPlaceOrderButton.register=function(o,r){t[o]||("string"==typeof o&&o?"object"==typeof r&&null!==r?"function"==typeof r.render?"function"==typeof r.cleanup?(t[o]=r,n().find('input[name="payment_method"]:checked').val()===o&&e(document.body).trigger("wc_custom_place_order_button_registered",[o])):console.error("wc.customPlaceOrderButton.register: cleanup must be a function"):console.error("wc.customPlaceOrderButton.register: render must be a function"):console.error("wc.customPlaceOrderButton.register: config must be an object"):console.error("wc.customPlaceOrderButton.register: gatewayId must be a non-empty string"))},window.wc.customPlaceOrderButton.__maybeShow=function(u,d){var s=n();if(o&&t[o])try{t[o].cleanup()}catch(i){console.error("Error in custom place order button cleanup:",i)}if(Boolean(t[u])){s.addClass("has-custom-place-order-button"),o=u;var l=function(){if(r&&r.length&&e.contains(document,r[0]))return r;var t=n().find("#place_order");return t.length?(r=e('
'),t.after(r),r):e([])}();l.empty();try{t[u].render(l.get(0),d)}catch(i){console.error("Error rendering custom place order button:",i)}}else c(u)||s.removeClass("has-custom-place-order-button"),o=null,a()},window.wc.customPlaceOrderButton.__maybeHideDefaultButtonOnInit=function(e){c(e)&&n().addClass("has-custom-place-order-button")},window.wc.customPlaceOrderButton.__cleanup=function(){if(o&&t[o])try{t[o].cleanup()}catch(e){console.error("Error in custom place order button cleanup:",e)}a(),o=null},window.wc.customPlaceOrderButton.__getForm=n}(jQuery);