@tuwaio/nova-payments 0.0.0 → 0.0.1
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.
- package/README.md +133 -11
- package/dist/OwnConnection-ET76SUMX.js +1 -0
- package/dist/OwnConnection-S5SQLIBT.cjs +1 -0
- package/dist/chunk-PUMIYLSN.js +1 -0
- package/dist/chunk-S3L4QDPT.cjs +1 -0
- package/dist/chunk-WOAPFVQF.js +1 -0
- package/dist/chunk-XOVRZTAM.cjs +1 -0
- package/dist/de-53SSE6O2.js +1 -0
- package/dist/de-LB5XSRMX.cjs +1 -0
- package/dist/es-LP3HJ4KB.js +1 -0
- package/dist/es-VDW2RZMP.cjs +1 -0
- package/dist/evm/index.cjs +1 -1
- package/dist/evm/index.d.cts +3 -3
- package/dist/evm/index.d.ts +3 -3
- package/dist/evm/index.js +1 -1
- package/dist/i18n/index.cjs +1 -1
- package/dist/i18n/index.d.cts +4 -23
- package/dist/i18n/index.d.ts +4 -23
- package/dist/i18n/index.js +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.css +457 -43
- package/dist/index.d.cts +1924 -242
- package/dist/index.d.ts +1924 -242
- package/dist/index.js +2 -1
- package/dist/it-6IQFXLAR.cjs +1 -0
- package/dist/it-JJ5Z5EUF.js +1 -0
- package/dist/locales-DzMinYsr.d.cts +1221 -0
- package/dist/locales-DzMinYsr.d.ts +1221 -0
- package/dist/solana/index.cjs +1 -1
- package/dist/solana/index.d.cts +7 -4
- package/dist/solana/index.d.ts +7 -4
- package/dist/solana/index.js +1 -1
- package/dist/{types-Bmj8ctqc.d.cts → types-Bp6JUt56.d.cts} +116 -7
- package/dist/{types-Bmj8ctqc.d.ts → types-Bp6JUt56.d.ts} +116 -7
- package/dist/uk-EI4N5BMM.js +1 -0
- package/dist/uk-FVCYLYSB.cjs +1 -0
- package/dist/zhCN-BZBMKUUA.js +1 -0
- package/dist/zhCN-TA7WU5XS.cjs +1 -0
- package/package.json +37 -36
- package/dist/chunk-2GRM2VF3.cjs +0 -1
- package/dist/chunk-4TPU7WSP.cjs +0 -1
- package/dist/chunk-BK3GAYTJ.js +0 -1
- package/dist/chunk-XAUJNVKC.js +0 -1
- package/dist/locales-DtReb4Tp.d.cts +0 -588
- package/dist/locales-DtReb4Tp.d.ts +0 -588
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import {b,d,f,e,c}from'./chunk-BK3GAYTJ.js';import {b as b$1,a}from'./chunk-XAUJNVKC.js';export{a as PaymentWalletError,b as walletErrorKind}from'./chunk-XAUJNVKC.js';import {getChainName,WalletIcon,cn as cn$1,TokenIcon,NetworkIcon,Dialog,DialogContent,DialogTitle}from'@tuwaio/nova-core';import {createContext,useContext,useId,useRef,useEffect,useState,useMemo,useEffectEvent,useCallback}from'react';import {toCaip2ChainId,formatCaip10AccountId,toEvmChainId,parseCaip19AssetId,parseCaip10AccountId,OrbitAdapter,parseCaip2ChainId}from'@tuwaio/orbit-core';import {ArrowPathIcon,LockClosedIcon,ClockIcon,GlobeAltIcon,ChevronDownIcon,CheckIcon as CheckIcon$1,XMarkIcon,WalletIcon as WalletIcon$1,QrCodeIcon,DevicePhoneMobileIcon,NoSymbolIcon,ArrowPathRoundedSquareIcon,XCircleIcon,ArrowUturnLeftIcon,MagnifyingGlassIcon,ExclamationTriangleIcon,DocumentTextIcon,ArrowDownTrayIcon,CheckCircleIcon,DocumentDuplicateIcon}from'@heroicons/react/24/outline';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {CheckIcon}from'@heroicons/react/24/solid';import {TxStatusVisual,TxProgressIndicator,HashLink}from'@tuwaio/nova-transactions';import {useLabels,NovaTransactionsLabelsProvider}from'@tuwaio/nova-transactions/providers';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';var Ie=createContext(null),Ze=Ie.Provider;function C(){let a=useContext(Ie);if(!a)throw new Error("useCheckoutContext must be used inside PaymentCheckout");return a}function X(a,e=2){let o=a.startsWith("-"),t=(o?a.slice(1):a).padStart(e+1,"0");return `${o?"-":""}${t.slice(0,-e)}.${t.slice(-e)}`}var Je=a=>new Intl.NumberFormat(a).formatToParts(1.1).find(e=>e.type==="decimal")?.value??".";function H(a,e){let[o="0",t=""]=(typeof a=="number"?a.toFixed(2):a.trim()).split("."),n=o.startsWith("-"),r=new Intl.NumberFormat(e).format(BigInt(n?o.slice(1):o));return `${n?"-":""}${r}${Je(e)}${t.padEnd(2,"0").slice(0,2)}`}function $(a,e,o){let t=BigInt(a),n=t<0n,r=n?-t:t,s=10n**BigInt(e),c=new Intl.NumberFormat(o).format(r/s),y=(r%s).toString().padStart(e,"0").replace(/0+$/,"").padEnd(2,"0");return `${n?"-":""}${c}${Je(o)}${y}`}function se(a,e){let o=BigInt(a),t=10n**BigInt(e),n=(o%t).toString().padStart(e,"0").replace(/0+$/,"");return n?`${o/t}.${n}`:String(o/t)}function Y(a,e=a.startsWith("0x")?6:4,o=4){return a.length<=e+o+1?a:`${a.slice(0,e)}\u2026${a.slice(-o)}`}var Ca=a=>String(a).padStart(2,"0");function ua(a){let e=Math.max(0,Math.floor(a/1e3)),o=Math.floor(e/86400),t=Math.floor(e%86400/3600),n=Math.floor(e%3600/60),r=e%60;return o>0?`${o}d ${Ca(t)}:${Ca(n)}:${Ca(r)}`:t>0?`${Ca(t)}:${Ca(n)}:${Ca(r)}`:`${Ca(n)}:${Ca(r)}`}var Po={metamask:"MetaMask",walletconnect:"WalletConnect",coinbase:"Coinbase Wallet",okx:"OKX Wallet",trust:"Trust Wallet",injected:"Browser wallet"};function So(a){let e=a.slice(a.indexOf(":")+1).toLowerCase();return Po[e]??e.charAt(0).toUpperCase()+e.slice(1)}var Xe=a=>{let e=parseCaip2ChainId(a)?.namespace;return e==="eip155"||e==="solana"?e:null};function at(a){if(!a?.address)return null;let e=toCaip2ChainId(a.chainId),o=e?Xe(e):null;return !e||!o?null:{address:a.address,chainId:e,family:o,connectorType:a.connectorType,walletId:a.connectorType.slice(a.connectorType.indexOf(":")+1).toLowerCase(),name:So(a.connectorType),connection:a}}function aa(a){return Xe(a.chainId)}function ma(a,e){return !a||a.family!==aa(e)?null:formatCaip10AccountId(e.chainId,a.address)??null}function et(a,e){let o=aa(a);return o==="solana"||o==="eip155"&&!!e}function Te(a){let e=o=>String(Number((o/100).toFixed(2)));return a.discountBps>0?{kind:"discount",percent:e(a.discountBps)}:a.markupBps>0?{kind:"markup",percent:e(a.markupBps)}:null}function G(a){return getChainName(toEvmChainId(a)??a).name}function tt(a){let e=a.assetId?parseCaip19AssetId(a.assetId):void 0;return !e||e.assetNamespace==="slip44"?"native":e.assetReference}function ot(a,e){return a.supportEmail?`mailto:${a.supportEmail}?subject=${encodeURIComponent(e)}`:a.website??null}var Io=["buyer","selectMethod","quoting","awaitingPayment"];function Ae(a){return Io.includes(a)}function pe(a,e){switch(a.code){case "screening_unavailable":return e.pay.screeningUnavailable;case "request_failed":return e.pay.noAnswer;case "amount_out_of_range":case "method_not_found":return e.method.methodUnavailable;case "payer_not_expected":return e.method.payerNotExpected;case "rate_limited":return e.method.rateLimited;default:return e.error.generic}}function nt(a,e){if(a?.status!=="available")return null;let o=e.find(r=>r.id===a.methodId);if(!o)return null;let{request:t}=a,n=t.rules.find(r=>r.type==="expiry")?.data;return {chainId:`eip155:${Number.parseInt(t.chainId,16)}`,to:t.to,limit:BigInt(t.permission.data.periodAmount).toString(),decimals:o.decimals,symbol:o.symbol,periodSeconds:t.permission.data.periodDuration,expiresAt:n?.timestamp?n.timestamp*1e3:null}}function rt(a,e){let o=a%86400===0;return new Intl.NumberFormat(e,{style:"unit",unit:o?"day":"hour",unitDisplay:"long"}).format(o?a/86400:Math.round(a/3600))}function st(a,e){if(!a||e===null)return null;let o=BigInt(a.cryptoAmountExpected)-BigInt(e);return o>0n?o.toString():null}var A="novapay:focus-visible:outline-2 novapay:focus-visible:outline-offset-2 novapay:focus-visible:outline-[var(--tuwa-text-accent)]",Fa=`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)] ${A}`,x="novapay:font-mono novapay:tabular-nums";function ya({title:a,subtitle:e,children:o}){return jsxs("section",{className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-2.5 novapay:px-5 novapay:py-4",children:[jsxs("div",{children:[jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold"),children:a}),e&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:e})]}),o]})}function K({children:a}){return jsx("footer",{className:"novapay:flex novapay:flex-col novapay:gap-1.5 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:px-5 novapay:pb-3.5 novapay:pt-3",children:a})}function ie({children:a,id:e}){return jsx("span",{id:e,className:cn$1(x,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:a})}function U({busy:a,children:e,className:o,...t}){return jsxs("button",{type:"button","aria-busy":a||void 0,...t,disabled:t.disabled||a,className:cn$1(x,"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:transition-colors novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70",A,o),children:[a&&jsx(ArrowPathIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:animate-spin novapay:motion-reduce:animate-none"}),e]})}function J({children:a}){return jsx("p",{role:"alert",className:"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)]",children:a})}function za({text:a,label:e,copiedLabel:o,children:t}){let[n,r]=useState(false);useEffect(()=>{if(!n)return;let c=setTimeout(()=>r(false),2e3);return ()=>clearTimeout(c)},[n]);let s=n?CheckIcon$1:DocumentDuplicateIcon;return jsxs(Fragment,{children:[jsxs("button",{type:"button","aria-label":t?void 0:e,onClick:()=>{navigator.clipboard?.writeText(a).then(()=>r(true),()=>{});},className:cn$1(Fa,"novapay:min-h-6 novapay:min-w-6 novapay:text-xs"),children:[jsx(s,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),t]}),jsx("span",{role:"status",className:"novapay:sr-only",children:n?o:""})]})}function D({name:a,children:e}){return jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3 novapay:text-xs",children:[jsx("dt",{className:"novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]",children:a}),jsx("dd",{className:cn$1(x,"novapay:m-0 novapay:min-w-0 novapay:text-right novapay:break-words"),children:e})]})}function W({children:a,onClick:e}){return jsx("button",{type:"button",onClick:e,className:cn$1("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",A),children:a})}function ce({kind:a,walletName:e,walletId:o,amount:t,merchant:n,network:r,to:s,priceTime:c,onRetry:y,onCancel:l}){let{labels:u}=C(),i=useId(),v=useRef(null);useEffect(()=>v.current?.focus(),[a]);let m={wallet:e,amount:t,merchant:n,network:r},b$1=a==="sign"?u.walletPrompt.signIn:a==="switch"?u.walletPrompt.switchIn:a==="submitting"?u.walletPrompt.submitting:a==="permission"?u.autoPay.approveIn:u.walletPrompt.confirmIn;return jsxs("section",{"aria-labelledby":i,className:"novapay:absolute novapay:inset-0 novapay:z-10 novapay:flex novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:bg-[var(--tuwa-bg-primary)] novapay:px-6 novapay:py-5 novapay:text-center",children:[jsxs("span",{className:"novapay:relative novapay:h-12 novapay:w-12",children:[o&&jsx(WalletIcon,{walletName:o}),jsx(ArrowPathIcon,{"aria-hidden":true,className:"novapay:absolute novapay:-bottom-1 novapay:-right-1 novapay:h-5 novapay:w-5 novapay:animate-spin novapay:rounded-full novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-accent)] novapay:motion-reduce:animate-none"})]}),jsx("h2",{id:i,ref:v,tabIndex:-1,className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold novapay:outline-none"),children:b(b$1,m)}),(a==="sign"||a==="confirm")&&jsxs(Fragment,{children:[jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:b(a==="sign"?u.walletPrompt.signText:u.walletPrompt.confirmText,m)}),jsxs("div",{className:"novapay:w-full novapay:max-w-xs 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("span",{className:"novapay:text-[11px] novapay:font-semibold",children:b(u.walletPrompt.check,m)}),jsxs("dl",{className:"novapay:m-0 novapay:mt-1.5 novapay:flex novapay:flex-col novapay:gap-1",children:[jsx(D,{name:u.walletPrompt.amount,children:t}),jsx(D,{name:u.walletPrompt.to,children:s}),jsx(D,{name:u.walletPrompt.network,children:r}),c&&jsx(D,{name:u.walletPrompt.priceLocked,children:c})]})]}),y?jsxs("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[u.walletPrompt.notOpened," ",jsx(W,{onClick:y,children:u.walletPrompt.tryAgain})]}):jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:b(u.walletPrompt.stillWaiting,m)})]}),a==="permission"&&jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:u.autoPay.walletNote}),a!=="submitting"&&jsx(W,{onClick:l,children:u.walletPrompt.cancel})]})}function it(){let{checkout:a,state:e,store:o,labels:t,locale:n,wallet:r,adapterFor:s,setAutoPay:c}=C(),[y,l]=useState(false),[u,i]=useState(null);if(!a)return null;let v=a.merchant.name,m=nt(a.autoCharge,a.methods),b$2=a.autoCharge,N=b$2?.status==="available"?a.methods.find(w=>w.id===b$2.methodId):void 0,S=N?aa(N):null,T=S?s(S):void 0,f=async()=>{if(b$2?.status!=="available"||!m||!r||!T?.requestPermission)return i("unsupported");i(null),l(true);try{let w=await T.requestPermission({request:b$2.request,account:r.address});await o.getState().grantPermission({payer:`${m.chainId}:${r.address}`,...w})&&c(!1);}catch(w){i(b$1(w));}finally{l(false);}},d={wallet:r?.name??"",network:m?G(m.chainId):""},h=u==="declined"?b(t.pay.declined,d):u==="unsupported"?b(t.autoPay.unavailable,d):u?t.error.generic:e.error?pe(e.error,t):null;return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{inert:y,className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(ya,{title:t.autoPay.title,subtitle:t.autoPay.subtitle,children:[m&&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:b(t.autoPay.allow,{merchant:v})}),jsxs("p",{className:cn$1(x,"novapay:m-0 novapay:text-lg novapay:font-bold"),children:[b(t.autoPay.limit,{amount:`${$(m.limit,m.decimals,n)} ${m.symbol}`})," ",jsx("span",{className:"novapay:text-sm novapay:font-normal",children:b(t.autoPay.every,{period:rt(m.periodSeconds,n)})})]})]}),jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5",children:[r&&jsxs(D,{name:t.autoPay.from,children:[Y(r.address)," \xB7 ",G(m.chainId)]}),jsxs(D,{name:t.autoPay.to,children:[Y(m.to)," ",jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:v})]}),m.expiresAt&&jsx(D,{name:t.autoPay.validUntil,children:b(t.autoPay.validUntilValue,{date:new Intl.DateTimeFormat(n,{dateStyle:"medium"}).format(m.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:t.autoPay.invoices}),jsx("li",{children:b(t.autoPay.cap,{merchant:v})}),jsx("li",{children:t.autoPay.turnOff})]})]}),h&&jsx(J,{children:h})]}),jsxs(K,{children:[jsx(U,{busy:y,disabled:!m,onClick:()=>{f();},children:t.autoPay.confirm}),jsx(W,{onClick:()=>c(false),children:t.autoPay.skip}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:t.autoPay.walletNote})]})]}),y&&r&&jsx(ce,{kind:"permission",walletName:r.name,walletId:r.walletId,amount:"",merchant:v,network:d.network,to:"",priceTime:null,onCancel:()=>l(false)})]})}var Go=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ct="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(" "),Ko=new Set(ct);function Ee(a,e){let o=a==="full"||e,t=[{name:"email",required:true,autoComplete:"email",type:"email"}];return o?[...t,{name:"name",required:true,autoComplete:e?"organization":"name",type:"text"},{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"},{name:"country",required:true,autoComplete:"country",type:"country"},...e?Vo():[]]:t}var Vo=()=>[{name:"taxId",required:true,autoComplete:"off",type:"text"},{name:"registrationNumber",required:false,autoComplete:"off",type:"text"}];function lt(a,e,o){let t={};for(let n of Ee(e,o)){let r=a[n.name]?.trim()??"";r?n.type==="email"&&!Go.test(r)?t[n.name]="email":n.type==="country"&&!Ko.has(r.toUpperCase())&&(t[n.name]="country"):n.required&&(t[n.name]="required");}return t}function ut(a){let e={};for(let[o,t]of Object.entries(a)){let n=t?.trim();n&&(e[o]=o==="country"?n.toUpperCase():n);}return e}function mt(a){let e=new Intl.DisplayNames([a],{type:"region"});return ct.map(o=>({code:o,name:e.of(o)??o})).sort((o,t)=>o.name.localeCompare(t.name,a))}var jo=(a,e,o)=>e==="name"&&o?a.buyer.companyName:a.buyer[e]??e,zo=(a,e)=>e==="email"?a.buyer.invalidEmail:e==="country"?a.buyer.invalidCountry:a.buyer.required,yt=a=>cn$1("novapay:h-9 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:bg-[var(--tuwa-bg-primary)] novapay:px-2.5 novapay:text-[13px] novapay:text-[var(--tuwa-text-primary)]",a?"novapay:border-[var(--tuwa-error-icon)]":"novapay:border-[var(--tuwa-text-secondary)]",A);function vt(){let{checkout:a,state:e,store:o,labels:t,locale:n}=C(),[r,s]=useState({}),[c,y]=useState(false),[l,u]=useState(false),[i,v]=useState(false),m=useId(),b=useMemo(()=>mt(n),[n]);if(!a||a.buyer.collect==="off")return null;let N=a.buyer.collect,S=Ee(N,c),T=lt(r,N,c),f=(h,w)=>s(B=>({...B,[h]:w})),d=async h=>{if(h.preventDefault(),u(true),Object.keys(T).length>0){document.getElementById(`${m}-${Object.keys(T)[0]}`)?.focus();return}v(true),await o.getState().setBuyer(ut(r),{company:c}),v(false);};return jsxs("form",{noValidate:true,onSubmit:h=>{d(h);},className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(ya,{title:t.buyer.title,subtitle:t.buyer.subtitle,children:[a.buyer.companyInvoice&&jsxs("label",{className:"novapay:flex novapay:cursor-pointer novapay:items-center novapay:gap-2 novapay:text-[13px]",children:[jsx("input",{type:"checkbox",checked:c,onChange:h=>y(h.target.checked),className:cn$1("novapay:h-4 novapay:w-4 novapay:accent-[var(--tuwa-text-accent)]",A)}),t.buyer.companyInvoice]}),jsx("div",{className:"novapay:grid novapay:grid-cols-1 novapay:gap-x-3 novapay:gap-y-2.5 novapay:sm:grid-cols-2",children:S.map(h=>{let w=`${m}-${h.name}`,B=l?T[h.name]:void 0,_=h.name==="email"||h.name==="name"||h.name.startsWith("addressLine");return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1",_&&"novapay:sm:col-span-2"),children:[jsxs("label",{htmlFor:w,className:"novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:[jo(t,h.name,c),!h.required&&jsxs("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:[" (",t.buyer.optional,")"]})]}),h.type==="country"?jsxs("select",{id:w,autoComplete:h.autoComplete,required:h.required,"aria-invalid":!!B,"aria-describedby":B?`${w}-error`:void 0,value:r.country??"",onChange:F=>f("country",F.target.value),className:yt(!!B),children:[jsx("option",{value:"",children:t.buyer.chooseCountry}),b.map(F=>jsx("option",{value:F.code,children:F.name},F.code))]}):jsx("input",{id:w,type:h.type,autoComplete:h.autoComplete,required:h.required,"aria-invalid":!!B,"aria-describedby":B?`${w}-error`:void 0,value:r[h.name]??"",onChange:F=>f(h.name,F.target.value),className:yt(!!B)}),B&&jsx("span",{id:`${w}-error`,className:"novapay:text-[11px] novapay:text-[var(--tuwa-error-text)]",children:zo(t,B)})]},h.name)})}),e.error&&e.phase==="buyer"&&jsx(J,{children:e.error.message})]}),jsx(K,{children:jsx(U,{type:"submit",busy:i,children:t.buyer.continue})})]})}function dt(a,e={}){switch(a.phase){case "selectMethod":return e.handoff&&e.payWith==="qr"?"qr":"method";case "quoting":return a.quote?e.payWith==="qr"||a.quote.payer===null?"qr":"pay":"method";case "awaitingPayment":case "submitting":return e.payWith==="qr"||a.quote?.payer===null?"qr":"pay";case "confirming":return "confirm";case "paid":return e.autoPay&&a.checkout?.autoCharge?.status==="available"?"autoPay":"paid";case "cancelled":return a.checkout?.invoice.replacedBy?"replaced":"cancelled";default:return a.phase}}var Yo={buyer:"details",method:"method",pay:"pay",qr:"pay",underpaid:"pay",confirm:"confirm",autoPay:"autoPay"};function Me(a,e={}){let o=Yo[a];if(!o)return null;let t=[...e.withDetails||o==="details"?["details"]:[],"method","pay","confirm",...o==="autoPay"?["autoPay"]:[]],n=t.indexOf(o);return t.map((r,s)=>({key:r,state:s<n?"done":s===n?"current":"upcoming"}))}function ft(a,e){let o=s=>s.chainId===e?0:s.featured?1:2,t=new Map;for(let s of a)t.set(s.symbol,[...t.get(s.symbol)??[],s]);let n=[...t].map(([s,c])=>{let y=[...c].sort((l,u)=>o(l)-o(u));return {symbol:s,methods:y,featured:c.some(l=>l.featured),inWallet:!!e&&c.some(l=>l.chainId===e)}}),r=s=>s.inWallet?0:s.featured?1:2;return n.sort((s,c)=>r(s)-r(c))}var Zo=[10,5,1];function xt(a,e){if(a===null||e<=0)return null;let o=Zo.filter(t=>a>t*6e4&&e<=t*6e4);return o.length?Math.min(...o):null}var Be=6e4;function ht(a){return a>0&&a<=Be}function Re({steps:a,labels:e,className:o}){let t=a.findIndex(n=>n.state==="current");return jsx("nav",{"aria-label":e.steps.label,className:cn$1("novapay:min-w-0 novapay:flex-1",o),children:jsx("ol",{className:"novapay:flex novapay:items-center novapay:gap-1.5",children:a.map((n,r)=>{let s=e.steps[n.key];return jsxs("li",{"aria-current":n.state==="current"?"step":void 0,className:cn$1("novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-1.5",r>0&&"novapay:flex-auto"),children:[r>0&&jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-0.5 novapay:min-w-2 novapay:flex-1 novapay:rounded-full",n.state==="upcoming"?"novapay:bg-[var(--tuwa-border-primary)]":"novapay:bg-[var(--tuwa-success-icon)]")}),jsx("span",{"aria-hidden":true,className:cn$1(x,"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",n.state==="done"&&"novapay:bg-[var(--tuwa-success-icon)] novapay:text-white",n.state==="current"&&"novapay:border-2 novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",n.state==="upcoming"&&"novapay:border-2 novapay:border-[var(--tuwa-border-primary)] novapay:text-[var(--tuwa-text-secondary)]"),children:n.state==="done"?jsx(CheckIcon,{className:"novapay:h-3 novapay:w-3"}):r+1}),jsx("span",{className:cn$1(x,"novapay:truncate novapay:text-[11px]",n.state==="current"?"novapay:font-bold novapay:text-[var(--tuwa-text-primary)]":"novapay:text-[var(--tuwa-text-secondary)]"),children:n.state==="current"?jsxs(Fragment,{children:[jsx("span",{className:"novapay:sr-only",children:b(e.steps.progress,{current:t+1,total:a.length,name:s})}),jsx("span",{"aria-hidden":true,children:s})]}):s})]},n.key)})})})}function ue(a){let e=a.lineItems.reduce((r,s)=>r+BigInt(s.netMinor),0n),o=BigInt(a.totalMinor??e.toString()),t=o-e,n=[...new Set(a.lineItems.filter(r=>Number(r.taxRate)>0).map(r=>r.taxRate))];return {subtotal:X(e.toString()),tax:t>0n?X(t.toString()):null,rate:n.length===1?String(Number(n[0])):null,total:X(o.toString())}}var gt=new Set(["open","processing","underpaid"]),rn=a=>{try{return new URL(a).host}catch{return a}};function Fe({compact:a=false}){let{checkout:e,state:o,labels:t}=C();if(!e)return null;let{merchant:n,invoice:r}=e,s=a?"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:[o.logoUrl?jsx("img",{src:o.logoUrl,alt:"",className:cn$1(s,"novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:object-contain")}):jsx("span",{"aria-hidden":true,className:cn$1(s,x,"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:n.name.trim().charAt(0).toUpperCase()}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:truncate novapay:text-sm novapay:font-semibold",children:n.name}),a?r.number&&jsx("span",{className:cn$1(x,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:r.number}):n.website&&jsx("a",{href:n.website,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:truncate novapay:text-xs novapay:text-[var(--tuwa-text-secondary)] novapay:hover:underline",A),children:rn(n.website)})]}),r.environment==="test"&&jsxs("span",{title:t.summary.testHint,className:cn$1(x,"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:[t.summary.test,jsxs("span",{className:"novapay:sr-only",children:[": ",t.summary.testHint]})]})]})}function wt({checkout:a,labels:e}){let{merchant:o}=a,t=o.seller,n=[[e.summary.terms,o.links.terms],[e.summary.refundPolicy,o.links.refundPolicy],[e.summary.privacy,o.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:[t?.legalName&&jsx("span",{className:"novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)]",children:t.legalName}),(t?.address||t?.country)&&jsx("span",{children:[t.address,t.country].filter(Boolean).join(", ")}),t?.registrationNumber&&jsxs("span",{children:[e.summary.registration," ",t.registrationNumber]}),t?.taxId&&jsxs("span",{children:[e.summary.taxId," ",t.taxId]}),o.supportEmail&&jsx("a",{href:`mailto:${o.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:o.supportEmail}),n.length>0&&jsx("span",{className:"novapay:flex novapay:flex-wrap novapay:gap-x-3",children:n.map(([r,s])=>jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:r},r))}),jsx("span",{children:b(e.summary.sellerRole,{seller:t?.legalName||o.name})})]})}function sn(){let{checkout:a,labels:e,locale:o,now:t}=C(),n=a?.invoice.dueAt;if(!a||!n||!gt.has(a.invoice.status))return null;let r=new Intl.DateTimeFormat(o,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(n));return jsxs("div",{className:"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",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-0.5",children:[jsx("span",{className:cn$1(x,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:e.summary.payWithin}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:b(e.summary.until,{date:r})})]}),jsx("span",{role:"timer",className:cn$1(x,"novapay:text-lg novapay:font-bold"),children:ua(Date.parse(n)-t)})]})}function kt(){let{checkout:a,labels:e,locale:o}=C();if(!a)return null;let{invoice:t}=a,n=ue(t);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:[t.number&&jsxs("div",{className:cn$1(x,"novapay:flex novapay:justify-between novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("span",{children:e.summary.invoice}),jsx("span",{children:t.number})]}),jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-2.5 novapay:p-0",children:t.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(x,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:b(e.summary.quantity,{quantity:r.quantity,price:H(r.unitPrice,o)})})]}),jsx("span",{className:x,children:H(X(r.netMinor),o)})]},s))})]}),n.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:e.summary.subtotal}),jsx("dd",{className:cn$1(x,"novapay:m-0"),children:H(n.subtotal,o)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:n.rate?b(e.summary.taxRate,{rate:n.rate}):e.summary.tax}),jsx("dd",{className:cn$1(x,"novapay:m-0"),children:H(n.tax,o)})]})]})]})}function pn(){let{checkout:a,labels:e,locale:o}=C();return a?jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsx("span",{className:cn$1(x,"novapay:text-xs novapay:font-bold"),children:e.summary.total}),jsxs("span",{className:cn$1(x,"novapay:text-[22px] novapay:font-bold"),children:[H(ue(a.invoice).total,o)," ",jsx("span",{className:"novapay:text-[13px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:a.invoice.currency})]})]}):null}function cn(){let{checkout:a,labels:e}=C();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"}),e.summary.secured]}),a?.merchant.supportEmail&&jsxs("span",{children:[e.summary.help,":"," ",jsx("a",{href:`mailto:${a.merchant.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:a.merchant.supportEmail})]})]})}function Nt({label:a,children:e,className:o}){let[t,n]=useState(false),r=useId();return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-2",o),children:[jsxs("button",{type:"button","aria-expanded":t,"aria-controls":r,onClick:()=>n(s=>!s),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)]",A),children:[a,jsx(ChevronDownIcon,{"aria-hidden":true,className:cn$1("novapay:h-3 novapay:w-3 novapay:transition-transform novapay:motion-reduce:transition-none",t&&"novapay:rotate-180")})]}),jsx("div",{id:r,hidden:!t,children:e})]})}function Ct(){let{checkout:a,labels:e}=C();return a?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(Fe,{}),jsx(Nt,{label:e.summary.sellerDetails,children:jsx(wt,{checkout:a,labels:e})})]}),jsx(sn,{}),jsx("div",{className:"novapay:-mr-2.5 novapay:min-h-0 novapay:flex-1 novapay:overflow-y-auto novapay:pr-2.5",children:jsx(kt,{})}),jsx(pn,{}),jsx(cn,{})]}):null}function Pt(){let{checkout:a,labels:e,locale:o,now:t}=C();if(!a)return null;let{invoice:n}=a,r=ue(n),s=n.dueAt&>.has(n.status)?Date.parse(n.dueAt):null;return jsxs("div",{className:"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",children:[jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsxs("span",{className:cn$1(x,"novapay:text-[22px] novapay:font-bold"),children:[H(r.total,o)," ",jsx("span",{className:"novapay:text-xs novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:n.currency})]}),s&&jsxs("span",{role:"timer",className:cn$1(x,"novapay:flex novapay:items-center novapay:gap-1 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)]"}),ua(s-t)]})]}),jsx(Nt,{label:`${b(e.summary.compact,{count:n.lineItems.length,tax:r.tax?H(r.tax,o):H("0",o)})} \xB7 ${e.summary.showOrder}`,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-1",children:[jsx(kt,{}),jsx(wt,{checkout:a,labels:e})]})})]})}function It({locale:a,labels:e,receiptIssued:o,onSelect:t,className:n}){let[r,s]=useState(false),c=d.find(f=>f.code===a)??d[0],[y,l]=useState(0),u=useId(),i=useRef(null),v=useRef(null),m=useRef(null);useEffect(()=>{if(!r)return;m.current?.focus();let f=d=>{i.current?.contains(d.target)||s(false);};return document.addEventListener("pointerdown",f),()=>document.removeEventListener("pointerdown",f)},[r]);let b$1=()=>{l(Math.max(0,d.indexOf(c))),s(true);},N=()=>{s(false),v.current?.focus();},S=f=>{N(),f!==c.code&&t(f);},T=f=>{let d$1=d.length-1,h={ArrowDown:()=>Math.min(d$1,y+1),ArrowUp:()=>Math.max(0,y-1),Home:()=>0,End:()=>d$1};h[f.key]?(f.preventDefault(),l(h[f.key]())):f.key==="Enter"||f.key===" "?(f.preventDefault(),S(d[y].code)):(f.key==="Escape"||f.key==="Tab")&&(f.preventDefault(),f.stopPropagation(),N());};return jsxs("div",{ref:i,className:cn$1("novapay:relative",n),children:[jsxs("button",{ref:v,type:"button","aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?`${u}-list`:void 0,"aria-label":b(e.language.button,{language:c.name}),className:cn$1(Fa,x,"novapay:text-[11px] novapay:font-semibold"),onClick:()=>r?N():b$1(),onKeyDown:f=>{f.key==="ArrowDown"&&!r&&(f.preventDefault(),b$1());},children:[jsx(GlobeAltIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),jsx("span",{"aria-hidden":true,children:c.short}),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$1(x,"novapay:block novapay:px-2.5 novapay:py-1 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:e.language.title}),jsx("ul",{ref:m,id:`${u}-list`,role:"listbox",tabIndex:-1,"aria-labelledby":`${u}-title`,"aria-activedescendant":`${u}-${d[y].code}`,onKeyDown:T,className:cn$1("novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-0.5 novapay:p-0",A),children:d.map((f,d)=>{let h=f.code===c.code;return jsxs("li",{id:`${u}-${f.code}`,role:"option","aria-selected":h,lang:f.code,onClick:()=>S(f.code),onPointerMove:()=>l(d),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]",d===y&&"novapay:bg-[var(--tuwa-bg-muted)]","novapay:text-[var(--tuwa-text-primary)]",h&&"novapay:font-semibold"),children:[jsx("span",{"aria-hidden":true,className:cn$1(x,"novapay:w-5 novapay:text-[11px]"),children:f.short}),jsx("span",{children:f.name}),h&&jsx(CheckIcon$1,{"aria-hidden":true,className:"novapay:ml-auto novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-accent)]"})]},f.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:o?e.language.noteAfterPaid:e.language.note})]})]})}function Tt({title:a,withDetails:e}){let{screen:o,labels:t,locale:n,store:r,close:s,state:c}=C(),y=Me(o,{withDetails:e}),l=jsxs("div",{className:"novapay:ml-auto novapay:flex novapay:shrink-0 novapay:items-center novapay:gap-2",children:[jsx(It,{locale:n,labels:t,receiptIssued:!!c.receiptUrl,onSelect:u=>{r.getState().setLocale(u);}}),s&&jsx("button",{type:"button","aria-label":t.common.close,onClick:s,className:Fa,children:jsx(XMarkIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"})})]});return jsxs(Fragment,{children:[jsxs("header",{className:"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",children:[y?jsx(Re,{steps:y,labels:t}):a&&jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:flex-1 novapay:text-[15px] novapay:font-bold"),children:a}),l]}),jsxs("header",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-4 novapay:pb-3 novapay:pt-1.5 novapay:sm:hidden",children:[jsx(Fe,{compact:true}),l]})]})}function At({withDetails:a}){let{screen:e,labels:o}=C(),t=Me(e,{withDetails:a});return t?jsx(Re,{steps:t,labels:o,className:"novapay:px-4 novapay:pt-3.5"}):null}function Lt(a,e){return e.withGas||!a.gasless?"transfer":a.gasless.paymaster&&e.canSponsorCalls?"paymaster":a.gasless.relay?"relay":"transfer"}function Mt(a){let e=BigInt(a.amountToSend),o=BigInt(a.cryptoAmountExpected);return !a.transferFee||e<=o?{send:a.amountToSend,receives:a.cryptoAmountExpected,fee:null}:{send:a.amountToSend,receives:a.cryptoAmountExpected,fee:{amount:String(e-o),percent:String(a.transferFee.bps/100)}}}var ve=10000n,Et=8n;function Bt(a,e){let o=BigInt(a.cryptoAmountExpected);if(!e||o<=0n)return null;let n=BigInt(e)*(ve+BigInt(a.markupBps))*(ve-BigInt(a.discountBps))*10n**BigInt(a.decimals)*10n**Et/(100n*ve*ve*o);return Number(n)/10**Number(Et)}function Rt(a,e,o=0n){let t=BigInt(e.amountToSend)+o;return a>=t?null:{have:String(a),need:String(t),short:String(t-a)}}function na(a){return a.family==="eip155"?`eip155:${a.chainId}`:a.chainId}function de(){let{state:a,locale:e,adapterFor:o}=C(),t=a.quote,n=t?na(t.instructions):null,r=a.txHash??a.txKey,s=t?.payer?parseCaip10AccountId(t.payer)?.address:void 0;return {network:n?G(n):null,amount:t?`${$(t.amountToSend,t.decimals,e)} ${t.instructions.symbol}`:null,txKey:r,explorerUrl:t&&n&&r?o(t.instructions.family)?.explorerUrl?.({chainId:n,txKey:r}):void 0,from:s?Y(s):null}}function fe({children:a}){let{labels:e}=C(),o=useLabels(),t=useMemo(()=>({...o,trackingModal:{...o.trackingModal,progressIndicator:{created:e.confirm.sent,processing:e.confirm.confirming,succeed:e.confirm.paid}},statuses:{...o.statuses,confirmed:e.confirm.confirmed,failed:e.confirm.failed},actions:{...o.actions,viewOnExplorer:e.confirm.viewOnExplorer,copy:e.confirm.copyHash},txError:{...o.txError,copied:e.pay.copied}}),[o,e]);return jsx(NovaTransactionsLabelsProvider,{labels:t,children:a})}function Ft(){let{labels:a,close:e}=C(),o=de();return jsxs(fe,{children:[jsxs("section",{className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",children:[jsx(TxStatusVisual,{isProcessing:true}),jsxs("div",{children:[jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold"),children:a.confirm.title}),o.network&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:b(a.confirm.hint,{network:o.network})})]}),jsx(TxProgressIndicator,{isProcessing:true,className:"novapay:max-w-sm"}),jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:gap-1.5 novapay:text-left",children:[o.network&&jsx(D,{name:a.confirm.network,children:o.network}),o.amount&&jsx(D,{name:a.confirm.amount,children:o.amount}),o.txKey&&jsx(D,{name:a.confirm.transaction,children:jsx(HashLink,{hash:o.txKey,explorerUrl:o.explorerUrl,variant:"compact"})}),o.from&&jsx(D,{name:a.confirm.from,children:o.from})]}),jsx("p",{role:"status",className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:a.confirm.canClose})]}),e&&jsx(K,{children:jsx(W,{onClick:e,children:a.common.close})})]})}function Dt({onStay:a,onLeave:e}){let{checkout:o,labels:t,locale:n}=C(),r=useId(),s=useRef(null);useEffect(()=>s.current?.focus(),[]);let c=o?.invoice.dueAt?new Intl.DateTimeFormat(n,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(o.invoice.dueAt)):null;return jsx("section",{role:"alertdialog","aria-modal":"true","aria-labelledby":r,className:"novapay:absolute novapay:inset-0 novapay:z-20 novapay:flex novapay:items-center novapay:justify-center novapay:bg-[var(--tuwa-bg-primary)]/95 novapay:p-6",children:jsxs("div",{className:"novapay:flex novapay:max-w-sm novapay:flex-col novapay:gap-3 novapay:text-center",children:[jsx("h2",{id:r,ref:s,tabIndex:-1,className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold novapay:outline-none"),children:t.leave.title}),jsx("p",{className:"novapay:m-0 novapay:text-xs",children:c?b(t.leave.text,{date:c}):t.leave.textNoDate}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:t.leave.price}),jsx(U,{onClick:a,children:t.leave.stay}),jsx(W,{onClick:e,children:t.leave.leave})]})})}function he({label:a,items:e,value:o,getKey:t,onChange:n,children:r,className:s,itemClassName:c}){let y=useRef([]),l=Math.max(0,e.findIndex(i=>t(i)===o)),u=(i,v)=>{let m=e.length-1,b={ArrowRight:v+1,ArrowDown:v+1,ArrowLeft:v-1,ArrowUp:v-1,Home:0,End:m}[i.key];if(b===void 0)return;i.preventDefault();let N=b<0?m:b>m?0:b;n(t(e[N])),y.current[N]?.focus();};return jsx("div",{role:"radiogroup","aria-label":a,className:s,children:e.map((i,v)=>{let m=t(i),b=m===o;return jsx("button",{ref:N=>{y.current[v]=N;},type:"button",role:"radio","aria-checked":b,tabIndex:v===l?0:-1,onClick:()=>n(m),onKeyDown:N=>u(N,v),className:cn$1("novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-left novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors",b?"novapay:border-2 novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)]":"novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-text-secondary)]",A,c?.(b)),children:r(i,b)},m)})})}function Za({tone:a,children:e}){return jsx("span",{className:cn$1("novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:px-1.5 novapay:py-0.5 novapay:text-[11px]",a==="neutral"&&"novapay:bg-[var(--tuwa-bg-muted)] novapay:text-[var(--tuwa-text-primary)]",a==="accent"&&"novapay:border novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",a==="success"&&"novapay:bg-[var(--tuwa-success-bg)] novapay:text-[var(--tuwa-success-text)]"),children:e})}function Ot({method:a,labels:e}){let o=Te(a);return o?o.kind==="discount"?jsx(Za,{tone:"success",children:b(e.method.discount,{percent:o.percent})}):jsx(Za,{tone:"neutral",children:b(e.method.markup,{percent:o.percent})}):null}function Kn({selected:a}){return jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:shrink-0 novapay:rounded-full novapay:box-border",a?"novapay:border-4 novapay:border-[var(--tuwa-text-accent)]":"novapay:border novapay:border-[var(--tuwa-text-secondary)]")})}function Vn({labels:a,terms:e,refundPolicy:o}){let t=(r,s)=>jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:s},r),n=e&&o?c(a.method.agreeBoth,{terms:t(e,a.summary.terms),refundPolicy:t(o,a.summary.refundPolicy)}):e||o?c(a.method.agreeOne,{link:e?t(e,a.summary.terms):t(o,a.summary.refundPolicy)}):null;return n?jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n}):null}function $t(){let{checkout:a,state:e,store:o,labels:t,wallet:n,payWith:r,setPayWith:s,payUrl:c,connectWallet:y,adapterFor:l,setHandoff:u}=C(),i=useMemo(()=>a?.methods??[],[a]),v=useMemo(()=>ft(i,n?.chainId),[i,n?.chainId]),m=i.find(g=>g.id===e.methodId)??null,b$1=v.find(g=>g.symbol===m?.symbol)??null,N=m?et(m,c):false,S=m?aa(m):null,f=[...(S?!!l(S):false)?["wallet"]:[],...N?["qr"]:[]],d=f.includes(r)?r:f[0]??null,[h,w]=useState(false),B=useEffectEvent(()=>{let g=v[0]?.methods[0];!e.methodId&&g&&o.getState().selectMethod(g.id);});if(useEffect(()=>B(),[v]),!a)return null;if(i.length===0)return jsx(ya,{title:t.method.title,children:jsx(J,{children:t.method.noMethods})});let _=e.phase==="quoting",F=async()=>{if(!m||!d)return;if(w(false),d==="qr"){if(r!=="qr"&&s("qr"),S!=="solana")return u(true);o.getState().setPayer(null),await o.getState().requestQuote();return}r!=="wallet"&&s("wallet");let g=ma(n,m);if(!g)return w(!y(m));o.getState().setPayer(g),await o.getState().requestQuote();};return jsxs(Fragment,{children:[jsxs(ya,{title:t.method.title,subtitle:b(t.method.subtitle,{minutes:Math.round(a.quoteTtlSeconds/60)}),children:[jsx(ie,{children:t.method.token}),jsx(he,{label:t.method.token,items:v,value:b$1?.symbol??null,getKey:g=>g.symbol,onChange:g=>{let j=v.find(Ba=>Ba.symbol===g)?.methods[0];j&&o.getState().selectMethod(j.id);},className:"novapay:grid novapay:grid-cols-2 novapay:gap-2 novapay:sm:grid-cols-4",itemClassName:()=>"novapay:flex novapay:flex-col novapay:items-center novapay:gap-1 novapay:px-1 novapay:py-2",children:g=>jsxs(Fragment,{children:[jsx("span",{className:"novapay:h-6.5 novapay:w-6.5",children:jsx(TokenIcon,{symbol:g.symbol})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:g.symbol}),jsx("span",{className:"novapay:text-[10px] novapay:text-[var(--tuwa-text-secondary)]",children:g.methods.length>1?b(t.method.networks,{count:g.methods.length}):Te(g.methods[0])?jsx(Ot,{method:g.methods[0],labels:t}):G(g.methods[0].chainId)})]})}),b$1&&b$1.methods.length>1&&jsxs(Fragment,{children:[jsx(ie,{children:b(t.method.network,{symbol:b$1.symbol})}),jsx(he,{label:b(t.method.network,{symbol:b$1.symbol}),items:b$1.methods,value:m?.id??null,getKey:g=>g.id,onChange:g=>o.getState().selectMethod(g),className:"novapay:flex novapay:flex-col novapay:gap-1.5",itemClassName:()=>"novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-3 novapay:py-2",children:(g,j)=>jsxs(Fragment,{children:[jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(NetworkIcon,{chainId:toEvmChainId(g.chainId)??g.chainId})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:G(g.chainId)}),jsxs("span",{className:"novapay:ml-auto novapay:flex novapay:flex-wrap novapay:justify-end novapay:gap-1.5",children:[n?.chainId===g.chainId&&jsx(Za,{tone:"neutral",children:t.method.yourWallet}),g.featured&&jsx(Za,{tone:"accent",children:t.method.popular}),jsx(Ot,{method:g,labels:t}),g.gasless==="auto"?jsx(Za,{tone:"success",children:t.method.noGasFee}):jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:t.method.buyerPaysGas})]}),jsx(Kn,{selected:j})]})})]}),jsx(ie,{children:t.method.payWith}),jsx(he,{label:t.method.payWith,items:f,value:d,getKey:g=>g,onChange:g=>{w(false),s(g);},className:cn$1("novapay:grid novapay:gap-2",f.length>1&&"novapay:grid-cols-2"),itemClassName:()=>"novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-2.5 novapay:py-2",children:g=>g==="wallet"?jsxs(Fragment,{children:[n?jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(WalletIcon,{walletName:n.walletId})}):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:t.method.wallet}),jsx("span",{className:cn$1("novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",n&&x),children:n?`${n.name} \xB7 ${Y(n.address)}`:t.method.walletHint})]})]}):jsxs(Fragment,{children:[m&&aa(m)==="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:t.method.qr}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:t.method.qrHint})]})]})}),m&&!d&&jsx(J,{children:t.method.methodUnavailable}),h&&jsx(J,{children:N?t.pay.connectUnavailable:t.method.methodUnavailable}),e.error&&e.phase==="selectMethod"&&jsx(J,{children:pe(e.error,t)})]}),jsxs(K,{children:[jsx(U,{busy:_,disabled:!m||!d,onClick:()=>{F();},children:_?t.method.quoting:t.method.continue}),jsx(Vn,{labels:t,terms:a.merchant.links.terms,refundPolicy:a.merchant.links.refundPolicy})]})]})}var ar={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:XCircleIcon,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)]"}},sa=({children:a,muted:e})=>jsx("p",{className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs",e?"novapay:text-[var(--tuwa-text-secondary)]":"novapay:text-[var(--tuwa-text-primary)]"),children:a});function er(){let{checkout:a,labels:e,onContact:o}=C();if(!a)return null;let t=b(e.outcome.contact,{merchant:a.merchant.name}),n=cn$1("novapay:inline-flex novapay:min-h-6 novapay:items-center novapay:justify-center novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-accent)] novapay:underline novapay:hover:no-underline",A);if(o)return jsx("button",{type:"button",onClick:o,className:cn$1(n,"novapay:cursor-pointer novapay:border-0 novapay:bg-transparent"),children:t});let r=ot(a.merchant,b(e.outcome.contactSubject,{number:a.invoice.number??a.invoice.id}));return r?jsx("a",{href:r,target:r.startsWith("mailto:")?void 0:"_blank",rel:"noopener noreferrer",className:n,children:t}):null}function Ut({kind:a}){let{checkout:e,state:o,store:t,labels:n,locale:r,wallet:s,connectWallet:c,openInvoice:y}=C();if(!e)return null;let l=e.merchant.name,{Icon:u,tone:i}=ar[a],v=o.quote,m=e.methods.find(d=>d.id===(o.methodId??v?.methodId)),b$1=e.invoice.dueAt?new Intl.DateTimeFormat(r,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(e.invoice.dueAt)):null,N=d=>v?`${$(d,v.decimals,r)} ${v.instructions.symbol}`:d,S,T=null,f=null;switch(a){case "underpaid":{let d=e.invoice.amountPaid,h=st(v,d);S=n.outcome.underpaidTitle,T=jsxs(Fragment,{children:[v&&d&&jsx(sa,{children:b(n.outcome.underpaidText,{received:N(d),total:N(v.cryptoAmountExpected)})}),v&&h&&jsx(sa,{children:b(n.outcome.underpaidRest,{rest:N(h),network:G(na(v.instructions))})}),b$1&&jsx(sa,{muted:true,children:b(n.outcome.underpaidNote,{merchant:l,date:b$1})})]});let w=()=>{if(!m)return;let B=v?.payer===null?null:s?ma(s,m):null;if(v?.payer!==null&&!B)return void c(m);t.getState().setPayer(B),t.getState().requestQuote();};f=jsx(U,{busy:o.phase==="quoting",onClick:w,children:n.outcome.payRest});break}case "held":{S=b(n.outcome.heldTitle,{merchant:l});let d=e.invoice.review?.reason,h=d==="late"?n.outcome.heldLate:d==="overpaid"?n.outcome.heldOverpaid:n.outcome.heldScreening;T=jsxs(Fragment,{children:[jsx(sa,{children:b(h,{merchant:l})}),jsx(sa,{muted:true,children:n.outcome.heldNote})]});break}case "refunded":{S=n.outcome.refundedTitle;let d=e.invoice.refundedTotalMinor??e.invoice.totalMinor;T=d&&jsx(sa,{children:b(n.outcome.refundedText,{merchant:l,amount:H(X(d),r),currency:e.invoice.currency})});break}case "expired":S=n.outcome.expiredTitle,T=jsxs(Fragment,{children:[b$1&&jsx(sa,{children:b(n.outcome.expiredText,{date:b$1,merchant:l})}),jsx(sa,{muted:true,children:n.outcome.expiredNote})]});break;case "cancelled":S=n.outcome.cancelledTitle,T=jsx(sa,{children:b(n.outcome.cancelledText,{merchant:l})});break;case "replaced":{let d=e.invoice.replacedBy,h=d?.number??"";if(S=b(n.outcome.replacedTitle,{merchant:l}),T=jsxs(Fragment,{children:[jsx(sa,{children:b(n.outcome.replacedText,{number:h})}),jsx(sa,{muted:true,children:n.outcome.replacedPaid})]}),d?.checkoutToken){let w=d.checkoutToken;f=jsx(U,{onClick:()=>y(w),children:b(n.outcome.openReplacement,{number:h})});}break}case "blocked":{S=n.outcome.blockedTitle;let d=o.payer?parseCaip10AccountId(o.payer)?.address:void 0;T=jsxs(Fragment,{children:[jsx(sa,{children:b(n.outcome.blockedText,{merchant:l})}),d&&jsx("p",{className:cn$1(x,"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]"),children:Y(d)})]}),m&&(f=jsx(U,{onClick:()=>{c(m);},children:n.outcome.useAnotherWallet}));break}}return jsxs(Fragment,{children:[jsxs("section",{role:a==="blocked"?"alert":void 0,className:"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",children:[jsx(u,{"aria-hidden":true,className:cn$1("novapay:h-12 novapay:w-12",i)}),jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:max-w-sm novapay:text-base novapay:font-bold"),children:S}),T]}),jsxs(K,{children:[f,jsx(er,{})]})]})}function Vt(a,e,o){let t=useRef(false),n=useEffectEvent(()=>{e&&o?.(e);});useEffect(()=>{a!=="paid"||t.current||(t.current=true,n());},[a]);}function _t({url:a,seconds:e,now:o,navigate:t=n=>window.location.assign(n)}){let[n]=useState(o),[r,s]=useState(false),c=a&&e>0&&!r?Math.max(0,e-Math.floor((o-n)/1e3)):null,y=useEffectEvent(()=>{a&&t(a);});return useEffect(()=>{c===0&&y();},[c]),{left:c,stay:()=>s(true)}}function Qt(){let{checkout:a,state:e,labels:o,locale:t,now:n,close:r,wallet:s,adapterFor:c,setAutoPay:y,autoReturnSeconds:l}=C(),u=de(),[i]=useState(n),v=a?.merchant.name??"",m=a?.invoice.successUrl??null,b$1=a?.autoCharge??null,N=b$1?.status==="available"?a?.methods.find(B=>B.id===b$1.methodId):void 0,S=N?aa(N):null,T=!!(s&&S&&c(S)?.requestPermission),f=_t({url:m,seconds:T?0:l,now:n});if(!a)return null;let d=a.invoice.totalMinor?H(X(a.invoice.totalMinor),t):null,h=a.invoice.refundedTotalMinor&&BigInt(a.invoice.refundedTotalMinor)>0n?H(X(a.invoice.refundedTotalMinor),t):null,w=new Intl.DateTimeFormat(t,{dateStyle:"medium",timeStyle:"short"}).format(i);return jsxs(fe,{children:[jsxs("section",{className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",children:[jsx(TxStatusVisual,{isSucceed:true}),jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold"),children:o.paid.title}),jsxs("div",{children:[jsx("p",{className:cn$1(x,"novapay:m-0 novapay:text-2xl novapay:font-bold"),children:u.amount??(d&&`${d} ${a.invoice.currency}`)}),jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:u.network?b(o.paid.summary,{network:u.network,date:w}):w})]}),u.txKey&&jsx(HashLink,{hash:u.txKey,explorerUrl:u.explorerUrl,variant:"compact",className:"novapay:max-w-sm"}),jsx(TxProgressIndicator,{isSucceed:true,isConfirmed:true,className:"novapay:max-w-sm"}),h&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:b(o.paid.refunded,{amount:h,currency:a.invoice.currency})}),e.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:o.paid.receipt}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.paid.receiptHint})]}),jsxs("a",{href:e.receiptUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1("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)]",A),children:[jsx(ArrowDownTrayIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"}),o.paid.download]})]}),b$1?.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(CheckCircleIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"}),o.paid.autoPayActive]})]}),jsxs(K,{children:[T&&jsx(U,{onClick:()=>y(true),children:o.paid.autoPayOffer}),m?jsxs(Fragment,{children:[jsx("a",{href:m,className:cn$1(x,"novapay:inline-flex novapay:h-11 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-sm novapay:font-bold novapay:no-underline",T?"novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:text-[var(--tuwa-text-primary)]":"novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-[var(--tuwa-text-on-accent)]",A),children:b(o.paid.back,{merchant:v})}),f.left!==null&&jsxs("p",{className:"novapay:m-0 novapay:text-center novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsx("span",{role:"timer","aria-live":"off",children:b(o.paid.returning,{merchant:v,seconds:f.left})})," ","\xB7 ",jsx(W,{onClick:f.stay,children:o.paid.stay})]})]}):r&&jsx(W,{onClick:r,children:o.common.close})]})]})}var Ma=()=>new Promise(()=>{}),dr={view:Ma,quote:Ma,buyer:Ma,locale:Ma,submit:Ma,relay:Ma,permission:Ma,url:()=>""},fr=createCheckoutStore({token:"idle",api:dr,EventSource:null});function zt(a){let{token:e,baseUrl:o,api:t,EventSource:n,pollMs:r}=a,[s,c]=useState(fr),y=useEffectEvent(()=>createCheckoutStore({token:e,baseUrl:o,api:t,EventSource:n,pollMs:r}));return useEffect(()=>{let l=y();return c(l),l.getState().load(),()=>l.getState().destroy()},[e,o]),s}function Yt(a,e){return useStore(a,e)}var kr=createStore(()=>({}));function Zt(){let a=useContext(SatelliteStoreContext),e=useStore(a??kr,o=>o.activeConnection);return useMemo(()=>at(e),[e])}var ge=createContext({});function we(){return useContext(ge)}function Jt(a,e=true){let[o,t]=useState(()=>Date.now());return useEffect(()=>{if(!e)return;let n=setInterval(()=>t(Date.now()),a);return ()=>clearInterval(n)},[a,e]),o}var Ir=100,Tr=300,Xt=(a,e)=>a.length>e?`${a.slice(0,e-1)}\u2026`:a,Ar=["paid","underpaid","held","refunded","expired","cancelled","blocked"];function ao(a){return !Ar.includes(a.phase)&&a.error?.code!=="payment_failed"}async function eo({adapter:a,pulsar:e,payment:o,labels:t,merchant:n,invoice:r,amount:s}){if(!e||!a?.pulsarTransaction)return false;let c=r.number?b(t.pay.txDescription,{amount:s,invoice:r.number}):s,y=a.pulsarTransaction({...o,title:Xt(b(t.pay.txTitle,{merchant:n}),Ir),description:Xt(c,Tr),payload:{quasarInvoice:r.id}});return await e.injectExternalPendingTxs([y]),true}function to({store:a,open:e,adapterFor:o,pulsar:t,labels:n,locale:r}){let s=useRef(null),c=useRef(!e),y=useRef({adapterFor:o,pulsar:t,labels:n,locale:r});useEffect(()=>{y.current={adapterFor:o,pulsar:t,labels:n,locale:r};});let l=useCallback(i=>{let{phase:v,error:m,checkout:b}=a.getState();if(!b||!ao({phase:v,error:m}))return;let{adapterFor:N,pulsar:S,labels:T,locale:f}=y.current,{amount:d,decimals:h,symbol:w}=i.instructions;eo({adapter:N(i.instructions.family),pulsar:S,payment:i,labels:T,merchant:b.merchant.name,invoice:{id:b.invoice.id,number:b.invoice.number},amount:`${$(d,h,f)} ${w}`}).catch(()=>{});},[a]),u=useCallback(()=>{c.current=true,s.current&&l(s.current),s.current=null;},[l]);return useEffect(()=>{e?c.current=false:u();},[e,u]),useEffect(()=>u,[u]),useCallback(i=>{c.current?l(i):s.current=i;},[l])}function oo(a){let{labels:e$1,customization:o}=we(),t=o?.labels?.transform;return useMemo(()=>{let n=f(e(a),e$1);return t?t(n,{locale:a}):n},[a,e$1,t])}function ro(a){let e=useContext(NovaConnectProviderContext);return {canConnect:!!(e||a),connecting:e?.isConnectModalOpen??false,connect:o=>e?(e.setIsConnectModalOpen(true,{adapter:o==="solana"?OrbitAdapter.SOLANA:OrbitAdapter.EVM}),true):a?(a(o),true):false}}function Xa(a,e){let[o,t]=useState(null),n=useEffectEvent(e);return useEffect(()=>{if(a===null)return;let r=true,s;try{s=Promise.resolve(n());}catch(c){s=Promise.reject(c);}return s.then(c=>r&&t({key:a,value:c}),()=>r&&t({key:a,value:null})),()=>{r=false;}},[a]),o&&o.key===a?o.value:void 0}var so=a$1=>new a("unsupported",`${a$1} is not available`);async function po({adapter:a,store:e,quote:o,wallet:t,path:n,paymasterUrl:r,onWalletDone:s,onSent:c}){let y=t.address;if(n==="relay"){let u=o.gasless?.relay?.typedData;if(!u||!a.signTransferAuthorization)throw so("A gasless signature");let i=await a.signTransferAuthorization({typedData:u,account:y});return s?.(),e.getState().relay(i)}if(n==="paymaster"){let u=o.gasless?.paymaster?.calls;if(!u||!r||!a.sendSponsoredCalls)throw so("A sponsored payment");let i=na(o.instructions),v=await a.sendSponsoredCalls({calls:u,paymasterUrl:r,chainId:i,account:y,onSent:s});return s?.(),c?.(v),e.getState().submit({txKey:v,connectorType:t.connectorType})}let l=await a.sendTransfer({instructions:o.instructions,account:y,connection:t.connection});return s?.(),c?.(l),e.getState().submit({txKey:l,connectorType:t.connectorType})}function co({adapter:a,store:e,quote:o,wallet:t,path:n,paymasterUrl:r,onSent:s}){let[c,y]=useState("idle"),[l,u]=useState(null),i=useRef(0),v=async(m,b)=>{let N=++i.current,S=()=>i.current===N;u(null),y(m);try{await b(S);}catch(T){S()&&u(b$1(T));}finally{S()&&y("idle");}};return {status:c,problem:l,pay:()=>v("wallet",async m=>{if(!a||!o||!t)return u("unsupported");await po({adapter:a,store:e,quote:o,wallet:t,path:n,paymasterUrl:r,onWalletDone:()=>m()&&y("submitting"),onSent:b=>s?.({txKey:b,instructions:o.instructions,account:t.address,connectorType:t.connectorType})});}),switchNetwork:()=>v("switching",async()=>{if(!a?.switchChain||!o)return u("unsupported");await a.switchChain(na(o.instructions));}),dismiss:()=>{i.current++,y("idle");}}}function Ur(a,e){return a>=1?H(a,e):new Intl.NumberFormat(e,{maximumSignificantDigits:6}).format(a)}function Hr(a,e,o,t){return o==="declined"?b(a.pay.declined,e):o==="unsupported"?b(a.pay.unsupported,e):o==="failed"||t==="payment_failed"?b(a.pay.failed,e):t==="screening_unavailable"?a.pay.screeningUnavailable:t==="request_failed"?a.pay.noAnswer:null}function Gr(a,e,o){let{wallet:t,adapterFor:n}=C(),r=e?.instructions.family,s=r?n(r):void 0,c=a.filter(l=>l.id!==e?.methodId&&aa(l)===r),y=Xa(o&&s&&t&&c.length?`${t.address}:${c.map(l=>l.id).join()}`:null,()=>Promise.all(c.map(l=>s.getBalance({chainId:l.chainId,account:t.address,token:tt(l)}).catch(()=>0n))));return y?c.map((l,u)=>({method:l,balance:y[u]})).filter(l=>l.balance>0n):[]}function lo(){let{checkout:a,state:e,store:o,labels:t,locale:n,now:r,wallet:s,adapterFor:c,connectWallet:y,backToMethods:l,onPaymentSent:u}=C(),i=e.quote,v=a?.methods??[],m=v.find(z=>z.id===i?.methodId),b$1=i?.instructions.family??"eip155",N=c(b$1),S=i?na(i.instructions):"",T=s?.address??"",[f,d]=useState(false),h=Xa(i?.gasless?.paymaster&&N?.canSponsorCalls&&s?`${S}:${T}`:null,()=>N.canSponsorCalls({chainId:S,account:T})),w=i?Lt(i,{withGas:f,canSponsorCalls:h===true}):"transfer",B=Xa(i&&N&&s?`${S}:${T}:${i.instructions.token}`:null,()=>N.getBalance({chainId:S,account:T,token:i.instructions.token})),_=Xa(i&&w==="transfer"&&N?.estimateFee&&s?`${S}:${T}:${i.amountToSend}`:null,()=>N.estimateFee({instructions:i.instructions,account:T})),F=co({adapter:N,store:o,quote:i,wallet:s,path:w,paymasterUrl:e.paymasterUrl,onSent:u}),g=i?.instructions.token==="native",j=i&&typeof B=="bigint"?Rt(B,i,g&&_?_.amount:0n):null,Ba=Gr(v,i,!!j);if(!a||!i||!m)return null;let da=a.merchant.name,fa=G(S),xa=z=>`${$(z,i.decimals,n)} ${i.instructions.symbol}`,Z=Mt(i),ka=i.expiresAt?Date.parse(i.expiresAt)-r:Number.POSITIVE_INFINITY,ha=ka<=0,Ce=ht(ka),Aa=e.phase==="quoting",ae=a.invoice.amountPaid?null:Bt(i,a.invoice.totalMinor),ee=a.invoice.totalMinor?H(X(a.invoice.totalMinor),n):null,ba=!!(s&&i.payer&&ma(s,m)===i.payer),Va=b$1==="eip155"&&s&&s.chainId!==S&&!!N?.switchChain,te=F.status!=="idle"||e.phase==="submitting"||Aa,oe=Hr(t,{wallet:s?.name??"",network:fa},F.problem,e.phase==="awaitingPayment"?e.error?.code:void 0),_a=()=>{o.getState().requestQuote();},la;ha?la={label:t.pay.newPrice,run:_a}:ba?Va?la={label:b(t.pay.switchTo,{network:fa}),run:()=>{F.switchNetwork();}}:la={label:b(w==="transfer"?t.pay.payAmount:t.pay.signToPay,{amount:xa(Z.send)}),run:()=>{F.pay();},disabled:!!j}:la={label:t.pay.connect,run:()=>{y(m);}};let Qa=F.status==="switching"?"switch":F.status==="submitting"||e.phase==="submitting"?"submitting":F.status==="wallet"?w==="transfer"?"confirm":"sign":null;return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{inert:Qa!==null,className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("section",{className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-3 novapay:px-5 novapay:py-4",children:[jsx("h2",{className:"novapay:sr-only",children:t.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(WalletIcon,{walletName:s.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:s.name}),jsx("span",{className:cn$1(x,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:b(t.pay.walletLine,{address:Y(s.address),network:G(s.chainId)})})]}),jsx("button",{type:"button","aria-label":t.pay.changeWallet,onClick:()=>y(m),className:cn$1("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)]",A),children:t.pay.change})]}),Va&&ba&&!ha&&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:t.pay.wrongNetwork}),b(t.pay.wrongNetworkText,{current:G(s.chainId),network:fa})," ",t.pay.switchHint]})]}),jsxs("div",{children:[jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:t.pay.youSend}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn$1(x,"novapay:text-[28px] novapay:font-bold novapay:leading-tight"),children:$(Z.send,i.decimals,n)}),jsx("span",{className:cn$1(x,"novapay:text-sm novapay:font-semibold"),children:i.instructions.symbol}),jsx(za,{text:se(Z.send,i.decimals),label:t.pay.copyAmount,copiedLabel:t.pay.copied})]}),jsxs("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[b(t.pay.onNetwork,{network:fa}),ee&&!Z.fee&&jsxs(Fragment,{children:[" \xB7 ",b(t.pay.fiatValue,{amount:ee,currency:a.invoice.currency})]})]})]}),Z.fee&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:px-3 novapay:py-2",children:[jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1",children:[jsx(D,{name:t.pay.invoiceTotal,children:$(Z.receives,i.decimals,n)}),jsx(D,{name:b(t.pay.transferFee,{percent:Z.fee.percent}),children:$(Z.fee.amount,i.decimals,n)}),jsx(D,{name:b(t.pay.merchantReceives,{merchant:da}),children:xa(Z.receives)})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:t.pay.transferFeeNote})]}),!ha&&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:b(t.pay.priceLocked,{time:ua(ka)})}),jsx(W,{onClick:_a,children:t.pay.refreshPrice})]}),Ce&&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:b(t.pay.priceEnding,{time:ua(ka)})}),jsx("span",{role:"status",className:"novapay:sr-only",children:b(t.pay.priceEnding,{time:ua(Be)})}),jsx("button",{type:"button",onClick:_a,disabled:Aa,className:cn$1(x,"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",A),children:b(t.pay.keepPrice,{minutes:Math.round(a.quoteTtlSeconds/60)})})]}),ha&&jsx(J,{children:t.pay.priceExpired}),j&&!ha&&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:t.pay.notEnough}),b(t.pay.walletHas,{amount:xa(j.have),network:fa}),"."," ",b(t.pay.shortBy,{short:xa(j.short),need:xa(j.need)})]}),Ba.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:t.pay.payFromBalance}),Ba.map(({method:z,balance:Ke})=>jsxs("button",{type:"button",onClick:()=>{let Ve=s?ma(s,z):null;o.getState().selectMethod(z.id),o.getState().setPayer(Ve),o.getState().requestQuote();},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)]",A),children:[jsxs("span",{className:"novapay:font-semibold",children:[z.symbol," \xB7 ",G(z.chainId)]}),jsx("span",{className:cn$1(x,"novapay:text-[var(--tuwa-text-secondary)]"),children:b(t.pay.youHave,{amount:`${$(String(Ke),z.decimals,n)} ${z.symbol}`})})]},z.id))]}),a.merchant.fundingUrl&&jsxs("span",{children:[b(t.pay.topUp,{symbol:i.instructions.symbol})," ",jsxs("a",{href:a.merchant.fundingUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:[b(t.pay.getToken,{symbol:i.instructions.symbol})," \u2197"]})]})]}),jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:pt-3",children:[ae!==null&&jsx(D,{name:t.pay.rate,children:b(t.pay.rateValue,{symbol:i.instructions.symbol,price:Ur(ae,n),currency:a.invoice.currency})}),jsx(D,{name:t.pay.networkFee,children:w!=="transfer"?jsx("span",{className:"novapay:text-[var(--tuwa-success-text)]",children:b(t.pay.merchantPaysGas,{merchant:da})}):_?b(t.pay.gasEstimate,{amount:`${$(String(_.amount),_.decimals,n)} ${_.symbol}`}):t.pay.gasFromWallet}),jsxs(D,{name:t.pay.to,children:[Y(i.instructions.to)," ",jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:da})]})]}),oe&&jsx(J,{children:oe})]}),jsxs(K,{children:[jsx(U,{busy:te,disabled:la.disabled,onClick:la.run,children:la.label}),jsxs("div",{className:"novapay:flex novapay:items-center novapay:justify-between novapay:gap-3",children:[jsx(W,{onClick:l,children:t.pay.back}),i.gasless&&jsx(W,{onClick:()=>d(!f),children:f?b(t.pay.payGasless,{merchant:da}):t.pay.payWithGas})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:b(t.pay.disclaimer,{merchant:da})})]})]}),Qa&&jsx(ce,{kind:Qa,walletName:s?.name??"",walletId:s?.walletId??"",amount:xa(Z.send),merchant:da,network:fa,to:Y(i.instructions.to),priceTime:ha?null:ua(ka),onRetry:w==="relay"?()=>{F.pay();}:void 0,onCancel:F.dismiss})]})}var $e=4;function uo(a){let{size:e,data:o}=encode(a,{ecc:"M",border:0}),t="";return o.forEach((n,r)=>n.forEach((s,c)=>{s&&(t+=`M${c+$e} ${r+$e}h1v1h-1z`);})),{size:e+$e*2,path:t}}function Ue({value:a,label:e,className:o}){let{size:t,path:n}=useMemo(()=>uo(a),[a]);return jsxs("svg",{role:"img","aria-label":e,viewBox:`0 0 ${t} ${t}`,shapeRendering:"crispEdges",className:cn$1("novapay:block novapay:rounded-[var(--tuwa-rounded-corners)]",o),children:[jsx("rect",{width:t,height:t,fill:"#ffffff"}),jsx("path",{d:n,fill:"#111827"})]})}function Zr({payUrl:a}){let{labels:e,backToMethods:o}=C();return jsxs(Fragment,{children:[jsx(ya,{title:e.qr.handoffTitle,subtitle:e.qr.handoffHint,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-3 novapay:py-2",children:[jsx(Ue,{value:a,label:e.qr.handoffCode,className:"novapay:h-48 novapay:w-48"}),jsx(za,{text:a,label:e.qr.copyLink,copiedLabel:e.pay.copied,children:e.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:e.qr.handoffNote})]})}),jsx(K,{children:jsx(W,{onClick:o,children:e.qr.back})})]})}function yo(){let{checkout:a,state:e,store:o,labels:t,locale:n,now:r,payUrl:s,backToMethods:c}=C(),y=e.quote;if(!a)return null;if(!y||y.instructions.family!=="solana")return s?jsx(Zr,{payUrl:s}):null;let{instructions:l}=y,u=G(na(l)),i=`${$(y.amountToSend,y.decimals,n)} ${l.symbol}`,v=y.expiresAt?Date.parse(y.expiresAt)-r:Number.POSITIVE_INFINITY,m=v<=0,b$1=e.phase==="quoting";return jsxs(Fragment,{children:[jsxs(ya,{title:t.qr.solanaTitle,subtitle:t.qr.solanaHint,children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-4 novapay:sm:flex-row novapay:sm:items-start",children:[jsx(Ue,{value:l.solanaPayUrl,label:b(t.qr.solanaCode,{amount:i}),className:cn$1("novapay:h-44 novapay:w-44 novapay:shrink-0",m&&"novapay:opacity-30")}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2 novapay:text-xs",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:t.qr.scanStep}),jsx("li",{children:t.qr.approveStep})]}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn$1(x,"novapay:text-2xl novapay:font-bold"),children:$(y.amountToSend,y.decimals,n)}),jsx(za,{text:se(y.amountToSend,y.decimals),label:t.pay.copyAmount,copiedLabel:t.pay.copied})]}),jsxs("span",{className:cn$1(x,"novapay:text-[var(--tuwa-text-secondary)]"),children:[l.symbol," \xB7 ",u," \xB7 ",Y(l.to)]}),!m&&jsxs(Fragment,{children:[jsxs("span",{role:"status",className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(ArrowPathIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:animate-spin novapay:motion-reduce:animate-none"}),t.qr.waiting]}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:text-[var(--tuwa-text-secondary)]",children:b(t.pay.priceLocked,{time:ua(v)})})]})]})]}),m&&jsx(J,{children:t.pay.priceExpired}),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"}),t.qr.exchangeWarning]})]}),jsxs(K,{children:[m?jsx(U,{busy:b$1,onClick:()=>{o.getState().requestQuote();},children:t.pay.newPrice}):jsx("a",{href:l.solanaPayUrl,className:cn$1(x,"novapay:inline-flex novapay:h-11 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-sm novapay:font-bold novapay:text-[var(--tuwa-text-on-accent)] novapay:no-underline novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)]",A),children:t.qr.openInWallet}),jsx(W,{onClick:c,children:t.qr.back})]})]})}function ss(){let{labels:a}=C();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(ArrowPathIcon,{"aria-hidden":true,className:"novapay:h-6 novapay:w-6 novapay:animate-spin novapay:motion-reduce:animate-none"}),a.common.loading]})}function ps(){let{labels:a,state:e,store:o}=C(),t=e.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",{className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold"),children:a.error.title}),jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-[13px] novapay:text-[var(--tuwa-text-secondary)]",children:t?a.error.notFound:a.error.generic}),!t&&jsx("button",{type:"button",onClick:()=>{o.getState().load();},className:cn$1(x,"novapay:h-9 novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border-0 novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-4 novapay:text-xs novapay:font-bold novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-standart-button-hover)]",A),children:a.common.retry})]})}function is(){let{screen:a}=C();return a==="loading"?jsx(ss,{}):a==="error"?jsx(ps,{}):a==="buyer"?jsx(vt,{}):a==="method"?jsx($t,{}):a==="pay"?jsx(lo,{}):a==="qr"?jsx(yo,{}):a==="confirm"?jsx(Ft,{}):a==="paid"?jsx(Qt,{}):a==="autoPay"?jsx(it,{}):jsx(Ut,{kind:a})}function cs({className:a,withDetails:e,leave:o}){let{checkout:t,locale:n,labels:r,now:s}=C(),[c,y]=useState(""),l=useRef(null),u=t?.invoice.dueAt?Date.parse(t.invoice.dueAt):null;return useEffect(()=>{if(u===null)return;let i=u-s,v=xt(l.current,i);l.current=i,v!==null&&y(v===1?r.summary.oneMinuteLeft:b(r.summary.minutesLeft,{minutes:v}));},[u,s,r]),jsxs("div",{lang:n,className:cn$1("novapay:relative 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-[600px] novapay:sm:w-[760px] novapay:sm:flex-row",a),children:[t&&jsx("aside",{className:"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",children:jsx(Ct,{})}),jsxs("div",{className:"novapay:flex novapay:min-h-0 novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx(Tt,{withDetails:e}),jsxs("div",{className:"novapay:sm:hidden",children:[t&&jsx(Pt,{}),jsx(At,{withDetails:e})]}),jsx("div",{className:"novapay:flex novapay:min-h-0 novapay:flex-1 novapay:flex-col novapay:overflow-y-auto",children:jsx(is,{})})]}),jsx("div",{role:"status","aria-live":"polite",className:"novapay:sr-only",children:c}),o&&jsx(Dt,{onStay:o.onStay,onLeave:o.onLeave})]})}function yu({token:a,display:e="modal",open:o=true,onOpenChange:t,onClose:n,baseUrl:r,api:s,EventSource:c,pollMs:y,payUrl:l,onConnectWallet:u,onPaid:i,autoReturnSeconds:v=5,onContact:m,className:b$1}){let N=we(),[S,T]=useState({from:a,token:a}),f=S.from===a?S.token:a,d=zt({token:f,baseUrl:r??N.baseUrl,api:s,EventSource:c,pollMs:y}),h=Yt(d,Q=>Q),w=h.checkout,B=h.locale??w?.invoice.locale??"en",_=oo(B),F=Jt(1e3,!!w),g=Zt(),j=ro(u),Ba=N.adapters,[da,fa]=useState("wallet"),[xa,Z]=useState(false),[ka,ha]=useState(false),[Ce,Aa]=useState(false),[ae,ee]=useState(f);ae!==f&&(ee(f),Z(false),ha(false),fa("wallet"));let ba=useRef(null),Va=dt(h,{payWith:da,handoff:xa,autoPay:ka});Vt(h.phase,w?.invoice,i);let te=Q=>Ba?.find(Ra=>Ra.family===Q),oe=to({store:d,open:e!=="modal"||o,adapterFor:te,pulsar:N.pulsar,labels:_,locale:B}),_a=useEffectEvent(()=>{if(!g||!w)return;let{quote:Q,phase:Ra}=d.getState();if(ba.current){let ne=w.methods.find(fo=>fo.id===ba.current),Qe=ne?ma(g,ne):null;if(!Qe)return;ba.current=null,d.getState().setPayer(Qe),d.getState().requestQuote();return}if(Ra!=="awaitingPayment"||!Q?.payer)return;let ja=w.methods.find(ne=>ne.id===Q.methodId),Pe=ja?ma(g,ja):null;if(Pe!==Q.payer){if(!Pe)return d.getState().releaseQuote();d.getState().setPayer(Pe),d.getState().requestQuote();}});useEffect(()=>_a(),[g?.address,g?.chainId,g?.connectorType]),useEffect(()=>{j.connecting||(ba.current=null);},[j.connecting]);let[la,Qa]=useState(false);Va==="buyer"&&!la&&Qa(true);let z=useMemo(()=>e==="modal"?()=>t?t(false):n?.():n,[e,t,n]),_e=jsx(Ze,{value:{store:d,state:h,checkout:w,screen:Va,locale:B,labels:_,now:F,close:z&&(()=>Ae(d.getState().phase)?Aa(true):z()),wallet:g,payWith:da,setPayWith:fa,payUrl:l,connectWallet:Q=>{let Ra=aa(Q);ba.current=Q.id;let ja=Ra!==null&&j.connect(Ra);return ja||(ba.current=null),ja},adapterFor:te,handoff:xa,setHandoff:Z,backToMethods:()=>{Z(false),d.getState().releaseQuote();},onPaymentSent:oe,autoPay:ka,setAutoPay:ha,openInvoice:Q=>T({from:a,token:Q}),onContact:m,autoReturnSeconds:v},children:jsx(MotionConfig,{reducedMotion:"user",children:jsx(cs,{withDetails:la,leave:Ce?{onStay:()=>Aa(false),onLeave:()=>{Aa(false),d.getState().releaseQuote(),z?.();}}:null,className:e==="modal"?b$1:void 0})})});return e==="modal"?jsx(Dialog,{open:o,onOpenChange:Q=>{if(!Q&&Ae(d.getState().phase))return Aa(true);t?.(Q),Q||n?.();},children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-auto",children:[jsx(DialogTitle,{className:"novapay:sr-only",children:b(_.common.dialogTitle,{merchant:w?.merchant.name??""})}),_e]})}):jsx("section",{"aria-label":b(_.common.dialogTitle,{merchant:w?.merchant.name??""}),className:cn$1("novapay:w-full novapay:overflow-hidden novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:sm:w-[760px]",e==="page"&&"novapay:mx-auto novapay:my-8",b$1),children:_e})}function Fu({baseUrl:a,labels:e,customization:o,adapters:t,pulsar:n,children:r}){let s=useMemo(()=>({baseUrl:a,labels:e,customization:o,adapters:t,pulsar:n}),[a,e,o,t,n]);return jsx(ge.Provider,{value:s,children:r})}export{it as AutoPayScreen,vt as BuyerScreen,Ie as CheckoutContext,Ze as CheckoutContextProvider,Tt as CheckoutHeader,Re as CheckoutStepper,Ct as CheckoutSummary,Pt as CompactSummary,Ft as ConfirmScreen,Zo as DEADLINE_ANNOUNCEMENTS,sn as DeadlineTimer,Dt as LeaveDialog,It as LocaleSwitcher,Fe as MerchantBadge,$t as MethodScreen,At as MobileSteps,ge as NovaPaymentsContext,Fu as NovaPaymentsProvider,kt as OrderLines,pn as OrderTotal,Ut as OutcomeScreen,Qt as PaidScreen,lo as PayScreen,yu as PaymentCheckout,Be as QUOTE_WARNING_MS,yo as QrScreen,wt as SellerDetailsContent,cn as SummaryFooter,ce as WalletPrompt,nt as autoPayTerms,Rt as balanceShortfall,se as baseUnitsToDecimal,Ee as buyerFields,lt as buyerIssues,et as canPayWithQr,dt as checkoutScreen,Me as checkoutSteps,ut as cleanBuyer,at as connectedWallet,ot as contactHref,mt as countryOptions,xt as deadlineAnnouncement,ua as formatCountdown,H as formatFiat,rt as formatPeriod,$ as formatTokenAmount,ft as groupMethodsByToken,eo as handOverPayment,na as instructionsChainId,ue as invoiceTotals,ht as isQuoteEnding,pe as methodErrorText,aa as methodFamily,tt as methodToken,X as minorToDecimal,Ae as needsLeaveConfirm,G as networkName,po as payInvoice,Lt as payPath,ma as payerFor,Te as priceAdjustment,uo as qrPath,Mt as quoteAmounts,Bt as quoteRate,Y as shortAddress,ao as shouldHandOver,st as underpaidRest,Xa as useAsyncValue,_t as useAutoReturn,C as useCheckoutContext,Yt as useCheckoutState,zt as useCheckoutStore,Zt as useConnectedWallet,we as useNovaPayments,Jt as useNow,Vt as usePaidCallback,co as usePayment,de as usePaymentFacts,to as usePaymentHandOver,oo as usePaymentsLabels,ro as useWalletConnection,So as walletLabel};
|
|
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};
|