import{__}from"@wordpress/i18n";export const RAZORPAY_CHECKOUT_SCRIPT_URL="https://checkout.razorpay.com/v1/checkout.js";export const RAZORPAY_METHOD_META={card:{icon:"razorpay",label:()=>__("Credit Card","surecart")},upi:{icon:"upi",label:()=>__("UPI","surecart")}};export const getRazorpayMethodLabel=o=>{var r;return o?null===(r=RAZORPAY_METHOD_META[o])||void 0===r?void 0:r.label():void 0};export const getRazorpayMethodIcon=o=>{var r;return o&&(null===(r=RAZORPAY_METHOD_META[o])||void 0===r?void 0:r.icon)||"razorpay"};let razorpayInstance=null,loadPromise=null;export const loadRazorpay=()=>razorpayInstance?Promise.resolve(razorpayInstance):loadPromise||(loadPromise=new Promise(((o,r)=>{const a=document.createElement("script");a.src=RAZORPAY_CHECKOUT_SCRIPT_URL,a.async=!0,a.onload=()=>{razorpayInstance=window.Razorpay,o(razorpayInstance)},a.onerror=()=>{loadPromise=null,r(new Error(__("Failed to load Razorpay script.","surecart")))},document.head.appendChild(a)})),loadPromise);