PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
← All changes | assets/chunks/payment-loader.js +1 -1 1.3.21 → 1.6.5 View file →
@@ -1 +1 @@
1 -var U=Object.defineProperty;var E=c=>{throw TypeError(c)};var N=(c,t,e)=>t in c?U(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var C=(c,t,e)=>N(c,typeof t!="symbol"?t+"":t,e),B=(c,t,e)=>t.has(c)||E("Cannot "+e);var n=(c,t,e)=>(B(c,t,"read from private field"),e?e.call(c):t.get(c)),m=(c,t,e)=>t.has(c)?E("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,e),y=(c,t,e,o)=>(B(c,t,"write to private field"),o?o.call(c,e):t.set(c,e),e);const w=class w{static handleFragments(t){let e=!1;t.forEach(o=>{const a=document.querySelector(o.selector);a&&(o.selector&&o.type==="replace"&&(e=!0),o.type==="replace"?a.innerHTML=o.content:a.insertAdjacentHTML("beforeend",o.content))}),e&&setTimeout(()=>{window.dispatchEvent(new CustomEvent("fluentCartFragmentsReplaced",{detail:{selectors:t.filter(o=>o.type==="replace").map(o=>o.selector)}}))},10),window.dispatchEvent(new CustomEvent("fluentCartNotifySummaryViewUpdated"))}static handleSummaryViewUpdated(){fetch(w.buildUrl(`${window.fluentcart_checkout_vars.ajaxurl}?action=fluent_cart_checkout_routes&fc_checkout_action=get_checkout_summary_view`).toString(),{headers:{"X-WP-Nonce":window.fluentCartRestVars.rest.nonce},credentials:"include"}).then(t=>t.json()).then(t=>{this.handleFragments(t.fragments),window.dispatchEvent(new CustomEvent("fluentCartCheckoutDataChanged",{detail:{response:t}}))}).catch(t=>{console.error("Error rendering checkout summary:",t)})}static getParams(){var i,s;const t=new URLSearchParams(window.location.search),e={};window.fluentcart_checkout_vars.is_instant_checkout==="yes"&&(e.fct_cart_hash=window.fluentcart_checkout_vars.cart_hash),window.fluentcart_checkout_vars.is_modal_checkout==="yes"&&(e.modal_checkout="yes"),t.has("quantity")&&(e.quantity=t.get("quantity"));const o=(i=window.fluentCartCouponService)==null?void 0:i.getCoupons();Array.isArray(o)&&o.length>0&&(e.coupons=o.join(","));const a=(s=window.fluent_cart_shipping_service)==null?void 0:s.currentShippingMethodId;return a&&(e.shipping_method_id=a),e}static buildUrl(t,e={}){const o={get(a,i){return i==="toString"||i==="valueOf"||i===Symbol.toPrimitive?()=>w._build(a.rawUrl,e):i==="rawUrl"?a.rawUrl:Reflect.get(a,i)}};return new Proxy({rawUrl:t},o)}static _build(t,e){var a,i;const o=new URLSearchParams(window.location.search);w.quantity==null&&(w.quantity=o.get("quantity")||1);for(const[s,_]of Object.entries(e))o.set(s,_);try{const s=new URL(t);for(const[u,v]of o)w.excludeKeys.includes(u)||s.searchParams.set(u,v);window.fluentcart_checkout_vars.is_instant_checkout==="yes"&&s.searchParams.set("fct_cart_hash",window.fluentcart_checkout_vars.cart_hash),window.fluentcart_checkout_vars.is_modal_checkout==="yes"&&s.searchParams.set("modal_checkout","yes"),s.searchParams.set("quantity",w.quantity);const _=(a=window.fluentCartCouponService)==null?void 0:a.getCoupons();Array.isArray(_)&&_.length>0&&s.searchParams.set("coupons",_.join(","));const p=(i=window.fluent_cart_shipping_service)==null?void 0:i.currentShippingMethodId;return p&&s.searchParams.set("shipping_method_id",p),s.href}catch(s){return console.error("Error building URL:",s),t}}static handleCheckoutRedirect(t,e="*"){var a;if(!t){console.error("CheckoutHelper: redirectUrl is required for handleCheckoutRedirect");return}((a=window.fluentcart_checkout_vars)==null?void 0:a.is_modal_checkout)==="yes"?window.parent.postMessage({type:"fluentCartCheckoutComplete",redirectUrl:t},e):window.location.href=t}};C(w,"quantity",null),C(w,"excludeKeys",["fluent-cart","fct_cart_hash"]);let S=w;var d,M,q,P,L,g,b,r,k;class R{constructor({form:t,orderHandler:e,checkoutHandler:o=null,customPayment:a=!1}){m(this,d);C(this,"payMethod");m(this,M,`${window.fluentcart_checkout_vars.ajaxurl}?action=fluent_cart_checkout_routes&fc_checkout_action=get_order_info`);m(this,q);C(this,"checkoutHandler");C(this,"customPayment");m(this,P);m(this,L,null);m(this,g,!1);m(this,b,!1);m(this,r,null);m(this,k,window.fluentcart.$t);var s,_,p,u,v;y(this,q,e),y(this,d,t),this.payMethod=(s=n(this,d).querySelector('input[name="_fct_pay_method"]:checked'))==null?void 0:s.value,this.checkoutHandler=o,y(this,r,o.checkoutUiService),this.customPayment=a,y(this,g,((_=window.fluentcart_checkout_info)==null?void 0:_.is_zero_payment)==="yes"),y(this,b,((p=window.fluentcart_checkout_info)==null?void 0:p.has_subscription)==="yes"),this.buttons=n(this,d).querySelector("[data-fluent-cart-checkout-page-checkout-button]"),this.paymenMethodsWithCustomCheckoutButtons=(u=window.fluentcart_checkout_vars)==null?void 0:u.payment_methods_with_custom_checkout_buttons,y(this,P,(v=window.fluentcart_checkout_vars)==null?void 0:v.submit_button);const i=n(this,d).querySelector('input[name="_fct_pay_method"]:checked');if(i)this.payMethod=i.value;else{const f=n(this,d).querySelector('input[name="_fct_pay_method"]');f?this.payMethod=f.value:(this.payMethod="offline_payment",window.is_offline_payment_ready=!0,n(this,r).showCheckoutButton(),n(this,r).enableCheckoutButton())}this.paymenMethodsWithCustomCheckoutButtons.includes(this.payMethod)&&(n(this,r).hideCheckoutButton(),n(this,r).enableCheckoutButton()),this.bindPaymentMethodListeners(),window.addEventListener("fluentCartCheckoutDataChanged",f=>{var l;this.checkTotal((l=f.detail)==null?void 0:l.response)}),window.addEventListener("fluentCartFragmentsReplaced",f=>{var l,h;(h=(l=f.detail)==null?void 0:l.selectors)!=null&&h.includes("[data-fluent-cart-checkout-payment-methods]")&&this.reinitializePaymentMethods()}),window.addEventListener("fluent_cart_payment_method_loading",f=>{const l=f.detail.payment_method;l&&(document.querySelectorAll(".fct_payment_method_wrapper").forEach(h=>{h.classList.remove("fct-payment-loading"),h.classList.remove("fct-payment-loading-failed")}),document.querySelectorAll(".fct_payment_method_"+l).forEach(h=>{h.classList.add("fct-payment-loading")}),document.querySelector(".fluent-cart-checkout_embed_payment_container_"+l).parentNode.classList.add("fct-payment-loading"),document.querySelector(".fct_place_order_btn_wrap")&&document.querySelector(".fct_place_order_btn_wrap").classList.add("fct-payment-loading"))}),window.addEventListener("fluent_cart_payment_method_loading_failed",f=>{const l=f.detail.payment_method;l&&document.querySelectorAll(".fct_payment_method_"+l).forEach(h=>{h.classList.remove("fct-payment-loading"),h.classList.add("fct-payment-loading-failed")})}),window.addEventListener("fluent_cart_payment_method_loading_success",f=>{const l=f.detail.payment_method;l&&(document.querySelectorAll(".fct_payment_method_"+l).forEach(h=>{h.classList.remove("fct-payment-loading"),h.classList.remove("fct-payment-loading-failed")}),document.querySelector(".fluent-cart-checkout_embed_payment_container_"+l).parentNode.classList.remove("fct-payment-loading"),document.querySelector(".fct_place_order_btn_wrap")&&document.querySelector(".fct_place_order_btn_wrap").classList.remove("fct-payment-loading"))})}reinitializePaymentMethods(){var i;const t=this.payMethod;!!n(this,d).querySelector("#fluent_payment_methods")?this.payMethod=((i=n(this,d).querySelector('input[name="_fct_pay_method"]:checked'))==null?void 0:i.value)||t:(this.payMethod="offline_payment",window.is_offline_payment_ready=!0,n(this,r).showCheckoutButton(),n(this,r).enableCheckoutButton()),this.bindPaymentMethodListeners();const a=n(this,d).querySelector('input[name="_fct_pay_method"]:checked');if(a){n(this,d).querySelectorAll('input[name="_fct_pay_method"]').forEach(p=>{p.parentNode.classList.remove("active")}),a.parentNode.classList.add("active");const s=a.parentNode,_=document.querySelector(".fluent-cart-checkout_embed_payment_container_"+this.payMethod);if(_){_.parentNode.classList.add("active"),document.querySelectorAll(".fct_payment_method_instructions").forEach(v=>v.style.display="none");const u=s.querySelector(".fct_payment_method_instructions");u&&(u.style.display="block"),this.load(this.payMethod)}}this.paymenMethodsWithCustomCheckoutButtons.includes(this.payMethod)?(n(this,r).hideCheckoutButton(),n(this,r).enableCheckoutButton()):(n(this,r).showCheckoutButton(),n(this,r).enableCheckoutButton())}bindPaymentMethodListeners(){const t=n(this,d).querySelectorAll('input[name="_fct_pay_method"]');t.forEach(e=>{e.addEventListener("change",()=>{var i;this.payMethod=(i=n(this,d).querySelector('input[name="_fct_pay_method"]:checked'))==null?void 0:i.value,t.forEach(s=>s.parentNode.classList.remove("active")),e.parentNode.classList.add("active"),this.paymenMethodsWithCustomCheckoutButtons.includes(this.payMethod)?(n(this,r).hideCheckoutButton(),n(this,r).enableCheckoutButton()):(n(this,r).showCheckoutButton(),n(this,r).enableCheckoutButton()),document.querySelectorAll(".fct_payment_method_instructions").forEach(s=>{s.style.display="none"});const a=document.querySelector(".fluent-cart-checkout_embed_payment_container_"+this.payMethod);if(document.querySelectorAll(".fluent-cart-checkout_embed_payment_container").forEach(s=>s.parentNode.classList.remove("active")),a){a.parentNode.classList.add("active");const s=e.parentNode.querySelector(".fct_payment_method_instructions");s&&(s.style.display="block"),this.load(this.payMethod)}})})}checkTotal(t){(t==null?void 0:t.total)!==n(this,L)&&((t==null?void 0:t.total)>0?y(this,g,!1):(t==null?void 0:t.total)<=0&&!n(this,b)&&y(this,g,!0),y(this,L,t==null?void 0:t.total))}decodeHtml(t){const e=document.createElement("textarea");return e.innerHTML=t,e.value}disableCheckoutButton(t){n(this,d).classList.add("fluent-cart-checkout-order-processing"),n(this,r).disableCheckoutButton(),n(this,r).setCheckoutButtonText(t)}enableCheckoutButton(t){n(this,d).classList.add("fluent-cart-checkout-order-processing"),n(this,r).enableCheckoutButton(),n(this,r).setCheckoutButtonText(t)}showCheckoutButton(){this.buttons.style.display="block",this.buttons.disabled=!1}triggerPaymentCompleteEvent(t){var a;const e=new URLSearchParams({action:"fluent_cart_run_order_actions",order_hash:(a=t==null?void 0:t.order)==null?void 0:a.uuid}),o=new XMLHttpRequest;o.open("POST",window.fluentcart_checkout_vars.ajaxurl,!0),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.onload=function(){o.status>=200&&o.status<300||console.error("Network response was not ok")},o.send(e.toString())}load(t){var s,_;if(t==null){const p=this.payMethod||null,u=p?n(this,d).querySelector('input[name="_fct_pay_method"][value="'+p+'"]'):n(this,d).querySelector('input[name="_fct_pay_method"]');if(u){t=u.value,u.checked=!0,n(this,d).querySelectorAll('input[name="_fct_pay_method"]').forEach(h=>{h.parentNode.classList.remove("active")}),u.parentNode.classList.add("active");const v=document.querySelector(".fluent-cart-checkout_embed_payment_container_"+u.value);v&&v.parentNode.classList.add("active");const l=u.parentNode.querySelector(".fct_payment_method_instructions");l&&(document.querySelectorAll(".fct_payment_method_instructions").forEach(h=>{h.style.display="none"}),l.style.display="block")}else return}this.payMethod=t,window["is_"+t+"_ready"]=!0;let e=new URLSearchParams(window.location.search);const o=n(this,M);let a={method:t};(s=window.fluentcart_checkout_info)!=null&&s.paymentMode&&(a.mode=window.fluentcart_checkout_info.paymentMode),(_=window.fluentcart_checkout_info)!=null&&_.orderHash&&(a.order_hash=window.fluentcart_checkout_info.orderHash),e.has("mode")&&e.get("variation_id")&&(a.mode=e.get("mode"),a.variation_id=e.get("variation_id"));const i=S.buildUrl(o.toString(),a).toString();window.dispatchEvent(new CustomEvent("fluent_cart_load_payments_"+t,{detail:{form:n(this,d),paymentInfoUrl:i,nonce:window.fluentcart_checkout_info.checkout_nonce,orderHandler:n(this,q),paymentLoader:this,isZeroPayment:n(this,g),hasSubscriptions:n(this,b)}}))}changeLoaderStatus(t){const e=document.querySelector(".fct-order-processing .loading-status");if(!e)return;const o={processing:n(this,k).call(this,"Payment Processing..."),confirming:n(this,k).call(this,"Confirming Payment..."),completed:n(this,k).call(this,"Payment completed! Updating order..."),redirecting:n(this,k).call(this,"Redirecting to receipt..."),failed:n(this,k).call(this,"Payment failed!"),canceled:n(this,k).call(this,"Payment canceled!"),rejected:n(this,k).call(this,"Payment Process rejected!")};e.textContent=o[t]||t}hideLoader(){const t=document.querySelector(".fct-order-processing");t&&t.classList.add("fct-loader-hidden")}getPaymentMethod(){return this.payMethod}}d=new WeakMap,M=new WeakMap,q=new WeakMap,P=new WeakMap,L=new WeakMap,g=new WeakMap,b=new WeakMap,r=new WeakMap,k=new WeakMap;export{S as C,R as P};
1 +var N=Object.defineProperty;var E=r=>{throw TypeError(r)};var x=(r,t,e)=>t in r?N(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>x(r,typeof t!="symbol"?t+"":t,e),U=(r,t,e)=>t.has(r)||E("Cannot "+e);var n=(r,t,e)=>(U(r,t,"read from private field"),e?e.call(r):t.get(r)),w=(r,t,e)=>t.has(r)?E("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),v=(r,t,e,o)=>(U(r,t,"write to private field"),o?o.call(r,e):t.set(r,e),e);const k=class k{static handleFragments(t){let e=!1;t.forEach(o=>{const a=document.querySelector(o.selector);a&&(o.selector&&o.type==="replace"&&(e=!0),o.type==="replace"?a.innerHTML=o.content:a.insertAdjacentHTML("beforeend",o.content))}),e&&setTimeout(()=>{window.dispatchEvent(new CustomEvent("fluentCartFragmentsReplaced",{detail:{selectors:t.filter(o=>o.type==="replace").map(o=>o.selector)}}))},10),window.dispatchEvent(new CustomEvent("fluentCartNotifySummaryViewUpdated"))}static handleSummaryViewUpdated(){fetch(k.buildUrl(`${window.fluentcart_checkout_vars.ajaxurl}?action=fluent_cart_checkout_routes&fc_checkout_action=get_checkout_summary_view`).toString(),{headers:{"X-WP-Nonce":window.fluentCartRestVars.rest.nonce},credentials:"include"}).then(t=>t.json()).then(t=>{this.handleFragments(t.fragments),window.dispatchEvent(new CustomEvent("fluentCartCheckoutDataChanged",{detail:{response:t}}))}).catch(t=>{})}static getParams(){var c,s;const t=new URLSearchParams(window.location.search),e={};window.fluentcart_checkout_vars.is_instant_checkout==="yes"&&(e.fct_cart_hash=window.fluentcart_checkout_vars.cart_hash),window.fluentcart_checkout_vars.is_modal_checkout==="yes"&&(e.modal_checkout="yes"),t.has("quantity")&&(e.quantity=t.get("quantity"));const o=(c=window.fluentCartCouponService)==null?void 0:c.getCoupons();Array.isArray(o)&&o.length>0&&(e.coupons=o.join(","));const a=(s=window.fluent_cart_shipping_service)==null?void 0:s.currentShippingMethodId;return a&&(e.shipping_method_id=a),e}static buildUrl(t,e={}){const o={get(a,c){return c==="toString"||c==="valueOf"||c===Symbol.toPrimitive?()=>k._build(a.rawUrl,e):c==="rawUrl"?a.rawUrl:Reflect.get(a,c)}};return new Proxy({rawUrl:t},o)}static _build(t,e){var a,c;const o=new URLSearchParams(window.location.search);k.quantity==null&&(k.quantity=o.get("quantity")||1);for(const[s,_]of Object.entries(e))o.set(s,_);try{const s=new URL(t);for(const[m,f]of o)k.excludeKeys.includes(m)||s.searchParams.set(m,f);window.fluentcart_checkout_vars.is_instant_checkout==="yes"&&s.searchParams.set("fct_cart_hash",window.fluentcart_checkout_vars.cart_hash),window.fluentcart_checkout_vars.is_modal_checkout==="yes"&&s.searchParams.set("modal_checkout","yes"),s.searchParams.set("quantity",k.quantity);const _=(a=window.fluentCartCouponService)==null?void 0:a.getCoupons();Array.isArray(_)&&_.length>0&&s.searchParams.set("coupons",_.join(","));const p=(c=window.fluent_cart_shipping_service)==null?void 0:c.currentShippingMethodId;return p&&s.searchParams.set("shipping_method_id",p),s.href}catch{return t}}static handleCheckoutRedirect(t,e="*"){var a;if(!t)return;((a=window.fluentcart_checkout_vars)==null?void 0:a.is_modal_checkout)==="yes"?window.parent.postMessage({type:"fluentCartCheckoutComplete",redirectUrl:t},e):window.location.href=t}};g(k,"quantity",null),g(k,"excludeKeys",["fluent-cart","fct_cart_hash"]);let B=k;var d,M,q,P,L,C,b,i,y;class I{constructor({form:t,orderHandler:e,checkoutHandler:o=null,customPayment:a=!1}){w(this,d);g(this,"payMethod");w(this,M,`${window.fluentcart_checkout_vars.ajaxurl}?action=fluent_cart_checkout_routes&fc_checkout_action=get_order_info`);w(this,q);g(this,"checkoutHandler");g(this,"customPayment");w(this,P);w(this,L,null);w(this,C,!1);w(this,b,!1);w(this,i,null);w(this,y,window.fluentcart.$t);var s,_,p,m,f;v(this,q,e),v(this,d,t),this.payMethod=(s=n(this,d).querySelector('input[name="_fct_pay_method"]:checked'))==null?void 0:s.value,this.checkoutHandler=o,v(this,i,(o==null?void 0:o.checkoutUiService)||{enableCheckoutButton:()=>{},disableCheckoutButton:()=>{},showCheckoutButton:()=>{},hideCheckoutButton:()=>{},setCheckoutButtonText:()=>{}}),this.customPayment=a,v(this,C,((_=window.fluentcart_checkout_info)==null?void 0:_.is_zero_payment)==="yes"),v(this,b,((p=window.fluentcart_checkout_info)==null?void 0:p.has_subscription)==="yes"),this.buttons=n(this,d).querySelector("[data-fluent-cart-checkout-page-checkout-button]"),this.paymenMethodsWithCustomCheckoutButtons=(m=window.fluentcart_checkout_vars)==null?void 0:m.payment_methods_with_custom_checkout_buttons,v(this,P,(f=window.fluentcart_checkout_vars)==null?void 0:f.submit_button);const c=n(this,d).querySelector('input[name="_fct_pay_method"]:checked');if(c)this.payMethod=c.value;else{const u=n(this,d).querySelector('input[name="_fct_pay_method"]');u?this.payMethod=u.value:(this.payMethod="offline_payment",window.is_offline_payment_ready=!0,n(this,i).showCheckoutButton(),n(this,i).enableCheckoutButton())}this.paymenMethodsWithCustomCheckoutButtons.includes(this.payMethod)&&(n(this,i).hideCheckoutButton(),n(this,i).enableCheckoutButton()),this.bindPaymentMethodListeners(),window.addEventListener("fluentCartCheckoutDataChanged",u=>{var l;this.checkTotal((l=u.detail)==null?void 0:l.response)}),window.addEventListener("fluentCartFragmentsReplaced",u=>{var l,h;(h=(l=u.detail)==null?void 0:l.selectors)!=null&&h.includes("[data-fluent-cart-checkout-payment-methods]")&&this.reinitializePaymentMethods()}),window.addEventListener("fluent_cart_payment_method_loading",u=>{const l=u.detail.payment_method;l&&(document.querySelectorAll(".fct_payment_method_wrapper").forEach(h=>{h.classList.remove("fct-payment-loading"),h.classList.remove("fct-payment-loading-failed")}),document.querySelectorAll(".fct_payment_method_"+l).forEach(h=>{h.classList.add("fct-payment-loading")}),document.querySelector(".fluent-cart-checkout_embed_payment_container_"+l).parentNode.classList.add("fct-payment-loading"),document.querySelector(".fct_place_order_btn_wrap")&&document.querySelector(".fct_place_order_btn_wrap").classList.add("fct-payment-loading"))}),window.addEventListener("fluent_cart_payment_method_loading_failed",u=>{const l=u.detail.payment_method;l&&(document.querySelectorAll(".fct_payment_method_"+l).forEach(h=>{h.classList.remove("fct-payment-loading"),h.classList.add("fct-payment-loading-failed")}),document.querySelector(".fct_place_order_btn_wrap")&&document.querySelector(".fct_place_order_btn_wrap").classList.remove("fct-payment-loading"),l===this.payMethod&&n(this,i).disableCheckoutButton())}),window.addEventListener("fluent_cart_payment_method_loading_success",u=>{const l=u.detail.payment_method;l&&(document.querySelectorAll(".fct_payment_method_"+l).forEach(h=>{h.classList.remove("fct-payment-loading"),h.classList.remove("fct-payment-loading-failed")}),document.querySelector(".fluent-cart-checkout_embed_payment_container_"+l).parentNode.classList.remove("fct-payment-loading"),document.querySelector(".fct_place_order_btn_wrap")&&document.querySelector(".fct_place_order_btn_wrap").classList.remove("fct-payment-loading"))})}reinitializePaymentMethods(){var c;const t=this.payMethod;!!n(this,d).querySelector("#fluent_payment_methods")?this.payMethod=((c=n(this,d).querySelector('input[name="_fct_pay_method"]:checked'))==null?void 0:c.value)||t:(this.payMethod="offline_payment",window.is_offline_payment_ready=!0,n(this,i).showCheckoutButton(),n(this,i).enableCheckoutButton()),this.bindPaymentMethodListeners();const a=n(this,d).querySelector('input[name="_fct_pay_method"]:checked');if(a){n(this,d).querySelectorAll('input[name="_fct_pay_method"]').forEach(p=>{p.parentNode.classList.remove("active")}),a.parentNode.classList.add("active");const s=a.parentNode,_=document.querySelector(".fluent-cart-checkout_embed_payment_container_"+this.payMethod);if(_){_.parentNode.classList.add("active"),document.querySelectorAll(".fct_payment_method_instructions").forEach(f=>f.style.display="none");const m=s.querySelector(".fct_payment_method_instructions");m&&(m.style.display="block"),this.load(this.payMethod)}}this.paymenMethodsWithCustomCheckoutButtons.includes(this.payMethod)?(n(this,i).hideCheckoutButton(),n(this,i).enableCheckoutButton()):(n(this,i).showCheckoutButton(),n(this,i).enableCheckoutButton())}bindPaymentMethodListeners(){const t=n(this,d).querySelectorAll('input[name="_fct_pay_method"]');t.forEach(e=>{e.addEventListener("change",()=>{var c;this.payMethod=(c=n(this,d).querySelector('input[name="_fct_pay_method"]:checked'))==null?void 0:c.value,t.forEach(s=>s.parentNode.classList.remove("active")),e.parentNode.classList.add("active"),this.paymenMethodsWithCustomCheckoutButtons.includes(this.payMethod)?(n(this,i).hideCheckoutButton(),n(this,i).enableCheckoutButton()):(n(this,i).showCheckoutButton(),n(this,i).enableCheckoutButton()),document.querySelectorAll(".fct_payment_method_instructions").forEach(s=>{s.style.display="none"});const a=document.querySelector(".fluent-cart-checkout_embed_payment_container_"+this.payMethod);if(document.querySelectorAll(".fluent-cart-checkout_embed_payment_container").forEach(s=>s.parentNode.classList.remove("active")),a){a.parentNode.classList.add("active");const s=e.parentNode.querySelector(".fct_payment_method_instructions");s&&(s.style.display="block"),this.load(this.payMethod)}})})}checkTotal(t){(t==null?void 0:t.total)!==n(this,L)&&((t==null?void 0:t.total)>0?v(this,C,!1):(t==null?void 0:t.total)<=0&&!n(this,b)&&v(this,C,!0),v(this,L,t==null?void 0:t.total))}decodeHtml(t){const e=document.createElement("textarea");return e.innerHTML=t,e.value}disableCheckoutButton(t){n(this,d).classList.add("fluent-cart-checkout-order-processing"),n(this,i).disableCheckoutButton(),n(this,i).setCheckoutButtonText(t)}enableCheckoutButton(t){n(this,d).classList.add("fluent-cart-checkout-order-processing"),n(this,i).enableCheckoutButton(),n(this,i).setCheckoutButtonText(t)}showCheckoutButton(){this.buttons.style.display="block",this.buttons.disabled=!1}triggerPaymentCompleteEvent(t){var a;const e=new URLSearchParams({action:"fluent_cart_run_order_actions",order_hash:(a=t==null?void 0:t.order)==null?void 0:a.uuid}),o=new XMLHttpRequest;o.open("POST",window.fluentcart_checkout_vars.ajaxurl,!0),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.onload=function(){o.status>=200&&o.status<300},o.send(e.toString())}load(t){var _,p;if(t==null){const m=this.payMethod||null,f=m?n(this,d).querySelector('input[name="_fct_pay_method"][value="'+m+'"]'):n(this,d).querySelector('input[name="_fct_pay_method"]');if(f){t=f.value,f.checked=!0,n(this,d).querySelectorAll('input[name="_fct_pay_method"]').forEach(S=>{S.parentNode.classList.remove("active")}),f.parentNode.classList.add("active");const u=document.querySelector(".fluent-cart-checkout_embed_payment_container_"+f.value);u&&u.parentNode.classList.add("active");const h=f.parentNode.querySelector(".fct_payment_method_instructions");h&&(document.querySelectorAll(".fct_payment_method_instructions").forEach(S=>{S.style.display="none"}),h.style.display="block")}else return}this.payMethod=t,window["is_"+t+"_ready"]=!0;let e=new URLSearchParams(window.location.search);const o=n(this,M);let a={method:t};(_=window.fluentcart_checkout_info)!=null&&_.paymentMode&&(a.mode=window.fluentcart_checkout_info.paymentMode),(p=window.fluentcart_checkout_info)!=null&&p.orderHash&&(a.order_hash=window.fluentcart_checkout_info.orderHash),e.has("mode")&&e.get("variation_id")&&(a.mode=e.get("mode"),a.variation_id=e.get("variation_id"));const c=n(this,d).querySelector('input[name="save_payment_method"]');c&&c.checked&&(a.save_payment_method="yes");const s=B.buildUrl(o.toString(),a).toString();window.dispatchEvent(new CustomEvent("fluent_cart_load_payments_"+t,{detail:{form:n(this,d),paymentInfoUrl:s,nonce:window.fluentcart_checkout_info.checkout_nonce,orderHandler:n(this,q),paymentLoader:this,isZeroPayment:n(this,C),hasSubscriptions:n(this,b)}}))}changeLoaderStatus(t){this.showLoader();const e=document.querySelector(".fct-order-processing .loading-status");if(!e)return;const o={processing:n(this,y).call(this,"Payment Processing..."),confirming:n(this,y).call(this,"Confirming Payment..."),completed:n(this,y).call(this,"Payment completed! Updating order..."),redirecting:n(this,y).call(this,"Redirecting to receipt..."),failed:n(this,y).call(this,"Payment failed!"),canceled:n(this,y).call(this,"Payment canceled!"),rejected:n(this,y).call(this,"Payment Process rejected!")};e.textContent=o[t]||t}showLoader(){let t=document.querySelector(".fct-order-processing");t?t.classList.remove("fct-loader-hidden"):(t=document.createElement("div"),t.className="fct-order-processing",t.innerHTML='<div class="fct-loader-spinner"></div><br/><div class="loading-status"></div><div class="fct-browser-notify">'+n(this,y).call(this,"Please Don't close the browser")+"</div>",document.body.appendChild(t))}hideLoader(){const t=document.querySelector(".fct-order-processing");t&&t.classList.add("fct-loader-hidden")}getPaymentMethod(){return this.payMethod}}d=new WeakMap,M=new WeakMap,q=new WeakMap,P=new WeakMap,L=new WeakMap,C=new WeakMap,b=new WeakMap,i=new WeakMap,y=new WeakMap;export{B as C,I as P};