@tuwaio/nova-payments 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +11 -6
  2. package/dist/chunk-4HBN6N7D.cjs +1 -0
  3. package/dist/chunk-7FQXTBOY.cjs +1 -0
  4. package/dist/chunk-7HSDAUKN.js +1 -0
  5. package/dist/chunk-A2WIFZQB.js +1 -0
  6. package/dist/de-5UOOKHHH.cjs +1 -0
  7. package/dist/de-U3SERR3Y.js +1 -0
  8. package/dist/es-J6MJIGEI.js +1 -0
  9. package/dist/es-WSJ36B6Y.cjs +1 -0
  10. package/dist/evm/index.cjs +1 -1
  11. package/dist/evm/index.d.cts +13 -5
  12. package/dist/evm/index.d.ts +13 -5
  13. package/dist/evm/index.js +1 -1
  14. package/dist/i18n/index.cjs +1 -1
  15. package/dist/i18n/index.d.cts +2 -2
  16. package/dist/i18n/index.d.ts +2 -2
  17. package/dist/i18n/index.js +1 -1
  18. package/dist/index.cjs +2 -2
  19. package/dist/index.css +198 -50
  20. package/dist/index.d.cts +197 -177
  21. package/dist/index.d.ts +197 -177
  22. package/dist/index.js +2 -2
  23. package/dist/it-KX7WWME3.js +1 -0
  24. package/dist/it-QORQLELA.cjs +1 -0
  25. package/dist/{locales-DzMinYsr.d.cts → locales-dTcrLl9B.d.cts} +69 -97
  26. package/dist/{locales-DzMinYsr.d.ts → locales-dTcrLl9B.d.ts} +69 -97
  27. package/dist/solana/index.cjs +1 -1
  28. package/dist/solana/index.js +1 -1
  29. package/dist/{types-Bp6JUt56.d.cts → types-DkYd2XhD.d.cts} +1 -49
  30. package/dist/{types-Bp6JUt56.d.ts → types-DkYd2XhD.d.ts} +1 -49
  31. package/dist/uk-GMKBC44N.js +1 -0
  32. package/dist/uk-R2A3XIGT.cjs +1 -0
  33. package/dist/zhCN-5JP4MWXH.cjs +1 -0
  34. package/dist/zhCN-AX2E4I6A.js +1 -0
  35. package/package.json +10 -11
  36. package/dist/chunk-PUMIYLSN.js +0 -1
  37. package/dist/chunk-S3L4QDPT.cjs +0 -1
  38. package/dist/chunk-WOAPFVQF.js +0 -1
  39. package/dist/chunk-XOVRZTAM.cjs +0 -1
  40. package/dist/de-53SSE6O2.js +0 -1
  41. package/dist/de-LB5XSRMX.cjs +0 -1
  42. package/dist/es-LP3HJ4KB.js +0 -1
  43. package/dist/es-VDW2RZMP.cjs +0 -1
  44. package/dist/it-6IQFXLAR.cjs +0 -1
  45. package/dist/it-JJ5Z5EUF.js +0 -1
  46. package/dist/uk-EI4N5BMM.js +0 -1
  47. package/dist/uk-FVCYLYSB.cjs +0 -1
  48. package/dist/zhCN-BZBMKUUA.js +0 -1
  49. package/dist/zhCN-TA7WU5XS.cjs +0 -1
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import {c,b,e,g,f,h,i,d}from'./chunk-WOAPFVQF.js';import {b as b$1,a}from'./chunk-PUMIYLSN.js';export{a as PaymentWalletError,b as walletErrorKind}from'./chunk-PUMIYLSN.js';import {getChainName,cn,DrawnCheck,MorphText,WalletIcon,Dialog,DialogContent,DialogTitle,TokenIcon,QuasarLoader,StatusEdge,NetworkIcon,DrawnCross,CopyIcon}from'@tuwaio/nova-core';import {createContext,lazy,useState,useEffectEvent,useEffect,useContext,useId,useRef,useMemo,Fragment as Fragment$1,useCallback,Suspense}from'react';import {formatBaseUnits,parseCaip2ChainId,toCaip2ChainId,formatCaip10AccountId,toEvmChainId,parseCaip19AssetId,parseCaip10AccountId,shortAddress,OrbitAdapter,getAdapterFromConnectorType,getConnectorTypeFromName,formatConnectorName,getSolanaCluster,isSameAddress,delay}from'@tuwaio/orbit-core';export{shortAddress}from'@tuwaio/orbit-core';import {TxStatusVisual,TxProgressIndicator,HashLink}from'@tuwaio/nova-transactions';import {useLabels,NovaTransactionsLabelsProvider}from'@tuwaio/nova-transactions/providers';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {ChevronDownIcon,LockClosedIcon,ClockIcon,GlobeAltIcon,XMarkIcon,FingerPrintIcon,WalletIcon as WalletIcon$1,QrCodeIcon,DevicePhoneMobileIcon,NoSymbolIcon,ArrowPathRoundedSquareIcon,ArrowUturnLeftIcon,MagnifyingGlassIcon,ExclamationTriangleIcon,DocumentTextIcon,ArrowDownTrayIcon,InformationCircleIcon}from'@heroicons/react/24/outline';import {MotionConfig}from'framer-motion';import {createCheckoutStore}from'@tuwaio/quasar-sdk/checkout';import {useStore}from'zustand';import {SatelliteStoreContext}from'@tuwaio/satellite-react';import {createStore}from'zustand/vanilla';import {NovaConnectProviderContext}from'@tuwaio/nova-connect/hooks';import {encode}from'uqr';function xt(e,t){let[n,a]=useState(null),o=useEffectEvent(t);return useEffect(()=>{if(e===null)return;let r=true,s;try{s=Promise.resolve(o());}catch(i){s=Promise.reject(i);}return s.then(i=>r&&a({key:e,value:i}),()=>r&&a({key:e,value:null})),()=>{r=false;}},[e]),n&&n.key===e?n.value:void 0}function _a(e,t,n){let[a,o]=useState(0),[r,s]=useState(null),i=useEffectEvent(t);return useEffect(()=>{if(e===null||typeof window>"u")return;let c=()=>{document.visibilityState!=="hidden"&&o(d=>d+1);},p=window,u=document;return p.addEventListener("focus",c),u.addEventListener("visibilitychange",c),()=>{p.removeEventListener("focus",c),u.removeEventListener("visibilitychange",c);}},[e]),useEffect(()=>{if(e===null)return;let c=true,p;try{p=Promise.resolve(i());}catch(u){p=Promise.reject(u);}return p.then(u=>c&&s({key:e,value:u}),()=>c&&s({key:e,value:null})),()=>{c=false;}},[e,a,n]),r&&r.key===e?r.value:void 0}var Wa=createContext(null),xo=Wa.Provider;function _(){let e=useContext(Wa);if(!e)throw new Error("useCheckoutContext must be used inside PaymentCheckout");return e}function Ge(){return useContext(Wa)}function bo(e){return e.closest("[data-novapay-scroll]")??null}function vi(e,t){let n=t?.offsetHeight;return n&&n>0?Math.min(e,n):e}function hi(e){let t=e.offsetHeight;return t>0?vi(t,bo(e)):null}function Vt(e){let[t,n]=useState(null),[a,o]=useState(null),[r,s]=useState(null);return useEffect(()=>{if(!t)return;let i=bo(t),c=()=>{if(!e){let d=hi(t);d!==null&&o(d);}let u=i?.offsetHeight;s(u&&u>0?u:null);};if(c(),typeof ResizeObserver>"u")return;let p=new ResizeObserver(c);return e||p.observe(t),i&&p.observe(i),()=>p.disconnect()},[t,e]),!e||a===null?[n,null]:[n,r?Math.min(a,r):a]}function Be(e,t=2){let n=e.startsWith("-"),a=(n?e.slice(1):e).padStart(t+1,"0");return `${n?"-":""}${a.slice(0,-t)}.${a.slice(-t)}`}var wo=e=>new Intl.NumberFormat(e).formatToParts(1.1).find(t=>t.type==="decimal")?.value??".";function be(e,t){let[n="0",a=""]=(typeof e=="number"?e.toFixed(2):e.trim()).split("."),o=n.startsWith("-"),r=new Intl.NumberFormat(t).format(BigInt(o?n.slice(1):n));return `${o?"-":""}${r}${wo(t)}${a.padEnd(2,"0").slice(0,2)}`}function ye(e,t,n){let a=BigInt(e),o=a<0n,r=o?-a:a,s=10n**BigInt(t),i=new Intl.NumberFormat(n).format(r/s),c=(r%s).toString().padStart(t,"0").replace(/0+$/,"").padEnd(2,"0");return `${o?"-":""}${i}${wo(n)}${c}`}function Da(e,t,n){let a=10n**BigInt(Math.max(t-6,0)),o=(BigInt(e)+a/2n)/a*a;return o===0n?null:ye(o.toString(),t,n)}function Ma(e,t){return formatBaseUnits(e,t)??"0"}var Lt=e=>String(e).padStart(2,"0");function at(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/86400),a=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),r=t%60;return n>0?`${n}d ${Lt(a)}:${Lt(o)}`:a>0?`${Lt(a)}:${Lt(o)}:${Lt(r)}`:`${Lt(o)}:${Lt(r)}`}var ko={metamask:"MetaMask",walletconnect:"WalletConnect",coinbase:"Coinbase Wallet",okx:"OKX Wallet",trust:"Trust Wallet",injected:"Browser wallet"};function Ri(e,t){let n=e.slice(e.indexOf(":")+1).toLowerCase();return n==="injected"?ko.injected:t?.trim()||ko[n]||n.charAt(0).toUpperCase()+n.slice(1)}var Ln=e=>/^data:image\//i.test(e)||/^https:\/\//i.test(e),An=e=>{let t=typeof e=="string"?e.trim():"";return t&&Ln(t)?t:void 0};function Ii(e,t,n){let a=getAdapterFromConnectorType(t),o=e[a];if(!Array.isArray(o))return;let r=o.filter(s=>typeof s=="object"&&s!==null&&typeof s.name=="string"&&getConnectorTypeFromName(a,formatConnectorName(s.name))===t);return n&&r.find(s=>An(s.icon)===n)||r[0]}var qa=e=>{let t=parseCaip2ChainId(e)?.namespace;return t==="eip155"||t==="solana"?t:null};function Co(e,t){if(!e?.address)return null;let n=toCaip2ChainId(e.chainId),a=n?qa(n):null;if(!n||!a)return null;let o=An(e.icon),r=t?Ii(t,e.connectorType,o):void 0;return {address:e.address,chainId:n,family:a,connectorType:e.connectorType,walletId:e.connectorType.slice(e.connectorType.indexOf(":")+1).toLowerCase(),name:Ri(e.connectorType,typeof r?.name=="string"?r.name:void 0),icon:o??An(r?.icon),connection:e}}function Oe(e){return qa(e.chainId)}function Ue(e,t){return !e||e.family!==Oe(t)?null:formatCaip10AccountId(t.chainId,e.address)??null}function Po(e,t){let n=Oe(e);return n==="solana"||n==="eip155"&&!!t}function Bn(e){let t=n=>String(Number((n/100).toFixed(2)));return e.discountBps>0?{kind:"discount",percent:t(e.discountBps)}:e.markupBps>0?{kind:"markup",percent:t(e.markupBps)}:null}function fe(e){return getChainName(toEvmChainId(e)??e).name}function So(e){let t=e.assetId?parseCaip19AssetId(e.assetId):void 0;return !t||t.assetNamespace==="slip44"?"native":t.assetReference}var Ei="too_many_payments",To=e=>e==="selectMethod"||e==="awaitingPayment",No=e=>e?.status==="active"&&!!e.replacement;function Ro(e,t={}){if(t.labelsReady===false&&e.phase!=="error")return "loading";if(t.autoPayOff&&e.checkout?.autoCharge?.status==="active")return "autoPayOff";if(e.phase==="unconfirmed")return gt(e.error)==="retrying"?"confirm":"unconfirmed";let n=e.payerProof==="required"||e.payerProof==="confirming"||e.payerProof==="confirmed"&&!e.error,a=!!(t.confirmWallet&&n);switch(e.phase){case "selectMethod":return t.autoPay&&No(e.checkout?.autoCharge)?"autoPay":a&&!(t.handoff&&t.payWith==="qr")?"confirmWallet":t.handoff&&t.payWith==="qr"?"qr":"method";case "underpaid":return a?"confirmWallet":"underpaid";case "quoting":return e.quote?t.payWith==="qr"||e.quote.payer===null?"qr":"pay":t.confirmWallet?"confirmWallet":"method";case "awaitingPayment":if(t.autoPay&&No(e.checkout?.autoCharge))return "autoPay";case "submitting":return e.phase==="submitting"&&!e.quote?"confirm":t.payWith==="qr"||e.quote?.payer===null?"qr":"pay";case "confirming":return "confirm";case "paid":return t.autoPay&&e.checkout?.autoCharge?.status==="available"?"autoPay":"paid";case "cancelled":return e.checkout?.invoice.replacedBy?"replaced":"cancelled";default:return e.phase}}var Ai={buyer:"details",method:"method",confirmWallet:"method",pay:"pay",qr:"pay",underpaid:"pay",confirm:"confirm",unconfirmed:"confirm",autoPay:"autoPay"};function Io(e,t={}){let n=Ai[e];if(!n)return null;let a=[...t.withDetails||n==="details"?["details"]:[],"method","pay","confirm",...n==="autoPay"?["autoPay"]:[]],o=a.indexOf(n);return a.map((r,s)=>({key:r,state:s<o?"done":s===o?"current":"upcoming"}))}function Eo(e={}){return [...e.withDetails?["details"]:[],"method","pay","confirm"].map(n=>({key:n,state:"done"}))}function Ao(e,t){let n=s=>s.chainId===t?0:s.featured?1:2,a=new Map;for(let s of e)a.set(s.symbol,[...a.get(s.symbol)??[],s]);let o=[...a].map(([s,i])=>{let c=[...i].sort((p,u)=>n(p)-n(u));return {symbol:s,methods:c,featured:i.some(p=>p.featured),inWallet:!!t&&i.some(p=>p.chainId===t)}}),r=s=>s.inWallet?0:s.featured?1:2;return o.sort((s,i)=>r(s)-r(i))}var Li=new Set(["open","processing","underpaid"]),Bi=new Set(["loading","error","buyer","method","confirmWallet","pay","qr","underpaid","blocked"]);function ya(e,t,n){return Li.has(e)?t==="confirm"||t==="unconfirmed"?"confirming":Bi.has(t)?e==="underpaid"&&n===false?"closed":"paying":null:null}var Oi=[10,5,1];function Lo(e,t,n=Oi){if(e===null||t<=0)return null;let a=n.filter(o=>e>o*6e4&&t<=o*6e4);return a.length?Math.min(...a):null}var On=6e4;function Bo(e){let{autoPayOffOpen:t,phase:n,quotePayer:a,payer:o}=e;return t||n!=="awaitingPayment"||!a||o===a?"keep":o?"lock":"release"}function Oo(e){let{open:t,storePayer:n,payer:a,paysRest:o}=e;return !t||a===n?"keep":a&&o?"follow":"leave"}function Fo(e){return e>0&&e<=On}function _o(e){return e.amlScreening!==false}function nt(e){return e.paymentOnTheWay??!!(e.txKey||e.txHash)}function pt(e,t){let n=t?.invoice?.pendingPayments??0;return e.invoicePaymentOnTheWay??n>0}function Wo({state:e,checkout:t,handedOverAt:n,dueAt:a}){let o=e.paymentSentInTime,r=nt({paymentOnTheWay:e.paymentOnTheWay,txKey:e.txKey??null,txHash:e.txHash??null});if(typeof o=="boolean"&&r)return o;let s=t.invoice.paymentCountsUntil;return s===void 0?n!==null&&n<a:n!==null&&n>=a?false:(e.paymentCountsUntil===void 0?s:e.paymentCountsUntil)!==null}var Fn="settlement_failed",Do="tx_already_used";function Mo(e){let t=e?.code,n=e?.reason;return (t==="payment_failed"||t==="payment_mismatch")&&!!n&&n!==Fn}var Fi=new Set(["no_matching_transfer","reference_missing","too_early","tx_already_used","payer_mismatch","payer_unconfirmed","quote_changed","too_many_parts","too_many_transfers","below_minimum","native_from_contract_unverifiable","invoice_not_payable"]);function ut(e){let t=e?.code,n=e?.reason;return n===Fn?false:t==="payment_mismatch"?true:t==="payment_failed"&&n!==void 0&&Fi.has(n)}function qo(e){let t=e?.reason;return ut(e)&&t===Do}function Bt(e,t){let n=t?.invoice?.unresolvedPayments??0;return e.invoicePaymentUnresolved??n>0}function gt(e){let t=e?.code,{reason:n,rechecked:a,stillRead:o}=e??{};return t==="payment_failed"&&n==="unresolved_after_24h"?"closed":n===Fn&&(t==="payment_unconfirmed"||t==="payment_mismatch")?a===true?"settlementRetrying":"settlementFailed":t!=="payment_unconfirmed"?null:n==="nonce_spent_unexplained"?"nonceSpent":n==="unmined_after_24h"||o===true?"unmined":n===Do?"takenElsewhere":n==="submit_retrying"?"retrying":n==="submit_failed"?"notReceived":n===Ei?"invoiceFull":a===true?"rechecked":"contact"}function Uo(e,t){let{txKey:n}=e.error??{};if(n)return n;let a=t?.invoice?.rejectedPayments;return e.txHash??e.txKey??a?.[0]?.txKey??null}function Ho(e,t){return e.supportEmail?`mailto:${e.supportEmail}?subject=${encodeURIComponent(t)}`:e.website??null}var $o={nonceSpent:"unconfirmedNonceSpent",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"},Wi=new Set(["payer_mismatch","payer_unconfirmed"]);function Ot(e,t,n=""){if(ut(e)){let r=e.reason??"",s=e.held===true;if(r==="quote_changed")return c(t.pay.mismatchChargeHeld,{merchant:n});if(r==="too_many_parts")return c(t.pay.mismatchTooManyParts,{merchant:n});let i=Wi.has(r)?s?t.pay.mismatchOtherWalletHeld:t.pay.mismatchOtherWallet:s?t.pay.mismatchHeldElsewhere:qo(e)?t.pay.mismatchTakenElsewhere:t.pay.mismatch;return c(i,{merchant:n})}let a=gt(e),o=a?$o[a]:void 0;return o?c(t.outcome[o],{merchant:n}):null}var Di=["buyer","selectMethod","quoting","awaitingPayment"];function _n(e,t,n){if(n==="underpaid")return false;let a=gt(t);return Di.includes(e)&&!ut(t)&&!(a&&$o[a])}function Gt(e,t,n=""){let a=Ot(e,t,n);if(a!==null)return a;switch(e.code){case "screening_unavailable":return t.pay.screeningUnavailable;case "request_failed":return t.pay.noAnswer;case "amount_out_of_range":case "method_not_found":case "testnet_required":return t.method.methodUnavailable;case "payer_not_expected":return t.method.payerNotExpected;case "too_many_payments":return c(t.method.tooManyPayments,{merchant:n});case "too_many_payers":return c(t.method.tooManyPayers,{merchant:n});case "native_from_contract":return t.method.nativeFromSmartWallet;case "rate_limited":return t.method.rateLimited;case "price_unavailable":case "price_no_rpc":return t.method.priceUnavailable;case "consent_required":return t.method.consentRequired;case "payer_proof_required":case "payer_proof_declined":return t.payerProof.text;case "payer_proof_invalid":return t.payerProof.invalid;case "payer_proof_unavailable":return t.payerProof.unavailable;case "payment_failed":return t.method.paymentFailed;case "rest_method_mismatch":return t.method.restSameMethod;default:return t.error.generic}}function Wn(e){return e?.status==="available"?e:e?.status==="active"?e.replacement??null:null}function Ko(e,t){let n=Wn(e);if(!n)return null;let a=t.find(i=>i.id===n.methodId);if(!a)return null;let{request:o}=n,r=o.rules.find(i=>i.type==="expiry")?.data,s=o.rules.find(i=>i.type==="payee")?.data;return {chainId:`eip155:${Number.parseInt(o.chainId,16)}`,to:s?.addresses?.[0]??o.to,limit:BigInt(o.permission.data.periodAmount).toString(),decimals:a.decimals,symbol:a.symbol,periodSeconds:o.permission.data.periodDuration,expiresAt:r?.timestamp?r.timestamp*1e3:null}}function Ua(e,t){let n=e%86400===0;return new Intl.NumberFormat(t,{style:"unit",unit:n?"day":"hour",unitDisplay:"long"}).format(n?e/86400:Math.round(e/3600))}function Vo(e,t){if(!e||t===null)return null;let n=BigInt(e.cryptoAmountExpected)-BigInt(t);return n>0n?n.toString():null}function zt(e,t,n,a,o,r=n.pay.restRateEnded){let s=e?.rateHeldUntil?Date.parse(e.rateHeldUntil):null;if(s===null)return null;if(s<=t)return c(r,{merchant:a});let i=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(s);return c(n.pay.restRateUntil,{time:i,merchant:a})}function ot(e){return parseCaip10AccountId(e)?.address??e}function bt(e,t){let n=ot(e),a=ot(t);return n.startsWith("0x")?n.toLowerCase()===a.toLowerCase():n===a}function Go(e){return e&&/^\d+$/.test(e)&&BigInt(e)>0n?e:null}function zo(e){let t=BigInt(e.cryptoAmount),n=e.received?BigInt(e.received):null;if(n&&t>n&&(t-n)*200n>=n)return true;if(!e.atPaymentRate)return false;let a=BigInt(e.atPaymentRate);return a===0n?false:(t>a?t-a:a-t)*200n>=a}var Mi=new Set(["held","refunded","expired","cancelled","blocked","error"]);function Qo(e,t,n){return n?e==="paid"?t!==0:!Mi.has(e):true}var qi=new Set(["evm:coinbase","evm:baseaccount","evm:porto"]);function Ha(e){return !!(e&&qi.has(e.connectorType.toLowerCase()))}function jo(e,t){return e==="required"||e==="confirming"?true:e==="unless_relayed"&&t!=="relay"}async function Yo(e,t){let{payerProof:n}=e.getState();if(n==="required"||n==="confirming")return t(true),null;t(false);let a=await e.getState().requestQuote();return !a&&e.getState().error?.code==="payer_proof_required"&&t(true),a}var Ui=new Set(["payer_chain_mismatch","too_many_payers"]);function Qt(e){let t=e?.code;return t!==void 0&&(t.startsWith("payer_proof_")||Ui.has(t))}var Hi=new Set(["rate_limited","request_failed","origin_required","invoice_not_payable"]);function fa(e){let t=e?.code;return Qt(e)||t!==void 0&&Hi.has(t)}function jt(e,t,n,a){if(t==="declined")return c(n.payerProof.declined,a);if(t==="switchDeclined")return c(n.payerProof.switchDeclined,a);if(t==="unsupported")return c(n.payerProof.unsupported,a);if(t==="wrongNetwork"||t==="switchFailed")return c(n.payerProof.wrongNetwork,a);if(t==="notAuthorized")return c(n.pay.notAuthorized,a);if(t==="alreadyPending")return c(n.walletPrompt.stillWaiting,a);if(t)return c(n.payerProof.failed,a);switch(e?.code){case void 0:case "payer_proof_required":return null;case "payer_proof_declined":return c(n.payerProof.declined,a);case "payer_proof_invalid":return n.payerProof.invalid;case "payer_proof_unavailable":return n.payerProof.unavailable;case "payer_chain_mismatch":return c(n.payerProof.wrongNetwork,a);case "too_many_payers":return c(n.payerProof.tooManyWallets,a);case "rate_limited":return n.method.rateLimited;case "request_failed":return n.pay.noAnswer;default:return n.error.generic}}var wt=6e5;async function $a(e,t){let n,a=new Promise(o=>{n=setTimeout(()=>o(false),t);});try{return await Promise.race([e.then(()=>!0),a])}finally{clearTimeout(n);}}var ae="novapay:focus-visible:outline-2 novapay:focus-visible:outline-offset-2 novapay:focus-visible:outline-[var(--tuwa-text-accent)]",kt=`novapay:inline-flex novapay:h-7 novapay:min-w-7 novapay:items-center novapay:justify-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-1.5 novapay:text-[var(--tuwa-text-primary)] novapay:cursor-pointer novapay:transition-colors novapay:hover:bg-[var(--tuwa-bg-muted)] ${ae}`,O="novapay:font-mono novapay:tabular-nums",rt=`novapay-title ${O} novapay:m-0 novapay:text-base novapay:font-bold novapay:text-balance novapay:outline-none`,Ct={tabIndex:-1,"data-novapay-heading":""},Pt=`${O} novapay:inline-flex novapay:h-11 novapay:w-full novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border-0 novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-sm novapay:font-bold novapay:text-[var(--tuwa-text-on-accent)] novapay:no-underline novapay:transition-colors novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ae}`,Ka=`novapay:cursor-pointer novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-[length:inherit] novapay:font-semibold novapay:text-[var(--tuwa-text-accent)] novapay:underline ${ae}`,Yt=`${O} novapay:inline-flex novapay:h-11 novapay:w-full novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:text-sm novapay:font-bold novapay:text-[var(--tuwa-text-primary)] novapay:no-underline novapay:transition-colors novapay:hover:bg-[var(--tuwa-bg-muted)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ae}`;function Va(e){return e==="modal"?{frame:"novapay:sm:w-[min(760px,calc(100vw_-_2rem_-_2px))]",section:""}:{frame:"",section:`novapay:box-border ${e==="page"?"novapay:w-[880px]":"novapay:w-[760px]"} novapay:max-w-full`}}var Zo={default:{frame:"novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-col novapay:overflow-hidden novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:h-[680px] novapay:sm:flex-row",aside:"novapay:hidden novapay:w-[286px] novapay:shrink-0 novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-5 novapay:sm:block",main:"novapay:flex novapay:min-h-0 novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:min-h-0 novapay:flex-1 novapay:flex-col novapay:overflow-y-auto"},page:{frame:"novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-1 novapay:flex-col novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:min-h-[calc(var(--novapay-page-floor)_-_2px)] novapay:sm:flex-row",aside:"novapay-page-aside novapay:hidden novapay:w-[clamp(260px,36.4%,320px)] novapay:shrink-0 novapay:flex-col novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-5 novapay:sm:flex",main:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:flex-1 novapay:flex-col"}};function Jo(e){return e.length<=7?"novapay:text-[36px]":e.length<=10?"novapay:text-[30px]":e.length<=13?"novapay:text-[24px]":"novapay:text-[20px]"}function ce(e,t,n){let a=e.customization.classNames?.[t];return a?.({screen:e.screen,checkoutState:e.state,checkout:e.checkout,...n})}function St({children:e,labels:t}){let n=Ge(),a=t??n?.labels,o=useLabels(),r=useMemo(()=>({...o,trackingModal:{...o.trackingModal,progressIndicator:{created:a.confirm.sent,processing:a.confirm.confirming,succeed:a.confirm.paid}},statuses:{...o.statuses,confirmed:a.confirm.confirmed,failed:a.confirm.failed},actions:{...o.actions,viewOnExplorer:a.confirm.viewOnExplorer,copy:a.confirm.copyHash},txError:{...o.txError,copied:a.pay.copied}}),[o,a]);return jsx(NovaTransactionsLabelsProvider,{labels:r,children:e})}var _t=(e,t)=>e?ce(e,t):void 0;function va({walletId:e,icon:t}){let[n,a]=useState(null);return t&&t!==n&&Ln(t)?jsx("img",{src:t,alt:"",onError:()=>a(t),className:"novapay:block novapay:h-full novapay:w-full novapay:object-contain"}):jsx(WalletIcon,{walletName:e})}function Te({hash:e,chainId:t,explorerUrl:n,labels:a}){let o=Ge(),r=n??(t?o?.adapterFor(t.startsWith("solana:")?"solana":"eip155")?.explorerAddressUrl?.({chainId:t,address:e}):void 0);return jsx(St,{labels:a,children:jsx(HashLink,{hash:e,explorerUrl:r,variant:"compact",...o?.customization.childCustomizations?.hashLink})})}function Ga({walletId:e,walletIcon:t}){return !e&&!t?jsx(QuasarLoader,{size:48,accent:"var(--tuwa-pending-icon)"}):jsxs("span",{className:"novapay:relative novapay:flex novapay:h-20 novapay:w-20 novapay:items-center novapay:justify-center novapay:rounded-full novapay:border-2 novapay:border-[var(--tuwa-border-primary)]",children:[jsx("span",{className:"novapay:block novapay:h-11 novapay:w-11",children:jsx(va,{walletId:e??"",icon:t})}),jsx("span",{"aria-hidden":true,className:"novapay:absolute novapay:-inset-0.5 novapay:animate-spin novapay:rounded-full novapay:border-2 novapay:border-transparent novapay:border-t-[var(--tuwa-pending-text)] novapay:motion-reduce:animate-none"})]})}function xe({title:e,subtitle:t,children:n}){let a=Ge(),o=a?.display==="page";return jsxs("section",{className:cn("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-2.5 novapay:px-5 novapay:py-4",o&&"novapay-page-screen",_t(a,"screen")),children:[jsxs("div",{children:[jsx("h2",{...Ct,className:rt,children:typeof e=="string"?jsx(MorphText,{wrap:true,children:e}):e}),t&&jsx("p",{className:cn("novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",o&&"novapay-page-subtitle"),children:t})]}),n]})}function re({children:e}){let t=Ge(),n=useRef(null),a=t?.display==="page";return useEffect(()=>{let o=n.current,r=a?o?.ownerDocument.documentElement:o?.closest("[data-novapay-scroll]");if(!o||!r||typeof ResizeObserver>"u")return;let s=()=>r.style.scrollPaddingBottom=!a||getComputedStyle(o).position==="sticky"?`${o.offsetHeight+8}px`:"";s();let i=new ResizeObserver(s);return i.observe(o),()=>{i.disconnect(),r.style.scrollPaddingBottom="";}},[a]),jsx("footer",{ref:n,className:cn("novapay:empty:hidden novapay:sticky novapay:bottom-0 novapay:z-10 novapay:flex novapay:flex-col novapay:gap-2 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-5 novapay:pb-3.5 novapay:pt-3 novapay:text-center",a&&"novapay-page-footer",_t(t,"footer")),children:e})}function Zt({children:e,id:t}){let n=Ge()?.display==="page";return jsx("span",{id:t,className:cn(O,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",n&&"novapay-page-group"),children:e})}function J({busy:e,children:t,className:n,...a}){let o=Ge(),r=_t(o,"primaryButton"),s=o?.customization.components?.PrimaryButton;return s?jsx(s,{busy:e,className:cn(n,r),...a,children:t}):jsxs("button",{type:"button","aria-busy":e||void 0,...a,disabled:a.disabled||e,className:cn(Pt,n,r),children:[e&&jsx(QuasarLoader,{size:16,accent:"currentColor"}),typeof t=="string"?jsx(MorphText,{children:t}):t]})}function ee({children:e,className:t,...n}){let a=Ge();return jsx("button",{type:"button",...n,className:cn(Yt,t,_t(a,"secondaryButton")),children:e})}function Re({children:e}){return jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:e})}function we({children:e,className:t}){let n=Ge();return jsx("dl",{className:cn("novapay:m-0 novapay:flex novapay:w-full novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-left",t,_t(n,"detailsCard")),children:e})}function Z({children:e}){let t=Ge();return jsx("p",{role:"alert",className:cn("novapay:m-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-error-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-error-text)]",_t(t,"error")),children:e})}function ha({text:e,label:t,copiedLabel:n,children:a}){let[o,r]=useState(false);return useEffect(()=>{if(!o)return;let s=setTimeout(()=>r(false),2e3);return ()=>clearTimeout(s)},[o]),jsxs(Fragment,{children:[jsxs("button",{type:"button","aria-label":a?void 0:t,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>r(true),()=>{});},className:cn(kt,"novapay:min-h-6 novapay:min-w-6 novapay:text-xs"),children:[jsx(CopyIcon,{copied:o,className:"novapay:h-3.5 novapay:w-3.5"}),a]}),jsx("span",{role:"status",className:"novapay:sr-only",children:o?n:""})]})}function q({name:e,children:t}){let n=Ge();return jsxs("div",{className:cn("novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3 novapay:py-2 novapay:text-xs",n?.display==="page"&&"novapay-page-row",_t(n,"detailRow")),children:[jsx("dt",{className:"novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]",children:e}),jsx("dd",{className:cn(O,"novapay:m-0 novapay:min-w-0 novapay:text-right novapay:break-words"),children:t})]})}function mt({children:e,onClick:t,disabled:n}){return jsx("button",{type:"button",onClick:t,disabled:n,className:cn("novapay:disabled:cursor-default novapay:disabled:opacity-50 novapay:min-h-6 novapay:cursor-pointer novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-xs novapay:text-[var(--tuwa-text-accent)] novapay:underline novapay:hover:no-underline",ae),children:e})}function Wt({kind:e,walletName:t,walletId:n,walletIcon:a,amount:o,merchant:r,network:s,to:i,priceTime:c$1,onRetry:p,text:u,details:d,hint:x,onCancel:b,stepHeight:h}){let{labels:m,display:N}=_(),v=useId(),w=useRef(null);useEffect(()=>w.current?.focus(),[e]);let[f]=useState(()=>typeof document>"u"?null:document.activeElement);useEffect(()=>()=>{let y=f?.ownerDocument;if(!f||!y||f===y.body||!f.isConnected)return;let g=y.activeElement;g&&g!==y.body&&!g.contains(f)||f.focus();},[f]);let k={wallet:t,amount:o,merchant:r,network:s},R=e==="sign"||e==="proof"?m.walletPrompt.signIn:e==="switch"?m.walletPrompt.switchIn:e==="submitting"?m.walletPrompt.submitting:e==="permission"?m.autoPay.approveIn:m.walletPrompt.confirmIn;return jsxs("section",{"aria-labelledby":v,style:h?{"--novapay-step-height":`${h}px`}:void 0,className:cn("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center-safe novapay:gap-3 novapay:bg-[var(--tuwa-bg-primary)] novapay:px-6 novapay:py-5 novapay:text-center",h&&(N==="page"?"novapay:min-h-[var(--novapay-step-height)]":"novapay:max-sm:min-h-[var(--novapay-step-height)]")),children:[jsx(Ga,{walletId:n,walletIcon:a}),jsx("h2",{id:v,ref:w,tabIndex:-1,className:rt,children:c(R,k)}),(e==="sign"||e==="confirm"||e==="proof")&&jsxs(Fragment,{children:[jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:u??c(e==="confirm"?m.walletPrompt.confirmText:m.walletPrompt.signText,k)}),x&&jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:x}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-xs novapay:flex-col novapay:gap-1.5 novapay:text-left",children:[jsx("span",{className:"novapay:text-[11px] novapay:font-semibold",children:c(m.walletPrompt.check,k)}),jsx(we,{children:d?d.map(y=>jsx(q,{name:y.name,children:y.value},y.name)):jsxs(Fragment,{children:[jsx(q,{name:m.walletPrompt.amount,children:o}),jsx(q,{name:m.walletPrompt.to,children:i}),jsx(q,{name:m.walletPrompt.network,children:s}),c$1&&jsx(q,{name:m.walletPrompt.priceLocked,children:c$1})]})})]}),p?jsxs("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[m.walletPrompt.notOpened," ",jsx(mt,{onClick:p,children:m.walletPrompt.tryAgain})]}):jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(m.walletPrompt.stillWaiting,k)})]}),e==="permission"&&jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:m.autoPay.walletNote}),e!=="submitting"&&jsx(ee,{onClick:b,className:"novapay:max-w-xs",children:m.walletPrompt.cancel})]})}var ja=class extends Error{};function sr(){let{checkout:e,state:t,store:n,labels:a,locale:o,wallet:r,adapterFor:s,setAutoPay:i,connectFamily:c$1}=_(),[p,u]=useState("idle"),[d,x]=useState(null),b=r?.address,[h,m]=useState(b);h!==b&&(m(b),x(null),u("idle"));let N=useRef(0);useEffect(()=>{N.current++;let{error:ue,clearError:T}=n.getState();ue&&(Qt(ue)||ue.code==="permission_invalid")&&T();},[b]);let v=useRef(null),w=useRef(null),f=useRef(null),k=p!=="idle"&&r!==null,[R,y]=Vt(k),g=Wn(e?.autoCharge??null),P=g?e?.methods.find(ue=>ue.id===g.methodId):void 0,A=P?Oe(P):null,C=A?s(A):void 0,B=e?Ko(e.autoCharge,e.methods):null,[G,D]=useState(null),ne=xt(B&&r&&C?.smartAccountStatus&&G!==r.address?`${B.chainId}:${r.address}`:null,()=>C.smartAccountStatus({chainId:B.chainId,account:r.address}));if(!e)return null;let $=e.merchant.name,z=ne==="upgradable"&&!!C?.upgradeToSmartAccount,Q=async()=>{if(!g||!B||!r||!C?.requestPermission)return x("unsupported");let{requestPermission:ue}=C,T=++N.current,F=()=>N.current===T,L=r.address;x(null),n.getState().clearError();try{if(r.chainId!==B.chainId&&C.switchChain&&(u("switching"),await C.switchChain(B.chainId),!F()))return;if(z){u("upgrading");try{if(w.current?.account!==L){let se={account:L,done:C.upgradeToSmartAccount({chainId:B.chainId,account:L}).then(Ke=>(D(L),Ke))};w.current=se;let le=()=>{w.current===se&&(w.current=null);};se.done.then(le,le);}await w.current?.done;}catch(se){throw b$1(se)==="failed"?new ja:se}if(!F())return}u("permission");let K=f.current?.account===L?f.current.granted:null;if(!K){if(v.current?.account!==L){let Ne=ue({request:g.request,account:L}),ct={account:L,asked:Ne};v.current=ct;let Ae=()=>{v.current===ct&&(v.current=null);};Ne.then(Ae,Ae);}let se=v.current,le=null;if(!await $a(se.asked.then(Ne=>{le=Ne;}),6e5)||!le){v.current===se&&(v.current=null),F()&&x("alreadyPending");return}K=le,f.current={account:L,granted:K};}if(await n.getState().grantPermission({payer:`${B.chainId}:${L}`,...K},C.signMessage&&((se,le)=>(F()&&u("proof"),C.signMessage({message:se,account:L,chainId:le.chainId}))))){f.current=null,F()&&i(!1);return}n.getState().error?.code==="permission_invalid"&&(f.current=null);}catch(K){if(!F())return;x(K instanceof ja?"smartAccount":b$1(K));}finally{F()&&u("idle");}},X={wallet:r?.name??"",network:B?fe(B.chainId):"",merchant:$},S=t.error,M=S?S.code==="permission_invalid"?S.reason==="wallet_unknown"?c(a.autoPay.smartAccountNeeded,X):a.autoPay.invalid:Qt(S)?jt(S,null,a,X):Gt(S,a,$):null,oe=d==="declined"?c(a.pay.declined,X):d==="unsupported"?c(a.autoPay.unavailable,X):d==="smartAccount"?c(a.autoPay.smartAccountNeeded,X):d==="wrongNetwork"||d==="switchFailed"?c(a.pay.switchFailed,X):d==="notAuthorized"?c(a.pay.notAuthorized,X):d==="alreadyPending"?c(a.walletPrompt.stillWaiting,X):d==="cannotConnect"?a.pay.connectUnavailable:d?c(a.autoPay.notGranted,X):M;return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:R,inert:k,className:cn("novapay:flex novapay:flex-1 novapay:flex-col",k&&"novapay:hidden"),children:[jsxs(xe,{title:a.autoPay.title,subtitle:a.autoPay.subtitle,children:[B&&jsxs(Fragment,{children:[jsxs("div",{className:"novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(a.autoPay.allow,{merchant:$})}),jsxs("p",{className:cn(O,"novapay:m-0 novapay:text-lg novapay:font-bold"),children:[c(a.autoPay.limit,{amount:`${ye(B.limit,B.decimals,o)} ${B.symbol}`})," ",jsx("span",{className:"novapay:text-sm novapay:font-normal",children:c(a.autoPay.every,{period:Ua(B.periodSeconds,o)})})]})]}),jsxs(we,{children:[r&&jsx(q,{name:a.autoPay.from,children:jsxs("span",{className:"novapay:inline-flex novapay:items-center novapay:gap-1",children:[jsx(Te,{hash:r.address,chainId:B.chainId})," \xB7 ",fe(B.chainId)]})}),jsxs(q,{name:a.autoPay.to,children:[jsx(Te,{hash:B.to,chainId:B.chainId}),jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:$})]}),B.expiresAt&&jsx(q,{name:a.autoPay.validUntil,children:c(a.autoPay.validUntilValue,{date:new Intl.DateTimeFormat(o,{dateStyle:"medium"}).format(B.expiresAt)})})]}),jsxs("ul",{className:"novapay:m-0 novapay:flex novapay:list-disc novapay:flex-col novapay:gap-1 novapay:pl-4 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsx("li",{children:c(a.autoPay.collector,{merchant:$})}),jsx("li",{children:a.autoPay.invoices}),jsx("li",{children:c(a.autoPay.cap,{merchant:$})}),jsx("li",{children:c(a.autoPay.turnOff,{merchant:$})})]})]}),z&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:c(a.autoPay.smartAccountNote,X)}),oe&&jsx(Z,{children:oe})]}),jsxs(re,{children:[r?jsx(J,{busy:k,disabled:!B,onClick:()=>{Q();},children:a.autoPay.confirm}):jsx(J,{disabled:!A,onClick:()=>{A&&!c$1(A)&&x("cannotConnect");},children:a.pay.connect}),jsx(ee,{onClick:()=>i(false),children:a.autoPay.skip}),jsx(Re,{children:a.autoPay.walletNote})]})]}),k&&r&&jsx(Wt,{kind:p==="switching"?"switch":p==="upgrading"?"confirm":p==="proof"?"proof":"permission",walletName:r.name,walletId:r.walletId,walletIcon:r.icon,amount:"",merchant:$,network:X.network,to:"",priceTime:null,text:p==="upgrading"?c(a.autoPay.smartAccountPrompt,X):p==="proof"?c(a.payerProof.promptText,{...X,invoice:e.invoice.number??e.invoice.id}):void 0,details:p==="upgrading"?[{name:a.autoPay.from,value:shortAddress(r.address)},{name:a.walletPrompt.network,value:X.network}]:p==="proof"?[{name:a.payerProof.invoice,value:e.invoice.number??e.invoice.id},{name:a.payerProof.merchant,value:$}]:void 0,onCancel:()=>{N.current++,u("idle");},stepHeight:y})]})}var oc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ir="AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" "),rc=new Set(ir);function Dn(e,t){let n=e==="full"||t,a=[{name:"email",required:true,autoComplete:"email",type:"email"}];return n?[...a,{name:"name",required:true,autoComplete:t?"organization":"name",type:"text"},{name:"country",required:true,autoComplete:"country",type:"country"},{name:"addressLine1",required:true,autoComplete:"address-line1",type:"text"},{name:"addressLine2",required:false,autoComplete:"address-line2",type:"text"},{name:"postalCode",required:false,autoComplete:"postal-code",type:"text"},{name:"city",required:false,autoComplete:"address-level2",type:"text"},...t?sc():[]]:a}var sc=()=>[{name:"taxId",required:true,autoComplete:"off",type:"text"},{name:"registrationNumber",required:false,autoComplete:"off",type:"text"}];function cr(e,t,n){let a={};for(let o of Dn(t,n)){let r=e[o.name]?.trim()??"";r?o.type==="email"&&!oc.test(r)?a[o.name]="email":o.type==="country"&&!rc.has(r.toUpperCase())&&(a[o.name]="country"):o.required&&(a[o.name]="required");}return a}function lr(e){let t={};for(let[n,a]of Object.entries(e)){let o=a?.trim();o&&(t[n]=n==="country"?o.toUpperCase():o);}return t}function pr(e){let t=new Intl.DisplayNames([e],{type:"region"});return ir.map(n=>({code:n,name:t.of(n)??n})).sort((n,a)=>n.name.localeCompare(a.name,e))}var uc=(e,t,n)=>t==="name"&&n?e.buyer.companyName:e.buyer[t]??t,mc=(e,t)=>t==="email"?e.buyer.invalidEmail:t==="country"?e.buyer.invalidCountry:e.buyer.required,dc=new Set(["postalCode","city","taxId","registrationNumber"]),yc=new Set(["name","country","addressLine1","addressLine2"]),ur=e=>cn("novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-[13px] novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:focus:border-[var(--tuwa-text-accent)]",e?"novapay:border-[var(--tuwa-error-icon)]":"novapay:border-[var(--tuwa-text-secondary)] novapay:hover:border-[var(--tuwa-text-primary)]",ae);function mr(){let{checkout:e,state:t,store:n,labels:a,locale:o,display:r}=_(),[s,i]=useState({}),[c,p]=useState(false),[u,d]=useState(false),[x,b]=useState(false),h=useId(),m=useMemo(()=>pr(o),[o]);if(!e||e.buyer.collect==="off")return null;let N=e.buyer.collect,v=Dn(N,c),w=cr(s,N,c),f=(R,y)=>i(g=>({...g,[R]:y})),k=async R=>{if(R.preventDefault(),d(true),Object.keys(w).length>0){document.getElementById(`${h}-${Object.keys(w)[0]}`)?.focus();return}b(true),await n.getState().setBuyer(lr(s),{company:c}),b(false);};return jsxs("form",{noValidate:true,onSubmit:R=>{k(R);},className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(xe,{title:a.buyer.title,subtitle:a.buyer.subtitle,children:[jsx("div",{className:"novapay:grid novapay:grid-cols-1 novapay:gap-x-3 novapay:gap-y-3.5 novapay:pt-1 novapay:sm:grid-cols-2",children:v.map((R,y)=>{let g=`${h}-${R.name}`,P=u?w[R.name]:void 0,A=R.type==="country"?jsxs("div",{className:"novapay:relative",children:[jsxs("select",{id:g,autoComplete:R.autoComplete,required:R.required,"aria-invalid":!!P,"aria-describedby":P?`${g}-error`:void 0,value:s.country??"",onChange:C=>f("country",C.target.value),className:cn(ur(!!P),"novapay:cursor-pointer novapay:appearance-none novapay:pr-9",!s.country&&"novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("option",{value:"",children:a.buyer.chooseCountry}),m.map(C=>jsx("option",{value:C.code,children:C.name},C.code))]}),jsx(ChevronDownIcon,{"aria-hidden":true,className:"novapay:pointer-events-none novapay:absolute novapay:top-1/2 novapay:right-3 novapay:h-4 novapay:w-4 novapay:-translate-y-1/2 novapay:text-[var(--tuwa-text-secondary)]"})]}):jsx("input",{id:g,type:R.type,autoComplete:R.autoComplete,required:R.required,"aria-invalid":!!P,"aria-describedby":P?`${g}-error`:void 0,value:s[R.name]??"",onChange:C=>f(R.name,C.target.value),className:ur(!!P)});return jsxs(Fragment$1,{children:[jsxs("div",{className:cn("novapay:flex novapay:flex-col novapay:gap-1.5",!dc.has(R.name)&&(r==="page"&&yc.has(R.name)?"novapay:sm:@max-[519px]:col-span-2":"novapay:sm:col-span-2")),children:[jsxs("label",{htmlFor:g,className:"novapay:text-xs novapay:font-medium novapay:text-[var(--tuwa-text-primary)]",children:[uc(a,R.name,c),R.required&&jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]}),!R.required&&jsxs("span",{className:"novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:[" ","(",a.buyer.optional,")"]})]}),A,P&&jsx("span",{id:`${g}-error`,className:"novapay:text-[11px] novapay:text-[var(--tuwa-error-text)]",children:mc(a,P)})]}),y===0&&e.buyer.companyInvoice&&jsxs("label",{className:cn("novapay:flex novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:text-[13px] novapay:transition-colors novapay:sm:col-span-2",c?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-text-secondary)]"),children:[jsx("input",{type:"checkbox",checked:c,onChange:C=>p(C.target.checked),className:cn("novapay:h-4 novapay:w-4 novapay:shrink-0 novapay:accent-[var(--tuwa-text-accent)]",ae)}),jsx("span",{className:"novapay:font-semibold",children:a.buyer.companyInvoice})]})]},R.name)})}),t.error&&t.phase==="buyer"&&jsx(Z,{children:a.buyer.refused})]}),jsx(re,{children:jsx(J,{type:"submit",busy:x,children:a.buyer.continue})})]})}function yr({steps:e,labels:t,className:n,stepClassName:a}){let o=e.findIndex(u=>u.state==="current"),r=e.map(u=>t.steps[u.key]).join(""),s=useRef(null),i=useRef(null),[c$1,p]=useState(false);return useEffect(()=>{let u=s.current,d=i.current;if(!u||!d||typeof ResizeObserver>"u")return;let x=()=>p(d.offsetWidth+e.length*32+(e.length-1)*24>u.clientWidth);x();let b=new ResizeObserver(x);return b.observe(u),()=>b.disconnect()},[r,e.length]),jsxs("nav",{ref:s,"aria-label":t.steps.label,className:cn("novapay:relative novapay:min-w-0 novapay:flex-1",n),children:[jsx("span",{"aria-hidden":true,className:"novapay:invisible novapay:absolute novapay:h-0 novapay:w-0 novapay:overflow-hidden",children:jsx("span",{ref:i,className:cn(O,"novapay:whitespace-nowrap novapay:text-[11px] novapay:font-bold"),children:r})}),jsx("ol",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:items-center novapay:gap-1.5 novapay:p-0",children:e.map((u,d)=>{let x=t.steps[u.key];return jsxs("li",{"aria-current":u.state==="current"?"step":void 0,className:cn("novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-1.5",d>0&&"novapay:flex-auto",a?.(u,d)),children:[d>0&&jsx("span",{"aria-hidden":true,className:cn("novapay:h-0.5 novapay:min-w-2 novapay:flex-1 novapay:rounded-full novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",u.state==="upcoming"?"novapay:bg-[var(--tuwa-border-primary)]":"novapay:bg-[var(--tuwa-success-icon)]")}),jsx("span",{"aria-hidden":true,className:cn(O,"novapay:flex novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-full novapay:text-[10px] novapay:font-bold",u.state==="done"&&"novapay:bg-[var(--tuwa-success-icon)] novapay:text-white",u.state==="current"&&"novapay:border-2 novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",u.state==="upcoming"&&"novapay:border-2 novapay:border-[var(--tuwa-border-primary)] novapay:text-[var(--tuwa-text-secondary)]"),children:u.state==="done"?jsx(DrawnCheck,{className:"novapay:h-3 novapay:w-3"}):d+1}),jsx("span",{className:cn(O,"novapay:truncate novapay:text-[11px]",u.state==="current"?"novapay:font-bold novapay:text-[var(--tuwa-text-primary)]":"novapay:text-[var(--tuwa-text-secondary)]",c$1&&u.state!=="current"&&"novapay:sr-only"),children:u.state==="current"?jsxs(Fragment,{children:[jsx("span",{className:"novapay:sr-only",children:c(t.steps.progress,{current:o+1,total:e.length,name:x})}),jsx("span",{"aria-hidden":true,children:x})]}):x})]},u.key)})})]})}function Xt(e){let t=e.lineItems.reduce((r,s)=>r+BigInt(s.netMinor),0n),n=BigInt(e.totalMinor??t.toString()),a=n-t,o=[...new Set(e.lineItems.filter(r=>Number(r.taxRate)>0).map(r=>r.taxRate))];return {subtotal:Be(t.toString()),tax:a>0n?Be(a.toString()):null,rate:o.length===1?String(Number(o[0])):null,total:Be(n.toString())}}var Cc=e=>{try{return new URL(e).host}catch{return e}};function Za({compact:e=false}){let{checkout:t,state:n,labels:a,display:o}=_(),[r,s]=useState(false);if(!t)return null;let{merchant:i,invoice:c}=t,p=e?"novapay:h-8 novapay:w-8":"novapay:h-9 novapay:w-9";return jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-2.5",children:[n.logoUrl&&!r?jsx("img",{src:n.logoUrl,alt:"",onError:()=>s(true),className:cn(p,"novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:object-contain")}):jsx("span",{"aria-hidden":true,className:cn(p,O,"novapay:flex novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-text-primary)] novapay:text-[15px] novapay:font-bold novapay:text-[var(--tuwa-bg-primary)]"),children:i.name.trim().charAt(0).toUpperCase()}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:cn("novapay:text-sm novapay:font-semibold",o==="page"&&!e?"novapay:line-clamp-2 novapay:break-words":"novapay:truncate"),children:i.name}),e?c.number&&jsx("span",{className:cn(O,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c.number}):i.website&&jsx("a",{href:i.website,target:"_blank",rel:"noopener noreferrer",className:cn("novapay:truncate novapay:text-xs novapay:text-[var(--tuwa-text-secondary)] novapay:hover:underline",ae),children:Cc(i.website)})]}),c.environment==="test"&&jsxs("span",{title:a.summary.testHint,className:cn(O,"novapay:ml-auto novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-pending-bg)] novapay:px-1.5 novapay:py-0.5 novapay:text-[10px] novapay:font-bold novapay:uppercase novapay:tracking-wider novapay:text-[var(--tuwa-pending-text)]"),children:[a.summary.test,jsxs("span",{className:"novapay:sr-only",children:[": ",a.summary.testHint]})]})]})}function qn({checkout:e,labels:t}){let{merchant:n}=e,a=n.seller,o=[[t.summary.terms,n.links.terms],[t.summary.refundPolicy,n.links.refundPolicy],[t.summary.privacy,n.links.privacy]].filter(r=>!!r[1]);return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:[a?.legalName&&jsx("span",{className:"novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)]",children:a.legalName}),(a?.address||a?.country)&&jsx("span",{children:[a.address,a.country].filter(Boolean).join(", ")}),a?.registrationNumber&&jsxs("span",{children:[t.summary.registration," ",a.registrationNumber]}),a?.taxId&&jsxs("span",{children:[t.summary.taxId," ",a.taxId]}),n.supportEmail&&jsx("a",{href:`mailto:${n.supportEmail}`,className:cn("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ae),children:n.supportEmail}),o.length>0&&jsx("span",{className:"novapay:flex novapay:flex-wrap novapay:gap-x-3",children:o.map(([r,s])=>jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:cn("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ae),children:r},r))}),jsx("span",{children:c(t.summary.sellerRole,{seller:a?.legalName||n.name})})]})}function xr(){let{checkout:e,labels:t,locale:n,now:a,screen:o,display:r}=_(),s=e?.invoice.dueAt,i=e&&ya(e.invoice.status,o,e.invoice.restPayable);if(!e||!s||!i)return null;let c$1=new Intl.DateTimeFormat(n,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(s));return jsxs("div",{className:cn("novapay:flex novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5",r==="page"&&"novapay-page-deadline"),children:[jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-0.5",children:[jsx("span",{className:cn(O,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:i==="closed"?t.summary.refundAfter:t.summary.payWithin}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:i==="closed"?c$1:c(t.summary.until,{date:c$1})})]}),jsx("span",{role:"timer",className:cn(O,"novapay:shrink-0 novapay:whitespace-nowrap novapay:text-lg novapay:font-bold"),children:at(Date.parse(s)-a)})]})}function gr(){let{checkout:e,labels:t,locale:n}=_();if(!e)return null;let{invoice:a}=e,o=Xt(a);return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3.5",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2.5",children:[a.number&&jsxs("div",{className:cn(O,"novapay:flex novapay:justify-between novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("span",{children:t.summary.invoice}),jsx("span",{children:a.number})]}),jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-2.5 novapay:p-0",children:a.lineItems.map((r,s)=>jsxs("li",{className:"novapay:flex novapay:justify-between novapay:gap-2 novapay:text-[13px]",children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:r.name}),r.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:r.description}),jsx("span",{className:cn(O,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:r.quantity,price:be(r.unitPrice,n)})})]}),jsx("span",{className:O,children:be(Be(r.netMinor),n)})]},s))})]}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:border-t novapay:border-dashed novapay:border-[var(--tuwa-border-primary)] novapay:pt-2.5 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn(O,"novapay:m-0"),children:be(o.subtotal,n)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn(O,"novapay:m-0"),children:be(o.tax,n)})]})]})]})}function Pc(){let e=_(),{checkout:t,labels:n,locale:a}=e;return t?jsxs("div",{className:cn("novapay:flex novapay:items-baseline novapay:justify-between",ce(e,"total")),children:[jsx("span",{className:cn(O,"novapay:text-xs novapay:font-bold"),children:n.summary.total}),jsxs("span",{className:cn(O,"novapay:text-[22px] novapay:font-bold"),children:[be(Xt(t.invoice).total,a)," ",jsx("span",{className:"novapay:text-[13px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]}):null}function br(){let{checkout:e,labels:t}=_();return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("span",{className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(LockClosedIcon,{"aria-hidden":true,className:"novapay:h-3 novapay:w-3"}),t.summary.secured]}),e?.merchant.supportEmail&&jsxs("span",{children:[t.summary.help,":"," ",jsx("a",{href:`mailto:${e.merchant.supportEmail}`,className:cn("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ae),children:e.merchant.supportEmail})]})]})}function Ja({label:e,children:t,className:n,buttonClassName:a,growsUp:o=false}){let[r,s]=useState(false),i=useId();return jsxs("div",{className:cn("novapay:flex novapay:flex-col novapay:gap-2",n),children:[jsxs("button",{type:"button","aria-expanded":r,"aria-controls":i,onClick:()=>s(c=>!c),className:cn("novapay:inline-flex novapay:cursor-pointer novapay:items-center novapay:gap-1 novapay:self-start novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)] novapay:hover:text-[var(--tuwa-text-primary)]",ae,a),children:[e,jsx(ChevronDownIcon,{"aria-hidden":true,className:cn("novapay:h-3 novapay:w-3 novapay:transition-transform novapay:motion-reduce:transition-none",r!==o&&"novapay:rotate-180")})]}),jsx("div",{id:i,hidden:!r,children:t})]})}var fr=5;function Sc(){let e=_(),{checkout:t,labels:n,locale:a}=e;if(!t)return null;let o=be(Xt(t.invoice).total,a);return jsxs("div",{className:cn("novapay:flex novapay:flex-col novapay:gap-1.5",ce(e,"total")),children:[jsx("span",{className:cn(O,"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]"),children:n.summary.total}),jsxs("span",{className:cn(O,"novapay:flex novapay:flex-wrap novapay:items-baseline novapay:gap-x-2 novapay:gap-y-1 novapay:font-bold",Jo(o)),children:[jsx("span",{children:o}),jsx("span",{className:"novapay:text-[15px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]})}var wr="novapay:flex novapay:justify-between novapay:gap-3 novapay:px-3 novapay:py-2";function vr({line:e}){let{labels:t,locale:n}=_(),a=be(Be(e.netMinor),n),o=be(e.unitPrice,n);return jsxs("li",{className:cn(wr,"novapay:text-[13px]"),children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:e.name}),e.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:e.description}),(Number(e.quantity)!==1||o!==a)&&jsx("span",{className:cn(O,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:e.quantity,price:o})})]}),jsx("span",{className:cn(O,"novapay:shrink-0"),children:a})]})}function Nc(){let{checkout:e,labels:t,locale:n}=_();if(!e)return null;let{invoice:a}=e,o=Xt(a),r=o.tax?fr-1:fr,s=a.lineItems,i=s.length>r?s.slice(0,r-1):s,c$1=s.slice(i.length);return !a.number&&s.length===0?null:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)]",children:[a.number&&jsxs("div",{className:cn(O,wr,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("span",{children:t.summary.invoice}),jsx("span",{className:"novapay:min-w-0 novapay:break-all novapay:text-right",children:a.number})]}),i.length>0&&jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:i.map((p,u)=>jsx(vr,{line:p},u))}),c$1.length>0&&jsx(Ja,{label:`+${c$1.length} \xB7 ${t.summary.showOrder}`,className:"novapay:px-3 novapay:py-2",buttonClassName:"novapay:min-h-6",children:jsx("ul",{className:"novapay:-mx-3 novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:c$1.map((p,u)=>jsx(vr,{line:p},u))})}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn(O,"novapay:m-0"),children:be(o.subtotal,n)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn(O,"novapay:m-0"),children:be(o.tax,n)})]})]})]})}function Tc(){let{checkout:e,labels:t}=_();return e?jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx(Za,{}),jsx("div",{className:"novapay:mt-6",children:jsx(Sc,{})}),jsx("div",{className:"novapay:mt-5",children:jsx(Nc,{})}),jsxs("div",{className:"novapay:mt-auto novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-5",children:[jsx(xr,{}),jsx(Ja,{label:t.summary.sellerDetails,buttonClassName:"novapay:min-h-6",growsUp:true,children:jsx(qn,{checkout:e,labels:t})}),jsx(br,{})]})]}):null}function kr(){let{checkout:e,labels:t,display:n}=_();return e?n==="page"?jsx(Tc,{}):jsxs("div",{className:"novapay:flex novapay:h-full novapay:flex-col novapay:gap-3.5",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsx(Za,{}),jsx(Ja,{label:t.summary.sellerDetails,children:jsx(qn,{checkout:e,labels:t})})]}),jsx(xr,{}),jsx("div",{className:"novapay:-mr-2.5 novapay:min-h-0 novapay:flex-1 novapay:overflow-y-auto novapay:pr-2.5",children:jsx(gr,{})}),jsx(Pc,{}),jsx(br,{})]}):null}function Cr({className:e}={}){let{checkout:t,labels:n,locale:a,now:o,screen:r}=_();if(!t)return null;let{invoice:s}=t,i=Xt(s),c=s.dueAt&&ya(s.status,r)?Date.parse(s.dueAt):null;return jsxs("div",{className:cn("novapay:mx-4 novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-3",e),children:[jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsxs("span",{className:cn(O,"novapay:text-[22px] novapay:font-bold"),children:[be(i.total,a)," ",jsx("span",{className:"novapay:text-xs novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:s.currency})]}),c&&jsxs("span",{role:"timer",className:cn(O,"novapay:flex novapay:items-center novapay:gap-1 novapay:whitespace-nowrap novapay:text-xs novapay:font-bold"),children:[jsx(ClockIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-secondary)]"}),at(c-o)]})]}),jsx(Ja,{label:`${b(i.tax?{one:n.summary.compactOne,other:n.summary.compact}:{one:n.summary.compactNoTaxOne,other:n.summary.compactNoTax},s.lineItems.length,a,i.tax?{tax:be(i.tax,a)}:{})} \xB7 ${n.summary.showOrder}`,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-1",children:[jsx(gr,{}),jsx(qn,{checkout:t,labels:n})]})})]})}function Sr({locale:e$1,labels:t,receiptIssued:n,onSelect:a,className:o}){let[r,s]=useState(false),i=e.find(w=>w.code===e$1)??e[0],[c$1,p]=useState(0),u=useId(),d=useRef(null),x=useRef(null),b=useRef(null);useEffect(()=>{if(!r)return;b.current?.focus();let w=f=>{d.current?.contains(f.target)||s(false);};return document.addEventListener("pointerdown",w),()=>document.removeEventListener("pointerdown",w)},[r]);let h=()=>{p(Math.max(0,e.indexOf(i))),s(true);},m=()=>{s(false),x.current?.focus();},N=w=>{m(),w!==i.code&&a(w);},v=w=>{let f=e.length-1,k={ArrowDown:()=>Math.min(f,c$1+1),ArrowUp:()=>Math.max(0,c$1-1),Home:()=>0,End:()=>f};k[w.key]?(w.preventDefault(),p(k[w.key]())):w.key==="Enter"||w.key===" "?(w.preventDefault(),N(e[c$1].code)):(w.key==="Escape"||w.key==="Tab")&&(w.preventDefault(),w.stopPropagation(),m());};return jsxs("div",{ref:d,className:cn("novapay:relative",o),children:[jsxs("button",{ref:x,type:"button","aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?`${u}-list`:void 0,className:cn(kt,O,"novapay:text-[11px] novapay:font-semibold"),onClick:()=>r?m():h(),onKeyDown:w=>{w.key==="ArrowDown"&&!r&&(w.preventDefault(),h());},children:[jsx(GlobeAltIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),jsx("span",{children:i.short}),jsxs("span",{className:"novapay:sr-only",children:[", ",c(t.language.button,{language:i.name})]}),jsx(ChevronDownIcon,{"aria-hidden":true,className:"novapay:h-3 novapay:w-3"})]}),r&&jsxs("div",{className:"novapay:absolute novapay:right-0 novapay:top-full novapay:z-20 novapay:mt-1.5 novapay:w-60 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-1.5 novapay:shadow-xl",children:[jsx("span",{id:`${u}-title`,className:cn(O,"novapay:block novapay:px-2.5 novapay:py-1 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:t.language.title}),jsx("ul",{ref:b,id:`${u}-list`,role:"listbox",tabIndex:-1,"aria-labelledby":`${u}-title`,"aria-activedescendant":`${u}-${e[c$1].code}`,onKeyDown:v,className:cn("novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-0.5 novapay:p-0",ae),children:e.map((w,f)=>{let k=w.code===i.code;return jsxs("li",{id:`${u}-${w.code}`,role:"option","aria-selected":k,lang:w.code,onClick:()=>N(w.code),onPointerMove:()=>p(f),className:cn("novapay:flex novapay:h-8 novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:px-2.5 novapay:text-[13px]",f===c$1&&"novapay:bg-[var(--tuwa-bg-muted)]","novapay:text-[var(--tuwa-text-primary)]",k&&"novapay:font-semibold"),children:[jsx("span",{"aria-hidden":true,className:cn(O,"novapay:w-5 novapay:text-[11px]"),children:w.short}),jsx("span",{children:w.name}),k&&jsx(DrawnCheck,{className:"novapay:ml-auto novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-accent)]"})]},w.code)})}),jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:px-2.5 novapay:pb-1 novapay:pt-2 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:n?t.language.noteAfterPaid:t.language.note})]})]})}var Nr=(e,t)=>Io(e.screen,{withDetails:t})??(e.display==="page"&&e.screen==="paid"?Eo({withDetails:t}):null);function Tr(e,t,n){let a=e.customization.components?.Stepper??yr;return jsx(a,{steps:t,labels:e.labels,className:cn(n,ce(e,"stepper")),stepClassName:(o,r)=>ce(e,"step",{step:o,index:r})})}function Rr({title:e,withDetails:t}){let n=_(),{labels:a,locale:o,store:r,close:s,state:i}=n,c=n.display==="page",p=n.customization.config?.showSteps===false?null:Nr(n,t),u=ce(n,"header"),d=n.customization.handlers?.onLocaleChange,x=async h=>{await r.getState().setLocale(h);},b=jsxs("div",{className:"novapay:ml-auto novapay:flex novapay:shrink-0 novapay:items-center novapay:gap-2",children:[jsx(Sr,{locale:o,labels:a,receiptIssued:!!i.receiptUrl,onSelect:h=>{d?d({locale:h,proceed:()=>x(h)}):x(h);}}),s&&jsx("button",{type:"button","aria-label":a.common.close,onClick:s,className:kt,children:jsx(XMarkIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"})})]});return jsxs(Fragment,{children:[jsxs("header",{className:cn("novapay:hidden novapay:items-center novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:py-3.5 novapay:pl-5 novapay:pr-4 novapay:sm:flex",c&&"novapay-page-header",u),children:[p?Tr(n,p):e&&jsx("h2",{className:cn(O,"novapay:m-0 novapay:flex-1 novapay:text-[15px] novapay:font-bold"),children:e}),b]}),jsxs("header",{className:cn("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-4 novapay:pb-3 novapay:pt-1.5 novapay:sm:hidden",c&&"novapay-page-header-phone",u),children:[jsx(Za,{compact:true}),b]})]})}function Ir({withDetails:e}){let t=_();if(t.customization.config?.showSteps===false)return null;let n=Nr(t,e);return n?Tr(t,n,"novapay:px-4 novapay:pt-3.5"):null}function Ar(e,t){return t.withGas||!e.gasless?"transfer":e.gasless.paymaster&&t.canSponsorCalls?"paymaster":e.gasless.relay?"relay":"transfer"}function Lr(e){let t=BigInt(e.amountToSend),n=BigInt(e.amountDue);return !e.transferFee||t<=n?{send:e.amountToSend,receives:e.amountDue,fee:null}:{send:e.amountToSend,receives:e.amountDue,fee:{amount:String(t-n),percent:String(e.transferFee.bps/100)}}}var tn=10000n,Er=8n;function Br(e,t){let n=BigInt(e.cryptoAmountExpected);if(!t||n<=0n)return null;let o=BigInt(t)*(tn+BigInt(e.markupBps))*(tn-BigInt(e.discountBps))*10n**BigInt(e.decimals)*10n**Er/(100n*tn*tn*n);return Number(o)/10**Number(Er)}function Or(e,t,n=0n){let a=BigInt(t.amountToSend)+n;return e>=a?null:{have:String(e),need:String(a),short:String(a-e)}}function Le(e){return e.family==="eip155"?`eip155:${e.chainId}`:e.chainId}var _c=new Set(["paid","held","refunded","partially_refunded"]);function an(){let{state:e,locale:t,adapterFor:n}=_(),o=(e.invoiceStatus&&_c.has(e.invoiceStatus)?e.checkout?.quote:null)??e.quote,r=o?Le(o.instructions):null,s=e.txHash??e.txKey,i=o?.payer?parseCaip10AccountId(o.payer)?.address:void 0;return {network:r?fe(r):null,amount:o?`${ye(o.amountToSend,o.decimals,t)} ${o.instructions.symbol}`:null,paidAmount:o?`${ye(o.amountDue===o.cryptoAmountExpected?o.amountToSend:o.cryptoAmountExpected,o.decimals,t)} ${o.instructions.symbol}`:null,txKey:s,lastOfParts:o?o.amountDue!==o.cryptoAmountExpected:false,explorerUrl:o&&r&&s?n(o.instructions.family)?.explorerUrl?.({chainId:r,txKey:s}):void 0,from:i?shortAddress(i):null,fromAddress:i??null,fromUrl:o&&r&&i?n(o.instructions.family)?.explorerAddressUrl?.({chainId:r,address:i}):void 0}}var Fr=new WeakMap,Uc=500;function aa({children:e,className:t}){let{store:n}=_(),[a,o]=useState(()=>{let r=Fr.get(n);return r&&Date.now()-r.leftAt<Uc?r.title:e});return useEffect(()=>(o(e),()=>{Fr.set(n,{title:e,leftAt:Date.now()});}),[n,e]),jsx("h2",{...Ct,"aria-label":e,className:cn(rt,t),children:jsx(MorphText,{wrap:true,children:a})})}var Vc=new Set(["open","underpaid"]);function Dr(){let{checkout:e,state:t,labels:n,close:a,customization:o,now:r,handedOverAt:s,display:i}=_(),c$1=i==="page",p=o.childCustomizations,u=an(),d=e?.invoice.dueAt?Date.parse(e.invoice.dueAt):null,x=t.invoiceStatus??e?.invoice.status,b=nt(t),h=!b&&pt(t,e),m=e!==null&&(b||h)&&Vc.has(x??"")&&d!==null&&r>=d,N=m&&Wo({state:t,checkout:e,handedOverAt:s,dueAt:d}),v=gt(t.error)==="retrying";return jsxs(St,{children:[jsxs("section",{className:cn("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",c$1&&"novapay-page-status"),children:[jsx(TxStatusVisual,{isProcessing:true,...p?.statusVisual,className:c$1?cn("novapay-page-visual",p?.statusVisual?.className):p?.statusVisual?.className}),jsxs("div",{children:[jsx(aa,{children:n.confirm.title}),c$1&&u.amount&&jsx("p",{className:cn(O,"novapay-page-amount novapay:m-0 novapay:mt-2 novapay:text-2xl novapay:font-bold"),children:u.amount}),u.network&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.confirm.hint,{network:u.network})})]}),jsx(TxProgressIndicator,{isProcessing:true,...p?.progressIndicator,className:cn("novapay:max-w-sm",p?.progressIndicator?.className)}),jsxs(we,{className:"novapay:max-w-sm",children:[u.network&&jsx(q,{name:n.confirm.network,children:u.network}),!c$1&&u.amount&&jsx(q,{name:n.confirm.amount,children:u.amount}),u.txKey&&jsx(q,{name:n.confirm.transaction,children:jsx(HashLink,{hash:u.txKey,explorerUrl:u.explorerUrl,variant:"compact",...p?.hashLink})}),u.fromAddress&&jsx(q,{name:n.confirm.from,children:jsx(HashLink,{hash:u.fromAddress,explorerUrl:u.fromUrl,variant:"compact",...p?.hashLink})})]}),jsx("p",{role:"status",className:cn("novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",c$1&&"novapay:mt-auto"),children:jsx(MorphText,{wrap:true,children:v?n.outcome.unconfirmedRetrying:m?c(N?n.confirm.afterDeadline:n.confirm.pastDeadline,{merchant:e.merchant.name}):h?n.confirm.invoicePayment:n.confirm.canClose})})]}),a&&jsx(re,{children:jsx(ee,{onClick:a,children:n.common.close})})]})}function on({adapter:e,store:t,wallet:n,chainId:a}){let[o,r]=useState("idle"),[s,i]=useState(null),[c,p]=useState(null),u=useRef(0),d=n?.address,x=useRef(d);useEffect(()=>{x.current!==d&&(x.current=d,u.current++,r("idle"),i(null),p(null));},[d]);let b=useRef(false);return useEffect(()=>(b.current=false,()=>{b.current=true;}),[]),{step:o,problem:s,request:c,confirm:async({quote:m=false}={})=>{let N=++u.current,v=()=>u.current===N;i(null);let w=e?.signMessage;if(!w||!n)return i("unsupported"),false;if(n.chainId!==a&&e.switchChain){r("switching");try{await e.switchChain(a);}catch(y){if(v()){let g=b$1(y);i(g==="declined"?"switchDeclined":g==="failed"?"switchFailed":g),r("idle");}return false}if(!v())return false}v()&&r("signing");let f=t.getState().payer,k=null,R=await t.getState().confirmPayer(async(y,g)=>{v()&&p(g);try{return await w({message:y,account:n.address,chainId:g.chainId})}catch(P){throw k=b$1(P),P}});return v()&&(i(k),r("idle")),R&&m&&!b.current&&t.getState().payer===f&&await t.getState().requestQuote(),R},dismiss:()=>{u.current++,r("idle"),t.getState().abandonConfirmation();}}}function Ur(){let{checkout:e,state:t,store:n,labels:a,locale:o,wallet:r,adapterFor:s,connectWallet:i,setConfirmWallet:c$1}=_(),p=e?.methods.find(Q=>Q.id===t.methodId)??null,u=p?Oe(p):null,d=on({adapter:u?s(u):void 0,store:n,wallet:r,chainId:p?.chainId??""}),[x,b]=useState(false),h=useRef(null),m=d.step!=="idle",[N,v]=Vt(m),w=useRef(false);if(useEffect(()=>{w.current&&!m&&h.current?.querySelector("[data-novapay-heading]")?.focus(),w.current=m;},[m]),!e||!p)return null;let f=e.merchant.name,k=r?.name??"",R=fe(p.chainId),y=e.invoice.number??e.invoice.id,g=e.invoice.totalMinor?`${be(Be(e.invoice.totalMinor),o)} ${e.invoice.currency}`:null,P=Ha(r),A=t.phase==="quoting",C=m,B=jt(!A&&fa(t.error)?t.error:null,d.problem,a,{wallet:k,network:R,merchant:f}),G={wallet:k,invoice:y,merchant:f},D=Ue(r,p),ne=()=>{D&&t.payer!==D&&n.getState().setPayer(D),d.confirm({quote:true});},$=()=>{c$1(false),n.getState().clearError();},z=D?t.confirmedWallets?.find(Q=>!bt(Q,D)):void 0;return jsxs("div",{ref:h,className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:N,inert:m,className:cn("novapay:flex novapay:flex-1 novapay:flex-col",m&&"novapay:hidden"),children:[jsxs(xe,{title:a.payerProof.title,subtitle:a.payerProof.text,children:[r&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:h-7 novapay:w-7 novapay:shrink-0",children:jsx(WalletIcon,{walletName:r.walletId})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:k}),jsx("span",{className:cn(O,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(a.pay.walletLine,{address:shortAddress(r.address),network:fe(r.chainId)})})]}),jsx("button",{type:"button","aria-label":a.pay.changeWallet,onClick:()=>{i(p)||b(true);},className:cn("novapay:min-h-6 novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-transparent novapay:px-2.5 novapay:py-1 novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-bg-muted)]",ae),children:a.pay.change})]}),jsx(Zt,{children:a.payerProof.summary}),jsxs(we,{children:[jsx(q,{name:a.payerProof.invoice,children:y}),jsx(q,{name:a.payerProof.merchant,children:f}),g&&jsx(q,{name:a.payerProof.amount,children:g}),r&&jsx(q,{name:a.payerProof.wallet,children:jsx(Te,{hash:r.address,chainId:r.chainId})})]}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:a.payerProof.why}),P&&jsxs("p",{className:"novapay:m-0 novapay:flex novapay:items-start novapay:gap-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsx(FingerPrintIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsx("span",{children:c(a.payerProof.passkey,G)})]}),r&&u==="eip155"&&r.chainId!==p.chainId&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(a.payerProof.willSwitch,{current:fe(r.chainId),network:R})}),z&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:c(a.payerProof.alreadyConfirmed,{wallet:shortAddress(ot(z))})}),B&&jsx(Z,{children:B}),x&&jsx(Z,{children:a.pay.connectUnavailable})]}),jsxs(re,{children:[jsx(J,{busy:C||A,onClick:ne,children:A?a.method.quoting:C?c(a.payerProof.waiting,G):c(a.payerProof.confirm,G)}),jsx(ee,{disabled:A,onClick:$,children:(t.invoiceStatus??e?.invoice.status)==="underpaid"?a.pay.backFromRest:a.pay.back}),jsx(Re,{children:P?a.payerProof.noteSmart:a.payerProof.note})]})]}),m&&jsx(Wt,{kind:d.step==="switching"?"switch":"proof",walletName:k,walletId:r?.walletId??"",walletIcon:r?.icon,amount:g??"",merchant:f,network:R,to:"",priceTime:null,text:c(P?a.payerProof.promptPasskey:a.payerProof.promptText,G),details:[...d.request?[{name:a.payerProof.site,value:d.request.domain}]:[],{name:a.payerProof.invoice,value:y},{name:a.payerProof.merchant,value:f},...g?[{name:a.payerProof.amount,value:g}]:[]],hint:d.request?c(a.payerProof.signInRequest,{wallet:k,site:d.request.domain}):void 0,onRetry:ne,onCancel:d.dismiss,stepHeight:v})]})}function Kr({onStay:e,onLeave:t}){let{checkout:n,labels:a,locale:o}=_(),r=useId(),s=useId(),i=useRef(null),c$1=n?.invoice.dueAt?new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(n.invoice.dueAt)):null;return jsx(Dialog,{open:true,onOpenChange:p=>{p||e();},children:jsxs(DialogContent,{role:"alertdialog","aria-labelledby":r,"aria-describedby":s,onOpenAutoFocus:p=>{p.preventDefault(),i.current?.focus();},className:"novapay:w-full novapay:sm:w-[24rem]",children:[jsx(DialogTitle,{"aria-hidden":true,className:"novapay:sr-only",children:a.leave.title}),jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:p-5 novapay:text-center",children:[jsx("h2",{id:r,ref:i,tabIndex:-1,className:rt,children:a.leave.title}),jsx("p",{id:s,className:"novapay:m-0 novapay:text-xs",children:c$1?c(a.leave.text,{date:c$1}):a.leave.textNoDate}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:a.leave.price}),jsx(J,{onClick:e,children:a.leave.stay}),jsx(ee,{onClick:t,children:a.leave.leave})]})]})})}function na(){let{checkout:e,labels:t,autoPayOff:n,setAutoPayOff:a}=_(),o=e?.autoCharge;return n==="done"?jsx(Re,{children:c(t.paid.autoPayTurnedOff,{merchant:e?.merchant.name??""})}):o?.status!=="active"||!o.revocation?null:jsxs(Re,{children:[t.paid.autoPayActive," ",jsx("button",{type:"button",onClick:()=>a("open"),className:Ka,children:t.paid.autoPayOff})]})}function oa({label:e,items:t,value:n,getKey:a,onChange:o,children:r,className:s,itemClassName:i}){let c=useRef([]),p=Math.max(0,t.findIndex(d=>a(d)===n)),u=(d,x)=>{let b=t.length-1,h={ArrowRight:x+1,ArrowDown:x+1,ArrowLeft:x-1,ArrowUp:x-1,Home:0,End:b}[d.key];if(h===void 0)return;d.preventDefault();let m=h<0?b:h>b?0:h;o(a(t[m])),c.current[m]?.focus();};return jsx("div",{role:"radiogroup","aria-label":e,className:s,children:t.map((d,x)=>{let b=a(d),h=b===n;return jsx("button",{ref:m=>{c.current[x]=m;},type:"button",role:"radio","aria-checked":h,tabIndex:x===p?0:-1,onClick:()=>o(b),onKeyDown:m=>u(m,x),className:cn("novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-left novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors","novapay:border",h?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-text-secondary)]",ae,i?.(h,d)),children:r(d,h)},b)})})}function ka({tone:e,children:t}){return jsx("span",{className:cn("novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:px-1.5 novapay:py-0.5 novapay:text-[11px]",e==="neutral"&&"novapay:bg-[var(--tuwa-bg-muted)] novapay:text-[var(--tuwa-text-primary)]",e==="accent"&&"novapay:border novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",e==="success"&&"novapay:bg-[var(--tuwa-success-bg)] novapay:text-[var(--tuwa-success-text)]"),children:t})}function jr({method:e,labels:t}){let n=Bn(e);return n?n.kind==="discount"?jsx(ka,{tone:"success",children:c(t.method.discount,{percent:n.percent})}):jsx(ka,{tone:"neutral",children:c(t.method.markup,{percent:n.percent})}):null}function ml({selected:e}){return jsx("span",{"aria-hidden":true,className:cn("novapay:h-3.5 novapay:w-3.5 novapay:shrink-0 novapay:rounded-full novapay:box-border",e?"novapay:border-4 novapay:border-[var(--tuwa-text-accent)]":"novapay:border novapay:border-[var(--tuwa-text-secondary)]")})}function dl({labels:e,terms:t,refundPolicy:n}){let a=(r,s)=>jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:cn("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ae),children:s},r),o=t&&n?d(e.method.agreeBoth,{terms:a(t,e.summary.terms),refundPolicy:a(n,e.summary.refundPolicy)}):t||n?d(e.method.agreeOne,{link:t?a(t,e.summary.terms):a(n,e.summary.refundPolicy)}):null;return o?jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o}):null}function Yr(){let e=_(),{checkout:t,state:n,store:a,labels:o,wallet:r,payWith:s,setPayWith:i,payUrl:c$1,connectWallet:p,adapterFor:u,setHandoff:d,lockPrice:x}=e,{TokenOption:b,NetworkOption:h}=e.customization.components??{},m=useMemo(()=>t?.methods??[],[t]),N=useMemo(()=>Ao(m,r?.chainId),[m,r?.chainId]),v=m.find(T=>T.id===n.methodId)??null,w=N.find(T=>T.symbol===v?.symbol)??null,f=v?Po(v,c$1):false,k=v?Oe(v):null,y=[...(k?!!u(k):false)?["wallet"]:[],...f?["qr"]:[]],g=y.includes(s)?s:y[0]??null,[P,A]=useState(false),C=useId(),B=useId(),G=useEffectEvent(()=>{let T=N[0]?.methods[0];!n.methodId&&T&&a.getState().selectMethod(T.id,{keepError:true});});if(useEffect(()=>G(),[N]),!t)return null;if(m.length===0)return jsx(xe,{title:o.method.title,children:jsx(Z,{children:o.method.noMethods})});let D=e.display==="page",ne=N.reduce((T,F)=>F.methods.length>T.methods.length?F:T,N[0]),$=n.phase==="quoting",z=t.consent??null,Q=!!n.consentGiven,X=!!(z?.required&&!Q),S=e.customization.handlers,M=T=>{let F=()=>a.getState().selectMethod(T.id);S?.onMethodSelect?S.onMethodSelect({method:T,select:F}):F();},oe=async()=>{if(!v||!g)return;if(A(false),g==="qr"){if(s!=="qr"&&i("qr"),k!=="solana")return d(true);a.getState().setPayer(null),await a.getState().requestQuote();return}s!=="wallet"&&i("wallet");let T=Ue(r,v);if(!T)return A(!p(v));a.getState().setPayer(T),await x();},ue=T=>jsxs(Fragment,{children:[jsx(Zt,{children:c(o.method.network,{symbol:T.symbol})}),jsx(oa,{label:c(o.method.network,{symbol:T.symbol}),items:T.methods,value:v?.id??null,getKey:F=>F.id,onChange:F=>{let L=T.methods.find(K=>K.id===F);L&&M(L);},className:D&&T.methods.length>1?"novapay:grid novapay:grid-cols-1 novapay:gap-1.5 novapay:@min-[520px]:grid-cols-2":"novapay:flex novapay:flex-col novapay:gap-1.5",itemClassName:(F,L)=>cn("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-3 novapay:py-2.5",ce(e,"networkOption",{method:L,selected:F})),children:(F,L)=>h?jsx(h,{method:F,selected:L}):jsxs(Fragment,{children:[jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(NetworkIcon,{chainId:toEvmChainId(F.chainId)??F.chainId})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col novapay:gap-1",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:fe(F.chainId)}),jsxs("span",{className:"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-1.5",children:[r?.chainId===F.chainId&&jsx(ka,{tone:"neutral",children:o.method.yourWallet}),F.featured&&jsx(ka,{tone:"accent",children:o.method.popular}),jsx(jr,{method:F,labels:o}),F.gasless==="auto"?jsx(ka,{tone:"success",children:o.method.noGasFee}):jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.buyerPaysGas})]})]}),jsx(ml,{selected:L})]})})]});return jsxs(Fragment,{children:[jsxs(xe,{title:o.method.title,subtitle:c(o.method.subtitle,{minutes:Math.round(t.quoteTtlSeconds/60)}),children:[jsx(Zt,{children:o.method.token}),jsx(oa,{label:o.method.token,items:N,value:w?.symbol??null,getKey:T=>T.symbol,onChange:T=>{let F=N.find(L=>L.symbol===T)?.methods[0];F&&M(F);},className:"novapay:grid novapay:grid-cols-[repeat(auto-fit,minmax(5.5rem,1fr))] novapay:gap-2",itemClassName:(T,F)=>cn("novapay:flex novapay:min-w-0 novapay:flex-col novapay:items-center novapay:gap-1 novapay:px-2 novapay:py-2",D&&"novapay-page-token",ce(e,"tokenOption",{group:F,selected:T})),children:(T,F)=>b?jsx(b,{group:T,selected:F}):jsxs(Fragment,{children:[jsx("span",{className:"novapay:h-6.5 novapay:w-6.5",children:jsx(TokenIcon,{symbol:T.symbol})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:T.symbol}),jsx("span",{className:"novapay:max-w-full novapay:truncate novapay:text-[10px] novapay:text-[var(--tuwa-text-secondary)]",children:T.methods.length>1?c(o.method.networks,{count:T.methods.length}):Bn(T.methods[0])?jsx(jr,{method:T.methods[0],labels:o}):fe(T.methods[0].chainId)})]})}),D&&w?jsxs("div",{className:cn("novapay:grid",w.methods.length===1&&"novapay:max-sm:hidden"),children:[ne!==w&&jsx("div",{inert:true,"aria-hidden":true,className:"novapay:invisible novapay:flex novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1] novapay:max-sm:hidden",children:ue(ne)}),jsx("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1]",children:ue(w)})]}):w&&w.methods.length>1&&ue(w),jsx(Zt,{children:o.method.payWith}),jsx(oa,{label:o.method.payWith,items:y,value:g,getKey:T=>T,onChange:T=>{A(false),i(T);},className:cn("novapay:grid novapay:gap-2",y.length>1&&"novapay:grid-cols-2"),itemClassName:(T,F)=>cn("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-2.5 novapay:py-2",D&&"novapay-page-way",ce(e,"payWithOption",{payWith:F,selected:T})),children:T=>T==="wallet"?jsxs(Fragment,{children:[r?jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(va,{walletId:r.walletId,icon:r.icon})}):jsx(WalletIcon$1,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:text-[var(--tuwa-text-accent)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:o.method.wallet}),jsx("span",{className:cn("novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",r&&O),children:r?`${r.name} \xB7 ${shortAddress(r.address)}`:o.method.walletHint})]})]}):jsxs(Fragment,{children:[v&&Oe(v)==="solana"?jsx(QrCodeIcon,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}):jsx(DevicePhoneMobileIcon,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}),jsxs("span",{className:"novapay:flex novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:o.method.qr}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.qrHint})]})]})}),z&&jsxs("label",{className:cn("novapay:flex novapay:cursor-pointer novapay:items-start novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:transition-colors",Q?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-text-secondary)]",ce(e,"consentOption",{checked:Q,required:z.required})),children:[jsx("input",{type:"checkbox",checked:Q,required:z.required,"aria-labelledby":C,"aria-describedby":z.required?B:void 0,onChange:T=>a.getState().setConsentGiven(T.target.checked),className:cn("novapay:mt-0.5 novapay:h-4 novapay:w-4 novapay:shrink-0 novapay:accent-[var(--tuwa-text-accent)]",ae)}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-1",children:[jsx("span",{id:C,className:"novapay:whitespace-pre-line novapay:break-words novapay:text-[12px] novapay:leading-snug",children:z.text}),z.required&&jsx("span",{id:B,className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.consentRequired})]})]}),v&&!g&&jsx(Z,{children:o.method.methodUnavailable}),P&&jsx(Z,{children:f?o.pay.connectUnavailable:o.method.methodUnavailable}),n.error&&n.phase==="selectMethod"&&jsx(Z,{children:Gt(n.error,o,t.merchant.name)})]}),jsxs(re,{children:[jsx(J,{busy:$,disabled:!v||!g||X,onClick:()=>{v&&g&&S?.onQuote?S.onQuote({method:v,payWith:g,proceed:oe}):oe();},children:$?o.method.quoting:o.method.continue}),jsx(dl,{labels:o,terms:t.merchant.links.terms,refundPolicy:t.merchant.links.refundPolicy}),jsx(na,{})]})]})}var vl=/^0x[0-9a-fA-F]{64}$/,hl=/^[1-9A-HJ-NP-Za-km-z]{64,90}$/;function Pa(){let{store:e,state:t,checkout:n,labels:a,wallet:o}=_(),[r,s]=useState(false),[i,c]=useState(""),[p,u]=useState(false),[d,x]=useState(null),b=useId(),h=t.quote??n?.quote;if(!h)return null;let m=a.outcome;if(!r)return jsx(mt,{onClick:()=>s(true),children:m.nameHash});let N=async v=>{v.preventDefault();let w=i.trim();if(!(h.instructions.family==="solana"?hl:vl).test(w))return x(m.nameHashInvalid);x(null),u(true);let k=await e.getState().submit({txKey:w,...o?{from:o.address}:{}});u(false),k||x(m.nameHashRefused);};return jsxs("form",{onSubmit:v=>{N(v);},className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:gap-2 novapay:text-left",children:[jsx("label",{htmlFor:b,className:"novapay:text-xs novapay:font-semibold",children:m.nameHashField}),jsx("input",{id:b,value:i,autoComplete:"off",spellCheck:false,"aria-invalid":d?true:void 0,onChange:v=>c(v.target.value),className:cn(O,"novapay:box-border novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",ae)}),d&&jsx(Z,{children:d}),jsx(ee,{type:"submit",disabled:p||!i.trim(),children:m.nameHashSend})]})}var Xr=e=>e?.code==="payment_unconfirmed",Tl={nonceSpent:"unconfirmedNonceSpent",unmined:"unconfirmedUnmined",rechecked:"unconfirmedNote",retrying:"unconfirmedRetrying",notReceived:"unconfirmedNotReceived",contact:"unconfirmedContact",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"},es=new Set(["nonceSpent","unmined","notReceived","contact","closed","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),ts=new Set(["nonceSpent","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Rl=({className:e})=>jsx(DrawnCross,{variant:"disc",className:e}),Il={unconfirmed:{Icon:ExclamationTriangleIcon,tone:"novapay:text-[var(--tuwa-pending-icon)]"},underpaid:{Icon:ExclamationTriangleIcon,tone:"novapay:text-[var(--tuwa-pending-icon)]"},held:{Icon:MagnifyingGlassIcon,tone:"novapay:text-[var(--tuwa-info-icon)]"},refunded:{Icon:ArrowUturnLeftIcon,tone:"novapay:text-[var(--tuwa-info-icon)]"},expired:{Icon:ClockIcon,tone:"novapay:text-[var(--tuwa-text-secondary)]"},cancelled:{Icon:Rl,tone:"novapay:text-[var(--tuwa-text-secondary)]"},replaced:{Icon:ArrowPathRoundedSquareIcon,tone:"novapay:text-[var(--tuwa-info-icon)]"},blocked:{Icon:NoSymbolIcon,tone:"novapay:text-[var(--tuwa-error-icon)]"}},ie=({children:e,muted:t})=>jsx("p",{className:cn("novapay:m-0 novapay:max-w-sm novapay:text-xs",t?"novapay:text-[var(--tuwa-text-secondary)]":"novapay:text-[var(--tuwa-text-primary)]"),children:e});function El(){let e=_(),{checkout:t,labels:n,onContact:a}=e;if(!t)return null;let o=c(n.outcome.contact,{merchant:t.merchant.name}),r=cn(Yt,ce(e,"secondaryButton"));if(a)return jsx("button",{type:"button",onClick:a,className:r,children:o});let s=Ho(t.merchant,c(n.outcome.contactSubject,{number:t.invoice.number??t.invoice.id}));return s?jsx("a",{href:s,target:s.startsWith("mailto:")?void 0:"_blank",rel:"noopener noreferrer",className:r,children:o}):null}function as({kind:e}){let[t,n]=useState(false),a=_(),{checkout:o,state:r,store:s,labels:i,locale:c$1,now:p,wallet:u,connectWallet:d,openInvoice:x,qrShown:b,paymentSent:h,adapterFor:m,lockPrice:N}=a;if(!o)return null;let v=o.merchant.name,{Icon:w,tone:f}=Il[e],k=a.customization.components?.StatusIcon,R=ce(a,"statusIcon",{kind:e}),y=r.quote,g=o.methods.find(S=>S.id===(r.methodId??y?.methodId)),P=o.invoice.dueAt&&!o.invoice.closed?new Intl.DateTimeFormat(c$1,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(o.invoice.dueAt)):null,A=(S,M=y)=>M?`${ye(S,M.decimals,c$1)} ${M.instructions.symbol}`:S,C=gt(r.error),B=S=>c(i.outcome[Tl[S]],{merchant:v}),G=r.followingUntil??null,D=G?jsx(ie,{muted:true,children:c(i.outcome.followingUntil,{time:new Intl.DateTimeFormat(c$1,{timeStyle:"short"}).format(Date.parse(G))})}):null,ne=Uo(r,o),$=S=>{if(!ne||S!=="mismatch"&&(!S||!es.has(S)))return null;let M=y??o.quote,oe=M?Le(M.instructions):null,ue=M&&oe?m(M.instructions.family)?.explorerUrl?.({chainId:oe,txKey:ne}):void 0;return jsx(St,{children:jsx(we,{className:"novapay:w-full novapay:max-w-sm",children:jsx(q,{name:i.confirm.transaction,children:jsx(HashLink,{hash:ne,explorerUrl:ue,variant:"compact",...a.customization.childCustomizations?.hashLink})})})})},z,Q=null,X=null;switch(e){case "unconfirmed":{if(z=i.outcome.unconfirmedTitle,ut(r.error))Q=jsxs(Fragment,{children:[jsx(ie,{children:Ot(r.error,i,v)}),$("mismatch")]});else if(C&&ts.has(C))Q=jsxs(Fragment,{children:[jsx(ie,{children:B(C)}),$(C),C==="nonceSpent"&&jsx(Pa,{})]});else {let oe=C??"contact";Q=jsxs(Fragment,{children:[jsx(ie,{children:i.outcome.unconfirmedText}),jsx(ie,{muted:true,children:B(oe)}),$(oe),jsx(Pa,{})]});}let{payAgain:S}=s.getState(),M=r.invoiceStatus??o.invoice.status;S&&(M==="open"||M==="underpaid")&&!(C&&ts.has(C))&&(X=ut(r.error)?r.error.held===true?jsx(J,{onClick:()=>S(),children:i.pay.payAgain}):jsx(ee,{onClick:()=>S(),children:i.pay.payAgain}):jsx(ee,{onClick:()=>S(),children:i.outcome.unconfirmedPayAgain}));break}case "underpaid":{let S=y??o.quote,M=o.invoice.amountPaid,oe=Vo(S,M);z=i.outcome.underpaidTitle;let ue=S&&M&&jsx(ie,{children:c(i.outcome.underpaidText,{received:A(M,S),total:A(S.cryptoAmountExpected,S)})});if(o.invoice.status==="underpaid"&&o.invoice.restPayable===false||r.error?.code==="method_not_found"){Q=jsxs(Fragment,{children:[ue,jsx(ie,{children:i.outcome.underpaidClosed}),P&&jsx(ie,{children:c(i.outcome.underpaidClosedRefund,{merchant:v,date:P})})]});break}let F=zt(S,p,i,v,c$1,i.outcome.underpaidRateEnded),L=o.methods.find(Ae=>Ae.id===S?.methodId)??g??o.methods[0],K=r.error?.code==="payer_blocked"?c(i.outcome.underpaidBlocked,{merchant:v}):r.error&&r.error.code!=="payer_mismatch"?Gt(r.error,i,v):null;Q=jsxs(Fragment,{children:[ue,S&&oe&&jsx(ie,{children:c(i.outcome.underpaidRest,{rest:A(oe,S),network:fe(Le(S.instructions))})}),P&&jsx(ie,{muted:true,children:c(i.outcome.underpaidNote,{merchant:v,date:P})}),F&&jsx(ie,{muted:true,children:F}),K&&jsx(Z,{children:K})]});let me=L&&u?Ue(u,L):null,de=r.error?.code==="payer_mismatch"?r.error.originWallet??null:null,se=de??o.invoice.originWallet??S?.payer??null,le=se?ot(se):void 0,Ke=me?parseCaip10AccountId(me)?.address:void 0,Ne=S?.payer!==null&&!!(le&&(Ke?!bt(Ke,le):de)),ct=()=>{if(!L)return;if(Ne)return void d(L);let Ae=S?.payer===null?null:me;if(S?.payer!==null&&!Ae)return void d(L);r.methodId!==L.id&&s.getState().selectMethod(L.id),s.getState().setPayer(Ae),N();};Ne&&le&&(Q=jsxs(Fragment,{children:[Q,jsx(ie,{children:c(i.outcome.payRestFirstWallet,{wallet:shortAddress(le)})})]})),X=jsx(J,{busy:r.phase==="quoting",onClick:ct,children:i.outcome.payRest});break}case "held":{z=c(i.outcome.heldTitle,{merchant:v});let S=o.invoice.review?.reason,M=S==="late"?i.outcome.heldLate:S==="overpaid"?i.outcome.heldOverpaid:S==="quote_expired"?i.outcome.heldQuoteExpired:i.outcome.heldScreening;Q=jsxs(Fragment,{children:[jsx(ie,{children:c(M,{merchant:v})}),jsx(ie,{muted:true,children:i.outcome.heldNote})]});break}case "refunded":{z=i.outcome.refundedTitle;let S=o.invoice.refundedTotalMinor??o.invoice.totalMinor;Q=S&&jsx(ie,{children:c(i.outcome.refundedText,{merchant:v,amount:be(Be(S),c$1),currency:o.invoice.currency})});break}case "expired":{z=i.outcome.expiredTitle;let S=Go(o.invoice.amountPaid),M=y??o.quote,oe=nt(r)||pt(r,o),ue=Xr(r.error)||C==="settlementFailed"||C==="settlementRetrying",T=ue||!oe&&Bt(r,o),F=!T&&C==="closed",L=!T&&!F&&(oe||h),K=!T&&!F&&!L&&ut(r.error),me=L||T||F||K||b,de=ue?C??"contact":"rechecked";Q=jsxs(Fragment,{children:[S?jsxs(Fragment,{children:[P&&jsx(ie,{children:M?c(i.outcome.expiredPartText,{date:P,amount:A(S,M)}):c(i.outcome.expiredPartNoAmount,{date:P})}),!P&&M&&jsx(ie,{children:c(i.outcome.closedPartText,{merchant:v,amount:A(S,M)})}),jsx(ie,{children:c(i.outcome.expiredPartRefund,{merchant:v})})]}):!me&&P&&jsx(ie,{children:c(i.outcome.expiredText,{date:P,merchant:v})}),T?jsxs(Fragment,{children:[jsx(ie,{children:de==="rechecked"?c(i.outcome.expiredUnconfirmed,{merchant:v}):B(de)}),$(de),de==="nonceSpent"&&jsx(Pa,{})]}):F?jsxs(Fragment,{children:[jsx(ie,{children:B("closed")}),$("closed")]}):L?jsxs(Fragment,{children:[jsx(ie,{children:c(i.outcome.expiredWhileConfirming,{merchant:v})}),D]}):K?jsxs(Fragment,{children:[jsx(ie,{children:Ot(r.error,i,v)}),$("mismatch")]}):b?jsx(ie,{children:c(i.outcome.expiredAfterQr,{merchant:v})}):jsx(ie,{muted:true,children:i.outcome.expiredNote})]});break}case "cancelled":{if(z=i.outcome.cancelledTitle,C&&es.has(C)){Q=jsxs(Fragment,{children:[jsx(ie,{children:B(C)}),$(C),C==="nonceSpent"&&jsx(Pa,{})]});break}let S=Xr(r.error)||C==="closed"||nt(r)||pt(r,o)||Bt(r,o)||h,M=!S&&ut(r.error),oe=S?c(i.outcome.cancelledWhilePaying,{merchant:v}):M?Ot(r.error,i,v):c(b?i.outcome.cancelledAfterQr:i.outcome.cancelledText,{merchant:v});Q=jsxs(Fragment,{children:[jsx(ie,{children:oe}),M&&$("mismatch"),C==="retrying"&&jsx(ie,{muted:true,children:i.outcome.unconfirmedRetrying}),S&&D]});break}case "replaced":{let S=o.invoice.replacedBy,M=S?.number??"";if(z=c(i.outcome.replacedTitle,{merchant:v}),Q=jsxs(Fragment,{children:[jsx(ie,{children:c(i.outcome.replacedText,{number:M})}),jsx(ie,{muted:true,children:i.outcome.replacedPaid})]}),S?.checkoutToken){let oe=S.checkoutToken;X=jsx(J,{onClick:()=>x(oe),children:c(i.outcome.openReplacement,{number:M})});}break}case "blocked":{z=i.outcome.blockedTitle;let S=r.payer?parseCaip10AccountId(r.payer)?.address:void 0;Q=jsxs(Fragment,{children:[jsx(ie,{children:r.error?.code==="payer_not_expected"?i.method.payerNotExpected:c(i.outcome.blockedText,{merchant:v})}),S&&jsx(Te,{hash:S,chainId:y??o.quote?Le((y??o.quote).instructions):null})]}),g&&(X=jsx(J,{onClick:()=>{d(g)||n(true);},children:i.outcome.useAnotherWallet}));break}}return jsxs(Fragment,{children:[jsxs("section",{role:e==="blocked"?"alert":void 0,className:cn("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:px-5 novapay:py-6 novapay:text-center",a.display==="page"&&"novapay-page-screen"),children:[k?jsx(k,{kind:e,className:R}):jsx(w,{"aria-hidden":true,className:cn("novapay:h-12 novapay:w-12",f,R)}),jsx(aa,{className:"novapay:max-w-sm",children:z}),Q,t&&jsx(Z,{children:i.pay.connectUnavailable})]}),jsxs(re,{children:[X,jsx(El,{}),jsx(na,{})]})]})}function ss(e,t,n,a=false){let o=useRef(null),r=t?.id??null,s=useEffectEvent(()=>{t&&n?.({...t,status:"paid"});});useEffect(()=>{e!=="paid"||!r||o.current===r||(o.current=r,a||s());},[e,r,a]);}function is({url:e,seconds:t,now:n,navigate:a=o=>window.location.assign(o)}){let[o,r]=useState(t>0?n:null);t>0!=(o!==null)&&r(t>0?n:null);let s=t>0?o??n:n,[i,c]=useState(false),p=e&&t>0&&!i?Math.max(0,t-Math.floor((n-s)/1e3)):null,u=useEffectEvent(()=>{e&&a(e);});return useEffect(()=>{p===0&&u();},[p]),{left:p,stay:()=>c(true)}}function ls(){let e=_(),{checkout:t,state:n,labels:a,locale:o,now:r,close:s,wallet:i,adapterFor:c$1,setAutoPay:p,autoPayOff:u,setAutoPayOff:d,autoReturnSeconds:x,openedPaid:b,display:h}=e,m=e.customization.childCustomizations,N=an(),[v]=useState(r),w=t?.merchant.name??"",f=h==="modal"&&x===0?null:t?.invoice.successUrl??null,k=t?.autoCharge??null,R=k?.status==="available"?t?.methods.find(ne=>ne.id===k.methodId):void 0,y=R?Oe(R):null,g=u!=="done"&&!!(i&&y&&c$1(y)?.requestPermission),P=g||b||k?.status==="active",A=is({url:f,seconds:P?0:x,now:r});if(!t)return null;let C=t.invoice.totalMinor?be(Be(t.invoice.totalMinor),o):null,B=t.invoice.refundedTotalMinor&&BigInt(t.invoice.refundedTotalMinor)>0n?be(Be(t.invoice.refundedTotalMinor),o):null,G=t.invoice.paidAt?Date.parse(t.invoice.paidAt):v,D=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(G);return jsxs(St,{children:[jsxs("section",{className:cn("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",e.display==="page"&&"novapay-page-status"),children:[jsx(TxStatusVisual,{isSucceed:true,...m?.statusVisual,className:e.display==="page"?cn("novapay-page-visual",m?.statusVisual?.className):m?.statusVisual?.className}),jsx(aa,{children:a.paid.title}),jsxs("div",{children:[jsx("p",{className:cn(O,"novapay:m-0 novapay:text-2xl novapay:font-bold",e.display==="page"&&"novapay-page-amount"),children:N.paidAmount??(C&&`${C} ${t.invoice.currency}`)}),jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:N.network?c(a.paid.summary,{network:N.network,date:D}):D})]}),jsx(TxProgressIndicator,{isSucceed:true,isConfirmed:true,...m?.progressIndicator,className:cn("novapay:max-w-sm",m?.progressIndicator?.className)}),(N.network||N.txKey||N.from)&&jsxs(we,{className:"novapay:max-w-sm",children:[N.network&&jsx(q,{name:a.confirm.network,children:N.network}),N.txKey&&jsx(q,{name:N.lastOfParts?a.confirm.lastTransfer:a.confirm.transaction,children:jsx(HashLink,{hash:N.txKey,explorerUrl:N.explorerUrl,variant:"compact",...m?.hashLink})}),N.fromAddress&&jsx(q,{name:a.confirm.from,children:jsx(HashLink,{hash:N.fromAddress,explorerUrl:N.fromUrl,variant:"compact",...m?.hashLink})})]}),B&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(a.paid.refunded,{amount:B,currency:t.invoice.currency})}),n.receiptUrl&&jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:items-center novapay:gap-3 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-left",children:[jsx(DocumentTextIcon,{"aria-hidden":true,className:"novapay:h-6 novapay:w-6 novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:a.paid.receipt}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:a.paid.receiptHint})]}),jsxs("a",{href:n.receiptUrl,target:"_blank",rel:"noopener noreferrer",className:cn("novapay:inline-flex novapay:min-h-6 novapay:items-center novapay:gap-1 novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-accent)]",ae),children:[jsx(ArrowDownTrayIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"}),a.paid.download]})]}),k?.status==="active"&&jsxs("p",{className:"novapay:m-0 novapay:flex novapay:items-center novapay:gap-1.5 novapay:text-xs novapay:text-[var(--tuwa-success-text)]",children:[jsx(DrawnCheck,{variant:"disc",className:"novapay:h-4 novapay:w-4"}),a.paid.autoPayActive,k.revocation&&jsx("button",{type:"button",onClick:()=>d("open"),className:Ka,children:a.paid.autoPayOff})]}),u==="done"&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(a.paid.autoPayTurnedOff,{merchant:w})})]}),jsxs(re,{children:[g&&jsx(J,{onClick:()=>p(true),children:a.paid.autoPayOffer}),f?jsxs(Fragment,{children:[jsx("a",{href:f,className:g?cn(Yt,ce(e,"secondaryButton")):cn(Pt,ce(e,"primaryButton")),children:c(a.paid.back,{merchant:w})}),A.left!==null&&jsxs(Re,{children:[jsx("span",{role:"timer","aria-live":"off",children:c(a.paid.returning,{merchant:w,seconds:A.left})})," ","\xB7 ",jsx(mt,{onClick:A.stay,children:a.paid.stay})]})]}):s&&(g?jsx(ee,{onClick:s,children:a.common.close}):jsx(J,{onClick:s,children:a.common.close}))]})]})}function ps({state:e,screen:t,now:n,handlers:a}){let o=e.checkout?.invoice.status??null,{phase:r,error:s}=e,i=e.quote?.expiresAt?Date.parse(e.quote.expiresAt):null,c=i!==null&&n>=i,p=useEffectEvent(()=>a?.onStatusChange?.({phase:r,status:o,screen:t}));useEffect(()=>p(),[r,o]);let u=useEffectEvent(()=>{s&&a?.onError?.({error:s,screen:t});});useEffect(()=>u(),[s]);let d=useRef({quote:false,invoice:false}),x=useEffectEvent(b=>a?.onExpire?.({kind:b,paymentOnTheWay:nt(e)||pt(e,e.checkout)||Bt(e,e.checkout)}));useEffect(()=>{c&&!d.current.quote&&x("quote"),d.current.quote=c;},[c]),useEffect(()=>{let b=o==="expired";b&&!d.current.invoice&&x("invoice"),d.current.invoice=b;},[o]);}var Tt=()=>new Promise(()=>{}),Kl={view:Tt,quote:Tt,buyer:Tt,locale:Tt,submit:Tt,relay:Tt,permission:Tt,permissionRevoked:Tt,url:()=>""},Vl=createCheckoutStore({token:"idle",api:Kl,EventSource:null});function ms(e){let{token:t,baseUrl:n,api:a,EventSource:o,pollMs:r,enabled:s=true}=e,[i,c]=useState(Vl),p=useEffectEvent(()=>createCheckoutStore({token:t,baseUrl:n,api:a,EventSource:o,pollMs:r}));return useEffect(()=>{if(!s)return;let u=p();return c(u),u.getState().load(),()=>u.getState().destroy()},[t,n,s]),i}function ds(e,t){return useStore(e,t)}var Zl=createStore(()=>({}));function ln(){let e=useContext(SatelliteStoreContext)??Zl,t=useStore(e,p=>p.activeConnection),n=useStore(e,p=>p.getConnectors),a=useStore(e,p=>p.watchConnectors),[o,r]=useState(0);useEffect(()=>a?.(()=>r(p=>p+1)),[a]);let s=useMemo(()=>Co(t,n?.()),[t,n,o]),i=s?.name,c=s?.icon;return useMemo(()=>s,[t,i,c])}function fs(e){let[t,n]=useState({store:e,at:null});return useEffect(()=>e.subscribe((a,o)=>{a.phase!==o.phase&&(a.phase==="confirming"?n({store:e,at:o.phase==="submitting"?Date.now():null}):o.phase==="confirming"&&n({store:e,at:null}));}),[e]),t.store===e?t.at:null}var vs=Symbol.for("tuwaio.nova-payments.context"),hs=globalThis,Sa=hs[vs]??(hs[vs]=createContext({}));function it(){return useContext(Sa)}function xs(e,t=true){let[n,a]=useState(()=>Date.now());return useEffect(()=>{if(!t)return;let o=setInterval(()=>a(Date.now()),e);return ()=>clearInterval(o)},[e,t]),n}var zn="nova-payments:sponsoredBatches";var Qn=()=>{try{return globalThis.sessionStorage??null}catch{return null}},jn=()=>{try{let e=JSON.parse(Qn()?.getItem(zn)??"[]");return Array.isArray(e)?e:[]}catch{return []}},gs=e=>{try{e.length>0?Qn()?.setItem(zn,JSON.stringify(e)):Qn()?.removeItem(zn);}catch{}},pn=e=>gs(jn().filter(t=>t.invoiceId!==e)),bs=e=>gs([...jn().filter(t=>t.invoiceId!==e.invoiceId),e]),Yn=e=>jn().find(t=>t.invoiceId===e&&Date.now()-t.at<21e5)??null;var ws=e=>new a("unsupported",`${e} is not available`);async function ks({adapter:e,store:t,quote:n,wallet:a,path:o,paymasterUrl:r,onWalletDone:s,onBatchAccepted:i,onSent:c}){let p=a.address;if(o==="relay"){let d=n.gasless?.relay?.typedData;if(!d||!e.signTransferAuthorization)throw ws("A gasless signature");let x=await e.signTransferAuthorization({typedData:d,account:p});return s?.(),t.getState().relay(x)}if(o==="paymaster"){let d=n.gasless?.paymaster?.calls;if(!d||!r||!e.sendSponsoredCalls)throw ws("A sponsored payment");let x=Le(n.instructions),b=await e.sendSponsoredCalls({calls:d,paymasterUrl:r,chainId:x,account:p,onSent:s,onAccepted:i,onLate:h=>{c?.(h),t.getState().submit({txKey:h,connectorType:a.connectorType,methodId:n.methodId});}});return s?.(),c?.(b),t.getState().submit({txKey:b,connectorType:a.connectorType,methodId:n.methodId})}let u=await e.sendTransfer({instructions:n.instructions,account:p,connection:a.connection});return s?.(),c?.(u),t.getState().submit({txKey:u,connectorType:a.connectorType,methodId:n.methodId})}var Rt=new WeakMap;function mn(e){let t=Rt.get(e);return !!(t?.accepted&&Date.now()<t.until)}function Ps({adapter:e,store:t,quote:n,wallet:a$1,path:o,paymasterUrl:r,invoiceId:s,onSent:i}){let[c,p]=useState("idle"),[u,d]=useState(()=>{let f=Rt.get(t),k=f?.unconfirmed&&f.account===a$1?.address&&Date.now()<f.until,R=s?Yn(s):null;return k||R?"sentUnconfirmed":null}),x=useEffectEvent(f=>i?.(f));useEffect(()=>{if(!s||Rt.has(t))return;let f=Yn(s);if(!f)return;let k=Promise.reject(new a("sentUnconfirmed","The sponsored payment is not confirmed yet"));k.catch(()=>{});let R=f.at+21e5;Rt.set(t,{account:f.account,path:"paymaster",paying:k,until:R,unconfirmed:true,instructions:f.instructions,accepted:true}),e?.followSponsoredCalls?.({batchId:f.batchId,until:R,onLate:y=>{pn(s),x({txKey:y,instructions:f.instructions,account:f.account,connectorType:f.connectorType}),t.getState().submit({txKey:y,connectorType:f.connectorType,methodId:f.methodId});}});},[s,e,t]);let b=useRef(0),[h,m]=useState(null),[N,v]=useState(null),w=async(f,k)=>{let R=++b.current,y=()=>b.current===R;d(null),p(f);try{await k(y);}catch(g){y()&&d(b$1(g));}finally{y()&&p("idle");}};return {status:c,problem:u,askedWallet:h,askedInstructions:N,pay:()=>w("wallet",async f=>{if(!e||!n||!a$1)return d("unsupported");m(a$1);let k=Rt.get(t),R=k?.path==="relay"&&o==="relay";if(k?.account===a$1.address&&!R&&Date.now()<k.until){v(k.instructions),await k.paying;return}v(n.instructions);let y={account:a$1.address,path:o,paying:Promise.resolve(),until:Date.now()+6e5,unconfirmed:!1,instructions:n.instructions,accepted:!1};Rt.set(t,y);let g=ks({adapter:e,store:t,quote:n,wallet:a$1,path:o,paymasterUrl:r,onWalletDone:()=>{o==="paymaster"&&(y.accepted=!0),f()&&p("submitting");},onBatchAccepted:A=>{s&&bs({invoiceId:s,batchId:A,account:a$1.address,instructions:n.instructions,connectorType:a$1.connectorType,methodId:n.methodId,at:Date.now()});},onSent:A=>{s&&pn(s),i?.({txKey:A,instructions:n.instructions,account:a$1.address,connectorType:a$1.connectorType});}});y.paying=g;let P=()=>{Rt.get(t)===y&&Rt.delete(t),s&&pn(s);};g.then(P,A=>{if(b$1(A)!=="sentUnconfirmed")return P();y.unconfirmed=!0,y.until=Date.now()+21e5;}),await g;}),switchNetwork:()=>w("switching",async()=>{if(!e?.switchChain||!n)return d("unsupported");await e.switchChain(Le(n.instructions));}),dismiss:()=>{b.current++,p("idle");}}}var ip=100,cp=300,Ss=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e,lp=["paid","underpaid","held","refunded","expired","cancelled","blocked"];function Ns(e){let t=e.error?.code;return !lp.includes(e.phase)&&t!=="payment_failed"&&t!=="payment_mismatch"}async function Ts({adapter:e,pulsar:t,payment:n,labels:a,merchant:o,invoice:r,amount:s}){if(!t||!e?.pulsarTransaction)return false;let i=r.number?c(a.pay.txDescription,{amount:s,invoice:r.number}):s,c$1=e.pulsarTransaction({...n,title:Ss(c(a.pay.txTitle,{merchant:o}),ip),description:Ss(i,cp),payload:{quasarInvoice:r.id}});return await t.injectExternalPendingTxs([c$1]),true}function Rs({store:e,open:t,adapterFor:n,pulsar:a,labels:o,locale:r}){let s=useRef(null),i=useRef(!t),c=useRef({adapterFor:n,pulsar:a,labels:o,locale:r});useEffect(()=>{c.current={adapterFor:n,pulsar:a,labels:o,locale:r};});let p=useCallback(d=>{let{phase:x,error:b,checkout:h}=e.getState();if(!h||!Ns({phase:x,error:b}))return;let{adapterFor:m,pulsar:N,labels:v,locale:w}=c.current,{amount:f,decimals:k,symbol:R}=d.instructions;Ts({adapter:m(d.instructions.family),pulsar:N,payment:d,labels:v,merchant:h.merchant.name,invoice:{id:h.invoice.id,number:h.invoice.number},amount:`${ye(f,k,w)} ${R}`}).catch(()=>{});},[e]),u=useCallback(()=>{i.current=true,s.current&&p(s.current),s.current=null;},[p]);return useEffect(()=>{t?i.current=false:u();},[t,u]),useEffect(()=>u,[u]),useCallback(d=>{i.current?p(d):s.current=d;},[p])}function Es({store:e,state:t,walletTxKey:n=null}){let[a,o]=useState(null),[r,s]=useState(null),i=n!==null&&n!==r;i&&s(n);let c=t.phase,p=i||nt(t)||pt(t,t.checkout)||Bt(t,t.checkout)||c==="confirming"||c==="unconfirmed",u=a?.store===e?a:null,d=p?u&&u.error===t.error?u:{store:e,error:t.error}:u&&Mo(t.error)&&t.error!==u.error?null:a;return d!==a&&o(d),d?.store===e}function Na(e){let{labels:t,customization:n}=it(),a=n?.labels?.transform,[o,r]=useState(()=>g(e)),s=f(e);s&&o!==g(e)&&r(g(e));let i$1=s?g(e):o;return useEffect(()=>{if(f(e))return;let c=true;return h(e).then(p=>c&&r(p)),()=>{c=false;}},[e]),useMemo(()=>{let c=i(i$1,t);return a?a(c,{locale:e}):c},[i$1,e,t,a])}function As({store:e,screen:t}){let[n,a]=useState(null),o=t==="qr";return o&&n!==e&&a(e),o||n===e}function dn(e){let t=useContext(NovaConnectProviderContext),n=it(),a=e??n.onConnectWallet;return {canConnect:!!(t||a),connecting:t?.isConnectModalOpen??false,connect:o=>t?(t.setIsConnectModalOpen(true,{adapter:o==="solana"?OrbitAdapter.SOLANA:OrbitAdapter.EVM}),true):a?(a(o),true):false}}var Bs=5,hp=2e3;function Os(){let{checkout:e,state:t,store:n,labels:a$1,locale:o,wallet:r,adapterFor:s,connectFamily:i,setAutoPayOff:c$1,setAutoPay:p,revokeSent:u,setRevokeSent:d}=_(),[x,b]=useState("idle"),[h,m]=useState(null),N=r?.address,[v,w]=useState(N);v!==N&&(w(N),m(null));let f=e?.autoCharge,k=f?.status==="active"&&!!f.replacement&&To(t.phase);if(!e||f?.status!=="active"||!f.permission||!f.revocation)return null;let{permission:R,revocation:y}=f,g=e.merchant.name,P=R.chainId??"",A=fe(P),C=ot(R.payer??""),B=e.methods.find(S=>S.id===R.methodId),G=s("eip155"),D=!!(r&&bt(r.address,C)),ne=async()=>{b("network");let S=false;for(let M=0;M<Bs;M++){let oe=await n.getState().permissionRevoked();if(oe===true)return c$1("done");S||=oe===false,M<Bs-1&&await delay(void 0,hp);}m(S?"notYet":"notAsked");},$=async()=>{if(!r)return;m(null);let S=false;try{if(!u){b("network");let M=await n.getState().permissionRevoked();if(M===!0)return c$1("done");if(M===null)return m("notAsked");if(!G?.revokePermission)return m("unsupported");if(b("wallet"),!await $a(G.revokePermission({revocation:y,chainId:P,account:r.address,onSent:()=>{S=!0,d(!0),b("network");}}),6e5)&&!S)return m("alreadyPending")}await ne();}catch(M){S?(M instanceof a&&M.kind==="failed"&&d(false),await ne().catch(()=>m("notYet"))):m(b$1(M));}finally{b("idle");}},z={wallet:r?.name??"",network:A},Q=h==="notYet"?a$1.autoPayOff.notYet:h==="declined"?c(a$1.pay.declined,z):h==="unsupported"?c(a$1.autoPayOff.unsupported,z):h==="wrongNetwork"||h==="switchFailed"?c(a$1.pay.switchFailed,z):h==="notAuthorized"?c(a$1.pay.notAuthorized,z):h==="alreadyPending"?c(a$1.walletPrompt.stillWaiting,z):h==="failed"?c(a$1.pay.walletFailed,z):h?a$1.error.generic:null,X=B?Number(B.decimals):null;return jsxs(Fragment,{children:[jsxs(xe,{title:a$1.autoPayOff.title,subtitle:c(a$1.autoPayOff.subtitle,{merchant:g}),children:[jsxs(we,{children:[jsx(q,{name:a$1.autoPayOff.wallet,children:jsxs("span",{className:"novapay:inline-flex novapay:items-center novapay:gap-1",children:[jsx(Te,{hash:C,chainId:P})," \xB7 ",A]})}),R.periodAmount&&X!==null&&B&&jsxs(q,{name:a$1.autoPayOff.allowed,children:[c(a$1.autoPay.limit,{amount:`${ye(R.periodAmount,X,o)} ${B.symbol}`})," ",c(a$1.autoPay.every,{period:Ua(R.periodSeconds??0,o)})]})]}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:D?c(a$1.autoPayOff.fee,{network:A}):c(a$1.autoPayOff.otherWallet,{wallet:shortAddress(C)})}),Q&&jsx(Z,{children:Q})]}),jsxs(re,{children:[D?jsx(J,{busy:x!=="idle",onClick:()=>{$();},children:x==="wallet"?c(a$1.autoPayOff.inWallet,z):x==="network"?a$1.autoPayOff.waiting:u?a$1.autoPayOff.checkAgain:c(a$1.autoPayOff.confirm,z)}):jsx(J,{onClick:()=>{i("eip155");},children:a$1.autoPayOff.connect}),!D&&r&&k&&jsx(ee,{onClick:()=>{c$1(null),p(true);},children:a$1.autoPayOff.useThisWallet}),jsx(ee,{onClick:()=>c$1(null),children:a$1.autoPayOff.keep})]})]})}var gp=e=>e.charAt(0).toUpperCase()+e.slice(1);function Fs(e,t,n){let a=e.startsWith("solana:")?getSolanaCluster(e):void 0;if(!a||a==="mainnet")return null;let o={network:fe(e),cluster:gp(a),wallet:t?.name??""},r=t?.family!=="solana"?void 0:t.walletId==="phantom"?n.pay.solanaHintPhantom:t.walletId==="solflare"?n.pay.solanaHintSolflare:n.pay.solanaHintOther;return {title:c(n.pay.solanaNetwork,o),text:c(n.pay.solanaNetworkText,o),...r?{hint:c(r,o)}:{}}}function _s(e,t){let n=e.startsWith("solana:")?getSolanaCluster(e):void 0;return !n||t?.family!=="solana"||getSolanaCluster(t.chainId)===n?null:e}function Ws(e,t){let n=useContext(SatelliteStoreContext),a=_s(e,t);useEffect(()=>{a&&n?.getState().switchNetwork?.(a);},[n,a]);}function Np(e,t){return e>=1?be(e,t):new Intl.NumberFormat(t,{maximumSignificantDigits:6}).format(e)}function Tp(e,t,n,a){let o=a?.code;if(n==="declined")return c(e.pay.declined,t);if(n==="unsupported")return c(e.pay.unsupported,t);if(n==="wrongNetwork")return c(e.pay.wrongCluster,t);if(n==="switchFailed")return c(e.pay.switchFailed,t);if(n==="notAuthorized")return c(e.pay.notAuthorized,t);if(n==="alreadyPending")return c(e.walletPrompt.stillWaiting,t);if(n==="sentUnconfirmed")return c(e.pay.sentUnconfirmed,t);let r=n?null:Ot(a,e,t.merchant);return r!==null?r:n==="failed"?c(e.pay.walletFailed,t):o==="payment_failed"?c(e.pay.failed,t):o==="screening_unavailable"?e.pay.screeningUnavailable:o==="request_failed"?e.pay.noAnswer:o==="price_unavailable"||o==="price_no_rpc"?e.method.priceUnavailable:o==="rate_limited"?e.method.rateLimited:o==="method_not_found"||o==="amount_out_of_range"||o==="testnet_required"?e.method.methodUnavailable:a&&!Qt(a)?e.error.generic:null}var Rp=(...e)=>e.reduce((t,n)=>t&&!/[。!?]$/.test(t)?`${t} ${n}`:`${t}${n}`,"");function Ip(e,t,n){let{wallet:a,adapterFor:o}=_(),r=t?.instructions.family,s=r?o(r):void 0,i=e.filter(p=>p.id!==t?.methodId&&Oe(p)===r),c=xt(n&&s&&a&&i.length?`${a.address}:${i.map(p=>p.id).join()}`:null,()=>Promise.all(i.map(p=>s.getBalance({chainId:p.chainId,account:a.address,token:So(p)}).catch(()=>0n))));return c?i.map((p,u)=>({method:p,balance:c[u]})).filter(p=>p.balance>0n):[]}function qs(){let{checkout:e,state:t,store:n,labels:a,locale:o,now:r,wallet:s,adapterFor:i,connectWallet:c$1,backToMethods:p,onPaymentSent:u,customization:d,lockPrice:x,display:b}=_(),h=d.config?.balanceCheck!==false,m=t.quote,N=e?.methods??[],v=N.find(Me=>Me.id===m?.methodId),w=m?.instructions.family??"eip155",f=i(w),k=m?Le(m.instructions):"",R=s?.address??"",[y,g]=useState(false),P=xt(m?.gasless?.paymaster&&f?.canSponsorCalls&&s?`${k}:${R}`:null,()=>f.canSponsorCalls({chainId:k,account:R})),A=m?Ar(m,{withGas:y,canSponsorCalls:P===true}):"transfer",C=_a(h&&m&&f&&s?`${k}:${R}:${m.instructions.token}`:null,()=>f.getBalance({chainId:k,account:R,token:m.instructions.token}),m?.expiresAt),B=xt(m&&A==="transfer"&&f?.estimateFee&&s?`${k}:${R}:${m.amountToSend}`:null,()=>f.estimateFee({instructions:m.instructions,account:R})),G=Ps({adapter:f,store:n,quote:m,wallet:s,path:A,paymasterUrl:t.paymasterUrl,invoiceId:e?.invoice.id,onSent:u}),D=on({adapter:f,store:n,wallet:s,chainId:k});Ws(k,s);let ne=m?.instructions.token==="native",$=m&&typeof C=="bigint"?Or(C,m,ne&&B?B.amount:0n):null,z=(t.invoiceStatus??e?.invoice.status)==="underpaid",Q=Ip(N,m,h&&!!$&&!z),[X,S]=useState(false),M=D.step==="switching"||D.step==="signing"||G.status==="switching"||G.status==="submitting"||G.status==="wallet"||t.phase==="submitting",[oe,ue]=Vt(M);if(e&&m&&!v)return jsxs(Fragment,{children:[jsx(xe,{title:a.method.methodUnavailable,children:null}),jsx(re,{children:jsx(ee,{onClick:p,children:a.pay.back})})]});if(!e||!m||!v)return null;let T=e.merchant.name,F=fe(k),L=Me=>`${ye(Me,m.decimals,o)} ${m.instructions.symbol}`,K=Lr(m),me=G.askedInstructions,de=me&&me.amount!==m.instructions.amount?`${ye(me.amount,me.decimals,o)} ${me.symbol}`:L(K.send),se=m.expiresAt?Date.parse(m.expiresAt)-r:Number.POSITIVE_INFINITY,le=se<=0,Ke=Fo(se),Ne=t.phase==="quoting",ct=e.invoice.amountPaid?null:Br(m,e.invoice.totalMinor),Ae=(t.invoiceStatus??e.invoice.status)==="underpaid",pa=b==="page",Ra=B?Da(String(B.amount),B.decimals,o):null,Et=Ae?zt(m,r,a,T,o):null,qt=e.invoice.totalMinor?be(Be(e.invoice.totalMinor),o):null,ua=!!(s&&m.payer&&Ue(s,v)===m.payer),vt=w==="eip155"&&s&&s.chainId!==k&&!!f?.switchChain,Ia=G.status!=="idle"||t.phase==="submitting"||Ne||D.step!=="idle",Ve=Fs(k,s,a),Ut=()=>{n.getState().requestQuote();},bn=t.payerProof,tt=jo(bn,A),At=tt?jt(fa(t.error)?t.error:null,D.problem,a,{wallet:s?.name??"",network:F,merchant:T}):null,Ea=Tp(a,{wallet:s?.name??"",network:F,merchant:T},G.problem,t.phase==="awaitingPayment"&&!(tt&&fa(t.error))?t.error:void 0),Aa=()=>{c$1(v)||S(true);},Qe;le?Qe={label:Ae?a.outcome.payRest:a.pay.newPrice,run:Ut}:ua?vt?Qe={label:c(a.pay.switchTo,{network:F}),run:()=>{G.switchNetwork();}}:tt?Qe={label:a.payerProof.confirmToPay,run:()=>{D.confirm();}}:Qe={label:c(A==="transfer"?a.pay.payAmount:a.pay.signToPay,{amount:L(K.send)}),run:()=>{d.handlers?.onSubmit?d.handlers.onSubmit({quote:m,method:v,proceed:G.pay}):G.pay();},disabled:!!$||G.problem==="sentUnconfirmed"}:Qe={label:a.pay.connect,run:Aa};let Ht=D.step==="switching"?"switch":D.step==="signing"?"proof":G.status==="switching"?"switch":G.status==="submitting"||t.phase==="submitting"?"submitting":G.status==="wallet"?A==="transfer"?"confirm":"sign":null,La=e.invoice.number??e.invoice.id,je=s??G.askedWallet,Ba={wallet:je?.name??"",invoice:La,merchant:T};return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:oe,inert:M,className:cn("novapay:flex novapay:flex-1 novapay:flex-col",M&&"novapay:hidden"),children:[jsxs("section",{className:cn("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-3 novapay:px-5 novapay:py-4",pa&&"novapay-page-screen novapay-page-pay"),children:[jsx("h2",{...Ct,className:"novapay:sr-only",children:a.pay.title}),s&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:h-7 novapay:w-7 novapay:shrink-0",children:jsx(va,{walletId:s.walletId,icon:s.icon})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:s.name}),jsx("span",{className:cn(O,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(a.pay.walletLine,{address:shortAddress(s.address),network:fe(s.chainId)})})]}),jsx("button",{type:"button","aria-label":a.pay.changeWallet,onClick:Aa,className:cn("novapay:min-h-6 novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-transparent novapay:px-2.5 novapay:py-1 novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-bg-muted)]",ae),children:a.pay.change})]}),vt&&ua&&!le&&jsxs("div",{role:"status",className:"novapay:flex novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-pending-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-pending-text)]",children:[jsx(ExclamationTriangleIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsxs("span",{children:[jsx("strong",{className:"novapay:block",children:a.pay.wrongNetwork}),c(a.pay.wrongNetworkText,{current:fe(s.chainId),network:F})," ",a.pay.switchHint]})]}),Ve&&!le&&jsxs("div",{className:"novapay:flex novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-xs",children:[jsx(InformationCircleIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]"}),jsxs("span",{className:"novapay:flex novapay:flex-col novapay:gap-0.5",children:[jsx("strong",{children:Ve.title}),jsx("span",{children:Ve.text}),Ve.hint&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:Ve.hint})]})]}),jsxs("div",{children:[jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:Ae?a.pay.youSendRest:a.pay.youSend}),jsxs("div",{className:cn("novapay:flex novapay:items-baseline novapay:gap-2",pa&&"novapay-page-amount-row"),children:[jsx("span",{className:cn(O,"novapay:text-[28px] novapay:font-bold novapay:leading-tight",pa&&"novapay-page-amount"),children:ye(K.send,m.decimals,o)}),jsx("span",{className:cn(O,"novapay:text-sm novapay:font-semibold"),children:m.instructions.symbol}),jsx(ha,{text:Ma(K.send,m.decimals),label:a.pay.copyAmount,copiedLabel:a.pay.copied})]}),jsxs("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[c(a.pay.onNetwork,{network:F}),qt&&!K.fee&&!Ae&&jsxs(Fragment,{children:[" \xB7 ",c(a.pay.fiatValue,{amount:qt,currency:e.invoice.currency})]})]})]}),K.fee&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsxs(we,{children:[jsx(q,{name:Ae?a.pay.invoiceRest:a.pay.invoiceTotal,children:ye(K.receives,m.decimals,o)}),jsx(q,{name:c(a.pay.transferFee,{percent:K.fee.percent}),children:ye(K.fee.amount,m.decimals,o)}),jsx(q,{name:c(a.pay.merchantReceives,{merchant:T}),children:L(K.receives)})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:a.pay.transferFeeNote})]}),!le&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2 novapay:text-xs",children:[jsx(ClockIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:text-[var(--tuwa-text-secondary)]"}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:flex-1",children:c(Et?a.pay.restTimeLeft:a.pay.priceLocked,{time:at(se)})}),!Ae&&jsx(mt,{disabled:Ne,onClick:Ut,children:a.pay.refreshPrice})]}),Ke&&!Et&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-text-accent)] novapay:px-3 novapay:py-2",children:[jsx("span",{"aria-hidden":true,className:"novapay:text-xs",children:c(a.pay.priceEnding,{time:at(se)})}),jsx("span",{role:"status",className:"novapay:sr-only",children:c(a.pay.priceEnding,{time:at(On)})}),jsx("button",{type:"button",onClick:Ut,disabled:Ne,className:cn(O,"novapay:min-h-8 novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border-0 novapay:bg-[var(--tuwa-button-primary-bg)] novapay:px-3 novapay:text-xs novapay:font-bold novapay:text-[var(--tuwa-text-on-accent)] novapay:disabled:opacity-70",ae),children:c(a.pay.keepPrice,{minutes:Math.round(e.quoteTtlSeconds/60)})})]}),le&&jsx(Z,{children:a.pay.priceExpired}),Et&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:Et}),$&&!le&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-xs",children:[jsxs("div",{role:"alert",children:[jsx("strong",{className:"novapay:block",children:a.pay.notEnough}),c(a.pay.walletHas,{amount:L($.have),network:F}),"."," ",c(a.pay.shortBy,{short:L($.short),need:L($.need)})]}),Q.length>0&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:a.pay.payFromBalance}),Q.map(({method:Me,balance:wn})=>jsxs("button",{type:"button",onClick:()=>{let kn=s?Ue(s,Me):null;n.getState().selectMethod(Me.id),n.getState().setPayer(kn),x();},className:cn("novapay:flex novapay:cursor-pointer novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-transparent novapay:px-2.5 novapay:py-1.5 novapay:text-left novapay:text-xs novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-bg-muted)]",ae),children:[jsxs("span",{className:"novapay:font-semibold",children:[Me.symbol," \xB7 ",fe(Me.chainId)]}),jsx("span",{className:cn(O,"novapay:text-[var(--tuwa-text-secondary)]"),children:c(a.pay.youHave,{amount:`${ye(String(wn),Me.decimals,o)} ${Me.symbol}`})})]},Me.id))]}),e.merchant.fundingUrl&&jsxs("span",{children:[c(a.pay.topUp,{symbol:m.instructions.symbol})," ",jsxs("a",{href:e.merchant.fundingUrl,target:"_blank",rel:"noopener noreferrer",className:cn("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ae),children:[c(a.pay.getToken,{symbol:m.instructions.symbol})," \u2197"]})]})]}),jsxs(we,{children:[ct!==null&&jsx(q,{name:a.pay.rate,children:c(a.pay.rateValue,{symbol:m.instructions.symbol,price:Np(ct,o),currency:e.invoice.currency})}),jsx(q,{name:a.pay.networkFee,children:jsxs("span",{className:"novapay:inline-flex novapay:flex-col novapay:items-end novapay:gap-0.5",children:[A!=="transfer"?jsx("span",{className:"novapay:text-[var(--tuwa-success-text)]",children:c(a.pay.merchantPaysGas,{merchant:T})}):Ra?c(a.pay.gasEstimate,{amount:`${Ra} ${B?.symbol}`}):a.pay.gasFromWallet,m.gasless&&jsx(mt,{onClick:()=>g(!y),children:y?c(a.pay.payGasless,{merchant:T}):a.pay.payWithGas})]})}),jsxs(q,{name:a.pay.to,children:[jsx(Te,{hash:m.instructions.to,chainId:k}),jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:T})]})]}),tt&&!le&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:a.payerProof.payNote}),At&&jsx(Z,{children:At}),Ea&&jsx(Z,{children:Ea}),X&&jsx(Z,{children:a.pay.connectUnavailable})]}),jsxs(re,{children:[jsx(J,{busy:Ia,disabled:Qe.disabled,onClick:Qe.run,children:Qe.label}),jsx(ee,{disabled:Ne,onClick:p,children:Ae?a.pay.backFromRest:a.pay.back}),jsx(Re,{children:Rp(c(a.pay.disclaimer,{merchant:T}),..._o(e)?[c(a.pay.disclaimerScreening,{merchant:T})]:[])}),jsx(na,{})]})]}),Ht==="proof"&&jsx(Wt,{kind:"proof",walletName:je?.name??"",walletId:je?.walletId??"",walletIcon:je?.icon,amount:de,merchant:T,network:F,to:shortAddress(m.instructions.to),priceTime:null,text:c(Ha(s)?a.payerProof.promptPasskey:a.payerProof.promptText,Ba),details:[...D.request?[{name:a.payerProof.site,value:D.request.domain}]:[],{name:a.payerProof.invoice,value:La},{name:a.payerProof.merchant,value:T}],hint:D.request?c(a.payerProof.signInRequest,{wallet:je?.name??"",site:D.request.domain}):void 0,onRetry:()=>{D.confirm();},onCancel:D.dismiss,stepHeight:ue}),Ht&&Ht!=="proof"&&jsx(Wt,{kind:Ht,walletName:je?.name??"",walletId:je?.walletId??"",walletIcon:je?.icon,amount:de,merchant:T,network:F,to:shortAddress(m.instructions.to),priceTime:le?null:at(se),onRetry:A==="relay"?()=>{G.pay();}:void 0,onCancel:D.step==="switching"?D.dismiss:G.dismiss,stepHeight:ue})]})}var ao=4;function Us(e){let{size:t,data:n}=encode(e,{ecc:"M",border:0}),a="";return n.forEach((o,r)=>o.forEach((s,i)=>{s&&(a+=`M${i+ao} ${r+ao}h1v1h-1z`);})),{size:t+ao*2,path:a}}function oo({value:e,label:t,className:n}){let a=_(),o=cn(n,ce(a,"qrCode")),{size:r,path:s}=useMemo(()=>Us(e),[e]),i=a.customization.components?.QrCode;return i?jsx(i,{value:e,label:t,className:o}):jsxs("svg",{role:"img","aria-label":t,viewBox:`0 0 ${r} ${r}`,shapeRendering:"crispEdges",className:cn("novapay:block novapay:rounded-[var(--tuwa-rounded-corners)]",o),children:[jsx("rect",{width:r,height:r,fill:"#ffffff"}),jsx("path",{d:s,fill:"#111827"})]})}function Fp({payUrl:e}){let{labels:t,backToMethods:n,display:a}=_();return jsxs(Fragment,{children:[jsx(xe,{title:t.qr.handoffTitle,subtitle:t.qr.handoffHint,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-3 novapay:py-2",children:[jsx(oo,{value:e,label:t.qr.handoffCode,className:cn("novapay:h-48 novapay:w-48",a==="page"&&"novapay-page-qr-handoff")}),jsx(ha,{text:e,label:t.qr.copyLink,copiedLabel:t.pay.copied,children:t.qr.copyLink}),jsx("p",{className:"novapay:m-0 novapay:max-w-xs novapay:text-center novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:t.qr.handoffNote})]})}),jsx(re,{children:jsx(ee,{onClick:n,children:t.qr.back})})]})}function $s(){let e=_(),{checkout:t,state:n,store:a,labels:o,locale:r,now:s,payUrl:i,backToMethods:c$1}=e,p=n.quote;if(!t)return null;if(!p||p.instructions.family!=="solana")return i?jsx(Fp,{payUrl:i}):null;let{instructions:u}=p,d=fe(Le(u)),x=`${ye(p.amountToSend,p.decimals,r)} ${u.symbol}`,b=p.expiresAt?Date.parse(p.expiresAt)-s:Number.POSITIVE_INFINITY,h=b<=0,m=n.phase==="quoting",N=(n.invoiceStatus??t.invoice.status)==="underpaid",v=N?zt(p,s,o,t.merchant.name,r):null,w=N?t.invoice.originWallet:null,f=w?c(o.qr.restHint,{wallet:shortAddress(ot(w))}):o.qr.solanaHint;return jsxs(Fragment,{children:[jsxs(xe,{title:o.qr.solanaTitle,subtitle:f,children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-4 novapay:@min-[440px]:flex-row novapay:@min-[440px]:items-start",children:[jsx(oo,{value:u.solanaPayUrl,label:c(o.qr.solanaCode,{amount:x}),className:cn("novapay:h-44 novapay:w-44 novapay:shrink-0",e.display==="page"&&"novapay-page-qr",h&&"novapay:opacity-30")}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2 novapay:self-stretch novapay:text-xs novapay:@min-[440px]:self-auto",children:[jsxs("ol",{className:"novapay:m-0 novapay:flex novapay:list-decimal novapay:flex-col novapay:gap-1 novapay:pl-4",children:[jsx("li",{children:o.qr.scanStep}),jsx("li",{children:o.qr.approveStep})]}),N&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:o.pay.youSendRest}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn(O,"novapay:text-2xl novapay:font-bold"),children:ye(p.amountToSend,p.decimals,r)}),jsx(ha,{text:Ma(p.amountToSend,p.decimals),label:o.pay.copyAmount,copiedLabel:o.pay.copied})]}),jsxs("div",{className:cn(O,"novapay:flex novapay:items-center novapay:gap-1 novapay:text-[var(--tuwa-text-secondary)]"),children:[u.symbol," \xB7 ",d," \xB7"," ",jsx(Te,{hash:u.to,chainId:Le(u)})]}),!h&&jsxs(Fragment,{children:[jsxs("span",{role:"status",className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(QuasarLoader,{size:14,accent:"var(--tuwa-pending-icon)"}),o.qr.waiting]}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(v?o.pay.restTimeLeft:o.pay.priceLocked,{time:at(b)})})]})]})]}),h&&jsx(Z,{children:o.pay.priceExpired}),v&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:v}),jsxs("p",{className:"novapay:m-0 novapay:flex novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-pending-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-pending-text)]",children:[jsx(ExclamationTriangleIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),o.qr.exchangeWarning]})]}),jsxs(re,{children:[h?jsx(J,{busy:m,onClick:()=>{a.getState().requestQuote();},children:N?o.outcome.payRest:o.pay.newPrice}):jsx("a",{href:u.solanaPayUrl,className:cn(Pt,ce(e,"primaryButton")),children:o.qr.openInWallet}),jsx(ee,{onClick:c$1,children:N?o.pay.backFromRest:o.qr.back})]})]})}function Ks(e){switch(e){case "confirm":return "pending";case "unconfirmed":case "underpaid":return "warning";case "paid":return "success";case "blocked":case "error":return "error";case "held":case "refunded":case "expired":case "cancelled":case "replaced":return "neutral";default:return null}}function Gp(){let{labels:e}=_();return jsxs("div",{role:"status",className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:p-8 novapay:text-sm novapay:text-[var(--tuwa-text-secondary)]",children:[jsx(QuasarLoader,{size:48}),e.common.loading]})}function zp(){let{labels:e,state:t,store:n}=_(),a=t.error?.code==="checkout_not_found";return jsxs("div",{role:"alert",className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:p-8 novapay:text-center",children:[jsx(ExclamationTriangleIcon,{"aria-hidden":true,className:"novapay:h-7 novapay:w-7 novapay:text-[var(--tuwa-error-icon)]"}),jsx("h2",{...Ct,className:rt,children:e.error.title}),jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-[13px] novapay:text-[var(--tuwa-text-secondary)]",children:a?e.error.notFound:e.error.generic}),!a&&jsx(ee,{onClick:()=>{n.getState().load();},className:"novapay:w-auto novapay:px-6",children:e.common.retry})]})}var Qp=new Set(["paid","partially_refunded","refunded"]);function Vs(){let{screen:e,customization:t}=_(),n=t.components?.screens?.[e];return n?jsx(n,{screen:e}):e==="loading"?jsx(Gp,{}):e==="error"?jsx(zp,{}):e==="buyer"?jsx(mr,{}):e==="method"?jsx(Yr,{}):e==="confirmWallet"?jsx(Ur,{}):e==="pay"?jsx(qs,{}):e==="qr"?jsx($s,{}):e==="confirm"?jsx(Dr,{}):e==="paid"?jsx(ls,{}):e==="autoPay"?jsx(sr,{}):e==="autoPayOff"?jsx(Os,{}):jsx(as,{kind:e})}function jp({className:e,withDetails:t,leave:n}){let a=_(),{checkout:o,locale:r,labels:s,now:i,customization:c$1,display:p}=a,{Header:u=Rr,Summary:d=kr,CompactSummary:x=Cr}=c$1.components??{},b=c$1.config?.deadlineAnnouncements,{screen:h}=a,m=useRef(null),N=useRef(h);useEffect(()=>{let C=N.current;N.current=h;let B=m.current;if(!B||C===h||C==="loading")return;let G=B.ownerDocument.activeElement;if(G&&G!==B.ownerDocument.body&&!B.contains(G))return;let D=B.querySelector("[data-novapay-scroll] [data-novapay-heading]");if(p!=="page")return D?.focus();B.getBoundingClientRect().top<0&&B.scrollIntoView({block:"start"}),D?.focus({preventScroll:true});},[h,p]);let[v,w]=useState(""),f=useRef(null),k=o?.invoice.dueAt?Date.parse(o.invoice.dueAt):null,R=o?ya(o.invoice.status,h,o.invoice.restPayable)==="paying":false;useEffect(()=>{if(k===null)return;let C=k-i,B=Lo(f.current,C,b);f.current=C,B!==null&&R&&w(B===1?s.summary.oneMinuteLeft:c(s.summary.minutesLeft,{minutes:B}));},[k,i,s,b,R]);let y=p==="page",g=Zo[y?"page":"default"],P=Ks(h),A=c$1.components?.StatusEdge??StatusEdge;return jsxs("div",{ref:m,lang:r,className:cn(g.frame,Va(p).frame,e),children:[o&&jsx("aside",{inert:!!n,className:cn(g.aside,ce(a,"summary")),children:jsx(d,{})}),jsxs("div",{inert:!!n,className:cn("novapay:relative",g.main),children:[P&&jsx(A,{tone:P,className:cn("novapay:z-20",ce(a,"statusEdge",{tone:P}))}),jsx(u,{withDetails:t}),jsxs("div",{className:"novapay:sm:hidden",children:[o&&jsx(x,{className:ce(a,"compactSummary")}),jsx(Ir,{withDetails:t})]}),jsx("div",{"data-novapay-scroll":"",className:cn(g.area,ce(a,"body")),children:y?jsx("div",{className:cn("novapay:flex novapay:flex-1 novapay:flex-col",!c$1.config?.animation?.disabled&&"novapay-page-fade"),children:jsx(Vs,{})},P?"status":h):jsx(Vs,{})})]}),jsx("div",{role:"status","aria-live":"polite",className:"novapay:sr-only",children:v}),n&&jsx(Kr,{onStay:n.onStay,onLeave:n.onLeave})]})}function eg({token:e,display:t="modal",open:n=true,onOpenChange:a,onClose:o,baseUrl:r,api:s,EventSource:i,pollMs:c$1,payUrl:p,onConnectWallet:u,onPaid:d,autoReturnSeconds:x,onContact:b,className:h,customization:m}){let N=it(),[v,w]=useState({from:e,token:e}),f$1=v.from===e?v.token:e,[k,R]=useState(t!=="modal"||n);!k&&(t!=="modal"||n)&&R(true);let y=ms({token:f$1,baseUrl:r??N.baseUrl,api:s,EventSource:i,pollMs:c$1,enabled:k}),g=ds(y,ve=>ve),P=g.checkout,A=g.locale??P?.invoice.locale??"en",C=Na(A),B=!!P&&k&&Qo(g.phase,x,f(A)),D=xs(1e3,B)-(g.clockSkewMs??0),ne=ln(),$=dn(u),z=N.adapters,[Q,X]=useState("wallet"),[S,M]=useState(false),[oe,ue]=useState(false),[T,F]=useState(null),[L,K]=useState(false),[me,de]=useState(null);P&&me?.store!==y&&de({store:y,paid:Qp.has(P.invoice.status)});let[se,le]=useState(false),[Ke,Ne]=useState(false),[ct,Ae]=useState(f$1);ct!==f$1&&(Ae(f$1),M(false),ue(false),F(null),K(false),X("wallet"),Ne(false));let pa=g.payerProof==="confirmed"&&!!g.error,Ra=g.error?.code==="payer_mismatch";Ke&&(g.phase==="awaitingPayment"||pa||Ra)&&Ne(false);let Et=(g.invoiceStatus??P?.invoice.status)==="underpaid"?P?.invoice.originWallet??null:null,qt=ve=>!Et||bt(ve,Et),ua=P?.methods.find(ve=>ve.id===g.methodId),vt=ua?Ue(ne,ua):null,Ia=Oo({open:Ke,storePayer:g.payer,payer:vt,paysRest:!vt||qt(vt)});Ia==="leave"&&Ne(false);let Ve=useRef(null),[Ut,bn]=useState(false);!Ut&&P&&f(A)&&bn(true);let tt=Ro(g,{payWith:Q,handoff:S,autoPay:oe,autoPayOff:T==="open",confirmWallet:Ke,labelsReady:Ut||!P}),At=async()=>{await Yo(y,Ne);},Ea=fs(y),Aa=As({store:y,screen:tt}),[Qe,Ht]=useState(null),La=Es({store:y,state:g,walletTxKey:Qe?.store===y?Qe.txKey:null});ss(g.phase,P?.invoice,d,me?.store===y&&me.paid),ps({state:g,screen:tt,now:D,handlers:m?.handlers});let je=ve=>z?.find(lt=>lt.family===ve),Ba=Rs({store:y,open:t!=="modal"||n,adapterFor:je,pulsar:N.pulsar,labels:C,locale:A}),Me=useCallback(ve=>{Ht({store:y,txKey:ve.txKey}),Ba(ve);},[y,Ba]),wn=useEffectEvent(()=>{if(!P)return;let{quote:ve,phase:lt}=y.getState();if(ne&&Ve.current){let Fa=P.methods.find(di=>di.id===Ve.current),Nn=Fa?Ue(ne,Fa):null;if(!Nn)return;Ve.current=null,y.getState().setPayer(Nn),qt(Nn)&&At();return}if(lt==="selectMethod"||lt==="underpaid"||lt==="blocked"){if(g.payer===null||vt===g.payer)return;y.getState().setPayer(vt),Ia==="follow"&&At();return}if(!ne)return;let ma=P.methods.find(Fa=>Fa.id===ve?.methodId),Oa=ma?Ue(ne,ma):null,mo=Bo({autoPayOffOpen:T==="open",phase:lt,quotePayer:ve?.payer,payer:Oa});if(mo==="release")return y.getState().releaseQuote();mo==="keep"||!Oa||(y.getState().setPayer(Oa),qt(Oa)&&At());}),kn=g.quote?.payer,ci=!!P;useEffect(()=>wn(),[ne?.address,ne?.chainId,ne?.connectorType,T,g.phase,kn,ci]),useEffect(()=>{$.connecting||(Ve.current=null);},[$.connecting]);let[lo,li]=useState(false);tt==="buyer"&&!lo&&li(true);let Cn=useMemo(()=>t==="modal"?()=>{a?.(false),o?.();}:o,[t,a,o]),pi=Cn&&(()=>_n(y.getState().phase,y.getState().error,y.getState().invoiceStatus)&&!mn(y)?le(true):Cn()),ui=se?{onStay:()=>le(false),onLeave:()=>{le(false),y.getState().releaseQuote(),Cn?.();}}:null,po=m??{},mi={store:y,state:g,checkout:P,screen:tt,locale:A,labels:C,now:D,handedOverAt:Ea,qrShown:Aa,paymentSent:La||mn(y),close:pi,wallet:ne,payWith:Q,setPayWith:X,payUrl:p,connectWallet:ve=>{let lt=Oe(ve);Ve.current=ve.id;let ma=lt!==null&&$.connect(lt);return ma||(Ve.current=null),ma},connectFamily:ve=>$.connect(ve),openedPaid:me?.store===y&&me.paid,revokeSent:L,setRevokeSent:K,adapterFor:je,handoff:S,setHandoff:M,backToMethods:()=>{M(false),Ne(false),y.getState().releaseQuote();},confirmWallet:Ke,setConfirmWallet:Ne,lockPrice:At,onPaymentSent:Me,autoPay:oe,setAutoPay:ue,autoPayOff:T,setAutoPayOff:F,openInvoice:ve=>w({from:e,token:ve}),onContact:b,autoReturnSeconds:x??(t==="modal"?0:5),display:t,customization:po},Pn=cn(h,ce({customization:po,screen:tt,state:g,checkout:P},"container")),Sn=jsx(xo,{value:mi,children:jsx(MotionConfig,{reducedMotion:m?.config?.animation?.disabled?"always":"user",children:jsx(jp,{withDetails:lo,leave:ui,className:t==="modal"?Pn:void 0})})});if(t==="modal")return jsx(Dialog,{open:n,onOpenChange:ve=>{if(!ve&&se)return le(false);if(!ve&&_n(y.getState().phase,y.getState().error,y.getState().invoiceStatus)&&!mn(y))return le(true);a?.(ve),ve||o?.();},children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-auto",children:[jsx(DialogTitle,{className:"novapay:sr-only",children:c(C.common.dialogTitle,{merchant:P?.merchant.name??""})}),Sn]})});let uo=c(C.common.dialogTitle,{merchant:P?.merchant.name??""});return t==="page"?jsx(Yp,{label:uo,className:Pn,children:Sn}):jsx("section",{"aria-label":uo,className:cn("novapay:overflow-hidden novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)]",Va(t).section,Pn),children:Sn})}function Yp({label:e,className:t,children:n}){return jsx("div",{className:"novapay-page",children:jsx("section",{"aria-label":e,className:cn(Va("page").section,"novapay-page-block",t),children:n})})}function Gs(e){if(!e.to)return null;let t=parseCaip19AssetId(e.assetId),n={to:e.to,token:!t||t.assetNamespace==="slip44"?"native":t.assetReference,amount:e.amount,decimals:e.decimals,symbol:e.symbol},a=qa(e.chainId);if(a==="solana")return {family:a,chainId:e.chainId,...n,reference:"",solanaPayUrl:""};let o=a==="eip155"?toEvmChainId(e.chainId):void 0;return o===void 0?null:{family:"eip155",chainId:o,...n}}function Qs(e){let t=b$1(e);return t==="switchFailed"?"wrongNetwork":t==="notAuthorized"||t==="alreadyPending"||t==="sentUnconfirmed"?"failed":t}var io=new WeakMap,ca=new WeakMap;function js({store:e,invoiceId:t,invoice:n,params:a,open:o,labels:r,locale:s,onConnectWallet:i}){let c$1=useStore(e),{adapters:p,pulsar:u}=it(),d=ln(),x=dn(i),[b,h]=useState("idle"),[m,N]=useState(null),[,v]=useState(0),w=ca.has(e),f=useRef(0),k=useRef(o),R=c$1.sentTransaction?.txHash??c$1.refund?.txHash??null,y=c$1.instructions?Gs(c$1.instructions):null,g=y?.family??null,P=y?Le(y):c$1.instructions?.chainId??null,A=p?.find(L=>L.family===g),C=d&&d.family===g?d:null,B=P?fe(P):"",G=m&&m.account===C?.address?m.problem:null,D=L=>N(L?{problem:L,account:C?.address}:null),ne=!!(C&&g==="eip155"&&P&&C.chainId!==P),$=c$1.instructions,z=$?`${ye($.amount,$.decimals,s)} ${$.symbol}`:"",Q=_a(y&&C&&A?`balance|${P}|${C.address}|${y.token}`:null,()=>A.getBalance({chainId:P,account:C.address,token:y.token}),c$1.refund?.id),X=xt(y&&C&&A?.estimateFee?`fee|${P}|${C.address}|${y.token}`:null,()=>A.estimateFee({instructions:y,account:C.address}));useEffect(()=>{!a||io.get(e)===t||e.getState().phase!=="idle"||(io.set(e,t),e.getState().start(t,a));},[a,e,t]),useEffect(()=>{o&&!k.current&&!a&&e.getState().phase==="confirmed"&&e.getState().reset(),k.current=o;},[o,a,e]),useEffect(()=>(e.getState().keepFollowing(),()=>e.getState().stopFollowing()),[e]),useEffect(()=>{let L=true;return ca.get(e)?.settled.then(()=>{L&&v(K=>K+1);}),()=>{L=false;}},[e]);let S=async(L,K,me)=>{if(!u||!A?.pulsarTransaction||!c$1.refund)return;let de={invoice:n??t,amount:z};try{await u.injectExternalPendingTxs([A.pulsarTransaction({txKey:L,instructions:me,account:K.address,connectorType:K.connectorType,title:c(r.refund.txTitle,de),description:c(c$1.refund.heldTransfer?r.refund.txDescriptionSender:r.refund.txDescription,de),payload:{quasarRefund:c$1.refund.id}})]);}catch{}},M=async()=>{if(D(null),!(!ne||!A?.switchChain))try{h("switching"),await A.switchChain(P);}catch(L){D(Qs(L));}finally{h("idle");}},oe=async()=>{if(D(null),!y)return D("noRecipient");if(!C||!A)return D("unsupported");if(c$1.sentTransaction){await e.getState().submit(c$1.sentTransaction);return}let L=BigInt(y.amount)+(y.token==="native"&&X?X.amount:0n);if(typeof Q=="bigint"&&Q<L)return D("notEnough");if(g&&y.to&&isSameAddress(g,C.address,y.to))return D("fromBuyer");if(!await e.getState().recheck()){let de=e.getState(),se=de.error?.code==="refund_repriced";de.phase==="awaitingTransfer"&&!de.sentTransaction&&!se&&D("unreachable");return}let K=++f.current,me=()=>f.current===K;try{ne&&A.switchChain&&(h("switching"),await A.switchChain(P)),me()&&h("wallet");let de=await A.sendTransfer({instructions:y,account:C.address,connection:C.connection});me()?h("idle"):N(null),S(de,C,y),await e.getState().submit({txHash:de,from:C.address});}catch(de){me()?(h("idle"),D(Qs(de))):N(null);}},ue=async()=>{if(ca.has(e))return;let L,K={settled:new Promise(se=>L=se)},me=()=>{ca.get(e)===K&&ca.delete(e),L(),v(se=>se+1);},de=setTimeout(me,6e5);ca.set(e,K),v(se=>se+1);try{await oe();}finally{clearTimeout(de),me();}},T=b!=="idle"?b:C?"confirm":"connect";return {step:c$1.phase==="idle"?a&&!c$1.error&&io.get(e)!==t?"requesting":"amount":c$1.phase==="awaitingTransfer"?T:c$1.phase,phase:c$1.phase,refund:c$1.refund,error:c$1.error,transfer:y,chainId:P,network:B,amount:z,wallet:C,wrongNetwork:ne,balance:Q,fee:X,problem:G??(c$1.instructions&&!y?"noRecipient":null),txKey:R,transactionUrl:L=>P?A?.explorerUrl?.({chainId:P,txKey:L}):void 0,addressUrl:L=>P?A?.explorerAddressUrl?.({chainId:P,address:L}):void 0,canConnect:x.canConnect,connecting:x.connecting,preview:async L=>{let K=await e.getState().preview(t,L);return K||(e.getState().error?"refused":null)},start:async L=>{D(null),await e.getState().start(t,L);},connect:()=>{g&&x.connect(g);},switchNetwork:M,send:ue,dismiss:()=>{f.current++,h("idle"),D("stillInWallet");},sending:w}}function Lg({label:e,className:t,disabled:n,...a}){let[o,r]=useState(false),s=Na(a.locale??"en");return jsxs(Fragment,{children:[jsx("button",{type:"button",disabled:n,onClick:()=>r(true),className:cn(Pt,"novapay:w-auto novapay:px-4",t),children:e??s.refund.button}),jsx(iu,{...a,open:o,onOpenChange:r})]})}function iu({open:e,onOpenChange:t,locale:n="en",onRefunded:a,...o}){let r=Na(n),s=js({store:o.store,invoiceId:o.invoiceId,invoice:o.invoice,params:e?o.params:void 0,open:e,labels:r,locale:n,onConnectWallet:o.onConnectWallet}),i=useEffectEvent(u=>a?.(u)),c$1=s.phase==="confirmed"?s.refund:null;useEffect(()=>{c$1&&i(c$1);},[c$1]);let p=o.invoice?c(r.refund.title,{invoice:o.invoice}):r.refund.button;return jsx(Dialog,{open:e,onOpenChange:t,children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-[440px]",children:[jsxs("div",{className:"novapay:flex novapay:items-center novapay:justify-between novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:px-5 novapay:py-3",children:[jsx(DialogTitle,{className:cn(O,"novapay:m-0 novapay:truncate novapay:text-sm novapay:font-bold"),children:p}),jsx("button",{type:"button","aria-label":r.refund.close,onClick:()=>t(false),className:kt,children:jsx(XMarkIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]}),jsx(cu,{flow:s,labels:r,locale:n,close:()=>t(false),...o})]})})}function cu({flow:e,labels:t,locale:n,close:a,currency:o="USD",refundable:r,details:s,onRecord:i}){let c$1=t.refund,p={network:e.network,symbol:e.transfer?.symbol??e.refund?.assetId??"",amount:e.amount,wallet:e.wallet?.name??""},u=e.refund?.txHash??e.txKey,d=i&&jsxs(Fragment,{children:[jsx(ee,{onClick:i,children:c$1.record}),jsx(Re,{children:c$1.recordHint})]});switch(e.step){case "amount":return jsx(vu,{flow:e,labels:t,locale:n,currency:o,refundable:r});case "requesting":case "submitting":return jsx(ei,{children:e.step==="requesting"?c$1.requesting:c$1.submitting});case "switching":case "wallet":return jsxs(Fragment,{children:[jsxs(ei,{walletId:e.wallet?.walletId,walletIcon:e.wallet?.icon,children:[jsx("strong",{className:cn(O,"novapay:text-sm"),children:c(e.step==="switching"?c$1.switchTitle:c$1.walletTitle,p)}),e.step==="wallet"&&jsx("span",{children:c(c$1.walletText,p)})]}),jsx(re,{children:jsx(ee,{onClick:e.dismiss,children:t.walletPrompt.cancel})})]});case "connect":return jsxs(Fragment,{children:[jsxs(xe,{title:c$1.connectTitle,subtitle:c(c$1.connectText,p),children:[e.problem==="noRecipient"&&jsx(Z,{children:c$1.noRecipient}),!e.canConnect&&jsx(Z,{children:c$1.connectUnavailable})]}),jsxs(re,{children:[e.canConnect&&e.problem!=="noRecipient"&&jsx(J,{busy:e.connecting,onClick:e.connect,children:c$1.connect}),d]})]});case "confirm":return jsx(hu,{flow:e,labels:t,locale:n,values:p,details:s?.confirm,recordAction:d});case "confirming":return jsxs(Fragment,{children:[jsxs(xe,{title:c$1.onItsWay,children:[jsxs(we,{children:[jsx(q,{name:c$1.status,children:c$1.pending}),u&&jsx(q,{name:c$1.transaction,children:jsx(Te,{hash:u,explorerUrl:e.transactionUrl(u),labels:t})}),jsx(q,{name:c$1.network,children:c(c$1.waiting,p)})]}),Xs(e.refund)&&jsx(Re,{children:c$1.slowNote})]}),jsxs(re,{children:[jsx(ee,{onClick:a,children:c$1.close}),Xs(e.refund)?d:jsx(Re,{children:c$1.canClose})]})]});case "confirmed":return jsxs(Fragment,{children:[jsx(xe,{title:c$1.refunded,children:jsxs(we,{children:[e.refund?.creditNoteNumber&&jsx(q,{name:c$1.creditNote,children:e.refund.creditNoteNumber}),u&&jsx(q,{name:c$1.transaction,children:jsx(Te,{hash:u,explorerUrl:e.transactionUrl(u),labels:t})}),s?.done]})}),jsx(re,{children:jsx(J,{onClick:a,children:c$1.done})})]});case "failed":return jsx(fu,{flow:e,labels:t,locale:n,values:p,recordAction:d,close:a})}}var lu={amount_short:"failedShort",over_limit:"failedByHand",tx_of_another_refund:"failedByHand",refund_from_buyer:"failedFromBuyer",transaction_failed:"failedNotFound",dropped:"failedDropped",too_early:"failedTooEarly",no_matching_transfer:"failedNoTransfer",withdrawn:"failedWithdrawn",cancelled:"failedCancelling",cancelled_final:"failedCancelled",resend_confirmed:"failedResendConfirmed"},Zs=(e,t,n)=>{let a=e?.failureReason?lu[e.failureReason]:void 0;return a?t[a]:c(t.failedText,n)},pu={withdrawn:"failedWithdrawnTitle",cancelled:"failedCancelledTitle",cancelled_final:"failedCancelledTitle"},Js=(e,t)=>t[e?.failureReason&&pu[e.failureReason]||"failedTitle"],uu={refund_repriced:"movedTitle",request_failed:"unreachable",amount_exceeds_refundable:"refusedAmount",invoice_not_refundable:"refusedNotRefundable",payment_unknown:"refusedNotRefundable",held_transfer_not_refundable:"refusedNotRefundable",held_refund_must_be_whole:"refusedWhole",sender_blocked:"refusedBlocked",refund_not_waiting:"refusedNotWaiting",refund_may_have_landed:"refusedMayHaveLanded",refund_from_buyer:"failedFromBuyer",method_not_priced:"refusedPrice",price_no_rpc:"refusedPrice",price_unavailable:"refusedPrice",mainnet_disabled_on_node:"refusedTestOnly"},mu=600*1e3,Xs=e=>{let t=e?.updatedAt??e?.createdAt;return !!t&&Date.now()-Date.parse(t)>mu},xn=(e,t)=>e.text??t[uu[e.code]??"refusedOther"],du=e=>e?.failureReason==="over_limit"||e?.failureReason==="tx_of_another_refund",yu=e=>{let t=e.mode==="fiat_value"||e.failureReason==="amount_short";return {mode:t?"fiat_value":e.mode,...t&&{amount:e.amount},...e.reason&&{reason:e.reason}}};function ni(e){let[t,n]=useState(false),[a,o]=useState(null),r=useRef(false);return useEffect(()=>(r.current=false,()=>{r.current=true;}),[]),{ask:async(i,c)=>{if(i?.mode==="fiat_value"){n(true);let p=await e.preview(i);if(r.current||(n(false),p==="refused"))return;if(p&&zo(c?{cryptoAmount:p.cryptoAmount,atPaymentRate:c.cryptoAmount}:p))return o({preview:p,request:i})}o(null),e.start(i);},checking:t,moved:a,back:()=>o(null)}}function oi({preview:e,request:t},n,a,o,r,s){let i=o.refund,c$1=p=>`${ye(p,e.decimals,r)} ${e.symbol}`;return jsxs(Fragment,{children:[jsxs(xe,{title:i.movedTitle,children:[jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(i.movedText,{symbol:e.symbol})}),jsxs(we,{children:[jsx(q,{name:i.movedSend,children:c$1(e.cryptoAmount)}),e.atPaymentRate&&jsx(q,{name:i.movedAtPayment,children:c$1(e.atPaymentRate)}),e.received&&jsx(q,{name:i.movedReceived,children:c$1(e.received)})]}),s&&e.exactPossible&&jsx(Re,{children:c(i.movedExact,{exact:i.modeExact})}),a.error&&jsx(Z,{children:xn(a.error,i)})]}),jsxs(re,{children:[jsx(J,{busy:n.checking,onClick:()=>{n.ask(t,e);},children:i.movedContinue}),jsx(ee,{disabled:n.checking,onClick:n.back,children:i.movedBack})]})]})}function fu({flow:e,labels:t,locale:n,values:a,recordAction:o,close:r}){let s=t.refund,i=ni(e);return e.refund?.heldTransfer?jsxs(Fragment,{children:[jsxs(xe,{title:Js(e.refund,s),children:[jsx(Z,{children:Zs(e.refund,s,a)}),jsx(Re,{children:s.failedHeldNote})]}),jsx(re,{children:jsx(J,{onClick:r,children:s.close})})]}):i.moved?oi(i.moved,i,e,t,n,false):jsxs(Fragment,{children:[jsxs(xe,{title:Js(e.refund,s),children:[jsx(Z,{children:Zs(e.refund,s,a)}),e.error&&jsx(Z,{children:xn(e.error,s)})]}),jsxs(re,{children:[du(e.refund)?jsx(J,{onClick:r,children:s.close}):jsx(J,{busy:i.checking,onClick:()=>e.refund&&void i.ask(yu(e.refund)),children:s.sendRefund}),o]})]})}function ei({walletId:e,walletIcon:t,children:n}){return jsxs("section",{role:"status",className:"novapay:flex novapay:min-h-56 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:px-5 novapay:py-6 novapay:text-center",children:[jsx(Ga,{walletId:e,walletIcon:t}),n]})}function vu({flow:e,labels:t,locale:n,currency:a,refundable:o}){let r=t.refund,s=useId(),i=useId(),[c$1,p]=useState("fiat_value"),[u,d]=useState(""),[x,b]=useState(""),h=ni(e),m=c$1==="exact_received"||u.trim()===""||/^\d{1,12}(\.\d{1,2})?$/.test(u.trim()),N=[{key:"fiat_value",title:r.modeFiat,hint:c(r.modeFiatText,{currency:a})},{key:"exact_received",title:r.modeExact,hint:r.modeExactText}],v="novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-sm novapay:text-[var(--tuwa-text-primary)]",w={mode:c$1,...c$1==="fiat_value"&&u.trim()&&{amount:u.trim()},...x.trim()&&{reason:x.trim()}};return h.moved?oi(h.moved,h,e,t,n,true):jsxs(Fragment,{children:[jsxs(xe,{title:r.amountTitle,children:[jsxs("fieldset",{disabled:h.checking,className:"novapay:contents",children:[jsx(oa,{label:r.amountTitle,items:[...N],value:c$1,getKey:f=>f.key,onChange:f=>p(f),className:"novapay:flex novapay:flex-col novapay:gap-2",itemClassName:()=>"novapay:flex novapay:flex-col novapay:gap-0.5 novapay:px-3 novapay:py-2.5",children:f=>jsxs(Fragment,{children:[jsx("span",{className:"novapay:text-sm novapay:font-semibold",children:f.title}),jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:f.hint})]})}),c$1==="fiat_value"&&jsxs("label",{htmlFor:s,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsxs("span",{children:[c(r.amount,{currency:a}),jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]})]}),jsx("input",{id:s,required:true,inputMode:"decimal",value:u,placeholder:"0.00","aria-invalid":!m||void 0,onChange:f=>d(f.target.value.replace(",",".")),className:cn(O,v)}),o&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(r.amountHint,{amount:o})})]}),jsxs("label",{htmlFor:i,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsx("span",{children:r.reason}),jsx("input",{id:i,value:x,maxLength:500,onChange:f=>b(f.target.value),className:v})]})]}),e.error&&jsx(Z,{children:xn(e.error,r)})]}),jsx(re,{children:jsx(J,{busy:h.checking,disabled:!m,onClick:()=>{h.ask(w);},children:r.continue})})]})}function ti(e,t){return jsxs("span",{className:"novapay:flex novapay:flex-col novapay:items-end novapay:gap-1",children:[e,t&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:t})]})}function hu({flow:e,labels:t,locale:n,values:a,details:o,recordAction:r}){let s=t.refund,i=e.transfer,c$1=typeof e.balance=="bigint"&&i?`${ye(e.balance.toString(),i.decimals,n)} ${i.symbol}`:null,p=e.fee?Da(e.fee.amount.toString(),e.fee.decimals,n):null,u=e.fee&&p?`${p} ${e.fee.symbol}`:null,d={notEnough:c(s.notEnough,{...a,address:e.wallet?shortAddress(e.wallet.address):"",balance:c$1??""}),declined:c(s.declined,a),unsupported:c(s.unsupported,a),wrongNetwork:c(s.wrongNetwork,a),failed:s.failed,noRecipient:s.noRecipient,fromBuyer:s.failedFromBuyer,stillInWallet:c(t.walletPrompt.stillWaiting,a),unreachable:s.unreachable},x=!!e.problem,b=!!e.txKey;return jsxs(Fragment,{children:[jsxs(xe,{title:x?s.notSent:s.confirmTitle,children:[jsxs(we,{children:[jsx(q,{name:s.send,children:a.amount}),jsx(q,{name:s.network,children:a.network}),i&&jsx(q,{name:s.to,children:ti(jsx(Te,{hash:i.to,explorerUrl:e.addressUrl(i.to),labels:t}),e.refund?.heldTransfer?s.theSender:s.thePayer)}),e.wallet&&jsx(q,{name:s.from,children:ti(jsx(Te,{hash:e.wallet.address,explorerUrl:e.addressUrl(e.wallet.address),labels:t}),c$1&&c(s.balance,{amount:c$1}))}),u&&jsx(q,{name:s.networkFee,children:c(s.feeEstimate,{amount:u})}),o]}),e.problem&&jsx(Z,{children:d[e.problem]}),e.problem&&!["noRecipient","unreachable","stillInWallet"].includes(e.problem)&&jsx(Re,{children:s.nothingSent}),b&&e.error&&jsx(Z,{children:s.notHandedOver}),!b&&e.error&&e.problem!=="unreachable"&&jsx(Z,{children:xn(e.error,s)})]}),jsxs(re,{children:[e.problem!=="noRecipient"&&(e.wrongNetwork&&!b?jsx(J,{onClick:()=>{e.switchNetwork();},children:c(s.switchTo,a)}):jsx(J,{busy:e.sending,onClick:()=>{e.send();},children:b?s.handOver:s.sendRefund})),(x||b)&&r,!x&&!b&&e.wallet&&jsx(ee,{onClick:e.connect,children:t.pay.changeWallet})]})]})}function bu(e){return e.appStore?e.novaConnect?"app":"appStore":e.ownConnection?"own":"none"}function gn(e){let t=useContext(SatelliteStoreContext),n=useContext(NovaConnectProviderContext);return bu({appStore:t!=null,novaConnect:n!==void 0,ownConnection:e})}function ib(){let e=it(),t=gn(false);return e.connection??t}var ku=()=>import('./OwnConnection-ET76SUMX.js').then(e=>({default:e.OwnConnection})),si=lazy(ku);var Ru=()=>process.env.NODE_ENV==="development";function fb({baseUrl:e,labels:t,customization:n,adapters:a,pulsar:o,ownConnection:r,onConnectWallet:s,children:i}){let c=useContext(Sa),p=gn(!!r),[u]=useState(p),[d]=useState(r),x=u==="own"?r??d:void 0,b=(u==="app"||u==="appStore")&&c.connection!==void 0&&c.connection!=="none",h=x?x.adapters:a??(b?c.adapters:void 0),m=useMemo(()=>({baseUrl:e,labels:t,customization:n,adapters:h,pulsar:o,connection:u,onConnectWallet:s}),[e,t,n,h,o,u,s]),N=useRef(null),v=!!r,w=!!h;return useEffect(()=>{if(!Ru())return;N.current??=new Set;let f=N.current,k=(R,y)=>{f.has(R)||(f.add(R),console.warn(`[NovaPaymentsProvider] ${y}`));};p!==u&&k("connection",`it keeps the wallet connection it chose on its first render ("${u}"), though the providers above now call for "${p}". Render it inside the app's SatelliteConnectProvider and NovaConnectProvider from the start.`),v&&u==="appStore"&&k("appStore","it is inside the app's SatelliteConnectProvider without NovaConnectProvider: it uses the app's wallet and never adds a second store, so `ownConnection` is not used. Connect wallets with `onConnectWallet`, or render it inside NovaConnectProvider."),v&&!w&&(u==="app"||u==="appStore")&&k("adapters","it uses the app's wallet connection, so the adapters of `ownConnection` are not used: pass `adapters` on the app's wagmi config to pay from the app's wallet.");},[p,u,v,w]),jsx(Sa.Provider,{value:m,children:x?jsx(Suspense,{fallback:null,children:jsx(si,{own:x,children:i})}):i})}
2
- export{vu as AmountStep,sr as AutoPayScreen,mr as BuyerScreen,Wa as CheckoutContext,xo as CheckoutContextProvider,jp as CheckoutFrame,Rr as CheckoutHeader,Yp as CheckoutPageRoot,yr as CheckoutStepper,kr as CheckoutSummary,Cr as CompactSummary,Dr as ConfirmScreen,hu as ConfirmStep,Ur as ConfirmWalletScreen,Oi as DEADLINE_ANNOUNCEMENTS,xr as DeadlineTimer,Ja as Disclosure,fu as FailedStep,Kr as LeaveDialog,Sr as LocaleSwitcher,Za as MerchantBadge,Yr as MethodScreen,Ir as MobileSteps,Sa as NovaPaymentsContext,fb as NovaPaymentsProvider,wt as OPEN_REQUEST_MS,gr as OrderLines,Pc as OrderTotal,as as OutcomeScreen,ls as PaidScreen,qs as PayScreen,eg as PaymentCheckout,On as QUOTE_WARNING_MS,$s as QrScreen,Lg as RefundButton,iu as RefundDialog,cu as RefundSteps,Vs as ScreenBody,qn as SellerDetailsContent,br as SummaryFooter,Wt as WalletPrompt,ot as addressOfWallet,Ko as autoPayTerms,Or as balanceShortfall,Ma as baseUnitsToDecimal,Dn as buyerFields,cr as buyerIssues,Po as canPayWithQr,ce as checkoutClassName,Ro as checkoutScreen,Io as checkoutSteps,lr as cleanBuyer,Co as connectedWallet,Ho as contactHref,pr as countryOptions,Lo as deadlineAnnouncement,ya as deadlineState,qa as familyOf,at as formatCountdown,Da as formatFeeAmount,be as formatFiat,Ua as formatPeriod,ye as formatTokenAmount,Wn as grantableOffer,Ao as groupMethodsByToken,Ts as handOverPayment,Le as instructionsChainId,Xt as invoiceTotals,fa as isConfirmationError,Mo as isFinalPaymentFailure,pt as isInvoicePaymentOnTheWay,Bt as isInvoicePaymentUnresolved,ut as isMovedMoneyFailure,qo as isPaidElsewhere,Qt as isPayerProofError,mn as isPaymentAccepted,nt as isPaymentOnTheWay,Fo as isQuoteEnding,bt as isSameWallet,Xs as isSlow,Ha as isSmartWallet,Ln as isWalletIconUrl,Ot as leftTheWalletText,Yo as lockPrice,Bo as lockedPriceOnWallet,Gt as methodErrorText,Oe as methodFamily,So as methodToken,Be as minorToDecimal,_n as needsLeaveConfirm,jo as needsPayerProof,Qo as needsTheClock,fe as networkName,Eo as paidSteps,ks as payInvoice,Ar as payPath,Ue as payerFor,jt as payerProofErrorText,Bn as priceAdjustment,Us as qrPath,Lr as quoteAmounts,Br as quoteRate,Go as receivedAmount,zo as refundRateMoved,Gs as refundTransfer,xn as refusalText,zt as restRateText,_o as screensPayingWallets,Wo as sentBeforeDeadline,Ns as shouldHandOver,To as takeOverOpens,gt as unconfirmedFollowUp,Uo as unconfirmedTxKey,Vo as underpaidRest,xt as useAsyncValue,is as useAutoReturn,_ as useCheckoutContext,ps as useCheckoutEvents,ds as useCheckoutState,ms as useCheckoutStore,ln as useConnectedWallet,it as useNovaPayments,xs as useNow,Ge as useOptionalCheckoutContext,ss as usePaidCallback,on as usePayerProof,Ps as usePayment,an as usePaymentFacts,Rs as usePaymentHandOver,ib as usePaymentsConnection,Na as usePaymentsLabels,js as useRefund,_a as useRereadValue,dn as useWalletConnection,Ri as walletLabel,Oo as walletOnConfirmStep};
1
+ import {c,b,e,h,g,i,j,f,d}from'./chunk-A2WIFZQB.js';import {b as b$1,a}from'./chunk-7HSDAUKN.js';export{a as PaymentWalletError,b as walletErrorKind}from'./chunk-7HSDAUKN.js';import {getChainName,cn as cn$1,DrawnCheck,CloseIcon,MorphText,WalletIcon,Dialog,DialogContent,DialogTitle,TokenIcon,QuasarLoader,StatusEdge,NetworkIcon,NovaSetIcon,CopyIcon,useNovaIcons,DrawnCross,pixelFlight}from'@tuwaio/nova-core';import {createContext,lazy,useContext,useState,useId,useMemo,Fragment,useRef,useEffect,useEffectEvent,useCallback,Suspense,useLayoutEffect}from'react';import {LockClosedIcon,FingerPrintIcon,QrCodeIcon,DevicePhoneMobileIcon,ArrowDownTrayIcon,NoSymbolIcon,ArrowPathRoundedSquareIcon,ArrowUturnLeftIcon,MagnifyingGlassIcon}from'@tuwaio/nova-icons/24/outline';import {jsxs,jsx,Fragment as Fragment$1}from'react/jsx-runtime';import {HashLink,TxProgressIndicator,TxStatusVisual}from'@tuwaio/nova-transactions';import {parseCaip2ChainId,toCaip2ChainId,formatCaip10AccountId,toEvmChainId,parseCaip19AssetId,parseCaip10AccountId,formatBaseUnits,shortAddress,OrbitAdapter,getAdapterFromConnectorType,getConnectorTypeFromName,formatConnectorName,getSolanaCluster,isSameAddress}from'@tuwaio/orbit-core';export{shortAddress}from'@tuwaio/orbit-core';import {useLabels,NovaTransactionsLabelsProvider}from'@tuwaio/nova-transactions/providers';import {MotionConfig,AnimatePresence}from'framer-motion';import {createCheckoutStore}from'@tuwaio/quasar-sdk/checkout';import {useStore}from'zustand';import {SatelliteStoreContext}from'@tuwaio/satellite-react';import {createStore}from'zustand/vanilla';import {NovaConnectProviderContext}from'@tuwaio/nova-connect/hooks';import {encode}from'uqr';var Xn=createContext(null),Uo=Xn.Provider;function A(){let e=useContext(Xn);if(!e)throw new Error("useCheckoutContext must be used inside PaymentCheckout");return e}function Oe(){return useContext(Xn)}var Cc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,$o="AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" "),Sc=new Set($o);function Va(e,t){let a=e==="full"||t,n=[{name:"email",required:true,autoComplete:"email",type:"email"}];return a?[...n,{name:"name",required:true,autoComplete:t?"organization":"name",type:"text"},{name:"country",required:true,autoComplete:"country",type:"country"},{name:"addressLine1",required:true,autoComplete:"address-line1",type:"text"},{name:"addressLine2",required:false,autoComplete:"address-line2",type:"text"},{name:"postalCode",required:false,autoComplete:"postal-code",type:"text"},{name:"city",required:false,autoComplete:"address-level2",type:"text"},...t?Pc():[]]:n}var Pc=()=>[{name:"taxId",required:true,autoComplete:"off",type:"text"},{name:"registrationNumber",required:false,autoComplete:"off",type:"text"}];function Ko(e,t,a){let n={};for(let o of Va(t,a)){let r=e[o.name]?.trim()??"";r?o.type==="email"&&!Cc.test(r)?n[o.name]="email":o.type==="country"&&!Sc.has(r.toUpperCase())&&(n[o.name]="country"):o.required&&(n[o.name]="required");}return n}function Go(e){let t={};for(let[a,n]of Object.entries(e)){let o=n?.trim();o&&(t[a]=a==="country"?o.toUpperCase():o);}return t}function Vo(e){let t=new Intl.DisplayNames([e],{type:"region"});return $o.map(a=>({code:a,name:t.of(a)??a})).sort((a,n)=>a.name.localeCompare(n.name,e))}var oe="novapay:focus-visible:outline-2 novapay:focus-visible:outline-offset-2 novapay:focus-visible:outline-[var(--tuwa-text-accent)]",Ct=`novapay:inline-flex novapay:h-7 novapay:min-w-7 novapay:items-center novapay:justify-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-1.5 novapay:text-[var(--tuwa-text-primary)] novapay:cursor-pointer novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] ${oe}`,q="novapay:font-mono novapay:tabular-nums",Xe="novapay:font-mono novapay:font-bold novapay:uppercase novapay:tracking-[0.12em]",De=`${Xe} novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-secondary)]`,en=`${Xe} novapay:inline-flex novapay:shrink-0 novapay:items-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-1.5 novapay:py-0.5 novapay:text-[10px] novapay:leading-3`,tn={neutral:"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-primary)]",accent:"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",success:"novapay:border-[color-mix(in_srgb,var(--tuwa-success-icon)_35%,transparent)] novapay:bg-[var(--tuwa-success-bg)] novapay:text-[var(--tuwa-success-text)]",pending:"novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]",error:"novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:text-[var(--tuwa-error-text)]"},et=`novapay-title ${q} novapay:m-0 novapay:text-base novapay:font-bold novapay:text-balance novapay:outline-none`,St={tabIndex:-1,"data-novapay-heading":""},zo=`${Xe} novapay:box-border novapay:inline-flex novapay:min-h-11 novapay:w-full novapay:min-w-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2 novapay:text-center novapay:text-xs novapay:leading-4 novapay:no-underline novapay:transition-colors novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${oe}`,Pt=`tuwa-solid ${zo} novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-[var(--tuwa-text-on-accent)] novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)]`,ea=`${zo} novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-standart-button-hover)]`,nn=`${Xe} novapay:inline-flex novapay:min-h-7 novapay:shrink-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-2.5 novapay:py-1 novapay:text-[10px] novapay:leading-3 novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${oe}`,Qo=`tuwa-solid ${Xe} novapay:inline-flex novapay:min-h-8 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:px-3 novapay:py-1.5 novapay:text-center novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-on-accent)] novapay:transition-colors novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${oe}`,ta="novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]";function na(e){return e==="modal"?{frame:"novapay:sm:w-[min(760px,calc(100vw_-_2rem_-_2px))]",section:""}:{frame:"",section:`novapay:box-border ${e==="page"?"novapay:w-[880px]":"novapay:w-[760px]"} novapay:max-w-full`}}var jo={default:{frame:"tuwa-scanlines novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-col novapay:overflow-hidden novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:h-[680px] novapay:sm:flex-row",aside:"tuwa-scanlines novapay:hidden novapay:w-[286px] novapay:shrink-0 novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-5 novapay:sm:block",main:"novapay:flex novapay:min-h-0 novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:min-h-0 novapay:flex-1 novapay:flex-col novapay:overflow-y-auto"},page:{frame:"tuwa-scanlines novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-1 novapay:flex-col novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:min-h-[calc(var(--novapay-page-floor)_-_2px)] novapay:sm:flex-row",aside:"novapay-page-aside tuwa-scanlines novapay:hidden novapay:w-[clamp(260px,36.4%,320px)] novapay:shrink-0 novapay:flex-col novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-5 novapay:sm:flex",main:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:flex-1 novapay:flex-col"}};function Yo(e){return e.length<=7?"novapay:text-[36px]":e.length<=10?"novapay:text-[30px]":e.length<=13?"novapay:text-[24px]":"novapay:text-[20px]"}function pt(){return useNovaIcons().outline}function an(e){return jsx(NovaSetIcon,{solid:"ChevronDownIcon",...e})}function Zo(e){return jsx(NovaSetIcon,{solid:"GlobeAltIcon",...e})}function on(e){return jsx(NovaSetIcon,{outline:"ClockIcon",...e})}function Jo(e){return jsx(NovaSetIcon,{outline:"DocumentTextIcon",...e})}function ut(e){return jsx(NovaSetIcon,{outline:"ExclamationTriangleIcon",...e})}function Xo(e){return jsx(NovaSetIcon,{outline:"InformationCircleIcon",...e})}function er(e){return jsx(NovaSetIcon,{outline:"WalletIcon",...e})}function tr(e){let a=pt().ArrowDownTrayIcon??ArrowDownTrayIcon;return jsx(a,{...e})}function nr(e){let a=pt().ArrowPathRoundedSquareIcon??ArrowPathRoundedSquareIcon;return jsx(a,{...e})}function ar(e){let a=pt().ArrowUturnLeftIcon??ArrowUturnLeftIcon;return jsx(a,{...e})}function or(e){let a=pt().DevicePhoneMobileIcon??DevicePhoneMobileIcon;return jsx(a,{...e})}function rr(e){let a=pt().FingerPrintIcon??FingerPrintIcon;return jsx(a,{...e})}function sr(e){let a=pt().LockClosedIcon??LockClosedIcon;return jsx(a,{...e})}function ir(e){let a=pt().MagnifyingGlassIcon??MagnifyingGlassIcon;return jsx(a,{...e})}function cr(e){let a=pt().NoSymbolIcon??NoSymbolIcon;return jsx(a,{...e})}function lr(e){let a=pt().QrCodeIcon??QrCodeIcon;return jsx(a,{...e})}var pr={metamask:"MetaMask",walletconnect:"WalletConnect",coinbase:"Coinbase Wallet",okx:"OKX Wallet",trust:"Trust Wallet",injected:"Browser wallet"};function Gc(e,t){let a=e.slice(e.indexOf(":")+1).toLowerCase();return a==="injected"?pr.injected:t?.trim()||pr[a]||a.charAt(0).toUpperCase()+a.slice(1)}var Qa=e=>/^data:image\//i.test(e)||/^https:\/\//i.test(e),za=e=>{let t=typeof e=="string"?e.trim():"";return t&&Qa(t)?t:void 0};function Vc(e,t,a){let n=getAdapterFromConnectorType(t),o=e[n];if(!Array.isArray(o))return;let r=o.filter(s=>typeof s=="object"&&s!==null&&typeof s.name=="string"&&getConnectorTypeFromName(n,formatConnectorName(s.name))===t);return a&&r.find(s=>za(s.icon)===a)||r[0]}var rn=e=>{let t=parseCaip2ChainId(e)?.namespace;return t==="eip155"||t==="solana"?t:null};function ur(e,t){if(!e?.address)return null;let a=toCaip2ChainId(e.chainId),n=a?rn(a):null;if(!a||!n)return null;let o=za(e.icon),r=t?Vc(t,e.connectorType,o):void 0;return {address:e.address,chainId:a,family:n,connectorType:e.connectorType,walletId:e.connectorType.slice(e.connectorType.indexOf(":")+1).toLowerCase(),name:Gc(e.connectorType,typeof r?.name=="string"?r.name:void 0),icon:o??za(r?.icon),connection:e}}function Ve(e){return rn(e.chainId)}function We(e,t){return !e||e.family!==Ve(t)?null:formatCaip10AccountId(t.chainId,e.address)??null}function mr(e,t){let a=Ve(e);return a==="solana"||a==="eip155"&&!!t}function ja(e){let t=a=>String(Number((a/100).toFixed(2)));return e.discountBps>0?{kind:"discount",percent:t(e.discountBps)}:e.markupBps>0?{kind:"markup",percent:t(e.markupBps)}:null}function ye(e){return getChainName(toEvmChainId(e)??e).name}function dr(e){let t=e.assetId?parseCaip19AssetId(e.assetId):void 0;return !t||t.assetNamespace==="slip44"?"native":t.assetReference}var zc=new Set(["awaitingPayment","selectMethod","underpaid"]),Qc="too_many_payments";function Ya(e,t={}){if(t.labelsReady===false&&e.phase!=="error")return "loading";if(e.phase==="unconfirmed")return Nt(e.error)==="retrying"?"confirm":"unconfirmed";if(t.afterFailure&&e.error?.code==="payment_failed"&&zc.has(e.phase))return "failed";let a=e.payerProof==="required"||e.payerProof==="confirming"||e.payerProof==="confirmed"&&!e.error,n=!!(t.confirmWallet&&a);switch(e.phase){case "selectMethod":return n&&!(t.handoff&&t.payWith==="qr")?"confirmWallet":t.handoff&&t.payWith==="qr"?"qr":"method";case "underpaid":return n?"confirmWallet":"underpaid";case "quoting":return e.quote?t.payWith==="qr"||e.quote.payer===null?"qr":"pay":t.confirmWallet?"confirmWallet":"method";case "awaitingPayment":case "submitting":return e.phase==="submitting"&&!e.quote?"confirm":t.payWith==="qr"||e.quote?.payer===null?"qr":"pay";case "confirming":return "confirm";case "cancelled":return e.checkout?.invoice.replacedBy?"replaced":"cancelled";default:return e.phase}}var jc={buyer:"details",method:"method",confirmWallet:"method",pay:"pay",qr:"pay",underpaid:"pay",confirm:"confirm",unconfirmed:"confirm",failed:"confirm"};function yr(e,t={}){let a=jc[e];if(!a)return null;let n=[...t.withDetails||a==="details"?["details"]:[],"method","pay","confirm"],o=n.indexOf(a);return n.map((r,s)=>({key:r,state:s<o?"done":s===o?"current":"upcoming"}))}function fr(e={}){return [...e.withDetails?["details"]:[],"method","pay","confirm"].map(a=>({key:a,state:"done"}))}function vr(e,t){let a=s=>s.chainId===t?0:s.featured?1:2,n=new Map;for(let s of e)n.set(s.symbol,[...n.get(s.symbol)??[],s]);let o=[...n].map(([s,i])=>{let c=[...i].sort((l,p)=>a(l)-a(p));return {symbol:s,methods:c,featured:i.some(l=>l.featured),inWallet:!!t&&i.some(l=>l.chainId===t)}}),r=s=>s.inWallet?0:s.featured?1:2;return o.sort((s,i)=>r(s)-r(i))}var Yc=new Set(["open","processing","underpaid"]),Zc=new Set(["loading","error","buyer","method","confirmWallet","pay","qr","failed","underpaid","blocked"]);function En(e,t,a){return Yc.has(e)?t==="confirm"||t==="unconfirmed"?"confirming":Zc.has(t)?e==="underpaid"&&a===false?"closed":"paying":null:null}var Jc=[10,5,1];function hr(e,t,a=Jc){if(e===null||t<=0)return null;let n=a.filter(o=>e>o*6e4&&t<=o*6e4);return n.length?Math.min(...n):null}var Za=6e4;function xr(e){let{phase:t,quotePayer:a,payer:n}=e;return t!=="awaitingPayment"||!a||n===a?"keep":n?"lock":"release"}function gr(e){let{open:t,storePayer:a,payer:n,paysRest:o}=e;return !t||n===a?"keep":n&&o?"follow":"leave"}function br(e){return e>0&&e<=Za}function wr(e){return e.amlScreening!==false}function tt(e){return e.paymentOnTheWay??!!(e.txKey||e.txHash)}function mt(e,t){let a=t?.invoice?.pendingPayments??0;return e.invoicePaymentOnTheWay??a>0}function kr({state:e,checkout:t,handedOverAt:a,dueAt:n}){let o=e.paymentSentInTime,r=tt({paymentOnTheWay:e.paymentOnTheWay,txKey:e.txKey??null,txHash:e.txHash??null});if(typeof o=="boolean"&&r)return o;let s=t.invoice.paymentCountsUntil;return s===void 0?a!==null&&a<n:a!==null&&a>=n?false:(e.paymentCountsUntil===void 0?s:e.paymentCountsUntil)!==null}var Ja="settlement_failed",Cr="tx_already_used";function Sr(e){let t=e?.code,a=e?.reason;return (t==="payment_failed"||t==="payment_mismatch")&&!!a&&a!==Ja}var Xc=new Set(["no_matching_transfer","reference_missing","too_early","tx_already_used","payer_mismatch","payer_unconfirmed","quote_changed","too_many_parts","too_many_transfers","below_minimum","native_from_contract_unverifiable","invoice_not_payable"]);function dt(e){let t=e?.code,a=e?.reason;return a===Ja?false:t==="payment_mismatch"?true:t==="payment_failed"&&a!==void 0&&Xc.has(a)}function Pr(e){let t=e?.reason;return dt(e)&&t===Cr}function Ot(e,t){let a=t?.invoice?.unresolvedPayments??0;return e.invoicePaymentUnresolved??a>0}function Nt(e){let t=e?.code,{reason:a,rechecked:n,stillRead:o}=e??{};return t==="payment_failed"&&a==="unresolved_after_24h"?"closed":a===Ja&&(t==="payment_unconfirmed"||t==="payment_mismatch")?n===true?"settlementRetrying":"settlementFailed":t!=="payment_unconfirmed"?null:a==="nonce_spent_unexplained"?"nonceSpent":a==="unmined_after_24h"||o===true?"unmined":a===Cr?"takenElsewhere":a==="submit_retrying"?"retrying":a==="submit_failed"?"notReceived":a===Qc?"invoiceFull":n===true?"rechecked":"contact"}function Nr(e,t){let{txKey:a}=e.error??{};if(a)return a;let n=t?.invoice?.rejectedPayments;return e.txHash??e.txKey??n?.[0]?.txKey??null}function Tr({picked:e,page:t,invoice:a}){return e&&e.page===t?e.locale:t??a??"en"}function Ir(e,t){return e.supportEmail?`mailto:${e.supportEmail}?subject=${encodeURIComponent(t)}`:e.website??null}var Rr={nonceSpent:"unconfirmedNonceSpent",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"};function Ln(e,t,a){let n=e.reason;return n==="expired"?t.pay.failedExpired:n==="cancelled"?t.pay.failedCancelled:n==="reverted"?a?c(t.pay.failed,{network:a}):t.method.paymentFailed:t.pay.didNotGoThrough}function aa(e){if(e?.code!=="payment_failed"&&e?.code!=="payment_mismatch")return null;let{txKey:t}=e;return typeof t=="string"&&t?t:null}var tl=new Set(["payer_mismatch","payer_unconfirmed"]);function Wt(e,t,a=""){if(dt(e)){let r=e.reason??"",s=e.held===true;if(r==="quote_changed")return c(t.pay.mismatchChargeHeld,{merchant:a});if(r==="too_many_parts")return c(t.pay.mismatchTooManyParts,{merchant:a});if(r==="reference_missing"&&s)return c(t.pay.mismatchNoReferenceHeld,{merchant:a});let i=tl.has(r)?s?t.pay.mismatchOtherWalletHeld:t.pay.mismatchOtherWallet:s?t.pay.mismatchHeldElsewhere:Pr(e)?t.pay.mismatchTakenElsewhere:t.pay.mismatch;return c(i,{merchant:a})}let n=Nt(e),o=n?Rr[n]:void 0;return o?c(t.outcome[o],{merchant:a}):null}var nl=["buyer","selectMethod","quoting","awaitingPayment"];function Xa(e,t,a){if(a==="underpaid")return false;let n=Nt(t);return nl.includes(e)&&!dt(t)&&!(n&&Rr[n])}function oa(e,t,a=""){let n=Wt(e,t,a);if(n!==null)return n;switch(e.code){case "screening_unavailable":return t.pay.screeningUnavailable;case "request_failed":return t.pay.noAnswer;case "amount_out_of_range":case "method_not_found":case "testnet_required":return t.method.methodUnavailable;case "payer_not_expected":return t.method.payerNotExpected;case "payer_is_recipient":return t.method.payerIsRecipient;case "too_many_payments":return c(t.method.tooManyPayments,{merchant:a});case "too_many_payers":return c(t.method.tooManyPayers,{merchant:a});case "native_from_contract":return t.method.nativeFromSmartWallet;case "rate_limited":return t.method.rateLimited;case "price_unavailable":case "price_no_rpc":return t.method.priceUnavailable;case "consent_required":return t.method.consentRequired;case "payer_proof_required":case "payer_proof_declined":return t.payerProof.text;case "payer_proof_invalid":return t.payerProof.invalid;case "payer_proof_unavailable":return t.payerProof.unavailable;case "payment_failed":return Ln(e,t);case "rest_method_mismatch":return t.method.restSameMethod;default:return t.error.generic}}function Er(e,t){if(!e||t===null)return null;let a=BigInt(e.cryptoAmountExpected)-BigInt(t);return a>0n?a.toString():null}function sn(e,t,a,n,o,r=a.pay.restRateEnded){let s=e?.rateHeldUntil?Date.parse(e.rateHeldUntil):null;if(s===null)return null;if(s<=t)return c(r,{merchant:n});let i=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(s);return c(a.pay.restRateUntil,{time:i,merchant:n})}function Tt(e){return parseCaip10AccountId(e)?.address??e}function cn(e,t){let a=Tt(e),n=Tt(t);return a.startsWith("0x")?a.toLowerCase()===n.toLowerCase():a===n}function Lr(e){return e&&/^\d+$/.test(e)&&BigInt(e)>0n?e:null}function Ar(e){let t=BigInt(e.cryptoAmount),a=e.received?BigInt(e.received):null;if(a&&t>a&&(t-a)*200n>=a)return true;if(!e.atPaymentRate)return false;let n=BigInt(e.atPaymentRate);return n===0n?false:(t>n?t-n:n-t)*200n>=n}var al=new Set(["held","refunded","expired","cancelled","blocked","error"]);function _r(e,t,a){return a?e==="paid"?t!==0:!al.has(e):true}function Fr(e,t){return t.withGas||!e.gasless?"transfer":e.gasless.paymaster&&t.canSponsorCalls?"paymaster":e.gasless.relay?"relay":"transfer"}function Br(e){let t=BigInt(e.amountToSend),a=BigInt(e.amountDue);return !e.transferFee||t<=a?{send:e.amountToSend,receives:e.amountDue,fee:null}:{send:e.amountToSend,receives:e.amountDue,fee:{amount:String(t-a),percent:String(e.transferFee.bps/100)}}}var ra=10000n,Mr=8n;function Dr(e,t){let a=BigInt(e.cryptoAmountExpected);if(!t||a<=0n)return null;let o=BigInt(t)*(ra+BigInt(e.markupBps))*(ra-BigInt(e.discountBps))*10n**BigInt(e.decimals)*10n**Mr/(100n*ra*ra*a);return Number(o)/10**Number(Mr)}function Or(e,t,a=0n){let n=BigInt(t.amountToSend)+a;return e>=n?null:{have:String(e),need:String(n),short:String(n-e)}}function ve(e){return e.family==="eip155"?`eip155:${e.chainId}`:e.chainId}var qr="novapay:normal-case",cl=3,ll={};function pl(e){let[,t="",a="",n=""]=/^(\s*)([\s\S]*?)(\s*)$/.exec(e)??[];return [t,a,n]}function ul(e,t){let a=e.ownerDocument.createElement("span");a.style.cssText="position:absolute;visibility:hidden;white-space:nowrap;pointer-events:none";for(let[o,r]of t){let s=e.ownerDocument.createElement("span");r&&(s.style.textTransform="none"),s.textContent=o,a.append(s);}e.append(a);let{width:n}=a.getBoundingClientRect();return a.remove(),n}function ml(e,t){let a=getComputedStyle(t),n=[...t.children].filter(s=>s!==e),o=n.reduce((s,i)=>s+i.getBoundingClientRect().width,0),r=(Number.parseFloat(a.columnGap)||0)*n.length;return t.clientWidth-Number.parseFloat(a.paddingLeft)-Number.parseFloat(a.paddingRight)-o-r}function Ce({label:e,values:t=ll}){let a=useRef(null),[n,o]=useState(false),[r,s]=useState(cl),i=Object.fromEntries(Object.entries(t).map(([p,m])=>[p,{own:String(m)}])),c=d(e,i).map(p=>typeof p=="string"?[p,false]:[p.own,true]),l=JSON.stringify(c);return useLayoutEffect(()=>{let p=a.current,m=p?.parentElement;if(!p||!m)return;let y=JSON.parse(l),f=()=>{o(ul(p,y)>ml(p,m)+.5),s(d=>Math.max(d,y.length));};if(f(),typeof ResizeObserver>"u")return;let v=new ResizeObserver(f);return v.observe(m),()=>v.disconnect()},[l]),n?jsx("span",{ref:a,className:"novapay:min-w-0",children:jsx("span",{className:"novapay-label-fade",children:c.map(([p,m],y)=>m?jsx("span",{className:qr,children:p},y):p)},l)}):jsx("span",{ref:a,className:"novapay:min-w-0 novapay:whitespace-nowrap",children:Array.from({length:Math.max(r,c.length)},(p,m)=>{let[y,f]=c[m]??["",false],[v,d,I]=pl(y);return jsxs(Fragment,{children:[v,jsx(MorphText,{className:f?qr:void 0,children:d}),I]},m)})})}function Z(e,t,a){let n=e.customization.classNames?.[t];return n?.({screen:e.screen,checkoutState:e.state,checkout:e.checkout,...a})}function ze({children:e,labels:t}){let a=Oe(),n=t??a?.labels,o=useLabels(),r=useMemo(()=>({...o,trackingModal:{...o.trackingModal,progressIndicator:{created:n.confirm.sent,processing:n.confirm.confirming,succeed:n.confirm.paid}},statuses:{...o.statuses,confirmed:n.confirm.confirmed,failed:n.confirm.failed},actions:{...o.actions,viewOnExplorer:n.confirm.viewOnExplorer,copy:n.confirm.copyHash},txError:{...o.txError,copied:n.pay.copied}}),[o,n]);return jsx(NovaTransactionsLabelsProvider,{labels:r,children:e})}var Ut=(e,t)=>e?Z(e,t):void 0;function _n({walletId:e,icon:t}){let[a,n]=useState(null);return t&&t!==a&&Qa(t)?jsx("img",{src:t,alt:"",onError:()=>n(t),className:"novapay:block novapay:h-full novapay:w-full novapay:object-contain"}):jsx(WalletIcon,{walletName:e})}function qe({hash:e,chainId:t,explorerUrl:a,labels:n}){let o=Oe(),r=a??(t?o?.adapterFor(t.startsWith("solana:")?"solana":"eip155")?.explorerAddressUrl?.({chainId:t,address:e}):void 0);return jsx(ze,{labels:n,children:jsx(HashLink,{hash:e,explorerUrl:r,variant:"compact",...o?.customization.childCustomizations?.hashLink})})}function sa({walletId:e,walletIcon:t}){return !e&&!t?jsx(QuasarLoader,{size:48,accent:"var(--tuwa-pending-icon)"}):jsx("span",{className:"novapay-chase novapay:relative novapay:flex novapay:h-20 novapay:w-20 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border-2 novapay:border-[color-mix(in_srgb,var(--tuwa-pending-text)_25%,transparent)]",children:jsx("span",{className:"novapay:block novapay:h-11 novapay:w-11",children:jsx(_n,{walletId:e??"",icon:t})})})}function he({title:e,subtitle:t,children:a}){let n=Oe(),o=n?.display==="page";return jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-2.5 novapay:px-5 novapay:py-4",o&&"novapay-page-screen",Ut(n,"screen")),children:[jsxs("div",{children:[jsx("h2",{...St,className:et,children:typeof e=="string"?jsx(MorphText,{wrap:true,children:e}):e}),t&&jsx("p",{className:cn$1("novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",o&&"novapay-page-subtitle"),children:t})]}),a]})}function te({children:e}){let t=Oe(),a=useRef(null),n=t?.display==="page";return useEffect(()=>{let o=a.current,r=n?o?.ownerDocument.documentElement:o?.closest("[data-novapay-scroll]");if(!o||!r||typeof ResizeObserver>"u")return;let s=()=>r.style.scrollPaddingBottom=!n||getComputedStyle(o).position==="sticky"?`${o.offsetHeight+8}px`:"";s();let i=new ResizeObserver(s);return i.observe(o),()=>{i.disconnect(),r.style.scrollPaddingBottom="";}},[n]),jsx("footer",{ref:a,className:cn$1("tuwa-scanlines novapay:empty:hidden novapay:sticky novapay:bottom-0 novapay:z-10 novapay:flex novapay:flex-col novapay:gap-2 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-5 novapay:pb-3.5 novapay:pt-3 novapay:text-center",n&&"novapay-page-footer",Ut(t,"footer")),children:e})}function ln({children:e,id:t}){let a=Oe()?.display==="page";return jsx("span",{id:t,className:cn$1(De,a&&"novapay-page-group"),children:e})}function X({busy:e,children:t,className:a,...n}){let o=Oe(),r=Ut(o,"primaryButton"),s=o?.customization.components?.PrimaryButton;return s?jsx(s,{busy:e,className:cn$1(a,r),...n,children:t}):jsxs("button",{type:"button","aria-busy":e||void 0,...n,disabled:n.disabled||e,className:cn$1(Pt,a,r),children:[e&&jsx(QuasarLoader,{size:16,accent:"currentColor"}),typeof t=="string"?jsx(Ce,{label:t}):t]})}function re({children:e,className:t,...a}){let n=Oe();return jsx("button",{type:"button",...a,className:cn$1(ea,t,Ut(n,"secondaryButton")),children:e})}function ia({className:e,...t}){return jsxs("span",{className:cn$1("novapay:relative novapay:inline-flex novapay:h-4 novapay:w-4 novapay:shrink-0",e),children:[jsx("input",{type:"checkbox",...t,className:cn$1("novapay:peer novapay:m-0 novapay:box-border novapay:h-4 novapay:w-4 novapay:cursor-pointer novapay:appearance-none novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:border-[var(--tuwa-text-secondary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:transition-colors novapay:checked:border-[var(--tuwa-text-accent)] novapay:checked:bg-[var(--tuwa-text-accent)]",oe)}),jsx(DrawnCheck,{className:"novapay:pointer-events-none novapay:absolute novapay:inset-0 novapay:m-auto novapay:h-3 novapay:w-3 novapay:text-[var(--tuwa-bg-primary)] novapay:opacity-0 novapay:peer-checked:opacity-100"})]})}function Ue({children:e}){return jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:e})}function xe({children:e,className:t}){let a=Oe();return jsx("dl",{className:cn$1("tuwa-scanlines novapay:m-0 novapay:flex novapay:w-full novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-left",t,Ut(a,"detailsCard")),children:e})}function Q({children:e}){let t=Oe();return jsx("p",{role:"alert",className:cn$1("novapay:m-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-error-text)]",Ut(t,"error")),children:e})}function ca({error:e}){let t=Oe(),a=aa(e);if(!t||!a)return null;let n=t.state.quote??t.checkout?.quote,o=n?ve(n.instructions):null,r=n&&o?t.adapterFor(n.instructions.family)?.explorerUrl?.({chainId:o,txKey:a}):void 0;return jsx(ze,{children:jsx(xe,{children:jsx(W,{name:t.labels.confirm.transaction,children:jsx(HashLink,{hash:a,explorerUrl:r,variant:"compact",...t.customization.childCustomizations?.hashLink})})})})}function Mn({text:e,label:t,copiedLabel:a,children:n}){let[o,r]=useState(false);return useEffect(()=>{if(!o)return;let s=setTimeout(()=>r(false),2e3);return ()=>clearTimeout(s)},[o]),jsxs(Fragment$1,{children:[jsxs("button",{type:"button","aria-label":n?void 0:t,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>r(true),()=>{});},className:cn$1(Ct,"novapay:min-h-6 novapay:min-w-6 novapay:text-xs"),children:[jsx(CopyIcon,{copied:o,className:"novapay:h-3.5 novapay:w-3.5"}),n]}),jsx("span",{role:"status",className:"novapay:sr-only",children:o?a:""})]})}function W({name:e,children:t}){let a=Oe();return jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3 novapay:py-2 novapay:text-xs",a?.display==="page"&&"novapay-page-row",Ut(a,"detailRow")),children:[jsx("dt",{className:"novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]",children:e}),jsx("dd",{className:cn$1(q,"novapay:m-0 novapay:min-w-0 novapay:text-right novapay:break-words"),children:t})]})}function yt({children:e,onClick:t,disabled:a}){return jsx("button",{type:"button",onClick:t,disabled:a,className:cn$1("novapay:disabled:cursor-default novapay:disabled:opacity-50 novapay:min-h-6 novapay:cursor-pointer novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-xs novapay:text-[var(--tuwa-text-accent)] novapay:underline novapay:hover:no-underline",oe),children:e})}var Tl=(e,t,a)=>t==="name"&&a?e.buyer.companyName:e.buyer[t]??t,Il=(e,t)=>t==="email"?e.buyer.invalidEmail:t==="country"?e.buyer.invalidCountry:e.buyer.required,Rl=new Set(["postalCode","city","taxId","registrationNumber"]),El=new Set(["name","country","addressLine1","addressLine2"]),Gr=e=>cn$1("novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-[13px] novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:focus:border-[var(--tuwa-text-accent)]",e?"novapay:border-[var(--tuwa-error-icon)]":"novapay:border-[var(--tuwa-text-secondary)] novapay:hover:border-[var(--tuwa-text-primary)]",oe);function Vr(){let{checkout:e,state:t,store:a,labels:n,locale:o,display:r}=A(),[s,i]=useState({}),[c,l]=useState(false),[p,m]=useState(false),[y,f]=useState(false),v=useId(),d=useMemo(()=>Vo(o),[o]);if(!e||e.buyer.collect==="off")return null;let I=e.buyer.collect,h=Va(I,c),b=Ko(s,I,c),g=(P,w)=>i(x=>({...x,[P]:w})),k=async P=>{if(P.preventDefault(),m(true),Object.keys(b).length>0){document.getElementById(`${v}-${Object.keys(b)[0]}`)?.focus();return}f(true),await a.getState().setBuyer(Go(s),{company:c}),f(false);};return jsxs("form",{noValidate:true,onSubmit:P=>{k(P);},className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(he,{title:n.buyer.title,subtitle:n.buyer.subtitle,children:[jsx("div",{className:"novapay:grid novapay:grid-cols-1 novapay:gap-x-3 novapay:gap-y-3.5 novapay:pt-1 novapay:sm:grid-cols-2",children:h.map((P,w)=>{let x=`${v}-${P.name}`,C=p?b[P.name]:void 0,L=P.type==="country"?jsxs("div",{className:"novapay:relative",children:[jsxs("select",{id:x,autoComplete:P.autoComplete,required:P.required,"aria-invalid":!!C,"aria-describedby":C?`${x}-error`:void 0,value:s.country??"",onChange:_=>g("country",_.target.value),className:cn$1(Gr(!!C),"novapay:cursor-pointer novapay:appearance-none novapay:pr-9",!s.country&&"novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("option",{value:"",children:n.buyer.chooseCountry}),d.map(_=>jsx("option",{value:_.code,children:_.name},_.code))]}),jsx(an,{"aria-hidden":true,className:"novapay:pointer-events-none novapay:absolute novapay:top-1/2 novapay:right-3 novapay:h-4 novapay:w-4 novapay:-translate-y-1/2 novapay:text-[var(--tuwa-text-secondary)]"})]}):jsx("input",{id:x,type:P.type,autoComplete:P.autoComplete,required:P.required,"aria-invalid":!!C,"aria-describedby":C?`${x}-error`:void 0,value:s[P.name]??"",onChange:_=>g(P.name,_.target.value),className:Gr(!!C)});return jsxs(Fragment,{children:[jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",!Rl.has(P.name)&&(r==="page"&&El.has(P.name)?"novapay:sm:@max-[519px]:col-span-2":"novapay:sm:col-span-2")),children:[jsxs("label",{htmlFor:x,className:"novapay:text-xs novapay:font-medium novapay:text-[var(--tuwa-text-primary)]",children:[Tl(n,P.name,c),P.required&&jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]}),!P.required&&jsxs("span",{className:"novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:[" ","(",n.buyer.optional,")"]})]}),L,C&&jsx("span",{id:`${x}-error`,className:"novapay:text-[11px] novapay:text-[var(--tuwa-error-text)]",children:Il(n,C)})]}),w===0&&e.buyer.companyInvoice&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:text-[13px] novapay:transition-colors novapay:sm:col-span-2",c?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]"),children:[jsx(ia,{checked:c,onChange:_=>l(_.target.checked)}),jsx("span",{className:"novapay:font-semibold",children:n.buyer.companyInvoice})]})]},P.name)})}),t.error&&t.phase==="buyer"&&jsx(Q,{children:n.buyer.refused})]}),jsx(te,{children:jsx(X,{type:"submit",busy:y,children:n.buyer.continue})})]})}function Qr({steps:e,labels:t,className:a,stepClassName:n}){let o=e.findIndex(p=>p.state==="current"),r=e.map(p=>t.steps[p.key]).join(""),s=useRef(null),i=useRef(null),[c$1,l]=useState(false);return useEffect(()=>{let p=s.current,m=i.current;if(!p||!m||typeof ResizeObserver>"u")return;let y=()=>l(m.offsetWidth+e.length*32+(e.length-1)*24>p.clientWidth);y();let f=new ResizeObserver(y);return f.observe(p),()=>f.disconnect()},[r,e.length]),jsxs("nav",{ref:s,"aria-label":t.steps.label,className:cn$1("novapay:relative novapay:min-w-0 novapay:flex-1",a),children:[jsx("span",{"aria-hidden":true,className:"novapay:invisible novapay:absolute novapay:h-0 novapay:w-0 novapay:overflow-hidden",children:jsx("span",{ref:i,className:cn$1(Xe,"novapay:whitespace-nowrap novapay:text-[11px]"),children:r})}),jsx("ol",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:items-center novapay:gap-1.5 novapay:p-0",children:e.map((p,m)=>{let y=t.steps[p.key];return jsxs("li",{"aria-current":p.state==="current"?"step":void 0,className:cn$1("novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-1.5",m>0&&"novapay:flex-auto",n?.(p,m)),children:[m>0&&jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-px novapay:min-w-2 novapay:flex-1 novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",p.state==="upcoming"?"novapay:bg-[var(--tuwa-border-primary)]":"novapay:bg-[var(--tuwa-success-icon)]")}),jsx("span",{"aria-hidden":true,className:cn$1(q,"novapay:box-border novapay:flex novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:text-[10px] novapay:font-bold",p.state==="done"&&"novapay:border-[var(--tuwa-success-icon)] novapay:bg-[var(--tuwa-success-icon)] novapay:text-white",p.state==="current"&&"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",p.state==="upcoming"&&"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-secondary)]"),children:p.state==="done"?jsx(DrawnCheck,{className:"novapay:h-3 novapay:w-3"}):m+1}),jsx("span",{className:cn$1(Xe,"novapay:truncate novapay:text-[11px] novapay:leading-4",p.state==="current"?"novapay:text-[var(--tuwa-text-primary)]":"novapay:text-[var(--tuwa-text-secondary)]",c$1&&p.state!=="current"&&"novapay:sr-only"),children:p.state==="current"?jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:sr-only",children:c(t.steps.progress,{current:o+1,total:e.length,name:y})}),jsx("span",{"aria-hidden":true,children:y})]}):y})]},p.key)})})]})}function Ee(e,t=2){let a=e.startsWith("-"),n=(a?e.slice(1):e).padStart(t+1,"0");return `${a?"-":""}${n.slice(0,-t)}.${n.slice(-t)}`}var jr=e=>new Intl.NumberFormat(e).formatToParts(1.1).find(t=>t.type==="decimal")?.value??".";function ue(e,t){let[a="0",n=""]=(typeof e=="number"?e.toFixed(2):e.trim()).split("."),o=a.startsWith("-"),r=new Intl.NumberFormat(t).format(BigInt(o?a.slice(1):a));return `${o?"-":""}${r}${jr(t)}${n.padEnd(2,"0").slice(0,2)}`}function le(e,t,a){let n=BigInt(e),o=n<0n,r=o?-n:n,s=10n**BigInt(t),i=new Intl.NumberFormat(a).format(r/s),c=(r%s).toString().padStart(t,"0").replace(/0+$/,"").padEnd(2,"0");return `${o?"-":""}${i}${jr(a)}${c}`}function ua(e,t,a){let n=10n**BigInt(Math.max(t-6,0)),o=(BigInt(e)+n/2n)/n*n;return o===0n?null:le(o.toString(),t,a)}function ma(e,t){return formatBaseUnits(e,t)??"0"}var Ht=e=>String(e).padStart(2,"0");function at(e){let t=Math.max(0,Math.floor(e/1e3)),a=Math.floor(t/86400),n=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),r=t%60;return a>0?`${a}d ${Ht(n)}:${Ht(o)}`:n>0?`${Ht(n)}:${Ht(o)}:${Ht(r)}`:`${Ht(o)}:${Ht(r)}`}function un(e){let t=e.lineItems.reduce((r,s)=>r+BigInt(s.netMinor),0n),a=BigInt(e.totalMinor??t.toString()),n=a-t,o=[...new Set(e.lineItems.filter(r=>Number(r.taxRate)>0).map(r=>r.taxRate))];return {subtotal:Ee(t.toString()),tax:n>0n?Ee(n.toString()):null,rate:o.length===1?String(Number(o[0])):null,total:Ee(a.toString())}}var Dl=e=>{try{return new URL(e).host}catch{return e}};function da({compact:e=false}){let{checkout:t,state:a,labels:n,display:o}=A(),[r,s]=useState(false);if(!t)return null;let{merchant:i,invoice:c}=t,l=e?"novapay:h-8 novapay:w-8":"novapay:h-9 novapay:w-9";return jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-2.5",children:[a.logoUrl&&!r?jsx("img",{src:a.logoUrl,alt:"",onError:()=>s(true),className:cn$1(l,"novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:object-contain")}):jsx("span",{"aria-hidden":true,className:cn$1(l,q,"novapay:flex novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-text-primary)] novapay:text-[15px] novapay:font-bold novapay:text-[var(--tuwa-bg-primary)]"),children:i.name.trim().charAt(0).toUpperCase()}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:cn$1("novapay:text-sm novapay:font-semibold",o==="page"&&!e?"novapay:line-clamp-2 novapay:break-words":"novapay:truncate"),children:i.name}),e?c.number&&jsx("span",{className:cn$1(q,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c.number}):i.website&&jsx("a",{href:i.website,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:truncate novapay:text-xs novapay:text-[var(--tuwa-text-secondary)] novapay:hover:underline",oe),children:Dl(i.website)})]}),c.environment==="test"&&jsxs("span",{title:n.summary.testHint,className:cn$1(en,tn.pending,"novapay:ml-auto"),children:[n.summary.test,jsxs("span",{className:"novapay:sr-only",children:[": ",n.summary.testHint]})]})]})}function to({checkout:e,labels:t}){let{merchant:a}=e,n=a.seller,o=[[t.summary.terms,a.links.terms],[t.summary.refundPolicy,a.links.refundPolicy],[t.summary.privacy,a.links.privacy]].filter(r=>!!r[1]);return jsxs("div",{className:"tuwa-scanlines novapay:flex novapay:flex-col novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:[n?.legalName&&jsx("span",{className:"novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)]",children:n.legalName}),(n?.address||n?.country)&&jsx("span",{children:[n.address,n.country].filter(Boolean).join(", ")}),n?.registrationNumber&&jsxs("span",{children:[t.summary.registration," ",n.registrationNumber]}),n?.taxId&&jsxs("span",{children:[t.summary.taxId," ",n.taxId]}),a.supportEmail&&jsx("a",{href:`mailto:${a.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",oe),children:a.supportEmail}),o.length>0&&jsx("span",{className:"novapay:flex novapay:flex-wrap novapay:gap-x-3",children:o.map(([r,s])=>jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",oe),children:r},r))}),jsx("span",{children:c(t.summary.sellerRole,{seller:n?.legalName||a.name})})]})}function Xr(){let{checkout:e,labels:t,locale:a,now:n,screen:o,display:r}=A(),s=e?.invoice.dueAt,i=e&&En(e.invoice.status,o,e.invoice.restPayable);if(!e||!s||!i)return null;let c$1=new Intl.DateTimeFormat(a,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(s));return jsxs("div",{className:cn$1("tuwa-scanlines novapay:flex novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5",r==="page"&&"novapay-page-deadline"),children:[jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-0.5",children:[jsx("span",{className:De,children:i==="closed"?t.summary.refundAfter:t.summary.payWithin}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:i==="closed"?c$1:c(t.summary.until,{date:c$1})})]}),jsx("span",{role:"timer",className:cn$1(q,"novapay:shrink-0 novapay:whitespace-nowrap novapay:text-lg novapay:font-bold"),children:at(Date.parse(s)-n)})]})}function es(){let{checkout:e,labels:t,locale:a}=A();if(!e)return null;let{invoice:n}=e,o=un(n);return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3.5",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2.5",children:[n.number&&jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3",children:[jsx("span",{className:De,children:t.summary.invoice}),jsx("span",{className:cn$1(q,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-2.5 novapay:p-0",children:n.lineItems.map((r,s)=>jsxs("li",{className:"novapay:flex novapay:justify-between novapay:gap-2 novapay:text-[13px]",children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:r.name}),r.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:r.description}),jsx("span",{className:cn$1(q,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:r.quantity,price:ue(r.unitPrice,a)})})]}),jsx("span",{className:q,children:ue(Ee(r.netMinor),a)})]},s))})]}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:border-t novapay:border-dashed novapay:border-[var(--tuwa-border-primary)] novapay:pt-2.5 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn$1(q,"novapay:m-0"),children:ue(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1(q,"novapay:m-0"),children:ue(o.tax,a)})]})]})]})}function Ol(){let e=A(),{checkout:t,labels:a,locale:n}=e;return t?jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between",Z(e,"total")),children:[jsx("span",{className:cn$1(De,"novapay:text-[var(--tuwa-text-primary)]"),children:a.summary.total}),jsxs("span",{className:cn$1(q,"novapay:text-[22px] novapay:font-bold"),children:[ue(un(t.invoice).total,n)," ",jsx("span",{className:"novapay:text-[13px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]}):null}function ts(){let{checkout:e,labels:t}=A();return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("span",{className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(sr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:shrink-0"}),t.summary.secured]}),e?.merchant.supportEmail&&jsxs("span",{children:[t.summary.help,":"," ",jsx("a",{href:`mailto:${e.merchant.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",oe),children:e.merchant.supportEmail})]})]})}function ya({label:e,children:t,className:a,buttonClassName:n,growsUp:o=false}){let[r,s]=useState(false),i=useId();return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-2",a),children:[jsxs("button",{type:"button","aria-expanded":r,"aria-controls":i,onClick:()=>s(c=>!c),className:cn$1("novapay:inline-flex novapay:cursor-pointer novapay:items-center novapay:gap-1 novapay:self-start novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)] novapay:hover:text-[var(--tuwa-text-primary)]",oe,n),children:[e,jsx(an,{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:transition-transform novapay:motion-reduce:transition-none",r!==o&&"novapay:rotate-180")})]}),jsx("div",{id:i,hidden:!r,children:t})]})}var Yr=5;function Wl(){let e=A(),{checkout:t,labels:a,locale:n}=e;if(!t)return null;let o=ue(un(t.invoice).total,n);return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",Z(e,"total")),children:[jsx("span",{className:De,children:a.summary.total}),jsxs("span",{className:cn$1(q,"novapay:flex novapay:flex-wrap novapay:items-baseline novapay:gap-x-2 novapay:gap-y-1 novapay:font-bold",Yo(o)),children:[jsx("span",{children:o}),jsx("span",{className:"novapay:text-[15px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]})}var ns="novapay:flex novapay:justify-between novapay:gap-3 novapay:px-3 novapay:py-2";function Zr({line:e}){let{labels:t,locale:a}=A(),n=ue(Ee(e.netMinor),a),o=ue(e.unitPrice,a);return jsxs("li",{className:cn$1(ns,"novapay:text-[13px]"),children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:e.name}),e.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:e.description}),(Number(e.quantity)!==1||o!==n)&&jsx("span",{className:cn$1(q,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:e.quantity,price:o})})]}),jsx("span",{className:cn$1(q,"novapay:shrink-0"),children:n})]})}function ql(){let{checkout:e,labels:t,locale:a}=A();if(!e)return null;let{invoice:n}=e,o=un(n),r=o.tax?Yr-1:Yr,s=n.lineItems,i=s.length>r?s.slice(0,r-1):s,c$1=s.slice(i.length);return !n.number&&s.length===0?null:jsxs("div",{className:"tuwa-scanlines novapay:flex novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)]",children:[n.number&&jsxs("div",{className:cn$1(ns,"novapay:items-baseline"),children:[jsx("span",{className:De,children:t.summary.invoice}),jsx("span",{className:cn$1(q,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),i.length>0&&jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:i.map((l,p)=>jsx(Zr,{line:l},p))}),c$1.length>0&&jsx(ya,{label:`+${c$1.length} \xB7 ${t.summary.showOrder}`,className:"novapay:px-3 novapay:py-2",buttonClassName:"novapay:min-h-6",children:jsx("ul",{className:"novapay:-mx-3 novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:c$1.map((l,p)=>jsx(Zr,{line:l},p))})}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn$1(q,"novapay:m-0"),children:ue(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1(q,"novapay:m-0"),children:ue(o.tax,a)})]})]})]})}function Ul(){let{checkout:e,labels:t}=A();return e?jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx(da,{}),jsx("div",{className:"novapay:mt-6",children:jsx(Wl,{})}),jsx("div",{className:"novapay:mt-5",children:jsx(ql,{})}),jsxs("div",{className:"novapay:mt-auto novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-5",children:[jsx(Xr,{}),jsx(ya,{label:t.summary.sellerDetails,buttonClassName:"novapay:min-h-6",growsUp:true,children:jsx(to,{checkout:e,labels:t})}),jsx(ts,{})]})]}):null}function as(){let{checkout:e,labels:t,display:a}=A();return e?a==="page"?jsx(Ul,{}):jsxs("div",{className:"novapay:flex novapay:h-full novapay:flex-col novapay:gap-3.5",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsx(da,{}),jsx(ya,{label:t.summary.sellerDetails,children:jsx(to,{checkout:e,labels:t})})]}),jsx(Xr,{}),jsx("div",{className:"novapay:-mr-2.5 novapay:min-h-0 novapay:flex-1 novapay:overflow-y-auto novapay:pr-2.5",children:jsx(es,{})}),jsx(Ol,{}),jsx(ts,{})]}):null}function os({className:e}={}){let{checkout:t,labels:a,locale:n,now:o,screen:r}=A();if(!t)return null;let{invoice:s}=t,i=un(s),c=s.dueAt&&En(s.status,r)?Date.parse(s.dueAt):null;return jsxs("div",{className:cn$1("tuwa-scanlines novapay:mx-4 novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-3",e),children:[jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsxs("span",{className:cn$1(q,"novapay:text-[22px] novapay:font-bold"),children:[ue(i.total,n)," ",jsx("span",{className:"novapay:text-xs novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:s.currency})]}),c&&jsxs("span",{role:"timer",className:cn$1(q,"novapay:flex novapay:items-center novapay:gap-1 novapay:whitespace-nowrap novapay:text-xs novapay:font-bold"),children:[jsx(on,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-secondary)]"}),at(c-o)]})]}),jsx(ya,{label:`${b(i.tax?{one:a.summary.compactOne,other:a.summary.compact}:{one:a.summary.compactNoTaxOne,other:a.summary.compactNoTax},s.lineItems.length,n,i.tax?{tax:ue(i.tax,n)}:{})} \xB7 ${a.summary.showOrder}`,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-1",children:[jsx(es,{}),jsx(to,{checkout:t,labels:a})]})})]})}function ss({locale:e$1,labels:t,receiptIssued:a,onSelect:n,className:o}){let[r,s]=useState(false),i=e.find(b=>b.code===e$1)??e[0],[c$1,l]=useState(0),p=useId(),m=useRef(null),y=useRef(null),f=useRef(null);useEffect(()=>{if(!r)return;f.current?.focus();let b=g=>{m.current?.contains(g.target)||s(false);};return document.addEventListener("pointerdown",b),()=>document.removeEventListener("pointerdown",b)},[r]);let v=()=>{l(Math.max(0,e.indexOf(i))),s(true);},d=()=>{s(false),y.current?.focus();},I=b=>{d(),b!==i.code&&n(b);},h=b=>{let g=e.length-1,k={ArrowDown:()=>Math.min(g,c$1+1),ArrowUp:()=>Math.max(0,c$1-1),Home:()=>0,End:()=>g};k[b.key]?(b.preventDefault(),l(k[b.key]())):b.key==="Enter"||b.key===" "?(b.preventDefault(),I(e[c$1].code)):(b.key==="Escape"||b.key==="Tab")&&(b.preventDefault(),b.stopPropagation(),d());};return jsxs("div",{ref:m,className:cn$1("novapay:relative",o),children:[jsxs("button",{ref:y,type:"button","aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?`${p}-list`:void 0,className:cn$1(Ct,Xe,"novapay:text-[11px]"),onClick:()=>r?d():v(),onKeyDown:b=>{b.key==="ArrowDown"&&!r&&(b.preventDefault(),v());},children:[jsx(Zo,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),jsx("span",{children:i.short}),jsxs("span",{className:"novapay:sr-only",children:[", ",c(t.language.button,{language:i.name})]}),jsx(an,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"})]}),r&&jsxs("div",{className:"tuwa-scanlines novapay:absolute novapay:right-0 novapay:top-full novapay:z-20 novapay:mt-1.5 novapay:w-60 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-1.5",children:[jsx("span",{id:`${p}-title`,className:cn$1(De,"novapay:block novapay:px-2.5 novapay:py-1"),children:t.language.title}),jsx("ul",{ref:f,id:`${p}-list`,role:"listbox",tabIndex:-1,"aria-labelledby":`${p}-title`,"aria-activedescendant":`${p}-${e[c$1].code}`,onKeyDown:h,className:cn$1("novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-0.5 novapay:p-0",oe),children:e.map((b,g)=>{let k=b.code===i.code;return jsxs("li",{id:`${p}-${b.code}`,role:"option","aria-selected":k,lang:b.code,onClick:()=>I(b.code),onPointerMove:()=>l(g),className:cn$1("novapay:flex novapay:h-8 novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:px-2.5 novapay:text-[13px]",g===c$1&&"novapay:bg-[var(--tuwa-bg-muted)]","novapay:text-[var(--tuwa-text-primary)]",k&&"novapay:font-semibold"),children:[jsx("span",{"aria-hidden":true,className:cn$1(q,"novapay:w-5 novapay:text-[11px]"),children:b.short}),jsx("span",{children:b.name}),k&&jsx(DrawnCheck,{className:"novapay:ml-auto novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-accent)]"})]},b.code)})}),jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:px-2.5 novapay:pb-1 novapay:pt-2 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:a?t.language.noteAfterPaid:t.language.note})]})]})}var is=(e,t)=>yr(e.screen,{withDetails:t})??(e.screen==="paid"?fr({withDetails:t}):null);function cs(e,t,a){let n=e.customization.components?.Stepper??Qr;return jsx(n,{steps:t,labels:e.labels,className:cn$1(a,Z(e,"stepper")),stepClassName:(o,r)=>Z(e,"step",{step:o,index:r})})}function ls({title:e,withDetails:t}){let a=A(),{labels:n,locale:o,setLocale:r,close:s,state:i}=a,c=a.display==="page",l=a.customization.config?.showSteps===false?null:is(a,t),p=Z(a,"header"),m=a.customization.handlers?.onLocaleChange,y=jsxs("div",{className:"novapay:ml-auto novapay:flex novapay:shrink-0 novapay:items-center novapay:gap-2",children:[jsx(ss,{locale:o,labels:n,receiptIssued:!!i.receiptUrl,onSelect:f=>{m?m({locale:f,proceed:()=>r(f)}):r(f);}}),s&&jsx("button",{type:"button","aria-label":n.common.close,onClick:s,className:Ct,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]});return jsxs(Fragment$1,{children:[jsxs("header",{className:cn$1("novapay:hidden novapay:items-center novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:py-3.5 novapay:pl-5 novapay:pr-4 novapay:sm:flex",c&&"novapay-page-header",p),children:[l?cs(a,l):e&&jsx("h2",{className:cn$1(q,"novapay:m-0 novapay:flex-1 novapay:text-[15px] novapay:font-bold"),children:e}),y]}),jsxs("header",{className:cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-4 novapay:pb-3 novapay:pt-1.5 novapay:sm:hidden",c&&"novapay-page-header-phone",p),children:[jsx(da,{compact:true}),y]})]})}function ps({withDetails:e}){let t=A();if(t.customization.config?.showSteps===false)return null;let a=is(t,e);return a?cs(t,a,"novapay:px-4 novapay:pt-3.5"):null}var Ql=new Set(["paid","held","refunded","partially_refunded"]);function yn(){let{state:e,locale:t,adapterFor:a}=A(),o=(e.invoiceStatus&&Ql.has(e.invoiceStatus)?e.checkout?.quote:null)??e.quote,r=o?ve(o.instructions):null,s=e.txHash??e.txKey,i=o?.payer?parseCaip10AccountId(o.payer)?.address:void 0,c=(e.checkout?.invoice.payments??[]).map(l=>{let p=l.chainId?rn(l.chainId):null;return {txKey:l.txKey,amount:l.symbol&&l.decimals!==null?`${le(l.amount,l.decimals,t)} ${l.symbol}`:null,at:Date.parse(l.at),explorerUrl:p&&l.chainId?a(p)?.explorerUrl?.({chainId:l.chainId,txKey:l.txKey}):void 0}});return {network:r?ye(r):null,amount:o?`${le(o.amountToSend,o.decimals,t)} ${o.instructions.symbol}`:null,paidAmount:o?`${le(o.amountDue===o.cryptoAmountExpected?o.amountToSend:o.cryptoAmountExpected,o.decimals,t)} ${o.instructions.symbol}`:null,txKey:s,lastOfParts:o?o.amountDue!==o.cryptoAmountExpected:false,transfers:c,explorerUrl:o&&r&&s?a(o.instructions.family)?.explorerUrl?.({chainId:r,txKey:s}):void 0,from:i?shortAddress(i):null,fromAddress:i??null,fromUrl:o&&r&&i?a(o.instructions.family)?.explorerAddressUrl?.({chainId:r,address:i}):void 0}}var ao=new WeakMap,Zl=500;function ht(e,t){let a=ao.get(e)?.get(t);if(a)return a.leftAt===null||Date.now()-a.leftAt<Zl?a.value:void 0}function Bn(e,t,a,n=true){let o=ao.get(e)??new Map;o.set(t,{value:a,leftAt:n?Date.now():null}),ao.set(e,o);}function He(e,t){let{store:a}=A(),[n,o]=useState(()=>ht(a,e)??t);return useEffect(()=>(o(t),Bn(a,e,t,false),()=>Bn(a,e,t)),[a,e,t]),n}var us="actionKind",Xl="actionLabel",ha="novapay-action-arrives";function fn(e,t){let{store:a,customization:n}=A(),[o]=useState(()=>e==="primary"&&ht(a,us)==="secondary"&&!n.config?.animation?.disabled);return He(us,e??"none"),{label:He(Xl,e?t:"")||t,arrives:o}}function ds({tone:e,children:t}){let a=A(),n=He("chipTone",e),o=He("chipLabel",t);return jsx("span",{className:cn$1(en,"novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",tn[n],Z(a,"statusChip",{tone:e})),children:jsx(MorphText,{children:o})})}var ys=["................",".....######.....","...##########...","..############..",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.","..############..","...##########...",".....######.....","................"],np=["................","................","................","................","................","..........##....",".........###....","....##..###.....","....######......",".....####.......","......##........","................","................","................","................","................"],ap=["................","................","................","................","....##....##....","....###..###....",".....######.....","......####......","......####......",".....######.....","....###..###....","....##....##....","................","................","................","................"],xa=e=>e.flatMap((t,a)=>[...t].flatMap((n,o)=>n==="."?[]:[{x:o,y:a}])),fs=({x:e,y:t})=>`${e},${t}`,vs=(e,t)=>{let a=new Set(t.map(fs));return e.filter(n=>!a.has(fs(n)))},xs={check:vs(xa(ys),xa(np)),cross:vs(xa(ys),xa(ap))},hs=/M(\d+) (\d+)h(\d+)v1h-\3z/g;function gs(e){let t=new Map,a=(n,o)=>t.set(`${n},${o}`,{x:n,y:o});for(let n of e){if("d"in n){if(n.d.replace(hs,"")!=="")continue;for(let[,r,s,i]of n.d.matchAll(hs))for(let c=0;c<Number(i);c++)a(Number(r)+c,Number(s));continue}if([n.x,n.y,n.width,n.height].every(Number.isInteger))for(let r=0;r<n.height;r++)for(let s=0;s<n.width;s++)a(n.x+s,n.y+r);}return [...t.values()]}function bs(e,t,a){if(t.length===0)return [];let n=Math.PI*2,o=({x:i,y:c})=>Math.atan2(c-a.y,i-a.x),r=(i,c)=>{let l=Math.abs(i-c)%n;return l>Math.PI?n-l:l},s=t.map(i=>({source:i,at:o(i)}));return e.map(i=>{let c=o(i);return s.reduce((l,p)=>r(p.at,c)<r(l.at,c)?p:l).source})}var oo="mark",pp={paid:{mark:"check",tone:"novapay:text-[var(--tuwa-success-icon)]"},failed:{mark:"cross",tone:"novapay:text-[var(--tuwa-error-icon)]"},cancelled:{mark:"cross",tone:"novapay:text-[var(--tuwa-text-secondary)]"}},up={unconfirmed:{Icon:ut,tone:"novapay:text-[var(--tuwa-pending-icon)]"},underpaid:{Icon:ut,tone:"novapay:text-[var(--tuwa-pending-icon)]"},held:{Icon:ir,tone:"novapay:text-[var(--tuwa-info-icon)]"},refunded:{Icon:ar,tone:"novapay:text-[var(--tuwa-info-icon)]"},expired:{Icon:on,tone:"novapay:text-[var(--tuwa-text-secondary)]"},replaced:{Icon:nr,tone:"novapay:text-[var(--tuwa-info-icon)]"},blocked:{Icon:cr,tone:"novapay:text-[var(--tuwa-error-icon)]"}},Cs={waiting:"processing",paid:"succeed",failed:"failed"};function mp(e,t){let a=e.viewBox.baseVal,n=e.getBoundingClientRect();if(!a||a.width===0||n.width===0)return [];let o=(c,l)=>Number(c.getAttribute(l)??0),r=c=>!c.closest("defs, clipPath, mask"),s=[...[...e.querySelectorAll("rect")].filter(r).map(c=>({x:o(c,"x"),y:o(c,"y"),width:o(c,"width"),height:o(c,"height")})),...[...e.querySelectorAll("path")].filter(r).map(c=>({d:c.getAttribute("d")??""}))],i=n.width/a.width;return gs(s).map(({x:c,y:l})=>({x:n.left-t.left+(c+.5)*i,y:n.top-t.top+(l+.5)*i}))}function dp(e,t,a){let n=[...e.querySelectorAll("[data-px]")],o=e.viewBox.baseVal,r=e.getBoundingClientRect();if(n.length===0||!o||o.width===0||r.width===0)return;let s=r.width/o.width,i=n.map(p=>({x:r.left-t.left+(Number(p.getAttribute("x")??0)+.5)*s,y:r.top-t.top+(Number(p.getAttribute("y")??0)+.5)*s})),c=bs(i,a,{x:t.width/2,y:t.height/2});if(c.length===0)return;let l=p=>`${Math.round(p/s*100)/100}px`;n.forEach((p,m)=>{p.style.setProperty("--nova-px-x",l(c[m].x-i[m].x)),p.style.setProperty("--nova-px-y",l(c[m].y-i[m].y));});}function yp({mark:e,moves:t,className:a}){return jsx("svg",{viewBox:`0 0 ${16} ${16}`,shapeRendering:"crispEdges",fill:"currentColor","aria-hidden":"true",className:cn$1("novapay:block",a),"data-motion":t?"assemble":void 0,children:xs[e].map(({x:n,y:o})=>jsx("rect",{x:n,y:o,width:1,height:1,"data-px":"",style:pixelFlight(n,o)},`${n}-${o}`))})}function Ss({kind:e,className:t}){let a=A(),{store:n,customization:o}=a,{look:r}=useNovaIcons(),s=useRef(null),i=useRef(null),c=!o.config?.animation?.disabled;useLayoutEffect(()=>{let h=s.current,b=h?.querySelector("svg")??null,g=h?.getBoundingClientRect(),k=i.current??ht(n,oo)??null;b&&g&&c&&k&&k.kind!==e&&dp(b,g,k.pixels);let P={kind:e,pixels:b&&g?mp(b,g):[]};return i.current=P,Bn(n,oo,P,false),()=>Bn(n,oo,P)},[e,n,c]);let l=o.childCustomizations?.statusVisual,p=e in Cs?Cs[e]:null,m=p&&cn$1(l?.iconClassNames?.icon,l?.iconClassNames?.statusOverrides?.[p]),y=pp[e],f=up[e],v=o.components?.StatusIcon,d=p?void 0:Z(a,"statusIcon",{kind:e}),I;if(!p&&v)I=jsx(v,{kind:e,className:d});else {if(p&&r!=="pixel")return jsx(TxStatusVisual,{isProcessing:e==="waiting",isSucceed:e==="paid",isFailed:e==="failed",...l,className:cn$1(t,l?.className)});e==="waiting"?I=jsx(QuasarLoader,{size:64,accent:"var(--tuwa-pending-icon)",className:cn$1("novapay:text-[var(--tuwa-text-primary)]",m)}):y&&r==="pixel"?I=jsx(yp,{mark:y.mark,moves:c,className:cn$1(p?"novapay:h-16 novapay:w-16":"novapay:h-12 novapay:w-12",y.tone,m,d)}):y?I=jsx(DrawnCross,{variant:"disc",className:cn$1("novapay:h-12 novapay:w-12",y.tone,d)}):f&&(I=jsx(f.Icon,{"aria-hidden":true,className:cn$1("novapay:h-12 novapay:w-12",f.tone,d),...c&&r==="pixel"?{motion:"assemble"}:{}}));}return jsx("div",{className:cn$1("novapay:flex novapay:justify-center novapay:py-4",t,p&&l?.className),children:jsx("span",{ref:s,className:"novapay:relative novapay:flex novapay:h-16 novapay:w-16 novapay:items-center novapay:justify-center",children:I})})}function Ns({children:e,className:t}){let a=He("title",e);return jsx("h2",{...St,"aria-label":e,className:cn$1(et,t),children:jsx(MorphText,{wrap:true,children:a})})}function Rt({mark:e,tone:t,chip:a,title:n,amount:o,note:r}){let{display:s}=A(),i=s==="page",c=He("amount",o??""),l=He("note",r??"");return jsxs(Fragment$1,{children:[jsx(Ss,{kind:e,className:i?"novapay-page-visual":void 0}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:items-center",children:[jsx(ds,{tone:t,children:a}),jsx(Ns,{className:"novapay:mt-2",children:n}),o&&jsx("p",{"aria-label":o,className:cn$1(q,"novapay:m-0 novapay:mt-2 novapay:text-2xl novapay:font-bold",i&&"novapay-page-amount"),children:jsx(MorphText,{children:c||o})}),r&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:jsx(MorphText,{wrap:true,children:l||r})})]})]})}var Rs="steps";function vn({state:e}){let{store:t,customization:a}=A(),n=a.childCustomizations,[o]=useState(()=>ht(t,Rs)!==void 0),r=He(Rs,e),s=jsx(TxProgressIndicator,{isProcessing:r==="processing",isSucceed:r==="succeed",isConfirmed:r==="succeed",isFailed:r==="failed",...n?.progressIndicator,className:cn$1("novapay:max-w-sm",n?.progressIndicator?.className)});return o?jsx(AnimatePresence,{initial:false,children:s}):s}var Sp=new Set(["open","underpaid"]);function _s(){let{checkout:e,state:t,labels:a,close:n,customization:o,now:r,handedOverAt:s,display:i}=A(),c$1=i==="page",l=o.childCustomizations,p=yn(),m=e?.invoice.dueAt?Date.parse(e.invoice.dueAt):null,y=t.invoiceStatus??e?.invoice.status,f=tt(t),v=!f&&mt(t,e),d=e!==null&&(f||v)&&Sp.has(y??"")&&m!==null&&r>=m,I=d&&kr({state:t,checkout:e,handedOverAt:s,dueAt:m}),h=Nt(t.error)==="retrying",b=fn(n?"secondary":null,a.common.close);return jsxs(ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",c$1&&"novapay-page-status"),children:[jsx(Rt,{mark:"waiting",tone:"pending",chip:a.status.pending,title:a.confirm.title,amount:p.amount,note:p.network?c(a.confirm.hint,{network:p.network}):null}),jsx(vn,{state:"processing"}),jsxs(xe,{className:"novapay:max-w-sm",children:[p.network&&jsx(W,{name:a.confirm.network,children:p.network}),p.txKey&&jsx(W,{name:a.confirm.transaction,children:jsx(HashLink,{hash:p.txKey,explorerUrl:p.explorerUrl,variant:"compact",...l?.hashLink})}),p.fromAddress&&jsx(W,{name:a.confirm.from,children:jsx(HashLink,{hash:p.fromAddress,explorerUrl:p.fromUrl,variant:"compact",...l?.hashLink})})]}),jsx("p",{role:"status",className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",c$1&&"novapay:mt-auto"),children:jsx(MorphText,{wrap:true,children:h?a.outcome.unconfirmedRetrying:d?c(I?a.confirm.afterDeadline:a.confirm.pastDeadline,{merchant:e.merchant.name}):v?a.confirm.invoicePayment:a.confirm.canClose})})]}),n&&jsx(te,{children:jsx(re,{onClick:n,children:b.label})})]})}function ga({adapter:e,store:t,wallet:a$1,chainId:n}){let[o,r]=useState("idle"),[s,i]=useState(null),[c,l]=useState(null),p=useRef(0),m=a$1?.address,y=useRef(m);useEffect(()=>{y.current!==m&&(y.current=m,p.current++,r("idle"),i(null),l(null));},[m]);let f=useRef(false);return useEffect(()=>(f.current=false,()=>{f.current=true;}),[]),{step:o,problem:s,request:c,confirm:async({quote:d=false}={})=>{let I=++p.current,h=()=>p.current===I;i(null);let b=e?.signMessage;if(!b||!a$1)return i("unsupported"),false;if(a$1.chainId!==n&&e.switchChain){r("switching");try{await e.switchChain(n);}catch(w){if(h()){let x=b$1(w);i(x==="declined"?"switchDeclined":x==="failed"?"switchFailed":x),r("idle");}return false}if(!h())return false}h()&&r("signing");let g=t.getState().payer,k=null,P=await t.getState().confirmPayer(async(w,x)=>{h()&&l(x);try{return await b({message:w,account:a$1.address,chainId:x.chainId})}catch(C){let L=b$1(C);throw k=L==="declined"&&C instanceof a&&C.step==="switch"?"switchDeclined":L,C}});return h()&&(i(k),r("idle")),P&&d&&!f.current&&t.getState().payer===g&&await t.getState().requestQuote(),P},dismiss:()=>{p.current++,r("idle"),t.getState().abandonConfirmation();}}}function Fs(e){return e.closest("[data-novapay-scroll]")??null}function Np(e,t){let a=t?.offsetHeight;return a&&a>0?Math.min(e,a):e}function Tp(e){let t=e.offsetHeight;return t>0?Np(t,Fs(e)):null}function ba(e){let[t,a]=useState(null),[n,o]=useState(null),[r,s]=useState(null);return useEffect(()=>{if(!t)return;let i=Fs(t),c=()=>{if(!e){let m=Tp(t);m!==null&&o(m);}let p=i?.offsetHeight;s(p&&p>0?p:null);};if(c(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(c);return e||l.observe(t),i&&l.observe(i),()=>l.disconnect()},[t,e]),!e||n===null?[a,null]:[a,r?Math.min(n,r):n]}var Ip=new Set(["evm:coinbase","evm:baseaccount","evm:porto"]);function wa(e){return !!(e&&Ip.has(e.connectorType.toLowerCase()))}function Bs(e,t){return e==="required"||e==="confirming"?true:e==="unless_relayed"&&t!=="relay"}async function Ds(e,t){let{payerProof:a}=e.getState();if(a==="required"||a==="confirming")return t(true),null;t(false);let n=await e.getState().requestQuote();return !n&&e.getState().error?.code==="payer_proof_required"&&t(true),n}var Rp=new Set(["payer_chain_mismatch","too_many_payers","payer_is_recipient"]);function lo(e){let t=e?.code;return t!==void 0&&(t.startsWith("payer_proof_")||Rp.has(t))}var Ep=new Set(["rate_limited","request_failed","origin_required","invoice_not_payable"]);function Dn(e){let t=e?.code;return lo(e)||t!==void 0&&Ep.has(t)}function ka(e,t,a,n){if(t==="declined")return c(a.payerProof.declined,n);if(t==="switchDeclined")return c(a.payerProof.switchDeclined,n);if(t==="unsupported")return c(a.payerProof.unsupported,n);if(t==="wrongNetwork"||t==="switchFailed")return c(a.payerProof.wrongNetwork,n);if(t==="notAuthorized")return c(a.pay.notAuthorized,n);if(t==="alreadyPending")return c(a.walletPrompt.stillWaiting,n);if(t)return c(a.payerProof.failed,n);switch(e?.code){case void 0:case "payer_proof_required":return null;case "payer_proof_declined":return c(a.payerProof.declined,n);case "payer_proof_invalid":return a.payerProof.invalid;case "payer_proof_unavailable":return a.payerProof.unavailable;case "payer_chain_mismatch":return c(a.payerProof.wrongNetwork,n);case "too_many_payers":return c(a.payerProof.tooManyWallets,n);case "payer_is_recipient":return a.method.payerIsRecipient;case "rate_limited":return a.method.rateLimited;case "request_failed":return a.pay.noAnswer;default:return a.error.generic}}function Wn({kind:e,walletName:t,walletId:a,walletIcon:n,amount:o,merchant:r,network:s,to:i,priceTime:c$1,onRetry:l,text:p,details:m,hint:y,onCancel:f,stepHeight:v}){let{labels:d,display:I}=A(),h=useId(),b=useRef(null);useEffect(()=>b.current?.focus(),[e]);let[g]=useState(()=>typeof document>"u"?null:document.activeElement);useEffect(()=>()=>{let w=g?.ownerDocument;if(!g||!w||g===w.body||!g.isConnected)return;let x=w.activeElement;x&&x!==w.body&&!x.contains(g)||g.focus();},[g]);let k={wallet:t,amount:o,merchant:r,network:s},P=e==="sign"||e==="proof"?d.walletPrompt.signIn:e==="switch"?d.walletPrompt.switchIn:e==="submitting"?d.walletPrompt.submitting:d.walletPrompt.confirmIn;return jsxs("section",{"aria-labelledby":h,style:v?{"--novapay-step-height":`${v}px`}:void 0,className:cn$1("tuwa-scanlines novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center-safe novapay:gap-3 novapay:bg-[var(--tuwa-bg-primary)] novapay:px-6 novapay:py-5 novapay:text-center",v&&(I==="page"?"novapay:min-h-[var(--novapay-step-height)]":"novapay:max-sm:min-h-[var(--novapay-step-height)]")),children:[jsx(sa,{walletId:a,walletIcon:n}),jsx("h2",{id:h,ref:b,tabIndex:-1,className:et,children:c(P,k)}),(e==="sign"||e==="confirm"||e==="proof")&&jsxs(Fragment$1,{children:[jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:p??c(e==="confirm"?d.walletPrompt.confirmText:d.walletPrompt.signText,k)}),y&&jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:y}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-xs novapay:flex-col novapay:gap-1.5 novapay:text-left",children:[jsx("span",{className:De,children:jsx(Ce,{label:d.walletPrompt.check,values:k})}),jsx(xe,{children:m?m.map(w=>jsx(W,{name:w.name,children:w.value},w.name)):jsxs(Fragment$1,{children:[jsx(W,{name:d.walletPrompt.amount,children:o}),jsx(W,{name:d.walletPrompt.to,children:i}),jsx(W,{name:d.walletPrompt.network,children:s}),c$1&&jsx(W,{name:d.walletPrompt.priceLocked,children:c$1})]})})]}),l?jsxs("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[d.walletPrompt.notOpened," ",jsx(yt,{onClick:l,children:d.walletPrompt.tryAgain})]}):jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(d.walletPrompt.stillWaiting,k)})]}),e!=="submitting"&&jsx(re,{onClick:f,className:"novapay:max-w-xs",children:d.walletPrompt.cancel})]})}function Hs(){let{checkout:e,state:t,store:a,labels:n,locale:o,wallet:r,adapterFor:s,connectWallet:i,setConfirmWallet:c$1}=A(),l=e?.methods.find(z=>z.id===t.methodId)??null,p=l?Ve(l):null,m=ga({adapter:p?s(p):void 0,store:a,wallet:r,chainId:l?.chainId??""}),[y,f]=useState(false),v=useRef(null),d=m.step!=="idle",[I,h]=ba(d),b=useRef(false);if(useEffect(()=>{b.current&&!d&&v.current?.querySelector("[data-novapay-heading]")?.focus(),b.current=d;},[d]),!e||!l)return null;let g=e.merchant.name,k=r?.name??"",P=ye(l.chainId),w=e.invoice.number??e.invoice.id,x=e.invoice.totalMinor?`${ue(Ee(e.invoice.totalMinor),o)} ${e.invoice.currency}`:null,C=wa(r),L=t.phase==="quoting",_=d,K=ka(!L&&Dn(t.error)?t.error:null,m.problem,n,{wallet:k,network:P,merchant:g}),U={wallet:k,invoice:w,merchant:g},N=We(r,l),se=()=>{N&&t.payer!==N&&a.getState().setPayer(N),m.confirm({quote:true});},R=()=>{c$1(false),a.getState().clearError();},H=N?t.confirmedWallets?.find(z=>!cn(z,N)):void 0;return jsxs("div",{ref:v,className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:I,inert:d,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",d&&"novapay:hidden"),children:[jsxs(he,{title:n.payerProof.title,subtitle:n.payerProof.text,children:[r&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:h-7 novapay:w-7 novapay:shrink-0",children:jsx(WalletIcon,{walletName:r.walletId})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:k}),jsx("span",{className:cn$1(q,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(r.address),network:ye(r.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:()=>{i(l)||f(true);},className:nn,children:n.pay.change})]}),jsx(ln,{children:n.payerProof.summary}),jsxs(xe,{children:[jsx(W,{name:n.payerProof.invoice,children:w}),jsx(W,{name:n.payerProof.merchant,children:g}),x&&jsx(W,{name:n.payerProof.amount,children:x}),r&&jsx(W,{name:n.payerProof.wallet,children:jsx(qe,{hash:r.address,chainId:r.chainId})})]}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.why}),C&&jsxs("p",{className:"novapay:m-0 novapay:flex novapay:items-start novapay:gap-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsx(rr,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsx("span",{children:c(n.payerProof.passkey,U)})]}),r&&p==="eip155"&&r.chainId!==l.chainId&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.payerProof.willSwitch,{current:ye(r.chainId),network:P})}),H&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:c(n.payerProof.alreadyConfirmed,{wallet:shortAddress(Tt(H))})}),K&&jsx(Q,{children:K}),y&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(te,{children:[jsx(X,{busy:_||L,onClick:se,children:L?n.method.quoting:_?jsx(Ce,{label:n.payerProof.waiting,values:U}):jsx(Ce,{label:n.payerProof.confirm,values:U})}),jsx(re,{disabled:L,onClick:R,children:(t.invoiceStatus??e?.invoice.status)==="underpaid"?n.pay.backFromRest:n.pay.back}),jsx(Ue,{children:C?n.payerProof.noteSmart:n.payerProof.note})]})]}),d&&jsx(Wn,{kind:m.step==="switching"?"switch":"proof",walletName:k,walletId:r?.walletId??"",walletIcon:r?.icon,amount:x??"",merchant:g,network:P,to:"",priceTime:null,text:c(C?n.payerProof.promptPasskey:n.payerProof.promptText,U),details:[...m.request?[{name:n.payerProof.site,value:m.request.domain}]:[],{name:n.payerProof.invoice,value:w},{name:n.payerProof.merchant,value:g},...x?[{name:n.payerProof.amount,value:x}]:[]],hint:m.request?c(n.payerProof.signInRequest,{wallet:k,site:m.request.domain}):void 0,onRetry:se,onCancel:m.dismiss,stepHeight:h})]})}var qp=/^0x[0-9a-fA-F]{64}$/,Up=/^[1-9A-HJ-NP-Za-km-z]{64,90}$/;function Un(){let{store:e,state:t,checkout:a,labels:n,wallet:o}=A(),[r,s]=useState(false),[i,c]=useState(""),[l,p]=useState(false),[m,y]=useState(null),f=useId(),v=t.quote??a?.quote;if(!v)return null;let d=n.outcome;if(!r)return jsx(yt,{onClick:()=>s(true),children:d.nameHash});let I=async h=>{h.preventDefault();let b=i.trim();if(!(v.instructions.family==="solana"?Up:qp).test(b))return y(d.nameHashInvalid);y(null),p(true);let k=await e.getState().submit({txKey:b,...o?{from:o.address}:{}});p(false),k||y(d.nameHashRefused);};return jsxs("form",{onSubmit:h=>{I(h);},className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:gap-2 novapay:text-left",children:[jsx("label",{htmlFor:f,className:"novapay:text-xs novapay:font-semibold",children:d.nameHashField}),jsx("input",{id:f,value:i,autoComplete:"off",spellCheck:false,"aria-invalid":m?true:void 0,onChange:h=>c(h.target.value),className:cn$1(q,"novapay:box-border novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",oe)}),m&&jsx(Q,{children:m}),jsx(re,{type:"submit",disabled:l||!i.trim(),children:d.nameHashSend})]})}var Ks=e=>e?.code==="payment_unconfirmed",Gp={nonceSpent:"unconfirmedNonceSpent",unmined:"unconfirmedUnmined",rechecked:"unconfirmedNote",retrying:"unconfirmedRetrying",notReceived:"unconfirmedNotReceived",contact:"unconfirmedContact",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"},Gs=new Set(["nonceSpent","unmined","notReceived","contact","closed","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Vs=new Set(["nonceSpent","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),zs={unconfirmed:{tone:"pending",label:"unconfirmed"},underpaid:{tone:"pending",label:"underpaid"},held:{tone:"neutral",label:"review"},refunded:{tone:"neutral",label:"refunded"},expired:{tone:"neutral",label:"expired"},cancelled:{tone:"neutral",label:"cancelled"},replaced:{tone:"neutral",label:"replaced"},blocked:{tone:"error",label:"blocked"}},ee=({children:e,muted:t})=>jsx("p",{className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs",t?"novapay:text-[var(--tuwa-text-secondary)]":"novapay:text-[var(--tuwa-text-primary)]"),children:e});function uo(){let e=A(),{checkout:t,labels:a,onContact:n}=e;if(!t)return null;let o=jsx(Ce,{label:a.outcome.contact,values:{merchant:t.merchant.name}}),r=cn$1(ea,Z(e,"secondaryButton"));if(n)return jsx("button",{type:"button",onClick:n,className:r,children:o});let s=Ir(t.merchant,c(a.outcome.contactSubject,{number:t.invoice.number??t.invoice.id}));return s?jsx("a",{href:s,target:s.startsWith("mailto:")?void 0:"_blank",rel:"noopener noreferrer",className:r,children:o}):null}function Qs({kind:e}){let[t,a]=useState(false),n=A(),{checkout:o,state:r,store:s,labels:i,locale:c$1,now:l,wallet:p,connectWallet:m,openInvoice:y,qrShown:f,paymentSent:v,adapterFor:d,lockPrice:I}=n;if(!o)return null;let h=o.merchant.name,b=r.quote,g=o.methods.find(R=>R.id===(r.methodId??b?.methodId)),k=o.invoice.dueAt&&!o.invoice.closed?new Intl.DateTimeFormat(c$1,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(o.invoice.dueAt)):null,P=(R,H=b)=>H?`${le(R,H.decimals,c$1)} ${H.instructions.symbol}`:R,w=Nt(r.error),x=R=>c(i.outcome[Gp[R]],{merchant:h}),C=r.followingUntil??null,L=C?jsx(ee,{muted:true,children:c(i.outcome.followingUntil,{time:new Intl.DateTimeFormat(c$1,{timeStyle:"short"}).format(Date.parse(C))})}):null,_=Nr(r,o),K=R=>{if(!_||R!=="mismatch"&&(!R||!Gs.has(R)))return null;let H=b??o.quote,z=H?ve(H.instructions):null,ie=H&&z?d(H.instructions.family)?.explorerUrl?.({chainId:z,txKey:_}):void 0;return jsx(ze,{children:jsx(xe,{className:"novapay:w-full novapay:max-w-sm",children:jsx(W,{name:i.confirm.transaction,children:jsx(HashLink,{hash:_,explorerUrl:ie,variant:"compact",...n.customization.childCustomizations?.hashLink})})})})},U,N=null,se=null;switch(e){case "unconfirmed":{if(U=i.outcome.unconfirmedTitle,dt(r.error))N=jsxs(Fragment$1,{children:[jsx(ee,{children:Wt(r.error,i,h)}),K("mismatch")]});else if(w&&Vs.has(w))N=jsxs(Fragment$1,{children:[jsx(ee,{children:x(w)}),K(w),w==="nonceSpent"&&jsx(Un,{})]});else {let z=w??"contact";N=jsxs(Fragment$1,{children:[jsx(ee,{children:i.outcome.unconfirmedText}),jsx(ee,{muted:true,children:x(z)}),K(z),jsx(Un,{})]});}let{payAgain:R}=s.getState(),H=r.invoiceStatus??o.invoice.status;R&&(H==="open"||H==="underpaid")&&!(w&&Vs.has(w))&&(se=dt(r.error)?r.error.held===true?jsx(X,{onClick:()=>R(),children:i.pay.payAgain}):jsx(re,{onClick:()=>R(),children:i.pay.payAgain}):jsx(re,{onClick:()=>R(),children:i.outcome.unconfirmedPayAgain}));break}case "underpaid":{let R=b??o.quote,H=o.invoice.amountPaid,z=Er(R,H);U=i.outcome.underpaidTitle;let ie=R&&H&&jsx(ee,{children:c(i.outcome.underpaidText,{received:P(H,R),total:P(R.cryptoAmountExpected,R)})});if(o.invoice.status==="underpaid"&&o.invoice.restPayable===false||r.error?.code==="method_not_found"){N=jsxs(Fragment$1,{children:[ie,jsx(ee,{children:i.outcome.underpaidClosed}),k&&jsx(ee,{children:c(i.outcome.underpaidClosedRefund,{merchant:h,date:k})})]});break}let Pe=sn(R,l,i,h,c$1,i.outcome.underpaidRateEnded),fe=o.methods.find(ke=>ke.id===R?.methodId)??g??o.methods[0],Te=r.error?.code==="payer_blocked"?c(i.outcome.underpaidBlocked,{merchant:h}):r.error&&r.error.code!=="payer_mismatch"?oa(r.error,i,h):null;N=jsxs(Fragment$1,{children:[ie,R&&z&&jsx(ee,{children:c(i.outcome.underpaidRest,{rest:P(z,R),network:ye(ve(R.instructions))})}),k&&jsx(ee,{muted:true,children:c(i.outcome.underpaidNote,{merchant:h,date:k})}),Pe&&jsx(ee,{muted:true,children:Pe}),Te&&jsx(Q,{children:Te})]});let E=fe&&p?We(p,fe):null,B=r.error?.code==="payer_mismatch"?r.error.originWallet??null:null,O=B??o.invoice.originWallet??R?.payer??null,Y=O?Tt(O):void 0,be=E?parseCaip10AccountId(E)?.address:void 0,ce=R?.payer!==null&&!!(Y&&(be?!cn(be,Y):B)),we=()=>{if(!fe)return;if(ce)return void m(fe);let ke=R?.payer===null?null:E;if(R?.payer!==null&&!ke)return void m(fe);r.methodId!==fe.id&&s.getState().selectMethod(fe.id),s.getState().setPayer(ke),I();};ce&&Y&&(N=jsxs(Fragment$1,{children:[N,jsx(ee,{children:c(i.outcome.payRestFirstWallet,{wallet:shortAddress(Y)})})]})),se=jsx(X,{busy:r.phase==="quoting",onClick:we,children:i.outcome.payRest});break}case "held":{U=c(i.outcome.heldTitle,{merchant:h});let R=o.invoice.review?.reason,H=R==="late"?i.outcome.heldLate:R==="overpaid"?i.outcome.heldOverpaid:R==="quote_expired"?i.outcome.heldQuoteExpired:i.outcome.heldScreening;N=jsxs(Fragment$1,{children:[jsx(ee,{children:c(H,{merchant:h})}),jsx(ee,{muted:true,children:i.outcome.heldNote})]});break}case "refunded":{U=i.outcome.refundedTitle;let R=o.invoice.refundedTotalMinor??o.invoice.totalMinor;N=R&&jsx(ee,{children:c(i.outcome.refundedText,{merchant:h,amount:ue(Ee(R),c$1),currency:o.invoice.currency})});break}case "expired":{U=i.outcome.expiredTitle;let R=Lr(o.invoice.amountPaid),H=b??o.quote,z=tt(r)||mt(r,o),ie=Ks(r.error)||w==="settlementFailed"||w==="settlementRetrying",ge=ie||!z&&Ot(r,o),Pe=!ge&&w==="closed",fe=!ge&&!Pe&&(z||v),Te=!ge&&!Pe&&!fe&&dt(r.error),E=fe||ge||Pe||Te||f,B=ie?w??"contact":"rechecked";N=jsxs(Fragment$1,{children:[R?jsxs(Fragment$1,{children:[k&&jsx(ee,{children:H?c(i.outcome.expiredPartText,{date:k,amount:P(R,H)}):c(i.outcome.expiredPartNoAmount,{date:k})}),!k&&H&&jsx(ee,{children:c(i.outcome.closedPartText,{merchant:h,amount:P(R,H)})}),jsx(ee,{children:c(i.outcome.expiredPartRefund,{merchant:h})})]}):!E&&k&&jsx(ee,{children:c(i.outcome.expiredText,{date:k,merchant:h})}),ge?jsxs(Fragment$1,{children:[jsx(ee,{children:B==="rechecked"?c(i.outcome.expiredUnconfirmed,{merchant:h}):x(B)}),K(B),B==="nonceSpent"&&jsx(Un,{})]}):Pe?jsxs(Fragment$1,{children:[jsx(ee,{children:x("closed")}),K("closed")]}):fe?jsxs(Fragment$1,{children:[jsx(ee,{children:c(i.outcome.expiredWhileConfirming,{merchant:h})}),L]}):Te?jsxs(Fragment$1,{children:[jsx(ee,{children:Wt(r.error,i,h)}),K("mismatch")]}):f?jsx(ee,{children:c(i.outcome.expiredAfterQr,{merchant:h})}):jsx(ee,{muted:true,children:i.outcome.expiredNote})]});break}case "cancelled":{if(U=i.outcome.cancelledTitle,w&&Gs.has(w)){N=jsxs(Fragment$1,{children:[jsx(ee,{children:x(w)}),K(w),w==="nonceSpent"&&jsx(Un,{})]});break}let R=Ks(r.error)||w==="closed"||tt(r)||mt(r,o)||Ot(r,o)||v,H=!R&&dt(r.error),z=R?c(i.outcome.cancelledWhilePaying,{merchant:h}):H?Wt(r.error,i,h):c(f?i.outcome.cancelledAfterQr:i.outcome.cancelledText,{merchant:h});N=jsxs(Fragment$1,{children:[jsx(ee,{children:z}),H&&K("mismatch"),w==="retrying"&&jsx(ee,{muted:true,children:i.outcome.unconfirmedRetrying}),R&&L]});break}case "replaced":{let R=o.invoice.replacedBy,H=R?.number??"";if(U=c(i.outcome.replacedTitle,{merchant:h}),N=jsxs(Fragment$1,{children:[jsx(ee,{children:c(i.outcome.replacedText,{number:H})}),jsx(ee,{muted:true,children:i.outcome.replacedPaid})]}),R?.checkoutToken){let z=R.checkoutToken;se=jsx(X,{onClick:()=>y(z),children:jsx(Ce,{label:i.outcome.openReplacement,values:{number:H}})});}break}case "blocked":{U=i.outcome.blockedTitle;let R=r.payer?parseCaip10AccountId(r.payer)?.address:void 0;N=jsxs(Fragment$1,{children:[jsx(ee,{children:r.error?.code==="payer_not_expected"?i.method.payerNotExpected:c(i.outcome.blockedText,{merchant:h})}),R&&jsx(qe,{hash:R,chainId:b??o.quote?ve((b??o.quote).instructions):null})]}),g&&(se=jsx(X,{onClick:()=>{m(g)||a(true);},children:i.outcome.useAnotherWallet}));break}}return jsxs(Fragment$1,{children:[jsxs("section",{role:e==="blocked"?"alert":void 0,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",n.display==="page"&&"novapay-page-status"),children:[jsx(Rt,{mark:e,tone:zs[e].tone,chip:i.status[zs[e].label],title:U}),N,t&&jsx(Q,{children:i.pay.connectUnavailable})]}),jsxs(te,{children:[se,jsx(uo,{})]})]})}function Hn({children:e,className:t}){let{store:a,customization:n}=A(),[o]=useState(()=>ht(a,"title")!==void 0),r=o&&!n.config?.animation?.disabled;return jsx("div",{className:cn$1("novapay:w-full",r&&"novapay-status-reveal",t),children:e})}function Ys(){let e=A(),{checkout:t,state:a,labels:n,adapterFor:o,payAfterFailure:r,customization:s,display:i}=e,c$1=yn(),l=fn("primary",n.pay.payAgain);if(!t||!a.error)return null;let p=i==="page",m=s.childCustomizations,y=aa(a.error)??c$1.txKey,f=a.quote??t.quote,v=f?ve(f.instructions):null,d=y===c$1.txKey?c$1.explorerUrl:f&&v&&y?o(f.instructions.family)?.explorerUrl?.({chainId:v,txKey:y}):void 0;return jsxs(ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",p&&"novapay-page-status"),children:[jsx(Rt,{mark:"failed",tone:"error",chip:n.status.failed,title:n.failed.title,amount:c$1.amount,note:c$1.network?c(n.failed.summary,{network:c$1.network}):null}),jsx(vn,{state:"failed"}),(c$1.network||y||c$1.fromAddress)&&jsxs(xe,{className:"novapay:max-w-sm",children:[c$1.network&&jsx(W,{name:n.confirm.network,children:c$1.network}),y&&jsx(W,{name:n.confirm.transaction,children:jsx(HashLink,{hash:y,explorerUrl:d,variant:"compact",...m?.hashLink})}),c$1.fromAddress&&jsx(W,{name:n.confirm.from,children:jsx(HashLink,{hash:c$1.fromAddress,explorerUrl:c$1.fromUrl,variant:"compact",...m?.hashLink})})]}),jsx(Hn,{className:"novapay:max-w-sm",children:jsx("p",{role:"status",className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:Ln(a.error,n,c$1.network??void 0)})})]}),jsxs(te,{children:[jsx(X,{onClick:r,className:l.arrives?ha:void 0,children:l.label}),jsx(Hn,{children:jsx(uo,{})})]})]})}function Xs({onStay:e,onLeave:t}){let{checkout:a,labels:n,locale:o}=A(),r=useId(),s=useId(),i=useRef(null),c$1=a?.invoice.dueAt?new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(a.invoice.dueAt)):null;return jsx(Dialog,{open:true,onOpenChange:l=>{l||e();},children:jsxs(DialogContent,{role:"alertdialog","aria-labelledby":r,"aria-describedby":s,onOpenAutoFocus:l=>{l.preventDefault(),i.current?.focus();},className:"novapay:w-full novapay:sm:w-[24rem]",children:[jsx(DialogTitle,{"aria-hidden":true,className:"novapay:sr-only",children:n.leave.title}),jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:p-5 novapay:text-center",children:[jsx("h2",{id:r,ref:i,tabIndex:-1,className:et,children:n.leave.title}),jsx("p",{id:s,className:"novapay:m-0 novapay:text-xs",children:c$1?c(n.leave.text,{date:c$1}):n.leave.textNoDate}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.leave.price}),jsx(X,{onClick:e,children:n.leave.stay}),jsx(re,{onClick:t,children:n.leave.leave})]})]})})}function hn({label:e,items:t,value:a,getKey:n,onChange:o,children:r,className:s,itemClassName:i}){let c=useRef([]),l=Math.max(0,t.findIndex(m=>n(m)===a)),p=(m,y)=>{let f=t.length-1,v={ArrowRight:y+1,ArrowDown:y+1,ArrowLeft:y-1,ArrowUp:y-1,Home:0,End:f}[m.key];if(v===void 0)return;m.preventDefault();let d=v<0?f:v>f?0:v;o(n(t[d])),c.current[d]?.focus();};return jsx("div",{role:"radiogroup","aria-label":e,className:s,children:t.map((m,y)=>{let f=n(m),v=f===a;return jsx("button",{ref:d=>{c.current[y]=d;},type:"button",role:"radio","aria-checked":v,tabIndex:y===l?0:-1,onClick:()=>o(f),onKeyDown:d=>p(d,y),className:cn$1("novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-left novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors","novapay:border",v?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",oe,i?.(v,m)),children:r(m,v)},f)})})}function $n({tone:e,children:t}){return jsx("span",{className:cn$1(en,tn[e]),children:t})}function ai({method:e,labels:t}){let a=ja(e);return a?a.kind==="discount"?jsx($n,{tone:"success",children:c(t.method.discount,{percent:a.percent})}):jsx($n,{tone:"neutral",children:c(t.method.markup,{percent:a.percent})}):null}function cu({selected:e}){return jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-full)] novapay:box-border",e?"novapay:border-4 novapay:border-[var(--tuwa-text-accent)]":"novapay:border novapay:border-[var(--tuwa-text-secondary)]")})}function lu({labels:e,terms:t,refundPolicy:a}){let n=(r,s)=>jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",oe),children:s},r),o=t&&a?d(e.method.agreeBoth,{terms:n(t,e.summary.terms),refundPolicy:n(a,e.summary.refundPolicy)}):t||a?d(e.method.agreeOne,{link:t?n(t,e.summary.terms):n(a,e.summary.refundPolicy)}):null;return o?jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o}):null}function oi(){let e=A(),{checkout:t,state:a,store:n,labels:o,wallet:r,payWith:s,setPayWith:i,payUrl:c$1,connectWallet:l,adapterFor:p,setHandoff:m,lockPrice:y}=e,{TokenOption:f,NetworkOption:v}=e.customization.components??{},d=useMemo(()=>t?.methods??[],[t]),I=useMemo(()=>vr(d,r?.chainId),[d,r?.chainId]),h=d.find(E=>E.id===a.methodId)??null,b=I.find(E=>E.symbol===h?.symbol)??null,g=h?mr(h,c$1):false,k=h?Ve(h):null,w=[...(k?!!p(k):false)?["wallet"]:[],...g?["qr"]:[]],x=w.includes(s)?s:w[0]??null,[C,L]=useState(false),_=useId(),K=useId(),U=useEffectEvent(()=>{let E=I[0]?.methods[0];!a.methodId&&E&&n.getState().selectMethod(E.id,{keepError:true});});if(useEffect(()=>U(),[I]),!t)return null;if(d.length===0)return jsx(he,{title:o.method.title,children:jsx(Q,{children:o.method.noMethods})});let N=e.display==="page",se=I.reduce((E,B)=>B.methods.length>E.methods.length?B:E,I[0]),R=a.phase==="quoting",H=t.consent??null,z=!!a.consentGiven,ie=!!(H?.required&&!z),ge=e.customization.handlers,Pe=E=>{let B=()=>n.getState().selectMethod(E.id);ge?.onMethodSelect?ge.onMethodSelect({method:E,select:B}):B();},fe=async()=>{if(!h||!x)return;if(L(false),x==="qr"){if(s!=="qr"&&i("qr"),k!=="solana")return m(true);n.getState().setPayer(null),await n.getState().requestQuote();return}s!=="wallet"&&i("wallet");let E=We(r,h);if(!E)return L(!l(h));n.getState().setPayer(E),await y();},Te=E=>jsxs(Fragment$1,{children:[jsx(ln,{children:jsx(Ce,{label:o.method.network,values:{symbol:E.symbol}})}),jsx(hn,{label:c(o.method.network,{symbol:E.symbol}),items:E.methods,value:h?.id??null,getKey:B=>B.id,onChange:B=>{let O=E.methods.find(Y=>Y.id===B);O&&Pe(O);},className:N&&E.methods.length>1?"novapay:grid novapay:grid-cols-1 novapay:gap-1.5 novapay:@min-[520px]:grid-cols-2":"novapay:flex novapay:flex-col novapay:gap-1.5",itemClassName:(B,O)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-3 novapay:py-2.5",Z(e,"networkOption",{method:O,selected:B})),children:(B,O)=>v?jsx(v,{method:B,selected:O}):jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(NetworkIcon,{chainId:toEvmChainId(B.chainId)??B.chainId})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col novapay:gap-1",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:ye(B.chainId)}),jsxs("span",{className:"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-1.5",children:[r?.chainId===B.chainId&&jsx($n,{tone:"neutral",children:o.method.yourWallet}),B.featured&&jsx($n,{tone:"accent",children:o.method.popular}),jsx(ai,{method:B,labels:o}),B.gasless==="auto"?jsx($n,{tone:"success",children:o.method.noGasFee}):jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.buyerPaysGas})]})]}),jsx(cu,{selected:O})]})})]});return jsxs(Fragment$1,{children:[jsxs(he,{title:o.method.title,subtitle:c(o.method.subtitle,{minutes:Math.round(t.quoteTtlSeconds/60)}),children:[jsx(ln,{children:o.method.token}),jsx(hn,{label:o.method.token,items:I,value:b?.symbol??null,getKey:E=>E.symbol,onChange:E=>{let B=I.find(O=>O.symbol===E)?.methods[0];B&&Pe(B);},className:"novapay:grid novapay:grid-cols-[repeat(auto-fit,minmax(5.5rem,1fr))] novapay:gap-2",itemClassName:(E,B)=>cn$1("novapay:flex novapay:min-w-0 novapay:flex-col novapay:items-center novapay:gap-1 novapay:px-2 novapay:py-2",N&&"novapay-page-token",Z(e,"tokenOption",{group:B,selected:E})),children:(E,B)=>f?jsx(f,{group:E,selected:B}):jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:h-6.5 novapay:w-6.5",children:jsx(TokenIcon,{symbol:E.symbol})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:E.symbol}),jsx("span",{className:"novapay:max-w-full novapay:truncate novapay:text-[10px] novapay:text-[var(--tuwa-text-secondary)]",children:E.methods.length>1?c(o.method.networks,{count:E.methods.length}):ja(E.methods[0])?jsx(ai,{method:E.methods[0],labels:o}):ye(E.methods[0].chainId)})]})}),N&&b?jsxs("div",{className:cn$1("novapay:grid",b.methods.length===1&&"novapay:max-sm:hidden"),children:[se!==b&&jsx("div",{inert:true,"aria-hidden":true,className:"novapay:invisible novapay:flex novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1] novapay:max-sm:hidden",children:Te(se)}),jsx("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1]",children:Te(b)})]}):b&&b.methods.length>1&&Te(b),jsx(ln,{children:o.method.payWith}),jsx(hn,{label:o.method.payWith,items:w,value:x,getKey:E=>E,onChange:E=>{L(false),i(E);},className:cn$1("novapay:grid novapay:gap-2",w.length>1&&"novapay:grid-cols-2"),itemClassName:(E,B)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-2.5 novapay:py-2",N&&"novapay-page-way",Z(e,"payWithOption",{payWith:B,selected:E})),children:E=>E==="wallet"?jsxs(Fragment$1,{children:[r?jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(_n,{walletId:r.walletId,icon:r.icon})}):jsx(er,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:text-[var(--tuwa-text-accent)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:o.method.wallet}),jsx("span",{className:cn$1("novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",r&&q),children:r?`${r.name} \xB7 ${shortAddress(r.address)}`:o.method.walletHint})]})]}):jsxs(Fragment$1,{children:[h&&Ve(h)==="solana"?jsx(lr,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}):jsx(or,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}),jsxs("span",{className:"novapay:flex novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:o.method.qr}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.qrHint})]})]})}),H&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-start novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:transition-colors",z?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",Z(e,"consentOption",{checked:z,required:H.required})),children:[jsx(ia,{checked:z,required:H.required,"aria-labelledby":_,"aria-describedby":H.required?K:void 0,onChange:E=>n.getState().setConsentGiven(E.target.checked),className:"novapay:mt-0.5"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-1",children:[jsx("span",{id:_,className:"novapay:whitespace-pre-line novapay:break-words novapay:text-[12px] novapay:leading-snug",children:H.text}),H.required&&jsx("span",{id:K,className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.consentRequired})]})]}),h&&!x&&jsx(Q,{children:o.method.methodUnavailable}),C&&jsx(Q,{children:g?o.pay.connectUnavailable:o.method.methodUnavailable}),a.error&&a.phase==="selectMethod"&&jsxs(Fragment$1,{children:[jsx(Q,{children:oa(a.error,o,t.merchant.name)}),jsx(ca,{error:a.error})]})]}),jsxs(te,{children:[jsx(X,{busy:R,disabled:!h||!x||ie,onClick:()=>{h&&x&&ge?.onQuote?ge.onQuote({method:h,payWith:x,proceed:fe}):fe();},children:R?o.method.quoting:o.method.continue}),jsx(lu,{labels:o,terms:t.merchant.links.terms,refundPolicy:t.merchant.links.refundPolicy})]})]})}function ci(e,t,a,n=false){let o=useRef(null),r=t?.id??null,s=useEffectEvent(()=>{t&&a?.({...t,status:"paid"});});useEffect(()=>{e!=="paid"||!r||o.current===r||(o.current=r,n||s());},[e,r,n]);}function li({url:e,seconds:t,now:a,navigate:n=o=>window.location.assign(o)}){let[o,r]=useState(t>0?a:null);t>0!=(o!==null)&&r(t>0?a:null);let s=t>0?o??a:a,[i,c]=useState(false),l=e&&t>0&&!i?Math.max(0,t-Math.floor((a-s)/1e3)):null,p=useEffectEvent(()=>{e&&n(e);});return useEffect(()=>{l===0&&p();},[l]),{left:l,stay:()=>c(true)}}function ui(){let e=A(),{checkout:t,state:a,labels:n,locale:o,now:r,close:s,autoReturnSeconds:i,openedPaid:c$1,display:l}=e,p=e.customization.childCustomizations,m=yn(),[y]=useState(r),f=t?.merchant.name??"",v=l==="modal"&&i===0?null:t?.invoice.successUrl??null,d=li({url:v,seconds:c$1?0:i,now:r}),I=v?n.paid.back:s?n.common.close:null,h=fn(I===null?null:"primary",I??""),b=h.arrives?ha:void 0;if(!t)return null;let g=t.invoice.totalMinor?ue(Ee(t.invoice.totalMinor),o):null,k=t.invoice.refundedTotalMinor&&BigInt(t.invoice.refundedTotalMinor)>0n?ue(Ee(t.invoice.refundedTotalMinor),o):null,P=t.invoice.paidAt?Date.parse(t.invoice.paidAt):y,w=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(P),{transfers:x}=m,C=x.length>1?x:null,L=x.length===1?x[0]:null,_=m.txKey??L?.txKey??null,K=m.txKey?m.explorerUrl:L?.explorerUrl,U=new Intl.DateTimeFormat(o,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return jsxs(ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",e.display==="page"&&"novapay-page-status"),children:[jsx(Rt,{mark:"paid",tone:"success",chip:n.status.paid,title:n.paid.title,amount:m.paidAmount??(g&&`${g} ${t.invoice.currency}`),note:m.network?c(n.paid.summary,{network:m.network,date:w}):w}),jsx(vn,{state:"succeed"}),(m.network||_||C||m.from)&&jsxs(xe,{className:"novapay:max-w-sm",children:[m.network&&jsx(W,{name:n.confirm.network,children:m.network}),C?C.map((N,se)=>jsxs(W,{name:jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:block",children:c(n.confirm.transferOf,{index:se+1,count:C.length})}),jsx("time",{dateTime:new Date(N.at).toISOString(),className:"novapay:block novapay:text-[11px] novapay:leading-4",children:U.format(N.at)})]}),children:[N.amount&&jsx("span",{className:"novapay:block",children:N.amount}),jsx(HashLink,{hash:N.txKey,explorerUrl:N.explorerUrl,variant:"compact",...p?.hashLink})]},`${N.txKey}:${se}`)):_&&jsx(W,{name:m.lastOfParts?n.confirm.lastTransfer:n.confirm.transaction,children:jsx(HashLink,{hash:_,explorerUrl:K,variant:"compact",...p?.hashLink})}),m.fromAddress&&jsx(W,{name:n.confirm.from,children:jsx(HashLink,{hash:m.fromAddress,explorerUrl:m.fromUrl,variant:"compact",...p?.hashLink})})]}),k&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.paid.refunded,{amount:k,currency:t.invoice.currency})}),a.receiptUrl&&jsx(Hn,{className:"novapay:max-w-sm",children:jsxs("div",{className:"novapay:flex novapay:w-full novapay:items-center novapay:gap-3 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-left",children:[jsx(Jo,{"aria-hidden":true,className:"novapay:h-6 novapay:w-6 novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:n.paid.receipt}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.paid.receiptHint})]}),jsxs("a",{href:a.receiptUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1(nn,"novapay:gap-1.5 novapay:no-underline"),children:[jsx(tr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),n.paid.download]})]})})]}),jsx(te,{children:v?jsxs(Fragment$1,{children:[jsx("a",{href:v,className:cn$1(Pt,b,Z(e,"primaryButton")),children:jsx(Ce,{label:h.label,values:{merchant:f}})}),d.left!==null&&jsxs(Ue,{children:[jsx("span",{role:"timer","aria-live":"off",children:c(n.paid.returning,{merchant:f,seconds:d.left})})," ","\xB7 ",jsx(yt,{onClick:d.stay,children:n.paid.stay})]})]}):s&&jsx(X,{onClick:s,className:b,children:h.label})})]})}function mi({state:e,screen:t,now:a,locale:n=null,handlers:o}){let r=e.checkout?.invoice.status??null,{phase:s,error:i}=e,c=e.quote?.expiresAt?Date.parse(e.quote.expiresAt):null,l=c!==null&&a>=c,p=useEffectEvent(()=>o?.onStatusChange?.({phase:s,status:r,screen:t}));useEffect(()=>p(),[s,r]);let m=useEffectEvent(()=>{n&&o?.onLocaleShown?.({locale:n});});useEffect(()=>m(),[n]);let y=useEffectEvent(()=>{i&&o?.onError?.({error:i,screen:t});});useEffect(()=>y(),[i]);let f=useRef({quote:false,invoice:false}),v=useEffectEvent(d=>o?.onExpire?.({kind:d,paymentOnTheWay:tt(e)||mt(e,e.checkout)||Ot(e,e.checkout)}));useEffect(()=>{l&&!f.current.quote&&v("quote"),f.current.quote=l;},[l]),useEffect(()=>{let d=r==="expired";d&&!f.current.invoice&&v("invoice"),f.current.invoice=d;},[r]);}var xn=()=>new Promise(()=>{}),hu={view:xn,quote:xn,buyer:xn,locale:xn,submit:xn,relay:xn,url:()=>""},xu=createCheckoutStore({token:"idle",api:hu,EventSource:null});function yi(e){let{token:t,baseUrl:a,api:n,EventSource:o,pollMs:r,enabled:s=true}=e,[i,c]=useState(xu),l=useEffectEvent(()=>createCheckoutStore({token:t,baseUrl:a,api:n,EventSource:o,pollMs:r}));return useEffect(()=>{if(!s)return;let p=l();return c(p),p.getState().load(),()=>p.getState().destroy()},[t,a,s]),i}function fi(e,t){return useStore(e,t)}var Su=createStore(()=>({}));function Na(){let e=useContext(SatelliteStoreContext)??Su,t=useStore(e,l=>l.activeConnection),a=useStore(e,l=>l.getConnectors),n=useStore(e,l=>l.watchConnectors),[o,r]=useState(0);useEffect(()=>n?.(()=>r(l=>l+1)),[n]);let s=useMemo(()=>ur(t,a?.()),[t,a,o]),i=s?.name,c=s?.icon;return useMemo(()=>s,[t,i,c])}function hi(e){let[t,a]=useState({store:e,at:null});return useEffect(()=>e.subscribe((n,o)=>{n.phase!==o.phase&&(n.phase==="confirming"?a({store:e,at:o.phase==="submitting"?Date.now():null}):o.phase==="confirming"&&a({store:e,at:null}));}),[e]),t.store===e?t.at:null}var xi=Symbol.for("tuwaio.nova-payments.context"),gi=globalThis,Gn=gi[xi]??(gi[xi]=createContext({}));function it(){return useContext(Gn)}function bi(e,t=true){let[a,n]=useState(()=>Date.now());return useEffect(()=>{if(!t)return;let o=setInterval(()=>n(Date.now()),e);return ()=>clearInterval(o)},[e,t]),a}var vo="nova-payments:sponsoredBatches";var ho=()=>{try{return globalThis.sessionStorage??null}catch{return null}},xo=()=>{try{let e=JSON.parse(ho()?.getItem(vo)??"[]");return Array.isArray(e)?e:[]}catch{return []}},wi=e=>{try{e.length>0?ho()?.setItem(vo,JSON.stringify(e)):ho()?.removeItem(vo);}catch{}},Ta=e=>wi(xo().filter(t=>t.invoiceId!==e)),ki=e=>wi([...xo().filter(t=>t.invoiceId!==e.invoiceId),e]),go=e=>xo().find(t=>t.invoiceId===e&&Date.now()-t.at<21e5)??null;var Ci=e=>new a("unsupported",`${e} is not available`);async function Si({adapter:e,store:t,quote:a,wallet:n,path:o,paymasterUrl:r,onWalletDone:s,onBatchAccepted:i,onSent:c}){let l=n.address;if(o==="relay"){let m=a.gasless?.relay?.typedData;if(!m||!e.signTransferAuthorization)throw Ci("A gasless signature");let y=await e.signTransferAuthorization({typedData:m,account:l});return s?.(),t.getState().relay(y)}if(o==="paymaster"){let m=a.gasless?.paymaster?.calls;if(!m||!r||!e.sendSponsoredCalls)throw Ci("A sponsored payment");let y=ve(a.instructions),f=await e.sendSponsoredCalls({calls:m,paymasterUrl:r,chainId:y,account:l,onSent:s,onAccepted:i,onLate:v=>{c?.(v),t.getState().submit({txKey:v,connectorType:n.connectorType,methodId:a.methodId});}});return s?.(),c?.(f),t.getState().submit({txKey:f,connectorType:n.connectorType,methodId:a.methodId})}let p=await e.sendTransfer({instructions:a.instructions,account:l,connection:n.connection});return s?.(),c?.(p),t.getState().submit({txKey:p,connectorType:n.connectorType,methodId:a.methodId})}var Ia=6e5;var Lt=new WeakMap;function Ea(e){let t=Lt.get(e);return !!(t?.accepted&&Date.now()<t.until)}function Ni({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,invoiceId:s,onSent:i}){let[c,l]=useState("idle"),[p,m]=useState(()=>{let g=Lt.get(t),k=g?.unconfirmed&&g.account===n?.address&&Date.now()<g.until,P=s?go(s):null;return k||P?"sentUnconfirmed":null}),y=useEffectEvent(g=>i?.(g));useEffect(()=>{if(!s||Lt.has(t))return;let g=go(s);if(!g)return;let k=Promise.reject(new a("sentUnconfirmed","The sponsored payment is not confirmed yet"));k.catch(()=>{});let P=g.at+21e5;Lt.set(t,{account:g.account,path:"paymaster",paying:k,until:P,unconfirmed:true,instructions:g.instructions,accepted:true}),e?.followSponsoredCalls?.({batchId:g.batchId,until:P,onLate:w=>{Ta(s),y({txKey:w,instructions:g.instructions,account:g.account,connectorType:g.connectorType}),t.getState().submit({txKey:w,connectorType:g.connectorType,methodId:g.methodId});}});},[s,e,t]);let f=useRef(0),[v,d]=useState(null),[I,h]=useState(null),b=async(g,k)=>{let P=++f.current,w=()=>f.current===P;m(null),l(g);try{await k(w);}catch(x){w()&&m(b$1(x));}finally{w()&&l("idle");}};return {status:c,problem:p,askedWallet:v,askedInstructions:I,pay:()=>b("wallet",async g=>{if(!e||!a$1||!n)return m("unsupported");d(n);let k=Lt.get(t),P=k?.path==="relay"&&o==="relay";if(k?.account===n.address&&!P&&Date.now()<k.until){h(k.instructions),await k.paying;return}h(a$1.instructions);let w={account:n.address,path:o,paying:Promise.resolve(),until:Date.now()+6e5,unconfirmed:!1,instructions:a$1.instructions,accepted:!1};Lt.set(t,w);let x=Si({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,onWalletDone:()=>{o==="paymaster"&&(w.accepted=!0),g()&&l("submitting");},onBatchAccepted:L=>{s&&ki({invoiceId:s,batchId:L,account:n.address,instructions:a$1.instructions,connectorType:n.connectorType,methodId:a$1.methodId,at:Date.now()});},onSent:L=>{s&&Ta(s),i?.({txKey:L,instructions:a$1.instructions,account:n.address,connectorType:n.connectorType});}});w.paying=x;let C=()=>{Lt.get(t)===w&&Lt.delete(t),s&&Ta(s);};x.then(C,L=>{if(b$1(L)!=="sentUnconfirmed")return C();w.unconfirmed=!0,w.until=Date.now()+21e5;}),await x;}),switchNetwork:()=>b("switching",async()=>{if(!e?.switchChain||!a$1)return m("unsupported");await e.switchChain(ve(a$1.instructions));}),dismiss:()=>{f.current++,l("idle");}}}var Mu=100,Fu=300,Ti=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e;async function Ii({adapter:e,pulsar:t,payment:a,labels:n,merchant:o,invoice:r,amount:s}){if(!t||!e?.pulsarTransaction)return false;let i=r.number?c(n.pay.txDescription,{amount:s,invoice:r.number}):s,c$1=e.pulsarTransaction({...a,title:Ti(c(n.pay.txTitle,{merchant:o}),Mu),description:Ti(i,Fu),payload:{quasarInvoice:r.id}});return await t.injectExternalPendingTxs([c$1]),true}var Du=new Set(["open","processing","underpaid"]),Li=new WeakMap,bo=e=>{let t=Li.get(e);return t||Li.set(e,t={keys:new Set,sentHere:false}),t},Ou=e=>e.split(":").at(-1)??e;function Ai({store:e,adapterFor:t,pulsar:a,labels:n,locale:o}){let r=useRef({adapterFor:t,pulsar:a,labels:n,locale:o});useEffect(()=>{r.current={adapterFor:t,pulsar:a,labels:n,locale:o};});let s=useCallback(i=>{let{checkout:c}=e.getState(),{adapterFor:l,pulsar:p,labels:m,locale:y}=r.current,f=bo(e);if(!c||!p||f.keys.has(i.txKey))return;f.keys.add(i.txKey);let{amount:v,decimals:d,symbol:I}=i.instructions;Ii({adapter:l(i.instructions.family),pulsar:p,payment:i,labels:m,merchant:c.merchant.name,invoice:{id:c.invoice.id,number:c.invoice.number},amount:`${le(v,d,y)} ${I}`}).catch(()=>{});},[e]);return useEffect(()=>e.subscribe((i,c)=>{let{txHash:l,quote:p,checkout:m}=i;if(!l||l===c.txHash||!p||!m||!Du.has(c.invoiceStatus)||bo(e).sentHere)return;let y=m.invoice.originWallet??p.payer;s({txKey:l,instructions:p.instructions,account:y?Ou(y):"",connectorType:""});}),[e,s]),useCallback(i=>{bo(e).sentHere=true,s(i);},[e,s])}function Mi({store:e,state:t,walletTxKey:a=null}){let[n,o]=useState(null),[r,s]=useState(null),i=a!==null&&a!==r;i&&s(a);let c=t.phase,l=i||tt(t)||mt(t,t.checkout)||Ot(t,t.checkout)||c==="confirming"||c==="unconfirmed",p=n?.store===e?n:null,m=l?p&&p.error===t.error?p:{store:e,error:t.error}:p&&Sr(t.error)&&t.error!==p.error?null:n;return m!==n&&o(m),m?.store===e}function Vn(e){let{labels:t,customization:a}=it(),n=a?.labels?.transform,[o,r]=useState(()=>h(e)),s=g(e);s&&o!==h(e)&&r(h(e));let i$1=s?h(e):o;return useEffect(()=>{if(g(e))return;let c=true;return i(e).then(l=>c&&r(l)),()=>{c=false;}},[e]),useMemo(()=>{let c=j(i$1,t);return n?n(c,{locale:e}):c},[i$1,e,t,n])}function Fi({store:e,screen:t}){let[a,n]=useState(null),o=t==="qr";return o&&a!==e&&n(e),o||a===e}function La(e){let t=useContext(NovaConnectProviderContext),a=it(),n=e??a.onConnectWallet;return {canConnect:!!(t||n),connecting:t?.isConnectModalOpen??false,connect:o=>t?(t.setIsConnectModalOpen(true,{adapter:o==="solana"?OrbitAdapter.SOLANA:OrbitAdapter.EVM}),true):n?(n(o),true):false}}function Di({box:e,content:t,isNarrow:a,isActive:n,duration:o=300}){if(typeof ResizeObserver>"u")return ()=>{};let r,s,i=0,c=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,l=()=>{s=void 0,e.style.removeProperty("overflow");},p=()=>{let f=s;l(),f?.cancel();},m=()=>{let f=t.offsetHeight,v=r;if(r=f,v===void 0||v===f)return;if(s){s.effect?.setKeyframes?.([{height:`${i}px`},{height:`${f}px`}]);return}if(!a()||!n()||c()||typeof e.animate!="function"||Math.abs(f-v)<12)return;i=v,e.style.overflow="clip";let I=e.animate([{height:`${v}px`},{height:`${f}px`}],{duration:o,easing:"cubic-bezier(0.2, 0, 0, 1)"});s=I;let h=()=>{s===I&&l();};I.onfinish=h,I.oncancel=h;},y=new ResizeObserver(m);return y.observe(t),m(),()=>{y.disconnect(),p();}}function qi({active:e,children:t}){let a=useRef(null),n=useRef(null),o=useRef(e);return useEffect(()=>{o.current=e;},[e]),useEffect(()=>{if(!a.current||!n.current||typeof window>"u"||!window.matchMedia)return;let r=window.matchMedia("(max-width: 639.98px)");return Di({box:a.current,content:n.current,isNarrow:()=>r.matches,isActive:()=>o.current})},[]),jsx("div",{ref:a,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:jsx("div",{ref:n,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:t})})}function gn(e,t){let[a,n]=useState(null),o=useEffectEvent(t);return useEffect(()=>{if(e===null)return;let r=true,s;try{s=Promise.resolve(o());}catch(i){s=Promise.reject(i);}return s.then(i=>r&&n({key:e,value:i}),()=>r&&n({key:e,value:null})),()=>{r=false;}},[e]),a&&a.key===e?a.value:void 0}function Aa(e,t,a){let[n,o]=useState(0),[r,s]=useState(null),i=useEffectEvent(t);return useEffect(()=>{if(e===null||typeof window>"u")return;let c=()=>{document.visibilityState!=="hidden"&&o(m=>m+1);},l=window,p=document;return l.addEventListener("focus",c),p.addEventListener("visibilitychange",c),()=>{l.removeEventListener("focus",c),p.removeEventListener("visibilitychange",c);}},[e]),useEffect(()=>{if(e===null)return;let c=true,l;try{l=Promise.resolve(i());}catch(p){l=Promise.reject(p);}return l.then(p=>c&&s({key:e,value:p}),()=>c&&s({key:e,value:null})),()=>{c=false;}},[e,n,a]),r&&r.key===e?r.value:void 0}var Gu=e=>e.charAt(0).toUpperCase()+e.slice(1);function Hi(e,t,a){let n=e.startsWith("solana:")?getSolanaCluster(e):void 0;if(!n||n==="mainnet")return null;let o={network:ye(e),cluster:Gu(n),wallet:t?.name??""},r=t?.family!=="solana"?void 0:t.walletId==="phantom"?a.pay.solanaHintPhantom:t.walletId==="solflare"?a.pay.solanaHintSolflare:a.pay.solanaHintOther;return {title:c(a.pay.solanaNetwork,o),text:c(a.pay.solanaNetworkText,o),...r?{hint:c(r,o)}:{}}}function $i(e,t){let a=e.startsWith("solana:")?getSolanaCluster(e):void 0;return !a||t?.family!=="solana"||getSolanaCluster(t.chainId)===a?null:e}function Ki(e,t){let a=useContext(SatelliteStoreContext),n=$i(e,t);useEffect(()=>{n&&a?.getState().switchNetwork?.(n);},[a,n]);}function ju(e,t){return e>=1?ue(e,t):new Intl.NumberFormat(t,{maximumSignificantDigits:6}).format(e)}function Yu(e,t,a,n){let o=n?.code;if(a==="declined")return c(e.pay.declined,t);if(a==="unsupported")return c(e.pay.unsupported,t);if(a==="wrongNetwork")return c(e.pay.wrongCluster,t);if(a==="switchFailed")return c(e.pay.switchFailed,t);if(a==="notAuthorized")return c(e.pay.notAuthorized,t);if(a==="alreadyPending")return c(e.walletPrompt.stillWaiting,t);if(a==="sentUnconfirmed")return c(e.pay.sentUnconfirmed,t);let r=a?null:Wt(n,e,t.merchant);return r!==null?r:a==="failed"?c(e.pay.walletFailed,t):n&&o==="payment_failed"?Ln(n,e,t.network):o==="screening_unavailable"?e.pay.screeningUnavailable:o==="request_failed"?e.pay.noAnswer:o==="price_unavailable"||o==="price_no_rpc"?e.method.priceUnavailable:o==="rate_limited"?e.method.rateLimited:o==="method_not_found"||o==="amount_out_of_range"||o==="testnet_required"?e.method.methodUnavailable:n&&!lo(n)?e.error.generic:null}var Zu=(...e)=>e.reduce((t,a)=>t&&!/[。!?]$/.test(t)?`${t} ${a}`:`${t}${a}`,"");function Ju(e,t,a){let{wallet:n,adapterFor:o}=A(),r=t?.instructions.family,s=r?o(r):void 0,i=e.filter(l=>l.id!==t?.methodId&&Ve(l)===r),c=gn(a&&s&&n&&i.length?`${n.address}:${i.map(l=>l.id).join()}`:null,()=>Promise.all(i.map(l=>s.getBalance({chainId:l.chainId,account:n.address,token:dr(l)}).catch(()=>0n))));return c?i.map((l,p)=>({method:l,balance:c[p]})).filter(l=>l.balance>0n):[]}function zi(){let{checkout:e,state:t,store:a,labels:n,locale:o,now:r,wallet:s,adapterFor:i,connectWallet:c$1,backToMethods:l,onPaymentSent:p,customization:m,lockPrice:y,display:f}=A(),v=m.config?.balanceCheck!==false,d=t.quote,I=e?.methods??[],h=I.find(Be=>Be.id===d?.methodId),b=d?.instructions.family??"eip155",g=i(b),k=d?ve(d.instructions):"",P=s?.address??"",[w,x]=useState(false),C=gn(d?.gasless?.paymaster&&g?.canSponsorCalls&&s?`${k}:${P}`:null,()=>g.canSponsorCalls({chainId:k,account:P})),L=d?Fr(d,{withGas:w,canSponsorCalls:C===true}):"transfer",_=Aa(v&&d&&g&&s?`${k}:${P}:${d.instructions.token}`:null,()=>g.getBalance({chainId:k,account:P,token:d.instructions.token}),d?.expiresAt),K=gn(d&&L==="transfer"&&g?.estimateFee&&s?`${k}:${P}:${d.amountToSend}`:null,()=>g.estimateFee({instructions:d.instructions,account:P})),U=Ni({adapter:g,store:a,quote:d,wallet:s,path:L,paymasterUrl:t.paymasterUrl,invoiceId:e?.invoice.id,onSent:p}),N=ga({adapter:g,store:a,wallet:s,chainId:k});Ki(k,s);let se=d?.instructions.token==="native",R=d&&typeof _=="bigint"?Or(_,d,se&&K?K.amount:0n):null,H=(t.invoiceStatus??e?.invoice.status)==="underpaid",z=Ju(I,d,v&&!!R&&!H),[ie,ge]=useState(false),Pe=N.step==="switching"||N.step==="signing"||U.status==="switching"||U.status==="submitting"||U.status==="wallet"||t.phase==="submitting",[fe,Te]=ba(Pe);if(e&&d&&!h)return jsxs(Fragment$1,{children:[jsx(he,{title:n.method.methodUnavailable,children:null}),jsx(te,{children:jsx(re,{onClick:l,children:n.pay.back})})]});if(!e||!d||!h)return null;let E=e.merchant.name,B=ye(k),O=Be=>`${le(Be,d.decimals,o)} ${d.instructions.symbol}`,Y=Br(d),be=U.askedInstructions,ce=be&&be.amount!==d.instructions.amount?`${le(be.amount,be.decimals,o)} ${be.symbol}`:O(Y.send),we=d.expiresAt?Date.parse(d.expiresAt)-r:Number.POSITIVE_INFINITY,ke=we<=0,Wa=br(we),zt=t.phase==="quoting",zn=e.invoice.amountPaid?null:Dr(d,e.invoice.totalMinor),ct=(t.invoiceStatus??e.invoice.status)==="underpaid",Qt=f==="page",jt=K?ua(String(K.amount),K.decimals,o):null,At=ct?sn(d,r,n,E,o):null,gt=e.invoice.totalMinor?ue(Ee(e.invoice.totalMinor),o):null,Cn=!!(s&&d.payer&&We(s,h)===d.payer),lt=b==="eip155"&&s&&s.chainId!==k&&!!g?.switchChain,Qn=U.status!=="idle"||t.phase==="submitting"||zt||N.step!=="idle",_t=Hi(k,s,n),Yt=()=>{a.getState().requestQuote();},jn=t.payerProof,Mt=Bs(jn,L),Sn=Mt?ka(Dn(t.error)?t.error:null,N.problem,n,{wallet:s?.name??"",network:B,merchant:E}):null,Ft=t.phase==="awaitingPayment"&&!(Mt&&Dn(t.error))?t.error:void 0,Pn=Yu(n,{wallet:s?.name??"",network:B,merchant:E},U.problem,Ft),bt=!U.problem&&(Ft?.code==="payment_failed"||Ft?.code==="payment_mismatch"),Bt=()=>{c$1(h)||ge(true);},Ze;ke?Ze={label:ct?n.outcome.payRest:n.pay.newPrice,run:Yt}:Cn?lt?Ze={label:jsx(Ce,{label:n.pay.switchTo,values:{network:B}}),run:()=>{U.switchNetwork();}}:Mt?Ze={label:n.payerProof.confirmToPay,run:()=>{N.confirm();}}:Ze={label:bt?n.pay.payAgain:jsx(Ce,{label:L==="transfer"?n.pay.payAmount:n.pay.signToPay,values:{amount:O(Y.send)}}),run:()=>{m.handlers?.onSubmit?m.handlers.onSubmit({quote:d,method:h,proceed:U.pay}):U.pay();},disabled:!!R||U.problem==="sentUnconfirmed"}:Ze={label:n.pay.connect,run:Bt};let Zt=N.step==="switching"?"switch":N.step==="signing"?"proof":U.status==="switching"?"switch":U.status==="submitting"||t.phase==="submitting"?"submitting":U.status==="wallet"?L==="transfer"?"confirm":"sign":null,Nn=e.invoice.number??e.invoice.id,Je=s??U.askedWallet,qa={wallet:Je?.name??"",invoice:Nn,merchant:E};return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:fe,inert:Pe,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",Pe&&"novapay:hidden"),children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-3 novapay:px-5 novapay:py-4",Qt&&"novapay-page-screen novapay-page-pay"),children:[jsx("h2",{...St,className:"novapay:sr-only",children:n.pay.title}),s&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:h-7 novapay:w-7 novapay:shrink-0",children:jsx(_n,{walletId:s.walletId,icon:s.icon})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:s.name}),jsx("span",{className:cn$1(q,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(s.address),network:ye(s.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:Bt,className:nn,children:n.pay.change})]}),lt&&Cn&&!ke&&jsxs("div",{role:"status",className:cn$1(ta,"novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(ut,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsxs("span",{children:[jsx("strong",{className:"novapay:block",children:n.pay.wrongNetwork}),c(n.pay.wrongNetworkText,{current:ye(s.chainId),network:B})," ",n.pay.switchHint]})]}),_t&&!ke&&jsxs("div",{className:"novapay:flex novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-xs",children:[jsx(Xo,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]"}),jsxs("span",{className:"novapay:flex novapay:flex-col novapay:gap-0.5",children:[jsx("strong",{children:_t.title}),jsx("span",{children:_t.text}),_t.hint&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:_t.hint})]})]}),jsxs("div",{children:[jsx("span",{className:cn$1(De,"novapay:block"),children:ct?n.pay.youSendRest:n.pay.youSend}),jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:gap-2",Qt&&"novapay-page-amount-row"),children:[jsx("span",{className:cn$1(q,"novapay:text-[28px] novapay:font-bold novapay:leading-tight",Qt&&"novapay-page-amount"),children:le(Y.send,d.decimals,o)}),jsx("span",{className:cn$1(q,"novapay:text-sm novapay:font-semibold"),children:d.instructions.symbol}),jsx(Mn,{text:ma(Y.send,d.decimals),label:n.pay.copyAmount,copiedLabel:n.pay.copied})]}),jsxs("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[c(n.pay.onNetwork,{network:B}),gt&&!Y.fee&&!ct&&jsxs(Fragment$1,{children:[" \xB7 ",c(n.pay.fiatValue,{amount:gt,currency:e.invoice.currency})]})]})]}),Y.fee&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsxs(xe,{children:[jsx(W,{name:ct?n.pay.invoiceRest:n.pay.invoiceTotal,children:le(Y.receives,d.decimals,o)}),jsx(W,{name:c(n.pay.transferFee,{percent:Y.fee.percent}),children:le(Y.fee.amount,d.decimals,o)}),jsx(W,{name:c(n.pay.merchantReceives,{merchant:E}),children:O(Y.receives)})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.pay.transferFeeNote})]}),!ke&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2 novapay:text-xs",children:[jsx(on,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:text-[var(--tuwa-text-secondary)]"}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:flex-1",children:c(At?n.pay.restTimeLeft:n.pay.priceLocked,{time:at(we)})}),!ct&&jsx(yt,{disabled:zt,onClick:Yt,children:n.pay.refreshPrice})]}),Wa&&!At&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-text-accent)] novapay:px-3 novapay:py-2",children:[jsx("span",{"aria-hidden":true,className:"novapay:text-xs",children:c(n.pay.priceEnding,{time:at(we)})}),jsx("span",{role:"status",className:"novapay:sr-only",children:c(n.pay.priceEnding,{time:at(Za)})}),jsx("button",{type:"button",onClick:Yt,disabled:zt,className:Qo,children:jsx(Ce,{label:n.pay.keepPrice,values:{minutes:Math.round(e.quoteTtlSeconds/60)}})})]}),ke&&jsx(Q,{children:n.pay.priceExpired}),At&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:At}),R&&!ke&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-xs",children:[jsxs("div",{role:"alert",children:[jsx("strong",{className:"novapay:block",children:n.pay.notEnough}),c(n.pay.walletHas,{amount:O(R.have),network:B}),"."," ",c(n.pay.shortBy,{short:O(R.short),need:O(R.need)})]}),z.length>0&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:n.pay.payFromBalance}),z.map(({method:Be,balance:Yn})=>jsxs("button",{type:"button",onClick:()=>{let Ua=s?We(s,Be):null;a.getState().selectMethod(Be.id),a.getState().setPayer(Ua),y();},className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-transparent novapay:px-2.5 novapay:py-1.5 novapay:text-left novapay:text-xs novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-bg-muted)]",oe),children:[jsxs("span",{className:"novapay:font-semibold",children:[Be.symbol," \xB7 ",ye(Be.chainId)]}),jsx("span",{className:cn$1(q,"novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.youHave,{amount:`${le(String(Yn),Be.decimals,o)} ${Be.symbol}`})})]},Be.id))]}),e.merchant.fundingUrl&&jsxs("span",{children:[c(n.pay.topUp,{symbol:d.instructions.symbol})," ",jsxs("a",{href:e.merchant.fundingUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",oe),children:[c(n.pay.getToken,{symbol:d.instructions.symbol})," \u2197"]})]})]}),jsxs(xe,{children:[zn!==null&&jsx(W,{name:n.pay.rate,children:c(n.pay.rateValue,{symbol:d.instructions.symbol,price:ju(zn,o),currency:e.invoice.currency})}),jsx(W,{name:n.pay.networkFee,children:jsxs("span",{className:"novapay:inline-flex novapay:flex-col novapay:items-end novapay:gap-0.5",children:[L!=="transfer"?jsx("span",{className:"novapay:text-[var(--tuwa-success-text)]",children:c(n.pay.merchantPaysGas,{merchant:E})}):jt?c(n.pay.gasEstimate,{amount:`${jt} ${K?.symbol}`}):n.pay.gasFromWallet,d.gasless&&jsx(yt,{onClick:()=>x(!w),children:w?c(n.pay.payGasless,{merchant:E}):n.pay.payWithGas})]})}),jsxs(W,{name:n.pay.to,children:[jsx(qe,{hash:d.instructions.to,chainId:k}),jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:E})]})]}),Mt&&!ke&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.payNote}),Sn&&jsx(Q,{children:Sn}),Pn&&jsx(Q,{children:Pn}),!U.problem&&jsx(ca,{error:Ft}),ie&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(te,{children:[jsx(X,{busy:Qn,disabled:Ze.disabled,onClick:Ze.run,children:Ze.label}),jsx(re,{disabled:zt,onClick:l,children:ct?n.pay.backFromRest:n.pay.back}),jsx(Ue,{children:Zu(c(n.pay.disclaimer,{merchant:E}),...wr(e)?[c(n.pay.disclaimerScreening,{merchant:E})]:[])})]})]}),Zt==="proof"&&jsx(Wn,{kind:"proof",walletName:Je?.name??"",walletId:Je?.walletId??"",walletIcon:Je?.icon,amount:ce,merchant:E,network:B,to:shortAddress(d.instructions.to),priceTime:null,text:c(wa(s)?n.payerProof.promptPasskey:n.payerProof.promptText,qa),details:[...N.request?[{name:n.payerProof.site,value:N.request.domain}]:[],{name:n.payerProof.invoice,value:Nn},{name:n.payerProof.merchant,value:E}],hint:N.request?c(n.payerProof.signInRequest,{wallet:Je?.name??"",site:N.request.domain}):void 0,onRetry:()=>{N.confirm();},onCancel:N.dismiss,stepHeight:Te}),Zt&&Zt!=="proof"&&jsx(Wn,{kind:Zt,walletName:Je?.name??"",walletId:Je?.walletId??"",walletIcon:Je?.icon,amount:ce,merchant:E,network:B,to:shortAddress(d.instructions.to),priceTime:ke?null:at(we),onRetry:L==="relay"?()=>{U.pay();}:void 0,onCancel:N.step==="switching"?N.dismiss:U.dismiss,stepHeight:Te})]})}var Po=4;function Qi(e){let{size:t,data:a}=encode(e,{ecc:"M",border:0}),n="";return a.forEach((o,r)=>o.forEach((s,i)=>{s&&(n+=`M${i+Po} ${r+Po}h1v1h-1z`);})),{size:t+Po*2,path:n}}function To({value:e,label:t,className:a}){let n=A(),o=cn$1(a,Z(n,"qrCode")),{size:r,path:s}=useMemo(()=>Qi(e),[e]),i=n.customization.components?.QrCode;return i?jsx(i,{value:e,label:t,className:o}):jsxs("svg",{role:"img","aria-label":t,viewBox:`0 0 ${r} ${r}`,shapeRendering:"crispEdges",className:cn$1("novapay:block novapay:rounded-[var(--tuwa-rounded-corners)]",o),children:[jsx("rect",{width:r,height:r,fill:"#ffffff"}),jsx("path",{d:s,fill:"#111827"})]})}function am({payUrl:e}){let{labels:t,backToMethods:a,display:n}=A();return jsxs(Fragment$1,{children:[jsx(he,{title:t.qr.handoffTitle,subtitle:t.qr.handoffHint,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-3 novapay:py-2",children:[jsx(To,{value:e,label:t.qr.handoffCode,className:cn$1("novapay:h-48 novapay:w-48",n==="page"&&"novapay-page-qr-handoff")}),jsx(Mn,{text:e,label:t.qr.copyLink,copiedLabel:t.pay.copied,children:t.qr.copyLink}),jsx("p",{className:"novapay:m-0 novapay:max-w-xs novapay:text-center novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:t.qr.handoffNote})]})}),jsx(te,{children:jsx(re,{onClick:a,children:t.qr.back})})]})}function Yi(){let e=A(),{checkout:t,state:a,store:n,labels:o,locale:r,now:s,payUrl:i,backToMethods:c$1}=e,l=a.quote;if(!t)return null;if(!l||l.instructions.family!=="solana")return i?jsx(am,{payUrl:i}):null;let{instructions:p}=l,m=ye(ve(p)),y=`${le(l.amountToSend,l.decimals,r)} ${p.symbol}`,f=l.expiresAt?Date.parse(l.expiresAt)-s:Number.POSITIVE_INFINITY,v=f<=0,d=a.phase==="quoting",I=(a.invoiceStatus??t.invoice.status)==="underpaid",h=I?sn(l,s,o,t.merchant.name,r):null,b=I?t.invoice.originWallet:null,g=b?c(o.qr.restHint,{wallet:shortAddress(Tt(b))}):o.qr.solanaHint;return jsxs(Fragment$1,{children:[jsxs(he,{title:o.qr.solanaTitle,subtitle:g,children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-4 novapay:@min-[440px]:flex-row novapay:@min-[440px]:items-start",children:[jsx(To,{value:p.solanaPayUrl,label:c(o.qr.solanaCode,{amount:y}),className:cn$1("novapay:h-44 novapay:w-44 novapay:shrink-0",e.display==="page"&&"novapay-page-qr",v&&"novapay:opacity-30")}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2 novapay:self-stretch novapay:text-xs novapay:@min-[440px]:self-auto",children:[jsxs("ol",{className:"novapay:m-0 novapay:flex novapay:list-decimal novapay:flex-col novapay:gap-1 novapay:pl-4",children:[jsx("li",{children:o.qr.scanStep}),jsx("li",{children:o.qr.approveStep})]}),I&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:o.pay.youSendRest}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn$1(q,"novapay:text-2xl novapay:font-bold"),children:le(l.amountToSend,l.decimals,r)}),jsx(Mn,{text:ma(l.amountToSend,l.decimals),label:o.pay.copyAmount,copiedLabel:o.pay.copied})]}),jsxs("div",{"data-qr-line":true,className:cn$1(q,"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-x-1 novapay:gap-y-0.5 novapay:text-[var(--tuwa-text-secondary)]"),children:[jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[p.symbol," \xB7"]}),jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[m," \xB7"]}),jsx("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:jsx(qe,{hash:p.to,chainId:ve(p)})})]}),!v&&jsxs(Fragment$1,{children:[jsxs("span",{role:"status",className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(QuasarLoader,{size:14,accent:"var(--tuwa-pending-icon)"}),o.qr.waiting]}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(h?o.pay.restTimeLeft:o.pay.priceLocked,{time:at(f)})})]})]})]}),v&&jsx(Q,{children:o.pay.priceExpired}),h&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:h}),jsxs("p",{className:cn$1(ta,"novapay:m-0 novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(ut,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),o.qr.exchangeWarning]})]}),jsxs(te,{children:[v?jsx(X,{busy:d,onClick:()=>{n.getState().requestQuote();},children:I?o.outcome.payRest:o.pay.newPrice}):jsx("a",{href:p.solanaPayUrl,className:cn$1(Pt,Z(e,"primaryButton")),children:o.qr.openInWallet}),jsx(re,{onClick:c$1,children:I?o.pay.backFromRest:o.qr.back})]})]})}function Ro(e){switch(e){case "confirm":return "pending";case "unconfirmed":case "underpaid":return "warning";case "paid":return "success";case "failed":case "blocked":case "error":return "error";case "held":case "refunded":case "expired":case "cancelled":case "replaced":return "neutral";default:return null}}function dm(){let{labels:e}=A();return jsxs("div",{role:"status",className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:p-8 novapay:text-sm novapay:text-[var(--tuwa-text-secondary)]",children:[jsx(QuasarLoader,{size:48}),e.common.loading]})}function ym(){let{labels:e,state:t,store:a}=A(),n=t.error?.code==="checkout_not_found";return jsxs("div",{role:"alert",className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:p-8 novapay:text-center",children:[jsx(ut,{"aria-hidden":true,className:"novapay:h-7 novapay:w-7 novapay:text-[var(--tuwa-error-icon)]"}),jsx("h2",{...St,className:et,children:e.error.title}),jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-[13px] novapay:text-[var(--tuwa-text-secondary)]",children:n?e.error.notFound:e.error.generic}),!n&&jsx(re,{onClick:()=>{a.getState().load();},className:"novapay:w-auto novapay:px-6",children:e.common.retry})]})}var fm=new Set(["paid","partially_refunded","refunded"]);function Zi(){let{screen:e,customization:t}=A(),a=t.components?.screens?.[e];return a?jsx(a,{screen:e}):e==="loading"?jsx(dm,{}):e==="error"?jsx(ym,{}):e==="buyer"?jsx(Vr,{}):e==="method"?jsx(oi,{}):e==="confirmWallet"?jsx(Hs,{}):e==="pay"?jsx(zi,{}):e==="qr"?jsx(Yi,{}):e==="confirm"?jsx(_s,{}):e==="failed"?jsx(Ys,{}):e==="paid"?jsx(ui,{}):jsx(Qs,{kind:e})}function vm({className:e,withDetails:t,leave:a}){let n=A(),{checkout:o,locale:r,labels:s,now:i,customization:c$1,display:l}=n,{Header:p=ls,Summary:m=as,CompactSummary:y=os}=c$1.components??{},f=c$1.config?.deadlineAnnouncements,{screen:v}=n,d=useRef(null),I=useRef(v);useEffect(()=>{let _=I.current;I.current=v;let K=d.current;if(!K||_===v||_==="loading")return;let U=K.ownerDocument.activeElement;if(U&&U!==K.ownerDocument.body&&!K.contains(U))return;let N=K.querySelector("[data-novapay-scroll] [data-novapay-heading]");if(l!=="page")return N?.focus();K.getBoundingClientRect().top<0&&K.scrollIntoView({block:"start"}),N?.focus({preventScroll:true});},[v,l]);let[h,b]=useState(""),g=useRef(null),k=o?.invoice.dueAt?Date.parse(o.invoice.dueAt):null,P=o?En(o.invoice.status,v,o.invoice.restPayable)==="paying":false;useEffect(()=>{if(k===null)return;let _=k-i,K=hr(g.current,_,f);g.current=_,K!==null&&P&&b(K===1?s.summary.oneMinuteLeft:c(s.summary.minutesLeft,{minutes:K}));},[k,i,s,f,P]);let w=l==="page",x=jo[w?"page":"default"],C=Ro(v),L=c$1.components?.StatusEdge??StatusEdge;return jsxs("div",{ref:d,lang:r,className:cn$1(x.frame,na(l).frame,e),children:[o&&jsx("aside",{inert:!!a,className:cn$1(x.aside,Z(n,"summary")),children:jsx(m,{})}),jsxs("div",{inert:!!a,className:cn$1("novapay:relative",x.main),children:[C&&jsx(L,{tone:C,className:cn$1("novapay:z-20",Z(n,"statusEdge",{tone:C}))}),jsxs(qi,{active:!!C&&!w&&!c$1.config?.animation?.disabled,children:[jsx(p,{withDetails:t}),jsxs("div",{className:"novapay:sm:hidden",children:[o&&jsx(y,{className:Z(n,"compactSummary")}),jsx(ps,{withDetails:t})]}),jsx("div",{"data-novapay-scroll":"",className:cn$1(x.area,Z(n,"body")),children:w?jsx("div",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",!c$1.config?.animation?.disabled&&"novapay-page-fade"),children:jsx(Zi,{})},C?"status":v):jsx(Zi,{})})]})]}),jsx("div",{role:"status","aria-live":"polite",className:"novapay:sr-only",children:h}),a&&jsx(Xs,{onStay:a.onStay,onLeave:a.onLeave})]})}function vw({token:e,display:t="modal",open:a=true,onOpenChange:n,onClose:o,baseUrl:r,api:s,EventSource:i,pollMs:c$1,payUrl:l,onConnectWallet:p,onPaid:m,autoReturnSeconds:y,onContact:f$1,locale:v,className:d,customization:I}){let h=it(),[b,g$1]=useState({from:e,token:e}),k=b.from===e?b.token:e,[P,w]=useState(t!=="modal"||a);!P&&(t!=="modal"||a)&&w(true);let x=yi({token:k,baseUrl:r??h.baseUrl,api:s,EventSource:i,pollMs:c$1,enabled:P}),C=fi(x,ae=>ae),L=C.checkout,_=f(v),[K,U]=useState(null),N=Tr({picked:K,page:_,invoice:C.locale??L?.invoice.locale}),se=Vn(N),R=!!L&&P&&_r(C.phase,y,g(N)),z=bi(1e3,R)-(C.clockSkewMs??0),ie=Na(),ge=La(p),Pe=h.adapters,[fe,Te]=useState("wallet"),[E,B]=useState(false),[O,Y]=useState(null);L&&O?.store!==x&&Y({store:x,paid:fm.has(L.invoice.status)});let[be,ce]=useState(false),[we,ke]=useState(false),[Wa,zt]=useState(k);Wa!==k&&(zt(k),B(false),Te("wallet"),ke(false));let zn=C.payerProof==="confirmed"&&!!C.error,ct=C.error?.code==="payer_mismatch";we&&(C.phase==="awaitingPayment"||zn||ct)&&ke(false);let Qt=(C.invoiceStatus??L?.invoice.status)==="underpaid"?L?.invoice.originWallet??null:null,jt=ae=>!Qt||cn(ae,Qt),At=L?.methods.find(ae=>ae.id===C.methodId),gt=At?We(ie,At):null,Cn=gr({open:we,storePayer:C.payer,payer:gt,paysRest:!gt||jt(gt)});Cn==="leave"&&ke(false);let lt=useRef(null),[Qn,_t]=useState(false);!Qn&&L&&g(N)&&_t(true);let Yt={payWith:fe,handoff:E,confirmWallet:we,labelsReady:Qn||!L},jn=Ya(C,Yt),[Mt,Sn]=useState(null),[Ft,Pn]=useState(null);jn==="confirm"?Mt!==x&&Sn(x):Mt===x&&(Sn(null),C.error?.code==="payment_failed"&&Pn(C.error));let bt=Ft!==null&&C.error===Ft?Ya(C,{...Yt,afterFailure:true}):jn,Bt=async()=>{await Ds(x,ke);},Ze=hi(x),Zt=Fi({store:x,screen:bt}),[Nn,Je]=useState(null),qa=Mi({store:x,state:C,walletTxKey:Nn?.store===x?Nn.txKey:null});ci(C.phase,L?.invoice,m,O?.store===x&&O.paid),mi({state:C,screen:bt,now:z,locale:L||_?N:null,handlers:I?.handlers});let Be=ae=>Pe?.find(Ge=>Ge.family===ae),Yn=Ai({store:x,adapterFor:Be,pulsar:h.pulsar,labels:se,locale:N}),Ua=useCallback(ae=>{Je({store:x,txKey:ae.txKey}),Yn(ae);},[x,Yn]),yc=useEffectEvent(()=>{if(!L)return;let{quote:ae,phase:Ge}=x.getState();if(ie&&lt.current){let Jn=L.methods.find(wc=>wc.id===lt.current),Ga=Jn?We(ie,Jn):null;if(!Ga)return;lt.current=null,x.getState().setPayer(Ga),jt(Ga)&&Bt();return}if(Ge==="selectMethod"||Ge==="underpaid"||Ge==="blocked"){if(C.payer===null||gt===C.payer)return;x.getState().setPayer(gt),Cn==="follow"&&Bt();return}if(!ie)return;let Tn=L.methods.find(Jn=>Jn.id===ae?.methodId),Zn=Tn?We(ie,Tn):null,Bo=xr({phase:Ge,quotePayer:ae?.payer,payer:Zn});if(Bo==="release")return x.getState().releaseQuote();Bo==="keep"||!Zn||(x.getState().setPayer(Zn),jt(Zn)&&Bt());}),fc=C.quote?.payer,vc=!!L;useEffect(()=>yc(),[ie?.address,ie?.chainId,ie?.connectorType,C.phase,fc,vc]),useEffect(()=>{ge.connecting||(lt.current=null);},[ge.connecting]);let[_o,hc]=useState(false);bt==="buyer"&&!_o&&hc(true);let Ha=useMemo(()=>t==="modal"?()=>{n?.(false),o?.();}:o,[t,n,o]),xc=Ha&&(()=>Xa(x.getState().phase,x.getState().error,x.getState().invoiceStatus)&&!Ea(x)?ce(true):Ha()),gc=be?{onStay:()=>ce(false),onLeave:()=>{ce(false),x.getState().releaseQuote(),Ha?.();}}:null,Mo=I??{},bc={store:x,state:C,checkout:L,screen:bt,locale:N,labels:se,setLocale:async ae=>{let Ge=K;U({locale:ae,page:_}),await x.getState().setLocale(ae)||U(Ge);},now:z,handedOverAt:Ze,qrShown:Zt,paymentSent:qa||Ea(x),close:xc,wallet:ie,payWith:fe,setPayWith:Te,payUrl:l,connectWallet:ae=>{let Ge=Ve(ae);lt.current=ae.id;let Tn=Ge!==null&&ge.connect(Ge);return Tn||(lt.current=null),Tn},connectFamily:ae=>ge.connect(ae),openedPaid:O?.store===x&&O.paid,adapterFor:Be,handoff:E,setHandoff:B,backToMethods:()=>{B(false),ke(false),x.getState().releaseQuote();},payAfterFailure:()=>{Pn(null),x.getState().clearError();},confirmWallet:we,setConfirmWallet:ke,lockPrice:Bt,onPaymentSent:Ua,openInvoice:ae=>g$1({from:e,token:ae}),onContact:f$1,autoReturnSeconds:y??(t==="modal"?0:5),display:t,customization:Mo},$a=cn$1(d,Z({customization:Mo,screen:bt,state:C,checkout:L},"container")),Ka=jsx(Uo,{value:bc,children:jsx(MotionConfig,{reducedMotion:I?.config?.animation?.disabled?"always":"user",children:jsx(vm,{withDetails:_o,leave:gc,className:t==="modal"?$a:void 0})})});if(t==="modal")return jsx(Dialog,{open:a,onOpenChange:ae=>{if(!ae&&be)return ce(false);if(!ae&&Xa(x.getState().phase,x.getState().error,x.getState().invoiceStatus)&&!Ea(x))return ce(true);n?.(ae),ae||o?.();},children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-auto",animateHeight:Ro(bt)===null,children:[jsx(DialogTitle,{className:"novapay:sr-only",children:c(se.common.dialogTitle,{merchant:L?.merchant.name??""})}),Ka]})});let Fo=c(se.common.dialogTitle,{merchant:L?.merchant.name??""});return t==="page"?jsx(hm,{label:Fo,className:$a,children:Ka}):jsx("section",{"aria-label":Fo,className:cn$1("novapay:overflow-hidden novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)]",na(t).section,$a),children:Ka})}function hm({label:e,className:t,children:a}){return jsx("div",{className:"novapay-page",children:jsx("section",{"aria-label":e,className:cn$1(na("page").section,"novapay-page-block",t),children:a})})}function Ji(e){if(!e.to)return null;let t=parseCaip19AssetId(e.assetId),a={to:e.to,token:!t||t.assetNamespace==="slip44"?"native":t.assetReference,amount:e.amount,decimals:e.decimals,symbol:e.symbol},n=rn(e.chainId);if(n==="solana")return {family:n,chainId:e.chainId,...a,reference:"",solanaPayUrl:""};let o=n==="eip155"?toEvmChainId(e.chainId):void 0;return o===void 0?null:{family:"eip155",chainId:o,...a}}function ec(e){let t=b$1(e);return t==="switchFailed"?"wrongNetwork":t==="notAuthorized"||t==="alreadyPending"||t==="sentUnconfirmed"?"failed":t}var Lo=new WeakMap,wn=new WeakMap;function tc({store:e,invoiceId:t,invoice:a,params:n,open:o,labels:r,locale:s,onConnectWallet:i}){let c$1=useStore(e),{adapters:l,pulsar:p}=it(),m=Na(),y=La(i),[f,v]=useState("idle"),[d,I]=useState(null),[,h]=useState(0),b=wn.has(e),g=useRef(0),k=useRef(o),P=c$1.sentTransaction?.txHash??c$1.refund?.txHash??null,w=c$1.instructions?Ji(c$1.instructions):null,x=w?.family??null,C=w?ve(w):c$1.instructions?.chainId??null,L=l?.find(O=>O.family===x),_=m&&m.family===x?m:null,K=C?ye(C):"",U=d&&d.account===_?.address?d.problem:null,N=O=>I(O?{problem:O,account:_?.address}:null),se=!!(_&&x==="eip155"&&C&&_.chainId!==C),R=c$1.instructions,H=R?`${le(R.amount,R.decimals,s)} ${R.symbol}`:"",z=Aa(w&&_&&L?`balance|${C}|${_.address}|${w.token}`:null,()=>L.getBalance({chainId:C,account:_.address,token:w.token}),c$1.refund?.id),ie=gn(w&&_&&L?.estimateFee?`fee|${C}|${_.address}|${w.token}`:null,()=>L.estimateFee({instructions:w,account:_.address}));useEffect(()=>{!n||Lo.get(e)===t||e.getState().phase!=="idle"||(Lo.set(e,t),e.getState().start(t,n));},[n,e,t]),useEffect(()=>{o&&!k.current&&!n&&e.getState().phase==="confirmed"&&e.getState().reset(),k.current=o;},[o,n,e]),useEffect(()=>(e.getState().keepFollowing(),()=>e.getState().stopFollowing()),[e]),useEffect(()=>{let O=true;return wn.get(e)?.settled.then(()=>{O&&h(Y=>Y+1);}),()=>{O=false;}},[e]);let ge=async(O,Y,be)=>{if(!p||!L?.pulsarTransaction||!c$1.refund)return;let ce={invoice:a??t,amount:H};try{await p.injectExternalPendingTxs([L.pulsarTransaction({txKey:O,instructions:be,account:Y.address,connectorType:Y.connectorType,title:c(r.refund.txTitle,ce),description:c(c$1.refund.heldTransfer?r.refund.txDescriptionSender:r.refund.txDescription,ce),payload:{quasarRefund:c$1.refund.id}})]);}catch{}},Pe=async()=>{if(N(null),!(!se||!L?.switchChain))try{v("switching"),await L.switchChain(C);}catch(O){N(ec(O));}finally{v("idle");}},fe=async()=>{if(N(null),!w)return N("noRecipient");if(!_||!L)return N("unsupported");if(c$1.sentTransaction){await e.getState().submit(c$1.sentTransaction);return}let O=BigInt(w.amount)+(w.token==="native"&&ie?ie.amount:0n);if(typeof z=="bigint"&&z<O)return N("notEnough");if(x&&w.to&&isSameAddress(x,_.address,w.to))return N("fromBuyer");if(!await e.getState().recheck()){let ce=e.getState(),we=ce.error?.code==="refund_repriced";ce.phase==="awaitingTransfer"&&!ce.sentTransaction&&!we&&N("unreachable");return}let Y=++g.current,be=()=>g.current===Y;try{se&&L.switchChain&&(v("switching"),await L.switchChain(C)),be()&&v("wallet");let ce=await L.sendTransfer({instructions:w,account:_.address,connection:_.connection});be()?v("idle"):I(null),ge(ce,_,w),await e.getState().submit({txHash:ce,from:_.address});}catch(ce){be()?(v("idle"),N(ec(ce))):I(null);}},Te=async()=>{if(wn.has(e))return;let O,Y={settled:new Promise(we=>O=we)},be=()=>{wn.get(e)===Y&&wn.delete(e),O(),h(we=>we+1);},ce=setTimeout(be,6e5);wn.set(e,Y),h(we=>we+1);try{await fe();}finally{clearTimeout(ce),be();}},E=f!=="idle"?f:_?"confirm":"connect";return {step:c$1.phase==="idle"?n&&!c$1.error&&Lo.get(e)!==t?"requesting":"amount":c$1.phase==="awaitingTransfer"?E:c$1.phase,phase:c$1.phase,refund:c$1.refund,error:c$1.error,transfer:w,chainId:C,network:K,amount:H,wallet:_,wrongNetwork:se,balance:z,fee:ie,problem:U??(c$1.instructions&&!w?"noRecipient":null),txKey:P,transactionUrl:O=>C?L?.explorerUrl?.({chainId:C,txKey:O}):void 0,addressUrl:O=>C?L?.explorerAddressUrl?.({chainId:C,address:O}):void 0,canConnect:y.canConnect,connecting:y.connecting,preview:async O=>{let Y=await e.getState().preview(t,O);return Y||(e.getState().error?"refused":null)},start:async O=>{N(null),await e.getState().start(t,O);},connect:()=>{x&&y.connect(x);},switchNetwork:Pe,send:Te,dismiss:()=>{g.current++,v("idle"),N("stillInWallet");},sending:b}}function Qw({label:e,className:t,disabled:a,...n}){let[o,r]=useState(false),s=Vn(n.locale??"en");return jsxs(Fragment$1,{children:[jsx("button",{type:"button",disabled:a,onClick:()=>r(true),className:cn$1(Pt,"novapay:w-auto novapay:px-4",t),children:e??s.refund.button}),jsx(Im,{...n,open:o,onOpenChange:r})]})}function Im({open:e,onOpenChange:t,locale:a="en",onRefunded:n,...o}){let r=Vn(a),s=tc({store:o.store,invoiceId:o.invoiceId,invoice:o.invoice,params:e?o.params:void 0,open:e,labels:r,locale:a,onConnectWallet:o.onConnectWallet}),i=useEffectEvent(p=>n?.(p)),c$1=s.phase==="confirmed"?s.refund:null;useEffect(()=>{c$1&&i(c$1);},[c$1]);let l=o.invoice?c(r.refund.title,{invoice:o.invoice}):r.refund.button;return jsx(Dialog,{open:e,onOpenChange:t,children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-[440px]",children:[jsxs("div",{className:"novapay:flex novapay:items-center novapay:justify-between novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:px-5 novapay:py-3",children:[jsx(DialogTitle,{className:cn$1(q,"novapay:m-0 novapay:truncate novapay:text-sm novapay:font-bold"),children:l}),jsx("button",{type:"button","aria-label":r.refund.close,onClick:()=>t(false),className:Ct,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]}),jsx(Rm,{flow:s,labels:r,locale:a,close:()=>t(false),...o})]})})}function Rm({flow:e,labels:t,locale:a,close:n,currency:o="USD",refundable:r,details:s,onRecord:i}){let c$1=t.refund,l={network:e.network,symbol:e.transfer?.symbol??e.refund?.assetId??"",amount:e.amount,wallet:e.wallet?.name??""},p=e.refund?.txHash??e.txKey,m=i&&jsxs(Fragment$1,{children:[jsx(re,{onClick:i,children:c$1.record}),jsx(Ue,{children:c$1.recordHint})]});switch(e.step){case "amount":return jsx(Dm,{flow:e,labels:t,locale:a,currency:o,refundable:r});case "requesting":case "submitting":return jsx(sc,{children:e.step==="requesting"?c$1.requesting:c$1.submitting});case "switching":case "wallet":return jsxs(Fragment$1,{children:[jsxs(sc,{walletId:e.wallet?.walletId,walletIcon:e.wallet?.icon,children:[jsx("strong",{className:cn$1(q,"novapay:text-sm"),children:c(e.step==="switching"?c$1.switchTitle:c$1.walletTitle,l)}),e.step==="wallet"&&jsx("span",{children:c(c$1.walletText,l)})]}),jsx(te,{children:jsx(re,{onClick:e.dismiss,children:t.walletPrompt.cancel})})]});case "connect":return jsxs(Fragment$1,{children:[jsxs(he,{title:c$1.connectTitle,subtitle:c(c$1.connectText,l),children:[e.problem==="noRecipient"&&jsx(Q,{children:c$1.noRecipient}),!e.canConnect&&jsx(Q,{children:c$1.connectUnavailable})]}),jsxs(te,{children:[e.canConnect&&e.problem!=="noRecipient"&&jsx(X,{busy:e.connecting,onClick:e.connect,children:c$1.connect}),m]})]});case "confirm":return jsx(Om,{flow:e,labels:t,locale:a,values:l,details:s?.confirm,recordAction:m});case "confirming":return jsxs(Fragment$1,{children:[jsxs(he,{title:c$1.onItsWay,children:[jsxs(xe,{children:[jsx(W,{name:c$1.status,children:c$1.pending}),p&&jsx(W,{name:c$1.transaction,children:jsx(qe,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),jsx(W,{name:c$1.network,children:c(c$1.waiting,l)})]}),rc(e.refund)&&jsx(Ue,{children:c$1.slowNote})]}),jsxs(te,{children:[jsx(re,{onClick:n,children:c$1.close}),rc(e.refund)?m:jsx(Ue,{children:c$1.canClose})]})]});case "confirmed":return jsxs(Fragment$1,{children:[jsx(he,{title:c$1.refunded,children:jsxs(xe,{children:[e.refund?.creditNoteNumber&&jsx(W,{name:c$1.creditNote,children:e.refund.creditNoteNumber}),p&&jsx(W,{name:c$1.transaction,children:jsx(qe,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),s?.done]})}),jsx(te,{children:jsx(X,{onClick:n,children:c$1.done})})]});case "failed":return jsx(Bm,{flow:e,labels:t,locale:a,values:l,recordAction:m,close:n})}}var Em={amount_short:"failedShort",over_limit:"failedByHand",tx_of_another_refund:"failedByHand",refund_from_buyer:"failedFromBuyer",transaction_failed:"failedNotFound",dropped:"failedDropped",too_early:"failedTooEarly",no_matching_transfer:"failedNoTransfer",withdrawn:"failedWithdrawn",cancelled:"failedCancelling",cancelled_final:"failedCancelled",resend_confirmed:"failedResendConfirmed"},ac=(e,t,a)=>{let n=e?.failureReason?Em[e.failureReason]:void 0;return n?t[n]:c(t.failedText,a)},Lm={withdrawn:"failedWithdrawnTitle",cancelled:"failedCancelledTitle",cancelled_final:"failedCancelledTitle"},oc=(e,t)=>t[e?.failureReason&&Lm[e.failureReason]||"failedTitle"],Am={refund_repriced:"movedTitle",request_failed:"unreachable",amount_exceeds_refundable:"refusedAmount",invoice_not_refundable:"refusedNotRefundable",payment_unknown:"refusedNotRefundable",held_transfer_not_refundable:"refusedNotRefundable",held_refund_must_be_whole:"refusedWhole",sender_blocked:"refusedBlocked",refund_not_waiting:"refusedNotWaiting",refund_may_have_landed:"refusedMayHaveLanded",refund_from_buyer:"failedFromBuyer",method_not_priced:"refusedPrice",price_no_rpc:"refusedPrice",price_unavailable:"refusedPrice",mainnet_disabled_on_node:"refusedTestOnly"},_m=600*1e3,rc=e=>{let t=e?.updatedAt??e?.createdAt;return !!t&&Date.now()-Date.parse(t)>_m},Da=(e,t)=>e.text??t[Am[e.code]??"refusedOther"],Mm=e=>e?.failureReason==="over_limit"||e?.failureReason==="tx_of_another_refund",Fm=e=>{let t=e.mode==="fiat_value"||e.failureReason==="amount_short";return {mode:t?"fiat_value":e.mode,...t&&{amount:e.amount},...e.reason&&{reason:e.reason}}};function lc(e){let[t,a]=useState(false),[n,o]=useState(null),r=useRef(false);return useEffect(()=>(r.current=false,()=>{r.current=true;}),[]),{ask:async(i,c)=>{if(i?.mode==="fiat_value"){a(true);let l=await e.preview(i);if(r.current||(a(false),l==="refused"))return;if(l&&Ar(c?{cryptoAmount:l.cryptoAmount,atPaymentRate:c.cryptoAmount}:l))return o({preview:l,request:i})}o(null),e.start(i);},checking:t,moved:n,back:()=>o(null)}}function pc({preview:e,request:t},a,n,o,r,s){let i=o.refund,c$1=l=>`${le(l,e.decimals,r)} ${e.symbol}`;return jsxs(Fragment$1,{children:[jsxs(he,{title:i.movedTitle,children:[jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(i.movedText,{symbol:e.symbol})}),jsxs(xe,{children:[jsx(W,{name:i.movedSend,children:c$1(e.cryptoAmount)}),e.atPaymentRate&&jsx(W,{name:i.movedAtPayment,children:c$1(e.atPaymentRate)}),e.received&&jsx(W,{name:i.movedReceived,children:c$1(e.received)})]}),s&&e.exactPossible&&jsx(Ue,{children:c(i.movedExact,{exact:i.modeExact})}),n.error&&jsx(Q,{children:Da(n.error,i)})]}),jsxs(te,{children:[jsx(X,{busy:a.checking,onClick:()=>{a.ask(t,e);},children:i.movedContinue}),jsx(re,{disabled:a.checking,onClick:a.back,children:i.movedBack})]})]})}function Bm({flow:e,labels:t,locale:a,values:n,recordAction:o,close:r}){let s=t.refund,i=lc(e);return e.refund?.heldTransfer?jsxs(Fragment$1,{children:[jsxs(he,{title:oc(e.refund,s),children:[jsx(Q,{children:ac(e.refund,s,n)}),jsx(Ue,{children:s.failedHeldNote})]}),jsx(te,{children:jsx(X,{onClick:r,children:s.close})})]}):i.moved?pc(i.moved,i,e,t,a,false):jsxs(Fragment$1,{children:[jsxs(he,{title:oc(e.refund,s),children:[jsx(Q,{children:ac(e.refund,s,n)}),e.error&&jsx(Q,{children:Da(e.error,s)})]}),jsxs(te,{children:[Mm(e.refund)?jsx(X,{onClick:r,children:s.close}):jsx(X,{busy:i.checking,onClick:()=>e.refund&&void i.ask(Fm(e.refund)),children:s.sendRefund}),o]})]})}function sc({walletId:e,walletIcon:t,children:a}){return jsxs("section",{role:"status",className:"novapay:flex novapay:min-h-56 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:px-5 novapay:py-6 novapay:text-center",children:[jsx(sa,{walletId:e,walletIcon:t}),a]})}function Dm({flow:e,labels:t,locale:a,currency:n,refundable:o}){let r=t.refund,s=useId(),i=useId(),[c$1,l]=useState("fiat_value"),[p,m]=useState(""),[y,f]=useState(""),v=lc(e),d=c$1==="exact_received"||p.trim()===""||/^\d{1,12}(\.\d{1,2})?$/.test(p.trim()),I=[{key:"fiat_value",title:r.modeFiat,hint:c(r.modeFiatText,{currency:n})},{key:"exact_received",title:r.modeExact,hint:r.modeExactText}],h="novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-sm novapay:text-[var(--tuwa-text-primary)]",b={mode:c$1,...c$1==="fiat_value"&&p.trim()&&{amount:p.trim()},...y.trim()&&{reason:y.trim()}};return v.moved?pc(v.moved,v,e,t,a,true):jsxs(Fragment$1,{children:[jsxs(he,{title:r.amountTitle,children:[jsxs("fieldset",{disabled:v.checking,className:"novapay:contents",children:[jsx(hn,{label:r.amountTitle,items:[...I],value:c$1,getKey:g=>g.key,onChange:g=>l(g),className:"novapay:flex novapay:flex-col novapay:gap-2",itemClassName:()=>"novapay:flex novapay:flex-col novapay:gap-0.5 novapay:px-3 novapay:py-2.5",children:g=>jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:text-sm novapay:font-semibold",children:g.title}),jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:g.hint})]})}),c$1==="fiat_value"&&jsxs("label",{htmlFor:s,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsxs("span",{children:[c(r.amount,{currency:n}),jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]})]}),jsx("input",{id:s,required:true,inputMode:"decimal",value:p,placeholder:"0.00","aria-invalid":!d||void 0,onChange:g=>m(g.target.value.replace(",",".")),className:cn$1(q,h)}),o&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(r.amountHint,{amount:o})})]}),jsxs("label",{htmlFor:i,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsx("span",{children:r.reason}),jsx("input",{id:i,value:y,maxLength:500,onChange:g=>f(g.target.value),className:h})]})]}),e.error&&jsx(Q,{children:Da(e.error,r)})]}),jsx(te,{children:jsx(X,{busy:v.checking,disabled:!d,onClick:()=>{v.ask(b);},children:r.continue})})]})}function ic(e,t){return jsxs("span",{className:"novapay:flex novapay:flex-col novapay:items-end novapay:gap-1",children:[e,t&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:t})]})}function Om({flow:e,labels:t,locale:a,values:n,details:o,recordAction:r}){let s=t.refund,i=e.transfer,c$1=typeof e.balance=="bigint"&&i?`${le(e.balance.toString(),i.decimals,a)} ${i.symbol}`:null,l=e.fee?ua(e.fee.amount.toString(),e.fee.decimals,a):null,p=e.fee&&l?`${l} ${e.fee.symbol}`:null,m={notEnough:c(s.notEnough,{...n,address:e.wallet?shortAddress(e.wallet.address):"",balance:c$1??""}),declined:c(s.declined,n),unsupported:c(s.unsupported,n),wrongNetwork:c(s.wrongNetwork,n),failed:s.failed,noRecipient:s.noRecipient,fromBuyer:s.failedFromBuyer,stillInWallet:c(t.walletPrompt.stillWaiting,n),unreachable:s.unreachable},y=!!e.problem,f=!!e.txKey;return jsxs(Fragment$1,{children:[jsxs(he,{title:y?s.notSent:s.confirmTitle,children:[jsxs(xe,{children:[jsx(W,{name:s.send,children:n.amount}),jsx(W,{name:s.network,children:n.network}),i&&jsx(W,{name:s.to,children:ic(jsx(qe,{hash:i.to,explorerUrl:e.addressUrl(i.to),labels:t}),e.refund?.heldTransfer?s.theSender:s.thePayer)}),e.wallet&&jsx(W,{name:s.from,children:ic(jsx(qe,{hash:e.wallet.address,explorerUrl:e.addressUrl(e.wallet.address),labels:t}),c$1&&c(s.balance,{amount:c$1}))}),p&&jsx(W,{name:s.networkFee,children:c(s.feeEstimate,{amount:p})}),o]}),e.problem&&jsx(Q,{children:m[e.problem]}),e.problem&&!["noRecipient","unreachable","stillInWallet"].includes(e.problem)&&jsx(Ue,{children:s.nothingSent}),f&&e.error&&jsx(Q,{children:s.notHandedOver}),!f&&e.error&&e.problem!=="unreachable"&&jsx(Q,{children:Da(e.error,s)})]}),jsxs(te,{children:[e.problem!=="noRecipient"&&(e.wrongNetwork&&!f?jsx(X,{onClick:()=>{e.switchNetwork();},children:jsx(Ce,{label:s.switchTo,values:n})}):jsx(X,{busy:e.sending,onClick:()=>{e.send();},children:f?s.handOver:s.sendRefund})),(y||f)&&r,!y&&!f&&e.wallet&&jsx(re,{onClick:e.connect,children:t.pay.changeWallet})]})]})}function Um(e){return e.appStore?e.novaConnect?"app":"appStore":e.ownConnection?"own":"none"}function Oa(e){let t=useContext(SatelliteStoreContext),a=useContext(NovaConnectProviderContext);return Um({appStore:t!=null,novaConnect:a!==void 0,ownConnection:e})}function Ck(){let e=it(),t=Oa(false);return e.connection??t}var $m=()=>import('./OwnConnection-ET76SUMX.js').then(e=>({default:e.OwnConnection})),mc=lazy($m);var jm=()=>process.env.NODE_ENV==="development";function Lk({baseUrl:e,labels:t,customization:a,adapters:n,pulsar:o,ownConnection:r,onConnectWallet:s,children:i}){let c=useContext(Gn),l=Oa(!!r),[p]=useState(l),[m]=useState(r),y=p==="own"?r??m:void 0,f=(p==="app"||p==="appStore")&&c.connection!==void 0&&c.connection!=="none",v=y?y.adapters:n??(f?c.adapters:void 0),d=useMemo(()=>({baseUrl:e,labels:t,customization:a,adapters:v,pulsar:o,connection:p,onConnectWallet:s}),[e,t,a,v,o,p,s]),I=useRef(null),h=!!r,b=!!v;return useEffect(()=>{if(!jm())return;I.current??=new Set;let g=I.current,k=(P,w)=>{g.has(P)||(g.add(P),console.warn(`[NovaPaymentsProvider] ${w}`));};l!==p&&k("connection",`it keeps the wallet connection it chose on its first render ("${p}"), though the providers above now call for "${l}". Render it inside the app's SatelliteConnectProvider and NovaConnectProvider from the start.`),h&&p==="appStore"&&k("appStore","it is inside the app's SatelliteConnectProvider without NovaConnectProvider: it uses the app's wallet and never adds a second store, so `ownConnection` is not used. Connect wallets with `onConnectWallet`, or render it inside NovaConnectProvider."),h&&!b&&(p==="app"||p==="appStore")&&k("adapters","it uses the app's wallet connection, so the adapters of `ownConnection` are not used: pass `adapters` on the app's wagmi config to pay from the app's wallet.");},[l,p,h,b]),jsx(Gn.Provider,{value:d,children:y?jsx(Suspense,{fallback:null,children:jsx(mc,{own:y,children:i})}):i})}
2
+ export{Dm as AmountStep,Vr as BuyerScreen,Xn as CheckoutContext,Uo as CheckoutContextProvider,vm as CheckoutFrame,ls as CheckoutHeader,hm as CheckoutPageRoot,Qr as CheckoutStepper,as as CheckoutSummary,os as CompactSummary,_s as ConfirmScreen,Om as ConfirmStep,Hs as ConfirmWalletScreen,uo as ContactLink,Jc as DEADLINE_ANNOUNCEMENTS,Xr as DeadlineTimer,ya as Disclosure,Ys as FailedScreen,Bm as FailedStep,Xs as LeaveDialog,ss as LocaleSwitcher,da as MerchantBadge,oi as MethodScreen,ps as MobileSteps,Gn as NovaPaymentsContext,Lk as NovaPaymentsProvider,Ia as OPEN_REQUEST_MS,es as OrderLines,Ol as OrderTotal,Qs as OutcomeScreen,ui as PaidScreen,zi as PayScreen,vw as PaymentCheckout,Za as QUOTE_WARNING_MS,Yi as QrScreen,Qw as RefundButton,Im as RefundDialog,Rm as RefundSteps,Zi as ScreenBody,to as SellerDetailsContent,ts as SummaryFooter,Wn as WalletPrompt,Tt as addressOfWallet,Or as balanceShortfall,ma as baseUnitsToDecimal,Va as buyerFields,Ko as buyerIssues,mr as canPayWithQr,Z as checkoutClassName,Ya as checkoutScreen,yr as checkoutSteps,Go as cleanBuyer,ur as connectedWallet,Ir as contactHref,Vo as countryOptions,hr as deadlineAnnouncement,En as deadlineState,aa as failedPaymentTx,rn as familyOf,at as formatCountdown,ua as formatFeeAmount,ue as formatFiat,le as formatTokenAmount,vr as groupMethodsByToken,Ii as handOverPayment,ve as instructionsChainId,un as invoiceTotals,Dn as isConfirmationError,Sr as isFinalPaymentFailure,mt as isInvoicePaymentOnTheWay,Ot as isInvoicePaymentUnresolved,dt as isMovedMoneyFailure,Pr as isPaidElsewhere,lo as isPayerProofError,Ea as isPaymentAccepted,tt as isPaymentOnTheWay,br as isQuoteEnding,cn as isSameWallet,rc as isSlow,wa as isSmartWallet,Qa as isWalletIconUrl,Wt as leftTheWalletText,Ds as lockPrice,xr as lockedPriceOnWallet,oa as methodErrorText,Ve as methodFamily,dr as methodToken,Ee as minorToDecimal,Xa as needsLeaveConfirm,Bs as needsPayerProof,_r as needsTheClock,ye as networkName,fr as paidSteps,Si as payInvoice,Fr as payPath,We as payerFor,ka as payerProofErrorText,Ln as paymentFailedText,ja as priceAdjustment,Qi as qrPath,Br as quoteAmounts,Dr as quoteRate,Lr as receivedAmount,Ar as refundRateMoved,Ji as refundTransfer,Da as refusalText,sn as restRateText,wr as screensPayingWallets,kr as sentBeforeDeadline,Tr as shownLocale,Nt as unconfirmedFollowUp,Nr as unconfirmedTxKey,Er as underpaidRest,gn as useAsyncValue,li as useAutoReturn,A as useCheckoutContext,mi as useCheckoutEvents,fi as useCheckoutState,yi as useCheckoutStore,Na as useConnectedWallet,it as useNovaPayments,bi as useNow,Oe as useOptionalCheckoutContext,ci as usePaidCallback,ga as usePayerProof,Ni as usePayment,yn as usePaymentFacts,Ai as usePaymentHandOver,Ck as usePaymentsConnection,Vn as usePaymentsLabels,tc as useRefund,Aa as useRereadValue,La as useWalletConnection,Gc as walletLabel,gr as walletOnConfirmStep};