@tuwaio/nova-payments 0.5.0 → 0.5.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/dist/index.cjs +2 -2
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {c,b,e,h,g,i,j,f,d}from'./chunk-SB5LW2OQ.js';import {b as b$1,a}from'./chunk-7HSDAUKN.js';export{a as PaymentWalletError,b as walletErrorKind}from'./chunk-7HSDAUKN.js';import {getChainName,cn as cn$1,DrawnCheck,CloseIcon,MorphText,WalletIcon,Dialog,DialogContent,DialogTitle,TokenIcon,QuasarLoader,StatusEdge,NetworkIcon,NovaSetIcon,CopyIcon,useNovaIcons,DrawnCross,pixelFlight}from'@tuwaio/nova-core';import {createContext,lazy,useContext,useState,useId,useMemo,Fragment,useRef,useEffect,useEffectEvent,useCallback,Suspense,useLayoutEffect}from'react';import {LockClosedIcon,FingerPrintIcon,QrCodeIcon,DevicePhoneMobileIcon,ArrowDownTrayIcon,NoSymbolIcon,ArrowPathRoundedSquareIcon,ArrowUturnLeftIcon,MagnifyingGlassIcon}from'@tuwaio/nova-icons/24/outline';import {jsxs,jsx,Fragment as Fragment$1}from'react/jsx-runtime';import {HashLink,TxProgressIndicator,TxStatusVisual}from'@tuwaio/nova-transactions';import {parseCaip2ChainId,toCaip2ChainId,formatCaip10AccountId,toEvmChainId,parseCaip19AssetId,parseCaip10AccountId,formatBaseUnits,shortAddress,OrbitAdapter,getAdapterFromConnectorType,getConnectorTypeFromName,formatConnectorName,getSolanaCluster,isSameAddress}from'@tuwaio/orbit-core';export{shortAddress}from'@tuwaio/orbit-core';import {useLabels,NovaTransactionsLabelsProvider}from'@tuwaio/nova-transactions/providers';import {MotionConfig,AnimatePresence}from'framer-motion';import {createCheckoutStore}from'@tuwaio/quasar-sdk/checkout';import {useStore}from'zustand';import {SatelliteStoreContext}from'@tuwaio/satellite-react';import {createStore}from'zustand/vanilla';import {NovaConnectProviderContext}from'@tuwaio/nova-connect/hooks';import {encode}from'uqr';var oa=createContext(null),Go=oa.Provider;function E(){let e=useContext(oa);if(!e)throw new Error("useCheckoutContext must be used inside PaymentCheckout");return e}function qe(){return useContext(oa)}var _c=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Qo="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(" "),Fc=new Set(Qo);function Ya(e,t){let a=e==="full"||t,n=[{name:"email",required:true,autoComplete:"email",type:"email"}];return a?[...n,{name:"name",required:true,autoComplete:t?"organization":"name",type:"text"},{name:"country",required:true,autoComplete:"country",type:"country"},{name:"addressLine1",required:true,autoComplete:"address-line1",type:"text"},{name:"addressLine2",required:false,autoComplete:"address-line2",type:"text"},{name:"postalCode",required:false,autoComplete:"postal-code",type:"text"},{name:"city",required:false,autoComplete:"address-level2",type:"text"},...t?Mc():[]]:n}var Mc=()=>[{name:"taxId",required:true,autoComplete:"off",type:"text"},{name:"registrationNumber",required:false,autoComplete:"off",type:"text"}];function jo(e,t,a){let n={};for(let o of Ya(t,a)){let r=e[o.name]?.trim()??"";r?o.type==="email"&&!_c.test(r)?n[o.name]="email":o.type==="country"&&!Fc.has(r.toUpperCase())&&(n[o.name]="country"):o.required&&(n[o.name]="required");}return n}function Yo(e){let t={};for(let[a,n]of Object.entries(e)){let o=n?.trim();o&&(t[a]=a==="country"?o.toUpperCase():o);}return t}function Zo(e){let t=new Intl.DisplayNames([e],{type:"region"});return Qo.map(a=>({code:a,name:t.of(a)??a})).sort((a,n)=>a.name.localeCompare(n.name,e))}var ie="novapay:focus-visible:outline-2 novapay:focus-visible:outline-offset-2 novapay:focus-visible:outline-[var(--tuwa-text-accent)]",Pt=`novapay:inline-flex novapay:h-7 novapay:min-w-7 novapay:items-center novapay:justify-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-1.5 novapay:text-[var(--tuwa-text-primary)] novapay:cursor-pointer novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] ${ie}`,$="novapay:font-mono novapay:tabular-nums",nt="novapay:font-mono novapay:font-bold novapay:uppercase novapay:tracking-[0.12em]",Oe=`${nt} novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-secondary)]`,en=`${nt} novapay:inline-flex novapay:shrink-0 novapay:items-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-1.5 novapay:py-0.5 novapay:text-[10px] novapay:leading-3`,tn={neutral:"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-primary)]",accent:"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",success:"novapay:border-[color-mix(in_srgb,var(--tuwa-success-icon)_35%,transparent)] novapay:bg-[var(--tuwa-success-bg)] novapay:text-[var(--tuwa-success-text)]",pending:"novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]",error:"novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:text-[var(--tuwa-error-text)]"},at=`novapay-title ${$} novapay:m-0 novapay:text-base novapay:font-bold novapay:text-balance novapay:outline-none`,Nt={tabIndex:-1,"data-novapay-heading":""},Jo=`${nt} novapay:box-border novapay:inline-flex novapay:min-h-11 novapay:w-full novapay:min-w-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2 novapay:text-center novapay:text-xs novapay:leading-4 novapay:no-underline novapay:transition-colors novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ie}`,Tt=`tuwa-solid ${Jo} novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-[var(--tuwa-text-on-accent)] novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)]`,ra=`${Jo} novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-standart-button-hover)]`,nn=`${nt} novapay:inline-flex novapay:min-h-7 novapay:shrink-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-2.5 novapay:py-1 novapay:text-[10px] novapay:leading-3 novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ie}`,Xo=`tuwa-solid ${nt} novapay:inline-flex novapay:min-h-8 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:px-3 novapay:py-1.5 novapay:text-center novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-on-accent)] novapay:transition-colors novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ie}`,sa="novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]";function ia(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 er={default:{frame:"tuwa-scanlines novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-col novapay:overflow-hidden novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:h-[680px] novapay:sm:flex-row",aside:"tuwa-scanlines novapay:hidden novapay:w-[286px] novapay:shrink-0 novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-5 novapay:sm:block",main:"novapay:flex novapay:min-h-0 novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:min-h-0 novapay:flex-1 novapay:flex-col novapay:overflow-y-auto"},page:{frame:"tuwa-scanlines novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-1 novapay:flex-col novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:min-h-[calc(var(--novapay-page-floor)_-_2px)] novapay:sm:flex-row",aside:"novapay-page-aside tuwa-scanlines novapay:hidden novapay:w-[clamp(260px,36.4%,320px)] novapay:shrink-0 novapay:flex-col novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-5 novapay:sm:flex",main:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:flex-1 novapay:flex-col"}};function tr(e){return e.length<=7?"novapay:text-[36px]":e.length<=10?"novapay:text-[30px]":e.length<=13?"novapay:text-[24px]":"novapay:text-[20px]"}function dt(){return useNovaIcons().outline}function an(e){return jsx(NovaSetIcon,{solid:"ChevronDownIcon",...e})}function nr(e){return jsx(NovaSetIcon,{solid:"GlobeAltIcon",...e})}function on(e){return jsx(NovaSetIcon,{outline:"ClockIcon",...e})}function ar(e){return jsx(NovaSetIcon,{outline:"DocumentTextIcon",...e})}function yt(e){return jsx(NovaSetIcon,{outline:"ExclamationTriangleIcon",...e})}function or(e){return jsx(NovaSetIcon,{outline:"InformationCircleIcon",...e})}function rr(e){return jsx(NovaSetIcon,{outline:"WalletIcon",...e})}function sr(e){let a=dt().ArrowDownTrayIcon??ArrowDownTrayIcon;return jsx(a,{...e})}function ir(e){let a=dt().ArrowPathRoundedSquareIcon??ArrowPathRoundedSquareIcon;return jsx(a,{...e})}function cr(e){let a=dt().ArrowUturnLeftIcon??ArrowUturnLeftIcon;return jsx(a,{...e})}function lr(e){let a=dt().DevicePhoneMobileIcon??DevicePhoneMobileIcon;return jsx(a,{...e})}function pr(e){let a=dt().FingerPrintIcon??FingerPrintIcon;return jsx(a,{...e})}function ur(e){let a=dt().LockClosedIcon??LockClosedIcon;return jsx(a,{...e})}function mr(e){let a=dt().MagnifyingGlassIcon??MagnifyingGlassIcon;return jsx(a,{...e})}function dr(e){let a=dt().NoSymbolIcon??NoSymbolIcon;return jsx(a,{...e})}function yr(e){let a=dt().QrCodeIcon??QrCodeIcon;return jsx(a,{...e})}var fr={metamask:"MetaMask",walletconnect:"WalletConnect",coinbase:"Coinbase Wallet",okx:"OKX Wallet",trust:"Trust Wallet",injected:"Browser wallet"};function tl(e,t){let a=e.slice(e.indexOf(":")+1).toLowerCase();return a==="injected"?fr.injected:t?.trim()||fr[a]||a.charAt(0).toUpperCase()+a.slice(1)}var Ja=e=>/^data:image\//i.test(e)||/^https:\/\//i.test(e),Za=e=>{let t=typeof e=="string"?e.trim():"";return t&&Ja(t)?t:void 0};function nl(e,t,a){let n=getAdapterFromConnectorType(t),o=e[n];if(!Array.isArray(o))return;let r=o.filter(s=>typeof s=="object"&&s!==null&&typeof s.name=="string"&&getConnectorTypeFromName(n,formatConnectorName(s.name))===t);return a&&r.find(s=>Za(s.icon)===a)||r[0]}var Rt=e=>{let t=parseCaip2ChainId(e)?.namespace;return t==="eip155"||t==="solana"?t:null};function vr(e,t){if(!e?.address)return null;let a=toCaip2ChainId(e.chainId),n=a?Rt(a):null;if(!a||!n)return null;let o=Za(e.icon),r=t?nl(t,e.connectorType,o):void 0;return {address:e.address,chainId:a,family:n,connectorType:e.connectorType,walletId:e.connectorType.slice(e.connectorType.indexOf(":")+1).toLowerCase(),name:tl(e.connectorType,typeof r?.name=="string"?r.name:void 0),icon:o??Za(r?.icon),connection:e}}function Ye(e){return Rt(e.chainId)}function Ue(e,t){return !e||e.family!==Ye(t)?null:formatCaip10AccountId(t.chainId,e.address)??null}function hr(e,t){let a=Ye(e);return a==="solana"||a==="eip155"&&!!t}function Xa(e){let t=a=>String(Number((a/100).toFixed(2)));return e.discountBps>0?{kind:"discount",percent:t(e.discountBps)}:e.markupBps>0?{kind:"markup",percent:t(e.markupBps)}:null}function ve(e){return getChainName(toEvmChainId(e)??e).name}function xr(e){let t=e.assetId?parseCaip19AssetId(e.assetId):void 0;return !t||t.assetNamespace==="slip44"?"native":t.assetReference}var al=new Set(["awaitingPayment","selectMethod","underpaid"]),ol="too_many_payments";function eo(e,t={}){if(t.labelsReady===false&&e.phase!=="error")return "loading";if(e.phase==="unconfirmed")return It(e.error)==="retrying"?"confirm":"unconfirmed";if(t.afterFailure&&e.error?.code==="payment_failed"&&al.has(e.phase))return "failed";let a=e.payerProof==="required"||e.payerProof==="confirming"||e.payerProof==="confirmed"&&!e.error,n=!!(t.confirmWallet&&a);switch(e.phase){case "selectMethod":return n&&!(t.handoff&&t.payWith==="qr")?"confirmWallet":t.handoff&&t.payWith==="qr"?"qr":"method";case "underpaid":return n?"confirmWallet":"underpaid";case "quoting":return e.quote?t.payWith==="qr"||e.quote.payer===null?"qr":"pay":t.confirmWallet?"confirmWallet":"method";case "awaitingPayment":case "submitting":return e.phase==="submitting"&&!e.quote?"confirm":t.payWith==="qr"||e.quote?.payer===null?"qr":"pay";case "confirming":return "confirm";case "cancelled":return e.checkout?.invoice.replacedBy?"replaced":"cancelled";default:return e.phase}}var rl={buyer:"details",method:"method",confirmWallet:"method",pay:"pay",qr:"pay",underpaid:"pay",confirm:"confirm",unconfirmed:"confirm",failed:"confirm"};function gr(e,t={}){let a=rl[e];if(!a)return null;let n=[...t.withDetails||a==="details"?["details"]:[],"method","pay","confirm"],o=n.indexOf(a);return n.map((r,s)=>({key:r,state:s<o?"done":s===o?"current":"upcoming"}))}function br(e={}){return [...e.withDetails?["details"]:[],"method","pay","confirm"].map(a=>({key:a,state:"done"}))}function wr(e,t){let a=s=>s.chainId===t?0:s.featured?1:2,n=new Map;for(let s of e)n.set(s.symbol,[...n.get(s.symbol)??[],s]);let o=[...n].map(([s,i])=>{let c=[...i].sort((l,p)=>a(l)-a(p));return {symbol:s,methods:c,featured:i.some(l=>l.featured),inWallet:!!t&&i.some(l=>l.chainId===t)}}),r=s=>s.inWallet?0:s.featured?1:2;return o.sort((s,i)=>r(s)-r(i))}var sl=new Set(["open","processing","underpaid"]),il=new Set(["loading","error","buyer","method","confirmWallet","pay","qr","failed","underpaid","blocked"]);function En(e,t,a){return sl.has(e)?t==="confirm"||t==="unconfirmed"?"confirming":il.has(t)?e==="underpaid"&&a===false?"closed":"paying":null:null}var cl=[10,5,1];function kr(e,t,a=cl){if(e===null||t<=0)return null;let n=a.filter(o=>e>o*6e4&&t<=o*6e4);return n.length?Math.min(...n):null}var to=6e4;function Cr(e){let{phase:t,quotePayer:a,payer:n}=e;return t!=="awaitingPayment"||!a||n===a?"keep":n?"lock":"release"}function Sr(e){let{open:t,storePayer:a,payer:n,paysRest:o}=e;return !t||n===a?"keep":n&&o?"follow":"leave"}function Pr(e){return e>0&&e<=to}function Nr(e){return e.amlScreening!==false}function ot(e){return e.paymentOnTheWay??!!(e.txKey||e.txHash)}function ft(e,t){let a=t?.invoice?.pendingPayments??0;return e.invoicePaymentOnTheWay??a>0}function Tr({state:e,checkout:t,handedOverAt:a,dueAt:n}){let o=e.paymentSentInTime,r=ot({paymentOnTheWay:e.paymentOnTheWay,txKey:e.txKey??null,txHash:e.txHash??null});if(typeof o=="boolean"&&r)return o;let s=t.invoice.paymentCountsUntil;return s===void 0?a!==null&&a<n:a!==null&&a>=n?false:(e.paymentCountsUntil===void 0?s:e.paymentCountsUntil)!==null}var no="settlement_failed",Rr="tx_already_used";function Ir(e){let t=e?.code,a=e?.reason;return (t==="payment_failed"||t==="payment_mismatch")&&!!a&&a!==no}var ll=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 vt(e){let t=e?.code,a=e?.reason;return a===no?false:t==="payment_mismatch"?true:t==="payment_failed"&&a!==void 0&&ll.has(a)}function Er(e){let t=e?.reason;return vt(e)&&t===Rr}function qt(e,t){let a=t?.invoice?.unresolvedPayments??0;return e.invoicePaymentUnresolved??a>0}function It(e){let t=e?.code,{reason:a,rechecked:n,stillRead:o}=e??{};return t==="payment_failed"&&a==="unresolved_after_24h"?"closed":a===no&&(t==="payment_unconfirmed"||t==="payment_mismatch")?n===true?"settlementRetrying":"settlementFailed":t!=="payment_unconfirmed"?null:a==="nonce_spent_unexplained"?"nonceSpent":a==="unmined_after_24h"||o===true?"unmined":a===Rr?"takenElsewhere":a==="submit_retrying"?"retrying":a==="submit_failed"?"notReceived":a===ol?"invoiceFull":n===true?"rechecked":"contact"}function Lr(e,t){let{txKey:a}=e.error??{};if(a)return a;let n=t?.invoice?.rejectedPayments;return e.txHash??e.txKey??n?.[0]?.txKey??null}function Ar({picked:e,page:t,invoice:a}){return e&&e.page===t?e.locale:t??a??"en"}function _r(e,t){return e.supportEmail?`mailto:${e.supportEmail}?subject=${encodeURIComponent(t)}`:e.website??null}var Fr={nonceSpent:"unconfirmedNonceSpent",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"};function Ln(e,t,a){let n=e.reason;return n==="expired"?t.pay.failedExpired:n==="cancelled"?t.pay.failedCancelled:n==="reverted"?a?c(t.pay.failed,{network:a}):t.method.paymentFailed:t.pay.didNotGoThrough}function ca(e){if(e?.code!=="payment_failed"&&e?.code!=="payment_mismatch")return null;let{txKey:t}=e;return typeof t=="string"&&t?t:null}var ul=new Set(["payer_mismatch","payer_unconfirmed"]);function Ut(e,t,a=""){if(vt(e)){let r=e.reason??"",s=e.unmatched===true;if(r==="quote_changed")return c(t.pay.mismatchChargeUnmatched,{merchant:a});if(r==="too_many_parts")return c(t.pay.mismatchTooManyParts,{merchant:a});if(r==="reference_missing"&&s)return c(t.pay.mismatchNoReferenceUnmatched,{merchant:a});let i=ul.has(r)?s?t.pay.mismatchOtherWalletUnmatched:t.pay.mismatchOtherWallet:s?t.pay.mismatchUnmatchedElsewhere:Er(e)?t.pay.mismatchTakenElsewhere:t.pay.mismatch;return c(i,{merchant:a})}let n=It(e),o=n?Fr[n]:void 0;return o?c(t.outcome[o],{merchant:a}):null}var ml=["buyer","selectMethod","quoting","awaitingPayment"];function ao(e,t,a){if(a==="underpaid")return false;let n=It(t);return ml.includes(e)&&!vt(t)&&!(n&&Fr[n])}function la(e,t,a=""){let n=Ut(e,t,a);if(n!==null)return n;switch(e.code){case "screening_unavailable":return t.pay.screeningUnavailable;case "request_failed":return t.pay.noAnswer;case "amount_out_of_range":case "method_not_found":case "testnet_required":return t.method.methodUnavailable;case "payer_not_expected":return t.method.payerNotExpected;case "payer_is_recipient":return t.method.payerIsRecipient;case "too_many_payments":return c(t.method.tooManyPayments,{merchant:a});case "too_many_payers":return c(t.method.tooManyPayers,{merchant:a});case "native_from_contract":return t.method.nativeFromSmartWallet;case "rate_limited":return t.method.rateLimited;case "price_unavailable":case "price_no_rpc":return t.method.priceUnavailable;case "consent_required":return t.method.consentRequired;case "payer_proof_required":case "payer_proof_declined":return t.payerProof.text;case "payer_proof_invalid":return t.payerProof.invalid;case "payer_proof_unavailable":return t.payerProof.unavailable;case "payment_failed":return Ln(e,t);case "rest_method_mismatch":return t.method.restSameMethod;default:return t.error.generic}}function Mr(e,t){if(!e||t===null)return null;let a=BigInt(e.cryptoAmountExpected)-BigInt(t);return a>0n?a.toString():null}function rn(e,t,a,n,o,r=a.pay.restRateEnded){let s=e?.rateHeldUntil?Date.parse(e.rateHeldUntil):null;if(s===null)return null;if(s<=t)return c(r,{merchant:n});let i=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(s);return c(a.pay.restRateUntil,{time:i,merchant:n})}function Et(e){return parseCaip10AccountId(e)?.address??e}function sn(e,t){let a=Et(e),n=Et(t);return a.startsWith("0x")?a.toLowerCase()===n.toLowerCase():a===n}function Br(e){return e&&/^\d+$/.test(e)&&BigInt(e)>0n?e:null}function Or(e){let t=BigInt(e.cryptoAmount),a=e.received?BigInt(e.received):null;if(a&&t>a&&(t-a)*200n>=a)return true;if(!e.atPaymentRate)return false;let n=BigInt(e.atPaymentRate);return n===0n?false:(t>n?t-n:n-t)*200n>=n}var dl=new Set(["needs_review","refunded","expired","cancelled","blocked","error"]);function Dr(e,t,a){return a?e==="paid"?t!==0:!dl.has(e):true}function qr(e,t){return t.withGas||!e.gasless?"transfer":e.gasless.paymaster&&t.canSponsorCalls?"paymaster":e.gasless.relay?"relay":"transfer"}function Ur(e){let t=BigInt(e.amountToSend),a=BigInt(e.amountDue);return !e.transferFee||t<=a?{send:e.amountToSend,receives:e.amountDue,fee:null}:{send:e.amountToSend,receives:e.amountDue,fee:{amount:String(t-a),percent:String(e.transferFee.bps/100)}}}var pa=10000n,Wr=8n;function Hr(e,t){let a=BigInt(e.cryptoAmountExpected);if(!t||a<=0n)return null;let o=BigInt(t)*(pa+BigInt(e.markupBps))*(pa-BigInt(e.discountBps))*10n**BigInt(e.decimals)*10n**Wr/(100n*pa*pa*a);return Number(o)/10**Number(Wr)}function $r(e,t,a=0n){let n=BigInt(t.amountToSend)+a;return e>=n?null:{have:String(e),need:String(n),short:String(n-e)}}function he(e){return e.family==="eip155"?`eip155:${e.chainId}`:e.chainId}var Vr="novapay:normal-case",xl=3,gl={};function bl(e){let[,t="",a="",n=""]=/^(\s*)([\s\S]*?)(\s*)$/.exec(e)??[];return [t,a,n]}function wl(e,t){let a=e.ownerDocument.createElement("span");a.style.cssText="position:absolute;visibility:hidden;white-space:nowrap;pointer-events:none";for(let[o,r]of t){let s=e.ownerDocument.createElement("span");r&&(s.style.textTransform="none"),s.textContent=o,a.append(s);}e.append(a);let{width:n}=a.getBoundingClientRect();return a.remove(),n}function kl(e,t){let a=getComputedStyle(t),n=[...t.children].filter(s=>s!==e),o=n.reduce((s,i)=>s+i.getBoundingClientRect().width,0),r=(Number.parseFloat(a.columnGap)||0)*n.length;return t.clientWidth-Number.parseFloat(a.paddingLeft)-Number.parseFloat(a.paddingRight)-o-r}function ge({label:e,values:t=gl}){let a=useRef(null),[n,o]=useState(false),[r,s]=useState(xl),i=Object.fromEntries(Object.entries(t).map(([p,m])=>[p,{own:String(m)}])),c=d(e,i).map(p=>typeof p=="string"?[p,false]:[p.own,true]),l=JSON.stringify(c);return useLayoutEffect(()=>{let p=a.current,m=p?.parentElement;if(!p||!m)return;let y=JSON.parse(l),f=()=>{o(wl(p,y)>kl(p,m)+.5),s(d=>Math.max(d,y.length));};if(f(),typeof ResizeObserver>"u")return;let v=new ResizeObserver(f);return v.observe(m),()=>v.disconnect()},[l]),n?jsx("span",{ref:a,className:"novapay:min-w-0",children:jsx("span",{className:"novapay-label-fade",children:c.map(([p,m],y)=>m?jsx("span",{className:Vr,children:p},y):p)},l)}):jsx("span",{ref:a,className:"novapay:min-w-0 novapay:whitespace-nowrap",children:Array.from({length:Math.max(r,c.length)},(p,m)=>{let[y,f]=c[m]??["",false],[v,d,R]=bl(y);return jsxs(Fragment,{children:[v,jsx(MorphText,{className:f?Vr:void 0,children:d}),R]},m)})})}function Y(e,t,a){let n=e.customization.classNames?.[t];return n?.({screen:e.screen,checkoutState:e.state,checkout:e.checkout,...a})}function Ze({children:e,labels:t}){let a=qe(),n=t??a?.labels,o=useLabels(),r=useMemo(()=>({...o,trackingModal:{...o.trackingModal,progressIndicator:{created:n.confirm.sent,processing:n.confirm.confirming,succeed:n.confirm.paid}},statuses:{...o.statuses,confirmed:n.confirm.confirmed,failed:n.confirm.failed},actions:{...o.actions,viewOnExplorer:n.confirm.viewOnExplorer,copy:n.confirm.copyHash},txError:{...o.txError,copied:n.pay.copied}}),[o,n]);return jsx(NovaTransactionsLabelsProvider,{labels:r,children:e})}var $t=(e,t)=>e?Y(e,t):void 0;function _n({walletId:e,icon:t}){let[a,n]=useState(null);return t&&t!==a&&Ja(t)?jsx("img",{src:t,alt:"",onError:()=>n(t),className:"novapay:block novapay:h-full novapay:w-full novapay:object-contain"}):jsx(WalletIcon,{walletName:e})}function He({hash:e,chainId:t,explorerUrl:a,labels:n}){let o=qe(),r=a??(t?o?.adapterFor(t.startsWith("solana:")?"solana":"eip155")?.explorerAddressUrl?.({chainId:t,address:e}):void 0);return jsx(Ze,{labels:n,children:jsx(HashLink,{hash:e,explorerUrl:r,variant:"compact",...o?.customization.childCustomizations?.hashLink})})}function ua({walletId:e,walletIcon:t}){return !e&&!t?jsx(QuasarLoader,{size:48,accent:"var(--tuwa-pending-icon)"}):jsx("span",{className:"novapay-chase novapay:relative novapay:flex novapay:h-20 novapay:w-20 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border-2 novapay:border-[color-mix(in_srgb,var(--tuwa-pending-text)_25%,transparent)]",children:jsx("span",{className:"novapay:block novapay:h-11 novapay:w-11",children:jsx(_n,{walletId:e??"",icon:t})})})}function de({title:e,subtitle:t,children:a}){let n=qe(),o=n?.display==="page";return jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-2.5 novapay:px-5 novapay:py-4",o&&"novapay-page-screen",$t(n,"screen")),children:[jsxs("div",{children:[jsx("h2",{...Nt,className:at,children:typeof e=="string"?jsx(MorphText,{wrap:true,children:e}):e}),t&&jsx("p",{className:cn$1("novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",o&&"novapay-page-subtitle"),children:t})]}),a]})}function Z({children:e}){let t=qe(),a=useRef(null),n=t?.display==="page";return useEffect(()=>{let o=a.current,r=n?o?.ownerDocument.documentElement:o?.closest("[data-novapay-scroll]");if(!o||!r||typeof ResizeObserver>"u")return;let s=()=>r.style.scrollPaddingBottom=!n||getComputedStyle(o).position==="sticky"?`${o.offsetHeight+8}px`:"";s();let i=new ResizeObserver(s);return i.observe(o),()=>{i.disconnect(),r.style.scrollPaddingBottom="";}},[n]),jsx("footer",{ref:a,className:cn$1("tuwa-scanlines novapay:empty:hidden novapay:sticky novapay:bottom-0 novapay:z-10 novapay:flex novapay:flex-col novapay:gap-2 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-5 novapay:pb-3.5 novapay:pt-3 novapay:text-center",n&&"novapay-page-footer",$t(t,"footer")),children:e})}function cn({children:e,id:t}){let a=qe()?.display==="page";return jsx("span",{id:t,className:cn$1(Oe,a&&"novapay-page-group"),children:e})}function X({busy:e,children:t,className:a,...n}){let o=qe(),r=$t(o,"primaryButton"),s=o?.customization.components?.PrimaryButton;return s?jsx(s,{busy:e,className:cn$1(a,r),...n,children:t}):jsxs("button",{type:"button","aria-busy":e||void 0,...n,disabled:n.disabled||e,className:cn$1(Tt,a,r),children:[e&&jsx(QuasarLoader,{size:16,accent:"currentColor"}),typeof t=="string"?jsx(ge,{label:t}):t]})}function ae({children:e,className:t,...a}){let n=qe();return jsx("button",{type:"button",...a,className:cn$1(ra,t,$t(n,"secondaryButton")),children:e})}function ma({className:e,...t}){return jsxs("span",{className:cn$1("novapay:relative novapay:inline-flex novapay:h-4 novapay:w-4 novapay:shrink-0",e),children:[jsx("input",{type:"checkbox",...t,className:cn$1("novapay:peer novapay:m-0 novapay:box-border novapay:h-4 novapay:w-4 novapay:cursor-pointer novapay:appearance-none novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:border-[var(--tuwa-text-secondary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:transition-colors novapay:checked:border-[var(--tuwa-text-accent)] novapay:checked:bg-[var(--tuwa-text-accent)]",ie)}),jsx(DrawnCheck,{className:"novapay:pointer-events-none novapay:absolute novapay:inset-0 novapay:m-auto novapay:h-3 novapay:w-3 novapay:text-[var(--tuwa-bg-primary)] novapay:opacity-0 novapay:peer-checked:opacity-100"})]})}function $e({children:e}){return jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:e})}function xe({children:e,className:t}){let a=qe();return jsx("dl",{className:cn$1("tuwa-scanlines novapay:m-0 novapay:flex novapay:w-full novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-left",t,$t(a,"detailsCard")),children:e})}function Q({children:e}){let t=qe();return jsx("p",{role:"alert",className:cn$1("novapay:m-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-error-text)]",$t(t,"error")),children:e})}function da({error:e}){let t=qe(),a=ca(e);if(!t||!a)return null;let n=t.state.quote??t.checkout?.quote,o=n?he(n.instructions):null,r=n&&o?t.adapterFor(n.instructions.family)?.explorerUrl?.({chainId:o,txKey:a}):void 0;return jsx(Ze,{children:jsx(xe,{children:jsx(H,{name:t.labels.confirm.transaction,children:jsx(HashLink,{hash:a,explorerUrl:r,variant:"compact",...t.customization.childCustomizations?.hashLink})})})})}function Fn({text:e,label:t,copiedLabel:a,children:n}){let[o,r]=useState(false);return useEffect(()=>{if(!o)return;let s=setTimeout(()=>r(false),2e3);return ()=>clearTimeout(s)},[o]),jsxs(Fragment$1,{children:[jsxs("button",{type:"button","aria-label":n?void 0:t,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>r(true),()=>{});},className:cn$1(Pt,"novapay:min-h-6 novapay:min-w-6 novapay:text-xs"),children:[jsx(CopyIcon,{copied:o,className:"novapay:h-3.5 novapay:w-3.5"}),n]}),jsx("span",{role:"status",className:"novapay:sr-only",children:o?a:""})]})}function H({name:e,children:t}){let a=qe();return jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3 novapay:py-2 novapay:text-xs",a?.display==="page"&&"novapay-page-row",$t(a,"detailRow")),children:[jsx("dt",{className:"novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]",children:e}),jsx("dd",{className:cn$1($,"novapay:m-0 novapay:min-w-0 novapay:text-right novapay:break-words"),children:t})]})}function ht({children:e,onClick:t,disabled:a}){return jsx("button",{type:"button",onClick:t,disabled:a,className:cn$1("novapay:disabled:cursor-default novapay:disabled:opacity-50 novapay:min-h-6 novapay:cursor-pointer novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-xs novapay:text-[var(--tuwa-text-accent)] novapay:underline novapay:hover:no-underline",ie),children:e})}var Ol=(e,t,a)=>t==="name"&&a?e.buyer.companyName:e.buyer[t]??t,Dl=(e,t)=>t==="email"?e.buyer.invalidEmail:t==="country"?e.buyer.invalidCountry:e.buyer.required,Wl=new Set(["postalCode","city","taxId","registrationNumber"]),ql=new Set(["name","country","addressLine1","addressLine2"]),Yr=e=>cn$1("novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-[13px] novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:focus:border-[var(--tuwa-text-accent)]",e?"novapay:border-[var(--tuwa-error-icon)]":"novapay:border-[var(--tuwa-text-secondary)] novapay:hover:border-[var(--tuwa-text-primary)]",ie);function Zr(){let{checkout:e,state:t,store:a,labels:n,locale:o,display:r}=E(),[s,i]=useState({}),[c,l]=useState(false),[p,m]=useState(false),[y,f]=useState(false),v=useId(),d=useMemo(()=>Zo(o),[o]);if(!e||e.buyer.collect==="off")return null;let R=e.buyer.collect,h=Ya(R,c),g=jo(s,R,c),x=(S,b)=>i(I=>({...I,[S]:b})),k=async S=>{if(S.preventDefault(),m(true),Object.keys(g).length>0){document.getElementById(`${v}-${Object.keys(g)[0]}`)?.focus();return}f(true),await a.getState().setBuyer(Yo(s),{company:c}),f(false);};return jsxs("form",{noValidate:true,onSubmit:S=>{k(S);},className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(de,{title:n.buyer.title,subtitle:n.buyer.subtitle,children:[jsx("div",{className:"novapay:grid novapay:grid-cols-1 novapay:gap-x-3 novapay:gap-y-3.5 novapay:pt-1 novapay:sm:grid-cols-2",children:h.map((S,b)=>{let I=`${v}-${S.name}`,F=p?g[S.name]:void 0,D=S.type==="country"?jsxs("div",{className:"novapay:relative",children:[jsxs("select",{id:I,autoComplete:S.autoComplete,required:S.required,"aria-invalid":!!F,"aria-describedby":F?`${I}-error`:void 0,value:s.country??"",onChange:w=>x("country",w.target.value),className:cn$1(Yr(!!F),"novapay:cursor-pointer novapay:appearance-none novapay:pr-9",!s.country&&"novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("option",{value:"",children:n.buyer.chooseCountry}),d.map(w=>jsx("option",{value:w.code,children:w.name},w.code))]}),jsx(an,{"aria-hidden":true,className:"novapay:pointer-events-none novapay:absolute novapay:top-1/2 novapay:right-3 novapay:h-4 novapay:w-4 novapay:-translate-y-1/2 novapay:text-[var(--tuwa-text-secondary)]"})]}):jsx("input",{id:I,type:S.type,autoComplete:S.autoComplete,required:S.required,"aria-invalid":!!F,"aria-describedby":F?`${I}-error`:void 0,value:s[S.name]??"",onChange:w=>x(S.name,w.target.value),className:Yr(!!F)});return jsxs(Fragment,{children:[jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",!Wl.has(S.name)&&(r==="page"&&ql.has(S.name)?"novapay:sm:@max-[519px]:col-span-2":"novapay:sm:col-span-2")),children:[jsxs("label",{htmlFor:I,className:"novapay:text-xs novapay:font-medium novapay:text-[var(--tuwa-text-primary)]",children:[Ol(n,S.name,c),S.required&&jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]}),!S.required&&jsxs("span",{className:"novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:[" ","(",n.buyer.optional,")"]})]}),D,F&&jsx("span",{id:`${I}-error`,className:"novapay:text-[11px] novapay:text-[var(--tuwa-error-text)]",children:Dl(n,F)})]}),b===0&&e.buyer.companyInvoice&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:text-[13px] novapay:transition-colors novapay:sm:col-span-2",c?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]"),children:[jsx(ma,{checked:c,onChange:w=>l(w.target.checked)}),jsx("span",{className:"novapay:font-semibold",children:n.buyer.companyInvoice})]})]},S.name)})}),t.error&&t.phase==="buyer"&&jsx(Q,{children:n.buyer.refused})]}),jsx(Z,{children:jsx(X,{type:"submit",busy:y,children:n.buyer.continue})})]})}function Xr({steps:e,labels:t,className:a,stepClassName:n}){let o=e.findIndex(p=>p.state==="current"),r=e.map(p=>t.steps[p.key]).join(""),s=useRef(null),i=useRef(null),[c$1,l]=useState(false);return useEffect(()=>{let p=s.current,m=i.current;if(!p||!m||typeof ResizeObserver>"u")return;let y=()=>l(m.offsetWidth+e.length*32+(e.length-1)*24>p.clientWidth);y();let f=new ResizeObserver(y);return f.observe(p),()=>f.disconnect()},[r,e.length]),jsxs("nav",{ref:s,"aria-label":t.steps.label,className:cn$1("novapay:relative novapay:min-w-0 novapay:flex-1",a),children:[jsx("span",{"aria-hidden":true,className:"novapay:invisible novapay:absolute novapay:h-0 novapay:w-0 novapay:overflow-hidden",children:jsx("span",{ref:i,className:cn$1(nt,"novapay:whitespace-nowrap novapay:text-[11px]"),children:r})}),jsx("ol",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:items-center novapay:gap-1.5 novapay:p-0",children:e.map((p,m)=>{let y=t.steps[p.key];return jsxs("li",{"aria-current":p.state==="current"?"step":void 0,className:cn$1("novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-1.5",m>0&&"novapay:flex-auto",n?.(p,m)),children:[m>0&&jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-px novapay:min-w-2 novapay:flex-1 novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",p.state==="upcoming"?"novapay:bg-[var(--tuwa-border-primary)]":"novapay:bg-[var(--tuwa-success-icon)]")}),jsx("span",{"aria-hidden":true,className:cn$1($,"novapay:box-border novapay:flex novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:text-[10px] novapay:font-bold",p.state==="done"&&"novapay:border-[var(--tuwa-success-icon)] novapay:bg-[var(--tuwa-success-icon)] novapay:text-white",p.state==="current"&&"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",p.state==="upcoming"&&"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-secondary)]"),children:p.state==="done"?jsx(DrawnCheck,{className:"novapay:h-3 novapay:w-3"}):m+1}),jsx("span",{className:cn$1(nt,"novapay:truncate novapay:text-[11px] novapay:leading-4",p.state==="current"?"novapay:text-[var(--tuwa-text-primary)]":"novapay:text-[var(--tuwa-text-secondary)]",c$1&&p.state!=="current"&&"novapay:sr-only"),children:p.state==="current"?jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:sr-only",children:c(t.steps.progress,{current:o+1,total:e.length,name:y})}),jsx("span",{"aria-hidden":true,children:y})]}):y})]},p.key)})})]})}function Re(e,t=2){let a=e.startsWith("-"),n=(a?e.slice(1):e).padStart(t+1,"0");return `${a?"-":""}${n.slice(0,-t)}.${n.slice(-t)}`}var es=e=>new Intl.NumberFormat(e).formatToParts(1.1).find(t=>t.type==="decimal")?.value??".";function ye(e,t){let[a="0",n=""]=(typeof e=="number"?e.toFixed(2):e.trim()).split("."),o=a.startsWith("-"),r=new Intl.NumberFormat(t).format(BigInt(o?a.slice(1):a));return `${o?"-":""}${r}${es(t)}${n.padEnd(2,"0").slice(0,2)}`}function le(e,t,a){let n=BigInt(e),o=n<0n,r=o?-n:n,s=10n**BigInt(t),i=new Intl.NumberFormat(a).format(r/s),c=(r%s).toString().padStart(t,"0").replace(/0+$/,"").padEnd(2,"0");return `${o?"-":""}${i}${es(a)}${c}`}function va(e,t,a){let n=10n**BigInt(Math.max(t-6,0)),o=(BigInt(e)+n/2n)/n*n;return o===0n?null:le(o.toString(),t,a)}function ha(e,t){return formatBaseUnits(e,t)??"0"}var Kt=e=>String(e).padStart(2,"0");function st(e){let t=Math.max(0,Math.floor(e/1e3)),a=Math.floor(t/86400),n=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),r=t%60;return a>0?`${a}d ${Kt(n)}:${Kt(o)}`:n>0?`${Kt(n)}:${Kt(o)}:${Kt(r)}`:`${Kt(o)}:${Kt(r)}`}function pn(e){let t=e.lineItems.reduce((r,s)=>r+BigInt(s.netMinor),0n),a=BigInt(e.totalMinor??t.toString()),n=a-t,o=[...new Set(e.lineItems.filter(r=>Number(r.taxRate)>0).map(r=>r.taxRate))];return {subtotal:Re(t.toString()),tax:n>0n?Re(n.toString()):null,rate:o.length===1?String(Number(o[0])):null,total:Re(a.toString())}}var zl=e=>{try{return new URL(e).host}catch{return e}};function xa({compact:e=false}){let{checkout:t,state:a,labels:n,display:o}=E(),[r,s]=useState(false);if(!t)return null;let{merchant:i,invoice:c}=t,l=e?"novapay:h-8 novapay:w-8":"novapay:h-9 novapay:w-9";return jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-2.5",children:[a.logoUrl&&!r?jsx("img",{src:a.logoUrl,alt:"",onError:()=>s(true),className:cn$1(l,"novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:object-contain")}):jsx("span",{"aria-hidden":true,className:cn$1(l,$,"novapay:flex novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-text-primary)] novapay:text-[15px] novapay:font-bold novapay:text-[var(--tuwa-bg-primary)]"),children:i.name.trim().charAt(0).toUpperCase()}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:cn$1("novapay:text-sm novapay:font-semibold",o==="page"&&!e?"novapay:line-clamp-2 novapay:break-words":"novapay:truncate"),children:i.name}),e?c.number&&jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c.number}):i.website&&jsx("a",{href:i.website,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:truncate novapay:text-xs novapay:text-[var(--tuwa-text-secondary)] novapay:hover:underline",ie),children:zl(i.website)})]}),c.environment==="test"&&jsxs("span",{title:n.summary.testHint,className:cn$1(en,tn.pending,"novapay:ml-auto"),children:[n.summary.test,jsxs("span",{className:"novapay:sr-only",children:[": ",n.summary.testHint]})]})]})}function ro({checkout:e,labels:t}){let{merchant:a}=e,n=a.seller,o=[[t.summary.terms,a.links.terms],[t.summary.refundPolicy,a.links.refundPolicy],[t.summary.privacy,a.links.privacy]].filter(r=>!!r[1]);return jsxs("div",{className:"tuwa-scanlines novapay:flex novapay:flex-col novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:[n?.legalName&&jsx("span",{className:"novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)]",children:n.legalName}),(n?.address||n?.country)&&jsx("span",{children:[n.address,n.country].filter(Boolean).join(", ")}),n?.registrationNumber&&jsxs("span",{children:[t.summary.registration," ",n.registrationNumber]}),n?.taxId&&jsxs("span",{children:[t.summary.taxId," ",n.taxId]}),a.supportEmail&&jsx("a",{href:`mailto:${a.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ie),children:a.supportEmail}),o.length>0&&jsx("span",{className:"novapay:flex novapay:flex-wrap novapay:gap-x-3",children:o.map(([r,s])=>jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ie),children:r},r))}),jsx("span",{children:c(t.summary.sellerRole,{seller:n?.legalName||a.name})})]})}function os(){let{checkout:e,labels:t,locale:a,now:n,screen:o,display:r}=E(),s=e?.invoice.dueAt,i=e&&En(e.invoice.status,o,e.invoice.restPayable);if(!e||!s||!i)return null;let c$1=new Intl.DateTimeFormat(a,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(s));return jsxs("div",{className:cn$1("tuwa-scanlines novapay:flex novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5",r==="page"&&"novapay-page-deadline"),children:[jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-0.5",children:[jsx("span",{className:Oe,children:i==="closed"?t.summary.refundAfter:t.summary.payWithin}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:i==="closed"?c$1:c(t.summary.until,{date:c$1})})]}),jsx("span",{role:"timer",className:cn$1($,"novapay:shrink-0 novapay:whitespace-nowrap novapay:text-lg novapay:font-bold"),children:st(Date.parse(s)-n)})]})}function rs(){let{checkout:e,labels:t,locale:a}=E();if(!e)return null;let{invoice:n}=e,o=pn(n);return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3.5",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2.5",children:[n.number&&jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3",children:[jsx("span",{className:Oe,children:t.summary.invoice}),jsx("span",{className:cn$1($,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-2.5 novapay:p-0",children:n.lineItems.map((r,s)=>jsxs("li",{className:"novapay:flex novapay:justify-between novapay:gap-2 novapay:text-[13px]",children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:r.name}),r.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:r.description}),jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:r.quantity,price:ye(r.unitPrice,a)})})]}),jsx("span",{className:$,children:ye(Re(r.netMinor),a)})]},s))})]}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:border-t novapay:border-dashed novapay:border-[var(--tuwa-border-primary)] novapay:pt-2.5 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.tax,a)})]})]})]})}function Ql(){let e=E(),{checkout:t,labels:a,locale:n}=e;return t?jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between",Y(e,"total")),children:[jsx("span",{className:cn$1(Oe,"novapay:text-[var(--tuwa-text-primary)]"),children:a.summary.total}),jsxs("span",{className:cn$1($,"novapay:text-[22px] novapay:font-bold"),children:[ye(pn(t.invoice).total,n)," ",jsx("span",{className:"novapay:text-[13px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]}):null}function ss(){let{checkout:e,labels:t}=E();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(ur,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:shrink-0"}),t.summary.secured]}),e?.merchant.supportEmail&&jsxs("span",{children:[t.summary.help,":"," ",jsx("a",{href:`mailto:${e.merchant.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ie),children:e.merchant.supportEmail})]})]})}function ga({label:e,children:t,className:a,buttonClassName:n,growsUp:o=false}){let[r,s]=useState(false),i=useId();return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-2",a),children:[jsxs("button",{type:"button","aria-expanded":r,"aria-controls":i,onClick:()=>s(c=>!c),className:cn$1("novapay:inline-flex novapay:cursor-pointer novapay:items-center novapay:gap-1 novapay:self-start novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)] novapay:hover:text-[var(--tuwa-text-primary)]",ie,n),children:[e,jsx(an,{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:transition-transform novapay:motion-reduce:transition-none",r!==o&&"novapay:rotate-180")})]}),jsx("div",{id:i,hidden:!r,children:t})]})}var ts=5;function jl(){let e=E(),{checkout:t,labels:a,locale:n}=e;if(!t)return null;let o=ye(pn(t.invoice).total,n);return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",Y(e,"total")),children:[jsx("span",{className:Oe,children:a.summary.total}),jsxs("span",{className:cn$1($,"novapay:flex novapay:flex-wrap novapay:items-baseline novapay:gap-x-2 novapay:gap-y-1 novapay:font-bold",tr(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 is="novapay:flex novapay:justify-between novapay:gap-3 novapay:px-3 novapay:py-2";function ns({line:e}){let{labels:t,locale:a}=E(),n=ye(Re(e.netMinor),a),o=ye(e.unitPrice,a);return jsxs("li",{className:cn$1(is,"novapay:text-[13px]"),children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:e.name}),e.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:e.description}),(Number(e.quantity)!==1||o!==n)&&jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:e.quantity,price:o})})]}),jsx("span",{className:cn$1($,"novapay:shrink-0"),children:n})]})}function Yl(){let{checkout:e,labels:t,locale:a}=E();if(!e)return null;let{invoice:n}=e,o=pn(n),r=o.tax?ts-1:ts,s=n.lineItems,i=s.length>r?s.slice(0,r-1):s,c$1=s.slice(i.length);return !n.number&&s.length===0?null:jsxs("div",{className:"tuwa-scanlines novapay:flex novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)]",children:[n.number&&jsxs("div",{className:cn$1(is,"novapay:items-baseline"),children:[jsx("span",{className:Oe,children:t.summary.invoice}),jsx("span",{className:cn$1($,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),i.length>0&&jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:i.map((l,p)=>jsx(ns,{line:l},p))}),c$1.length>0&&jsx(ga,{label:`+${c$1.length} \xB7 ${t.summary.showOrder}`,className:"novapay:px-3 novapay:py-2",buttonClassName:"novapay:min-h-6",children:jsx("ul",{className:"novapay:-mx-3 novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:c$1.map((l,p)=>jsx(ns,{line:l},p))})}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.tax,a)})]})]})]})}function Zl(){let{checkout:e,labels:t}=E();return e?jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx(xa,{}),jsx("div",{className:"novapay:mt-6",children:jsx(jl,{})}),jsx("div",{className:"novapay:mt-5",children:jsx(Yl,{})}),jsxs("div",{className:"novapay:mt-auto novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-5",children:[jsx(os,{}),jsx(ga,{label:t.summary.sellerDetails,buttonClassName:"novapay:min-h-6",growsUp:true,children:jsx(ro,{checkout:e,labels:t})}),jsx(ss,{})]})]}):null}function cs(){let{checkout:e,labels:t,display:a}=E();return e?a==="page"?jsx(Zl,{}):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(xa,{}),jsx(ga,{label:t.summary.sellerDetails,children:jsx(ro,{checkout:e,labels:t})})]}),jsx(os,{}),jsx("div",{className:"novapay:-mr-2.5 novapay:min-h-0 novapay:flex-1 novapay:overflow-y-auto novapay:pr-2.5",children:jsx(rs,{})}),jsx(Ql,{}),jsx(ss,{})]}):null}function ls({className:e}={}){let{checkout:t,labels:a,locale:n,now:o,screen:r}=E();if(!t)return null;let{invoice:s}=t,i=pn(s),c=s.dueAt&&En(s.status,r)?Date.parse(s.dueAt):null;return jsxs("div",{className:cn$1("tuwa-scanlines novapay:mx-4 novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-3",e),children:[jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsxs("span",{className:cn$1($,"novapay:text-[22px] novapay:font-bold"),children:[ye(i.total,n)," ",jsx("span",{className:"novapay:text-xs novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:s.currency})]}),c&&jsxs("span",{role:"timer",className:cn$1($,"novapay:flex novapay:items-center novapay:gap-1 novapay:whitespace-nowrap novapay:text-xs novapay:font-bold"),children:[jsx(on,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-secondary)]"}),st(c-o)]})]}),jsx(ga,{label:`${b(i.tax?{one:a.summary.compactOne,other:a.summary.compact}:{one:a.summary.compactNoTaxOne,other:a.summary.compactNoTax},s.lineItems.length,n,i.tax?{tax:ye(i.tax,n)}:{})} \xB7 ${a.summary.showOrder}`,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-1",children:[jsx(rs,{}),jsx(ro,{checkout:t,labels:a})]})})]})}function us({locale:e$1,labels:t,receiptIssued:a,onSelect:n,className:o}){let[r,s]=useState(false),i=e.find(g=>g.code===e$1)??e[0],[c$1,l]=useState(0),p=useId(),m=useRef(null),y=useRef(null),f=useRef(null);useEffect(()=>{if(!r)return;f.current?.focus();let g=x=>{m.current?.contains(x.target)||s(false);};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[r]);let v=()=>{l(Math.max(0,e.indexOf(i))),s(true);},d=()=>{s(false),y.current?.focus();},R=g=>{d(),g!==i.code&&n(g);},h=g=>{let x=e.length-1,k={ArrowDown:()=>Math.min(x,c$1+1),ArrowUp:()=>Math.max(0,c$1-1),Home:()=>0,End:()=>x};k[g.key]?(g.preventDefault(),l(k[g.key]())):g.key==="Enter"||g.key===" "?(g.preventDefault(),R(e[c$1].code)):(g.key==="Escape"||g.key==="Tab")&&(g.preventDefault(),g.stopPropagation(),d());};return jsxs("div",{ref:m,className:cn$1("novapay:relative",o),children:[jsxs("button",{ref:y,type:"button","aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?`${p}-list`:void 0,className:cn$1(Pt,nt,"novapay:text-[11px]"),onClick:()=>r?d():v(),onKeyDown:g=>{g.key==="ArrowDown"&&!r&&(g.preventDefault(),v());},children:[jsx(nr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),jsx("span",{children:i.short}),jsxs("span",{className:"novapay:sr-only",children:[", ",c(t.language.button,{language:i.name})]}),jsx(an,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"})]}),r&&jsxs("div",{className:"tuwa-scanlines novapay:absolute novapay:right-0 novapay:top-full novapay:z-20 novapay:mt-1.5 novapay:w-60 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-1.5",children:[jsx("span",{id:`${p}-title`,className:cn$1(Oe,"novapay:block novapay:px-2.5 novapay:py-1"),children:t.language.title}),jsx("ul",{ref:f,id:`${p}-list`,role:"listbox",tabIndex:-1,"aria-labelledby":`${p}-title`,"aria-activedescendant":`${p}-${e[c$1].code}`,onKeyDown:h,className:cn$1("novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-0.5 novapay:p-0",ie),children:e.map((g,x)=>{let k=g.code===i.code;return jsxs("li",{id:`${p}-${g.code}`,role:"option","aria-selected":k,lang:g.code,onClick:()=>R(g.code),onPointerMove:()=>l(x),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]",x===c$1&&"novapay:bg-[var(--tuwa-bg-muted)]","novapay:text-[var(--tuwa-text-primary)]",k&&"novapay:font-semibold"),children:[jsx("span",{"aria-hidden":true,className:cn$1($,"novapay:w-5 novapay:text-[11px]"),children:g.short}),jsx("span",{children:g.name}),k&&jsx(DrawnCheck,{className:"novapay:ml-auto novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-accent)]"})]},g.code)})}),jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:px-2.5 novapay:pb-1 novapay:pt-2 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:a?t.language.noteAfterPaid:t.language.note})]})]})}var ms=(e,t)=>gr(e.screen,{withDetails:t})??(e.screen==="paid"?br({withDetails:t}):null);function ds(e,t,a){let n=e.customization.components?.Stepper??Xr;return jsx(n,{steps:t,labels:e.labels,className:cn$1(a,Y(e,"stepper")),stepClassName:(o,r)=>Y(e,"step",{step:o,index:r})})}function ys({title:e,withDetails:t}){let a=E(),{labels:n,locale:o,setLocale:r,close:s,state:i}=a,c=a.display==="page",l=a.customization.config?.showSteps===false?null:ms(a,t),p=Y(a,"header"),m=a.customization.handlers?.onLocaleChange,y=jsxs("div",{className:"novapay:ml-auto novapay:flex novapay:shrink-0 novapay:items-center novapay:gap-2",children:[jsx(us,{locale:o,labels:n,receiptIssued:!!i.receiptUrl,onSelect:f=>{m?m({locale:f,proceed:()=>r(f)}):r(f);}}),s&&jsx("button",{type:"button","aria-label":n.common.close,onClick:s,className:Pt,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]});return jsxs(Fragment$1,{children:[jsxs("header",{className:cn$1("novapay:hidden novapay:items-center novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:py-3.5 novapay:pl-5 novapay:pr-4 novapay:sm:flex",c&&"novapay-page-header",p),children:[l?ds(a,l):e&&jsx("h2",{className:cn$1($,"novapay:m-0 novapay:flex-1 novapay:text-[15px] novapay:font-bold"),children:e}),y]}),jsxs("header",{className:cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-4 novapay:pb-3 novapay:pt-1.5 novapay:sm:hidden",c&&"novapay-page-header-phone",p),children:[jsx(xa,{compact:true}),y]})]})}function fs({withDetails:e}){let t=E();if(t.customization.config?.showSteps===false)return null;let a=ms(t,e);return a?ds(t,a,"novapay:px-4 novapay:pt-3.5"):null}var op=new Set(["paid","needs_review","refunded","partially_refunded"]);function dn(){let{state:e,locale:t,adapterFor:a}=E(),o=(e.invoiceStatus&&op.has(e.invoiceStatus)?e.checkout?.quote:null)??e.quote,r=o?he(o.instructions):null,s=e.txHash??e.txKey,i=o?.payer?parseCaip10AccountId(o.payer)?.address:void 0,c=(e.checkout?.invoice.payments??[]).map(l=>{let p=l.chainId?Rt(l.chainId):null;return {txKey:l.txKey,amount:l.symbol&&l.decimals!==null?`${le(l.amount,l.decimals,t)} ${l.symbol}`:null,at:Date.parse(l.at),explorerUrl:p&&l.chainId?a(p)?.explorerUrl?.({chainId:l.chainId,txKey:l.txKey}):void 0}});return {network:r?ve(r):null,amount:o?`${le(o.amountToSend,o.decimals,t)} ${o.instructions.symbol}`:null,paidAmount:o?`${le(o.amountDue===o.cryptoAmountExpected?o.amountToSend:o.cryptoAmountExpected,o.decimals,t)} ${o.instructions.symbol}`:null,txKey:s,lastOfParts:o?o.amountDue!==o.cryptoAmountExpected:false,transfers:c,explorerUrl:o&&r&&s?a(o.instructions.family)?.explorerUrl?.({chainId:r,txKey:s}):void 0,from:i?shortAddress(i):null,fromAddress:i??null,fromUrl:o&&r&&i?a(o.instructions.family)?.explorerAddressUrl?.({chainId:r,address:i}):void 0}}var io=new WeakMap,ip=500;function bt(e,t){let a=io.get(e)?.get(t);if(a)return a.leftAt===null||Date.now()-a.leftAt<ip?a.value:void 0}function Bn(e,t,a,n=true){let o=io.get(e)??new Map;o.set(t,{value:a,leftAt:n?Date.now():null}),io.set(e,o);}function Ke(e,t){let{store:a}=E(),[n,o]=useState(()=>bt(a,e)??t);return useEffect(()=>(o(t),Bn(a,e,t,false),()=>Bn(a,e,t)),[a,e,t]),n}var vs="actionKind",lp="actionLabel",ka="novapay-action-arrives";function yn(e,t){let{store:a,customization:n}=E(),[o]=useState(()=>e==="primary"&&bt(a,vs)==="secondary"&&!n.config?.animation?.disabled);return Ke(vs,e??"none"),{label:Ke(lp,e?t:"")||t,arrives:o}}function xs({tone:e,children:t}){let a=E(),n=Ke("chipTone",e),o=Ke("chipLabel",t);return jsx("span",{className:cn$1(en,"novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",tn[n],Y(a,"statusChip",{tone:e})),children:jsx(MorphText,{children:o})})}var gs=["................",".....######.....","...##########...","..############..",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.","..############..","...##########...",".....######.....","................"],mp=["................","................","................","................","................","..........##....",".........###....","....##..###.....","....######......",".....####.......","......##........","................","................","................","................","................"],dp=["................","................","................","................","....##....##....","....###..###....",".....######.....","......####......","......####......",".....######.....","....###..###....","....##....##....","................","................","................","................"],Ca=e=>e.flatMap((t,a)=>[...t].flatMap((n,o)=>n==="."?[]:[{x:o,y:a}])),bs=({x:e,y:t})=>`${e},${t}`,ws=(e,t)=>{let a=new Set(t.map(bs));return e.filter(n=>!a.has(bs(n)))},Cs={check:ws(Ca(gs),Ca(mp)),cross:ws(Ca(gs),Ca(dp))},ks=/M(\d+) (\d+)h(\d+)v1h-\3z/g;function Ss(e){let t=new Map,a=(n,o)=>t.set(`${n},${o}`,{x:n,y:o});for(let n of e){if("d"in n){if(n.d.replace(ks,"")!=="")continue;for(let[,r,s,i]of n.d.matchAll(ks))for(let c=0;c<Number(i);c++)a(Number(r)+c,Number(s));continue}if([n.x,n.y,n.width,n.height].every(Number.isInteger))for(let r=0;r<n.height;r++)for(let s=0;s<n.width;s++)a(n.x+s,n.y+r);}return [...t.values()]}function Ps(e,t,a){if(t.length===0)return [];let n=Math.PI*2,o=({x:i,y:c})=>Math.atan2(c-a.y,i-a.x),r=(i,c)=>{let l=Math.abs(i-c)%n;return l>Math.PI?n-l:l},s=t.map(i=>({source:i,at:o(i)}));return e.map(i=>{let c=o(i);return s.reduce((l,p)=>r(p.at,c)<r(l.at,c)?p:l).source})}var co="mark",bp={paid:{mark:"check",tone:"novapay:text-[var(--tuwa-success-icon)]"},failed:{mark:"cross",tone:"novapay:text-[var(--tuwa-error-icon)]"},cancelled:{mark:"cross",tone:"novapay:text-[var(--tuwa-text-secondary)]"}},wp={unconfirmed:{Icon:yt,tone:"novapay:text-[var(--tuwa-pending-icon)]"},underpaid:{Icon:yt,tone:"novapay:text-[var(--tuwa-pending-icon)]"},needs_review:{Icon:mr,tone:"novapay:text-[var(--tuwa-info-icon)]"},refunded:{Icon:cr,tone:"novapay:text-[var(--tuwa-info-icon)]"},expired:{Icon:on,tone:"novapay:text-[var(--tuwa-text-secondary)]"},replaced:{Icon:ir,tone:"novapay:text-[var(--tuwa-info-icon)]"},blocked:{Icon:dr,tone:"novapay:text-[var(--tuwa-error-icon)]"}},Rs={waiting:"processing",paid:"succeed",failed:"failed"};function kp(e,t){let a=e.viewBox.baseVal,n=e.getBoundingClientRect();if(!a||a.width===0||n.width===0)return [];let o=(c,l)=>Number(c.getAttribute(l)??0),r=c=>!c.closest("defs, clipPath, mask"),s=[...[...e.querySelectorAll("rect")].filter(r).map(c=>({x:o(c,"x"),y:o(c,"y"),width:o(c,"width"),height:o(c,"height")})),...[...e.querySelectorAll("path")].filter(r).map(c=>({d:c.getAttribute("d")??""}))],i=n.width/a.width;return Ss(s).map(({x:c,y:l})=>({x:n.left-t.left+(c+.5)*i,y:n.top-t.top+(l+.5)*i}))}function Cp(e,t,a){let n=[...e.querySelectorAll("[data-px]")],o=e.viewBox.baseVal,r=e.getBoundingClientRect();if(n.length===0||!o||o.width===0||r.width===0)return;let s=r.width/o.width,i=n.map(p=>({x:r.left-t.left+(Number(p.getAttribute("x")??0)+.5)*s,y:r.top-t.top+(Number(p.getAttribute("y")??0)+.5)*s})),c=Ps(i,a,{x:t.width/2,y:t.height/2});if(c.length===0)return;let l=p=>`${Math.round(p/s*100)/100}px`;n.forEach((p,m)=>{p.style.setProperty("--nova-px-x",l(c[m].x-i[m].x)),p.style.setProperty("--nova-px-y",l(c[m].y-i[m].y));});}function Sp({mark:e,moves:t,className:a}){return jsx("svg",{viewBox:`0 0 ${16} ${16}`,shapeRendering:"crispEdges",fill:"currentColor","aria-hidden":"true",className:cn$1("novapay:block",a),"data-motion":t?"assemble":void 0,children:Cs[e].map(({x:n,y:o})=>jsx("rect",{x:n,y:o,width:1,height:1,"data-px":"",style:pixelFlight(n,o)},`${n}-${o}`))})}function Is({kind:e,className:t}){let a=E(),{store:n,customization:o}=a,{look:r}=useNovaIcons(),s=useRef(null),i=useRef(null),c=!o.config?.animation?.disabled;useLayoutEffect(()=>{let h=s.current,g=h?.querySelector("svg")??null,x=h?.getBoundingClientRect(),k=i.current??bt(n,co)??null;g&&x&&c&&k&&k.kind!==e&&Cp(g,x,k.pixels);let S={kind:e,pixels:g&&x?kp(g,x):[]};return i.current=S,Bn(n,co,S,false),()=>Bn(n,co,S)},[e,n,c]);let l=o.childCustomizations?.statusVisual,p=e in Rs?Rs[e]:null,m=p&&cn$1(l?.iconClassNames?.icon,l?.iconClassNames?.statusOverrides?.[p]),y=bp[e],f=wp[e],v=o.components?.StatusIcon,d=p?void 0:Y(a,"statusIcon",{kind:e}),R;if(!p&&v)R=jsx(v,{kind:e,className:d});else {if(p&&r!=="pixel")return jsx(TxStatusVisual,{isProcessing:e==="waiting",isSucceed:e==="paid",isFailed:e==="failed",...l,className:cn$1(t,l?.className)});e==="waiting"?R=jsx(QuasarLoader,{size:64,accent:"var(--tuwa-pending-icon)",className:cn$1("novapay:text-[var(--tuwa-text-primary)]",m)}):y&&r==="pixel"?R=jsx(Sp,{mark:y.mark,moves:c,className:cn$1(p?"novapay:h-16 novapay:w-16":"novapay:h-12 novapay:w-12",y.tone,m,d)}):y?R=jsx(DrawnCross,{variant:"disc",className:cn$1("novapay:h-12 novapay:w-12",y.tone,d)}):f&&(R=jsx(f.Icon,{"aria-hidden":true,className:cn$1("novapay:h-12 novapay:w-12",f.tone,d),...c&&r==="pixel"?{motion:"assemble"}:{}}));}return jsx("div",{className:cn$1("novapay:flex novapay:justify-center novapay:py-4",t,p&&l?.className),children:jsx("span",{ref:s,className:"novapay:relative novapay:flex novapay:h-16 novapay:w-16 novapay:items-center novapay:justify-center",children:R})})}function Ls({children:e,className:t}){let a=Ke("title",e);return jsx("h2",{...Nt,"aria-label":e,className:cn$1(at,t),children:jsx(MorphText,{wrap:true,children:a})})}function At({mark:e,tone:t,chip:a,title:n,amount:o,note:r}){let{display:s}=E(),i=s==="page",c=Ke("amount",o??""),l=Ke("note",r??"");return jsxs(Fragment$1,{children:[jsx(Is,{kind:e,className:i?"novapay-page-visual":void 0}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:items-center",children:[jsx(xs,{tone:t,children:a}),jsx(Ls,{className:"novapay:mt-2",children:n}),o&&jsx("p",{"aria-label":o,className:cn$1($,"novapay:m-0 novapay:mt-2 novapay:text-2xl novapay:font-bold",i&&"novapay-page-amount"),children:jsx(MorphText,{children:c||o})}),r&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:jsx(MorphText,{wrap:true,children:l||r})})]})]})}var Fs="steps";function fn({state:e}){let{store:t,customization:a}=E(),n=a.childCustomizations,[o]=useState(()=>bt(t,Fs)!==void 0),r=Ke(Fs,e),s=jsx(TxProgressIndicator,{isProcessing:r==="processing",isSucceed:r==="succeed",isConfirmed:r==="succeed",isFailed:r==="failed",...n?.progressIndicator,className:cn$1("novapay:max-w-sm",n?.progressIndicator?.className)});return o?jsx(AnimatePresence,{initial:false,children:s}):s}var Fp=new Set(["open","underpaid"]);function Ds(){let{checkout:e,state:t,labels:a,close:n,customization:o,now:r,handedOverAt:s,display:i}=E(),c$1=i==="page",l=o.childCustomizations,p=dn(),m=e?.invoice.dueAt?Date.parse(e.invoice.dueAt):null,y=t.invoiceStatus??e?.invoice.status,f=ot(t),v=!f&&ft(t,e),d=e!==null&&(f||v)&&Fp.has(y??"")&&m!==null&&r>=m,R=d&&Tr({state:t,checkout:e,handedOverAt:s,dueAt:m}),h=It(t.error)==="retrying",g=yn(n?"secondary":null,a.common.close);return jsxs(Ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",c$1&&"novapay-page-status"),children:[jsx(At,{mark:"waiting",tone:"pending",chip:a.status.pending,title:a.confirm.title,amount:p.amount,note:p.network?c(a.confirm.hint,{network:p.network}):null}),jsx(fn,{state:"processing"}),jsxs(xe,{className:"novapay:max-w-sm",children:[p.network&&jsx(H,{name:a.confirm.network,children:p.network}),p.txKey&&jsx(H,{name:a.confirm.transaction,children:jsx(HashLink,{hash:p.txKey,explorerUrl:p.explorerUrl,variant:"compact",...l?.hashLink})}),p.fromAddress&&jsx(H,{name:a.confirm.from,children:jsx(HashLink,{hash:p.fromAddress,explorerUrl:p.fromUrl,variant:"compact",...l?.hashLink})})]}),jsx("p",{role:"status",className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",c$1&&"novapay:mt-auto"),children:jsx(MorphText,{wrap:true,children:h?a.outcome.unconfirmedRetrying:d?c(R?a.confirm.afterDeadline:a.confirm.pastDeadline,{merchant:e.merchant.name}):v?a.confirm.invoicePayment:a.confirm.canClose})})]}),n&&jsx(Z,{children:jsx(ae,{onClick:n,children:g.label})})]})}function Sa({adapter:e,store:t,wallet:a$1,chainId:n}){let[o,r]=useState("idle"),[s,i]=useState(null),[c,l]=useState(null),p=useRef(0),m=a$1?.address,y=useRef(m);useEffect(()=>{y.current!==m&&(y.current=m,p.current++,r("idle"),i(null),l(null));},[m]);let f=useRef(false);return useEffect(()=>(f.current=false,()=>{f.current=true;}),[]),{step:o,problem:s,request:c,confirm:async({quote:d=false}={})=>{let R=++p.current,h=()=>p.current===R;i(null);let g=e?.signMessage;if(!g||!a$1)return i("unsupported"),false;if(a$1.chainId!==n&&e.switchChain){r("switching");try{await e.switchChain(n);}catch(b){if(h()){let I=b$1(b);i(I==="declined"?"switchDeclined":I==="failed"?"switchFailed":I),r("idle");}return false}if(!h())return false}h()&&r("signing");let x=t.getState().payer,k=null,S=await t.getState().confirmPayer(async(b,I)=>{h()&&l(I);try{return await g({message:b,account:a$1.address,chainId:I.chainId})}catch(F){let D=b$1(F);throw k=D==="declined"&&F instanceof a&&F.step==="switch"?"switchDeclined":D,F}});return h()&&(i(k),r("idle")),S&&d&&!f.current&&t.getState().payer===x&&await t.getState().requestQuote(),S},dismiss:()=>{p.current++,r("idle"),t.getState().abandonConfirmation();}}}function qs(e){return e.closest("[data-novapay-scroll]")??null}function Bp(e,t){let a=t?.offsetHeight;return a&&a>0?Math.min(e,a):e}function Op(e){let t=e.offsetHeight;return t>0?Bp(t,qs(e)):null}function Pa(e){let[t,a]=useState(null),[n,o]=useState(null),[r,s]=useState(null);return useEffect(()=>{if(!t)return;let i=qs(t),c=()=>{if(!e){let m=Op(t);m!==null&&o(m);}let p=i?.offsetHeight;s(p&&p>0?p:null);};if(c(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(c);return e||l.observe(t),i&&l.observe(i),()=>l.disconnect()},[t,e]),!e||n===null?[a,null]:[a,r?Math.min(n,r):n]}var Dp=new Set(["evm:coinbase","evm:baseaccount","evm:porto"]);function Na(e){return !!(e&&Dp.has(e.connectorType.toLowerCase()))}function Us(e,t){return e==="required"||e==="confirming"?true:e==="unless_relayed"&&t!=="relay"}async function Hs(e,t){let{payerProof:a}=e.getState();if(a==="required"||a==="confirming")return t(true),null;t(false);let n=await e.getState().requestQuote();return !n&&e.getState().error?.code==="payer_proof_required"&&t(true),n}var Wp=new Set(["payer_chain_mismatch","too_many_payers","payer_is_recipient"]);function yo(e){let t=e?.code;return t!==void 0&&(t.startsWith("payer_proof_")||Wp.has(t))}var qp=new Set(["rate_limited","request_failed","origin_required","invoice_not_payable"]);function On(e){let t=e?.code;return yo(e)||t!==void 0&&qp.has(t)}function Ta(e,t,a,n){if(t==="declined")return c(a.payerProof.declined,n);if(t==="switchDeclined")return c(a.payerProof.switchDeclined,n);if(t==="unsupported")return c(a.payerProof.unsupported,n);if(t==="wrongNetwork"||t==="switchFailed")return c(a.payerProof.wrongNetwork,n);if(t==="notAuthorized")return c(a.pay.notAuthorized,n);if(t==="alreadyPending")return c(a.walletPrompt.stillWaiting,n);if(t)return c(a.payerProof.failed,n);switch(e?.code){case void 0:case "payer_proof_required":return null;case "payer_proof_declined":return c(a.payerProof.declined,n);case "payer_proof_invalid":return a.payerProof.invalid;case "payer_proof_unavailable":return a.payerProof.unavailable;case "payer_chain_mismatch":return c(a.payerProof.wrongNetwork,n);case "too_many_payers":return c(a.payerProof.tooManyWallets,n);case "payer_is_recipient":return a.method.payerIsRecipient;case "rate_limited":return a.method.rateLimited;case "request_failed":return a.pay.noAnswer;default:return a.error.generic}}function Wn({kind:e,walletName:t,walletId:a,walletIcon:n,amount:o,merchant:r,network:s,to:i,priceTime:c$1,onRetry:l,text:p,details:m,hint:y,onCancel:f,stepHeight:v}){let{labels:d,display:R}=E(),h=useId(),g=useRef(null);useEffect(()=>g.current?.focus(),[e]);let[x]=useState(()=>typeof document>"u"?null:document.activeElement);useEffect(()=>()=>{let b=x?.ownerDocument;if(!x||!b||x===b.body||!x.isConnected)return;let I=b.activeElement;I&&I!==b.body&&!I.contains(x)||x.focus();},[x]);let k={wallet:t,amount:o,merchant:r,network:s},S=e==="sign"||e==="proof"?d.walletPrompt.signIn:e==="switch"?d.walletPrompt.switchIn:e==="submitting"?d.walletPrompt.submitting:d.walletPrompt.confirmIn;return jsxs("section",{"aria-labelledby":h,style:v?{"--novapay-step-height":`${v}px`}:void 0,className:cn$1("tuwa-scanlines novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center-safe novapay:gap-3 novapay:bg-[var(--tuwa-bg-primary)] novapay:px-6 novapay:py-5 novapay:text-center",v&&(R==="page"?"novapay:min-h-[var(--novapay-step-height)]":"novapay:max-sm:min-h-[var(--novapay-step-height)]")),children:[jsx(ua,{walletId:a,walletIcon:n}),jsx("h2",{id:h,ref:g,tabIndex:-1,className:at,children:c(S,k)}),(e==="sign"||e==="confirm"||e==="proof")&&jsxs(Fragment$1,{children:[jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:p??c(e==="confirm"?d.walletPrompt.confirmText:d.walletPrompt.signText,k)}),y&&jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:y}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-xs novapay:flex-col novapay:gap-1.5 novapay:text-left",children:[jsx("span",{className:Oe,children:jsx(ge,{label:d.walletPrompt.check,values:k})}),jsx(xe,{children:m?m.map(b=>jsx(H,{name:b.name,children:b.value},b.name)):jsxs(Fragment$1,{children:[jsx(H,{name:d.walletPrompt.amount,children:o}),jsx(H,{name:d.walletPrompt.to,children:i}),jsx(H,{name:d.walletPrompt.network,children:s}),c$1&&jsx(H,{name:d.walletPrompt.priceLocked,children:c$1})]})})]}),l?jsxs("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[d.walletPrompt.notOpened," ",jsx(ht,{onClick:l,children:d.walletPrompt.tryAgain})]}):jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(d.walletPrompt.stillWaiting,k)})]}),e!=="submitting"&&jsx(ae,{onClick:f,className:"novapay:max-w-xs",children:d.walletPrompt.cancel})]})}function zs(){let{checkout:e,state:t,store:a,labels:n,locale:o,wallet:r,adapterFor:s,connectWallet:i,setConfirmWallet:c$1}=E(),l=e?.methods.find(z=>z.id===t.methodId)??null,p=l?Ye(l):null,m=Sa({adapter:p?s(p):void 0,store:a,wallet:r,chainId:l?.chainId??""}),[y,f]=useState(false),v=useRef(null),d=m.step!=="idle",[R,h]=Pa(d),g=useRef(false);if(useEffect(()=>{g.current&&!d&&v.current?.querySelector("[data-novapay-heading]")?.focus(),g.current=d;},[d]),!e||!l)return null;let x=e.merchant.name,k=r?.name??"",S=ve(l.chainId),b=e.invoice.number??e.invoice.id,I=e.invoice.totalMinor?`${ye(Re(e.invoice.totalMinor),o)} ${e.invoice.currency}`:null,F=Na(r),D=t.phase==="quoting",w=d,A=Ta(!D&&On(t.error)?t.error:null,m.problem,n,{wallet:k,network:S,merchant:x}),L={wallet:k,invoice:b,merchant:x},T=Ue(r,l),me=()=>{T&&t.payer!==T&&a.getState().setPayer(T),m.confirm({quote:true});},P=()=>{c$1(false),a.getState().clearError();},W=T?t.confirmedWallets?.find(z=>!sn(z,T)):void 0;return jsxs("div",{ref:v,className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:R,inert:d,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",d&&"novapay:hidden"),children:[jsxs(de,{title:n.payerProof.title,subtitle:n.payerProof.text,children:[r&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:h-7 novapay:w-7 novapay:shrink-0",children:jsx(WalletIcon,{walletName:r.walletId})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:k}),jsx("span",{className:cn$1($,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(r.address),network:ve(r.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:()=>{i(l)||f(true);},className:nn,children:n.pay.change})]}),jsx(cn,{children:n.payerProof.summary}),jsxs(xe,{children:[jsx(H,{name:n.payerProof.invoice,children:b}),jsx(H,{name:n.payerProof.merchant,children:x}),I&&jsx(H,{name:n.payerProof.amount,children:I}),r&&jsx(H,{name:n.payerProof.wallet,children:jsx(He,{hash:r.address,chainId:r.chainId})})]}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.why}),F&&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(pr,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsx("span",{children:c(n.payerProof.passkey,L)})]}),r&&p==="eip155"&&r.chainId!==l.chainId&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.payerProof.willSwitch,{current:ve(r.chainId),network:S})}),W&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:c(n.payerProof.alreadyConfirmed,{wallet:shortAddress(Et(W))})}),A&&jsx(Q,{children:A}),y&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(Z,{children:[jsx(X,{busy:w||D,onClick:me,children:D?n.method.quoting:w?jsx(ge,{label:n.payerProof.waiting,values:L}):jsx(ge,{label:n.payerProof.confirm,values:L})}),jsx(ae,{disabled:D,onClick:P,children:(t.invoiceStatus??e?.invoice.status)==="underpaid"?n.pay.backFromRest:n.pay.back}),jsx($e,{children:F?n.payerProof.noteSmart:n.payerProof.note})]})]}),d&&jsx(Wn,{kind:m.step==="switching"?"switch":"proof",walletName:k,walletId:r?.walletId??"",walletIcon:r?.icon,amount:I??"",merchant:x,network:S,to:"",priceTime:null,text:c(F?n.payerProof.promptPasskey:n.payerProof.promptText,L),details:[...m.request?[{name:n.payerProof.site,value:m.request.domain}]:[],{name:n.payerProof.invoice,value:b},{name:n.payerProof.merchant,value:x},...I?[{name:n.payerProof.amount,value:I}]:[]],hint:m.request?c(n.payerProof.signInRequest,{wallet:k,site:m.request.domain}):void 0,onRetry:me,onCancel:m.dismiss,stepHeight:h})]})}var Yp=/^0x[0-9a-fA-F]{64}$/,Zp=/^[1-9A-HJ-NP-Za-km-z]{64,90}$/;function Un(){let{store:e,state:t,checkout:a,labels:n,wallet:o}=E(),[r,s]=useState(false),[i,c]=useState(""),[l,p]=useState(false),[m,y]=useState(null),f=useId(),v=t.quote??a?.quote;if(!v)return null;let d=n.outcome;if(!r)return jsx(ht,{onClick:()=>s(true),children:d.nameHash});let R=async h=>{h.preventDefault();let g=i.trim();if(!(v.instructions.family==="solana"?Zp:Yp).test(g))return y(d.nameHashInvalid);y(null),p(true);let k=await e.getState().submit({txKey:g,...o?{from:o.address}:{}});p(false),k||y(d.nameHashRefused);};return jsxs("form",{onSubmit:h=>{R(h);},className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:gap-2 novapay:text-left",children:[jsx("label",{htmlFor:f,className:"novapay:text-xs novapay:font-semibold",children:d.nameHashField}),jsx("input",{id:f,value:i,autoComplete:"off",spellCheck:false,"aria-invalid":m?true:void 0,onChange:h=>c(h.target.value),className:cn$1($,"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)]",ie)}),m&&jsx(Q,{children:m}),jsx(ae,{type:"submit",disabled:l||!i.trim(),children:d.nameHashSend})]})}var js=e=>e?.code==="payment_unconfirmed",tu={nonceSpent:"unconfirmedNonceSpent",unmined:"unconfirmedUnmined",rechecked:"unconfirmedNote",retrying:"unconfirmedRetrying",notReceived:"unconfirmedNotReceived",contact:"unconfirmedContact",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"},Ys=new Set(["nonceSpent","unmined","notReceived","contact","closed","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Zs=new Set(["nonceSpent","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Js={unconfirmed:{tone:"pending",label:"unconfirmed"},underpaid:{tone:"pending",label:"underpaid"},needs_review:{tone:"neutral",label:"review"},refunded:{tone:"neutral",label:"refunded"},expired:{tone:"neutral",label:"expired"},cancelled:{tone:"neutral",label:"cancelled"},replaced:{tone:"neutral",label:"replaced"},blocked:{tone:"error",label:"blocked"}},ee=({children:e,muted:t})=>jsx("p",{className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs",t?"novapay:text-[var(--tuwa-text-secondary)]":"novapay:text-[var(--tuwa-text-primary)]"),children:e});function vo(){let e=E(),{checkout:t,labels:a,onContact:n}=e;if(!t)return null;let o=jsx(ge,{label:a.outcome.contact,values:{merchant:t.merchant.name}}),r=cn$1(ra,Y(e,"secondaryButton"));if(n)return jsx("button",{type:"button",onClick:n,className:r,children:o});let s=_r(t.merchant,c(a.outcome.contactSubject,{number:t.invoice.number??t.invoice.id}));return s?jsx("a",{href:s,target:s.startsWith("mailto:")?void 0:"_blank",rel:"noopener noreferrer",className:r,children:o}):null}function Xs({kind:e}){let[t,a]=useState(false),n=E(),{checkout:o,state:r,store:s,labels:i,locale:c$1,now:l,wallet:p,connectWallet:m,openInvoice:y,qrShown:f,paymentSent:v,adapterFor:d,lockPrice:R}=n;if(!o)return null;let h=o.merchant.name,g=r.quote,x=o.methods.find(P=>P.id===(r.methodId??g?.methodId)),k=o.invoice.dueAt&&!o.invoice.closed?new Intl.DateTimeFormat(c$1,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(o.invoice.dueAt)):null,S=(P,W=g)=>W?`${le(P,W.decimals,c$1)} ${W.instructions.symbol}`:P,b=It(r.error),I=P=>c(i.outcome[tu[P]],{merchant:h}),F=r.followingUntil??null,D=F?jsx(ee,{muted:true,children:c(i.outcome.followingUntil,{time:new Intl.DateTimeFormat(c$1,{timeStyle:"short"}).format(Date.parse(F))})}):null,w=Lr(r,o),A=P=>{if(!w||P!=="mismatch"&&(!P||!Ys.has(P)))return null;let W=g??o.quote,z=W?he(W.instructions):null,Se=W&&z?d(W.instructions.family)?.explorerUrl?.({chainId:z,txKey:w}):void 0;return jsx(Ze,{children:jsx(xe,{className:"novapay:w-full novapay:max-w-sm",children:jsx(H,{name:i.confirm.transaction,children:jsx(HashLink,{hash:w,explorerUrl:Se,variant:"compact",...n.customization.childCustomizations?.hashLink})})})})},L,T=null,me=null;switch(e){case "unconfirmed":{if(L=i.outcome.unconfirmedTitle,vt(r.error))T=jsxs(Fragment$1,{children:[jsx(ee,{children:Ut(r.error,i,h)}),A("mismatch")]});else if(b&&Zs.has(b))T=jsxs(Fragment$1,{children:[jsx(ee,{children:I(b)}),A(b),b==="nonceSpent"&&jsx(Un,{})]});else {let z=b??"contact";T=jsxs(Fragment$1,{children:[jsx(ee,{children:i.outcome.unconfirmedText}),jsx(ee,{muted:true,children:I(z)}),A(z),jsx(Un,{})]});}let{payAgain:P}=s.getState(),W=r.invoiceStatus??o.invoice.status;P&&(W==="open"||W==="underpaid")&&!(b&&Zs.has(b))&&(me=vt(r.error)?r.error.unmatched===true?jsx(X,{onClick:()=>P(),children:i.pay.payAgain}):jsx(ae,{onClick:()=>P(),children:i.pay.payAgain}):jsx(ae,{onClick:()=>P(),children:i.outcome.unconfirmedPayAgain}));break}case "underpaid":{let P=g??o.quote,W=o.invoice.amountPaid,z=Mr(P,W);L=i.outcome.underpaidTitle;let Se=P&&W&&jsx(ee,{children:c(i.outcome.underpaidText,{received:S(W,P),total:S(P.cryptoAmountExpected,P)})});if(o.invoice.status==="underpaid"&&o.invoice.restPayable===false||r.error?.code==="method_not_found"){T=jsxs(Fragment$1,{children:[Se,jsx(ee,{children:i.outcome.underpaidClosed}),k&&jsx(ee,{children:c(i.outcome.underpaidClosedRefund,{merchant:h,date:k})})]});break}let we=rn(P,l,i,h,c$1,i.outcome.underpaidRateEnded),re=o.methods.find(De=>De.id===P?.methodId)??x??o.methods[0],ke=r.error?.code==="payer_blocked"?c(i.outcome.underpaidBlocked,{merchant:h}):r.error&&r.error.code!=="payer_mismatch"?la(r.error,i,h):null;T=jsxs(Fragment$1,{children:[Se,P&&z&&jsx(ee,{children:c(i.outcome.underpaidRest,{rest:S(z,P),network:ve(he(P.instructions))})}),k&&jsx(ee,{muted:true,children:c(i.outcome.underpaidNote,{merchant:h,date:k})}),we&&jsx(ee,{muted:true,children:we}),ke&&jsx(Q,{children:ke})]});let _=re&&p?Ue(p,re):null,M=r.error?.code==="payer_mismatch"?r.error.originWallet??null:null,U=M??o.invoice.originWallet??P?.payer??null,ne=U?Et(U):void 0,ce=_?parseCaip10AccountId(_)?.address:void 0,se=P?.payer!==null&&!!(ne&&(ce?!sn(ce,ne):M)),Me=()=>{if(!re)return;if(se)return void m(re);let De=P?.payer===null?null:_;if(P?.payer!==null&&!De)return void m(re);r.methodId!==re.id&&s.getState().selectMethod(re.id),s.getState().setPayer(De),R();};se&&ne&&(T=jsxs(Fragment$1,{children:[T,jsx(ee,{children:c(i.outcome.payRestFirstWallet,{wallet:shortAddress(ne)})})]})),me=jsx(X,{busy:r.phase==="quoting",onClick:Me,children:i.outcome.payRest});break}case "needs_review":{L=c(i.outcome.reviewTitle,{merchant:h});let P=o.invoice.review?.reason,W=P==="late"?i.outcome.reviewLate:P==="overpaid"?i.outcome.reviewOverpaid:P==="quote_expired"?i.outcome.reviewQuoteExpired:i.outcome.reviewScreening;T=jsxs(Fragment$1,{children:[jsx(ee,{children:c(W,{merchant:h})}),jsx(ee,{muted:true,children:i.outcome.reviewNote})]});break}case "refunded":{L=i.outcome.refundedTitle;let P=o.invoice.refundedTotalMinor??o.invoice.totalMinor;T=P&&jsx(ee,{children:c(i.outcome.refundedText,{merchant:h,amount:ye(Re(P),c$1),currency:o.invoice.currency})});break}case "expired":{L=i.outcome.expiredTitle;let P=Br(o.invoice.amountPaid),W=g??o.quote,z=ot(r)||ft(r,o),Se=js(r.error)||b==="settlementFailed"||b==="settlementRetrying",Ne=Se||!z&&qt(r,o),we=!Ne&&b==="closed",re=!Ne&&!we&&(z||v),ke=!Ne&&!we&&!re&&vt(r.error),_=re||Ne||we||ke||f,M=Se?b??"contact":"rechecked";T=jsxs(Fragment$1,{children:[P?jsxs(Fragment$1,{children:[k&&jsx(ee,{children:W?c(i.outcome.expiredPartText,{date:k,amount:S(P,W)}):c(i.outcome.expiredPartNoAmount,{date:k})}),!k&&W&&jsx(ee,{children:c(i.outcome.closedPartText,{merchant:h,amount:S(P,W)})}),jsx(ee,{children:c(i.outcome.expiredPartRefund,{merchant:h})})]}):!_&&k&&jsx(ee,{children:c(i.outcome.expiredText,{date:k,merchant:h})}),Ne?jsxs(Fragment$1,{children:[jsx(ee,{children:M==="rechecked"?c(i.outcome.expiredUnconfirmed,{merchant:h}):I(M)}),A(M),M==="nonceSpent"&&jsx(Un,{})]}):we?jsxs(Fragment$1,{children:[jsx(ee,{children:I("closed")}),A("closed")]}):re?jsxs(Fragment$1,{children:[jsx(ee,{children:c(i.outcome.expiredWhileConfirming,{merchant:h})}),D]}):ke?jsxs(Fragment$1,{children:[jsx(ee,{children:Ut(r.error,i,h)}),A("mismatch")]}):f?jsx(ee,{children:c(i.outcome.expiredAfterQr,{merchant:h})}):jsx(ee,{muted:true,children:i.outcome.expiredNote})]});break}case "cancelled":{if(L=i.outcome.cancelledTitle,b&&Ys.has(b)){T=jsxs(Fragment$1,{children:[jsx(ee,{children:I(b)}),A(b),b==="nonceSpent"&&jsx(Un,{})]});break}let P=js(r.error)||b==="closed"||ot(r)||ft(r,o)||qt(r,o)||v,W=!P&&vt(r.error),z=P?c(i.outcome.cancelledWhilePaying,{merchant:h}):W?Ut(r.error,i,h):c(f?i.outcome.cancelledAfterQr:i.outcome.cancelledText,{merchant:h});T=jsxs(Fragment$1,{children:[jsx(ee,{children:z}),W&&A("mismatch"),b==="retrying"&&jsx(ee,{muted:true,children:i.outcome.unconfirmedRetrying}),P&&D]});break}case "replaced":{let P=o.invoice.replacedBy,W=P?.number??"";if(L=c(i.outcome.replacedTitle,{merchant:h}),T=jsxs(Fragment$1,{children:[jsx(ee,{children:c(i.outcome.replacedText,{number:W})}),jsx(ee,{muted:true,children:i.outcome.replacedPaid})]}),P?.checkoutToken){let z=P.checkoutToken;me=jsx(X,{onClick:()=>y(z),children:jsx(ge,{label:i.outcome.openReplacement,values:{number:W}})});}break}case "blocked":{L=i.outcome.blockedTitle;let P=r.payer?parseCaip10AccountId(r.payer)?.address:void 0;T=jsxs(Fragment$1,{children:[jsx(ee,{children:r.error?.code==="payer_not_expected"?i.method.payerNotExpected:c(i.outcome.blockedText,{merchant:h})}),P&&jsx(He,{hash:P,chainId:g??o.quote?he((g??o.quote).instructions):null})]}),x&&(me=jsx(X,{onClick:()=>{m(x)||a(true);},children:i.outcome.useAnotherWallet}));break}}return jsxs(Fragment$1,{children:[jsxs("section",{role:e==="blocked"?"alert":void 0,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",n.display==="page"&&"novapay-page-status"),children:[jsx(At,{mark:e,tone:Js[e].tone,chip:i.status[Js[e].label],title:L}),T,t&&jsx(Q,{children:i.pay.connectUnavailable})]}),jsxs(Z,{children:[me,jsx(vo,{})]})]})}function Hn({children:e,className:t}){let{store:a,customization:n}=E(),[o]=useState(()=>bt(a,"title")!==void 0),r=o&&!n.config?.animation?.disabled;return jsx("div",{className:cn$1("novapay:w-full",r&&"novapay-status-reveal",t),children:e})}function ti(){let e=E(),{checkout:t,state:a,labels:n,adapterFor:o,payAfterFailure:r,customization:s,display:i}=e,c$1=dn(),l=yn("primary",n.pay.payAgain);if(!t||!a.error)return null;let p=i==="page",m=s.childCustomizations,y=ca(a.error)??c$1.txKey,f=a.quote??t.quote,v=f?he(f.instructions):null,d=y===c$1.txKey?c$1.explorerUrl:f&&v&&y?o(f.instructions.family)?.explorerUrl?.({chainId:v,txKey:y}):void 0;return jsxs(Ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",p&&"novapay-page-status"),children:[jsx(At,{mark:"failed",tone:"error",chip:n.status.failed,title:n.failed.title,amount:c$1.amount,note:c$1.network?c(n.failed.summary,{network:c$1.network}):null}),jsx(fn,{state:"failed"}),(c$1.network||y||c$1.fromAddress)&&jsxs(xe,{className:"novapay:max-w-sm",children:[c$1.network&&jsx(H,{name:n.confirm.network,children:c$1.network}),y&&jsx(H,{name:n.confirm.transaction,children:jsx(HashLink,{hash:y,explorerUrl:d,variant:"compact",...m?.hashLink})}),c$1.fromAddress&&jsx(H,{name:n.confirm.from,children:jsx(HashLink,{hash:c$1.fromAddress,explorerUrl:c$1.fromUrl,variant:"compact",...m?.hashLink})})]}),jsx(Hn,{className:"novapay:max-w-sm",children:jsx("p",{role:"status",className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:Ln(a.error,n,c$1.network??void 0)})})]}),jsxs(Z,{children:[jsx(X,{onClick:r,className:l.arrives?ka:void 0,children:l.label}),jsx(Hn,{children:jsx(vo,{})})]})]})}function oi({onStay:e,onLeave:t}){let{checkout:a,labels:n,locale:o}=E(),r=useId(),s=useId(),i=useRef(null),c$1=a?.invoice.dueAt?new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(a.invoice.dueAt)):null;return jsx(Dialog,{open:true,onOpenChange:l=>{l||e();},children:jsxs(DialogContent,{role:"alertdialog","aria-labelledby":r,"aria-describedby":s,onOpenAutoFocus:l=>{l.preventDefault(),i.current?.focus();},className:"novapay:w-full novapay:sm:w-[24rem]",children:[jsx(DialogTitle,{"aria-hidden":true,className:"novapay:sr-only",children:n.leave.title}),jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:p-5 novapay:text-center",children:[jsx("h2",{id:r,ref:i,tabIndex:-1,className:at,children:n.leave.title}),jsx("p",{id:s,className:"novapay:m-0 novapay:text-xs",children:c$1?c(n.leave.text,{date:c$1}):n.leave.textNoDate}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.leave.price}),jsx(X,{onClick:e,children:n.leave.stay}),jsx(ae,{onClick:t,children:n.leave.leave})]})]})})}function vn({label:e,items:t,value:a,getKey:n,onChange:o,children:r,className:s,itemClassName:i}){let c=useRef([]),l=Math.max(0,t.findIndex(m=>n(m)===a)),p=(m,y)=>{let f=t.length-1,v={ArrowRight:y+1,ArrowDown:y+1,ArrowLeft:y-1,ArrowUp:y-1,Home:0,End:f}[m.key];if(v===void 0)return;m.preventDefault();let d=v<0?f:v>f?0:v;o(n(t[d])),c.current[d]?.focus();};return jsx("div",{role:"radiogroup","aria-label":e,className:s,children:t.map((m,y)=>{let f=n(m),v=f===a;return jsx("button",{ref:d=>{c.current[y]=d;},type:"button",role:"radio","aria-checked":v,tabIndex:y===l?0:-1,onClick:()=>o(f),onKeyDown:d=>p(d,y),className:cn$1("novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-left novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors","novapay:border",v?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",ie,i?.(v,m)),children:r(m,v)},f)})})}function $n({tone:e,children:t}){return jsx("span",{className:cn$1(en,tn[e]),children:t})}function ci({method:e,labels:t}){let a=Xa(e);return a?a.kind==="discount"?jsx($n,{tone:"success",children:c(t.method.discount,{percent:a.percent})}):jsx($n,{tone:"neutral",children:c(t.method.markup,{percent:a.percent})}):null}function xu({selected:e}){return jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-full)] novapay:box-border",e?"novapay:border-4 novapay:border-[var(--tuwa-text-accent)]":"novapay:border novapay:border-[var(--tuwa-text-secondary)]")})}function gu({labels:e,terms:t,refundPolicy:a}){let n=(r,s)=>jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ie),children:s},r),o=t&&a?d(e.method.agreeBoth,{terms:n(t,e.summary.terms),refundPolicy:n(a,e.summary.refundPolicy)}):t||a?d(e.method.agreeOne,{link:t?n(t,e.summary.terms):n(a,e.summary.refundPolicy)}):null;return o?jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o}):null}function li(){let e=E(),{checkout:t,state:a,store:n,labels:o,wallet:r,payWith:s,setPayWith:i,payUrl:c$1,connectWallet:l,adapterFor:p,setHandoff:m,lockPrice:y}=e,{TokenOption:f,NetworkOption:v}=e.customization.components??{},d=useMemo(()=>t?.methods??[],[t]),R=useMemo(()=>wr(d,r?.chainId),[d,r?.chainId]),h=d.find(_=>_.id===a.methodId)??null,g=R.find(_=>_.symbol===h?.symbol)??null,x=h?hr(h,c$1):false,k=h?Ye(h):null,b=[...(k?!!p(k):false)?["wallet"]:[],...x?["qr"]:[]],I=b.includes(s)?s:b[0]??null,[F,D]=useState(false),w=useId(),A=useId(),L=useEffectEvent(()=>{let _=R[0]?.methods[0];!a.methodId&&_&&n.getState().selectMethod(_.id,{keepError:true});});if(useEffect(()=>L(),[R]),!t)return null;if(d.length===0)return jsx(de,{title:o.method.title,children:jsx(Q,{children:o.method.noMethods})});let T=e.display==="page",me=R.reduce((_,M)=>M.methods.length>_.methods.length?M:_,R[0]),P=a.phase==="quoting",W=t.consent??null,z=!!a.consentGiven,Se=!!(W?.required&&!z),Ne=e.customization.handlers,we=_=>{let M=()=>n.getState().selectMethod(_.id);Ne?.onMethodSelect?Ne.onMethodSelect({method:_,select:M}):M();},re=async()=>{if(!h||!I)return;if(D(false),I==="qr"){if(s!=="qr"&&i("qr"),k!=="solana")return m(true);n.getState().setPayer(null),await n.getState().requestQuote();return}s!=="wallet"&&i("wallet");let _=Ue(r,h);if(!_)return D(!l(h));n.getState().setPayer(_),await y();},ke=_=>jsxs(Fragment$1,{children:[jsx(cn,{children:jsx(ge,{label:o.method.network,values:{symbol:_.symbol}})}),jsx(vn,{label:c(o.method.network,{symbol:_.symbol}),items:_.methods,value:h?.id??null,getKey:M=>M.id,onChange:M=>{let U=_.methods.find(ne=>ne.id===M);U&&we(U);},className: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:(M,U)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-3 novapay:py-2.5",Y(e,"networkOption",{method:U,selected:M})),children:(M,U)=>v?jsx(v,{method:M,selected:U}):jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(NetworkIcon,{chainId:toEvmChainId(M.chainId)??M.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:ve(M.chainId)}),jsxs("span",{className:"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-1.5",children:[r?.chainId===M.chainId&&jsx($n,{tone:"neutral",children:o.method.yourWallet}),M.featured&&jsx($n,{tone:"accent",children:o.method.popular}),jsx(ci,{method:M,labels:o}),M.gasless==="auto"?jsx($n,{tone:"success",children:o.method.noGasFee}):jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.buyerPaysGas})]})]}),jsx(xu,{selected:U})]})})]});return jsxs(Fragment$1,{children:[jsxs(de,{title:o.method.title,subtitle:c(o.method.subtitle,{minutes:Math.round(t.quoteTtlSeconds/60)}),children:[jsx(cn,{children:o.method.token}),jsx(vn,{label:o.method.token,items:R,value:g?.symbol??null,getKey:_=>_.symbol,onChange:_=>{let M=R.find(U=>U.symbol===_)?.methods[0];M&&we(M);},className:"novapay:grid novapay:grid-cols-[repeat(auto-fit,minmax(5.5rem,1fr))] novapay:gap-2",itemClassName:(_,M)=>cn$1("novapay:flex novapay:min-w-0 novapay:flex-col novapay:items-center novapay:gap-1 novapay:px-2 novapay:py-2",T&&"novapay-page-token",Y(e,"tokenOption",{group:M,selected:_})),children:(_,M)=>f?jsx(f,{group:_,selected:M}):jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:h-6.5 novapay:w-6.5",children:jsx(TokenIcon,{symbol:_.symbol})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:_.symbol}),jsx("span",{className:"novapay:max-w-full novapay:truncate novapay:text-[10px] novapay:text-[var(--tuwa-text-secondary)]",children:_.methods.length>1?c(o.method.networks,{count:_.methods.length}):Xa(_.methods[0])?jsx(ci,{method:_.methods[0],labels:o}):ve(_.methods[0].chainId)})]})}),T&&g?jsxs("div",{className:cn$1("novapay:grid",g.methods.length===1&&"novapay:max-sm:hidden"),children:[me!==g&&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:ke(me)}),jsx("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1]",children:ke(g)})]}):g&&g.methods.length>1&&ke(g),jsx(cn,{children:o.method.payWith}),jsx(vn,{label:o.method.payWith,items:b,value:I,getKey:_=>_,onChange:_=>{D(false),i(_);},className:cn$1("novapay:grid novapay:gap-2",b.length>1&&"novapay:grid-cols-2"),itemClassName:(_,M)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-2.5 novapay:py-2",T&&"novapay-page-way",Y(e,"payWithOption",{payWith:M,selected:_})),children:_=>_==="wallet"?jsxs(Fragment$1,{children:[r?jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(_n,{walletId:r.walletId,icon:r.icon})}):jsx(rr,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:text-[var(--tuwa-text-accent)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:o.method.wallet}),jsx("span",{className:cn$1("novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",r&&$),children:r?`${r.name} \xB7 ${shortAddress(r.address)}`:o.method.walletHint})]})]}):jsxs(Fragment$1,{children:[h&&Ye(h)==="solana"?jsx(yr,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}):jsx(lr,{"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})]})]})}),W&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-start novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:transition-colors",z?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",Y(e,"consentOption",{checked:z,required:W.required})),children:[jsx(ma,{checked:z,required:W.required,"aria-labelledby":w,"aria-describedby":W.required?A:void 0,onChange:_=>n.getState().setConsentGiven(_.target.checked),className:"novapay:mt-0.5"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-1",children:[jsx("span",{id:w,className:"novapay:whitespace-pre-line novapay:break-words novapay:text-[12px] novapay:leading-snug",children:W.text}),W.required&&jsx("span",{id:A,className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.consentRequired})]})]}),h&&!I&&jsx(Q,{children:o.method.methodUnavailable}),F&&jsx(Q,{children:x?o.pay.connectUnavailable:o.method.methodUnavailable}),a.error&&a.phase==="selectMethod"&&jsxs(Fragment$1,{children:[jsx(Q,{children:la(a.error,o,t.merchant.name)}),jsx(da,{error:a.error})]})]}),jsxs(Z,{children:[jsx(X,{busy:P,disabled:!h||!I||Se,onClick:()=>{h&&I&&Ne?.onQuote?Ne.onQuote({method:h,payWith:I,proceed:re}):re();},children:P?o.method.quoting:o.method.continue}),jsx(gu,{labels:o,terms:t.merchant.links.terms,refundPolicy:t.merchant.links.refundPolicy})]})]})}function di(e,t,a,n=false){let o=useRef(null),r=t?.id??null,s=useEffectEvent(()=>{t&&a?.({...t,status:"paid"});});useEffect(()=>{e!=="paid"||!r||o.current===r||(o.current=r,n||s());},[e,r,n]);}function yi({url:e,seconds:t,now:a,navigate:n=o=>window.location.assign(o)}){let[o,r]=useState(t>0?a:null);t>0!=(o!==null)&&r(t>0?a:null);let s=t>0?o??a:a,[i,c]=useState(false),l=e&&t>0&&!i?Math.max(0,t-Math.floor((a-s)/1e3)):null,p=useEffectEvent(()=>{e&&n(e);});return useEffect(()=>{l===0&&p();},[l]),{left:l,stay:()=>c(true)}}function vi(){let e=E(),{checkout:t,state:a,labels:n,locale:o,now:r,close:s,autoReturnSeconds:i,openedPaid:c$1,display:l}=e,p=e.customization.childCustomizations,m=dn(),[y]=useState(r),f=t?.merchant.name??"",v=l==="modal"&&i===0?null:t?.invoice.successUrl??null,d=yi({url:v,seconds:c$1?0:i,now:r}),R=v?n.paid.back:s?n.common.close:null,h=yn(R===null?null:"primary",R??""),g=h.arrives?ka:void 0;if(!t)return null;let x=t.invoice.totalMinor?ye(Re(t.invoice.totalMinor),o):null,k=t.invoice.refundedTotalMinor&&BigInt(t.invoice.refundedTotalMinor)>0n?ye(Re(t.invoice.refundedTotalMinor),o):null,S=t.invoice.paidAt?Date.parse(t.invoice.paidAt):y,b=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(S),{transfers:I}=m,F=I.length>1?I:null,D=I.length===1?I[0]:null,w=m.txKey??D?.txKey??null,A=m.txKey?m.explorerUrl:D?.explorerUrl,L=new Intl.DateTimeFormat(o,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return jsxs(Ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",e.display==="page"&&"novapay-page-status"),children:[jsx(At,{mark:"paid",tone:"success",chip:n.status.paid,title:n.paid.title,amount:m.paidAmount??(x&&`${x} ${t.invoice.currency}`),note:m.network?c(n.paid.summary,{network:m.network,date:b}):b}),jsx(fn,{state:"succeed"}),(m.network||w||F||m.from)&&jsxs(xe,{className:"novapay:max-w-sm",children:[m.network&&jsx(H,{name:n.confirm.network,children:m.network}),F?F.map((T,me)=>jsxs(H,{name:jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:block",children:c(n.confirm.transferOf,{index:me+1,count:F.length})}),jsx("time",{dateTime:new Date(T.at).toISOString(),className:"novapay:block novapay:text-[11px] novapay:leading-4",children:L.format(T.at)})]}),children:[T.amount&&jsx("span",{className:"novapay:block",children:T.amount}),jsx(HashLink,{hash:T.txKey,explorerUrl:T.explorerUrl,variant:"compact",...p?.hashLink})]},`${T.txKey}:${me}`)):w&&jsx(H,{name:m.lastOfParts?n.confirm.lastTransfer:n.confirm.transaction,children:jsx(HashLink,{hash:w,explorerUrl:A,variant:"compact",...p?.hashLink})}),m.fromAddress&&jsx(H,{name:n.confirm.from,children:jsx(HashLink,{hash:m.fromAddress,explorerUrl:m.fromUrl,variant:"compact",...p?.hashLink})})]}),k&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.paid.refunded,{amount:k,currency:t.invoice.currency})}),a.receiptUrl&&jsx(Hn,{className:"novapay:max-w-sm",children:jsxs("div",{className:"novapay:flex novapay:w-full novapay:items-center novapay:gap-3 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-left",children:[jsx(ar,{"aria-hidden":true,className:"novapay:h-6 novapay:w-6 novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:n.paid.receipt}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.paid.receiptHint})]}),jsxs("a",{href:a.receiptUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1(nn,"novapay:gap-1.5 novapay:no-underline"),children:[jsx(sr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),n.paid.download]})]})})]}),jsx(Z,{children:v?jsxs(Fragment$1,{children:[jsx("a",{href:v,className:cn$1(Tt,g,Y(e,"primaryButton")),children:jsx(ge,{label:h.label,values:{merchant:f}})}),d.left!==null&&jsxs($e,{children:[jsx("span",{role:"timer","aria-live":"off",children:c(n.paid.returning,{merchant:f,seconds:d.left})})," ","\xB7 ",jsx(ht,{onClick:d.stay,children:n.paid.stay})]})]}):s&&jsx(X,{onClick:s,className:g,children:h.label})})]})}function Ea({payee:e}){let{labels:t,checkout:a,state:n,backToMethods:o}=E();if(e.status==="checking")return jsxs("div",{role:"status",className:cn$1("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)]","novapay-payee-wait"),children:[jsx(QuasarLoader,{size:40}),t.pay.payeeChecking]});let r=a?.merchant.name??"",s=(n.invoiceStatus??a?.invoice.status)==="underpaid";return jsxs(Fragment$1,{children:[jsx(de,{title:t.pay.payeeRefusedTitle,children:jsx("div",{"data-payee-refusal":e.reason,children:jsx(Q,{children:c(t.pay.payeeRefused,{merchant:r})})})}),jsx(Z,{children:jsx(ae,{onClick:o,children:s?t.pay.backFromRest:t.pay.back})})]})}function xi({state:e,screen:t,now:a,locale:n=null,handlers:o}){let r=e.checkout?.invoice.status??null,{phase:s,error:i}=e,c=e.quote?.expiresAt?Date.parse(e.quote.expiresAt):null,l=c!==null&&a>=c,p=useEffectEvent(()=>o?.onStatusChange?.({phase:s,status:r,screen:t}));useEffect(()=>p(),[s,r]);let m=useEffectEvent(()=>{n&&o?.onLocaleShown?.({locale:n});});useEffect(()=>m(),[n]);let y=useEffectEvent(()=>{i&&o?.onError?.({error:i,screen:t});});useEffect(()=>y(),[i]);let f=useRef({quote:false,invoice:false}),v=useEffectEvent(d=>o?.onExpire?.({kind:d,paymentOnTheWay:ot(e)||ft(e,e.checkout)||qt(e,e.checkout)}));useEffect(()=>{l&&!f.current.quote&&v("quote"),f.current.quote=l;},[l]),useEffect(()=>{let d=r==="expired";d&&!f.current.invoice&&v("invoice"),f.current.invoice=d;},[r]);}var Qt=()=>new Promise(()=>{}),Eu={view:Qt,quote:Qt,buyer:Qt,locale:Qt,submit:Qt,relay:Qt,authorizeRelay:Qt,url:()=>""},Lu=createCheckoutStore({token:"idle",api:Eu,EventSource:null});function bi(e){let{token:t,baseUrl:a,api:n,EventSource:o,pollMs:r,enabled:s=true,payee:i}=e,[c,l]=useState(Lu),p=useEffectEvent(()=>createCheckoutStore({token:t,baseUrl:a,api:n,EventSource:o,pollMs:r,payee:i})),m=i?.addresses?.join(`
|
|
2
|
-
`)??"";return useEffect(()=>{if(!s)return;let y=p();return l(y),y.getState().load(),()=>y.getState().destroy()},[t,a,s,m]),c}function wi(e,t){return useStore(e,t)}var Ou=createStore(()=>({}));function Aa(){let e=useContext(SatelliteStoreContext)??Ou,t=useStore(e,l=>l.activeConnection),a=useStore(e,l=>l.getConnectors),n=useStore(e,l=>l.watchConnectors),[o,r]=useState(0);useEffect(()=>n?.(()=>r(l=>l+1)),[n]);let s=useMemo(()=>vr(t,a?.()),[t,a,o]),i=s?.name,c=s?.icon;return useMemo(()=>s,[t,i,c])}function Ci(e){let[t,a]=useState({store:e,at:null});return useEffect(()=>e.subscribe((n,o)=>{n.phase!==o.phase&&(n.phase==="confirming"?a({store:e,at:o.phase==="submitting"?Date.now():null}):o.phase==="confirming"&&a({store:e,at:null}));}),[e]),t.store===e?t.at:null}var Si=Symbol.for("tuwaio.nova-payments.context"),Pi=globalThis,Vn=Pi[Si]??(Pi[Si]=createContext({}));function pt(){return useContext(Vn)}function Ni(e,t=true){let[a,n]=useState(()=>Date.now());return useEffect(()=>{if(!t)return;let o=setInterval(()=>n(Date.now()),e);return ()=>clearInterval(o)},[e,t]),a}var bo="nova-payments:sponsoredBatches";var wo=()=>{try{return globalThis.sessionStorage??null}catch{return null}},ko=()=>{try{let e=JSON.parse(wo()?.getItem(bo)??"[]");return Array.isArray(e)?e:[]}catch{return []}},Ti=e=>{try{e.length>0?wo()?.setItem(bo,JSON.stringify(e)):wo()?.removeItem(bo);}catch{}},_a=e=>Ti(ko().filter(t=>t.invoiceId!==e)),Ri=e=>Ti([...ko().filter(t=>t.invoiceId!==e.invoiceId),e]),Co=e=>ko().find(t=>t.invoiceId===e&&Date.now()-t.at<21e5)??null;function Fa(e){let t=e.payeeCheck;return !e.quote||!t||t.quote!==e.quote||t.status==="checking"?{status:"checking"}:t.status==="verified"?{status:"verified"}:{status:"refused",reason:t.reason}}function Ii(e,t){return e.payeeCheck?.quote===t&&e.payeeCheck.status==="verified"}function Ei(e,t){let a=Rt(t.chainId),n=a?e?.find(o=>o.family===a)?.verifyPayoutRecord:void 0;return n?n(t):Promise.resolve(null)}var Li=e=>new a("unsupported",`${e} is not available`);async function Ai({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,onWalletDone:s,onBatchAccepted:i,onSent:c}){if(!Ii(t.getState(),a$1))throw new a("unsupported","The payee of the quote is not verified");let l=n.address;if(o==="relay"){let m=a$1.gasless?.relay?.typedData;if(!m||!e.signTransferAuthorization)throw Li("A gasless signature");let y=await e.signTransferAuthorization({typedData:m,account:l});s?.();let{relayFromPage:f,relay:v}=t.getState(),d=e.sendOneTimeRelay;return f&&d&&r?f(y,R=>d({chainId:R.chainId,call:R.call,paymasterUrl:r})):v(y)}if(o==="paymaster"){let m=a$1.gasless?.paymaster?.calls;if(!m||!r||!e.sendSponsoredCalls)throw Li("A sponsored payment");let y=he(a$1.instructions),f=await e.sendSponsoredCalls({calls:m,paymasterUrl:r,chainId:y,account:l,onSent:s,onAccepted:i,onLate:v=>{c?.(v),t.getState().submit({txKey:v,connectorType:n.connectorType,methodId:a$1.methodId});}});return s?.(),c?.(f),t.getState().submit({txKey:f,connectorType:n.connectorType,methodId:a$1.methodId})}let p=await e.sendTransfer({instructions:a$1.instructions,account:l,connection:n.connection});return s?.(),c?.(p),t.getState().submit({txKey:p,connectorType:n.connectorType,methodId:a$1.methodId})}var Ma=6e5;var Ft=new WeakMap;function Oa(e){let t=Ft.get(e);return !!(t?.accepted&&Date.now()<t.until)}function Fi({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,invoiceId:s,onSent:i}){let[c,l]=useState("idle"),[p,m]=useState(()=>{let x=Ft.get(t),k=x?.unconfirmed&&x.account===n?.address&&Date.now()<x.until,S=s?Co(s):null;return k||S?"sentUnconfirmed":null}),y=useEffectEvent(x=>i?.(x));useEffect(()=>{if(!s||Ft.has(t))return;let x=Co(s);if(!x)return;let k=Promise.reject(new a("sentUnconfirmed","The sponsored payment is not confirmed yet"));k.catch(()=>{});let S=x.at+21e5;Ft.set(t,{account:x.account,path:"paymaster",paying:k,until:S,unconfirmed:true,instructions:x.instructions,accepted:true}),e?.followSponsoredCalls?.({batchId:x.batchId,until:S,onLate:b=>{_a(s),y({txKey:b,instructions:x.instructions,account:x.account,connectorType:x.connectorType}),t.getState().submit({txKey:b,connectorType:x.connectorType,methodId:x.methodId});}});},[s,e,t]);let f=useRef(0),[v,d]=useState(null),[R,h]=useState(null),g=async(x,k)=>{let S=++f.current,b=()=>f.current===S;m(null),l(x);try{await k(b);}catch(I){b()&&m(b$1(I));}finally{b()&&l("idle");}};return {status:c,problem:p,askedWallet:v,askedInstructions:R,pay:()=>g("wallet",async x=>{if(!e||!a$1||!n)return m("unsupported");d(n);let k=Ft.get(t),S=k?.path==="relay"&&o==="relay";if(k?.account===n.address&&!S&&Date.now()<k.until){h(k.instructions),await k.paying;return}h(a$1.instructions);let b={account:n.address,path:o,paying:Promise.resolve(),until:Date.now()+6e5,unconfirmed:!1,instructions:a$1.instructions,accepted:!1};Ft.set(t,b);let I=Ai({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,onWalletDone:()=>{o==="paymaster"&&(b.accepted=!0),x()&&l("submitting");},onBatchAccepted:D=>{s&&Ri({invoiceId:s,batchId:D,account:n.address,instructions:a$1.instructions,connectorType:n.connectorType,methodId:a$1.methodId,at:Date.now()});},onSent:D=>{s&&_a(s),i?.({txKey:D,instructions:a$1.instructions,account:n.address,connectorType:n.connectorType});}});b.paying=I;let F=()=>{Ft.get(t)===b&&Ft.delete(t),s&&_a(s);};I.then(F,D=>{if(b$1(D)!=="sentUnconfirmed")return F();b.unconfirmed=!0,b.until=Date.now()+21e5;}),await I;}),switchNetwork:()=>g("switching",async()=>{if(!e?.switchChain||!a$1)return m("unsupported");await e.switchChain(he(a$1.instructions));}),dismiss:()=>{f.current++,l("idle");}}}var zu=100,Qu=300,Mi=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e;async function Bi({adapter:e,pulsar:t,payment:a,labels:n,merchant:o,invoice:r,amount:s}){if(!t||!e?.pulsarTransaction)return false;let i=r.number?c(n.pay.txDescription,{amount:s,invoice:r.number}):s,c$1=e.pulsarTransaction({...a,title:Mi(c(n.pay.txTitle,{merchant:o}),zu),description:Mi(i,Qu),payload:{quasarInvoice:r.id}});return await t.injectExternalPendingTxs([c$1]),true}var Yu=new Set(["open","processing","underpaid"]),Wi=new WeakMap,So=e=>{let t=Wi.get(e);return t||Wi.set(e,t={keys:new Set,sentHere:false}),t},Zu=e=>e.split(":").at(-1)??e;function qi({store:e,adapterFor:t,pulsar:a,labels:n,locale:o}){let r=useRef({adapterFor:t,pulsar:a,labels:n,locale:o});useEffect(()=>{r.current={adapterFor:t,pulsar:a,labels:n,locale:o};});let s=useCallback(i=>{let{checkout:c}=e.getState(),{adapterFor:l,pulsar:p,labels:m,locale:y}=r.current,f=So(e);if(!c||!p||f.keys.has(i.txKey))return;f.keys.add(i.txKey);let{amount:v,decimals:d,symbol:R}=i.instructions;Bi({adapter:l(i.instructions.family),pulsar:p,payment:i,labels:m,merchant:c.merchant.name,invoice:{id:c.invoice.id,number:c.invoice.number},amount:`${le(v,d,y)} ${R}`}).catch(()=>{});},[e]);return useEffect(()=>e.subscribe((i,c)=>{let{txHash:l,quote:p,checkout:m}=i;if(!l||l===c.txHash||!p||!m||!Yu.has(c.invoiceStatus)||So(e).sentHere)return;let y=m.invoice.originWallet??p.payer;s({txKey:l,instructions:p.instructions,account:y?Zu(y):"",connectorType:""});}),[e,s]),useCallback(i=>{So(e).sentHere=true,s(i);},[e,s])}function Hi({store:e,state:t,walletTxKey:a=null}){let[n,o]=useState(null),[r,s]=useState(null),i=a!==null&&a!==r;i&&s(a);let c=t.phase,l=i||ot(t)||ft(t,t.checkout)||qt(t,t.checkout)||c==="confirming"||c==="unconfirmed",p=n?.store===e?n:null,m=l?p&&p.error===t.error?p:{store:e,error:t.error}:p&&Ir(t.error)&&t.error!==p.error?null:n;return m!==n&&o(m),m?.store===e}function Gn(e){let{labels:t,customization:a}=pt(),n=a?.labels?.transform,[o,r]=useState(()=>h(e)),s=g(e);s&&o!==h(e)&&r(h(e));let i$1=s?h(e):o;return useEffect(()=>{if(g(e))return;let c=true;return i(e).then(l=>c&&r(l)),()=>{c=false;}},[e]),useMemo(()=>{let c=j(i$1,t);return n?n(c,{locale:e}):c},[i$1,e,t,n])}function $i({store:e,screen:t}){let[a,n]=useState(null),o=t==="qr";return o&&a!==e&&n(e),o||a===e}function Da(e){let t=useContext(NovaConnectProviderContext),a=pt(),n=e??a.onConnectWallet;return {canConnect:!!(t||n),connecting:t?.isConnectModalOpen??false,connect:o=>t?(t.setIsConnectModalOpen(true,{adapter:o==="solana"?OrbitAdapter.SOLANA:OrbitAdapter.EVM}),true):n?(n(o),true):false}}function Vi({box:e,content:t,isNarrow:a,isActive:n,duration:o=300}){if(typeof ResizeObserver>"u")return ()=>{};let r,s,i=0,c=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,l=()=>{s=void 0,e.style.removeProperty("overflow");},p=()=>{let f=s;l(),f?.cancel();},m=()=>{let f=t.offsetHeight,v=r;if(r=f,v===void 0||v===f)return;if(s){s.effect?.setKeyframes?.([{height:`${i}px`},{height:`${f}px`}]);return}if(!a()||!n()||c()||typeof e.animate!="function"||Math.abs(f-v)<12)return;i=v,e.style.overflow="clip";let R=e.animate([{height:`${v}px`},{height:`${f}px`}],{duration:o,easing:"cubic-bezier(0.2, 0, 0, 1)"});s=R;let h=()=>{s===R&&l();};R.onfinish=h,R.oncancel=h;},y=new ResizeObserver(m);return y.observe(t),m(),()=>{y.disconnect(),p();}}function Qi({active:e,children:t}){let a=useRef(null),n=useRef(null),o=useRef(e);return useEffect(()=>{o.current=e;},[e]),useEffect(()=>{if(!a.current||!n.current||typeof window>"u"||!window.matchMedia)return;let r=window.matchMedia("(max-width: 639.98px)");return Vi({box:a.current,content:n.current,isNarrow:()=>r.matches,isActive:()=>o.current})},[]),jsx("div",{ref:a,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:jsx("div",{ref:n,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:t})})}function xn(e,t){let[a,n]=useState(null),o=useEffectEvent(t);return useEffect(()=>{if(e===null)return;let r=true,s;try{s=Promise.resolve(o());}catch(i){s=Promise.reject(i);}return s.then(i=>r&&n({key:e,value:i}),()=>r&&n({key:e,value:null})),()=>{r=false;}},[e]),a&&a.key===e?a.value:void 0}function Wa(e,t,a){let[n,o]=useState(0),[r,s]=useState(null),i=useEffectEvent(t);return useEffect(()=>{if(e===null||typeof window>"u")return;let c=()=>{document.visibilityState!=="hidden"&&o(m=>m+1);},l=window,p=document;return l.addEventListener("focus",c),p.addEventListener("visibilitychange",c),()=>{l.removeEventListener("focus",c),p.removeEventListener("visibilitychange",c);}},[e]),useEffect(()=>{if(e===null)return;let c=true,l;try{l=Promise.resolve(i());}catch(p){l=Promise.reject(p);}return l.then(p=>c&&s({key:e,value:p}),()=>c&&s({key:e,value:null})),()=>{c=false;}},[e,n,a]),r&&r.key===e?r.value:void 0}var om=e=>e.charAt(0).toUpperCase()+e.slice(1);function Yi(e,t,a){let n=e.startsWith("solana:")?getSolanaCluster(e):void 0;if(!n||n==="mainnet")return null;let o={network:ve(e),cluster:om(n),wallet:t?.name??""},r=t?.family!=="solana"?void 0:t.walletId==="phantom"?a.pay.solanaHintPhantom:t.walletId==="solflare"?a.pay.solanaHintSolflare:a.pay.solanaHintOther;return {title:c(a.pay.solanaNetwork,o),text:c(a.pay.solanaNetworkText,o),...r?{hint:c(r,o)}:{}}}function Zi(e,t){let a=e.startsWith("solana:")?getSolanaCluster(e):void 0;return !a||t?.family!=="solana"||getSolanaCluster(t.chainId)===a?null:e}function Ji(e,t){let a=useContext(SatelliteStoreContext),n=Zi(e,t);useEffect(()=>{n&&a?.getState().switchNetwork?.(n);},[a,n]);}function cm(e,t){return e>=1?ye(e,t):new Intl.NumberFormat(t,{maximumSignificantDigits:6}).format(e)}function lm(e,t,a,n){let o=n?.code;if(a==="declined")return c(e.pay.declined,t);if(a==="unsupported")return c(e.pay.unsupported,t);if(a==="wrongNetwork")return c(e.pay.wrongCluster,t);if(a==="switchFailed")return c(e.pay.switchFailed,t);if(a==="notAuthorized")return c(e.pay.notAuthorized,t);if(a==="alreadyPending")return c(e.walletPrompt.stillWaiting,t);if(a==="sentUnconfirmed")return c(e.pay.sentUnconfirmed,t);let r=a?null:Ut(n,e,t.merchant);return r!==null?r:a==="failed"?c(e.pay.walletFailed,t):n&&o==="payment_failed"?Ln(n,e,t.network):o==="screening_unavailable"?e.pay.screeningUnavailable:o==="request_failed"?e.pay.noAnswer:o==="price_unavailable"||o==="price_no_rpc"?e.method.priceUnavailable:o==="rate_limited"?e.method.rateLimited:o==="method_not_found"||o==="amount_out_of_range"||o==="testnet_required"?e.method.methodUnavailable:n&&!yo(n)?e.error.generic:null}var pm=(...e)=>e.reduce((t,a)=>t&&!/[。!?]$/.test(t)?`${t} ${a}`:`${t}${a}`,"");function um(e,t,a){let{wallet:n,adapterFor:o}=E(),r=t?.instructions.family,s=r?o(r):void 0,i=e.filter(l=>l.id!==t?.methodId&&Ye(l)===r),c=xn(a&&s&&n&&i.length?`${n.address}:${i.map(l=>l.id).join()}`:null,()=>Promise.all(i.map(l=>s.getBalance({chainId:l.chainId,account:n.address,token:xr(l)}).catch(()=>0n))));return c?i.map((l,p)=>({method:l,balance:c[p]})).filter(l=>l.balance>0n):[]}function tc(){let{checkout:e,state:t,store:a,labels:n,locale:o,now:r,wallet:s,adapterFor:i,connectWallet:c$1,backToMethods:l,onPaymentSent:p,customization:m,lockPrice:y,display:f}=E(),v=m.config?.balanceCheck!==false,d=t.quote,R=e?.methods??[],h=R.find(We=>We.id===d?.methodId),g=d?.instructions.family??"eip155",x=i(g),k=d?he(d.instructions):"",S=s?.address??"",[b,I]=useState(false),F=xn(d?.gasless?.paymaster&&x?.canSponsorCalls&&s?`${k}:${S}`:null,()=>x.canSponsorCalls({chainId:k,account:S})),D=d?qr(d,{withGas:b,canSponsorCalls:F===true}):"transfer",w=Wa(v&&d&&x&&s?`${k}:${S}:${d.instructions.token}`:null,()=>x.getBalance({chainId:k,account:S,token:d.instructions.token}),d?.expiresAt),A=xn(d&&D==="transfer"&&x?.estimateFee&&s?`${k}:${S}:${d.amountToSend}`:null,()=>x.estimateFee({instructions:d.instructions,account:S})),L=Fi({adapter:x,store:a,quote:d,wallet:s,path:D,paymasterUrl:t.paymasterUrl,invoiceId:e?.invoice.id,onSent:p}),T=Sa({adapter:x,store:a,wallet:s,chainId:k});Ji(k,s);let me=d?.instructions.token==="native",P=d&&typeof w=="bigint"?$r(w,d,me&&A?A.amount:0n):null,W=(t.invoiceStatus??e?.invoice.status)==="underpaid",z=um(R,d,v&&!!P&&!W),[Se,Ne]=useState(false),we=T.step==="switching"||T.step==="signing"||L.status==="switching"||L.status==="submitting"||L.status==="wallet"||t.phase==="submitting",[re,ke]=Pa(we);if(e&&d&&!h)return jsxs(Fragment$1,{children:[jsx(de,{title:n.method.methodUnavailable,children:null}),jsx(Z,{children:jsx(ae,{onClick:l,children:n.pay.back})})]});if(!e||!d||!h)return null;let _=Fa(t);if(_.status!=="verified"&&t.phase!=="submitting"&&L.status==="idle")return jsx(Ea,{payee:_});let M=e.merchant.name,U=ve(k),ne=We=>`${le(We,d.decimals,o)} ${d.instructions.symbol}`,ce=Ur(d),se=L.askedInstructions,Me=se&&se.amount!==d.instructions.amount?`${le(se.amount,se.decimals,o)} ${se.symbol}`:ne(ce.send),De=d.expiresAt?Date.parse(d.expiresAt)-r:Number.POSITIVE_INFINITY,Be=De<=0,Yt=Pr(De),Qe=t.phase==="quoting",jn=e.invoice.amountPaid?null:Hr(d,e.invoice.totalMinor),ut=(t.invoiceStatus??e.invoice.status)==="underpaid",kn=f==="page",Yn=A?va(String(A.amount),A.decimals,o):null,Mt=ut?rn(d,r,n,M,o):null,Zt=e.invoice.totalMinor?ye(Re(e.invoice.totalMinor),o):null,Cn=!!(s&&d.payer&&Ue(s,h)===d.payer),kt=g==="eip155"&&s&&s.chainId!==k&&!!x?.switchChain,Zn=L.status!=="idle"||t.phase==="submitting"||Qe||T.step!=="idle",Ve=Yi(k,s,n),Jt=()=>{a.getState().requestQuote();},Ka=t.payerProof,Bt=Us(Ka,D),Sn=Bt?Ta(On(t.error)?t.error:null,T.problem,n,{wallet:s?.name??"",network:U,merchant:M}):null,Ot=t.phase==="awaitingPayment"&&!(Bt&&On(t.error))?t.error:void 0,Pn=lm(n,{wallet:s?.name??"",network:U,merchant:M},L.problem,Ot),Jn=!L.problem&&(Ot?.code==="payment_failed"||Ot?.code==="payment_mismatch"),Nn=()=>{c$1(h)||Ne(true);},Ee;Be?Ee={label:ut?n.outcome.payRest:n.pay.newPrice,run:Jt}:Cn?kt?Ee={label:jsx(ge,{label:n.pay.switchTo,values:{network:U}}),run:()=>{L.switchNetwork();}}:Bt?Ee={label:n.payerProof.confirmToPay,run:()=>{T.confirm();}}:Ee={label:Jn?n.pay.payAgain:jsx(ge,{label:D==="transfer"?n.pay.payAmount:n.pay.signToPay,values:{amount:ne(ce.send)}}),run:()=>{m.handlers?.onSubmit?m.handlers.onSubmit({quote:d,method:h,proceed:L.pay}):L.pay();},disabled:!!P||L.problem==="sentUnconfirmed"}:Ee={label:n.pay.connect,run:Nn};let mt=T.step==="switching"?"switch":T.step==="signing"?"proof":L.status==="switching"?"switch":L.status==="submitting"||t.phase==="submitting"?"submitting":L.status==="wallet"?D==="transfer"?"confirm":"sign":null,Xn=e.invoice.number??e.invoice.id,tt=s??L.askedWallet,ea={wallet:tt?.name??"",invoice:Xn,merchant:M};return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:re,inert:we,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",we&&"novapay:hidden"),children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-3 novapay:px-5 novapay:py-4",kn&&"novapay-page-screen novapay-page-pay"),children:[jsx("h2",{...Nt,className:"novapay:sr-only",children:n.pay.title}),s&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:h-7 novapay:w-7 novapay:shrink-0",children:jsx(_n,{walletId:s.walletId,icon:s.icon})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:s.name}),jsx("span",{className:cn$1($,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(s.address),network:ve(s.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:Nn,className:nn,children:n.pay.change})]}),kt&&Cn&&!Be&&jsxs("div",{role:"status",className:cn$1(sa,"novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(yt,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsxs("span",{children:[jsx("strong",{className:"novapay:block",children:n.pay.wrongNetwork}),c(n.pay.wrongNetworkText,{current:ve(s.chainId),network:U})," ",n.pay.switchHint]})]}),Ve&&!Be&&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(or,{"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:cn$1(Oe,"novapay:block"),children:ut?n.pay.youSendRest:n.pay.youSend}),jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:gap-2",kn&&"novapay-page-amount-row"),children:[jsx("span",{className:cn$1($,"novapay:text-[28px] novapay:font-bold novapay:leading-tight",kn&&"novapay-page-amount"),children:le(ce.send,d.decimals,o)}),jsx("span",{className:cn$1($,"novapay:text-sm novapay:font-semibold"),children:d.instructions.symbol}),jsx(Fn,{text:ha(ce.send,d.decimals),label:n.pay.copyAmount,copiedLabel:n.pay.copied})]}),jsxs("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[c(n.pay.onNetwork,{network:U}),Zt&&!ce.fee&&!ut&&jsxs(Fragment$1,{children:[" \xB7 ",c(n.pay.fiatValue,{amount:Zt,currency:e.invoice.currency})]})]})]}),ce.fee&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsxs(xe,{children:[jsx(H,{name:ut?n.pay.invoiceRest:n.pay.invoiceTotal,children:le(ce.receives,d.decimals,o)}),jsx(H,{name:c(n.pay.transferFee,{percent:ce.fee.percent}),children:le(ce.fee.amount,d.decimals,o)}),jsx(H,{name:c(n.pay.merchantReceives,{merchant:M}),children:ne(ce.receives)})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.pay.transferFeeNote})]}),!Be&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2 novapay:text-xs",children:[jsx(on,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:text-[var(--tuwa-text-secondary)]"}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:flex-1",children:c(Mt?n.pay.restTimeLeft:n.pay.priceLocked,{time:st(De)})}),!ut&&jsx(ht,{disabled:Qe,onClick:Jt,children:n.pay.refreshPrice})]}),Yt&&!Mt&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-text-accent)] novapay:px-3 novapay:py-2",children:[jsx("span",{"aria-hidden":true,className:"novapay:text-xs",children:c(n.pay.priceEnding,{time:st(De)})}),jsx("span",{role:"status",className:"novapay:sr-only",children:c(n.pay.priceEnding,{time:st(to)})}),jsx("button",{type:"button",onClick:Jt,disabled:Qe,className:Xo,children:jsx(ge,{label:n.pay.keepPrice,values:{minutes:Math.round(e.quoteTtlSeconds/60)}})})]}),Be&&jsx(Q,{children:n.pay.priceExpired}),Mt&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:Mt}),P&&!Be&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-xs",children:[jsxs("div",{role:"alert",children:[jsx("strong",{className:"novapay:block",children:n.pay.notEnough}),c(n.pay.walletHas,{amount:ne(P.have),network:U}),"."," ",c(n.pay.shortBy,{short:ne(P.short),need:ne(P.need)})]}),z.length>0&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:n.pay.payFromBalance}),z.map(({method:We,balance:Va})=>jsxs("button",{type:"button",onClick:()=>{let ta=s?Ue(s,We):null;a.getState().selectMethod(We.id),a.getState().setPayer(ta),y();},className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-transparent novapay:px-2.5 novapay:py-1.5 novapay:text-left novapay:text-xs novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-bg-muted)]",ie),children:[jsxs("span",{className:"novapay:font-semibold",children:[We.symbol," \xB7 ",ve(We.chainId)]}),jsx("span",{className:cn$1($,"novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.youHave,{amount:`${le(String(Va),We.decimals,o)} ${We.symbol}`})})]},We.id))]}),e.merchant.fundingUrl&&jsxs("span",{children:[c(n.pay.topUp,{symbol:d.instructions.symbol})," ",jsxs("a",{href:e.merchant.fundingUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ie),children:[c(n.pay.getToken,{symbol:d.instructions.symbol})," \u2197"]})]})]}),jsxs(xe,{children:[jn!==null&&jsx(H,{name:n.pay.rate,children:c(n.pay.rateValue,{symbol:d.instructions.symbol,price:cm(jn,o),currency:e.invoice.currency})}),jsx(H,{name:n.pay.networkFee,children:jsxs("span",{className:"novapay:inline-flex novapay:flex-col novapay:items-end novapay:gap-0.5",children:[D!=="transfer"?jsx("span",{className:"novapay:text-[var(--tuwa-success-text)]",children:c(n.pay.merchantPaysGas,{merchant:M})}):Yn?c(n.pay.gasEstimate,{amount:`${Yn} ${A?.symbol}`}):n.pay.gasFromWallet,d.gasless&&jsx(ht,{onClick:()=>I(!b),children:b?c(n.pay.payGasless,{merchant:M}):n.pay.payWithGas})]})}),jsxs(H,{name:n.pay.to,children:[jsx(He,{hash:d.instructions.to,chainId:k}),jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:M})]})]}),Bt&&!Be&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.payNote}),Sn&&jsx(Q,{children:Sn}),Pn&&jsx(Q,{children:Pn}),!L.problem&&jsx(da,{error:Ot}),Se&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(Z,{children:[jsx(X,{busy:Zn,disabled:Ee.disabled,onClick:Ee.run,children:Ee.label}),jsx(ae,{disabled:Qe,onClick:l,children:ut?n.pay.backFromRest:n.pay.back}),jsx($e,{children:pm(c(n.pay.disclaimer,{merchant:M}),...Nr(e)?[c(n.pay.disclaimerScreening,{merchant:M})]:[])})]})]}),mt==="proof"&&jsx(Wn,{kind:"proof",walletName:tt?.name??"",walletId:tt?.walletId??"",walletIcon:tt?.icon,amount:Me,merchant:M,network:U,to:shortAddress(d.instructions.to),priceTime:null,text:c(Na(s)?n.payerProof.promptPasskey:n.payerProof.promptText,ea),details:[...T.request?[{name:n.payerProof.site,value:T.request.domain}]:[],{name:n.payerProof.invoice,value:Xn},{name:n.payerProof.merchant,value:M}],hint:T.request?c(n.payerProof.signInRequest,{wallet:tt?.name??"",site:T.request.domain}):void 0,onRetry:()=>{T.confirm();},onCancel:T.dismiss,stepHeight:ke}),mt&&mt!=="proof"&&jsx(Wn,{kind:mt,walletName:tt?.name??"",walletId:tt?.walletId??"",walletIcon:tt?.icon,amount:Me,merchant:M,network:U,to:shortAddress(d.instructions.to),priceTime:Be?null:st(De),onRetry:D==="relay"?()=>{L.pay();}:void 0,onCancel:T.step==="switching"?T.dismiss:L.dismiss,stepHeight:ke})]})}var Io=4;function nc(e){let{size:t,data:a}=encode(e,{ecc:"M",border:0}),n="";return a.forEach((o,r)=>o.forEach((s,i)=>{s&&(n+=`M${i+Io} ${r+Io}h1v1h-1z`);})),{size:t+Io*2,path:n}}function Lo({value:e,label:t,className:a}){let n=E(),o=cn$1(a,Y(n,"qrCode")),{size:r,path:s}=useMemo(()=>nc(e),[e]),i=n.customization.components?.QrCode;return i?jsx(i,{value:e,label:t,className:o}):jsxs("svg",{role:"img","aria-label":t,viewBox:`0 0 ${r} ${r}`,shapeRendering:"crispEdges",className:cn$1("novapay:block novapay:rounded-[var(--tuwa-rounded-corners)]",o),children:[jsx("rect",{width:r,height:r,fill:"#ffffff"}),jsx("path",{d:s,fill:"#111827"})]})}function vm({payUrl:e}){let{labels:t,backToMethods:a,display:n}=E();return jsxs(Fragment$1,{children:[jsx(de,{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(Lo,{value:e,label:t.qr.handoffCode,className:cn$1("novapay:h-48 novapay:w-48",n==="page"&&"novapay-page-qr-handoff")}),jsx(Fn,{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(Z,{children:jsx(ae,{onClick:a,children:t.qr.back})})]})}function oc(){let e=E(),{checkout:t,state:a,store:n,labels:o,locale:r,now:s,payUrl:i,backToMethods:c$1}=e,l=a.quote;if(!t)return null;if(!l||l.instructions.family!=="solana")return i?jsx(vm,{payUrl:i}):null;let p=Fa(a);if(p.status!=="verified"&&a.phase!=="submitting")return jsx(Ea,{payee:p});let{instructions:m}=l,y=ve(he(m)),f=`${le(l.amountToSend,l.decimals,r)} ${m.symbol}`,v=l.expiresAt?Date.parse(l.expiresAt)-s:Number.POSITIVE_INFINITY,d=v<=0,R=a.phase==="quoting",h=(a.invoiceStatus??t.invoice.status)==="underpaid",g=h?rn(l,s,o,t.merchant.name,r):null,x=h?t.invoice.originWallet:null,k=x?c(o.qr.restHint,{wallet:shortAddress(Et(x))}):o.qr.solanaHint;return jsxs(Fragment$1,{children:[jsxs(de,{title:o.qr.solanaTitle,subtitle:k,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(Lo,{value:m.solanaPayUrl,label:c(o.qr.solanaCode,{amount:f}),className:cn$1("novapay:h-44 novapay:w-44 novapay:shrink-0",e.display==="page"&&"novapay-page-qr",d&&"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})]}),h&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:o.pay.youSendRest}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn$1($,"novapay:text-2xl novapay:font-bold"),children:le(l.amountToSend,l.decimals,r)}),jsx(Fn,{text:ha(l.amountToSend,l.decimals),label:o.pay.copyAmount,copiedLabel:o.pay.copied})]}),jsxs("div",{"data-qr-line":true,className:cn$1($,"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-x-1 novapay:gap-y-0.5 novapay:text-[var(--tuwa-text-secondary)]"),children:[jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[m.symbol," \xB7"]}),jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[y," \xB7"]}),jsx("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:jsx(He,{hash:m.to,chainId:he(m)})})]}),!d&&jsxs(Fragment$1,{children:[jsxs("span",{role:"status",className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(QuasarLoader,{size:14,accent:"var(--tuwa-pending-icon)"}),o.qr.waiting]}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(g?o.pay.restTimeLeft:o.pay.priceLocked,{time:st(v)})})]})]})]}),d&&jsx(Q,{children:o.pay.priceExpired}),g&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:g}),jsxs("p",{className:cn$1(sa,"novapay:m-0 novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(yt,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),o.qr.exchangeWarning]})]}),jsxs(Z,{children:[d?jsx(X,{busy:R,onClick:()=>{n.getState().requestQuote();},children:h?o.outcome.payRest:o.pay.newPrice}):jsx("a",{href:m.solanaPayUrl,className:cn$1(Tt,Y(e,"primaryButton")),children:o.qr.openInWallet}),jsx(ae,{onClick:c$1,children:h?o.pay.backFromRest:o.qr.back})]})]})}function _o(e){switch(e){case "confirm":return "pending";case "unconfirmed":case "underpaid":return "warning";case "paid":return "success";case "failed":case "blocked":case "error":return "error";case "needs_review":case "refunded":case "expired":case "cancelled":case "replaced":return "neutral";default:return null}}function Pm(){let{labels:e}=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 Nm(){let{labels:e,state:t,store:a}=E(),n=t.error?.code==="checkout_not_found";return jsxs("div",{role:"alert",className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:p-8 novapay:text-center",children:[jsx(yt,{"aria-hidden":true,className:"novapay:h-7 novapay:w-7 novapay:text-[var(--tuwa-error-icon)]"}),jsx("h2",{...Nt,className:at,children:e.error.title}),jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-[13px] novapay:text-[var(--tuwa-text-secondary)]",children:n?e.error.notFound:e.error.generic}),!n&&jsx(ae,{onClick:()=>{a.getState().load();},className:"novapay:w-auto novapay:px-6",children:e.common.retry})]})}var Tm=new Set(["paid","partially_refunded","refunded"]);function sc(){let{screen:e,customization:t}=E(),a=t.components?.screens?.[e];return a?jsx(a,{screen:e}):e==="loading"?jsx(Pm,{}):e==="error"?jsx(Nm,{}):e==="buyer"?jsx(Zr,{}):e==="method"?jsx(li,{}):e==="confirmWallet"?jsx(zs,{}):e==="pay"?jsx(tc,{}):e==="qr"?jsx(oc,{}):e==="confirm"?jsx(Ds,{}):e==="failed"?jsx(ti,{}):e==="paid"?jsx(vi,{}):jsx(Xs,{kind:e})}function Rm({className:e,withDetails:t,leave:a}){let n=E(),{checkout:o,locale:r,labels:s,now:i,customization:c$1,display:l}=n,{Header:p=ys,Summary:m=cs,CompactSummary:y=ls}=c$1.components??{},f=c$1.config?.deadlineAnnouncements,{screen:v}=n,d=useRef(null),R=useRef(v);useEffect(()=>{let w=R.current;R.current=v;let A=d.current;if(!A||w===v||w==="loading")return;let L=A.ownerDocument.activeElement;if(L&&L!==A.ownerDocument.body&&!A.contains(L))return;let T=A.querySelector("[data-novapay-scroll] [data-novapay-heading]");if(l!=="page")return T?.focus();A.getBoundingClientRect().top<0&&A.scrollIntoView({block:"start"}),T?.focus({preventScroll:true});},[v,l]);let[h,g]=useState(""),x=useRef(null),k=o?.invoice.dueAt?Date.parse(o.invoice.dueAt):null,S=o?En(o.invoice.status,v,o.invoice.restPayable)==="paying":false;useEffect(()=>{if(k===null)return;let w=k-i,A=kr(x.current,w,f);x.current=w,A!==null&&S&&g(A===1?s.summary.oneMinuteLeft:c(s.summary.minutesLeft,{minutes:A}));},[k,i,s,f,S]);let b=l==="page",I=er[b?"page":"default"],F=_o(v),D=c$1.components?.StatusEdge??StatusEdge;return jsxs("div",{ref:d,lang:r,className:cn$1(I.frame,ia(l).frame,e),children:[o&&jsx("aside",{inert:!!a,className:cn$1(I.aside,Y(n,"summary")),children:jsx(m,{})}),jsxs("div",{inert:!!a,className:cn$1("novapay:relative",I.main),children:[F&&jsx(D,{tone:F,className:cn$1("novapay:z-20",Y(n,"statusEdge",{tone:F}))}),jsxs(Qi,{active:!!F&&!b&&!c$1.config?.animation?.disabled,children:[jsx(p,{withDetails:t}),jsxs("div",{className:"novapay:sm:hidden",children:[o&&jsx(y,{className:Y(n,"compactSummary")}),jsx(fs,{withDetails:t})]}),jsx("div",{"data-novapay-scroll":"",className:cn$1(I.area,Y(n,"body")),children:b?jsx("div",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",!c$1.config?.animation?.disabled&&"novapay-page-fade"),children:jsx(sc,{})},F?"status":v):jsx(sc,{})})]})]}),jsx("div",{role:"status","aria-live":"polite",className:"novapay:sr-only",children:h}),a&&jsx(oi,{onStay:a.onStay,onLeave:a.onLeave})]})}function Hw({token:e,display:t="modal",open:a=true,onOpenChange:n,onClose:o,baseUrl:r,api:s,EventSource:i,pollMs:c$1,payUrl:l,payoutAddresses:p,onConnectWallet:m,onPaid:y,autoReturnSeconds:f$1,onContact:v,locale:d,className:R,customization:h}){let g$1=pt(),[x,k]=useState({from:e,token:e}),S=x.from===e?x.token:e,[b,I]=useState(t!=="modal"||a);!b&&(t!=="modal"||a)&&I(true);let F=useRef(g$1.adapters);useEffect(()=>{F.current=g$1.adapters;},[g$1.adapters]);let D=useCallback(te=>Ei(F.current,te),[]),w=bi({token:S,baseUrl:r??g$1.baseUrl,api:s,EventSource:i,pollMs:c$1,enabled:b,payee:{verify:D,addresses:p}}),A=wi(w,te=>te),L=A.checkout,T=f(d),[me,P]=useState(null),W=Ar({picked:me,page:T,invoice:A.locale??L?.invoice.locale}),z=Gn(W),Se=!!L&&b&&Dr(A.phase,f$1,g(W)),we=Ni(1e3,Se)-(A.clockSkewMs??0),re=Aa(),ke=Da(m),_=g$1.adapters,[M,U]=useState("wallet"),[ne,ce]=useState(false),[se,Me]=useState(null);L&&se?.store!==w&&Me({store:w,paid:Tm.has(L.invoice.status)});let[De,Be]=useState(false),[Yt,Qe]=useState(false),[jn,ut]=useState(S);jn!==S&&(ut(S),ce(false),U("wallet"),Qe(false));let kn=A.payerProof==="confirmed"&&!!A.error,Yn=A.error?.code==="payer_mismatch";Yt&&(A.phase==="awaitingPayment"||kn||Yn)&&Qe(false);let Mt=(A.invoiceStatus??L?.invoice.status)==="underpaid"?L?.invoice.originWallet??null:null,Zt=te=>!Mt||sn(te,Mt),Cn=L?.methods.find(te=>te.id===A.methodId),kt=Cn?Ue(re,Cn):null,Zn=Sr({open:Yt,storePayer:A.payer,payer:kt,paysRest:!kt||Zt(kt)});Zn==="leave"&&Qe(false);let Ve=useRef(null),[Jt,Ka]=useState(false);!Jt&&L&&g(W)&&Ka(true);let Bt={payWith:M,handoff:ne,confirmWallet:Yt,labelsReady:Jt||!L},Sn=eo(A,Bt),[Ot,Pn]=useState(null),[Jn,Nn]=useState(null);Sn==="confirm"?Ot!==w&&Pn(w):Ot===w&&(Pn(null),A.error?.code==="payment_failed"&&Nn(A.error));let Ee=Jn!==null&&A.error===Jn?eo(A,{...Bt,afterFailure:true}):Sn,mt=async()=>{await Hs(w,Qe);},Xn=Ci(w),tt=$i({store:w,screen:Ee}),[ea,We]=useState(null),Va=Hi({store:w,state:A,walletTxKey:ea?.store===w?ea.txKey:null});di(A.phase,L?.invoice,y,se?.store===w&&se.paid),xi({state:A,screen:Ee,now:we,locale:L||T?W:null,handlers:h?.handlers});let ta=te=>_?.find(je=>je.family===te),Oo=qi({store:w,adapterFor:ta,pulsar:g$1.pulsar,labels:z,locale:W}),Cc=useCallback(te=>{We({store:w,txKey:te.txKey}),Oo(te);},[w,Oo]),Sc=useEffectEvent(()=>{if(!L)return;let{quote:te,phase:je}=w.getState();if(re&&Ve.current){let aa=L.methods.find(Lc=>Lc.id===Ve.current),ja=aa?Ue(re,aa):null;if(!ja)return;Ve.current=null,w.getState().setPayer(ja),Zt(ja)&&mt();return}if(je==="selectMethod"||je==="underpaid"||je==="blocked"){if(A.payer===null||kt===A.payer)return;w.getState().setPayer(kt),Zn==="follow"&&mt();return}if(!re)return;let Tn=L.methods.find(aa=>aa.id===te?.methodId),na=Tn?Ue(re,Tn):null,Uo=Cr({phase:je,quotePayer:te?.payer,payer:na});if(Uo==="release")return w.getState().releaseQuote();Uo==="keep"||!na||(w.getState().setPayer(na),Zt(na)&&mt());}),Pc=A.quote?.payer,Nc=!!L;useEffect(()=>Sc(),[re?.address,re?.chainId,re?.connectorType,A.phase,Pc,Nc]),useEffect(()=>{ke.connecting||(Ve.current=null);},[ke.connecting]);let[Do,Tc]=useState(false);Ee==="buyer"&&!Do&&Tc(true);let Ga=useMemo(()=>t==="modal"?()=>{n?.(false),o?.();}:o,[t,n,o]),Rc=Ga&&(()=>ao(w.getState().phase,w.getState().error,w.getState().invoiceStatus)&&!Oa(w)?Be(true):Ga()),Ic=De?{onStay:()=>Be(false),onLeave:()=>{Be(false),w.getState().releaseQuote(),Ga?.();}}:null,Wo=h??{},Ec={store:w,state:A,checkout:L,screen:Ee,locale:W,labels:z,setLocale:async te=>{let je=me;P({locale:te,page:T}),await w.getState().setLocale(te)||P(je);},now:we,handedOverAt:Xn,qrShown:tt,paymentSent:Va||Oa(w),close:Rc,wallet:re,payWith:M,setPayWith:U,payUrl:l,connectWallet:te=>{let je=Ye(te);Ve.current=te.id;let Tn=je!==null&&ke.connect(je);return Tn||(Ve.current=null),Tn},connectFamily:te=>ke.connect(te),openedPaid:se?.store===w&&se.paid,adapterFor:ta,handoff:ne,setHandoff:ce,backToMethods:()=>{ce(false),Qe(false),w.getState().releaseQuote();},payAfterFailure:()=>{Nn(null),w.getState().clearError();},confirmWallet:Yt,setConfirmWallet:Qe,lockPrice:mt,onPaymentSent:Cc,openInvoice:te=>k({from:e,token:te}),onContact:v,autoReturnSeconds:f$1??(t==="modal"?0:5),display:t,customization:Wo},za=cn$1(R,Y({customization:Wo,screen:Ee,state:A,checkout:L},"container")),Qa=jsx(Go,{value:Ec,children:jsx(MotionConfig,{reducedMotion:h?.config?.animation?.disabled?"always":"user",children:jsx(Rm,{withDetails:Do,leave:Ic,className:t==="modal"?za:void 0})})});if(t==="modal")return jsx(Dialog,{open:a,onOpenChange:te=>{if(!te&&De)return Be(false);if(!te&&ao(w.getState().phase,w.getState().error,w.getState().invoiceStatus)&&!Oa(w))return Be(true);n?.(te),te||o?.();},children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-auto",animateHeight:_o(Ee)===null,children:[jsx(DialogTitle,{className:"novapay:sr-only",children:c(z.common.dialogTitle,{merchant:L?.merchant.name??""})}),Qa]})});let qo=c(z.common.dialogTitle,{merchant:L?.merchant.name??""});return t==="page"?jsx(Im,{label:qo,className:za,children:Qa}):jsx("section",{"aria-label":qo,className:cn$1("novapay:overflow-hidden novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)]",ia(t).section,za),children:Qa})}function Im({label:e,className:t,children:a}){return jsx("div",{className:"novapay-page",children:jsx("section",{"aria-label":e,className:cn$1(ia("page").section,"novapay-page-block",t),children:a})})}function ic(e){if(!e.to)return null;let t=parseCaip19AssetId(e.assetId),a={to:e.to,token:!t||t.assetNamespace==="slip44"?"native":t.assetReference,amount:e.amount,decimals:e.decimals,symbol:e.symbol},n=Rt(e.chainId);if(n==="solana")return {family:n,chainId:e.chainId,...a,reference:"",solanaPayUrl:""};let o=n==="eip155"?toEvmChainId(e.chainId):void 0;return o===void 0?null:{family:"eip155",chainId:o,...a}}function lc(e){let t=b$1(e);return t==="switchFailed"?"wrongNetwork":t==="notAuthorized"||t==="alreadyPending"||t==="sentUnconfirmed"?"failed":t}var Mo=new WeakMap,bn=new WeakMap;function pc({store:e,invoiceId:t,invoice:a,params:n,open:o,labels:r,locale:s,onConnectWallet:i}){let c$1=useStore(e),{adapters:l,pulsar:p}=pt(),m=Aa(),y=Da(i),[f,v]=useState("idle"),[d,R]=useState(null),[,h]=useState(0),g=bn.has(e),x=useRef(0),k=useRef(o),S=c$1.sentTransaction?.txHash??c$1.refund?.txHash??null,b=c$1.instructions?ic(c$1.instructions):null,I=b?.family??null,F=b?he(b):c$1.instructions?.chainId??null,D=l?.find(U=>U.family===I),w=m&&m.family===I?m:null,A=F?ve(F):"",L=d&&d.account===w?.address?d.problem:null,T=U=>R(U?{problem:U,account:w?.address}:null),me=!!(w&&I==="eip155"&&F&&w.chainId!==F),P=c$1.instructions,W=P?`${le(P.amount,P.decimals,s)} ${P.symbol}`:"",z=Wa(b&&w&&D?`balance|${F}|${w.address}|${b.token}`:null,()=>D.getBalance({chainId:F,account:w.address,token:b.token}),c$1.refund?.id),Se=xn(b&&w&&D?.estimateFee?`fee|${F}|${w.address}|${b.token}`:null,()=>D.estimateFee({instructions:b,account:w.address}));useEffect(()=>{!n||Mo.get(e)===t||e.getState().phase!=="idle"||(Mo.set(e,t),e.getState().start(t,n));},[n,e,t]),useEffect(()=>{o&&!k.current&&!n&&e.getState().phase==="confirmed"&&e.getState().reset(),k.current=o;},[o,n,e]),useEffect(()=>(e.getState().keepFollowing(),()=>e.getState().stopFollowing()),[e]),useEffect(()=>{let U=true;return bn.get(e)?.settled.then(()=>{U&&h(ne=>ne+1);}),()=>{U=false;}},[e]);let Ne=async(U,ne,ce)=>{if(!p||!D?.pulsarTransaction||!c$1.refund)return;let se={invoice:a??t,amount:W};try{await p.injectExternalPendingTxs([D.pulsarTransaction({txKey:U,instructions:ce,account:ne.address,connectorType:ne.connectorType,title:c(r.refund.txTitle,se),description:c(c$1.refund.unmatchedTransfer?r.refund.txDescriptionSender:r.refund.txDescription,se),payload:{quasarRefund:c$1.refund.id}})]);}catch{}},we=async()=>{if(T(null),!(!me||!D?.switchChain))try{v("switching"),await D.switchChain(F);}catch(U){T(lc(U));}finally{v("idle");}},re=async()=>{if(T(null),!b)return T("noRecipient");if(!w||!D)return T("unsupported");if(c$1.sentTransaction){await e.getState().submit(c$1.sentTransaction);return}let U=BigInt(b.amount)+(b.token==="native"&&Se?Se.amount:0n);if(typeof z=="bigint"&&z<U)return T("notEnough");if(I&&b.to&&isSameAddress(I,w.address,b.to))return T("fromBuyer");if(!await e.getState().recheck()){let se=e.getState(),Me=se.error?.code==="refund_repriced";se.phase==="awaitingTransfer"&&!se.sentTransaction&&!Me&&T("unreachable");return}let ne=++x.current,ce=()=>x.current===ne;try{me&&D.switchChain&&(v("switching"),await D.switchChain(F)),ce()&&v("wallet");let se=await D.sendTransfer({instructions:b,account:w.address,connection:w.connection});ce()?v("idle"):R(null),Ne(se,w,b),await e.getState().submit({txHash:se,from:w.address});}catch(se){ce()?(v("idle"),T(lc(se))):R(null);}},ke=async()=>{if(bn.has(e))return;let U,ne={settled:new Promise(Me=>U=Me)},ce=()=>{bn.get(e)===ne&&bn.delete(e),U(),h(Me=>Me+1);},se=setTimeout(ce,6e5);bn.set(e,ne),h(Me=>Me+1);try{await re();}finally{clearTimeout(se),ce();}},_=f!=="idle"?f:w?"confirm":"connect";return {step:c$1.phase==="idle"?n&&!c$1.error&&Mo.get(e)!==t?"requesting":"amount":c$1.phase==="awaitingTransfer"?_:c$1.phase,phase:c$1.phase,refund:c$1.refund,error:c$1.error,transfer:b,chainId:F,network:A,amount:W,wallet:w,wrongNetwork:me,balance:z,fee:Se,problem:L??(c$1.instructions&&!b?"noRecipient":null),txKey:S,transactionUrl:U=>F?D?.explorerUrl?.({chainId:F,txKey:U}):void 0,addressUrl:U=>F?D?.explorerAddressUrl?.({chainId:F,address:U}):void 0,canConnect:y.canConnect,connecting:y.connecting,preview:async U=>{let ne=await e.getState().preview(t,U);return ne||(e.getState().error?"refused":null)},start:async U=>{T(null),await e.getState().start(t,U);},connect:()=>{I&&y.connect(I);},switchNetwork:we,send:ke,dismiss:()=>{x.current++,v("idle"),T("stillInWallet");},sending:g}}function bk({label:e,className:t,disabled:a,...n}){let[o,r]=useState(false),s=Gn(n.locale??"en");return jsxs(Fragment$1,{children:[jsx("button",{type:"button",disabled:a,onClick:()=>r(true),className:cn$1(Tt,"novapay:w-auto novapay:px-4",t),children:e??s.refund.button}),jsx(qm,{...n,open:o,onOpenChange:r})]})}function qm({open:e,onOpenChange:t,locale:a="en",onRefunded:n,...o}){let r=Gn(a),s=pc({store:o.store,invoiceId:o.invoiceId,invoice:o.invoice,params:e?o.params:void 0,open:e,labels:r,locale:a,onConnectWallet:o.onConnectWallet}),i=useEffectEvent(p=>n?.(p)),c$1=s.phase==="confirmed"?s.refund:null;useEffect(()=>{c$1&&i(c$1);},[c$1]);let l=o.invoice?c(r.refund.title,{invoice:o.invoice}):r.refund.button;return jsx(Dialog,{open:e,onOpenChange:t,children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-[440px]",children:[jsxs("div",{className:"novapay:flex novapay:items-center novapay:justify-between novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:px-5 novapay:py-3",children:[jsx(DialogTitle,{className:cn$1($,"novapay:m-0 novapay:truncate novapay:text-sm novapay:font-bold"),children:l}),jsx("button",{type:"button","aria-label":r.refund.close,onClick:()=>t(false),className:Pt,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]}),jsx(Um,{flow:s,labels:r,locale:a,close:()=>t(false),...o})]})})}function Um({flow:e,labels:t,locale:a,close:n,currency:o="USD",refundable:r,details:s,onRecord:i}){let c$1=t.refund,l={network:e.network,symbol:e.transfer?.symbol??e.refund?.assetId??"",amount:e.amount,wallet:e.wallet?.name??""},p=e.refund?.txHash??e.txKey,m=i&&jsxs(Fragment$1,{children:[jsx(ae,{onClick:i,children:c$1.record}),jsx($e,{children:c$1.recordHint})]});switch(e.step){case "amount":return jsx(jm,{flow:e,labels:t,locale:a,currency:o,refundable:r});case "requesting":case "submitting":return jsx(fc,{children:e.step==="requesting"?c$1.requesting:c$1.submitting});case "switching":case "wallet":return jsxs(Fragment$1,{children:[jsxs(fc,{walletId:e.wallet?.walletId,walletIcon:e.wallet?.icon,children:[jsx("strong",{className:cn$1($,"novapay:text-sm"),children:c(e.step==="switching"?c$1.switchTitle:c$1.walletTitle,l)}),e.step==="wallet"&&jsx("span",{children:c(c$1.walletText,l)})]}),jsx(Z,{children:jsx(ae,{onClick:e.dismiss,children:t.walletPrompt.cancel})})]});case "connect":return jsxs(Fragment$1,{children:[jsxs(de,{title:c$1.connectTitle,subtitle:c(c$1.connectText,l),children:[e.problem==="noRecipient"&&jsx(Q,{children:c$1.noRecipient}),!e.canConnect&&jsx(Q,{children:c$1.connectUnavailable})]}),jsxs(Z,{children:[e.canConnect&&e.problem!=="noRecipient"&&jsx(X,{busy:e.connecting,onClick:e.connect,children:c$1.connect}),m]})]});case "confirm":return jsx(Ym,{flow:e,labels:t,locale:a,values:l,details:s?.confirm,recordAction:m});case "confirming":return jsxs(Fragment$1,{children:[jsxs(de,{title:c$1.onItsWay,children:[jsxs(xe,{children:[jsx(H,{name:c$1.status,children:c$1.pending}),p&&jsx(H,{name:c$1.transaction,children:jsx(He,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),jsx(H,{name:c$1.network,children:c(c$1.waiting,l)})]}),yc(e.refund)&&jsx($e,{children:c$1.slowNote})]}),jsxs(Z,{children:[jsx(ae,{onClick:n,children:c$1.close}),yc(e.refund)?m:jsx($e,{children:c$1.canClose})]})]});case "confirmed":return jsxs(Fragment$1,{children:[jsx(de,{title:c$1.refunded,children:jsxs(xe,{children:[e.refund?.creditNoteNumber&&jsx(H,{name:c$1.creditNote,children:e.refund.creditNoteNumber}),p&&jsx(H,{name:c$1.transaction,children:jsx(He,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),s?.done]})}),jsx(Z,{children:jsx(X,{onClick:n,children:c$1.done})})]});case "failed":return jsx(Qm,{flow:e,labels:t,locale:a,values:l,recordAction:m,close:n})}}var Hm={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"},mc=(e,t,a)=>{let n=e?.failureReason?Hm[e.failureReason]:void 0;return n?t[n]:c(t.failedText,a)},$m={withdrawn:"failedWithdrawnTitle",cancelled:"failedCancelledTitle",cancelled_final:"failedCancelledTitle"},dc=(e,t)=>t[e?.failureReason&&$m[e.failureReason]||"failedTitle"],Km={refund_repriced:"movedTitle",request_failed:"unreachable",amount_exceeds_refundable:"refusedAmount",invoice_not_refundable:"refusedNotRefundable",payment_unknown:"refusedNotRefundable",unmatched_transfer_not_refundable:"refusedNotRefundable",review_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"},Vm=600*1e3,yc=e=>{let t=e?.updatedAt??e?.createdAt;return !!t&&Date.now()-Date.parse(t)>Vm},Ha=(e,t)=>e.text??t[Km[e.code]??"refusedOther"],Gm=e=>e?.failureReason==="over_limit"||e?.failureReason==="tx_of_another_refund",zm=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 xc(e){let[t,a]=useState(false),[n,o]=useState(null),r=useRef(false);return useEffect(()=>(r.current=false,()=>{r.current=true;}),[]),{ask:async(i,c)=>{if(i?.mode==="fiat_value"){a(true);let l=await e.preview(i);if(r.current||(a(false),l==="refused"))return;if(l&&Or(c?{cryptoAmount:l.cryptoAmount,atPaymentRate:c.cryptoAmount}:l))return o({preview:l,request:i})}o(null),e.start(i);},checking:t,moved:n,back:()=>o(null)}}function gc({preview:e,request:t},a,n,o,r,s){let i=o.refund,c$1=l=>`${le(l,e.decimals,r)} ${e.symbol}`;return jsxs(Fragment$1,{children:[jsxs(de,{title:i.movedTitle,children:[jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(i.movedText,{symbol:e.symbol})}),jsxs(xe,{children:[jsx(H,{name:i.movedSend,children:c$1(e.cryptoAmount)}),e.atPaymentRate&&jsx(H,{name:i.movedAtPayment,children:c$1(e.atPaymentRate)}),e.received&&jsx(H,{name:i.movedReceived,children:c$1(e.received)})]}),s&&e.exactPossible&&jsx($e,{children:c(i.movedExact,{exact:i.modeExact})}),n.error&&jsx(Q,{children:Ha(n.error,i)})]}),jsxs(Z,{children:[jsx(X,{busy:a.checking,onClick:()=>{a.ask(t,e);},children:i.movedContinue}),jsx(ae,{disabled:a.checking,onClick:a.back,children:i.movedBack})]})]})}function Qm({flow:e,labels:t,locale:a,values:n,recordAction:o,close:r}){let s=t.refund,i=xc(e);return e.refund?.unmatchedTransfer?jsxs(Fragment$1,{children:[jsxs(de,{title:dc(e.refund,s),children:[jsx(Q,{children:mc(e.refund,s,n)}),jsx($e,{children:s.failedUnmatchedNote})]}),jsx(Z,{children:jsx(X,{onClick:r,children:s.close})})]}):i.moved?gc(i.moved,i,e,t,a,false):jsxs(Fragment$1,{children:[jsxs(de,{title:dc(e.refund,s),children:[jsx(Q,{children:mc(e.refund,s,n)}),e.error&&jsx(Q,{children:Ha(e.error,s)})]}),jsxs(Z,{children:[Gm(e.refund)?jsx(X,{onClick:r,children:s.close}):jsx(X,{busy:i.checking,onClick:()=>e.refund&&void i.ask(zm(e.refund)),children:s.sendRefund}),o]})]})}function fc({walletId:e,walletIcon:t,children:a}){return jsxs("section",{role:"status",className:"novapay:flex novapay:min-h-56 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:px-5 novapay:py-6 novapay:text-center",children:[jsx(ua,{walletId:e,walletIcon:t}),a]})}function jm({flow:e,labels:t,locale:a,currency:n,refundable:o}){let r=t.refund,s=useId(),i=useId(),[c$1,l]=useState("fiat_value"),[p,m]=useState(""),[y,f]=useState(""),v=xc(e),d=c$1==="exact_received"||p.trim()===""||/^\d{1,12}(\.\d{1,2})?$/.test(p.trim()),R=[{key:"fiat_value",title:r.modeFiat,hint:c(r.modeFiatText,{currency:n})},{key:"exact_received",title:r.modeExact,hint:r.modeExactText}],h="novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-sm novapay:text-[var(--tuwa-text-primary)]",g={mode:c$1,...c$1==="fiat_value"&&p.trim()&&{amount:p.trim()},...y.trim()&&{reason:y.trim()}};return v.moved?gc(v.moved,v,e,t,a,true):jsxs(Fragment$1,{children:[jsxs(de,{title:r.amountTitle,children:[jsxs("fieldset",{disabled:v.checking,className:"novapay:contents",children:[jsx(vn,{label:r.amountTitle,items:[...R],value:c$1,getKey:x=>x.key,onChange:x=>l(x),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:x=>jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:text-sm novapay:font-semibold",children:x.title}),jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:x.hint})]})}),c$1==="fiat_value"&&jsxs("label",{htmlFor:s,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsxs("span",{children:[c(r.amount,{currency:n}),jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]})]}),jsx("input",{id:s,required:true,inputMode:"decimal",value:p,placeholder:"0.00","aria-invalid":!d||void 0,onChange:x=>m(x.target.value.replace(",",".")),className:cn$1($,h)}),o&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(r.amountHint,{amount:o})})]}),jsxs("label",{htmlFor:i,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsx("span",{children:r.reason}),jsx("input",{id:i,value:y,maxLength:500,onChange:x=>f(x.target.value),className:h})]})]}),e.error&&jsx(Q,{children:Ha(e.error,r)})]}),jsx(Z,{children:jsx(X,{busy:v.checking,disabled:!d,onClick:()=>{v.ask(g);},children:r.continue})})]})}function vc(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 Ym({flow:e,labels:t,locale:a,values:n,details:o,recordAction:r}){let s=t.refund,i=e.transfer,c$1=typeof e.balance=="bigint"&&i?`${le(e.balance.toString(),i.decimals,a)} ${i.symbol}`:null,l=e.fee?va(e.fee.amount.toString(),e.fee.decimals,a):null,p=e.fee&&l?`${l} ${e.fee.symbol}`:null,m={notEnough:c(s.notEnough,{...n,address:e.wallet?shortAddress(e.wallet.address):"",balance:c$1??""}),declined:c(s.declined,n),unsupported:c(s.unsupported,n),wrongNetwork:c(s.wrongNetwork,n),failed:s.failed,noRecipient:s.noRecipient,fromBuyer:s.failedFromBuyer,stillInWallet:c(t.walletPrompt.stillWaiting,n),unreachable:s.unreachable},y=!!e.problem,f=!!e.txKey;return jsxs(Fragment$1,{children:[jsxs(de,{title:y?s.notSent:s.confirmTitle,children:[jsxs(xe,{children:[jsx(H,{name:s.send,children:n.amount}),jsx(H,{name:s.network,children:n.network}),i&&jsx(H,{name:s.to,children:vc(jsx(He,{hash:i.to,explorerUrl:e.addressUrl(i.to),labels:t}),e.refund?.unmatchedTransfer?s.theSender:s.thePayer)}),e.wallet&&jsx(H,{name:s.from,children:vc(jsx(He,{hash:e.wallet.address,explorerUrl:e.addressUrl(e.wallet.address),labels:t}),c$1&&c(s.balance,{amount:c$1}))}),p&&jsx(H,{name:s.networkFee,children:c(s.feeEstimate,{amount:p})}),o]}),e.problem&&jsx(Q,{children:m[e.problem]}),e.problem&&!["noRecipient","unreachable","stillInWallet"].includes(e.problem)&&jsx($e,{children:s.nothingSent}),f&&e.error&&jsx(Q,{children:s.notHandedOver}),!f&&e.error&&e.problem!=="unreachable"&&jsx(Q,{children:Ha(e.error,s)})]}),jsxs(Z,{children:[e.problem!=="noRecipient"&&(e.wrongNetwork&&!f?jsx(X,{onClick:()=>{e.switchNetwork();},children:jsx(ge,{label:s.switchTo,values:n})}):jsx(X,{busy:e.sending,onClick:()=>{e.send();},children:f?s.handOver:s.sendRefund})),(y||f)&&r,!y&&!f&&e.wallet&&jsx(ae,{onClick:e.connect,children:t.pay.changeWallet})]})]})}function Xm(e){return e.appStore?e.novaConnect?"app":"appStore":e.ownConnection?"own":"none"}function $a(e){let t=useContext(SatelliteStoreContext),a=useContext(NovaConnectProviderContext);return Xm({appStore:t!=null,novaConnect:a!==void 0,ownConnection:e})}function Yk(){let e=pt(),t=$a(false);return e.connection??t}var td=()=>import('./OwnConnection-ET76SUMX.js').then(e=>({default:e.OwnConnection})),wc=lazy(td);var id=()=>process.env.NODE_ENV==="development";function oC({baseUrl:e,labels:t,customization:a,adapters:n,pulsar:o,ownConnection:r,onConnectWallet:s,children:i}){let c=useContext(Vn),l=$a(!!r),[p]=useState(l),[m]=useState(r),y=p==="own"?r??m:void 0,f=(p==="app"||p==="appStore")&&c.connection!==void 0&&c.connection!=="none",v=y?y.adapters:n??(f?c.adapters:void 0),d=useMemo(()=>({baseUrl:e,labels:t,customization:a,adapters:v,pulsar:o,connection:p,onConnectWallet:s}),[e,t,a,v,o,p,s]),R=useRef(null),h=!!r,g=!!v;return useEffect(()=>{if(!id())return;R.current??=new Set;let x=R.current,k=(S,b)=>{x.has(S)||(x.add(S),console.warn(`[NovaPaymentsProvider] ${b}`));};l!==p&&k("connection",`it keeps the wallet connection it chose on its first render ("${p}"), though the providers above now call for "${l}". Render it inside the app's SatelliteConnectProvider and NovaConnectProvider from the start.`),h&&p==="appStore"&&k("appStore","it is inside the app's SatelliteConnectProvider without NovaConnectProvider: it uses the app's wallet and never adds a second store, so `ownConnection` is not used. Connect wallets with `onConnectWallet`, or render it inside NovaConnectProvider."),h&&!g&&(p==="app"||p==="appStore")&&k("adapters","it uses the app's wallet connection, so the adapters of `ownConnection` are not used: pass `adapters` on the app's wagmi config to pay from the app's wallet.");},[l,p,h,g]),jsx(Vn.Provider,{value:d,children:y?jsx(Suspense,{fallback:null,children:jsx(wc,{own:y,children:i})}):i})}export{jm as AmountStep,Zr as BuyerScreen,oa as CheckoutContext,Go as CheckoutContextProvider,Rm as CheckoutFrame,ys as CheckoutHeader,Im as CheckoutPageRoot,Xr as CheckoutStepper,cs as CheckoutSummary,ls as CompactSummary,Ds as ConfirmScreen,Ym as ConfirmStep,zs as ConfirmWalletScreen,vo as ContactLink,cl as DEADLINE_ANNOUNCEMENTS,os as DeadlineTimer,ga as Disclosure,ti as FailedScreen,Qm as FailedStep,oi as LeaveDialog,us as LocaleSwitcher,xa as MerchantBadge,li as MethodScreen,fs as MobileSteps,Vn as NovaPaymentsContext,oC as NovaPaymentsProvider,Ma as OPEN_REQUEST_MS,rs as OrderLines,Ql as OrderTotal,Xs as OutcomeScreen,vi as PaidScreen,tc as PayScreen,Ea as PayeeScreen,Hw as PaymentCheckout,to as QUOTE_WARNING_MS,oc as QrScreen,bk as RefundButton,qm as RefundDialog,Um as RefundSteps,sc as ScreenBody,ro as SellerDetailsContent,ss as SummaryFooter,Wn as WalletPrompt,Et as addressOfWallet,$r as balanceShortfall,ha as baseUnitsToDecimal,Ya as buyerFields,jo as buyerIssues,hr as canPayWithQr,Y as checkoutClassName,eo as checkoutScreen,gr as checkoutSteps,Yo as cleanBuyer,vr as connectedWallet,_r as contactHref,Zo as countryOptions,kr as deadlineAnnouncement,En as deadlineState,ca as failedPaymentTx,Rt as familyOf,st as formatCountdown,va as formatFeeAmount,ye as formatFiat,le as formatTokenAmount,wr as groupMethodsByToken,Bi as handOverPayment,he as instructionsChainId,pn as invoiceTotals,On as isConfirmationError,Ir as isFinalPaymentFailure,ft as isInvoicePaymentOnTheWay,qt as isInvoicePaymentUnresolved,vt as isMovedMoneyFailure,Er as isPaidElsewhere,yo as isPayerProofError,Oa as isPaymentAccepted,ot as isPaymentOnTheWay,Pr as isQuoteEnding,sn as isSameWallet,yc as isSlow,Na as isSmartWallet,Ja as isWalletIconUrl,Ut as leftTheWalletText,Hs as lockPrice,Cr as lockedPriceOnWallet,la as methodErrorText,Ye as methodFamily,xr as methodToken,Re as minorToDecimal,ao as needsLeaveConfirm,Us as needsPayerProof,Dr as needsTheClock,ve as networkName,br as paidSteps,Ai as payInvoice,qr as payPath,Fa as payeeStatus,Ii as payeeVerified,Ue as payerFor,Ta as payerProofErrorText,Ln as paymentFailedText,Xa as priceAdjustment,nc as qrPath,Ur as quoteAmounts,Hr as quoteRate,Br as receivedAmount,Or as refundRateMoved,ic as refundTransfer,Ha as refusalText,rn as restRateText,Nr as screensPayingWallets,Tr as sentBeforeDeadline,Ar as shownLocale,It as unconfirmedFollowUp,Lr as unconfirmedTxKey,Mr as underpaidRest,xn as useAsyncValue,yi as useAutoReturn,E as useCheckoutContext,xi as useCheckoutEvents,wi as useCheckoutState,bi as useCheckoutStore,Aa as useConnectedWallet,pt as useNovaPayments,Ni as useNow,qe as useOptionalCheckoutContext,di as usePaidCallback,Sa as usePayerProof,Fi as usePayment,dn as usePaymentFacts,qi as usePaymentHandOver,Yk as usePaymentsConnection,Gn as usePaymentsLabels,pc as useRefund,Wa as useRereadValue,Da as useWalletConnection,Ei as verifyPayeeWith,tl as walletLabel,Sr as walletOnConfirmStep};
|
|
1
|
+
import {c,b,e,h,g,i,j,f,d}from'./chunk-SB5LW2OQ.js';import {b as b$1,a}from'./chunk-7HSDAUKN.js';export{a as PaymentWalletError,b as walletErrorKind}from'./chunk-7HSDAUKN.js';import {getChainName,cn as cn$1,DrawnCheck,CloseIcon,MorphText,WalletIcon,Dialog,DialogContent,DialogTitle,TokenIcon,QuasarLoader,StatusEdge,NetworkIcon,NovaSetIcon,CopyIcon,useNovaIcons,DrawnCross,pixelFlight}from'@tuwaio/nova-core';import {createContext,lazy,useContext,useState,useId,useMemo,Fragment,useRef,useEffect,useEffectEvent,useCallback,Suspense,useLayoutEffect}from'react';import {LockClosedIcon,FingerPrintIcon,QrCodeIcon,DevicePhoneMobileIcon,ArrowDownTrayIcon,NoSymbolIcon,ArrowPathRoundedSquareIcon,ArrowUturnLeftIcon,MagnifyingGlassIcon}from'@tuwaio/nova-icons/24/outline';import {jsxs,jsx,Fragment as Fragment$1}from'react/jsx-runtime';import {HashLink,TxProgressIndicator,TxStatusVisual}from'@tuwaio/nova-transactions';import {parseCaip2ChainId,toCaip2ChainId,formatCaip10AccountId,toEvmChainId,parseCaip19AssetId,parseCaip10AccountId,formatBaseUnits,shortAddress,OrbitAdapter,getAdapterFromConnectorType,getConnectorTypeFromName,formatConnectorName,getSolanaCluster,isSameAddress}from'@tuwaio/orbit-core';export{shortAddress}from'@tuwaio/orbit-core';import {useLabels,NovaTransactionsLabelsProvider}from'@tuwaio/nova-transactions/providers';import {MotionConfig,AnimatePresence}from'framer-motion';import {createCheckoutStore,payoutAddressesOf,withPayoutAddresses}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 ra=createContext(null),Go=ra.Provider;function I(){let e=useContext(ra);if(!e)throw new Error("useCheckoutContext must be used inside PaymentCheckout");return e}function qe(){return useContext(ra)}var Fc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Qo="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(" "),Mc=new Set(Qo);function Ya(e,t){let a=e==="full"||t,n=[{name:"email",required:true,autoComplete:"email",type:"email"}];return a?[...n,{name:"name",required:true,autoComplete:t?"organization":"name",type:"text"},{name:"country",required:true,autoComplete:"country",type:"country"},{name:"addressLine1",required:true,autoComplete:"address-line1",type:"text"},{name:"addressLine2",required:false,autoComplete:"address-line2",type:"text"},{name:"postalCode",required:false,autoComplete:"postal-code",type:"text"},{name:"city",required:false,autoComplete:"address-level2",type:"text"},...t?Bc():[]]:n}var Bc=()=>[{name:"taxId",required:true,autoComplete:"off",type:"text"},{name:"registrationNumber",required:false,autoComplete:"off",type:"text"}];function jo(e,t,a){let n={};for(let o of Ya(t,a)){let r=e[o.name]?.trim()??"";r?o.type==="email"&&!Fc.test(r)?n[o.name]="email":o.type==="country"&&!Mc.has(r.toUpperCase())&&(n[o.name]="country"):o.required&&(n[o.name]="required");}return n}function Yo(e){let t={};for(let[a,n]of Object.entries(e)){let o=n?.trim();o&&(t[a]=a==="country"?o.toUpperCase():o);}return t}function Zo(e){let t=new Intl.DisplayNames([e],{type:"region"});return Qo.map(a=>({code:a,name:t.of(a)??a})).sort((a,n)=>a.name.localeCompare(n.name,e))}var ce="novapay:focus-visible:outline-2 novapay:focus-visible:outline-offset-2 novapay:focus-visible:outline-[var(--tuwa-text-accent)]",Pt=`novapay:inline-flex novapay:h-7 novapay:min-w-7 novapay:items-center novapay:justify-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-1.5 novapay:text-[var(--tuwa-text-primary)] novapay:cursor-pointer novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] ${ce}`,$="novapay:font-mono novapay:tabular-nums",nt="novapay:font-mono novapay:font-bold novapay:uppercase novapay:tracking-[0.12em]",Oe=`${nt} novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-secondary)]`,en=`${nt} novapay:inline-flex novapay:shrink-0 novapay:items-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-1.5 novapay:py-0.5 novapay:text-[10px] novapay:leading-3`,tn={neutral:"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-primary)]",accent:"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",success:"novapay:border-[color-mix(in_srgb,var(--tuwa-success-icon)_35%,transparent)] novapay:bg-[var(--tuwa-success-bg)] novapay:text-[var(--tuwa-success-text)]",pending:"novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]",error:"novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:text-[var(--tuwa-error-text)]"},at=`novapay-title ${$} novapay:m-0 novapay:text-base novapay:font-bold novapay:text-balance novapay:outline-none`,Nt={tabIndex:-1,"data-novapay-heading":""},Jo=`${nt} novapay:box-border novapay:inline-flex novapay:min-h-11 novapay:w-full novapay:min-w-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2 novapay:text-center novapay:text-xs novapay:leading-4 novapay:no-underline novapay:transition-colors novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ce}`,Tt=`tuwa-solid ${Jo} novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-[var(--tuwa-text-on-accent)] novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)]`,sa=`${Jo} novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-standart-button-hover)]`,nn=`${nt} novapay:inline-flex novapay:min-h-7 novapay:shrink-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-2.5 novapay:py-1 novapay:text-[10px] novapay:leading-3 novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ce}`,Xo=`tuwa-solid ${nt} novapay:inline-flex novapay:min-h-8 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:px-3 novapay:py-1.5 novapay:text-center novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-on-accent)] novapay:transition-colors novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ce}`,ia="novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]";function ca(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 er={default:{frame:"tuwa-scanlines novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-col novapay:overflow-hidden novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:h-[680px] novapay:sm:flex-row",aside:"tuwa-scanlines novapay:hidden novapay:w-[286px] novapay:shrink-0 novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-5 novapay:sm:block",main:"novapay:flex novapay:min-h-0 novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:min-h-0 novapay:flex-1 novapay:flex-col novapay:overflow-y-auto"},page:{frame:"tuwa-scanlines novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-1 novapay:flex-col novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:min-h-[calc(var(--novapay-page-floor)_-_2px)] novapay:sm:flex-row",aside:"novapay-page-aside tuwa-scanlines novapay:hidden novapay:w-[clamp(260px,36.4%,320px)] novapay:shrink-0 novapay:flex-col novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-5 novapay:sm:flex",main:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:flex-1 novapay:flex-col"}};function tr(e){return e.length<=7?"novapay:text-[36px]":e.length<=10?"novapay:text-[30px]":e.length<=13?"novapay:text-[24px]":"novapay:text-[20px]"}function dt(){return useNovaIcons().outline}function an(e){return jsx(NovaSetIcon,{solid:"ChevronDownIcon",...e})}function nr(e){return jsx(NovaSetIcon,{solid:"GlobeAltIcon",...e})}function on(e){return jsx(NovaSetIcon,{outline:"ClockIcon",...e})}function ar(e){return jsx(NovaSetIcon,{outline:"DocumentTextIcon",...e})}function yt(e){return jsx(NovaSetIcon,{outline:"ExclamationTriangleIcon",...e})}function or(e){return jsx(NovaSetIcon,{outline:"InformationCircleIcon",...e})}function rr(e){return jsx(NovaSetIcon,{outline:"WalletIcon",...e})}function sr(e){let a=dt().ArrowDownTrayIcon??ArrowDownTrayIcon;return jsx(a,{...e})}function ir(e){let a=dt().ArrowPathRoundedSquareIcon??ArrowPathRoundedSquareIcon;return jsx(a,{...e})}function cr(e){let a=dt().ArrowUturnLeftIcon??ArrowUturnLeftIcon;return jsx(a,{...e})}function lr(e){let a=dt().DevicePhoneMobileIcon??DevicePhoneMobileIcon;return jsx(a,{...e})}function pr(e){let a=dt().FingerPrintIcon??FingerPrintIcon;return jsx(a,{...e})}function ur(e){let a=dt().LockClosedIcon??LockClosedIcon;return jsx(a,{...e})}function mr(e){let a=dt().MagnifyingGlassIcon??MagnifyingGlassIcon;return jsx(a,{...e})}function dr(e){let a=dt().NoSymbolIcon??NoSymbolIcon;return jsx(a,{...e})}function yr(e){let a=dt().QrCodeIcon??QrCodeIcon;return jsx(a,{...e})}var fr={metamask:"MetaMask",walletconnect:"WalletConnect",coinbase:"Coinbase Wallet",okx:"OKX Wallet",trust:"Trust Wallet",injected:"Browser wallet"};function nl(e,t){let a=e.slice(e.indexOf(":")+1).toLowerCase();return a==="injected"?fr.injected:t?.trim()||fr[a]||a.charAt(0).toUpperCase()+a.slice(1)}var Ja=e=>/^data:image\//i.test(e)||/^https:\/\//i.test(e),Za=e=>{let t=typeof e=="string"?e.trim():"";return t&&Ja(t)?t:void 0};function al(e,t,a){let n=getAdapterFromConnectorType(t),o=e[n];if(!Array.isArray(o))return;let r=o.filter(s=>typeof s=="object"&&s!==null&&typeof s.name=="string"&&getConnectorTypeFromName(n,formatConnectorName(s.name))===t);return a&&r.find(s=>Za(s.icon)===a)||r[0]}var Rt=e=>{let t=parseCaip2ChainId(e)?.namespace;return t==="eip155"||t==="solana"?t:null};function vr(e,t){if(!e?.address)return null;let a=toCaip2ChainId(e.chainId),n=a?Rt(a):null;if(!a||!n)return null;let o=Za(e.icon),r=t?al(t,e.connectorType,o):void 0;return {address:e.address,chainId:a,family:n,connectorType:e.connectorType,walletId:e.connectorType.slice(e.connectorType.indexOf(":")+1).toLowerCase(),name:nl(e.connectorType,typeof r?.name=="string"?r.name:void 0),icon:o??Za(r?.icon),connection:e}}function Ye(e){return Rt(e.chainId)}function Ue(e,t){return !e||e.family!==Ye(t)?null:formatCaip10AccountId(t.chainId,e.address)??null}function hr(e,t){let a=Ye(e);return a==="solana"||a==="eip155"&&!!t}function Xa(e){let t=a=>String(Number((a/100).toFixed(2)));return e.discountBps>0?{kind:"discount",percent:t(e.discountBps)}:e.markupBps>0?{kind:"markup",percent:t(e.markupBps)}:null}function ve(e){return getChainName(toEvmChainId(e)??e).name}function xr(e){let t=e.assetId?parseCaip19AssetId(e.assetId):void 0;return !t||t.assetNamespace==="slip44"?"native":t.assetReference}var ol=new Set(["awaitingPayment","selectMethod","underpaid"]),rl="too_many_payments";function eo(e,t={}){if(t.labelsReady===false&&e.phase!=="error")return "loading";if(e.phase==="unconfirmed")return It(e.error)==="retrying"?"confirm":"unconfirmed";if(t.afterFailure&&e.error?.code==="payment_failed"&&ol.has(e.phase))return "failed";let a=e.payerProof==="required"||e.payerProof==="confirming"||e.payerProof==="confirmed"&&!e.error,n=!!(t.confirmWallet&&a);switch(e.phase){case "selectMethod":return n&&!(t.handoff&&t.payWith==="qr")?"confirmWallet":t.handoff&&t.payWith==="qr"?"qr":"method";case "underpaid":return n?"confirmWallet":"underpaid";case "quoting":return e.quote?t.payWith==="qr"||e.quote.payer===null?"qr":"pay":t.confirmWallet?"confirmWallet":"method";case "awaitingPayment":case "submitting":return e.phase==="submitting"&&!e.quote?"confirm":t.payWith==="qr"||e.quote?.payer===null?"qr":"pay";case "confirming":return "confirm";case "cancelled":return e.checkout?.invoice.replacedBy?"replaced":"cancelled";default:return e.phase}}var sl={buyer:"details",method:"method",confirmWallet:"method",pay:"pay",qr:"pay",underpaid:"pay",confirm:"confirm",unconfirmed:"confirm",failed:"confirm"};function gr(e,t={}){let a=sl[e];if(!a)return null;let n=[...t.withDetails||a==="details"?["details"]:[],"method","pay","confirm"],o=n.indexOf(a);return n.map((r,s)=>({key:r,state:s<o?"done":s===o?"current":"upcoming"}))}function br(e={}){return [...e.withDetails?["details"]:[],"method","pay","confirm"].map(a=>({key:a,state:"done"}))}function wr(e,t){let a=s=>s.chainId===t?0:s.featured?1:2,n=new Map;for(let s of e)n.set(s.symbol,[...n.get(s.symbol)??[],s]);let o=[...n].map(([s,i])=>{let c=[...i].sort((l,p)=>a(l)-a(p));return {symbol:s,methods:c,featured:i.some(l=>l.featured),inWallet:!!t&&i.some(l=>l.chainId===t)}}),r=s=>s.inWallet?0:s.featured?1:2;return o.sort((s,i)=>r(s)-r(i))}var il=new Set(["open","processing","underpaid"]),cl=new Set(["loading","error","buyer","method","confirmWallet","pay","qr","failed","underpaid","blocked"]);function Ln(e,t,a){return il.has(e)?t==="confirm"||t==="unconfirmed"?"confirming":cl.has(t)?e==="underpaid"&&a===false?"closed":"paying":null:null}var ll=[10,5,1];function kr(e,t,a=ll){if(e===null||t<=0)return null;let n=a.filter(o=>e>o*6e4&&t<=o*6e4);return n.length?Math.min(...n):null}var to=6e4;function Cr(e){let{phase:t,quotePayer:a,payer:n}=e;return t!=="awaitingPayment"||!a||n===a?"keep":n?"lock":"release"}function Sr(e){let{open:t,storePayer:a,payer:n,paysRest:o}=e;return !t||n===a?"keep":n&&o?"follow":"leave"}function Pr(e){return e>0&&e<=to}function Nr(e){return e.amlScreening!==false}function ot(e){return e.paymentOnTheWay??!!(e.txKey||e.txHash)}function ft(e,t){let a=t?.invoice?.pendingPayments??0;return e.invoicePaymentOnTheWay??a>0}function Tr({state:e,checkout:t,handedOverAt:a,dueAt:n}){let o=e.paymentSentInTime,r=ot({paymentOnTheWay:e.paymentOnTheWay,txKey:e.txKey??null,txHash:e.txHash??null});if(typeof o=="boolean"&&r)return o;let s=t.invoice.paymentCountsUntil;return s===void 0?a!==null&&a<n:a!==null&&a>=n?false:(e.paymentCountsUntil===void 0?s:e.paymentCountsUntil)!==null}var no="settlement_failed",Rr="tx_already_used";function Ir(e){let t=e?.code,a=e?.reason;return (t==="payment_failed"||t==="payment_mismatch")&&!!a&&a!==no}var pl=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 vt(e){let t=e?.code,a=e?.reason;return a===no?false:t==="payment_mismatch"?true:t==="payment_failed"&&a!==void 0&&pl.has(a)}function Er(e){let t=e?.reason;return vt(e)&&t===Rr}function qt(e,t){let a=t?.invoice?.unresolvedPayments??0;return e.invoicePaymentUnresolved??a>0}function It(e){let t=e?.code,{reason:a,rechecked:n,stillRead:o}=e??{};return t==="payment_failed"&&a==="unresolved_after_24h"?"closed":a===no&&(t==="payment_unconfirmed"||t==="payment_mismatch")?n===true?"settlementRetrying":"settlementFailed":t!=="payment_unconfirmed"?null:a==="nonce_spent_unexplained"?"nonceSpent":a==="unmined_after_24h"||o===true?"unmined":a===Rr?"takenElsewhere":a==="submit_retrying"?"retrying":a==="submit_failed"?"notReceived":a===rl?"invoiceFull":n===true?"rechecked":"contact"}function Lr(e,t){let{txKey:a}=e.error??{};if(a)return a;let n=t?.invoice?.rejectedPayments;return e.txHash??e.txKey??n?.[0]?.txKey??null}function Ar({picked:e,page:t,invoice:a}){return e&&e.page===t?e.locale:t??a??"en"}function _r(e,t){return e.supportEmail?`mailto:${e.supportEmail}?subject=${encodeURIComponent(t)}`:e.website??null}var Fr={nonceSpent:"unconfirmedNonceSpent",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"};function An(e,t,a){let n=e.reason;return n==="expired"?t.pay.failedExpired:n==="cancelled"?t.pay.failedCancelled:n==="reverted"?a?c(t.pay.failed,{network:a}):t.method.paymentFailed:t.pay.didNotGoThrough}function la(e){if(e?.code!=="payment_failed"&&e?.code!=="payment_mismatch")return null;let{txKey:t}=e;return typeof t=="string"&&t?t:null}var ml=new Set(["payer_mismatch","payer_unconfirmed"]);function Ut(e,t,a=""){if(vt(e)){let r=e.reason??"",s=e.unmatched===true;if(r==="quote_changed")return c(t.pay.mismatchChargeUnmatched,{merchant:a});if(r==="too_many_parts")return c(t.pay.mismatchTooManyParts,{merchant:a});if(r==="reference_missing"&&s)return c(t.pay.mismatchNoReferenceUnmatched,{merchant:a});let i=ml.has(r)?s?t.pay.mismatchOtherWalletUnmatched:t.pay.mismatchOtherWallet:s?t.pay.mismatchUnmatchedElsewhere:Er(e)?t.pay.mismatchTakenElsewhere:t.pay.mismatch;return c(i,{merchant:a})}let n=It(e),o=n?Fr[n]:void 0;return o?c(t.outcome[o],{merchant:a}):null}var dl=["buyer","selectMethod","quoting","awaitingPayment"];function ao(e,t,a){if(a==="underpaid")return false;let n=It(t);return dl.includes(e)&&!vt(t)&&!(n&&Fr[n])}function pa(e,t,a=""){let n=Ut(e,t,a);if(n!==null)return n;switch(e.code){case "screening_unavailable":return t.pay.screeningUnavailable;case "request_failed":return t.pay.noAnswer;case "amount_out_of_range":case "method_not_found":case "testnet_required":return t.method.methodUnavailable;case "payer_not_expected":return t.method.payerNotExpected;case "payer_is_recipient":return t.method.payerIsRecipient;case "too_many_payments":return c(t.method.tooManyPayments,{merchant:a});case "too_many_payers":return c(t.method.tooManyPayers,{merchant:a});case "native_from_contract":return t.method.nativeFromSmartWallet;case "rate_limited":return t.method.rateLimited;case "price_unavailable":case "price_no_rpc":return t.method.priceUnavailable;case "consent_required":return t.method.consentRequired;case "payer_proof_required":case "payer_proof_declined":return t.payerProof.text;case "payer_proof_invalid":return t.payerProof.invalid;case "payer_proof_unavailable":return t.payerProof.unavailable;case "payment_failed":return An(e,t);case "rest_method_mismatch":return t.method.restSameMethod;default:return t.error.generic}}function Mr(e,t){if(!e||t===null)return null;let a=BigInt(e.cryptoAmountExpected)-BigInt(t);return a>0n?a.toString():null}function rn(e,t,a,n,o,r=a.pay.restRateEnded){let s=e?.rateHeldUntil?Date.parse(e.rateHeldUntil):null;if(s===null)return null;if(s<=t)return c(r,{merchant:n});let i=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(s);return c(a.pay.restRateUntil,{time:i,merchant:n})}function Et(e){return parseCaip10AccountId(e)?.address??e}function sn(e,t){let a=Et(e),n=Et(t);return a.startsWith("0x")?a.toLowerCase()===n.toLowerCase():a===n}function Br(e){return e&&/^\d+$/.test(e)&&BigInt(e)>0n?e:null}function Or(e){let t=BigInt(e.cryptoAmount),a=e.received?BigInt(e.received):null;if(a&&t>a&&(t-a)*200n>=a)return true;if(!e.atPaymentRate)return false;let n=BigInt(e.atPaymentRate);return n===0n?false:(t>n?t-n:n-t)*200n>=n}var yl=new Set(["needs_review","refunded","expired","cancelled","blocked","error"]);function Dr(e,t,a){return a?e==="paid"?t!==0:!yl.has(e):true}function qr(e,t){return t.withGas||!e.gasless?"transfer":e.gasless.paymaster&&t.canSponsorCalls?"paymaster":e.gasless.relay?"relay":"transfer"}function Ur(e){let t=BigInt(e.amountToSend),a=BigInt(e.amountDue);return !e.transferFee||t<=a?{send:e.amountToSend,receives:e.amountDue,fee:null}:{send:e.amountToSend,receives:e.amountDue,fee:{amount:String(t-a),percent:String(e.transferFee.bps/100)}}}var ua=10000n,Wr=8n;function Hr(e,t){let a=BigInt(e.cryptoAmountExpected);if(!t||a<=0n)return null;let o=BigInt(t)*(ua+BigInt(e.markupBps))*(ua-BigInt(e.discountBps))*10n**BigInt(e.decimals)*10n**Wr/(100n*ua*ua*a);return Number(o)/10**Number(Wr)}function $r(e,t,a=0n){let n=BigInt(t.amountToSend)+a;return e>=n?null:{have:String(e),need:String(n),short:String(n-e)}}function he(e){return e.family==="eip155"?`eip155:${e.chainId}`:e.chainId}var Vr="novapay:normal-case",gl=3,bl={};function wl(e){let[,t="",a="",n=""]=/^(\s*)([\s\S]*?)(\s*)$/.exec(e)??[];return [t,a,n]}function kl(e,t){let a=e.ownerDocument.createElement("span");a.style.cssText="position:absolute;visibility:hidden;white-space:nowrap;pointer-events:none";for(let[o,r]of t){let s=e.ownerDocument.createElement("span");r&&(s.style.textTransform="none"),s.textContent=o,a.append(s);}e.append(a);let{width:n}=a.getBoundingClientRect();return a.remove(),n}function Cl(e,t){let a=getComputedStyle(t),n=[...t.children].filter(s=>s!==e),o=n.reduce((s,i)=>s+i.getBoundingClientRect().width,0),r=(Number.parseFloat(a.columnGap)||0)*n.length;return t.clientWidth-Number.parseFloat(a.paddingLeft)-Number.parseFloat(a.paddingRight)-o-r}function ge({label:e,values:t=bl}){let a=useRef(null),[n,o]=useState(false),[r,s]=useState(gl),i=Object.fromEntries(Object.entries(t).map(([p,m])=>[p,{own:String(m)}])),c=d(e,i).map(p=>typeof p=="string"?[p,false]:[p.own,true]),l=JSON.stringify(c);return useLayoutEffect(()=>{let p=a.current,m=p?.parentElement;if(!p||!m)return;let y=JSON.parse(l),f=()=>{o(kl(p,y)>Cl(p,m)+.5),s(d=>Math.max(d,y.length));};if(f(),typeof ResizeObserver>"u")return;let v=new ResizeObserver(f);return v.observe(m),()=>v.disconnect()},[l]),n?jsx("span",{ref:a,className:"novapay:min-w-0",children:jsx("span",{className:"novapay-label-fade",children:c.map(([p,m],y)=>m?jsx("span",{className:Vr,children:p},y):p)},l)}):jsx("span",{ref:a,className:"novapay:min-w-0 novapay:whitespace-nowrap",children:Array.from({length:Math.max(r,c.length)},(p,m)=>{let[y,f]=c[m]??["",false],[v,d,R]=wl(y);return jsxs(Fragment,{children:[v,jsx(MorphText,{className:f?Vr:void 0,children:d}),R]},m)})})}function Y(e,t,a){let n=e.customization.classNames?.[t];return n?.({screen:e.screen,checkoutState:e.state,checkout:e.checkout,...a})}function Ze({children:e,labels:t}){let a=qe(),n=t??a?.labels,o=useLabels(),r=useMemo(()=>({...o,trackingModal:{...o.trackingModal,progressIndicator:{created:n.confirm.sent,processing:n.confirm.confirming,succeed:n.confirm.paid}},statuses:{...o.statuses,confirmed:n.confirm.confirmed,failed:n.confirm.failed},actions:{...o.actions,viewOnExplorer:n.confirm.viewOnExplorer,copy:n.confirm.copyHash},txError:{...o.txError,copied:n.pay.copied}}),[o,n]);return jsx(NovaTransactionsLabelsProvider,{labels:r,children:e})}var $t=(e,t)=>e?Y(e,t):void 0;function Fn({walletId:e,icon:t}){let[a,n]=useState(null);return t&&t!==a&&Ja(t)?jsx("img",{src:t,alt:"",onError:()=>n(t),className:"novapay:block novapay:h-full novapay:w-full novapay:object-contain"}):jsx(WalletIcon,{walletName:e})}function He({hash:e,chainId:t,explorerUrl:a,labels:n}){let o=qe(),r=a??(t?o?.adapterFor(t.startsWith("solana:")?"solana":"eip155")?.explorerAddressUrl?.({chainId:t,address:e}):void 0);return jsx(Ze,{labels:n,children:jsx(HashLink,{hash:e,explorerUrl:r,variant:"compact",...o?.customization.childCustomizations?.hashLink})})}function ma({walletId:e,walletIcon:t}){return !e&&!t?jsx(QuasarLoader,{size:48,accent:"var(--tuwa-pending-icon)"}):jsx("span",{className:"novapay-chase novapay:relative novapay:flex novapay:h-20 novapay:w-20 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border-2 novapay:border-[color-mix(in_srgb,var(--tuwa-pending-text)_25%,transparent)]",children:jsx("span",{className:"novapay:block novapay:h-11 novapay:w-11",children:jsx(Fn,{walletId:e??"",icon:t})})})}function de({title:e,subtitle:t,children:a}){let n=qe(),o=n?.display==="page";return jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-2.5 novapay:px-5 novapay:py-4",o&&"novapay-page-screen",$t(n,"screen")),children:[jsxs("div",{children:[jsx("h2",{...Nt,className:at,children:typeof e=="string"?jsx(MorphText,{wrap:true,children:e}):e}),t&&jsx("p",{className:cn$1("novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",o&&"novapay-page-subtitle"),children:t})]}),a]})}function Z({children:e}){let t=qe(),a=useRef(null),n=t?.display==="page";return useEffect(()=>{let o=a.current,r=n?o?.ownerDocument.documentElement:o?.closest("[data-novapay-scroll]");if(!o||!r||typeof ResizeObserver>"u")return;let s=()=>r.style.scrollPaddingBottom=!n||getComputedStyle(o).position==="sticky"?`${o.offsetHeight+8}px`:"";s();let i=new ResizeObserver(s);return i.observe(o),()=>{i.disconnect(),r.style.scrollPaddingBottom="";}},[n]),jsx("footer",{ref:a,className:cn$1("tuwa-scanlines novapay:empty:hidden novapay:sticky novapay:bottom-0 novapay:z-10 novapay:flex novapay:flex-col novapay:gap-2 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-5 novapay:pb-3.5 novapay:pt-3 novapay:text-center",n&&"novapay-page-footer",$t(t,"footer")),children:e})}function cn({children:e,id:t}){let a=qe()?.display==="page";return jsx("span",{id:t,className:cn$1(Oe,a&&"novapay-page-group"),children:e})}function X({busy:e,children:t,className:a,...n}){let o=qe(),r=$t(o,"primaryButton"),s=o?.customization.components?.PrimaryButton;return s?jsx(s,{busy:e,className:cn$1(a,r),...n,children:t}):jsxs("button",{type:"button","aria-busy":e||void 0,...n,disabled:n.disabled||e,className:cn$1(Tt,a,r),children:[e&&jsx(QuasarLoader,{size:16,accent:"currentColor"}),typeof t=="string"?jsx(ge,{label:t}):t]})}function ae({children:e,className:t,...a}){let n=qe();return jsx("button",{type:"button",...a,className:cn$1(sa,t,$t(n,"secondaryButton")),children:e})}function da({className:e,...t}){return jsxs("span",{className:cn$1("novapay:relative novapay:inline-flex novapay:h-4 novapay:w-4 novapay:shrink-0",e),children:[jsx("input",{type:"checkbox",...t,className:cn$1("novapay:peer novapay:m-0 novapay:box-border novapay:h-4 novapay:w-4 novapay:cursor-pointer novapay:appearance-none novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:border-[var(--tuwa-text-secondary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:transition-colors novapay:checked:border-[var(--tuwa-text-accent)] novapay:checked:bg-[var(--tuwa-text-accent)]",ce)}),jsx(DrawnCheck,{className:"novapay:pointer-events-none novapay:absolute novapay:inset-0 novapay:m-auto novapay:h-3 novapay:w-3 novapay:text-[var(--tuwa-bg-primary)] novapay:opacity-0 novapay:peer-checked:opacity-100"})]})}function $e({children:e}){return jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:e})}function xe({children:e,className:t}){let a=qe();return jsx("dl",{className:cn$1("tuwa-scanlines novapay:m-0 novapay:flex novapay:w-full novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-left",t,$t(a,"detailsCard")),children:e})}function Q({children:e}){let t=qe();return jsx("p",{role:"alert",className:cn$1("novapay:m-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-error-text)]",$t(t,"error")),children:e})}function ya({error:e}){let t=qe(),a=la(e);if(!t||!a)return null;let n=t.state.quote??t.checkout?.quote,o=n?he(n.instructions):null,r=n&&o?t.adapterFor(n.instructions.family)?.explorerUrl?.({chainId:o,txKey:a}):void 0;return jsx(Ze,{children:jsx(xe,{children:jsx(H,{name:t.labels.confirm.transaction,children:jsx(HashLink,{hash:a,explorerUrl:r,variant:"compact",...t.customization.childCustomizations?.hashLink})})})})}function Mn({text:e,label:t,copiedLabel:a,children:n}){let[o,r]=useState(false);return useEffect(()=>{if(!o)return;let s=setTimeout(()=>r(false),2e3);return ()=>clearTimeout(s)},[o]),jsxs(Fragment$1,{children:[jsxs("button",{type:"button","aria-label":n?void 0:t,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>r(true),()=>{});},className:cn$1(Pt,"novapay:min-h-6 novapay:min-w-6 novapay:text-xs"),children:[jsx(CopyIcon,{copied:o,className:"novapay:h-3.5 novapay:w-3.5"}),n]}),jsx("span",{role:"status",className:"novapay:sr-only",children:o?a:""})]})}function H({name:e,children:t}){let a=qe();return jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3 novapay:py-2 novapay:text-xs",a?.display==="page"&&"novapay-page-row",$t(a,"detailRow")),children:[jsx("dt",{className:"novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]",children:e}),jsx("dd",{className:cn$1($,"novapay:m-0 novapay:min-w-0 novapay:text-right novapay:break-words"),children:t})]})}function ht({children:e,onClick:t,disabled:a}){return jsx("button",{type:"button",onClick:t,disabled:a,className:cn$1("novapay:disabled:cursor-default novapay:disabled:opacity-50 novapay:min-h-6 novapay:cursor-pointer novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-xs novapay:text-[var(--tuwa-text-accent)] novapay:underline novapay:hover:no-underline",ce),children:e})}var Dl=(e,t,a)=>t==="name"&&a?e.buyer.companyName:e.buyer[t]??t,Wl=(e,t)=>t==="email"?e.buyer.invalidEmail:t==="country"?e.buyer.invalidCountry:e.buyer.required,ql=new Set(["postalCode","city","taxId","registrationNumber"]),Ul=new Set(["name","country","addressLine1","addressLine2"]),Yr=e=>cn$1("novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-[13px] novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:focus:border-[var(--tuwa-text-accent)]",e?"novapay:border-[var(--tuwa-error-icon)]":"novapay:border-[var(--tuwa-text-secondary)] novapay:hover:border-[var(--tuwa-text-primary)]",ce);function Zr(){let{checkout:e,state:t,store:a,labels:n,locale:o,display:r}=I(),[s,i]=useState({}),[c,l]=useState(false),[p,m]=useState(false),[y,f]=useState(false),v=useId(),d=useMemo(()=>Zo(o),[o]);if(!e||e.buyer.collect==="off")return null;let R=e.buyer.collect,h=Ya(R,c),x=jo(s,R,c),g=(N,b)=>i(L=>({...L,[N]:b})),k=async N=>{if(N.preventDefault(),m(true),Object.keys(x).length>0){document.getElementById(`${v}-${Object.keys(x)[0]}`)?.focus();return}f(true),await a.getState().setBuyer(Yo(s),{company:c}),f(false);};return jsxs("form",{noValidate:true,onSubmit:N=>{k(N);},className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(de,{title:n.buyer.title,subtitle:n.buyer.subtitle,children:[jsx("div",{className:"novapay:grid novapay:grid-cols-1 novapay:gap-x-3 novapay:gap-y-3.5 novapay:pt-1 novapay:sm:grid-cols-2",children:h.map((N,b)=>{let L=`${v}-${N.name}`,B=p?x[N.name]:void 0,_=N.type==="country"?jsxs("div",{className:"novapay:relative",children:[jsxs("select",{id:L,autoComplete:N.autoComplete,required:N.required,"aria-invalid":!!B,"aria-describedby":B?`${L}-error`:void 0,value:s.country??"",onChange:w=>g("country",w.target.value),className:cn$1(Yr(!!B),"novapay:cursor-pointer novapay:appearance-none novapay:pr-9",!s.country&&"novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("option",{value:"",children:n.buyer.chooseCountry}),d.map(w=>jsx("option",{value:w.code,children:w.name},w.code))]}),jsx(an,{"aria-hidden":true,className:"novapay:pointer-events-none novapay:absolute novapay:top-1/2 novapay:right-3 novapay:h-4 novapay:w-4 novapay:-translate-y-1/2 novapay:text-[var(--tuwa-text-secondary)]"})]}):jsx("input",{id:L,type:N.type,autoComplete:N.autoComplete,required:N.required,"aria-invalid":!!B,"aria-describedby":B?`${L}-error`:void 0,value:s[N.name]??"",onChange:w=>g(N.name,w.target.value),className:Yr(!!B)});return jsxs(Fragment,{children:[jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",!ql.has(N.name)&&(r==="page"&&Ul.has(N.name)?"novapay:sm:@max-[519px]:col-span-2":"novapay:sm:col-span-2")),children:[jsxs("label",{htmlFor:L,className:"novapay:text-xs novapay:font-medium novapay:text-[var(--tuwa-text-primary)]",children:[Dl(n,N.name,c),N.required&&jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]}),!N.required&&jsxs("span",{className:"novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:[" ","(",n.buyer.optional,")"]})]}),_,B&&jsx("span",{id:`${L}-error`,className:"novapay:text-[11px] novapay:text-[var(--tuwa-error-text)]",children:Wl(n,B)})]}),b===0&&e.buyer.companyInvoice&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:text-[13px] novapay:transition-colors novapay:sm:col-span-2",c?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]"),children:[jsx(da,{checked:c,onChange:w=>l(w.target.checked)}),jsx("span",{className:"novapay:font-semibold",children:n.buyer.companyInvoice})]})]},N.name)})}),t.error&&t.phase==="buyer"&&jsx(Q,{children:n.buyer.refused})]}),jsx(Z,{children:jsx(X,{type:"submit",busy:y,children:n.buyer.continue})})]})}function Xr({steps:e,labels:t,className:a,stepClassName:n}){let o=e.findIndex(p=>p.state==="current"),r=e.map(p=>t.steps[p.key]).join(""),s=useRef(null),i=useRef(null),[c$1,l]=useState(false);return useEffect(()=>{let p=s.current,m=i.current;if(!p||!m||typeof ResizeObserver>"u")return;let y=()=>l(m.offsetWidth+e.length*32+(e.length-1)*24>p.clientWidth);y();let f=new ResizeObserver(y);return f.observe(p),()=>f.disconnect()},[r,e.length]),jsxs("nav",{ref:s,"aria-label":t.steps.label,className:cn$1("novapay:relative novapay:min-w-0 novapay:flex-1",a),children:[jsx("span",{"aria-hidden":true,className:"novapay:invisible novapay:absolute novapay:h-0 novapay:w-0 novapay:overflow-hidden",children:jsx("span",{ref:i,className:cn$1(nt,"novapay:whitespace-nowrap novapay:text-[11px]"),children:r})}),jsx("ol",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:items-center novapay:gap-1.5 novapay:p-0",children:e.map((p,m)=>{let y=t.steps[p.key];return jsxs("li",{"aria-current":p.state==="current"?"step":void 0,className:cn$1("novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-1.5",m>0&&"novapay:flex-auto",n?.(p,m)),children:[m>0&&jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-px novapay:min-w-2 novapay:flex-1 novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",p.state==="upcoming"?"novapay:bg-[var(--tuwa-border-primary)]":"novapay:bg-[var(--tuwa-success-icon)]")}),jsx("span",{"aria-hidden":true,className:cn$1($,"novapay:box-border novapay:flex novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:text-[10px] novapay:font-bold",p.state==="done"&&"novapay:border-[var(--tuwa-success-icon)] novapay:bg-[var(--tuwa-success-icon)] novapay:text-white",p.state==="current"&&"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",p.state==="upcoming"&&"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-secondary)]"),children:p.state==="done"?jsx(DrawnCheck,{className:"novapay:h-3 novapay:w-3"}):m+1}),jsx("span",{className:cn$1(nt,"novapay:truncate novapay:text-[11px] novapay:leading-4",p.state==="current"?"novapay:text-[var(--tuwa-text-primary)]":"novapay:text-[var(--tuwa-text-secondary)]",c$1&&p.state!=="current"&&"novapay:sr-only"),children:p.state==="current"?jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:sr-only",children:c(t.steps.progress,{current:o+1,total:e.length,name:y})}),jsx("span",{"aria-hidden":true,children:y})]}):y})]},p.key)})})]})}function Re(e,t=2){let a=e.startsWith("-"),n=(a?e.slice(1):e).padStart(t+1,"0");return `${a?"-":""}${n.slice(0,-t)}.${n.slice(-t)}`}var es=e=>new Intl.NumberFormat(e).formatToParts(1.1).find(t=>t.type==="decimal")?.value??".";function ye(e,t){let[a="0",n=""]=(typeof e=="number"?e.toFixed(2):e.trim()).split("."),o=a.startsWith("-"),r=new Intl.NumberFormat(t).format(BigInt(o?a.slice(1):a));return `${o?"-":""}${r}${es(t)}${n.padEnd(2,"0").slice(0,2)}`}function pe(e,t,a){let n=BigInt(e),o=n<0n,r=o?-n:n,s=10n**BigInt(t),i=new Intl.NumberFormat(a).format(r/s),c=(r%s).toString().padStart(t,"0").replace(/0+$/,"").padEnd(2,"0");return `${o?"-":""}${i}${es(a)}${c}`}function ha(e,t,a){let n=10n**BigInt(Math.max(t-6,0)),o=(BigInt(e)+n/2n)/n*n;return o===0n?null:pe(o.toString(),t,a)}function xa(e,t){return formatBaseUnits(e,t)??"0"}var Kt=e=>String(e).padStart(2,"0");function st(e){let t=Math.max(0,Math.floor(e/1e3)),a=Math.floor(t/86400),n=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),r=t%60;return a>0?`${a}d ${Kt(n)}:${Kt(o)}`:n>0?`${Kt(n)}:${Kt(o)}:${Kt(r)}`:`${Kt(o)}:${Kt(r)}`}function pn(e){let t=e.lineItems.reduce((r,s)=>r+BigInt(s.netMinor),0n),a=BigInt(e.totalMinor??t.toString()),n=a-t,o=[...new Set(e.lineItems.filter(r=>Number(r.taxRate)>0).map(r=>r.taxRate))];return {subtotal:Re(t.toString()),tax:n>0n?Re(n.toString()):null,rate:o.length===1?String(Number(o[0])):null,total:Re(a.toString())}}var Ql=e=>{try{return new URL(e).host}catch{return e}};function ga({compact:e=false}){let{checkout:t,state:a,labels:n,display:o}=I(),[r,s]=useState(false);if(!t)return null;let{merchant:i,invoice:c}=t,l=e?"novapay:h-8 novapay:w-8":"novapay:h-9 novapay:w-9";return jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-2.5",children:[a.logoUrl&&!r?jsx("img",{src:a.logoUrl,alt:"",onError:()=>s(true),className:cn$1(l,"novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:object-contain")}):jsx("span",{"aria-hidden":true,className:cn$1(l,$,"novapay:flex novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-text-primary)] novapay:text-[15px] novapay:font-bold novapay:text-[var(--tuwa-bg-primary)]"),children:i.name.trim().charAt(0).toUpperCase()}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:cn$1("novapay:text-sm novapay:font-semibold",o==="page"&&!e?"novapay:line-clamp-2 novapay:break-words":"novapay:truncate"),children:i.name}),e?c.number&&jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c.number}):i.website&&jsx("a",{href:i.website,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:truncate novapay:text-xs novapay:text-[var(--tuwa-text-secondary)] novapay:hover:underline",ce),children:Ql(i.website)})]}),c.environment==="test"&&jsxs("span",{title:n.summary.testHint,className:cn$1(en,tn.pending,"novapay:ml-auto"),children:[n.summary.test,jsxs("span",{className:"novapay:sr-only",children:[": ",n.summary.testHint]})]})]})}function ro({checkout:e,labels:t}){let{merchant:a}=e,n=a.seller,o=[[t.summary.terms,a.links.terms],[t.summary.refundPolicy,a.links.refundPolicy],[t.summary.privacy,a.links.privacy]].filter(r=>!!r[1]);return jsxs("div",{className:"tuwa-scanlines novapay:flex novapay:flex-col novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:[n?.legalName&&jsx("span",{className:"novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)]",children:n.legalName}),(n?.address||n?.country)&&jsx("span",{children:[n.address,n.country].filter(Boolean).join(", ")}),n?.registrationNumber&&jsxs("span",{children:[t.summary.registration," ",n.registrationNumber]}),n?.taxId&&jsxs("span",{children:[t.summary.taxId," ",n.taxId]}),a.supportEmail&&jsx("a",{href:`mailto:${a.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:a.supportEmail}),o.length>0&&jsx("span",{className:"novapay:flex novapay:flex-wrap novapay:gap-x-3",children:o.map(([r,s])=>jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:r},r))}),jsx("span",{children:c(t.summary.sellerRole,{seller:n?.legalName||a.name})})]})}function os(){let{checkout:e,labels:t,locale:a,now:n,screen:o,display:r}=I(),s=e?.invoice.dueAt,i=e&&Ln(e.invoice.status,o,e.invoice.restPayable);if(!e||!s||!i)return null;let c$1=new Intl.DateTimeFormat(a,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(s));return jsxs("div",{className:cn$1("tuwa-scanlines novapay:flex novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5",r==="page"&&"novapay-page-deadline"),children:[jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-0.5",children:[jsx("span",{className:Oe,children:i==="closed"?t.summary.refundAfter:t.summary.payWithin}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:i==="closed"?c$1:c(t.summary.until,{date:c$1})})]}),jsx("span",{role:"timer",className:cn$1($,"novapay:shrink-0 novapay:whitespace-nowrap novapay:text-lg novapay:font-bold"),children:st(Date.parse(s)-n)})]})}function rs(){let{checkout:e,labels:t,locale:a}=I();if(!e)return null;let{invoice:n}=e,o=pn(n);return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3.5",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2.5",children:[n.number&&jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3",children:[jsx("span",{className:Oe,children:t.summary.invoice}),jsx("span",{className:cn$1($,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-2.5 novapay:p-0",children:n.lineItems.map((r,s)=>jsxs("li",{className:"novapay:flex novapay:justify-between novapay:gap-2 novapay:text-[13px]",children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:r.name}),r.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:r.description}),jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:r.quantity,price:ye(r.unitPrice,a)})})]}),jsx("span",{className:$,children:ye(Re(r.netMinor),a)})]},s))})]}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:border-t novapay:border-dashed novapay:border-[var(--tuwa-border-primary)] novapay:pt-2.5 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.tax,a)})]})]})]})}function jl(){let e=I(),{checkout:t,labels:a,locale:n}=e;return t?jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between",Y(e,"total")),children:[jsx("span",{className:cn$1(Oe,"novapay:text-[var(--tuwa-text-primary)]"),children:a.summary.total}),jsxs("span",{className:cn$1($,"novapay:text-[22px] novapay:font-bold"),children:[ye(pn(t.invoice).total,n)," ",jsx("span",{className:"novapay:text-[13px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]}):null}function ss(){let{checkout:e,labels:t}=I();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(ur,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:shrink-0"}),t.summary.secured]}),e?.merchant.supportEmail&&jsxs("span",{children:[t.summary.help,":"," ",jsx("a",{href:`mailto:${e.merchant.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:e.merchant.supportEmail})]})]})}function ba({label:e,children:t,className:a,buttonClassName:n,growsUp:o=false}){let[r,s]=useState(false),i=useId();return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-2",a),children:[jsxs("button",{type:"button","aria-expanded":r,"aria-controls":i,onClick:()=>s(c=>!c),className:cn$1("novapay:inline-flex novapay:cursor-pointer novapay:items-center novapay:gap-1 novapay:self-start novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)] novapay:hover:text-[var(--tuwa-text-primary)]",ce,n),children:[e,jsx(an,{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:transition-transform novapay:motion-reduce:transition-none",r!==o&&"novapay:rotate-180")})]}),jsx("div",{id:i,hidden:!r,children:t})]})}var ts=5;function Yl(){let e=I(),{checkout:t,labels:a,locale:n}=e;if(!t)return null;let o=ye(pn(t.invoice).total,n);return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",Y(e,"total")),children:[jsx("span",{className:Oe,children:a.summary.total}),jsxs("span",{className:cn$1($,"novapay:flex novapay:flex-wrap novapay:items-baseline novapay:gap-x-2 novapay:gap-y-1 novapay:font-bold",tr(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 is="novapay:flex novapay:justify-between novapay:gap-3 novapay:px-3 novapay:py-2";function ns({line:e}){let{labels:t,locale:a}=I(),n=ye(Re(e.netMinor),a),o=ye(e.unitPrice,a);return jsxs("li",{className:cn$1(is,"novapay:text-[13px]"),children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:e.name}),e.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:e.description}),(Number(e.quantity)!==1||o!==n)&&jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:e.quantity,price:o})})]}),jsx("span",{className:cn$1($,"novapay:shrink-0"),children:n})]})}function Zl(){let{checkout:e,labels:t,locale:a}=I();if(!e)return null;let{invoice:n}=e,o=pn(n),r=o.tax?ts-1:ts,s=n.lineItems,i=s.length>r?s.slice(0,r-1):s,c$1=s.slice(i.length);return !n.number&&s.length===0?null:jsxs("div",{className:"tuwa-scanlines novapay:flex novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)]",children:[n.number&&jsxs("div",{className:cn$1(is,"novapay:items-baseline"),children:[jsx("span",{className:Oe,children:t.summary.invoice}),jsx("span",{className:cn$1($,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),i.length>0&&jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:i.map((l,p)=>jsx(ns,{line:l},p))}),c$1.length>0&&jsx(ba,{label:`+${c$1.length} \xB7 ${t.summary.showOrder}`,className:"novapay:px-3 novapay:py-2",buttonClassName:"novapay:min-h-6",children:jsx("ul",{className:"novapay:-mx-3 novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:c$1.map((l,p)=>jsx(ns,{line:l},p))})}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.tax,a)})]})]})]})}function Jl(){let{checkout:e,labels:t}=I();return e?jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx(ga,{}),jsx("div",{className:"novapay:mt-6",children:jsx(Yl,{})}),jsx("div",{className:"novapay:mt-5",children:jsx(Zl,{})}),jsxs("div",{className:"novapay:mt-auto novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-5",children:[jsx(os,{}),jsx(ba,{label:t.summary.sellerDetails,buttonClassName:"novapay:min-h-6",growsUp:true,children:jsx(ro,{checkout:e,labels:t})}),jsx(ss,{})]})]}):null}function cs(){let{checkout:e,labels:t,display:a}=I();return e?a==="page"?jsx(Jl,{}):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(ga,{}),jsx(ba,{label:t.summary.sellerDetails,children:jsx(ro,{checkout:e,labels:t})})]}),jsx(os,{}),jsx("div",{className:"novapay:-mr-2.5 novapay:min-h-0 novapay:flex-1 novapay:overflow-y-auto novapay:pr-2.5",children:jsx(rs,{})}),jsx(jl,{}),jsx(ss,{})]}):null}function ls({className:e}={}){let{checkout:t,labels:a,locale:n,now:o,screen:r}=I();if(!t)return null;let{invoice:s}=t,i=pn(s),c=s.dueAt&&Ln(s.status,r)?Date.parse(s.dueAt):null;return jsxs("div",{className:cn$1("tuwa-scanlines novapay:mx-4 novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-3",e),children:[jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsxs("span",{className:cn$1($,"novapay:text-[22px] novapay:font-bold"),children:[ye(i.total,n)," ",jsx("span",{className:"novapay:text-xs novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:s.currency})]}),c&&jsxs("span",{role:"timer",className:cn$1($,"novapay:flex novapay:items-center novapay:gap-1 novapay:whitespace-nowrap novapay:text-xs novapay:font-bold"),children:[jsx(on,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-secondary)]"}),st(c-o)]})]}),jsx(ba,{label:`${b(i.tax?{one:a.summary.compactOne,other:a.summary.compact}:{one:a.summary.compactNoTaxOne,other:a.summary.compactNoTax},s.lineItems.length,n,i.tax?{tax:ye(i.tax,n)}:{})} \xB7 ${a.summary.showOrder}`,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-1",children:[jsx(rs,{}),jsx(ro,{checkout:t,labels:a})]})})]})}function us({locale:e$1,labels:t,receiptIssued:a,onSelect:n,className:o}){let[r,s]=useState(false),i=e.find(x=>x.code===e$1)??e[0],[c$1,l]=useState(0),p=useId(),m=useRef(null),y=useRef(null),f=useRef(null);useEffect(()=>{if(!r)return;f.current?.focus();let x=g=>{m.current?.contains(g.target)||s(false);};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[r]);let v=()=>{l(Math.max(0,e.indexOf(i))),s(true);},d=()=>{s(false),y.current?.focus();},R=x=>{d(),x!==i.code&&n(x);},h=x=>{let g=e.length-1,k={ArrowDown:()=>Math.min(g,c$1+1),ArrowUp:()=>Math.max(0,c$1-1),Home:()=>0,End:()=>g};k[x.key]?(x.preventDefault(),l(k[x.key]())):x.key==="Enter"||x.key===" "?(x.preventDefault(),R(e[c$1].code)):(x.key==="Escape"||x.key==="Tab")&&(x.preventDefault(),x.stopPropagation(),d());};return jsxs("div",{ref:m,className:cn$1("novapay:relative",o),children:[jsxs("button",{ref:y,type:"button","aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?`${p}-list`:void 0,className:cn$1(Pt,nt,"novapay:text-[11px]"),onClick:()=>r?d():v(),onKeyDown:x=>{x.key==="ArrowDown"&&!r&&(x.preventDefault(),v());},children:[jsx(nr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),jsx("span",{children:i.short}),jsxs("span",{className:"novapay:sr-only",children:[", ",c(t.language.button,{language:i.name})]}),jsx(an,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"})]}),r&&jsxs("div",{className:"tuwa-scanlines novapay:absolute novapay:right-0 novapay:top-full novapay:z-20 novapay:mt-1.5 novapay:w-60 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-1.5",children:[jsx("span",{id:`${p}-title`,className:cn$1(Oe,"novapay:block novapay:px-2.5 novapay:py-1"),children:t.language.title}),jsx("ul",{ref:f,id:`${p}-list`,role:"listbox",tabIndex:-1,"aria-labelledby":`${p}-title`,"aria-activedescendant":`${p}-${e[c$1].code}`,onKeyDown:h,className:cn$1("novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-0.5 novapay:p-0",ce),children:e.map((x,g)=>{let k=x.code===i.code;return jsxs("li",{id:`${p}-${x.code}`,role:"option","aria-selected":k,lang:x.code,onClick:()=>R(x.code),onPointerMove:()=>l(g),className:cn$1("novapay:flex novapay:h-8 novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:px-2.5 novapay:text-[13px]",g===c$1&&"novapay:bg-[var(--tuwa-bg-muted)]","novapay:text-[var(--tuwa-text-primary)]",k&&"novapay:font-semibold"),children:[jsx("span",{"aria-hidden":true,className:cn$1($,"novapay:w-5 novapay:text-[11px]"),children:x.short}),jsx("span",{children:x.name}),k&&jsx(DrawnCheck,{className:"novapay:ml-auto novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-accent)]"})]},x.code)})}),jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:px-2.5 novapay:pb-1 novapay:pt-2 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:a?t.language.noteAfterPaid:t.language.note})]})]})}var ms=(e,t)=>gr(e.screen,{withDetails:t})??(e.screen==="paid"?br({withDetails:t}):null);function ds(e,t,a){let n=e.customization.components?.Stepper??Xr;return jsx(n,{steps:t,labels:e.labels,className:cn$1(a,Y(e,"stepper")),stepClassName:(o,r)=>Y(e,"step",{step:o,index:r})})}function ys({title:e,withDetails:t}){let a=I(),{labels:n,locale:o,setLocale:r,close:s,state:i}=a,c=a.display==="page",l=a.customization.config?.showSteps===false?null:ms(a,t),p=Y(a,"header"),m=a.customization.handlers?.onLocaleChange,y=jsxs("div",{className:"novapay:ml-auto novapay:flex novapay:shrink-0 novapay:items-center novapay:gap-2",children:[jsx(us,{locale:o,labels:n,receiptIssued:!!i.receiptUrl,onSelect:f=>{m?m({locale:f,proceed:()=>r(f)}):r(f);}}),s&&jsx("button",{type:"button","aria-label":n.common.close,onClick:s,className:Pt,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]});return jsxs(Fragment$1,{children:[jsxs("header",{className:cn$1("novapay:hidden novapay:items-center novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:py-3.5 novapay:pl-5 novapay:pr-4 novapay:sm:flex",c&&"novapay-page-header",p),children:[l?ds(a,l):e&&jsx("h2",{className:cn$1($,"novapay:m-0 novapay:flex-1 novapay:text-[15px] novapay:font-bold"),children:e}),y]}),jsxs("header",{className:cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-4 novapay:pb-3 novapay:pt-1.5 novapay:sm:hidden",c&&"novapay-page-header-phone",p),children:[jsx(ga,{compact:true}),y]})]})}function fs({withDetails:e}){let t=I();if(t.customization.config?.showSteps===false)return null;let a=ms(t,e);return a?ds(t,a,"novapay:px-4 novapay:pt-3.5"):null}var rp=new Set(["paid","needs_review","refunded","partially_refunded"]);function dn(){let{state:e,locale:t,adapterFor:a}=I(),o=(e.invoiceStatus&&rp.has(e.invoiceStatus)?e.checkout?.quote:null)??e.quote,r=o?he(o.instructions):null,s=e.txHash??e.txKey,i=o?.payer?parseCaip10AccountId(o.payer)?.address:void 0,c=(e.checkout?.invoice.payments??[]).map(l=>{let p=l.chainId?Rt(l.chainId):null;return {txKey:l.txKey,amount:l.symbol&&l.decimals!==null?`${pe(l.amount,l.decimals,t)} ${l.symbol}`:null,at:Date.parse(l.at),explorerUrl:p&&l.chainId?a(p)?.explorerUrl?.({chainId:l.chainId,txKey:l.txKey}):void 0}});return {network:r?ve(r):null,amount:o?`${pe(o.amountToSend,o.decimals,t)} ${o.instructions.symbol}`:null,paidAmount:o?`${pe(o.amountDue===o.cryptoAmountExpected?o.amountToSend:o.cryptoAmountExpected,o.decimals,t)} ${o.instructions.symbol}`:null,txKey:s,lastOfParts:o?o.amountDue!==o.cryptoAmountExpected:false,transfers:c,explorerUrl:o&&r&&s?a(o.instructions.family)?.explorerUrl?.({chainId:r,txKey:s}):void 0,from:i?shortAddress(i):null,fromAddress:i??null,fromUrl:o&&r&&i?a(o.instructions.family)?.explorerAddressUrl?.({chainId:r,address:i}):void 0}}var io=new WeakMap,cp=500;function bt(e,t){let a=io.get(e)?.get(t);if(a)return a.leftAt===null||Date.now()-a.leftAt<cp?a.value:void 0}function On(e,t,a,n=true){let o=io.get(e)??new Map;o.set(t,{value:a,leftAt:n?Date.now():null}),io.set(e,o);}function Ke(e,t){let{store:a}=I(),[n,o]=useState(()=>bt(a,e)??t);return useEffect(()=>(o(t),On(a,e,t,false),()=>On(a,e,t)),[a,e,t]),n}var vs="actionKind",pp="actionLabel",Ca="novapay-action-arrives";function yn(e,t){let{store:a,customization:n}=I(),[o]=useState(()=>e==="primary"&&bt(a,vs)==="secondary"&&!n.config?.animation?.disabled);return Ke(vs,e??"none"),{label:Ke(pp,e?t:"")||t,arrives:o}}function xs({tone:e,children:t}){let a=I(),n=Ke("chipTone",e),o=Ke("chipLabel",t);return jsx("span",{className:cn$1(en,"novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",tn[n],Y(a,"statusChip",{tone:e})),children:jsx(MorphText,{children:o})})}var gs=["................",".....######.....","...##########...","..############..",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.","..############..","...##########...",".....######.....","................"],dp=["................","................","................","................","................","..........##....",".........###....","....##..###.....","....######......",".....####.......","......##........","................","................","................","................","................"],yp=["................","................","................","................","....##....##....","....###..###....",".....######.....","......####......","......####......",".....######.....","....###..###....","....##....##....","................","................","................","................"],Sa=e=>e.flatMap((t,a)=>[...t].flatMap((n,o)=>n==="."?[]:[{x:o,y:a}])),bs=({x:e,y:t})=>`${e},${t}`,ws=(e,t)=>{let a=new Set(t.map(bs));return e.filter(n=>!a.has(bs(n)))},Cs={check:ws(Sa(gs),Sa(dp)),cross:ws(Sa(gs),Sa(yp))},ks=/M(\d+) (\d+)h(\d+)v1h-\3z/g;function Ss(e){let t=new Map,a=(n,o)=>t.set(`${n},${o}`,{x:n,y:o});for(let n of e){if("d"in n){if(n.d.replace(ks,"")!=="")continue;for(let[,r,s,i]of n.d.matchAll(ks))for(let c=0;c<Number(i);c++)a(Number(r)+c,Number(s));continue}if([n.x,n.y,n.width,n.height].every(Number.isInteger))for(let r=0;r<n.height;r++)for(let s=0;s<n.width;s++)a(n.x+s,n.y+r);}return [...t.values()]}function Ps(e,t,a){if(t.length===0)return [];let n=Math.PI*2,o=({x:i,y:c})=>Math.atan2(c-a.y,i-a.x),r=(i,c)=>{let l=Math.abs(i-c)%n;return l>Math.PI?n-l:l},s=t.map(i=>({source:i,at:o(i)}));return e.map(i=>{let c=o(i);return s.reduce((l,p)=>r(p.at,c)<r(l.at,c)?p:l).source})}var co="mark",wp={paid:{mark:"check",tone:"novapay:text-[var(--tuwa-success-icon)]"},failed:{mark:"cross",tone:"novapay:text-[var(--tuwa-error-icon)]"},cancelled:{mark:"cross",tone:"novapay:text-[var(--tuwa-text-secondary)]"}},kp={unconfirmed:{Icon:yt,tone:"novapay:text-[var(--tuwa-pending-icon)]"},underpaid:{Icon:yt,tone:"novapay:text-[var(--tuwa-pending-icon)]"},needs_review:{Icon:mr,tone:"novapay:text-[var(--tuwa-info-icon)]"},refunded:{Icon:cr,tone:"novapay:text-[var(--tuwa-info-icon)]"},expired:{Icon:on,tone:"novapay:text-[var(--tuwa-text-secondary)]"},replaced:{Icon:ir,tone:"novapay:text-[var(--tuwa-info-icon)]"},blocked:{Icon:dr,tone:"novapay:text-[var(--tuwa-error-icon)]"}},Rs={waiting:"processing",paid:"succeed",failed:"failed"};function Cp(e,t){let a=e.viewBox.baseVal,n=e.getBoundingClientRect();if(!a||a.width===0||n.width===0)return [];let o=(c,l)=>Number(c.getAttribute(l)??0),r=c=>!c.closest("defs, clipPath, mask"),s=[...[...e.querySelectorAll("rect")].filter(r).map(c=>({x:o(c,"x"),y:o(c,"y"),width:o(c,"width"),height:o(c,"height")})),...[...e.querySelectorAll("path")].filter(r).map(c=>({d:c.getAttribute("d")??""}))],i=n.width/a.width;return Ss(s).map(({x:c,y:l})=>({x:n.left-t.left+(c+.5)*i,y:n.top-t.top+(l+.5)*i}))}function Sp(e,t,a){let n=[...e.querySelectorAll("[data-px]")],o=e.viewBox.baseVal,r=e.getBoundingClientRect();if(n.length===0||!o||o.width===0||r.width===0)return;let s=r.width/o.width,i=n.map(p=>({x:r.left-t.left+(Number(p.getAttribute("x")??0)+.5)*s,y:r.top-t.top+(Number(p.getAttribute("y")??0)+.5)*s})),c=Ps(i,a,{x:t.width/2,y:t.height/2});if(c.length===0)return;let l=p=>`${Math.round(p/s*100)/100}px`;n.forEach((p,m)=>{p.style.setProperty("--nova-px-x",l(c[m].x-i[m].x)),p.style.setProperty("--nova-px-y",l(c[m].y-i[m].y));});}function Pp({mark:e,moves:t,className:a}){return jsx("svg",{viewBox:`0 0 ${16} ${16}`,shapeRendering:"crispEdges",fill:"currentColor","aria-hidden":"true",className:cn$1("novapay:block",a),"data-motion":t?"assemble":void 0,children:Cs[e].map(({x:n,y:o})=>jsx("rect",{x:n,y:o,width:1,height:1,"data-px":"",style:pixelFlight(n,o)},`${n}-${o}`))})}function Is({kind:e,className:t}){let a=I(),{store:n,customization:o}=a,{look:r}=useNovaIcons(),s=useRef(null),i=useRef(null),c=!o.config?.animation?.disabled;useLayoutEffect(()=>{let h=s.current,x=h?.querySelector("svg")??null,g=h?.getBoundingClientRect(),k=i.current??bt(n,co)??null;x&&g&&c&&k&&k.kind!==e&&Sp(x,g,k.pixels);let N={kind:e,pixels:x&&g?Cp(x,g):[]};return i.current=N,On(n,co,N,false),()=>On(n,co,N)},[e,n,c]);let l=o.childCustomizations?.statusVisual,p=e in Rs?Rs[e]:null,m=p&&cn$1(l?.iconClassNames?.icon,l?.iconClassNames?.statusOverrides?.[p]),y=wp[e],f=kp[e],v=o.components?.StatusIcon,d=p?void 0:Y(a,"statusIcon",{kind:e}),R;if(!p&&v)R=jsx(v,{kind:e,className:d});else {if(p&&r!=="pixel")return jsx(TxStatusVisual,{isProcessing:e==="waiting",isSucceed:e==="paid",isFailed:e==="failed",...l,className:cn$1(t,l?.className)});e==="waiting"?R=jsx(QuasarLoader,{size:64,accent:"var(--tuwa-pending-icon)",className:cn$1("novapay:text-[var(--tuwa-text-primary)]",m)}):y&&r==="pixel"?R=jsx(Pp,{mark:y.mark,moves:c,className:cn$1(p?"novapay:h-16 novapay:w-16":"novapay:h-12 novapay:w-12",y.tone,m,d)}):y?R=jsx(DrawnCross,{variant:"disc",className:cn$1("novapay:h-12 novapay:w-12",y.tone,d)}):f&&(R=jsx(f.Icon,{"aria-hidden":true,className:cn$1("novapay:h-12 novapay:w-12",f.tone,d),...c&&r==="pixel"?{motion:"assemble"}:{}}));}return jsx("div",{className:cn$1("novapay:flex novapay:justify-center novapay:py-4",t,p&&l?.className),children:jsx("span",{ref:s,className:"novapay:relative novapay:flex novapay:h-16 novapay:w-16 novapay:items-center novapay:justify-center",children:R})})}function Ls({children:e,className:t}){let a=Ke("title",e);return jsx("h2",{...Nt,"aria-label":e,className:cn$1(at,t),children:jsx(MorphText,{wrap:true,children:a})})}function At({mark:e,tone:t,chip:a,title:n,amount:o,note:r}){let{display:s}=I(),i=s==="page",c=Ke("amount",o??""),l=Ke("note",r??"");return jsxs(Fragment$1,{children:[jsx(Is,{kind:e,className:i?"novapay-page-visual":void 0}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:items-center",children:[jsx(xs,{tone:t,children:a}),jsx(Ls,{className:"novapay:mt-2",children:n}),o&&jsx("p",{"aria-label":o,className:cn$1($,"novapay:m-0 novapay:mt-2 novapay:text-2xl novapay:font-bold",i&&"novapay-page-amount"),children:jsx(MorphText,{children:c||o})}),r&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:jsx(MorphText,{wrap:true,children:l||r})})]})]})}var Fs="steps";function fn({state:e}){let{store:t,customization:a}=I(),n=a.childCustomizations,[o]=useState(()=>bt(t,Fs)!==void 0),r=Ke(Fs,e),s=jsx(TxProgressIndicator,{isProcessing:r==="processing",isSucceed:r==="succeed",isConfirmed:r==="succeed",isFailed:r==="failed",...n?.progressIndicator,className:cn$1("novapay:max-w-sm",n?.progressIndicator?.className)});return o?jsx(AnimatePresence,{initial:false,children:s}):s}var Mp=new Set(["open","underpaid"]);function Ds(){let{checkout:e,state:t,labels:a,close:n,customization:o,now:r,handedOverAt:s,display:i}=I(),c$1=i==="page",l=o.childCustomizations,p=dn(),m=e?.invoice.dueAt?Date.parse(e.invoice.dueAt):null,y=t.invoiceStatus??e?.invoice.status,f=ot(t),v=!f&&ft(t,e),d=e!==null&&(f||v)&&Mp.has(y??"")&&m!==null&&r>=m,R=d&&Tr({state:t,checkout:e,handedOverAt:s,dueAt:m}),h=It(t.error)==="retrying",x=yn(n?"secondary":null,a.common.close);return jsxs(Ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",c$1&&"novapay-page-status"),children:[jsx(At,{mark:"waiting",tone:"pending",chip:a.status.pending,title:a.confirm.title,amount:p.amount,note:p.network?c(a.confirm.hint,{network:p.network}):null}),jsx(fn,{state:"processing"}),jsxs(xe,{className:"novapay:max-w-sm",children:[p.network&&jsx(H,{name:a.confirm.network,children:p.network}),p.txKey&&jsx(H,{name:a.confirm.transaction,children:jsx(HashLink,{hash:p.txKey,explorerUrl:p.explorerUrl,variant:"compact",...l?.hashLink})}),p.fromAddress&&jsx(H,{name:a.confirm.from,children:jsx(HashLink,{hash:p.fromAddress,explorerUrl:p.fromUrl,variant:"compact",...l?.hashLink})})]}),jsx("p",{role:"status",className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",c$1&&"novapay:mt-auto"),children:jsx(MorphText,{wrap:true,children:h?a.outcome.unconfirmedRetrying:d?c(R?a.confirm.afterDeadline:a.confirm.pastDeadline,{merchant:e.merchant.name}):v?a.confirm.invoicePayment:a.confirm.canClose})})]}),n&&jsx(Z,{children:jsx(ae,{onClick:n,children:x.label})})]})}function Pa({adapter:e,store:t,wallet:a$1,chainId:n}){let[o,r]=useState("idle"),[s,i]=useState(null),[c,l]=useState(null),p=useRef(0),m=a$1?.address,y=useRef(m);useEffect(()=>{y.current!==m&&(y.current=m,p.current++,r("idle"),i(null),l(null));},[m]);let f=useRef(false);return useEffect(()=>(f.current=false,()=>{f.current=true;}),[]),{step:o,problem:s,request:c,confirm:async({quote:d=false}={})=>{let R=++p.current,h=()=>p.current===R;i(null);let x=e?.signMessage;if(!x||!a$1)return i("unsupported"),false;if(a$1.chainId!==n&&e.switchChain){r("switching");try{await e.switchChain(n);}catch(b){if(h()){let L=b$1(b);i(L==="declined"?"switchDeclined":L==="failed"?"switchFailed":L),r("idle");}return false}if(!h())return false}h()&&r("signing");let g=t.getState().payer,k=null,N=await t.getState().confirmPayer(async(b,L)=>{h()&&l(L);try{return await x({message:b,account:a$1.address,chainId:L.chainId})}catch(B){let _=b$1(B);throw k=_==="declined"&&B instanceof a&&B.step==="switch"?"switchDeclined":_,B}});return h()&&(i(k),r("idle")),N&&d&&!f.current&&t.getState().payer===g&&await t.getState().requestQuote(),N},dismiss:()=>{p.current++,r("idle"),t.getState().abandonConfirmation();}}}function qs(e){return e.closest("[data-novapay-scroll]")??null}function Op(e,t){let a=t?.offsetHeight;return a&&a>0?Math.min(e,a):e}function Dp(e){let t=e.offsetHeight;return t>0?Op(t,qs(e)):null}function Na(e){let[t,a]=useState(null),[n,o]=useState(null),[r,s]=useState(null);return useEffect(()=>{if(!t)return;let i=qs(t),c=()=>{if(!e){let m=Dp(t);m!==null&&o(m);}let p=i?.offsetHeight;s(p&&p>0?p:null);};if(c(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(c);return e||l.observe(t),i&&l.observe(i),()=>l.disconnect()},[t,e]),!e||n===null?[a,null]:[a,r?Math.min(n,r):n]}var Wp=new Set(["evm:coinbase","evm:baseaccount","evm:porto"]);function Ta(e){return !!(e&&Wp.has(e.connectorType.toLowerCase()))}function Us(e,t){return e==="required"||e==="confirming"?true:e==="unless_relayed"&&t!=="relay"}async function Hs(e,t){let{payerProof:a}=e.getState();if(a==="required"||a==="confirming")return t(true),null;t(false);let n=await e.getState().requestQuote();return !n&&e.getState().error?.code==="payer_proof_required"&&t(true),n}var qp=new Set(["payer_chain_mismatch","too_many_payers","payer_is_recipient"]);function yo(e){let t=e?.code;return t!==void 0&&(t.startsWith("payer_proof_")||qp.has(t))}var Up=new Set(["rate_limited","request_failed","origin_required","invoice_not_payable"]);function Dn(e){let t=e?.code;return yo(e)||t!==void 0&&Up.has(t)}function Ra(e,t,a,n){if(t==="declined")return c(a.payerProof.declined,n);if(t==="switchDeclined")return c(a.payerProof.switchDeclined,n);if(t==="unsupported")return c(a.payerProof.unsupported,n);if(t==="wrongNetwork"||t==="switchFailed")return c(a.payerProof.wrongNetwork,n);if(t==="notAuthorized")return c(a.pay.notAuthorized,n);if(t==="alreadyPending")return c(a.walletPrompt.stillWaiting,n);if(t)return c(a.payerProof.failed,n);switch(e?.code){case void 0:case "payer_proof_required":return null;case "payer_proof_declined":return c(a.payerProof.declined,n);case "payer_proof_invalid":return a.payerProof.invalid;case "payer_proof_unavailable":return a.payerProof.unavailable;case "payer_chain_mismatch":return c(a.payerProof.wrongNetwork,n);case "too_many_payers":return c(a.payerProof.tooManyWallets,n);case "payer_is_recipient":return a.method.payerIsRecipient;case "rate_limited":return a.method.rateLimited;case "request_failed":return a.pay.noAnswer;default:return a.error.generic}}function qn({kind:e,walletName:t,walletId:a,walletIcon:n,amount:o,merchant:r,network:s,to:i,priceTime:c$1,onRetry:l,text:p,details:m,hint:y,onCancel:f,stepHeight:v}){let{labels:d,display:R}=I(),h=useId(),x=useRef(null);useEffect(()=>x.current?.focus(),[e]);let[g]=useState(()=>typeof document>"u"?null:document.activeElement);useEffect(()=>()=>{let b=g?.ownerDocument;if(!g||!b||g===b.body||!g.isConnected)return;let L=b.activeElement;L&&L!==b.body&&!L.contains(g)||g.focus();},[g]);let k={wallet:t,amount:o,merchant:r,network:s},N=e==="sign"||e==="proof"?d.walletPrompt.signIn:e==="switch"?d.walletPrompt.switchIn:e==="submitting"?d.walletPrompt.submitting:d.walletPrompt.confirmIn;return jsxs("section",{"aria-labelledby":h,style:v?{"--novapay-step-height":`${v}px`}:void 0,className:cn$1("tuwa-scanlines novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center-safe novapay:gap-3 novapay:bg-[var(--tuwa-bg-primary)] novapay:px-6 novapay:py-5 novapay:text-center",v&&(R==="page"?"novapay:min-h-[var(--novapay-step-height)]":"novapay:max-sm:min-h-[var(--novapay-step-height)]")),children:[jsx(ma,{walletId:a,walletIcon:n}),jsx("h2",{id:h,ref:x,tabIndex:-1,className:at,children:c(N,k)}),(e==="sign"||e==="confirm"||e==="proof")&&jsxs(Fragment$1,{children:[jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:p??c(e==="confirm"?d.walletPrompt.confirmText:d.walletPrompt.signText,k)}),y&&jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:y}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-xs novapay:flex-col novapay:gap-1.5 novapay:text-left",children:[jsx("span",{className:Oe,children:jsx(ge,{label:d.walletPrompt.check,values:k})}),jsx(xe,{children:m?m.map(b=>jsx(H,{name:b.name,children:b.value},b.name)):jsxs(Fragment$1,{children:[jsx(H,{name:d.walletPrompt.amount,children:o}),jsx(H,{name:d.walletPrompt.to,children:i}),jsx(H,{name:d.walletPrompt.network,children:s}),c$1&&jsx(H,{name:d.walletPrompt.priceLocked,children:c$1})]})})]}),l?jsxs("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[d.walletPrompt.notOpened," ",jsx(ht,{onClick:l,children:d.walletPrompt.tryAgain})]}):jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(d.walletPrompt.stillWaiting,k)})]}),e!=="submitting"&&jsx(ae,{onClick:f,className:"novapay:max-w-xs",children:d.walletPrompt.cancel})]})}function zs(){let{checkout:e,state:t,store:a,labels:n,locale:o,wallet:r,adapterFor:s,connectWallet:i,setConfirmWallet:c$1}=I(),l=e?.methods.find(z=>z.id===t.methodId)??null,p=l?Ye(l):null,m=Pa({adapter:p?s(p):void 0,store:a,wallet:r,chainId:l?.chainId??""}),[y,f]=useState(false),v=useRef(null),d=m.step!=="idle",[R,h]=Na(d),x=useRef(false);if(useEffect(()=>{x.current&&!d&&v.current?.querySelector("[data-novapay-heading]")?.focus(),x.current=d;},[d]),!e||!l)return null;let g=e.merchant.name,k=r?.name??"",N=ve(l.chainId),b=e.invoice.number??e.invoice.id,L=e.invoice.totalMinor?`${ye(Re(e.invoice.totalMinor),o)} ${e.invoice.currency}`:null,B=Ta(r),_=t.phase==="quoting",w=d,D=Ra(!_&&Dn(t.error)?t.error:null,m.problem,n,{wallet:k,network:N,merchant:g}),E={wallet:k,invoice:b,merchant:g},C=Ue(r,l),ie=()=>{C&&t.payer!==C&&a.getState().setPayer(C),m.confirm({quote:true});},P=()=>{c$1(false),a.getState().clearError();},W=C?t.confirmedWallets?.find(z=>!sn(z,C)):void 0;return jsxs("div",{ref:v,className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:R,inert:d,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",d&&"novapay:hidden"),children:[jsxs(de,{title:n.payerProof.title,subtitle:n.payerProof.text,children:[r&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:h-7 novapay:w-7 novapay:shrink-0",children:jsx(WalletIcon,{walletName:r.walletId})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:k}),jsx("span",{className:cn$1($,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(r.address),network:ve(r.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:()=>{i(l)||f(true);},className:nn,children:n.pay.change})]}),jsx(cn,{children:n.payerProof.summary}),jsxs(xe,{children:[jsx(H,{name:n.payerProof.invoice,children:b}),jsx(H,{name:n.payerProof.merchant,children:g}),L&&jsx(H,{name:n.payerProof.amount,children:L}),r&&jsx(H,{name:n.payerProof.wallet,children:jsx(He,{hash:r.address,chainId:r.chainId})})]}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.why}),B&&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(pr,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsx("span",{children:c(n.payerProof.passkey,E)})]}),r&&p==="eip155"&&r.chainId!==l.chainId&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.payerProof.willSwitch,{current:ve(r.chainId),network:N})}),W&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:c(n.payerProof.alreadyConfirmed,{wallet:shortAddress(Et(W))})}),D&&jsx(Q,{children:D}),y&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(Z,{children:[jsx(X,{busy:w||_,onClick:ie,children:_?n.method.quoting:w?jsx(ge,{label:n.payerProof.waiting,values:E}):jsx(ge,{label:n.payerProof.confirm,values:E})}),jsx(ae,{disabled:_,onClick:P,children:(t.invoiceStatus??e?.invoice.status)==="underpaid"?n.pay.backFromRest:n.pay.back}),jsx($e,{children:B?n.payerProof.noteSmart:n.payerProof.note})]})]}),d&&jsx(qn,{kind:m.step==="switching"?"switch":"proof",walletName:k,walletId:r?.walletId??"",walletIcon:r?.icon,amount:L??"",merchant:g,network:N,to:"",priceTime:null,text:c(B?n.payerProof.promptPasskey:n.payerProof.promptText,E),details:[...m.request?[{name:n.payerProof.site,value:m.request.domain}]:[],{name:n.payerProof.invoice,value:b},{name:n.payerProof.merchant,value:g},...L?[{name:n.payerProof.amount,value:L}]:[]],hint:m.request?c(n.payerProof.signInRequest,{wallet:k,site:m.request.domain}):void 0,onRetry:ie,onCancel:m.dismiss,stepHeight:h})]})}var Zp=/^0x[0-9a-fA-F]{64}$/,Jp=/^[1-9A-HJ-NP-Za-km-z]{64,90}$/;function Hn(){let{store:e,state:t,checkout:a,labels:n,wallet:o}=I(),[r,s]=useState(false),[i,c]=useState(""),[l,p]=useState(false),[m,y]=useState(null),f=useId(),v=t.quote??a?.quote;if(!v)return null;let d=n.outcome;if(!r)return jsx(ht,{onClick:()=>s(true),children:d.nameHash});let R=async h=>{h.preventDefault();let x=i.trim();if(!(v.instructions.family==="solana"?Jp:Zp).test(x))return y(d.nameHashInvalid);y(null),p(true);let k=await e.getState().submit({txKey:x,...o?{from:o.address}:{}});p(false),k||y(d.nameHashRefused);};return jsxs("form",{onSubmit:h=>{R(h);},className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:gap-2 novapay:text-left",children:[jsx("label",{htmlFor:f,className:"novapay:text-xs novapay:font-semibold",children:d.nameHashField}),jsx("input",{id:f,value:i,autoComplete:"off",spellCheck:false,"aria-invalid":m?true:void 0,onChange:h=>c(h.target.value),className:cn$1($,"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)]",ce)}),m&&jsx(Q,{children:m}),jsx(ae,{type:"submit",disabled:l||!i.trim(),children:d.nameHashSend})]})}var js=e=>e?.code==="payment_unconfirmed",nu={nonceSpent:"unconfirmedNonceSpent",unmined:"unconfirmedUnmined",rechecked:"unconfirmedNote",retrying:"unconfirmedRetrying",notReceived:"unconfirmedNotReceived",contact:"unconfirmedContact",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"},Ys=new Set(["nonceSpent","unmined","notReceived","contact","closed","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Zs=new Set(["nonceSpent","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Js={unconfirmed:{tone:"pending",label:"unconfirmed"},underpaid:{tone:"pending",label:"underpaid"},needs_review:{tone:"neutral",label:"review"},refunded:{tone:"neutral",label:"refunded"},expired:{tone:"neutral",label:"expired"},cancelled:{tone:"neutral",label:"cancelled"},replaced:{tone:"neutral",label:"replaced"},blocked:{tone:"error",label:"blocked"}},ee=({children:e,muted:t})=>jsx("p",{className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs",t?"novapay:text-[var(--tuwa-text-secondary)]":"novapay:text-[var(--tuwa-text-primary)]"),children:e});function vo(){let e=I(),{checkout:t,labels:a,onContact:n}=e;if(!t)return null;let o=jsx(ge,{label:a.outcome.contact,values:{merchant:t.merchant.name}}),r=cn$1(sa,Y(e,"secondaryButton"));if(n)return jsx("button",{type:"button",onClick:n,className:r,children:o});let s=_r(t.merchant,c(a.outcome.contactSubject,{number:t.invoice.number??t.invoice.id}));return s?jsx("a",{href:s,target:s.startsWith("mailto:")?void 0:"_blank",rel:"noopener noreferrer",className:r,children:o}):null}function Xs({kind:e}){let[t,a]=useState(false),n=I(),{checkout:o,state:r,store:s,labels:i,locale:c$1,now:l,wallet:p,connectWallet:m,openInvoice:y,qrShown:f,paymentSent:v,adapterFor:d,lockPrice:R}=n;if(!o)return null;let h=o.merchant.name,x=r.quote,g=o.methods.find(P=>P.id===(r.methodId??x?.methodId)),k=o.invoice.dueAt&&!o.invoice.closed?new Intl.DateTimeFormat(c$1,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(o.invoice.dueAt)):null,N=(P,W=x)=>W?`${pe(P,W.decimals,c$1)} ${W.instructions.symbol}`:P,b=It(r.error),L=P=>c(i.outcome[nu[P]],{merchant:h}),B=r.followingUntil??null,_=B?jsx(ee,{muted:true,children:c(i.outcome.followingUntil,{time:new Intl.DateTimeFormat(c$1,{timeStyle:"short"}).format(Date.parse(B))})}):null,w=Lr(r,o),D=P=>{if(!w||P!=="mismatch"&&(!P||!Ys.has(P)))return null;let W=x??o.quote,z=W?he(W.instructions):null,Se=W&&z?d(W.instructions.family)?.explorerUrl?.({chainId:z,txKey:w}):void 0;return jsx(Ze,{children:jsx(xe,{className:"novapay:w-full novapay:max-w-sm",children:jsx(H,{name:i.confirm.transaction,children:jsx(HashLink,{hash:w,explorerUrl:Se,variant:"compact",...n.customization.childCustomizations?.hashLink})})})})},E,C=null,ie=null;switch(e){case "unconfirmed":{if(E=i.outcome.unconfirmedTitle,vt(r.error))C=jsxs(Fragment$1,{children:[jsx(ee,{children:Ut(r.error,i,h)}),D("mismatch")]});else if(b&&Zs.has(b))C=jsxs(Fragment$1,{children:[jsx(ee,{children:L(b)}),D(b),b==="nonceSpent"&&jsx(Hn,{})]});else {let z=b??"contact";C=jsxs(Fragment$1,{children:[jsx(ee,{children:i.outcome.unconfirmedText}),jsx(ee,{muted:true,children:L(z)}),D(z),jsx(Hn,{})]});}let{payAgain:P}=s.getState(),W=r.invoiceStatus??o.invoice.status;P&&(W==="open"||W==="underpaid")&&!(b&&Zs.has(b))&&(ie=vt(r.error)?r.error.unmatched===true?jsx(X,{onClick:()=>P(),children:i.pay.payAgain}):jsx(ae,{onClick:()=>P(),children:i.pay.payAgain}):jsx(ae,{onClick:()=>P(),children:i.outcome.unconfirmedPayAgain}));break}case "underpaid":{let P=x??o.quote,W=o.invoice.amountPaid,z=Mr(P,W);E=i.outcome.underpaidTitle;let Se=P&&W&&jsx(ee,{children:c(i.outcome.underpaidText,{received:N(W,P),total:N(P.cryptoAmountExpected,P)})});if(o.invoice.status==="underpaid"&&o.invoice.restPayable===false||r.error?.code==="method_not_found"){C=jsxs(Fragment$1,{children:[Se,jsx(ee,{children:i.outcome.underpaidClosed}),k&&jsx(ee,{children:c(i.outcome.underpaidClosedRefund,{merchant:h,date:k})})]});break}let we=rn(P,l,i,h,c$1,i.outcome.underpaidRateEnded),re=o.methods.find(De=>De.id===P?.methodId)??g??o.methods[0],ke=r.error?.code==="payer_blocked"?c(i.outcome.underpaidBlocked,{merchant:h}):r.error&&r.error.code!=="payer_mismatch"?pa(r.error,i,h):null;C=jsxs(Fragment$1,{children:[Se,P&&z&&jsx(ee,{children:c(i.outcome.underpaidRest,{rest:N(z,P),network:ve(he(P.instructions))})}),k&&jsx(ee,{muted:true,children:c(i.outcome.underpaidNote,{merchant:h,date:k})}),we&&jsx(ee,{muted:true,children:we}),ke&&jsx(Q,{children:ke})]});let A=re&&p?Ue(p,re):null,F=r.error?.code==="payer_mismatch"?r.error.originWallet??null:null,U=F??o.invoice.originWallet??P?.payer??null,ne=U?Et(U):void 0,le=A?parseCaip10AccountId(A)?.address:void 0,se=P?.payer!==null&&!!(ne&&(le?!sn(le,ne):F)),Me=()=>{if(!re)return;if(se)return void m(re);let De=P?.payer===null?null:A;if(P?.payer!==null&&!De)return void m(re);r.methodId!==re.id&&s.getState().selectMethod(re.id),s.getState().setPayer(De),R();};se&&ne&&(C=jsxs(Fragment$1,{children:[C,jsx(ee,{children:c(i.outcome.payRestFirstWallet,{wallet:shortAddress(ne)})})]})),ie=jsx(X,{busy:r.phase==="quoting",onClick:Me,children:i.outcome.payRest});break}case "needs_review":{E=c(i.outcome.reviewTitle,{merchant:h});let P=o.invoice.review?.reason,W=P==="late"?i.outcome.reviewLate:P==="overpaid"?i.outcome.reviewOverpaid:P==="quote_expired"?i.outcome.reviewQuoteExpired:i.outcome.reviewScreening;C=jsxs(Fragment$1,{children:[jsx(ee,{children:c(W,{merchant:h})}),jsx(ee,{muted:true,children:i.outcome.reviewNote})]});break}case "refunded":{E=i.outcome.refundedTitle;let P=o.invoice.refundedTotalMinor??o.invoice.totalMinor;C=P&&jsx(ee,{children:c(i.outcome.refundedText,{merchant:h,amount:ye(Re(P),c$1),currency:o.invoice.currency})});break}case "expired":{E=i.outcome.expiredTitle;let P=Br(o.invoice.amountPaid),W=x??o.quote,z=ot(r)||ft(r,o),Se=js(r.error)||b==="settlementFailed"||b==="settlementRetrying",Ne=Se||!z&&qt(r,o),we=!Ne&&b==="closed",re=!Ne&&!we&&(z||v),ke=!Ne&&!we&&!re&&vt(r.error),A=re||Ne||we||ke||f,F=Se?b??"contact":"rechecked";C=jsxs(Fragment$1,{children:[P?jsxs(Fragment$1,{children:[k&&jsx(ee,{children:W?c(i.outcome.expiredPartText,{date:k,amount:N(P,W)}):c(i.outcome.expiredPartNoAmount,{date:k})}),!k&&W&&jsx(ee,{children:c(i.outcome.closedPartText,{merchant:h,amount:N(P,W)})}),jsx(ee,{children:c(i.outcome.expiredPartRefund,{merchant:h})})]}):!A&&k&&jsx(ee,{children:c(i.outcome.expiredText,{date:k,merchant:h})}),Ne?jsxs(Fragment$1,{children:[jsx(ee,{children:F==="rechecked"?c(i.outcome.expiredUnconfirmed,{merchant:h}):L(F)}),D(F),F==="nonceSpent"&&jsx(Hn,{})]}):we?jsxs(Fragment$1,{children:[jsx(ee,{children:L("closed")}),D("closed")]}):re?jsxs(Fragment$1,{children:[jsx(ee,{children:c(i.outcome.expiredWhileConfirming,{merchant:h})}),_]}):ke?jsxs(Fragment$1,{children:[jsx(ee,{children:Ut(r.error,i,h)}),D("mismatch")]}):f?jsx(ee,{children:c(i.outcome.expiredAfterQr,{merchant:h})}):jsx(ee,{muted:true,children:i.outcome.expiredNote})]});break}case "cancelled":{if(E=i.outcome.cancelledTitle,b&&Ys.has(b)){C=jsxs(Fragment$1,{children:[jsx(ee,{children:L(b)}),D(b),b==="nonceSpent"&&jsx(Hn,{})]});break}let P=js(r.error)||b==="closed"||ot(r)||ft(r,o)||qt(r,o)||v,W=!P&&vt(r.error),z=P?c(i.outcome.cancelledWhilePaying,{merchant:h}):W?Ut(r.error,i,h):c(f?i.outcome.cancelledAfterQr:i.outcome.cancelledText,{merchant:h});C=jsxs(Fragment$1,{children:[jsx(ee,{children:z}),W&&D("mismatch"),b==="retrying"&&jsx(ee,{muted:true,children:i.outcome.unconfirmedRetrying}),P&&_]});break}case "replaced":{let P=o.invoice.replacedBy,W=P?.number??"";if(E=c(i.outcome.replacedTitle,{merchant:h}),C=jsxs(Fragment$1,{children:[jsx(ee,{children:c(i.outcome.replacedText,{number:W})}),jsx(ee,{muted:true,children:i.outcome.replacedPaid})]}),P?.checkoutToken){let z=P.checkoutToken;ie=jsx(X,{onClick:()=>y(z),children:jsx(ge,{label:i.outcome.openReplacement,values:{number:W}})});}break}case "blocked":{E=i.outcome.blockedTitle;let P=r.payer?parseCaip10AccountId(r.payer)?.address:void 0;C=jsxs(Fragment$1,{children:[jsx(ee,{children:r.error?.code==="payer_not_expected"?i.method.payerNotExpected:c(i.outcome.blockedText,{merchant:h})}),P&&jsx(He,{hash:P,chainId:x??o.quote?he((x??o.quote).instructions):null})]}),g&&(ie=jsx(X,{onClick:()=>{m(g)||a(true);},children:i.outcome.useAnotherWallet}));break}}return jsxs(Fragment$1,{children:[jsxs("section",{role:e==="blocked"?"alert":void 0,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",n.display==="page"&&"novapay-page-status"),children:[jsx(At,{mark:e,tone:Js[e].tone,chip:i.status[Js[e].label],title:E}),C,t&&jsx(Q,{children:i.pay.connectUnavailable})]}),jsxs(Z,{children:[ie,jsx(vo,{})]})]})}function $n({children:e,className:t}){let{store:a,customization:n}=I(),[o]=useState(()=>bt(a,"title")!==void 0),r=o&&!n.config?.animation?.disabled;return jsx("div",{className:cn$1("novapay:w-full",r&&"novapay-status-reveal",t),children:e})}function ti(){let e=I(),{checkout:t,state:a,labels:n,adapterFor:o,payAfterFailure:r,customization:s,display:i}=e,c$1=dn(),l=yn("primary",n.pay.payAgain);if(!t||!a.error)return null;let p=i==="page",m=s.childCustomizations,y=la(a.error)??c$1.txKey,f=a.quote??t.quote,v=f?he(f.instructions):null,d=y===c$1.txKey?c$1.explorerUrl:f&&v&&y?o(f.instructions.family)?.explorerUrl?.({chainId:v,txKey:y}):void 0;return jsxs(Ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",p&&"novapay-page-status"),children:[jsx(At,{mark:"failed",tone:"error",chip:n.status.failed,title:n.failed.title,amount:c$1.amount,note:c$1.network?c(n.failed.summary,{network:c$1.network}):null}),jsx(fn,{state:"failed"}),(c$1.network||y||c$1.fromAddress)&&jsxs(xe,{className:"novapay:max-w-sm",children:[c$1.network&&jsx(H,{name:n.confirm.network,children:c$1.network}),y&&jsx(H,{name:n.confirm.transaction,children:jsx(HashLink,{hash:y,explorerUrl:d,variant:"compact",...m?.hashLink})}),c$1.fromAddress&&jsx(H,{name:n.confirm.from,children:jsx(HashLink,{hash:c$1.fromAddress,explorerUrl:c$1.fromUrl,variant:"compact",...m?.hashLink})})]}),jsx($n,{className:"novapay:max-w-sm",children:jsx("p",{role:"status",className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:An(a.error,n,c$1.network??void 0)})})]}),jsxs(Z,{children:[jsx(X,{onClick:r,className:l.arrives?Ca:void 0,children:l.label}),jsx($n,{children:jsx(vo,{})})]})]})}function oi({onStay:e,onLeave:t}){let{checkout:a,labels:n,locale:o}=I(),r=useId(),s=useId(),i=useRef(null),c$1=a?.invoice.dueAt?new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(a.invoice.dueAt)):null;return jsx(Dialog,{open:true,onOpenChange:l=>{l||e();},children:jsxs(DialogContent,{role:"alertdialog","aria-labelledby":r,"aria-describedby":s,onOpenAutoFocus:l=>{l.preventDefault(),i.current?.focus();},className:"novapay:w-full novapay:sm:w-[24rem]",children:[jsx(DialogTitle,{"aria-hidden":true,className:"novapay:sr-only",children:n.leave.title}),jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:p-5 novapay:text-center",children:[jsx("h2",{id:r,ref:i,tabIndex:-1,className:at,children:n.leave.title}),jsx("p",{id:s,className:"novapay:m-0 novapay:text-xs",children:c$1?c(n.leave.text,{date:c$1}):n.leave.textNoDate}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.leave.price}),jsx(X,{onClick:e,children:n.leave.stay}),jsx(ae,{onClick:t,children:n.leave.leave})]})]})})}function vn({label:e,items:t,value:a,getKey:n,onChange:o,children:r,className:s,itemClassName:i}){let c=useRef([]),l=Math.max(0,t.findIndex(m=>n(m)===a)),p=(m,y)=>{let f=t.length-1,v={ArrowRight:y+1,ArrowDown:y+1,ArrowLeft:y-1,ArrowUp:y-1,Home:0,End:f}[m.key];if(v===void 0)return;m.preventDefault();let d=v<0?f:v>f?0:v;o(n(t[d])),c.current[d]?.focus();};return jsx("div",{role:"radiogroup","aria-label":e,className:s,children:t.map((m,y)=>{let f=n(m),v=f===a;return jsx("button",{ref:d=>{c.current[y]=d;},type:"button",role:"radio","aria-checked":v,tabIndex:y===l?0:-1,onClick:()=>o(f),onKeyDown:d=>p(d,y),className:cn$1("novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-left novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors","novapay:border",v?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",ce,i?.(v,m)),children:r(m,v)},f)})})}function Kn({tone:e,children:t}){return jsx("span",{className:cn$1(en,tn[e]),children:t})}function ci({method:e,labels:t}){let a=Xa(e);return a?a.kind==="discount"?jsx(Kn,{tone:"success",children:c(t.method.discount,{percent:a.percent})}):jsx(Kn,{tone:"neutral",children:c(t.method.markup,{percent:a.percent})}):null}function gu({selected:e}){return jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-full)] novapay:box-border",e?"novapay:border-4 novapay:border-[var(--tuwa-text-accent)]":"novapay:border novapay:border-[var(--tuwa-text-secondary)]")})}function bu({labels:e,terms:t,refundPolicy:a}){let n=(r,s)=>jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:s},r),o=t&&a?d(e.method.agreeBoth,{terms:n(t,e.summary.terms),refundPolicy:n(a,e.summary.refundPolicy)}):t||a?d(e.method.agreeOne,{link:t?n(t,e.summary.terms):n(a,e.summary.refundPolicy)}):null;return o?jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o}):null}function li(){let e=I(),{checkout:t,state:a,store:n,labels:o,wallet:r,payWith:s,setPayWith:i,payUrl:c$1,connectWallet:l,adapterFor:p,setHandoff:m,lockPrice:y}=e,{TokenOption:f,NetworkOption:v}=e.customization.components??{},d=useMemo(()=>t?.methods??[],[t]),R=useMemo(()=>wr(d,r?.chainId),[d,r?.chainId]),h=d.find(A=>A.id===a.methodId)??null,x=R.find(A=>A.symbol===h?.symbol)??null,g=h?hr(h,c$1):false,k=h?Ye(h):null,b=[...(k?!!p(k):false)?["wallet"]:[],...g?["qr"]:[]],L=b.includes(s)?s:b[0]??null,[B,_]=useState(false),w=useId(),D=useId(),E=useEffectEvent(()=>{let A=R[0]?.methods[0];!a.methodId&&A&&n.getState().selectMethod(A.id,{keepError:true});});if(useEffect(()=>E(),[R]),!t)return null;if(d.length===0)return jsx(de,{title:o.method.title,children:jsx(Q,{children:o.method.noMethods})});let C=e.display==="page",ie=R.reduce((A,F)=>F.methods.length>A.methods.length?F:A,R[0]),P=a.phase==="quoting",W=t.consent??null,z=!!a.consentGiven,Se=!!(W?.required&&!z),Ne=e.customization.handlers,we=A=>{let F=()=>n.getState().selectMethod(A.id);Ne?.onMethodSelect?Ne.onMethodSelect({method:A,select:F}):F();},re=async()=>{if(!h||!L)return;if(_(false),L==="qr"){if(s!=="qr"&&i("qr"),k!=="solana")return m(true);n.getState().setPayer(null),await n.getState().requestQuote();return}s!=="wallet"&&i("wallet");let A=Ue(r,h);if(!A)return _(!l(h));n.getState().setPayer(A),await y();},ke=A=>jsxs(Fragment$1,{children:[jsx(cn,{children:jsx(ge,{label:o.method.network,values:{symbol:A.symbol}})}),jsx(vn,{label:c(o.method.network,{symbol:A.symbol}),items:A.methods,value:h?.id??null,getKey:F=>F.id,onChange:F=>{let U=A.methods.find(ne=>ne.id===F);U&&we(U);},className:C&&A.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,U)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-3 novapay:py-2.5",Y(e,"networkOption",{method:U,selected:F})),children:(F,U)=>v?jsx(v,{method:F,selected:U}):jsxs(Fragment$1,{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:ve(F.chainId)}),jsxs("span",{className:"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-1.5",children:[r?.chainId===F.chainId&&jsx(Kn,{tone:"neutral",children:o.method.yourWallet}),F.featured&&jsx(Kn,{tone:"accent",children:o.method.popular}),jsx(ci,{method:F,labels:o}),F.gasless==="auto"?jsx(Kn,{tone:"success",children:o.method.noGasFee}):jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.buyerPaysGas})]})]}),jsx(gu,{selected:U})]})})]});return jsxs(Fragment$1,{children:[jsxs(de,{title:o.method.title,subtitle:c(o.method.subtitle,{minutes:Math.round(t.quoteTtlSeconds/60)}),children:[jsx(cn,{children:o.method.token}),jsx(vn,{label:o.method.token,items:R,value:x?.symbol??null,getKey:A=>A.symbol,onChange:A=>{let F=R.find(U=>U.symbol===A)?.methods[0];F&&we(F);},className:"novapay:grid novapay:grid-cols-[repeat(auto-fit,minmax(5.5rem,1fr))] novapay:gap-2",itemClassName:(A,F)=>cn$1("novapay:flex novapay:min-w-0 novapay:flex-col novapay:items-center novapay:gap-1 novapay:px-2 novapay:py-2",C&&"novapay-page-token",Y(e,"tokenOption",{group:F,selected:A})),children:(A,F)=>f?jsx(f,{group:A,selected:F}):jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:h-6.5 novapay:w-6.5",children:jsx(TokenIcon,{symbol:A.symbol})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:A.symbol}),jsx("span",{className:"novapay:max-w-full novapay:truncate novapay:text-[10px] novapay:text-[var(--tuwa-text-secondary)]",children:A.methods.length>1?c(o.method.networks,{count:A.methods.length}):Xa(A.methods[0])?jsx(ci,{method:A.methods[0],labels:o}):ve(A.methods[0].chainId)})]})}),C&&x?jsxs("div",{className:cn$1("novapay:grid",x.methods.length===1&&"novapay:max-sm:hidden"),children:[ie!==x&&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:ke(ie)}),jsx("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1]",children:ke(x)})]}):x&&x.methods.length>1&&ke(x),jsx(cn,{children:o.method.payWith}),jsx(vn,{label:o.method.payWith,items:b,value:L,getKey:A=>A,onChange:A=>{_(false),i(A);},className:cn$1("novapay:grid novapay:gap-2",b.length>1&&"novapay:grid-cols-2"),itemClassName:(A,F)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-2.5 novapay:py-2",C&&"novapay-page-way",Y(e,"payWithOption",{payWith:F,selected:A})),children:A=>A==="wallet"?jsxs(Fragment$1,{children:[r?jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(Fn,{walletId:r.walletId,icon:r.icon})}):jsx(rr,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:text-[var(--tuwa-text-accent)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:o.method.wallet}),jsx("span",{className:cn$1("novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",r&&$),children:r?`${r.name} \xB7 ${shortAddress(r.address)}`:o.method.walletHint})]})]}):jsxs(Fragment$1,{children:[h&&Ye(h)==="solana"?jsx(yr,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}):jsx(lr,{"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})]})]})}),W&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-start novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:transition-colors",z?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",Y(e,"consentOption",{checked:z,required:W.required})),children:[jsx(da,{checked:z,required:W.required,"aria-labelledby":w,"aria-describedby":W.required?D:void 0,onChange:A=>n.getState().setConsentGiven(A.target.checked),className:"novapay:mt-0.5"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-1",children:[jsx("span",{id:w,className:"novapay:whitespace-pre-line novapay:break-words novapay:text-[12px] novapay:leading-snug",children:W.text}),W.required&&jsx("span",{id:D,className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.consentRequired})]})]}),h&&!L&&jsx(Q,{children:o.method.methodUnavailable}),B&&jsx(Q,{children:g?o.pay.connectUnavailable:o.method.methodUnavailable}),a.error&&a.phase==="selectMethod"&&jsxs(Fragment$1,{children:[jsx(Q,{children:pa(a.error,o,t.merchant.name)}),jsx(ya,{error:a.error})]})]}),jsxs(Z,{children:[jsx(X,{busy:P,disabled:!h||!L||Se,onClick:()=>{h&&L&&Ne?.onQuote?Ne.onQuote({method:h,payWith:L,proceed:re}):re();},children:P?o.method.quoting:o.method.continue}),jsx(bu,{labels:o,terms:t.merchant.links.terms,refundPolicy:t.merchant.links.refundPolicy})]})]})}function di(e,t,a,n=false){let o=useRef(null),r=t?.id??null,s=useEffectEvent(()=>{t&&a?.({...t,status:"paid"});});useEffect(()=>{e!=="paid"||!r||o.current===r||(o.current=r,n||s());},[e,r,n]);}function yi({url:e,seconds:t,now:a,navigate:n=o=>window.location.assign(o)}){let[o,r]=useState(t>0?a:null);t>0!=(o!==null)&&r(t>0?a:null);let s=t>0?o??a:a,[i,c]=useState(false),l=e&&t>0&&!i?Math.max(0,t-Math.floor((a-s)/1e3)):null,p=useEffectEvent(()=>{e&&n(e);});return useEffect(()=>{l===0&&p();},[l]),{left:l,stay:()=>c(true)}}function vi(){let e=I(),{checkout:t,state:a,labels:n,locale:o,now:r,close:s,autoReturnSeconds:i,openedPaid:c$1,display:l}=e,p=e.customization.childCustomizations,m=dn(),[y]=useState(r),f=t?.merchant.name??"",v=l==="modal"&&i===0?null:t?.invoice.successUrl??null,d=yi({url:v,seconds:c$1?0:i,now:r}),R=v?n.paid.back:s?n.common.close:null,h=yn(R===null?null:"primary",R??""),x=h.arrives?Ca:void 0;if(!t)return null;let g=t.invoice.totalMinor?ye(Re(t.invoice.totalMinor),o):null,k=t.invoice.refundedTotalMinor&&BigInt(t.invoice.refundedTotalMinor)>0n?ye(Re(t.invoice.refundedTotalMinor),o):null,N=t.invoice.paidAt?Date.parse(t.invoice.paidAt):y,b=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(N),{transfers:L}=m,B=L.length>1?L:null,_=L.length===1?L[0]:null,w=m.txKey??_?.txKey??null,D=m.txKey?m.explorerUrl:_?.explorerUrl,E=new Intl.DateTimeFormat(o,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return jsxs(Ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",e.display==="page"&&"novapay-page-status"),children:[jsx(At,{mark:"paid",tone:"success",chip:n.status.paid,title:n.paid.title,amount:m.paidAmount??(g&&`${g} ${t.invoice.currency}`),note:m.network?c(n.paid.summary,{network:m.network,date:b}):b}),jsx(fn,{state:"succeed"}),(m.network||w||B||m.from)&&jsxs(xe,{className:"novapay:max-w-sm",children:[m.network&&jsx(H,{name:n.confirm.network,children:m.network}),B?B.map((C,ie)=>jsxs(H,{name:jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:block",children:c(n.confirm.transferOf,{index:ie+1,count:B.length})}),jsx("time",{dateTime:new Date(C.at).toISOString(),className:"novapay:block novapay:text-[11px] novapay:leading-4",children:E.format(C.at)})]}),children:[C.amount&&jsx("span",{className:"novapay:block",children:C.amount}),jsx(HashLink,{hash:C.txKey,explorerUrl:C.explorerUrl,variant:"compact",...p?.hashLink})]},`${C.txKey}:${ie}`)):w&&jsx(H,{name:m.lastOfParts?n.confirm.lastTransfer:n.confirm.transaction,children:jsx(HashLink,{hash:w,explorerUrl:D,variant:"compact",...p?.hashLink})}),m.fromAddress&&jsx(H,{name:n.confirm.from,children:jsx(HashLink,{hash:m.fromAddress,explorerUrl:m.fromUrl,variant:"compact",...p?.hashLink})})]}),k&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.paid.refunded,{amount:k,currency:t.invoice.currency})}),a.receiptUrl&&jsx($n,{className:"novapay:max-w-sm",children:jsxs("div",{className:"novapay:flex novapay:w-full novapay:items-center novapay:gap-3 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-left",children:[jsx(ar,{"aria-hidden":true,className:"novapay:h-6 novapay:w-6 novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:n.paid.receipt}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.paid.receiptHint})]}),jsxs("a",{href:a.receiptUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1(nn,"novapay:gap-1.5 novapay:no-underline"),children:[jsx(sr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),n.paid.download]})]})})]}),jsx(Z,{children:v?jsxs(Fragment$1,{children:[jsx("a",{href:v,className:cn$1(Tt,x,Y(e,"primaryButton")),children:jsx(ge,{label:h.label,values:{merchant:f}})}),d.left!==null&&jsxs($e,{children:[jsx("span",{role:"timer","aria-live":"off",children:c(n.paid.returning,{merchant:f,seconds:d.left})})," ","\xB7 ",jsx(ht,{onClick:d.stay,children:n.paid.stay})]})]}):s&&jsx(X,{onClick:s,className:x,children:h.label})})]})}function La({payee:e}){let{labels:t,checkout:a,state:n,backToMethods:o}=I();if(e.status==="checking")return jsxs("div",{role:"status",className:cn$1("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)]","novapay-payee-wait"),children:[jsx(QuasarLoader,{size:40}),t.pay.payeeChecking]});let r=a?.merchant.name??"",s=(n.invoiceStatus??a?.invoice.status)==="underpaid";return jsxs(Fragment$1,{children:[jsx(de,{title:t.pay.payeeRefusedTitle,children:jsx("div",{"data-payee-refusal":e.reason,children:jsx(Q,{children:c(t.pay.payeeRefused,{merchant:r})})})}),jsx(Z,{children:jsx(ae,{onClick:o,children:s?t.pay.backFromRest:t.pay.back})})]})}function xi({state:e,screen:t,now:a,locale:n=null,handlers:o}){let r=e.checkout?.invoice.status??null,{phase:s,error:i}=e,c=e.quote?.expiresAt?Date.parse(e.quote.expiresAt):null,l=c!==null&&a>=c,p=useEffectEvent(()=>o?.onStatusChange?.({phase:s,status:r,screen:t}));useEffect(()=>p(),[s,r]);let m=useEffectEvent(()=>{n&&o?.onLocaleShown?.({locale:n});});useEffect(()=>m(),[n]);let y=useEffectEvent(()=>{i&&o?.onError?.({error:i,screen:t});});useEffect(()=>y(),[i]);let f=useRef({quote:false,invoice:false}),v=useEffectEvent(d=>o?.onExpire?.({kind:d,paymentOnTheWay:ot(e)||ft(e,e.checkout)||qt(e,e.checkout)}));useEffect(()=>{l&&!f.current.quote&&v("quote"),f.current.quote=l;},[l]),useEffect(()=>{let d=r==="expired";d&&!f.current.invoice&&v("invoice"),f.current.invoice=d;},[r]);}var Qt=()=>new Promise(()=>{}),Lu={view:Qt,quote:Qt,buyer:Qt,locale:Qt,submit:Qt,relay:Qt,authorizeRelay:Qt,url:()=>""},Au=createCheckoutStore({token:"idle",api:Lu,EventSource:null});function bi(e){let{token:t,baseUrl:a,api:n,EventSource:o,pollMs:r,enabled:s=true,payee:i}=e,[c,l]=useState(Au),p=useEffectEvent(()=>createCheckoutStore({token:t,baseUrl:a,api:n,EventSource:o,pollMs:r,payee:i})),m=i?.addresses?.join(`
|
|
2
|
+
`)??"";return useEffect(()=>{if(!s)return;let y=p();return l(y),y.getState().load(),()=>y.getState().destroy()},[t,a,s,m]),c}function wi(e,t){return useStore(e,t)}var Du=createStore(()=>({}));function _a(){let e=useContext(SatelliteStoreContext)??Du,t=useStore(e,l=>l.activeConnection),a=useStore(e,l=>l.getConnectors),n=useStore(e,l=>l.watchConnectors),[o,r]=useState(0);useEffect(()=>n?.(()=>r(l=>l+1)),[n]);let s=useMemo(()=>vr(t,a?.()),[t,a,o]),i=s?.name,c=s?.icon;return useMemo(()=>s,[t,i,c])}function Ci(e){let[t,a]=useState({store:e,at:null});return useEffect(()=>e.subscribe((n,o)=>{n.phase!==o.phase&&(n.phase==="confirming"?a({store:e,at:o.phase==="submitting"?Date.now():null}):o.phase==="confirming"&&a({store:e,at:null}));}),[e]),t.store===e?t.at:null}var Si=Symbol.for("tuwaio.nova-payments.context"),Pi=globalThis,Gn=Pi[Si]??(Pi[Si]=createContext({}));function pt(){return useContext(Gn)}function Ni(e,t=true){let[a,n]=useState(()=>Date.now());return useEffect(()=>{if(!t)return;let o=setInterval(()=>n(Date.now()),e);return ()=>clearInterval(o)},[e,t]),a}var bo="nova-payments:sponsoredBatches";var wo=()=>{try{return globalThis.sessionStorage??null}catch{return null}},ko=()=>{try{let e=JSON.parse(wo()?.getItem(bo)??"[]");return Array.isArray(e)?e:[]}catch{return []}},Ti=e=>{try{e.length>0?wo()?.setItem(bo,JSON.stringify(e)):wo()?.removeItem(bo);}catch{}},Fa=e=>Ti(ko().filter(t=>t.invoiceId!==e)),Ri=e=>Ti([...ko().filter(t=>t.invoiceId!==e.invoiceId),e]),Co=e=>ko().find(t=>t.invoiceId===e&&Date.now()-t.at<21e5)??null;function xn(e){let t=e.payeeCheck;return !e.quote||!t||t.quote!==e.quote||t.status==="checking"?{status:"checking"}:t.status==="verified"?{status:"verified"}:{status:"refused",reason:t.reason}}function Ii(e,t){return e.payeeCheck?.quote===t&&e.payeeCheck.status==="verified"}function Ei(e,t){let a=Rt(t.chainId),n=a?e?.find(o=>o.family===a)?.verifyPayoutRecord:void 0;return n?n(t):Promise.resolve(null)}function Li(e,t){return !e||!t?.length||payoutAddressesOf(e)?e:withPayoutAddresses(e,t)}var Ai=e=>new a("unsupported",`${e} is not available`);async function _i({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,onWalletDone:s,onBatchAccepted:i,onSent:c}){if(!Ii(t.getState(),a$1))throw new a("unsupported","The payee of the quote is not verified");let l=n.address;if(o==="relay"){let m=a$1.gasless?.relay?.typedData;if(!m||!e.signTransferAuthorization)throw Ai("A gasless signature");let y=await e.signTransferAuthorization({typedData:m,account:l});s?.();let{relayFromPage:f,relay:v}=t.getState(),d=e.sendOneTimeRelay;return f&&d&&r?f(y,R=>d({chainId:R.chainId,call:R.call,paymasterUrl:r})):v(y)}if(o==="paymaster"){let m=a$1.gasless?.paymaster?.calls;if(!m||!r||!e.sendSponsoredCalls)throw Ai("A sponsored payment");let y=he(a$1.instructions),f=await e.sendSponsoredCalls({calls:m,paymasterUrl:r,chainId:y,account:l,onSent:s,onAccepted:i,onLate:v=>{c?.(v),t.getState().submit({txKey:v,connectorType:n.connectorType,methodId:a$1.methodId});}});return s?.(),c?.(f),t.getState().submit({txKey:f,connectorType:n.connectorType,methodId:a$1.methodId})}let p=await e.sendTransfer({instructions:a$1.instructions,account:l,connection:n.connection});return s?.(),c?.(p),t.getState().submit({txKey:p,connectorType:n.connectorType,methodId:a$1.methodId})}var Ma=6e5;var Ft=new WeakMap;function Oa(e){let t=Ft.get(e);return !!(t?.accepted&&Date.now()<t.until)}function Mi({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,invoiceId:s,onSent:i}){let[c,l]=useState("idle"),[p,m]=useState(()=>{let g=Ft.get(t),k=g?.unconfirmed&&g.account===n?.address&&Date.now()<g.until,N=s?Co(s):null;return k||N?"sentUnconfirmed":null}),y=useEffectEvent(g=>i?.(g));useEffect(()=>{if(!s||Ft.has(t))return;let g=Co(s);if(!g)return;let k=Promise.reject(new a("sentUnconfirmed","The sponsored payment is not confirmed yet"));k.catch(()=>{});let N=g.at+21e5;Ft.set(t,{account:g.account,path:"paymaster",paying:k,until:N,unconfirmed:true,instructions:g.instructions,accepted:true}),e?.followSponsoredCalls?.({batchId:g.batchId,until:N,onLate:b=>{Fa(s),y({txKey:b,instructions:g.instructions,account:g.account,connectorType:g.connectorType}),t.getState().submit({txKey:b,connectorType:g.connectorType,methodId:g.methodId});}});},[s,e,t]);let f=useRef(0),[v,d]=useState(null),[R,h]=useState(null),x=async(g,k)=>{let N=++f.current,b=()=>f.current===N;m(null),l(g);try{await k(b);}catch(L){b()&&m(b$1(L));}finally{b()&&l("idle");}};return {status:c,problem:p,askedWallet:v,askedInstructions:R,pay:()=>x("wallet",async g=>{if(!e||!a$1||!n)return m("unsupported");d(n);let k=Ft.get(t),N=k?.path==="relay"&&o==="relay";if(k?.account===n.address&&!N&&Date.now()<k.until){h(k.instructions),await k.paying;return}h(a$1.instructions);let b={account:n.address,path:o,paying:Promise.resolve(),until:Date.now()+6e5,unconfirmed:!1,instructions:a$1.instructions,accepted:!1};Ft.set(t,b);let L=_i({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,onWalletDone:()=>{o==="paymaster"&&(b.accepted=!0),g()&&l("submitting");},onBatchAccepted:_=>{s&&Ri({invoiceId:s,batchId:_,account:n.address,instructions:a$1.instructions,connectorType:n.connectorType,methodId:a$1.methodId,at:Date.now()});},onSent:_=>{s&&Fa(s),i?.({txKey:_,instructions:a$1.instructions,account:n.address,connectorType:n.connectorType});}});b.paying=L;let B=()=>{Ft.get(t)===b&&Ft.delete(t),s&&Fa(s);};L.then(B,_=>{if(b$1(_)!=="sentUnconfirmed")return B();b.unconfirmed=!0,b.until=Date.now()+21e5;}),await L;}),switchNetwork:()=>x("switching",async()=>{if(!e?.switchChain||!a$1)return m("unsupported");await e.switchChain(he(a$1.instructions));}),dismiss:()=>{f.current++,l("idle");}}}var Yu=100,Zu=300,Bi=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e;async function Oi({adapter:e,pulsar:t,payment:a,labels:n,merchant:o,invoice:r,amount:s}){if(!t||!e?.pulsarTransaction)return false;let i=r.number?c(n.pay.txDescription,{amount:s,invoice:r.number}):s,c$1=e.pulsarTransaction({...a,title:Bi(c(n.pay.txTitle,{merchant:o}),Yu),description:Bi(i,Zu),payload:{quasarInvoice:r.id}});return await t.injectExternalPendingTxs([c$1]),true}var Xu=new Set(["open","processing","underpaid"]),qi=new WeakMap,So=e=>{let t=qi.get(e);return t||qi.set(e,t={keys:new Set,sentHere:false}),t},em=e=>e.split(":").at(-1)??e;function Ui({store:e,adapterFor:t,pulsar:a,labels:n,locale:o}){let r=useRef({adapterFor:t,pulsar:a,labels:n,locale:o});useEffect(()=>{r.current={adapterFor:t,pulsar:a,labels:n,locale:o};});let s=useCallback(i=>{let{checkout:c}=e.getState(),{adapterFor:l,pulsar:p,labels:m,locale:y}=r.current,f=So(e);if(!c||!p||f.keys.has(i.txKey))return;f.keys.add(i.txKey);let{amount:v,decimals:d,symbol:R}=i.instructions;Oi({adapter:l(i.instructions.family),pulsar:p,payment:i,labels:m,merchant:c.merchant.name,invoice:{id:c.invoice.id,number:c.invoice.number},amount:`${pe(v,d,y)} ${R}`}).catch(()=>{});},[e]);return useEffect(()=>e.subscribe((i,c)=>{let{txHash:l,quote:p,checkout:m}=i;if(!l||l===c.txHash||!p||!m||!Xu.has(c.invoiceStatus)||So(e).sentHere)return;let y=m.invoice.originWallet??p.payer;s({txKey:l,instructions:p.instructions,account:y?em(y):"",connectorType:""});}),[e,s]),useCallback(i=>{So(e).sentHere=true,s(i);},[e,s])}function $i({store:e,state:t,walletTxKey:a=null}){let[n,o]=useState(null),[r,s]=useState(null),i=a!==null&&a!==r;i&&s(a);let c=t.phase,l=i||ot(t)||ft(t,t.checkout)||qt(t,t.checkout)||c==="confirming"||c==="unconfirmed",p=n?.store===e?n:null,m=l?p&&p.error===t.error?p:{store:e,error:t.error}:p&&Ir(t.error)&&t.error!==p.error?null:n;return m!==n&&o(m),m?.store===e}function zn(e){let{labels:t,customization:a}=pt(),n=a?.labels?.transform,[o,r]=useState(()=>h(e)),s=g(e);s&&o!==h(e)&&r(h(e));let i$1=s?h(e):o;return useEffect(()=>{if(g(e))return;let c=true;return i(e).then(l=>c&&r(l)),()=>{c=false;}},[e]),useMemo(()=>{let c=j(i$1,t);return n?n(c,{locale:e}):c},[i$1,e,t,n])}function Ki({store:e,screen:t}){let[a,n]=useState(null),o=t==="qr";return o&&a!==e&&n(e),o||a===e}function Da(e){let t=useContext(NovaConnectProviderContext),a=pt(),n=e??a.onConnectWallet;return {canConnect:!!(t||n),connecting:t?.isConnectModalOpen??false,connect:o=>t?(t.setIsConnectModalOpen(true,{adapter:o==="solana"?OrbitAdapter.SOLANA:OrbitAdapter.EVM}),true):n?(n(o),true):false}}function Gi({box:e,content:t,isNarrow:a,isActive:n,duration:o=300}){if(typeof ResizeObserver>"u")return ()=>{};let r,s,i=0,c=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,l=()=>{s=void 0,e.style.removeProperty("overflow");},p=()=>{let f=s;l(),f?.cancel();},m=()=>{let f=t.offsetHeight,v=r;if(r=f,v===void 0||v===f)return;if(s){s.effect?.setKeyframes?.([{height:`${i}px`},{height:`${f}px`}]);return}if(!a()||!n()||c()||typeof e.animate!="function"||Math.abs(f-v)<12)return;i=v,e.style.overflow="clip";let R=e.animate([{height:`${v}px`},{height:`${f}px`}],{duration:o,easing:"cubic-bezier(0.2, 0, 0, 1)"});s=R;let h=()=>{s===R&&l();};R.onfinish=h,R.oncancel=h;},y=new ResizeObserver(m);return y.observe(t),m(),()=>{y.disconnect(),p();}}function ji({active:e,children:t}){let a=useRef(null),n=useRef(null),o=useRef(e);return useEffect(()=>{o.current=e;},[e]),useEffect(()=>{if(!a.current||!n.current||typeof window>"u"||!window.matchMedia)return;let r=window.matchMedia("(max-width: 639.98px)");return Gi({box:a.current,content:n.current,isNarrow:()=>r.matches,isActive:()=>o.current})},[]),jsx("div",{ref:a,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:jsx("div",{ref:n,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:t})})}function gn(e,t){let[a,n]=useState(null),o=useEffectEvent(t);return useEffect(()=>{if(e===null)return;let r=true,s;try{s=Promise.resolve(o());}catch(i){s=Promise.reject(i);}return s.then(i=>r&&n({key:e,value:i}),()=>r&&n({key:e,value:null})),()=>{r=false;}},[e]),a&&a.key===e?a.value:void 0}function Wa(e,t,a){let[n,o]=useState(0),[r,s]=useState(null),i=useEffectEvent(t);return useEffect(()=>{if(e===null||typeof window>"u")return;let c=()=>{document.visibilityState!=="hidden"&&o(m=>m+1);},l=window,p=document;return l.addEventListener("focus",c),p.addEventListener("visibilitychange",c),()=>{l.removeEventListener("focus",c),p.removeEventListener("visibilitychange",c);}},[e]),useEffect(()=>{if(e===null)return;let c=true,l;try{l=Promise.resolve(i());}catch(p){l=Promise.reject(p);}return l.then(p=>c&&s({key:e,value:p}),()=>c&&s({key:e,value:null})),()=>{c=false;}},[e,n,a]),r&&r.key===e?r.value:void 0}var im=e=>e.charAt(0).toUpperCase()+e.slice(1);function Zi(e,t,a){let n=e.startsWith("solana:")?getSolanaCluster(e):void 0;if(!n||n==="mainnet")return null;let o={network:ve(e),cluster:im(n),wallet:t?.name??""},r=t?.family!=="solana"?void 0:t.walletId==="phantom"?a.pay.solanaHintPhantom:t.walletId==="solflare"?a.pay.solanaHintSolflare:a.pay.solanaHintOther;return {title:c(a.pay.solanaNetwork,o),text:c(a.pay.solanaNetworkText,o),...r?{hint:c(r,o)}:{}}}function Ji(e,t){let a=e.startsWith("solana:")?getSolanaCluster(e):void 0;return !a||t?.family!=="solana"||getSolanaCluster(t.chainId)===a?null:e}function Xi(e,t){let a=useContext(SatelliteStoreContext),n=Ji(e,t);useEffect(()=>{n&&a?.getState().switchNetwork?.(n);},[a,n]);}function um(e,t){return e>=1?ye(e,t):new Intl.NumberFormat(t,{maximumSignificantDigits:6}).format(e)}function mm(e,t,a,n){let o=n?.code;if(a==="declined")return c(e.pay.declined,t);if(a==="unsupported")return c(e.pay.unsupported,t);if(a==="wrongNetwork")return c(e.pay.wrongCluster,t);if(a==="switchFailed")return c(e.pay.switchFailed,t);if(a==="notAuthorized")return c(e.pay.notAuthorized,t);if(a==="alreadyPending")return c(e.walletPrompt.stillWaiting,t);if(a==="sentUnconfirmed")return c(e.pay.sentUnconfirmed,t);let r=a?null:Ut(n,e,t.merchant);return r!==null?r:a==="failed"?c(e.pay.walletFailed,t):n&&o==="payment_failed"?An(n,e,t.network):o==="screening_unavailable"?e.pay.screeningUnavailable:o==="request_failed"?e.pay.noAnswer:o==="price_unavailable"||o==="price_no_rpc"?e.method.priceUnavailable:o==="rate_limited"?e.method.rateLimited:o==="method_not_found"||o==="amount_out_of_range"||o==="testnet_required"?e.method.methodUnavailable:n&&!yo(n)?e.error.generic:null}var dm=(...e)=>e.reduce((t,a)=>t&&!/[。!?]$/.test(t)?`${t} ${a}`:`${t}${a}`,"");function ym(e,t,a){let{wallet:n,adapterFor:o}=I(),r=t?.instructions.family,s=r?o(r):void 0,i=e.filter(l=>l.id!==t?.methodId&&Ye(l)===r),c=gn(a&&s&&n&&i.length?`${n.address}:${i.map(l=>l.id).join()}`:null,()=>Promise.all(i.map(l=>s.getBalance({chainId:l.chainId,account:n.address,token:xr(l)}).catch(()=>0n))));return c?i.map((l,p)=>({method:l,balance:c[p]})).filter(l=>l.balance>0n):[]}function nc(){let{checkout:e,state:t,store:a,labels:n,locale:o,now:r,wallet:s,adapterFor:i,connectWallet:c$1,backToMethods:l,onPaymentSent:p,customization:m,lockPrice:y,display:f}=I(),v=m.config?.balanceCheck!==false,d=t.quote,R=e?.methods??[],h=R.find(We=>We.id===d?.methodId),x=d?.instructions.family??"eip155",g=i(x),k=d?he(d.instructions):"",N=s?.address??"",[b,L]=useState(false),B=gn(d?.gasless?.paymaster&&g?.canSponsorCalls&&s?`${k}:${N}`:null,()=>g.canSponsorCalls({chainId:k,account:N})),_=d?qr(d,{withGas:b,canSponsorCalls:B===true}):"transfer",w=Wa(v&&d&&g&&s?`${k}:${N}:${d.instructions.token}`:null,()=>g.getBalance({chainId:k,account:N,token:d.instructions.token}),d?.expiresAt),D=gn(d&&_==="transfer"&&g?.estimateFee&&s?`${k}:${N}:${d.amountToSend}`:null,()=>g.estimateFee({instructions:d.instructions,account:N})),E=Mi({adapter:g,store:a,quote:d,wallet:s,path:_,paymasterUrl:t.paymasterUrl,invoiceId:e?.invoice.id,onSent:p}),C=Pa({adapter:g,store:a,wallet:s,chainId:k});Xi(k,s);let ie=d?.instructions.token==="native",P=d&&typeof w=="bigint"?$r(w,d,ie&&D?D.amount:0n):null,W=(t.invoiceStatus??e?.invoice.status)==="underpaid",z=ym(R,d,v&&!!P&&!W),[Se,Ne]=useState(false),we=C.step==="switching"||C.step==="signing"||E.status==="switching"||E.status==="submitting"||E.status==="wallet"||t.phase==="submitting",[re,ke]=Na(we);if(e&&d&&!h)return jsxs(Fragment$1,{children:[jsx(de,{title:n.method.methodUnavailable,children:null}),jsx(Z,{children:jsx(ae,{onClick:l,children:n.pay.back})})]});if(!e||!d||!h)return null;let A=xn(t);if(A.status!=="verified"&&t.phase!=="submitting"&&E.status==="idle")return jsx(La,{payee:A});let F=e.merchant.name,U=ve(k),ne=We=>`${pe(We,d.decimals,o)} ${d.instructions.symbol}`,le=Ur(d),se=E.askedInstructions,Me=se&&se.amount!==d.instructions.amount?`${pe(se.amount,se.decimals,o)} ${se.symbol}`:ne(le.send),De=d.expiresAt?Date.parse(d.expiresAt)-r:Number.POSITIVE_INFINITY,Be=De<=0,Yt=Pr(De),Qe=t.phase==="quoting",Yn=e.invoice.amountPaid?null:Hr(d,e.invoice.totalMinor),ut=(t.invoiceStatus??e.invoice.status)==="underpaid",Cn=f==="page",Zn=D?ha(String(D.amount),D.decimals,o):null,Mt=ut?rn(d,r,n,F,o):null,Zt=e.invoice.totalMinor?ye(Re(e.invoice.totalMinor),o):null,Sn=!!(s&&d.payer&&Ue(s,h)===d.payer),kt=x==="eip155"&&s&&s.chainId!==k&&!!g?.switchChain,Jn=E.status!=="idle"||t.phase==="submitting"||Qe||C.step!=="idle",Ve=Zi(k,s,n),Jt=()=>{a.getState().requestQuote();},Ka=t.payerProof,Bt=Us(Ka,_),Pn=Bt?Ra(Dn(t.error)?t.error:null,C.problem,n,{wallet:s?.name??"",network:U,merchant:F}):null,Ot=t.phase==="awaitingPayment"&&!(Bt&&Dn(t.error))?t.error:void 0,Nn=mm(n,{wallet:s?.name??"",network:U,merchant:F},E.problem,Ot),Xn=!E.problem&&(Ot?.code==="payment_failed"||Ot?.code==="payment_mismatch"),Tn=()=>{c$1(h)||Ne(true);},Ee;Be?Ee={label:ut?n.outcome.payRest:n.pay.newPrice,run:Jt}:Sn?kt?Ee={label:jsx(ge,{label:n.pay.switchTo,values:{network:U}}),run:()=>{E.switchNetwork();}}:Bt?Ee={label:n.payerProof.confirmToPay,run:()=>{C.confirm();}}:Ee={label:Xn?n.pay.payAgain:jsx(ge,{label:_==="transfer"?n.pay.payAmount:n.pay.signToPay,values:{amount:ne(le.send)}}),run:()=>{m.handlers?.onSubmit?m.handlers.onSubmit({quote:d,method:h,proceed:E.pay}):E.pay();},disabled:!!P||E.problem==="sentUnconfirmed"}:Ee={label:n.pay.connect,run:Tn};let mt=C.step==="switching"?"switch":C.step==="signing"?"proof":E.status==="switching"?"switch":E.status==="submitting"||t.phase==="submitting"?"submitting":E.status==="wallet"?_==="transfer"?"confirm":"sign":null,ea=e.invoice.number??e.invoice.id,tt=s??E.askedWallet,ta={wallet:tt?.name??"",invoice:ea,merchant:F};return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:re,inert:we,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",we&&"novapay:hidden"),children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-3 novapay:px-5 novapay:py-4",Cn&&"novapay-page-screen novapay-page-pay"),children:[jsx("h2",{...Nt,className:"novapay:sr-only",children:n.pay.title}),s&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:h-7 novapay:w-7 novapay:shrink-0",children:jsx(Fn,{walletId:s.walletId,icon:s.icon})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:s.name}),jsx("span",{className:cn$1($,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(s.address),network:ve(s.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:Tn,className:nn,children:n.pay.change})]}),kt&&Sn&&!Be&&jsxs("div",{role:"status",className:cn$1(ia,"novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(yt,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsxs("span",{children:[jsx("strong",{className:"novapay:block",children:n.pay.wrongNetwork}),c(n.pay.wrongNetworkText,{current:ve(s.chainId),network:U})," ",n.pay.switchHint]})]}),Ve&&!Be&&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(or,{"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:cn$1(Oe,"novapay:block"),children:ut?n.pay.youSendRest:n.pay.youSend}),jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:gap-2",Cn&&"novapay-page-amount-row"),children:[jsx("span",{className:cn$1($,"novapay:text-[28px] novapay:font-bold novapay:leading-tight",Cn&&"novapay-page-amount"),children:pe(le.send,d.decimals,o)}),jsx("span",{className:cn$1($,"novapay:text-sm novapay:font-semibold"),children:d.instructions.symbol}),jsx(Mn,{text:xa(le.send,d.decimals),label:n.pay.copyAmount,copiedLabel:n.pay.copied})]}),jsxs("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[c(n.pay.onNetwork,{network:U}),Zt&&!le.fee&&!ut&&jsxs(Fragment$1,{children:[" \xB7 ",c(n.pay.fiatValue,{amount:Zt,currency:e.invoice.currency})]})]})]}),le.fee&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsxs(xe,{children:[jsx(H,{name:ut?n.pay.invoiceRest:n.pay.invoiceTotal,children:pe(le.receives,d.decimals,o)}),jsx(H,{name:c(n.pay.transferFee,{percent:le.fee.percent}),children:pe(le.fee.amount,d.decimals,o)}),jsx(H,{name:c(n.pay.merchantReceives,{merchant:F}),children:ne(le.receives)})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.pay.transferFeeNote})]}),!Be&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2 novapay:text-xs",children:[jsx(on,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:text-[var(--tuwa-text-secondary)]"}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:flex-1",children:c(Mt?n.pay.restTimeLeft:n.pay.priceLocked,{time:st(De)})}),!ut&&jsx(ht,{disabled:Qe,onClick:Jt,children:n.pay.refreshPrice})]}),Yt&&!Mt&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-text-accent)] novapay:px-3 novapay:py-2",children:[jsx("span",{"aria-hidden":true,className:"novapay:text-xs",children:c(n.pay.priceEnding,{time:st(De)})}),jsx("span",{role:"status",className:"novapay:sr-only",children:c(n.pay.priceEnding,{time:st(to)})}),jsx("button",{type:"button",onClick:Jt,disabled:Qe,className:Xo,children:jsx(ge,{label:n.pay.keepPrice,values:{minutes:Math.round(e.quoteTtlSeconds/60)}})})]}),Be&&jsx(Q,{children:n.pay.priceExpired}),Mt&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:Mt}),P&&!Be&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-xs",children:[jsxs("div",{role:"alert",children:[jsx("strong",{className:"novapay:block",children:n.pay.notEnough}),c(n.pay.walletHas,{amount:ne(P.have),network:U}),"."," ",c(n.pay.shortBy,{short:ne(P.short),need:ne(P.need)})]}),z.length>0&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:n.pay.payFromBalance}),z.map(({method:We,balance:Va})=>jsxs("button",{type:"button",onClick:()=>{let na=s?Ue(s,We):null;a.getState().selectMethod(We.id),a.getState().setPayer(na),y();},className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-transparent novapay:px-2.5 novapay:py-1.5 novapay:text-left novapay:text-xs novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-bg-muted)]",ce),children:[jsxs("span",{className:"novapay:font-semibold",children:[We.symbol," \xB7 ",ve(We.chainId)]}),jsx("span",{className:cn$1($,"novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.youHave,{amount:`${pe(String(Va),We.decimals,o)} ${We.symbol}`})})]},We.id))]}),e.merchant.fundingUrl&&jsxs("span",{children:[c(n.pay.topUp,{symbol:d.instructions.symbol})," ",jsxs("a",{href:e.merchant.fundingUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:[c(n.pay.getToken,{symbol:d.instructions.symbol})," \u2197"]})]})]}),jsxs(xe,{children:[Yn!==null&&jsx(H,{name:n.pay.rate,children:c(n.pay.rateValue,{symbol:d.instructions.symbol,price:um(Yn,o),currency:e.invoice.currency})}),jsx(H,{name:n.pay.networkFee,children:jsxs("span",{className:"novapay:inline-flex novapay:flex-col novapay:items-end novapay:gap-0.5",children:[_!=="transfer"?jsx("span",{className:"novapay:text-[var(--tuwa-success-text)]",children:c(n.pay.merchantPaysGas,{merchant:F})}):Zn?c(n.pay.gasEstimate,{amount:`${Zn} ${D?.symbol}`}):n.pay.gasFromWallet,d.gasless&&jsx(ht,{onClick:()=>L(!b),children:b?c(n.pay.payGasless,{merchant:F}):n.pay.payWithGas})]})}),jsxs(H,{name:n.pay.to,children:[jsx(He,{hash:d.instructions.to,chainId:k}),jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:F})]})]}),Bt&&!Be&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.payNote}),Pn&&jsx(Q,{children:Pn}),Nn&&jsx(Q,{children:Nn}),!E.problem&&jsx(ya,{error:Ot}),Se&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(Z,{children:[jsx(X,{busy:Jn,disabled:Ee.disabled,onClick:Ee.run,children:Ee.label}),jsx(ae,{disabled:Qe,onClick:l,children:ut?n.pay.backFromRest:n.pay.back}),jsx($e,{children:dm(c(n.pay.disclaimer,{merchant:F}),...Nr(e)?[c(n.pay.disclaimerScreening,{merchant:F})]:[])})]})]}),mt==="proof"&&jsx(qn,{kind:"proof",walletName:tt?.name??"",walletId:tt?.walletId??"",walletIcon:tt?.icon,amount:Me,merchant:F,network:U,to:shortAddress(d.instructions.to),priceTime:null,text:c(Ta(s)?n.payerProof.promptPasskey:n.payerProof.promptText,ta),details:[...C.request?[{name:n.payerProof.site,value:C.request.domain}]:[],{name:n.payerProof.invoice,value:ea},{name:n.payerProof.merchant,value:F}],hint:C.request?c(n.payerProof.signInRequest,{wallet:tt?.name??"",site:C.request.domain}):void 0,onRetry:()=>{C.confirm();},onCancel:C.dismiss,stepHeight:ke}),mt&&mt!=="proof"&&jsx(qn,{kind:mt,walletName:tt?.name??"",walletId:tt?.walletId??"",walletIcon:tt?.icon,amount:Me,merchant:F,network:U,to:shortAddress(d.instructions.to),priceTime:Be?null:st(De),onRetry:_==="relay"?()=>{E.pay();}:void 0,onCancel:C.step==="switching"?C.dismiss:E.dismiss,stepHeight:ke})]})}var Io=4;function ac(e){let{size:t,data:a}=encode(e,{ecc:"M",border:0}),n="";return a.forEach((o,r)=>o.forEach((s,i)=>{s&&(n+=`M${i+Io} ${r+Io}h1v1h-1z`);})),{size:t+Io*2,path:n}}function Lo({value:e,label:t,className:a}){let n=I(),o=cn$1(a,Y(n,"qrCode")),{size:r,path:s}=useMemo(()=>ac(e),[e]),i=n.customization.components?.QrCode;return i?jsx(i,{value:e,label:t,className:o}):jsxs("svg",{role:"img","aria-label":t,viewBox:`0 0 ${r} ${r}`,shapeRendering:"crispEdges",className:cn$1("novapay:block novapay:rounded-[var(--tuwa-rounded-corners)]",o),children:[jsx("rect",{width:r,height:r,fill:"#ffffff"}),jsx("path",{d:s,fill:"#111827"})]})}function gm({payUrl:e}){let{labels:t,backToMethods:a,display:n}=I();return jsxs(Fragment$1,{children:[jsx(de,{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(Lo,{value:e,label:t.qr.handoffCode,className:cn$1("novapay:h-48 novapay:w-48",n==="page"&&"novapay-page-qr-handoff")}),jsx(Mn,{text:e,label:t.qr.copyLink,copiedLabel:t.pay.copied,children:t.qr.copyLink}),jsx("p",{className:"novapay:m-0 novapay:max-w-xs novapay:text-center novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:t.qr.handoffNote})]})}),jsx(Z,{children:jsx(ae,{onClick:a,children:t.qr.back})})]})}function rc(){let e=I(),{checkout:t,state:a,store:n,labels:o,locale:r,now:s,payUrl:i,backToMethods:c$1}=e,l=a.quote;if(!t)return null;if(!l||l.instructions.family!=="solana")return i?jsx(gm,{payUrl:i}):null;let p=xn(a);if(p.status!=="verified"&&a.phase!=="submitting")return jsx(La,{payee:p});let{instructions:m}=l,y=ve(he(m)),f=`${pe(l.amountToSend,l.decimals,r)} ${m.symbol}`,v=l.expiresAt?Date.parse(l.expiresAt)-s:Number.POSITIVE_INFINITY,d=v<=0,R=a.phase==="quoting",h=(a.invoiceStatus??t.invoice.status)==="underpaid",x=h?rn(l,s,o,t.merchant.name,r):null,g=h?t.invoice.originWallet:null,k=g?c(o.qr.restHint,{wallet:shortAddress(Et(g))}):o.qr.solanaHint;return jsxs(Fragment$1,{children:[jsxs(de,{title:o.qr.solanaTitle,subtitle:k,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(Lo,{value:m.solanaPayUrl,label:c(o.qr.solanaCode,{amount:f}),className:cn$1("novapay:h-44 novapay:w-44 novapay:shrink-0",e.display==="page"&&"novapay-page-qr",d&&"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})]}),h&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:o.pay.youSendRest}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn$1($,"novapay:text-2xl novapay:font-bold"),children:pe(l.amountToSend,l.decimals,r)}),jsx(Mn,{text:xa(l.amountToSend,l.decimals),label:o.pay.copyAmount,copiedLabel:o.pay.copied})]}),jsxs("div",{"data-qr-line":true,className:cn$1($,"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-x-1 novapay:gap-y-0.5 novapay:text-[var(--tuwa-text-secondary)]"),children:[jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[m.symbol," \xB7"]}),jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[y," \xB7"]}),jsx("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:jsx(He,{hash:m.to,chainId:he(m)})})]}),!d&&jsxs(Fragment$1,{children:[jsxs("span",{role:"status",className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(QuasarLoader,{size:14,accent:"var(--tuwa-pending-icon)"}),o.qr.waiting]}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(x?o.pay.restTimeLeft:o.pay.priceLocked,{time:st(v)})})]})]})]}),d&&jsx(Q,{children:o.pay.priceExpired}),x&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:x}),jsxs("p",{className:cn$1(ia,"novapay:m-0 novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(yt,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),o.qr.exchangeWarning]})]}),jsxs(Z,{children:[d?jsx(X,{busy:R,onClick:()=>{n.getState().requestQuote();},children:h?o.outcome.payRest:o.pay.newPrice}):jsx("a",{href:m.solanaPayUrl,className:cn$1(Tt,Y(e,"primaryButton")),children:o.qr.openInWallet}),jsx(ae,{onClick:c$1,children:h?o.pay.backFromRest:o.qr.back})]})]})}function _o(e){switch(e){case "confirm":return "pending";case "unconfirmed":case "underpaid":return "warning";case "paid":return "success";case "failed":case "blocked":case "error":return "error";case "needs_review":case "refunded":case "expired":case "cancelled":case "replaced":return "neutral";default:return null}}function Rm(){let{labels:e}=I();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 Im(){let{labels:e,state:t,store:a}=I(),n=t.error?.code==="checkout_not_found";return jsxs("div",{role:"alert",className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:p-8 novapay:text-center",children:[jsx(yt,{"aria-hidden":true,className:"novapay:h-7 novapay:w-7 novapay:text-[var(--tuwa-error-icon)]"}),jsx("h2",{...Nt,className:at,children:e.error.title}),jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-[13px] novapay:text-[var(--tuwa-text-secondary)]",children:n?e.error.notFound:e.error.generic}),!n&&jsx(ae,{onClick:()=>{a.getState().load();},className:"novapay:w-auto novapay:px-6",children:e.common.retry})]})}var Em=new Set(["paid","partially_refunded","refunded"]);function ic(){let{screen:e,customization:t}=I(),a=t.components?.screens?.[e];return a?jsx(a,{screen:e}):e==="loading"?jsx(Rm,{}):e==="error"?jsx(Im,{}):e==="buyer"?jsx(Zr,{}):e==="method"?jsx(li,{}):e==="confirmWallet"?jsx(zs,{}):e==="pay"?jsx(nc,{}):e==="qr"?jsx(rc,{}):e==="confirm"?jsx(Ds,{}):e==="failed"?jsx(ti,{}):e==="paid"?jsx(vi,{}):jsx(Xs,{kind:e})}function Lm({className:e,withDetails:t,leave:a}){let n=I(),{checkout:o,locale:r,labels:s,now:i,customization:c$1,display:l}=n,{Header:p=ys,Summary:m=cs,CompactSummary:y=ls}=c$1.components??{},f=c$1.config?.deadlineAnnouncements,{screen:v,state:d}=n,R=useRef(null),h=(v==="pay"||v==="qr"&&d.quote?.instructions.family==="solana")&&d.phase!=="submitting"&&!!d.quote&&xn(d).status==="checking",x=useRef(v);useEffect(()=>{if(h)return;let E=x.current;x.current=v;let C=R.current;if(!C||E===v||E==="loading")return;let ie=C.ownerDocument.activeElement;if(ie&&ie!==C.ownerDocument.body&&!C.contains(ie))return;let P=C.querySelector("[data-novapay-scroll] [data-novapay-heading]");if(l!=="page")return P?.focus();C.getBoundingClientRect().top<0&&C.scrollIntoView({block:"start"}),P?.focus({preventScroll:true});},[v,l,h]);let[g,k]=useState(""),N=useRef(null),b=o?.invoice.dueAt?Date.parse(o.invoice.dueAt):null,L=o?Ln(o.invoice.status,v,o.invoice.restPayable)==="paying":false;useEffect(()=>{if(b===null)return;let E=b-i,C=kr(N.current,E,f);N.current=E,C!==null&&L&&k(C===1?s.summary.oneMinuteLeft:c(s.summary.minutesLeft,{minutes:C}));},[b,i,s,f,L]);let B=l==="page",_=er[B?"page":"default"],w=_o(v),D=c$1.components?.StatusEdge??StatusEdge;return jsxs("div",{ref:R,lang:r,className:cn$1(_.frame,ca(l).frame,e),children:[o&&jsx("aside",{inert:!!a,className:cn$1(_.aside,Y(n,"summary")),children:jsx(m,{})}),jsxs("div",{inert:!!a,className:cn$1("novapay:relative",_.main),children:[w&&jsx(D,{tone:w,className:cn$1("novapay:z-20",Y(n,"statusEdge",{tone:w}))}),jsxs(ji,{active:!!w&&!B&&!c$1.config?.animation?.disabled,children:[jsx(p,{withDetails:t}),jsxs("div",{className:"novapay:sm:hidden",children:[o&&jsx(y,{className:Y(n,"compactSummary")}),jsx(fs,{withDetails:t})]}),jsx("div",{"data-novapay-scroll":"",className:cn$1(_.area,Y(n,"body")),children:B?jsx("div",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",!c$1.config?.animation?.disabled&&"novapay-page-fade"),children:jsx(ic,{})},w?"status":v):jsx(ic,{})})]})]}),jsx("div",{role:"status","aria-live":"polite",className:"novapay:sr-only",children:g}),a&&jsx(oi,{onStay:a.onStay,onLeave:a.onLeave})]})}function Gw({token:e,display:t="modal",open:a=true,onOpenChange:n,onClose:o,baseUrl:r,api:s,EventSource:i,pollMs:c$1,payUrl:l,payoutAddresses:p,onConnectWallet:m,onPaid:y,autoReturnSeconds:f$1,onContact:v,locale:d,className:R,customization:h}){let x=pt(),[g$1,k]=useState({from:e,token:e}),N=g$1.from===e?g$1.token:e,[b,L]=useState(t!=="modal"||a);!b&&(t!=="modal"||a)&&L(true);let B=useRef(x.adapters);useEffect(()=>{B.current=x.adapters;},[x.adapters]);let _=useCallback(te=>Ei(B.current,te),[]),w=bi({token:N,baseUrl:r??x.baseUrl,api:s,EventSource:i,pollMs:c$1,enabled:b,payee:{verify:_,addresses:p}}),D=wi(w,te=>te),E=D.checkout,C=f(d),[ie,P]=useState(null),W=Ar({picked:ie,page:C,invoice:D.locale??E?.invoice.locale}),z=zn(W),Se=!!E&&b&&Dr(D.phase,f$1,g(W)),we=Ni(1e3,Se)-(D.clockSkewMs??0),re=_a(),ke=Da(m),A=x.adapters,[F,U]=useState("wallet"),[ne,le]=useState(false),[se,Me]=useState(null);E&&se?.store!==w&&Me({store:w,paid:Em.has(E.invoice.status)});let[De,Be]=useState(false),[Yt,Qe]=useState(false),[Yn,ut]=useState(N);Yn!==N&&(ut(N),le(false),U("wallet"),Qe(false));let Cn=D.payerProof==="confirmed"&&!!D.error,Zn=D.error?.code==="payer_mismatch";Yt&&(D.phase==="awaitingPayment"||Cn||Zn)&&Qe(false);let Mt=(D.invoiceStatus??E?.invoice.status)==="underpaid"?E?.invoice.originWallet??null:null,Zt=te=>!Mt||sn(te,Mt),Sn=E?.methods.find(te=>te.id===D.methodId),kt=Sn?Ue(re,Sn):null,Jn=Sr({open:Yt,storePayer:D.payer,payer:kt,paysRest:!kt||Zt(kt)});Jn==="leave"&&Qe(false);let Ve=useRef(null),[Jt,Ka]=useState(false);!Jt&&E&&g(W)&&Ka(true);let Bt={payWith:F,handoff:ne,confirmWallet:Yt,labelsReady:Jt||!E},Pn=eo(D,Bt),[Ot,Nn]=useState(null),[Xn,Tn]=useState(null);Pn==="confirm"?Ot!==w&&Nn(w):Ot===w&&(Nn(null),D.error?.code==="payment_failed"&&Tn(D.error));let Ee=Xn!==null&&D.error===Xn?eo(D,{...Bt,afterFailure:true}):Pn,mt=async()=>{await Hs(w,Qe);},ea=Ci(w),tt=Ki({store:w,screen:Ee}),[ta,We]=useState(null),Va=$i({store:w,state:D,walletTxKey:ta?.store===w?ta.txKey:null});di(D.phase,E?.invoice,y,se?.store===w&&se.paid),xi({state:D,screen:Ee,now:we,locale:E||C?W:null,handlers:h?.handlers});let na=te=>A?.find(je=>je.family===te),Oo=Ui({store:w,adapterFor:na,pulsar:x.pulsar,labels:z,locale:W}),Sc=useCallback(te=>{We({store:w,txKey:te.txKey}),Oo(te);},[w,Oo]),Pc=useEffectEvent(()=>{if(!E)return;let{quote:te,phase:je}=w.getState();if(re&&Ve.current){let oa=E.methods.find(Ac=>Ac.id===Ve.current),ja=oa?Ue(re,oa):null;if(!ja)return;Ve.current=null,w.getState().setPayer(ja),Zt(ja)&&mt();return}if(je==="selectMethod"||je==="underpaid"||je==="blocked"){if(D.payer===null||kt===D.payer)return;w.getState().setPayer(kt),Jn==="follow"&&mt();return}if(!re)return;let Rn=E.methods.find(oa=>oa.id===te?.methodId),aa=Rn?Ue(re,Rn):null,Uo=Cr({phase:je,quotePayer:te?.payer,payer:aa});if(Uo==="release")return w.getState().releaseQuote();Uo==="keep"||!aa||(w.getState().setPayer(aa),Zt(aa)&&mt());}),Nc=D.quote?.payer,Tc=!!E;useEffect(()=>Pc(),[re?.address,re?.chainId,re?.connectorType,D.phase,Nc,Tc]),useEffect(()=>{ke.connecting||(Ve.current=null);},[ke.connecting]);let[Do,Rc]=useState(false);Ee==="buyer"&&!Do&&Rc(true);let Ga=useMemo(()=>t==="modal"?()=>{n?.(false),o?.();}:o,[t,n,o]),Ic=Ga&&(()=>ao(w.getState().phase,w.getState().error,w.getState().invoiceStatus)&&!Oa(w)?Be(true):Ga()),Ec=De?{onStay:()=>Be(false),onLeave:()=>{Be(false),w.getState().releaseQuote(),Ga?.();}}:null,Wo=h??{},Lc={store:w,state:D,checkout:E,screen:Ee,locale:W,labels:z,setLocale:async te=>{let je=ie;P({locale:te,page:C}),await w.getState().setLocale(te)||P(je);},now:we,handedOverAt:ea,qrShown:tt,paymentSent:Va||Oa(w),close:Ic,wallet:re,payWith:F,setPayWith:U,payUrl:Li(l,p),connectWallet:te=>{let je=Ye(te);Ve.current=te.id;let Rn=je!==null&&ke.connect(je);return Rn||(Ve.current=null),Rn},connectFamily:te=>ke.connect(te),openedPaid:se?.store===w&&se.paid,adapterFor:na,handoff:ne,setHandoff:le,backToMethods:()=>{le(false),Qe(false),w.getState().releaseQuote();},payAfterFailure:()=>{Tn(null),w.getState().clearError();},confirmWallet:Yt,setConfirmWallet:Qe,lockPrice:mt,onPaymentSent:Sc,openInvoice:te=>k({from:e,token:te}),onContact:v,autoReturnSeconds:f$1??(t==="modal"?0:5),display:t,customization:Wo},za=cn$1(R,Y({customization:Wo,screen:Ee,state:D,checkout:E},"container")),Qa=jsx(Go,{value:Lc,children:jsx(MotionConfig,{reducedMotion:h?.config?.animation?.disabled?"always":"user",children:jsx(Lm,{withDetails:Do,leave:Ec,className:t==="modal"?za:void 0})})});if(t==="modal")return jsx(Dialog,{open:a,onOpenChange:te=>{if(!te&&De)return Be(false);if(!te&&ao(w.getState().phase,w.getState().error,w.getState().invoiceStatus)&&!Oa(w))return Be(true);n?.(te),te||o?.();},children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-auto",animateHeight:_o(Ee)===null,children:[jsx(DialogTitle,{className:"novapay:sr-only",children:c(z.common.dialogTitle,{merchant:E?.merchant.name??""})}),Qa]})});let qo=c(z.common.dialogTitle,{merchant:E?.merchant.name??""});return t==="page"?jsx(Am,{label:qo,className:za,children:Qa}):jsx("section",{"aria-label":qo,className:cn$1("novapay:overflow-hidden novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)]",ca(t).section,za),children:Qa})}function Am({label:e,className:t,children:a}){return jsx("div",{className:"novapay-page",children:jsx("section",{"aria-label":e,className:cn$1(ca("page").section,"novapay-page-block",t),children:a})})}function cc(e){if(!e.to)return null;let t=parseCaip19AssetId(e.assetId),a={to:e.to,token:!t||t.assetNamespace==="slip44"?"native":t.assetReference,amount:e.amount,decimals:e.decimals,symbol:e.symbol},n=Rt(e.chainId);if(n==="solana")return {family:n,chainId:e.chainId,...a,reference:"",solanaPayUrl:""};let o=n==="eip155"?toEvmChainId(e.chainId):void 0;return o===void 0?null:{family:"eip155",chainId:o,...a}}function pc(e){let t=b$1(e);return t==="switchFailed"?"wrongNetwork":t==="notAuthorized"||t==="alreadyPending"||t==="sentUnconfirmed"?"failed":t}var Mo=new WeakMap,wn=new WeakMap;function uc({store:e,invoiceId:t,invoice:a,params:n,open:o,labels:r,locale:s,onConnectWallet:i}){let c$1=useStore(e),{adapters:l,pulsar:p}=pt(),m=_a(),y=Da(i),[f,v]=useState("idle"),[d,R]=useState(null),[,h]=useState(0),x=wn.has(e),g=useRef(0),k=useRef(o),N=c$1.sentTransaction?.txHash??c$1.refund?.txHash??null,b=c$1.instructions?cc(c$1.instructions):null,L=b?.family??null,B=b?he(b):c$1.instructions?.chainId??null,_=l?.find(U=>U.family===L),w=m&&m.family===L?m:null,D=B?ve(B):"",E=d&&d.account===w?.address?d.problem:null,C=U=>R(U?{problem:U,account:w?.address}:null),ie=!!(w&&L==="eip155"&&B&&w.chainId!==B),P=c$1.instructions,W=P?`${pe(P.amount,P.decimals,s)} ${P.symbol}`:"",z=Wa(b&&w&&_?`balance|${B}|${w.address}|${b.token}`:null,()=>_.getBalance({chainId:B,account:w.address,token:b.token}),c$1.refund?.id),Se=gn(b&&w&&_?.estimateFee?`fee|${B}|${w.address}|${b.token}`:null,()=>_.estimateFee({instructions:b,account:w.address}));useEffect(()=>{!n||Mo.get(e)===t||e.getState().phase!=="idle"||(Mo.set(e,t),e.getState().start(t,n));},[n,e,t]),useEffect(()=>{o&&!k.current&&!n&&e.getState().phase==="confirmed"&&e.getState().reset(),k.current=o;},[o,n,e]),useEffect(()=>(e.getState().keepFollowing(),()=>e.getState().stopFollowing()),[e]),useEffect(()=>{let U=true;return wn.get(e)?.settled.then(()=>{U&&h(ne=>ne+1);}),()=>{U=false;}},[e]);let Ne=async(U,ne,le)=>{if(!p||!_?.pulsarTransaction||!c$1.refund)return;let se={invoice:a??t,amount:W};try{await p.injectExternalPendingTxs([_.pulsarTransaction({txKey:U,instructions:le,account:ne.address,connectorType:ne.connectorType,title:c(r.refund.txTitle,se),description:c(c$1.refund.unmatchedTransfer?r.refund.txDescriptionSender:r.refund.txDescription,se),payload:{quasarRefund:c$1.refund.id}})]);}catch{}},we=async()=>{if(C(null),!(!ie||!_?.switchChain))try{v("switching"),await _.switchChain(B);}catch(U){C(pc(U));}finally{v("idle");}},re=async()=>{if(C(null),!b)return C("noRecipient");if(!w||!_)return C("unsupported");if(c$1.sentTransaction){await e.getState().submit(c$1.sentTransaction);return}let U=BigInt(b.amount)+(b.token==="native"&&Se?Se.amount:0n);if(typeof z=="bigint"&&z<U)return C("notEnough");if(L&&b.to&&isSameAddress(L,w.address,b.to))return C("fromBuyer");if(!await e.getState().recheck()){let se=e.getState(),Me=se.error?.code==="refund_repriced";se.phase==="awaitingTransfer"&&!se.sentTransaction&&!Me&&C("unreachable");return}let ne=++g.current,le=()=>g.current===ne;try{ie&&_.switchChain&&(v("switching"),await _.switchChain(B)),le()&&v("wallet");let se=await _.sendTransfer({instructions:b,account:w.address,connection:w.connection});le()?v("idle"):R(null),Ne(se,w,b),await e.getState().submit({txHash:se,from:w.address});}catch(se){le()?(v("idle"),C(pc(se))):R(null);}},ke=async()=>{if(wn.has(e))return;let U,ne={settled:new Promise(Me=>U=Me)},le=()=>{wn.get(e)===ne&&wn.delete(e),U(),h(Me=>Me+1);},se=setTimeout(le,6e5);wn.set(e,ne),h(Me=>Me+1);try{await re();}finally{clearTimeout(se),le();}},A=f!=="idle"?f:w?"confirm":"connect";return {step:c$1.phase==="idle"?n&&!c$1.error&&Mo.get(e)!==t?"requesting":"amount":c$1.phase==="awaitingTransfer"?A:c$1.phase,phase:c$1.phase,refund:c$1.refund,error:c$1.error,transfer:b,chainId:B,network:D,amount:W,wallet:w,wrongNetwork:ie,balance:z,fee:Se,problem:E??(c$1.instructions&&!b?"noRecipient":null),txKey:N,transactionUrl:U=>B?_?.explorerUrl?.({chainId:B,txKey:U}):void 0,addressUrl:U=>B?_?.explorerAddressUrl?.({chainId:B,address:U}):void 0,canConnect:y.canConnect,connecting:y.connecting,preview:async U=>{let ne=await e.getState().preview(t,U);return ne||(e.getState().error?"refused":null)},start:async U=>{C(null),await e.getState().start(t,U);},connect:()=>{L&&y.connect(L);},switchNetwork:we,send:ke,dismiss:()=>{g.current++,v("idle"),C("stillInWallet");},sending:x}}function Sk({label:e,className:t,disabled:a,...n}){let[o,r]=useState(false),s=zn(n.locale??"en");return jsxs(Fragment$1,{children:[jsx("button",{type:"button",disabled:a,onClick:()=>r(true),className:cn$1(Tt,"novapay:w-auto novapay:px-4",t),children:e??s.refund.button}),jsx($m,{...n,open:o,onOpenChange:r})]})}function $m({open:e,onOpenChange:t,locale:a="en",onRefunded:n,...o}){let r=zn(a),s=uc({store:o.store,invoiceId:o.invoiceId,invoice:o.invoice,params:e?o.params:void 0,open:e,labels:r,locale:a,onConnectWallet:o.onConnectWallet}),i=useEffectEvent(p=>n?.(p)),c$1=s.phase==="confirmed"?s.refund:null;useEffect(()=>{c$1&&i(c$1);},[c$1]);let l=o.invoice?c(r.refund.title,{invoice:o.invoice}):r.refund.button;return jsx(Dialog,{open:e,onOpenChange:t,children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-[440px]",children:[jsxs("div",{className:"novapay:flex novapay:items-center novapay:justify-between novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:px-5 novapay:py-3",children:[jsx(DialogTitle,{className:cn$1($,"novapay:m-0 novapay:truncate novapay:text-sm novapay:font-bold"),children:l}),jsx("button",{type:"button","aria-label":r.refund.close,onClick:()=>t(false),className:Pt,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]}),jsx(Km,{flow:s,labels:r,locale:a,close:()=>t(false),...o})]})})}function Km({flow:e,labels:t,locale:a,close:n,currency:o="USD",refundable:r,details:s,onRecord:i}){let c$1=t.refund,l={network:e.network,symbol:e.transfer?.symbol??e.refund?.assetId??"",amount:e.amount,wallet:e.wallet?.name??""},p=e.refund?.txHash??e.txKey,m=i&&jsxs(Fragment$1,{children:[jsx(ae,{onClick:i,children:c$1.record}),jsx($e,{children:c$1.recordHint})]});switch(e.step){case "amount":return jsx(Jm,{flow:e,labels:t,locale:a,currency:o,refundable:r});case "requesting":case "submitting":return jsx(vc,{children:e.step==="requesting"?c$1.requesting:c$1.submitting});case "switching":case "wallet":return jsxs(Fragment$1,{children:[jsxs(vc,{walletId:e.wallet?.walletId,walletIcon:e.wallet?.icon,children:[jsx("strong",{className:cn$1($,"novapay:text-sm"),children:c(e.step==="switching"?c$1.switchTitle:c$1.walletTitle,l)}),e.step==="wallet"&&jsx("span",{children:c(c$1.walletText,l)})]}),jsx(Z,{children:jsx(ae,{onClick:e.dismiss,children:t.walletPrompt.cancel})})]});case "connect":return jsxs(Fragment$1,{children:[jsxs(de,{title:c$1.connectTitle,subtitle:c(c$1.connectText,l),children:[e.problem==="noRecipient"&&jsx(Q,{children:c$1.noRecipient}),!e.canConnect&&jsx(Q,{children:c$1.connectUnavailable})]}),jsxs(Z,{children:[e.canConnect&&e.problem!=="noRecipient"&&jsx(X,{busy:e.connecting,onClick:e.connect,children:c$1.connect}),m]})]});case "confirm":return jsx(Xm,{flow:e,labels:t,locale:a,values:l,details:s?.confirm,recordAction:m});case "confirming":return jsxs(Fragment$1,{children:[jsxs(de,{title:c$1.onItsWay,children:[jsxs(xe,{children:[jsx(H,{name:c$1.status,children:c$1.pending}),p&&jsx(H,{name:c$1.transaction,children:jsx(He,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),jsx(H,{name:c$1.network,children:c(c$1.waiting,l)})]}),fc(e.refund)&&jsx($e,{children:c$1.slowNote})]}),jsxs(Z,{children:[jsx(ae,{onClick:n,children:c$1.close}),fc(e.refund)?m:jsx($e,{children:c$1.canClose})]})]});case "confirmed":return jsxs(Fragment$1,{children:[jsx(de,{title:c$1.refunded,children:jsxs(xe,{children:[e.refund?.creditNoteNumber&&jsx(H,{name:c$1.creditNote,children:e.refund.creditNoteNumber}),p&&jsx(H,{name:c$1.transaction,children:jsx(He,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),s?.done]})}),jsx(Z,{children:jsx(X,{onClick:n,children:c$1.done})})]});case "failed":return jsx(Zm,{flow:e,labels:t,locale:a,values:l,recordAction:m,close:n})}}var Vm={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"},dc=(e,t,a)=>{let n=e?.failureReason?Vm[e.failureReason]:void 0;return n?t[n]:c(t.failedText,a)},Gm={withdrawn:"failedWithdrawnTitle",cancelled:"failedCancelledTitle",cancelled_final:"failedCancelledTitle"},yc=(e,t)=>t[e?.failureReason&&Gm[e.failureReason]||"failedTitle"],zm={refund_repriced:"movedTitle",request_failed:"unreachable",amount_exceeds_refundable:"refusedAmount",invoice_not_refundable:"refusedNotRefundable",payment_unknown:"refusedNotRefundable",unmatched_transfer_not_refundable:"refusedNotRefundable",review_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"},Qm=600*1e3,fc=e=>{let t=e?.updatedAt??e?.createdAt;return !!t&&Date.now()-Date.parse(t)>Qm},Ha=(e,t)=>e.text??t[zm[e.code]??"refusedOther"],jm=e=>e?.failureReason==="over_limit"||e?.failureReason==="tx_of_another_refund",Ym=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 gc(e){let[t,a]=useState(false),[n,o]=useState(null),r=useRef(false);return useEffect(()=>(r.current=false,()=>{r.current=true;}),[]),{ask:async(i,c)=>{if(i?.mode==="fiat_value"){a(true);let l=await e.preview(i);if(r.current||(a(false),l==="refused"))return;if(l&&Or(c?{cryptoAmount:l.cryptoAmount,atPaymentRate:c.cryptoAmount}:l))return o({preview:l,request:i})}o(null),e.start(i);},checking:t,moved:n,back:()=>o(null)}}function bc({preview:e,request:t},a,n,o,r,s){let i=o.refund,c$1=l=>`${pe(l,e.decimals,r)} ${e.symbol}`;return jsxs(Fragment$1,{children:[jsxs(de,{title:i.movedTitle,children:[jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(i.movedText,{symbol:e.symbol})}),jsxs(xe,{children:[jsx(H,{name:i.movedSend,children:c$1(e.cryptoAmount)}),e.atPaymentRate&&jsx(H,{name:i.movedAtPayment,children:c$1(e.atPaymentRate)}),e.received&&jsx(H,{name:i.movedReceived,children:c$1(e.received)})]}),s&&e.exactPossible&&jsx($e,{children:c(i.movedExact,{exact:i.modeExact})}),n.error&&jsx(Q,{children:Ha(n.error,i)})]}),jsxs(Z,{children:[jsx(X,{busy:a.checking,onClick:()=>{a.ask(t,e);},children:i.movedContinue}),jsx(ae,{disabled:a.checking,onClick:a.back,children:i.movedBack})]})]})}function Zm({flow:e,labels:t,locale:a,values:n,recordAction:o,close:r}){let s=t.refund,i=gc(e);return e.refund?.unmatchedTransfer?jsxs(Fragment$1,{children:[jsxs(de,{title:yc(e.refund,s),children:[jsx(Q,{children:dc(e.refund,s,n)}),jsx($e,{children:s.failedUnmatchedNote})]}),jsx(Z,{children:jsx(X,{onClick:r,children:s.close})})]}):i.moved?bc(i.moved,i,e,t,a,false):jsxs(Fragment$1,{children:[jsxs(de,{title:yc(e.refund,s),children:[jsx(Q,{children:dc(e.refund,s,n)}),e.error&&jsx(Q,{children:Ha(e.error,s)})]}),jsxs(Z,{children:[jm(e.refund)?jsx(X,{onClick:r,children:s.close}):jsx(X,{busy:i.checking,onClick:()=>e.refund&&void i.ask(Ym(e.refund)),children:s.sendRefund}),o]})]})}function vc({walletId:e,walletIcon:t,children:a}){return jsxs("section",{role:"status",className:"novapay:flex novapay:min-h-56 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:px-5 novapay:py-6 novapay:text-center",children:[jsx(ma,{walletId:e,walletIcon:t}),a]})}function Jm({flow:e,labels:t,locale:a,currency:n,refundable:o}){let r=t.refund,s=useId(),i=useId(),[c$1,l]=useState("fiat_value"),[p,m]=useState(""),[y,f]=useState(""),v=gc(e),d=c$1==="exact_received"||p.trim()===""||/^\d{1,12}(\.\d{1,2})?$/.test(p.trim()),R=[{key:"fiat_value",title:r.modeFiat,hint:c(r.modeFiatText,{currency:n})},{key:"exact_received",title:r.modeExact,hint:r.modeExactText}],h="novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-sm novapay:text-[var(--tuwa-text-primary)]",x={mode:c$1,...c$1==="fiat_value"&&p.trim()&&{amount:p.trim()},...y.trim()&&{reason:y.trim()}};return v.moved?bc(v.moved,v,e,t,a,true):jsxs(Fragment$1,{children:[jsxs(de,{title:r.amountTitle,children:[jsxs("fieldset",{disabled:v.checking,className:"novapay:contents",children:[jsx(vn,{label:r.amountTitle,items:[...R],value:c$1,getKey:g=>g.key,onChange:g=>l(g),className:"novapay:flex novapay:flex-col novapay:gap-2",itemClassName:()=>"novapay:flex novapay:flex-col novapay:gap-0.5 novapay:px-3 novapay:py-2.5",children:g=>jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:text-sm novapay:font-semibold",children:g.title}),jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:g.hint})]})}),c$1==="fiat_value"&&jsxs("label",{htmlFor:s,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsxs("span",{children:[c(r.amount,{currency:n}),jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]})]}),jsx("input",{id:s,required:true,inputMode:"decimal",value:p,placeholder:"0.00","aria-invalid":!d||void 0,onChange:g=>m(g.target.value.replace(",",".")),className:cn$1($,h)}),o&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(r.amountHint,{amount:o})})]}),jsxs("label",{htmlFor:i,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsx("span",{children:r.reason}),jsx("input",{id:i,value:y,maxLength:500,onChange:g=>f(g.target.value),className:h})]})]}),e.error&&jsx(Q,{children:Ha(e.error,r)})]}),jsx(Z,{children:jsx(X,{busy:v.checking,disabled:!d,onClick:()=>{v.ask(x);},children:r.continue})})]})}function hc(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 Xm({flow:e,labels:t,locale:a,values:n,details:o,recordAction:r}){let s=t.refund,i=e.transfer,c$1=typeof e.balance=="bigint"&&i?`${pe(e.balance.toString(),i.decimals,a)} ${i.symbol}`:null,l=e.fee?ha(e.fee.amount.toString(),e.fee.decimals,a):null,p=e.fee&&l?`${l} ${e.fee.symbol}`:null,m={notEnough:c(s.notEnough,{...n,address:e.wallet?shortAddress(e.wallet.address):"",balance:c$1??""}),declined:c(s.declined,n),unsupported:c(s.unsupported,n),wrongNetwork:c(s.wrongNetwork,n),failed:s.failed,noRecipient:s.noRecipient,fromBuyer:s.failedFromBuyer,stillInWallet:c(t.walletPrompt.stillWaiting,n),unreachable:s.unreachable},y=!!e.problem,f=!!e.txKey;return jsxs(Fragment$1,{children:[jsxs(de,{title:y?s.notSent:s.confirmTitle,children:[jsxs(xe,{children:[jsx(H,{name:s.send,children:n.amount}),jsx(H,{name:s.network,children:n.network}),i&&jsx(H,{name:s.to,children:hc(jsx(He,{hash:i.to,explorerUrl:e.addressUrl(i.to),labels:t}),e.refund?.unmatchedTransfer?s.theSender:s.thePayer)}),e.wallet&&jsx(H,{name:s.from,children:hc(jsx(He,{hash:e.wallet.address,explorerUrl:e.addressUrl(e.wallet.address),labels:t}),c$1&&c(s.balance,{amount:c$1}))}),p&&jsx(H,{name:s.networkFee,children:c(s.feeEstimate,{amount:p})}),o]}),e.problem&&jsx(Q,{children:m[e.problem]}),e.problem&&!["noRecipient","unreachable","stillInWallet"].includes(e.problem)&&jsx($e,{children:s.nothingSent}),f&&e.error&&jsx(Q,{children:s.notHandedOver}),!f&&e.error&&e.problem!=="unreachable"&&jsx(Q,{children:Ha(e.error,s)})]}),jsxs(Z,{children:[e.problem!=="noRecipient"&&(e.wrongNetwork&&!f?jsx(X,{onClick:()=>{e.switchNetwork();},children:jsx(ge,{label:s.switchTo,values:n})}):jsx(X,{busy:e.sending,onClick:()=>{e.send();},children:f?s.handOver:s.sendRefund})),(y||f)&&r,!y&&!f&&e.wallet&&jsx(ae,{onClick:e.connect,children:t.pay.changeWallet})]})]})}function nd(e){return e.appStore?e.novaConnect?"app":"appStore":e.ownConnection?"own":"none"}function $a(e){let t=useContext(SatelliteStoreContext),a=useContext(NovaConnectProviderContext);return nd({appStore:t!=null,novaConnect:a!==void 0,ownConnection:e})}function eC(){let e=pt(),t=$a(false);return e.connection??t}var od=()=>import('./OwnConnection-ET76SUMX.js').then(e=>({default:e.OwnConnection})),kc=lazy(od);var pd=()=>process.env.NODE_ENV==="development";function cC({baseUrl:e,labels:t,customization:a,adapters:n,pulsar:o,ownConnection:r,onConnectWallet:s,children:i}){let c=useContext(Gn),l=$a(!!r),[p]=useState(l),[m]=useState(r),y=p==="own"?r??m:void 0,f=(p==="app"||p==="appStore")&&c.connection!==void 0&&c.connection!=="none",v=y?y.adapters:n??(f?c.adapters:void 0),d=useMemo(()=>({baseUrl:e,labels:t,customization:a,adapters:v,pulsar:o,connection:p,onConnectWallet:s}),[e,t,a,v,o,p,s]),R=useRef(null),h=!!r,x=!!v;return useEffect(()=>{if(!pd())return;R.current??=new Set;let g=R.current,k=(N,b)=>{g.has(N)||(g.add(N),console.warn(`[NovaPaymentsProvider] ${b}`));};l!==p&&k("connection",`it keeps the wallet connection it chose on its first render ("${p}"), though the providers above now call for "${l}". Render it inside the app's SatelliteConnectProvider and NovaConnectProvider from the start.`),h&&p==="appStore"&&k("appStore","it is inside the app's SatelliteConnectProvider without NovaConnectProvider: it uses the app's wallet and never adds a second store, so `ownConnection` is not used. Connect wallets with `onConnectWallet`, or render it inside NovaConnectProvider."),h&&!x&&(p==="app"||p==="appStore")&&k("adapters","it uses the app's wallet connection, so the adapters of `ownConnection` are not used: pass `adapters` on the app's wagmi config to pay from the app's wallet.");},[l,p,h,x]),jsx(Gn.Provider,{value:d,children:y?jsx(Suspense,{fallback:null,children:jsx(kc,{own:y,children:i})}):i})}export{Jm as AmountStep,Zr as BuyerScreen,ra as CheckoutContext,Go as CheckoutContextProvider,Lm as CheckoutFrame,ys as CheckoutHeader,Am as CheckoutPageRoot,Xr as CheckoutStepper,cs as CheckoutSummary,ls as CompactSummary,Ds as ConfirmScreen,Xm as ConfirmStep,zs as ConfirmWalletScreen,vo as ContactLink,ll as DEADLINE_ANNOUNCEMENTS,os as DeadlineTimer,ba as Disclosure,ti as FailedScreen,Zm as FailedStep,oi as LeaveDialog,us as LocaleSwitcher,ga as MerchantBadge,li as MethodScreen,fs as MobileSteps,Gn as NovaPaymentsContext,cC as NovaPaymentsProvider,Ma as OPEN_REQUEST_MS,rs as OrderLines,jl as OrderTotal,Xs as OutcomeScreen,vi as PaidScreen,nc as PayScreen,La as PayeeScreen,Gw as PaymentCheckout,to as QUOTE_WARNING_MS,rc as QrScreen,Sk as RefundButton,$m as RefundDialog,Km as RefundSteps,ic as ScreenBody,ro as SellerDetailsContent,ss as SummaryFooter,qn as WalletPrompt,Et as addressOfWallet,$r as balanceShortfall,xa as baseUnitsToDecimal,Ya as buyerFields,jo as buyerIssues,hr as canPayWithQr,Y as checkoutClassName,eo as checkoutScreen,gr as checkoutSteps,Yo as cleanBuyer,vr as connectedWallet,_r as contactHref,Zo as countryOptions,kr as deadlineAnnouncement,Ln as deadlineState,la as failedPaymentTx,Rt as familyOf,st as formatCountdown,ha as formatFeeAmount,ye as formatFiat,pe as formatTokenAmount,wr as groupMethodsByToken,Li as handOffPayUrl,Oi as handOverPayment,he as instructionsChainId,pn as invoiceTotals,Dn as isConfirmationError,Ir as isFinalPaymentFailure,ft as isInvoicePaymentOnTheWay,qt as isInvoicePaymentUnresolved,vt as isMovedMoneyFailure,Er as isPaidElsewhere,yo as isPayerProofError,Oa as isPaymentAccepted,ot as isPaymentOnTheWay,Pr as isQuoteEnding,sn as isSameWallet,fc as isSlow,Ta as isSmartWallet,Ja as isWalletIconUrl,Ut as leftTheWalletText,Hs as lockPrice,Cr as lockedPriceOnWallet,pa as methodErrorText,Ye as methodFamily,xr as methodToken,Re as minorToDecimal,ao as needsLeaveConfirm,Us as needsPayerProof,Dr as needsTheClock,ve as networkName,br as paidSteps,_i as payInvoice,qr as payPath,xn as payeeStatus,Ii as payeeVerified,Ue as payerFor,Ra as payerProofErrorText,An as paymentFailedText,Xa as priceAdjustment,ac as qrPath,Ur as quoteAmounts,Hr as quoteRate,Br as receivedAmount,Or as refundRateMoved,cc as refundTransfer,Ha as refusalText,rn as restRateText,Nr as screensPayingWallets,Tr as sentBeforeDeadline,Ar as shownLocale,It as unconfirmedFollowUp,Lr as unconfirmedTxKey,Mr as underpaidRest,gn as useAsyncValue,yi as useAutoReturn,I as useCheckoutContext,xi as useCheckoutEvents,wi as useCheckoutState,bi as useCheckoutStore,_a as useConnectedWallet,pt as useNovaPayments,Ni as useNow,qe as useOptionalCheckoutContext,di as usePaidCallback,Pa as usePayerProof,Mi as usePayment,dn as usePaymentFacts,Ui as usePaymentHandOver,eC as usePaymentsConnection,zn as usePaymentsLabels,uc as useRefund,Wa as useRereadValue,Da as useWalletConnection,Ei as verifyPayeeWith,nl as walletLabel,Sr as walletOnConfirmStep};
|