window.addEventListener("fluent_cart_load_payments_stripe",function(o){const i=window.fluentcart.$t||(t=>t);window.dispatchEvent(new CustomEvent("fluent_cart_payment_method_loading",{detail:{payment_method:"stripe"}}));const n=document.querySelector(".fluent-cart-checkout_embed_payment_container_stripe");if(n){const t=i("Loading Payment Processor...");n.innerHTML='<p id="fct_loading_payment_processor">'+t+"</p>"}fetch(o.detail.paymentInfoUrl,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":o.detail.nonce},credentials:"include"}).then(async t=>{var r,l,s;if(t=await t.json(),(t==null?void 0:t.status)==="failed"){c((t==null?void 0:t.message)||i("Something went wrong")),(r=o.detail.paymentLoader)==null||r.disableCheckoutButton();return}if(n){const m=`
                <div class="stripe-hosted-checkout-info" style="padding: 15px; background: #f8f9fa; border-radius: 4px; margin: 10px 0;">
                    <p style="margin: 0; color: #495057; font-size: 14px;">
                        ${i("You will be redirected to Stripe to complete your payment securely.")}
                    </p>
                </div>
            `;n.innerHTML=m}const e=document.getElementById("fct_loading_payment_processor");e&&e.remove(),window.dispatchEvent(new CustomEvent("fluent_cart_payment_method_loading_success",{detail:{payment_method:"stripe"}}));const a=(l=window.fluentcart_checkout_vars)==null?void 0:l.submit_button,d=o.detail.form.querySelector('input[name="_fct_pay_method"]:checked');d&&d.value==="stripe"&&((s=o.detail.paymentLoader)==null||s.enableCheckoutButton((a==null?void 0:a.text)||i("Place Order")))}).catch(t=>{var a;console.error("Stripe hosted checkout error:",t),c(i("An error occurred while loading the payment method."));const e=document.getElementById("fct_loading_payment_processor");e&&e.remove(),(a=o.detail.paymentLoader)==null||a.disableCheckoutButton()});function c(t){if(!t||!n)return;const e=document.createElement("div");e.className="fct-error-message",e.style.color="#dc3545",e.style.fontSize="14px",e.style.padding="10px",e.textContent=t,n.innerHTML="",n.appendChild(e)}});
