@nowramp/form 0.1.34 → 0.1.35

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.
@@ -51,5 +51,5 @@ Error generating stack: `+o.message+`
51
51
  * @nowramp/sdk v0.1.13
52
52
  * (c) 2026 NowRamp
53
53
  * @license MIT
54
- */class Yl{constructor(t){this.config=t,this.baseUrl=t.apiUrl||"https://api.nowramp.com"}async getRate(t){var o,i,s,a,c,y;if(!this.config.apiKey)return this.getPublicRate(t);const n=await fetch(`${this.baseUrl}/v1/rates/convert`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({from:t.from,to:t.to,amount:t.amount,flowType:t.flowType||"buy"})});if(!n.ok){const m=await n.json().catch(()=>({})),h=((o=m.error)==null?void 0:o.message)||m.message||`HTTP ${n.status}`;throw new Error(`Failed to get rate: ${h}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{rate:l.rate,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationAmount:l.destinationAmount,destinationCurrency:l.destinationCurrency,fees:{processingFee:((s=l.fees)==null?void 0:s.processingFee)||0,processingFeePercent:((a=l.fees)==null?void 0:a.processingFeePercent)||0,networkFee:((c=l.fees)==null?void 0:c.networkFee)||0,totalFee:((y=l.fees)==null?void 0:y.totalFee)||0},provider:l.provider||"unknown",expiresAt:l.expiresAt}}async getPublicRate(t){var o,i,s,a,c,y;const n=await fetch(`${this.baseUrl}/public/wert/convert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:t.from,to:t.to,amount:t.amount,flowType:t.flowType||"buy"})});if(!n.ok){const m=await n.json().catch(()=>({})),h=((o=m.error)==null?void 0:o.message)||m.message||`HTTP ${n.status}`;throw new Error(`Failed to get rate: ${h}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{rate:l.ticker||l.rate,sourceAmount:l.currencyAmount||l.sourceAmount||t.amount,sourceCurrency:t.from,destinationAmount:l.commodityAmount||l.destinationAmount,destinationCurrency:t.to,fees:{processingFee:l.feeAmount||((s=l.fees)==null?void 0:s.processingFee)||0,processingFeePercent:l.feePercent||((a=l.fees)==null?void 0:a.processingFeePercent)||0,networkFee:l.currencyMinerFee||((c=l.fees)==null?void 0:c.networkFee)||0,totalFee:(l.feeAmount||0)+(l.currencyMinerFee||0)||((y=l.fees)==null?void 0:y.totalFee)||0},provider:"wert",expiresAt:l.expiresAt}}async getCurrencies(){var l,o;if(!this.config.apiKey)return this.getPublicCurrencies();const t=await fetch(`${this.baseUrl}/v1/rates/currencies`,{method:"GET",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!t.ok){const i=await t.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${t.status}`;throw new Error(`Failed to get currencies: ${s}`)}const n=await t.json(),r=((o=n.data)==null?void 0:o.attributes)||n.data||n;return{fiat:r.fiat||[],crypto:r.crypto||[],provider:r.provider||"unknown",environment:r.environment||"sandbox"}}async getPublicCurrencies(){var l,o;if(!this.config.projectId)throw new Error("projectId is required to fetch currencies without an API key");const t=await fetch(`${this.baseUrl}/public/projects/${this.config.projectId}/currencies`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const i=await t.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${t.status}`;throw new Error(`Failed to get currencies: ${s}`)}const n=await t.json(),r=((o=n.data)==null?void 0:o.attributes)||n.data||n;return{fiat:r.fiat||[],crypto:r.crypto||[],provider:r.provider||"unknown",environment:r.environment||"sandbox"}}async validateAddress(t){var l,o;const n=await fetch(`${this.baseUrl}/public/validate/address`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to validate address: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async validateAddressBatch(t){var l,o;if(t.length>20)throw new Error("Maximum 20 addresses per batch");const n=await fetch(`${this.baseUrl}/public/validate/address/batch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({addresses:t})});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to validate addresses: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async getSupportedNetworks(){var r,l;const t=await fetch(`${this.baseUrl}/public/validate/networks`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const o=await t.json().catch(()=>({})),i=((r=o.error)==null?void 0:r.message)||o.message||`HTTP ${t.status}`;throw new Error(`Failed to get supported networks: ${i}`)}const n=await t.json();return((l=n.data)==null?void 0:l.attributes)||n.data||n}async createSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to create sessions. Use a secret key (sk_) for this operation.");const n=await fetch(`${this.baseUrl}/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify(t)});if(!n.ok){const a=await n.json().catch(()=>({})),c=((o=a.error)==null?void 0:o.message)||a.message||`HTTP ${n.status}`;throw new Error(`Failed to create session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,clientSecret:l.clientSecret,type:l.type||"onramp",status:l.status||"pending",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,expiresAt:l.expiresAt,createdAt:l.createdAt}}async getSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to get session details.");const n=await fetch(`${this.baseUrl}/v1/sessions/${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!n.ok){const a=await n.json().catch(()=>({})),c=((o=a.error)==null?void 0:o.message)||a.message||`HTTP ${n.status}`;throw new Error(`Failed to get session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,type:l.type||"onramp",status:l.status||"pending",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,fieldLocks:l.fieldLocks,orderId:l.orderId,expiresAt:l.expiresAt,confirmedAt:l.confirmedAt,completedAt:l.completedAt,createdAt:l.createdAt}}async cancelSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to cancel sessions. Use a secret key (sk_) for this operation.");const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/cancel`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!n.ok){const a=await n.json().catch(()=>({})),c=((o=a.error)==null?void 0:o.message)||a.message||`HTTP ${n.status}`;throw new Error(`Failed to cancel session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,type:l.type||"onramp",status:l.status||"cancelled",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,orderId:l.orderId,expiresAt:l.expiresAt,confirmedAt:l.confirmedAt,completedAt:l.completedAt,createdAt:l.createdAt}}async getSupported(t){var o,i;if(!this.config.projectId)throw new Error("projectId is required to get supported config");const n=new URLSearchParams({projectId:this.config.projectId});t&&n.set("orderType",t);const r=await fetch(`${this.baseUrl}/public/v1/onramp/supported?${n}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){const s=await r.json().catch(()=>({})),a=((o=s.error)==null?void 0:o.message)||s.message||`HTTP ${r.status}`;throw new Error(`Failed to get supported config: ${a}`)}const l=await r.json();return((i=l.data)==null?void 0:i.attributes)||l.data||l}async getQuotes(t){var o,i;if(!this.config.projectId)throw new Error("projectId is required to get quotes");const n=new URLSearchParams({projectId:this.config.projectId,fiatCurrency:t.fiatCurrency,cryptoCurrency:t.cryptoCurrency,network:t.network});t.fiatAmount&&n.set("fiatAmount",t.fiatAmount),t.cryptoAmount&&n.set("cryptoAmount",t.cryptoAmount),t.orderType&&n.set("orderType",t.orderType),t.paymentMethodId&&n.set("paymentMethodId",t.paymentMethodId),t.country&&n.set("country",t.country);const r=await fetch(`${this.baseUrl}/public/v1/onramp/quotes?${n}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){const s=await r.json().catch(()=>({})),a=((o=s.error)==null?void 0:o.message)||s.message||`HTTP ${r.status}`;throw new Error(`Failed to get quotes: ${a}`)}const l=await r.json();return((i=l.data)==null?void 0:i.attributes)||l.data||l}async createCheckoutIntent(t){var l,o;if(!this.config.projectId)throw new Error("projectId is required to create checkout intents");const n=await fetch(`${this.baseUrl}/public/v1/onramp/checkout-intent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:this.config.projectId,...t})});if(!n.ok){const i=await n.json().catch(()=>({})),s=(typeof i.error=="string"?i.error:(l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;let a="";if(i.details)try{const c=typeof i.details=="string"?JSON.parse(i.details):i.details;if(c.errors&&typeof c.errors=="object"){const y=Object.values(c.errors).flat().filter(Boolean);y.length&&(a=y.join("; "))}}catch{}throw new Error(`Failed to create checkout intent: ${a||s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async getTransaction(t){var l,o;const n=await fetch(`${this.baseUrl}/public/v1/onramp/transactions/${t}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to get transaction: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}}function Gp(e,t){const[n,r]=k.useState(null),[l,o]=k.useState(!0),[i,s]=k.useState(null),a=k.useRef(null);(!a.current||a.current!==e)&&(a.current=new Yl({apiKey:"",...e}));const c=k.useCallback(async()=>{if(!e.projectId){s(new Error("projectId is required")),o(!1);return}o(!0),s(null);try{const y=await a.current.getSupported(t);r(y)}catch(y){s(y instanceof Error?y:new Error("Failed to fetch config"))}finally{o(!1)}},[e.projectId,t]);return k.useEffect(()=>{c()},[c]),{config:n,loading:l,error:i,refetch:c}}function Zp(e,t){const[n,r]=k.useState(null),[l,o]=k.useState(!1),[i,s]=k.useState(null),a=k.useRef(null),c=k.useRef(""),y=`${e.apiUrl}|${e.projectId}`;(!a.current||c.current!==y)&&(a.current=new Yl({apiKey:"",...e}),c.current=y);const m=k.useRef(0);k.useEffect(()=>{const x=++m.current;if(!t||!e.projectId){r(null),o(!1);return}o(!0),s(null),a.current.getQuotes(t).then(g=>{m.current===x&&(r(g),o(!1))},g=>{m.current===x&&(s(g instanceof Error?g:new Error("Failed to fetch quotes")),r(null),o(!1))})},[e.projectId,t==null?void 0:t.fiatCurrency,t==null?void 0:t.fiatAmount,t==null?void 0:t.cryptoAmount,t==null?void 0:t.cryptoCurrency,t==null?void 0:t.network,t==null?void 0:t.paymentMethodId,t==null?void 0:t.country,t==null?void 0:t.orderType]);const h=k.useCallback(async()=>{if(!(!t||!e.projectId)){o(!0),s(null);try{const x=await a.current.getQuotes(t);r(x)}catch(x){s(x instanceof Error?x:new Error("Failed to fetch quotes"))}finally{o(!1)}}},[e.projectId,t]);return{quotes:n,loading:l,error:i,refetch:h}}function Jp(e){const[t,n]=k.useState(null),[r,l]=k.useState(!1),[o,i]=k.useState(null),s=k.useRef(null),a=k.useRef(""),c=`${e.apiUrl}|${e.projectId}`;(!s.current||a.current!==c)&&(s.current=new Yl({apiKey:"",...e}),a.current=c);const y=k.useCallback(async h=>{l(!0),i(null);try{const x=await s.current.createCheckoutIntent(h);return n(x),x}catch(x){const g=x instanceof Error?x:new Error("Failed to create checkout intent");throw i(g),g}finally{l(!1)}},[]),m=k.useCallback(()=>{n(null),i(null)},[]);return{order:t,loading:r,error:o,createOrder:y,reset:m}}function qp(e,t,n){const[r,l]=k.useState(null),[o,i]=k.useState(!1),[s,a]=k.useState(null),c=k.useRef(null);c.current||(c.current=new Yl({apiKey:"",projectId:"",...e}));const y=k.useCallback(async()=>{if(t){i(!0),a(null);try{const m=await c.current.getTransaction(t);l(m)}catch(m){a(m instanceof Error?m:new Error("Failed to fetch status"))}finally{i(!1)}}},[t]);return k.useEffect(()=>{if(!t)return;const m=n==null?void 0:n.initialDelay;{const h=setTimeout(y,m);return()=>clearTimeout(h)}},[y,t,n==null?void 0:n.initialDelay]),k.useEffect(()=>{if(!t||!(n!=null&&n.pollInterval)||!r||["completed","failed","cancelled","expired","refunded"].includes(r.status))return;const h=setInterval(y,n.pollInterval);return()=>clearInterval(h)},[t,n==null?void 0:n.pollInterval,r==null?void 0:r.status,y]),{status:r,loading:o,error:s,refetch:y}}function Yc(e,t){if(!e)return e;const n=e.indexOf(".");if(n===-1)return e;let r=e;return r.length-n-1>t&&(r=r.slice(0,n+t+1)),r=r.replace(/0+$/,"").replace(/\.$/,""),r}const Gc={step:"amount",flowType:"buy",fiatCurrency:"USD",fiatAmount:"",cryptoCurrency:"",cryptoAmount:"",network:"",paymentMethodId:"",walletAddress:"",walletError:null,selectedProvider:null,selectedQuote:null,customerId:"",email:"",country:"",errorMessage:null};function bp(e,t){switch(t.type){case"SET_STEP":return{...e,step:t.step,errorMessage:null};case"SET_FLOW_TYPE":return{...e,flowType:t.flowType,fiatAmount:"",cryptoAmount:"",selectedQuote:null,selectedProvider:null,errorMessage:null};case"SET_FIAT_CURRENCY":return{...e,fiatCurrency:t.currency};case"SET_FIAT_AMOUNT":return{...e,fiatAmount:t.amount};case"SET_CRYPTO_CURRENCY":return{...e,cryptoCurrency:t.currency,network:""};case"SET_CRYPTO_AMOUNT":return{...e,cryptoAmount:t.amount};case"SET_NETWORK":return{...e,network:t.network};case"SET_CRYPTO_CHAIN":return{...e,network:t.chain};case"SET_PAYMENT_METHOD":return{...e,paymentMethodId:t.methodId};case"SET_WALLET_ADDRESS":return{...e,walletAddress:t.address,walletError:null};case"SET_WALLET_ERROR":return{...e,walletError:t.message};case"SELECT_QUOTE":return{...e,selectedQuote:t.quote,selectedProvider:t.quote.gatewayId};case"SET_CUSTOMER_ID":return{...e,customerId:t.customerId};case"SET_EMAIL":return{...e,email:t.email};case"SET_COUNTRY":return{...e,country:t.country};case"SET_ERROR":return{...e,step:"error",errorMessage:t.message};case"CLEAR_ERROR":return{...e,errorMessage:null};case"RESET":return Gc;default:return e}}const Zc=k.createContext(null);function em({projectId:e,apiUrl:t="https://api.nowramp.com",assetBaseUrl:n="",flowType:r="buy",customerId:l="",defaultFiatCurrency:o="USD",defaultCryptoCurrency:i="BTC",defaultNetwork:s="",defaultFiatAmount:a="",defaultCryptoAmount:c="",defaultWalletAddress:y="",defaultGateway:m,fieldLocks:h,statusPollInterval:x=5e3,onComplete:g,onError:S,children:_}){const f=k.useMemo(()=>({apiUrl:t,projectId:e}),[t,e]),d=s||(i?i.toLowerCase():""),p=r==="sell",w=p?!!c:!!a,A=(p?!!(w&&i&&d):!!(w&&i&&d&&y))&&m?"confirm":"amount",[v,T]=k.useReducer(bp,{...Gc,step:A,flowType:r,fiatCurrency:o,cryptoCurrency:i,network:d,fiatAmount:Yc(a,2),cryptoAmount:Yc(c,6),walletAddress:y,customerId:l}),R=v.flowType==="sell",{config:L,loading:Q,error:fe}=Gp(f,v.flowType);Mr.useEffect(()=>{var ne,re,q;if(!L||!v.cryptoCurrency||v.network)return;const F=(ne=L.cryptos)==null?void 0:ne.find(Je=>Je.code===v.cryptoCurrency),Z=((re=F==null?void 0:F.networks)==null?void 0:re.find(Je=>Je.isDefault))||((q=F==null?void 0:F.networks)==null?void 0:q[0]);Z!=null&&Z.id&&T({type:"SET_NETWORK",network:Z.id})},[L,v.cryptoCurrency,v.network]);const pe=k.useMemo(()=>{if(R){if(!v.cryptoAmount)return null;const q=parseFloat(v.cryptoAmount);return isNaN(q)||q<=0?"Enter a valid amount":null}if(!L||!v.fiatAmount)return null;const F=parseFloat(v.fiatAmount);if(isNaN(F))return null;const Z=L.fiats.find(q=>q.code===v.fiatCurrency);if(!Z)return null;const ne=parseFloat(Z.minAmount),re=parseFloat(Z.maxAmount);return!isNaN(ne)&&F<ne?`Minimum amount is ${Z.minAmount} ${v.fiatCurrency}`:!isNaN(re)&&F>re?`Maximum amount is ${Z.maxAmount} ${v.fiatCurrency}`:null},[L,v.fiatAmount,v.fiatCurrency,v.cryptoAmount,R]),tn=k.useMemo(()=>{const F=R?!!v.cryptoAmount:!!v.fiatAmount;return!L||!F||!v.cryptoCurrency||!v.network||pe?null:{fiatCurrency:v.fiatCurrency,...R?{cryptoAmount:v.cryptoAmount}:{fiatAmount:v.fiatAmount},cryptoCurrency:v.cryptoCurrency,network:v.network,paymentMethodId:v.paymentMethodId||void 0,country:v.country||void 0,orderType:v.flowType}},[L,v.fiatCurrency,v.fiatAmount,v.cryptoAmount,v.cryptoCurrency,v.network,v.paymentMethodId,v.country,pe,R,v.flowType]),{quotes:nn,loading:pt,error:Re,refetch:N}=Zp(f,tn),{order:P,loading:I,error:B,createOrder:V}=Jp(f),mt=15e3,{status:ae,loading:Ze}=qp({apiUrl:t},(P==null?void 0:P.orderId)??null,{pollInterval:x,initialDelay:mt});Mr.useEffect(()=>{(ae==null?void 0:ae.status)==="completed"&&g&&g(ae)},[ae==null?void 0:ae.status,g]),Mr.useEffect(()=>{const F=fe||B;F&&S&&S(F)},[fe,B,S]);const ke=m||(L==null?void 0:L.defaultGateway)||null,ht=k.useRef(ke);ht.current=ke;const Jl=k.useRef(nn);Jl.current=nn;const ql=k.useCallback(async()=>{var Z,ne,re;const F=((Z=v.selectedQuote)==null?void 0:Z.gatewayId)||((re=(ne=Jl.current)==null?void 0:ne.bestQuote)==null?void 0:re.gatewayId)||ht.current;if(!F||!v.walletAddress){const q=[!F&&"gateway",!v.walletAddress&&"walletAddress"].filter(Boolean).join(", ");T({type:"SET_ERROR",message:`Missing required fields: ${q}`});return}try{await V({gateway:F,customerId:v.customerId||void 0,fiatCurrency:v.fiatCurrency,...R?{cryptoAmount:v.cryptoAmount}:{fiatAmount:v.fiatAmount},cryptoCurrency:v.cryptoCurrency,network:v.network,walletAddress:v.walletAddress,paymentMethodId:v.paymentMethodId||void 0,email:v.email||void 0,orderType:v.flowType}),T({type:"SET_STEP",step:"checkout"})}catch(q){const Je=q instanceof Error?q.message:"Failed to create order";/wallet|address/i.test(Je)?T({type:"SET_WALLET_ERROR",message:Je.replace(/^Failed to create checkout intent:\s*/i,"")}):T({type:"SET_ERROR",message:Je})}},[v,V,R]),Ut=k.useCallback(F=>{T({type:"SET_STEP",step:F})},[]),Fn=k.useCallback(()=>{const F=["confirm","amount","quotes","wallet","checkout","processing","complete"],Z=F.indexOf(v.step);Z>0&&T({type:"SET_STEP",step:F[Z-1]})},[v.step,R]),ws=k.useMemo(()=>{const F=R?!!v.cryptoAmount:!!v.fiatAmount;switch(v.step){case"confirm":return!!(F&&v.cryptoCurrency&&v.network&&v.walletAddress&&!pe);case"amount":return!!(F&&v.cryptoCurrency&&v.network&&!pe);case"quotes":return!!v.selectedQuote;case"wallet":return!!v.walletAddress;default:return!1}},[v,pe,R]),Lr={apiConfig:f,assetBaseUrl:n,config:L,configLoading:Q,configError:fe,state:v,dispatch:T,quotes:nn,quotesLoading:pt,quotesError:Re,fetchQuotes:N,order:P,orderLoading:I,orderError:B,createOrder:ql,orderStatus:ae,orderStatusLoading:Ze,fieldLocks:h||null,defaultGateway:ke,amountError:pe,goToStep:Ut,goBack:Fn,canProceed:ws};return u.jsx(Zc.Provider,{value:Lr,children:_})}function Mn(){const e=k.useContext(Zc);if(!e)throw new Error("useRamp must be used within a RampProvider");return e}function tm({className:e="",iframeHeight:t=600,autoRedirect:n=!1,redirectDelay:r=3e3}){var x;const{order:l,orderStatus:o,goToStep:i,goBack:s}=Mn(),[a,c]=k.useState(!1),[y,m]=k.useState(null),h=l!=null&&l.checkout.expiresAt?Date.now()>l.checkout.expiresAt:!1;if(k.useEffect(()=>{if((l==null?void 0:l.checkout.method)==="redirect"&&n&&!h){m(Math.ceil(r/1e3));const g=setTimeout(()=>{window.location.href=l.checkout.url},r),S=setInterval(()=>{m(_=>_&&_>1?_-1:null)},1e3);return()=>{clearTimeout(g),clearInterval(S)}}},[l,n,r,h]),k.useEffect(()=>{o&&(o.status==="completed"?i("complete"):["failed","cancelled","expired"].includes(o.status)&&i("error"))},[o==null?void 0:o.status,i]),!l)return u.jsxs("div",{className:`flex flex-col items-center justify-center p-8 ${e}`,style:{color:"var(--t-text)"},children:[u.jsx("p",{className:"text-[15px] mb-4",children:"No order found"}),u.jsx("button",{className:"font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",paddingLeft:24,paddingRight:24},onClick:s,children:"Go Back"})]});if(h)return u.jsxs("div",{className:`flex flex-col items-center justify-center p-8 text-center ${e}`,style:{color:"var(--t-text)"},children:[u.jsx("div",{className:"text-[48px] mb-4",children:"⏰"}),u.jsx("h3",{className:"text-[18px] font-semibold mb-2",children:"Checkout Expired"}),u.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:"The checkout link has expired. Please try again."}),u.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:s,children:"Start Over"})]});if(l.checkout.method==="iframe")return u.jsx("div",{className:`flex flex-col flex-1 ${e}`,children:u.jsxs("div",{className:"relative flex-1",style:{height:t,borderRadius:5,overflow:"hidden",background:"var(--t-surface)"},children:[!a&&u.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[u.jsx("div",{className:"nramp-spinner"}),u.jsx("p",{className:"text-[14px] mt-4",style:{color:"var(--t-text-secondary)"},children:"Loading checkout..."})]}),u.jsx("iframe",{src:l.checkout.url,style:{display:a?"block":"none",width:"100%",height:"100%",border:"none"},allow:((x=l.checkout.allowedFeatures)==null?void 0:x.join("; "))||"payment; camera; microphone; geolocation; clipboard-read; clipboard-write; accelerometer; gyroscope; magnetometer; fullscreen; autoplay; encrypted-media; web-share",onLoad:()=>c(!0),title:"Provider Checkout"})]})});if(l.checkout.method==="redirect")return u.jsxs("div",{className:`flex flex-col items-center justify-center p-8 text-center ${e}`,style:{color:"var(--t-text)"},children:[u.jsx("div",{className:"text-[48px] mb-4",children:"🔗"}),u.jsx("h3",{className:"text-[18px] font-semibold mb-2",children:"Complete Payment"}),u.jsxs("p",{className:"text-[14px] mb-4",style:{color:"var(--t-text-secondary)"},children:["You'll be redirected to ",l.gateway," to complete your payment."]}),y!==null&&u.jsxs("p",{className:"text-[13px] mb-4",style:{color:"var(--t-text-muted)"},children:["Redirecting in ",y,"..."]}),u.jsxs("a",{href:l.checkout.url,className:"w-full font-semibold text-[16px] flex items-center justify-center transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",textDecoration:"none"},target:"_blank",rel:"noopener noreferrer",children:["Continue to ",l.gateway]}),u.jsx("button",{className:"w-full font-semibold text-[14px] mt-2 transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)"},onClick:s,children:"Cancel"})]});if(l.checkout.method==="widget"&&l.widgetConfig){const g=nm(l.checkout.url,l.widgetConfig);return u.jsx("div",{className:`flex flex-col flex-1 ${e}`,children:u.jsxs("div",{className:"relative flex-1",style:{height:t,borderRadius:5,overflow:"hidden",background:"var(--t-surface)"},children:[!a&&u.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[u.jsx("div",{className:"nramp-spinner"}),u.jsx("p",{className:"text-[14px] mt-4",style:{color:"var(--t-text-secondary)"},children:"Loading checkout..."})]}),u.jsx("iframe",{src:g,style:{display:a?"block":"none",width:"100%",height:"100%",border:"none"},allow:"payment; camera; microphone; geolocation; clipboard-read; clipboard-write; accelerometer; gyroscope; magnetometer; fullscreen; autoplay; encrypted-media; web-share",onLoad:()=>c(!0),title:"Payment Checkout"})]})})}return u.jsxs("div",{className:`flex flex-col items-center justify-center p-8 ${e}`,style:{color:"var(--t-text)"},children:[u.jsx("p",{className:"text-[15px] mb-4",children:"Unknown checkout method"}),u.jsx("button",{className:"font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",paddingLeft:24,paddingRight:24},onClick:s,children:"Go Back"})]})}function nm(e,t){const n=new URL("/en/partner/widget",e);for(const[r,l]of Object.entries(t))l!=null&&l!==""&&n.searchParams.set(r,String(l));return n.toString()}function rm({className:e=""}){const{orderStatus:t,orderStatusLoading:n,goToStep:r}=Mn();k.useEffect(()=>{t&&(t.status==="completed"?r("complete"):["failed","cancelled","expired","refunded"].includes(t.status)&&r("error"))},[t==null?void 0:t.status,r]);const l=()=>{if(!t)return"Processing your order...";switch(t.status){case"pending":return"Waiting for payment confirmation...";case"processing":return"Processing your transaction...";default:return"Processing..."}};return u.jsxs("div",{className:`flex flex-col items-center justify-center px-8 py-12 text-center ${e}`,children:[u.jsx("div",{className:"mb-6",children:u.jsx("div",{className:"nramp-spinner-large nramp-spinner"})}),u.jsx("h2",{className:"text-[20px] font-semibold mb-3",style:{color:"var(--t-text)"},children:l()}),n&&u.jsx("p",{className:"text-[13px] mb-4",style:{color:"var(--t-text-muted)"},children:"Checking status..."}),t&&u.jsxs("div",{className:"w-full mt-6 text-left",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[u.jsx(Dn,{label:"Order ID",value:t.orderId,mono:!0}),u.jsx(Dn,{label:"Provider",value:t.gateway}),u.jsx(Dn,{label:"Amount",value:`${t.fiatAmount} ${t.fiatCurrency}`}),u.jsx(Dn,{label:"Receiving",value:`${t.cryptoAmount||"..."} ${t.cryptoCurrency}`}),u.jsx(Dn,{label:"Network",value:t.network}),u.jsx(Dn,{label:"To Address",value:`${t.walletAddress.slice(0,10)}...${t.walletAddress.slice(-8)}`,mono:!0})]}),u.jsxs("div",{className:"mt-6",children:[u.jsx("p",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"This usually takes a few minutes."}),u.jsx("p",{className:"text-[12px] mt-1",style:{color:"var(--t-text-muted)"},children:"You can safely close this page - we'll send you an email when complete."})]})]})}function Dn({label:e,value:t,mono:n}){return u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),u.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:"var(--t-text)"},children:t})]})}function lm({className:e="",explorerUrl:t,onDone:n,doneButtonText:r="Done"}){const{orderStatus:l,state:o,dispatch:i}=Mn(),s=o.flowType==="sell",a=()=>{if(!(l!=null&&l.transactionHash))return null;if(!t){const m={ethereum:"https://etherscan.io/tx/{txHash}",polygon:"https://polygonscan.com/tx/{txHash}",arbitrum:"https://arbiscan.io/tx/{txHash}",optimism:"https://optimistic.etherscan.io/tx/{txHash}",base:"https://basescan.org/tx/{txHash}",bitcoin:"https://mempool.space/tx/{txHash}",solana:"https://solscan.io/tx/{txHash}",avalanche:"https://snowtrace.io/tx/{txHash}",fantom:"https://ftmscan.com/tx/{txHash}"};return(m[o.network]||m.ethereum).replace("{txHash}",l.transactionHash)}return t.replace("{txHash}",l.transactionHash)},c=()=>{n?n():i({type:"RESET"})},y=a();return u.jsxs("div",{className:`flex flex-col items-center px-8 py-12 text-center ${e}`,children:[u.jsx("div",{className:"flex items-center justify-center mb-5",style:{width:64,height:64,borderRadius:"50%",background:"var(--t-success, #10b981)"},children:u.jsx("svg",{viewBox:"0 0 24 24",width:"32",height:"32",fill:"white",children:u.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"})})}),u.jsx("h2",{className:"text-[20px] font-semibold mb-2",style:{color:"var(--t-text)"},children:s?"Sale Complete!":"Purchase Complete!"}),u.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:s?`Your ${(l==null?void 0:l.fiatCurrency)||o.fiatCurrency} payout is being processed.`:`Your ${(l==null?void 0:l.cryptoCurrency)||o.cryptoCurrency} has been sent to your wallet.`}),l&&u.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[u.jsx(Ft,{label:s?"Amount Sold":"Amount Received",value:`${l.cryptoAmount} ${l.cryptoCurrency}`,highlight:!0}),u.jsx(Ft,{label:s?"Payout Amount":"Amount Paid",value:`${l.fiatAmount} ${l.fiatCurrency}`}),u.jsx(Ft,{label:"Network",value:l.network}),u.jsx(Ft,{label:"Wallet",value:`${l.walletAddress.slice(0,10)}...${l.walletAddress.slice(-8)}`,mono:!0}),l.transactionHash&&u.jsx(Ft,{label:"Transaction",value:`${l.transactionHash.slice(0,10)}...${l.transactionHash.slice(-8)}`,mono:!0}),u.jsx(Ft,{label:"Provider",value:l.gateway}),u.jsx(Ft,{label:"Order ID",value:l.orderId,mono:!0}),l.completedAt&&u.jsx(Ft,{label:"Completed",value:new Date(l.completedAt).toLocaleString()})]}),u.jsxs("div",{className:"w-full flex flex-col gap-2",children:[y&&u.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"w-full font-semibold text-[14px] flex items-center justify-center transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",textDecoration:"none"},children:"View on Explorer"}),u.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:c,children:r})]})]})}function Ft({label:e,value:t,mono:n,highlight:r}){return u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),u.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:r?"var(--t-success, #10b981)":"var(--t-text)"},children:t})]})}function om({className:e="",onRetry:t,supportEmail:n="support@nowramp.com"}){const{state:r,orderStatus:l,dispatch:o,goToStep:i}=Mn(),s=r.flowType==="sell",a=()=>{if(l)switch(l.status){case"failed":return"Payment Failed";case"cancelled":return"Order Cancelled";case"expired":return"Order Expired";case"refunded":return"Order Refunded";default:return"Something Went Wrong"}return"Something Went Wrong"},c=()=>{if(r.errorMessage)return r.errorMessage;if(l)switch(l.status){case"failed":return s?"Your sale could not be processed. Please try again.":"Your payment could not be processed. Please try again or use a different payment method.";case"cancelled":return s?"Your sale was cancelled. No crypto was transferred.":"Your order was cancelled. No payment was processed.";case"expired":return s?"Your order has expired. Please start a new sale.":"Your order has expired. Please start a new purchase.";case"refunded":return s?"Your crypto has been returned. The funds should appear in your wallet shortly.":"Your payment has been refunded. The funds should appear in your account within 5-10 business days.";default:return"An unexpected error occurred. Please try again."}return"An unexpected error occurred. Please try again."},y=()=>{o({type:"CLEAR_ERROR"}),t?t():(o({type:"RESET"}),i("amount"))},m=()=>{o({type:"RESET"}),i("amount")};return u.jsxs("div",{className:`flex flex-col items-center px-8 py-12 text-center ${e}`,children:[u.jsx("div",{className:"flex items-center justify-center mb-5",style:{width:64,height:64,borderRadius:"50%",background:"var(--t-error, #EF4444)"},children:u.jsx("svg",{viewBox:"0 0 24 24",width:"32",height:"32",fill:"white",children:u.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})})}),u.jsx("h2",{className:"text-[20px] font-semibold mb-2",style:{color:"var(--t-text)"},children:a()}),u.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:c()}),l&&u.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Order ID"}),u.jsx("span",{className:"text-[13px] font-medium font-mono",style:{color:"var(--t-text)"},children:l.orderId})]}),u.jsxs("div",{className:"flex justify-between items-center py-2",children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Status"}),u.jsx("span",{className:"text-[12px] font-medium px-2 py-0.5",style:{background:"rgba(239,68,68,0.15)",color:"#EF4444",borderRadius:4},children:l.gatewayStatus})]})]}),u.jsxs("div",{className:"w-full flex flex-col gap-2",children:[u.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:y,children:"Try Again"}),u.jsx("button",{className:"w-full font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)"},onClick:m,children:"Start Over"})]}),u.jsxs("div",{className:"mt-6",children:[u.jsxs("p",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:["Need help? Contact"," ",u.jsx("a",{href:`mailto:${n}`,className:"underline",style:{color:"var(--t-accent)"},children:n})]}),l&&u.jsxs("p",{className:"text-[12px] mt-1",style:{color:"var(--t-text-muted)"},children:["Reference: ",l.orderId]})]})]})}function Jc(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-6)}`}function im({className:e=""}){const{config:t,configLoading:n,state:r,defaultGateway:l,fetchQuotes:o,createOrder:i,orderLoading:s}=Mn(),a=r.flowType==="sell",[c,y]=k.useState(null),m=t==null?void 0:t.gateways.find(x=>x.id===l),h=async()=>{y(null);try{o(),await i()}catch(x){const g=x instanceof Error?x.message:"Failed to create order";y(g)}};return n?u.jsxs("div",{className:`flex flex-col items-center justify-center p-12 ${e}`,children:[u.jsx("div",{className:"nramp-spinner"}),u.jsx("p",{className:"text-[14px] mt-4",style:{color:"var(--t-text-secondary)"},children:"Loading..."})]}):u.jsxs("div",{className:`flex flex-col items-center px-8 py-12 ${e}`,children:[u.jsx("h2",{className:"text-[20px] font-semibold mb-6",style:{color:"var(--t-text)"},children:a?"Confirm Sale":"Confirm Purchase"}),u.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[m&&u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Provider"}),u.jsxs("span",{className:"flex items-center gap-2",children:[m.logo&&u.jsx("img",{src:m.logo,alt:m.name,width:20,height:20,style:{borderRadius:4}}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:m.name})]})]}),a?u.jsxs(u.Fragment,{children:[u.jsx(en,{label:"You sell",value:`${r.cryptoAmount} ${r.cryptoCurrency}`,highlight:!0}),u.jsx(en,{label:"You receive",value:`${r.fiatCurrency} payout`})]}):u.jsxs(u.Fragment,{children:[u.jsx(en,{label:"You pay",value:`${r.fiatAmount} ${r.fiatCurrency}`,highlight:!0}),u.jsx(en,{label:"You receive",value:`${r.cryptoCurrency} on ${r.network}`}),u.jsx(en,{label:"Wallet",value:Jc(r.walletAddress),mono:!0})]}),u.jsx(en,{label:"Network",value:r.network}),a&&r.walletAddress&&u.jsx(en,{label:"Refund address",value:Jc(r.walletAddress),mono:!0})]}),c&&u.jsx("p",{className:"text-[12px] mb-4",style:{color:"#EF4444"},children:c}),u.jsx("button",{className:"w-full font-semibold text-[16px] transition-all flex items-center justify-center gap-2",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",opacity:s?.7:1},disabled:s,onClick:h,children:s?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"nramp-spinner-inline"}),"Processing..."]}):a?"Confirm & Sell":"Confirm & Pay"})]})}function en({label:e,value:t,mono:n,highlight:r}){return u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),u.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:r?"var(--t-success, #10b981)":"var(--t-text)"},children:t})]})}function hs({isOpen:e,onClose:t,children:n}){const[r,l]=k.useState(!1),[o,i]=k.useState(!1);k.useEffect(()=>{if(e)l(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>i(!0)));else if(r){i(!1);const a=setTimeout(()=>l(!1),250);return()=>clearTimeout(a)}},[e]);const s=k.useCallback(()=>{i(!1),setTimeout(()=>t(),250)},[t]);return r?u.jsx("div",{className:"absolute inset-0 z-20 transition-opacity duration-250",style:{opacity:o?1:0},children:u.jsx("div",{className:"absolute inset-0 flex flex-col transition-transform duration-250 ease-out",style:{background:"var(--t-modal-bg)",transform:o?"translateY(0)":"translateY(24px)"},children:typeof n=="function"?n(s):n})}):null}function sm({char:e,height:t=38}){const n="0123456789",r=n.indexOf(e);return r===-1?u.jsx("span",{children:e}):u.jsx("span",{className:"digit-slot",style:{height:t,lineHeight:`${t}px`},children:u.jsx("span",{className:"digit-slot-inner block",style:{transform:`translateY(-${r*t}px)`},children:n.split("").map(l=>u.jsx("span",{className:"block",style:{height:t,lineHeight:`${t}px`},children:l},l))})})}function am({value:e,height:t=38,className:n="",style:r={}}){return u.jsx("span",{className:n,style:{display:"inline-flex",...r},children:e.split("").map((l,o)=>u.jsx(sm,{char:l,height:t},o))})}function $e({w:e,h:t,className:n=""}){return u.jsx("div",{className:`skeleton ${n}`,style:{width:e,height:t}})}function um(){return u.jsxs("div",{className:"flex-1 px-5 flex flex-col",children:[u.jsxs("div",{className:"px-[18px] pt-[14px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5},children:[u.jsx($e,{w:70,h:14,className:"mb-3"}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx($e,{w:120,h:32}),u.jsx($e,{w:75,h:32})]})]}),u.jsxs("div",{className:"px-[18px] pt-[12px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5,marginTop:4},children:[u.jsx($e,{w:50,h:14,className:"mb-3"}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx($e,{w:180,h:32}),u.jsx($e,{w:85,h:32})]})]}),u.jsxs("div",{className:"flex justify-between mt-3 px-[2px]",children:[u.jsx($e,{w:140,h:12}),u.jsx($e,{w:90,h:12})]}),u.jsxs("div",{className:"mt-8",children:[u.jsx($e,{w:65,h:14,className:"mb-2.5"}),u.jsx($e,{w:"100%",h:47})]}),u.jsx("div",{className:"flex-1"}),u.jsx($e,{w:"100%",h:60,className:"mb-2"}),u.jsx("div",{className:"text-center py-3",children:u.jsx("span",{className:"text-[11px]",style:{color:"var(--t-text-tertiary)"},children:"Powered by NowRamp"})})]})}const Gl={ETH:{name:"Ethereum (ERC20)",shortName:"Ethereum",icon:"eth"},BSC:{name:"Binance Smart Chain (BEP20)",shortName:"Binance",icon:"bnb"},BTC:{name:"Bitcoin",icon:"btc"},SOL:{name:"Solana",icon:"sol"},MATIC:{name:"Polygon",icon:"pol"},ARB:{name:"Arbitrum",icon:"arb"},BASE:{name:"Base",icon:"base"},OPTIMISM:{name:"Optimism",icon:"op"},AVAX_C:{name:"Avalanche C-Chain",shortName:"Avalanche C",icon:"avax"},AVAX_X:{name:"Avalanche X-Chain",shortName:"Avalanche X",icon:"avax"},ADA:{name:"Cardano",icon:"ada"},DOT:{name:"Polkadot",icon:"dot"},TRON:{name:"Tron (TRC20)",shortName:"Tron",icon:"trx"},XRP:{name:"Ripple",icon:"xrp"},XLM:{name:"Stellar",icon:"xlm"},ALGO:{name:"Algorand",icon:"algo"},ATOM:{name:"Cosmos",icon:"atom"},NEAR:{name:"NEAR Protocol",shortName:"NEAR",icon:"near"},SUI:{name:"Sui",icon:"sui"},APT:{name:"Aptos",icon:"apt"},TON:{name:"Ton",icon:"ton"},FIL:{name:"Filecoin",icon:"fil"},FLOW:{name:"Flow",icon:"flow"},HBAR:{name:"Hedera Hashgraph",shortName:"Hedera",icon:"hbar"},INJ:{name:"Injective",icon:"inj"},SEI_EVM:{name:"SEI (EVM)",shortName:"SEI",icon:"sei"},ZKSYNC:{name:"zkSync",icon:"zksync"},LINEA:{name:"Linea",icon:"linea"},STARK:{name:"StarkNet",icon:"strk"},LN:{name:"Lightning",icon:"btc"},CELO:{name:"Celo",icon:"celo"},CRO:{name:"Cronos",icon:"cro"},FTM:{name:"Fantom",icon:"ftm"},GLMR:{name:"Moonbeam",icon:"glmr"},MOVR:{name:"Moonriver",icon:"movr"},KSM:{name:"Kusama",icon:"ksm"},EOS:{name:"EOS",icon:"eos"},ETC:{name:"Ethereum Classic",shortName:"ETH Classic",icon:"etc"},LTC:{name:"Litecoin",icon:"ltc"},BCH:{name:"Bitcoin Cash",shortName:"BTC Cash",icon:"bch"},DOGE:{name:"Dogecoin",icon:"doge"},BNB:{name:"Binance Chain (BEP2)",shortName:"Binance",icon:"bnb"},ONE:{name:"Harmony",icon:"one"},KLAY:{name:"Kaia",icon:"kaia"},RON:{name:"Ronin",icon:"ron"},LRC:{name:"Loopring",icon:"lrc"},ICP:{name:"Internet Computer",shortName:"ICP",icon:"icp"},EGLD:{name:"MultiversX",icon:"egld"},FLUX:{name:"Flux",icon:"flux"},KDA:{name:"Kadena",icon:"kda"},WAVES:{name:"Waves",icon:"waves"},XTZ:{name:"Tezos",icon:"xtz"},ACA:{name:"Acala",icon:"aca"},ALEO:{name:"Aleo",icon:"aleo"},ALPH:{name:"Alephium",icon:"alph"},APE:{name:"ApeChain",icon:"ape"},ASTR:{name:"Astar",icon:"astr"},AZERO:{name:"Aleph Zero",icon:"azero"},AZERO_EVM:{name:"Aleph Zero EVM",shortName:"Aleph Zero",icon:"azero"},BAJU:{name:"Bajun Network",shortName:"Bajun",icon:"baju"},BNCPOLKA:{name:"Bifrost Polkadot",shortName:"Bifrost",icon:"bnc"},BNC:{name:"Bifrost Kusama",shortName:"Bifrost",icon:"bnc"},BOBA:{name:"Boba Network",shortName:"Boba",icon:"boba"},BSX:{name:"Basilisk",icon:"bsx"},CHZ:{name:"Chiliz",icon:"chz"},VIC:{name:"Viction",icon:"vic"},CCD:{name:"Concordium",icon:"ccd"},COREUM:{name:"Coreum",icon:"coreum"},DINGO:{name:"Dingocoin",icon:"dingo"},HDX:{name:"Hydration",icon:"hdx"},PLMC:{name:"Polimec",icon:"plmc"},MNT:{name:"Mantle",icon:"mnt"},ERG:{name:"Ergo",icon:"erg"},ECLIPSE:{name:"Eclipse",icon:"eclipse"},FUEL:{name:"Fuel Ignition",shortName:"Fuel",icon:"fuel"},INK:{name:"Ink",icon:"ink"},SOPHON:{name:"Sophon",icon:"sophon"},UNICHAIN:{name:"Unichain",icon:"unichain"},WLD:{name:"Worldchain",icon:"wld"},ETHERLINK:{name:"Etherlink",icon:"etherlink"},MOB:{name:"MobileCoin",icon:"mob"},GALA:{name:"Gala",icon:"gala"},GUNZ:{name:"Gunz",icon:"gun"},HNT:{name:"Helium",icon:"hnt"},BITKUB:{name:"BitKub",icon:"kub"},IMMUTABLE_ZKEVM:{name:"Immutable-zkEVM",shortName:"Immutable",icon:"imx"},INIT:{name:"Initia",icon:"init"},INTR:{name:"Interlay",icon:"intr"},KINESIS:{name:"Kinesis",icon:"kag"},KAR:{name:"Karura",icon:"kar"},KCC:{name:"KuCoin Community Chain",shortName:"KuCoin",icon:"kcs"},KILT:{name:"KILT Spiritnet",shortName:"KILT",icon:"kilt"},KINT:{name:"Kintsugi",icon:"kint"},KMD:{name:"Komodo",icon:"kmd"},LSK:{name:"Lisk",icon:"lsk"},METIS:{name:"Metis Andromeda",shortName:"Metis",icon:"metis"},MYTH:{name:"Myth",icon:"myth"},OAS:{name:"Oasys",icon:"oas"},PEAQ_EVM:{name:"Peaq (EVM)",shortName:"Peaq",icon:"peaq"},PEN:{name:"Pendulum",icon:"pen"},PI:{name:"Pi",icon:"pi"},POLYX:{name:"Polymesh",icon:"polyx"},Q:{name:"QuantumCoin",icon:"q"},QRL:{name:"Quantum Resistant Ledger",shortName:"QRL",icon:"qrl"},QUBIC:{name:"Qubic",icon:"qubic"},RBX:{name:"ReserveBlock",icon:"rbx"},ROLLUX:{name:"Rollux",icon:"rollux"},THORCHAIN:{name:"Thorchain",icon:"rune"},S:{name:"Sonic",icon:"s"},SONIC:{name:"Sonic",icon:"s"},TERNOA:{name:"Ternoa",icon:"caps"},SX:{name:"SX Network",icon:"sol"},WAX:{name:"WAX",icon:"waxp"},XCH:{name:"Chia Chain",icon:"xch"},XPRT:{name:"Persistence",icon:"xprt"},ZETACHAIN:{name:"ZetaChain",icon:"zeta"},ZTG:{name:"Zeitgeist",icon:"ztg"},PLS:{name:"Pulsechain",icon:"pulsechain"},MEZO:{name:"Mezo",icon:"mezo"},BSV:{name:"Bitcoin SV",shortName:"BTC SV",icon:"btc"},MONAD:{name:"Monad",icon:"mon"},SUPRA:{name:"Supra",icon:"supra"},SOMI:{name:"Somnia",icon:"somi"},VERIFIEDX:{name:"VerifiedX",icon:"vfx"},MOVE:{name:"Movement",icon:"move"},FLR:{name:"Flare",icon:"flr"},ASSETHUB:{name:"Asset Hub Polkadot",shortName:"Asset Hub",icon:"dot"},BOB:{name:"BOB",icon:"btc"},GLUE:{name:"Glue",icon:"eth"},DYDX:{name:"StarkEx",icon:"stark"},OKC:{name:"OKX Chain",icon:"eth"},UNI_CHAIN:{name:"UNI",icon:"uni"},ZEC:{name:"ZCash",icon:"zec"}},cm=[{code:"BTC",name:"Bitcoin",chains:["BTC","LN"],popular:!0},{code:"ETH",name:"Ethereum",chains:["ETH","ARB","BASE","BSC","OPTIMISM","LINEA","ZKSYNC","LRC","STARK","APE","ECLIPSE","FUEL","INK","SOPHON","UNICHAIN","WLD"],popular:!0},{code:"USDC",name:"USD Coin",chains:["ETH","SOL","ARB","BASE","BSC","MATIC","OPTIMISM","AVAX_C","ALGO","APT","CELO","FLOW","HBAR","LINEA","LRC","ZKSYNC","STARK","SUI","XLM","ECLIPSE","HDX","INK","LSK","METIS","MONAD","SEI_EVM","SONIC","SOPHON","SX","UNICHAIN","APE","BNCPOLKA","GLMR","PEAQ_EVM","PLMC","RON","UNI_CHAIN","WLD","BITKUB","BOB","DYDX","ETHERLINK","GLUE","ASSETHUB"],popular:!0},{code:"USDT",name:"Tether",chains:["ETH","BSC","TRON","ARB","MATIC","AVAX_C","SOL","OPTIMISM","ZKSYNC","STARK","APT","CELO","KLAY","LRC","LSK","ECLIPSE","ETHERLINK","OKC","PEAQ_EVM","BNCPOLKA","GLMR","HDX","PLMC","VIC","ASSETHUB"],popular:!0},{code:"SOL",name:"Solana",chains:["SOL"],popular:!0},{code:"XRP",name:"Ripple",chains:["XRP"],popular:!0},{code:"ADA",name:"Cardano",chains:["ADA"],popular:!0},{code:"DOGE",name:"Dogecoin",chains:["DOGE"],popular:!0},{code:"DOT",name:"Polkadot",chains:["DOT","BSC","BNCPOLKA","GLMR","HDX","PLMC"],popular:!0},{code:"AVAX",name:"Avalanche",chains:["AVAX_C","AVAX_X","BSC"],popular:!0},{code:"LINK",name:"ChainLink",chains:["ETH","BSC"],popular:!0},{code:"LTC",name:"Litecoin",chains:["LTC"],popular:!0},{code:"AAVE",name:"Aave",chains:["ETH","BSC"],popular:!1},{code:"ACA",name:"Acala",chains:["ACA"],popular:!1},{code:"ALEO",name:"Aleo",chains:["ALEO"],popular:!1},{code:"ALGO",name:"Algorand",chains:["ALGO"],popular:!1},{code:"ALPH",name:"Alephium",chains:["ALPH"],popular:!1},{code:"APE",name:"ApeCoin",chains:["APE","ETH"],popular:!1},{code:"APT",name:"Aptos",chains:["APT"],popular:!1},{code:"ARB",name:"Arbitrum",chains:["ARB"],popular:!1},{code:"ASTR",name:"Astar",chains:["ASTR"],popular:!1},{code:"ATOM",name:"Cosmos",chains:["ATOM"],popular:!1},{code:"AUDD",name:"Novatti Australian Digital Dollar",chains:["ETH"],popular:!1},{code:"AVT",name:"Aventus",chains:["ETH"],popular:!1},{code:"AXS",name:"Axie Infinity",chains:["ETH","RON"],popular:!1},{code:"AZERO",name:"Aleph Zero",chains:["AZERO","AZERO_EVM"],popular:!1},{code:"BAJU",name:"Bajun Network",chains:["BAJU"],popular:!1},{code:"BARSIK",name:"Hasbulla's Cat",chains:["SOL"],popular:!1},{code:"BAT",name:"Basic Attention Token",chains:["ETH","BSC"],popular:!1},{code:"BCH",name:"Bitcoin Cash",chains:["BCH"],popular:!1},{code:"BNB",name:"Binance Coin",chains:["BNB","BSC"],popular:!1},{code:"BNC",name:"Bifrost Native Coin",chains:["BNC","BNCPOLKA"],popular:!1},{code:"BOBA",name:"Boba Network",chains:["BOBA","ETH"],popular:!1},{code:"BORA",name:"Bora",chains:["KLAY"],popular:!1},{code:"BRETT",name:"Brett",chains:["BASE"],popular:!1},{code:"BSX",name:"Basilisk",chains:["BSX"],popular:!1},{code:"BZR",name:"Bazaars",chains:["ETH"],popular:!1},{code:"CAGA",name:"Crypto Asset Governance Alliance",chains:["ETH"],popular:!1},{code:"CAKE",name:"PancakeSwap",chains:["BSC"],popular:!1},{code:"CAPS",name:"Caps",chains:["TERNOA"],popular:!1},{code:"CELO",name:"Celo",chains:["CELO"],popular:!1},{code:"CHZ",name:"Chiliz",chains:["CHZ","BNB","ETH"],popular:!1},{code:"C98",name:"Coin98",chains:["VIC"],popular:!1},{code:"CCD",name:"Concordium",chains:["CCD"],popular:!1},{code:"COMP",name:"Compound",chains:["ETH","BSC"],popular:!1},{code:"COREUM",name:"Coreum",chains:["COREUM","XRP"],popular:!1},{code:"CRO",name:"Cronos",chains:["CRO"],popular:!1},{code:"CUSD",name:"Celo Dollar",chains:["CELO"],popular:!1},{code:"CVC",name:"Civic",chains:["ETH"],popular:!1},{code:"DAI",name:"Dai",chains:["ETH","BASE","MATIC"],popular:!1},{code:"DINGO",name:"Dingocoin",chains:["DINGO"],popular:!1},{code:"EGLD",name:"MultiversX",chains:["EGLD"],popular:!1},{code:"EMBER",name:"Ember Sword",chains:["MNT"],popular:!1},{code:"EOS",name:"EOS",chains:["EOS"],popular:!1},{code:"ERG",name:"Ergo",chains:["ERG"],popular:!1},{code:"ETC",name:"Ethereum Classic",chains:["ETC","BSC"],popular:!1},{code:"EUR",name:"EURC",chains:["BASE"],popular:!1},{code:"EUROC",name:"Euro Coin",chains:["ETH"],popular:!1},{code:"EURQ",name:"Quantoz EURQ",chains:["ETH"],popular:!1},{code:"EURR",name:"StablR EUR",chains:["ETH"],popular:!1},{code:"EUSD",name:"Electronic USD",chains:["MOB"],popular:!1},{code:"EXIT",name:"EXIT - Designer Token",chains:["BSC"],popular:!1},{code:"FDUSD",name:"First Digital USD",chains:["SUI"],popular:!1},{code:"FIL",name:"Filecoin",chains:["FIL","BSC"],popular:!1},{code:"FLOW",name:"Flow",chains:["FLOW"],popular:!1},{code:"FLR",name:"Flare",chains:["FLR"],popular:!1},{code:"FLUX",name:"Flux",chains:["FLUX"],popular:!1},{code:"FTM",name:"Fantom",chains:["FTM","ETH","BSC"],popular:!1},{code:"GALA",name:"Gala",chains:["GALA"],popular:!1},{code:"GLMR",name:"Moonbeam",chains:["GLMR"],popular:!1},{code:"GMX",name:"GMX",chains:["ARB"],popular:!1},{code:"GNUS",name:"Genius AI",chains:["ETH"],popular:!1},{code:"GRT",name:"The Graph",chains:["ETH","ARB"],popular:!1},{code:"GUN",name:"Gunz",chains:["GUNZ"],popular:!1},{code:"HBAR",name:"Hedera",chains:["HBAR"],popular:!1},{code:"HDX",name:"HydraDX",chains:["HDX"],popular:!1},{code:"HNT",name:"Helium",chains:["HNT"],popular:!1},{code:"HTP",name:"HowToPay",chains:["BSC"],popular:!1},{code:"HVLO",name:"Hivello",chains:["SOL"],popular:!1},{code:"ICP",name:"Internet Computer",chains:["ICP"],popular:!1},{code:"IMX",name:"Immutable X",chains:["ETH"],popular:!1},{code:"INIT",name:"Initia",chains:["INIT"],popular:!1},{code:"INJ",name:"Injective",chains:["INJ"],popular:!1},{code:"INTR",name:"Interlay",chains:["INTR"],popular:!1},{code:"JAM",name:"Jam Tune.FM",chains:["HBAR"],popular:!1},{code:"KAG",name:"Silver",chains:["KINESIS"],popular:!1},{code:"KAIA",name:"Kaia",chains:["KLAY"],popular:!1},{code:"KAR",name:"Karura",chains:["KAR"],popular:!1},{code:"KAU",name:"Gold",chains:["KINESIS"],popular:!1},{code:"KCS",name:"KuCoin Token",chains:["ETH","KCC"],popular:!1},{code:"KDA",name:"Kadena",chains:["KDA"],popular:!1},{code:"KILT",name:"KILT",chains:["KILT"],popular:!1},{code:"KINT",name:"Kintsugi",chains:["KINT"],popular:!1},{code:"KLV",name:"Klever",chains:["TRON"],popular:!1},{code:"KMD",name:"Komodo",chains:["KMD"],popular:!1},{code:"KSM",name:"Kusama",chains:["KSM"],popular:!1},{code:"KUB",name:"Bitkub Coin",chains:["BITKUB"],popular:!1},{code:"LOOKS",name:"LooksRare",chains:["ETH"],popular:!1},{code:"LRC",name:"Loopring",chains:["ETH","LRC"],popular:!1},{code:"LSK",name:"Lisk",chains:["LSK"],popular:!1},{code:"MANA",name:"Decentraland",chains:["ETH"],popular:!1},{code:"MBX",name:"Marblex",chains:["IMMUTABLE_ZKEVM","KLAY"],popular:!1},{code:"MELANIA",name:"Melania",chains:["SOL"],popular:!1},{code:"METAMASKUSD",name:"Metamask USD",chains:["ETH","LINEA"],popular:!1},{code:"METIS",name:"Metis",chains:["METIS"],popular:!1},{code:"MEZOUSD",name:"MUSD",chains:["ETH","MEZO"],popular:!1},{code:"MKR",name:"Maker",chains:["ETH","BSC"],popular:!1},{code:"MNEE",name:"MNEE",chains:["BSV","ETH"],popular:!1},{code:"MNT",name:"Mantle",chains:["ETH","MNT"],popular:!1},{code:"MOB",name:"MobileCoin",chains:["MOB"],popular:!1},{code:"MON",name:"Monad",chains:["MONAD"],popular:!1},{code:"MOVE",name:"Movement",chains:["MOVE"],popular:!1},{code:"MOVR",name:"Moonriver",chains:["MOVR"],popular:!1},{code:"MYTH",name:"Myth",chains:["MYTH"],popular:!1},{code:"NEAR",name:"NEAR Protocol",chains:["NEAR","BSC"],popular:!1},{code:"NEIRO",name:"NEIRO Ethereum",chains:["ETH"],popular:!1},{code:"OAS",name:"Oasys",chains:["OAS"],popular:!1},{code:"OMG",name:"OmiseGo",chains:["ETH"],popular:!1},{code:"OMUSD",name:"Open Money USD",chains:["ETH"],popular:!1},{code:"ONE",name:"Harmony",chains:["ONE","BNB","ETH"],popular:!1},{code:"OP",name:"Optimism",chains:["OPTIMISM"],popular:!1},{code:"ORDER",name:"Orderly Network",chains:["ETH"],popular:!1},{code:"PEAQ",name:"Peaq",chains:["PEAQ_EVM"],popular:!1},{code:"PEN",name:"Pendulum",chains:["PEN"],popular:!1},{code:"PERC",name:"Perion",chains:["ETH"],popular:!1},{code:"PI",name:"Pi",chains:["PI"],popular:!1},{code:"PLMC",name:"Polimec",chains:["PLMC"],popular:!1},{code:"POL",name:"Polygon",chains:["ETH","MATIC"],popular:!1},{code:"POLYX",name:"Polymesh",chains:["POLYX"],popular:!1},{code:"PROPC",name:"Propchain",chains:["ETH"],popular:!1},{code:"PSTAKE",name:"pSTAKE Finance",chains:["ETH"],popular:!1},{code:"Q",name:"QuantumCoin",chains:["Q"],popular:!1},{code:"QRDO",name:"Qredo",chains:["ETH"],popular:!1},{code:"QRL",name:"Quantum Resistant Ledger",chains:["QRL"],popular:!1},{code:"QUBIC",name:"QUBIC",chains:["QUBIC"],popular:!1},{code:"RBX",name:"ReserveBlock",chains:["RBX"],popular:!1},{code:"REVU",name:"Revuto",chains:["ADA"],popular:!1},{code:"RITE",name:"Ritestream",chains:["BSC"],popular:!1},{code:"RLUSD",name:"Ripple USD",chains:["ETH"],popular:!1},{code:"RON",name:"Ronin",chains:["RON"],popular:!1},{code:"RUNE",name:"THORChain",chains:["THORCHAIN"],popular:!1},{code:"S",name:"Sonic",chains:["S"],popular:!1},{code:"SAND",name:"The Sandbox",chains:["ETH","BSC"],popular:!1},{code:"SEI",name:"SEI",chains:["SEI_EVM"],popular:!1},{code:"SNX",name:"Synthetix",chains:["ETH"],popular:!1},{code:"SOIL",name:"Sun Minimeal",chains:["PLS"],popular:!1},{code:"SOLO",name:"Sologenic",chains:["XRP"],popular:!1},{code:"SOMI",name:"Somnia",chains:["SOMI"],popular:!1},{code:"STRK",name:"Starknet",chains:["STARK"],popular:!1},{code:"SUI",name:"Sui",chains:["SUI"],popular:!1},{code:"SUPR",name:"SuperDapp",chains:["ROLLUX"],popular:!1},{code:"SUPRA",name:"Supra",chains:["SUPRA"],popular:!1},{code:"SUSHI",name:"SushiSwap",chains:["ETH","BSC"],popular:!1},{code:"SYS",name:"Syscoin",chains:["ROLLUX"],popular:!1},{code:"TBTC",name:"tBTC",chains:["SUI","STARK"],popular:!1},{code:"TON",name:"Toncoin",chains:["TON"],popular:!1},{code:"TRUMP",name:"TRUMP",chains:["SOL"],popular:!1},{code:"TRX",name:"Tron",chains:["TRON","BSC"],popular:!1},{code:"TWT",name:"Trust Wallet Token",chains:["BSC"],popular:!1},{code:"UNI",name:"Uniswap",chains:["ETH","BSC"],popular:!1},{code:"URANIUM",name:"Uranium",chains:["ETHERLINK"],popular:!1},{code:"USD0",name:"Usual USD",chains:["ETH"],popular:!1},{code:"USD1",name:"World Liberty Financial USD",chains:["SOL"],popular:!1},{code:"USDE",name:"Ethena USDe",chains:["ETH"],popular:!1},{code:"USDP",name:"Pax Dollar",chains:["ETH"],popular:!1},{code:"USDQ",name:"Quantoz USDQ",chains:["ETH"],popular:!1},{code:"USDR",name:"StablR USD",chains:["ETH"],popular:!1},{code:"USDT0",name:"USDT0",chains:["INK"],popular:!1},{code:"VFX",name:"VerifiedX",chains:["VERIFIEDX"],popular:!1},{code:"VERSE",name:"Verse",chains:["ETH","MATIC"],popular:!1},{code:"VIC",name:"Viction",chains:["VIC"],popular:!1},{code:"WAL",name:"Walrus",chains:["SUI"],popular:!1},{code:"WAVES",name:"Waves",chains:["WAVES"],popular:!1},{code:"WAXP",name:"WAX",chains:["WAX"],popular:!1},{code:"WBTC",name:"Wrapped Bitcoin",chains:["ETH","STARK"],popular:!1},{code:"WETH",name:"Wrapped Ether",chains:["ETHERLINK"],popular:!1},{code:"WLD",name:"Worldcoin",chains:["WLD"],popular:!1},{code:"WLFI",name:"World Liberty Financial",chains:["ETH"],popular:!1},{code:"WOLF",name:"LandWolf",chains:["ETH"],popular:!1},{code:"WOMBAT",name:"Wombat",chains:["MATIC"],popular:!1},{code:"XCH",name:"Chia",chains:["XCH"],popular:!1},{code:"XLM",name:"Stellar Lumens",chains:["XLM","BSC"],popular:!1},{code:"XPRT",name:"Persistence",chains:["XPRT"],popular:!1},{code:"XTZ",name:"Tezos",chains:["XTZ","ETHERLINK"],popular:!1},{code:"YFI",name:"yearn.finance",chains:["ETH"],popular:!1},{code:"ZBU",name:"Zeebu",chains:["BSC"],popular:!1},{code:"ZEC",name:"ZCash",chains:["ZEC"],popular:!1},{code:"ZCHF",name:"Frankencoin",chains:["ETH"],popular:!1},{code:"ZETA",name:"Zeta",chains:["ETH","ZETACHAIN"],popular:!1},{code:"ZTG",name:"Zeitgeist",chains:["ZTG"],popular:!1}],dm={USD:"us",EUR:"eu",GBP:"gb",JPY:"jp",CAD:"ca",AUD:"au",BRL:"br",CHF:"ch",MXN:"mx",INR:"in",ARS:"ar",ALL:"al"};function qc(e,t=""){return`${t}/crypto-icons/${e.toLowerCase()}.svg`}function fm(e,t=""){const n=dm[e]||"us";return`${t}/flags/${n}.svg`}function ys(e,t=""){const n=Gl[e];return n?`${t}/crypto-icons/${n.icon}.svg`:`${t}/crypto-icons/${e.toLowerCase()}.svg`}const bc=[{code:"ALL",name:"Albania Lek"},{code:"ARS",name:"Argentina Peso"},{code:"AUD",name:"Australian Dollar"},{code:"BRL",name:"Brazilian Real"},{code:"CAD",name:"Canadian Dollar"},{code:"EUR",name:"Euro"},{code:"GBP",name:"British Pound"},{code:"JPY",name:"Japanese Yen"},{code:"USD",name:"US Dollar"},{code:"CHF",name:"Swiss Franc"},{code:"MXN",name:"Mexican Peso"},{code:"INR",name:"Indian Rupee"}],ed=[{id:"blue",name:"Blue",accent:"#0077FF"},{id:"violet",name:"Violet",accent:"#7C3AED"},{id:"green",name:"Green",accent:"#10B981"},{id:"orange",name:"Orange",accent:"#F59E0B"},{id:"rose",name:"Rose",accent:"#F43F5E"},{id:"mono",name:"Mono",accent:null}];function pm(e){return parseFloat(e.replace(/,/g,""))||0}const vs=e=>/^#([0-9A-Fa-f]{3}){1,2}$/.test(e),td=10,nd=1e-4,mm=(()=>{const e=[];for(const t of cm)for(const n of t.chains)e.push({code:t.code,name:t.name,chain:n,popular:t.popular});return e})();function rd({ticker:e,size:t=32,baseUrl:n=""}){return u.jsx("img",{src:qc(e,n),alt:e,width:t,height:t,className:"rounded-full shrink-0",style:{width:t,height:t}})}function gs({currencyCode:e,size:t=16,baseUrl:n=""}){return u.jsx("img",{src:fm(e,n),alt:e,width:t,height:t,className:"rounded-full shrink-0",style:{width:t,height:t}})}function Zl(){return u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:u.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"var(--t-text-secondary)",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function hm(){return u.jsx("svg",{width:"8",height:"14",viewBox:"0 0 8 14",fill:"none",children:u.jsx("path",{d:"M1 1L7 7L1 13",stroke:"var(--t-icon-stroke)",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function ym({onClick:e}){return u.jsx("button",{onClick:e,className:"hover:opacity-70 transition-opacity",children:u.jsx("svg",{width:"24",height:"16",viewBox:"0 0 24 16",fill:"none",children:u.jsx("path",{d:"M4 0.799805H20C21.7673 0.799805 23.2002 2.23269 23.2002 4V12C23.2002 13.7673 21.7673 15.2002 20 15.2002H4C2.23269 15.2002 0.799805 13.7673 0.799805 12V4C0.799805 2.23269 2.23269 0.799805 4 0.799805Z",stroke:"var(--t-icon-stroke)",strokeWidth:"1.6"})})})}function vm({size:e=40}){return u.jsx("div",{className:"rounded-full flex items-center justify-center shrink-0",style:{width:e,height:e,background:"var(--t-surface)"},children:u.jsxs("svg",{width:e*.5,height:e*.5,viewBox:"0 0 20 20",fill:"none",children:[u.jsx("circle",{cx:"10",cy:"10",r:"7.5",stroke:"var(--t-text)",strokeWidth:"1.5"}),u.jsx("path",{d:"M10 2.5A7.5 7.5 0 0 1 10 17.5",fill:"var(--t-text)"})]})})}function xs({onClick:e}){return u.jsx("button",{onClick:e,className:"flex items-center justify-center transition-colors rounded-full shrink-0",style:{width:30,height:30,backgroundColor:"var(--t-close-bg)"},onMouseEnter:t=>t.currentTarget.style.backgroundColor="var(--t-close-hover)",onMouseLeave:t=>t.currentTarget.style.backgroundColor="var(--t-close-bg)",children:u.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:u.jsx("path",{d:"M1 1L9 9M9 1L1 9",stroke:"var(--t-icon-close)",strokeWidth:"1.4",strokeLinecap:"round"})})})}function ld({value:e,onChange:t,placeholder:n=""}){return u.jsxs("div",{className:"relative mx-5 mb-5",children:[u.jsx("input",{type:"text",value:e,onChange:r=>t(r.target.value),placeholder:n,style:{height:47,borderRadius:4.5,borderColor:"var(--t-border)",color:"var(--t-text)",paddingLeft:14,paddingRight:e?40:14,fontSize:14},className:"w-full bg-transparent border outline-none transition-colors"}),e&&u.jsx("button",{onClick:()=>t(""),className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center justify-center transition-colors rounded",style:{width:22,height:22,backgroundColor:"var(--t-close-bg)",borderRadius:4},children:u.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:u.jsx("path",{d:"M1 1L7 7M7 1L1 7",stroke:"var(--t-icon-close)",strokeWidth:"1.2",strokeLinecap:"round"})})})]})}function gm({onClose:e,onSelect:t,currencies:n,assetBaseUrl:r=""}){const[l,o]=k.useState(""),i=k.useMemo(()=>{if(!n||n.length===0)return bc;const a=new Map(bc.map(c=>[c.code,c.name]));return n.map(c=>({code:c.code,name:c.name||a.get(c.code)||c.code}))},[n]),s=k.useMemo(()=>{const a=l.trim().toLowerCase();return a?i.filter(c=>c.code.toLowerCase().includes(a)||c.name.toLowerCase().includes(a)):i},[i,l]);return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"flex justify-end px-5 pt-5",children:u.jsx(xs,{onClick:e})}),u.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)"},children:"Select fiat currency"}),u.jsx(ld,{value:l,onChange:o}),u.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[s.map(a=>u.jsxs("button",{onClick:()=>t(a.code),className:"flex items-center gap-3.5 w-full py-3.5 transition-colors",style:{color:"var(--t-text)"},children:[u.jsx(gs,{currencyCode:a.code,size:32,baseUrl:r}),u.jsxs("div",{className:"text-left",children:[u.jsx("div",{className:"font-semibold text-[15px] leading-tight",children:a.code}),u.jsx("div",{className:"text-[13px] mt-0.5",style:{color:"var(--t-text-secondary)"},children:a.name})]})]},a.code)),s.length===0&&u.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No currencies found"})]})]})}function xm({onClose:e,onSelect:t,cryptos:n,assetBaseUrl:r=""}){const[l,o]=k.useState(""),i=k.useMemo(()=>{if(!n||n.length===0)return mm;const a=[];for(const c of n){const y=c.networks||[];if(y.length===0)a.push({code:c.code,name:c.name||c.code,chain:c.code,popular:!1});else for(const m of y){const h=m.code||m.id||m.name||c.code;a.push({code:c.code,name:c.name||c.code,chain:h,chainName:m.name,popular:!1})}}return a},[n]),s=k.useMemo(()=>{var m;const a=l.trim().toLowerCase();if(!a)return i;const c=a.split(/\s+/),y=[];for(const h of i){const x=Gl[h.chain],g=x?x.name.toLowerCase():"",S=((m=x==null?void 0:x.shortName)==null?void 0:m.toLowerCase())||"",_=h.chain.toLowerCase(),f=h.code.toLowerCase(),d=h.name.toLowerCase(),p=[f,d,g,S,_];if(!c.every(A=>p.some(v=>v.includes(A))))continue;let C=0;f===a?C+=100:f.startsWith(c[0])&&(C+=50),h.popular&&(C+=10),c.length>1&&(g.includes(c[1])||S.includes(c[1])||_.includes(c[1]))&&(C+=25),y.push({item:h,score:C})}return y.sort((h,x)=>x.score-h.score),y.map(h=>h.item)},[i,l]);return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"flex justify-end px-5 pt-5",children:u.jsx(xs,{onClick:e})}),u.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)"},children:"Select crypto currency"}),u.jsx(ld,{value:l,onChange:o}),u.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[s.map(a=>{const c=Gl[a.chain],y=(c==null?void 0:c.name)||a.chainName||a.chain;return u.jsxs("button",{onClick:()=>t(a.code,a.chain),className:"flex items-center gap-3.5 w-full py-3.5 transition-colors",children:[u.jsxs("div",{className:"relative shrink-0",style:{width:40,height:40},children:[u.jsx("img",{src:qc(a.code,r),alt:a.code,width:32,height:32,className:"rounded-full absolute top-0 left-0",style:{width:32,height:32}}),u.jsx("img",{src:ys(a.chain,r),alt:a.chain,width:16,height:16,className:"rounded-full absolute",style:{width:16,height:16,bottom:0,right:0,border:"2px solid var(--t-chain-border)"}})]}),u.jsxs("div",{className:"text-left flex-1 min-w-0",children:[u.jsx("div",{className:"font-semibold text-[15px] leading-tight",style:{color:"var(--t-text)"},children:a.code}),u.jsx("div",{className:"text-[13px] mt-0.5",style:{color:"var(--t-text-secondary)"},children:a.name})]}),u.jsx("div",{className:"text-right shrink-0",children:u.jsx("div",{className:"text-[13px]",style:{color:"var(--t-text-muted)"},children:y})})]},`${a.code}-${a.chain}`)}),s.length===0&&u.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No currencies found"})]})]})}function wm({checked:e,onChange:t,accentColor:n="var(--t-accent)"}){return u.jsx("button",{onClick:()=>t(!e),className:"relative shrink-0 transition-colors duration-200",style:{width:48,height:28,borderRadius:14,backgroundColor:e?n:"var(--t-border)"},children:u.jsx("div",{className:"absolute top-[3px] rounded-full bg-white shadow transition-transform duration-200",style:{width:22,height:22,transform:e?"translateX(23px)":"translateX(3px)"}})})}const Sm=[{label:"Privacy policy",href:"https://nowramp.com/privacy-policy"},{label:"Terms of use",href:"https://nowramp.com/terms-and-conditions"}];function Em({onClose:e,darkMode:t,onToggleDarkMode:n,skinId:r,onSelectSkin:l}){return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"flex justify-end items-center px-5 pt-5",children:u.jsx(xs,{onClick:e})}),u.jsxs("div",{className:"px-5 flex-1 pt-6 overflow-y-auto custom-scroll",children:[u.jsx("div",{style:{borderTop:"1px solid var(--t-divider)"},children:u.jsxs("div",{className:"flex items-center justify-between w-full py-5",children:[u.jsxs("div",{className:"flex items-center gap-3.5",children:[u.jsx(vm,{size:40}),u.jsx("span",{className:"font-medium text-[15px]",style:{color:"var(--t-text)"},children:"Dark Mode"})]}),u.jsx(wm,{checked:t,onChange:n,accentColor:"#4CD964"})]})}),u.jsx("div",{style:{height:1,background:"var(--t-divider)"}}),Sm.map(o=>u.jsxs("div",{children:[u.jsxs("a",{href:o.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between w-full py-5 transition-colors",children:[u.jsx("span",{className:"font-medium text-[15px]",style:{color:"var(--t-text)"},children:o.label}),u.jsx(hm,{})]}),u.jsx("div",{style:{height:1,background:"var(--t-divider)"}})]},o.label))]})]})}function km({className:e="",theme:t="dark",skinId:n="mono",accentColor:r,bgColor:l,bgImage:o,borderColor:i,borderRadius:s,showFlowToggle:a=!0,autoRedirect:c=!1,explorerUrl:y,doneButtonText:m="Done",supportEmail:h,onDone:x}){var md,hd,yd,vd,gd,xd,wd;const{state:g,dispatch:S,config:_,configLoading:f,quotes:d,quotesLoading:p,quotesError:w,fetchQuotes:C,createOrder:A,orderLoading:v,amountError:T,fieldLocks:R,apiConfig:L,assetBaseUrl:Q}=Mn(),[fe,pe]=k.useState(t==="dark"),[tn,nn]=k.useState(n),[pt,Re]=k.useState(null),[N,P]=k.useState(!1),[I,B]=k.useState(!1),[V,mt]=k.useState(!1),[ae,Ze]=k.useState(null),[ke,ht]=k.useState(!0),[Jl,ql]=k.useState(!1),[Ut,Fn]=k.useState(!1),ws=k.useRef(null),Lr=k.useRef(),F=k.useRef(g.flowType);k.useEffect(()=>{pe(t==="dark")},[t]),k.useEffect(()=>{const M=setTimeout(()=>ht(!1),f?0:800);return()=>clearTimeout(M)},[f]),k.useEffect(()=>{if(F.current!==g.flowType&&!ke){F.current=g.flowType,ql(!0),P(!1),B(!1);const M=setTimeout(()=>ql(!1),350);return()=>clearTimeout(M)}F.current=g.flowType},[g.flowType,ke]);const Z=g.flowType,ne=Z==="buy",re=g.cryptoCurrency||"BTC",q=g.fiatCurrency||"USD",Je=ne?g.fiatAmount:g.cryptoAmount,rn=pm(Je),Un=(md=d==null?void 0:d.bestQuote)!=null&&md.exchangeRate?parseFloat(d.bestQuote.exchangeRate):null,bl=k.useRef(null);Un&&re&&q&&(bl.current={rate:Un,crypto:re,fiat:q});const Tm=k.useMemo(()=>{if(d!=null&&d.bestQuote){const M=ne?d.bestQuote.cryptoAmount:d.bestQuote.fiatAmount;if(M)return M}return"0"},[d,ne]),jm=k.useMemo(()=>{var ge,Bt,ks;const M=Un||((ge=bl.current)==null?void 0:ge.rate),z=Un?re:(Bt=bl.current)==null?void 0:Bt.crypto,ee=Un?q:(ks=bl.current)==null?void 0:ks.fiat;return!M||!z||!ee?"":`1 ${z} ≈ ${M.toFixed(2)} ${ee}`},[re,q,Un]);k.useEffect(()=>{const M=g.walletAddress.trim(),z=g.network;if(!M||M.length<10){Ze(null),S({type:"SET_WALLET_ERROR",message:""});return}return mt(!0),Ze(null),clearTimeout(Lr.current),Lr.current=setTimeout(async()=>{var ee,ge,Bt;try{const Cs=await(await fetch(`${L.apiUrl}/public/validate/address`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:M,...z?{network:z}:{}})})).json(),Ns=((ee=Cs.data)==null?void 0:ee.attributes)||Cs.data||Cs;if(Ns.isValid)Ze(!0),S({type:"SET_WALLET_ERROR",message:""});else{Ze(!1);const Om=((ge=Ns.errors)==null?void 0:ge[0])||((Bt=Ns.details)==null?void 0:Bt.formatMessage)||"Invalid wallet address";S({type:"SET_WALLET_ERROR",message:Om})}}catch{Ze(null)}finally{mt(!1)}},500),()=>clearTimeout(Lr.current)},[g.walletAddress,g.network,L.apiUrl]);const id=!Je||rn===0,sd=rn>0&&(ne?rn<td:rn<nd),ad=!!T||sd||N&&id,Am=rn>0&&!T&&!sd,Ss=g.walletAddress.trim().length>=10&&ae!==!1&&!V,eo=Am&&Ss&&!!g.cryptoCurrency&&!!g.network,Rm=M=>{let z=M.target.value.replace(/[^0-9.,]/g,"");const ee=ne?2:6,ge=z.indexOf(".");ge!==-1&&z.length-ge-1>ee&&(z=z.slice(0,ge+ee+1)),S(ne?{type:"SET_FIAT_AMOUNT",amount:z}:{type:"SET_CRYPTO_AMOUNT",amount:z})},ud=M=>{M!==Z&&S({type:"SET_FLOW_TYPE",flowType:M})},Lm=k.useCallback(M=>{S({type:"SET_FIAT_CURRENCY",currency:M})},[S]),Pm=k.useCallback((M,z)=>{S({type:"SET_CRYPTO_CURRENCY",currency:M}),S({type:"SET_CRYPTO_CHAIN",chain:z})},[S]),Im=()=>{eo&&(Fn(!0),C())};k.useEffect(()=>{var M;if(!(!Ut||p)){if(d!=null&&d.bestQuote)Fn(!1),S({type:"SELECT_QUOTE",quote:d.bestQuote}),A().catch(()=>{});else if(w)Fn(!1),S({type:"SET_ERROR",message:w.message||"No quotes available"});else if(d&&!d.bestQuote){Fn(!1);const z=(M=d.unavailableGateways)==null?void 0:M.map(ge=>ge.reason).filter(Boolean),ee=z!=null&&z.length?`No providers available: ${z.join("; ")}`:"No providers available for this currency/network combination";S({type:"SET_ERROR",message:ee})}}},[Ut,d,p,w,S,A]);const cd=fe?"theme-dark":"theme-light",Es=ed.find(M=>M.id===tn)||ed[0],_m=Es.accent===null,dd=(r?vs(r):!1)?{"--t-accent":r,"--t-cta-bg":r,"--t-cta-text":"#ffffff"}:_m?{"--t-accent":fe?"#ffffff":"#111111","--t-cta-bg":fe?"#ffffff":"#111111","--t-cta-text":fe?"#000000":"#ffffff"}:{"--t-accent":Es.accent,"--t-cta-bg":Es.accent,"--t-cta-text":"#ffffff"},ln={};l&&vs(l)?ln.backgroundColor=l:ln.backgroundColor="var(--t-bg)",o&&(ln.backgroundImage=`url(${o})`,ln.backgroundSize="cover",ln.backgroundPosition="center");const to={};i&&vs(i)&&(to.border=`1px solid ${i}`),s&&(to.borderRadius=s);const fd=g.step==="checkout"?u.jsx(tm,{autoRedirect:c}):g.step==="processing"?u.jsx(rm,{}):g.step==="complete"?u.jsx(lm,{explorerUrl:y,doneButtonText:m,onDone:x}):g.step==="error"?u.jsx(om,{supportEmail:h}):g.step==="confirm"?u.jsx(im,{}):null;if(fd)return u.jsx("div",{className:`${cd} relative w-full max-w-[390px] h-[640px] overflow-hidden flex flex-col select-none transition-colors duration-300 ${e}`,style:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...ln,...dd,...to},children:fd});const yt=g.network,Bn=yt?Gl[yt]:null,pd=(Bn==null?void 0:Bn.shortName)||(Bn==null?void 0:Bn.name)||yt;return u.jsxs("div",{className:`${cd} relative w-full max-w-[390px] min-h-[640px] overflow-hidden flex flex-col select-none transition-colors duration-300 ${e}`,style:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...ln,...dd,...to},children:[u.jsx("div",{className:`flex justify-end items-center px-5 pt-3 ${a?"pb-1":"pb-5"}`,children:u.jsx(ym,{onClick:()=>Re("settings")})}),a?u.jsxs("div",{className:"flex flex-col items-center pt-3 pb-5",children:[u.jsxs("div",{className:"flex",style:{width:165},children:[u.jsx("button",{onClick:()=>ud("buy"),className:"flex-1 pb-2.5 text-[16px] font-medium text-center transition-colors duration-200",style:{color:Z==="buy"?"var(--t-text)":"var(--t-text-secondary)"},children:"Buy"}),u.jsx("button",{onClick:()=>ud("sell"),className:"flex-1 pb-2.5 text-[16px] font-medium text-center transition-colors duration-200",style:{color:Z==="sell"?"var(--t-text)":"var(--t-text-secondary)"},children:"Sell"})]}),u.jsxs("div",{className:"relative",style:{width:165,height:1},children:[u.jsx("div",{className:"absolute inset-0",style:{background:"var(--t-divider)"}}),u.jsx("div",{className:"absolute top-0 h-full transition-all duration-300 ease-in-out",style:{width:"50%",left:Z==="buy"?"0%":"50%",background:"var(--t-accent)"}})]})]}):null,ke||Jl||f?u.jsx(um,{}):u.jsxs("div",{className:"flex-1 overflow-hidden px-5 flex flex-col tab-fade-in",children:[u.jsxs("div",{className:"px-[18px] pt-[14px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5,border:N&&ad?"1px solid #EF4444":"1px solid transparent"},children:[u.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"You spend"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("input",{ref:ws,type:"text",value:Je,onChange:Rm,onBlur:()=>P(!0),placeholder:ne?"250":"0.01",className:"bg-transparent outline-none w-0 flex-1 mr-3",style:{color:"var(--t-text)",fontSize:24,fontWeight:600,lineHeight:"32px"},inputMode:"decimal",disabled:!!((hd=R==null?void 0:R.sourceAmount)!=null&&hd.locked)}),ne?u.jsxs("button",{onClick:()=>Re("fiat"),className:"flex items-center gap-1.5 shrink-0 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((yd=R==null?void 0:R.sourceCurrency)!=null&&yd.locked),children:[u.jsx(gs,{currencyCode:q,size:16,baseUrl:Q}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:q}),u.jsx(Zl,{})]}):u.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[u.jsxs("button",{onClick:()=>Re("crypto"),className:"flex items-center gap-1.5 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((vd=R==null?void 0:R.destinationCurrency)!=null&&vd.locked),children:[u.jsx(rd,{ticker:re,size:16,baseUrl:Q}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:re}),u.jsx(Zl,{})]}),yt&&u.jsxs("div",{className:"flex items-center gap-1 mt-1.5 mr-0.5",children:[u.jsx("img",{src:ys(yt,Q),alt:yt,width:14,height:14,className:"rounded-full",style:{width:14,height:14}}),u.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:pd})]})]})]})]}),N&&ad&&u.jsx("div",{className:"text-[12px] mt-1.5 px-[2px]",style:{color:"#EF4444"},children:T||(id?"Amount should be more than 0":ne?`Minimum amount is ${td} ${q}`:`Minimum amount is ${nd} ${re}`)}),u.jsxs("div",{className:"px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)",borderTopLeftRadius:5,borderTopRightRadius:5,borderBottomLeftRadius:0,borderBottomRightRadius:0,marginTop:4},children:[u.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"You get"}),u.jsxs("div",{className:"flex items-start justify-between",children:[p?u.jsx($e,{w:180,h:32}):u.jsx(am,{value:rn>0?Tm:"0",height:32,className:"font-semibold",style:{color:rn>0?"var(--t-text)":"var(--t-text-muted)",fontSize:24}}),ne?u.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[u.jsxs("button",{onClick:()=>Re("crypto"),className:"flex items-center gap-1.5 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((gd=R==null?void 0:R.destinationCurrency)!=null&&gd.locked),children:[u.jsx(rd,{ticker:re,size:16,baseUrl:Q}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:re}),u.jsx(Zl,{})]}),yt&&u.jsxs("div",{className:"flex items-center gap-1 mt-1.5 mr-0.5",children:[u.jsx("img",{src:ys(yt,Q),alt:yt,width:14,height:14,className:"rounded-full",style:{width:14,height:14}}),u.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:pd})]})]}):u.jsxs("button",{onClick:()=>Re("fiat"),className:"flex items-center gap-1.5 shrink-0 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((xd=R==null?void 0:R.sourceCurrency)!=null&&xd.locked),children:[u.jsx(gs,{currencyCode:q,size:16,baseUrl:Q}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:q}),u.jsx(Zl,{})]})]})]}),u.jsx("div",{className:"flex items-center justify-between mt-[2px] px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)"},children:u.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-secondary)"},children:jm||" "})}),u.jsxs("div",{className:"mt-8",children:[u.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"Wallet address"}),u.jsx("input",{type:"text",value:g.walletAddress,onChange:M=>S({type:"SET_WALLET_ADDRESS",address:M.target.value}),onBlur:()=>B(!0),placeholder:"Enter your wallet address",spellCheck:!1,autoComplete:"off",className:"w-full bg-transparent text-[13px] outline-none transition-colors",style:{border:g.walletError||I&&!Ss?"1px solid #EF4444":"1px solid var(--t-border)",borderRadius:3.5,height:47,paddingLeft:14,paddingRight:14,color:"var(--t-text)"},disabled:!!((wd=R==null?void 0:R.destinationAddress)!=null&&wd.locked)}),g.walletError?u.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"#EF4444"},children:g.walletError}):I&&!Ss&&!V?u.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"#EF4444"},children:"Enter a valid wallet address"}):V&&g.walletAddress.trim().length>=10?u.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"var(--t-text-muted)"},children:"Validating address..."}):null]}),u.jsx("div",{className:"flex-1"}),u.jsx("button",{disabled:!eo||v||Ut,onClick:Im,className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",opacity:eo&&!v&&!Ut?1:.4,cursor:eo&&!v&&!Ut?"pointer":"not-allowed"},children:Ut?"Getting best price...":v?"Processing...":ne?`Buy ${re}`:`Sell ${re}`}),u.jsx("div",{className:"text-center py-3",children:u.jsx("span",{className:"text-[11px]",style:{color:"var(--t-text-tertiary)"},children:"Powered by NowRamp"})})]},Z),u.jsx(hs,{isOpen:pt==="fiat",onClose:()=>Re(null),children:M=>{var z;return u.jsx(gm,{onClose:M,onSelect:ee=>{Lm(ee),M()},currencies:(z=_==null?void 0:_.fiats)==null?void 0:z.map(ee=>({code:ee.code,name:ee.code})),assetBaseUrl:Q})}}),u.jsx(hs,{isOpen:pt==="crypto",onClose:()=>Re(null),children:M=>{var z;return u.jsx(xm,{onClose:M,onSelect:(ee,ge)=>{Pm(ee,ge),M()},cryptos:(z=_==null?void 0:_.cryptos)==null?void 0:z.map(ee=>{var ge;return{code:ee.code,name:ee.code,networks:(ge=ee.networks)==null?void 0:ge.map(Bt=>({code:Bt.id,name:Bt.name}))}}),assetBaseUrl:Q})}}),u.jsx(hs,{isOpen:pt==="settings",onClose:()=>Re(null),children:M=>u.jsx(Em,{onClose:M,darkMode:fe,onToggleDarkMode:pe,skinId:tn,onSelectSkin:z=>{nn(z)}})})]})}function od({projectId:e,apiUrl:t,assetBaseUrl:n,flowType:r,customerId:l,defaultFiatCurrency:o,defaultCryptoCurrency:i,defaultNetwork:s,defaultFiatAmount:a,defaultCryptoAmount:c,defaultWalletAddress:y,defaultGateway:m,fieldLocks:h,statusPollInterval:x,onComplete:g,onError:S,className:_,theme:f,skinId:d,accentColor:p,bgColor:w,bgImage:C,borderColor:A,borderRadius:v,showFlowToggle:T,autoRedirect:R,explorerUrl:L,doneButtonText:Q,supportEmail:fe,onDone:pe}){return u.jsx(em,{projectId:e,apiUrl:t,assetBaseUrl:n,flowType:r,customerId:l,defaultFiatCurrency:o,defaultCryptoCurrency:i,defaultNetwork:s,defaultFiatAmount:a,defaultCryptoAmount:c,defaultWalletAddress:y,defaultGateway:m,fieldLocks:h,statusPollInterval:x,onComplete:g,onError:S,children:u.jsx(km,{className:_,theme:f,skinId:d,accentColor:p,bgColor:w,bgImage:C,borderColor:A,borderRadius:v,showFlowToggle:T,autoRedirect:R,explorerUrl:L,doneButtonText:Q,supportEmail:fe,onDone:pe})})}const Rr=new Map;function Cm(e,t){const n=typeof e=="string"?document.querySelector(e):e;if(!n){console.error(`[NowRampForm] Element not found: ${e}`);return}const r=Rr.get(n);r&&(r.unmount(),Rr.delete(n));const l=Vc(n);Rr.set(n,l),l.render(Mr.createElement(od,t))}function Nm(e){const t=typeof e=="string"?document.querySelector(e):e;if(!t)return;const n=Rr.get(t);n&&(n.unmount(),Rr.delete(t))}Pr.RampForm=od,Pr.mount=Cm,Pr.unmount=Nm,Object.defineProperty(Pr,Symbol.toStringTag,{value:"Module"})})(this.NowRampForm=this.NowRampForm||{});
54
+ */class Yl{constructor(t){this.config=t,this.baseUrl=t.apiUrl||"https://api.nowramp.com"}async getRate(t){var o,i,s,a,c,y;if(!this.config.apiKey)return this.getPublicRate(t);const n=await fetch(`${this.baseUrl}/v1/rates/convert`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({from:t.from,to:t.to,amount:t.amount,flowType:t.flowType||"buy"})});if(!n.ok){const m=await n.json().catch(()=>({})),h=((o=m.error)==null?void 0:o.message)||m.message||`HTTP ${n.status}`;throw new Error(`Failed to get rate: ${h}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{rate:l.rate,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationAmount:l.destinationAmount,destinationCurrency:l.destinationCurrency,fees:{processingFee:((s=l.fees)==null?void 0:s.processingFee)||0,processingFeePercent:((a=l.fees)==null?void 0:a.processingFeePercent)||0,networkFee:((c=l.fees)==null?void 0:c.networkFee)||0,totalFee:((y=l.fees)==null?void 0:y.totalFee)||0},provider:l.provider||"unknown",expiresAt:l.expiresAt}}async getPublicRate(t){var o,i,s,a,c,y;const n=await fetch(`${this.baseUrl}/public/wert/convert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:t.from,to:t.to,amount:t.amount,flowType:t.flowType||"buy"})});if(!n.ok){const m=await n.json().catch(()=>({})),h=((o=m.error)==null?void 0:o.message)||m.message||`HTTP ${n.status}`;throw new Error(`Failed to get rate: ${h}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{rate:l.ticker||l.rate,sourceAmount:l.currencyAmount||l.sourceAmount||t.amount,sourceCurrency:t.from,destinationAmount:l.commodityAmount||l.destinationAmount,destinationCurrency:t.to,fees:{processingFee:l.feeAmount||((s=l.fees)==null?void 0:s.processingFee)||0,processingFeePercent:l.feePercent||((a=l.fees)==null?void 0:a.processingFeePercent)||0,networkFee:l.currencyMinerFee||((c=l.fees)==null?void 0:c.networkFee)||0,totalFee:(l.feeAmount||0)+(l.currencyMinerFee||0)||((y=l.fees)==null?void 0:y.totalFee)||0},provider:"wert",expiresAt:l.expiresAt}}async getCurrencies(){var l,o;if(!this.config.apiKey)return this.getPublicCurrencies();const t=await fetch(`${this.baseUrl}/v1/rates/currencies`,{method:"GET",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!t.ok){const i=await t.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${t.status}`;throw new Error(`Failed to get currencies: ${s}`)}const n=await t.json(),r=((o=n.data)==null?void 0:o.attributes)||n.data||n;return{fiat:r.fiat||[],crypto:r.crypto||[],provider:r.provider||"unknown",environment:r.environment||"sandbox"}}async getPublicCurrencies(){var l,o;if(!this.config.projectId)throw new Error("projectId is required to fetch currencies without an API key");const t=await fetch(`${this.baseUrl}/public/projects/${this.config.projectId}/currencies`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const i=await t.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${t.status}`;throw new Error(`Failed to get currencies: ${s}`)}const n=await t.json(),r=((o=n.data)==null?void 0:o.attributes)||n.data||n;return{fiat:r.fiat||[],crypto:r.crypto||[],provider:r.provider||"unknown",environment:r.environment||"sandbox"}}async validateAddress(t){var l,o;const n=await fetch(`${this.baseUrl}/public/validate/address`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to validate address: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async validateAddressBatch(t){var l,o;if(t.length>20)throw new Error("Maximum 20 addresses per batch");const n=await fetch(`${this.baseUrl}/public/validate/address/batch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({addresses:t})});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to validate addresses: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async getSupportedNetworks(){var r,l;const t=await fetch(`${this.baseUrl}/public/validate/networks`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const o=await t.json().catch(()=>({})),i=((r=o.error)==null?void 0:r.message)||o.message||`HTTP ${t.status}`;throw new Error(`Failed to get supported networks: ${i}`)}const n=await t.json();return((l=n.data)==null?void 0:l.attributes)||n.data||n}async createSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to create sessions. Use a secret key (sk_) for this operation.");const n=await fetch(`${this.baseUrl}/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify(t)});if(!n.ok){const a=await n.json().catch(()=>({})),c=((o=a.error)==null?void 0:o.message)||a.message||`HTTP ${n.status}`;throw new Error(`Failed to create session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,clientSecret:l.clientSecret,type:l.type||"onramp",status:l.status||"pending",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,expiresAt:l.expiresAt,createdAt:l.createdAt}}async getSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to get session details.");const n=await fetch(`${this.baseUrl}/v1/sessions/${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!n.ok){const a=await n.json().catch(()=>({})),c=((o=a.error)==null?void 0:o.message)||a.message||`HTTP ${n.status}`;throw new Error(`Failed to get session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,type:l.type||"onramp",status:l.status||"pending",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,fieldLocks:l.fieldLocks,orderId:l.orderId,expiresAt:l.expiresAt,confirmedAt:l.confirmedAt,completedAt:l.completedAt,createdAt:l.createdAt}}async cancelSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to cancel sessions. Use a secret key (sk_) for this operation.");const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/cancel`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!n.ok){const a=await n.json().catch(()=>({})),c=((o=a.error)==null?void 0:o.message)||a.message||`HTTP ${n.status}`;throw new Error(`Failed to cancel session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,type:l.type||"onramp",status:l.status||"cancelled",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,orderId:l.orderId,expiresAt:l.expiresAt,confirmedAt:l.confirmedAt,completedAt:l.completedAt,createdAt:l.createdAt}}async getSupported(t){var o,i;if(!this.config.projectId)throw new Error("projectId is required to get supported config");const n=new URLSearchParams({projectId:this.config.projectId});t&&n.set("orderType",t);const r=await fetch(`${this.baseUrl}/public/v1/onramp/supported?${n}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){const s=await r.json().catch(()=>({})),a=((o=s.error)==null?void 0:o.message)||s.message||`HTTP ${r.status}`;throw new Error(`Failed to get supported config: ${a}`)}const l=await r.json();return((i=l.data)==null?void 0:i.attributes)||l.data||l}async getQuotes(t){var o,i;if(!this.config.projectId)throw new Error("projectId is required to get quotes");const n=new URLSearchParams({projectId:this.config.projectId,fiatCurrency:t.fiatCurrency,cryptoCurrency:t.cryptoCurrency,network:t.network});t.fiatAmount&&n.set("fiatAmount",t.fiatAmount),t.cryptoAmount&&n.set("cryptoAmount",t.cryptoAmount),t.orderType&&n.set("orderType",t.orderType),t.paymentMethodId&&n.set("paymentMethodId",t.paymentMethodId),t.country&&n.set("country",t.country);const r=await fetch(`${this.baseUrl}/public/v1/onramp/quotes?${n}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){const s=await r.json().catch(()=>({})),a=((o=s.error)==null?void 0:o.message)||s.message||`HTTP ${r.status}`;throw new Error(`Failed to get quotes: ${a}`)}const l=await r.json();return((i=l.data)==null?void 0:i.attributes)||l.data||l}async createCheckoutIntent(t){var l,o;if(!this.config.projectId)throw new Error("projectId is required to create checkout intents");const n=await fetch(`${this.baseUrl}/public/v1/onramp/checkout-intent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:this.config.projectId,...t})});if(!n.ok){const i=await n.json().catch(()=>({})),s=(typeof i.error=="string"?i.error:(l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;let a="";if(i.details)try{const c=typeof i.details=="string"?JSON.parse(i.details):i.details;if(c.errors&&typeof c.errors=="object"){const y=Object.values(c.errors).flat().filter(Boolean);y.length&&(a=y.join("; "))}}catch{}throw new Error(`Failed to create checkout intent: ${a||s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async getTransaction(t){var l,o;const n=await fetch(`${this.baseUrl}/public/v1/onramp/transactions/${t}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to get transaction: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}}function Gp(e,t){const[n,r]=k.useState(null),[l,o]=k.useState(!0),[i,s]=k.useState(null),a=k.useRef(null);(!a.current||a.current!==e)&&(a.current=new Yl({apiKey:"",...e}));const c=k.useCallback(async()=>{if(!e.projectId){s(new Error("projectId is required")),o(!1);return}o(!0),s(null);try{const y=await a.current.getSupported(t);r(y)}catch(y){s(y instanceof Error?y:new Error("Failed to fetch config"))}finally{o(!1)}},[e.projectId,t]);return k.useEffect(()=>{c()},[c]),{config:n,loading:l,error:i,refetch:c}}function Zp(e,t){const[n,r]=k.useState(null),[l,o]=k.useState(!1),[i,s]=k.useState(null),a=k.useRef(null),c=k.useRef(""),y=`${e.apiUrl}|${e.projectId}`;(!a.current||c.current!==y)&&(a.current=new Yl({apiKey:"",...e}),c.current=y);const m=k.useRef(0);k.useEffect(()=>{const x=++m.current;if(!t||!e.projectId){r(null),o(!1);return}o(!0),s(null),a.current.getQuotes(t).then(g=>{m.current===x&&(r(g),o(!1))},g=>{m.current===x&&(s(g instanceof Error?g:new Error("Failed to fetch quotes")),r(null),o(!1))})},[e.projectId,t==null?void 0:t.fiatCurrency,t==null?void 0:t.fiatAmount,t==null?void 0:t.cryptoAmount,t==null?void 0:t.cryptoCurrency,t==null?void 0:t.network,t==null?void 0:t.paymentMethodId,t==null?void 0:t.country,t==null?void 0:t.orderType]);const h=k.useCallback(async()=>{if(!(!t||!e.projectId)){o(!0),s(null);try{const x=await a.current.getQuotes(t);r(x)}catch(x){s(x instanceof Error?x:new Error("Failed to fetch quotes"))}finally{o(!1)}}},[e.projectId,t]);return{quotes:n,loading:l,error:i,refetch:h}}function Jp(e){const[t,n]=k.useState(null),[r,l]=k.useState(!1),[o,i]=k.useState(null),s=k.useRef(null),a=k.useRef(""),c=`${e.apiUrl}|${e.projectId}`;(!s.current||a.current!==c)&&(s.current=new Yl({apiKey:"",...e}),a.current=c);const y=k.useCallback(async h=>{l(!0),i(null);try{const x=await s.current.createCheckoutIntent(h);return n(x),x}catch(x){const g=x instanceof Error?x:new Error("Failed to create checkout intent");throw i(g),g}finally{l(!1)}},[]),m=k.useCallback(()=>{n(null),i(null)},[]);return{order:t,loading:r,error:o,createOrder:y,reset:m}}function qp(e,t,n){const[r,l]=k.useState(null),[o,i]=k.useState(!1),[s,a]=k.useState(null),c=k.useRef(null);c.current||(c.current=new Yl({apiKey:"",projectId:"",...e}));const y=k.useCallback(async()=>{if(t){i(!0),a(null);try{const m=await c.current.getTransaction(t);l(m)}catch(m){a(m instanceof Error?m:new Error("Failed to fetch status"))}finally{i(!1)}}},[t]);return k.useEffect(()=>{if(!t)return;const m=n==null?void 0:n.initialDelay;{const h=setTimeout(y,m);return()=>clearTimeout(h)}},[y,t,n==null?void 0:n.initialDelay]),k.useEffect(()=>{if(!t||!(n!=null&&n.pollInterval)||!r||["completed","failed","cancelled","expired","refunded"].includes(r.status))return;const h=setInterval(y,n.pollInterval);return()=>clearInterval(h)},[t,n==null?void 0:n.pollInterval,r==null?void 0:r.status,y]),{status:r,loading:o,error:s,refetch:y}}function Yc(e,t){if(!e)return e;const n=e.indexOf(".");if(n===-1)return e;let r=e;return r.length-n-1>t&&(r=r.slice(0,n+t+1)),r=r.replace(/0+$/,"").replace(/\.$/,""),r}const Gc={step:"amount",flowType:"buy",fiatCurrency:"USD",fiatAmount:"",cryptoCurrency:"",cryptoAmount:"",network:"",paymentMethodId:"",walletAddress:"",walletError:null,selectedProvider:null,selectedQuote:null,customerId:"",email:"",country:"",errorMessage:null};function bp(e,t){switch(t.type){case"SET_STEP":return{...e,step:t.step,errorMessage:null};case"SET_FLOW_TYPE":return{...e,flowType:t.flowType,fiatAmount:"",cryptoAmount:"",selectedQuote:null,selectedProvider:null,errorMessage:null};case"SET_FIAT_CURRENCY":return{...e,fiatCurrency:t.currency};case"SET_FIAT_AMOUNT":return{...e,fiatAmount:t.amount};case"SET_CRYPTO_CURRENCY":return{...e,cryptoCurrency:t.currency,network:""};case"SET_CRYPTO_AMOUNT":return{...e,cryptoAmount:t.amount};case"SET_NETWORK":return{...e,network:t.network};case"SET_CRYPTO_CHAIN":return{...e,network:t.chain};case"SET_PAYMENT_METHOD":return{...e,paymentMethodId:t.methodId};case"SET_WALLET_ADDRESS":return{...e,walletAddress:t.address,walletError:null};case"SET_WALLET_ERROR":return{...e,walletError:t.message};case"SELECT_QUOTE":return{...e,selectedQuote:t.quote,selectedProvider:t.quote.gatewayId};case"SET_CUSTOMER_ID":return{...e,customerId:t.customerId};case"SET_EMAIL":return{...e,email:t.email};case"SET_COUNTRY":return{...e,country:t.country};case"SET_ERROR":return{...e,step:"error",errorMessage:t.message};case"CLEAR_ERROR":return{...e,errorMessage:null};case"RESET":return Gc;default:return e}}const Zc=k.createContext(null);function em({projectId:e,apiUrl:t="https://api.nowramp.com",assetBaseUrl:n="",flowType:r="buy",customerId:l="",defaultFiatCurrency:o="USD",defaultCryptoCurrency:i="BTC",defaultNetwork:s="",defaultFiatAmount:a="",defaultCryptoAmount:c="",defaultWalletAddress:y="",defaultGateway:m,fieldLocks:h,statusPollInterval:x=5e3,onComplete:g,onError:S,children:_}){const f=k.useMemo(()=>({apiUrl:t,projectId:e}),[t,e]),d=s||(i?i.toLowerCase():""),p=r==="sell",w=p?!!c:!!a,A=(p?!!(w&&i&&d):!!(w&&i&&d&&y))&&m?"confirm":"amount",[v,T]=k.useReducer(bp,{...Gc,step:A,flowType:r,fiatCurrency:o,cryptoCurrency:i,network:d,fiatAmount:Yc(a,2),cryptoAmount:Yc(c,6),walletAddress:y,customerId:l}),R=v.flowType==="sell",{config:L,loading:Q,error:fe}=Gp(f,v.flowType);Mr.useEffect(()=>{var ne,re,q;if(!L||!v.cryptoCurrency||v.network)return;const F=(ne=L.cryptos)==null?void 0:ne.find(Je=>Je.code===v.cryptoCurrency),Z=((re=F==null?void 0:F.networks)==null?void 0:re.find(Je=>Je.isDefault))||((q=F==null?void 0:F.networks)==null?void 0:q[0]);Z!=null&&Z.id&&T({type:"SET_NETWORK",network:Z.id})},[L,v.cryptoCurrency,v.network]);const pe=k.useMemo(()=>{if(R){if(!v.cryptoAmount)return null;const q=parseFloat(v.cryptoAmount);return isNaN(q)||q<=0?"Enter a valid amount":null}if(!L||!v.fiatAmount)return null;const F=parseFloat(v.fiatAmount);if(isNaN(F))return null;const Z=L.fiats.find(q=>q.code===v.fiatCurrency);if(!Z)return null;const ne=parseFloat(Z.minAmount),re=parseFloat(Z.maxAmount);return!isNaN(ne)&&F<ne?`Minimum amount is ${Z.minAmount} ${v.fiatCurrency}`:!isNaN(re)&&F>re?`Maximum amount is ${Z.maxAmount} ${v.fiatCurrency}`:null},[L,v.fiatAmount,v.fiatCurrency,v.cryptoAmount,R]),tn=k.useMemo(()=>{const F=R?!!v.cryptoAmount:!!v.fiatAmount;return!L||!F||!v.cryptoCurrency||!v.network||pe?null:{fiatCurrency:v.fiatCurrency,...R?{cryptoAmount:v.cryptoAmount}:{fiatAmount:v.fiatAmount},cryptoCurrency:v.cryptoCurrency,network:v.network,paymentMethodId:v.paymentMethodId||void 0,country:v.country||void 0,orderType:v.flowType}},[L,v.fiatCurrency,v.fiatAmount,v.cryptoAmount,v.cryptoCurrency,v.network,v.paymentMethodId,v.country,pe,R,v.flowType]),{quotes:nn,loading:pt,error:Re,refetch:N}=Zp(f,tn),{order:P,loading:I,error:B,createOrder:V}=Jp(f),mt=15e3,{status:ae,loading:Ze}=qp({apiUrl:t},(P==null?void 0:P.orderId)??null,{pollInterval:x,initialDelay:mt});Mr.useEffect(()=>{(ae==null?void 0:ae.status)==="completed"&&g&&g(ae)},[ae==null?void 0:ae.status,g]),Mr.useEffect(()=>{const F=fe||B;F&&S&&S(F)},[fe,B,S]);const ke=m||(L==null?void 0:L.defaultGateway)||null,ht=k.useRef(ke);ht.current=ke;const Jl=k.useRef(nn);Jl.current=nn;const ql=k.useCallback(async()=>{var Z,ne,re;const F=((Z=v.selectedQuote)==null?void 0:Z.gatewayId)||((re=(ne=Jl.current)==null?void 0:ne.bestQuote)==null?void 0:re.gatewayId)||ht.current;if(!F||!v.walletAddress){const q=[!F&&"gateway",!v.walletAddress&&"walletAddress"].filter(Boolean).join(", ");T({type:"SET_ERROR",message:`Missing required fields: ${q}`});return}try{await V({gateway:F,externalCustomerId:v.customerId||void 0,fiatCurrency:v.fiatCurrency,...R?{cryptoAmount:v.cryptoAmount}:{fiatAmount:v.fiatAmount},cryptoCurrency:v.cryptoCurrency,network:v.network,walletAddress:v.walletAddress,paymentMethodId:v.paymentMethodId||void 0,email:v.email||void 0,orderType:v.flowType}),T({type:"SET_STEP",step:"checkout"})}catch(q){const Je=q instanceof Error?q.message:"Failed to create order";/wallet|address/i.test(Je)?T({type:"SET_WALLET_ERROR",message:Je.replace(/^Failed to create checkout intent:\s*/i,"")}):T({type:"SET_ERROR",message:Je})}},[v,V,R]),Ut=k.useCallback(F=>{T({type:"SET_STEP",step:F})},[]),Fn=k.useCallback(()=>{const F=["confirm","amount","quotes","wallet","checkout","processing","complete"],Z=F.indexOf(v.step);Z>0&&T({type:"SET_STEP",step:F[Z-1]})},[v.step,R]),ws=k.useMemo(()=>{const F=R?!!v.cryptoAmount:!!v.fiatAmount;switch(v.step){case"confirm":return!!(F&&v.cryptoCurrency&&v.network&&v.walletAddress&&!pe);case"amount":return!!(F&&v.cryptoCurrency&&v.network&&!pe);case"quotes":return!!v.selectedQuote;case"wallet":return!!v.walletAddress;default:return!1}},[v,pe,R]),Lr={apiConfig:f,assetBaseUrl:n,config:L,configLoading:Q,configError:fe,state:v,dispatch:T,quotes:nn,quotesLoading:pt,quotesError:Re,fetchQuotes:N,order:P,orderLoading:I,orderError:B,createOrder:ql,orderStatus:ae,orderStatusLoading:Ze,fieldLocks:h||null,defaultGateway:ke,amountError:pe,goToStep:Ut,goBack:Fn,canProceed:ws};return u.jsx(Zc.Provider,{value:Lr,children:_})}function Mn(){const e=k.useContext(Zc);if(!e)throw new Error("useRamp must be used within a RampProvider");return e}function tm({className:e="",iframeHeight:t=600,autoRedirect:n=!1,redirectDelay:r=3e3}){var x;const{order:l,orderStatus:o,goToStep:i,goBack:s}=Mn(),[a,c]=k.useState(!1),[y,m]=k.useState(null),h=l!=null&&l.checkout.expiresAt?Date.now()>l.checkout.expiresAt:!1;if(k.useEffect(()=>{if((l==null?void 0:l.checkout.method)==="redirect"&&n&&!h){m(Math.ceil(r/1e3));const g=setTimeout(()=>{window.location.href=l.checkout.url},r),S=setInterval(()=>{m(_=>_&&_>1?_-1:null)},1e3);return()=>{clearTimeout(g),clearInterval(S)}}},[l,n,r,h]),k.useEffect(()=>{o&&(o.status==="completed"?i("complete"):["failed","cancelled","expired"].includes(o.status)&&i("error"))},[o==null?void 0:o.status,i]),!l)return u.jsxs("div",{className:`flex flex-col items-center justify-center p-8 ${e}`,style:{color:"var(--t-text)"},children:[u.jsx("p",{className:"text-[15px] mb-4",children:"No order found"}),u.jsx("button",{className:"font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",paddingLeft:24,paddingRight:24},onClick:s,children:"Go Back"})]});if(h)return u.jsxs("div",{className:`flex flex-col items-center justify-center p-8 text-center ${e}`,style:{color:"var(--t-text)"},children:[u.jsx("div",{className:"text-[48px] mb-4",children:"⏰"}),u.jsx("h3",{className:"text-[18px] font-semibold mb-2",children:"Checkout Expired"}),u.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:"The checkout link has expired. Please try again."}),u.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:s,children:"Start Over"})]});if(l.checkout.method==="iframe")return u.jsx("div",{className:`flex flex-col flex-1 ${e}`,children:u.jsxs("div",{className:"relative flex-1",style:{height:t,borderRadius:5,overflow:"hidden",background:"var(--t-surface)"},children:[!a&&u.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[u.jsx("div",{className:"nramp-spinner"}),u.jsx("p",{className:"text-[14px] mt-4",style:{color:"var(--t-text-secondary)"},children:"Loading checkout..."})]}),u.jsx("iframe",{src:l.checkout.url,style:{display:a?"block":"none",width:"100%",height:"100%",border:"none"},allow:((x=l.checkout.allowedFeatures)==null?void 0:x.join("; "))||"payment; camera; microphone; geolocation; clipboard-read; clipboard-write; accelerometer; gyroscope; magnetometer; fullscreen; autoplay; encrypted-media; web-share",onLoad:()=>c(!0),title:"Provider Checkout"})]})});if(l.checkout.method==="redirect")return u.jsxs("div",{className:`flex flex-col items-center justify-center p-8 text-center ${e}`,style:{color:"var(--t-text)"},children:[u.jsx("div",{className:"text-[48px] mb-4",children:"🔗"}),u.jsx("h3",{className:"text-[18px] font-semibold mb-2",children:"Complete Payment"}),u.jsxs("p",{className:"text-[14px] mb-4",style:{color:"var(--t-text-secondary)"},children:["You'll be redirected to ",l.gateway," to complete your payment."]}),y!==null&&u.jsxs("p",{className:"text-[13px] mb-4",style:{color:"var(--t-text-muted)"},children:["Redirecting in ",y,"..."]}),u.jsxs("a",{href:l.checkout.url,className:"w-full font-semibold text-[16px] flex items-center justify-center transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",textDecoration:"none"},target:"_blank",rel:"noopener noreferrer",children:["Continue to ",l.gateway]}),u.jsx("button",{className:"w-full font-semibold text-[14px] mt-2 transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)"},onClick:s,children:"Cancel"})]});if(l.checkout.method==="widget"&&l.widgetConfig){const g=nm(l.checkout.url,l.widgetConfig);return u.jsx("div",{className:`flex flex-col flex-1 ${e}`,children:u.jsxs("div",{className:"relative flex-1",style:{height:t,borderRadius:5,overflow:"hidden",background:"var(--t-surface)"},children:[!a&&u.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[u.jsx("div",{className:"nramp-spinner"}),u.jsx("p",{className:"text-[14px] mt-4",style:{color:"var(--t-text-secondary)"},children:"Loading checkout..."})]}),u.jsx("iframe",{src:g,style:{display:a?"block":"none",width:"100%",height:"100%",border:"none"},allow:"payment; camera; microphone; geolocation; clipboard-read; clipboard-write; accelerometer; gyroscope; magnetometer; fullscreen; autoplay; encrypted-media; web-share",onLoad:()=>c(!0),title:"Payment Checkout"})]})})}return u.jsxs("div",{className:`flex flex-col items-center justify-center p-8 ${e}`,style:{color:"var(--t-text)"},children:[u.jsx("p",{className:"text-[15px] mb-4",children:"Unknown checkout method"}),u.jsx("button",{className:"font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",paddingLeft:24,paddingRight:24},onClick:s,children:"Go Back"})]})}function nm(e,t){const n=new URL("/en/partner/widget",e);for(const[r,l]of Object.entries(t))l!=null&&l!==""&&n.searchParams.set(r,String(l));return n.toString()}function rm({className:e=""}){const{orderStatus:t,orderStatusLoading:n,goToStep:r}=Mn();k.useEffect(()=>{t&&(t.status==="completed"?r("complete"):["failed","cancelled","expired","refunded"].includes(t.status)&&r("error"))},[t==null?void 0:t.status,r]);const l=()=>{if(!t)return"Processing your order...";switch(t.status){case"pending":return"Waiting for payment confirmation...";case"processing":return"Processing your transaction...";default:return"Processing..."}};return u.jsxs("div",{className:`flex flex-col items-center justify-center px-8 py-12 text-center ${e}`,children:[u.jsx("div",{className:"mb-6",children:u.jsx("div",{className:"nramp-spinner-large nramp-spinner"})}),u.jsx("h2",{className:"text-[20px] font-semibold mb-3",style:{color:"var(--t-text)"},children:l()}),n&&u.jsx("p",{className:"text-[13px] mb-4",style:{color:"var(--t-text-muted)"},children:"Checking status..."}),t&&u.jsxs("div",{className:"w-full mt-6 text-left",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[u.jsx(Dn,{label:"Order ID",value:t.orderId,mono:!0}),u.jsx(Dn,{label:"Provider",value:t.gateway}),u.jsx(Dn,{label:"Amount",value:`${t.fiatAmount} ${t.fiatCurrency}`}),u.jsx(Dn,{label:"Receiving",value:`${t.cryptoAmount||"..."} ${t.cryptoCurrency}`}),u.jsx(Dn,{label:"Network",value:t.network}),u.jsx(Dn,{label:"To Address",value:`${t.walletAddress.slice(0,10)}...${t.walletAddress.slice(-8)}`,mono:!0})]}),u.jsxs("div",{className:"mt-6",children:[u.jsx("p",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"This usually takes a few minutes."}),u.jsx("p",{className:"text-[12px] mt-1",style:{color:"var(--t-text-muted)"},children:"You can safely close this page - we'll send you an email when complete."})]})]})}function Dn({label:e,value:t,mono:n}){return u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),u.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:"var(--t-text)"},children:t})]})}function lm({className:e="",explorerUrl:t,onDone:n,doneButtonText:r="Done"}){const{orderStatus:l,state:o,dispatch:i}=Mn(),s=o.flowType==="sell",a=()=>{if(!(l!=null&&l.transactionHash))return null;if(!t){const m={ethereum:"https://etherscan.io/tx/{txHash}",polygon:"https://polygonscan.com/tx/{txHash}",arbitrum:"https://arbiscan.io/tx/{txHash}",optimism:"https://optimistic.etherscan.io/tx/{txHash}",base:"https://basescan.org/tx/{txHash}",bitcoin:"https://mempool.space/tx/{txHash}",solana:"https://solscan.io/tx/{txHash}",avalanche:"https://snowtrace.io/tx/{txHash}",fantom:"https://ftmscan.com/tx/{txHash}"};return(m[o.network]||m.ethereum).replace("{txHash}",l.transactionHash)}return t.replace("{txHash}",l.transactionHash)},c=()=>{n?n():i({type:"RESET"})},y=a();return u.jsxs("div",{className:`flex flex-col items-center px-8 py-12 text-center ${e}`,children:[u.jsx("div",{className:"flex items-center justify-center mb-5",style:{width:64,height:64,borderRadius:"50%",background:"var(--t-success, #10b981)"},children:u.jsx("svg",{viewBox:"0 0 24 24",width:"32",height:"32",fill:"white",children:u.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"})})}),u.jsx("h2",{className:"text-[20px] font-semibold mb-2",style:{color:"var(--t-text)"},children:s?"Sale Complete!":"Purchase Complete!"}),u.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:s?`Your ${(l==null?void 0:l.fiatCurrency)||o.fiatCurrency} payout is being processed.`:`Your ${(l==null?void 0:l.cryptoCurrency)||o.cryptoCurrency} has been sent to your wallet.`}),l&&u.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[u.jsx(Ft,{label:s?"Amount Sold":"Amount Received",value:`${l.cryptoAmount} ${l.cryptoCurrency}`,highlight:!0}),u.jsx(Ft,{label:s?"Payout Amount":"Amount Paid",value:`${l.fiatAmount} ${l.fiatCurrency}`}),u.jsx(Ft,{label:"Network",value:l.network}),u.jsx(Ft,{label:"Wallet",value:`${l.walletAddress.slice(0,10)}...${l.walletAddress.slice(-8)}`,mono:!0}),l.transactionHash&&u.jsx(Ft,{label:"Transaction",value:`${l.transactionHash.slice(0,10)}...${l.transactionHash.slice(-8)}`,mono:!0}),u.jsx(Ft,{label:"Provider",value:l.gateway}),u.jsx(Ft,{label:"Order ID",value:l.orderId,mono:!0}),l.completedAt&&u.jsx(Ft,{label:"Completed",value:new Date(l.completedAt).toLocaleString()})]}),u.jsxs("div",{className:"w-full flex flex-col gap-2",children:[y&&u.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"w-full font-semibold text-[14px] flex items-center justify-center transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",textDecoration:"none"},children:"View on Explorer"}),u.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:c,children:r})]})]})}function Ft({label:e,value:t,mono:n,highlight:r}){return u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),u.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:r?"var(--t-success, #10b981)":"var(--t-text)"},children:t})]})}function om({className:e="",onRetry:t,supportEmail:n="support@nowramp.com"}){const{state:r,orderStatus:l,dispatch:o,goToStep:i}=Mn(),s=r.flowType==="sell",a=()=>{if(l)switch(l.status){case"failed":return"Payment Failed";case"cancelled":return"Order Cancelled";case"expired":return"Order Expired";case"refunded":return"Order Refunded";default:return"Something Went Wrong"}return"Something Went Wrong"},c=()=>{if(r.errorMessage)return r.errorMessage;if(l)switch(l.status){case"failed":return s?"Your sale could not be processed. Please try again.":"Your payment could not be processed. Please try again or use a different payment method.";case"cancelled":return s?"Your sale was cancelled. No crypto was transferred.":"Your order was cancelled. No payment was processed.";case"expired":return s?"Your order has expired. Please start a new sale.":"Your order has expired. Please start a new purchase.";case"refunded":return s?"Your crypto has been returned. The funds should appear in your wallet shortly.":"Your payment has been refunded. The funds should appear in your account within 5-10 business days.";default:return"An unexpected error occurred. Please try again."}return"An unexpected error occurred. Please try again."},y=()=>{o({type:"CLEAR_ERROR"}),t?t():(o({type:"RESET"}),i("amount"))},m=()=>{o({type:"RESET"}),i("amount")};return u.jsxs("div",{className:`flex flex-col items-center px-8 py-12 text-center ${e}`,children:[u.jsx("div",{className:"flex items-center justify-center mb-5",style:{width:64,height:64,borderRadius:"50%",background:"var(--t-error, #EF4444)"},children:u.jsx("svg",{viewBox:"0 0 24 24",width:"32",height:"32",fill:"white",children:u.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})})}),u.jsx("h2",{className:"text-[20px] font-semibold mb-2",style:{color:"var(--t-text)"},children:a()}),u.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:c()}),l&&u.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Order ID"}),u.jsx("span",{className:"text-[13px] font-medium font-mono",style:{color:"var(--t-text)"},children:l.orderId})]}),u.jsxs("div",{className:"flex justify-between items-center py-2",children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Status"}),u.jsx("span",{className:"text-[12px] font-medium px-2 py-0.5",style:{background:"rgba(239,68,68,0.15)",color:"#EF4444",borderRadius:4},children:l.gatewayStatus})]})]}),u.jsxs("div",{className:"w-full flex flex-col gap-2",children:[u.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:y,children:"Try Again"}),u.jsx("button",{className:"w-full font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)"},onClick:m,children:"Start Over"})]}),u.jsxs("div",{className:"mt-6",children:[u.jsxs("p",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:["Need help? Contact"," ",u.jsx("a",{href:`mailto:${n}`,className:"underline",style:{color:"var(--t-accent)"},children:n})]}),l&&u.jsxs("p",{className:"text-[12px] mt-1",style:{color:"var(--t-text-muted)"},children:["Reference: ",l.orderId]})]})]})}function Jc(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-6)}`}function im({className:e=""}){const{config:t,configLoading:n,state:r,defaultGateway:l,fetchQuotes:o,createOrder:i,orderLoading:s}=Mn(),a=r.flowType==="sell",[c,y]=k.useState(null),m=t==null?void 0:t.gateways.find(x=>x.id===l),h=async()=>{y(null);try{o(),await i()}catch(x){const g=x instanceof Error?x.message:"Failed to create order";y(g)}};return n?u.jsxs("div",{className:`flex flex-col items-center justify-center p-12 ${e}`,children:[u.jsx("div",{className:"nramp-spinner"}),u.jsx("p",{className:"text-[14px] mt-4",style:{color:"var(--t-text-secondary)"},children:"Loading..."})]}):u.jsxs("div",{className:`flex flex-col items-center px-8 py-12 ${e}`,children:[u.jsx("h2",{className:"text-[20px] font-semibold mb-6",style:{color:"var(--t-text)"},children:a?"Confirm Sale":"Confirm Purchase"}),u.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[m&&u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Provider"}),u.jsxs("span",{className:"flex items-center gap-2",children:[m.logo&&u.jsx("img",{src:m.logo,alt:m.name,width:20,height:20,style:{borderRadius:4}}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:m.name})]})]}),a?u.jsxs(u.Fragment,{children:[u.jsx(en,{label:"You sell",value:`${r.cryptoAmount} ${r.cryptoCurrency}`,highlight:!0}),u.jsx(en,{label:"You receive",value:`${r.fiatCurrency} payout`})]}):u.jsxs(u.Fragment,{children:[u.jsx(en,{label:"You pay",value:`${r.fiatAmount} ${r.fiatCurrency}`,highlight:!0}),u.jsx(en,{label:"You receive",value:`${r.cryptoCurrency} on ${r.network}`}),u.jsx(en,{label:"Wallet",value:Jc(r.walletAddress),mono:!0})]}),u.jsx(en,{label:"Network",value:r.network}),a&&r.walletAddress&&u.jsx(en,{label:"Refund address",value:Jc(r.walletAddress),mono:!0})]}),c&&u.jsx("p",{className:"text-[12px] mb-4",style:{color:"#EF4444"},children:c}),u.jsx("button",{className:"w-full font-semibold text-[16px] transition-all flex items-center justify-center gap-2",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",opacity:s?.7:1},disabled:s,onClick:h,children:s?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"nramp-spinner-inline"}),"Processing..."]}):a?"Confirm & Sell":"Confirm & Pay"})]})}function en({label:e,value:t,mono:n,highlight:r}){return u.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[u.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),u.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:r?"var(--t-success, #10b981)":"var(--t-text)"},children:t})]})}function hs({isOpen:e,onClose:t,children:n}){const[r,l]=k.useState(!1),[o,i]=k.useState(!1);k.useEffect(()=>{if(e)l(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>i(!0)));else if(r){i(!1);const a=setTimeout(()=>l(!1),250);return()=>clearTimeout(a)}},[e]);const s=k.useCallback(()=>{i(!1),setTimeout(()=>t(),250)},[t]);return r?u.jsx("div",{className:"absolute inset-0 z-20 transition-opacity duration-250",style:{opacity:o?1:0},children:u.jsx("div",{className:"absolute inset-0 flex flex-col transition-transform duration-250 ease-out",style:{background:"var(--t-modal-bg)",transform:o?"translateY(0)":"translateY(24px)"},children:typeof n=="function"?n(s):n})}):null}function sm({char:e,height:t=38}){const n="0123456789",r=n.indexOf(e);return r===-1?u.jsx("span",{children:e}):u.jsx("span",{className:"digit-slot",style:{height:t,lineHeight:`${t}px`},children:u.jsx("span",{className:"digit-slot-inner block",style:{transform:`translateY(-${r*t}px)`},children:n.split("").map(l=>u.jsx("span",{className:"block",style:{height:t,lineHeight:`${t}px`},children:l},l))})})}function am({value:e,height:t=38,className:n="",style:r={}}){return u.jsx("span",{className:n,style:{display:"inline-flex",...r},children:e.split("").map((l,o)=>u.jsx(sm,{char:l,height:t},o))})}function $e({w:e,h:t,className:n=""}){return u.jsx("div",{className:`skeleton ${n}`,style:{width:e,height:t}})}function um(){return u.jsxs("div",{className:"flex-1 px-5 flex flex-col",children:[u.jsxs("div",{className:"px-[18px] pt-[14px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5},children:[u.jsx($e,{w:70,h:14,className:"mb-3"}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx($e,{w:120,h:32}),u.jsx($e,{w:75,h:32})]})]}),u.jsxs("div",{className:"px-[18px] pt-[12px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5,marginTop:4},children:[u.jsx($e,{w:50,h:14,className:"mb-3"}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx($e,{w:180,h:32}),u.jsx($e,{w:85,h:32})]})]}),u.jsxs("div",{className:"flex justify-between mt-3 px-[2px]",children:[u.jsx($e,{w:140,h:12}),u.jsx($e,{w:90,h:12})]}),u.jsxs("div",{className:"mt-8",children:[u.jsx($e,{w:65,h:14,className:"mb-2.5"}),u.jsx($e,{w:"100%",h:47})]}),u.jsx("div",{className:"flex-1"}),u.jsx($e,{w:"100%",h:60,className:"mb-2"}),u.jsx("div",{className:"text-center py-3",children:u.jsx("span",{className:"text-[11px]",style:{color:"var(--t-text-tertiary)"},children:"Powered by NowRamp"})})]})}const Gl={ETH:{name:"Ethereum (ERC20)",shortName:"Ethereum",icon:"eth"},BSC:{name:"Binance Smart Chain (BEP20)",shortName:"Binance",icon:"bnb"},BTC:{name:"Bitcoin",icon:"btc"},SOL:{name:"Solana",icon:"sol"},MATIC:{name:"Polygon",icon:"pol"},ARB:{name:"Arbitrum",icon:"arb"},BASE:{name:"Base",icon:"base"},OPTIMISM:{name:"Optimism",icon:"op"},AVAX_C:{name:"Avalanche C-Chain",shortName:"Avalanche C",icon:"avax"},AVAX_X:{name:"Avalanche X-Chain",shortName:"Avalanche X",icon:"avax"},ADA:{name:"Cardano",icon:"ada"},DOT:{name:"Polkadot",icon:"dot"},TRON:{name:"Tron (TRC20)",shortName:"Tron",icon:"trx"},XRP:{name:"Ripple",icon:"xrp"},XLM:{name:"Stellar",icon:"xlm"},ALGO:{name:"Algorand",icon:"algo"},ATOM:{name:"Cosmos",icon:"atom"},NEAR:{name:"NEAR Protocol",shortName:"NEAR",icon:"near"},SUI:{name:"Sui",icon:"sui"},APT:{name:"Aptos",icon:"apt"},TON:{name:"Ton",icon:"ton"},FIL:{name:"Filecoin",icon:"fil"},FLOW:{name:"Flow",icon:"flow"},HBAR:{name:"Hedera Hashgraph",shortName:"Hedera",icon:"hbar"},INJ:{name:"Injective",icon:"inj"},SEI_EVM:{name:"SEI (EVM)",shortName:"SEI",icon:"sei"},ZKSYNC:{name:"zkSync",icon:"zksync"},LINEA:{name:"Linea",icon:"linea"},STARK:{name:"StarkNet",icon:"strk"},LN:{name:"Lightning",icon:"btc"},CELO:{name:"Celo",icon:"celo"},CRO:{name:"Cronos",icon:"cro"},FTM:{name:"Fantom",icon:"ftm"},GLMR:{name:"Moonbeam",icon:"glmr"},MOVR:{name:"Moonriver",icon:"movr"},KSM:{name:"Kusama",icon:"ksm"},EOS:{name:"EOS",icon:"eos"},ETC:{name:"Ethereum Classic",shortName:"ETH Classic",icon:"etc"},LTC:{name:"Litecoin",icon:"ltc"},BCH:{name:"Bitcoin Cash",shortName:"BTC Cash",icon:"bch"},DOGE:{name:"Dogecoin",icon:"doge"},BNB:{name:"Binance Chain (BEP2)",shortName:"Binance",icon:"bnb"},ONE:{name:"Harmony",icon:"one"},KLAY:{name:"Kaia",icon:"kaia"},RON:{name:"Ronin",icon:"ron"},LRC:{name:"Loopring",icon:"lrc"},ICP:{name:"Internet Computer",shortName:"ICP",icon:"icp"},EGLD:{name:"MultiversX",icon:"egld"},FLUX:{name:"Flux",icon:"flux"},KDA:{name:"Kadena",icon:"kda"},WAVES:{name:"Waves",icon:"waves"},XTZ:{name:"Tezos",icon:"xtz"},ACA:{name:"Acala",icon:"aca"},ALEO:{name:"Aleo",icon:"aleo"},ALPH:{name:"Alephium",icon:"alph"},APE:{name:"ApeChain",icon:"ape"},ASTR:{name:"Astar",icon:"astr"},AZERO:{name:"Aleph Zero",icon:"azero"},AZERO_EVM:{name:"Aleph Zero EVM",shortName:"Aleph Zero",icon:"azero"},BAJU:{name:"Bajun Network",shortName:"Bajun",icon:"baju"},BNCPOLKA:{name:"Bifrost Polkadot",shortName:"Bifrost",icon:"bnc"},BNC:{name:"Bifrost Kusama",shortName:"Bifrost",icon:"bnc"},BOBA:{name:"Boba Network",shortName:"Boba",icon:"boba"},BSX:{name:"Basilisk",icon:"bsx"},CHZ:{name:"Chiliz",icon:"chz"},VIC:{name:"Viction",icon:"vic"},CCD:{name:"Concordium",icon:"ccd"},COREUM:{name:"Coreum",icon:"coreum"},DINGO:{name:"Dingocoin",icon:"dingo"},HDX:{name:"Hydration",icon:"hdx"},PLMC:{name:"Polimec",icon:"plmc"},MNT:{name:"Mantle",icon:"mnt"},ERG:{name:"Ergo",icon:"erg"},ECLIPSE:{name:"Eclipse",icon:"eclipse"},FUEL:{name:"Fuel Ignition",shortName:"Fuel",icon:"fuel"},INK:{name:"Ink",icon:"ink"},SOPHON:{name:"Sophon",icon:"sophon"},UNICHAIN:{name:"Unichain",icon:"unichain"},WLD:{name:"Worldchain",icon:"wld"},ETHERLINK:{name:"Etherlink",icon:"etherlink"},MOB:{name:"MobileCoin",icon:"mob"},GALA:{name:"Gala",icon:"gala"},GUNZ:{name:"Gunz",icon:"gun"},HNT:{name:"Helium",icon:"hnt"},BITKUB:{name:"BitKub",icon:"kub"},IMMUTABLE_ZKEVM:{name:"Immutable-zkEVM",shortName:"Immutable",icon:"imx"},INIT:{name:"Initia",icon:"init"},INTR:{name:"Interlay",icon:"intr"},KINESIS:{name:"Kinesis",icon:"kag"},KAR:{name:"Karura",icon:"kar"},KCC:{name:"KuCoin Community Chain",shortName:"KuCoin",icon:"kcs"},KILT:{name:"KILT Spiritnet",shortName:"KILT",icon:"kilt"},KINT:{name:"Kintsugi",icon:"kint"},KMD:{name:"Komodo",icon:"kmd"},LSK:{name:"Lisk",icon:"lsk"},METIS:{name:"Metis Andromeda",shortName:"Metis",icon:"metis"},MYTH:{name:"Myth",icon:"myth"},OAS:{name:"Oasys",icon:"oas"},PEAQ_EVM:{name:"Peaq (EVM)",shortName:"Peaq",icon:"peaq"},PEN:{name:"Pendulum",icon:"pen"},PI:{name:"Pi",icon:"pi"},POLYX:{name:"Polymesh",icon:"polyx"},Q:{name:"QuantumCoin",icon:"q"},QRL:{name:"Quantum Resistant Ledger",shortName:"QRL",icon:"qrl"},QUBIC:{name:"Qubic",icon:"qubic"},RBX:{name:"ReserveBlock",icon:"rbx"},ROLLUX:{name:"Rollux",icon:"rollux"},THORCHAIN:{name:"Thorchain",icon:"rune"},S:{name:"Sonic",icon:"s"},SONIC:{name:"Sonic",icon:"s"},TERNOA:{name:"Ternoa",icon:"caps"},SX:{name:"SX Network",icon:"sol"},WAX:{name:"WAX",icon:"waxp"},XCH:{name:"Chia Chain",icon:"xch"},XPRT:{name:"Persistence",icon:"xprt"},ZETACHAIN:{name:"ZetaChain",icon:"zeta"},ZTG:{name:"Zeitgeist",icon:"ztg"},PLS:{name:"Pulsechain",icon:"pulsechain"},MEZO:{name:"Mezo",icon:"mezo"},BSV:{name:"Bitcoin SV",shortName:"BTC SV",icon:"btc"},MONAD:{name:"Monad",icon:"mon"},SUPRA:{name:"Supra",icon:"supra"},SOMI:{name:"Somnia",icon:"somi"},VERIFIEDX:{name:"VerifiedX",icon:"vfx"},MOVE:{name:"Movement",icon:"move"},FLR:{name:"Flare",icon:"flr"},ASSETHUB:{name:"Asset Hub Polkadot",shortName:"Asset Hub",icon:"dot"},BOB:{name:"BOB",icon:"btc"},GLUE:{name:"Glue",icon:"eth"},DYDX:{name:"StarkEx",icon:"stark"},OKC:{name:"OKX Chain",icon:"eth"},UNI_CHAIN:{name:"UNI",icon:"uni"},ZEC:{name:"ZCash",icon:"zec"}},cm=[{code:"BTC",name:"Bitcoin",chains:["BTC","LN"],popular:!0},{code:"ETH",name:"Ethereum",chains:["ETH","ARB","BASE","BSC","OPTIMISM","LINEA","ZKSYNC","LRC","STARK","APE","ECLIPSE","FUEL","INK","SOPHON","UNICHAIN","WLD"],popular:!0},{code:"USDC",name:"USD Coin",chains:["ETH","SOL","ARB","BASE","BSC","MATIC","OPTIMISM","AVAX_C","ALGO","APT","CELO","FLOW","HBAR","LINEA","LRC","ZKSYNC","STARK","SUI","XLM","ECLIPSE","HDX","INK","LSK","METIS","MONAD","SEI_EVM","SONIC","SOPHON","SX","UNICHAIN","APE","BNCPOLKA","GLMR","PEAQ_EVM","PLMC","RON","UNI_CHAIN","WLD","BITKUB","BOB","DYDX","ETHERLINK","GLUE","ASSETHUB"],popular:!0},{code:"USDT",name:"Tether",chains:["ETH","BSC","TRON","ARB","MATIC","AVAX_C","SOL","OPTIMISM","ZKSYNC","STARK","APT","CELO","KLAY","LRC","LSK","ECLIPSE","ETHERLINK","OKC","PEAQ_EVM","BNCPOLKA","GLMR","HDX","PLMC","VIC","ASSETHUB"],popular:!0},{code:"SOL",name:"Solana",chains:["SOL"],popular:!0},{code:"XRP",name:"Ripple",chains:["XRP"],popular:!0},{code:"ADA",name:"Cardano",chains:["ADA"],popular:!0},{code:"DOGE",name:"Dogecoin",chains:["DOGE"],popular:!0},{code:"DOT",name:"Polkadot",chains:["DOT","BSC","BNCPOLKA","GLMR","HDX","PLMC"],popular:!0},{code:"AVAX",name:"Avalanche",chains:["AVAX_C","AVAX_X","BSC"],popular:!0},{code:"LINK",name:"ChainLink",chains:["ETH","BSC"],popular:!0},{code:"LTC",name:"Litecoin",chains:["LTC"],popular:!0},{code:"AAVE",name:"Aave",chains:["ETH","BSC"],popular:!1},{code:"ACA",name:"Acala",chains:["ACA"],popular:!1},{code:"ALEO",name:"Aleo",chains:["ALEO"],popular:!1},{code:"ALGO",name:"Algorand",chains:["ALGO"],popular:!1},{code:"ALPH",name:"Alephium",chains:["ALPH"],popular:!1},{code:"APE",name:"ApeCoin",chains:["APE","ETH"],popular:!1},{code:"APT",name:"Aptos",chains:["APT"],popular:!1},{code:"ARB",name:"Arbitrum",chains:["ARB"],popular:!1},{code:"ASTR",name:"Astar",chains:["ASTR"],popular:!1},{code:"ATOM",name:"Cosmos",chains:["ATOM"],popular:!1},{code:"AUDD",name:"Novatti Australian Digital Dollar",chains:["ETH"],popular:!1},{code:"AVT",name:"Aventus",chains:["ETH"],popular:!1},{code:"AXS",name:"Axie Infinity",chains:["ETH","RON"],popular:!1},{code:"AZERO",name:"Aleph Zero",chains:["AZERO","AZERO_EVM"],popular:!1},{code:"BAJU",name:"Bajun Network",chains:["BAJU"],popular:!1},{code:"BARSIK",name:"Hasbulla's Cat",chains:["SOL"],popular:!1},{code:"BAT",name:"Basic Attention Token",chains:["ETH","BSC"],popular:!1},{code:"BCH",name:"Bitcoin Cash",chains:["BCH"],popular:!1},{code:"BNB",name:"Binance Coin",chains:["BNB","BSC"],popular:!1},{code:"BNC",name:"Bifrost Native Coin",chains:["BNC","BNCPOLKA"],popular:!1},{code:"BOBA",name:"Boba Network",chains:["BOBA","ETH"],popular:!1},{code:"BORA",name:"Bora",chains:["KLAY"],popular:!1},{code:"BRETT",name:"Brett",chains:["BASE"],popular:!1},{code:"BSX",name:"Basilisk",chains:["BSX"],popular:!1},{code:"BZR",name:"Bazaars",chains:["ETH"],popular:!1},{code:"CAGA",name:"Crypto Asset Governance Alliance",chains:["ETH"],popular:!1},{code:"CAKE",name:"PancakeSwap",chains:["BSC"],popular:!1},{code:"CAPS",name:"Caps",chains:["TERNOA"],popular:!1},{code:"CELO",name:"Celo",chains:["CELO"],popular:!1},{code:"CHZ",name:"Chiliz",chains:["CHZ","BNB","ETH"],popular:!1},{code:"C98",name:"Coin98",chains:["VIC"],popular:!1},{code:"CCD",name:"Concordium",chains:["CCD"],popular:!1},{code:"COMP",name:"Compound",chains:["ETH","BSC"],popular:!1},{code:"COREUM",name:"Coreum",chains:["COREUM","XRP"],popular:!1},{code:"CRO",name:"Cronos",chains:["CRO"],popular:!1},{code:"CUSD",name:"Celo Dollar",chains:["CELO"],popular:!1},{code:"CVC",name:"Civic",chains:["ETH"],popular:!1},{code:"DAI",name:"Dai",chains:["ETH","BASE","MATIC"],popular:!1},{code:"DINGO",name:"Dingocoin",chains:["DINGO"],popular:!1},{code:"EGLD",name:"MultiversX",chains:["EGLD"],popular:!1},{code:"EMBER",name:"Ember Sword",chains:["MNT"],popular:!1},{code:"EOS",name:"EOS",chains:["EOS"],popular:!1},{code:"ERG",name:"Ergo",chains:["ERG"],popular:!1},{code:"ETC",name:"Ethereum Classic",chains:["ETC","BSC"],popular:!1},{code:"EUR",name:"EURC",chains:["BASE"],popular:!1},{code:"EUROC",name:"Euro Coin",chains:["ETH"],popular:!1},{code:"EURQ",name:"Quantoz EURQ",chains:["ETH"],popular:!1},{code:"EURR",name:"StablR EUR",chains:["ETH"],popular:!1},{code:"EUSD",name:"Electronic USD",chains:["MOB"],popular:!1},{code:"EXIT",name:"EXIT - Designer Token",chains:["BSC"],popular:!1},{code:"FDUSD",name:"First Digital USD",chains:["SUI"],popular:!1},{code:"FIL",name:"Filecoin",chains:["FIL","BSC"],popular:!1},{code:"FLOW",name:"Flow",chains:["FLOW"],popular:!1},{code:"FLR",name:"Flare",chains:["FLR"],popular:!1},{code:"FLUX",name:"Flux",chains:["FLUX"],popular:!1},{code:"FTM",name:"Fantom",chains:["FTM","ETH","BSC"],popular:!1},{code:"GALA",name:"Gala",chains:["GALA"],popular:!1},{code:"GLMR",name:"Moonbeam",chains:["GLMR"],popular:!1},{code:"GMX",name:"GMX",chains:["ARB"],popular:!1},{code:"GNUS",name:"Genius AI",chains:["ETH"],popular:!1},{code:"GRT",name:"The Graph",chains:["ETH","ARB"],popular:!1},{code:"GUN",name:"Gunz",chains:["GUNZ"],popular:!1},{code:"HBAR",name:"Hedera",chains:["HBAR"],popular:!1},{code:"HDX",name:"HydraDX",chains:["HDX"],popular:!1},{code:"HNT",name:"Helium",chains:["HNT"],popular:!1},{code:"HTP",name:"HowToPay",chains:["BSC"],popular:!1},{code:"HVLO",name:"Hivello",chains:["SOL"],popular:!1},{code:"ICP",name:"Internet Computer",chains:["ICP"],popular:!1},{code:"IMX",name:"Immutable X",chains:["ETH"],popular:!1},{code:"INIT",name:"Initia",chains:["INIT"],popular:!1},{code:"INJ",name:"Injective",chains:["INJ"],popular:!1},{code:"INTR",name:"Interlay",chains:["INTR"],popular:!1},{code:"JAM",name:"Jam Tune.FM",chains:["HBAR"],popular:!1},{code:"KAG",name:"Silver",chains:["KINESIS"],popular:!1},{code:"KAIA",name:"Kaia",chains:["KLAY"],popular:!1},{code:"KAR",name:"Karura",chains:["KAR"],popular:!1},{code:"KAU",name:"Gold",chains:["KINESIS"],popular:!1},{code:"KCS",name:"KuCoin Token",chains:["ETH","KCC"],popular:!1},{code:"KDA",name:"Kadena",chains:["KDA"],popular:!1},{code:"KILT",name:"KILT",chains:["KILT"],popular:!1},{code:"KINT",name:"Kintsugi",chains:["KINT"],popular:!1},{code:"KLV",name:"Klever",chains:["TRON"],popular:!1},{code:"KMD",name:"Komodo",chains:["KMD"],popular:!1},{code:"KSM",name:"Kusama",chains:["KSM"],popular:!1},{code:"KUB",name:"Bitkub Coin",chains:["BITKUB"],popular:!1},{code:"LOOKS",name:"LooksRare",chains:["ETH"],popular:!1},{code:"LRC",name:"Loopring",chains:["ETH","LRC"],popular:!1},{code:"LSK",name:"Lisk",chains:["LSK"],popular:!1},{code:"MANA",name:"Decentraland",chains:["ETH"],popular:!1},{code:"MBX",name:"Marblex",chains:["IMMUTABLE_ZKEVM","KLAY"],popular:!1},{code:"MELANIA",name:"Melania",chains:["SOL"],popular:!1},{code:"METAMASKUSD",name:"Metamask USD",chains:["ETH","LINEA"],popular:!1},{code:"METIS",name:"Metis",chains:["METIS"],popular:!1},{code:"MEZOUSD",name:"MUSD",chains:["ETH","MEZO"],popular:!1},{code:"MKR",name:"Maker",chains:["ETH","BSC"],popular:!1},{code:"MNEE",name:"MNEE",chains:["BSV","ETH"],popular:!1},{code:"MNT",name:"Mantle",chains:["ETH","MNT"],popular:!1},{code:"MOB",name:"MobileCoin",chains:["MOB"],popular:!1},{code:"MON",name:"Monad",chains:["MONAD"],popular:!1},{code:"MOVE",name:"Movement",chains:["MOVE"],popular:!1},{code:"MOVR",name:"Moonriver",chains:["MOVR"],popular:!1},{code:"MYTH",name:"Myth",chains:["MYTH"],popular:!1},{code:"NEAR",name:"NEAR Protocol",chains:["NEAR","BSC"],popular:!1},{code:"NEIRO",name:"NEIRO Ethereum",chains:["ETH"],popular:!1},{code:"OAS",name:"Oasys",chains:["OAS"],popular:!1},{code:"OMG",name:"OmiseGo",chains:["ETH"],popular:!1},{code:"OMUSD",name:"Open Money USD",chains:["ETH"],popular:!1},{code:"ONE",name:"Harmony",chains:["ONE","BNB","ETH"],popular:!1},{code:"OP",name:"Optimism",chains:["OPTIMISM"],popular:!1},{code:"ORDER",name:"Orderly Network",chains:["ETH"],popular:!1},{code:"PEAQ",name:"Peaq",chains:["PEAQ_EVM"],popular:!1},{code:"PEN",name:"Pendulum",chains:["PEN"],popular:!1},{code:"PERC",name:"Perion",chains:["ETH"],popular:!1},{code:"PI",name:"Pi",chains:["PI"],popular:!1},{code:"PLMC",name:"Polimec",chains:["PLMC"],popular:!1},{code:"POL",name:"Polygon",chains:["ETH","MATIC"],popular:!1},{code:"POLYX",name:"Polymesh",chains:["POLYX"],popular:!1},{code:"PROPC",name:"Propchain",chains:["ETH"],popular:!1},{code:"PSTAKE",name:"pSTAKE Finance",chains:["ETH"],popular:!1},{code:"Q",name:"QuantumCoin",chains:["Q"],popular:!1},{code:"QRDO",name:"Qredo",chains:["ETH"],popular:!1},{code:"QRL",name:"Quantum Resistant Ledger",chains:["QRL"],popular:!1},{code:"QUBIC",name:"QUBIC",chains:["QUBIC"],popular:!1},{code:"RBX",name:"ReserveBlock",chains:["RBX"],popular:!1},{code:"REVU",name:"Revuto",chains:["ADA"],popular:!1},{code:"RITE",name:"Ritestream",chains:["BSC"],popular:!1},{code:"RLUSD",name:"Ripple USD",chains:["ETH"],popular:!1},{code:"RON",name:"Ronin",chains:["RON"],popular:!1},{code:"RUNE",name:"THORChain",chains:["THORCHAIN"],popular:!1},{code:"S",name:"Sonic",chains:["S"],popular:!1},{code:"SAND",name:"The Sandbox",chains:["ETH","BSC"],popular:!1},{code:"SEI",name:"SEI",chains:["SEI_EVM"],popular:!1},{code:"SNX",name:"Synthetix",chains:["ETH"],popular:!1},{code:"SOIL",name:"Sun Minimeal",chains:["PLS"],popular:!1},{code:"SOLO",name:"Sologenic",chains:["XRP"],popular:!1},{code:"SOMI",name:"Somnia",chains:["SOMI"],popular:!1},{code:"STRK",name:"Starknet",chains:["STARK"],popular:!1},{code:"SUI",name:"Sui",chains:["SUI"],popular:!1},{code:"SUPR",name:"SuperDapp",chains:["ROLLUX"],popular:!1},{code:"SUPRA",name:"Supra",chains:["SUPRA"],popular:!1},{code:"SUSHI",name:"SushiSwap",chains:["ETH","BSC"],popular:!1},{code:"SYS",name:"Syscoin",chains:["ROLLUX"],popular:!1},{code:"TBTC",name:"tBTC",chains:["SUI","STARK"],popular:!1},{code:"TON",name:"Toncoin",chains:["TON"],popular:!1},{code:"TRUMP",name:"TRUMP",chains:["SOL"],popular:!1},{code:"TRX",name:"Tron",chains:["TRON","BSC"],popular:!1},{code:"TWT",name:"Trust Wallet Token",chains:["BSC"],popular:!1},{code:"UNI",name:"Uniswap",chains:["ETH","BSC"],popular:!1},{code:"URANIUM",name:"Uranium",chains:["ETHERLINK"],popular:!1},{code:"USD0",name:"Usual USD",chains:["ETH"],popular:!1},{code:"USD1",name:"World Liberty Financial USD",chains:["SOL"],popular:!1},{code:"USDE",name:"Ethena USDe",chains:["ETH"],popular:!1},{code:"USDP",name:"Pax Dollar",chains:["ETH"],popular:!1},{code:"USDQ",name:"Quantoz USDQ",chains:["ETH"],popular:!1},{code:"USDR",name:"StablR USD",chains:["ETH"],popular:!1},{code:"USDT0",name:"USDT0",chains:["INK"],popular:!1},{code:"VFX",name:"VerifiedX",chains:["VERIFIEDX"],popular:!1},{code:"VERSE",name:"Verse",chains:["ETH","MATIC"],popular:!1},{code:"VIC",name:"Viction",chains:["VIC"],popular:!1},{code:"WAL",name:"Walrus",chains:["SUI"],popular:!1},{code:"WAVES",name:"Waves",chains:["WAVES"],popular:!1},{code:"WAXP",name:"WAX",chains:["WAX"],popular:!1},{code:"WBTC",name:"Wrapped Bitcoin",chains:["ETH","STARK"],popular:!1},{code:"WETH",name:"Wrapped Ether",chains:["ETHERLINK"],popular:!1},{code:"WLD",name:"Worldcoin",chains:["WLD"],popular:!1},{code:"WLFI",name:"World Liberty Financial",chains:["ETH"],popular:!1},{code:"WOLF",name:"LandWolf",chains:["ETH"],popular:!1},{code:"WOMBAT",name:"Wombat",chains:["MATIC"],popular:!1},{code:"XCH",name:"Chia",chains:["XCH"],popular:!1},{code:"XLM",name:"Stellar Lumens",chains:["XLM","BSC"],popular:!1},{code:"XPRT",name:"Persistence",chains:["XPRT"],popular:!1},{code:"XTZ",name:"Tezos",chains:["XTZ","ETHERLINK"],popular:!1},{code:"YFI",name:"yearn.finance",chains:["ETH"],popular:!1},{code:"ZBU",name:"Zeebu",chains:["BSC"],popular:!1},{code:"ZEC",name:"ZCash",chains:["ZEC"],popular:!1},{code:"ZCHF",name:"Frankencoin",chains:["ETH"],popular:!1},{code:"ZETA",name:"Zeta",chains:["ETH","ZETACHAIN"],popular:!1},{code:"ZTG",name:"Zeitgeist",chains:["ZTG"],popular:!1}],dm={USD:"us",EUR:"eu",GBP:"gb",JPY:"jp",CAD:"ca",AUD:"au",BRL:"br",CHF:"ch",MXN:"mx",INR:"in",ARS:"ar",ALL:"al"};function qc(e,t=""){return`${t}/crypto-icons/${e.toLowerCase()}.svg`}function fm(e,t=""){const n=dm[e]||"us";return`${t}/flags/${n}.svg`}function ys(e,t=""){const n=Gl[e];return n?`${t}/crypto-icons/${n.icon}.svg`:`${t}/crypto-icons/${e.toLowerCase()}.svg`}const bc=[{code:"ALL",name:"Albania Lek"},{code:"ARS",name:"Argentina Peso"},{code:"AUD",name:"Australian Dollar"},{code:"BRL",name:"Brazilian Real"},{code:"CAD",name:"Canadian Dollar"},{code:"EUR",name:"Euro"},{code:"GBP",name:"British Pound"},{code:"JPY",name:"Japanese Yen"},{code:"USD",name:"US Dollar"},{code:"CHF",name:"Swiss Franc"},{code:"MXN",name:"Mexican Peso"},{code:"INR",name:"Indian Rupee"}],ed=[{id:"blue",name:"Blue",accent:"#0077FF"},{id:"violet",name:"Violet",accent:"#7C3AED"},{id:"green",name:"Green",accent:"#10B981"},{id:"orange",name:"Orange",accent:"#F59E0B"},{id:"rose",name:"Rose",accent:"#F43F5E"},{id:"mono",name:"Mono",accent:null}];function pm(e){return parseFloat(e.replace(/,/g,""))||0}const vs=e=>/^#([0-9A-Fa-f]{3}){1,2}$/.test(e),td=10,nd=1e-4,mm=(()=>{const e=[];for(const t of cm)for(const n of t.chains)e.push({code:t.code,name:t.name,chain:n,popular:t.popular});return e})();function rd({ticker:e,size:t=32,baseUrl:n=""}){return u.jsx("img",{src:qc(e,n),alt:e,width:t,height:t,className:"rounded-full shrink-0",style:{width:t,height:t}})}function gs({currencyCode:e,size:t=16,baseUrl:n=""}){return u.jsx("img",{src:fm(e,n),alt:e,width:t,height:t,className:"rounded-full shrink-0",style:{width:t,height:t}})}function Zl(){return u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:u.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"var(--t-text-secondary)",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function hm(){return u.jsx("svg",{width:"8",height:"14",viewBox:"0 0 8 14",fill:"none",children:u.jsx("path",{d:"M1 1L7 7L1 13",stroke:"var(--t-icon-stroke)",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function ym({onClick:e}){return u.jsx("button",{onClick:e,className:"hover:opacity-70 transition-opacity",children:u.jsx("svg",{width:"24",height:"16",viewBox:"0 0 24 16",fill:"none",children:u.jsx("path",{d:"M4 0.799805H20C21.7673 0.799805 23.2002 2.23269 23.2002 4V12C23.2002 13.7673 21.7673 15.2002 20 15.2002H4C2.23269 15.2002 0.799805 13.7673 0.799805 12V4C0.799805 2.23269 2.23269 0.799805 4 0.799805Z",stroke:"var(--t-icon-stroke)",strokeWidth:"1.6"})})})}function vm({size:e=40}){return u.jsx("div",{className:"rounded-full flex items-center justify-center shrink-0",style:{width:e,height:e,background:"var(--t-surface)"},children:u.jsxs("svg",{width:e*.5,height:e*.5,viewBox:"0 0 20 20",fill:"none",children:[u.jsx("circle",{cx:"10",cy:"10",r:"7.5",stroke:"var(--t-text)",strokeWidth:"1.5"}),u.jsx("path",{d:"M10 2.5A7.5 7.5 0 0 1 10 17.5",fill:"var(--t-text)"})]})})}function xs({onClick:e}){return u.jsx("button",{onClick:e,className:"flex items-center justify-center transition-colors rounded-full shrink-0",style:{width:30,height:30,backgroundColor:"var(--t-close-bg)"},onMouseEnter:t=>t.currentTarget.style.backgroundColor="var(--t-close-hover)",onMouseLeave:t=>t.currentTarget.style.backgroundColor="var(--t-close-bg)",children:u.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:u.jsx("path",{d:"M1 1L9 9M9 1L1 9",stroke:"var(--t-icon-close)",strokeWidth:"1.4",strokeLinecap:"round"})})})}function ld({value:e,onChange:t,placeholder:n=""}){return u.jsxs("div",{className:"relative mx-5 mb-5",children:[u.jsx("input",{type:"text",value:e,onChange:r=>t(r.target.value),placeholder:n,style:{height:47,borderRadius:4.5,borderColor:"var(--t-border)",color:"var(--t-text)",paddingLeft:14,paddingRight:e?40:14,fontSize:14},className:"w-full bg-transparent border outline-none transition-colors"}),e&&u.jsx("button",{onClick:()=>t(""),className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center justify-center transition-colors rounded",style:{width:22,height:22,backgroundColor:"var(--t-close-bg)",borderRadius:4},children:u.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:u.jsx("path",{d:"M1 1L7 7M7 1L1 7",stroke:"var(--t-icon-close)",strokeWidth:"1.2",strokeLinecap:"round"})})})]})}function gm({onClose:e,onSelect:t,currencies:n,assetBaseUrl:r=""}){const[l,o]=k.useState(""),i=k.useMemo(()=>{if(!n||n.length===0)return bc;const a=new Map(bc.map(c=>[c.code,c.name]));return n.map(c=>({code:c.code,name:c.name||a.get(c.code)||c.code}))},[n]),s=k.useMemo(()=>{const a=l.trim().toLowerCase();return a?i.filter(c=>c.code.toLowerCase().includes(a)||c.name.toLowerCase().includes(a)):i},[i,l]);return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"flex justify-end px-5 pt-5",children:u.jsx(xs,{onClick:e})}),u.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)"},children:"Select fiat currency"}),u.jsx(ld,{value:l,onChange:o}),u.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[s.map(a=>u.jsxs("button",{onClick:()=>t(a.code),className:"flex items-center gap-3.5 w-full py-3.5 transition-colors",style:{color:"var(--t-text)"},children:[u.jsx(gs,{currencyCode:a.code,size:32,baseUrl:r}),u.jsxs("div",{className:"text-left",children:[u.jsx("div",{className:"font-semibold text-[15px] leading-tight",children:a.code}),u.jsx("div",{className:"text-[13px] mt-0.5",style:{color:"var(--t-text-secondary)"},children:a.name})]})]},a.code)),s.length===0&&u.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No currencies found"})]})]})}function xm({onClose:e,onSelect:t,cryptos:n,assetBaseUrl:r=""}){const[l,o]=k.useState(""),i=k.useMemo(()=>{if(!n||n.length===0)return mm;const a=[];for(const c of n){const y=c.networks||[];if(y.length===0)a.push({code:c.code,name:c.name||c.code,chain:c.code,popular:!1});else for(const m of y){const h=m.code||m.id||m.name||c.code;a.push({code:c.code,name:c.name||c.code,chain:h,chainName:m.name,popular:!1})}}return a},[n]),s=k.useMemo(()=>{var m;const a=l.trim().toLowerCase();if(!a)return i;const c=a.split(/\s+/),y=[];for(const h of i){const x=Gl[h.chain],g=x?x.name.toLowerCase():"",S=((m=x==null?void 0:x.shortName)==null?void 0:m.toLowerCase())||"",_=h.chain.toLowerCase(),f=h.code.toLowerCase(),d=h.name.toLowerCase(),p=[f,d,g,S,_];if(!c.every(A=>p.some(v=>v.includes(A))))continue;let C=0;f===a?C+=100:f.startsWith(c[0])&&(C+=50),h.popular&&(C+=10),c.length>1&&(g.includes(c[1])||S.includes(c[1])||_.includes(c[1]))&&(C+=25),y.push({item:h,score:C})}return y.sort((h,x)=>x.score-h.score),y.map(h=>h.item)},[i,l]);return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"flex justify-end px-5 pt-5",children:u.jsx(xs,{onClick:e})}),u.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)"},children:"Select crypto currency"}),u.jsx(ld,{value:l,onChange:o}),u.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[s.map(a=>{const c=Gl[a.chain],y=(c==null?void 0:c.name)||a.chainName||a.chain;return u.jsxs("button",{onClick:()=>t(a.code,a.chain),className:"flex items-center gap-3.5 w-full py-3.5 transition-colors",children:[u.jsxs("div",{className:"relative shrink-0",style:{width:40,height:40},children:[u.jsx("img",{src:qc(a.code,r),alt:a.code,width:32,height:32,className:"rounded-full absolute top-0 left-0",style:{width:32,height:32}}),u.jsx("img",{src:ys(a.chain,r),alt:a.chain,width:16,height:16,className:"rounded-full absolute",style:{width:16,height:16,bottom:0,right:0,border:"2px solid var(--t-chain-border)"}})]}),u.jsxs("div",{className:"text-left flex-1 min-w-0",children:[u.jsx("div",{className:"font-semibold text-[15px] leading-tight",style:{color:"var(--t-text)"},children:a.code}),u.jsx("div",{className:"text-[13px] mt-0.5",style:{color:"var(--t-text-secondary)"},children:a.name})]}),u.jsx("div",{className:"text-right shrink-0",children:u.jsx("div",{className:"text-[13px]",style:{color:"var(--t-text-muted)"},children:y})})]},`${a.code}-${a.chain}`)}),s.length===0&&u.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No currencies found"})]})]})}function wm({checked:e,onChange:t,accentColor:n="var(--t-accent)"}){return u.jsx("button",{onClick:()=>t(!e),className:"relative shrink-0 transition-colors duration-200",style:{width:48,height:28,borderRadius:14,backgroundColor:e?n:"var(--t-border)"},children:u.jsx("div",{className:"absolute top-[3px] rounded-full bg-white shadow transition-transform duration-200",style:{width:22,height:22,transform:e?"translateX(23px)":"translateX(3px)"}})})}const Sm=[{label:"Privacy policy",href:"https://nowramp.com/privacy-policy"},{label:"Terms of use",href:"https://nowramp.com/terms-and-conditions"}];function Em({onClose:e,darkMode:t,onToggleDarkMode:n,skinId:r,onSelectSkin:l}){return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"flex justify-end items-center px-5 pt-5",children:u.jsx(xs,{onClick:e})}),u.jsxs("div",{className:"px-5 flex-1 pt-6 overflow-y-auto custom-scroll",children:[u.jsx("div",{style:{borderTop:"1px solid var(--t-divider)"},children:u.jsxs("div",{className:"flex items-center justify-between w-full py-5",children:[u.jsxs("div",{className:"flex items-center gap-3.5",children:[u.jsx(vm,{size:40}),u.jsx("span",{className:"font-medium text-[15px]",style:{color:"var(--t-text)"},children:"Dark Mode"})]}),u.jsx(wm,{checked:t,onChange:n,accentColor:"#4CD964"})]})}),u.jsx("div",{style:{height:1,background:"var(--t-divider)"}}),Sm.map(o=>u.jsxs("div",{children:[u.jsxs("a",{href:o.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between w-full py-5 transition-colors",children:[u.jsx("span",{className:"font-medium text-[15px]",style:{color:"var(--t-text)"},children:o.label}),u.jsx(hm,{})]}),u.jsx("div",{style:{height:1,background:"var(--t-divider)"}})]},o.label))]})]})}function km({className:e="",theme:t="dark",skinId:n="mono",accentColor:r,bgColor:l,bgImage:o,borderColor:i,borderRadius:s,showFlowToggle:a=!0,autoRedirect:c=!1,explorerUrl:y,doneButtonText:m="Done",supportEmail:h,onDone:x}){var md,hd,yd,vd,gd,xd,wd;const{state:g,dispatch:S,config:_,configLoading:f,quotes:d,quotesLoading:p,quotesError:w,fetchQuotes:C,createOrder:A,orderLoading:v,amountError:T,fieldLocks:R,apiConfig:L,assetBaseUrl:Q}=Mn(),[fe,pe]=k.useState(t==="dark"),[tn,nn]=k.useState(n),[pt,Re]=k.useState(null),[N,P]=k.useState(!1),[I,B]=k.useState(!1),[V,mt]=k.useState(!1),[ae,Ze]=k.useState(null),[ke,ht]=k.useState(!0),[Jl,ql]=k.useState(!1),[Ut,Fn]=k.useState(!1),ws=k.useRef(null),Lr=k.useRef(),F=k.useRef(g.flowType);k.useEffect(()=>{pe(t==="dark")},[t]),k.useEffect(()=>{const M=setTimeout(()=>ht(!1),f?0:800);return()=>clearTimeout(M)},[f]),k.useEffect(()=>{if(F.current!==g.flowType&&!ke){F.current=g.flowType,ql(!0),P(!1),B(!1);const M=setTimeout(()=>ql(!1),350);return()=>clearTimeout(M)}F.current=g.flowType},[g.flowType,ke]);const Z=g.flowType,ne=Z==="buy",re=g.cryptoCurrency||"BTC",q=g.fiatCurrency||"USD",Je=ne?g.fiatAmount:g.cryptoAmount,rn=pm(Je),Un=(md=d==null?void 0:d.bestQuote)!=null&&md.exchangeRate?parseFloat(d.bestQuote.exchangeRate):null,bl=k.useRef(null);Un&&re&&q&&(bl.current={rate:Un,crypto:re,fiat:q});const Tm=k.useMemo(()=>{if(d!=null&&d.bestQuote){const M=ne?d.bestQuote.cryptoAmount:d.bestQuote.fiatAmount;if(M)return M}return"0"},[d,ne]),jm=k.useMemo(()=>{var ge,Bt,ks;const M=Un||((ge=bl.current)==null?void 0:ge.rate),z=Un?re:(Bt=bl.current)==null?void 0:Bt.crypto,ee=Un?q:(ks=bl.current)==null?void 0:ks.fiat;return!M||!z||!ee?"":`1 ${z} ≈ ${M.toFixed(2)} ${ee}`},[re,q,Un]);k.useEffect(()=>{const M=g.walletAddress.trim(),z=g.network;if(!M||M.length<10){Ze(null),S({type:"SET_WALLET_ERROR",message:""});return}return mt(!0),Ze(null),clearTimeout(Lr.current),Lr.current=setTimeout(async()=>{var ee,ge,Bt;try{const Cs=await(await fetch(`${L.apiUrl}/public/validate/address`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:M,...z?{network:z}:{}})})).json(),Ns=((ee=Cs.data)==null?void 0:ee.attributes)||Cs.data||Cs;if(Ns.isValid)Ze(!0),S({type:"SET_WALLET_ERROR",message:""});else{Ze(!1);const Om=((ge=Ns.errors)==null?void 0:ge[0])||((Bt=Ns.details)==null?void 0:Bt.formatMessage)||"Invalid wallet address";S({type:"SET_WALLET_ERROR",message:Om})}}catch{Ze(null)}finally{mt(!1)}},500),()=>clearTimeout(Lr.current)},[g.walletAddress,g.network,L.apiUrl]);const id=!Je||rn===0,sd=rn>0&&(ne?rn<td:rn<nd),ad=!!T||sd||N&&id,Am=rn>0&&!T&&!sd,Ss=g.walletAddress.trim().length>=10&&ae!==!1&&!V,eo=Am&&Ss&&!!g.cryptoCurrency&&!!g.network,Rm=M=>{let z=M.target.value.replace(/[^0-9.,]/g,"");const ee=ne?2:6,ge=z.indexOf(".");ge!==-1&&z.length-ge-1>ee&&(z=z.slice(0,ge+ee+1)),S(ne?{type:"SET_FIAT_AMOUNT",amount:z}:{type:"SET_CRYPTO_AMOUNT",amount:z})},ud=M=>{M!==Z&&S({type:"SET_FLOW_TYPE",flowType:M})},Lm=k.useCallback(M=>{S({type:"SET_FIAT_CURRENCY",currency:M})},[S]),Pm=k.useCallback((M,z)=>{S({type:"SET_CRYPTO_CURRENCY",currency:M}),S({type:"SET_CRYPTO_CHAIN",chain:z})},[S]),Im=()=>{eo&&(Fn(!0),C())};k.useEffect(()=>{var M;if(!(!Ut||p)){if(d!=null&&d.bestQuote)Fn(!1),S({type:"SELECT_QUOTE",quote:d.bestQuote}),A().catch(()=>{});else if(w)Fn(!1),S({type:"SET_ERROR",message:w.message||"No quotes available"});else if(d&&!d.bestQuote){Fn(!1);const z=(M=d.unavailableGateways)==null?void 0:M.map(ge=>ge.reason).filter(Boolean),ee=z!=null&&z.length?`No providers available: ${z.join("; ")}`:"No providers available for this currency/network combination";S({type:"SET_ERROR",message:ee})}}},[Ut,d,p,w,S,A]);const cd=fe?"theme-dark":"theme-light",Es=ed.find(M=>M.id===tn)||ed[0],_m=Es.accent===null,dd=(r?vs(r):!1)?{"--t-accent":r,"--t-cta-bg":r,"--t-cta-text":"#ffffff"}:_m?{"--t-accent":fe?"#ffffff":"#111111","--t-cta-bg":fe?"#ffffff":"#111111","--t-cta-text":fe?"#000000":"#ffffff"}:{"--t-accent":Es.accent,"--t-cta-bg":Es.accent,"--t-cta-text":"#ffffff"},ln={};l&&vs(l)?ln.backgroundColor=l:ln.backgroundColor="var(--t-bg)",o&&(ln.backgroundImage=`url(${o})`,ln.backgroundSize="cover",ln.backgroundPosition="center");const to={};i&&vs(i)&&(to.border=`1px solid ${i}`),s&&(to.borderRadius=s);const fd=g.step==="checkout"?u.jsx(tm,{autoRedirect:c}):g.step==="processing"?u.jsx(rm,{}):g.step==="complete"?u.jsx(lm,{explorerUrl:y,doneButtonText:m,onDone:x}):g.step==="error"?u.jsx(om,{supportEmail:h}):g.step==="confirm"?u.jsx(im,{}):null;if(fd)return u.jsx("div",{className:`${cd} relative w-full max-w-[390px] h-[640px] overflow-hidden flex flex-col select-none transition-colors duration-300 ${e}`,style:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...ln,...dd,...to},children:fd});const yt=g.network,Bn=yt?Gl[yt]:null,pd=(Bn==null?void 0:Bn.shortName)||(Bn==null?void 0:Bn.name)||yt;return u.jsxs("div",{className:`${cd} relative w-full max-w-[390px] min-h-[640px] overflow-hidden flex flex-col select-none transition-colors duration-300 ${e}`,style:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...ln,...dd,...to},children:[u.jsx("div",{className:`flex justify-end items-center px-5 pt-3 ${a?"pb-1":"pb-5"}`,children:u.jsx(ym,{onClick:()=>Re("settings")})}),a?u.jsxs("div",{className:"flex flex-col items-center pt-3 pb-5",children:[u.jsxs("div",{className:"flex",style:{width:165},children:[u.jsx("button",{onClick:()=>ud("buy"),className:"flex-1 pb-2.5 text-[16px] font-medium text-center transition-colors duration-200",style:{color:Z==="buy"?"var(--t-text)":"var(--t-text-secondary)"},children:"Buy"}),u.jsx("button",{onClick:()=>ud("sell"),className:"flex-1 pb-2.5 text-[16px] font-medium text-center transition-colors duration-200",style:{color:Z==="sell"?"var(--t-text)":"var(--t-text-secondary)"},children:"Sell"})]}),u.jsxs("div",{className:"relative",style:{width:165,height:1},children:[u.jsx("div",{className:"absolute inset-0",style:{background:"var(--t-divider)"}}),u.jsx("div",{className:"absolute top-0 h-full transition-all duration-300 ease-in-out",style:{width:"50%",left:Z==="buy"?"0%":"50%",background:"var(--t-accent)"}})]})]}):null,ke||Jl||f?u.jsx(um,{}):u.jsxs("div",{className:"flex-1 overflow-hidden px-5 flex flex-col tab-fade-in",children:[u.jsxs("div",{className:"px-[18px] pt-[14px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5,border:N&&ad?"1px solid #EF4444":"1px solid transparent"},children:[u.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"You spend"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("input",{ref:ws,type:"text",value:Je,onChange:Rm,onBlur:()=>P(!0),placeholder:ne?"250":"0.01",className:"bg-transparent outline-none w-0 flex-1 mr-3",style:{color:"var(--t-text)",fontSize:24,fontWeight:600,lineHeight:"32px"},inputMode:"decimal",disabled:!!((hd=R==null?void 0:R.sourceAmount)!=null&&hd.locked)}),ne?u.jsxs("button",{onClick:()=>Re("fiat"),className:"flex items-center gap-1.5 shrink-0 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((yd=R==null?void 0:R.sourceCurrency)!=null&&yd.locked),children:[u.jsx(gs,{currencyCode:q,size:16,baseUrl:Q}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:q}),u.jsx(Zl,{})]}):u.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[u.jsxs("button",{onClick:()=>Re("crypto"),className:"flex items-center gap-1.5 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((vd=R==null?void 0:R.destinationCurrency)!=null&&vd.locked),children:[u.jsx(rd,{ticker:re,size:16,baseUrl:Q}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:re}),u.jsx(Zl,{})]}),yt&&u.jsxs("div",{className:"flex items-center gap-1 mt-1.5 mr-0.5",children:[u.jsx("img",{src:ys(yt,Q),alt:yt,width:14,height:14,className:"rounded-full",style:{width:14,height:14}}),u.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:pd})]})]})]})]}),N&&ad&&u.jsx("div",{className:"text-[12px] mt-1.5 px-[2px]",style:{color:"#EF4444"},children:T||(id?"Amount should be more than 0":ne?`Minimum amount is ${td} ${q}`:`Minimum amount is ${nd} ${re}`)}),u.jsxs("div",{className:"px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)",borderTopLeftRadius:5,borderTopRightRadius:5,borderBottomLeftRadius:0,borderBottomRightRadius:0,marginTop:4},children:[u.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"You get"}),u.jsxs("div",{className:"flex items-start justify-between",children:[p?u.jsx($e,{w:180,h:32}):u.jsx(am,{value:rn>0?Tm:"0",height:32,className:"font-semibold",style:{color:rn>0?"var(--t-text)":"var(--t-text-muted)",fontSize:24}}),ne?u.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[u.jsxs("button",{onClick:()=>Re("crypto"),className:"flex items-center gap-1.5 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((gd=R==null?void 0:R.destinationCurrency)!=null&&gd.locked),children:[u.jsx(rd,{ticker:re,size:16,baseUrl:Q}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:re}),u.jsx(Zl,{})]}),yt&&u.jsxs("div",{className:"flex items-center gap-1 mt-1.5 mr-0.5",children:[u.jsx("img",{src:ys(yt,Q),alt:yt,width:14,height:14,className:"rounded-full",style:{width:14,height:14}}),u.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:pd})]})]}):u.jsxs("button",{onClick:()=>Re("fiat"),className:"flex items-center gap-1.5 shrink-0 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((xd=R==null?void 0:R.sourceCurrency)!=null&&xd.locked),children:[u.jsx(gs,{currencyCode:q,size:16,baseUrl:Q}),u.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:q}),u.jsx(Zl,{})]})]})]}),u.jsx("div",{className:"flex items-center justify-between mt-[2px] px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)"},children:u.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-secondary)"},children:jm||" "})}),u.jsxs("div",{className:"mt-8",children:[u.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"Wallet address"}),u.jsx("input",{type:"text",value:g.walletAddress,onChange:M=>S({type:"SET_WALLET_ADDRESS",address:M.target.value}),onBlur:()=>B(!0),placeholder:"Enter your wallet address",spellCheck:!1,autoComplete:"off",className:"w-full bg-transparent text-[13px] outline-none transition-colors",style:{border:g.walletError||I&&!Ss?"1px solid #EF4444":"1px solid var(--t-border)",borderRadius:3.5,height:47,paddingLeft:14,paddingRight:14,color:"var(--t-text)"},disabled:!!((wd=R==null?void 0:R.destinationAddress)!=null&&wd.locked)}),g.walletError?u.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"#EF4444"},children:g.walletError}):I&&!Ss&&!V?u.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"#EF4444"},children:"Enter a valid wallet address"}):V&&g.walletAddress.trim().length>=10?u.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"var(--t-text-muted)"},children:"Validating address..."}):null]}),u.jsx("div",{className:"flex-1"}),u.jsx("button",{disabled:!eo||v||Ut,onClick:Im,className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",opacity:eo&&!v&&!Ut?1:.4,cursor:eo&&!v&&!Ut?"pointer":"not-allowed"},children:Ut?"Getting best price...":v?"Processing...":ne?`Buy ${re}`:`Sell ${re}`}),u.jsx("div",{className:"text-center py-3",children:u.jsx("span",{className:"text-[11px]",style:{color:"var(--t-text-tertiary)"},children:"Powered by NowRamp"})})]},Z),u.jsx(hs,{isOpen:pt==="fiat",onClose:()=>Re(null),children:M=>{var z;return u.jsx(gm,{onClose:M,onSelect:ee=>{Lm(ee),M()},currencies:(z=_==null?void 0:_.fiats)==null?void 0:z.map(ee=>({code:ee.code,name:ee.code})),assetBaseUrl:Q})}}),u.jsx(hs,{isOpen:pt==="crypto",onClose:()=>Re(null),children:M=>{var z;return u.jsx(xm,{onClose:M,onSelect:(ee,ge)=>{Pm(ee,ge),M()},cryptos:(z=_==null?void 0:_.cryptos)==null?void 0:z.map(ee=>{var ge;return{code:ee.code,name:ee.code,networks:(ge=ee.networks)==null?void 0:ge.map(Bt=>({code:Bt.id,name:Bt.name}))}}),assetBaseUrl:Q})}}),u.jsx(hs,{isOpen:pt==="settings",onClose:()=>Re(null),children:M=>u.jsx(Em,{onClose:M,darkMode:fe,onToggleDarkMode:pe,skinId:tn,onSelectSkin:z=>{nn(z)}})})]})}function od({projectId:e,apiUrl:t,assetBaseUrl:n,flowType:r,customerId:l,defaultFiatCurrency:o,defaultCryptoCurrency:i,defaultNetwork:s,defaultFiatAmount:a,defaultCryptoAmount:c,defaultWalletAddress:y,defaultGateway:m,fieldLocks:h,statusPollInterval:x,onComplete:g,onError:S,className:_,theme:f,skinId:d,accentColor:p,bgColor:w,bgImage:C,borderColor:A,borderRadius:v,showFlowToggle:T,autoRedirect:R,explorerUrl:L,doneButtonText:Q,supportEmail:fe,onDone:pe}){return u.jsx(em,{projectId:e,apiUrl:t,assetBaseUrl:n,flowType:r,customerId:l,defaultFiatCurrency:o,defaultCryptoCurrency:i,defaultNetwork:s,defaultFiatAmount:a,defaultCryptoAmount:c,defaultWalletAddress:y,defaultGateway:m,fieldLocks:h,statusPollInterval:x,onComplete:g,onError:S,children:u.jsx(km,{className:_,theme:f,skinId:d,accentColor:p,bgColor:w,bgImage:C,borderColor:A,borderRadius:v,showFlowToggle:T,autoRedirect:R,explorerUrl:L,doneButtonText:Q,supportEmail:fe,onDone:pe})})}const Rr=new Map;function Cm(e,t){const n=typeof e=="string"?document.querySelector(e):e;if(!n){console.error(`[NowRampForm] Element not found: ${e}`);return}const r=Rr.get(n);r&&(r.unmount(),Rr.delete(n));const l=Vc(n);Rr.set(n,l),l.render(Mr.createElement(od,t))}function Nm(e){const t=typeof e=="string"?document.querySelector(e):e;if(!t)return;const n=Rr.get(t);n&&(n.unmount(),Rr.delete(t))}Pr.RampForm=od,Pr.mount=Cm,Pr.unmount=Nm,Object.defineProperty(Pr,Symbol.toStringTag,{value:"Module"})})(this.NowRampForm=this.NowRampForm||{});
55
55
  //# sourceMappingURL=nowramp-form.iife.js.map