window.addEventListener("fluent_cart_load_payments_stripe",function(a){const i=function(t){var n;return(((n=window.fct_stripe_data)==null?void 0:n.translations)||{})[t]||t};window.dispatchEvent(new CustomEvent("fluent_cart_payment_method_loading",{detail:{payment_method:"stripe"}}));const o=document.querySelector(".fluent-cart-checkout_embed_payment_container_stripe");if(o){const t=i("Loading Payment Processor...");o.innerHTML='<p id="fct_loading_payment_processor">'+t+"</p>"}fetch(a.detail.paymentInfoUrl,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":a.detail.nonce},credentials:"include"}).then(async t=>{var r,l,s;if(t=await t.json(),(t==null?void 0:t.status)==="failed"){d((t==null?void 0:t.message)||i("Something went wrong")),(r=a.detail.paymentLoader)==null||r.disableCheckoutButton();return}if(o){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>
            `;o.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 n=(l=window.fluentcart_checkout_vars)==null?void 0:l.submit_button,c=a.detail.form.querySelector('input[name="_fct_pay_method"]:checked');c&&c.value==="stripe"&&((s=a.detail.paymentLoader)==null||s.enableCheckoutButton((n==null?void 0:n.text)||i("Place Order")))}).catch(t=>{var n;d(i("An error occurred while loading the payment method."));const e=document.getElementById("fct_loading_payment_processor");e&&e.remove(),(n=a.detail.paymentLoader)==null||n.disableCheckoutButton()});function d(t){if(!t||!o)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,o.innerHTML="",o.appendChild(e)}});
