import{o as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{T as r,Vt as i,j as a,l as o,y as s}from"./useActiveWallet-CEs8euQ3.js";import"./context-Cdw68BC2.js";import{c}from"./toViemAccount-BywVRwQG.js";import{t as l}from"./modal-context-DHfp-mFQ.js";import{l as u,r as d,u as f}from"./ModalHeader-BS54PZSj.js";import{t as p}from"./Layouts-BlFm53ED.js";import{t as m}from"./analytics-mkkvFRju.js";import{t as h}from"./ArrowsRightLeftIcon.js";import{t as g}from"./CheckCircleIcon2.js";var _=n(),v=e(t(),1);a();var y={component:()=>{let{data:e,setModalData:t,navigate:n,navigateBack:r}=l(),{closePrivyModal:a,createAnalyticsEvent:o,client:s}=i(),[c,u]=(0,v.useState)(`pending-in-flow`),p=(0,v.useRef)(0),h={...e?.funding,showAlternateFundingMethod:!0};h.usingDefaultFundingMethod&&=!1;let{partnerUserId:g,popup:y}=e?.coinbaseOnrampStatus??{};return(0,v.useEffect)((()=>{if(c===`pending-in-flow`||c===`pending-after-flow`){let r=setInterval((async()=>{if(g)try{let{status:r}=await s.getCoinbaseOnRampStatus({partnerUserId:g});if(r===`success`)return void u(`success`);if(r===`failure`)throw Error(`There was an error completing Coinbase Onramp flow.`);if(p.current>=3)return t({funding:h,solanaFundingData:e?.solanaFundingData}),void n(`FundingMethodSelectionScreen`);y?.closed&&(p.current+=1,u(`pending-after-flow`))}catch(r){console.error(r),u(`error`),o({eventName:m,payload:{status:`failure`,provider:`coinbase-onramp`,error:r.message}}),t({funding:{...h,errorMessage:`Something went wrong adding funds. Please try again or use another method.`},solanaFundingData:e?.solanaFundingData}),n(`FundingMethodSelectionScreen`)}}),1500);return()=>clearInterval(r)}}),[g,y,c]),(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d,{title:`Fund account`,backFn:()=>{t({funding:h,solanaFundingData:e?.solanaFundingData}),r()}},`header`),(0,_.jsx)(b,{status:c,onClickCta:a}),(0,_.jsx)(f,{})]})}},b=({status:e,onClickCta:t})=>{let{title:n,body:r,cta:i}=(0,v.useMemo)((()=>(e=>{switch(e){case`success`:return{title:`You've funded your account!`,body:`It may take a few minutes for the assets to appear.`,cta:`Continue`};case`pending-after-flow`:return{title:`In Progress`,body:`Almost done. Retrieving transaction status from Coinbase`,cta:``};case`error`:case`pending-in-flow`:return{title:`In Progress`,body:`Go back to Coinbase Onramp to finish funding your account.`,cta:``}}})(e)),[e]);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(C,{children:[(0,_.jsx)(x,{isSucccess:e===`success`}),(0,_.jsxs)(p,{children:[(0,_.jsx)(`h3`,{children:n}),(0,_.jsx)(S,{children:r})]})]}),i&&(0,_.jsx)(u,{onClick:t,children:i})]})},x=({isSucccess:e})=>{if(!e){let e=`var(--privy-color-foreground-4)`;return(0,_.jsxs)(`div`,{style:{position:`relative`},children:[(0,_.jsx)(s,{color:e,style:{position:`absolute`}}),(0,_.jsx)(o,{color:e}),(0,_.jsx)(c,{style:{position:`absolute`,width:`2.8rem`,height:`2.8rem`,top:`1.2rem`,left:`1.2rem`}})]})}let t=e?g:()=>(0,_.jsx)(h,{width:`3rem`,height:`3rem`,style:{backgroundColor:`var(--privy-color-foreground-4)`,color:`var(--privy-color-background)`,borderRadius:`100%`,padding:`0.5rem`,margin:`0.5rem`}}),n=e?`var(--privy-color-success)`:`var(--privy-color-foreground-4)`;return(0,_.jsx)(`div`,{style:{borderColor:n,display:`flex`,justifyContent:`center`,alignItems:`center`,borderRadius:`100%`,borderWidth:2,padding:`0.5rem`,marginBottom:`0.5rem`},children:t&&(0,_.jsx)(t,{width:`4rem`,height:`4rem`,color:n})})},S=r.p`
  font-size: 1rem;
  color: var(--privy-color-foreground-3);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
`,C=r.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-left: 1.75rem;
  margin-right: 1.75rem;
  padding: 2rem 0;
`;export{y as CoinbaseOnrampStatusScreen,y as default};