@privy-io/react-auth 1.87.0-beta-20240920172644 → 1.87.0-beta-20240920184838
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.
- package/dist/{chunk-4GRYKTVV.js → chunk-4ODVFLKF.js} +1 -1
- package/dist/{chunk-NGIQBA55.js → chunk-4RGQ4R3M.js} +3 -3
- package/dist/{chunk-LTAXBMI2.js → chunk-E7B7OFUX.js} +78 -78
- package/dist/{chunk-V5T6BXGX.js → chunk-VGM5FGSZ.js} +1 -1
- package/dist/esm/{chunk-4GRYKTVV.js → chunk-4ODVFLKF.js} +1 -1
- package/dist/esm/{chunk-NGIQBA55.js → chunk-4RGQ4R3M.js} +1 -1
- package/dist/esm/{chunk-LTAXBMI2.js → chunk-E7B7OFUX.js} +43 -43
- package/dist/esm/{chunk-V5T6BXGX.js → chunk-VGM5FGSZ.js} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/smart-wallets.js +1 -1
- package/dist/esm/solana.js +1 -1
- package/dist/esm/ui.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/smart-wallets.js +1 -1
- package/dist/solana.js +1 -1
- package/dist/ui.js +8 -8
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as bf,A as It,B as St,C as Ll,D as uf,E as mf,F as ff,G as ze,H as N,I as Ya,J as Qa,K as B,L as j,M as Rr,N as hf,O as ur,P as yf,Q as Vt,R as Wp,S as ls,T as gf,U as Cf,V as Xa,W as vf,X as Za,Y as ko,Z as Mt,_ as cs,a as rs,b as Z,c as un,d as Sl,e as Dm,f as Pl,g as Um,h as uo,i as Fm,j as Bm,k as os,l as Al,m as Hm,n as Zn,o as Vm,p as za,q as Gm,r as Qo,s as Kr,t as ns,u as qm,v as Be,w as Mp,x as oa,y as Ml,z as Wl}from"./chunk-NGIQBA55.js";import{a as df,b as x,d as Ul,e as Fl}from"./chunk-4GRYKTVV.js";import{$ as Yr,A as kp,B as Rl,C as as,D as is,E as _l,F as ss,G as jn,H as $n,I as ea,J as ta,K as Il,L as Rp,M as _p,N as ra,O as Xo,P as Ip,Q as Ka,R as Xm,S as Zm,T as Jm,U as jm,V as $m,W as Ht,X as mo,Y as ef,Z as Nl,_ as tf,a as Wm,aa as rf,b as Tl,ba as Ol,c as Sp,ca as of,d as Lm,da as Qr,e as pr,ea as xo,f as xr,fa as nf,g as C,ga as Xr,h as Nm,ha as af,i as Le,ia as sf,j as de,ja as lf,k as qe,l as Xn,m as kr,n as Om,na as cf,o as Ao,oa as _e,p as xl,pa as Dl,q as zm,qa as pf,r as Oe,ra as R,s as Km,sa as De,t as Ym,ta as z,u as Pp,ua as wf,v as Jn,va as Zo,w as Ap,x as kl,y as Qm,z as xp}from"./chunk-V5T6BXGX.js";import{getAddress as Ha}from"@ethersproject/address";import{Web3Provider as Am}from"@ethersproject/providers";import{createStore as JA}from"mipd";import{useEffect as co,useMemo as jA,useRef as Va,useState as ut}from"react";import{isAndroid as $A}from"react-device-detect";import{ProviderErrors as ex,calculateTotalGasEstimate as tx,populateTransactionRequest as rx}from"@privy-io/js-sdk-core";var Bl="/api/v1/sessions",Hl="/api/v1/sessions/logout",Ef="/api/v1/sessions/fork",Vl="/api/v1/sessions/fork/recover",Tf="/api/v1/siwe/init",Sf="/api/v1/siwe/authenticate",Pf="/api/v1/siwe/link",Af="/api/v1/siwe/link_smart_wallet",xf="/api/v1/siwe/unlink",kf="/api/v1/siwe/transfer",Rf="/api/v1/siws/init",_f="/api/v1/siws/authenticate",If="/api/v1/siws/link",Mf="/api/v1/siws/unlink",Wf="/api/v1/farcaster/init",Lf="/api/v1/farcaster/authenticate",Nf="/api/v1/farcaster/link",Of="/api/v1/farcaster/status",Df="/api/v1/farcaster/unlink",Uf="/api/v1/farcaster/transfer",Ff="/api/v1/passwordless/init",Bf="/api/v1/passwordless/authenticate",Hf="/api/v1/passwordless/link",Vf="/api/v1/passwordless/unlink",Gf="/api/v1/passwordless/update",qf="/api/v1/passwordless/transfer",zf="/api/v1/passwordless_sms/init",Kf="/api/v1/passwordless_sms/link",Yf="/api/v1/passwordless_sms/unlink",Qf="/api/v1/passwordless_sms/authenticate",Xf="/api/v1/passwordless_sms/update",Zf="/api/v1/passwordless_sms/transfer",Gl="/api/v1/oauth/init",ql="/api/v1/oauth/authenticate",zl="/api/v1/oauth/link",Jf="/api/v1/oauth/unlink",jf="/api/v1/oauth/transfer",$f="/api/v1/recovery/oauth/init",eh="/api/v1/recovery/oauth/init_icloud",th="/api/v1/recovery/oauth/authenticate",rh="/api/v1/passkeys/link/init",oh="/api/v1/passkeys/authenticate/init",nh="/api/v1/passkeys/link",ah="/api/v1/passkeys/authenticate",ih="/api/v1/passkeys/unlink",sh="/api/v1/telegram/authenticate",lh="/api/v1/telegram/link",ch="/api/v1/telegram/unlink",dh="/api/v1/telegram/transfer";var ph="/api/v1/mfa/passwordless_sms/init",uh="/api/v1/mfa/passkeys/init",mh="/api/v1/users/me/accept_terms",Kl="/api/v1/analytics_events",fh="/api/v1/custom_jwt_account/authenticate",hh="/api/v1/guest/authenticate",yh="/api/v1/plugins/moonpay_on_ramp/sign",gh="/api/v1/funding/coinbase_on_ramp/init",Ch="/api/v1/funding/coinbase_on_ramp/status";var Ja=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=await this.api.post(fh,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){throw new Error("Unimplemented")}};var mn=class{constructor(t,r,o=!1){this.meta={email:t,captchaToken:r,disableSignup:o}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Bf,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Hf,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw de(t)}}async sendCodeEmail(t,r){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new C("Email must be set when initialzing authentication.");try{return await this.api.post(Ff,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw de(o)}}},Yl=class extends mn{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r,disableSignup:!1}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new C("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(Gf,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw de(r)}}};import{isMobile as v0,isIOS as w0}from"react-device-detect";var Ql=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(Xl))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var Xl={metamask:{id:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",displayName:"MetaMask",hostname:"metamask.io",mobile:{native:"metamask://",universal:"https://metamask.app.link"}},trust:{id:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",displayName:"Trust",hostname:"trustwallet.com",mobile:{universal:"https://link.trustwallet.com"}},safe:{id:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",displayName:"Safe",hostname:"safe.global",mobile:{universal:"https://app.safe.global/"}},rainbow:{id:"1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",displayName:"Rainbow",hostname:"rainbow.me",mobile:{native:"rainbow://",universal:"https://rnbwapp.com"}},uniswap:{id:"c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a",displayName:"Uniswap",hostname:"uniswap.org",mobile:{universal:"https://uniswap.org/app",native:"uniswap://"}},zerion:{id:"ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18",displayName:"Zerion",hostname:"zerion.io",mobile:{native:"zerion://",universal:"https://wallet.zerion.io"}},argent:{id:"bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6",displayName:"Argent",hostname:"www.argent.xyz",mobile:{universal:"https://www.argent.xyz/app"}},spot:{id:"74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d",displayName:"Spot",hostname:"www.spot-wallet.com",mobile:{universal:"https://spot.so"}},omni:{id:"afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7",displayName:"Omni",hostname:"omni.app",mobile:{universal:"https://links.omni.app"}},cryptocom:{id:"f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d",displayName:"Crypto.com",hostname:"crypto.com",mobile:{universal:"https://wallet.crypto.com",native:"dfw://"}},blockchain:{id:"84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04",displayName:"Blockchain",hostname:"www.blockchain.com",mobile:{universal:"https://www.blockchain.com"}},safepal:{id:"0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150",displayName:"SafePal",hostname:"safepal.com",mobile:{universal:"https://link.safepal.io"}},bitkeep:{id:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",displayName:"BitKeep",hostname:"bitkeep.com",mobile:{universal:"https://bkapp.vip"}},zengo:{id:"9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0",displayName:"ZenGo",hostname:"zengo.com",mobile:{universal:"https://get.zengo.com/"}},"1inch":{id:"c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576",displayName:"1inch",hostname:"wallet.1inch.io",mobile:{universal:"https://wallet.1inch.io/wc/"}},binance:{id:"8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4",displayName:"Binance",hostname:"www.binance.com",mobile:{universal:"https://app.binance.com/cedefi"}},exodus:{id:"e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4",displayName:"Exodus",hostname:"exodus.com",mobile:{universal:"https://exodus.com/m"}},mew_wallet:{id:"f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2",displayName:"MEW wallet",hostname:"mewwallet.com",mobile:{universal:"https://mewwallet.com"}},alphawallet:{id:"138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98",displayName:"AlphaWallet",hostname:"alphawallet.com",mobile:{universal:"https://aw.app"}},keyring_pro:{id:"47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83",displayName:"KEYRING PRO",hostname:"keyring.app",mobile:{universal:"https://keyring.app/"}},mathwallet:{id:"7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26",displayName:"MathWallet",hostname:"mathwallet.org",mobile:{universal:"https://www.mathwallet.org"}},unstoppable:{id:"8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3",displayName:"Unstoppable",hostname:"unstoppabledomains.com",mobile:{universal:"https://unstoppabledomains.com/mobile"}},obvious:{id:"031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa",displayName:"Obvious",hostname:"obvious.technology",mobile:{universal:"https://wallet.obvious.technology"}},ambire:{id:"2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568",displayName:"Ambire",hostname:"www.ambire.com",mobile:{universal:"https://mobile.ambire.com"}},internet_money_wallet:{id:"dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd",displayName:"Internet Money Wallet",hostname:"internetmoney.io",mobile:{universal:"https://internetmoney.io"}},coin98:{id:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",displayName:"Coin98",hostname:"coin98.com",mobile:{universal:"https://coin98.services"}},abc_wallet:{id:"b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f",displayName:"ABC Wallet",hostname:"myabcwallet.io",mobile:{universal:"https://abcwalletconnect.page.link"}},arculus_wallet:{id:"0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92",displayName:"Arculus Wallet",hostname:"www.getarculus.com",mobile:{universal:"https://gw.arculus.co/app"}},haha:{id:"719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3",displayName:"HaHa",hostname:"www.haha.me",mobile:{universal:"https://haha.me"}},cling_wallet:{id:"942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef",displayName:"Cling Wallet",hostname:"clingon.io",mobile:{universal:"https://cling.carrieverse.com/apple-app-site-association"}},broearn:{id:"8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2",displayName:"Broearn",hostname:"www.broearn.com",mobile:{universal:"https://www.broearn.com/link/wallet/"}},copiosa:{id:"07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80",displayName:"Copiosa",hostname:"copiosa.io",mobile:{universal:"https://copiosa.io/action/"}},burrito_wallet:{id:"8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819",displayName:"Burrito Wallet",hostname:"burritowallet.com",mobile:{universal:"https://burritowallet.com/wc?uri="}},enjin_wallet:{id:"bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a",displayName:"Enjin Wallet",hostname:"enjin.io",mobile:{universal:"https://deeplink.wallet.enjin.io/"}},plasma_wallet:{id:"cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e",displayName:"Plasma Wallet",hostname:"plasma-wallet.com",mobile:{universal:"https://plasma-wallet.com"}},avacus:{id:"94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43",displayName:"Avacus",hostname:"avacus.cc",mobile:{universal:"https://avacus.app.link"}},bee:{id:"2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715",displayName:"Bee",hostname:"www.beewallet.app",mobile:{universal:"https://beewallet.app/wc"}},pitaka:{id:"14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc",displayName:"Pitaka",hostname:"pitaka.io",mobile:{universal:"https://app.pitaka.io"}},pltwallet:{id:"576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd",displayName:"PLTwallet",hostname:"pltwallet.io",mobile:{universal:"https://pltwallet.io/"}},minerva:{id:"49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd",displayName:"Minerva",hostname:"minerva.digital",mobile:{universal:"https://minerva.digital"}},kryptogo:{id:"19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b",displayName:"KryptoGO",hostname:"kryptogo.com",mobile:{universal:"https://kryptogo.page.link"}},prema:{id:"5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b",displayName:"PREMA",hostname:"premanft.com",mobile:{universal:"https://premanft.com"}},slingshot:{id:"d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b",displayName:"Slingshot",hostname:"slingshot.finance",mobile:{universal:"https://app.slingshot.finance"}},kriptonio:{id:"50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b",displayName:"Kriptonio",hostname:"kriptonio.com",mobile:{universal:"https://app.kriptonio.com/mobile"}},timeless:{id:"9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8",displayName:"Timeless",hostname:"timelesswallet.xyz",mobile:{universal:"https://timelesswallet.xyz"}},secux:{id:"6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa",displayName:"SecuX",hostname:"secuxtech.com",mobile:{universal:"https://wsweb.secuxtech.com"}},bitizen:{id:"41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071",displayName:"Bitizen",hostname:"bitizen.org",mobile:{universal:"https://bitizen.org/wallet"}},blocto:{id:"14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd",displayName:"Blocto",hostname:"blocto.io",mobile:{universal:"https://blocto.app"}},safemoon:{id:"a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1",displayName:"SafeMoon",hostname:"safemoon.com",mobile:{universal:"https://safemoon.com/wc"}},okx_wallet:{id:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",displayName:"OKX Wallet",hostname:"okx.com",mobile:{native:"okex://main"}},rabby_wallet:{id:"18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1",displayName:"Rabby Wallet",hostname:"rabby.io",mobile:{}}};function vh(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function wh(e,t){let r=vh(t);if(r.deepLink)return Ah(r.deepLink,e);if(r.universalLink)return Lp(r.universalLink,e);throw new C(`Unsupported wallet ${t.id}`)}function bh(e,t){let r=vh(t);if(r.universalLink)return Lp(r.universalLink,e)}var Eh="WALLETCONNECT_DEEPLINK_CHOICE";function Th(){try{localStorage.removeItem(Eh)}catch{}}function Sh({href:e,name:t}){try{localStorage.setItem(Eh,JSON.stringify({href:e,name:t}))}catch{}}function Ph(e){return e.startsWith("http://")||e.startsWith("https://")}function Ah(e,t){if(Ph(e))return Lp(e,t);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function Lp(e,t){if(!Ph(e))return Ah(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function Zl(e,t){window.open(e,t,"noreferrer noopener")}var Ke=class{constructor(t){this.promise=null;this.fn=t}execute(t){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(t)}finally{this.promise=null}})()),this.promise}};var ds=class{constructor(t,r=!1){this._meta={disableSignup:!1};this.captchaToken=t,this.startChannelOnce=new Ke(this._startChannelOnce.bind(this)),this.pollForReady=new Ke(this._pollForReady.bind(this)),this._meta.disableSignup=r}get meta(){return this._meta}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.channelToken)throw new C("Auth flow must be initialized first");try{let t=await this.api.post(Lf,{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(!t)throw new C("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");try{return await this.api.post(Nf,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw de(t)}}async _startChannelOnce(){if(!this.api)throw new C("Auth flow has no API instance");let t=await this.api.post(Wf,{token:this.captchaToken});v0&&!w0&&t.connect_uri&&Zl(t.connect_uri,"_blank"),this._meta={...this._meta,connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new C("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.channelToken)throw new C("Auth flow must be initialized first");let t=await this.api.get(Of,{headers:{"farcaster-channel-token":this.meta.channelToken}});return t.state==="completed"?(this.message=t.message,this.signature=t.signature,this.fid=t.fid,!0):!1}};import{base64url as kh}from"jose";async function xh(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function ps(e){return crypto.getRandomValues(new Uint8Array(e))}var ja=class{constructor(t){this.meta={guestCredential:this.getOrCreateGuestCredential(t)}}getOrCreateGuestCredential(t){let r=_l(t);if(rs()){if(Z.get(r))return Z.get(r);{let o=kh.encode(ps(32));return Z.put(r,o),o}}return kh.encode(ps(32))}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=await this.api.post(hh,{guest_credential:this.meta.guestCredential});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){throw new Error("Linking is not supported for the guest flow")}};import{base64url as Rh}from"jose";var b0="S256",E0="S256";function na(){return Rh.encode(ps(36))}function $a(){return na()}async function ei(e,t=b0){if(t==E0){let r=await xh(e);return Rh.encode(r)}else return e}function _h(){let e=Z.get($n);if(!e)throw new C("Authentication error.");return e}function Jl(){return!!Z.get(ea)}function Ih(){return!!Z.get(ta)}var Ro=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:Jl();this.meta={...t,headless:r}}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=_h();try{let r=await this.api.post(ql,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Z.del($n),Z.del(ea),Z.del(ta),{user:r.user,token:r.token,refresh_token:r.refresh_token,identity_token:r.identity_token,is_new_user:r.is_new_user,oauth_tokens:r.oauth_tokens}}catch(r){let o=de(r);throw o.privyErrorCode?new C(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new C("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new C("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=Z.get($n);if(!t)throw new C("Authentication error.");try{let r=await this.api.post(zl,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Z.del($n),r}catch(r){throw de(r)}}async getAuthorizationUrl(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.provider)throw new C("Provider must be set when initializing OAuth authentication.");let t=na();Z.put($n,t);let r=$a();Z.put(jn,r);let o=await ei(t);this.meta.headless&&Z.put(ea,!0),this.meta.disableSignup&&Z.put(ta,!0);try{return await this.api.post(Gl,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw de(n)}}};function us(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{jsx as Mh,jsxs as T0}from"react/jsx-runtime";var jl=({style:e,...t})=>T0("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...e},...t,children:[Mh("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"}),Mh("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"})]});import{jsx as ms,jsxs as S0}from"react/jsx-runtime";var $l=({style:e,...t})=>S0("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...e},...t,children:[ms("g",{clipPath:"url(#clip0)",children:ms("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"})}),ms("defs",{children:ms("clipPath",{id:"clip0",children:ms("rect",{width:"71",height:"55",fill:"white"})})})]});import{jsx as Wh}from"react/jsx-runtime";var ec=({style:e,...t})=>Wh("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...t,children:Wh("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"})});import P0 from"@heroicons/react/24/outline/GlobeAltIcon";import{jsx as A0}from"react/jsx-runtime";var Lh=({style:e})=>A0(P0,{style:{color:"var(--privy-color-error)",...e}});import{jsx as tc,jsxs as x0}from"react/jsx-runtime";var rc=({style:e,...t})=>x0("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...e},...t,children:[tc("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"}),tc("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"}),tc("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"}),tc("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"})]});import{jsx as Zr,jsxs as oc}from"react/jsx-runtime";function nc(e){return oc("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",...e,children:[oc("defs",{children:[oc("linearGradient",{id:"b",children:[Zr("stop",{offset:"0",stopColor:"#3771c8"}),Zr("stop",{stopColor:"#3771c8",offset:".128"}),Zr("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),oc("linearGradient",{id:"a",children:[Zr("stop",{offset:"0",stopColor:"#fd5"}),Zr("stop",{offset:".1",stopColor:"#fd5"}),Zr("stop",{offset:".5",stopColor:"#ff543e"}),Zr("stop",{offset:"1",stopColor:"#c837ab"})]}),Zr("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"}),Zr("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"})]}),Zr("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)"}),Zr("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)"}),Zr("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"})]})}import{jsx as ac}from"react/jsx-runtime";function ic({style:e,...t}){return ac("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},...t,children:ac("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:ac("g",{transform:"scale(5.12,5.12)",children:ac("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"})})})})}import{jsx as Nh,jsxs as k0}from"react/jsx-runtime";function sc(e){return k0("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...e,children:[Nh("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"}),Nh("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"})]})}import{jsx as Np,jsxs as R0}from"react/jsx-runtime";function lc(e){return R0("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,...e,children:[Np("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"}),Np("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"}),Np("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"})]})}import{jsx as Oh}from"react/jsx-runtime";var cc=({style:e,...t})=>Oh("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},...t,children:Oh("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"})});var Dh={google:{name:"Google",component:rc},discord:{name:"Discord",component:$l},github:{name:"Github",component:ec},linkedin:{name:"LinkedIn",component:ic},twitter:{name:"Twitter",component:cc},spotify:{name:"Spotify",component:sc},instagram:{name:"Instagram",component:nc},tiktok:{name:"Tiktok",component:lc},apple:{name:"Apple",component:jl}},fs=e=>e in Dh?Dh[e]:{name:"Unknown",component:Lh};function Uh(e,t){let r={detail:"",retryable:!1},o=us(t);if(e?.privyErrorCode==="linked_to_another_user"&&(r.detail="This account has already been linked to another user."),e?.privyErrorCode==="invalid_credentials"&&(r.retryable=!0,r.detail="Something went wrong. Try again."),e.privyErrorCode==="oauth_user_denied"&&(r.detail=`Retry and check ${o} to finish connecting your account.`,r.retryable=!0),e?.privyErrorCode==="too_many_requests"&&(r.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="too_many_requests"&&e.message.includes("provider rate limit")){let n=fs(t).name;r.detail=`Request limit reached for ${n}. Please wait a moment and try again.`}if(e?.privyErrorCode==="oauth_account_suspended"){let n=fs(t).name;r.detail=`Your ${n} account is suspended. Please try another login method.`}return e?.privyErrorCode==="cannot_link_more_of_type"&&(r.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode==="oauth_unexpected"&&t.startsWith("privy:")&&(r.detail="Something went wrong. Please try again."),r}function hs(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),o=e.get("privy_oauth_provider");if(!t||!r||!o)return{inProgress:!1};let n=!1;try{n=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:Jl(),popupFlow:window.opener!==null&&n,disableSignup:Ih()}}function aa(){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"),Z.del(jn),window.history.replaceState({},"",e)}var ia=class{constructor(t,r){this.initAuthenticateOnce=new Ke(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Ke(this._initLinkOnce.bind(this)),this.meta={captchaToken:t,setPasskeyAuthState:r}}async initAuthenticationFlow(){if(!this.api)throw new C("Auth flow has no API instance");this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute()}async initLinkFlow(){if(!this.api)throw new C("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async authenticate(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new C("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new C("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());try{let r=await t.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase(this.meta.initAuthenticateResponse.options));this.meta.setPasskeyAuthState?.({status:"submitting-response"});let o=await this.api.post(ah,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(r){throw r.name==="NotAllowedError"?new C("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):de(r)}}async link(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new C("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new C("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let r=this.meta.initLinkResponse.options,o=await t.startRegistration(this._transformInitLinkOptionsToCamelCase(r));return await this.api.post(nh,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(o)})}catch(r){throw r.name==="NotAllowedError"?new C("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):de(r)}}async _initAuthenticateOnce(){if(!this.api)throw new C("Auth flow has no API instance");return await this.api.post(oh,{token:this.meta.captchaToken})}async _initLinkOnce(){if(!this.api)throw new C("Auth flow has no API instance");return await this.api.post(rh,{})}_transformInitLinkOptionsToCamelCase(t){return{rp:t.rp,user:{id:t.user.id,name:t.user.name,displayName:t.user.display_name},challenge:t.challenge,pubKeyCredParams:t.pub_key_cred_params.map(r=>({type:r.type,alg:r.alg})),timeout:t.timeout,excludeCredentials:t.exclude_credentials?.map(r=>({id:r.id,type:r.type,transports:r.transports})),authenticatorSelection:{authenticatorAttachment:t.authenticator_selection?.authenticator_attachment,requireResidentKey:t.authenticator_selection?.require_resident_key,residentKey:t.authenticator_selection?.resident_key,userVerification:t.authenticator_selection?.user_verification},attestation:t.attestation,extensions:{appid:t.extensions?.app_id,credProps:t.extensions?.cred_props?.rk,hmacCreateSecret:t.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(t){return{id:t.id,raw_id:t.rawId,response:{client_data_json:t.response.clientDataJSON,attestation_object:t.response.attestationObject,authenticator_data:t.response.authenticatorData},authenticator_attachment:t.authenticatorAttachment,client_extension_results:{app_id:t.clientExtensionResults.appid,cred_props:t.clientExtensionResults.credProps,hmac_create_secret:t.clientExtensionResults.hmacCreateSecret},type:t.type}}_transformInitAuthenticateOptionsToCamelCase(t){return{challenge:t.challenge,allowCredentials:t.allow_credentials?.map(r=>({id:r.id,type:r.type,transports:r.transports}))||[],timeout:t.timeout,extensions:{appid:t.extensions?.app_id,credProps:t.extensions?.cred_props,hmacCreateSecret:t.extensions?.hmac_create_secret},userVerification:t.user_verification}}_transformAuthenticationResponseToSnakeCase(t){return{id:t.id,raw_id:t.rawId,response:{client_data_json:t.response.clientDataJSON,authenticator_data:t.response.authenticatorData,signature:t.response.signature,user_handle:t.response.userHandle},authenticator_attachment:t.authenticatorAttachment,client_extension_results:{app_id:t.clientExtensionResults.appid,cred_props:t.clientExtensionResults.credProps,hmac_create_secret:t.clientExtensionResults.hmacCreateSecret},type:t.type}}};var dc=({address:e,chainId:t,nonce:r})=>{let o=window.location.host,n=window.location.origin,a="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",i=new Date().toISOString();return`${o} wants you to sign in with your Ethereum account:
|
|
1
|
+
import{$ as bf,A as It,B as St,C as Ll,D as uf,E as mf,F as ff,G as ze,H as N,I as Ya,J as Qa,K as V,L as j,M as Rr,N as hf,O as ur,P as yf,Q as Vt,R as Wp,S as ls,T as gf,U as Cf,V as Xa,W as vf,X as Za,Y as ko,Z as Mt,_ as cs,a as rs,b as Z,c as un,d as Sl,e as Dm,f as Pl,g as Um,h as uo,i as Fm,j as Bm,k as os,l as Al,m as Hm,n as Zn,o as Vm,p as za,q as Gm,r as Qo,s as Kr,t as ns,u as qm,v as Be,w as Mp,x as oa,y as Ml,z as Wl}from"./chunk-4RGQ4R3M.js";import{a as df,b as x,d as Ul,e as Fl}from"./chunk-4ODVFLKF.js";import{$ as Yr,A as kp,B as Rl,C as as,D as is,E as _l,F as ss,G as jn,H as $n,I as ea,J as ta,K as Il,L as Rp,M as _p,N as ra,O as Xo,P as Ip,Q as Ka,R as Xm,S as Zm,T as Jm,U as jm,V as $m,W as Ht,X as mo,Y as ef,Z as Nl,_ as tf,a as Wm,aa as rf,b as Tl,ba as Ol,c as Sp,ca as of,d as Lm,da as Qr,e as pr,ea as xo,f as xr,fa as nf,g as C,ga as Xr,h as Nm,ha as af,i as Le,ia as sf,j as de,ja as lf,k as qe,l as Xn,m as kr,n as Om,na as cf,o as Ao,oa as _e,p as xl,pa as Dl,q as zm,qa as pf,r as Oe,ra as R,s as Km,sa as De,t as Ym,ta as z,u as Pp,ua as wf,v as Jn,va as Zo,w as Ap,x as kl,y as Qm,z as xp}from"./chunk-VGM5FGSZ.js";import{getAddress as Ha}from"@ethersproject/address";import{Web3Provider as Am}from"@ethersproject/providers";import{createStore as JA}from"mipd";import{useEffect as co,useMemo as jA,useRef as Va,useState as ut}from"react";import{isAndroid as $A}from"react-device-detect";import{ProviderErrors as ex,calculateTotalGasEstimate as tx,populateTransactionRequest as rx}from"@privy-io/js-sdk-core";var Bl="/api/v1/sessions",Hl="/api/v1/sessions/logout",Ef="/api/v1/sessions/fork",Vl="/api/v1/sessions/fork/recover",Tf="/api/v1/siwe/init",Sf="/api/v1/siwe/authenticate",Pf="/api/v1/siwe/link",Af="/api/v1/siwe/link_smart_wallet",xf="/api/v1/siwe/unlink",kf="/api/v1/siwe/transfer",Rf="/api/v1/siws/init",_f="/api/v1/siws/authenticate",If="/api/v1/siws/link",Mf="/api/v1/siws/unlink",Wf="/api/v1/farcaster/init",Lf="/api/v1/farcaster/authenticate",Nf="/api/v1/farcaster/link",Of="/api/v1/farcaster/status",Df="/api/v1/farcaster/unlink",Uf="/api/v1/farcaster/transfer",Ff="/api/v1/passwordless/init",Bf="/api/v1/passwordless/authenticate",Hf="/api/v1/passwordless/link",Vf="/api/v1/passwordless/unlink",Gf="/api/v1/passwordless/update",qf="/api/v1/passwordless/transfer",zf="/api/v1/passwordless_sms/init",Kf="/api/v1/passwordless_sms/link",Yf="/api/v1/passwordless_sms/unlink",Qf="/api/v1/passwordless_sms/authenticate",Xf="/api/v1/passwordless_sms/update",Zf="/api/v1/passwordless_sms/transfer",Gl="/api/v1/oauth/init",ql="/api/v1/oauth/authenticate",zl="/api/v1/oauth/link",Jf="/api/v1/oauth/unlink",jf="/api/v1/oauth/transfer",$f="/api/v1/recovery/oauth/init",eh="/api/v1/recovery/oauth/init_icloud",th="/api/v1/recovery/oauth/authenticate",rh="/api/v1/passkeys/link/init",oh="/api/v1/passkeys/authenticate/init",nh="/api/v1/passkeys/link",ah="/api/v1/passkeys/authenticate",ih="/api/v1/passkeys/unlink",sh="/api/v1/telegram/authenticate",lh="/api/v1/telegram/link",ch="/api/v1/telegram/unlink",dh="/api/v1/telegram/transfer";var ph="/api/v1/mfa/passwordless_sms/init",uh="/api/v1/mfa/passkeys/init",mh="/api/v1/users/me/accept_terms",Kl="/api/v1/analytics_events",fh="/api/v1/custom_jwt_account/authenticate",hh="/api/v1/guest/authenticate",yh="/api/v1/plugins/moonpay_on_ramp/sign",gh="/api/v1/funding/coinbase_on_ramp/init",Ch="/api/v1/funding/coinbase_on_ramp/status";var Ja=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=await this.api.post(fh,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){throw new Error("Unimplemented")}};var mn=class{constructor(t,r,o=!1){this.meta={email:t,captchaToken:r,disableSignup:o}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Bf,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Hf,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw de(t)}}async sendCodeEmail(t,r){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new C("Email must be set when initialzing authentication.");try{return await this.api.post(Ff,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw de(o)}}},Yl=class extends mn{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r,disableSignup:!1}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new C("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(Gf,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw de(r)}}};import{isMobile as v0,isIOS as w0}from"react-device-detect";var Ql=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(Xl))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var Xl={metamask:{id:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",displayName:"MetaMask",hostname:"metamask.io",mobile:{native:"metamask://",universal:"https://metamask.app.link"}},trust:{id:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",displayName:"Trust",hostname:"trustwallet.com",mobile:{universal:"https://link.trustwallet.com"}},safe:{id:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",displayName:"Safe",hostname:"safe.global",mobile:{universal:"https://app.safe.global/"}},rainbow:{id:"1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",displayName:"Rainbow",hostname:"rainbow.me",mobile:{native:"rainbow://",universal:"https://rnbwapp.com"}},uniswap:{id:"c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a",displayName:"Uniswap",hostname:"uniswap.org",mobile:{universal:"https://uniswap.org/app",native:"uniswap://"}},zerion:{id:"ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18",displayName:"Zerion",hostname:"zerion.io",mobile:{native:"zerion://",universal:"https://wallet.zerion.io"}},argent:{id:"bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6",displayName:"Argent",hostname:"www.argent.xyz",mobile:{universal:"https://www.argent.xyz/app"}},spot:{id:"74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d",displayName:"Spot",hostname:"www.spot-wallet.com",mobile:{universal:"https://spot.so"}},omni:{id:"afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7",displayName:"Omni",hostname:"omni.app",mobile:{universal:"https://links.omni.app"}},cryptocom:{id:"f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d",displayName:"Crypto.com",hostname:"crypto.com",mobile:{universal:"https://wallet.crypto.com",native:"dfw://"}},blockchain:{id:"84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04",displayName:"Blockchain",hostname:"www.blockchain.com",mobile:{universal:"https://www.blockchain.com"}},safepal:{id:"0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150",displayName:"SafePal",hostname:"safepal.com",mobile:{universal:"https://link.safepal.io"}},bitkeep:{id:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",displayName:"BitKeep",hostname:"bitkeep.com",mobile:{universal:"https://bkapp.vip"}},zengo:{id:"9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0",displayName:"ZenGo",hostname:"zengo.com",mobile:{universal:"https://get.zengo.com/"}},"1inch":{id:"c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576",displayName:"1inch",hostname:"wallet.1inch.io",mobile:{universal:"https://wallet.1inch.io/wc/"}},binance:{id:"8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4",displayName:"Binance",hostname:"www.binance.com",mobile:{universal:"https://app.binance.com/cedefi"}},exodus:{id:"e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4",displayName:"Exodus",hostname:"exodus.com",mobile:{universal:"https://exodus.com/m"}},mew_wallet:{id:"f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2",displayName:"MEW wallet",hostname:"mewwallet.com",mobile:{universal:"https://mewwallet.com"}},alphawallet:{id:"138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98",displayName:"AlphaWallet",hostname:"alphawallet.com",mobile:{universal:"https://aw.app"}},keyring_pro:{id:"47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83",displayName:"KEYRING PRO",hostname:"keyring.app",mobile:{universal:"https://keyring.app/"}},mathwallet:{id:"7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26",displayName:"MathWallet",hostname:"mathwallet.org",mobile:{universal:"https://www.mathwallet.org"}},unstoppable:{id:"8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3",displayName:"Unstoppable",hostname:"unstoppabledomains.com",mobile:{universal:"https://unstoppabledomains.com/mobile"}},obvious:{id:"031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa",displayName:"Obvious",hostname:"obvious.technology",mobile:{universal:"https://wallet.obvious.technology"}},ambire:{id:"2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568",displayName:"Ambire",hostname:"www.ambire.com",mobile:{universal:"https://mobile.ambire.com"}},internet_money_wallet:{id:"dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd",displayName:"Internet Money Wallet",hostname:"internetmoney.io",mobile:{universal:"https://internetmoney.io"}},coin98:{id:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",displayName:"Coin98",hostname:"coin98.com",mobile:{universal:"https://coin98.services"}},abc_wallet:{id:"b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f",displayName:"ABC Wallet",hostname:"myabcwallet.io",mobile:{universal:"https://abcwalletconnect.page.link"}},arculus_wallet:{id:"0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92",displayName:"Arculus Wallet",hostname:"www.getarculus.com",mobile:{universal:"https://gw.arculus.co/app"}},haha:{id:"719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3",displayName:"HaHa",hostname:"www.haha.me",mobile:{universal:"https://haha.me"}},cling_wallet:{id:"942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef",displayName:"Cling Wallet",hostname:"clingon.io",mobile:{universal:"https://cling.carrieverse.com/apple-app-site-association"}},broearn:{id:"8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2",displayName:"Broearn",hostname:"www.broearn.com",mobile:{universal:"https://www.broearn.com/link/wallet/"}},copiosa:{id:"07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80",displayName:"Copiosa",hostname:"copiosa.io",mobile:{universal:"https://copiosa.io/action/"}},burrito_wallet:{id:"8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819",displayName:"Burrito Wallet",hostname:"burritowallet.com",mobile:{universal:"https://burritowallet.com/wc?uri="}},enjin_wallet:{id:"bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a",displayName:"Enjin Wallet",hostname:"enjin.io",mobile:{universal:"https://deeplink.wallet.enjin.io/"}},plasma_wallet:{id:"cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e",displayName:"Plasma Wallet",hostname:"plasma-wallet.com",mobile:{universal:"https://plasma-wallet.com"}},avacus:{id:"94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43",displayName:"Avacus",hostname:"avacus.cc",mobile:{universal:"https://avacus.app.link"}},bee:{id:"2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715",displayName:"Bee",hostname:"www.beewallet.app",mobile:{universal:"https://beewallet.app/wc"}},pitaka:{id:"14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc",displayName:"Pitaka",hostname:"pitaka.io",mobile:{universal:"https://app.pitaka.io"}},pltwallet:{id:"576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd",displayName:"PLTwallet",hostname:"pltwallet.io",mobile:{universal:"https://pltwallet.io/"}},minerva:{id:"49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd",displayName:"Minerva",hostname:"minerva.digital",mobile:{universal:"https://minerva.digital"}},kryptogo:{id:"19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b",displayName:"KryptoGO",hostname:"kryptogo.com",mobile:{universal:"https://kryptogo.page.link"}},prema:{id:"5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b",displayName:"PREMA",hostname:"premanft.com",mobile:{universal:"https://premanft.com"}},slingshot:{id:"d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b",displayName:"Slingshot",hostname:"slingshot.finance",mobile:{universal:"https://app.slingshot.finance"}},kriptonio:{id:"50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b",displayName:"Kriptonio",hostname:"kriptonio.com",mobile:{universal:"https://app.kriptonio.com/mobile"}},timeless:{id:"9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8",displayName:"Timeless",hostname:"timelesswallet.xyz",mobile:{universal:"https://timelesswallet.xyz"}},secux:{id:"6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa",displayName:"SecuX",hostname:"secuxtech.com",mobile:{universal:"https://wsweb.secuxtech.com"}},bitizen:{id:"41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071",displayName:"Bitizen",hostname:"bitizen.org",mobile:{universal:"https://bitizen.org/wallet"}},blocto:{id:"14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd",displayName:"Blocto",hostname:"blocto.io",mobile:{universal:"https://blocto.app"}},safemoon:{id:"a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1",displayName:"SafeMoon",hostname:"safemoon.com",mobile:{universal:"https://safemoon.com/wc"}},okx_wallet:{id:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",displayName:"OKX Wallet",hostname:"okx.com",mobile:{native:"okex://main"}},rabby_wallet:{id:"18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1",displayName:"Rabby Wallet",hostname:"rabby.io",mobile:{}}};function vh(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function wh(e,t){let r=vh(t);if(r.deepLink)return Ah(r.deepLink,e);if(r.universalLink)return Lp(r.universalLink,e);throw new C(`Unsupported wallet ${t.id}`)}function bh(e,t){let r=vh(t);if(r.universalLink)return Lp(r.universalLink,e)}var Eh="WALLETCONNECT_DEEPLINK_CHOICE";function Th(){try{localStorage.removeItem(Eh)}catch{}}function Sh({href:e,name:t}){try{localStorage.setItem(Eh,JSON.stringify({href:e,name:t}))}catch{}}function Ph(e){return e.startsWith("http://")||e.startsWith("https://")}function Ah(e,t){if(Ph(e))return Lp(e,t);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function Lp(e,t){if(!Ph(e))return Ah(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function Zl(e,t){window.open(e,t,"noreferrer noopener")}var Ke=class{constructor(t){this.promise=null;this.fn=t}execute(t){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(t)}finally{this.promise=null}})()),this.promise}};var ds=class{constructor(t,r=!1){this._meta={disableSignup:!1};this.captchaToken=t,this.startChannelOnce=new Ke(this._startChannelOnce.bind(this)),this.pollForReady=new Ke(this._pollForReady.bind(this)),this._meta.disableSignup=r}get meta(){return this._meta}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.channelToken)throw new C("Auth flow must be initialized first");try{let t=await this.api.post(Lf,{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(!t)throw new C("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");try{return await this.api.post(Nf,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw de(t)}}async _startChannelOnce(){if(!this.api)throw new C("Auth flow has no API instance");let t=await this.api.post(Wf,{token:this.captchaToken});v0&&!w0&&t.connect_uri&&Zl(t.connect_uri,"_blank"),this._meta={...this._meta,connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new C("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.channelToken)throw new C("Auth flow must be initialized first");let t=await this.api.get(Of,{headers:{"farcaster-channel-token":this.meta.channelToken}});return t.state==="completed"?(this.message=t.message,this.signature=t.signature,this.fid=t.fid,!0):!1}};import{base64url as kh}from"jose";async function xh(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function ps(e){return crypto.getRandomValues(new Uint8Array(e))}var ja=class{constructor(t){this.meta={guestCredential:this.getOrCreateGuestCredential(t)}}getOrCreateGuestCredential(t){let r=_l(t);if(rs()){if(Z.get(r))return Z.get(r);{let o=kh.encode(ps(32));return Z.put(r,o),o}}return kh.encode(ps(32))}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=await this.api.post(hh,{guest_credential:this.meta.guestCredential});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){throw new Error("Linking is not supported for the guest flow")}};import{base64url as Rh}from"jose";var b0="S256",E0="S256";function na(){return Rh.encode(ps(36))}function $a(){return na()}async function ei(e,t=b0){if(t==E0){let r=await xh(e);return Rh.encode(r)}else return e}function _h(){let e=Z.get($n);if(!e)throw new C("Authentication error.");return e}function Jl(){return!!Z.get(ea)}function Ih(){return!!Z.get(ta)}var Ro=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:Jl();this.meta={...t,headless:r}}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=_h();try{let r=await this.api.post(ql,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Z.del($n),Z.del(ea),Z.del(ta),{user:r.user,token:r.token,refresh_token:r.refresh_token,identity_token:r.identity_token,is_new_user:r.is_new_user,oauth_tokens:r.oauth_tokens}}catch(r){let o=de(r);throw o.privyErrorCode?new C(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new C("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new C("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=Z.get($n);if(!t)throw new C("Authentication error.");try{let r=await this.api.post(zl,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Z.del($n),r}catch(r){throw de(r)}}async getAuthorizationUrl(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.provider)throw new C("Provider must be set when initializing OAuth authentication.");let t=na();Z.put($n,t);let r=$a();Z.put(jn,r);let o=await ei(t);this.meta.headless&&Z.put(ea,!0),this.meta.disableSignup&&Z.put(ta,!0);try{return await this.api.post(Gl,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw de(n)}}};function us(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{jsx as Mh,jsxs as T0}from"react/jsx-runtime";var jl=({style:e,...t})=>T0("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...e},...t,children:[Mh("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"}),Mh("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"})]});import{jsx as ms,jsxs as S0}from"react/jsx-runtime";var $l=({style:e,...t})=>S0("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...e},...t,children:[ms("g",{clipPath:"url(#clip0)",children:ms("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"})}),ms("defs",{children:ms("clipPath",{id:"clip0",children:ms("rect",{width:"71",height:"55",fill:"white"})})})]});import{jsx as Wh}from"react/jsx-runtime";var ec=({style:e,...t})=>Wh("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...t,children:Wh("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"})});import P0 from"@heroicons/react/24/outline/GlobeAltIcon";import{jsx as A0}from"react/jsx-runtime";var Lh=({style:e})=>A0(P0,{style:{color:"var(--privy-color-error)",...e}});import{jsx as tc,jsxs as x0}from"react/jsx-runtime";var rc=({style:e,...t})=>x0("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...e},...t,children:[tc("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"}),tc("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"}),tc("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"}),tc("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"})]});import{jsx as Zr,jsxs as oc}from"react/jsx-runtime";function nc(e){return oc("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",...e,children:[oc("defs",{children:[oc("linearGradient",{id:"b",children:[Zr("stop",{offset:"0",stopColor:"#3771c8"}),Zr("stop",{stopColor:"#3771c8",offset:".128"}),Zr("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),oc("linearGradient",{id:"a",children:[Zr("stop",{offset:"0",stopColor:"#fd5"}),Zr("stop",{offset:".1",stopColor:"#fd5"}),Zr("stop",{offset:".5",stopColor:"#ff543e"}),Zr("stop",{offset:"1",stopColor:"#c837ab"})]}),Zr("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"}),Zr("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"})]}),Zr("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)"}),Zr("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)"}),Zr("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"})]})}import{jsx as ac}from"react/jsx-runtime";function ic({style:e,...t}){return ac("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},...t,children:ac("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:ac("g",{transform:"scale(5.12,5.12)",children:ac("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"})})})})}import{jsx as Nh,jsxs as k0}from"react/jsx-runtime";function sc(e){return k0("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...e,children:[Nh("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"}),Nh("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"})]})}import{jsx as Np,jsxs as R0}from"react/jsx-runtime";function lc(e){return R0("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,...e,children:[Np("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"}),Np("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"}),Np("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"})]})}import{jsx as Oh}from"react/jsx-runtime";var cc=({style:e,...t})=>Oh("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},...t,children:Oh("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"})});var Dh={google:{name:"Google",component:rc},discord:{name:"Discord",component:$l},github:{name:"Github",component:ec},linkedin:{name:"LinkedIn",component:ic},twitter:{name:"Twitter",component:cc},spotify:{name:"Spotify",component:sc},instagram:{name:"Instagram",component:nc},tiktok:{name:"Tiktok",component:lc},apple:{name:"Apple",component:jl}},fs=e=>e in Dh?Dh[e]:{name:"Unknown",component:Lh};function Uh(e,t){let r={detail:"",retryable:!1},o=us(t);if(e?.privyErrorCode==="linked_to_another_user"&&(r.detail="This account has already been linked to another user."),e?.privyErrorCode==="invalid_credentials"&&(r.retryable=!0,r.detail="Something went wrong. Try again."),e.privyErrorCode==="oauth_user_denied"&&(r.detail=`Retry and check ${o} to finish connecting your account.`,r.retryable=!0),e?.privyErrorCode==="too_many_requests"&&(r.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="too_many_requests"&&e.message.includes("provider rate limit")){let n=fs(t).name;r.detail=`Request limit reached for ${n}. Please wait a moment and try again.`}if(e?.privyErrorCode==="oauth_account_suspended"){let n=fs(t).name;r.detail=`Your ${n} account is suspended. Please try another login method.`}return e?.privyErrorCode==="cannot_link_more_of_type"&&(r.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode==="oauth_unexpected"&&t.startsWith("privy:")&&(r.detail="Something went wrong. Please try again."),r}function hs(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),o=e.get("privy_oauth_provider");if(!t||!r||!o)return{inProgress:!1};let n=!1;try{n=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:Jl(),popupFlow:window.opener!==null&&n,disableSignup:Ih()}}function aa(){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"),Z.del(jn),window.history.replaceState({},"",e)}var ia=class{constructor(t,r){this.initAuthenticateOnce=new Ke(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Ke(this._initLinkOnce.bind(this)),this.meta={captchaToken:t,setPasskeyAuthState:r}}async initAuthenticationFlow(){if(!this.api)throw new C("Auth flow has no API instance");this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute()}async initLinkFlow(){if(!this.api)throw new C("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async authenticate(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new C("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new C("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());try{let r=await t.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase(this.meta.initAuthenticateResponse.options));this.meta.setPasskeyAuthState?.({status:"submitting-response"});let o=await this.api.post(ah,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(r){throw r.name==="NotAllowedError"?new C("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):de(r)}}async link(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new C("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new C("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let r=this.meta.initLinkResponse.options,o=await t.startRegistration(this._transformInitLinkOptionsToCamelCase(r));return await this.api.post(nh,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(o)})}catch(r){throw r.name==="NotAllowedError"?new C("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):de(r)}}async _initAuthenticateOnce(){if(!this.api)throw new C("Auth flow has no API instance");return await this.api.post(oh,{token:this.meta.captchaToken})}async _initLinkOnce(){if(!this.api)throw new C("Auth flow has no API instance");return await this.api.post(rh,{})}_transformInitLinkOptionsToCamelCase(t){return{rp:t.rp,user:{id:t.user.id,name:t.user.name,displayName:t.user.display_name},challenge:t.challenge,pubKeyCredParams:t.pub_key_cred_params.map(r=>({type:r.type,alg:r.alg})),timeout:t.timeout,excludeCredentials:t.exclude_credentials?.map(r=>({id:r.id,type:r.type,transports:r.transports})),authenticatorSelection:{authenticatorAttachment:t.authenticator_selection?.authenticator_attachment,requireResidentKey:t.authenticator_selection?.require_resident_key,residentKey:t.authenticator_selection?.resident_key,userVerification:t.authenticator_selection?.user_verification},attestation:t.attestation,extensions:{appid:t.extensions?.app_id,credProps:t.extensions?.cred_props?.rk,hmacCreateSecret:t.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(t){return{id:t.id,raw_id:t.rawId,response:{client_data_json:t.response.clientDataJSON,attestation_object:t.response.attestationObject,authenticator_data:t.response.authenticatorData},authenticator_attachment:t.authenticatorAttachment,client_extension_results:{app_id:t.clientExtensionResults.appid,cred_props:t.clientExtensionResults.credProps,hmac_create_secret:t.clientExtensionResults.hmacCreateSecret},type:t.type}}_transformInitAuthenticateOptionsToCamelCase(t){return{challenge:t.challenge,allowCredentials:t.allow_credentials?.map(r=>({id:r.id,type:r.type,transports:r.transports}))||[],timeout:t.timeout,extensions:{appid:t.extensions?.app_id,credProps:t.extensions?.cred_props,hmacCreateSecret:t.extensions?.hmac_create_secret},userVerification:t.user_verification}}_transformAuthenticationResponseToSnakeCase(t){return{id:t.id,raw_id:t.rawId,response:{client_data_json:t.response.clientDataJSON,authenticator_data:t.response.authenticatorData,signature:t.response.signature,user_handle:t.response.userHandle},authenticator_attachment:t.authenticatorAttachment,client_extension_results:{app_id:t.clientExtensionResults.appid,cred_props:t.clientExtensionResults.credProps,hmac_create_secret:t.clientExtensionResults.hmacCreateSecret},type:t.type}}};var dc=({address:e,chainId:t,nonce:r})=>{let o=window.location.host,n=window.location.origin,a="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",i=new Date().toISOString();return`${o} wants you to sign in with your Ethereum account:
|
|
2
2
|
${e}
|
|
3
3
|
|
|
4
4
|
${a}
|
|
@@ -20,7 +20,7 @@ Chain ID: mainnet
|
|
|
20
20
|
Nonce: ${t}
|
|
21
21
|
Issued At: ${a}
|
|
22
22
|
Resources:
|
|
23
|
-
- https://privy.io`};var sa=class{constructor(t,r,o,n=!1){this._meta={disableSignup:!1};this.getNonceOnce=new Ke(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=o,this.client=r,this._meta.disableSignup=n}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new C("SiwsFlow has no client instance");try{let{message:t,signature:r}=await this.sign(),o=await this.client.authenticateWithSiwsInternal({message:t,signature:r,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return{user:o.user,token:o.token,refresh_token:o.refresh_token,identity_token:o.identity_token,is_new_user:o.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.client)throw new C("SiwsFlow has no client instance");try{let{message:t,signature:r}=await this.sign();return await this.client.linkWithSiwsInternal({message:t,signature:r,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw de(t)}}async sign(){if(!this.client)throw new C("SiwsFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new C("Could not prepare SIWS message");if(!this.wallet.signMessage)throw new C("Wallet does not support signMessage");let t=await this.wallet.signMessage(Buffer.from(this.preparedMessage));return{message:this.preparedMessage,signature:Buffer.from(t).toString("base64")}}async _getNonceOnce(){if(!this.client)throw new C("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new C("SiwsFlow has no client instance");let t=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=Fh({address:t,nonce:this.nonce}),this.preparedMessage}};var fn=class{constructor(t,r,o=!1){this.meta={phoneNumber:t,captchaToken:r,disableSignup:o}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new C("phone number and sms code must be set prior to calling authenticate.");try{let t=await this.api.post(Qf,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new C("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Kf,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw de(t)}}async sendSmsCode(t,r){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),r&&(this.meta.captchaToken=r),!this.meta.phoneNumber)throw new C("phone nNumber must be set when initialzing authentication.");try{return await this.api.post(zf,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(o){throw de(o)}}},pc=class extends fn{constructor(r,o,n){super(o,n);this.meta={phoneNumber:o,captchaToken:n,oldPhoneNumber:r,disableSignup:!1}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new C("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(Xf,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(r){throw de(r)}}};var ti=class{constructor(t,r=!1){this.meta={disableSignup:!1};this.meta={captchaToken:t,disableSignup:!1},this.meta.disableSignup=r}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=await this.api.post(sh,{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"});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");try{return await this.api.post(lh,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(t){throw de(t)}}};function Op(e){let t={detail:"",retryable:!1};return e?.privyErrorCode==="linked_to_another_user"&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode==="disallowed_login_method"&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode==="invalid_data"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="cannot_link_more_of_type"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="invalid_credentials"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="too_many_requests"&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="too_many_requests"&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),t}function Hh(){let e;if(e=_0(),e)return Bh(),{...e,flowType:"login-url"};if(e=I0(),e)return Bh(),{...e,flowType:"web-app"}}function _0(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),r=e.get("hash"),o=Number(e.get("auth_date")||""),n=e.get("first_name"),a=e.get("last_name")||void 0,i=e.get("username")||void 0,s=e.get("photo_url")||void 0;if(!(!t||!n||!o||!r))return{id:t,first_name:n,last_name:a,username:i,photo_url:s,auth_date:o,hash:r}}function I0(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=new URLSearchParams(decodeURIComponent(e.replace("#tgWebAppData=",""))),r=t.get("query_id")||void 0,o=t.get("user"),n=Number(t.get("auth_date")||""),a=t.get("hash"),i=t.get("chat_instance")||void 0,s=t.get("chat_type")||void 0,l=t.get("start_param")||void 0;if(!(!o||!n||!a))return{query_id:r,user:o,auth_date:n,hash:a,chat_instance:i,chat_type:s,start_param:l}}function Bh(){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)}import{v4 as cw}from"uuid";import{getAddress as ty}from"@ethersproject/address";import{isHexString as rw}from"@ethersproject/bytes";import ow from"eventemitter3";import F0 from"@coinbase/wallet-sdk";import{jsx as Vh,jsxs as M0}from"react/jsx-runtime";var jo=({style:e,...t})=>M0("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[Vh("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),Vh("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"})]});import{ErrorCode as W0}from"@ethersproject/logger";import{ProviderErrors as la}from"@privy-io/js-sdk-core";var ri=class extends Le{constructor(){super("Wallet timeout");this.type="wallet_error"}},oi=class extends Le{constructor(){super("User rejected connection");this.type="wallet_error"}},_r=e=>{if(e instanceof Le)return e;if(e?.code&&e?.reason){let t=new Wt(e);return e.code===W0.ACTION_REJECTED&&(t.details=la.E4001_USER_REJECTED_REQUEST),t}return e?.code?new Wt(e):new Le("Unknown connector error",e)},Jr=class extends pr{constructor(r,o,n){super(r);this.type="provider_error";this.code=o,this.data=n}},Wt=class extends Jr{constructor(r){let o=r;super(o.message,o.code,o.data);let n=Object.values(la).find(a=>a.eipCode===o.code);this.details=n||la.UNKNOWN_ERROR,o.code===-32002&&(o.message?.includes("already pending for origin")?o.message?.includes("wallet_requestPermissions")?this.details=la.E32002_CONNECTION_ALREADY_PENDING:this.details=la.E32002_REQUEST_ALREADY_PENDING:o.message?.includes("Already processing")&&o.message.includes("eth_requestAccounts")&&(this.details=la.E32002_WALLET_LOCKED))}},L0={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1}},_o={...L0,...la};import{getAddress as Mo}from"@ethersproject/address";import{Web3Provider as Qh}from"@ethersproject/providers";import{default as N0}from"eventemitter3";var ca=class extends N0{constructor(r){super();this.walletClientType=r,this.connected=!1,this.initialized=!1}};import D0 from"eventemitter3";var O0=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation"],Gh=e=>O0.includes(e);var st=class{constructor(t,r){this.removeListener=(t,r)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(t,r)}catch{console.warn("Unable to remove wallet provider listener")}};this.walletTimeout=(t=new ri,r=this.rpcTimeoutDuration)=>new Promise((o,n)=>setTimeout(()=>{n(t)},r));this.setWalletProvider=t=>{this.walletProvider&&this._subscriptions.forEach(r=>{this.removeListener(r.eventName,r.listener)}),this.walletProvider=t,this._subscriptions.forEach(r=>{this.walletProvider?.on(r.eventName,r.listener)})};this.walletProvider=t,this.rpcTimeoutDuration=r||ra,this._subscriptions=[]}on(t,r){if(this.walletProvider)return this.walletProvider.on(t,r);this._subscriptions.push({eventName:t,listener:r})}async request(t){if(!this.walletProvider)throw new Le(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),this.walletTimeout()]).catch(r=>{throw _r(r)})}},hn=class extends Error{constructor(r,o,n){super(r);this.code=o,this.data=n}},ys=class extends D0{constructor({walletProxy:r,address:o,rootAddress:n,rpcConfig:a,chains:i,appId:s,chainId:l=1,walletIndex:d}){super();this.walletProxy=r,this.address=o,this.rootAddress=n,this.chainId=l,this.rpcConfig=a,this.chains=i,this.provider=Kr(l,this.chains,a,{appId:s}),this.rpcTimeoutDuration=ni(a,"privy"),this.appId=s,this.walletIndex=d}async handleSendTransaction(r){if(!r.params||!Array.isArray(r.params))throw new hn(`Invalid params for ${r.method}`,4200);let o=r.params[0];if(!await he()||!this.address)throw new hn("Disconnected",4900);return(await Kh(o,void 0,void 0,this.address)).hash}handleSwitchEthereumChain(r){if(!r.params||!Array.isArray(r.params))throw new hn(`Invalid params for ${r.method}`,4200);let o;if(typeof r.params[0]=="string")o=r.params[0];else if("chainId"in r.params[0]&&typeof r.params[0].chainId=="string")o=r.params[0].chainId;else throw new hn(`Invalid params for ${r.method}`,4200);this.chainId=Number(o),this.provider=Kr(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",o)}async handlePersonalSign(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for personal_sign");let o=r.params[0],n=r.params[1];return await qh(o,void 0,n)}async handleSignedTypedData(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for eth_signTypedData_v4");let o=r.params[0],n=typeof r.params[1]=="string"?JSON.parse(r.params[1]):r.params[1];return await zh(ns(n),void 0,o)}async handleEstimateGas(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for eth_estimateGas");delete r.params[0].gasPrice,delete r.params[0].maxFeePerGas,delete r.params[0].maxPriorityFeePerGas;let o={...r.params[0],chainId:Zn(this.chainId)};try{return await this.provider.send("eth_estimateGas",[o])}catch(n){console.warn(`Gas estimation failed with error: ${n}. Retrying gas estimation by omitting the 'from' address`);try{return delete o.from,await this.provider.send("eth_estimateGas",[o])}catch(a){throw console.warn(`Gas estimation failed with error: ${a} when omitting the 'from' address`),n}}}async request(r){switch(console.debug("Embedded1193Provider.request() called with args",r),r.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return Zn(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(r);case"eth_sendTransaction":return this.handleSendTransaction(r);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(r);case"personal_sign":return this.handlePersonalSign(r);case"eth_signTypedData_v4":return this.handleSignedTypedData(r);default:break}if(Gh(r.method)){let o=await he();if(await Yh(),!o||!this.address)throw new hn("Disconnected",4900);try{return(await this.walletProxy.rpc({address:this.rootAddress,accessToken:o,hdWalletIndex:this.walletIndex,request:{method:r.method,params:r.params}})).response.data}catch(n){throw console.error(n),new hn("Disconnected",4900)}}else return this.provider.send(r.method,r.params)}async connect(){let r=await he();if(!r||!this.address)return null;try{return(await this.walletProxy.connect({address:this.address,accessToken:r})).address}catch(o){return console.error(o),null}}},Io=class extends st{constructor(r){super(r,r.rpcTimeoutDuration)}},yn=class extends st{constructor(t){super(t,t.rpcTimeoutDuration)}sendAsync(t,r){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var U0=(e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");default:return e.code===4902||e.message?.includes("4902")}};function ai(e){return e.chainType==="ethereum"}function fo(e){return e.type==="ethereum"}var mr=class extends ca{constructor(r,o,n,a){super(r);this.chainType="ethereum";this.onAccountsChanged=r=>{r.length===0?this.onDisconnect():this.syncAccounts(r)};this.onChainChanged=r=>{this.wallets.forEach(o=>{o.chainId=za(r),this.walletClientType==="privy"&&Z.put(Il(o.address),r)}),this.emit("walletsUpdated")};this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")};this.onConnect=()=>{this.connected=!0,this.syncAccounts()};this.wallets=[],this.walletClientType=r,this.chains=o,this.defaultChain=n,this.rpcConfig=a,this.rpcTimeoutDuration=ni(a,r),this.connected=!1,this.initialized=!1}buildConnectedWallet(r,o,n,a){let i=async()=>!!this.wallets.find(s=>Mo(s.address)===Mo(r));return{type:"ethereum",address:Mo(r),chainId:o,meta:n,imported:a,switchChain:async s=>{if(!i)throw new Le("Wallet is not currently connected.");let l=this.wallets.find(g=>Mo(g.address)===Mo(r))?.chainId;if(!l)throw new Le("Unable to determine current chainId.");let d,p;if(typeof s=="number"?(d=`0x${s.toString(16)}`,p=s):(d=s,p=Number(s)),l===za(d))return;let m=this.chains.find(g=>g.id===p);if(!m)throw new Le(`Unsupported chainId: ${s}`);let h=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:d}]})};try{return await h()}catch(g){if(U0(g,this.walletClientType))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:d,chainName:m.name,nativeCurrency:m.nativeCurrency,rpcUrls:[m.rpcUrls.default?.http[0]??""],blockExplorerUrls:[m.blockExplorers?.default.url??""]}]}),h();throw this.walletClientType==="rainbow"&&g.message?.includes("wallet_switchEthereumChain")?new Le(`Rainbow does not support the chainId ${o}`):g}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:i,getEthereumProvider:async()=>{if(!await i())throw new Le("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await i())throw new Le("Wallet is not currently connected.");return new Qh(new Io(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await i())throw new Le("Wallet is not currently connected.");return new yn(this.proxyProvider)},sign:async s=>{if(!await i())throw new Le("Wallet is not currently connected.");return await this.sign(s)},disconnect:()=>{this.disconnect()}}}async syncAccounts(r){let o=r;try{if(o===void 0){let d=await os(()=>this.proxyProvider.request({method:"eth_accounts"}),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,d),Array.isArray(d)&&(o=d)}}catch(d){console.warn("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",d)}if(!o||!Array.isArray(o)||o.length<=0||!o[0])return;let n=o[0],a=Mo(n),i=[],s;if(this.walletClientType==="privy"){let d=Z.get(Il(a));this.chains.find(p=>p.id===Number(d))||(Z.del(Il(a)),d=null),s=d||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:s}]})}catch{console.warn(`Unable to switch embedded wallet to chain ID ${s} on initialization`)}}else try{let d=await os(()=>this.proxyProvider.request({method:"eth_chainId"}),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,d),typeof d=="string")s=d;else if(typeof d=="number")s=`0x${d.toString(16)}`;else throw new Error("Invalid chainId returned from provider")}catch(d){console.warn(`Failed to get chainId from provider, defaulting to ${Ip}`,d),s=Ip}let l=za(s);if(!i.find(d=>Mo(d.address)===a)){let d={name:this.walletBranding.name,icon:typeof this.walletBranding.icon=="string"?this.walletBranding.icon:void 0,id:this.walletBranding.id};i.push(this.buildConnectedWallet(Mo(n),l,d,this.connectorType==="embedded_imported"))}gs(i,this.wallets)||(this.wallets=i,this.emit("walletsUpdated"))}async getConnectedWallet(){let r=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort((o,n)=>n.connectedAt-o.connectedAt).find(o=>r.find(n=>Mo(n)===Mo(o.address)))||null}async isConnected(){let r=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(r)&&r.length>0}async sign(r){return await this.connect({showPrompt:!1}),new Qh(new Io(this.proxyProvider)).getSigner().signMessage(r)}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}};var B0=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],Xh=(e,t)=>e.makeWeb3Provider({options:t}),uc,mc=class extends mr{constructor(r,o,n,a,i,s){super("coinbase_wallet",r,o,n);this.connectorType="coinbase_wallet";this.displayName="Coinbase Wallet";if(this.proxyProvider=new st(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=a.coinbaseWallet.connectionOptions??"all",this.walletClientType=this.connectionOptions==="smartWalletOnly"?"coinbase_smart_wallet":"coinbase_wallet",this.walletClientType==="coinbase_smart_wallet"&&(this.displayName="Coinbase Smart Wallet"),!uc){let l=[o.id].concat(r.map(p=>p.id)),d=this.connectionOptions!=="eoaOnly"?l.filter(p=>!B0.includes(p)):[];d.length>0&&console.warn(`The following configured chains are not supported by the Coinbase Smart Wallet: ${d.join(", ")}`),uc=new F0({appName:i,appLogoUrl:s,appChainIds:l})}this.proxyProvider.setWalletProvider(Xh(uc,this.connectionOptions))}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:jo,id:"com.coinbase.wallet"}}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new Le("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([r[0]])}catch(r){throw _r(r)}}updateConnectionPreference(r){this.connectionOptions=r,this.walletClientType=r==="smartWalletOnly"?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(Xh(uc,this.connectionOptions))}};var Cs=class extends mr{constructor({provider:r,chains:o,defaultChain:n,rpcConfig:a,imported:i,walletIndex:s}){super("privy",o,n,a);this.connectorType="embedded";this.proxyProvider=r,this.walletIndex=s,i&&(this.connectorType="embedded_imported"),this.subscribeListeners()}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[Zn(r?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Ll,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}};import{jsx as Zh}from"react/jsx-runtime";var ii=({style:e,...t})=>Zh("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...e},...t,children:Zh("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})});import{jsx as Ir,jsxs as H0}from"react/jsx-runtime";var si=({style:e,...t})=>H0("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",...e},...t,children:[Ir("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),Ir("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"})]});import{jsx as Jh,jsxs as V0}from"react/jsx-runtime";var Wo=({style:e,...t})=>V0("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...e},...t,children:[Jh("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),Jh("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"})]});var ci=class extends mr{constructor(r,o,n,a,i){super(i||"unknown",r,o,n);this.connectorType="injected";this.proxyProvider=new st(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=a;let s=a.provider;this.proxyProvider.setWalletProvider(s)}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.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 r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new Le("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw _r(r)}}},li,di=class extends mr{constructor(r,o,n,a,i){super(i??"unknown",r,o,n);this.connectorType="injected";Tl(this,li,void 0);this.proxyProvider=new st(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(a),i==="metamask"?Sp(this,li,{name:"MetaMask",icon:si,id:"io.metamask"}):i==="phantom"&&Sp(this,li,{name:"Phantom",icon:Wo,id:"phantom"})}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return Wm(this,li)??{name:"Browser Extension",icon:ii,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new Le("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw _r(r)}}};li=new WeakMap;import{getAddress as F_}from"@ethersproject/address";import{Web3Provider as H_}from"@ethersproject/providers";import{isMobile as G0}from"react-device-detect";var fc=class extends ci{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{G0||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let t=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!t||t.length===0||!t[0])throw new Le("Unable to retrieve accounts");await this.syncAccounts([t[0]])}catch(t){throw _r(t)}}};var hc=class extends mr{constructor(r,o){super(r,[],o,{});this.connectorType="null";this.proxyProvider=new st(void 0,ra);this.connectorType=r}get walletBranding(){return{name:"Wallet",id:""}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw new Error("connect called for an uninstalled wallet via the NullConnector")}disconnect(){throw new Error("disconnect called for an uninstalled wallet via the NullConnector")}promptConnection(r){throw new Error(`promptConnection called for an uninstalled wallet via the NullConnector for ${r}`)}};var yc=class extends hc{constructor(t){super("phantom",t)}get walletBranding(){return{name:"Phantom",icon:Wo,id:"phantom"}}};var q0=["privy"],z0=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","crypto.com_wallet_extension"],K0=["coinbase_wallet","coinbase_smart_wallet"],Y0=["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"],Q0=["unknown"],X0=["phantom","solflare","glow"],Z0=[...z0,...K0,...Y0,...q0,...Q0,...X0];function jh(e){return Z0.includes(e)}function ey(e){return e.chainType==="solana"}function Dp(e){return e.type==="solana"}var $h=class extends ca{constructor(r,o){let n=jh(r.name.toLowerCase())?r.name.toLowerCase():"unknown";super(n);this.chainType="solana";this.connectorType="solana_adapter";this.disconnect=()=>{this.adapter.disconnect().then(()=>this.onDisconnect()).catch(r=>console.error("Error disconnecting",r))};this.promptConnection=async()=>{try{await this.adapter.connect()}catch(r){throw _r(r)}};this.onDisconnect=()=>{this.syncAccounts()};this.onConnect=r=>{this.syncAccounts()};this.onError=r=>{this.syncAccounts()};this.onReadyStateChange=r=>{r!=="Installed"&&(this.connected=!1),this.syncAccounts()};this.adapter=r,this.shouldAutoConnect=o,this.wallets=[]}get isInstalled(){return this.adapter.readyState==="Installed"}buildConnectedWallet(r,o){if(r.readyState!=="Installed"||!r.publicKey)throw Error("Wallet is not connected.");let n;"signMessage"in r&&(n=async(...s)=>{if(!r.connected)throw Error("Wallet is not connected.");return await r.signMessage(s[0])});let a;"sendTransaction"in r&&(a=async(...s)=>await r.sendTransaction(s[0],s[1],s[2]));let i;return"signTransaction"in r&&(i=async s=>await r.signTransaction(s)),{type:"solana",address:r.publicKey.toBase58(),meta:o,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>r.connected,disconnect:()=>{try{r.disconnect()}catch{console.error("Wallet does not support programmatic disconnect")}},getProvider:Ht,signMessage:n,sendTransaction:a,signTransaction:i}}async syncAccounts(){if(this.adapter.readyState!=="Installed"||!this.adapter.publicKey)this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"));else{let r={name:this.walletBranding.name,icon:typeof this.walletBranding.icon=="string"?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find(o=>this.adapter.publicKey&&o.address===this.adapter.publicKey.toBase58())||(this.wallets=[this.buildConnectedWallet(this.adapter,r)],this.emit("walletsUpdated"))}}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAutoConnect&&await this.adapter.autoConnect().catch(console.error),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort((r,o)=>o.connectedAt-r.connectedAt)[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}};import{EthereumProvider as j0,OPTIONAL_EVENTS as $0,OPTIONAL_METHODS as ew}from"@walletconnect/ethereum-provider";import{isMobile as tw}from"react-device-detect";import{jsx as pi,jsxs as J0}from"react/jsx-runtime";var vs=({style:e,...t})=>{let{app:r}=x();return J0("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[pi("rect",{width:"28",height:"28",rx:"3",fill:r?.appearance.palette.colorScheme==="dark"?"#3396ff":"#141414"}),pi("g",{clipPath:"url(#clip0_1765_9946)",children:pi("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),pi("defs",{children:pi("clipPath",{id:"clip0_1765_9946",children:pi("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};var ho=class extends mr{constructor(r,o,n,a,i,s,l,d){super(d||"unknown",n,a,o);this.connectorType="wallet_connect_v2";this.privyAppId=s,this.privyAppName=l,this.walletConnectCloudProjectId=r,this.rpcConfig=o,this.shouldEnforceDefaultChainOnConnect=i,this.proxyProvider=new st(void 0,this.rpcTimeoutDuration),d&&(this.walletEntry=Xl[d],this.walletClientType=d)}async initialize(){let r=await this.createProvider();if(this.provider=r,this.proxyProvider.setWalletProvider(r),this.subscribeListeners(),r.session){if(this.walletProvider?.session?.peer.metadata.url){let n=Ql(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=n?.entry,this.walletClientType=n?.walletClientType||"unknown"}this.connected=!0,await this.syncAccounts()}this.initialized=!0,this.emit("initialized");let{WalletConnectModal:o}=await import("@walletconnect/modal");this.modal=new o({projectId:this.walletConnectCloudProjectId,themeVariables:{"--wcm-z-index":"1000000"}}),this.modal.subscribeModal(n=>{!n.open&&!this.walletProvider?.session&&this.onQrModalClosed&&this.onQrModalClosed()})}async connect(r){return r.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){return this.walletClientType==="metamask"?{name:"MetaMask",icon:si,id:"io.metamask"}:{name:Hm(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:this.walletProvider?.session?.peer.metadata.icons?.[0]||vs,id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(r){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletEntry=Xl[r],this.walletClientType=r,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,Th(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise((r,o)=>{let n=()=>{o(new oi)};this.onQrModalClosed=n,(async()=>{let i="",s=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(s?.length&&(i=s[0]),!i||i==="")throw new Le("Unable to retrieve address");if(this.walletProvider?.session?.peer.metadata.url){let l=Ql(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=l?.entry,this.walletClientType=l?.walletClientType||"unknown",this.proxyProvider.rpcTimeoutDuration=ni(this.rpcConfig,this.walletClientType)}this.connected=!0,await this.syncAccounts(s),r()})().catch(i=>{if(i){o(_r(i));return}o(new Le("Unknown error during connection"))}).finally(()=>this.modal?.closeModal())})}disconnect(){this.walletProvider?.disconnect().then(()=>this.onDisconnect()).catch(()=>console.warn("Unable to disconnect Wallet Connect provider"))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(r){this.proxyProvider.setWalletProvider(r)}async createProvider(){let r={};for(let i of this.chains){let s=Gm(i.id,this.chains,this.rpcConfig,this.privyAppId);s&&(r[i.id]=s)}let o=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],n=this.chains.map(i=>i.id),a=await j0.init({projectId:this.walletConnectCloudProjectId,chains:o,optionalChains:n,optionalEvents:$0,optionalMethods:ew,rpcMap:r,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.toString(),icons:[]}});return a.on("display_uri",i=>{if(a.signer.abortPairingAttempt(),tw&&this.walletEntry){let{redirect:s,href:l}=wh(i,this.walletEntry);Sh({href:l,name:this.walletEntry.displayName}),this.redirectUri=s;let d=bh(i,this.walletEntry);d?.redirect&&(this.fallbackUniversalRedirectUri=d.redirect),Zl(s,"_self")}else this.modal?.openModal({uri:i,chains:[this.defaultChain.id]})}),a.on("connect",()=>{if(this.modal?.closeModal(),a.session?.peer.metadata.url){let i=Ql(a.session?.peer.metadata.url);this.walletEntry=i?.entry,this.walletClientType=i?.walletClientType||"unknown"}}),a}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider?.enable()}};var Fp=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses")?.split(" ").filter(o=>rw(o)).map(o=>ty(o));return t?.length?!!e?.linkedAccounts.filter(o=>o.type=="wallet"&&t.includes(o.address)).length:!1},ni=(e,t)=>e.rpcTimeouts?e.rpcTimeouts[t]||ra:ra,ws=class extends ow{constructor(r,o,n,a,i,s,l,d,p,m,h){super();this.addSolanaWalletConnector=async r=>{this.findWalletConnector("solana_adapter",r.walletClientType)||this.addWalletConnector(r)};this.getEthereumProvider=()=>{let r=this.wallets[0],o=this.walletConnectors.find(n=>n.wallets.find(a=>a.address===r?.address));return!r||!o?new st:o.proxyProvider};this.privyAppId=r,this.walletConnectCloudProjectId=o,this.rpcConfig=n,this.chains=a,this.defaultChain=i,this.walletConnectors=[],this.initialized=!1,this.store=s,this.walletList=l,this.shouldEnforceDefaultChainOnConnect=d,this.externalWalletConfig=p,this.privyAppName=m,this.privyAppLogo=h,this.storedConnections=Up()}get wallets(){let r=new Set,o=this.walletConnectors.flatMap(a=>a.wallets).sort((a,i)=>a.connectedAt&&i.connectedAt?i.connectedAt-a.connectedAt:0).filter(a=>{let i=`${a.address}${a.walletClientType}${a.connectorType}`;return r.has(i)?!1:(r.add(i),!0)}),n=o.findIndex(a=>a.address===(this.activeWallet?this.activeWallet:"unknown"));return n>=0&&o.unshift(o.splice(n,1)[0]),o}async initialize(){if(this.initialized)return;Z.get(Rp)&&(Z.getKeys().forEach(o=>{o.startsWith("walletconnect")&&Z.del(o)}),Z.del(Rp));let r=Vm(this.store,this.walletList,this.externalWalletConfig).then(o=>{o.forEach(({type:n,eip6963InjectedProvider:a,legacyInjectedProvider:i})=>{this.createEthereumWalletConnector("injected",n,{eip6963InjectedProvider:a,legacyInjectedProvider:i})})});this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector("coinbase_wallet","coinbase_wallet"),!un()&&this.walletList.includes("phantom")&&this.createEthereumWalletConnector("phantom","phantom"),this.externalWalletConfig.walletConnect.enabled&&this.createEthereumWalletConnector("wallet_connect_v2","unknown"),this.externalWalletConfig.solana.connectors?.get().forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.(o=>{o?.forEach(this.addSolanaWalletConnector)}),await r,this.initialized=!0}findWalletConnector(r,o){return r==="wallet_connect_v2"?this.walletConnectors.filter(ai).find(n=>n.connectorType===r)??null:this.walletConnectors.filter(ai).find(n=>n.connectorType===r&&n.walletClientType===o)??null}findSolanaWalletConnector(r,o){return this.walletConnectors.filter(ey).find(n=>n.connectorType===r&&n.walletClientType===o)??null}findEmbeddedWalletConnectors(){return this.walletConnectors.filter(r=>r.connectorType==="embedded")}onInitialized(r){r.wallets.forEach(o=>{let n=this.storedConnections.find(a=>a.address===o.address&&a.connectorType===o.connectorType&&a.walletClientType===o.walletClientType);n&&(o.connectedAt=n.connectedAt)}),this.saveConnectionHistory(),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(r){r.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnectors({walletProxy:r,rootWallet:o,embeddedWallets:n,defaultChain:a,appId:i}){for(let s of n){let l=this.findEmbeddedWalletConnectors().find(d=>d.walletIndex===s.walletIndex);if(l&&ai(l))l.proxyProvider.walletProxy=r;else{let d=new ys({walletProxy:r,address:s.address,rootAddress:o.address,rpcConfig:this.rpcConfig,chains:this.chains,appId:i,chainId:a.id,walletIndex:s.walletIndex}),p=new Cs({provider:d,chains:this.chains,defaultChain:a,rpcConfig:this.rpcConfig,imported:!1,walletIndex:s.walletIndex});this.addWalletConnector(p)}}}addImportedWalletConnector(r,o,n,a){let i=this.findWalletConnector("embedded_imported","privy");if(i&&ai(i))i.proxyProvider.walletProxy=r;else{let s=new ys({walletProxy:r,rootAddress:o,address:o,walletIndex:0,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:n.id}),l=new Cs({provider:s,chains:this.chains,walletIndex:0,defaultChain:n,rpcConfig:this.rpcConfig,imported:!0});this.addWalletConnector(l)}}removeEmbeddedWalletConnectors(){this.walletConnectors=this.walletConnectors.filter(r=>r.connectorType!=="embedded"),this.saveConnectionHistory(),this.storedConnections=Up(),this.emit("walletsUpdated")}removeImportedWalletConnector(){let r=this.findWalletConnector("embedded_imported","privy");if(r){let o=this.walletConnectors.indexOf(r);this.walletConnectors.splice(o,1),this.saveConnectionHistory(),this.storedConnections=Up(),this.emit("walletsUpdated")}}async createEthereumWalletConnector(r,o,n){let a=this.findWalletConnector(r,o);if(a&&ai(a))return a instanceof ho&&a.resetConnection(o),a;let s=(()=>{if(r==="injected"){if(o==="metamask"&&n?.eip6963InjectedProvider)return new fc(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask");if(o==="metamask"&&n?.legacyInjectedProvider)return new di(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask");if(o==="phantom"&&n?.legacyInjectedProvider)return new di(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom");if(n?.legacyInjectedProvider&&o==="unknown_browser_extension")return new di(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider);if(n?.eip6963InjectedProvider)return new ci(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,o)}else return r==="coinbase_wallet"?new mc(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):r==="phantom"?new yc(this.defaultChain):new ho(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,this.privyAppName,o)})();return s&&this.addWalletConnector(s),s||null}addWalletConnector(r){this.walletConnectors.push(r),r.on("initialized",()=>this.onInitialized(r)),r.on("walletsUpdated",()=>this.onWalletsUpdated(r)),r.initialize().catch(o=>{console.debug("Failed to initialize connector",o)})}saveConnectionHistory(){let r=this.wallets.map(o=>({address:o.address,connectorType:o.connectorType,walletClientType:o.walletClientType,connectedAt:o.connectedAt}));Z.put(_p,r)}async activeWalletSign(r){let o=this.wallets,n=o.length>0?o[0]:null;return!n||!fo(n)?null:n.sign(r)}setActiveWallet(r){this.activeWallet=ty(r),this.emit("walletsUpdated")}};function gs(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let o=e[r],n=t[r];if(o?.address!==n?.address||o&&n&&fo(o)&&fo(n)&&o?.chainId!==n?.chainId||o?.connectorType!==n?.connectorType||o?.connectedAt!==n?.connectedAt||o?.walletClientType!==n?.walletClientType||o?.isConnected!==n?.isConnected||o?.linked!==n?.linked)return!1}return!0}var nw=e=>e&&typeof e.address=="string"&&typeof e.connectorType=="string"&&typeof e.walletClientType=="string"&&typeof e.connectedAt=="number",Up=()=>{let e=Z.get(_p);return e&&Array.isArray(e)&&e.map(o=>nw(o)).every(Boolean)?e:[]};import{ofetch as aw}from"ofetch";var iw=[Bl,Vl,Hl,Kl],gc=class{constructor({appId:t,appClientId:r,client:o,defaults:n}){this.appId=t,this.appClientId=r,this.clientAnalyticsId=o.clientAnalyticsId,this.sdkVersion=Pp,this.client=o,this.defaults=n,this.fallbackApiUrl=o.fallbackApiUrl,this.baseFetch=aw.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:a,options:i})=>{let s=new Headers(i.headers);s.set("privy-app-id",this.appId),this.appClientId&&s.set("privy-client-id",this.appClientId),s.set("privy-ca-id",this.clientAnalyticsId||""),s.set("privy-client",`react-auth:${this.sdkVersion}`);let l=iw.includes(a.toString());if(!s.has("authorization")){let d=await this.client.getAccessToken({disableAutoRefresh:l});d!==null&&s.set("authorization",`Bearer ${d}`)}i.headers=s,i.retryDelay&&(i.retryDelay=i.retryDelay*3)},onRequestError:({error:a})=>{if(a instanceof DOMException&&a.name==="AbortError")throw new Nm}})}async get(t,r){try{return await this.baseFetch(t,r)}catch(o){throw de(o)}}async post(t,r,o){try{return await this.baseFetch(t,{method:"POST",...r?{body:r}:{},...o})}catch(n){throw de(n)}}async delete(t,r){try{return await this.baseFetch(t,{method:"DELETE",...r})}catch(o){throw de(o)}}};var ry=e=>({challenge:e.challenge,allowCredentials:e.allow_credentials?.map(t=>({id:t.id,type:t.type,transports:t.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});import gn from"js-cookie";function oy(e){return e instanceof mn?"email":e instanceof fn?"sms":e instanceof Jo?"siwe":e instanceof ja?"guest":e instanceof Ja?"custom_auth":e instanceof Ro?e.meta.provider:null}import{isSafari as sw}from"react-device-detect";function Cc(){return!(sw&&window.location.origin.startsWith("http://localhost"))}import*as ny from"jose";var jr=class{static parse(t){try{return new jr(t)}catch{return null}}constructor(t){this.value=t,this._decoded=ny.decodeJwt(t)}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(t=0){let r=Date.now(),o=(this.expiration-t)*1e3;return r>=o}};var lw=30,vc=class{constructor(){this.authenticateOnce=new Ke(async t=>this._authenticate(t)),this.linkOnce=new Ke(async t=>this._link(t)),this.refreshOnce=new Ke(this._refresh.bind(this)),this.destroyOnce=new Ke(this._destroy.bind(this)),this.forkSessionOnce=new Ke(this._forkSession.bind(this))}get token(){try{let t=Z.get(Jn);return typeof t=="string"?new jr(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=Z.get(kl);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=Z.get(as);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}getProviderAccessToken(t){try{let r=Z.get(ss(t));if(typeof r=="string"){let o=new jr(r);return o.isExpired()?(Z.del(ss(t)),null):o.value}else return null}catch(r){return console.error(r),null}}get mightHaveServerCookies(){try{let t=gn.get(Rl);return t!==void 0&&t.length>0}catch(t){console.error(t)}return!1}hasRefreshCredentials(){return this.mightHaveServerCookies||typeof this.token=="string"&&typeof this.refreshToken=="string"&&this.refreshToken!==$m}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=jr.parse(this.token);return t!==null&&!t.isExpired(lw)}authenticate(t){return this.authenticateOnce.execute(t)}link(t){return this.linkOnce.execute(t)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(t,r){typeof r=="string"?Z.put(ss(t),r):Z.del(ss(t))}async _authenticate(t){try{let r=await t.authenticate(),{user:o,is_new_user:n,oauth_tokens:a}=r;this.handleTokenResponse(r);let i=a,s=i?{provider:i.provider,accessToken:i.access_token,accessTokenExpiresInSeconds:i.access_token_expires_in_seconds,refreshToken:i.refresh_token,refreshTokenExpiresInSeconds:a.refresh_token_expires_in_seconds,scopes:i.scopes}:void 0,l=oy(t);return l&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:l,isNewUser:n}}),l==="siwe"&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}}),{user:St(o),isNewUser:n,oAuthTokens:s}}catch(r){throw console.warn("Error authenticating session"),qe(r)}}async _link(t){try{let r=await t.link(),o=r.oauth_tokens,n=o?{provider:o.provider,accessToken:o.access_token,accessTokenExpiresInSeconds:o.access_token_expires_in_seconds,refreshToken:o.refresh_token,refreshTokenExpiresInSeconds:o.refresh_token_expires_in_seconds,scopes:o.scopes}:void 0;return{user:St(r),oAuthTokens:n}}catch(r){throw console.warn("Error linking account"),qe(r)}}async _refresh(){if(!this.api)throw new C("Session has no API instance");if(!this.client)throw new C("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,r=this.refreshToken,o=this.forkedToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let n;if(t&&r||this.mightHaveServerCookies){let a={};t&&(a.authorization=`Bearer ${t}`);let i=r?{refresh_token:r}:{};n=await this.api.post(Bl,i,{headers:a}),o&&this.clearForkedToken()}else if(o)n=await this.api.post(Vl,{refresh_token:o}),this.clearForkedToken();else return null;return this.handleTokenResponse(n),St(n.user)}catch(n){if(n instanceof xr&&n.privyErrorCode==="missing_or_invalid_token")return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw qe(n)}}handleTokenResponse(t){t.session_update_action?t.session_update_action==="set"?(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token)):t.session_update_action==="clear"?this.destroyLocalState():t.session_update_action==="ignore"&&t.token&&(this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token)):(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token))}async _destroy(){try{await this.api?.post(Hl,{refresh_token:this.refreshToken})}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new C("Session has no API instance");let t=this.refreshToken;try{let r=await this.api.post(Ef,{refresh_token:t});return this.storeRefreshToken(r.refresh_token),this.storeToken(r.token),r.new_session_refresh_token}catch(r){throw qe(r)}}destroyLocalState(){this.storeRefreshToken(null),this.storeToken(null),this.clearIdentityToken(),this.clearForkedToken()}storeToken(t){if(typeof t=="string"){let r=Z.get(Jn);if(Z.put(Jn,t),!this.client?.useServerCookies){let o=jr.parse(t)?.expiration;gn.set(Ap,t,{sameSite:"Strict",secure:Cc(),expires:o?new Date(o*1e3):void 0})}r!==t&&this.client?.onStoreToken?.(t)}else Z.del(Jn),gn.remove(Ap),this.client?.onDeleteToken?.()}storeRefreshToken(t){typeof t=="string"?(Z.put(kl,t),this.client?.useServerCookies||gn.set(Rl,"t",{sameSite:"Strict",secure:Cc(),expires:30})):(Z.del(kl),gn.remove(Qm),gn.remove(Rl))}storeIdentityToken(t){if(this.client?.useServerCookies)return;Z.put(xp,t);let r=jr.parse(t)?.expiration;gn.set(kp,t,{sameSite:"Strict",secure:Cc(),expires:r?new Date(r*1e3):void 0})}clearIdentityToken(){Z.del(xp),gn.remove(kp)}clearForkedToken(){Z.del(as)}};var Bp,wc,ay,bs=class{constructor(t){Tl(this,wc);this.apiUrl=t.apiUrl||xl,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!!t.apiUrl&&t.apiUrl.startsWith("https://privy."),this.timeout=t.timeout||zm,this.appId=t.appId,this.appClientId=t.appClientId,this.clientAnalyticsId=Lm(this,wc,ay).call(this),Bp||(Bp=new vc),this.session=Bp,this.api=this.generateApi(),this.session.client=this}initializeConnectorManager({walletConnectCloudProjectId:t,rpcConfig:r,chains:o,defaultChain:n,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:s,externalWalletConfig:l,appName:d}){this.connectors||(this.connectors=new ws(this.appId,t,r,o,n,a,i,s,l,d))}sessionHasActiveToken(){return this.session.hasActiveToken()}generateApi(){let t=new gc({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=t,t}updateApiUrl(t){this.apiUrl=t||this.fallbackApiUrl,this.api=this.generateApi(),t&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new C("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new C("No auth flow in progress.");let{oAuthTokens:t}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:t}}storeProviderAccessToken(t,r){this.session.storeProviderAccessToken(t,r)}getProviderAccessToken(t){return this.session.getProviderAccessToken(t)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(t){t.linkedAccounts.filter(o=>o.type==="cross_app").forEach(o=>{this.storeProviderAccessToken(o.providerApp.id,null)})}startAuthFlow(t){return t.api=this.api,this.authFlow=t,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(ph,{action:"verify"})}catch(t){throw de(t)}}async initMfaPasskeyVerification(){try{let t=await this.api.post(uh,{});return ry(t.options)}catch(t){throw de(t)}}async acceptTerms(){try{let t=await this.api.post(mh,{});return St(t)}catch(t){throw qe(t)}}async unlinkEmail(t){try{let r=await this.api.post(Vf,{address:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkPhone(t){try{let r=await this.api.post(Yf,{phoneNumber:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkEthereumWallet(t){try{let r=await this.api.post(xf,{address:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkSolanaWallet(t){try{let r=await this.api.post(Mf,{address:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkOAuth(t,r){try{let o=await this.api.post(Jf,{provider:t,subject:r});return await this.getAuthenticatedUser()??St(o)}catch(o){throw qe(o)}}async unlinkFarcaster(t){try{let r=await this.api.post(Df,{fid:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkTelegram(t){try{let r=await this.api.post(ch,{telegram_user_id:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkPasskey(t){try{let r=await this.api.post(ih,{credential_id:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async createAnalyticsEvent({eventName:t,payload:r,timestamp:o,options:n}){if(!(typeof window>"u"))try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(Kl,{event_name:t,client_id:this.clientAnalyticsId,payload:{...r||{},clientTimestamp:o?o.toISOString():new Date().toISOString()}},{retry:-1,keepalive:n?.keepAlive??!1})}catch{}}async signMoonpayOnRampUrl(t){try{return this.api.post(yh,t)}catch(r){throw qe(r)}}async initCoinbaseOnRamp(t){try{return this.api.post(gh,t)}catch(r){throw qe(r)}}async getCoinbaseOnRampStatus({partnerUserId:t}){try{return this.api.get(`${Ch}?partnerUserId=${t}`)}catch(r){throw qe(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){return this.session.hasActiveToken()?this.session.hasRefreshCredentials()?jr.parse(this.session.token)?.audience!==this.appId?(await this.logout(),null):this.session.token:(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getSmartWalletsConfig(){try{let t={},r=this.session.token;r&&(t.authorization=`Bearer ${r}`);let o=await this.api.get(`/api/v1/apps/${this.appId}/smart_wallets`,{baseURL:this.fallbackApiUrl,headers:t});return o.enabled?{enabled:o.enabled,smartWalletType:o.smart_wallet_type,configuredNetworks:o.configured_networks.map(n=>({chainId:n.chain_id,bundlerUrl:n.bundler_url,paymasterUrl:n.paymaster_url}))}:{enabled:o.enabled}}catch(t){throw qe(t)}}async getServerConfig(){try{let t={},r=this.session.token;r&&(t.authorization=`Bearer ${r}`);let o=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl,headers:t}),n=o.telegram_auth_config?{botId:o.telegram_auth_config.bot_id,botName:o.telegram_auth_config.bot_name,linkEnabled:o.telegram_auth_config.link_enabled,seamlessAuthEnabled:o.telegram_auth_config.seamless_auth_enabled}:void 0,a=o.funding_config?{methods:o.funding_config.methods,defaultRecommendedAmount:o.funding_config.default_recommended_amount,defaultRecommendedCurrency:o.funding_config.default_recommended_currency,promptFundingOnWalletCreation:o.funding_config.prompt_funding_on_wallet_creation}:void 0;return{id:o.id,name:o.name,verificationKey:o.verification_key,logoUrl:o.logo_url||void 0,accentColor:o.accent_color||void 0,showWalletLoginFirst:o.show_wallet_login_first,allowlistConfig:{errorTitle:o.allowlist_config.error_title,errorDetail:o.allowlist_config.error_detail,errorCtaText:o.allowlist_config.cta_text,errorCtaLink:o.allowlist_config.cta_link},walletAuth:o.wallet_auth,emailAuth:o.email_auth,smsAuth:o.sms_auth,googleOAuth:o.google_oauth,twitterOAuth:o.twitter_oauth,discordOAuth:o.discord_oauth,githubOAuth:o.github_oauth,spotifyOAuth:o.spotify_oauth,instagramOAuth:o.instagram_oauth,tiktokOAuth:o.tiktok_oauth,linkedinOAuth:o.linkedin_oauth,appleOAuth:o.apple_oauth,farcasterAuth:o.farcaster_auth,passkeyAuth:o.passkey_auth,telegramAuth:o.telegram_auth,termsAndConditionsUrl:o.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:o.embedded_wallet_config?.create_on_login,userOwnedRecoveryOptions:o.embedded_wallet_config.user_owned_recovery_options,requireUserOwnedRecoveryOnCreate:o.embedded_wallet_config.require_user_owned_recovery_on_create},privacyPolicyUrl:o.privacy_policy_url,requireUsersAcceptTerms:o.require_users_accept_terms,customApiUrl:o.custom_api_url,walletConnectCloudProjectId:o.wallet_connect_cloud_project_id,fiatOnRampEnabled:o.fiat_on_ramp_enabled,captchaEnabled:o.captcha_enabled,captchaSiteKey:o.captcha_site_key,createdAt:new Date(o.created_at*1e3),updatedAt:new Date(o.updated_at*1e3),mfaMethods:o.mfa_methods,enforceWalletUis:o.enforce_wallet_uis,legacyWalletUiConfig:o.legacy_wallet_ui_config,telegramAuthConfiguration:n,fundingConfig:a}}catch(t){throw qe(t)}}async getUsdTokenPrice(t){try{return(await this.api.get(`/api/v1/token_price?chainId=${t.id}&tokenSymbol=${t.nativeCurrency.symbol}`)).usd}catch{console.error(`Unable to fetch token price for chain with id ${t.id}`);return}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch{console.error("Unable to fetch token price for SOL");return}}async requestFarcasterSignerStatus(t){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:t})}catch(r){throw console.error("Unable to fetch Farcaster signer status"),r}}async forkSession(){return await this.session.forkSession()}async generateSiweNonce({address:t,captchaToken:r}){try{return(await this.api.post(Tf,{address:t,token:r})).nonce}catch(o){throw qe(o)}}async authenticateWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:a,mode:i}){return await this.api.post(Sf,{message:t,signature:r,chainId:o,walletClientType:n,connectorType:a,mode:i})}async linkWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:a}){return await this.api.post(Pf,{message:t,signature:r,chainId:o,walletClientType:n,connectorType:a})}async linkSmartWallet({message:t,signature:r,smartWalletType:o}){try{let n=await this.api.post(Af,{message:t,signature:r,smart_wallet_type:o});return St(n)}catch(n){throw qe(n)}}async linkWithSiwe({message:t,signature:r,chainId:o,walletClientType:n,connectorType:a}){try{let i=await this.linkWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:a});return St(i)}catch(i){throw qe(i)}}async generateSiwsNonce({address:t,captchaToken:r}){try{return(await this.api.post(Rf,{address:t,token:r})).nonce}catch(o){throw qe(o)}}async authenticateWithSiwsInternal({message:t,signature:r,walletClientType:o,connectorType:n,mode:a}){return await this.api.post(_f,{message:t,signature:r,walletClientType:o,connectorType:n,mode:a})}async sendAccountTransferRequest({nonce:t,account:r,accountType:o,chainId:n,walletClientType:a,connectorType:i,telegramAuthResult:s}){try{let l,d;switch(o){case"email":l=qf,d={nonce:t,email:r};break;case"sms":l=Zf,d={nonce:t,phoneNumber:r};break;case"siwe":if(l=kf,!n||!a||!i)throw Error("Wallet parameters must be defined");d={nonce:t,address:r,chainId:n,walletClientType:a,connectorType:i};break;case"farcaster":l=Uf,d={nonce:t};break;case"telegram":l=dh,d={nonce:t,telegram_auth_result:s};break;case"custom":throw Error("Invalid transfer account type");case"guest":throw Error("Invalid transfer account type");case"passkey":throw Error("Invalid transfer account type");default:l=jf,d={nonce:t,subject:r}}let p=await this.api.post(l,d);return await this.getAuthenticatedUser()??St(p)}catch(l){throw qe(l)}}async linkWithSiwsInternal({message:t,signature:r,walletClientType:o,connectorType:n}){return await this.api.post(If,{message:t,signature:r,walletClientType:o,connectorType:n})}async linkWithSiws({message:t,signature:r,walletClientType:o,connectorType:n}){try{let a=await this.linkWithSiwsInternal({message:t,signature:r,walletClientType:o,connectorType:n});return St(a)}catch(a){throw qe(a)}}};wc=new WeakSet,ay=function(){if(typeof window>"u")return null;try{let r=Z.get(is);if(typeof r=="string"&&r.length>0)return r}catch{}let t=cw();try{return Z.put(is,t),t}catch{return t}};import{Turnstile as hw}from"@marsidev/react-turnstile";import{useEffect as yw,useMemo as gw}from"react";import{useMemo as dw,useRef as pw,useContext as uw,useState as Hp,createContext as mw}from"react";import{jsx as fw}from"react/jsx-runtime";var iy=mw({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:Ht,setError:Ht,setExecuting:Ht,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:Ht,reset:Ht,execute:Ht}),Lt=class extends pr{constructor(r,o,n){super(r||"Captcha failed");this.type="Captcha";o instanceof Error&&(this.cause=o),this.privyErrorCode=n}},sy=({children:e,id:t,captchaSiteKey:r,captchaEnabled:o})=>{let n=pw(null),[a,i]=Hp(),[s,l]=Hp(),[d,p]=Hp(!1),m=dw(()=>o?!d&&!a&&!s?{status:"ready"}:d&&!a&&!s?{status:"loading"}:a&&!s?{status:"success",token:a}:s?{status:"error",error:s}:{status:"ready"}:{status:"disabled"},[o,a,s,d]);return fw(iy.Provider,{value:{...m,ref:n,enabled:o,siteKey:r,appId:t,setToken:i,setError:l,setExecuting:p,remove(){o&&(n.current?.remove(),p(!1),l(void 0),i(void 0))},reset(){o&&(n.current?.reset(),p(!1),l(void 0),i(void 0))},execute(){o&&(p(!0),n.current?.execute())},async waitForResult(){if(!o)return"";try{return await Bm(()=>n.current?.getResponse(),{interval:200,timeout:2e4})}catch{throw new Lt("Captcha failed",null,"captcha_timeout")}}},children:e})},Te=()=>uw(iy);import{jsx as ly}from"react/jsx-runtime";var Vp=e=>{let{enabled:t,siteKey:r,appId:o,setError:n,setToken:a,setExecuting:i,ref:s}=Te(),[,l]=gw(()=>r?.split("t:")||[],[r]);if(yw(()=>s.current?.remove,[]),!t)return null;if(!l)throw new Error("Unsupported captcha site key");return ly("div",{className:"hidden h-0 w-0",children:ly(hw,{...e,ref:s,siteKey:l,options:{action:o,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?.(),n("Captcha failed"),i(!1)},onSuccess:d=>{e.onSuccess?.(d),a(d),i(!1)},onExpire:()=>{e.onExpire?.();try{s.current?.reset(),n(void 0),a(void 0)}catch{n("expired_and_failed_reset")}}})})};import{useCallback as IA,useEffect as Bv,useRef as MA,useState as WA}from"react";import Gv from"styled-components";function Gp(e){ze("configureMfa",e)}import Fw from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import hy from"styled-components";import da,{css as cy}from"styled-components";import zp from"styled-components";import{Fragment as vw,jsx as qp,jsxs as ww}from"react/jsx-runtime";var ht=({success:e,fail:t})=>ww(vw,{children:[qp(yt,{className:e?"success":t?"fail":""}),qp(Es,{className:e?"success":t?"fail":""})]}),yt=zp.span`
|
|
23
|
+
- https://privy.io`};var sa=class{constructor(t,r,o,n=!1){this._meta={disableSignup:!1};this.getNonceOnce=new Ke(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=o,this.client=r,this._meta.disableSignup=n}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new C("SiwsFlow has no client instance");try{let{message:t,signature:r}=await this.sign(),o=await this.client.authenticateWithSiwsInternal({message:t,signature:r,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return{user:o.user,token:o.token,refresh_token:o.refresh_token,identity_token:o.identity_token,is_new_user:o.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.client)throw new C("SiwsFlow has no client instance");try{let{message:t,signature:r}=await this.sign();return await this.client.linkWithSiwsInternal({message:t,signature:r,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw de(t)}}async sign(){if(!this.client)throw new C("SiwsFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new C("Could not prepare SIWS message");if(!this.wallet.signMessage)throw new C("Wallet does not support signMessage");let t=await this.wallet.signMessage(Buffer.from(this.preparedMessage));return{message:this.preparedMessage,signature:Buffer.from(t).toString("base64")}}async _getNonceOnce(){if(!this.client)throw new C("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new C("SiwsFlow has no client instance");let t=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=Fh({address:t,nonce:this.nonce}),this.preparedMessage}};var fn=class{constructor(t,r,o=!1){this.meta={phoneNumber:t,captchaToken:r,disableSignup:o}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new C("phone number and sms code must be set prior to calling authenticate.");try{let t=await this.api.post(Qf,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new C("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Kf,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw de(t)}}async sendSmsCode(t,r){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),r&&(this.meta.captchaToken=r),!this.meta.phoneNumber)throw new C("phone nNumber must be set when initialzing authentication.");try{return await this.api.post(zf,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(o){throw de(o)}}},pc=class extends fn{constructor(r,o,n){super(o,n);this.meta={phoneNumber:o,captchaToken:n,oldPhoneNumber:r,disableSignup:!1}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new C("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(Xf,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(r){throw de(r)}}};var ti=class{constructor(t,r=!1){this.meta={disableSignup:!1};this.meta={captchaToken:t,disableSignup:!1},this.meta.disableSignup=r}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=await this.api.post(sh,{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"});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");try{return await this.api.post(lh,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(t){throw de(t)}}};function Op(e){let t={detail:"",retryable:!1};return e?.privyErrorCode==="linked_to_another_user"&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode==="disallowed_login_method"&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode==="invalid_data"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="cannot_link_more_of_type"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="invalid_credentials"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="too_many_requests"&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="too_many_requests"&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),t}function Hh(){let e;if(e=_0(),e)return Bh(),{...e,flowType:"login-url"};if(e=I0(),e)return Bh(),{...e,flowType:"web-app"}}function _0(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),r=e.get("hash"),o=Number(e.get("auth_date")||""),n=e.get("first_name"),a=e.get("last_name")||void 0,i=e.get("username")||void 0,s=e.get("photo_url")||void 0;if(!(!t||!n||!o||!r))return{id:t,first_name:n,last_name:a,username:i,photo_url:s,auth_date:o,hash:r}}function I0(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=new URLSearchParams(decodeURIComponent(e.replace("#tgWebAppData=",""))),r=t.get("query_id")||void 0,o=t.get("user"),n=Number(t.get("auth_date")||""),a=t.get("hash"),i=t.get("chat_instance")||void 0,s=t.get("chat_type")||void 0,l=t.get("start_param")||void 0;if(!(!o||!n||!a))return{query_id:r,user:o,auth_date:n,hash:a,chat_instance:i,chat_type:s,start_param:l}}function Bh(){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)}import{v4 as cw}from"uuid";import{getAddress as ty}from"@ethersproject/address";import{isHexString as rw}from"@ethersproject/bytes";import ow from"eventemitter3";import F0 from"@coinbase/wallet-sdk";import{jsx as Vh,jsxs as M0}from"react/jsx-runtime";var jo=({style:e,...t})=>M0("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[Vh("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),Vh("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"})]});import{ErrorCode as W0}from"@ethersproject/logger";import{ProviderErrors as la}from"@privy-io/js-sdk-core";var ri=class extends Le{constructor(){super("Wallet timeout");this.type="wallet_error"}},oi=class extends Le{constructor(){super("User rejected connection");this.type="wallet_error"}},_r=e=>{if(e instanceof Le)return e;if(e?.code&&e?.reason){let t=new Wt(e);return e.code===W0.ACTION_REJECTED&&(t.details=la.E4001_USER_REJECTED_REQUEST),t}return e?.code?new Wt(e):new Le("Unknown connector error",e)},Jr=class extends pr{constructor(r,o,n){super(r);this.type="provider_error";this.code=o,this.data=n}},Wt=class extends Jr{constructor(r){let o=r;super(o.message,o.code,o.data);let n=Object.values(la).find(a=>a.eipCode===o.code);this.details=n||la.UNKNOWN_ERROR,o.code===-32002&&(o.message?.includes("already pending for origin")?o.message?.includes("wallet_requestPermissions")?this.details=la.E32002_CONNECTION_ALREADY_PENDING:this.details=la.E32002_REQUEST_ALREADY_PENDING:o.message?.includes("Already processing")&&o.message.includes("eth_requestAccounts")&&(this.details=la.E32002_WALLET_LOCKED))}},L0={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1}},_o={...L0,...la};import{getAddress as Mo}from"@ethersproject/address";import{Web3Provider as Qh}from"@ethersproject/providers";import{default as N0}from"eventemitter3";var ca=class extends N0{constructor(r){super();this.walletClientType=r,this.connected=!1,this.initialized=!1}};import D0 from"eventemitter3";var O0=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation"],Gh=e=>O0.includes(e);var st=class{constructor(t,r){this.removeListener=(t,r)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(t,r)}catch{console.warn("Unable to remove wallet provider listener")}};this.walletTimeout=(t=new ri,r=this.rpcTimeoutDuration)=>new Promise((o,n)=>setTimeout(()=>{n(t)},r));this.setWalletProvider=t=>{this.walletProvider&&this._subscriptions.forEach(r=>{this.removeListener(r.eventName,r.listener)}),this.walletProvider=t,this._subscriptions.forEach(r=>{this.walletProvider?.on(r.eventName,r.listener)})};this.walletProvider=t,this.rpcTimeoutDuration=r||ra,this._subscriptions=[]}on(t,r){if(this.walletProvider)return this.walletProvider.on(t,r);this._subscriptions.push({eventName:t,listener:r})}async request(t){if(!this.walletProvider)throw new Le(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),this.walletTimeout()]).catch(r=>{throw _r(r)})}},hn=class extends Error{constructor(r,o,n){super(r);this.code=o,this.data=n}},ys=class extends D0{constructor({walletProxy:r,address:o,rootAddress:n,rpcConfig:a,chains:i,appId:s,chainId:l=1,walletIndex:d}){super();this.walletProxy=r,this.address=o,this.rootAddress=n,this.chainId=l,this.rpcConfig=a,this.chains=i,this.provider=Kr(l,this.chains,a,{appId:s}),this.rpcTimeoutDuration=ni(a,"privy"),this.appId=s,this.walletIndex=d}async handleSendTransaction(r){if(!r.params||!Array.isArray(r.params))throw new hn(`Invalid params for ${r.method}`,4200);let o=r.params[0];if(!await he()||!this.address)throw new hn("Disconnected",4900);return(await Kh(o,void 0,void 0,this.address)).hash}handleSwitchEthereumChain(r){if(!r.params||!Array.isArray(r.params))throw new hn(`Invalid params for ${r.method}`,4200);let o;if(typeof r.params[0]=="string")o=r.params[0];else if("chainId"in r.params[0]&&typeof r.params[0].chainId=="string")o=r.params[0].chainId;else throw new hn(`Invalid params for ${r.method}`,4200);this.chainId=Number(o),this.provider=Kr(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",o)}async handlePersonalSign(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for personal_sign");let o=r.params[0],n=r.params[1];return await qh(o,void 0,n)}async handleSignedTypedData(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for eth_signTypedData_v4");let o=r.params[0],n=typeof r.params[1]=="string"?JSON.parse(r.params[1]):r.params[1];return await zh(ns(n),void 0,o)}async handleEstimateGas(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for eth_estimateGas");delete r.params[0].gasPrice,delete r.params[0].maxFeePerGas,delete r.params[0].maxPriorityFeePerGas;let o={...r.params[0],chainId:Zn(this.chainId)};try{return await this.provider.send("eth_estimateGas",[o])}catch(n){console.warn(`Gas estimation failed with error: ${n}. Retrying gas estimation by omitting the 'from' address`);try{return delete o.from,await this.provider.send("eth_estimateGas",[o])}catch(a){throw console.warn(`Gas estimation failed with error: ${a} when omitting the 'from' address`),n}}}async request(r){switch(console.debug("Embedded1193Provider.request() called with args",r),r.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return Zn(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(r);case"eth_sendTransaction":return this.handleSendTransaction(r);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(r);case"personal_sign":return this.handlePersonalSign(r);case"eth_signTypedData_v4":return this.handleSignedTypedData(r);default:break}if(Gh(r.method)){let o=await he();if(await Yh(),!o||!this.address)throw new hn("Disconnected",4900);try{return(await this.walletProxy.rpc({address:this.rootAddress,accessToken:o,hdWalletIndex:this.walletIndex,request:{method:r.method,params:r.params}})).response.data}catch(n){throw console.error(n),new hn("Disconnected",4900)}}else return this.provider.send(r.method,r.params)}async connect(){let r=await he();if(!r||!this.address)return null;try{return(await this.walletProxy.connect({address:this.address,accessToken:r})).address}catch(o){return console.error(o),null}}},Io=class extends st{constructor(r){super(r,r.rpcTimeoutDuration)}},yn=class extends st{constructor(t){super(t,t.rpcTimeoutDuration)}sendAsync(t,r){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var U0=(e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");default:return e.code===4902||e.message?.includes("4902")}};function ai(e){return e.chainType==="ethereum"}function fo(e){return e.type==="ethereum"}var mr=class extends ca{constructor(r,o,n,a){super(r);this.chainType="ethereum";this.onAccountsChanged=r=>{r.length===0?this.onDisconnect():this.syncAccounts(r)};this.onChainChanged=r=>{this.wallets.forEach(o=>{o.chainId=za(r),this.walletClientType==="privy"&&Z.put(Il(o.address),r)}),this.emit("walletsUpdated")};this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")};this.onConnect=()=>{this.connected=!0,this.syncAccounts()};this.wallets=[],this.walletClientType=r,this.chains=o,this.defaultChain=n,this.rpcConfig=a,this.rpcTimeoutDuration=ni(a,r),this.connected=!1,this.initialized=!1}buildConnectedWallet(r,o,n,a){let i=async()=>!!this.wallets.find(s=>Mo(s.address)===Mo(r));return{type:"ethereum",address:Mo(r),chainId:o,meta:n,imported:a,switchChain:async s=>{if(!i)throw new Le("Wallet is not currently connected.");let l=this.wallets.find(g=>Mo(g.address)===Mo(r))?.chainId;if(!l)throw new Le("Unable to determine current chainId.");let d,p;if(typeof s=="number"?(d=`0x${s.toString(16)}`,p=s):(d=s,p=Number(s)),l===za(d))return;let m=this.chains.find(g=>g.id===p);if(!m)throw new Le(`Unsupported chainId: ${s}`);let h=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:d}]})};try{return await h()}catch(g){if(U0(g,this.walletClientType))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:d,chainName:m.name,nativeCurrency:m.nativeCurrency,rpcUrls:[m.rpcUrls.default?.http[0]??""],blockExplorerUrls:[m.blockExplorers?.default.url??""]}]}),h();throw this.walletClientType==="rainbow"&&g.message?.includes("wallet_switchEthereumChain")?new Le(`Rainbow does not support the chainId ${o}`):g}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:i,getEthereumProvider:async()=>{if(!await i())throw new Le("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await i())throw new Le("Wallet is not currently connected.");return new Qh(new Io(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await i())throw new Le("Wallet is not currently connected.");return new yn(this.proxyProvider)},sign:async s=>{if(!await i())throw new Le("Wallet is not currently connected.");return await this.sign(s)},disconnect:()=>{this.disconnect()}}}async syncAccounts(r){let o=r;try{if(o===void 0){let d=await os(()=>this.proxyProvider.request({method:"eth_accounts"}),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,d),Array.isArray(d)&&(o=d)}}catch(d){console.warn("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",d)}if(!o||!Array.isArray(o)||o.length<=0||!o[0])return;let n=o[0],a=Mo(n),i=[],s;if(this.walletClientType==="privy"){let d=Z.get(Il(a));this.chains.find(p=>p.id===Number(d))||(Z.del(Il(a)),d=null),s=d||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:s}]})}catch{console.warn(`Unable to switch embedded wallet to chain ID ${s} on initialization`)}}else try{let d=await os(()=>this.proxyProvider.request({method:"eth_chainId"}),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,d),typeof d=="string")s=d;else if(typeof d=="number")s=`0x${d.toString(16)}`;else throw new Error("Invalid chainId returned from provider")}catch(d){console.warn(`Failed to get chainId from provider, defaulting to ${Ip}`,d),s=Ip}let l=za(s);if(!i.find(d=>Mo(d.address)===a)){let d={name:this.walletBranding.name,icon:typeof this.walletBranding.icon=="string"?this.walletBranding.icon:void 0,id:this.walletBranding.id};i.push(this.buildConnectedWallet(Mo(n),l,d,this.connectorType==="embedded_imported"))}gs(i,this.wallets)||(this.wallets=i,this.emit("walletsUpdated"))}async getConnectedWallet(){let r=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort((o,n)=>n.connectedAt-o.connectedAt).find(o=>r.find(n=>Mo(n)===Mo(o.address)))||null}async isConnected(){let r=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(r)&&r.length>0}async sign(r){return await this.connect({showPrompt:!1}),new Qh(new Io(this.proxyProvider)).getSigner().signMessage(r)}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}};var B0=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],Xh=(e,t)=>e.makeWeb3Provider({options:t}),uc,mc=class extends mr{constructor(r,o,n,a,i,s){super("coinbase_wallet",r,o,n);this.connectorType="coinbase_wallet";this.displayName="Coinbase Wallet";if(this.proxyProvider=new st(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=a.coinbaseWallet.connectionOptions??"all",this.walletClientType=this.connectionOptions==="smartWalletOnly"?"coinbase_smart_wallet":"coinbase_wallet",this.walletClientType==="coinbase_smart_wallet"&&(this.displayName="Coinbase Smart Wallet"),!uc){let l=[o.id].concat(r.map(p=>p.id)),d=this.connectionOptions!=="eoaOnly"?l.filter(p=>!B0.includes(p)):[];d.length>0&&console.warn(`The following configured chains are not supported by the Coinbase Smart Wallet: ${d.join(", ")}`),uc=new F0({appName:i,appLogoUrl:s,appChainIds:l})}this.proxyProvider.setWalletProvider(Xh(uc,this.connectionOptions))}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:jo,id:"com.coinbase.wallet"}}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new Le("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([r[0]])}catch(r){throw _r(r)}}updateConnectionPreference(r){this.connectionOptions=r,this.walletClientType=r==="smartWalletOnly"?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(Xh(uc,this.connectionOptions))}};var Cs=class extends mr{constructor({provider:r,chains:o,defaultChain:n,rpcConfig:a,imported:i,walletIndex:s}){super("privy",o,n,a);this.connectorType="embedded";this.proxyProvider=r,this.walletIndex=s,i&&(this.connectorType="embedded_imported"),this.subscribeListeners()}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[Zn(r?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Ll,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}};import{jsx as Zh}from"react/jsx-runtime";var ii=({style:e,...t})=>Zh("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...e},...t,children:Zh("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})});import{jsx as Ir,jsxs as H0}from"react/jsx-runtime";var si=({style:e,...t})=>H0("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",...e},...t,children:[Ir("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),Ir("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"}),Ir("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"})]});import{jsx as Jh,jsxs as V0}from"react/jsx-runtime";var Wo=({style:e,...t})=>V0("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...e},...t,children:[Jh("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),Jh("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"})]});var ci=class extends mr{constructor(r,o,n,a,i){super(i||"unknown",r,o,n);this.connectorType="injected";this.proxyProvider=new st(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=a;let s=a.provider;this.proxyProvider.setWalletProvider(s)}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.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 r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new Le("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw _r(r)}}},li,di=class extends mr{constructor(r,o,n,a,i){super(i??"unknown",r,o,n);this.connectorType="injected";Tl(this,li,void 0);this.proxyProvider=new st(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(a),i==="metamask"?Sp(this,li,{name:"MetaMask",icon:si,id:"io.metamask"}):i==="phantom"&&Sp(this,li,{name:"Phantom",icon:Wo,id:"phantom"})}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return Wm(this,li)??{name:"Browser Extension",icon:ii,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new Le("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw _r(r)}}};li=new WeakMap;import{getAddress as F_}from"@ethersproject/address";import{Web3Provider as H_}from"@ethersproject/providers";import{isMobile as G0}from"react-device-detect";var fc=class extends ci{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{G0||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let t=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!t||t.length===0||!t[0])throw new Le("Unable to retrieve accounts");await this.syncAccounts([t[0]])}catch(t){throw _r(t)}}};var hc=class extends mr{constructor(r,o){super(r,[],o,{});this.connectorType="null";this.proxyProvider=new st(void 0,ra);this.connectorType=r}get walletBranding(){return{name:"Wallet",id:""}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw new Error("connect called for an uninstalled wallet via the NullConnector")}disconnect(){throw new Error("disconnect called for an uninstalled wallet via the NullConnector")}promptConnection(r){throw new Error(`promptConnection called for an uninstalled wallet via the NullConnector for ${r}`)}};var yc=class extends hc{constructor(t){super("phantom",t)}get walletBranding(){return{name:"Phantom",icon:Wo,id:"phantom"}}};var q0=["privy"],z0=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","crypto.com_wallet_extension"],K0=["coinbase_wallet","coinbase_smart_wallet"],Y0=["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"],Q0=["unknown"],X0=["phantom","solflare","glow"],Z0=[...z0,...K0,...Y0,...q0,...Q0,...X0];function jh(e){return Z0.includes(e)}function ey(e){return e.chainType==="solana"}function Dp(e){return e.type==="solana"}var $h=class extends ca{constructor(r,o){let n=jh(r.name.toLowerCase())?r.name.toLowerCase():"unknown";super(n);this.chainType="solana";this.connectorType="solana_adapter";this.disconnect=()=>{this.adapter.disconnect().then(()=>this.onDisconnect()).catch(r=>console.error("Error disconnecting",r))};this.promptConnection=async()=>{try{await this.adapter.connect()}catch(r){throw _r(r)}};this.onDisconnect=()=>{this.syncAccounts()};this.onConnect=r=>{this.syncAccounts()};this.onError=r=>{this.syncAccounts()};this.onReadyStateChange=r=>{r!=="Installed"&&(this.connected=!1),this.syncAccounts()};this.adapter=r,this.shouldAutoConnect=o,this.wallets=[]}get isInstalled(){return this.adapter.readyState==="Installed"}buildConnectedWallet(r,o){if(r.readyState!=="Installed"||!r.publicKey)throw Error("Wallet is not connected.");let n;"signMessage"in r&&(n=async(...s)=>{if(!r.connected)throw Error("Wallet is not connected.");return await r.signMessage(s[0])});let a;"sendTransaction"in r&&(a=async(...s)=>await r.sendTransaction(s[0],s[1],s[2]));let i;return"signTransaction"in r&&(i=async s=>await r.signTransaction(s)),{type:"solana",address:r.publicKey.toBase58(),meta:o,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>r.connected,disconnect:()=>{try{r.disconnect()}catch{console.error("Wallet does not support programmatic disconnect")}},getProvider:Ht,signMessage:n,sendTransaction:a,signTransaction:i}}async syncAccounts(){if(this.adapter.readyState!=="Installed"||!this.adapter.publicKey)this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"));else{let r={name:this.walletBranding.name,icon:typeof this.walletBranding.icon=="string"?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find(o=>this.adapter.publicKey&&o.address===this.adapter.publicKey.toBase58())||(this.wallets=[this.buildConnectedWallet(this.adapter,r)],this.emit("walletsUpdated"))}}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAutoConnect&&await this.adapter.autoConnect().catch(console.error),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort((r,o)=>o.connectedAt-r.connectedAt)[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}};import{EthereumProvider as j0,OPTIONAL_EVENTS as $0,OPTIONAL_METHODS as ew}from"@walletconnect/ethereum-provider";import{isMobile as tw}from"react-device-detect";import{jsx as pi,jsxs as J0}from"react/jsx-runtime";var vs=({style:e,...t})=>{let{app:r}=x();return J0("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[pi("rect",{width:"28",height:"28",rx:"3",fill:r?.appearance.palette.colorScheme==="dark"?"#3396ff":"#141414"}),pi("g",{clipPath:"url(#clip0_1765_9946)",children:pi("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),pi("defs",{children:pi("clipPath",{id:"clip0_1765_9946",children:pi("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};var ho=class extends mr{constructor(r,o,n,a,i,s,l,d){super(d||"unknown",n,a,o);this.connectorType="wallet_connect_v2";this.privyAppId=s,this.privyAppName=l,this.walletConnectCloudProjectId=r,this.rpcConfig=o,this.shouldEnforceDefaultChainOnConnect=i,this.proxyProvider=new st(void 0,this.rpcTimeoutDuration),d&&(this.walletEntry=Xl[d],this.walletClientType=d)}async initialize(){let r=await this.createProvider();if(this.provider=r,this.proxyProvider.setWalletProvider(r),this.subscribeListeners(),r.session){if(this.walletProvider?.session?.peer.metadata.url){let n=Ql(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=n?.entry,this.walletClientType=n?.walletClientType||"unknown"}this.connected=!0,await this.syncAccounts()}this.initialized=!0,this.emit("initialized");let{WalletConnectModal:o}=await import("@walletconnect/modal");this.modal=new o({projectId:this.walletConnectCloudProjectId,themeVariables:{"--wcm-z-index":"1000000"}}),this.modal.subscribeModal(n=>{!n.open&&!this.walletProvider?.session&&this.onQrModalClosed&&this.onQrModalClosed()})}async connect(r){return r.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){return this.walletClientType==="metamask"?{name:"MetaMask",icon:si,id:"io.metamask"}:{name:Hm(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:this.walletProvider?.session?.peer.metadata.icons?.[0]||vs,id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(r){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletEntry=Xl[r],this.walletClientType=r,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,Th(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise((r,o)=>{let n=()=>{o(new oi)};this.onQrModalClosed=n,(async()=>{let i="",s=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(s?.length&&(i=s[0]),!i||i==="")throw new Le("Unable to retrieve address");if(this.walletProvider?.session?.peer.metadata.url){let l=Ql(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=l?.entry,this.walletClientType=l?.walletClientType||"unknown",this.proxyProvider.rpcTimeoutDuration=ni(this.rpcConfig,this.walletClientType)}this.connected=!0,await this.syncAccounts(s),r()})().catch(i=>{if(i){o(_r(i));return}o(new Le("Unknown error during connection"))}).finally(()=>this.modal?.closeModal())})}disconnect(){this.walletProvider?.disconnect().then(()=>this.onDisconnect()).catch(()=>console.warn("Unable to disconnect Wallet Connect provider"))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(r){this.proxyProvider.setWalletProvider(r)}async createProvider(){let r={};for(let i of this.chains){let s=Gm(i.id,this.chains,this.rpcConfig,this.privyAppId);s&&(r[i.id]=s)}let o=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],n=this.chains.map(i=>i.id),a=await j0.init({projectId:this.walletConnectCloudProjectId,chains:o,optionalChains:n,optionalEvents:$0,optionalMethods:ew,rpcMap:r,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.toString(),icons:[]}});return a.on("display_uri",i=>{if(a.signer.abortPairingAttempt(),tw&&this.walletEntry){let{redirect:s,href:l}=wh(i,this.walletEntry);Sh({href:l,name:this.walletEntry.displayName}),this.redirectUri=s;let d=bh(i,this.walletEntry);d?.redirect&&(this.fallbackUniversalRedirectUri=d.redirect),Zl(s,"_self")}else this.modal?.openModal({uri:i,chains:[this.defaultChain.id]})}),a.on("connect",()=>{if(this.modal?.closeModal(),a.session?.peer.metadata.url){let i=Ql(a.session?.peer.metadata.url);this.walletEntry=i?.entry,this.walletClientType=i?.walletClientType||"unknown"}}),a}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider?.enable()}};var Fp=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses")?.split(" ").filter(o=>rw(o)).map(o=>ty(o));return t?.length?!!e?.linkedAccounts.filter(o=>o.type=="wallet"&&t.includes(o.address)).length:!1},ni=(e,t)=>e.rpcTimeouts?e.rpcTimeouts[t]||ra:ra,ws=class extends ow{constructor(r,o,n,a,i,s,l,d,p,m,h){super();this.addSolanaWalletConnector=async r=>{this.findWalletConnector("solana_adapter",r.walletClientType)||this.addWalletConnector(r)};this.getEthereumProvider=()=>{let r=this.wallets[0],o=this.walletConnectors.find(n=>n.wallets.find(a=>a.address===r?.address));return!r||!o?new st:o.proxyProvider};this.privyAppId=r,this.walletConnectCloudProjectId=o,this.rpcConfig=n,this.chains=a,this.defaultChain=i,this.walletConnectors=[],this.initialized=!1,this.store=s,this.walletList=l,this.shouldEnforceDefaultChainOnConnect=d,this.externalWalletConfig=p,this.privyAppName=m,this.privyAppLogo=h,this.storedConnections=Up()}get wallets(){let r=new Set,o=this.walletConnectors.flatMap(a=>a.wallets).sort((a,i)=>a.connectedAt&&i.connectedAt?i.connectedAt-a.connectedAt:0).filter(a=>{let i=`${a.address}${a.walletClientType}${a.connectorType}`;return r.has(i)?!1:(r.add(i),!0)}),n=o.findIndex(a=>a.address===(this.activeWallet?this.activeWallet:"unknown"));return n>=0&&o.unshift(o.splice(n,1)[0]),o}async initialize(){if(this.initialized)return;Z.get(Rp)&&(Z.getKeys().forEach(o=>{o.startsWith("walletconnect")&&Z.del(o)}),Z.del(Rp));let r=Vm(this.store,this.walletList,this.externalWalletConfig).then(o=>{o.forEach(({type:n,eip6963InjectedProvider:a,legacyInjectedProvider:i})=>{this.createEthereumWalletConnector("injected",n,{eip6963InjectedProvider:a,legacyInjectedProvider:i})})});this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector("coinbase_wallet","coinbase_wallet"),!un()&&this.walletList.includes("phantom")&&this.createEthereumWalletConnector("phantom","phantom"),this.externalWalletConfig.walletConnect.enabled&&this.createEthereumWalletConnector("wallet_connect_v2","unknown"),this.externalWalletConfig.solana.connectors?.get().forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.(o=>{o?.forEach(this.addSolanaWalletConnector)}),await r,this.initialized=!0}findWalletConnector(r,o){return r==="wallet_connect_v2"?this.walletConnectors.filter(ai).find(n=>n.connectorType===r)??null:this.walletConnectors.filter(ai).find(n=>n.connectorType===r&&n.walletClientType===o)??null}findSolanaWalletConnector(r,o){return this.walletConnectors.filter(ey).find(n=>n.connectorType===r&&n.walletClientType===o)??null}findEmbeddedWalletConnectors(){return this.walletConnectors.filter(r=>r.connectorType==="embedded")}onInitialized(r){r.wallets.forEach(o=>{let n=this.storedConnections.find(a=>a.address===o.address&&a.connectorType===o.connectorType&&a.walletClientType===o.walletClientType);n&&(o.connectedAt=n.connectedAt)}),this.saveConnectionHistory(),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(r){r.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnectors({walletProxy:r,rootWallet:o,embeddedWallets:n,defaultChain:a,appId:i}){for(let s of n){let l=this.findEmbeddedWalletConnectors().find(d=>d.walletIndex===s.walletIndex);if(l&&ai(l))l.proxyProvider.walletProxy=r;else{let d=new ys({walletProxy:r,address:s.address,rootAddress:o.address,rpcConfig:this.rpcConfig,chains:this.chains,appId:i,chainId:a.id,walletIndex:s.walletIndex}),p=new Cs({provider:d,chains:this.chains,defaultChain:a,rpcConfig:this.rpcConfig,imported:!1,walletIndex:s.walletIndex});this.addWalletConnector(p)}}}addImportedWalletConnector(r,o,n,a){let i=this.findWalletConnector("embedded_imported","privy");if(i&&ai(i))i.proxyProvider.walletProxy=r;else{let s=new ys({walletProxy:r,rootAddress:o,address:o,walletIndex:0,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:n.id}),l=new Cs({provider:s,chains:this.chains,walletIndex:0,defaultChain:n,rpcConfig:this.rpcConfig,imported:!0});this.addWalletConnector(l)}}removeEmbeddedWalletConnectors(){this.walletConnectors=this.walletConnectors.filter(r=>r.connectorType!=="embedded"),this.saveConnectionHistory(),this.storedConnections=Up(),this.emit("walletsUpdated")}removeImportedWalletConnector(){let r=this.findWalletConnector("embedded_imported","privy");if(r){let o=this.walletConnectors.indexOf(r);this.walletConnectors.splice(o,1),this.saveConnectionHistory(),this.storedConnections=Up(),this.emit("walletsUpdated")}}async createEthereumWalletConnector(r,o,n){let a=this.findWalletConnector(r,o);if(a&&ai(a))return a instanceof ho&&a.resetConnection(o),a;let s=(()=>{if(r==="injected"){if(o==="metamask"&&n?.eip6963InjectedProvider)return new fc(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask");if(o==="metamask"&&n?.legacyInjectedProvider)return new di(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask");if(o==="phantom"&&n?.legacyInjectedProvider)return new di(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom");if(n?.legacyInjectedProvider&&o==="unknown_browser_extension")return new di(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider);if(n?.eip6963InjectedProvider)return new ci(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,o)}else return r==="coinbase_wallet"?new mc(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):r==="phantom"?new yc(this.defaultChain):new ho(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,this.privyAppName,o)})();return s&&this.addWalletConnector(s),s||null}addWalletConnector(r){this.walletConnectors.push(r),r.on("initialized",()=>this.onInitialized(r)),r.on("walletsUpdated",()=>this.onWalletsUpdated(r)),r.initialize().catch(o=>{console.debug("Failed to initialize connector",o)})}saveConnectionHistory(){let r=this.wallets.map(o=>({address:o.address,connectorType:o.connectorType,walletClientType:o.walletClientType,connectedAt:o.connectedAt}));Z.put(_p,r)}async activeWalletSign(r){let o=this.wallets,n=o.length>0?o[0]:null;return!n||!fo(n)?null:n.sign(r)}setActiveWallet(r){this.activeWallet=ty(r),this.emit("walletsUpdated")}};function gs(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let o=e[r],n=t[r];if(o?.address!==n?.address||o&&n&&fo(o)&&fo(n)&&o?.chainId!==n?.chainId||o?.connectorType!==n?.connectorType||o?.connectedAt!==n?.connectedAt||o?.walletClientType!==n?.walletClientType||o?.isConnected!==n?.isConnected||o?.linked!==n?.linked)return!1}return!0}var nw=e=>e&&typeof e.address=="string"&&typeof e.connectorType=="string"&&typeof e.walletClientType=="string"&&typeof e.connectedAt=="number",Up=()=>{let e=Z.get(_p);return e&&Array.isArray(e)&&e.map(o=>nw(o)).every(Boolean)?e:[]};import{ofetch as aw}from"ofetch";var iw=[Bl,Vl,Hl,Kl],gc=class{constructor({appId:t,appClientId:r,client:o,defaults:n}){this.appId=t,this.appClientId=r,this.clientAnalyticsId=o.clientAnalyticsId,this.sdkVersion=Pp,this.client=o,this.defaults=n,this.fallbackApiUrl=o.fallbackApiUrl,this.baseFetch=aw.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:a,options:i})=>{let s=new Headers(i.headers);s.set("privy-app-id",this.appId),this.appClientId&&s.set("privy-client-id",this.appClientId),s.set("privy-ca-id",this.clientAnalyticsId||""),s.set("privy-client",`react-auth:${this.sdkVersion}`);let l=iw.includes(a.toString());if(!s.has("authorization")){let d=await this.client.getAccessToken({disableAutoRefresh:l});d!==null&&s.set("authorization",`Bearer ${d}`)}i.headers=s,i.retryDelay&&(i.retryDelay=i.retryDelay*3)},onRequestError:({error:a})=>{if(a instanceof DOMException&&a.name==="AbortError")throw new Nm}})}async get(t,r){try{return await this.baseFetch(t,r)}catch(o){throw de(o)}}async post(t,r,o){try{return await this.baseFetch(t,{method:"POST",...r?{body:r}:{},...o})}catch(n){throw de(n)}}async delete(t,r){try{return await this.baseFetch(t,{method:"DELETE",...r})}catch(o){throw de(o)}}};var ry=e=>({challenge:e.challenge,allowCredentials:e.allow_credentials?.map(t=>({id:t.id,type:t.type,transports:t.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});import gn from"js-cookie";function oy(e){return e instanceof mn?"email":e instanceof fn?"sms":e instanceof Jo?"siwe":e instanceof ja?"guest":e instanceof Ja?"custom_auth":e instanceof Ro?e.meta.provider:null}import{isSafari as sw}from"react-device-detect";function Cc(){return!(sw&&window.location.origin.startsWith("http://localhost"))}import*as ny from"jose";var jr=class{static parse(t){try{return new jr(t)}catch{return null}}constructor(t){this.value=t,this._decoded=ny.decodeJwt(t)}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(t=0){let r=Date.now(),o=(this.expiration-t)*1e3;return r>=o}};var lw=30,vc=class{constructor(){this.authenticateOnce=new Ke(async t=>this._authenticate(t)),this.linkOnce=new Ke(async t=>this._link(t)),this.refreshOnce=new Ke(this._refresh.bind(this)),this.destroyOnce=new Ke(this._destroy.bind(this)),this.forkSessionOnce=new Ke(this._forkSession.bind(this))}get token(){try{let t=Z.get(Jn);return typeof t=="string"?new jr(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=Z.get(kl);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=Z.get(as);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}getProviderAccessToken(t){try{let r=Z.get(ss(t));if(typeof r=="string"){let o=new jr(r);return o.isExpired()?(Z.del(ss(t)),null):o.value}else return null}catch(r){return console.error(r),null}}get mightHaveServerCookies(){try{let t=gn.get(Rl);return t!==void 0&&t.length>0}catch(t){console.error(t)}return!1}hasRefreshCredentials(){return this.mightHaveServerCookies||typeof this.token=="string"&&typeof this.refreshToken=="string"&&this.refreshToken!==$m}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=jr.parse(this.token);return t!==null&&!t.isExpired(lw)}authenticate(t){return this.authenticateOnce.execute(t)}link(t){return this.linkOnce.execute(t)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(t,r){typeof r=="string"?Z.put(ss(t),r):Z.del(ss(t))}async _authenticate(t){try{let r=await t.authenticate(),{user:o,is_new_user:n,oauth_tokens:a}=r;this.handleTokenResponse(r);let i=a,s=i?{provider:i.provider,accessToken:i.access_token,accessTokenExpiresInSeconds:i.access_token_expires_in_seconds,refreshToken:i.refresh_token,refreshTokenExpiresInSeconds:a.refresh_token_expires_in_seconds,scopes:i.scopes}:void 0,l=oy(t);return l&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:l,isNewUser:n}}),l==="siwe"&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}}),{user:St(o),isNewUser:n,oAuthTokens:s}}catch(r){throw console.warn("Error authenticating session"),qe(r)}}async _link(t){try{let r=await t.link(),o=r.oauth_tokens,n=o?{provider:o.provider,accessToken:o.access_token,accessTokenExpiresInSeconds:o.access_token_expires_in_seconds,refreshToken:o.refresh_token,refreshTokenExpiresInSeconds:o.refresh_token_expires_in_seconds,scopes:o.scopes}:void 0;return{user:St(r),oAuthTokens:n}}catch(r){throw console.warn("Error linking account"),qe(r)}}async _refresh(){if(!this.api)throw new C("Session has no API instance");if(!this.client)throw new C("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,r=this.refreshToken,o=this.forkedToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let n;if(t&&r||this.mightHaveServerCookies){let a={};t&&(a.authorization=`Bearer ${t}`);let i=r?{refresh_token:r}:{};n=await this.api.post(Bl,i,{headers:a}),o&&this.clearForkedToken()}else if(o)n=await this.api.post(Vl,{refresh_token:o}),this.clearForkedToken();else return null;return this.handleTokenResponse(n),St(n.user)}catch(n){if(n instanceof xr&&n.privyErrorCode==="missing_or_invalid_token")return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw qe(n)}}handleTokenResponse(t){t.session_update_action?t.session_update_action==="set"?(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token)):t.session_update_action==="clear"?this.destroyLocalState():t.session_update_action==="ignore"&&t.token&&(this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token)):(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token))}async _destroy(){try{await this.api?.post(Hl,{refresh_token:this.refreshToken})}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new C("Session has no API instance");let t=this.refreshToken;try{let r=await this.api.post(Ef,{refresh_token:t});return this.storeRefreshToken(r.refresh_token),this.storeToken(r.token),r.new_session_refresh_token}catch(r){throw qe(r)}}destroyLocalState(){this.storeRefreshToken(null),this.storeToken(null),this.clearIdentityToken(),this.clearForkedToken()}storeToken(t){if(typeof t=="string"){let r=Z.get(Jn);if(Z.put(Jn,t),!this.client?.useServerCookies){let o=jr.parse(t)?.expiration;gn.set(Ap,t,{sameSite:"Strict",secure:Cc(),expires:o?new Date(o*1e3):void 0})}r!==t&&this.client?.onStoreToken?.(t)}else Z.del(Jn),gn.remove(Ap),this.client?.onDeleteToken?.()}storeRefreshToken(t){typeof t=="string"?(Z.put(kl,t),this.client?.useServerCookies||gn.set(Rl,"t",{sameSite:"Strict",secure:Cc(),expires:30})):(Z.del(kl),gn.remove(Qm),gn.remove(Rl))}storeIdentityToken(t){if(this.client?.useServerCookies)return;Z.put(xp,t);let r=jr.parse(t)?.expiration;gn.set(kp,t,{sameSite:"Strict",secure:Cc(),expires:r?new Date(r*1e3):void 0})}clearIdentityToken(){Z.del(xp),gn.remove(kp)}clearForkedToken(){Z.del(as)}};var Bp,wc,ay,bs=class{constructor(t){Tl(this,wc);this.apiUrl=t.apiUrl||xl,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!!t.apiUrl&&t.apiUrl.startsWith("https://privy."),this.timeout=t.timeout||zm,this.appId=t.appId,this.appClientId=t.appClientId,this.clientAnalyticsId=Lm(this,wc,ay).call(this),Bp||(Bp=new vc),this.session=Bp,this.api=this.generateApi(),this.session.client=this}initializeConnectorManager({walletConnectCloudProjectId:t,rpcConfig:r,chains:o,defaultChain:n,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:s,externalWalletConfig:l,appName:d}){this.connectors||(this.connectors=new ws(this.appId,t,r,o,n,a,i,s,l,d))}sessionHasActiveToken(){return this.session.hasActiveToken()}generateApi(){let t=new gc({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=t,t}updateApiUrl(t){this.apiUrl=t||this.fallbackApiUrl,this.api=this.generateApi(),t&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new C("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new C("No auth flow in progress.");let{oAuthTokens:t}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:t}}storeProviderAccessToken(t,r){this.session.storeProviderAccessToken(t,r)}getProviderAccessToken(t){return this.session.getProviderAccessToken(t)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(t){t.linkedAccounts.filter(o=>o.type==="cross_app").forEach(o=>{this.storeProviderAccessToken(o.providerApp.id,null)})}startAuthFlow(t){return t.api=this.api,this.authFlow=t,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(ph,{action:"verify"})}catch(t){throw de(t)}}async initMfaPasskeyVerification(){try{let t=await this.api.post(uh,{});return ry(t.options)}catch(t){throw de(t)}}async acceptTerms(){try{let t=await this.api.post(mh,{});return St(t)}catch(t){throw qe(t)}}async unlinkEmail(t){try{let r=await this.api.post(Vf,{address:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkPhone(t){try{let r=await this.api.post(Yf,{phoneNumber:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkEthereumWallet(t){try{let r=await this.api.post(xf,{address:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkSolanaWallet(t){try{let r=await this.api.post(Mf,{address:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkOAuth(t,r){try{let o=await this.api.post(Jf,{provider:t,subject:r});return await this.getAuthenticatedUser()??St(o)}catch(o){throw qe(o)}}async unlinkFarcaster(t){try{let r=await this.api.post(Df,{fid:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkTelegram(t){try{let r=await this.api.post(ch,{telegram_user_id:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async unlinkPasskey(t){try{let r=await this.api.post(ih,{credential_id:t});return await this.getAuthenticatedUser()??St(r)}catch(r){throw qe(r)}}async createAnalyticsEvent({eventName:t,payload:r,timestamp:o,options:n}){if(!(typeof window>"u"))try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(Kl,{event_name:t,client_id:this.clientAnalyticsId,payload:{...r||{},clientTimestamp:o?o.toISOString():new Date().toISOString()}},{retry:-1,keepalive:n?.keepAlive??!1})}catch{}}async signMoonpayOnRampUrl(t){try{return this.api.post(yh,t)}catch(r){throw qe(r)}}async initCoinbaseOnRamp(t){try{return this.api.post(gh,t)}catch(r){throw qe(r)}}async getCoinbaseOnRampStatus({partnerUserId:t}){try{return this.api.get(`${Ch}?partnerUserId=${t}`)}catch(r){throw qe(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){return this.session.hasActiveToken()?this.session.hasRefreshCredentials()?jr.parse(this.session.token)?.audience!==this.appId?(await this.logout(),null):this.session.token:(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getSmartWalletsConfig(){try{let t={},r=this.session.token;r&&(t.authorization=`Bearer ${r}`);let o=await this.api.get(`/api/v1/apps/${this.appId}/smart_wallets`,{baseURL:this.fallbackApiUrl,headers:t});return o.enabled?{enabled:o.enabled,smartWalletType:o.smart_wallet_type,configuredNetworks:o.configured_networks.map(n=>({chainId:n.chain_id,bundlerUrl:n.bundler_url,paymasterUrl:n.paymaster_url}))}:{enabled:o.enabled}}catch(t){throw qe(t)}}async getServerConfig(){try{let t={},r=this.session.token;r&&(t.authorization=`Bearer ${r}`);let o=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl,headers:t}),n=o.telegram_auth_config?{botId:o.telegram_auth_config.bot_id,botName:o.telegram_auth_config.bot_name,linkEnabled:o.telegram_auth_config.link_enabled,seamlessAuthEnabled:o.telegram_auth_config.seamless_auth_enabled}:void 0,a=o.funding_config?{methods:o.funding_config.methods,defaultRecommendedAmount:o.funding_config.default_recommended_amount,defaultRecommendedCurrency:o.funding_config.default_recommended_currency,promptFundingOnWalletCreation:o.funding_config.prompt_funding_on_wallet_creation}:void 0;return{id:o.id,name:o.name,verificationKey:o.verification_key,logoUrl:o.logo_url||void 0,accentColor:o.accent_color||void 0,showWalletLoginFirst:o.show_wallet_login_first,allowlistConfig:{errorTitle:o.allowlist_config.error_title,errorDetail:o.allowlist_config.error_detail,errorCtaText:o.allowlist_config.cta_text,errorCtaLink:o.allowlist_config.cta_link},walletAuth:o.wallet_auth,emailAuth:o.email_auth,smsAuth:o.sms_auth,googleOAuth:o.google_oauth,twitterOAuth:o.twitter_oauth,discordOAuth:o.discord_oauth,githubOAuth:o.github_oauth,spotifyOAuth:o.spotify_oauth,instagramOAuth:o.instagram_oauth,tiktokOAuth:o.tiktok_oauth,linkedinOAuth:o.linkedin_oauth,appleOAuth:o.apple_oauth,farcasterAuth:o.farcaster_auth,passkeyAuth:o.passkey_auth,telegramAuth:o.telegram_auth,termsAndConditionsUrl:o.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:o.embedded_wallet_config?.create_on_login,userOwnedRecoveryOptions:o.embedded_wallet_config.user_owned_recovery_options,requireUserOwnedRecoveryOnCreate:o.embedded_wallet_config.require_user_owned_recovery_on_create},privacyPolicyUrl:o.privacy_policy_url,requireUsersAcceptTerms:o.require_users_accept_terms,customApiUrl:o.custom_api_url,walletConnectCloudProjectId:o.wallet_connect_cloud_project_id,fiatOnRampEnabled:o.fiat_on_ramp_enabled,captchaEnabled:o.captcha_enabled,captchaSiteKey:o.captcha_site_key,createdAt:new Date(o.created_at*1e3),updatedAt:new Date(o.updated_at*1e3),mfaMethods:o.mfa_methods,enforceWalletUis:o.enforce_wallet_uis,legacyWalletUiConfig:o.legacy_wallet_ui_config,telegramAuthConfiguration:n,fundingConfig:a}}catch(t){throw qe(t)}}async getUsdTokenPrice(t){try{return(await this.api.get(`/api/v1/token_price?chainId=${t.id}&tokenSymbol=${t.nativeCurrency.symbol}`)).usd}catch{console.error(`Unable to fetch token price for chain with id ${t.id}`);return}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch{console.error("Unable to fetch token price for SOL");return}}async requestFarcasterSignerStatus(t){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:t})}catch(r){throw console.error("Unable to fetch Farcaster signer status"),r}}async forkSession(){return await this.session.forkSession()}async generateSiweNonce({address:t,captchaToken:r}){try{return(await this.api.post(Tf,{address:t,token:r})).nonce}catch(o){throw qe(o)}}async authenticateWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:a,mode:i}){return await this.api.post(Sf,{message:t,signature:r,chainId:o,walletClientType:n,connectorType:a,mode:i})}async linkWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:a}){return await this.api.post(Pf,{message:t,signature:r,chainId:o,walletClientType:n,connectorType:a})}async linkSmartWallet({message:t,signature:r,smartWalletType:o}){try{let n=await this.api.post(Af,{message:t,signature:r,smart_wallet_type:o});return St(n)}catch(n){throw qe(n)}}async linkWithSiwe({message:t,signature:r,chainId:o,walletClientType:n,connectorType:a}){try{let i=await this.linkWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:a});return St(i)}catch(i){throw qe(i)}}async generateSiwsNonce({address:t,captchaToken:r}){try{return(await this.api.post(Rf,{address:t,token:r})).nonce}catch(o){throw qe(o)}}async authenticateWithSiwsInternal({message:t,signature:r,walletClientType:o,connectorType:n,mode:a}){return await this.api.post(_f,{message:t,signature:r,walletClientType:o,connectorType:n,mode:a})}async sendAccountTransferRequest({nonce:t,account:r,accountType:o,chainId:n,walletClientType:a,connectorType:i,telegramAuthResult:s,farcasterEmbeddedAddress:l}){try{let d,p;switch(o){case"email":d=qf,p={nonce:t,email:r};break;case"sms":d=Zf,p={nonce:t,phoneNumber:r};break;case"siwe":if(d=kf,!n||!a||!i)throw Error("Wallet parameters must be defined");p={nonce:t,address:r,chainId:n,walletClientType:a,connectorType:i};break;case"farcaster":d=Uf,p={nonce:t,farcaster_id:r,farcaster_embedded_address:l};break;case"telegram":d=dh,p={nonce:t,telegram_auth_result:s};break;case"custom":throw Error("Invalid transfer account type");case"guest":throw Error("Invalid transfer account type");case"passkey":throw Error("Invalid transfer account type");default:d=jf,p={nonce:t,subject:r}}let m=await this.api.post(d,p);return await this.getAuthenticatedUser()??St(m)}catch(d){throw qe(d)}}async linkWithSiwsInternal({message:t,signature:r,walletClientType:o,connectorType:n}){return await this.api.post(If,{message:t,signature:r,walletClientType:o,connectorType:n})}async linkWithSiws({message:t,signature:r,walletClientType:o,connectorType:n}){try{let a=await this.linkWithSiwsInternal({message:t,signature:r,walletClientType:o,connectorType:n});return St(a)}catch(a){throw qe(a)}}};wc=new WeakSet,ay=function(){if(typeof window>"u")return null;try{let r=Z.get(is);if(typeof r=="string"&&r.length>0)return r}catch{}let t=cw();try{return Z.put(is,t),t}catch{return t}};import{Turnstile as hw}from"@marsidev/react-turnstile";import{useEffect as yw,useMemo as gw}from"react";import{useMemo as dw,useRef as pw,useContext as uw,useState as Hp,createContext as mw}from"react";import{jsx as fw}from"react/jsx-runtime";var iy=mw({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:Ht,setError:Ht,setExecuting:Ht,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:Ht,reset:Ht,execute:Ht}),Lt=class extends pr{constructor(r,o,n){super(r||"Captcha failed");this.type="Captcha";o instanceof Error&&(this.cause=o),this.privyErrorCode=n}},sy=({children:e,id:t,captchaSiteKey:r,captchaEnabled:o})=>{let n=pw(null),[a,i]=Hp(),[s,l]=Hp(),[d,p]=Hp(!1),m=dw(()=>o?!d&&!a&&!s?{status:"ready"}:d&&!a&&!s?{status:"loading"}:a&&!s?{status:"success",token:a}:s?{status:"error",error:s}:{status:"ready"}:{status:"disabled"},[o,a,s,d]);return fw(iy.Provider,{value:{...m,ref:n,enabled:o,siteKey:r,appId:t,setToken:i,setError:l,setExecuting:p,remove(){o&&(n.current?.remove(),p(!1),l(void 0),i(void 0))},reset(){o&&(n.current?.reset(),p(!1),l(void 0),i(void 0))},execute(){o&&(p(!0),n.current?.execute())},async waitForResult(){if(!o)return"";try{return await Bm(()=>n.current?.getResponse(),{interval:200,timeout:2e4})}catch{throw new Lt("Captcha failed",null,"captcha_timeout")}}},children:e})},Te=()=>uw(iy);import{jsx as ly}from"react/jsx-runtime";var Vp=e=>{let{enabled:t,siteKey:r,appId:o,setError:n,setToken:a,setExecuting:i,ref:s}=Te(),[,l]=gw(()=>r?.split("t:")||[],[r]);if(yw(()=>s.current?.remove,[]),!t)return null;if(!l)throw new Error("Unsupported captcha site key");return ly("div",{className:"hidden h-0 w-0",children:ly(hw,{...e,ref:s,siteKey:l,options:{action:o,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?.(),n("Captcha failed"),i(!1)},onSuccess:d=>{e.onSuccess?.(d),a(d),i(!1)},onExpire:()=>{e.onExpire?.();try{s.current?.reset(),n(void 0),a(void 0)}catch{n("expired_and_failed_reset")}}})})};import{useCallback as IA,useEffect as Bv,useRef as MA,useState as WA}from"react";import Gv from"styled-components";function Gp(e){ze("configureMfa",e)}import Fw from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import hy from"styled-components";import da,{css as cy}from"styled-components";import zp from"styled-components";import{Fragment as vw,jsx as qp,jsxs as ww}from"react/jsx-runtime";var ht=({success:e,fail:t})=>ww(vw,{children:[qp(yt,{className:e?"success":t?"fail":""}),qp(Es,{className:e?"success":t?"fail":""})]}),yt=zp.span`
|
|
24
24
|
&& {
|
|
25
25
|
width: 82px;
|
|
26
26
|
height: 82px;
|
|
@@ -525,7 +525,7 @@ Resources:
|
|
|
525
525
|
display: flex;
|
|
526
526
|
justify-content: center;
|
|
527
527
|
align-items: center;
|
|
528
|
-
`;import{Fragment as Qw,jsx as yr,jsxs as hi}from"react/jsx-runtime";var Yw=()=>yr(vy,{children:yr(Rc,{iconSize:60})}),wy=({address:e,onClose:t,onRetry:r})=>{let{defaultChain:o}=_e(),n=o.blockExplorers?.default.url??"https://etherscan.io";return hi(Qw,{children:[yr(k,{onClose:t,backFn:r}),hi(xc,{children:[yr(Yw,{}),hi(Ps,{children:[yr("h3",{children:"Check account assets before transferring"}),yr("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."}),hi(Cy,{children:[yr("p",{children:" To check your balance, you can:"}),yr(Qp,{children:"Log out and log back into the other account, or "}),hi(Qp,{children:["Copy your wallet address and use a"," ",yr("u",{children:yr("a",{target:"_blank",href:n,children:"block explorer"})})," ","to see if the account holds any assets."]})]}),hi(kc,{onClick:()=>navigator.clipboard.writeText(e).catch(console.error),children:[yr(Kw,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),yr(Rr,{address:e,showCopyIcon:!1}),yr(gy,{})]})]})]}),yr(
|
|
528
|
+
`;import{Fragment as Qw,jsx as yr,jsxs as hi}from"react/jsx-runtime";var Yw=()=>yr(vy,{children:yr(Rc,{iconSize:60})}),wy=({address:e,onClose:t,onRetry:r})=>{let{defaultChain:o}=_e(),n=o.blockExplorers?.default.url??"https://etherscan.io";return hi(Qw,{children:[yr(k,{onClose:t,backFn:r}),hi(xc,{children:[yr(Yw,{}),hi(Ps,{children:[yr("h3",{children:"Check account assets before transferring"}),yr("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."}),hi(Cy,{children:[yr("p",{children:" To check your balance, you can:"}),yr(Qp,{children:"Log out and log back into the other account, or "}),hi(Qp,{children:["Copy your wallet address and use a"," ",yr("u",{children:yr("a",{target:"_blank",href:n,children:"block explorer"})})," ","to see if the account holds any assets."]})]}),hi(kc,{onClick:()=>navigator.clipboard.writeText(e).catch(console.error),children:[yr(Kw,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),yr(Rr,{address:e,showCopyIcon:!1}),yr(gy,{})]})]})]}),yr(V,{})]})};import{Fragment as t4,jsx as qt,jsxs as yi}from"react/jsx-runtime";var Ey=()=>{let{initiateAccountTransfer:e,closePrivyModal:t}=R(),{data:r,navigate:o,lastScreen:n,setModalData:a}=x(),[i,s]=by(void 0),[l,d]=by(!1);return i?qt(wy,{address:i,onClose:t,onRetry:()=>s(void 0)}):qt(Jw,{onClose:t,onInfo:()=>s(r?.accountTransfer?.embeddedWalletAddress),onClick:async()=>{try{if(!r?.accountTransfer?.nonce||!r?.accountTransfer?.account||!r?.accountTransfer?.account)throw new Error("missing account transfer inputs");await e({nonce:r?.accountTransfer?.nonce,account:r?.accountTransfer?.account,accountType:r?.accountTransfer?.linkMethod,walletClientType:r?.accountTransfer?.walletClientType,connectorType:r?.accountTransfer?.connectorType,chainId:r?.accountTransfer?.chainId,telegramAuthResult:r?.accountTransfer?.telegramAuthResult,farcasterEmbeddedAddress:r?.accountTransfer?.farcasterEmbeddedAddress}),d(!0),setTimeout(t,1e3)}catch(m){a({errorModalData:{error:m,previousScreen:n||"LINK_CONFLICT_SCREEN"}}),o("ERROR_SCREEN",!0)}},data:r,transferSuccess:l})},Jw=({onClose:e,onClick:t,onInfo:r,data:o,transferSuccess:n})=>{if(!o?.accountTransfer?.linkMethod||!o?.accountTransfer?.displayName)return;let a={method:o?.accountTransfer?.linkMethod,handle:o?.accountTransfer?.displayName,disclosedAccount:o?.accountTransfer?.embeddedWalletAddress?{type:"wallet",handle:o?.accountTransfer?.embeddedWalletAddress}:void 0},{title:i,detail:s}=e4(a);return yi(t4,{children:[qt(k,{closeable:!0}),yi(xc,{children:[qt(Ye,{children:yi("div",{children:[qt(fi,{color:"var(--privy-color-error)"}),qt(Xw,{height:38,width:38,stroke:"var(--privy-color-error)"})]})}),yi(Ps,{children:[qt("h3",{children:i}),qt("p",{children:s}),qt(jw,{onClick:r,disclosedAccount:a.disclosedAccount})]}),yi(Ps,{style:{gap:12,marginTop:12},children:[n?qt(F,{success:!0,children:"Success!"}):qt(F,{warn:!0,onClick:t,children:"Transfer and delete account"}),qt(Mr,{onClick:e,children:"No thanks"})]})]}),qt(V,{})]})};function jw({disclosedAccount:e,onClick:t}){return e?yi(kc,{onClick:t,children:[qt(Zw,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),qt(Rr,{address:e.handle,showCopyIcon:!1}),qt(Rc,{iconSize:15})]}):null}function $w(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`${us(e.replace("_oauth",""))} profile`;default:return e}}function e4({method:e,handle:t}){return{title:`${$w(e)} is associated with another account`,detail:`Do you want to transfer ${t} to this account instead? This will delete your other account.`}}import Sy from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import r4 from"@heroicons/react/24/solid/DocumentCheckIcon";import o4 from"styled-components";import Pt from"styled-components";var He=Pt.div`
|
|
529
529
|
display: flex;
|
|
530
530
|
flex-direction: column;
|
|
531
531
|
align-items: center;
|
|
@@ -694,7 +694,7 @@ Resources:
|
|
|
694
694
|
}
|
|
695
695
|
`,Nc=Pt.div`
|
|
696
696
|
color: var(--privy-color-error);
|
|
697
|
-
`;import{Fragment as i4,jsx as No,jsxs as xs}from"react/jsx-runtime";var Py=()=>{let{user:e,logout:t}=z(),{app:r,onUserCloseViaDialogOrKeybindRef:o,setModalData:n,navigate:a}=x(),{acceptTerms:i,closePrivyModal:s,createAnalyticsEvent:l}=R(),d=m=>{m?.preventDefault(),s({shouldCallAuthOnSuccess:!1}),t()};o.current=d;let p=async m=>{m.preventDefault(),await i(),e&&It(e,r?.embeddedWallets?.createOnLogin)?(n({createWallet:{onSuccess:()=>{},onFailure:h=>{console.error(h),l({eventName:"embedded_wallet_creation_failure_logout",payload:{error:h,screen:"AffirmativeConsentScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),a("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")):s()};return No(n4,{termsAndConditionsUrl:r?.legal.termsAndConditionsUrl,privacyPolicyUrl:r?.legal.privacyPolicyUrl,onAccept:p,onDecline:d})},n4=({termsAndConditionsUrl:e,privacyPolicyUrl:t,onAccept:r,onDecline:o})=>xs(i4,{children:[No(k,{closeable:!1}),No(r4,{width:56,height:56,fill:"var(--privy-color-accent)",style:{margin:"auto"}}),No(ye,{style:{marginTop:24},children:"One last step"}),No(ve,{children:"By signing up, you agree to our terms and privacy policy."}),xs(hr,{style:{marginTop:24},children:[e&&xs(Yp,{target:"_blank",href:e,children:["View Terms ",No(Sy,{style:{marginLeft:"auto"}})]}),t&&xs(Yp,{target:"_blank",href:t,children:["View Privacy Policy ",No(Sy,{style:{marginLeft:"auto"}})]})]}),xs(a4,{style:{marginTop:24},children:[No(Mr,{onClick:o,children:"No thanks"}),No(F,{onClick:r,children:"Accept"})]}),No(
|
|
697
|
+
`;import{Fragment as i4,jsx as No,jsxs as xs}from"react/jsx-runtime";var Py=()=>{let{user:e,logout:t}=z(),{app:r,onUserCloseViaDialogOrKeybindRef:o,setModalData:n,navigate:a}=x(),{acceptTerms:i,closePrivyModal:s,createAnalyticsEvent:l}=R(),d=m=>{m?.preventDefault(),s({shouldCallAuthOnSuccess:!1}),t()};o.current=d;let p=async m=>{m.preventDefault(),await i(),e&&It(e,r?.embeddedWallets?.createOnLogin)?(n({createWallet:{onSuccess:()=>{},onFailure:h=>{console.error(h),l({eventName:"embedded_wallet_creation_failure_logout",payload:{error:h,screen:"AffirmativeConsentScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),a("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")):s()};return No(n4,{termsAndConditionsUrl:r?.legal.termsAndConditionsUrl,privacyPolicyUrl:r?.legal.privacyPolicyUrl,onAccept:p,onDecline:d})},n4=({termsAndConditionsUrl:e,privacyPolicyUrl:t,onAccept:r,onDecline:o})=>xs(i4,{children:[No(k,{closeable:!1}),No(r4,{width:56,height:56,fill:"var(--privy-color-accent)",style:{margin:"auto"}}),No(ye,{style:{marginTop:24},children:"One last step"}),No(ve,{children:"By signing up, you agree to our terms and privacy policy."}),xs(hr,{style:{marginTop:24},children:[e&&xs(Yp,{target:"_blank",href:e,children:["View Terms ",No(Sy,{style:{marginLeft:"auto"}})]}),t&&xs(Yp,{target:"_blank",href:t,children:["View Privacy Policy ",No(Sy,{style:{marginLeft:"auto"}})]})]}),xs(a4,{style:{marginTop:24},children:[No(Mr,{onClick:o,children:"No thanks"}),No(F,{onClick:r,children:"Accept"})]}),No(V,{})]}),a4=o4.div`
|
|
698
698
|
display: flex;
|
|
699
699
|
gap: 10px;
|
|
700
700
|
`;import xy from"styled-components";import{jsx as Ay}from"react/jsx-runtime";var Oc=({style:e,...t})=>Ay("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},...t,children:Ay("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"})});import{Fragment as Xp,jsx as Oo,jsxs as Dc}from"react/jsx-runtime";var ky=()=>{let{navigate:e,app:t}=x(),r=t?.allowlistConfig.errorTitle||"You don't have access to this app",o=t?.allowlistConfig.errorDetail||"Have you been invited?",n=t?.allowlistConfig.errorCtaText||"Try another account";return Dc(Xp,{children:[Oo(k,{}),Dc(s4,{children:[Oo(Ye,{children:Dc("div",{children:[Oo(fi,{}),Oo(Oc,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})]})}),Dc(l4,{children:[typeof r=="string"?Oo("h3",{children:r}):Oo(Xp,{children:r}),typeof o=="string"?Oo("p",{children:o}):Oo(Xp,{children:o})]}),t?.allowlistConfig.errorCtaLink?Oo(F,{as:"a",href:t.allowlistConfig.errorCtaLink,children:n}):Oo(F,{onClick:()=>{e("LANDING")},children:n})]})]})},s4=xy.div`
|
|
@@ -815,7 +815,7 @@ Resources:
|
|
|
815
815
|
h3 {
|
|
816
816
|
margin-bottom: 24px;
|
|
817
817
|
}
|
|
818
|
-
`;import{Fragment as T4,jsx as er,jsxs as $o}from"react/jsx-runtime";var jp=6,Ny=new Array(jp).fill(""),h4=1400,y4=30;var Dy=()=>{let{app:e,navigate:t,lastScreen:r,navigateBack:o,setModalData:n,onUserCloseViaDialogOrKeybindRef:a}=x(),{closePrivyModal:i,resendEmailCode:s,resendSmsCode:l,getAuthMeta:d,loginWithCode:p,updateWallets:m,createAnalyticsEvent:h}=R(),{authenticated:g,logout:v,user:w}=z(),[E,I]=Rs(Ny),[A,T]=Rs(!1),[P,S]=Rs(null),[_,
|
|
818
|
+
`;import{Fragment as T4,jsx as er,jsxs as $o}from"react/jsx-runtime";var jp=6,Ny=new Array(jp).fill(""),h4=1400,y4=30;var Dy=()=>{let{app:e,navigate:t,lastScreen:r,navigateBack:o,setModalData:n,onUserCloseViaDialogOrKeybindRef:a}=x(),{closePrivyModal:i,resendEmailCode:s,resendSmsCode:l,getAuthMeta:d,loginWithCode:p,updateWallets:m,createAnalyticsEvent:h}=R(),{authenticated:g,logout:v,user:w}=z(),[E,I]=Rs(Ny),[A,T]=Rs(!1),[P,S]=Rs(null),[_,U]=Rs(null),[D,H]=Rs(0);a.current=()=>null;let B=d()?.email?0:1,Y=Oe,K=Y-500;Jp(()=>{if(D){let pe=setTimeout(()=>{H(D-1)},1e3);return()=>clearTimeout(pe)}},[D]),Jp(()=>{if(g&&A&&w){if(e?.legal.requireUsersAcceptTerms&&!w.hasAcceptedTerms){let X=setTimeout(()=>{t("AFFIRMATIVE_CONSENT_SCREEN")},K);return()=>clearTimeout(X)}if(It(w,e?.embeddedWallets?.createOnLogin)){let X=setTimeout(()=>{n({createWallet:{onSuccess:()=>{},onFailure:fe=>{console.error(fe),h({eventName:"embedded_wallet_creation_failure_logout",payload:{error:fe,screen:"AwaitingPasswordlessCodeScreen"}}),v()},callAuthOnSuccessOnClose:!0}}),t("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")},K);return()=>clearTimeout(X)}else{m();let X=setTimeout(()=>i({shouldCallAuthOnSuccess:!0,isSuccess:!0}),Y);return()=>clearTimeout(X)}}},[g,A,w]),Jp(()=>{if(P&&_===0){let pe=setTimeout(()=>{I(Ny),S(null),document.querySelector("input[name=code-0]")?.focus()},h4);return()=>clearTimeout(pe)}},[P]);let O=pe=>{pe.preventDefault();let X=pe.currentTarget.value.replace(" ","");if(X==="")return;if(isNaN(Number(X))){S("Code should be numeric"),U(1);return}S(null),U(null);let fe=Number(pe.currentTarget.name?.charAt(5)),re=[...X||[""]].slice(0,jp-fe),te=[...E.slice(0,fe),...re,...E.slice(fe+re.length)];I(te);let ae=re.length,Je=Math.min(Math.max(fe+ae,0),jp-1);isNaN(Number(pe.currentTarget.value))||document.querySelector(`input[name=code-${Je}]`)?.focus(),te.every(ot=>ot&&!isNaN(+ot))&&(document.querySelector(`input[name=code-${Je}]`)?.blur(),p(te.join("")).then(()=>T(!0)).catch(ie=>{if(ie instanceof xr&&ie.privyErrorCode==="invalid_credentials")S("Invalid or expired verification code");else if(ie instanceof xr&&ie.privyErrorCode==="cannot_link_more_of_type")S(ie.message);else if(ie instanceof xr&&ie.privyErrorCode==="max_accounts_reached"){console.error(new Ao(ie).toString()),t("USER_LIMIT_REACHED_SCREEN");return}else if(ie instanceof xr&&ie.privyErrorCode==="user_does_not_exist"){t("ACCOUNT_NOT_FOUND_SCREEN");return}else if(ie instanceof xr&&ie.privyErrorCode==="linked_to_another_user"){n({errorModalData:{error:ie,previousScreen:r??"AWAITING_PASSWORDLESS_CODE"}}),t("ERROR_SCREEN",!1);return}else if(ie instanceof xr&&ie.privyErrorCode==="account_transfer_required"&&ie.data?.data?.nonce){n({accountTransfer:{nonce:ie.data?.data?.nonce,account:B===0?d()?.email:d()?.phoneNumber,displayName:ie.data?.data?.account?.displayName,linkMethod:B===0?"email":"sms",embeddedWalletAddress:ie.data?.data?.otherUser?.embeddedWalletAddress}}),t("LINK_CONFLICT_SCREEN");return}else S("Issue verifying code");U(0)}))},Q=pe=>{_===1&&(S(null),U(null));let X=[...E.slice(0,pe),"",...E.slice(pe+1)];I(X),pe>0&&document.querySelector(`input[name=code-${pe-1}]`)?.focus()},L=B==0?er(u4,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"}):er(m4,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),Ge=B==0?$o("p",{children:["Please check ",er(Oy,{children:d()?.email})," for an email from privy.io and enter your code below."]}):$o("p",{children:["Please check ",er(Oy,{children:d()?.phoneNumber})," for a message from ",e?.name||"Privy"," and enter your code below."]});return $o(T4,{children:[er(k,{backFn:()=>o()},"header"),$o(g4,{children:[er(we,{title:"Enter confirmation code",description:Ge,icon:L}),$o(Ry,{children:[$o(C4,{children:[er(v4,{fail:!!P,success:A,children:er("span",{children:P||(A?"Success!":"")})}),er("div",{children:E.map((pe,X)=>er("input",{name:`code-${X}`,type:"text",value:E[X],onChange:O,onKeyUp:fe=>{fe.key==="Backspace"&&Q(X)},inputMode:"numeric",autoFocus:X===0,pattern:"[0-9]",className:`${A?"success":""} ${P?"fail":""}`,autoComplete:f4?"one-time-code":"off"},X))})]}),$o(w4,{children:[$o("span",{children:["Didn't get ",B==0?"an email":"a message","?"]}),D?$o(E4,{children:[er(p4,{color:"var(--privy-color-foreground)",strokeWidth:1.33,height:"12px",width:"12px"}),er("span",{children:"Code sent"})]}):er(b4,{children:er("button",{onClick:async()=>{H(y4),B==0?await s():await l()},children:"Resend code"})})]})]})]}),er(V,{})]})},g4=ya.div`
|
|
819
819
|
display: flex;
|
|
820
820
|
flex-direction: column;
|
|
821
821
|
align-items: flex-start;
|
|
@@ -940,7 +940,7 @@ Resources:
|
|
|
940
940
|
left: -19px;
|
|
941
941
|
top: -19px;
|
|
942
942
|
}
|
|
943
|
-
`;import{Fragment as W4,jsx as go,jsxs as eu}from"react/jsx-runtime";var By=500,Fy=By*2,Hy=()=>{let{lastScreen:e,currentScreen:t,data:r,navigateBack:o,navigate:n,setModalData:a}=x(),{status:i,token:s,waitForResult:l,reset:d,execute:p}=Te(),m=_4([]),h=K=>{m.current=[K,...m.current]},[g,v]=wi(!0);$p(()=>{let K=setTimeout(v,Fy,!1);return h(K),()=>{m.current.forEach(O=>clearTimeout(O)),m.current=[]}},[]);let[w,E]=wi(""),[I,A]=wi("Checking that you are a human..."),[T,P]=wi(go(F,{onClick:()=>{},disabled:!0,children:"Continue"})),[S,_]=wi(!1),[D
|
|
943
|
+
`;import{Fragment as W4,jsx as go,jsxs as eu}from"react/jsx-runtime";var By=500,Fy=By*2,Hy=()=>{let{lastScreen:e,currentScreen:t,data:r,navigateBack:o,navigate:n,setModalData:a}=x(),{status:i,token:s,waitForResult:l,reset:d,execute:p}=Te(),m=_4([]),h=K=>{m.current=[K,...m.current]},[g,v]=wi(!0);$p(()=>{let K=setTimeout(v,Fy,!1);return h(K),()=>{m.current.forEach(O=>clearTimeout(O)),m.current=[]}},[]);let[w,E]=wi(""),[I,A]=wi("Checking that you are a human..."),[T,P]=wi(go(F,{onClick:()=>{},disabled:!0,children:"Continue"})),[S,_]=wi(!1),[U,D]=wi(3),H=r?.captchaModalData,B=async K=>{try{await H?.callback(K),H?.onSuccessNavigateTo&&n(H?.onSuccessNavigateTo,!1)}catch(O){if(O instanceof Lt)return;{let Q={error:O,previousScreen:e||"LANDING"};a({errorModalData:Q}),n(H?.onErrorNavigateTo||"ERROR_SCREEN",!1)}}};$p(()=>{if(i==="success"){let K=setTimeout(async()=>{let O=await l();!O||H?.userIntentRequired||B(O)},Fy);h(K)}else if(i==="ready"){let K=setTimeout(()=>{i==="ready"&&p()},By);h(K)}},[i]),$p(()=>{if(!g)switch(i){case"success":E("Success!"),A("CAPTCHA passed successfully."),P(go(F,{onClick:()=>{_(!0),B(s)},disabled:!H?.userIntentRequired,loading:S,children:H?.userIntentRequired?"Continue":"Continuing..."}));break;case"loading":E(""),A("Checking that you are a human..."),P(go(F,{onClick:()=>{},disabled:!0,children:"Continue"}));break;case"error":E("Something went wrong"),U<=0?(A("If you use an adblocker or VPN, try disabling and re-attempting."),P(null)):(A("You did not pass CAPTCHA. Please try again."),P(go(F,{onClick:Y,children:"Retry"})));break;case"ready":default:break}},[i,g,S]);let Y=async()=>{if(U<=0)return;D(O=>O-1),d(),p();let K=await l();!K||H?.userIntentRequired||B(K)};return eu(W4,{children:[go(k,{backFn:!e||t===e?void 0:o}),eu(M4,{children:[i==="success"?go(k4,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}):i==="error"?go(R4,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}):go(Uy,{}),eu(at,{children:[w?go("h3",{children:w}):null,go("p",{children:I})]}),T]}),go(j,{})]})},M4=I4.div`
|
|
944
944
|
display: flex;
|
|
945
945
|
flex-direction: column;
|
|
946
946
|
align-items: center;
|
|
@@ -972,7 +972,7 @@ Resources:
|
|
|
972
972
|
flex-wrap: wrap;
|
|
973
973
|
gap: 8px;
|
|
974
974
|
margin-left: auto;
|
|
975
|
-
`;import{Fragment as V4,jsx as Ti,jsxs as G4}from"react/jsx-runtime";var U4=["coinbase_wallet"],F4=["metamask","okx_wallet","rainbow","uniswap","uniswap_extension","zerion","rabby_wallet","cryptocom"],B4=["safe"],H4=["phantom"],Si=({connectOnly:e})=>{let{connectors:t}=R(),{app:r,data:o}=x(),n=Tn(o?.externalConnectWallet?.walletList??r.appearance.walletList,r.appearance.walletChainType,t,e,r.appearance.walletList,r.externalWallets.walletConnect.enabled);return G4(V4,{children:[...n]})},Tn=(e,t,r,o,n,a)=>{let i=[],s=[],l=[];r=r.filter(p=>t==="ethereum-only"?p.chainType==="ethereum":t==="solana-only"?p.chainType==="solana":!0);let d=r.find(p=>p.connectorType==="wallet_connect_v2");for(let p of e)if(p==="detected_wallets"){let m=r.filter(({chainType:h,connectorType:g,walletClientType:v})=>v==="uniswap_wallet_extension"||v==="uniswap_extension"?!n.includes("uniswap"):v==="crypto.com_wallet_extension"?!n.includes("cryptocom"):h==="solana"?t!=="ethereum-only":g==="injected"&&!n.includes(v));for(let[h,g]of m.entries()){let{walletClientType:v,walletBranding:w}=g;(v==="unknown"?s:i).push(Ti(ga,{connectOnly:o,provider:v,logo:w.icon,displayName:w.name,connector:g},`${p}-${v}-${g.chainType}-${h}`))}}else if(H4.includes(p)){let m=r.find(h=>h.connectorType==="injected"&&h.walletClientType===p||h.connectorType===p);m&&i.push(Ti(ga,{connectOnly:o,provider:p,connector:m},p))}else if(F4.includes(p)){let m=r.find(h=>p==="uniswap"?h.walletClientType==="uniswap_wallet_extension"||h.walletClientType==="uniswap_extension":p==="cryptocom"?h.walletClientType==="crypto.com_wallet_extension":h.connectorType==="injected"&&h.walletClientType===p);a&&!m&&(m=d),m&&i.push(Ti(ga,{connectOnly:o,provider:p,connector:m,logo:m.connectorType==="injected"?m.walletBranding.icon:void 0,displayName:m.connectorType==="injected"?m.walletBranding.name:void 0},p))}else if(U4.includes(p)){let m=r.find(({connectorType:h})=>h===p);m&&i.push(Ti(ga,{connectOnly:o,provider:p,connector:m},p))}else B4.includes(p)?d&&l.push(Ti(ga,{connectOnly:o,provider:p,connector:d},p)):p==="wallet_connect"&&d&&l.push(Ti(ga,{connectOnly:o,provider:p,connector:d},p));return[...s,...i,...l]};import{Fragment as q4,jsx as Ws,jsxs as z4}from"react/jsx-runtime";var tg=()=>{let{app:e,data:t}=x(),r=t?.externalConnectWallet?.suggestedAddress,o=r?`Connect the wallet with address ${uo(r)} ${e?.name?`to ${e.name}.`:"."}`:`Connect a wallet to ${e?.name}`;return z4(q4,{children:[Ws(k,{},"header"),Ws(Do,{title:"Connect your wallet",description:o}),Ws(hr,{children:Ws(Si,{connectOnly:!0})}),Ws(
|
|
975
|
+
`;import{Fragment as V4,jsx as Ti,jsxs as G4}from"react/jsx-runtime";var U4=["coinbase_wallet"],F4=["metamask","okx_wallet","rainbow","uniswap","uniswap_extension","zerion","rabby_wallet","cryptocom"],B4=["safe"],H4=["phantom"],Si=({connectOnly:e})=>{let{connectors:t}=R(),{app:r,data:o}=x(),n=Tn(o?.externalConnectWallet?.walletList??r.appearance.walletList,r.appearance.walletChainType,t,e,r.appearance.walletList,r.externalWallets.walletConnect.enabled);return G4(V4,{children:[...n]})},Tn=(e,t,r,o,n,a)=>{let i=[],s=[],l=[];r=r.filter(p=>t==="ethereum-only"?p.chainType==="ethereum":t==="solana-only"?p.chainType==="solana":!0);let d=r.find(p=>p.connectorType==="wallet_connect_v2");for(let p of e)if(p==="detected_wallets"){let m=r.filter(({chainType:h,connectorType:g,walletClientType:v})=>v==="uniswap_wallet_extension"||v==="uniswap_extension"?!n.includes("uniswap"):v==="crypto.com_wallet_extension"?!n.includes("cryptocom"):h==="solana"?t!=="ethereum-only":g==="injected"&&!n.includes(v));for(let[h,g]of m.entries()){let{walletClientType:v,walletBranding:w}=g;(v==="unknown"?s:i).push(Ti(ga,{connectOnly:o,provider:v,logo:w.icon,displayName:w.name,connector:g},`${p}-${v}-${g.chainType}-${h}`))}}else if(H4.includes(p)){let m=r.find(h=>h.connectorType==="injected"&&h.walletClientType===p||h.connectorType===p);m&&i.push(Ti(ga,{connectOnly:o,provider:p,connector:m},p))}else if(F4.includes(p)){let m=r.find(h=>p==="uniswap"?h.walletClientType==="uniswap_wallet_extension"||h.walletClientType==="uniswap_extension":p==="cryptocom"?h.walletClientType==="crypto.com_wallet_extension":h.connectorType==="injected"&&h.walletClientType===p);a&&!m&&(m=d),m&&i.push(Ti(ga,{connectOnly:o,provider:p,connector:m,logo:m.connectorType==="injected"?m.walletBranding.icon:void 0,displayName:m.connectorType==="injected"?m.walletBranding.name:void 0},p))}else if(U4.includes(p)){let m=r.find(({connectorType:h})=>h===p);m&&i.push(Ti(ga,{connectOnly:o,provider:p,connector:m},p))}else B4.includes(p)?d&&l.push(Ti(ga,{connectOnly:o,provider:p,connector:d},p)):p==="wallet_connect"&&d&&l.push(Ti(ga,{connectOnly:o,provider:p,connector:d},p));return[...s,...i,...l]};import{Fragment as q4,jsx as Ws,jsxs as z4}from"react/jsx-runtime";var tg=()=>{let{app:e,data:t}=x(),r=t?.externalConnectWallet?.suggestedAddress,o=r?`Connect the wallet with address ${uo(r)} ${e?.name?`to ${e.name}.`:"."}`:`Connect a wallet to ${e?.name}`;return z4(q4,{children:[Ws(k,{},"header"),Ws(Do,{title:"Connect your wallet",description:o}),Ws(hr,{children:Ws(Si,{connectOnly:!0})}),Ws(V,{})]})};import{Fragment as K4,jsx as Ca,jsxs as rg}from"react/jsx-runtime";var og=()=>{let{app:e,data:t}=x(),r=t?.externalConnectWallet?.suggestedAddress,o=r?rg("span",{children:["Connect the wallet with address ",Ca(Rr,{showCopyIcon:!1,address:r})," ",e?.name?`to ${e.name}.`:"."]}):`Connect a wallet to your ${e?.name} account`;return rg(K4,{children:[Ca(k,{},"header"),Ca(ha,{title:"Connect your wallet",description:o}),Ca(hr,{children:Ca(Si,{connectOnly:!0})}),e&&Ca(Qa,{app:e,alwaysShowImplicitConsent:!0}),Ca(V,{})]})};import{useEffect as cg,useState as dg}from"react";import{isMobile as e5}from"react-device-detect";import t5 from"styled-components";import{useEffect as ou,useState as Sn}from"react";import{isMobile as Hc}from"react-device-detect";import sg from"styled-components";import{useEffect as ng,useRef as Y4}from"react";var Q4=(e,t)=>{let r=Y4(()=>{});ng(()=>{r.current=e}),ng(()=>{if(t!==null){let o=setInterval(()=>r.current(),t||0);return()=>clearInterval(o)}},[t])},ag=Q4;import{useState as X4,useEffect as Z4,useCallback as J4}from"react";function ig(){let[e,t]=X4(!1),r=J4(()=>{document.hidden&&t(!0)},[]);return Z4(()=>(document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)),[r]),{hasTabbedAway:e,reset:()=>t(!1)}}import{Fragment as au,jsx as At,jsxs as Pi}from"react/jsx-runtime";var nu=2,iu=e=>e?.privyErrorCode==="linked_to_another_user"?_o.ERROR_USER_EXISTS:e instanceof Wt&&!e.details.default?e.details:e instanceof ri?_o.ERROR_TIMED_OUT:e instanceof oi?_o.ERROR_USER_REJECTED_CONNECTION:e?.privyErrorCode==="cannot_link_more_of_type"?_o.ERROR_USER_LIMIT_REACHED:_o.ERROR_WALLET_CONNECTION,lg=()=>{let[e,t]=Sn(!1),[r,o]=Sn(!1),[n,a]=Sn(void 0),{authenticated:i,logout:s}=z(),{app:l,navigate:d,navigateBack:p,lastScreen:m,currentScreen:h,setModalData:g,data:v}=x(),{getAuthFlow:w,walletConnectionStatus:E,closePrivyModal:I,initLoginWithWallet:A,loginWithWallet:T,updateWallets:P,createAnalyticsEvent:S}=R(),{walletConnectors:_}=z(),[U,D]=Sn(0),{user:H}=z(),[B]=Sn(H?.linkedAccounts.length||0),[Y,K]=Sn(""),[O,Q]=Sn(""),[L,Ge]=Sn(!1),{hasTabbedAway:pe}=ig(),{enabled:X,token:fe}=Te(),re=Hc&&E?.connector?.connectorType==="wallet_connect_v2"||Hc&&E?.connector?.connectorType==="coinbase_wallet"||Hc&&E?.connector?.connectorType==="injected"&&E?.connector?.walletClientType==="phantom",te=E?.status==="connected",ae=E?.status==="switching_to_supported_chain";ou(()=>{let Ce=w(),Tt=Ce instanceof Jo||Ce instanceof sa?Ce:void 0;if(te&&!Tt&&(X&&!fe&&!i?(g({captchaModalData:{callback:J=>A(E.connectedWallet,J,v?.login?.disableSignup).then(()=>{Ge(!0)}),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"}}),d("CAPTCHA_SCREEN",!1)):A(E.connectedWallet,fe,v?.login?.disableSignup).then(()=>{Ge(!0)})),Tt&&re&&te&&!Tt.preparedMessage){Tt.buildMessage();return}!Tt||re||!te||r||(async()=>{o(!0),a(void 0);try{E?.connector?.connectorType==="wallet_connect_v2"&&E?.connector?.walletClientType==="metamask"&&await Fm(2500),await ot()}catch(J){console.warn("Auto-prompted signature failed",J)}finally{o(!1)}})()},[U,te,L]),ou(()=>{if(H&&e){let Tt=Oe-500;if(l?.legal.requireUsersAcceptTerms&&!H.hasAcceptedTerms){let oe=setTimeout(()=>{d("AFFIRMATIVE_CONSENT_SCREEN")},Tt);return()=>clearTimeout(oe)}if(It(H,l?.embeddedWallets?.createOnLogin)){let oe=setTimeout(()=>{g({createWallet:{onSuccess:()=>{},onFailure:sr=>{console.error(sr),S({eventName:"embedded_wallet_creation_failure_logout",payload:{error:sr,screen:"ConnectionStatusScreen"}}),s()},callAuthOnSuccessOnClose:!0}}),d("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")},Tt);return()=>clearTimeout(oe)}P();let J=setTimeout(()=>I({shouldCallAuthOnSuccess:!0,isSuccess:!0}),Oe);return()=>clearTimeout(J)}},[H,e]);let Je=Ce=>{if(Ce?.privyErrorCode==="allowlist_rejected"){d("ALLOWLIST_REJECTION_SCREEN");return}else if(Ce?.privyErrorCode==="max_accounts_reached"){console.error(new Ao(Ce).toString()),d("USER_LIMIT_REACHED_SCREEN");return}else if(Ce?.privyErrorCode==="user_does_not_exist"){d("ACCOUNT_NOT_FOUND_SCREEN");return}if(Ce?.privyErrorCode==="account_transfer_required"&&Ce.data?.data?.nonce){g({accountTransfer:{nonce:Ce.data?.data?.nonce,account:w()?.meta.address,displayName:Ce.data?.data?.account?.displayName,walletClientType:w()?.meta.walletClientType,chainId:w()?.meta.chainId,connectorType:w()?.meta.connectorType,linkMethod:"siwe",embeddedWalletAddress:Ce.data?.data?.otherUser?.embeddedWalletAddress}}),d("LINK_CONFLICT_SCREEN");return}a(iu(Ce))};async function ot(){try{await T(),t(!0)}catch(Ce){Je(Ce)}finally{o(!1)}}ou(()=>{E?.connectError&&Je(E?.connectError)},[E]),ag(()=>{let Ce=ie==="wallet_connect_v2"&&E?.connector instanceof ho?E.connector.redirectUri:void 0;Ce&&K(Ce);let Tt=ie==="wallet_connect_v2"&&E?.connector instanceof ho?E.connector.fallbackUniversalRedirectUri:void 0;Tt&&Q(Tt)},E?.connector instanceof ho&&!Y?500:null);let ie=E?.connector?.connectorType||"injected",mt=E?.connector?.walletClientType||"unknown",jt=eo[mt]?.displayName||E?.connector?.walletBranding.name||"Browser Extension",qr=eo[mt]?.logo||E?.connector?.walletBranding.icon||(Ce=>At(ii,{...Ce})),Pe=jt==="Browser Extension"?jt.toLowerCase():jt,ue;e?ue=`Successfully connected with ${Pe}`:n?ue=n.message:ae?ue="Switching networks":te?ue=r&&re?"Signing":"Sign to verify":ue=`Waiting for ${Pe}`;let ke="Don\u2019t see your wallet? Check your other browser windows.";if(e){let Ce=H?.linkedAccounts.length||0;B===Ce?ke="Wallet was already linked.":ke="You\u2019re good to go!"}else U>=nu&&n?ke="Unable to connect wallet":n?ke=n.detail:ae?ke="Switch your wallet to the requested network.":te&&re?ke="Sign the message in your wallet to verify it belongs to you.":mt==="metamask"&&Hc?ke="Click continue to open and connect MetaMask.":mt==="metamask"?ke="For the best experience, connect only one wallet at a time.":ie==="wallet_connect"?ke="Open your mobile wallet app to continue":ie==="coinbase_wallet"&&(Sl()||(Fp(H)?ke="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":ke="Open the Coinbase app on your phone to continue."));let se=_?.walletConnectors?.find(Ce=>Ce.walletClientType==="coinbase_wallet"),W=mt==="coinbase_wallet"&&(Fp(H)||n===_o.ERROR_USER_EXISTS);return Pi(au,{children:[At(k,{backFn:!m||h===m?void 0:p}),Pi(j4,{children:[At(su,{walletLogo:qr,success:e,fail:!!n}),Pi(at,{children:[At("h3",{children:ue}),At("p",{children:ke}),!te&&Y&&!pe?Pi("p",{children:["Still here?"," ",At("a",{href:Y,target:"_blank",style:{textDecoration:"underline"},children:"Try connecting again"}),O&&Pi(au,{children:[" ","or"," ",At("a",{href:O,target:"_blank",style:{textDecoration:"underline"},children:"use this different link"})]})]}):null]}),W?At(F,{onClick:()=>se&&se?.disconnect(),disabled:e,children:"Use a different wallet"}):n==_o.ERROR_USER_EXISTS&&h!==m?At(F,{onClick:p,children:"Use a different wallet"}):te&&!e&&re?At(F,{onClick:()=>{o(!0),ot()},disabled:r,children:r?"Signing":"Sign with your wallet"}):!e&&n?.retryable&&U<nu?At(F,{onClick:()=>{D(U+1),a(void 0),te?(o(!0),ot()):E?.connectRetry()},disabled:!e&&(!n?.retryable||U>=nu),children:"Retry"}):!e&&!n?At(F,{onClick:()=>{},disabled:!0,children:"Connecting"}):null]}),At(j,{})]})},j4=sg.div`
|
|
976
976
|
display: flex;
|
|
977
977
|
flex-direction: column;
|
|
978
978
|
align-items: center;
|
|
@@ -1009,7 +1009,7 @@ Resources:
|
|
|
1009
1009
|
justify-content: center;
|
|
1010
1010
|
gap: 24px;
|
|
1011
1011
|
width: 100%;
|
|
1012
|
-
`;import{useEffect as fg,useMemo as n5,useState as a5}from"react";import i5 from"styled-components";import{jsx as ug}from"react/jsx-runtime";var mg=({name:e,logoUrl:t})=>{let r=`${e??"Provider app"} logo`;return typeof t=="string"?ug("img",{src:t,alt:r,style:{width:"38px",height:"38px",maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):ug("span",{})};import{Fragment as l5,jsx as tn,jsxs as Gc}from"react/jsx-runtime";var hg=()=>{let e=_e(),{data:t,navigate:r,setModalData:o,onUserCloseViaDialogOrKeybindRef:n}=x(),{crossAppAuthFlow:a,updateWallets:i,closePrivyModal:s,createAnalyticsEvent:l}=R(),{logout:d}=Wp(),[p,m]=a5({}),h=t?.crossAppAuth,g={id:h.appId,name:h.name,logoUrl:h.logoUrl},v=Oe,w=new C(`There was an issue connecting your ${g.name} account. Please try again.`),E=new Ke(async P=>{if(!h.popup){m({error:w});return}try{let S=await a({appId:P,popup:h.popup,action:h.action});m({data:S})}catch(S){S instanceof C?m({error:S}):S instanceof xr?(h.popup&&h.popup.close(),m({error:w})):m({error:w})}}),I=()=>{p.data&&(i(),h.onSuccess(p.data),s({shouldCallAuthOnSuccess:!0,isSuccess:!0})),h.onError(p.error??new C("User canceled flow")),s({shouldCallAuthOnSuccess:!1,isSuccess:!1})};n.current=I,fg(()=>{g.id.length&&E.execute(g.id)},[g.id]),fg(()=>{if(!p.data)return;let P=p.data;if(e.legal.requireUsersAcceptTerms&&!P.hasAcceptedTerms){let _=setTimeout(()=>{r("AFFIRMATIVE_CONSENT_SCREEN")},v);return()=>clearTimeout(_)}if(It(P,e.embeddedWallets?.createOnLogin)){let _=setTimeout(()=>{o({createWallet:{onSuccess:()=>{},onFailure:
|
|
1012
|
+
`;import{useEffect as fg,useMemo as n5,useState as a5}from"react";import i5 from"styled-components";import{jsx as ug}from"react/jsx-runtime";var mg=({name:e,logoUrl:t})=>{let r=`${e??"Provider app"} logo`;return typeof t=="string"?ug("img",{src:t,alt:r,style:{width:"38px",height:"38px",maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):ug("span",{})};import{Fragment as l5,jsx as tn,jsxs as Gc}from"react/jsx-runtime";var hg=()=>{let e=_e(),{data:t,navigate:r,setModalData:o,onUserCloseViaDialogOrKeybindRef:n}=x(),{crossAppAuthFlow:a,updateWallets:i,closePrivyModal:s,createAnalyticsEvent:l}=R(),{logout:d}=Wp(),[p,m]=a5({}),h=t?.crossAppAuth,g={id:h.appId,name:h.name,logoUrl:h.logoUrl},v=Oe,w=new C(`There was an issue connecting your ${g.name} account. Please try again.`),E=new Ke(async P=>{if(!h.popup){m({error:w});return}try{let S=await a({appId:P,popup:h.popup,action:h.action});m({data:S})}catch(S){S instanceof C?m({error:S}):S instanceof xr?(h.popup&&h.popup.close(),m({error:w})):m({error:w})}}),I=()=>{p.data&&(i(),h.onSuccess(p.data),s({shouldCallAuthOnSuccess:!0,isSuccess:!0})),h.onError(p.error??new C("User canceled flow")),s({shouldCallAuthOnSuccess:!1,isSuccess:!1})};n.current=I,fg(()=>{g.id.length&&E.execute(g.id)},[g.id]),fg(()=>{if(!p.data)return;let P=p.data;if(e.legal.requireUsersAcceptTerms&&!P.hasAcceptedTerms){let _=setTimeout(()=>{r("AFFIRMATIVE_CONSENT_SCREEN")},v);return()=>clearTimeout(_)}if(It(P,e.embeddedWallets?.createOnLogin)){let _=setTimeout(()=>{o({createWallet:{onSuccess:()=>{},onFailure:U=>{console.error(U),l({eventName:"embedded_wallet_creation_failure_logout",payload:{error:U,provider:`privy:${g.id}`,screen:"CrossAppAuthScreen"}}),d()},callAuthOnSuccessOnClose:!0}}),r("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")},v);return()=>clearTimeout(_)}let S=setTimeout(I,v);return()=>clearTimeout(S)},[p.data]);let{title:A,subtitle:T}=n5(()=>p.data?{title:`Successfully connected with ${g.name}`,subtitle:"You're good to go!"}:p.error?{title:"Authentication failed",subtitle:p.error.message}:{title:`Connecting to ${g.name}`,subtitle:`Please check the pop-up from ${g.name} to continue`},[p,g.name]);return Gc(l5,{children:[tn(k,{onClose:I}),tn(le,{}),Gc(s5,{children:[tn(Ye,{children:Gc("div",{children:[tn(ht,{success:!!p.data,fail:!!p.error}),tn(mg,{name:g.name,logoUrl:g.logoUrl})]})}),Gc(at,{children:[tn("h3",{children:A}),tn("p",{children:T})]})]}),tn(ce,{}),tn(j,{})]})},s5=i5.div`
|
|
1013
1013
|
display: flex;
|
|
1014
1014
|
flex-direction: column;
|
|
1015
1015
|
align-items: center;
|
|
@@ -1073,9 +1073,9 @@ Resources:
|
|
|
1073
1073
|
transform: rotate(360deg);
|
|
1074
1074
|
}
|
|
1075
1075
|
}
|
|
1076
|
-
`;var yg=["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"];var Ue=class extends Error{constructor(r,o){super(o);this.type=r}};function Ai(e){let t=e.type;return typeof t=="string"&&yg.includes(t)}function f5(e){let t=e.type;return typeof t=="string"&&t==="client_error"}function va(e){return Ai(e)&&e.type==="wallet_not_on_device"}function gg(e){return Ai(e)&&(e.type==="invalid_recovery_pin"||e.type==="invalid_request_arguments")}function wa(e){return!!(Ai(e)&&e.type==="mfa_timeout")}function ba(e){return!!(Ai(e)&&e.type==="missing_or_invalid_mfa")}function du(e){return!!(Ai(e)&&e.type==="mfa_verification_max_attempts_reached")}function Kc(e){return!!(Ai(e)&&e.message.includes("code 429"))}function Yc(e){return!!(f5(e)&&e.message==="MFA canceled")}function pu({isCreatingWallet:e,skipSplashScreen:t}){return e?"EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN":t?"EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN":"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN"}function Qc({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:r,isResettingPassword:o,showAutomaticRecovery:n}){return n?"EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN":r||t.length===1?pu({isCreatingWallet:e==="create",skipSplashScreen:o}):"EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN"}function Xc(e){switch(e){case"user-passcode":return"EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN";case"google-drive":return"EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN";case"icloud":return"EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN";default:throw new Error("Recovery method not supported")}}async function uu({api:e,provider:t}){let r=na(),o=$a(),n=await ei(r);try{return t==="icloud"?{url:(await e.post(eh,{client_type:"web"})).url}:{url:(await e.post($f,{redirect_to:window.location.href,code_challenge:n,state_code:o})).url,codeVerifier:r,stateCode:o,provider:t}}catch(a){throw de(a)}}async function Cg({api:e,provider:t,stateCode:r,codeVerifier:o,authorizationCode:n}){if(!n||!r)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if(n==="undefined")throw new C("User denied confirmation during OAuth flow");try{return(await e.post(th,{authorization_code:n,state_code:r,code_verifier:o,provider:t})).access_token}catch(a){let i=de(a);throw i.privyErrorCode?new C(i.message||"Invalid code during OAuth flow.",void 0,i.privyErrorCode):i.message==="User denied confirmation during OAuth flow"?new C("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new C("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}import{Fragment as wg,jsx as xi,jsxs as mu}from"react/jsx-runtime";var vg=1,bg=()=>{let{authenticated:e,user:t,getAccessToken:r}=z(),{closePrivyModal:o,createAnalyticsEvent:n,walletProxy:a}=R(),{navigate:i,data:s,setModalData:l,onUserCloseViaDialogOrKeybindRef:d}=x(),p=g5(()=>Date.now(),[]),[m,h]=C5(!1),{onCompleteNavigateTo:g,onFailure:v,shouldForceMFA:w,address:E}=s?.connectWallet,I=T=>{m||(h(!0),v(typeof T=="string"?new Error(T):T))};y5(()=>{let T=E?t?.linkedAccounts.find(_=>_.type==="wallet"&&_.walletClientType==="privy"&&_.address===E):Be(t),P;return!e||!T?I("User must be authenticated and have a Privy wallet before it can be connected"):a?((async()=>{let _=await r();if(!_)return I("User must be authenticated and have a Privy wallet before it can be connected");try{await a.connect({accessToken:_,address:T.address}),w&&await a.verifyMfa({accessToken:_});let D=(Date.now()-p)/1e3;g==="EMBEDDED_WALLET_KEY_EXPORT_SCREEN"&&D<vg?P=setTimeout(()=>{i(g,!1)},(vg-D)*1e3):i(g,!1)}catch(D){if(va(D)&&T.recoveryMethod==="privy"){let
|
|
1076
|
+
`;var yg=["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"];var Ue=class extends Error{constructor(r,o){super(o);this.type=r}};function Ai(e){let t=e.type;return typeof t=="string"&&yg.includes(t)}function f5(e){let t=e.type;return typeof t=="string"&&t==="client_error"}function va(e){return Ai(e)&&e.type==="wallet_not_on_device"}function gg(e){return Ai(e)&&(e.type==="invalid_recovery_pin"||e.type==="invalid_request_arguments")}function wa(e){return!!(Ai(e)&&e.type==="mfa_timeout")}function ba(e){return!!(Ai(e)&&e.type==="missing_or_invalid_mfa")}function du(e){return!!(Ai(e)&&e.type==="mfa_verification_max_attempts_reached")}function Kc(e){return!!(Ai(e)&&e.message.includes("code 429"))}function Yc(e){return!!(f5(e)&&e.message==="MFA canceled")}function pu({isCreatingWallet:e,skipSplashScreen:t}){return e?"EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN":t?"EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN":"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN"}function Qc({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:r,isResettingPassword:o,showAutomaticRecovery:n}){return n?"EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN":r||t.length===1?pu({isCreatingWallet:e==="create",skipSplashScreen:o}):"EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN"}function Xc(e){switch(e){case"user-passcode":return"EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN";case"google-drive":return"EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN";case"icloud":return"EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN";default:throw new Error("Recovery method not supported")}}async function uu({api:e,provider:t}){let r=na(),o=$a(),n=await ei(r);try{return t==="icloud"?{url:(await e.post(eh,{client_type:"web"})).url}:{url:(await e.post($f,{redirect_to:window.location.href,code_challenge:n,state_code:o})).url,codeVerifier:r,stateCode:o,provider:t}}catch(a){throw de(a)}}async function Cg({api:e,provider:t,stateCode:r,codeVerifier:o,authorizationCode:n}){if(!n||!r)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if(n==="undefined")throw new C("User denied confirmation during OAuth flow");try{return(await e.post(th,{authorization_code:n,state_code:r,code_verifier:o,provider:t})).access_token}catch(a){let i=de(a);throw i.privyErrorCode?new C(i.message||"Invalid code during OAuth flow.",void 0,i.privyErrorCode):i.message==="User denied confirmation during OAuth flow"?new C("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new C("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}import{Fragment as wg,jsx as xi,jsxs as mu}from"react/jsx-runtime";var vg=1,bg=()=>{let{authenticated:e,user:t,getAccessToken:r}=z(),{closePrivyModal:o,createAnalyticsEvent:n,walletProxy:a}=R(),{navigate:i,data:s,setModalData:l,onUserCloseViaDialogOrKeybindRef:d}=x(),p=g5(()=>Date.now(),[]),[m,h]=C5(!1),{onCompleteNavigateTo:g,onFailure:v,shouldForceMFA:w,address:E}=s?.connectWallet,I=T=>{m||(h(!0),v(typeof T=="string"?new Error(T):T))};y5(()=>{let T=E?t?.linkedAccounts.find(_=>_.type==="wallet"&&_.walletClientType==="privy"&&_.address===E):Be(t),P;return!e||!T?I("User must be authenticated and have a Privy wallet before it can be connected"):a?((async()=>{let _=await r();if(!_)return I("User must be authenticated and have a Privy wallet before it can be connected");let U=T.chainType==="ethereum";try{U?await a.connect({accessToken:_,address:T.address}):await a.connectSolana({accessToken:_,publicKey:T.address}),w&&await a.verifyMfa({accessToken:_});let D=(Date.now()-p)/1e3;g==="EMBEDDED_WALLET_KEY_EXPORT_SCREEN"&&D<vg?P=setTimeout(()=>{i(g,!1)},(vg-D)*1e3):i(g,!1)}catch(D){if(va(D)&&T.recoveryMethod==="privy"){let H=await r();if(!H)return I("User must be authenticated and have a Privy wallet before it can be recovered");try{n({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:T.address}}),U?(await a?.recover({address:T.address,accessToken:H,recoveryMethod:T.recoveryMethod}))?.address||I(new Error("Unable to recover wallet")):(await a?.recoverSolana({publicKey:T.address,accessToken:H}))?.publicKey||I(new Error("Unable to recover wallet")),g?i(g):o({shouldCallAuthOnSuccess:!1}),n({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:T.address}}),i(g)}catch{I("An error has occurred, please try again.")}}else if(va(D)&&T.recoveryMethod!=="privy"){l({...s,recoverWallet:{privyWallet:T,onCompleteNavigateTo:g,onFailure:v},recoveryOAuthStatus:{provider:T.recoveryMethod,action:"recover",isInAccountCreateFlow:!1}});let H=Xc(T.recoveryMethod);i(H)}else I(D)}})(),()=>clearTimeout(P)):void 0},[e,t,a]);let A=()=>{I("User exited before wallet could be connected"),o({shouldCallAuthOnSuccess:!1})};return d.current=A,mu(wg,{children:[xi(k,{onClose:A}),m?mu(wg,{children:[mu(Wr,{children:[xi(h5,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),xi(we,{title:"Something went wrong",description:"We\u2019re on it. Please try again later."})]}),xi(F,{onClick:()=>o({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):xi(zc,{}),xi(w5,{})]})},w5=v5.div`
|
|
1077
1077
|
height: 44px;
|
|
1078
|
-
`;import b5 from"@heroicons/react/24/solid/CheckCircleIcon";import{useEffect as E5}from"react";import{Fragment as T5,jsx as ki,jsxs as Eg}from"react/jsx-runtime";var Tg=()=>{let{user:e}=z(),{closePrivyModal:t,isNewUserThisSession:r,updateWallets:o}=R(),{app:n,data:a,onUserCloseViaDialogOrKeybindRef:i}=x(),{onSuccess:s,onFailure:l,callAuthOnSuccessOnClose:d}=a.createWallet,p=()=>{let m=Be(e);m?(o(),s(m)):l(new Error("Failed to create wallet")),t({shouldCallAuthOnSuccess:d})};return E5(()=>{let m=setTimeout(p,Km);return()=>clearTimeout(m)},[]),i.current=p,Eg(T5,{children:[ki(k,{onClose:p}),ki(le,{}),Eg(Wr,{children:[ki(b5,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),ki(we,{title:r?`Welcome${n?.name?` to ${n?.name}`:""}`:"All set!",description:r?"You\u2019ve successfully created an account.":"Your account is secured."})]}),ki(ce,{}),ki(
|
|
1078
|
+
`;import b5 from"@heroicons/react/24/solid/CheckCircleIcon";import{useEffect as E5}from"react";import{Fragment as T5,jsx as ki,jsxs as Eg}from"react/jsx-runtime";var Tg=()=>{let{user:e}=z(),{closePrivyModal:t,isNewUserThisSession:r,updateWallets:o}=R(),{app:n,data:a,onUserCloseViaDialogOrKeybindRef:i}=x(),{onSuccess:s,onFailure:l,callAuthOnSuccessOnClose:d}=a.createWallet,p=()=>{let m=Be(e);m?(o(),s(m)):l(new Error("Failed to create wallet")),t({shouldCallAuthOnSuccess:d})};return E5(()=>{let m=setTimeout(p,Km);return()=>clearTimeout(m)},[]),i.current=p,Eg(T5,{children:[ki(k,{onClose:p}),ki(le,{}),Eg(Wr,{children:[ki(b5,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),ki(we,{title:r?`Welcome${n?.name?` to ${n?.name}`:""}`:"All set!",description:r?"You\u2019ve successfully created an account.":"Your account is secured."})]}),ki(ce,{}),ki(V,{})]})};import{useEffect as Ag,useRef as I5,useState as fu}from"react";import hu from"styled-components";import{ExclamationTriangleIcon as S5}from"@heroicons/react/24/outline";import P5 from"styled-components";import{jsx as x5,jsxs as k5}from"react/jsx-runtime";var Sg=({children:e,theme:t})=>k5(A5,{$theme:t,children:[x5(S5,{width:"1.25rem",color:t==="dark"?"#FDE68A":"var(--privy-color-warn)"}),e]}),A5=P5.div`
|
|
1079
1079
|
display: flex;
|
|
1080
1080
|
gap: 0.5rem;
|
|
1081
1081
|
background-color: ${e=>e.$theme==="dark"?"var(--privy-color-background-2)":"var(--privy-color-warn-light)"};
|
|
@@ -1113,7 +1113,7 @@ Resources:
|
|
|
1113
1113
|
font-weight: 600;
|
|
1114
1114
|
line-height: 1.875rem; /* 166.667% */
|
|
1115
1115
|
text-align: center;
|
|
1116
|
-
`;import{Fragment as N5,jsx as ro,jsxs as Zc}from"react/jsx-runtime";var xg=()=>{let[e,t]=fu(null),{authenticated:r,user:o,getAccessToken:n}=z(),{closePrivyModal:a,createAnalyticsEvent:i,clientAnalyticsId:s}=R(),l=_e(),{data:d,onUserCloseViaDialogOrKeybindRef:p}=x(),{onFailure:m,onSuccess:h,origin:g,appId:v,appClientId:w,wallet:E}=d.keyExport,I=T=>{a({shouldCallAuthOnSuccess:!1}),m(typeof T=="string"?new Error(T):T)},A=()=>{a({shouldCallAuthOnSuccess:!1}),h(),i({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:E.address}})};return Ag(()=>{if(!r||!E)return I("User must be authenticated before exporting their wallet");n().then(t,I)},[r,o]),p.current=A,Zc(N5,{children:[ro(k,{onClose:A}),Zc(W5,{children:[ro(wo,{children:"Transfer wallet"}),Zc(to,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",ro("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),ro(Sg,{theme:l.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),ro(Xa,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:E.address,showIcon:!0}),ro("div",{style:{width:"100%"},children:e&&ro(M5,{origin:g,appId:v,appClientId:w,accessToken:e,clientAnalyticsId:s,wallet:E,dimensions:{height:"44px"}})})]}),ro(
|
|
1116
|
+
`;import{Fragment as N5,jsx as ro,jsxs as Zc}from"react/jsx-runtime";var xg=()=>{let[e,t]=fu(null),{authenticated:r,user:o,getAccessToken:n}=z(),{closePrivyModal:a,createAnalyticsEvent:i,clientAnalyticsId:s}=R(),l=_e(),{data:d,onUserCloseViaDialogOrKeybindRef:p}=x(),{onFailure:m,onSuccess:h,origin:g,appId:v,appClientId:w,wallet:E}=d.keyExport,I=T=>{a({shouldCallAuthOnSuccess:!1}),m(typeof T=="string"?new Error(T):T)},A=()=>{a({shouldCallAuthOnSuccess:!1}),h(),i({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:E.address}})};return Ag(()=>{if(!r||!E)return I("User must be authenticated before exporting their wallet");n().then(t,I)},[r,o]),p.current=A,Zc(N5,{children:[ro(k,{onClose:A}),Zc(W5,{children:[ro(wo,{children:"Transfer wallet"}),Zc(to,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",ro("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),ro(Sg,{theme:l.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),ro(Xa,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:E.address,showIcon:!0}),ro("div",{style:{width:"100%"},children:e&&ro(M5,{origin:g,appId:v,appClientId:w,accessToken:e,clientAnalyticsId:s,wallet:E,dimensions:{height:"44px"}})})]}),ro(V,{})]})};function M5(e){let[t,r]=fu(e.dimensions.width),[o,n]=fu(void 0),a=I5(null);Ag(()=>{if(a.current&&t===void 0){let{width:l}=a.current.getBoundingClientRect();r(l)}let s=getComputedStyle(document.documentElement);n({background:s.getPropertyValue("--privy-color-background"),background2:s.getPropertyValue("--privy-color-background-2"),foreground3:s.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:s.getPropertyValue("--privy-color-foreground-accent"),accent:s.getPropertyValue("--privy-color-accent"),accentDark:s.getPropertyValue("--privy-color-accent-dark"),success:s.getPropertyValue("--privy-color-success")})},[]);let i=e.wallet.chainType==="ethereum"&&!e.wallet.imported;return ro("div",{ref:a,children:t&&Zc(L5,{children:[ro("iframe",{style:{position:"absolute",zIndex:1},width:t,height:e.dimensions.height,allow:"clipboard-write self *",src:Al(e.origin,`/apps/${e.appId}/embedded-wallets/export`,{client_id:e.appClientId,address:e.wallet.address,width:`${t}px`,caid:e.clientAnalyticsId,phrase_export:i,...o},{token:e.accessToken})}),ro(Pg,{children:"Loading..."}),i&&ro(Pg,{children:"Loading..."})]})})}var W5=hu.div`
|
|
1117
1117
|
display: flex;
|
|
1118
1118
|
flex-direction: column;
|
|
1119
1119
|
gap: 1.25rem;
|
|
@@ -1317,7 +1317,7 @@ Resources:
|
|
|
1317
1317
|
transition: all 0.1s ease-out;
|
|
1318
1318
|
background: ${({label:e})=>e==="Strong"&&"#78dca6"||e==="Medium"&&"var(--privy-color-warn)"||"var(--privy-color-error)"};
|
|
1319
1319
|
}
|
|
1320
|
-
`;import{Fragment as X5,jsx as Or,jsxs as $c}from"react/jsx-runtime";var Ng=({buttonHideAnimations:e,buttonLoading:t,password:r,onSubmit:o,onBack:n})=>{let[a,i]=Cu(!0),[s,l]=Cu(!1),[d,p]=Cu(""),m=r===d;return Q5(()=>{d&&!s&&l(!0)},[d]),$c(X5,{children:[Or(k,{closeable:!1,backFn:n}),Or(le,{}),$c(Pn,{children:[$c(kn,{children:[Or(Y5,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),Or("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm your password"}),Or("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please re-enter your password below to continue."})]}),$c(xn,{children:[Or(_i,{value:d,onChange:h=>p(h.target.value),onKeyUp:h=>{h.key==="Enter"&&o()},onBlur:()=>l(!0),placeholder:"confirm your password",type:a?"password":"text",style:{paddingRight:"2.3rem"}}),Or(Ii,{style:{right:"0.75rem"},children:a?Or(Mi,{onClick:()=>i(!1)}):Or(Wi,{onClick:()=>i(!0)})})]}),Or(jc,{"aria-hidden":!s||m,error:!0,children:"Passwords do not match"})]}),Or(An,{onClick:o,loading:t,disabled:!m,hideAnimations:e,children:"Continue"}),Or(ce,{}),Or(
|
|
1320
|
+
`;import{Fragment as X5,jsx as Or,jsxs as $c}from"react/jsx-runtime";var Ng=({buttonHideAnimations:e,buttonLoading:t,password:r,onSubmit:o,onBack:n})=>{let[a,i]=Cu(!0),[s,l]=Cu(!1),[d,p]=Cu(""),m=r===d;return Q5(()=>{d&&!s&&l(!0)},[d]),$c(X5,{children:[Or(k,{closeable:!1,backFn:n}),Or(le,{}),$c(Pn,{children:[$c(kn,{children:[Or(Y5,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),Or("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm your password"}),Or("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please re-enter your password below to continue."})]}),$c(xn,{children:[Or(_i,{value:d,onChange:h=>p(h.target.value),onKeyUp:h=>{h.key==="Enter"&&o()},onBlur:()=>l(!0),placeholder:"confirm your password",type:a?"password":"text",style:{paddingRight:"2.3rem"}}),Or(Ii,{style:{right:"0.75rem"},children:a?Or(Mi,{onClick:()=>i(!1)}):Or(Wi,{onClick:()=>i(!0)})})]}),Or(jc,{"aria-hidden":!s||m,error:!0,children:"Passwords do not match"})]}),Or(An,{onClick:o,loading:t,disabled:!m,hideAnimations:e,children:"Continue"}),Or(ce,{}),Or(V,{})]})};import $5 from"@heroicons/react/24/outline/ExclamationTriangleIcon";import{useState as e6}from"react";import t6 from"styled-components";import Ds from"styled-components";import{jsx as Os,jsxs as j5}from"react/jsx-runtime";var Og=({className:e,checked:t,color:r="var(--privy-color-accent)",...o})=>Os("label",{children:j5(Z5,{className:e,children:[Os(Ug,{checked:t,...o}),Os(J5,{color:r,checked:t,children:Os(Dg,{viewBox:"0 0 24 24",children:Os("polyline",{points:"20 6 9 17 4 12"})})})]})});var kF=Ds.label`
|
|
1321
1321
|
&& {
|
|
1322
1322
|
cursor: pointer;
|
|
1323
1323
|
display: flex;
|
|
@@ -1369,21 +1369,21 @@ Resources:
|
|
|
1369
1369
|
${Dg} {
|
|
1370
1370
|
visibility: ${e=>e.checked?"visible":"hidden"};
|
|
1371
1371
|
}
|
|
1372
|
-
`;import{Fragment as Fg,jsx as oo,jsxs as Us}from"react/jsx-runtime";var Bg=({buttonHideAnimations:e,buttonLoading:t,onSubmit:r,onBack:o,config:n})=>{let[a,i]=e6(!1);return Us(Fg,{children:[oo(k,{closeable:!1,backFn:o}),oo(le,{}),Us(Pn,{children:[Us(kn,{children:[oo($5,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-error)"}),oo("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm you have saved"}),oo("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Losing access to your password means you will lose access to your account."})]}),oo(Ls,{children:Us(Ns,{style:{color:"var(--privy-color-error)",cursor:"pointer"},onClick:s=>{s.preventDefault(),i(l=>!l)},children:[oo(Og,{color:"var(--privy-color-error)",readOnly:!0,checked:a}),oo(Fg,{children:"I understand that if I lose my password and device, I will lose access to my account and my assets."})]})})]}),Us(r6,{children:[n.initiatedBy==="user"&&oo(Mr,{onClick:n.onCancel,disabled:t,children:"Cancel"}),oo(An,{onClick:r,loading:t,hideAnimations:e,disabled:!a,children:"Set Password"})]}),oo(ce,{}),oo(
|
|
1372
|
+
`;import{Fragment as Fg,jsx as oo,jsxs as Us}from"react/jsx-runtime";var Bg=({buttonHideAnimations:e,buttonLoading:t,onSubmit:r,onBack:o,config:n})=>{let[a,i]=e6(!1);return Us(Fg,{children:[oo(k,{closeable:!1,backFn:o}),oo(le,{}),Us(Pn,{children:[Us(kn,{children:[oo($5,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-error)"}),oo("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm you have saved"}),oo("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Losing access to your password means you will lose access to your account."})]}),oo(Ls,{children:Us(Ns,{style:{color:"var(--privy-color-error)",cursor:"pointer"},onClick:s=>{s.preventDefault(),i(l=>!l)},children:[oo(Og,{color:"var(--privy-color-error)",readOnly:!0,checked:a}),oo(Fg,{children:"I understand that if I lose my password and device, I will lose access to my account and my assets."})]})})]}),Us(r6,{children:[n.initiatedBy==="user"&&oo(Mr,{onClick:n.onCancel,disabled:t,children:"Cancel"}),oo(An,{onClick:r,loading:t,hideAnimations:e,disabled:!a,children:"Set Password"})]}),oo(ce,{}),oo(V,{})]})},r6=t6.div`
|
|
1373
1373
|
display: flex;
|
|
1374
1374
|
gap: 10px;
|
|
1375
|
-
`;import C6 from"@heroicons/react/24/outline/KeyIcon";import Yg from"@heroicons/react/24/solid/CheckCircleIcon";import{useState as Qg,useMemo as vu,useEffect as v6}from"react";import Xg from"styled-components";import o6 from"fast-password-entropy";import*as Hg from"secure-password-utilities";import{DEFAULT_WORDLIST as n6}from"secure-password-utilities/wordlists";var a6=95,i6=8,s6=3,l6=.3,c6=/[a-z]/,d6=/[A-Z]/,p6=/[0-9]/,u6="a-zA-Z0-9",Vg="!@#$%^&*()\\-_+.",Gg=`${u6}${Vg}`,m6=new RegExp(`[${Vg}]`),f6=new RegExp(`[${Gg}]`),qg=new RegExp(`^[${Gg}]{6,}$`),zg=(e="")=>{let t=e.split("").filter(r=>!f6.test(r)).map(r=>r.replace(" ","SPACE"));return[...new Set(t)]},ed=()=>Hg.generatePassphrase(4,n6);function h6(e){return e>.9?"Strong":e>.5?"Medium":"Weak"}function y6(e){if(e.length<i6)return 0;let t=0;c6.test(e)&&(t+=1),d6.test(e)&&(t+=1),p6.test(e)&&(t+=1),m6.test(e)&&(t+=1);let r=t/s6;return Math.max(0,Math.min(1,r))}function g6(e=""){let t=y6(e),r=o6(e)/a6;return(t*l6+r)/2}function Kg(e=""){let t=g6(e);return{value:t,label:h6(t)}}import{Fragment as E6,jsx as Yt,jsxs as Fo}from"react/jsx-runtime";var Zg=({buttonHideAnimations:e,buttonLoading:t,password:r="",config:o,isResettingPassword:n,onSubmit:a,onClose:i,onBack:s,onPasswordChange:l,onPasswordGenerate:d})=>{let[p,m]=Qg(!1),[h,g]=Qg(!1);v6(()=>{r&&!h&&g(!0)},[r]);let v=vu(()=>h?(r?.length||0)<6?"Password must be at least 6 characters":qg.test(r||"")?null:`Invalid characters used ( ${zg(r).join(" ")} )`:null,[r,h]),w=vu(()=>v?{value:0,label:"Weak"}:Kg(r),[r,v]),E=vu(()=>!!(!r?.length||v),[v,r]);return Fo(E6,{children:[Yt(k,{onClose:i,closeable:o.initiatedBy==="user",backFn:s}),Yt(le,{}),Fo(Pn,{children:[Fo(kn,{children:[Yt(C6,{height:48,width:48,stroke:"var(--privy-color-accent)"}),Fo("h3",{style:{color:"var(--privy-color-foreground)"},children:[n?"Reset":"Set"," your password"]}),Yt("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Select a strong, memorable password to secure your account."})]}),Fo(xn,{children:[Yt(_i,{value:r,onChange:I=>l(I.target.value),onKeyUp:I=>{I.key==="Enter"&&a()},placeholder:"enter or generate a strong password",type:p?"password":"text",style:{paddingRight:"3.8rem"}}),Fo(Ii,{style:{width:"3.5rem"},children:[p?Yt(Mi,{onClick:()=>m(!1)}):Yt(Wi,{onClick:()=>m(!0)}),Yt(Wg,{onClick:d})]})]}),Yt(Lg,{value:w.value===0?.01:w.value,label:w.label}),Yt(jc,{error:!!v,children:v||`Password Strength: ${h?w.label:"--"}`}),Fo(b6,{children:[Yt(w6,{children:Fo(Ls,{children:[Fo(Ns,{children:[Yt(Yg,{width:24,height:24,fill:"var(--privy-color-accent)"}),"This password is used to secure your account."]}),Fo(Ns,{children:[Yt(Yg,{width:24,height:24,fill:"var(--privy-color-accent)"}),"Use it to log in on a new environment, like another browser or device."]})]})}),Yt(An,{onClick:a,loading:t,disabled:E,hideAnimations:e,children:"Continue"})]})]}),Yt(ce,{}),Yt(
|
|
1375
|
+
`;import C6 from"@heroicons/react/24/outline/KeyIcon";import Yg from"@heroicons/react/24/solid/CheckCircleIcon";import{useState as Qg,useMemo as vu,useEffect as v6}from"react";import Xg from"styled-components";import o6 from"fast-password-entropy";import*as Hg from"secure-password-utilities";import{DEFAULT_WORDLIST as n6}from"secure-password-utilities/wordlists";var a6=95,i6=8,s6=3,l6=.3,c6=/[a-z]/,d6=/[A-Z]/,p6=/[0-9]/,u6="a-zA-Z0-9",Vg="!@#$%^&*()\\-_+.",Gg=`${u6}${Vg}`,m6=new RegExp(`[${Vg}]`),f6=new RegExp(`[${Gg}]`),qg=new RegExp(`^[${Gg}]{6,}$`),zg=(e="")=>{let t=e.split("").filter(r=>!f6.test(r)).map(r=>r.replace(" ","SPACE"));return[...new Set(t)]},ed=()=>Hg.generatePassphrase(4,n6);function h6(e){return e>.9?"Strong":e>.5?"Medium":"Weak"}function y6(e){if(e.length<i6)return 0;let t=0;c6.test(e)&&(t+=1),d6.test(e)&&(t+=1),p6.test(e)&&(t+=1),m6.test(e)&&(t+=1);let r=t/s6;return Math.max(0,Math.min(1,r))}function g6(e=""){let t=y6(e),r=o6(e)/a6;return(t*l6+r)/2}function Kg(e=""){let t=g6(e);return{value:t,label:h6(t)}}import{Fragment as E6,jsx as Yt,jsxs as Fo}from"react/jsx-runtime";var Zg=({buttonHideAnimations:e,buttonLoading:t,password:r="",config:o,isResettingPassword:n,onSubmit:a,onClose:i,onBack:s,onPasswordChange:l,onPasswordGenerate:d})=>{let[p,m]=Qg(!1),[h,g]=Qg(!1);v6(()=>{r&&!h&&g(!0)},[r]);let v=vu(()=>h?(r?.length||0)<6?"Password must be at least 6 characters":qg.test(r||"")?null:`Invalid characters used ( ${zg(r).join(" ")} )`:null,[r,h]),w=vu(()=>v?{value:0,label:"Weak"}:Kg(r),[r,v]),E=vu(()=>!!(!r?.length||v),[v,r]);return Fo(E6,{children:[Yt(k,{onClose:i,closeable:o.initiatedBy==="user",backFn:s}),Yt(le,{}),Fo(Pn,{children:[Fo(kn,{children:[Yt(C6,{height:48,width:48,stroke:"var(--privy-color-accent)"}),Fo("h3",{style:{color:"var(--privy-color-foreground)"},children:[n?"Reset":"Set"," your password"]}),Yt("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Select a strong, memorable password to secure your account."})]}),Fo(xn,{children:[Yt(_i,{value:r,onChange:I=>l(I.target.value),onKeyUp:I=>{I.key==="Enter"&&a()},placeholder:"enter or generate a strong password",type:p?"password":"text",style:{paddingRight:"3.8rem"}}),Fo(Ii,{style:{width:"3.5rem"},children:[p?Yt(Mi,{onClick:()=>m(!1)}):Yt(Wi,{onClick:()=>m(!0)}),Yt(Wg,{onClick:d})]})]}),Yt(Lg,{value:w.value===0?.01:w.value,label:w.label}),Yt(jc,{error:!!v,children:v||`Password Strength: ${h?w.label:"--"}`}),Fo(b6,{children:[Yt(w6,{children:Fo(Ls,{children:[Fo(Ns,{children:[Yt(Yg,{width:24,height:24,fill:"var(--privy-color-accent)"}),"This password is used to secure your account."]}),Fo(Ns,{children:[Yt(Yg,{width:24,height:24,fill:"var(--privy-color-accent)"}),"Use it to log in on a new environment, like another browser or device."]})]})}),Yt(An,{onClick:a,loading:t,disabled:E,hideAnimations:e,children:"Continue"})]})]}),Yt(ce,{}),Yt(V,{})]})},w6=Xg(Ls)`
|
|
1376
1376
|
flex: 1;
|
|
1377
1377
|
padding-top: 1rem;
|
|
1378
1378
|
`,b6=Xg.div`
|
|
1379
1379
|
display: flex;
|
|
1380
1380
|
flex-direction: column;
|
|
1381
1381
|
height: 100%;
|
|
1382
|
-
`;import T6 from"@heroicons/react/24/outline/ArrowDownTrayIcon";import S6 from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import P6 from"@heroicons/react/24/outline/DocumentDuplicateIcon";import A6 from"@heroicons/react/24/outline/ExclamationTriangleIcon";import{useState as x6,useCallback as Jg}from"react";import{Fragment as wu,jsx as br,jsxs as Ea}from"react/jsx-runtime";var jg=({buttonHideAnimations:e,buttonLoading:t,appName:r,password:o,onSubmit:n,onBack:a})=>{let[i,s]=x6(!1),l=Jg(()=>{s(!0),o&&navigator.clipboard.writeText(o)},[o]),d=Jg(()=>{let p=document.createElement("a"),m=r.toLowerCase().replace(/[^a-z\s]/g,"").replace(/\s/g,"-"),h=new Blob([k6(r,o)],{type:"text/plain"}),g=URL.createObjectURL(h);p.href=g,p.target="_blank",p.download=`${m}-privy-wallet-recovery.txt`,document.body.appendChild(p),p.click(),setTimeout(()=>{p.remove(),URL.revokeObjectURL(g)},5e3)},[o]);return Ea(wu,{children:[br(k,{backFn:a,closeable:!1}),br(le,{}),Ea(Pn,{children:[Ea(kn,{children:[br(A6,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),br("h3",{style:{color:"var(--privy-color-foreground)"},children:"Save your password"}),br("p",{style:{color:"var(--privy-color-foreground-2)"},children:"For your security, this password cannot be reset, so keep it somewhere safe."})]}),br(xn,{centered:!0,children:br(Mg,{children:o})}),Ea("div",{style:{display:"flex",margin:"12px 0",gap:"12px"},children:[br(gu,{onClick:l,children:i?Ea(wu,{children:[br(S6,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copied"]}):Ea(wu,{children:[br(P6,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copy"]})}),Ea(gu,{onClick:d,children:[br(T6,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Download"]})]})]}),br(An,{onClick:n,loading:t,hideAnimations:e,children:"Continue"}),br(ce,{}),br(
|
|
1382
|
+
`;import T6 from"@heroicons/react/24/outline/ArrowDownTrayIcon";import S6 from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import P6 from"@heroicons/react/24/outline/DocumentDuplicateIcon";import A6 from"@heroicons/react/24/outline/ExclamationTriangleIcon";import{useState as x6,useCallback as Jg}from"react";import{Fragment as wu,jsx as br,jsxs as Ea}from"react/jsx-runtime";var jg=({buttonHideAnimations:e,buttonLoading:t,appName:r,password:o,onSubmit:n,onBack:a})=>{let[i,s]=x6(!1),l=Jg(()=>{s(!0),o&&navigator.clipboard.writeText(o)},[o]),d=Jg(()=>{let p=document.createElement("a"),m=r.toLowerCase().replace(/[^a-z\s]/g,"").replace(/\s/g,"-"),h=new Blob([k6(r,o)],{type:"text/plain"}),g=URL.createObjectURL(h);p.href=g,p.target="_blank",p.download=`${m}-privy-wallet-recovery.txt`,document.body.appendChild(p),p.click(),setTimeout(()=>{p.remove(),URL.revokeObjectURL(g)},5e3)},[o]);return Ea(wu,{children:[br(k,{backFn:a,closeable:!1}),br(le,{}),Ea(Pn,{children:[Ea(kn,{children:[br(A6,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),br("h3",{style:{color:"var(--privy-color-foreground)"},children:"Save your password"}),br("p",{style:{color:"var(--privy-color-foreground-2)"},children:"For your security, this password cannot be reset, so keep it somewhere safe."})]}),br(xn,{centered:!0,children:br(Mg,{children:o})}),Ea("div",{style:{display:"flex",margin:"12px 0",gap:"12px"},children:[br(gu,{onClick:l,children:i?Ea(wu,{children:[br(S6,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copied"]}):Ea(wu,{children:[br(P6,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copy"]})}),Ea(gu,{onClick:d,children:[br(T6,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Download"]})]})]}),br(An,{onClick:n,loading:t,hideAnimations:e,children:"Continue"}),br(ce,{}),br(V,{})]})},k6=(e,t)=>`Your wallet recovery password for ${e} is
|
|
1383
1383
|
|
|
1384
1384
|
${t}
|
|
1385
1385
|
|
|
1386
|
-
You will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;import R6 from"@heroicons/react/24/solid/CheckCircleIcon";import _6 from"@heroicons/react/24/solid/XCircleIcon";import{Fragment as I6,jsx as rn,jsxs as bu}from"react/jsx-runtime";var $g=({error:e,onClose:t})=>bu(I6,{children:[rn(k,{closeable:!1}),rn(le,{}),e?bu(Wr,{children:[rn(_6,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),rn(we,{title:"Something went wrong",description:e})]}):bu(Wr,{children:[rn(R6,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}),rn(we,{title:"Success"})]}),rn(F,{onClick:t,children:"Close"}),rn(ce,{}),rn(
|
|
1386
|
+
You will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;import R6 from"@heroicons/react/24/solid/CheckCircleIcon";import _6 from"@heroicons/react/24/solid/XCircleIcon";import{Fragment as I6,jsx as rn,jsxs as bu}from"react/jsx-runtime";var $g=({error:e,onClose:t})=>bu(I6,{children:[rn(k,{closeable:!1}),rn(le,{}),e?bu(Wr,{children:[rn(_6,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),rn(we,{title:"Something went wrong",description:e})]}):bu(Wr,{children:[rn(R6,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}),rn(we,{title:"Success"})]}),rn(F,{onClick:t,children:"Close"}),rn(ce,{}),rn(V,{})]});import{useReducer as M6}from"react";var W6=(e,t)=>{switch(e){case"creating":return t==="back"?e:"saving";case"saving":return t==="back"?"creating":"confirming";case"confirming":return t==="back"?"saving":"finalizing";case"finalizing":return t==="back"?"confirming":"done";default:return e}},e1=()=>{let[e,t]=M6(W6,"creating");return{send:t,state:e}};import{jsx as Fs}from"react/jsx-runtime";var td=({onSubmit:e,...t})=>{let{lastScreen:r,navigate:o}=x(),{send:n,state:a}=e1(),i=Eu(async()=>{a==="finalizing"&&await e(),n("next")},[a,n,e]);L6(()=>{let d;return a==="done"&&t.config.initiatedBy==="automatic"&&(d=setTimeout(()=>t.onClose?.(),Oe)),()=>{d&&clearTimeout(d)}},[a,t.config.initiatedBy,t.onClose]);let s=Eu(()=>{n("back")},[n]),l=Eu(()=>{o("EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN")},[r,o]);return a==="creating"?Fs(Zg,{...t,onSubmit:i,onBack:r==="EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN"?l:void 0}):a==="saving"?Fs(jg,{...t,onSubmit:i,onBack:s}):a==="confirming"?Fs(Ng,{...t,onSubmit:i,onBack:s}):a==="finalizing"?Fs(Bg,{...t,onSubmit:i,onBack:s}):a==="done"?Fs($g,{...t,onSubmit:i}):null};import{jsx as O6}from"react/jsx-runtime";var t1=()=>{let[e,t]=rd(null),[r,o]=rd(!1),[n,a]=rd(null),[i,s]=rd(""),{authenticated:l,getAccessToken:d,user:p}=z(),{walletProxy:m,refreshUser:h,closePrivyModal:g,createAnalyticsEvent:v}=R(),{app:w,navigate:E,data:I,onUserCloseViaDialogOrKeybindRef:A}=x(),{onSuccess:T,onFailure:P}=I.createWallet,S=Be(p),_=e?.recoveryMethod==="user-passcode",U=S?.recoveryMethod==="user-passcode";N6(()=>{l||(E("LANDING"),P(new Om("User must be authenticated before setting a password on a Privy wallet")))},[l]);let D=()=>{if(n){P(n),g({shouldCallAuthOnSuccess:!1});return}if(!_){P(new kr("Exited before password was added to wallet")),g({shouldCallAuthOnSuccess:!1});return}T(e),g({shouldCallAuthOnSuccess:!1})};A.current=D;let H=async()=>{let Y=await d();if(Y&&S?.address&&i&&m)try{if(v({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:S.address,existingRecoveryMethod:S.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:U}}),!(await m.setRecovery({accessToken:Y,address:S.address,recoveryPassword:i,recoveryMethod:"user-passcode"})).address){a(new kr("Error setting password on privy wallet")),v({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:S.address,existingRecoveryMethod:S.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:U,reason:"error setting password"}});return}let O=await h(),Q=Be(O);if(!Q){a(new kr("Error setting password on privy wallet")),v({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:S.address,existingRecoveryMethod:S.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:U,reason:"wallet disconnected"}});return}t(Q),v({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:S.address,existingRecoveryMethod:S.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:U}})}catch(K){console.warn(K),a(K instanceof Error?K:new Error("Error setting password on privy wallet")),v({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:S.address,reason:K}})}},B=async()=>{_?(T(e),g({shouldCallAuthOnSuccess:!1})):(o(!0),a(null),await H(),o(!1))};return O6(td,{appName:w?.name||"privy",config:{initiatedBy:"user",onCancel:D},error:n?"An error has occurred, please try again.":void 0,buttonLoading:r,buttonHideAnimations:!1,password:i,isResettingPassword:U,onPasswordGenerate:()=>s(ed()),onPasswordChange:s,onSubmit:B,onClose:D})};import D6 from"@heroicons/react/24/outline/UserCircleIcon";import U6 from"@heroicons/react/24/solid/LockClosedIcon";import{Fragment as F6,jsx as on,jsxs as od}from"react/jsx-runtime";var r1=()=>{let{closePrivyModal:e}=R(),{data:t,setModalData:r,navigate:o,onUserCloseViaDialogOrKeybindRef:n}=x(),{onSuccess:a,onFailure:i}=t.setWalletPassword,s=()=>{i(new kr("Exited before password was added to wallet")),e({shouldCallAuthOnSuccess:!1})};return n.current=s,od(F6,{children:[on(k,{onClose:s}),on(le,{}),od(Wr,{children:[od(Iy,{children:[on(D6,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),on(My,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:on(U6,{width:"12px",height:"12px",fill:"white"})})]}),od(we,{title:"Secure Your Account",children:["Please set a password to secure your account.",on("p",{children:"Losing access to this password and this device will make your account inaccessible."})]})]}),on(F,{onClick:()=>{r({createWallet:{onFailure:i,onSuccess:a,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),o("EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN")},children:"Add password"}),on(ce,{}),on(V,{})]})};import B6 from"@heroicons/react/24/outline/ExclamationTriangleIcon";import H6 from"@heroicons/react/24/outline/PhoneIcon";import o1 from"styled-components";import{Fragment as z6,jsx as no,jsxs as nd}from"react/jsx-runtime";var V6=(e,t)=>{let r=no(B6,{height:38,width:38,stroke:"var(--privy-color-error)"});if(e instanceof C)switch(e.privyErrorCode){case"client_request_timeout":return{title:"Timed out",detail:e.message,ctaText:"Try again",icon:r};case"insufficient_balance":return{title:"Insufficient balance",detail:e.message,ctaText:"Try again",icon:r};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:r}}else{if(e instanceof Ue&&e.type==="twilio_verification_failed")return{title:"Something went wrong",detail:e.message,ctaText:"Try again",icon:no(H6,{height:38,width:38,stroke:"var(--privy-color-error)"})};if(e instanceof pr)switch(e.privyErrorCode){case"invalid_captcha":return{title:"Something went wrong",detail:"Please try again.",ctaText:"Try again",icon:r};case"disallowed_login_method":return{title:"Not allowed",detail:e.message,ctaText:"Try another method",icon:r};case"allowlist_rejected":return{title:t.errorTitle||"You don't have access to this app",detail:t.errorDetail||"Have you been invited?",ctaText:t.errorCtaText||"Try another account",icon:no(Oc,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})};case"captcha_failure":return{title:"Something went wrong",detail:"You did not pass CAPTCHA. Please try again.",ctaText:"Try again",icon:no("span",{})};case"captcha_timeout":return{title:"Something went wrong",detail:"Something went wrong! Please try again later.",ctaText:"Try again",icon:no("span",{})};case"linked_to_another_user":return{title:"Authentication failed",detail:"This account has already been linked to another user.",ctaText:"Try again",icon:r};case"not_supported":return{title:"This region is not supported",detail:"SMS authentication from this region is not available",ctaText:"Try another method",icon:r};case"too_many_requests":return{title:"Request failed",detail:"Too many attempts.",ctaText:"Try again later",icon:r};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:r}}else return e instanceof xr&&e.status&&[400,422].includes(e.status)?{title:"Something went wrong",detail:e.message,ctaText:"Try again",icon:r}:{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:r}}},n1=()=>{let{navigate:e,navigateBack:t,data:r,lastScreen:o,currentScreen:n}=x(),a=r?.errorModalData?.previousScreen||(o===n?void 0:o);return no(nn,{error:r?.errorModalData?.error||new Error,backFn:()=>a?e(a,!1):t(),onClick:()=>e(a||"LANDING",!1)})},nn=({error:e,backFn:t,onClick:r})=>{let{reset:o}=Te(),{app:n}=x(),a=V6(e,n.allowlistConfig),i=()=>{if(e instanceof pr&&(e.privyErrorCode==="invalid_captcha"&&o(),e.privyErrorCode==="allowlist_rejected"&&n.allowlistConfig.errorCtaLink)){window.location.href=n.allowlistConfig.errorCtaLink;return}r?.()};return nd(z6,{children:[no(k,{backFn:t}),nd(G6,{children:[no(Ye,{children:nd("div",{children:[no(fi,{color:"var(--privy-color-error)"}),a.icon]})}),nd(q6,{children:[no("h3",{children:a.title}),no("p",{children:a.detail})]}),no(F,{color:"var(--privy-color-error)",onClick:i,children:a.ctaText})]})]})},G6=o1.div`
|
|
1387
1387
|
display: flex;
|
|
1388
1388
|
flex-direction: column;
|
|
1389
1389
|
align-items: center;
|
|
@@ -1485,7 +1485,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
1485
1485
|
border-color: ${e=>e.borderColor};
|
|
1486
1486
|
border-radius: var(--privy-border-radius-md);
|
|
1487
1487
|
}
|
|
1488
|
-
`,_n=e=>{let{appearance:t}=_e(),r=e.bgColor||"#FFFFFF",o=e.fgColor||"#000000",n=e.size||160,a=t.palette.colorScheme==="dark"?r:o;return tr(cb,{size:n,bgColor:r,fgColor:o,borderColor:a,children:tr(lb,{url:e.url,logo:{element:e.squareLogoElement??l1},outputSize:n,bgColor:r,fgColor:o,errorCorrectionLevel:e.errorCorrectionLevel||"Q"})})};import{jsx as id,jsxs as db}from"react/jsx-runtime";var Bo=({style:e,...t})=>db("svg",{width:"1000",height:"1000",viewBox:"0 0 1000 1000",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",...e},...t,children:[id("rect",{width:"1000",height:"1000",rx:"200",fill:"#855DCD"}),id("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"}),id("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"}),id("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"})]});import{Fragment as sd,jsx as Ne,jsxs as Ho}from"react/jsx-runtime";var u1="#8a63d2",h1=1e3,mb=h1*2,fb=h1*120,y1=()=>{let{authenticated:e,logout:t,ready:r,user:o}=z(),{lastScreen:n,navigate:a,navigateBack:i,setModalData:s,app:l}=x(),{getAuthFlow:d,loginWithFarcaster:p,closePrivyModal:m,createAnalyticsEvent:h}=R(),[g,v]=Su(void 0),[w,E]=Su(!1),[I,A]=Su(!1),T=pb([]),P=Oe,S=d(),_=S?.meta.connectUri;return d1(()=>{let
|
|
1488
|
+
`,_n=e=>{let{appearance:t}=_e(),r=e.bgColor||"#FFFFFF",o=e.fgColor||"#000000",n=e.size||160,a=t.palette.colorScheme==="dark"?r:o;return tr(cb,{size:n,bgColor:r,fgColor:o,borderColor:a,children:tr(lb,{url:e.url,logo:{element:e.squareLogoElement??l1},outputSize:n,bgColor:r,fgColor:o,errorCorrectionLevel:e.errorCorrectionLevel||"Q"})})};import{jsx as id,jsxs as db}from"react/jsx-runtime";var Bo=({style:e,...t})=>db("svg",{width:"1000",height:"1000",viewBox:"0 0 1000 1000",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",...e},...t,children:[id("rect",{width:"1000",height:"1000",rx:"200",fill:"#855DCD"}),id("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"}),id("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"}),id("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"})]});import{Fragment as sd,jsx as Ne,jsxs as Ho}from"react/jsx-runtime";var u1="#8a63d2",h1=1e3,mb=h1*2,fb=h1*120,y1=()=>{let{authenticated:e,logout:t,ready:r,user:o}=z(),{lastScreen:n,navigate:a,navigateBack:i,setModalData:s,app:l}=x(),{getAuthFlow:d,loginWithFarcaster:p,closePrivyModal:m,createAnalyticsEvent:h}=R(),[g,v]=Su(void 0),[w,E]=Su(!1),[I,A]=Su(!1),T=pb([]),P=Oe,S=d(),_=S?.meta.connectUri;return d1(()=>{let U=Date.now(),D=setInterval(async()=>{let H=await S.pollForReady.execute(),B=Date.now()-U;if(H){clearInterval(D),E(!0);try{await p(),A(!0)}catch(Y){let K={retryable:!1,message:"Authentication failed"};if(Y?.privyErrorCode==="allowlist_rejected"){a("ALLOWLIST_REJECTION_SCREEN");return}else if(Y?.privyErrorCode==="max_accounts_reached"){console.error(new Ao(Y).toString()),a("USER_LIMIT_REACHED_SCREEN");return}else if(Y?.privyErrorCode==="user_does_not_exist"){a("ACCOUNT_NOT_FOUND_SCREEN");return}else if(Y?.privyErrorCode==="linked_to_another_user")K.detail="This account has already been linked to another user.";else if(Y?.privyErrorCode==="account_transfer_required"&&Y.data?.data?.nonce){s({accountTransfer:{nonce:Y.data?.data?.nonce,account:Y.data?.data?.subject,displayName:Y.data?.data?.account?.displayName,linkMethod:"farcaster",embeddedWalletAddress:Y.data?.data?.otherUser?.embeddedWalletAddress,farcasterEmbeddedAddress:Y.data?.data?.otherUser?.farcasterEmbeddedAddress}}),a("LINK_CONFLICT_SCREEN");return}else Y?.privyErrorCode==="invalid_credentials"?(K.retryable=!0,K.detail="Something went wrong. Try again."):Y?.privyErrorCode==="too_many_requests"&&(K.detail="Too many requests. Please wait before trying again.");v(K)}}else B>fb&&(clearInterval(D),v({retryable:!0,message:"Authentication failed",detail:"The request timed out. Try again."}))},mb);return()=>{clearInterval(D),T.current.forEach(H=>clearTimeout(H))}},[]),d1(()=>{if(r&&e&&I&&o){if(l?.legal.requireUsersAcceptTerms&&!o.hasAcceptedTerms){let D=setTimeout(()=>{a("AFFIRMATIVE_CONSENT_SCREEN")},P);return()=>clearTimeout(D)}I&&(It(o,l?.embeddedWallets.createOnLogin)?T.current.push(setTimeout(()=>{s({createWallet:{onSuccess:()=>{},onFailure:D=>{console.error(D),h({eventName:"embedded_wallet_creation_failure_logout",payload:{error:D,screen:"FarcasterConnectStatusScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),a("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")},P)):T.current.push(setTimeout(()=>m({shouldCallAuthOnSuccess:!0,isSuccess:!0}),P)))}},[I,r,e,o]),p1||w?Ho(sd,{children:[Ne(k,{backFn:n?i:void 0,onClose:m},"header"),Ne(le,{}),ub?Ne(sd,{children:Ho(hb,{children:[Ne(Ye,{children:Ho("div",{children:[Ne(ht,{success:I,fail:!!g}),Ne(Bo,{style:{width:"38px",height:"38px"}})]})}),Ho(at,{children:[Ne(ye,{children:g?g.message:"Sign in with Farcaster"}),Ne(ve,{children:g?g.detail:"To sign in with Farcaster, please open the Warpcast app."})]}),_&&Ne(F,{onClick:U=>{U.preventDefault(),window.location.href=_},children:"Open Warpcast app"})]})}):Ne(sd,{children:Ho(m1,{children:[Ne(Ye,{children:Ho("div",{children:[Ne(ht,{success:I,fail:!!g}),Ne(Bo,{style:{width:"38px",height:"38px"}})]})}),Ho(at,{children:[Ne(ye,{children:g?g.message:"Signing in with Farcaster"}),Ne(ve,{children:g?g.detail:"This should only take a moment"}),Ne(Ot,{children:_&&p1&&Ne(ad,{text:"Take me to Warpcast",url:_,color:u1})})]})]})}),Ne(j,{})]}):Ho(sd,{children:[Ne(k,{backFn:n?i:void 0,onClose:m},"header"),Ne(le,{}),Ne(m1,{children:Ho("div",{children:[Ne(ye,{children:"Sign in with Farcaster"}),Ne(ve,{children:"Scan with your phone's camera to continue."}),Ne(gi,{children:_?Ne(_n,{url:_,size:275,squareLogoElement:Bo}):Ne(yt,{})}),Ho(Ot,{children:[Ne(ve,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),_&&Ne(Rn,{text:_,itemName:"link",color:u1})]})]})}),Ne(j,{})]})},m1=f1.div`
|
|
1489
1489
|
display: flex;
|
|
1490
1490
|
flex-direction: column;
|
|
1491
1491
|
align-items: center;
|
|
@@ -1852,12 +1852,12 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
1852
1852
|
`,c2=io(Cn)`
|
|
1853
1853
|
border-radius: var(--privy-border-radius-md) !important;
|
|
1854
1854
|
animation: ${C7} 0.3s ease-in-out;
|
|
1855
|
-
`;import{Fragment as v7,jsx as or,jsxs as Ys}from"react/jsx-runtime";var d2=({displayName:e,errorMessage:t,configuredFundingChain:r,formattedBalance:o,fundingAmount:n,fundingCurrency:a,fundingAmountInUsd:i,options:s,selectedOption:l,isPreparing:d,isSubmitting:p,onSubmit:m,onSelect:h})=>Ys(v7,{children:[or(Qt,{}),or(le,{}),or(wo,{children:"Transfer from another network"}),Ys(to,{children:["You need more funds on the ",r.name," network. Bridge from another blockchain network."]}),Ys(Ui,{style:{marginTop:"2rem"},children:[Ys(Fi,{children:[or(gd,{children:n}),or(Bi,{children:a})]}),i&&or(Hi,{children:i})]}),or($e,{style:{marginTop:"1.5rem"},children:or(it,{children:"From"})}),or(Z1,{selected:{chain:l.chain,balance:Mt(l.balance,l.chain.nativeCurrency.symbol,3,!0)},options:s.map(({chain:g,balance:v})=>({chain:g,balance:Mt(v,g.nativeCurrency.symbol,3,!0)})),onSelect:h}),or($e,{children:or(it,{style:{marginTop:"1.5rem"},children:"To"})}),or(Q1,{chain:r,balance:o}),or(ls,{style:{marginTop:"1rem"},children:t}),Ys(pa,{style:{marginTop:"1rem"},loading:p||d,disabled:d||p,onClick:m,children:["Confirm with ",e]}),or(ce,{}),or(
|
|
1855
|
+
`;import{Fragment as v7,jsx as or,jsxs as Ys}from"react/jsx-runtime";var d2=({displayName:e,errorMessage:t,configuredFundingChain:r,formattedBalance:o,fundingAmount:n,fundingCurrency:a,fundingAmountInUsd:i,options:s,selectedOption:l,isPreparing:d,isSubmitting:p,onSubmit:m,onSelect:h})=>Ys(v7,{children:[or(Qt,{}),or(le,{}),or(wo,{children:"Transfer from another network"}),Ys(to,{children:["You need more funds on the ",r.name," network. Bridge from another blockchain network."]}),Ys(Ui,{style:{marginTop:"2rem"},children:[Ys(Fi,{children:[or(gd,{children:n}),or(Bi,{children:a})]}),i&&or(Hi,{children:i})]}),or($e,{style:{marginTop:"1.5rem"},children:or(it,{children:"From"})}),or(Z1,{selected:{chain:l.chain,balance:Mt(l.balance,l.chain.nativeCurrency.symbol,3,!0)},options:s.map(({chain:g,balance:v})=>({chain:g,balance:Mt(v,g.nativeCurrency.symbol,3,!0)})),onSelect:h}),or($e,{children:or(it,{style:{marginTop:"1.5rem"},children:"To"})}),or(Q1,{chain:r,balance:o}),or(ls,{style:{marginTop:"1rem"},children:t}),Ys(pa,{style:{marginTop:"1rem"},loading:p||d,disabled:d||p,onClick:m,children:["Confirm with ",e]}),or(ce,{}),or(V,{})]});import w7 from"styled-components";import{Fragment as E7,jsx as Dt,jsxs as Aa}from"react/jsx-runtime";var p2=({wallet:e,displayName:t,addressToFund:r,chain:o,isBridging:n,isErc20Flow:a,totalPriceInNativeCurrency:i,totalPriceInUsd:s,gasPriceInNativeCurrency:l,gasPriceInUsd:d})=>Aa(E7,{children:[Dt(Qt,{}),Dt(Ni,{}),Dt(Ot,{style:{marginTop:"16px"},children:Dt(Uc,{icon:Bc(e.walletClientType,e.connectorType,e.walletClientType),name:e.walletClientType})}),Dt(we,{style:{marginTop:"8px",marginBottom:"12px"},title:`${n?"Bridging":"Confirming"} with ${t}`}),!n&&!a&&Aa(Ta,{children:[Aa($e,{children:[Dt(it,{children:"Total"}),Dt(ct,{children:s||i})]}),Aa($e,{children:[Dt(it,{children:"To"}),Dt(ct,{children:Dt(Rr,{address:r,showCopyIcon:!1})})]}),Aa($e,{children:[Dt(it,{children:"Network"}),Dt(ct,{children:Aa(b7,{children:[Dt(Di,{chainId:o.id,height:16,width:16})," ",o.name]})})]}),l&&Aa($e,{children:[Dt(it,{children:"Estimated fee"}),Dt(ct,{children:d||l})]})]}),Dt(Ci,{height:24}),Dt(V,{})]}),b7=w7.div`
|
|
1856
1856
|
display: flex;
|
|
1857
1857
|
flex-direction: row;
|
|
1858
1858
|
align-items: center;
|
|
1859
1859
|
gap: 4px;
|
|
1860
|
-
`;import{Fragment as f2,jsx as so,jsxs as Mu}from"react/jsx-runtime";var h2=()=>{let{rpcConfig:e,appId:t,closePrivyModal:r,createAnalyticsEvent:o}=R(),{navigate:n,setModalData:a,app:i,data:s}=x(),{wallets:l}=Zo(),[d,p]=nr(!1),[m,h]=nr(0n),[g,v]=nr(!1),[w,E]=nr(null),[I,A]=nr(null),[T,P]=nr([]),[S,_]=nr(0),[D,U]=nr(!1),[V,H]=nr(!1),[Y,K]=nr(!1),[O,Q]=nr(!1),{erc20ContractInfo:L,erc20Address:Ge,address:pe,chain:X,amount:fe}=s.funding;In(()=>{Ge&&!L&&E(new Error("Unable to fetch token details"))},[]);let te=!!Ge&&!!L,ee=te?BigInt(parseFloat(fe)*10**L.decimals):x7(fe),ae=l[0],[Je,ot]=nr(null);In(()=>{(async()=>{if(!ae)return;let lr=await ae.getEthereumProvider(),Ar=S7({account:ae.address,transport:P7(lr)}).extend(k7);ot(Ar)})().catch(console.error)},[ae]);let[ie,mt]=nr(0n);In(()=>{u2({chain:X,transport:m2(Qo(X,e,t))}).getBalance({address:pe}).then(mt).catch(console.error)},[]);let[jt,qr]=nr(0n);In(()=>{te&&k1({chain:X,address:pe,appId:t,rpcConfig:e,erc20Address:Ge}).then(We=>qr(We.balance)).catch(console.error)},[]);let{tokenPrice:Pe}=Vo({chainId:X.id}),[ue,ke]=nr({to:pe,chain:X,value:ee,data:void 0});In(()=>{(async()=>{if(!Je||!ae||D||Y)return;U(!0);let lr,Ar=u2({chain:ue.chain,transport:m2(Qo(ue.chain,e,t))});if(te&&!ue.data){if(!await Ar.simulateContract({address:Ge,chain:ue.chain,abi:Hs,functionName:"transfer",args:[pe,ee],account:ae.address}).catch(zr=>{console.warn("Simulated token transfer failed with error, fetching bridge options.",zr)})){U(!1),v(!0);return}U(!1),ke({to:Ge,chain:ue.chain,data:A7({abi:Hs,functionName:"transfer",args:[pe,ee]}),value:"0x0"});return}try{lr=await Ar.prepareTransactionRequest({account:ae.address,to:ue.to,chain:ue.chain,data:ue.data,value:BigInt(ue.value??0)})}catch(Rt){console.error(Rt),T.length>1&&A(Rt.shortMessage??"Something went wrong")}if(!lr){U(!1),v(!0);return}U(!1),K(!0),p(!0),h(lr.gas);try{await Je.switchChain({id:ue.chain.id})}catch{await Je.addChain({chain:ue.chain}),await Je.switchChain({id:ue.chain.id})}let cr;try{cr=await Je.sendTransaction(lr),o({eventName:an,payload:{provider:"external",status:"success",address:ae.address,chainId:ue.chain.id,value:ue.value?.toString(),txHash:cr}})}catch(Rt){console.error(Rt);let zr=Rt;zr.name==="TransactionExecutionError"&&(T.length<1?E(new C(zr.shortMessage,void 0,"transaction_failure")):A(Rt.shortMessage??"Something went wrong"))}if(!cr){K(!1);return}await Je.waitForTransactionReceipt({hash:cr}),K(!1),Q(!0)})().catch(console.error)},[Je,ue]),In(()=>{(async()=>{if(!g||!Je||!ae)return;let Ar=Ul(i.chains).filter(nt=>nt.id!==s.funding.chain.id&&!!nt.testnet==!!s.funding.chain.testnet);te&&Ar.unshift(s.funding.chain);let cr=await x1({chains:Ar,address:ae.address,appId:t,rpcConfig:e}),Rt=te?cr.filter(nt=>nt.balance>0n):cr.filter(nt=>nt.balance>ee);if(Rt.length<1){E(new C(`Wallet ${uo(ae.address)} does not have enough funds.`,void 0,"insufficient_balance"));return}Rt.sort((nt,Cl)=>Number(Cl.balance-nt.balance));let zr=(await Promise.allSettled(Rt.map(async nt=>({quote:await P1({isTestnet:!!s.funding?.chain.testnet,input:S1({amount:ee.toString(),user:ae.address,recipient:pe,destinationChainId:X.id,destinationCurrency:Ge,originChainId:nt.chain.id})}),...nt})))).filter(nt=>nt.status==="fulfilled").map(nt=>nt.value);if(zr.length<1){E(new C(`Wallet ${uo(ae.address)} does not have enough funds.`,void 0,"insufficient_balance"));return}let Ga=zr.map(nt=>({bridgeTx:A1(nt.quote),balance:nt.balance,chain:nt.chain})).filter(nt=>!!nt.bridgeTx);if(Ga.length>1){P(Ga);return}let je=Ga[0];if(!je){E(new C(`Wallet ${uo(ae.address)} does not have enough funds.`,void 0,"insufficient_balance"));return}H(!0),ke({data:je.bridgeTx.data,to:je.bridgeTx.to,value:je.bridgeTx.value,chain:je.chain})})().catch(console.error)},[g]),In(()=>{if(!w)return;let We={error:w,previousScreen:"FUNDING_TRANSFER_FROM_WALLET_SCREEN"};a({funding:s?.funding,sendTransaction:s?.sendTransaction,errorModalData:We}),n("ERROR_SCREEN",!1)},[w]);let se=ae?En(ae.walletClientType,ae.connectorType,ae.walletClientType)||"wallet":null,W=!te&&Pe?Za(s?.funding?.amount??"0",Pe):void 0,Ce=te?m:cs([m,ee]),Tt=Ce&&Pe?ko(Ce,Pe):void 0,J=Ce?Mt(Ce,"ETH"):void 0,re=m&&Pe?ko(m,Pe):void 0,sr=m?Mt(m,"ETH"):void 0;if(In(()=>{if(!O)return;let We=setTimeout(r,Ym);return()=>clearTimeout(We)},[O]),O)return Mu(f2,{children:[so(Qt,{}),so(le,{}),Mu(Wr,{children:[so(T7,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),so(we,{title:"Success!",description:`You\u2019ve successfully added ${fe} ${te?L.symbol:X.nativeCurrency.symbol} to your ${i.name} wallet. It may take a minute before the funds are available to use.`})]}),so(ce,{}),so(B,{})]});let Me=te?`${dd({amount:jt,decimals:L.decimals})} ${L.symbol}`:Mt(ie,X.nativeCurrency.symbol,3,!0),wt=T[S];return T.length>1&&wt?so(d2,{displayName:se,configuredFundingChain:X,formattedBalance:Me,fundingAmount:fe,fundingCurrency:te?L.symbol:X.nativeCurrency.symbol,fundingAmountInUsd:W,options:T,selectedOption:wt,isPreparing:D,isSubmitting:Y,errorMessage:I,onSubmit:()=>{ke({to:wt.bridgeTx.to,data:wt.bridgeTx.data,value:wt.bridgeTx.value,chain:wt.chain})},onSelect:We=>{We!==S&&(A(null),_(We))}}):d&&m&&ae&&s?.funding?so(p2,{wallet:ae,displayName:se,addressToFund:pe,isBridging:V,isErc20Flow:te,totalPriceInUsd:Tt,totalPriceInNativeCurrency:J,gasPriceInUsd:re,gasPriceInNativeCurrency:sr,chain:s.funding.chain}):Mu(f2,{children:[so(Qt,{}),so(Ni,{}),so("div",{style:{marginTop:"1rem"}}),so(B,{})]})};import L7 from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import N7 from"@heroicons/react/24/solid/CheckCircleIcon";import{useEffect as O7,useMemo as D7,useState as b2}from"react";import E2 from"styled-components";var Cd=class{constructor({authorizationCode:t,stateCode:r,codeVerifier:o,provider:n}){this.meta={authorizationCode:t,stateCode:r,codeVerifier:o,provider:n}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{return await this.api.post(ql,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");try{return await this.api.post(zl,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(t){throw de(t)}}};async function vd({api:e,requesterAppId:t,providerAppId:r}){let n=(await e.get(`/api/v1/apps/${t}/cross-app/connections`)).connections.find(a=>a.provider_app_id===r);if(!n)throw new C("Invalid connected app");return{name:n.provider_app_name,logoUrl:n.provider_app_icon_url||void 0,apiUrl:n.provider_app_custom_api_url,readOnly:n.read_only}}async function y2({api:e,appId:t}){let r=na(),o=$a(),n=await ei(r);try{let{url:a}=await e.post(Gl,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:n,state_code:o});return{url:a,stateCode:o,codeVerifier:r}}catch(a){throw de(a)}}async function g2({appId:e,stateCode:t,codeVerifier:r,authorizationCode:o,action:n,client:a}){if(!o||!t)throw new C("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if(o==="undefined")throw new C("User denied confirmation during cross-app auth flow");try{let i=new Cd({authorizationCode:o,stateCode:t,codeVerifier:r,provider:`privy:${e}`});a.startAuthFlow(i);let l=(n==="link"?await a.link():await a.authenticate()).oAuthTokens?.accessToken;return console.debug(),l}catch(i){let s=de(i);throw s.privyErrorCode?new C(s.message||"Invalid code during cross-app auth flow.",void 0,s.privyErrorCode):s.message==="User denied confirmation during cross-app auth flow"?new C("Invalid code during cross-app auth flow.",void 0,"oauth_user_denied"):new C("Invalid code during cross-app auth flow.",void 0,"unknown_auth_error")}}var wd=async({user:e,address:t,client:r,request:o,requesterAppId:n,reconnect:a})=>{r.createAnalyticsEvent({eventName:"cross_app_request_started",payload:{address:t,method:o.method}});let i=e?.linkedAccounts.find(h=>!!(h.type==="cross_app"&&h.embeddedWallets.find(g=>g.address===t)));if(!e||!i)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Cannot request a signature with this wallet address",address:t}}),new C("Cannot request a signature with this wallet address");let s=r.getProviderAccessToken(i.providerApp.id),l=await vd({api:r.api,requesterAppId:n,providerAppId:i.providerApp.id});if(!s){if(l.readOnly)throw console.error("cannot transact against a read-only provider app"),new C("Cannot transact against a read-only provider app");await a({appId:i.providerApp.id,action:"link"})&&(s=r.getProviderAccessToken(i.providerApp.id))}if(!s)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Transactions require a valid token",address:t}}),new C("Transactions require a valid token");let d=window.open(void 0,void 0,Qs({w:400,h:680}));if(!d)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Missing token",address:t}}),new C("Failed to initialize signature request");let p=new URL(`${l.apiUrl}/oauth/transact`);return p.searchParams.set("token",s||""),p.searchParams.set("request",R7(o)),d.location=p.href,new Promise((h,g)=>{let w=setTimeout(()=>{A(),g(new C("Request timeout")),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Request timeout",address:t}})},12e4),E=setInterval(()=>{d.closed&&(A(),g(new C("User rejected request")),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"User rejected request",address:t}}))},300),I=T=>{T.data&&(T.data.token?.action==="set"&&T.data.token?.value!==void 0?r.storeProviderAccessToken(i.providerApp.id,T.data.token.value):T.data.token?.action==="clear"&&r.storeProviderAccessToken(i.providerApp.id,null),T.data.type==="PRIVY_CROSS_APP_ACTION_RESPONSE"&&T.data.result&&(A(),h(T.data.result),r.createAnalyticsEvent({eventName:"cross_app_request_success",payload:{address:t,method:o.method}})),T.data.type==="PRIVY_CROSS_APP_ACTION_ERROR"&&T.data.error&&(A(),g(T.data.error),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:T.data.error,address:t}})))};window.addEventListener("message",I);let A=()=>{d.close(),clearInterval(E),clearTimeout(w),window.removeEventListener("message",I)}})},R7=e=>JSON.stringify({content:{request:{request:e}},timestamp:Date.now(),callbackUrl:window.origin}),Qs=({w:e,h:t})=>{let r=window.screenLeft!==void 0?window.screenLeft:window.screenX,o=window.screenTop!==void 0?window.screenTop:window.screenY,n=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,a=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,i=n/window.screen.availWidth,s=a/window.screen.availHeight,l=(n-e)/2/i+r,d=(a-t)/2/s+o;return`toolbar=0,location=0,menubar=0,height=${t},width=${e},popup=1,left=${l},top=${d}`};var _7=new Set([Qr.id,Yr.id,xo.id,Xr.id,mo.id]),I7=new Set([Qr.id,Yr.id,Xr.id,xo.id]),M7={[Qr.id]:"ethereum",[Yr.id]:"base",[xo.id]:"optimism",[Xr.id]:"polygon",[mo.id]:"arbitrum"},C2=(e,t)=>{switch(t){case"native-currency":return _7.has(e);case"USDC":return I7.has(e);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}};function v2(e){let t=M7[e];if(!t)throw new C(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}function W7(e){return e.startsWith(".")?`0${e}`:e}var w2=({input:e,amount:t,blockchain:r})=>{let o=new URL("https://pay.coinbase.com/buy/select-asset");return o.searchParams.set("appId",e.app_id),o.searchParams.set("sessionToken",e.session_token),o.searchParams.set("defaultExperience","buy"),o.searchParams.set("presetCryptoAmount",W7(t)),o.searchParams.set("defaultNetwork",r),o.searchParams.set("partnerUserId",e.partner_user_id),{url:o}};import{Fragment as P2,jsx as Ur,jsxs as Xs}from"react/jsx-runtime";var U7=240,T2=1500,F7=Math.floor(U7*1e3/T2),S2=()=>{let{data:e,setModalData:t,navigate:r}=x(),{closePrivyModal:o,createAnalyticsEvent:n,initCoinbaseOnRamp:a,getCoinbaseOnRampStatus:i}=R(),s=e?.funding,l=s.isUSDC?"USDC":"ETH",[d,p]=b2(!1),[m,h]=b2(!1);return O7(()=>{if(d)return;p(!0);let g=async()=>{try{n({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:s.amount,chainId:s.chain.id}});let w=window.open(void 0,void 0,Qs({w:440,h:680})),E=v2(s.chain.id),I=await a({addresses:[{address:s.address,blockchains:[E]}],assets:[l]}),{url:A}=w2({input:I,amount:s.amount,blockchain:E});if(!w)throw new Error("Unable to initiate Coinbase Onramp flow.");w.location=A.toString();let T=0,P=!1;for(;T<F7;){T++;let{status:S}=await i({partnerUserId:I.partner_user_id});if(S==="success"){P=!0;break}if(S==="failure")throw new Error("There was an error completing Coinbase Onramp flow.");if(w.closed)throw new Error("User exited Coinbase Onramp flow before transaction response.");await new Promise(_=>setTimeout(_,T2))}if(!P)throw new Error("Timed out waiting for transaction response from Coinbase Onramp.");h(!0)}catch(w){console.error(w),n({eventName:an,payload:{status:"failure",provider:"coinbase-onramp",error:w.message}}),t({funding:{...s,errorMessage:"Something went wrong adding funds from Coinbase Onramp. Please try again or use another method to fund your wallet."}}),r("FUNDING_METHOD_SELECTION_SCREEN")}finally{p(!1)}},v=setTimeout(()=>void g(),500);return()=>clearTimeout(v)},[]),Xs(P2,{children:[Ur(k,{title:"Fund account"},"header"),Ur(H7,{isSucccess:m,onClickCta:o}),Ur(B,{})]})},B7=e=>e?{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"}:{title:"In Progress",body:"Go back to Coinbase Onramp to finish funding your account.",cta:""},H7=({isSucccess:e,onClickCta:t})=>{let{title:r,body:o,cta:n}=D7(()=>B7(e),[e]);return Xs(P2,{children:[Xs(K7,{children:[Ur(q7,{isSucccess:e}),Xs(at,{children:[Ur("h3",{children:r}),Ur(z7,{children:o})]})]}),n&&Ur(F,{onClick:t,children:n})]})},V7=e=>e?"var(--privy-color-success)":"var(--privy-color-foreground-4)",G7=e=>e?N7:()=>Ur(L7,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}}),q7=({isSucccess:e})=>{if(!e){let o="var(--privy-color-foreground-4)";return Xs("div",{style:{position:"relative"},children:[Ur(yt,{color:o,style:{position:"absolute"}}),Ur(Es,{color:o}),Ur(jo,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let t=G7(e),r=V7(e);return Ur("div",{style:{borderColor:r,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:t&&Ur(t,{width:"4rem",height:"4rem",color:r})})},z7=E2.p`
|
|
1860
|
+
`;import{Fragment as f2,jsx as so,jsxs as Mu}from"react/jsx-runtime";var h2=()=>{let{rpcConfig:e,appId:t,closePrivyModal:r,createAnalyticsEvent:o}=R(),{navigate:n,setModalData:a,app:i,data:s}=x(),{wallets:l}=Zo(),[d,p]=nr(!1),[m,h]=nr(0n),[g,v]=nr(!1),[w,E]=nr(null),[I,A]=nr(null),[T,P]=nr([]),[S,_]=nr(0),[U,D]=nr(!1),[H,B]=nr(!1),[Y,K]=nr(!1),[O,Q]=nr(!1),{erc20ContractInfo:L,erc20Address:Ge,address:pe,chain:X,amount:fe}=s.funding;In(()=>{Ge&&!L&&E(new Error("Unable to fetch token details"))},[]);let re=!!Ge&&!!L,te=re?BigInt(parseFloat(fe)*10**L.decimals):x7(fe),ae=l[0],[Je,ot]=nr(null);In(()=>{(async()=>{if(!ae)return;let lr=await ae.getEthereumProvider(),Ar=S7({account:ae.address,transport:P7(lr)}).extend(k7);ot(Ar)})().catch(console.error)},[ae]);let[ie,mt]=nr(0n);In(()=>{u2({chain:X,transport:m2(Qo(X,e,t))}).getBalance({address:pe}).then(mt).catch(console.error)},[]);let[jt,qr]=nr(0n);In(()=>{re&&k1({chain:X,address:pe,appId:t,rpcConfig:e,erc20Address:Ge}).then(We=>qr(We.balance)).catch(console.error)},[]);let{tokenPrice:Pe}=Vo({chainId:X.id}),[ue,ke]=nr({to:pe,chain:X,value:te,data:void 0});In(()=>{(async()=>{if(!Je||!ae||U||Y)return;D(!0);let lr,Ar=u2({chain:ue.chain,transport:m2(Qo(ue.chain,e,t))});if(re&&!ue.data){if(!await Ar.simulateContract({address:Ge,chain:ue.chain,abi:Hs,functionName:"transfer",args:[pe,te],account:ae.address}).catch(zr=>{console.warn("Simulated token transfer failed with error, fetching bridge options.",zr)})){D(!1),v(!0);return}D(!1),ke({to:Ge,chain:ue.chain,data:A7({abi:Hs,functionName:"transfer",args:[pe,te]}),value:"0x0"});return}try{lr=await Ar.prepareTransactionRequest({account:ae.address,to:ue.to,chain:ue.chain,data:ue.data,value:BigInt(ue.value??0)})}catch(Rt){console.error(Rt),T.length>1&&A(Rt.shortMessage??"Something went wrong")}if(!lr){D(!1),v(!0);return}D(!1),K(!0),p(!0),h(lr.gas);try{await Je.switchChain({id:ue.chain.id})}catch{await Je.addChain({chain:ue.chain}),await Je.switchChain({id:ue.chain.id})}let cr;try{cr=await Je.sendTransaction(lr),o({eventName:an,payload:{provider:"external",status:"success",address:ae.address,chainId:ue.chain.id,value:ue.value?.toString(),txHash:cr}})}catch(Rt){console.error(Rt);let zr=Rt;zr.name==="TransactionExecutionError"&&(T.length<1?E(new C(zr.shortMessage,void 0,"transaction_failure")):A(Rt.shortMessage??"Something went wrong"))}if(!cr){K(!1);return}await Je.waitForTransactionReceipt({hash:cr}),K(!1),Q(!0)})().catch(console.error)},[Je,ue]),In(()=>{(async()=>{if(!g||!Je||!ae)return;let Ar=Ul(i.chains).filter(nt=>nt.id!==s.funding.chain.id&&!!nt.testnet==!!s.funding.chain.testnet);re&&Ar.unshift(s.funding.chain);let cr=await x1({chains:Ar,address:ae.address,appId:t,rpcConfig:e}),Rt=re?cr.filter(nt=>nt.balance>0n):cr.filter(nt=>nt.balance>te);if(Rt.length<1){E(new C(`Wallet ${uo(ae.address)} does not have enough funds.`,void 0,"insufficient_balance"));return}Rt.sort((nt,Cl)=>Number(Cl.balance-nt.balance));let zr=(await Promise.allSettled(Rt.map(async nt=>({quote:await P1({isTestnet:!!s.funding?.chain.testnet,input:S1({amount:te.toString(),user:ae.address,recipient:pe,destinationChainId:X.id,destinationCurrency:Ge,originChainId:nt.chain.id})}),...nt})))).filter(nt=>nt.status==="fulfilled").map(nt=>nt.value);if(zr.length<1){E(new C(`Wallet ${uo(ae.address)} does not have enough funds.`,void 0,"insufficient_balance"));return}let Ga=zr.map(nt=>({bridgeTx:A1(nt.quote),balance:nt.balance,chain:nt.chain})).filter(nt=>!!nt.bridgeTx);if(Ga.length>1){P(Ga);return}let je=Ga[0];if(!je){E(new C(`Wallet ${uo(ae.address)} does not have enough funds.`,void 0,"insufficient_balance"));return}B(!0),ke({data:je.bridgeTx.data,to:je.bridgeTx.to,value:je.bridgeTx.value,chain:je.chain})})().catch(console.error)},[g]),In(()=>{if(!w)return;let We={error:w,previousScreen:"FUNDING_TRANSFER_FROM_WALLET_SCREEN"};a({funding:s?.funding,sendTransaction:s?.sendTransaction,errorModalData:We}),n("ERROR_SCREEN",!1)},[w]);let se=ae?En(ae.walletClientType,ae.connectorType,ae.walletClientType)||"wallet":null,W=!re&&Pe?Za(s?.funding?.amount??"0",Pe):void 0,Ce=re?m:cs([m,te]),Tt=Ce&&Pe?ko(Ce,Pe):void 0,J=Ce?Mt(Ce,"ETH"):void 0,oe=m&&Pe?ko(m,Pe):void 0,sr=m?Mt(m,"ETH"):void 0;if(In(()=>{if(!O)return;let We=setTimeout(r,Ym);return()=>clearTimeout(We)},[O]),O)return Mu(f2,{children:[so(Qt,{}),so(le,{}),Mu(Wr,{children:[so(T7,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),so(we,{title:"Success!",description:`You\u2019ve successfully added ${fe} ${re?L.symbol:X.nativeCurrency.symbol} to your ${i.name} wallet. It may take a minute before the funds are available to use.`})]}),so(ce,{}),so(V,{})]});let Me=re?`${dd({amount:jt,decimals:L.decimals})} ${L.symbol}`:Mt(ie,X.nativeCurrency.symbol,3,!0),wt=T[S];return T.length>1&&wt?so(d2,{displayName:se,configuredFundingChain:X,formattedBalance:Me,fundingAmount:fe,fundingCurrency:re?L.symbol:X.nativeCurrency.symbol,fundingAmountInUsd:W,options:T,selectedOption:wt,isPreparing:U,isSubmitting:Y,errorMessage:I,onSubmit:()=>{ke({to:wt.bridgeTx.to,data:wt.bridgeTx.data,value:wt.bridgeTx.value,chain:wt.chain})},onSelect:We=>{We!==S&&(A(null),_(We))}}):d&&m&&ae&&s?.funding?so(p2,{wallet:ae,displayName:se,addressToFund:pe,isBridging:H,isErc20Flow:re,totalPriceInUsd:Tt,totalPriceInNativeCurrency:J,gasPriceInUsd:oe,gasPriceInNativeCurrency:sr,chain:s.funding.chain}):Mu(f2,{children:[so(Qt,{}),so(Ni,{}),so("div",{style:{marginTop:"1rem"}}),so(V,{})]})};import L7 from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import N7 from"@heroicons/react/24/solid/CheckCircleIcon";import{useEffect as O7,useMemo as D7,useState as b2}from"react";import E2 from"styled-components";var Cd=class{constructor({authorizationCode:t,stateCode:r,codeVerifier:o,provider:n}){this.meta={authorizationCode:t,stateCode:r,codeVerifier:o,provider:n}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{return await this.api.post(ql,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(t){throw de(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");try{return await this.api.post(zl,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(t){throw de(t)}}};async function vd({api:e,requesterAppId:t,providerAppId:r}){let n=(await e.get(`/api/v1/apps/${t}/cross-app/connections`)).connections.find(a=>a.provider_app_id===r);if(!n)throw new C("Invalid connected app");return{name:n.provider_app_name,logoUrl:n.provider_app_icon_url||void 0,apiUrl:n.provider_app_custom_api_url,readOnly:n.read_only}}async function y2({api:e,appId:t}){let r=na(),o=$a(),n=await ei(r);try{let{url:a}=await e.post(Gl,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:n,state_code:o});return{url:a,stateCode:o,codeVerifier:r}}catch(a){throw de(a)}}async function g2({appId:e,stateCode:t,codeVerifier:r,authorizationCode:o,action:n,client:a}){if(!o||!t)throw new C("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if(o==="undefined")throw new C("User denied confirmation during cross-app auth flow");try{let i=new Cd({authorizationCode:o,stateCode:t,codeVerifier:r,provider:`privy:${e}`});a.startAuthFlow(i);let l=(n==="link"?await a.link():await a.authenticate()).oAuthTokens?.accessToken;return console.debug(),l}catch(i){let s=de(i);throw s.privyErrorCode?new C(s.message||"Invalid code during cross-app auth flow.",void 0,s.privyErrorCode):s.message==="User denied confirmation during cross-app auth flow"?new C("Invalid code during cross-app auth flow.",void 0,"oauth_user_denied"):new C("Invalid code during cross-app auth flow.",void 0,"unknown_auth_error")}}var wd=async({user:e,address:t,client:r,request:o,requesterAppId:n,reconnect:a})=>{r.createAnalyticsEvent({eventName:"cross_app_request_started",payload:{address:t,method:o.method}});let i=e?.linkedAccounts.find(h=>!!(h.type==="cross_app"&&h.embeddedWallets.find(g=>g.address===t)));if(!e||!i)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Cannot request a signature with this wallet address",address:t}}),new C("Cannot request a signature with this wallet address");let s=r.getProviderAccessToken(i.providerApp.id),l=await vd({api:r.api,requesterAppId:n,providerAppId:i.providerApp.id});if(!s){if(l.readOnly)throw console.error("cannot transact against a read-only provider app"),new C("Cannot transact against a read-only provider app");await a({appId:i.providerApp.id,action:"link"})&&(s=r.getProviderAccessToken(i.providerApp.id))}if(!s)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Transactions require a valid token",address:t}}),new C("Transactions require a valid token");let d=window.open(void 0,void 0,Qs({w:400,h:680}));if(!d)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Missing token",address:t}}),new C("Failed to initialize signature request");let p=new URL(`${l.apiUrl}/oauth/transact`);return p.searchParams.set("token",s||""),p.searchParams.set("request",R7(o)),d.location=p.href,new Promise((h,g)=>{let w=setTimeout(()=>{A(),g(new C("Request timeout")),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Request timeout",address:t}})},12e4),E=setInterval(()=>{d.closed&&(A(),g(new C("User rejected request")),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"User rejected request",address:t}}))},300),I=T=>{T.data&&(T.data.token?.action==="set"&&T.data.token?.value!==void 0?r.storeProviderAccessToken(i.providerApp.id,T.data.token.value):T.data.token?.action==="clear"&&r.storeProviderAccessToken(i.providerApp.id,null),T.data.type==="PRIVY_CROSS_APP_ACTION_RESPONSE"&&T.data.result&&(A(),h(T.data.result),r.createAnalyticsEvent({eventName:"cross_app_request_success",payload:{address:t,method:o.method}})),T.data.type==="PRIVY_CROSS_APP_ACTION_ERROR"&&T.data.error&&(A(),g(T.data.error),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:T.data.error,address:t}})))};window.addEventListener("message",I);let A=()=>{d.close(),clearInterval(E),clearTimeout(w),window.removeEventListener("message",I)}})},R7=e=>JSON.stringify({content:{request:{request:e}},timestamp:Date.now(),callbackUrl:window.origin}),Qs=({w:e,h:t})=>{let r=window.screenLeft!==void 0?window.screenLeft:window.screenX,o=window.screenTop!==void 0?window.screenTop:window.screenY,n=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,a=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,i=n/window.screen.availWidth,s=a/window.screen.availHeight,l=(n-e)/2/i+r,d=(a-t)/2/s+o;return`toolbar=0,location=0,menubar=0,height=${t},width=${e},popup=1,left=${l},top=${d}`};var _7=new Set([Qr.id,Yr.id,xo.id,Xr.id,mo.id]),I7=new Set([Qr.id,Yr.id,Xr.id,xo.id]),M7={[Qr.id]:"ethereum",[Yr.id]:"base",[xo.id]:"optimism",[Xr.id]:"polygon",[mo.id]:"arbitrum"},C2=(e,t)=>{switch(t){case"native-currency":return _7.has(e);case"USDC":return I7.has(e);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}};function v2(e){let t=M7[e];if(!t)throw new C(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}function W7(e){return e.startsWith(".")?`0${e}`:e}var w2=({input:e,amount:t,blockchain:r})=>{let o=new URL("https://pay.coinbase.com/buy/select-asset");return o.searchParams.set("appId",e.app_id),o.searchParams.set("sessionToken",e.session_token),o.searchParams.set("defaultExperience","buy"),o.searchParams.set("presetCryptoAmount",W7(t)),o.searchParams.set("defaultNetwork",r),o.searchParams.set("partnerUserId",e.partner_user_id),{url:o}};import{Fragment as P2,jsx as Ur,jsxs as Xs}from"react/jsx-runtime";var U7=240,T2=1500,F7=Math.floor(U7*1e3/T2),S2=()=>{let{data:e,setModalData:t,navigate:r}=x(),{closePrivyModal:o,createAnalyticsEvent:n,initCoinbaseOnRamp:a,getCoinbaseOnRampStatus:i}=R(),s=e?.funding,l=s.isUSDC?"USDC":"ETH",[d,p]=b2(!1),[m,h]=b2(!1);return O7(()=>{if(d)return;p(!0);let g=async()=>{try{n({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:s.amount,chainId:s.chain.id}});let w=window.open(void 0,void 0,Qs({w:440,h:680})),E=v2(s.chain.id),I=await a({addresses:[{address:s.address,blockchains:[E]}],assets:[l]}),{url:A}=w2({input:I,amount:s.amount,blockchain:E});if(!w)throw new Error("Unable to initiate Coinbase Onramp flow.");w.location=A.toString();let T=0,P=!1;for(;T<F7;){T++;let{status:S}=await i({partnerUserId:I.partner_user_id});if(S==="success"){P=!0;break}if(S==="failure")throw new Error("There was an error completing Coinbase Onramp flow.");if(w.closed)throw new Error("User exited Coinbase Onramp flow before transaction response.");await new Promise(_=>setTimeout(_,T2))}if(!P)throw new Error("Timed out waiting for transaction response from Coinbase Onramp.");h(!0)}catch(w){console.error(w),n({eventName:an,payload:{status:"failure",provider:"coinbase-onramp",error:w.message}}),t({funding:{...s,errorMessage:"Something went wrong adding funds from Coinbase Onramp. Please try again or use another method to fund your wallet."}}),r("FUNDING_METHOD_SELECTION_SCREEN")}finally{p(!1)}},v=setTimeout(()=>void g(),500);return()=>clearTimeout(v)},[]),Xs(P2,{children:[Ur(k,{title:"Fund account"},"header"),Ur(H7,{isSucccess:m,onClickCta:o}),Ur(V,{})]})},B7=e=>e?{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"}:{title:"In Progress",body:"Go back to Coinbase Onramp to finish funding your account.",cta:""},H7=({isSucccess:e,onClickCta:t})=>{let{title:r,body:o,cta:n}=D7(()=>B7(e),[e]);return Xs(P2,{children:[Xs(K7,{children:[Ur(q7,{isSucccess:e}),Xs(at,{children:[Ur("h3",{children:r}),Ur(z7,{children:o})]})]}),n&&Ur(F,{onClick:t,children:n})]})},V7=e=>e?"var(--privy-color-success)":"var(--privy-color-foreground-4)",G7=e=>e?N7:()=>Ur(L7,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}}),q7=({isSucccess:e})=>{if(!e){let o="var(--privy-color-foreground-4)";return Xs("div",{style:{position:"relative"},children:[Ur(yt,{color:o,style:{position:"absolute"}}),Ur(Es,{color:o}),Ur(jo,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let t=G7(e),r=V7(e);return Ur("div",{style:{borderColor:r,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:t&&Ur(t,{width:"4rem",height:"4rem",color:r})})},z7=E2.p`
|
|
1861
1861
|
font-size: 1rem;
|
|
1862
1862
|
color: var(--privy-color-foreground-3);
|
|
1863
1863
|
margin-bottom: 1rem;
|
|
@@ -1891,7 +1891,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
1891
1891
|
border: 1px solid var(--privy-color-error);
|
|
1892
1892
|
border-radius: var(--privy-border-radius-sm);
|
|
1893
1893
|
}
|
|
1894
|
-
`;import{createPublicClient as j7,http as $7}from"viem";var bd=async({address:e,chain:t,rpcConfig:r,privyAppId:o})=>{try{let n=j7({chain:t,transport:$7(Qo(t,r,o))}),[a,i]=await Promise.all([n.readContract({abi:x2,address:e,functionName:"symbol"}),n.readContract({abi:x2,address:e,functionName:"decimals"})]);return{decimals:i,symbol:a}}catch(n){return console.log(n),null}},x2=[{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}];import{ofetch as eE}from"ofetch";import{useEffect as tE,useRef as rE,useState as oE}from"react";var Ed="moonpay",nE=new Set([Qr.id,mo.id,Yr.id,Xr.id]),aE=new Set([Qr.id,mo.id,xo.id,Yr.id,Xr.id]);function k2(e,t){switch(e){case mo.id:return t==="native-currency"?"ETH_ARBITRUM":"USDC_ARBITRUM";case 43114:return"AVAX_CCHAIN";case Yr.id:return t==="native-currency"?"ETH_BASE":"USDC_BASE";case Ol.id:return"CELO_CELO";case Xr.id:return t==="native-currency"?"MATIC_POLYGON":"USDC_POLYGON";case Qr.id:return t==="native-currency"?"ETH_ETHEREUM":"USDC_ETHEREUM";default:return console.warn(`Chain ${e} not supported by Moonpay, defaulting to Ethereum mainnet`),"ETH_ETHEREUM"}}function R2(e){return parseFloat(e)}function _2(e){return!!e&&e.config!==void 0&&e.provider!==void 0}function Td(e){return!!e&&(e.chain!==void 0||e.amount!==void 0)}async function I2(e,t,r,o,n=!1){let a=r.currencyCode?{}:{defaultCurrencyCode:"ETH_ETHEREUM"},i=r.uiConfig||{accentColor:o.accent,theme:o.colorScheme};return e.signMoonpayOnRampUrl({address:t,useSandbox:n,config:{...r,...a,...i}})}async function iE(e,t){let r=t?Zm:Xm,o=t?jm:Jm;return eE(`${r}/transactions/ext/${e}`,{query:{apiKey:o}})}function M2(e,t=!1){let[r,o]=oE(null),{createAnalyticsEvent:n}=R(),{data:a,navigate:i,setModalData:s}=x(),l=a?.funding,d=rE(0);return tE(()=>{let p=setInterval(async()=>{if(e)try{let[m]=await iE(e,t),h=m.status==="waitingAuthorization"&&m.paymentMethod==="credit_debit_card"?"pending":m.status;if(["failed","completed","awaitingAuthorization"].includes(h)&&(n({eventName:an,payload:{status:h,provider:Ed,paymentMethod:m.paymentMethod,cardPaymentType:m.cardPaymentType,currency:m.currency?.code,baseCurrencyAmount:m.baseCurrencyAmount,quoteCurrencyAmount:m.quoteCurrencyAmount,feeAmount:m.feeAmount,extraFeeAmount:m.extraFeeAmount,networkFeeAmount:m.networkFeeAmount,isSandbox:t}}),clearInterval(p)),h==="failed"||h==="serviceFailure"){s({funding:{...l,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),i("FUNDING_METHOD_SELECTION_SCREEN");return}o(h)}catch(m){m.response?.status!==404&&(d.current+=1),d.current>=3&&(n({eventName:an,payload:{status:"serviceFailure",provider:Ed}}),clearInterval(p),s({funding:{...l,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),i("FUNDING_METHOD_SELECTION_SCREEN"))}},3e3);return()=>clearInterval(p)},[e,d]),r}var W2=(e,t)=>{switch(t){case"native-currency":return nE.has(e);case"USDC":return aE.has(e);default:return console.warn("Unknown asset passed to MoonPay Onramp"),!1}};import{jsx as Wu,jsxs as sE}from"react/jsx-runtime";var Vi=({size:e=61,...t})=>Wu("svg",{width:e,height:e,viewBox:"0 0 61 61",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:sE("g",{id:"moonpay_symbol_wht 2",children:[Wu("rect",{x:"1.3374",y:"1",width:"59",height:"59",rx:"11.5",fill:"#7715F5"}),Wu("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"})]})});import{Fragment as O2,jsx as xt,jsxs as Mn}from"react/jsx-runtime";var D2=()=>{let{wallets:e}=Zo(),{navigate:t,data:r,setModalData:o}=x(),n=_e(),a=r?.funding,i=dE(null),[s,l]=pE(!1);N2(()=>{i.current&&i.current.style.setProperty("--funding-input-length",Math.max(a.amount.length,1).toString())},[a.amount,i.current]);let d=n.fundingConfig?.methods.slice()??[],{tokenPrice:p}=Vo({chainId:a.chain.id});N2(()=>{a.erc20Address&&a.chain&&!a.erc20ContractInfo&&bd({address:a.erc20Address,chain:a.chain,rpcConfig:n.rpcConfig,privyAppId:n.id}).then(S=>o({...r,funding:{...r.funding,erc20ContractInfo:S?{symbol:S.symbol,decimals:S.decimals}:void 0}})).catch(console.error)},[a.erc20Address,a.chain]);let m=p?Za(a.amount,p):void 0,h=e.find(S=>L2(S.address)===L2(a.address)),g=h&&h.walletClientType!=="privy"?En(h.walletClientType,h.connectorType,h.walletClientType):n.name,v=parseFloat(a.amount),w=!isNaN(v)&&v>0,E=!!(a.erc20Address&&!a.erc20ContractInfo),I=a.isUSDC?"USDC":a.erc20Address?void 0:"native-currency",A=I&&W2(Number(a.chain.id),I),T=I&&C2(Number(a.chain.id),I),P=a.erc20Address||!a.erc20Address&&!a.isUSDC;return Mn(O2,{children:[xt(Qt,{}),Mn("h3",{children:["Add funds to your"," ",g?.toLowerCase().endsWith("wallet")?g:g+" wallet"]}),xt(bn,{style:{marginTop:"32px"},children:xt(Ui,{children:E?xt(Ni,{size:"50px"}):Mn(O2,{children:[Mn(Fi,{onClick:()=>i.current?.focus(),children:[xt(a2,{ref:i,value:a.amount,onFocus:()=>l(!0),onBlur:()=>l(!1),onChange:S=>{let _=S.target.value;/^[0-9.]*$/.test(_)&&_.split(".").length-1<=1&&o({...r,funding:{...a,amount:_}})}}),xt(Bi,{children:a.erc20Address?a.erc20ContractInfo?.symbol:a.chain.nativeCurrency.symbol}),!s&&xt(i2,{children:xt(lE,{width:12,height:12})})]}),!a.erc20Address&&xt(Hi,{children:m&&w?m:""})]})})}),Mn(n2,{children:[a.errorMessage&&xt(A2,{children:a.errorMessage}),d.sort().map(S=>{switch(S){case"moonpay":return A?Mn(xe,{disabled:!w||E,onClick:()=>{t("MOONPAY_PROMPT_SCREEN")},children:[xt(yd,{children:xt(Vi,{style:{width:24}})}),"Moonpay"]},S):null;case"coinbase-onramp":return T?Mn(xe,{disabled:!w||E,onClick:()=>{t("COINBASE_ONRAMP_STATUS_SCREEN")},children:[xt(yd,{children:xt(jo,{style:{width:24}})}),"Coinbase Onramp"]},S):null;case"external":return P?Mn(xe,{disabled:!w||E,onClick:()=>{t("FUNDING_TRANSFER_FROM_WALLET_SCREEN")},children:[xt(yd,{children:xt(cE,{style:{width:24}})}),"Transfer from wallet"]},S):null}}),xt(l2,{disabled:!w,onClick:()=>t("FUNDING_MANUAL_TRANSFER_SCREEN"),children:"Send funds manually"})]}),xt(B,{})]})};import{formatUnits as uE}from"@ethersproject/units";import mE from"@heroicons/react/24/outline/DocumentDuplicateIcon";import fE from"@heroicons/react/24/outline/InformationCircleIcon";import hE from"@heroicons/react/24/outline/QrCodeIcon";import{useEffect as yE,useMemo as gE,useState as Lu}from"react";import Gi from"styled-components";import{Fragment as Sd,jsx as tt,jsxs as Xt}from"react/jsx-runtime";var CE=2e3,U2=()=>{let{wallets:e}=Zo(),{app:t,data:r,setModalData:o,navigate:n,lastScreen:a}=x(),{chains:i,rpcConfig:s,appId:l,closePrivyModal:d,createAnalyticsEvent:p}=R(),[m,h]=Lu("default"),[g,v]=Lu(void 0),w=r?.funding,{tokenPrice:E}=Vo({chainId:w.chain.id}),I=E?Za(w.amount,E):void 0,A=e.find(_=>uo(_.address)===uo(w.address)),T=A&&A.walletClientType!=="privy"?En(A.walletClientType,A.connectorType,A.walletClientType):t.name;if(!w)return o({errorModalData:{error:new Error("Couldn't find funding config"),previousScreen:a||"FUNDING_METHOD_SELECTION_SCREEN"},funding:r?.funding,sendTransaction:r?.sendTransaction}),n("ERROR_SCREEN"),tt(Sd,{});yE(()=>{let _=Kr(w.chain.id,i,s,{appId:l});function D(){_.getBalance(w.address).then(V=>{let H=parseFloat(uE(V,"ether"));v(Y=>(Y&&H>Y&&p({eventName:an,payload:{provider:"manual",status:"success",address:A?.address,value:(H-Y).toString()}}),H))}).catch(()=>v(void 0))}let U=setInterval(D,CE);return D(),()=>clearInterval(U)},[]);let P=gE(()=>g!==void 0?g>=parseFloat(w.amount):!1,[g,w.amount]),S=Xt(Sd,{children:[tt(Xa,{title:"Your wallet",errMsg:void 0,isLoading:!w||g===void 0,isPulsing:!P,balance:`${g!==void 0?g.toPrecision(2):""} ETH`,address:w.address,statusColor:P?"green":"gray"}),P&&tt(c2,{onClick:()=>d(),children:"Close"})]});return m==="qr-code"?Xt(Sd,{children:[tt(k,{backFn:()=>h("default")}),Xt(bn,{style:{gap:"24px",marginBottom:"24px"},children:[Xt("div",{children:[tt(ye,{children:"Scan QR code"}),Xt(ve,{children:["Scan this code using your mobile wallet to send funds to your ",T," ","wallet."]})]}),tt(_n,{url:w.address,size:200,squareLogoElement:vE}),S]}),tt(B,{})]}):Xt(Sd,{children:[tt(Qt,{}),tt(we,{title:"Send funds",description:"Send funds directly to your wallet by copying your wallet address or scanning a QR code."}),Xt(bn,{style:{gap:"16px"},children:[Xt(EE,{children:[tt(fE,{height:"20px",width:"20px",color:"var(--privy-color-accent-light)"}),Xt(TE,{children:["Make sure to send on ",w.chain.name,"."]})]}),Xt(SE,{children:[tt(Ci,{height:16}),Xt(Ui,{children:[Xt(Fi,{children:[tt(gd,{children:w.amount}),tt(Bi,{children:w.chain.nativeCurrency.symbol})]}),tt(Hi,{children:I?`${I} USD`:"..."}),Xt(s2,{children:[tt(Di,{chainId:w.chain.id,height:16,width:16})," ",w.chain.name]})]}),tt(Ci,{height:8}),Xt(bE,{children:[tt(wE,{text:w.address}),tt(B2,{onClick:()=>h("qr-code"),children:Xt(F2,{children:[tt(hE,{height:"16px",width:"16px"}),"Scan code"]})})]})]}),S]}),tt(Ci,{height:16}),tt(B,{})]})},vE=({...e})=>tt(Ll,{color:"black",...e}),wE=e=>{let[t,r]=Lu(!1);return tt(B2,{onClick:()=>{r(!0),navigator.clipboard.writeText(e.text),setTimeout(()=>r(!1),1500)},children:Xt(F2,{children:[t?tt(Li,{style:{height:"16px",width:"16px"},strokeWidth:"2"}):tt(mE,{style:{height:"16px",width:"16px"}}),t?"Copied":"Copy address"]})})},bE=Gi.div`
|
|
1894
|
+
`;import{createPublicClient as j7,http as $7}from"viem";var bd=async({address:e,chain:t,rpcConfig:r,privyAppId:o})=>{try{let n=j7({chain:t,transport:$7(Qo(t,r,o))}),[a,i]=await Promise.all([n.readContract({abi:x2,address:e,functionName:"symbol"}),n.readContract({abi:x2,address:e,functionName:"decimals"})]);return{decimals:i,symbol:a}}catch(n){return console.log(n),null}},x2=[{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}];import{ofetch as eE}from"ofetch";import{useEffect as tE,useRef as rE,useState as oE}from"react";var Ed="moonpay",nE=new Set([Qr.id,mo.id,Yr.id,Xr.id]),aE=new Set([Qr.id,mo.id,xo.id,Yr.id,Xr.id]);function k2(e,t){switch(e){case mo.id:return t==="native-currency"?"ETH_ARBITRUM":"USDC_ARBITRUM";case 43114:return"AVAX_CCHAIN";case Yr.id:return t==="native-currency"?"ETH_BASE":"USDC_BASE";case Ol.id:return"CELO_CELO";case Xr.id:return t==="native-currency"?"MATIC_POLYGON":"USDC_POLYGON";case Qr.id:return t==="native-currency"?"ETH_ETHEREUM":"USDC_ETHEREUM";default:return console.warn(`Chain ${e} not supported by Moonpay, defaulting to Ethereum mainnet`),"ETH_ETHEREUM"}}function R2(e){return parseFloat(e)}function _2(e){return!!e&&e.config!==void 0&&e.provider!==void 0}function Td(e){return!!e&&(e.chain!==void 0||e.amount!==void 0)}async function I2(e,t,r,o,n=!1){let a=r.currencyCode?{}:{defaultCurrencyCode:"ETH_ETHEREUM"},i=r.uiConfig||{accentColor:o.accent,theme:o.colorScheme};return e.signMoonpayOnRampUrl({address:t,useSandbox:n,config:{...r,...a,...i}})}async function iE(e,t){let r=t?Zm:Xm,o=t?jm:Jm;return eE(`${r}/transactions/ext/${e}`,{query:{apiKey:o}})}function M2(e,t=!1){let[r,o]=oE(null),{createAnalyticsEvent:n}=R(),{data:a,navigate:i,setModalData:s}=x(),l=a?.funding,d=rE(0);return tE(()=>{let p=setInterval(async()=>{if(e)try{let[m]=await iE(e,t),h=m.status==="waitingAuthorization"&&m.paymentMethod==="credit_debit_card"?"pending":m.status;if(["failed","completed","awaitingAuthorization"].includes(h)&&(n({eventName:an,payload:{status:h,provider:Ed,paymentMethod:m.paymentMethod,cardPaymentType:m.cardPaymentType,currency:m.currency?.code,baseCurrencyAmount:m.baseCurrencyAmount,quoteCurrencyAmount:m.quoteCurrencyAmount,feeAmount:m.feeAmount,extraFeeAmount:m.extraFeeAmount,networkFeeAmount:m.networkFeeAmount,isSandbox:t}}),clearInterval(p)),h==="failed"||h==="serviceFailure"){s({funding:{...l,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),i("FUNDING_METHOD_SELECTION_SCREEN");return}o(h)}catch(m){m.response?.status!==404&&(d.current+=1),d.current>=3&&(n({eventName:an,payload:{status:"serviceFailure",provider:Ed}}),clearInterval(p),s({funding:{...l,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),i("FUNDING_METHOD_SELECTION_SCREEN"))}},3e3);return()=>clearInterval(p)},[e,d]),r}var W2=(e,t)=>{switch(t){case"native-currency":return nE.has(e);case"USDC":return aE.has(e);default:return console.warn("Unknown asset passed to MoonPay Onramp"),!1}};import{jsx as Wu,jsxs as sE}from"react/jsx-runtime";var Vi=({size:e=61,...t})=>Wu("svg",{width:e,height:e,viewBox:"0 0 61 61",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:sE("g",{id:"moonpay_symbol_wht 2",children:[Wu("rect",{x:"1.3374",y:"1",width:"59",height:"59",rx:"11.5",fill:"#7715F5"}),Wu("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"})]})});import{Fragment as O2,jsx as xt,jsxs as Mn}from"react/jsx-runtime";var D2=()=>{let{wallets:e}=Zo(),{navigate:t,data:r,setModalData:o}=x(),n=_e(),a=r?.funding,i=dE(null),[s,l]=pE(!1);N2(()=>{i.current&&i.current.style.setProperty("--funding-input-length",Math.max(a.amount.length,1).toString())},[a.amount,i.current]);let d=n.fundingConfig?.methods.slice()??[],{tokenPrice:p}=Vo({chainId:a.chain.id});N2(()=>{a.erc20Address&&a.chain&&!a.erc20ContractInfo&&bd({address:a.erc20Address,chain:a.chain,rpcConfig:n.rpcConfig,privyAppId:n.id}).then(S=>o({...r,funding:{...r.funding,erc20ContractInfo:S?{symbol:S.symbol,decimals:S.decimals}:void 0}})).catch(console.error)},[a.erc20Address,a.chain]);let m=p?Za(a.amount,p):void 0,h=e.find(S=>L2(S.address)===L2(a.address)),g=h&&h.walletClientType!=="privy"?En(h.walletClientType,h.connectorType,h.walletClientType):n.name,v=parseFloat(a.amount),w=!isNaN(v)&&v>0,E=!!(a.erc20Address&&!a.erc20ContractInfo),I=a.isUSDC?"USDC":a.erc20Address?void 0:"native-currency",A=I&&W2(Number(a.chain.id),I),T=I&&C2(Number(a.chain.id),I),P=a.erc20Address||!a.erc20Address&&!a.isUSDC;return Mn(O2,{children:[xt(Qt,{}),Mn("h3",{children:["Add funds to your"," ",g?.toLowerCase().endsWith("wallet")?g:g+" wallet"]}),xt(bn,{style:{marginTop:"32px"},children:xt(Ui,{children:E?xt(Ni,{size:"50px"}):Mn(O2,{children:[Mn(Fi,{onClick:()=>i.current?.focus(),children:[xt(a2,{ref:i,value:a.amount,onFocus:()=>l(!0),onBlur:()=>l(!1),onChange:S=>{let _=S.target.value;/^[0-9.]*$/.test(_)&&_.split(".").length-1<=1&&o({...r,funding:{...a,amount:_}})}}),xt(Bi,{children:a.erc20Address?a.erc20ContractInfo?.symbol:a.chain.nativeCurrency.symbol}),!s&&xt(i2,{children:xt(lE,{width:12,height:12})})]}),!a.erc20Address&&xt(Hi,{children:m&&w?m:""})]})})}),Mn(n2,{children:[a.errorMessage&&xt(A2,{children:a.errorMessage}),d.sort().map(S=>{switch(S){case"moonpay":return A?Mn(xe,{disabled:!w||E,onClick:()=>{t("MOONPAY_PROMPT_SCREEN")},children:[xt(yd,{children:xt(Vi,{style:{width:24}})}),"Moonpay"]},S):null;case"coinbase-onramp":return T?Mn(xe,{disabled:!w||E,onClick:()=>{t("COINBASE_ONRAMP_STATUS_SCREEN")},children:[xt(yd,{children:xt(jo,{style:{width:24}})}),"Coinbase Onramp"]},S):null;case"external":return P?Mn(xe,{disabled:!w||E,onClick:()=>{t("FUNDING_TRANSFER_FROM_WALLET_SCREEN")},children:[xt(yd,{children:xt(cE,{style:{width:24}})}),"Transfer from wallet"]},S):null}}),xt(l2,{disabled:!w,onClick:()=>t("FUNDING_MANUAL_TRANSFER_SCREEN"),children:"Send funds manually"})]}),xt(V,{})]})};import{formatUnits as uE}from"@ethersproject/units";import mE from"@heroicons/react/24/outline/DocumentDuplicateIcon";import fE from"@heroicons/react/24/outline/InformationCircleIcon";import hE from"@heroicons/react/24/outline/QrCodeIcon";import{useEffect as yE,useMemo as gE,useState as Lu}from"react";import Gi from"styled-components";import{Fragment as Sd,jsx as tt,jsxs as Xt}from"react/jsx-runtime";var CE=2e3,U2=()=>{let{wallets:e}=Zo(),{app:t,data:r,setModalData:o,navigate:n,lastScreen:a}=x(),{chains:i,rpcConfig:s,appId:l,closePrivyModal:d,createAnalyticsEvent:p}=R(),[m,h]=Lu("default"),[g,v]=Lu(void 0),w=r?.funding,{tokenPrice:E}=Vo({chainId:w.chain.id}),I=E?Za(w.amount,E):void 0,A=e.find(_=>uo(_.address)===uo(w.address)),T=A&&A.walletClientType!=="privy"?En(A.walletClientType,A.connectorType,A.walletClientType):t.name;if(!w)return o({errorModalData:{error:new Error("Couldn't find funding config"),previousScreen:a||"FUNDING_METHOD_SELECTION_SCREEN"},funding:r?.funding,sendTransaction:r?.sendTransaction}),n("ERROR_SCREEN"),tt(Sd,{});yE(()=>{let _=Kr(w.chain.id,i,s,{appId:l});function U(){_.getBalance(w.address).then(H=>{let B=parseFloat(uE(H,"ether"));v(Y=>(Y&&B>Y&&p({eventName:an,payload:{provider:"manual",status:"success",address:A?.address,value:(B-Y).toString()}}),B))}).catch(()=>v(void 0))}let D=setInterval(U,CE);return U(),()=>clearInterval(D)},[]);let P=gE(()=>g!==void 0?g>=parseFloat(w.amount):!1,[g,w.amount]),S=Xt(Sd,{children:[tt(Xa,{title:"Your wallet",errMsg:void 0,isLoading:!w||g===void 0,isPulsing:!P,balance:`${g!==void 0?g.toPrecision(2):""} ETH`,address:w.address,statusColor:P?"green":"gray"}),P&&tt(c2,{onClick:()=>d(),children:"Close"})]});return m==="qr-code"?Xt(Sd,{children:[tt(k,{backFn:()=>h("default")}),Xt(bn,{style:{gap:"24px",marginBottom:"24px"},children:[Xt("div",{children:[tt(ye,{children:"Scan QR code"}),Xt(ve,{children:["Scan this code using your mobile wallet to send funds to your ",T," ","wallet."]})]}),tt(_n,{url:w.address,size:200,squareLogoElement:vE}),S]}),tt(V,{})]}):Xt(Sd,{children:[tt(Qt,{}),tt(we,{title:"Send funds",description:"Send funds directly to your wallet by copying your wallet address or scanning a QR code."}),Xt(bn,{style:{gap:"16px"},children:[Xt(EE,{children:[tt(fE,{height:"20px",width:"20px",color:"var(--privy-color-accent-light)"}),Xt(TE,{children:["Make sure to send on ",w.chain.name,"."]})]}),Xt(SE,{children:[tt(Ci,{height:16}),Xt(Ui,{children:[Xt(Fi,{children:[tt(gd,{children:w.amount}),tt(Bi,{children:w.chain.nativeCurrency.symbol})]}),tt(Hi,{children:I?`${I} USD`:"..."}),Xt(s2,{children:[tt(Di,{chainId:w.chain.id,height:16,width:16})," ",w.chain.name]})]}),tt(Ci,{height:8}),Xt(bE,{children:[tt(wE,{text:w.address}),tt(B2,{onClick:()=>h("qr-code"),children:Xt(F2,{children:[tt(hE,{height:"16px",width:"16px"}),"Scan code"]})})]})]}),S]}),tt(Ci,{height:16}),tt(V,{})]})},vE=({...e})=>tt(Ll,{color:"black",...e}),wE=e=>{let[t,r]=Lu(!1);return tt(B2,{onClick:()=>{r(!0),navigator.clipboard.writeText(e.text),setTimeout(()=>r(!1),1500)},children:Xt(F2,{children:[t?tt(Li,{style:{height:"16px",width:"16px"},strokeWidth:"2"}):tt(mE,{style:{height:"16px",width:"16px"}}),t?"Copied":"Copy address"]})})},bE=Gi.div`
|
|
1895
1895
|
display: flex;
|
|
1896
1896
|
flex-direction: row;
|
|
1897
1897
|
gap: 8px;
|
|
@@ -2015,7 +2015,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2015
2015
|
margin: 0 0.5rem;
|
|
2016
2016
|
`,DE=Go.div`
|
|
2017
2017
|
margin: 30px 0;
|
|
2018
|
-
`;import{Fragment as BE,jsx as Ou,jsxs as HE}from"react/jsx-runtime";var G2=()=>{let{app:e,data:t,navigate:r,setModalData:o}=x(),{createAnalyticsEvent:n,getMoonpaySignedUrl:a}=R(),[i,s]=FE(null),l=t?.funding,d=l.isUSDC?"USDC":"native-currency";return UE(()=>{if(i||!l)return;async function p(){if(!e.fundingConfig)return;let{signedUrl:m,externalTransactionId:h}=await a(l.address,{...e.fundingMethodConfig.moonpay,...l.moonpayConfigOverride,currencyCode:l.moonpayConfigOverride?.currencyCode??k2(l.chain.id,d),quoteCurrencyAmount:l.moonpayConfigOverride?.quoteCurrencyAmount??R2(l.amount)});s(m),o({moonpayStatus:{externalTransactionId:h},funding:t?.funding})}p()},[i,l]),HE(BE,{children:[Ou(Qt,{}),Ou(V2,{app:e,signedUrl:i,onContinue:()=>{n({eventName:"sdk_fiat_on_ramp_started",payload:{provider:Ed}}),r("MOONPAY_STATUS_SCREEN")}}),Ou(
|
|
2018
|
+
`;import{Fragment as BE,jsx as Ou,jsxs as HE}from"react/jsx-runtime";var G2=()=>{let{app:e,data:t,navigate:r,setModalData:o}=x(),{createAnalyticsEvent:n,getMoonpaySignedUrl:a}=R(),[i,s]=FE(null),l=t?.funding,d=l.isUSDC?"USDC":"native-currency";return UE(()=>{if(i||!l)return;async function p(){if(!e.fundingConfig)return;let{signedUrl:m,externalTransactionId:h}=await a(l.address,{...e.fundingMethodConfig.moonpay,...l.moonpayConfigOverride,currencyCode:l.moonpayConfigOverride?.currencyCode??k2(l.chain.id,d),quoteCurrencyAmount:l.moonpayConfigOverride?.quoteCurrencyAmount??R2(l.amount)});s(m),o({moonpayStatus:{externalTransactionId:h},funding:t?.funding})}p()},[i,l]),HE(BE,{children:[Ou(Qt,{}),Ou(V2,{app:e,signedUrl:i,onContinue:()=>{n({eventName:"sdk_fiat_on_ramp_started",payload:{provider:Ed}}),r("MOONPAY_STATUS_SCREEN")}}),Ou(V,{})]})};import VE from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import GE from"@heroicons/react/24/solid/CheckCircleIcon";import{useMemo as qE}from"react";import q2 from"styled-components";import{Fragment as K2,jsx as Fr,jsxs as Zs}from"react/jsx-runtime";var z2=()=>{let{app:e,data:t}=x(),{closePrivyModal:r}=R(),{externalTransactionId:o}=t?.moonpayStatus,n=M2(o||null,e.fundingMethodConfig.moonpay.useSandbox??!1);return Zs(K2,{children:[Fr(k,{title:"Fund account"},"header"),Fr(KE,{status:n,onClickCta:r}),Fr(V,{})]})},zE=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:""}}},KE=({status:e,onClickCta:t})=>{let{title:r,body:o,cta:n}=qE(()=>zE(e),[e]);return Zs(K2,{children:[Zs(JE,{children:[Fr(XE,{status:e}),Zs(at,{children:[Fr("h3",{children:r}),Fr(ZE,{children:o})]})]}),n&&Fr(F,{onClick:t,children:n})]})},YE=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)",QE=e=>{switch(e){case"completed":return GE;case"waitingAuthorization":return()=>Fr(VE,{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}},XE=({status:e})=>{if(!e||e==="pending"){let o="var(--privy-color-foreground-4)";return Zs("div",{style:{position:"relative"},children:[Fr(yt,{color:o,style:{position:"absolute"}}),Fr(Es,{color:o}),Fr(Vi,{size:"3rem",style:{position:"absolute",top:"1rem",left:"1rem"}})]})}let t=QE(e),r=YE(e);return Fr("div",{style:{borderColor:r,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:t&&Fr(t,{width:"4rem",height:"4rem",color:r})})},ZE=q2.p`
|
|
2019
2019
|
font-size: 1rem;
|
|
2020
2020
|
color: var(--privy-color-foreground-3);
|
|
2021
2021
|
margin-bottom: 1rem;
|
|
@@ -2057,7 +2057,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2057
2057
|
}
|
|
2058
2058
|
`,Du=jE.button`
|
|
2059
2059
|
${eT}
|
|
2060
|
-
`;import rT from"@heroicons/react/24/outline/ChevronRightIcon";import oT from"@heroicons/react/24/outline/WalletIcon";import{jsx as Uu,jsxs as nT}from"react/jsx-runtime";var Ad=({onClick:e,text:t})=>nT(xe,{onClick:e,children:[Uu(oT,{}),Uu($t,{children:t}),Uu(rT,{})]});import{Fragment as Y2,jsx as Wn,jsxs as xd}from"react/jsx-runtime";var Q2=()=>{let{connectors:e}=R(),{app:t,setModalData:r,data:o,navigate:n}=x(),[a,i]=iT("default"),s=Tn(t.appearance.walletList,"ethereum-only",e,!0,t.appearance.walletList,t.externalWallets.walletConnect.enabled),l=Wn(Ad,{text:"More wallets",onClick:()=>i("overflow")});return aT(()=>{r({...o,externalConnectWallet:{onCompleteNavigateTo:"FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN"}})},[]),a==="overflow"?xd(Y2,{children:[Wn(k,{backFn:()=>i("default")},"header"),xd(hr,{children:[Wn(to,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),s]}),Wn(
|
|
2060
|
+
`;import rT from"@heroicons/react/24/outline/ChevronRightIcon";import oT from"@heroicons/react/24/outline/WalletIcon";import{jsx as Uu,jsxs as nT}from"react/jsx-runtime";var Ad=({onClick:e,text:t})=>nT(xe,{onClick:e,children:[Uu(oT,{}),Uu($t,{children:t}),Uu(rT,{})]});import{Fragment as Y2,jsx as Wn,jsxs as xd}from"react/jsx-runtime";var Q2=()=>{let{connectors:e}=R(),{app:t,setModalData:r,data:o,navigate:n}=x(),[a,i]=iT("default"),s=Tn(t.appearance.walletList,"ethereum-only",e,!0,t.appearance.walletList,t.externalWallets.walletConnect.enabled),l=Wn(Ad,{text:"More wallets",onClick:()=>i("overflow")});return aT(()=>{r({...o,externalConnectWallet:{onCompleteNavigateTo:"FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN"}})},[]),a==="overflow"?xd(Y2,{children:[Wn(k,{backFn:()=>i("default")},"header"),xd(hr,{children:[Wn(to,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),s]}),Wn(V,{})]}):xd(Y2,{children:[Wn(Qt,{}),Wn(we,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),xd(hr,{children:[...s.length>3?s.slice(0,2):s,s.length>3&&l,Wn(Du,{onClick:()=>n("FUNDING_MANUAL_TRANSFER_SCREEN"),children:"Send funds manually"})]}),Wn(V,{})]})};import sT from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import lT from"styled-components";import{Fragment as dT,jsx as Ln,jsxs as pT}from"react/jsx-runtime";var X2=()=>{let{closePrivyModal:e}=R();return pT(dT,{children:[Ln(k,{},"header"),Ln(cT,{children:Ln(sT,{style:{width:32,height:32}})}),Ln(Do,{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"}}),Ln(wr,{children:Ln(F,{onClick:()=>e(),children:"Close"})}),Ln(ce,{}),Ln(V,{})]})},cT=lT.div`
|
|
2061
2061
|
border-radius: 50%;
|
|
2062
2062
|
height: 68px;
|
|
2063
2063
|
width: 68px;
|
|
@@ -2109,7 +2109,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2109
2109
|
padding: 24px 0;
|
|
2110
2110
|
flex-grow: 1;
|
|
2111
2111
|
justify-content: center;
|
|
2112
|
-
`;import RT from"@heroicons/react/24/outline/EnvelopeIcon";import{useRef as _T}from"react";import ST from"@heroicons/react/24/outline/EnvelopeIcon";import{forwardRef as PT,useState as Hu}from"react";import nC from"styled-components";import{Fragment as kT,jsx as ka,jsxs as oC}from"react/jsx-runtime";var _d=PT((e,t)=>{let[r,o]=Hu(e.defaultValue||""),[n,a]=Hu(!1),{authenticated:i}=z(),{initLoginWithEmail:s}=R(),{navigate:l,setModalData:d,currentScreen:p,data:m}=x(),{enabled:h,token:g}=Te(),[v,w]=Hu(!1),{accountType:E}=Vt(),I=Pl(r),A=n,T=n||!I,P=_=>{a(!0),s(r,_,m?.login?.disableSignup).then(()=>{l("AWAITING_PASSWORDLESS_CODE")}).catch(
|
|
2112
|
+
`;import RT from"@heroicons/react/24/outline/EnvelopeIcon";import{useRef as _T}from"react";import ST from"@heroicons/react/24/outline/EnvelopeIcon";import{forwardRef as PT,useState as Hu}from"react";import nC from"styled-components";import{Fragment as kT,jsx as ka,jsxs as oC}from"react/jsx-runtime";var _d=PT((e,t)=>{let[r,o]=Hu(e.defaultValue||""),[n,a]=Hu(!1),{authenticated:i}=z(),{initLoginWithEmail:s}=R(),{navigate:l,setModalData:d,currentScreen:p,data:m}=x(),{enabled:h,token:g}=Te(),[v,w]=Hu(!1),{accountType:E}=Vt(),I=Pl(r),A=n,T=n||!I,P=_=>{a(!0),s(r,_,m?.login?.disableSignup).then(()=>{l("AWAITING_PASSWORDLESS_CODE")}).catch(U=>{d({errorModalData:{error:U,previousScreen:p||"LANDING"}}),l("ERROR_SCREEN")}).finally(()=>{a(!1)})},S=()=>{h&&!g&&!i?(d({captchaModalData:{callback:_=>s(r,_),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_PASSWORDLESS_CODE",onErrorNavigateTo:"ERROR_SCREEN"}}),l("CAPTCHA_SCREEN")):P(g)};return oC(kT,{children:[ka(AT,{children:oC(xT,{stacked:e.stacked,children:[ka(ST,{}),ka("input",{ref:t,id:"email-input",type:"email",placeholder:"your@email.com",onFocus:()=>w(!0),onChange:_=>o(_.target.value),onKeyUp:_=>{_.key==="Enter"&&S()},value:r,autoComplete:"email"}),E==="email"&&!v?ka(ur,{color:"gray",children:"Recent"}):e.stacked?ka("span",{}):ka(ui,{isSubmitting:A,onClick:S,disabled:T,children:"Submit"})]})}),e.stacked?ka(F,{loadingText:null,loading:A,disabled:T,onClick:S,children:"Submit"}):null]})}),AT=nC.div`
|
|
2113
2113
|
width: 100%;
|
|
2114
2114
|
`,xT=nC.label`
|
|
2115
2115
|
display: block;
|
|
@@ -2180,7 +2180,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2180
2180
|
}
|
|
2181
2181
|
`;import{Fragment as IT,jsx as Id,jsxs as aC}from"react/jsx-runtime";var Md=({isEditable:e,setIsEditable:t,defaultValue:r})=>{let o=_T(null);return aC(IT,{children:[Id(yo,{if:!e,children:Id(_d,{ref:o,defaultValue:r})}),Id(yo,{if:e,children:aC(xe,{onClick:()=>{t(),setTimeout(()=>{o.current?.focus()},0)},children:[Id(RT,{})," Continue with Email"]})})]})};import{useState as MT}from"react";import WT from"styled-components";import{jsx as Vu,jsxs as NT}from"react/jsx-runtime";var Wd=()=>{let[e,t]=MT(!1),{currentScreen:r,navigate:o,setModalData:n,data:a}=x(),{enabled:i,token:s}=Te(),{initLoginWithFarcaster:l}=R(),{accountType:d}=Vt();return NT(xe,{onClick:async()=>{t(!0);try{i&&!s?(n({captchaModalData:{callback:m=>l(m,a?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:"AWAITING_FARCASTER_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"}}),o("CAPTCHA_SCREEN")):(await l(s,a?.login?.disableSignup),o("AWAITING_FARCASTER_CONNECTION"))}catch(m){n({errorModalData:{error:m,previousScreen:r||"LANDING"}}),o("ERROR_SCREEN")}finally{t(!1)}},disabled:!1,children:[Vu(Bo,{})," Farcaster",e&&Vu(Lo,{}),d==="farcaster"&&Vu(LT,{color:"gray",children:"Recent"})]})},LT=WT(ur)`
|
|
2182
2182
|
margin-left: auto;
|
|
2183
|
-
`;import QT from"@heroicons/react/24/outline/PhoneIcon";import{useRef as XT}from"react";import{forwardRef as GT,useEffect as qT,useState as Od}from"react";import mC from"styled-components";import OT from"libphonenumber-js/examples.mobile.json";import{isPossiblePhoneNumber as DT,AsYouType as iC,getCountries as UT,getCountryCallingCode as Ld,getExampleNumber as FT}from"libphonenumber-js/min";import{jsx as VT,jsxs as HT}from"react/jsx-runtime";var js=(e,t)=>DT(String(e),t),Nd=(e,t)=>`+${Ld(t)} ${e}`,sC=e=>`*${e.replaceAll("-","").slice(-4)}`,lC=e=>new iC(e),BT=UT().map(e=>({code:e,callCode:Ld(e)})),cC=e=>{let t=FT(e,OT)?.formatInternational();return t?.substring(t.indexOf(" ")+1)},dC=({value:e,onChange:t})=>VT("select",{value:e,onChange:t,children:BT.map(r=>HT("option",{value:r.code,children:[r.code," +",r.callCode]},r.code))}),pC=e=>{let t=new iC;t.input(e);let r=t.getCountry()||"US",o=t.getCallingCode()||"1";return{countryCode:r,phone:e.replace("+"+o,"")}};import{Fragment as YT,jsx as Ra,jsxs as uC}from"react/jsx-runtime";var On=GT((e,t)=>{let{app:r}=x(),[o,n]=Od(!1),{accountType:a}=Vt(),[i,s]=Od(""),[l,d]=Od(r?.intl.defaultCountry??"US"),p=js(i,l),m=lC(l),h=cC(l),g=Ld(l),v=!p,[w,E]=Od(!1),I=g.length,A=S=>{let _=S.target.value;d(_),s(""),e.onChange&&e.onChange({rawPhoneNumber:i,qualifiedPhoneNumber:Nd(i,_),countryCode:_,isValid:js(i,l)})},T=(S,_)=>{try{let
|
|
2183
|
+
`;import QT from"@heroicons/react/24/outline/PhoneIcon";import{useRef as XT}from"react";import{forwardRef as GT,useEffect as qT,useState as Od}from"react";import mC from"styled-components";import OT from"libphonenumber-js/examples.mobile.json";import{isPossiblePhoneNumber as DT,AsYouType as iC,getCountries as UT,getCountryCallingCode as Ld,getExampleNumber as FT}from"libphonenumber-js/min";import{jsx as VT,jsxs as HT}from"react/jsx-runtime";var js=(e,t)=>DT(String(e),t),Nd=(e,t)=>`+${Ld(t)} ${e}`,sC=e=>`*${e.replaceAll("-","").slice(-4)}`,lC=e=>new iC(e),BT=UT().map(e=>({code:e,callCode:Ld(e)})),cC=e=>{let t=FT(e,OT)?.formatInternational();return t?.substring(t.indexOf(" ")+1)},dC=({value:e,onChange:t})=>VT("select",{value:e,onChange:t,children:BT.map(r=>HT("option",{value:r.code,children:[r.code," +",r.callCode]},r.code))}),pC=e=>{let t=new iC;t.input(e);let r=t.getCountry()||"US",o=t.getCallingCode()||"1";return{countryCode:r,phone:e.replace("+"+o,"")}};import{Fragment as YT,jsx as Ra,jsxs as uC}from"react/jsx-runtime";var On=GT((e,t)=>{let{app:r}=x(),[o,n]=Od(!1),{accountType:a}=Vt(),[i,s]=Od(""),[l,d]=Od(r?.intl.defaultCountry??"US"),p=js(i,l),m=lC(l),h=cC(l),g=Ld(l),v=!p,[w,E]=Od(!1),I=g.length,A=S=>{let _=S.target.value;d(_),s(""),e.onChange&&e.onChange({rawPhoneNumber:i,qualifiedPhoneNumber:Nd(i,_),countryCode:_,isValid:js(i,l)})},T=(S,_)=>{try{let U=S.replace(/\D/g,""),D=i.replace(/\D/g,""),H=U===D?S:m.input(S);s(H),e.onChange&&e.onChange({rawPhoneNumber:H,qualifiedPhoneNumber:Nd(S,_),countryCode:_,isValid:js(S,_)})}catch(U){console.error("Error processing phone number:",U)}},P=()=>{E(!0);let S=Nd(i,l);e.onSubmit({rawPhoneNumber:i,qualifiedPhoneNumber:S,countryCode:l,isValid:js(i,l)}).finally(()=>E(!1))};return qT(()=>{if(e.defaultValue){let S=pC(e.defaultValue);m.reset(),A({target:{value:S.countryCode}}),T(S.phone,S.countryCode)}},[e.defaultValue]),uC(YT,{children:[Ra(zT,{children:uC(KT,{callingCodeLength:I,stacked:e.stacked,children:[Ra(dC,{value:l,onChange:A}),Ra("input",{ref:t,id:"phone-number-input",type:"tel",placeholder:h,onFocus:()=>n(!0),onChange:S=>{T(S.target.value,l)},onKeyUp:S=>{S.key==="Enter"&&P()},value:i,autoComplete:"tel"}),a==="phone"&&!o&&!e.hideRecent?Ra(ur,{color:"gray",children:"Recent"}):!e.stacked&&!e.noIncludeSubmitButton?Ra(ui,{isSubmitting:w,onClick:P,disabled:v,children:"Submit"}):Ra("span",{})]})}),e.stacked&&!e.noIncludeSubmitButton?Ra(F,{loading:w,loadingText:null,onClick:P,disabled:v,children:"Submit"}):null]})}),zT=mC.div`
|
|
2184
2184
|
width: 100%;
|
|
2185
2185
|
`,KT=mC.label`
|
|
2186
2186
|
--country-code-dropdown-width: calc(54px + calc(12 * ${e=>e.callingCodeLength}px));
|
|
@@ -2279,11 +2279,11 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2279
2279
|
margin-left: auto;
|
|
2280
2280
|
`;import{useState as r8}from"react";import o8 from"styled-components";import{jsx as Dn,jsxs as hC}from"react/jsx-runtime";function Fd(e){return hC("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 240 240",...e,children:[Dn("defs",{children:hC("linearGradient",{x1:"120",y1:"240",x2:"120",gradientUnits:"userSpaceOnUse",id:"telegram-linear-gradient",children:[Dn("stop",{offset:"0",stopColor:"#1d93d2"}),Dn("stop",{offset:"1",stopColor:"#38b0e3"})]})}),Dn("title",{children:"Telegram_logo"}),Dn("circle",{cx:"120",cy:"120",r:"120",fill:"url(#telegram-linear-gradient)"}),Dn("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"}),Dn("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"}),Dn("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"})]})}import{jsx as yC,jsxs as a8}from"react/jsx-runtime";var Bd=()=>{let{enabled:e,token:t}=Te(),{navigate:r,setModalData:o,data:n}=x(),[a,i]=r8(!1),{initLoginWithTelegram:s}=R(),{accountType:l}=Vt();async function d(m){try{await s(m,n?.login?.disableSignup),r("TELEGRAM_AUTH_SCREEN")}catch(h){console.error(h),i(!1)}}async function p(){if(i(!0),e&&!t){o({captchaModalData:{callback:d,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ERROR_SCREEN"}}),r("CAPTCHA_SCREEN");return}await d()}return a8(xe,{onClick:p,disabled:a,children:[yC(Fd,{}),"Telegram",l==="telegram"&&yC(n8,{color:"gray",children:"Recent"})]})},n8=o8(ur)`
|
|
2281
2281
|
margin-left: auto;
|
|
2282
|
-
`;import i8 from"@heroicons/react/24/outline/ChevronRightIcon";import{jsx as gC,jsxs as s8}from"react/jsx-runtime";var Hd=({onClick:e,text:t,icon:r})=>s8(xe,{onClick:e,children:[r,gC($t,{children:t}),gC(i8,{})]});import{Fragment as Gu,jsx as dt,jsxs as Gd}from"react/jsx-runtime";var qd=({connectOnly:e})=>{let{closePrivyModal:t,connectors:r}=R(),{app:o,onUserCloseViaDialogOrKeybindRef:n,data:a}=x(),{appearance:{palette:{colorScheme:i}}}=_e(),{accountType:s,walletClientType:l}=Vt(),d=s?Nn(s):null,p=o.loginMethodsAndOrder?.primary??[],m=o.loginMethodsAndOrder?.overflow??[],h=[...p,...m],g=o.loginMethods.passkey,v=a?.login,w=[];l&&h.includes(l)?w.push(l):s&&h.includes(d?.loginMethod)&&w.push(d?.loginMethod);let[E,I]=CC("default"),[A,T]=CC(s==="phone"?"sms":"email");c8(()=>{s==="phone"&&T("sms");let Q=h.indexOf("sms"),L=h.indexOf("email");Q>-1&&Q<L&&T("sms")},[s,p,m]);let P=()=>{t({shouldCallAuthOnSuccess:!0}),setTimeout(()=>{I("default")},150)};n.current=P;let S=Q=>Q==="email"?dt(Md,{isEditable:A==="email",setIsEditable:()=>{T("email")},defaultValue:v?.prefill?.type==="email"?v.prefill.value:void 0},Q):Q==="sms"?dt(Ud,{isEditable:A==="sms",setIsEditable:()=>{T("sms")},defaultValue:v?.prefill?.type==="phone"?v.prefill.value:void 0},Q):Q==="apple"?dt(gt,{provider:"apple"},Q):Q==="discord"?dt(gt,{provider:"discord"},Q):Q==="farcaster"?dt(Wd,{},Q):Q==="github"?dt(gt,{provider:"github"},Q):Q==="google"?dt(gt,{provider:"google"},Q):Q==="linkedin"?dt(gt,{provider:"linkedin"},Q):Q==="spotify"?dt(gt,{provider:"spotify"},Q):Q==="instagram"?dt(gt,{provider:"instagram"},Q):Q==="tiktok"?dt(gt,{provider:"tiktok"},Q):Q==="twitter"?dt(gt,{provider:"twitter"},Q):Q==="telegram"?dt(Bd,{},Q):Tn([Q],o.appearance.walletChainType,r,e,h,o.externalWallets.walletConnect.enabled),_=w.flatMap(S),
|
|
2282
|
+
`;import i8 from"@heroicons/react/24/outline/ChevronRightIcon";import{jsx as gC,jsxs as s8}from"react/jsx-runtime";var Hd=({onClick:e,text:t,icon:r})=>s8(xe,{onClick:e,children:[r,gC($t,{children:t}),gC(i8,{})]});import{Fragment as Gu,jsx as dt,jsxs as Gd}from"react/jsx-runtime";var qd=({connectOnly:e})=>{let{closePrivyModal:t,connectors:r}=R(),{app:o,onUserCloseViaDialogOrKeybindRef:n,data:a}=x(),{appearance:{palette:{colorScheme:i}}}=_e(),{accountType:s,walletClientType:l}=Vt(),d=s?Nn(s):null,p=o.loginMethodsAndOrder?.primary??[],m=o.loginMethodsAndOrder?.overflow??[],h=[...p,...m],g=o.loginMethods.passkey,v=a?.login,w=[];l&&h.includes(l)?w.push(l):s&&h.includes(d?.loginMethod)&&w.push(d?.loginMethod);let[E,I]=CC("default"),[A,T]=CC(s==="phone"?"sms":"email");c8(()=>{s==="phone"&&T("sms");let Q=h.indexOf("sms"),L=h.indexOf("email");Q>-1&&Q<L&&T("sms")},[s,p,m]);let P=()=>{t({shouldCallAuthOnSuccess:!0}),setTimeout(()=>{I("default")},150)};n.current=P;let S=Q=>Q==="email"?dt(Md,{isEditable:A==="email",setIsEditable:()=>{T("email")},defaultValue:v?.prefill?.type==="email"?v.prefill.value:void 0},Q):Q==="sms"?dt(Ud,{isEditable:A==="sms",setIsEditable:()=>{T("sms")},defaultValue:v?.prefill?.type==="phone"?v.prefill.value:void 0},Q):Q==="apple"?dt(gt,{provider:"apple"},Q):Q==="discord"?dt(gt,{provider:"discord"},Q):Q==="farcaster"?dt(Wd,{},Q):Q==="github"?dt(gt,{provider:"github"},Q):Q==="google"?dt(gt,{provider:"google"},Q):Q==="linkedin"?dt(gt,{provider:"linkedin"},Q):Q==="spotify"?dt(gt,{provider:"spotify"},Q):Q==="instagram"?dt(gt,{provider:"instagram"},Q):Q==="tiktok"?dt(gt,{provider:"tiktok"},Q):Q==="twitter"?dt(gt,{provider:"twitter"},Q):Q==="telegram"?dt(Bd,{},Q):Tn([Q],o.appearance.walletChainType,r,e,h,o.externalWallets.walletConnect.enabled),_=w.flatMap(S),U=p.filter(Q=>Q!==l&&Q!==d?.loginMethod).flatMap(S),D=m.filter(Q=>Q!==l&&Q!==d?.loginMethod).flatMap(S),H=[..._,...U,...D],B=p8({primary:U.length+_.length,overflow:D.length}),[Y,K]=Dm(H,B),O=E==="default"?void 0:()=>{I("default")};return Gd(Gu,{children:[dt(k,{title:o.appearance.landingHeader,onClose:P,backFn:O}),E==="default"&&dt(u8,{}),E==="default"&&(typeof o.appearance.loginMessage=="string"?dt(Ac,{children:o.appearance.loginMessage}):o.appearance.loginMessage),dt(Pc,{style:{overflow:"hidden"},children:Gd(my,{colorScheme:i,style:{maxHeight:400,overflowY:"scroll",padding:2},children:[E==="default"&&Gd(Gu,{children:[...Y,K.length>0&&dt(Hd,{text:"More options",icon:dt(l8,{}),onClick:()=>I("overflow")})]}),E==="overflow"&&Gd(Gu,{children:[...K]}),g&&E==="default"&&dt(Pd,{})]})}),o&&dt(Qa,{app:o}),dt(V,{})]})},Vd=5,p8=({primary:e,overflow:t})=>e<Vd?e:e===Vd&&t===0?Vd:Vd-1,u8=d8(Rd)`
|
|
2283
2283
|
margin-bottom: 16px;
|
|
2284
|
-
`;import m8 from"@heroicons/react/24/outline/EnvelopeIcon";import f8 from"@heroicons/react/24/outline/PhoneIcon";import h8 from"@heroicons/react/24/outline/UserCircleIcon";import{useEffect as y8,useMemo as bC,useState as EC}from"react";import g8 from"styled-components";import{toObjectKeys as C8}from"@privy-io/js-sdk-core";import{jsx as $s,jsxs as vC}from"react/jsx-runtime";var wC=({...e})=>vC("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...e,children:[vC("g",{clipPath:"url(#clip0_2856_1743)",children:[$s("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"}),$s("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"})]}),$s("defs",{children:$s("clipPath",{id:"clip0_2856_1743",children:$s("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]});import{Fragment as el,jsx as Qe,jsxs as qi}from"react/jsx-runtime";var zd=({connectOnly:e})=>{let{closePrivyModal:t,connectors:r}=R(),{data:o,onUserCloseViaDialogOrKeybindRef:n}=x(),a=_e(),{accountType:i,walletClientType:s}=Vt(),l=i?Nn(i):null,d=o?.login,p=bC(()=>d?.loginMethods?C8(d.loginMethods,!0):null,[d]),{email:m,sms:h,google:g,twitter:v,discord:w,github:E,spotify:I,instagram:A,tiktok:T,linkedin:P,apple:S,wallet:_,farcaster:
|
|
2284
|
+
`;import m8 from"@heroicons/react/24/outline/EnvelopeIcon";import f8 from"@heroicons/react/24/outline/PhoneIcon";import h8 from"@heroicons/react/24/outline/UserCircleIcon";import{useEffect as y8,useMemo as bC,useState as EC}from"react";import g8 from"styled-components";import{toObjectKeys as C8}from"@privy-io/js-sdk-core";import{jsx as $s,jsxs as vC}from"react/jsx-runtime";var wC=({...e})=>vC("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...e,children:[vC("g",{clipPath:"url(#clip0_2856_1743)",children:[$s("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"}),$s("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"})]}),$s("defs",{children:$s("clipPath",{id:"clip0_2856_1743",children:$s("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]});import{Fragment as el,jsx as Qe,jsxs as qi}from"react/jsx-runtime";var zd=({connectOnly:e})=>{let{closePrivyModal:t,connectors:r}=R(),{data:o,onUserCloseViaDialogOrKeybindRef:n}=x(),a=_e(),{accountType:i,walletClientType:s}=Vt(),l=i?Nn(i):null,d=o?.login,p=bC(()=>d?.loginMethods?C8(d.loginMethods,!0):null,[d]),{email:m,sms:h,google:g,twitter:v,discord:w,github:E,spotify:I,instagram:A,tiktok:T,linkedin:P,apple:S,wallet:_,farcaster:U,telegram:D}=p??a.loginMethods,{passkey:H}=a.loginMethods,B=[m&&"email",h&&"sms",g&&"google",v&&"twitter",w&&"discord",E&&"github",I&&"spotify",A&&"instagram",T&&"tiktok",P&&"linkedin",S&&"apple",U&&"farcaster",D&&"telegram"].filter(se=>!!se),Y=B.length>0,K=bC(()=>_&&!Y?"web3-first":_&&a?.appearance.loginGroupPriority||"web2-first",[_,Y,a?.appearance.loginGroupPriority]),O=a?.appearance.hideDirectWeb2Inputs,[Q,L]=EC("default"),[Ge,pe]=EC(TC({mostRecentlyUsedAccountType:i,smsAvailable:h,emailAvailable:m,prefilledType:d?.prefill?.type}));y8(()=>{pe(TC({mostRecentlyUsedAccountType:i,smsAvailable:h,emailAvailable:m,prefilledType:d?.prefill?.type}))},[m,h,i]);let X=()=>{t({shouldCallAuthOnSuccess:!0}),setTimeout(()=>{L("default")},150)};n.current=X;let fe=[];s&&_?fe.push(s):l?.loginMethod&&B.includes(l.loginMethod)&&fe.push(l.loginMethod);let re=se=>se==="email"?Qe(Md,{isEditable:Ge==="email",setIsEditable:()=>{pe("email")},defaultValue:d?.prefill?.type==="email"?d.prefill.value:void 0},se):se==="sms"?Qe(Ud,{isEditable:Ge==="sms",setIsEditable:()=>{pe("sms")},defaultValue:d?.prefill?.type==="phone"?d.prefill.value:void 0},se):se==="apple"?Qe(gt,{provider:"apple"},se):se==="discord"?Qe(gt,{provider:"discord"},se):se==="farcaster"?Qe(Wd,{},se):se==="github"?Qe(gt,{provider:"github"},se):se==="google"?Qe(gt,{provider:"google"},se):se==="linkedin"?Qe(gt,{provider:"linkedin"},se):se==="tiktok"?Qe(gt,{provider:"tiktok"},se):se==="spotify"?Qe(gt,{provider:"spotify"},se):se==="instagram"?Qe(gt,{provider:"instagram"},se):se==="twitter"?Qe(gt,{provider:"twitter"},se):se==="telegram"?Qe(Bd,{},se):Tn([se],a.appearance.walletChainType,r,e,[],a.externalWallets.walletConnect.enabled),te=Tn(a.appearance.walletList.filter(se=>se!==s),a.appearance.walletChainType,r,e,[...a.appearance.walletList,s],a.externalWallets.walletConnect.enabled),ae=B.filter(se=>se!==l?.loginMethod).flatMap(re),Je=fe.flatMap(re);K==="web3-first"&&Q==="default"?te.unshift(...Je):K==="web2-first"&&ae.unshift(...Je);let ot=Q==="default"?void 0:()=>{L("default")},ie=B.filter(se=>se!=="email"&&se!=="sms"),mt=w8({priority:K,email:m,sms:h,social:ie}),jt=b8({priority:K,email:m,sms:h,social:ie}),qr=E8({priority:K}),Pe=Qe(Ad,{text:qr,onClick:()=>L("web3-overflow")}),ue=Qe(Hd,{text:mt,icon:jt,onClick:()=>L("web2-overflow")}),ke=O?0:1;return qi(el,{children:[Qe(k,{title:a.appearance.landingHeader,onClose:X,backFn:ot}),Q==="default"&&Qe(v8,{}),Q==="default"&&(typeof a.appearance.loginMessage=="string"?Qe(Ac,{children:a.appearance.loginMessage}):a.appearance.loginMessage),Qe(Pc,{style:{overflow:"hidden",padding:2},children:qi(hr,{children:[Q==="default"&&K==="web2-first"&&qi(el,{children:[...ae.length>4?ae.slice(0,3):ae,ae.length>4&&ue,_&&Pe]}),Q==="default"&&K==="web3-first"&&qi(el,{children:[_&&qi(el,{children:[...te.length>4?te.slice(0,3):te,te.length>4&&Pe]}),ae.length>ke&&ue,ae.length===ke&&ae[0]]}),Q==="web2-overflow"&&qi(el,{children:[...K==="web3-first"?ae:ae.slice(3)]}),...Q==="web3-overflow"?te:[],H&&Q==="default"&&Qe(Pd,{})]})}),a&&Qe(Qa,{app:a}),Qe(V,{})]})},v8=g8(Rd)`
|
|
2285
2285
|
margin-bottom: 16px;
|
|
2286
|
-
`,w8=({priority:e,email:t,sms:r,social:o})=>e==="web2-first"?"Other socials":t&&r&&o.length>0||t&&o.length>0?"Log in with email or socials":r&&o.length>0?"Log in with sms or socials":t&&r?"Continue with email or sms":t?"Continue with email":r?"Continue with sms":"Log in with a social account",b8=({priority:e,email:t,sms:r,social:o})=>e==="web2-first"||o.length>0?Qe(h8,{}):t&&r?Qe(wC,{}):t?Qe(m8,{}):r?Qe(f8,{}):null,E8=({priority:e})=>e==="web2-first"?"Continue with a wallet":"Other wallets",TC=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:r,prefilledType:o})=>r&&(e==="email"&&o!=="phone"||o==="email")?"email":t&&(e==="phone"||o==="phone")?"sms":"email";import{jsx as SC}from"react/jsx-runtime";var PC=()=>{let{app:e}=x();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?SC(qd,{connectOnly:!0}):SC(zd,{connectOnly:!0})};import{jsx as AC}from"react/jsx-runtime";var xC=()=>{let{app:e}=x();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?AC(qd,{connectOnly:!1}):AC(zd,{connectOnly:!1})};import T8 from"@heroicons/react/24/outline/EnvelopeIcon";import{Fragment as S8,jsx as Un,jsxs as P8}from"react/jsx-runtime";var kC=()=>{let{app:e}=x();return P8(S8,{children:[Un(k,{},"header"),Un(le,{}),Un(we,{title:"Connect your email",description:`Add your email to your ${e?.name} account`,icon:Un(T8,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),Un(wr,{children:Un(_d,{stacked:!0})}),Un(ce,{}),Un(
|
|
2286
|
+
`,w8=({priority:e,email:t,sms:r,social:o})=>e==="web2-first"?"Other socials":t&&r&&o.length>0||t&&o.length>0?"Log in with email or socials":r&&o.length>0?"Log in with sms or socials":t&&r?"Continue with email or sms":t?"Continue with email":r?"Continue with sms":"Log in with a social account",b8=({priority:e,email:t,sms:r,social:o})=>e==="web2-first"||o.length>0?Qe(h8,{}):t&&r?Qe(wC,{}):t?Qe(m8,{}):r?Qe(f8,{}):null,E8=({priority:e})=>e==="web2-first"?"Continue with a wallet":"Other wallets",TC=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:r,prefilledType:o})=>r&&(e==="email"&&o!=="phone"||o==="email")?"email":t&&(e==="phone"||o==="phone")?"sms":"email";import{jsx as SC}from"react/jsx-runtime";var PC=()=>{let{app:e}=x();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?SC(qd,{connectOnly:!0}):SC(zd,{connectOnly:!0})};import{jsx as AC}from"react/jsx-runtime";var xC=()=>{let{app:e}=x();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?AC(qd,{connectOnly:!1}):AC(zd,{connectOnly:!1})};import T8 from"@heroicons/react/24/outline/EnvelopeIcon";import{Fragment as S8,jsx as Un,jsxs as P8}from"react/jsx-runtime";var kC=()=>{let{app:e}=x();return P8(S8,{children:[Un(k,{},"header"),Un(le,{}),Un(we,{title:"Connect your email",description:`Add your email to your ${e?.name} account`,icon:Un(T8,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),Un(wr,{children:Un(_d,{stacked:!0})}),Un(ce,{}),Un(V,{})]})};import A8 from"@heroicons/react/24/outline/PhoneIcon";import{Fragment as x8,jsx as Fn,jsxs as k8}from"react/jsx-runtime";var RC=()=>{let{app:e,currentScreen:t,data:r,navigate:o,setModalData:n}=x(),{initLoginWithSms:a}=R();async function i({qualifiedPhoneNumber:s}){try{await a(s),o("AWAITING_PASSWORDLESS_CODE")}catch(l){n({errorModalData:{error:l,previousScreen:r?.errorModalData?.previousScreen||t||"LINK_PHONE_SCREEN"}}),o("ERROR_SCREEN")}}return k8(x8,{children:[Fn(k,{},"header"),Fn(le,{}),Fn(we,{title:"Connect your phone",description:`Add your number to your ${e?.name} account`,icon:Fn(A8,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),Fn(wr,{children:Fn(On,{stacked:!0,onSubmit:i,hideRecent:!0})}),Fn(ce,{}),Fn(V,{})]})};import{Fragment as R8,jsx as zi,jsxs as _C}from"react/jsx-runtime";var IC=()=>{let{app:e,data:t}=x(),r=t?.externalConnectWallet?.suggestedAddress,o=r?_C("span",{children:["Link the wallet with address ",zi(Rr,{showCopyIcon:!1,address:r})," ",e?.name?`to ${e.name}.`:"."]}):`Link a wallet to your ${e?.name} account`;return _C(R8,{children:[zi(k,{},"header"),zi(Do,{title:"Link your wallet",description:o}),zi(hr,{children:zi(Si,{connectOnly:!1})}),zi(V,{})]})};import{jsx as MC,jsxs as _8}from"react/jsx-runtime";var WC=({style:e,...t})=>_8("svg",{width:"164",height:"164",viewBox:"0 0 164 164",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...e},...t,children:[MC("circle",{cx:"82",cy:"82",r:"80",stroke:"#EC6351","stroke-width":"4","stroke-linecap":"round"}),MC("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"})]});import{Fragment as I8,jsx as Bn,jsxs as LC}from"react/jsx-runtime";var NC=()=>{let{closePrivyModal:e}=R(),{navigate:t}=x();return LC(I8,{children:[Bn(k,{},"header"),Bn(le,{}),Bn(WC,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),Bn(Do,{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"}}),LC(wr,{children:[Bn(F,{onClick:()=>t("LANDING"),children:"Try again"}),Bn(Mr,{onClick:()=>e(),children:"Cancel"})]}),Bn(ce,{}),Bn(V,{})]})};import f9 from"@heroicons/react/24/solid/CheckBadgeIcon";import h9 from"@heroicons/react/24/solid/DevicePhoneMobileIcon";import y9 from"@heroicons/react/24/solid/IdentificationIcon";import g9 from"@heroicons/react/24/solid/PhoneIcon";import C9 from"@heroicons/react/24/solid/QuestionMarkCircleIcon";import QC from"@heroicons/react/24/solid/ShieldCheckIcon";import{useEffect as v9,useState as Ki}from"react";import{useContext as M8}from"react";function tl(){let{promptMfa:e,init:t,submit:r,cancel:o,mfaMethods:n}=M8(De);return{promptMfa:e,init:t,submit:r,cancel:o,mfaMethods:n}}import{useContext as W8}from"react";function Eo(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:r,submitEnrollmentWithSms:o,submitEnrollmentWithTotp:n,submitEnrollmentWithPasskey:a,unenroll:i,enrollInMfa:s}=W8(De);return{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:r,submitEnrollmentWithSms:o,submitEnrollmentWithTotp:n,submitEnrollmentWithPasskey:a,unenrollWithSms:()=>i("sms"),unenrollWithTotp:()=>i("totp"),unenrollWithPasskey:()=>i("passkey"),showMfaEnrollmentModal:()=>s(!0),closeMfaEnrollmentModal:()=>s(!1)}}import L8 from"styled-components";import{jsx as OC,jsxs as O8}from"react/jsx-runtime";var DC=e=>O8(N8,{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"88",height:"89",viewBox:"0 0 88 89",...e,children:[OC("rect",{y:"0.666016",width:"88",height:"88",rx:"44"}),OC("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"})]}),N8=L8.svg`
|
|
2287
2287
|
height: 90px;
|
|
2288
2288
|
width: 90px;
|
|
2289
2289
|
|
|
@@ -2294,7 +2294,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2294
2294
|
> path {
|
|
2295
2295
|
fill: white;
|
|
2296
2296
|
}
|
|
2297
|
-
`;import qu from"@heroicons/react/20/solid/CheckIcon";import D8 from"@heroicons/react/24/outline/ChevronRightIcon";import U8 from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import F8 from"@heroicons/react/24/outline/FingerPrintIcon";import B8 from"@heroicons/react/24/outline/PhoneIcon";import zu from"@heroicons/react/24/outline/TrashIcon";import H8 from"@heroicons/react/24/solid/ShieldCheckIcon";import{Fragment as V8,jsx as Ie,jsxs as Tr}from"react/jsx-runtime";var UC=({showIntro:e,userMfaMethods:t,appMfaMethods:r,userHasAuthSms:o,isTotpLoading:n,isPasskeyLoading:a,error:i,onClose:s,onBackToIntro:l,handleSelectMethod:d,setRemovingMfaMethod:p})=>{let m=t.reduce((g,v)=>({...g,[v]:!0}),{}),h=r.reduce((g,v)=>({...g,[v]:!0}),{});return Tr(V8,{children:[Ie(k,{backFn:e?l:void 0,onClose:s},"header"),Ie(He,{children:Ie(lt,{children:Ie(H8,{})})}),Ie(ye,{children:"Choose a verification method"}),t.length>0?Ie(ve,{children:"To add or delete verification methods, verification is required."}):Ie(ve,{children:"How would you like to verify your identity? You can change this later."}),i&&Ie(Nc,{style:{marginTop:"1.25rem"},children:i.message}),Tr(_c,{children:[(h.totp||m.totp)&&Tr(Ic,{children:[Ie(xe,{style:{justifyContent:"center"},disabled:m.totp||n,onClick:()=>d("totp"),children:n?Ie(yt,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):Tr(Lc,{children:[Tr(Wc,{children:[Ie(U8,{}),"Authenticator App"]}),m.totp?Tr(fa,{children:[Ie(qu,{}),"Added"]}):Ie(fa,{children:"Recommended"})]})}),m.totp&&Ie(Mc,{onClick:()=>p("totp"),children:Ie(zu,{})})]},"totp"),(h.sms||m.sms)&&Tr(Ic,{children:[Ie(xe,{disabled:m.sms||o,onClick:()=>d("sms"),children:Tr(Lc,{children:[Tr(Wc,{children:[Ie(B8,{}),"SMS"]}),m.sms&&Tr(fa,{children:[Ie(qu,{}),"Added"]}),o&&Ie(fa,{children:"Disabled"})]})}),m.sms&&Ie(Mc,{onClick:()=>p("sms"),children:Ie(zu,{})})]},"sms"),(h.passkey||m.passkey)&&Tr(Ic,{children:[Ie(xe,{style:{justifyContent:"center"},onClick:()=>d("passkey"),disabled:m.passkey||a,children:a?Ie(yt,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):Tr(Lc,{children:[Tr(Wc,{children:[Ie(F8,{}),"Passkey"]}),m.passkey?Tr(fa,{children:[Ie(qu,{}),"Added"]}):Ie(fa,{isAccent:!0,children:Ie(D8,{})})]})}),m.passkey&&Ie(Mc,{onClick:()=>p("passkey"),children:Ie(zu,{})})]},"passkey")]}),Ie(j,{})]})};import G8 from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import q8 from"@heroicons/react/24/outline/ClockIcon";import z8 from"@heroicons/react/24/outline/ShieldCheckIcon";import K8 from"@heroicons/react/24/solid/CheckCircleIcon";import{useMemo as Y8,useState as rl}from"react";import Kd from"styled-components";import{Fragment as Ku,jsx as be,jsxs as lo}from"react/jsx-runtime";var BC=({onComplete:e,onClose:t,onReset:r})=>{let{user:o}=z(),{data:n}=x(),{initLinkWithPasskey:a,linkWithPasskey:i}=R(),{initEnrollmentWithPasskey:s,submitEnrollmentWithPasskey:l}=Eo(),[d,p]=rl(!1),[m,h]=rl(!1),[g,v]=rl(!1),[w,E]=rl(null),I=Y8(()=>o?.linkedAccounts.filter(S=>S.type==="passkey")??[],[o]),A=()=>{n?.mfaEnrollmentFlow?.onSuccess(),e()},T=async S=>{p(!0);try{await s(),await l({credentialIds:S}),v(!0)}catch(_){E(_)}finally{p(!1)}},P=async()=>{h(!0),E(null);try{await a();let _=(await i())?.linkedAccounts.filter(
|
|
2297
|
+
`;import qu from"@heroicons/react/20/solid/CheckIcon";import D8 from"@heroicons/react/24/outline/ChevronRightIcon";import U8 from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import F8 from"@heroicons/react/24/outline/FingerPrintIcon";import B8 from"@heroicons/react/24/outline/PhoneIcon";import zu from"@heroicons/react/24/outline/TrashIcon";import H8 from"@heroicons/react/24/solid/ShieldCheckIcon";import{Fragment as V8,jsx as Ie,jsxs as Tr}from"react/jsx-runtime";var UC=({showIntro:e,userMfaMethods:t,appMfaMethods:r,userHasAuthSms:o,isTotpLoading:n,isPasskeyLoading:a,error:i,onClose:s,onBackToIntro:l,handleSelectMethod:d,setRemovingMfaMethod:p})=>{let m=t.reduce((g,v)=>({...g,[v]:!0}),{}),h=r.reduce((g,v)=>({...g,[v]:!0}),{});return Tr(V8,{children:[Ie(k,{backFn:e?l:void 0,onClose:s},"header"),Ie(He,{children:Ie(lt,{children:Ie(H8,{})})}),Ie(ye,{children:"Choose a verification method"}),t.length>0?Ie(ve,{children:"To add or delete verification methods, verification is required."}):Ie(ve,{children:"How would you like to verify your identity? You can change this later."}),i&&Ie(Nc,{style:{marginTop:"1.25rem"},children:i.message}),Tr(_c,{children:[(h.totp||m.totp)&&Tr(Ic,{children:[Ie(xe,{style:{justifyContent:"center"},disabled:m.totp||n,onClick:()=>d("totp"),children:n?Ie(yt,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):Tr(Lc,{children:[Tr(Wc,{children:[Ie(U8,{}),"Authenticator App"]}),m.totp?Tr(fa,{children:[Ie(qu,{}),"Added"]}):Ie(fa,{children:"Recommended"})]})}),m.totp&&Ie(Mc,{onClick:()=>p("totp"),children:Ie(zu,{})})]},"totp"),(h.sms||m.sms)&&Tr(Ic,{children:[Ie(xe,{disabled:m.sms||o,onClick:()=>d("sms"),children:Tr(Lc,{children:[Tr(Wc,{children:[Ie(B8,{}),"SMS"]}),m.sms&&Tr(fa,{children:[Ie(qu,{}),"Added"]}),o&&Ie(fa,{children:"Disabled"})]})}),m.sms&&Ie(Mc,{onClick:()=>p("sms"),children:Ie(zu,{})})]},"sms"),(h.passkey||m.passkey)&&Tr(Ic,{children:[Ie(xe,{style:{justifyContent:"center"},onClick:()=>d("passkey"),disabled:m.passkey||a,children:a?Ie(yt,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):Tr(Lc,{children:[Tr(Wc,{children:[Ie(F8,{}),"Passkey"]}),m.passkey?Tr(fa,{children:[Ie(qu,{}),"Added"]}):Ie(fa,{isAccent:!0,children:Ie(D8,{})})]})}),m.passkey&&Ie(Mc,{onClick:()=>p("passkey"),children:Ie(zu,{})})]},"passkey")]}),Ie(j,{})]})};import G8 from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import q8 from"@heroicons/react/24/outline/ClockIcon";import z8 from"@heroicons/react/24/outline/ShieldCheckIcon";import K8 from"@heroicons/react/24/solid/CheckCircleIcon";import{useMemo as Y8,useState as rl}from"react";import Kd from"styled-components";import{Fragment as Ku,jsx as be,jsxs as lo}from"react/jsx-runtime";var BC=({onComplete:e,onClose:t,onReset:r})=>{let{user:o}=z(),{data:n}=x(),{initLinkWithPasskey:a,linkWithPasskey:i}=R(),{initEnrollmentWithPasskey:s,submitEnrollmentWithPasskey:l}=Eo(),[d,p]=rl(!1),[m,h]=rl(!1),[g,v]=rl(!1),[w,E]=rl(null),I=Y8(()=>o?.linkedAccounts.filter(S=>S.type==="passkey")??[],[o]),A=()=>{n?.mfaEnrollmentFlow?.onSuccess(),e()},T=async S=>{p(!0);try{await s(),await l({credentialIds:S}),v(!0)}catch(_){E(_)}finally{p(!1)}},P=async()=>{h(!0),E(null);try{await a();let _=(await i())?.linkedAccounts.filter(U=>U.type==="passkey").map(U=>U.credentialId)??[];await T(_)}catch(S){E(S)}finally{h(!1)}};return I.length===0||m?be(Q8,{onReset:r,onClose:t,onClick:P,isCreating:m}):g?be(Z8,{onClick:A,onClose:A}):w?be(nn,{error:w,backFn:()=>E(null),onClick:()=>E(null)}):be(X8,{passkeys:I,isSubmitting:d,isCreating:m,onReset:r,onClose:t,onSubmitEnrollment:()=>T(I.map(S=>S.credentialId)),onAddPasskey:P})},Q8=({onReset:e,onClose:t,onClick:r,isCreating:o})=>lo(Ku,{children:[be(k,{backFn:e,onClose:t},"header"),be(He,{children:lo(hd,{children:[be(Sa,{}),be(Pa,{})]})}),be(ye,{children:"Set up passkey verification"}),lo(ma,{children:[lo(Cr,{children:[be(gr,{children:be(z8,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),lo(Cr,{children:[be(gr,{children:be(q8,{})}),"Takes seconds to set up and use"]}),lo(Cr,{children:[be(gr,{children:be(G8,{})}),"Use your passkey to verify transactions and login to your account"]})]}),be(F,{style:{marginTop:"2.25rem"},onClick:r,loading:o,children:"Add a new passkey"}),be(j,{})]}),X8=({onReset:e,onClose:t,onAddPasskey:r,onSubmitEnrollment:o,passkeys:n,isSubmitting:a,isCreating:i})=>{let[s,l]=rl(!1),d=s?n.length:n.length>3?2:3;return lo(Ku,{children:[be(k,{backFn:s?()=>l(!1):e,onClose:t},"header"),!s&&be(He,{children:lo(hd,{children:[be(Sa,{}),be(Pa,{})]})}),be(ye,{children:"Enable your passkeys for verification"}),lo(ma,{children:[n.slice(0,d).map(p=>lo(J8,{children:[be(j8,{children:e9(p)}),lo($8,{children:["Last used: ",p.latestVerifiedAt?.toLocaleString()]})]},p.credentialId)),!s&&n.length>3&&be(FC,{onClick:()=>l(!0),children:"View All"})]}),be(F,{style:{marginTop:"1.5rem"},onClick:o,loading:a,children:"Enable passkeys"}),n.length<5&&be(FC,{style:{marginTop:"0.5rem"},onClick:r,disabled:i,children:i?be(yt,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),be(j,{})]})},Z8=({onClick:e,onClose:t})=>lo(Ku,{children:[be(k,{onClose:t},"header"),be(He,{children:be(lt,{status:"success",children:be(K8,{})})}),be(ye,{children:"Passkey verification added"}),be(ve,{children:"From now on, you'll use the passkey whenever you use your Privy wallet."}),be(zt,{children:be(F,{onClick:e,children:"Done"})}),be(j,{})]}),J8=Kd.div`
|
|
2298
2298
|
&& {
|
|
2299
2299
|
padding: 0.75rem 1rem;
|
|
2300
2300
|
text-align: left;
|
|
@@ -2339,7 +2339,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2339
2339
|
box-shadow: none;
|
|
2340
2340
|
}
|
|
2341
2341
|
}
|
|
2342
|
-
`;import c9 from"@heroicons/react/24/solid/CheckCircleIcon";import GC from"@heroicons/react/24/solid/PhoneIcon";import{useState as Yd}from"react";import{useState as Yu}from"react";import{isMobile as t9}from"react-device-detect";import VC from"styled-components";import{Fragment as l9,jsx as ol,jsxs as s9}from"react/jsx-runtime";var nl=6,r9=new Array(nl).fill("");function o9(e){return e.replace(/\s+/g,"")}function Qu(e){return/^[0-9]{1}$/.test(e)}function HC(e){return e.length===nl&&e.every(Qu)}function n9(e,t){return e.reduce((r,o)=>r+Number(t(o)),0)}var _a=({onChange:e,disabled:t,errorReasonOverride:r,success:o})=>{let[n,a]=Yu(r9),[i,s]=Yu(null),[l,d]=Yu(null),p=async v=>{v.preventDefault();let w=o9(v.currentTarget.value);if(w==="")return;let E=n9(n,Qu),I=w.split(""),A=!I.every(Qu),T=I.length+E>nl;if(A){s("Passcode can only be numbers"),d(1);return}if(T){s("Passcode must be exactly 6 numbers"),d(1);return}s(null),d(null);let P=Number(v.currentTarget.name?.charAt(4)),S=[...w||[""]].slice(0,nl-P),_=[...n.slice(0,P),...S,...n.slice(P+S.length)];a(_);let
|
|
2342
|
+
`;import c9 from"@heroicons/react/24/solid/CheckCircleIcon";import GC from"@heroicons/react/24/solid/PhoneIcon";import{useState as Yd}from"react";import{useState as Yu}from"react";import{isMobile as t9}from"react-device-detect";import VC from"styled-components";import{Fragment as l9,jsx as ol,jsxs as s9}from"react/jsx-runtime";var nl=6,r9=new Array(nl).fill("");function o9(e){return e.replace(/\s+/g,"")}function Qu(e){return/^[0-9]{1}$/.test(e)}function HC(e){return e.length===nl&&e.every(Qu)}function n9(e,t){return e.reduce((r,o)=>r+Number(t(o)),0)}var _a=({onChange:e,disabled:t,errorReasonOverride:r,success:o})=>{let[n,a]=Yu(r9),[i,s]=Yu(null),[l,d]=Yu(null),p=async v=>{v.preventDefault();let w=o9(v.currentTarget.value);if(w==="")return;let E=n9(n,Qu),I=w.split(""),A=!I.every(Qu),T=I.length+E>nl;if(A){s("Passcode can only be numbers"),d(1);return}if(T){s("Passcode must be exactly 6 numbers"),d(1);return}s(null),d(null);let P=Number(v.currentTarget.name?.charAt(4)),S=[...w||[""]].slice(0,nl-P),_=[...n.slice(0,P),...S,...n.slice(P+S.length)];a(_);let U=S.length,D=Math.min(Math.max(P+U,0),nl-1);if(document.querySelector(`input[name=pin-${D}]`)?.focus(),HC(_))try{await e(_.join("")),document.querySelector(`input[name=pin-${D}]`)?.blur()}catch(B){d(1),s(B.message)}else try{await e(null)}catch(B){d(1),s(B.message)}},m=v=>{l===1&&(s(null),d(null));let w=[...n.slice(0,v),"",...n.slice(v+1)];a(w),v>0&&document.querySelector(`input[name=pin-${v-1}]`)?.focus(),HC(w)?e(w.join("")):e(null)},g=o?"success":!!(r||i)?"fail":"";return ol(l9,{children:s9(a9,{children:[ol("div",{children:n.map((v,w)=>ol("input",{name:`pin-${w}`,type:"text",value:n[w],onChange:p,onKeyUp:E=>{E.key==="Backspace"&&m(w)},inputMode:"numeric",autoFocus:w===0,pattern:"[0-9]",className:g,autoComplete:t9?"one-time-code":"off",disabled:t},w))}),ol("div",{children:ol(i9,{fail:!!r||!!i,children:r||i})})]})})},a9=VC.div`
|
|
2343
2343
|
display: flex;
|
|
2344
2344
|
flex-direction: column;
|
|
2345
2345
|
width: 100%;
|
|
@@ -2415,7 +2415,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2415
2415
|
width: 100%;
|
|
2416
2416
|
|
|
2417
2417
|
color: ${e=>e.fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)"};
|
|
2418
|
-
`;import{Fragment as Xu,jsx as Xe,jsxs as Ia}from"react/jsx-runtime";var qC=({onComplete:e,onReset:t,onClose:r})=>{let[o,n]=Yd(""),[a,i]=Yd(!1),[s,l]=Yd(null),[d,p]=Yd("enroll"),{initEnrollmentWithSms:m,submitEnrollmentWithSms:h}=Eo(),{app:g,data:v}=x();function w(){v?.mfaEnrollmentFlow?.onSuccess(),e()}async function E({qualifiedPhoneNumber:T}){try{await m({phoneNumber:T}),n(T),p("verify")}catch(P){l(P)}}async function I(T){try{if(!T)return;await h({phoneNumber:o,mfaCode:T}),i(!0)}catch(P){throw Kc(P)?new Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds."):ba(P)?new Error("The code you entered is not valid"):wa(P)?new Error("You have exceeded the time limit for code entry. Please try again in 30 seconds."):Yc(P)?new Error("Verification canceled"):new Error("Unknown error")}}function A(){d==="verify"?p("enroll"):t()}return s?Xe(nn,{error:s,backFn:()=>l(null),onClick:()=>l(null)}):d==="enroll"?Ia(Xu,{children:[Xe(k,{backFn:t,onClose:r},"header"),Xe(He,{children:Xe(lt,{children:Xe(GC,{})})}),Xe(ye,{children:"Set up SMS verification"}),Xe(ve,{children:"We'll text a verification code to this mobile device whenever you use your Privy wallet."}),Ia($r,{children:[Xe(On,{onSubmit:E,hideRecent:!0}),Ia(Ty,{children:["By providing your mobile number, you agree to receive text messages from ",g?.name,". Some carrier charges may apply"]})]}),Xe(j,{})]}):a?Ia(Xu,{children:[Xe(k,{onClose:w},"header"),Xe(He,{children:Xe(lt,{status:"success",children:Xe(c9,{})})}),Xe(ye,{children:"SMS verification added"}),Xe(ve,{children:"From now on, you'll enter the verification code sent to your mobile device whenever you use your Privy wallet."}),Xe(zt,{children:Xe(F,{onClick:w,children:"Done"})}),Xe(j,{})]}):Ia(Xu,{children:[Xe(k,{backFn:A,onClose:r},"header"),Xe(He,{children:Xe(lt,{children:Xe(GC,{})})}),Xe(ye,{children:"Enter enrollment code"}),Ia($r,{children:[Xe(_a,{onChange:I}),Ia(ve,{children:["To continue, enter the 6-digit code sent to ",Xe("strong",{children:sC(o)})]})]}),Xe(j,{})]})};import u9 from"@heroicons/react/24/solid/CheckCircleIcon";import m9 from"@heroicons/react/24/solid/DevicePhoneMobileIcon";import{useState as KC}from"react";import d9 from"@heroicons/react/24/solid/ShieldCheckIcon";import{jsx as p9}from"react/jsx-runtime";var zC=({size:e,authUrl:t})=>p9(_n,{url:t,squareLogoElement:d9,size:e,fgColor:"#1F1F1F"});import{Fragment as Zu,jsx as Ve,jsxs as al}from"react/jsx-runtime";var YC=({onComplete:e,onClose:t,onReset:r,totpInfo:o})=>{let[n,a]=KC("enroll"),[i,s]=KC(!1),{submitEnrollmentWithTotp:l}=Eo(),{data:d}=x();function p(){d?.mfaEnrollmentFlow?.onSuccess(),e()}function m(){a("verify")}async function h(v){try{if(!v)return;await l({mfaCode:v}),s(!0)}catch(w){throw Kc(w)?new Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds."):ba(w)?new Error("The code you entered is not valid"):wa(w)?new Error("You have exceeded the time limit for code entry. Please try again in 30 seconds."):Yc(w)?new Error("Verification canceled"):new Error("Unknown error")}}function g(){n==="verify"?a("enroll"):r()}return n==="enroll"?al(Zu,{children:[Ve(k,{backFn:r,onClose:t},"header"),Ve(ye,{children:"Scan QR code"}),Ve(ve,{children:"Open your authenticator app and scan the QR code to continue."}),Ve(gi,{children:Ve(zC,{authUrl:o.authUrl,size:200})}),al(zt,{children:[Ve(Ot,{children:Ve(Rn,{itemName:"secret",text:o.secret})}),Ve(F,{onClick:m,children:"Continue"})]}),Ve(j,{})]}):i?al(Zu,{children:[Ve(k,{onClose:p},"header"),Ve(He,{children:Ve(lt,{status:"success",children:Ve(u9,{})})}),Ve(ye,{children:"Authenticator app verification added"}),Ve(ve,{children:"From now on, you'll enter the verification code generated by your authenticator app whenever you use your Privy wallet."}),Ve(zt,{children:Ve(F,{onClick:p,children:"Done"})}),Ve(j,{})]}):al(Zu,{children:[Ve(k,{backFn:g,onClose:t},"header"),Ve(He,{children:Ve(lt,{children:Ve(m9,{})})}),Ve(ye,{children:"Enter enrollment code"}),Ve($r,{children:Ve(_a,{onChange:h})}),al(ve,{children:["To continue, enter the 6-digit code generated from your ",Ve("strong",{children:"authenticator app"})]}),Ve(j,{})]})};import{Fragment as Yi,jsx as
|
|
2418
|
+
`;import{Fragment as Xu,jsx as Xe,jsxs as Ia}from"react/jsx-runtime";var qC=({onComplete:e,onReset:t,onClose:r})=>{let[o,n]=Yd(""),[a,i]=Yd(!1),[s,l]=Yd(null),[d,p]=Yd("enroll"),{initEnrollmentWithSms:m,submitEnrollmentWithSms:h}=Eo(),{app:g,data:v}=x();function w(){v?.mfaEnrollmentFlow?.onSuccess(),e()}async function E({qualifiedPhoneNumber:T}){try{await m({phoneNumber:T}),n(T),p("verify")}catch(P){l(P)}}async function I(T){try{if(!T)return;await h({phoneNumber:o,mfaCode:T}),i(!0)}catch(P){throw Kc(P)?new Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds."):ba(P)?new Error("The code you entered is not valid"):wa(P)?new Error("You have exceeded the time limit for code entry. Please try again in 30 seconds."):Yc(P)?new Error("Verification canceled"):new Error("Unknown error")}}function A(){d==="verify"?p("enroll"):t()}return s?Xe(nn,{error:s,backFn:()=>l(null),onClick:()=>l(null)}):d==="enroll"?Ia(Xu,{children:[Xe(k,{backFn:t,onClose:r},"header"),Xe(He,{children:Xe(lt,{children:Xe(GC,{})})}),Xe(ye,{children:"Set up SMS verification"}),Xe(ve,{children:"We'll text a verification code to this mobile device whenever you use your Privy wallet."}),Ia($r,{children:[Xe(On,{onSubmit:E,hideRecent:!0}),Ia(Ty,{children:["By providing your mobile number, you agree to receive text messages from ",g?.name,". Some carrier charges may apply"]})]}),Xe(j,{})]}):a?Ia(Xu,{children:[Xe(k,{onClose:w},"header"),Xe(He,{children:Xe(lt,{status:"success",children:Xe(c9,{})})}),Xe(ye,{children:"SMS verification added"}),Xe(ve,{children:"From now on, you'll enter the verification code sent to your mobile device whenever you use your Privy wallet."}),Xe(zt,{children:Xe(F,{onClick:w,children:"Done"})}),Xe(j,{})]}):Ia(Xu,{children:[Xe(k,{backFn:A,onClose:r},"header"),Xe(He,{children:Xe(lt,{children:Xe(GC,{})})}),Xe(ye,{children:"Enter enrollment code"}),Ia($r,{children:[Xe(_a,{onChange:I}),Ia(ve,{children:["To continue, enter the 6-digit code sent to ",Xe("strong",{children:sC(o)})]})]}),Xe(j,{})]})};import u9 from"@heroicons/react/24/solid/CheckCircleIcon";import m9 from"@heroicons/react/24/solid/DevicePhoneMobileIcon";import{useState as KC}from"react";import d9 from"@heroicons/react/24/solid/ShieldCheckIcon";import{jsx as p9}from"react/jsx-runtime";var zC=({size:e,authUrl:t})=>p9(_n,{url:t,squareLogoElement:d9,size:e,fgColor:"#1F1F1F"});import{Fragment as Zu,jsx as Ve,jsxs as al}from"react/jsx-runtime";var YC=({onComplete:e,onClose:t,onReset:r,totpInfo:o})=>{let[n,a]=KC("enroll"),[i,s]=KC(!1),{submitEnrollmentWithTotp:l}=Eo(),{data:d}=x();function p(){d?.mfaEnrollmentFlow?.onSuccess(),e()}function m(){a("verify")}async function h(v){try{if(!v)return;await l({mfaCode:v}),s(!0)}catch(w){throw Kc(w)?new Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds."):ba(w)?new Error("The code you entered is not valid"):wa(w)?new Error("You have exceeded the time limit for code entry. Please try again in 30 seconds."):Yc(w)?new Error("Verification canceled"):new Error("Unknown error")}}function g(){n==="verify"?a("enroll"):r()}return n==="enroll"?al(Zu,{children:[Ve(k,{backFn:r,onClose:t},"header"),Ve(ye,{children:"Scan QR code"}),Ve(ve,{children:"Open your authenticator app and scan the QR code to continue."}),Ve(gi,{children:Ve(zC,{authUrl:o.authUrl,size:200})}),al(zt,{children:[Ve(Ot,{children:Ve(Rn,{itemName:"secret",text:o.secret})}),Ve(F,{onClick:m,children:"Continue"})]}),Ve(j,{})]}):i?al(Zu,{children:[Ve(k,{onClose:p},"header"),Ve(He,{children:Ve(lt,{status:"success",children:Ve(u9,{})})}),Ve(ye,{children:"Authenticator app verification added"}),Ve(ve,{children:"From now on, you'll enter the verification code generated by your authenticator app whenever you use your Privy wallet."}),Ve(zt,{children:Ve(F,{onClick:p,children:"Done"})}),Ve(j,{})]}):al(Zu,{children:[Ve(k,{backFn:g,onClose:t},"header"),Ve(He,{children:Ve(lt,{children:Ve(m9,{})})}),Ve(ye,{children:"Enter enrollment code"}),Ve($r,{children:Ve(_a,{onChange:h})}),al(ve,{children:["To continue, enter the 6-digit code generated from your ",Ve("strong",{children:"authenticator app"})]}),Ve(j,{})]})};import{Fragment as Yi,jsx as ee,jsxs as Br}from"react/jsx-runtime";var XC=()=>{let{user:e,enrollInMfa:t}=z(),[r,o]=Ki(null),{unenrollWithSms:n,unenrollWithTotp:a,unenrollWithPasskey:i}=Eo(),{app:s,ready:l,data:d,onUserCloseViaDialogOrKeybindRef:p}=x(),{closePrivyModal:m}=R(),{promptMfa:h}=tl(),{initEnrollmentWithTotp:g}=Eo(),[v,w]=Ki(!1),[E,I]=Ki(null),[A,T]=Ki(null),P=()=>{m({shouldCallAuthOnSuccess:!0}),t(!1),setTimeout(()=>{o(null),I(null)},500)},{initEnrollmentWithPasskey:S,submitEnrollmentWithPasskey:_}=Eo(),[U,D]=Ki(!1),[H,B]=Ki(null);p.current=P;let Y=e?.mfaMethods.includes("sms"),K=!!e?.phone,O=e?.mfaMethods.includes("totp"),Q=e?.mfaMethods.includes("passkey"),L=Y||O||Q,Ge=e?.linkedAccounts.filter(ie=>ie.type==="passkey").map(ie=>ie.credentialId)??[];v9(()=>{L&&w(!0)},[L]);function pe(){o(null),I(null)}function X(){w(!1)}async function fe(){D(!0);try{await S(),await _({credentialIds:Ge})}catch(ie){B(ie)}finally{D(!1)}}async function re(ie){if(await h().catch(B),ie==="totp"){I(ie),T(null),g().then(mt=>{T(mt)}).catch(()=>{T(null),pe()});return}if(ie==="passkey"&&Ge.length===1)return await fe();I(ie)}if(!l||!e||!s)return Br(Yi,{children:[ee(k,{onClose:P},"header"),ee(He,{children:ee(DC,{})}),ee($r,{children:ee(yt,{})}),ee(j,{})]});async function te(){o(null);try{await n()}catch{o(null)}}async function ae(){o(null);try{await a()}catch{o(null)}}async function Je(){o(null);try{await h(),await i()}catch{o(null)}}if(r==="sms")return Br(Yi,{children:[ee(k,{backFn:pe,onClose:P},"header"),ee(He,{children:ee(lt,{children:ee(g9,{})})}),ee(ye,{children:"Remove SMS verification?"}),Br(ve,{children:["MFA adds an extra layer of security to your ",s?.name," account. Make sure you have other methods to secure your account."]}),ee(zt,{children:ee(F,{warn:!0,onClick:te,children:"Remove SMS for MFA"})}),ee(j,{})]});if(r==="totp")return Br(Yi,{children:[ee(k,{backFn:pe,onClose:P},"header"),ee(He,{children:ee(lt,{children:ee(h9,{})})}),ee(ye,{children:"Remove Authenticator App verification?"}),Br(ve,{children:["MFA adds an extra layer of security to your ",s?.name," account. Make sure you have other methods to secure your account."]}),ee(zt,{children:ee(F,{warn:!0,onClick:ae,children:"Remove Authenticator App for MFA"})}),ee(j,{})]});if(r==="passkey")return Br(Yi,{children:[ee(k,{backFn:pe,onClose:P},"header"),ee(He,{children:ee(lt,{children:ee(C9,{})})}),ee(ye,{children:"Are you sure you want to remove passkey verification?"}),ee(ve,{children:"This will disable any passkeys you have set up for verification. You\u2019ll still be able to login with your passkeys if you\u2019ve set up passkey login."}),ee(zt,{children:ee(F,{warn:!0,onClick:Je,children:"Yes, remove"})}),ee(j,{})]});if(d.mfaEnrollmentFlow.mfaMethods.length===0&&!L)return Br(Yi,{children:[ee(k,{onClose:P},"header"),ee(He,{children:ee(lt,{children:ee(QC,{})})}),ee(ye,{children:"Add more security"}),Br(ve,{children:[s?.name," does not have any verification methods enabled."]}),ee(zt,{children:ee(F,{onClick:P,children:"Close"})}),ee(j,{})]});let ot=!L&&!v;return ot?Br(Yi,{children:[ee(k,{onClose:P},"header"),ee(He,{children:ee(lt,{children:ee(QC,{})})}),ee(ye,{children:"Transaction Protection"}),ee(ve,{children:"Set up transaction protection to add an extra layer of security to your account"}),Br(ma,{children:[Br(Cr,{children:[ee(gr,{children:ee(f9,{})}),"Enable 2-Step verification for your ",s?.name," wallet."]}),Br(Cr,{children:[ee(gr,{children:ee(y9,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),Br(zt,{children:[ee(F,{onClick:()=>w(!0),children:"Continue"}),ee(Mr,{onClick:P,children:"Not now"})]}),ee(j,{})]}):E==="sms"?ee(qC,{onComplete:P,onReset:pe,onClose:P}):E==="totp"&&A?ee(YC,{onComplete:P,onClose:P,onReset:pe,totpInfo:A}):E==="passkey"?ee(BC,{onComplete:P,onReset:pe,onClose:P}):ee(UC,{showIntro:ot,userMfaMethods:e.mfaMethods,appMfaMethods:s.mfa.methods,userHasAuthSms:K,onBackToIntro:X,handleSelectMethod:re,isTotpLoading:E==="totp"&&!A,isPasskeyLoading:U,error:H,onClose:P,setRemovingMfaMethod:o})};import eS from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import tS from"@heroicons/react/24/outline/FingerPrintIcon";import rS from"@heroicons/react/24/outline/PhoneIcon";import oS from"@heroicons/react/24/outline/ShieldCheckIcon";import nS from"@heroicons/react/24/solid/DevicePhoneMobileIcon";import aS from"@heroicons/react/24/solid/PhoneIcon";import{useEffect as iS,useState as cl}from"react";import{useMemo as z9,useEffect as K9,useState as v3}from"react";import Y9 from"styled-components";import{calculateTotalGasEstimate as Q9,populateTransactionRequest as X9}from"@privy-io/js-sdk-core";import C3 from"styled-components";import JC from"styled-components";import{jsx as ZC,jsxs as E9}from"react/jsx-runtime";var Qd=({label:e,children:t,valueStyles:r})=>E9(w9,{children:[ZC("div",{children:e}),ZC(b9,{style:{...r},children:t})]}),w9=JC.div`
|
|
2419
2419
|
display: flex;
|
|
2420
2420
|
align-items: center;
|
|
2421
2421
|
justify-content: space-between;
|
|
@@ -2545,7 +2545,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2545
2545
|
`;import{jsx as w3}from"react/jsx-runtime";var ll=({pendingTransaction:e})=>{let{getAccessToken:t}=z(),{wallets:r}=Zo(),{walletProxy:o,rpcConfig:n,chains:a,appId:i,nativeTokenSymbolForChainId:s}=R(),[l,d]=v3(null),[p,m]=v3(e),{tokenPrice:h}=Vo(p),g=s(e.chainId)||"ETH",v=z9(()=>r.find(w=>w.walletClientType==="privy"),[r]);return K9(()=>{async function w(){if(!await t()||!o||!v)return p;let I=Kr(p.chainId,a,n,{appId:i}),A=await X9(v.address,p,I),{totalGasEstimate:T}=await Q9(A,I);return d(T.toHexString()),A}w().then(m).catch(console.error)},[o]),v?w3(Z9,{children:w3(tp,{from:v.address,to:p.to,txn:p,gas:l??void 0,tokenPrice:h,tokenSymbol:g})}):null},Z9=Y9.div`
|
|
2546
2546
|
width: 100%;
|
|
2547
2547
|
padding: 1rem 0;
|
|
2548
|
-
`;import J9 from"@heroicons/react/24/outline/CalendarIcon";import j9 from"@heroicons/react/24/outline/ExclamationTriangleIcon";import $9 from"@heroicons/react/24/outline/ShieldCheckIcon";import{Fragment as b3,jsx as Zt,jsxs as ji}from"react/jsx-runtime";var E3=({hasBlockingError:e,error:t,onClose:r,onBack:o,handleSubmit:n,account:a,submitSuccess:i})=>{let{pendingTransaction:s}=R();return ji(b3,{children:[Zt(k,{onClose:r},"header"),Zt(Ye,{children:ji("div",{children:[Zt(ht,{success:i,fail:!!t}),t?Zt(j9,{style:{width:"38px",height:"38px"}}):Zt(Sa,{style:{width:"38px",height:"38px"}})]})}),Zt(ye,{style:{marginTop:"1rem"},children:"Verifying with passkey"}),ji(ma,{children:[ji(Cr,{children:[Zt(gr,{children:Zt($9,{})}),"Approve this action using your touch, face, PIN, or hardware key."]}),ji(Cr,{children:[Zt(gr,{children:Zt(J9,{})}),"You last added a passkey on"," ",a?.firstVerifiedAt?.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),"."]})]}),s&&Zt($r,{children:Zt(ll,{pendingTransaction:s})}),t&&ji(b3,{children:[Zt(Nc,{style:{marginTop:"1.25rem"},children:t.message}),Zt(F,{disabled:e,onClick:n,style:{marginTop:"1.25rem"},children:"Try again"})]}),o&&Zt(As,{style:{marginTop:"1rem"},onClick:o,children:"Choose another method"}),Zt(j,{})]})};import{Fragment as rm,jsx as Se,jsxs as So}from"react/jsx-runtime";var om=({open:e,onClose:t})=>{let{user:r}=z(),[o,n]=cl(null),{init:a,cancel:i,submit:s}=tl(),[l,d]=cl(!1),[p,m]=cl(!1),[h,g]=cl(null),[v,w]=cl(null);iS(()=>{e&&r?.mfaMethods&&r.mfaMethods.length>0?A(r.mfaMethods[0]):n(null)},[r?.mfaMethods,e]);let E=S=>du(S)?(d(!0),new Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")):ba(S)?(d(!1),new Error("The code you entered is not valid")):wa(S)?(d(!0),new Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")):(console.error(S),d(!1),new Error("Something went wrong."));async function I(S){w(null);try{if(!S||!o)return;await s(o,S),m(!0),d(!1),t()}catch(_){throw E(_)}}async function A(S){if(S==="passkey"){try{n(S);let _=await a(S);if(!_)throw new Error("something went wrong");g(_),await s(S,_),m(!0),d(!1),t()}catch(_){w(E(_))}return}try{n(S),await a(S)}catch(_){console.error(_)}}let T=()=>{n(null),w(null),i(),t()},P=()=>{n(null),w(null)};if(!e||!r)return null;if(o==="passkey"){let S=r.linkedAccounts.filter(_=>_.type==="passkey"&&_.enrolledInMfa).sort((_,
|
|
2548
|
+
`;import J9 from"@heroicons/react/24/outline/CalendarIcon";import j9 from"@heroicons/react/24/outline/ExclamationTriangleIcon";import $9 from"@heroicons/react/24/outline/ShieldCheckIcon";import{Fragment as b3,jsx as Zt,jsxs as ji}from"react/jsx-runtime";var E3=({hasBlockingError:e,error:t,onClose:r,onBack:o,handleSubmit:n,account:a,submitSuccess:i})=>{let{pendingTransaction:s}=R();return ji(b3,{children:[Zt(k,{onClose:r},"header"),Zt(Ye,{children:ji("div",{children:[Zt(ht,{success:i,fail:!!t}),t?Zt(j9,{style:{width:"38px",height:"38px"}}):Zt(Sa,{style:{width:"38px",height:"38px"}})]})}),Zt(ye,{style:{marginTop:"1rem"},children:"Verifying with passkey"}),ji(ma,{children:[ji(Cr,{children:[Zt(gr,{children:Zt($9,{})}),"Approve this action using your touch, face, PIN, or hardware key."]}),ji(Cr,{children:[Zt(gr,{children:Zt(J9,{})}),"You last added a passkey on"," ",a?.firstVerifiedAt?.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),"."]})]}),s&&Zt($r,{children:Zt(ll,{pendingTransaction:s})}),t&&ji(b3,{children:[Zt(Nc,{style:{marginTop:"1.25rem"},children:t.message}),Zt(F,{disabled:e,onClick:n,style:{marginTop:"1.25rem"},children:"Try again"})]}),o&&Zt(As,{style:{marginTop:"1rem"},onClick:o,children:"Choose another method"}),Zt(j,{})]})};import{Fragment as rm,jsx as Se,jsxs as So}from"react/jsx-runtime";var om=({open:e,onClose:t})=>{let{user:r}=z(),[o,n]=cl(null),{init:a,cancel:i,submit:s}=tl(),[l,d]=cl(!1),[p,m]=cl(!1),[h,g]=cl(null),[v,w]=cl(null);iS(()=>{e&&r?.mfaMethods&&r.mfaMethods.length>0?A(r.mfaMethods[0]):n(null)},[r?.mfaMethods,e]);let E=S=>du(S)?(d(!0),new Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")):ba(S)?(d(!1),new Error("The code you entered is not valid")):wa(S)?(d(!0),new Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")):(console.error(S),d(!1),new Error("Something went wrong."));async function I(S){w(null);try{if(!S||!o)return;await s(o,S),m(!0),d(!1),t()}catch(_){throw E(_)}}async function A(S){if(S==="passkey"){try{n(S);let _=await a(S);if(!_)throw new Error("something went wrong");g(_),await s(S,_),m(!0),d(!1),t()}catch(_){w(E(_))}return}try{n(S),await a(S)}catch(_){console.error(_)}}let T=()=>{n(null),w(null),i(),t()},P=()=>{n(null),w(null)};if(!e||!r)return null;if(o==="passkey"){let S=r.linkedAccounts.filter(_=>_.type==="passkey"&&_.enrolledInMfa).sort((_,U)=>U.firstVerifiedAt.valueOf()-_.firstVerifiedAt.valueOf())[0];return Se(E3,{account:S,selectedMethod:o,submitSuccess:p,hasBlockingError:l,error:v,onClose:T,onBack:P,handleSubmit:()=>I(h).catch(w)})}return o?Se(sS,{submitSuccess:p,hasBlockingError:l,handleSubmitCode:I,selectedMethod:o,onClose:T,onBack:r.mfaMethods.length>1?()=>n(null):void 0}):So(rm,{children:[Se(k,{onClose:T},"header"),Se(He,{children:Se(lt,{children:Se(oS,{})})}),Se(ye,{children:"Verify your identity"}),Se(ve,{children:"Choose a verification method"}),So(_c,{children:[r.mfaMethods.includes("totp")&&So(xe,{onClick:()=>A("totp"),children:[Se(eS,{}),"Authenticator App"]},"totp"),r.mfaMethods.includes("sms")&&So(xe,{onClick:()=>A("sms"),children:[Se(rS,{}),"SMS"]},"sms"),r.mfaMethods.includes("passkey")&&So(xe,{onClick:()=>A("passkey"),children:[Se(tS,{}),"Passkey"]},"passkey")]}),Se(j,{})]})},sS=({selectedMethod:e,submitSuccess:t,hasBlockingError:r,onClose:o,onBack:n,handleSubmitCode:a})=>{let{app:i}=x(),{pendingTransaction:s}=R();switch(e){case"sms":return So(rm,{children:[Se(k,{onClose:o},"header"),Se(He,{children:Se(lt,{children:Se(aS,{})})}),Se(ye,{children:"Enter verification code"}),So($r,{children:[Se(_a,{success:t,disabled:r,onChange:a}),So(ve,{children:["To continue, please enter the 6-digit code sent to your ",Se("strong",{children:"mobile device"})]}),s&&Se(ll,{pendingTransaction:s})]}),n&&Se(As,{theme:i?.appearance.palette.colorScheme,onClick:n,children:"Choose another method"}),Se(Mr,{onClick:o,children:"Not now"}),Se(j,{})]});case"totp":return So(rm,{children:[Se(k,{onClose:o},"header"),Se(He,{children:Se(lt,{children:Se(nS,{})})}),Se(ye,{children:"Enter verification code"}),So($r,{children:[Se(_a,{success:t,disabled:r,onChange:a}),So(ve,{children:["To continue, please enter the 6-digit code generated from your"," ",Se("strong",{children:"authenticator app"})]}),s&&Se(ll,{pendingTransaction:s})]}),n&&Se(As,{theme:i?.appearance.palette.colorScheme,onClick:n,children:"Choose another method"}),Se(Mr,{onClick:o,children:"Not now"}),Se(j,{})]});default:return null}};import{useEffect as T3,useState as S3}from"react";import lS from"styled-components";import{Fragment as dS,jsx as zo,jsxs as rp}from"react/jsx-runtime";var P3=()=>{let{authenticated:e,logout:t,ready:r,user:o}=z(),{app:n,setModalData:a,navigate:i,resetNavigation:s}=x(),{getAuthMeta:l,initLoginWithOAuth:d,loginWithOAuth:p,updateWallets:m,setReadyToTrue:h,closePrivyModal:g,createAnalyticsEvent:v}=R(),[w,E]=S3(!1),[I,A]=S3(void 0),T=l()?.provider||"google",{name:P,component:S}=fs(T),_=Ya(),U=Oe;T3(()=>{p(T).then(B=>{E(!0),h(!0),B&&_("login","onOAuthLoginComplete",B)}).catch(B=>{if(h(!1),B?.privyErrorCode==="allowlist_rejected"){A(void 0),s(),i("ALLOWLIST_REJECTION_SCREEN");return}if(B?.privyErrorCode==="max_accounts_reached"){console.error(new Ao(B).toString()),A(void 0),s(),i("USER_LIMIT_REACHED_SCREEN");return}if(B?.privyErrorCode==="user_does_not_exist"){A(void 0),s(),i("ACCOUNT_NOT_FOUND_SCREEN");return}if(B?.privyErrorCode==="account_transfer_required"&&B.data?.data?.nonce){A(void 0),s(),a({accountTransfer:{nonce:B.data?.data?.nonce,account:B.data?.data?.subject,displayName:B.data?.data?.account?.displayName,linkMethod:l()?.provider,embeddedWalletAddress:B.data?.data?.otherUser?.embeddedWalletAddress}}),i("LINK_CONFLICT_SCREEN");return}let{retryable:Y,detail:K}=Uh(B,T);A({retryable:Y,detail:K,message:"Authentication failed"})}).finally(()=>{aa()})},[P,T]),T3(()=>{if(r&&e&&w&&o){if(n?.legal.requireUsersAcceptTerms&&!o.hasAcceptedTerms){let Y=setTimeout(()=>{i("AFFIRMATIVE_CONSENT_SCREEN")},U);return()=>clearTimeout(Y)}if(It(o,n?.embeddedWallets?.createOnLogin)){let Y=setTimeout(()=>{a({createWallet:{onSuccess:()=>{},onFailure:K=>{console.error(K),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:K,provider:T,screen:"OAuthStatusScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),i("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")},U);return()=>clearTimeout(Y)}else{let Y=setTimeout(()=>g({shouldCallAuthOnSuccess:!0,isSuccess:!0}),U);return m(),()=>clearTimeout(Y)}}},[r,e,w,o]);let D=w?`Successfully connected with ${P}`:I?I.message:`Verifying connection to ${P}`,H="";return w?H="You\u2019re good to go!":I?H=I.detail:H="Just a few moments more",rp(dS,{children:[zo(k,{}),zo(le,{}),rp(cS,{children:[zo(Ye,{children:rp("div",{children:[zo(ht,{success:w,fail:!!I}),zo(S,{style:{width:"38px",height:"38px"}})]})}),rp(at,{children:[zo("h3",{children:D}),zo("p",{children:H})]}),I&&I?.retryable?zo(Cn,{onClick:()=>{aa(),d(T),A(void 0)},disabled:!w&&!I?.retryable,children:"Retry"}):null]}),zo(ce,{}),zo(j,{})]})},cS=lS.div`
|
|
2549
2549
|
display: flex;
|
|
2550
2550
|
flex-direction: column;
|
|
2551
2551
|
align-items: center;
|
|
@@ -2579,9 +2579,9 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2579
2579
|
stroke: var(--privy-color-accent) !important;
|
|
2580
2580
|
fill: var(--privy-color-accent) !important;
|
|
2581
2581
|
}
|
|
2582
|
-
`;import{useEffect as hS,useState as _3}from"react";import yS from"styled-components";import{isMobile as fS}from"react-device-detect";var R3=(e,t,r)=>{let o=new URL(window.location.href),n=encodeURIComponent(o.href.replace(/\/$/g,"")+`?privy_token=${e}&privy_connector=${r?"solana_adapter":"injected"}&privy_wallet_client=${r?"phantom_solana":"phantom"}`);if(!un()&&fS)return`${t?"phantom://":"https://phantom.app/ul/"}browse/${n}?ref=${n}`};import{Fragment as CS,jsx as ln,jsxs as I3}from"react/jsx-runtime";var M3=()=>{let{forkSession:e,ready:t,authenticated:r}=z(),{walletConnectionStatus:o}=R(),[n,a]=_3(""),[i,s]=_3(!1);hS(()=>{t&&r&&e().then(a)},[t,r]);let l=o?.connector?.chainType==="solana"||!1,d=R3(n,!i,l),p={title:"Redirecting to Phantom Mobile Wallet",description:"We'll take you to the Phantom Mobile Wallet app to continue your login experience.",footnote:""};return t&&(p.description="For the best experience, we'll automatically log you into the Phantom 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 Phantom mobile app.",p.footnote="Once you're done, you can return here or connect via Phantom's in-app browser."),I3(CS,{children:[ln(k,{},"header"),ln(le,{}),ln(Do,{title:p.title,description:p.description}),I3(wr,{children:[ln(gS,{children:ln(Wo,{style:{width:"72px",height:"72px"}})}),ln(bc,{href:d,onClick:()=>{setTimeout(()=>s(!0),1e3)},loading:t&&!d,children:i?"Go to App Store":"Continue"}),p.footnote?ln("p",{children:p.footnote}):null]}),ln(ce,{}),ln(
|
|
2582
|
+
`;import{useEffect as hS,useState as _3}from"react";import yS from"styled-components";import{isMobile as fS}from"react-device-detect";var R3=(e,t,r)=>{let o=new URL(window.location.href),n=encodeURIComponent(o.href.replace(/\/$/g,"")+`?privy_token=${e}&privy_connector=${r?"solana_adapter":"injected"}&privy_wallet_client=${r?"phantom_solana":"phantom"}`);if(!un()&&fS)return`${t?"phantom://":"https://phantom.app/ul/"}browse/${n}?ref=${n}`};import{Fragment as CS,jsx as ln,jsxs as I3}from"react/jsx-runtime";var M3=()=>{let{forkSession:e,ready:t,authenticated:r}=z(),{walletConnectionStatus:o}=R(),[n,a]=_3(""),[i,s]=_3(!1);hS(()=>{t&&r&&e().then(a)},[t,r]);let l=o?.connector?.chainType==="solana"||!1,d=R3(n,!i,l),p={title:"Redirecting to Phantom Mobile Wallet",description:"We'll take you to the Phantom Mobile Wallet app to continue your login experience.",footnote:""};return t&&(p.description="For the best experience, we'll automatically log you into the Phantom 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 Phantom mobile app.",p.footnote="Once you're done, you can return here or connect via Phantom's in-app browser."),I3(CS,{children:[ln(k,{},"header"),ln(le,{}),ln(Do,{title:p.title,description:p.description}),I3(wr,{children:[ln(gS,{children:ln(Wo,{style:{width:"72px",height:"72px"}})}),ln(bc,{href:d,onClick:()=>{setTimeout(()=>s(!0),1e3)},loading:t&&!d,children:i?"Go to App Store":"Continue"}),p.footnote?ln("p",{children:p.footnote}):null]}),ln(ce,{}),ln(V,{})]})},gS=yS(Ot)`
|
|
2583
2583
|
margin: 16px auto;
|
|
2584
|
-
`;import vS from"@heroicons/react/24/outline/ShieldCheckIcon";import{useEffect as wS,useState as np}from"react";import ap,{css as bS}from"styled-components";import{Fragment as AS,jsx as ir,jsxs as Na}from"react/jsx-runtime";var W3=()=>{let[e,t]=np(!0),{authenticated:r,getAccessToken:o}=z(),{walletProxy:n,closePrivyModal:a,createAnalyticsEvent:i}=R(),{navigate:s,data:l,onUserCloseViaDialogOrKeybindRef:d}=x(),[p,m]=np(void 0),[h,g]=np(""),[v,w]=np(!1),{privyWallet:E,onCompleteNavigateTo:I,onSuccess:A,onFailure:T}=l.recoverWallet,P=(
|
|
2584
|
+
`;import vS from"@heroicons/react/24/outline/ShieldCheckIcon";import{useEffect as wS,useState as np}from"react";import ap,{css as bS}from"styled-components";import{Fragment as AS,jsx as ir,jsxs as Na}from"react/jsx-runtime";var W3=()=>{let[e,t]=np(!0),{authenticated:r,getAccessToken:o}=z(),{walletProxy:n,closePrivyModal:a,createAnalyticsEvent:i}=R(),{navigate:s,data:l,onUserCloseViaDialogOrKeybindRef:d}=x(),[p,m]=np(void 0),[h,g]=np(""),[v,w]=np(!1),{privyWallet:E,onCompleteNavigateTo:I,onSuccess:A,onFailure:T}=l.recoverWallet,P=(U="User exited before their wallet could be recovered")=>{a({shouldCallAuthOnSuccess:!1}),T(typeof U=="string"?new kr(U):U)};d.current=P,wS(()=>{if(!r||!E)return P("User must be authenticated and have a Privy wallet before it can be recovered")},[r]);let S=U=>{U&&m(U)};return Na(AS,{children:[ir(k,{onClose:P}),ir(le,{}),Na(TS,{children:[Na(ES,{children:[ir(vS,{height:48,width:48,stroke:"var(--privy-color-accent)"}),ir("h3",{style:{color:"var(--privy-color-foreground)"},children:"Enter your password"}),ir("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),Na("div",{children:[Na(xn,{children:[ir(_i,{type:e?"password":"text",onChange:U=>S(U.target.value),disabled:v,style:{paddingRight:"2.3rem"}}),ir(Ii,{style:{right:"0.75rem"},children:e?ir(Mi,{onClick:()=>t(!1)}):ir(Wi,{onClick:()=>t(!0)})})]}),!!h&&ir(SS,{children:h})]}),Na("div",{children:[Na(_y,{children:[ir("h4",{children:"Why is this necessary?"}),ir("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),ir(PS,{loading:v||!n,disabled:!p,onClick:async()=>{w(!0);let U=await o();if(U&&E&&p!==null)try{i({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:E.address}}),await n?.recover({address:E.address,accessToken:U,recoveryPin:p,recoveryMethod:E.recoveryMethod}),g(""),I?s(I):a({shouldCallAuthOnSuccess:!1}),A?.(E),i({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:E.address}})}catch(D){gg(D)?g("Invalid recovery password, please try again."):g("An error has occurred, please try again.")}finally{w(!1)}else return P("User must be authenticated and have a Privy wallet before it can be recovered")},warn:!1,hideAnimations:!E&&v,children:"Recover your account"})]})]}),ir(ce,{}),ir(V,{})]})},ES=ap.div`
|
|
2585
2585
|
display: flex;
|
|
2586
2586
|
flex-direction: column;
|
|
2587
2587
|
align-items: center;
|
|
@@ -2630,13 +2630,13 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2630
2630
|
padding-bottom: 24px;
|
|
2631
2631
|
`,D3=O3.div`
|
|
2632
2632
|
padding-bottom: 24px;
|
|
2633
|
-
`;import{Fragment as B3,jsx as Gn,jsxs as cp}from"react/jsx-runtime";var F3={"google-drive":{name:"Google Drive",component:lp},icloud:{name:"iCloud",component:sp}},H3=()=>{let{logout:e}=z(),{navigate:t,setModalData:r,data:o}=x(),{recoveryOAuthFlow:n,closePrivyModal:a,createAnalyticsEvent:i}=R(),[s,l]=am(!1),{provider:d,action:p,isInAccountCreateFlow:m}=o?.recoveryOAuthStatus,[h,g]=am(void 0),[v,w]=am(p==="create-wallet");if(d==="user-passcode")throw new Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let E=F3[d].name,I=F3[d].component,A=o?.recoverWallet?.onCompleteNavigateTo,T=new Ke(async(
|
|
2633
|
+
`;import{Fragment as B3,jsx as Gn,jsxs as cp}from"react/jsx-runtime";var F3={"google-drive":{name:"Google Drive",component:lp},icloud:{name:"iCloud",component:sp}},H3=()=>{let{logout:e}=z(),{navigate:t,setModalData:r,data:o}=x(),{recoveryOAuthFlow:n,closePrivyModal:a,createAnalyticsEvent:i}=R(),[s,l]=am(!1),{provider:d,action:p,isInAccountCreateFlow:m}=o?.recoveryOAuthStatus,[h,g]=am(void 0),[v,w]=am(p==="create-wallet");if(d==="user-passcode")throw new Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let E=F3[d].name,I=F3[d].component,A=o?.recoverWallet?.onCompleteNavigateTo,T=new Ke(async(B="create-wallet")=>(w(!0),new Promise((Y,K)=>{setTimeout(async()=>{try{let O=window.open();await n(d,B,O),l(!0),Y()}catch{g({message:`${B==="recover"?"Recovery":"Back up"} with ${E} unsuccessful`,detail:p==="recover"?`Please verify that you are selecting the ${E} account associated with your backup.`:"",retryable:!0}),K()}},0)})));U3(()=>{p!=="recover"&&T.execute(m?"create-wallet":"set-recovery")},[]),U3(()=>{if(!s)return;let B=setTimeout(()=>{m?(r({createWallet:{onSuccess:()=>{},onFailure:Y=>{i({eventName:"embedded_wallet_creation_failure_logout",payload:{error:Y,screen:"RecoveryOAuthScreen"}}),e()},callAuthOnSuccessOnClose:!0}}),t("EMBEDDED_WALLET_CREATED_SCREEN")):a({shouldCallAuthOnSuccess:!1})},Oe);return()=>clearTimeout(B)},[s]);let P=xS(async()=>{await T.execute("recover"),A?t(A):l(!0)},[]),S=d==="google-drive"?"Google Drive":"Apple iCloud",_=p==="recover"?"recovered":"backed up",U=p==="recover"?"Recovering":"Backing up",D=s&&`Successfully ${_} with ${S}.`||h&&h.message||`${U} with ${S}...`,H=h?h.detail:"";return cp(B3,{children:[Gn(k,{}),v?Gn(B3,{children:cp(dl,{children:[Gn(we,{title:D,icon:Gn(I,{style:{width:"38px",height:"38px"}}),description:H}),h&&h?.retryable?Gn(F,{onClick:()=>{aa(),g(void 0),p==="create-wallet"?T.execute("create-wallet"):P()},disabled:!s&&!h?.retryable,children:"Try again"}):null]})}):cp(dl,{children:[Gn(we,{title:"Confirm it's really you",icon:Gn(I,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${S} where your account is backed up.`}),cp(F,{onClick:P,children:["Confirm with ",S]})]}),Gn(V,{})]})};import{useEffect as V3,useState as pl}from"react";import{jsx as kS}from"react/jsx-runtime";var G3=()=>{let{app:e,navigate:t,data:r,onUserCloseViaDialogOrKeybindRef:o}=x(),[n,a]=pl(""),[i,s]=pl(!1),[l,d]=pl(),[p,m]=pl(null),{authenticated:h}=z(),{closePrivyModal:g,isNewUserThisSession:v,initializeWalletProxy:w}=R(),{onSuccess:E,onFailure:I,callAuthOnSuccessOnClose:A}=r.createWallet,{createWallet:T}=Jc(),[P,S]=pl(null),_=new Ke(async()=>{try{let H=await T(l);if(!H)return;S(H),v?t("EMBEDDED_WALLET_CREATED_SCREEN"):(E(H),g({shouldCallAuthOnSuccess:A}))}catch(H){a(H.message)}});V3(()=>{p||w(3e4).then(H=>m(H))},[p]),V3(()=>{if(!h){t("LANDING"),I(new Error("User must be authenticated before creating a Privy wallet"));return}},[h]);let U=()=>{P&&P?.recoveryMethod!=="user-passcode"?(I(new kr("User created a wallet but failed to set a password for it")),g({shouldCallAuthOnSuccess:!1})):P?(E(P),g({shouldCallAuthOnSuccess:A})):(I(new kr("User wallet creation failed")),g({shouldCallAuthOnSuccess:!1}))};o.current=()=>null;let D=async()=>{s(!0);let H=250;return _.execute().then(()=>new Promise(B=>setTimeout(B,H))).finally(()=>s(!1))};return kS(td,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:!p,buttonLoading:i,buttonHideAnimations:!P&&i,isResettingPassword:!1,error:n,password:l||"",onClose:U,onPasswordChange:d,onPasswordGenerate:()=>d(ed()),onSubmit:D})};import RS from"@heroicons/react/24/outline/LockClosedIcon";import _S from"@heroicons/react/24/outline/PencilSquareIcon";import IS from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import{useState as MS}from"react";import WS from"styled-components";import{Fragment as sm,jsx as kt,jsxs as qn}from"react/jsx-runtime";var im=WS.div`
|
|
2634
2634
|
width: 24px;
|
|
2635
2635
|
height: 24px;
|
|
2636
2636
|
display: flex;
|
|
2637
2637
|
justify-content: center;
|
|
2638
2638
|
align-items: center;
|
|
2639
|
-
`,LS={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy"},NS=({onClose:e})=>qn(D3,{children:[kt(we,{title:"Why do I need to secure my account?",icon:kt(IS,{width:48}),description:qn(sm,{children:[kt("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),kt("p",{children:"To use this app on new devices, secure account secrets using a password, your Google or your Apple account. It\u2019s important you don\u2019t lose access to the method you choose."})]})}),kt(F,{onClick:e,children:"Select backup method"})]}),q3=()=>{let[e,t]=MS(!1),{navigate:r,lastScreen:o,navigateBack:n,setModalData:a,data:i,onUserCloseViaDialogOrKeybindRef:s}=x(),{user:l}=z(),{embeddedWallets:d}=_e(),{closePrivyModal:p}=R(),m=Be(l),h=m===null,{isInAccountCreateFlow:g,isResettingPassword:v}=i.recoverySelection,w=m&&m.recoveryMethod!=="privy",E=w?"Update backup method":"Secure your account",I=w?qn("span",{children:["Your account is currently secured using"," ",kt("strong",{children:LS[m?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function A(P){a({recoveryOAuthStatus:{provider:P,action:h?"create-wallet":"set-recovery",isInAccountCreateFlow:g}}),r("EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN")}function T(){i?.setWalletPassword?.onFailure(new Error("User exited set recovery flow")),p({shouldCallAuthOnSuccess:i?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return s.current=T,qn(sm,{children:[kt(k,{onClose:T,backFn:e?()=>t(!1):o?n:void 0,infoFn:o||e?void 0:()=>t(!0)},"header"),e?kt(NS,{onClose:()=>t(!1)}):qn(sm,{children:[kt(we,{title:E,icon:kt(RS,{width:48}),description:I}),kt(dl,{children:d.userOwnedRecoveryOptions.filter(P=>["icloud","google-drive"].includes(m?.recoveryMethod||"")?P!==m?.recoveryMethod:!0).sort().map(P=>{switch(P){case"google-drive":return qn(xe,{onClick:()=>A("google-drive"),children:[kt(im,{children:kt(lp,{style:{width:18}})}),"Back up to Google Drive"]},P);case"icloud":return qn(xe,{onClick:()=>A("icloud"),children:[kt(im,{children:kt(sp,{style:{width:24}})}),"Back up to Apple iCloud"]},P);case"user-passcode":return qn(xe,{onClick:()=>{let S=pu({isCreatingWallet:h,skipSplashScreen:!0});r(S)},children:[kt(im,{children:kt(_S,{style:{width:18}})}),v?"Reset your":"Set a"," password"]},P);default:return null}})})]}),kt(
|
|
2639
|
+
`,LS={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy"},NS=({onClose:e})=>qn(D3,{children:[kt(we,{title:"Why do I need to secure my account?",icon:kt(IS,{width:48}),description:qn(sm,{children:[kt("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),kt("p",{children:"To use this app on new devices, secure account secrets using a password, your Google or your Apple account. It\u2019s important you don\u2019t lose access to the method you choose."})]})}),kt(F,{onClick:e,children:"Select backup method"})]}),q3=()=>{let[e,t]=MS(!1),{navigate:r,lastScreen:o,navigateBack:n,setModalData:a,data:i,onUserCloseViaDialogOrKeybindRef:s}=x(),{user:l}=z(),{embeddedWallets:d}=_e(),{closePrivyModal:p}=R(),m=Be(l),h=m===null,{isInAccountCreateFlow:g,isResettingPassword:v}=i.recoverySelection,w=m&&m.recoveryMethod!=="privy",E=w?"Update backup method":"Secure your account",I=w?qn("span",{children:["Your account is currently secured using"," ",kt("strong",{children:LS[m?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function A(P){a({recoveryOAuthStatus:{provider:P,action:h?"create-wallet":"set-recovery",isInAccountCreateFlow:g}}),r("EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN")}function T(){i?.setWalletPassword?.onFailure(new Error("User exited set recovery flow")),p({shouldCallAuthOnSuccess:i?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return s.current=T,qn(sm,{children:[kt(k,{onClose:T,backFn:e?()=>t(!1):o?n:void 0,infoFn:o||e?void 0:()=>t(!0)},"header"),e?kt(NS,{onClose:()=>t(!1)}):qn(sm,{children:[kt(we,{title:E,icon:kt(RS,{width:48}),description:I}),kt(dl,{children:d.userOwnedRecoveryOptions.filter(P=>["icloud","google-drive"].includes(m?.recoveryMethod||"")?P!==m?.recoveryMethod:!0).sort().map(P=>{switch(P){case"google-drive":return qn(xe,{onClick:()=>A("google-drive"),children:[kt(im,{children:kt(lp,{style:{width:18}})}),"Back up to Google Drive"]},P);case"icloud":return qn(xe,{onClick:()=>A("icloud"),children:[kt(im,{children:kt(sp,{style:{width:24}})}),"Back up to Apple iCloud"]},P);case"user-passcode":return qn(xe,{onClick:()=>{let S=pu({isCreatingWallet:h,skipSplashScreen:!0});r(S)},children:[kt(im,{children:kt(_S,{style:{width:18}})}),v?"Reset your":"Set a"," password"]},P);default:return null}})})]}),kt(V,{})]})};import DS from"@heroicons/react/24/outline/ExclamationTriangleIcon";import US from"@heroicons/react/24/outline/LockClosedIcon";import{useState as lm}from"react";import OS from"styled-components";var z3=OS.div`
|
|
2640
2640
|
&& {
|
|
2641
2641
|
border-width: 4px;
|
|
2642
2642
|
}
|
|
@@ -2649,7 +2649,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2649
2649
|
border-style: solid;
|
|
2650
2650
|
border-color: ${e=>e.$color??"var(--privy-color-accent)"};
|
|
2651
2651
|
border-radius: 50%;
|
|
2652
|
-
`;import{Fragment as K3,jsx as Sr,jsxs as Y3}from"react/jsx-runtime";var Q3=()=>{let{user:e,getAccessToken:t}=z(),r=Be(e),{walletProxy:o,refreshUser:n,closePrivyModal:a}=R(),i=x(),[s,l]=lm(!1),[d,p]=lm(null),[m,h]=lm(null);function g(){if(!s){if(m){i.data?.setWalletPassword?.onFailure(m),a();return}if(!d){i.data?.setWalletPassword?.onFailure(new Error("User exited set recovery flow")),a();return}}}i.onUserCloseViaDialogOrKeybindRef.current=g;async function v(){l(!0);try{let E=await t();if(!E||!o||!r)return;if(!(await o.setRecovery({recoveryMethod:"privy",address:r.address,accessToken:E})).address)throw new Error("Unable to set recovery on wallet");let A=await n();if(!A)throw new Error("Unable to set recovery on wallet");let T=Be(A);if(!T)throw new Error("Unabled to set recovery on wallet");p(!!A),setTimeout(()=>{i.data?.setWalletPassword?.onSuccess(T),a()},Oe)}catch(E){h(E)}finally{l(!1)}}let w=!!(s||d);return m?Y3(K3,{children:[Sr(k,{onClose:g},"header"),Sr(z3,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:Sr(DS,{height:38,width:38,stroke:"var(--privy-color-error)"})}),Sr(wo,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),Sr($t,{style:{minHeight:"2rem"}}),Sr(pa,{onClick:()=>h(null),children:"Try again"}),Sr(
|
|
2652
|
+
`;import{Fragment as K3,jsx as Sr,jsxs as Y3}from"react/jsx-runtime";var Q3=()=>{let{user:e,getAccessToken:t}=z(),r=Be(e),{walletProxy:o,refreshUser:n,closePrivyModal:a}=R(),i=x(),[s,l]=lm(!1),[d,p]=lm(null),[m,h]=lm(null);function g(){if(!s){if(m){i.data?.setWalletPassword?.onFailure(m),a();return}if(!d){i.data?.setWalletPassword?.onFailure(new Error("User exited set recovery flow")),a();return}}}i.onUserCloseViaDialogOrKeybindRef.current=g;async function v(){l(!0);try{let E=await t();if(!E||!o||!r)return;if(!(await o.setRecovery({recoveryMethod:"privy",address:r.address,accessToken:E})).address)throw new Error("Unable to set recovery on wallet");let A=await n();if(!A)throw new Error("Unable to set recovery on wallet");let T=Be(A);if(!T)throw new Error("Unabled to set recovery on wallet");p(!!A),setTimeout(()=>{i.data?.setWalletPassword?.onSuccess(T),a()},Oe)}catch(E){h(E)}finally{l(!1)}}let w=!!(s||d);return m?Y3(K3,{children:[Sr(k,{onClose:g},"header"),Sr(z3,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:Sr(DS,{height:38,width:38,stroke:"var(--privy-color-error)"})}),Sr(wo,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),Sr($t,{style:{minHeight:"2rem"}}),Sr(pa,{onClick:()=>h(null),children:"Try again"}),Sr(V,{})]}):Y3(K3,{children:[Sr(k,{onClose:g},"header"),Sr(US,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),Sr(wo,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),Sr(to,{style:{marginTop:"1rem"},children:"When you log into a new device, you\u2019ll only need to authenticate to access your account. Never get logged out if you forget your password."}),Sr($t,{style:{minHeight:"2rem"}}),Sr(pa,{loading:s,disabled:w,onClick:()=>v(),children:d?"Success":"Confirm"}),Sr(V,{})]})};import{isVersionedTransaction as PP}from"@solana/wallet-adapter-base";import{useEffect as AP,useState as Da}from"react";async function cm({tx:e,accessToken:t,walletProxy:r}){let o=il(e,"from"),n=Ma(e)?Buffer.from(e.message.serialize()):e.serializeMessage(),{response:a}=await r.rpcSolana({accessToken:t,publicKey:o.toBase58(),request:{method:"signMessage",params:{message:n.toString("base64")}}}),i=a.data.signature;e.addSignature(o,Buffer.from(i,"base64"))}async function dp({tx:e,connection:t,accessToken:r,walletProxy:o,transactionOptions:n}){let a;try{await cm({tx:e,accessToken:r,walletProxy:o});let i=e.serialize();a=await t.sendRawTransaction(i,n);let s=await t.confirmTransaction(a);if(s.value.err||s.value.err){let d=s.value.err||s.value.err;throw typeof d=="string"?new Error(d):d}let l=await t.getParsedTransaction(a,{maxSupportedTransactionVersion:0});return{signature:a,receipt:l}}catch(i){throw i.txSignature=a,i}}import{useState as dm,useEffect as FS}from"react";var X3=()=>{let{showFiatPrices:e,getUsdPriceForSol:t}=R(),[r,o]=dm(!0),[n,a]=dm(void 0),[i,s]=dm(void 0);return FS(()=>{(async()=>{if(!e){o(!1);return}try{o(!0);let d=await t();d?s(d):a(new Error("Unable to fetch SOL price"))}catch(d){a(d)}finally{o(!1)}})()},[]),{solPrice:i,isSolPriceLoading:r,solPriceError:n}};import Z3 from"styled-components";import{Fragment as zS,jsx as rt,jsxs as Po}from"react/jsx-runtime";var BS=({transactionIndex:e,maxIndex:t})=>typeof e!="number"||t===0?"":` (${e+1} / ${t+1})`,pp=({img:e,submitError:t,prepareError:r,onClose:o,action:n,amount:a,title:i,subtitle:s,total:l,to:d,network:p,missingFunds:m,fee:h,from:g,cta:v,disabled:w,chain:E,isSubmitting:I,isPreparing:A,isTokenPriceLoading:T,isTokenContractInfoLoading:P,isSponsored:S,symbol:_,balance:U,onClick:D,spender:H,transactionIndex:B,maxIndex:Y,onBack:K,chainName:O})=>Po(zS,{children:[rt(k,{onClose:o,backFn:K}),e&&rt(qS,{children:e}),Po(wo,{style:{marginTop:e?"1.5rem":0},children:[i,rt(BS,{maxIndex:Y,transactionIndex:B})]}),rt(to,{children:s}),Po(Ta,{style:{marginTop:"2rem"},children:[l&&Po($e,{children:[rt(it,{children:"Total"}),rt(ct,{$isLoading:A||T,children:l})]}),n&&n!=="transaction"&&n!=="transfer"&&Po($e,{children:[rt(it,{children:"Action"}),rt(ct,{children:n})]}),a?Po($e,{children:[rt(it,{children:"Amount"}),Po(ct,{$isLoading:P,children:[GS(a)," ",_]})]}):null,H?Po($e,{children:[rt(it,{children:"Spender"}),rt(ct,{children:rt(Rr,{address:H,url:E?.blockExplorers?.default?.url,showCopyIcon:!1})})]}):null,d&&Po($e,{children:[rt(it,{children:"To"}),rt(ct,{children:rt(Rr,{address:d,url:E?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),Po($e,{children:[rt(it,{children:"Network"}),rt(ct,{children:p})]}),S===!1&&Po($e,{children:[rt(it,{children:"Estimated fee"}),rt(ct,{$isLoading:A||T,children:h})]})]}),rt($t,{}),t?rt(ls,{style:{marginTop:"2rem"},children:t.message}):r?rt(ls,{style:{marginTop:"2rem"},children:VS}):null,rt(HS,{$useSmallMargins:!!(r||t),address:g,balance:U,isLoading:A||T,errMsg:!A&&!r&&!t&&m?`Add funds on ${E?.name??O} to complete transaction.`:void 0}),rt(F,{style:{marginTop:"1rem"},loading:I,disabled:w||A,onClick:D,children:v}),rt(V,{})]}),HS=Z3(Xa)`
|
|
2653
2653
|
${e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;"}
|
|
2654
2654
|
`,VS="There was an error preparing your transaction. Your transaction request will likely fail.",GS=e=>e.toLocaleString(),qS=Z3.div`
|
|
2655
2655
|
display: flex;
|
|
@@ -2793,24 +2793,24 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2793
2793
|
display: inline-flex;
|
|
2794
2794
|
gap: 8px;
|
|
2795
2795
|
align-items: center;
|
|
2796
|
-
`;import{Fragment as SP,jsx as Ko,jsxs as av}from"react/jsx-runtime";var iv=({instructions:e,fees:t,onClose:r,receiptHeader:o,receiptDescription:n,transactionInfo:a,solPrice:i,rpcEndpoint:s})=>av(SP,{children:[Ko(k,{onClose:r}),Ko(Ye,{style:{marginBottom:"16px"},children:av("div",{children:[Ko(Tc,{color:"var(--privy-color-success-light)"}),Ko(bP,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),Ko(we,{title:o??"Transaction completed successfully.",description:n??""}),Ko(nv,{solPrice:i,instructions:e,fees:t,transactionInfo:a,rpcEndpoint:s}),Ko($t,{}),Ko(TP,{loading:!1,onClick:r,children:"Close"}),Ko(ce,{}),Ko(
|
|
2796
|
+
`;import{Fragment as SP,jsx as Ko,jsxs as av}from"react/jsx-runtime";var iv=({instructions:e,fees:t,onClose:r,receiptHeader:o,receiptDescription:n,transactionInfo:a,solPrice:i,rpcEndpoint:s})=>av(SP,{children:[Ko(k,{onClose:r}),Ko(Ye,{style:{marginBottom:"16px"},children:av("div",{children:[Ko(Tc,{color:"var(--privy-color-success-light)"}),Ko(bP,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),Ko(we,{title:o??"Transaction completed successfully.",description:n??""}),Ko(nv,{solPrice:i,instructions:e,fees:t,transactionInfo:a,rpcEndpoint:s}),Ko($t,{}),Ko(TP,{loading:!1,onClick:r,children:"Close"}),Ko(ce,{}),Ko(V,{})]}),TP=EP(F)`
|
|
2797
2797
|
&& {
|
|
2798
2798
|
margin-top: 24px;
|
|
2799
2799
|
}
|
|
2800
2800
|
transition: color 350ms ease, background-color 350ms ease;
|
|
2801
|
-
`;import{jsx as ul}from"react/jsx-runtime";var sv=()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:t}=x(),{closePrivyModal:r,walletProxy:o}=R(),n=_e(),{user:a}=z(),[i,s]=Da(e?.sendSolanaTransaction?.transactionRequest),[l,d]=Da(),[p,m]=Da(),[h,g]=Da(0),[v,w]=Da(!1),[E,I]=Da(),[A,T]=Da(null),P=e?.sendSolanaTransaction?.connection,S=e?.sendSolanaTransaction?.transactingWallet,_=l?.instructions.at(h),
|
|
2801
|
+
`;import{jsx as ul}from"react/jsx-runtime";var sv=()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:t}=x(),{closePrivyModal:r,walletProxy:o}=R(),n=_e(),{user:a}=z(),[i,s]=Da(e?.sendSolanaTransaction?.transactionRequest),[l,d]=Da(),[p,m]=Da(),[h,g]=Da(0),[v,w]=Da(!1),[E,I]=Da(),[A,T]=Da(null),P=e?.sendSolanaTransaction?.connection,S=e?.sendSolanaTransaction?.transactingWallet,_=l?.instructions.at(h),U=l?.instructions.length??1;if(AP(()=>{async function Pe(){if(i&&P)try{m(void 0);let ue=await Zd(i,P);d(ue),g(0)}catch(ue){console.warn("Failed to prepare transaction",ue),m(ue)}}Pe()},[i,P]),!i||!e?.sendSolanaTransaction||!S||!P){let Pe=new Error("Invalid transaction request");return ul(nn,{error:Pe,onClick:()=>{e?.sendSolanaTransaction?.onFailure(Pe),r({shouldCallAuthOnSuccess:!1})}})}let{solPrice:D,isSolPriceLoading:H}=X3(),B=()=>{if(!v)return E?(e?.sendSolanaTransaction?.onSuccess(E),r({shouldCallAuthOnSuccess:!1})):(e?.sendSolanaTransaction?.onFailure(A??p??new Error("User exited the modal before submitting the transaction")),g(0),r({shouldCallAuthOnSuccess:!1}))};t.current=B;let Y=async()=>{if(h<(l?.instructions.length??1)-1){g(h+1);return}try{w(!0);let Pe=await he();if(v||!Pe||!S||!o||!a)return;let{signature:ue,receipt:ke}=await dp({tx:i,accessToken:Pe,connection:P,walletProxy:o,transactionOptions:e.sendSolanaTransaction?.transactionOptions});I(Xd(ue,ke))}catch(Pe){console.warn({transaction:i,error:Pe}),T(Pe)}finally{w(!1)}},K=n.embeddedWallets.priceDisplay.primary==="fiat-currency",O=e.sendTransaction?.uiOptions?.transactionInfo?.title||(_?.action==="approve"?"Confirm address":"Approve transaction"),Q=e.sendTransaction?.uiOptions?.description||`${n.name} wants your permission to approve the following transaction.`,L=e.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?ul("img",{src:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,Ge=_?.amount||0n,pe=h===0&&l?.fees||0n,X=_?.balance||0n,fe=_?.from,re=_?.to,te=Ge+pe,ae=Qi(te),Je=K&&D?Xi(te,D):void 0,ot=pe?Qi(pe):void 0,ie=K&&D?Xi(pe,D):void 0,mt=X?Qi(X):void 0,jt=K&&D?Xi(X,D):void 0,qr=e.sendTransaction?.uiOptions?.buttonText||"Approve";if(E){let Pe=l?.instructions.map(({from:ue,to:ke,amount:se})=>({from:ue.toBase58(),to:ke.toBase58(),amount:se}));return ul(iv,{instructions:Pe??[],fees:h===0?E.fees:0n,onClose:B,transactionInfo:e.sendTransaction?.uiOptions.transactionInfo,solPrice:D,receiptHeader:e.sendTransaction?.uiOptions.successHeader,receiptDescription:e.sendTransaction?.uiOptions.successDescription,rpcEndpoint:P.rpcEndpoint})}return A?ul(mp,{transactionError:A,connection:P,onClose:B,network:"solana",onRetry:async()=>{T(null);let{blockhash:Pe}=await P.getLatestBlockhash();PP(i)?i.message.recentBlockhash=Pe:i.recentBlockhash=Pe,s(i)}}):ul(pp,{isSubmitting:v,submitError:A,isPreparing:!l,isTokenPriceLoading:H,isTokenContractInfoLoading:!1,symbol:"SOL",chain:void 0,img:L,title:O,subtitle:Q,from:fe?.toBase58()||"",to:re?.toBase58(),fee:ie??ot,total:Ge!=null?Je??ae:void 0,spender:_?.spender?.toBase58(),network:"Solana",cta:qr,missingFunds:!p&&!_?.hasFunds,action:_?.action,balance:jt??mt,prepareError:p,chainName:"Solana",onClose:B,onClick:Y,isSponsored:!1,transactionIndex:h,maxIndex:U-1,disabled:!_?.hasFunds,onBack:h>0&&U>1?()=>g(h-1):void 0})};import{useEffect as fv,useMemo as hm,useState as Fa}from"react";import{ProviderErrors as gv,QuantityToBigNumber as hv}from"@privy-io/js-sdk-core";import{EtherscanProvider as Lie}from"@ethersproject/providers";import{QuantityToBigNumber as xP}from"@privy-io/js-sdk-core";async function fp({accessToken:e,rootWallet:t,transactingWallet:r,walletProxy:o,transactionRequest:n,provider:a,requesterAppId:i}){n=Object.assign({chainId:Xo},n),kP(n);let l=(await o.rpc({address:t.address,hdWalletIndex:r.walletIndex??void 0,accessToken:e,requesterAppId:i,request:{method:"eth_signTransaction",params:[n]}})).response.data;return await a.sendTransaction(l)}async function hp(e,t,r,o){let n=await o.getBalance(e),a=t.value||0,s=!n.sub(xP(a)).sub(r).isNegative();return{balance:n,hasSufficientFunds:s}}function kP(e){let t=["gasLimit","gasPrice","value","maxPriorityFeePerGas","maxFeePerGas"];for(let r of t){let o=e[r];if(!(typeof o>"u")&&!RP(o))throw new Error(`Transaction request property '${r}' must be a valid number, bigint, or hex string representing a quantity`)}if(typeof e.chainId!="number")throw new Error("Transaction request property 'chainId' must be a number")}function RP(e){let t=typeof e=="number",r=typeof e=="bigint",o=typeof e=="string"&&_P(e);return t||r||o}function _P(e){return/^-?0x[a-f0-9]+$/i.test(e)}function yp(e){return{to:e.to,from:e.from,contractAddress:e.contractAddress,transactionIndex:e.transactionIndex,root:e.root,logsBloom:e.logsBloom,blockHash:e.blockHash,transactionHash:e.transactionHash,logs:e.logs,blockNumber:e.blockNumber,confirmations:e.confirmations,byzantium:e.byzantium,type:e.type,status:e.status,gasUsed:e.gasUsed.toHexString(),cumulativeGasUsed:e.cumulativeGasUsed.toHexString(),effectiveGasPrice:e.effectiveGasPrice?e.effectiveGasPrice.toHexString():void 0}}var pm={[Qr.id]:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",[sf.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[xo.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[nf.id]:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",[Xr.id]:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",[af.id]:"0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",[Yr.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[rf.id]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[Nl.id]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[tf.id]:"0x5425890298aed601595a70ab815c96711a31bc65",[mo.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[ef.id]:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},lv=(e,t)=>e===pm[t.id];var um=({address:e,appConfig:t,fundWalletConfig:r,methodScreen:o,chainIdOverride:n,comingFromSendTransactionScreen:a=!1})=>{if(!t.fundingConfig||t.fundingConfig.methods.length===0)return;let i;n?i=n:Td(r)&&r.chain?i=r.chain.id:i=Fl(t.fundingConfig.defaultRecommendedCurrency.chain);let s=t.chains.find(h=>h.id===i);if(!s)throw new C(`Funding chain ${i} is not in PrivyProvider chains list`);let l=Td(r)&&r.amount?r.amount:t.fundingConfig.defaultRecommendedAmount,d,p=!1;function m(){if(!i)return;let h=pm[i];t.fundingConfig?.methods.includes("external")&&!h&&console.warn("Attempting to fund with USDC on chain where USDC address is not known. Funding via external wallet will be disabled."),d=h,p=!0}return Td(r)&&"asset"in r?r.asset==="USDC"?m():typeof r.asset!="string"&&"erc20"in r.asset&&(d=r.asset.erc20,p=lv(d,s)):t.fundingConfig.defaultRecommendedCurrency.asset==="USDC"&&m(),{address:e,amount:l,chain:s,erc20Address:d,erc20ContractInfo:p?{symbol:"USDC",decimals:6}:void 0,isUSDC:p,methodScreen:o,comingFromSendTransactionScreen:a,..._2(r)?{moonpayConfigOverride:r.config}:{}}};var mm=["FUNDING_METHOD_SELECTION_SCREEN","FUNDING_TRANSFER_FROM_WALLET_SCREEN","FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN","FUNDING_MANUAL_TRANSFER_SCREEN","MOONPAY_PROMPT_SCREEN","MOONPAY_STATUS_SCREEN"],cv={["FUNDING_METHOD_SELECTION_SCREEN"]:null,["FUNDING_TRANSFER_FROM_WALLET_SCREEN"]:"external",["FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN"]:"external",["FUNDING_MANUAL_TRANSFER_SCREEN"]:"manual",["MOONPAY_PROMPT_SCREEN"]:"moonpay",["MOONPAY_STATUS_SCREEN"]:"moonpay"},IP={moonpay:"MOONPAY_PROMPT_SCREEN","coinbase-onramp":"COINBASE_ONRAMP_STATUS_SCREEN",external:"FUNDING_TRANSFER_FROM_WALLET_SCREEN"};function gp({fundingMethods:e}){if(e.length===0)throw new Error("Wallet funding is not enabled");return e.length===1?IP[e[0]]:"FUNDING_METHOD_SELECTION_SCREEN"}import{BigNumber as fm}from"@ethersproject/bignumber";import MP from"styled-components";import{Fragment as NP,jsx as Ua,jsxs as OP}from"react/jsx-runtime";var WP=(e,t)=>{if(e.gasUsed&&e.effectiveGasPrice)try{let r=fm.from(e.gasUsed),o=fm.from(e.effectiveGasPrice),n=r.mul(o);if(t){let a=fm.from(t);n=n.add(a)}return n.toString()}catch{return}else return},dv=({txn:e,receipt:t,transactionInfo:r,onClose:o,tokenPrice:n,tokenSymbol:a,l1GasEstimate:i,receiptHeader:s,receiptDescription:l})=>OP(NP,{children:[Ua(k,{onClose:o}),Ua(ha,{title:s??"Transaction complete!",description:l??"You're all set."}),Ua(tp,{tokenPrice:n,from:t.from,to:t.to,gas:WP(t,i),txn:e,transactionInfo:r,tokenSymbol:a}),Ua($t,{}),Ua(LP,{loading:!1,onClick:o,children:"All Done"}),Ua(ce,{}),Ua(V,{})]}),LP=MP(F)`
|
|
2802
2802
|
&& {
|
|
2803
2803
|
margin-top: 24px;
|
|
2804
2804
|
}
|
|
2805
2805
|
transition: color 350ms ease, background-color 350ms ease;
|
|
2806
|
-
`;import{decodeFunctionData as pv}from"viem";var uv=e=>{let t=UP(e);if(t)return{action:"approve",isErc20Ish:!0,functionName:t.functionName,spender:t.args[0],amount:t.args[1]};let r=FP(e);return r?{action:"transfer",isErc20Ish:!0,functionName:r.functionName,amount:r.args[1]}:{action:"transaction",isErc20Ish:!1}},DP=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],UP=e=>{try{return pv({abi:DP,data:e})}catch{return null}},FP=e=>{try{return pv({abi:Hs,data:e})}catch{return null}};import{BigNumber as BP}from"@ethersproject/bignumber";import{useEffect as HP,useState as VP}from"react";import{calculateTotalGasEstimate as GP,populateTransactionRequest as qP}from"@privy-io/js-sdk-core";var mv=(e,t,r)=>{let[o,n]=VP(null),{getAccessToken:a}=z(),{walletProxy:i}=R(),s=async()=>{if(!await a()||!i||!t)return null;let d=[],p=await qP(t.address,e,r).catch(w=>(d.push(w),e)),{totalGasEstimate:m,l1ExecutionFeeEstimate:h}=await GP(p,r).catch(w=>(d.push(w),{totalGasEstimate:null,l1ExecutionFeeEstimate:null})),{balance:g,hasSufficientFunds:v}=await hp(t.address,p,m??BP.from(0),r).catch(w=>(d.push(w),{balance:null,hasSufficientFunds:!1}));return{tx:p,totalGasEstimate:m,l1ExecutionFeeEstimate:h,balance:g,hasFunds:v,errors:d}};return HP(()=>{o&&n(null),s().then(n)},[e]),o};import{jsx as ml}from"react/jsx-runtime";var yv=new Wt(new Jr("There was an issue preparing your transaction",gv.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),zP=(e,t)=>{if(e?.sendTransaction)return"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]},KP=e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0,Cv=()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:t,setModalData:r,navigate:o}=x(),{rpcConfig:n,chains:a,closePrivyModal:i,walletProxy:s}=R(),{getAccessToken:l,user:d}=z(),p=_e(),[m,h]=Fa(0),g=KP(e),[v,w]=Fa(zP(e,m)),[E,I]=Fa(null),[A,T]=Fa(),[P,S]=Fa(!1),[_,
|
|
2806
|
+
`;import{decodeFunctionData as pv}from"viem";var uv=e=>{let t=UP(e);if(t)return{action:"approve",isErc20Ish:!0,functionName:t.functionName,spender:t.args[0],amount:t.args[1]};let r=FP(e);return r?{action:"transfer",isErc20Ish:!0,functionName:r.functionName,amount:r.args[1]}:{action:"transaction",isErc20Ish:!1}},DP=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],UP=e=>{try{return pv({abi:DP,data:e})}catch{return null}},FP=e=>{try{return pv({abi:Hs,data:e})}catch{return null}};import{BigNumber as BP}from"@ethersproject/bignumber";import{useEffect as HP,useState as VP}from"react";import{calculateTotalGasEstimate as GP,populateTransactionRequest as qP}from"@privy-io/js-sdk-core";var mv=(e,t,r)=>{let[o,n]=VP(null),{getAccessToken:a}=z(),{walletProxy:i}=R(),s=async()=>{if(!await a()||!i||!t)return null;let d=[],p=await qP(t.address,e,r).catch(w=>(d.push(w),e)),{totalGasEstimate:m,l1ExecutionFeeEstimate:h}=await GP(p,r).catch(w=>(d.push(w),{totalGasEstimate:null,l1ExecutionFeeEstimate:null})),{balance:g,hasSufficientFunds:v}=await hp(t.address,p,m??BP.from(0),r).catch(w=>(d.push(w),{balance:null,hasSufficientFunds:!1}));return{tx:p,totalGasEstimate:m,l1ExecutionFeeEstimate:h,balance:g,hasFunds:v,errors:d}};return HP(()=>{o&&n(null),s().then(n)},[e]),o};import{jsx as ml}from"react/jsx-runtime";var yv=new Wt(new Jr("There was an issue preparing your transaction",gv.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),zP=(e,t)=>{if(e?.sendTransaction)return"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]},KP=e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0,Cv=()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:t,setModalData:r,navigate:o}=x(),{rpcConfig:n,chains:a,closePrivyModal:i,walletProxy:s}=R(),{getAccessToken:l,user:d}=z(),p=_e(),[m,h]=Fa(0),g=KP(e),[v,w]=Fa(zP(e,m)),[E,I]=Fa(null),[A,T]=Fa(),[P,S]=Fa(!1),[_,U]=Fa(null),[D,H]=Fa(null);if(!v||!e?.sendTransaction||!e?.sendTransaction.transactingWallet)return ml(nn,{error:new Error("Invalid transaction request"),onClick:()=>{e?.sendTransaction?.onFailure(yv),i({shouldCallAuthOnSuccess:!1})}});let B=e.sendTransaction.rootWallet,Y=e.sendTransaction.transactingWallet,K=hm(()=>a.find(We=>Number(We.id)===Number(v.chainId)),[v.chainId]),O=K?.nativeCurrency.symbol??"ETH",{action:Q,amount:L,spender:Ge,isErc20Ish:pe}=hm(()=>uv(v.data),[v.data]);fv(()=>{v.to&&K&&pe&&bd({address:v.to,chain:K,rpcConfig:p.rpcConfig,privyAppId:p.id}).then(I).catch(console.error)},[v.to,K]);let{tokenPrice:X,isTokenPriceLoading:fe}=Vo(v),re=hm(()=>Kr(Number(v.chainId),a,n,{appId:p.id}),[v.chainId,n]),te=mv(v,Y,re);fv(()=>{e.sendTransaction?.getIsSponsored?e.sendTransaction.getIsSponsored().then(T).catch(console.error):T(!1)},[e.sendTransaction.getIsSponsored]);let ae=()=>{if(!P)return _?(e?.sendTransaction?.onSuccess(_.response),i({shouldCallAuthOnSuccess:!1})):!D&&!te?.errors[0]?(e?.sendTransaction?.onFailure(new Wt(new Jr("The user rejected the request",gv.E4001_USER_REJECTED_REQUEST.eipCode))),i({shouldCallAuthOnSuccess:!1})):(e?.sendTransaction?.onFailure(D??te?.errors[0]??yv),i({shouldCallAuthOnSuccess:!1}))};t.current=ae;let Je=async()=>{if(m<g){h(m+1);return}S(!0);try{let We=await l();if(P||!We||!Y||!s||!d)return;let lr=e?.sendTransaction?.onConfirm?await e.sendTransaction.onConfirm():(await fp({accessToken:We,transactingWallet:Y,rootWallet:B,walletProxy:s,transactionRequest:te?.tx??v,provider:re,requesterAppId:e.sendTransaction?.requesterAppId})).hash,Ar=await re.getTransaction(lr),cr=await Ar.wait();U({receipt:yp(cr),response:Ar})}catch(We){console.warn({transaction:te?.tx??v,error:We}),H(We)}finally{S(!1)}},ot=!!(p.fundingConfig&&p.fundingConfig.methods.length>0&&e.funding),ie=async()=>{if(!Y)return;if(!ot)throw new Error("Funding wallet is not enabled");let We=gp({fundingMethods:p.fundingConfig.methods});r({...e,funding:{...e.funding,methodScreen:We}}),o(We)},mt=p.embeddedWallets.priceDisplay.primary==="fiat-currency",jt=hv(te?.tx.value??0).add(hv(te?.totalGasEstimate?.toBigInt()??0)).toHexString(),qr=Mt(jt,O),Pe=mt&&X?ko(jt,X):void 0,ue=Mt(te?.totalGasEstimate?.toString()??0,O),ke=mt&&X?ko(te?.totalGasEstimate?.toString()??0,X):void 0,se=Mt(te?.balance?.toString()??0,O,void 0,!0),W=mt&&X?ko(te?.balance?.toString()??0,X):void 0,Ce=e.sendTransaction?.uiOptions?.transactionInfo?.title||(Q==="approve"?"Confirm address":`Approve ${Q}`),Tt=e.sendTransaction?.uiOptions?.description||`${p.name} wants your permission to approve the following transaction.`,J=e.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?ml("img",{src:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,oe=!!(te&&!te.errors[0]&&!te.hasFunds&&A===!1),sr=oe&&ot,Me=sr?"Add funds":e.sendTransaction?.uiOptions?.buttonText||(m<g?"Continue":"Approve");return _?.receipt?ml(dv,{txn:te?.tx??v,onClose:ae,receipt:_.receipt,transactionInfo:e.sendTransaction?.uiOptions.transactionInfo,tokenPrice:X,tokenSymbol:O,l1GasEstimate:te?.l1ExecutionFeeEstimate?.toString(),receiptHeader:e.sendTransaction?.uiOptions.successHeader,receiptDescription:e.sendTransaction?.uiOptions.successDescription}):D?ml(mp,{transactionError:D,network:"ethereum",chainId:te?.tx.chainId??v.chainId,onClose:ae,onRetry:({resetNonce:We})=>{H(null);let lr={...te?.tx??v};We&&(lr.nonce=void 0),w(lr)}}):ml(pp,{transactionIndex:m,onBack:g!==0&&typeof m=="number"&&m!==0?()=>{h(m-1)}:void 0,maxIndex:g,disabled:oe&&!ot,isSubmitting:P,submitError:D,isPreparing:!te,isTokenPriceLoading:fe,isTokenContractInfoLoading:!E,prepareError:te?.errors[0],symbol:E?.symbol,chain:K,img:J,title:Ce,subtitle:Tt,spender:Ge,total:v.value?Pe??qr:void 0,fee:ke??ue,isSponsored:A,to:v.to,network:p.chains.find(We=>We.id===v.chainId)?.name??"",from:Y?.address??"",cta:Me,missingFunds:oe,action:Q,balance:W??se,amount:L&&E?dd({amount:L,decimals:E.decimals}):L,onClose:ae,onClick:sr?ie:Je})};import{isHexString as QP}from"@ethersproject/bytes";import{toUtf8String as XP}from"@ethersproject/strings";import{useEffect as wv,useState as fl}from"react";import es from"styled-components";import{ProviderErrors as ym}from"@privy-io/js-sdk-core";import YP from"styled-components";var vv=YP.img`
|
|
2807
2807
|
&& {
|
|
2808
2808
|
height: ${e=>e.size==="sm"?"65px":"140px"};
|
|
2809
2809
|
width: ${e=>e.size==="sm"?"65px":"140px"};
|
|
2810
2810
|
border-radius: 16px;
|
|
2811
2811
|
margin-bottom: 12px;
|
|
2812
2812
|
}
|
|
2813
|
-
`;import{Fragment as Ev,jsx as pt,jsxs as hl}from"react/jsx-runtime";var ZP=e=>{if(!QP(e))return e;try{return XP(e)}catch{return e}},JP=e=>JSON.stringify(e,null,2),jP=({data:e})=>{let t=r=>typeof r=="object"&&r!==null?pt(eA,{children:Object.entries(r).map(([o,n])=>hl("li",{children:[hl("strong",{children:[o,":"]})," ",t(n)]},o))}):pt("span",{children:String(r)});return pt("div",{children:t(e)})},$P=e=>{let{types:t,primaryType:r,...o}=e.typedData;return hl(Ev,{children:[pt(gm,{children:pt(jP,{data:o})}),pt(Rn,{text:JP(e.typedData),itemName:"full payload to clipboard"})," "]})},bv=()=>{let{authenticated:e}=z(),{initializeWalletProxy:t,closePrivyModal:r}=R(),{navigate:o,data:n,onUserCloseViaDialogOrKeybindRef:a}=x(),[i,s]=fl(!0),[l,d]=fl(""),[p,m]=fl(),[h,g]=fl(null),[v,w]=fl(!1),E=h!==null;wv(()=>{e||o("LANDING")},[e]),wv(()=>{t(Ka).then(
|
|
2813
|
+
`;import{Fragment as Ev,jsx as pt,jsxs as hl}from"react/jsx-runtime";var ZP=e=>{if(!QP(e))return e;try{return XP(e)}catch{return e}},JP=e=>JSON.stringify(e,null,2),jP=({data:e})=>{let t=r=>typeof r=="object"&&r!==null?pt(eA,{children:Object.entries(r).map(([o,n])=>hl("li",{children:[hl("strong",{children:[o,":"]})," ",t(n)]},o))}):pt("span",{children:String(r)});return pt("div",{children:t(e)})},$P=e=>{let{types:t,primaryType:r,...o}=e.typedData;return hl(Ev,{children:[pt(gm,{children:pt(jP,{data:o})}),pt(Rn,{text:JP(e.typedData),itemName:"full payload to clipboard"})," "]})},bv=()=>{let{authenticated:e}=z(),{initializeWalletProxy:t,closePrivyModal:r}=R(),{navigate:o,data:n,onUserCloseViaDialogOrKeybindRef:a}=x(),[i,s]=fl(!0),[l,d]=fl(""),[p,m]=fl(),[h,g]=fl(null),[v,w]=fl(!1),E=h!==null;wv(()=>{e||o("LANDING")},[e]),wv(()=>{t(Ka).then(H=>{s(!1),H||(d("An error has occurred, please try again."),m(new Wt(new Jr(l,ym.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))})},[]);let{method:I,data:A,confirmAndSign:T,onSuccess:P,onFailure:S,uiOptions:_}=n.signMessage,U={title:_.title||"Sign message",description:_.description||"Signing this message will not cost you any fees.",buttonText:_.buttonText||"Sign and continue"},D=H=>{H?P(H):S(p||new Wt(new Jr("The user rejected the request.",ym.E4001_USER_REJECTED_REQUEST.eipCode))),r({shouldCallAuthOnSuccess:!1}),setTimeout(()=>{g(null),d(""),m(void 0)},200)};return a.current=()=>{D(h)},hl(Ev,{children:[pt(k,{onClose:()=>D(h)}),pt(le,{}),_.iconUrl&&typeof _.iconUrl=="string"?pt(oA,{children:pt(vv,{size:"sm",src:_.iconUrl,alt:"app image"})}):null,pt(wo,{children:U.title}),pt(to,{children:U.description}),I==="personal_sign"&&pt(gm,{children:ZP(A)}),I==="eth_signTypedData_v4"&&pt($P,{typedData:A}),I==="solana_signMessage"&&pt(gm,{children:A}),pt(nA,{}),pt(tA,{fail:!0,children:l}),pt(pa,{disabled:v||E||i,loading:v,onClick:async()=>{w(!0),d("");try{let H=await T();g(H),w(!1),setTimeout(()=>{D(H)},Oe)}catch(H){console.error(H),d("An error has occurred, please try again."),m(new Wt(new Jr(l,ym.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),w(!1)}},children:v?"Signing...":E?hl(rA,{children:[pt(Li,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",pt("span",{children:"Success"})]}):U.buttonText}),pt(ce,{}),pt(V,{})]})},gm=es.div`
|
|
2814
2814
|
margin-top: 1.5rem;
|
|
2815
2815
|
background-color: var(--privy-color-background-2);
|
|
2816
2816
|
border-radius: var(--privy-border-radius-md);
|
|
@@ -2864,7 +2864,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2864
2864
|
height: 82px;
|
|
2865
2865
|
`,nA=es.div`
|
|
2866
2866
|
flex-grow: 1;
|
|
2867
|
-
`;import{useEffect as Tv,useState as Sv}from"react";import aA from"styled-components";import{Fragment as sA,jsx as Yo,jsxs as Cp}from"react/jsx-runtime";var Pv=()=>{let{authenticated:e,logout:t,ready:r,user:o}=z(),{app:n,setModalData:a,navigate:i,resetNavigation:s,data:l}=x(),{initLoginWithTelegram:d,loginWithTelegram:p,updateWallets:m,setReadyToTrue:h,closePrivyModal:g,createAnalyticsEvent:v,getAuthMeta:w}=R(),[E,I]=Sv(!1),[A,T]=Sv(void 0),P=Oe;async function S(){try{await p(),I(!0),h(!0)}catch(
|
|
2867
|
+
`;import{useEffect as Tv,useState as Sv}from"react";import aA from"styled-components";import{Fragment as sA,jsx as Yo,jsxs as Cp}from"react/jsx-runtime";var Pv=()=>{let{authenticated:e,logout:t,ready:r,user:o}=z(),{app:n,setModalData:a,navigate:i,resetNavigation:s,data:l}=x(),{initLoginWithTelegram:d,loginWithTelegram:p,updateWallets:m,setReadyToTrue:h,closePrivyModal:g,createAnalyticsEvent:v,getAuthMeta:w}=R(),[E,I]=Sv(!1),[A,T]=Sv(void 0),P=Oe;async function S(){try{await p(),I(!0),h(!0)}catch(D){if(D?.privyErrorCode==="allowlist_rejected"){T(void 0),s(),i("ALLOWLIST_REJECTION_SCREEN");return}if(D?.privyErrorCode==="max_accounts_reached"){console.error(new Ao(D).toString()),T(void 0),s(),i("USER_LIMIT_REACHED_SCREEN");return}if(D?.privyErrorCode==="user_does_not_exist"){T(void 0),s(),i("ACCOUNT_NOT_FOUND_SCREEN");return}if(D?.privyErrorCode==="account_transfer_required"&&D.data?.data?.nonce){T(void 0),s(),a({accountTransfer:{nonce:D.data?.data?.nonce,account:D.data?.data?.subject,telegramAuthResult:w()?.telegramAuthResult,displayName:D.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:D.data?.data?.otherUser?.embeddedWalletAddress}}),i("LINK_CONFLICT_SCREEN");return}let{retryable:H,detail:B}=Op(D);T({retryable:H,detail:B,message:"Authentication failed"})}}Tv(()=>{S()},[]),Tv(()=>{if(!(r&&e&&E&&o))return;if(n?.legal.requireUsersAcceptTerms&&!o.hasAcceptedTerms){let B=setTimeout(()=>{i("AFFIRMATIVE_CONSENT_SCREEN")},P);return()=>clearTimeout(B)}if(It(o,n?.embeddedWallets?.createOnLogin)){let B=setTimeout(()=>{a({createWallet:{onSuccess:()=>{},onFailure:Y=>{console.error(Y),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:Y,provider:"telegram",screen:"TelegramAuthScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),i("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")},P);return()=>clearTimeout(B)}m();let H=setTimeout(()=>g({shouldCallAuthOnSuccess:!0,isSuccess:!0}),P);return()=>clearTimeout(H)},[r,e,E,o]);let _=E?"Successfully connected with Telegram":A?A.message:"Verifying connection to Telegram",U="";return E?U="You\u2019re good to go!":A?U=A.detail:U="Just a few moments more",Cp(sA,{children:[Yo(k,{}),Yo(le,{}),Cp(iA,{children:[Yo(Ye,{children:Cp("div",{children:[Yo(ht,{success:E,fail:!!A}),Yo(Fd,{style:{width:"38px",height:"38px"}})]})}),Cp(at,{children:[Yo("h3",{children:_}),Yo("p",{children:U})]}),A&&A?.retryable?Yo(Cn,{onClick:()=>{d(void 0,l?.login?.disableSignup).then(async()=>S()).catch(D=>{let{retryable:H,detail:B}=Op(D);T({retryable:H,detail:B,message:"Authentication failed"})}),T(void 0)},disabled:!E&&!A?.retryable,children:"Retry"}):null]}),Yo(ce,{}),Yo(j,{})]})},iA=aA.div`
|
|
2868
2868
|
display: flex;
|
|
2869
2869
|
flex-direction: column;
|
|
2870
2870
|
align-items: center;
|
|
@@ -2932,7 +2932,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2932
2932
|
&& > input::placeholder {
|
|
2933
2933
|
color: var(--privy-color-foreground-3);
|
|
2934
2934
|
}
|
|
2935
|
-
`;import{Fragment as fA,jsx as zn,jsxs as hA}from"react/jsx-runtime";var _v=()=>hA(fA,{children:[zn(k,{},"header"),zn(le,{}),zn(we,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:zn(mA,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),zn(wr,{children:zn(Rv,{stacked:!0})}),zn(ce,{}),zn(
|
|
2935
|
+
`;import{Fragment as fA,jsx as zn,jsxs as hA}from"react/jsx-runtime";var _v=()=>hA(fA,{children:[zn(k,{},"header"),zn(le,{}),zn(we,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:zn(mA,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),zn(wr,{children:zn(Rv,{stacked:!0})}),zn(ce,{}),zn(V,{})]});import yA from"@heroicons/react/24/outline/PhoneIcon";import{Fragment as gA,jsx as Kn,jsxs as CA}from"react/jsx-runtime";var Iv=()=>{let{currentScreen:e,data:t,navigate:r,setModalData:o}=x(),{user:n}=z(),{initUpdatePhone:a}=R();async function i({qualifiedPhoneNumber:s}){try{if(!n?.phone?.number)throw new Error("User is required to have an phone number to update it.");await a(n?.phone?.number,s),r("AWAITING_PASSWORDLESS_CODE")}catch(l){o({errorModalData:{error:l,previousScreen:t?.errorModalData?.previousScreen||e||"LINK_PHONE_SCREEN"}}),r("ERROR_SCREEN")}}return CA(gA,{children:[Kn(k,{},"header"),Kn(le,{}),Kn(we,{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:Kn(yA,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),Kn(wr,{children:Kn(On,{stacked:!0,onSubmit:i,hideRecent:!0})}),Kn(ce,{}),Kn(V,{})]})};import vm from"styled-components";import{jsx as Mv}from"react/jsx-runtime";var Wv=({style:e,...t})=>Mv("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},...t,children:Mv("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"})});import{Fragment as EA,jsx as Ba,jsxs as Cm}from"react/jsx-runtime";var Lv=()=>{let{navigate:e}=x();return Cm(EA,{children:[Ba(k,{}),Cm(vA,{children:[Ba(wA,{children:Ba(Wv,{})}),Cm(bA,{children:[Ba("h3",{children:"Unable to sign in"}),Ba("p",{children:"This application has reached its user limit and cannot sign in new users."})]}),Ba(F,{onClick:()=>{e("LANDING")},children:"Go back"})]}),Ba(V,{})]})},vA=vm.div`
|
|
2936
2936
|
display: flex;
|
|
2937
2937
|
flex-direction: column;
|
|
2938
2938
|
align-items: center;
|
|
@@ -3373,4 +3373,4 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
3373
3373
|
box-shadow: 0px 8px 36px rgba(55, 65, 81, 0.15);
|
|
3374
3374
|
border-radius: var(--privy-border-radius-lg);
|
|
3375
3375
|
}
|
|
3376
|
-
`;import{useRef as Kv,useEffect as FA}from"react";import{jsx as HA}from"react/jsx-runtime";function BA({botUsername:e,scriptHost:t}){let r=document.createElement("script"),{origin:o}=new URL(t);return r.async=!0,r.src=`${o}/js/telegram-login.js`,r.setAttribute("data-telegram-login",e),r.setAttribute("data-request-access","write"),r.setAttribute("data-lang","en"),r}function Yv(e){let t=Kv(null),r=Kv();return FA(()=>{r.current?.remove(),r.current=BA(e),t.current?.after(r.current)},[e]),HA("div",{ref:t,hidden:!0})}import{useState as VA}from"react";import{useEffect as Qv,useRef as Xv}from"react";var vp=class{constructor(){this.callbacks={}}enqueue(t,r){this.callbacks[t]=r}dequeue(t,r){let o=this.callbacks[r];if(!o)throw new Error(`cannot dequeue ${t} event: no event found for id ${r}`);switch(delete this.callbacks[r],t){case"privy:iframe:ready":return o;case"privy:wallet:create":return o;case"privy:wallet:create-additional":return o;case"privy:wallet:import":return o;case"privy:wallet:connect":return o;case"privy:wallet:recover":return o;case"privy:wallet:rpc":return o;case"privy:wallet:set-recovery":return o;case"privy:mfa:verify":return o;case"privy:mfa:init-enrollment":return o;case"privy:mfa:submit-enrollment":return o;case"privy:mfa:unenroll":return o;case"privy:mfa:clear":return o;case"privy:farcaster:init-signer":return o;case"privy:farcaster:sign":return o;case"privy:solana-wallet:create":return o;case"privy:solana-wallet:connect":return o;case"privy:solana-wallet:recover":return o;case"privy:solana-wallet:rpc":return o;default:throw new Error(`invalid wallet event type ${t}`)}}};async function Yn(e,t,r,o,n,a=!1){let i=a,s=async p=>{if(i&&t&&t.length>0){p===(a?0:1)?n("configureMfa","onMfaRequired",t):o.current?.reject(new Ue("missing_or_invalid_mfa","MFA verification failed, retry."));let m=await new Promise((h,g)=>{r.current={resolve:h,reject:g};let v=1e3*60*5;setTimeout(()=>{let w=new Ue("mfa_timeout","Timed out waiting for MFA code");o.current?.reject(w),g(w)},v)});return await e(m)}return await e()},l=4,d=null;for(let p=0;p<l;p++)try{d=await s(p),o.current?.resolve(void 0);break}catch(m){if(m.type==="missing_or_invalid_mfa")i=!0;else throw o.current?.resolve(void 0),m}if(d===null){let p=new Ue("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw o.current?.reject(p),p}return d}import{jsx as QA}from"react/jsx-runtime";var GA=function(e){return()=>`id-${e++}`}(0);function qA(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function bt(e){return e.error!==void 0}var vt=new vp,Sm=new Map,zA=(e,t)=>typeof t=="bigint"?t.toString():t,KA=(e,t)=>`${e}${JSON.stringify(t,zA)}`;function Et(e,t,r,o){let n=r.contentWindow;if(!n)throw new Error("iframe not initialized");let a=KA(e,t);if(e==="privy:wallet:create"){let s=Sm.get(a);if(s)return s}let i=new Promise((s,l)=>{let d=GA();vt.enqueue(d,{resolve:s,reject:l}),n.postMessage({id:d,event:e,data:t},o)}).finally(()=>{Sm.delete(a)});return Sm.set(a,i),i}function YA(e){switch(e.event){case"privy:iframe:ready":let t=vt.dequeue(e.event,e.id);return bt(e)?t.reject(new Ue(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let r=vt.dequeue(e.event,e.id);return bt(e)?r.reject(new Ue(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:create-additional":let o=vt.dequeue(e.event,e.id);return bt(e)?o.reject(new Ue(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:import":let n=vt.dequeue(e.event,e.id);return bt(e)?n.reject(new Ue(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:connect":let a=vt.dequeue(e.event,e.id);return bt(e)?a.reject(new Ue(e.error.type,e.error.message)):a.resolve(e.data);case"privy:wallet:recover":let i=vt.dequeue(e.event,e.id);return bt(e)?i.reject(new Ue(e.error.type,e.error.message)):i.resolve(e.data);case"privy:wallet:rpc":let s=vt.dequeue(e.event,e.id);return bt(e)?s.reject(new Ue(e.error.type,e.error.message)):s.resolve(e.data);case"privy:wallet:set-recovery":let l=vt.dequeue(e.event,e.id);return bt(e)?l.reject(new Ue(e.error.type,e.error.message)):l.resolve(e.data);case"privy:mfa:verify":let d=vt.dequeue(e.event,e.id);return bt(e)?d.reject(new Ue(e.error.type,e.error.message)):d.resolve(e.data);case"privy:mfa:init-enrollment":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:mfa:submit-enrollment":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:mfa:unenroll":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:mfa:clear":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:farcaster:init-signer":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:farcaster:sign":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:solana-wallet:create":let p=vt.dequeue(e.event,e.id);return bt(e)?p.reject(new Ue(e.error.type,e.error.message)):p.resolve(e.data);case"privy:solana-wallet:connect":let m=vt.dequeue(e.event,e.id);return bt(e)?m.reject(new Ue(e.error.type,e.error.message)):m.resolve(e.data);case"privy:solana-wallet:recover":let h=vt.dequeue(e.event,e.id);return bt(e)?h.reject(new Ue(e.error.type,e.error.message)):h.resolve(e.data);case"privy:solana-wallet:rpc":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}function Zv(e){let t=Xv(null),r=Xv(e.mfaMethods),o=Ya(),[n,a]=VA(!1);return Qv(()=>{r.current=e.mfaMethods},[e.mfaMethods]),Qv(()=>{if(!n)return;let i=t.current;if(!i)return;function s(h){h&&h.origin===e.origin&&qA(h.data)&&YA(h.data)}let l={create(h){return Et("privy:wallet:create",h,i,e.origin)},createAdditional(h){return Et("privy:wallet:create-additional",h,i,e.origin)},import(h){return Et("privy:wallet:import",h,i,e.origin)},connect(h){return Et("privy:wallet:connect",h,i,e.origin)},recover(h){return Yn(g=>Et("privy:wallet:recover",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!h.recoveryMethod||h.recoveryMethod==="privy")},rpc(h){return Yn(g=>Et("privy:wallet:rpc",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},createSolana(h){return Et("privy:solana-wallet:create",h,i,e.origin)},connectSolana(h){return Et("privy:solana-wallet:connect",h,i,e.origin)},recoverSolana(h){return Et("privy:solana-wallet:recover",h,i,e.origin)},rpcSolana(h){return Et("privy:solana-wallet:rpc",h,i,e.origin)},setRecovery(h){return Yn(g=>Et("privy:wallet:set-recovery",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},verifyMfa(h){return Yn(g=>Et("privy:mfa:verify",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},initEnrollMfa(h){return Yn(g=>Et("privy:mfa:init-enrollment",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},submitEnrollMfa(h){return Yn(g=>Et("privy:mfa:submit-enrollment",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},unenrollMfa(h){return Yn(g=>Et("privy:mfa:unenroll",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},clearMfa(h){return Et("privy:mfa:clear",h,i,e.origin)},initFarcasterSigner(h){return Et("privy:farcaster:init-signer",h,i,e.origin)},signFarcasterMessage(h){return Et("privy:farcaster:sign",h,i,e.origin)}};window.addEventListener("message",s);let d=()=>e.onLoad(l),p=(...h)=>{console.warn("Privy iframe failed to load: ",...h),e.onLoadFailed()},m=new AbortController;return os(()=>Et("privy:iframe:ready",{},i,e.origin),{abortSignal:m.signal}).then(d,p),()=>{window.removeEventListener("message",s),m.abort()}},[n]),QA("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>a(!0),src:Al(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId,client_id:e.appClientId})})}var wp=class{constructor(t,r){this.walletProxy=t,this.address=r}async handleSignMessage(t){if(!t.params||typeof t.params.message!="string")throw new Error("Message must be provided as a string for Solana signMessage RPC");return await jv({message:t.params.message})}async request(t){if(console.debug("EmbeddedSolanaProvider.request() called with args",t),!await he())throw new Error("User must be authenticated to use embedded Solana wallet");if(!await Jv())throw new C("Unable to connect to Solana embedded wallet");switch(t.method){case"signMessage":return await this.handleSignMessage(t);default:throw new Error("Embedded Solana provider does not yet support this RPC method.")}}};var bp="popup-privy-oauth",Ep="PRIVY_OAUTH_USE_BROADCAST_CHANNEL",XA="privy:";function $v(e){return e.startsWith(XA)}async function e0({url:e,popup:t}){return t.location=e,new Promise((o,n)=>{let i=setTimeout(()=>{n(new C("Authorization request timed out after 2 minutes.")),s()},12e4);function s(){t?.close(),window.removeEventListener("message",p)}let l,d=setInterval(()=>{t?.closed&&!l&&(s(),clearInterval(d),clearTimeout(i),n(new C("User rejected request")))},300);function p(m){m.data&&(m.data.type==="PRIVY_OAUTH_RESPONSE"&&m.data.stateCode&&m.data.authorizationCode&&(clearTimeout(i),o(m.data),s()),m.data.type==="PRIVY_OAUTH_ERROR"&&(clearTimeout(i),n(new C(m.data.error)),s()),m.data.type===Ep&&(l=new BroadcastChannel(bp),l.onmessage=p))}window.addEventListener("message",p)})}var ZA="https://cdn.apple-cloudkit.com";async function Pm({url:e,popup:t,provider:r}){return t.location=e,new Promise((n,a)=>{function i(){t?.close(),window.removeEventListener("message",s)}function s(l){l.data&&(l.data.type==="PRIVY_OAUTH_RESPONSE"&&l.data.stateCode&&l.data.authorizationCode&&(n(l.data),i()),l.origin===ZA&&l.data.ckSession&&(n({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:l.data.ckSession}),i()),l.data.type==="PRIVY_OAUTH_ERROR"&&(a(l.data.error),i()))}window.addEventListener("message",s)})}var t0=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});import{jsx as Gr,jsxs as r0}from"react/jsx-runtime";var dn;function ox(e){return typeof e=="string"&&e.length===25}function he(){if(!dn){let e=Z.get(Jn);return Promise.resolve(e||null)}return dn.getAccessToken()}var o0,qh=(e,t,r)=>o0(e,t,r),n0,zh=(e,t,r)=>n0(e,t,r),a0,Kh=(e,t,r,o)=>a0(e,t,r,o),i0,Yh=()=>i0(),s0,Jv=()=>s0(),l0,jv=({message:e})=>l0({message:e}),nx=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;Z.put(as,t);let r=new URL(window.location.href);r.searchParams.delete("privy_token"),window.history.pushState({},"",r)},ax=({config:e,...t})=>{if(typeof window<"u"&&["localhost","127.0.0.1"].indexOf(window.location.hostname)<0&&window.location.protocol!=="https:")throw new C("Embedded wallet is only available over HTTPS");if(!ox(t.appId))throw new C("Cannot initialize the Privy provider with an invalid Privy app ID");dn||(dn=new bs({appId:t.appId,appClientId:t.clientId,apiUrl:t.apiUrl}));let r=Object.assign({},e);return t.createPrivyWalletOnLogin!==void 0&&r.embeddedWallets?.createOnLogin===void 0&&(r.embeddedWallets||(r.embeddedWallets={}),r.embeddedWallets.createOnLogin=t.createPrivyWalletOnLogin?"users-without-wallets":"off"),t.createPrivyWalletOnLogin!==void 0&&e?.embeddedWallets?.createOnLogin&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),Gr(cf,{client:dn,clientConfig:r,legacyCreateEmbeddedWalletFlag:t.createPrivyWalletOnLogin,children:Gr(ix,{...t,client:dn})})},ix=e=>{let t=e.client,[r,o]=ut(!1),[n,a]=ut(!1),[i,s]=ut(!1),[l,d]=ut(null),[p,m]=ut([]),[h,g]=ut([]),[v,w]=ut(null),E=Va(p),[I,A]=ut(!1),[T,P]=ut(null),[S,_]=ut(!1),[D,U]=ut({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:Ht}),[V,H]=ut({status:"initial"}),[Y,K]=ut({status:"initial"}),[O,Q]=ut(null),L=_e(),Ge=Dl(),[pe,X]=ut(!0),[fe,te]=ut({}),[ee,ae]=ut(null),[Je,ot]=ut(null),[ie,mt]=ut(!1),[jt,qr]=ut(!1),[Pe,ue]=ut(L.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),ke=Va(null),se=Va(null),W=Va(mf),[Ce,Tt]=ut(!1);t.onStoreToken=c=>{c&&N(W,"accessToken","onAccessTokenGranted",c)},t.onDeleteToken=()=>{d(null),s(!1),N(W,"accessToken","onAccessTokenRemoved")};let J=Va(null),re=Va(null),sr=Va(!1),Me=c=>{P(c),setTimeout(()=>{o(!0)},15),t.createAnalyticsEvent({eventName:"modal_open",payload:{initialScreen:c}})},wt=c=>{L.embeddedWallets.createOnLogin!=="off"&&X(!0),Me(c)};co(()=>{let c=oa(l);if(!c||!O){w(null);return}let u={type:"solana",imported:!1,address:c.address,connectedAt:Date.now(),walletClientType:"privy",connectorType:"embedded",meta:{name:"Privy Wallet",icon:void 0,id:"io.privy.solana.wallet"},linked:!0,fund:()=>{throw new C("Funding is not supported for Solana embedded wallets.")},unlink:()=>{throw new C("Cannot unlink an embedded Solana wallet")},getProvider:async()=>new wp(O,c.address),signMessage:async f=>{let y=await he();if(!y||!O)throw new C("Must have valid access token and Privy wallet to send transaction","must_be_authenticated");let{response:b}=await O.rpcSolana({accessToken:y,publicKey:u.address,request:{method:"signMessage",params:{message:Buffer.from(f).toString("base64")}}});return Buffer.from(b.data.signature,"base64")},async sendTransaction(f,y,b){let{signature:M}=await Rm({transaction:f,connection:y,transactionOptions:b,wallet:this});return M},signTransaction:async f=>{let y=await he();if(!y||!O)throw new C("Must have valid access token and Privy wallet to send transaction","must_be_authenticated");return await cm({tx:f,accessToken:y,walletProxy:O}),f},loginOrLink:async()=>{throw new C("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{w(null)},isConnected:async()=>!0};w(u)},[O,l]),co(()=>{if(!l){t.connectors?.removeEmbeddedWalletConnectors();return}let c=Be(l),u=Mp(l),f=Ml(l);if((!c||!u.length)&&t.connectors?.removeEmbeddedWalletConnectors(),f||t.connectors?.removeImportedWalletConnector(),!t.connectors){console.debug("Failed to add embedded wallet connector: Client connectors not initialized");return}if(!O){console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized");return}c&&t.connectors.addEmbeddedWalletConnectors({walletProxy:O,rootWallet:c,embeddedWallets:u,defaultChain:L.defaultChain,appId:e.appId}),f&&t.connectors.addImportedWalletConnector(O,f.address,L.defaultChain,e.appId)},[O,l]),co(()=>{O&&Je?.(O)},[O]),co(()=>{(async()=>{if(!L.customAuth?.enabled){ue({status:"not-enabled"});return}X(!0),ue({status:"loading"});let{getCustomAccessToken:u,isLoading:f}=L.customAuth;if(!(!n||f))try{let y=await u();if(!y&&i){await qa.logout(),ue({status:"done"}),N(W,"customAuth","onUnauthenticated");return}if(!y){ue({status:"done"});return}if(i){ue({status:"done"});return}t.startAuthFlow(new Ja(y));let{user:b,isNewUser:M}=await t.authenticate();if(!b){await qa.logout(),ue({status:"error",error:new C("Failed to sync with custom auth provider")}),N(W,"customAuth","onUnauthenticated");return}M!==void 0&&N(W,"login","onComplete",b,M,!1,"custom",null),N(W,"customAuth","onAuthenticated",{user:b}),ue({status:"done"}),d(b||null),A(M||!1),s(!0),qr(!0)}catch(y){throw console.warn(y),i&&(await qa.logout(),N(W,"customAuth","onUnauthenticated")),N(W,"login","onError",y.privyErrorCode||"unknown_auth_error"),ue({status:"error",error:y}),y}})()},[L.customAuth?.enabled,L.customAuth?.getCustomAccessToken,L.customAuth?.isLoading,n,i]),co(()=>{jt&&O&&l&&It(l,L.embeddedWallets.createOnLogin)&&(qr(!1),Tp(l,Ka).catch(console.error))},[jt&&O&&l]),co(()=>{if(L.externalWallets.solana.connectors)return L.externalWallets.solana.connectors.onMount(),()=>L.externalWallets.solana.connectors?.onUnmount()},[L.externalWallets.solana.connectors]),co(()=>{async function c(){let u=We(),f=lr();nx();let y=JA();t.initializeConnectorManager({walletConnectCloudProjectId:L.walletConnectCloudProjectId,rpcConfig:L.rpcConfig,chains:L.chains,defaultChain:L.defaultChain,store:y,walletList:L.appearance.walletList,shouldEnforceDefaultChainOnConnect:L.shouldEnforceDefaultChainOnConnect,externalWalletConfig:L.externalWallets,appName:L.name??"Privy"});let b;t.connectors?.on("connectorInitialized",()=>{b&&clearTimeout(b);let q=t.connectors.walletConnectors.length,ne=t.connectors.walletConnectors.reduce((me,Ae)=>me+(Ae.initialized?1:0),0);ne===q?Tt(!0):b=setTimeout(()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:ne,expected:q}),Tt(!0)},1500)}),t.connectors?.initialize().then(()=>{Ga()});let M=await t.getAuthenticatedUser(),G=!!M;if(L.customAuth?.enabled||(s(!!M),M&&N(W,"login","onComplete",M,!1,!0,null,null),d(M)),u){re.current=G?"link":"login";return}if(f&&!G){re.current="login",wt("TELEGRAM_AUTH_SCREEN");return}oe.setReadyToTrue(!!M)}!n&&Ge&&c()},[t,ee,n,Ge]),co(()=>{if(!n)return;if(!l){mt(!0);return}if(!!!l.linkedAccounts.find(f=>f.type==="wallet"&&f.walletClientType==="privy")){mt(!0);return}let u=!!p.find(f=>f.walletClientType==="privy");mt(u)},[n,l,p]);let We=()=>{let c=hs();if(c.inProgress&&c.popupFlow){if(window.opener.location.origin!==window.location.origin){window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."});return}if(c.authorizationCode==="error"){window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."});return}window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:c.stateCode,authorizationCode:c.authorizationCode});return}return c.inProgress&&$v(c.provider)&&!c.popupFlow&&(new BroadcastChannel(bp).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:c.stateCode,authorizationCode:c.authorizationCode}),window.close()),!c.inProgress||c.headless?!1:(t.startAuthFlow(new Ro(c)),wt("AWAITING_OAUTH_SCREEN"),!0)},lr=()=>{let c=Hh();if(!c||!L.loginMethods.telegram||!L.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let u=new ti;return t.startAuthFlow(u),c.flowType==="login-url"&&(u.meta.telegramWebAppData=void 0,u.meta.telegramAuthResult={id:c.id,first_name:c.first_name,last_name:c.last_name,auth_date:c.auth_date,username:c.username,photo_url:c.photo_url,hash:c.hash}),c.flowType==="web-app"&&(u.meta.telegramAuthResult=void 0,u.meta.telegramWebAppData={query_id:c.query_id,user:c.user,auth_date:c.auth_date,hash:c.hash,chat_instance:c.chat_instance,chat_type:c.chat_type,start_param:c.start_param}),!0},Ar=async(c,u,f,y)=>{let b=await t.connectors?.createEthereumWalletConnector(c,u)||null;cr(b,u,f,y)};async function cr(c,u,f,y){if(c)U({status:"disconnected",connectedWallet:null,connectError:null,connector:c,connectRetry:Ht});else return U({status:"disconnected",connectedWallet:null,connectError:new Le("Unable to connect to wallet."),connector:null,connectRetry:Ht}),y?.(null,f);c instanceof ho&&u&&await c.resetConnection(u),U({connector:c,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>cr(c,u,f,y)});try{let b=await c.connect({showPrompt:!0});if((!b||fo(b))&&L.shouldEnforceDefaultChainOnConnect&&!L.chains.find(M=>M.id===Number(b?.chainId.replace("eip155:","")))&&!(b?.connectorType==="wallet_connect_v2"&&b?.walletClientType==="metamask")){U(M=>({...M,connector:c,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:Ht}));try{await b?.switchChain(L.defaultChain.id),b&&(b.chainId=za(Zn(L.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${L.defaultChain.id}`)}}return U(M=>({...M,status:"connected",connectedWallet:b,connectError:null,connectRetry:Ht})),b&&N(W,"connectWallet","onSuccess",b),y?.(b,f)}catch(b){return b instanceof pr?(console.warn(b.cause?b.cause:b.message),N(W,"connectWallet","onError",b.privyErrorCode||"generic_connect_wallet_error")):(console.warn(b),N(W,"connectWallet","onError","unknown_connect_wallet_error")),U(M=>({...M,status:"disconnected",connectedWallet:null,connectError:b})),y?.(null,f)}}let Rt=async(c,u,f)=>{if(c===null||!fo(c))return;let y=new Jo(c,t,u,f);t.startAuthFlow(y)},zr=async(c,u)=>{if(c===null||!Dp(c))return;let f=new sa(c,t,u);t.startAuthFlow(f)},Ga=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_connector"),f=c.get("privy_wallet_client");if(!u||!f)return;if(f==="phantom"&&!un()&&wt("LOGIN_FAILED_SCREEN"),!t.connectors)throw new C("Connector not initialized");Me("AWAITING_CONNECTION");let y=new URL(window.location.href);y.searchParams.delete("privy_connector"),y.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",y),Ar(u,f,void 0,Rt)};co(()=>{n&&i&&l===null&&t.getAuthenticatedUser().then(d)},[n,i,l,t]);let je=c=>{if(!i)throw N(W,"linkAccount","onError","must_be_authenticated",{linkMethod:c}),new C("User must be authenticated before linking an account.")},nt=()=>{je("siwe"),J.current="siwe",re.current="link",Me("LINK_WALLET_SCREEN")},Cl=c=>{if(!i||!l)return!1;if(c.walletClientType==="privy")return!0;for(let u of l.linkedAccounts)if(u.type==="wallet"&&u.address===c.address&&u.walletClientType!=="privy")return!0;return!1},xm=async c=>{if(!t.connectors)throw new C("Connector not initialized");let u;if(c.type==="ethereum"?u=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null:u=t.connectors.findSolanaWalletConnector(c.connectorType,c.walletClientType)||null,U(f=>({...f,connector:u,status:"connected",connectedWallet:c,connectError:null,connectRetry:Ht})),L.captchaEnabled&&!i){let f={callback:y=>fo(c)?Rt(c,y):zr(c,y),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"};te({captchaModalData:f}),wt("CAPTCHA_SCREEN")}else fo(c)?await Rt(c):await zr(c),wt("AWAITING_CONNECTION")},f0=async(c,u)=>{let{signedUrl:f,externalTransactionId:y}=await I2(t,c,u??{},L.appearance.palette,L.fundingMethodConfig?.moonpay.useSandbox??!1);return{signedUrl:f,externalTransactionId:y}},vl=()=>{m(c=>{let u=t.connectors?.wallets.filter(fo).map(f=>({...f,linked:Cl(f),loginOrLink:async()=>{if(!await f.isConnected())throw new C("Wallet is not connected");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new C("Cannot link or login with embedded wallet");xm(f)},fund:async y=>{await oe.fundWallet(f.address,y)},unlink:async()=>{if(!i)throw new C("User is not authenticated.");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new C("Cannot unlink an embedded wallet");let y=await t.unlinkEthereumWallet(f.address);d(y)}}))||[];return gs(c,u)?c:u}),g(c=>{let u=t.connectors?.wallets.filter(Dp).map(f=>({...f,linked:Cl(f),loginOrLink:async()=>{if(!await f.isConnected())throw new C("Wallet is not connected");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new C("Cannot link or login with embedded wallet");xm(f)},fund:async y=>{throw new C("Funding not supported for Solana wallets")},unlink:async()=>{if(!i)throw new C("User is not authenticated.");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new C("Cannot unlink an embedded wallet");let y=await t.unlinkSolanaWallet(f.address);d(y)}}))||[];return gs(c,u)?c:u})};co(()=>{vl()},[l?.linkedAccounts,i,n]),co(()=>{if(n){if(!t.connectors)throw new C("Connector not initialized");vl(),t.connectors.on("walletsUpdated",vl)}},[n]);let h0=c=>{c&&"target"in c&&c&&(c=void 0),te({externalConnectWallet:{walletList:c?.walletList&&c?.walletList.length>0?c.walletList:void 0,suggestedAddress:c?.suggestedAddress}}),Me(i?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};co(()=>{if(!p[0])return;let c=p[0],u=E.current.find(y=>y.address===c.address),f;if(c.walletClientType==="privy"?f=l?.linkedAccounts.find(y=>y.type==="wallet"&&y.address===c.address&&y.walletClientType==="privy"):f=l?.linkedAccounts.find(y=>y.type==="wallet"&&y.address===c.address&&y.walletClientType!=="privy"),!u&&f){let y=Object.assign({},l);y.wallet=f&&{address:f.address,chainType:f.chainType,chainId:f.chainId,walletClient:f.walletClient,walletClientType:f.walletClientType,connectorType:f.connectorType,imported:f.imported,walletIndex:f.walletIndex},d(y)}E.current=p},[p]);let Tp=async(c,u,f)=>{let y=Be(c);if(y&&!f?.createAdditional)throw N(W,"createWallet","onError","embedded_wallet_already_exists"),new Error("User already has an embedded wallet.");let[b,M]=await Promise.all([oe.initializeWalletProxy(u),he()]);if(!b&&L.customAuth?.enabled)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!b||!M||L.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return new Promise((G,q)=>{X(!0),te({createWallet:{onSuccess:me=>{N(W,"createWallet","onSuccess",me),G(me)},onFailure:me=>{N(W,"createWallet","onError","unknown_embedded_wallet_error"),q(me)},callAuthOnSuccessOnClose:!1}}),Me("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{if(!y)await b.create({accessToken:M});else{let ne=Mp(c),Ae=(ne?.length?Math.max(...ne.map(Re=>Re.walletIndex)):y.walletIndex)+1;await oe.recoverEmbeddedEthereumWallet(),await b.createAdditional({accessToken:M,primaryWalletAddress:y?.address,hdWalletIndex:Ae})}let G=await oe.refreshUser(),q=Be(G);if(!q)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return N(W,"createWallet","onSuccess",q),q}},y0=c=>{if(!L.chains.map(u=>u.id).includes(c))throw new Le(`Chain ID ${c} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},km=(c,u,f,y)=>new Promise(async(b,M)=>{let{requesterAppId:G}=u||{};if(!i||!l){N(W,"sendTransaction","onError","must_be_authenticated"),M(new Error("User must be authenticated before signing with a Privy wallet"));return}let q=y??Be(l)?.address;if(!q)throw new C("User must have an embedded wallet to send a transaction.");let{signingWallet:ne,rootWallet:me}=Wl(l,q);if(!me||!ne){N(W,"sendTransaction","onError","embedded_wallet_not_found"),M(new Error("Must have a Privy wallet before signing"));return}X(!0);let Ae=Mm.wallets.find(Bt=>Bt.walletClientType==="privy"&&Ha(Bt.address)===Ha(ne.address)),Re=await Ae?.getEthereumProvider();if(!Ae||!Re)throw new C(`Cannot sendTransaction before embedded wallet ${ne.address} is connected`);let Ft=c.chainId?Number(c.chainId):Fl(Ae.chainId);y0(Ft);let _t=Object.assign({},c,{chainId:Ft}),ft=async()=>{let Bt=await he();if(!Bt||!O){N(W,"sendTransaction","onError","embedded_wallet_not_found"),M(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await oe.recoverEmbeddedEthereumWallet()){N(W,"sendTransaction","onError","unknown_connect_wallet_error"),M(new Error("Unable to connect to wallet"));return}let pn=Kr(_t.chainId,L.chains,L.rpcConfig,{appId:e.appId}),po=await rx(ne.address,_t,pn);if(L.embeddedWallets.noPromptOnSignature||sr.current){let{totalGasEstimate:g0}=await tx(po,pn),{hasSufficientFunds:C0}=await hp(ne.address,po,g0,pn);if(!C0)throw new Wt(new Jr("Wallet has insufficient funds for this transaction.",ex.E32603_DEFAULT_INTERNAL_ERROR.eipCode))}let El=await fp({accessToken:Bt,rootWallet:me,transactingWallet:ne,walletProxy:O,transactionRequest:po,provider:pn,requesterAppId:G});N(W,"sendTransaction","onSuccess",El),b(El)}catch(Qn){N(W,"sendTransaction","onError","transaction_failure"),M(Qn)}};if(L.embeddedWallets.noPromptOnSignature||sr.current)u&&L.embeddedWallets.noPromptOnSignature&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),ft();else{let Bt={transactionRequest:_t,transactingWallet:ne,rootWallet:me,onSuccess:po=>{N(W,"sendTransaction","onSuccess",po),b(po)},onFailure:po=>{N(W,"sendTransaction","onError","transaction_failure"),M(po)},uiOptions:u||{},fundWalletConfig:f,requesterAppId:G},Qn={address:me.address,onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:po=>{N(W,"sendTransaction","onError","unknown_connect_wallet_error"),M(po)}},pn=um({address:ne.address,appConfig:L,fundWalletConfig:f,chainIdOverride:_t.chainId,comingFromSendTransactionScreen:!0});te({connectWallet:Qn,sendTransaction:Bt,funding:pn}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),Rm=({transaction:c,connection:u,transactionOptions:f,uiOptions:y,wallet:b})=>new Promise(async(M,G)=>{let{requesterAppId:q}=y||{};if(!i||!l){N(W,"sendSolanaTransaction","onError","must_be_authenticated"),G(new C("User must be authenticated before signing with a Privy wallet","must_be_authenticated"));return}let ne=b?l.linkedAccounts.find(Ft=>Ft.type==="wallet"&&Ft.address===b.address):oa(l);if(!ne){N(W,"sendSolanaTransaction","onError","embedded_wallet_not_found"),G(new C("Must have a Privy wallet before signing","embedded_wallet_not_found"));return}X(!0);let me=b??v,Ae=await me?.isConnected();if(!me||!Ae)throw N(W,"sendSolanaTransaction","onError","embedded_wallet_not_found"),new C(`Cannot sendSolanaTransaction before embedded wallet ${ne.address} is connected`,"embedded_wallet_not_found");let Re=async()=>{let Ft=await he();if(!Ft||!O){N(W,"sendSolanaTransaction","onError","embedded_wallet_not_found"),G(new C("Must have valid access token and Privy wallet to send transaction","embedded_wallet_not_found"));return}try{if(!await oe.recoverEmbeddedSolanaWallet()){N(W,"sendSolanaTransaction","onError","unknown_connect_wallet_error"),G(new C("Unable to connect to wallet","unknown_connect_wallet_error"));return}if(L.embeddedWallets.noPromptOnSignature){let{instructions:pn}=await Zd(c,u);pn.every(El=>El.hasFunds)||(N(W,"sendSolanaTransaction","onError","insufficient_balance"),G(new C("Solana wallet has insufficient funds for this transaction.","insufficient_balance")))}let{signature:ft,receipt:Bt}=await dp({accessToken:Ft,tx:c,connection:u,walletProxy:O,transactionOptions:f}),Qn=Xd(ft,Bt);N(W,"sendSolanaTransaction","onSuccess",Qn),M(Qn)}catch(_t){N(W,"sendSolanaTransaction","onError","transaction_failure"),G(_t)}};if(L.embeddedWallets.noPromptOnSignature)y&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),Re();else{let Ft={transactionRequest:c,connection:u,transactionOptions:f,transactingWallet:ne,onSuccess:ft=>{N(W,"sendSolanaTransaction","onSuccess",ft),M(ft)},onFailure:ft=>{N(W,"sendSolanaTransaction","onError","transaction_failure"),G(ft)},uiOptions:y||{},requesterAppId:q},_t={address:ne.address,onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN",onFailure:ft=>{N(W,"sendSolanaTransaction","onError","unknown_connect_wallet_error"),G(ft)}};te({connectWallet:_t,sendSolanaTransaction:Ft,funding:void 0}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}});function _m(){return new Promise(async(c,u)=>{let f=await he();if(!f||!O)throw new Error("Must have valid access token to enroll in MFA");try{await O.verifyMfa({accessToken:f}),c()}catch(y){u(y)}})}let wl=c=>c?.linkedAccounts.filter(u=>u.latestVerifiedAt!==null&&!(u.type==="wallet"&&u.walletClientType==="privy")).sort((u,f)=>f.latestVerifiedAt.getTime()-u.latestVerifiedAt.getTime())[0],dr=c=>{let u=l?.linkedAccounts.filter(b=>b.type===c).length??0,{displayName:f,loginMethod:y}=Nn(c);if(c==="passkey"&&u>=5||c!=="passkey"&&u>=1)throw N(W,"linkAccount","onError","cannot_link_more_of_type",{linkMethod:y}),new C(`User already has an account of type ${f} linked.`)};async function Im({showAutomaticRecovery:c=!1,legacySetWalletPasswordFlow:u=!1}){P(null);let f=u?"setWalletPassword":"setWalletRecovery";if(!i||!l)throw N(W,f,"onError","must_be_authenticated"),new Error("User must be authenticated before adding recovery method to Privy wallet");let y=Be(l);if(!y||!O)throw N(W,f,"onError","embedded_wallet_not_found"),new Error("Must have a Privy wallet to add a recovery method");if(oa(l))throw new Error("Cannot set user-controlled recovery for user with Solana.");try{await _m()}catch(M){throw N(W,f,"onError","missing_or_invalid_mfa"),M}return new Promise((M,G)=>{X(!0);let q={onSuccess:Re=>{N(W,f,"onSuccess","user-passcode",Re),M(Re)},onFailure:Re=>{N(W,f,"onError","user_exited_set_password_flow"),G(Re)},callAuthOnSuccessOnClose:!1},ne=y.recoveryMethod==="user-passcode",Ae={onCompleteNavigateTo:Qc({walletAction:"update",availableRecoveryMethods:L.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:u,isResettingPassword:ne,showAutomaticRecovery:c}),shouldForceMFA:!1,onFailure:Re=>{N(W,f,"onError","unknown_connect_wallet_error"),G(Re)}};te({setWalletPassword:q,createWallet:q,connectWallet:Ae,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:ne}}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")})}async function bl({appId:c,action:u}){let f=await he();if(u==="link"&&!f)throw N(W,"linkAccount","onError","must_be_authenticated",{linkMethod:`privy:${c}`}),new C("User must be authenticated before linking an account.");if(u==="login"&&f)throw N(W,"login","onError","unknown_auth_error"),new C("Attempted to log in, but user is already logged in. Use a `link` helper instead.");J.current=`privy:${c}`,re.current=u;let y=window.open(void 0,void 0,Qs({w:440,h:680}));return t.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:c}}),new Promise(async(b,M)=>{let{name:G,logoUrl:q}=await vd({api:t.api,providerAppId:c,requesterAppId:L.id});te({crossAppAuth:{appId:c,name:G,logoUrl:q,action:u,popup:y,onSuccess:b,onError:M}}),wt("CROSS_APP_AUTH_SCREEN")})}let qa={ready:n,authenticated:i,user:l,walletConnectors:t.connectors||null,connectWallet:h0,importWallet:async({privateKey:c})=>{je("siwe");let[u,f]=await Promise.all([oe.initializeWalletProxy(15e3),he()]);if(u&&f){await u.import({privateKey:c,accessToken:f});let y=await oe.refreshUser(),b=Ml(y);if(!b)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to import wallet");return N(W,"createWallet","onSuccess",b),b}else throw new C("User is not authenticated")},linkWallet:nt,startCrossAppAuthFlow:bl,linkEmail:()=>{je("email"),dr("email"),J.current="email",re.current="link",Me("LINK_EMAIL_SCREEN")},linkPhone:()=>{je("sms"),dr("phone"),J.current="sms",re.current="link",Me("LINK_PHONE_SCREEN")},linkGoogle:async()=>{je("google"),dr("google_oauth"),re.current="link",await oe.initLoginWithOAuth("google")},linkTwitter:async()=>{je("twitter"),dr("twitter_oauth"),re.current="link",await oe.initLoginWithOAuth("twitter")},linkDiscord:async()=>{je("discord"),dr("discord_oauth"),re.current="link",await oe.initLoginWithOAuth("discord")},linkGithub:async()=>{je("github"),dr("github_oauth"),re.current="link",await oe.initLoginWithOAuth("github")},linkSpotify:async()=>{je("spotify"),dr("spotify_oauth"),re.current="link",await oe.initLoginWithOAuth("spotify")},linkInstagram:async()=>{je("instagram"),dr("instagram_oauth"),re.current="link",await oe.initLoginWithOAuth("instagram")},linkTiktok:async()=>{je("tiktok"),dr("tiktok_oauth"),re.current="link",await oe.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{je("linkedin"),dr("linkedin_oauth"),re.current="link",await oe.initLoginWithOAuth("linkedin")},linkApple:async()=>{je("apple"),dr("apple_oauth"),re.current="link",await oe.initLoginWithOAuth("apple")},linkPasskey:async()=>{je("passkey"),dr("passkey"),await oe.initLinkWithPasskey(),Me("LINK_PASSKEY_SCREEN")},linkTelegram:async()=>{je("telegram"),dr("telegram"),re.current="link",J.current="telegram",await oe.initLoginWithTelegram(),Me("TELEGRAM_AUTH_SCREEN")},linkFarcaster:async()=>{je("farcaster"),dr("farcaster"),await oe.initLoginWithFarcaster(),re.current="link",J.current="farcaster",Me("AWAITING_FARCASTER_CONNECTION")},updateEmail:()=>{if(je("email"),!l?.email)throw new C("User does not have an email linked to their account.");re.current="link",J.current="email",Me("UPDATE_EMAIL_SCREEN")},updatePhone:()=>{if(je("sms"),!l?.phone)throw new C("User does not have a phone number linked to their account.");re.current="link",J.current="sms",Me("UPDATE_PHONE_SCREEN")},login:async c=>{c&&"target"in c&&c&&(c=void 0);let u="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!n){let f=await new Promise(y=>{ae(b=>y.bind(b))});if(ae(null),f){console.warn(u);return}}if(l&&!l.isGuest){console.warn(u);return}re.current="login",te({login:c}),wt("LANDING")},connectOrCreateWallet:async()=>{if(n||(await new Promise(c=>{ae(()=>c)}),ae(null)),i){console.warn("User must be unauthenticated to `connectOrCreateWallet`");return}wt("CONNECT_OR_CREATE")},logout:async()=>{if(l&&t.clearProviderAcccessTokens(l),P(null),await t.logout(),l&&O)try{await O.clearMfa({userId:l.id})}catch{}d(null),s(!1),N(W,"logout","onSuccess"),re.current=null,J.current=null,o(!1),Z.del(is),Z.del(_l(L.id))},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{if(!l||!l.wallet)return new st;let c=p.find(f=>l.wallet&&f.address===l.wallet.address),u=t.connectors?.walletConnectors.find(f=>f.wallets.find(y=>y.address===c?.address));return!c||!u?new st:u.proxyProvider},getEthersProvider:()=>{if(!l||!l.wallet)return new Am(new Io(new st));let c=p.find(f=>l.wallet&&f.address===l.wallet.address),u=t.connectors?.walletConnectors.find(f=>f.wallets.find(y=>y.address===c?.address));return!c||!u?new Am(new Io(new st)):new Am(new Io(u.proxyProvider))},getWeb3jsProvider:()=>{if(!l||!l.wallet)return new yn(new st);let c=p.find(f=>l.wallet&&f.address===l.wallet.address),u=t.connectors?.walletConnectors.find(f=>f.wallets.find(y=>y.address===c?.address));return!c||!u?new yn(new st):new yn(u.proxyProvider)},unlinkWallet:async c=>{let u;return c.startsWith("0x")?u=await t.unlinkEthereumWallet(c):u=await t.unlinkSolanaWallet(c),d(u),u},unlinkEmail:async c=>{let u=await t.unlinkEmail(c);return d(u),u},unlinkPhone:async c=>{let u=await t.unlinkPhone(c);return d(u),u},unlinkGoogle:async c=>{let u=await t.unlinkOAuth("google",c);return d(u),u},unlinkTwitter:async c=>{let u=await t.unlinkOAuth("twitter",c);return d(u),u},unlinkDiscord:async c=>{let u=await t.unlinkOAuth("discord",c);return d(u),u},unlinkGithub:async c=>{let u=await t.unlinkOAuth("github",c);return d(u),u},unlinkSpotify:async c=>{let u=await t.unlinkOAuth("spotify",c);return d(u),u},unlinkInstagram:async c=>{let u=await t.unlinkOAuth("instagram",c);return d(u),u},unlinkTiktok:async c=>{let u=await t.unlinkOAuth("tiktok",c);return d(u),u},unlinkLinkedIn:async c=>{let u=await t.unlinkOAuth("linkedin",c);return d(u),u},unlinkApple:async c=>{let u=await t.unlinkOAuth("apple",c);return d(u),u},unlinkFarcaster:async c=>{let u=await t.unlinkFarcaster(c);return d(u),u},unlinkTelegram:async c=>{let u=await t.unlinkTelegram(c);return d(u),u},unlinkPasskey:async c=>{let u=await t.unlinkPasskey(c);return d(u),u},unlinkCrossAppAccount:async({subject:c})=>{let u=l?.linkedAccounts.find(y=>y.type==="cross_app"&&y.subject===c)?.providerApp;if(!u)throw new C("Invalid subject");t.storeProviderAccessToken(u.id,null);let f=await t.unlinkOAuth(`privy:${u.id}`,c);return d(f),f},setActiveWallet:async c=>{let u=p.find(y=>Ha(y.address)===Ha(c)),f=l?.linkedAccounts.find(y=>y.type==="wallet"&&Ha(y.address)===Ha(c));if(!u||!await u.isConnected())te({externalConnectWallet:{suggestedAddress:c}}),nt();else if(!u.linked)u.loginOrLink();else{let y=Object.assign({},l);y.wallet=f&&{address:f.address,chainType:f.chainType,chainId:f.chainId,walletClient:f.walletClient,walletClientType:f.walletClientType,connectorType:f.connectorType,imported:f.imported,walletIndex:f.walletIndex},d(y)}},forkSession:()=>t.forkSession(),createWallet:async c=>{if(c&&"target"in c&&c&&(c=void 0),!i||!l)throw N(W,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return Tp(l,15e3,c)},setWalletRecovery:async c=>Im({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:c?.showAutomaticRecovery??!1}),setWalletPassword:async()=>Im({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(c,u,f)=>new Promise(async(y,b)=>{let{requesterAppId:M}=u||{};if(!i||!l){N(W,"signMessage","onError","must_be_authenticated"),b(new Error("User must be authenticated before signing with a Privy wallet"));return}let G=f??Be(l)?.address;if(!G)throw new C("User must have an embedded wallet to sign a message.");let{signingWallet:q,rootWallet:ne}=Wl(l,G);if(!q||!ne){N(W,"signMessage","onError","embedded_wallet_not_found"),b(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){N(W,"signMessage","onError","invalid_message"),b(new Error("Message must be a non-empty string"));return}X(!0);let me=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let Ae=await he();if(!O||!Ae)throw new Error("Unable to connect to wallet");if(!await oe.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:q.address,requesterAppId:M}});let{response:Ft}=await O.rpc({accessToken:Ae,address:ne.address,hdWalletIndex:q.walletIndex??void 0,requesterAppId:M,request:{method:"personal_sign",params:[c,q.address]}}),_t=Ft.data;return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:q.address,requesterAppId:M}}),_t};if(L.embeddedWallets.noPromptOnSignature||sr.current){u&&L.embeddedWallets.noPromptOnSignature&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let Ae=await me();N(W,"signMessage","onSuccess",Ae),y(Ae)}catch(Ae){N(W,"signMessage","onError","unable_to_sign"),b(Ae??new Wt("Unable to sign message"))}}else{let Ft={method:"personal_sign",data:c,confirmAndSign:me,onSuccess:ft=>{N(W,"signMessage","onSuccess",ft),y(ft)},onFailure:ft=>{N(W,"signMessage","onError","unable_to_sign"),b(ft)},uiOptions:u||{}},_t={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:ft=>{N(W,"signMessage","onError","unknown_connect_wallet_error"),b(ft)},address:ne.address};te({signMessage:Ft,connectWallet:_t}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),signTypedData:(c,u,f)=>new Promise(async(y,b)=>{let{requesterAppId:M}=u||{};if(!i||!l){N(W,"signTypedData","onError","must_be_authenticated"),b(new Error("User must be authenticated before signing with a Privy wallet"));return}let G=f??Be(l)?.address;if(!G)throw new C("User must have an embedded wallet to sign a message.");let{signingWallet:q,rootWallet:ne}=Wl(l,G);if(!ne||!q){N(W,"signTypedData","onError","embedded_wallet_not_found"),b(new Error("Must have a Privy wallet before signing"));return}X(!0);let me=ns(c),Ae=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let Re=await he();if(!O||!Re)throw new Error("Unable to connect to wallet");if(!await oe.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:q.address,requesterAppId:M}});let{response:_t}=await O.rpc({accessToken:Re,address:ne.address,hdWalletIndex:q.walletIndex??void 0,requesterAppId:M,request:{method:"eth_signTypedData_v4",params:[q.address,me]}}),ft=_t.data;return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:q.address,requesterAppId:M}}),ft};if(sr.current||L.embeddedWallets.noPromptOnSignature||(L.legacyWalletUiConfig??!1)){u&&L.embeddedWallets.noPromptOnSignature&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let Re=await Ae();N(W,"signTypedData","onSuccess",Re),y(Re)}catch(Re){N(W,"signTypedData","onError","unable_to_sign"),b(Re??new Wt("Unable to sign message"))}}else{let _t={method:"eth_signTypedData_v4",data:me,confirmAndSign:Ae,onSuccess:Bt=>{N(W,"signTypedData","onSuccess",Bt),y(Bt)},onFailure:Bt=>{N(W,"signTypedData","onError","unable_to_sign"),b(Bt)},uiOptions:u||{}},ft={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Bt=>{N(W,"signMessage","onError","unknown_connect_wallet_error"),b(Bt)}};te({signMessage:_t,connectWallet:ft}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:async(c,u,f,y)=>{let M=await(await km(c,u,f,y)).wait();return yp(M)},sendSolanaTransaction:async(c,u,f,y)=>await Rm({transaction:c,connection:u,transactionOptions:y,uiOptions:f,wallet:v??void 0}),exportWallet:c=>new Promise(async(u,f)=>{if(!i||!l){f(new Error("User must be authenticated before exporting their Privy wallet"));return}c&&"target"in c&&c&&(c=void 0);let y=c?.address,b=l.linkedAccounts.filter(me=>me.type==="wallet"&&me.walletClientType==="privy"&&me.chainType==="ethereum"),M=y?b.find(me=>me.address===Ha(y)):b.find(me=>!me.imported)||b[0];if(!M){f(new Error("Must have a Privy wallet before exporting"));return}X(!0);let G={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:f,address:M.address,shouldForceMFA:!0};if(te(fe),!await he()||!O){f(new Error("Must have valid access token to enroll in MFA"));return}if(!O){f(new Error("Must have a Privy wallet before exporting"));return}let ne={appId:e.appId,appClientId:e.clientId,origin:t.apiUrl,wallet:M,onSuccess:u,onFailure:f};te({keyExport:ne,connectWallet:G}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}),promptMfa:_m,async init(c){switch(c){case"sms":await t.initMfaSmsVerification();return;case"passkey":return await t.initMfaPasskeyVerification();case"totp":return;default:throw new Error(`Unsupported MFA method: ${c}`)}},async submit(c,u){switch(c){case"totp":case"sms":if(typeof u!="string")throw new C("Invalid MFA code");ke.current?.resolve({mfaMethod:c,mfaCode:u,relyingParty:window.origin}),await new Promise((M,G)=>{se.current={resolve:M,reject:G}});break;case"passkey":if(typeof u=="string")throw new C("Invalid authenticator response");let y=await(await import("@simplewebauthn/browser")).startAuthentication(u),b=t0(y);ke.current?.resolve({mfaMethod:c,mfaCode:b,relyingParty:window.origin}),await new Promise((M,G)=>{se.current={resolve:M,reject:G}});break;default:throw ke.current?.reject(new C("Unsupported MFA method")),new C(`Unsupported MFA method: ${c}`)}},cancel(){ke.current?.reject(new C("MFA canceled"))},async initEnrollmentWithSms(c){let u=await he();if(!u||!O)throw new Error("Must have valid access token to enroll in MFA");await O.initEnrollMfa({method:"sms",accessToken:u,phoneNumber:c.phoneNumber})},enrollInMfa(c){return new Promise((u,f)=>{if(!c){oe.closePrivyModal(),u();return}L.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."),te({mfaEnrollmentFlow:{mfaMethods:L.mfa.methods,onSuccess:u,onFailure:f}}),Me("MFA_ENROLLMENT_FLOW_SCREEN")})},async initEnrollmentWithTotp(){let c=await he();if(!c||!O)throw new Error("Must have valid access token to enroll in MFA");let u=await O.initEnrollMfa({method:"totp",accessToken:c});return{secret:u.secret,authUrl:u.authUrl}},async submitEnrollmentWithSms(c){let u=await he();if(!u||!O)throw new Error("Must have valid access token to enroll in MFA");await O.submitEnrollMfa({method:"sms",accessToken:u,phoneNumber:c.phoneNumber,code:c.mfaCode});let f=await t.getAuthenticatedUser();d(f)},async submitEnrollmentWithTotp(c){let u=await he();if(!u||!O)throw new Error("Must have valid access token to enroll in MFA");await O.submitEnrollMfa({method:"totp",accessToken:u,code:c.mfaCode});let f=await t.getAuthenticatedUser();d(f)},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:c}){let u=await he();if(!u||!O)throw new Error("Must have valid access token to enroll in MFA");await O.submitEnrollMfa({method:"passkey",accessToken:u,credentialIds:c});let f=await t.getAuthenticatedUser();d(f)},async unenroll(c){let u=await he();if(!u||!O)throw new Error("Must have valid access token to remove MFA");c==="passkey"?await O.submitEnrollMfa({method:"passkey",accessToken:u,credentialIds:[]}):await O.unenrollMfa({method:c,accessToken:u});let f=await t.getAuthenticatedUser();d(f)},requestFarcasterSignerFromWarpcast:async()=>{let c=await he(),u=l?.linkedAccounts.find(b=>b.type==="wallet"&&b.walletClientType==="privy");if(!c)throw new Error("Must have valid access token to connect with Farcaster");if(!O||!u)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!l?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await oe.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");let y=await O.initFarcasterSigner({address:u.address,hdWalletIndex:null,accessToken:c,mfaCode:null,mfaMethod:null,relyingParty:window.origin});if(y.status==="approved"){let b=await t.getAuthenticatedUser();d(b||l||null)}te({farcasterSigner:y}),Me("AWAITING_FARCASTER_SIGNER")},getFarcasterSignerPublicKey:async()=>{let c=await he(),u=l?.linkedAccounts.find(b=>b.type==="wallet"&&b.walletClientType==="privy");if(!c)throw new Error("Must have valid access token to connect with Farcaster");if(!O||!u)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!l?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await oe.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");if(!l.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster signer public key to sign");return(b=>Uint8Array.from(b.match(/.{1,2}/g).map(M=>parseInt(M,16))))(l.farcaster.signerPublicKey.slice(2))},signFarcasterMessage:async c=>{let u=await he(),f=l?.linkedAccounts.find(G=>G.type==="wallet"&&G.walletClientType==="privy");if(!u)throw new Error("Must have valid access token to connect with Farcaster");if(!O||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!l?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await oe.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");if(!l.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster signer public key to sign");let b=await import("@simplewebauthn/browser"),M=await O.signFarcasterMessage({address:f.address,hdWalletIndex:null,accessToken:u,mfaCode:null,mfaMethod:null,payload:{hash:b.bufferToBase64URLString(c)},fid:BigInt(l.farcaster.fid),relyingParty:window.origin});return new Uint8Array(b.base64URLStringToBuffer(M.signature))},createGuestAccount:async()=>{if(l&&!l.isGuest)throw new Error("User cannot already be authenticated to create a guest account");return l?.isGuest?l:oe.loginWithGuestAccountFlow()},isHeadlessOAuthLoading:S,loginWithCode(c){return oe.loginWithCode(c)},initLoginWithEmail(c){return oe.initLoginWithEmail(c)},initLoginWithSms(c){return oe.initLoginWithSms(c)},otpState:V,fundWallet(c,u){return oe.fundWallet(c,u)},initLoginWithHeadlessOAuth(c,u){return oe.initLoginWithHeadlessOAuth(c,u)},loginWithHeadlessOAuth(c){return oe.loginWithHeadlessOAuth(c)},generateSiweMessage({address:c,chainId:u}){return oe.generateSiweMessage({address:c,chainId:u})},linkWithSiwe({message:c,signature:u,chainId:f,walletClientType:y,connectorType:b}){return je("siwe"),oe.linkWithSiwe({message:c,signature:u,chainId:f,walletClientType:y,connectorType:b})},signMessageWithCrossAppWallet(c,{address:u}){return wd({user:l,client:t,address:u,requesterAppId:L.id,request:{method:"personal_sign",params:[c,u]},reconnect:bl})},signTypedDataWithCrossAppWallet(c,{address:u}){let f=ns(c);return wd({user:l,client:t,address:u,requesterAppId:L.id,request:{method:"eth_signTypedData_v4",params:[u,f]},reconnect:bl})},sendTransactionWithCrossAppWallet(c,{address:u}){return wd({user:l,client:t,address:u,requesterAppId:L.id,request:{method:"eth_sendTransaction",params:[c]},reconnect:bl})},isModalOpen:r,mfaMethods:L.mfa.methods};o0=qa.signMessage,n0=qa.signTypedData,a0=async(...c)=>{let u=await km(...c);return L.embeddedWallets.waitForTransactionConfirmation&&await u.wait(),u};let oe=(()=>({isNewUserThisSession:I,pendingTransaction:null,walletConnectionStatus:D,connectors:t.connectors?.walletConnectors??[],solanaWallets:h,rpcConfig:L.rpcConfig,chains:L.chains,appId:e.appId,showFiatPrices:L.embeddedWallets.priceDisplay.primary!=="native-token",clientAnalyticsId:t.clientAnalyticsId,customAuthStatus:Pe,noPromptOnSignature:sr,nativeTokenSymbolForChainId:c=>L.chains.find(u=>u.id===Number(c))?.nativeCurrency.symbol,initializeWalletProxy:async c=>{if(O)return O;let u=new Promise(b=>{ot(()=>M=>b(M))}),f=new Promise(b=>setTimeout(()=>b(null),c)),y=await Promise.race([u,f]);return ot(null),y},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>t.authFlow?.meta,client:t,closePrivyModal:async(c={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let u=n&&i&&l,f;u&&J.current&&(f=wl(l)),re.current==="login"?c.shouldCallAuthOnSuccess&&u&&J.current?(N(W,"login","onComplete",l,I,!1,J.current,f??null),e.onSuccess?.(l,I)):N(W,"login","onError","exited_auth_flow"):re.current==="link"&&f&&(c.isSuccess&&u&&J.current?N(W,"linkAccount","onSuccess",l,J.current,f):J.current&&N(W,"linkAccount","onError","exited_link_flow",{linkMethod:J.current}));let y=T&&mm.includes(T),b=T==="ERROR_SCREEN"&&fe.errorModalData&&mm.includes(fe.errorModalData.previousScreen);if((y||b)&&fe.funding){let M=cv[T]??null,G=Kr(fe.funding.chain.id,L.chains,L.rpcConfig,{appId:e.appId}),q;try{q=(await G.getBalance(fe.funding.address)).toBigInt()}catch{console.error("Unable to pull wallet balance")}N(W,"fundWallet","onUserExited",{address:fe.funding.address,chain:fe.funding.chain,fundingMethod:M,balance:q})}te({...fe,externalConnectWallet:{suggestedAddress:void 0}}),re.current=null,J.current=null,A(!1),o(!1),setTimeout(()=>{t.authFlow=void 0},200),t.createAnalyticsEvent({eventName:"modal_closed"})},solanaSignMessage:async({message:c})=>new Promise(async(u,f)=>{let y=async()=>{let b=await t.getAccessToken();if(!b)throw new Error("User must be authenticated to use their embedded wallet.");if(!v)throw new Error("User must have an embedded Solana wallet to sign messages for Solana.");let M=oe.walletProxy??await oe.initializeWalletProxy(15e3);if(!M)throw new Error("Failed to initialize embedded wallet proxy.");let{response:G}=await M.rpcSolana({accessToken:b,publicKey:v.address,request:{method:"signMessage",params:{message:c}}});return G.data.signature};if(L.embeddedWallets.noPromptOnSignature||sr.current)try{let b=await y();u({signature:b})}catch(b){f(b)}else te({signMessage:{method:"solana_signMessage",data:c,confirmAndSign:y,onSuccess:q=>{u({signature:q})},onFailure:q=>{f(q)},uiOptions:{}}}),wt("EMBEDDED_WALLET_SIGN_REQUEST_SCREEN")}),openPrivyModal:Me,connectWallet:cr,initLoginWithWallet:async(c,u,f)=>{fo(c)?(J.current="siwe",Rt(c,u,f)):(J.current="siws",zr(c,u))},loginWithWallet:async()=>{if(!n)throw new Xn;let c;if(t.authFlow instanceof Jo?c="siwe":t.authFlow instanceof sa&&(c="siws"),!c)throw new C("Must initialize SIWE/SIWS flow first.");let u=await t.getAccessToken(),f,y;if(u!==null)try{({user:f}=await t.link()),J.current=c}catch(b){throw N(W,"linkAccount","onError",b.privyErrorCode||"failed_to_link_account",{linkMethod:c}),b}else try{({user:f,isNewUser:y}=await t.authenticate()),J.current=c}catch(b){throw N(W,"login","onError",b.privyErrorCode||"generic_connect_wallet_error"),b}d(f||l||null),A(y||!1),s(!0)},initLoginWithFarcaster:async(c,u)=>{let f=new ds(c,u);t.startAuthFlow(f);try{J.current="farcaster",await f.initializeFarcasterConnect()}catch(y){throw re.current==="login"?N(W,"login","onError",y.privyErrorCode||"unknown_auth_error"):re.current==="link"&&N(W,"linkAccount","onError",y.privyErrorCode||"unknown_auth_error",{linkMethod:"farcaster"}),y}},loginWithFarcaster:async()=>{if(!n)throw new Xn;if(!(t.authFlow instanceof ds))throw new C("Must initialize Farcaster flow first.");let c=await t.getAccessToken(),u,f;if(c!==null)try{({user:u}=await t.link()),J.current="farcaster"}catch(y){throw N(W,"linkAccount","onError",y.privyErrorCode||"failed_to_link_account",{linkMethod:"farcaster"}),y}else try{({user:u,isNewUser:f}=await t.authenticate()),J.current="farcaster"}catch(y){throw N(W,"login","onError",y.privyErrorCode||"unknown_auth_error"),y}d(u||null),A(f||!1),s(!0)},async loginWithGuestAccountFlow(){let c=new ja(this.appId);t.startAuthFlow(c);try{re.current="login",J.current="guest";let u=await t.authenticate(),{user:f,isNewUser:y}=u;if(y=y||!1,!f)throw new C("Unable to authenticate guest account");if(It(f,L.embeddedWallets.createOnLogin))try{await Tp(f,15e3),f=await oe.refreshUser()}catch{d(f),console.warn("Unable to create embedded wallet for guest account")}else d(f);return A(y),s(!0),N(W,"login","onComplete",f,y,!1,"guest",null),f}catch(u){throw N(W,"login","onError",u.privyErrorCode||"unknown_auth_error"),u}},async crossAppAuthFlow({appId:c,popup:u,action:f}){let y=`privy:${c}`;J.current=y;let{url:b,stateCode:M,codeVerifier:G}=await y2({api:t.api,appId:c});if(!b)throw t.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:c}}),new C("No authorization URL returned for cross-app auth.");try{let q=await e0({url:b,popup:u,provider:y}),ne=q.stateCode,me=q.authorizationCode;if(ne!==M)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:y,storedStateCode:M??"",returnedStateCode:ne??""}}),new C("Unexpected auth flow. This may be a phishing attempt.",void 0,"oauth_unexpected");let Ae=await g2({appId:c,codeVerifier:G,stateCode:ne,authorizationCode:me,action:f,client:t});Ae&&t.storeProviderAccessToken(c,Ae);let Re=await oe.refreshUser();if(!Re)throw new C("Unable to update user");return t.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:c}}),Re}catch(q){throw t.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:q.toString(),provider:y}}),q}},async initLoginWithOAuth(c,u,f){if(J.current=c,rs()){if(c==="google"&&Ei(window.navigator.userAgent)){wt("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}}else{wt("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}c==="twitter"&&window.opener&&window.opener.postMessage({type:Ep},"*"),Z.del(ea),Z.del(ta);let y=new Ro({provider:c,disableSignup:!!f});u&&y.addCaptchaToken(u),t.startAuthFlow(y);let b=await t.authFlow.getAuthorizationUrl();b&&b.url&&(c==="twitter"&&$A&&(b.url=b.url.replace("x.com","twitter.com")),window.location.assign(b.url))},async initLoginWithTelegram(c,u){if(!n)throw new Xn;J.current="telegram";let f=new ti(c,u);t.startAuthFlow(f),f.meta.telegramWebAppData=void 0,f.meta.telegramAuthResult=await new Promise((y,b)=>{if(!L.loginConfig.telegramAuthConfiguration)return b(new C("Telegram Auth configuration is not loaded"));if(!window.Telegram)return b(new C("Telegram was not initialized"));window.Telegram.Login.auth({bot_id:L.loginConfig.telegramAuthConfiguration.botId,request_access:!0},M=>M?y(M):b(new C("Telegram auth failed or was canceled by the client")))})},async loginWithTelegram(){if(!(t.authFlow instanceof ti))throw new C("Must initialize Telegram flow before calling loginWithTelegram");let c,u;if(re.current==="login")try{let f=await t.authenticate();c=f.user,u=f.isNewUser,J.current="telegram"}catch(f){throw N(W,"login","onError",f.privyErrorCode||"unknown_auth_error"),f}else if(re.current==="link")try{c=(await t.link()).user,J.current="telegram"}catch(f){throw N(W,"linkAccount","onError",f.privyErrorCode||"failed_to_link_account",{linkMethod:"telegram"}),f}else throw new C("Unknown auth intent");d(c),A(u||!1),s(!0)},async recoveryOAuthFlow(c,u,f){let y,b;function M(G){if(!G)throw t.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:c}}),new C("Recovery OAuth failed")}switch(c){case"google-drive":{let{url:G,codeVerifier:q,stateCode:ne}=await uu({api:dn.api,provider:c});M(G);let me,Ae;try{let Re=await Pm({url:G,popup:f,provider:c});if(me=Re.stateCode,Ae=Re.authorizationCode,me!==ne)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:c,storedStateCode:ne??"",returnedStateCode:me??""}}),new C("Unexpected auth flow. This may be a phishing attempt.",void 0,"oauth_unexpected")}catch(Re){throw t.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:Re.toString(),provider:c}}),new C("Recovery OAuth failed")}[y,b]=await Promise.all([he(),Cg({api:dn.api,provider:c,codeVerifier:q,stateCode:me,authorizationCode:Ae})]);break}case"icloud":{let{url:G}=await uu({api:dn.api,provider:c});M(G);let{ckWebAuthToken:q}=await Pm({url:G,popup:f,provider:c});b=q,y=await he();break}}if(!O)throw new C("Cannot connect to wallet proxy");if(!y)throw new C("Unable to authorize user");switch(u){case"recover":let G=fe.recoverWallet?.privyWallet?.address;if(!G)throw new C("Recovery OAuth failed");t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:G,recoveryMethod:c}}),await O.recover({address:G,accessToken:y,recoveryAccessToken:b,recoveryMethod:c}),t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:G,recoveryMethod:c}});break;case"create-wallet":t.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await O.create({accessToken:y,recoveryAccessToken:b,recoveryMethod:c});let q=await oe.refreshUser(),ne=Be(q);if(!ne)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:ne.address}}),N(W,"createWallet","onSuccess",ne);break;case"set-recovery":let me=Be(l);if(!me)throw N(W,"setWalletRecovery","onError","embedded_wallet_not_found"),new Error("Embedded wallet not found");t.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:me.address,existingRecoveryMethod:me.recoveryMethod,targetRecoveryMethod:c}}),await O.setRecovery({address:me.address,accessToken:y,recoveryAccessToken:b,recoveryMethod:c});let Ae=Be(await oe.refreshUser());if(!Ae)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to set recovery on wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:me.address,existingRecoveryMethod:me.recoveryMethod,targetRecoveryMethod:c}}),N(W,"setWalletRecovery","onSuccess",c,Ae);break;default:throw new C("Unsupported recovery action")}},async loginWithOAuth(c){if(!(t.authFlow instanceof Ro))throw new C("Must initialize OAuth flow before calling loginWithOAuth");let u=Z.get(jn),f=t.authFlow.meta.stateCode;if(u!==f)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:c,storedStateCode:u??"",returnedStateCode:f??""}}),new C("Unexpected auth flow. This may be a phishing attempt.",void 0,"oauth_unexpected");let y=await t.getAccessToken(),b,M,G;if(y!==null)try{let q=await t.link();b=q.user,G=q.oAuthTokens,J.current=c}catch(q){throw N(W,"linkAccount","onError",q.privyErrorCode||"failed_to_link_account",{linkMethod:c}),q}else try{let q=await t.authenticate();b=q.user,M=q.isNewUser,G=q.oAuthTokens,J.current=c}catch(q){throw re.current==="login"?N(W,"login","onError",q.privyErrorCode||"unknown_auth_error"):re.current==="link"&&N(W,"linkAccount","onError",q.privyErrorCode||"failed_to_link_account",{linkMethod:c}),q}return d(b),A(M||!1),s(!0),G&&b&&N(W,"oAuthAuthorization","onOAuthTokenGrant",G,{user:b}),G},passkeyAuthState:Y,setPasskeyAuthState:K,async initLoginWithPasskey(c){let u=new ia(c,K);t.startAuthFlow(u),re.current="login";try{J.current="passkey",K({status:"generating-challenge"}),await u.initAuthenticationFlow(),K({status:"awaiting-passkey"})}catch(f){throw K({status:"error",error:f}),N(W,"login","onError",f.privyErrorCode||"unknown_auth_error"),f}},async loginWithPasskey(){if(!n)throw new Xn;if(!(t.authFlow instanceof ia))throw new C("Must initialize Passkey flow first.");if(J.current!=="passkey"){let M=new C("Must init login with Passkey flow first.");throw K({status:"error",error:M}),M}let u=!!await he(),f,y;try{J.current="passkey",K({status:"awaiting-passkey"}),{user:f,isNewUser:y}=await t.authenticate()}catch(M){throw K({status:"error",error:M}),N(W,"login","onError",M.privyErrorCode||"unknown_auth_error"),M}d(f),A(y||!1),s(!0),K({status:"done"});let b=f?.linkedAccounts.find(({type:M})=>M==="passkey")||null;return{user:f,isNewUser:y||!1,wasAlreadyAuthenticated:u,loginAccount:b}},async initLinkWithPasskey(c){let u=new ia(c);t.startAuthFlow(u),re.current="link",J.current="passkey";try{await u.initLinkFlow()}catch(f){throw N(W,"linkAccount","onError",f.privyErrorCode||"unknown_auth_error",{linkMethod:"passkey"}),f}},async linkWithPasskey(){if(!n)throw new Xn;if(!(t.authFlow instanceof ia))throw new C("Must initialize Passkey flow first.");if(J.current!=="passkey")throw new C("Must init login with Passkey flow first.");let c;try{J.current="passkey",{user:c}=await t.link()}catch(u){throw N(W,"linkAccount","onError",u.privyErrorCode||"failed_to_link_account",{linkMethod:"passkey"}),u}return d(c||l||null),c},async initLoginWithHeadlessOAuth(c,u){if(rs()){if(c==="google"&&Ei(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.")}else throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let f=new Ro({provider:c,headless:!0,disableSignup:!1});u&&f.addCaptchaToken(u);let y=await t.startAuthFlow(f).getAuthorizationUrl();y?.url&&window.location.assign(y.url)},async loginWithHeadlessOAuth(c){_(!0),t.startAuthFlow(new Ro(c));let u=Z.get(jn),f=c.stateCode;if(u!==f)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:c.provider,storedStateCode:u??"",returnedStateCode:f??""}}),_(!1),new C("Unexpected auth flow. This may be a phishing attempt.",void 0,"oauth_unexpected");let y=await t.getAccessToken(),b,M,G;if(y!==null)try{({user:b,oAuthTokens:G}=await t.link()),J.current=c.provider;let q=wl(b);b&&q&&N(W,"linkAccount","onSuccess",b,J.current,q)}catch(q){throw _(!1),N(W,"linkAccount","onError",q.privyErrorCode||"failed_to_link_account",{linkMethod:c.provider}),q}else try{({user:b,isNewUser:M,oAuthTokens:G}=await t.authenticate()),J.current=c.provider;let q=wl(b);b&&q&&M!==void 0&&re.current==="login"&&N(W,"login","onComplete",b,M,!1,J.current,q)}catch(q){throw _(!1),N(W,"login","onError",q.privyErrorCode||"unknown_auth_error"),q}return d(b),A(M||!1),s(!0),_(!1),G&&b&&N(W,"oAuthAuthorization","onOAuthTokenGrant",G,{user:b}),b??void 0},initLoginWithEmail:async(c,u,f)=>{let y=new mn(c,u,f);t.startAuthFlow(y);try{J.current="email",await y.sendCodeEmail()}catch(b){throw re.current==="login"?N(W,"login","onError",b.privyErrorCode||"unknown_auth_error"):re.current==="link"&&N(W,"linkAccount","onError",b.privyErrorCode||"failed_to_link_account",{linkMethod:"email"}),b}},initUpdateEmail:async(c,u,f)=>{let y=new Yl(c,u,f);t.startAuthFlow(y),await y.sendCodeEmail()},initUpdatePhone:async(c,u,f)=>{let y=new pc(c,u,f);t.startAuthFlow(y),await y.sendSmsCode()},initLoginWithSms:async(c,u,f)=>{H({status:"sending-code"});let y=new fn(c,u,f);t.startAuthFlow(y);try{J.current="sms",await y.sendSmsCode(),H({status:"awaiting-code-input"})}catch(b){throw H({status:"error",error:b}),re.current==="login"?N(W,"login","onError",b.privyErrorCode||"unknown_auth_error"):re.current==="link"&&N(W,"linkAccount","onError",b.privyErrorCode||"failed_to_link_account",{linkMethod:"sms"}),b}},resendEmailCode:async()=>{await t.authFlow?.sendCodeEmail()},resendSmsCode:async()=>{await t.authFlow?.sendSmsCode()},loginWithCode:async c=>{if(H({status:"submitting-code"}),!n){let y=new Xn;throw H({status:"error",error:y}),y}if(t.authFlow instanceof mn)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof fn)t.authFlow.meta.smsCode=c.trim();else{let y=new C("Must initialize a passwordless code flow first");throw H({status:"error",error:y}),y}await he();let u,f;if(re.current==="link")try{({user:u}=await t.link())}catch(y){throw H({status:"error",error:y}),N(W,"linkAccount","onError",y.privyErrorCode||"failed_to_link_account",{linkMethod:J.current}),y}else try{({user:u,isNewUser:f}=await t.authenticate())}catch(y){throw H({status:"error",error:y}),N(W,"login","onError",y.privyErrorCode||"unknown_auth_error"),y}d(u||l||null),A(f||!1),s(!0),H({status:"done"})},generateSiweMessage:async({address:c,chainId:u,captchaToken:f})=>{re.current="link",J.current="siwe";let y=await t.generateSiweNonce({address:c,captchaToken:f}),b=u.replace("eip155:","");return dc({address:c,chainId:b,nonce:y})},linkSmartWallet:async({message:c,signature:u,smartWalletType:f})=>{re.current=null,J.current=null;let y;try{y=await t.linkSmartWallet({message:c,signature:u,smartWalletType:f}),y=await oe.refreshUser()??y}catch(b){throw b}d(y||l||null)},linkWithSiwe:async({message:c,signature:u,chainId:f,walletClientType:y,connectorType:b})=>{let M;try{M=await t.linkWithSiwe({message:c,signature:u,chainId:f,walletClientType:y,connectorType:b}),M=await oe.refreshUser()??M;let G=wl(M);G&&N(W,"linkAccount","onSuccess",M,"siwe",G)}catch(G){throw N(W,"linkAccount","onError",G.privyErrorCode||"failed_to_link_account",{linkMethod:"siwe"}),re.current=null,J.current=null,G}d(M||l||null),re.current=null,J.current=null},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return s(!!c),d(c),c},walletProxy:O,createAnalyticsEvent:({eventName:c,payload:u,timestamp:f})=>t.createAnalyticsEvent({eventName:c,payload:u,timestamp:f}),acceptTerms:async()=>{let c=await t.acceptTerms();return d(c),c},getUsdTokenPrice:c=>t.getUsdTokenPrice(c),getUsdPriceForSol:()=>t.getUsdPriceForSol(),recoverEmbeddedEthereumWallet:async c=>new Promise(async(u,f)=>{let y=Be(c?.user??l)||Ml(c?.user??l),b=await he();if(!b||!O||!y){f(new Error("Must have valid access token and Privy wallet to recover wallet"));return}X(!0);try{await O.connect({accessToken:b,address:y.address}),u(!0)}catch(M){if(va(M)&&y.recoveryMethod==="privy")t.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:y.address}}),(await O.recover({address:y.address,accessToken:b,recoveryMethod:y.recoveryMethod})).address||f(new Error("Unable to recover wallet")),t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:y.address}}),u(!0);else if(va(M)&&y.recoveryMethod!=="privy"){te({recoverWallet:{privyWallet:y,onFailure:f,onSuccess:()=>u(!0)},recoveryOAuthStatus:{provider:y.recoveryMethod,action:"recover"}});let G=Xc(y.recoveryMethod);Me(G)}else f(M)}}),embeddedSolanaWallet:v,createEmbeddedSolanaWallet:async()=>{X(!0);let c=await he(),u=await oe.refreshUser(),f=oa(u),y=Be(u);if(!u||!c)throw new C("User must be logged in to create a Solana wallet");if(f)throw new C("User already has an embedded Solana wallet.");if(y)if(y.recoveryMethod==="privy")await oe.recoverEmbeddedEthereumWallet({user:u});else throw new C("Cannot create an embedded Solana wallet for a user with an existing Ethereum wallet with user-controlled recovery.");let b=await oe.initializeWalletProxy(15e3);if(!b)throw new C("Unable to initialize wallet proxy");t.createAnalyticsEvent({eventName:"embedded_solana_wallet_creation_started"});try{await b.createSolana({accessToken:c,ethereumAddress:y?.address});let M=await oe.refreshUser(),G=oa(M);if(!G)throw new C("Could not get Solana wallet for user");return t.createAnalyticsEvent({eventName:"embedded_solana_wallet_creation_completed",payload:{walletAddress:G.address}}),G}catch(M){throw t.createAnalyticsEvent({eventName:"embedded_solana_wallet_creation_failed"}),new C("Failed to create Solana embedded wallet with error ",M)}},exportSolanaWallet:c=>new Promise(async(u,f)=>{if(!i||!l){f(new Error("User must be authenticated before exporting their Privy wallet"));return}let y=c?.address,b=l.linkedAccounts.filter(ne=>ne.type==="wallet"&&ne.walletClientType==="privy"&&ne.chainType==="solana"),M=y?b.find(ne=>ne.address.toLowerCase()===y.toLowerCase()):b.find(ne=>!ne.imported)||b[0];if(!M){f(new Error("Must have a Privy wallet before exporting"));return}if(X(!0),!await he()||!O){f(new Error("Must have valid access token to enroll in MFA"));return}if(!O){f(new Error("Must have a Privy wallet before exporting"));return}await oe.recoverEmbeddedSolanaWallet();let q={appId:e.appId,appClientId:e.clientId,origin:t.apiUrl,wallet:M,onSuccess:u,onFailure:f};te({keyExport:q}),Me("EMBEDDED_WALLET_KEY_EXPORT_SCREEN")}),recoverEmbeddedSolanaWallet:async()=>new Promise(async(c,u)=>{let f=oa(l),y=await he();if(!y||!O||!f){u(new Error("Must have valid access token and Privy wallet to recover wallet"));return}X(!0);try{await O.connectSolana({accessToken:y,publicKey:f.address}),c(!0)}catch(b){va(b)&&f.recoveryMethod==="privy"?(t.createAnalyticsEvent({eventName:"embedded_solana_wallet_pinless_recovery_started",payload:{walletAddress:f.address}}),(await O.recoverSolana({publicKey:f.address,accessToken:y})).publicKey||u(new Error("Unable to recover wallet")),t.createAnalyticsEvent({eventName:"embedded_solana_wallet_recovery_completed",payload:{walletAddress:f.address}}),c(!0)):u(b)}}),getMoonpaySignedUrl:f0,initCoinbaseOnRamp:t.initCoinbaseOnRamp.bind(t),getCoinbaseOnRampStatus:t.getCoinbaseOnRampStatus.bind(t),setReadyToTrue:c=>{a(!0),ee?.(c)},updateWallets:()=>vl(),fundWallet:async(c,u)=>{if(!L.fundingConfig||L.fundingConfig.methods.length===0)throw new Error("Wallet funding is not enabled");let f=gp({fundingMethods:L.fundingConfig.methods});te({funding:um({address:c,appConfig:L,fundWalletConfig:u,methodScreen:f})}),Me(f)},requestFarcasterSignerStatus:async c=>{let u=await he(),f=l?.linkedAccounts.find(b=>b.type==="wallet"&&b.walletClientType==="privy");if(!u)throw new Error("Must have valid access token to connect with Farcaster");if(!O||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!l?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");let y=await t.requestFarcasterSignerStatus(c);if(y.status==="approved"){let b=await t.getAuthenticatedUser();d(b||l||null)}return y},connectCoinbaseSmartWallet:async()=>{L.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let c=t.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||t.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(c)return c.updateConnectionPreference("smartWalletOnly"),cr(c);await Ar("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:c,account:u,accountType:f,chainId:y,walletClientType:b,connectorType:M,telegramAuthResult:G})=>{try{let q=await t.sendAccountTransferRequest({nonce:c,account:u,accountType:f,walletClientType:b,chainId:y,connectorType:M,telegramAuthResult:G});return d(q),q}catch(q){throw q}}}))();i0=oe.recoverEmbeddedEthereumWallet,s0=oe.recoverEmbeddedSolanaWallet,l0=oe.solanaSignMessage;let Mm=jA(()=>({wallets:p,ready:ie&&Ce}),[p,ie,Ce]);return Gr(De.Provider,{value:qa,children:Gr(ff.Provider,{value:W,children:Gr(wf.Provider,{value:Mm,children:Gr(sy,{...L,children:r0(pf.Provider,{value:oe,children:[Gr(yf,{children:r0(df,{data:fe,setModalData:te,setInitialScreen:P,initialScreen:T,authenticated:i,open:r,children:[e.children,!L.headless&&L.captchaEnabled&&n&&!i&&Gr(Vp,{delayedExecution:!1}),Gr(Ov,{theme:{...L.appearance.palette||{}}}),!L.render.standalone&&Gr(Tm,{open:r})]})}),pe&&Ge?Gr(Zv,{appId:e.appId,appClientId:e.clientId,clientAnalyticsId:t.clientAnalyticsId,origin:t.apiUrl,mfaMethods:l?.mfaMethods,mfaPromise:ke,mfaSubmitPromise:se,onLoad:Q,onLoadFailed:()=>null}):null,L.loginConfig.telegramAuthConfiguration&&Gr(yo,{if:!0,children:Gr(Yv,{scriptHost:e.apiUrl||xl,botUsername:L.loginConfig.telegramAuthConfiguration.botName})})]})})})})})};import{useCallback as c0,useEffect as sx}from"react";var lx=e=>{ze("login",e);let t=Te(),r=Dl(),{initLoginWithHeadlessOAuth:o,loginWithHeadlessOAuth:n,isHeadlessOAuthLoading:a,ready:i,user:s}=z(),l=c0(async p=>{if(t.enabled&&t.status!=="success")throw new Lt(t.error,null,"captcha_failure");return o(p.provider,t.token)},[o,t]),d=c0(async()=>{let p=hs();if(s)return console.warn("Cannot login with OAuth when already logged in"),s;if(!p.inProgress)throw new Error("Cannot login with OAuth because no OAuth flow is in progress");if(!p.popupFlow)try{return await n(p)}catch(m){throw m}finally{aa()}},[n]);return sx(()=>{let p=hs();i&&r&&p.inProgress&&p.headless&&!p.popupFlow&&d()},[i,r]),{initOAuth:l,loginWithOAuth:d,loading:a}};import{useCallback as d0}from"react";var cx=()=>{let e=Te(),{initLoginWithEmail:t,loginWithCode:r}=R(),o=d0(async({email:a})=>{if(!a)throw new Error("Email required to send OTP code");if(e.enabled&&e.status==="error")throw new Lt(e.error,null,"captcha_failure");let i;return e.enabled&&e.status!=="success"&&(e.execute(),i=await e.waitForResult()),t(a,i)},[t]),n=d0(async({code:a})=>{if(e.enabled&&e.status==="error")throw new Lt(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};import{useCallback as dx}from"react";var px=e=>{let t=Te(),{initLoginWithPasskey:r,loginWithPasskey:o,passkeyAuthState:n,setPasskeyAuthState:a}=R();return{loginWithPasskey:dx(async()=>{try{if(t.enabled&&t.status==="error")throw new Lt(t.error,null,"captcha_failure");let s;t.enabled&&t.status!=="success"&&(t.execute(),s=await t.waitForResult()),await r(s);let{user:l,isNewUser:d,wasAlreadyAuthenticated:p,loginAccount:m}=await o();e?.onComplete?.(l,d,p,"passkey",m)}catch(s){throw a({status:"error",error:s}),e?.onError?.(s),s}},[o,t.status]),state:n}};import{useCallback as p0}from"react";var ux=()=>{let e=Te(),{otpState:t}=z(),{initLoginWithSms:r,loginWithCode:o}=R(),n=p0(async({phoneNumber:i})=>{if(!i)throw new Error("SMS required to send OTP code");if(e.enabled&&e.status==="error")throw new Lt(e.error,null,"captcha_failure");let s;return e.enabled&&e.status!=="success"&&(e.execute(),s=await e.waitForResult()),r(i,s)},[r]),a=p0(async({code:i})=>{if(e.enabled&&e.status!=="success")throw new Lt(e.error,null,"captcha_failure");return o(i)},[o,e.status]);return{sendCode:n,loginWithCode:a,state:t}};import{useCallback as u0}from"react";var mx=()=>{let e=Te(),{generateSiweMessage:t,linkWithSiwe:r}=z(),o=u0(async({address:a,chainId:i})=>{if(!a||!i)throw new Error("wallet address and chainId required to generate nonce");return t({address:a,chainId:i}).then(s=>s)},[t]),n=u0(async({signature:a,message:i,chainId:s,walletClientType:l,connectorType:d})=>{if(e.enabled&&e.status!=="success")throw new Lt(e.error,null,"captcha_failure");return r({message:i,signature:a,chainId:s,walletClientType:l,connectorType:d})},[r,e.status]);return{generateSiweMessage:o,linkWithSiwe:n}};import{useContext as fx}from"react";function hx(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:s,linkGithub:l,linkLinkedIn:d,linkTiktok:p,linkSpotify:m,linkInstagram:h,linkTelegram:g,linkFarcaster:v}=fx(De);return ze("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:s,linkGithub:l,linkLinkedIn:d,linkTiktok:p,linkSpotify:m,linkInstagram:h,linkFarcaster:v,linkTelegram:g}}import{useContext as yx}from"react";function gx(e){let{createWallet:t}=yx(De);return ze("createWallet",e),{createWallet:t}}var Cx=()=>{let{embeddedSolanaWallet:e,exportSolanaWallet:t,createEmbeddedSolanaWallet:r,solanaWallets:o}=R();return{createWallet:r,exportWallet:t,wallets:o.concat(e?[e]:[])}};var vx=()=>{let{connectCoinbaseSmartWallet:e}=R();return{connectCoinbaseSmartWallet:e}};var wx=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:r,signTypedDataWithCrossAppWallet:o,sendTransactionWithCrossAppWallet:n}=z();return{loginWithCrossAppAccount:({appId:a})=>e({appId:a,action:"login"}),linkCrossAppAccount:({appId:a})=>e({appId:a,action:"link"}),unlinkCrossAppAccount:t,signMessage:r,signTypedData:o,sendTransaction:n}};import{useContext as bx}from"react";function Ex(e){let{sendTransaction:t}=bx(De);return ze("sendTransaction",e),{sendTransaction:t}}import{useContext as Tx}from"react";function Sx(e){let{sendSolanaTransaction:t}=Tx(De);return ze("sendSolanaTransaction",e),{sendSolanaTransaction:t}}import{useContext as Px}from"react";function Ax(e){let{setWalletPassword:t}=Px(De);return ze("setWalletPassword",e),{setWalletPassword:t}}import{useContext as xx}from"react";function kx(){let{createGuestAccount:e}=xx(De);return{createGuestAccount:e}}import{useContext as Rx}from"react";function _x(e){let{setWalletRecovery:t}=Rx(De);return ze("setWalletRecovery",e),{setWalletRecovery:t}}import{useContext as Ix}from"react";function Mx(e){let{signMessage:t}=Ix(De);return ze("signMessage",e),{signMessage:t}}import{useContext as Wx}from"react";function Lx(e){let{signTypedData:t}=Wx(De);return ze("signTypedData",e),{signTypedData:t}}import{useContext as Nx}from"react";var Ox=()=>{let{isModalOpen:e}=Nx(De);return{isOpen:e}};import{useContext as Dx}from"react";function Ux(e){let{getAccessToken:t}=Dx(De);return ze("accessToken",e),{getAccessToken:t}}function Fx(e){let{authenticated:t,user:r}=z(),{initLoginWithOAuth:o}=R(),n=Ya();return ze("oAuthAuthorization",e),{reauthorize:a=>Bx(t,r,o,n,a.provider)}}var Bx=async(e,t,r,o,n)=>{if(!e)throw o("linkAccount","onError","must_be_authenticated",{linkMethod:n}),new C("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some(i=>i.type.includes(n)))throw new C(`OAuth account of type ${n} not linked to the account.`);await r(n)};var Hx=e=>{let{customAuthStatus:t}=R();return ze("customAuth",e),{status:t}};var Vx=m0;function m0(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=z();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}}export{ca as a,st as b,Io as c,mr as d,$h as e,ws as f,bs as g,Vp as h,Gp as i,wa as j,ba as k,du as l,tl as m,Eo as n,Tm as o,he as p,ax as q,lx as r,cx as s,px as t,ux as u,mx as v,hx as w,gx as x,Cx as y,vx as z,wx as A,Ex as B,Sx as C,Ax as D,kx as E,_x as F,Mx as G,Lx as H,Ox as I,Ux as J,Fx as K,Hx as L,Vx as M,m0 as N};
|
|
3376
|
+
`;import{useRef as Kv,useEffect as FA}from"react";import{jsx as HA}from"react/jsx-runtime";function BA({botUsername:e,scriptHost:t}){let r=document.createElement("script"),{origin:o}=new URL(t);return r.async=!0,r.src=`${o}/js/telegram-login.js`,r.setAttribute("data-telegram-login",e),r.setAttribute("data-request-access","write"),r.setAttribute("data-lang","en"),r}function Yv(e){let t=Kv(null),r=Kv();return FA(()=>{r.current?.remove(),r.current=BA(e),t.current?.after(r.current)},[e]),HA("div",{ref:t,hidden:!0})}import{useState as VA}from"react";import{useEffect as Qv,useRef as Xv}from"react";var vp=class{constructor(){this.callbacks={}}enqueue(t,r){this.callbacks[t]=r}dequeue(t,r){let o=this.callbacks[r];if(!o)throw new Error(`cannot dequeue ${t} event: no event found for id ${r}`);switch(delete this.callbacks[r],t){case"privy:iframe:ready":return o;case"privy:wallet:create":return o;case"privy:wallet:create-additional":return o;case"privy:wallet:import":return o;case"privy:wallet:connect":return o;case"privy:wallet:recover":return o;case"privy:wallet:rpc":return o;case"privy:wallet:set-recovery":return o;case"privy:mfa:verify":return o;case"privy:mfa:init-enrollment":return o;case"privy:mfa:submit-enrollment":return o;case"privy:mfa:unenroll":return o;case"privy:mfa:clear":return o;case"privy:farcaster:init-signer":return o;case"privy:farcaster:sign":return o;case"privy:solana-wallet:create":return o;case"privy:solana-wallet:connect":return o;case"privy:solana-wallet:recover":return o;case"privy:solana-wallet:rpc":return o;default:throw new Error(`invalid wallet event type ${t}`)}}};async function Yn(e,t,r,o,n,a=!1){let i=a,s=async p=>{if(i&&t&&t.length>0){p===(a?0:1)?n("configureMfa","onMfaRequired",t):o.current?.reject(new Ue("missing_or_invalid_mfa","MFA verification failed, retry."));let m=await new Promise((h,g)=>{r.current={resolve:h,reject:g};let v=1e3*60*5;setTimeout(()=>{let w=new Ue("mfa_timeout","Timed out waiting for MFA code");o.current?.reject(w),g(w)},v)});return await e(m)}return await e()},l=4,d=null;for(let p=0;p<l;p++)try{d=await s(p),o.current?.resolve(void 0);break}catch(m){if(m.type==="missing_or_invalid_mfa")i=!0;else throw o.current?.resolve(void 0),m}if(d===null){let p=new Ue("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw o.current?.reject(p),p}return d}import{jsx as QA}from"react/jsx-runtime";var GA=function(e){return()=>`id-${e++}`}(0);function qA(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function bt(e){return e.error!==void 0}var vt=new vp,Sm=new Map,zA=(e,t)=>typeof t=="bigint"?t.toString():t,KA=(e,t)=>`${e}${JSON.stringify(t,zA)}`;function Et(e,t,r,o){let n=r.contentWindow;if(!n)throw new Error("iframe not initialized");let a=KA(e,t);if(e==="privy:wallet:create"){let s=Sm.get(a);if(s)return s}let i=new Promise((s,l)=>{let d=GA();vt.enqueue(d,{resolve:s,reject:l}),n.postMessage({id:d,event:e,data:t},o)}).finally(()=>{Sm.delete(a)});return Sm.set(a,i),i}function YA(e){switch(e.event){case"privy:iframe:ready":let t=vt.dequeue(e.event,e.id);return bt(e)?t.reject(new Ue(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let r=vt.dequeue(e.event,e.id);return bt(e)?r.reject(new Ue(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:create-additional":let o=vt.dequeue(e.event,e.id);return bt(e)?o.reject(new Ue(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:import":let n=vt.dequeue(e.event,e.id);return bt(e)?n.reject(new Ue(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:connect":let a=vt.dequeue(e.event,e.id);return bt(e)?a.reject(new Ue(e.error.type,e.error.message)):a.resolve(e.data);case"privy:wallet:recover":let i=vt.dequeue(e.event,e.id);return bt(e)?i.reject(new Ue(e.error.type,e.error.message)):i.resolve(e.data);case"privy:wallet:rpc":let s=vt.dequeue(e.event,e.id);return bt(e)?s.reject(new Ue(e.error.type,e.error.message)):s.resolve(e.data);case"privy:wallet:set-recovery":let l=vt.dequeue(e.event,e.id);return bt(e)?l.reject(new Ue(e.error.type,e.error.message)):l.resolve(e.data);case"privy:mfa:verify":let d=vt.dequeue(e.event,e.id);return bt(e)?d.reject(new Ue(e.error.type,e.error.message)):d.resolve(e.data);case"privy:mfa:init-enrollment":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:mfa:submit-enrollment":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:mfa:unenroll":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:mfa:clear":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:farcaster:init-signer":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:farcaster:sign":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}case"privy:solana-wallet:create":let p=vt.dequeue(e.event,e.id);return bt(e)?p.reject(new Ue(e.error.type,e.error.message)):p.resolve(e.data);case"privy:solana-wallet:connect":let m=vt.dequeue(e.event,e.id);return bt(e)?m.reject(new Ue(e.error.type,e.error.message)):m.resolve(e.data);case"privy:solana-wallet:recover":let h=vt.dequeue(e.event,e.id);return bt(e)?h.reject(new Ue(e.error.type,e.error.message)):h.resolve(e.data);case"privy:solana-wallet:rpc":{let g=vt.dequeue(e.event,e.id);return bt(e)?g.reject(new Ue(e.error.type,e.error.message)):g.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}function Zv(e){let t=Xv(null),r=Xv(e.mfaMethods),o=Ya(),[n,a]=VA(!1);return Qv(()=>{r.current=e.mfaMethods},[e.mfaMethods]),Qv(()=>{if(!n)return;let i=t.current;if(!i)return;function s(h){h&&h.origin===e.origin&&qA(h.data)&&YA(h.data)}let l={create(h){return Et("privy:wallet:create",h,i,e.origin)},createAdditional(h){return Et("privy:wallet:create-additional",h,i,e.origin)},import(h){return Et("privy:wallet:import",h,i,e.origin)},connect(h){return Et("privy:wallet:connect",h,i,e.origin)},recover(h){return Yn(g=>Et("privy:wallet:recover",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!h.recoveryMethod||h.recoveryMethod==="privy")},rpc(h){return Yn(g=>Et("privy:wallet:rpc",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},createSolana(h){return Et("privy:solana-wallet:create",h,i,e.origin)},connectSolana(h){return Et("privy:solana-wallet:connect",h,i,e.origin)},recoverSolana(h){return Et("privy:solana-wallet:recover",h,i,e.origin)},rpcSolana(h){return Et("privy:solana-wallet:rpc",h,i,e.origin)},setRecovery(h){return Yn(g=>Et("privy:wallet:set-recovery",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},verifyMfa(h){return Yn(g=>Et("privy:mfa:verify",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},initEnrollMfa(h){return Yn(g=>Et("privy:mfa:init-enrollment",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},submitEnrollMfa(h){return Yn(g=>Et("privy:mfa:submit-enrollment",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},unenrollMfa(h){return Yn(g=>Et("privy:mfa:unenroll",{...h,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},clearMfa(h){return Et("privy:mfa:clear",h,i,e.origin)},initFarcasterSigner(h){return Et("privy:farcaster:init-signer",h,i,e.origin)},signFarcasterMessage(h){return Et("privy:farcaster:sign",h,i,e.origin)}};window.addEventListener("message",s);let d=()=>e.onLoad(l),p=(...h)=>{console.warn("Privy iframe failed to load: ",...h),e.onLoadFailed()},m=new AbortController;return os(()=>Et("privy:iframe:ready",{},i,e.origin),{abortSignal:m.signal}).then(d,p),()=>{window.removeEventListener("message",s),m.abort()}},[n]),QA("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>a(!0),src:Al(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId,client_id:e.appClientId})})}var wp=class{constructor(t,r){this.walletProxy=t,this.address=r}async handleSignMessage(t){if(!t.params||typeof t.params.message!="string")throw new Error("Message must be provided as a string for Solana signMessage RPC");return await jv({message:t.params.message})}async request(t){if(console.debug("EmbeddedSolanaProvider.request() called with args",t),!await he())throw new Error("User must be authenticated to use embedded Solana wallet");if(!await Jv())throw new C("Unable to connect to Solana embedded wallet");switch(t.method){case"signMessage":return await this.handleSignMessage(t);default:throw new Error("Embedded Solana provider does not yet support this RPC method.")}}};var bp="popup-privy-oauth",Ep="PRIVY_OAUTH_USE_BROADCAST_CHANNEL",XA="privy:";function $v(e){return e.startsWith(XA)}async function e0({url:e,popup:t}){return t.location=e,new Promise((o,n)=>{let i=setTimeout(()=>{n(new C("Authorization request timed out after 2 minutes.")),s()},12e4);function s(){t?.close(),window.removeEventListener("message",p)}let l,d=setInterval(()=>{t?.closed&&!l&&(s(),clearInterval(d),clearTimeout(i),n(new C("User rejected request")))},300);function p(m){m.data&&(m.data.type==="PRIVY_OAUTH_RESPONSE"&&m.data.stateCode&&m.data.authorizationCode&&(clearTimeout(i),o(m.data),s()),m.data.type==="PRIVY_OAUTH_ERROR"&&(clearTimeout(i),n(new C(m.data.error)),s()),m.data.type===Ep&&(l=new BroadcastChannel(bp),l.onmessage=p))}window.addEventListener("message",p)})}var ZA="https://cdn.apple-cloudkit.com";async function Pm({url:e,popup:t,provider:r}){return t.location=e,new Promise((n,a)=>{function i(){t?.close(),window.removeEventListener("message",s)}function s(l){l.data&&(l.data.type==="PRIVY_OAUTH_RESPONSE"&&l.data.stateCode&&l.data.authorizationCode&&(n(l.data),i()),l.origin===ZA&&l.data.ckSession&&(n({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:l.data.ckSession}),i()),l.data.type==="PRIVY_OAUTH_ERROR"&&(a(l.data.error),i()))}window.addEventListener("message",s)})}var t0=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});import{jsx as Gr,jsxs as r0}from"react/jsx-runtime";var dn;function ox(e){return typeof e=="string"&&e.length===25}function he(){if(!dn){let e=Z.get(Jn);return Promise.resolve(e||null)}return dn.getAccessToken()}var o0,qh=(e,t,r)=>o0(e,t,r),n0,zh=(e,t,r)=>n0(e,t,r),a0,Kh=(e,t,r,o)=>a0(e,t,r,o),i0,Yh=()=>i0(),s0,Jv=()=>s0(),l0,jv=({message:e})=>l0({message:e}),nx=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;Z.put(as,t);let r=new URL(window.location.href);r.searchParams.delete("privy_token"),window.history.pushState({},"",r)},ax=({config:e,...t})=>{if(typeof window<"u"&&["localhost","127.0.0.1"].indexOf(window.location.hostname)<0&&window.location.protocol!=="https:")throw new C("Embedded wallet is only available over HTTPS");if(!ox(t.appId))throw new C("Cannot initialize the Privy provider with an invalid Privy app ID");dn||(dn=new bs({appId:t.appId,appClientId:t.clientId,apiUrl:t.apiUrl}));let r=Object.assign({},e);return t.createPrivyWalletOnLogin!==void 0&&r.embeddedWallets?.createOnLogin===void 0&&(r.embeddedWallets||(r.embeddedWallets={}),r.embeddedWallets.createOnLogin=t.createPrivyWalletOnLogin?"users-without-wallets":"off"),t.createPrivyWalletOnLogin!==void 0&&e?.embeddedWallets?.createOnLogin&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),Gr(cf,{client:dn,clientConfig:r,legacyCreateEmbeddedWalletFlag:t.createPrivyWalletOnLogin,children:Gr(ix,{...t,client:dn})})},ix=e=>{let t=e.client,[r,o]=ut(!1),[n,a]=ut(!1),[i,s]=ut(!1),[l,d]=ut(null),[p,m]=ut([]),[h,g]=ut([]),[v,w]=ut(null),E=Va(p),[I,A]=ut(!1),[T,P]=ut(null),[S,_]=ut(!1),[U,D]=ut({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:Ht}),[H,B]=ut({status:"initial"}),[Y,K]=ut({status:"initial"}),[O,Q]=ut(null),L=_e(),Ge=Dl(),[pe,X]=ut(!0),[fe,re]=ut({}),[te,ae]=ut(null),[Je,ot]=ut(null),[ie,mt]=ut(!1),[jt,qr]=ut(!1),[Pe,ue]=ut(L.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),ke=Va(null),se=Va(null),W=Va(mf),[Ce,Tt]=ut(!1);t.onStoreToken=c=>{c&&N(W,"accessToken","onAccessTokenGranted",c)},t.onDeleteToken=()=>{d(null),s(!1),N(W,"accessToken","onAccessTokenRemoved")};let J=Va(null),oe=Va(null),sr=Va(!1),Me=c=>{P(c),setTimeout(()=>{o(!0)},15),t.createAnalyticsEvent({eventName:"modal_open",payload:{initialScreen:c}})},wt=c=>{L.embeddedWallets.createOnLogin!=="off"&&X(!0),Me(c)};co(()=>{let c=oa(l);if(!c||!O){w(null);return}let u={type:"solana",imported:!1,address:c.address,connectedAt:Date.now(),walletClientType:"privy",connectorType:"embedded",meta:{name:"Privy Wallet",icon:void 0,id:"io.privy.solana.wallet"},linked:!0,fund:()=>{throw new C("Funding is not supported for Solana embedded wallets.")},unlink:()=>{throw new C("Cannot unlink an embedded Solana wallet")},getProvider:async()=>new wp(O,c.address),signMessage:async f=>{let y=await he();if(!y||!O)throw new C("Must have valid access token and Privy wallet to send transaction","must_be_authenticated");let{response:b}=await O.rpcSolana({accessToken:y,publicKey:u.address,request:{method:"signMessage",params:{message:Buffer.from(f).toString("base64")}}});return Buffer.from(b.data.signature,"base64")},async sendTransaction(f,y,b){let{signature:M}=await Rm({transaction:f,connection:y,transactionOptions:b,wallet:this});return M},signTransaction:async f=>{let y=await he();if(!y||!O)throw new C("Must have valid access token and Privy wallet to send transaction","must_be_authenticated");return await cm({tx:f,accessToken:y,walletProxy:O}),f},loginOrLink:async()=>{throw new C("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{w(null)},isConnected:async()=>!0};w(u)},[O,l]),co(()=>{if(!l){t.connectors?.removeEmbeddedWalletConnectors();return}let c=Be(l),u=Mp(l),f=Ml(l);if((!c||!u.length)&&t.connectors?.removeEmbeddedWalletConnectors(),f||t.connectors?.removeImportedWalletConnector(),!t.connectors){console.debug("Failed to add embedded wallet connector: Client connectors not initialized");return}if(!O){console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized");return}c&&t.connectors.addEmbeddedWalletConnectors({walletProxy:O,rootWallet:c,embeddedWallets:u,defaultChain:L.defaultChain,appId:e.appId}),f&&t.connectors.addImportedWalletConnector(O,f.address,L.defaultChain,e.appId)},[O,l]),co(()=>{O&&Je?.(O)},[O]),co(()=>{(async()=>{if(!L.customAuth?.enabled){ue({status:"not-enabled"});return}X(!0),ue({status:"loading"});let{getCustomAccessToken:u,isLoading:f}=L.customAuth;if(!(!n||f))try{let y=await u();if(!y&&i){await qa.logout(),ue({status:"done"}),N(W,"customAuth","onUnauthenticated");return}if(!y){ue({status:"done"});return}if(i){ue({status:"done"});return}t.startAuthFlow(new Ja(y));let{user:b,isNewUser:M}=await t.authenticate();if(!b){await qa.logout(),ue({status:"error",error:new C("Failed to sync with custom auth provider")}),N(W,"customAuth","onUnauthenticated");return}M!==void 0&&N(W,"login","onComplete",b,M,!1,"custom",null),N(W,"customAuth","onAuthenticated",{user:b}),ue({status:"done"}),d(b||null),A(M||!1),s(!0),qr(!0)}catch(y){throw console.warn(y),i&&(await qa.logout(),N(W,"customAuth","onUnauthenticated")),N(W,"login","onError",y.privyErrorCode||"unknown_auth_error"),ue({status:"error",error:y}),y}})()},[L.customAuth?.enabled,L.customAuth?.getCustomAccessToken,L.customAuth?.isLoading,n,i]),co(()=>{jt&&O&&l&&It(l,L.embeddedWallets.createOnLogin)&&(qr(!1),Tp(l,Ka).catch(console.error))},[jt&&O&&l]),co(()=>{if(L.externalWallets.solana.connectors)return L.externalWallets.solana.connectors.onMount(),()=>L.externalWallets.solana.connectors?.onUnmount()},[L.externalWallets.solana.connectors]),co(()=>{async function c(){let u=We(),f=lr();nx();let y=JA();t.initializeConnectorManager({walletConnectCloudProjectId:L.walletConnectCloudProjectId,rpcConfig:L.rpcConfig,chains:L.chains,defaultChain:L.defaultChain,store:y,walletList:L.appearance.walletList,shouldEnforceDefaultChainOnConnect:L.shouldEnforceDefaultChainOnConnect,externalWalletConfig:L.externalWallets,appName:L.name??"Privy"});let b;t.connectors?.on("connectorInitialized",()=>{b&&clearTimeout(b);let q=t.connectors.walletConnectors.length,$=t.connectors.walletConnectors.reduce((me,Ae)=>me+(Ae.initialized?1:0),0);$===q?Tt(!0):b=setTimeout(()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:$,expected:q}),Tt(!0)},1500)}),t.connectors?.initialize().then(()=>{Ga()});let M=await t.getAuthenticatedUser(),G=!!M;if(L.customAuth?.enabled||(s(!!M),M&&N(W,"login","onComplete",M,!1,!0,null,null),d(M)),u){oe.current=G?"link":"login";return}if(f&&!G){oe.current="login",wt("TELEGRAM_AUTH_SCREEN");return}ne.setReadyToTrue(!!M)}!n&&Ge&&c()},[t,te,n,Ge]),co(()=>{if(!n)return;if(!l){mt(!0);return}if(!!!l.linkedAccounts.find(f=>f.type==="wallet"&&f.walletClientType==="privy")){mt(!0);return}let u=!!p.find(f=>f.walletClientType==="privy");mt(u)},[n,l,p]);let We=()=>{let c=hs();if(c.inProgress&&c.popupFlow){if(window.opener.location.origin!==window.location.origin){window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."});return}if(c.authorizationCode==="error"){window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."});return}window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:c.stateCode,authorizationCode:c.authorizationCode});return}return c.inProgress&&$v(c.provider)&&!c.popupFlow&&(new BroadcastChannel(bp).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:c.stateCode,authorizationCode:c.authorizationCode}),window.close()),!c.inProgress||c.headless?!1:(t.startAuthFlow(new Ro(c)),wt("AWAITING_OAUTH_SCREEN"),!0)},lr=()=>{let c=Hh();if(!c||!L.loginMethods.telegram||!L.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let u=new ti;return t.startAuthFlow(u),c.flowType==="login-url"&&(u.meta.telegramWebAppData=void 0,u.meta.telegramAuthResult={id:c.id,first_name:c.first_name,last_name:c.last_name,auth_date:c.auth_date,username:c.username,photo_url:c.photo_url,hash:c.hash}),c.flowType==="web-app"&&(u.meta.telegramAuthResult=void 0,u.meta.telegramWebAppData={query_id:c.query_id,user:c.user,auth_date:c.auth_date,hash:c.hash,chat_instance:c.chat_instance,chat_type:c.chat_type,start_param:c.start_param}),!0},Ar=async(c,u,f,y)=>{let b=await t.connectors?.createEthereumWalletConnector(c,u)||null;cr(b,u,f,y)};async function cr(c,u,f,y){if(c)D({status:"disconnected",connectedWallet:null,connectError:null,connector:c,connectRetry:Ht});else return D({status:"disconnected",connectedWallet:null,connectError:new Le("Unable to connect to wallet."),connector:null,connectRetry:Ht}),y?.(null,f);c instanceof ho&&u&&await c.resetConnection(u),D({connector:c,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>cr(c,u,f,y)});try{let b=await c.connect({showPrompt:!0});if((!b||fo(b))&&L.shouldEnforceDefaultChainOnConnect&&!L.chains.find(M=>M.id===Number(b?.chainId.replace("eip155:","")))&&!(b?.connectorType==="wallet_connect_v2"&&b?.walletClientType==="metamask")){D(M=>({...M,connector:c,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:Ht}));try{await b?.switchChain(L.defaultChain.id),b&&(b.chainId=za(Zn(L.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${L.defaultChain.id}`)}}return D(M=>({...M,status:"connected",connectedWallet:b,connectError:null,connectRetry:Ht})),b&&N(W,"connectWallet","onSuccess",b),y?.(b,f)}catch(b){return b instanceof pr?(console.warn(b.cause?b.cause:b.message),N(W,"connectWallet","onError",b.privyErrorCode||"generic_connect_wallet_error")):(console.warn(b),N(W,"connectWallet","onError","unknown_connect_wallet_error")),D(M=>({...M,status:"disconnected",connectedWallet:null,connectError:b})),y?.(null,f)}}let Rt=async(c,u,f)=>{if(c===null||!fo(c))return;let y=new Jo(c,t,u,f);t.startAuthFlow(y)},zr=async(c,u)=>{if(c===null||!Dp(c))return;let f=new sa(c,t,u);t.startAuthFlow(f)},Ga=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_connector"),f=c.get("privy_wallet_client");if(!u||!f)return;if(f==="phantom"&&!un()&&wt("LOGIN_FAILED_SCREEN"),!t.connectors)throw new C("Connector not initialized");Me("AWAITING_CONNECTION");let y=new URL(window.location.href);y.searchParams.delete("privy_connector"),y.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",y),Ar(u,f,void 0,Rt)};co(()=>{n&&i&&l===null&&t.getAuthenticatedUser().then(d)},[n,i,l,t]);let je=c=>{if(!i)throw N(W,"linkAccount","onError","must_be_authenticated",{linkMethod:c}),new C("User must be authenticated before linking an account.")},nt=()=>{je("siwe"),J.current="siwe",oe.current="link",Me("LINK_WALLET_SCREEN")},Cl=c=>{if(!i||!l)return!1;if(c.walletClientType==="privy")return!0;for(let u of l.linkedAccounts)if(u.type==="wallet"&&u.address===c.address&&u.walletClientType!=="privy")return!0;return!1},xm=async c=>{if(!t.connectors)throw new C("Connector not initialized");let u;if(c.type==="ethereum"?u=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null:u=t.connectors.findSolanaWalletConnector(c.connectorType,c.walletClientType)||null,D(f=>({...f,connector:u,status:"connected",connectedWallet:c,connectError:null,connectRetry:Ht})),L.captchaEnabled&&!i){let f={callback:y=>fo(c)?Rt(c,y):zr(c,y),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"};re({captchaModalData:f}),wt("CAPTCHA_SCREEN")}else fo(c)?await Rt(c):await zr(c),wt("AWAITING_CONNECTION")},f0=async(c,u)=>{let{signedUrl:f,externalTransactionId:y}=await I2(t,c,u??{},L.appearance.palette,L.fundingMethodConfig?.moonpay.useSandbox??!1);return{signedUrl:f,externalTransactionId:y}},vl=()=>{m(c=>{let u=t.connectors?.wallets.filter(fo).map(f=>({...f,linked:Cl(f),loginOrLink:async()=>{if(!await f.isConnected())throw new C("Wallet is not connected");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new C("Cannot link or login with embedded wallet");xm(f)},fund:async y=>{await ne.fundWallet(f.address,y)},unlink:async()=>{if(!i)throw new C("User is not authenticated.");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new C("Cannot unlink an embedded wallet");let y=await t.unlinkEthereumWallet(f.address);d(y)}}))||[];return gs(c,u)?c:u}),g(c=>{let u=t.connectors?.wallets.filter(Dp).map(f=>({...f,linked:Cl(f),loginOrLink:async()=>{if(!await f.isConnected())throw new C("Wallet is not connected");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new C("Cannot link or login with embedded wallet");xm(f)},fund:async y=>{throw new C("Funding not supported for Solana wallets")},unlink:async()=>{if(!i)throw new C("User is not authenticated.");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new C("Cannot unlink an embedded wallet");let y=await t.unlinkSolanaWallet(f.address);d(y)}}))||[];return gs(c,u)?c:u})};co(()=>{vl()},[l?.linkedAccounts,i,n]),co(()=>{if(n){if(!t.connectors)throw new C("Connector not initialized");vl(),t.connectors.on("walletsUpdated",vl)}},[n]);let h0=c=>{c&&"target"in c&&c&&(c=void 0),re({externalConnectWallet:{walletList:c?.walletList&&c?.walletList.length>0?c.walletList:void 0,suggestedAddress:c?.suggestedAddress}}),Me(i?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};co(()=>{if(!p[0])return;let c=p[0],u=E.current.find(y=>y.address===c.address),f;if(c.walletClientType==="privy"?f=l?.linkedAccounts.find(y=>y.type==="wallet"&&y.address===c.address&&y.walletClientType==="privy"):f=l?.linkedAccounts.find(y=>y.type==="wallet"&&y.address===c.address&&y.walletClientType!=="privy"),!u&&f){let y=Object.assign({},l);y.wallet=f&&{address:f.address,chainType:f.chainType,chainId:f.chainId,walletClient:f.walletClient,walletClientType:f.walletClientType,connectorType:f.connectorType,imported:f.imported,walletIndex:f.walletIndex},d(y)}E.current=p},[p]);let Tp=async(c,u,f)=>{let y=Be(c);if(y&&!f?.createAdditional)throw N(W,"createWallet","onError","embedded_wallet_already_exists"),new Error("User already has an embedded wallet.");let[b,M]=await Promise.all([ne.initializeWalletProxy(u),he()]);if(!b&&L.customAuth?.enabled)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!b||!M||L.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return new Promise((G,q)=>{X(!0),re({createWallet:{onSuccess:me=>{N(W,"createWallet","onSuccess",me),G(me)},onFailure:me=>{N(W,"createWallet","onError","unknown_embedded_wallet_error"),q(me)},callAuthOnSuccessOnClose:!1}}),Me("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{if(!y)await b.create({accessToken:M});else{let $=Mp(c),Ae=($?.length?Math.max(...$.map(Re=>Re.walletIndex)):y.walletIndex)+1;await ne.recoverEmbeddedEthereumWallet(),await b.createAdditional({accessToken:M,primaryWalletAddress:y?.address,hdWalletIndex:Ae})}let G=await ne.refreshUser(),q=Be(G);if(!q)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return N(W,"createWallet","onSuccess",q),q}},y0=c=>{if(!L.chains.map(u=>u.id).includes(c))throw new Le(`Chain ID ${c} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},km=(c,u,f,y)=>new Promise(async(b,M)=>{let{requesterAppId:G}=u||{};if(!i||!l){N(W,"sendTransaction","onError","must_be_authenticated"),M(new Error("User must be authenticated before signing with a Privy wallet"));return}let q=y??Be(l)?.address;if(!q)throw new C("User must have an embedded wallet to send a transaction.");let{signingWallet:$,rootWallet:me}=Wl(l,q);if(!me||!$){N(W,"sendTransaction","onError","embedded_wallet_not_found"),M(new Error("Must have a Privy wallet before signing"));return}X(!0);let Ae=Mm.wallets.find(Bt=>Bt.walletClientType==="privy"&&Ha(Bt.address)===Ha($.address)),Re=await Ae?.getEthereumProvider();if(!Ae||!Re)throw new C(`Cannot sendTransaction before embedded wallet ${$.address} is connected`);let Ft=c.chainId?Number(c.chainId):Fl(Ae.chainId);y0(Ft);let _t=Object.assign({},c,{chainId:Ft}),ft=async()=>{let Bt=await he();if(!Bt||!O){N(W,"sendTransaction","onError","embedded_wallet_not_found"),M(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await ne.recoverEmbeddedEthereumWallet()){N(W,"sendTransaction","onError","unknown_connect_wallet_error"),M(new Error("Unable to connect to wallet"));return}let pn=Kr(_t.chainId,L.chains,L.rpcConfig,{appId:e.appId}),po=await rx($.address,_t,pn);if(L.embeddedWallets.noPromptOnSignature||sr.current){let{totalGasEstimate:g0}=await tx(po,pn),{hasSufficientFunds:C0}=await hp($.address,po,g0,pn);if(!C0)throw new Wt(new Jr("Wallet has insufficient funds for this transaction.",ex.E32603_DEFAULT_INTERNAL_ERROR.eipCode))}let El=await fp({accessToken:Bt,rootWallet:me,transactingWallet:$,walletProxy:O,transactionRequest:po,provider:pn,requesterAppId:G});N(W,"sendTransaction","onSuccess",El),b(El)}catch(Qn){N(W,"sendTransaction","onError","transaction_failure"),M(Qn)}};if(L.embeddedWallets.noPromptOnSignature||sr.current)u&&L.embeddedWallets.noPromptOnSignature&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),ft();else{let Bt={transactionRequest:_t,transactingWallet:$,rootWallet:me,onSuccess:po=>{N(W,"sendTransaction","onSuccess",po),b(po)},onFailure:po=>{N(W,"sendTransaction","onError","transaction_failure"),M(po)},uiOptions:u||{},fundWalletConfig:f,requesterAppId:G},Qn={address:me.address,onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:po=>{N(W,"sendTransaction","onError","unknown_connect_wallet_error"),M(po)}},pn=um({address:$.address,appConfig:L,fundWalletConfig:f,chainIdOverride:_t.chainId,comingFromSendTransactionScreen:!0});re({connectWallet:Qn,sendTransaction:Bt,funding:pn}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),Rm=({transaction:c,connection:u,transactionOptions:f,uiOptions:y,wallet:b})=>new Promise(async(M,G)=>{let{requesterAppId:q}=y||{};if(!i||!l){N(W,"sendSolanaTransaction","onError","must_be_authenticated"),G(new C("User must be authenticated before signing with a Privy wallet","must_be_authenticated"));return}let $=b?l.linkedAccounts.find(Ft=>Ft.type==="wallet"&&Ft.address===b.address):oa(l);if(!$){N(W,"sendSolanaTransaction","onError","embedded_wallet_not_found"),G(new C("Must have a Privy wallet before signing","embedded_wallet_not_found"));return}X(!0);let me=b??v,Ae=await me?.isConnected();if(!me||!Ae)throw N(W,"sendSolanaTransaction","onError","embedded_wallet_not_found"),new C(`Cannot sendSolanaTransaction before embedded wallet ${$.address} is connected`,"embedded_wallet_not_found");let Re=async()=>{let Ft=await he();if(!Ft||!O){N(W,"sendSolanaTransaction","onError","embedded_wallet_not_found"),G(new C("Must have valid access token and Privy wallet to send transaction","embedded_wallet_not_found"));return}try{if(!await ne.recoverEmbeddedSolanaWallet()){N(W,"sendSolanaTransaction","onError","unknown_connect_wallet_error"),G(new C("Unable to connect to wallet","unknown_connect_wallet_error"));return}if(L.embeddedWallets.noPromptOnSignature){let{instructions:pn}=await Zd(c,u);pn.every(El=>El.hasFunds)||(N(W,"sendSolanaTransaction","onError","insufficient_balance"),G(new C("Solana wallet has insufficient funds for this transaction.","insufficient_balance")))}let{signature:ft,receipt:Bt}=await dp({accessToken:Ft,tx:c,connection:u,walletProxy:O,transactionOptions:f}),Qn=Xd(ft,Bt);N(W,"sendSolanaTransaction","onSuccess",Qn),M(Qn)}catch(_t){N(W,"sendSolanaTransaction","onError","transaction_failure"),G(_t)}};if(L.embeddedWallets.noPromptOnSignature)y&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),Re();else{let Ft={transactionRequest:c,connection:u,transactionOptions:f,transactingWallet:$,onSuccess:ft=>{N(W,"sendSolanaTransaction","onSuccess",ft),M(ft)},onFailure:ft=>{N(W,"sendSolanaTransaction","onError","transaction_failure"),G(ft)},uiOptions:y||{},requesterAppId:q},_t={address:$.address,onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN",onFailure:ft=>{N(W,"sendSolanaTransaction","onError","unknown_connect_wallet_error"),G(ft)}};re({connectWallet:_t,sendSolanaTransaction:Ft,funding:void 0}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}});function _m(){return new Promise(async(c,u)=>{let f=await he();if(!f||!O)throw new Error("Must have valid access token to enroll in MFA");try{await O.verifyMfa({accessToken:f}),c()}catch(y){u(y)}})}let wl=c=>c?.linkedAccounts.filter(u=>u.latestVerifiedAt!==null&&!(u.type==="wallet"&&u.walletClientType==="privy")).sort((u,f)=>f.latestVerifiedAt.getTime()-u.latestVerifiedAt.getTime())[0],dr=c=>{let u=l?.linkedAccounts.filter(b=>b.type===c).length??0,{displayName:f,loginMethod:y}=Nn(c);if(c==="passkey"&&u>=5||c!=="passkey"&&u>=1)throw N(W,"linkAccount","onError","cannot_link_more_of_type",{linkMethod:y}),new C(`User already has an account of type ${f} linked.`)};async function Im({showAutomaticRecovery:c=!1,legacySetWalletPasswordFlow:u=!1}){P(null);let f=u?"setWalletPassword":"setWalletRecovery";if(!i||!l)throw N(W,f,"onError","must_be_authenticated"),new Error("User must be authenticated before adding recovery method to Privy wallet");let y=Be(l);if(!y||!O)throw N(W,f,"onError","embedded_wallet_not_found"),new Error("Must have a Privy wallet to add a recovery method");if(oa(l))throw new Error("Cannot set user-controlled recovery for user with Solana.");try{await _m()}catch(M){throw N(W,f,"onError","missing_or_invalid_mfa"),M}return new Promise((M,G)=>{X(!0);let q={onSuccess:Re=>{N(W,f,"onSuccess","user-passcode",Re),M(Re)},onFailure:Re=>{N(W,f,"onError","user_exited_set_password_flow"),G(Re)},callAuthOnSuccessOnClose:!1},$=y.recoveryMethod==="user-passcode",Ae={onCompleteNavigateTo:Qc({walletAction:"update",availableRecoveryMethods:L.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:u,isResettingPassword:$,showAutomaticRecovery:c}),shouldForceMFA:!1,onFailure:Re=>{N(W,f,"onError","unknown_connect_wallet_error"),G(Re)}};re({setWalletPassword:q,createWallet:q,connectWallet:Ae,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:$}}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")})}async function bl({appId:c,action:u}){let f=await he();if(u==="link"&&!f)throw N(W,"linkAccount","onError","must_be_authenticated",{linkMethod:`privy:${c}`}),new C("User must be authenticated before linking an account.");if(u==="login"&&f)throw N(W,"login","onError","unknown_auth_error"),new C("Attempted to log in, but user is already logged in. Use a `link` helper instead.");J.current=`privy:${c}`,oe.current=u;let y=window.open(void 0,void 0,Qs({w:440,h:680}));return t.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:c}}),new Promise(async(b,M)=>{let{name:G,logoUrl:q}=await vd({api:t.api,providerAppId:c,requesterAppId:L.id});re({crossAppAuth:{appId:c,name:G,logoUrl:q,action:u,popup:y,onSuccess:b,onError:M}}),wt("CROSS_APP_AUTH_SCREEN")})}let qa={ready:n,authenticated:i,user:l,walletConnectors:t.connectors||null,connectWallet:h0,importWallet:async({privateKey:c})=>{je("siwe");let[u,f]=await Promise.all([ne.initializeWalletProxy(15e3),he()]);if(u&&f){await u.import({privateKey:c,accessToken:f});let y=await ne.refreshUser(),b=Ml(y);if(!b)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to import wallet");return N(W,"createWallet","onSuccess",b),b}else throw new C("User is not authenticated")},linkWallet:nt,startCrossAppAuthFlow:bl,linkEmail:()=>{je("email"),dr("email"),J.current="email",oe.current="link",Me("LINK_EMAIL_SCREEN")},linkPhone:()=>{je("sms"),dr("phone"),J.current="sms",oe.current="link",Me("LINK_PHONE_SCREEN")},linkGoogle:async()=>{je("google"),dr("google_oauth"),oe.current="link",await ne.initLoginWithOAuth("google")},linkTwitter:async()=>{je("twitter"),dr("twitter_oauth"),oe.current="link",await ne.initLoginWithOAuth("twitter")},linkDiscord:async()=>{je("discord"),dr("discord_oauth"),oe.current="link",await ne.initLoginWithOAuth("discord")},linkGithub:async()=>{je("github"),dr("github_oauth"),oe.current="link",await ne.initLoginWithOAuth("github")},linkSpotify:async()=>{je("spotify"),dr("spotify_oauth"),oe.current="link",await ne.initLoginWithOAuth("spotify")},linkInstagram:async()=>{je("instagram"),dr("instagram_oauth"),oe.current="link",await ne.initLoginWithOAuth("instagram")},linkTiktok:async()=>{je("tiktok"),dr("tiktok_oauth"),oe.current="link",await ne.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{je("linkedin"),dr("linkedin_oauth"),oe.current="link",await ne.initLoginWithOAuth("linkedin")},linkApple:async()=>{je("apple"),dr("apple_oauth"),oe.current="link",await ne.initLoginWithOAuth("apple")},linkPasskey:async()=>{je("passkey"),dr("passkey"),await ne.initLinkWithPasskey(),Me("LINK_PASSKEY_SCREEN")},linkTelegram:async()=>{je("telegram"),dr("telegram"),oe.current="link",J.current="telegram",await ne.initLoginWithTelegram(),Me("TELEGRAM_AUTH_SCREEN")},linkFarcaster:async()=>{je("farcaster"),dr("farcaster"),await ne.initLoginWithFarcaster(),oe.current="link",J.current="farcaster",Me("AWAITING_FARCASTER_CONNECTION")},updateEmail:()=>{if(je("email"),!l?.email)throw new C("User does not have an email linked to their account.");oe.current="link",J.current="email",Me("UPDATE_EMAIL_SCREEN")},updatePhone:()=>{if(je("sms"),!l?.phone)throw new C("User does not have a phone number linked to their account.");oe.current="link",J.current="sms",Me("UPDATE_PHONE_SCREEN")},login:async c=>{c&&"target"in c&&c&&(c=void 0);let u="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!n){let f=await new Promise(y=>{ae(b=>y.bind(b))});if(ae(null),f){console.warn(u);return}}if(l&&!l.isGuest){console.warn(u);return}oe.current="login",re({login:c}),wt("LANDING")},connectOrCreateWallet:async()=>{if(n||(await new Promise(c=>{ae(()=>c)}),ae(null)),i){console.warn("User must be unauthenticated to `connectOrCreateWallet`");return}wt("CONNECT_OR_CREATE")},logout:async()=>{if(l&&t.clearProviderAcccessTokens(l),P(null),await t.logout(),l&&O)try{await O.clearMfa({userId:l.id})}catch{}d(null),s(!1),N(W,"logout","onSuccess"),oe.current=null,J.current=null,o(!1),Z.del(is),Z.del(_l(L.id))},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{if(!l||!l.wallet)return new st;let c=p.find(f=>l.wallet&&f.address===l.wallet.address),u=t.connectors?.walletConnectors.find(f=>f.wallets.find(y=>y.address===c?.address));return!c||!u?new st:u.proxyProvider},getEthersProvider:()=>{if(!l||!l.wallet)return new Am(new Io(new st));let c=p.find(f=>l.wallet&&f.address===l.wallet.address),u=t.connectors?.walletConnectors.find(f=>f.wallets.find(y=>y.address===c?.address));return!c||!u?new Am(new Io(new st)):new Am(new Io(u.proxyProvider))},getWeb3jsProvider:()=>{if(!l||!l.wallet)return new yn(new st);let c=p.find(f=>l.wallet&&f.address===l.wallet.address),u=t.connectors?.walletConnectors.find(f=>f.wallets.find(y=>y.address===c?.address));return!c||!u?new yn(new st):new yn(u.proxyProvider)},unlinkWallet:async c=>{let u;return c.startsWith("0x")?u=await t.unlinkEthereumWallet(c):u=await t.unlinkSolanaWallet(c),d(u),u},unlinkEmail:async c=>{let u=await t.unlinkEmail(c);return d(u),u},unlinkPhone:async c=>{let u=await t.unlinkPhone(c);return d(u),u},unlinkGoogle:async c=>{let u=await t.unlinkOAuth("google",c);return d(u),u},unlinkTwitter:async c=>{let u=await t.unlinkOAuth("twitter",c);return d(u),u},unlinkDiscord:async c=>{let u=await t.unlinkOAuth("discord",c);return d(u),u},unlinkGithub:async c=>{let u=await t.unlinkOAuth("github",c);return d(u),u},unlinkSpotify:async c=>{let u=await t.unlinkOAuth("spotify",c);return d(u),u},unlinkInstagram:async c=>{let u=await t.unlinkOAuth("instagram",c);return d(u),u},unlinkTiktok:async c=>{let u=await t.unlinkOAuth("tiktok",c);return d(u),u},unlinkLinkedIn:async c=>{let u=await t.unlinkOAuth("linkedin",c);return d(u),u},unlinkApple:async c=>{let u=await t.unlinkOAuth("apple",c);return d(u),u},unlinkFarcaster:async c=>{let u=await t.unlinkFarcaster(c);return d(u),u},unlinkTelegram:async c=>{let u=await t.unlinkTelegram(c);return d(u),u},unlinkPasskey:async c=>{let u=await t.unlinkPasskey(c);return d(u),u},unlinkCrossAppAccount:async({subject:c})=>{let u=l?.linkedAccounts.find(y=>y.type==="cross_app"&&y.subject===c)?.providerApp;if(!u)throw new C("Invalid subject");t.storeProviderAccessToken(u.id,null);let f=await t.unlinkOAuth(`privy:${u.id}`,c);return d(f),f},setActiveWallet:async c=>{let u=p.find(y=>Ha(y.address)===Ha(c)),f=l?.linkedAccounts.find(y=>y.type==="wallet"&&Ha(y.address)===Ha(c));if(!u||!await u.isConnected())re({externalConnectWallet:{suggestedAddress:c}}),nt();else if(!u.linked)u.loginOrLink();else{let y=Object.assign({},l);y.wallet=f&&{address:f.address,chainType:f.chainType,chainId:f.chainId,walletClient:f.walletClient,walletClientType:f.walletClientType,connectorType:f.connectorType,imported:f.imported,walletIndex:f.walletIndex},d(y)}},forkSession:()=>t.forkSession(),createWallet:async c=>{if(c&&"target"in c&&c&&(c=void 0),!i||!l)throw N(W,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return Tp(l,15e3,c)},setWalletRecovery:async c=>Im({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:c?.showAutomaticRecovery??!1}),setWalletPassword:async()=>Im({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(c,u,f)=>new Promise(async(y,b)=>{let{requesterAppId:M}=u||{};if(!i||!l){N(W,"signMessage","onError","must_be_authenticated"),b(new Error("User must be authenticated before signing with a Privy wallet"));return}let G=f??Be(l)?.address;if(!G)throw new C("User must have an embedded wallet to sign a message.");let{signingWallet:q,rootWallet:$}=Wl(l,G);if(!q||!$){N(W,"signMessage","onError","embedded_wallet_not_found"),b(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){N(W,"signMessage","onError","invalid_message"),b(new Error("Message must be a non-empty string"));return}X(!0);let me=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let Ae=await he();if(!O||!Ae)throw new Error("Unable to connect to wallet");if(!await ne.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:q.address,requesterAppId:M}});let{response:Ft}=await O.rpc({accessToken:Ae,address:$.address,hdWalletIndex:q.walletIndex??void 0,requesterAppId:M,request:{method:"personal_sign",params:[c,q.address]}}),_t=Ft.data;return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:q.address,requesterAppId:M}}),_t};if(L.embeddedWallets.noPromptOnSignature||sr.current){u&&L.embeddedWallets.noPromptOnSignature&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let Ae=await me();N(W,"signMessage","onSuccess",Ae),y(Ae)}catch(Ae){N(W,"signMessage","onError","unable_to_sign"),b(Ae??new Wt("Unable to sign message"))}}else{let Ft={method:"personal_sign",data:c,confirmAndSign:me,onSuccess:ft=>{N(W,"signMessage","onSuccess",ft),y(ft)},onFailure:ft=>{N(W,"signMessage","onError","unable_to_sign"),b(ft)},uiOptions:u||{}},_t={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:ft=>{N(W,"signMessage","onError","unknown_connect_wallet_error"),b(ft)},address:$.address};re({signMessage:Ft,connectWallet:_t}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),signTypedData:(c,u,f)=>new Promise(async(y,b)=>{let{requesterAppId:M}=u||{};if(!i||!l){N(W,"signTypedData","onError","must_be_authenticated"),b(new Error("User must be authenticated before signing with a Privy wallet"));return}let G=f??Be(l)?.address;if(!G)throw new C("User must have an embedded wallet to sign a message.");let{signingWallet:q,rootWallet:$}=Wl(l,G);if(!$||!q){N(W,"signTypedData","onError","embedded_wallet_not_found"),b(new Error("Must have a Privy wallet before signing"));return}X(!0);let me=ns(c),Ae=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let Re=await he();if(!O||!Re)throw new Error("Unable to connect to wallet");if(!await ne.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:q.address,requesterAppId:M}});let{response:_t}=await O.rpc({accessToken:Re,address:$.address,hdWalletIndex:q.walletIndex??void 0,requesterAppId:M,request:{method:"eth_signTypedData_v4",params:[q.address,me]}}),ft=_t.data;return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:q.address,requesterAppId:M}}),ft};if(sr.current||L.embeddedWallets.noPromptOnSignature||(L.legacyWalletUiConfig??!1)){u&&L.embeddedWallets.noPromptOnSignature&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let Re=await Ae();N(W,"signTypedData","onSuccess",Re),y(Re)}catch(Re){N(W,"signTypedData","onError","unable_to_sign"),b(Re??new Wt("Unable to sign message"))}}else{let _t={method:"eth_signTypedData_v4",data:me,confirmAndSign:Ae,onSuccess:Bt=>{N(W,"signTypedData","onSuccess",Bt),y(Bt)},onFailure:Bt=>{N(W,"signTypedData","onError","unable_to_sign"),b(Bt)},uiOptions:u||{}},ft={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Bt=>{N(W,"signMessage","onError","unknown_connect_wallet_error"),b(Bt)}};re({signMessage:_t,connectWallet:ft}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:async(c,u,f,y)=>{let M=await(await km(c,u,f,y)).wait();return yp(M)},sendSolanaTransaction:async(c,u,f,y)=>await Rm({transaction:c,connection:u,transactionOptions:y,uiOptions:f,wallet:v??void 0}),exportWallet:c=>new Promise(async(u,f)=>{if(!i||!l){f(new Error("User must be authenticated before exporting their Privy wallet"));return}c&&"target"in c&&c&&(c=void 0);let y=c?.address,b=l.linkedAccounts.filter(me=>me.type==="wallet"&&me.walletClientType==="privy"&&me.chainType==="ethereum"),M=y?b.find(me=>me.address===Ha(y)):b.find(me=>!me.imported)||b[0];if(!M){f(new Error("Must have a Privy wallet before exporting"));return}X(!0);let G={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:f,address:M.address,shouldForceMFA:!0};if(re(fe),!await he()||!O){f(new Error("Must have valid access token to enroll in MFA"));return}if(!O){f(new Error("Must have a Privy wallet before exporting"));return}let $={appId:e.appId,appClientId:e.clientId,origin:t.apiUrl,wallet:M,onSuccess:u,onFailure:f};re({keyExport:$,connectWallet:G}),Me("EMBEDDED_WALLET_CONNECTING_SCREEN")}),promptMfa:_m,async init(c){switch(c){case"sms":await t.initMfaSmsVerification();return;case"passkey":return await t.initMfaPasskeyVerification();case"totp":return;default:throw new Error(`Unsupported MFA method: ${c}`)}},async submit(c,u){switch(c){case"totp":case"sms":if(typeof u!="string")throw new C("Invalid MFA code");ke.current?.resolve({mfaMethod:c,mfaCode:u,relyingParty:window.origin}),await new Promise((M,G)=>{se.current={resolve:M,reject:G}});break;case"passkey":if(typeof u=="string")throw new C("Invalid authenticator response");let y=await(await import("@simplewebauthn/browser")).startAuthentication(u),b=t0(y);ke.current?.resolve({mfaMethod:c,mfaCode:b,relyingParty:window.origin}),await new Promise((M,G)=>{se.current={resolve:M,reject:G}});break;default:throw ke.current?.reject(new C("Unsupported MFA method")),new C(`Unsupported MFA method: ${c}`)}},cancel(){ke.current?.reject(new C("MFA canceled"))},async initEnrollmentWithSms(c){let u=await he();if(!u||!O)throw new Error("Must have valid access token to enroll in MFA");await O.initEnrollMfa({method:"sms",accessToken:u,phoneNumber:c.phoneNumber})},enrollInMfa(c){return new Promise((u,f)=>{if(!c){ne.closePrivyModal(),u();return}L.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."),re({mfaEnrollmentFlow:{mfaMethods:L.mfa.methods,onSuccess:u,onFailure:f}}),Me("MFA_ENROLLMENT_FLOW_SCREEN")})},async initEnrollmentWithTotp(){let c=await he();if(!c||!O)throw new Error("Must have valid access token to enroll in MFA");let u=await O.initEnrollMfa({method:"totp",accessToken:c});return{secret:u.secret,authUrl:u.authUrl}},async submitEnrollmentWithSms(c){let u=await he();if(!u||!O)throw new Error("Must have valid access token to enroll in MFA");await O.submitEnrollMfa({method:"sms",accessToken:u,phoneNumber:c.phoneNumber,code:c.mfaCode});let f=await t.getAuthenticatedUser();d(f)},async submitEnrollmentWithTotp(c){let u=await he();if(!u||!O)throw new Error("Must have valid access token to enroll in MFA");await O.submitEnrollMfa({method:"totp",accessToken:u,code:c.mfaCode});let f=await t.getAuthenticatedUser();d(f)},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:c}){let u=await he();if(!u||!O)throw new Error("Must have valid access token to enroll in MFA");await O.submitEnrollMfa({method:"passkey",accessToken:u,credentialIds:c});let f=await t.getAuthenticatedUser();d(f)},async unenroll(c){let u=await he();if(!u||!O)throw new Error("Must have valid access token to remove MFA");c==="passkey"?await O.submitEnrollMfa({method:"passkey",accessToken:u,credentialIds:[]}):await O.unenrollMfa({method:c,accessToken:u});let f=await t.getAuthenticatedUser();d(f)},requestFarcasterSignerFromWarpcast:async()=>{let c=await he(),u=l?.linkedAccounts.find(b=>b.type==="wallet"&&b.walletClientType==="privy");if(!c)throw new Error("Must have valid access token to connect with Farcaster");if(!O||!u)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!l?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await ne.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");let y=await O.initFarcasterSigner({address:u.address,hdWalletIndex:null,accessToken:c,mfaCode:null,mfaMethod:null,relyingParty:window.origin});if(y.status==="approved"){let b=await t.getAuthenticatedUser();d(b||l||null)}re({farcasterSigner:y}),Me("AWAITING_FARCASTER_SIGNER")},getFarcasterSignerPublicKey:async()=>{let c=await he(),u=l?.linkedAccounts.find(b=>b.type==="wallet"&&b.walletClientType==="privy");if(!c)throw new Error("Must have valid access token to connect with Farcaster");if(!O||!u)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!l?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await ne.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");if(!l.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster signer public key to sign");return(b=>Uint8Array.from(b.match(/.{1,2}/g).map(M=>parseInt(M,16))))(l.farcaster.signerPublicKey.slice(2))},signFarcasterMessage:async c=>{let u=await he(),f=l?.linkedAccounts.find(G=>G.type==="wallet"&&G.walletClientType==="privy");if(!u)throw new Error("Must have valid access token to connect with Farcaster");if(!O||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!l?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await ne.recoverEmbeddedEthereumWallet())throw new Error("Unable to connect to wallet");if(!l.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster signer public key to sign");let b=await import("@simplewebauthn/browser"),M=await O.signFarcasterMessage({address:f.address,hdWalletIndex:null,accessToken:u,mfaCode:null,mfaMethod:null,payload:{hash:b.bufferToBase64URLString(c)},fid:BigInt(l.farcaster.fid),relyingParty:window.origin});return new Uint8Array(b.base64URLStringToBuffer(M.signature))},createGuestAccount:async()=>{if(l&&!l.isGuest)throw new Error("User cannot already be authenticated to create a guest account");return l?.isGuest?l:ne.loginWithGuestAccountFlow()},isHeadlessOAuthLoading:S,loginWithCode(c){return ne.loginWithCode(c)},initLoginWithEmail(c){return ne.initLoginWithEmail(c)},initLoginWithSms(c){return ne.initLoginWithSms(c)},otpState:H,fundWallet(c,u){return ne.fundWallet(c,u)},initLoginWithHeadlessOAuth(c,u){return ne.initLoginWithHeadlessOAuth(c,u)},loginWithHeadlessOAuth(c){return ne.loginWithHeadlessOAuth(c)},generateSiweMessage({address:c,chainId:u}){return ne.generateSiweMessage({address:c,chainId:u})},linkWithSiwe({message:c,signature:u,chainId:f,walletClientType:y,connectorType:b}){return je("siwe"),ne.linkWithSiwe({message:c,signature:u,chainId:f,walletClientType:y,connectorType:b})},signMessageWithCrossAppWallet(c,{address:u}){return wd({user:l,client:t,address:u,requesterAppId:L.id,request:{method:"personal_sign",params:[c,u]},reconnect:bl})},signTypedDataWithCrossAppWallet(c,{address:u}){let f=ns(c);return wd({user:l,client:t,address:u,requesterAppId:L.id,request:{method:"eth_signTypedData_v4",params:[u,f]},reconnect:bl})},sendTransactionWithCrossAppWallet(c,{address:u}){return wd({user:l,client:t,address:u,requesterAppId:L.id,request:{method:"eth_sendTransaction",params:[c]},reconnect:bl})},isModalOpen:r,mfaMethods:L.mfa.methods};o0=qa.signMessage,n0=qa.signTypedData,a0=async(...c)=>{let u=await km(...c);return L.embeddedWallets.waitForTransactionConfirmation&&await u.wait(),u};let ne=(()=>({isNewUserThisSession:I,pendingTransaction:null,walletConnectionStatus:U,connectors:t.connectors?.walletConnectors??[],solanaWallets:h,rpcConfig:L.rpcConfig,chains:L.chains,appId:e.appId,showFiatPrices:L.embeddedWallets.priceDisplay.primary!=="native-token",clientAnalyticsId:t.clientAnalyticsId,customAuthStatus:Pe,noPromptOnSignature:sr,nativeTokenSymbolForChainId:c=>L.chains.find(u=>u.id===Number(c))?.nativeCurrency.symbol,initializeWalletProxy:async c=>{if(O)return O;let u=new Promise(b=>{ot(()=>M=>b(M))}),f=new Promise(b=>setTimeout(()=>b(null),c)),y=await Promise.race([u,f]);return ot(null),y},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>t.authFlow?.meta,client:t,closePrivyModal:async(c={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let u=n&&i&&l,f;u&&J.current&&(f=wl(l)),oe.current==="login"?c.shouldCallAuthOnSuccess&&u&&J.current?(N(W,"login","onComplete",l,I,!1,J.current,f??null),e.onSuccess?.(l,I)):N(W,"login","onError","exited_auth_flow"):oe.current==="link"&&f&&(c.isSuccess&&u&&J.current?N(W,"linkAccount","onSuccess",l,J.current,f):J.current&&N(W,"linkAccount","onError","exited_link_flow",{linkMethod:J.current}));let y=T&&mm.includes(T),b=T==="ERROR_SCREEN"&&fe.errorModalData&&mm.includes(fe.errorModalData.previousScreen);if((y||b)&&fe.funding){let M=cv[T]??null,G=Kr(fe.funding.chain.id,L.chains,L.rpcConfig,{appId:e.appId}),q;try{q=(await G.getBalance(fe.funding.address)).toBigInt()}catch{console.error("Unable to pull wallet balance")}N(W,"fundWallet","onUserExited",{address:fe.funding.address,chain:fe.funding.chain,fundingMethod:M,balance:q})}re({...fe,externalConnectWallet:{suggestedAddress:void 0}}),oe.current=null,J.current=null,A(!1),o(!1),setTimeout(()=>{t.authFlow=void 0},200),t.createAnalyticsEvent({eventName:"modal_closed"})},solanaSignMessage:async({message:c})=>new Promise(async(u,f)=>{let y=async()=>{let b=await t.getAccessToken();if(!b)throw new Error("User must be authenticated to use their embedded wallet.");if(!v)throw new Error("User must have an embedded Solana wallet to sign messages for Solana.");let M=ne.walletProxy??await ne.initializeWalletProxy(15e3);if(!M)throw new Error("Failed to initialize embedded wallet proxy.");let{response:G}=await M.rpcSolana({accessToken:b,publicKey:v.address,request:{method:"signMessage",params:{message:c}}});return G.data.signature};if(L.embeddedWallets.noPromptOnSignature||sr.current)try{let b=await y();u({signature:b})}catch(b){f(b)}else re({signMessage:{method:"solana_signMessage",data:c,confirmAndSign:y,onSuccess:q=>{u({signature:q})},onFailure:q=>{f(q)},uiOptions:{}}}),wt("EMBEDDED_WALLET_SIGN_REQUEST_SCREEN")}),openPrivyModal:Me,connectWallet:cr,initLoginWithWallet:async(c,u,f)=>{fo(c)?(J.current="siwe",Rt(c,u,f)):(J.current="siws",zr(c,u))},loginWithWallet:async()=>{if(!n)throw new Xn;let c;if(t.authFlow instanceof Jo?c="siwe":t.authFlow instanceof sa&&(c="siws"),!c)throw new C("Must initialize SIWE/SIWS flow first.");let u=await t.getAccessToken(),f,y;if(u!==null)try{({user:f}=await t.link()),J.current=c}catch(b){throw N(W,"linkAccount","onError",b.privyErrorCode||"failed_to_link_account",{linkMethod:c}),b}else try{({user:f,isNewUser:y}=await t.authenticate()),J.current=c}catch(b){throw N(W,"login","onError",b.privyErrorCode||"generic_connect_wallet_error"),b}d(f||l||null),A(y||!1),s(!0)},initLoginWithFarcaster:async(c,u)=>{let f=new ds(c,u);t.startAuthFlow(f);try{J.current="farcaster",await f.initializeFarcasterConnect()}catch(y){throw oe.current==="login"?N(W,"login","onError",y.privyErrorCode||"unknown_auth_error"):oe.current==="link"&&N(W,"linkAccount","onError",y.privyErrorCode||"unknown_auth_error",{linkMethod:"farcaster"}),y}},loginWithFarcaster:async()=>{if(!n)throw new Xn;if(!(t.authFlow instanceof ds))throw new C("Must initialize Farcaster flow first.");let c=await t.getAccessToken(),u,f;if(c!==null)try{({user:u}=await t.link()),J.current="farcaster"}catch(y){throw N(W,"linkAccount","onError",y.privyErrorCode||"failed_to_link_account",{linkMethod:"farcaster"}),y}else try{({user:u,isNewUser:f}=await t.authenticate()),J.current="farcaster"}catch(y){throw N(W,"login","onError",y.privyErrorCode||"unknown_auth_error"),y}d(u||null),A(f||!1),s(!0)},async loginWithGuestAccountFlow(){let c=new ja(this.appId);t.startAuthFlow(c);try{oe.current="login",J.current="guest";let u=await t.authenticate(),{user:f,isNewUser:y}=u;if(y=y||!1,!f)throw new C("Unable to authenticate guest account");if(It(f,L.embeddedWallets.createOnLogin))try{await Tp(f,15e3),f=await ne.refreshUser()}catch{d(f),console.warn("Unable to create embedded wallet for guest account")}else d(f);return A(y),s(!0),N(W,"login","onComplete",f,y,!1,"guest",null),f}catch(u){throw N(W,"login","onError",u.privyErrorCode||"unknown_auth_error"),u}},async crossAppAuthFlow({appId:c,popup:u,action:f}){let y=`privy:${c}`;J.current=y;let{url:b,stateCode:M,codeVerifier:G}=await y2({api:t.api,appId:c});if(!b)throw t.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:c}}),new C("No authorization URL returned for cross-app auth.");try{let q=await e0({url:b,popup:u,provider:y}),$=q.stateCode,me=q.authorizationCode;if($!==M)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:y,storedStateCode:M??"",returnedStateCode:$??""}}),new C("Unexpected auth flow. This may be a phishing attempt.",void 0,"oauth_unexpected");let Ae=await g2({appId:c,codeVerifier:G,stateCode:$,authorizationCode:me,action:f,client:t});Ae&&t.storeProviderAccessToken(c,Ae);let Re=await ne.refreshUser();if(!Re)throw new C("Unable to update user");return t.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:c}}),Re}catch(q){throw t.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:q.toString(),provider:y}}),q}},async initLoginWithOAuth(c,u,f){if(J.current=c,rs()){if(c==="google"&&Ei(window.navigator.userAgent)){wt("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}}else{wt("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}c==="twitter"&&window.opener&&window.opener.postMessage({type:Ep},"*"),Z.del(ea),Z.del(ta);let y=new Ro({provider:c,disableSignup:!!f});u&&y.addCaptchaToken(u),t.startAuthFlow(y);let b=await t.authFlow.getAuthorizationUrl();b&&b.url&&(c==="twitter"&&$A&&(b.url=b.url.replace("x.com","twitter.com")),window.location.assign(b.url))},async initLoginWithTelegram(c,u){if(!n)throw new Xn;J.current="telegram";let f=new ti(c,u);t.startAuthFlow(f),f.meta.telegramWebAppData=void 0,f.meta.telegramAuthResult=await new Promise((y,b)=>{if(!L.loginConfig.telegramAuthConfiguration)return b(new C("Telegram Auth configuration is not loaded"));if(!window.Telegram)return b(new C("Telegram was not initialized"));window.Telegram.Login.auth({bot_id:L.loginConfig.telegramAuthConfiguration.botId,request_access:!0},M=>M?y(M):b(new C("Telegram auth failed or was canceled by the client")))})},async loginWithTelegram(){if(!(t.authFlow instanceof ti))throw new C("Must initialize Telegram flow before calling loginWithTelegram");let c,u;if(oe.current==="login")try{let f=await t.authenticate();c=f.user,u=f.isNewUser,J.current="telegram"}catch(f){throw N(W,"login","onError",f.privyErrorCode||"unknown_auth_error"),f}else if(oe.current==="link")try{c=(await t.link()).user,J.current="telegram"}catch(f){throw N(W,"linkAccount","onError",f.privyErrorCode||"failed_to_link_account",{linkMethod:"telegram"}),f}else throw new C("Unknown auth intent");d(c),A(u||!1),s(!0)},async recoveryOAuthFlow(c,u,f){let y,b;function M(G){if(!G)throw t.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:c}}),new C("Recovery OAuth failed")}switch(c){case"google-drive":{let{url:G,codeVerifier:q,stateCode:$}=await uu({api:dn.api,provider:c});M(G);let me,Ae;try{let Re=await Pm({url:G,popup:f,provider:c});if(me=Re.stateCode,Ae=Re.authorizationCode,me!==$)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:c,storedStateCode:$??"",returnedStateCode:me??""}}),new C("Unexpected auth flow. This may be a phishing attempt.",void 0,"oauth_unexpected")}catch(Re){throw t.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:Re.toString(),provider:c}}),new C("Recovery OAuth failed")}[y,b]=await Promise.all([he(),Cg({api:dn.api,provider:c,codeVerifier:q,stateCode:me,authorizationCode:Ae})]);break}case"icloud":{let{url:G}=await uu({api:dn.api,provider:c});M(G);let{ckWebAuthToken:q}=await Pm({url:G,popup:f,provider:c});b=q,y=await he();break}}if(!O)throw new C("Cannot connect to wallet proxy");if(!y)throw new C("Unable to authorize user");switch(u){case"recover":let G=fe.recoverWallet?.privyWallet?.address;if(!G)throw new C("Recovery OAuth failed");t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:G,recoveryMethod:c}}),await O.recover({address:G,accessToken:y,recoveryAccessToken:b,recoveryMethod:c}),t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:G,recoveryMethod:c}});break;case"create-wallet":t.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await O.create({accessToken:y,recoveryAccessToken:b,recoveryMethod:c});let q=await ne.refreshUser(),$=Be(q);if(!$)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:$.address}}),N(W,"createWallet","onSuccess",$);break;case"set-recovery":let me=Be(l);if(!me)throw N(W,"setWalletRecovery","onError","embedded_wallet_not_found"),new Error("Embedded wallet not found");t.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:me.address,existingRecoveryMethod:me.recoveryMethod,targetRecoveryMethod:c}}),await O.setRecovery({address:me.address,accessToken:y,recoveryAccessToken:b,recoveryMethod:c});let Ae=Be(await ne.refreshUser());if(!Ae)throw N(W,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to set recovery on wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:me.address,existingRecoveryMethod:me.recoveryMethod,targetRecoveryMethod:c}}),N(W,"setWalletRecovery","onSuccess",c,Ae);break;default:throw new C("Unsupported recovery action")}},async loginWithOAuth(c){if(!(t.authFlow instanceof Ro))throw new C("Must initialize OAuth flow before calling loginWithOAuth");let u=Z.get(jn),f=t.authFlow.meta.stateCode;if(u!==f)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:c,storedStateCode:u??"",returnedStateCode:f??""}}),new C("Unexpected auth flow. This may be a phishing attempt.",void 0,"oauth_unexpected");let y=await t.getAccessToken(),b,M,G;if(y!==null)try{let q=await t.link();b=q.user,G=q.oAuthTokens,J.current=c}catch(q){throw N(W,"linkAccount","onError",q.privyErrorCode||"failed_to_link_account",{linkMethod:c}),q}else try{let q=await t.authenticate();b=q.user,M=q.isNewUser,G=q.oAuthTokens,J.current=c}catch(q){throw oe.current==="login"?N(W,"login","onError",q.privyErrorCode||"unknown_auth_error"):oe.current==="link"&&N(W,"linkAccount","onError",q.privyErrorCode||"failed_to_link_account",{linkMethod:c}),q}return d(b),A(M||!1),s(!0),G&&b&&N(W,"oAuthAuthorization","onOAuthTokenGrant",G,{user:b}),G},passkeyAuthState:Y,setPasskeyAuthState:K,async initLoginWithPasskey(c){let u=new ia(c,K);t.startAuthFlow(u),oe.current="login";try{J.current="passkey",K({status:"generating-challenge"}),await u.initAuthenticationFlow(),K({status:"awaiting-passkey"})}catch(f){throw K({status:"error",error:f}),N(W,"login","onError",f.privyErrorCode||"unknown_auth_error"),f}},async loginWithPasskey(){if(!n)throw new Xn;if(!(t.authFlow instanceof ia))throw new C("Must initialize Passkey flow first.");if(J.current!=="passkey"){let M=new C("Must init login with Passkey flow first.");throw K({status:"error",error:M}),M}let u=!!await he(),f,y;try{J.current="passkey",K({status:"awaiting-passkey"}),{user:f,isNewUser:y}=await t.authenticate()}catch(M){throw K({status:"error",error:M}),N(W,"login","onError",M.privyErrorCode||"unknown_auth_error"),M}d(f),A(y||!1),s(!0),K({status:"done"});let b=f?.linkedAccounts.find(({type:M})=>M==="passkey")||null;return{user:f,isNewUser:y||!1,wasAlreadyAuthenticated:u,loginAccount:b}},async initLinkWithPasskey(c){let u=new ia(c);t.startAuthFlow(u),oe.current="link",J.current="passkey";try{await u.initLinkFlow()}catch(f){throw N(W,"linkAccount","onError",f.privyErrorCode||"unknown_auth_error",{linkMethod:"passkey"}),f}},async linkWithPasskey(){if(!n)throw new Xn;if(!(t.authFlow instanceof ia))throw new C("Must initialize Passkey flow first.");if(J.current!=="passkey")throw new C("Must init login with Passkey flow first.");let c;try{J.current="passkey",{user:c}=await t.link()}catch(u){throw N(W,"linkAccount","onError",u.privyErrorCode||"failed_to_link_account",{linkMethod:"passkey"}),u}return d(c||l||null),c},async initLoginWithHeadlessOAuth(c,u){if(rs()){if(c==="google"&&Ei(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.")}else throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let f=new Ro({provider:c,headless:!0,disableSignup:!1});u&&f.addCaptchaToken(u);let y=await t.startAuthFlow(f).getAuthorizationUrl();y?.url&&window.location.assign(y.url)},async loginWithHeadlessOAuth(c){_(!0),t.startAuthFlow(new Ro(c));let u=Z.get(jn),f=c.stateCode;if(u!==f)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:c.provider,storedStateCode:u??"",returnedStateCode:f??""}}),_(!1),new C("Unexpected auth flow. This may be a phishing attempt.",void 0,"oauth_unexpected");let y=await t.getAccessToken(),b,M,G;if(y!==null)try{({user:b,oAuthTokens:G}=await t.link()),J.current=c.provider;let q=wl(b);b&&q&&N(W,"linkAccount","onSuccess",b,J.current,q)}catch(q){throw _(!1),N(W,"linkAccount","onError",q.privyErrorCode||"failed_to_link_account",{linkMethod:c.provider}),q}else try{({user:b,isNewUser:M,oAuthTokens:G}=await t.authenticate()),J.current=c.provider;let q=wl(b);b&&q&&M!==void 0&&oe.current==="login"&&N(W,"login","onComplete",b,M,!1,J.current,q)}catch(q){throw _(!1),N(W,"login","onError",q.privyErrorCode||"unknown_auth_error"),q}return d(b),A(M||!1),s(!0),_(!1),G&&b&&N(W,"oAuthAuthorization","onOAuthTokenGrant",G,{user:b}),b??void 0},initLoginWithEmail:async(c,u,f)=>{let y=new mn(c,u,f);t.startAuthFlow(y);try{J.current="email",await y.sendCodeEmail()}catch(b){throw oe.current==="login"?N(W,"login","onError",b.privyErrorCode||"unknown_auth_error"):oe.current==="link"&&N(W,"linkAccount","onError",b.privyErrorCode||"failed_to_link_account",{linkMethod:"email"}),b}},initUpdateEmail:async(c,u,f)=>{let y=new Yl(c,u,f);t.startAuthFlow(y),await y.sendCodeEmail()},initUpdatePhone:async(c,u,f)=>{let y=new pc(c,u,f);t.startAuthFlow(y),await y.sendSmsCode()},initLoginWithSms:async(c,u,f)=>{B({status:"sending-code"});let y=new fn(c,u,f);t.startAuthFlow(y);try{J.current="sms",await y.sendSmsCode(),B({status:"awaiting-code-input"})}catch(b){throw B({status:"error",error:b}),oe.current==="login"?N(W,"login","onError",b.privyErrorCode||"unknown_auth_error"):oe.current==="link"&&N(W,"linkAccount","onError",b.privyErrorCode||"failed_to_link_account",{linkMethod:"sms"}),b}},resendEmailCode:async()=>{await t.authFlow?.sendCodeEmail()},resendSmsCode:async()=>{await t.authFlow?.sendSmsCode()},loginWithCode:async c=>{if(B({status:"submitting-code"}),!n){let y=new Xn;throw B({status:"error",error:y}),y}if(t.authFlow instanceof mn)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof fn)t.authFlow.meta.smsCode=c.trim();else{let y=new C("Must initialize a passwordless code flow first");throw B({status:"error",error:y}),y}await he();let u,f;if(oe.current==="link")try{({user:u}=await t.link())}catch(y){throw B({status:"error",error:y}),N(W,"linkAccount","onError",y.privyErrorCode||"failed_to_link_account",{linkMethod:J.current}),y}else try{({user:u,isNewUser:f}=await t.authenticate())}catch(y){throw B({status:"error",error:y}),N(W,"login","onError",y.privyErrorCode||"unknown_auth_error"),y}d(u||l||null),A(f||!1),s(!0),B({status:"done"})},generateSiweMessage:async({address:c,chainId:u,captchaToken:f})=>{oe.current="link",J.current="siwe";let y=await t.generateSiweNonce({address:c,captchaToken:f}),b=u.replace("eip155:","");return dc({address:c,chainId:b,nonce:y})},linkSmartWallet:async({message:c,signature:u,smartWalletType:f})=>{oe.current=null,J.current=null;let y;try{y=await t.linkSmartWallet({message:c,signature:u,smartWalletType:f}),y=await ne.refreshUser()??y}catch(b){throw b}d(y||l||null)},linkWithSiwe:async({message:c,signature:u,chainId:f,walletClientType:y,connectorType:b})=>{let M;try{M=await t.linkWithSiwe({message:c,signature:u,chainId:f,walletClientType:y,connectorType:b}),M=await ne.refreshUser()??M;let G=wl(M);G&&N(W,"linkAccount","onSuccess",M,"siwe",G)}catch(G){throw N(W,"linkAccount","onError",G.privyErrorCode||"failed_to_link_account",{linkMethod:"siwe"}),oe.current=null,J.current=null,G}d(M||l||null),oe.current=null,J.current=null},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return s(!!c),d(c),c},walletProxy:O,createAnalyticsEvent:({eventName:c,payload:u,timestamp:f})=>t.createAnalyticsEvent({eventName:c,payload:u,timestamp:f}),acceptTerms:async()=>{let c=await t.acceptTerms();return d(c),c},getUsdTokenPrice:c=>t.getUsdTokenPrice(c),getUsdPriceForSol:()=>t.getUsdPriceForSol(),recoverEmbeddedEthereumWallet:async c=>new Promise(async(u,f)=>{let y=Be(c?.user??l)||Ml(c?.user??l),b=await he();if(!b||!O||!y){f(new Error("Must have valid access token and Privy wallet to recover wallet"));return}X(!0);try{await O.connect({accessToken:b,address:y.address}),u(!0)}catch(M){if(va(M)&&y.recoveryMethod==="privy")t.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:y.address}}),(await O.recover({address:y.address,accessToken:b,recoveryMethod:y.recoveryMethod})).address||f(new Error("Unable to recover wallet")),t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:y.address}}),u(!0);else if(va(M)&&y.recoveryMethod!=="privy"){re({recoverWallet:{privyWallet:y,onFailure:f,onSuccess:()=>u(!0)},recoveryOAuthStatus:{provider:y.recoveryMethod,action:"recover"}});let G=Xc(y.recoveryMethod);Me(G)}else f(M)}}),embeddedSolanaWallet:v,createEmbeddedSolanaWallet:async()=>{X(!0);let c=await he(),u=await ne.refreshUser(),f=oa(u),y=Be(u);if(!u||!c)throw new C("User must be logged in to create a Solana wallet");if(f)throw new C("User already has an embedded Solana wallet.");if(y)if(y.recoveryMethod==="privy")await ne.recoverEmbeddedEthereumWallet({user:u});else throw new C("Cannot create an embedded Solana wallet for a user with an existing Ethereum wallet with user-controlled recovery.");let b=await ne.initializeWalletProxy(15e3);if(!b)throw new C("Unable to initialize wallet proxy");t.createAnalyticsEvent({eventName:"embedded_solana_wallet_creation_started"});try{await b.createSolana({accessToken:c,ethereumAddress:y?.address});let M=await ne.refreshUser(),G=oa(M);if(!G)throw new C("Could not get Solana wallet for user");return t.createAnalyticsEvent({eventName:"embedded_solana_wallet_creation_completed",payload:{walletAddress:G.address}}),G}catch(M){throw t.createAnalyticsEvent({eventName:"embedded_solana_wallet_creation_failed"}),new C("Failed to create Solana embedded wallet with error ",M)}},exportSolanaWallet:c=>new Promise(async(u,f)=>{if(!i||!l){f(new Error("User must be authenticated before exporting their Privy wallet"));return}let y=c?.address,b=l.linkedAccounts.filter($=>$.type==="wallet"&&$.walletClientType==="privy"&&$.chainType==="solana"),M=y?b.find($=>$.address.toLowerCase()===y.toLowerCase()):b.find($=>!$.imported)||b[0];if(!M){f(new Error("Must have a Privy wallet before exporting"));return}if(X(!0),!await he()||!O){f(new Error("Must have valid access token to enroll in MFA"));return}if(!O){f(new Error("Must have a Privy wallet before exporting"));return}await ne.recoverEmbeddedSolanaWallet();let q={appId:e.appId,appClientId:e.clientId,origin:t.apiUrl,wallet:M,onSuccess:u,onFailure:f};re({keyExport:q}),Me("EMBEDDED_WALLET_KEY_EXPORT_SCREEN")}),recoverEmbeddedSolanaWallet:async()=>new Promise(async(c,u)=>{let f=oa(l),y=await he();if(!y||!O||!f){u(new Error("Must have valid access token and Privy wallet to recover wallet"));return}X(!0);try{await O.connectSolana({accessToken:y,publicKey:f.address}),c(!0)}catch(b){va(b)&&f.recoveryMethod==="privy"?(t.createAnalyticsEvent({eventName:"embedded_solana_wallet_pinless_recovery_started",payload:{walletAddress:f.address}}),(await O.recoverSolana({publicKey:f.address,accessToken:y})).publicKey||u(new Error("Unable to recover wallet")),t.createAnalyticsEvent({eventName:"embedded_solana_wallet_recovery_completed",payload:{walletAddress:f.address}}),c(!0)):u(b)}}),getMoonpaySignedUrl:f0,initCoinbaseOnRamp:t.initCoinbaseOnRamp.bind(t),getCoinbaseOnRampStatus:t.getCoinbaseOnRampStatus.bind(t),setReadyToTrue:c=>{a(!0),te?.(c)},updateWallets:()=>vl(),fundWallet:async(c,u)=>{if(!L.fundingConfig||L.fundingConfig.methods.length===0)throw new Error("Wallet funding is not enabled");let f=gp({fundingMethods:L.fundingConfig.methods});re({funding:um({address:c,appConfig:L,fundWalletConfig:u,methodScreen:f})}),Me(f)},requestFarcasterSignerStatus:async c=>{let u=await he(),f=l?.linkedAccounts.find(b=>b.type==="wallet"&&b.walletClientType==="privy");if(!u)throw new Error("Must have valid access token to connect with Farcaster");if(!O||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!l?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");let y=await t.requestFarcasterSignerStatus(c);if(y.status==="approved"){let b=await t.getAuthenticatedUser();d(b||l||null)}return y},connectCoinbaseSmartWallet:async()=>{L.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let c=t.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||t.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(c)return c.updateConnectionPreference("smartWalletOnly"),cr(c);await Ar("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:c,account:u,accountType:f,chainId:y,walletClientType:b,connectorType:M,telegramAuthResult:G,farcasterEmbeddedAddress:q})=>{try{let $=await t.sendAccountTransferRequest({nonce:c,account:u,accountType:f,walletClientType:b,chainId:y,connectorType:M,telegramAuthResult:G,farcasterEmbeddedAddress:q});return d($),$}catch($){throw $}}}))();i0=ne.recoverEmbeddedEthereumWallet,s0=ne.recoverEmbeddedSolanaWallet,l0=ne.solanaSignMessage;let Mm=jA(()=>({wallets:p,ready:ie&&Ce}),[p,ie,Ce]);return Gr(De.Provider,{value:qa,children:Gr(ff.Provider,{value:W,children:Gr(wf.Provider,{value:Mm,children:Gr(sy,{...L,children:r0(pf.Provider,{value:ne,children:[Gr(yf,{children:r0(df,{data:fe,setModalData:re,setInitialScreen:P,initialScreen:T,authenticated:i,open:r,children:[e.children,!L.headless&&L.captchaEnabled&&n&&!i&&Gr(Vp,{delayedExecution:!1}),Gr(Ov,{theme:{...L.appearance.palette||{}}}),!L.render.standalone&&Gr(Tm,{open:r})]})}),pe&&Ge?Gr(Zv,{appId:e.appId,appClientId:e.clientId,clientAnalyticsId:t.clientAnalyticsId,origin:t.apiUrl,mfaMethods:l?.mfaMethods,mfaPromise:ke,mfaSubmitPromise:se,onLoad:Q,onLoadFailed:()=>null}):null,L.loginConfig.telegramAuthConfiguration&&Gr(yo,{if:!0,children:Gr(Yv,{scriptHost:e.apiUrl||xl,botUsername:L.loginConfig.telegramAuthConfiguration.botName})})]})})})})})};import{useCallback as c0,useEffect as sx}from"react";var lx=e=>{ze("login",e);let t=Te(),r=Dl(),{initLoginWithHeadlessOAuth:o,loginWithHeadlessOAuth:n,isHeadlessOAuthLoading:a,ready:i,user:s}=z(),l=c0(async p=>{if(t.enabled&&t.status!=="success")throw new Lt(t.error,null,"captcha_failure");return o(p.provider,t.token)},[o,t]),d=c0(async()=>{let p=hs();if(s)return console.warn("Cannot login with OAuth when already logged in"),s;if(!p.inProgress)throw new Error("Cannot login with OAuth because no OAuth flow is in progress");if(!p.popupFlow)try{return await n(p)}catch(m){throw m}finally{aa()}},[n]);return sx(()=>{let p=hs();i&&r&&p.inProgress&&p.headless&&!p.popupFlow&&d()},[i,r]),{initOAuth:l,loginWithOAuth:d,loading:a}};import{useCallback as d0}from"react";var cx=()=>{let e=Te(),{initLoginWithEmail:t,loginWithCode:r}=R(),o=d0(async({email:a})=>{if(!a)throw new Error("Email required to send OTP code");if(e.enabled&&e.status==="error")throw new Lt(e.error,null,"captcha_failure");let i;return e.enabled&&e.status!=="success"&&(e.execute(),i=await e.waitForResult()),t(a,i)},[t]),n=d0(async({code:a})=>{if(e.enabled&&e.status==="error")throw new Lt(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};import{useCallback as dx}from"react";var px=e=>{let t=Te(),{initLoginWithPasskey:r,loginWithPasskey:o,passkeyAuthState:n,setPasskeyAuthState:a}=R();return{loginWithPasskey:dx(async()=>{try{if(t.enabled&&t.status==="error")throw new Lt(t.error,null,"captcha_failure");let s;t.enabled&&t.status!=="success"&&(t.execute(),s=await t.waitForResult()),await r(s);let{user:l,isNewUser:d,wasAlreadyAuthenticated:p,loginAccount:m}=await o();e?.onComplete?.(l,d,p,"passkey",m)}catch(s){throw a({status:"error",error:s}),e?.onError?.(s),s}},[o,t.status]),state:n}};import{useCallback as p0}from"react";var ux=()=>{let e=Te(),{otpState:t}=z(),{initLoginWithSms:r,loginWithCode:o}=R(),n=p0(async({phoneNumber:i})=>{if(!i)throw new Error("SMS required to send OTP code");if(e.enabled&&e.status==="error")throw new Lt(e.error,null,"captcha_failure");let s;return e.enabled&&e.status!=="success"&&(e.execute(),s=await e.waitForResult()),r(i,s)},[r]),a=p0(async({code:i})=>{if(e.enabled&&e.status!=="success")throw new Lt(e.error,null,"captcha_failure");return o(i)},[o,e.status]);return{sendCode:n,loginWithCode:a,state:t}};import{useCallback as u0}from"react";var mx=()=>{let e=Te(),{generateSiweMessage:t,linkWithSiwe:r}=z(),o=u0(async({address:a,chainId:i})=>{if(!a||!i)throw new Error("wallet address and chainId required to generate nonce");return t({address:a,chainId:i}).then(s=>s)},[t]),n=u0(async({signature:a,message:i,chainId:s,walletClientType:l,connectorType:d})=>{if(e.enabled&&e.status!=="success")throw new Lt(e.error,null,"captcha_failure");return r({message:i,signature:a,chainId:s,walletClientType:l,connectorType:d})},[r,e.status]);return{generateSiweMessage:o,linkWithSiwe:n}};import{useContext as fx}from"react";function hx(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:s,linkGithub:l,linkLinkedIn:d,linkTiktok:p,linkSpotify:m,linkInstagram:h,linkTelegram:g,linkFarcaster:v}=fx(De);return ze("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:s,linkGithub:l,linkLinkedIn:d,linkTiktok:p,linkSpotify:m,linkInstagram:h,linkFarcaster:v,linkTelegram:g}}import{useContext as yx}from"react";function gx(e){let{createWallet:t}=yx(De);return ze("createWallet",e),{createWallet:t}}var Cx=()=>{let{embeddedSolanaWallet:e,exportSolanaWallet:t,createEmbeddedSolanaWallet:r,solanaWallets:o}=R();return{createWallet:r,exportWallet:t,wallets:o.concat(e?[e]:[])}};var vx=()=>{let{connectCoinbaseSmartWallet:e}=R();return{connectCoinbaseSmartWallet:e}};var wx=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:r,signTypedDataWithCrossAppWallet:o,sendTransactionWithCrossAppWallet:n}=z();return{loginWithCrossAppAccount:({appId:a})=>e({appId:a,action:"login"}),linkCrossAppAccount:({appId:a})=>e({appId:a,action:"link"}),unlinkCrossAppAccount:t,signMessage:r,signTypedData:o,sendTransaction:n}};import{useContext as bx}from"react";function Ex(e){let{sendTransaction:t}=bx(De);return ze("sendTransaction",e),{sendTransaction:t}}import{useContext as Tx}from"react";function Sx(e){let{sendSolanaTransaction:t}=Tx(De);return ze("sendSolanaTransaction",e),{sendSolanaTransaction:t}}import{useContext as Px}from"react";function Ax(e){let{setWalletPassword:t}=Px(De);return ze("setWalletPassword",e),{setWalletPassword:t}}import{useContext as xx}from"react";function kx(){let{createGuestAccount:e}=xx(De);return{createGuestAccount:e}}import{useContext as Rx}from"react";function _x(e){let{setWalletRecovery:t}=Rx(De);return ze("setWalletRecovery",e),{setWalletRecovery:t}}import{useContext as Ix}from"react";function Mx(e){let{signMessage:t}=Ix(De);return ze("signMessage",e),{signMessage:t}}import{useContext as Wx}from"react";function Lx(e){let{signTypedData:t}=Wx(De);return ze("signTypedData",e),{signTypedData:t}}import{useContext as Nx}from"react";var Ox=()=>{let{isModalOpen:e}=Nx(De);return{isOpen:e}};import{useContext as Dx}from"react";function Ux(e){let{getAccessToken:t}=Dx(De);return ze("accessToken",e),{getAccessToken:t}}function Fx(e){let{authenticated:t,user:r}=z(),{initLoginWithOAuth:o}=R(),n=Ya();return ze("oAuthAuthorization",e),{reauthorize:a=>Bx(t,r,o,n,a.provider)}}var Bx=async(e,t,r,o,n)=>{if(!e)throw o("linkAccount","onError","must_be_authenticated",{linkMethod:n}),new C("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some(i=>i.type.includes(n)))throw new C(`OAuth account of type ${n} not linked to the account.`);await r(n)};var Hx=e=>{let{customAuthStatus:t}=R();return ze("customAuth",e),{status:t}};var Vx=m0;function m0(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=z();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}}export{ca as a,st as b,Io as c,mr as d,$h as e,ws as f,bs as g,Vp as h,Gp as i,wa as j,ba as k,du as l,tl as m,Eo as n,Tm as o,he as p,ax as q,lx as r,cx as s,px as t,ux as u,mx as v,hx as w,gx as x,Cx as y,vx as z,wx as A,Ex as B,Sx as C,Ax as D,kx as E,_x as F,Mx as G,Lx as H,Ox as I,Ux as J,Fx as K,Hx as L,Vx as M,m0 as N};
|