"use strict";var e=require("react/jsx-runtime"),r=require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),t=require("@heroicons/react/24/solid/CheckCircleIcon"),i=require("react"),n=require("styled-components"),o=require("./ModalHeader-Cpls13mi.js"),s=require("./Layouts-D3TOcPhm.js"),a=require("./useActiveWallet-dTc6deka.js"),u=require("./internal-context-CdsQ3LEl.js"),c=require("./modal-context-BgeioxwT.js"),l=require("./analytics-C6C_4JmG.js"),d=require("./toViemAccount-CopJpCYv.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./context-rs-ygOK2.js"),require("@privy-io/js-sdk-core"),require("tinycolor2"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("viem/utils"),require("./wallet-connect-BuohfvHK.js"),require("./errors-CBapWvRs.js"),require("ofetch"),require("./getPublicClient-CFd_sHBk.js"),require("viem"),require("viem/chains"),require("eventemitter3"),require("./events-context-Di6--rDg.js"),require("./privy-context-UTJouJ1x.js"),require("@privy-io/are-addresses-equal"),require("./index-Ub4KpwSY.js"),require("zustand"),require("react-device-detect"),require("./get-entropy-details-for-user-D63rM5_a.js"),require("./user-D2oPA-vS.js"),require("jose"),require("@coinbase/wallet-sdk"),require("@walletconnect/ethereum-provider"),require("./pkce-CmuJlEgn.js"),require("./paths-DizMb-lU.js"),require("./PrivyPluginContext-DsLtVhZA.js"),require("js-cookie"),require("@privy-io/ethereum"),require("viem/accounts");var m=/*#__PURE__*/g(r),f=/*#__PURE__*/g(t);const p={component:()=>{let{data:r,setModalData:t,navigate:n,navigateBack:s}=c.usePrivyModal(),{closePrivyModal:a,createAnalyticsEvent:d,client:g}=u.usePrivyInternal(),[m,f]=i.useState("pending-in-flow"),p=i.useRef(0),y={...r?.funding,showAlternateFundingMethod:!0};y.usingDefaultFundingMethod&&(y.usingDefaultFundingMethod=!1);let{partnerUserId:v,popup:j}=r?.coinbaseOnrampStatus??{};return i.useEffect((()=>{if("pending-in-flow"===m||"pending-after-flow"===m){let e=setInterval((async()=>{if(v)try{let{status:e}=await g.getCoinbaseOnRampStatus({partnerUserId:v});if("success"===e)return void f("success");if("failure"===e)throw Error("There was an error completing Coinbase Onramp flow.");if(p.current>=3)return t({funding:y,solanaFundingData:r?.solanaFundingData}),void n("FundingMethodSelectionScreen");j?.closed&&(p.current=p.current+1,f("pending-after-flow"))}catch(e){console.error(e),f("error"),d({eventName:l.ON_RAMP_COMPLETE_ANALYTICS_EVENT,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),t({funding:{...y,errorMessage:"Something went wrong adding funds. Please try again or use another method."},solanaFundingData:r?.solanaFundingData}),n("FundingMethodSelectionScreen")}}),1500);return()=>clearInterval(e)}}),[v,j,m]),/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(o.ModalHeader,{title:"Fund account",backFn:()=>{t({funding:y,solanaFundingData:r?.solanaFundingData}),s()}},"header"),/*#__PURE__*/e.jsx(h,{status:m,onClickCta:a}),/*#__PURE__*/e.jsx(o.BlobbyFooter,{})]})}};let h=({status:r,onClickCta:t})=>{let{title:n,body:a,cta:u}=i.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:""}}})(r)),[r]);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(j,{children:[/*#__PURE__*/e.jsx(y,{isSucccess:"success"===r}),/*#__PURE__*/e.jsxs(s.FixedGappedContainer,{children:[/*#__PURE__*/e.jsx("h3",{children:n}),/*#__PURE__*/e.jsx(v,{children:a})]})]}),u&&/*#__PURE__*/e.jsx(o.PrimaryButton,{onClick:t,children:u})]})},y=({isSucccess:r})=>{if(!r){let r="var(--privy-color-foreground-4)";/*#__PURE__*/return e.jsxs("div",{style:{position:"relative"},children:[/*#__PURE__*/e.jsx(a.Loader,{color:r,style:{position:"absolute"}}),/*#__PURE__*/e.jsx(a.LoaderFaint,{color:r}),/*#__PURE__*/e.jsx(d.CoinbaseWallet,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let t=r?f.default:()=>/*#__PURE__*/e.jsx(m.default,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}}),i=r?"var(--privy-color-success)":"var(--privy-color-foreground-4)";/*#__PURE__*/return e.jsx("div",{style:{borderColor:i,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:t&&/*#__PURE__*/e.jsx(t,{width:"4rem",height:"4rem",color:i})})},v=n.styled.p`
  font-size: 1rem;
  color: var(--privy-color-foreground-3);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
`,j=n.styled.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-left: 1.75rem;
  margin-right: 1.75rem;
  padding: 2rem 0;
`;exports.CoinbaseOnrampStatusScreen=p,exports.default=p;
//# sourceMappingURL=CoinbaseOnrampStatusScreen-CGpR3eSA.js.map
