import{P as H}from"./chunks/payment-loader.js?ver=1.5.2";const l=jQuery;l(()=>{const a=window.fluentcart_checkout_info;a.baseUrl;const N=a.paymentMode,E=a.orderHash;a.rest_url;const J=a==null?void 0:a.rest.nonce;a.ajaxurl;const M=a.variationId;a.order_information_url;const $=a.custom_checkout_url,d=window.fluentcart.$t;let u=l(l("form[data-fluent-cart-checkout-page-checkout-form]")[0]);const m=async _=>{_!==void 0&&_.preventDefault();const n=jQuery(".fct-loader"),i=f.getPaymentMethod(),C=window["is_"+i+"_ready"];if(i!=="offline_payment"&&!C)return window.dispatchEvent(new CustomEvent("fluent_cart_validate_checkout_"+i)),!1;const b=$,h=new URLSearchParams(window.location.search);let j=h.get("license_key")||"",x=h.get("coupon")||"";return n.addClass("active"),await jQuery.post(b,{order_hash:E,mode:N,payment_method:i,variation_id:M,license_key:j,coupon:x,_wpnonce:J}).then(t=>{var o;return t.actionName==="custom"?window.dispatchEvent(new CustomEvent("fluent_cart_payment_next_action_"+t.nextAction,{detail:{response:t}})):t.redirect_to?((void 0).buttonState("order_processing",d("Please wait..."),(o=t.data)==null?void 0:o.buttonState),window.location.href=t==null?void 0:t.redirect_to):(t==null?void 0:t.status)==="failed"?alert((t==null?void 0:t.message)||d("Payment failed. Please try again.")):n.removeClass("active"),t}).catch(t=>{var o,y,w,v,k,g,P,S,O;if(n.removeClass("active"),!((y=(o=t==null?void 0:t.responseJSON)==null?void 0:o.data)!=null&&y.message)){if(!((w=t==null?void 0:t.responseJSON)!=null&&w.message)){if((k=(v=t==null?void 0:t.responseJSON)==null?void 0:v.data)!=null&&k.errors){const e=(P=(g=t==null?void 0:t.responseJSON)==null?void 0:g.data)==null?void 0:P.errors;let r="";for(const c in e)e.hasOwnProperty(c)&&(r+=`${c}: ${e[c]}
`)}else if((S=t==null?void 0:t.responseJSON)!=null&&S.errors){const e=(O=t==null?void 0:t.responseJSON)==null?void 0:O.errors;let r="";for(const c in e)e.hasOwnProperty(c)&&(r+=`${c}: ${e[c]}
`)}}}})};u.on("submit",m);const f=new H({form:u[0],orderHandler:m,customPayment:!0});f.load()});
