@privy-io/react-auth 2.4.3 → 2.4.5

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.
Files changed (41) hide show
  1. package/dist/cjs/abstract-smart-wallets.js +1 -1
  2. package/dist/cjs/{importWallet-BvzASqsr.js → importWallet-DbohmIiw.js} +1 -1
  3. package/dist/cjs/index.js +21 -21
  4. package/dist/cjs/{prepareFundingModalData-C8wPeHar.js → prepareFundingModalData-BdtVxCug.js} +1 -1
  5. package/dist/cjs/{smart-wallets-DlC_5Y5l.js → smart-wallets-DR6SCvrN.js} +1 -1
  6. package/dist/cjs/smart-wallets.js +1 -1
  7. package/dist/cjs/solana.js +1 -1
  8. package/dist/cjs/ui.js +2 -2
  9. package/dist/cjs/useActiveWallet-BmSLq25D.js +5 -0
  10. package/dist/cjs/{useFundWallet-2Ezrz28N.js → useFundWallet-DNBXOQPj.js} +1 -1
  11. package/dist/cjs/useWallets-C7Zst89H.js +1 -0
  12. package/dist/dts/farcaster.d.mts +1 -1
  13. package/dist/dts/farcaster.d.ts +1 -1
  14. package/dist/dts/index.d.mts +8 -9
  15. package/dist/dts/index.d.ts +8 -9
  16. package/dist/dts/smart-wallets.d.mts +1 -1
  17. package/dist/dts/smart-wallets.d.ts +1 -1
  18. package/dist/dts/solana.d.mts +4 -4
  19. package/dist/dts/solana.d.ts +4 -4
  20. package/dist/dts/{types-CjeWF_LJ.d.mts → types-BKBPK3tN.d.mts} +4 -2
  21. package/dist/dts/{types-CjeWF_LJ.d.ts → types-BKBPK3tN.d.ts} +4 -2
  22. package/dist/dts/ui.d.mts +1 -1
  23. package/dist/dts/ui.d.ts +1 -1
  24. package/dist/dts/{useSolanaWallets-CXnYSqQR.d.mts → useSolanaWallets-BkzftCx7.d.mts} +1 -1
  25. package/dist/dts/{useSolanaWallets-CXnYSqQR.d.ts → useSolanaWallets-BkzftCx7.d.ts} +1 -1
  26. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  27. package/dist/esm/{importWallet-DfwAobLp.mjs → importWallet-ylHVDCXz.mjs} +1 -1
  28. package/dist/esm/index.mjs +21 -21
  29. package/dist/esm/{prepareFundingModalData-R09VUVWm.mjs → prepareFundingModalData-CsN1TYQy.mjs} +1 -1
  30. package/dist/esm/{smart-wallets-BKO_VzqX.mjs → smart-wallets-gIJUc6-6.mjs} +1 -1
  31. package/dist/esm/smart-wallets.mjs +1 -1
  32. package/dist/esm/solana.mjs +1 -1
  33. package/dist/esm/ui.mjs +2 -2
  34. package/dist/esm/useActiveWallet-DvvTjRH_.mjs +5 -0
  35. package/dist/esm/{useFundWallet-vjrQZZWa.mjs → useFundWallet-DS1kytse.mjs} +1 -1
  36. package/dist/esm/useWallets-8w3LVxdW.mjs +1 -0
  37. package/package.json +6 -6
  38. package/dist/cjs/useActiveWallet-DUvjidjw.js +0 -5
  39. package/dist/cjs/useWallets-DobnZGpT.js +0 -1
  40. package/dist/esm/useActiveWallet-CRQOoJef.mjs +0 -5
  41. package/dist/esm/useWallets-Bm3b-V02.mjs +0 -1
@@ -1,22 +1,22 @@
1
- import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createStore as r}from"mipd";import a,{useMemo as i,useEffect as o,useState as s,useRef as l,useCallback as c,useReducer as d,forwardRef as h,useContext as u,createContext as p}from"react";import*as m from"react-device-detect";import{isMobile as y,isIOS as f,isSafari as w,isAndroid as v}from"react-device-detect";import{getAddress as C}from"viem/utils";import{P as E,f as T,a as b,b as A,c as _,d as k,e as I,u as N,g as x,h as S,i as R,j as O,n as L,k as P,I as M}from"./internal-context-DBDJ7qsa.mjs";import{c as U,p as D,a as F,b as B,u as z,f as H,d as V,e as $,g as G,h as q,o as j,i as K,j as Y,k as Z,l as X,m as Q,n as J,q as ee,r as te,s as ne,t as re,v as ie,w as oe,x as se,y as le,z as ce,A as de,B as he,C as ue,D as pe,E as me,F as ye,G as ge,H as fe,I as we,J as ve,K as Ce,L as Ee,M as Te,N as be,O as Ae,P as _e,Q as ke,R as Ie,S as Ne,T as xe,U as Se,V as Re,W as Oe,X as We,Y as Le,Z as Pe,_ as Me,$ as Ue,a0 as De,a1 as Fe,a2 as Be,a3 as ze,a4 as He,a5 as Ve,a6 as $e,a7 as Ge}from"./paths-CasJYDld.mjs";import{o as qe,R as je,C as Ke,E as Ye,a as Ze,P as Xe,t as Qe,g as Je,b as et,B as tt,M as nt,c as rt,d as at,S as it,e as ot,f as st,h as lt,O as ct,i as dt,j as ht,k as ut,W as pt,l as mt,m as yt,u as gt,n as ft,p as wt,A as vt,q as Ct,r as Et,s as Tt,H as bt,v as At,F as _t,w as kt,x as It,y as Nt,z as xt,D as St,G as Rt,I as Ot,T as Wt,J as Lt,K as Pt,L as Mt,N as Ut,Q as Dt,U as Ft,V as Bt,X as zt,Y as Ht,Z as Vt,_ as $t,$ as Gt,a0 as qt,a1 as jt,a2 as Kt,a3 as Yt,a4 as Zt,a5 as Xt,a6 as Qt,a7 as Jt,a8 as en,a9 as tn,aa as nn,ab as rn,ac as an,ad as on,ae as sn,af as ln,ag as cn,ah as dn,ai as hn,aj as un,ak as pn,al as mn,am as yn,an as gn,ao as fn,ap as wn,aq as vn,ar as Cn,as as En,at as Tn,au as bn,av as An,aw as _n,ax as kn,ay as In,az as Nn,aA as xn,aB as Sn,aC as Rn,aD as On,aE as Wn,aF as Ln,aG as Pn,aH as Mn,aI as Un,aJ as Dn,aK as Fn,aL as Bn,aM as zn,aN as Hn,aO as Vn,aP as $n,aQ as Gn,aR as qn,aS as jn}from"./useActiveWallet-CRQOoJef.mjs";export{aW as useActiveWallet,aU as useConnectWallet,aV as useFundWallet,aT as useLogin}from"./useActiveWallet-CRQOoJef.mjs";import*as Kn from"jose";import{base64url as Yn}from"jose";import{g as Zn,C as Xn,H as Qn,O as Jn,S as er,D as tr,a as nr,b as rr,c as ar,d as ir,V as or,e as sr,P as lr,R as cr,F as dr,f as hr,h as ur,i as pr,j as mr,k as yr,l as gr,I as fr,m as wr,n as vr,o as Cr,p as Er,u as Tr,M as br,q as Ar,r as _r,s as kr,t as Ir,v as Nr,w as xr,x as Sr,W as Rr,y as Or,z as Wr,A as Lr,B as Pr,E as Mr,G as Ur,J as Dr,K as Fr,L as Br,N as zr,Q as Hr,T as Vr,U as $r,X as Gr,Y as qr,Z as jr,_ as Kr,$ as Yr,a0 as Zr,a1 as Xr,a2 as Qr,a3 as Jr,a4 as ea,a5 as ta,a6 as na,a7 as ra,a8 as aa,a9 as ia,aa as oa,ab as sa,ac as la}from"./useWallets-Bm3b-V02.mjs";export{ad as SUPPORTED_CHAINS,af as addPrivyRpcToChain,ae as addRpcUrlOverrideToChain}from"./useWallets-Bm3b-V02.mjs";import{e as ca,i as da,f as ha,S as ua,a as pa,l as ma,u as ya,C as ga,b as fa,c as wa,O as va,d as Ca,g as Ea,h as Ta,P as ba,j as Aa,k as _a,m as ka,n as Ia,p as Na,o as xa,q as Sa,r as Ra,s as Oa,t as Wa,v as La}from"./prepareFundingModalData-R09VUVWm.mjs";export{W as WalletConnector}from"./prepareFundingModalData-R09VUVWm.mjs";import{v4 as Pa}from"uuid";import Ma from"eventemitter3";import{CoinbaseWalletSDK as Ua}from"@coinbase/wallet-sdk";import{isHex as Da,toHex as Fa,createPublicClient as Ba,http as za,createWalletClient as Ha,custom as Va,publicActions as $a,formatUnits as Ga,parseEther as qa,encodeFunctionData as ja,isAddress as Ka,decodeFunctionData as Ya,decodeAbiParameters as Za,formatEther as Xa,hexToString as Qa}from"viem";import{g as Ja,a as ei}from"./getPublicClient-BghjDv1y.mjs";import{ofetch as ti}from"ofetch";import ni from"js-cookie";import{create as ri}from"zustand";import{Turnstile as ai}from"@marsidev/react-turnstile";import{styled as ii,css as oi,createGlobalStyle as si}from"styled-components";import li from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import ci from"@heroicons/react/24/outline/ExclamationTriangleIcon";import di from"@heroicons/react/24/outline/WalletIcon";import hi from"@heroicons/react/24/outline/ExclamationCircleIcon";import ui from"@heroicons/react/24/outline/Square2StackIcon";import pi from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import mi from"@heroicons/react/24/solid/DocumentCheckIcon";import yi from"@heroicons/react/20/solid/CheckIcon";import gi from"@heroicons/react/24/outline/EnvelopeIcon";import fi from"@heroicons/react/24/outline/PhoneIcon";import wi from"@heroicons/react/24/solid/CheckCircleIcon";import vi from"@heroicons/react/24/solid/XCircleIcon";import Ci from"@heroicons/react/24/outline/CheckCircleIcon";import Ei from"@heroicons/react/24/outline/CloudArrowUpIcon";import Ti from"@heroicons/react/24/outline/NoSymbolIcon";import bi from"fast-password-entropy";import*as Ai from"secure-password-utilities";import{DEFAULT_WORDLIST as _i}from"secure-password-utilities/wordlists";import ki from"@heroicons/react/24/outline/ArrowPathIcon";import Ii from"@heroicons/react/24/outline/EyeIcon";import Ni from"@heroicons/react/24/outline/EyeSlashIcon";import xi from"@heroicons/react/24/outline/KeyIcon";import Si from"@heroicons/react/24/outline/ArrowDownTrayIcon";import Ri from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import Oi from"@heroicons/react/24/outline/DocumentDuplicateIcon";import Wi from"@heroicons/react/24/outline/UserCircleIcon";import Li from"@heroicons/react/24/solid/LockClosedIcon";import{formatWalletAddress as Pi,getCoinbaseOnRampUrl as Mi,chainToMoonpayCurrency as Ui,isSupportedChainIdForMoonpay as Di,isSupportedChainIdForCoinbaseOnramp as Fi,formatTokenAmount as Bi,formatWeiAmount as zi,countryCodesAndNumbers as Hi,validatePhoneNumber as Vi,phoneNumberTypingFormatter as $i,getPlaceholderPhoneNumber as Gi,getCountryCallingCode as qi,getPhoneCountryCodeAndNumber as ji,formatPhoneNumber as Ki,toObjectKeys as Yi,lastFourDigits as Zi,SolanaClient as Xi,ProviderErrors as Qi}from"@privy-io/js-sdk-core";import{Menu as Ji,MenuButton as eo,MenuItems as to,MenuItem as no,Transition as ro,Dialog as ao,TransitionChild as io,DialogPanel as oo}from"@headlessui/react";import so from"@heroicons/react/24/outline/ChevronDownIcon";import lo from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import co from"@heroicons/react/24/outline/CreditCardIcon";import ho from"@heroicons/react/24/outline/QrCodeIcon";import uo from"@heroicons/react/24/outline/InformationCircleIcon";import po from"@heroicons/react/24/outline/ChevronRightIcon";import mo from"@heroicons/react/24/outline/FingerPrintIcon";import yo from"@heroicons/react/24/outline/ClockIcon";import go from"@heroicons/react/24/outline/TrashIcon";import fo from"@heroicons/react/24/solid/CheckBadgeIcon";import wo from"@heroicons/react/24/outline/ShieldCheckIcon";import vo from"@heroicons/react/24/solid/IdentificationIcon";import Co from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import Eo from"@heroicons/react/24/outline/MinusCircleIcon";import To from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import bo from"@heroicons/react/24/solid/ShieldCheckIcon";import Ao from"@heroicons/react/24/outline/CalendarIcon";import _o from"@heroicons/react/24/outline/GlobeAltIcon";import ko from"@heroicons/react/24/outline/LockClosedIcon";import Io from"@heroicons/react/24/outline/PencilSquareIcon";import{ChevronDownIcon as No,ArrowRightIcon as xo}from"@heroicons/react/24/outline";import So from"@heroicons/react/24/outline/ClipboardDocumentIcon";import{i as Ro}from"./importWallet-DfwAobLp.mjs";export{g as getEmbeddedConnectedWallet}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"zustand/shallow";import"zustand/traditional";import"tinycolor2";class Oo{async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");try{return await this.api.post(U,{token:this.meta.token})}catch(e){throw T(e)}}async link(){throw Error("Unimplemented")}constructor(e){this.meta={token:e}}}function Wo(e){return e?{"privy-ui":"t"}:void 0}class Lo{async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new E("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(D,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new E("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(F,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw T(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new E("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new E("Email must be set when initialzing authentication.");let r=Wo(n);try{return await this.api.post(B,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw T(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class Po extends Lo{async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new E("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(z,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw T(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class Mo{get meta(){return this._meta}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.channelToken)throw new E("Auth flow must be initialized first");try{let e=await this.api.post(H,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new E("No response from authentication");return e}catch(e){throw T(e)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");try{return await this.api.post(V,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw T(e)}}async _startChannelOnce(){if(!this.api)throw new E("Auth flow has no API instance");let e=await this.api.post($,{token:this.captchaToken});y&&!f&&e.connect_uri&&qe(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new E("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.channelToken)throw new E("Auth flow must be initialized first");let e=await this.api.get(G,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new je(this._startChannelOnce.bind(this)),this.pollForReady=new je(this._pollForReady.bind(this)),this._meta.disableSignup=t}}function Uo(e){return crypto.getRandomValues(new Uint8Array(e))}class Do{getOrCreateGuestCredential(e){let t=Zn(e);if(ca()){if(da.get(t))return da.get(t);{let e=Yn.encode(Uo(32));return da.put(t,e),e}}return Yn.encode(Uo(32))}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");try{return await this.api.post(q,{guest_credential:this.meta.guestCredential})}catch(e){throw T(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function Fo(){return Yn.encode(Uo(36))}function Bo(){return Fo()}async function zo(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return Yn.encode(t)}}class Ho{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new E("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new E("User denied confirmation during OAuth flow");let e=function(){let e=da.get(Xn);if(!e)throw new E("Authentication error.");return e}();try{let t=await this.api.post(j,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return da.del(Xn),da.del(Qn),da.del(Jn),t}catch(e){let t=T(e);if(t.privyErrorCode)throw new E(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new E("Invalid code during oauth flow.",void 0,b.OAUTH_USER_DENIED);throw new E("Invalid code during OAuth flow.",void 0,b.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new E("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new E("User denied confirmation during OAuth flow");let e=da.get(Xn);if(!e)throw new E("Authentication error.");try{let t=await this.api.post(K,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return da.del(Xn),t}catch(e){throw T(e)}}async getAuthorizationUrl(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.provider)throw new E("Provider must be set when initializing OAuth authentication.");let e=Fo();da.put(Xn,e);let t=Bo();da.put(er,t);let n=await zo(e);this.meta.withPrivyUi||da.put(Qn,!0),this.meta.disableSignup&&da.put(Jn,!0);let r=Wo(this.meta.withPrivyUi);try{return await this.api.post(Y,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...r}})}catch(e){throw T(e)}}constructor(e){this.meta=e}}function Vo(e){return e.charAt(0).toUpperCase()+e.slice(1)}const $o=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),/*#__PURE__*/t("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]}),Go=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("g",{clipPath:"url(#clip0)",children:/*#__PURE__*/t("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0",children:/*#__PURE__*/t("rect",{width:"71",height:"55",fill:"white"})})})]}),qo=({style:e,...n})=>/*#__PURE__*/t("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...n,children:/*#__PURE__*/t("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})}),jo=({style:e})=>/*#__PURE__*/t(_o,{style:{color:"var(--privy-color-error)",...e}}),Ko=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...n},...r,children:[/*#__PURE__*/t("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),/*#__PURE__*/t("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),/*#__PURE__*/t("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),/*#__PURE__*/t("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});function Yo(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...n,children:[/*#__PURE__*/e("defs",{children:[/*#__PURE__*/e("linearGradient",{id:"b",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#3771c8"}),/*#__PURE__*/t("stop",{stopColor:"#3771c8",offset:".128"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),/*#__PURE__*/e("linearGradient",{id:"a",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".1",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".5",stopColor:"#ff543e"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#c837ab"})]}),/*#__PURE__*/t("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),/*#__PURE__*/t("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),/*#__PURE__*/t("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/t("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/t("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}function Zo({style:e,...n}){/*#__PURE__*/return t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...e},...n,children:/*#__PURE__*/t("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:/*#__PURE__*/t("g",{transform:"scale(5.12,5.12)",children:/*#__PURE__*/t("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}function Xo(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...n,children:[/*#__PURE__*/t("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),/*#__PURE__*/t("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}function Qo(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...n,children:[/*#__PURE__*/t("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),/*#__PURE__*/t("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),/*#__PURE__*/t("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}const Jo=({style:e,...n})=>/*#__PURE__*/t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...e},...n,children:/*#__PURE__*/t("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})});let es={google:{name:"Google",component:Ko},discord:{name:"Discord",component:Go},github:{name:"Github",component:qo},linkedin:{name:"LinkedIn",component:Zo},twitter:{name:"Twitter",component:Jo},spotify:{name:"Spotify",component:Xo},instagram:{name:"Instagram",component:Yo},tiktok:{name:"Tiktok",component:Qo},apple:{name:"Apple",component:$o}};const ts=e=>e in es?es[e]:{name:"Unknown",component:jo};function ns(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),n=e.get("privy_oauth_state"),r=e.get("privy_oauth_provider");if(!t||!n||!r)return{inProgress:!1};let a=!1;try{a=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:n,provider:r,withPrivyUi:!da.get(Qn),popupFlow:null!==window.opener&&a,disableSignup:!!da.get(Jn)}}function rs(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),da.del(er),window.history.replaceState({},"",e)}class as{async initRegisterFlow(e){if(!this.api)throw new E("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new E("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new E("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new E("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new E("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(Z,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new E("Passkey request timed out or rejected by user.",void 0,b.PASSKEY_NOT_ALLOWED);throw T(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new E("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new E("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let n=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(X,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new E("Passkey request timed out or rejected by user.",void 0,b.PASSKEY_NOT_ALLOWED);throw T(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new E("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new E("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(Q,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new E("Passkey request timed out or rejected by user.",void 0,b.PASSKEY_NOT_ALLOWED);throw T(e)}}async _initRegisterOnce(e){if(!this.api)throw new E("Auth flow has no API instance");let t=Wo(e);return await this.api.post(J,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new E("Auth flow has no API instance");let t=Wo(e);return await this.api.post(ee,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new E("Auth flow has no API instance");return await this.api.post(te,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new je(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new je(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new je(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}class is{async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new E("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(ne,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new E("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(re,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw T(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new E("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new E("phone nNumber must be set when initialzing authentication.");let r=Wo(n);try{return await this.api.post(ie,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw T(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:n}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:n??!1}}}class os extends is{async link(){if(!this.api)throw new E("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new E("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(oe,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw T(e)}}constructor(e,t,n){super({phoneNumber:t,captchaToken:n}),this.meta={phoneNumber:t,captchaToken:n,oldPhoneNumber:e,disableSignup:!1}}}class ss{async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");try{return await this.api.post(se,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");try{return await this.api.post(le,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw T(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function ls(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===b.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===b.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===b.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===b.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===b.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===b.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===b.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof Ke&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function cs(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function ds(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}class hs{static parse(e){try{return new hs(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return Kn.decodeJwt(e),e}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=Kn.decodeJwt(e)}}class us extends hs{static parse(e){try{return new us(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}let ps,ms=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],ys=(e,t)=>e.makeWeb3Provider({options:t});class gs extends Ye{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:Ze,id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new A("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw ha(e)}}updateConnectionPreference(e){this.connectionOptions=e,this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(ys(ps,this.connectionOptions))}constructor(e,t,n,r,a,i){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Xe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=r.coinbaseWallet.connectionOptions??"all",this.walletClientType="smartWalletOnly"===this.connectionOptions?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!ps){let n=[t.id].concat(e.map((e=>e.id))),r="eoaOnly"!==this.connectionOptions?n.filter((e=>!ms.includes(e))):[];r.length>0&&!r.every((e=>tr.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${r.join(", ")}`),ps=new Ua({appName:a,appLogoUrl:i,appChainIds:n})}this.proxyProvider.setWalletProvider(ys(ps,this.connectionOptions))}}const fs=({...e})=>/*#__PURE__*/t("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:e.color||"var(--privy-color-foreground-3)"})});class ws extends Ye{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[Qe(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:fs,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}constructor({provider:e,chains:t,defaultChain:n,rpcConfig:r,imported:a,walletIndex:i}){super("privy",t,n,r),this.connectorType="embedded",this.proxyProvider=e,this.walletIndex=i,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}}const vs=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];let Cs={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844"};const Es={legacy:0,eip2930:1,eip1559:2,eip4844:3};let Ts=e=>void 0!==e?BigInt(e):void 0;function bs(e){let t,{type:n=2,...r}=e;r.accessList&&Array.isArray(r.accessList)?t=r.accessList.map((e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e)):r.accessList&&(t=Object.entries(r.accessList).map((e=>({address:e[0],storageKeys:e[1]}))));let a=Number(r.chainId??1),i=Da(r.data)?r.data:r.data?Fa(Uint8Array.from(r.data)):void 0,o=r.nonce?Number(r.nonce):void 0,s={chainId:a,data:i,nonce:o,value:Ts(r.value),gas:Ts(r.gas??r.gasLimit)},l=Number(n);if(0===l)return{...r,type:Cs[l],...s,gasPrice:Ts(r.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===l)return{...r,type:Cs[l],...s,gasPrice:Ts(r.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===l)return{...r,type:Cs[l],...s,nonce:o,accessList:t,maxFeePerGas:Ts(r.maxFeePerGas),maxPriorityFeePerGas:Ts(r.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw new E(`Unsupported transaction type: ${n}`)}class As extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}class _s extends Ma{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new As(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await uw()||!this.address)throw new As("Disconnected",4900);let{hash:n}=await gw(t,{address:this.address});return n}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new As(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await uw()||!this.address)throw new As("Disconnected",4900);let{signature:n}=await yw(t,{address:this.address});return n}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new As(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new As(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Ja(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],n=e.params[1],{signature:r}=await pw({message:t},{address:n});return r}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],n="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:r}=await mw(Je(n),{address:t});return r}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:Qe(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...bs(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return Qe(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>vs.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await uw();if(await fw(),!t||!this.address)throw new As("Disconnected",4900);try{return(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:{method:e.method,params:e.params}})).response.data}catch(e){throw console.error(e),new As("Disconnected",4900)}}}constructor({walletProxy:e,address:t,entropyId:n,entropyIdVerifier:r,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l}){super(),this.walletProxy=e,this.address=t,this.entropyId=n,this.entropyIdVerifier=r,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Ja(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=et(a,"privy"),this.appId=o,this.walletIndex=l}}class ks extends Ye{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:n,walletClientType:r,defaultChain:a}){super(r,[],a,{}),this.connectorType="null",this.proxyProvider=new Xe(void 0,nr),this.id=e,this.name=t,this.icon=n,this.connectorType=r}}function Is(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Ns=0;class xs extends Ye{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new A("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw ha(e)}}constructor(e,t,n,r,a){super(a||"unknown",e,t,n),this.connectorType="injected",this.proxyProvider=new Xe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=r;let i=r.provider;this.proxyProvider.setWalletProvider(i)}}var Ss="__private_"+Ns+++"__walletBranding";class Rs extends Ye{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return Is(this,Ss)[Ss]??{name:"Browser Extension",icon:tt,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new A("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw ha(e)}}constructor(e,t,n,r,a){super(a??"unknown",e,t,n),Object.defineProperty(this,Ss,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Xe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(r),"metamask"===a?Is(this,Ss)[Ss]={name:"MetaMask",icon:nt,id:"io.metamask"}:"phantom"===a&&(Is(this,Ss)[Ss]={name:"Phantom",icon:rt,id:"phantom"})}}class Os extends xs{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{y||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new A("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw ha(e)}}}const Ws=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","crypto.com_wallet_extension","crypto.com_onchain","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","privy","unknown","phantom","solflare","glow","backpack"],Ls=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:m.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",logo:rt,logoDataUri:at,chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=Ms({client:this.client,isSolana:t,connectOnly:n});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${r}?ref=${r}`}},solflare:{client:"solflare",name:"Solflare",installLink:m.isFirefox?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",logo:it,logoDataUri:ot,chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=Ms({client:this.client,isSolana:t,connectOnly:n});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${r}?ref=${r}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcbcmnbpgliof",logo:st,logoDataUri:lt,chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=Ms({client:this.client,isSolana:t,connectOnly:n});return`${e?"backpack://ul/v1/":"https://backpack.com/ul/v1/"}browse/${r}?ref=${r}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",logo:ct,logoDataUri:dt,chainTypes:["ethereum","solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return"https://www.okx.com/download?deeplink="+encodeURIComponent("okx://wallet/dapp/url?dappUrl="+Ms({client:this.client,isSolana:e,connectOnly:t}))}}});function Ps({connectorType:e,walletClientType:t}){for(let n of Ws)if(e===n||t===n)return Ls[n]}function Ms({client:e,isSolana:t,connectOnly:n}){let r=new URL(window.location.href);return r.searchParams.set("privy_connector",t?"solana_adapter":"injected"),r.searchParams.set("privy_wallet_client",e),r.searchParams.set("privy_connect_only",String(n)),encodeURIComponent(r.href.replace(/\/$/g,""))}class Us extends ua{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:n}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new Xe(void 0,nr),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=n}}class Ds extends Ma{get wallets(){let e=new Set,t=this.walletConnectors.flatMap((e=>e.wallets)).sort(((e,t)=>e.connectedAt&&t.connectedAt?t.connectedAt-e.connectedAt:0)).filter((t=>{let n=`${t.address}${t.walletClientType}${t.connectorType}${t.meta.id}`;return!e.has(n)&&(e.add(n),!0)})),n=t.findIndex((e=>e.address===(this.activeWallet?this.activeWallet:"unknown")));return n>=0&&t.unshift(t.splice(n,1)[0]),t}async initialize(e){if(this.initialized&&!e)return;e&&this.removeAllConnectors(),da.get(rr)&&(da.getKeys().forEach((e=>{e.startsWith("walletconnect")&&da.del(e)})),da.del(rr));let t=ht({store:this.store,walletList:this.walletList,externalWalletConfig:this.externalWalletConfig,walletChainType:this.walletChainType}).then((e=>{e.forEach((({type:e,eip6963InjectedProvider:t,legacyInjectedProvider:n})=>{this.createEthereumWalletConnector({connectorType:"injected",walletClientType:e,providers:{eip6963InjectedProvider:t,legacyInjectedProvider:n}})}))}));for(let e of(this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector({connectorType:"coinbase_wallet",walletClientType:"coinbase_wallet"}),Object.values(Ls)))!e.isInstalled&&this.walletList.includes(e.client)&&(["ethereum-only","ethereum-and-solana"].includes(this.walletChainType)&&e.chainTypes.includes("ethereum")&&this.createEthereumWalletConnector({connectorType:"null",walletClientType:e.client,walletConfig:e}),["ethereum-and-solana","solana-only"].includes(this.walletChainType)&&e.chainTypes.includes("solana")&&this.addWalletConnector(new Us({id:e.client,name:e.name,icon:e.logoDataUri})));this.externalWalletConfig.walletConnect.enabled&&this.createEthereumWalletConnector({connectorType:"wallet_connect_v2",walletClientType:"unknown"}),this.externalWalletConfig.solana.connectors?.get().forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.((e=>{e?.forEach(this.addSolanaWalletConnector)})),await t,this.initialized=!0}findWalletConnector(e,t){return"wallet_connect_v2"===e?this.walletConnectors.filter(ut).find((t=>t.connectorType===e))??null:this.walletConnectors.filter(ut).find((n=>n.connectorType===e&&n.walletClientType===t))??null}findSolanaWalletConnector(e,t){return this.walletConnectors.filter(pa).find((n=>n.connectorType===e&&("unknown"===n.walletClientType?n.walletBranding.id===t:n.walletClientType===t)))??null}findEmbeddedWalletConnectors(){return this.walletConnectors.filter((e=>"embedded"===e.connectorType))}onInitialized(e){e.wallets.forEach((e=>{let t=this.storedConnections.find((t=>t.address===e.address&&t.connectorType===e.connectorType&&("solana"===e.type&&"unknown"===t.walletClientType&&"unknown"===e.walletClientType?e.meta.id===t.id:t.walletClientType===e.walletClientType)));t&&(e.connectedAt=t.connectedAt)})),this.saveConnectionHistory(),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnectors({walletProxy:e,rootWallet:t,embeddedWallets:n,defaultChain:r,appId:a}){for(let i of n){let n=this.findEmbeddedWalletConnectors().find((e=>e.walletIndex===i.walletIndex));if(n&&ut(n))n.proxyProvider.walletProxy=e;else{let{entropyId:n,entropyIdVerifier:o}=ar(t),s=new ws({provider:new _s({walletProxy:e,address:i.address,entropyId:n,entropyIdVerifier:o,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:r.id,walletIndex:i.walletIndex}),chains:this.chains,defaultChain:r,rpcConfig:this.rpcConfig,imported:!1,walletIndex:i.walletIndex});this.addWalletConnector(s)}}}addImportedWalletConnector(e,t,n,r){let a=this.findWalletConnector("embedded_imported","privy");if(a&&ut(a))a.proxyProvider.walletProxy=e;else{let a=new ws({provider:new _s({walletProxy:e,address:t,entropyId:t,entropyIdVerifier:"ethereum-address-verifier",walletIndex:0,rpcConfig:this.rpcConfig,chains:this.chains,appId:r,chainId:n.id}),chains:this.chains,walletIndex:0,defaultChain:n,rpcConfig:this.rpcConfig,imported:!0});this.addWalletConnector(a)}}removeEmbeddedWalletConnectors(){this.walletConnectors=this.walletConnectors.filter((e=>"embedded"!==e.connectorType)),this.saveConnectionHistory(),this.storedConnections=ma(),this.emit("walletsUpdated")}removeImportedWalletConnector(){let e=this.findWalletConnector("embedded_imported","privy");if(e){let t=this.walletConnectors.indexOf(e);this.walletConnectors.splice(t,1),this.saveConnectionHistory(),this.storedConnections=ma(),this.emit("walletsUpdated")}}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:n,walletConfig:r}){let a=this.findWalletConnector(e,t);if(a&&ut(a))return a instanceof pt&&a.resetConnection(t),a;let i=(()=>"injected"!==e?"coinbase_wallet"===e?new gs(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):"null"!==e?new pt(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,this.privyAppName,t):r?new ks({id:r.client,name:r.name,icon:r.logoDataUri,defaultChain:this.defaultChain,walletClientType:r.client}):null:"metamask"===t&&n?.eip6963InjectedProvider?new Os(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask"):"metamask"===t&&n?.legacyInjectedProvider?new Rs(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask"):"phantom"===t&&n?.legacyInjectedProvider?new Rs(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom"):n?.legacyInjectedProvider&&"unknown_browser_extension"===t?new Rs(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider):n?.eip6963InjectedProvider?new xs(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,t):void 0)();return i&&this.addWalletConnector(i),i||null}addWalletConnector(e){this.walletConnectors.push(e),e.on("initialized",(()=>this.onInitialized(e))),e.on("walletsUpdated",(()=>this.onWalletsUpdated(e))),e.initialize().catch((e=>{console.debug("Failed to initialize connector",e)}))}saveConnectionHistory(){let e=this.wallets.map((e=>({address:e.address,connectorType:e.connectorType,walletClientType:e.walletClientType,connectedAt:e.connectedAt,id:e.meta.id})));da.put(ir,e)}async activeWalletSign(e){let t=this.wallets,n=t.length>0?t[0]:null;return n&&mt(n)?n.sign(e):null}setActiveWallet(e){this.activeWallet=C(e),this.emit("walletsUpdated")}setWalletList(e){this.walletList=e,this.initialized&&this.initialize(!0).catch(console.error)}removeAllConnectors(){for(let e of this.walletConnectors)e.removeAllListeners();this.walletConnectors=[]}constructor(e,t,n,r,a,i,o,s,l,c,d,h){super(),this.addSolanaWalletConnector=async e=>{this.findSolanaWalletConnector("solana_adapter",e.walletClientType)||this.addWalletConnector(e)},this.getEthereumProvider=()=>{let e=this.wallets[0],t=this.walletConnectors.find((t=>t.wallets.find((t=>t.address===e?.address))));return e&&t?t.proxyProvider:new Xe},this.privyAppId=e,this.walletConnectCloudProjectId=t,this.rpcConfig=n,this.chains=r,this.defaultChain=a,this.walletConnectors=[],this.initialized=!1,this.store=i,this.walletList=o,this.shouldEnforceDefaultChainOnConnect=s,this.externalWalletConfig=l,this.privyAppName=c,this.privyAppLogo=d,this.walletChainType=h||"ethereum-only",this.storedConnections=ma()}}let Fs=[ce,de,he,ue];class Bs{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw T(e)}}async post(e,t,n){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...n})}catch(e){throw T(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw T(e)}}constructor({appId:e,appClientId:t,client:n,defaults:r}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=n.clientAnalyticsId,this.sdkVersion=or,this.client=n,this.defaults=r,this.fallbackApiUrl=n.fallbackApiUrl,this.baseFetch=ti.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:e,options:t})=>{let n=new Headers(t.headers);n.set("privy-app-id",this.appId),this.appClientId&&n.set("privy-client-id",this.appClientId),n.set("privy-ca-id",this.clientAnalyticsId||""),n.set("privy-client",`react-auth:${this.sdkVersion}`);let r=Fs.includes(e.toString());if(!n.has("authorization")){let e=await this.client.getAccessToken({disableAutoRefresh:r});null!==e&&n.set("authorization",`Bearer ${e}`)}t.headers=n,t.retryDelay&&"number"==typeof t.retryDelay&&(t.retryDelay=3*t.retryDelay)},onRequestError:({error:e})=>{if(e instanceof DOMException&&"AbortError"===e.name)throw new _}})}}let zs=/paymaster\.biconomy\.io\/api/i,Hs={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const Vs=(e,t)=>e&&zs.test(e)?Hs:t&&t.policy_id?{policyId:t.policy_id}:void 0;function $s(){return!(w&&window.location.origin.startsWith("http://localhost"))}const Gs=ri((()=>({identityToken:null})));function qs(){let{identityToken:e}=Gs();return{identityToken:e}}var js,Ks=((js={}).PRIVY="privy_access_token",js.CUSTOMER="customer_access_token",js);class Ys{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(sr)}get privyAccessToken(){return this._getToken(lr)}_getToken(e){try{let t=da.get(e);return"string"==typeof t?hs.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=da.get(cr);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}get forkedToken(){try{let e=da.get(dr);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=da.get(hr(e));if("string"!=typeof t)return null;{let n=new hs(t);return n.isExpired()?(da.del(hr(e)),null):n.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=ni.get(ur);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e="privy_access_token"){let t="string"==typeof this.getToken(e),n="string"==typeof this.refreshToken&&this.refreshToken!==pr;return this.mightHaveServerCookies||t&&n}hasRecoveryCredentials(){return"string"==typeof this.forkedToken}hasActiveAccessToken(e){let t=hs.parse(this.getToken(e));return null!==t&&!t.isExpired(30)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(e,t){"string"==typeof t?da.put(hr(e),t):da.del(hr(e))}updateIdentityToken(e){"string"==typeof e?this.storeIdentityToken(e):this.clearIdentityToken()}async _authenticate(e){try{let t=await e.authenticate(),{user:n,is_new_user:r,oauth_tokens:a}=t;this.handleTokenResponse(t);let i=a?{provider:a.provider,accessToken:a.access_token,accessTokenExpiresInSeconds:a.access_token_expires_in_seconds,refreshToken:a.refresh_token,refreshTokenExpiresInSeconds:a.refresh_token_expires_in_seconds,scopes:a.scopes}:void 0;return this._trackAuthenticateEvents(e,r),{user:mr(n),isNewUser:r,oAuthTokens:i}}catch(e){throw console.warn("Error authenticating session"),k(e)}}_trackAuthenticateEvents(e,t){let n=function(e){return e instanceof Lo?"email":e instanceof is?"sms":e instanceof yt?"siwe":e instanceof Do?"guest":e instanceof Oo?"custom_auth":e instanceof Ho?e.meta.provider:null}(e);n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:n,isNewUser:t}}),"siwe"===n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:e.meta.connectorType,walletClientType:e.meta.walletClientType}})}async _link(e){try{let t=await e.link(),n=t.oauth_tokens,r=n?{provider:n.provider,accessToken:n.access_token,accessTokenExpiresInSeconds:n.access_token_expires_in_seconds,refreshToken:n.refresh_token,refreshTokenExpiresInSeconds:n.refresh_token_expires_in_seconds,scopes:n.scopes}:void 0;return{user:mr(t),oAuthTokens:r}}catch(e){throw console.warn("Error linking account"),k(e)}}async _refresh(){if(!this.api)throw new E("Session has no API instance");if(!this.client)throw new E("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let e=this.token,t=this.refreshToken,n=this.forkedToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let r;if(e&&t||this.mightHaveServerCookies){let a={};e&&(a.authorization=`Bearer ${e}`),r=await this.api.post(ce,t?{refresh_token:t}:{},{headers:a}),n&&this.clearForkedToken()}else{if(!n)return null;r=await this.api.post(de,{refresh_token:n}),this.clearForkedToken()}return this.handleTokenResponse(r),mr(r.user)}catch(e){if(e instanceof I&&e.privyErrorCode===b.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw k(e)}}handleTokenResponse(e){e.session_update_action&&"set"!==e.session_update_action?"clear"===e.session_update_action?this.destroyLocalState():"ignore"===e.session_update_action&&(e.token&&(this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token)),e.identity_token&&this.storeIdentityToken(e.identity_token)):this._storeAllTokens(e)}_storeAllTokens(e){this.storeRefreshToken(e.refresh_token),this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),e.identity_token&&this.storeIdentityToken(e.identity_token)}async _destroy(){try{await(this.api?.post(he,{refresh_token:this.refreshToken}))}catch(e){console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new E("Session has no API instance");let e=this.refreshToken;try{let t=await this.api.post(pe,{refresh_token:e});return this.storeRefreshToken(t.refresh_token),this.storeCustomerAccessToken(t.token),t.new_session_refresh_token}catch(e){throw k(e)}}destroyLocalState(){this.storeRefreshToken(null),this.storeCustomerAccessToken(null),this.storePrivyAccessToken(null),this.clearIdentityToken(),this.clearForkedToken()}storeCustomerAccessToken(e){if("string"==typeof e){let t=da.get(sr);if(da.put(sr,e),!this.client?.useServerCookies){let t=hs.parse(e)?.expiration;ni.set(yr,e,{sameSite:"Strict",secure:$s(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else da.del(sr),ni.remove(yr),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(da.put(cr,e),this.client?.useServerCookies||ni.set(ur,"t",{sameSite:"Strict",secure:$s(),expires:30})):(da.del(cr),ni.remove(gr),ni.remove(ur))}storePrivyAccessToken(e){"string"==typeof e?da.put(lr,e):da.del(lr)}storeIdentityToken(e){if(Gs.setState({identityToken:e}),this.client?.useServerCookies)return;da.put(fr,e);let t=hs.parse(e)?.expiration;ni.set(wr,e,{sameSite:"Strict",secure:$s(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){da.del(fr),Gs.setState({identityToken:null}),ni.remove(wr)}clearForkedToken(){da.del(dr)}constructor(){this.authenticateOnce=new je((async e=>this._authenticate(e))),this.linkOnce=new je((async e=>this._link(e))),this.refreshOnce=new je(this._refresh.bind(this)),this.destroyOnce=new je(this._destroy.bind(this)),this.forkSessionOnce=new je(this._forkSession.bind(this))}}let Zs;var Xs=0,Qs="__private_"+Xs+++"__getOrGenerateClientAnalyticsId";class Js{initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:r,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:o,externalWalletConfig:s,appName:l,walletChainType:c}){this.connectors||(this.connectors=new Ds(this.appId,e,t,n,r,a,i,o,s,l,void 0,c))}generateApi(){let e=new Bs({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=e,e}updateApiUrl(e){this.apiUrl=e||this.fallbackApiUrl,this.api=this.generateApi(),e&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new E("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new E("No auth flow in progress.");let{oAuthTokens:e}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:e}}storeProviderAccessToken(e,t){this.session.storeProviderAccessToken(e,t)}getProviderAccessToken(e){return this.session.getProviderAccessToken(e)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(e){e.linkedAccounts.filter((e=>"cross_app"===e.type)).forEach((e=>{this.storeProviderAccessToken(e.providerApp.id,null)}))}startAuthFlow(e){return e.api=this.api,this.authFlow=e,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(me,{action:"verify"})}catch(e){throw T(e)}}async initMfaPasskeyVerification(){try{return(e=>({rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}))((await this.api.post(ye,{})).options)}catch(e){throw T(e)}}async getCrossAppProviderDetails(e){try{return this._cachedProviderAppDetails[e]||(this._cachedProviderAppDetails[e]=await this.api.get(`/api/v1/apps/${e}/cross-app/details`)),this._cachedProviderAppDetails[e]}catch(e){console.error("Error fetching cross app provider details",e)}}async acceptTerms(){try{let e=await this.api.post(ge,{});return mr(e)}catch(e){throw k(e)}}async unlinkEmail(e){try{let t=await this.api.post(fe,{address:e});return await this.getAuthenticatedUser()??mr(t)}catch(e){throw k(e)}}async unlinkPhone(e){try{let t=await this.api.post(we,{phoneNumber:e});return await this.getAuthenticatedUser()??mr(t)}catch(e){throw k(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(ve,{address:e});return await this.getAuthenticatedUser()??mr(t)}catch(e){throw k(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(Ce,{address:e});return await this.getAuthenticatedUser()??mr(t)}catch(e){throw k(e)}}async unlinkOAuth(e,t){try{let n=await this.api.post(Ee,{provider:e,subject:t});return await this.getAuthenticatedUser()??mr(n)}catch(e){throw k(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(Te,{fid:e});return await this.getAuthenticatedUser()??mr(t)}catch(e){throw k(e)}}async unlinkTelegram(e){try{let t=await this.api.post(be,{telegram_user_id:e});return await this.getAuthenticatedUser()??mr(t)}catch(e){throw k(e)}}async revokeDelegatedWallet(){try{await this.api.post(Ae,{})}catch(e){throw k(e)}}async createAnalyticsEvent({eventName:e,payload:t,timestamp:n,options:r}){if("undefined"!=typeof window)try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(ue,{event_name:e,client_id:this.clientAnalyticsId,payload:{...t||{},clientTimestamp:n?n.toISOString():(new Date).toISOString()}},{retry:-1,keepalive:r?.keepAlive??!1})}catch(e){}}async signMoonpayOnRampUrl(e){try{return this.api.post(_e,e)}catch(e){throw k(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(ke,e)}catch(e){throw k(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${Ie}?partnerUserId=${e}`)}catch(e){throw k(e)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(e){return await this.getPrivyAccessToken(e)||await this.getCustomerAccessToken(e)}async getCustomerAccessToken(e){return await this._getToken(Ks.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(Ks.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?us.parse(this.session.getToken(e))?.appId!==this.appId?(await this.logout(),null):this.session.getToken(e):(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials(e)?(await this.session.refresh(),this.session.getToken(e)):null:null}async getSmartWalletsConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let n=await this.api.get(`/api/v1/apps/${this.appId}/smart_wallets`,{baseURL:this.fallbackApiUrl,headers:e});return n.enabled?{enabled:n.enabled,smartWalletType:n.smart_wallet_type,configuredNetworks:n.configured_networks.map((e=>({chainId:e.chain_id,bundlerUrl:e.bundler_url,paymasterUrl:e.paymaster_url,paymasterContext:Vs(e.paymaster_url,e.paymaster_context)})))}:{enabled:n.enabled}}catch(e){throw k(e)}}async getServerConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let n=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl,headers:e}),r=n.telegram_auth_config?{botId:n.telegram_auth_config.bot_id,botName:n.telegram_auth_config.bot_name,linkEnabled:n.telegram_auth_config.link_enabled,seamlessAuthEnabled:n.telegram_auth_config.seamless_auth_enabled}:void 0,a=n.funding_config?{methods:n.funding_config.methods,options:n.funding_config.options,defaultRecommendedAmount:n.funding_config.default_recommended_amount,defaultRecommendedCurrency:n.funding_config.default_recommended_currency,promptFundingOnWalletCreation:n.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:n.funding_config.cross_chain_bridging_enabled}:void 0;return{id:n.id,name:n.name,verificationKey:n.verification_key,logoUrl:n.logo_url||void 0,accentColor:n.accent_color||void 0,showWalletLoginFirst:n.show_wallet_login_first,allowlistConfig:{errorTitle:n.allowlist_config.error_title,errorDetail:n.allowlist_config.error_detail,errorCtaText:n.allowlist_config.cta_text,errorCtaLink:n.allowlist_config.cta_link},walletAuth:n.wallet_auth,solanaWalletAuth:n.solana_wallet_auth,emailAuth:n.email_auth,smsAuth:n.sms_auth,googleOAuth:n.google_oauth,twitterOAuth:n.twitter_oauth,discordOAuth:n.discord_oauth,githubOAuth:n.github_oauth,spotifyOAuth:n.spotify_oauth,instagramOAuth:n.instagram_oauth,tiktokOAuth:n.tiktok_oauth,linkedinOAuth:n.linkedin_oauth,appleOAuth:n.apple_oauth,farcasterAuth:n.farcaster_auth,passkeyAuth:n.passkey_auth,passkeysForSignupEnabled:n.passkeys_for_signup_enabled,telegramAuth:n.telegram_auth,disablePlusEmails:n.disable_plus_emails,termsAndConditionsUrl:n.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:n.embedded_wallet_config?.create_on_login,userOwnedRecoveryOptions:n.embedded_wallet_config.user_owned_recovery_options,requireUserOwnedRecoveryOnCreate:n.embedded_wallet_config.require_user_owned_recovery_on_create},privacyPolicyUrl:n.privacy_policy_url,requireUsersAcceptTerms:n.require_users_accept_terms,customApiUrl:n.custom_api_url,walletConnectCloudProjectId:n.wallet_connect_cloud_project_id,fiatOnRampEnabled:n.fiat_on_ramp_enabled,captchaEnabled:n.captcha_enabled,captchaSiteKey:n.captcha_site_key,createdAt:new Date(1e3*n.created_at),updatedAt:new Date(1e3*n.updated_at),mfaMethods:n.mfa_methods,enforceWalletUis:n.enforce_wallet_uis,legacyWalletUiConfig:n.legacy_wallet_ui_config,telegramAuthConfiguration:r,fundingConfig:a}}catch(e){throw k(e)}}async getUsdTokenPrice(e){try{return(await this.api.get(`/api/v1/token_price?chainId=${e.id}&tokenSymbol=${e.nativeCurrency.symbol}`)).usd}catch(t){return void console.error(`Unable to fetch token price for chain with id ${e.id}`)}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch(e){return void console.error("Unable to fetch token price for SOL")}}async getSplTokenMetadata({mintAddress:e,cluster:t}){try{return await this.api.get(`/api/v1/spl_token_info?mint_address=${e}&cluster=${t}`)}catch(n){return void console.error(`Unable to fetch token metadata for ${t}:${e}`)}}async requestFarcasterSignerStatus(e){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:e})}catch(e){throw console.error("Unable to fetch Farcaster signer status"),e}}async forkSession(){return await this.session.forkSession()}async generateSiweNonce({address:e,captchaToken:t}){try{return(await this.api.post(Ne,{address:e,token:t})).nonce}catch(e){throw k(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i}){return await this.api.post(xe,{message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i})}async linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a}){return await this.api.post(Se,{message:e,signature:t,chainId:n,walletClientType:r,connectorType:a})}async linkSmartWallet({message:e,signature:t,smartWalletType:n}){try{let r=await this.api.post(Re,{message:e,signature:t,smart_wallet_type:n});return mr(r)}catch(e){throw k(e)}}async linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a}){try{let i=await this.linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a});return mr(i)}catch(e){throw k(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(Oe,{address:e,token:t})).nonce}catch(e){throw k(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,mode:a}){return await this.api.post(We,{message:e,signature:t,walletClientType:n,connectorType:r,mode:a})}async sendAccountTransferRequest({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:s}){try{let l,c;switch(n){case"email":l=Fe,c={nonce:e,email:t};break;case"sms":l=De,c={nonce:e,phoneNumber:t};break;case"siwe":if(l=Ue,!r)throw Error("Wallet parameters must be defined");c={nonce:e,address:t,...r};break;case"farcaster":l=Me,c={nonce:e,farcaster_id:t,farcaster_embedded_address:o};break;case"telegram":l=Pe,c={nonce:e,telegram_auth_result:a,telegram_web_app_data:i};break;case"custom":case"guest":case"passkey":throw Error("Invalid transfer account type");default:l=Le,c={nonce:e,userInfo:s}}let d=await this.api.post(l,c);return await this.getAuthenticatedUser()??mr(d)}catch(e){throw k(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r}){return await this.api.post(Be,{message:e,signature:t,walletClientType:n,connectorType:r})}async linkWithSiws({message:e,signature:t,walletClientType:n,connectorType:r}){try{let a=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r});return mr(a)}catch(e){throw k(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(ze);return this.session.updateIdentityToken(e.identity_token),mr(e.user)}catch(e){throw k(e)}}async scanTransaction(e){try{return await this.api.post(He,e)}catch(e){throw k(e)}}constructor({apiUrl:e=vr,appId:t,appClientId:n,timeout:r=Cr}){Object.defineProperty(this,Qs,{value:el}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==vr&&e.startsWith("https://privy."),this.timeout=r,this.appId=t,this.appClientId=n,this.clientAnalyticsId=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}(this,Qs)[Qs](),Zs||(Zs=new Ys),this.session=Zs,this.api=this.generateApi(),this.session.client=this}}function el(){if("undefined"==typeof window)return null;try{let e=da.get(Er);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=Pa();try{return da.put(Er,e),e}catch(t){return e}}const tl=e=>{let{enabled:n,siteKey:r,appId:a,setError:s,setToken:l,setExecuting:c,ref:d}=gt(),[,h]=i((()=>r?.split("t:")||[]),[r]);if(o((()=>d.current?.remove),[]),!n)return null;if(!h)throw Error("Unsupported captcha site key");/*#__PURE__*/return t("div",{className:"hidden h-0 w-0",children:/*#__PURE__*/t(ai,{...e,ref:d,siteKey:h,options:{action:a,size:"invisible",...e.delayedExecution?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{e.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{e.onError?.(),s("Captcha failed"),c(!1)},onSuccess:t=>{e.onSuccess?.(t),l(t),c(!1)},onExpire:()=>{e.onExpire?.();try{d.current?.reset(),s(void 0),l(void 0)}catch(e){s("expired_and_failed_reset")}}})})};function nl(e){ya("configureMfa",e)}const rl=/*#__PURE__*/ii.span.withConfig({displayName:"CircleBackground",componentId:"sc-c9f33cd-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";background-color:",";border-radius:50%;display:inline-block;box-sizing:border-box;}"],(e=>e.color??"var(--privy-color-accent)"),(e=>e.color??"var(--privy-color-accent)"));let al=/*#__PURE__*/ii.div.withConfig({displayName:"StackedContainer",componentId:"sc-f7e7d474-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]);const il=/*#__PURE__*/ii.div.withConfig({displayName:"Grow",componentId:"sc-b51c7c74-0"})(["text-align:left;flex-grow:1;"]),ol=/*#__PURE__*/ii.div.withConfig({displayName:"AlignBottom",componentId:"sc-b51c7c74-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),sl=/*#__PURE__*/ii.div.withConfig({displayName:"LoginMethodContainer",componentId:"sc-b51c7c74-2"})(["display:flex;flex-direction:column;gap:12px;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]),ll=/*#__PURE__*/ii(sl).withConfig({displayName:"LoginMethodContainerWithScrollShadows",componentId:"sc-b51c7c74-3"})([""," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;"],(e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0));let cl=/*#__PURE__*/oi(["&&{width:100%;font-size:16px;line-height:24px;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-mdlg);transition:background-color 200ms ease;cursor:pointer;&:hover{background-color:var(--privy-color-background-2);}&:disabled{cursor:pointer;background-color:var(--privy-color-background-2);}svg{height:24px;max-height:24px;max-width:24px;}}"]);const dl=/*#__PURE__*/ii.div.withConfig({displayName:"Subtitle",componentId:"sc-b51c7c74-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),hl=/*#__PURE__*/ii.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-b51c7c74-5"})(["",""],cl),ul=/*#__PURE__*/ii.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-b51c7c74-6"})(["",""],cl),pl=/*#__PURE__*/ii.div.withConfig({displayName:"Hide",componentId:"sc-b51c7c74-7"})(["width:100%;height:100%;min-height:inherit;display:flex;flex-direction:column;",""],(e=>e.$if?"display: none;":"")),ml=/*#__PURE__*/ii.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-b51c7c74-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),yl=/*#__PURE__*/ii.div.withConfig({displayName:"Header",componentId:"sc-b51c7c74-9"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-bottom:32px;gap:12px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]);let gl=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-a3e74b9e-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;margin-top:24px;"]),fl=/*#__PURE__*/ii.div.withConfig({displayName:"GappedContainer",componentId:"sc-a3e74b9e-1"})(["display:flex;flex-direction:column;gap:8px;"]);const wl=/*#__PURE__*/ii.span.withConfig({displayName:"CircleBorder",componentId:"sc-9056b8b8-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";border-bottom-color:transparent;border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1.2s linear infinite;transition:border-color 800ms;border-bottom-color:",";}"],(e=>e.color??"var(--privy-color-accent)"),(e=>e.color??"var(--privy-color-accent)"));function vl(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...n,children:[/*#__PURE__*/t("circle",{cx:"12",cy:"12",r:"10"}),/*#__PURE__*/t("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),/*#__PURE__*/t("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})}const Cl=({onTransfer:e,isTransferring:n,transferSuccess:r})=>/*#__PURE__*/t(wt,{...r?{success:!0,children:"Success!"}:{warn:!0,loading:n,onClick:e,children:"Transfer and delete account"}}),El=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-aa2e65ff-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;width:100%;padding-bottom:16px;"]),Tl=/*#__PURE__*/ii.div.withConfig({displayName:"GappedContainer",componentId:"sc-aa2e65ff-1"})(["display:flex;flex-direction:column;&& p{font-size:14px;}width:100%;gap:16px;"]),bl=/*#__PURE__*/ii.div.withConfig({displayName:"DisclosedAccountContainer",componentId:"sc-aa2e65ff-2"})(["display:flex;cursor:pointer;align-items:center;width:100%;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-md);padding:8px 10px;font-size:14px;font-weight:500;gap:8px;"]),Al=/*#__PURE__*/ii(hi).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-aa2e65ff-3"})(["position:relative;width:",";height:",";color:var(--privy-color-foreground-3);margin-left:auto;"],(e=>`${e.iconSize}px`),(e=>`${e.iconSize}px`)),_l=/*#__PURE__*/ii(ui).withConfig({displayName:"StyledCopyIcon",componentId:"sc-aa2e65ff-4"})(["position:relative;width:15px;height:15px;color:var(--privy-color-foreground-3);margin-left:auto;"]),kl=/*#__PURE__*/ii.ol.withConfig({displayName:"ListContainer",componentId:"sc-aa2e65ff-5"})(["display:flex;flex-direction:column;font-size:14px;width:100%;text-align:left;"]),Il=/*#__PURE__*/ii.li.withConfig({displayName:"ListItem",componentId:"sc-aa2e65ff-6"})(["font-size:14px;list-style-type:auto;list-style-position:outside;margin-left:1rem;margin-bottom:0.5rem;&:last-child{margin-bottom:0;}"]),Nl=/*#__PURE__*/ii.div.withConfig({displayName:"CircleContainer",componentId:"sc-aa2e65ff-7"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]);let xl=()=>/*#__PURE__*/t(Nl,{children:/*#__PURE__*/t(Al,{iconSize:60})});const Sl=({address:r,onClose:a,onRetry:i,onTransfer:o,isTransferring:s,transferSuccess:l})=>{let{defaultChain:c}=Ar(),d=c.blockExplorers?.default.url??"https://etherscan.io";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:a,backFn:i}),/*#__PURE__*/e(El,{children:[/*#__PURE__*/t(xl,{}),/*#__PURE__*/e(Tl,{children:[/*#__PURE__*/t("h3",{children:"Check account assets before transferring"}),/*#__PURE__*/t("p",{children:"Before transferring, ensure there are no assets in the other account. Assets in that account will not transfer automatically and may be lost."}),/*#__PURE__*/e(kl,{children:[/*#__PURE__*/t("p",{children:" To check your balance, you can:"}),/*#__PURE__*/t(Il,{children:"Log out and log back into the other account, or "}),/*#__PURE__*/e(Il,{children:["Copy your wallet address and use a"," ",/*#__PURE__*/t("u",{children:/*#__PURE__*/t("a",{target:"_blank",href:d,children:"block explorer"})})," ","to see if the account holds any assets."]})]}),/*#__PURE__*/e(bl,{onClick:()=>navigator.clipboard.writeText(r).catch(console.error),children:[/*#__PURE__*/t(di,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),/*#__PURE__*/t(vt,{address:r,showCopyIcon:!1}),/*#__PURE__*/t(_l,{})]}),/*#__PURE__*/t(Cl,{onTransfer:o,isTransferring:s,transferSuccess:l})]})]}),/*#__PURE__*/t(Ct,{})]})},Rl=({onClose:r,onContinue:a,onInfo:i,onTransfer:o,transferSuccess:s,isTransferring:l,data:c})=>{if(!c?.accountTransfer?.linkMethod||!c?.accountTransfer?.displayName)return;let d={method:c?.accountTransfer?.linkMethod,handle:c?.accountTransfer?.displayName,disclosedAccount:c?.accountTransfer?.embeddedWalletAddress?{type:"wallet",handle:c?.accountTransfer?.embeddedWalletAddress}:void 0};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{closeable:!0}),/*#__PURE__*/e(El,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(wl,{color:"var(--privy-color-error)"}),/*#__PURE__*/t(ci,{height:38,width:38,stroke:"var(--privy-color-error)"})]})}),/*#__PURE__*/e(Tl,{children:[/*#__PURE__*/e("h3",{children:[function(e){switch(e){case"sms":return"Phone number";case"email":return"Email address";case"siwe":return"Wallet address";case"linkedin":return"LinkedIn profile";case"google":case"apple":case"discord":case"github":case"instagram":case"spotify":case"tiktok":case"twitter":case"telegram":case"farcaster":return`${Vo(e.replace("_oauth",""))} profile`;default:return e}}(d.method)," is associated with another account"]}),/*#__PURE__*/e("p",{children:["Do you want to transfer",/*#__PURE__*/t("b",{children:d.handle?` ${d.handle}`:""})," to this account instead? This will delete your other account."]}),/*#__PURE__*/t(Ol,{onClick:i,disclosedAccount:d.disclosedAccount})]}),/*#__PURE__*/e(Tl,{style:{gap:12,marginTop:12},children:[c?.accountTransfer?.embeddedWalletAddress?/*#__PURE__*/t(wt,{onClick:a,children:"Continue"}):/*#__PURE__*/t(Cl,{onTransfer:o,transferSuccess:s,isTransferring:l}),/*#__PURE__*/t(Et,{onClick:r,children:"No thanks"})]})]}),/*#__PURE__*/t(Ct,{})]})};function Ol({disclosedAccount:n,onClick:r}){return n?/*#__PURE__*/e(bl,{onClick:r,children:[/*#__PURE__*/t(di,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),/*#__PURE__*/t(vt,{address:n.handle,showCopyIcon:!1}),/*#__PURE__*/t(vl,{width:15,height:15,color:"var(--privy-color-foreground-3)",style:{marginLeft:"auto"}})]}):null}const Wl=/*#__PURE__*/ii.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a63b1990-0"})(["display:flex;flex-direction:column;align-items:center;padding:0px 0px 30px;@media (max-width:440px){padding:10px 10px 20px;}"]),Ll=/*#__PURE__*/ii.div.withConfig({displayName:"Title",componentId:"sc-a63b1990-1"})(["font-size:18px;line-height:30px;text-align:center;font-weight:600;margin-bottom:10px;"]),Pl=/*#__PURE__*/ii.div.withConfig({displayName:"SubTitle",componentId:"sc-a63b1990-2"})(["font-size:0.875rem;text-align:center;"]),Ml=/*#__PURE__*/ii.div.withConfig({displayName:"Container",componentId:"sc-a63b1990-3"})(["display:flex;flex-direction:column;align-items:center;gap:10px;flex-grow:1;padding:20px 0;@media (max-width:440px){padding:10px 10px 20px;}"]),Ul=/*#__PURE__*/ii.div.withConfig({displayName:"List",componentId:"sc-a63b1990-4"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.75rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),Dl=/*#__PURE__*/ii.div.withConfig({displayName:"ListItemIcon",componentId:"sc-a63b1990-5"})(["width:25px;display:flex;align-items:center;justify-content:flex-start;> svg{z-index:2;height:25px !important;width:25px !important;color:var(--privy-color-accent);}"]),Fl=/*#__PURE__*/ii.div.withConfig({displayName:"ListItem",componentId:"sc-a63b1990-6"})(["display:flex;align-items:center;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;"]),Bl=/*#__PURE__*/ii.div.withConfig({displayName:"BottomSection",componentId:"sc-a63b1990-7"})(["display:flex;flex-direction:column;gap:10px;padding-top:20px;"]),zl=/*#__PURE__*/ii.div.withConfig({displayName:"MethodList",componentId:"sc-a63b1990-8"})(["display:flex;flex-direction:column;align-items:stretch;gap:1rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),Hl=/*#__PURE__*/ii.div.withConfig({displayName:"MethodListItem",componentId:"sc-a63b1990-9"})(["display:flex;gap:5px;width:100%;position:relative;"]),Vl=/*#__PURE__*/ii.button.withConfig({displayName:"RemoveMethodButton",componentId:"sc-a63b1990-10"})(["&&{background-color:transparent;color:var(--privy-color-foreground-3);padding:0 0.75rem;display:flex;align-items:center;height:100%;> svg{z-index:2;height:20px !important;width:20px !important;}}&&:hover{color:var(--privy-color-error);}"]),$l=/*#__PURE__*/ii.div.withConfig({displayName:"MethodText",componentId:"sc-a63b1990-11"})(["display:flex;align-items:center;gap:0.5rem;> svg{z-index:2;height:20px !important;width:20px !important;}"]),Gl=/*#__PURE__*/ii.div.withConfig({displayName:"ExtraText",componentId:"sc-a63b1990-12"})(["display:flex;align-items:center;gap:6px;font-weight:400 !important;color:",";> svg{z-index:2;height:18px !important;width:18px !important;display:flex !important;align-items:flex-end;}"],(e=>e.isAccent?"var(--privy-color-accent)":"var(--privy-color-foreground-3)")),ql=/*#__PURE__*/ii.div.withConfig({displayName:"SmsInsecureText",componentId:"sc-a63b1990-13"})(["width:100%;display:flex;justify-content:space-between;"]),jl=/*#__PURE__*/ii.p.withConfig({displayName:"TermsText",componentId:"sc-a63b1990-14"})(["text-align:left;width:100%;color:var(--privy-color-foreground-3) !important;"]),Kl=/*#__PURE__*/ii.button.withConfig({displayName:"PrimaryTextButton",componentId:"sc-a63b1990-15"})(["display:flex;flex-direction:row;align-items:center;justify-content:center;user-select:none;&{width:100%;cursor:pointer;border-radius:var(--privy-border-radius-md);font-size:0.875rem;line-height:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{color:",";background-color:transparent;padding:0.5rem 0px;}&:hover{text-decoration:underline;}"],(e=>"dark"===e.theme?"var(--privy-color-foreground-2)":"var(--privy-color-accent)")),Yl=/*#__PURE__*/ii.div.withConfig({displayName:"IconWrapper",componentId:"sc-a63b1990-16"})(["display:flex;align-items:center;justify-content:center;color:var(--privy-color-accent);width:100%;> svg{z-index:2;width:3rem;height:3rem;}"]),Zl=/*#__PURE__*/ii.div.withConfig({displayName:"ErrorMessage",componentId:"sc-a63b1990-17"})(["color:var(--privy-color-error);"]),Xl=({termsAndConditionsUrl:r,privacyPolicyUrl:a,onAccept:i,onDecline:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{closeable:!1}),/*#__PURE__*/t(mi,{width:56,height:56,fill:"var(--privy-color-accent)",style:{margin:"auto"}}),/*#__PURE__*/t(Ll,{style:{marginTop:24},children:"One last step"}),/*#__PURE__*/t(Pl,{children:"By signing up, you agree to our terms and privacy policy."}),/*#__PURE__*/e(sl,{style:{marginTop:24},children:[r&&/*#__PURE__*/e(ul,{target:"_blank",href:r,children:["View Terms ",/*#__PURE__*/t(pi,{style:{marginLeft:"auto"}})]}),a&&/*#__PURE__*/e(ul,{target:"_blank",href:a,children:["View Privacy Policy ",/*#__PURE__*/t(pi,{style:{marginLeft:"auto"}})]})]}),/*#__PURE__*/e(Ql,{style:{marginTop:24},children:[/*#__PURE__*/t(Et,{onClick:o,children:"No thanks"}),/*#__PURE__*/t(wt,{onClick:i,children:"Accept"})]}),/*#__PURE__*/t(Ct,{})]});let Ql=/*#__PURE__*/ii.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-d601b243-0"})(["display:flex;gap:10px;"]);const Jl=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...n,children:/*#__PURE__*/t("path",{fillRule:"evenodd",d:"M12 1.5a5.25 5.25 0 00-5.25 5.25v3a3 3 0 00-3 3v6.75a3 3 0 003 3h10.5a3 3 0 003-3v-6.75a3 3 0 00-3-3v-3c0-2.9-2.35-5.25-5.25-5.25zm3.75 8.25v-3a3.75 3.75 0 10-7.5 0v3h7.5z",clipRule:"evenodd"})});let ec=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-ed4ecf-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),tc=/*#__PURE__*/ii.div.withConfig({displayName:"GappedContainer",componentId:"sc-ed4ecf-1"})(["display:flex;flex-direction:column;gap:8px;"]);const nc=({title:r,description:a,children:i,...o})=>
2
- /*#__PURE__*/t(ic,{...o,children:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("h3",{children:r}),"string"==typeof a?/*#__PURE__*/t("p",{children:a}):a,i]})}),rc=/*#__PURE__*/ii(nc).withConfig({displayName:"PaddedScreenHeader",componentId:"sc-523a75d6-0"})(["margin-bottom:24px;"]),ac=({title:n,description:r,icon:a,children:i,...o})=>/*#__PURE__*/e(oc,{...o,children:[a||null,/*#__PURE__*/t("h3",{children:n}),r&&"string"==typeof r?/*#__PURE__*/t("p",{children:r}):r,i]});let ic=/*#__PURE__*/ii.div.withConfig({displayName:"StyledSection",componentId:"sc-523a75d6-1"})(["display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;text-align:left;gap:8px;width:100%;margin-bottom:24px;&& h3{font-size:17px;color:var(--privy-color-foreground);}&& p{color:var(--privy-color-foreground-2);font-size:14px;}"]),oc=/*#__PURE__*/ii(ic).withConfig({displayName:"CenteredStyledSection",componentId:"sc-523a75d6-2"})(["align-items:center;text-align:center;gap:16px;h3{margin-bottom:24px;}"]),sc=Array(6).fill("");var lc,cc,dc=((lc=dc||{})[lc.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",lc[lc.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",lc),hc=((cc=hc||{})[cc.EMAIL=0]="EMAIL",cc[cc.SMS=1]="SMS",cc);let uc=/*#__PURE__*/ii.div.withConfig({displayName:"PasswordlessCodeContainer",componentId:"sc-1c4b718a-0"})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:center;margin:auto;gap:16px;flex-grow:1;"]),pc=/*#__PURE__*/ii.div.withConfig({displayName:"CodeInput",componentId:"sc-1c4b718a-1"})(["display:flex;flex-direction:column;width:100%;gap:8px;> div:last-child{display:flex;justify-content:center;gap:0.5rem;width:100%;border-radius:var(--privy-border-radius-md);> input{border:1px solid var(--privy-color-foreground-4);background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);padding:8px 10px;height:58px;width:46px;text-align:center;font-size:18px;}> input:focus{border:1px solid var(--privy-color-accent);}> input:invalid{border:1px solid var(--privy-color-error);}> input.success{border:1px solid var(--privy-color-success);}> input.fail{border:1px solid var(--privy-color-error);animation:shake 180ms;animation-iteration-count:2;}}@keyframes shake{0%{transform:translate(1px,0px);}33%{transform:translate(-1px,0px);}67%{transform:translate(-1px,0px);}100%{transform:translate(1px,0px);}}"]),mc=/*#__PURE__*/ii.div.withConfig({displayName:"InputHelp",componentId:"sc-1c4b718a-2"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-end;width:100%;"],(e=>e.$success?"var(--privy-color-success)":e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),yc=/*#__PURE__*/ii.div.withConfig({displayName:"HelpText",componentId:"sc-1c4b718a-3"})(["font-size:13px;color:var(--privy-color-foreground);display:flex;gap:8px;align-items:center;width:100%;margin-top:16px;padding-bottom:32px;"]),gc=/*#__PURE__*/ii.div.withConfig({displayName:"ResendButtonContainer",componentId:"sc-1c4b718a-4"})(["color:var(--privy-color-accent);padding:2px 0;> button{text-decoration:underline;}"]),fc=/*#__PURE__*/ii.div.withConfig({displayName:"Badge",componentId:"sc-1c4b718a-5"})(["display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-sm);padding:2px 8px;gap:4px;background:var(--privy-color-background-2);color:var(--privy-color-foreground-2);"]),wc=/*#__PURE__*/ii.span.withConfig({displayName:"BoldWrappingSpan",componentId:"sc-1c4b718a-6"})(["font-weight:500;word-break:break-all;"]);const vc=({icon:r})=>/*#__PURE__*/t(n,{children:/*#__PURE__*/t(Cc,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{}),"string"==typeof r?
1
+ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createStore as r}from"mipd";import a,{useMemo as i,useEffect as o,useState as s,useRef as l,useCallback as c,useReducer as d,forwardRef as h,useContext as u,createContext as p}from"react";import*as m from"react-device-detect";import{isMobile as y,isIOS as f,isSafari as w,isAndroid as v}from"react-device-detect";import{getAddress as C,isAddress as E}from"viem/utils";import{P as T,f as b,a as A,b as _,c as k,d as I,e as N,u as x,g as S,h as R,i as O,j as M,n as P,k as L,I as D}from"./internal-context-DBDJ7qsa.mjs";import{c as U,p as F,a as B,b as z,u as H,f as V,d as $,e as j,g as G,h as q,o as K,i as Y,j as Z,k as J,l as Q,m as X,n as ee,q as te,r as ne,s as re,t as ie,v as oe,w as se,x as le,y as ce,z as de,A as he,B as ue,C as pe,D as me,E as ye,F as ge,G as fe,H as we,I as ve,J as Ce,K as Ee,L as Te,M as be,N as Ae,O as _e,P as ke,Q as Ie,R as Ne,S as xe,T as Se,U as Re,V as Oe,W as We,X as Me,Y as Pe,Z as Le,_ as De,$ as Ue,a0 as Fe,a1 as Be,a2 as ze,a3 as He,a4 as Ve,a5 as $e,a6 as je,a7 as Ge}from"./paths-CasJYDld.mjs";import{o as qe,R as Ke,C as Ye,E as Ze,P as Je,t as Qe,g as Xe,a as et,B as tt,d as nt,i as rt,W as at,b as it,S as ot,u as st,M as lt,c as ct,A as dt,e as ht,f as ut,s as pt,H as mt,h as yt,F as gt,j as ft,k as wt,l as vt,m as Ct,n as Et,p as Tt,T as bt,q as At,r as _t,v as kt,w as It,x as Nt,y as xt,z as St,D as Rt,G as Ot,I as Wt,J as Mt,K as Pt,L as Lt,N as Dt,O as Ut,Q as Ft,U as Bt,V as zt,X as Ht,Y as Vt,Z as $t,_ as jt,$ as Gt,a0 as qt,a1 as Kt,a2 as Yt,a3 as Zt,a4 as Jt,a5 as Qt,a6 as Xt,a7 as en,a8 as tn,a9 as nn,aa as rn,ab as an,ac as on,ad as sn,ae as ln,af as cn,ag as dn,ah as hn,ai as un,aj as pn,ak as mn,al as yn,am as gn,an as fn,ao as wn,ap as vn,aq as Cn,ar as En,as as Tn,at as bn,au as An,av as _n,aw as kn,ax as In,ay as Nn,az as xn,aA as Sn,aB as Rn,aC as On,aD as Wn,aE as Mn,aF as Pn,aG as Ln}from"./useActiveWallet-DvvTjRH_.mjs";export{aK as useActiveWallet,aI as useConnectWallet,aJ as useFundWallet,aH as useLogin}from"./useActiveWallet-DvvTjRH_.mjs";import*as Dn from"jose";import{base64url as Un}from"jose";import{g as Fn,C as Bn,H as zn,O as Hn,S as Vn,D as $n,a as jn,b as Gn,c as qn,d as Kn,V as Yn,e as Zn,P as Jn,R as Qn,F as Xn,f as er,h as tr,i as nr,j as rr,k as ar,l as ir,I as or,m as sr,n as lr,o as cr,p as dr,u as hr,M as ur,q as pr,r as mr,s as yr,t as gr,v as fr,w as wr,x as vr,W as Cr,y as Er,z as Tr,A as br,B as Ar,E as _r,G as kr,J as Ir,K as Nr,L as xr,N as Sr,Q as Rr,T as Or,U as Wr,X as Mr,Y as Pr,Z as Lr,_ as Dr,$ as Ur,a0 as Fr,a1 as Br,a2 as zr,a3 as Hr,a4 as Vr,a5 as $r,a6 as jr,a7 as Gr,a8 as qr,a9 as Kr,aa as Yr,ab as Zr,ac as Jr}from"./useWallets-8w3LVxdW.mjs";export{ad as SUPPORTED_CHAINS,af as addPrivyRpcToChain,ae as addRpcUrlOverrideToChain}from"./useWallets-8w3LVxdW.mjs";import{e as Qr,i as Xr,f as ea,S as ta,a as na,l as ra,u as aa,C as ia,b as oa,c as sa,O as la,d as ca,g as da,h as ha,P as ua,j as pa,k as ma,m as ya,n as ga,p as fa,o as wa,q as va,r as Ca,s as Ea,t as Ta,v as ba}from"./prepareFundingModalData-CsN1TYQy.mjs";export{W as WalletConnector}from"./prepareFundingModalData-CsN1TYQy.mjs";import{v4 as Aa}from"uuid";import _a from"eventemitter3";import{CoinbaseWalletSDK as ka}from"@coinbase/wallet-sdk";import{isHex as Ia,toHex as Na,createPublicClient as xa,http as Sa,createWalletClient as Ra,custom as Oa,publicActions as Wa,formatUnits as Ma,parseEther as Pa,encodeFunctionData as La,isAddress as Da,decodeFunctionData as Ua,decodeAbiParameters as Fa,formatEther as Ba,hexToString as za}from"viem";import{g as Ha,a as Va}from"./getPublicClient-BghjDv1y.mjs";import{ofetch as $a}from"ofetch";import ja from"js-cookie";import{create as Ga}from"zustand";import{Turnstile as qa}from"@marsidev/react-turnstile";import{styled as Ka,css as Ya,createGlobalStyle as Za}from"styled-components";import Ja from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Qa from"@heroicons/react/24/outline/ExclamationTriangleIcon";import Xa from"@heroicons/react/24/outline/WalletIcon";import ei from"@heroicons/react/24/outline/ExclamationCircleIcon";import ti from"@heroicons/react/24/outline/Square2StackIcon";import ni from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import ri from"@heroicons/react/24/solid/DocumentCheckIcon";import ai from"@heroicons/react/20/solid/CheckIcon";import ii from"@heroicons/react/24/outline/EnvelopeIcon";import oi from"@heroicons/react/24/outline/PhoneIcon";import si from"@heroicons/react/24/solid/CheckCircleIcon";import li from"@heroicons/react/24/solid/XCircleIcon";import ci from"@heroicons/react/24/outline/CheckCircleIcon";import di from"@heroicons/react/24/outline/CloudArrowUpIcon";import hi from"@heroicons/react/24/outline/NoSymbolIcon";import ui from"fast-password-entropy";import*as pi from"secure-password-utilities";import{DEFAULT_WORDLIST as mi}from"secure-password-utilities/wordlists";import yi from"@heroicons/react/24/outline/ArrowPathIcon";import gi from"@heroicons/react/24/outline/EyeIcon";import fi from"@heroicons/react/24/outline/EyeSlashIcon";import wi from"@heroicons/react/24/outline/KeyIcon";import vi from"@heroicons/react/24/outline/ArrowDownTrayIcon";import Ci from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import Ei from"@heroicons/react/24/outline/DocumentDuplicateIcon";import Ti from"@heroicons/react/24/outline/UserCircleIcon";import bi from"@heroicons/react/24/solid/LockClosedIcon";import{formatWalletAddress as Ai,getCoinbaseOnRampUrl as _i,chainToMoonpayCurrency as ki,isSupportedChainIdForMoonpay as Ii,isSupportedChainIdForCoinbaseOnramp as Ni,formatTokenAmount as xi,formatWeiAmount as Si,countryCodesAndNumbers as Ri,validatePhoneNumber as Oi,phoneNumberTypingFormatter as Wi,getPlaceholderPhoneNumber as Mi,getCountryCallingCode as Pi,getPhoneCountryCodeAndNumber as Li,formatPhoneNumber as Di,toObjectKeys as Ui,lastFourDigits as Fi,SolanaClient as Bi,ProviderErrors as zi}from"@privy-io/js-sdk-core";import{Menu as Hi,MenuButton as Vi,MenuItems as $i,MenuItem as ji,Transition as Gi,Dialog as qi,TransitionChild as Ki,DialogPanel as Yi}from"@headlessui/react";import Zi from"@heroicons/react/24/outline/ChevronDownIcon";import Ji from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import Qi from"@heroicons/react/24/outline/CreditCardIcon";import Xi from"@heroicons/react/24/outline/QrCodeIcon";import eo from"@heroicons/react/24/outline/InformationCircleIcon";import to from"@heroicons/react/24/outline/ChevronRightIcon";import no from"@heroicons/react/24/outline/FingerPrintIcon";import ro from"@heroicons/react/24/outline/ClockIcon";import ao from"@heroicons/react/24/outline/TrashIcon";import io from"@heroicons/react/24/solid/CheckBadgeIcon";import oo from"@heroicons/react/24/outline/ShieldCheckIcon";import so from"@heroicons/react/24/solid/IdentificationIcon";import lo from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import co from"@heroicons/react/24/outline/MinusCircleIcon";import ho from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import uo from"@heroicons/react/24/solid/ShieldCheckIcon";import po from"@heroicons/react/24/outline/CalendarIcon";import mo from"@heroicons/react/24/outline/GlobeAltIcon";import yo from"@heroicons/react/24/outline/LockClosedIcon";import go from"@heroicons/react/24/outline/PencilSquareIcon";import{ChevronDownIcon as fo,ArrowRightIcon as wo}from"@heroicons/react/24/outline";import vo from"@heroicons/react/24/outline/ClipboardDocumentIcon";import{i as Co}from"./importWallet-ylHVDCXz.mjs";export{g as getEmbeddedConnectedWallet}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"zustand/shallow";import"zustand/traditional";import"tinycolor2";class Eo{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(U,{token:this.meta.token})}catch(e){throw b(e)}}async link(){throw Error("Unimplemented")}constructor(e){this.meta={token:e}}}function To(e){return e?{"privy-ui":"t"}:void 0}class bo{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(F,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(B,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw b(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new T("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new T("Email must be set when initialzing authentication.");let r=To(n);try{return await this.api.post(z,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw b(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class Ao extends bo{async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new T("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(H,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw b(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class _o{get meta(){return this._meta}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");try{let e=await this.api.post(V,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new T("No response from authentication");return e}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post($,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw b(e)}}async _startChannelOnce(){if(!this.api)throw new T("Auth flow has no API instance");let e=await this.api.post(j,{token:this.captchaToken});y&&!f&&e.connect_uri&&qe(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new T("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");let e=await this.api.get(G,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new Ke(this._startChannelOnce.bind(this)),this.pollForReady=new Ke(this._pollForReady.bind(this)),this._meta.disableSignup=t}}function ko(e){return crypto.getRandomValues(new Uint8Array(e))}class Io{getOrCreateGuestCredential(e){let t=Fn(e);if(Qr()){if(Xr.get(t))return Xr.get(t);{let e=Un.encode(ko(32));return Xr.put(t,e),e}}return Un.encode(ko(32))}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(q,{guest_credential:this.meta.guestCredential})}catch(e){throw b(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function No(){return Un.encode(ko(36))}function xo(){return No()}async function So(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return Un.encode(t)}}class Ro{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new T("User denied confirmation during OAuth flow");let e=function(){let e=Xr.get(Bn);if(!e)throw new T("Authentication error.");return e}();try{let t=await this.api.post(K,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Xr.del(Bn),Xr.del(zn),Xr.del(Hn),t}catch(e){let t=b(e);if(t.privyErrorCode)throw new T(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new T("Invalid code during oauth flow.",void 0,A.OAUTH_USER_DENIED);throw new T("Invalid code during OAuth flow.",void 0,A.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new T("User denied confirmation during OAuth flow");let e=Xr.get(Bn);if(!e)throw new T("Authentication error.");try{let t=await this.api.post(Y,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return Xr.del(Bn),t}catch(e){throw b(e)}}async getAuthorizationUrl(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.provider)throw new T("Provider must be set when initializing OAuth authentication.");let e=No();Xr.put(Bn,e);let t=xo();Xr.put(Vn,t);let n=await So(e);this.meta.withPrivyUi||Xr.put(zn,!0),this.meta.disableSignup&&Xr.put(Hn,!0);let r=To(this.meta.withPrivyUi);try{return await this.api.post(Z,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...r}})}catch(e){throw b(e)}}constructor(e){this.meta=e}}function Oo(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Wo=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),/*#__PURE__*/t("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]}),Mo=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("g",{clipPath:"url(#clip0)",children:/*#__PURE__*/t("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0",children:/*#__PURE__*/t("rect",{width:"71",height:"55",fill:"white"})})})]}),Po=({style:e,...n})=>/*#__PURE__*/t("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...n,children:/*#__PURE__*/t("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})}),Lo=({style:e})=>/*#__PURE__*/t(mo,{style:{color:"var(--privy-color-error)",...e}}),Do=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...n},...r,children:[/*#__PURE__*/t("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),/*#__PURE__*/t("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),/*#__PURE__*/t("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),/*#__PURE__*/t("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});function Uo(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...n,children:[/*#__PURE__*/e("defs",{children:[/*#__PURE__*/e("linearGradient",{id:"b",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#3771c8"}),/*#__PURE__*/t("stop",{stopColor:"#3771c8",offset:".128"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),/*#__PURE__*/e("linearGradient",{id:"a",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".1",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".5",stopColor:"#ff543e"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#c837ab"})]}),/*#__PURE__*/t("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),/*#__PURE__*/t("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),/*#__PURE__*/t("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/t("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/t("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}function Fo({style:e,...n}){/*#__PURE__*/return t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...e},...n,children:/*#__PURE__*/t("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:/*#__PURE__*/t("g",{transform:"scale(5.12,5.12)",children:/*#__PURE__*/t("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}function Bo(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...n,children:[/*#__PURE__*/t("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),/*#__PURE__*/t("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}function zo(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...n,children:[/*#__PURE__*/t("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),/*#__PURE__*/t("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),/*#__PURE__*/t("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}const Ho=({style:e,...n})=>/*#__PURE__*/t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...e},...n,children:/*#__PURE__*/t("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})});let Vo={google:{name:"Google",component:Do},discord:{name:"Discord",component:Mo},github:{name:"Github",component:Po},linkedin:{name:"LinkedIn",component:Fo},twitter:{name:"Twitter",component:Ho},spotify:{name:"Spotify",component:Bo},instagram:{name:"Instagram",component:Uo},tiktok:{name:"Tiktok",component:zo},apple:{name:"Apple",component:Wo}};const $o=e=>e in Vo?Vo[e]:{name:"Unknown",component:Lo};function jo(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),n=e.get("privy_oauth_state"),r=e.get("privy_oauth_provider");if(!t||!n||!r)return{inProgress:!1};let a=!1;try{a=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:n,provider:r,withPrivyUi:!Xr.get(zn),popupFlow:null!==window.opener&&a,disableSignup:!!Xr.get(Hn)}}function Go(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Xr.del(Vn),window.history.replaceState({},"",e)}class qo{async initRegisterFlow(e){if(!this.api)throw new T("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new T("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new T("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new T("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new T("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(J,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new T("Passkey request timed out or rejected by user.",void 0,A.PASSKEY_NOT_ALLOWED);throw b(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new T("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new T("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let n=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(Q,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new T("Passkey request timed out or rejected by user.",void 0,A.PASSKEY_NOT_ALLOWED);throw b(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new T("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new T("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(X,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new T("Passkey request timed out or rejected by user.",void 0,A.PASSKEY_NOT_ALLOWED);throw b(e)}}async _initRegisterOnce(e){if(!this.api)throw new T("Auth flow has no API instance");let t=To(e);return await this.api.post(ee,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new T("Auth flow has no API instance");let t=To(e);return await this.api.post(te,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new T("Auth flow has no API instance");return await this.api.post(ne,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new Ke(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new Ke(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Ke(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}class Ko{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(re,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(ie,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw b(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new T("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new T("phone nNumber must be set when initialzing authentication.");let r=To(n);try{return await this.api.post(oe,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw b(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:n}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:n??!1}}}class Yo extends Ko{async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new T("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(se,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw b(e)}}constructor(e,t,n){super({phoneNumber:t,captchaToken:n}),this.meta={phoneNumber:t,captchaToken:n,oldPhoneNumber:e,disableSignup:!1}}}class Zo{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(le,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(ce,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw b(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function Jo(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===A.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===A.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===A.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===A.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof Ye&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function Qo(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function Xo(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}class es{static parse(e){try{return new es(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return Dn.decodeJwt(e),e}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=Dn.decodeJwt(e)}}class ts extends es{static parse(e){try{return new ts(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}const ns=({style:n,...r})=>/*#__PURE__*/e("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});let rs,as=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],is=(e,t)=>e.makeWeb3Provider({options:t});class os extends Ze{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new _("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw ea(e)}}updateConnectionPreference(e){this.connectionOptions=e,this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(is(rs,this.connectionOptions))}constructor(e,t,n,r,a,i){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Je(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=r.coinbaseWallet.connectionOptions??"all",this.walletClientType="smartWalletOnly"===this.connectionOptions?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!rs){let n=[t.id].concat(e.map((e=>e.id))),r="eoaOnly"!==this.connectionOptions?n.filter((e=>!as.includes(e))):[];r.length>0&&!r.every((e=>$n.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${r.join(", ")}`),rs=new ka({appName:a,appLogoUrl:i,appChainIds:n})}this.proxyProvider.setWalletProvider(is(rs,this.connectionOptions))}}const ss=({...e})=>/*#__PURE__*/t("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:e.color||"var(--privy-color-foreground-3)"})});class ls extends Ze{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[Qe(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:ss,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}constructor({provider:e,chains:t,defaultChain:n,rpcConfig:r,imported:a,walletIndex:i}){super("privy",t,n,r),this.connectorType="embedded",this.proxyProvider=e,this.walletIndex=i,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}}const cs=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];let ds={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844"};const hs={legacy:0,eip2930:1,eip1559:2,eip4844:3};let us=e=>void 0!==e?BigInt(e):void 0;function ps(e){let t,{type:n=2,...r}=e;r.accessList&&Array.isArray(r.accessList)?t=r.accessList.map((e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e)):r.accessList&&(t=Object.entries(r.accessList).map((e=>({address:e[0],storageKeys:e[1]}))));let a=Number(r.chainId??1),i=Ia(r.data)?r.data:r.data?Na(Uint8Array.from(r.data)):void 0,o=r.nonce?Number(r.nonce):void 0,s={chainId:a,data:i,nonce:o,value:us(r.value),gas:us(r.gas??r.gasLimit)},l=Number(n);if(0===l)return{...r,type:ds[l],...s,gasPrice:us(r.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===l)return{...r,type:ds[l],...s,gasPrice:us(r.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===l)return{...r,type:ds[l],...s,nonce:o,accessList:t,maxFeePerGas:us(r.maxFeePerGas),maxPriorityFeePerGas:us(r.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw new T(`Unsupported transaction type: ${n}`)}class ms extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}class ys extends _a{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new ms(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await rw()||!this.address)throw new ms("Disconnected",4900);let{hash:n}=await sw(t,{address:this.address});return n}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new ms(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await rw()||!this.address)throw new ms("Disconnected",4900);let{signature:n}=await ow(t,{address:this.address});return n}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new ms(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new ms(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Ha(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],n=e.params[1],{signature:r}=await aw({message:t},{address:n});return r}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],n="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:r}=await iw(Xe(n),{address:t});return r}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:Qe(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...ps(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return Qe(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>cs.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await rw();if(await lw(),!t||!this.address)throw new ms("Disconnected",4900);try{return(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:{method:e.method,params:e.params}})).response.data}catch(e){throw console.error(e),new ms("Disconnected",4900)}}}constructor({walletProxy:e,address:t,entropyId:n,entropyIdVerifier:r,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l}){super(),this.walletProxy=e,this.address=t,this.entropyId=n,this.entropyIdVerifier=r,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Ha(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=et(a,"privy"),this.appId=o,this.walletIndex=l}}class gs extends Ze{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:n,walletClientType:r,defaultChain:a}){super(r,[],a,{}),this.connectorType="null",this.proxyProvider=new Je(void 0,jn),this.id=e,this.name=t,this.icon=n,this.connectorType=r}}const fs=({style:n,...r})=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...n},...r,children:[/*#__PURE__*/t("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),/*#__PURE__*/t("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),/*#__PURE__*/t("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),/*#__PURE__*/t("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),/*#__PURE__*/t("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),/*#__PURE__*/t("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),/*#__PURE__*/t("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),/*#__PURE__*/t("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),/*#__PURE__*/t("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),/*#__PURE__*/t("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),/*#__PURE__*/t("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),/*#__PURE__*/t("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),/*#__PURE__*/t("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]}),ws=({style:n,...r})=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});function vs(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Cs=0;class Es extends Ze{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new _("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw ea(e)}}constructor(e,t,n,r,a){super(a||"unknown",e,t,n),this.connectorType="injected",this.proxyProvider=new Je(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=r;let i=r.provider;this.proxyProvider.setWalletProvider(i)}}var Ts="__private_"+Cs+++"__walletBranding";class bs extends Ze{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return vs(this,Ts)[Ts]??{name:"Browser Extension",icon:tt,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new _("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw ea(e)}}constructor(e,t,n,r,a){super(a??"unknown",e,t,n),Object.defineProperty(this,Ts,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Je(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(r),"metamask"===a?vs(this,Ts)[Ts]={name:"MetaMask",icon:fs,id:"io.metamask"}:"phantom"===a&&(vs(this,Ts)[Ts]={name:"Phantom",icon:ws,id:"phantom"})}}class As extends Es{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{y||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new _("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw ea(e)}}}const _s=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","crypto.com_wallet_extension","crypto.com_onchain","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","privy","unknown","phantom","solflare","glow","backpack"],ks=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:m.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=Ns({client:this.client,isSolana:t,connectOnly:n});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${r}?ref=${r}`}},solflare:{client:"solflare",name:"Solflare",installLink:m.isFirefox?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=Ns({client:this.client,isSolana:t,connectOnly:n});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${r}?ref=${r}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcbcmnbpgliof",chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=Ns({client:this.client,isSolana:t,connectOnly:n});return`${e?"backpack://ul/v1/":"https://backpack.com/ul/v1/"}browse/${r}?ref=${r}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",chainTypes:["solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return"https://www.okx.com/download?deeplink="+encodeURIComponent("okx://wallet/dapp/url?dappUrl="+Ns({client:this.client,isSolana:e,connectOnly:t}))}}});function Is({connectorType:e,walletClientType:t}){for(let n of _s)if(e===n||t===n)return ks[n]}function Ns({client:e,isSolana:t,connectOnly:n}){let r=new URL(window.location.href);return r.searchParams.set("privy_connector",t?"solana_adapter":"injected"),r.searchParams.set("privy_wallet_client",e),r.searchParams.set("privy_connect_only",String(n)),encodeURIComponent(r.href.replace(/\/$/g,""))}class xs extends ta{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:n}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new Je(void 0,jn),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=n}}class Ss extends _a{get wallets(){let e=new Set,t=this.walletConnectors.flatMap((e=>e.wallets)).sort(((e,t)=>e.connectedAt&&t.connectedAt?t.connectedAt-e.connectedAt:0)).filter((t=>{let n=`${t.address}${t.walletClientType}${t.connectorType}${t.meta.id}`;return!e.has(n)&&(e.add(n),!0)})),n=t.findIndex((e=>e.address===(this.activeWallet?this.activeWallet:"unknown")));return n>=0&&t.unshift(t.splice(n,1)[0]),t}async initialize(e){if(this.initialized&&!e)return;e&&this.removeAllConnectors(),Xr.get(Gn)&&(Xr.getKeys().forEach((e=>{e.startsWith("walletconnect")&&Xr.del(e)})),Xr.del(Gn));let t=nt({store:this.store,walletList:this.walletList,externalWalletConfig:this.externalWalletConfig,walletChainType:this.walletChainType}).then((e=>{e.forEach((({type:e,eip6963InjectedProvider:t,legacyInjectedProvider:n})=>{this.createEthereumWalletConnector({connectorType:"injected",walletClientType:e,providers:{eip6963InjectedProvider:t,legacyInjectedProvider:n}})}))}));for(let e of(this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector({connectorType:"coinbase_wallet",walletClientType:"coinbase_wallet"}),Object.values(ks)))!e.isInstalled&&this.walletList.includes(e.client)&&(["ethereum-only","ethereum-and-solana"].includes(this.walletChainType)&&e.chainTypes.includes("ethereum")&&this.createEthereumWalletConnector({connectorType:"null",walletClientType:e.client,walletConfig:e}),["ethereum-and-solana","solana-only"].includes(this.walletChainType)&&e.chainTypes.includes("solana")&&this.addSolanaWalletConnector(new xs({id:e.client,name:e.name})));this.externalWalletConfig.walletConnect.enabled&&this.createEthereumWalletConnector({connectorType:"wallet_connect_v2",walletClientType:"unknown"}),this.externalWalletConfig.solana.connectors?.get().forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.((e=>{e?.forEach(this.addSolanaWalletConnector)})),await t,this.initialized=!0}findWalletConnector(e,t){return"wallet_connect_v2"===e?this.walletConnectors.filter(rt).find((t=>t.connectorType===e))??null:this.walletConnectors.filter(rt).find((n=>n.connectorType===e&&n.walletClientType===t))??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(na).find((t=>"unknown"===t.walletClientType?t.walletBranding.id===e:t.walletClientType===e))??null}findEmbeddedWalletConnectors(){return this.walletConnectors.filter((e=>"embedded"===e.connectorType))}onInitialized(e){e.wallets.forEach((e=>{let t=this.storedConnections.find((t=>t.address===e.address&&t.connectorType===e.connectorType&&("solana"===e.type&&"unknown"===t.walletClientType&&"unknown"===e.walletClientType?e.meta.id===t.id:t.walletClientType===e.walletClientType)));t&&(e.connectedAt=t.connectedAt)})),this.saveConnectionHistory(),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnectors({walletProxy:e,rootWallet:t,embeddedWallets:n,defaultChain:r,appId:a}){for(let i of n){let n=this.findEmbeddedWalletConnectors().find((e=>e.walletIndex===i.walletIndex));if(n&&rt(n))n.proxyProvider.walletProxy=e;else{let{entropyId:n,entropyIdVerifier:o}=qn(t),s=new ls({provider:new ys({walletProxy:e,address:i.address,entropyId:n,entropyIdVerifier:o,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:r.id,walletIndex:i.walletIndex}),chains:this.chains,defaultChain:r,rpcConfig:this.rpcConfig,imported:!1,walletIndex:i.walletIndex});this.addWalletConnector(s)}}}addImportedWalletConnector(e,t,n,r){let a=this.findWalletConnector("embedded_imported","privy");if(a&&rt(a))a.proxyProvider.walletProxy=e;else{let a=new ls({provider:new ys({walletProxy:e,address:t,entropyId:t,entropyIdVerifier:"ethereum-address-verifier",walletIndex:0,rpcConfig:this.rpcConfig,chains:this.chains,appId:r,chainId:n.id}),chains:this.chains,walletIndex:0,defaultChain:n,rpcConfig:this.rpcConfig,imported:!0});this.addWalletConnector(a)}}removeEmbeddedWalletConnectors(){this.walletConnectors=this.walletConnectors.filter((e=>"embedded"!==e.connectorType)),this.saveConnectionHistory(),this.storedConnections=ra(),this.emit("walletsUpdated")}removeImportedWalletConnector(){let e=this.findWalletConnector("embedded_imported","privy");if(e){let t=this.walletConnectors.indexOf(e);this.walletConnectors.splice(t,1),this.saveConnectionHistory(),this.storedConnections=ra(),this.emit("walletsUpdated")}}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:n,walletConfig:r}){let a=this.findWalletConnector(e,t);if(a&&rt(a))return a instanceof at&&a.resetConnection(t),a;let i=(()=>"injected"!==e?"coinbase_wallet"===e?new os(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):"null"!==e?new at(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,this.privyAppName,t):r?new gs({id:r.client,name:r.name,defaultChain:this.defaultChain,walletClientType:r.client}):null:"metamask"===t&&n?.eip6963InjectedProvider?new As(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask"):"metamask"===t&&n?.legacyInjectedProvider?new bs(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask"):"phantom"===t&&n?.legacyInjectedProvider?new bs(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom"):n?.legacyInjectedProvider&&"unknown_browser_extension"===t?new bs(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider):n?.eip6963InjectedProvider?new Es(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,t):void 0)();return i&&this.addWalletConnector(i),i||null}addWalletConnector(e){this.walletConnectors.push(e),e.on("initialized",(()=>this.onInitialized(e))),e.on("walletsUpdated",(()=>this.onWalletsUpdated(e))),e.initialize().catch((e=>{console.debug("Failed to initialize connector",e)}))}saveConnectionHistory(){let e=this.wallets.map((e=>({address:e.address,connectorType:e.connectorType,walletClientType:e.walletClientType,connectedAt:e.connectedAt,id:e.meta.id})));Xr.put(Kn,e)}async activeWalletSign(e){let t=this.wallets,n=t.length>0?t[0]:null;return n&&it(n)?n.sign(e):null}setActiveWallet(e){this.activeWallet=C(e),this.emit("walletsUpdated")}setWalletList(e){this.walletList=e,this.initialized&&this.initialize(!0).catch(console.error)}removeAllConnectors(){for(let e of this.walletConnectors)e.removeAllListeners();this.walletConnectors=[]}constructor(e,t,n,r,a,i,o,s,l,c,d,h){super(),this.addSolanaWalletConnector=async e=>{let t=this.findSolanaWalletConnector(e.walletClientType);if(!t||"null"===t.connectorType){if("null"===t?.connectorType){let e=this.walletConnectors.indexOf(t);this.walletConnectors.splice(e,1)}this.addWalletConnector(e)}},this.getEthereumProvider=()=>{let e=this.wallets[0],t=this.walletConnectors.find((t=>t.wallets.find((t=>t.address===e?.address))));return e&&t?t.proxyProvider:new Je},this.privyAppId=e,this.walletConnectCloudProjectId=t,this.rpcConfig=n,this.chains=r,this.defaultChain=a,this.walletConnectors=[],this.initialized=!1,this.store=i,this.walletList=o,this.shouldEnforceDefaultChainOnConnect=s,this.externalWalletConfig=l,this.privyAppName=c,this.privyAppLogo=d,this.walletChainType=h||"ethereum-only",this.storedConnections=ra()}}let Rs=[de,he,ue,pe];class Os{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw b(e)}}async post(e,t,n){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...n})}catch(e){throw b(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw b(e)}}constructor({appId:e,appClientId:t,client:n,defaults:r}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=n.clientAnalyticsId,this.sdkVersion=Yn,this.client=n,this.defaults=r,this.fallbackApiUrl=n.fallbackApiUrl,this.baseFetch=$a.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:e,options:t})=>{let n=new Headers(t.headers);n.set("privy-app-id",this.appId),this.appClientId&&n.set("privy-client-id",this.appClientId),n.set("privy-ca-id",this.clientAnalyticsId||""),n.set("privy-client",`react-auth:${this.sdkVersion}`);let r=Rs.includes(e.toString());if(!n.has("authorization")){let e=await this.client.getAccessToken({disableAutoRefresh:r});null!==e&&n.set("authorization",`Bearer ${e}`)}t.headers=n,t.retryDelay&&"number"==typeof t.retryDelay&&(t.retryDelay=3*t.retryDelay)},onRequestError:({error:e})=>{if(e instanceof DOMException&&"AbortError"===e.name)throw new k}})}}let Ws=/paymaster\.biconomy\.io\/api/i,Ms={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const Ps=(e,t)=>e&&Ws.test(e)?Ms:t&&t.policy_id?{policyId:t.policy_id}:void 0;function Ls(){return!(w&&window.location.origin.startsWith("http://localhost"))}const Ds=Ga((()=>({identityToken:null})));function Us(){let{identityToken:e}=Ds();return{identityToken:e}}var Fs,Bs=((Fs={}).PRIVY="privy_access_token",Fs.CUSTOMER="customer_access_token",Fs);class zs{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(Zn)}get privyAccessToken(){return this._getToken(Jn)}_getToken(e){try{let t=Xr.get(e);return"string"==typeof t?es.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=Xr.get(Qn);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}get forkedToken(){try{let e=Xr.get(Xn);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=Xr.get(er(e));if("string"!=typeof t)return null;{let n=new es(t);return n.isExpired()?(Xr.del(er(e)),null):n.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=ja.get(tr);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e="privy_access_token"){let t="string"==typeof this.getToken(e),n="string"==typeof this.refreshToken&&this.refreshToken!==nr;return this.mightHaveServerCookies||t&&n}hasRecoveryCredentials(){return"string"==typeof this.forkedToken}hasActiveAccessToken(e){let t=es.parse(this.getToken(e));return null!==t&&!t.isExpired(30)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(e,t){"string"==typeof t?Xr.put(er(e),t):Xr.del(er(e))}updateIdentityToken(e){"string"==typeof e?this.storeIdentityToken(e):this.clearIdentityToken()}async _authenticate(e){try{let t=await e.authenticate(),{user:n,is_new_user:r,oauth_tokens:a}=t;this.handleTokenResponse(t);let i=a?{provider:a.provider,accessToken:a.access_token,accessTokenExpiresInSeconds:a.access_token_expires_in_seconds,refreshToken:a.refresh_token,refreshTokenExpiresInSeconds:a.refresh_token_expires_in_seconds,scopes:a.scopes}:void 0;return this._trackAuthenticateEvents(e,r),{user:rr(n),isNewUser:r,oAuthTokens:i}}catch(e){throw console.warn("Error authenticating session"),I(e)}}_trackAuthenticateEvents(e,t){let n=function(e){return e instanceof bo?"email":e instanceof Ko?"sms":e instanceof ot?"siwe":e instanceof Io?"guest":e instanceof Eo?"custom_auth":e instanceof Ro?e.meta.provider:null}(e);n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:n,isNewUser:t}}),"siwe"===n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:e.meta.connectorType,walletClientType:e.meta.walletClientType}})}async _link(e){try{let t=await e.link(),n=t.oauth_tokens,r=n?{provider:n.provider,accessToken:n.access_token,accessTokenExpiresInSeconds:n.access_token_expires_in_seconds,refreshToken:n.refresh_token,refreshTokenExpiresInSeconds:n.refresh_token_expires_in_seconds,scopes:n.scopes}:void 0;return{user:rr(t),oAuthTokens:r}}catch(e){throw console.warn("Error linking account"),I(e)}}async _refresh(){if(!this.api)throw new T("Session has no API instance");if(!this.client)throw new T("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let e=this.token,t=this.refreshToken,n=this.forkedToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let r;if(e&&t||this.mightHaveServerCookies){let a={};e&&(a.authorization=`Bearer ${e}`),r=await this.api.post(de,t?{refresh_token:t}:{},{headers:a}),n&&this.clearForkedToken()}else{if(!n)return null;r=await this.api.post(he,{refresh_token:n}),this.clearForkedToken()}return this.handleTokenResponse(r),rr(r.user)}catch(e){if(e instanceof N&&e.privyErrorCode===A.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw I(e)}}handleTokenResponse(e){e.session_update_action&&"set"!==e.session_update_action?"clear"===e.session_update_action?this.destroyLocalState():"ignore"===e.session_update_action&&(e.token&&(this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token)),e.identity_token&&this.storeIdentityToken(e.identity_token)):this._storeAllTokens(e)}_storeAllTokens(e){this.storeRefreshToken(e.refresh_token),this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),e.identity_token&&this.storeIdentityToken(e.identity_token)}async _destroy(){try{await(this.api?.post(ue,{refresh_token:this.refreshToken}))}catch(e){console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new T("Session has no API instance");let e=this.refreshToken;try{let t=await this.api.post(me,{refresh_token:e});return this.storeRefreshToken(t.refresh_token),this.storeCustomerAccessToken(t.token),t.new_session_refresh_token}catch(e){throw I(e)}}destroyLocalState(){this.storeRefreshToken(null),this.storeCustomerAccessToken(null),this.storePrivyAccessToken(null),this.clearIdentityToken(),this.clearForkedToken()}storeCustomerAccessToken(e){if("string"==typeof e){let t=Xr.get(Zn);if(Xr.put(Zn,e),!this.client?.useServerCookies){let t=es.parse(e)?.expiration;ja.set(ar,e,{sameSite:"Strict",secure:Ls(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else Xr.del(Zn),ja.remove(ar),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(Xr.put(Qn,e),this.client?.useServerCookies||ja.set(tr,"t",{sameSite:"Strict",secure:Ls(),expires:30})):(Xr.del(Qn),ja.remove(ir),ja.remove(tr))}storePrivyAccessToken(e){"string"==typeof e?Xr.put(Jn,e):Xr.del(Jn)}storeIdentityToken(e){if(Ds.setState({identityToken:e}),this.client?.useServerCookies)return;Xr.put(or,e);let t=es.parse(e)?.expiration;ja.set(sr,e,{sameSite:"Strict",secure:Ls(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){Xr.del(or),Ds.setState({identityToken:null}),ja.remove(sr)}clearForkedToken(){Xr.del(Xn)}constructor(){this.authenticateOnce=new Ke((async e=>this._authenticate(e))),this.linkOnce=new Ke((async e=>this._link(e))),this.refreshOnce=new Ke(this._refresh.bind(this)),this.destroyOnce=new Ke(this._destroy.bind(this)),this.forkSessionOnce=new Ke(this._forkSession.bind(this))}}let Hs;var Vs=0,$s="__private_"+Vs+++"__getOrGenerateClientAnalyticsId";class js{initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:r,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:o,externalWalletConfig:s,appName:l,walletChainType:c}){this.connectors||(this.connectors=new Ss(this.appId,e,t,n,r,a,i,o,s,l,void 0,c))}generateApi(){let e=new Os({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=e,e}updateApiUrl(e){this.apiUrl=e||this.fallbackApiUrl,this.api=this.generateApi(),e&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new T("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new T("No auth flow in progress.");let{oAuthTokens:e}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:e}}storeProviderAccessToken(e,t){this.session.storeProviderAccessToken(e,t)}getProviderAccessToken(e){return this.session.getProviderAccessToken(e)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(e){e.linkedAccounts.filter((e=>"cross_app"===e.type)).forEach((e=>{this.storeProviderAccessToken(e.providerApp.id,null)}))}startAuthFlow(e){return e.api=this.api,this.authFlow=e,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(ye,{action:"verify"})}catch(e){throw b(e)}}async initMfaPasskeyVerification(){try{return(e=>({rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}))((await this.api.post(ge,{})).options)}catch(e){throw b(e)}}async getCrossAppProviderDetails(e){try{return this._cachedProviderAppDetails[e]||(this._cachedProviderAppDetails[e]=await this.api.get(`/api/v1/apps/${e}/cross-app/details`)),this._cachedProviderAppDetails[e]}catch(e){console.error("Error fetching cross app provider details",e)}}async acceptTerms(){try{let e=await this.api.post(fe,{});return rr(e)}catch(e){throw I(e)}}async unlinkEmail(e){try{let t=await this.api.post(we,{address:e});return await this.getAuthenticatedUser()??rr(t)}catch(e){throw I(e)}}async unlinkPhone(e){try{let t=await this.api.post(ve,{phoneNumber:e});return await this.getAuthenticatedUser()??rr(t)}catch(e){throw I(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(Ce,{address:e});return await this.getAuthenticatedUser()??rr(t)}catch(e){throw I(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(Ee,{address:e});return await this.getAuthenticatedUser()??rr(t)}catch(e){throw I(e)}}async unlinkOAuth(e,t){try{let n=await this.api.post(Te,{provider:e,subject:t});return await this.getAuthenticatedUser()??rr(n)}catch(e){throw I(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(be,{fid:e});return await this.getAuthenticatedUser()??rr(t)}catch(e){throw I(e)}}async unlinkTelegram(e){try{let t=await this.api.post(Ae,{telegram_user_id:e});return await this.getAuthenticatedUser()??rr(t)}catch(e){throw I(e)}}async revokeDelegatedWallet(){try{await this.api.post(_e,{})}catch(e){throw I(e)}}async createAnalyticsEvent({eventName:e,payload:t,timestamp:n,options:r}){if("undefined"!=typeof window)try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(pe,{event_name:e,client_id:this.clientAnalyticsId,payload:{...t||{},clientTimestamp:n?n.toISOString():(new Date).toISOString()}},{retry:-1,keepalive:r?.keepAlive??!1})}catch(e){console.log("Unable to submit event. This is not an issue.")}}async signMoonpayOnRampUrl(e){try{return this.api.post(ke,e)}catch(e){throw I(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(Ie,e)}catch(e){throw I(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${Ne}?partnerUserId=${e}`)}catch(e){throw I(e)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(e){return await this.getPrivyAccessToken(e)||await this.getCustomerAccessToken(e)}async getCustomerAccessToken(e){return await this._getToken(Bs.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(Bs.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?ts.parse(this.session.getToken(e))?.appId!==this.appId?(await this.logout(),null):this.session.getToken(e):(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials(e)?(await this.session.refresh(),this.session.getToken(e)):null:null}async getSmartWalletsConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let n=await this.api.get(`/api/v1/apps/${this.appId}/smart_wallets`,{baseURL:this.fallbackApiUrl,headers:e});return n.enabled?{enabled:n.enabled,smartWalletType:n.smart_wallet_type,configuredNetworks:n.configured_networks.map((e=>({chainId:e.chain_id,bundlerUrl:e.bundler_url,paymasterUrl:e.paymaster_url,paymasterContext:Ps(e.paymaster_url,e.paymaster_context)})))}:{enabled:n.enabled}}catch(e){throw I(e)}}async getServerConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let n=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl,headers:e}),r=n.telegram_auth_config?{botId:n.telegram_auth_config.bot_id,botName:n.telegram_auth_config.bot_name,linkEnabled:n.telegram_auth_config.link_enabled,seamlessAuthEnabled:n.telegram_auth_config.seamless_auth_enabled}:void 0,a=n.funding_config?{methods:n.funding_config.methods,options:n.funding_config.options,defaultRecommendedAmount:n.funding_config.default_recommended_amount,defaultRecommendedCurrency:n.funding_config.default_recommended_currency,promptFundingOnWalletCreation:n.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:n.funding_config.cross_chain_bridging_enabled}:void 0;return{id:n.id,name:n.name,verificationKey:n.verification_key,logoUrl:n.logo_url||void 0,accentColor:n.accent_color||void 0,showWalletLoginFirst:n.show_wallet_login_first,allowlistConfig:{errorTitle:n.allowlist_config.error_title,errorDetail:n.allowlist_config.error_detail,errorCtaText:n.allowlist_config.cta_text,errorCtaLink:n.allowlist_config.cta_link},walletAuth:n.wallet_auth,solanaWalletAuth:n.solana_wallet_auth,emailAuth:n.email_auth,smsAuth:n.sms_auth,googleOAuth:n.google_oauth,twitterOAuth:n.twitter_oauth,discordOAuth:n.discord_oauth,githubOAuth:n.github_oauth,spotifyOAuth:n.spotify_oauth,instagramOAuth:n.instagram_oauth,tiktokOAuth:n.tiktok_oauth,linkedinOAuth:n.linkedin_oauth,appleOAuth:n.apple_oauth,farcasterAuth:n.farcaster_auth,passkeyAuth:n.passkey_auth,passkeysForSignupEnabled:n.passkeys_for_signup_enabled,telegramAuth:n.telegram_auth,disablePlusEmails:n.disable_plus_emails,termsAndConditionsUrl:n.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:n.embedded_wallet_config?.create_on_login,userOwnedRecoveryOptions:n.embedded_wallet_config.user_owned_recovery_options,requireUserOwnedRecoveryOnCreate:n.embedded_wallet_config.require_user_owned_recovery_on_create},privacyPolicyUrl:n.privacy_policy_url,requireUsersAcceptTerms:n.require_users_accept_terms,customApiUrl:n.custom_api_url,walletConnectCloudProjectId:n.wallet_connect_cloud_project_id,fiatOnRampEnabled:n.fiat_on_ramp_enabled,captchaEnabled:n.captcha_enabled,captchaSiteKey:n.captcha_site_key,createdAt:new Date(1e3*n.created_at),updatedAt:new Date(1e3*n.updated_at),mfaMethods:n.mfa_methods,enforceWalletUis:n.enforce_wallet_uis,legacyWalletUiConfig:n.legacy_wallet_ui_config,telegramAuthConfiguration:r,fundingConfig:a}}catch(e){throw I(e)}}async getUsdTokenPrice(e){try{return(await this.api.get(`/api/v1/token_price?chainId=${e.id}&tokenSymbol=${e.nativeCurrency.symbol}`)).usd}catch(t){return void console.error(`Unable to fetch token price for chain with id ${e.id}`)}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch(e){return void console.error("Unable to fetch token price for SOL")}}async getSplTokenMetadata({mintAddress:e,cluster:t}){try{return await this.api.get(`/api/v1/spl_token_info?mint_address=${e}&cluster=${t}`)}catch(n){return void console.error(`Unable to fetch token metadata for ${t}:${e}`)}}async requestFarcasterSignerStatus(e){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:e})}catch(e){throw console.error("Unable to fetch Farcaster signer status"),e}}async forkSession(){return await this.session.forkSession()}async generateSiweNonce({address:e,captchaToken:t}){try{return(await this.api.post(xe,{address:e,token:t})).nonce}catch(e){throw I(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i}){return await this.api.post(Se,{message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i})}async linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a}){return await this.api.post(Re,{message:e,signature:t,chainId:n,walletClientType:r,connectorType:a})}async linkSmartWallet({message:e,signature:t,smartWalletType:n}){try{let r=await this.api.post(Oe,{message:e,signature:t,smart_wallet_type:n});return rr(r)}catch(e){throw I(e)}}async linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a}){try{let i=await this.linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a});return rr(i)}catch(e){throw I(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(We,{address:e,token:t})).nonce}catch(e){throw I(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,mode:a}){return await this.api.post(Me,{message:e,signature:t,walletClientType:n,connectorType:r,mode:a})}async sendAccountTransferRequest({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:s}){try{let l,c;switch(n){case"email":l=Be,c={nonce:e,email:t};break;case"sms":l=Fe,c={nonce:e,phoneNumber:t};break;case"siwe":if(l=Ue,!r)throw Error("Wallet parameters must be defined");c={nonce:e,address:t,...r};break;case"farcaster":l=De,c={nonce:e,farcaster_id:t,farcaster_embedded_address:o};break;case"telegram":l=Le,c={nonce:e,telegram_auth_result:a,telegram_web_app_data:i};break;case"custom":case"guest":case"passkey":throw Error("Invalid transfer account type");default:l=Pe,c={nonce:e,userInfo:s}}let d=await this.api.post(l,c);return await this.getAuthenticatedUser()??rr(d)}catch(e){throw I(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r}){return await this.api.post(ze,{message:e,signature:t,walletClientType:n,connectorType:r})}async linkWithSiws({message:e,signature:t,walletClientType:n,connectorType:r}){try{let a=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r});return rr(a)}catch(e){throw I(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(He);return this.session.updateIdentityToken(e.identity_token),rr(e.user)}catch(e){throw I(e)}}async scanTransaction(e){try{return await this.api.post(Ve,e)}catch(e){throw I(e)}}constructor({apiUrl:e=lr,appId:t,appClientId:n,timeout:r=cr}){Object.defineProperty(this,$s,{value:Gs}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==lr&&e.startsWith("https://privy."),this.timeout=r,this.appId=t,this.appClientId=n,this.clientAnalyticsId=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}(this,$s)[$s](),Hs||(Hs=new zs),this.session=Hs,this.api=this.generateApi(),this.session.client=this}}function Gs(){if("undefined"==typeof window)return null;try{let e=Xr.get(dr);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=Aa();try{return Xr.put(dr,e),e}catch(t){return e}}const qs=e=>{let{enabled:n,siteKey:r,appId:a,setError:s,setToken:l,setExecuting:c,ref:d}=st(),[,h]=i((()=>r?.split("t:")||[]),[r]);if(o((()=>d.current?.remove),[]),!n)return null;if(!h)throw Error("Unsupported captcha site key");/*#__PURE__*/return t("div",{className:"hidden h-0 w-0",children:/*#__PURE__*/t(qa,{...e,ref:d,siteKey:h,options:{action:a,size:"invisible",...e.delayedExecution?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{e.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{e.onError?.(),s("Captcha failed"),c(!1)},onSuccess:t=>{e.onSuccess?.(t),l(t),c(!1)},onExpire:()=>{e.onExpire?.();try{d.current?.reset(),s(void 0),l(void 0)}catch(e){s("expired_and_failed_reset")}}})})};function Ks(e){aa("configureMfa",e)}const Ys=/*#__PURE__*/Ka.span.withConfig({displayName:"CircleBackground",componentId:"sc-c9f33cd-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";background-color:",";border-radius:50%;display:inline-block;box-sizing:border-box;}"],(e=>e.color??"var(--privy-color-accent)"),(e=>e.color??"var(--privy-color-accent)"));let Zs=/*#__PURE__*/Ka.div.withConfig({displayName:"StackedContainer",componentId:"sc-f7e7d474-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]);const Js=/*#__PURE__*/Ka.div.withConfig({displayName:"Grow",componentId:"sc-5f5b688-0"})(["text-align:left;flex-grow:1;"]),Qs=/*#__PURE__*/Ka.div.withConfig({displayName:"AlignBottom",componentId:"sc-5f5b688-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),Xs=/*#__PURE__*/Ka.div.withConfig({displayName:"LoginMethodContainer",componentId:"sc-5f5b688-2"})(["display:flex;flex-direction:column;gap:12px;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]),el=/*#__PURE__*/Ka(Xs).withConfig({displayName:"LoginMethodContainerWithScrollShadows",componentId:"sc-5f5b688-3"})([""," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;max-height:400;overflow-y:'scroll';padding:2;"],(e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0));let tl=/*#__PURE__*/Ya(["&&{width:100%;font-size:16px;line-height:24px;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-mdlg);transition:background-color 200ms ease;cursor:pointer;&:hover{background-color:var(--privy-color-background-2);}&:disabled{cursor:pointer;background-color:var(--privy-color-background-2);}svg{height:24px;max-height:24px;max-width:24px;}}"]);const nl=/*#__PURE__*/Ka.div.withConfig({displayName:"Subtitle",componentId:"sc-5f5b688-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),rl=/*#__PURE__*/Ka.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-5f5b688-5"})(["",""],tl),al=/*#__PURE__*/Ka.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-5f5b688-6"})(["",""],tl),il=/*#__PURE__*/Ka.div.withConfig({displayName:"Hide",componentId:"sc-5f5b688-7"})(["width:100%;height:100%;min-height:inherit;display:flex;flex-direction:column;",""],(e=>e.$if?"display: none;":"")),ol=/*#__PURE__*/Ka.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-5f5b688-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),sl=/*#__PURE__*/Ka.div.withConfig({displayName:"Header",componentId:"sc-5f5b688-9"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-bottom:32px;gap:12px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]);let ll=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-a3e74b9e-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;margin-top:24px;"]),cl=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-a3e74b9e-1"})(["display:flex;flex-direction:column;gap:8px;"]);const dl=/*#__PURE__*/Ka.span.withConfig({displayName:"CircleBorder",componentId:"sc-9056b8b8-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";border-bottom-color:transparent;border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1.2s linear infinite;transition:border-color 800ms;border-bottom-color:",";}"],(e=>e.color??"var(--privy-color-accent)"),(e=>e.color??"var(--privy-color-accent)"));function hl(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...n,children:[/*#__PURE__*/t("circle",{cx:"12",cy:"12",r:"10"}),/*#__PURE__*/t("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),/*#__PURE__*/t("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})}const ul=({onTransfer:e,isTransferring:n,transferSuccess:r})=>/*#__PURE__*/t(ct,{...r?{success:!0,children:"Success!"}:{warn:!0,loading:n,onClick:e,children:"Transfer and delete account"}}),pl=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-aa2e65ff-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;width:100%;padding-bottom:16px;"]),ml=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-aa2e65ff-1"})(["display:flex;flex-direction:column;&& p{font-size:14px;}width:100%;gap:16px;"]),yl=/*#__PURE__*/Ka.div.withConfig({displayName:"DisclosedAccountContainer",componentId:"sc-aa2e65ff-2"})(["display:flex;cursor:pointer;align-items:center;width:100%;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-md);padding:8px 10px;font-size:14px;font-weight:500;gap:8px;"]),gl=/*#__PURE__*/Ka(ei).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-aa2e65ff-3"})(["position:relative;width:",";height:",";color:var(--privy-color-foreground-3);margin-left:auto;"],(e=>`${e.iconSize}px`),(e=>`${e.iconSize}px`)),fl=/*#__PURE__*/Ka(ti).withConfig({displayName:"StyledCopyIcon",componentId:"sc-aa2e65ff-4"})(["position:relative;width:15px;height:15px;color:var(--privy-color-foreground-3);margin-left:auto;"]),wl=/*#__PURE__*/Ka.ol.withConfig({displayName:"ListContainer",componentId:"sc-aa2e65ff-5"})(["display:flex;flex-direction:column;font-size:14px;width:100%;text-align:left;"]),vl=/*#__PURE__*/Ka.li.withConfig({displayName:"ListItem",componentId:"sc-aa2e65ff-6"})(["font-size:14px;list-style-type:auto;list-style-position:outside;margin-left:1rem;margin-bottom:0.5rem;&:last-child{margin-bottom:0;}"]),Cl=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleContainer",componentId:"sc-aa2e65ff-7"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]);let El=()=>/*#__PURE__*/t(Cl,{children:/*#__PURE__*/t(gl,{iconSize:60})});const Tl=({address:r,onClose:a,onRetry:i,onTransfer:o,isTransferring:s,transferSuccess:l})=>{let{defaultChain:c}=pr(),d=c.blockExplorers?.default.url??"https://etherscan.io";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:a,backFn:i}),/*#__PURE__*/e(pl,{children:[/*#__PURE__*/t(El,{}),/*#__PURE__*/e(ml,{children:[/*#__PURE__*/t("h3",{children:"Check account assets before transferring"}),/*#__PURE__*/t("p",{children:"Before transferring, ensure there are no assets in the other account. Assets in that account will not transfer automatically and may be lost."}),/*#__PURE__*/e(wl,{children:[/*#__PURE__*/t("p",{children:" To check your balance, you can:"}),/*#__PURE__*/t(vl,{children:"Log out and log back into the other account, or "}),/*#__PURE__*/e(vl,{children:["Copy your wallet address and use a"," ",/*#__PURE__*/t("u",{children:/*#__PURE__*/t("a",{target:"_blank",href:d,children:"block explorer"})})," ","to see if the account holds any assets."]})]}),/*#__PURE__*/e(yl,{onClick:()=>navigator.clipboard.writeText(r).catch(console.error),children:[/*#__PURE__*/t(Xa,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),/*#__PURE__*/t(dt,{address:r,showCopyIcon:!1}),/*#__PURE__*/t(fl,{})]}),/*#__PURE__*/t(ul,{onTransfer:o,isTransferring:s,transferSuccess:l})]})]}),/*#__PURE__*/t(ht,{})]})},bl=({onClose:r,onContinue:a,onInfo:i,onTransfer:o,transferSuccess:s,isTransferring:l,data:c})=>{if(!c?.accountTransfer?.linkMethod||!c?.accountTransfer?.displayName)return;let d={method:c?.accountTransfer?.linkMethod,handle:c?.accountTransfer?.displayName,disclosedAccount:c?.accountTransfer?.embeddedWalletAddress?{type:"wallet",handle:c?.accountTransfer?.embeddedWalletAddress}:void 0};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{closeable:!0}),/*#__PURE__*/e(pl,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(dl,{color:"var(--privy-color-error)"}),/*#__PURE__*/t(Qa,{height:38,width:38,stroke:"var(--privy-color-error)"})]})}),/*#__PURE__*/e(ml,{children:[/*#__PURE__*/e("h3",{children:[function(e){switch(e){case"sms":return"Phone number";case"email":return"Email address";case"siwe":return"Wallet address";case"linkedin":return"LinkedIn profile";case"google":case"apple":case"discord":case"github":case"instagram":case"spotify":case"tiktok":case"twitter":case"telegram":case"farcaster":return`${Oo(e.replace("_oauth",""))} profile`;default:return e}}(d.method)," is associated with another account"]}),/*#__PURE__*/e("p",{children:["Do you want to transfer",/*#__PURE__*/t("b",{children:d.handle?` ${d.handle}`:""})," to this account instead? This will delete your other account."]}),/*#__PURE__*/t(Al,{onClick:i,disclosedAccount:d.disclosedAccount})]}),/*#__PURE__*/e(ml,{style:{gap:12,marginTop:12},children:[c?.accountTransfer?.embeddedWalletAddress?/*#__PURE__*/t(ct,{onClick:a,children:"Continue"}):/*#__PURE__*/t(ul,{onTransfer:o,transferSuccess:s,isTransferring:l}),/*#__PURE__*/t(ut,{onClick:r,children:"No thanks"})]})]}),/*#__PURE__*/t(ht,{})]})};function Al({disclosedAccount:n,onClick:r}){return n?/*#__PURE__*/e(yl,{onClick:r,children:[/*#__PURE__*/t(Xa,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),/*#__PURE__*/t(dt,{address:n.handle,showCopyIcon:!1}),/*#__PURE__*/t(hl,{width:15,height:15,color:"var(--privy-color-foreground-3)",style:{marginLeft:"auto"}})]}):null}const _l=/*#__PURE__*/Ka.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a63b1990-0"})(["display:flex;flex-direction:column;align-items:center;padding:0px 0px 30px;@media (max-width:440px){padding:10px 10px 20px;}"]),kl=/*#__PURE__*/Ka.div.withConfig({displayName:"Title",componentId:"sc-a63b1990-1"})(["font-size:18px;line-height:30px;text-align:center;font-weight:600;margin-bottom:10px;"]),Il=/*#__PURE__*/Ka.div.withConfig({displayName:"SubTitle",componentId:"sc-a63b1990-2"})(["font-size:0.875rem;text-align:center;"]),Nl=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-a63b1990-3"})(["display:flex;flex-direction:column;align-items:center;gap:10px;flex-grow:1;padding:20px 0;@media (max-width:440px){padding:10px 10px 20px;}"]),xl=/*#__PURE__*/Ka.div.withConfig({displayName:"List",componentId:"sc-a63b1990-4"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.75rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),Sl=/*#__PURE__*/Ka.div.withConfig({displayName:"ListItemIcon",componentId:"sc-a63b1990-5"})(["width:25px;display:flex;align-items:center;justify-content:flex-start;> svg{z-index:2;height:25px !important;width:25px !important;color:var(--privy-color-accent);}"]),Rl=/*#__PURE__*/Ka.div.withConfig({displayName:"ListItem",componentId:"sc-a63b1990-6"})(["display:flex;align-items:center;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;"]),Ol=/*#__PURE__*/Ka.div.withConfig({displayName:"BottomSection",componentId:"sc-a63b1990-7"})(["display:flex;flex-direction:column;gap:10px;padding-top:20px;"]),Wl=/*#__PURE__*/Ka.div.withConfig({displayName:"MethodList",componentId:"sc-a63b1990-8"})(["display:flex;flex-direction:column;align-items:stretch;gap:1rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),Ml=/*#__PURE__*/Ka.div.withConfig({displayName:"MethodListItem",componentId:"sc-a63b1990-9"})(["display:flex;gap:5px;width:100%;position:relative;"]),Pl=/*#__PURE__*/Ka.button.withConfig({displayName:"RemoveMethodButton",componentId:"sc-a63b1990-10"})(["&&{background-color:transparent;color:var(--privy-color-foreground-3);padding:0 0.75rem;display:flex;align-items:center;height:100%;> svg{z-index:2;height:20px !important;width:20px !important;}}&&:hover{color:var(--privy-color-error);}"]),Ll=/*#__PURE__*/Ka.div.withConfig({displayName:"MethodText",componentId:"sc-a63b1990-11"})(["display:flex;align-items:center;gap:0.5rem;> svg{z-index:2;height:20px !important;width:20px !important;}"]),Dl=/*#__PURE__*/Ka.div.withConfig({displayName:"ExtraText",componentId:"sc-a63b1990-12"})(["display:flex;align-items:center;gap:6px;font-weight:400 !important;color:",";> svg{z-index:2;height:18px !important;width:18px !important;display:flex !important;align-items:flex-end;}"],(e=>e.isAccent?"var(--privy-color-accent)":"var(--privy-color-foreground-3)")),Ul=/*#__PURE__*/Ka.div.withConfig({displayName:"SmsInsecureText",componentId:"sc-a63b1990-13"})(["width:100%;display:flex;justify-content:space-between;"]),Fl=/*#__PURE__*/Ka.p.withConfig({displayName:"TermsText",componentId:"sc-a63b1990-14"})(["text-align:left;width:100%;color:var(--privy-color-foreground-3) !important;"]),Bl=/*#__PURE__*/Ka.button.withConfig({displayName:"PrimaryTextButton",componentId:"sc-a63b1990-15"})(["display:flex;flex-direction:row;align-items:center;justify-content:center;user-select:none;&{width:100%;cursor:pointer;border-radius:var(--privy-border-radius-md);font-size:0.875rem;line-height:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{color:",";background-color:transparent;padding:0.5rem 0px;}&:hover{text-decoration:underline;}"],(e=>"dark"===e.theme?"var(--privy-color-foreground-2)":"var(--privy-color-accent)")),zl=/*#__PURE__*/Ka.div.withConfig({displayName:"IconWrapper",componentId:"sc-a63b1990-16"})(["display:flex;align-items:center;justify-content:center;color:var(--privy-color-accent);width:100%;> svg{z-index:2;width:3rem;height:3rem;}"]),Hl=/*#__PURE__*/Ka.div.withConfig({displayName:"ErrorMessage",componentId:"sc-a63b1990-17"})(["color:var(--privy-color-error);"]),Vl=({termsAndConditionsUrl:r,privacyPolicyUrl:a,onAccept:i,onDecline:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{closeable:!1}),/*#__PURE__*/t(ri,{width:56,height:56,fill:"var(--privy-color-accent)",style:{margin:"auto"}}),/*#__PURE__*/t(kl,{style:{marginTop:24},children:"One last step"}),/*#__PURE__*/t(Il,{children:"By signing up, you agree to our terms and privacy policy."}),/*#__PURE__*/e(Xs,{style:{marginTop:24},children:[r&&/*#__PURE__*/e(al,{target:"_blank",href:r,children:["View Terms ",/*#__PURE__*/t(ni,{style:{marginLeft:"auto"}})]}),a&&/*#__PURE__*/e(al,{target:"_blank",href:a,children:["View Privacy Policy ",/*#__PURE__*/t(ni,{style:{marginLeft:"auto"}})]})]}),/*#__PURE__*/e($l,{style:{marginTop:24},children:[/*#__PURE__*/t(ut,{onClick:o,children:"No thanks"}),/*#__PURE__*/t(ct,{onClick:i,children:"Accept"})]}),/*#__PURE__*/t(ht,{})]});let $l=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-d601b243-0"})(["display:flex;gap:10px;"]);const jl=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...n,children:/*#__PURE__*/t("path",{fillRule:"evenodd",d:"M12 1.5a5.25 5.25 0 00-5.25 5.25v3a3 3 0 00-3 3v6.75a3 3 0 003 3h10.5a3 3 0 003-3v-6.75a3 3 0 00-3-3v-3c0-2.9-2.35-5.25-5.25-5.25zm3.75 8.25v-3a3.75 3.75 0 10-7.5 0v3h7.5z",clipRule:"evenodd"})});let Gl=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-ed4ecf-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),ql=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-ed4ecf-1"})(["display:flex;flex-direction:column;gap:8px;"]);const Kl=({title:r,description:a,children:i,...o})=>
2
+ /*#__PURE__*/t(Jl,{...o,children:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("h3",{children:r}),"string"==typeof a?/*#__PURE__*/t("p",{children:a}):a,i]})}),Yl=/*#__PURE__*/Ka(Kl).withConfig({displayName:"PaddedScreenHeader",componentId:"sc-523a75d6-0"})(["margin-bottom:24px;"]),Zl=({title:n,description:r,icon:a,children:i,...o})=>/*#__PURE__*/e(Ql,{...o,children:[a||null,/*#__PURE__*/t("h3",{children:n}),r&&"string"==typeof r?/*#__PURE__*/t("p",{children:r}):r,i]});let Jl=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledSection",componentId:"sc-523a75d6-1"})(["display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;text-align:left;gap:8px;width:100%;margin-bottom:24px;&& h3{font-size:17px;color:var(--privy-color-foreground);}&& p{color:var(--privy-color-foreground-2);font-size:14px;}"]),Ql=/*#__PURE__*/Ka(Jl).withConfig({displayName:"CenteredStyledSection",componentId:"sc-523a75d6-2"})(["align-items:center;text-align:center;gap:16px;h3{margin-bottom:24px;}"]),Xl=Array(6).fill("");var ec,tc,nc=((ec=nc||{})[ec.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",ec[ec.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",ec),rc=((tc=rc||{})[tc.EMAIL=0]="EMAIL",tc[tc.SMS=1]="SMS",tc);let ac=/*#__PURE__*/Ka.div.withConfig({displayName:"PasswordlessCodeContainer",componentId:"sc-1c4b718a-0"})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:center;margin:auto;gap:16px;flex-grow:1;"]),ic=/*#__PURE__*/Ka.div.withConfig({displayName:"CodeInput",componentId:"sc-1c4b718a-1"})(["display:flex;flex-direction:column;width:100%;gap:8px;> div:last-child{display:flex;justify-content:center;gap:0.5rem;width:100%;border-radius:var(--privy-border-radius-md);> input{border:1px solid var(--privy-color-foreground-4);background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);padding:8px 10px;height:58px;width:46px;text-align:center;font-size:18px;}> input:focus{border:1px solid var(--privy-color-accent);}> input:invalid{border:1px solid var(--privy-color-error);}> input.success{border:1px solid var(--privy-color-success);}> input.fail{border:1px solid var(--privy-color-error);animation:shake 180ms;animation-iteration-count:2;}}@keyframes shake{0%{transform:translate(1px,0px);}33%{transform:translate(-1px,0px);}67%{transform:translate(-1px,0px);}100%{transform:translate(1px,0px);}}"]),oc=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-1c4b718a-2"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-end;width:100%;"],(e=>e.$success?"var(--privy-color-success)":e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),sc=/*#__PURE__*/Ka.div.withConfig({displayName:"HelpText",componentId:"sc-1c4b718a-3"})(["font-size:13px;color:var(--privy-color-foreground);display:flex;gap:8px;align-items:center;width:100%;margin-top:16px;padding-bottom:32px;"]),lc=/*#__PURE__*/Ka.div.withConfig({displayName:"ResendButtonContainer",componentId:"sc-1c4b718a-4"})(["color:var(--privy-color-accent);padding:2px 0;> button{text-decoration:underline;}"]),cc=/*#__PURE__*/Ka.div.withConfig({displayName:"Badge",componentId:"sc-1c4b718a-5"})(["display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-sm);padding:2px 8px;gap:4px;background:var(--privy-color-background-2);color:var(--privy-color-foreground-2);"]),dc=/*#__PURE__*/Ka.span.withConfig({displayName:"BoldWrappingSpan",componentId:"sc-1c4b718a-6"})(["font-weight:500;word-break:break-all;"]);const hc=({icon:r})=>/*#__PURE__*/t(n,{children:/*#__PURE__*/t(uc,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{}),"string"==typeof r?
3
3
  /*#__PURE__*/t("span",{style:{background:`url('${r}')`,height:"38px",width:"38px",borderRadius:"6px",margin:"auto",backgroundSize:"cover"}}):r?/*#__PURE__*/t(r,{style:{width:"38px",height:"38px"}}):
4
- /*#__PURE__*/t("span",{})]})})});let Cc=/*#__PURE__*/ii.div.withConfig({displayName:"StackedContainer",componentId:"sc-26c1d9b9-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]);let Ec=/*#__PURE__*/ii.div.withConfig({displayName:"CaptchaContainer",componentId:"sc-9afcf974-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Tc=({chainType:n,withPadding:r})=>{let a="";return a="ethereum-only"===n||"ethereum-and-solana"===n?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/t(ml,{$withPadding:r,children:/*#__PURE__*/e(yl,{children:[/*#__PURE__*/t(li,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/t("h3",{children:"No wallets available"}),/*#__PURE__*/e("p",{children:["Please download an external wallet provider, like ",a,"."]})]})},"empty-wallet-state")},bc=({icon:e,name:n})=>"string"==typeof e?/*#__PURE__*/t("img",{alt:`${n||"wallet"} logo`,src:e,style:{height:24,width:24,borderRadius:4}}):void 0===e?/*#__PURE__*/t(di,{}):e?/*#__PURE__*/t(e,{}):null;function Ac(e){let t=e.toLowerCase();return!!window?.webkit?.messageHandlers?.ReactNativeWebView||!!window?.ReactNativeWebView||["fbav","fban","instagram","snapchat","linkedinapp"].some((e=>t.includes(e)))}const _c=({provider:n,displayName:r,logo:a,connectOnly:i,connector:o})=>{let{navigate:s,setModalData:l}=Tr(),{connectWallet:c}=N(),d=It(),h="wallet_connect_v2"===o.connectorType?n:o.walletClientType,u=window.matchMedia("(display-mode: standalone)").matches,p=Ps(o);/*#__PURE__*/return e(kc,{onClick:p?()=>{p.isInstalled||"solana"===o.chainType&&"isInstalled"in o&&o.isInstalled?(c(o,h),s(i?br.AWAITING_CONNECT_ONLY_CONNECTION:br.AWAITING_CONNECTION)):y?(l({installWalletModalData:{walletConfig:p,chainType:o.chainType,connectOnly:i}}),s(br.WALLET_INTERSTITIAL_SCREEN)):(l({installWalletModalData:{walletConfig:p,chainType:o.chainType,connectOnly:i}}),s(br.INSTALL_WALLET_SCREEN))}:"coinbase_wallet"!==o.connectorType||"eoaOnly"!==o.connectionOptions||!y||u||Nt()?()=>{(!Ac(window.navigator.userAgent)||event?.isTrusted)&&(c(o,h),s(i?br.AWAITING_CONNECT_ONLY_CONNECTION:br.AWAITING_CONNECTION))}:()=>{window.location.href=`https://go.cb-w.com/dapp?cb_url=${encodeURI(window.location.href)}`},children:[/*#__PURE__*/t(bc,{icon:xt(n,o.connectorType,o.walletClientType)??a,name:o.walletClientType}),/*#__PURE__*/t("span",{children:St(n,o.connectorType,o.walletClientType)||r||o.walletClientType}),/*#__PURE__*/e(Nc,{id:"chip-container",children:[d?.walletClientType===h&&d?.chainType===o.chainType?/*#__PURE__*/t(Ic,{color:"gray",children:"Recent"}):/*#__PURE__*/t("span",{id:"connect-text",children:"Connect"}),"solana"===o.chainType&&/*#__PURE__*/t(Ic,{color:"gray",children:"Solana"})]})]})};let kc=/*#__PURE__*/ii(hl).withConfig({displayName:"ConnectWalletButton",componentId:"sc-820f3381-0"})(["> #chip-container > #connect-text{font-weight:500;color:var(--privy-color-accent);opacity:0;transition:opacity 0.1s ease-out;}:hover > #chip-container > #connect-text{opacity:1;}@media (max-width:440px){> #chip-container > #connect-text{display:none;}}"]),Ic=/*#__PURE__*/ii(Rt).withConfig({displayName:"StyledChip",componentId:"sc-820f3381-1"})(["margin-left:auto;"]),Nc=/*#__PURE__*/ii.div.withConfig({displayName:"ChipContainer",componentId:"sc-820f3381-2"})(["display:flex;flex-wrap:wrap;gap:8px;margin-left:auto;"]);const xc=["coinbase_wallet"];let Sc=["metamask","okx_wallet","rainbow","uniswap","bybit_wallet","uniswap_extension","zerion","rabby_wallet","cryptocom"];const Rc=["safe"],Oc=["phantom","backpack","solflare","universal_profile"],Wc=({wallets:e})=>{let{app:r}=Tr();return 0===e.length?/*#__PURE__*/t(Tc,{chainType:r.appearance.walletChainType,withPadding:!0}):/*#__PURE__*/t(n,{children:e})},Lc=({walletList:e,walletChainType:n,connectors:r,connectOnly:a,ignore:i,walletConnectEnabled:o,forceWallet:s})=>{let l=[],c=[],d=[],h=r.filter((e=>"ethereum-only"===n?"ethereum"===e.chainType:"solana-only"!==n||"solana"===e.chainType)),u=h.find((e=>"wallet_connect_v2"===e.connectorType));for(let[r,p]of(s?[s.wallet]:e).entries()){if("detected_ethereum_wallets"===p||"detected_wallets"===p)for(let[e,n]of h.filter((({chainType:e,connectorType:t,walletClientType:n})=>"solana"!==e&&("uniswap_wallet_extension"===n||"uniswap_extension"===n?!i.includes("uniswap"):"crypto.com_wallet_extension"===n||"crypto.com_onchain"===n?!i.includes("cryptocom"):"injected"===t&&!i.includes(n)))).entries()){let{walletClientType:i,walletBranding:o,chainType:s}=n;("unknown"===i?c:l).push(/*#__PURE__*/t(_c,{connectOnly:a,provider:i,logo:o.icon,displayName:o.name,connector:n},`${r}-${p}-${i}-${s}-${e}`))}if("detected_solana_wallets"===p||"detected_wallets"===p)for(let[e,o]of h.filter((({chainType:e,walletClientType:t})=>{if("solana"===e)return"ethereum-only"!==n&&!i.includes(t)})).entries()){let{walletClientType:n,walletBranding:i,chainType:s}=o;("unknown"===n?c:l).push(/*#__PURE__*/t(_c,{connectOnly:a,provider:n,logo:i.icon,displayName:i.name,connector:o},`${r}-${p}-${n}-${s}-${e}`))}if(Oc.includes(p)){let e=h.find((e=>"injected"===e.connectorType&&e.walletClientType===p||e.connectorType===p));if(e&&l.push(/*#__PURE__*/t(_c,{connectOnly:a,provider:p,connector:e},`${r}-${p}`)),"solana-only"===n||"ethereum-and-solana"===n){let e=h.find((({chainType:e,walletClientType:t})=>"solana"===e&&t===p));e&&l.push(/*#__PURE__*/t(_c,{connectOnly:a,provider:p,connector:e},`${p}-solana`))}}else if(Sc.includes(p)){let e=h.find((e=>"uniswap"===p?"uniswap_wallet_extension"===e.walletClientType||"uniswap_extension"===e.walletClientType:"cryptocom"===p?"crypto.com_wallet_extension"===e.walletClientType||"crypto.com_onchain"===e.walletClientType:"injected"===e.connectorType&&e.walletClientType===p));if(o&&!e&&(e=u),e&&l.push(/*#__PURE__*/t(_c,{connectOnly:a,provider:p,connector:e,logo:"injected"===e.connectorType?e.walletBranding.icon:void 0,displayName:"injected"===e.connectorType?e.walletBranding.name:void 0},`${r}-${p}`)),"solana-only"===n||"ethereum-and-solana"===n){let e=h.find((({chainType:e,walletClientType:t})=>"solana"===e&&t===p));e&&l.push(/*#__PURE__*/t(_c,{connectOnly:a,provider:p,connector:e},`${p}-solana`))}}else if(xc.includes(p)){let e=h.find((({connectorType:e})=>e===p));e&&l.push(/*#__PURE__*/t(_c,{connectOnly:a,provider:p,connector:e},`${r}-${p}`))}else if(Rc.includes(p))u&&d.push(/*#__PURE__*/t(_c,{connectOnly:a,provider:p,connector:u},`${r}-${p}`));else if("wallet_connect"===p)u&&d.push(/*#__PURE__*/t(_c,{connectOnly:a,provider:p,connector:u},`${r}-${p}`));else if(p===s?.wallet){let n="ethereum"===s.chainType&&e.includes("detected_ethereum_wallets"),i="solana"===s.chainType&&e.includes("detected_solana_wallets");if(e.includes("detected_wallets")||n||i){let e=h.find((({walletClientType:e})=>e===p));e&&l.push(/*#__PURE__*/t(_c,{connectOnly:a,provider:p,displayName:e.walletBranding?.name,logo:e.walletBranding?.icon,connector:e},`${r}-${p}`))}}}return[...c,...l,...d]};let Pc=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-1346f57-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Mc=({name:e,logoUrl:n,size:r="38px"})=>"string"==typeof n?/*#__PURE__*/t("img",{src:n,alt:`${e??"Provider app"} logo`,style:{width:r,height:r,maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):
5
- /*#__PURE__*/t("span",{});let Uc=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-128f2a0d-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);let Dc=/*#__PURE__*/ii.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-b99bc0c0-0"})(["display:flex;gap:10px;"]),Fc=/*#__PURE__*/ii(zt).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-b99bc0c0-1"})(["margin-top:1.5rem;"]);let Bc=/*#__PURE__*/ii.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-8ff214d7-0"})(["display:flex;gap:10px;"]);const zc=()=>/*#__PURE__*/t(Hc,{children:/*#__PURE__*/e(Vc,{children:[/*#__PURE__*/t($c,{}),/*#__PURE__*/t(Gc,{})]})});let Hc=/*#__PURE__*/ii.div.withConfig({displayName:"LoadingContainer",componentId:"sc-85b54ede-0"})(["display:flex;justify-content:center;align-items:center;flex-grow:1;margin:12px;padding:16px;@media all and (display-mode:standalone){margin-bottom:30px;}"]),Vc=/*#__PURE__*/ii.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-85b54ede-1"})(["position:relative;height:140px;width:140px;opacity:1;animation:fadein 200ms ease;"]),$c=/*#__PURE__*/ii.div.withConfig({displayName:"CircleFixed",componentId:"sc-85b54ede-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;&&{border:4px solid var(--privy-color-accent-light);border-radius:50%;}"]),Gc=/*#__PURE__*/ii.div.withConfig({displayName:"CircleRotate",componentId:"sc-85b54ede-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:var(--privy-color-accent) transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]);const qc=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];class jc extends Error{constructor(e,t){super(t),this.type=e}}function Kc(e){let t=e.type;return"string"==typeof t&&qc.includes(t)}function Yc(e){return Kc(e)&&"wallet_not_on_device"===e.type}function Zc(e){return!!Kc(e)&&"mfa_timeout"===e.type}function Xc(e){return!!Kc(e)&&"missing_or_invalid_mfa"===e.type}function Qc(e){return!!Kc(e)&&"mfa_verification_max_attempts_reached"===e.type}function Jc(e){return!(!Kc(e)||!e.message.includes("code 429"))}function ed(e){return!!function(e){let t=e.type;return"string"==typeof t&&"client_error"===t}(e)&&"MFA canceled"===e.message}function td({isCreatingWallet:e,skipSplashScreen:t}){return e?br.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN:t?br.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN:br.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN}function nd({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:n,isResettingPassword:r,showAutomaticRecovery:a}){return a?br.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN:n||1===t.length?td({isCreatingWallet:"create"===e,skipSplashScreen:r}):br.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN}function rd(e){switch(e){case"user-passcode":return br.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN;case"google-drive":case"icloud":return br.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN;default:throw Error("Recovery method not supported")}}async function id({api:e,provider:t}){let n=Fo(),r=Bo(),a=await zo(n);try{return"icloud"===t?{url:(await e.post(Ve,{client_type:"web"})).url}:{url:(await e.post($e,{redirect_to:window.location.href,code_challenge:a,state_code:r})).url,codeVerifier:n,stateCode:r,provider:t}}catch(e){throw T(e)}}async function od({api:e,provider:t,stateCode:n,codeVerifier:r,authorizationCode:a}){if(!a||!n)throw new E("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===a)throw new E("User denied confirmation during OAuth flow");try{return(await e.post(Ge,{authorization_code:a,state_code:n,code_verifier:r,provider:t})).access_token}catch(e){let t=T(e);if(t.privyErrorCode)throw new E(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new E("Invalid code during oauth flow.",void 0,b.OAUTH_USER_DENIED);throw new E("Invalid code during OAuth flow.",void 0,b.UNKNOWN_AUTH_ERROR)}}let sd=/*#__PURE__*/ii.div.withConfig({displayName:"BottomSpacing",componentId:"sc-124dbb1c-0"})(["height:44px;"]);const ld=({children:n,theme:r})=>/*#__PURE__*/e(cd,{$theme:r,children:[/*#__PURE__*/t(ci,{width:"1.25rem",color:"dark"===r?"#FDE68A":"var(--privy-color-warn)"}),n]});let cd=/*#__PURE__*/ii.div.withConfig({displayName:"Container",componentId:"sc-97f152b3-0"})(["display:flex;gap:0.5rem;background-color:",";"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);}"],(e=>"dark"===e.$theme?"var(--privy-color-background-2)":"var(--privy-color-warn-light)"),(e=>"dark"===e.$theme?"color: #FDE68A;":""));function dd(n){let[r,a]=s(n.dimensions.width),[i,c]=s(void 0),d=l(null);o((()=>{if(d.current&&void 0===r){let{width:e}=d.current.getBoundingClientRect();a(e)}let e=getComputedStyle(document.documentElement);c({background:e.getPropertyValue("--privy-color-background"),background2:e.getPropertyValue("--privy-color-background-2"),foreground3:e.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:e.getPropertyValue("--privy-color-foreground-accent"),accent:e.getPropertyValue("--privy-color-accent"),accentDark:e.getPropertyValue("--privy-color-accent-dark"),success:e.getPropertyValue("--privy-color-success")})}),[]);let h="ethereum"===n.walletToExport.chainType&&!n.walletToExport.imported;/*#__PURE__*/return t("div",{ref:d,children:r&&
6
- /*#__PURE__*/e(ud,{children:[/*#__PURE__*/t("iframe",{style:{position:"absolute",zIndex:1},width:r,height:n.dimensions.height,allow:"clipboard-write self *",src:Gt(n.origin,`/apps/${n.appId}/embedded-wallets/export`,{client_id:n.appClientId,primaryAddress:n.primaryWallet.address,address:n.walletToExport.address,walletIndex:n.walletToExport.walletIndex,width:`${r}px`,caid:n.clientAnalyticsId,phrase_export:h,...i},{token:n.accessToken})}),/*#__PURE__*/t(pd,{children:"Loading..."}),h&&/*#__PURE__*/t(pd,{children:"Loading..."})]})})}let hd=/*#__PURE__*/ii.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-eaab13a9-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),ud=/*#__PURE__*/ii.div.withConfig({displayName:"ButtonContainer",componentId:"sc-eaab13a9-1"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),pd=/*#__PURE__*/ii.div.withConfig({displayName:"LoadingButton",componentId:"sc-eaab13a9-2"})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:16px;font-weight:500;border-radius:var(--privy-border-radius-md);background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);"]);function md(){let{getAccessToken:e}=_r(),{refreshSessionAndUser:t,createAnalyticsEvent:n,initializeWalletProxy:r}=N(),a=l(!1);return{createWallet:c((async({user:i,recoveryPassword:o})=>{let s=await e();if(!s)throw n({eventName:"embedded_wallet_creation_failed",payload:{error:"Missing access token for user."}}),Error("An error has occured, please login again.");try{n({eventName:"embedded_wallet_creation_started"});let e=await r(Rr);if(!e)throw Error("walletProxy does not exist.");let l=new Promise(((e,t)=>{setTimeout((()=>{t(Error("walletProxy.create timed out."))}),2e4)})),c=Sr(i);if(!await Promise.race([e.create({accessToken:s,recoveryPassword:o,recoveryMethod:o?"user-passcode":void 0,solanaAddress:c?.address}),l]))throw Error("walletProxy.create did not send a response.");let d=await t();if(!d)throw Error("Failed to refresh user.");let h=xr(d);if(!h)throw Error("Updated user is missing embedded wallet.");return n({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:h.address}}),a.current=!0,h}catch(i){if(a.current)return;throw n({eventName:"embedded_wallet_creation_failed",payload:{error:i.toString()}}),console.warn(i),i}}),[])}}let yd=/*#__PURE__*/ii.div.withConfig({displayName:"BottomSpacing",componentId:"sc-f34e977e-0"})(["height:44px;"]),gd=/*#__PURE__*/oi(["font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;text-align:left;transition:color 0.1s ease-in;"]);const fd=/*#__PURE__*/ii.span.withConfig({displayName:"StatusText",componentId:"sc-3f6866a9-0"})([""," transition:color 0.1s ease-in;color:",";text-transform:",";&[aria-hidden='true']{visibility:hidden;}"],gd,(({error:e})=>e?"var(--privy-color-error)":"var(--privy-color-foreground-3)"),(({error:e})=>e?"":"capitalize")),wd=/*#__PURE__*/ii.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-3f6866a9-1"})(["display:flex;flex-direction:column;justify-content:center;flex-grow:1;"]),vd=/*#__PURE__*/ii(wt).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-3f6866a9-2"})(["",""],(e=>e.hideAnimations&&/*#__PURE__*/oi(["&&{transition:none;}"])));let Cd=/*#__PURE__*/oi(["&&{width:100%;border-width:1px;border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);background:var(--privy-color-background);color:var(--privy-color-foreground);padding:12px;font-size:16px;font-style:normal;font-weight:300;line-height:22px;}"]);const Ed=/*#__PURE__*/ii.input.withConfig({displayName:"PasswordInput",componentId:"sc-3f6866a9-3"})([""," &::placeholder{color:var(--privy-color-foreground-3);font-style:italic;font-size:14px;}overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"],Cd),Td=/*#__PURE__*/ii.div.withConfig({displayName:"PasswordDisplay",componentId:"sc-3f6866a9-4"})(["",""],Cd),bd=/*#__PURE__*/ii.div.withConfig({displayName:"PasswordContainer",componentId:"sc-3f6866a9-5"})(["position:relative;width:100%;display:flex;align-items:center;justify-content:",";"],(({centered:e})=>e?"center":"space-between")),Ad=/*#__PURE__*/ii.div.withConfig({displayName:"Header",componentId:"sc-3f6866a9-6"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:32px 0;gap:4px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]),_d=/*#__PURE__*/ii.div.withConfig({displayName:"Details",componentId:"sc-3f6866a9-7"})(["display:flex;flex-direction:column;gap:10px;padding-bottom:1rem;"]),kd=/*#__PURE__*/ii.div.withConfig({displayName:"DetailItem",componentId:"sc-3f6866a9-8"})(["display:flex;text-align:left;align-items:center;gap:8px;max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;margin:0 8px;color:var(--privy-color-foreground-2);> :first-child{min-width:24px;}"]),Id=/*#__PURE__*/ii(Kt).withConfig({displayName:"ExportButton",componentId:"sc-3f6866a9-10"})(["display:flex;flex:1;gap:4px;justify-content:center;&&{background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);border-width:1px;}"]),Nd=/*#__PURE__*/ii.div.withConfig({displayName:"InputRightIcons",componentId:"sc-3f6866a9-11"})(["position:absolute;right:0.5rem;display:flex;flex-direction:row;justify-content:space-around;align-items:center;"]),xd=/*#__PURE__*/ii(ki).withConfig({displayName:"RegenerateIcon",componentId:"sc-3f6866a9-12"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),Sd=/*#__PURE__*/ii(Ni).withConfig({displayName:"HiddenIcon",componentId:"sc-3f6866a9-13"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),Rd=/*#__PURE__*/ii(Ii).withConfig({displayName:"ShownIcon",componentId:"sc-3f6866a9-14"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),Od=/*#__PURE__*/ii.progress.withConfig({displayName:"StrengthMeter",componentId:"sc-3f6866a9-15"})(["height:4px;width:100%;margin:8px 0;::-webkit-progress-bar{border-radius:8px;background:var(--privy-color-foreground-4);}::-webkit-progress-value{border-radius:8px;transition:all 0.1s ease-out;background:",";}"],(({label:e})=>("Strong"===e?"#78dca6":"Medium"===e&&"var(--privy-color-warn)")||"var(--privy-color-error)")),Wd=({buttonHideAnimations:r,buttonLoading:a,password:i,onSubmit:l,onBack:c})=>{let[d,h]=s(!0),[u,p]=s(!1),[m,y]=s(""),g=i===m;return o((()=>{m&&!u&&p(!0)}),[m]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{closeable:!1,backFn:c}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(wd,{children:[/*#__PURE__*/e(Ad,{children:[/*#__PURE__*/t(ci,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please re-enter your password below to continue."})]}),/*#__PURE__*/e(bd,{children:[/*#__PURE__*/t(Ed,{value:m,onChange:e=>y(e.target.value),onKeyUp:e=>{"Enter"===e.key&&l()},onBlur:()=>p(!0),placeholder:"confirm your password",type:d?"password":"text",style:{paddingRight:"2.3rem"}}),/*#__PURE__*/t(Nd,{style:{right:"0.75rem"},children:d?/*#__PURE__*/t(Sd,{onClick:()=>h(!1)}):/*#__PURE__*/t(Rd,{onClick:()=>h(!0)})})]}),
7
- /*#__PURE__*/t(fd,{"aria-hidden":!u||g,error:!0,children:"Passwords do not match"})]}),/*#__PURE__*/t(vd,{onClick:l,loading:a,disabled:!g,hideAnimations:r,children:"Continue"}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},Ld=({className:n,checked:r,color:a="var(--privy-color-accent)",...i})=>/*#__PURE__*/t("label",{children:/*#__PURE__*/e(Pd,{className:n,children:[/*#__PURE__*/t(Ud,{checked:r,...i}),/*#__PURE__*/t(Dd,{color:a,checked:r,children:/*#__PURE__*/t(Md,{viewBox:"0 0 24 24",children:/*#__PURE__*/t("polyline",{points:"20 6 9 17 4 12"})})})]})});let Pd=/*#__PURE__*/ii.div.withConfig({displayName:"CheckboxContainer",componentId:"sc-db51b935-1"})(["display:inline-block;vertical-align:middle;"]),Md=/*#__PURE__*/ii.svg.withConfig({displayName:"Icon",componentId:"sc-db51b935-2"})(["fill:none;stroke:white;stroke-width:3px;"]),Ud=/*#__PURE__*/ii.input.attrs({type:"checkbox"}).withConfig({displayName:"HiddenCheckbox",componentId:"sc-db51b935-3"})(["border:0;clip:rect(0 0 0 0);clippath:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px;"]),Dd=/*#__PURE__*/ii.div.withConfig({displayName:"StyledCheckbox",componentId:"sc-db51b935-4"})(["display:inline-block;width:18px;height:18px;transition:all 150ms;cursor:pointer;border-color:",";border-radius:3px;background:",";&&{border-width:1px;}",":focus + &{box-shadow:0 0 0 1px ",";}","{visibility:",";}"],(e=>e.color),(e=>e.checked?e.color:"var(--privy-color-background)"),Ud,(e=>e.color),Md,(e=>e.checked?"visible":"hidden"));const Fd=({buttonHideAnimations:r,buttonLoading:a,onSubmit:i,onBack:o,config:l})=>{let[c,d]=s(!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{closeable:!1,backFn:o}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(wd,{children:[/*#__PURE__*/e(Ad,{children:[/*#__PURE__*/t(ci,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-error)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm you have saved"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Losing access to your password means you will lose access to your account."})]}),/*#__PURE__*/t(_d,{children:/*#__PURE__*/e(kd,{style:{color:"var(--privy-color-error)",cursor:"pointer"},onClick:e=>{e.preventDefault(),d((e=>!e))},children:[/*#__PURE__*/t(Ld,{color:"var(--privy-color-error)",readOnly:!0,checked:c}),/*#__PURE__*/t(n,{children:"I understand that if I lose my password and device, I will lose access to my account and my assets."})]})})]}),/*#__PURE__*/e(Bd,{children:["user"===l.initiatedBy&&/*#__PURE__*/t(Et,{onClick:l.onCancel,disabled:a,children:"Cancel"}),/*#__PURE__*/t(vd,{onClick:i,loading:a,hideAnimations:r,disabled:!c,children:"Set Password"})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})};let Bd=/*#__PURE__*/ii.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-eb601350-0"})(["display:flex;gap:10px;"]),zd=/[a-z]/,Hd=/[A-Z]/,Vd=/[0-9]/,$d="!@#$%^&*()\\-_+.",Gd=`a-zA-Z0-9${$d}`,qd=RegExp(`[${$d}]`),jd=RegExp(`[${Gd}]`);const Kd=RegExp(`^[${Gd}]{6,}$`),Yd=()=>Ai.generatePassphrase(4,_i);function Zd(e){return e>.9?"Strong":e>.5?"Medium":"Weak"}function Xd(e=""){return(.3*function(e){if(e.length<8)return 0;let t=0;return zd.test(e)&&(t+=1),Hd.test(e)&&(t+=1),Vd.test(e)&&(t+=1),qd.test(e)&&(t+=1),Math.max(0,Math.min(1,t/3))}(e)+bi(e)/95)/2}const Qd=({buttonHideAnimations:r,buttonLoading:a,password:l="",config:c,isResettingPassword:d,onSubmit:h,onClose:u,onBack:p,onPasswordChange:m,onPasswordGenerate:y})=>{let[g,f]=s(!1),[w,v]=s(!1);o((()=>{l&&!w&&v(!0)}),[l]);let C=i((()=>w?6>(l?.length||0)?"Password must be at least 6 characters":Kd.test(l||"")?null:`Invalid characters used ( ${((e="")=>[...new Set(e.split("").filter((e=>!jd.test(e))).map((e=>e.replace(" ","SPACE"))))])(l).join(" ")} )`:null),[l,w]),E=i((()=>C?{value:0,label:"Weak"}:function(e=""){let t=Xd(e);return{value:t,label:Zd(t)}}(l)),[l,C]),T=i((()=>!l?.length||!!C),[C,l]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:u,closeable:"user"===c.initiatedBy,backFn:p}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(wd,{children:[/*#__PURE__*/e(Ad,{children:[/*#__PURE__*/t(xi,{height:48,width:48,stroke:"var(--privy-color-accent)"}),/*#__PURE__*/e("h3",{style:{color:"var(--privy-color-foreground)"},children:[d?"Reset":"Set"," your password"]}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Select a strong, memorable password to secure your account."})]}),/*#__PURE__*/e(bd,{children:[/*#__PURE__*/t(Ed,{value:l,onChange:e=>m(e.target.value),onKeyUp:e=>{"Enter"===e.key&&h()},placeholder:"enter or generate a strong password",type:g?"password":"text",style:{paddingRight:"3.8rem"}}),/*#__PURE__*/e(Nd,{style:{width:"3.5rem"},children:[g?/*#__PURE__*/t(Sd,{onClick:()=>f(!1)}):/*#__PURE__*/t(Rd,{onClick:()=>f(!0)}),/*#__PURE__*/t(xd,{onClick:y})]})]}),/*#__PURE__*/t(Od,{value:0===E.value?.01:E.value,label:E.label}),/*#__PURE__*/t(fd,{error:!!C,children:C||`Password Strength: ${w?E.label:"--"}`}),/*#__PURE__*/e(eh,{children:[/*#__PURE__*/t(Jd,{children:/*#__PURE__*/e(_d,{children:[/*#__PURE__*/e(kd,{children:[/*#__PURE__*/t(wi,{width:24,height:24,fill:"var(--privy-color-accent)"}),"This password is used to secure your account."]}),/*#__PURE__*/e(kd,{children:[/*#__PURE__*/t(wi,{width:24,height:24,fill:"var(--privy-color-accent)"}),"Use it to log in on a new environment, like another browser or device."]})]})}),/*#__PURE__*/t(vd,{onClick:h,loading:a,disabled:T,hideAnimations:r,children:"Continue"})]})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})};let Jd=/*#__PURE__*/ii(_d).withConfig({displayName:"DetailsContainer",componentId:"sc-7b3b7727-0"})(["flex:1;padding-top:1rem;"]),eh=/*#__PURE__*/ii.div.withConfig({displayName:"LowerContainer",componentId:"sc-7b3b7727-1"})(["display:flex;flex-direction:column;height:100%;"]);const th=({buttonHideAnimations:r,buttonLoading:a,appName:i,password:o,onSubmit:l,onBack:d})=>{let[h,u]=s(!1),[p,m]=s(!0),y=c((()=>{u(!0),o&&navigator.clipboard.writeText(o)}),[o]),g=c((()=>{let e=document.createElement("a"),t=i.toLowerCase().replace(/[^a-z\s]/g,"").replace(/\s/g,"-"),n=new Blob([nh(i,o)],{type:"text/plain"}),r=URL.createObjectURL(n);e.href=r,e.target="_blank",e.download=`${t}-privy-wallet-recovery.txt`,document.body.appendChild(e),e.click(),setTimeout((()=>{e.remove(),URL.revokeObjectURL(r)}),5e3)}),[o]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:d,closeable:!1}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(wd,{children:[/*#__PURE__*/e(Ad,{children:[/*#__PURE__*/t(ci,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Save your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"For your security, this password cannot be reset, so keep it somewhere safe."})]}),/*#__PURE__*/e(bd,{centered:!0,children:[/*#__PURE__*/t(Td,{children:p?"•".repeat(o.length):o}),/*#__PURE__*/t(Nd,{style:{right:"0.75rem"},children:p?/*#__PURE__*/t(Sd,{onClick:()=>m(!1)}):/*#__PURE__*/t(Rd,{onClick:()=>m(!0)})})]}),/*#__PURE__*/e("div",{style:{display:"flex",margin:"12px 0",gap:"12px"},children:[/*#__PURE__*/t(Id,{onClick:y,children:/*#__PURE__*/e(n,h?{children:[/*#__PURE__*/t(Ri,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copied"]}:{children:[/*#__PURE__*/t(Oi,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copy"]})}),/*#__PURE__*/e(Id,{onClick:g,children:[/*#__PURE__*/t(Si,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Download"]})]})]}),/*#__PURE__*/t(vd,{onClick:l,loading:a,hideAnimations:r,children:"Continue"}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})};let nh=(e,t)=>`Your wallet recovery password for ${e} is\n\n${t}\n\nYou will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;const rh=({error:r,onClose:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{closeable:!1}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Ht,r?{children:[/*#__PURE__*/t(vi,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(ac,{title:"Something went wrong",description:r})]}:{children:[/*#__PURE__*/t(wi,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(ac,{title:"Success"})]}),/*#__PURE__*/t(wt,{onClick:a,children:"Close"}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]});let ah=(e,t)=>{switch(e){case"creating":return"back"===t?e:"saving";case"saving":return"back"===t?"creating":"confirming";case"confirming":return"back"===t?"saving":"finalizing";case"finalizing":return"back"===t?"confirming":"done";default:return e}};const ih=({onSubmit:e,...n})=>{let{lastScreen:r,navigate:a}=Tr(),{send:i,state:s}=(()=>{let[e,t]=d(ah,"creating");return{send:t,state:e}})(),l=c((async()=>{"finalizing"===s&&await e(),i("next")}),[s,i,e]);o((()=>{let e;return"done"===s&&"automatic"===n.config.initiatedBy&&(e=setTimeout((()=>n.onClose?.()),kr)),()=>{e&&clearTimeout(e)}}),[s,n.config.initiatedBy,n.onClose]);let h=c((()=>{i("back")}),[i]),u=c((()=>{a(br.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN)}),[r,a]);return"creating"===s?/*#__PURE__*/t(Qd,{...n,onSubmit:l,onBack:r===br.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN?u:void 0}):"saving"===s?/*#__PURE__*/t(th,{...n,onSubmit:l,onBack:h}):"confirming"===s?/*#__PURE__*/t(Wd,{...n,onSubmit:l,onBack:h}):"finalizing"===s?/*#__PURE__*/t(Fd,{...n,onSubmit:l,onBack:h}):"done"===s?/*#__PURE__*/t(rh,{...n,onSubmit:l}):null};let oh="0x0000000000000000000000000000000000000000";const sh=({destinationCurrency:e,...t})=>({tradeType:"EXACT_OUTPUT",originCurrency:oh,destinationCurrency:e??oh,...t});let lh="https://api.relay.link",ch="https://api.testnets.relay.link";const dh=async({input:e,isTestnet:t})=>{let n=await fetch((t?ch:lh)+"/execute/swap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await n.json();if(!(n.ok||"string"==typeof r.message&&r.message.startsWith("Invalid address")))throw console.error("Relay error:",r),Error(r.message??"Error fetching quote from relay");return r},hh=e=>{let t=e.steps[0]?.items?.[0];if(t)return{from:t.data.from,to:t.data.to,value:Number(t.data.value),chainId:Number(t.data.chainId),data:t.data.data}};function uh({transactionHash:e,wallet:t,isTestnet:n,bridgingStatus:r,setBridgingStatus:a,onSuccess:i,onFailure:s}){o((()=>{if(e&&t&&r){if(["delayed","waiting","pending"].includes(r)){let t=setInterval((async()=>{try{let t=await async function({transactionHash:e,isTestnet:t}){let n=await fetch((t?ch:lh)+"/requests/v2?hash="+e),r=await n.json();if(!n.ok){if("message"in r&&"string"==typeof r.message)throw Error(r.message);throw Error("Error fetching request from relay")}return r.requests.at(0)?.status??"pending"}({transactionHash:e,isTestnet:n});a(t)}catch(e){console.error(e)}}),1e3);return()=>clearInterval(t)}"success"===r?i({transactionHash:e,wallet:t}):["refund","failure"].includes(r)&&s({error:new ph(e,n)})}}),[r,e,n,t])}class ph extends E{constructor(e,t){super("We were unable to complete the bridging transaction. Funds will be refunded on your wallet.",void 0,b.TRANSACTION_FAILURE),this.relayLink=t?`https://testnets.relay.link/transaction/${e}`:`https://relay.link/transaction/${e}`}}const mh=({error:r,backFn:a,onClick:i})=>{let{reset:o}=gt(),{app:s}=Tr(),l=((r,a)=>{let i=/*#__PURE__*/t(ci,{height:38,width:38,stroke:"var(--privy-color-error)"});if(r instanceof ph)return{title:"Transaction failed",detail:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("p",{children:r.message}),/*#__PURE__*/e("p",{children:["Check the"," ",/*#__PURE__*/t(fh,{href:r.relayLink,target:"_blank",children:"refund status"}),"."]})]}),ctaText:"Try again",icon:i};if(r instanceof E)switch(r.privyErrorCode){case b.CLIENT_REQUEST_TIMEOUT:return{title:"Timed out",detail:r.message,ctaText:"Try again",icon:i};case b.INSUFFICIENT_BALANCE:return{title:"Insufficient balance",detail:r.message,ctaText:"Try again",icon:i};case b.TRANSACTION_FAILURE:return{title:"Transaction failure",detail:r.message,ctaText:"Try again",icon:i};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i}}else{if(r instanceof jc&&"twilio_verification_failed"===r.type)return{title:"Something went wrong",detail:r.message,ctaText:"Try again",icon:/*#__PURE__*/t(fi,{height:38,width:38,stroke:"var(--privy-color-error)"})};if(!(r instanceof O))return r instanceof I&&r.status&&[400,422].includes(r.status)?{title:"Something went wrong",detail:r.message,ctaText:"Try again",icon:i}:{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i};switch(r.privyErrorCode){case b.INVALID_CAPTCHA:return{title:"Something went wrong",detail:"Please try again.",ctaText:"Try again",icon:i};case b.DISALLOWED_LOGIN_METHOD:return{title:"Not allowed",detail:r.message,ctaText:"Try another method",icon:i};case b.ALLOWLIST_REJECTED:return{title:a.errorTitle||"You don't have access to this app",detail:a.errorDetail||"Have you been invited?",ctaText:a.errorCtaText||"Try another account",icon:/*#__PURE__*/t(Jl,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})};case b.CAPTCHA_FAILURE:return{title:"Something went wrong",detail:"You did not pass CAPTCHA. Please try again.",ctaText:"Try again",icon:/*#__PURE__*/t("span",{})};case b.CAPTCHA_TIMEOUT:return{title:"Something went wrong",detail:"Something went wrong! Please try again later.",ctaText:"Try again",icon:/*#__PURE__*/t("span",{})};case b.LINKED_TO_ANOTHER_USER:return{title:"Authentication failed",detail:"This account has already been linked to another user.",ctaText:"Try again",icon:i};case b.NOT_SUPPORTED:return{title:"This region is not supported",detail:"SMS authentication from this region is not available",ctaText:"Try another method",icon:i};case b.TOO_MANY_REQUESTS:return{title:"Request failed",detail:"Too many attempts.",ctaText:"Try again later",icon:i};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i}}}})(r,s.allowlistConfig);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:a}),/*#__PURE__*/e(yh,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(wl,{color:"var(--privy-color-error)"}),l.icon]})}),/*#__PURE__*/e(gh,{children:[/*#__PURE__*/t("h3",{children:l.title}),"string"==typeof l.detail?/*#__PURE__*/t("p",{children:l.detail}):l.detail]}),/*#__PURE__*/t(wt,{color:"var(--privy-color-error)",onClick:()=>{r instanceof O&&(r.privyErrorCode===b.INVALID_CAPTCHA&&o(),r.privyErrorCode===b.ALLOWLIST_REJECTED&&s.allowlistConfig.errorCtaLink)?window.location.href=s.allowlistConfig.errorCtaLink:i?.()},children:l.ctaText})]})]})};let yh=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-f1b9e2cb-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),gh=/*#__PURE__*/ii.div.withConfig({displayName:"GappedContainer",componentId:"sc-f1b9e2cb-1"})(["display:flex;flex-direction:column;gap:8px;"]),fh=/*#__PURE__*/ii.a.withConfig({displayName:"Link",componentId:"sc-f1b9e2cb-2"})(["color:var(--privy-color-accent) !important;font-weight:600;"]);const wh=({style:e,color:n,...r})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:n||"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...r,children:/*#__PURE__*/t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}),vh=n=>{let[r,a]=s(!1);/*#__PURE__*/return e(Ch,{color:n.color,onClick:()=>{a(!0),navigator.clipboard.writeText(n.text),setTimeout((()=>a(!1)),1500)},justCopied:r,children:[r?/*#__PURE__*/t(wh,{style:{height:"14px",width:"14px"},strokeWidth:"2"}):/*#__PURE__*/t(Xt,{style:{height:"14px",width:"14px"}}),r?"Copied":"Copy"," ",n.itemName?n.itemName:"to Clipboard"]})};let Ch=/*#__PURE__*/ii.button.withConfig({displayName:"StyledCopytoClipboardButton",componentId:"sc-9c2ee64b-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.justCopied?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.justCopied?"medium":"normal"),(e=>e.justCopied?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"));const Eh=e=>{let[n,r]=s(!1);/*#__PURE__*/return t(Th,{color:e.color,href:e.url,target:"_blank",rel:"noreferrer noopener",onClick:()=>{r(!0),setTimeout((()=>r(!1)),1500)},justOpened:n,children:e.text})};let Th=/*#__PURE__*/ii.a.withConfig({displayName:"StyledOpenLinkButton",componentId:"sc-4e695c83-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.justOpened?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.justOpened?"medium":"normal"),(e=>e.justOpened?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"));const bh=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"1000",height:"1000",viewBox:"0 0 1000 1000",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"1000",height:"1000",rx:"200",fill:"#855DCD"}),/*#__PURE__*/t("path",{d:"M257.778 155.556H742.222V844.444H671.111V528.889H670.414C662.554 441.677 589.258 373.333 500 373.333C410.742 373.333 337.446 441.677 329.586 528.889H328.889V844.444H257.778V155.556Z",fill:"white"}),/*#__PURE__*/t("path",{d:"M128.889 253.333L157.778 351.111H182.222V746.667C169.949 746.667 160 756.616 160 768.889V795.556H155.556C143.283 795.556 133.333 805.505 133.333 817.778V844.444H382.222V817.778C382.222 805.505 372.273 795.556 360 795.556H355.556V768.889C355.556 756.616 345.606 746.667 333.333 746.667H306.667V253.333H128.889Z",fill:"white"}),/*#__PURE__*/t("path",{d:"M675.556 746.667C663.283 746.667 653.333 756.616 653.333 768.889V795.556H648.889C636.616 795.556 626.667 805.505 626.667 817.778V844.444H875.556V817.778C875.556 805.505 865.606 795.556 853.333 795.556H848.889V768.889C848.889 756.616 838.94 746.667 826.667 746.667V351.111H851.111L880 253.333H702.222V746.667H675.556Z",fill:"white"})]});let Ah="#8a63d2";let _h=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-d15a94a3-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),kh=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-d15a94a3-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),Ih="#8a63d2";let Nh=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-6e2c96cd-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),xh=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e2c96cd-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);function Sh({title:e}){let{currentScreen:n,navigateBack:r,navigate:a,data:i,setModalData:o}=Tr();/*#__PURE__*/return t(ft,{title:e,backFn:n===br.FUNDING_MANUAL_TRANSFER_SCREEN?r:n===i?.funding?.methodScreen?i.funding.comingFromSendTransactionScreen?()=>a(br.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN):void 0:i?.funding?.methodScreen?()=>{let e=i.funding;e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),o({funding:e}),a(e.methodScreen)}:void 0})}const Rh=({size:n})=>/*#__PURE__*/t(Oh,{$size:n,children:/*#__PURE__*/e(Wh,{children:[/*#__PURE__*/t(Lh,{}),/*#__PURE__*/t(Ph,{})]})});let Oh=/*#__PURE__*/ii.div.withConfig({displayName:"LoadingContainer",componentId:"sc-3ddaba1c-0"})(["--spinner-size:",";display:flex;justify-content:center;align-items:center;flex-grow:1;@media all and (display-mode:standalone){margin-bottom:30px;}"],(e=>e.$size?e.$size:"96px")),Wh=/*#__PURE__*/ii.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-3ddaba1c-1"})(["position:relative;height:var(--spinner-size);width:var(--spinner-size);opacity:1;animation:fadein 200ms ease;"]),Lh=/*#__PURE__*/ii.div.withConfig({displayName:"CircleFixed",componentId:"sc-3ddaba1c-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);&&{border:4px solid #f1f2f9;border-radius:50%;}"]),Ph=/*#__PURE__*/ii.div.withConfig({displayName:"CircleRotate",componentId:"sc-3ddaba1c-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:#cbcde1 transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]);const Mh=({enabled:e=!0}={})=>{let{showFiatPrices:t,getUsdPriceForSol:n}=N(),[r,a]=s(!0),[i,l]=s(void 0),[c,d]=s(void 0);return o((()=>{(async()=>{if(t&&e)try{a(!0);let e=await n();e?d(e):l(Error("Unable to fetch SOL price"))}catch(e){l(e)}finally{a(!1)}else a(!1)})()}),[]),{solPrice:c,isSolPriceLoading:r,solPriceError:i}};function Uh(e){let{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:r}=(e=>{let{showFiatPrices:t,getUsdTokenPrice:n,chains:r}=N(),[a,i]=s(!0),[l,c]=s(void 0),[d,h]=s(void 0);return o((()=>{e||=Lr;let a=Wr(r).find((t=>t.id===Number(e)));(async()=>{if(t){if(!a)return i(!1),void c(Error(`Unable to fetch token price on chain id ${e}`));try{i(!0);let e=await n(a);e?h(e):c(Error(`Unable to fetch token price on chain id ${a.id}`))}catch(e){c(e)}finally{i(!1)}}else i(!1)})()}),[e]),{tokenPrice:d,isTokenPriceLoading:a,tokenPriceError:l}})("solana"===e?-1:e),{solPrice:a,isSolPriceLoading:i,solPriceError:l}=Mh({enabled:"solana"===e});return"solana"===e?{tokenPrice:a,isTokenPriceLoading:i,tokenPriceError:l}:{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:r}}const Dh=(e,t=0)=>{let n=e[t],r=e[t+7];if(!n||!r)throw Error(`Buffer offset out of range: first: ${n}, last: ${r}.`);return(BigInt(e[t+4]+256*e[t+5]+65536*e[t+6]+(r<<24))<<32n)+BigInt(n+256*e[++t]+65536*e[++t]+16777216*e[++t])};async function Fh(e){try{return await e}catch{}}let Bh=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2});function zh(e,t=6,n=!1,r=!1){let a=(parseFloat(e.toString())/1e9).toFixed(t).replace(/0+$/,"").replace(/\.$/,""),i=r?"":" SOL";return n?`${a}${i}`:`${"0"===a?"<0.001":a}${i}`}function Hh(e,t){let n=parseFloat(e.toString())/1e9,r=Bh.format(t*n);return"$0.00"===r?"<$0.01":r}function Vh({amount:e,fee:t,tokenPrice:n}){let r=BigInt(1e9*parseFloat(e)),a=r+t;return{fundingAmountInBaseUnit:r,fundingAmountInUsd:n?Hh(r,n):void 0,totalPriceInUsd:n?Hh(a,n):void 0,totalPriceInNativeCurrency:zh(a),feePriceInNativeCurrency:zh(t),feePriceInUsd:n?Hh(t,n):void 0}}function $h(e){return"version"in e}function Gh(e,t,n){return{signature:e,parsedTransaction:n??null,signedTransaction:t,fees:BigInt(n?.meta?.fee||0)}}async function qh({tx:e,connection:t,client:n}){let r=$h(e)?e.message:e.compileMessage(),a=r.staticAccountKeys[0]?.toBase58()??"",i=await async function(e,t){return BigInt(($h(e)?(await t.getFeeForMessage(e.message)).value:await e.getEstimatedFee(t))??0)}(e,t),o={},s={},l=[];for(let e of r.compiledInstructions){let a=r.staticAccountKeys[e.programIdIndex]?.toBase58()||"";if("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"!==a&&"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"!==a)if("11111111111111111111111111111111"!==a)if("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"!==a)l.push({type:"unknown",program:a});else{let t=await Fh(function(e,t){let[n,r,a,i]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!(n&&r&&a&&i))throw Error("Failed to parse ATA creation instruction");return{type:"ata-creation",payer:n.toBase58(),ata:r.toBase58(),owner:a.toBase58(),mint:i.toBase58()}}(e,r));if(!t)continue;l.push(t),s[t.ata]={owner:t.owner,mint:t.mint}}else{let t=await Fh(Yh(e,r));if(!t)continue;l.push(t)}else{let a=await Fh(Kh(e,r,t,n,o,s));if(!a)continue;l.push(a),o[a.token.address]=a.token,s[a.fromAta]??={owner:a.fromAccount,mint:a.token.address},a.toAccount&&(s[a.toAta]??={owner:a.toAccount,mint:a.token.address})}}let c=l.filter((({type:e})=>["spl-transfer","sol-transfer"].includes(e)));return{spender:a,fee:i,instructions:c.length?c:l}}function jh(e,t){try{return function(e,t=0){let n=0n;for(let r=0;r<8;r++)n|=BigInt(e[t+r])<<BigInt(8*r);return n}(e,t)}catch{}try{return e.readBigInt64LE(t)}catch{}let n=Buffer.from(e);try{return Dh(n)}catch{}try{return n.subarray(t).readBigInt64LE()}catch{}try{return n.readBigInt64LE(t)}catch{}return 0n}async function Kh(e,t,n,r,a,i){let o,s,[l,c,d]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!l||!c||!d)throw Error("Failed to parse SPL transfer instruction");let h="",u=i[c.toBase58()];if(u)o=u.owner,h=u.mint;else{let e=await n.getParsedAccountInfo(c,"confirmed"),t=e.value?.data;o=t?.parsed?.info?.owner,h=t?.parsed?.info?.mint??"",s=t?.parsed?.info?.tokenAmount?.decimals}if(!h){let e=await n.getParsedAccountInfo(l,"confirmed"),t=e.value?.data;h=t?.parsed?.info?.mint??""}let p=a[h];if(h&&!p){let e=await r.getSplTokenMetadata({mintAddress:h,cluster:Pr(n.rpcEndpoint)});e&&(p={address:h,symbol:e.symbol,decimals:e.decimals})}let m=p?.symbol??"";s??=p?.decimals??9;let y=jh(e.data,1);return{type:"spl-transfer",fromAta:l.toBase58(),fromAccount:d.toBase58(),toAta:c.toBase58(),toAccount:o,value:y,token:{symbol:m,decimals:s,address:h}}}async function Yh(e,t){let[n,r]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!n||!r)throw Error("Failed to parse SOL transfer instruction");let a=jh(e.data,4);return{type:"sol-transfer",fromAccount:n.toBase58(),toAccount:r.toBase58(),value:a,token:{symbol:"SOL",decimals:9}}}const Zh=({chains:e,appId:t,address:n,rpcConfig:r})=>Promise.all(e.map((async e=>{let a=Ba({chain:e,transport:za(ei(e,r,t))});return{balance:await a.getBalance({address:n}).catch((()=>0n)),chain:e}}))),Xh=/*#__PURE__*/ii.span.withConfig({displayName:"LabelSm",componentId:"sc-6c002d6-0"})(["color:var(--privy-color-foreground-3);font-size:0.875rem;font-weight:400;line-height:1.375rem;"]),Qh=/*#__PURE__*/ii(Xh).withConfig({displayName:"LabelSmPrimary",componentId:"sc-6c002d6-1"})(["color:var(--privy-color-accent);"]),Jh=/*#__PURE__*/ii.span.withConfig({displayName:"Value",componentId:"sc-72aa026-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;",""],nn),eu=({balance:e,className:n,chain:r})=>/*#__PURE__*/t(rn,{className:n,$state:void 0,children:/*#__PURE__*/t(tu,{balance:e,chain:r})}),tu=({balance:r,chain:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(nu,{children:[/*#__PURE__*/t(au,{chainId:"id"in a?a.id:"solana"}),/*#__PURE__*/t(Jh,{children:a.name})]}),/*#__PURE__*/e(Rt,{isLoading:!1,isPulsing:!1,color:"gray",children:[/*#__PURE__*/t(ru,{children:/*#__PURE__*/t(di,{})}),r]})]});let nu=/*#__PURE__*/ii.div.withConfig({displayName:"Container",componentId:"sc-6d3c340d-0"})(["display:flex;align-items:center;"]),ru=/*#__PURE__*/ii.div.withConfig({displayName:"IconContainer",componentId:"sc-6d3c340d-1"})(["height:0.75rem;width:0.75rem;margin-right:0.2rem;"]),au=/*#__PURE__*/ii(an).withConfig({displayName:"StyledNetworkIcon",componentId:"sc-6d3c340d-2"})(["height:1.25rem;width:1.25rem;display:inline-block;margin-right:0.5rem;border-radius:4px;"]);const iu=({options:n,onSelect:r,selected:a,className:i})=>/*#__PURE__*/e(Ji,{as:ou,children:[/*#__PURE__*/e(eo,{as:du,children:[/*#__PURE__*/t(tu,{balance:a.balance,chain:a.chain}),/*#__PURE__*/t(cu,{height:16})]}),/*#__PURE__*/t(to,{as:su,className:i,children:n.map(((e,n)=>/*#__PURE__*/t(no,{as:lu,onClick:()=>r(n),children:/*#__PURE__*/t(tu,{balance:e.balance,chain:e.chain})},n)))})]});let ou=/*#__PURE__*/ii.div.withConfig({displayName:"Wrapper",componentId:"sc-7924b61-0"})(["width:100%;position:relative;"]),su=/*#__PURE__*/ii.div.withConfig({displayName:"Popover",componentId:"sc-7924b61-1"})(["width:100%;margin-top:0.5rem;position:absolute;background-color:var(--privy-color-background);border-radius:var(--privy-border-radius-md);overflow-x:hidden;overflow-y:auto;box-shadow:0px 1px 2px 0px rgba(16,24,40,0.05);max-height:11.75rem;&&{border:solid 1px var(--privy-color-foreground-4);}z-index:1;"]),lu=/*#__PURE__*/ii.button.withConfig({displayName:"Button",componentId:"sc-7924b61-2"})(["width:100%;display:flex;justify-content:space-between;&&{padding:1rem;}:not(:last-child){border-bottom:solid 1px var(--privy-color-foreground-4);}:hover{background:var(--privy-color-background-2);}"]),cu=/*#__PURE__*/ii(so).withConfig({displayName:"StyledChevronIcon",componentId:"sc-7924b61-3"})(["height:1rem;margin-left:0.5rem;"]),du=/*#__PURE__*/ii.button.withConfig({displayName:"StyledMenuButton",componentId:"sc-7924b61-4"})([""," span{margin-left:auto;}","{transition:rotate 100ms ease-in;}&[aria-expanded='true']{","{rotate:-180deg;}}"],on,cu,cu);const hu=({style:e,...n})=>/*#__PURE__*/t("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...e},fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.71369 17.5625V10.375C3.71369 6.44625 6.85845 3.25 10.7238 3.25H17.7953C18.6783 3.25 19.3941 2.52244 19.3941 1.625C19.3941 0.727562 18.6783 0 17.7953 0H10.7238C5.09529 0 0.516113 4.65419 0.516113 10.375V17.5625C0.516113 18.4599 1.23194 19.1875 2.1149 19.1875C2.99787 19.1875 3.71369 18.4599 3.71369 17.5625ZM17.7953 60.7501C18.6783 60.7501 19.3941 61.4777 19.3941 62.3751C19.3941 63.2726 18.6783 64.0001 17.7953 64.0001H10.7238C5.09529 64.0001 0.516113 59.3459 0.516113 53.6251V46.4376C0.516113 45.5402 1.23194 44.8126 2.1149 44.8126C2.99787 44.8126 3.71369 45.5402 3.71369 46.4376V53.6251C3.71369 57.5538 6.85845 60.7501 10.7238 60.7501H17.7953ZM63.4839 46.4376V53.6251C63.4839 59.3459 58.9048 64.0001 53.2763 64.0001H46.2047C45.3217 64.0001 44.6059 63.2726 44.6059 62.3751C44.6059 61.4777 45.3217 60.7501 46.2047 60.7501H53.2763C57.1416 60.7501 60.2864 57.5538 60.2864 53.6251V46.4376C60.2864 45.5402 61.0022 44.8126 61.8851 44.8126C62.7681 44.8126 63.4839 45.5402 63.4839 46.4376ZM63.4839 10.375V17.5625C63.4839 18.4599 62.7681 19.1875 61.8851 19.1875C61.0022 19.1875 60.2864 18.4599 60.2864 17.5625V10.375C60.2864 6.44625 57.1416 3.25 53.2763 3.25H46.2047C45.3217 3.25 44.6059 2.52244 44.6059 1.625C44.6059 0.727562 45.3217 0 46.2047 0H53.2763C58.9048 0 63.4839 4.65419 63.4839 10.375ZM43.0331 47.3022C43.7067 46.6698 43.7483 45.6022 43.1262 44.9176C42.5039 44.233 41.4536 44.1906 40.78 44.823C38.3832 47.0732 35.265 48.3125 31.9997 48.3125C28.7344 48.3125 25.6162 47.0732 23.2194 44.823C22.5457 44.1906 21.4955 44.233 20.8732 44.9176C20.251 45.6022 20.2927 46.6698 20.9663 47.3022C23.9784 50.1301 27.8968 51.6875 31.9997 51.6875C36.1026 51.6875 40.021 50.1301 43.0331 47.3022ZM35.3207 24.1249V36.1249C35.3207 38.5029 33.4173 40.4374 31.0777 40.4374H29.7249C28.8079 40.4374 28.0646 39.6819 28.0646 38.7499C28.0646 37.8179 28.8079 37.0624 29.7249 37.0624H31.0777C31.5863 37.0624 32.0001 36.6419 32.0001 36.1249V24.1249C32.0001 23.1929 32.7434 22.4374 33.6604 22.4374C34.5774 22.4374 35.3207 23.1929 35.3207 24.1249ZM46.7581 28.8437V24.0312C46.7581 23.151 46.056 22.4374 45.19 22.4374C44.324 22.4374 43.622 23.151 43.622 24.0312V28.8437C43.622 29.7239 44.324 30.4374 45.19 30.4374C46.056 30.4374 46.7581 29.7239 46.7581 28.8437ZM17.6109 28.8437C17.6109 29.7239 18.313 30.4374 19.1789 30.4374C20.0449 30.4374 20.747 29.7239 20.747 28.8437V24.0312C20.747 23.151 20.0449 22.4374 19.1789 22.4374C18.313 22.4374 17.6109 23.151 17.6109 24.0312V28.8437Z"})}),uu=({style:n,...r})=>/*#__PURE__*/e("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...n},xmlns:"http://www.w3.org/2000/svg",...r,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_113_33841)",children:[/*#__PURE__*/t("path",{d:"M39.1193 0.943398C34.636 -0.174912 29.9185 -0.334713 25.328 0.656273C24.9732 0.732859 24.7477 1.08253 24.8243 1.43729C24.9009 1.79205 25.2506 2.01756 25.6053 1.94097C30.0015 0.991934 34.53 1.14842 38.8375 2.22802C49.1385 4.80983 57.7129 12.5548 60.9786 22.6718C62.2416 26.5843 62.7781 30.7505 62.8855 35.1167C62.8945 35.4795 63.1958 35.7664 63.5586 35.7575C63.9215 35.7485 64.2083 35.4472 64.1994 35.0843C64.0905 30.6582 63.5477 26.3849 62.2536 22.3432C58.8621 11.7515 49.9005 3.63265 39.1193 0.943398Z"}),/*#__PURE__*/t("path",{d:"M21.9931 2.93163C22.343 2.83511 22.5484 2.47325 22.4518 2.12339C22.3553 1.77352 21.9935 1.56815 21.6436 1.66466C16.8429 2.98903 10.0898 7.56519 5.91628 13.6786C5.91465 13.681 5.91304 13.6834 5.91145 13.6858C2.24684 19.2083 -0.0503572 26.1484 0.591012 32.8828C0.591623 32.8892 0.592328 32.8956 0.593127 32.902C0.746837 34.1317 1.00488 35.3591 1.26323 36.5879C1.80735 39.1761 2.35282 41.7706 1.92765 44.4064C1.86986 44.7647 2.11347 45.102 2.47177 45.1598C2.83007 45.2176 3.16738 44.974 3.22518 44.6157C3.66961 41.8605 3.11776 39.173 2.56581 36.4851C2.31054 35.2419 2.05525 33.9987 1.89847 32.7486C1.29525 26.3851 3.46802 19.7466 7.00418 14.416C11.0189 8.5373 17.5201 4.16562 21.9931 2.93163Z"}),/*#__PURE__*/t("path",{d:"M30.6166 4.39985C38.8671 3.89603 47.1159 7.26314 52.6556 13.7139C52.8921 13.9893 52.8605 14.4042 52.5852 14.6406C52.3099 14.8771 51.895 14.8455 51.6585 14.5702C46.3904 8.43576 38.541 5.23144 30.6927 5.71195C30.6899 5.71212 30.6871 5.71227 30.6843 5.71241C20.7592 6.19265 11.4643 12.9257 8.04547 22.3603C7.92183 22.7016 7.54498 22.8779 7.20375 22.7543C6.86253 22.6306 6.68616 22.2538 6.80981 21.9126C10.4114 11.9735 20.1717 4.90702 30.6166 4.39985Z"}),/*#__PURE__*/t("path",{d:"M54.6576 16.5848C54.4553 16.2836 54.047 16.2033 53.7457 16.4057C53.4444 16.608 53.3642 17.0163 53.5665 17.3176C56.6376 21.8904 57.9074 26.8665 58.4094 32.7717C58.4401 33.1333 58.7582 33.4016 59.1199 33.3708C59.4815 33.3401 59.7497 33.022 59.719 32.6604C59.206 26.6261 57.8965 21.4076 54.6576 16.5848Z"}),/*#__PURE__*/t("path",{d:"M59.2796 35.4504C59.6419 35.4277 59.9539 35.703 59.9765 36.0653C60.2242 40.0279 60.2265 44.5112 59.7881 47.8243C59.7405 48.1841 59.4102 48.4372 59.0504 48.3896C58.6906 48.342 58.4376 48.0117 58.4852 47.6519C58.9077 44.4586 58.91 40.0704 58.6648 36.1473C58.6421 35.785 58.9174 35.473 59.2796 35.4504Z"}),/*#__PURE__*/t("path",{d:"M7.05311 25.5432C7.13829 25.1904 6.92135 24.8354 6.56855 24.7502C6.21576 24.665 5.86071 24.882 5.77553 25.2348C5.2932 27.2325 5.0428 29.2847 5.03288 31.3388C5.02266 33.4559 5.41742 35.5225 5.81234 37.5899C6.1354 39.2811 6.45855 40.9728 6.5602 42.6932C6.69373 44.9531 6.21839 47.2163 5.39698 49.3703C5.26766 49.7094 5.43774 50.0891 5.77685 50.2184C6.11596 50.3477 6.4957 50.1777 6.62502 49.8386C7.49325 47.5617 8.01954 45.1092 7.87221 42.6157C7.77126 40.9071 7.44813 39.2252 7.12512 37.5439C6.73099 35.4925 6.33704 33.442 6.34716 31.3451C6.35659 29.3933 6.59455 27.4425 7.05311 25.5432Z"}),/*#__PURE__*/t("path",{d:"M24.2964 10.94C24.4317 11.2768 24.2683 11.6595 23.9315 11.7947C17.1187 14.5307 12.0027 20.7047 10.959 27.9852C10.523 31.0269 10.9941 34.0398 11.465 37.052C11.7303 38.7483 11.9954 40.4443 12.0985 42.1451C12.3221 45.833 11.902 49.8839 9.50192 53.5696C9.30387 53.8737 8.89677 53.9597 8.59264 53.7617C8.28851 53.5636 8.20251 53.1565 8.40056 52.8524C10.5873 49.4944 11.0012 45.7644 10.7867 42.2246C10.6821 40.499 10.4185 38.7833 10.1552 37.0686C9.68265 33.9923 9.21067 30.9195 9.65804 27.7987C10.7724 20.025 16.221 13.4748 23.4417 10.5751C23.7785 10.4399 24.1612 10.6032 24.2964 10.94Z"}),/*#__PURE__*/t("path",{d:"M47.3662 14.6814C41.9915 9.64741 34.2017 7.89046 27.122 9.4433C26.7675 9.52105 26.5432 9.87147 26.6209 10.226C26.6987 10.5805 27.0491 10.8048 27.4036 10.7271C34.1075 9.25665 41.4426 10.934 46.4677 15.6406C50.7033 19.6077 53.1628 25.38 53.8066 31.6779C53.8435 32.0389 54.1661 32.3017 54.5272 32.2648C54.8883 32.2279 55.151 31.9053 55.1141 31.5442C54.4456 25.0047 51.8822 18.9111 47.3662 14.6814Z"}),/*#__PURE__*/t("path",{d:"M54.9766 34.6738C55.3376 34.6368 55.6604 34.8994 55.6975 35.2604C56.3216 41.337 56.0526 47.9003 55.1104 54.2496C55.0571 54.6086 54.7229 54.8565 54.3639 54.8032C54.0049 54.7499 53.7571 54.4157 53.8103 54.0567C54.7394 47.7957 55.001 41.3439 54.39 35.3947C54.353 35.0336 54.6156 34.7109 54.9766 34.6738Z"}),/*#__PURE__*/t("path",{d:"M32.0659 13.3553C21.9959 13.3553 13.814 21.3892 13.814 31.3219C13.814 32.3829 13.9081 33.4225 14.0876 34.4334C14.1511 34.7907 14.4922 35.029 14.8495 34.9655C15.2069 34.9021 15.4451 34.561 15.3817 34.2036C15.2155 33.2677 15.1283 32.305 15.1283 31.3219C15.1283 22.1352 22.7014 14.6696 32.0659 14.6696C36.2978 14.6696 40.1642 16.1949 43.1319 18.7152C43.4086 18.9501 43.8233 18.9163 44.0582 18.6396C44.2931 18.363 44.2593 17.9483 43.9827 17.7134C40.7847 14.9975 36.6188 13.3553 32.0659 13.3553Z"}),/*#__PURE__*/t("path",{d:"M45.455 20.1635C45.717 19.9123 46.133 19.921 46.3842 20.183C49.2843 23.2072 50.2126 27.9605 50.8269 31.9494C51.5188 36.4426 51.6244 40.826 51.6244 42.8585C51.6244 43.2214 51.3302 43.5156 50.9673 43.5156C50.6044 43.5156 50.3101 43.2214 50.3101 42.8585C50.3101 40.8589 50.2055 36.5497 49.5279 32.1494C48.9577 28.4462 48.1356 23.9082 45.4356 21.0927C45.1844 20.8307 45.1931 20.4147 45.455 20.1635Z"}),/*#__PURE__*/t("path",{d:"M51.4576 46.6219C51.4864 46.2601 51.2165 45.9435 50.8547 45.9146C50.493 45.8858 50.1763 46.1557 50.1474 46.5175C49.8247 50.5654 49.403 54.6088 48.5474 58.3439C48.4663 58.6977 48.6874 59.0502 49.0412 59.1312C49.3949 59.2123 49.7474 58.9912 49.8285 58.6374C50.7067 54.8039 51.134 50.6806 51.4576 46.6219Z"}),/*#__PURE__*/t("path",{d:"M15.1454 36.852C15.5015 36.7819 15.847 37.0137 15.9171 37.3698C17.3066 44.4257 16.3467 50.8355 12.6672 56.4502C12.4682 56.7537 12.0609 56.8385 11.7573 56.6396C11.4538 56.4407 11.369 56.0333 11.5679 55.7298C15.0299 50.4469 15.9617 44.3985 14.6276 37.6238C14.5575 37.2677 14.7893 36.9221 15.1454 36.852Z"}),/*#__PURE__*/t("path",{d:"M32.0659 17.631C25.5291 17.631 19.1165 22.691 18.462 29.0504C18.1754 31.8345 18.578 34.5769 18.9807 37.3204C19.3323 39.7159 19.684 42.1124 19.5772 44.5381C19.3328 50.0898 17.7039 54.6726 14.905 58.4471C14.6888 58.7386 14.7499 59.1502 15.0414 59.3663C15.333 59.5825 15.7445 59.5214 15.9607 59.2299C18.9293 55.2266 20.6354 50.386 20.8903 44.5959C20.9966 42.1811 20.6438 39.7923 20.2912 37.4051C19.888 34.6752 19.4851 31.9473 19.7694 29.1849C20.3444 23.5983 26.0946 18.9453 32.0659 18.9453C34.851 18.9453 42.057 20.4534 44.3492 27.9205C45.7856 32.5998 46.1774 38.9326 45.8295 45.0849C45.4816 51.2364 44.3994 57.12 42.9442 60.8928C42.8136 61.2314 42.9822 61.6118 43.3208 61.7424C43.6594 61.873 44.0398 61.7044 44.1704 61.3658C45.6929 57.4186 46.7895 51.386 47.1417 45.1591C47.4938 38.9329 47.1068 32.4249 45.6056 27.5348C43.0612 19.2461 35.0851 17.631 32.0659 17.631Z"}),/*#__PURE__*/t("path",{d:"M21.9529 56.4512C22.2569 56.6494 22.3426 57.0566 22.1444 57.3606C21.7369 57.9854 21.3784 58.6391 21.0199 59.2928C20.6614 59.9465 20.3028 60.6004 19.8953 61.2253C19.697 61.5293 19.2898 61.615 18.9858 61.4167C18.6819 61.2184 18.5962 60.8113 18.7944 60.5073C19.2019 59.8825 19.5604 59.2288 19.9189 58.5751C20.2774 57.9213 20.636 57.2675 21.0435 56.6426C21.2418 56.3386 21.649 56.2529 21.9529 56.4512Z"}),/*#__PURE__*/t("path",{d:"M27.5799 24.4525C27.8816 24.2508 27.9625 23.8426 27.7608 23.541C27.559 23.2393 27.1509 23.1583 26.8492 23.3601C24.247 25.1006 22.6505 27.494 22.6505 31.0002C22.6505 33.088 23.0203 34.7946 23.3997 36.5449C23.9674 39.1641 24.3524 41.7777 24.2832 44.468C24.1992 47.7349 23.56 50.7201 22.3313 53.564C22.1873 53.8971 22.3407 54.2839 22.6739 54.4278C23.0071 54.5718 23.3938 54.4184 23.5378 54.0852C24.8369 51.0784 25.509 47.9266 25.5971 44.5018C25.6689 41.7062 25.2732 38.9892 24.6845 36.267C24.3042 34.509 23.9648 32.9394 23.9648 31.0002C23.9648 27.9961 25.2863 25.9866 27.5799 24.4525Z"}),/*#__PURE__*/t("path",{d:"M30.1447 22.1436C32.8717 21.5877 35.8061 22.2746 37.966 24.0228C41.8241 27.1455 42.3372 32.8403 42.753 37.4549L42.7742 37.69C43.3115 43.6385 42.6964 49.4163 41.4575 55.2186C41.3817 55.5736 41.0326 55.7999 40.6776 55.7241C40.3227 55.6483 40.0964 55.2991 40.1722 54.9442C41.3926 49.2288 41.9873 43.5885 41.4652 37.8082C41.4479 37.6169 41.4307 37.4228 41.4133 37.2264L41.4131 37.2235C41.0438 33.0534 40.5812 27.8304 37.1392 25.0444C35.2926 23.5498 32.7599 22.9518 30.4073 23.4314C30.0517 23.5039 29.7046 23.2744 29.6321 22.9188C29.5596 22.5632 29.7891 22.2161 30.1447 22.1436Z"}),/*#__PURE__*/t("path",{d:"M40.5287 58.4885C40.6183 58.1368 40.4057 57.7791 40.054 57.6896C39.7023 57.6 39.3446 57.8126 39.2551 58.1643C38.8578 59.7247 38.2456 61.1333 37.4695 62.4301C37.2831 62.7415 37.3844 63.145 37.6958 63.3314C38.0072 63.5178 38.4108 63.4165 38.5972 63.1051C39.4336 61.7075 40.0977 60.1816 40.5287 58.4885Z"}),/*#__PURE__*/t("path",{d:"M37.3152 48.9521C37.6756 48.9948 37.9332 49.3215 37.8906 49.682C37.2699 54.9267 35.8688 59.6042 33.6205 63.6613C33.4446 63.9787 33.0446 64.0934 32.7272 63.9175C32.4097 63.7416 32.295 63.3417 32.4709 63.0242C34.6226 59.1416 35.9811 54.6339 36.5854 49.5275C36.6281 49.1671 36.9548 48.9095 37.3152 48.9521Z"}),/*#__PURE__*/t("path",{d:"M37.1798 30.6556C36.7242 28.2212 34.6349 26.3591 32.0985 26.3591C28.6638 26.3591 26.254 29.8212 27.1032 33.0422C28.54 38.7279 28.7759 44.2077 27.8032 49.4855L27.8025 49.4893C26.9584 54.228 25.3374 58.4908 23.1263 62.1031C22.9368 62.4127 23.0342 62.8172 23.3437 63.0067C23.6533 63.1962 24.0578 63.0988 24.2473 62.7893C26.5488 59.0292 28.2249 54.6109 29.0961 49.7218C30.106 44.2403 29.8558 38.5684 28.3765 32.7168L28.3748 32.7099C27.7378 30.3005 29.5133 27.6734 32.0985 27.6734C33.9641 27.6734 35.5393 29.0459 35.8871 30.8929C36.8436 36.4411 37.3418 41.5862 36.9871 46.016C36.9581 46.3778 37.2279 46.6945 37.5897 46.7235C37.9515 46.7525 38.2682 46.4827 38.2972 46.1209C38.6649 41.5294 38.1459 36.2576 37.1815 30.6648C37.1809 30.6617 37.1804 30.6586 37.1798 30.6556Z"}),/*#__PURE__*/t("path",{d:"M30.1376 59.1171C30.4604 59.283 30.5876 59.6792 30.4217 60.002L28.6804 63.3906C28.5145 63.7134 28.1184 63.8406 27.7956 63.6747C27.4728 63.5088 27.3456 63.1127 27.5114 62.7899L29.2527 59.4013C29.4186 59.0785 29.8147 58.9513 30.1376 59.1171Z"}),/*#__PURE__*/t("path",{d:"M32.5872 31.2892C32.5042 30.9359 32.1505 30.7168 31.7972 30.7998C31.4439 30.8828 31.2247 31.2365 31.3077 31.5898C33.5238 41.0232 33.2194 49.3066 30.5201 56.363C30.3905 56.702 30.5602 57.0819 30.8991 57.2115C31.2381 57.3412 31.618 57.1715 31.7477 56.8326C34.5622 49.475 34.8483 40.9141 32.5872 31.2892Z"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_113_33841",children:/*#__PURE__*/t("rect",{width:"64",height:"64",fill:"white",transform:"translate(0.483887)"})})})]});let pu=({passkeys:n,expanded:r,onUnlink:a,onExpand:i})=>{let[o,l]=s([]),c=r?n.length:2,d=e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device";/*#__PURE__*/return e("div",{children:[/*#__PURE__*/t(bu,{children:"Your passkeys"}),/*#__PURE__*/e(vu,{children:[n.slice(0,c).map((n=>/*#__PURE__*/e(ku,{children:[/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Au,{children:d(n)}),/*#__PURE__*/e(_u,{children:["Last used: ",(n.latestVerifiedAt??n.verifiedAt).toLocaleString()]})]}),/*#__PURE__*/t(Nu,{disabled:o.includes(n.credentialId),onClick:()=>(async e=>{l((t=>t.concat([e]))),await a(e),l((t=>t.filter((t=>t!==e))))})(n.credentialId),children:o.includes(n.credentialId)?/*#__PURE__*/t(sn,{}):/*#__PURE__*/t(go,{height:"1.6em"})})]},n.credentialId))),n.length>2&&!r&&/*#__PURE__*/t(wu,{onClick:i,children:"View all"})]})]})},mu=()=>/*#__PURE__*/e(vu,{children:[/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(fo,{})}),"Log in with Touch ID, Face ID, or a security key."]}),/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(Li,{})}),"More secure than a password."]}),/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(yo,{})}),"Takes seconds to set up and use."]})]});const yu=/*#__PURE__*/ii.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-302702bc-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent) !important;stroke:var(--privy-color-accent) !important;fill:var(--privy-color-accent) !important;}"]);let gu=/*#__PURE__*/ii.div.withConfig({displayName:"InputHelp",componentId:"sc-302702bc-1"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-beginngin;width:100%;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),fu=/*#__PURE__*/oi(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]);const wu=/*#__PURE__*/ii.button.withConfig({displayName:"LinkButton",componentId:"sc-302702bc-2"})(["",""],fu);let vu=/*#__PURE__*/ii.div.withConfig({displayName:"List",componentId:"sc-302702bc-3"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.8rem;padding:0.5rem 0rem 0rem;flex-grow:1;width:100%;"]),Cu=/*#__PURE__*/ii.div.withConfig({displayName:"ModalTitle",componentId:"sc-302702bc-4"})(["font-size:18px;line-height:18px;text-align:center;font-weight:600;"]),Eu=/*#__PURE__*/ii.div.withConfig({displayName:"ModalSubTitle",componentId:"sc-302702bc-5"})(["font-size:0.875rem;text-align:center;margin-top:10px;"]),Tu=/*#__PURE__*/ii.div.withConfig({displayName:"SectionSpacer",componentId:"sc-302702bc-6"})(["height:32px;"]),bu=/*#__PURE__*/ii.div.withConfig({displayName:"PasskeyListTitle",componentId:"sc-302702bc-7"})(["line-height:20px;height:20px;font-size:1em;font-weight:450;display:flex;justify-content:flex-beginning;width:100%;"]),Au=/*#__PURE__*/ii.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-302702bc-8"})(["font-size:1em;line-height:1.3em;font-weight:500;color:var(--privy-color-foreground-2);padding:0.2em 0;"]),_u=/*#__PURE__*/ii.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-302702bc-9"})(["font-size:0.875rem;line-height:1rem;color:#64668b;padding:0.2em 0;"]),ku=/*#__PURE__*/ii.div.withConfig({displayName:"PasskeyListItem",componentId:"sc-302702bc-10"})(["display:flex;align-items:center;justify-content:space-between;padding:1em;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;border-radius:8px;border:1px solid #e2e3f0 !important;width:100%;height:5em;"]),Iu=/*#__PURE__*/oi([":focus,:hover,:active{outline:none;}display:flex;width:2em;height:2em;justify-content:center;align-items:center;svg{color:var(--privy-color-error);}svg:hover{color:var(--privy-color-foreground-3);}"]),Nu=/*#__PURE__*/ii.button.withConfig({displayName:"PasskeyItemUnlinkButton",componentId:"sc-302702bc-11"})(["",""],Iu);const xu=/*#__PURE__*/ii.div.withConfig({displayName:"FundingMethodContainer",componentId:"sc-eaaa12a-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),Su=/*#__PURE__*/ii.div.withConfig({displayName:"IconContainer",componentId:"sc-eaaa12a-1"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;svg{border-radius:var(--privy-border-radius-sm);}"]),Ru=/*#__PURE__*/ii.div.withConfig({displayName:"FundingQuantityWrapper",componentId:"sc-eaaa12a-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:8px;"]),Ou=/*#__PURE__*/ii.div.withConfig({displayName:"FundingQuantity",componentId:"sc-eaaa12a-3"})(["display:flex;align-items:center;gap:4px;width:100%;padding:0 16px;border-width:1px !important;border-radius:12px;cursor:text;&:focus-within{border-color:var(--privy-color-accent);}"]),Wu=/*#__PURE__*/ii.input.withConfig({displayName:"FundingAmountInput",componentId:"sc-eaaa12a-5"})(["background-color:var(--privy-color-background);width:100%;&:focus{outline:none !important;border:none !important;box-shadow:none !important;}&&{font-size:26px;}"]),Lu=/*#__PURE__*/ii(Wu).withConfig({displayName:"FundingAmountInputLarge",componentId:"sc-eaaa12a-6"})(["&&{font-size:42px;}"]),Pu=/*#__PURE__*/ii.div.withConfig({displayName:"FundingCurrency",componentId:"sc-eaaa12a-8"})(["font-size:18px;"]),Mu=/*#__PURE__*/ii.div.withConfig({displayName:"FundingDollars",componentId:"sc-eaaa12a-9"})(["font-size:12px;color:var(--privy-color-foreground-3);height:20px;"]),Uu=/*#__PURE__*/ii.div.withConfig({displayName:"InfoButtonText",componentId:"sc-eaaa12a-13"})([""]),Du=/*#__PURE__*/ii.a.withConfig({displayName:"InfoButtonLink",componentId:"sc-eaaa12a-14"})(["&&{color:var(--privy-color-accent);}cursor:pointer;"]),Fu=({displayName:r,errorMessage:a,configuredFundingChain:i,formattedBalance:o,fundingAmount:s,fundingCurrency:c,fundingAmountInUsd:d,options:h,selectedOption:u,isPreparing:p,isSubmitting:m,addressToFund:y,fundingWalletAddress:g,onSubmit:f,onSelect:w,onAmountChange:v})=>{let C=l(null);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(Vt,{children:"Transfer from another network"}),/*#__PURE__*/e($t,{children:["You need more funds on the ",i.name," network. Bridge from another blockchain network."]}),/*#__PURE__*/e(Ru,{style:{marginTop:"2rem"},children:[/*#__PURE__*/e(Ou,{onClick:()=>C.current?.focus(),children:[/*#__PURE__*/t(Wu,{ref:C,value:s,onChange:e=>{let t=e.target.value;/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1&&v(t)}}),/*#__PURE__*/t(Pu,{children:c})]}),d&&/*#__PURE__*/t(Mu,{children:d})]}),/*#__PURE__*/e(ln,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/t(Xh,{children:"From"}),/*#__PURE__*/t(Xh,{children:Pi(g)})]}),/*#__PURE__*/t(iu,{selected:{chain:u.chain,balance:cn(u.balance,u.chain.nativeCurrency.symbol,3,!0)},options:h.map((({chain:e,balance:t})=>({chain:e,balance:cn(t,e.nativeCurrency.symbol,3,!0)}))),onSelect:w}),/*#__PURE__*/e(ln,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/t(Xh,{children:"To"}),/*#__PURE__*/t(Xh,{children:Pi(y)})]}),/*#__PURE__*/t(eu,{chain:i,balance:o}),/*#__PURE__*/t(dn,{style:{marginTop:"1rem"},children:a}),/*#__PURE__*/e(hn,{style:{marginTop:"1rem"},loading:m||p,disabled:p||m,onClick:f,children:["Confirm with ",r]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},Bu=({wallet:r,displayName:a,addressToFund:i,chainId:o,chainName:s,isBridging:l,isErc20Flow:c,totalPriceInNativeCurrency:d,totalPriceInUsd:h,gasPriceInNativeCurrency:u,gasPriceInUsd:p})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Rh,{}),/*#__PURE__*/t(Qt,{style:{marginTop:"16px"},children:/*#__PURE__*/t(bc,{icon:xt(r.walletClientType,r.connectorType,r.walletClientType),name:r.walletClientType})}),/*#__PURE__*/t(ac,{style:{marginTop:"8px",marginBottom:"12px"},title:`${l?"Bridging":"Confirming"} with ${a}`}),!l&&!c&&/*#__PURE__*/e(un,{children:[/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Total"}),/*#__PURE__*/t(Jh,{children:h||d})]}),/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"To"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:i,showCopyIcon:!1})})]}),/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Network"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/e(zu,{children:[/*#__PURE__*/t(an,{chainId:o,height:16,width:16})," ",s]})})]}),u&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Estimated fee"}),/*#__PURE__*/t(Jh,{children:p||u})]})]}),/*#__PURE__*/t(Bt,{height:24}),/*#__PURE__*/t(Ct,{})]});let zu=/*#__PURE__*/ii.div.withConfig({displayName:"NetworkColumn",componentId:"sc-67160e5-0"})(["display:flex;flex-direction:row;align-items:center;gap:4px;"]);const Hu=[br.FUNDING_METHOD_SELECTION_SCREEN,br.FUNDING_TRANSFER_FROM_WALLET_SCREEN,br.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN,br.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN,br.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN,br.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN,br.FUNDING_MANUAL_TRANSFER_SCREEN,br.MOONPAY_STATUS_SCREEN],Vu={[br.FUNDING_METHOD_SELECTION_SCREEN]:null,[br.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:"external",[br.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:"external",[br.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN]:"external",[br.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN]:"external",[br.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN]:"external",[br.FUNDING_MANUAL_TRANSFER_SCREEN]:"manual",[br.MOONPAY_STATUS_SCREEN]:"moonpay"},$u=[{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}];let Gu=({status:r,onClickCta:a})=>{let{title:o,body:s,cta:l}=i((()=>(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(n,{children:[/*#__PURE__*/e(Ku,{children:[/*#__PURE__*/t(qu,{isSucccess:"success"===r}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t("h3",{children:o}),/*#__PURE__*/t(ju,{children:s})]})]}),l&&/*#__PURE__*/t(wt,{onClick:a,children:l})]})},qu=({isSucccess:n})=>{if(!n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t(tn,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(vn,{color:n}),/*#__PURE__*/t(Cn,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let r=(e=>e?wi:()=>/*#__PURE__*/t(lo,{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),a=(e=>e?"var(--privy-color-success)":"var(--privy-color-foreground-4)")(n);/*#__PURE__*/return t("div",{style:{borderColor:a,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:r&&/*#__PURE__*/t(r,{width:"4rem",height:"4rem",color:a})})},ju=/*#__PURE__*/ii.p.withConfig({displayName:"StatusBody",componentId:"sc-96ef1540-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),Ku=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-96ef1540-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const Yu=({children:n,theme:r})=>/*#__PURE__*/e(Zu,{$theme:r,children:[/*#__PURE__*/t(ci,{width:"3rem",color:"var(--privy-color-error)"}),n]});let Zu=/*#__PURE__*/ii.div.withConfig({displayName:"Container",componentId:"sc-5400b18f-0"})(["display:flex;gap:0.5rem;"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.75rem;font-weight:400;line-height:1.125rem;padding:0.5rem 0.75rem;&&{border:1px solid var(--privy-color-error);border-radius:var(--privy-border-radius-sm);}"],(e=>"dark"===e.$theme?"color: var(--privy-color-error);":"background-color: var(--privy-color-error-light);"));const Xu=({children:n,theme:r})=>/*#__PURE__*/e(Qu,{$theme:r,children:[/*#__PURE__*/t(uo,{width:"1.25rem",color:"dark"===r?"var(--privy-color-accent-light)":"var(--privy-color-accent-dark)",style:{minWidth:"1.25rem"}}),n]});let Qu=/*#__PURE__*/ii.div.withConfig({displayName:"Container",componentId:"sc-dc8a0871-0"})(["display:flex;gap:0.5rem;background-color:",";color:var(--privy-color-foreground);align-items:flex-start;text-align:left;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);border:1px solid var(--privy-color-accent);}"],(e=>"dark"===e.$theme?"var(--privy-color-accent-darkest)":"var(--privy-color-accent-lightest)"));const Ju=e=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 210.2",xmlSpace:"preserve",...e,children:/*#__PURE__*/t("path",{d:"M93.6,27.1C87.6,34.2,78,39.8,68.4,39c-1.2-9.6,3.5-19.8,9-26.1c6-7.3,16.5-12.5,25-12.9 C103.4,10,99.5,19.8,93.6,27.1 M102.3,40.9c-13.9-0.8-25.8,7.9-32.4,7.9c-6.7,0-16.8-7.5-27.8-7.3c-14.3,0.2-27.6,8.3-34.9,21.2 c-15,25.8-3.9,64,10.6,85c7.1,10.4,15.6,21.8,26.8,21.4c10.6-0.4,14.8-6.9,27.6-6.9c12.9,0,16.6,6.9,27.8,6.7 c11.6-0.2,18.9-10.4,26-20.8c8.1-11.8,11.4-23.3,11.6-23.9c-0.2-0.2-22.4-8.7-22.6-34.3c-0.2-21.4,17.5-31.6,18.3-32.2 C123.3,42.9,107.7,41.3,102.3,40.9 M182.6,11.9v155.9h24.2v-53.3h33.5c30.6,0,52.1-21,52.1-51.4c0-30.4-21.1-51.2-51.3-51.2H182.6z M206.8,32.3h27.9c21,0,33,11.2,33,30.9c0,19.7-12,31-33.1,31h-27.8V32.3z M336.6,169c15.2,0,29.3-7.7,35.7-19.9h0.5v18.7h22.4V90.2 c0-22.5-18-37-45.7-37c-25.7,0-44.7,14.7-45.4,34.9h21.8c1.8-9.6,10.7-15.9,22.9-15.9c14.8,0,23.1,6.9,23.1,19.6v8.6l-30.2,1.8 c-28.1,1.7-43.3,13.2-43.3,33.2C298.4,155.6,314.1,169,336.6,169z M343.1,150.5c-12.9,0-21.1-6.2-21.1-15.7c0-9.8,7.9-15.5,23-16.4 l26.9-1.7v8.8C371.9,140.1,359.5,150.5,343.1,150.5z M425.1,210.2c23.6,0,34.7-9,44.4-36.3L512,54.7h-24.6l-28.5,92.1h-0.5 l-28.5-92.1h-25.3l41,113.5l-2.2,6.9c-3.7,11.7-9.7,16.2-20.4,16.2c-1.9,0-5.6-0.2-7.1-0.4v18.7C417.3,210,423.3,210.2,425.1,210.2z"})}),ep=n=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 38.1",xmlSpace:"preserve",...n,children:[/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M37.8,19.7V29h-3V6h7.8c1.9,0,3.7,0.7,5.1,2c1.4,1.2,2.1,3,2.1,4.9c0,1.9-0.7,3.6-2.1,4.9c-1.4,1.3-3.1,2-5.1,2 L37.8,19.7L37.8,19.7z M37.8,8.8v8h5c1.1,0,2.2-0.4,2.9-1.2c1.6-1.5,1.6-4,0.1-5.5c0,0-0.1-0.1-0.1-0.1c-0.8-0.8-1.8-1.3-2.9-1.2 L37.8,8.8L37.8,8.8z"}),/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M56.7,12.8c2.2,0,3.9,0.6,5.2,1.8s1.9,2.8,1.9,4.8V29H61v-2.2h-0.1c-1.2,1.8-2.9,2.7-4.9,2.7 c-1.7,0-3.2-0.5-4.4-1.5c-1.1-1-1.8-2.4-1.8-3.9c0-1.6,0.6-2.9,1.8-3.9c1.2-1,2.9-1.4,4.9-1.4c1.8,0,3.2,0.3,4.3,1v-0.7 c0-1-0.4-2-1.2-2.6c-0.8-0.7-1.8-1.1-2.9-1.1c-1.7,0-3,0.7-3.9,2.1l-2.6-1.6C51.8,13.8,53.9,12.8,56.7,12.8z M52.9,24.2 c0,0.8,0.4,1.5,1,1.9c0.7,0.5,1.5,0.8,2.3,0.8c1.2,0,2.4-0.5,3.3-1.4c1-0.9,1.5-2,1.5-3.2c-0.9-0.7-2.2-1.1-3.9-1.1 c-1.2,0-2.2,0.3-3,0.9C53.3,22.6,52.9,23.3,52.9,24.2z"}),/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M80,13.3l-9.9,22.7h-3l3.7-7.9l-6.5-14.7h3.2l4.7,11.3h0.1l4.6-11.3H80z"}),/*#__PURE__*/t("path",{style:{fill:"#4285F4"},d:"M25.9,17.7c0-0.9-0.1-1.8-0.2-2.7H13.2v5.1h7.1c-0.3,1.6-1.2,3.1-2.6,4v3.3H22C24.5,25.1,25.9,21.7,25.9,17.7z"}),/*#__PURE__*/t("path",{style:{fill:"#34A853"},d:"M13.2,30.6c3.6,0,6.6-1.2,8.8-3.2l-4.3-3.3c-1.2,0.8-2.7,1.3-4.5,1.3c-3.4,0-6.4-2.3-7.4-5.5H1.4v3.4 C3.7,27.8,8.2,30.6,13.2,30.6z"}),/*#__PURE__*/t("path",{style:{fill:"#FBBC04"},d:"M5.8,19.9c-0.6-1.6-0.6-3.4,0-5.1v-3.4H1.4c-1.9,3.7-1.9,8.1,0,11.9L5.8,19.9z"}),/*#__PURE__*/t("path",{style:{fill:"#EA4335"},d:"M13.2,9.4c1.9,0,3.7,0.7,5.1,2l0,0l3.8-3.8c-2.4-2.2-5.6-3.5-8.8-3.4c-5,0-9.6,2.8-11.8,7.3l4.4,3.4 C6.8,11.7,9.8,9.4,13.2,9.4z"})]}),tp=e=>{let[t,n]=s();return o((()=>{e().then((e=>{n(e)})).catch((()=>{}))}),[]),t},np=()=>window.open(void 0,void 0,rp({w:440,h:680}));let rp=({w:e,h:t})=>{let n=void 0!==window.screenLeft?window.screenLeft:window.screenX,r=void 0!==window.screenTop?window.screenTop:window.screenY,a=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,i=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;return`toolbar=0,location=0,menubar=0,height=${t},width=${e},popup=1,left=${(a-e)/2/(a/window.screen.availWidth)+n},top=${(i-t)/2/(i/window.screen.availHeight)+r}`};let ap={[Hr.id]:"ethereum",[Vr.id]:"base",[$r.id]:"optimism",[Gr.id]:"polygon",[qr.id]:"arbitrum"};const ip=(e,t,n,r,a,i)=>new Promise((async(o,s)=>{let l=np();if(!l)return void s(Error("Unable to initialize flow"));let c="ethereum"===t.chainType?function(e){let t=ap[e];if(!t)throw new E(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}(t.chain.id):"solana",d=t.isUSDC?"USDC":"ethereum"===t.chainType?"ETH":"SOL",h=await e.initCoinbaseOnRamp({addresses:[{address:t.address,blockchains:[c]}],assets:[d]}),{url:u}=Mi({input:h,amount:t.amount,blockchain:c,asset:d,experience:i});l.location=u.toString();let p={...a?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(p.usingDefaultFundingMethod=!1),n({funding:p,coinbaseOnrampStatus:{popup:l}}),r(br.COINBASE_ONRAMP_STATUS_SCREEN),e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),setTimeout((()=>{n({funding:p,coinbaseOnrampStatus:{partnerUserId:h.partner_user_id,popup:l}})}),5e3),o()})),op=async(e,t,n,r,a,i,o,s)=>{let l=np();if(!l)throw Error("Unable to initialize flow");let c="ethereum"===t.chainType?t.moonpayConfigOverride?.currencyCode??Ui(t.chain.id,r):"SOL",{signedUrl:d,externalTransactionId:h}=await e.signMoonpayOnRampUrl({address:t.address,useSandbox:n.fundingMethodConfig.moonpay.useSandbox??!1,config:{uiConfig:{accentColor:n.appearance.palette.accent,theme:n.appearance.palette.colorScheme},...t.moonpayConfigOverride,paymentMethod:s,currencyCode:c,quoteCurrencyAmount:t.moonpayConfigOverride?.quoteCurrencyAmount??Ea(t.amount)}});e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"moonpay",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),l.location=d;let u={...o?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(u.usingDefaultFundingMethod=!1),a({moonpayStatus:{},funding:u}),i(br.MOONPAY_STATUS_SCREEN),setTimeout((()=>{a({moonpayStatus:{externalTransactionId:h},funding:u})}),8e3)};let sp=async e=>"undefined"!=typeof window&&"PaymentRequest"in window&&await new window.PaymentRequest([{supportedMethods:e}],{id:"0",total:{label:"Item",amount:{currency:"USD",value:"1.00"}}}).canMakePayment();const lp=()=>sp("https://apple.com/apple-pay"),cp=()=>sp("https://google.com/pay");let dp=({...e})=>/*#__PURE__*/t(fs,{color:"black",...e}),hp={devnet:"Devnet","mainnet-beta":"Solana",testnet:"Testnet"};const up=({size:n=61,...r})=>/*#__PURE__*/t("svg",{width:n,height:n,viewBox:"0 0 61 61",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:/*#__PURE__*/e("g",{id:"moonpay_symbol_wht 2",children:[/*#__PURE__*/t("rect",{x:"1.3374",y:"1",width:"59",height:"59",rx:"11.5",fill:"#7715F5"}),/*#__PURE__*/t("path",{id:"Vector",d:"M43.8884 23.3258C45.0203 23.3258 46.1268 22.9901 47.068 22.3613C48.0091 21.7324 48.7427 20.8386 49.1759 19.7928C49.6091 18.747 49.7224 17.5962 49.5016 16.4861C49.2807 15.3759 48.7357 14.3561 47.9353 13.5557C47.1349 12.7553 46.1151 12.2102 45.0049 11.9893C43.8947 11.7685 42.7439 11.8819 41.6982 12.3151C40.6524 12.7482 39.7585 13.4818 39.1297 14.423C38.5008 15.3641 38.1651 16.4707 38.1651 17.6026C38.165 18.3542 38.3131 19.0985 38.6007 19.7929C38.8883 20.4873 39.3098 21.1182 39.8413 21.6496C40.3728 22.1811 41.0037 22.6027 41.6981 22.8903C42.3925 23.1778 43.1367 23.3259 43.8884 23.3258ZM26.3395 49.1017C23.5804 49.1017 20.8832 48.2836 18.5891 46.7507C16.295 45.2178 14.5069 43.039 13.4511 40.49C12.3952 37.9409 12.1189 35.1359 12.6572 32.4298C13.1955 29.7237 14.5241 27.238 16.4751 25.287C18.4262 23.336 20.9118 22.0074 23.6179 21.4691C26.324 20.9308 29.129 21.2071 31.6781 22.2629C34.2272 23.3189 36.406 25.1069 37.9389 27.401C39.4717 29.6952 40.2899 32.3923 40.2899 35.1514C40.2899 36.9835 39.9291 38.7975 39.2281 40.49C38.527 42.1826 37.4994 43.7205 36.204 45.0159C34.9086 46.3113 33.3707 47.3389 31.6781 48.04C29.9856 48.741 28.1715 49.1018 26.3395 49.1017Z",fill:"white"})]})});let pp=({status:r,onClickCta:a})=>{let{title:o,body:s,cta:l}=i((()=>(e=>{switch(e){case"completed":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"waitingAuthorization":return{title:"Processing payment",body:"This may take up to a few hours. You will receive an email when the purchase is complete.",cta:"Continue"};default:return{title:"In Progress",body:"Go back to MoonPay to finish funding your account.",cta:""}}})(r)),[r]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(gp,{children:[/*#__PURE__*/t(mp,{status:r}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t("h3",{children:o}),/*#__PURE__*/t(yp,{children:s})]})]}),l&&/*#__PURE__*/t(wt,{onClick:a,children:l})]})},mp=({status:n})=>{if(!n||"pending"===n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t(tn,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(vn,{color:n}),/*#__PURE__*/t(up,{size:"3rem",style:{position:"absolute",top:"1rem",left:"1rem"}})]})}let r=(e=>{switch(e){case"completed":return wi;case"waitingAuthorization":return()=>/*#__PURE__*/t(lo,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}});default:return}})(n),a=(e=>e?{completed:"var(--privy-color-success)",failed:"var(--privy-color-error)",serviceFailure:"var(--privy-color-error)",waitingAuthorization:"var(--privy-color-accent)",pending:"var(--privy-color-foreground-4)"}[e]:"var(--privy-color-foreground-4)")(n);/*#__PURE__*/return t("div",{style:{borderColor:a,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:r&&/*#__PURE__*/t(r,{width:"4rem",height:"4rem",color:a})})},yp=/*#__PURE__*/ii.p.withConfig({displayName:"StatusBody",componentId:"sc-56bea42a-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),gp=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-56bea42a-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const fp=({onClick:n,text:r})=>/*#__PURE__*/e(hl,{onClick:n,children:[/*#__PURE__*/t(di,{}),/*#__PURE__*/t(il,{children:r}),/*#__PURE__*/t(po,{})]});let wp=({onClick:n,icon:r,name:a,chainType:i})=>/*#__PURE__*/e(hl,{onClick:n,children:[/*#__PURE__*/t(Su,{style:{width:20},children:/*#__PURE__*/t("img",{src:r})}),a,/*#__PURE__*/t(Rt,{color:"gray",style:{marginLeft:"auto"},children:"Connected"}),"solana"===i&&/*#__PURE__*/t(Rt,{color:"gray",children:"Solana"})]});let vp=/*#__PURE__*/ii.div.withConfig({displayName:"StyledCircle",componentId:"sc-30eca48b-0"})(["border-radius:50%;height:68px;width:68px;display:flex;align-items:center;justify-content:center;background-color:var(--privy-color-accent);color:white;margin:0 auto 24px auto;"]);const Cp=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"17",height:"17",viewBox:"0 0 17 17",style:{height:"1.25rem",width:"1.25rem",...e},...n,children:/*#__PURE__*/t("path",{strokeLinecap:"round",strokeLinejoin:"round",fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 8.67993C16.5 9.82986 15.853 10.8287 14.9032 11.3322C15.2188 12.3599 14.97 13.5237 14.1569 14.3368C13.3437 15.1499 12.18 15.3987 11.1523 15.0831C10.6488 16.0329 9.64993 16.6799 8.5 16.6799C7.35007 16.6799 6.35126 16.0329 5.84771 15.0831C4.82003 15.3987 3.65627 15.1499 2.84314 14.3368C2.03001 13.5237 1.78124 12.3599 2.09681 11.3322C1.14699 10.8287 0.5 9.82986 0.5 8.67993C0.5 7.53 1.14699 6.53119 2.0968 6.02764C1.78125 4.99996 2.03003 3.83621 2.84315 3.02309C3.65627 2.20997 4.82002 1.96119 5.8477 2.27675C6.35125 1.32692 7.35007 0.679932 8.5 0.679932C9.64992 0.679932 10.6487 1.32691 11.1523 2.27672C12.18 1.96115 13.3437 2.20993 14.1569 3.02305C14.97 3.83618 15.2188 4.99996 14.9032 6.02764C15.853 6.53119 16.5 7.53 16.5 8.67993ZM12.2659 6.68856C12.5654 6.40238 12.5761 5.92763 12.29 5.62818C12.0038 5.32873 11.529 5.31797 11.2296 5.60416C9.73022 7.03711 8.40877 8.65489 7.3018 10.4211L5.78033 8.89963C5.48744 8.60673 5.01256 8.60673 4.71967 8.89963C4.42678 9.19252 4.42678 9.66739 4.71967 9.96029L6.92031 12.1609C7.08544 12.3261 7.31807 12.4048 7.54957 12.374C7.78106 12.3432 7.98499 12.2064 8.1012 12.0038C9.23027 10.0356 10.6362 8.24613 12.2659 6.68856Z",fill:"var(--privy-color-accent)"})}),Ep=/*#__PURE__*/ii.div.withConfig({displayName:"TodoList",componentId:"sc-491785d-0"})(["display:flex;flex-direction:column;justify-content:flex-start;gap:4px;"]),Tp=/*#__PURE__*/ii.div.withConfig({displayName:"TodoSpacer",componentId:"sc-491785d-1"})(["&&&{margin-left:7px;border-left:2px solid var(--privy-color-foreground-4);height:12px;}"]),bp=({children:n})=>/*#__PURE__*/e(Ap,{children:[/*#__PURE__*/t(Cp,{style:{width:"16px",height:"16px"}}),n]});let Ap=/*#__PURE__*/ii.div.withConfig({displayName:"TodoItemWrapper",componentId:"sc-491785d-2"})(["display:flex;justify-content:flex-start;justify-items:center;text-align:left;gap:8px;&&{a{text-decoration:underline;color:var(--privy-color-accent);}svg{margin-top:auto;margin-bottom:auto;}}"]),_p=({name:n,installLink:r,logo:a,logoDataUri:i})=>/*#__PURE__*/e(kp,{children:[/*#__PURE__*/t(nc,{title:`Create a ${n} wallet`,description:"Follow the instructions below to get started."}),!!a&&/*#__PURE__*/t(Qt,{children:/*#__PURE__*/t(a,{style:{width:"152px",height:"152px"}})}),!a&&!!i&&/*#__PURE__*/t(Qt,{children:/*#__PURE__*/t("img",{src:i,alt:n,style:{width:"152px",height:"152px"}})}),/*#__PURE__*/e(Ep,{children:[/*#__PURE__*/t(bp,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t("span",{children:"Install the "})," ",/*#__PURE__*/e("a",{href:r,target:"_blank",children:[n," browser extension"]})]})}),/*#__PURE__*/t(Tp,{}),/*#__PURE__*/t(bp,{children:"Set up your first wallet"}),/*#__PURE__*/t(Tp,{}),/*#__PURE__*/t(bp,{children:"Store your recovery phrase in a safe place!"})]}),/*#__PURE__*/t(kn,{onClick:()=>window.location.reload(),children:"Reload the page to use your wallet"})]});let kp=/*#__PURE__*/ii(Qt).withConfig({displayName:"CreateWalletContainer",componentId:"sc-4eba1dc8-0"})(["gap:30px;> :first-child > svg{margin-top:20px;}"]),Ip={apple_oauth:"apple",custom_auth:"custom",discord_oauth:"discord",email:"email",farcaster:"farcaster",github_oauth:"github",google_oauth:"google",instagram_oauth:"instagram",linkedin_oauth:"linkedin",passkey:"passkey",phone:"sms",spotify_oauth:"spotify",telegram:"telegram",tiktok_oauth:"tiktok",twitter_oauth:"twitter",wallet:"siwe",smart_wallet:"siwe",cross_app:"privy:",guest:"guest"};const Np=e=>{let t=Ip[e];return"wallet"===e||"phone"===e?{displayName:e,loginMethod:t}:{displayName:t,loginMethod:t}},xp=()=>{let{app:e}=Tr(),n=e?.appearance?.logo,r=`${e?.name} logo`,i={maxHeight:"90px",maxWidth:"180px"};return n?"string"==typeof n?/*#__PURE__*/t("img",{src:n,alt:r,style:i}):"svg"===n.type||"img"===n.type?/*#__PURE__*/a.cloneElement(n,{alt:r,style:i}):(console.warn("`config.appearance.logo` must be a string, or an SVG / IMG element. Nothing will be rendered."),null):null},Sp=e=>{let{app:n}=Tr();return n?.appearance.logo?/*#__PURE__*/t(Rp,{...e,children:/*#__PURE__*/t(xp,{})}):null},Rp=/*#__PURE__*/ii.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a206bd44-0"})(["display:flex;flex-direction:column;align-items:center;padding:24px 0;flex-grow:1;justify-content:center;"]),Op=({appId:r})=>{let[a,i]=s(void 0),{startCrossAppAuthFlow:l,authenticated:c}=_r(),{client:d}=N();return o((()=>{(async()=>{d&&i(await d.getCrossAppProviderDetails(r))})()}),[d]),/*#__PURE__*/t(hl,{onClick:()=>l({appId:r,action:c?"link":"login"}),disabled:!a,children:a?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Mc,{name:a.name,logoUrl:a.icon_url||void 0,size:"24px"})," ",a.name]}):/*#__PURE__*/t(sn,{})})},Wp=/*#__PURE__*/h(((r,a)=>{let[i,l]=s(r.defaultValue||""),[c,d]=s(""),[h,u]=s(!1),{authenticated:p}=_r(),{initLoginWithEmail:m}=N(),{navigate:y,setModalData:g,currentScreen:f,data:w}=Tr(),{enabled:v,token:C}=gt(),[E,T]=s(!1),{accountType:A}=It(),_=Ar();o((()=>{!i&&_.disablePlusEmails&&w?.inlineError?.error instanceof O&&w?.inlineError?.error.privyErrorCode===b.DISALLOWED_PLUS_EMAIL&&!c&&d("Please enter a valid email address without a '+'."),c&&d("")}),[i]);let k=In(i),I=h||!k,x=()=>{g({inlineError:void 0}),!v||C||p?(e=>{u(!0),m({email:i,captchaToken:e,disableSignup:w?.login?.disableSignup,withPrivyUi:!0}).then((()=>{y(br.AWAITING_PASSWORDLESS_CODE)})).catch((e=>{g({errorModalData:{error:e,previousScreen:f||br.LANDING}}),y(br.ERROR_SCREEN)})).finally((()=>{u(!1)}))})(C):(g({captchaModalData:{callback:e=>m({email:i,captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:br.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:br.ERROR_SCREEN}}),y(br.CAPTCHA_SCREEN))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(Lp,{children:[c&&/*#__PURE__*/t(dn,{style:{display:"block",marginTop:"0.25rem",textAlign:"left"},children:c}),/*#__PURE__*/e(Pp,{stacked:r.stacked,$error:!!c,children:[/*#__PURE__*/t(gi,{}),/*#__PURE__*/t("input",{ref:a,id:"email-input",className:"login-method-button",type:"email",placeholder:"your@email.com",onFocus:()=>T(!0),onChange:e=>l(e.target.value),onKeyUp:e=>{"Enter"===e.key&&x()},value:i,autoComplete:"email"}),"email"!==A||E?r.stacked?/*#__PURE__*/t("span",{}):/*#__PURE__*/t(Nn,{isSubmitting:h,onClick:x,disabled:I,children:"Submit"}):/*#__PURE__*/t(Rt,{color:"gray",children:"Recent"})]})]}),r.stacked?/*#__PURE__*/t(wt,{loadingText:null,loading:h,disabled:I,onClick:x,children:"Submit"}):null]})}));let Lp=xn,Pp=Sn;const Mp=({isEditable:r,setIsEditable:a,defaultValue:i})=>{let o=l(null);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(pl,{$if:!r,children:/*#__PURE__*/t(Wp,{ref:o,defaultValue:i})}),/*#__PURE__*/t(pl,{$if:r,children:/*#__PURE__*/e(hl,{onClick:()=>{a(),setTimeout((()=>{o.current?.focus()}),0)},children:[/*#__PURE__*/t(gi,{})," Continue with Email"]})})]})},Up=()=>{let[n,r]=s(!1),{currentScreen:a,navigate:i,setModalData:o,data:l}=Tr(),{enabled:c,token:d}=gt(),{initLoginWithFarcaster:h}=N(),{accountType:u}=It();/*#__PURE__*/return e(hl,{onClick:async()=>{r(!0);try{c&&!d?(o({captchaModalData:{callback:e=>h(e,l?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:br.AWAITING_FARCASTER_CONNECTION,onErrorNavigateTo:br.ERROR_SCREEN}}),i(br.CAPTCHA_SCREEN)):(await h(d,l?.login?.disableSignup),i(br.AWAITING_FARCASTER_CONNECTION))}catch(e){o({errorModalData:{error:e,previousScreen:a||br.LANDING}}),i(br.ERROR_SCREEN)}finally{r(!1)}},disabled:!1,children:[/*#__PURE__*/t(bh,{})," Farcaster",n&&/*#__PURE__*/t(sn,{}),"farcaster"===u&&/*#__PURE__*/t(Dp,{color:"gray",children:"Recent"})]})};let Dp=/*#__PURE__*/ii(Rt).withConfig({displayName:"StyledChip",componentId:"sc-19f52850-0"})(["margin-left:auto;"]);const Fp=({...n})=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...n,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_2856_1743)",children:[/*#__PURE__*/t("path",{d:"M22.1673 8.24075V16.3642C22.1673 17.3256 21.3421 18.105 20.3241 18.105H17.0028M22.1673 8.24075C22.1673 7.27936 21.3421 6.5 20.3241 6.5H11.5302M22.1673 8.24075V8.42852C22.1673 9.03302 21.8352 9.59423 21.2901 9.91105L15.1463 13.4818C14.5539 13.8261 13.8067 13.8261 13.2143 13.4818L10.1621 11.5401",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),/*#__PURE__*/t("path",{d:"M3.12913 6.64816C0.508085 12.9507 3.49251 20.1847 9.79504 22.8057L11.5068 23.5176C12.4522 23.9108 13.7783 23.2222 14.1714 22.2768L14.6054 21.2333C14.7687 20.8406 14.6438 20.3871 14.3024 20.1334L11.2872 17.8927C10.9878 17.6702 10.5843 17.6488 10.2632 17.8384L9.11575 18.5156C8.78274 18.7121 8.3597 18.6844 8.07552 18.4221C5.94293 16.4542 4.77629 13.6264 4.90096 10.7273C4.91757 10.3409 5.19796 10.023 5.57269 9.92753L6.86381 9.59869C7.22522 9.50664 7.49627 9.20696 7.55169 8.83815L8.10986 5.12321C8.17306 4.70259 7.94188 4.29293 7.54915 4.1296L6.50564 3.69564C5.56026 3.30248 4.23416 3.99103 3.84101 4.9364L3.12913 6.64816Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_2856_1743",children:/*#__PURE__*/t("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]}),Bp=()=>{let{enabled:n,token:r}=gt(),{navigate:a,setModalData:o,app:s,data:l}=Tr(),{initLoginWithPasskey:c}=N(),d=()=>{s.loginConfig.passkeysForSignupEnabled?a(br.SELECT_PASSKEY_SIGNUP_OR_LOGIN):(async()=>{n&&!r?(o({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>c({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:br.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:br.ERROR_SCREEN}}),a(br.CAPTCHA_SCREEN)):(await c({withPrivyUi:!0}),o({passkeyAuthModalData:{passkeySignupFlow:!1}}),a(br.AWAITING_PASSKEY_SYSTEM_DIALOGUE))})()};return 0===i((()=>{let e=l?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(s.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[s.loginMethods,l?.login])?/*#__PURE__*/e(hl,{onClick:d,children:[/*#__PURE__*/t(mo,{})," Continue with passkey"]}):/*#__PURE__*/t(Hp,{onClick:d,children:"I have a passkey"})};let zp=/*#__PURE__*/oi(["&&{width:100%;font-size:0.875rem;line-height:1rem;display:flex;gap:0.5rem;justify-content:center;align-items:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]);const Hp=/*#__PURE__*/ii.button.withConfig({displayName:"StyledLink",componentId:"sc-48dad958-0"})(["",""],zp),Vp=({value:n,onChange:r})=>/*#__PURE__*/t("select",{value:n,onChange:r,children:Hi.map((t=>/*#__PURE__*/e("option",{value:t.code,children:[t.code," +",t.callCode]},t.code)))}),$p=/*#__PURE__*/h(((r,a)=>{let{app:i}=Tr(),[l,c]=s(!1),{accountType:d}=It(),[h,u]=s(""),[p,m]=s(i?.intl.defaultCountry??"US"),y=Vi(h,p),g=$i(p),f=Gi(p),w=qi(p),v=!y,[C,E]=s(!1),T=w.length,b=e=>{let t=e.target.value;m(t),u(""),r.onChange&&r.onChange({rawPhoneNumber:h,qualifiedPhoneNumber:Ki(h,t),countryCode:t,isValid:Vi(h,p)})},A=(e,t)=>{try{let n=e.replace(/\D/g,"")===h.replace(/\D/g,"")?e:g.input(e);u(n),r.onChange&&r.onChange({rawPhoneNumber:n,qualifiedPhoneNumber:Ki(e,t),countryCode:t,isValid:Vi(e,t)})}catch(e){console.error("Error processing phone number:",e)}},_=()=>{E(!0);let e=Ki(h,p);r.onSubmit({rawPhoneNumber:h,qualifiedPhoneNumber:e,countryCode:p,isValid:Vi(h,p)}).finally((()=>E(!1)))};return o((()=>{if(r.defaultValue){let e=ji(r.defaultValue);g.reset(),b({target:{value:e.countryCode}}),A(e.phone,e.countryCode)}}),[r.defaultValue]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Gp,{children:/*#__PURE__*/e(qp,{$callingCodeLength:T,$stacked:r.stacked,children:[/*#__PURE__*/t(Vp,{value:p,onChange:b}),/*#__PURE__*/t("input",{ref:a,id:"phone-number-input",className:"login-method-button",type:"tel",placeholder:f,onFocus:()=>c(!0),onChange:e=>{A(e.target.value,p)},onKeyUp:e=>{"Enter"===e.key&&_()},value:h,autoComplete:"tel"}),"phone"!==d||l||r.hideRecent?r.stacked||r.noIncludeSubmitButton?/*#__PURE__*/t("span",{}):/*#__PURE__*/t(Nn,{isSubmitting:C,onClick:_,disabled:v,children:"Submit"}):/*#__PURE__*/t(Rt,{color:"gray",children:"Recent"})]})}),r.stacked&&!r.noIncludeSubmitButton?/*#__PURE__*/t(wt,{loading:C,loadingText:null,onClick:_,disabled:v,children:"Submit"}):null]})}));let Gp=/*#__PURE__*/ii.div.withConfig({displayName:"InputContainer",componentId:"sc-2a729487-0"})(["width:100%;"]),qp=/*#__PURE__*/ii.label.withConfig({displayName:"PhoneNumberInput",componentId:"sc-2a729487-1"})(["--country-code-dropdown-width:calc(54px + calc(12 * ","px));--phone-input-extra-padding-left:calc(12px + calc(3 * ","px));display:block;position:relative;width:100%;@media (min-width:441px){--country-code-dropdown-width:calc(52px + calc(10 * ","px));}&& > select{font-size:16px;height:24px;position:absolute;margin:13px calc(var(--country-code-dropdown-width) / 4);line-height:24px;width:var(--country-code-dropdown-width);background-color:var(--privy-color-background);background-size:auto;background-position-x:right;cursor:pointer;@media (min-width:441px){font-size:14px;width:var(--country-code-dropdown-width);}:focus{outline:none;box-shadow:none;}}&& > input{font-size:16px;line-height:24px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width:calc(100% - var(--country-code-dropdown-width));padding:12px 88px 12px calc(var(--country-code-dropdown-width) + var(--phone-input-extra-padding-left));padding-right:",";flex-grow:1;background:var(--privy-color-background);border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-mdlg);width:100%;:focus{outline:none;border-color:var(--privy-color-accent);}:autofill,:-webkit-autofill{background:var(--privy-color-background);}@media (min-width:441px){font-size:14px;padding-right:78px;}}&& > :last-child{right:16px;position:absolute;top:50%;transform:translate(0,-50%);}&& > button:last-child{right:0px;line-height:24px;padding:13px 17px;:focus{outline:none;border-color:var(--privy-color-accent);}}&& > input::placeholder{color:var(--privy-color-foreground-3);}"],(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$stacked?"16px":"88px"));const jp=({isEditable:r,setIsEditable:a,defaultValue:i})=>{let o=l(null),{authenticated:s}=_r(),{navigate:c,setModalData:d,currentScreen:h,data:u}=Tr(),{initLoginWithSms:p}=N(),{enabled:m,token:y}=gt();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(pl,{$if:!r,children:/*#__PURE__*/t($p,{ref:o,onSubmit:async function({qualifiedPhoneNumber:e}){if(!m||y||s)try{await p({phoneNumber:e,captchaToken:y,withPrivyUi:!0,disableSignup:u?.login?.disableSignup}),c(br.AWAITING_PASSWORDLESS_CODE)}catch(e){d({errorModalData:{error:e,previousScreen:h||br.LANDING}}),c(br.ERROR_SCREEN)}else d({captchaModalData:{callback:t=>p({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:u?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:br.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:br.ERROR_SCREEN}}),c(br.CAPTCHA_SCREEN)},defaultValue:i})}),/*#__PURE__*/t(pl,{$if:r,children:/*#__PURE__*/e(hl,{onClick:()=>{a(),setTimeout((()=>{o.current?.focus()}),0)},children:[/*#__PURE__*/t(fi,{})," Continue with SMS"]})})]})};let Kp={apple:{logo:/*#__PURE__*/t($o,{}),displayName:"Apple"},discord:{logo:/*#__PURE__*/t(Go,{}),displayName:"Discord"},github:{logo:/*#__PURE__*/t(qo,{}),displayName:"GitHub"},google:{logo:/*#__PURE__*/t(Ko,{}),displayName:"Google"},linkedin:{logo:/*#__PURE__*/t(Zo,{}),displayName:"LinkedIn"},spotify:{logo:/*#__PURE__*/t(Xo,{}),displayName:"Spotify"},instagram:{logo:/*#__PURE__*/t(Yo,{}),displayName:"Instagram"},twitter:{logo:/*#__PURE__*/t(Jo,{}),displayName:"Twitter"},tiktok:{logo:/*#__PURE__*/t(Qo,{}),displayName:"TikTok"}};const Yp=({provider:n})=>{let{enabled:r,token:a}=gt(),{navigate:i,setModalData:o,data:l}=Tr(),[c,d]=s(!1),{initLoginWithOAuth:h}=N(),{accountType:u}=It(),p=u?Np(u):null,{displayName:m,logo:y}=Kp[n];/*#__PURE__*/return e(hl,{onClick:()=>{d(!0),r&&!a?(o({captchaModalData:{callback:e=>h(n,e,l?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:br.ERROR_SCREEN}}),i(br.CAPTCHA_SCREEN)):h(n,void 0,l?.login?.disableSignup)},disabled:c,children:[y," ",m,p?.loginMethod===n&&/*#__PURE__*/t(Zp,{color:"gray",children:"Recent"})]})};let Zp=/*#__PURE__*/ii(Rt).withConfig({displayName:"StyledChip",componentId:"sc-7d3bb993-0"})(["margin-left:auto;"]);function Xp(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 240 240",...n,children:[/*#__PURE__*/t("defs",{children:/*#__PURE__*/e("linearGradient",{x1:"120",y1:"240",x2:"120",gradientUnits:"userSpaceOnUse",id:"telegram-linear-gradient",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#1d93d2"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#38b0e3"})]})}),/*#__PURE__*/t("title",{children:"Telegram_logo"}),/*#__PURE__*/t("circle",{cx:"120",cy:"120",r:"120",fill:"url(#telegram-linear-gradient)"}),/*#__PURE__*/t("path",{d:"M81.229,128.772l14.237,39.406s1.78,3.687,3.686,3.687,30.255-29.492,30.255-29.492l31.525-60.89L81.737,118.6Z",fill:"#c8daea"}),/*#__PURE__*/t("path",{d:"M100.106,138.878l-2.733,29.046s-1.144,8.9,7.754,0,17.415-15.763,17.415-15.763",fill:"#a9c6d8"}),/*#__PURE__*/t("path",{d:"M81.486,130.178,52.2,120.636s-3.5-1.42-2.373-4.64c.232-.664.7-1.229,2.1-2.2,6.489-4.523,120.106-45.36,120.106-45.36s3.208-1.081,5.1-.362a2.766,2.766,0,0,1,1.885,2.055,9.357,9.357,0,0,1,.254,2.585c-.009.752-.1,1.449-.169,2.542-.692,11.165-21.4,94.493-21.4,94.493s-1.239,4.876-5.678,5.043A8.13,8.13,0,0,1,146.1,172.5c-8.711-7.493-38.819-27.727-45.472-32.177a1.27,1.27,0,0,1-.546-.9c-.093-.469.417-1.05.417-1.05s52.426-46.6,53.821-51.492c.108-.379-.3-.566-.848-.4-3.482,1.281-63.844,39.4-70.506,43.607A3.21,3.21,0,0,1,81.486,130.178Z",fill:"#fff"})]})}const Qp=()=>{let{enabled:n,token:r}=gt(),{navigate:a,setModalData:i,data:o}=Tr(),[l,c]=s(!1),{initLoginWithTelegram:d}=N(),{accountType:h}=It();async function u(e){try{await d(e,o?.login?.disableSignup),i({telegramAuthModalData:{seamlessAuth:!1}}),a(br.TELEGRAM_AUTH_SCREEN)}catch(e){console.error(e),c(!1)}}/*#__PURE__*/return e(hl,{onClick:async function(){if(c(!0),n&&!r)return i({captchaModalData:{callback:u,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:br.ERROR_SCREEN}}),void a(br.CAPTCHA_SCREEN);await u(r)},disabled:l,children:[/*#__PURE__*/t(Xp,{}),"Telegram","telegram"===h&&/*#__PURE__*/t(Jp,{color:"gray",children:"Recent"})]})};let Jp=/*#__PURE__*/ii(Rt).withConfig({displayName:"StyledChip",componentId:"sc-f716a3a1-0"})(["margin-left:auto;"]);const em=({onClick:n,text:r,icon:a})=>/*#__PURE__*/e(hl,{onClick:n,children:[a,/*#__PURE__*/t(il,{children:r}),/*#__PURE__*/t(po,{})]}),tm=({connectOnly:r})=>{let{closePrivyModal:a,connectors:l}=N(),{data:c,onUserCloseViaDialogOrKeybindRef:d}=Tr(),h=Ar(),{accountType:u,walletClientType:p,chainType:m}=It(),y=u?Np(u):null,g=c?.login,{email:f,sms:w,google:v,twitter:C,discord:E,github:T,spotify:b,instagram:A,tiktok:_,linkedin:k,apple:I,wallet:x,farcaster:S,telegram:R}=i((()=>g?.loginMethods?Yi(g.loginMethods,!0):null),[g])??h.loginMethods,{passkey:O}=h.loginMethods,W=[f&&"email",w&&"sms",v&&"google",C&&"twitter",E&&"discord",T&&"github",b&&"spotify",A&&"instagram",_&&"tiktok",k&&"linkedin",I&&"apple",S&&"farcaster",R&&"telegram"].filter((e=>!!e)),L=W.length>0,P=i((()=>x&&!L?"web3-first":x&&h?.appearance.loginGroupPriority||"web2-first"),[x,L,h?.appearance.loginGroupPriority]),M=h?.appearance.hideDirectWeb2Inputs,[U,D]=s("default"),[F,B]=s(om({mostRecentlyUsedAccountType:u,smsAvailable:w,emailAvailable:f,prefilledType:g?.prefill?.type}));o((()=>{B(om({mostRecentlyUsedAccountType:u,smsAvailable:w,emailAvailable:f,prefilledType:g?.prefill?.type}))}),[f,w,u]);let z=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{D("default")}),150)};d.current=z;let H=[];p&&x?H.push(p):y?.loginMethod&&W.includes(y.loginMethod)&&H.push(y.loginMethod);let V=e=>"email"===e?/*#__PURE__*/t(Mp,{isEditable:"email"===F,setIsEditable:()=>{B("email")},defaultValue:"email"===g?.prefill?.type?g.prefill.value:void 0},e):"sms"===e?/*#__PURE__*/t(jp,{isEditable:"sms"===F,setIsEditable:()=>{B("sms")},defaultValue:"phone"===g?.prefill?.type?g.prefill.value:void 0},e):"apple"===e?/*#__PURE__*/t(Yp,{provider:"apple"},e):"discord"===e?/*#__PURE__*/t(Yp,{provider:"discord"},e):"farcaster"===e?/*#__PURE__*/t(Up,{},e):"github"===e?/*#__PURE__*/t(Yp,{provider:"github"},e):"google"===e?/*#__PURE__*/t(Yp,{provider:"google"},e):"linkedin"===e?/*#__PURE__*/t(Yp,{provider:"linkedin"},e):"tiktok"===e?/*#__PURE__*/t(Yp,{provider:"tiktok"},e):"spotify"===e?/*#__PURE__*/t(Yp,{provider:"spotify"},e):"instagram"===e?/*#__PURE__*/t(Yp,{provider:"instagram"},e):"twitter"===e?/*#__PURE__*/t(Yp,{provider:"twitter"},e):"telegram"===e?/*#__PURE__*/t(Qp,{},e):Lc({walletList:h.appearance.walletList,walletChainType:g?.walletChainType??h.appearance.walletChainType,connectors:l,connectOnly:r,ignore:[],walletConnectEnabled:h.externalWallets.walletConnect.enabled,forceWallet:{wallet:e,chainType:m??"ethereum"}}),$=Lc({walletList:h.appearance.walletList.filter((e=>e!==p)),walletChainType:g?.walletChainType??h.appearance.walletChainType,connectors:l,connectOnly:r,ignore:[...h.appearance.walletList,p],walletConnectEnabled:h.externalWallets.walletConnect.enabled}),G=W.filter((e=>e!==y?.loginMethod)).flatMap(V),q=H.flatMap(V);"web3-first"===P&&"default"===U?$.unshift(...q):"web2-first"===P&&G.unshift(...q);let j=W.filter((e=>"email"!==e&&"sms"!==e)),K=rm({priority:P,email:f,sms:w,social:j}),Y=am({priority:P,email:f,sms:w,social:j}),Z=/*#__PURE__*/t(fp,{text:im({priority:P}),onClick:()=>D("web3-overflow")}),X=/*#__PURE__*/t(em,{text:K,icon:Y,onClick:()=>D("web2-overflow")}),Q=M?0:1,J=x&&$.length>0,ee=0===G.length&&x&&0===$.length,te=5-(J?1:0),ne=$.length>0?$:/*#__PURE__*/t(Tc,{chainType:h.appearance.walletChainType,withPadding:!0});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{title:h.appearance.landingHeader,onClose:z,backFn:"default"===U?void 0:()=>{D("default")}}),"default"===U&&/*#__PURE__*/t(nm,{}),"default"===U&&("string"==typeof h.appearance.loginMessage?/*#__PURE__*/t(dl,{children:h.appearance.loginMessage}):h.appearance.loginMessage),/*#__PURE__*/t(ol,{style:{overflow:"hidden",padding:2},children:/*#__PURE__*/e(sl,{children:["default"===U&&"web2-first"===P&&/*#__PURE__*/e(n,{children:[G.length>te?G.slice(0,te-1):G,G.length>te&&X,J&&Z,ee&&/*#__PURE__*/t(Tc,{chainType:h.appearance.walletChainType})]}),"default"===U&&"web3-first"===P&&/*#__PURE__*/e(n,{children:[x&&/*#__PURE__*/e(n,{children:[$.length>te?$.slice(0,te-1):$,$.length>te&&Z]}),G.length>Q&&X,G.length===Q&&G[0],ee&&/*#__PURE__*/t(Tc,{chainType:h.appearance.walletChainType})]}),"web2-overflow"===U&&/*#__PURE__*/t(n,{children:"web3-first"===P?G:G.slice(3)}),"web3-overflow"===U?ne:[],O&&"default"===U&&/*#__PURE__*/t(Bp,{})]})}),h&&/*#__PURE__*/t(Wt,{app:h}),/*#__PURE__*/t(Ct,{})]})};let nm=/*#__PURE__*/ii(Sp).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-65cd3bf6-0"})(["margin-bottom:16px;"]),rm=({priority:e,email:t,sms:n,social:r})=>"web2-first"===e?"Other socials":t&&n&&r.length>0||t&&r.length>0?"Log in with email or socials":n&&r.length>0?"Log in with sms or socials":t&&n?"Continue with email or sms":t?"Continue with email":n?"Continue with sms":"Log in with a social account",am=({priority:e,email:n,sms:r,social:a})=>"web2-first"===e||a.length>0?/*#__PURE__*/t(Wi,{}):n&&r?/*#__PURE__*/t(Fp,{}):n?/*#__PURE__*/t(gi,{}):r?/*#__PURE__*/t(fi,{}):null,im=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const om=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:n,prefilledType:r})=>n&&("email"===e&&"phone"!==r||"email"===r)||!t||"phone"!==e&&"phone"!==r?"email":"sms",sm=({connectOnly:r})=>{let{closePrivyModal:a,connectors:l}=N(),{app:c,onUserCloseViaDialogOrKeybindRef:d,data:h}=Tr(),{appearance:{palette:{colorScheme:u}}}=Ar(),{accountType:p,walletClientType:m,chainType:y}=It(),g=p?Np(p):null,f=c.loginMethodsAndOrder?.primary??[],w=c.loginMethodsAndOrder?.overflow??[],v=i((()=>[...f,...w]),[f,w]),C=c.loginMethods.passkey,E=h?.login,T=[];m&&v.includes(m)?T.push(m):p&&v.includes(g?.loginMethod)&&T.push(g?.loginMethod);let[b,A]=s("default"),[_,k]=s(om({mostRecentlyUsedAccountType:p,smsAvailable:v.includes("sms"),emailAvailable:v.includes("email"),prefilledType:E?.prefill?.type}));o((()=>{k(om({mostRecentlyUsedAccountType:p,smsAvailable:v.includes("sms"),emailAvailable:v.includes("email"),prefilledType:E?.prefill?.type}))}),[v,p]),o((()=>{"phone"===p&&k("sms");let e=v.indexOf("sms"),t=v.indexOf("email");e>-1&&e<t&&k("sms")}),[p,f,w]);let I=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{A("default")}),150)};d.current=I;let x=e=>"email"===e?/*#__PURE__*/t(Mp,{isEditable:"email"===_,setIsEditable:()=>{k("email")},defaultValue:"email"===E?.prefill?.type?E.prefill.value:void 0},e):"sms"===e?/*#__PURE__*/t(jp,{isEditable:"sms"===_,setIsEditable:()=>{k("sms")},defaultValue:"phone"===E?.prefill?.type?E.prefill.value:void 0},e):"apple"===e?/*#__PURE__*/t(Yp,{provider:"apple"},e):"discord"===e?/*#__PURE__*/t(Yp,{provider:"discord"},e):"farcaster"===e?/*#__PURE__*/t(Up,{},e):"github"===e?/*#__PURE__*/t(Yp,{provider:"github"},e):"google"===e?/*#__PURE__*/t(Yp,{provider:"google"},e):"linkedin"===e?/*#__PURE__*/t(Yp,{provider:"linkedin"},e):"spotify"===e?/*#__PURE__*/t(Yp,{provider:"spotify"},e):"instagram"===e?/*#__PURE__*/t(Yp,{provider:"instagram"},e):"tiktok"===e?/*#__PURE__*/t(Yp,{provider:"tiktok"},e):"twitter"===e?/*#__PURE__*/t(Yp,{provider:"twitter"},e):"telegram"===e?/*#__PURE__*/t(Qp,{},e):e.startsWith("privy:")?/*#__PURE__*/t(Op,{appId:e.replace("privy:","")},e):Lc({walletList:c.appearance.walletList,walletChainType:E?.walletChainType??c.appearance.walletChainType,connectors:l,connectOnly:r,ignore:v,walletConnectEnabled:c.externalWallets.walletConnect.enabled,forceWallet:{wallet:e,chainType:y??"ethereum"}}),S=T.flatMap(x),R=f.filter((e=>e!==m&&e!==g?.loginMethod)).flatMap(x),O=w.filter((e=>e!==m&&e!==g?.loginMethod)).flatMap(x),[W,L]=Rn([...S,...R,...O],lm({primary:R.length+S.length,overflow:O.length}));/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{title:c.appearance.landingHeader,onClose:I,backFn:"default"===b?void 0:()=>{A("default")}}),"default"===b&&/*#__PURE__*/t(cm,{}),"default"===b&&("string"==typeof c.appearance.loginMessage?/*#__PURE__*/t(dl,{children:c.appearance.loginMessage}):c.appearance.loginMessage),/*#__PURE__*/t(ol,{style:{overflow:"hidden"},children:/*#__PURE__*/e(ll,{$colorScheme:u,style:{maxHeight:400,overflowY:"scroll",padding:2},children:["default"===b&&/*#__PURE__*/e(n,{children:[W,L.length>0&&/*#__PURE__*/t(em,{text:"More options",icon:/*#__PURE__*/t(Wi,{}),onClick:()=>A("overflow")})]}),"overflow"===b&&/*#__PURE__*/t(n,{children:L}),C&&"default"===b&&/*#__PURE__*/t(Bp,{})]})}),c&&/*#__PURE__*/t(Wt,{app:c}),/*#__PURE__*/t(Ct,{})]})};let lm=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,cm=/*#__PURE__*/ii(Sp).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-c7a2d9e3-0"})(["margin-bottom:16px;"]);const dm=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"164",height:"164",viewBox:"0 0 164 164",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...n},...r,children:[/*#__PURE__*/t("circle",{cx:"82",cy:"82",r:"80",stroke:"#EC6351","stroke-width":"4","stroke-linecap":"round"}),/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M81.9999 100.788C93.3288 100.788 102.513 91.6043 102.513 80.2754C102.513 68.9465 93.3288 59.7626 81.9999 59.7626C70.671 59.7626 61.4871 68.9465 61.4871 80.2754C61.4871 91.6043 70.671 100.788 81.9999 100.788ZM88.3236 71.8304C88.9093 71.2446 89.8591 71.2446 90.4449 71.8304C91.0307 72.4161 91.0307 73.3659 90.4449 73.9517L84.121 80.2756L90.445 86.5996C91.0308 87.1854 91.0308 88.1351 90.445 88.7209C89.8592 89.3067 88.9095 89.3067 88.3237 88.7209L81.9997 82.3969L75.6756 88.7209C75.0899 89.3067 74.1401 89.3067 73.5543 88.7209C72.9685 88.1351 72.9685 87.1854 73.5543 86.5996L79.8783 80.2756L73.5544 73.9517C72.9686 73.3659 72.9686 72.4161 73.5544 71.8304C74.1402 71.2446 75.09 71.2446 75.6758 71.8304L81.9997 78.1543L88.3236 71.8304Z",fill:"#EC6351"})]});function hm(){let{promptMfa:e,init:t,submit:n,cancel:r,mfaMethods:a}=u(jr);return{promptMfa:e,init:t,submit:n,cancel:r,mfaMethods:a}}function um(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenroll:o,enrollInMfa:s}=u(jr);return{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenrollWithSms:()=>o("sms"),unenrollWithTotp:()=>o("totp"),unenrollWithPasskey:e=>o("passkey",e),showMfaEnrollmentModal:()=>s(!0),closeMfaEnrollmentModal:()=>s(!1)}}const pm=n=>/*#__PURE__*/e(mm,{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"88",height:"89",viewBox:"0 0 88 89",...n,children:[/*#__PURE__*/t("rect",{y:"0.666016",width:"88",height:"88",rx:"44"}),/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M45.2463 20.9106C44.5473 20.2486 43.4527 20.2486 42.7537 20.9106C37.8798 25.5263 31.3034 28.3546 24.0625 28.3546C23.9473 28.3546 23.8323 28.3539 23.7174 28.3525C22.9263 28.3427 22.2202 28.8471 21.9731 29.5987C20.9761 32.6311 20.4375 35.8693 20.4375 39.2297C20.4375 53.5896 30.259 65.651 43.5482 69.0714C43.8446 69.1477 44.1554 69.1477 44.4518 69.0714C57.741 65.651 67.5625 53.5896 67.5625 39.2297C67.5625 35.8693 67.0239 32.6311 66.0269 29.5987C65.7798 28.8471 65.0737 28.3427 64.2826 28.3525C64.1677 28.3539 64.0527 28.3546 63.9375 28.3546C56.6966 28.3546 50.1202 25.5263 45.2463 20.9106ZM52.7249 40.2829C53.3067 39.4683 53.1181 38.3363 52.3035 37.7545C51.4889 37.1726 50.3569 37.3613 49.7751 38.1759L41.9562 49.1223L38.0316 45.1977C37.3238 44.4899 36.1762 44.4899 35.4684 45.1977C34.7605 45.9056 34.7605 47.0532 35.4684 47.761L40.9059 53.1985C41.2826 53.5752 41.806 53.7671 42.337 53.7232C42.868 53.6792 43.3527 53.4039 43.6624 52.9704L52.7249 40.2829Z"})]});let mm=/*#__PURE__*/ii.svg.withConfig({displayName:"StyledSvg",componentId:"sc-59fa943f-0"})(["height:90px;width:90px;> rect{","}> path{fill:white;}"],(e=>"success"===e.color?"fill: var(--privy-color-success);":"fill: var(--privy-color-accent);"));const ym=({showIntro:r,userMfaMethods:a,appMfaMethods:i,userHasAuthSms:o,isTotpLoading:s,isPasskeyLoading:l,error:c,onClose:d,onBackToIntro:h,handleSelectMethod:u,setRemovingMfaMethod:p})=>{let m=a.reduce(((e,t)=>({...e,[t]:!0})),{}),y=i.reduce(((e,t)=>({...e,[t]:!0})),{});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:r?h:void 0,onClose:d},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(wo,{})}),/*#__PURE__*/t(Ll,{children:"Choose a verification method"}),a.length>0?/*#__PURE__*/t(Pl,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/t(Pl,{children:"How would you like to verify your identity? You can change this later."}),c&&/*#__PURE__*/t(Zl,{style:{marginTop:"1.25rem"},children:c.message}),/*#__PURE__*/e(zl,{children:[(y.totp||m.totp)&&/*#__PURE__*/e(Hl,{children:[/*#__PURE__*/t(hl,{style:{justifyContent:"center"},disabled:m.totp||s,onClick:()=>u("totp"),children:s?/*#__PURE__*/t(tn,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(ql,{children:[/*#__PURE__*/e($l,{children:[/*#__PURE__*/t(Co,{}),"Authenticator app"]}),m.totp?/*#__PURE__*/t(gm,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Gl,{children:"Recommended"})]})}),m.totp&&/*#__PURE__*/t(Vl,{style:{position:"absolute",right:0},onClick:()=>p("totp"),children:/*#__PURE__*/t(Eo,{})})]},"totp"),(y.sms||m.sms)&&/*#__PURE__*/e(Hl,{children:[/*#__PURE__*/t(hl,{disabled:m.sms||o,onClick:()=>u("sms"),children:/*#__PURE__*/e(ql,{children:[/*#__PURE__*/e($l,{children:[/*#__PURE__*/t(fi,{}),"SMS"]}),m.sms&&/*#__PURE__*/t(gm,{color:"green",children:"Enabled"}),o&&/*#__PURE__*/t(Gl,{children:"Disabled"})]})}),m.sms&&/*#__PURE__*/t(Vl,{style:{position:"absolute",right:0},onClick:()=>p("sms"),children:/*#__PURE__*/t(Eo,{})})]},"sms"),(y.passkey||m.passkey)&&/*#__PURE__*/e(Hl,{children:[/*#__PURE__*/t(hl,{style:{justifyContent:"center"},onClick:()=>u("passkey"),disabled:m.passkey||l,children:l?/*#__PURE__*/t(tn,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(ql,{children:[/*#__PURE__*/e($l,{children:[/*#__PURE__*/t(mo,{}),"Passkey"]}),m.passkey?/*#__PURE__*/t(gm,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Gl,{isAccent:!0,children:/*#__PURE__*/t(po,{})})]})}),m.passkey&&/*#__PURE__*/t(Vl,{style:{position:"absolute",right:0},onClick:()=>p("passkey"),children:/*#__PURE__*/t(Eo,{})})]},"passkey")]}),/*#__PURE__*/t(kt,{})]})};let gm=/*#__PURE__*/ii(Rt).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const fm=({appName:e,onComplete:n,onClose:r,onReset:a})=>{let{user:o}=_r(),{data:l}=Tr(),{initLinkWithPasskey:c,linkWithPasskey:d}=N(),{initEnrollmentWithPasskey:h,submitEnrollmentWithPasskey:u}=um(),[p,m]=s(!1),[y,g]=s(!1),[f,w]=s(!1),[v,C]=s(null),E=i((()=>o?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[o]),T=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},b=async e=>{m(!0);try{await h(),await u({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),w(!0)}catch(e){C(e)}finally{m(!1)}},A=async()=>{g(!0),C(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await b(t)}catch(e){C(e)}finally{g(!1)}};return 0===E.length||y?/*#__PURE__*/t(wm,{onReset:a,onClose:r,onClick:A,isCreating:y}):f?/*#__PURE__*/t(Cm,{appName:e,onClick:T,onClose:T}):v?/*#__PURE__*/t(mh,{error:v,backFn:()=>C(null),onClick:()=>C(null)}):/*#__PURE__*/t(vm,{passkeys:E,isSubmitting:p,isCreating:y,onReset:a,onClose:r,onSubmitEnrollment:()=>b(E.map((e=>e.credentialId))),onAddPasskey:A})};let wm=({onReset:r,onClose:a,onClick:i,isCreating:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{backFn:r,onClose:a},"header"),/*#__PURE__*/t(Wl,{children:/*#__PURE__*/e(yu,{children:[/*#__PURE__*/t(hu,{}),/*#__PURE__*/t(uu,{})]})}),/*#__PURE__*/t(Ll,{children:"Set up passkey verification"}),/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(wo,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(yo,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(To,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/t(wt,{style:{marginTop:"2.25rem"},onClick:i,loading:o,children:"Add a new passkey"}),/*#__PURE__*/t(kt,{})]}),vm=({onReset:r,onClose:a,onAddPasskey:i,onSubmitEnrollment:o,passkeys:l,isSubmitting:c,isCreating:d})=>{let[h,u]=s(!1),p=h?l.length:l.length>3?2:3;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:h?()=>u(!1):r,onClose:a},"header"),!h&&/*#__PURE__*/t(Wl,{children:/*#__PURE__*/e(yu,{children:[/*#__PURE__*/t(hu,{}),/*#__PURE__*/t(uu,{})]})}),/*#__PURE__*/t(Ll,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e(Ul,{children:[l.slice(0,p).map((n=>/*#__PURE__*/e(Em,{children:[/*#__PURE__*/t(Tm,{children:Am(n)}),/*#__PURE__*/e(bm,{children:["Last used: ",n.latestVerifiedAt?.toLocaleString()]})]},n.credentialId))),!h&&l.length>3&&/*#__PURE__*/t(_m,{onClick:()=>u(!0),children:"View All"})]}),/*#__PURE__*/t(wt,{style:{marginTop:"1.5rem"},onClick:o,loading:c,children:"Enable passkeys"}),l.length<5&&/*#__PURE__*/t(_m,{style:{marginTop:"0.5rem"},onClick:i,disabled:d,children:d?/*#__PURE__*/t(tn,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/t(kt,{})]})},Cm=({appName:r,onClick:a,onClose:i})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:i},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ci,{})}),/*#__PURE__*/t(Ll,{children:"Passkey verification added"}),/*#__PURE__*/e(Pl,{children:["From now on, you'll use the passkey whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Bl,{children:/*#__PURE__*/t(wt,{onClick:a,children:"Done"})}),/*#__PURE__*/t(kt,{})]}),Em=/*#__PURE__*/ii.div.withConfig({displayName:"PasskeyItem",componentId:"sc-d5b2bf9c-0"})(["&&{padding:0.75rem 1rem;text-align:left;border-radius:0.5rem;border:1px solid var(--privy-color-foreground-4);width:100%;}"]),Tm=/*#__PURE__*/ii.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-d5b2bf9c-1"})(["font-size:0.875rem;line-height:1.375rem;font-weight:500;color:var(--privy-color-foreground-1);"]),bm=/*#__PURE__*/ii.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-d5b2bf9c-2"})(["font-size:0.75rem;font-weight:400;line-height:1.125rem;color:var(--privy-color-foreground-2);"]),Am=e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device";const _m=/*#__PURE__*/ii.button.withConfig({displayName:"StyledLink",componentId:"sc-d5b2bf9c-3"})(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:0.75rem 1rem;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent);:focus{outline:none;box-shadow:none;}}"]);let km=Array(6).fill("");var Im,Nm=((Im=Nm||{})[Im.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",Im[Im.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",Im);function xm(e){return/^[0-9]{1}$/.test(e)}function Sm(e){return 6===e.length&&e.every(xm)}const Rm=({onChange:r,disabled:a,errorReasonOverride:i,success:o})=>{let[l,c]=s(km),[d,h]=s(null),[u,p]=s(null),m=async e=>{e.preventDefault();let t=e.currentTarget.value.replace(/\s+/g,"");if(""===t)return;let n=l.reduce(((e,t)=>e+Number(xm(t))),0),a=t.split(""),i=!a.every(xm),o=a.length+n>6;if(i)return h("Passcode can only be numbers"),void p(1);if(o)return h("Passcode must be exactly 6 numbers"),void p(1);h(null),p(null);let s=Number(e.currentTarget.name?.charAt(4)),d=[...t||[""]].slice(0,6-s),u=[...l.slice(0,s),...d,...l.slice(s+d.length)];c(u);let m=Math.min(Math.max(s+d.length,0),5),y=document.querySelector(`input[name=pin-${m}]`);if(y?.focus(),Sm(u))try{await r(u.join(""));let e=document.querySelector(`input[name=pin-${m}]`);e?.blur()}catch(e){p(1),h(e.message)}else try{await r(null)}catch(e){p(1),h(e.message)}},g=o?"success":!(!i&&!d)?"fail":"";/*#__PURE__*/return t(n,{children:/*#__PURE__*/e(Om,{children:[/*#__PURE__*/t("div",{children:l.map(((e,n)=>/*#__PURE__*/t("input",{name:`pin-${n}`,type:"text",value:l[n],onChange:m,onKeyUp:e=>{"Backspace"===e.key&&(e=>{1===u&&(h(null),p(null));let t=[...l.slice(0,e),"",...l.slice(e+1)];if(c(t),e>0){let t=document.querySelector(`input[name=pin-${e-1}]`);t?.focus()}Sm(t)?r(t.join("")):r(null)})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:g,autoComplete:y?"one-time-code":"off",disabled:a},n)))}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Wm,{$fail:!!i||!!d,children:i||d})})]})})};let Om=/*#__PURE__*/ii.div.withConfig({displayName:"PinInputContainer",componentId:"sc-7a171f6-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;@media (max-width:440px){margin-top:8px;margin-bottom:8px;}> div:nth-child(1){display:flex;justify-content:center;gap:0.5rem;width:100%;border-radius:var(--privy-border-radius-md);> input{border:1px solid var(--privy-color-foreground-4);background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);padding:8px 10px;height:58px;width:46px;text-align:center;font-size:18px;}> input:disabled{background:var(--privy-color-background-2);}> input:focus{border:1px solid var(--privy-color-accent);}> input:invalid{border:1px solid var(--privy-color-error);}> input.success{border:1px solid var(--privy-color-success);}> input.fail{border:1px solid var(--privy-color-error);animation:shake 180ms;animation-iteration-count:2;}}@keyframes shake{0%{transform:translate(1px,0px);}33%{transform:translate(-1px,0px);}67%{transform:translate(-1px,0px);}100%{transform:translate(1px,0px);}}"]),Wm=/*#__PURE__*/ii.div.withConfig({displayName:"InputHelp",componentId:"sc-7a171f6-1"})(["line-height:20px;font-size:13px;display:flex;justify-content:flex-start;width:100%;color:",";"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)"));const Lm=({appName:r,onComplete:a,onReset:i,onClose:o})=>{let[l,c]=s(""),[d,h]=s(!1),[u,p]=s(null),[m,y]=s("enroll"),{initEnrollmentWithSms:g,submitEnrollmentWithSms:f}=um(),{app:w,data:v}=Tr();function C(){v?.mfaEnrollmentFlow?.onSuccess(),a()}return u?/*#__PURE__*/t(mh,{error:u,backFn:()=>p(null),onClick:()=>p(null)}):/*#__PURE__*/e(n,"enroll"===m?{children:[/*#__PURE__*/t(ft,{backFn:i,onClose:o},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(fi,{})}),/*#__PURE__*/t(Ll,{children:"Set up SMS verification"}),/*#__PURE__*/e(Pl,{children:["We'll text a verification code to this mobile device whenever you use your ",r," ","wallet."]}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t($p,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await g({phoneNumber:e}),c(e),y("verify")}catch(e){p(e)}},hideRecent:!0}),/*#__PURE__*/e(jl,{children:["By providing your mobile number, you agree to receive text messages from ",w?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/t(kt,{})]}:d?{children:[/*#__PURE__*/t(ft,{onClose:C},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ci,{})}),/*#__PURE__*/t(Ll,{children:"SMS verification added"}),/*#__PURE__*/e(Pl,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Bl,{children:/*#__PURE__*/t(wt,{onClick:C,children:"Done"})}),/*#__PURE__*/t(kt,{})]}:{children:[/*#__PURE__*/t(ft,{backFn:function(){"verify"===m?y("enroll"):i()},onClose:o},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(fi,{})}),/*#__PURE__*/t(Ll,{children:"Enter enrollment code"}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(Rm,{onChange:async function(e){try{if(!e)return;await f({phoneNumber:l,mfaCode:e}),h(!0)}catch(e){if(Jc(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Xc(e))throw Error("The code you entered is not valid");if(Zc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw ed(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e(Pl,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/t("strong",{children:Zi(l)})]})]}),/*#__PURE__*/t(kt,{})]})},Pm=({size:e,authUrl:n})=>/*#__PURE__*/t(en,{url:n,squareLogoElement:bo,size:e,fgColor:"#1F1F1F"}),Mm=({onComplete:r,onClose:a,onReset:i,totpInfo:o})=>{let[l,c]=s("enroll"),[d,h]=s(!1),{submitEnrollmentWithTotp:u}=um(),{data:p}=Tr();function m(){p?.mfaEnrollmentFlow?.onSuccess(),r()}/*#__PURE__*/return e(n,"enroll"===l?{children:[/*#__PURE__*/t(ft,{backFn:i,onClose:a},"header"),/*#__PURE__*/t(Ll,{children:"Scan QR code"}),/*#__PURE__*/t(Pl,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/t(Jt,{children:/*#__PURE__*/t(Pm,{authUrl:o.authUrl,size:200})}),/*#__PURE__*/e(Bl,{children:[/*#__PURE__*/t(Qt,{children:/*#__PURE__*/t(vh,{itemName:"setup key",text:o.secret})}),/*#__PURE__*/t(wt,{onClick:function(){c("verify")},children:"Continue"})]}),/*#__PURE__*/t(kt,{})]}:d?{children:[/*#__PURE__*/t(ft,{onClose:m},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ci,{})}),/*#__PURE__*/t(Ll,{children:"Authenticator app verification added"}),/*#__PURE__*/e(Pl,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",o.appName," wallet."]}),/*#__PURE__*/t(Bl,{children:/*#__PURE__*/t(wt,{onClick:m,children:"Done"})}),/*#__PURE__*/t(kt,{})]}:{children:[/*#__PURE__*/t(ft,{backFn:function(){"verify"===l?c("enroll"):i()},onClose:a},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Co,{})}),/*#__PURE__*/t(Ll,{children:"Enter enrollment code"}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(Rm,{onChange:async function(e){try{if(!e)return;await u({mfaCode:e}),h(!0)}catch(e){if(Jc(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Xc(e))throw Error("The code you entered is not valid");if(Zc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw ed(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e(Pl,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),/*#__PURE__*/t(kt,{})]})},Um=({label:n,children:r,valueStyles:a})=>/*#__PURE__*/e(Dm,{children:[/*#__PURE__*/t("div",{children:n}),/*#__PURE__*/t(Fm,{style:{...a},children:r})]});let Dm=/*#__PURE__*/ii.div.withConfig({displayName:"StyledDetailsRow",componentId:"sc-4ebfdd45-0"})(["display:flex;align-items:center;justify-content:space-between;width:100%;> :first-child{color:var(--privy-color-foreground-3);text-align:left;}> :last-child{color:var(--privy-color-foreground-2);text-align:right;}"]),Fm=/*#__PURE__*/ii.div.withConfig({displayName:"ValueWrapper",componentId:"sc-4ebfdd45-1"})(["font-size:14px;line-height:100%;display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-full);background-color:var(--privy-color-background-2);padding:4px 8px;"]);const Bm=({weiQuantities:e,tokenPrice:n,tokenSymbol:r})=>{let a=fn(e),i=n?yn(a,n):void 0,o=cn(a,r);/*#__PURE__*/return t(Vm,{children:i||o})},zm=({weiQuantities:r,tokenPrice:a,tokenSymbol:i})=>{let o=fn(r),s=a?yn(o,a):void 0,l=cn(o,i);/*#__PURE__*/return t(Vm,{children:s?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t($m,{children:"USD"}),"<$0.01"===s?
8
- /*#__PURE__*/e(qm,{children:[/*#__PURE__*/t(Gm,{children:"<"}),"$0.01"]}):s]}):l})},Hm=({quantities:r,tokenPrice:a,tokenSymbol:i="SOL",tokenDecimals:o=9})=>{let s=r.reduce(((e,t)=>e+t),0n),l=a&&"SOL"===i&&9===o?Hh(s,a):void 0,c="SOL"===i&&9===o?zh(s):`${Ga(s,o)} ${i}`;/*#__PURE__*/return t(Vm,{children:l?/*#__PURE__*/t(n,{children:"<$0.01"===l?
9
- /*#__PURE__*/e(qm,{children:[/*#__PURE__*/t(Gm,{children:"<"}),"$0.01"]}):l}):c})};let Vm=/*#__PURE__*/ii.span.withConfig({displayName:"StyledPriceDisplay",componentId:"sc-596cd423-0"})(["font-size:14px;line-height:140%;display:flex;gap:4px;align-items:center;"]),$m=/*#__PURE__*/ii.span.withConfig({displayName:"StyledPriceUnit",componentId:"sc-596cd423-1"})(["font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);"]),Gm=/*#__PURE__*/ii.span.withConfig({displayName:"TinyLessThan",componentId:"sc-596cd423-2"})(["font-size:10px;"]),qm=/*#__PURE__*/ii.span.withConfig({displayName:"FlexCenter",componentId:"sc-596cd423-3"})(["display:flex;align-items:center;"]);const jm=({gas:n,tokenPrice:r,tokenSymbol:a})=>/*#__PURE__*/e(En,{style:{paddingBottom:"12px"},children:[/*#__PURE__*/e(Ym,{children:[/*#__PURE__*/t(Xm,{children:"Est. Fees"}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(zm,{weiQuantities:[BigInt(n)],tokenPrice:r,tokenSymbol:a})})]}),r&&/*#__PURE__*/t(Zm,{children:`${cn(BigInt(n),a)}`})]}),Km=({value:n,gas:r,tokenPrice:a,tokenSymbol:i})=>{let o=BigInt(n??0)+BigInt(r);/*#__PURE__*/return e(En,{children:[/*#__PURE__*/e(Ym,{children:[/*#__PURE__*/t(Xm,{children:"Total (including fees)"}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(zm,{weiQuantities:[BigInt(n||0),BigInt(r)],tokenPrice:a,tokenSymbol:i})})]}),a&&/*#__PURE__*/t(Zm,{children:cn(o,i)})]})};let Ym=/*#__PURE__*/ii.div.withConfig({displayName:"TransactionTotalRow",componentId:"sc-f8ef9b74-0"})(["display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-top:4px;"]),Zm=/*#__PURE__*/ii.div.withConfig({displayName:"ValueConversionRow",componentId:"sc-f8ef9b74-1"})(["display:flex;flex-direction:row;height:12px;font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);font-weight:400;"]),Xm=/*#__PURE__*/ii.div.withConfig({displayName:"TotalText",componentId:"sc-f8ef9b74-2"})(["font-size:14px;line-height:22.4px;font-weight:400;"]);const Qm=/*#__PURE__*/p(void 0),Jm=/*#__PURE__*/p(void 0),ey=({defaultValue:e,children:n})=>{let[r,a]=s(e||null);/*#__PURE__*/return t(Qm.Provider,{value:{activePanel:r,togglePanel:e=>{a(r===e?null:e)}},children:/*#__PURE__*/t(iy,{children:n})})},ty=({value:e,children:n})=>{let{activePanel:r,togglePanel:a}=u(Qm),i=r===e;/*#__PURE__*/return t(Jm.Provider,{value:{onToggle:()=>a(e),value:e},children:/*#__PURE__*/t(cy,{isActive:i,"data-open":i,children:n})})},ny=({children:r})=>{let{activePanel:a}=u(Qm),{onToggle:i,value:o}=u(Jm),s=a===o;/*#__PURE__*/
10
- return e(n,{children:[/*#__PURE__*/e(oy,{onClick:i,"data-open":s,children:[/*#__PURE__*/t(ly,{children:r}),/*#__PURE__*/t(uy,{isactive:s,children:/*#__PURE__*/t(so,{height:"16px",width:"16px",strokeWidth:"2"})})]}),/*#__PURE__*/t(sy,{})]})},ry=({children:e})=>{let{activePanel:n}=u(Qm),{value:r}=u(Jm);/*#__PURE__*/return t(dy,{"data-open":n===r,children:/*#__PURE__*/t(hy,{children:e})})},ay=({children:e})=>{let{activePanel:n}=u(Qm),{value:r}=u(Jm);/*#__PURE__*/return t(hy,{children:"function"==typeof e?e({isActive:n===r}):e})};let iy=/*#__PURE__*/ii.div.withConfig({displayName:"AccordionRoot",componentId:"sc-281bf545-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;"]),oy=/*#__PURE__*/ii.div.withConfig({displayName:"AccordionTriggerContainer",componentId:"sc-281bf545-1"})(["display:flex;justify-content:space-between;align-items:center;width:100%;cursor:pointer;padding-bottom:8px;"]),sy=/*#__PURE__*/ii.div.withConfig({displayName:"AccordionDivider",componentId:"sc-281bf545-2"})(["width:100%;&&{border-top:1px solid;border-color:var(--privy-color-foreground-4);}padding-bottom:12px;"]),ly=/*#__PURE__*/ii.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-281bf545-3"})(["font-size:14px;font-weight:500;line-height:19.6px;width:100%;padding-right:8px;"]),cy=/*#__PURE__*/ii.div.withConfig({displayName:"AccordionPanelContainer",componentId:"sc-281bf545-4"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;padding:12px;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),dy=/*#__PURE__*/ii.div.withConfig({displayName:"AccordionContentContainer",componentId:"sc-281bf545-5"})(["position:relative;overflow:hidden;transition:max-height 25ms ease-out;&[data-open='true']{max-height:700px;}&[data-open='false']{max-height:0;}"]),hy=/*#__PURE__*/ii.div.withConfig({displayName:"ContentWrapper",componentId:"sc-281bf545-6"})(["display:flex;flex-direction:column;gap:12px;flex:1 1 auto;min-height:1px;"]),uy=/*#__PURE__*/ii.div.withConfig({displayName:"IconWrapper",componentId:"sc-281bf545-7"})(["transform:",";"],(e=>e.isactive?"rotate(180deg)":"rotate(0deg)"));const py=({walletAddress:e,chainId:n=Lr,network:r,rpcEndpoint:a})=>/*#__PURE__*/t(my,{href:"ethereum"===r?On(n,e):Kr(e,Pr(a||"")),target:"_blank",children:Ot(e)});let my=/*#__PURE__*/ii.a.withConfig({displayName:"StyledLink",componentId:"sc-adda23e5-0"})(["&:hover{text-decoration:underline;}"]);const yy=({from:n,to:r,txn:a,transactionInfo:i,tokenPrice:o,gas:s,tokenSymbol:l})=>{let c=BigInt(a?.value||0);/*#__PURE__*/
11
- return t(ey,{...Ar().render.standalone?{defaultValue:"details"}:{},children:/*#__PURE__*/e(ty,{value:"details",children:[/*#__PURE__*/t(ny,{children:/*#__PURE__*/e(gy,{children:[/*#__PURE__*/t("div",{children:i?.title||"Details"}),/*#__PURE__*/t(fy,{children:/*#__PURE__*/t(Bm,{weiQuantities:[c],tokenPrice:o,tokenSymbol:l})})]})}),/*#__PURE__*/e(ry,{children:[/*#__PURE__*/t(Um,{label:"From",children:/*#__PURE__*/t(py,{walletAddress:n,chainId:a.chainId||Lr,network:"ethereum"})}),/*#__PURE__*/t(Um,{label:"To",children:/*#__PURE__*/t(py,{walletAddress:r,chainId:a.chainId||Lr,network:"ethereum"})}),i&&i.action&&/*#__PURE__*/t(Um,{label:"Action",children:i.action}),s&&/*#__PURE__*/t(jm,{value:a.value,gas:s,tokenPrice:o,tokenSymbol:l})]}),/*#__PURE__*/t(ay,{children:({isActive:e})=>/*#__PURE__*/t(Km,{value:a.value,displayFee:e,gas:s||"0x0",tokenPrice:o,tokenSymbol:l})})]})})};let gy=/*#__PURE__*/ii.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-29499c17-0"})(["display:flex;flex-direction:row;justify-content:space-between;"]),fy=/*#__PURE__*/ii.div.withConfig({displayName:"TotalText",componentId:"sc-29499c17-1"})(["flex-shrink:0;padding-left:8px;"]);async function wy(e,t,n){let r=bs(e),a=await t.prepareTransactionRequest({...r,account:{address:n,type:"json-rpc"}});return{...a,type:Es[a.type]}}const vy=({pendingTransaction:e})=>{let{getAccessToken:n}=_r(),{wallets:r}=Mr(),{walletProxy:a,rpcConfig:l,chains:c,appId:d,nativeTokenSymbolForChainId:h}=N(),[u,p]=s(null),[m,y]=s(e),{tokenPrice:g}=Uh(m.chainId),f=h(e.chainId)||"ETH",w=i((()=>r.find((e=>"privy"===e.walletClientType))),[r]);return o((()=>{(async function(){if(!await n()||!a||!w)return m;let e=Ja(m.chainId,c,l,{appId:d}),t=await wy(m,e,w.address);return p(Fa(BigInt(t.gas??0))),t})().then(y).catch(console.error)}),[a]),w?/*#__PURE__*/t(Cy,{children:/*#__PURE__*/t(yy,{from:w.address,to:m.to,txn:m,gas:u??void 0,tokenPrice:g,tokenSymbol:f})}):null};let Cy=/*#__PURE__*/ii.div.withConfig({displayName:"TransactionInfoWrapper",componentId:"sc-731f1950-0"})(["width:100%;padding:1rem 0;"]);const Ey=({hasBlockingError:r,error:a,onClose:i,onBack:o,handleSubmit:s,account:l,submitSuccess:c})=>{let{pendingTransaction:d}=N();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:i},"header"),/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{success:c,fail:!!a}),/*#__PURE__*/t(a?ci:hu,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/t(Ll,{style:{marginTop:"1rem"},children:"Verifying with passkey"}),/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(wo,{})}),"Approve this action using your touch, face, PIN, or hardware key."]}),/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(Ao,{})}),"You last added a passkey on"," ",l?.firstVerifiedAt?.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),"."]})]}),d&&/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(vy,{pendingTransaction:d})}),a&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Zl,{style:{marginTop:"1.25rem"},children:a.message}),/*#__PURE__*/t(wt,{disabled:r,onClick:s,style:{marginTop:"1.25rem"},children:"Try again"})]}),o&&/*#__PURE__*/t(Kl,{style:{marginTop:"1rem"},onClick:o,children:"Choose another method"}),/*#__PURE__*/t(kt,{})]})},Ty=({open:r,onClose:a})=>{let{user:i}=_r(),[c,d]=s(i?.mfaMethods[0]??null),{init:h,cancel:u,submit:p}=hm(),[m,y]=s(!1),[g,f]=s(!1),[w,v]=s(null),[C,E]=s(null);o((()=>{d(i?.mfaMethods[0]??null)}),[i?.mfaMethods]);let T=l(!1);o((()=>{!T.current&&c&&r&&(T.current=!0,_(c).finally((()=>{T.current=!1})))}),[r]);let b=e=>Qc(e)?(y(!0),Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")):Xc(e)?(y(!1),Error("The code you entered is not valid")):Zc(e)?(y(!0),Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")):(console.error(e),y(!1),Error("Something went wrong."));async function A(e){E(null);try{if(!e||!c)return;await p(c,e),f(!0),y(!1),a()}catch(e){throw b(e)}}async function _(e){if("passkey"!==e)try{d(e),await h(e)}catch(e){console.error(e)}else try{d(e);let t=await h(e);if(!t)throw Error("something went wrong");v(t),await p(e,t),f(!0),y(!1),a()}catch(e){E(b(e))}}let k=()=>{d(null),E(null),u(),a()};return r&&i?"passkey"===c?/*#__PURE__*/t(Ey,{account:i.linkedAccounts.filter((e=>"passkey"===e.type&&e.enrolledInMfa)).sort(((e,t)=>t.firstVerifiedAt.valueOf()-e.firstVerifiedAt.valueOf()))[0],selectedMethod:c,submitSuccess:g,hasBlockingError:m,error:C,onClose:k,onBack:()=>{d(null),E(null)},handleSubmit:()=>A(w).catch(E)}):c?/*#__PURE__*/t(by,{submitSuccess:g,hasBlockingError:m,handleSubmitCode:A,selectedMethod:c,onClose:k,onBack:i.mfaMethods.length>1?()=>d(null):void 0}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:k},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(wo,{})}),/*#__PURE__*/t(Ll,{children:"Verify your identity"}),/*#__PURE__*/t(Pl,{children:"Choose a verification method"}),/*#__PURE__*/e(zl,{children:[i.mfaMethods.includes("totp")&&/*#__PURE__*/e(hl,{onClick:()=>_("totp"),children:[/*#__PURE__*/t(Co,{}),"Authenticator App"]},"totp"),i.mfaMethods.includes("sms")&&/*#__PURE__*/e(hl,{onClick:()=>_("sms"),children:[/*#__PURE__*/t(fi,{}),"SMS"]},"sms"),i.mfaMethods.includes("passkey")&&/*#__PURE__*/e(hl,{onClick:()=>_("passkey"),children:[/*#__PURE__*/t(mo,{}),"Passkey"]},"passkey")]}),/*#__PURE__*/t(kt,{})]}):null};let by=({selectedMethod:r,submitSuccess:a,hasBlockingError:i,onClose:o,onBack:s,handleSubmitCode:l})=>{let{app:c}=Tr(),{pendingTransaction:d}=N();switch(r){case"sms":/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:o},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(fi,{})}),/*#__PURE__*/t(Ll,{children:"Enter verification code"}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(Rm,{success:a,disabled:i,onChange:l}),/*#__PURE__*/e(Pl,{children:["To continue, please enter the 6-digit code sent to your ",/*#__PURE__*/t("strong",{children:"mobile device"})]}),d&&/*#__PURE__*/t(vy,{pendingTransaction:d})]}),s&&/*#__PURE__*/t(Kl,{theme:c?.appearance.palette.colorScheme,onClick:s,children:"Choose another method"}),/*#__PURE__*/t(Et,{onClick:o,children:"Not now"}),/*#__PURE__*/t(kt,{})]});case"totp":/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:o},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Co,{})}),/*#__PURE__*/t(Ll,{children:"Enter verification code"}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(Rm,{success:a,disabled:i,onChange:l}),/*#__PURE__*/e(Pl,{children:["To continue, please enter the 6-digit code generated from your"," ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),d&&/*#__PURE__*/t(vy,{pendingTransaction:d})]}),s&&/*#__PURE__*/t(Kl,{theme:c?.appearance.palette.colorScheme,onClick:s,children:"Choose another method"}),/*#__PURE__*/t(Et,{onClick:o,children:"Not now"}),/*#__PURE__*/t(kt,{})]});default:return null}};let Ay=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-814a2c46-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const _y=/*#__PURE__*/ii.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-fd7f30b7-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent);stroke:var(--privy-color-accent);fill:var(--privy-color-accent);}"]);let ky=/*#__PURE__*/ii.div.withConfig({displayName:"Container",componentId:"sc-d3724da1-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Iy=/*#__PURE__*/ii.div.withConfig({displayName:"Header",componentId:"sc-858d1103-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:20px 0;gap:4px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]);let Ny=/*#__PURE__*/ii.div.withConfig({displayName:"Content",componentId:"sc-858d1103-1"})(["display:flex;flex-direction:column;justify-content:space-between;"]),xy=/*#__PURE__*/ii.div.withConfig({displayName:"ErrorMessage",componentId:"sc-858d1103-2"})(["line-height:20px;height:20px;font-size:13px;color:var(--privy-color-error);text-align:left;margin-top:0.5rem;"]),Sy=/*#__PURE__*/ii(wt).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-858d1103-3"})(["",""],(e=>e.hideAnimations&&/*#__PURE__*/oi(["&&{transition:none;}"])));const Ry=n=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 21 20",...n,children:[/*#__PURE__*/t("path",{fill:"url(#icloud-gradient)",d:"M12.34 7.315a4.26 4.26 0 0 0-3.707 2.18 2.336 2.336 0 0 0-1.02-.236 2.336 2.336 0 0 0-2.3 1.963 3.217 3.217 0 0 0 1.244 6.181c.135-.001.27-.01.404-.029h8.943c.047.004.094.006.141.007.045-.001.09-.004.135-.007h.214v-.016a2.99 2.99 0 0 0 1.887-.988c.487-.55.757-1.261.757-1.998v-.006a3.017 3.017 0 0 0-.69-1.915 2.992 2.992 0 0 0-1.748-1.034 4.26 4.26 0 0 0-4.26-4.102Z"}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/e("linearGradient",{id:"icloud-gradient",x1:19.086,x2:3.333,y1:14.38,y2:14.163,gradientUnits:"userSpaceOnUse",children:[/*#__PURE__*/t("stop",{stopColor:"#3E82F4"}),/*#__PURE__*/t("stop",{offset:1,stopColor:"#93DCF7"})]})})]}),Oy=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"16",height:"14",style:n,viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_2115_829)",children:[/*#__PURE__*/t("path",{d:"M2.34709 12.9404L2.3471 12.9404L2.34565 12.938L1.64031 11.7448L1.64004 11.7444L0.651257 10.0677C0.640723 10.0496 0.630746 10.0314 0.621325 10.0129H4.16461L2.39424 13.0139C2.3775 12.9901 2.36178 12.9656 2.34709 12.9404Z",fill:"#0066DA",stroke:"#6366F1"}),/*#__PURE__*/t("path",{d:"M8 4.48713L5.47995 0.215332C5.23253 0.358922 5.02176 0.556358 4.87514 0.80764L0.219931 8.70508C0.076007 8.95094 0.000191627 9.22937 0 9.51277H5.04009L8 4.48713Z",fill:"#00AC47"}),/*#__PURE__*/t("path",{d:"M13.48 13.7847C13.7274 13.6411 13.9382 13.4437 14.0848 13.1924L14.3781 12.6988L15.7801 10.3206C15.9267 10.0693 16.0001 9.79114 16.0001 9.51294H10.9596L12.0321 11.577L13.48 13.7847Z",fill:"#EA4335"}),/*#__PURE__*/t("path",{d:"M8.00003 4.48718L10.5201 0.215385C10.2726 0.0717949 9.98857 0 9.69533 0H6.30472C6.01148 0 5.7274 0.0807692 5.47998 0.215385L8.00003 4.48718Z",fill:"#00832D"}),/*#__PURE__*/t("path",{d:"M10.9599 9.51294H5.04007L2.52002 13.7847C2.76744 13.9283 3.05152 14.0001 3.34476 14.0001H12.6552C12.9484 14.0001 13.2325 13.9194 13.4799 13.7847L10.9599 9.51294Z",fill:"#2684FC"}),/*#__PURE__*/t("path",{d:"M13.4525 4.75636L11.1249 0.80764C10.9782 0.556358 10.7675 0.358922 10.52 0.215332L8 4.48713L10.9599 9.51277H15.9908C15.9908 9.23456 15.9175 8.95636 15.7709 8.70508L13.4525 4.75636Z",fill:"#FFBA00"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_2115_829",children:/*#__PURE__*/t("rect",{width:"16",height:"14",fill:"white"})})})]}),Wy=/*#__PURE__*/ii.div.withConfig({displayName:"RecoveryContainer",componentId:"sc-12b46968-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),Ly=/*#__PURE__*/ii.div.withConfig({displayName:"RecoveryExplainerContainer",componentId:"sc-12b46968-1"})(["padding-bottom:24px;"]);let Py={"google-drive":{name:"Google Drive",component:Oy},icloud:{name:"iCloud",component:Ry}};let My=/*#__PURE__*/ii.div.withConfig({displayName:"IconContainer",componentId:"sc-6716a2fa-0"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;"]),Uy={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy"},Dy=({onClose:r})=>/*#__PURE__*/e(Ly,{children:[/*#__PURE__*/t(ac,{title:"Why do I need to secure my account?",icon:/*#__PURE__*/t(li,{width:48}),description:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),/*#__PURE__*/t("p",{children:"To use this app on new devices, secure account secrets using a password, your Google or your Apple account. It’s important you don’t lose access to the method you choose."})]})}),/*#__PURE__*/t(wt,{onClick:r,children:"Select backup method"})]});const Fy=/*#__PURE__*/ii.div.withConfig({displayName:"WithCircleBorder",componentId:"sc-e4fc5563-0"})(["&&{border-width:4px;}display:flex;justify-content:center;align-items:center;padding:1rem;aspect-ratio:1;border-style:solid;border-color:",";border-radius:50%;"],(e=>e.$color??"var(--privy-color-accent)"));async function By({tx:e,accessToken:t,walletProxy:n,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:i,transactingWalletIndex:o}){let s=function(e,t){let n=($h(e)?e.message:e.compileMessage()).staticAccountKeys.find((e=>e.toBase58()===t));if(!n)throw Error(`Transaction does not contain public key ${t}`);return n}(e,i),l=$h(e)?Buffer.from(e.message.serialize()):e.serializeMessage(),{response:c}=await n.rpc({accessToken:t,entropyId:r,entropyIdVerifier:a,chainType:"solana",hdWalletIndex:o,request:{method:"signMessage",params:{message:l.toString("base64")}}}),d=c.data.signature,h=Buffer.from(d,"base64");e.addSignature(s,h)}async function zy({tx:e,connection:t,accessToken:n,walletProxy:r,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:o,transactingWalletIndex:s,transactionOptions:l}){let c;try{await By({tx:e,accessToken:n,walletProxy:r,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:o,transactingWalletIndex:s});let d=e.serialize();c=await t.sendRawTransaction(d,l);let h=await t.confirmTransaction(c);if(h.value.err||h.value.err){let e=h.value.err||h.value.err;if("string"==typeof e)throw Error(e);throw e}return{signature:c,signedTransaction:e,receipt:await t.getParsedTransaction(c,{maxSupportedTransactionVersion:0})}}catch(e){throw e.txSignature=c,e}}const Hy=/*#__PURE__*/ii(Xh).withConfig({displayName:"InteractiveLabel",componentId:"sc-94a4dccc-0"})(["cursor:pointer;display:inline-flex;gap:8px;align-items:center;color:var(--privy-color-accent);svg{fill:var(--privy-color-accent);}"]);var Vy=({iconUrl:n,value:r,symbol:a,usdValue:i,nftName:o,$isLoading:s})=>s?/*#__PURE__*/t($y,{$isLoading:s}):/*#__PURE__*/e("div",{children:[/*#__PURE__*/e($y,{$isLoading:s,children:[n&&/*#__PURE__*/t(qy,{src:n,alt:"Token icon"}),o,r," ",a]}),i&&/*#__PURE__*/e(Gy,{$isLoading:s,children:["$",i]})]});let $y=/*#__PURE__*/ii.span.withConfig({displayName:"Value",componentId:"sc-d8e62921-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],nn);const Gy=/*#__PURE__*/ii.span.withConfig({displayName:"Subvalue",componentId:"sc-d8e62921-1"})(["color:var(--privy-color-foreground-2);font-size:12px;font-weight:400;line-height:18px;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],nn);let qy=/*#__PURE__*/ii.img.withConfig({displayName:"TokenIcon",componentId:"sc-d8e62921-2"})(["height:14px;width:14px;margin-right:4px;object-fit:contain;"]);const jy=r=>{let{chain:a,transactionDetails:i,isTokenContractInfoLoading:o,symbol:s}=r,{action:l,functionName:c}=i;/*#__PURE__*/return t(rn,{children:/*#__PURE__*/e(un,{children:["transaction"!==l&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Action"}),/*#__PURE__*/t(Jh,{children:c})]}),"mint"===c&&"args"in i&&i.args.filter((e=>e)).map(((n,r)=>/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:`Param ${r}`}),/*#__PURE__*/t(Jh,{children:"string"==typeof n&&Ka(n)?/*#__PURE__*/t(vt,{address:n,url:a?.blockExplorers?.default?.url,showCopyIcon:!1}):n?.toString()})]},r))),"setApprovalForAll"===c&&i.operator&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Operator"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:i.operator,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===c&&void 0!==i.approved&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Set approval to"}),/*#__PURE__*/t(Jh,{children:i.approved?"true":"false"})]}),"transfer"===c||"transferFrom"===c||"safeTransferFrom"===c||"approve"===c?/*#__PURE__*/e(n,{children:["formattedAmount"in i&&i.formattedAmount&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Amount"}),/*#__PURE__*/e(Jh,{$isLoading:o,children:[i.formattedAmount," ",s]})]}),"tokenId"in i&&i.tokenId&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Token ID"}),/*#__PURE__*/t(Jh,{children:i.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===c&&/*#__PURE__*/e(n,{children:["amounts"in i&&i.amounts&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Amounts"}),/*#__PURE__*/t(Jh,{children:i.amounts.join(", ")})]}),"tokenIds"in i&&i.tokenIds&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Token IDs"}),/*#__PURE__*/t(Jh,{children:i.tokenIds.join(", ")})]})]}),"approve"===c&&i.spender&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Spender"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:i.spender,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferFrom&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Transferring from"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:i.transferFrom,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferTo&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Transferring to"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:i.transferTo,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})};let Ky={success:"background: var(--privy-color-success-lightest, #dcfce7);",warn:"background: var(--privy-color-warn-lightest, #fff7e6);",error:"background: var(--privy-color-error-lightest, #fde8e8);"};const Yy=/*#__PURE__*/ii.div.withConfig({displayName:"Pill",componentId:"sc-8c138024-0"})(["border-radius:var(--privy-border-radius-md,8px);padding:12px;text-align:left;margin-top:23px;",""],(e=>Ky[e.variant])),Zy=({variant:n,setPreventMaliciousTransaction:r,preventMaliciousTransaction:a})=>"warn"===n?/*#__PURE__*/t(Yy,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t(Xy,{variant:n}),/*#__PURE__*/e("p",{children:[/*#__PURE__*/t("b",{children:"Warning: Suspicious transaction"}),/*#__PURE__*/t("br",{}),"This has been flagged as a potentially deceptive request. Approving could put your assets or funds at risk."]})]})}):"error"===n?/*#__PURE__*/t(Yy,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-col",children:[/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t(Xy,{variant:n}),/*#__PURE__*/e("p",{children:[/*#__PURE__*/t("b",{children:"This is a malicious transaction"}),/*#__PURE__*/t("br",{}),"This transaction transfers tokens to a known malicious address. Proceeding may result in the loss of valuable assets."]})]}),/*#__PURE__*/e("div",{className:"mt-3 flex flex-row gap-2",children:[/*#__PURE__*/t(Ld,{color:"var(--privy-color-error)",checked:!a,readOnly:!0,onClick:()=>r(!a)}),/*#__PURE__*/t("p",{children:"I understand and want to proceed anyways."})]})]})}):void 0;let Xy=/*#__PURE__*/ii(ci).withConfig({displayName:"StyledExclamationTriangleIcon",componentId:"sc-e6305f32-0"})(["width:20px;height:20px;stroke-width:2px;flex-shrink:0;display:inline-block;margin-right:8px;",";"],(e=>"error"===e.variant?"color: var(--privy-color-error)":"color: var(--privy-color-warn)"));const Qy=({transactionIndex:e,maxIndex:t})=>"number"!=typeof e||0===t?"":` (${e+1} / ${t+1})`,Jy=({img:r,submitError:a,prepareError:i,onClose:o,action:l,title:c,subtitle:d,txValue:h,to:u,tokenAddress:p,network:m,missingFunds:y,fee:g,from:f,cta:w,disabled:v,chain:C,isSubmitting:E,isPreparing:T,isTokenPriceLoading:b,isTokenContractInfoLoading:A,isSponsored:_,symbol:k,balance:I,onClick:N,transactionDetails:x,transactionIndex:S,maxIndex:R,onBack:O,chainName:W,validation:L,hasScanDetails:P,setIsScanDetailsOpen:M,preventMaliciousTransaction:U,setPreventMaliciousTransaction:D,tokensSent:F,tokensReceived:B,isScanning:z,isCancellable:H})=>{let{showTransactionDetails:V,setShowTransactionDetails:$,hasMoreDetails:G,isErc20Ish:q}=(e=>{let[t,n]=s(!1),r=!0,a=!1;return(!e||e.isErc20Ish||"transaction"===e.action)&&(r=!1),r&&(a=Object.entries(e||{}).some((([e,t])=>t&&!["action","isErc20Ish","isNFTIsh"].includes(e)))),{showTransactionDetails:t,setShowTransactionDetails:n,hasMoreDetails:r&&a,isErc20Ish:e?.isErc20Ish}})(x),j=q&&A||T||b||z;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:o,backFn:O}),r&&/*#__PURE__*/t(rg,{children:r}),/*#__PURE__*/e(Vt,{style:{marginTop:r?"1.5rem":0},children:[c,/*#__PURE__*/t(Qy,{maxIndex:R,transactionIndex:S})]}),/*#__PURE__*/t($t,{children:d}),/*#__PURE__*/e(un,{style:{marginTop:"2rem"},children:[(!!F[0]||j)&&/*#__PURE__*/e(ln,{children:[B.length>0?/*#__PURE__*/t(Xh,{children:"Send"}):/*#__PURE__*/t(Xh,{children:"Amount"}),/*#__PURE__*/t(Vy,{iconUrl:F[0]?.iconUrl,value:F[0]?.value,usdValue:F[0]?.usdValue,symbol:F[0]?.symbol,nftName:F[0]?.nftName,$isLoading:j})]}),B.length>0&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Receive"}),/*#__PURE__*/t("div",{className:"flex flex-col",children:B.map(((e,n)=>/*#__PURE__*/t(Vy,{iconUrl:e.iconUrl,value:e.value,usdValue:e.usdValue,symbol:e.symbol,nftName:e.nftName},n)))})]}),x&&"spender"in x&&x?.spender?/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Spender"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:x.spender,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}):null,u&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"To"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:u,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),p&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Token address"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:p,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Network"}),/*#__PURE__*/t(Jh,{children:m})]}),/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Estimated fee"}),/*#__PURE__*/t(Jh,{$isLoading:T||b||void 0===_,children:_?"Sponsored":g})]}),G&&!P&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ln,{className:"cursor-pointer",onClick:()=>$(!V),children:/*#__PURE__*/e(Qh,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/t(No,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:V?"rotate(180deg)":void 0}})]})}),V&&x&&/*#__PURE__*/t(jy,{action:l,chain:C,transactionDetails:x,isTokenContractInfoLoading:A,symbol:k})]}),P&&/*#__PURE__*/t(ln,{children:/*#__PURE__*/e(Hy,{onClick:()=>M(!0),children:[/*#__PURE__*/t("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/t(xo,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/t(il,{}),a?/*#__PURE__*/t(dn,{style:{marginTop:"2rem"},children:a.message}):i?/*#__PURE__*/t(dn,{style:{marginTop:"2rem"},children:i.shortMessage??ng}):null,/*#__PURE__*/t(Zy,{variant:L,preventMaliciousTransaction:U,setPreventMaliciousTransaction:D}),/*#__PURE__*/t(tg,{$useSmallMargins:!(!i&&!a&&"warn"!==L&&"error"!==L),title:Number(h)>0?void 0:!1!==_?"Your wallet":void 0,address:f,balance:I,isLoading:T||b,errMsg:T||i||a||!y?void 0:`Add funds on ${C?.name??W} to complete transaction.`}),/*#__PURE__*/t(wt,{style:{marginTop:"1rem"},loading:E,disabled:v||T,onClick:N,children:w}),H&&/*#__PURE__*/t(Nn,{style:{marginTop:"1rem"},onClick:o,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(Ct,{})]})},eg=({img:r,title:a,subtitle:i,cta:o,network:s,blockExplorerUrl:l,transactionIndex:c,maxIndex:d,isMissingFunds:h,submitError:u,parseError:p,total:m,amount:y,fee:g,balance:f,from:w,to:v,tokenAddress:C,tokenAccount:E,tokenAccountOwner:T,programAddress:b,transactingWalletAddress:A,disabled:_,isSubmitting:k,isPreparing:I,isTokenPriceLoading:N,onClick:x,onClose:S,onBack:R})=>{let O=I||N;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:S,backFn:R}),r&&/*#__PURE__*/t(rg,{children:r}),/*#__PURE__*/e(Vt,{style:{marginTop:r?"1.5rem":0},children:[a,/*#__PURE__*/t(Qy,{maxIndex:d,transactionIndex:c})]}),/*#__PURE__*/t($t,{children:i}),/*#__PURE__*/e(un,{style:{marginTop:"2rem"},children:[(m||O)&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Total"}),/*#__PURE__*/t(Jh,{$isLoading:O,children:m})]}),w&&w!==A&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"From"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:w,url:l,showCopyIcon:!1})})]}),v&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"To"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:v,url:l,showCopyIcon:!1})})]}),T&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Token account owner"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:T,url:l,showCopyIcon:!1})})]}),E&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Token account"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:E,url:l,showCopyIcon:!1})})]}),C&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Token address"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:C,url:l,showCopyIcon:!1})})]}),b&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Program address"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(vt,{address:b,url:l,showCopyIcon:!1})})]}),s&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Network"}),/*#__PURE__*/t(Jh,{children:s})]}),(y||O)&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Amount"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(Jh,{$isLoading:O,children:y})})]}),(g||O)&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Estimated fee"}),/*#__PURE__*/t(Jh,{$isLoading:O,children:g})]})]}),/*#__PURE__*/t(il,{}),u?/*#__PURE__*/t(dn,{style:{marginTop:"2rem"},children:u.message}):p?/*#__PURE__*/t(dn,{style:{marginTop:"2rem"},children:ng}):null,/*#__PURE__*/t(tg,{$useSmallMargins:!(!p&&!u),title:"Your wallet",address:A,balance:f,isLoading:I||N,errMsg:I||p||u||!h?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/t(wt,{style:{marginTop:"1rem"},loading:k,disabled:_||I,onClick:x,children:o}),/*#__PURE__*/t(Ct,{})]})};let tg=/*#__PURE__*/ii(zt).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-4bd3bb7d-0"})(["",""],(e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;")),ng="There was an error preparing your transaction. Your transaction request will likely fail.",rg=/*#__PURE__*/ii.div.withConfig({displayName:"ImageContainer",componentId:"sc-4bd3bb7d-1"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),ag=()=>/*#__PURE__*/e(cg,{children:[/*#__PURE__*/t(hg,{}),/*#__PURE__*/t(dg,{})]});const ig=({transactionError:r,chainId:a,onClose:i,onRetry:o,network:l,connection:c,transactionHash:d})=>{let{chains:h}=N(),[u,p]=s(!1),{errorCode:m,errorMessage:y}=((e,t)=>{if("ethereum"===t)return{errorCode:e.details??e.message,errorMessage:e.shortMessage};let n=e.txSignature,r=e?.transactionMessage||"Something went wrong.";if(Array.isArray(e.logs)){let t=e.logs.find((e=>/insufficient (lamports|funds)/gi.test(e)));t&&(r=t)}return{transactionHash:n,errorMessage:r}})(r,l),g=(({chains:e,chainId:t,network:n,connection:r,transactionHash:a})=>"ethereum"===n?e.find((e=>e.id===t))?.blockExplorers?.default.url??"https://etherscan.io":Yr(a||"",Pr(r?.rpcEndpoint||"")))({chains:h,chainId:a,network:l,connection:c,transactionHash:d});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:i}),/*#__PURE__*/e(og,{children:[/*#__PURE__*/t(ag,{}),/*#__PURE__*/t(sg,{children:m}),/*#__PURE__*/t(lg,{children:"Please try again."}),/*#__PURE__*/e(mg,{children:[/*#__PURE__*/t(pg,{children:"Error message"}),/*#__PURE__*/t(gg,{$clickable:!1,children:y})]}),d&&/*#__PURE__*/e(mg,{children:[/*#__PURE__*/t(pg,{children:"Transaction hash"}),/*#__PURE__*/e(yg,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/t("u",{children:/*#__PURE__*/t("a",{href:g,children:"block explorer"})}),"."]}),/*#__PURE__*/e(gg,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(d),p(!0)},children:[d,/*#__PURE__*/t(vg,{clicked:u})]})]}),/*#__PURE__*/t(ug,{onClick:()=>o({resetNonce:!!d}),children:"Retry transaction"})]}),/*#__PURE__*/t(kt,{})]})};let og=/*#__PURE__*/ii.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-a4816d51-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),sg=/*#__PURE__*/ii.span.withConfig({displayName:"ErrorCode",componentId:"sc-a4816d51-1"})(["color:var(--privy-color-foreground);text-align:center;font-size:1.125rem;font-weight:500;line-height:1.25rem;text-align:center;margin:10px;"]),lg=/*#__PURE__*/ii.span.withConfig({displayName:"Subtitle",componentId:"sc-a4816d51-2"})(["margin-top:4px;margin-bottom:10px;color:var(--privy-color-foreground-3);text-align:center;font-size:0.875rem;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;"]),cg=/*#__PURE__*/ii.div.withConfig({displayName:"CircleContainer",componentId:"sc-a4816d51-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),dg=/*#__PURE__*/ii(hi).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-a4816d51-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),hg=/*#__PURE__*/ii.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-a4816d51-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),ug=/*#__PURE__*/ii(wt).withConfig({displayName:"RetryButton",componentId:"sc-a4816d51-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),pg=/*#__PURE__*/ii.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-a4816d51-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),mg=/*#__PURE__*/ii.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-a4816d51-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),yg=/*#__PURE__*/ii.text.withConfig({displayName:"HelperText",componentId:"sc-a4816d51-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),gg=/*#__PURE__*/ii.span.withConfig({displayName:"TextBox",componentId:"sc-a4816d51-10"})(["position:relative;width:100%;background-color:var(--privy-color-background-2);padding:8px 12px;border-radius:10px;margin-top:5px;font-size:14px;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;",""],(e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }")),fg=/*#__PURE__*/ii(So).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-a4816d51-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),wg=/*#__PURE__*/ii(Ri).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-a4816d51-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),vg=({clicked:e})=>/*#__PURE__*/t(e?wg:fg,{});const Cg=({instructions:r,fees:a,transactionInfo:i,solPrice:o,rpcEndpoint:l})=>{let c=r.reduce(((e,{amount:t,token:n})=>t&&"SOL"===n?.symbol?e+t:e),0n),[d,h]=s(0),[u,p]=s(!1),m=r[d];/*#__PURE__*/return e(un,{children:[/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Total"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(Hm,{quantities:[c,a],tokenPrice:o})})]}),i&&i.action&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Action"}),/*#__PURE__*/t(Jh,{children:i.action})]}),/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Fees"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(Hm,{quantities:[a||0n],tokenPrice:o})})]}),r.length>1?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ln,{children:/*#__PURE__*/e(Hy,{onClick:()=>p((e=>!e)),children:[/*#__PURE__*/t("span",{children:"Details"}),/*#__PURE__*/t(so,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:u?"rotate(180deg)":void 0}})]})}),u&&/*#__PURE__*/t(ln,{children:/*#__PURE__*/e(Tg,{children:[/*#__PURE__*/e(bg,{children:[/*#__PURE__*/e(Ag,{children:[d+1," of ",r.length," instructions"]}),/*#__PURE__*/e(kg,{children:[d>0&&/*#__PURE__*/t(Ln,{backFn:()=>h((e=>e-1))}),d<r.length-1&&/*#__PURE__*/t(Pn,{nextFn:()=>h((e=>e+1))})]})]}),/*#__PURE__*/t(_g,{children:/*#__PURE__*/t(Eg,{instruction:m,rpcEndpoint:l,solPrice:o})})]})})]}):/*#__PURE__*/t(Eg,{instruction:m,rpcEndpoint:l,solPrice:o,hideAmount:!0})]})};function Eg({instruction:n,rpcEndpoint:r,solPrice:a,hideAmount:i}){return n?/*#__PURE__*/e(un,{children:[!i&&!!n.amount&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Amount"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(Hm,{quantities:[n.amount],tokenPrice:a,tokenSymbol:n.token?.symbol??"SOL",tokenDecimals:n.token?.decimals??9})})]}),n.to&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"To"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(py,{walletAddress:n.to,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccount&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Token account"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(py,{walletAddress:n.tokenAccount,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccountOwner&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"Token account owner"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(py,{walletAddress:n.tokenAccountOwner,rpcEndpoint:r,network:"solana"})})]}),n.from&&/*#__PURE__*/e(ln,{children:[/*#__PURE__*/t(Xh,{children:"From"}),/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(py,{walletAddress:n.from,rpcEndpoint:r,network:"solana"})})]})]}):null}let Tg=/*#__PURE__*/ii.div.withConfig({displayName:"InstructionsBox",componentId:"sc-5a140027-0"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),bg=/*#__PURE__*/ii.header.withConfig({displayName:"InstructionsBoxHeader",componentId:"sc-5a140027-1"})(["display:flex;justify-content:space-between;align-items:center;padding:12px;background-color:var(--privy-color-background-2);"]),Ag=/*#__PURE__*/ii.h4.withConfig({displayName:"HeaderTitle",componentId:"sc-5a140027-2"})(["font-size:14px;font-weight:500;line-height:19.6px;"]),_g=/*#__PURE__*/ii.div.withConfig({displayName:"InstructionsBoxContent",componentId:"sc-5a140027-3"})(["padding:12px;"]),kg=/*#__PURE__*/ii.div.withConfig({displayName:"NavigationButtonsConatiner",componentId:"sc-5a140027-4"})(["display:flex;gap:8px;align-items:center;"]);const Ig=({instructions:r,fees:a,onClose:i,receiptHeader:o,receiptDescription:s,transactionInfo:l,solPrice:c,rpcEndpoint:d,signOnly:h})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:i}),/*#__PURE__*/t(al,{style:{marginBottom:"16px"},children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(rl,{color:"var(--privy-color-success-light)"}),/*#__PURE__*/t(Ci,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),/*#__PURE__*/t(ac,{title:o??`Transaction ${h?"signed":"complete"}!`,description:s??"You're all set."}),/*#__PURE__*/t(Cg,{solPrice:c,instructions:r,fees:a,transactionInfo:l,rpcEndpoint:d}),/*#__PURE__*/t(il,{}),/*#__PURE__*/t(Ng,{loading:!1,onClick:i,children:"Close"}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]});let Ng=/*#__PURE__*/ii(wt).withConfig({displayName:"SubmitButton",componentId:"sc-1510a4b6-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);async function xg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,publicClient:o,requesterAppId:s}){let l=await Sg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,requesterAppId:s});return await o.sendRawTransaction({serializedTransaction:l})}async function Sg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,requesterAppId:o}){return(await a.rpc({entropyId:t,entropyIdVerifier:n,hdWalletIndex:r.walletIndex??0,chainType:"ethereum",accessToken:e,requesterAppId:o,request:{method:"eth_signTransaction",params:[i]}})).response.data}let Rg=({data:n})=>{let r=n=>"object"==typeof n&&null!==n?/*#__PURE__*/t(Wg,{children:Object.entries(n).map((([t,n])=>/*#__PURE__*/e("li",{children:[/*#__PURE__*/e("strong",{children:[t,":"]})," ",r(n)]},t)))}):/*#__PURE__*/t("span",{children:String(n)});/*#__PURE__*/return t("div",{children:r(n)})};const Og=/*#__PURE__*/ii.div.withConfig({displayName:"Message",componentId:"sc-ccf49562-0"})(["margin-top:1.5rem;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-md);padding:12px;text-align:left;max-height:310px;overflow:scroll;white-space:pre-wrap;width:100%;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]);let Wg=/*#__PURE__*/ii.ul.withConfig({displayName:"MessageList",componentId:"sc-ccf49562-1"})(["margin-left:12px !important;white-space:nowrap;&:first-child{margin-left:0 !important;}strong{font-weight:500 !important;}"]);const Lg=({data:e})=>/*#__PURE__*/t(Og,{children:/*#__PURE__*/t(Rg,{data:e})});let Pg=/*#__PURE__*/ii.div.withConfig({displayName:"Container",componentId:"sc-b3a607dd-0"})(["display:flex;flex-direction:column;min-height:72px;"]);var Mg=({onBack:n,details:r})=>/*#__PURE__*/e(Pg,{children:[/*#__PURE__*/t(ft,{backFn:n}),/*#__PURE__*/t(Lg,{data:r}),/*#__PURE__*/t(Ct,{})]});let Ug=({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return Fa(e*t)}catch(e){return}};const Dg=({txn:r,receipt:a,transactionInfo:i,onClose:o,tokenPrice:s,tokenSymbol:l,receiptHeader:c,receiptDescription:d})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:o}),/*#__PURE__*/t(nc,{title:c??"Transaction complete!",description:d??"You're all set."}),/*#__PURE__*/t(yy,{tokenPrice:s,from:a.from,to:a.to,gas:Ug(a),txn:r,transactionInfo:i,tokenSymbol:l}),/*#__PURE__*/t(il,{}),/*#__PURE__*/t(Fg,{loading:!1,onClick:o,children:"All Done"}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]});let Fg=/*#__PURE__*/ii(wt).withConfig({displayName:"SubmitButton",componentId:"sc-824e1e82-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const Bg=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],zg=[{name:"from",type:"address"},{name:"param2",type:"address"},{name:"param3",type:"bytes"},{name:"param4",type:"tuple",components:[]},{type:"tuple",components:[{name:"param5",type:"address"},{name:"param6",type:"uint256"},{name:"param7",type:"uint256"},{name:"encodedInitData",type:"bytes"}]}],Hg=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Vg=[{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"payable",type:"function"}],$g=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Gg=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],qg=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],jg=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenIds",type:"uint256[]"},{name:"_amounts",type:"uint256[]"},{name:"_data",type:"bytes"}],name:"safeBatchTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Kg=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"},{name:"_amount",type:"uint256"},{name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Yg=(e,t)=>{let n=Zg(Hg,e);if(n)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:n.args[0],amount:n.args[1]};let r=Zg($u,e);if(r)return{action:"transfer",functionName:"transfer",isErc20Ish:!0,isNFTIsh:!1,transferTo:r.args[0],amount:r.args[1]};if(!t)return{action:"transaction",functionName:"",isErc20Ish:!1,isNFTIsh:!1};let a=Zg(Bg,e);if(a&&"string"==typeof a.args[1]){let e=Xg(a.args[1]);if(e&&e[4].encodedInitData)return Yg(e[4].encodedInitData,t)}let i=Zg(Gg,e);if(i)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:i.args[0],approved:i.args[1]};let o=Zg(qg,e);if(o)return{action:"transfer",functionName:"transferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:o.args[0],transferTo:o.args[1],tokenId:o.args[2]};let s=Zg($g,e);if(s)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:s.args[0],transferTo:s.args[1],tokenId:s.args[2]};let l=Zg(Kg,e);if(l)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:l.args[0],transferTo:l.args[1],tokenId:l.args[2],amount:l.args[3]};let c=Zg(jg,e);if(c)return{action:"batch transfer",functionName:"safeBatchTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:c.args[0],transferTo:c.args[1],tokenIds:c.args[2],amounts:c.args[3]};let d=Zg(Vg,e);return d?{action:"mint",functionName:d.functionName,isNFTIsh:!0,isErc20Ish:!1,args:d.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}};let Zg=(e,t)=>{try{let n=Ya({abi:e,data:t});return{functionName:n.functionName,args:n.args||[]}}catch(e){return null}},Xg=e=>{try{if("string"==typeof e)return Za(zg,`0x${e.slice(10)}`)}catch(e){return null}};const Qg=(e,t,n)=>{let[r,a]=s(null),{getAccessToken:i}=_r(),{walletProxy:l}=N();return o((()=>{r&&a(null),(async()=>{if(!await i()||!l||!t)return null;let r=[],a=!0,o=await wy(e,n,t.address).catch((t=>(t.details.includes("insufficient funds")?a=!1:r.push(t),e)));return{tx:o,totalGasEstimate:o.gas,hasFunds:a,errors:r}})().then(a)}),[e]),r};let Jg=new ba(new Aa("There was an issue preparing your transaction",Qi.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),ef=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0;const tf=/*#__PURE__*/ii.img.withConfig({displayName:"StyledLogo",componentId:"sc-68c1b1ea-0"})(["&&{height:",";width:",";border-radius:16px;margin-bottom:12px;}"],(e=>"sm"===e.size?"65px":"140px"),(e=>"sm"===e.size?"65px":"140px"));let nf=e=>{if(!Da(e))return e;try{return Qa(e)}catch{return e}},rf=e=>JSON.stringify(e,null,2),of=r=>{let{types:a,primaryType:i,...o}=r.typedData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Lg,{data:o}),/*#__PURE__*/t(vh,{text:rf(r.typedData),itemName:"full payload to clipboard"})," "]})};let sf=/*#__PURE__*/ii.div.withConfig({displayName:"InputHelp",componentId:"sc-cc107211-0"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-start;width:100%;margin-top:16px;margin-bottom:4px;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),lf=/*#__PURE__*/ii.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-cc107211-1"})(["display:flex;align-items:center;gap:8px;"]),cf=/*#__PURE__*/ii.div.withConfig({displayName:"IconContainer",componentId:"sc-cc107211-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),df=/*#__PURE__*/ii.div.withConfig({displayName:"Grow",componentId:"sc-cc107211-3"})(["flex-grow:1;"]);let hf=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-35bf31dd-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const uf=/*#__PURE__*/h(((r,a)=>{let[i,o]=s(""),[l,c]=s(""),[d,h]=s(!1),{authenticated:u,user:p}=_r(),{initUpdateEmail:m}=N(),{navigate:y,setModalData:g,currentScreen:f}=Tr(),{enabled:w,token:v}=gt(),C=Ar(),E=In(i)&&(C.disablePlusEmails&&i.includes("+")?(l||c("Please enter a valid email address without a '+'."),!1):(l&&c(""),!0)),T=d||!E,b=()=>{!w||v||u?(async e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");h(!0);try{await m(p.email.address,i,e),y(br.AWAITING_PASSWORDLESS_CODE)}catch(e){g({errorModalData:{error:e,previousScreen:f||br.LANDING}})}h(!1)})(v):(g({captchaModalData:{callback:e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");return m(p.email.address,i,e)},userIntentRequired:!1,onSuccessNavigateTo:br.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:br.ERROR_SCREEN}}),y(br.CAPTCHA_SCREEN))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(pf,{children:[l&&/*#__PURE__*/t(dn,{style:{marginTop:"0.25rem",textAlign:"left"},children:l}),/*#__PURE__*/e(mf,{$error:!!l,children:[/*#__PURE__*/t(gi,{}),/*#__PURE__*/t("input",{ref:a,id:"email-input",type:"email",placeholder:"your@email.com",onChange:e=>o(e.target.value),onKeyUp:e=>{"Enter"===e.key&&b()},value:i,autoComplete:"email"}),r.stacked?null:/*#__PURE__*/t(Nn,{isSubmitting:d,onClick:b,disabled:T,children:"Submit"})]})]}),r.stacked?/*#__PURE__*/t(wt,{loadingText:null,loading:d,disabled:T,onClick:b,children:"Submit"}):null]})}));let pf=xn,mf=Un;const yf=({style:e,...n})=>/*#__PURE__*/t("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"38px",width:"38px",...e},...n,children:/*#__PURE__*/t("path",{d:"M20 13.6V20M20 26.4H20.016M36 20C36 28.8365 28.8366 36 20 36C11.1635 36 4.00001 28.8365 4.00001 20C4.00001 11.1634 11.1635 3.99999 20 3.99999C28.8366 3.99999 36 11.1634 36 20Z",stroke:"currentColor",strokeWidth:"3.2",strokeLinecap:"round",strokeLinejoin:"round"})});let gf=/*#__PURE__*/ii.div.withConfig({displayName:"ConnectContainer",componentId:"sc-fc448c87-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-top:8px;padding-bottom:32px;"]),ff=/*#__PURE__*/ii.div.withConfig({displayName:"IconContainer",componentId:"sc-fc448c87-1"})(["display:flex;align-items:center;justify-content:center;height:72px;aspect-ratio:1;color:var(--privy-color-error);background-color:var(--privy-color-error-light);border-radius:50%;"]),wf=/*#__PURE__*/ii.div.withConfig({displayName:"GappedContainer",componentId:"sc-fc448c87-2"})(["display:flex;flex-direction:column;gap:8px;"]);let vf=/*#__PURE__*/ii(Qt).withConfig({displayName:"LogoContainer",componentId:"sc-1ae1f76-0"})(["margin:16px auto;"]);const Cf=/*#__PURE__*/si([":root{--privy-border-radius-sm:6px;--privy-border-radius-md:12px;--privy-border-radius-mdlg:16px;--privy-border-radius-lg:24px;--privy-border-radius-full:9999px;--privy-color-background:",";--privy-color-background-2:",";--privy-color-background-3:",";--privy-color-foreground:",";--privy-color-foreground-2:",";--privy-color-foreground-3:",";--privy-color-foreground-4:",";--privy-color-foreground-accent:",";--privy-color-accent:",";--privy-color-accent-light:",";--privy-color-accent-lightest:",";--privy-color-accent-dark:",";--privy-color-accent-darkest:",";--privy-color-success:",";--privy-color-success-dark:",";--privy-color-success-light:",";--privy-color-error:",";--privy-color-error-light:",";--privy-color-warn:",";--privy-color-warn-light:",";--privy-height-modal-full:620px;--privy-height-modal-compact:480px;};"],(e=>e.theme.background),(e=>e.theme.background2),(e=>e.theme.background3),(e=>e.theme.foreground),(e=>e.theme.foreground2),(e=>e.theme.foreground3),(e=>e.theme.foreground4),(e=>e.theme.foregroundAccent),(e=>e.theme.accent),(e=>e.theme.accentLight),(e=>e.theme.accentLightest),(e=>e.theme.accentDark),(e=>e.theme.accentDarkest),(e=>e.theme.success),(e=>e.theme.successDark),(e=>e.theme.successLight),(e=>e.theme.error),(e=>e.theme.errorLight),(e=>e.theme.warn),(e=>e.theme.warnLight)),Ef=/*#__PURE__*/ii.div.withConfig({displayName:"StylesWrapper",componentId:"sc-bc1e45b4-0"})([""," color:var(--privy-color-foreground-2);h3{font-size:16px;line-height:24px;font-weight:500;color:var(--privy-color-foreground-2);}h4{font-size:14px;line-height:20px;font-weight:500;color:var(--privy-color-foreground);}p{font-size:13px;line-height:20px;color:var(--privy-color-foreground-2);}button:focus,input:focus,optgroup:focus,select:focus,textarea:focus{outline:none;border-color:var(--privy-color-accent-light);box-shadow:0 0 0 1px var(--privy-color-accent-light);}.mobile-only{@media (min-width:441px){display:none;}}@keyframes fadein{0%{opacity:0;}100%{opacity:1;}}"],"\n *,\n ::before,\n ::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n }\n\n line-height: 1.15;\n -webkit-text-size-adjust: 100%;\n -moz-tab-size: 4;\n tab-size: 4;\n font-feature-settings: normal;\n\n margin: 0;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n display: inline;\n }\n\n a {\n color: inherit;\n text-decoration: inherit;\n }\n\n b,\n strong {\n font-weight: bolder;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n font-family: inherit;\n font-size: 100%;\n font-weight: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n }\n\n button,\n select {\n text-transform: none;\n }\n\n button,\n [type='button'],\n [type='reset'],\n [type='submit'] {\n -webkit-appearance: button;\n background-color: transparent;\n background-image: none;\n }\n\n ::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n :-moz-focusring {\n outline: 1px dotted ButtonText;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n legend {\n padding: 0;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [type='search'] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n }\n\n summary {\n display: list-item;\n }\n\n blockquote,\n dl,\n dd,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n hr,\n figure,\n p,\n pre {\n margin: 0;\n }\n\n fieldset {\n margin: 0;\n padding: 0;\n }\n\n legend {\n padding: 0;\n }\n\n ol,\n ul,\n menu {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n textarea {\n resize: vertical;\n }\n\n input::placeholder,\n textarea::placeholder {\n opacity: 1;\n color: #9ca3af;\n }\n\n button,\n [role='button'] {\n cursor: pointer;\n }\n\n :disabled {\n cursor: default;\n }\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n }\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n [hidden] {\n display: none;\n }\n"),Tf=({children:n,open:r,onClick:i,...o})=>/*#__PURE__*/t(ro,{show:r,as:a.Fragment,children:/*#__PURE__*/e(ao,{onClose:i,...o,as:Af,children:[/*#__PURE__*/t(io,{as:a.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/t(bf,{id:"privy-dialog-backdrop","aria-hidden":"true"})}),/*#__PURE__*/t(_f,{children:/*#__PURE__*/t(io,{as:a.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/t(oo,{as:kf,children:n})})})]})});let bf=/*#__PURE__*/ii.div.withConfig({displayName:"Backdrop",componentId:"sc-28ab5e6b-0"})(["position:fixed;inset:0;transition:backdrop-filter 100ms ease;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);&.entering,&.leaving{backdrop-filter:unset;-webkit-backdrop-filter:unset;}"]),Af=/*#__PURE__*/ii.div.withConfig({displayName:"DialogWrapper",componentId:"sc-28ab5e6b-1"})(["position:relative;z-index:999999;"]),_f=/*#__PURE__*/ii.div.withConfig({displayName:"DialogContainer",componentId:"sc-28ab5e6b-2"})(["position:fixed;inset:0;display:flex;align-items:center;justify-content:center;width:100vw;min-height:100vh;"]);const kf=/*#__PURE__*/ii.div.withConfig({displayName:"Panel",componentId:"sc-28ab5e6b-3"})(["padding:0;background:transparent;border:none;width:100%;pointer-events:auto;outline:none;display:block;@media (max-width:440px){opacity:1;transform:translate3d(0,0,0);transition:transform 200ms ease-in;position:fixed;bottom:0;&.entering,&.leaving{opacity:0;transform:translate3d(0,100%,0);transition:transform 150ms ease-in 0ms,opacity 0ms ease 150ms;}}@media (min-width:441px){opacity:1;transition:opacity 100ms ease-in;&.entering,&.leaving{opacity:0;transition-delay:5ms;}margin:auto;width:360px;box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]),If=/*#__PURE__*/ii.div.withConfig({displayName:"CenterItem",componentId:"sc-28ab5e6b-4"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;"]);let Nf={[br.LANDING]:()=>{let{app:e}=Tr();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/t(sm,{connectOnly:!1}):/*#__PURE__*/t(tm,{connectOnly:!1})},[br.CONNECT_OR_CREATE]:()=>{let{app:e}=Tr();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/t(sm,{connectOnly:!0}):/*#__PURE__*/t(tm,{connectOnly:!0})},[br.AWAITING_PASSWORDLESS_CODE]:()=>{let{app:r,navigate:a,lastScreen:i,navigateBack:l,setModalData:c,onUserCloseViaDialogOrKeybindRef:d}=Tr(),{closePrivyModal:h,resendEmailCode:u,resendSmsCode:p,getAuthMeta:m,loginWithCode:g,updateWallets:f,createAnalyticsEvent:w}=N(),{authenticated:v,logout:C,user:E}=_r(),[T,A]=s(sc),[_,k]=s(!1),[S,R]=s(null),[O,W]=s(null),[L,P]=s(0);d.current=()=>null;let M=m()?.email?0:1,U=kr-500;o((()=>{if(L){let e=setTimeout((()=>{P(L-1)}),1e3);return()=>clearTimeout(e)}}),[L]),o((()=>{if(v&&_&&E){if(r?.legal.requireUsersAcceptTerms&&!E.hasAcceptedTerms){let e=setTimeout((()=>{a(br.AFFIRMATIVE_CONSENT_SCREEN)}),U);return()=>clearTimeout(e)}if(Tt(E,r.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),w({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AwaitingPasswordlessCodeScreen"}}),C()},callAuthOnSuccessOnClose:!0}}),a(br.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),U);return()=>clearTimeout(e)}{f();let e=setTimeout((()=>h({shouldCallAuthOnSuccess:!0,isSuccess:!0})),kr);return()=>clearTimeout(e)}}}),[v,_,E]),o((()=>{if(S&&0===O){let e=setTimeout((()=>{A(sc),R(null);let e=document.querySelector("input[name=code-0]");e?.focus()}),1400);return()=>clearTimeout(e)}}),[S]);let D=e=>{e.preventDefault();let t=e.currentTarget.value.replace(" ","");if(""===t)return;if(isNaN(Number(t)))return R("Code should be numeric"),void W(1);R(null),W(null);let n=Number(e.currentTarget.name?.charAt(5)),r=[...t||[""]].slice(0,6-n),o=[...T.slice(0,n),...r,...T.slice(n+r.length)];A(o);let s=Math.min(Math.max(n+r.length,0),5);if(!isNaN(Number(e.currentTarget.value))){let e=document.querySelector(`input[name=code-${s}]`);e?.focus()}if(o.every((e=>e&&!isNaN(+e)))){let e=document.querySelector(`input[name=code-${s}]`);e?.blur(),g(o.join("")).then((()=>k(!0))).catch((e=>{if(e instanceof I&&e.privyErrorCode===b.INVALID_CREDENTIALS)R("Invalid or expired verification code");else if(e instanceof I&&e.privyErrorCode===b.CANNOT_LINK_MORE_OF_TYPE)R(e.message);else{if(e instanceof I&&e.privyErrorCode===b.USER_LIMIT_REACHED)return console.error(new x(e).toString()),void a(br.USER_LIMIT_REACHED_SCREEN);if(e instanceof I&&e.privyErrorCode===b.USER_DOES_NOT_EXIST)return void a(br.ACCOUNT_NOT_FOUND_SCREEN);if(e instanceof I&&e.privyErrorCode===b.LINKED_TO_ANOTHER_USER)return c({errorModalData:{error:e,previousScreen:i??br.AWAITING_PASSWORDLESS_CODE}}),void a(br.ERROR_SCREEN,!1);if(e instanceof I&&e.privyErrorCode===b.DISALLOWED_PLUS_EMAIL)return c({inlineError:{error:e}}),void a(br.CONNECT_OR_CREATE,!1);if(e instanceof I&&e.privyErrorCode===b.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return c({accountTransfer:{nonce:e.data?.data?.nonce,account:0===M?m()?.email:m()?.phoneNumber,displayName:e.data?.data?.account?.displayName,linkMethod:0===M?"email":"sms",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void a(br.LINK_CONFLICT_SCREEN);R("Issue verifying code")}W(0)}))}},F=0==M?/*#__PURE__*/t(gi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"}):
12
- /*#__PURE__*/t(fi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),B=/*#__PURE__*/e("p",0==M?{children:["Please check ",/*#__PURE__*/t(wc,{children:m()?.email})," for an email from privy.io and enter your code below."]}:{children:["Please check ",/*#__PURE__*/t(wc,{children:m()?.phoneNumber})," for a message from ",r?.name||"Privy"," and enter your code below."]});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:()=>l()},"header"),/*#__PURE__*/e(uc,{children:[/*#__PURE__*/t(ac,{title:"Enter confirmation code",description:B,icon:F}),/*#__PURE__*/e(bt,{children:[/*#__PURE__*/e(pc,{children:[/*#__PURE__*/t(mc,{$fail:!!S,$success:_,children:/*#__PURE__*/t("span",{children:S||(_?"Success!":"")})}),/*#__PURE__*/t("div",{children:T.map(((e,n)=>/*#__PURE__*/t("input",{name:`code-${n}`,type:"text",value:T[n],onChange:D,onKeyUp:e=>{"Backspace"===e.key&&(e=>{if(1===O&&(R(null),W(null)),A([...T.slice(0,e),"",...T.slice(e+1)]),e>0){let t=document.querySelector(`input[name=code-${e-1}]`);t?.focus()}})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:`${_?"success":""} ${S?"fail":""}`,autoComplete:y?"one-time-code":"off"},n)))})]}),/*#__PURE__*/e(yc,{children:[/*#__PURE__*/e("span",{children:["Didn't get ",0==M?"an email":"a message","?"]}),L?/*#__PURE__*/e(fc,{children:[/*#__PURE__*/t(yi,{color:"var(--privy-color-foreground)",strokeWidth:1.33,height:"12px",width:"12px"}),/*#__PURE__*/t("span",{children:"Code sent"})]}):/*#__PURE__*/t(gc,{children:/*#__PURE__*/t("button",{onClick:async()=>{P(30),0==M?await u():await p()},children:"Resend code"})})]})]})]}),/*#__PURE__*/t(Ct,{})]})},[br.AWAITING_CONNECTION]:Fn,[br.AWAITING_CONNECT_ONLY_CONNECTION]:()=>{let r,{navigateBack:a,navigate:i,lastScreen:l,currentScreen:c,data:d,setModalData:h}=Tr(),{walletConnectionStatus:u,closePrivyModal:p}=N(),[m,g]=s(void 0),[f,w]=s(0),v="connected"===u?.status,C="switching_to_supported_chain"===u?.status;o((()=>{if(v){let e;if(d?.externalConnectWallet?.onCompleteNavigateTo){let t=d.externalConnectWallet.onCompleteNavigateTo,n=u.connectedWallet?.address;e=setTimeout((()=>{d.funding&&h({...d,funding:{...d.funding,connectedWalletAddress:n}}),i(t({walletChainType:u.connector?.chainType}))}),kr)}else e=setTimeout(p,kr);return()=>clearTimeout(e)}}),[v]);o((()=>{u?.connectError&&(e=>{g(Mt(e))})(u?.connectError)}),[u]);let E=u?.connector?.connectorType||"injected",T=u?.connector?.walletClientType||"unknown",b=Lt[T]?.displayName||u?.connector?.walletBranding.name||"Browser Extension",A=Lt[T]?.logo||u?.connector?.walletBranding.icon||(e=>/*#__PURE__*/t(tt,{...e})),_="Browser Extension"===b?b.toLowerCase():b;r=v?`Successfully connected with ${_}`:m?m.message:C?"Switching networks":`Waiting for ${_}`;let k="Don’t see your wallet? Check your other browser windows.";return v?k="You’re good to go!":f>=2&&m?k="Unable to connect wallet":m?k=m.detail:C?k="Switch your wallet to the requested network.":"metamask"===T&&y?k="Click to continue to open and connect MetaMask.":"metamask"===T?k="For the best experience, connect only one wallet at a time.":"wallet_connect_v2"===E?k="Open your mobile wallet app to continue":"coinbase_wallet"===E&&(k="Open the Coinbase app on your phone to continue."),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{backFn:c===l?void 0:a}),/*#__PURE__*/e(Pc,{children:[/*#__PURE__*/t(Pt,{walletLogo:A,success:v,fail:!!m}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t("h3",{children:r}),/*#__PURE__*/t("p",{children:k})]}),m==ga.ERROR_USER_EXISTS?/*#__PURE__*/t(wt,{onClick:a,children:"Use a different wallet"}):!v&&m?.retryable&&f<2?/*#__PURE__*/t(wt,{onClick:()=>{w(f+1),g(void 0),u?.connectRetry()},disabled:!v&&(!m?.retryable||f>=2),children:"Retry"}):!v&&m&&f>=2?/*#__PURE__*/t(wt,{onClick:a,children:"Use a different wallet"}):null]}),/*#__PURE__*/t(kt,{})]})},[br.AWAITING_FARCASTER_CONNECTION]:()=>{let{authenticated:r,logout:a,ready:i,user:c}=_r(),{lastScreen:d,navigate:h,navigateBack:u,setModalData:p,app:m}=Tr(),{getAuthFlow:g,loginWithFarcaster:w,closePrivyModal:v,createAnalyticsEvent:C}=N(),[E,T]=s(void 0),[A,_]=s(!1),[k,I]=s(!1),S=l([]),R=g(),O=R?.meta.connectUri;return o((()=>{let e=Date.now(),t=setInterval((async()=>{let n=await R.pollForReady.execute(),r=Date.now()-e;if(n){clearInterval(t),_(!0);try{await w(),I(!0)}catch(e){let t={retryable:!1,message:"Authentication failed"};if(e?.privyErrorCode===b.ALLOWLIST_REJECTED)return void h(br.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===b.USER_LIMIT_REACHED)return console.error(new x(e).toString()),void h(br.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===b.USER_DOES_NOT_EXIST)return void h(br.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===b.LINKED_TO_ANOTHER_USER)t.detail=e.message??"This account has already been linked to another user.";else{if(e?.privyErrorCode===b.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return p({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:"farcaster",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,farcasterEmbeddedAddress:e.data?.data?.otherUser?.farcasterEmbeddedAddress}}),void h(br.LINK_CONFLICT_SCREEN);e?.privyErrorCode===b.INVALID_CREDENTIALS?(t.retryable=!0,t.detail="Something went wrong. Try again."):e?.privyErrorCode===b.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again.")}T(t)}}else r>12e4&&(clearInterval(t),T({retryable:!0,message:"Authentication failed",detail:"The request timed out. Try again."}))}),2e3);return()=>{clearInterval(t),S.current.forEach((e=>clearTimeout(e)))}}),[]),o((()=>{if(i&&r&&k&&c){if(m?.legal.requireUsersAcceptTerms&&!c.hasAcceptedTerms){let e=setTimeout((()=>{h(br.AFFIRMATIVE_CONSENT_SCREEN)}),kr);return()=>clearTimeout(e)}k&&(Tt(c,m.embeddedWallets)?S.current.push(setTimeout((()=>{p({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),C({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"FarcasterConnectStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(br.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),kr)):S.current.push(setTimeout((()=>v({shouldCallAuthOnSuccess:!0,isSuccess:!0})),kr)))}}),[k,i,r,c]),/*#__PURE__*/e(n,y||A?{children:[/*#__PURE__*/t(ft,{backFn:d?u:void 0,onClose:v},"header"),/*#__PURE__*/t(Dt,{}),
13
- /*#__PURE__*/t(n,f?{children:/*#__PURE__*/e(kh,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{success:k,fail:!!E}),/*#__PURE__*/t(bh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t(Ll,{children:E?E.message:"Sign in with Farcaster"}),/*#__PURE__*/t(Pl,{children:E?E.detail:"To sign in with Farcaster, please open the Warpcast app."})]}),O&&/*#__PURE__*/t(wt,{onClick:e=>{e.preventDefault(),window.location.href=O},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(_h,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{success:k,fail:!!E}),/*#__PURE__*/t(bh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t(Ll,{children:E?E.message:"Signing in with Farcaster"}),/*#__PURE__*/t(Pl,{children:E?E.detail:"This should only take a moment"}),/*#__PURE__*/t(Qt,{children:O&&y&&/*#__PURE__*/t(Eh,{text:"Take me to Warpcast",url:O,color:Ah})})]})]})}),/*#__PURE__*/t(kt,{})]}:{children:[/*#__PURE__*/t(ft,{backFn:d?u:void 0,onClose:v},"header"),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(_h,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Ll,{children:"Sign in with Farcaster"}),/*#__PURE__*/t(Pl,{children:"Scan with your phone's camera to continue."}),/*#__PURE__*/t(Jt,{children:O?/*#__PURE__*/t(en,{url:O,size:275,squareLogoElement:bh}):/*#__PURE__*/t(tn,{})}),/*#__PURE__*/e(Qt,{children:[/*#__PURE__*/t(Pl,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),O&&/*#__PURE__*/t(vh,{text:O,itemName:"link",color:Ah})]})]})}),/*#__PURE__*/t(kt,{})]})},[br.AWAITING_FARCASTER_SIGNER]:()=>{let{lastScreen:r,navigateBack:a,data:i,app:c}=Tr(),{requestFarcasterSignerStatus:d,closePrivyModal:h}=N(),[u,p]=s(void 0),[m,g]=s(!1),[w,v]=s(!1),C=l([]),E=i?.farcasterSigner;o((()=>{let e=Date.now(),t=setInterval((async()=>{if(!E?.public_key)return clearInterval(t),void p({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===E.status&&(clearInterval(t),g(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),kr)));let n=await d(E?.public_key),r=Date.now()-e;"approved"===n.status?(clearInterval(t),g(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),kr))):r>3e5?(clearInterval(t),p({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===n.status&&(clearInterval(t),p({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),C.current.forEach((e=>clearTimeout(e)))}}),[]);let T="pending_approval"===E?.status?E.signer_approval_url:void 0;/*#__PURE__*/return e(n,y||m?{children:[/*#__PURE__*/t(ft,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(Dt,{}),
14
- /*#__PURE__*/t(n,f?{children:/*#__PURE__*/e(xh,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{success:w,fail:!!u}),/*#__PURE__*/t(bh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t(Ll,{children:u?u.message:"Add a signer to Farcaster"}),/*#__PURE__*/t(Pl,{children:u?u.detail:"This will allow "+c.name+" to add casts, likes, follows, and more on your behalf."})]}),T&&/*#__PURE__*/t(wt,{onClick:e=>{e.preventDefault(),window.location.href=T},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(Nh,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{success:w,fail:!!u}),/*#__PURE__*/t(bh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t(Ll,{children:u?u.message:"Requesting signer from Farcaster"}),/*#__PURE__*/t(Pl,{children:u?u.detail:"This should only take a moment"}),/*#__PURE__*/t(Qt,{children:T&&y&&/*#__PURE__*/t(Eh,{text:"Take me to Warpcast",url:T,color:Ih})})]})]})}),/*#__PURE__*/t(kt,{})]}:{children:[/*#__PURE__*/t(ft,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(Nh,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Ll,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e(Pl,{children:["This will allow ",c.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/t(Jt,{children:"pending_approval"===E?.status?/*#__PURE__*/t(en,{url:E.signer_approval_url,size:275,squareLogoElement:bh}):/*#__PURE__*/t(tn,{})}),/*#__PURE__*/e(Qt,{children:[/*#__PURE__*/t(Pl,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===E?.status&&/*#__PURE__*/t(vh,{text:E.signer_approval_url,itemName:"link",color:Ih})]})]})}),/*#__PURE__*/t(kt,{})]})},[br.SELECT_PASSKEY_SIGNUP_OR_LOGIN]:()=>{let{enabled:r,token:a}=gt(),{lastScreen:i,currentScreen:o,navigateBack:s,navigate:l,setModalData:c}=Tr(),{initSignupWithPasskey:d,initLoginWithPasskey:h}=N();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:i&&o!==i?s:void 0}),/*#__PURE__*/t(Wl,{children:/*#__PURE__*/e(_y,{children:[/*#__PURE__*/t(hu,{}),/*#__PURE__*/t(uu,{})]})}),/*#__PURE__*/t(Ll,{children:"Log in or create a new account?"}),/*#__PURE__*/t(Pl,{children:"Create a new account with a passkey or use a passkey to log in to an existing account."}),/*#__PURE__*/e(Bl,{children:[/*#__PURE__*/t(wt,{onClick:async()=>{r&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!0},captchaModalData:{callback:e=>d({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:br.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:br.ERROR_SCREEN}}),l(br.CAPTCHA_SCREEN)):(await d({withPrivyUi:!0}),c({passkeyAuthModalData:{passkeySignupFlow:!0}}),l(br.AWAITING_PASSKEY_SYSTEM_DIALOGUE))},children:"Create new account"}),/*#__PURE__*/t(Kl,{onClick:async()=>{r&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>h({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:br.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:br.ERROR_SCREEN}}),l(br.CAPTCHA_SCREEN)):(await h({withPrivyUi:!0}),c({passkeyAuthModalData:{passkeySignupFlow:!1}}),l(br.AWAITING_PASSKEY_SYSTEM_DIALOGUE))},children:"Log in with a passkey"})]}),/*#__PURE__*/t(Ct,{})]})},[br.AWAITING_PASSKEY_SYSTEM_DIALOGUE]:()=>{let{app:r,lastScreen:a,currentScreen:i,navigateBack:c,data:d,setModalData:h,navigate:u}=Tr(),{loginWithPasskey:p,signupWithPasskey:m,closePrivyModal:y,createAnalyticsEvent:g}=N(),{user:f,logout:w}=_r(),{passkeySignupFlow:v}=d?.passkeyAuthModalData??{},C=kr-500,[E,T]=s("loading"),[A,_]=s(null),k=l([]),I=e=>{k.current=[e,...k.current]};o((()=>()=>{k.current.forEach((e=>clearTimeout(e))),k.current=[]}),[]);let x=async()=>{T("loading");try{v?await m():await p(),T("success")}catch(e){_(e),T("error")}};return o((()=>{if("success"===E&&f){if(r?.legal.requireUsersAcceptTerms&&!f.hasAcceptedTerms)return void I(setTimeout((()=>{u(br.AFFIRMATIVE_CONSENT_SCREEN)}),C));if(!Tt(f,r?.embeddedWallets))return void I(setTimeout((()=>{y({shouldCallAuthOnSuccess:!0,isSuccess:!0})}),kr));I(setTimeout((()=>{h({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),g({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"PasskeyStatusScreen"}}),w()},callAuthOnSuccessOnClose:!0}}),u(br.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),C))}}),[f,E]),o((()=>{x()}),[]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{backFn:a&&i!==a?c:void 0}),/*#__PURE__*/e(ky,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{success:"success"===E,fail:"error"===E}),/*#__PURE__*/t(uu,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t("h3",{children:(()=>{switch(E){case"loading":return"Waiting for passkey";case"success":return"Success";case"error":return"Something went wrong"}})()}),/*#__PURE__*/t("p",{style:{whiteSpace:"pre-wrap"},children:(()=>{switch(E){case"loading":return v?"Please follow prompts to register your passkey.":"Please follow prompts to verify your passkey.\nYou will have to sign up with another method first to register a passkey for your account.";case"success":return"You've successfully logged in with your passkey.";case"error":if(A instanceof O){if(A.privyErrorCode===b.CANNOT_LINK_MORE_OF_TYPE)return"Cannot link more passkeys to account.";if(A.privyErrorCode===b.PASSKEY_NOT_ALLOWED)return"Passkey request timed out or rejected by user.\nYou will have to sign up with another method first to register a passkey for your account."}return"An unknown error occurred.\nYou will have to sign up with another method first to register a passkey for your account."}})()})]}),(()=>{switch(E){case"loading":case"success":/*#__PURE__*/return t(wt,{onClick:()=>{},disabled:!0,children:"Continue"});case"error":/*#__PURE__*/return t(wt,{onClick:x,disabled:!1,children:"Retry"})}})()]}),/*#__PURE__*/t(kt,{})]})},[br.WALLET_INTERSTITIAL_SCREEN]:()=>{let{ready:r}=_r(),{data:a}=Tr(),[i,o]=s(!1);if(!a?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:l,connectOnly:c,chainType:d}=a.installWalletModalData,h=l.getMobileRedirect({useUniversalLink:!i,isSolana:"solana"===d,connectOnly:c}),u={title:`Redirecting to ${l.name} Mobile Wallet`,description:`We'll take you to the ${l.name} Mobile Wallet app to continue your login experience.`,footnote:""};r&&(u.description=`For the best experience, we'll automatically log you into the ${l.name} Mobile Wallet in-app browser.`,u.footnote="Once you're done, you can always return here and refresh to view your updated account."),i&&(u.title="Still here?",u.description=`You may need to install the ${l.name} mobile app.`,u.footnote=`Once you're done, you can return here or connect via ${l.name}'s in-app browser.`);let p=l.logo;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{},"header"),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(rc,{title:u.title,description:u.description}),/*#__PURE__*/e(_n,{children:[!!p&&/*#__PURE__*/t(vf,{children:/*#__PURE__*/t(p,{style:{width:"72px",height:"72px"}})}),!p&&!!l.logoDataUri&&/*#__PURE__*/t(Qt,{children:/*#__PURE__*/t("img",{src:l.logoDataUri,alt:l.name,style:{width:"72px",height:"72px"}})}),/*#__PURE__*/t(Dn,{href:h,onClick:()=>{setTimeout((()=>o(!0)),1e3)},loading:r&&!h,children:i?"Go to App Store":"Continue"}),u.footnote?/*#__PURE__*/t("p",{children:u.footnote}):null]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.LOGIN_FAILED_SCREEN]:()=>{let{closePrivyModal:r}=N(),{navigate:a}=Tr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{},"header"),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(dm,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/t(rc,{title:"Could not connect with wallet",description:"Please check that Phantom multichain is enabled and try again.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/e(_n,{children:[/*#__PURE__*/t(wt,{onClick:()=>a(br.LANDING),children:"Try again"}),/*#__PURE__*/t(Et,{onClick:()=>r(),children:"Cancel"})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.AWAITING_OAUTH_SCREEN]:()=>{let{authenticated:r,logout:a,ready:i,user:l}=_r(),{app:c,setModalData:d,navigate:h,resetNavigation:u}=Tr(),{getAuthMeta:p,initLoginWithOAuth:m,loginWithOAuth:y,updateWallets:g,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v}=N(),[C,E]=s(!1),[T,A]=s(void 0),_=p()?.provider||"google",{name:k,component:I}=ts(_);o((()=>{y(_).then((()=>{E(!0),f(!0)})).catch((e=>{if(f(!1),e?.privyErrorCode===b.ALLOWLIST_REJECTED)return A(void 0),u(),void h(br.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===b.USER_LIMIT_REACHED)return console.error(new x(e).toString()),A(void 0),u(),void h(br.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===b.USER_DOES_NOT_EXIST)return A(void 0),u(),void h(br.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===b.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return A(void 0),u(),d({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:p()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void h(br.LINK_CONFLICT_SCREEN);let{retryable:t,detail:n}=function(e,t){let n={detail:"",retryable:!1},r=Vo(t);if(e?.privyErrorCode===b.LINKED_TO_ANOTHER_USER&&(n.detail="This account has already been linked to another user."),e?.privyErrorCode===b.INVALID_CREDENTIALS&&(n.retryable=!0,n.detail="Something went wrong. Try again."),e.privyErrorCode===b.OAUTH_USER_DENIED&&(n.detail=`Retry and check ${r} to finish connecting your account.`,n.retryable=!0),e?.privyErrorCode===b.TOO_MANY_REQUESTS&&(n.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===b.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=ts(t).name;n.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===b.OAUTH_ACCOUNT_SUSPENDED){let e=ts(t).name;n.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===b.CANNOT_LINK_MORE_OF_TYPE&&(n.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===b.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(n.detail="Something went wrong. Please try again."),n}(e,_);A({retryable:t,detail:n,message:"Authentication failed"})})).finally((()=>{rs()}))}),[k,_]),o((()=>{if(i&&r&&C&&l){if(c?.legal.requireUsersAcceptTerms&&!l.hasAcceptedTerms){let e=setTimeout((()=>{h(br.AFFIRMATIVE_CONSENT_SCREEN)}),kr);return()=>clearTimeout(e)}if(Tt(l,c.embeddedWallets)){let e=setTimeout((()=>{d({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:_,screen:"OAuthStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(br.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),kr);return()=>clearTimeout(e)}{let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),kr);return g(),()=>clearTimeout(e)}}}),[i,r,C,l]);let S=C?`Successfully connected with ${k}`:T?T.message:`Verifying connection to ${k}`,R="";return R=C?"You’re good to go!":T?T.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Ay,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{success:C,fail:!!T}),/*#__PURE__*/t(I,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t("h3",{children:S}),/*#__PURE__*/t("p",{children:R})]}),T&&T?.retryable?/*#__PURE__*/t(kn,{onClick:()=>{rs(),m(_),A(void 0)},disabled:!C&&!T?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(kt,{})]})},[br.CROSS_APP_AUTH_SCREEN]:()=>{let r=Ar(),{data:a,navigate:l,setModalData:c,onUserCloseViaDialogOrKeybindRef:d}=Tr(),{crossAppAuthFlow:h,updateWallets:u,closePrivyModal:p,createAnalyticsEvent:m}=N(),{logout:y}=Ut(),[g,f]=s({}),w=a?.crossAppAuth,v={id:w.appId,name:w.name,logoUrl:w.logoUrl},C=new E(`There was an issue connecting your ${v.name} account. Please try again.`),T=new je((async e=>{if(w.popup)try{let t=await h({appId:e,popup:w.popup,action:w.action});f({data:t})}catch(e){e instanceof E?f({error:e}):(e instanceof I&&w.popup&&w.popup.close(),f({error:C}))}else f({error:C})})),b=()=>{g.data&&(u(),w.onSuccess(g.data),p({shouldCallAuthOnSuccess:!0,isSuccess:!0})),w.onError(g.error??new E("User canceled flow")),p({shouldCallAuthOnSuccess:!1,isSuccess:!1})};d.current=b,o((()=>{v.id.length&&T.execute(v.id)}),[v.id]),o((()=>{if(!g.data)return;let e=g.data;if(r.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{l(br.AFFIRMATIVE_CONSENT_SCREEN)}),kr);return()=>clearTimeout(e)}if(Tt(e,r.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),m({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${v.id}`,screen:"CrossAppAuthScreen"}}),y()},callAuthOnSuccessOnClose:!0}}),l(br.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),kr);return()=>clearTimeout(e)}let t=setTimeout(b,kr);return()=>clearTimeout(t)}),[g.data]);let{title:A,subtitle:_}=i((()=>g.data?{title:`Successfully connected with ${v.name}`,subtitle:"You're good to go!"}:g.error?{title:"Authentication failed",subtitle:g.error.message}:{title:`Connecting to ${v.name}`,subtitle:`Please check the pop-up from ${v.name} to continue`}),[g,v.name]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:b}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Uc,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{success:!!g.data,fail:!!g.error}),/*#__PURE__*/t(Mc,{name:v.name,logoUrl:v.logoUrl})]})}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t("h3",{children:A}),/*#__PURE__*/t("p",{children:_})]})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(kt,{})]})},[br.ALLOWLIST_REJECTION_SCREEN]:()=>{let{navigate:r,app:a}=Tr(),i=a?.allowlistConfig.errorTitle||"You don't have access to this app",o=a?.allowlistConfig.errorDetail||"Have you been invited?",s=a?.allowlistConfig.errorCtaText||"Try another account";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{}),/*#__PURE__*/e(ec,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(wl,{}),/*#__PURE__*/t(Jl,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})]})}),/*#__PURE__*/e(tc,{children:[/*#__PURE__*/t("string"==typeof i?"h3":n,{children:i}),/*#__PURE__*/t("string"==typeof o?"p":n,{children:o})]}),a?.allowlistConfig.errorCtaLink?
15
- /*#__PURE__*/t(wt,{as:"a",href:a.allowlistConfig.errorCtaLink,children:s}):/*#__PURE__*/t(wt,{onClick:()=>{r(br.LANDING)},children:s})]})]})},[br.ACCOUNT_NOT_FOUND_SCREEN]:()=>{let{navigate:r,app:a,setModalData:i,data:o}=Tr(),{getAuthMeta:s,client:l}=N();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{}),/*#__PURE__*/e(gl,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(rl,{color:"var(--privy-color-warn-light)"}),/*#__PURE__*/t(li,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-warn)"})]})}),/*#__PURE__*/e(fl,{children:[/*#__PURE__*/t("h3",{children:"Account not found"}),/*#__PURE__*/e("p",{children:["Please try logging in again or go to ",a.name," to create an account."]})]}),/*#__PURE__*/t(il,{}),/*#__PURE__*/t(wt,{onClick:()=>{let e=s();i({...o,login:{...o?.login,...e?.disableSignup?{disableSignup:!0}:{}}}),l?.authFlow&&(l.authFlow=void 0),r(br.LANDING)},children:"Try logging in again"})]})]})},[br.USER_LIMIT_REACHED_SCREEN]:()=>{let{navigate:r}=Tr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{}),/*#__PURE__*/e(gf,{children:[/*#__PURE__*/t(ff,{children:/*#__PURE__*/t(yf,{})}),/*#__PURE__*/e(wf,{children:[/*#__PURE__*/t("h3",{children:"Unable to sign in"}),/*#__PURE__*/t("p",{children:"This application has reached its user limit and cannot sign in new users."})]}),/*#__PURE__*/t(wt,{onClick:()=>{r(br.LANDING)},children:"Go back"})]}),/*#__PURE__*/t(Ct,{})]})},[br.INSTALL_WALLET_SCREEN]:()=>{let{navigateBack:r,data:a}=Tr();if(!a?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:i}=a.installWalletModalData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:r},"header"),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(_p,{...i}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/e(kt,{children:[/*#__PURE__*/t("span",{children:"Still not sure? "}),/*#__PURE__*/t("a",{target:"_blank",href:"https://solana.com/docs/intro/wallets",children:"Learn more"})]})]})},[br.LINK_EMAIL_SCREEN]:()=>{let{app:r}=Tr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{},"header"),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(ac,{title:"Connect your email",description:`Add your email to your ${r?.name} account`,icon:/*#__PURE__*/t(gi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(_n,{children:/*#__PURE__*/t(Wp,{stacked:!0})}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.LINK_PHONE_SCREEN]:()=>{let{app:r,currentScreen:a,data:i,navigate:o,setModalData:s}=Tr(),{initLoginWithSms:l}=N();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{},"header"),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(ac,{title:"Connect your phone",description:`Add your number to your ${r?.name} account`,icon:/*#__PURE__*/t(fi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/t(_n,{children:/*#__PURE__*/t($p,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await l({phoneNumber:e,withPrivyUi:!0}),o(br.AWAITING_PASSWORDLESS_CODE)}catch(e){s({errorModalData:{error:e,previousScreen:i?.errorModalData?.previousScreen||a||br.LINK_PHONE_SCREEN}}),o(br.ERROR_SCREEN)}},hideRecent:!0})}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.LINK_WALLET_SCREEN]:()=>{let{app:r,data:a}=Tr(),i=a?.externalConnectWallet?.suggestedAddress,o=i?/*#__PURE__*/e("span",{children:["Link the wallet with address ",/*#__PURE__*/t(vt,{showCopyIcon:!1,address:i})," ",r?.name?`to ${r.name}.`:"."]}):`Link a wallet to your ${r?.name} account`,{connectors:s}=N(),l=Lc({walletList:a?.externalConnectWallet?.walletList??r.appearance.walletList,walletChainType:a?.externalConnectWallet?.walletChainType??r.appearance.walletChainType,connectors:s,connectOnly:!1,ignore:r.appearance.walletList,walletConnectEnabled:r.externalWallets.walletConnect.enabled});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{},"header"),l.length>0&&/*#__PURE__*/t(rc,{title:"Link your wallet",description:o}),/*#__PURE__*/t(sl,{children:/*#__PURE__*/t(Wc,{wallets:l})}),/*#__PURE__*/t(Ct,{})]})},[br.LINK_PASSKEY_SCREEN]:()=>{let{user:r,unlinkPasskey:a}=_r(),{linkWithPasskey:i,closePrivyModal:l}=N(),c=r?.linkedAccounts.filter((e=>"passkey"===e.type)),[d,h]=s(!1),[u,p]=s(""),[m,y]=s(!1),[g,f]=s(!1);o((()=>{0===c.length&&f(!1)}),[c.length]);let w=async e=>(h(!0),await a(e).then((()=>y(!0))).catch((e=>{e instanceof O&&e.privyErrorCode===b.MISSING_MFA_CREDENTIALS?p("Cannot unlink a passkey enrolled in MFA"):p("Unknown error occurred.")})).finally((()=>{h(!1)})));/*#__PURE__*/return e(n,m?{children:[/*#__PURE__*/t(ft,{onClose:()=>l()},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ci,{})}),/*#__PURE__*/t(Cu,{style:{marginBottom:"1.5rem"},children:"Passkeys updated"}),/*#__PURE__*/t(Eu,{children:" "}),/*#__PURE__*/t(Bl,{children:/*#__PURE__*/t(wt,{onClick:()=>l(),children:"Done"})}),/*#__PURE__*/t(kt,{})]}:g?{children:[/*#__PURE__*/t(ft,{backFn:()=>f(!1),onClose:()=>l()},"header"),/*#__PURE__*/t(pu,{passkeys:c,expanded:g,onUnlink:w,onExpand:()=>f(!0)}),/*#__PURE__*/t(kt,{})]}:{children:[/*#__PURE__*/t(ft,{onClose:()=>l()},"header"),/*#__PURE__*/t(Wl,{children:/*#__PURE__*/e(yu,{children:[/*#__PURE__*/t(hu,{}),/*#__PURE__*/t(uu,{})]})}),/*#__PURE__*/t(Cu,{children:"Secure your account with a passkey"}),/*#__PURE__*/t(Tu,{}),0===c.length?/*#__PURE__*/t(mu,{}):/*#__PURE__*/t(pu,{passkeys:c,expanded:g,onUnlink:w,onExpand:()=>f(!0)}),/*#__PURE__*/e(Bl,{style:{marginTop:"12px"},children:[u&&/*#__PURE__*/t(gu,{$fail:!0,children:u}),/*#__PURE__*/t(wt,{onClick:()=>{h(!0),i().then((()=>y(!0))).catch((e=>{if(e instanceof O){if(e.privyErrorCode===b.CANNOT_LINK_MORE_OF_TYPE)return void p("Cannot link more passkeys to account.");if(e.privyErrorCode===b.PASSKEY_NOT_ALLOWED)return void p("Passkey request timed out or rejected by user.")}p("Unknown error occurred.")})).finally((()=>{h(!1)}))},loading:d,children:"Add new passkey"})]}),/*#__PURE__*/t(kt,{})]})},[br.UPDATE_EMAIL_SCREEN]:()=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{},"header"),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(ac,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/t(gi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(_n,{children:/*#__PURE__*/t(uf,{stacked:!0})}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]}),[br.UPDATE_PHONE_SCREEN]:()=>{let{currentScreen:r,data:a,navigate:i,setModalData:o}=Tr(),{user:s}=_r(),{initUpdatePhone:l}=N();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{},"header"),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(ac,{title:"Update your phone number",description:"Add the phone number you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/t(fi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(_n,{children:/*#__PURE__*/t($p,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{if(!s?.phone?.number)throw Error("User is required to have an phone number to update it.");await l(s?.phone?.number,e),i(br.AWAITING_PASSWORDLESS_CODE)}catch(e){o({errorModalData:{error:e,previousScreen:a?.errorModalData?.previousScreen||r||br.LINK_PHONE_SCREEN}}),i(br.ERROR_SCREEN)}},hideRecent:!0})}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.CONNECT_ONLY_LANDING_SCREEN]:()=>{let{app:r,data:a}=Tr(),i=a?.externalConnectWallet?.suggestedAddress,o=i?/*#__PURE__*/e("span",{children:["Connect the wallet with address ",/*#__PURE__*/t(vt,{showCopyIcon:!1,address:i})," ",r?.name?`to ${r.name}.`:"."]}):`Connect a wallet to your ${r?.name} account`,{connectors:s}=N(),l=Lc({walletList:a?.externalConnectWallet?.walletList??r.appearance.walletList,walletChainType:a?.externalConnectWallet?.walletChainType??r.appearance.walletChainType,connectors:s,connectOnly:!0,ignore:r.appearance.walletList,walletConnectEnabled:r.externalWallets.walletConnect.enabled});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{},"header"),l.length>0&&/*#__PURE__*/t(nc,{title:"Connect your wallet",description:o}),/*#__PURE__*/t(sl,{children:/*#__PURE__*/t(Wc,{wallets:l})}),r&&/*#__PURE__*/t(Wt,{app:r,alwaysShowImplicitConsent:!0}),/*#__PURE__*/t(Ct,{})]})},[br.CONNECT_ONLY_AUTHENTICATED_SCREEN]:()=>{let{app:r,data:a}=Tr(),i=a?.externalConnectWallet?.suggestedAddress,o=i?`Connect the wallet with address ${Ot(i)} ${r?.name?`to ${r.name}.`:"."}`:`Connect a wallet to ${r?.name}`,{connectors:s}=N(),l=Lc({walletList:a?.externalConnectWallet?.walletList??r.appearance.walletList,walletChainType:a?.externalConnectWallet?.walletChainType??r.appearance.walletChainType,connectors:s,connectOnly:!0,ignore:r.appearance.walletList,walletConnectEnabled:r.externalWallets.walletConnect.enabled});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{},"header"),l.length>0&&/*#__PURE__*/t(rc,{title:"Connect your wallet",description:o}),/*#__PURE__*/t(sl,{children:/*#__PURE__*/t(Wc,{wallets:l})}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN]:()=>{let{app:r,setModalData:a,navigate:i,data:l,onUserCloseViaDialogOrKeybindRef:c}=Tr(),[d,h]=s(""),{embeddedWallets:u}=Ar(),{authenticated:p,user:m,getAccessToken:y}=_r(),{closePrivyModal:g,walletProxy:f,refreshSessionAndUser:w,recoverPrimaryWallet:v}=N(),{onSuccess:C,onFailure:T,callAuthOnSuccessOnClose:b}=l.createWallet,A=!0===r?.embeddedWallets.requireUserOwnedRecoveryOnCreate,{createWallet:_}=md(),[k,I]=s(null),x=new je((async()=>{let e=await y();if(m&&e&&f)try{let t=Or(m);if(t&&"privy"===t.recoveryMethod)await v();else if(t){let{entropyId:n,entropyIdVerifier:r}=ar(t);try{if(!await f.connect({accessToken:e,entropyId:n,entropyIdVerifier:r}))throw new E("Primary wallet not connected.")}catch(e){return I(t),void i(br.EMBEDDED_WALLET_CREATED_SCREEN)}}let n=qt(m,r.embeddedWallets.ethereum.createOnLogin),a=jt(m,r.embeddedWallets.solana.createOnLogin);if(n&&a){let t=await _({user:m});if(await f.createSolana({accessToken:e,ethereumAddress:t?.address}),!t)return;return I(t),void i(br.EMBEDDED_WALLET_CREATED_SCREEN)}if(a){await f.createSolana({accessToken:e,ethereumAddress:xr(m)?.address});let t=await w();return I(Sr(t)),void i(br.EMBEDDED_WALLET_CREATED_SCREEN)}if(n){let e=await _({user:m});if(!e)return;I(e),i(br.EMBEDDED_WALLET_CREATED_SCREEN)}}catch(e){h(e.message)}}));return o((()=>p&&m?A?(a({...l,recoverySelection:{...l?.recoverySelection,isInAccountCreateFlow:!0}}),i(nd({walletAction:"create",showAutomaticRecovery:!1,availableRecoveryMethods:u.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:!1,isResettingPassword:!1}))):void x.execute():(i(br.LANDING),void T(Error("User must be authenticated before creating a Privy wallet")))),[A,p]),c.current=()=>null,d?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{closeable:!1}),/*#__PURE__*/e(Ht,{children:[/*#__PURE__*/t(vi,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(ac,{title:"Something went wrong",description:d})]}),/*#__PURE__*/t(wt,{onClick:()=>{k?(C(k),g({shouldCallAuthOnSuccess:b})):(T(new S("User wallet creation failed")),g({shouldCallAuthOnSuccess:!1}))},children:"Close"}),/*#__PURE__*/t(yd,{})]}):/*#__PURE__*/t(zc,{})},[br.EMBEDDED_WALLET_CREATED_SCREEN]:()=>{let{user:r}=_r(),{closePrivyModal:a,isNewUserThisSession:i,updateWallets:s}=N(),{app:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=Tr(),{onSuccess:h,onFailure:u,callAuthOnSuccessOnClose:p}=c.createWallet,m=()=>{let e=xr(r)??Sr(r);e?(s(),h(e)):u(Error("Failed to create wallet")),a({shouldCallAuthOnSuccess:p})};return o((()=>{let e=setTimeout(m,Ir);return()=>clearTimeout(e)}),[]),d.current=m,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:m}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Ht,{children:[/*#__PURE__*/t(wi,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),/*#__PURE__*/t(ac,{title:i?"Welcome"+(l?.name?` to ${l?.name}`:""):"All set!",description:i?"You’ve successfully created an account.":"Your account is secured."})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_CONNECTING_SCREEN]:()=>{let{authenticated:r,user:a,getAccessToken:l}=_r(),{closePrivyModal:c,createAnalyticsEvent:d,walletProxy:h}=N(),{navigate:u,data:p,setModalData:m,onUserCloseViaDialogOrKeybindRef:y}=Tr(),g=i((()=>Date.now()),[]),[f,w]=s(!1),{onCompleteNavigateTo:v,onFailure:C,shouldForceMFA:E,entropyId:T,entropyIdVerifier:b}=p?.connectWallet,A=e=>{f||(w(!0),C("string"==typeof e?Error(e):e))};o((()=>{let e,t=Nr(a,T);return r&&t?h?((async()=>{let n=await l();if(!n)return A("User must be authenticated and have a Privy wallet before it can be connected");try{await h.connect({accessToken:n,entropyId:T,entropyIdVerifier:b}),E&&await h.verifyMfa({accessToken:n});let t=(Date.now()-g)/1e3;v===br.EMBEDDED_WALLET_KEY_EXPORT_SCREEN&&t<1?e=setTimeout((()=>{u(v,!1)}),1e3*(1-t)):u(v,!1)}catch(e){if(Yc(e)&&"privy"===t.recoveryMethod){let e=await l();if(!e)return A("User must be authenticated and have a Privy wallet before it can be recovered");try{d({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:t.address}});let n=await(h?.recover({accessToken:e,entropyId:T,entropyIdVerifier:b}));n?.entropyId||A(Error("Unable to recover wallet")),v?u(v):c({shouldCallAuthOnSuccess:!1}),d({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}}),u(v)}catch(e){A("An error has occurred, please try again.")}}else Yc(e)&&"privy"!==t.recoveryMethod?(m({...p,recoverWallet:{entropyId:T,entropyIdVerifier:b,onCompleteNavigateTo:v,onFailure:C},recoveryOAuthStatus:{provider:t.recoveryMethod,action:"recover",isInAccountCreateFlow:!1}}),u(rd(t.recoveryMethod))):A(e)}})(),()=>clearTimeout(e)):void 0:A("User must be authenticated and have a Privy wallet before it can be connected")}),[r,a,h]);let _=()=>{A("User exited before wallet could be connected"),c({shouldCallAuthOnSuccess:!1})};return y.current=_,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:_}),f?/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(Ht,{children:[/*#__PURE__*/t(vi,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(ac,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),/*#__PURE__*/t(wt,{onClick:()=>c({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):/*#__PURE__*/t(zc,{}),/*#__PURE__*/t(sd,{})]})},[br.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN]:()=>{let[r,a]=s(!0),{authenticated:i,getAccessToken:l,user:c}=_r(),{walletProxy:d,closePrivyModal:h,createAnalyticsEvent:u}=N(),{navigate:p,data:m,onUserCloseViaDialogOrKeybindRef:y}=Tr(),[g,f]=s(void 0),[w,v]=s(""),[C,E]=s(!1),{entropyId:T,entropyIdVerifier:b,onCompleteNavigateTo:A,onSuccess:_,onFailure:k}=m.recoverWallet,I=(e="User exited before their wallet could be recovered")=>{h({shouldCallAuthOnSuccess:!1}),k("string"==typeof e?new S(e):e)};y.current=I,o((()=>{if(!i)return I("User must be authenticated and have a Privy wallet before it can be recovered")}),[i]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:I}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Ny,{children:[/*#__PURE__*/e(Iy,{children:[/*#__PURE__*/t(wo,{height:48,width:48,stroke:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Enter your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(bd,{children:[/*#__PURE__*/t(Ed,{type:r?"password":"text",onChange:e=>(e=>{e&&f(e)})(e.target.value),disabled:C,style:{paddingRight:"2.3rem"}}),/*#__PURE__*/t(Nd,{style:{right:"0.75rem"},children:r?/*#__PURE__*/t(Sd,{onClick:()=>a(!1)}):/*#__PURE__*/t(Rd,{onClick:()=>a(!0)})})]}),!!w&&/*#__PURE__*/t(xy,{children:w})]}),/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(Wn,{children:[/*#__PURE__*/t("h4",{children:"Why is this necessary?"}),/*#__PURE__*/t("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),/*#__PURE__*/t(Sy,{loading:C||!d,disabled:!g,onClick:async()=>{E(!0);let e=await l(),t=Nr(c,T);if(!e||!t||null===g)return I("User must be authenticated and have a Privy wallet before it can be recovered");try{u({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t.address}}),await(d?.recover({accessToken:e,entropyId:T,entropyIdVerifier:b,recoveryPassword:g})),v(""),A?p(A):h({shouldCallAuthOnSuccess:!1}),_?.(t),u({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}})}catch(e){!function(e){return Kc(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)}(e)?v("An error has occurred, please try again."):v("Invalid recovery password, please try again.")}finally{E(!1)}},warn:!1,hideAnimations:!T&&C,children:"Recover your account"})]})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN]:()=>{let[r,a]=s(!1),{navigate:i,lastScreen:o,navigateBack:l,setModalData:c,data:d,onUserCloseViaDialogOrKeybindRef:h}=Tr(),{user:u}=_r(),{embeddedWallets:p}=Ar(),{closePrivyModal:m}=N(),y=Or(u),g=null===y,{isInAccountCreateFlow:f,isResettingPassword:w}=d.recoverySelection,v=y&&"privy"!==y.recoveryMethod,C=v?/*#__PURE__*/e("span",{children:["Your account is currently secured using"," ",/*#__PURE__*/t("strong",{children:Uy[y?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function E(e){c({recoveryOAuthStatus:{provider:e,action:g?"create-wallet":"set-recovery",isInAccountCreateFlow:f}}),i(br.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN)}function T(){d?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),m({shouldCallAuthOnSuccess:d?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return h.current=T,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:T,backFn:r?()=>a(!1):o?l:void 0,infoFn:o||r?void 0:()=>a(!0)},"header"),r?/*#__PURE__*/t(Dy,{onClose:()=>a(!1)}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ac,{title:v?"Update backup method":"Secure your account",icon:/*#__PURE__*/t(ko,{width:48}),description:C}),/*#__PURE__*/t(Wy,{children:p.userOwnedRecoveryOptions.filter((e=>!["icloud","google-drive"].includes(y?.recoveryMethod||"")||e!==y?.recoveryMethod)).sort().map((n=>{switch(n){case"google-drive":/*#__PURE__*/return e(hl,{onClick:()=>E("google-drive"),children:[/*#__PURE__*/t(My,{children:/*#__PURE__*/t(Oy,{style:{width:18}})}),"Back up to Google Drive"]},n);case"icloud":/*#__PURE__*/return e(hl,{onClick:()=>E("icloud"),children:[/*#__PURE__*/t(My,{children:/*#__PURE__*/t(Ry,{style:{width:24}})}),"Back up to Apple iCloud"]},n);case"user-passcode":/*#__PURE__*/return e(hl,{onClick:()=>{i(td({isCreatingWallet:g,skipSplashScreen:!0}))},children:[/*#__PURE__*/t(My,{children:/*#__PURE__*/t(Io,{style:{width:18}})}),w?"Reset your":"Set a"," password"]},n);default:return null}}))})]}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN]:()=>{let{user:r,getAccessToken:a}=_r(),{walletProxy:i,refreshSessionAndUser:o,closePrivyModal:l}=N(),c=Tr(),{entropyId:d,entropyIdVerifier:h}=c.data?.recoverWallet,[u,p]=s(!1),[m,y]=s(null),[g,f]=s(null);function w(){if(!u){if(g)return c.data?.setWalletPassword?.onFailure(g),void l();if(!m)return c.data?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),void l()}}c.onUserCloseViaDialogOrKeybindRef.current=w;let v=!(!u&&!m);/*#__PURE__*/return e(n,g?{children:[/*#__PURE__*/t(ft,{onClose:w},"header"),/*#__PURE__*/t(Fy,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:/*#__PURE__*/t(ci,{height:38,width:38,stroke:"var(--privy-color-error)"})}),/*#__PURE__*/t(Vt,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),/*#__PURE__*/t(il,{style:{minHeight:"2rem"}}),/*#__PURE__*/t(hn,{onClick:()=>f(null),children:"Try again"}),/*#__PURE__*/t(Ct,{})]}:{children:[/*#__PURE__*/t(ft,{onClose:w},"header"),/*#__PURE__*/t(ko,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),/*#__PURE__*/t(Vt,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),/*#__PURE__*/t($t,{style:{marginTop:"1rem"},children:"When you log into a new device, you’ll only need to authenticate to access your account. Never get logged out if you forget your password."}),/*#__PURE__*/t(il,{style:{minHeight:"2rem"}}),/*#__PURE__*/t(hn,{loading:u,disabled:v,onClick:()=>async function(){p(!0);try{let e=await a(),t=Nr(r,d);if(!e||!i||!t)return;if(!(await i.setRecovery({accessToken:e,entropyId:d,entropyIdVerifier:h,existingRecoveryMethod:t.recoveryMethod,recoveryMethod:"privy"})).entropyId)throw Error("Unable to set recovery on wallet");let n=await o();if(!n)throw Error("Unable to set recovery on wallet");let s=Nr(n,t.address);if(!s)throw Error("Unabled to set recovery on wallet");y(!!n),setTimeout((()=>{c.data?.setWalletPassword?.onSuccess(s),l()}),kr)}catch(e){f(e)}finally{p(!1)}}(),children:m?"Success":"Confirm"}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN]:()=>{let{logout:r}=_r(),{navigate:a,setModalData:i,data:l}=Tr(),{recoveryOAuthFlow:d,closePrivyModal:h,createAnalyticsEvent:u}=N(),[p,m]=s(!1),{provider:y,action:g,isInAccountCreateFlow:f}=l?.recoveryOAuthStatus,[w,v]=s(void 0),[C,E]=s("create-wallet"===g);if("user-passcode"===y)throw Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let T=Py[y].name,b=Py[y].component,A=l?.recoverWallet?.onCompleteNavigateTo,_=new je((async(e="create-wallet")=>(E(!0),new Promise(((t,n)=>{setTimeout((async()=>{try{let n=window.open();await d(y,e,n),m(!0),t()}catch(t){v({message:`${"recover"===e?"Recovery":"Back up"} with ${T} unsuccessful`,detail:"recover"===g?`Please verify that you are selecting the ${T} account associated with your backup.`:"",retryable:!0}),n()}}),0)})))));o((()=>{"recover"!==g&&_.execute(f?"create-wallet":"set-recovery")}),[]),o((()=>{if(!p)return;let e=setTimeout((()=>{f?(i({createWallet:{onSuccess:()=>{},onFailure:e=>{u({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"RecoveryOAuthScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),a(br.EMBEDDED_WALLET_CREATED_SCREEN)):h({shouldCallAuthOnSuccess:!1})}),kr);return()=>clearTimeout(e)}),[p]);let k=c((async()=>{await _.execute("recover"),A?a(A):m(!0)}),[]),I="google-drive"===y?"Google Drive":"Apple iCloud",x=p&&`Successfully ${"recover"===g?"recovered":"backed up"} with ${I}.`||w&&w.message||`${"recover"===g?"Recovering":"Backing up"} with ${I}...`,S=w?w.detail:"";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{}),C?/*#__PURE__*/t(n,{children:/*#__PURE__*/e(Wy,{children:[/*#__PURE__*/t(ac,{title:x,icon:/*#__PURE__*/t(b,{style:{width:"38px",height:"38px"}}),description:S}),w&&w?.retryable?/*#__PURE__*/t(wt,{onClick:()=>{rs(),v(void 0),"create-wallet"===g?_.execute("create-wallet"):k()},disabled:!p&&!w?.retryable,children:"Try again"}):null]})}):/*#__PURE__*/e(Wy,{children:[/*#__PURE__*/t(ac,{title:"Confirm it's really you",icon:/*#__PURE__*/t(b,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${I} where your account is backed up.`}),/*#__PURE__*/e(wt,{onClick:k,children:["Confirm with ",I]})]}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_KEY_EXPORT_SCREEN]:()=>{let[r,a]=s(null),{authenticated:i,user:l,getAccessToken:c}=_r(),{closePrivyModal:d,createAnalyticsEvent:h,clientAnalyticsId:u}=N(),p=Ar(),{data:m,onUserCloseViaDialogOrKeybindRef:y}=Tr(),{onFailure:g,onSuccess:f,origin:w,appId:v,appClientId:C,walletToExport:E,primaryWallet:T}=m.keyExport,b=e=>{d({shouldCallAuthOnSuccess:!1}),g("string"==typeof e?Error(e):e)},A=()=>{d({shouldCallAuthOnSuccess:!1}),f(),h({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:E.address}})};return o((()=>{if(!i||!E)return b("User must be authenticated before exporting their wallet");c().then(a,b)}),[i,l]),y.current=A,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:A}),/*#__PURE__*/e(hd,{children:[/*#__PURE__*/t(Vt,{children:"Transfer wallet"}),/*#__PURE__*/e($t,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",/*#__PURE__*/t("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),/*#__PURE__*/t(ld,{theme:p.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),/*#__PURE__*/t(zt,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:E.address,showIcon:!0}),/*#__PURE__*/t("div",{style:{width:"100%"},children:r&&/*#__PURE__*/t(dd,{origin:w,appId:v,appClientId:C,accessToken:r,clientAnalyticsId:u,walletToExport:E,primaryWallet:T,dimensions:{height:"44px"}})})]}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN]:()=>{let{authenticated:r}=_r(),{initializeWalletProxy:a,closePrivyModal:i}=N(),{navigate:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=Tr(),[h,u]=s(!0),[p,m]=s(""),[y,g]=s(),[f,w]=s(null),[v,C]=s(!1),E=null!==f;o((()=>{r||l(br.LANDING)}),[r]),o((()=>{a(Rr).then((e=>{u(!1),e||(m("An error has occurred, please try again."),g(new ba(new Aa(p,Qi.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:T,data:b,confirmAndSign:A,onSuccess:_,onFailure:k,uiOptions:I}=c.signMessage,x={title:I.title||"Sign message",description:I.description||"Signing this message will not cost you any fees.",buttonText:I.buttonText||"Sign and continue"},S=e=>{e?_(e):k(y||new ba(new Aa("The user rejected the request.",Qi.E4001_USER_REJECTED_REQUEST.eipCode))),i({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{w(null),m(""),g(void 0)}),200)};return d.current=()=>{S(f)},/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:()=>S(f)}),/*#__PURE__*/t(Dt,{}),I.iconUrl&&"string"==typeof I.iconUrl?/*#__PURE__*/t(cf,{children:/*#__PURE__*/t(tf,{size:"sm",src:I.iconUrl,alt:"app image"})}):null,/*#__PURE__*/t(Vt,{children:x.title}),/*#__PURE__*/t($t,{children:x.description}),"personal_sign"===T&&/*#__PURE__*/t(Og,{children:nf(b)}),"eth_signTypedData_v4"===T&&/*#__PURE__*/t(of,{typedData:b}),"solana_signMessage"===T&&/*#__PURE__*/t(Og,{children:b}),/*#__PURE__*/t(df,{}),/*#__PURE__*/t(sf,{$fail:!0,children:p}),/*#__PURE__*/t(hn,{disabled:v||E||h,loading:v,onClick:async()=>{C(!0),m("");try{let e=await A();w(e),C(!1),setTimeout((()=>{S(e)}),kr)}catch(e){console.error(e),m("An error has occurred, please try again."),g(new ba(new Aa(p,Qi.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),C(!1)}},children:v?"Signing...":E?/*#__PURE__*/e(lf,{children:[/*#__PURE__*/t(wh,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",/*#__PURE__*/t("span",{children:"Success"})]}):x.buttonText}),I.isCancellable&&/*#__PURE__*/t(Nn,{style:{marginTop:"1rem"},onClick:()=>S(null),isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN]:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=Tr(),{rpcConfig:l,chains:c,closePrivyModal:d,walletProxy:h,client:u}=N(),{getAccessToken:p,user:m}=_r(),y=Ar(),[g,f]=s(0),w=(e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(e),[v,C]=s(ef(e,g)),[E,T]=s(null),[b,A]=s(),[_,k]=s(!1),[I,x]=s(null),[S,R]=s(null),[O,W]=s(null),[L,P]=s(void 0),[M,U]=s(void 0),[D,F]=s(!1),[B,z]=s(!1),[H,V]=s([]),[$,G]=s([]),[q,j]=s(!1),[K,Y]=s(void 0),Z="fiat-currency"===y.embeddedWallets.priceDisplay.primary;if(!v||!e?.sendTransaction||!e?.sendTransaction.transactingWallet)/*#__PURE__*/return t(mh,{error:Error("Invalid transaction request"),onClick:()=>{e?.sendTransaction?.onFailure(Jg),d({shouldCallAuthOnSuccess:!1})}});let{entropyId:X,entropyIdVerifier:Q,transactingWallet:J}=e.sendTransaction,ee=i((()=>c.find((e=>Number(e.id)===Number(v.chainId)))),[v.chainId]),te=ee?.nativeCurrency.symbol??"ETH",ne=i((()=>Yg(v.data,!!y.embeddedWallets.extendedCalldataDecoding)),[v.data]),{action:re,isErc20Ish:ae,isNFTIsh:ie}=ne,{toAddress:oe,tokenAddress:se}=i((()=>({toAddress:ne.isErc20Ish?ne.transferTo:v.to??void 0,tokenAddress:ne.isErc20Ish?v.to:void 0})),[ne]);o((()=>{v.to&&ee&&ae&&Tn({address:v.to,chain:ee,rpcConfig:y.rpcConfig,privyAppId:y.id}).then(T).catch(console.error)}),[v.to,ee]);let{tokenPrice:le,isTokenPriceLoading:ce}=Uh(v.chainId),{balance:de}=An({rpcConfig:y.rpcConfig,appId:y.id,address:J.address,chain:ee}),he=i((()=>Ja(Number(v.chainId),c,l,{appId:y.id})),[v.chainId,l]),ue=Qg(v,J,he);o((()=>{C(ef(e,g))}),[g]),o((()=>{e.sendTransaction?.getIsSponsored?e.sendTransaction.getIsSponsored().then(A).catch(console.error):A(!1)}),[e.sendTransaction.getIsSponsored]);let pe=()=>{if(!_)return I?e?.sendTransaction?.onSuccess({hash:I}):O||ue?.errors[0]?e?.sendTransaction?.onFailure(O??ue?.errors[0]??Jg):e?.sendTransaction?.onFailure(new ba(new Aa("The user rejected the request",Qi.E4001_USER_REJECTED_REQUEST.eipCode))),d({shouldCallAuthOnSuccess:!1})};n.current=pe;let me=!!(e.funding&&e.funding.supportedOptions.length>0),ye=cn(BigInt(ue?.totalGasEstimate??0n),te),ge=Z&&le?yn(BigInt(ue?.totalGasEstimate??0n),le):void 0,fe=cn(de??0n,te,void 0,!0),we=Z&&le?yn(de??0n,le):void 0,ve=e.sendTransaction?.uiOptions?.transactionInfo?.title;ve||(ve="approve"===re?ae?"Confirm address":"Confirm action":`Approve ${re}`);let Ce=e.sendTransaction?.uiOptions?.description||(ae&&"approve"===re?`${y.name} would like your permission for ${Ot(ne.spender)} to spend tokens on your behalf.`:`${y.name} wants your permission to approve the following transaction.`),Ee=e.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/t("img",{src:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,Te=!(!ue||ue.errors[0]||ue.hasFunds||!1!==b),be=Te&&me,Ae=be?"Add funds":e.sendTransaction?.uiOptions?.buttonText||(g<w?"Continue":"Approve");if(o((()=>{let e=(e,t,n)=>{if(t.isErc20Ish&&t.amount&&n)Y(gn({amount:t.amount,decimals:n.decimals})),V([{value:K,symbol:n?.symbol}]);else if(e.value){let t=BigInt(e.value),n=le&&yn(t,le);V(Z&&n?[{value:n}]:[{value:Mn(t),symbol:te}])}else V(Z?[{value:"$0"}]:[{value:"0",symbol:te}])},t=ue?.tx??v;y.embeddedWallets.transactionScanning.enabled&&t?(j(!0),(async e=>{if(u)return await u.scanTransaction({metadata:{domain:y.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})})(t).then((e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?U("safe"):"Warning"===e.validation.result_type?U("warn"):"Malicious"===e.validation.result_type&&(U("error"),z(!0))),"Success"!==e.simulation.status)throw Error("Simulation failed");{P(e.simulation.params);let{assetsIn:t,assetsOut:n}=function(e,t){let n=[],r=[];if(e)for(let t of e)if(t.in[0]){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.in[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price},n.push(e)}else if(t.out[0]?.value){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.out[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.out[0].value,symbol:t.asset.symbol,usdValue:t.out[0].usd_price},r.push(e)}for(let e of t)for(let t of Object.keys(e.spenders)){let n;n="ERC721"===e.asset.type||"approve_for_all"===e.spenders[t]?.value?{nftName:e.asset.name}:{iconUrl:e.asset.logo_url,value:e.spenders[t]?.value,symbol:e.asset.symbol,usdValue:e.spenders[t]?.usd_price},r.push(n)}return{assetsIn:n,assetsOut:r}}(e.simulation.assets_diffs,e.simulation.exposures);if(0===n.length&&0===t.length)throw Error("No tokens found");V(n),G(t)}j(!1)})).catch((()=>{j(!1),e(t,ne,E)}))):e(t,ne,E)}),[v,ue?.tx,ne,E]),S/*#__PURE__*/)return t(Dg,{txn:ue?.tx??v,onClose:pe,receipt:S,transactionInfo:e.sendTransaction?.uiOptions.transactionInfo,tokenPrice:le,tokenSymbol:te,receiptHeader:e.sendTransaction?.uiOptions.successHeader,receiptDescription:e.sendTransaction?.uiOptions.successDescription});if(O)/*#__PURE__*/return t(ig,{transactionError:O,transactionHash:I??void 0,network:"ethereum",chainId:ue?.tx.chainId??v.chainId,onClose:pe,onRetry:({resetNonce:e})=>{W(null);let t={...ue?.tx??v};e&&(t.nonce=void 0),C(t)}});let _e=0!==w&&"number"==typeof g&&0!==g?()=>{f(g-1)}:void 0;return D&&L?/*#__PURE__*/t(Mg,{details:L,onBack:()=>F(!1)}):/*#__PURE__*/t(Jy,{transactionIndex:g,onBack:_e,maxIndex:w,disabled:Te&&!me||B,isSubmitting:_,submitError:O,isPreparing:!ue,isTokenPriceLoading:ce,isTokenContractInfoLoading:!ie&&!E,prepareError:ue?.errors[0],symbol:E?.symbol,chain:ee,img:Ee,title:ve,subtitle:Ce,txValue:v.value,fee:ge??ye,isSponsored:b,from:J?.address??"",to:oe,tokenAddress:se??void 0,network:y.chains.find((e=>e.id===v.chainId))?.name??"",transactionDetails:{...ne,formattedAmount:K},cta:Ae,missingFunds:Te,action:re,balance:we??fe,onClose:pe,onClick:be?async()=>{if(!J)return;if(!me)throw Error("Funding wallet is not enabled");let t=br.FUNDING_METHOD_SELECTION_SCREEN;r({...e,funding:{...e.funding,methodScreen:t,chainType:"ethereum",amount:Xa(BigInt(ue?.tx.value??0)+BigInt(ue?.totalGasEstimate?.toString()??0)),chain:ee}}),a(t)}:async()=>{if(g<w)f(g+1);else{k(!0);try{let t=await p();if(_||!t||!J||!h||!m)return;let n=e?.sendTransaction?.onConfirm?await e.sendTransaction.onConfirm():await xg({accessToken:t,transactingWallet:J,entropyId:X,entropyIdVerifier:Q,walletProxy:h,transactionRequest:ue?.tx??v,publicClient:he,requesterAppId:e.sendTransaction?.requesterAppId});if(x(n),e.sendTransaction?.signOnly)return await new Promise((e=>setTimeout(e,kr))),e?.sendTransaction?.onSuccess({hash:n}),d({shouldCallAuthOnSuccess:!1});let r=await he.waitForTransactionReceipt({hash:n});if("reverted"===r.status)throw Error("Transaction failed");R(r)}catch(e){console.warn({transaction:ue?.tx??v,error:e}),W(e)}finally{k(!1)}}},validation:M,hasScanDetails:!!L,setIsScanDetailsOpen:F,preventMaliciousTransaction:B,setPreventMaliciousTransaction:z,tokensSent:H,tokensReceived:$,isScanning:q,isCancellable:e.sendTransaction?.uiOptions?.isCancellable??!1})},[br.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN]:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=Tr(),{client:l,closePrivyModal:c,walletProxy:d}=N(),h=Ar(),{user:u,getAccessToken:p}=_r(),[m,y]=s(e?.sendSolanaTransaction?.transactionRequest),[g,f]=s(),[w,v]=s(),[C,E]=s(0),[T,b]=s({value:0n,isLoading:!1}),[A,_]=s(!1),[k,I]=s(),[x,S]=s(),R=e?.sendSolanaTransaction?.connection,O=e?.sendSolanaTransaction?.transactingWallet,W=e?.sendSolanaTransaction?.signOnly??!1,L=g?.instructions.length??1,P=O?.imported?Zr(u):Or(u),M=Pr(R?.rpcEndpoint||""),U="fiat-currency"===h.embeddedWallets.priceDisplay.primary,{solPrice:D,isSolPriceLoading:F}=Mh({enabled:U}),B=i((()=>{let e,t;if(!g)return;let n=g.spender;0===C&&O?.address===n&&(e=zh(g.fee));let r=zh(T.value,3,!0),a=g.instructions[C];if(!a)return{fee:e,spender:n,balance:r};if("unknown"===a.type)return{fee:e,spender:n,program:a.program,balance:r};if("ata-creation"===a.type)return{fee:e,spender:n,balance:r,tokenAccountOwner:a.owner,tokenAccount:a.ata,tokenAddress:a.mint};let i=a.fromAccount,o="sol-transfer"===a.type?a.toAccount:a.toAccount||a.toAta,s="spl-transfer"===a.type?a.token.address:void 0;return null!=e&&"SOL"===a.token.symbol&&(t=zh(a.value+g.fee)),{fee:e,spender:n,from:i,to:o,tokenAddress:s,amount:`${Ga(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}}),[g,C,O?.address,T]),z=i((()=>{let e,t;if(!g||!U||!D||F)return;function n(...e){return Hh(e.reduce(((e,t)=>e+t),0n),D??0)}0===C&&O?.address===g.spender&&(e=n(g.fee));let r=n(T.value),a=g.instructions[C];return a&&"unknown"!==a.type&&"ata-creation"!==a.type?(null!=e&&"SOL"===a.token.symbol&&(t=n(a.value,g.fee)),{fee:e,amount:"SOL"===a.token.symbol?n(a.value):`${Ga(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}):{fee:e,balance:r}}),[g,U,D,F,O?.address,C,T]),H=i((()=>{if(W||!g||T.isLoading||C>0)return!1;let e=g.instructions[C];if(!e)return!1;let t=0n;return O?.address===g.spender&&(t+=g.fee),"value"in e&&O?.address===e.fromAccount&&"SOL"===e.token.symbol&&(t+=e.value),T.value<t}),[g,T,C,W]);if(o((()=>{!async function(){if(m&&R&&l)try{v(void 0);let e=await qh({tx:m,connection:R,client:l});f(e),E(0)}catch(e){console.error("Failed to prepare transaction",e),v(e)}}()}),[m,R,l]),o((()=>{(async function(){if(!O||!R)return;b({value:T.value,isLoading:!0});let e=new Xi({name:"mainnet-beta",rpcUrl:R.rpcEndpoint});b({value:await e.getBalance(O.address).catch((()=>0n))??0n,isLoading:!1})})().catch(console.error)}),[g,R]),!(m&&e?.sendSolanaTransaction&&O&&R)){let n=Error("Invalid transaction request");/*#__PURE__*/return t(mh,{error:n,onClick:()=>{e?.sendSolanaTransaction?.onFailure(n),c({shouldCallAuthOnSuccess:!1})}})}let V=()=>{if(!A)return k?e?.sendSolanaTransaction?.onSuccess(k):(e?.sendSolanaTransaction?.onFailure(x??w??Error("User exited the modal before submitting the transaction")),E(0)),c({shouldCallAuthOnSuccess:!1})};n.current=V;let $=e.sendSolanaTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/t("img",{src:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,G=!!(e.funding&&e.funding.supportedOptions.length>0),q=H&&G;return k?/*#__PURE__*/t(Ig,{instructions:g?.instructions.reduce(((e,t)=>("ata-creation"===t.type&&e.push({tokenAccountOwner:t.owner,tokenAccount:t.ata}),"spl-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount||t.toAta,amount:t.value,token:t.token}),"sol-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount,amount:t.value,token:t.token}),e)),[])??[],fees:0===C?k.fees:0n,onClose:V,transactionInfo:e.sendSolanaTransaction?.uiOptions.transactionInfo,solPrice:D,receiptHeader:e.sendSolanaTransaction?.uiOptions.successHeader,receiptDescription:e.sendSolanaTransaction?.uiOptions.successDescription,rpcEndpoint:R.rpcEndpoint,signOnly:W}):x?/*#__PURE__*/t(ig,{transactionError:x,connection:R,onClose:V,network:"solana",onRetry:async()=>{S(void 0);let{blockhash:e}=await R.getLatestBlockhash();$h(m)?m.message.recentBlockhash=e:m.recentBlockhash=e,y(m)}}):/*#__PURE__*/t(eg,{img:$,title:e.sendSolanaTransaction?.uiOptions?.transactionInfo?.title||"Confirm transaction",subtitle:e.sendSolanaTransaction?.uiOptions?.description||`${h.name} wants your permission to approve the following transaction.`,cta:q?"Add funds":e.sendSolanaTransaction?.uiOptions?.buttonText||"Approve",transactionIndex:C,maxIndex:L-1,network:"mainnet-beta"==M?"Solana":M,blockExplorerUrl:"https://explorer.solana.com",total:U?z?.total:B?.total,amount:U?z?.amount:B?.amount,fee:U?z?.fee:B?.fee,balance:U?z?.balance:B?.balance,from:B?.from,to:B?.to,tokenAccount:B?.tokenAccount,tokenAccountOwner:B?.tokenAccountOwner,tokenAddress:B?.tokenAddress,transactingWalletAddress:O.address,programAddress:B?.program,disabled:H&&!G,isSubmitting:A,isPreparing:!g||T.isLoading,isTokenPriceLoading:U&&F,isMissingFunds:H,submitError:x??void 0,parseError:w,onClick:q?async()=>{if(!O)return;if(!G)throw Error("Funding wallet is not enabled");let t=br.FUNDING_METHOD_SELECTION_SCREEN;r({...e,funding:{...e.funding,methodScreen:t}}),a(t)}:async()=>{if(C<(g?.instructions.length??1)-1)E(C+1);else try{_(!0);let t=await p();if(A||!t||!O||!d||!u||!P)return;let{rootWallet:n}=Xr(u,O.address);if(!n)throw Error("No root wallet for transacting wallet found");let{entropyId:r,entropyIdVerifier:a}=ar(n);if(W)await By({tx:m,accessToken:t,walletProxy:d,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:O.address,transactingWalletIndex:O.walletIndex??0}),I(Gh("",m,null));else{let{signature:n,receipt:i}=await zy({tx:m,accessToken:t,connection:R,walletProxy:d,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:O.address,transactingWalletIndex:O.walletIndex??0,transactionOptions:e.sendSolanaTransaction?.transactionOptions});I(Gh(n,m,i))}}catch(e){console.warn({transaction:m,error:e}),S(e)}finally{_(!1)}},onClose:V,onBack:C>0&&L>1?()=>E(C-1):void 0})},[br.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN]:()=>{let{app:r,data:a}=Tr(),{closePrivyModal:i}=N(),[l,c]=s(!1),[d,h]=s(),{address:u,onDelegate:p,onSuccess:m,onError:y}=a.delegatedActions.consent,g=async()=>{l?m():y(d??new E("User declined delegating actions.")),i({shouldCallAuthOnSuccess:!1})};return o((()=>{if(!l&&!d)return;let e=setTimeout(g,Ir);return()=>clearTimeout(e)}),[l,d]),/*#__PURE__*/e(n,l||d?{children:[/*#__PURE__*/t(ft,{onClose:g}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(bt,{children:[d?/*#__PURE__*/t(hi,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(Ci,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Bt,{height:20}),/*#__PURE__*/t(ac,{title:d?"Something went wrong":"Success!",description:d?"Please try again.":`You’ve successfully granted delegated action permissions to ${r.name}.`})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]}:{children:[/*#__PURE__*/t(ft,{closeable:!0,onClose:g}),/*#__PURE__*/t(Ei,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(Ll,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),/*#__PURE__*/e(Pl,{style:{marginBottom:24,textWrap:"pretty"},children:["By confirming, ",r.name," will be able to use your wallet for you even when you're not around. You can revoke this later."]}),/*#__PURE__*/t(Fc,{showIcon:!0,address:u,title:"Wallet",isLoading:!1}),/*#__PURE__*/e(Dc,{style:{marginTop:24},children:[/*#__PURE__*/t(Et,{onClick:g,children:"Not now"}),/*#__PURE__*/t(wt,{onClick:async()=>{try{await p(),c(!0)}catch(e){h(e)}},children:"Accept"})]}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_DELEGATED_ACTIONS_REVOKE_SCREEN]:()=>{let{app:r,data:a}=Tr(),{closePrivyModal:i}=N(),[l,c]=s(!1),[d,h]=s(),{onRevoke:u,onSuccess:p,onError:m}=a.delegatedActions.revoke,y=async()=>{l?p():m(d??new E("User declined revoking access to their delegated wallet.")),i({shouldCallAuthOnSuccess:!1})};return o((()=>{if(!l&&!d)return;let e=setTimeout(y,Ir);return()=>clearTimeout(e)}),[l,d]),/*#__PURE__*/e(n,l||d?{children:[/*#__PURE__*/t(ft,{onClose:y}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(bt,{children:[d?/*#__PURE__*/t(hi,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(Ci,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Bt,{height:20}),/*#__PURE__*/t(ac,{title:d?"Something went wrong":"Success!",description:d?"Please try again.":"You've successfully revoked permissions."})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]}:{children:[/*#__PURE__*/t(ft,{closeable:!0,onClose:y}),/*#__PURE__*/t(Ti,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(Ll,{style:{marginTop:24},children:"Revoke offline access to wallet"}),/*#__PURE__*/e(Pl,{children:["By confirming, ",r.name," will no longer be able to use this wallet on your behalf when you are not online."]}),/*#__PURE__*/e(Bc,{style:{marginTop:24},children:[/*#__PURE__*/t(Et,{onClick:y,children:"Deny"}),/*#__PURE__*/t(wt,{onClick:async()=>{try{await u(),c(!0)}catch(e){h(e)}},children:"Confirm"})]}),/*#__PURE__*/t(Ct,{})]})},[br.FUNDING_METHOD_SELECTION_SCREEN]:()=>{let{wallets:r}=Mr(),{wallets:a}=Ca(),{navigate:s,data:l,setModalData:c}=Tr(),{client:d}=N(),h=Ar(),u=l?.funding,p=tp(lp),m=tp(cp),y="solana"===u.chainType,g=y?void 0:u,f=i((()=>((e,t,n,r,a,i)=>{let o,s,l="solana"===n.chainType,c=l?void 0:n,d=n.isUSDC?"USDC":c?.erc20Address?void 0:"native-currency",h=!!l||d&&Di(Number(n.chain.id),d),u=!!l||d&&Fi(Number(n.chain.id),d),p=[];for(let o of(n.preferredCardProvider&&n.supportedOptions.sort((e=>e.provider===n.preferredCardProvider?-1:1)),n.supportedOptions))"card"===o.method&&"coinbase"===o.provider&&u&&p.push((()=>ip(t,n,r,a,i,"buy"))),"card"===o.method&&"moonpay"===o.provider&&h&&d&&p.push((()=>op(t,n,e,d,r,a,i,"credit_debit_card")));for(let e of n.supportedOptions)"exchange"===e.method&&"coinbase"===e.provider&&u&&(o=()=>ip(t,n,r,a,i,"buy"));for(let e of i?.funding?.supportedOptions??[])"wallets"===e.method&&(s=()=>a(br.FUNDING_TRANSFER_FROM_WALLET_SCREEN));return{onFundWithCard:p,onFundWithExchange:o,onFundWithWallet:s}})(h,d,u,c,s,l)),[h,d,u,l,c,s]);o((()=>{if(u?.defaultFundingMethod&&u.usingDefaultFundingMethod)switch(c({funding:{...u,usingDefaultFundingMethod:!1}}),u?.defaultFundingMethod){case"card":f.onFundWithCard[0]&&f.onFundWithCard[0]();break;case"exchange":f.onFundWithExchange&&f.onFundWithExchange();break;case"wallet":f.onFundWithWallet&&f.onFundWithWallet();break;case"manual":s(br.FUNDING_MANUAL_TRANSFER_SCREEN)}}),[]),o((()=>{g?.erc20Address&&!g.erc20ContractInfo&&Tn({address:g.erc20Address,chain:g.chain,rpcConfig:h.rpcConfig,privyAppId:h.id}).then((e=>{c({...l,funding:{...g,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}})})).catch(console.error)}),[g?.erc20Address,g?.chain]);let w=y?a.find((({address:e})=>e===u.address)):r.find((({address:e})=>C(e)===C(u.address))),v=w&&"privy"!==w.walletClientType?St(w.walletClientType,w.connectorType,w.walletClientType):h.name,E=!(!g?.erc20Address||g?.erc20ContractInfo);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/e("h3",{children:["Add funds to your"," ",v?.toLowerCase().endsWith("wallet")?v:v+" wallet"]}),/*#__PURE__*/e(xu,{children:[u.errorMessage&&/*#__PURE__*/t(Yu,{theme:h.appearance.palette.colorScheme,children:u.errorMessage}),f.onFundWithCard?.[0]&&/*#__PURE__*/e(hl,{disabled:E,onClick:f.onFundWithCard[0],children:[/*#__PURE__*/t(Su,{children:/*#__PURE__*/t(co,{style:{width:24}})}),"Pay with card",p?/*#__PURE__*/t(Ju,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):m?/*#__PURE__*/t(ep,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):null]}),f.onFundWithExchange&&/*#__PURE__*/e(hl,{disabled:E,onClick:f.onFundWithExchange,children:[/*#__PURE__*/t(Su,{children:/*#__PURE__*/t(lo,{style:{width:24}})}),"Transfer from an exchange"]}),f.onFundWithWallet&&/*#__PURE__*/e(hl,{disabled:E,onClick:f.onFundWithWallet,children:[/*#__PURE__*/t(Su,{children:/*#__PURE__*/t(bn,{style:{width:24}})}),"Transfer from wallet"]}),/*#__PURE__*/e(hl,{disabled:E,onClick:()=>s(br.FUNDING_MANUAL_TRANSFER_SCREEN),children:[/*#__PURE__*/t(Su,{children:/*#__PURE__*/t(ho,{style:{width:24}})}),"Receive funds"]}),u?.showAlternateFundingMethod&&f.onFundWithCard?.[1]&&/*#__PURE__*/t(Xu,{theme:h.appearance.palette.colorScheme,children:/*#__PURE__*/e(Uu,{children:["Having trouble or facing location restrictions?"," ",/*#__PURE__*/t(Du,{onClick:f.onFundWithCard[1],children:"Try a different provider."})]})})]}),/*#__PURE__*/t(Ct,{})]})},[br.MOONPAY_STATUS_SCREEN]:()=>{let{app:r,data:a,setModalData:i,navigateBack:o}=Tr(),{closePrivyModal:s}=N(),{externalTransactionId:l}=a?.moonpayStatus,c=Ta(l||null,r.fundingMethodConfig.moonpay.useSandbox??!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{title:"Fund account",backFn:()=>{let e={...a?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),i({funding:e}),o()}}),/*#__PURE__*/t(pp,{status:c,onClickCta:s}),/*#__PURE__*/t(Ct,{})]})},[br.COINBASE_ONRAMP_STATUS_SCREEN]:()=>{let{data:r,setModalData:a,navigate:i,navigateBack:c}=Tr(),{closePrivyModal:d,createAnalyticsEvent:h,client:u}=N(),[p,m]=s("pending-in-flow"),y=l(0),g={...r?.funding,showAlternateFundingMethod:!0};g.usingDefaultFundingMethod&&(g.usingDefaultFundingMethod=!1);let{partnerUserId:f,popup:w}=r?.coinbaseOnrampStatus??{};return o((()=>{if("pending-in-flow"===p||"pending-after-flow"===p){let e=setInterval((async()=>{if(f)try{let{status:e}=await u.getCoinbaseOnRampStatus({partnerUserId:f});if("success"===e)return void m("success");if("failure"===e)throw Error("There was an error completing Coinbase Onramp flow.");if(y.current>=3)return a({funding:g}),void i(br.FUNDING_METHOD_SELECTION_SCREEN);w?.closed&&(y.current=y.current+1,m("pending-after-flow"))}catch(e){console.error(e),m("error"),h({eventName:va,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),a({funding:{...g,errorMessage:"Something went wrong adding funds. Please try again or use another method."}}),i(br.FUNDING_METHOD_SELECTION_SCREEN)}}),1500);return()=>clearInterval(e)}}),[f,w,p]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{title:"Fund account",backFn:()=>{a({funding:g}),c()}},"header"),/*#__PURE__*/t(Gu,{status:p,onClickCta:d}),/*#__PURE__*/t(Ct,{})]})},[br.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:()=>{let r,{connectors:a}=N(),{app:i,setModalData:l,data:c,navigate:d}=Tr(),{wallets:h}=Mr(),{wallets:u}=Ca(),[p,m]=s("default"),y="solana"===c?.funding?.chainType,g=!!c?.funding?.crossChainBridgingEnabled;r="ethereum"===c?.funding?.chainType?c.funding.erc20Address&&!c.funding.isUSDC?"ethereum-only":g&&!c.funding.chain.testnet?"ethereum-and-solana":"ethereum-only":g?"ethereum-and-solana":"solana-only";let f=h.filter((e=>"privy"!==e.walletClientType)),w=f.map((e=>e.walletClientType)),v=u.filter((e=>"privy"!==e.walletClientType)),C=v.map((e=>e.walletClientType)),E=[],T={...c.funding};T.usingDefaultFundingMethod&&(T.usingDefaultFundingMethod=!1);let b=({address:e,walletChainType:t})=>{l({...c,funding:{...T,connectedWalletAddress:e,onContinueWithExternalWallet:()=>d(_({destChainType:y?"solana":"ethereum",sourceChainType:t}))}}),d(br.FUNDING_EDIT_AMOUNT_SCREEN)};"solana-only"!==r&&E.push(...f.map(((e,n)=>/*#__PURE__*/t(wp,{onClick:()=>b({address:e.address,walletChainType:"ethereum"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),"ethereum-only"!==r&&E.push(...v.map(((e,n)=>/*#__PURE__*/t(wp,{onClick:()=>b({address:e.address,walletChainType:"solana"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),E.push(...Lc({walletList:i.appearance.walletList.filter((e=>!f.some((t=>t.walletClientType===e))&&!v.some((t=>t.walletClientType===e)))),walletChainType:r,connectors:a,connectOnly:!0,ignore:[...i.appearance.walletList,...w,...C],walletConnectEnabled:i.externalWallets.walletConnect.enabled}));let A=/*#__PURE__*/t(fp,{text:"More wallets",onClick:()=>m("overflow")}),_=({sourceChainType:e,destChainType:t})=>"ethereum"===e&&"solana"===t?br.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN:"ethereum"===e&&"ethereum"===t?br.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN:"solana"===e&&"ethereum"===t?br.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN:br.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN;return o((()=>{l({...c,externalConnectWallet:{onCompleteNavigateTo:({walletChainType:e})=>(l({...c,funding:{...T,onContinueWithExternalWallet:()=>{d(_({destChainType:y?"solana":"ethereum",sourceChainType:e??"ethereum"}))}}}),br.FUNDING_EDIT_AMOUNT_SCREEN)}})}),[]),/*#__PURE__*/e(n,"overflow"===p?{children:[/*#__PURE__*/t(ft,{backFn:()=>m("default")},"header"),/*#__PURE__*/e(sl,{children:[/*#__PURE__*/t($t,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),E]}),/*#__PURE__*/t(Ct,{})]}:{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(ac,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),/*#__PURE__*/e(sl,{children:[E.length>4?E.slice(0,3):E,E.length>4&&A]}),/*#__PURE__*/t(Ct,{})]})},[br.FUNDING_EDIT_AMOUNT_SCREEN]:()=>{let{data:r,setModalData:a}=Tr(),i=r?.funding,o="solana"===i.chainType,s=l(null),{tokenPrice:c}=Uh(o?"solana":i.chain.id),d=o?void 0:i,h=!(!d?.erc20Address||d?.erc20ContractInfo),u=o?"SOL":i.erc20Address?i.erc20ContractInfo?.symbol:i.chain.nativeCurrency.symbol||"ETH",p=parseFloat(i.amount),m=!isNaN(p)&&p>0,y=c?mn(i.amount,c):void 0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Vt,{children:"Confirm or edit amount"}),/*#__PURE__*/e(En,{style:{marginTop:"32px"},children:[/*#__PURE__*/t(Ru,{children:h?/*#__PURE__*/t(Rh,{size:"50px"}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(Ou,{onClick:()=>s.current?.focus(),children:[/*#__PURE__*/t(Lu,{ref:s,value:i.amount,onChange:e=>{let t=e.target.value;/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1&&a({...r,funding:{...i,amount:t}})}}),/*#__PURE__*/t(Pu,{children:u})]}),!d?.erc20Address&&/*#__PURE__*/t(Mu,{children:y&&m?`${y} USD`:""})]})}),/*#__PURE__*/t(hn,{style:{marginTop:"1rem"},disabled:!m,onClick:i.onContinueWithExternalWallet,children:"Continue"})]}),/*#__PURE__*/t(Ct,{})]})},[br.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:l}=N(),{navigate:c,setModalData:d,app:h,data:u}=Tr(),{wallets:p}=Mr(),[m,y]=s(!1),[g,f]=s(0n),[w,v]=s(!1),[C,T]=s(null),[A,_]=s(null),[k,I]=s([]),[x,S]=s(0),[R,O]=s(!1),[W,L]=s(!1),[P,M]=s(!1),[U,D]=s(!1),[F,B]=s(),[z,H]=s();if(!u?.funding||"ethereum"!==u.funding.chainType)throw Error("Invalid funding data");let{erc20ContractInfo:V,chain:$,connectedWalletAddress:G}=u.funding,q=u.funding.address,j=u.funding.erc20Address,[K,Y]=s(u.funding.amount);o((()=>{j&&!V&&T(Error("Unable to fetch token details"))}),[]);let Z=!!j&&!!V,X=Z?BigInt(parseFloat(K)*10**V.decimals):qa(K),Q=G?p.find((({address:e})=>e===G)):p[0],[J,ee]=s(null);o((()=>{(async()=>{if(!Q)return;let e=await Q.getEthereumProvider();ee(Ha({account:Q.address,transport:Va(e)}).extend($a))})().catch(console.error)}),[Q]);let[te,ne]=s(0n);o((()=>{Ba({chain:$,transport:za(ei($,r,a))}).getBalance({address:q}).then(ne).catch(console.error)}),[]);let[re,ae]=s(0n);o((()=>{Z&&pn({chain:$,address:q,appId:a,rpcConfig:r,erc20Address:j}).then((e=>ae(e.balance))).catch(console.error)}),[]);let{tokenPrice:ie}=Uh($.id),[oe,se]=s({to:q,chain:$,value:X,data:void 0});o((()=>{(async()=>{let e,t;if(!J||!Q||R||P)return;O(!0);let n=Ba({chain:oe.chain,transport:za(ei(oe.chain,r,a))});if(Z&&!oe.data)return await n.simulateContract({address:j,chain:oe.chain,abi:$u,functionName:"transfer",args:[q,X],account:Q.address}).catch((e=>{console.warn("Simulated token transfer failed with error, fetching bridge options.",e)}))?(O(!1),void se({to:j,chain:oe.chain,data:ja({abi:$u,functionName:"transfer",args:[q,X]}),value:"0x0"})):(O(!1),void v(!0));try{e=await n.prepareTransactionRequest({account:Q.address,to:oe.to,chain:oe.chain,data:oe.data,value:BigInt(oe.value??0)})}catch(e){if(console.error(e),k.length>1)_(e.shortMessage??"Something went wrong");else if(W&&0===k.length)return void T(new E(`Wallet ${Ot(Q.address)} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE))}if(!e)return O(!1),void v(!0);O(!1),M(!0),y(!0),f(e.gas);try{await J.switchChain({id:oe.chain.id})}catch(e){await J.addChain({chain:oe.chain}),await J.switchChain({id:oe.chain.id})}try{t=await J.sendTransaction(e)}catch(e){if(console.error(e),"TransactionExecutionError"===e.name)if(k.length<1){let t=e.shortMessage;(e.shortMessage.includes("rejected the request")||e.details.includes("rejected the request"))&&(t="User rejected the request."),T(new E(t,void 0,b.TRANSACTION_FAILURE))}else _(e.shortMessage??"Something went wrong")}if(t)return await J.waitForTransactionReceipt({hash:t}),M(!1),W?(B(t),void H("pending")):(D(!0),void l({eventName:va,payload:{provider:"external",status:"success",txHash:t,address:Q.address,chainId:oe.chain.id,chainType:"ethereum",value:oe.value?Ga(BigInt(oe.value),V?.decimals??18):void 0,token:V?.symbol??j??"ETH",destinationAddress:q,destinationChainId:$.id,destinationChainType:"ethereum",destinationValue:X?Ga(X,V?.decimals??18):void 0,destinationToken:V?.symbol??j??$.nativeCurrency.name}}));M(!1)})().catch(console.error)}),[J,oe]),o((()=>{(async()=>{if(!w||!J||!Q)return;let e=Wr(h.chains).filter((e=>e.id!==$.id&&!!e.testnet==!!$.testnet));Z&&e.unshift($);let t=await Zh({chains:e,address:Q.address,appId:a,rpcConfig:r}),n=Z?t.filter((e=>e.balance>0n)):t.filter((e=>e.balance>X));if(n.length<1)return void T(new E(`Wallet ${Ot(Q.address)} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({quote:await dh({isTestnet:!!$.testnet,input:sh({amount:X.toString(),user:Q.address,recipient:q,destinationChainId:$.id,destinationCurrency:j,originChainId:e.chain.id})}),...e}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void T(new E(`Wallet ${Ot(Q.address)} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE));let o=i.map((e=>({bridgeTx:hh(e.quote),balance:e.balance,chain:e.chain}))).filter((e=>!!e.bridgeTx));if(o.length>1)return void I(o);let s=o[0];s?(L(!0),se({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):T(new E(`Wallet ${Ot(Q.address)} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE))})().catch(console.error)}),[w]),uh({transactionHash:F,wallet:Q,isTestnet:!!$.testnet,bridgingStatus:z,setBridgingStatus:H,onSuccess({transactionHash:e,wallet:t}){L(!1),D(!0),l({eventName:va,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:oe.chain.id,chainType:"ethereum",value:oe.value?Ga(BigInt(oe.value),V?.decimals??18):void 0,token:V?.symbol??j??"ETH",destinationAddress:q,destinationChainId:$.id,destinationChainType:"ethereum",destinationValue:X?Ga(X,V?.decimals??18):void 0,destinationToken:V?.symbol??j??$.nativeCurrency.name}})},onFailure({error:e}){L(!1),T(e)}}),o((()=>{if(!C)return;let e={error:C,previousScreen:br.FUNDING_TRANSFER_FROM_WALLET_SCREEN};d({funding:u?.funding,sendTransaction:u?.sendTransaction,errorModalData:e}),c(br.ERROR_SCREEN,!1)}),[C]);let le=Q?St(Q.walletClientType,Q.connectorType,Q.walletClientType)||"wallet":null,ce=!Z&&ie?mn(K??"0",ie):void 0,de=Z?g:fn([g,X]),he=de&&ie?yn(de,ie):void 0,ue=de?cn(de,"ETH"):void 0,pe=g&&ie?yn(g,ie):void 0,me=g?cn(g,"ETH"):void 0;if(o((()=>{if(!U)return;let e=setTimeout(i,Fr);return()=>clearTimeout(e)}),[U]),U/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Ht,{children:[/*#__PURE__*/t(Ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(ac,{title:"Success!",description:`You’ve successfully added ${K} ${Z?V.symbol:$.nativeCurrency.symbol} to your ${h.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]});let ye=Z?`${gn({amount:re,decimals:V.decimals})} ${V.symbol}`:cn(te,$.nativeCurrency.symbol,3,!0),ge=k[x];return k.length>1&&ge?/*#__PURE__*/t(Fu,{displayName:le,configuredFundingChain:$,formattedBalance:ye,fundingAmount:K,fundingCurrency:Z?V.symbol:$.nativeCurrency.symbol,fundingAmountInUsd:ce,options:k,selectedOption:ge,isPreparing:R,isSubmitting:P,addressToFund:q,fundingWalletAddress:Q?.address||"",errorMessage:A,onSubmit:()=>{u.funding?.amount!==K?async function(){if(Q&&ge)try{let e=await dh({isTestnet:!!$.testnet,input:sh({amount:X.toString(),user:Q.address,recipient:q,destinationChainId:$.id,destinationCurrency:j,originChainId:ge.chain.id})}),t=hh(e);if(!t)throw Error("Invalid transaction request");L(!0),se({data:t.data,to:t.to,value:t.value,chain:ge.chain})}catch(e){console.error(e),T(new E("Unable to fetch quotes for bridging",e,b.INSUFFICIENT_BALANCE))}}().catch(console.error):se({to:ge.bridgeTx.to,data:ge.bridgeTx.data,value:ge.bridgeTx.value,chain:ge.chain})},onSelect:e=>{e!==x&&(_(null),S(e))},onAmountChange:Y}):m&&g&&Q&&u?.funding?/*#__PURE__*/t(Bu,{wallet:Q,displayName:le,addressToFund:q,isBridging:W,isErc20Flow:Z,totalPriceInUsd:he,totalPriceInNativeCurrency:ue,gasPriceInUsd:pe,gasPriceInNativeCurrency:me,chainId:$.id,chainName:$.name}):
16
- /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Rh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(Ct,{})]})},[br.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN]:()=>{let{closePrivyModal:r,createAnalyticsEvent:a}=N(),{navigate:i,setModalData:c,app:d,data:h}=Tr(),{wallets:u}=Ca(),p=fa(),[m,y]=s(0n),[g,f]=s(null),[w,v]=s(!1),[C,T]=s(!1),A=l(!1);if(!h?.funding||"solana"!==h.funding.chainType)throw Error("Invalid funding data");let{address:_,amount:k,cluster:I,connectedWalletAddress:x}=h.funding,S=Br(I),{tokenPrice:R}=Uh("solana"),{fundingAmountInBaseUnit:O,totalPriceInUsd:W,totalPriceInNativeCurrency:L,feePriceInNativeCurrency:P,feePriceInUsd:M}=Vh({amount:k,fee:m,tokenPrice:R}),U=x?u.find((({address:e})=>e===x)):u[0];if(o((()=>{(async()=>{if("solana"===U?.type&&U.sendTransaction&&!w&&!A.current){A.current=!0;try{let e=p(wa);if(!e)throw new E("Unable to load solana plugin");let{connection:t,transaction:n}=await e.createTransferTransaction({from:U.address,to:_,amount:O,cluster:I}),r=await n.getEstimatedFee(t);null!=r&&y(BigInt(r)),v(!0);let i=await t.simulateTransaction(n);if(i.value.err)return i.value.logs?.find((e=>/insufficient (lamports|funds)/gi.test(e)))?void f(new E(`Wallet ${Ot(U.address,void 0,void 0,"solana")} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",i.value.err),void f(new E("Something went wrong",void 0,b.TRANSACTION_FAILURE)));let o=await U.sendTransaction(n,t);a({eventName:va,payload:{provider:"external",status:"success",txHash:o,rpcEndpoint:S,address:U.address,value:Ga(O,9),chainType:"solana",clusterName:I.name,token:"SOL",destinationAddress:_,destinationValue:Ga(O,9),destinationChainType:"solana",destinationClusterName:I.name,destinationToken:"SOL"}}),v(!1),T(!0)}catch(e){if(console.error(e),v(!1),/user rejected the request/gi.test(e.message||""))return void f(new E("Transaction was rejected by the user",void 0,b.TRANSACTION_FAILURE));f(new E("Something went wrong",void 0,b.TRANSACTION_FAILURE))}}})().catch(console.error).finally((()=>A.current=!1))}),[]),o((()=>{if(!g)return;let e={error:g,previousScreen:br.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),i(br.ERROR_SCREEN,!1)}),[g]),o((()=>{if(!C)return;let e=setTimeout(r,Fr);return()=>clearTimeout(e)}),[C]),C/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Ht,{children:[/*#__PURE__*/t(Ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(ac,{title:"Success!",description:`You’ve successfully added ${k} SOL to your ${d.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]});let D=U?St(U.walletClientType,U.connectorType,U.walletClientType)||"wallet":null;return U&&w?/*#__PURE__*/t(Bu,{wallet:U,displayName:D,addressToFund:_,isBridging:!1,isErc20Flow:!1,totalPriceInUsd:W,totalPriceInNativeCurrency:L,gasPriceInUsd:M,gasPriceInNativeCurrency:P,chainId:"solana",chainName:I.name}):
17
- /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Rh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(Ct,{})]})},[br.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN]:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:l}=N(),{navigate:c,setModalData:d,app:h,data:u}=Tr(),{wallets:p}=Mr(),m=fa(),[y,g]=s(null),[f,w]=s(null),[v,C]=s([]),[T,A]=s(0),[_,k]=s(!1),[I,x]=s(!1),[S,R]=s(!1),[O,W]=s(!1),[L,P]=s(),[M,U]=s();if(!u?.funding||"solana"!==u.funding.chainType)throw Error("Invalid funding data");let{address:D,cluster:F,connectedWalletAddress:B}=u.funding,[z,H]=s(u.funding.amount),V=B?p.find((({address:e})=>e===B)):p[0],[$,G]=s(null);o((()=>{(async()=>{if(!V)return;let e=await V.getEthereumProvider();G(Ha({account:V.address,transport:Va(e)}).extend($a))})().catch(console.error)}),[V]);let[q,j]=s(0n),K=zh(q);o((()=>{let e=m(wa);e?e.getBalance({address:D,cluster:F}).then((e=>j(BigInt(e)))):console.warn("Unable to load solana plugin, skipping balance")}),[]);let[Y,Z]=s(),{tokenPrice:X}=Uh("solana"),{fundingAmountInBaseUnit:Q,fundingAmountInUsd:J}=Vh({amount:z,fee:0n,tokenPrice:X});o((()=>{(async()=>{if(!$||!V)return;let e=["testnet","devnet"].includes(F.name);e&&console.warn("Solana testnets are not supported for bridging");let t=Wr(h.chains).filter((({testnet:t})=>!!t===e)),n=(await Zh({chains:t,address:V.address,appId:a,rpcConfig:r})).filter((e=>e.balance>0n));if(n.length<1)return void g(new E(`Wallet ${Ot(V.address)} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({...e,quote:await dh({isTestnet:!1,input:sh({amount:Q.toString(),user:V.address,recipient:D,destinationChainId:Ur,destinationCurrency:Dr,originChainId:e.chain.id})})}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void g(new E(`Unable to fetch quotes for bridging. Wallet ${Ot(V.address)} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE));let o=i.map((({quote:e,balance:t,chain:n})=>({bridgeTx:hh(e),balance:t,chain:n}))).filter((({bridgeTx:e})=>!!e));if(o.length>1)return void C(o);let s=o.at(0);s?(x(!0),Z({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):g(new E(`Unable to select bridge option from quotes. Wallet ${Ot(V.address)} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE))})().catch(console.error)}),[$]),o((()=>{(async()=>{let e,t;if(!$||!V||_||S||!Y)return;k(!0);let n=Ba({chain:Y.chain,transport:za(ei(Y.chain,r,a))});try{e=await n.prepareTransactionRequest({account:V.address,to:Y.to,chain:Y.chain,data:Y.data,value:BigInt(Y.value??0)})}catch(e){console.error(e),v.length>1&&w(e.shortMessage??"Something went wrong")}if(e){k(!1),R(!0);try{await $.switchChain({id:Y.chain.id})}catch(e){await $.addChain({chain:Y.chain}),await $.switchChain({id:Y.chain.id})}try{t=await $.sendTransaction(e)}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(v.length<1?g(new E(e.shortMessage,void 0,b.TRANSACTION_FAILURE)):w(e.shortMessage??"Something went wrong"))}if(t)return await $.waitForTransactionReceipt({hash:t}),I?(U("pending"),void P(t)):(R(!1),W(!0),void l({eventName:va,payload:{provider:"external",status:"success",txHash:t,address:V.address,chainId:Y.chain.id,chainType:"ethereum",value:Y.value?Ga(BigInt(Y.value),18):void 0,token:"ETH",destination:D,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ga(Q,9),destinationToken:"SOL"}}));R(!1)}else k(!1)})().catch(console.error)}),[$,Y]),uh({transactionHash:L,wallet:V,isTestnet:!1,bridgingStatus:M,setBridgingStatus:U,onSuccess({transactionHash:e,wallet:t}){x(!1),W(!0),l({eventName:va,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:Y?.chain.id,chainType:"ethereum",value:Y?.value?Ga(BigInt(Y.value),18):void 0,token:"ETH",destination:D,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ga(Q,9),destinationToken:"SOL"}})},onFailure({error:e}){x(!1),g(e)}}),o((()=>{if(!y)return;let e={error:y,previousScreen:br.FUNDING_TRANSFER_FROM_WALLET_SCREEN};d({funding:u?.funding,sendTransaction:u?.sendTransaction,errorModalData:e}),c(br.ERROR_SCREEN,!1)}),[y]);let ee=V?St(V.walletClientType,V.connectorType,V.walletClientType)||"wallet":null;if(o((()=>{if(!O)return;let e=setTimeout(i,Fr);return()=>clearTimeout(e)}),[O]),O/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Ht,{children:[/*#__PURE__*/t(Ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(ac,{title:"Success!",description:`You’ve successfully added ${z} SOL to your ${h.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]});let te=v[T];return v.length>1&&te?/*#__PURE__*/t(Fu,{displayName:ee,configuredFundingChain:F,formattedBalance:K,fundingAmount:z,fundingCurrency:"SOL",fundingAmountInUsd:J,options:v,selectedOption:te,isPreparing:_,isSubmitting:S,addressToFund:D,fundingWalletAddress:V?.address||"",errorMessage:f,onSubmit:()=>{u.funding?.amount!==z?async function(){if(V&&te)try{let e=await dh({isTestnet:!1,input:sh({amount:Q.toString(),user:V.address,recipient:D,destinationChainId:Ur,destinationCurrency:Dr,originChainId:te.chain.id})}),t=hh(e);if(!t)throw Error("Invalid transaction request");x(!0),Z({data:t.data,to:t.to,value:t.value,chain:te.chain})}catch(e){console.error(e),g(new E("Unable to fetch quotes for bridging",e,b.INSUFFICIENT_BALANCE))}}().catch(console.error):Z({to:te.bridgeTx.to,data:te.bridgeTx.data,value:te.bridgeTx.value,chain:te.chain})},onSelect:e=>{e!==T&&(w(null),A(e))},onAmountChange:H}):S&&V?/*#__PURE__*/t(Bu,{wallet:V,displayName:ee,addressToFund:D,isBridging:I,isErc20Flow:!1,chainId:"solana",chainName:F.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
18
- /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Rh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(Ct,{})]})},[br.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN]:function(){let{closePrivyModal:r,createAnalyticsEvent:a}=N(),{navigate:i,setModalData:c,app:d,data:h}=Tr(),{wallets:u}=Ca(),p=l(!1),m=fa(),[y,g]=s(!1),[f,w]=s(!1),[v,C]=s(null),[T,A]=s(),[_,k]=s();if(!h?.funding||"ethereum"!==h.funding.chainType)throw Error("Invalid funding data");let{amount:I,connectedWalletAddress:x,chain:S,cluster:R,isUSDC:O}=h.funding,W=h.funding.address,L=h.funding.erc20Address,P=h.funding.isUSDC?"USDC":S.nativeCurrency.symbol,M=R??{name:"mainnet-beta"},U=x?u.find((({address:e})=>e===x)):u[0];if(o((()=>{(async function(){if(!U||!S||p.current)return;let e=m(wa);if(!e)return void C(new E("Unable to solana plugin"));p.current=!0,S?.testnet&&console.warn("Solana testnets are not supported for bridging");let t=O?1e6*parseFloat(I):qa(I),n=await dh({isTestnet:!!S.testnet,input:sh({amount:t.toString(),user:U.address,recipient:W,destinationChainId:S.id,originChainId:Ur,originCurrency:O?zr:Dr,destinationCurrency:O?L:void 0})}).catch(console.error);if(!n)return void C(new E(`Unable to fetch quotes for bridging. Wallet ${wn(U.address)} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE));let r=await e.createBridgeTransactionFromRelayQuote({quote:n,from:U.address,cluster:M});if(r)try{g(!0);let{connection:e,transaction:t}=r,a=await e.simulateTransaction(t);if(a.value.err)return a.value.logs?.find((e=>/insufficient (lamports|funds)/gi.test(e)))?void C(new E(`Wallet ${wn(U?.address)} does not have enough funds. ${n.details.currencyIn.amountFormatted} ${P} are needed to complete the transaction.`,void 0,b.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",a.value.err),void C(new E("Something went wrong",void 0,b.TRANSACTION_FAILURE)));let i=await U.sendTransaction(t,e),o=await e.confirmTransaction(i);if(o.value.err)return console.error("Transaction failed:",o.value.err),void C(new E("Something went wrong",void 0,b.TRANSACTION_FAILURE));A(i),k("pending")}catch(e){if(console.error(e),/user rejected the request/gi.test(e.message||""))return void C(new E("Transaction was rejected by the user",void 0,b.TRANSACTION_FAILURE));C(new E("Something went wrong",void 0,b.TRANSACTION_FAILURE))}else C(new E(`Unable to select bridge option from quotes. Wallet ${wn(U.address)} does not have enough funds.`,void 0,b.INSUFFICIENT_BALANCE))})().catch(console.error)}),[]),uh({transactionHash:T,wallet:U,isTestnet:!1,bridgingStatus:_,setBridgingStatus:k,onSuccess({transactionHash:e,wallet:t}){g(!1),w(!0),a({eventName:va,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainType:"solana",clusterName:M.name,token:"SOL",destinationAddress:W,destinationChainId:S.id,destinationChainType:"ethereum",destinationValue:I,destinationToken:O?"USDC":"ETH"}})},onFailure({error:e}){g(!1),C(e)}}),o((()=>{if(!f)return;let e=setTimeout(r,Fr);return()=>clearTimeout(e)}),[f]),o((()=>{if(!v)return;let e={error:v,previousScreen:br.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),i(br.ERROR_SCREEN,!1)}),[v]),f/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Ht,{children:[/*#__PURE__*/t(Ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(ac,{title:"Success!",description:`You’ve successfully added ${I} ${P} to your ${d.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]});if(y&&U){let e=U?St(U.walletClientType,U.connectorType,U.walletClientType)||"wallet":null;/*#__PURE__*/return t(Bu,{wallet:U,displayName:e,addressToFund:W,isBridging:y,isErc20Flow:!1,chainId:S.id,chainName:S.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0})}/*#__PURE__*/
19
- return e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/t(Rh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(Ct,{})]})},[br.FUNDING_MANUAL_TRANSFER_SCREEN]:()=>{let{wallets:r}=Mr(),{wallets:a}=Ca(),{data:l,setModalData:c,navigate:d,lastScreen:h}=Tr(),{rpcConfig:u,appId:p,createAnalyticsEvent:m,closePrivyModal:y}=N(),g=Ar(),[f,w]=s(void 0),[v,C]=s(!1),E=fa(),T=l?.funding,{reloadBalance:b}=An({rpcConfig:u,appId:p,address:"ethereum"===T.chainType?T.address:void 0,chain:"ethereum"===T.chainType?T.chain:void 0}),A="solana"===T.chainType,_=A?"SOL":T.erc20Address?T.erc20ContractInfo?.symbol:T.chain.nativeCurrency.symbol,k=A?a.find((({address:e})=>e===T.address)):r.find((({address:e})=>Ot(e)===Ot(T.address)));if(!T)return c({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:h||br.FUNDING_METHOD_SELECTION_SCREEN},funding:l?.funding,sendTransaction:l?.sendTransaction}),d(br.ERROR_SCREEN),/*#__PURE__*/t(n,{});o((()=>{let e=A?async function(){if("solana"!==T.chainType)return;let e=E(wa);e?e.getBalance({address:T.address,cluster:T.cluster}).then((e=>{let t=BigInt(e);f&&t>f&&(C(!0),m({eventName:va,payload:{provider:"manual",status:"success",chainType:"solana",address:k?.address,value:Ga(t-f,9),token:"SOL"}})),w(t)})):console.warn("Unable to load solana plugin, skipping balance")}:async function(){"ethereum"===T.chainType&&(async()=>{if(!T.erc20Address)return await b()??BigInt(0);{let{balance:e}=await pn({chain:T.chain,address:T.address,erc20Address:T.erc20Address,rpcConfig:u,appId:p});return e}})().then((e=>{f&&e>f&&(C(!0),m({eventName:va,payload:{provider:"manual",status:"success",chainType:"ethereum",address:k?.address,chainId:T.chain.id,value:Ga(e-f,T.erc20ContractInfo?.decimals??18),token:T.erc20ContractInfo?.symbol??T.erc20Address??"ETH"}})),w(e)})).catch((()=>w(void 0)))},t=setInterval(e,2e3);return e(),()=>clearInterval(t)}),[f]);let I=i((()=>void 0!==f&&f>=parseFloat(T.amount)),[f,T.amount]),x=i((()=>null==f?"":T.isUSDC?Bi({amount:f,decimals:6}):A?zh(f,3,!0,!0):null!=T.erc20ContractInfo?.decimals?Bi({amount:f,decimals:T.erc20ContractInfo.decimals}):zi({wei:f})),[f,A,T]),S="ethereum"===T.chainType?T.chain.name:hp[T.cluster.name];/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Sh,{}),/*#__PURE__*/e(Vt,{children:["Receive ",T.amount," ",_]}),/*#__PURE__*/e($t,{children:["Scan this code or copy your wallet address to receive funds on ",S,"."]}),/*#__PURE__*/e(En,{style:{gap:"1rem",margin:"1rem 0"},children:[/*#__PURE__*/t(en,{url:`${T.chainType}:${T.address}`,size:200,squareLogoElement:dp}),/*#__PURE__*/e(Xu,{theme:g.appearance.palette.colorScheme,children:["Make sure to send funds on ",S,"."]}),/*#__PURE__*/t(zt,{title:"Your wallet",errMsg:void 0,showIcon:!0,isLoading:!T||void 0===f,isPulsing:!I,balance:`${x} ${_}`,address:T.address,statusColor:I?"green":"gray"}),v&&/*#__PURE__*/t(wt,{onClick:()=>y({shouldCallAuthOnSuccess:!1,isSuccess:!0}),children:"Continue"})]}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN]:()=>{let{closePrivyModal:r}=N(),{data:a,setModalData:i,navigate:o,onUserCloseViaDialogOrKeybindRef:s}=Tr(),{onSuccess:l,onFailure:c}=a.setWalletPassword,d=()=>{c(new S("Exited before password was added to wallet")),r({shouldCallAuthOnSuccess:!1})};return s.current=d,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:d}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(Ht,{children:[/*#__PURE__*/e(Yt,{children:[/*#__PURE__*/t(Wi,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zt,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:/*#__PURE__*/t(Li,{width:"12px",height:"12px",fill:"white"})})]}),/*#__PURE__*/e(ac,{title:"Secure Your Account",children:["Please set a password to secure your account.",/*#__PURE__*/t("p",{children:"Losing access to this password and this device will make your account inaccessible."})]})]}),/*#__PURE__*/t(wt,{onClick:()=>{i({createWallet:{onFailure:c,onSuccess:l,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),o(br.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN)},children:"Add password"}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN]:()=>{let[e,n]=s(null),[r,a]=s(!1),[i,l]=s(null),[c,d]=s(""),{authenticated:h,getAccessToken:u,user:p}=_r(),{walletProxy:m,refreshSessionAndUser:y,closePrivyModal:g,createAnalyticsEvent:f}=N(),{app:w,navigate:v,data:C,onUserCloseViaDialogOrKeybindRef:E}=Tr(),{onSuccess:T,onFailure:b}=C.createWallet,A=Or(p),_="user-passcode"===e?.recoveryMethod,k="user-passcode"===A?.recoveryMethod;o((()=>{h||(v(br.LANDING),b(new R("User must be authenticated before setting a password on a Privy wallet")))}),[h]);let I=()=>i?(b(i),void g({shouldCallAuthOnSuccess:!1})):_?(T(e),void g({shouldCallAuthOnSuccess:!1})):(b(new S("Exited before password was added to wallet")),void g({shouldCallAuthOnSuccess:!1}));E.current=I;/*#__PURE__*/return t(ih,{appName:w?.name||"privy",config:{initiatedBy:"user",onCancel:I},error:i?"An error has occurred, please try again.":void 0,buttonLoading:r,buttonHideAnimations:!1,password:c,isResettingPassword:k,onPasswordGenerate:()=>d(Yd()),onPasswordChange:d,onSubmit:async()=>{_?(T(e),g({shouldCallAuthOnSuccess:!1})):(a(!0),l(null),await(async()=>{let e=await u();if(e&&A?.address&&c&&m)try{f({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k}});let{entropyId:t,entropyIdVerifier:r}=ar(A);if(!(await m.setRecovery({accessToken:e,entropyId:t,entropyIdVerifier:r,recoveryPassword:c,recoveryMethod:"user-passcode"})).entropyId)return l(new S("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k,reason:"error setting password"}});let a=await y(),i=Or(a);if(!i)return l(new S("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k,reason:"wallet disconnected"}});n(i),f({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k}})}catch(e){console.warn(e),l(e instanceof Error?e:Error("Error setting password on privy wallet")),f({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:A.address,reason:e}})}})(),a(!1))},onClose:I})},[br.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN]:()=>{let{app:e,navigate:n,data:r,onUserCloseViaDialogOrKeybindRef:a}=Tr(),[i,l]=s(""),[c,d]=s(!1),[h,u]=s(),[p,m]=s(null),{authenticated:y,user:g}=_r(),{closePrivyModal:f,isNewUserThisSession:w,initializeWalletProxy:v}=N(),{onSuccess:C,onFailure:E,callAuthOnSuccessOnClose:T}=r.createWallet,{createWallet:b}=md(),[A,_]=s(null),k=new je((async()=>{try{let e=await b({recoveryPassword:h,user:g});if(!e)return;_(e),w?n(br.EMBEDDED_WALLET_CREATED_SCREEN):(C(e),f({shouldCallAuthOnSuccess:T}))}catch(e){l(e.message)}}));o((()=>{p||v(3e4).then((e=>m(e)))}),[p]),o((()=>{if(!y||!g)return n(br.LANDING),void E(Error("User must be authenticated before creating a Privy wallet"))}),[y]),a.current=()=>null;/*#__PURE__*/return t(ih,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:!p,buttonLoading:c,buttonHideAnimations:!A&&c,isResettingPassword:!1,error:i,password:h||"",onClose:()=>{A&&"user-passcode"!==A?.recoveryMethod?(E(new S("User created a wallet but failed to set a password for it")),f({shouldCallAuthOnSuccess:!1})):A?(C(A),f({shouldCallAuthOnSuccess:T})):(E(new S("User wallet creation failed")),f({shouldCallAuthOnSuccess:!1}))},onPasswordChange:u,onPasswordGenerate:()=>u(Yd()),onSubmit:async()=>(d(!0),k.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>d(!1))))})},[br.MFA_ENROLLMENT_FLOW_SCREEN]:()=>{let{user:r,enrollInMfa:a}=_r(),[i,l]=s(null),{unenrollWithSms:c,unenrollWithTotp:d,unenrollWithPasskey:h}=um(),{app:u,ready:p,data:m,onUserCloseViaDialogOrKeybindRef:y}=Tr(),{closePrivyModal:g}=N(),{promptMfa:f}=hm(),{initEnrollmentWithTotp:w}=um(),[v,C]=s(!1),[E,T]=s(null),[b,A]=s(null),_=()=>{g({shouldCallAuthOnSuccess:!0}),a(!1),setTimeout((()=>{l(null),T(null)}),500)},{initEnrollmentWithPasskey:k,submitEnrollmentWithPasskey:I}=um(),[x,S]=s(!1),[R,O]=s(null);y.current=_;let W=r?.mfaMethods.includes("sms"),L=!!r?.phone,P=r?.mfaMethods.includes("totp"),M=r?.mfaMethods.includes("passkey"),U=W||P||M,D=r?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function F(){l(null),T(null)}if(o((()=>{U&&C(!0)}),[U]),!p||!r||!u/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(ft,{onClose:_},"header"),/*#__PURE__*/t(Wl,{children:/*#__PURE__*/t(pm,{})}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(tn,{})}),/*#__PURE__*/t(kt,{})]});if("sms"===i)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(li,{})}),/*#__PURE__*/t(Ll,{children:"Remove SMS verification?"}),/*#__PURE__*/e(Pl,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/t(Bl,{children:/*#__PURE__*/t(wt,{warn:!0,onClick:async function(){l(null);try{await c()}catch(e){l(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/t(kt,{})]});if("totp"===i)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(li,{})}),/*#__PURE__*/t(Ll,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e(Pl,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/t(Bl,{children:/*#__PURE__*/t(wt,{warn:!0,onClick:async function(){l(null);try{await d()}catch(e){l(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/t(kt,{})]});if("passkey"===i){let r=m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(li,{})}),/*#__PURE__*/t(Ll,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/t(Pl,{children:r?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/t(Bl,{children:/*#__PURE__*/t(wt,{warn:!0,onClick:async function(){l(null);try{await h({removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){l(null)}},children:"Yes, remove"})}),/*#__PURE__*/t(kt,{})]})}if(0===m.mfaEnrollmentFlow.mfaMethods.length&&!U)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{onClose:_},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(wo,{})}),/*#__PURE__*/t(Ll,{children:"Add more security"}),/*#__PURE__*/e(Pl,{children:[u?.name," does not have any verification methods enabled."]}),/*#__PURE__*/t(Bl,{children:/*#__PURE__*/t(wt,{onClick:_,children:"Close"})}),/*#__PURE__*/t(kt,{})]});let B=!U&&!v;return B?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{onClose:_},"header"),/*#__PURE__*/t(Yl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(wo,{})}),/*#__PURE__*/t(Ll,{children:"Transaction Protection"}),/*#__PURE__*/t(Pl,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(fo,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),/*#__PURE__*/e(Fl,{children:[/*#__PURE__*/t(Dl,{children:/*#__PURE__*/t(vo,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e(Bl,{children:[/*#__PURE__*/t(wt,{onClick:()=>C(!0),children:"Continue"}),/*#__PURE__*/t(Et,{onClick:_,children:"Not now"})]}),/*#__PURE__*/t(kt,{})]}):"sms"===E?/*#__PURE__*/t(Lm,{appName:u?.name||"Privy",onComplete:_,onReset:F,onClose:_}):"totp"===E&&b?/*#__PURE__*/t(Mm,{onComplete:_,onClose:_,onReset:F,totpInfo:{...b,appName:u?.name||"Privy"}}):"passkey"===E?/*#__PURE__*/t(fm,{appName:u?.name||"Privy",onComplete:_,onReset:F,onClose:_}):/*#__PURE__*/t(ym,{showIntro:B,userMfaMethods:r.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:L,onBackToIntro:function(){C(!1)},handleSelectMethod:async function(e){return await f().catch(O),"totp"===e?(T(e),A(null),void w().then((e=>{A(e)})).catch((()=>{A(null),F()}))):"passkey"===e&&1===D.length?await async function(){S(!0);try{await k(),await I({credentialIds:D},{removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){O(e)}finally{S(!1)}}():void T(e)},isTotpLoading:"totp"===E&&!b,isPasskeyLoading:x,error:R,onClose:_,setRemovingMfaMethod:async e=>{await f().catch(O),l(e)}})},[br.CAPTCHA_SCREEN]:()=>{let{lastScreen:r,currentScreen:a,data:i,navigateBack:c,navigate:d,setModalData:h}=Tr(),{status:u,token:p,waitForResult:m,reset:y,execute:g}=gt(),f=l([]),w=e=>{f.current=[e,...f.current]},[v,C]=s(!0);o((()=>(w(setTimeout(C,1e3,!1)),()=>{f.current.forEach((e=>clearTimeout(e))),f.current=[]})),[]);let[E,T]=s(""),[b,A]=s("Checking that you are a human..."),[_,k]=s(/*#__PURE__*/t(wt,{onClick:()=>{},disabled:!0,children:"Continue"})),[I,N]=s(!1),[x,S]=s(3),R=i?.captchaModalData,O=async e=>{try{await(R?.callback(e)),R?.onSuccessNavigateTo&&d(R?.onSuccessNavigateTo,!1)}catch(e){if(e instanceof Ke)return;h({errorModalData:{error:e,previousScreen:r||br.LANDING}}),d(R?.onErrorNavigateTo||br.ERROR_SCREEN,!1)}};o((()=>{"success"===u?w(setTimeout((async()=>{let e=await m();!e||R?.userIntentRequired||O(e)}),1e3)):"ready"===u&&w(setTimeout((()=>{"ready"===u&&g()}),500))}),[u]),o((()=>{if(!v)switch(u){case"success":T("Success!"),A("CAPTCHA passed successfully."),k(/*#__PURE__*/t(wt,{onClick:()=>{N(!0),O(p)},disabled:!R?.userIntentRequired,loading:I,children:R?.userIntentRequired?"Continue":"Continuing..."}));break;case"loading":T(""),A("Checking that you are a human..."),k(/*#__PURE__*/t(wt,{onClick:()=>{},disabled:!0,children:"Continue"}));break;case"error":T("Something went wrong"),x<=0?(A("If you use an adblocker or VPN, try disabling and re-attempting."),k(null)):(A("You did not pass CAPTCHA. Please try again."),k(/*#__PURE__*/t(wt,{onClick:W,children:"Retry"})))}}),[u,v,I]);let W=async()=>{if(x<=0)return;S((e=>e-1)),y(),g();let e=await m();!e||R?.userIntentRequired||O(e)};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{backFn:r&&a!==r?c:void 0}),/*#__PURE__*/e(Ec,{children:["success"===u?/*#__PURE__*/t(wi,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}):"error"===u?/*#__PURE__*/t(vi,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(vc,{}),/*#__PURE__*/e(_t,{children:[E?/*#__PURE__*/t("h3",{children:E}):null,/*#__PURE__*/t("p",{children:b})]}),_]}),/*#__PURE__*/t(kt,{})]})},[br.ERROR_SCREEN]:()=>{let{navigate:e,navigateBack:n,data:r,lastScreen:a,currentScreen:i}=Tr(),o=r?.errorModalData?.previousScreen||(a===i?void 0:a);/*#__PURE__*/return t(mh,{error:r?.errorModalData?.error||Error(),backFn:()=>o?e(o,!1):n(),onClick:()=>e(o||br.LANDING,!1)})},[br.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE]:()=>{let{closePrivyModal:r}=N();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ft,{},"header"),/*#__PURE__*/t(vp,{children:/*#__PURE__*/t(pi,{style:{width:32,height:32}})}),/*#__PURE__*/t(rc,{title:"Could not log in with provider",description:"It looks like you're using an in-app browser. To log in, please try again using an external browser.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/t(_n,{children:/*#__PURE__*/t(wt,{onClick:()=>r(),children:"Close"})}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(Ct,{})]})},[br.AFFIRMATIVE_CONSENT_SCREEN]:()=>{let{user:e,logout:n}=_r(),{app:r,onUserCloseViaDialogOrKeybindRef:a,setModalData:i,navigate:o}=Tr(),{acceptTerms:s,closePrivyModal:l,createAnalyticsEvent:c}=N(),d=e=>{e?.preventDefault(),l({shouldCallAuthOnSuccess:!1}),n()};a.current=d;/*#__PURE__*/return t(Xl,{termsAndConditionsUrl:r?.legal.termsAndConditionsUrl,privacyPolicyUrl:r?.legal.privacyPolicyUrl,onAccept:async t=>{t.preventDefault(),await s(),e&&Tt(e,r.embeddedWallets)?(i({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),c({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AffirmativeConsentScreen"}}),n()},callAuthOnSuccessOnClose:!0}}),o(br.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)):l()},onDecline:d})},[br.TELEGRAM_AUTH_SCREEN]:()=>{let{authenticated:r,logout:a,ready:i,user:l}=_r(),{app:c,setModalData:d,navigate:h,resetNavigation:u,data:p}=Tr(),{initLoginWithTelegram:m,loginWithTelegram:y,updateWallets:g,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v,getAuthMeta:C}=N(),[E,T]=s(!1),[A,_]=s(void 0),k=gt();async function I(){try{let e=await async function(){let e;if(!r){if(k.enabled&&"error"===k.status)throw new Ke(k.error,null,b.CAPTCHA_FAILURE);return k.enabled&&"success"!==k.status&&(k.execute(),e=await k.waitForResult()),e}}();await y({captchaToken:e}),T(!0),f(!0)}catch(e){if(e?.privyErrorCode===b.ALLOWLIST_REJECTED)return _(void 0),u(),void h(br.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===b.USER_LIMIT_REACHED)return console.error(new x(e).toString()),_(void 0),u(),void h(br.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===b.USER_DOES_NOT_EXIST)return _(void 0),u(),void h(br.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===b.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return _(void 0),u(),d({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,telegramAuthResult:C()?.telegramAuthResult,telegramWebAppData:C()?.telegramWebAppData,displayName:e.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void h(br.LINK_CONFLICT_SCREEN);let{retryable:t,detail:n}=ls(e);_({retryable:t,detail:n,message:"Authentication failed"})}}o((()=>{I()}),[]),o((()=>{if(!(i&&r&&E&&l))return;if(c?.legal.requireUsersAcceptTerms&&!l.hasAcceptedTerms){let e=setTimeout((()=>{h(br.AFFIRMATIVE_CONSENT_SCREEN)}),kr);return()=>clearTimeout(e)}if(Tt(l,c.embeddedWallets)){let e=setTimeout((()=>{d({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:"telegram",screen:"TelegramAuthScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(br.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),kr);return()=>clearTimeout(e)}g();let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),kr);return()=>clearTimeout(e)}),[i,r,E,l]);let S=E?"Successfully connected with Telegram":A?A.message:"Verifying connection to Telegram",R="";return R=E?"You’re good to go!":A?A.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(al,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(At,{success:E,fail:!!A}),/*#__PURE__*/t(Xp,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(_t,{children:[/*#__PURE__*/t("h3",{children:S}),/*#__PURE__*/t("p",{children:R})]}),A&&A?.retryable?/*#__PURE__*/t(kn,{onClick:async()=>{try{_(void 0),p?.telegramAuthModalData?.seamlessAuth||await m(void 0,p?.login?.disableSignup),await I()}catch(e){let{retryable:t,detail:n}=ls(e);_({retryable:t,detail:n,message:"Authentication failed"})}},disabled:!E&&!A?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(kt,{})]})},[br.LINK_CONFLICT_SCREEN]:()=>{let{initiateAccountTransfer:e,closePrivyModal:n}=N(),{data:r,navigate:a,lastScreen:i,setModalData:o}=Tr(),[l,c]=s(void 0),[d,h]=s(!1),[u,p]=s(!1),m=async()=>{try{if(!r?.accountTransfer?.nonce||!r?.accountTransfer?.account)throw Error("missing account transfer inputs");p(!0),await e({nonce:r?.accountTransfer?.nonce,account:r?.accountTransfer?.account,accountType:r?.accountTransfer?.linkMethod,externalWalletMetadata:r?.accountTransfer?.externalWalletMetadata,telegramWebAppData:r?.accountTransfer?.telegramWebAppData,telegramAuthResult:r?.accountTransfer?.telegramAuthResult,farcasterEmbeddedAddress:r?.accountTransfer?.farcasterEmbeddedAddress,oAuthUserInfo:r?.accountTransfer?.oAuthUserInfo}),h(!0),p(!1),setTimeout(n,1e3)}catch(e){o({errorModalData:{error:e,previousScreen:i||br.LINK_CONFLICT_SCREEN}}),a(br.ERROR_SCREEN,!0)}};return l?/*#__PURE__*/t(Sl,{address:l,onClose:n,onRetry:()=>c(void 0),onTransfer:m,isTransferring:u,transferSuccess:d}):/*#__PURE__*/t(Rl,{onClose:n,onInfo:()=>c(r?.accountTransfer?.embeddedWalletAddress),onContinue:()=>c(r?.accountTransfer?.embeddedWalletAddress),onTransfer:m,isTransferring:u,transferSuccess:d,data:r})}},xf=[br.LANDING,br.AWAITING_CONNECTION],Sf=({isMfaVerifying:r,onMfaVerificationComplete:a})=>{let{ready:i,isModalOpen:s}=_r(),{headless:l}=Ar(),{ready:c,currentScreen:d}=Tr(),{status:h,execute:u,reset:p,enabled:m}=gt(),y=s&&d&&xf.includes(d)&&!l&&"ready"===h;return o((()=>{y&&u()}),[y]),o((()=>{!s&&m&&p()}),[s,m]),i&&c||d===br.AWAITING_OAUTH_SCREEN||d===br.CROSS_APP_AUTH_SCREEN||d===br.TELEGRAM_AUTH_SCREEN?!d&&r?/*#__PURE__*/t(Ty,{open:r,onClose:a}):d?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(pl,{$if:!!r,children:/*#__PURE__*/t(Nf[d],{})}),/*#__PURE__*/t(pl,{$if:!r,children:/*#__PURE__*/t(Ty,{open:r,onClose:a})})]}):null:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ft,{}),/*#__PURE__*/t(Dt,{}),/*#__PURE__*/t(If,{children:/*#__PURE__*/t(tn,{})}),/*#__PURE__*/t(Ft,{}),/*#__PURE__*/t(kt,{})]})},Rf=({isMfaVerifying:e,onMfaVerificationComplete:n})=>{let r=l(null);/*#__PURE__*/return t(Lf,{style:{height:Bn(r)},id:"privy-modal-content",children:/*#__PURE__*/t("div",{ref:r,children:/*#__PURE__*/t(Sf,{isMfaVerifying:e,onMfaVerificationComplete:n})})})};const Of=({open:e})=>{let{app:n}=Tr(),{gracefulClosePrivyModal:r}=(()=>{let{closePrivyModal:e}=N(),{onUserCloseViaDialogOrKeybindRef:t}=Tr();return{gracefulClosePrivyModal:c((()=>{if(!t?.current)return e({shouldCallAuthOnSuccess:!1});t.current()}),[e])}})(),[a,i]=s(!1);nl({onMfaRequired:()=>{n?.mfa.noPromptOnMfaRequired||i(!0)}});let o=e||a;return n.render.standalone?/*#__PURE__*/t(Ef,{children:/*#__PURE__*/t(Wf,{id:"privy-modal-content",children:/*#__PURE__*/t(Sf,{isMfaVerifying:a,onMfaVerificationComplete:()=>i(!1)})})}):/*#__PURE__*/t(Tf,{open:o,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:/*#__PURE__*/t(Ef,{children:/*#__PURE__*/t(Rf,{isMfaVerifying:a,onMfaVerificationComplete:()=>i(!1)})})})};let Wf=/*#__PURE__*/ii.div.withConfig({displayName:"ContentWrapper",componentId:"sc-1174608a-0"})(["display:flex;flex-direction:column;text-align:center;font-size:14px;line-height:20px;width:100%;background:var(--privy-color-background);padding:0 16px;"]),Lf=/*#__PURE__*/ii(Wf).withConfig({displayName:"BaseModal",componentId:"sc-1174608a-1"})(["transition:height 150ms ease-out;overflow:hidden;max-height:calc(100svh - 32px);border-radius:var(--privy-border-radius-lg) var(--privy-border-radius-lg) 0 0;box-shadow:0px 0px 36px rgba(55,65,81,0.15);@media (min-width:441px){box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]);function Pf(e){let n=l(null),r=l();return o((()=>{r.current?.remove(),r.current=function({botUsername:e,scriptHost:t}){let n=document.createElement("script"),{origin:r}=new URL(t);return n.async=!0,n.src=`${r}/js/telegram-login.js`,n.setAttribute("data-telegram-login",e),n.setAttribute("data-request-access","write"),n.setAttribute("data-lang","en"),n}(e),n.current?.after(r.current)}),[e]),/*#__PURE__*/t("div",{ref:n,hidden:!0})}async function Mf(e,t,n,r,a,i=!1){let o=i,s=async s=>{if(o&&t&&t.length>0){s===(i?0:1)?a("configureMfa","onMfaRequired",{mfaMethods:t}):r.current?.reject(new jc("missing_or_invalid_mfa","MFA verification failed, retry."));let o=await new Promise(((e,t)=>{n.current={resolve:e,reject:t},setTimeout((()=>{let e=new jc("mfa_timeout","Timed out waiting for MFA code");r.current?.reject(e),t(e)}),3e5)}));return await e(o)}return await e()},l=null;for(let e=0;e<4;e++)try{l=await s(e),r.current?.resolve(void 0);break}catch(e){if("missing_or_invalid_mfa"!==e.type)throw r.current?.resolve(void 0),e;o=!0}if(null===l){let e=new jc("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw r.current?.reject(e),e}return l}var Uf;let Df=(Uf=0,()=>"id-"+Uf++);function Ff(e){return void 0!==e.error}let Bf=new class{enqueue(e,t){this.callbacks[e]=t}dequeue(e,t){let n=this.callbacks[t];if(!n)throw Error(`cannot dequeue ${e} event: no event found for id ${t}`);switch(delete this.callbacks[t],e){case"privy:iframe:ready":case"privy:wallets:create":case"privy:wallets:add":case"privy:wallets:import":case"privy:wallets:set-recovery":case"privy:wallets:connect":case"privy:wallets:recover":case"privy:wallets:rpc":case"privy:wallet:create":case"privy:mfa:verify":case"privy:mfa:init-enrollment":case"privy:mfa:submit-enrollment":case"privy:mfa:unenroll":case"privy:mfa:clear":case"privy:auth:unlink-passkey":case"privy:farcaster:init-signer":case"privy:farcaster:sign":case"privy:solana-wallet:create":case"privy:delegated-actions:consent":return n;default:throw Error(`invalid wallet event type ${e}`)}}constructor(){this.callbacks={}}},zf=new Map,Hf=(e,t)=>"bigint"==typeof t?t.toString():t,Vf=(e,t)=>`${e}${JSON.stringify(t,Hf)}`;function $f(e,t,n,r){let a=n.contentWindow;if(!a)throw Error("iframe not initialized");let i=Vf(e,t);if("privy:wallet:create"===e){let e=zf.get(i);if(e)return e}let o=new Promise(((n,i)=>{let o=Df();Bf.enqueue(o,{resolve:n,reject:i}),a.postMessage({id:o,event:e,data:t},r)})).finally((()=>{zf.delete(i)}));return zf.set(i,o),o}function Gf(e){let n=l(null),r=l(e.mfaMethods),a=_a(),[i,c]=s(!1);return o((()=>{r.current=e.mfaMethods}),[e.mfaMethods]),o((()=>{if(!i)return;let t=n.current;if(!t)return;function o(t){var n;t&&t.origin===e.origin&&"string"==typeof(n=t.data).event&&/^privy:.+/.test(n.event)&&function(e){switch(e.event){case"privy:iframe:ready":let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallets:create":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:add":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:set-recovery":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:connect":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:recover":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:rpc":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallet:create":let n=Bf.dequeue(e.event,e.id);return Ff(e)?n.reject(new jc(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallets:import":let r=Bf.dequeue(e.event,e.id);return Ff(e)?r.reject(new jc(e.error.type,e.error.message)):r.resolve(e.data);case"privy:mfa:verify":let a=Bf.dequeue(e.event,e.id);return Ff(e)?a.reject(new jc(e.error.type,e.error.message)):a.resolve(e.data);case"privy:mfa:init-enrollment":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:submit-enrollment":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:unenroll":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:clear":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:auth:unlink-passkey":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:solana-wallet:create":let i=Bf.dequeue(e.event,e.id);return Ff(e)?i.reject(new jc(e.error.type,e.error.message)):i.resolve(e.data);case"privy:farcaster:init-signer":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:farcaster:sign":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:delegated-actions:consent":{let t=Bf.dequeue(e.event,e.id);return Ff(e)?t.reject(new jc(e.error.type,e.error.message)):t.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}(t.data)}let s={createWallet:n=>Mf((r=>$f("privy:wallets:create",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),addWallet:n=>Mf((r=>$f("privy:wallets:add",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),setRecovery:n=>Mf((r=>$f("privy:wallets:set-recovery",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),connect:n=>Mf((r=>$f("privy:wallets:connect",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),recover:n=>Mf((r=>$f("privy:wallets:recover",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a,!n.recoveryAccessToken&&!n.recoveryPassword&&!n.recoverySecretOverride),rpc:n=>Mf((r=>$f("privy:wallets:rpc",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),create:n=>$f("privy:wallet:create",n,t,e.origin),importWallet:n=>$f("privy:wallets:import",n,t,e.origin),createSolana:n=>Mf((r=>$f("privy:solana-wallet:create",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),createDelegatedAction:n=>$f("privy:delegated-actions:consent",n,t,e.origin),verifyMfa:n=>Mf((r=>$f("privy:mfa:verify",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a,!0),initEnrollMfa:n=>Mf((r=>$f("privy:mfa:init-enrollment",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),submitEnrollMfa:n=>Mf((r=>$f("privy:mfa:submit-enrollment",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),unenrollMfa:n=>Mf((r=>$f("privy:mfa:unenroll",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),clearMfa:n=>$f("privy:mfa:clear",n,t,e.origin),unlinkPasskeyAccount:n=>Mf((r=>$f("privy:auth:unlink-passkey",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),initFarcasterSigner:n=>$f("privy:farcaster:init-signer",n,t,e.origin),signFarcasterMessage:n=>$f("privy:farcaster:sign",n,t,e.origin)};window.addEventListener("message",o);let l=new AbortController;return zn((()=>$f("privy:iframe:ready",{},t,e.origin)),{abortSignal:l.signal}).then((()=>e.onLoad(s)),((...t)=>{console.warn("Privy iframe failed to load: ",...t),e.onLoadFailed()})),()=>{window.removeEventListener("message",o),l.abort()}}),[i]),
20
- /*#__PURE__*/t("iframe",{ref:n,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>c(!0),src:Gt(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId,client_id:e.appClientId})})}const qf=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.delegated));class jf{async handleSignMessage(e){if(!e.params||"string"!=typeof e.params.message)throw Error("Message must be provided as a string for Solana signMessage RPC");return await vw({message:e.params.message,options:{address:this.address,uiOptions:{}}})}async request(e){if(console.debug("EmbeddedSolanaProvider.request() called with args",e),!await uw())throw Error("User must be authenticated to use embedded Solana wallet");if(!await ww())throw new E("Unable to connect to Solana embedded wallet");if("signMessage"===e.method)return await this.handleSignMessage(e);throw Error("Embedded Solana provider does not yet support this RPC method.")}constructor(e,t){this.walletProxy=e,this.address=t}}const Kf="popup-privy-oauth",Yf="PRIVY_OAUTH_USE_BROADCAST_CHANNEL";class Zf{async authenticate(){if(!this.api)throw new E("Auth flow has no API instance");try{return await this.api.post(j,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw T(e)}}async link(){if(!this.api)throw new E("Auth flow has no API instance");try{return await this.api.post(K,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw T(e)}}constructor({authorizationCode:e,stateCode:t,codeVerifier:n,provider:r}){this.meta={authorizationCode:e,stateCode:t,codeVerifier:n,provider:r}}}async function Xf({api:e,requesterAppId:t,providerAppId:n}){let r=(await e.get(`/api/v1/apps/${t}/cross-app/connections`)).connections.find((e=>e.provider_app_id===n));if(!r)throw new E("Invalid connected app");return{name:r.provider_app_name,logoUrl:r.provider_app_icon_url||void 0,apiUrl:r.provider_app_custom_api_url,readOnly:r.read_only}}const Qf=async({user:e,address:t,client:n,request:r,requesterAppId:a,reconnect:i})=>{n.createAnalyticsEvent({eventName:"cross_app_request_started",payload:{address:t,method:r.method}});let o=e?.linkedAccounts.find((e=>"cross_app"===e.type&&(e.embeddedWallets.some((e=>e.address===t))||e.smartWallets.some((e=>e.address===t)))));if(!e||!o)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Cannot request a signature with this wallet address",address:t}}),new E("Cannot request a signature with this wallet address");let s=n.getProviderAccessToken(o.providerApp.id),l=await Xf({api:n.api,requesterAppId:a,providerAppId:o.providerApp.id});if(!s){if(l.readOnly)throw console.error("cannot transact against a read-only provider app"),new E("Cannot transact against a read-only provider app");await i({appId:o.providerApp.id,action:"link"})&&(s=n.getProviderAccessToken(o.providerApp.id))}if(!s)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Transactions require a valid token",address:t}}),new E("Transactions require a valid token");let c=np();if(!c)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Missing token",address:t}}),new E("Failed to initialize signature request");let d=new URL(`${l.apiUrl}/oauth/transact`);return d.searchParams.set("token",s||""),d.searchParams.set("request",Jf(r)),c.location=d.href,new Promise(((e,a)=>{let i=setTimeout((()=>{d(),a(new E("Request timeout")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Request timeout",address:t}})}),12e4),s=setInterval((()=>{c.closed&&(d(),a(new E("User rejected request")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"User rejected request",address:t}}))}),300),l=i=>{i.data&&("set"===i.data.token?.action&&void 0!==i.data.token?.value?n.storeProviderAccessToken(o.providerApp.id,i.data.token.value):"clear"===i.data.token?.action&&n.storeProviderAccessToken(o.providerApp.id,null),"PRIVY_CROSS_APP_ACTION_RESPONSE"===i.data.type&&i.data.result&&(d(),e(i.data.result),n.createAnalyticsEvent({eventName:"cross_app_request_success",payload:{address:t,method:r.method}})),"PRIVY_CROSS_APP_ACTION_ERROR"===i.data.type&&i.data.error&&(d(),a(i.data.error),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:i.data.error,address:t}})))};window.addEventListener("message",l);let d=()=>{c.close(),clearInterval(s),clearTimeout(i),window.removeEventListener("message",l)}}))};let Jf=e=>JSON.stringify({content:{request:{request:ew(e,Fa)}},timestamp:Date.now(),callbackUrl:window.origin});const ew=(e,t)=>"bigint"==typeof e?t(e):Array.isArray(e)?e.map((e=>ew(e,t))):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,ew(n,t)]))):e,tw=e=>!!e.fundingConfig&&ka(e.fundingConfig.options).length>=1;async function nw({url:e,popup:t,provider:n}){return t.location=e,new Promise(((e,n)=>{function r(){t?.close(),window.removeEventListener("message",a)}function a(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(e(t.data),r()),"https://cdn.apple-cloudkit.com"===t.origin&&t.data.ckSession&&(e({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:t.data.ckSession}),r()),"PRIVY_OAUTH_ERROR"===t.data.type&&(n(t.data.error),r()))}window.addEventListener("message",a)}))}let rw,aw,iw,ow,sw,lw,cw,dw;function hw(){return rw?rw.getCustomerAccessToken():Promise.resolve(da.get(sr)||null)}async function uw(){return rw?rw.getAccessToken():Promise.resolve(da.get(lr)||da.get(sr)||null)}const pw=(e,t)=>aw(e,t),mw=(e,t)=>iw(e,t),yw=(e,t)=>ow(e,t),gw=(e,t)=>sw(e,t),fw=()=>lw(),ww=()=>cw(),vw=({message:e,address:t})=>dw({message:e,options:{address:t,uiOptions:{}}});const Cw=({config:e,...n})=>{var r;if("undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new E("Embedded wallet is only available over HTTPS");if("string"!=typeof(r=n.appId)||25!==r.length)throw new E("Cannot initialize the Privy provider with an invalid Privy app ID");rw||(rw=new Js({appId:n.appId,appClientId:n.clientId,apiUrl:n.apiUrl}));let a=Object.assign({},e);/*#__PURE__*/
21
- return t(Qr,{client:rw,clientConfig:a,children:/*#__PURE__*/t(Ia,{children:/*#__PURE__*/t(Ew,{...n,client:rw})})})};let Ew=n=>{let a=n.client,d=fa(),[h,u]=s(!1),[p,m]=s(!1),[y,g]=s(!1),[f,w]=s(null),[_,k]=s([]),[I,N]=s([]),[x,S]=s([]),[R,W]=s(!1),[U,D]=s(null),[F,B]=s(!1),[z,H]=s({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:L}),[V,$]=s({status:"initial"}),[G,q]=s({status:"initial"}),[j,K]=s({status:"initial"}),[Z,X]=s({status:"initial"}),[Q,J]=s({status:"initial"}),[ee,te]=s({status:"initial"}),[ne,re]=s(null),ae=Ar(),ie=Jr(),[oe,se]=s(!0),[le,ce]=s({}),[de,he]=s(null),[ue,pe]=s(null),[me,ye]=s(!1),[ge,fe]=s(!1),[we,ve]=s(ae.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),Ce=l(null),Ee=l(null),Te=l(Na),[be,Ae]=s(!1);a.onStoreCustomerAccessToken=e=>{e&&xa(Te,"accessToken","onAccessTokenGranted",{accessToken:e})},a.onDeleteCustomerAccessToken=()=>{w(null),g(!1),xa(Te,"accessToken","onAccessTokenRemoved")};let _e=l(null),ke=l(null),Ie=l(!1),Ne=({showWalletUIs:e})=>Ie.current?Ie.current:void 0!==e?!e:!ae.embeddedWallets.showWalletUIs,xe=e=>{D(e),setTimeout((()=>{u(!0)}),15),a.createAnalyticsEvent({eventName:"modal_open",payload:{initialScreen:e}})},Se=e=>{("off"!==ae.embeddedWallets.ethereum.createOnLogin||"off"!==ae.embeddedWallets.solana.createOnLogin)&&se(!0),xe(e)};o((()=>{let e=[...ea(f),Zr(f)].filter((e=>!!e));ne&&S(e.map((e=>({type:"solana",imported:e.imported,address:e.address,connectedAt:Date.now(),walletClientType:"privy",connectorType:"embedded",walletIndex:e.walletIndex??void 0,meta:{name:"Privy Wallet",icon:void 0,id:"io.privy.solana.wallet"},linked:!0,fund(){throw new E("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:()=>{throw new E("Cannot unlink an embedded Solana wallet")},getProvider:async()=>new jf(ne,e.address),async signMessage(t){let n=await uw();if(!n||!ne)throw new E("Must have valid access token and Privy wallet to send transaction",b.MUST_BE_AUTHENTICATED);let r=e.imported?Zr(f):Or(f);if(!r)throw new E("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=ar(r);if(!await at.recoverPrimaryWallet().catch((()=>!1)))throw new E("Wallet couldn't be connected",b.UNKNOWN_CONNECT_WALLET_ERROR);if(!f)throw new E("Attempting to sign a transaction with no user initialized");let{response:o}=await ne.rpc({accessToken:n,entropyId:a,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:e.walletIndex??0,request:{method:"signMessage",params:{message:Buffer.from(t).toString("base64")}}});return Buffer.from(o.data.signature,"base64")},async sendTransaction(e,t,n){let{signature:r}=await Ye({transaction:e,connection:t,transactionOptions:n,wallet:this,signOnly:!1});return r},async signTransaction(t){let n=await uw();if(!n||!ne)throw new E("Must have valid access token and Privy wallet to send transaction",b.MUST_BE_AUTHENTICATED);if(!await at.recoverPrimaryWallet().catch((()=>!1)))throw new E("Wallet couldn't be connected",b.UNKNOWN_CONNECT_WALLET_ERROR);let r=e.imported?e:Or(f);if(!r)throw new E("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=ar(r);return await By({tx:t,accessToken:n,walletProxy:ne,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0}),t},loginOrLink:async()=>{throw new E("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{},isConnected:async()=>!0}))))}),[ne,f]),o((()=>{if(!f)return void a.connectors?.removeEmbeddedWalletConnectors();let e=xr(f),t=ta(f),r=na(f);e&&t.length||a.connectors?.removeEmbeddedWalletConnectors(),r||a.connectors?.removeImportedWalletConnector(),a.connectors?ne?(e&&a.connectors.addEmbeddedWalletConnectors({walletProxy:ne,rootWallet:e,embeddedWallets:t,defaultChain:ae.defaultChain,appId:n.appId}),r&&a.connectors.addImportedWalletConnector(ne,r.address,ae.defaultChain,n.appId)):console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized"):console.debug("Failed to add embedded wallet connector: Client connectors not initialized")}),[ne,f]),o((()=>{ne&&ue?.(ne)}),[ne]);let Re=l();o((()=>{(async()=>{if(!ae.customAuth?.enabled)return void ve({status:"not-enabled"});se(!0);let{getCustomAccessToken:e,isLoading:t}=ae.customAuth;if(p&&!t&&"loading"!==we.status){ve({status:"loading"});try{let t=await e();if(t===Re.current)return void ve({status:"done"});if(!t&&y)return Re.current=t,await rt.logout(),ve({status:"done"}),void xa(Te,"customAuth","onUnauthenticated");if(!t)return Re.current=t,void ve({status:"done"});a.startAuthFlow(new Oo(t));let{user:n,isNewUser:r}=await a.authenticate();if(!n)return await rt.logout(),ve({status:"error",error:new E("Failed to sync with custom auth provider")}),void xa(Te,"customAuth","onUnauthenticated");void 0!==r&&xa(Te,"login","onComplete",{user:n,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),Re.current=t,xa(Te,"customAuth","onAuthenticated",{user:n}),ve({status:"done"}),w(n||null),W(r||!1),g(!0),fe(!0)}catch(e){if(console.warn(e),await rt.logout(),xa(Te,"customAuth","onUnauthenticated"),"User already exists with provided custom JWT account."===e.message)return void ve({status:"initial"});xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),ve({status:"error",error:e})}}})()}),["initial"===we.status,ae.customAuth?.enabled,ae.customAuth?.getCustomAccessToken,ae.customAuth?.isLoading,p,y]),o((()=>{ge&&ne&&f&&(async()=>{let e=qt(f,ae.embeddedWallets.ethereum.createOnLogin),t=jt(f,ae.embeddedWallets.solana.createOnLogin),n=await uw();if(n){if(e&&t){let e=await Ve(f,Rr);return await ne.createSolana({accessToken:n,ethereumAddress:e?.address}),void fe(!1)}if(t)return await ne.createSolana({accessToken:n,ethereumAddress:xr(f)?.address}),await at.refreshSessionAndUser(),void fe(!1);if(e)return await Ve(f,Rr),void fe(!1)}})().catch(console.error)}),[ge&&ne&&f]),o((()=>{if(ae.externalWallets.solana.connectors)return ae.externalWallets.solana.connectors.onMount(),()=>ae.externalWallets.solana.connectors?.onUnmount()}),[ae.externalWallets.solana.connectors]),o((()=>{!p&&ie&&async function(){let e,t=Oe(),n=We();(()=>{let e=new URLSearchParams(window.location.search).get("privy_token");if(!e)return;da.put(dr,e);let t=new URL(window.location.href);t.searchParams.delete("privy_token"),window.history.pushState({},"",t)})();let i=r();a.initializeConnectorManager({walletConnectCloudProjectId:ae.walletConnectCloudProjectId,rpcConfig:ae.rpcConfig,chains:ae.chains,defaultChain:ae.defaultChain,store:i,walletList:ae.appearance.walletList,shouldEnforceDefaultChainOnConnect:ae.shouldEnforceDefaultChainOnConnect,externalWalletConfig:ae.externalWallets,appName:ae.name??"Privy",walletChainType:ae.appearance.walletChainType}),a.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=a.connectors.walletConnectors.length,n=a.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);n===t?Ae(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:n,expected:t}),Ae(!0)}),1500)})),a.connectors?.initialize().then((()=>{De()}));let o=await a.getAuthenticatedUser(),s=!!o;ae.legal.requireUsersAcceptTerms&&o&&!o.hasAcceptedTerms?(await a.logout(),at.setReadyToTrue(!0),xa(Te,"logout","onSuccess")):(ae.customAuth?.enabled||(g(!!o),o&&xa(Te,"login","onComplete",{user:o,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),w(o)),t?ke.current=s?"link":"login":n&&!s?(ke.current="login",ce({telegramAuthModalData:{seamlessAuth:!0}}),Se(br.TELEGRAM_AUTH_SCREEN)):at.setReadyToTrue(!!o))}()}),[a,de,p,ie]),o((()=>{if(p){if(!f||!f.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType)))return void ye(!0);ye([..._,...x].some((e=>"privy"===e.walletClientType)))}}),[p,f,_,x]),o((()=>{a.connectors?.setWalletList(ae.appearance.walletList)}),[ae.appearance.walletList.join()]);let Oe=()=>{let e=ns();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&function(e){return e.startsWith("privy:")}(e.provider)&&!e.popupFlow&&(new BroadcastChannel(Kf).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(a.startAuthFlow(new Ho(e)),Se(br.AWAITING_OAUTH_SCREEN),!0))},We=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),n=e.get("hash"),r=Number(e.get("auth_date")||""),a=e.get("first_name");if(t&&a&&r&&n)return Object.fromEntries(e.entries())}())?(ds(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=cs(e.replace("#tgWebAppData=","")),{user:n,auth_date:r,hash:a}=t;return n&&r&&a?t:void 0}())?(ds(),{flowType:"web-app",authData:e}):void 0}();if(!e||!ae.loginMethods.telegram||!ae.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new ss;return a.startAuthFlow(t),"login-url"===e.flowType&&(t.meta.telegramWebAppData=void 0,t.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=e.authData),!0},Le=async(e,t,n,r)=>{if("solana_adapter"!==e)Pe(await(a.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,n,r);else{let i=a.connectors?.findSolanaWalletConnector(e,t);if(!i)return;Pe(i,t,n,r)}};async function Pe(e,t,n,r){if(!e)return H({status:"disconnected",connectedWallet:null,connectError:new A("Unable to connect to wallet."),connector:null,connectRetry:L}),r?.(null,n);H({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:L}),e instanceof pt&&t&&await e.resetConnection(t),H({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Pe(e,t,n,r)});try{let t=await e.connect({showPrompt:!0});if((!t||mt(t))&&ae.shouldEnforceDefaultChainOnConnect&&!ae.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){H((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:L})));try{await(t?.switchChain(ae.defaultChain.id)),t&&(t.chainId=qn(Qe(ae.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${ae.defaultChain.id}`)}}return H((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:L}))),t&&xa(Te,"connectWallet","onSuccess",{wallet:t}),r?.(t,n)}catch(e){return e instanceof O?(console.warn(e.cause?e.cause:e.message),xa(Te,"connectWallet","onError",e.privyErrorCode||b.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),xa(Te,"connectWallet","onError",b.UNKNOWN_CONNECT_WALLET_ERROR)),H((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),r?.(null,n)}}let Me=async(e,t,n)=>{if(null===e||!mt(e))return;let r=new yt(e,a,t,n);a.startAuthFlow(r)},Ue=async(e,t,n)=>{if(null===e||!Wa(e))return;let r=new Hn(e,a,t,n);a.startAuthFlow(r)},De=()=>{let e=new URLSearchParams(window.location.search),t=e.get("privy_connector"),n=e.get("privy_wallet_client"),r="true"===e.get("privy_connect_only");if(!t||!n)return;let i=Ps({connectorType:t,walletClientType:n});if(!i||!i.isInstalled)return Se(br.LOGIN_FAILED_SCREEN);if(!a.connectors)throw new E("Connector not initialized");xe(r?br.AWAITING_CONNECT_ONLY_CONNECTION:br.AWAITING_CONNECTION);let o=new URL(window.location.href);o.searchParams.delete("privy_connector"),o.searchParams.delete("privy_wallet_client"),o.searchParams.delete("privy_connect_only"),window.history.pushState({},"",o),Le(t,n,void 0,r?void 0:"solana_adapter"===t?Ue:Me)};o((()=>{p&&y&&null===f&&a.getAuthenticatedUser().then(w)}),[p,y,f,a]);let Fe=e=>{if(!y)throw xa(Te,"linkAccount","onError",b.MUST_BE_AUTHENTICATED,{linkMethod:e}),new E("User must be authenticated before linking an account.")},Be=e=>{if(!y||!f)return!1;if("privy"===e.walletClientType)return!0;for(let t of f.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},ze=async e=>{let t;if(!a.connectors)throw new E("Connector not initialized");t="ethereum"===e.type?a.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:a.connectors.findSolanaWalletConnector(e.connectorType,e.walletClientType)||null,H((n=>({...n,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:L}))),ae.captchaEnabled&&!y?(ce({captchaModalData:{callback:t=>mt(e)?Me(e,t):Ue(e,t),userIntentRequired:!1,onSuccessNavigateTo:br.AWAITING_CONNECTION,onErrorNavigateTo:br.ERROR_SCREEN}}),Se(br.CAPTCHA_SCREEN)):(mt(e)?await Me(e):await Ue(e),Se(br.AWAITING_CONNECTION))},He=()=>{k((e=>{let t=a.connectors?.wallets.filter(mt).map((e=>({...e,linked:Be(e),loginOrLink:async()=>{if(!await e.isConnected())throw new E("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new E("Cannot link or login with embedded wallet");ze(e)},fund:async t=>{await at.fundWallet(e.address,t)},unlink:async()=>{if(!y)throw new E("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new E("Cannot unlink an embedded wallet");w(await a.unlinkEthereumWallet(e.address))}})))||[];return jn(e,t)?e:t})),N((e=>{let t=(a.connectors?.wallets??[]).filter(Wa).map((e=>({...e,linked:Be(e),loginOrLink:async()=>{if(!await e.isConnected())throw new E("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new E("Cannot link or login with embedded wallet");ze(e)},fund:async()=>{throw new E("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!y)throw new E("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new E("Cannot unlink an embedded wallet");w(await a.unlinkSolanaWallet(e.address))}})));return jn(e,t)?e:t}))};o((()=>{He()}),[f?.linkedAccounts,y,p]),o((()=>{if(p){if(!a.connectors)throw new E("Connector not initialized");He(),a.connectors.on("walletsUpdated",He)}}),[p]),o((()=>{[...ae.loginMethodsAndOrder?.primary??[],...ae.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>a.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!a]);let Ve=async(e,t,n)=>{let r=xr(e),a=Sr(e);if(n&&"walletIndex"in n&&"number"==typeof n.walletIndex)return Ge(e,t,n.walletIndex,r,a);let i=n&&"createAdditional"in n&&n.createAdditional;if(r&&!i)throw xa(Te,"createWallet","onError",b.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");let[o,s]=await Promise.all([at.initializeWalletProxy(t),uw()]);if(!o&&ae.customAuth?.enabled)throw xa(Te,"createWallet","onError",b.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!o||!s||ae.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return $e();if(!r)return a&&await at.recoverPrimaryWallet(),await o.create({accessToken:s,solanaAddress:a?.address}),je(0,"ethereum");{let t=(ra(e)?.walletIndex??0)+1,{entropyId:n,entropyIdVerifier:r}=ar(Or(e));return await at.recoverPrimaryWallet(),await o.addWallet({accessToken:s,entropyId:n,entropyIdVerifier:r,chainType:"ethereum",hdWalletIndex:t}),je(t,"ethereum")}},$e=async()=>new Promise(((e,t)=>{se(!0),ce({createWallet:{onSuccess:t=>{xa(Te,"createWallet","onSuccess",{wallet:t}),e(t)},onFailure:e=>{xa(Te,"createWallet","onError",b.UNKNOWN_EMBEDDED_WALLET_ERROR),t(e)},callAuthOnSuccessOnClose:!1}}),xe(br.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)})),Ge=async(e,t,n,r,a)=>{if(n<0)throw xa(Te,"createWallet","onError",b.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${n}) is invalid.`);let[i,o]=await Promise.all([at.initializeWalletProxy(t),uw()]);if(!i&&ae.customAuth?.enabled)throw xa(Te,"createWallet","onError",b.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!i||!o||ae.embeddedWallets?.requireUserOwnedRecoveryOnCreate){if(0==n)return $e();throw xa(Te,"createWallet","onError",b.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Create wallet UI can only be displayed when walletIndex is 0.")}if(0==n){if(r)return r;await i.create({accessToken:o,solanaAddress:a?.address})}else{if(!r)throw xa(Te,"createWallet","onError",b.EMBEDDED_WALLET_CREATE_ERROR),Error("A user must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let t=ta(e).find((e=>e.walletIndex===n));if(t)return t;let{entropyId:a,entropyIdVerifier:s}=ar(Or(e));await at.recoverPrimaryWallet(),await i.addWallet({accessToken:o,entropyId:a,entropyIdVerifier:s,chainType:"ethereum",hdWalletIndex:n})}return je(n,"ethereum")},qe=async({user:e,wp:t,accessToken:n,walletIndex:r,ethereumWallet:a})=>{let i=ea(e).find((e=>e.walletIndex===r));if(i)return i;if(0===r)a&&await at.recoverPrimaryWallet(),await t.createSolana({accessToken:n,ethereumAddress:a?.address});else{let a=Or(e);if(!a)throw xa(Te,"createWallet","onError",b.EMBEDDED_WALLET_CREATE_ERROR),Error("User must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let{entropyId:i,entropyIdVerifier:o}=ar(a);await at.recoverPrimaryWallet(),await t.addWallet({accessToken:n,entropyId:i,entropyIdVerifier:o,chainType:"solana",hdWalletIndex:r})}return je(r,"solana")},je=async(e,t)=>{let n=await at.refreshSessionAndUser(),r=("ethereum"===t?ta(n):ea(n)).find((t=>t.walletIndex===e));if(!r)throw xa(Te,"createWallet","onError",b.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");return xa(Te,"createWallet","onSuccess",{wallet:r}),r},Ke=({transaction:e,uiOptions:t,fundWalletConfig:r,address:a,signOnly:i})=>new Promise((async(o,s)=>{let{requesterAppId:l}=t||{},c=i?"signTransaction":"sendTransaction";if(!y||!f)return xa(Te,c,"onError",b.MUST_BE_AUTHENTICATED),void s(Error("User must be authenticated before signing with a Privy wallet"));let d=a??xr(f)?.address;if(!d)throw new E("User must have an embedded wallet to send a transaction.");let{signingWallet:h,rootWallet:u}=aa(f,d);if(!u||!h)return xa(Te,c,"onError",b.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have a Privy wallet before signing"));se(!0);let p=it.wallets.find((e=>"privy"===e.walletClientType&&C(e.address)===C(h.address))),m=await(p?.getEthereumProvider());if(!p||!m)throw new E(`Cannot sendTransaction before embedded wallet ${h.address} is connected`);let g=e.chainId?Number(e.chainId):La(p.chainId);(e=>{if(!ae.chains.map((e=>e.id)).includes(e))throw new A(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,b.UNSUPPORTED_CHAIN_ID)})(g);let w={...e,from:e.from??h.address,chainId:g},v=await uw();if(!v||!ne)return xa(Te,c,"onError",b.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have valid access token and Privy wallet to send transaction"));let T=Ja(w.chainId,ae.chains,ae.rpcConfig,{appId:n.appId});if(Ne({showWalletUIs:t?.showWalletUIs}))(async()=>{try{if(!await at.recoverPrimaryWallet())return xa(Te,c,"onError",b.UNKNOWN_CONNECT_WALLET_ERROR),void s(Error("Unable to connect to wallet"));let e=await wy(w,T,w.from),{entropyId:t,entropyIdVerifier:n}=ar(u),r=i?await Sg({accessToken:v,entropyId:t,entropyIdVerifier:n,transactingWallet:h,walletProxy:ne,transactionRequest:w,requesterAppId:l}):await xg({accessToken:v,entropyId:t,entropyIdVerifier:n,transactingWallet:h,walletProxy:ne,transactionRequest:e,publicClient:T,requesterAppId:l});i?xa(Te,"signTransaction","onSuccess",{signature:r}):xa(Te,"sendTransaction","onSuccess",{hash:r}),o({hash:r})}catch(e){xa(Te,c,"onError",b.TRANSACTION_FAILURE),s(e)}})();else{let{entropyId:e,entropyIdVerifier:n}=ar(u),a={entropyId:e,entropyIdVerifier:n,onCompleteNavigateTo:br.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:e=>{xa(Te,c,"onError",b.UNKNOWN_CONNECT_WALLET_ERROR),s(e)}},d=tw(ae)?Ra({address:h.address,appConfig:ae,fundWalletConfig:r,methodScreen:br.FUNDING_METHOD_SELECTION_SCREEN,chainIdOverride:w.chainId,comingFromSendTransactionScreen:!0}):void 0;ce({connectWallet:a,sendTransaction:{transactionRequest:w,transactingWallet:h,entropyId:e,entropyIdVerifier:n,signOnly:i,onConfirm:i?async()=>await Sg({accessToken:v,entropyId:e,entropyIdVerifier:n,transactingWallet:h,walletProxy:ne,transactionRequest:w,requesterAppId:l}):void 0,onSuccess:e=>{i?xa(Te,"signTransaction","onSuccess",{signature:e.hash}):xa(Te,"sendTransaction","onSuccess",{hash:e.hash}),o(e)},onFailure:e=>{xa(Te,c,"onError",b.TRANSACTION_FAILURE),s(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:l},funding:d}),xe(br.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),Ye=({transaction:e,connection:t,transactionOptions:n,fundWalletConfig:r,uiOptions:a,wallet:i,signOnly:o})=>new Promise((async(s,l)=>{let{requesterAppId:c}=a||{},d=o?"signSolanaTransaction":"sendSolanaTransaction";if(!y||!f)return xa(Te,d,"onError",b.MUST_BE_AUTHENTICATED),void l(new E("User must be authenticated before signing with a Privy wallet",b.MUST_BE_AUTHENTICATED));let h=i?f.linkedAccounts.find((e=>"wallet"===e.type&&e.address===i.address)):Sr(f);if(!h)return xa(Te,d,"onError",b.EMBEDDED_WALLET_NOT_FOUND),void l(new E("Must have a Privy wallet before signing",b.EMBEDDED_WALLET_NOT_FOUND));se(!0);let{rootWallet:u}=Xr(f,h.address);if(!await at.recoverPrimaryWallet().catch((()=>!1))||!u)throw xa(Te,d,"onError",b.EMBEDDED_WALLET_NOT_FOUND),new E(`Cannot sendSolanaTransaction before embedded wallet ${h.address} is connected`,b.EMBEDDED_WALLET_NOT_FOUND);if(Ne({showWalletUIs:a?.showWalletUIs}))(async()=>{let r=await uw();if(!r||!ne)return xa(Te,d,"onError",b.EMBEDDED_WALLET_NOT_FOUND),void l(new E("Must have valid access token and Privy wallet to send transaction",b.EMBEDDED_WALLET_NOT_FOUND));try{let i;if(!await at.recoverPrimaryWallet())return xa(Te,d,"onError",b.UNKNOWN_CONNECT_WALLET_ERROR),void l(new E("Unable to connect to wallet",b.UNKNOWN_CONNECT_WALLET_ERROR));if(Ne({showWalletUIs:a?.showWalletUIs}))try{if(!await async function(e,t){let{value:n}=await t.simulateTransaction(e);if("BlockhashNotFound"===n.err)throw Error("Simulation failed: Blockhash not found");return null==n.err&&n.logs?.every((e=>!/insufficient funds/gi.test(e)))}(e,t))return xa(Te,d,"onError",b.INSUFFICIENT_BALANCE),void l(new E("Solana wallet has insufficient funds for this transaction.",b.INSUFFICIENT_BALANCE))}catch(e){return console.error(e),xa(Te,d,"onError",b.TRANSACTION_FAILURE),void l(new E(e instanceof Error?e.message:"Transaction failed.",b.TRANSACTION_FAILURE))}let{entropyId:c,entropyIdVerifier:u}=la(f);if(o)await By({accessToken:r,tx:e,walletProxy:ne,entropyId:c,entropyIdVerifier:u,transactingWalletAddress:h.address,transactingWalletIndex:h.walletIndex??0}),i=Gh("",e,null),xa(Te,"signSolanaTransaction","onSuccess",{signedTransaction:e});else{let{signature:a,receipt:o}=await zy({accessToken:r,tx:e,connection:t,walletProxy:ne,transactionOptions:n,entropyId:c,entropyIdVerifier:u,transactingWalletAddress:h.address,transactingWalletIndex:h.walletIndex??0});i=Gh(a,e,o),xa(Te,"sendSolanaTransaction","onSuccess",{response:i})}s(i)}catch(e){xa(Te,d,"onError",b.TRANSACTION_FAILURE),l(e)}})();else{let{entropyId:i,entropyIdVerifier:p}=ar(u),m={entropyId:i,entropyIdVerifier:p,onCompleteNavigateTo:br.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN,onFailure:e=>{xa(Te,d,"onError",b.UNKNOWN_CONNECT_WALLET_ERROR),l(e)}},y=tw(ae)?Sa({address:h.address,appConfig:ae,methodScreen:br.FUNDING_METHOD_SELECTION_SCREEN,fundWalletConfig:r,comingFromSendTransactionScreen:!0}):void 0;ce({connectWallet:m,sendSolanaTransaction:{transactionRequest:e,connection:t,transactionOptions:n,transactingWallet:h,onSuccess:e=>{o?xa(Te,"signSolanaTransaction","onSuccess",{signedTransaction:e.signedTransaction}):xa(Te,"sendSolanaTransaction","onSuccess",{response:e}),s(e)},onFailure:e=>{xa(Te,d,"onError",b.TRANSACTION_FAILURE),l(e)},uiOptions:a||{},requesterAppId:c,signOnly:o},funding:y}),xe(br.EMBEDDED_WALLET_CONNECTING_SCREEN)}}));function Ze(){return new Promise((async(e,t)=>{let n=await uw();if(!n||!ne)throw Error("Must have valid access token to enroll in MFA");try{await ne.verifyMfa({accessToken:n}),e()}catch(e){t(e)}}))}let Xe=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],et=e=>{let t=f?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:n,loginMethod:r}=Np(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw xa(Te,"linkAccount","onError",b.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:r}),new E(`User already has an account of type ${n} linked.`)};async function tt({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){D(null);let n=t?"setWalletPassword":"setWalletRecovery";if(!y||!f)throw xa(Te,n,"onError",b.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let r=Or(f);if(!r||!ne)throw xa(Te,n,"onError",b.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");try{await Ze()}catch(e){throw xa(Te,n,"onError",b.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,i)=>{se(!0);let o={onSuccess:e=>{xa(Te,n,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{xa(Te,n,"onError",b.USER_EXITED_SET_PASSWORD_FLOW),i(e)},callAuthOnSuccessOnClose:!1},s="user-passcode"===r.recoveryMethod,l=nd({walletAction:"update",availableRecoveryMethods:ae.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:s,showAutomaticRecovery:e}),{entropyId:c,entropyIdVerifier:d}=ar(r);ce({setWalletPassword:o,recoverWallet:{entropyId:c,entropyIdVerifier:d,onFailure:i},createWallet:o,connectWallet:{onCompleteNavigateTo:l,shouldForceMFA:!1,entropyId:c,entropyIdVerifier:d,onFailure:e=>{xa(Te,n,"onError",b.UNKNOWN_CONNECT_WALLET_ERROR),i(e)}},recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:s}}),xe(br.EMBEDDED_WALLET_CONNECTING_SCREEN)}))}async function nt({appId:e,action:t}){let n=await uw();if("link"===t&&!n)throw xa(Te,"linkAccount","onError",b.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new E("User must be authenticated before linking an account.");if("login"===t&&n)throw xa(Te,"login","onError",b.UNKNOWN_AUTH_ERROR),new E("Attempted to log in, but user is already logged in. Use a `link` helper instead.");_e.current=`privy:${e}`,ke.current=t;let r=np();return a.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,i)=>{let{name:o,logoUrl:s}=await Xf({api:a.api,providerAppId:e,requesterAppId:ae.id});ce({crossAppAuth:{appId:e,name:o,logoUrl:s,action:t,popup:r,onSuccess:n,onError:i}}),Se(br.CROSS_APP_AUTH_SCREEN)}))}let rt={ready:p,authenticated:y,user:f,walletConnectors:a.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),ce({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),xe(y?br.CONNECT_ONLY_AUTHENTICATED_SCREEN:br.CONNECT_ONLY_LANDING_SCREEN)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),Fe("siwe"),_e.current="siwe",ke.current="link",ce({...le,externalConnectWallet:{...le.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),xe(br.LINK_WALLET_SCREEN)},startCrossAppAuthFlow:nt,linkEmail:()=>{Fe("email"),et("email"),_e.current="email",ke.current="link",xe(br.LINK_EMAIL_SCREEN)},linkPhone:()=>{Fe("sms"),et("phone"),_e.current="sms",ke.current="link",xe(br.LINK_PHONE_SCREEN)},linkGoogle:async()=>{Fe("google"),et("google_oauth"),ke.current="link",await at.initLoginWithOAuth("google")},linkTwitter:async()=>{Fe("twitter"),et("twitter_oauth"),ke.current="link",await at.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Fe("discord"),et("discord_oauth"),ke.current="link",await at.initLoginWithOAuth("discord")},linkGithub:async()=>{Fe("github"),et("github_oauth"),ke.current="link",await at.initLoginWithOAuth("github")},linkSpotify:async()=>{Fe("spotify"),et("spotify_oauth"),ke.current="link",await at.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Fe("instagram"),et("instagram_oauth"),ke.current="link",await at.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Fe("tiktok"),et("tiktok_oauth"),ke.current="link",await at.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Fe("linkedin"),et("linkedin_oauth"),ke.current="link",await at.initLoginWithOAuth("linkedin")},linkApple:async()=>{Fe("apple"),et("apple_oauth"),ke.current="link",await at.initLoginWithOAuth("apple")},linkPasskey:async()=>{Fe("passkey"),et("passkey"),await at.initLinkWithPasskey(),xe(br.LINK_PASSKEY_SCREEN)},linkTelegram:async e=>{if(Fe("telegram"),et("telegram"),ke.current="link",_e.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new ss;a.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=cs(e.launchParams.initDataRaw),ce({telegramAuthModalData:{seamlessAuth:!0}}),Se(br.TELEGRAM_AUTH_SCREEN)}else xa(Te,"linkAccount","onError",b.INVALID_DATA,{linkMethod:"telegram"});else await at.initLoginWithTelegram();xe(br.TELEGRAM_AUTH_SCREEN)},linkFarcaster:async()=>{Fe("farcaster"),et("farcaster"),await at.initLoginWithFarcaster(),ke.current="link",_e.current="farcaster",xe(br.AWAITING_FARCASTER_CONNECTION)},updateEmail:()=>{if(Fe("email"),!f?.email)throw new E("User does not have an email linked to their account.");ke.current="update",_e.current="email",xe(br.UPDATE_EMAIL_SCREEN)},updatePhone:()=>{if(Fe("sms"),!f?.phone)throw new E("User does not have a phone number linked to their account.");ke.current="update",_e.current="sms",xe(br.UPDATE_PHONE_SCREEN)},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!p){let e=await new Promise((e=>{he((t=>e.bind(t)))}));if(he(null),e)return void console.warn(t)}!f||f.isGuest?(ke.current="login",ce({login:e}),Se(br.LANDING)):console.warn(t)},connectOrCreateWallet:async()=>{p||(await new Promise((e=>{he((()=>e))})),he(null)),y?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(ke.current="login",Se(br.CONNECT_OR_CREATE))},logout:async()=>{if(ke.current=null,_e.current=null,f&&a.clearProviderAcccessTokens(f),D(null),await a.logout(),f&&ne)try{await ne.clearMfa({userId:f.id})}catch(e){}w(null),g(!1),xa(Te,"logout","onSuccess"),u(!1),da.del(Er),da.del(Zn(ae.id))},getAccessToken:c((()=>a.getCustomerAccessToken()),[a]),unlinkWallet:async e=>{let t;return w(t=e.startsWith("0x")?await a.unlinkEthereumWallet(e):await a.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await a.unlinkEmail(e);return w(t),t},unlinkPhone:async e=>{let t=await a.unlinkPhone(e);return w(t),t},unlinkGoogle:async e=>{let t=await a.unlinkOAuth("google",e);return w(t),t},unlinkTwitter:async e=>{let t=await a.unlinkOAuth("twitter",e);return w(t),t},unlinkDiscord:async e=>{let t=await a.unlinkOAuth("discord",e);return w(t),t},unlinkGithub:async e=>{let t=await a.unlinkOAuth("github",e);return w(t),t},unlinkSpotify:async e=>{let t=await a.unlinkOAuth("spotify",e);return w(t),t},unlinkInstagram:async e=>{let t=await a.unlinkOAuth("instagram",e);return w(t),t},unlinkTiktok:async e=>{let t=await a.unlinkOAuth("tiktok",e);return w(t),t},unlinkLinkedIn:async e=>{let t=await a.unlinkOAuth("linkedin",e);return w(t),t},unlinkApple:async e=>{let t=await a.unlinkOAuth("apple",e);return w(t),t},unlinkFarcaster:async e=>{let t=await a.unlinkFarcaster(e);return w(t),t},unlinkTelegram:async e=>{let t=await a.unlinkTelegram(e);return w(t),t},unlinkPasskey:async e=>{let t=await uw();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!ne)throw Error("Wallet proxy not initialized.");let n=ae.passkeys.shouldUnenrollMfaOnUnlink;await ne.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:n});let r=await a.getAuthenticatedUser();return w(r),r},unlinkCrossAppAccount:async({subject:e})=>{let t=f?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new E("Invalid subject");a.storeProviderAccessToken(t.id,null);let n=await a.unlinkOAuth(`privy:${t.id}`,e);return w(n),n},createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let t=await at.refreshSessionAndUser();if(!t)throw xa(Te,"createWallet","onError",b.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return Ve(t,15e3,e)},setWalletRecovery:async e=>tt({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>tt({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=e.message;if(!y||!f)return xa(Te,"signMessage","onError",b.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let s=t?.address??xr(f)?.address;if(!s)throw new E("User must have an embedded wallet to sign a message.");let{signingWallet:l,rootWallet:c}=aa(f,s);if(!l||!c)return xa(Te,"signMessage","onError",b.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));if("string"!=typeof o||o.length<1)return xa(Te,"signMessage","onError",b.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));se(!0);let d=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let e=await uw();if(!ne||!e||!await at.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:l.address,requesterAppId:i}});let{entropyId:t,entropyIdVerifier:n}=ar(c),{response:r}=await ne.rpc({accessToken:e,entropyId:t,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:l.walletIndex??0,requesterAppId:i,request:{method:"personal_sign",params:[o,l.address]}}),s=r.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:l.address,requesterAppId:i}}),s};if(Ne({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await d();xa(Te,"signMessage","onSuccess",{signature:e}),n({signature:e})}catch(e){xa(Te,"signMessage","onError",b.UNABLE_TO_SIGN),r(e??new ba("Unable to sign message"))}else{let e={method:"personal_sign",data:o,confirmAndSign:d,onSuccess:e=>{xa(Te,"signMessage","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{xa(Te,"signMessage","onError",b.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},{entropyId:a,entropyIdVerifier:i}=ar(c);ce({signMessage:e,connectWallet:{entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:br.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{xa(Te,"signMessage","onError",b.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),xe(br.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),signTypedData:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{};if(!y||!f)return xa(Te,"signTypedData","onError",b.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let o=t?.address??xr(f)?.address;if(!o)throw new E("User must have an embedded wallet to sign a message.");let{signingWallet:s,rootWallet:l}=aa(f,o);if(!l||!s)return xa(Te,"signTypedData","onError",b.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));se(!0);let c=Je(e),d=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let e=await uw();if(!ne||!e||!await at.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:s.address,requesterAppId:i}});let{entropyId:t,entropyIdVerifier:n}=ar(l),{response:r}=await ne.rpc({accessToken:e,entropyId:t,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:s.walletIndex??0,requesterAppId:i,request:{method:"eth_signTypedData_v4",params:[s.address,c]}}),o=r.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:s.address,requesterAppId:i}}),o};if(Ne({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await d();xa(Te,"signTypedData","onSuccess",{signature:e}),n({signature:e})}catch(e){xa(Te,"signTypedData","onError",b.UNABLE_TO_SIGN),r(e??new ba("Unable to sign message"))}else{let e={method:"eth_signTypedData_v4",data:c,confirmAndSign:d,onSuccess:e=>{xa(Te,"signTypedData","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{xa(Te,"signTypedData","onError",b.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},{entropyId:a,entropyIdVerifier:i}=ar(l);ce({signMessage:e,connectWallet:{entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:br.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{xa(Te,"signMessage","onError",b.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),xe(br.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),sendTransaction:async(e,t)=>await Ke({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await Ke({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!y||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let i=e?.address??xr(f)?.address;if(!i)return void r(Error("User does not have an HD Ethereum wallet. To export an imported wallet, pass the `address` of the wallet to `exportWallet`."));let{signingWallet:o,rootWallet:s}=aa(f,i);if(!o||!s)return void r(Error("Must have a Privy wallet before exporting"));se(!0);let{entropyId:l,entropyIdVerifier:c}=ar(s),d={entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:br.EMBEDDED_WALLET_KEY_EXPORT_SCREEN,onFailure:r,shouldForceMFA:!0};ce(le),await uw()&&ne?ne?(ce({keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:o,primaryWallet:s,onSuccess:t,onFailure:r},connectWallet:d}),xe(br.EMBEDDED_WALLET_CONNECTING_SCREEN)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:Ze,async init(e){switch(e){case"sms":return void await a.initMfaSmsVerification();case"passkey":return await a.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new E("Invalid MFA code");Ce.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{Ee.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new E("Invalid authenticator response");let n=await import("@simplewebauthn/browser"),r=(e=>({id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}))(await n.startAuthentication(t));Ce.current?.resolve({mfaMethod:e,mfaCode:r,relyingParty:window.origin}),await new Promise(((e,t)=>{Ee.current={resolve:e,reject:t}}));break;default:throw Ce.current?.reject(new E("Unsupported MFA method")),new E(`Unsupported MFA method: ${e}`)}},cancel(){Ce.current?.reject(new E("MFA canceled"))},async initEnrollmentWithSms(e){let t=await uw();if(!t||!ne)throw Error("Must have valid access token to enroll in MFA");await ne.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,n)=>{if(!e)return at.closePrivyModal(),void t();ae.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),ce({mfaEnrollmentFlow:{mfaMethods:ae.mfa.methods,shouldUnlinkOnUnenrollMfa:ae.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:n}}),xe(br.MFA_ENROLLMENT_FLOW_SCREEN)})),async initEnrollmentWithTotp(){let e=await uw();if(!e||!ne)throw Error("Must have valid access token to enroll in MFA");let t=await ne.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await uw();if(!t||!ne)throw Error("Must have valid access token to enroll in MFA");await ne.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),w(await a.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await uw();if(!t||!ne)throw Error("Must have valid access token to enroll in MFA");await ne.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),w(await a.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let n=await uw();if(!n||!ne)throw Error("Must have valid access token to enroll in MFA");await ne.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:e,removeForLogin:t.removeForLogin}),w(await a.getAuthenticatedUser())},async unenroll(e,t={}){let n=await uw();if(!n||!ne)throw Error("Must have valid access token to remove MFA");"passkey"===e?await ne.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:[],removeForLogin:t.removeForLogin}):await ne.unenrollMfa({method:e,accessToken:n}),w(await a.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await uw(),t=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!ne||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await at.recoverPrimaryWallet())throw Error("Unable to connect to wallet");let n=await ne.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===n.status&&w(await a.getAuthenticatedUser()||f||null),ce({farcasterSigner:n}),xe(br.AWAITING_FARCASTER_SIGNER)},getFarcasterSignerPublicKey:async()=>{let e,t=await uw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!ne||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await at.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=f.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await uw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!ne||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await at.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let r=await import("@simplewebauthn/browser"),a=await ne.signFarcasterMessage({address:n.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:r.bufferToBase64URLString(e)},fid:BigInt(f.farcaster.fid),relyingParty:window.origin});return new Uint8Array(r.base64URLStringToBuffer(a.signature))},createGuestAccount:async()=>{if(f&&!f.isGuest)throw Error("User cannot already be authenticated to create a guest account");return f?.isGuest?f:at.loginWithGuestAccountFlow()},signMessageWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Qf({user:f,client:a,address:t,requesterAppId:ae.id,request:{method:r?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:n},reconnect:nt})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),i=Je(e);return Qf({user:f,client:a,address:t,requesterAppId:ae.id,request:{method:r?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,i],chainId:n},reconnect:nt})},sendTransactionWithCrossAppWallet(e,{address:t}){let n=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Qf({user:f,client:a,address:t,requesterAppId:ae.id,request:{method:n?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:nt})},isModalOpen:h,mfaMethods:ae.mfa.methods};aw=rt.signMessage,iw=rt.signTypedData,sw=async(e,t)=>await Ke({transaction:e,...t,signOnly:!1}),ow=async(e,t)=>({signature:(await Ke({transaction:e,...t,signOnly:!0})).hash});let at={setAuthenticated:g,setUser:w,isNewUserThisSession:R,pendingTransaction:null,walletConnectionStatus:z,connectors:a.connectors?.walletConnectors??[],solanaWallets:I,rpcConfig:ae.rpcConfig,chains:ae.chains,appId:n.appId,showFiatPrices:"native-token"!==ae.embeddedWallets.priceDisplay.primary,clientAnalyticsId:a.clientAnalyticsId,customAuthStatus:we,hideWalletUIs:Ie,emailOtpState:G,setEmailOtpState:q,smsOtpState:j,setSmsOtpState:K,oAuthState:Q,setOAuthState:J,telegramAuthState:ee,setTelegramAuthState:te,siweState:Z,setSiweState:X,isHeadlessOAuthLoading:F,nativeTokenSymbolForChainId:e=>ae.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(ne)return ne;let t=new Promise((e=>{pe((()=>t=>e(t)))})),n=new Promise((t=>setTimeout((()=>t(null)),e))),r=await Promise.race([t,n]);return pe(null),r},getAuthFlow:()=>a.authFlow,getAuthMeta:()=>a.authFlow?.meta,client:a,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=p&&y&&f;r&&_e.current&&(t=Xe(f)),"login"===ke.current?e.shouldCallAuthOnSuccess&&r&&_e.current?xa(Te,"login","onComplete",{user:f,isNewUser:R,wasAlreadyAuthenticated:!1,loginMethod:_e.current,loginAccount:t??null}):xa(Te,"login","onError",b.USER_EXITED_AUTH_FLOW):"link"===ke.current&&t?e.isSuccess&&r&&_e.current?xa(Te,"linkAccount","onSuccess",{user:f,linkMethod:_e.current,linkedAccount:t}):_e.current&&xa(Te,"linkAccount","onError",b.USER_EXITED_LINK_FLOW,{linkMethod:_e.current}):"update"===ke.current&&t&&(e.isSuccess&&r&&_e.current?xa(Te,"update","onSuccess",{user:f,updateMethod:_e.current,updatedAccount:t}):_e.current&&xa(Te,"update","onError",b.USER_EXITED_UPDATE_FLOW,{linkMethod:_e.current}));let i=U&&Hu.includes(U),o=U===br.ERROR_SCREEN&&le.errorModalData&&Hu.includes(le.errorModalData.previousScreen);if((i||o)&&le.funding){let e,t=Vu[U]??null;if("solana"===le.funding.chainType){let n=d(wa);if(!n)return void console.warn("Unable to load solana plugin, skipping balance");try{e=BigInt(await n.getBalance({address:le.funding.address,cluster:le.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}xa(Te,"fundSolanaWallet","onUserExited",{address:le.funding.address,cluster:le.funding.cluster,fundingMethod:t,balance:e})}else{let r=Ja(le.funding.chain.id,ae.chains,ae.rpcConfig,{appId:n.appId});try{e=await r.getBalance({address:le.funding.address})}catch{console.error("Unable to pull wallet balance")}xa(Te,"fundWallet","onUserExited",{address:le.funding.address,chain:le.funding.chain,fundingMethod:t,balance:e})}}ce({...le,externalConnectWallet:{suggestedAddress:void 0}}),ke.current=null,_e.current=null,W(!1),u(!1),setTimeout((()=>{a.authFlow=void 0}),200),a.createAnalyticsEvent({eventName:"modal_closed"})},solanaSignMessage:({message:e,options:t})=>new Promise((async(n,r)=>{if(!y||!f)return xa(Te,"signSolanaMessage","onError",b.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let i=t?.address??Sr(f)?.address;if(!i)throw new E("User must have an embedded wallet to sign a message.");let{signingWallet:o,rootWallet:s}=Xr(f,i);if(!o||!s)return xa(Te,"signSolanaMessage","onError",b.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));if("string"!=typeof e||e.length<1)return xa(Te,"signMessage","onError",b.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));se(!0);let l=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let t=await a.getAccessToken();if(!t)throw Error("User must be authenticated to use their embedded wallet.");let n=at.walletProxy??await at.initializeWalletProxy(15e3);if(!n)throw Error("Failed to initialize embedded wallet proxy.");if(!await at.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!s)throw Error("No root wallet for signing wallet found");let{entropyId:r,entropyIdVerifier:i}=ar(s),{response:l}=await n.rpc({accessToken:t,entropyId:r,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:o.walletIndex??0,request:{method:"signMessage",params:{message:e}}});return l.data.signature};if(Ne({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await l();xa(Te,"signSolanaMessage","onSuccess",{signature:new Uint8Array(Buffer.from(e,"base64"))}),n({signature:e})}catch(e){r(e)}else{let a={method:"solana_signMessage",data:e,confirmAndSign:l,onSuccess:e=>{xa(Te,"signSolanaMessage","onSuccess",{signature:new Uint8Array(Buffer.from(e,"base64"))}),n({signature:e})},onFailure:e=>{r(e)},uiOptions:t?.uiOptions},{entropyId:i,entropyIdVerifier:o}=ar(s);ce({signMessage:a,connectWallet:{entropyId:i,entropyIdVerifier:o,onCompleteNavigateTo:br.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{xa(Te,"signSolanaMessage","onError",b.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Se(br.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),signSolanaTransaction:async({transaction:e,connection:t,uiOptions:n,transactionOptions:r,address:a})=>{let i=a?x.find((e=>e.address===a)):x.slice().sort(((e,t)=>(e.walletIndex??0)-(t.walletIndex??0)))[0];if(!i)throw xa(Te,"signSolanaTransaction","onError",b.EMBEDDED_WALLET_NOT_FOUND),new E("Embedded wallet not found",b.EMBEDDED_WALLET_NOT_FOUND);let{signedTransaction:o}=await Ye({transaction:e,connection:t,transactionOptions:r,uiOptions:n,wallet:i,signOnly:!0});return o},sendSolanaTransaction:async({transaction:e,connection:t,uiOptions:n,transactionOptions:r,fundWalletConfig:a,address:i})=>{let o=i?x.find((e=>e.address===i)):x.slice().sort(((e,t)=>(e.walletIndex??0)-(t.walletIndex??0)))[0];if(!o)throw xa(Te,"sendSolanaTransaction","onError",b.EMBEDDED_WALLET_NOT_FOUND),new E("Embedded wallet not found",b.EMBEDDED_WALLET_NOT_FOUND);return await Ye({transaction:e,connection:t,transactionOptions:r,uiOptions:n,fundWalletConfig:a,wallet:o,signOnly:!1})},openPrivyModal:xe,connectWallet:Pe,initLoginWithWallet:async(e,t,n)=>{mt(e)?(_e.current="siwe",Me(e,t,n)):(_e.current="siws",Ue(e,t,n))},loginWithWallet:async()=>{let e,t,n;if(!p)throw new P;if(a.authFlow instanceof yt?e="siwe":a.authFlow instanceof Hn&&(e="siws"),!e)throw new E("Must initialize SIWE/SIWS flow first.");if(null!==await a.getAccessToken())try{({user:t}=await a.link()),_e.current=e}catch(t){throw xa(Te,"linkAccount","onError",t.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:n}=await a.authenticate()),_e.current=e}catch(e){throw xa(Te,"login","onError",e.privyErrorCode||b.GENERIC_CONNECT_WALLET_ERROR),e}w(t||f||null),W(n||!1),g(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:n})=>new Promise((async(r,a)=>{let i=await uw();if(!y||!f||!i)throw new E("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new E("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=at.walletProxy??await at.initializeWalletProxy(15e3);if(!o)throw new E("Wallet proxy not initialized.");if((({address:e,chainType:t,user:n})=>!!qf(n).find((n=>n.address===e&&n.chainType===t)))({address:e,chainType:t,user:f}))return r();let s=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new E("Address to delegate is not associated with current user.");return{address:n.address,chainType:n.chainType,walletIndex:n.walletIndex??0}})({address:e,user:f}),l=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new E("Address to delegate is not associated with current user.");let r=n.imported?n:Or(t);if(!r)throw new E("Unable to determine root address for delegated address.");return{address:r.address,chainType:r.chainType,imported:r.imported}})({address:e,user:f}),c=async()=>{await o.createDelegatedAction({accessToken:i,rootWallet:l,delegatedWallets:[s]}),await at.refreshSessionAndUser()};if(await at.recoverPrimaryWallet(),n)ce({delegatedActions:{consent:{address:e,onDelegate:c,onSuccess:async()=>{r()},onError:async e=>{a(e)}}}}),xe(br.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN);else try{await c(),r()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,n)=>{if(!y||!f)throw new E("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");if(0===qf(f).length)throw new E("User has no delegated wallets to revoke.");let r=async()=>{await a.revokeDelegatedWallet(),await at.refreshSessionAndUser()};if(e)ce({delegatedActions:{revoke:{onRevoke:r,onSuccess:async()=>{t()},onError:async e=>{n(e)}}}}),xe(br.EMBEDDED_WALLET_DELEGATED_ACTIONS_REVOKE_SCREEN);else try{await r(),t()}catch(e){n(e)}})),initLoginWithFarcaster:async(e,t)=>{let n=new Mo(e,t);a.startAuthFlow(n);try{_e.current="farcaster",await n.initializeFarcasterConnect()}catch(e){throw"login"===ke.current?xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR):"link"===ke.current&&xa(Te,"linkAccount","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!p)throw new P;if(!(a.authFlow instanceof Mo))throw new E("Must initialize Farcaster flow first.");if(null!==await a.getAccessToken())try{({user:e}=await a.link()),_e.current="farcaster"}catch(e){throw xa(Te,"linkAccount","onError",e.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await a.authenticate()),_e.current="farcaster"}catch(e){throw xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),e}w(e||null),W(t||!1),g(!0)},async loginWithGuestAccountFlow(){let e=new Do(this.appId);a.startAuthFlow(e);try{ke.current="login",_e.current="guest";let{user:e,isNewUser:t}=await a.authenticate();if(t=t||!1,!e)throw new E("Unable to authenticate guest account");let n=await uw(),r=await at.initializeWalletProxy(Rr);if(n&&r)try{let t=qt(e,ae.embeddedWallets.ethereum.createOnLogin),a=jt(e,ae.embeddedWallets.solana.createOnLogin);if(t&&a){let t=await Ve(e,Rr);await r.createSolana({accessToken:n,ethereumAddress:t?.address}),e=await at.refreshSessionAndUser()}else a?(await r.createSolana({accessToken:n,ethereumAddress:xr(e)?.address}),e=await at.refreshSessionAndUser()):t?(await Ve(e,Rr),e=await at.refreshSessionAndUser()):w(e)}catch(t){w(e),console.warn("Unable to create embedded wallet for guest account")}return W(t),g(!0),xa(Te,"login","onComplete",{user:e,isNewUser:t,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),e}catch(e){throw xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),e}},async crossAppAuthFlow({appId:e,popup:t,action:n}){let r=`privy:${e}`;_e.current=r;let{url:i,stateCode:o,codeVerifier:s}=await async function({api:e,appId:t}){let n=Fo(),r=Bo(),a=await zo(n);try{let{url:i}=await e.post(Y,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:r});return{url:i,stateCode:r,codeVerifier:n}}catch(e){throw T(e)}}({api:a.api,appId:e});if(!i)throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new E("No authorization URL returned for cross-app auth.");try{let l=await async function({url:e,popup:t}){return t.location=e,new Promise(((e,n)=>{let r,a=setTimeout((()=>{n(new E("Authorization request timed out after 2 minutes.")),i()}),12e4);function i(){t?.close(),window.removeEventListener("message",s)}let o=setInterval((()=>{t?.closed&&!r&&(i(),clearInterval(o),clearTimeout(a),n(new E("User rejected request")))}),300);function s(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(a),e(t.data),i()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(a),n(new E(t.data.error)),i()),t.data.type===Yf&&((r=new BroadcastChannel(Kf)).onmessage=s))}window.addEventListener("message",s)}))}({url:i,popup:t,provider:r}),c=l.stateCode,d=l.authorizationCode;if(c!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:r,storedStateCode:o??"",returnedStateCode:c??""}}),new E("Unexpected auth flow. This may be a phishing attempt.",void 0,b.OAUTH_UNEXPECTED);let h=await async function({appId:e,stateCode:t,codeVerifier:n,authorizationCode:r,action:a,client:i}){if(!r||!t)throw new E("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===r)throw new E("User denied confirmation during cross-app auth flow");try{let o=new Zf({authorizationCode:r,stateCode:t,codeVerifier:n,provider:`privy:${e}`});i.startAuthFlow(o);let s="link"===a?await i.link():await i.authenticate(),l=s.oAuthTokens?.accessToken;return console.debug(),l}catch(e){let t=T(e);if(t.privyErrorCode)throw new E(t.message||"Invalid code during cross-app auth flow.",void 0,t.privyErrorCode);if("User denied confirmation during cross-app auth flow"===t.message)throw new E("Invalid code during cross-app auth flow.",void 0,b.OAUTH_USER_DENIED);throw new E("Invalid code during cross-app auth flow.",void 0,b.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:s,stateCode:c,authorizationCode:d,action:n,client:a});h&&a.storeProviderAccessToken(e,h);let u=await at.refreshSessionAndUser();if(!u)throw new E("Unable to update user");return a.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),u}catch(e){throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:r}}),e}},async initLoginWithOAuth(e,t,n){if(_e.current=e,!ca())return void Se(br.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE);if("google"===e&&Ac(window.navigator.userAgent))return void Se(br.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE);"twitter"===e&&window.opener&&window.opener.postMessage({type:Yf},"*"),da.del(Qn),da.del(Jn);let r=new Ho({provider:e,disableSignup:!!n,withPrivyUi:!0});t&&r.addCaptchaToken(t),a.startAuthFlow(r);let i=await a.authFlow.getAuthorizationUrl();i&&i.url&&("twitter"===e&&v&&(i.url=i.url.replace("x.com","twitter.com")),window.location.assign(i.url))},async initLoginWithTelegram(e,t){if(!p)throw new P;_e.current="telegram";let n=new ss(e,t);a.startAuthFlow(n),te({status:"loading"}),n.meta.telegramWebAppData=void 0,n.meta.telegramAuthResult=await new Promise(((e,t)=>ae.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:ae.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(n=>n?e(n):t(new E("Telegram auth failed or was canceled by the client")))):t(new E("Telegram was not initialized")):t(new E("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,n;if(!(a.authFlow instanceof ss))throw new E("Must initialize Telegram flow before calling loginWithTelegram");a.authFlow.meta.captchaToken||=e?.captchaToken;let r=await uw(),i=e?.intent||ke.current;if("login"===i)try{let e=await a.authenticate();t=e.user,n=e.isNewUser,_e.current="telegram"}catch(e){throw xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),e}else{if("link"!==i)throw new E("Unknown auth intent");try{t=(await a.link()).user,_e.current="telegram"}catch(e){throw xa(Te,"linkAccount","onError",e.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}w(t),W(n||!1),g(!0),te({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:o}},async recoveryOAuthFlow(e,t,n){let r,i;function o(t){if(!t)throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:e}}),new E("Recovery OAuth failed")}switch(e){case"google-drive":{let t,s,{url:l,codeVerifier:c,stateCode:d}=await id({api:rw.api,provider:e});o(l);try{let r=await nw({url:l,popup:n,provider:e});if(t=r.stateCode,s=r.authorizationCode,t!==d)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:d??"",returnedStateCode:t??""}}),new E("Unexpected auth flow. This may be a phishing attempt.",void 0,b.OAUTH_UNEXPECTED)}catch(t){throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:e}}),new E("Recovery OAuth failed")}[r,i]=await Promise.all([uw(),od({api:rw.api,provider:e,codeVerifier:c,stateCode:t,authorizationCode:s})]);break}case"icloud":{let{url:t}=await id({api:rw.api,provider:e});o(t);let{ckWebAuthToken:a}=await nw({url:t,popup:n,provider:e});i=a,r=await uw()}}if(!ne)throw new E("Cannot connect to wallet proxy");if(!r)throw new E("Unable to authorize user");switch(t){case"recover":{let t=le.recoverWallet?.entropyId,n=le.recoverWallet?.entropyIdVerifier;if(!t||!n)throw new E("Recovery OAuth failed");a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t,recoveryMethod:e}}),await ne.recover({accessToken:r,entropyId:t,entropyIdVerifier:n,recoveryAccessToken:i}),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t,recoveryMethod:e}});break}case"create-wallet":{a.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await ne.create({accessToken:r,recoveryAccessToken:i,recoveryMethod:e});let t=xr(await at.refreshSessionAndUser());if(!t)throw xa(Te,"createWallet","onError",b.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.address}}),xa(Te,"createWallet","onSuccess",{wallet:t});break}case"set-recovery":{let t=Or(f);if(!t)throw xa(Te,"setWalletRecovery","onError",b.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}});let{entropyId:n,entropyIdVerifier:o}=ar(t);await ne.setRecovery({accessToken:r,entropyId:n,entropyIdVerifier:o,recoveryMethod:e,recoveryAccessToken:i});let s=Or(await at.refreshSessionAndUser());if(!s)throw xa(Te,"createWallet","onError",b.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}}),xa(Te,"setWalletRecovery","onSuccess",{method:e,wallet:s});break}default:throw new E("Unsupported recovery action")}},async loginWithOAuth(e){let t,n,r;if(!(a.authFlow instanceof Ho))throw new E("Must initialize OAuth flow before calling loginWithOAuth");let i=da.get(er),o=a.authFlow.meta.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:i??"",returnedStateCode:o??""}}),new E("Unexpected auth flow. This may be a phishing attempt.",void 0,b.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{let n=await a.link();t=n.user,r=n.oAuthTokens,_e.current=e}catch(t){throw xa(Te,"linkAccount","onError",t.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let i=await a.authenticate();t=i.user,n=i.isNewUser,r=i.oAuthTokens,_e.current=e}catch(t){throw"login"===ke.current?xa(Te,"login","onError",t.privyErrorCode||b.UNKNOWN_AUTH_ERROR):"link"===ke.current&&xa(Te,"linkAccount","onError",t.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return w(t),W(n||!1),g(!0),r&&t&&xa(Te,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),r},passkeyAuthState:V,setPasskeyAuthState:$,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new as({captchaToken:e,setPasskeyAuthState:$});a.startAuthFlow(n),ke.current="login";try{_e.current="passkey",$({status:"generating-challenge"}),await n.initRegisterFlow(t),$({status:"awaiting-passkey"})}catch(e){throw $({status:"error",error:e}),xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!p)throw new P;if(!(a.authFlow instanceof as))throw new E("Must initialize Passkey flow first.");if("passkey"!==_e.current){let e=new E("Must init login with Passkey flow first.");throw $({status:"error",error:e}),e}let n=await uw();try{_e.current="passkey",$({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await a.authenticate())}catch(e){throw $({status:"error",error:e}),xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),e}w(e),W(t||!1),g(!0),$({status:"done"});let r=e?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:e,isNewUser:t||!1,wasAlreadyAuthenticated:!!n,loginAccount:r}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new as({captchaToken:e,setPasskeyAuthState:$});a.startAuthFlow(n),ke.current="login";try{_e.current="passkey",$({status:"generating-challenge"}),await n.initAuthenticationFlow(t),$({status:"awaiting-passkey"})}catch(e){throw $({status:"error",error:e}),xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,n;if(!p)throw new P;if(!(a.authFlow instanceof as))throw new E("Must initialize Passkey flow first.");if(e?.credentialIds&&(a.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==_e.current){let e=new E("Must init login with Passkey flow first.");throw $({status:"error",error:e}),e}let r=await uw();try{_e.current="passkey",$({status:"awaiting-passkey"}),({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw $({status:"error",error:e}),xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),e}w(t),W(n||!1),g(!0),$({status:"done"});let i=t?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:i}},async initLinkWithPasskey(e){let t=new as({captchaToken:e});a.startAuthFlow(t),ke.current="link",_e.current="passkey",$({status:"generating-challenge"});try{await t.initLinkFlow(),$({status:"awaiting-passkey"})}catch(e){throw xa(Te,"linkAccount","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),$({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!p)throw new P;if(!(a.authFlow instanceof as))throw new E("Must initialize Passkey flow first.");if("passkey"!==_e.current)throw new E("Must init login with Passkey flow first.");try{_e.current="passkey",({user:e}=await a.link())}catch(e){throw xa(Te,"linkAccount","onError",e.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return w(e||f||null),$({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,n){if(!ca())throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");if("google"===e&&Ac(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let r=new Ho({provider:e,withPrivyUi:!1,disableSignup:n??!1});t&&r.addCaptchaToken(t),J({status:"loading"});let i=await a.startAuthFlow(r).getAuthorizationUrl();i?.url&&window.location.assign(i.url)},async loginWithHeadlessOAuth(e){let t,n,r;B(!0),J({status:"loading"}),a.startAuthFlow(new Ho(e));let i=da.get(er),o=e.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:i??"",returnedStateCode:o??""}}),B(!1),new E("Unexpected auth flow. This may be a phishing attempt.",void 0,b.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{({user:t,oAuthTokens:r}=await a.link()),_e.current=e.provider;let n=Xe(t);t&&n&&xa(Te,"linkAccount","onSuccess",{user:t,linkMethod:_e.current,linkedAccount:n})}catch(t){throw B(!1),xa(Te,"linkAccount","onError",t.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:n,oAuthTokens:r}=await a.authenticate()),_e.current=e.provider;let i=Xe(t);t&&i&&void 0!==n&&xa(Te,"login","onComplete",{user:t,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:_e.current,loginAccount:i})}catch(e){throw B(!1),J({status:"error",error:e}),xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),e}return w(t),W(n||!1),g(!0),B(!1),J({status:"done"}),r&&t&&xa(Te,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{let i=new Lo({email:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{_e.current="email",q({status:"sending-code"}),await i.sendCodeEmail({withPrivyUi:r}),q({status:"awaiting-code-input"})}catch(e){throw q({status:"error",error:e}),"login"===ke.current?xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR):"link"===ke.current&&xa(Te,"linkAccount","onError",e.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,n)=>{let r=new Po(e,t,n);a.startAuthFlow(r);try{await r.sendCodeEmail({withPrivyUi:!0})}catch(e){xa(Te,"update","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR,{linkMethod:_e.current})}},initUpdatePhone:async(e,t,n)=>{let r=new os(e,t,n);a.startAuthFlow(r);try{await r.sendSmsCode({withPrivyUi:!0})}catch(e){xa(Te,"update","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR,{linkMethod:_e.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{K({status:"sending-code"});let i=new is({phoneNumber:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{_e.current="sms",await i.sendSmsCode({withPrivyUi:r}),K({status:"awaiting-code-input"})}catch(e){throw K({status:"error",error:e}),"login"===ke.current?xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR):"link"===ke.current&&xa(Te,"linkAccount","onError",e.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await(a.authFlow?.sendCodeEmail({withPrivyUi:!0}))},resendSmsCode:async()=>{await(a.authFlow?.sendSmsCode({withPrivyUi:!0}))},loginWithCode:async e=>{let t,n;function r(e){a.authFlow instanceof Lo?q(e):a.authFlow instanceof is&&K(e)}if(r({status:"submitting-code"}),!p){let e=new P;throw r({status:"error",error:e}),e}if(a.authFlow instanceof Lo)a.authFlow.meta.emailCode=e.trim();else{if(!(a.authFlow instanceof is)){let e=new E("Must initialize a passwordless code flow first");throw r({status:"error",error:e}),e}a.authFlow.meta.smsCode=e.trim()}let i=await uw();if("link"===ke.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),xa(Te,"linkAccount","onError",e.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:_e.current}),e}else if("update"===ke.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),xa(Te,"update","onError",e.privyErrorCode||b.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:_e.current}),e}else try{({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw r({status:"error",error:e}),xa(Te,"login","onError",e.privyErrorCode||b.UNKNOWN_AUTH_ERROR),e}let o=t||f;w(o||null),W(n||!1),g(!0),r({status:"done"});let s=null;return a.authFlow instanceof Lo?s=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:a.authFlow instanceof is&&(s=o?.linkedAccounts.find((({type:e})=>"phone"===e))||null),{user:o,isNewUser:n||!1,wasAlreadyAuthenticated:!!i,linkedAccount:s}},generateSiweMessage:async({address:e,chainId:t,captchaToken:n})=>{ke.current="link",_e.current="siwe",X({status:"generating-message"});let r=await a.generateSiweNonce({address:e,captchaToken:n});return X({status:"awaiting-signature"}),Vn({address:e,chainId:t.replace("eip155:",""),nonce:r})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let n=await a.generateSiweNonce({address:e});return Vn({address:e,chainId:t.replace("eip155:",""),nonce:n})},linkSmartWallet:async({message:e,signature:t,smartWalletType:n})=>{let r;r=await a.linkSmartWallet({message:e,signature:t,smartWalletType:n}),w((r=await at.refreshSessionAndUser()??r)||f||null)},linkWithSiwe:async({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i})=>{let o;Fe("siwe");let s=null;try{X({status:"submitting-signature"}),o=await a.linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i}),o=await at.refreshSessionAndUser()??o,X({status:"done"}),(s=Xe(o)||null)&&xa(Te,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:s})}catch(e){throw xa(Te,"linkAccount","onError",e.privyErrorCode||b.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),ke.current=null,_e.current=null,X({status:"error",error:e}),e}let l=o||f;return w(l||null),ke.current=null,_e.current=null,{user:l,linkedAccount:s}},refreshSessionAndUser:async()=>{let e=await a.getAuthenticatedUser();return g(!!e),w(e),e},walletProxy:ne,createAnalyticsEvent:({eventName:e,payload:t,timestamp:n})=>a.createAnalyticsEvent({eventName:e,payload:t,timestamp:n}),acceptTerms:async()=>{let e=await a.acceptTerms();return w(e),e},getUsdTokenPrice:e=>a.getUsdTokenPrice(e),getUsdPriceForSol:()=>a.getUsdPriceForSol(),getSplTokenMetadata:e=>a.getSplTokenMetadata(e),recoverPrimaryWallet:async e=>new Promise((async(t,n)=>{let r=Or(e?.user??f)||na(e?.user??f)||Zr(e?.user??f);r||t(!0);let i=await uw();if(!i||!ne||!r)return void n(Error("Must have valid access token and Privy wallet to recover wallet"));se(!0);let{entropyId:o,entropyIdVerifier:s}=ar(r);try{await ne.connect({accessToken:i,entropyId:o,entropyIdVerifier:s}),t(!0)}catch(e){Yc(e)&&"privy"===r.recoveryMethod?(a.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:r.address}}),(await ne.recover({entropyId:o,entropyIdVerifier:s,accessToken:i})).entropyId||n(Error("Unable to recover wallet")),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:r.address}}),t(!0)):Yc(e)&&"privy"!==r.recoveryMethod?(ce({recoverWallet:{entropyId:o,entropyIdVerifier:s,onFailure:n,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:r.recoveryMethod,action:"recover"}}),xe(rd(r.recoveryMethod))):n(e)}})),embeddedSolanaWallets:x,createEmbeddedSolanaWallet:async e=>{e&&"target"in e&&(e=void 0);let t=await at.refreshSessionAndUser();if(!t)throw xa(Te,"createWallet","onError",b.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return(async(e,t,n)=>{let r=xr(e),a=Sr(e),i=n&&"createAdditional"in n&&n.createAdditional,o=n&&"walletIndex"in n?n.walletIndex:void 0,s=(sa(e)?.walletIndex??-1)+1;if(a&&!i&&"number"!=typeof o)throw xa(Te,"createWallet","onError",b.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");if("number"==typeof o&&o<0)throw xa(Te,"createWallet","onError",b.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${o}) is invalid.`);let[l,c]=await Promise.all([at.initializeWalletProxy(t),uw()]);if(!l||!c)throw xa(Te,"createWallet","onError",b.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return await qe({user:e,wp:l,accessToken:c,walletIndex:o??s,ethereumWallet:r})})(t,15e3,e)},exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!y||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));let i=e?.address??Sr(f)?.address;if(!i)return void r(Error("User does not have an HD Solana wallet."));let{signingWallet:o,rootWallet:s}=Xr(f,i);if(!o||!s)return void r(Error("Must have a Privy wallet before exporting"));if(se(!0),!await uw()||!ne)return void r(Error("Must have valid access token to enroll in MFA"));if(!ne)return void r(Error("Must have a Privy wallet before exporting"));let{entropyId:l,entropyIdVerifier:c}=ar(s);ce({connectWallet:{entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:br.EMBEDDED_WALLET_KEY_EXPORT_SCREEN,onFailure:r,shouldForceMFA:!0},keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:o,primaryWallet:s,onSuccess:t,onFailure:r}}),xe(br.EMBEDDED_WALLET_CONNECTING_SCREEN)})),setReadyToTrue:e=>{m(!0),de?.(e)},updateWallets:()=>He(),fundWallet:async(e,t)=>{let n=br.FUNDING_METHOD_SELECTION_SCREEN;ce({funding:Ra({address:e,appConfig:ae,fundWalletConfig:t,methodScreen:n})}),xe(n)},openModal:xe,requestFarcasterSignerStatus:async e=>{let t=await uw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!ne||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let r=await a.requestFarcasterSignerStatus(e);return"approved"===r.status&&w(await a.getAuthenticatedUser()||f||null),r},connectCoinbaseSmartWallet:async()=>{ae.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let e=a.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||a.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Pe(e);await Le("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:i,telegramWebAppData:o,farcasterEmbeddedAddress:s,oAuthUserInfo:l})=>{let c=await a.sendAccountTransferRequest({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:i,telegramWebAppData:o,farcasterEmbeddedAddress:s,oAuthUserInfo:l});return w(c),c}};lw=at.recoverPrimaryWallet,cw=at.recoverPrimaryWallet,dw=at.solanaSignMessage;let it=i((()=>({wallets:_,ready:me&&be})),[_,me,be]),ot=a.authFlow instanceof ss,st=!ae.headless&&ae.captchaEnabled&&!y&&(p||ot);/*#__PURE__*/return t(jr.Provider,{value:rt,children:/*#__PURE__*/t(Oa.Provider,{value:Te,children:/*#__PURE__*/t(ia.Provider,{value:it,children:/*#__PURE__*/t($n,{...ae,children:/*#__PURE__*/e(M.Provider,{value:at,children:[/*#__PURE__*/t(Gn,{children:/*#__PURE__*/e(oa,{data:le,setModalData:ce,setInitialScreen:D,initialScreen:U,authenticated:y,open:h,children:[n.children,st&&/*#__PURE__*/t(tl,{delayedExecution:!1}),/*#__PURE__*/t(Cf,{theme:{...ae.appearance.palette||{}}}),!ae.render.standalone&&/*#__PURE__*/t(Of,{open:h})]})}),oe&&ie?/*#__PURE__*/t(Gf,{appId:n.appId,appClientId:n.clientId,clientAnalyticsId:a.clientAnalyticsId,origin:a.apiUrl,mfaMethods:f?.mfaMethods,mfaPromise:Ce,mfaSubmitPromise:Ee,onLoad:re,onLoadFailed:()=>null}):null,ae.loginConfig.telegramAuthConfiguration&&
22
- /*#__PURE__*/t(pl,{$if:!0,children:/*#__PURE__*/t(Pf,{scriptHost:n.apiUrl||vr,botUsername:ae.loginConfig.telegramAuthConfiguration.botName})})]})})})})})};const Tw=()=>{let{getAccessToken:e,user:t}=_r(),{refreshSessionAndUser:n,initializeWalletProxy:r}=N(),a=_a();return{importWallet:c((({privateKey:i})=>Ro({getAccessToken:e,user:t,initializeWalletProxy:r,refreshSessionAndUser:n,emitPrivyEvent:a},{privateKey:i,chainType:"ethereum"})),[t,e,n,r,a])}},bw=()=>{let{importWallet:e}=Tw();return{...u(jr),importWallet:e}},Aw=e=>{ya("login",e);let t=gt(),n=Jr(),{ready:r,user:a}=_r(),{initLoginWithHeadlessOAuth:i,loginWithHeadlessOAuth:s,oAuthState:l,setOAuthState:d,isHeadlessOAuthLoading:h}=N(),u=c((async e=>{try{if(t.enabled&&"success"!==t.status)throw new Ke(t.error,null,b.CAPTCHA_FAILURE);return await i(e.provider,t.token,e.disableSignup)}catch(e){throw d({status:"error",error:e}),e}}),[i,t]),p=c((async()=>{let e=ns();try{if(a)return console.warn("Cannot login with OAuth when already logged in"),a;if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(e.popupFlow)return}catch(e){throw d({status:"error",error:e}),e}try{return await s(e)}catch(e){throw d({status:"error",error:e}),e}finally{rs()}}),[s]);return o((()=>{let e=ns();r&&n&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&p().catch((()=>{}))}),[r,n]),{initOAuth:u,loading:h,state:l}},_w=e=>{let t=gt(),{emailOtpState:n,setEmailOtpState:r,initLoginWithEmail:a,loginWithCode:i}=N();return{sendCode:c((async({email:n,disableSignup:i})=>{try{let e;if(!n)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new Ke(t.error,null,b.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({email:n,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||b.UNKNOWN_AUTH_ERROR),n}}),[a]),loginWithCode:c((async({code:n})=>{try{if(t.enabled&&"error"===t.status)throw new Ke(t.error,null,b.CAPTCHA_FAILURE);let{user:r,isNewUser:a,wasAlreadyAuthenticated:o,linkedAccount:s}=await i(n);e?.onComplete?.({user:r,isNewUser:a,wasAlreadyAuthenticated:o,loginMethod:"email",loginAccount:s})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||b.UNKNOWN_AUTH_ERROR),n}}),[i,t.status]),state:n}},kw=e=>{let t=gt(),{initSignupWithPasskey:n,signupWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:i}=N();return{signupWithPasskey:c((async()=>{try{let a;if(t.enabled&&"error"===t.status)throw new Ke(t.error,null,b.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult()),await n({captchaToken:a,withPrivyUi:!1});let{user:i,isNewUser:o,wasAlreadyAuthenticated:s,loginAccount:l}=await r();e?.onComplete?.({user:i,isNewUser:o,wasAlreadyAuthenticated:s,loginMethod:"passkey",loginAccount:l})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||b.UNKNOWN_AUTH_ERROR),t}}),[r,t.status]),state:a}},Iw=e=>{let t=gt(),{initLoginWithPasskey:n,loginWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:i}=N();return{loginWithPasskey:c((async a=>{try{let i;if(t.enabled&&"error"===t.status)throw new Ke(t.error,null,b.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await n({captchaToken:i,withPrivyUi:!1});let{user:o,isNewUser:s,wasAlreadyAuthenticated:l,loginAccount:c}=await r(a);e?.onComplete?.({user:o,isNewUser:s,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(a){throw i({status:"error",error:a}),e?.onError?.(a.privyErrorCode||b.UNKNOWN_AUTH_ERROR),a}}),[r,t.status]),state:a}},Nw=e=>{let{initLinkWithPasskey:t,linkWithPasskey:n,passkeyAuthState:r,setPasskeyAuthState:a}=N();return{linkWithPasskey:c((async()=>{try{await t();let r=await n();if(!r)throw Error("Error, user not found");let a=r.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:r,linkMethod:"passkey",linkedAccount:a})}catch(t){throw a({status:"error",error:t}),e?.onError?.(t.privyErrorCode||b.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[n]),state:r}},xw=e=>{let t=gt(),{smsOtpState:n,setSmsOtpState:r,initLoginWithSms:a,loginWithCode:i}=N();return{sendCode:c((async({phoneNumber:n,disableSignup:i})=>{try{let e;if(!n)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new Ke(t.error,null,b.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({phoneNumber:n,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||b.UNKNOWN_AUTH_ERROR),n}}),[a]),loginWithCode:c((async({code:n})=>{try{if(t.enabled&&"success"!==t.status)throw new Ke(t.error,null,b.CAPTCHA_FAILURE);let{user:r,isNewUser:a,wasAlreadyAuthenticated:o,linkedAccount:s}=await i(n);e?.onComplete?.({user:r,isNewUser:a,wasAlreadyAuthenticated:o,loginMethod:"sms",loginAccount:s})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||b.UNKNOWN_AUTH_ERROR),n}}),[i,t.status]),state:n}},Sw=e=>{let t=gt(),{siweState:n,setSiweState:r,linkWithSiwe:a,generateSiweMessage:i}=N();return{generateSiweMessage:c((async({address:t,chainId:n})=>{try{if(!t||!n)throw Error("wallet address and chainId required to generate nonce");return await i({address:t,chainId:n}).then((e=>e))}catch(t){throw r({status:"error",error:t}),e?.onError?.(t.privyErrorCode||b.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[i]),linkWithSiwe:c((async({signature:n,message:i,chainId:o,walletClientType:s,connectorType:l})=>{try{if(t.enabled&&"success"!==t.status)throw new Ke(t.error,null,b.CAPTCHA_FAILURE);let{user:r,linkedAccount:c}=await a({message:i,signature:n,chainId:o,walletClientType:s,connectorType:l});c&&e?.onSuccess?.({user:r,linkMethod:"siwe",linkedAccount:c})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||b.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),n}}),[a,t.status]),state:n}};function Rw(){let{signTransaction:e}=u(jr);return{signTransaction:e}}function Ow(e){let{linkEmail:t,linkPhone:n,linkWallet:r,linkGoogle:a,linkApple:i,linkTwitter:o,linkDiscord:s,linkGithub:l,linkLinkedIn:c,linkTiktok:d,linkSpotify:h,linkInstagram:p,linkTelegram:m,linkFarcaster:y}=u(jr);return ya("linkAccount",e),{linkEmail:t,linkPhone:n,linkWallet:r,linkGoogle:a,linkApple:i,linkTwitter:o,linkDiscord:s,linkGithub:l,linkLinkedIn:c,linkTiktok:d,linkSpotify:h,linkInstagram:p,linkFarcaster:y,linkTelegram:m}}function Ww(e){let{updateEmail:t,updatePhone:n}=u(jr);return ya("update",e),{updateEmail:t,updatePhone:n}}function Lw(e){let{createWallet:t}=u(jr);return ya("createWallet",e),{createWallet:t}}const Pw=()=>{let{connectCoinbaseSmartWallet:e}=N();return{connectCoinbaseSmartWallet:e}},Mw=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:n,signTypedDataWithCrossAppWallet:r,sendTransactionWithCrossAppWallet:a}=_r();return{loginWithCrossAppAccount:({appId:t})=>e({appId:t,action:"login"}),linkCrossAppAccount:({appId:t})=>e({appId:t,action:"link"}),unlinkCrossAppAccount:t,signMessage:n,signTypedData:r,sendTransaction:a}};function Uw(e){let{sendTransaction:t}=u(jr);return ya("sendTransaction",e),{sendTransaction:t}}function Dw(e){let{setWalletPassword:t}=u(jr);return ya("setWalletPassword",e),{setWalletPassword:t}}function Fw(){let{createGuestAccount:e}=u(jr);return{createGuestAccount:e}}function Bw(e){let{setWalletRecovery:t}=u(jr);return ya("setWalletRecovery",e),{setWalletRecovery:t}}function zw(e){let{signMessage:t}=u(jr);return ya("signMessage",e),{signMessage:t}}function Hw(e){let{signTypedData:t}=u(jr);return ya("signTypedData",e),{signTypedData:t}}const Vw=()=>{let{isModalOpen:e}=u(jr);return{isOpen:e}};function $w(e){let{getAccessToken:t}=u(jr);return ya("accessToken",e),{getAccessToken:t}}function Gw(e){let{authenticated:t,user:n}=_r(),{initLoginWithOAuth:r}=N(),a=_a();return ya("oAuthAuthorization",e),{reauthorize:e=>qw(t,n,r,a,e.provider)}}let qw=async(e,t,n,r,a)=>{if(!e)throw r("linkAccount","onError",b.MUST_BE_AUTHENTICATED,{linkMethod:a}),new E("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(a))))throw new E(`OAuth account of type ${a} not linked to the account.`);await n(a)};const jw=e=>{let{customAuthStatus:t}=N();return ya("customAuth",e),{status:t}};function Kw(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:n}=_r();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:n}}const Yw=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=N();return{delegateWallet:async({address:e,chainType:n})=>await t({address:e,chainType:n,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Zw=()=>{let{setUser:e,client:t}=u(M),{user:n}=u(jr);return{user:n,refreshUser:c((async()=>{let n=await(t?.updateUserAndIdToken());return e(n??null),n}),[t,e])}},Xw=e=>{let t=gt(),{initLoginWithTelegram:n,loginWithTelegram:r,telegramAuthState:a,setTelegramAuthState:i}=N();return{login:c((async a=>{try{if(t.enabled&&"success"!==t.status)throw new Ke(t.error,null,b.CAPTCHA_FAILURE);await n(t.token,a?.disableSignup);let{user:i,isNewUser:o,loginAccount:s,wasAlreadyAuthenticated:l}=await r({intent:"login"});e?.onComplete?.({user:i,isNewUser:o,wasAlreadyAuthenticated:l,loginMethod:"telegram",loginAccount:s})}catch(a){throw i({status:"error",error:a}),e?.onError?.(a.privyErrorCode||b.UNKNOWN_AUTH_ERROR),a}}),[n,r,t]),state:a}},Qw=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=N();return{delegateWallet:async({address:e,chainType:n})=>await t({address:e,chainType:n,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{tl as Captcha,Ds as ConnectorManager,Ye as EthereumWalletConnector,Of as LoginModal,Js as PrivyClient,Cw as PrivyProvider,or as VERSION,Qc as errorIndicatesMaxMfaRetries,Zc as errorIndicatesMfaTimeout,Xc as errorIndicatesMfaVerificationFailed,hw as getAccessToken,Pw as useConnectCoinbaseSmartWallet,Lw as useCreateWallet,Mw as useCrossAppAccounts,jw as useCustomAuth,Yw as useDelegatedActions,Kw as useFarcasterSigner,Fw as useGuestAccounts,Qw as useHeadlessDelegatedActions,qs as useIdentityToken,Tw as useImportWallet,Ow as useLinkAccount,Nw as useLinkWithPasskey,Sw as useLinkWithSiwe,_w as useLoginWithEmail,Aw as useLoginWithOAuth,Iw as useLoginWithPasskey,xw as useLoginWithSms,Xw as useLoginWithTelegram,Ut as useLogout,hm as useMfa,um as useMfaEnrollment,Vw as useModalStatus,Gw as useOAuthTokens,bw as usePrivy,nl as useRegisterMfaListener,Uw as useSendTransaction,Dw as useSetWalletPassword,Bw as useSetWalletRecovery,zw as useSignMessage,Rw as useSignTransaction,Hw as useSignTypedData,kw as useSignupWithPasskey,Ca as useSolanaWallets,$w as useToken,Ww as useUpdateAccount,Zw as useUser,Mr as useWallets};
4
+ /*#__PURE__*/t("span",{})]})})});let uc=/*#__PURE__*/Ka.div.withConfig({displayName:"StackedContainer",componentId:"sc-26c1d9b9-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]);let pc=/*#__PURE__*/Ka.div.withConfig({displayName:"CaptchaContainer",componentId:"sc-9afcf974-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const mc=({chainType:n,withPadding:r})=>{let a="";return a="ethereum-only"===n||"ethereum-and-solana"===n?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/t(ol,{$withPadding:r,children:/*#__PURE__*/e(sl,{children:[/*#__PURE__*/t(Ja,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/t("h3",{children:"No wallets available"}),/*#__PURE__*/e("p",{children:["Please download an external wallet provider, like ",a,"."]})]})},"empty-wallet-state")},yc=({icon:e,name:n})=>"string"==typeof e?/*#__PURE__*/t("img",{alt:`${n||"wallet"} logo`,src:e,style:{height:24,width:24,borderRadius:4}}):void 0===e?/*#__PURE__*/t(Xa,{}):e?/*#__PURE__*/t(e,{}):null;function gc(e){let t=e.toLowerCase();return!!window?.webkit?.messageHandlers?.ReactNativeWebView||!!window?.ReactNativeWebView||["fbav","fban","instagram","snapchat","linkedinapp"].some((e=>t.includes(e)))}const fc=({provider:n,displayName:r,logo:a,connectOnly:i,connector:o})=>{let s,{navigate:l,setModalData:c}=hr(),{connectWallet:d}=x(),h=wt(),u=vt(n),p="wallet_connect_v2"===o.connectorType?n:o.walletClientType,m=window.matchMedia("(display-mode: standalone)").matches,g=Is({connectorType:o.connectorType,walletClientType:p});s=g&&g.chainTypes.includes(o.chainType)?()=>{g.isInstalled||"solana"===o.chainType&&"isInstalled"in o&&o.isInstalled?(d(o,p),l(i?ur.AWAITING_CONNECT_ONLY_CONNECTION:ur.AWAITING_CONNECTION)):y?(c({installWalletModalData:{walletConfig:g,chainType:o.chainType,connectOnly:i}}),l(ur.WALLET_INTERSTITIAL_SCREEN)):(c({installWalletModalData:{walletConfig:g,chainType:o.chainType,connectOnly:i}}),l(ur.INSTALL_WALLET_SCREEN))}:"coinbase_wallet"!==o.connectorType||"eoaOnly"!==o.connectionOptions||!y||m||Ct()?()=>{(!gc(window.navigator.userAgent)||event?.isTrusted)&&(d(o,p),l(i?ur.AWAITING_CONNECT_ONLY_CONNECTION:ur.AWAITING_CONNECTION))}:()=>{window.location.href=`https://go.cb-w.com/dapp?cb_url=${encodeURI(window.location.href)}`};let f=r||u?.metadata?.shortName||u?.name||o.walletClientType;/*#__PURE__*/return e(wc,{onClick:s,children:[/*#__PURE__*/t(yc,{icon:a||u?.image_url?.md,name:f}),/*#__PURE__*/t("span",{children:f}),/*#__PURE__*/e(Cc,{id:"chip-container",children:[h?.walletClientType===p&&h?.chainType===o.chainType?/*#__PURE__*/t(vc,{color:"gray",children:"Recent"}):/*#__PURE__*/t("span",{id:"connect-text",children:"Connect"}),"solana"===o.chainType&&/*#__PURE__*/t(vc,{color:"gray",children:"Solana"})]})]})};let wc=/*#__PURE__*/Ka(rl).withConfig({displayName:"ConnectWalletButton",componentId:"sc-c6a554d4-0"})(["> #chip-container > #connect-text{font-weight:500;color:var(--privy-color-accent);opacity:0;transition:opacity 0.1s ease-out;}:hover > #chip-container > #connect-text{opacity:1;}@media (max-width:440px){> #chip-container > #connect-text{display:none;}}"]),vc=/*#__PURE__*/Ka(Et).withConfig({displayName:"StyledChip",componentId:"sc-c6a554d4-1"})(["margin-left:auto;"]),Cc=/*#__PURE__*/Ka.div.withConfig({displayName:"ChipContainer",componentId:"sc-c6a554d4-2"})(["display:flex;flex-wrap:wrap;gap:8px;margin-left:auto;"]);const Ec=["coinbase_wallet"];let Tc=["metamask","okx_wallet","rainbow","uniswap","bybit_wallet","ronin_wallet","uniswap_extension","zerion","rabby_wallet","cryptocom"];const bc=["safe"],Ac=["phantom","backpack","solflare","universal_profile"],_c=({wallets:e})=>{let{app:r}=hr();return 0===e.length?/*#__PURE__*/t(mc,{chainType:r.appearance.walletChainType,withPadding:!0}):/*#__PURE__*/t(n,{children:e})},kc=({walletList:e,walletChainType:n,connectors:r,connectOnly:a,ignore:i,walletConnectEnabled:o,forceWallet:s})=>{let l=[],c=[],d=[],h=r.filter((e=>"ethereum-only"===n?"ethereum"===e.chainType:"solana-only"!==n||"solana"===e.chainType)),u=h.find((e=>"wallet_connect_v2"===e.connectorType));for(let[r,p]of(s?[s.wallet]:e).entries()){if("detected_ethereum_wallets"===p||"detected_wallets"===p)for(let[e,n]of h.filter((({chainType:e,connectorType:t,walletClientType:n})=>"solana"!==e&&("uniswap_wallet_extension"===n||"uniswap_extension"===n?!i.includes("uniswap"):"crypto.com_wallet_extension"===n||"crypto.com_onchain"===n?!i.includes("cryptocom"):"injected"===t&&!i.includes(n)))).entries()){let{walletClientType:i,walletBranding:o,chainType:s}=n;("unknown"===i?c:l).push(/*#__PURE__*/t(fc,{connectOnly:a,provider:i,logo:o.icon,displayName:o.name,connector:n},`${r}-${p}-${i}-${s}-${e}`))}if("detected_solana_wallets"===p||"detected_wallets"===p)for(let[e,o]of h.filter((({chainType:e,walletClientType:t})=>{if("solana"===e)return"ethereum-only"!==n&&!i.includes(t)})).entries()){let{walletClientType:n,walletBranding:i,chainType:s}=o;("unknown"===n?c:l).push(/*#__PURE__*/t(fc,{connectOnly:a,provider:n,logo:i.icon,displayName:i.name,connector:o},`${r}-${p}-${n}-${s}-${e}`))}if(Ac.includes(p)){let e=h.find((e=>"injected"===e.connectorType&&e.walletClientType===p||e.connectorType===p));if(e&&l.push(/*#__PURE__*/t(fc,{connectOnly:a,provider:p,connector:e},`${r}-${p}`)),"solana-only"===n||"ethereum-and-solana"===n){let e=h.find((({chainType:e,walletClientType:t})=>"solana"===e&&t===p));e&&l.push(/*#__PURE__*/t(fc,{connectOnly:a,provider:p,connector:e},`${p}-solana`))}}else if(Tc.includes(p)){let e=h.find((e=>"uniswap"===p?"uniswap_wallet_extension"===e.walletClientType||"uniswap_extension"===e.walletClientType:"cryptocom"===p?"crypto.com_wallet_extension"===e.walletClientType||"crypto.com_onchain"===e.walletClientType:"injected"===e.connectorType&&e.walletClientType===p));if(o&&!e&&(e=u),e&&l.push(/*#__PURE__*/t(fc,{connectOnly:a,provider:p,connector:e,logo:"injected"===e.connectorType?e.walletBranding.icon:void 0,displayName:"injected"===e.connectorType?e.walletBranding.name:void 0},`${r}-${p}`)),"solana-only"===n||"ethereum-and-solana"===n){let e=h.find((({chainType:e,walletClientType:t})=>"solana"===e&&t===p));e&&l.push(/*#__PURE__*/t(fc,{connectOnly:a,provider:p,connector:e},`${p}-solana`))}}else if(Ec.includes(p)){let e=h.find((({connectorType:e})=>e===p));e&&l.push(/*#__PURE__*/t(fc,{connectOnly:a,provider:p,connector:e},`${r}-${p}`))}else if(bc.includes(p))u&&d.push(/*#__PURE__*/t(fc,{connectOnly:a,provider:p,connector:u},`${r}-${p}`));else if("wallet_connect"===p)u&&d.push(/*#__PURE__*/t(fc,{connectOnly:a,provider:p,connector:u,logo:u.walletBranding.icon,displayName:"Wallet Connect"},`${r}-${p}`));else if(p===s?.wallet){let n="ethereum"===s.chainType&&e.includes("detected_ethereum_wallets"),i="solana"===s.chainType&&e.includes("detected_solana_wallets");if(e.includes("detected_wallets")||n||i){let e=h.find((({walletClientType:e})=>e===p));e&&l.push(/*#__PURE__*/t(fc,{connectOnly:a,provider:p,displayName:e.walletBranding?.name,logo:e.walletBranding?.icon,connector:e},`${r}-${p}`))}}}return[...c,...l,...d]};let Ic=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-4475d7d5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Nc=({name:e,logoUrl:n,size:r="38px"})=>"string"==typeof n?/*#__PURE__*/t("img",{src:n,alt:`${e??"Provider app"} logo`,style:{width:r,height:r,maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):
5
+ /*#__PURE__*/t("span",{});let xc=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-128f2a0d-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);let Sc=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-b99bc0c0-0"})(["display:flex;gap:10px;"]),Rc=/*#__PURE__*/Ka(St).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-b99bc0c0-1"})(["margin-top:1.5rem;"]);let Oc=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-8ff214d7-0"})(["display:flex;gap:10px;"]);const Wc=()=>/*#__PURE__*/t(Mc,{children:/*#__PURE__*/e(Pc,{children:[/*#__PURE__*/t(Lc,{}),/*#__PURE__*/t(Dc,{})]})});let Mc=/*#__PURE__*/Ka.div.withConfig({displayName:"LoadingContainer",componentId:"sc-85b54ede-0"})(["display:flex;justify-content:center;align-items:center;flex-grow:1;margin:12px;padding:16px;@media all and (display-mode:standalone){margin-bottom:30px;}"]),Pc=/*#__PURE__*/Ka.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-85b54ede-1"})(["position:relative;height:140px;width:140px;opacity:1;animation:fadein 200ms ease;"]),Lc=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleFixed",componentId:"sc-85b54ede-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;&&{border:4px solid var(--privy-color-accent-light);border-radius:50%;}"]),Dc=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleRotate",componentId:"sc-85b54ede-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:var(--privy-color-accent) transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]);const Uc=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];class Fc extends Error{constructor(e,t){super(t),this.type=e}}function Bc(e){let t=e.type;return"string"==typeof t&&Uc.includes(t)}function zc(e){return Bc(e)&&"wallet_not_on_device"===e.type}function Hc(e){return!!Bc(e)&&"mfa_timeout"===e.type}function Vc(e){return!!Bc(e)&&"missing_or_invalid_mfa"===e.type}function $c(e){return!!Bc(e)&&"mfa_verification_max_attempts_reached"===e.type}function jc(e){return!(!Bc(e)||!e.message.includes("code 429"))}function Gc(e){return!!function(e){let t=e.type;return"string"==typeof t&&"client_error"===t}(e)&&"MFA canceled"===e.message}function qc({isCreatingWallet:e,skipSplashScreen:t}){return e?ur.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN:t?ur.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN:ur.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN}function Kc({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:n,isResettingPassword:r,showAutomaticRecovery:a}){return a?ur.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN:n||1===t.length?qc({isCreatingWallet:"create"===e,skipSplashScreen:r}):ur.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN}function Yc(e){switch(e){case"user-passcode":return ur.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN;case"google-drive":case"icloud":return ur.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN;default:throw Error("Recovery method not supported")}}async function Zc({api:e,provider:t}){let n=No(),r=xo(),a=await So(n);try{return"icloud"===t?{url:(await e.post($e,{client_type:"web"})).url}:{url:(await e.post(je,{redirect_to:window.location.href,code_challenge:a,state_code:r})).url,codeVerifier:n,stateCode:r,provider:t}}catch(e){throw b(e)}}async function Jc({api:e,provider:t,stateCode:n,codeVerifier:r,authorizationCode:a}){if(!a||!n)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===a)throw new T("User denied confirmation during OAuth flow");try{return(await e.post(Ge,{authorization_code:a,state_code:n,code_verifier:r,provider:t})).access_token}catch(e){let t=b(e);if(t.privyErrorCode)throw new T(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new T("Invalid code during oauth flow.",void 0,A.OAUTH_USER_DENIED);throw new T("Invalid code during OAuth flow.",void 0,A.UNKNOWN_AUTH_ERROR)}}let Qc=/*#__PURE__*/Ka.div.withConfig({displayName:"BottomSpacing",componentId:"sc-124dbb1c-0"})(["height:44px;"]);const Xc=({children:n,theme:r})=>/*#__PURE__*/e(ed,{$theme:r,children:[/*#__PURE__*/t(Qa,{width:"1.25rem",color:"dark"===r?"#FDE68A":"var(--privy-color-warn)"}),n]});let ed=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-97f152b3-0"})(["display:flex;gap:0.5rem;background-color:",";"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);}"],(e=>"dark"===e.$theme?"var(--privy-color-background-2)":"var(--privy-color-warn-light)"),(e=>"dark"===e.$theme?"color: #FDE68A;":""));function td(n){let[r,a]=s(n.dimensions.width),[i,c]=s(void 0),d=l(null);o((()=>{if(d.current&&void 0===r){let{width:e}=d.current.getBoundingClientRect();a(e)}let e=getComputedStyle(document.documentElement);c({background:e.getPropertyValue("--privy-color-background"),background2:e.getPropertyValue("--privy-color-background-2"),foreground3:e.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:e.getPropertyValue("--privy-color-foreground-accent"),accent:e.getPropertyValue("--privy-color-accent"),accentDark:e.getPropertyValue("--privy-color-accent-dark"),success:e.getPropertyValue("--privy-color-success")})}),[]);let h="ethereum"===n.walletToExport.chainType&&!n.walletToExport.imported;/*#__PURE__*/return t("div",{ref:d,children:r&&
6
+ /*#__PURE__*/e(rd,{children:[/*#__PURE__*/t("iframe",{style:{position:"absolute",zIndex:1},width:r,height:n.dimensions.height,allow:"clipboard-write self *",src:Mt(n.origin,`/apps/${n.appId}/embedded-wallets/export`,{client_id:n.appClientId,primaryAddress:n.primaryWallet.address,address:n.walletToExport.address,walletIndex:n.walletToExport.walletIndex,width:`${r}px`,caid:n.clientAnalyticsId,phrase_export:h,...i},{token:n.accessToken})}),/*#__PURE__*/t(id,{children:"Loading..."}),h&&/*#__PURE__*/t(id,{children:"Loading..."})]})})}let nd=/*#__PURE__*/Ka.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-eaab13a9-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),rd=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonContainer",componentId:"sc-eaab13a9-1"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),id=/*#__PURE__*/Ka.div.withConfig({displayName:"LoadingButton",componentId:"sc-eaab13a9-2"})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:16px;font-weight:500;border-radius:var(--privy-border-radius-md);background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);"]);function od(){let{getAccessToken:e}=mr(),{refreshSessionAndUser:t,createAnalyticsEvent:n,initializeWalletProxy:r}=x(),a=l(!1);return{createWallet:c((async({user:i,recoveryPassword:o})=>{let s=await e();if(!s)throw n({eventName:"embedded_wallet_creation_failed",payload:{error:"Missing access token for user."}}),Error("An error has occured, please login again.");try{n({eventName:"embedded_wallet_creation_started"});let e=await r(Cr);if(!e)throw Error("walletProxy does not exist.");let l=new Promise(((e,t)=>{setTimeout((()=>{t(Error("walletProxy.create timed out."))}),2e4)})),c=vr(i);if(!await Promise.race([e.create({accessToken:s,recoveryPassword:o,recoveryMethod:o?"user-passcode":void 0,solanaAddress:c?.address}),l]))throw Error("walletProxy.create did not send a response.");let d=await t();if(!d)throw Error("Failed to refresh user.");let h=wr(d);if(!h)throw Error("Updated user is missing embedded wallet.");return n({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:h.address}}),a.current=!0,h}catch(i){if(a.current)return;throw n({eventName:"embedded_wallet_creation_failed",payload:{error:i.toString()}}),console.warn(i),i}}),[])}}let sd=/*#__PURE__*/Ka.div.withConfig({displayName:"BottomSpacing",componentId:"sc-f34e977e-0"})(["height:44px;"]),ld=/*#__PURE__*/Ya(["font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;text-align:left;transition:color 0.1s ease-in;"]);const cd=/*#__PURE__*/Ka.span.withConfig({displayName:"StatusText",componentId:"sc-3f6866a9-0"})([""," transition:color 0.1s ease-in;color:",";text-transform:",";&[aria-hidden='true']{visibility:hidden;}"],ld,(({error:e})=>e?"var(--privy-color-error)":"var(--privy-color-foreground-3)"),(({error:e})=>e?"":"capitalize")),dd=/*#__PURE__*/Ka.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-3f6866a9-1"})(["display:flex;flex-direction:column;justify-content:center;flex-grow:1;"]),hd=/*#__PURE__*/Ka(ct).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-3f6866a9-2"})(["",""],(e=>e.hideAnimations&&/*#__PURE__*/Ya(["&&{transition:none;}"])));let ud=/*#__PURE__*/Ya(["&&{width:100%;border-width:1px;border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);background:var(--privy-color-background);color:var(--privy-color-foreground);padding:12px;font-size:16px;font-style:normal;font-weight:300;line-height:22px;}"]);const pd=/*#__PURE__*/Ka.input.withConfig({displayName:"PasswordInput",componentId:"sc-3f6866a9-3"})([""," &::placeholder{color:var(--privy-color-foreground-3);font-style:italic;font-size:14px;}overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"],ud),md=/*#__PURE__*/Ka.div.withConfig({displayName:"PasswordDisplay",componentId:"sc-3f6866a9-4"})(["",""],ud),yd=/*#__PURE__*/Ka.div.withConfig({displayName:"PasswordContainer",componentId:"sc-3f6866a9-5"})(["position:relative;width:100%;display:flex;align-items:center;justify-content:",";"],(({centered:e})=>e?"center":"space-between")),gd=/*#__PURE__*/Ka.div.withConfig({displayName:"Header",componentId:"sc-3f6866a9-6"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:32px 0;gap:4px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]),fd=/*#__PURE__*/Ka.div.withConfig({displayName:"Details",componentId:"sc-3f6866a9-7"})(["display:flex;flex-direction:column;gap:10px;padding-bottom:1rem;"]),wd=/*#__PURE__*/Ka.div.withConfig({displayName:"DetailItem",componentId:"sc-3f6866a9-8"})(["display:flex;text-align:left;align-items:center;gap:8px;max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;margin:0 8px;color:var(--privy-color-foreground-2);> :first-child{min-width:24px;}"]),vd=/*#__PURE__*/Ka(Dt).withConfig({displayName:"ExportButton",componentId:"sc-3f6866a9-10"})(["display:flex;flex:1;gap:4px;justify-content:center;&&{background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);border-width:1px;}"]),Cd=/*#__PURE__*/Ka.div.withConfig({displayName:"InputRightIcons",componentId:"sc-3f6866a9-11"})(["position:absolute;right:0.5rem;display:flex;flex-direction:row;justify-content:space-around;align-items:center;"]),Ed=/*#__PURE__*/Ka(yi).withConfig({displayName:"RegenerateIcon",componentId:"sc-3f6866a9-12"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),Td=/*#__PURE__*/Ka(fi).withConfig({displayName:"HiddenIcon",componentId:"sc-3f6866a9-13"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),bd=/*#__PURE__*/Ka(gi).withConfig({displayName:"ShownIcon",componentId:"sc-3f6866a9-14"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),Ad=/*#__PURE__*/Ka.progress.withConfig({displayName:"StrengthMeter",componentId:"sc-3f6866a9-15"})(["height:4px;width:100%;margin:8px 0;::-webkit-progress-bar{border-radius:8px;background:var(--privy-color-foreground-4);}::-webkit-progress-value{border-radius:8px;transition:all 0.1s ease-out;background:",";}"],(({label:e})=>("Strong"===e?"#78dca6":"Medium"===e&&"var(--privy-color-warn)")||"var(--privy-color-error)")),_d=({buttonHideAnimations:r,buttonLoading:a,password:i,onSubmit:l,onBack:c})=>{let[d,h]=s(!0),[u,p]=s(!1),[m,y]=s(""),g=i===m;return o((()=>{m&&!u&&p(!0)}),[m]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{closeable:!1,backFn:c}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(Qa,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please re-enter your password below to continue."})]}),/*#__PURE__*/e(yd,{children:[/*#__PURE__*/t(pd,{value:m,onChange:e=>y(e.target.value),onKeyUp:e=>{"Enter"===e.key&&l()},onBlur:()=>p(!0),placeholder:"confirm your password",type:d?"password":"text",style:{paddingRight:"2.3rem"}}),/*#__PURE__*/t(Cd,{style:{right:"0.75rem"},children:d?/*#__PURE__*/t(Td,{onClick:()=>h(!1)}):/*#__PURE__*/t(bd,{onClick:()=>h(!0)})})]}),
7
+ /*#__PURE__*/t(cd,{"aria-hidden":!u||g,error:!0,children:"Passwords do not match"})]}),/*#__PURE__*/t(hd,{onClick:l,loading:a,disabled:!g,hideAnimations:r,children:"Continue"}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},kd=({className:n,checked:r,color:a="var(--privy-color-accent)",...i})=>/*#__PURE__*/t("label",{children:/*#__PURE__*/e(Id,{className:n,children:[/*#__PURE__*/t(xd,{checked:r,...i}),/*#__PURE__*/t(Sd,{color:a,checked:r,children:/*#__PURE__*/t(Nd,{viewBox:"0 0 24 24",children:/*#__PURE__*/t("polyline",{points:"20 6 9 17 4 12"})})})]})});let Id=/*#__PURE__*/Ka.div.withConfig({displayName:"CheckboxContainer",componentId:"sc-db51b935-1"})(["display:inline-block;vertical-align:middle;"]),Nd=/*#__PURE__*/Ka.svg.withConfig({displayName:"Icon",componentId:"sc-db51b935-2"})(["fill:none;stroke:white;stroke-width:3px;"]),xd=/*#__PURE__*/Ka.input.attrs({type:"checkbox"}).withConfig({displayName:"HiddenCheckbox",componentId:"sc-db51b935-3"})(["border:0;clip:rect(0 0 0 0);clippath:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px;"]),Sd=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledCheckbox",componentId:"sc-db51b935-4"})(["display:inline-block;width:18px;height:18px;transition:all 150ms;cursor:pointer;border-color:",";border-radius:3px;background:",";&&{border-width:1px;}",":focus + &{box-shadow:0 0 0 1px ",";}","{visibility:",";}"],(e=>e.color),(e=>e.checked?e.color:"var(--privy-color-background)"),xd,(e=>e.color),Nd,(e=>e.checked?"visible":"hidden"));const Rd=({buttonHideAnimations:r,buttonLoading:a,onSubmit:i,onBack:o,config:l})=>{let[c,d]=s(!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{closeable:!1,backFn:o}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(Qa,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-error)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm you have saved"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Losing access to your password means you will lose access to your account."})]}),/*#__PURE__*/t(fd,{children:/*#__PURE__*/e(wd,{style:{color:"var(--privy-color-error)",cursor:"pointer"},onClick:e=>{e.preventDefault(),d((e=>!e))},children:[/*#__PURE__*/t(kd,{color:"var(--privy-color-error)",readOnly:!0,checked:c}),/*#__PURE__*/t(n,{children:"I understand that if I lose my password and device, I will lose access to my account and my assets."})]})})]}),/*#__PURE__*/e(Od,{children:["user"===l.initiatedBy&&/*#__PURE__*/t(ut,{onClick:l.onCancel,disabled:a,children:"Cancel"}),/*#__PURE__*/t(hd,{onClick:i,loading:a,hideAnimations:r,disabled:!c,children:"Set Password"})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})};let Od=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-eb601350-0"})(["display:flex;gap:10px;"]),Wd=/[a-z]/,Md=/[A-Z]/,Pd=/[0-9]/,Ld="!@#$%^&*()\\-_+.",Dd=`a-zA-Z0-9${Ld}`,Ud=RegExp(`[${Ld}]`),Fd=RegExp(`[${Dd}]`);const Bd=RegExp(`^[${Dd}]{6,}$`),zd=()=>pi.generatePassphrase(4,mi);function Hd(e){return e>.9?"Strong":e>.5?"Medium":"Weak"}function Vd(e=""){return(.3*function(e){if(e.length<8)return 0;let t=0;return Wd.test(e)&&(t+=1),Md.test(e)&&(t+=1),Pd.test(e)&&(t+=1),Ud.test(e)&&(t+=1),Math.max(0,Math.min(1,t/3))}(e)+ui(e)/95)/2}const $d=({buttonHideAnimations:r,buttonLoading:a,password:l="",config:c,isResettingPassword:d,onSubmit:h,onClose:u,onBack:p,onPasswordChange:m,onPasswordGenerate:y})=>{let[g,f]=s(!1),[w,v]=s(!1);o((()=>{l&&!w&&v(!0)}),[l]);let C=i((()=>w?6>(l?.length||0)?"Password must be at least 6 characters":Bd.test(l||"")?null:`Invalid characters used ( ${((e="")=>[...new Set(e.split("").filter((e=>!Fd.test(e))).map((e=>e.replace(" ","SPACE"))))])(l).join(" ")} )`:null),[l,w]),E=i((()=>C?{value:0,label:"Weak"}:function(e=""){let t=Vd(e);return{value:t,label:Hd(t)}}(l)),[l,C]),T=i((()=>!l?.length||!!C),[C,l]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:u,closeable:"user"===c.initiatedBy,backFn:p}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(wi,{height:48,width:48,stroke:"var(--privy-color-accent)"}),/*#__PURE__*/e("h3",{style:{color:"var(--privy-color-foreground)"},children:[d?"Reset":"Set"," your password"]}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Select a strong, memorable password to secure your account."})]}),/*#__PURE__*/e(yd,{children:[/*#__PURE__*/t(pd,{value:l,onChange:e=>m(e.target.value),onKeyUp:e=>{"Enter"===e.key&&h()},placeholder:"enter or generate a strong password",type:g?"password":"text",style:{paddingRight:"3.8rem"}}),/*#__PURE__*/e(Cd,{style:{width:"3.5rem"},children:[g?/*#__PURE__*/t(Td,{onClick:()=>f(!1)}):/*#__PURE__*/t(bd,{onClick:()=>f(!0)}),/*#__PURE__*/t(Ed,{onClick:y})]})]}),/*#__PURE__*/t(Ad,{value:0===E.value?.01:E.value,label:E.label}),/*#__PURE__*/t(cd,{error:!!C,children:C||`Password Strength: ${w?E.label:"--"}`}),/*#__PURE__*/e(Gd,{children:[/*#__PURE__*/t(jd,{children:/*#__PURE__*/e(fd,{children:[/*#__PURE__*/e(wd,{children:[/*#__PURE__*/t(si,{width:24,height:24,fill:"var(--privy-color-accent)"}),"This password is used to secure your account."]}),/*#__PURE__*/e(wd,{children:[/*#__PURE__*/t(si,{width:24,height:24,fill:"var(--privy-color-accent)"}),"Use it to log in on a new environment, like another browser or device."]})]})}),/*#__PURE__*/t(hd,{onClick:h,loading:a,disabled:T,hideAnimations:r,children:"Continue"})]})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})};let jd=/*#__PURE__*/Ka(fd).withConfig({displayName:"DetailsContainer",componentId:"sc-7b3b7727-0"})(["flex:1;padding-top:1rem;"]),Gd=/*#__PURE__*/Ka.div.withConfig({displayName:"LowerContainer",componentId:"sc-7b3b7727-1"})(["display:flex;flex-direction:column;height:100%;"]);const qd=({buttonHideAnimations:r,buttonLoading:a,appName:i,password:o,onSubmit:l,onBack:d})=>{let[h,u]=s(!1),[p,m]=s(!0),y=c((()=>{u(!0),o&&navigator.clipboard.writeText(o)}),[o]),g=c((()=>{let e=document.createElement("a"),t=i.toLowerCase().replace(/[^a-z\s]/g,"").replace(/\s/g,"-"),n=new Blob([Kd(i,o)],{type:"text/plain"}),r=URL.createObjectURL(n);e.href=r,e.target="_blank",e.download=`${t}-privy-wallet-recovery.txt`,document.body.appendChild(e),e.click(),setTimeout((()=>{e.remove(),URL.revokeObjectURL(r)}),5e3)}),[o]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:d,closeable:!1}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(Qa,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Save your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"For your security, this password cannot be reset, so keep it somewhere safe."})]}),/*#__PURE__*/e(yd,{centered:!0,children:[/*#__PURE__*/t(md,{children:p?"•".repeat(o.length):o}),/*#__PURE__*/t(Cd,{style:{right:"0.75rem"},children:p?/*#__PURE__*/t(Td,{onClick:()=>m(!1)}):/*#__PURE__*/t(bd,{onClick:()=>m(!0)})})]}),/*#__PURE__*/e("div",{style:{display:"flex",margin:"12px 0",gap:"12px"},children:[/*#__PURE__*/t(vd,{onClick:y,children:/*#__PURE__*/e(n,h?{children:[/*#__PURE__*/t(Ci,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copied"]}:{children:[/*#__PURE__*/t(Ei,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copy"]})}),/*#__PURE__*/e(vd,{onClick:g,children:[/*#__PURE__*/t(vi,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Download"]})]})]}),/*#__PURE__*/t(hd,{onClick:l,loading:a,hideAnimations:r,children:"Continue"}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})};let Kd=(e,t)=>`Your wallet recovery password for ${e} is\n\n${t}\n\nYou will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;const Yd=({error:r,onClose:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{closeable:!1}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(Rt,r?{children:[/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zl,{title:"Something went wrong",description:r})]}:{children:[/*#__PURE__*/t(si,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zl,{title:"Success"})]}),/*#__PURE__*/t(ct,{onClick:a,children:"Close"}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]});let Zd=(e,t)=>{switch(e){case"creating":return"back"===t?e:"saving";case"saving":return"back"===t?"creating":"confirming";case"confirming":return"back"===t?"saving":"finalizing";case"finalizing":return"back"===t?"confirming":"done";default:return e}};const Jd=({onSubmit:e,...n})=>{let{lastScreen:r,navigate:a}=hr(),{send:i,state:s}=(()=>{let[e,t]=d(Zd,"creating");return{send:t,state:e}})(),l=c((async()=>{"finalizing"===s&&await e(),i("next")}),[s,i,e]);o((()=>{let e;return"done"===s&&"automatic"===n.config.initiatedBy&&(e=setTimeout((()=>n.onClose?.()),yr)),()=>{e&&clearTimeout(e)}}),[s,n.config.initiatedBy,n.onClose]);let h=c((()=>{i("back")}),[i]),u=c((()=>{a(ur.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN)}),[r,a]);return"creating"===s?/*#__PURE__*/t($d,{...n,onSubmit:l,onBack:r===ur.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN?u:void 0}):"saving"===s?/*#__PURE__*/t(qd,{...n,onSubmit:l,onBack:h}):"confirming"===s?/*#__PURE__*/t(_d,{...n,onSubmit:l,onBack:h}):"finalizing"===s?/*#__PURE__*/t(Rd,{...n,onSubmit:l,onBack:h}):"done"===s?/*#__PURE__*/t(Yd,{...n,onSubmit:l}):null};let Qd="0x0000000000000000000000000000000000000000";const Xd=({destinationCurrency:e,...t})=>({tradeType:"EXPECTED_OUTPUT",originCurrency:Qd,destinationCurrency:e??Qd,...t});let eh="https://api.relay.link",th="https://api.testnets.relay.link";const nh=async({input:e,isTestnet:t})=>{let n=await fetch((t?th:eh)+"/execute/swap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await n.json();if(!(n.ok||"string"==typeof r.message&&r.message.startsWith("Invalid address")))throw console.error("Relay error:",r),Error(r.message??"Error fetching quote from relay");return r},rh=e=>{let t=e.steps[0]?.items?.[0];if(t)return{from:t.data.from,to:t.data.to,value:Number(t.data.value),chainId:Number(t.data.chainId),data:t.data.data}};function ah({transactionHash:e,wallet:t,isTestnet:n,bridgingStatus:r,setBridgingStatus:a,onSuccess:i,onFailure:s}){o((()=>{if(e&&t&&r){if(["delayed","waiting","pending"].includes(r)){let t=setInterval((async()=>{try{let t=await async function({transactionHash:e,isTestnet:t}){let n=await fetch((t?th:eh)+"/requests/v2?hash="+e),r=await n.json();if(!n.ok){if("message"in r&&"string"==typeof r.message)throw Error(r.message);throw Error("Error fetching request from relay")}return r.requests.at(0)?.status??"pending"}({transactionHash:e,isTestnet:n});a(t)}catch(e){console.error(e)}}),1e3);return()=>clearInterval(t)}"success"===r?i({transactionHash:e,wallet:t}):["refund","failure"].includes(r)&&s({error:new ih(e,n)})}}),[r,e,n,t])}class ih extends T{constructor(e,t){super("We were unable to complete the bridging transaction. Funds will be refunded on your wallet.",void 0,A.TRANSACTION_FAILURE),this.relayLink=t?`https://testnets.relay.link/transaction/${e}`:`https://relay.link/transaction/${e}`}}const oh=({error:r,backFn:a,onClick:i})=>{let{reset:o}=st(),{app:s}=hr(),l=((r,a)=>{let i=/*#__PURE__*/t(Qa,{height:38,width:38,stroke:"var(--privy-color-error)"});if(r instanceof ih)return{title:"Transaction failed",detail:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("p",{children:r.message}),/*#__PURE__*/e("p",{children:["Check the"," ",/*#__PURE__*/t(ch,{href:r.relayLink,target:"_blank",children:"refund status"}),"."]})]}),ctaText:"Try again",icon:i};if(r instanceof T)switch(r.privyErrorCode){case A.CLIENT_REQUEST_TIMEOUT:return{title:"Timed out",detail:r.message,ctaText:"Try again",icon:i};case A.INSUFFICIENT_BALANCE:return{title:"Insufficient balance",detail:r.message,ctaText:"Try again",icon:i};case A.TRANSACTION_FAILURE:return{title:"Transaction failure",detail:r.message,ctaText:"Try again",icon:i};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i}}else{if(r instanceof Fc&&"twilio_verification_failed"===r.type)return{title:"Something went wrong",detail:r.message,ctaText:"Try again",icon:/*#__PURE__*/t(oi,{height:38,width:38,stroke:"var(--privy-color-error)"})};if(!(r instanceof M))return r instanceof N&&r.status&&[400,422].includes(r.status)?{title:"Something went wrong",detail:r.message,ctaText:"Try again",icon:i}:{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i};switch(r.privyErrorCode){case A.INVALID_CAPTCHA:return{title:"Something went wrong",detail:"Please try again.",ctaText:"Try again",icon:i};case A.DISALLOWED_LOGIN_METHOD:return{title:"Not allowed",detail:r.message,ctaText:"Try another method",icon:i};case A.ALLOWLIST_REJECTED:return{title:a.errorTitle||"You don't have access to this app",detail:a.errorDetail||"Have you been invited?",ctaText:a.errorCtaText||"Try another account",icon:/*#__PURE__*/t(jl,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})};case A.CAPTCHA_FAILURE:return{title:"Something went wrong",detail:"You did not pass CAPTCHA. Please try again.",ctaText:"Try again",icon:/*#__PURE__*/t("span",{})};case A.CAPTCHA_TIMEOUT:return{title:"Something went wrong",detail:"Something went wrong! Please try again later.",ctaText:"Try again",icon:/*#__PURE__*/t("span",{})};case A.LINKED_TO_ANOTHER_USER:return{title:"Authentication failed",detail:"This account has already been linked to another user.",ctaText:"Try again",icon:i};case A.NOT_SUPPORTED:return{title:"This region is not supported",detail:"SMS authentication from this region is not available",ctaText:"Try another method",icon:i};case A.TOO_MANY_REQUESTS:return{title:"Request failed",detail:"Too many attempts.",ctaText:"Try again later",icon:i};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i}}}})(r,s.allowlistConfig);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:a}),/*#__PURE__*/e(sh,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(dl,{color:"var(--privy-color-error)"}),l.icon]})}),/*#__PURE__*/e(lh,{children:[/*#__PURE__*/t("h3",{children:l.title}),"string"==typeof l.detail?/*#__PURE__*/t("p",{children:l.detail}):l.detail]}),/*#__PURE__*/t(ct,{color:"var(--privy-color-error)",onClick:()=>{r instanceof M&&(r.privyErrorCode===A.INVALID_CAPTCHA&&o(),r.privyErrorCode===A.ALLOWLIST_REJECTED&&s.allowlistConfig.errorCtaLink)?window.location.href=s.allowlistConfig.errorCtaLink:i?.()},children:l.ctaText})]})]})};let sh=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-f1b9e2cb-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),lh=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-f1b9e2cb-1"})(["display:flex;flex-direction:column;gap:8px;"]),ch=/*#__PURE__*/Ka.a.withConfig({displayName:"Link",componentId:"sc-f1b9e2cb-2"})(["color:var(--privy-color-accent) !important;font-weight:600;"]);const dh=({style:e,color:n,...r})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:n||"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...r,children:/*#__PURE__*/t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}),hh=n=>{let[r,a]=s(!1);/*#__PURE__*/return e(uh,{color:n.color,onClick:()=>{a(!0),navigator.clipboard.writeText(n.text),setTimeout((()=>a(!1)),1500)},justCopied:r,children:[r?/*#__PURE__*/t(dh,{style:{height:"14px",width:"14px"},strokeWidth:"2"}):/*#__PURE__*/t(Bt,{style:{height:"14px",width:"14px"}}),r?"Copied":"Copy"," ",n.itemName?n.itemName:"to Clipboard"]})};let uh=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledCopytoClipboardButton",componentId:"sc-9c2ee64b-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.justCopied?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.justCopied?"medium":"normal"),(e=>e.justCopied?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"));const ph=e=>{let[n,r]=s(!1);/*#__PURE__*/return t(mh,{color:e.color,href:e.url,target:"_blank",rel:"noreferrer noopener",onClick:()=>{r(!0),setTimeout((()=>r(!1)),1500)},justOpened:n,children:e.text})};let mh=/*#__PURE__*/Ka.a.withConfig({displayName:"StyledOpenLinkButton",componentId:"sc-4e695c83-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.justOpened?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.justOpened?"medium":"normal"),(e=>e.justOpened?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"));const yh=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"1000",height:"1000",viewBox:"0 0 1000 1000",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"1000",height:"1000",rx:"200",fill:"#855DCD"}),/*#__PURE__*/t("path",{d:"M257.778 155.556H742.222V844.444H671.111V528.889H670.414C662.554 441.677 589.258 373.333 500 373.333C410.742 373.333 337.446 441.677 329.586 528.889H328.889V844.444H257.778V155.556Z",fill:"white"}),/*#__PURE__*/t("path",{d:"M128.889 253.333L157.778 351.111H182.222V746.667C169.949 746.667 160 756.616 160 768.889V795.556H155.556C143.283 795.556 133.333 805.505 133.333 817.778V844.444H382.222V817.778C382.222 805.505 372.273 795.556 360 795.556H355.556V768.889C355.556 756.616 345.606 746.667 333.333 746.667H306.667V253.333H128.889Z",fill:"white"}),/*#__PURE__*/t("path",{d:"M675.556 746.667C663.283 746.667 653.333 756.616 653.333 768.889V795.556H648.889C636.616 795.556 626.667 805.505 626.667 817.778V844.444H875.556V817.778C875.556 805.505 865.606 795.556 853.333 795.556H848.889V768.889C848.889 756.616 838.94 746.667 826.667 746.667V351.111H851.111L880 253.333H702.222V746.667H675.556Z",fill:"white"})]});let gh="#8a63d2";let fh=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-d15a94a3-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),wh=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-d15a94a3-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),vh="#8a63d2";let Ch=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-6e2c96cd-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),Eh=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e2c96cd-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);function Th({title:e}){let{currentScreen:n,navigateBack:r,navigate:a,data:i,setModalData:o}=hr();/*#__PURE__*/return t(lt,{title:e,backFn:n===ur.FUNDING_MANUAL_TRANSFER_SCREEN?r:n===i?.funding?.methodScreen?i.funding.comingFromSendTransactionScreen?()=>a(ur.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN):void 0:i?.funding?.methodScreen?()=>{let e=i.funding;e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),o({funding:e}),a(e.methodScreen)}:void 0})}const bh=({size:n})=>/*#__PURE__*/t(Ah,{$size:n,children:/*#__PURE__*/e(_h,{children:[/*#__PURE__*/t(kh,{}),/*#__PURE__*/t(Ih,{})]})});let Ah=/*#__PURE__*/Ka.div.withConfig({displayName:"LoadingContainer",componentId:"sc-3ddaba1c-0"})(["--spinner-size:",";display:flex;justify-content:center;align-items:center;flex-grow:1;@media all and (display-mode:standalone){margin-bottom:30px;}"],(e=>e.$size?e.$size:"96px")),_h=/*#__PURE__*/Ka.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-3ddaba1c-1"})(["position:relative;height:var(--spinner-size);width:var(--spinner-size);opacity:1;animation:fadein 200ms ease;"]),kh=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleFixed",componentId:"sc-3ddaba1c-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);&&{border:4px solid #f1f2f9;border-radius:50%;}"]),Ih=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleRotate",componentId:"sc-3ddaba1c-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:#cbcde1 transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]);const Nh=({enabled:e=!0}={})=>{let{showFiatPrices:t,getUsdPriceForSol:n}=x(),[r,a]=s(!0),[i,l]=s(void 0),[c,d]=s(void 0);return o((()=>{(async()=>{if(t&&e)try{a(!0);let e=await n();e?d(e):l(Error("Unable to fetch SOL price"))}catch(e){l(e)}finally{a(!1)}else a(!1)})()}),[]),{solPrice:c,isSolPriceLoading:r,solPriceError:i}};function xh(e){let{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:r}=(e=>{let{showFiatPrices:t,getUsdTokenPrice:n,chains:r}=x(),[a,i]=s(!0),[l,c]=s(void 0),[d,h]=s(void 0);return o((()=>{e||=br;let a=Tr(r).find((t=>t.id===Number(e)));(async()=>{if(t){if(!a)return i(!1),void c(Error(`Unable to fetch token price on chain id ${e}`));try{i(!0);let e=await n(a);e?h(e):c(Error(`Unable to fetch token price on chain id ${a.id}`))}catch(e){c(e)}finally{i(!1)}}else i(!1)})()}),[e]),{tokenPrice:d,isTokenPriceLoading:a,tokenPriceError:l}})("solana"===e?-1:e),{solPrice:a,isSolPriceLoading:i,solPriceError:l}=Nh({enabled:"solana"===e});return"solana"===e?{tokenPrice:a,isTokenPriceLoading:i,tokenPriceError:l}:{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:r}}const Sh=(e,t=0)=>{let n=e[t],r=e[t+7];if(!n||!r)throw Error(`Buffer offset out of range: first: ${n}, last: ${r}.`);return(BigInt(e[t+4]+256*e[t+5]+65536*e[t+6]+(r<<24))<<32n)+BigInt(n+256*e[++t]+65536*e[++t]+16777216*e[++t])};async function Rh(e){try{return await e}catch{}}let Oh=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2});function Wh(e,t=6,n=!1,r=!1){let a=(parseFloat(e.toString())/1e9).toFixed(t).replace(/0+$/,"").replace(/\.$/,""),i=r?"":" SOL";return n?`${a}${i}`:`${"0"===a?"<0.001":a}${i}`}function Mh(e,t){let n=parseFloat(e.toString())/1e9,r=Oh.format(t*n);return"$0.00"===r?"<$0.01":r}function Ph({amount:e,fee:t,tokenPrice:n}){let r=BigInt(1e9*parseFloat(e)),a=r+t;return{fundingAmountInBaseUnit:r,fundingAmountInUsd:n?Mh(r,n):void 0,totalPriceInUsd:n?Mh(a,n):void 0,totalPriceInNativeCurrency:Wh(a),feePriceInNativeCurrency:Wh(t),feePriceInUsd:n?Mh(t,n):void 0}}function Lh(e){return"version"in e}function Dh(e,t,n){return{signature:e,parsedTransaction:n??null,signedTransaction:t,fees:BigInt(n?.meta?.fee||0)}}async function Uh({tx:e,connection:t,client:n}){let r=Lh(e)?e.message:e.compileMessage(),a=r.staticAccountKeys[0]?.toBase58()??"",i=await async function(e,t){return BigInt((Lh(e)?(await t.getFeeForMessage(e.message)).value:await e.getEstimatedFee(t))??0)}(e,t),o={},s={},l=[];for(let e of r.compiledInstructions){let a=r.staticAccountKeys[e.programIdIndex]?.toBase58()||"";if("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"!==a&&"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"!==a)if("11111111111111111111111111111111"!==a)if("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"!==a)l.push({type:"unknown",program:a});else{let t=await Rh(function(e,t){let[n,r,a,i]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!(n&&r&&a&&i))throw Error("Failed to parse ATA creation instruction");return{type:"ata-creation",payer:n.toBase58(),ata:r.toBase58(),owner:a.toBase58(),mint:i.toBase58()}}(e,r));if(!t)continue;l.push(t),s[t.ata]={owner:t.owner,mint:t.mint}}else{let t=await Rh(zh(e,r));if(!t)continue;l.push(t)}else{let a=await Rh(Bh(e,r,t,n,o,s));if(!a)continue;l.push(a),o[a.token.address]=a.token,s[a.fromAta]??={owner:a.fromAccount,mint:a.token.address},a.toAccount&&(s[a.toAta]??={owner:a.toAccount,mint:a.token.address})}}let c=l.filter((({type:e})=>["spl-transfer","sol-transfer"].includes(e)));return{spender:a,fee:i,instructions:c.length?c:l}}function Fh(e,t){try{return function(e,t=0){let n=0n;for(let r=0;r<8;r++)n|=BigInt(e[t+r])<<BigInt(8*r);return n}(e,t)}catch{}try{return e.readBigInt64LE(t)}catch{}let n=Buffer.from(e);try{return Sh(n)}catch{}try{return n.subarray(t).readBigInt64LE()}catch{}try{return n.readBigInt64LE(t)}catch{}return 0n}async function Bh(e,t,n,r,a,i){let o,s,[l,c,d]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!l||!c||!d)throw Error("Failed to parse SPL transfer instruction");let h="",u=i[c.toBase58()];if(u)o=u.owner,h=u.mint;else{let e=await n.getParsedAccountInfo(c,"confirmed"),t=e.value?.data;o=t?.parsed?.info?.owner,h=t?.parsed?.info?.mint??"",s=t?.parsed?.info?.tokenAmount?.decimals}if(!h){let e=await n.getParsedAccountInfo(l,"confirmed"),t=e.value?.data;h=t?.parsed?.info?.mint??""}let p=a[h];if(h&&!p){let e=await r.getSplTokenMetadata({mintAddress:h,cluster:Ar(n.rpcEndpoint)});e&&(p={address:h,symbol:e.symbol,decimals:e.decimals})}let m=p?.symbol??"";s??=p?.decimals??9;let y=Fh(e.data,1);return{type:"spl-transfer",fromAta:l.toBase58(),fromAccount:d.toBase58(),toAta:c.toBase58(),toAccount:o,value:y,token:{symbol:m,decimals:s,address:h}}}async function zh(e,t){let[n,r]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!n||!r)throw Error("Failed to parse SOL transfer instruction");let a=Fh(e.data,4);return{type:"sol-transfer",fromAccount:n.toBase58(),toAccount:r.toBase58(),value:a,token:{symbol:"SOL",decimals:9}}}const Hh=({chains:e,appId:t,address:n,rpcConfig:r})=>Promise.all(e.map((async e=>{let a=xa({chain:e,transport:Sa(Va(e,r,t))});return{balance:await a.getBalance({address:n}).catch((()=>0n)),chain:e}}))),Vh=/*#__PURE__*/Ka.span.withConfig({displayName:"LabelSm",componentId:"sc-6c002d6-0"})(["color:var(--privy-color-foreground-3);font-size:0.875rem;font-weight:400;line-height:1.375rem;"]),$h=/*#__PURE__*/Ka(Vh).withConfig({displayName:"LabelSmPrimary",componentId:"sc-6c002d6-1"})(["color:var(--privy-color-accent);"]),jh=/*#__PURE__*/Ka.span.withConfig({displayName:"Value",componentId:"sc-72aa026-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;",""],jt),Gh=({balance:e,className:n,chain:r})=>/*#__PURE__*/t(Gt,{className:n,$state:void 0,children:/*#__PURE__*/t(qh,{balance:e,chain:r})}),qh=({balance:r,chain:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(Kh,{children:[/*#__PURE__*/t(Zh,{chainId:"id"in a?a.id:"solana"}),/*#__PURE__*/t(jh,{children:a.name})]}),/*#__PURE__*/e(Et,{isLoading:!1,isPulsing:!1,color:"gray",children:[/*#__PURE__*/t(Yh,{children:/*#__PURE__*/t(Xa,{})}),r]})]});let Kh=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-6d3c340d-0"})(["display:flex;align-items:center;"]),Yh=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-6d3c340d-1"})(["height:0.75rem;width:0.75rem;margin-right:0.2rem;"]),Zh=/*#__PURE__*/Ka(qt).withConfig({displayName:"StyledNetworkIcon",componentId:"sc-6d3c340d-2"})(["height:1.25rem;width:1.25rem;display:inline-block;margin-right:0.5rem;border-radius:4px;"]);const Jh=({options:n,onSelect:r,selected:a,className:i})=>/*#__PURE__*/e(Hi,{as:Qh,children:[/*#__PURE__*/e(Vi,{as:nu,children:[/*#__PURE__*/t(qh,{balance:a.balance,chain:a.chain}),/*#__PURE__*/t(tu,{height:16})]}),/*#__PURE__*/t($i,{as:Xh,className:i,children:n.map(((e,n)=>/*#__PURE__*/t(ji,{as:eu,onClick:()=>r(n),children:/*#__PURE__*/t(qh,{balance:e.balance,chain:e.chain})},n)))})]});let Qh=/*#__PURE__*/Ka.div.withConfig({displayName:"Wrapper",componentId:"sc-7924b61-0"})(["width:100%;position:relative;"]),Xh=/*#__PURE__*/Ka.div.withConfig({displayName:"Popover",componentId:"sc-7924b61-1"})(["width:100%;margin-top:0.5rem;position:absolute;background-color:var(--privy-color-background);border-radius:var(--privy-border-radius-md);overflow-x:hidden;overflow-y:auto;box-shadow:0px 1px 2px 0px rgba(16,24,40,0.05);max-height:11.75rem;&&{border:solid 1px var(--privy-color-foreground-4);}z-index:1;"]),eu=/*#__PURE__*/Ka.button.withConfig({displayName:"Button",componentId:"sc-7924b61-2"})(["width:100%;display:flex;justify-content:space-between;&&{padding:1rem;}:not(:last-child){border-bottom:solid 1px var(--privy-color-foreground-4);}:hover{background:var(--privy-color-background-2);}"]),tu=/*#__PURE__*/Ka(Zi).withConfig({displayName:"StyledChevronIcon",componentId:"sc-7924b61-3"})(["height:1rem;margin-left:0.5rem;"]),nu=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledMenuButton",componentId:"sc-7924b61-4"})([""," span{margin-left:auto;}","{transition:rotate 100ms ease-in;}&[aria-expanded='true']{","{rotate:-180deg;}}"],Kt,tu,tu);const ru=({style:e,...n})=>/*#__PURE__*/t("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...e},fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.71369 17.5625V10.375C3.71369 6.44625 6.85845 3.25 10.7238 3.25H17.7953C18.6783 3.25 19.3941 2.52244 19.3941 1.625C19.3941 0.727562 18.6783 0 17.7953 0H10.7238C5.09529 0 0.516113 4.65419 0.516113 10.375V17.5625C0.516113 18.4599 1.23194 19.1875 2.1149 19.1875C2.99787 19.1875 3.71369 18.4599 3.71369 17.5625ZM17.7953 60.7501C18.6783 60.7501 19.3941 61.4777 19.3941 62.3751C19.3941 63.2726 18.6783 64.0001 17.7953 64.0001H10.7238C5.09529 64.0001 0.516113 59.3459 0.516113 53.6251V46.4376C0.516113 45.5402 1.23194 44.8126 2.1149 44.8126C2.99787 44.8126 3.71369 45.5402 3.71369 46.4376V53.6251C3.71369 57.5538 6.85845 60.7501 10.7238 60.7501H17.7953ZM63.4839 46.4376V53.6251C63.4839 59.3459 58.9048 64.0001 53.2763 64.0001H46.2047C45.3217 64.0001 44.6059 63.2726 44.6059 62.3751C44.6059 61.4777 45.3217 60.7501 46.2047 60.7501H53.2763C57.1416 60.7501 60.2864 57.5538 60.2864 53.6251V46.4376C60.2864 45.5402 61.0022 44.8126 61.8851 44.8126C62.7681 44.8126 63.4839 45.5402 63.4839 46.4376ZM63.4839 10.375V17.5625C63.4839 18.4599 62.7681 19.1875 61.8851 19.1875C61.0022 19.1875 60.2864 18.4599 60.2864 17.5625V10.375C60.2864 6.44625 57.1416 3.25 53.2763 3.25H46.2047C45.3217 3.25 44.6059 2.52244 44.6059 1.625C44.6059 0.727562 45.3217 0 46.2047 0H53.2763C58.9048 0 63.4839 4.65419 63.4839 10.375ZM43.0331 47.3022C43.7067 46.6698 43.7483 45.6022 43.1262 44.9176C42.5039 44.233 41.4536 44.1906 40.78 44.823C38.3832 47.0732 35.265 48.3125 31.9997 48.3125C28.7344 48.3125 25.6162 47.0732 23.2194 44.823C22.5457 44.1906 21.4955 44.233 20.8732 44.9176C20.251 45.6022 20.2927 46.6698 20.9663 47.3022C23.9784 50.1301 27.8968 51.6875 31.9997 51.6875C36.1026 51.6875 40.021 50.1301 43.0331 47.3022ZM35.3207 24.1249V36.1249C35.3207 38.5029 33.4173 40.4374 31.0777 40.4374H29.7249C28.8079 40.4374 28.0646 39.6819 28.0646 38.7499C28.0646 37.8179 28.8079 37.0624 29.7249 37.0624H31.0777C31.5863 37.0624 32.0001 36.6419 32.0001 36.1249V24.1249C32.0001 23.1929 32.7434 22.4374 33.6604 22.4374C34.5774 22.4374 35.3207 23.1929 35.3207 24.1249ZM46.7581 28.8437V24.0312C46.7581 23.151 46.056 22.4374 45.19 22.4374C44.324 22.4374 43.622 23.151 43.622 24.0312V28.8437C43.622 29.7239 44.324 30.4374 45.19 30.4374C46.056 30.4374 46.7581 29.7239 46.7581 28.8437ZM17.6109 28.8437C17.6109 29.7239 18.313 30.4374 19.1789 30.4374C20.0449 30.4374 20.747 29.7239 20.747 28.8437V24.0312C20.747 23.151 20.0449 22.4374 19.1789 22.4374C18.313 22.4374 17.6109 23.151 17.6109 24.0312V28.8437Z"})}),au=({style:n,...r})=>/*#__PURE__*/e("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...n},xmlns:"http://www.w3.org/2000/svg",...r,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_113_33841)",children:[/*#__PURE__*/t("path",{d:"M39.1193 0.943398C34.636 -0.174912 29.9185 -0.334713 25.328 0.656273C24.9732 0.732859 24.7477 1.08253 24.8243 1.43729C24.9009 1.79205 25.2506 2.01756 25.6053 1.94097C30.0015 0.991934 34.53 1.14842 38.8375 2.22802C49.1385 4.80983 57.7129 12.5548 60.9786 22.6718C62.2416 26.5843 62.7781 30.7505 62.8855 35.1167C62.8945 35.4795 63.1958 35.7664 63.5586 35.7575C63.9215 35.7485 64.2083 35.4472 64.1994 35.0843C64.0905 30.6582 63.5477 26.3849 62.2536 22.3432C58.8621 11.7515 49.9005 3.63265 39.1193 0.943398Z"}),/*#__PURE__*/t("path",{d:"M21.9931 2.93163C22.343 2.83511 22.5484 2.47325 22.4518 2.12339C22.3553 1.77352 21.9935 1.56815 21.6436 1.66466C16.8429 2.98903 10.0898 7.56519 5.91628 13.6786C5.91465 13.681 5.91304 13.6834 5.91145 13.6858C2.24684 19.2083 -0.0503572 26.1484 0.591012 32.8828C0.591623 32.8892 0.592328 32.8956 0.593127 32.902C0.746837 34.1317 1.00488 35.3591 1.26323 36.5879C1.80735 39.1761 2.35282 41.7706 1.92765 44.4064C1.86986 44.7647 2.11347 45.102 2.47177 45.1598C2.83007 45.2176 3.16738 44.974 3.22518 44.6157C3.66961 41.8605 3.11776 39.173 2.56581 36.4851C2.31054 35.2419 2.05525 33.9987 1.89847 32.7486C1.29525 26.3851 3.46802 19.7466 7.00418 14.416C11.0189 8.5373 17.5201 4.16562 21.9931 2.93163Z"}),/*#__PURE__*/t("path",{d:"M30.6166 4.39985C38.8671 3.89603 47.1159 7.26314 52.6556 13.7139C52.8921 13.9893 52.8605 14.4042 52.5852 14.6406C52.3099 14.8771 51.895 14.8455 51.6585 14.5702C46.3904 8.43576 38.541 5.23144 30.6927 5.71195C30.6899 5.71212 30.6871 5.71227 30.6843 5.71241C20.7592 6.19265 11.4643 12.9257 8.04547 22.3603C7.92183 22.7016 7.54498 22.8779 7.20375 22.7543C6.86253 22.6306 6.68616 22.2538 6.80981 21.9126C10.4114 11.9735 20.1717 4.90702 30.6166 4.39985Z"}),/*#__PURE__*/t("path",{d:"M54.6576 16.5848C54.4553 16.2836 54.047 16.2033 53.7457 16.4057C53.4444 16.608 53.3642 17.0163 53.5665 17.3176C56.6376 21.8904 57.9074 26.8665 58.4094 32.7717C58.4401 33.1333 58.7582 33.4016 59.1199 33.3708C59.4815 33.3401 59.7497 33.022 59.719 32.6604C59.206 26.6261 57.8965 21.4076 54.6576 16.5848Z"}),/*#__PURE__*/t("path",{d:"M59.2796 35.4504C59.6419 35.4277 59.9539 35.703 59.9765 36.0653C60.2242 40.0279 60.2265 44.5112 59.7881 47.8243C59.7405 48.1841 59.4102 48.4372 59.0504 48.3896C58.6906 48.342 58.4376 48.0117 58.4852 47.6519C58.9077 44.4586 58.91 40.0704 58.6648 36.1473C58.6421 35.785 58.9174 35.473 59.2796 35.4504Z"}),/*#__PURE__*/t("path",{d:"M7.05311 25.5432C7.13829 25.1904 6.92135 24.8354 6.56855 24.7502C6.21576 24.665 5.86071 24.882 5.77553 25.2348C5.2932 27.2325 5.0428 29.2847 5.03288 31.3388C5.02266 33.4559 5.41742 35.5225 5.81234 37.5899C6.1354 39.2811 6.45855 40.9728 6.5602 42.6932C6.69373 44.9531 6.21839 47.2163 5.39698 49.3703C5.26766 49.7094 5.43774 50.0891 5.77685 50.2184C6.11596 50.3477 6.4957 50.1777 6.62502 49.8386C7.49325 47.5617 8.01954 45.1092 7.87221 42.6157C7.77126 40.9071 7.44813 39.2252 7.12512 37.5439C6.73099 35.4925 6.33704 33.442 6.34716 31.3451C6.35659 29.3933 6.59455 27.4425 7.05311 25.5432Z"}),/*#__PURE__*/t("path",{d:"M24.2964 10.94C24.4317 11.2768 24.2683 11.6595 23.9315 11.7947C17.1187 14.5307 12.0027 20.7047 10.959 27.9852C10.523 31.0269 10.9941 34.0398 11.465 37.052C11.7303 38.7483 11.9954 40.4443 12.0985 42.1451C12.3221 45.833 11.902 49.8839 9.50192 53.5696C9.30387 53.8737 8.89677 53.9597 8.59264 53.7617C8.28851 53.5636 8.20251 53.1565 8.40056 52.8524C10.5873 49.4944 11.0012 45.7644 10.7867 42.2246C10.6821 40.499 10.4185 38.7833 10.1552 37.0686C9.68265 33.9923 9.21067 30.9195 9.65804 27.7987C10.7724 20.025 16.221 13.4748 23.4417 10.5751C23.7785 10.4399 24.1612 10.6032 24.2964 10.94Z"}),/*#__PURE__*/t("path",{d:"M47.3662 14.6814C41.9915 9.64741 34.2017 7.89046 27.122 9.4433C26.7675 9.52105 26.5432 9.87147 26.6209 10.226C26.6987 10.5805 27.0491 10.8048 27.4036 10.7271C34.1075 9.25665 41.4426 10.934 46.4677 15.6406C50.7033 19.6077 53.1628 25.38 53.8066 31.6779C53.8435 32.0389 54.1661 32.3017 54.5272 32.2648C54.8883 32.2279 55.151 31.9053 55.1141 31.5442C54.4456 25.0047 51.8822 18.9111 47.3662 14.6814Z"}),/*#__PURE__*/t("path",{d:"M54.9766 34.6738C55.3376 34.6368 55.6604 34.8994 55.6975 35.2604C56.3216 41.337 56.0526 47.9003 55.1104 54.2496C55.0571 54.6086 54.7229 54.8565 54.3639 54.8032C54.0049 54.7499 53.7571 54.4157 53.8103 54.0567C54.7394 47.7957 55.001 41.3439 54.39 35.3947C54.353 35.0336 54.6156 34.7109 54.9766 34.6738Z"}),/*#__PURE__*/t("path",{d:"M32.0659 13.3553C21.9959 13.3553 13.814 21.3892 13.814 31.3219C13.814 32.3829 13.9081 33.4225 14.0876 34.4334C14.1511 34.7907 14.4922 35.029 14.8495 34.9655C15.2069 34.9021 15.4451 34.561 15.3817 34.2036C15.2155 33.2677 15.1283 32.305 15.1283 31.3219C15.1283 22.1352 22.7014 14.6696 32.0659 14.6696C36.2978 14.6696 40.1642 16.1949 43.1319 18.7152C43.4086 18.9501 43.8233 18.9163 44.0582 18.6396C44.2931 18.363 44.2593 17.9483 43.9827 17.7134C40.7847 14.9975 36.6188 13.3553 32.0659 13.3553Z"}),/*#__PURE__*/t("path",{d:"M45.455 20.1635C45.717 19.9123 46.133 19.921 46.3842 20.183C49.2843 23.2072 50.2126 27.9605 50.8269 31.9494C51.5188 36.4426 51.6244 40.826 51.6244 42.8585C51.6244 43.2214 51.3302 43.5156 50.9673 43.5156C50.6044 43.5156 50.3101 43.2214 50.3101 42.8585C50.3101 40.8589 50.2055 36.5497 49.5279 32.1494C48.9577 28.4462 48.1356 23.9082 45.4356 21.0927C45.1844 20.8307 45.1931 20.4147 45.455 20.1635Z"}),/*#__PURE__*/t("path",{d:"M51.4576 46.6219C51.4864 46.2601 51.2165 45.9435 50.8547 45.9146C50.493 45.8858 50.1763 46.1557 50.1474 46.5175C49.8247 50.5654 49.403 54.6088 48.5474 58.3439C48.4663 58.6977 48.6874 59.0502 49.0412 59.1312C49.3949 59.2123 49.7474 58.9912 49.8285 58.6374C50.7067 54.8039 51.134 50.6806 51.4576 46.6219Z"}),/*#__PURE__*/t("path",{d:"M15.1454 36.852C15.5015 36.7819 15.847 37.0137 15.9171 37.3698C17.3066 44.4257 16.3467 50.8355 12.6672 56.4502C12.4682 56.7537 12.0609 56.8385 11.7573 56.6396C11.4538 56.4407 11.369 56.0333 11.5679 55.7298C15.0299 50.4469 15.9617 44.3985 14.6276 37.6238C14.5575 37.2677 14.7893 36.9221 15.1454 36.852Z"}),/*#__PURE__*/t("path",{d:"M32.0659 17.631C25.5291 17.631 19.1165 22.691 18.462 29.0504C18.1754 31.8345 18.578 34.5769 18.9807 37.3204C19.3323 39.7159 19.684 42.1124 19.5772 44.5381C19.3328 50.0898 17.7039 54.6726 14.905 58.4471C14.6888 58.7386 14.7499 59.1502 15.0414 59.3663C15.333 59.5825 15.7445 59.5214 15.9607 59.2299C18.9293 55.2266 20.6354 50.386 20.8903 44.5959C20.9966 42.1811 20.6438 39.7923 20.2912 37.4051C19.888 34.6752 19.4851 31.9473 19.7694 29.1849C20.3444 23.5983 26.0946 18.9453 32.0659 18.9453C34.851 18.9453 42.057 20.4534 44.3492 27.9205C45.7856 32.5998 46.1774 38.9326 45.8295 45.0849C45.4816 51.2364 44.3994 57.12 42.9442 60.8928C42.8136 61.2314 42.9822 61.6118 43.3208 61.7424C43.6594 61.873 44.0398 61.7044 44.1704 61.3658C45.6929 57.4186 46.7895 51.386 47.1417 45.1591C47.4938 38.9329 47.1068 32.4249 45.6056 27.5348C43.0612 19.2461 35.0851 17.631 32.0659 17.631Z"}),/*#__PURE__*/t("path",{d:"M21.9529 56.4512C22.2569 56.6494 22.3426 57.0566 22.1444 57.3606C21.7369 57.9854 21.3784 58.6391 21.0199 59.2928C20.6614 59.9465 20.3028 60.6004 19.8953 61.2253C19.697 61.5293 19.2898 61.615 18.9858 61.4167C18.6819 61.2184 18.5962 60.8113 18.7944 60.5073C19.2019 59.8825 19.5604 59.2288 19.9189 58.5751C20.2774 57.9213 20.636 57.2675 21.0435 56.6426C21.2418 56.3386 21.649 56.2529 21.9529 56.4512Z"}),/*#__PURE__*/t("path",{d:"M27.5799 24.4525C27.8816 24.2508 27.9625 23.8426 27.7608 23.541C27.559 23.2393 27.1509 23.1583 26.8492 23.3601C24.247 25.1006 22.6505 27.494 22.6505 31.0002C22.6505 33.088 23.0203 34.7946 23.3997 36.5449C23.9674 39.1641 24.3524 41.7777 24.2832 44.468C24.1992 47.7349 23.56 50.7201 22.3313 53.564C22.1873 53.8971 22.3407 54.2839 22.6739 54.4278C23.0071 54.5718 23.3938 54.4184 23.5378 54.0852C24.8369 51.0784 25.509 47.9266 25.5971 44.5018C25.6689 41.7062 25.2732 38.9892 24.6845 36.267C24.3042 34.509 23.9648 32.9394 23.9648 31.0002C23.9648 27.9961 25.2863 25.9866 27.5799 24.4525Z"}),/*#__PURE__*/t("path",{d:"M30.1447 22.1436C32.8717 21.5877 35.8061 22.2746 37.966 24.0228C41.8241 27.1455 42.3372 32.8403 42.753 37.4549L42.7742 37.69C43.3115 43.6385 42.6964 49.4163 41.4575 55.2186C41.3817 55.5736 41.0326 55.7999 40.6776 55.7241C40.3227 55.6483 40.0964 55.2991 40.1722 54.9442C41.3926 49.2288 41.9873 43.5885 41.4652 37.8082C41.4479 37.6169 41.4307 37.4228 41.4133 37.2264L41.4131 37.2235C41.0438 33.0534 40.5812 27.8304 37.1392 25.0444C35.2926 23.5498 32.7599 22.9518 30.4073 23.4314C30.0517 23.5039 29.7046 23.2744 29.6321 22.9188C29.5596 22.5632 29.7891 22.2161 30.1447 22.1436Z"}),/*#__PURE__*/t("path",{d:"M40.5287 58.4885C40.6183 58.1368 40.4057 57.7791 40.054 57.6896C39.7023 57.6 39.3446 57.8126 39.2551 58.1643C38.8578 59.7247 38.2456 61.1333 37.4695 62.4301C37.2831 62.7415 37.3844 63.145 37.6958 63.3314C38.0072 63.5178 38.4108 63.4165 38.5972 63.1051C39.4336 61.7075 40.0977 60.1816 40.5287 58.4885Z"}),/*#__PURE__*/t("path",{d:"M37.3152 48.9521C37.6756 48.9948 37.9332 49.3215 37.8906 49.682C37.2699 54.9267 35.8688 59.6042 33.6205 63.6613C33.4446 63.9787 33.0446 64.0934 32.7272 63.9175C32.4097 63.7416 32.295 63.3417 32.4709 63.0242C34.6226 59.1416 35.9811 54.6339 36.5854 49.5275C36.6281 49.1671 36.9548 48.9095 37.3152 48.9521Z"}),/*#__PURE__*/t("path",{d:"M37.1798 30.6556C36.7242 28.2212 34.6349 26.3591 32.0985 26.3591C28.6638 26.3591 26.254 29.8212 27.1032 33.0422C28.54 38.7279 28.7759 44.2077 27.8032 49.4855L27.8025 49.4893C26.9584 54.228 25.3374 58.4908 23.1263 62.1031C22.9368 62.4127 23.0342 62.8172 23.3437 63.0067C23.6533 63.1962 24.0578 63.0988 24.2473 62.7893C26.5488 59.0292 28.2249 54.6109 29.0961 49.7218C30.106 44.2403 29.8558 38.5684 28.3765 32.7168L28.3748 32.7099C27.7378 30.3005 29.5133 27.6734 32.0985 27.6734C33.9641 27.6734 35.5393 29.0459 35.8871 30.8929C36.8436 36.4411 37.3418 41.5862 36.9871 46.016C36.9581 46.3778 37.2279 46.6945 37.5897 46.7235C37.9515 46.7525 38.2682 46.4827 38.2972 46.1209C38.6649 41.5294 38.1459 36.2576 37.1815 30.6648C37.1809 30.6617 37.1804 30.6586 37.1798 30.6556Z"}),/*#__PURE__*/t("path",{d:"M30.1376 59.1171C30.4604 59.283 30.5876 59.6792 30.4217 60.002L28.6804 63.3906C28.5145 63.7134 28.1184 63.8406 27.7956 63.6747C27.4728 63.5088 27.3456 63.1127 27.5114 62.7899L29.2527 59.4013C29.4186 59.0785 29.8147 58.9513 30.1376 59.1171Z"}),/*#__PURE__*/t("path",{d:"M32.5872 31.2892C32.5042 30.9359 32.1505 30.7168 31.7972 30.7998C31.4439 30.8828 31.2247 31.2365 31.3077 31.5898C33.5238 41.0232 33.2194 49.3066 30.5201 56.363C30.3905 56.702 30.5602 57.0819 30.8991 57.2115C31.2381 57.3412 31.618 57.1715 31.7477 56.8326C34.5622 49.475 34.8483 40.9141 32.5872 31.2892Z"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_113_33841",children:/*#__PURE__*/t("rect",{width:"64",height:"64",fill:"white",transform:"translate(0.483887)"})})})]});let iu=({passkeys:n,expanded:r,onUnlink:a,onExpand:i})=>{let[o,l]=s([]),c=r?n.length:2,d=e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device";/*#__PURE__*/return e("div",{children:[/*#__PURE__*/t(yu,{children:"Your passkeys"}),/*#__PURE__*/e(hu,{children:[n.slice(0,c).map((n=>/*#__PURE__*/e(wu,{children:[/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(gu,{children:d(n)}),/*#__PURE__*/e(fu,{children:["Last used: ",(n.latestVerifiedAt??n.verifiedAt).toLocaleString()]})]}),/*#__PURE__*/t(Cu,{disabled:o.includes(n.credentialId),onClick:()=>(async e=>{l((t=>t.concat([e]))),await a(e),l((t=>t.filter((t=>t!==e))))})(n.credentialId),children:o.includes(n.credentialId)?/*#__PURE__*/t(Yt,{}):/*#__PURE__*/t(ao,{height:"1.6em"})})]},n.credentialId))),n.length>2&&!r&&/*#__PURE__*/t(du,{onClick:i,children:"View all"})]})]})},ou=()=>/*#__PURE__*/e(hu,{children:[/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(io,{})}),"Log in with Touch ID, Face ID, or a security key."]}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(bi,{})}),"More secure than a password."]}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(ro,{})}),"Takes seconds to set up and use."]})]});const su=/*#__PURE__*/Ka.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-302702bc-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent) !important;stroke:var(--privy-color-accent) !important;fill:var(--privy-color-accent) !important;}"]);let lu=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-302702bc-1"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-beginngin;width:100%;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),cu=/*#__PURE__*/Ya(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]);const du=/*#__PURE__*/Ka.button.withConfig({displayName:"LinkButton",componentId:"sc-302702bc-2"})(["",""],cu);let hu=/*#__PURE__*/Ka.div.withConfig({displayName:"List",componentId:"sc-302702bc-3"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.8rem;padding:0.5rem 0rem 0rem;flex-grow:1;width:100%;"]),uu=/*#__PURE__*/Ka.div.withConfig({displayName:"ModalTitle",componentId:"sc-302702bc-4"})(["font-size:18px;line-height:18px;text-align:center;font-weight:600;"]),pu=/*#__PURE__*/Ka.div.withConfig({displayName:"ModalSubTitle",componentId:"sc-302702bc-5"})(["font-size:0.875rem;text-align:center;margin-top:10px;"]),mu=/*#__PURE__*/Ka.div.withConfig({displayName:"SectionSpacer",componentId:"sc-302702bc-6"})(["height:32px;"]),yu=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyListTitle",componentId:"sc-302702bc-7"})(["line-height:20px;height:20px;font-size:1em;font-weight:450;display:flex;justify-content:flex-beginning;width:100%;"]),gu=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-302702bc-8"})(["font-size:1em;line-height:1.3em;font-weight:500;color:var(--privy-color-foreground-2);padding:0.2em 0;"]),fu=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-302702bc-9"})(["font-size:0.875rem;line-height:1rem;color:#64668b;padding:0.2em 0;"]),wu=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyListItem",componentId:"sc-302702bc-10"})(["display:flex;align-items:center;justify-content:space-between;padding:1em;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;border-radius:8px;border:1px solid #e2e3f0 !important;width:100%;height:5em;"]),vu=/*#__PURE__*/Ya([":focus,:hover,:active{outline:none;}display:flex;width:2em;height:2em;justify-content:center;align-items:center;svg{color:var(--privy-color-error);}svg:hover{color:var(--privy-color-foreground-3);}"]),Cu=/*#__PURE__*/Ka.button.withConfig({displayName:"PasskeyItemUnlinkButton",componentId:"sc-302702bc-11"})(["",""],vu);const Eu=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingMethodContainer",componentId:"sc-eaaa12a-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),Tu=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-eaaa12a-1"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;svg{border-radius:var(--privy-border-radius-sm);}"]),bu=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingQuantityWrapper",componentId:"sc-eaaa12a-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:8px;"]),Au=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingQuantity",componentId:"sc-eaaa12a-3"})(["display:flex;align-items:center;gap:4px;width:100%;padding:0 16px;border-width:1px !important;border-radius:12px;cursor:text;&:focus-within{border-color:var(--privy-color-accent);}"]),_u=/*#__PURE__*/Ka.input.withConfig({displayName:"FundingAmountInput",componentId:"sc-eaaa12a-5"})(["background-color:var(--privy-color-background);width:100%;&:focus{outline:none !important;border:none !important;box-shadow:none !important;}&&{font-size:26px;}"]),ku=/*#__PURE__*/Ka(_u).withConfig({displayName:"FundingAmountInputLarge",componentId:"sc-eaaa12a-6"})(["&&{font-size:42px;}"]),Iu=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingCurrency",componentId:"sc-eaaa12a-8"})(["font-size:18px;"]),Nu=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingDollars",componentId:"sc-eaaa12a-9"})(["font-size:12px;color:var(--privy-color-foreground-3);height:20px;"]),xu=/*#__PURE__*/Ka.div.withConfig({displayName:"InfoButtonText",componentId:"sc-eaaa12a-13"})([""]),Su=/*#__PURE__*/Ka.a.withConfig({displayName:"InfoButtonLink",componentId:"sc-eaaa12a-14"})(["&&{color:var(--privy-color-accent);}cursor:pointer;"]),Ru=({displayName:r,errorMessage:a,configuredFundingChain:i,formattedBalance:o,fundingAmount:s,fundingCurrency:c,fundingAmountInUsd:d,options:h,selectedOption:u,isPreparing:p,isSubmitting:m,addressToFund:y,fundingWalletAddress:g,onSubmit:f,onSelect:w,onAmountChange:v})=>{let C=l(null);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(Ot,{children:"Transfer from another network"}),/*#__PURE__*/e(Wt,{children:["You need more funds on the ",i.name," network. Bridge from another blockchain network."]}),/*#__PURE__*/e(bu,{style:{marginTop:"2rem"},children:[/*#__PURE__*/e(Au,{onClick:()=>C.current?.focus(),children:[/*#__PURE__*/t(_u,{ref:C,value:s,onChange:e=>{let t=e.target.value;/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1&&v(t)}}),/*#__PURE__*/t(Iu,{children:c})]}),d&&/*#__PURE__*/t(Nu,{children:d})]}),/*#__PURE__*/e(Zt,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/t(Vh,{children:"From"}),/*#__PURE__*/t(Vh,{children:Ai(g)})]}),/*#__PURE__*/t(Jh,{selected:{chain:u.chain,balance:Jt(u.balance,u.chain.nativeCurrency.symbol,3,!0)},options:h.map((({chain:e,balance:t})=>({chain:e,balance:Jt(t,e.nativeCurrency.symbol,3,!0)}))),onSelect:w}),/*#__PURE__*/e(Zt,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/t(Vh,{children:"To"}),/*#__PURE__*/t(Vh,{children:Ai(y)})]}),/*#__PURE__*/t(Gh,{chain:i,balance:o}),/*#__PURE__*/t(Qt,{style:{marginTop:"1rem"},children:a}),/*#__PURE__*/e(Xt,{style:{marginTop:"1rem"},loading:m||p,disabled:p||m,onClick:f,children:["Confirm with ",r]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},Ou=({wallet:r,displayName:a,addressToFund:i,chainId:o,chainName:s,isBridging:l,isErc20Flow:c,totalPriceInNativeCurrency:d,totalPriceInUsd:h,gasPriceInNativeCurrency:u,gasPriceInUsd:p})=>{let m=vt(r.walletClientType);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(bh,{}),/*#__PURE__*/t(zt,{style:{marginTop:"16px"},children:/*#__PURE__*/t(yc,{icon:m?.image_url?.md,name:r.walletClientType})}),/*#__PURE__*/t(Zl,{style:{marginTop:"8px",marginBottom:"12px"},title:`${l?"Bridging":"Confirming"} with ${a}`}),!l&&!c&&/*#__PURE__*/e(en,{children:[/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Total"}),/*#__PURE__*/t(jh,{children:h||d})]}),/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"To"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:i,showCopyIcon:!1})})]}),/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Network"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/e(Wu,{children:[/*#__PURE__*/t(qt,{chainId:o,height:16,width:16})," ",s]})})]}),u&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Estimated fee"}),/*#__PURE__*/t(jh,{children:p||u})]})]}),/*#__PURE__*/t(xt,{height:24}),/*#__PURE__*/t(ht,{})]})};let Wu=/*#__PURE__*/Ka.div.withConfig({displayName:"NetworkColumn",componentId:"sc-ec6320ce-0"})(["display:flex;flex-direction:row;align-items:center;gap:4px;"]);const Mu=[ur.FUNDING_METHOD_SELECTION_SCREEN,ur.FUNDING_TRANSFER_FROM_WALLET_SCREEN,ur.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN,ur.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN,ur.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN,ur.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN,ur.FUNDING_MANUAL_TRANSFER_SCREEN,ur.MOONPAY_STATUS_SCREEN],Pu={[ur.FUNDING_METHOD_SELECTION_SCREEN]:null,[ur.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:"external",[ur.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:"external",[ur.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN]:"external",[ur.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN]:"external",[ur.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN]:"external",[ur.FUNDING_MANUAL_TRANSFER_SCREEN]:"manual",[ur.MOONPAY_STATUS_SCREEN]:"moonpay"},Lu=[{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}];let Du=({status:r,onClickCta:a})=>{let{title:o,body:s,cta:l}=i((()=>(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(n,{children:[/*#__PURE__*/e(Bu,{children:[/*#__PURE__*/t(Uu,{isSucccess:"success"===r}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t("h3",{children:o}),/*#__PURE__*/t(Fu,{children:s})]})]}),l&&/*#__PURE__*/t(ct,{onClick:a,children:l})]})},Uu=({isSucccess:n})=>{if(!n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t($t,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(ln,{color:n}),/*#__PURE__*/t(ns,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let r=(e=>e?si:()=>/*#__PURE__*/t(Ji,{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),a=(e=>e?"var(--privy-color-success)":"var(--privy-color-foreground-4)")(n);/*#__PURE__*/return t("div",{style:{borderColor:a,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:r&&/*#__PURE__*/t(r,{width:"4rem",height:"4rem",color:a})})},Fu=/*#__PURE__*/Ka.p.withConfig({displayName:"StatusBody",componentId:"sc-96ef1540-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),Bu=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-96ef1540-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const zu=({children:n,theme:r})=>/*#__PURE__*/e(Hu,{$theme:r,children:[/*#__PURE__*/t(Qa,{width:"3rem",color:"var(--privy-color-error)"}),n]});let Hu=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-5400b18f-0"})(["display:flex;gap:0.5rem;"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.75rem;font-weight:400;line-height:1.125rem;padding:0.5rem 0.75rem;&&{border:1px solid var(--privy-color-error);border-radius:var(--privy-border-radius-sm);}"],(e=>"dark"===e.$theme?"color: var(--privy-color-error);":"background-color: var(--privy-color-error-light);"));const Vu=({children:n,theme:r})=>/*#__PURE__*/e($u,{$theme:r,children:[/*#__PURE__*/t(eo,{width:"1.25rem",color:"dark"===r?"var(--privy-color-accent-light)":"var(--privy-color-accent-dark)",style:{minWidth:"1.25rem"}}),n]});let $u=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-dc8a0871-0"})(["display:flex;gap:0.5rem;background-color:",";color:var(--privy-color-foreground);align-items:flex-start;text-align:left;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);border:1px solid var(--privy-color-accent);}"],(e=>"dark"===e.$theme?"var(--privy-color-accent-darkest)":"var(--privy-color-accent-lightest)"));const ju=e=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 210.2",xmlSpace:"preserve",...e,children:/*#__PURE__*/t("path",{d:"M93.6,27.1C87.6,34.2,78,39.8,68.4,39c-1.2-9.6,3.5-19.8,9-26.1c6-7.3,16.5-12.5,25-12.9 C103.4,10,99.5,19.8,93.6,27.1 M102.3,40.9c-13.9-0.8-25.8,7.9-32.4,7.9c-6.7,0-16.8-7.5-27.8-7.3c-14.3,0.2-27.6,8.3-34.9,21.2 c-15,25.8-3.9,64,10.6,85c7.1,10.4,15.6,21.8,26.8,21.4c10.6-0.4,14.8-6.9,27.6-6.9c12.9,0,16.6,6.9,27.8,6.7 c11.6-0.2,18.9-10.4,26-20.8c8.1-11.8,11.4-23.3,11.6-23.9c-0.2-0.2-22.4-8.7-22.6-34.3c-0.2-21.4,17.5-31.6,18.3-32.2 C123.3,42.9,107.7,41.3,102.3,40.9 M182.6,11.9v155.9h24.2v-53.3h33.5c30.6,0,52.1-21,52.1-51.4c0-30.4-21.1-51.2-51.3-51.2H182.6z M206.8,32.3h27.9c21,0,33,11.2,33,30.9c0,19.7-12,31-33.1,31h-27.8V32.3z M336.6,169c15.2,0,29.3-7.7,35.7-19.9h0.5v18.7h22.4V90.2 c0-22.5-18-37-45.7-37c-25.7,0-44.7,14.7-45.4,34.9h21.8c1.8-9.6,10.7-15.9,22.9-15.9c14.8,0,23.1,6.9,23.1,19.6v8.6l-30.2,1.8 c-28.1,1.7-43.3,13.2-43.3,33.2C298.4,155.6,314.1,169,336.6,169z M343.1,150.5c-12.9,0-21.1-6.2-21.1-15.7c0-9.8,7.9-15.5,23-16.4 l26.9-1.7v8.8C371.9,140.1,359.5,150.5,343.1,150.5z M425.1,210.2c23.6,0,34.7-9,44.4-36.3L512,54.7h-24.6l-28.5,92.1h-0.5 l-28.5-92.1h-25.3l41,113.5l-2.2,6.9c-3.7,11.7-9.7,16.2-20.4,16.2c-1.9,0-5.6-0.2-7.1-0.4v18.7C417.3,210,423.3,210.2,425.1,210.2z"})}),Gu=n=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 38.1",xmlSpace:"preserve",...n,children:[/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M37.8,19.7V29h-3V6h7.8c1.9,0,3.7,0.7,5.1,2c1.4,1.2,2.1,3,2.1,4.9c0,1.9-0.7,3.6-2.1,4.9c-1.4,1.3-3.1,2-5.1,2 L37.8,19.7L37.8,19.7z M37.8,8.8v8h5c1.1,0,2.2-0.4,2.9-1.2c1.6-1.5,1.6-4,0.1-5.5c0,0-0.1-0.1-0.1-0.1c-0.8-0.8-1.8-1.3-2.9-1.2 L37.8,8.8L37.8,8.8z"}),/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M56.7,12.8c2.2,0,3.9,0.6,5.2,1.8s1.9,2.8,1.9,4.8V29H61v-2.2h-0.1c-1.2,1.8-2.9,2.7-4.9,2.7 c-1.7,0-3.2-0.5-4.4-1.5c-1.1-1-1.8-2.4-1.8-3.9c0-1.6,0.6-2.9,1.8-3.9c1.2-1,2.9-1.4,4.9-1.4c1.8,0,3.2,0.3,4.3,1v-0.7 c0-1-0.4-2-1.2-2.6c-0.8-0.7-1.8-1.1-2.9-1.1c-1.7,0-3,0.7-3.9,2.1l-2.6-1.6C51.8,13.8,53.9,12.8,56.7,12.8z M52.9,24.2 c0,0.8,0.4,1.5,1,1.9c0.7,0.5,1.5,0.8,2.3,0.8c1.2,0,2.4-0.5,3.3-1.4c1-0.9,1.5-2,1.5-3.2c-0.9-0.7-2.2-1.1-3.9-1.1 c-1.2,0-2.2,0.3-3,0.9C53.3,22.6,52.9,23.3,52.9,24.2z"}),/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M80,13.3l-9.9,22.7h-3l3.7-7.9l-6.5-14.7h3.2l4.7,11.3h0.1l4.6-11.3H80z"}),/*#__PURE__*/t("path",{style:{fill:"#4285F4"},d:"M25.9,17.7c0-0.9-0.1-1.8-0.2-2.7H13.2v5.1h7.1c-0.3,1.6-1.2,3.1-2.6,4v3.3H22C24.5,25.1,25.9,21.7,25.9,17.7z"}),/*#__PURE__*/t("path",{style:{fill:"#34A853"},d:"M13.2,30.6c3.6,0,6.6-1.2,8.8-3.2l-4.3-3.3c-1.2,0.8-2.7,1.3-4.5,1.3c-3.4,0-6.4-2.3-7.4-5.5H1.4v3.4 C3.7,27.8,8.2,30.6,13.2,30.6z"}),/*#__PURE__*/t("path",{style:{fill:"#FBBC04"},d:"M5.8,19.9c-0.6-1.6-0.6-3.4,0-5.1v-3.4H1.4c-1.9,3.7-1.9,8.1,0,11.9L5.8,19.9z"}),/*#__PURE__*/t("path",{style:{fill:"#EA4335"},d:"M13.2,9.4c1.9,0,3.7,0.7,5.1,2l0,0l3.8-3.8c-2.4-2.2-5.6-3.5-8.8-3.4c-5,0-9.6,2.8-11.8,7.3l4.4,3.4 C6.8,11.7,9.8,9.4,13.2,9.4z"})]}),qu=e=>{let[t,n]=s();return o((()=>{e().then((e=>{n(e)})).catch((()=>{}))}),[]),t},Ku=()=>window.open(void 0,void 0,Yu({w:440,h:680}));let Yu=({w:e,h:t})=>{let n=void 0!==window.screenLeft?window.screenLeft:window.screenX,r=void 0!==window.screenTop?window.screenTop:window.screenY,a=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,i=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;return`toolbar=0,location=0,menubar=0,height=${t},width=${e},popup=1,left=${(a-e)/2/(a/window.screen.availWidth)+n},top=${(i-t)/2/(i/window.screen.availHeight)+r}`};let Zu={[Rr.id]:"ethereum",[Or.id]:"base",[Wr.id]:"optimism",[Mr.id]:"polygon",[Pr.id]:"arbitrum"};const Ju=(e,t,n,r,a,i)=>new Promise((async(o,s)=>{let l=Ku();if(!l)return void s(Error("Unable to initialize flow"));let c="ethereum"===t.chainType?function(e){let t=Zu[e];if(!t)throw new T(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}(t.chain.id):"solana",d=t.isUSDC?"USDC":"ethereum"===t.chainType?"ETH":"SOL",h=await e.initCoinbaseOnRamp({addresses:[{address:t.address,blockchains:[c]}],assets:[d]}),{url:u}=_i({input:h,amount:t.amount,blockchain:c,asset:d,experience:i});l.location=u.toString();let p={...a?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(p.usingDefaultFundingMethod=!1),n({funding:p,coinbaseOnrampStatus:{popup:l}}),r(ur.COINBASE_ONRAMP_STATUS_SCREEN),e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),setTimeout((()=>{n({funding:p,coinbaseOnrampStatus:{partnerUserId:h.partner_user_id,popup:l}})}),5e3),o()})),Qu=async(e,t,n,r,a,i,o,s)=>{let l=Ku();if(!l)throw Error("Unable to initialize flow");let c="ethereum"===t.chainType?t.moonpayConfigOverride?.currencyCode??ki(t.chain.id,r):"SOL",{signedUrl:d,externalTransactionId:h}=await e.signMoonpayOnRampUrl({address:t.address,useSandbox:n.fundingMethodConfig.moonpay.useSandbox??!1,config:{uiConfig:{accentColor:n.appearance.palette.accent,theme:n.appearance.palette.colorScheme},...t.moonpayConfigOverride,paymentMethod:s,currencyCode:c,quoteCurrencyAmount:t.moonpayConfigOverride?.quoteCurrencyAmount??da(t.amount)}});e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"moonpay",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),l.location=d;let u={...o?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(u.usingDefaultFundingMethod=!1),a({moonpayStatus:{},funding:u}),i(ur.MOONPAY_STATUS_SCREEN),setTimeout((()=>{a({moonpayStatus:{externalTransactionId:h},funding:u})}),8e3)};let Xu=async e=>"undefined"!=typeof window&&"PaymentRequest"in window&&await new window.PaymentRequest([{supportedMethods:e}],{id:"0",total:{label:"Item",amount:{currency:"USD",value:"1.00"}}}).canMakePayment();const ep=()=>Xu("https://apple.com/apple-pay"),tp=()=>Xu("https://google.com/pay");let np=({...e})=>/*#__PURE__*/t(ss,{color:"black",...e}),rp={devnet:"Devnet","mainnet-beta":"Solana",testnet:"Testnet"};const ap=({size:n=61,...r})=>/*#__PURE__*/t("svg",{width:n,height:n,viewBox:"0 0 61 61",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:/*#__PURE__*/e("g",{id:"moonpay_symbol_wht 2",children:[/*#__PURE__*/t("rect",{x:"1.3374",y:"1",width:"59",height:"59",rx:"11.5",fill:"#7715F5"}),/*#__PURE__*/t("path",{id:"Vector",d:"M43.8884 23.3258C45.0203 23.3258 46.1268 22.9901 47.068 22.3613C48.0091 21.7324 48.7427 20.8386 49.1759 19.7928C49.6091 18.747 49.7224 17.5962 49.5016 16.4861C49.2807 15.3759 48.7357 14.3561 47.9353 13.5557C47.1349 12.7553 46.1151 12.2102 45.0049 11.9893C43.8947 11.7685 42.7439 11.8819 41.6982 12.3151C40.6524 12.7482 39.7585 13.4818 39.1297 14.423C38.5008 15.3641 38.1651 16.4707 38.1651 17.6026C38.165 18.3542 38.3131 19.0985 38.6007 19.7929C38.8883 20.4873 39.3098 21.1182 39.8413 21.6496C40.3728 22.1811 41.0037 22.6027 41.6981 22.8903C42.3925 23.1778 43.1367 23.3259 43.8884 23.3258ZM26.3395 49.1017C23.5804 49.1017 20.8832 48.2836 18.5891 46.7507C16.295 45.2178 14.5069 43.039 13.4511 40.49C12.3952 37.9409 12.1189 35.1359 12.6572 32.4298C13.1955 29.7237 14.5241 27.238 16.4751 25.287C18.4262 23.336 20.9118 22.0074 23.6179 21.4691C26.324 20.9308 29.129 21.2071 31.6781 22.2629C34.2272 23.3189 36.406 25.1069 37.9389 27.401C39.4717 29.6952 40.2899 32.3923 40.2899 35.1514C40.2899 36.9835 39.9291 38.7975 39.2281 40.49C38.527 42.1826 37.4994 43.7205 36.204 45.0159C34.9086 46.3113 33.3707 47.3389 31.6781 48.04C29.9856 48.741 28.1715 49.1018 26.3395 49.1017Z",fill:"white"})]})});let ip=({status:r,onClickCta:a})=>{let{title:o,body:s,cta:l}=i((()=>(e=>{switch(e){case"completed":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"waitingAuthorization":return{title:"Processing payment",body:"This may take up to a few hours. You will receive an email when the purchase is complete.",cta:"Continue"};default:return{title:"In Progress",body:"Go back to MoonPay to finish funding your account.",cta:""}}})(r)),[r]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(lp,{children:[/*#__PURE__*/t(op,{status:r}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t("h3",{children:o}),/*#__PURE__*/t(sp,{children:s})]})]}),l&&/*#__PURE__*/t(ct,{onClick:a,children:l})]})},op=({status:n})=>{if(!n||"pending"===n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t($t,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(ln,{color:n}),/*#__PURE__*/t(ap,{size:"3rem",style:{position:"absolute",top:"1rem",left:"1rem"}})]})}let r=(e=>{switch(e){case"completed":return si;case"waitingAuthorization":return()=>/*#__PURE__*/t(Ji,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}});default:return}})(n),a=(e=>e?{completed:"var(--privy-color-success)",failed:"var(--privy-color-error)",serviceFailure:"var(--privy-color-error)",waitingAuthorization:"var(--privy-color-accent)",pending:"var(--privy-color-foreground-4)"}[e]:"var(--privy-color-foreground-4)")(n);/*#__PURE__*/return t("div",{style:{borderColor:a,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:r&&/*#__PURE__*/t(r,{width:"4rem",height:"4rem",color:a})})},sp=/*#__PURE__*/Ka.p.withConfig({displayName:"StatusBody",componentId:"sc-56bea42a-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),lp=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-56bea42a-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const cp=({onClick:n,text:r})=>/*#__PURE__*/e(rl,{onClick:n,children:[/*#__PURE__*/t(Xa,{}),/*#__PURE__*/t(Js,{children:r}),/*#__PURE__*/t(to,{})]});let dp=({onClick:n,icon:r,name:a,chainType:i})=>/*#__PURE__*/e(rl,{onClick:n,children:[/*#__PURE__*/t(Tu,{style:{width:20},children:/*#__PURE__*/t("img",{src:r})}),a,/*#__PURE__*/t(Et,{color:"gray",style:{marginLeft:"auto"},children:"Connected"}),"solana"===i&&/*#__PURE__*/t(Et,{color:"gray",children:"Solana"})]});let hp=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledCircle",componentId:"sc-30eca48b-0"})(["border-radius:50%;height:68px;width:68px;display:flex;align-items:center;justify-content:center;background-color:var(--privy-color-accent);color:white;margin:0 auto 24px auto;"]);const up=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"17",height:"17",viewBox:"0 0 17 17",style:{height:"1.25rem",width:"1.25rem",...e},...n,children:/*#__PURE__*/t("path",{strokeLinecap:"round",strokeLinejoin:"round",fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 8.67993C16.5 9.82986 15.853 10.8287 14.9032 11.3322C15.2188 12.3599 14.97 13.5237 14.1569 14.3368C13.3437 15.1499 12.18 15.3987 11.1523 15.0831C10.6488 16.0329 9.64993 16.6799 8.5 16.6799C7.35007 16.6799 6.35126 16.0329 5.84771 15.0831C4.82003 15.3987 3.65627 15.1499 2.84314 14.3368C2.03001 13.5237 1.78124 12.3599 2.09681 11.3322C1.14699 10.8287 0.5 9.82986 0.5 8.67993C0.5 7.53 1.14699 6.53119 2.0968 6.02764C1.78125 4.99996 2.03003 3.83621 2.84315 3.02309C3.65627 2.20997 4.82002 1.96119 5.8477 2.27675C6.35125 1.32692 7.35007 0.679932 8.5 0.679932C9.64992 0.679932 10.6487 1.32691 11.1523 2.27672C12.18 1.96115 13.3437 2.20993 14.1569 3.02305C14.97 3.83618 15.2188 4.99996 14.9032 6.02764C15.853 6.53119 16.5 7.53 16.5 8.67993ZM12.2659 6.68856C12.5654 6.40238 12.5761 5.92763 12.29 5.62818C12.0038 5.32873 11.529 5.31797 11.2296 5.60416C9.73022 7.03711 8.40877 8.65489 7.3018 10.4211L5.78033 8.89963C5.48744 8.60673 5.01256 8.60673 4.71967 8.89963C4.42678 9.19252 4.42678 9.66739 4.71967 9.96029L6.92031 12.1609C7.08544 12.3261 7.31807 12.4048 7.54957 12.374C7.78106 12.3432 7.98499 12.2064 8.1012 12.0038C9.23027 10.0356 10.6362 8.24613 12.2659 6.68856Z",fill:"var(--privy-color-accent)"})}),pp=/*#__PURE__*/Ka.div.withConfig({displayName:"TodoList",componentId:"sc-491785d-0"})(["display:flex;flex-direction:column;justify-content:flex-start;gap:4px;"]),mp=/*#__PURE__*/Ka.div.withConfig({displayName:"TodoSpacer",componentId:"sc-491785d-1"})(["&&&{margin-left:7px;border-left:2px solid var(--privy-color-foreground-4);height:12px;}"]),yp=({children:n})=>/*#__PURE__*/e(gp,{children:[/*#__PURE__*/t(up,{style:{width:"16px",height:"16px"}}),n]});let gp=/*#__PURE__*/Ka.div.withConfig({displayName:"TodoItemWrapper",componentId:"sc-491785d-2"})(["display:flex;justify-content:flex-start;justify-items:center;text-align:left;gap:8px;&&{a{text-decoration:underline;color:var(--privy-color-accent);}svg{margin-top:auto;margin-bottom:auto;}}"]),fp=({name:n,installLink:r})=>/*#__PURE__*/e(zt,{children:[/*#__PURE__*/t(Kl,{title:`Create a ${n} wallet`.replace(/wallet wallet/gi,"wallet"),description:"Follow the instructions below to get started."}),/*#__PURE__*/e(pp,{children:[/*#__PURE__*/t(yp,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t("span",{children:"Install the "})," ",/*#__PURE__*/e("a",{href:r,target:"_blank",children:[n," browser extension"]})]})}),/*#__PURE__*/t(mp,{}),/*#__PURE__*/t(yp,{children:"Set up your first wallet"}),/*#__PURE__*/t(mp,{}),/*#__PURE__*/t(yp,{children:"Store your recovery phrase in a safe place!"})]}),/*#__PURE__*/t(mn,{onClick:()=>window.location.reload(),style:{marginTop:"20px"},children:"Reload the page to use your wallet"})]});let wp={apple_oauth:"apple",custom_auth:"custom",discord_oauth:"discord",email:"email",farcaster:"farcaster",github_oauth:"github",google_oauth:"google",instagram_oauth:"instagram",linkedin_oauth:"linkedin",passkey:"passkey",phone:"sms",spotify_oauth:"spotify",telegram:"telegram",tiktok_oauth:"tiktok",twitter_oauth:"twitter",wallet:"siwe",smart_wallet:"siwe",cross_app:"privy:",guest:"guest"};const vp=e=>{let t=wp[e];return"wallet"===e||"phone"===e?{displayName:e,loginMethod:t}:{displayName:t,loginMethod:t}},Cp=()=>{let{app:e}=hr(),n=e?.appearance?.logo,r=`${e?.name} logo`,i={maxHeight:"90px",maxWidth:"180px"};return n?"string"==typeof n?/*#__PURE__*/t("img",{src:n,alt:r,style:i}):"svg"===n.type||"img"===n.type?/*#__PURE__*/a.cloneElement(n,{alt:r,style:i}):(console.warn("`config.appearance.logo` must be a string, or an SVG / IMG element. Nothing will be rendered."),null):null},Ep=e=>{let{app:n}=hr();return n?.appearance.logo?/*#__PURE__*/t(Tp,{...e,children:/*#__PURE__*/t(Cp,{})}):null},Tp=/*#__PURE__*/Ka.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a206bd44-0"})(["display:flex;flex-direction:column;align-items:center;padding:24px 0;flex-grow:1;justify-content:center;"]),bp=({appId:r})=>{let[a,i]=s(void 0),{startCrossAppAuthFlow:l,authenticated:c}=mr(),{client:d}=x();return o((()=>{(async()=>{d&&i(await d.getCrossAppProviderDetails(r))})()}),[d]),/*#__PURE__*/t(rl,{onClick:()=>l({appId:r,action:c?"link":"login"}),disabled:!a,children:a?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Nc,{name:a.name,logoUrl:a.icon_url||void 0,size:"24px"})," ",a.name]}):/*#__PURE__*/t(Yt,{})})},Ap=/*#__PURE__*/h(((r,a)=>{let[i,l]=s(r.defaultValue||""),[c,d]=s(""),[h,u]=s(!1),{authenticated:p}=mr(),{initLoginWithEmail:m}=x(),{navigate:y,setModalData:g,currentScreen:f,data:w}=hr(),{enabled:v,token:C}=st(),[E,T]=s(!1),{accountType:b}=wt(),_=pr();o((()=>{!i&&_.disablePlusEmails&&w?.inlineError?.error instanceof M&&w?.inlineError?.error.privyErrorCode===A.DISALLOWED_PLUS_EMAIL&&!c&&d("Please enter a valid email address without a '+'."),c&&d("")}),[i]);let k=yn(i),I=h||!k,N=()=>{g({inlineError:void 0}),!v||C||p?(e=>{u(!0),m({email:i,captchaToken:e,disableSignup:w?.login?.disableSignup,withPrivyUi:!0}).then((()=>{y(ur.AWAITING_PASSWORDLESS_CODE)})).catch((e=>{g({errorModalData:{error:e,previousScreen:f||ur.LANDING}}),y(ur.ERROR_SCREEN)})).finally((()=>{u(!1)}))})(C):(g({captchaModalData:{callback:e=>m({email:i,captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:ur.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:ur.ERROR_SCREEN}}),y(ur.CAPTCHA_SCREEN))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(_p,{children:[c&&/*#__PURE__*/t(Qt,{style:{display:"block",marginTop:"0.25rem",textAlign:"left"},children:c}),/*#__PURE__*/e(kp,{stacked:r.stacked,$error:!!c,children:[/*#__PURE__*/t(ii,{}),/*#__PURE__*/t("input",{ref:a,id:"email-input",className:"login-method-button",type:"email",placeholder:"your@email.com",onFocus:()=>T(!0),onChange:e=>l(e.target.value),onKeyUp:e=>{"Enter"===e.key&&N()},value:i,autoComplete:"email"}),"email"!==b||E?r.stacked?/*#__PURE__*/t("span",{}):/*#__PURE__*/t(gn,{isSubmitting:h,onClick:N,disabled:I,children:"Submit"}):/*#__PURE__*/t(Et,{color:"gray",children:"Recent"})]})]}),r.stacked?/*#__PURE__*/t(ct,{loadingText:null,loading:h,disabled:I,onClick:N,children:"Submit"}):null]})}));let _p=fn,kp=wn;const Ip=({isEditable:r,setIsEditable:a,defaultValue:i})=>{let o=l(null);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(il,{$if:!r,children:/*#__PURE__*/t(Ap,{ref:o,defaultValue:i})}),/*#__PURE__*/t(il,{$if:r,children:/*#__PURE__*/e(rl,{onClick:()=>{a(),setTimeout((()=>{o.current?.focus()}),0)},children:[/*#__PURE__*/t(ii,{})," Continue with Email"]})})]})},Np=()=>{let[n,r]=s(!1),{currentScreen:a,navigate:i,setModalData:o,data:l}=hr(),{enabled:c,token:d}=st(),{initLoginWithFarcaster:h}=x(),{accountType:u}=wt();/*#__PURE__*/return e(rl,{onClick:async()=>{r(!0);try{c&&!d?(o({captchaModalData:{callback:e=>h(e,l?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:ur.AWAITING_FARCASTER_CONNECTION,onErrorNavigateTo:ur.ERROR_SCREEN}}),i(ur.CAPTCHA_SCREEN)):(await h(d,l?.login?.disableSignup),i(ur.AWAITING_FARCASTER_CONNECTION))}catch(e){o({errorModalData:{error:e,previousScreen:a||ur.LANDING}}),i(ur.ERROR_SCREEN)}finally{r(!1)}},disabled:!1,children:[/*#__PURE__*/t(yh,{})," Farcaster",n&&/*#__PURE__*/t(Yt,{}),"farcaster"===u&&/*#__PURE__*/t(xp,{color:"gray",children:"Recent"})]})};let xp=/*#__PURE__*/Ka(Et).withConfig({displayName:"StyledChip",componentId:"sc-19f52850-0"})(["margin-left:auto;"]);const Sp=({...n})=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...n,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_2856_1743)",children:[/*#__PURE__*/t("path",{d:"M22.1673 8.24075V16.3642C22.1673 17.3256 21.3421 18.105 20.3241 18.105H17.0028M22.1673 8.24075C22.1673 7.27936 21.3421 6.5 20.3241 6.5H11.5302M22.1673 8.24075V8.42852C22.1673 9.03302 21.8352 9.59423 21.2901 9.91105L15.1463 13.4818C14.5539 13.8261 13.8067 13.8261 13.2143 13.4818L10.1621 11.5401",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),/*#__PURE__*/t("path",{d:"M3.12913 6.64816C0.508085 12.9507 3.49251 20.1847 9.79504 22.8057L11.5068 23.5176C12.4522 23.9108 13.7783 23.2222 14.1714 22.2768L14.6054 21.2333C14.7687 20.8406 14.6438 20.3871 14.3024 20.1334L11.2872 17.8927C10.9878 17.6702 10.5843 17.6488 10.2632 17.8384L9.11575 18.5156C8.78274 18.7121 8.3597 18.6844 8.07552 18.4221C5.94293 16.4542 4.77629 13.6264 4.90096 10.7273C4.91757 10.3409 5.19796 10.023 5.57269 9.92753L6.86381 9.59869C7.22522 9.50664 7.49627 9.20696 7.55169 8.83815L8.10986 5.12321C8.17306 4.70259 7.94188 4.29293 7.54915 4.1296L6.50564 3.69564C5.56026 3.30248 4.23416 3.99103 3.84101 4.9364L3.12913 6.64816Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_2856_1743",children:/*#__PURE__*/t("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]}),Rp=()=>{let{enabled:n,token:r}=st(),{navigate:a,setModalData:o,app:s,data:l}=hr(),{initLoginWithPasskey:c}=x(),d=()=>{s.loginConfig.passkeysForSignupEnabled?a(ur.SELECT_PASSKEY_SIGNUP_OR_LOGIN):(async()=>{n&&!r?(o({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>c({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:ur.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:ur.ERROR_SCREEN}}),a(ur.CAPTCHA_SCREEN)):(await c({withPrivyUi:!0}),o({passkeyAuthModalData:{passkeySignupFlow:!1}}),a(ur.AWAITING_PASSKEY_SYSTEM_DIALOGUE))})()};return 0===i((()=>{let e=l?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(s.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[s.loginMethods,l?.login])?/*#__PURE__*/e(rl,{onClick:d,children:[/*#__PURE__*/t(no,{})," Continue with passkey"]}):/*#__PURE__*/t(Wp,{onClick:d,children:"I have a passkey"})};let Op=/*#__PURE__*/Ya(["&&{width:100%;font-size:0.875rem;line-height:1rem;display:flex;gap:0.5rem;justify-content:center;align-items:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]);const Wp=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledLink",componentId:"sc-48dad958-0"})(["",""],Op),Mp=({value:n,onChange:r})=>/*#__PURE__*/t("select",{value:n,onChange:r,children:Ri.map((t=>/*#__PURE__*/e("option",{value:t.code,children:[t.code," +",t.callCode]},t.code)))}),Pp=/*#__PURE__*/h(((r,a)=>{let{app:i}=hr(),[l,c]=s(!1),{accountType:d}=wt(),[h,u]=s(""),[p,m]=s(i?.intl.defaultCountry??"US"),y=Oi(h,p),g=Wi(p),f=Mi(p),w=Pi(p),v=!y,[C,E]=s(!1),T=w.length,b=e=>{let t=e.target.value;m(t),u(""),r.onChange&&r.onChange({rawPhoneNumber:h,qualifiedPhoneNumber:Di(h,t),countryCode:t,isValid:Oi(h,p)})},A=(e,t)=>{try{let n=e.replace(/\D/g,"")===h.replace(/\D/g,"")?e:g.input(e);u(n),r.onChange&&r.onChange({rawPhoneNumber:n,qualifiedPhoneNumber:Di(e,t),countryCode:t,isValid:Oi(e,t)})}catch(e){console.error("Error processing phone number:",e)}},_=()=>{E(!0);let e=Di(h,p);r.onSubmit({rawPhoneNumber:h,qualifiedPhoneNumber:e,countryCode:p,isValid:Oi(h,p)}).finally((()=>E(!1)))};return o((()=>{if(r.defaultValue){let e=Li(r.defaultValue);g.reset(),b({target:{value:e.countryCode}}),A(e.phone,e.countryCode)}}),[r.defaultValue]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Lp,{children:/*#__PURE__*/e(Dp,{$callingCodeLength:T,$stacked:r.stacked,children:[/*#__PURE__*/t(Mp,{value:p,onChange:b}),/*#__PURE__*/t("input",{ref:a,id:"phone-number-input",className:"login-method-button",type:"tel",placeholder:f,onFocus:()=>c(!0),onChange:e=>{A(e.target.value,p)},onKeyUp:e=>{"Enter"===e.key&&_()},value:h,autoComplete:"tel"}),"phone"!==d||l||r.hideRecent?r.stacked||r.noIncludeSubmitButton?/*#__PURE__*/t("span",{}):/*#__PURE__*/t(gn,{isSubmitting:C,onClick:_,disabled:v,children:"Submit"}):/*#__PURE__*/t(Et,{color:"gray",children:"Recent"})]})}),r.stacked&&!r.noIncludeSubmitButton?/*#__PURE__*/t(ct,{loading:C,loadingText:null,onClick:_,disabled:v,children:"Submit"}):null]})}));let Lp=/*#__PURE__*/Ka.div.withConfig({displayName:"InputContainer",componentId:"sc-2a729487-0"})(["width:100%;"]),Dp=/*#__PURE__*/Ka.label.withConfig({displayName:"PhoneNumberInput",componentId:"sc-2a729487-1"})(["--country-code-dropdown-width:calc(54px + calc(12 * ","px));--phone-input-extra-padding-left:calc(12px + calc(3 * ","px));display:block;position:relative;width:100%;@media (min-width:441px){--country-code-dropdown-width:calc(52px + calc(10 * ","px));}&& > select{font-size:16px;height:24px;position:absolute;margin:13px calc(var(--country-code-dropdown-width) / 4);line-height:24px;width:var(--country-code-dropdown-width);background-color:var(--privy-color-background);background-size:auto;background-position-x:right;cursor:pointer;@media (min-width:441px){font-size:14px;width:var(--country-code-dropdown-width);}:focus{outline:none;box-shadow:none;}}&& > input{font-size:16px;line-height:24px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width:calc(100% - var(--country-code-dropdown-width));padding:12px 88px 12px calc(var(--country-code-dropdown-width) + var(--phone-input-extra-padding-left));padding-right:",";flex-grow:1;background:var(--privy-color-background);border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-mdlg);width:100%;:focus{outline:none;border-color:var(--privy-color-accent);}:autofill,:-webkit-autofill{background:var(--privy-color-background);}@media (min-width:441px){font-size:14px;padding-right:78px;}}&& > :last-child{right:16px;position:absolute;top:50%;transform:translate(0,-50%);}&& > button:last-child{right:0px;line-height:24px;padding:13px 17px;:focus{outline:none;border-color:var(--privy-color-accent);}}&& > input::placeholder{color:var(--privy-color-foreground-3);}"],(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$stacked?"16px":"88px"));const Up=({isEditable:r,setIsEditable:a,defaultValue:i})=>{let o=l(null),{authenticated:s}=mr(),{navigate:c,setModalData:d,currentScreen:h,data:u}=hr(),{initLoginWithSms:p}=x(),{enabled:m,token:y}=st();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(il,{$if:!r,children:/*#__PURE__*/t(Pp,{ref:o,onSubmit:async function({qualifiedPhoneNumber:e}){if(!m||y||s)try{await p({phoneNumber:e,captchaToken:y,withPrivyUi:!0,disableSignup:u?.login?.disableSignup}),c(ur.AWAITING_PASSWORDLESS_CODE)}catch(e){d({errorModalData:{error:e,previousScreen:h||ur.LANDING}}),c(ur.ERROR_SCREEN)}else d({captchaModalData:{callback:t=>p({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:u?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:ur.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:ur.ERROR_SCREEN}}),c(ur.CAPTCHA_SCREEN)},defaultValue:i})}),/*#__PURE__*/t(il,{$if:r,children:/*#__PURE__*/e(rl,{onClick:()=>{a(),setTimeout((()=>{o.current?.focus()}),0)},children:[/*#__PURE__*/t(oi,{})," Continue with SMS"]})})]})};let Fp={apple:{logo:/*#__PURE__*/t(Wo,{}),displayName:"Apple"},discord:{logo:/*#__PURE__*/t(Mo,{}),displayName:"Discord"},github:{logo:/*#__PURE__*/t(Po,{}),displayName:"GitHub"},google:{logo:/*#__PURE__*/t(Do,{}),displayName:"Google"},linkedin:{logo:/*#__PURE__*/t(Fo,{}),displayName:"LinkedIn"},spotify:{logo:/*#__PURE__*/t(Bo,{}),displayName:"Spotify"},instagram:{logo:/*#__PURE__*/t(Uo,{}),displayName:"Instagram"},twitter:{logo:/*#__PURE__*/t(Ho,{}),displayName:"Twitter"},tiktok:{logo:/*#__PURE__*/t(zo,{}),displayName:"TikTok"}};const Bp=({provider:n})=>{let{enabled:r,token:a}=st(),{navigate:i,setModalData:o,data:l}=hr(),[c,d]=s(!1),{initLoginWithOAuth:h}=x(),{accountType:u}=wt(),p=u?vp(u):null,{displayName:m,logo:y}=Fp[n];/*#__PURE__*/return e(rl,{onClick:()=>{d(!0),r&&!a?(o({captchaModalData:{callback:e=>h(n,e,l?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:ur.ERROR_SCREEN}}),i(ur.CAPTCHA_SCREEN)):h(n,void 0,l?.login?.disableSignup)},disabled:c,children:[y," ",m,p?.loginMethod===n&&/*#__PURE__*/t(zp,{color:"gray",children:"Recent"})]})};let zp=/*#__PURE__*/Ka(Et).withConfig({displayName:"StyledChip",componentId:"sc-7d3bb993-0"})(["margin-left:auto;"]);function Hp(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 240 240",...n,children:[/*#__PURE__*/t("defs",{children:/*#__PURE__*/e("linearGradient",{x1:"120",y1:"240",x2:"120",gradientUnits:"userSpaceOnUse",id:"telegram-linear-gradient",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#1d93d2"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#38b0e3"})]})}),/*#__PURE__*/t("title",{children:"Telegram_logo"}),/*#__PURE__*/t("circle",{cx:"120",cy:"120",r:"120",fill:"url(#telegram-linear-gradient)"}),/*#__PURE__*/t("path",{d:"M81.229,128.772l14.237,39.406s1.78,3.687,3.686,3.687,30.255-29.492,30.255-29.492l31.525-60.89L81.737,118.6Z",fill:"#c8daea"}),/*#__PURE__*/t("path",{d:"M100.106,138.878l-2.733,29.046s-1.144,8.9,7.754,0,17.415-15.763,17.415-15.763",fill:"#a9c6d8"}),/*#__PURE__*/t("path",{d:"M81.486,130.178,52.2,120.636s-3.5-1.42-2.373-4.64c.232-.664.7-1.229,2.1-2.2,6.489-4.523,120.106-45.36,120.106-45.36s3.208-1.081,5.1-.362a2.766,2.766,0,0,1,1.885,2.055,9.357,9.357,0,0,1,.254,2.585c-.009.752-.1,1.449-.169,2.542-.692,11.165-21.4,94.493-21.4,94.493s-1.239,4.876-5.678,5.043A8.13,8.13,0,0,1,146.1,172.5c-8.711-7.493-38.819-27.727-45.472-32.177a1.27,1.27,0,0,1-.546-.9c-.093-.469.417-1.05.417-1.05s52.426-46.6,53.821-51.492c.108-.379-.3-.566-.848-.4-3.482,1.281-63.844,39.4-70.506,43.607A3.21,3.21,0,0,1,81.486,130.178Z",fill:"#fff"})]})}const Vp=()=>{let{enabled:n,token:r}=st(),{navigate:a,setModalData:i,data:o}=hr(),[l,c]=s(!1),{initLoginWithTelegram:d}=x(),{accountType:h}=wt();async function u(e){try{await d(e,o?.login?.disableSignup),i({telegramAuthModalData:{seamlessAuth:!1}}),a(ur.TELEGRAM_AUTH_SCREEN)}catch(e){console.error(e),c(!1)}}/*#__PURE__*/return e(rl,{onClick:async function(){if(c(!0),n&&!r)return i({captchaModalData:{callback:u,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:ur.ERROR_SCREEN}}),void a(ur.CAPTCHA_SCREEN);await u(r)},disabled:l,children:[/*#__PURE__*/t(Hp,{}),"Telegram","telegram"===h&&/*#__PURE__*/t($p,{color:"gray",children:"Recent"})]})};let $p=/*#__PURE__*/Ka(Et).withConfig({displayName:"StyledChip",componentId:"sc-f716a3a1-0"})(["margin-left:auto;"]);const jp=({onClick:n,text:r,icon:a})=>/*#__PURE__*/e(rl,{onClick:n,children:[a,/*#__PURE__*/t(Js,{children:r}),/*#__PURE__*/t(to,{})]}),Gp=({connectOnly:r})=>{let{closePrivyModal:a,connectors:l}=x(),{data:c,onUserCloseViaDialogOrKeybindRef:d}=hr(),h=pr(),{accountType:u,walletClientType:p,chainType:m}=wt(),y=u?vp(u):null,g=c?.login,{email:f,sms:w,google:v,twitter:C,discord:E,github:T,spotify:b,instagram:A,tiktok:_,linkedin:k,apple:I,wallet:N,farcaster:S,telegram:R}=i((()=>g?.loginMethods?Ui(g.loginMethods,!0):null),[g])??h.loginMethods,{passkey:O}=h.loginMethods,W=[f&&"email",w&&"sms",v&&"google",C&&"twitter",E&&"discord",T&&"github",b&&"spotify",A&&"instagram",_&&"tiktok",k&&"linkedin",I&&"apple",S&&"farcaster",R&&"telegram"].filter((e=>!!e)),M=W.length>0,P=i((()=>N&&!M?"web3-first":N&&h?.appearance.loginGroupPriority||"web2-first"),[N,M,h?.appearance.loginGroupPriority]),L=h?.appearance.hideDirectWeb2Inputs,[D,U]=s("default"),[F,B]=s(Jp({mostRecentlyUsedAccountType:u,smsAvailable:w,emailAvailable:f,prefilledType:g?.prefill?.type}));o((()=>{B(Jp({mostRecentlyUsedAccountType:u,smsAvailable:w,emailAvailable:f,prefilledType:g?.prefill?.type}))}),[f,w,u]);let z=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{U("default")}),150)};d.current=z;let H=[];p&&N?H.push(p):y?.loginMethod&&W.includes(y.loginMethod)&&H.push(y.loginMethod);let V=e=>"email"===e?/*#__PURE__*/t(Ip,{isEditable:"email"===F,setIsEditable:()=>{B("email")},defaultValue:"email"===g?.prefill?.type?g.prefill.value:void 0},e):"sms"===e?/*#__PURE__*/t(Up,{isEditable:"sms"===F,setIsEditable:()=>{B("sms")},defaultValue:"phone"===g?.prefill?.type?g.prefill.value:void 0},e):"apple"===e?/*#__PURE__*/t(Bp,{provider:"apple"},e):"discord"===e?/*#__PURE__*/t(Bp,{provider:"discord"},e):"farcaster"===e?/*#__PURE__*/t(Np,{},e):"github"===e?/*#__PURE__*/t(Bp,{provider:"github"},e):"google"===e?/*#__PURE__*/t(Bp,{provider:"google"},e):"linkedin"===e?/*#__PURE__*/t(Bp,{provider:"linkedin"},e):"tiktok"===e?/*#__PURE__*/t(Bp,{provider:"tiktok"},e):"spotify"===e?/*#__PURE__*/t(Bp,{provider:"spotify"},e):"instagram"===e?/*#__PURE__*/t(Bp,{provider:"instagram"},e):"twitter"===e?/*#__PURE__*/t(Bp,{provider:"twitter"},e):"telegram"===e?/*#__PURE__*/t(Vp,{},e):kc({walletList:h.appearance.walletList,walletChainType:g?.walletChainType??h.appearance.walletChainType,connectors:l,connectOnly:r,ignore:[],walletConnectEnabled:h.externalWallets.walletConnect.enabled,forceWallet:{wallet:e,chainType:m??"ethereum"}}),$=kc({walletList:h.appearance.walletList.filter((e=>e!==p)),walletChainType:g?.walletChainType??h.appearance.walletChainType,connectors:l,connectOnly:r,ignore:[...h.appearance.walletList,p],walletConnectEnabled:h.externalWallets.walletConnect.enabled}),j=W.filter((e=>e!==y?.loginMethod)).flatMap(V),G=H.flatMap(V);"web3-first"===P&&"default"===D?$.unshift(...G):"web2-first"===P&&j.unshift(...G);let q=W.filter((e=>"email"!==e&&"sms"!==e)),K=Kp({priority:P,email:f,sms:w,social:q}),Y=Yp({priority:P,email:f,sms:w,social:q}),Z=/*#__PURE__*/t(cp,{text:Zp({priority:P}),onClick:()=>U("web3-overflow")}),J=/*#__PURE__*/t(jp,{text:K,icon:Y,onClick:()=>U("web2-overflow")}),Q=L?0:1,X=N&&$.length>0,ee=0===j.length&&N&&0===$.length,te=5-(X?1:0),ne=$.length>0?$:/*#__PURE__*/t(mc,{chainType:h.appearance.walletChainType,withPadding:!0});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{title:h.appearance.landingHeader,onClose:z,backFn:"default"===D?void 0:()=>{U("default")}}),"default"===D&&/*#__PURE__*/t(qp,{}),"default"===D&&("string"==typeof h.appearance.loginMessage?/*#__PURE__*/t(nl,{children:h.appearance.loginMessage}):h.appearance.loginMessage),/*#__PURE__*/t(Qs,{style:{overflow:"hidden",padding:2},children:/*#__PURE__*/e(Xs,{children:["default"===D&&"web2-first"===P&&/*#__PURE__*/e(n,{children:[j.length>te?j.slice(0,te-1):j,j.length>te&&J,X&&Z,ee&&/*#__PURE__*/t(mc,{chainType:h.appearance.walletChainType})]}),"default"===D&&"web3-first"===P&&/*#__PURE__*/e(n,{children:[N&&/*#__PURE__*/e(n,{children:[$.length>te?$.slice(0,te-1):$,$.length>te&&Z]}),j.length>Q&&J,j.length===Q&&j[0],ee&&/*#__PURE__*/t(mc,{chainType:h.appearance.walletChainType})]}),"web2-overflow"===D&&/*#__PURE__*/t(n,{children:"web3-first"===P?j:j.slice(3)}),"web3-overflow"===D?ne:[],O&&"default"===D&&/*#__PURE__*/t(Rp,{})]})}),h&&/*#__PURE__*/t(bt,{app:h}),/*#__PURE__*/t(ht,{})]})};let qp=/*#__PURE__*/Ka(Ep).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-65cd3bf6-0"})(["margin-bottom:16px;"]),Kp=({priority:e,email:t,sms:n,social:r})=>"web2-first"===e?"Other socials":t&&n&&r.length>0||t&&r.length>0?"Log in with email or socials":n&&r.length>0?"Log in with sms or socials":t&&n?"Continue with email or sms":t?"Continue with email":n?"Continue with sms":"Log in with a social account",Yp=({priority:e,email:n,sms:r,social:a})=>"web2-first"===e||a.length>0?/*#__PURE__*/t(Ti,{}):n&&r?/*#__PURE__*/t(Sp,{}):n?/*#__PURE__*/t(ii,{}):r?/*#__PURE__*/t(oi,{}):null,Zp=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const Jp=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:n,prefilledType:r})=>n&&("email"===e&&"phone"!==r||"email"===r)||!t||"phone"!==e&&"phone"!==r?"email":"sms",Qp=({connectOnly:r})=>{let{closePrivyModal:a,connectors:l}=x(),{app:c,onUserCloseViaDialogOrKeybindRef:d,data:h}=hr(),{appearance:{palette:{colorScheme:u}}}=pr(),{accountType:p,walletClientType:m,chainType:y}=wt(),g=p?vp(p):null,f=c.loginMethodsAndOrder?.primary??[],w=c.loginMethodsAndOrder?.overflow??[],v=i((()=>[...f,...w]),[f,w]),C=c.loginMethods.passkey,E=h?.login,T=[];m&&v.includes(m)?T.push(m):p&&v.includes(g?.loginMethod)&&T.push(g?.loginMethod);let[b,A]=s("default"),[_,k]=s(Jp({mostRecentlyUsedAccountType:p,smsAvailable:v.includes("sms"),emailAvailable:v.includes("email"),prefilledType:E?.prefill?.type}));o((()=>{k(Jp({mostRecentlyUsedAccountType:p,smsAvailable:v.includes("sms"),emailAvailable:v.includes("email"),prefilledType:E?.prefill?.type}))}),[v,p]),o((()=>{"phone"===p&&k("sms");let e=v.indexOf("sms"),t=v.indexOf("email");e>-1&&e<t&&k("sms")}),[p,f,w]);let I=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{A("default")}),150)};d.current=I;let N=e=>"email"===e?/*#__PURE__*/t(Ip,{isEditable:"email"===_,setIsEditable:()=>{k("email")},defaultValue:"email"===E?.prefill?.type?E.prefill.value:void 0},e):"sms"===e?/*#__PURE__*/t(Up,{isEditable:"sms"===_,setIsEditable:()=>{k("sms")},defaultValue:"phone"===E?.prefill?.type?E.prefill.value:void 0},e):"apple"===e?/*#__PURE__*/t(Bp,{provider:"apple"},e):"discord"===e?/*#__PURE__*/t(Bp,{provider:"discord"},e):"farcaster"===e?/*#__PURE__*/t(Np,{},e):"github"===e?/*#__PURE__*/t(Bp,{provider:"github"},e):"google"===e?/*#__PURE__*/t(Bp,{provider:"google"},e):"linkedin"===e?/*#__PURE__*/t(Bp,{provider:"linkedin"},e):"spotify"===e?/*#__PURE__*/t(Bp,{provider:"spotify"},e):"instagram"===e?/*#__PURE__*/t(Bp,{provider:"instagram"},e):"tiktok"===e?/*#__PURE__*/t(Bp,{provider:"tiktok"},e):"twitter"===e?/*#__PURE__*/t(Bp,{provider:"twitter"},e):"telegram"===e?/*#__PURE__*/t(Vp,{},e):e.startsWith("privy:")?/*#__PURE__*/t(bp,{appId:e.replace("privy:","")},e):kc({walletList:c.appearance.walletList,walletChainType:E?.walletChainType??c.appearance.walletChainType,connectors:l,connectOnly:r,ignore:v,walletConnectEnabled:c.externalWallets.walletConnect.enabled,forceWallet:{wallet:e,chainType:y??"ethereum"}}),S=T.flatMap(N),R=f.filter((e=>e!==m&&e!==g?.loginMethod)).flatMap(N),O=w.filter((e=>e!==m&&e!==g?.loginMethod)).flatMap(N),[W,M]=vn([...S,...R,...O],Xp({primary:R.length+S.length,overflow:O.length}));/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{title:c.appearance.landingHeader,onClose:I,backFn:"default"===b?void 0:()=>{A("default")}}),"default"===b&&/*#__PURE__*/t(em,{}),"default"===b&&("string"==typeof c.appearance.loginMessage?/*#__PURE__*/t(nl,{children:c.appearance.loginMessage}):c.appearance.loginMessage),/*#__PURE__*/t(Qs,{style:{overflow:"hidden"},children:/*#__PURE__*/e(el,{$colorScheme:u,children:["default"===b&&/*#__PURE__*/e(n,{children:[W,M.length>0&&/*#__PURE__*/t(jp,{text:"More options",icon:/*#__PURE__*/t(Ti,{}),onClick:()=>A("overflow")})]}),"overflow"===b&&/*#__PURE__*/t(n,{children:M}),C&&"default"===b&&/*#__PURE__*/t(Rp,{})]})}),c&&/*#__PURE__*/t(bt,{app:c}),/*#__PURE__*/t(ht,{})]})};let Xp=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,em=/*#__PURE__*/Ka(Ep).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-aacc6cb6-0"})(["margin-bottom:16px;"]);const tm=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"164",height:"164",viewBox:"0 0 164 164",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...n},...r,children:[/*#__PURE__*/t("circle",{cx:"82",cy:"82",r:"80",stroke:"#EC6351","stroke-width":"4","stroke-linecap":"round"}),/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M81.9999 100.788C93.3288 100.788 102.513 91.6043 102.513 80.2754C102.513 68.9465 93.3288 59.7626 81.9999 59.7626C70.671 59.7626 61.4871 68.9465 61.4871 80.2754C61.4871 91.6043 70.671 100.788 81.9999 100.788ZM88.3236 71.8304C88.9093 71.2446 89.8591 71.2446 90.4449 71.8304C91.0307 72.4161 91.0307 73.3659 90.4449 73.9517L84.121 80.2756L90.445 86.5996C91.0308 87.1854 91.0308 88.1351 90.445 88.7209C89.8592 89.3067 88.9095 89.3067 88.3237 88.7209L81.9997 82.3969L75.6756 88.7209C75.0899 89.3067 74.1401 89.3067 73.5543 88.7209C72.9685 88.1351 72.9685 87.1854 73.5543 86.5996L79.8783 80.2756L73.5544 73.9517C72.9686 73.3659 72.9686 72.4161 73.5544 71.8304C74.1402 71.2446 75.09 71.2446 75.6758 71.8304L81.9997 78.1543L88.3236 71.8304Z",fill:"#EC6351"})]});function nm(){let{promptMfa:e,init:t,submit:n,cancel:r,mfaMethods:a}=u(Lr);return{promptMfa:e,init:t,submit:n,cancel:r,mfaMethods:a}}function rm(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenroll:o,enrollInMfa:s}=u(Lr);return{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenrollWithSms:()=>o("sms"),unenrollWithTotp:()=>o("totp"),unenrollWithPasskey:e=>o("passkey",e),showMfaEnrollmentModal:()=>s(!0),closeMfaEnrollmentModal:()=>s(!1)}}const am=n=>/*#__PURE__*/e(im,{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"88",height:"89",viewBox:"0 0 88 89",...n,children:[/*#__PURE__*/t("rect",{y:"0.666016",width:"88",height:"88",rx:"44"}),/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M45.2463 20.9106C44.5473 20.2486 43.4527 20.2486 42.7537 20.9106C37.8798 25.5263 31.3034 28.3546 24.0625 28.3546C23.9473 28.3546 23.8323 28.3539 23.7174 28.3525C22.9263 28.3427 22.2202 28.8471 21.9731 29.5987C20.9761 32.6311 20.4375 35.8693 20.4375 39.2297C20.4375 53.5896 30.259 65.651 43.5482 69.0714C43.8446 69.1477 44.1554 69.1477 44.4518 69.0714C57.741 65.651 67.5625 53.5896 67.5625 39.2297C67.5625 35.8693 67.0239 32.6311 66.0269 29.5987C65.7798 28.8471 65.0737 28.3427 64.2826 28.3525C64.1677 28.3539 64.0527 28.3546 63.9375 28.3546C56.6966 28.3546 50.1202 25.5263 45.2463 20.9106ZM52.7249 40.2829C53.3067 39.4683 53.1181 38.3363 52.3035 37.7545C51.4889 37.1726 50.3569 37.3613 49.7751 38.1759L41.9562 49.1223L38.0316 45.1977C37.3238 44.4899 36.1762 44.4899 35.4684 45.1977C34.7605 45.9056 34.7605 47.0532 35.4684 47.761L40.9059 53.1985C41.2826 53.5752 41.806 53.7671 42.337 53.7232C42.868 53.6792 43.3527 53.4039 43.6624 52.9704L52.7249 40.2829Z"})]});let im=/*#__PURE__*/Ka.svg.withConfig({displayName:"StyledSvg",componentId:"sc-59fa943f-0"})(["height:90px;width:90px;> rect{","}> path{fill:white;}"],(e=>"success"===e.color?"fill: var(--privy-color-success);":"fill: var(--privy-color-accent);"));const om=({showIntro:r,userMfaMethods:a,appMfaMethods:i,userHasAuthSms:o,isTotpLoading:s,isPasskeyLoading:l,error:c,onClose:d,onBackToIntro:h,handleSelectMethod:u,setRemovingMfaMethod:p})=>{let m=a.reduce(((e,t)=>({...e,[t]:!0})),{}),y=i.reduce(((e,t)=>({...e,[t]:!0})),{});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:r?h:void 0,onClose:d},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(kl,{children:"Choose a verification method"}),a.length>0?/*#__PURE__*/t(Il,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/t(Il,{children:"How would you like to verify your identity? You can change this later."}),c&&/*#__PURE__*/t(Hl,{style:{marginTop:"1.25rem"},children:c.message}),/*#__PURE__*/e(Wl,{children:[(y.totp||m.totp)&&/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(rl,{style:{justifyContent:"center"},disabled:m.totp||s,onClick:()=>u("totp"),children:s?/*#__PURE__*/t($t,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/e(Ll,{children:[/*#__PURE__*/t(lo,{}),"Authenticator app"]}),m.totp?/*#__PURE__*/t(sm,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Dl,{children:"Recommended"})]})}),m.totp&&/*#__PURE__*/t(Pl,{style:{position:"absolute",right:0},onClick:()=>p("totp"),children:/*#__PURE__*/t(co,{})})]},"totp"),(y.sms||m.sms)&&/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(rl,{disabled:m.sms||o,onClick:()=>u("sms"),children:/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/e(Ll,{children:[/*#__PURE__*/t(oi,{}),"SMS"]}),m.sms&&/*#__PURE__*/t(sm,{color:"green",children:"Enabled"}),o&&/*#__PURE__*/t(Dl,{children:"Disabled"})]})}),m.sms&&/*#__PURE__*/t(Pl,{style:{position:"absolute",right:0},onClick:()=>p("sms"),children:/*#__PURE__*/t(co,{})})]},"sms"),(y.passkey||m.passkey)&&/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(rl,{style:{justifyContent:"center"},onClick:()=>u("passkey"),disabled:m.passkey||l,children:l?/*#__PURE__*/t($t,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/e(Ll,{children:[/*#__PURE__*/t(no,{}),"Passkey"]}),m.passkey?/*#__PURE__*/t(sm,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Dl,{isAccent:!0,children:/*#__PURE__*/t(to,{})})]})}),m.passkey&&/*#__PURE__*/t(Pl,{style:{position:"absolute",right:0},onClick:()=>p("passkey"),children:/*#__PURE__*/t(co,{})})]},"passkey")]}),/*#__PURE__*/t(ft,{})]})};let sm=/*#__PURE__*/Ka(Et).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const lm=({appName:e,onComplete:n,onClose:r,onReset:a})=>{let{user:o}=mr(),{data:l}=hr(),{initLinkWithPasskey:c,linkWithPasskey:d}=x(),{initEnrollmentWithPasskey:h,submitEnrollmentWithPasskey:u}=rm(),[p,m]=s(!1),[y,g]=s(!1),[f,w]=s(!1),[v,C]=s(null),E=i((()=>o?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[o]),T=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},b=async e=>{m(!0);try{await h(),await u({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),w(!0)}catch(e){C(e)}finally{m(!1)}},A=async()=>{g(!0),C(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await b(t)}catch(e){C(e)}finally{g(!1)}};return 0===E.length||y?/*#__PURE__*/t(cm,{onReset:a,onClose:r,onClick:A,isCreating:y}):f?/*#__PURE__*/t(hm,{appName:e,onClick:T,onClose:T}):v?/*#__PURE__*/t(oh,{error:v,backFn:()=>C(null),onClick:()=>C(null)}):/*#__PURE__*/t(dm,{passkeys:E,isSubmitting:p,isCreating:y,onReset:a,onClose:r,onSubmitEnrollment:()=>b(E.map((e=>e.credentialId))),onAddPasskey:A})};let cm=({onReset:r,onClose:a,onClick:i,isCreating:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{backFn:r,onClose:a},"header"),/*#__PURE__*/t(_l,{children:/*#__PURE__*/e(su,{children:[/*#__PURE__*/t(ru,{}),/*#__PURE__*/t(au,{})]})}),/*#__PURE__*/t(kl,{children:"Set up passkey verification"}),/*#__PURE__*/e(xl,{children:[/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(oo,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(ro,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(ho,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/t(ct,{style:{marginTop:"2.25rem"},onClick:i,loading:o,children:"Add a new passkey"}),/*#__PURE__*/t(ft,{})]}),dm=({onReset:r,onClose:a,onAddPasskey:i,onSubmitEnrollment:o,passkeys:l,isSubmitting:c,isCreating:d})=>{let[h,u]=s(!1),p=h?l.length:l.length>3?2:3;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:h?()=>u(!1):r,onClose:a},"header"),!h&&/*#__PURE__*/t(_l,{children:/*#__PURE__*/e(su,{children:[/*#__PURE__*/t(ru,{}),/*#__PURE__*/t(au,{})]})}),/*#__PURE__*/t(kl,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e(xl,{children:[l.slice(0,p).map((n=>/*#__PURE__*/e(um,{children:[/*#__PURE__*/t(pm,{children:ym(n)}),/*#__PURE__*/e(mm,{children:["Last used: ",n.latestVerifiedAt?.toLocaleString()]})]},n.credentialId))),!h&&l.length>3&&/*#__PURE__*/t(gm,{onClick:()=>u(!0),children:"View All"})]}),/*#__PURE__*/t(ct,{style:{marginTop:"1.5rem"},onClick:o,loading:c,children:"Enable passkeys"}),l.length<5&&/*#__PURE__*/t(gm,{style:{marginTop:"0.5rem"},onClick:i,disabled:d,children:d?/*#__PURE__*/t($t,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/t(ft,{})]})},hm=({appName:r,onClick:a,onClose:i})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:i},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(kl,{children:"Passkey verification added"}),/*#__PURE__*/e(Il,{children:["From now on, you'll use the passkey whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ct,{onClick:a,children:"Done"})}),/*#__PURE__*/t(ft,{})]}),um=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyItem",componentId:"sc-d5b2bf9c-0"})(["&&{padding:0.75rem 1rem;text-align:left;border-radius:0.5rem;border:1px solid var(--privy-color-foreground-4);width:100%;}"]),pm=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-d5b2bf9c-1"})(["font-size:0.875rem;line-height:1.375rem;font-weight:500;color:var(--privy-color-foreground-1);"]),mm=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-d5b2bf9c-2"})(["font-size:0.75rem;font-weight:400;line-height:1.125rem;color:var(--privy-color-foreground-2);"]),ym=e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device";const gm=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledLink",componentId:"sc-d5b2bf9c-3"})(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:0.75rem 1rem;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent);:focus{outline:none;box-shadow:none;}}"]);let fm=Array(6).fill("");var wm,vm=((wm=vm||{})[wm.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",wm[wm.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",wm);function Cm(e){return/^[0-9]{1}$/.test(e)}function Em(e){return 6===e.length&&e.every(Cm)}const Tm=({onChange:r,disabled:a,errorReasonOverride:i,success:o})=>{let[l,c]=s(fm),[d,h]=s(null),[u,p]=s(null),m=async e=>{e.preventDefault();let t=e.currentTarget.value.replace(/\s+/g,"");if(""===t)return;let n=l.reduce(((e,t)=>e+Number(Cm(t))),0),a=t.split(""),i=!a.every(Cm),o=a.length+n>6;if(i)return h("Passcode can only be numbers"),void p(1);if(o)return h("Passcode must be exactly 6 numbers"),void p(1);h(null),p(null);let s=Number(e.currentTarget.name?.charAt(4)),d=[...t||[""]].slice(0,6-s),u=[...l.slice(0,s),...d,...l.slice(s+d.length)];c(u);let m=Math.min(Math.max(s+d.length,0),5),y=document.querySelector(`input[name=pin-${m}]`);if(y?.focus(),Em(u))try{await r(u.join(""));let e=document.querySelector(`input[name=pin-${m}]`);e?.blur()}catch(e){p(1),h(e.message)}else try{await r(null)}catch(e){p(1),h(e.message)}},g=o?"success":!(!i&&!d)?"fail":"";/*#__PURE__*/return t(n,{children:/*#__PURE__*/e(bm,{children:[/*#__PURE__*/t("div",{children:l.map(((e,n)=>/*#__PURE__*/t("input",{name:`pin-${n}`,type:"text",value:l[n],onChange:m,onKeyUp:e=>{"Backspace"===e.key&&(e=>{1===u&&(h(null),p(null));let t=[...l.slice(0,e),"",...l.slice(e+1)];if(c(t),e>0){let t=document.querySelector(`input[name=pin-${e-1}]`);t?.focus()}Em(t)?r(t.join("")):r(null)})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:g,autoComplete:y?"one-time-code":"off",disabled:a},n)))}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Am,{$fail:!!i||!!d,children:i||d})})]})})};let bm=/*#__PURE__*/Ka.div.withConfig({displayName:"PinInputContainer",componentId:"sc-7a171f6-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;@media (max-width:440px){margin-top:8px;margin-bottom:8px;}> div:nth-child(1){display:flex;justify-content:center;gap:0.5rem;width:100%;border-radius:var(--privy-border-radius-md);> input{border:1px solid var(--privy-color-foreground-4);background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);padding:8px 10px;height:58px;width:46px;text-align:center;font-size:18px;}> input:disabled{background:var(--privy-color-background-2);}> input:focus{border:1px solid var(--privy-color-accent);}> input:invalid{border:1px solid var(--privy-color-error);}> input.success{border:1px solid var(--privy-color-success);}> input.fail{border:1px solid var(--privy-color-error);animation:shake 180ms;animation-iteration-count:2;}}@keyframes shake{0%{transform:translate(1px,0px);}33%{transform:translate(-1px,0px);}67%{transform:translate(-1px,0px);}100%{transform:translate(1px,0px);}}"]),Am=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-7a171f6-1"})(["line-height:20px;font-size:13px;display:flex;justify-content:flex-start;width:100%;color:",";"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)"));const _m=({appName:r,onComplete:a,onReset:i,onClose:o})=>{let[l,c]=s(""),[d,h]=s(!1),[u,p]=s(null),[m,y]=s("enroll"),{initEnrollmentWithSms:g,submitEnrollmentWithSms:f}=rm(),{app:w,data:v}=hr();function C(){v?.mfaEnrollmentFlow?.onSuccess(),a()}return u?/*#__PURE__*/t(oh,{error:u,backFn:()=>p(null),onClick:()=>p(null)}):/*#__PURE__*/e(n,"enroll"===m?{children:[/*#__PURE__*/t(lt,{backFn:i,onClose:o},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oi,{})}),/*#__PURE__*/t(kl,{children:"Set up SMS verification"}),/*#__PURE__*/e(Il,{children:["We'll text a verification code to this mobile device whenever you use your ",r," ","wallet."]}),/*#__PURE__*/e(Nl,{children:[/*#__PURE__*/t(Pp,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await g({phoneNumber:e}),c(e),y("verify")}catch(e){p(e)}},hideRecent:!0}),/*#__PURE__*/e(Fl,{children:["By providing your mobile number, you agree to receive text messages from ",w?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/t(ft,{})]}:d?{children:[/*#__PURE__*/t(lt,{onClose:C},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(kl,{children:"SMS verification added"}),/*#__PURE__*/e(Il,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ct,{onClick:C,children:"Done"})}),/*#__PURE__*/t(ft,{})]}:{children:[/*#__PURE__*/t(lt,{backFn:function(){"verify"===m?y("enroll"):i()},onClose:o},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oi,{})}),/*#__PURE__*/t(kl,{children:"Enter enrollment code"}),/*#__PURE__*/e(Nl,{children:[/*#__PURE__*/t(Tm,{onChange:async function(e){try{if(!e)return;await f({phoneNumber:l,mfaCode:e}),h(!0)}catch(e){if(jc(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Vc(e))throw Error("The code you entered is not valid");if(Hc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw Gc(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e(Il,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/t("strong",{children:Fi(l)})]})]}),/*#__PURE__*/t(ft,{})]})},km=({size:e,authUrl:n})=>/*#__PURE__*/t(Vt,{url:n,squareLogoElement:uo,size:e,fgColor:"#1F1F1F"}),Im=({onComplete:r,onClose:a,onReset:i,totpInfo:o})=>{let[l,c]=s("enroll"),[d,h]=s(!1),{submitEnrollmentWithTotp:u}=rm(),{data:p}=hr();function m(){p?.mfaEnrollmentFlow?.onSuccess(),r()}/*#__PURE__*/return e(n,"enroll"===l?{children:[/*#__PURE__*/t(lt,{backFn:i,onClose:a},"header"),/*#__PURE__*/t(kl,{children:"Scan QR code"}),/*#__PURE__*/t(Il,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/t(Ht,{children:/*#__PURE__*/t(km,{authUrl:o.authUrl,size:200})}),/*#__PURE__*/e(Ol,{children:[/*#__PURE__*/t(zt,{children:/*#__PURE__*/t(hh,{itemName:"setup key",text:o.secret})}),/*#__PURE__*/t(ct,{onClick:function(){c("verify")},children:"Continue"})]}),/*#__PURE__*/t(ft,{})]}:d?{children:[/*#__PURE__*/t(lt,{onClose:m},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(kl,{children:"Authenticator app verification added"}),/*#__PURE__*/e(Il,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",o.appName," wallet."]}),/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ct,{onClick:m,children:"Done"})}),/*#__PURE__*/t(ft,{})]}:{children:[/*#__PURE__*/t(lt,{backFn:function(){"verify"===l?c("enroll"):i()},onClose:a},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(lo,{})}),/*#__PURE__*/t(kl,{children:"Enter enrollment code"}),/*#__PURE__*/t(Nl,{children:/*#__PURE__*/t(Tm,{onChange:async function(e){try{if(!e)return;await u({mfaCode:e}),h(!0)}catch(e){if(jc(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Vc(e))throw Error("The code you entered is not valid");if(Hc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw Gc(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e(Il,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),/*#__PURE__*/t(ft,{})]})},Nm=({label:n,children:r,valueStyles:a})=>/*#__PURE__*/e(xm,{children:[/*#__PURE__*/t("div",{children:n}),/*#__PURE__*/t(Sm,{style:{...a},children:r})]});let xm=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledDetailsRow",componentId:"sc-4ebfdd45-0"})(["display:flex;align-items:center;justify-content:space-between;width:100%;> :first-child{color:var(--privy-color-foreground-3);text-align:left;}> :last-child{color:var(--privy-color-foreground-2);text-align:right;}"]),Sm=/*#__PURE__*/Ka.div.withConfig({displayName:"ValueWrapper",componentId:"sc-4ebfdd45-1"})(["font-size:14px;line-height:100%;display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-full);background-color:var(--privy-color-background-2);padding:4px 8px;"]);const Rm=({weiQuantities:e,tokenPrice:n,tokenSymbol:r})=>{let a=on(e),i=n?rn(a,n):void 0,o=Jt(a,r);/*#__PURE__*/return t(Mm,{children:i||o})},Om=({weiQuantities:r,tokenPrice:a,tokenSymbol:i})=>{let o=on(r),s=a?rn(o,a):void 0,l=Jt(o,i);/*#__PURE__*/return t(Mm,{children:s?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Pm,{children:"USD"}),"<$0.01"===s?
8
+ /*#__PURE__*/e(Dm,{children:[/*#__PURE__*/t(Lm,{children:"<"}),"$0.01"]}):s]}):l})},Wm=({quantities:r,tokenPrice:a,tokenSymbol:i="SOL",tokenDecimals:o=9})=>{let s=r.reduce(((e,t)=>e+t),0n),l=a&&"SOL"===i&&9===o?Mh(s,a):void 0,c="SOL"===i&&9===o?Wh(s):`${Ma(s,o)} ${i}`;/*#__PURE__*/return t(Mm,{children:l?/*#__PURE__*/t(n,{children:"<$0.01"===l?
9
+ /*#__PURE__*/e(Dm,{children:[/*#__PURE__*/t(Lm,{children:"<"}),"$0.01"]}):l}):c})};let Mm=/*#__PURE__*/Ka.span.withConfig({displayName:"StyledPriceDisplay",componentId:"sc-596cd423-0"})(["font-size:14px;line-height:140%;display:flex;gap:4px;align-items:center;"]),Pm=/*#__PURE__*/Ka.span.withConfig({displayName:"StyledPriceUnit",componentId:"sc-596cd423-1"})(["font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);"]),Lm=/*#__PURE__*/Ka.span.withConfig({displayName:"TinyLessThan",componentId:"sc-596cd423-2"})(["font-size:10px;"]),Dm=/*#__PURE__*/Ka.span.withConfig({displayName:"FlexCenter",componentId:"sc-596cd423-3"})(["display:flex;align-items:center;"]);const Um=({gas:n,tokenPrice:r,tokenSymbol:a})=>/*#__PURE__*/e(cn,{style:{paddingBottom:"12px"},children:[/*#__PURE__*/e(Bm,{children:[/*#__PURE__*/t(Hm,{children:"Est. Fees"}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Om,{weiQuantities:[BigInt(n)],tokenPrice:r,tokenSymbol:a})})]}),r&&/*#__PURE__*/t(zm,{children:`${Jt(BigInt(n),a)}`})]}),Fm=({value:n,gas:r,tokenPrice:a,tokenSymbol:i})=>{let o=BigInt(n??0)+BigInt(r);/*#__PURE__*/return e(cn,{children:[/*#__PURE__*/e(Bm,{children:[/*#__PURE__*/t(Hm,{children:"Total (including fees)"}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Om,{weiQuantities:[BigInt(n||0),BigInt(r)],tokenPrice:a,tokenSymbol:i})})]}),a&&/*#__PURE__*/t(zm,{children:Jt(o,i)})]})};let Bm=/*#__PURE__*/Ka.div.withConfig({displayName:"TransactionTotalRow",componentId:"sc-f8ef9b74-0"})(["display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-top:4px;"]),zm=/*#__PURE__*/Ka.div.withConfig({displayName:"ValueConversionRow",componentId:"sc-f8ef9b74-1"})(["display:flex;flex-direction:row;height:12px;font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);font-weight:400;"]),Hm=/*#__PURE__*/Ka.div.withConfig({displayName:"TotalText",componentId:"sc-f8ef9b74-2"})(["font-size:14px;line-height:22.4px;font-weight:400;"]);const Vm=/*#__PURE__*/p(void 0),$m=/*#__PURE__*/p(void 0),jm=({defaultValue:e,children:n})=>{let[r,a]=s(e||null);/*#__PURE__*/return t(Vm.Provider,{value:{activePanel:r,togglePanel:e=>{a(r===e?null:e)}},children:/*#__PURE__*/t(Zm,{children:n})})},Gm=({value:e,children:n})=>{let{activePanel:r,togglePanel:a}=u(Vm),i=r===e;/*#__PURE__*/return t($m.Provider,{value:{onToggle:()=>a(e),value:e},children:/*#__PURE__*/t(ey,{isActive:i,"data-open":i,children:n})})},qm=({children:r})=>{let{activePanel:a}=u(Vm),{onToggle:i,value:o}=u($m),s=a===o;/*#__PURE__*/
10
+ return e(n,{children:[/*#__PURE__*/e(Jm,{onClick:i,"data-open":s,children:[/*#__PURE__*/t(Xm,{children:r}),/*#__PURE__*/t(ry,{isactive:s,children:/*#__PURE__*/t(Zi,{height:"16px",width:"16px",strokeWidth:"2"})})]}),/*#__PURE__*/t(Qm,{})]})},Km=({children:e})=>{let{activePanel:n}=u(Vm),{value:r}=u($m);/*#__PURE__*/return t(ty,{"data-open":n===r,children:/*#__PURE__*/t(ny,{children:e})})},Ym=({children:e})=>{let{activePanel:n}=u(Vm),{value:r}=u($m);/*#__PURE__*/return t(ny,{children:"function"==typeof e?e({isActive:n===r}):e})};let Zm=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionRoot",componentId:"sc-281bf545-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;"]),Jm=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionTriggerContainer",componentId:"sc-281bf545-1"})(["display:flex;justify-content:space-between;align-items:center;width:100%;cursor:pointer;padding-bottom:8px;"]),Qm=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionDivider",componentId:"sc-281bf545-2"})(["width:100%;&&{border-top:1px solid;border-color:var(--privy-color-foreground-4);}padding-bottom:12px;"]),Xm=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-281bf545-3"})(["font-size:14px;font-weight:500;line-height:19.6px;width:100%;padding-right:8px;"]),ey=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionPanelContainer",componentId:"sc-281bf545-4"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;padding:12px;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),ty=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionContentContainer",componentId:"sc-281bf545-5"})(["position:relative;overflow:hidden;transition:max-height 25ms ease-out;&[data-open='true']{max-height:700px;}&[data-open='false']{max-height:0;}"]),ny=/*#__PURE__*/Ka.div.withConfig({displayName:"ContentWrapper",componentId:"sc-281bf545-6"})(["display:flex;flex-direction:column;gap:12px;flex:1 1 auto;min-height:1px;"]),ry=/*#__PURE__*/Ka.div.withConfig({displayName:"IconWrapper",componentId:"sc-281bf545-7"})(["transform:",";"],(e=>e.isactive?"rotate(180deg)":"rotate(0deg)"));const ay=({walletAddress:e,chainId:n=br,network:r,rpcEndpoint:a})=>/*#__PURE__*/t(iy,{href:"ethereum"===r?Cn(n,e):Dr(e,Ar(a||"")),target:"_blank",children:Tt(e)});let iy=/*#__PURE__*/Ka.a.withConfig({displayName:"StyledLink",componentId:"sc-adda23e5-0"})(["&:hover{text-decoration:underline;}"]);const oy=({from:n,to:r,txn:a,transactionInfo:i,tokenPrice:o,gas:s,tokenSymbol:l})=>{let c=BigInt(a?.value||0);/*#__PURE__*/
11
+ return t(jm,{...pr().render.standalone?{defaultValue:"details"}:{},children:/*#__PURE__*/e(Gm,{value:"details",children:[/*#__PURE__*/t(qm,{children:/*#__PURE__*/e(sy,{children:[/*#__PURE__*/t("div",{children:i?.title||"Details"}),/*#__PURE__*/t(ly,{children:/*#__PURE__*/t(Rm,{weiQuantities:[c],tokenPrice:o,tokenSymbol:l})})]})}),/*#__PURE__*/e(Km,{children:[/*#__PURE__*/t(Nm,{label:"From",children:/*#__PURE__*/t(ay,{walletAddress:n,chainId:a.chainId||br,network:"ethereum"})}),/*#__PURE__*/t(Nm,{label:"To",children:/*#__PURE__*/t(ay,{walletAddress:r,chainId:a.chainId||br,network:"ethereum"})}),i&&i.action&&/*#__PURE__*/t(Nm,{label:"Action",children:i.action}),s&&/*#__PURE__*/t(Um,{value:a.value,gas:s,tokenPrice:o,tokenSymbol:l})]}),/*#__PURE__*/t(Ym,{children:({isActive:e})=>/*#__PURE__*/t(Fm,{value:a.value,displayFee:e,gas:s||"0x0",tokenPrice:o,tokenSymbol:l})})]})})};let sy=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-29499c17-0"})(["display:flex;flex-direction:row;justify-content:space-between;"]),ly=/*#__PURE__*/Ka.div.withConfig({displayName:"TotalText",componentId:"sc-29499c17-1"})(["flex-shrink:0;padding-left:8px;"]);async function cy(e,t,n){let r=ps(e),a=await t.prepareTransactionRequest({...r,account:{address:n,type:"json-rpc"}});return{...a,type:hs[a.type]}}const dy=({pendingTransaction:e})=>{let{getAccessToken:n}=mr(),{wallets:r}=_r(),{walletProxy:a,rpcConfig:l,chains:c,appId:d,nativeTokenSymbolForChainId:h}=x(),[u,p]=s(null),[m,y]=s(e),{tokenPrice:g}=xh(m.chainId),f=h(e.chainId)||"ETH",w=i((()=>r.find((e=>"privy"===e.walletClientType))),[r]);return o((()=>{(async function(){if(!await n()||!a||!w)return m;let e=Ha(m.chainId,c,l,{appId:d}),t=await cy(m,e,w.address);return p(Na(BigInt(t.gas??0))),t})().then(y).catch(console.error)}),[a]),w?/*#__PURE__*/t(hy,{children:/*#__PURE__*/t(oy,{from:w.address,to:m.to,txn:m,gas:u??void 0,tokenPrice:g,tokenSymbol:f})}):null};let hy=/*#__PURE__*/Ka.div.withConfig({displayName:"TransactionInfoWrapper",componentId:"sc-731f1950-0"})(["width:100%;padding:1rem 0;"]);const uy=({hasBlockingError:r,error:a,onClose:i,onBack:o,handleSubmit:s,account:l,submitSuccess:c})=>{let{pendingTransaction:d}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:i},"header"),/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{success:c,fail:!!a}),/*#__PURE__*/t(a?Qa:ru,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/t(kl,{style:{marginTop:"1rem"},children:"Verifying with passkey"}),/*#__PURE__*/e(xl,{children:[/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(oo,{})}),"Approve this action using your touch, face, PIN, or hardware key."]}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(po,{})}),"You last added a passkey on"," ",l?.firstVerifiedAt?.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),"."]})]}),d&&/*#__PURE__*/t(Nl,{children:/*#__PURE__*/t(dy,{pendingTransaction:d})}),a&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Hl,{style:{marginTop:"1.25rem"},children:a.message}),/*#__PURE__*/t(ct,{disabled:r,onClick:s,style:{marginTop:"1.25rem"},children:"Try again"})]}),o&&/*#__PURE__*/t(Bl,{style:{marginTop:"1rem"},onClick:o,children:"Choose another method"}),/*#__PURE__*/t(ft,{})]})},py=({open:r,onClose:a})=>{let{user:i}=mr(),[c,d]=s(i?.mfaMethods[0]??null),{init:h,cancel:u,submit:p}=nm(),[m,y]=s(!1),[g,f]=s(!1),[w,v]=s(null),[C,E]=s(null);o((()=>{d(i?.mfaMethods[0]??null)}),[i?.mfaMethods]);let T=l(!1);o((()=>{!T.current&&c&&r&&(T.current=!0,_(c).finally((()=>{T.current=!1})))}),[r]);let b=e=>$c(e)?(y(!0),Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")):Vc(e)?(y(!1),Error("The code you entered is not valid")):Hc(e)?(y(!0),Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")):(console.error(e),y(!1),Error("Something went wrong."));async function A(e){E(null);try{if(!e||!c)return;await p(c,e),f(!0),y(!1),a()}catch(e){throw b(e)}}async function _(e){if("passkey"!==e)try{d(e),await h(e)}catch(e){console.error(e)}else try{d(e);let t=await h(e);if(!t)throw Error("something went wrong");v(t),await p(e,t),f(!0),y(!1),a()}catch(e){E(b(e))}}let k=()=>{d(null),E(null),u(),a()};return r&&i?"passkey"===c?/*#__PURE__*/t(uy,{account:i.linkedAccounts.filter((e=>"passkey"===e.type&&e.enrolledInMfa)).sort(((e,t)=>t.firstVerifiedAt.valueOf()-e.firstVerifiedAt.valueOf()))[0],selectedMethod:c,submitSuccess:g,hasBlockingError:m,error:C,onClose:k,onBack:()=>{d(null),E(null)},handleSubmit:()=>A(w).catch(E)}):c?/*#__PURE__*/t(my,{submitSuccess:g,hasBlockingError:m,handleSubmitCode:A,selectedMethod:c,onClose:k,onBack:i.mfaMethods.length>1?()=>d(null):void 0}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:k},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(kl,{children:"Verify your identity"}),/*#__PURE__*/t(Il,{children:"Choose a verification method"}),/*#__PURE__*/e(Wl,{children:[i.mfaMethods.includes("totp")&&/*#__PURE__*/e(rl,{onClick:()=>_("totp"),children:[/*#__PURE__*/t(lo,{}),"Authenticator App"]},"totp"),i.mfaMethods.includes("sms")&&/*#__PURE__*/e(rl,{onClick:()=>_("sms"),children:[/*#__PURE__*/t(oi,{}),"SMS"]},"sms"),i.mfaMethods.includes("passkey")&&/*#__PURE__*/e(rl,{onClick:()=>_("passkey"),children:[/*#__PURE__*/t(no,{}),"Passkey"]},"passkey")]}),/*#__PURE__*/t(ft,{})]}):null};let my=({selectedMethod:r,submitSuccess:a,hasBlockingError:i,onClose:o,onBack:s,handleSubmitCode:l})=>{let{app:c}=hr(),{pendingTransaction:d}=x();switch(r){case"sms":/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:o},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oi,{})}),/*#__PURE__*/t(kl,{children:"Enter verification code"}),/*#__PURE__*/e(Nl,{children:[/*#__PURE__*/t(Tm,{success:a,disabled:i,onChange:l}),/*#__PURE__*/e(Il,{children:["To continue, please enter the 6-digit code sent to your ",/*#__PURE__*/t("strong",{children:"mobile device"})]}),d&&/*#__PURE__*/t(dy,{pendingTransaction:d})]}),s&&/*#__PURE__*/t(Bl,{theme:c?.appearance.palette.colorScheme,onClick:s,children:"Choose another method"}),/*#__PURE__*/t(ut,{onClick:o,children:"Not now"}),/*#__PURE__*/t(ft,{})]});case"totp":/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:o},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(lo,{})}),/*#__PURE__*/t(kl,{children:"Enter verification code"}),/*#__PURE__*/e(Nl,{children:[/*#__PURE__*/t(Tm,{success:a,disabled:i,onChange:l}),/*#__PURE__*/e(Il,{children:["To continue, please enter the 6-digit code generated from your"," ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),d&&/*#__PURE__*/t(dy,{pendingTransaction:d})]}),s&&/*#__PURE__*/t(Bl,{theme:c?.appearance.palette.colorScheme,onClick:s,children:"Choose another method"}),/*#__PURE__*/t(ut,{onClick:o,children:"Not now"}),/*#__PURE__*/t(ft,{})]});default:return null}};let yy=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-814a2c46-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const gy=/*#__PURE__*/Ka.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-fd7f30b7-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent);stroke:var(--privy-color-accent);fill:var(--privy-color-accent);}"]);let fy=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-d3724da1-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const wy=/*#__PURE__*/Ka.div.withConfig({displayName:"Header",componentId:"sc-858d1103-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:20px 0;gap:4px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]);let vy=/*#__PURE__*/Ka.div.withConfig({displayName:"Content",componentId:"sc-858d1103-1"})(["display:flex;flex-direction:column;justify-content:space-between;"]),Cy=/*#__PURE__*/Ka.div.withConfig({displayName:"ErrorMessage",componentId:"sc-858d1103-2"})(["line-height:20px;height:20px;font-size:13px;color:var(--privy-color-error);text-align:left;margin-top:0.5rem;"]),Ey=/*#__PURE__*/Ka(ct).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-858d1103-3"})(["",""],(e=>e.hideAnimations&&/*#__PURE__*/Ya(["&&{transition:none;}"])));const Ty=n=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 21 20",...n,children:[/*#__PURE__*/t("path",{fill:"url(#icloud-gradient)",d:"M12.34 7.315a4.26 4.26 0 0 0-3.707 2.18 2.336 2.336 0 0 0-1.02-.236 2.336 2.336 0 0 0-2.3 1.963 3.217 3.217 0 0 0 1.244 6.181c.135-.001.27-.01.404-.029h8.943c.047.004.094.006.141.007.045-.001.09-.004.135-.007h.214v-.016a2.99 2.99 0 0 0 1.887-.988c.487-.55.757-1.261.757-1.998v-.006a3.017 3.017 0 0 0-.69-1.915 2.992 2.992 0 0 0-1.748-1.034 4.26 4.26 0 0 0-4.26-4.102Z"}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/e("linearGradient",{id:"icloud-gradient",x1:19.086,x2:3.333,y1:14.38,y2:14.163,gradientUnits:"userSpaceOnUse",children:[/*#__PURE__*/t("stop",{stopColor:"#3E82F4"}),/*#__PURE__*/t("stop",{offset:1,stopColor:"#93DCF7"})]})})]}),by=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"16",height:"14",style:n,viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_2115_829)",children:[/*#__PURE__*/t("path",{d:"M2.34709 12.9404L2.3471 12.9404L2.34565 12.938L1.64031 11.7448L1.64004 11.7444L0.651257 10.0677C0.640723 10.0496 0.630746 10.0314 0.621325 10.0129H4.16461L2.39424 13.0139C2.3775 12.9901 2.36178 12.9656 2.34709 12.9404Z",fill:"#0066DA",stroke:"#6366F1"}),/*#__PURE__*/t("path",{d:"M8 4.48713L5.47995 0.215332C5.23253 0.358922 5.02176 0.556358 4.87514 0.80764L0.219931 8.70508C0.076007 8.95094 0.000191627 9.22937 0 9.51277H5.04009L8 4.48713Z",fill:"#00AC47"}),/*#__PURE__*/t("path",{d:"M13.48 13.7847C13.7274 13.6411 13.9382 13.4437 14.0848 13.1924L14.3781 12.6988L15.7801 10.3206C15.9267 10.0693 16.0001 9.79114 16.0001 9.51294H10.9596L12.0321 11.577L13.48 13.7847Z",fill:"#EA4335"}),/*#__PURE__*/t("path",{d:"M8.00003 4.48718L10.5201 0.215385C10.2726 0.0717949 9.98857 0 9.69533 0H6.30472C6.01148 0 5.7274 0.0807692 5.47998 0.215385L8.00003 4.48718Z",fill:"#00832D"}),/*#__PURE__*/t("path",{d:"M10.9599 9.51294H5.04007L2.52002 13.7847C2.76744 13.9283 3.05152 14.0001 3.34476 14.0001H12.6552C12.9484 14.0001 13.2325 13.9194 13.4799 13.7847L10.9599 9.51294Z",fill:"#2684FC"}),/*#__PURE__*/t("path",{d:"M13.4525 4.75636L11.1249 0.80764C10.9782 0.556358 10.7675 0.358922 10.52 0.215332L8 4.48713L10.9599 9.51277H15.9908C15.9908 9.23456 15.9175 8.95636 15.7709 8.70508L13.4525 4.75636Z",fill:"#FFBA00"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_2115_829",children:/*#__PURE__*/t("rect",{width:"16",height:"14",fill:"white"})})})]}),Ay=/*#__PURE__*/Ka.div.withConfig({displayName:"RecoveryContainer",componentId:"sc-12b46968-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),_y=/*#__PURE__*/Ka.div.withConfig({displayName:"RecoveryExplainerContainer",componentId:"sc-12b46968-1"})(["padding-bottom:24px;"]);let ky={"google-drive":{name:"Google Drive",component:by},icloud:{name:"iCloud",component:Ty}};let Iy=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-6716a2fa-0"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;"]),Ny={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy"},xy=({onClose:r})=>/*#__PURE__*/e(_y,{children:[/*#__PURE__*/t(Zl,{title:"Why do I need to secure my account?",icon:/*#__PURE__*/t(Ja,{width:48}),description:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),/*#__PURE__*/t("p",{children:"To use this app on new devices, secure account secrets using a password, your Google or your Apple account. It’s important you don’t lose access to the method you choose."})]})}),/*#__PURE__*/t(ct,{onClick:r,children:"Select backup method"})]});const Sy=/*#__PURE__*/Ka.div.withConfig({displayName:"WithCircleBorder",componentId:"sc-e4fc5563-0"})(["&&{border-width:4px;}display:flex;justify-content:center;align-items:center;padding:1rem;aspect-ratio:1;border-style:solid;border-color:",";border-radius:50%;"],(e=>e.$color??"var(--privy-color-accent)"));async function Ry({tx:e,accessToken:t,walletProxy:n,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:i,transactingWalletIndex:o}){let s=function(e,t){let n=(Lh(e)?e.message:e.compileMessage()).staticAccountKeys.find((e=>e.toBase58()===t));if(!n)throw Error(`Transaction does not contain public key ${t}`);return n}(e,i),l=Lh(e)?Buffer.from(e.message.serialize()):e.serializeMessage(),{response:c}=await n.rpc({accessToken:t,entropyId:r,entropyIdVerifier:a,chainType:"solana",hdWalletIndex:o,request:{method:"signMessage",params:{message:l.toString("base64")}}}),d=c.data.signature,h=Buffer.from(d,"base64");e.addSignature(s,h)}async function Oy({tx:e,connection:t,accessToken:n,walletProxy:r,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:o,transactingWalletIndex:s,transactionOptions:l}){let c;try{await Ry({tx:e,accessToken:n,walletProxy:r,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:o,transactingWalletIndex:s});let d=e.serialize();c=await t.sendRawTransaction(d,l);let h=await t.confirmTransaction(c);if(h.value.err||h.value.err){let e=h.value.err||h.value.err;if("string"==typeof e)throw Error(e);throw e}return{signature:c,signedTransaction:e,receipt:await t.getParsedTransaction(c,{maxSupportedTransactionVersion:0})}}catch(e){throw e.txSignature=c,e}}const Wy=/*#__PURE__*/Ka(Vh).withConfig({displayName:"InteractiveLabel",componentId:"sc-94a4dccc-0"})(["cursor:pointer;display:inline-flex;gap:8px;align-items:center;color:var(--privy-color-accent);svg{fill:var(--privy-color-accent);}"]);var My=({iconUrl:n,value:r,symbol:a,usdValue:i,nftName:o,$isLoading:s})=>s?/*#__PURE__*/t(Py,{$isLoading:s}):/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(Py,{$isLoading:s,children:[n&&/*#__PURE__*/t(Dy,{src:n,alt:"Token icon"}),o,r," ",a]}),i&&/*#__PURE__*/e(Ly,{$isLoading:s,children:["$",i]})]});let Py=/*#__PURE__*/Ka.span.withConfig({displayName:"Value",componentId:"sc-d8e62921-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],jt);const Ly=/*#__PURE__*/Ka.span.withConfig({displayName:"Subvalue",componentId:"sc-d8e62921-1"})(["color:var(--privy-color-foreground-2);font-size:12px;font-weight:400;line-height:18px;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],jt);let Dy=/*#__PURE__*/Ka.img.withConfig({displayName:"TokenIcon",componentId:"sc-d8e62921-2"})(["height:14px;width:14px;margin-right:4px;object-fit:contain;"]);const Uy=r=>{let{chain:a,transactionDetails:i,isTokenContractInfoLoading:o,symbol:s}=r,{action:l,functionName:c}=i;/*#__PURE__*/return t(Gt,{children:/*#__PURE__*/e(en,{children:["transaction"!==l&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Action"}),/*#__PURE__*/t(jh,{children:c})]}),"mint"===c&&"args"in i&&i.args.filter((e=>e)).map(((n,r)=>/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:`Param ${r}`}),/*#__PURE__*/t(jh,{children:"string"==typeof n&&Da(n)?/*#__PURE__*/t(dt,{address:n,url:a?.blockExplorers?.default?.url,showCopyIcon:!1}):n?.toString()})]},r))),"setApprovalForAll"===c&&i.operator&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Operator"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:i.operator,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===c&&void 0!==i.approved&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Set approval to"}),/*#__PURE__*/t(jh,{children:i.approved?"true":"false"})]}),"transfer"===c||"transferFrom"===c||"safeTransferFrom"===c||"approve"===c?/*#__PURE__*/e(n,{children:["formattedAmount"in i&&i.formattedAmount&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Amount"}),/*#__PURE__*/e(jh,{$isLoading:o,children:[i.formattedAmount," ",s]})]}),"tokenId"in i&&i.tokenId&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Token ID"}),/*#__PURE__*/t(jh,{children:i.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===c&&/*#__PURE__*/e(n,{children:["amounts"in i&&i.amounts&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Amounts"}),/*#__PURE__*/t(jh,{children:i.amounts.join(", ")})]}),"tokenIds"in i&&i.tokenIds&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Token IDs"}),/*#__PURE__*/t(jh,{children:i.tokenIds.join(", ")})]})]}),"approve"===c&&i.spender&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Spender"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:i.spender,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferFrom&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Transferring from"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:i.transferFrom,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferTo&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Transferring to"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:i.transferTo,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})};let Fy={success:"background: var(--privy-color-success-lightest, #dcfce7);",warn:"background: var(--privy-color-warn-lightest, #fff7e6);",error:"background: var(--privy-color-error-lightest, #fde8e8);"};const By=/*#__PURE__*/Ka.div.withConfig({displayName:"Pill",componentId:"sc-8c138024-0"})(["border-radius:var(--privy-border-radius-md,8px);padding:12px;text-align:left;margin-top:23px;",""],(e=>Fy[e.variant])),zy=({variant:n,setPreventMaliciousTransaction:r,preventMaliciousTransaction:a})=>"warn"===n?/*#__PURE__*/t(By,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t(Hy,{variant:n}),/*#__PURE__*/e("p",{children:[/*#__PURE__*/t("b",{children:"Warning: Suspicious transaction"}),/*#__PURE__*/t("br",{}),"This has been flagged as a potentially deceptive request. Approving could put your assets or funds at risk."]})]})}):"error"===n?/*#__PURE__*/t(By,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-col",children:[/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t(Hy,{variant:n}),/*#__PURE__*/e("p",{children:[/*#__PURE__*/t("b",{children:"This is a malicious transaction"}),/*#__PURE__*/t("br",{}),"This transaction transfers tokens to a known malicious address. Proceeding may result in the loss of valuable assets."]})]}),/*#__PURE__*/e("div",{className:"mt-3 flex flex-row gap-2",children:[/*#__PURE__*/t(kd,{color:"var(--privy-color-error)",checked:!a,readOnly:!0,onClick:()=>r(!a)}),/*#__PURE__*/t("p",{children:"I understand and want to proceed anyways."})]})]})}):void 0;let Hy=/*#__PURE__*/Ka(Qa).withConfig({displayName:"StyledExclamationTriangleIcon",componentId:"sc-e6305f32-0"})(["width:20px;height:20px;stroke-width:2px;flex-shrink:0;display:inline-block;margin-right:8px;",";"],(e=>"error"===e.variant?"color: var(--privy-color-error)":"color: var(--privy-color-warn)"));const Vy=({transactionIndex:e,maxIndex:t})=>"number"!=typeof e||0===t?"":` (${e+1} / ${t+1})`,$y=({img:r,submitError:a,prepareError:i,onClose:o,action:l,title:c,subtitle:d,txValue:h,to:u,tokenAddress:p,network:m,missingFunds:y,fee:g,from:f,cta:w,disabled:v,chain:C,isSubmitting:E,isPreparing:T,isTokenPriceLoading:b,isTokenContractInfoLoading:A,isSponsored:_,symbol:k,balance:I,onClick:N,transactionDetails:x,transactionIndex:S,maxIndex:R,onBack:O,chainName:W,validation:M,hasScanDetails:P,setIsScanDetailsOpen:L,preventMaliciousTransaction:D,setPreventMaliciousTransaction:U,tokensSent:F,tokensReceived:B,isScanning:z,isCancellable:H})=>{let{showTransactionDetails:V,setShowTransactionDetails:$,hasMoreDetails:j,isErc20Ish:G}=(e=>{let[t,n]=s(!1),r=!0,a=!1;return(!e||e.isErc20Ish||"transaction"===e.action)&&(r=!1),r&&(a=Object.entries(e||{}).some((([e,t])=>t&&!["action","isErc20Ish","isNFTIsh"].includes(e)))),{showTransactionDetails:t,setShowTransactionDetails:n,hasMoreDetails:r&&a,isErc20Ish:e?.isErc20Ish}})(x),q=G&&A||T||b||z;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:o,backFn:O}),r&&/*#__PURE__*/t(Ky,{children:r}),/*#__PURE__*/e(Ot,{style:{marginTop:r?"1.5rem":0},children:[c,/*#__PURE__*/t(Vy,{maxIndex:R,transactionIndex:S})]}),/*#__PURE__*/t(Wt,{children:d}),/*#__PURE__*/e(en,{style:{marginTop:"2rem"},children:[(!!F[0]||q)&&/*#__PURE__*/e(Zt,{children:[B.length>0?/*#__PURE__*/t(Vh,{children:"Send"}):/*#__PURE__*/t(Vh,{children:"Amount"}),/*#__PURE__*/t(My,{iconUrl:F[0]?.iconUrl,value:F[0]?.value,usdValue:F[0]?.usdValue,symbol:F[0]?.symbol,nftName:F[0]?.nftName,$isLoading:q})]}),B.length>0&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Receive"}),/*#__PURE__*/t("div",{className:"flex flex-col",children:B.map(((e,n)=>/*#__PURE__*/t(My,{iconUrl:e.iconUrl,value:e.value,usdValue:e.usdValue,symbol:e.symbol,nftName:e.nftName},n)))})]}),x&&"spender"in x&&x?.spender?/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Spender"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:x.spender,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}):null,u&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"To"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:u,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),p&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Token address"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:p,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Network"}),/*#__PURE__*/t(jh,{children:m})]}),/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Estimated fee"}),/*#__PURE__*/t(jh,{$isLoading:T||b||void 0===_,children:_?"Sponsored":g})]}),j&&!P&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Zt,{className:"cursor-pointer",onClick:()=>$(!V),children:/*#__PURE__*/e($h,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/t(fo,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:V?"rotate(180deg)":void 0}})]})}),V&&x&&/*#__PURE__*/t(Uy,{action:l,chain:C,transactionDetails:x,isTokenContractInfoLoading:A,symbol:k})]}),P&&/*#__PURE__*/t(Zt,{children:/*#__PURE__*/e(Wy,{onClick:()=>L(!0),children:[/*#__PURE__*/t("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/t(wo,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/t(Js,{}),a?/*#__PURE__*/t(Qt,{style:{marginTop:"2rem"},children:a.message}):i?/*#__PURE__*/t(Qt,{style:{marginTop:"2rem"},children:i.shortMessage??qy}):null,/*#__PURE__*/t(zy,{variant:M,preventMaliciousTransaction:D,setPreventMaliciousTransaction:U}),/*#__PURE__*/t(Gy,{$useSmallMargins:!(!i&&!a&&"warn"!==M&&"error"!==M),title:Number(h)>0?void 0:!1!==_?"Your wallet":void 0,address:f,balance:I,isLoading:T||b,errMsg:T||i||a||!y?void 0:`Add funds on ${C?.name??W} to complete transaction.`}),/*#__PURE__*/t(ct,{style:{marginTop:"1rem"},loading:E,disabled:v||T,onClick:N,children:w}),H&&/*#__PURE__*/t(gn,{style:{marginTop:"1rem"},onClick:o,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(ht,{})]})},jy=({img:r,title:a,subtitle:i,cta:o,network:s,blockExplorerUrl:l,transactionIndex:c,maxIndex:d,isMissingFunds:h,submitError:u,parseError:p,total:m,amount:y,fee:g,balance:f,from:w,to:v,tokenAddress:C,tokenAccount:E,tokenAccountOwner:T,programAddress:b,transactingWalletAddress:A,disabled:_,isSubmitting:k,isPreparing:I,isTokenPriceLoading:N,onClick:x,onClose:S,onBack:R})=>{let O=I||N;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:S,backFn:R}),r&&/*#__PURE__*/t(Ky,{children:r}),/*#__PURE__*/e(Ot,{style:{marginTop:r?"1.5rem":0},children:[a,/*#__PURE__*/t(Vy,{maxIndex:d,transactionIndex:c})]}),/*#__PURE__*/t(Wt,{children:i}),/*#__PURE__*/e(en,{style:{marginTop:"2rem"},children:[(m||O)&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Total"}),/*#__PURE__*/t(jh,{$isLoading:O,children:m})]}),w&&w!==A&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"From"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:w,url:l,showCopyIcon:!1})})]}),v&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"To"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:v,url:l,showCopyIcon:!1})})]}),T&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Token account owner"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:T,url:l,showCopyIcon:!1})})]}),E&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Token account"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:E,url:l,showCopyIcon:!1})})]}),C&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Token address"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:C,url:l,showCopyIcon:!1})})]}),b&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Program address"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(dt,{address:b,url:l,showCopyIcon:!1})})]}),s&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Network"}),/*#__PURE__*/t(jh,{children:s})]}),(y||O)&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Amount"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(jh,{$isLoading:O,children:y})})]}),(g||O)&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Estimated fee"}),/*#__PURE__*/t(jh,{$isLoading:O,children:g})]})]}),/*#__PURE__*/t(Js,{}),u?/*#__PURE__*/t(Qt,{style:{marginTop:"2rem"},children:u.message}):p?/*#__PURE__*/t(Qt,{style:{marginTop:"2rem"},children:qy}):null,/*#__PURE__*/t(Gy,{$useSmallMargins:!(!p&&!u),title:"Your wallet",address:A,balance:f,isLoading:I||N,errMsg:I||p||u||!h?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/t(ct,{style:{marginTop:"1rem"},loading:k,disabled:_||I,onClick:x,children:o}),/*#__PURE__*/t(ht,{})]})};let Gy=/*#__PURE__*/Ka(St).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-4bd3bb7d-0"})(["",""],(e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;")),qy="There was an error preparing your transaction. Your transaction request will likely fail.",Ky=/*#__PURE__*/Ka.div.withConfig({displayName:"ImageContainer",componentId:"sc-4bd3bb7d-1"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),Yy=()=>/*#__PURE__*/e(eg,{children:[/*#__PURE__*/t(ng,{}),/*#__PURE__*/t(tg,{})]});const Zy=({transactionError:r,chainId:a,onClose:i,onRetry:o,network:l,connection:c,transactionHash:d})=>{let{chains:h}=x(),[u,p]=s(!1),{errorCode:m,errorMessage:y}=((e,t)=>{if("ethereum"===t)return{errorCode:e.details??e.message,errorMessage:e.shortMessage};let n=e.txSignature,r=e?.transactionMessage||"Something went wrong.";if(Array.isArray(e.logs)){let t=e.logs.find((e=>/insufficient (lamports|funds)/gi.test(e)));t&&(r=t)}return{transactionHash:n,errorMessage:r}})(r,l),g=(({chains:e,chainId:t,network:n,connection:r,transactionHash:a})=>"ethereum"===n?e.find((e=>e.id===t))?.blockExplorers?.default.url??"https://etherscan.io":Ur(a||"",Ar(r?.rpcEndpoint||"")))({chains:h,chainId:a,network:l,connection:c,transactionHash:d});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:i}),/*#__PURE__*/e(Jy,{children:[/*#__PURE__*/t(Yy,{}),/*#__PURE__*/t(Qy,{children:m}),/*#__PURE__*/t(Xy,{children:"Please try again."}),/*#__PURE__*/e(ig,{children:[/*#__PURE__*/t(ag,{children:"Error message"}),/*#__PURE__*/t(sg,{$clickable:!1,children:y})]}),d&&/*#__PURE__*/e(ig,{children:[/*#__PURE__*/t(ag,{children:"Transaction hash"}),/*#__PURE__*/e(og,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/t("u",{children:/*#__PURE__*/t("a",{href:g,children:"block explorer"})}),"."]}),/*#__PURE__*/e(sg,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(d),p(!0)},children:[d,/*#__PURE__*/t(dg,{clicked:u})]})]}),/*#__PURE__*/t(rg,{onClick:()=>o({resetNonce:!!d}),children:"Retry transaction"})]}),/*#__PURE__*/t(ft,{})]})};let Jy=/*#__PURE__*/Ka.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-a4816d51-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),Qy=/*#__PURE__*/Ka.span.withConfig({displayName:"ErrorCode",componentId:"sc-a4816d51-1"})(["color:var(--privy-color-foreground);text-align:center;font-size:1.125rem;font-weight:500;line-height:1.25rem;text-align:center;margin:10px;"]),Xy=/*#__PURE__*/Ka.span.withConfig({displayName:"Subtitle",componentId:"sc-a4816d51-2"})(["margin-top:4px;margin-bottom:10px;color:var(--privy-color-foreground-3);text-align:center;font-size:0.875rem;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;"]),eg=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleContainer",componentId:"sc-a4816d51-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),tg=/*#__PURE__*/Ka(ei).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-a4816d51-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),ng=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-a4816d51-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),rg=/*#__PURE__*/Ka(ct).withConfig({displayName:"RetryButton",componentId:"sc-a4816d51-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),ag=/*#__PURE__*/Ka.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-a4816d51-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),ig=/*#__PURE__*/Ka.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-a4816d51-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),og=/*#__PURE__*/Ka.text.withConfig({displayName:"HelperText",componentId:"sc-a4816d51-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),sg=/*#__PURE__*/Ka.span.withConfig({displayName:"TextBox",componentId:"sc-a4816d51-10"})(["position:relative;width:100%;background-color:var(--privy-color-background-2);padding:8px 12px;border-radius:10px;margin-top:5px;font-size:14px;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;",""],(e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }")),lg=/*#__PURE__*/Ka(vo).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-a4816d51-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),cg=/*#__PURE__*/Ka(Ci).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-a4816d51-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),dg=({clicked:e})=>/*#__PURE__*/t(e?cg:lg,{});const hg=({instructions:r,fees:a,transactionInfo:i,solPrice:o,rpcEndpoint:l})=>{let c=r.reduce(((e,{amount:t,token:n})=>t&&"SOL"===n?.symbol?e+t:e),0n),[d,h]=s(0),[u,p]=s(!1),m=r[d];/*#__PURE__*/return e(en,{children:[/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Total"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(Wm,{quantities:[c,a],tokenPrice:o})})]}),i&&i.action&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Action"}),/*#__PURE__*/t(jh,{children:i.action})]}),/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Fees"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(Wm,{quantities:[a||0n],tokenPrice:o})})]}),r.length>1?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Zt,{children:/*#__PURE__*/e(Wy,{onClick:()=>p((e=>!e)),children:[/*#__PURE__*/t("span",{children:"Details"}),/*#__PURE__*/t(Zi,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:u?"rotate(180deg)":void 0}})]})}),u&&/*#__PURE__*/t(Zt,{children:/*#__PURE__*/e(pg,{children:[/*#__PURE__*/e(mg,{children:[/*#__PURE__*/e(yg,{children:[d+1," of ",r.length," instructions"]}),/*#__PURE__*/e(fg,{children:[d>0&&/*#__PURE__*/t(Tn,{backFn:()=>h((e=>e-1))}),d<r.length-1&&/*#__PURE__*/t(bn,{nextFn:()=>h((e=>e+1))})]})]}),/*#__PURE__*/t(gg,{children:/*#__PURE__*/t(ug,{instruction:m,rpcEndpoint:l,solPrice:o})})]})})]}):/*#__PURE__*/t(ug,{instruction:m,rpcEndpoint:l,solPrice:o,hideAmount:!0})]})};function ug({instruction:n,rpcEndpoint:r,solPrice:a,hideAmount:i}){return n?/*#__PURE__*/e(en,{children:[!i&&!!n.amount&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Amount"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(Wm,{quantities:[n.amount],tokenPrice:a,tokenSymbol:n.token?.symbol??"SOL",tokenDecimals:n.token?.decimals??9})})]}),n.to&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"To"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(ay,{walletAddress:n.to,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccount&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Token account"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(ay,{walletAddress:n.tokenAccount,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccountOwner&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"Token account owner"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(ay,{walletAddress:n.tokenAccountOwner,rpcEndpoint:r,network:"solana"})})]}),n.from&&/*#__PURE__*/e(Zt,{children:[/*#__PURE__*/t(Vh,{children:"From"}),/*#__PURE__*/t(jh,{children:/*#__PURE__*/t(ay,{walletAddress:n.from,rpcEndpoint:r,network:"solana"})})]})]}):null}let pg=/*#__PURE__*/Ka.div.withConfig({displayName:"InstructionsBox",componentId:"sc-5a140027-0"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),mg=/*#__PURE__*/Ka.header.withConfig({displayName:"InstructionsBoxHeader",componentId:"sc-5a140027-1"})(["display:flex;justify-content:space-between;align-items:center;padding:12px;background-color:var(--privy-color-background-2);"]),yg=/*#__PURE__*/Ka.h4.withConfig({displayName:"HeaderTitle",componentId:"sc-5a140027-2"})(["font-size:14px;font-weight:500;line-height:19.6px;"]),gg=/*#__PURE__*/Ka.div.withConfig({displayName:"InstructionsBoxContent",componentId:"sc-5a140027-3"})(["padding:12px;"]),fg=/*#__PURE__*/Ka.div.withConfig({displayName:"NavigationButtonsConatiner",componentId:"sc-5a140027-4"})(["display:flex;gap:8px;align-items:center;"]);const wg=({instructions:r,fees:a,onClose:i,receiptHeader:o,receiptDescription:s,transactionInfo:l,solPrice:c,rpcEndpoint:d,signOnly:h})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:i}),/*#__PURE__*/t(Zs,{style:{marginBottom:"16px"},children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Ys,{color:"var(--privy-color-success-light)"}),/*#__PURE__*/t(ci,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),/*#__PURE__*/t(Zl,{title:o??`Transaction ${h?"signed":"complete"}!`,description:s??"You're all set."}),/*#__PURE__*/t(hg,{solPrice:c,instructions:r,fees:a,transactionInfo:l,rpcEndpoint:d}),/*#__PURE__*/t(Js,{}),/*#__PURE__*/t(vg,{loading:!1,onClick:i,children:"Close"}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]});let vg=/*#__PURE__*/Ka(ct).withConfig({displayName:"SubmitButton",componentId:"sc-1510a4b6-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);async function Cg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,publicClient:o,requesterAppId:s}){let l=await Eg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,requesterAppId:s});return await o.sendRawTransaction({serializedTransaction:l})}async function Eg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,requesterAppId:o}){return(await a.rpc({entropyId:t,entropyIdVerifier:n,hdWalletIndex:r.walletIndex??0,chainType:"ethereum",accessToken:e,requesterAppId:o,request:{method:"eth_signTransaction",params:[i]}})).response.data}let Tg=({data:n})=>{let r=n=>"object"==typeof n&&null!==n?/*#__PURE__*/t(Ag,{children:Object.entries(n).map((([t,n])=>/*#__PURE__*/e("li",{children:[/*#__PURE__*/e("strong",{children:[t,":"]})," ",r(n)]},t)))}):/*#__PURE__*/t("span",{children:String(n)});/*#__PURE__*/return t("div",{children:r(n)})};const bg=/*#__PURE__*/Ka.div.withConfig({displayName:"Message",componentId:"sc-ccf49562-0"})(["margin-top:1.5rem;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-md);padding:12px;text-align:left;max-height:310px;overflow:scroll;white-space:pre-wrap;width:100%;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]);let Ag=/*#__PURE__*/Ka.ul.withConfig({displayName:"MessageList",componentId:"sc-ccf49562-1"})(["margin-left:12px !important;white-space:nowrap;&:first-child{margin-left:0 !important;}strong{font-weight:500 !important;}"]);const _g=({data:e})=>/*#__PURE__*/t(bg,{children:/*#__PURE__*/t(Tg,{data:e})});let kg=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-b3a607dd-0"})(["display:flex;flex-direction:column;min-height:72px;"]);var Ig=({onBack:n,details:r})=>/*#__PURE__*/e(kg,{children:[/*#__PURE__*/t(lt,{backFn:n}),/*#__PURE__*/t(_g,{data:r}),/*#__PURE__*/t(ht,{})]});let Ng=({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return Na(e*t)}catch(e){return}};const xg=({txn:r,receipt:a,transactionInfo:i,onClose:o,tokenPrice:s,tokenSymbol:l,receiptHeader:c,receiptDescription:d})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:o}),/*#__PURE__*/t(Kl,{title:c??"Transaction complete!",description:d??"You're all set."}),/*#__PURE__*/t(oy,{tokenPrice:s,from:a.from,to:a.to,gas:Ng(a),txn:r,transactionInfo:i,tokenSymbol:l}),/*#__PURE__*/t(Js,{}),/*#__PURE__*/t(Sg,{loading:!1,onClick:o,children:"All Done"}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]});let Sg=/*#__PURE__*/Ka(ct).withConfig({displayName:"SubmitButton",componentId:"sc-824e1e82-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const Rg=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Og=[{name:"from",type:"address"},{name:"param2",type:"address"},{name:"param3",type:"bytes"},{name:"param4",type:"tuple",components:[]},{type:"tuple",components:[{name:"param5",type:"address"},{name:"param6",type:"uint256"},{name:"param7",type:"uint256"},{name:"encodedInitData",type:"bytes"}]}],Wg=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Mg=[{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"payable",type:"function"}],Pg=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Lg=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Dg=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Ug=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenIds",type:"uint256[]"},{name:"_amounts",type:"uint256[]"},{name:"_data",type:"bytes"}],name:"safeBatchTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Fg=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"},{name:"_amount",type:"uint256"},{name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Bg=(e,t)=>{let n=zg(Wg,e);if(n)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:n.args[0],amount:n.args[1]};let r=zg(Lu,e);if(r)return{action:"transfer",functionName:"transfer",isErc20Ish:!0,isNFTIsh:!1,transferTo:r.args[0],amount:r.args[1]};if(!t)return{action:"transaction",functionName:"",isErc20Ish:!1,isNFTIsh:!1};let a=zg(Rg,e);if(a&&"string"==typeof a.args[1]){let e=Hg(a.args[1]);if(e&&e[4].encodedInitData)return Bg(e[4].encodedInitData,t)}let i=zg(Lg,e);if(i)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:i.args[0],approved:i.args[1]};let o=zg(Dg,e);if(o)return{action:"transfer",functionName:"transferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:o.args[0],transferTo:o.args[1],tokenId:o.args[2]};let s=zg(Pg,e);if(s)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:s.args[0],transferTo:s.args[1],tokenId:s.args[2]};let l=zg(Fg,e);if(l)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:l.args[0],transferTo:l.args[1],tokenId:l.args[2],amount:l.args[3]};let c=zg(Ug,e);if(c)return{action:"batch transfer",functionName:"safeBatchTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:c.args[0],transferTo:c.args[1],tokenIds:c.args[2],amounts:c.args[3]};let d=zg(Mg,e);return d?{action:"mint",functionName:d.functionName,isNFTIsh:!0,isErc20Ish:!1,args:d.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}};let zg=(e,t)=>{try{let n=Ua({abi:e,data:t});return{functionName:n.functionName,args:n.args||[]}}catch(e){return null}},Hg=e=>{try{if("string"==typeof e)return Fa(Og,`0x${e.slice(10)}`)}catch(e){return null}};const Vg=(e,t,n)=>{let[r,a]=s(null),{getAccessToken:i}=mr(),{walletProxy:l}=x();return o((()=>{r&&a(null),(async()=>{if(!await i()||!l||!t)return null;let r=[],a=!0,o=await cy(e,n,t.address).catch((t=>(t.details.includes("insufficient funds")?a=!1:r.push(t),e)));return{tx:o,totalGasEstimate:o.gas,hasFunds:a,errors:r}})().then(a)}),[e]),r};let $g=new ua(new pa("There was an issue preparing your transaction",zi.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),jg=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0;const Gg=/*#__PURE__*/Ka.img.withConfig({displayName:"StyledLogo",componentId:"sc-68c1b1ea-0"})(["&&{height:",";width:",";border-radius:16px;margin-bottom:12px;}"],(e=>"sm"===e.size?"65px":"140px"),(e=>"sm"===e.size?"65px":"140px"));let qg=e=>{if(!Ia(e))return e;try{return za(e)}catch{return e}},Kg=e=>JSON.stringify(e,null,2),Yg=r=>{let{types:a,primaryType:i,...o}=r.typedData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_g,{data:o}),/*#__PURE__*/t(hh,{text:Kg(r.typedData),itemName:"full payload to clipboard"})," "]})};let Zg=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-84af275e-0"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-start;width:100%;margin-top:16px;margin-bottom:4px;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),Jg=/*#__PURE__*/Ka.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-84af275e-1"})(["display:flex;align-items:center;gap:8px;"]),Qg=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-84af275e-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),Xg=/*#__PURE__*/Ka.div.withConfig({displayName:"Grow",componentId:"sc-84af275e-3"})(["flex-grow:1;"]);let ef=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-35bf31dd-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const tf=/*#__PURE__*/h(((r,a)=>{let[i,o]=s(""),[l,c]=s(""),[d,h]=s(!1),{authenticated:u,user:p}=mr(),{initUpdateEmail:m}=x(),{navigate:y,setModalData:g,currentScreen:f}=hr(),{enabled:w,token:v}=st(),C=pr(),E=yn(i)&&(C.disablePlusEmails&&i.includes("+")?(l||c("Please enter a valid email address without a '+'."),!1):(l&&c(""),!0)),T=d||!E,b=()=>{!w||v||u?(async e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");h(!0);try{await m(p.email.address,i,e),y(ur.AWAITING_PASSWORDLESS_CODE)}catch(e){g({errorModalData:{error:e,previousScreen:f||ur.LANDING}})}h(!1)})(v):(g({captchaModalData:{callback:e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");return m(p.email.address,i,e)},userIntentRequired:!1,onSuccessNavigateTo:ur.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:ur.ERROR_SCREEN}}),y(ur.CAPTCHA_SCREEN))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(nf,{children:[l&&/*#__PURE__*/t(Qt,{style:{marginTop:"0.25rem",textAlign:"left"},children:l}),/*#__PURE__*/e(rf,{$error:!!l,children:[/*#__PURE__*/t(ii,{}),/*#__PURE__*/t("input",{ref:a,id:"email-input",type:"email",placeholder:"your@email.com",onChange:e=>o(e.target.value),onKeyUp:e=>{"Enter"===e.key&&b()},value:i,autoComplete:"email"}),r.stacked?null:/*#__PURE__*/t(gn,{isSubmitting:d,onClick:b,disabled:T,children:"Submit"})]})]}),r.stacked?/*#__PURE__*/t(ct,{loadingText:null,loading:d,disabled:T,onClick:b,children:"Submit"}):null]})}));let nf=fn,rf=_n;const of=({style:e,...n})=>/*#__PURE__*/t("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"38px",width:"38px",...e},...n,children:/*#__PURE__*/t("path",{d:"M20 13.6V20M20 26.4H20.016M36 20C36 28.8365 28.8366 36 20 36C11.1635 36 4.00001 28.8365 4.00001 20C4.00001 11.1634 11.1635 3.99999 20 3.99999C28.8366 3.99999 36 11.1634 36 20Z",stroke:"currentColor",strokeWidth:"3.2",strokeLinecap:"round",strokeLinejoin:"round"})});let sf=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-fc448c87-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-top:8px;padding-bottom:32px;"]),lf=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-fc448c87-1"})(["display:flex;align-items:center;justify-content:center;height:72px;aspect-ratio:1;color:var(--privy-color-error);background-color:var(--privy-color-error-light);border-radius:50%;"]),cf=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-fc448c87-2"})(["display:flex;flex-direction:column;gap:8px;"]);const df=/*#__PURE__*/Za([":root{--privy-border-radius-sm:6px;--privy-border-radius-md:12px;--privy-border-radius-mdlg:16px;--privy-border-radius-lg:24px;--privy-border-radius-full:9999px;--privy-color-background:",";--privy-color-background-2:",";--privy-color-background-3:",";--privy-color-foreground:",";--privy-color-foreground-2:",";--privy-color-foreground-3:",";--privy-color-foreground-4:",";--privy-color-foreground-accent:",";--privy-color-accent:",";--privy-color-accent-light:",";--privy-color-accent-lightest:",";--privy-color-accent-dark:",";--privy-color-accent-darkest:",";--privy-color-success:",";--privy-color-success-dark:",";--privy-color-success-light:",";--privy-color-error:",";--privy-color-error-light:",";--privy-color-warn:",";--privy-color-warn-light:",";--privy-height-modal-full:620px;--privy-height-modal-compact:480px;};"],(e=>e.theme.background),(e=>e.theme.background2),(e=>e.theme.background3),(e=>e.theme.foreground),(e=>e.theme.foreground2),(e=>e.theme.foreground3),(e=>e.theme.foreground4),(e=>e.theme.foregroundAccent),(e=>e.theme.accent),(e=>e.theme.accentLight),(e=>e.theme.accentLightest),(e=>e.theme.accentDark),(e=>e.theme.accentDarkest),(e=>e.theme.success),(e=>e.theme.successDark),(e=>e.theme.successLight),(e=>e.theme.error),(e=>e.theme.errorLight),(e=>e.theme.warn),(e=>e.theme.warnLight)),hf=/*#__PURE__*/Ka.div.withConfig({displayName:"StylesWrapper",componentId:"sc-bc1e45b4-0"})([""," color:var(--privy-color-foreground-2);h3{font-size:16px;line-height:24px;font-weight:500;color:var(--privy-color-foreground-2);}h4{font-size:14px;line-height:20px;font-weight:500;color:var(--privy-color-foreground);}p{font-size:13px;line-height:20px;color:var(--privy-color-foreground-2);}button:focus,input:focus,optgroup:focus,select:focus,textarea:focus{outline:none;border-color:var(--privy-color-accent-light);box-shadow:0 0 0 1px var(--privy-color-accent-light);}.mobile-only{@media (min-width:441px){display:none;}}@keyframes fadein{0%{opacity:0;}100%{opacity:1;}}"],"\n *,\n ::before,\n ::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n }\n\n line-height: 1.15;\n -webkit-text-size-adjust: 100%;\n -moz-tab-size: 4;\n tab-size: 4;\n font-feature-settings: normal;\n\n margin: 0;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n display: inline;\n }\n\n a {\n color: inherit;\n text-decoration: inherit;\n }\n\n b,\n strong {\n font-weight: bolder;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n font-family: inherit;\n font-size: 100%;\n font-weight: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n }\n\n button,\n select {\n text-transform: none;\n }\n\n button,\n [type='button'],\n [type='reset'],\n [type='submit'] {\n -webkit-appearance: button;\n background-color: transparent;\n background-image: none;\n }\n\n ::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n :-moz-focusring {\n outline: 1px dotted ButtonText;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n legend {\n padding: 0;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [type='search'] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n }\n\n summary {\n display: list-item;\n }\n\n blockquote,\n dl,\n dd,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n hr,\n figure,\n p,\n pre {\n margin: 0;\n }\n\n fieldset {\n margin: 0;\n padding: 0;\n }\n\n legend {\n padding: 0;\n }\n\n ol,\n ul,\n menu {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n textarea {\n resize: vertical;\n }\n\n input::placeholder,\n textarea::placeholder {\n opacity: 1;\n color: #9ca3af;\n }\n\n button,\n [role='button'] {\n cursor: pointer;\n }\n\n :disabled {\n cursor: default;\n }\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n }\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n [hidden] {\n display: none;\n }\n"),uf=({children:n,open:r,onClick:i,...o})=>/*#__PURE__*/t(Gi,{show:r,as:a.Fragment,children:/*#__PURE__*/e(qi,{onClose:i,...o,as:mf,children:[/*#__PURE__*/t(Ki,{as:a.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/t(pf,{id:"privy-dialog-backdrop","aria-hidden":"true"})}),/*#__PURE__*/t(yf,{children:/*#__PURE__*/t(Ki,{as:a.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/t(Yi,{as:gf,children:n})})})]})});let pf=/*#__PURE__*/Ka.div.withConfig({displayName:"Backdrop",componentId:"sc-28ab5e6b-0"})(["position:fixed;inset:0;transition:backdrop-filter 100ms ease;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);&.entering,&.leaving{backdrop-filter:unset;-webkit-backdrop-filter:unset;}"]),mf=/*#__PURE__*/Ka.div.withConfig({displayName:"DialogWrapper",componentId:"sc-28ab5e6b-1"})(["position:relative;z-index:999999;"]),yf=/*#__PURE__*/Ka.div.withConfig({displayName:"DialogContainer",componentId:"sc-28ab5e6b-2"})(["position:fixed;inset:0;display:flex;align-items:center;justify-content:center;width:100vw;min-height:100vh;"]);const gf=/*#__PURE__*/Ka.div.withConfig({displayName:"Panel",componentId:"sc-28ab5e6b-3"})(["padding:0;background:transparent;border:none;width:100%;pointer-events:auto;outline:none;display:block;@media (max-width:440px){opacity:1;transform:translate3d(0,0,0);transition:transform 200ms ease-in;position:fixed;bottom:0;&.entering,&.leaving{opacity:0;transform:translate3d(0,100%,0);transition:transform 150ms ease-in 0ms,opacity 0ms ease 150ms;}}@media (min-width:441px){opacity:1;transition:opacity 100ms ease-in;&.entering,&.leaving{opacity:0;transition-delay:5ms;}margin:auto;width:360px;box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]),ff=/*#__PURE__*/Ka.div.withConfig({displayName:"CenterItem",componentId:"sc-28ab5e6b-4"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;"]);let wf={[ur.LANDING]:()=>{let{app:e}=hr();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/t(Qp,{connectOnly:!1}):/*#__PURE__*/t(Gp,{connectOnly:!1})},[ur.CONNECT_OR_CREATE]:()=>{let{app:e}=hr();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/t(Qp,{connectOnly:!0}):/*#__PURE__*/t(Gp,{connectOnly:!0})},[ur.AWAITING_PASSWORDLESS_CODE]:()=>{let{app:r,navigate:a,lastScreen:i,navigateBack:l,setModalData:c,onUserCloseViaDialogOrKeybindRef:d}=hr(),{closePrivyModal:h,resendEmailCode:u,resendSmsCode:p,getAuthMeta:m,loginWithCode:g,updateWallets:f,createAnalyticsEvent:w}=x(),{authenticated:v,logout:C,user:E}=mr(),[T,b]=s(Xl),[_,k]=s(!1),[I,R]=s(null),[O,W]=s(null),[M,P]=s(0);d.current=()=>null;let L=m()?.email?0:1,D=yr-500;o((()=>{if(M){let e=setTimeout((()=>{P(M-1)}),1e3);return()=>clearTimeout(e)}}),[M]),o((()=>{if(v&&_&&E){if(r?.legal.requireUsersAcceptTerms&&!E.hasAcceptedTerms){let e=setTimeout((()=>{a(ur.AFFIRMATIVE_CONSENT_SCREEN)}),D);return()=>clearTimeout(e)}if(pt(E,r.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),w({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AwaitingPasswordlessCodeScreen"}}),C()},callAuthOnSuccessOnClose:!0}}),a(ur.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),D);return()=>clearTimeout(e)}{f();let e=setTimeout((()=>h({shouldCallAuthOnSuccess:!0,isSuccess:!0})),yr);return()=>clearTimeout(e)}}}),[v,_,E]),o((()=>{if(I&&0===O){let e=setTimeout((()=>{b(Xl),R(null);let e=document.querySelector("input[name=code-0]");e?.focus()}),1400);return()=>clearTimeout(e)}}),[I]);let U=e=>{e.preventDefault();let t=e.currentTarget.value.replace(" ","");if(""===t)return;if(isNaN(Number(t)))return R("Code should be numeric"),void W(1);R(null),W(null);let n=Number(e.currentTarget.name?.charAt(5)),r=[...t||[""]].slice(0,6-n),o=[...T.slice(0,n),...r,...T.slice(n+r.length)];b(o);let s=Math.min(Math.max(n+r.length,0),5);if(!isNaN(Number(e.currentTarget.value))){let e=document.querySelector(`input[name=code-${s}]`);e?.focus()}if(o.every((e=>e&&!isNaN(+e)))){let e=document.querySelector(`input[name=code-${s}]`);e?.blur(),g(o.join("")).then((()=>k(!0))).catch((e=>{if(e instanceof N&&e.privyErrorCode===A.INVALID_CREDENTIALS)R("Invalid or expired verification code");else if(e instanceof N&&e.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE)R(e.message);else{if(e instanceof N&&e.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),void a(ur.USER_LIMIT_REACHED_SCREEN);if(e instanceof N&&e.privyErrorCode===A.USER_DOES_NOT_EXIST)return void a(ur.ACCOUNT_NOT_FOUND_SCREEN);if(e instanceof N&&e.privyErrorCode===A.LINKED_TO_ANOTHER_USER)return c({errorModalData:{error:e,previousScreen:i??ur.AWAITING_PASSWORDLESS_CODE}}),void a(ur.ERROR_SCREEN,!1);if(e instanceof N&&e.privyErrorCode===A.DISALLOWED_PLUS_EMAIL)return c({inlineError:{error:e}}),void a(ur.CONNECT_OR_CREATE,!1);if(e instanceof N&&e.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return c({accountTransfer:{nonce:e.data?.data?.nonce,account:0===L?m()?.email:m()?.phoneNumber,displayName:e.data?.data?.account?.displayName,linkMethod:0===L?"email":"sms",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void a(ur.LINK_CONFLICT_SCREEN);R("Issue verifying code")}W(0)}))}},F=0==L?/*#__PURE__*/t(ii,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"}):
12
+ /*#__PURE__*/t(oi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),B=/*#__PURE__*/e("p",0==L?{children:["Please check ",/*#__PURE__*/t(dc,{children:m()?.email})," for an email from privy.io and enter your code below."]}:{children:["Please check ",/*#__PURE__*/t(dc,{children:m()?.phoneNumber})," for a message from ",r?.name||"Privy"," and enter your code below."]});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:()=>l()},"header"),/*#__PURE__*/e(ac,{children:[/*#__PURE__*/t(Zl,{title:"Enter confirmation code",description:B,icon:F}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/e(ic,{children:[/*#__PURE__*/t(oc,{$fail:!!I,$success:_,children:/*#__PURE__*/t("span",{children:I||(_?"Success!":"")})}),/*#__PURE__*/t("div",{children:T.map(((e,n)=>/*#__PURE__*/t("input",{name:`code-${n}`,type:"text",value:T[n],onChange:U,onKeyUp:e=>{"Backspace"===e.key&&(e=>{if(1===O&&(R(null),W(null)),b([...T.slice(0,e),"",...T.slice(e+1)]),e>0){let t=document.querySelector(`input[name=code-${e-1}]`);t?.focus()}})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:`${_?"success":""} ${I?"fail":""}`,autoComplete:y?"one-time-code":"off"},n)))})]}),/*#__PURE__*/e(sc,{children:[/*#__PURE__*/e("span",{children:["Didn't get ",0==L?"an email":"a message","?"]}),M?/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t(ai,{color:"var(--privy-color-foreground)",strokeWidth:1.33,height:"12px",width:"12px"}),/*#__PURE__*/t("span",{children:"Code sent"})]}):/*#__PURE__*/t(lc,{children:/*#__PURE__*/t("button",{onClick:async()=>{P(30),0==L?await u():await p()},children:"Resend code"})})]})]})]}),/*#__PURE__*/t(ht,{})]})},[ur.AWAITING_CONNECTION]:In,[ur.AWAITING_CONNECT_ONLY_CONNECTION]:()=>{let r,{navigateBack:a,navigate:i,lastScreen:l,currentScreen:c,data:d,setModalData:h}=hr(),{walletConnectionStatus:u,closePrivyModal:p}=x(),[m,g]=s(void 0),[f,w]=s(0),v=vt(u?.connector?.walletClientType||"unknown"),C="connected"===u?.status,E="switching_to_supported_chain"===u?.status;o((()=>{if(C){let e;if(d?.externalConnectWallet?.onCompleteNavigateTo){let t=d.externalConnectWallet.onCompleteNavigateTo,n=u.connectedWallet?.address;e=setTimeout((()=>{d.funding&&h({...d,funding:{...d.funding,connectedWalletAddress:n}}),i(t({walletChainType:u.connector?.chainType}))}),yr)}else e=setTimeout(p,yr);return()=>clearTimeout(e)}}),[C]);o((()=>{u?.connectError&&(e=>{g(_t(e))})(u?.connectError)}),[u]);let T=u?.connector?.connectorType||"injected",b=u?.connector?.walletClientType||"unknown",A=v?.metadata?.shortName||v?.name||u?.connector?.walletBranding.name||"Browser Extension",_=v?.image_url?.md||u?.connector?.walletBranding.icon||(e=>/*#__PURE__*/t(tt,{...e})),k="Browser Extension"===A?A.toLowerCase():A;r=C?`Successfully connected with ${k}`:m?m.message:E?"Switching networks":`Waiting for ${k}`;let I="Don’t see your wallet? Check your other browser windows.";return C?I="You’re good to go!":f>=2&&m?I="Unable to connect wallet":m?I=m.detail:E?I="Switch your wallet to the requested network.":"metamask"===b&&y?I="Click to continue to open and connect MetaMask.":"metamask"===b?I="For the best experience, connect only one wallet at a time.":"wallet_connect_v2"===T?I="Open your mobile wallet app to continue":"coinbase_wallet"===T&&(I="Open the Coinbase app on your phone to continue."),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{backFn:c===l?void 0:a}),/*#__PURE__*/e(Ic,{children:[/*#__PURE__*/t(At,{walletLogo:_,success:C,fail:!!m}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t("h3",{children:r}),/*#__PURE__*/t("p",{children:I})]}),m==ia.ERROR_USER_EXISTS?/*#__PURE__*/t(ct,{onClick:a,children:"Use a different wallet"}):!C&&m?.retryable&&f<2?/*#__PURE__*/t(ct,{onClick:()=>{w(f+1),g(void 0),u?.connectRetry()},disabled:!C&&(!m?.retryable||f>=2),children:"Retry"}):!C&&m&&f>=2?/*#__PURE__*/t(ct,{onClick:a,children:"Use a different wallet"}):null]}),/*#__PURE__*/t(ft,{})]})},[ur.AWAITING_FARCASTER_CONNECTION]:()=>{let{authenticated:r,logout:a,ready:i,user:c}=mr(),{lastScreen:d,navigate:h,navigateBack:u,setModalData:p,app:m}=hr(),{getAuthFlow:g,loginWithFarcaster:w,closePrivyModal:v,createAnalyticsEvent:C}=x(),[E,T]=s(void 0),[b,_]=s(!1),[k,I]=s(!1),N=l([]),R=g(),O=R?.meta.connectUri;return o((()=>{let e=Date.now(),t=setInterval((async()=>{let n=await R.pollForReady.execute(),r=Date.now()-e;if(n){clearInterval(t),_(!0);try{await w(),I(!0)}catch(e){let t={retryable:!1,message:"Authentication failed"};if(e?.privyErrorCode===A.ALLOWLIST_REJECTED)return void h(ur.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),void h(ur.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===A.USER_DOES_NOT_EXIST)return void h(ur.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===A.LINKED_TO_ANOTHER_USER)t.detail=e.message??"This account has already been linked to another user.";else{if(e?.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return p({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:"farcaster",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,farcasterEmbeddedAddress:e.data?.data?.otherUser?.farcasterEmbeddedAddress}}),void h(ur.LINK_CONFLICT_SCREEN);e?.privyErrorCode===A.INVALID_CREDENTIALS?(t.retryable=!0,t.detail="Something went wrong. Try again."):e?.privyErrorCode===A.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again.")}T(t)}}else r>12e4&&(clearInterval(t),T({retryable:!0,message:"Authentication failed",detail:"The request timed out. Try again."}))}),2e3);return()=>{clearInterval(t),N.current.forEach((e=>clearTimeout(e)))}}),[]),o((()=>{if(i&&r&&k&&c){if(m?.legal.requireUsersAcceptTerms&&!c.hasAcceptedTerms){let e=setTimeout((()=>{h(ur.AFFIRMATIVE_CONSENT_SCREEN)}),yr);return()=>clearTimeout(e)}k&&(pt(c,m.embeddedWallets)?N.current.push(setTimeout((()=>{p({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),C({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"FarcasterConnectStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(ur.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),yr)):N.current.push(setTimeout((()=>v({shouldCallAuthOnSuccess:!0,isSuccess:!0})),yr)))}}),[k,i,r,c]),/*#__PURE__*/e(n,y||b?{children:[/*#__PURE__*/t(lt,{backFn:d?u:void 0,onClose:v},"header"),/*#__PURE__*/t(It,{}),
13
+ /*#__PURE__*/t(n,f?{children:/*#__PURE__*/e(wh,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{success:k,fail:!!E}),/*#__PURE__*/t(yh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t(kl,{children:E?E.message:"Sign in with Farcaster"}),/*#__PURE__*/t(Il,{children:E?E.detail:"To sign in with Farcaster, please open the Warpcast app."})]}),O&&/*#__PURE__*/t(ct,{onClick:e=>{e.preventDefault(),window.location.href=O},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(fh,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{success:k,fail:!!E}),/*#__PURE__*/t(yh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t(kl,{children:E?E.message:"Signing in with Farcaster"}),/*#__PURE__*/t(Il,{children:E?E.detail:"This should only take a moment"}),/*#__PURE__*/t(zt,{children:O&&y&&/*#__PURE__*/t(ph,{text:"Take me to Warpcast",url:O,color:gh})})]})]})}),/*#__PURE__*/t(ft,{})]}:{children:[/*#__PURE__*/t(lt,{backFn:d?u:void 0,onClose:v},"header"),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(fh,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(kl,{children:"Sign in with Farcaster"}),/*#__PURE__*/t(Il,{children:"Scan with your phone's camera to continue."}),/*#__PURE__*/t(Ht,{children:O?/*#__PURE__*/t(Vt,{url:O,size:275,squareLogoElement:yh}):/*#__PURE__*/t($t,{})}),/*#__PURE__*/e(zt,{children:[/*#__PURE__*/t(Il,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),O&&/*#__PURE__*/t(hh,{text:O,itemName:"link",color:gh})]})]})}),/*#__PURE__*/t(ft,{})]})},[ur.AWAITING_FARCASTER_SIGNER]:()=>{let{lastScreen:r,navigateBack:a,data:i,app:c}=hr(),{requestFarcasterSignerStatus:d,closePrivyModal:h}=x(),[u,p]=s(void 0),[m,g]=s(!1),[w,v]=s(!1),C=l([]),E=i?.farcasterSigner;o((()=>{let e=Date.now(),t=setInterval((async()=>{if(!E?.public_key)return clearInterval(t),void p({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===E.status&&(clearInterval(t),g(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),yr)));let n=await d(E?.public_key),r=Date.now()-e;"approved"===n.status?(clearInterval(t),g(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),yr))):r>3e5?(clearInterval(t),p({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===n.status&&(clearInterval(t),p({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),C.current.forEach((e=>clearTimeout(e)))}}),[]);let T="pending_approval"===E?.status?E.signer_approval_url:void 0;/*#__PURE__*/return e(n,y||m?{children:[/*#__PURE__*/t(lt,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(It,{}),
14
+ /*#__PURE__*/t(n,f?{children:/*#__PURE__*/e(Eh,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{success:w,fail:!!u}),/*#__PURE__*/t(yh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t(kl,{children:u?u.message:"Add a signer to Farcaster"}),/*#__PURE__*/t(Il,{children:u?u.detail:"This will allow "+c.name+" to add casts, likes, follows, and more on your behalf."})]}),T&&/*#__PURE__*/t(ct,{onClick:e=>{e.preventDefault(),window.location.href=T},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(Ch,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{success:w,fail:!!u}),/*#__PURE__*/t(yh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t(kl,{children:u?u.message:"Requesting signer from Farcaster"}),/*#__PURE__*/t(Il,{children:u?u.detail:"This should only take a moment"}),/*#__PURE__*/t(zt,{children:T&&y&&/*#__PURE__*/t(ph,{text:"Take me to Warpcast",url:T,color:vh})})]})]})}),/*#__PURE__*/t(ft,{})]}:{children:[/*#__PURE__*/t(lt,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(Ch,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(kl,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e(Il,{children:["This will allow ",c.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/t(Ht,{children:"pending_approval"===E?.status?/*#__PURE__*/t(Vt,{url:E.signer_approval_url,size:275,squareLogoElement:yh}):/*#__PURE__*/t($t,{})}),/*#__PURE__*/e(zt,{children:[/*#__PURE__*/t(Il,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===E?.status&&/*#__PURE__*/t(hh,{text:E.signer_approval_url,itemName:"link",color:vh})]})]})}),/*#__PURE__*/t(ft,{})]})},[ur.SELECT_PASSKEY_SIGNUP_OR_LOGIN]:()=>{let{enabled:r,token:a}=st(),{lastScreen:i,currentScreen:o,navigateBack:s,navigate:l,setModalData:c}=hr(),{initSignupWithPasskey:d,initLoginWithPasskey:h}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:i&&o!==i?s:void 0}),/*#__PURE__*/t(_l,{children:/*#__PURE__*/e(gy,{children:[/*#__PURE__*/t(ru,{}),/*#__PURE__*/t(au,{})]})}),/*#__PURE__*/t(kl,{children:"Log in or create a new account?"}),/*#__PURE__*/t(Il,{children:"Create a new account with a passkey or use a passkey to log in to an existing account."}),/*#__PURE__*/e(Ol,{children:[/*#__PURE__*/t(ct,{onClick:async()=>{r&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!0},captchaModalData:{callback:e=>d({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:ur.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:ur.ERROR_SCREEN}}),l(ur.CAPTCHA_SCREEN)):(await d({withPrivyUi:!0}),c({passkeyAuthModalData:{passkeySignupFlow:!0}}),l(ur.AWAITING_PASSKEY_SYSTEM_DIALOGUE))},children:"Create new account"}),/*#__PURE__*/t(Bl,{onClick:async()=>{r&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>h({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:ur.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:ur.ERROR_SCREEN}}),l(ur.CAPTCHA_SCREEN)):(await h({withPrivyUi:!0}),c({passkeyAuthModalData:{passkeySignupFlow:!1}}),l(ur.AWAITING_PASSKEY_SYSTEM_DIALOGUE))},children:"Log in with a passkey"})]}),/*#__PURE__*/t(ht,{})]})},[ur.AWAITING_PASSKEY_SYSTEM_DIALOGUE]:()=>{let{app:r,lastScreen:a,currentScreen:i,navigateBack:c,data:d,setModalData:h,navigate:u}=hr(),{loginWithPasskey:p,signupWithPasskey:m,closePrivyModal:y,createAnalyticsEvent:g}=x(),{user:f,logout:w}=mr(),{passkeySignupFlow:v}=d?.passkeyAuthModalData??{},C=yr-500,[E,T]=s("loading"),[b,_]=s(null),k=l([]),I=e=>{k.current=[e,...k.current]};o((()=>()=>{k.current.forEach((e=>clearTimeout(e))),k.current=[]}),[]);let N=async()=>{T("loading");try{v?await m():await p(),T("success")}catch(e){_(e),T("error")}};return o((()=>{if("success"===E&&f){if(r?.legal.requireUsersAcceptTerms&&!f.hasAcceptedTerms)return void I(setTimeout((()=>{u(ur.AFFIRMATIVE_CONSENT_SCREEN)}),C));if(!pt(f,r?.embeddedWallets))return void I(setTimeout((()=>{y({shouldCallAuthOnSuccess:!0,isSuccess:!0})}),yr));I(setTimeout((()=>{h({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),g({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"PasskeyStatusScreen"}}),w()},callAuthOnSuccessOnClose:!0}}),u(ur.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),C))}}),[f,E]),o((()=>{N()}),[]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{backFn:a&&i!==a?c:void 0}),/*#__PURE__*/e(fy,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{success:"success"===E,fail:"error"===E}),/*#__PURE__*/t(au,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t("h3",{children:(()=>{switch(E){case"loading":return"Waiting for passkey";case"success":return"Success";case"error":return"Something went wrong"}})()}),/*#__PURE__*/t("p",{style:{whiteSpace:"pre-wrap"},children:(()=>{switch(E){case"loading":return v?"Please follow prompts to register your passkey.":"Please follow prompts to verify your passkey.\nYou will have to sign up with another method first to register a passkey for your account.";case"success":return"You've successfully logged in with your passkey.";case"error":if(b instanceof M){if(b.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE)return"Cannot link more passkeys to account.";if(b.privyErrorCode===A.PASSKEY_NOT_ALLOWED)return"Passkey request timed out or rejected by user.\nYou will have to sign up with another method first to register a passkey for your account."}return"An unknown error occurred.\nYou will have to sign up with another method first to register a passkey for your account."}})()})]}),(()=>{switch(E){case"loading":case"success":/*#__PURE__*/return t(ct,{onClick:()=>{},disabled:!0,children:"Continue"});case"error":/*#__PURE__*/return t(ct,{onClick:N,disabled:!1,children:"Retry"})}})()]}),/*#__PURE__*/t(ft,{})]})},[ur.WALLET_INTERSTITIAL_SCREEN]:()=>{let{ready:r}=mr(),{data:a}=hr(),[i,o]=s(!1);if(!a?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:l,connectOnly:c,chainType:d}=a.installWalletModalData,h=l.getMobileRedirect({useUniversalLink:!i,isSolana:"solana"===d,connectOnly:c}),u=l.name.replace(/ wallet/gi,""),p={title:`Redirecting to ${u} Mobile Wallet`,description:`We'll take you to the ${u} Mobile Wallet app to continue your login experience.`,footnote:""};return r&&(p.description=`For the best experience, we'll automatically log you into the ${u} Mobile Wallet in-app browser.`,p.footnote="Once you're done, you can always return here and refresh to view your updated account."),i&&(p.title="Still here?",p.description=`You may need to install the ${l.name} mobile app.`,p.footnote=`Once you're done, you can return here or connect via ${l.name}'s in-app browser.`),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{},"header"),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(Yl,{title:p.title,description:p.description}),/*#__PURE__*/e(pn,{children:[/*#__PURE__*/t(kn,{href:h,onClick:()=>setTimeout((()=>o(!0)),1e3),loading:r&&!h,children:i?"Go to App Store":"Continue"}),p.footnote?/*#__PURE__*/t("p",{children:p.footnote}):null]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.LOGIN_FAILED_SCREEN]:()=>{let{closePrivyModal:r}=x(),{navigate:a}=hr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{},"header"),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(tm,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/t(Yl,{title:"Could not connect with wallet",description:"Please check that Phantom multichain is enabled and try again.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/e(pn,{children:[/*#__PURE__*/t(ct,{onClick:()=>a(ur.LANDING),children:"Try again"}),/*#__PURE__*/t(ut,{onClick:()=>r(),children:"Cancel"})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.AWAITING_OAUTH_SCREEN]:()=>{let{authenticated:r,logout:a,ready:i,user:l}=mr(),{app:c,setModalData:d,navigate:h,resetNavigation:u}=hr(),{getAuthMeta:p,initLoginWithOAuth:m,loginWithOAuth:y,updateWallets:g,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v}=x(),[C,E]=s(!1),[T,b]=s(void 0),_=p()?.provider||"google",{name:k,component:I}=$o(_);o((()=>{y(_).then((()=>{E(!0),f(!0)})).catch((e=>{if(f(!1),e?.privyErrorCode===A.ALLOWLIST_REJECTED)return b(void 0),u(),void h(ur.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),b(void 0),u(),void h(ur.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===A.USER_DOES_NOT_EXIST)return b(void 0),u(),void h(ur.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return b(void 0),u(),d({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:p()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void h(ur.LINK_CONFLICT_SCREEN);let{retryable:t,detail:n}=function(e,t){let n={detail:"",retryable:!1},r=Oo(t);if(e?.privyErrorCode===A.LINKED_TO_ANOTHER_USER&&(n.detail="This account has already been linked to another user."),e?.privyErrorCode===A.INVALID_CREDENTIALS&&(n.retryable=!0,n.detail="Something went wrong. Try again."),e.privyErrorCode===A.OAUTH_USER_DENIED&&(n.detail=`Retry and check ${r} to finish connecting your account.`,n.retryable=!0),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&(n.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=$o(t).name;n.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===A.OAUTH_ACCOUNT_SUSPENDED){let e=$o(t).name;n.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE&&(n.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===A.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(n.detail="Something went wrong. Please try again."),n}(e,_);b({retryable:t,detail:n,message:"Authentication failed"})})).finally((()=>{Go()}))}),[k,_]),o((()=>{if(i&&r&&C&&l){if(c?.legal.requireUsersAcceptTerms&&!l.hasAcceptedTerms){let e=setTimeout((()=>{h(ur.AFFIRMATIVE_CONSENT_SCREEN)}),yr);return()=>clearTimeout(e)}if(pt(l,c.embeddedWallets)){let e=setTimeout((()=>{d({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:_,screen:"OAuthStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(ur.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),yr);return()=>clearTimeout(e)}{let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),yr);return g(),()=>clearTimeout(e)}}}),[i,r,C,l]);let N=C?`Successfully connected with ${k}`:T?T.message:`Verifying connection to ${k}`,R="";return R=C?"You’re good to go!":T?T.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(yy,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{success:C,fail:!!T}),/*#__PURE__*/t(I,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t("h3",{children:N}),/*#__PURE__*/t("p",{children:R})]}),T&&T?.retryable?/*#__PURE__*/t(mn,{onClick:()=>{Go(),m(_),b(void 0)},disabled:!C&&!T?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ft,{})]})},[ur.CROSS_APP_AUTH_SCREEN]:()=>{let r=pr(),{data:a,navigate:l,setModalData:c,onUserCloseViaDialogOrKeybindRef:d}=hr(),{crossAppAuthFlow:h,updateWallets:u,closePrivyModal:p,createAnalyticsEvent:m}=x(),{logout:y}=kt(),[g,f]=s({}),w=a?.crossAppAuth,v={id:w.appId,name:w.name,logoUrl:w.logoUrl},C=new T(`There was an issue connecting your ${v.name} account. Please try again.`),E=new Ke((async e=>{if(w.popup)try{let t=await h({appId:e,popup:w.popup,action:w.action});f({data:t})}catch(e){e instanceof T?f({error:e}):(e instanceof N&&w.popup&&w.popup.close(),f({error:C}))}else f({error:C})})),b=()=>{g.data&&(u(),w.onSuccess(g.data),p({shouldCallAuthOnSuccess:!0,isSuccess:!0})),w.onError(g.error??new T("User canceled flow")),p({shouldCallAuthOnSuccess:!1,isSuccess:!1})};d.current=b,o((()=>{v.id.length&&E.execute(v.id)}),[v.id]),o((()=>{if(!g.data)return;let e=g.data;if(r.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{l(ur.AFFIRMATIVE_CONSENT_SCREEN)}),yr);return()=>clearTimeout(e)}if(pt(e,r.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),m({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${v.id}`,screen:"CrossAppAuthScreen"}}),y()},callAuthOnSuccessOnClose:!0}}),l(ur.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),yr);return()=>clearTimeout(e)}let t=setTimeout(b,yr);return()=>clearTimeout(t)}),[g.data]);let{title:A,subtitle:_}=i((()=>g.data?{title:`Successfully connected with ${v.name}`,subtitle:"You're good to go!"}:g.error?{title:"Authentication failed",subtitle:g.error.message}:{title:`Connecting to ${v.name}`,subtitle:`Please check the pop-up from ${v.name} to continue`}),[g,v.name]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:b}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(xc,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{success:!!g.data,fail:!!g.error}),/*#__PURE__*/t(Nc,{name:v.name,logoUrl:v.logoUrl})]})}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t("h3",{children:A}),/*#__PURE__*/t("p",{children:_})]})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ft,{})]})},[ur.ALLOWLIST_REJECTION_SCREEN]:()=>{let{navigate:r,app:a}=hr(),i=a?.allowlistConfig.errorTitle||"You don't have access to this app",o=a?.allowlistConfig.errorDetail||"Have you been invited?",s=a?.allowlistConfig.errorCtaText||"Try another account";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{}),/*#__PURE__*/e(Gl,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(dl,{}),/*#__PURE__*/t(jl,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})]})}),/*#__PURE__*/e(ql,{children:[/*#__PURE__*/t("string"==typeof i?"h3":n,{children:i}),/*#__PURE__*/t("string"==typeof o?"p":n,{children:o})]}),a?.allowlistConfig.errorCtaLink?
15
+ /*#__PURE__*/t(ct,{as:"a",href:a.allowlistConfig.errorCtaLink,children:s}):/*#__PURE__*/t(ct,{onClick:()=>{r(ur.LANDING)},children:s})]})]})},[ur.ACCOUNT_NOT_FOUND_SCREEN]:()=>{let{navigate:r,app:a,setModalData:i,data:o}=hr(),{getAuthMeta:s,client:l}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{}),/*#__PURE__*/e(ll,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Ys,{color:"var(--privy-color-warn-light)"}),/*#__PURE__*/t(Ja,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-warn)"})]})}),/*#__PURE__*/e(cl,{children:[/*#__PURE__*/t("h3",{children:"Account not found"}),/*#__PURE__*/e("p",{children:["Please try logging in again or go to ",a.name," to create an account."]})]}),/*#__PURE__*/t(Js,{}),/*#__PURE__*/t(ct,{onClick:()=>{let e=s();i({...o,login:{...o?.login,...e?.disableSignup?{disableSignup:!0}:{}}}),l?.authFlow&&(l.authFlow=void 0),r(ur.LANDING)},children:"Try logging in again"})]})]})},[ur.USER_LIMIT_REACHED_SCREEN]:()=>{let{navigate:r}=hr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{}),/*#__PURE__*/e(sf,{children:[/*#__PURE__*/t(lf,{children:/*#__PURE__*/t(of,{})}),/*#__PURE__*/e(cf,{children:[/*#__PURE__*/t("h3",{children:"Unable to sign in"}),/*#__PURE__*/t("p",{children:"This application has reached its user limit and cannot sign in new users."})]}),/*#__PURE__*/t(ct,{onClick:()=>{r(ur.LANDING)},children:"Go back"})]}),/*#__PURE__*/t(ht,{})]})},[ur.INSTALL_WALLET_SCREEN]:()=>{let{navigateBack:r,data:a}=hr();if(!a?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:i}=a.installWalletModalData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:r},"header"),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(fp,{...i}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/e(ft,{children:[/*#__PURE__*/t("span",{children:"Still not sure? "}),/*#__PURE__*/t("a",{target:"_blank",href:"https://solana.com/docs/intro/wallets",children:"Learn more"})]})]})},[ur.LINK_EMAIL_SCREEN]:()=>{let{app:r}=hr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{},"header"),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(Zl,{title:"Connect your email",description:`Add your email to your ${r?.name} account`,icon:/*#__PURE__*/t(ii,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(pn,{children:/*#__PURE__*/t(Ap,{stacked:!0})}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.LINK_PHONE_SCREEN]:()=>{let{app:r,currentScreen:a,data:i,navigate:o,setModalData:s}=hr(),{initLoginWithSms:l}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{},"header"),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(Zl,{title:"Connect your phone",description:`Add your number to your ${r?.name} account`,icon:/*#__PURE__*/t(oi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/t(pn,{children:/*#__PURE__*/t(Pp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await l({phoneNumber:e,withPrivyUi:!0}),o(ur.AWAITING_PASSWORDLESS_CODE)}catch(e){s({errorModalData:{error:e,previousScreen:i?.errorModalData?.previousScreen||a||ur.LINK_PHONE_SCREEN}}),o(ur.ERROR_SCREEN)}},hideRecent:!0})}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.LINK_WALLET_SCREEN]:()=>{let{app:r,data:a}=hr(),i=a?.externalConnectWallet?.suggestedAddress,o=i?/*#__PURE__*/e("span",{children:["Link the wallet with address ",/*#__PURE__*/t(dt,{showCopyIcon:!1,address:i})," ",r?.name?`to ${r.name}.`:"."]}):`Link a wallet to your ${r?.name} account`,{connectors:s}=x(),l=kc({walletList:a?.externalConnectWallet?.walletList??r.appearance.walletList,walletChainType:a?.externalConnectWallet?.walletChainType??r.appearance.walletChainType,connectors:s,connectOnly:!1,ignore:r.appearance.walletList,walletConnectEnabled:r.externalWallets.walletConnect.enabled});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{},"header"),l.length>0&&/*#__PURE__*/t(Yl,{title:"Link your wallet",description:o}),/*#__PURE__*/t(Xs,{children:/*#__PURE__*/t(_c,{wallets:l})}),/*#__PURE__*/t(ht,{})]})},[ur.LINK_PASSKEY_SCREEN]:()=>{let{user:r,unlinkPasskey:a}=mr(),{linkWithPasskey:i,closePrivyModal:l}=x(),c=r?.linkedAccounts.filter((e=>"passkey"===e.type)),[d,h]=s(!1),[u,p]=s(""),[m,y]=s(!1),[g,f]=s(!1);o((()=>{0===c.length&&f(!1)}),[c.length]);let w=async e=>(h(!0),await a(e).then((()=>y(!0))).catch((e=>{e instanceof M&&e.privyErrorCode===A.MISSING_MFA_CREDENTIALS?p("Cannot unlink a passkey enrolled in MFA"):p("Unknown error occurred.")})).finally((()=>{h(!1)})));/*#__PURE__*/return e(n,m?{children:[/*#__PURE__*/t(lt,{onClose:()=>l()},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(uu,{style:{marginBottom:"1.5rem"},children:"Passkeys updated"}),/*#__PURE__*/t(pu,{children:" "}),/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ct,{onClick:()=>l(),children:"Done"})}),/*#__PURE__*/t(ft,{})]}:g?{children:[/*#__PURE__*/t(lt,{backFn:()=>f(!1),onClose:()=>l()},"header"),/*#__PURE__*/t(iu,{passkeys:c,expanded:g,onUnlink:w,onExpand:()=>f(!0)}),/*#__PURE__*/t(ft,{})]}:{children:[/*#__PURE__*/t(lt,{onClose:()=>l()},"header"),/*#__PURE__*/t(_l,{children:/*#__PURE__*/e(su,{children:[/*#__PURE__*/t(ru,{}),/*#__PURE__*/t(au,{})]})}),/*#__PURE__*/t(uu,{children:"Secure your account with a passkey"}),/*#__PURE__*/t(mu,{}),0===c.length?/*#__PURE__*/t(ou,{}):/*#__PURE__*/t(iu,{passkeys:c,expanded:g,onUnlink:w,onExpand:()=>f(!0)}),/*#__PURE__*/e(Ol,{style:{marginTop:"12px"},children:[u&&/*#__PURE__*/t(lu,{$fail:!0,children:u}),/*#__PURE__*/t(ct,{onClick:()=>{h(!0),i().then((()=>y(!0))).catch((e=>{if(e instanceof M){if(e.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE)return void p("Cannot link more passkeys to account.");if(e.privyErrorCode===A.PASSKEY_NOT_ALLOWED)return void p("Passkey request timed out or rejected by user.")}p("Unknown error occurred.")})).finally((()=>{h(!1)}))},loading:d,children:"Add new passkey"})]}),/*#__PURE__*/t(ft,{})]})},[ur.UPDATE_EMAIL_SCREEN]:()=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{},"header"),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(Zl,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/t(ii,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(pn,{children:/*#__PURE__*/t(tf,{stacked:!0})}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]}),[ur.UPDATE_PHONE_SCREEN]:()=>{let{currentScreen:r,data:a,navigate:i,setModalData:o}=hr(),{user:s}=mr(),{initUpdatePhone:l}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{},"header"),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(Zl,{title:"Update your phone number",description:"Add the phone number you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/t(oi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(pn,{children:/*#__PURE__*/t(Pp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{if(!s?.phone?.number)throw Error("User is required to have an phone number to update it.");await l(s?.phone?.number,e),i(ur.AWAITING_PASSWORDLESS_CODE)}catch(e){o({errorModalData:{error:e,previousScreen:a?.errorModalData?.previousScreen||r||ur.LINK_PHONE_SCREEN}}),i(ur.ERROR_SCREEN)}},hideRecent:!0})}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.CONNECT_ONLY_LANDING_SCREEN]:()=>{let{app:r,data:a}=hr(),i=pr(),o=a?.externalConnectWallet?.suggestedAddress,s=o?/*#__PURE__*/e("span",{children:["Connect the wallet with address ",/*#__PURE__*/t(dt,{showCopyIcon:!1,address:o})," ",r?.name?`to ${r.name}.`:"."]}):`Connect a wallet to your ${r?.name} account`,{connectors:l}=x(),c=kc({walletList:a?.externalConnectWallet?.walletList??r.appearance.walletList,walletChainType:a?.externalConnectWallet?.walletChainType??r.appearance.walletChainType,connectors:l,connectOnly:!0,ignore:r.appearance.walletList,walletConnectEnabled:r.externalWallets.walletConnect.enabled});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{},"header"),c.length>0&&/*#__PURE__*/t(Kl,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(el,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(_c,{wallets:c})}),r&&/*#__PURE__*/t(bt,{app:r,alwaysShowImplicitConsent:!0}),/*#__PURE__*/t(ht,{})]})},[ur.CONNECT_ONLY_AUTHENTICATED_SCREEN]:()=>{let{app:r,data:a}=hr(),i=pr(),o=a?.externalConnectWallet?.suggestedAddress,s=o?`Connect the wallet with address ${Tt(o)} ${r?.name?`to ${r.name}.`:"."}`:`Connect a wallet to ${r?.name}`,{connectors:l}=x(),c=kc({walletList:a?.externalConnectWallet?.walletList??r.appearance.walletList,walletChainType:a?.externalConnectWallet?.walletChainType??r.appearance.walletChainType,connectors:l,connectOnly:!0,ignore:r.appearance.walletList,walletConnectEnabled:r.externalWallets.walletConnect.enabled});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{},"header"),c.length>0&&/*#__PURE__*/t(Yl,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(el,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(_c,{wallets:c})}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN]:()=>{let{app:r,setModalData:a,navigate:i,data:l,onUserCloseViaDialogOrKeybindRef:c}=hr(),[d,h]=s(""),{embeddedWallets:u}=pr(),{authenticated:p,user:m,getAccessToken:y}=mr(),{closePrivyModal:g,walletProxy:f,refreshSessionAndUser:w,recoverPrimaryWallet:v}=x(),{onSuccess:C,onFailure:E,callAuthOnSuccessOnClose:b}=l.createWallet,A=!0===r?.embeddedWallets.requireUserOwnedRecoveryOnCreate,{createWallet:_}=od(),[k,I]=s(null),N=new Ke((async()=>{let e=await y();if(m&&e&&f)try{let t=Er(m);if(t&&"privy"===t.recoveryMethod)await v();else if(t){let{entropyId:n,entropyIdVerifier:r}=qn(t);try{if(!await f.connect({accessToken:e,entropyId:n,entropyIdVerifier:r}))throw new T("Primary wallet not connected.")}catch(e){return I(t),void i(ur.EMBEDDED_WALLET_CREATED_SCREEN)}}let n=Pt(m,r.embeddedWallets.ethereum.createOnLogin),a=Lt(m,r.embeddedWallets.solana.createOnLogin);if(n&&a){let t=await _({user:m});if(await f.createSolana({accessToken:e,ethereumAddress:t?.address}),!t)return;return I(t),void i(ur.EMBEDDED_WALLET_CREATED_SCREEN)}if(a){await f.createSolana({accessToken:e,ethereumAddress:wr(m)?.address});let t=await w();return I(vr(t)),void i(ur.EMBEDDED_WALLET_CREATED_SCREEN)}if(n){let e=await _({user:m});if(!e)return;I(e),i(ur.EMBEDDED_WALLET_CREATED_SCREEN)}}catch(e){h(e.message)}}));return o((()=>p&&m?A?(a({...l,recoverySelection:{...l?.recoverySelection,isInAccountCreateFlow:!0}}),i(Kc({walletAction:"create",showAutomaticRecovery:!1,availableRecoveryMethods:u.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:!1,isResettingPassword:!1}))):void N.execute():(i(ur.LANDING),void E(Error("User must be authenticated before creating a Privy wallet")))),[A,p]),c.current=()=>null,d?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{closeable:!1}),/*#__PURE__*/e(Rt,{children:[/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zl,{title:"Something went wrong",description:d})]}),/*#__PURE__*/t(ct,{onClick:()=>{k?(C(k),g({shouldCallAuthOnSuccess:b})):(E(new R("User wallet creation failed")),g({shouldCallAuthOnSuccess:!1}))},children:"Close"}),/*#__PURE__*/t(sd,{})]}):/*#__PURE__*/t(Wc,{})},[ur.EMBEDDED_WALLET_CREATED_SCREEN]:()=>{let{user:r}=mr(),{closePrivyModal:a,isNewUserThisSession:i,updateWallets:s}=x(),{app:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=hr(),{onSuccess:h,onFailure:u,callAuthOnSuccessOnClose:p}=c.createWallet,m=()=>{let e=wr(r)??vr(r);e?(s(),h(e)):u(Error("Failed to create wallet")),a({shouldCallAuthOnSuccess:p})};return o((()=>{let e=setTimeout(m,gr);return()=>clearTimeout(e)}),[]),d.current=m,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:m}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(Rt,{children:[/*#__PURE__*/t(si,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zl,{title:i?"Welcome"+(l?.name?` to ${l?.name}`:""):"All set!",description:i?"You’ve successfully created an account.":"Your account is secured."})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_CONNECTING_SCREEN]:()=>{let{authenticated:r,user:a,getAccessToken:l}=mr(),{closePrivyModal:c,createAnalyticsEvent:d,walletProxy:h}=x(),{navigate:u,data:p,setModalData:m,onUserCloseViaDialogOrKeybindRef:y}=hr(),g=i((()=>Date.now()),[]),[f,w]=s(!1),{onCompleteNavigateTo:v,onFailure:C,shouldForceMFA:E,entropyId:T,entropyIdVerifier:b}=p?.connectWallet,A=e=>{f||(w(!0),C("string"==typeof e?Error(e):e))};o((()=>{let e,t=fr(a,T);return r&&t?h?((async()=>{let n=await l();if(!n)return A("User must be authenticated and have a Privy wallet before it can be connected");try{await h.connect({accessToken:n,entropyId:T,entropyIdVerifier:b}),E&&await h.verifyMfa({accessToken:n});let t=(Date.now()-g)/1e3;v===ur.EMBEDDED_WALLET_KEY_EXPORT_SCREEN&&t<1?e=setTimeout((()=>{u(v,!1)}),1e3*(1-t)):u(v,!1)}catch(e){if(zc(e)&&"privy"===t.recoveryMethod){let e=await l();if(!e)return A("User must be authenticated and have a Privy wallet before it can be recovered");try{d({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:t.address}});let n=await(h?.recover({accessToken:e,entropyId:T,entropyIdVerifier:b}));n?.entropyId||A(Error("Unable to recover wallet")),v?u(v):c({shouldCallAuthOnSuccess:!1}),d({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}}),u(v)}catch(e){A("An error has occurred, please try again.")}}else zc(e)&&"privy"!==t.recoveryMethod?(m({...p,recoverWallet:{entropyId:T,entropyIdVerifier:b,onCompleteNavigateTo:v,onFailure:C},recoveryOAuthStatus:{provider:t.recoveryMethod,action:"recover",isInAccountCreateFlow:!1}}),u(Yc(t.recoveryMethod))):A(e)}})(),()=>clearTimeout(e)):void 0:A("User must be authenticated and have a Privy wallet before it can be connected")}),[r,a,h]);let _=()=>{A("User exited before wallet could be connected"),c({shouldCallAuthOnSuccess:!1})};return y.current=_,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:_}),f?/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(Rt,{children:[/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zl,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),/*#__PURE__*/t(ct,{onClick:()=>c({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):/*#__PURE__*/t(Wc,{}),/*#__PURE__*/t(Qc,{})]})},[ur.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN]:()=>{let[r,a]=s(!0),{authenticated:i,getAccessToken:l,user:c}=mr(),{walletProxy:d,closePrivyModal:h,createAnalyticsEvent:u}=x(),{navigate:p,data:m,onUserCloseViaDialogOrKeybindRef:y}=hr(),[g,f]=s(void 0),[w,v]=s(""),[C,E]=s(!1),{entropyId:T,entropyIdVerifier:b,onCompleteNavigateTo:A,onSuccess:_,onFailure:k}=m.recoverWallet,I=(e="User exited before their wallet could be recovered")=>{h({shouldCallAuthOnSuccess:!1}),k("string"==typeof e?new R(e):e)};y.current=I,o((()=>{if(!i)return I("User must be authenticated and have a Privy wallet before it can be recovered")}),[i]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:I}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(vy,{children:[/*#__PURE__*/e(wy,{children:[/*#__PURE__*/t(oo,{height:48,width:48,stroke:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Enter your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(yd,{children:[/*#__PURE__*/t(pd,{type:r?"password":"text",onChange:e=>(e=>{e&&f(e)})(e.target.value),disabled:C,style:{paddingRight:"2.3rem"}}),/*#__PURE__*/t(Cd,{style:{right:"0.75rem"},children:r?/*#__PURE__*/t(Td,{onClick:()=>a(!1)}):/*#__PURE__*/t(bd,{onClick:()=>a(!0)})})]}),!!w&&/*#__PURE__*/t(Cy,{children:w})]}),/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(En,{children:[/*#__PURE__*/t("h4",{children:"Why is this necessary?"}),/*#__PURE__*/t("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),/*#__PURE__*/t(Ey,{loading:C||!d,disabled:!g,onClick:async()=>{E(!0);let e=await l(),t=fr(c,T);if(!e||!t||null===g)return I("User must be authenticated and have a Privy wallet before it can be recovered");try{u({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t.address}}),await(d?.recover({accessToken:e,entropyId:T,entropyIdVerifier:b,recoveryPassword:g})),v(""),A?p(A):h({shouldCallAuthOnSuccess:!1}),_?.(t),u({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}})}catch(e){!function(e){return Bc(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)}(e)?v("An error has occurred, please try again."):v("Invalid recovery password, please try again.")}finally{E(!1)}},warn:!1,hideAnimations:!T&&C,children:"Recover your account"})]})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN]:()=>{let[r,a]=s(!1),{navigate:i,lastScreen:o,navigateBack:l,setModalData:c,data:d,onUserCloseViaDialogOrKeybindRef:h}=hr(),{user:u}=mr(),{embeddedWallets:p}=pr(),{closePrivyModal:m}=x(),y=Er(u),g=null===y,{isInAccountCreateFlow:f,isResettingPassword:w}=d.recoverySelection,v=y&&"privy"!==y.recoveryMethod,C=v?/*#__PURE__*/e("span",{children:["Your account is currently secured using"," ",/*#__PURE__*/t("strong",{children:Ny[y?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function E(e){c({recoveryOAuthStatus:{provider:e,action:g?"create-wallet":"set-recovery",isInAccountCreateFlow:f}}),i(ur.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN)}function T(){d?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),m({shouldCallAuthOnSuccess:d?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return h.current=T,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:T,backFn:r?()=>a(!1):o?l:void 0,infoFn:o||r?void 0:()=>a(!0)},"header"),r?/*#__PURE__*/t(xy,{onClose:()=>a(!1)}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Zl,{title:v?"Update backup method":"Secure your account",icon:/*#__PURE__*/t(yo,{width:48}),description:C}),/*#__PURE__*/t(Ay,{children:p.userOwnedRecoveryOptions.filter((e=>!["icloud","google-drive"].includes(y?.recoveryMethod||"")||e!==y?.recoveryMethod)).sort().map((n=>{switch(n){case"google-drive":/*#__PURE__*/return e(rl,{onClick:()=>E("google-drive"),children:[/*#__PURE__*/t(Iy,{children:/*#__PURE__*/t(by,{style:{width:18}})}),"Back up to Google Drive"]},n);case"icloud":/*#__PURE__*/return e(rl,{onClick:()=>E("icloud"),children:[/*#__PURE__*/t(Iy,{children:/*#__PURE__*/t(Ty,{style:{width:24}})}),"Back up to Apple iCloud"]},n);case"user-passcode":/*#__PURE__*/return e(rl,{onClick:()=>{i(qc({isCreatingWallet:g,skipSplashScreen:!0}))},children:[/*#__PURE__*/t(Iy,{children:/*#__PURE__*/t(go,{style:{width:18}})}),w?"Reset your":"Set a"," password"]},n);default:return null}}))})]}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN]:()=>{let{user:r,getAccessToken:a}=mr(),{walletProxy:i,refreshSessionAndUser:o,closePrivyModal:l}=x(),c=hr(),{entropyId:d,entropyIdVerifier:h}=c.data?.recoverWallet,[u,p]=s(!1),[m,y]=s(null),[g,f]=s(null);function w(){if(!u){if(g)return c.data?.setWalletPassword?.onFailure(g),void l();if(!m)return c.data?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),void l()}}c.onUserCloseViaDialogOrKeybindRef.current=w;let v=!(!u&&!m);/*#__PURE__*/return e(n,g?{children:[/*#__PURE__*/t(lt,{onClose:w},"header"),/*#__PURE__*/t(Sy,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:/*#__PURE__*/t(Qa,{height:38,width:38,stroke:"var(--privy-color-error)"})}),/*#__PURE__*/t(Ot,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),/*#__PURE__*/t(Js,{style:{minHeight:"2rem"}}),/*#__PURE__*/t(Xt,{onClick:()=>f(null),children:"Try again"}),/*#__PURE__*/t(ht,{})]}:{children:[/*#__PURE__*/t(lt,{onClose:w},"header"),/*#__PURE__*/t(yo,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),/*#__PURE__*/t(Ot,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),/*#__PURE__*/t(Wt,{style:{marginTop:"1rem"},children:"When you log into a new device, you’ll only need to authenticate to access your account. Never get logged out if you forget your password."}),/*#__PURE__*/t(Js,{style:{minHeight:"2rem"}}),/*#__PURE__*/t(Xt,{loading:u,disabled:v,onClick:()=>async function(){p(!0);try{let e=await a(),t=fr(r,d);if(!e||!i||!t)return;if(!(await i.setRecovery({accessToken:e,entropyId:d,entropyIdVerifier:h,existingRecoveryMethod:t.recoveryMethod,recoveryMethod:"privy"})).entropyId)throw Error("Unable to set recovery on wallet");let n=await o();if(!n)throw Error("Unable to set recovery on wallet");let s=fr(n,t.address);if(!s)throw Error("Unabled to set recovery on wallet");y(!!n),setTimeout((()=>{c.data?.setWalletPassword?.onSuccess(s),l()}),yr)}catch(e){f(e)}finally{p(!1)}}(),children:m?"Success":"Confirm"}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN]:()=>{let{logout:r}=mr(),{navigate:a,setModalData:i,data:l}=hr(),{recoveryOAuthFlow:d,closePrivyModal:h,createAnalyticsEvent:u}=x(),[p,m]=s(!1),{provider:y,action:g,isInAccountCreateFlow:f}=l?.recoveryOAuthStatus,[w,v]=s(void 0),[C,E]=s("create-wallet"===g);if("user-passcode"===y)throw Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let T=ky[y].name,b=ky[y].component,A=l?.recoverWallet?.onCompleteNavigateTo,_=new Ke((async(e="create-wallet")=>(E(!0),new Promise(((t,n)=>{setTimeout((async()=>{try{let n=window.open();await d(y,e,n),m(!0),t()}catch(t){v({message:`${"recover"===e?"Recovery":"Back up"} with ${T} unsuccessful`,detail:"recover"===g?`Please verify that you are selecting the ${T} account associated with your backup.`:"",retryable:!0}),n()}}),0)})))));o((()=>{"recover"!==g&&_.execute(f?"create-wallet":"set-recovery")}),[]),o((()=>{if(!p)return;let e=setTimeout((()=>{f?(i({createWallet:{onSuccess:()=>{},onFailure:e=>{u({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"RecoveryOAuthScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),a(ur.EMBEDDED_WALLET_CREATED_SCREEN)):h({shouldCallAuthOnSuccess:!1})}),yr);return()=>clearTimeout(e)}),[p]);let k=c((async()=>{await _.execute("recover"),A?a(A):m(!0)}),[]),I="google-drive"===y?"Google Drive":"Apple iCloud",N=p&&`Successfully ${"recover"===g?"recovered":"backed up"} with ${I}.`||w&&w.message||`${"recover"===g?"Recovering":"Backing up"} with ${I}...`,S=w?w.detail:"";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{}),C?/*#__PURE__*/t(n,{children:/*#__PURE__*/e(Ay,{children:[/*#__PURE__*/t(Zl,{title:N,icon:/*#__PURE__*/t(b,{style:{width:"38px",height:"38px"}}),description:S}),w&&w?.retryable?/*#__PURE__*/t(ct,{onClick:()=>{Go(),v(void 0),"create-wallet"===g?_.execute("create-wallet"):k()},disabled:!p&&!w?.retryable,children:"Try again"}):null]})}):/*#__PURE__*/e(Ay,{children:[/*#__PURE__*/t(Zl,{title:"Confirm it's really you",icon:/*#__PURE__*/t(b,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${I} where your account is backed up.`}),/*#__PURE__*/e(ct,{onClick:k,children:["Confirm with ",I]})]}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_KEY_EXPORT_SCREEN]:()=>{let[r,a]=s(null),{authenticated:i,user:l,getAccessToken:c}=mr(),{closePrivyModal:d,createAnalyticsEvent:h,clientAnalyticsId:u}=x(),p=pr(),{data:m,onUserCloseViaDialogOrKeybindRef:y}=hr(),{onFailure:g,onSuccess:f,origin:w,appId:v,appClientId:C,walletToExport:E,primaryWallet:T}=m.keyExport,b=e=>{d({shouldCallAuthOnSuccess:!1}),g("string"==typeof e?Error(e):e)},A=()=>{d({shouldCallAuthOnSuccess:!1}),f(),h({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:E.address}})};return o((()=>{if(!i||!E)return b("User must be authenticated before exporting their wallet");c().then(a,b)}),[i,l]),y.current=A,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:A}),/*#__PURE__*/e(nd,{children:[/*#__PURE__*/t(Ot,{children:"Transfer wallet"}),/*#__PURE__*/e(Wt,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",/*#__PURE__*/t("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),/*#__PURE__*/t(Xc,{theme:p.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),/*#__PURE__*/t(St,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:E.address,showIcon:!0}),/*#__PURE__*/t("div",{style:{width:"100%"},children:r&&/*#__PURE__*/t(td,{origin:w,appId:v,appClientId:C,accessToken:r,clientAnalyticsId:u,walletToExport:E,primaryWallet:T,dimensions:{height:"44px"}})})]}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN]:()=>{let{authenticated:r}=mr(),{initializeWalletProxy:a,closePrivyModal:i}=x(),{navigate:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=hr(),[h,u]=s(!0),[p,m]=s(""),[y,g]=s(),[f,w]=s(null),[v,C]=s(!1),E=null!==f;o((()=>{r||l(ur.LANDING)}),[r]),o((()=>{a(Cr).then((e=>{u(!1),e||(m("An error has occurred, please try again."),g(new ua(new pa(p,zi.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:T,data:b,confirmAndSign:A,onSuccess:_,onFailure:k,uiOptions:I}=c.signMessage,N={title:I?.title||"Sign message",description:I?.description||"Signing this message will not cost you any fees.",buttonText:I?.buttonText||"Sign and continue"},S=e=>{e?_(e):k(y||new ua(new pa("The user rejected the request.",zi.E4001_USER_REJECTED_REQUEST.eipCode))),i({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{w(null),m(""),g(void 0)}),200)};return d.current=()=>{S(f)},/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:()=>S(f)}),/*#__PURE__*/t(It,{}),I?.iconUrl&&"string"==typeof I.iconUrl?/*#__PURE__*/t(Qg,{children:/*#__PURE__*/t(Gg,{size:"sm",src:I.iconUrl,alt:"app image"})}):null,/*#__PURE__*/t(Ot,{children:N.title}),/*#__PURE__*/t(Wt,{children:N.description}),"personal_sign"===T&&/*#__PURE__*/t(bg,{children:qg(b)}),"eth_signTypedData_v4"===T&&/*#__PURE__*/t(Yg,{typedData:b}),"solana_signMessage"===T&&/*#__PURE__*/t(bg,{children:b}),/*#__PURE__*/t(Xg,{}),/*#__PURE__*/t(Zg,{$fail:!0,children:p}),/*#__PURE__*/t(Xt,{disabled:v||E||h,loading:v,onClick:async()=>{C(!0),m("");try{let e=await A();w(e),C(!1),setTimeout((()=>{S(e)}),yr)}catch(e){console.error(e),m("An error has occurred, please try again."),g(new ua(new pa(p,zi.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),C(!1)}},children:v?"Signing...":E?/*#__PURE__*/e(Jg,{children:[/*#__PURE__*/t(dh,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",/*#__PURE__*/t("span",{children:"Success"})]}):N.buttonText}),I?.isCancellable&&/*#__PURE__*/t(gn,{style:{marginTop:"1rem"},onClick:()=>S(null),isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN]:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=hr(),{rpcConfig:l,chains:c,closePrivyModal:d,walletProxy:h,client:u}=x(),{getAccessToken:p,user:m}=mr(),y=pr(),[g,f]=s(0),w=(e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(e),[v,C]=s(jg(e,g)),[E,T]=s(null),[b,A]=s(),[_,k]=s(!1),[I,N]=s(null),[S,R]=s(null),[O,W]=s(null),[M,P]=s(void 0),[L,D]=s(void 0),[U,F]=s(!1),[B,z]=s(!1),[H,V]=s([]),[$,j]=s([]),[G,q]=s(!1),[K,Y]=s(void 0),Z="fiat-currency"===y.embeddedWallets.priceDisplay.primary;if(!v||!e?.sendTransaction||!e?.sendTransaction.transactingWallet)/*#__PURE__*/return t(oh,{error:Error("Invalid transaction request"),onClick:()=>{e?.sendTransaction?.onFailure($g),d({shouldCallAuthOnSuccess:!1})}});let{entropyId:J,entropyIdVerifier:Q,transactingWallet:X}=e.sendTransaction,ee=i((()=>c.find((e=>Number(e.id)===Number(v.chainId)))),[v.chainId]),te=ee?.nativeCurrency.symbol??"ETH",ne=i((()=>Bg(v.data,!!y.embeddedWallets.extendedCalldataDecoding)),[v.data]),{action:re,isErc20Ish:ae,isNFTIsh:ie}=ne,{toAddress:oe,tokenAddress:se}=i((()=>({toAddress:ne.isErc20Ish?ne.transferTo:v.to??void 0,tokenAddress:ne.isErc20Ish?v.to:void 0})),[ne]);o((()=>{v.to&&ee&&ae&&dn({address:v.to,chain:ee,rpcConfig:y.rpcConfig,privyAppId:y.id}).then(T).catch(console.error)}),[v.to,ee]);let{tokenPrice:le,isTokenPriceLoading:ce}=xh(v.chainId),{balance:de}=un({rpcConfig:y.rpcConfig,appId:y.id,address:X.address,chain:ee}),he=i((()=>Ha(Number(v.chainId),c,l,{appId:y.id})),[v.chainId,l]),ue=Vg(v,X,he);o((()=>{C(jg(e,g))}),[g]),o((()=>{e.sendTransaction?.getIsSponsored?e.sendTransaction.getIsSponsored().then(A).catch(console.error):A(!1)}),[e.sendTransaction.getIsSponsored]);let pe=()=>{if(!_)return I?e?.sendTransaction?.onSuccess({hash:I}):O||ue?.errors[0]?e?.sendTransaction?.onFailure(O??ue?.errors[0]??$g):e?.sendTransaction?.onFailure(new ua(new pa("The user rejected the request",zi.E4001_USER_REJECTED_REQUEST.eipCode))),d({shouldCallAuthOnSuccess:!1})};n.current=pe;let me=!!(e.funding&&e.funding.supportedOptions.length>0),ye=Jt(BigInt(ue?.totalGasEstimate??0n),te),ge=Z&&le?rn(BigInt(ue?.totalGasEstimate??0n),le):void 0,fe=Jt(de??0n,te,void 0,!0),we=Z&&le?rn(de??0n,le):void 0,ve=e.sendTransaction?.uiOptions?.transactionInfo?.title;ve||(ve="approve"===re?ae?"Confirm address":"Confirm action":`Approve ${re}`);let Ce=e.sendTransaction?.uiOptions?.description||(ae&&"approve"===re?`${y.name} would like your permission for ${Tt(ne.spender)} to spend tokens on your behalf.`:`${y.name} wants your permission to approve the following transaction.`),Ee=e.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/t("img",{src:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,Te=!(!ue||ue.errors[0]||ue.hasFunds||!1!==b),be=Te&&me,Ae=be?"Add funds":e.sendTransaction?.uiOptions?.buttonText||(g<w?"Continue":"Approve");if(o((()=>{let e=(e,t,n)=>{if(t.isErc20Ish&&t.amount&&n)Y(an({amount:t.amount,decimals:n.decimals})),V([{value:K,symbol:n?.symbol}]);else if(e.value){let t=BigInt(e.value),n=le&&rn(t,le);V(Z&&n?[{value:n}]:[{value:An(t),symbol:te}])}else V(Z?[{value:"$0"}]:[{value:"0",symbol:te}])},t=ue?.tx??v;y.embeddedWallets.transactionScanning.enabled&&t?(q(!0),(async e=>{if(u)return await u.scanTransaction({metadata:{domain:y.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})})(t).then((e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?D("safe"):"Warning"===e.validation.result_type?D("warn"):"Malicious"===e.validation.result_type&&(D("error"),z(!0))),"Success"!==e.simulation.status)throw Error("Simulation failed");{P(e.simulation.params);let{assetsIn:t,assetsOut:n}=function(e,t){let n=[],r=[];if(e)for(let t of e)if(t.in[0]){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.in[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price},n.push(e)}else if(t.out[0]?.value){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.out[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.out[0].value,symbol:t.asset.symbol,usdValue:t.out[0].usd_price},r.push(e)}for(let e of t)for(let t of Object.keys(e.spenders)){let n;n="ERC721"===e.asset.type||"approve_for_all"===e.spenders[t]?.value?{nftName:e.asset.name}:{iconUrl:e.asset.logo_url,value:e.spenders[t]?.value,symbol:e.asset.symbol,usdValue:e.spenders[t]?.usd_price},r.push(n)}return{assetsIn:n,assetsOut:r}}(e.simulation.assets_diffs,e.simulation.exposures);if(0===n.length&&0===t.length)throw Error("No tokens found");V(n),j(t)}q(!1)})).catch((()=>{q(!1),e(t,ne,E)}))):e(t,ne,E)}),[v,ue?.tx,ne,E]),S/*#__PURE__*/)return t(xg,{txn:ue?.tx??v,onClose:pe,receipt:S,transactionInfo:e.sendTransaction?.uiOptions.transactionInfo,tokenPrice:le,tokenSymbol:te,receiptHeader:e.sendTransaction?.uiOptions.successHeader,receiptDescription:e.sendTransaction?.uiOptions.successDescription});if(O)/*#__PURE__*/return t(Zy,{transactionError:O,transactionHash:I??void 0,network:"ethereum",chainId:ue?.tx.chainId??v.chainId,onClose:pe,onRetry:({resetNonce:e})=>{W(null);let t={...ue?.tx??v};e&&(t.nonce=void 0),C(t)}});let _e=0!==w&&"number"==typeof g&&0!==g?()=>{f(g-1)}:void 0;return U&&M?/*#__PURE__*/t(Ig,{details:M,onBack:()=>F(!1)}):/*#__PURE__*/t($y,{transactionIndex:g,onBack:_e,maxIndex:w,disabled:Te&&!me||B,isSubmitting:_,submitError:O,isPreparing:!ue,isTokenPriceLoading:ce,isTokenContractInfoLoading:!ie&&!E,prepareError:ue?.errors[0],symbol:E?.symbol,chain:ee,img:Ee,title:ve,subtitle:Ce,txValue:v.value,fee:ge??ye,isSponsored:b,from:X?.address??"",to:oe,tokenAddress:se??void 0,network:y.chains.find((e=>e.id===v.chainId))?.name??"",transactionDetails:{...ne,formattedAmount:K},cta:Ae,missingFunds:Te,action:re,balance:we??fe,onClose:pe,onClick:be?async()=>{if(!X)return;if(!me)throw Error("Funding wallet is not enabled");let t=ur.FUNDING_METHOD_SELECTION_SCREEN;r({...e,funding:{...e.funding,methodScreen:t,chainType:"ethereum",amount:Ba(BigInt(ue?.tx.value??0)+BigInt(ue?.totalGasEstimate?.toString()??0)),chain:ee}}),a(t)}:async()=>{if(g<w)f(g+1);else{k(!0);try{let t=await p();if(_||!t||!X||!h||!m)return;let n=e?.sendTransaction?.onConfirm?await e.sendTransaction.onConfirm():await Cg({accessToken:t,transactingWallet:X,entropyId:J,entropyIdVerifier:Q,walletProxy:h,transactionRequest:ue?.tx??v,publicClient:he,requesterAppId:e.sendTransaction?.requesterAppId});if(N(n),e.sendTransaction?.signOnly)return await new Promise((e=>setTimeout(e,yr))),e?.sendTransaction?.onSuccess({hash:n}),d({shouldCallAuthOnSuccess:!1});let r=await he.waitForTransactionReceipt({hash:n});if("reverted"===r.status)throw Error("Transaction failed");R(r)}catch(e){console.warn({transaction:ue?.tx??v,error:e}),W(e)}finally{k(!1)}}},validation:L,hasScanDetails:!!M,setIsScanDetailsOpen:F,preventMaliciousTransaction:B,setPreventMaliciousTransaction:z,tokensSent:H,tokensReceived:$,isScanning:G,isCancellable:e.sendTransaction?.uiOptions?.isCancellable??!1})},[ur.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN]:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=hr(),{client:l,closePrivyModal:c,walletProxy:d}=x(),h=pr(),{user:u,getAccessToken:p}=mr(),[m,y]=s(e?.sendSolanaTransaction?.transactionRequest),[g,f]=s(),[w,v]=s(),[C,E]=s(0),[T,b]=s({value:0n,isLoading:!1}),[A,_]=s(!1),[k,I]=s(),[N,S]=s(),R=e?.sendSolanaTransaction?.connection,O=e?.sendSolanaTransaction?.transactingWallet,W=e?.sendSolanaTransaction?.signOnly??!1,M=g?.instructions.length??1,P=O?.imported?Fr(u):Er(u),L=Ar(R?.rpcEndpoint||""),D="fiat-currency"===h.embeddedWallets.priceDisplay.primary,{solPrice:U,isSolPriceLoading:F}=Nh({enabled:D}),B=i((()=>{let e,t;if(!g)return;let n=g.spender;0===C&&O?.address===n&&(e=Wh(g.fee));let r=Wh(T.value,3,!0),a=g.instructions[C];if(!a)return{fee:e,spender:n,balance:r};if("unknown"===a.type)return{fee:e,spender:n,program:a.program,balance:r};if("ata-creation"===a.type)return{fee:e,spender:n,balance:r,tokenAccountOwner:a.owner,tokenAccount:a.ata,tokenAddress:a.mint};let i=a.fromAccount,o="sol-transfer"===a.type?a.toAccount:a.toAccount||a.toAta,s="spl-transfer"===a.type?a.token.address:void 0;return null!=e&&"SOL"===a.token.symbol&&(t=Wh(a.value+g.fee)),{fee:e,spender:n,from:i,to:o,tokenAddress:s,amount:`${Ma(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}}),[g,C,O?.address,T]),z=i((()=>{let e,t;if(!g||!D||!U||F)return;function n(...e){return Mh(e.reduce(((e,t)=>e+t),0n),U??0)}0===C&&O?.address===g.spender&&(e=n(g.fee));let r=n(T.value),a=g.instructions[C];return a&&"unknown"!==a.type&&"ata-creation"!==a.type?(null!=e&&"SOL"===a.token.symbol&&(t=n(a.value,g.fee)),{fee:e,amount:"SOL"===a.token.symbol?n(a.value):`${Ma(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}):{fee:e,balance:r}}),[g,D,U,F,O?.address,C,T]),H=i((()=>{if(W||!g||T.isLoading||C>0)return!1;let e=g.instructions[C];if(!e)return!1;let t=0n;return O?.address===g.spender&&(t+=g.fee),"value"in e&&O?.address===e.fromAccount&&"SOL"===e.token.symbol&&(t+=e.value),T.value<t}),[g,T,C,W]);if(o((()=>{!async function(){if(m&&R&&l)try{v(void 0);let e=await Uh({tx:m,connection:R,client:l});f(e),E(0)}catch(e){console.error("Failed to prepare transaction",e),v(e)}}()}),[m,R,l]),o((()=>{(async function(){if(!O||!R)return;b({value:T.value,isLoading:!0});let e=new Bi({name:"mainnet-beta",rpcUrl:R.rpcEndpoint});b({value:await e.getBalance(O.address).catch((()=>0n))??0n,isLoading:!1})})().catch(console.error)}),[g,R]),!(m&&e?.sendSolanaTransaction&&O&&R)){let n=Error("Invalid transaction request");/*#__PURE__*/return t(oh,{error:n,onClick:()=>{e?.sendSolanaTransaction?.onFailure(n),c({shouldCallAuthOnSuccess:!1})}})}let V=()=>{if(!A)return k?e?.sendSolanaTransaction?.onSuccess(k):(e?.sendSolanaTransaction?.onFailure(N??w??Error("User exited the modal before submitting the transaction")),E(0)),c({shouldCallAuthOnSuccess:!1})};n.current=V;let $=e.sendSolanaTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/t("img",{src:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,j=!!(e.funding&&e.funding.supportedOptions.length>0),G=H&&j;return k?/*#__PURE__*/t(wg,{instructions:g?.instructions.reduce(((e,t)=>("ata-creation"===t.type&&e.push({tokenAccountOwner:t.owner,tokenAccount:t.ata}),"spl-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount||t.toAta,amount:t.value,token:t.token}),"sol-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount,amount:t.value,token:t.token}),e)),[])??[],fees:0===C?k.fees:0n,onClose:V,transactionInfo:e.sendSolanaTransaction?.uiOptions.transactionInfo,solPrice:U,receiptHeader:e.sendSolanaTransaction?.uiOptions.successHeader,receiptDescription:e.sendSolanaTransaction?.uiOptions.successDescription,rpcEndpoint:R.rpcEndpoint,signOnly:W}):N?/*#__PURE__*/t(Zy,{transactionError:N,connection:R,onClose:V,network:"solana",onRetry:async()=>{S(void 0);let{blockhash:e}=await R.getLatestBlockhash();Lh(m)?m.message.recentBlockhash=e:m.recentBlockhash=e,y(m)}}):/*#__PURE__*/t(jy,{img:$,title:e.sendSolanaTransaction?.uiOptions?.transactionInfo?.title||"Confirm transaction",subtitle:e.sendSolanaTransaction?.uiOptions?.description||`${h.name} wants your permission to approve the following transaction.`,cta:G?"Add funds":e.sendSolanaTransaction?.uiOptions?.buttonText||"Approve",transactionIndex:C,maxIndex:M-1,network:"mainnet-beta"==L?"Solana":L,blockExplorerUrl:"https://explorer.solana.com",total:D?z?.total:B?.total,amount:D?z?.amount:B?.amount,fee:D?z?.fee:B?.fee,balance:D?z?.balance:B?.balance,from:B?.from,to:B?.to,tokenAccount:B?.tokenAccount,tokenAccountOwner:B?.tokenAccountOwner,tokenAddress:B?.tokenAddress,transactingWalletAddress:O.address,programAddress:B?.program,disabled:H&&!j,isSubmitting:A,isPreparing:!g||T.isLoading,isTokenPriceLoading:D&&F,isMissingFunds:H,submitError:N??void 0,parseError:w,onClick:G?async()=>{if(!O)return;if(!j)throw Error("Funding wallet is not enabled");let t=ur.FUNDING_METHOD_SELECTION_SCREEN;r({...e,funding:{...e.funding,methodScreen:t}}),a(t)}:async()=>{if(C<(g?.instructions.length??1)-1)E(C+1);else try{_(!0);let t=await p();if(A||!t||!O||!d||!u||!P)return;let{rootWallet:n}=Br(u,O.address);if(!n)throw Error("No root wallet for transacting wallet found");let{entropyId:r,entropyIdVerifier:a}=qn(n);if(W)await Ry({tx:m,accessToken:t,walletProxy:d,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:O.address,transactingWalletIndex:O.walletIndex??0}),I(Dh("",m,null));else{let{signature:n,receipt:i}=await Oy({tx:m,accessToken:t,connection:R,walletProxy:d,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:O.address,transactingWalletIndex:O.walletIndex??0,transactionOptions:e.sendSolanaTransaction?.transactionOptions});I(Dh(n,m,i))}}catch(e){console.warn({transaction:m,error:e}),S(e)}finally{_(!1)}},onClose:V,onBack:C>0&&M>1?()=>E(C-1):void 0})},[ur.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN]:()=>{let{app:r,data:a}=hr(),{closePrivyModal:i}=x(),[l,c]=s(!1),[d,h]=s(),{address:u,onDelegate:p,onSuccess:m,onError:y}=a.delegatedActions.consent,g=async()=>{l?m():y(d??new T("User declined delegating actions.")),i({shouldCallAuthOnSuccess:!1})};return o((()=>{if(!l&&!d)return;let e=setTimeout(g,gr);return()=>clearTimeout(e)}),[l,d]),/*#__PURE__*/e(n,l||d?{children:[/*#__PURE__*/t(lt,{onClose:g}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(mt,{children:[d?/*#__PURE__*/t(ei,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(ci,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(xt,{height:20}),/*#__PURE__*/t(Zl,{title:d?"Something went wrong":"Success!",description:d?"Please try again.":`You’ve successfully granted delegated action permissions to ${r.name}.`})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]}:{children:[/*#__PURE__*/t(lt,{closeable:!0,onClose:g}),/*#__PURE__*/t(di,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(kl,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),/*#__PURE__*/e(Il,{style:{marginBottom:24,textWrap:"pretty"},children:["By confirming, ",r.name," will be able to use your wallet for you even when you're not around. You can revoke this later."]}),/*#__PURE__*/t(Rc,{showIcon:!0,address:u,title:"Wallet",isLoading:!1}),/*#__PURE__*/e(Sc,{style:{marginTop:24},children:[/*#__PURE__*/t(ut,{onClick:g,children:"Not now"}),/*#__PURE__*/t(ct,{onClick:async()=>{try{await p(),c(!0)}catch(e){h(e)}},children:"Accept"})]}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_DELEGATED_ACTIONS_REVOKE_SCREEN]:()=>{let{app:r,data:a}=hr(),{closePrivyModal:i}=x(),[l,c]=s(!1),[d,h]=s(),{onRevoke:u,onSuccess:p,onError:m}=a.delegatedActions.revoke,y=async()=>{l?p():m(d??new T("User declined revoking access to their delegated wallet.")),i({shouldCallAuthOnSuccess:!1})};return o((()=>{if(!l&&!d)return;let e=setTimeout(y,gr);return()=>clearTimeout(e)}),[l,d]),/*#__PURE__*/e(n,l||d?{children:[/*#__PURE__*/t(lt,{onClose:y}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(mt,{children:[d?/*#__PURE__*/t(ei,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(ci,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(xt,{height:20}),/*#__PURE__*/t(Zl,{title:d?"Something went wrong":"Success!",description:d?"Please try again.":"You've successfully revoked permissions."})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]}:{children:[/*#__PURE__*/t(lt,{closeable:!0,onClose:y}),/*#__PURE__*/t(hi,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(kl,{style:{marginTop:24},children:"Revoke offline access to wallet"}),/*#__PURE__*/e(Il,{children:["By confirming, ",r.name," will no longer be able to use this wallet on your behalf when you are not online."]}),/*#__PURE__*/e(Oc,{style:{marginTop:24},children:[/*#__PURE__*/t(ut,{onClick:y,children:"Deny"}),/*#__PURE__*/t(ct,{onClick:async()=>{try{await u(),c(!0)}catch(e){h(e)}},children:"Confirm"})]}),/*#__PURE__*/t(ht,{})]})},[ur.FUNDING_METHOD_SELECTION_SCREEN]:()=>{let{wallets:r}=_r(),{wallets:a}=ca(),{navigate:s,data:l,setModalData:c}=hr(),{client:d}=x(),h=pr(),u=l?.funding,p=qu(ep),m=qu(tp),y="solana"===u.chainType,g=y?void 0:u,f=i((()=>((e,t,n,r,a,i)=>{let o,s,l="solana"===n.chainType,c=l?void 0:n,d=n.isUSDC?"USDC":c?.erc20Address?void 0:"native-currency",h=!!l||d&&Ii(Number(n.chain.id),d),u=!!l||d&&Ni(Number(n.chain.id),d),p=[];for(let o of(n.preferredCardProvider&&n.supportedOptions.sort((e=>e.provider===n.preferredCardProvider?-1:1)),n.supportedOptions))"card"===o.method&&"coinbase"===o.provider&&u&&p.push((()=>Ju(t,n,r,a,i,"buy"))),"card"===o.method&&"moonpay"===o.provider&&h&&d&&p.push((()=>Qu(t,n,e,d,r,a,i,"credit_debit_card")));for(let e of n.supportedOptions)"exchange"===e.method&&"coinbase"===e.provider&&u&&(o=()=>Ju(t,n,r,a,i,"buy"));for(let e of i?.funding?.supportedOptions??[])"wallets"===e.method&&(s=()=>a(ur.FUNDING_TRANSFER_FROM_WALLET_SCREEN));return{onFundWithCard:p,onFundWithExchange:o,onFundWithWallet:s}})(h,d,u,c,s,l)),[h,d,u,l,c,s]);o((()=>{if(u?.defaultFundingMethod&&u.usingDefaultFundingMethod)switch(c({funding:{...u,usingDefaultFundingMethod:!1}}),u?.defaultFundingMethod){case"card":f.onFundWithCard[0]&&f.onFundWithCard[0]();break;case"exchange":f.onFundWithExchange&&f.onFundWithExchange();break;case"wallet":f.onFundWithWallet&&f.onFundWithWallet();break;case"manual":s(ur.FUNDING_MANUAL_TRANSFER_SCREEN)}}),[]),o((()=>{g?.erc20Address&&!g.erc20ContractInfo&&dn({address:g.erc20Address,chain:g.chain,rpcConfig:h.rpcConfig,privyAppId:h.id}).then((e=>{c({...l,funding:{...g,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}})})).catch(console.error)}),[g?.erc20Address,g?.chain]);let w=y?a.find((({address:e})=>e===u.address)):r.find((({address:e})=>C(e)===C(u.address))),v=vt(w?.walletClientType||"unknown"),E=v?.name||"wallet",T=w&&"privy"!==w.walletClientType?E:h.name,b=!(!g?.erc20Address||g?.erc20ContractInfo);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/e("h3",{children:["Add funds to your"," ",T?.toLowerCase().endsWith("wallet")?T:T+" wallet"]}),/*#__PURE__*/e(Eu,{children:[u.errorMessage&&/*#__PURE__*/t(zu,{theme:h.appearance.palette.colorScheme,children:u.errorMessage}),f.onFundWithCard?.[0]&&/*#__PURE__*/e(rl,{disabled:b,onClick:f.onFundWithCard[0],children:[/*#__PURE__*/t(Tu,{children:/*#__PURE__*/t(Qi,{style:{width:24}})}),"Pay with card",p?/*#__PURE__*/t(ju,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):m?/*#__PURE__*/t(Gu,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):null]}),f.onFundWithExchange&&/*#__PURE__*/e(rl,{disabled:b,onClick:f.onFundWithExchange,children:[/*#__PURE__*/t(Tu,{children:/*#__PURE__*/t(Ji,{style:{width:24}})}),"Transfer from an exchange"]}),f.onFundWithWallet&&/*#__PURE__*/e(rl,{disabled:b,onClick:f.onFundWithWallet,children:[/*#__PURE__*/t(Tu,{children:/*#__PURE__*/t(hn,{style:{width:24}})}),"Transfer from wallet"]}),/*#__PURE__*/e(rl,{disabled:b,onClick:()=>s(ur.FUNDING_MANUAL_TRANSFER_SCREEN),children:[/*#__PURE__*/t(Tu,{children:/*#__PURE__*/t(Xi,{style:{width:24}})}),"Receive funds"]}),u?.showAlternateFundingMethod&&f.onFundWithCard?.[1]&&/*#__PURE__*/t(Vu,{theme:h.appearance.palette.colorScheme,children:/*#__PURE__*/e(xu,{children:["Having trouble or facing location restrictions?"," ",/*#__PURE__*/t(Su,{onClick:f.onFundWithCard[1],children:"Try a different provider."})]})})]}),/*#__PURE__*/t(ht,{})]})},[ur.MOONPAY_STATUS_SCREEN]:()=>{let{app:r,data:a,setModalData:i,navigateBack:o}=hr(),{closePrivyModal:s}=x(),{externalTransactionId:l}=a?.moonpayStatus,c=ha(l||null,r.fundingMethodConfig.moonpay.useSandbox??!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{title:"Fund account",backFn:()=>{let e={...a?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),i({funding:e}),o()}}),/*#__PURE__*/t(ip,{status:c,onClickCta:s}),/*#__PURE__*/t(ht,{})]})},[ur.COINBASE_ONRAMP_STATUS_SCREEN]:()=>{let{data:r,setModalData:a,navigate:i,navigateBack:c}=hr(),{closePrivyModal:d,createAnalyticsEvent:h,client:u}=x(),[p,m]=s("pending-in-flow"),y=l(0),g={...r?.funding,showAlternateFundingMethod:!0};g.usingDefaultFundingMethod&&(g.usingDefaultFundingMethod=!1);let{partnerUserId:f,popup:w}=r?.coinbaseOnrampStatus??{};return o((()=>{if("pending-in-flow"===p||"pending-after-flow"===p){let e=setInterval((async()=>{if(f)try{let{status:e}=await u.getCoinbaseOnRampStatus({partnerUserId:f});if("success"===e)return void m("success");if("failure"===e)throw Error("There was an error completing Coinbase Onramp flow.");if(y.current>=3)return a({funding:g}),void i(ur.FUNDING_METHOD_SELECTION_SCREEN);w?.closed&&(y.current=y.current+1,m("pending-after-flow"))}catch(e){console.error(e),m("error"),h({eventName:la,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),a({funding:{...g,errorMessage:"Something went wrong adding funds. Please try again or use another method."}}),i(ur.FUNDING_METHOD_SELECTION_SCREEN)}}),1500);return()=>clearInterval(e)}}),[f,w,p]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{title:"Fund account",backFn:()=>{a({funding:g}),c()}},"header"),/*#__PURE__*/t(Du,{status:p,onClickCta:d}),/*#__PURE__*/t(ht,{})]})},[ur.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:()=>{let r,{connectors:a}=x(),{app:i,setModalData:l,data:c,navigate:d}=hr(),{wallets:h}=_r(),{wallets:u}=ca(),[p,m]=s("default"),y="solana"===c?.funding?.chainType,g=!!c?.funding?.crossChainBridgingEnabled;r="ethereum"===c?.funding?.chainType?c.funding.erc20Address&&!c.funding.isUSDC?"ethereum-only":g&&!c.funding.chain.testnet?"ethereum-and-solana":"ethereum-only":g?"ethereum-and-solana":"solana-only";let f=h.filter((e=>"privy"!==e.walletClientType)),w=f.map((e=>e.walletClientType)),v=u.filter((e=>"privy"!==e.walletClientType)),C=v.map((e=>e.walletClientType)),E=[],T={...c.funding};T.usingDefaultFundingMethod&&(T.usingDefaultFundingMethod=!1);let b=({address:e,walletChainType:t})=>{l({...c,funding:{...T,connectedWalletAddress:e,onContinueWithExternalWallet:()=>d(_({destChainType:y?"solana":"ethereum",sourceChainType:t}))}}),d(ur.FUNDING_EDIT_AMOUNT_SCREEN)};"solana-only"!==r&&E.push(...f.map(((e,n)=>/*#__PURE__*/t(dp,{onClick:()=>b({address:e.address,walletChainType:"ethereum"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),"ethereum-only"!==r&&E.push(...v.map(((e,n)=>/*#__PURE__*/t(dp,{onClick:()=>b({address:e.address,walletChainType:"solana"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),E.push(...kc({walletList:i.appearance.walletList.filter((e=>!f.some((t=>t.walletClientType===e))&&!v.some((t=>t.walletClientType===e)))),walletChainType:r,connectors:a,connectOnly:!0,ignore:[...i.appearance.walletList,...w,...C],walletConnectEnabled:i.externalWallets.walletConnect.enabled}));let A=/*#__PURE__*/t(cp,{text:"More wallets",onClick:()=>m("overflow")}),_=({sourceChainType:e,destChainType:t})=>"ethereum"===e&&"solana"===t?ur.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN:"ethereum"===e&&"ethereum"===t?ur.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN:"solana"===e&&"ethereum"===t?ur.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN:ur.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN;return o((()=>{l({...c,externalConnectWallet:{onCompleteNavigateTo:({walletChainType:e})=>(l({...c,funding:{...T,onContinueWithExternalWallet:()=>{d(_({destChainType:y?"solana":"ethereum",sourceChainType:e??"ethereum"}))}}}),ur.FUNDING_EDIT_AMOUNT_SCREEN)}})}),[]),/*#__PURE__*/e(n,"overflow"===p?{children:[/*#__PURE__*/t(lt,{backFn:()=>m("default")},"header"),/*#__PURE__*/e(Xs,{children:[/*#__PURE__*/t(Wt,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),E]}),/*#__PURE__*/t(ht,{})]}:{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(Zl,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),/*#__PURE__*/e(Xs,{children:[E.length>4?E.slice(0,3):E,E.length>4&&A]}),/*#__PURE__*/t(ht,{})]})},[ur.FUNDING_EDIT_AMOUNT_SCREEN]:()=>{let{data:r,setModalData:a}=hr(),i=r?.funding,o="solana"===i.chainType,s=l(null),{tokenPrice:c}=xh(o?"solana":i.chain.id),d=o?void 0:i,h=!(!d?.erc20Address||d?.erc20ContractInfo),u=o?"SOL":i.erc20Address?i.erc20ContractInfo?.symbol:i.chain.nativeCurrency.symbol||"ETH",p=parseFloat(i.amount),m=!isNaN(p)&&p>0,y=c?nn(i.amount,c):void 0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(Ot,{children:"Confirm or edit amount"}),/*#__PURE__*/e(cn,{style:{marginTop:"32px"},children:[/*#__PURE__*/t(bu,{children:h?/*#__PURE__*/t(bh,{size:"50px"}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(Au,{onClick:()=>s.current?.focus(),children:[/*#__PURE__*/t(ku,{ref:s,value:i.amount,onChange:e=>{let t=e.target.value;/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1&&a({...r,funding:{...i,amount:t}})}}),/*#__PURE__*/t(Iu,{children:u})]}),!d?.erc20Address&&/*#__PURE__*/t(Nu,{children:y&&m?`${y} USD`:""})]})}),/*#__PURE__*/t(Xt,{style:{marginTop:"1rem"},disabled:!m,onClick:i.onContinueWithExternalWallet,children:"Continue"})]}),/*#__PURE__*/t(ht,{})]})},[ur.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:l}=x(),{navigate:c,setModalData:d,app:h,data:u}=hr(),{wallets:p}=_r(),[m,y]=s(!1),[g,f]=s(0n),[w,v]=s(!1),[C,E]=s(null),[b,_]=s(null),[k,I]=s([]),[N,S]=s(0),[R,O]=s(!1),[W,M]=s(!1),[P,L]=s(!1),[D,U]=s(!1),[F,B]=s(),[z,H]=s();if(!u?.funding||"ethereum"!==u.funding.chainType)throw Error("Invalid funding data");let{erc20ContractInfo:V,chain:$,connectedWalletAddress:j}=u.funding,G=u.funding.address,q=u.funding.erc20Address,[K,Y]=s(u.funding.amount);o((()=>{q&&!V&&E(Error("Unable to fetch token details"))}),[]);let Z=!!q&&!!V,J=Z?BigInt(parseFloat(K)*10**V.decimals):Pa(K),Q=j?p.find((({address:e})=>e===j)):p[0],X=vt(Q?.walletClientType||"unknown"),ee=X?.name||"wallet",[te,ne]=s(null);o((()=>{(async()=>{if(!Q)return;let e=await Q.getEthereumProvider();ne(Ra({account:Q.address,transport:Oa(e)}).extend(Wa))})().catch(console.error)}),[Q]);let[re,ae]=s(0n);o((()=>{xa({chain:$,transport:Sa(Va($,r,a))}).getBalance({address:G}).then(ae).catch(console.error)}),[]);let[ie,oe]=s(0n);o((()=>{Z&&tn({chain:$,address:G,appId:a,rpcConfig:r,erc20Address:q}).then((e=>oe(e.balance))).catch(console.error)}),[]);let{tokenPrice:se}=xh($.id),[le,ce]=s({to:G,chain:$,value:J,data:void 0});o((()=>{(async()=>{let e,t;if(!te||!Q||R||P)return;O(!0);let n=xa({chain:le.chain,transport:Sa(Va(le.chain,r,a))});if(Z&&!le.data)return await n.simulateContract({address:q,chain:le.chain,abi:Lu,functionName:"transfer",args:[G,J],account:Q.address}).catch((e=>{console.warn("Simulated token transfer failed with error, fetching bridge options.",e)}))?(O(!1),void ce({to:q,chain:le.chain,data:La({abi:Lu,functionName:"transfer",args:[G,J]}),value:"0x0"})):(O(!1),void v(!0));try{e=await n.prepareTransactionRequest({account:Q.address,to:le.to,chain:le.chain,data:le.data,value:BigInt(le.value??0)})}catch(e){if(console.error(e),k.length>1)_(e.shortMessage??"Something went wrong");else if(W&&0===k.length)return void E(new T(`Wallet ${Tt(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))}if(!e)return O(!1),void v(!0);O(!1),L(!0),y(!0),f(e.gas);try{await te.switchChain({id:le.chain.id})}catch(e){await te.addChain({chain:le.chain}),await te.switchChain({id:le.chain.id})}try{t=await te.sendTransaction(e)}catch(e){if(console.error(e),"TransactionExecutionError"===e.name)if(k.length<1){let t=e.shortMessage;(e.shortMessage.includes("rejected the request")||e.details.includes("rejected the request"))&&(t="User rejected the request."),E(new T(t,void 0,A.TRANSACTION_FAILURE))}else _(e.shortMessage??"Something went wrong")}if(t)return await te.waitForTransactionReceipt({hash:t}),L(!1),W?(B(t),void H("pending")):(U(!0),void l({eventName:la,payload:{provider:"external",status:"success",txHash:t,address:Q.address,chainId:le.chain.id,chainType:"ethereum",value:le.value?Ma(BigInt(le.value),V?.decimals??18):void 0,token:V?.symbol??q??"ETH",destinationAddress:G,destinationChainId:$.id,destinationChainType:"ethereum",destinationValue:J?Ma(J,V?.decimals??18):void 0,destinationToken:V?.symbol??q??$.nativeCurrency.name}}));L(!1)})().catch(console.error)}),[te,le]),o((()=>{(async()=>{if(!w||!te||!Q)return;let e=Tr(h.chains).filter((e=>e.id!==$.id&&!!e.testnet==!!$.testnet));Z&&e.unshift($);let t=await Hh({chains:e,address:Q.address,appId:a,rpcConfig:r}),n=Z?t.filter((e=>e.balance>0n)):t.filter((e=>e.balance>J));if(n.length<1)return void E(new T(`Wallet ${Tt(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({quote:await nh({isTestnet:!!$.testnet,input:Xd({amount:J.toString(),user:Q.address,recipient:G,destinationChainId:$.id,destinationCurrency:q,originChainId:e.chain.id})}),...e}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void E(new T(`Wallet ${Tt(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));let o=i.map((e=>({bridgeTx:rh(e.quote),balance:e.balance,chain:e.chain}))).filter((e=>!!e.bridgeTx));if(o.length>1)return void I(o);let s=o[0];s?(M(!0),ce({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):E(new T(`Wallet ${Tt(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))})().catch(console.error)}),[w]),ah({transactionHash:F,wallet:Q,isTestnet:!!$.testnet,bridgingStatus:z,setBridgingStatus:H,onSuccess({transactionHash:e,wallet:t}){M(!1),U(!0),l({eventName:la,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:le.chain.id,chainType:"ethereum",value:le.value?Ma(BigInt(le.value),V?.decimals??18):void 0,token:V?.symbol??q??"ETH",destinationAddress:G,destinationChainId:$.id,destinationChainType:"ethereum",destinationValue:J?Ma(J,V?.decimals??18):void 0,destinationToken:V?.symbol??q??$.nativeCurrency.name}})},onFailure({error:e}){M(!1),E(e)}}),o((()=>{if(!C)return;let e={error:C,previousScreen:ur.FUNDING_TRANSFER_FROM_WALLET_SCREEN};d({funding:u?.funding,sendTransaction:u?.sendTransaction,errorModalData:e}),c(ur.ERROR_SCREEN,!1)}),[C]);let de=!Z&&se?nn(K??"0",se):void 0,he=Z?g:on([g,J]),ue=he&&se?rn(he,se):void 0,pe=he?Jt(he,"ETH"):void 0,me=g&&se?rn(g,se):void 0,ye=g?Jt(g,"ETH"):void 0;if(o((()=>{if(!D)return;let e=setTimeout(i,Nr);return()=>clearTimeout(e)}),[D]),D/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(Rt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zl,{title:"Success!",description:`You’ve successfully added ${K} ${Z?V.symbol:$.nativeCurrency.symbol} to your ${h.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]});let ge=Z?`${an({amount:ie,decimals:V.decimals})} ${V.symbol}`:Jt(re,$.nativeCurrency.symbol,3,!0),fe=k[N];return k.length>1&&fe?/*#__PURE__*/t(Ru,{displayName:ee,configuredFundingChain:$,formattedBalance:ge,fundingAmount:K,fundingCurrency:Z?V.symbol:$.nativeCurrency.symbol,fundingAmountInUsd:de,options:k,selectedOption:fe,isPreparing:R,isSubmitting:P,addressToFund:G,fundingWalletAddress:Q?.address||"",errorMessage:b,onSubmit:()=>{u.funding?.amount!==K?async function(){if(Q&&fe)try{let e=await nh({isTestnet:!!$.testnet,input:Xd({amount:J.toString(),user:Q.address,recipient:G,destinationChainId:$.id,destinationCurrency:q,originChainId:fe.chain.id})}),t=rh(e);if(!t)throw Error("Invalid transaction request");M(!0),ce({data:t.data,to:t.to,value:t.value,chain:fe.chain})}catch(e){console.error(e),E(new T("Unable to fetch quotes for bridging",e,A.INSUFFICIENT_BALANCE))}}().catch(console.error):ce({to:fe.bridgeTx.to,data:fe.bridgeTx.data,value:fe.bridgeTx.value,chain:fe.chain})},onSelect:e=>{e!==N&&(_(null),S(e))},onAmountChange:Y}):m&&g&&Q&&u?.funding?/*#__PURE__*/t(Ou,{wallet:Q,displayName:ee,addressToFund:G,isBridging:W,isErc20Flow:Z,totalPriceInUsd:ue,totalPriceInNativeCurrency:pe,gasPriceInUsd:me,gasPriceInNativeCurrency:ye,chainId:$.id,chainName:$.name}):
16
+ /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(bh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ht,{})]})},[ur.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN]:()=>{let{closePrivyModal:r,createAnalyticsEvent:a}=x(),{navigate:i,setModalData:c,app:d,data:h}=hr(),{wallets:u}=ca(),p=oa(),[m,y]=s(0n),[g,f]=s(null),[w,v]=s(!1),[C,E]=s(!1),b=l(!1);if(!h?.funding||"solana"!==h.funding.chainType)throw Error("Invalid funding data");let{address:_,amount:k,cluster:I,connectedWalletAddress:N}=h.funding,S=xr(I),{tokenPrice:R}=xh("solana"),{fundingAmountInBaseUnit:O,totalPriceInUsd:W,totalPriceInNativeCurrency:M,feePriceInNativeCurrency:P,feePriceInUsd:L}=Ph({amount:k,fee:m,tokenPrice:R}),D=N?u.find((({address:e})=>e===N)):u[0],U=vt(D?.walletClientType||"unknown"),F=U?.name||"wallet";return o((()=>{(async()=>{if("solana"===D?.type&&D.sendTransaction&&!w&&!b.current){b.current=!0;try{let e=p(sa);if(!e)throw new T("Unable to load solana plugin");let{connection:t,transaction:n}=await e.createTransferTransaction({from:D.address,to:_,amount:O,cluster:I}),r=await n.getEstimatedFee(t);null!=r&&y(BigInt(r)),v(!0);let i=await t.simulateTransaction(n);if(i.value.err)return i.value.logs?.find((e=>/insufficient (lamports|funds)/gi.test(e)))?void f(new T(`Wallet ${Tt(D.address,void 0,void 0,"solana")} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",i.value.err),void f(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE)));let o=await D.sendTransaction(n,t);a({eventName:la,payload:{provider:"external",status:"success",txHash:o,rpcEndpoint:S,address:D.address,value:Ma(O,9),chainType:"solana",clusterName:I.name,token:"SOL",destinationAddress:_,destinationValue:Ma(O,9),destinationChainType:"solana",destinationClusterName:I.name,destinationToken:"SOL"}}),v(!1),E(!0)}catch(e){if(console.error(e),v(!1),/user rejected the request/gi.test(e.message||""))return void f(new T("Transaction was rejected by the user",void 0,A.TRANSACTION_FAILURE));f(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE))}}})().catch(console.error).finally((()=>b.current=!1))}),[]),o((()=>{if(!g)return;let e={error:g,previousScreen:ur.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),i(ur.ERROR_SCREEN,!1)}),[g]),o((()=>{if(!C)return;let e=setTimeout(r,Nr);return()=>clearTimeout(e)}),[C]),C?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(Rt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zl,{title:"Success!",description:`You’ve successfully added ${k} SOL to your ${d.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]}):D&&w?/*#__PURE__*/t(Ou,{wallet:D,displayName:F,addressToFund:_,isBridging:!1,isErc20Flow:!1,totalPriceInUsd:W,totalPriceInNativeCurrency:M,gasPriceInUsd:L,gasPriceInNativeCurrency:P,chainId:"solana",chainName:I.name}):
17
+ /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(bh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ht,{})]})},[ur.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN]:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:l}=x(),{navigate:c,setModalData:d,app:h,data:u}=hr(),{wallets:p}=_r(),m=oa(),[y,g]=s(null),[f,w]=s(null),[v,C]=s([]),[E,b]=s(0),[_,k]=s(!1),[I,N]=s(!1),[S,R]=s(!1),[O,W]=s(!1),[M,P]=s(),[L,D]=s();if(!u?.funding||"solana"!==u.funding.chainType)throw Error("Invalid funding data");let{address:U,cluster:F,connectedWalletAddress:B}=u.funding,[z,H]=s(u.funding.amount),V=B?p.find((({address:e})=>e===B)):p[0],$=vt(V?.walletClientType||"unknown"),j=$?.name||"wallet",[G,q]=s(null);o((()=>{(async()=>{if(!V)return;let e=await V.getEthereumProvider();q(Ra({account:V.address,transport:Oa(e)}).extend(Wa))})().catch(console.error)}),[V]);let[K,Y]=s(0n),Z=Wh(K);o((()=>{let e=m(sa);e?e.getBalance({address:U,cluster:F}).then((e=>Y(BigInt(e)))):console.warn("Unable to load solana plugin, skipping balance")}),[]);let[J,Q]=s(),{tokenPrice:X}=xh("solana"),{fundingAmountInBaseUnit:ee,fundingAmountInUsd:te}=Ph({amount:z,fee:0n,tokenPrice:X});if(o((()=>{(async()=>{if(!G||!V)return;let e=["testnet","devnet"].includes(F.name);e&&console.warn("Solana testnets are not supported for bridging");let t=Tr(h.chains).filter((({testnet:t})=>!!t===e)),n=(await Hh({chains:t,address:V.address,appId:a,rpcConfig:r})).filter((e=>e.balance>0n));if(n.length<1)return void g(new T(`Wallet ${Tt(V.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({...e,quote:await nh({isTestnet:!1,input:Xd({amount:ee.toString(),user:V.address,recipient:U,destinationChainId:kr,destinationCurrency:Ir,originChainId:e.chain.id})})}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void g(new T(`Unable to fetch quotes for bridging. Wallet ${Tt(V.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));let o=i.map((({quote:e,balance:t,chain:n})=>({bridgeTx:rh(e),balance:t,chain:n}))).filter((({bridgeTx:e})=>!!e));if(o.length>1)return void C(o);let s=o.at(0);s?(N(!0),Q({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):g(new T(`Unable to select bridge option from quotes. Wallet ${Tt(V.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))})().catch(console.error)}),[G]),o((()=>{(async()=>{let e,t;if(!G||!V||_||S||!J)return;k(!0);let n=xa({chain:J.chain,transport:Sa(Va(J.chain,r,a))});try{e=await n.prepareTransactionRequest({account:V.address,to:J.to,chain:J.chain,data:J.data,value:BigInt(J.value??0)})}catch(e){console.error(e),v.length>1&&w(e.shortMessage??"Something went wrong")}if(e){k(!1),R(!0);try{await G.switchChain({id:J.chain.id})}catch(e){await G.addChain({chain:J.chain}),await G.switchChain({id:J.chain.id})}try{t=await G.sendTransaction(e)}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(v.length<1?g(new T(e.shortMessage,void 0,A.TRANSACTION_FAILURE)):w(e.shortMessage??"Something went wrong"))}if(t)return await G.waitForTransactionReceipt({hash:t}),I?(D("pending"),void P(t)):(R(!1),W(!0),void l({eventName:la,payload:{provider:"external",status:"success",txHash:t,address:V.address,chainId:J.chain.id,chainType:"ethereum",value:J.value?Ma(BigInt(J.value),18):void 0,token:"ETH",destination:U,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ma(ee,9),destinationToken:"SOL"}}));R(!1)}else k(!1)})().catch(console.error)}),[G,J]),ah({transactionHash:M,wallet:V,isTestnet:!1,bridgingStatus:L,setBridgingStatus:D,onSuccess({transactionHash:e,wallet:t}){N(!1),W(!0),l({eventName:la,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:J?.chain.id,chainType:"ethereum",value:J?.value?Ma(BigInt(J.value),18):void 0,token:"ETH",destination:U,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ma(ee,9),destinationToken:"SOL"}})},onFailure({error:e}){N(!1),g(e)}}),o((()=>{if(!y)return;let e={error:y,previousScreen:ur.FUNDING_TRANSFER_FROM_WALLET_SCREEN};d({funding:u?.funding,sendTransaction:u?.sendTransaction,errorModalData:e}),c(ur.ERROR_SCREEN,!1)}),[y]),o((()=>{if(!O)return;let e=setTimeout(i,Nr);return()=>clearTimeout(e)}),[O]),O/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(Rt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zl,{title:"Success!",description:`You’ve successfully added ${z} SOL to your ${h.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]});let ne=v[E];return v.length>1&&ne?/*#__PURE__*/t(Ru,{displayName:j,configuredFundingChain:F,formattedBalance:Z,fundingAmount:z,fundingCurrency:"SOL",fundingAmountInUsd:te,options:v,selectedOption:ne,isPreparing:_,isSubmitting:S,addressToFund:U,fundingWalletAddress:V?.address||"",errorMessage:f,onSubmit:()=>{u.funding?.amount!==z?async function(){if(V&&ne)try{let e=await nh({isTestnet:!1,input:Xd({amount:ee.toString(),user:V.address,recipient:U,destinationChainId:kr,destinationCurrency:Ir,originChainId:ne.chain.id})}),t=rh(e);if(!t)throw Error("Invalid transaction request");N(!0),Q({data:t.data,to:t.to,value:t.value,chain:ne.chain})}catch(e){console.error(e),g(new T("Unable to fetch quotes for bridging",e,A.INSUFFICIENT_BALANCE))}}().catch(console.error):Q({to:ne.bridgeTx.to,data:ne.bridgeTx.data,value:ne.bridgeTx.value,chain:ne.chain})},onSelect:e=>{e!==E&&(w(null),b(e))},onAmountChange:H}):S&&V?/*#__PURE__*/t(Ou,{wallet:V,displayName:j,addressToFund:U,isBridging:I,isErc20Flow:!1,chainId:"solana",chainName:F.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
18
+ /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(bh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ht,{})]})},[ur.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN]:function(){let{closePrivyModal:r,createAnalyticsEvent:a}=x(),{navigate:i,setModalData:c,app:d,data:h}=hr(),{wallets:u}=ca(),p=l(!1),m=oa(),[y,g]=s(!1),[f,w]=s(!1),[v,C]=s(null),[E,b]=s(),[_,k]=s();if(!h?.funding||"ethereum"!==h.funding.chainType)throw Error("Invalid funding data");let{amount:I,connectedWalletAddress:N,chain:S,cluster:R,isUSDC:O}=h.funding,W=h.funding.address,M=h.funding.erc20Address,P=h.funding.isUSDC?"USDC":S.nativeCurrency.symbol,L=R??{name:"mainnet-beta"},D=N?u.find((({address:e})=>e===N)):u[0],U=vt(D?.walletClientType||"unknown"),F=U?.name||"wallet";return o((()=>{(async function(){if(!D||!S||p.current)return;let e=m(sa);if(!e)return void C(new T("Unable to solana plugin"));p.current=!0,S?.testnet&&console.warn("Solana testnets are not supported for bridging");let t=O?1e6*parseFloat(I):Pa(I),n=await nh({isTestnet:!!S.testnet,input:Xd({amount:t.toString(),user:D.address,recipient:W,destinationChainId:S.id,originChainId:kr,originCurrency:O?Sr:Ir,destinationCurrency:O?M:void 0})}).catch(console.error);if(!n)return void C(new T(`Unable to fetch quotes for bridging. Wallet ${sn(D.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));let r=await e.createBridgeTransactionFromRelayQuote({quote:n,from:D.address,cluster:L});if(r)try{g(!0);let{connection:e,transaction:t}=r,a=await e.simulateTransaction(t);if(a.value.err)return a.value.logs?.find((e=>/insufficient (lamports|funds)/gi.test(e)))?void C(new T(`Wallet ${sn(D?.address)} does not have enough funds. ${n.details.currencyIn.amountFormatted} ${P} are needed to complete the transaction.`,void 0,A.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",a.value.err),void C(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE)));let i=await D.sendTransaction(t,e),o=await e.confirmTransaction(i);if(o.value.err)return console.error("Transaction failed:",o.value.err),void C(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE));b(i),k("pending")}catch(e){if(console.error(e),/user rejected the request/gi.test(e.message||""))return void C(new T("Transaction was rejected by the user",void 0,A.TRANSACTION_FAILURE));C(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE))}else C(new T(`Unable to select bridge option from quotes. Wallet ${sn(D.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))})().catch(console.error)}),[]),ah({transactionHash:E,wallet:D,isTestnet:!1,bridgingStatus:_,setBridgingStatus:k,onSuccess({transactionHash:e,wallet:t}){g(!1),w(!0),a({eventName:la,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainType:"solana",clusterName:L.name,token:"SOL",destinationAddress:W,destinationChainId:S.id,destinationChainType:"ethereum",destinationValue:I,destinationToken:O?"USDC":"ETH"}})},onFailure({error:e}){g(!1),C(e)}}),o((()=>{if(!f)return;let e=setTimeout(r,Nr);return()=>clearTimeout(e)}),[f]),o((()=>{if(!v)return;let e={error:v,previousScreen:ur.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),i(ur.ERROR_SCREEN,!1)}),[v]),f?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(Rt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Zl,{title:"Success!",description:`You’ve successfully added ${I} ${P} to your ${d.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]}):y&&D?/*#__PURE__*/t(Ou,{wallet:D,displayName:F,addressToFund:W,isBridging:y,isErc20Flow:!1,chainId:S.id,chainName:S.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
19
+ /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/t(bh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ht,{})]})},[ur.FUNDING_MANUAL_TRANSFER_SCREEN]:()=>{let{wallets:r}=_r(),{wallets:a}=ca(),{data:l,setModalData:c,navigate:d,lastScreen:h}=hr(),{rpcConfig:u,appId:p,createAnalyticsEvent:m,closePrivyModal:y}=x(),g=pr(),[f,w]=s(void 0),[v,C]=s(!1),E=oa(),T=l?.funding,{reloadBalance:b}=un({rpcConfig:u,appId:p,address:"ethereum"===T.chainType?T.address:void 0,chain:"ethereum"===T.chainType?T.chain:void 0}),A="solana"===T.chainType,_=A?"SOL":T.erc20Address?T.erc20ContractInfo?.symbol:T.chain.nativeCurrency.symbol,k=A?a.find((({address:e})=>e===T.address)):r.find((({address:e})=>Tt(e)===Tt(T.address)));if(!T)return c({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:h||ur.FUNDING_METHOD_SELECTION_SCREEN},funding:l?.funding,sendTransaction:l?.sendTransaction}),d(ur.ERROR_SCREEN),/*#__PURE__*/t(n,{});o((()=>{let e=A?async function(){if("solana"!==T.chainType)return;let e=E(sa);e?e.getBalance({address:T.address,cluster:T.cluster}).then((e=>{let t=BigInt(e);f&&t>f&&(C(!0),m({eventName:la,payload:{provider:"manual",status:"success",chainType:"solana",address:k?.address,value:Ma(t-f,9),token:"SOL"}})),w(t)})):console.warn("Unable to load solana plugin, skipping balance")}:async function(){"ethereum"===T.chainType&&(async()=>{if(!T.erc20Address)return await b()??BigInt(0);{let{balance:e}=await tn({chain:T.chain,address:T.address,erc20Address:T.erc20Address,rpcConfig:u,appId:p});return e}})().then((e=>{f&&e>f&&(C(!0),m({eventName:la,payload:{provider:"manual",status:"success",chainType:"ethereum",address:k?.address,chainId:T.chain.id,value:Ma(e-f,T.erc20ContractInfo?.decimals??18),token:T.erc20ContractInfo?.symbol??T.erc20Address??"ETH"}})),w(e)})).catch((()=>w(void 0)))},t=setInterval(e,2e3);return e(),()=>clearInterval(t)}),[f]);let I=i((()=>void 0!==f&&f>=parseFloat(T.amount)),[f,T.amount]),N=i((()=>null==f?"":T.isUSDC?xi({amount:f,decimals:6}):A?Wh(f,3,!0,!0):null!=T.erc20ContractInfo?.decimals?xi({amount:f,decimals:T.erc20ContractInfo.decimals}):Si({wei:f})),[f,A,T]),S="ethereum"===T.chainType?T.chain.name:rp[T.cluster.name];/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Th,{}),/*#__PURE__*/e(Ot,{children:["Receive ",T.amount," ",_]}),/*#__PURE__*/e(Wt,{children:["Scan this code or copy your wallet address to receive funds on ",S,"."]}),/*#__PURE__*/e(cn,{style:{gap:"1rem",margin:"1rem 0"},children:[/*#__PURE__*/t(Vt,{url:`${T.chainType}:${T.address}`,size:200,squareLogoElement:np}),/*#__PURE__*/e(Vu,{theme:g.appearance.palette.colorScheme,children:["Make sure to send funds on ",S,"."]}),/*#__PURE__*/t(St,{title:"Your wallet",errMsg:void 0,showIcon:!0,isLoading:!T||void 0===f,isPulsing:!I,balance:`${N} ${_}`,address:T.address,statusColor:I?"green":"gray"}),v&&/*#__PURE__*/t(ct,{onClick:()=>y({shouldCallAuthOnSuccess:!1,isSuccess:!0}),children:"Continue"})]}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN]:()=>{let{closePrivyModal:r}=x(),{data:a,setModalData:i,navigate:o,onUserCloseViaDialogOrKeybindRef:s}=hr(),{onSuccess:l,onFailure:c}=a.setWalletPassword,d=()=>{c(new R("Exited before password was added to wallet")),r({shouldCallAuthOnSuccess:!1})};return s.current=d,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:d}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(Rt,{children:[/*#__PURE__*/e(Ut,{children:[/*#__PURE__*/t(Ti,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ft,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:/*#__PURE__*/t(bi,{width:"12px",height:"12px",fill:"white"})})]}),/*#__PURE__*/e(Zl,{title:"Secure Your Account",children:["Please set a password to secure your account.",/*#__PURE__*/t("p",{children:"Losing access to this password and this device will make your account inaccessible."})]})]}),/*#__PURE__*/t(ct,{onClick:()=>{i({createWallet:{onFailure:c,onSuccess:l,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),o(ur.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN)},children:"Add password"}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN]:()=>{let[e,n]=s(null),[r,a]=s(!1),[i,l]=s(null),[c,d]=s(""),{authenticated:h,getAccessToken:u,user:p}=mr(),{walletProxy:m,refreshSessionAndUser:y,closePrivyModal:g,createAnalyticsEvent:f}=x(),{app:w,navigate:v,data:C,onUserCloseViaDialogOrKeybindRef:E}=hr(),{onSuccess:T,onFailure:b}=C.createWallet,A=Er(p),_="user-passcode"===e?.recoveryMethod,k="user-passcode"===A?.recoveryMethod;o((()=>{h||(v(ur.LANDING),b(new O("User must be authenticated before setting a password on a Privy wallet")))}),[h]);let I=()=>i?(b(i),void g({shouldCallAuthOnSuccess:!1})):_?(T(e),void g({shouldCallAuthOnSuccess:!1})):(b(new R("Exited before password was added to wallet")),void g({shouldCallAuthOnSuccess:!1}));E.current=I;/*#__PURE__*/return t(Jd,{appName:w?.name||"privy",config:{initiatedBy:"user",onCancel:I},error:i?"An error has occurred, please try again.":void 0,buttonLoading:r,buttonHideAnimations:!1,password:c,isResettingPassword:k,onPasswordGenerate:()=>d(zd()),onPasswordChange:d,onSubmit:async()=>{_?(T(e),g({shouldCallAuthOnSuccess:!1})):(a(!0),l(null),await(async()=>{let e=await u();if(e&&A?.address&&c&&m)try{f({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k}});let{entropyId:t,entropyIdVerifier:r}=qn(A);if(!(await m.setRecovery({accessToken:e,entropyId:t,entropyIdVerifier:r,recoveryPassword:c,recoveryMethod:"user-passcode"})).entropyId)return l(new R("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k,reason:"error setting password"}});let a=await y(),i=Er(a);if(!i)return l(new R("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k,reason:"wallet disconnected"}});n(i),f({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k}})}catch(e){console.warn(e),l(e instanceof Error?e:Error("Error setting password on privy wallet")),f({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:A.address,reason:e}})}})(),a(!1))},onClose:I})},[ur.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN]:()=>{let{app:e,navigate:n,data:r,onUserCloseViaDialogOrKeybindRef:a}=hr(),[i,l]=s(""),[c,d]=s(!1),[h,u]=s(),[p,m]=s(null),{authenticated:y,user:g}=mr(),{closePrivyModal:f,isNewUserThisSession:w,initializeWalletProxy:v}=x(),{onSuccess:C,onFailure:E,callAuthOnSuccessOnClose:T}=r.createWallet,{createWallet:b}=od(),[A,_]=s(null),k=new Ke((async()=>{try{let e=await b({recoveryPassword:h,user:g});if(!e)return;_(e),w?n(ur.EMBEDDED_WALLET_CREATED_SCREEN):(C(e),f({shouldCallAuthOnSuccess:T}))}catch(e){l(e.message)}}));o((()=>{p||v(3e4).then((e=>m(e)))}),[p]),o((()=>{if(!y||!g)return n(ur.LANDING),void E(Error("User must be authenticated before creating a Privy wallet"))}),[y]),a.current=()=>null;/*#__PURE__*/return t(Jd,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:!p,buttonLoading:c,buttonHideAnimations:!A&&c,isResettingPassword:!1,error:i,password:h||"",onClose:()=>{A&&"user-passcode"!==A?.recoveryMethod?(E(new R("User created a wallet but failed to set a password for it")),f({shouldCallAuthOnSuccess:!1})):A?(C(A),f({shouldCallAuthOnSuccess:T})):(E(new R("User wallet creation failed")),f({shouldCallAuthOnSuccess:!1}))},onPasswordChange:u,onPasswordGenerate:()=>u(zd()),onSubmit:async()=>(d(!0),k.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>d(!1))))})},[ur.MFA_ENROLLMENT_FLOW_SCREEN]:()=>{let{user:r,enrollInMfa:a}=mr(),[i,l]=s(null),{unenrollWithSms:c,unenrollWithTotp:d,unenrollWithPasskey:h}=rm(),{app:u,ready:p,data:m,onUserCloseViaDialogOrKeybindRef:y}=hr(),{closePrivyModal:g}=x(),{promptMfa:f}=nm(),{initEnrollmentWithTotp:w}=rm(),[v,C]=s(!1),[E,T]=s(null),[b,A]=s(null),_=()=>{g({shouldCallAuthOnSuccess:!0}),a(!1),setTimeout((()=>{l(null),T(null)}),500)},{initEnrollmentWithPasskey:k,submitEnrollmentWithPasskey:I}=rm(),[N,S]=s(!1),[R,O]=s(null);y.current=_;let W=r?.mfaMethods.includes("sms"),M=!!r?.phone,P=r?.mfaMethods.includes("totp"),L=r?.mfaMethods.includes("passkey"),D=W||P||L,U=r?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function F(){l(null),T(null)}if(o((()=>{D&&C(!0)}),[D]),!p||!r||!u/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(lt,{onClose:_},"header"),/*#__PURE__*/t(_l,{children:/*#__PURE__*/t(am,{})}),/*#__PURE__*/t(Nl,{children:/*#__PURE__*/t($t,{})}),/*#__PURE__*/t(ft,{})]});if("sms"===i)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ja,{})}),/*#__PURE__*/t(kl,{children:"Remove SMS verification?"}),/*#__PURE__*/e(Il,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ct,{warn:!0,onClick:async function(){l(null);try{await c()}catch(e){l(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/t(ft,{})]});if("totp"===i)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ja,{})}),/*#__PURE__*/t(kl,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e(Il,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ct,{warn:!0,onClick:async function(){l(null);try{await d()}catch(e){l(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/t(ft,{})]});if("passkey"===i){let r=m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ja,{})}),/*#__PURE__*/t(kl,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/t(Il,{children:r?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ct,{warn:!0,onClick:async function(){l(null);try{await h({removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){l(null)}},children:"Yes, remove"})}),/*#__PURE__*/t(ft,{})]})}if(0===m.mfaEnrollmentFlow.mfaMethods.length&&!D)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{onClose:_},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(kl,{children:"Add more security"}),/*#__PURE__*/e(Il,{children:[u?.name," does not have any verification methods enabled."]}),/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ct,{onClick:_,children:"Close"})}),/*#__PURE__*/t(ft,{})]});let B=!D&&!v;return B?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{onClose:_},"header"),/*#__PURE__*/t(zl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(kl,{children:"Transaction Protection"}),/*#__PURE__*/t(Il,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e(xl,{children:[/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(io,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(so,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e(Ol,{children:[/*#__PURE__*/t(ct,{onClick:()=>C(!0),children:"Continue"}),/*#__PURE__*/t(ut,{onClick:_,children:"Not now"})]}),/*#__PURE__*/t(ft,{})]}):"sms"===E?/*#__PURE__*/t(_m,{appName:u?.name||"Privy",onComplete:_,onReset:F,onClose:_}):"totp"===E&&b?/*#__PURE__*/t(Im,{onComplete:_,onClose:_,onReset:F,totpInfo:{...b,appName:u?.name||"Privy"}}):"passkey"===E?/*#__PURE__*/t(lm,{appName:u?.name||"Privy",onComplete:_,onReset:F,onClose:_}):/*#__PURE__*/t(om,{showIntro:B,userMfaMethods:r.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:M,onBackToIntro:function(){C(!1)},handleSelectMethod:async function(e){return await f().catch(O),"totp"===e?(T(e),A(null),void w().then((e=>{A(e)})).catch((()=>{A(null),F()}))):"passkey"===e&&1===U.length?await async function(){S(!0);try{await k(),await I({credentialIds:U},{removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){O(e)}finally{S(!1)}}():void T(e)},isTotpLoading:"totp"===E&&!b,isPasskeyLoading:N,error:R,onClose:_,setRemovingMfaMethod:async e=>{await f().catch(O),l(e)}})},[ur.CAPTCHA_SCREEN]:()=>{let{lastScreen:r,currentScreen:a,data:i,navigateBack:c,navigate:d,setModalData:h}=hr(),{status:u,token:p,waitForResult:m,reset:y,execute:g}=st(),f=l([]),w=e=>{f.current=[e,...f.current]},[v,C]=s(!0);o((()=>(w(setTimeout(C,1e3,!1)),()=>{f.current.forEach((e=>clearTimeout(e))),f.current=[]})),[]);let[E,T]=s(""),[b,A]=s("Checking that you are a human..."),[_,k]=s(/*#__PURE__*/t(ct,{onClick:()=>{},disabled:!0,children:"Continue"})),[I,N]=s(!1),[x,S]=s(3),R=i?.captchaModalData,O=async e=>{try{await(R?.callback(e)),R?.onSuccessNavigateTo&&d(R?.onSuccessNavigateTo,!1)}catch(e){if(e instanceof Ye)return;h({errorModalData:{error:e,previousScreen:r||ur.LANDING}}),d(R?.onErrorNavigateTo||ur.ERROR_SCREEN,!1)}};o((()=>{"success"===u?w(setTimeout((async()=>{let e=await m();!e||R?.userIntentRequired||O(e)}),1e3)):"ready"===u&&w(setTimeout((()=>{"ready"===u&&g()}),500))}),[u]),o((()=>{if(!v)switch(u){case"success":T("Success!"),A("CAPTCHA passed successfully."),k(/*#__PURE__*/t(ct,{onClick:()=>{N(!0),O(p)},disabled:!R?.userIntentRequired,loading:I,children:R?.userIntentRequired?"Continue":"Continuing..."}));break;case"loading":T(""),A("Checking that you are a human..."),k(/*#__PURE__*/t(ct,{onClick:()=>{},disabled:!0,children:"Continue"}));break;case"error":T("Something went wrong"),x<=0?(A("If you use an adblocker or VPN, try disabling and re-attempting."),k(null)):(A("You did not pass CAPTCHA. Please try again."),k(/*#__PURE__*/t(ct,{onClick:W,children:"Retry"})))}}),[u,v,I]);let W=async()=>{if(x<=0)return;S((e=>e-1)),y(),g();let e=await m();!e||R?.userIntentRequired||O(e)};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{backFn:r&&a!==r?c:void 0}),/*#__PURE__*/e(pc,{children:["success"===u?/*#__PURE__*/t(si,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}):"error"===u?/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(gt,{children:[E?/*#__PURE__*/t("h3",{children:E}):null,/*#__PURE__*/t("p",{children:b})]}),_]}),/*#__PURE__*/t(ft,{})]})},[ur.ERROR_SCREEN]:()=>{let{navigate:e,navigateBack:n,data:r,lastScreen:a,currentScreen:i}=hr(),o=r?.errorModalData?.previousScreen||(a===i?void 0:a);/*#__PURE__*/return t(oh,{error:r?.errorModalData?.error||Error(),backFn:()=>o?e(o,!1):n(),onClick:()=>e(o||ur.LANDING,!1)})},[ur.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE]:()=>{let{closePrivyModal:r}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(lt,{},"header"),/*#__PURE__*/t(hp,{children:/*#__PURE__*/t(ni,{style:{width:32,height:32}})}),/*#__PURE__*/t(Yl,{title:"Could not log in with provider",description:"It looks like you're using an in-app browser. To log in, please try again using an external browser.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/t(pn,{children:/*#__PURE__*/t(ct,{onClick:()=>r(),children:"Close"})}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ht,{})]})},[ur.AFFIRMATIVE_CONSENT_SCREEN]:()=>{let{user:e,logout:n}=mr(),{app:r,onUserCloseViaDialogOrKeybindRef:a,setModalData:i,navigate:o}=hr(),{acceptTerms:s,closePrivyModal:l,createAnalyticsEvent:c}=x(),d=e=>{e?.preventDefault(),l({shouldCallAuthOnSuccess:!1}),n()};a.current=d;/*#__PURE__*/return t(Vl,{termsAndConditionsUrl:r?.legal.termsAndConditionsUrl,privacyPolicyUrl:r?.legal.privacyPolicyUrl,onAccept:async t=>{t.preventDefault(),await s(),e&&pt(e,r.embeddedWallets)?(i({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),c({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AffirmativeConsentScreen"}}),n()},callAuthOnSuccessOnClose:!0}}),o(ur.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)):l()},onDecline:d})},[ur.TELEGRAM_AUTH_SCREEN]:()=>{let{authenticated:r,logout:a,ready:i,user:l}=mr(),{app:c,setModalData:d,navigate:h,resetNavigation:u,data:p}=hr(),{initLoginWithTelegram:m,loginWithTelegram:y,updateWallets:g,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v,getAuthMeta:C}=x(),[E,T]=s(!1),[b,_]=s(void 0),k=st();async function I(){try{let e=await async function(){let e;if(!r){if(k.enabled&&"error"===k.status)throw new Ye(k.error,null,A.CAPTCHA_FAILURE);return k.enabled&&"success"!==k.status&&(k.execute(),e=await k.waitForResult()),e}}();await y({captchaToken:e}),T(!0),f(!0)}catch(e){if(e?.privyErrorCode===A.ALLOWLIST_REJECTED)return _(void 0),u(),void h(ur.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),_(void 0),u(),void h(ur.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===A.USER_DOES_NOT_EXIST)return _(void 0),u(),void h(ur.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return _(void 0),u(),d({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,telegramAuthResult:C()?.telegramAuthResult,telegramWebAppData:C()?.telegramWebAppData,displayName:e.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void h(ur.LINK_CONFLICT_SCREEN);let{retryable:t,detail:n}=Jo(e);_({retryable:t,detail:n,message:"Authentication failed"})}}o((()=>{I()}),[]),o((()=>{if(!(i&&r&&E&&l))return;if(c?.legal.requireUsersAcceptTerms&&!l.hasAcceptedTerms){let e=setTimeout((()=>{h(ur.AFFIRMATIVE_CONSENT_SCREEN)}),yr);return()=>clearTimeout(e)}if(pt(l,c.embeddedWallets)){let e=setTimeout((()=>{d({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:"telegram",screen:"TelegramAuthScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(ur.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),yr);return()=>clearTimeout(e)}g();let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),yr);return()=>clearTimeout(e)}),[i,r,E,l]);let N=E?"Successfully connected with Telegram":b?b.message:"Verifying connection to Telegram",R="";return R=E?"You’re good to go!":b?b.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{}),/*#__PURE__*/t(It,{}),/*#__PURE__*/e(ef,{children:[/*#__PURE__*/t(Zs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(yt,{success:E,fail:!!b}),/*#__PURE__*/t(Hp,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(gt,{children:[/*#__PURE__*/t("h3",{children:N}),/*#__PURE__*/t("p",{children:R})]}),b&&b?.retryable?/*#__PURE__*/t(mn,{onClick:async()=>{try{_(void 0),p?.telegramAuthModalData?.seamlessAuth||await m(void 0,p?.login?.disableSignup),await I()}catch(e){let{retryable:t,detail:n}=Jo(e);_({retryable:t,detail:n,message:"Authentication failed"})}},disabled:!E&&!b?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ft,{})]})},[ur.LINK_CONFLICT_SCREEN]:()=>{let{initiateAccountTransfer:e,closePrivyModal:n}=x(),{data:r,navigate:a,lastScreen:i,setModalData:o}=hr(),[l,c]=s(void 0),[d,h]=s(!1),[u,p]=s(!1),m=async()=>{try{if(!r?.accountTransfer?.nonce||!r?.accountTransfer?.account)throw Error("missing account transfer inputs");p(!0),await e({nonce:r?.accountTransfer?.nonce,account:r?.accountTransfer?.account,accountType:r?.accountTransfer?.linkMethod,externalWalletMetadata:r?.accountTransfer?.externalWalletMetadata,telegramWebAppData:r?.accountTransfer?.telegramWebAppData,telegramAuthResult:r?.accountTransfer?.telegramAuthResult,farcasterEmbeddedAddress:r?.accountTransfer?.farcasterEmbeddedAddress,oAuthUserInfo:r?.accountTransfer?.oAuthUserInfo}),h(!0),p(!1),setTimeout(n,1e3)}catch(e){o({errorModalData:{error:e,previousScreen:i||ur.LINK_CONFLICT_SCREEN}}),a(ur.ERROR_SCREEN,!0)}};return l?/*#__PURE__*/t(Tl,{address:l,onClose:n,onRetry:()=>c(void 0),onTransfer:m,isTransferring:u,transferSuccess:d}):/*#__PURE__*/t(bl,{onClose:n,onInfo:()=>c(r?.accountTransfer?.embeddedWalletAddress),onContinue:()=>c(r?.accountTransfer?.embeddedWalletAddress),onTransfer:m,isTransferring:u,transferSuccess:d,data:r})}},vf=[ur.LANDING,ur.AWAITING_CONNECTION],Cf=({isMfaVerifying:r,onMfaVerificationComplete:a})=>{let{ready:i,isModalOpen:s}=mr(),{headless:l}=pr(),{ready:c,currentScreen:d}=hr(),{status:h,execute:u,reset:p,enabled:m}=st(),y=s&&d&&vf.includes(d)&&!l&&"ready"===h;return o((()=>{y&&u()}),[y]),o((()=>{!s&&m&&p()}),[s,m]),i&&c||d===ur.AWAITING_OAUTH_SCREEN||d===ur.CROSS_APP_AUTH_SCREEN||d===ur.TELEGRAM_AUTH_SCREEN?!d&&r?/*#__PURE__*/t(py,{open:r,onClose:a}):d?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(il,{$if:!!r,children:/*#__PURE__*/t(wf[d],{})}),/*#__PURE__*/t(il,{$if:!r,children:/*#__PURE__*/t(py,{open:r,onClose:a})})]}):null:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(lt,{}),/*#__PURE__*/t(It,{}),/*#__PURE__*/t(ff,{children:/*#__PURE__*/t($t,{})}),/*#__PURE__*/t(Nt,{}),/*#__PURE__*/t(ft,{})]})},Ef=({isMfaVerifying:e,onMfaVerificationComplete:n})=>{let r=l(null);/*#__PURE__*/return t(Af,{style:{height:Nn(r)},id:"privy-modal-content",children:/*#__PURE__*/t("div",{ref:r,children:/*#__PURE__*/t(Cf,{isMfaVerifying:e,onMfaVerificationComplete:n})})})};const Tf=({open:e})=>{let{app:n}=hr(),{gracefulClosePrivyModal:r}=(()=>{let{closePrivyModal:e}=x(),{onUserCloseViaDialogOrKeybindRef:t}=hr();return{gracefulClosePrivyModal:c((()=>{if(!t?.current)return e({shouldCallAuthOnSuccess:!1});t.current()}),[e])}})(),[a,i]=s(!1);Ks({onMfaRequired:()=>{n?.mfa.noPromptOnMfaRequired||i(!0)}});let o=e||a;return n.render.standalone?/*#__PURE__*/t(hf,{children:/*#__PURE__*/t(bf,{id:"privy-modal-content",children:/*#__PURE__*/t(Cf,{isMfaVerifying:a,onMfaVerificationComplete:()=>i(!1)})})}):/*#__PURE__*/t(uf,{open:o,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:/*#__PURE__*/t(hf,{children:/*#__PURE__*/t(Ef,{isMfaVerifying:a,onMfaVerificationComplete:()=>i(!1)})})})};let bf=/*#__PURE__*/Ka.div.withConfig({displayName:"ContentWrapper",componentId:"sc-1174608a-0"})(["display:flex;flex-direction:column;text-align:center;font-size:14px;line-height:20px;width:100%;background:var(--privy-color-background);padding:0 16px;"]),Af=/*#__PURE__*/Ka(bf).withConfig({displayName:"BaseModal",componentId:"sc-1174608a-1"})(["transition:height 150ms ease-out;overflow:hidden;max-height:calc(100svh - 32px);border-radius:var(--privy-border-radius-lg) var(--privy-border-radius-lg) 0 0;box-shadow:0px 0px 36px rgba(55,65,81,0.15);@media (min-width:441px){box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]);function _f(e){let n=l(null),r=l();return o((()=>{r.current?.remove(),r.current=function({botUsername:e,scriptHost:t}){let n=document.createElement("script"),{origin:r}=new URL(t);return n.async=!0,n.src=`${r}/js/telegram-login.js`,n.setAttribute("data-telegram-login",e),n.setAttribute("data-request-access","write"),n.setAttribute("data-lang","en"),n}(e),n.current?.after(r.current)}),[e]),/*#__PURE__*/t("div",{ref:n,hidden:!0})}async function kf(e,t,n,r,a,i=!1){let o=i,s=async s=>{if(o&&t&&t.length>0){s===(i?0:1)?a("configureMfa","onMfaRequired",{mfaMethods:t}):r.current?.reject(new Fc("missing_or_invalid_mfa","MFA verification failed, retry."));let o=await new Promise(((e,t)=>{n.current={resolve:e,reject:t},setTimeout((()=>{let e=new Fc("mfa_timeout","Timed out waiting for MFA code");r.current?.reject(e),t(e)}),3e5)}));return await e(o)}return await e()},l=null;for(let e=0;e<4;e++)try{l=await s(e),r.current?.resolve(void 0);break}catch(e){if("missing_or_invalid_mfa"!==e.type)throw r.current?.resolve(void 0),e;o=!0}if(null===l){let e=new Fc("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw r.current?.reject(e),e}return l}var If;let Nf=(If=0,()=>"id-"+If++);function xf(e){return void 0!==e.error}let Sf=new class{enqueue(e,t){this.callbacks[e]=t}dequeue(e,t){let n=this.callbacks[t];if(!n)throw Error(`cannot dequeue ${e} event: no event found for id ${t}`);switch(delete this.callbacks[t],e){case"privy:iframe:ready":case"privy:wallets:create":case"privy:wallets:add":case"privy:wallets:import":case"privy:wallets:set-recovery":case"privy:wallets:connect":case"privy:wallets:recover":case"privy:wallets:rpc":case"privy:wallet:create":case"privy:mfa:verify":case"privy:mfa:init-enrollment":case"privy:mfa:submit-enrollment":case"privy:mfa:unenroll":case"privy:mfa:clear":case"privy:auth:unlink-passkey":case"privy:farcaster:init-signer":case"privy:farcaster:sign":case"privy:solana-wallet:create":case"privy:delegated-actions:consent":return n;default:throw Error(`invalid wallet event type ${e}`)}}constructor(){this.callbacks={}}},Rf=new Map,Of=(e,t)=>"bigint"==typeof t?t.toString():t,Wf=(e,t)=>`${e}${JSON.stringify(t,Of)}`;function Mf(e,t,n,r){let a=n.contentWindow;if(!a)throw Error("iframe not initialized");let i=Wf(e,t);if("privy:wallet:create"===e){let e=Rf.get(i);if(e)return e}let o=new Promise(((n,i)=>{let o=Nf();Sf.enqueue(o,{resolve:n,reject:i}),a.postMessage({id:o,event:e,data:t},r)})).finally((()=>{Rf.delete(i)}));return Rf.set(i,o),o}function Pf(e){let n=l(null),r=l(e.mfaMethods),a=ma(),[i,c]=s(!1);return o((()=>{r.current=e.mfaMethods}),[e.mfaMethods]),o((()=>{if(!i)return;let t=n.current;if(!t)return;function o(t){var n;t&&t.origin===e.origin&&"string"==typeof(n=t.data).event&&/^privy:.+/.test(n.event)&&function(e){switch(e.event){case"privy:iframe:ready":let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallets:create":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:add":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:set-recovery":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:connect":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:recover":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:rpc":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallet:create":let n=Sf.dequeue(e.event,e.id);return xf(e)?n.reject(new Fc(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallets:import":let r=Sf.dequeue(e.event,e.id);return xf(e)?r.reject(new Fc(e.error.type,e.error.message)):r.resolve(e.data);case"privy:mfa:verify":let a=Sf.dequeue(e.event,e.id);return xf(e)?a.reject(new Fc(e.error.type,e.error.message)):a.resolve(e.data);case"privy:mfa:init-enrollment":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:submit-enrollment":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:unenroll":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:clear":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:auth:unlink-passkey":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:solana-wallet:create":let i=Sf.dequeue(e.event,e.id);return xf(e)?i.reject(new Fc(e.error.type,e.error.message)):i.resolve(e.data);case"privy:farcaster:init-signer":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:farcaster:sign":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:delegated-actions:consent":{let t=Sf.dequeue(e.event,e.id);return xf(e)?t.reject(new Fc(e.error.type,e.error.message)):t.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}(t.data)}let s={createWallet:n=>kf((r=>Mf("privy:wallets:create",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),addWallet:n=>kf((r=>Mf("privy:wallets:add",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),setRecovery:n=>kf((r=>Mf("privy:wallets:set-recovery",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),connect:n=>kf((r=>Mf("privy:wallets:connect",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),recover:n=>kf((r=>Mf("privy:wallets:recover",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a,!n.recoveryAccessToken&&!n.recoveryPassword&&!n.recoverySecretOverride),rpc:n=>kf((r=>Mf("privy:wallets:rpc",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),create:n=>Mf("privy:wallet:create",n,t,e.origin),importWallet:n=>Mf("privy:wallets:import",n,t,e.origin),createSolana:n=>kf((r=>Mf("privy:solana-wallet:create",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),createDelegatedAction:n=>Mf("privy:delegated-actions:consent",n,t,e.origin),verifyMfa:n=>kf((r=>Mf("privy:mfa:verify",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a,!0),initEnrollMfa:n=>kf((r=>Mf("privy:mfa:init-enrollment",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),submitEnrollMfa:n=>kf((r=>Mf("privy:mfa:submit-enrollment",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),unenrollMfa:n=>kf((r=>Mf("privy:mfa:unenroll",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),clearMfa:n=>Mf("privy:mfa:clear",n,t,e.origin),unlinkPasskeyAccount:n=>kf((r=>Mf("privy:auth:unlink-passkey",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),initFarcasterSigner:n=>Mf("privy:farcaster:init-signer",n,t,e.origin),signFarcasterMessage:n=>Mf("privy:farcaster:sign",n,t,e.origin)};window.addEventListener("message",o);let l=new AbortController;return xn((()=>Mf("privy:iframe:ready",{},t,e.origin)),{abortSignal:l.signal}).then((()=>e.onLoad(s)),((...t)=>{console.warn("Privy iframe failed to load: ",...t),e.onLoadFailed()})),()=>{window.removeEventListener("message",o),l.abort()}}),[i]),
20
+ /*#__PURE__*/t("iframe",{ref:n,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>c(!0),src:Mt(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId,client_id:e.appClientId})})}const Lf=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.delegated));class Df{async handleSignMessage(e){if(!e.params||"string"!=typeof e.params.message)throw Error("Message must be provided as a string for Solana signMessage RPC");return await dw({message:e.params.message,options:{address:this.address,uiOptions:{}}})}async request(e){if(console.debug("EmbeddedSolanaProvider.request() called with args",e),!await rw())throw Error("User must be authenticated to use embedded Solana wallet");if(!await cw())throw new T("Unable to connect to Solana embedded wallet");if("signMessage"===e.method)return await this.handleSignMessage(e);throw Error("Embedded Solana provider does not yet support this RPC method.")}constructor(e,t){this.walletProxy=e,this.address=t}}const Uf=()=>{let e=pr();o((()=>{(async e=>{let t=new URL("v3/wallets","https://explorer-api.walletconnect.com");t.searchParams.append("projectId",e);let n=await fetch(t);return n.ok?Object.values((await n.json()).listings).sort((({slug:e},{slug:t})=>"rainbow"===e&&"metamask"===t?1:"metamask"===e||"rainbow"===e?-1:1)):(console.debug(`Failed to fetch WalletConnect listings: ${await n.text().catch((()=>"No response."))}`),[])})(e.walletConnectCloudProjectId).then((e=>Sn({listings:e}))).catch(console.error)}),[e.walletConnectCloudProjectId])},Ff="popup-privy-oauth",Bf="PRIVY_OAUTH_USE_BROADCAST_CHANNEL";class zf{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(K,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(Y,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw b(e)}}constructor({authorizationCode:e,stateCode:t,codeVerifier:n,provider:r}){this.meta={authorizationCode:e,stateCode:t,codeVerifier:n,provider:r}}}async function Hf({api:e,requesterAppId:t,providerAppId:n}){let r=(await e.get(`/api/v1/apps/${t}/cross-app/connections`)).connections.find((e=>e.provider_app_id===n));if(!r)throw new T("Invalid connected app");return{name:r.provider_app_name,logoUrl:r.provider_app_icon_url||void 0,apiUrl:r.provider_app_custom_api_url,readOnly:r.read_only}}const Vf=async({user:e,address:t,client:n,request:r,requesterAppId:a,reconnect:i})=>{n.createAnalyticsEvent({eventName:"cross_app_request_started",payload:{address:t,method:r.method}});let o=e?.linkedAccounts.find((e=>"cross_app"===e.type&&(e.embeddedWallets.some((e=>e.address===t))||e.smartWallets.some((e=>e.address===t)))));if(!e||!o)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Cannot request a signature with this wallet address",address:t}}),new T("Cannot request a signature with this wallet address");let s=n.getProviderAccessToken(o.providerApp.id),l=await Hf({api:n.api,requesterAppId:a,providerAppId:o.providerApp.id});if(!s){if(l.readOnly)throw console.error("cannot transact against a read-only provider app"),new T("Cannot transact against a read-only provider app");await i({appId:o.providerApp.id,action:"link"})&&(s=n.getProviderAccessToken(o.providerApp.id))}if(!s)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Transactions require a valid token",address:t}}),new T("Transactions require a valid token");let c=Ku();if(!c)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Missing token",address:t}}),new T("Failed to initialize signature request");let d=new URL(`${l.apiUrl}/oauth/transact`);return d.searchParams.set("token",s||""),d.searchParams.set("request",$f(r)),c.location=d.href,new Promise(((e,a)=>{let i=setTimeout((()=>{d(),a(new T("Request timeout")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Request timeout",address:t}})}),12e4),s=setInterval((()=>{c.closed&&(d(),a(new T("User rejected request")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"User rejected request",address:t}}))}),300),l=i=>{i.data&&("set"===i.data.token?.action&&void 0!==i.data.token?.value?n.storeProviderAccessToken(o.providerApp.id,i.data.token.value):"clear"===i.data.token?.action&&n.storeProviderAccessToken(o.providerApp.id,null),"PRIVY_CROSS_APP_ACTION_RESPONSE"===i.data.type&&i.data.result&&(d(),e(i.data.result),n.createAnalyticsEvent({eventName:"cross_app_request_success",payload:{address:t,method:r.method}})),"PRIVY_CROSS_APP_ACTION_ERROR"===i.data.type&&i.data.error&&(d(),a(i.data.error),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:i.data.error,address:t}})))};window.addEventListener("message",l);let d=()=>{c.close(),clearInterval(s),clearTimeout(i),window.removeEventListener("message",l)}}))};let $f=e=>JSON.stringify({content:{request:{request:jf(e,Na)}},timestamp:Date.now(),callbackUrl:window.origin});const jf=(e,t)=>"bigint"==typeof e?t(e):Array.isArray(e)?e.map((e=>jf(e,t))):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,jf(n,t)]))):e,Gf=e=>!!e.fundingConfig&&ya(e.fundingConfig.options).length>=1;async function qf({url:e,popup:t,provider:n}){return t.location=e,new Promise(((e,n)=>{function r(){t?.close(),window.removeEventListener("message",a)}function a(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(e(t.data),r()),"https://cdn.apple-cloudkit.com"===t.origin&&t.data.ckSession&&(e({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:t.data.ckSession}),r()),"PRIVY_OAUTH_ERROR"===t.data.type&&(n(t.data.error),r()))}window.addEventListener("message",a)}))}let Kf,Yf,Zf,Jf,Qf,Xf,ew,tw;function nw(){return Kf?Kf.getCustomerAccessToken():Promise.resolve(Xr.get(Zn)||null)}async function rw(){return Kf?Kf.getAccessToken():Promise.resolve(Xr.get(Jn)||Xr.get(Zn)||null)}const aw=(e,t)=>Yf(e,t),iw=(e,t)=>Zf(e,t),ow=(e,t)=>Jf(e,t),sw=(e,t)=>Qf(e,t),lw=()=>Xf(),cw=()=>ew(),dw=({message:e,options:t})=>tw({message:e,options:t});const hw=({config:e,...n})=>{var r;if("undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new T("Embedded wallet is only available over HTTPS");if("string"!=typeof(r=n.appId)||25!==r.length)throw new T("Cannot initialize the Privy provider with an invalid Privy app ID");Kf||(Kf=new js({appId:n.appId,appClientId:n.clientId,apiUrl:n.apiUrl}));let a=Object.assign({},e);/*#__PURE__*/
21
+ return t(zr,{client:Kf,clientConfig:a,children:/*#__PURE__*/t(ga,{children:/*#__PURE__*/t(uw,{...n,client:Kf})})})};let uw=n=>{let a=n.client,d=oa();Uf();let[h,u]=s(!1),[p,m]=s(!1),[y,g]=s(!1),[f,w]=s(null),[k,I]=s([]),[N,x]=s([]),[S,R]=s([]),[O,W]=s(!1),[U,F]=s(null),[B,z]=s(!1),[H,V]=s({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:P}),[$,j]=s({status:"initial"}),[G,q]=s({status:"initial"}),[K,Y]=s({status:"initial"}),[J,Q]=s({status:"initial"}),[X,ee]=s({status:"initial"}),[te,ne]=s({status:"initial"}),[re,ae]=s(null),ie=pr(),oe=Hr(),[se,le]=s(!0),[ce,de]=s({}),[he,ue]=s(null),[pe,me]=s(null),[ye,ge]=s(!1),[fe,we]=s(!1),[ve,Ce]=s(ie.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),Ee=l(null),Te=l(null),be=l(fa),[Ae,_e]=s(!1);a.onStoreCustomerAccessToken=e=>{e&&wa(be,"accessToken","onAccessTokenGranted",{accessToken:e})},a.onDeleteCustomerAccessToken=()=>{w(null),g(!1),wa(be,"accessToken","onAccessTokenRemoved")};let ke=l(null),Ie=l(null),Ne=l(!1),xe=({showWalletUIs:e})=>Ne.current?Ne.current:void 0!==e?!e:!ie.embeddedWallets.showWalletUIs,Se=e=>{F(e),setTimeout((()=>{u(!0)}),15)},Re=e=>{("off"!==ie.embeddedWallets.ethereum.createOnLogin||"off"!==ie.embeddedWallets.solana.createOnLogin)&&le(!0),Se(e)};o((()=>{let e=[...Vr(f),Fr(f)].filter((e=>!!e));re&&R(e.map((e=>({type:"solana",imported:e.imported,address:e.address,connectedAt:Date.now(),walletClientType:"privy",connectorType:"embedded",walletIndex:e.walletIndex??void 0,meta:{name:"Privy Wallet",icon:void 0,id:"io.privy.solana.wallet"},linked:!0,fund(){throw new T("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:()=>{throw new T("Cannot unlink an embedded Solana wallet")},getProvider:async()=>new Df(re,e.address),async signMessage(t){let n=await rw();if(!n||!re)throw new T("Must have valid access token and Privy wallet to send transaction",A.MUST_BE_AUTHENTICATED);let r=e.imported?Fr(f):Er(f);if(!r)throw new T("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=qn(r);if(!await lt.recoverPrimaryWallet().catch((()=>!1)))throw new T("Wallet couldn't be connected",A.UNKNOWN_CONNECT_WALLET_ERROR);if(!f)throw new T("Attempting to sign a transaction with no user initialized");let{response:o}=await re.rpc({accessToken:n,entropyId:a,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:e.walletIndex??0,request:{method:"signMessage",params:{message:Buffer.from(t).toString("base64")}}});return Buffer.from(o.data.signature,"base64")},async sendTransaction(e,t,n){let{signature:r}=await Ze({transaction:e,connection:t,transactionOptions:n,wallet:this,signOnly:!1});return r},async signTransaction(t){let n=await rw();if(!n||!re)throw new T("Must have valid access token and Privy wallet to send transaction",A.MUST_BE_AUTHENTICATED);if(!await lt.recoverPrimaryWallet().catch((()=>!1)))throw new T("Wallet couldn't be connected",A.UNKNOWN_CONNECT_WALLET_ERROR);let r=e.imported?e:Er(f);if(!r)throw new T("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=qn(r);return await Ry({tx:t,accessToken:n,walletProxy:re,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0}),t},loginOrLink:async()=>{throw new T("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{},isConnected:async()=>!0}))))}),[re,f]),o((()=>{if(!f)return void a.connectors?.removeEmbeddedWalletConnectors();let e=wr(f),t=$r(f),r=jr(f);e&&t.length||a.connectors?.removeEmbeddedWalletConnectors(),r||a.connectors?.removeImportedWalletConnector(),a.connectors?re?(e&&a.connectors.addEmbeddedWalletConnectors({walletProxy:re,rootWallet:e,embeddedWallets:t,defaultChain:ie.defaultChain,appId:n.appId}),r&&a.connectors.addImportedWalletConnector(re,r.address,ie.defaultChain,n.appId)):console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized"):console.debug("Failed to add embedded wallet connector: Client connectors not initialized")}),[re,f]),o((()=>{re&&pe?.(re)}),[re]);let Oe=l();o((()=>{(async()=>{if(!ie.customAuth?.enabled)return void Ce({status:"not-enabled"});le(!0);let{getCustomAccessToken:e,isLoading:t}=ie.customAuth;if(p&&!t&&"loading"!==ve.status){Ce({status:"loading"});try{let t=await e();if(t===Oe.current)return void Ce({status:"done"});if(!t&&y)return Oe.current=t,await st.logout(),Ce({status:"done"}),void wa(be,"customAuth","onUnauthenticated");if(!t)return Oe.current=t,void Ce({status:"done"});a.startAuthFlow(new Eo(t));let{user:n,isNewUser:r}=await a.authenticate();if(!n)return await st.logout(),Ce({status:"error",error:new T("Failed to sync with custom auth provider")}),void wa(be,"customAuth","onUnauthenticated");void 0!==r&&wa(be,"login","onComplete",{user:n,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),Oe.current=t,wa(be,"customAuth","onAuthenticated",{user:n}),Ce({status:"done"}),w(n||null),W(r||!1),g(!0),we(!0)}catch(e){if(console.warn(e),await st.logout(),wa(be,"customAuth","onUnauthenticated"),"User already exists with provided custom JWT account."===e.message)return void Ce({status:"initial"});wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),Ce({status:"error",error:e})}}})()}),["initial"===ve.status,ie.customAuth?.enabled,ie.customAuth?.getCustomAccessToken,ie.customAuth?.isLoading,p,y]),o((()=>{fe&&re&&f&&(async()=>{let e=Pt(f,ie.embeddedWallets.ethereum.createOnLogin),t=Lt(f,ie.embeddedWallets.solana.createOnLogin),n=await rw();if(n){if(e&&t){let e=await $e(f,Cr);return await re.createSolana({accessToken:n,ethereumAddress:e?.address}),void we(!1)}if(t)return await re.createSolana({accessToken:n,ethereumAddress:wr(f)?.address}),await lt.refreshSessionAndUser(),void we(!1);if(e)return await $e(f,Cr),void we(!1)}})().catch(console.error)}),[fe&&re&&f]),o((()=>{if(ie.externalWallets.solana.connectors)return ie.externalWallets.solana.connectors.onMount(),()=>ie.externalWallets.solana.connectors?.onUnmount()}),[ie.externalWallets.solana.connectors]),o((()=>{!p&&oe&&async function(){let e,t=We(),n=Me();(()=>{let e=new URLSearchParams(window.location.search).get("privy_token");if(!e)return;Xr.put(Xn,e);let t=new URL(window.location.href);t.searchParams.delete("privy_token"),window.history.pushState({},"",t)})();let i=r();a.initializeConnectorManager({walletConnectCloudProjectId:ie.walletConnectCloudProjectId,rpcConfig:ie.rpcConfig,chains:ie.chains,defaultChain:ie.defaultChain,store:i,walletList:ie.appearance.walletList,shouldEnforceDefaultChainOnConnect:ie.shouldEnforceDefaultChainOnConnect,externalWalletConfig:ie.externalWallets,appName:ie.name??"Privy",walletChainType:ie.appearance.walletChainType}),a.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=a.connectors.walletConnectors.length,n=a.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);n===t?_e(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:n,expected:t}),_e(!0)}),1500)})),a.connectors?.initialize().then((()=>{Fe()}));let o=await a.getAuthenticatedUser(),s=!!o;ie.legal.requireUsersAcceptTerms&&o&&!o.hasAcceptedTerms?(await a.logout(),lt.setReadyToTrue(!0),wa(be,"logout","onSuccess")):(ie.customAuth?.enabled||(g(!!o),o&&wa(be,"login","onComplete",{user:o,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),w(o)),t?Ie.current=s?"link":"login":n&&!s?(Ie.current="login",de({telegramAuthModalData:{seamlessAuth:!0}}),Re(ur.TELEGRAM_AUTH_SCREEN)):lt.setReadyToTrue(!!o))}()}),[a,he,p,oe]),o((()=>{if(p){if(!f||!f.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType)))return void ge(!0);ge([...k,...S].some((e=>"privy"===e.walletClientType)))}}),[p,f,k,S]),o((()=>{a.connectors?.setWalletList(ie.appearance.walletList)}),[ie.appearance.walletList.join()]);let We=()=>{let e=jo();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&function(e){return e.startsWith("privy:")}(e.provider)&&!e.popupFlow&&(new BroadcastChannel(Ff).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(a.startAuthFlow(new Ro(e)),Re(ur.AWAITING_OAUTH_SCREEN),!0))},Me=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),n=e.get("hash"),r=Number(e.get("auth_date")||""),a=e.get("first_name");if(t&&a&&r&&n)return Object.fromEntries(e.entries())}())?(Xo(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=Qo(e.replace("#tgWebAppData=","")),{user:n,auth_date:r,hash:a}=t;return n&&r&&a?t:void 0}())?(Xo(),{flowType:"web-app",authData:e}):void 0}();if(!e||!ie.loginMethods.telegram||!ie.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new Zo;return a.startAuthFlow(t),"login-url"===e.flowType&&(t.meta.telegramWebAppData=void 0,t.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=e.authData),!0},Pe=async(e,t,n,r)=>{if("solana_adapter"!==e)Le(await(a.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,n,r);else{let e=a.connectors?.findSolanaWalletConnector(t);if(!e)return;Le(e,t,n,r)}};async function Le(e,t,n,r){if(!e)return V({status:"disconnected",connectedWallet:null,connectError:new _("Unable to connect to wallet."),connector:null,connectRetry:P}),r?.(null,n);V({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:P}),e instanceof at&&t&&await e.resetConnection(t),V({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Le(e,t,n,r)});try{let t=await e.connect({showPrompt:!0});if((!t||it(t))&&ie.shouldEnforceDefaultChainOnConnect&&!ie.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){V((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:P})));try{await(t?.switchChain(ie.defaultChain.id)),t&&(t.chainId=Pn(Qe(ie.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${ie.defaultChain.id}`)}}return V((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:P}))),t&&wa(be,"connectWallet","onSuccess",{wallet:t}),r?.(t,n)}catch(e){return e instanceof M?(console.warn(e.cause?e.cause:e.message),wa(be,"connectWallet","onError",e.privyErrorCode||A.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),wa(be,"connectWallet","onError",A.UNKNOWN_CONNECT_WALLET_ERROR)),V((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),r?.(null,n)}}let De=async(e,t,n)=>{if(null===e||!it(e))return;let r=new ot(e,a,t,n);a.startAuthFlow(r)},Ue=async(e,t,n)=>{if(null===e||!Ta(e))return;let r=new Rn(e,a,t,n);a.startAuthFlow(r)},Fe=()=>{let e=new URLSearchParams(window.location.search),t=e.get("privy_connector"),n=e.get("privy_wallet_client"),r="true"===e.get("privy_connect_only");if(!t||!n)return;let i=Is({connectorType:t,walletClientType:n});if(!i||!i.isInstalled)return Re(ur.LOGIN_FAILED_SCREEN);if(!a.connectors)throw new T("Connector not initialized");Se(r?ur.AWAITING_CONNECT_ONLY_CONNECTION:ur.AWAITING_CONNECTION);let o=new URL(window.location.href);o.searchParams.delete("privy_connector"),o.searchParams.delete("privy_wallet_client"),o.searchParams.delete("privy_connect_only"),window.history.pushState({},"",o),Pe(t,n,void 0,r?void 0:"solana_adapter"===t?Ue:De)};o((()=>{p&&y&&null===f&&a.getAuthenticatedUser().then(w)}),[p,y,f,a]);let Be=e=>{if(!y)throw wa(be,"linkAccount","onError",A.MUST_BE_AUTHENTICATED,{linkMethod:e}),new T("User must be authenticated before linking an account.")},ze=e=>{if(!y||!f)return!1;if("privy"===e.walletClientType)return!0;for(let t of f.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},He=async e=>{let t;if(!a.connectors)throw new T("Connector not initialized");t="ethereum"===e.type?a.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:a.connectors.findSolanaWalletConnector(e.walletClientType)||null,V((n=>({...n,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:P}))),ie.captchaEnabled&&!y?(de({captchaModalData:{callback:t=>it(e)?De(e,t):Ue(e,t),userIntentRequired:!1,onSuccessNavigateTo:ur.AWAITING_CONNECTION,onErrorNavigateTo:ur.ERROR_SCREEN}}),Re(ur.CAPTCHA_SCREEN)):(it(e)?await De(e):await Ue(e),Re(ur.AWAITING_CONNECTION))},Ve=()=>{I((e=>{let t=a.connectors?.wallets.filter(it).map((e=>({...e,linked:ze(e),loginOrLink:async()=>{if(!await e.isConnected())throw new T("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot link or login with embedded wallet");He(e)},fund:async t=>{await lt.fundWallet(e.address,t)},unlink:async()=>{if(!y)throw new T("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot unlink an embedded wallet");w(await a.unlinkEthereumWallet(e.address))}})))||[];return Ln(e,t)?e:t})),x((e=>{let t=(a.connectors?.wallets??[]).filter(Ta).map((e=>({...e,linked:ze(e),loginOrLink:async()=>{if(!await e.isConnected())throw new T("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot link or login with embedded wallet");He(e)},fund:async()=>{throw new T("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!y)throw new T("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot unlink an embedded wallet");w(await a.unlinkSolanaWallet(e.address))}})));return Ln(e,t)?e:t}))};o((()=>{Ve()}),[f?.linkedAccounts,y,p]),o((()=>{if(p){if(!a.connectors)throw new T("Connector not initialized");Ve(),a.connectors.on("walletsUpdated",Ve)}}),[p]),o((()=>{[...ie.loginMethodsAndOrder?.primary??[],...ie.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>a.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!a]);let $e=async(e,t,n)=>{let r=wr(e),a=vr(e);if(n&&"walletIndex"in n&&"number"==typeof n.walletIndex)return Ge(e,t,n.walletIndex,r,a);let i=n&&"createAdditional"in n&&n.createAdditional;if(r&&!i)throw wa(be,"createWallet","onError",A.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");let[o,s]=await Promise.all([lt.initializeWalletProxy(t),rw()]);if(!o&&ie.customAuth?.enabled)throw wa(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!o||!s||ie.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return je();if(!r)return a&&await lt.recoverPrimaryWallet(),await o.create({accessToken:s,solanaAddress:a?.address}),Ke(0,"ethereum");{let t=(Gr(e)?.walletIndex??0)+1,{entropyId:n,entropyIdVerifier:r}=qn(Er(e));return await lt.recoverPrimaryWallet(),await o.addWallet({accessToken:s,entropyId:n,entropyIdVerifier:r,chainType:"ethereum",hdWalletIndex:t}),Ke(t,"ethereum")}},je=async()=>new Promise(((e,t)=>{le(!0),de({createWallet:{onSuccess:t=>{wa(be,"createWallet","onSuccess",{wallet:t}),e(t)},onFailure:e=>{wa(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),t(e)},callAuthOnSuccessOnClose:!1}}),Se(ur.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)})),Ge=async(e,t,n,r,a)=>{if(n<0)throw wa(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${n}) is invalid.`);let[i,o]=await Promise.all([lt.initializeWalletProxy(t),rw()]);if(!i&&ie.customAuth?.enabled)throw wa(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!i||!o||ie.embeddedWallets?.requireUserOwnedRecoveryOnCreate){if(0==n)return je();throw wa(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Create wallet UI can only be displayed when walletIndex is 0.")}if(0==n){if(r)return r;await i.create({accessToken:o,solanaAddress:a?.address})}else{if(!r)throw wa(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error("A user must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let t=$r(e).find((e=>e.walletIndex===n));if(t)return t;let{entropyId:a,entropyIdVerifier:s}=qn(Er(e));await lt.recoverPrimaryWallet(),await i.addWallet({accessToken:o,entropyId:a,entropyIdVerifier:s,chainType:"ethereum",hdWalletIndex:n})}return Ke(n,"ethereum")},qe=async({user:e,wp:t,accessToken:n,walletIndex:r,ethereumWallet:a})=>{let i=Vr(e).find((e=>e.walletIndex===r));if(i)return i;if(0===r)a&&await lt.recoverPrimaryWallet(),await t.createSolana({accessToken:n,ethereumAddress:a?.address});else{let a=Er(e);if(!a)throw wa(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error("User must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let{entropyId:i,entropyIdVerifier:o}=qn(a);await lt.recoverPrimaryWallet(),await t.addWallet({accessToken:n,entropyId:i,entropyIdVerifier:o,chainType:"solana",hdWalletIndex:r})}return Ke(r,"solana")},Ke=async(e,t)=>{let n=await lt.refreshSessionAndUser(),r=("ethereum"===t?$r(n):Vr(n)).find((t=>t.walletIndex===e));if(!r)throw wa(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");return wa(be,"createWallet","onSuccess",{wallet:r}),r},Ye=({transaction:e,uiOptions:t,fundWalletConfig:r,address:a,signOnly:i})=>new Promise((async(o,s)=>{let{requesterAppId:l}=t||{},c=i?"signTransaction":"sendTransaction";if(!y||!f)return wa(be,c,"onError",A.MUST_BE_AUTHENTICATED),void s(Error("User must be authenticated before signing with a Privy wallet"));let d=a??wr(f)?.address;if(!d)throw new T("User must have an embedded wallet to send a transaction.");let{signingWallet:h,rootWallet:u}=qr(f,d);if(!u||!h)return wa(be,c,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have a Privy wallet before signing"));le(!0);let p=ct.wallets.find((e=>"privy"===e.walletClientType&&C(e.address)===C(h.address))),m=await(p?.getEthereumProvider());if(!p||!m)throw new T(`Cannot sendTransaction before embedded wallet ${h.address} is connected`);let g=e.chainId?Number(e.chainId):ba(p.chainId);(e=>{if(!ie.chains.map((e=>e.id)).includes(e))throw new _(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,A.UNSUPPORTED_CHAIN_ID)})(g);let w={...e,from:e.from??h.address,chainId:g},v=await rw();if(!v||!re)return wa(be,c,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have valid access token and Privy wallet to send transaction"));let E=Ha(w.chainId,ie.chains,ie.rpcConfig,{appId:n.appId});if(xe({showWalletUIs:t?.showWalletUIs}))(async()=>{try{if(!await lt.recoverPrimaryWallet())return wa(be,c,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),void s(Error("Unable to connect to wallet"));let e=await cy(w,E,w.from),{entropyId:t,entropyIdVerifier:n}=qn(u),r=i?await Eg({accessToken:v,entropyId:t,entropyIdVerifier:n,transactingWallet:h,walletProxy:re,transactionRequest:w,requesterAppId:l}):await Cg({accessToken:v,entropyId:t,entropyIdVerifier:n,transactingWallet:h,walletProxy:re,transactionRequest:e,publicClient:E,requesterAppId:l});i?wa(be,"signTransaction","onSuccess",{signature:r}):wa(be,"sendTransaction","onSuccess",{hash:r}),o({hash:r})}catch(e){wa(be,c,"onError",A.TRANSACTION_FAILURE),s(e)}})();else{let{entropyId:e,entropyIdVerifier:n}=qn(u),a={entropyId:e,entropyIdVerifier:n,onCompleteNavigateTo:ur.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:e=>{wa(be,c,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),s(e)}},d=Gf(ie)?Ca({address:h.address,appConfig:ie,fundWalletConfig:r,methodScreen:ur.FUNDING_METHOD_SELECTION_SCREEN,chainIdOverride:w.chainId,comingFromSendTransactionScreen:!0}):void 0;de({connectWallet:a,sendTransaction:{transactionRequest:w,transactingWallet:h,entropyId:e,entropyIdVerifier:n,signOnly:i,onConfirm:i?async()=>await Eg({accessToken:v,entropyId:e,entropyIdVerifier:n,transactingWallet:h,walletProxy:re,transactionRequest:w,requesterAppId:l}):void 0,onSuccess:e=>{i?wa(be,"signTransaction","onSuccess",{signature:e.hash}):wa(be,"sendTransaction","onSuccess",{hash:e.hash}),o(e)},onFailure:e=>{wa(be,c,"onError",A.TRANSACTION_FAILURE),s(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:l},funding:d}),Se(ur.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),Ze=({transaction:e,connection:t,transactionOptions:n,fundWalletConfig:r,uiOptions:a,wallet:i,signOnly:o})=>new Promise((async(s,l)=>{let{requesterAppId:c}=a||{},d=o?"signSolanaTransaction":"sendSolanaTransaction";if(!y||!f)return wa(be,d,"onError",A.MUST_BE_AUTHENTICATED),void l(new T("User must be authenticated before signing with a Privy wallet",A.MUST_BE_AUTHENTICATED));let h=i?f.linkedAccounts.find((e=>"wallet"===e.type&&e.address===i.address)):vr(f);if(!h)return wa(be,d,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void l(new T("Must have a Privy wallet before signing",A.EMBEDDED_WALLET_NOT_FOUND));le(!0);let{rootWallet:u}=Br(f,h.address);if(!await lt.recoverPrimaryWallet().catch((()=>!1))||!u)throw wa(be,d,"onError",A.EMBEDDED_WALLET_NOT_FOUND),new T(`Cannot sendSolanaTransaction before embedded wallet ${h.address} is connected`,A.EMBEDDED_WALLET_NOT_FOUND);if(xe({showWalletUIs:a?.showWalletUIs}))(async()=>{let r=await rw();if(!r||!re)return wa(be,d,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void l(new T("Must have valid access token and Privy wallet to send transaction",A.EMBEDDED_WALLET_NOT_FOUND));try{let i;if(!await lt.recoverPrimaryWallet())return wa(be,d,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),void l(new T("Unable to connect to wallet",A.UNKNOWN_CONNECT_WALLET_ERROR));if(xe({showWalletUIs:a?.showWalletUIs})&&!o)try{if(!await async function(e,t){let{value:n}=await t.simulateTransaction(e);if("BlockhashNotFound"===n.err)throw Error("Simulation failed: Blockhash not found");return null==n.err&&n.logs?.every((e=>!/insufficient funds/gi.test(e)))}(e,t))return wa(be,d,"onError",A.INSUFFICIENT_BALANCE),void l(new T("Solana wallet has insufficient funds for this transaction.",A.INSUFFICIENT_BALANCE))}catch(e){return console.error(e),wa(be,d,"onError",A.TRANSACTION_FAILURE),void l(new T(e instanceof Error?e.message:"Transaction failed.",A.TRANSACTION_FAILURE))}let{entropyId:c,entropyIdVerifier:u}=Jr(f);if(o)await Ry({accessToken:r,tx:e,walletProxy:re,entropyId:c,entropyIdVerifier:u,transactingWalletAddress:h.address,transactingWalletIndex:h.walletIndex??0}),i=Dh("",e,null),wa(be,"signSolanaTransaction","onSuccess",{signedTransaction:e});else{let{signature:a,receipt:o}=await Oy({accessToken:r,tx:e,connection:t,walletProxy:re,transactionOptions:n,entropyId:c,entropyIdVerifier:u,transactingWalletAddress:h.address,transactingWalletIndex:h.walletIndex??0});i=Dh(a,e,o),wa(be,"sendSolanaTransaction","onSuccess",{response:i})}s(i)}catch(e){wa(be,d,"onError",A.TRANSACTION_FAILURE),l(e)}})();else{let{entropyId:i,entropyIdVerifier:p}=qn(u),m={entropyId:i,entropyIdVerifier:p,onCompleteNavigateTo:ur.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN,onFailure:e=>{wa(be,d,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),l(e)}},y=Gf(ie)?va({address:h.address,appConfig:ie,methodScreen:ur.FUNDING_METHOD_SELECTION_SCREEN,fundWalletConfig:r,comingFromSendTransactionScreen:!0}):void 0;de({connectWallet:m,sendSolanaTransaction:{transactionRequest:e,connection:t,transactionOptions:n,transactingWallet:h,onSuccess:e=>{o?wa(be,"signSolanaTransaction","onSuccess",{signedTransaction:e.signedTransaction}):wa(be,"sendSolanaTransaction","onSuccess",{response:e}),s(e)},onFailure:e=>{wa(be,d,"onError",A.TRANSACTION_FAILURE),l(e)},uiOptions:a||{},requesterAppId:c,signOnly:o},funding:y}),Se(ur.EMBEDDED_WALLET_CONNECTING_SCREEN)}}));function Je(){return new Promise((async(e,t)=>{let n=await rw();if(!n||!re)throw Error("Must have valid access token to enroll in MFA");try{await re.verifyMfa({accessToken:n}),e()}catch(e){t(e)}}))}let et=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],tt=e=>{let t=f?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:n,loginMethod:r}=vp(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw wa(be,"linkAccount","onError",A.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:r}),new T(`User already has an account of type ${n} linked.`)};async function nt({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){F(null);let n=t?"setWalletPassword":"setWalletRecovery";if(!y||!f)throw wa(be,n,"onError",A.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let r=Er(f);if(!r||!re)throw wa(be,n,"onError",A.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");try{await Je()}catch(e){throw wa(be,n,"onError",A.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,i)=>{le(!0);let o={onSuccess:e=>{wa(be,n,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{wa(be,n,"onError",A.USER_EXITED_SET_PASSWORD_FLOW),i(e)},callAuthOnSuccessOnClose:!1},s="user-passcode"===r.recoveryMethod,l=Kc({walletAction:"update",availableRecoveryMethods:ie.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:s,showAutomaticRecovery:e}),{entropyId:c,entropyIdVerifier:d}=qn(r);de({setWalletPassword:o,recoverWallet:{entropyId:c,entropyIdVerifier:d,onFailure:i},createWallet:o,connectWallet:{onCompleteNavigateTo:l,shouldForceMFA:!1,entropyId:c,entropyIdVerifier:d,onFailure:e=>{wa(be,n,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),i(e)}},recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:s}}),Se(ur.EMBEDDED_WALLET_CONNECTING_SCREEN)}))}async function rt({appId:e,action:t}){let n=await rw();if("link"===t&&!n)throw wa(be,"linkAccount","onError",A.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new T("User must be authenticated before linking an account.");if("login"===t&&n)throw wa(be,"login","onError",A.UNKNOWN_AUTH_ERROR),new T("Attempted to log in, but user is already logged in. Use a `link` helper instead.");ke.current=`privy:${e}`,Ie.current=t;let r=Ku();return a.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,i)=>{let{name:o,logoUrl:s}=await Hf({api:a.api,providerAppId:e,requesterAppId:ie.id});de({crossAppAuth:{appId:e,name:o,logoUrl:s,action:t,popup:r,onSuccess:n,onError:i}}),Re(ur.CROSS_APP_AUTH_SCREEN)}))}let st={ready:p,authenticated:y,user:f,walletConnectors:a.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),de({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),Se(y?ur.CONNECT_ONLY_AUTHENTICATED_SCREEN:ur.CONNECT_ONLY_LANDING_SCREEN)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),Be("siwe"),ke.current="siwe",Ie.current="link",de({...ce,externalConnectWallet:{...ce.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),Se(ur.LINK_WALLET_SCREEN)},startCrossAppAuthFlow:rt,linkEmail:()=>{Be("email"),tt("email"),ke.current="email",Ie.current="link",Se(ur.LINK_EMAIL_SCREEN)},linkPhone:()=>{Be("sms"),tt("phone"),ke.current="sms",Ie.current="link",Se(ur.LINK_PHONE_SCREEN)},linkGoogle:async()=>{Be("google"),tt("google_oauth"),Ie.current="link",await lt.initLoginWithOAuth("google")},linkTwitter:async()=>{Be("twitter"),tt("twitter_oauth"),Ie.current="link",await lt.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Be("discord"),tt("discord_oauth"),Ie.current="link",await lt.initLoginWithOAuth("discord")},linkGithub:async()=>{Be("github"),tt("github_oauth"),Ie.current="link",await lt.initLoginWithOAuth("github")},linkSpotify:async()=>{Be("spotify"),tt("spotify_oauth"),Ie.current="link",await lt.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Be("instagram"),tt("instagram_oauth"),Ie.current="link",await lt.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Be("tiktok"),tt("tiktok_oauth"),Ie.current="link",await lt.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Be("linkedin"),tt("linkedin_oauth"),Ie.current="link",await lt.initLoginWithOAuth("linkedin")},linkApple:async()=>{Be("apple"),tt("apple_oauth"),Ie.current="link",await lt.initLoginWithOAuth("apple")},linkPasskey:async()=>{Be("passkey"),tt("passkey"),await lt.initLinkWithPasskey(),Se(ur.LINK_PASSKEY_SCREEN)},linkTelegram:async e=>{if(Be("telegram"),tt("telegram"),Ie.current="link",ke.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new Zo;a.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=Qo(e.launchParams.initDataRaw),de({telegramAuthModalData:{seamlessAuth:!0}}),Re(ur.TELEGRAM_AUTH_SCREEN)}else wa(be,"linkAccount","onError",A.INVALID_DATA,{linkMethod:"telegram"});else await lt.initLoginWithTelegram();Se(ur.TELEGRAM_AUTH_SCREEN)},linkFarcaster:async()=>{Be("farcaster"),tt("farcaster"),await lt.initLoginWithFarcaster(),Ie.current="link",ke.current="farcaster",Se(ur.AWAITING_FARCASTER_CONNECTION)},updateEmail:()=>{if(Be("email"),!f?.email)throw new T("User does not have an email linked to their account.");Ie.current="update",ke.current="email",Se(ur.UPDATE_EMAIL_SCREEN)},updatePhone:()=>{if(Be("sms"),!f?.phone)throw new T("User does not have a phone number linked to their account.");Ie.current="update",ke.current="sms",Se(ur.UPDATE_PHONE_SCREEN)},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!p){let e=await new Promise((e=>{ue((t=>e.bind(t)))}));if(ue(null),e)return void console.warn(t)}!f||f.isGuest?(Ie.current="login",de({login:e}),Re(ur.LANDING)):console.warn(t)},connectOrCreateWallet:async()=>{p||(await new Promise((e=>{ue((()=>e))})),ue(null)),y?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(Ie.current="login",Re(ur.CONNECT_OR_CREATE))},logout:async()=>{if(Ie.current=null,ke.current=null,f&&a.clearProviderAcccessTokens(f),F(null),await a.logout(),f&&re)try{await re.clearMfa({userId:f.id})}catch(e){}w(null),g(!1),wa(be,"logout","onSuccess"),u(!1),Xr.del(dr),Xr.del(Fn(ie.id))},getAccessToken:c((()=>a.getCustomerAccessToken()),[a]),unlinkWallet:async e=>{let t;return w(t=e.startsWith("0x")?await a.unlinkEthereumWallet(e):await a.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await a.unlinkEmail(e);return w(t),t},unlinkPhone:async e=>{let t=await a.unlinkPhone(e);return w(t),t},unlinkGoogle:async e=>{let t=await a.unlinkOAuth("google",e);return w(t),t},unlinkTwitter:async e=>{let t=await a.unlinkOAuth("twitter",e);return w(t),t},unlinkDiscord:async e=>{let t=await a.unlinkOAuth("discord",e);return w(t),t},unlinkGithub:async e=>{let t=await a.unlinkOAuth("github",e);return w(t),t},unlinkSpotify:async e=>{let t=await a.unlinkOAuth("spotify",e);return w(t),t},unlinkInstagram:async e=>{let t=await a.unlinkOAuth("instagram",e);return w(t),t},unlinkTiktok:async e=>{let t=await a.unlinkOAuth("tiktok",e);return w(t),t},unlinkLinkedIn:async e=>{let t=await a.unlinkOAuth("linkedin",e);return w(t),t},unlinkApple:async e=>{let t=await a.unlinkOAuth("apple",e);return w(t),t},unlinkFarcaster:async e=>{let t=await a.unlinkFarcaster(e);return w(t),t},unlinkTelegram:async e=>{let t=await a.unlinkTelegram(e);return w(t),t},unlinkPasskey:async e=>{let t=await rw();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!re)throw Error("Wallet proxy not initialized.");let n=ie.passkeys.shouldUnenrollMfaOnUnlink;await re.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:n});let r=await a.getAuthenticatedUser();return w(r),r},unlinkCrossAppAccount:async({subject:e})=>{let t=f?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new T("Invalid subject");a.storeProviderAccessToken(t.id,null);let n=await a.unlinkOAuth(`privy:${t.id}`,e);return w(n),n},createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let t=await lt.refreshSessionAndUser();if(!t)throw wa(be,"createWallet","onError",A.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return $e(t,15e3,e)},setWalletRecovery:async e=>nt({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>nt({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=e.message;if(!y||!f)return wa(be,"signMessage","onError",A.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let s=t?.address??wr(f)?.address;if(!s)throw new T("User must have an embedded wallet to sign a message.");let{signingWallet:l,rootWallet:c}=qr(f,s);if(!l||!c)return wa(be,"signMessage","onError",A.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));if("string"!=typeof o||o.length<1)return wa(be,"signMessage","onError",A.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));le(!0);let d=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let e=await rw();if(!re||!e||!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:l.address,requesterAppId:i}});let{entropyId:t,entropyIdVerifier:n}=qn(c),{response:r}=await re.rpc({accessToken:e,entropyId:t,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:l.walletIndex??0,requesterAppId:i,request:{method:"personal_sign",params:[o,l.address]}}),s=r.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:l.address,requesterAppId:i}}),s};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await d();wa(be,"signMessage","onSuccess",{signature:e}),n({signature:e})}catch(e){wa(be,"signMessage","onError",A.UNABLE_TO_SIGN),r(e??new ua("Unable to sign message"))}else{let e={method:"personal_sign",data:o,confirmAndSign:d,onSuccess:e=>{wa(be,"signMessage","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{wa(be,"signMessage","onError",A.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},{entropyId:a,entropyIdVerifier:i}=qn(c);de({signMessage:e,connectWallet:{entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:ur.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{wa(be,"signMessage","onError",A.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Se(ur.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),signTypedData:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{};if(!y||!f)return wa(be,"signTypedData","onError",A.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let o=t?.address??wr(f)?.address;if(!o)throw new T("User must have an embedded wallet to sign a message.");let{signingWallet:s,rootWallet:l}=qr(f,o);if(!l||!s)return wa(be,"signTypedData","onError",A.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));le(!0);let c=Xe(e),d=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let e=await rw();if(!re||!e||!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:s.address,requesterAppId:i}});let{entropyId:t,entropyIdVerifier:n}=qn(l),{response:r}=await re.rpc({accessToken:e,entropyId:t,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:s.walletIndex??0,requesterAppId:i,request:{method:"eth_signTypedData_v4",params:[s.address,c]}}),o=r.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:s.address,requesterAppId:i}}),o};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await d();wa(be,"signTypedData","onSuccess",{signature:e}),n({signature:e})}catch(e){wa(be,"signTypedData","onError",A.UNABLE_TO_SIGN),r(e??new ua("Unable to sign message"))}else{let e={method:"eth_signTypedData_v4",data:c,confirmAndSign:d,onSuccess:e=>{wa(be,"signTypedData","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{wa(be,"signTypedData","onError",A.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},{entropyId:a,entropyIdVerifier:i}=qn(l);de({signMessage:e,connectWallet:{entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:ur.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{wa(be,"signMessage","onError",A.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Se(ur.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),sendTransaction:async(e,t)=>await Ye({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await Ye({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!y||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let i=e?.address??wr(f)?.address;if(!i)return void r(Error("User does not have an HD Ethereum wallet. To export an imported wallet, pass the `address` of the wallet to `exportWallet`."));if(!E(i))return void r(Error("Must provide a valid Ethereum address."));let{signingWallet:o,rootWallet:s}=qr(f,i);if(!o||!s)return void r(Error("Must have a Privy wallet before exporting"));le(!0);let{entropyId:l,entropyIdVerifier:c}=qn(s),d={entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:ur.EMBEDDED_WALLET_KEY_EXPORT_SCREEN,onFailure:r,shouldForceMFA:!0};de(ce),await rw()&&re?re?(de({keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:o,primaryWallet:s,onSuccess:t,onFailure:r},connectWallet:d}),Se(ur.EMBEDDED_WALLET_CONNECTING_SCREEN)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:Je,async init(e){switch(e){case"sms":return void await a.initMfaSmsVerification();case"passkey":return await a.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new T("Invalid MFA code");Ee.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{Te.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new T("Invalid authenticator response");let n=await import("@simplewebauthn/browser"),r=(e=>({id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}))(await n.startAuthentication(t));Ee.current?.resolve({mfaMethod:e,mfaCode:r,relyingParty:window.origin}),await new Promise(((e,t)=>{Te.current={resolve:e,reject:t}}));break;default:throw Ee.current?.reject(new T("Unsupported MFA method")),new T(`Unsupported MFA method: ${e}`)}},cancel(){Ee.current?.reject(new T("MFA canceled"))},async initEnrollmentWithSms(e){let t=await rw();if(!t||!re)throw Error("Must have valid access token to enroll in MFA");await re.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,n)=>{if(!e)return lt.closePrivyModal(),void t();ie.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),de({mfaEnrollmentFlow:{mfaMethods:ie.mfa.methods,shouldUnlinkOnUnenrollMfa:ie.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:n}}),Se(ur.MFA_ENROLLMENT_FLOW_SCREEN)})),async initEnrollmentWithTotp(){let e=await rw();if(!e||!re)throw Error("Must have valid access token to enroll in MFA");let t=await re.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await rw();if(!t||!re)throw Error("Must have valid access token to enroll in MFA");await re.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),w(await a.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await rw();if(!t||!re)throw Error("Must have valid access token to enroll in MFA");await re.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),w(await a.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let n=await rw();if(!n||!re)throw Error("Must have valid access token to enroll in MFA");await re.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:e,removeForLogin:t.removeForLogin}),w(await a.getAuthenticatedUser())},async unenroll(e,t={}){let n=await rw();if(!n||!re)throw Error("Must have valid access token to remove MFA");"passkey"===e?await re.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:[],removeForLogin:t.removeForLogin}):await re.unenrollMfa({method:e,accessToken:n}),w(await a.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await rw(),t=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!re||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");let n=await re.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===n.status&&w(await a.getAuthenticatedUser()||f||null),de({farcasterSigner:n}),Se(ur.AWAITING_FARCASTER_SIGNER)},getFarcasterSignerPublicKey:async()=>{let e,t=await rw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!re||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=f.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await rw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!re||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let r=await import("@simplewebauthn/browser"),a=await re.signFarcasterMessage({address:n.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:r.bufferToBase64URLString(e)},fid:BigInt(f.farcaster.fid),relyingParty:window.origin});return new Uint8Array(r.base64URLStringToBuffer(a.signature))},createGuestAccount:async()=>{if(f&&!f.isGuest)throw Error("User cannot already be authenticated to create a guest account");return f?.isGuest?f:lt.loginWithGuestAccountFlow()},signMessageWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Vf({user:f,client:a,address:t,requesterAppId:ie.id,request:{method:r?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:n},reconnect:rt})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),i=Xe(e);return Vf({user:f,client:a,address:t,requesterAppId:ie.id,request:{method:r?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,i],chainId:n},reconnect:rt})},sendTransactionWithCrossAppWallet(e,{address:t}){let n=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Vf({user:f,client:a,address:t,requesterAppId:ie.id,request:{method:n?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:rt})},isModalOpen:h,mfaMethods:ie.mfa.methods};Yf=st.signMessage,Zf=st.signTypedData,Qf=async(e,t)=>await Ye({transaction:e,...t,signOnly:!1}),Jf=async(e,t)=>({signature:(await Ye({transaction:e,...t,signOnly:!0})).hash});let lt={setAuthenticated:g,setUser:w,isNewUserThisSession:O,pendingTransaction:null,walletConnectionStatus:H,connectors:a.connectors?.walletConnectors??[],solanaWallets:N,rpcConfig:ie.rpcConfig,chains:ie.chains,appId:n.appId,showFiatPrices:"native-token"!==ie.embeddedWallets.priceDisplay.primary,clientAnalyticsId:a.clientAnalyticsId,customAuthStatus:ve,hideWalletUIs:Ne,emailOtpState:G,setEmailOtpState:q,smsOtpState:K,setSmsOtpState:Y,oAuthState:X,setOAuthState:ee,telegramAuthState:te,setTelegramAuthState:ne,siweState:J,setSiweState:Q,isHeadlessOAuthLoading:B,nativeTokenSymbolForChainId:e=>ie.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(re)return re;let t=new Promise((e=>{me((()=>t=>e(t)))})),n=new Promise((t=>setTimeout((()=>t(null)),e))),r=await Promise.race([t,n]);return me(null),r},getAuthFlow:()=>a.authFlow,getAuthMeta:()=>a.authFlow?.meta,client:a,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=p&&y&&f;r&&ke.current&&(t=et(f)),"login"===Ie.current?e.shouldCallAuthOnSuccess&&r&&ke.current?wa(be,"login","onComplete",{user:f,isNewUser:O,wasAlreadyAuthenticated:!1,loginMethod:ke.current,loginAccount:t??null}):wa(be,"login","onError",A.USER_EXITED_AUTH_FLOW):"link"===Ie.current&&t?e.isSuccess&&r&&ke.current?wa(be,"linkAccount","onSuccess",{user:f,linkMethod:ke.current,linkedAccount:t}):ke.current&&wa(be,"linkAccount","onError",A.USER_EXITED_LINK_FLOW,{linkMethod:ke.current}):"update"===Ie.current&&t&&(e.isSuccess&&r&&ke.current?wa(be,"update","onSuccess",{user:f,updateMethod:ke.current,updatedAccount:t}):ke.current&&wa(be,"update","onError",A.USER_EXITED_UPDATE_FLOW,{linkMethod:ke.current}));let i=U&&Mu.includes(U),o=U===ur.ERROR_SCREEN&&ce.errorModalData&&Mu.includes(ce.errorModalData.previousScreen);if((i||o)&&ce.funding){let e,t=Pu[U]??null;if("solana"===ce.funding.chainType){let n=d(sa);if(!n)return void console.warn("Unable to load solana plugin, skipping balance");try{e=BigInt(await n.getBalance({address:ce.funding.address,cluster:ce.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}wa(be,"fundSolanaWallet","onUserExited",{address:ce.funding.address,cluster:ce.funding.cluster,fundingMethod:t,balance:e})}else{let r=Ha(ce.funding.chain.id,ie.chains,ie.rpcConfig,{appId:n.appId});try{e=await r.getBalance({address:ce.funding.address})}catch{console.error("Unable to pull wallet balance")}wa(be,"fundWallet","onUserExited",{address:ce.funding.address,chain:ce.funding.chain,fundingMethod:t,balance:e})}}de({...ce,externalConnectWallet:{suggestedAddress:void 0}}),Ie.current=null,ke.current=null,W(!1),u(!1),setTimeout((()=>{a.authFlow=void 0}),200)},solanaSignMessage:({message:e,options:t})=>new Promise((async(n,r)=>{if(!y||!f)return wa(be,"signSolanaMessage","onError",A.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let i=t?.address??vr(f)?.address;if(!i)throw new T("User must have an embedded wallet to sign a message.");let{signingWallet:o,rootWallet:s}=Br(f,i);if(!o||!s)return wa(be,"signSolanaMessage","onError",A.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));if("string"!=typeof e||e.length<1)return wa(be,"signMessage","onError",A.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));le(!0);let l=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let t=await a.getAccessToken();if(!t)throw Error("User must be authenticated to use their embedded wallet.");let n=lt.walletProxy??await lt.initializeWalletProxy(15e3);if(!n)throw Error("Failed to initialize embedded wallet proxy.");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!s)throw Error("No root wallet for signing wallet found");let{entropyId:r,entropyIdVerifier:i}=Jr(f),{response:l}=await n.rpc({accessToken:t,entropyId:r,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:o.walletIndex??0,request:{method:"signMessage",params:{message:e}}});return l.data.signature};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await l();wa(be,"signSolanaMessage","onSuccess",{signature:new Uint8Array(Buffer.from(e,"base64"))}),n({signature:e})}catch(e){r(e)}else{let a={method:"solana_signMessage",data:e,confirmAndSign:l,onSuccess:e=>{wa(be,"signSolanaMessage","onSuccess",{signature:new Uint8Array(Buffer.from(e,"base64"))}),n({signature:e})},onFailure:e=>{r(e)},uiOptions:t?.uiOptions},{entropyId:i,entropyIdVerifier:o}=qn(s);de({signMessage:a,connectWallet:{entropyId:i,entropyIdVerifier:o,onCompleteNavigateTo:ur.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{wa(be,"signSolanaMessage","onError",A.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Re(ur.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),signSolanaTransaction:async({transaction:e,connection:t,uiOptions:n,transactionOptions:r,address:a})=>{let i=a?S.find((e=>e.address===a)):S.slice().sort(((e,t)=>(e.walletIndex??0)-(t.walletIndex??0)))[0];if(!i)throw wa(be,"signSolanaTransaction","onError",A.EMBEDDED_WALLET_NOT_FOUND),new T("Embedded wallet not found",A.EMBEDDED_WALLET_NOT_FOUND);let{signedTransaction:o}=await Ze({transaction:e,connection:t,transactionOptions:r,uiOptions:n,wallet:i,signOnly:!0});return o},sendSolanaTransaction:async({transaction:e,connection:t,uiOptions:n,transactionOptions:r,fundWalletConfig:a,address:i})=>{let o=i?S.find((e=>e.address===i)):S.slice().sort(((e,t)=>(e.walletIndex??0)-(t.walletIndex??0)))[0];if(!o)throw wa(be,"sendSolanaTransaction","onError",A.EMBEDDED_WALLET_NOT_FOUND),new T("Embedded wallet not found",A.EMBEDDED_WALLET_NOT_FOUND);return await Ze({transaction:e,connection:t,transactionOptions:r,uiOptions:n,fundWalletConfig:a,wallet:o,signOnly:!1})},openPrivyModal:Se,connectWallet:Le,initLoginWithWallet:async(e,t,n)=>{it(e)?(ke.current="siwe",De(e,t,n)):(ke.current="siws",Ue(e,t,n))},loginWithWallet:async()=>{let e,t,n;if(!p)throw new L;if(a.authFlow instanceof ot?e="siwe":a.authFlow instanceof Rn&&(e="siws"),!e)throw new T("Must initialize SIWE/SIWS flow first.");if(null!==await a.getAccessToken())try{({user:t}=await a.link()),ke.current=e}catch(t){throw wa(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:n}=await a.authenticate()),ke.current=e}catch(e){throw wa(be,"login","onError",e.privyErrorCode||A.GENERIC_CONNECT_WALLET_ERROR),e}w(t||f||null),W(n||!1),g(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:n})=>new Promise((async(r,a)=>{let i=await rw();if(!y||!f||!i)throw new T("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new T("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=lt.walletProxy??await lt.initializeWalletProxy(15e3);if(!o)throw new T("Wallet proxy not initialized.");if((({address:e,chainType:t,user:n})=>!!Lf(n).find((n=>n.address===e&&n.chainType===t)))({address:e,chainType:t,user:f}))return r();let s=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new T("Address to delegate is not associated with current user.");return{address:n.address,chainType:n.chainType,walletIndex:n.walletIndex??0}})({address:e,user:f}),l=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new T("Address to delegate is not associated with current user.");let r=n.imported?n:Er(t);if(!r)throw new T("Unable to determine root address for delegated address.");return{address:r.address,chainType:r.chainType,imported:r.imported}})({address:e,user:f}),c=async()=>{await o.createDelegatedAction({accessToken:i,rootWallet:l,delegatedWallets:[s]}),await lt.refreshSessionAndUser()};if(await lt.recoverPrimaryWallet(),n)de({delegatedActions:{consent:{address:e,onDelegate:c,onSuccess:async()=>{r()},onError:async e=>{a(e)}}}}),Se(ur.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN);else try{await c(),r()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,n)=>{if(!y||!f)throw new T("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");if(0===Lf(f).length)throw new T("User has no delegated wallets to revoke.");let r=async()=>{await a.revokeDelegatedWallet(),await lt.refreshSessionAndUser()};if(e)de({delegatedActions:{revoke:{onRevoke:r,onSuccess:async()=>{t()},onError:async e=>{n(e)}}}}),Se(ur.EMBEDDED_WALLET_DELEGATED_ACTIONS_REVOKE_SCREEN);else try{await r(),t()}catch(e){n(e)}})),initLoginWithFarcaster:async(e,t)=>{let n=new _o(e,t);a.startAuthFlow(n);try{ke.current="farcaster",await n.initializeFarcasterConnect()}catch(e){throw"login"===Ie.current?wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&wa(be,"linkAccount","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!p)throw new L;if(!(a.authFlow instanceof _o))throw new T("Must initialize Farcaster flow first.");if(null!==await a.getAccessToken())try{({user:e}=await a.link()),ke.current="farcaster"}catch(e){throw wa(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await a.authenticate()),ke.current="farcaster"}catch(e){throw wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}w(e||null),W(t||!1),g(!0)},async loginWithGuestAccountFlow(){let e=new Io(this.appId);a.startAuthFlow(e);try{Ie.current="login",ke.current="guest";let{user:e,isNewUser:t}=await a.authenticate();if(t=t||!1,!e)throw new T("Unable to authenticate guest account");let n=await rw(),r=await lt.initializeWalletProxy(Cr);if(n&&r)try{let t=Pt(e,ie.embeddedWallets.ethereum.createOnLogin),a=Lt(e,ie.embeddedWallets.solana.createOnLogin);if(t&&a){let t=await $e(e,Cr);await r.createSolana({accessToken:n,ethereumAddress:t?.address}),e=await lt.refreshSessionAndUser()}else a?(await r.createSolana({accessToken:n,ethereumAddress:wr(e)?.address}),e=await lt.refreshSessionAndUser()):t?(await $e(e,Cr),e=await lt.refreshSessionAndUser()):w(e)}catch(t){w(e),console.warn("Unable to create embedded wallet for guest account")}return W(t),g(!0),wa(be,"login","onComplete",{user:e,isNewUser:t,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),e}catch(e){throw wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}},async crossAppAuthFlow({appId:e,popup:t,action:n}){let r=`privy:${e}`;ke.current=r;let{url:i,stateCode:o,codeVerifier:s}=await async function({api:e,appId:t}){let n=No(),r=xo(),a=await So(n);try{let{url:i}=await e.post(Z,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:r});return{url:i,stateCode:r,codeVerifier:n}}catch(e){throw b(e)}}({api:a.api,appId:e});if(!i)throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new T("No authorization URL returned for cross-app auth.");try{let l=await async function({url:e,popup:t}){return t.location=e,new Promise(((e,n)=>{let r,a=setTimeout((()=>{n(new T("Authorization request timed out after 2 minutes.")),i()}),12e4);function i(){t?.close(),window.removeEventListener("message",s)}let o=setInterval((()=>{t?.closed&&!r&&(i(),clearInterval(o),clearTimeout(a),n(new T("User rejected request")))}),300);function s(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(a),e(t.data),i()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(a),n(new T(t.data.error)),i()),t.data.type===Bf&&((r=new BroadcastChannel(Ff)).onmessage=s))}window.addEventListener("message",s)}))}({url:i,popup:t,provider:r}),c=l.stateCode,d=l.authorizationCode;if(c!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:r,storedStateCode:o??"",returnedStateCode:c??""}}),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED);let h=await async function({appId:e,stateCode:t,codeVerifier:n,authorizationCode:r,action:a,client:i}){if(!r||!t)throw new T("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===r)throw new T("User denied confirmation during cross-app auth flow");try{let o=new zf({authorizationCode:r,stateCode:t,codeVerifier:n,provider:`privy:${e}`});i.startAuthFlow(o);let s="link"===a?await i.link():await i.authenticate(),l=s.oAuthTokens?.accessToken;return console.debug(),l}catch(e){let t=b(e);if(t.privyErrorCode)throw new T(t.message||"Invalid code during cross-app auth flow.",void 0,t.privyErrorCode);if("User denied confirmation during cross-app auth flow"===t.message)throw new T("Invalid code during cross-app auth flow.",void 0,A.OAUTH_USER_DENIED);throw new T("Invalid code during cross-app auth flow.",void 0,A.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:s,stateCode:c,authorizationCode:d,action:n,client:a});h&&a.storeProviderAccessToken(e,h);let u=await lt.refreshSessionAndUser();if(!u)throw new T("Unable to update user");return a.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),u}catch(e){throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:r}}),e}},async initLoginWithOAuth(e,t,n){if(ke.current=e,!Qr())return void Re(ur.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE);if("google"===e&&gc(window.navigator.userAgent))return void Re(ur.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE);"twitter"===e&&window.opener&&window.opener.postMessage({type:Bf},"*"),Xr.del(zn),Xr.del(Hn);let r=new Ro({provider:e,disableSignup:!!n,withPrivyUi:!0});t&&r.addCaptchaToken(t),a.startAuthFlow(r);let i=await a.authFlow.getAuthorizationUrl();i&&i.url&&("twitter"===e&&v&&(i.url=i.url.replace("x.com","twitter.com")),window.location.assign(i.url))},async initLoginWithTelegram(e,t){if(!p)throw new L;ke.current="telegram";let n=new Zo(e,t);a.startAuthFlow(n),ne({status:"loading"}),n.meta.telegramWebAppData=void 0,n.meta.telegramAuthResult=await new Promise(((e,t)=>ie.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:ie.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(n=>n?e(n):t(new T("Telegram auth failed or was canceled by the client")))):t(new T("Telegram was not initialized")):t(new T("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,n;if(!(a.authFlow instanceof Zo))throw new T("Must initialize Telegram flow before calling loginWithTelegram");a.authFlow.meta.captchaToken||=e?.captchaToken;let r=await rw(),i=e?.intent||Ie.current;if("login"===i)try{let e=await a.authenticate();t=e.user,n=e.isNewUser,ke.current="telegram"}catch(e){throw wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}else{if("link"!==i)throw new T("Unknown auth intent");try{t=(await a.link()).user,ke.current="telegram"}catch(e){throw wa(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}w(t),W(n||!1),g(!0),ne({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:o}},async recoveryOAuthFlow(e,t,n){let r,i;function o(t){if(!t)throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:e}}),new T("Recovery OAuth failed")}switch(e){case"google-drive":{let t,s,{url:l,codeVerifier:c,stateCode:d}=await Zc({api:Kf.api,provider:e});o(l);try{let r=await qf({url:l,popup:n,provider:e});if(t=r.stateCode,s=r.authorizationCode,t!==d)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:d??"",returnedStateCode:t??""}}),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED)}catch(t){throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:e}}),new T("Recovery OAuth failed")}[r,i]=await Promise.all([rw(),Jc({api:Kf.api,provider:e,codeVerifier:c,stateCode:t,authorizationCode:s})]);break}case"icloud":{let{url:t}=await Zc({api:Kf.api,provider:e});o(t);let{ckWebAuthToken:a}=await qf({url:t,popup:n,provider:e});i=a,r=await rw()}}if(!re)throw new T("Cannot connect to wallet proxy");if(!r)throw new T("Unable to authorize user");switch(t){case"recover":{let t=ce.recoverWallet?.entropyId,n=ce.recoverWallet?.entropyIdVerifier;if(!t||!n)throw new T("Recovery OAuth failed");a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t,recoveryMethod:e}}),await re.recover({accessToken:r,entropyId:t,entropyIdVerifier:n,recoveryAccessToken:i}),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t,recoveryMethod:e}});break}case"create-wallet":{a.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await re.create({accessToken:r,recoveryAccessToken:i,recoveryMethod:e});let t=wr(await lt.refreshSessionAndUser());if(!t)throw wa(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.address}}),wa(be,"createWallet","onSuccess",{wallet:t});break}case"set-recovery":{let t=Er(f);if(!t)throw wa(be,"setWalletRecovery","onError",A.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}});let{entropyId:n,entropyIdVerifier:o}=qn(t);await re.setRecovery({accessToken:r,entropyId:n,entropyIdVerifier:o,recoveryMethod:e,recoveryAccessToken:i});let s=Er(await lt.refreshSessionAndUser());if(!s)throw wa(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}}),wa(be,"setWalletRecovery","onSuccess",{method:e,wallet:s});break}default:throw new T("Unsupported recovery action")}},async loginWithOAuth(e){let t,n,r;if(!(a.authFlow instanceof Ro))throw new T("Must initialize OAuth flow before calling loginWithOAuth");let i=Xr.get(Vn),o=a.authFlow.meta.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:i??"",returnedStateCode:o??""}}),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{let n=await a.link();t=n.user,r=n.oAuthTokens,ke.current=e}catch(t){throw wa(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let i=await a.authenticate();t=i.user,n=i.isNewUser,r=i.oAuthTokens,ke.current=e}catch(t){throw"login"===Ie.current?wa(be,"login","onError",t.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&wa(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return w(t),W(n||!1),g(!0),r&&t&&wa(be,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),r},passkeyAuthState:$,setPasskeyAuthState:j,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new qo({captchaToken:e,setPasskeyAuthState:j});a.startAuthFlow(n),Ie.current="login";try{ke.current="passkey",j({status:"generating-challenge"}),await n.initRegisterFlow(t),j({status:"awaiting-passkey"})}catch(e){throw j({status:"error",error:e}),wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!p)throw new L;if(!(a.authFlow instanceof qo))throw new T("Must initialize Passkey flow first.");if("passkey"!==ke.current){let e=new T("Must init login with Passkey flow first.");throw j({status:"error",error:e}),e}let n=await rw();try{ke.current="passkey",j({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await a.authenticate())}catch(e){throw j({status:"error",error:e}),wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}w(e),W(t||!1),g(!0),j({status:"done"});let r=e?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:e,isNewUser:t||!1,wasAlreadyAuthenticated:!!n,loginAccount:r}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new qo({captchaToken:e,setPasskeyAuthState:j});a.startAuthFlow(n),Ie.current="login";try{ke.current="passkey",j({status:"generating-challenge"}),await n.initAuthenticationFlow(t),j({status:"awaiting-passkey"})}catch(e){throw j({status:"error",error:e}),wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,n;if(!p)throw new L;if(!(a.authFlow instanceof qo))throw new T("Must initialize Passkey flow first.");if(e?.credentialIds&&(a.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==ke.current){let e=new T("Must init login with Passkey flow first.");throw j({status:"error",error:e}),e}let r=await rw();try{ke.current="passkey",j({status:"awaiting-passkey"}),({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw j({status:"error",error:e}),wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}w(t),W(n||!1),g(!0),j({status:"done"});let i=t?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:i}},async initLinkWithPasskey(e){let t=new qo({captchaToken:e});a.startAuthFlow(t),Ie.current="link",ke.current="passkey",j({status:"generating-challenge"});try{await t.initLinkFlow(),j({status:"awaiting-passkey"})}catch(e){throw wa(be,"linkAccount","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),j({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!p)throw new L;if(!(a.authFlow instanceof qo))throw new T("Must initialize Passkey flow first.");if("passkey"!==ke.current)throw new T("Must init login with Passkey flow first.");try{ke.current="passkey",({user:e}=await a.link())}catch(e){throw wa(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return w(e||f||null),j({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,n){if(!Qr())throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");if("google"===e&&gc(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let r=new Ro({provider:e,withPrivyUi:!1,disableSignup:n??!1});t&&r.addCaptchaToken(t),ee({status:"loading"});let i=await a.startAuthFlow(r).getAuthorizationUrl();i?.url&&window.location.assign(i.url)},async loginWithHeadlessOAuth(e){let t,n,r;z(!0),ee({status:"loading"}),a.startAuthFlow(new Ro(e));let i=Xr.get(Vn),o=e.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:i??"",returnedStateCode:o??""}}),z(!1),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{({user:t,oAuthTokens:r}=await a.link()),ke.current=e.provider;let n=et(t);t&&n&&wa(be,"linkAccount","onSuccess",{user:t,linkMethod:ke.current,linkedAccount:n})}catch(t){throw z(!1),wa(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:n,oAuthTokens:r}=await a.authenticate()),ke.current=e.provider;let i=et(t);t&&i&&void 0!==n&&wa(be,"login","onComplete",{user:t,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:ke.current,loginAccount:i})}catch(e){throw z(!1),ee({status:"error",error:e}),wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}return w(t),W(n||!1),g(!0),z(!1),ee({status:"done"}),r&&t&&wa(be,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{let i=new bo({email:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ke.current="email",q({status:"sending-code"}),await i.sendCodeEmail({withPrivyUi:r}),q({status:"awaiting-code-input"})}catch(e){throw q({status:"error",error:e}),"login"===Ie.current?wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&wa(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,n)=>{let r=new Ao(e,t,n);a.startAuthFlow(r);try{await r.sendCodeEmail({withPrivyUi:!0})}catch(e){wa(be,"update","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:ke.current})}},initUpdatePhone:async(e,t,n)=>{let r=new Yo(e,t,n);a.startAuthFlow(r);try{await r.sendSmsCode({withPrivyUi:!0})}catch(e){wa(be,"update","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:ke.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{Y({status:"sending-code"});let i=new Ko({phoneNumber:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ke.current="sms",await i.sendSmsCode({withPrivyUi:r}),Y({status:"awaiting-code-input"})}catch(e){throw Y({status:"error",error:e}),"login"===Ie.current?wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&wa(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await(a.authFlow?.sendCodeEmail({withPrivyUi:!0}))},resendSmsCode:async()=>{await(a.authFlow?.sendSmsCode({withPrivyUi:!0}))},loginWithCode:async e=>{let t,n;function r(e){a.authFlow instanceof bo?q(e):a.authFlow instanceof Ko&&Y(e)}if(r({status:"submitting-code"}),!p){let e=new L;throw r({status:"error",error:e}),e}if(a.authFlow instanceof bo)a.authFlow.meta.emailCode=e.trim();else{if(!(a.authFlow instanceof Ko)){let e=new T("Must initialize a passwordless code flow first");throw r({status:"error",error:e}),e}a.authFlow.meta.smsCode=e.trim()}let i=await rw();if("link"===Ie.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),wa(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:ke.current}),e}else if("update"===Ie.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),wa(be,"update","onError",e.privyErrorCode||A.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:ke.current}),e}else try{({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw r({status:"error",error:e}),wa(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}let o=t||f;w(o||null),W(n||!1),g(!0),r({status:"done"});let s=null;return a.authFlow instanceof bo?s=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:a.authFlow instanceof Ko&&(s=o?.linkedAccounts.find((({type:e})=>"phone"===e))||null),{user:o,isNewUser:n||!1,wasAlreadyAuthenticated:!!i,linkedAccount:s}},generateSiweMessage:async({address:e,chainId:t,captchaToken:n})=>{Ie.current="link",ke.current="siwe",Q({status:"generating-message"});let r=await a.generateSiweNonce({address:e,captchaToken:n});return Q({status:"awaiting-signature"}),On({address:e,chainId:t.replace("eip155:",""),nonce:r})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let n=await a.generateSiweNonce({address:e});return On({address:e,chainId:t.replace("eip155:",""),nonce:n})},linkSmartWallet:async({message:e,signature:t,smartWalletType:n})=>{let r;r=await a.linkSmartWallet({message:e,signature:t,smartWalletType:n}),w((r=await lt.refreshSessionAndUser()??r)||f||null)},linkWithSiwe:async({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i})=>{let o;Be("siwe");let s=null;try{Q({status:"submitting-signature"}),o=await a.linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i}),o=await lt.refreshSessionAndUser()??o,Q({status:"done"}),(s=et(o)||null)&&wa(be,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:s})}catch(e){throw wa(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),Ie.current=null,ke.current=null,Q({status:"error",error:e}),e}let l=o||f;return w(l||null),Ie.current=null,ke.current=null,{user:l,linkedAccount:s}},refreshSessionAndUser:async()=>{let e=await a.getAuthenticatedUser();return g(!!e),w(e),e},walletProxy:re,createAnalyticsEvent:({eventName:e,payload:t,timestamp:n})=>a.createAnalyticsEvent({eventName:e,payload:t,timestamp:n}),acceptTerms:async()=>{let e=await a.acceptTerms();return w(e),e},getUsdTokenPrice:e=>a.getUsdTokenPrice(e),getUsdPriceForSol:()=>a.getUsdPriceForSol(),getSplTokenMetadata:e=>a.getSplTokenMetadata(e),recoverPrimaryWallet:async e=>new Promise((async(t,n)=>{let r=Er(e?.user??f)||jr(e?.user??f)||Fr(e?.user??f);r||t(!0);let i=await rw();if(!i||!re||!r)return void n(Error("Must have valid access token and Privy wallet to recover wallet"));le(!0);let{entropyId:o,entropyIdVerifier:s}=qn(r);try{await re.connect({accessToken:i,entropyId:o,entropyIdVerifier:s}),t(!0)}catch(e){zc(e)&&"privy"===r.recoveryMethod?(a.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:r.address}}),(await re.recover({entropyId:o,entropyIdVerifier:s,accessToken:i})).entropyId||n(Error("Unable to recover wallet")),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:r.address}}),t(!0)):zc(e)&&"privy"!==r.recoveryMethod?(de({recoverWallet:{entropyId:o,entropyIdVerifier:s,onFailure:n,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:r.recoveryMethod,action:"recover"}}),Se(Yc(r.recoveryMethod))):n(e)}})),embeddedSolanaWallets:S,createEmbeddedSolanaWallet:async e=>{e&&"target"in e&&(e=void 0);let t=await lt.refreshSessionAndUser();if(!t)throw wa(be,"createWallet","onError",A.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return(async(e,t,n)=>{let r=wr(e),a=vr(e),i=n&&"createAdditional"in n&&n.createAdditional,o=n&&"walletIndex"in n?n.walletIndex:void 0,s=(Zr(e)?.walletIndex??-1)+1;if(a&&!i&&"number"!=typeof o)throw wa(be,"createWallet","onError",A.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");if("number"==typeof o&&o<0)throw wa(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${o}) is invalid.`);let[l,c]=await Promise.all([lt.initializeWalletProxy(t),rw()]);if(!l||!c)throw wa(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return await qe({user:e,wp:l,accessToken:c,walletIndex:o??s,ethereumWallet:r})})(t,15e3,e)},exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!y||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));let i=e?.address??vr(f)?.address;if(!i)return void r(Error("User does not have an HD Solana wallet."));let{signingWallet:o,rootWallet:s}=Br(f,i);if(!o||!s)return void r(Error("Must have a Privy wallet before exporting"));if(le(!0),!await rw()||!re)return void r(Error("Must have valid access token to enroll in MFA"));if(!re)return void r(Error("Must have a Privy wallet before exporting"));let{entropyId:l,entropyIdVerifier:c}=qn(s);de({connectWallet:{entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:ur.EMBEDDED_WALLET_KEY_EXPORT_SCREEN,onFailure:r,shouldForceMFA:!0},keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:o,primaryWallet:s,onSuccess:t,onFailure:r}}),Se(ur.EMBEDDED_WALLET_CONNECTING_SCREEN)})),setReadyToTrue:e=>{m(!0),he?.(e)},updateWallets:()=>Ve(),fundWallet:async(e,t)=>{let n=ur.FUNDING_METHOD_SELECTION_SCREEN;de({funding:Ca({address:e,appConfig:ie,fundWalletConfig:t,methodScreen:n})}),Se(n)},openModal:Se,requestFarcasterSignerStatus:async e=>{let t=await rw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!re||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let r=await a.requestFarcasterSignerStatus(e);return"approved"===r.status&&w(await a.getAuthenticatedUser()||f||null),r},connectCoinbaseSmartWallet:async()=>{ie.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let e=a.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||a.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Le(e);await Pe("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:i,telegramWebAppData:o,farcasterEmbeddedAddress:s,oAuthUserInfo:l})=>{let c=await a.sendAccountTransferRequest({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:i,telegramWebAppData:o,farcasterEmbeddedAddress:s,oAuthUserInfo:l});return w(c),c}};Xf=lt.recoverPrimaryWallet,ew=lt.recoverPrimaryWallet,tw=lt.solanaSignMessage;let ct=i((()=>({wallets:k,ready:ye&&Ae})),[k,ye,Ae]),dt=a.authFlow instanceof Zo,ht=!ie.headless&&ie.captchaEnabled&&!y&&(p||dt);/*#__PURE__*/return t(Lr.Provider,{value:st,children:/*#__PURE__*/t(Ea.Provider,{value:be,children:/*#__PURE__*/t(Kr.Provider,{value:ct,children:/*#__PURE__*/t(Wn,{...ie,children:/*#__PURE__*/e(D.Provider,{value:lt,children:[/*#__PURE__*/t(Mn,{children:/*#__PURE__*/e(Yr,{data:ce,setModalData:de,setInitialScreen:F,initialScreen:U,authenticated:y,open:h,children:[n.children,ht&&/*#__PURE__*/t(qs,{delayedExecution:!1}),/*#__PURE__*/t(df,{theme:{...ie.appearance.palette||{}}}),!ie.render.standalone&&/*#__PURE__*/t(Tf,{open:h})]})}),se&&oe?/*#__PURE__*/t(Pf,{appId:n.appId,appClientId:n.clientId,clientAnalyticsId:a.clientAnalyticsId,origin:a.apiUrl,mfaMethods:f?.mfaMethods,mfaPromise:Ee,mfaSubmitPromise:Te,onLoad:ae,onLoadFailed:()=>null}):null,ie.loginConfig.telegramAuthConfiguration&&
22
+ /*#__PURE__*/t(il,{$if:!0,children:/*#__PURE__*/t(_f,{scriptHost:n.apiUrl||lr,botUsername:ie.loginConfig.telegramAuthConfiguration.botName})})]})})})})})};const pw=()=>{let{getAccessToken:e,user:t}=mr(),{refreshSessionAndUser:n,initializeWalletProxy:r}=x(),a=ma();return{importWallet:c((({privateKey:i})=>Co({getAccessToken:e,user:t,initializeWalletProxy:r,refreshSessionAndUser:n,emitPrivyEvent:a},{privateKey:i,chainType:"ethereum"})),[t,e,n,r,a])}},mw=()=>{let{importWallet:e}=pw();return{...u(Lr),importWallet:e}},yw=e=>{aa("login",e);let t=st(),n=Hr(),{ready:r,user:a}=mr(),{initLoginWithHeadlessOAuth:i,loginWithHeadlessOAuth:s,oAuthState:l,setOAuthState:d,isHeadlessOAuthLoading:h}=x(),u=c((async e=>{try{if(t.enabled&&"success"!==t.status)throw new Ye(t.error,null,A.CAPTCHA_FAILURE);return await i(e.provider,t.token,e.disableSignup)}catch(e){throw d({status:"error",error:e}),e}}),[i,t]),p=c((async()=>{let e=jo();try{if(a)return console.warn("Cannot login with OAuth when already logged in"),a;if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(e.popupFlow)return}catch(e){throw d({status:"error",error:e}),e}try{return await s(e)}catch(e){throw d({status:"error",error:e}),e}finally{Go()}}),[s]);return o((()=>{let e=jo();r&&n&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&p().catch((()=>{}))}),[r,n]),{initOAuth:u,loading:h,state:l}},gw=e=>{let t=st(),{emailOtpState:n,setEmailOtpState:r,initLoginWithEmail:a,loginWithCode:i}=x();return{sendCode:c((async({email:n,disableSignup:i})=>{try{let e;if(!n)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new Ye(t.error,null,A.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({email:n,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[a]),loginWithCode:c((async({code:n})=>{try{if(t.enabled&&"error"===t.status)throw new Ye(t.error,null,A.CAPTCHA_FAILURE);let{user:r,isNewUser:a,wasAlreadyAuthenticated:o,linkedAccount:s}=await i(n);e?.onComplete?.({user:r,isNewUser:a,wasAlreadyAuthenticated:o,loginMethod:"email",loginAccount:s})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[i,t.status]),state:n}},fw=e=>{let t=st(),{initSignupWithPasskey:n,signupWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:i}=x();return{signupWithPasskey:c((async()=>{try{let a;if(t.enabled&&"error"===t.status)throw new Ye(t.error,null,A.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult()),await n({captchaToken:a,withPrivyUi:!1});let{user:i,isNewUser:o,wasAlreadyAuthenticated:s,loginAccount:l}=await r();e?.onComplete?.({user:i,isNewUser:o,wasAlreadyAuthenticated:s,loginMethod:"passkey",loginAccount:l})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||A.UNKNOWN_AUTH_ERROR),t}}),[r,t.status]),state:a}},ww=e=>{let t=st(),{initLoginWithPasskey:n,loginWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:i}=x();return{loginWithPasskey:c((async a=>{try{let i;if(t.enabled&&"error"===t.status)throw new Ye(t.error,null,A.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await n({captchaToken:i,withPrivyUi:!1});let{user:o,isNewUser:s,wasAlreadyAuthenticated:l,loginAccount:c}=await r(a);e?.onComplete?.({user:o,isNewUser:s,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(a){throw i({status:"error",error:a}),e?.onError?.(a.privyErrorCode||A.UNKNOWN_AUTH_ERROR),a}}),[r,t.status]),state:a}},vw=e=>{let{initLinkWithPasskey:t,linkWithPasskey:n,passkeyAuthState:r,setPasskeyAuthState:a}=x();return{linkWithPasskey:c((async()=>{try{await t();let r=await n();if(!r)throw Error("Error, user not found");let a=r.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:r,linkMethod:"passkey",linkedAccount:a})}catch(t){throw a({status:"error",error:t}),e?.onError?.(t.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[n]),state:r}},Cw=e=>{let t=st(),{smsOtpState:n,setSmsOtpState:r,initLoginWithSms:a,loginWithCode:i}=x();return{sendCode:c((async({phoneNumber:n,disableSignup:i})=>{try{let e;if(!n)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new Ye(t.error,null,A.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({phoneNumber:n,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[a]),loginWithCode:c((async({code:n})=>{try{if(t.enabled&&"success"!==t.status)throw new Ye(t.error,null,A.CAPTCHA_FAILURE);let{user:r,isNewUser:a,wasAlreadyAuthenticated:o,linkedAccount:s}=await i(n);e?.onComplete?.({user:r,isNewUser:a,wasAlreadyAuthenticated:o,loginMethod:"sms",loginAccount:s})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[i,t.status]),state:n}},Ew=e=>{let t=st(),{siweState:n,setSiweState:r,linkWithSiwe:a,generateSiweMessage:i}=x();return{generateSiweMessage:c((async({address:t,chainId:n})=>{try{if(!t||!n)throw Error("wallet address and chainId required to generate nonce");return await i({address:t,chainId:n}).then((e=>e))}catch(t){throw r({status:"error",error:t}),e?.onError?.(t.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[i]),linkWithSiwe:c((async({signature:n,message:i,chainId:o,walletClientType:s,connectorType:l})=>{try{if(t.enabled&&"success"!==t.status)throw new Ye(t.error,null,A.CAPTCHA_FAILURE);let{user:r,linkedAccount:c}=await a({message:i,signature:n,chainId:o,walletClientType:s,connectorType:l});c&&e?.onSuccess?.({user:r,linkMethod:"siwe",linkedAccount:c})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),n}}),[a,t.status]),state:n}};function Tw(){let{signTransaction:e}=u(Lr);return{signTransaction:e}}function bw(e){let{linkEmail:t,linkPhone:n,linkWallet:r,linkGoogle:a,linkApple:i,linkTwitter:o,linkDiscord:s,linkGithub:l,linkLinkedIn:c,linkTiktok:d,linkSpotify:h,linkInstagram:p,linkTelegram:m,linkFarcaster:y}=u(Lr);return aa("linkAccount",e),{linkEmail:t,linkPhone:n,linkWallet:r,linkGoogle:a,linkApple:i,linkTwitter:o,linkDiscord:s,linkGithub:l,linkLinkedIn:c,linkTiktok:d,linkSpotify:h,linkInstagram:p,linkFarcaster:y,linkTelegram:m}}function Aw(e){let{updateEmail:t,updatePhone:n}=u(Lr);return aa("update",e),{updateEmail:t,updatePhone:n}}function _w(e){let{createWallet:t}=u(Lr);return aa("createWallet",e),{createWallet:t}}const kw=()=>{let{connectCoinbaseSmartWallet:e}=x();return{connectCoinbaseSmartWallet:e}},Iw=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:n,signTypedDataWithCrossAppWallet:r,sendTransactionWithCrossAppWallet:a}=mr();return{loginWithCrossAppAccount:({appId:t})=>e({appId:t,action:"login"}),linkCrossAppAccount:({appId:t})=>e({appId:t,action:"link"}),unlinkCrossAppAccount:t,signMessage:n,signTypedData:r,sendTransaction:a}};function Nw(e){let{sendTransaction:t}=u(Lr);return aa("sendTransaction",e),{sendTransaction:t}}function xw(e){let{setWalletPassword:t}=u(Lr);return aa("setWalletPassword",e),{setWalletPassword:t}}function Sw(){let{createGuestAccount:e}=u(Lr);return{createGuestAccount:e}}function Rw(e){let{setWalletRecovery:t}=u(Lr);return aa("setWalletRecovery",e),{setWalletRecovery:t}}function Ow(e){let{signMessage:t}=u(Lr);return aa("signMessage",e),{signMessage:t}}function Ww(e){let{signTypedData:t}=u(Lr);return aa("signTypedData",e),{signTypedData:t}}const Mw=()=>{let{isModalOpen:e}=u(Lr);return{isOpen:e}};function Pw(e){let{getAccessToken:t}=u(Lr);return aa("accessToken",e),{getAccessToken:t}}function Lw(e){let{authenticated:t,user:n}=mr(),{initLoginWithOAuth:r}=x(),a=ma();return aa("oAuthAuthorization",e),{reauthorize:e=>Dw(t,n,r,a,e.provider)}}let Dw=async(e,t,n,r,a)=>{if(!e)throw r("linkAccount","onError",A.MUST_BE_AUTHENTICATED,{linkMethod:a}),new T("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(a))))throw new T(`OAuth account of type ${a} not linked to the account.`);await n(a)};const Uw=e=>{let{customAuthStatus:t}=x();return aa("customAuth",e),{status:t}};function Fw(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:n}=mr();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:n}}const Bw=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=x();return{delegateWallet:async({address:e,chainType:n})=>await t({address:e,chainType:n,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},zw=()=>{let{setUser:e,client:t}=u(D),{user:n}=u(Lr);return{user:n,refreshUser:c((async()=>{let n=await(t?.updateUserAndIdToken());return e(n??null),n}),[t,e])}},Hw=e=>{let t=st(),{initLoginWithTelegram:n,loginWithTelegram:r,telegramAuthState:a,setTelegramAuthState:i}=x();return{login:c((async a=>{try{if(t.enabled&&"success"!==t.status)throw new Ye(t.error,null,A.CAPTCHA_FAILURE);await n(t.token,a?.disableSignup);let{user:i,isNewUser:o,loginAccount:s,wasAlreadyAuthenticated:l}=await r({intent:"login"});e?.onComplete?.({user:i,isNewUser:o,wasAlreadyAuthenticated:l,loginMethod:"telegram",loginAccount:s})}catch(a){throw i({status:"error",error:a}),e?.onError?.(a.privyErrorCode||A.UNKNOWN_AUTH_ERROR),a}}),[n,r,t]),state:a}},Vw=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=x();return{delegateWallet:async({address:e,chainType:n})=>await t({address:e,chainType:n,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{qs as Captcha,Ss as ConnectorManager,Ze as EthereumWalletConnector,Tf as LoginModal,js as PrivyClient,hw as PrivyProvider,Yn as VERSION,$c as errorIndicatesMaxMfaRetries,Hc as errorIndicatesMfaTimeout,Vc as errorIndicatesMfaVerificationFailed,nw as getAccessToken,kw as useConnectCoinbaseSmartWallet,_w as useCreateWallet,Iw as useCrossAppAccounts,Uw as useCustomAuth,Bw as useDelegatedActions,Fw as useFarcasterSigner,Sw as useGuestAccounts,Vw as useHeadlessDelegatedActions,Us as useIdentityToken,pw as useImportWallet,bw as useLinkAccount,vw as useLinkWithPasskey,Ew as useLinkWithSiwe,gw as useLoginWithEmail,yw as useLoginWithOAuth,ww as useLoginWithPasskey,Cw as useLoginWithSms,Hw as useLoginWithTelegram,kt as useLogout,nm as useMfa,rm as useMfaEnrollment,Mw as useModalStatus,Lw as useOAuthTokens,mw as usePrivy,Ks as useRegisterMfaListener,Nw as useSendTransaction,xw as useSetWalletPassword,Rw as useSetWalletRecovery,Ow as useSignMessage,Tw as useSignTransaction,Ww as useSignTypedData,fw as useSignupWithPasskey,ca as useSolanaWallets,Pw as useToken,Aw as useUpdateAccount,zw as useUser,_r as useWallets};