1import{gX as j,gR as T,gT as v,gV as W,gN as D,gP as E,ka as $,B as c,gx as K,gp as Z,kb as ee,go as ae,gn as ne,kc as te,i9 as N,gy as re,j as t,j4 as S,jD as q,kd as ie,gC as se}from"./index-BSx329UM.js";import{F as oe}from"./ArrowsRightLeftIcon-Cpp6DHZI.js";import{u as de}from"./ModalHeader-DffkxvO4-4hAT2A9_.js";import{t as ce}from"./FundWalletMethodHeader-A50eT5P4-DeyUgsJx.js";import{t as le}from"./ErrorBanner-CQERa7bL-B_orRPdi.js";import{i as ue}from"./InfoBanner-DkQEPd77-DYC8wDaa.js";import{h as he,t as pe}from"./GooglePay-DA-Ff7zK-B-XANHAd.js";import{e as me}from"./WalletCards-DH1rqayz-CMHQSaRC.js";import{a as fe}from"./getErc20TokenInfo-BKTIPvdP-CHx5S2BN.js";import{l as ge}from"./index-DuSdaxpe-CmTEYg4O.js";import{e as ye,n as k,m as be,f as we}from"./styles-ByUO8DsA-CZMGYBE3.js";import"./ExclamationCircleIcon-DZJ7Qyom.js";import"./analytics-mkkvFRju-DOXuftJB.js";import"./LinkPasskeyScreen-C-MqivSL-CegMy8r7.js";import"./TodoList-CgrU7uwu-BPLRFI_B.js";import"./x-DJH24y2V.js";import"./createLucideIcon-DVQ5gbwD.js";import"./check-HNrCic8x.js";import"./ScreenLayout-Caq5mGD8-C8e_i3Eq.js";import"./Screen-D8KNyGVj-aZIJz9Of.js";import"./index-Dq_xe9dz-txSzgltx.js";import"./circle-check-big-BBmS3Rm6.js";import"./fingerprint-pattern-DMXeGVu0.js";let ve=new Set([j.id,T.id,W.id,v.id,D.id,E.id,$.id]),Ce=new Set([j.id,T.id,v.id,W.id,D.id,E.id,$.id]),xe={buy:"CARD",send:"CRYPTO_ACCOUNT"},Fe={USDC:"2b92315d-eab7-5bef-84fa-089a131333f5",ETH:"d85dce9b-5b73-5c3c-8978-522ce1d1c1b4",BTC:"5b71fc48-3dd3-540c-809b-f8c94d0e68b5",SOL:"4f039497-3af8-5bb3-951c-6df9afa9be1c",POL:"026bcc1e-9163-591c-a709-34dd18b2e7a1",MON:"92aa538f-b005-45cc-a237-71d6466f54d9"};j.id+"",T.id+"",W.id+"",v.id+"",D.id+"",E.id+"";function Me({appId:a,input:e,amount:i,blockchain:o,asset:l,experience:h}){let r=new URL("https://pay.coinbase.com/buy/select-asset");return r.searchParams.set("appId",e.app_id),r.searchParams.set("sessionToken",e.session_token),r.searchParams.set("endPartnerName",`privy:${a}`),r.searchParams.set("defaultExperience",h),r.searchParams.set("presetCryptoAmount",i.startsWith(".")?`0${i}`:i),r.searchParams.set("defaultNetwork",o),r.searchParams.set("defaultPaymentMethod",xe[h]),r.searchParams.set("defaultAsset",Fe[l]),r.searchParams.set("partnerUserId",e.partner_user_id),{url:r}}const Se=(a,e)=>{switch(e){case"native-currency":return ve.has(a);case"USDC":return Ce.has(a);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}};function ke(a,e){return a===v.id?"POL":a===$.id?"MON":"ETH"}function je({title:a,titleId:e,...i},o){return c.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:o,"aria-labelledby":e},i),a?c.createElement("title",{id:e},a):null,c.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 8.25h19.5M2.25 9h19.5m-16.5 5.25h6m-6 2.25h3m-3.75 3h15a2.25 2.25 0 0 0 2.25-2.25V6.75A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25v10.5A2.25 2.25 0 0 0 4.5 19.5Z"}))}const Te=c.forwardRef(je);function We({title:a,titleId:e,...i},o){return c.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:o,"aria-labelledby":e},i),a?c.createElement("title",{id:e},a):null,c.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 3.75 9.375v-4.5ZM3.75 14.625c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5a1.125 1.125 0 0 1-1.125-1.125v-4.5ZM13.5 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 13.5 9.375v-4.5Z"}),c.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 6.75h.75v.75h-.75v-.75ZM6.75 16.5h.75v.75h-.75v-.75ZM16.5 6.75h.75v.75h-.75v-.75ZM13.5 13.5h.75v.75h-.75v-.75ZM13.5 19.5h.75v.75h-.75v-.75ZM19.5 13.5h.75v.75h-.75v-.75ZM19.5 19.5h.75v.75h-.75v-.75ZM16.5 16.5h.75v.75h-.75v-.75Z"}))}const De=c.forwardRef(We),B=a=>{let[e,i]=c.useState();return c.useEffect((()=>{a().then((o=>{i(o)})).catch((()=>{}))}),[]),e};function Ee(a){let e=$e[a];if(!e)throw new se(`Unsupported chainId: ${a} for Coinbase Onramp`);return e}let $e={[j.id]:"ethereum",[T.id]:"base",[W.id]:"optimism",[v.id]:"polygon",[D.id]:"arbitrum",[E.id]:"avacchain",[$.id]:"monad"};const V=(a,e,i,o,l,h)=>new Promise((async(r,p)=>{let n=q();if(!n)return void p(Error("Unable to initialize flow"));let y=e.chainType==="ethereum"?Ee(e.chain.id):"solana",b=e.isUSDC?"USDC":e.chainType==="ethereum"?ke(e.chain.id):"SOL",g=await a.initCoinbaseOnRamp({addresses:[{address:e.address,blockchains:[y]}],assets:[b]}),{url:d}=Me({appId:a.getAppId(),input:g,amount:e.amount,blockchain:y,asset:b,experience:h});n.location=d.toString();let s={...l?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(s.usingDefaultFundingMethod=!1),i({funding:s,solanaFundingData:l?.solanaFundingData,coinbaseOnrampStatus:{popup:n}}),o("CoinbaseOnrampStatusScreen"),a.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:e.amount,chainType:e.chainType,chainId:e.chainType==="ethereum"?e.chain.id:e.chain}}),setTimeout((()=>{i({funding:s,solanaFundingData:l?.solanaFundingData,coinbaseOnrampStatus:{partnerUserId:g.partner_user_id,popup:n}})}),5e3),r()})),Ae=async(a,e,i,o,l,h,r,p)=>{let n=q();if(!n)throw Error("Unable to initialize flow");let y=e.chainType==="ethereum"?ie(e.chain.id,o):e.isUSDC?"USDC_SOL":"SOL",{signedUrl:b,externalTransactionId:g}=await a.signMoonpayOnRampUrl({address:e.address,useSandbox:i.fundingMethodConfig.moonpay.useSandbox??!1,config:{uiConfig:{accentColor:i.appearance.palette.accent,theme:i.appearance.palette.colorScheme},paymentMethod:p,currencyCode:y,quoteCurrencyAmount:ge(e.amount)}});a.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"moonpay",value:e.amount,chainType:e.chainType,chainId:e.chainType==="ethereum"?e.chain.id:e.chain}}),n.location=b;let d={...r?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(d.usingDefaultFundingMethod=!1),l({moonpayStatus:{},funding:d,solanaFundingData:r?.solanaFundingData}),h("MoonpayStatusScreen"),setTimeout((()=>{l({moonpayStatus:{externalTransactionId:g},funding:d,solanaFundingData:r?.solanaFundingData})}),8e3)};let H=async a=>typeof window<"u"&&"PaymentRequest"in window&&await new window.PaymentRequest([{supportedMethods:a}],{id:"0",total:{label:"Item",amount:{currency:"USD",value:"1.00"}}}).canMakePayment();const Pe=()=>H("https://apple.com/apple-pay"),Oe=()=>H("https://google.com/pay"),ia={component:()=>{let{wallets:a}=K(),{connectors:e}=Z(),i=e.filter(ee).flatMap((m=>m.wallets)),{navigate:o,data:l,setModalData:h}=ae(),{client:r}=Z(),p=ne(),n=l?.funding,y=B(Pe),b=B(Oe),g=n.chainType==="solana",d=g?void 0:n,s=c.useMemo((()=>((m,P,u,O,F,M)=>{let I,L,U=u.chainType==="solana",G=U?void 0:u,w=u.isUSDC?"USDC":G?.erc20Address?void 0:"native-currency",X=!!U||w&&te(Number(u.chain.id),w),R=!!U||w&&Se(Number(u.chain.id),w),_=[];for(let f of(u.preferredCardProvider&&u.supportedOptions.sort((J=>J.provider===u.preferredCardProvider?-1:1)),u.supportedOptions))f.method==="card"&&f.provider==="coinbase"&&R&&_.push((()=>V(P,u,O,F,M,"buy"))),f.method==="card"&&f.provider==="moonpay"&&X&&w&&_.push((()=>Ae(P,u,m,w,O,F,M,"credit_debit_card")));for(let f of u.supportedOptions)f.method==="exchange"&&f.provider==="coinbase"&&R&&(I=()=>V(P,u,O,F,M,"buy"));for(let f of M?.funding?.supportedOptions??[])f.method==="wallets"&&(L=()=>F("TransferFromWalletScreen"));return{onFundWithCard:_,onFundWithExchange:I,onFundWithWallet:L}})(p,r,n,h,o,l)),[p,r,n,l,h,o]),A=g?i.find((({address:m})=>m===n.address)):a.find((({address:m})=>N(m)===N(n.address))),Q=re(A?.walletClientType||"unknown"),Y=Q?.name||"wallet",C=A&&A.walletClientType!=="privy"?Y:p.name,z=c.useMemo((()=>
1n.uiConfig?.landing?.title?n.uiConfig?.landing?.title:`Add funds to your ${C?.toLowerCase().endsWith("wallet")?C:C+" wallet"}`),[n.uiConfig?.landing?.title,C]);c.useEffect((()=>{if(n?.defaultFundingMethod&&n.usingDefaultFundingMethod)switch(h({funding:{...n,usingDefaultFundingMethod:!1},solanaFundingData:l?.solanaFundingData}),n?.defaultFundingMethod){case"card":s.onFundWithCard[0]&&s.onFundWithCard[0]();break;case"exchange":s.onFundWithExchange&&s.onFundWithExchange();break;case"wallet":s.onFundWithWallet&&s.onFundWithWallet();break;case"manual":o("ManualTransferScreen")}}),[]),c.useEffect((()=>{d?.erc20Address&&!d.erc20ContractInfo&&fe({address:d.erc20Address,chain:d.chain,rpcConfig:p.rpcConfig,privyAppId:p.id}).then((m=>{h({...l,funding:{...d,erc20ContractInfo:m?{symbol:m.symbol,decimals:m.decimals}:void 0}})})).catch(console.error)}),[d?.erc20Address,d?.chain]);let x=!(!d?.erc20Address||d?.erc20ContractInfo);return t.jsxs(t.Fragment,{children:[t.jsx(ce,{}),t.jsx("h3",{children:z}),t.jsxs(ye,{children:[n.errorMessage&&t.jsx(le,{theme:p.appearance.palette.colorScheme,children:n.errorMessage}),s.onFundWithCard?.[0]&&t.jsxs(S,{disabled:x,onClick:s.onFundWithCard[0],children:[t.jsx(k,{children:t.jsx(Te,{style:{width:24}})}),"Pay with card",y?t.jsx(he,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):b?t.jsx(pe,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):null]}),s.onFundWithExchange&&t.jsxs(S,{disabled:x,onClick:s.onFundWithExchange,children:[t.jsx(k,{children:t.jsx(oe,{style:{width:24}})}),"Transfer from an exchange"]}),s.onFundWithWallet&&t.jsxs(S,{disabled:x,onClick:s.onFundWithWallet,children:[t.jsx(k,{children:t.jsx(me,{style:{width:24}})}),"Transfer from wallet"]}),t.jsxs(S,{disabled:x,onClick:()=>o("ManualTransferScreen"),children:[t.jsx(k,{children:t.jsx(De,{style:{width:24}})}),"Receive funds"]}),n?.showAlternateFundingMethod&&s.onFundWithCard?.[1]&&t.jsx(ue,{theme:p.appearance.palette.colorScheme,children:t.jsxs(be,{children:["Having trouble or facing location restrictions?"," ",t.jsx(we,{onClick:s.onFundWithCard[1],children:"Try a different provider."})]})})]}),t.jsx(de,{})]})}};export{ia as FundingMethodSelectionScreen,ia as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.