@privy-io/react-auth 1.59.7-beta-20240326191824 → 1.59.7
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/esm/index.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Qs=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var nd=(e,t,r)=>(Qs(e,t,"read from private field"),r?r.call(e):t.get(e)),Di=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Xs=(e,t,r,o)=>(Qs(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var id=(e,t,r)=>(Qs(e,t,"access private method"),r);import{getAddress as Ks}from"@ethersproject/address";import{Web3Provider as Xc}from"@ethersproject/providers";import{createStore as IE}from"mipd";import{useCallback as ME,useEffect as Or,useMemo as WE,useRef as Fn,useState as Me}from"react";import{FetchError as zy}from"ofetch";var $e=class extends Error{constructor(r,o,n){super(r);o instanceof Error&&(this.cause=o),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},nr=class extends $e{constructor(r,o,n,a,i){super(n,a,i);this.type=r;this.status=o}},S=class extends $e{constructor(r,o,n){super(r,o,n);this.type="client_error"}},Fi=class extends S{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var Z=class extends $e{constructor(r,o,n){super(r,o,n);this.type="connector_error"}},ue=e=>{if(e instanceof $e)return e;if(!(e instanceof zy))return rt(e);if(!e.response)return new nr("api_error",null,e.message,e);let{type:t,message:r,error:o,code:n}=e.data;return new nr(t||"ApiError",e.response.status,r||o,e,n)},rt=e=>e instanceof $e?e:e instanceof Error?new S(e.message,e):new S(`Internal error: ${e}`);var Oo=class extends S{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},wt=class extends S{constructor(t="Embedded wallet error",r){super(t,r,"unknown_embedded_wallet_error")}},Ui=class extends S{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var Bi="/api/v1/sessions",Hi="/api/v1/sessions/logout",ad="/api/v1/sessions/fork",Gi="/api/v1/sessions/fork/recover",sd="/api/v1/siwe/init",ld="/api/v1/siwe/authenticate",cd="/api/v1/siwe/link",dd="/api/v1/siwe/unlink",pd="/api/v1/farcaster/init",ud="/api/v1/farcaster/authenticate",md="/api/v1/farcaster/link",fd="/api/v1/farcaster/status",hd="/api/v1/farcaster/unlink",yd="/api/v1/passwordless/init",gd="/api/v1/passwordless/authenticate",vd="/api/v1/passwordless/link",wd="/api/v1/passwordless/unlink",Cd="/api/v1/passwordless/update",bd="/api/v1/passwordless_sms/init",Ed="/api/v1/passwordless_sms/link",Td="/api/v1/passwordless_sms/unlink",Pd="/api/v1/passwordless_sms/authenticate",xd="/api/v1/oauth/init",Sd="/api/v1/oauth/authenticate",_d="/api/v1/oauth/link",Ad="/api/v1/oauth/unlink";var kd="/api/v1/mfa/passwordless_sms/init",Rd="/api/v1/mfa/passwordless_sms/enroll";var Id="/api/v1/users/me/accept_terms",Md="/api/v1/analytics_events",Wd="/api/v1/plugins/moonpay_on_ramp/sign",Ld="/api/v1/custom_jwt_account/authenticate";var No=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new S("Auth flow has no API instance");try{let t=await this.api.post(Ld,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ue(t)}}async link(){throw new Error("Unimplemented")}};var Fr=class{constructor(t,r){this.meta={email:t,captchaToken:r}}async authenticate(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new S("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(gd,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ue(t)}}async link(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new S("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(vd,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ue(t)}}async sendCodeEmail(t,r){if(!this.api)throw new S("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new S("Email must be set when initialzing authentication.");try{return await this.api.post(yd,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw ue(o)}}},Vi=class extends Fr{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r}}async link(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new S("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(Cd,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw ue(r)}}};import{isMobile as Yy,isIOS as Jy}from"react-device-detect";var el=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,r){r!==void 0?this._cache[t]=r:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},zi=class{get(t){let r=localStorage.getItem(t);return r===null?void 0:JSON.parse(r)}put(t,r){r!==void 0?localStorage.setItem(t,JSON.stringify(r)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function tl(){try{let e="privy:__session_storage__test",t="blobby",r=new zi;return r.put(e,t),r.del(e),!0}catch{return!1}}function qy(){return typeof window<"u"&&window.localStorage?new zi:new el}var j=qy();import{StaticJsonRpcProvider as Uo}from"@ethersproject/providers";function Od(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let o of t.providers)o&&r.push(o);return r.push(e.ethereum),r}var qi=e=>{if(e.isApexWallet)return"Apex Wallet";if(e.isAvalanche)return"Core Wallet";if(e.isBackpack)return"Backpack";if(e.isBifrost)return"Bifrost Wallet";if(e.isBitKeep)return"BitKeep";if(e.isBitski)return"Bitski";if(e.isBlockWallet)return"BlockWallet";if(e.isBraveWallet)return"Brave Wallet";if(e.isClover)return"Clover";if(e.isCoin98)return"Coin98 Wallet";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isDawn)return"Dawn Wallet";if(e.isDefiant)return"Defiant";if(e.isDesig)return"Desig Wallet";if(e.isEnkrypt)return"Enkrypt";if(e.isExodus)return"Exodus";if(e.isFordefi)return"Fordefi";if(e.isFrame)return"Frame";if(e.isFrontier)return"Frontier Wallet";if(e.isGamestop)return"GameStop Wallet";if(e.isHaqqWallet)return"HAQQ Wallet";if(e.isHyperPay)return"HyperPay Wallet";if(e.isImToken)return"ImToken";if(e.isHaloWallet)return"Halo Wallet";if(e.isKuCoinWallet)return"KuCoin Wallet";if(e.isMathWallet)return"MathWallet";if(e.isNovaWallet)return"Nova Wallet";if(e.isOkxWallet||e.isOKExWallet)return"OKX Wallet";if(e.isOneInchIOSWallet||e.isOneInchAndroidWallet)return"1inch Wallet";if(e.isOneKey)return"OneKey Wallet";if(e.isOpera)return"Opera";if(e.isPhantom)return"Phantom";if(e.isPortal)return"Ripio Portal";if(e.isRabby)return"Rabby Wallet";if(e.isRainbow)return"Rainbow";if(e.isSafePal)return"SafePal Wallet";if(e.isStatus)return"Status";if(e.isSubWallet)return"SubWallet";if(e.isTalisman)return"Talisman";if(e.isTally||e.isTaho)return"Taho";if(e.isTokenPocket)return"TokenPocket";if(e.isTokenary)return"Tokenary";if(e.isTrust||e.isTrustWallet)return"Trust Wallet";if(e.isTTWallet)return"TTWallet";if(e.isXDEFI)return"XDEFI Wallet";if(e.isZeal)return"Zeal";if(e.isZerion)return"Zerion";if(e.isMetaMask)return"MetaMask"};var rl=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||qi(e)!=="MetaMask")return!1;if(e.providers){for(let r of e.providers)if(!rl(r))return!1}return!0},Ur=()=>!!("phantom"in window&&window?.phantom?.ethereum?.isPhantom),Nd=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0}return!1};var Dd="1.59.7-beta-20240326191824";var ol="4df5e2316331463a9130964bd6078dfa",nl="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",Fd="34357d3c125c2bcf2ce2bc3309d98715",$i="https://auth.privy.io",Ud=2e4,Oe=1400,Bd=2500,il=Dd;var mo="privy:token",al="privy-token",ji="privy:refresh_token",sl="privy-refresh-token",Ki="privy-session",Hn="privy:session_transfer_token",jy="privy:wallet",Gn="privy:caid",fo="privy:state_code",Do="privy:code_verifier",ho="privy:headless_oauth",Yi=e=>`${jy}:${e}`,ll="privy:connectors",cl="privy:connections";var yo=12e4,xr=1,dl="0x1",Fo=3e4,Hd="https://api.moonpay.com/v1",Gd="https://api.moonpay.com/v1",Vd="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",zd="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",qd="0x420000000000000000000000000000000000000F",$d=["function getL1Fee(bytes memory _data) external view returns (uint256)"];var jd=(e,t)=>{let r=[],o=[];for(let[n,a]of e.entries())n<t?r.push(a):o.push(a);return[r,o]},Ji=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),Kd=(e,t)=>{let r=e.slice(0),o=[];for(;r.length;)o.push(r.splice(0,t));return o},Br=(e,t=3,r=4)=>{if(!e)return"";let o=2,n=3;if(t+r+o+n>=e.length)return e;let a=e.slice(0,o+t),i=e.slice(e.length-r,e.length);return`${a}...${i}`},pl=e=>new Promise(t=>setTimeout(t,e));function Yd(e,{interval:t=100,timeout:r=5e3}={}){return new Promise((o,n)=>{let a=0,i,l=()=>{if(a>=r){n("Max attempts reached without result");return}if(i=e(),a+=t,i!=null){o(i);return}setTimeout(l,t)};l()})}var Jd=(e,t={})=>{let r=t.delayMs||150,o=t.maxAttempts||270;return new Promise(async(n,a)=>{let i=!1,l=0;for(;!i&&l<o;){if(t.abortSignal?.aborted)return;e().then(()=>{i=!0,n()},(...s)=>{i=!0,a(...s)}),l+=1,await pl(r)}i||a(new Error("Exceeded max attempts before resolving function"))})},Zi=(e,t,r={})=>{let o=new URL(t,e);for(let[n,a]of Object.entries(r))o.searchParams.set(n,a);return o.href};var Zd=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),go=e=>typeof e=="string"?e:"0x"+e.toString(16);async function Qd(e,t,r=3e3){let o=!1,n=window;return new Promise(a=>{n.ethereum?i():(window.addEventListener("ethereum#initialized",i,{once:!0}),setTimeout(()=>{i()},r));function i(){if(o)return;o=!0,window.removeEventListener("ethereum#initialized",i);let l=e.getProviders(),s=[];for(let d of l)t.includes("coinbase_wallet")&&d.info.rdns==="com.coinbase.wallet"||s.push({type:d.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:d});for(let d of Od()){let u=qi(d);if(!l.some(y=>y.info.name===u)){if(rl(d,!0)&&!s.find(y=>y.type==="metamask")){s.push({type:"metamask",legacyInjectedProvider:d});continue}if(u==="Phantom"&&!s.find(y=>y.type==="phantom")){s.push({type:"phantom",legacyInjectedProvider:d});continue}s.find(y=>y.type==="unknown_browser_extension")||s.push({type:"unknown_browser_extension",legacyInjectedProvider:d})}}a(s)}})}function Bo(e){return`eip155:${String(Number(e))}`}var Qi=(e,t,r,o)=>{let n=Number(e),a=t.find(l=>l.id===n);if(!a)throw new Z(`Unsupported chainId ${e}`,4901);let i;if(a.rpcUrls.privyWalletOverride&&a.rpcUrls.privyWalletOverride.http[0])i=a.rpcUrls.privyWalletOverride.http[0];else if(r.rpcUrls&&r.rpcUrls[n])i=r.rpcUrls[n];else if(a.rpcUrls.privy?.http[0]){let l=new URL(a.rpcUrls.privy.http[0]);l.searchParams.append("privyAppId",o),i=l.toString()}else a.rpcUrls.infura?.http[0]?i=a.rpcUrls.infura.http[0]+"/"+ol:a.rpcUrls.blast?.http[0]?i=a.rpcUrls.blast.http[0]+"/"+nl:i=a.rpcUrls.default?.http[0];if(!i)throw new Z(`No RPC url found for ${e}`);return i},Xd=(e,t)=>{let r=Number(e),o=t.find(n=>n.id===r);if(!o)throw new Z(`Unsupported chainId ${e}`,4901);return o.blockExplorers?.default.url},Sr=(e,t,r,o)=>{let n=Number(e),a=t.find(l=>l.id===n);if(!a)throw new Z(`Unsupported chainId ${e}`,4901);let i;if(a.rpcUrls.privyWalletOverride&&a.rpcUrls.privyWalletOverride.http[0]?i=new Uo(a.rpcUrls.privyWalletOverride.http[0]):r.rpcUrls&&r.rpcUrls[n]?i=new Uo(r.rpcUrls[n]):a.rpcUrls.privy?.http[0]?i=new Uo({url:a.rpcUrls.privy.http[0],headers:{"privy-app-id":o.appId}}):a.rpcUrls.infura?.http[0]?i=new Uo(a.rpcUrls.infura.http[0]+"/"+ol):a.rpcUrls.blast?.http[0]?i=new Uo(a.rpcUrls.blast.http[0]+"/"+nl):i=new Uo(a.rpcUrls.default?.http[0]),!i)throw new Z(`No RPC url found for ${e}`);return i},Xi=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map(([o,n])=>{if(n!=null&&typeof o=="string"&&o in t)return{name:o,type:t[o]}}).filter(o=>o!==void 0);return{...e,types:{...e.types,EIP712Domain:r}}};var ea=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(Ho))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var Ho={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"}}};function Ky(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}var ep=e=>e in Ho,tp=e=>{let t=Ho[e].mobile;if("native"in t)return t.native};function rp(e,t){let r=Ky(t);if(r.deepLink)return sp(r.deepLink,e);if(r.universalLink)return lp(r.universalLink,e);throw new S(`Unsupported wallet ${t.id}`)}var op="WALLETCONNECT_DEEPLINK_CHOICE";function np(){try{localStorage.removeItem(op)}catch{}}function ip({href:e,name:t}){try{localStorage.setItem(op,JSON.stringify({href:e,name:t}))}catch{}}function ap(e){return e.startsWith("http://")||e.startsWith("https://")}function sp(e,t){if(ap(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(!ap(e))return sp(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function ta(e,t){window.open(e,t,"noreferrer noopener")}var ot=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 Vn=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new ot(this._startChannelOnce.bind(this)),this.pollForReady=new ot(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.channelToken)throw new S("Auth flow must be initialized first");try{let t=await this.api.post(ud,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new S("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ue(t)}}async link(){if(!this.api)throw new S("Auth flow has no API instance");try{return await this.api.post(md,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw ue(t)}}async _startChannelOnce(){if(!this.api)throw new S("Auth flow has no API instance");let t=await this.api.post(pd,{token:this.captchaToken});Yy&&!Jy&&t.connect_uri&&ta(t.connect_uri,"_blank"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new S("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.channelToken)throw new S("Auth flow must be initialized first");let t=await this.api.get(fd,{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 pp}from"jose";async function cp(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function dp(e){return crypto.getRandomValues(new Uint8Array(e))}function ra(){return!!j.get(ho)}var Zy="S256",Qy="S256",ir=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:ra();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 S("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new S("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new S("User denied confirmation during OAuth flow");let t=j.get(Do);if(!t)throw new S("Authentication error.");try{let r=await this.api.post(Sd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return j.del(Do),this.meta.headless&&j.del(ho),{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(r){let o=ue(r);throw o.privyErrorCode?new S(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new S("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new S("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new S("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new S("User denied confirmation during OAuth flow");let t=j.get(Do);if(!t)throw new S("Authentication error.");try{let r=await this.api.post(_d,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return j.del(Do),r}catch(r){throw ue(r)}}createCodeVerifier(){return pp.encode(dp(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,r=Zy){if(r==Qy){let o=await cp(t);return pp.encode(o)}else return t}async getAuthorizationUrl(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.provider)throw new S("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();j.put(Do,t);let r=this.createStateCode();j.put(fo,r);let o=await this.deriveCodeChallengeFromCodeVerifier(t);this.meta.headless&&j.put(ho,!0);try{return await this.api.post(xd,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw ue(n)}}};function ul(e){return e.charAt(0).toUpperCase()+e.slice(1)}function up(e,t){let r={detail:"",retryable:!1},o=ul(t);return 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==="oauth_account_suspended"&&(r.detail=`Your ${o} account is suspended. Please try another login method.`),r}function qn(){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");return!t||!r||!o?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:ra()}}function $n(){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"),j.del(fo),window.history.replaceState({},"",e)}var vo=class{constructor(t,r){this.createSiweMessage=(t,r,o,n,a,i,l)=>`${o} wants you to sign in with your Ethereum account:
|
|
1
|
+
var Qs=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var nd=(e,t,r)=>(Qs(e,t,"read from private field"),r?r.call(e):t.get(e)),Di=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Xs=(e,t,r,o)=>(Qs(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var id=(e,t,r)=>(Qs(e,t,"access private method"),r);import{getAddress as Ks}from"@ethersproject/address";import{Web3Provider as Xc}from"@ethersproject/providers";import{createStore as IE}from"mipd";import{useCallback as ME,useEffect as Or,useMemo as WE,useRef as Fn,useState as Me}from"react";import{FetchError as zy}from"ofetch";var $e=class extends Error{constructor(r,o,n){super(r);o instanceof Error&&(this.cause=o),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},nr=class extends $e{constructor(r,o,n,a,i){super(n,a,i);this.type=r;this.status=o}},S=class extends $e{constructor(r,o,n){super(r,o,n);this.type="client_error"}},Fi=class extends S{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var Z=class extends $e{constructor(r,o,n){super(r,o,n);this.type="connector_error"}},ue=e=>{if(e instanceof $e)return e;if(!(e instanceof zy))return rt(e);if(!e.response)return new nr("api_error",null,e.message,e);let{type:t,message:r,error:o,code:n}=e.data;return new nr(t||"ApiError",e.response.status,r||o,e,n)},rt=e=>e instanceof $e?e:e instanceof Error?new S(e.message,e):new S(`Internal error: ${e}`);var Oo=class extends S{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},wt=class extends S{constructor(t="Embedded wallet error",r){super(t,r,"unknown_embedded_wallet_error")}},Ui=class extends S{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var Bi="/api/v1/sessions",Hi="/api/v1/sessions/logout",ad="/api/v1/sessions/fork",Gi="/api/v1/sessions/fork/recover",sd="/api/v1/siwe/init",ld="/api/v1/siwe/authenticate",cd="/api/v1/siwe/link",dd="/api/v1/siwe/unlink",pd="/api/v1/farcaster/init",ud="/api/v1/farcaster/authenticate",md="/api/v1/farcaster/link",fd="/api/v1/farcaster/status",hd="/api/v1/farcaster/unlink",yd="/api/v1/passwordless/init",gd="/api/v1/passwordless/authenticate",vd="/api/v1/passwordless/link",wd="/api/v1/passwordless/unlink",Cd="/api/v1/passwordless/update",bd="/api/v1/passwordless_sms/init",Ed="/api/v1/passwordless_sms/link",Td="/api/v1/passwordless_sms/unlink",Pd="/api/v1/passwordless_sms/authenticate",xd="/api/v1/oauth/init",Sd="/api/v1/oauth/authenticate",_d="/api/v1/oauth/link",Ad="/api/v1/oauth/unlink";var kd="/api/v1/mfa/passwordless_sms/init",Rd="/api/v1/mfa/passwordless_sms/enroll";var Id="/api/v1/users/me/accept_terms",Md="/api/v1/analytics_events",Wd="/api/v1/plugins/moonpay_on_ramp/sign",Ld="/api/v1/custom_jwt_account/authenticate";var No=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new S("Auth flow has no API instance");try{let t=await this.api.post(Ld,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ue(t)}}async link(){throw new Error("Unimplemented")}};var Fr=class{constructor(t,r){this.meta={email:t,captchaToken:r}}async authenticate(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new S("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(gd,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ue(t)}}async link(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new S("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(vd,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ue(t)}}async sendCodeEmail(t,r){if(!this.api)throw new S("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new S("Email must be set when initialzing authentication.");try{return await this.api.post(yd,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw ue(o)}}},Vi=class extends Fr{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r}}async link(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new S("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(Cd,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw ue(r)}}};import{isMobile as Yy,isIOS as Jy}from"react-device-detect";var el=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,r){r!==void 0?this._cache[t]=r:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},zi=class{get(t){let r=localStorage.getItem(t);return r===null?void 0:JSON.parse(r)}put(t,r){r!==void 0?localStorage.setItem(t,JSON.stringify(r)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function tl(){try{let e="privy:__session_storage__test",t="blobby",r=new zi;return r.put(e,t),r.del(e),!0}catch{return!1}}function qy(){return typeof window<"u"&&window.localStorage?new zi:new el}var j=qy();import{StaticJsonRpcProvider as Uo}from"@ethersproject/providers";function Od(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let o of t.providers)o&&r.push(o);return r.push(e.ethereum),r}var qi=e=>{if(e.isApexWallet)return"Apex Wallet";if(e.isAvalanche)return"Core Wallet";if(e.isBackpack)return"Backpack";if(e.isBifrost)return"Bifrost Wallet";if(e.isBitKeep)return"BitKeep";if(e.isBitski)return"Bitski";if(e.isBlockWallet)return"BlockWallet";if(e.isBraveWallet)return"Brave Wallet";if(e.isClover)return"Clover";if(e.isCoin98)return"Coin98 Wallet";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isDawn)return"Dawn Wallet";if(e.isDefiant)return"Defiant";if(e.isDesig)return"Desig Wallet";if(e.isEnkrypt)return"Enkrypt";if(e.isExodus)return"Exodus";if(e.isFordefi)return"Fordefi";if(e.isFrame)return"Frame";if(e.isFrontier)return"Frontier Wallet";if(e.isGamestop)return"GameStop Wallet";if(e.isHaqqWallet)return"HAQQ Wallet";if(e.isHyperPay)return"HyperPay Wallet";if(e.isImToken)return"ImToken";if(e.isHaloWallet)return"Halo Wallet";if(e.isKuCoinWallet)return"KuCoin Wallet";if(e.isMathWallet)return"MathWallet";if(e.isNovaWallet)return"Nova Wallet";if(e.isOkxWallet||e.isOKExWallet)return"OKX Wallet";if(e.isOneInchIOSWallet||e.isOneInchAndroidWallet)return"1inch Wallet";if(e.isOneKey)return"OneKey Wallet";if(e.isOpera)return"Opera";if(e.isPhantom)return"Phantom";if(e.isPortal)return"Ripio Portal";if(e.isRabby)return"Rabby Wallet";if(e.isRainbow)return"Rainbow";if(e.isSafePal)return"SafePal Wallet";if(e.isStatus)return"Status";if(e.isSubWallet)return"SubWallet";if(e.isTalisman)return"Talisman";if(e.isTally||e.isTaho)return"Taho";if(e.isTokenPocket)return"TokenPocket";if(e.isTokenary)return"Tokenary";if(e.isTrust||e.isTrustWallet)return"Trust Wallet";if(e.isTTWallet)return"TTWallet";if(e.isXDEFI)return"XDEFI Wallet";if(e.isZeal)return"Zeal";if(e.isZerion)return"Zerion";if(e.isMetaMask)return"MetaMask"};var rl=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||qi(e)!=="MetaMask")return!1;if(e.providers){for(let r of e.providers)if(!rl(r))return!1}return!0},Ur=()=>!!("phantom"in window&&window?.phantom?.ethereum?.isPhantom),Nd=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0}return!1};var Dd="1.59.7";var ol="4df5e2316331463a9130964bd6078dfa",nl="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",Fd="34357d3c125c2bcf2ce2bc3309d98715",$i="https://auth.privy.io",Ud=2e4,Oe=1400,Bd=2500,il=Dd;var mo="privy:token",al="privy-token",ji="privy:refresh_token",sl="privy-refresh-token",Ki="privy-session",Hn="privy:session_transfer_token",jy="privy:wallet",Gn="privy:caid",fo="privy:state_code",Do="privy:code_verifier",ho="privy:headless_oauth",Yi=e=>`${jy}:${e}`,ll="privy:connectors",cl="privy:connections";var yo=12e4,xr=1,dl="0x1",Fo=3e4,Hd="https://api.moonpay.com/v1",Gd="https://api.moonpay.com/v1",Vd="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",zd="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",qd="0x420000000000000000000000000000000000000F",$d=["function getL1Fee(bytes memory _data) external view returns (uint256)"];var jd=(e,t)=>{let r=[],o=[];for(let[n,a]of e.entries())n<t?r.push(a):o.push(a);return[r,o]},Ji=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),Kd=(e,t)=>{let r=e.slice(0),o=[];for(;r.length;)o.push(r.splice(0,t));return o},Br=(e,t=3,r=4)=>{if(!e)return"";let o=2,n=3;if(t+r+o+n>=e.length)return e;let a=e.slice(0,o+t),i=e.slice(e.length-r,e.length);return`${a}...${i}`},pl=e=>new Promise(t=>setTimeout(t,e));function Yd(e,{interval:t=100,timeout:r=5e3}={}){return new Promise((o,n)=>{let a=0,i,l=()=>{if(a>=r){n("Max attempts reached without result");return}if(i=e(),a+=t,i!=null){o(i);return}setTimeout(l,t)};l()})}var Jd=(e,t={})=>{let r=t.delayMs||150,o=t.maxAttempts||270;return new Promise(async(n,a)=>{let i=!1,l=0;for(;!i&&l<o;){if(t.abortSignal?.aborted)return;e().then(()=>{i=!0,n()},(...s)=>{i=!0,a(...s)}),l+=1,await pl(r)}i||a(new Error("Exceeded max attempts before resolving function"))})},Zi=(e,t,r={})=>{let o=new URL(t,e);for(let[n,a]of Object.entries(r))o.searchParams.set(n,a);return o.href};var Zd=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),go=e=>typeof e=="string"?e:"0x"+e.toString(16);async function Qd(e,t,r=3e3){let o=!1,n=window;return new Promise(a=>{n.ethereum?i():(window.addEventListener("ethereum#initialized",i,{once:!0}),setTimeout(()=>{i()},r));function i(){if(o)return;o=!0,window.removeEventListener("ethereum#initialized",i);let l=e.getProviders(),s=[];for(let d of l)t.includes("coinbase_wallet")&&d.info.rdns==="com.coinbase.wallet"||s.push({type:d.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:d});for(let d of Od()){let u=qi(d);if(!l.some(y=>y.info.name===u)){if(rl(d,!0)&&!s.find(y=>y.type==="metamask")){s.push({type:"metamask",legacyInjectedProvider:d});continue}if(u==="Phantom"&&!s.find(y=>y.type==="phantom")){s.push({type:"phantom",legacyInjectedProvider:d});continue}s.find(y=>y.type==="unknown_browser_extension")||s.push({type:"unknown_browser_extension",legacyInjectedProvider:d})}}a(s)}})}function Bo(e){return`eip155:${String(Number(e))}`}var Qi=(e,t,r,o)=>{let n=Number(e),a=t.find(l=>l.id===n);if(!a)throw new Z(`Unsupported chainId ${e}`,4901);let i;if(a.rpcUrls.privyWalletOverride&&a.rpcUrls.privyWalletOverride.http[0])i=a.rpcUrls.privyWalletOverride.http[0];else if(r.rpcUrls&&r.rpcUrls[n])i=r.rpcUrls[n];else if(a.rpcUrls.privy?.http[0]){let l=new URL(a.rpcUrls.privy.http[0]);l.searchParams.append("privyAppId",o),i=l.toString()}else a.rpcUrls.infura?.http[0]?i=a.rpcUrls.infura.http[0]+"/"+ol:a.rpcUrls.blast?.http[0]?i=a.rpcUrls.blast.http[0]+"/"+nl:i=a.rpcUrls.default?.http[0];if(!i)throw new Z(`No RPC url found for ${e}`);return i},Xd=(e,t)=>{let r=Number(e),o=t.find(n=>n.id===r);if(!o)throw new Z(`Unsupported chainId ${e}`,4901);return o.blockExplorers?.default.url},Sr=(e,t,r,o)=>{let n=Number(e),a=t.find(l=>l.id===n);if(!a)throw new Z(`Unsupported chainId ${e}`,4901);let i;if(a.rpcUrls.privyWalletOverride&&a.rpcUrls.privyWalletOverride.http[0]?i=new Uo(a.rpcUrls.privyWalletOverride.http[0]):r.rpcUrls&&r.rpcUrls[n]?i=new Uo(r.rpcUrls[n]):a.rpcUrls.privy?.http[0]?i=new Uo({url:a.rpcUrls.privy.http[0],headers:{"privy-app-id":o.appId}}):a.rpcUrls.infura?.http[0]?i=new Uo(a.rpcUrls.infura.http[0]+"/"+ol):a.rpcUrls.blast?.http[0]?i=new Uo(a.rpcUrls.blast.http[0]+"/"+nl):i=new Uo(a.rpcUrls.default?.http[0]),!i)throw new Z(`No RPC url found for ${e}`);return i},Xi=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map(([o,n])=>{if(n!=null&&typeof o=="string"&&o in t)return{name:o,type:t[o]}}).filter(o=>o!==void 0);return{...e,types:{...e.types,EIP712Domain:r}}};var ea=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(Ho))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var Ho={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"}}};function Ky(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}var ep=e=>e in Ho,tp=e=>{let t=Ho[e].mobile;if("native"in t)return t.native};function rp(e,t){let r=Ky(t);if(r.deepLink)return sp(r.deepLink,e);if(r.universalLink)return lp(r.universalLink,e);throw new S(`Unsupported wallet ${t.id}`)}var op="WALLETCONNECT_DEEPLINK_CHOICE";function np(){try{localStorage.removeItem(op)}catch{}}function ip({href:e,name:t}){try{localStorage.setItem(op,JSON.stringify({href:e,name:t}))}catch{}}function ap(e){return e.startsWith("http://")||e.startsWith("https://")}function sp(e,t){if(ap(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(!ap(e))return sp(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function ta(e,t){window.open(e,t,"noreferrer noopener")}var ot=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 Vn=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new ot(this._startChannelOnce.bind(this)),this.pollForReady=new ot(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.channelToken)throw new S("Auth flow must be initialized first");try{let t=await this.api.post(ud,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new S("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ue(t)}}async link(){if(!this.api)throw new S("Auth flow has no API instance");try{return await this.api.post(md,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw ue(t)}}async _startChannelOnce(){if(!this.api)throw new S("Auth flow has no API instance");let t=await this.api.post(pd,{token:this.captchaToken});Yy&&!Jy&&t.connect_uri&&ta(t.connect_uri,"_blank"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new S("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.channelToken)throw new S("Auth flow must be initialized first");let t=await this.api.get(fd,{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 pp}from"jose";async function cp(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function dp(e){return crypto.getRandomValues(new Uint8Array(e))}function ra(){return!!j.get(ho)}var Zy="S256",Qy="S256",ir=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:ra();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 S("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new S("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new S("User denied confirmation during OAuth flow");let t=j.get(Do);if(!t)throw new S("Authentication error.");try{let r=await this.api.post(Sd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return j.del(Do),this.meta.headless&&j.del(ho),{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(r){let o=ue(r);throw o.privyErrorCode?new S(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new S("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new S("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new S("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new S("User denied confirmation during OAuth flow");let t=j.get(Do);if(!t)throw new S("Authentication error.");try{let r=await this.api.post(_d,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return j.del(Do),r}catch(r){throw ue(r)}}createCodeVerifier(){return pp.encode(dp(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,r=Zy){if(r==Qy){let o=await cp(t);return pp.encode(o)}else return t}async getAuthorizationUrl(){if(!this.api)throw new S("Auth flow has no API instance");if(!this.meta.provider)throw new S("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();j.put(Do,t);let r=this.createStateCode();j.put(fo,r);let o=await this.deriveCodeChallengeFromCodeVerifier(t);this.meta.headless&&j.put(ho,!0);try{return await this.api.post(xd,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw ue(n)}}};function ul(e){return e.charAt(0).toUpperCase()+e.slice(1)}function up(e,t){let r={detail:"",retryable:!1},o=ul(t);return 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==="oauth_account_suspended"&&(r.detail=`Your ${o} account is suspended. Please try another login method.`),r}function qn(){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");return!t||!r||!o?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:ra()}}function $n(){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"),j.del(fo),window.history.replaceState({},"",e)}var vo=class{constructor(t,r){this.createSiweMessage=(t,r,o,n,a,i,l)=>`${o} wants you to sign in with your Ethereum account:
|
|
2
2
|
${r}
|
|
3
3
|
|
|
4
4
|
${l}
|
|
@@ -2749,4 +2749,4 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2749
2749
|
opacity: 1;
|
|
2750
2750
|
}
|
|
2751
2751
|
}
|
|
2752
|
-
`;import{jsx as Ge,jsxs as Ay}from"react/jsx-runtime";var CE={["LANDING"]:zf,["CONNECT_OR_CREATE"]:Gf,["AWAITING_PASSWORDLESS_CODE"]:Su,["AWAITING_CONNECTION"]:qu,["AWAITING_CONNECT_ONLY_CONNECTION"]:Yu,["AWAITING_FARCASTER_CONNECTION"]:Qm,["AWAITING_FARCASTER_SIGNER"]:nf,["PHANTOM_INTERSTITIAL_SCREEN"]:sy,["LOGIN_FAILED_SCREEN"]:Zf,["AWAITING_OAUTH_SCREEN"]:oy,["ALLOWLIST_REJECTION_SCREEN"]:yu,["INSTALL_PHANTOM_SCREEN"]:wf,["LINK_EMAIL_SCREEN"]:qf,["LINK_PHONE_SCREEN"]:$f,["LINK_WALLET_SCREEN"]:jf,["UPDATE_EMAIL_SCREEN"]:Ty,["CONNECT_ONLY_LANDING_SCREEN"]:Gu,["CONNECT_ONLY_AUTHENTICATED_SCREEN"]:Uu,["EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN"]:Lm,["EMBEDDED_WALLET_CREATED_SCREEN"]:rm,["EMBEDDED_WALLET_CONNECTING_SCREEN"]:em,["EMBEDDED_WALLET_RECOVERY_SCREEN"]:Dm,["EMBEDDED_WALLET_KEY_EXPORT_SCREEN"]:am,["EMBEDDED_WALLET_SIGN_REQUEST_SCREEN"]:yy,["EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN"]:fy,["FIAT_ON_RAMP_PROMPT_SCREEN"]:pf,["FIAT_ON_RAMP_STATUS_SCREEN"]:mf,["EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN"]:Nm,["EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN"]:Om,["MFA_ENROLLMENT_FLOW_SCREEN"]:ph,["CAPTCHA_SCREEN"]:Ru,["ERROR_SCREEN"]:Fm,["IN_APP_BROWSER_LOGIN_NOT_POSSIBLE"]:ff,["AFFIRMATIVE_CONSENT_SCREEN"]:fu},bE=["LANDING","AWAITING_CONNECTION"],EE=({isMfaVerifying:e,onMfaVerificationComplete:t})=>{let{ready:r,isModalOpen:o}=G(),{headless:n}=W(),{ready:a,currentScreen:i}=_(),{status:l,execute:s,reset:d,enabled:u}=fe(),y=gE(null),f=tu(y),g=o&&i&&bE.includes(i)&&!n&&l==="ready";if(_y(()=>{g&&s()},[g]),_y(()=>{!o&&u&&d()},[o,u]),(!r||!a)&&i!=="AWAITING_OAUTH_SCREEN")return Ay(Sn,{children:[Ge(A,{}),Ge(K,{}),Ge(eh,{children:Ge(ft,{})}),Ge(oe,{}),Ge(X,{})]});if(!i&&e)return Ge(Sn,{style:{height:f},children:Ge("div",{ref:y,children:Ge(Yc,{open:e,onClose:t})})});if(!i)return null;let E=CE[i];return Ge(Sn,{style:{height:f},children:Ay("div",{ref:y,children:[Ge(Ar,{if:!!e,children:Ge(E,{})}),Ge(Ar,{if:!e,children:Ge(Yc,{open:e,onClose:t})})]})})},TE=()=>{let{closePrivyModal:e}=W(),{onUserCloseViaDialogOrKeybindRef:t}=_();return{gracefulClosePrivyModal:yE(()=>{if(t?.current)t.current();else return e({shouldCallAuthOnSuccess:!1})},[e])}},ky=({open:e})=>{let{app:t}=_(),{gracefulClosePrivyModal:r}=TE(),[o,n]=vE(!1);Tl({onMfaRequired:()=>{t?.mfa.noPromptOnMfaRequired||n(!0)}});let a=Ge(Sy,{children:Ge(EE,{isMfaVerifying:o,onMfaVerificationComplete:()=>n(!1)})}),i=e||o,l=t?.render.inDialog?Ge(Xf,{open:i,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:a}):a;if(typeof window<"u"&&t?.render.inParentNodeId){let s=document.getElementById(t.render.inParentNodeId);if(s)return wE.createPortal(l,s)}return l};import{useState as PE}from"react";import{useEffect as Ry,useRef as Iy}from"react";var qs=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:connect":return o;case"privy:wallet:recover":return o;case"privy:wallet:rpc":return o;case"privy:wallet:set-recovery-password":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:submit-cast":return o;case"privy:farcaster:remove-cast":return o;case"privy:farcaster:react-to-cast":return o;case"privy:farcaster:submit-link":return o;case"privy:farcaster:remove-link":return o;default:throw new Error(`invalid wallet event type ${t}`)}}};async function Wo(e,t,r,o,n,a=!1){let i=a,l=async u=>{if(i&&t&&t.length>0){u===(a?0:1)?n("configureMfa","onMfaRequired",t):o.current?.reject(new ye("missing_or_invalid_mfa","MFA verification failed, retry."));let y=await new Promise((f,g)=>{r.current={resolve:f,reject:g};let E=1e3*60*5;setTimeout(()=>{let v=new ye("mfa_timeout","Timed out waiting for MFA code");o.current?.reject(v),g(v)},E)});return await e(y)}return await e()},s=4,d=null;for(let u=0;u<s;u++)try{d=await l(u),o.current?.resolve(void 0);break}catch(y){if(y.type==="missing_or_invalid_mfa")i=!0;else throw o.current?.resolve(void 0),y}if(d===null){let u=new ye("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw o.current?.reject(u),u}return d}import{jsx as RE}from"react/jsx-runtime";var xE=function(e){return()=>`id-${e++}`}(0);function SE(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Ve(e){return e.error!==void 0}var Ie=new qs,Qc=new Map,_E=(e,t)=>typeof t=="bigint"?t.toString():t,AE=(e,t)=>`${e}${JSON.stringify(t,_E)}`;function ze(e,t,r,o){let n=r.contentWindow;if(!n)throw new Error("iframe not initialized");let a=AE(e,t);if(e==="privy:wallet:create"){let l=Qc.get(a);if(l)return l}let i=new Promise((l,s)=>{let d=xE();Ie.enqueue(d,{resolve:l,reject:s}),n.postMessage({id:d,event:e,data:t},o)}).finally(()=>{Qc.delete(a)});return Qc.set(a,i),i}function kE(e){switch(e.event){case"privy:iframe:ready":let t=Ie.dequeue(e.event,e.id);return Ve(e)?t.reject(new ye(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let r=Ie.dequeue(e.event,e.id);return Ve(e)?r.reject(new ye(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:connect":let o=Ie.dequeue(e.event,e.id);return Ve(e)?o.reject(new ye(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:recover":let n=Ie.dequeue(e.event,e.id);return Ve(e)?n.reject(new ye(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:rpc":let a=Ie.dequeue(e.event,e.id);return Ve(e)?a.reject(new ye(e.error.type,e.error.message)):a.resolve(e.data);case"privy:wallet:set-recovery-password":let i=Ie.dequeue(e.event,e.id);return Ve(e)?i.reject(new ye(e.error.type,e.error.message)):i.resolve(e.data);case"privy:mfa:verify":let l=Ie.dequeue(e.event,e.id);return Ve(e)?l.reject(new ye(e.error.type,e.error.message)):l.resolve(e.data);case"privy:mfa:init-enrollment":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:submit-enrollment":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:unenroll":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:clear":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:init-signer":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:submit-cast":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:remove-cast":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:react-to-cast":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:submit-link":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:remove-link":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}function My(e){let t=Iy(null),r=Iy(e.mfaMethods),o=nu(),[n,a]=PE(!1);return Ry(()=>{r.current=e.mfaMethods},[e.mfaMethods]),Ry(()=>{if(!n)return;let i=t.current;if(!i)return;function l(f){f&&f.origin===e.origin&&SE(f.data)&&kE(f.data)}let s={create(f){return ze("privy:wallet:create",f,i,e.origin)},connect(f){return ze("privy:wallet:connect",f,i,e.origin)},recover(f){return Wo(g=>ze("privy:wallet:recover",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},rpc(f){return Wo(g=>ze("privy:wallet:rpc",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},setRecoveryPassword(f){return Wo(g=>ze("privy:wallet:set-recovery-password",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},verifyMfa(f){return Wo(g=>ze("privy:mfa:verify",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},initEnrollMfa(f){return Wo(g=>ze("privy:mfa:init-enrollment",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},submitEnrollMfa(f){return ze("privy:mfa:submit-enrollment",f,i,e.origin)},unenrollMfa(f){return Wo(g=>ze("privy:mfa:unenroll",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},clearMfa(f){return ze("privy:mfa:clear",f,i,e.origin)},initFarcasterSigner(f){return ze("privy:farcaster:init-signer",f,i,e.origin)},submitCast(f){return ze("privy:farcaster:submit-cast",f,i,e.origin)},removeCast(f){return ze("privy:farcaster:remove-cast",f,i,e.origin)},reactToCast(f){return ze("privy:farcaster:react-to-cast",f,i,e.origin)},submitLink(f){return ze("privy:farcaster:submit-link",f,i,e.origin)},removeLink(f){return ze("privy:farcaster:remove-link",f,i,e.origin)}};window.addEventListener("message",l);let d=()=>e.onLoad(s),u=(...f)=>{console.warn("Privy iframe failed to load: ",...f),e.onLoadFailed()},y=new AbortController;return Jd(()=>ze("privy:iframe:ready",{},i,e.origin),{abortSignal:y.signal}).then(d,u),()=>{window.removeEventListener("message",l),y.abort()}},[n]),RE("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>a(!0),src:Zi(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId})})}function $s(e){let t=e.toLowerCase();return["fbav","fban","instagram","snapchat"].some(o=>t.includes(o))}var js=class{constructor(t,r){this.meta={action:t,phoneNumber:r}}async init(){if(!this.meta.action)throw new S("action required");if(!this.api)throw new S("Auth flow has no API instance");if(this.meta.action==="enroll"&&!this.meta.phoneNumber)throw new S("phone number must be set when initialzing authentication.");try{await this.api.post(kd,{action:this.meta.action,phoneNumber:this.meta.phoneNumber})}catch(t){throw ue(t)}}async authenticate(){if(!this.meta.action)throw new S("action required");if(!this.api)throw new S("Mfa flow has no API instance");if(!this.meta.smsCode)throw new S("sms code must be set prior to calling authenticate.");if(this.meta.action==="enroll"&&!this.meta.phoneNumber)throw new S("phone number must be set prior to calling authenticate.");try{let t=await this.api.post(Rd,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return Ct(t)}catch(t){throw ue(t)}}};import{jsx as Er,jsxs as Wy}from"react/jsx-runtime";var Un;function LE(e){return typeof e=="string"&&e.length===25}function ve(){if(!Un){let e=j.get(mo);return Promise.resolve(e||null)}return Un.getAccessToken()}var Ly,hp=(e,t)=>Ly(e,t),Oy,yp=(e,t)=>Oy(e,t),Ny,gp=(e,t)=>Ny(e,t),Dy,vp=()=>Dy(),OE=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;j.put(Hn,t);let r=new URL(window.location.href);r.searchParams.delete("privy_token"),window.history.pushState({},"",r)},NE=({config:e,...t})=>{if(!LE(t.appId))throw new S("Cannot initialize the Privy provider with an invalid Privy app ID");Un||(Un=new Qn({appId:t.appId,apiUrl:t.apiUrl||$i}));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."),Er(qp,{client:Un,clientConfig:r,legacyCreateEmbeddedWalletFlag:t.createPrivyWalletOnLogin,children:Er(DE,{...t,config:r,client:Un})})},DE=e=>{let t=e.client,[r,o]=Me(!1),[n,a]=Me(!1),[i,l]=Me(!1),[s,d]=Me(null),[u,y]=Me([]),f=Fn(u),[g,E]=Me(!1),[v,x]=Me(null),[C,P]=Me(!1),[R,M]=Me({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:b}),[k,B]=Me(null),[U,H]=Me(null),[T,q]=Me(null),O=Sa(),Y=_a(),[se,re]=Me(!0),[te,z]=Me({}),[Pe,we]=Me(null),[Tr,yt]=Me(null),[Ae,ge]=Me(!1),[gt,Ut]=Me(!1),Nr=Fn(null),tr=Fn(null),L=Fn(ru);t.onStoreToken=c=>{c&&N(L,"accessToken","onAccessTokenGranted",c)},t.onDeleteToken=()=>{N(L,"accessToken","onAccessTokenRemoved")};let J=Fn(null),Q=Fn(null),Bn=ME(c=>{let p=t.connectors?.walletsReady||!1;return i&&s?.linkedAccounts?.some(h=>h.type==="wallet"&&h.walletClientType==="privy")?p&&c?.some(h=>h?.walletClientType==="privy"):p},[i,s?.linkedAccounts,t?.connectors?.walletsReady]),$=c=>{x(c),setTimeout(()=>{o(!0)},15),t.createAnalyticsEvent("modal_open",{initialScreen:c})},We=c=>{O.embeddedWallets.createOnLogin!=="off"&&re(!0),$(c)};Or(()=>{if(!T||!s){t.connectors?.removeEmbeddedWalletConnector();return}let c=s?.linkedAccounts.filter(p=>p.type==="wallet"&&p.walletClientType==="privy");if(c&&c.length>0){let p=c[0].address;t.connectors?.addEmbeddedWalletConnector(T,p,O.defaultChain,e.appId)}},[T,s]),Or(()=>{T&&Tr?.(T)},[T]),Or(()=>{(async()=>{if(!O.customAuth?.enabled)return;re(!0);let{getCustomAccessToken:p,isLoading:m}=O.customAuth;if(!(!n||m))try{let h=await p();if(!h){await Lo.logout();return}if(i)return;t.startAuthFlow(new No(h));let{user:I,isNewUser:D}=await t.authenticate();I||await Lo.logout(),d(I||null),E(D||!1),l(!0),Ut(!0)}catch(h){console.warn(h),i&&await Lo.logout()}})()},[O.customAuth?.enabled,O.customAuth?.getCustomAccessToken,O.customAuth?.isLoading,n,i]),Or(()=>{gt&&T&&s&&At(s,e.config?.embeddedWallets?.createOnLogin)&&(Ut(!1),or(s,Fo).catch(console.error))},[gt&&T&&s]),Or(()=>{async function c(){let p=pt();OE();let m=IE();B(m),t.initializeConnectorManager({walletConnectCloudProjectId:O.walletConnectCloudProjectId,rpcConfig:O.rpcConfig,chains:O.chains,defaultChain:O.defaultChain,store:m,walletList:O.appearance.walletList,shouldEnforceDefaultChainOnConnect:O.shouldEnforceDefaultChainOnConnect,appName:O.name??"Privy"}),t.connectors?.initialize().then(()=>{Ys()});let h=await t.getAuthenticatedUser();e.config?.customAuth?.enabled||(l(!!h),h&&N(L,"login","onComplete",h,!1,!0,null),d(h)),p||ie.setReadyToTrue(),p&&(h?Q.current="link":Q.current="login")}!n&&Y&&c()},[t,Pe,n,Y]);let pt=()=>{let c=qn();return!c.inProgress||c.headless?!1:(t.startAuthFlow(new ir(c)),We("AWAITING_OAUTH_SCREEN"),!0)},co=async(c,p,m,h)=>{let I=await t.connectors?.createWalletConnector(c,p)||null;Bt(I,p,m,h)};async function Bt(c,p,m,h){if(c)M({status:"disconnected",connectedWallet:null,connectError:null,connector:c,connectRetry:b});else return M({status:"disconnected",connectedWallet:null,connectError:new Z("Unable to connect to wallet."),connector:null,connectRetry:b}),h?.(null,m);c instanceof cr&&p&&await c.resetConnection(p),M({connector:c,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Bt(c,p,m,h)});try{let I=await c.connect({showPrompt:!0});if(O.shouldEnforceDefaultChainOnConnect&&!O.chains.find(D=>D.id===Number(I?.chainId))&&!(I?.connectorType==="wallet_connect_v2"&&I?.walletClientType==="metamask")){M(D=>({...D,connector:c,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:b}));try{await I?.switchChain(O.defaultChain.id),I&&(I.chainId=Bo(go(O.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${O.defaultChain.id}`)}}return M(D=>({...D,status:"connected",connectedWallet:I,connectError:null,connectRetry:b})),I&&!Q.current&&N(L,"connectWallet","onSuccess",I),h?.(I,m)}catch(I){return I instanceof $e?(console.warn(I.cause?I.cause:I.message),Q.current||N(L,"connectWallet","onError",I.privyErrorCode||"generic_connect_wallet_error")):(console.warn(I),Q.current||N(L,"connectWallet","onError","unknown_connect_wallet_error")),M(D=>({...D,status:"disconnected",connectedWallet:null,connectError:I})),h?.(null,m)}}let po=async(c,p)=>{if(c===null)return;let m=new vo(c,p);t.startAuthFlow(m)},Ys=()=>{let c=new URLSearchParams(window.location.search),p=c.get("privy_connector"),m=c.get("privy_wallet_client");if(!p||!m)return;if(m==="phantom"&&!Ur()&&We("LOGIN_FAILED_SCREEN"),!t.connectors)throw new S("Connector not initialized");$("AWAITING_CONNECTION");let h=new URL(window.location.href);h.searchParams.delete("privy_connector"),h.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",h),co(p,m,void 0,po)};Or(()=>{n&&i&&s===null&&t.getAuthenticatedUser().then(d)},[n,i,s,t]);let Le=()=>{if(!i)throw N(L,"linkAccount","onError","must_be_authenticated"),new S("User must be authenticated before linking an account.")},uo=()=>{Le(),J.current="siwe",Q.current="link",$("LINK_WALLET_SCREEN")},vt=c=>{if(!i||!s)return!1;if(c.walletClientType==="privy")return!0;for(let p of s.linkedAccounts)if(p.type==="wallet"&&p.address===c.address&&p.walletClientType!=="privy")return!0;return!1},qe=async c=>{if(!t.connectors)throw new S("Connector not initialized");let p=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null;if(M(m=>({...m,connector:p,status:"connected",connectedWallet:c,connectError:null,connectRetry:b})),O.captchaEnabled&&!i){let m={callback:h=>po(c,h),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"};z({captchaModalData:m}),We("CAPTCHA_SCREEN")}else await po(c),We("AWAITING_CONNECTION")},rr=async(c,p)=>{if(!O.fiatOnRamp.enabled)throw new S("Fiat on-ramp is not enabled");if(!p||!p.provider||p.provider==="moonpay"){let{signedUrl:m,externalTransactionId:h}=await cf(t,c,p?.config??{},O.appearance.palette,O.fiatOnRamp.useSandbox);return{signedUrl:m,externalTransactionId:h}}else throw new S("Unsupported fund provider. Currently supported option is `moonpay`.")},Dr=()=>{y(c=>{let p=t.connectors?.wallets.map(m=>({...m,linked:vt(m),loginOrLink:async()=>{if(!await m.isConnected())throw new S("Wallet is not connected");if(m.connectorType==="embedded"&&m.walletClientType==="privy")throw new S("Cannot link or login with embedded wallet");qe(m)},fund:async h=>{let{signedUrl:I,externalTransactionId:D}=await rr(m.address,h);z({fiatOnRampPrompt:{signedUrl:I},fiatOnRampStatus:{externalTransactionId:D}}),$("FIAT_ON_RAMP_PROMPT_SCREEN")},unlink:async()=>{if(!i)throw new S("User is not authenticated.");if(m.connectorType==="embedded"&&m.walletClientType==="privy")throw new S("Cannot unlink an embedded wallet");let h=await t.unlinkWallet(m.address);d(h)}}))||[];return ge(Bn(p)),ia(c,p)?c:p})};Or(()=>{Dr()},[s?.linkedAccounts,i,n]),Or(()=>{if(n){if(!t.connectors)throw new S("Connector not initialized");Dr(),t.connectors.on("walletsUpdated",Dr)}},[n]);let Ni=()=>{$(i?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};Or(()=>{if(!u[0])return;let c=u[0],p=f.current.find(h=>h.address===c.address),m;if(c.walletClientType==="privy"?m=s?.linkedAccounts.find(h=>h.type==="wallet"&&h.address===c.address&&h.walletClientType==="privy"):m=s?.linkedAccounts.find(h=>h.type==="wallet"&&h.address===c.address&&h.walletClientType!=="privy"),!p&&m){let h=Object.assign({},s);h.wallet=m&&{address:m.address,chainType:m.chainType,chainId:m.chainId,walletClient:m.walletClient,walletClientType:m.walletClientType,connectorType:m.connectorType},d(h)}f.current=u},[u]);let or=async(c,p)=>{if(Ce(c))throw N(L,"createWallet","onError","embedded_wallet_already_exists"),new Error("Only one Privy wallet per user is currently allowed");let[h,I]=await Promise.all([ie.initializeWalletProxy(p),ve()]);if(!h&&e.config?.customAuth?.enabled)throw N(L,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!h||!I||e.config?.embeddedWallets?.requireUserPasswordOnCreate)return new Promise((D,le)=>{re(!0),z({createWallet:{onSuccess:ut=>{N(L,"createWallet","onSuccess",ut),D(ut)},onFailure:ut=>{N(L,"createWallet","onError","unknown_embedded_wallet_error"),le(ut)},callAuthOnSuccessOnClose:!1}}),$("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{await h.create({accessToken:I});let D=await ie.refreshUser(),le=Ce(D);if(!le)throw N(L,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return N(L,"createWallet","onSuccess",le),le}},Js=c=>{if(!O.chains.map(p=>p.id).includes(c))throw new Z(`Chain ID ${c} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},ed=(c,p,m)=>new Promise(async(h,I)=>{if(!i||!s){N(L,"sendTransaction","onError","must_be_authenticated"),I(new Error("User must be authenticated before signing with a Privy wallet"));return}let D=Ce(s);if(!D){N(L,"sendTransaction","onError","embedded_wallet_not_found"),I(new Error("Must have a Privy wallet before signing"));return}re(!0);let le=t.connectors?.findWalletConnector("embedded","privy")?.proxyProvider,et=c.chainId?Number(c.chainId):le.chainId;Js(et);let ut=Object.assign({},c,{chainId:et}),Pr=async()=>{let tt=await ve();if(!tt||!T){N(L,"sendTransaction","onError","embedded_wallet_not_found"),I(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await ie.recoverEmbeddedWallet()){N(L,"sendTransaction","onError","unknown_connect_wallet_error"),I(new Error("Unable to connect to wallet"));return}let Vt=Sr(ut.chainId,O.chains,O.rpcConfig,{appId:e.appId}),Zs=await Ln(D.address,ut,Vt);if(O.embeddedWallets.noPromptOnSignature){let{totalGasEstimate:Gy}=await Wn(Zs,Vt),{hasSufficientFunds:Vy}=await Bs(D.address,Zs,Gy,Vt);if(!Vy)throw new xe(new kt("Wallet has insufficient funds for this transaction.",je.E32603_DEFAULT_INTERNAL_ERROR.eipCode))}let od=await Us(tt,D.address,T,Zs,Vt);N(L,"sendTransaction","onSuccess",od),h(od)}catch(Gt){N(L,"sendTransaction","onError","transaction_failure"),I(Gt)}};if(O.embeddedWallets.noPromptOnSignature)p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),Pr();else{let tt={transactionRequest:ut,onSuccess:Vt=>{N(L,"sendTransaction","onSuccess",Vt),h(Vt)},onFailure:Vt=>{N(L,"sendTransaction","onError","transaction_failure"),I(Vt)},uiOptions:p||{},fundWalletConfig:m},Gt={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:Vt=>{N(L,"sendTransaction","onError","unknown_connect_wallet_error"),I(Vt)}};z({connectWallet:Gt,sendTransaction:tt}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")}});function td(){return new Promise(async(c,p)=>{let m=await ve();if(!m||!T)throw new Error("Must have valid access token to enroll in MFA");try{await T.verifyMfa({accessToken:m}),c()}catch(h){p(h)}})}let Ht=c=>{if(s?.[c])throw N(L,"linkAccount","onError","cannot_link_more_of_type"),new S(`User already has an account of type ${c} linked.`)},Lo={ready:n,authenticated:i,user:s,walletConnectors:t.connectors||null,connectWallet:Ni,linkWallet:uo,linkEmail:()=>{Le(),Ht("email"),J.current="email",Q.current="link",$("LINK_EMAIL_SCREEN")},linkPhone:()=>{Le(),Ht("phone"),J.current="sms",Q.current="link",$("LINK_PHONE_SCREEN")},linkGoogle:async()=>{Le(),Ht("google"),Q.current="link",await ie.initLoginWithOAuth("google")},linkTwitter:async()=>{Le(),Ht("twitter"),Q.current="link",await ie.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Le(),Ht("discord"),Q.current="link",await ie.initLoginWithOAuth("discord")},linkGithub:async()=>{Le(),Ht("github"),Q.current="link",await ie.initLoginWithOAuth("github")},linkSpotify:async()=>{Le(),Ht("spotify"),Q.current="link",await ie.initLoginWithOAuth("spotify")},linkTiktok:async()=>{Le(),Ht("tiktok"),Q.current="link",await ie.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Le(),Ht("linkedin"),Q.current="link",await ie.initLoginWithOAuth("linkedin")},linkApple:async()=>{Le(),Ht("apple"),Q.current="link",await ie.initLoginWithOAuth("apple")},linkFarcaster:async()=>{Le(),Ht("farcaster"),await ie.initLoginWithFarcaster(),Q.current="link",J.current="farcaster",$("AWAITING_FARCASTER_CONNECTION")},updateEmail:()=>{if(Le(),!s?.email)throw new S("User does not have an email linked to their account.");Q.current="link",J.current="email",$("UPDATE_EMAIL_SCREEN")},login:async()=>{if(n||(await new Promise(c=>{we(()=>c)}),we(null)),i){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}Q.current="login",We("LANDING")},connectOrCreateWallet:async()=>{if(n||(await new Promise(c=>{we(()=>c)}),we(null)),i){console.warn("User must be unauthenticated to `connectOrCreateWallet`");return}if(u[0]){console.warn("User must have no connected wallets to `connectOrCreateWallet`");return}We("CONNECT_OR_CREATE")},logout:async()=>{await t.logout(),s&&T&&await T.clearMfa({userId:s.id}),d(null),l(!1),x(null),N(L,"logout","onSuccess"),Q.current=null,J.current=null,o(!1),j.del(Gn)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{if(!s||!s.wallet)return new be;let c=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(h=>h.address===c?.address));return!c||!p?new be:p.proxyProvider},getEthersProvider:()=>{if(!s||!s.wallet)return new Xc(new ar(new be));let c=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(h=>h.address===c?.address));return!c||!p?new Xc(new ar(new be)):new Xc(new ar(p.proxyProvider))},getWeb3jsProvider:()=>{if(!s||!s.wallet)return new Gr(new be);let c=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(h=>h.address===c?.address));return!c||!p?new Gr(new be):new Gr(p.proxyProvider)},unlinkWallet:async c=>{let p=await t.unlinkWallet(c);return d(p),p},unlinkEmail:async c=>{let p=await t.unlinkEmail(c);return d(p),p},unlinkPhone:async c=>{let p=await t.unlinkPhone(c);return d(p),p},unlinkGoogle:async c=>{let p=await t.unlinkOAuth("google",c);return d(p),p},unlinkTwitter:async c=>{let p=await t.unlinkOAuth("twitter",c);return d(p),p},unlinkDiscord:async c=>{let p=await t.unlinkOAuth("discord",c);return d(p),p},unlinkGithub:async c=>{let p=await t.unlinkOAuth("github",c);return d(p),p},unlinkSpotify:async c=>{let p=await t.unlinkOAuth("spotify",c);return d(p),p},unlinkTiktok:async c=>{let p=await t.unlinkOAuth("tiktok",c);return d(p),p},unlinkLinkedIn:async c=>{let p=await t.unlinkOAuth("linkedin",c);return d(p),p},unlinkApple:async c=>{let p=await t.unlinkOAuth("apple",c);return d(p),p},unlinkFarcaster:async c=>{let p=await t.unlinkFarcaster(c);return d(p),p},setActiveWallet:async c=>{let p=u.find(h=>Ks(h.address)===Ks(c)),m=s?.linkedAccounts.find(h=>h.type==="wallet"&&Ks(h.address)===Ks(c));if(!p||!await p.isConnected())H(c),uo();else if(!p.linked)p.loginOrLink();else{let h=Object.assign({},s);h.wallet=m&&{address:m.address,chainType:m.chainType,chainId:m.chainId,walletClient:m.walletClient,walletClientType:m.walletClientType,connectorType:m.connectorType},d(h)}},forkSession:()=>t.forkSession(),createWallet:async()=>{if(!i||!s)throw N(L,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return or(s,15e3)},setWalletPassword:async()=>{if(!i||!s)throw N(L,"setWalletPassword","onError","must_be_authenticated"),new Error("User must be authenticated before adding password to Privy wallet");let c=Ce(s);if(!c||!T)throw N(L,"setWalletPassword","onError","embedded_wallet_not_found"),new Error("Must have a Privy wallet to add a password");if(c.recoveryMethod==="user-passcode")throw N(L,"setWalletPassword","onError","embedded_wallet_password_already_exists"),new Error("Cannot set password. Embedded wallet already has a password.");try{await td()}catch(p){throw N(L,"setWalletPassword","onError","missing_mfa_credentials"),p}return new Promise((p,m)=>{re(!0);let h={onSuccess:D=>{N(L,"setWalletPassword","onSuccess",D),p(D)},onFailure:D=>{N(L,"setWalletPassword","onError","user_exited_set_password_flow"),m(D)},callAuthOnSuccessOnClose:!1},I={onCompleteNavigateTo:"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",onFailure:D=>{N(L,"setWalletPassword","onError","unknown_connect_wallet_error"),m(D)}};z({setWalletPassword:h,connectWallet:I}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")})},signMessage:(c,p)=>new Promise(async(m,h)=>{if(!i||!s){N(L,"signMessage","onError","must_be_authenticated"),h(new Error("User must be authenticated before signing with a Privy wallet"));return}let I=Ce(s);if(!I){N(L,"signMessage","onError","embedded_wallet_not_found"),h(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){N(L,"signMessage","onError","invalid_message"),h(new Error("Message must be a non-empty string"));return}re(!0);let D=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let le=await ve();if(!T||!le)throw new Error("Unable to connect to wallet");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:I.address});let{response:ut}=await T.rpc({accessToken:le,address:I.address,request:{method:"personal_sign",params:[c,I.address]}}),Pr=ut.data;return t.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:I.address}),Pr};if(O.embeddedWallets.noPromptOnSignature){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let le=await D();N(L,"signMessage","onSuccess",le),m(le)}catch(le){N(L,"signMessage","onError","unable_to_sign"),h(le??new xe("Unable to sign message"))}}else{let ut={method:"personal_sign",data:c,confirmAndSign:D,onSuccess:tt=>{N(L,"signMessage","onSuccess",tt),m(tt)},onFailure:tt=>{N(L,"signMessage","onError","unable_to_sign"),h(tt)},uiOptions:p||{}},Pr={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:tt=>{N(L,"signMessage","onError","unknown_connect_wallet_error"),h(tt)}};z({signMessage:ut,connectWallet:Pr}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),signTypedData:(c,p)=>new Promise(async(m,h)=>{if(!i||!s){N(L,"signTypedData","onError","must_be_authenticated"),h(new Error("User must be authenticated before signing with a Privy wallet"));return}let I=Ce(s);if(!I){N(L,"signTypedData","onError","embedded_wallet_not_found"),h(new Error("Must have a Privy wallet before signing"));return}re(!0);let D=Xi(c),le=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let et=await ve();if(!T||!et)throw new Error("Unable to connect to wallet");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent("embedded_wallet_sign_typed_data_started",{walletAddress:I.address});let{response:Pr}=await T.rpc({accessToken:et,address:I.address,request:{method:"eth_signTypedData_v4",params:[I.address,D]}}),tt=Pr.data;return t.createAnalyticsEvent("embedded_wallet_sign_typed_data_completed",{walletAddress:I.address}),tt};if(O.embeddedWallets.noPromptOnSignature||(O.legacyWalletUiConfig??!1)){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let et=await le();N(L,"signTypedData","onSuccess",et),m(et)}catch(et){N(L,"signTypedData","onError","unable_to_sign"),h(et??new xe("Unable to sign message"))}}else{let Pr={method:"eth_signTypedData_v4",data:D,confirmAndSign:le,onSuccess:Gt=>{N(L,"signTypedData","onSuccess",Gt),m(Gt)},onFailure:Gt=>{N(L,"signTypedData","onError","unable_to_sign"),h(Gt)},uiOptions:p||{}},tt={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Gt=>{N(L,"signMessage","onError","unknown_connect_wallet_error"),h(Gt)}};z({signMessage:Pr,connectWallet:tt}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:async(c,p,m)=>{let I=await(await ed(c,p,m)).wait();return Hs(I)},exportWallet:()=>new Promise(async(c,p)=>{if(!i||!s){p(new Error("User must be authenticated before exporting their Privy wallet"));return}let m=Ce(s);if(!m){p(new Error("Must have a Privy wallet before exporting"));return}re(!0);let h={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:p},I=await ve();if(!I||!T){p(new Error("Must have valid access token to enroll in MFA"));return}if(!T){p(new Error("Must have a Privy wallet before exporting"));return}try{try{await T.connect({accessToken:I,address:m.address}),await T.verifyMfa({accessToken:I})}catch(le){if(So(le))await ie.recoverEmbeddedWallet();else throw le}}catch(le){p(le);return}let D={appId:e.appId,origin:t.apiUrl,onSuccess:c,onFailure:p};z({keyExport:D,connectWallet:h}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")}),promptMfa:td,async init(c){let p;switch(c){case"sms":p=new js("verify");break;case"totp":return;default:throw new Error(`Unsupported MFA method: ${c}`)}t.startMfaFlow(p),await p.init()},async submit(c,p){switch(c){case"totp":case"sms":Nr.current?.resolve({mfaMethod:c,mfaCode:p}),await new Promise((m,h)=>{tr.current={resolve:m,reject:h}});break;default:throw Nr.current?.reject(new S("Unsupported MFA method")),new S(`Unsupported MFA method: ${c}`)}},cancel(){Nr.current?.reject(new S("MFA canceled"))},async initEnrollmentWithSms(c){let p=await ve();if(!p||!T)throw new Error("Must have valid access token to enroll in MFA");await T.initEnrollMfa({method:"sms",accessToken:p,phoneNumber:c.phoneNumber})},enrollInMfa(c){return new Promise((p,m)=>{if(!c){ie.closePrivyModal(),p();return}O.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."),z({mfaEnrollmentFlow:{mfaMethods:O.mfa.methods,onSuccess:p,onFailure:m}}),$("MFA_ENROLLMENT_FLOW_SCREEN")})},async initEnrollmentWithTotp(){let c=await ve();if(!c||!T)throw new Error("Must have valid access token to enroll in MFA");let p=await T.initEnrollMfa({method:"totp",accessToken:c});return{secret:p.secret,authUrl:p.authUrl}},async submitEnrollmentWithSms(c){let p=await ve();if(!p||!T)throw new Error("Must have valid access token to enroll in MFA");await T.submitEnrollMfa({method:"sms",accessToken:p,phoneNumber:c.phoneNumber,code:c.mfaCode});let m=await t.getAuthenticatedUser();d(m)},async submitEnrollmentWithTotp(c){let p=await ve();if(!p||!T)throw new Error("Must have valid access token to enroll in MFA");await T.submitEnrollMfa({method:"totp",accessToken:p,code:c.mfaCode});let m=await t.getAuthenticatedUser();d(m)},async unenroll(c){let p=await ve();if(!p||!T)throw new Error("Must have valid access token to remove MFA");await T.unenrollMfa({method:c,accessToken:p});let m=await t.getAuthenticatedUser();d(m)},requestFarcasterSigner:async()=>{let c=await ve(),p=s?.linkedAccounts.find(I=>I.type==="wallet"&&I.walletClientType==="privy");if(!c)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!p)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");let h=await T.initFarcasterSigner({address:p.address,hdWalletIndex:null,accessToken:c,mfaCode:null,mfaMethod:null});if(h.status==="approved"){let I=await t.getAuthenticatedUser();d(I||s||null)}z({farcasterSigner:h}),$("AWAITING_FARCASTER_SIGNER")},submitCast:async c=>{let p=await ve(),m=s?.linkedAccounts.find(D=>D.type==="wallet"&&D.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.submitCast({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:c,fid:BigInt(s.farcaster.fid)})).response.hash}},removeCast:async({castHash:c})=>{let p=await ve(),m=s?.linkedAccounts.find(D=>D.type==="wallet"&&D.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.removeCast({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:c,fid:BigInt(s.farcaster.fid)})).response.hash}},likeCast:async({castHash:c,castAuthorFid:p})=>{let m=await ve(),h=s?.linkedAccounts.find(le=>le.type==="wallet"&&le.walletClientType==="privy");if(!m)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!h)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.reactToCast({address:h.address,hdWalletIndex:null,accessToken:m,mfaCode:null,mfaMethod:null,payload:{type:1,castId:{hash:c,fid:p}},fid:BigInt(s.farcaster.fid)})).response.hash}},recastCast:async({castHash:c,castAuthorFid:p})=>{let m=await ve(),h=s?.linkedAccounts.find(le=>le.type==="wallet"&&le.walletClientType==="privy");if(!m)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!h)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.reactToCast({address:h.address,hdWalletIndex:null,accessToken:m,mfaCode:null,mfaMethod:null,payload:{type:2,castId:{hash:c,fid:p}},fid:BigInt(s.farcaster.fid)})).response.hash}},followUser:async({fid:c})=>{let p=await ve(),m=s?.linkedAccounts.find(D=>D.type==="wallet"&&D.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.submitLink({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{type:"follow",targetFid:c},fid:BigInt(s.farcaster.fid)})).response.hash}},unfollowUser:async({fid:c})=>{let p=await ve(),m=s?.linkedAccounts.find(D=>D.type==="wallet"&&D.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.removeLink({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{type:"follow",targetFid:c},fid:BigInt(s.farcaster.fid)})).response.hash}},isHeadlessOAuthLoading:C,loginWithCode(c){return ie.loginWithCode(c)},initLoginWithEmail(c){return ie.initLoginWithEmail(c)},initLoginWithSms(c){return ie.initLoginWithSms(c)},fundWallet(c,p){return ie.fundWallet(c,p)},initLoginWithHeadlessOAuth(c,p){return ie.initLoginWithHeadlessOAuth(c,p)},loginWithHeadlessOAuth(c){return ie.loginWithHeadlessOAuth(c)},isModalOpen:r};Ly=Lo.signMessage,Oy=Lo.signTypedData,Ny=async(...c)=>{let p=await ed(...c);return O.embeddedWallets.waitForTransactionConfirmation&&await p.wait(),p};let rd=!!e.config?.headless,ie=(()=>({headless:rd,isNewUserThisSession:g,linkingHint:U,pendingTransaction:null,walletConnectionStatus:R,mipdStore:k,connectors:t.connectors?.walletConnectors??[],rpcConfig:O.rpcConfig,chains:O.chains,appId:e.appId,showFiatPrices:O.embeddedWallets.priceDisplay.primary!=="native-token",clientAnalyticsId:t.clientAnalyticsId,nativeTokenSymbolForChainId:c=>O.chains.find(p=>p.id===Number(c))?.nativeCurrency.symbol,initializeWalletProxy:async c=>{if(T)return T;let p=new Promise(I=>{yt(()=>D=>I(D))}),m=new Promise(I=>setTimeout(()=>I(null),c)),h=await Promise.race([p,m]);return yt(null),h},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>t.authFlow?.meta,closePrivyModal:(c={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let p=n&&i&&s;Q.current==="login"?c.shouldCallAuthOnSuccess&&p?(N(L,"login","onComplete",s,g,!1,J.current??null),e.onSuccess?.(s,g)):N(L,"login","onError","exited_auth_flow"):Q.current==="link"&&J.current&&(c.isSuccess&&p?N(L,"linkAccount","onSuccess",s,J.current):N(L,"linkAccount","onError","exited_link_flow")),H(null),Q.current=null,J.current=null,E(!1),o(!1),setTimeout(()=>{t.authFlow=void 0},200),t.createAnalyticsEvent("modal_closed")},openPrivyModal:$,connectWallet:Bt,initLoginWithWallet:async(c,p)=>{J.current="siwe",po(c,p)},loginWithWallet:async()=>{if(!n)throw new Oo;if(!(t.authFlow instanceof vo))throw new S("Must initialize SIWE flow first.");let c,p;if(i)try{c=await t.link(),J.current="siwe"}catch(m){throw N(L,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{({user:c,isNewUser:p}=await t.authenticate()),J.current="siwe"}catch(m){throw N(L,"login","onError",m.privyErrorCode||"generic_connect_wallet_error"),m}d(c||s||null),E(p||!1),l(!0)},initLoginWithFarcaster:async c=>{let p=new Vn(c);t.startAuthFlow(p);try{J.current="farcaster",await p.initializeFarcasterConnect()}catch(m){throw Q.current==="login"?N(L,"login","onError",m.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",m.privyErrorCode||"unknown_auth_error"),m}},loginWithFarcaster:async()=>{if(!n)throw new Oo;if(!(t.authFlow instanceof Vn))throw new S("Must initialize Farcaster flow first.");let c,p;if(i)try{c=await t.link(),J.current="farcaster"}catch(m){throw N(L,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{({user:c,isNewUser:p}=await t.authenticate()),J.current="farcaster"}catch(m){throw N(L,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}d(c||null),E(p||!1),l(!0)},async initLoginWithOAuth(c,p){if(J.current=c,tl()){if(c==="google"&&$s(window.navigator.userAgent)){We("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}}else{We("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}j.del(ho);let m=new ir({provider:c});p&&m.addCaptchaToken(p),t.startAuthFlow(m);let h=await t.authFlow.getAuthorizationUrl();h&&h.url&&window.location.assign(h.url)},async loginWithOAuth(c){if(!(t.authFlow instanceof ir))throw new S("Must initialize OAuth flow before calling loginWithOAuth");let p=j.get(fo),m=t.authFlow.meta.stateCode;if(p!==m)throw t.createAnalyticsEvent("possible_phishing_attempt",{provider:c,storedStateCode:p??"",returnedStateCode:m??""}),new S("Unexpected auth flow. This may be a phishing attempt.");let h,I;if(i)try{h=await t.link(),J.current=c}catch(D){throw N(L,"linkAccount","onError",D.privyErrorCode||"failed_to_link_account"),D}else try{({user:h,isNewUser:I}=await t.authenticate()),J.current=c}catch(D){throw Q.current==="login"?N(L,"login","onError",D.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",D.privyErrorCode||"failed_to_link_account"),D}d(h),E(I||!1),l(!0)},async initLoginWithHeadlessOAuth(c,p){if(tl()){if(c==="google"&&$s(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 m=new ir({provider:c,headless:!0});p&&m.addCaptchaToken(p);let h=await t.startAuthFlow(m).getAuthorizationUrl();h?.url&&window.location.assign(h.url)},async loginWithHeadlessOAuth(c){P(!0),t.startAuthFlow(new ir(c));let p=j.get(fo),m=c.stateCode;if(p!==m)throw t.createAnalyticsEvent("possible_phishing_attempt",{provider:c.provider,storedStateCode:p??"",returnedStateCode:m??""}),P(!1),new S("Unexpected auth flow. This may be a phishing attempt.");let h,I;if(i)try{h=await t.link(),J.current=c.provider}catch(D){throw N(L,"linkAccount","onError",D.privyErrorCode||"failed_to_link_account"),D}else try{({user:h,isNewUser:I}=await t.authenticate()),J.current=c.provider}catch(D){throw Q.current==="login"?N(L,"login","onError",D.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",D.privyErrorCode||"failed_to_link_account"),D}return d(h),E(I||!1),l(!0),P(!1),h??void 0},initLoginWithEmail:async(c,p)=>{let m=new Fr(c,p);t.startAuthFlow(m);try{J.current="email",await m.sendCodeEmail()}catch(h){throw Q.current==="login"?N(L,"login","onError",h.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",h.privyErrorCode||"failed_to_link_account"),h}},initUpdateEmail:async(c,p,m)=>{let h=new Vi(c,p,m);t.startAuthFlow(h),await h.sendCodeEmail()},initLoginWithSms:async(c,p)=>{let m=new wo(c,p);t.startAuthFlow(m);try{J.current="sms",await m.sendSmsCode()}catch(h){throw Q.current==="login"?N(L,"login","onError",h.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",h.privyErrorCode||"failed_to_link_account"),h}},resendEmailCode:async()=>{await t.authFlow?.sendCodeEmail()},resendSmsCode:async()=>{await t.authFlow?.sendSmsCode()},loginWithCode:async c=>{if(!n)throw new Oo;if(t.authFlow instanceof Fr)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof wo)t.authFlow.meta.smsCode=c.trim();else throw new S("Must initialize a passwordless code flow first");let p,m;if(i)try{p=await t.link()}catch(h){throw N(L,"linkAccount","onError",h.privyErrorCode||"failed_to_link_account"),h}else try{({user:p,isNewUser:m}=await t.authenticate())}catch(h){throw N(L,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}d(p||s||null),E(m||!1),l(!0)},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return d(c),c},walletProxy:T,createAnalyticsEvent:(c,p,m)=>t.createAnalyticsEvent(c,p,m),acceptTerms:async()=>{let c=await t.acceptTerms();return d(c),c},getUsdTokenPrice:c=>t.getUsdTokenPrice(c),recoverEmbeddedWallet:async()=>new Promise(async(c,p)=>{let m=s?.linkedAccounts.find(I=>I.type==="wallet"&&I.walletClientType==="privy"),h=await ve();if(!h||!T||!m){p(new Error("Must have valid access token and Privy wallet to recover wallet"));return}re(!0);try{await T.connect({accessToken:h,address:m.address}),c(!0)}catch(I){So(I)&&m.recoveryMethod==="privy"?(t.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:m.address}),(await T.recover({address:m.address,accessToken:h})).address||p(new Error("Unable to recover wallet")),t.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:m.address}),c(!0)):So(I)?(z({recoverWallet:{privyWallet:m,onFailure:p,onSuccess:()=>c(!0)}}),$("EMBEDDED_WALLET_RECOVERY_SCREEN")):p(I)}}),getFiatOnRampConfig:rr,setReadyToTrue:()=>{a(!0),Pe?.()},updateWallets:()=>Dr(),fundWallet:async(c,p)=>{let{signedUrl:m,externalTransactionId:h}=await rr(c,p);z({fiatOnRampPrompt:{signedUrl:m},fiatOnRampStatus:{externalTransactionId:h}}),$("FIAT_ON_RAMP_PROMPT_SCREEN")},requestFarcasterSignerStatus:async c=>{let p=await ve(),m=s?.linkedAccounts.find(I=>I.type==="wallet"&&I.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");let h=await t.requestFarcasterSignerStatus(c);if(h.status==="approved"){let I=await t.getAuthenticatedUser();d(I||s||null)}return h}}))();Dy=ie.recoverEmbeddedWallet;let Hy=WE(()=>({wallets:u,ready:Ae}),[u,Ae]);return Er(ce.Provider,{value:Lo,children:Er(El.Provider,{value:L,children:Er(qc.Provider,{value:Hy,children:Wy(Xp,{...O,children:[e.children,Wy(bl.Provider,{value:ie,children:[!rd&&O.captchaEnabled&&n&&!i&&Er(Cl,{delayedExecution:!1}),Er(xy,{theme:{...O.appearance.palette||{}}}),Er(jp,{data:te,setModalData:z,setInitialScreen:x,initialScreen:v,authenticated:i,open:r,children:Er(ky,{open:r})}),se&&Y?Er(My,{appId:e.appId,clientAnalyticsId:t.clientAnalyticsId,origin:t.apiUrl,mfaMethods:s?.mfaMethods,mfaPromise:Nr,mfaSubmitPromise:tr,onLoad:q,onLoadFailed:()=>null}):null]})]})})})})};import{useContext as FE}from"react";function UE(e){let{login:t}=FE(ce);return Ee("login",e),{login:t}}import{useContext as BE}from"react";function HE(e){let{logout:t}=BE(ce);return Ee("logout",e),{logout:t}}import{useCallback as Fy,useEffect as GE}from"react";function VE(){let e=fe(),t=_a(),{initLoginWithHeadlessOAuth:r,loginWithHeadlessOAuth:o,isHeadlessOAuthLoading:n,ready:a,user:i}=G(),l=Fy(async d=>{if(e.enabled&&e.status!=="success")throw new qt(e.error,null,"captcha_failure");return r(d.provider,e.token)},[r,e]),s=Fy(async()=>{let d=qn();if(i)return console.warn("Cannot login with OAuth when already logged in"),i;if(!d.inProgress)throw new Error("Cannot login with OAuth because no OAuth flow is in progress");try{return await o(d)}catch(u){throw u}finally{$n()}},[o]);return GE(()=>{let d=qn();a&&t&&d.inProgress&&d.headless&&s()},[a,t]),{initOAuth:l,loginWithOAuth:s,loading:n}}import{useCallback as Uy}from"react";var zE=()=>{let e=fe(),{initLoginWithEmail:t,loginWithCode:r}=G(),o=Uy(async({email:a})=>{if(!a)throw new Error("Email required to send OTP code");return t(a)},[t]),n=Uy(async({code:a})=>{if(e.enabled&&e.status==="error")throw new qt(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};import{useCallback as By}from"react";var qE=()=>{let e=fe(),{initLoginWithSms:t,loginWithCode:r}=G(),o=By(async({phoneNumber:a})=>{if(!a)throw new Error("SMS required to send OTP code");return t(a)},[t]),n=By(async({code:a})=>{if(e.enabled&&e.status!=="success")throw new qt(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};import{useContext as $E}from"react";function jE(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:l,linkGithub:s,linkLinkedIn:d,linkTiktok:u,linkSpotify:y,linkFarcaster:f}=$E(ce);return Ee("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:l,linkGithub:s,linkLinkedIn:d,linkTiktok:u,linkSpotify:y,linkFarcaster:f}}import{useContext as KE}from"react";function YE(e){let{connectWallet:t}=KE(ce);return Ee("connectWallet",e),{connectWallet:t}}import{useContext as JE}from"react";function ZE(e){let{createWallet:t}=JE(ce);return Ee("createWallet",e),{createWallet:t}}var QE=()=>{let{fundWallet:e}=G();return{fundWallet:e}};import{useContext as XE}from"react";function e4(e){let{sendTransaction:t}=XE(ce);return Ee("sendTransaction",e),{sendTransaction:t}}import{useContext as t4}from"react";function r4(e){let{setWalletPassword:t}=t4(ce);return Ee("setWalletPassword",e),{setWalletPassword:t}}import{useContext as o4}from"react";function n4(e){let{signMessage:t}=o4(ce);return Ee("signMessage",e),{signMessage:t}}import{useContext as i4}from"react";function a4(e){let{signTypedData:t}=i4(ce);return Ee("signTypedData",e),{signTypedData:t}}import{useContext as s4}from"react";var l4=()=>{let{isModalOpen:e}=s4(ce);return{isOpen:e}};import{useContext as c4}from"react";function d4(e){let{getAccessToken:t}=c4(ce);return Ee("accessToken",e),{getAccessToken:t}}function p4(){let{submitCast:e,removeCast:t,likeCast:r,recastCast:o,followUser:n,unfollowUser:a,requestFarcasterSigner:i}=G();return{followUser:n,unfollowUser:a,submitCast:e,removeCast:t,likeCast:r,recastCast:o,requestFarcasterSigner:i}}function u4(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}export{ar as AsExternalProvider,Cl as Captcha,Zn as ConnectorManager,Qn as PrivyClient,NE as PrivyProvider,be as PrivyProxyProvider,Yn as SUPPORTED_CHAINS,il as VERSION,mt as WalletConnector,u4 as addRpcUrlOverrideToChain,Yl as errorIndicatesMaxMfaRetries,mn as errorIndicatesMfaTimeout,fn as errorIndicatesMfaVerificationFailed,ve as getAccessToken,YE as useConnectWallet,ZE as useCreateWallet,p4 as useExperimentalFarcasterSigner,QE as useFundWallet,jE as useLinkAccount,UE as useLogin,zE as useLoginWithEmail,VE as useLoginWithOAuth,qE as useLoginWithSms,HE as useLogout,An as useMfa,Si as useMfaEnrollment,l4 as useModalStatus,G as usePrivy,Tl as useRegisterMfaListener,e4 as useSendTransaction,r4 as useSetWalletPassword,n4 as useSignMessage,a4 as useSignTypedData,d4 as useToken,Wi as useWallets};
|
|
2752
|
+
`;import{jsx as Ge,jsxs as Ay}from"react/jsx-runtime";var CE={["LANDING"]:zf,["CONNECT_OR_CREATE"]:Gf,["AWAITING_PASSWORDLESS_CODE"]:Su,["AWAITING_CONNECTION"]:qu,["AWAITING_CONNECT_ONLY_CONNECTION"]:Yu,["AWAITING_FARCASTER_CONNECTION"]:Qm,["AWAITING_FARCASTER_SIGNER"]:nf,["PHANTOM_INTERSTITIAL_SCREEN"]:sy,["LOGIN_FAILED_SCREEN"]:Zf,["AWAITING_OAUTH_SCREEN"]:oy,["ALLOWLIST_REJECTION_SCREEN"]:yu,["INSTALL_PHANTOM_SCREEN"]:wf,["LINK_EMAIL_SCREEN"]:qf,["LINK_PHONE_SCREEN"]:$f,["LINK_WALLET_SCREEN"]:jf,["UPDATE_EMAIL_SCREEN"]:Ty,["CONNECT_ONLY_LANDING_SCREEN"]:Gu,["CONNECT_ONLY_AUTHENTICATED_SCREEN"]:Uu,["EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN"]:Lm,["EMBEDDED_WALLET_CREATED_SCREEN"]:rm,["EMBEDDED_WALLET_CONNECTING_SCREEN"]:em,["EMBEDDED_WALLET_RECOVERY_SCREEN"]:Dm,["EMBEDDED_WALLET_KEY_EXPORT_SCREEN"]:am,["EMBEDDED_WALLET_SIGN_REQUEST_SCREEN"]:yy,["EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN"]:fy,["FIAT_ON_RAMP_PROMPT_SCREEN"]:pf,["FIAT_ON_RAMP_STATUS_SCREEN"]:mf,["EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN"]:Nm,["EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN"]:Om,["MFA_ENROLLMENT_FLOW_SCREEN"]:ph,["CAPTCHA_SCREEN"]:Ru,["ERROR_SCREEN"]:Fm,["IN_APP_BROWSER_LOGIN_NOT_POSSIBLE"]:ff,["AFFIRMATIVE_CONSENT_SCREEN"]:fu},bE=["LANDING","AWAITING_CONNECTION"],EE=({isMfaVerifying:e,onMfaVerificationComplete:t})=>{let{ready:r,isModalOpen:o}=G(),{headless:n}=W(),{ready:a,currentScreen:i}=_(),{status:l,execute:s,reset:d,enabled:u}=fe(),y=gE(null),f=tu(y),g=o&&i&&bE.includes(i)&&!n&&l==="ready";if(_y(()=>{g&&s()},[g]),_y(()=>{!o&&u&&d()},[o,u]),(!r||!a)&&i!=="AWAITING_OAUTH_SCREEN")return Ay(Sn,{children:[Ge(A,{}),Ge(K,{}),Ge(eh,{children:Ge(ft,{})}),Ge(oe,{}),Ge(X,{})]});if(!i&&e)return Ge(Sn,{style:{height:f},children:Ge("div",{ref:y,children:Ge(Yc,{open:e,onClose:t})})});if(!i)return null;let E=CE[i];return Ge(Sn,{style:{height:f},children:Ay("div",{ref:y,children:[Ge(Ar,{if:!!e,children:Ge(E,{})}),Ge(Ar,{if:!e,children:Ge(Yc,{open:e,onClose:t})})]})})},TE=()=>{let{closePrivyModal:e}=W(),{onUserCloseViaDialogOrKeybindRef:t}=_();return{gracefulClosePrivyModal:yE(()=>{if(t?.current)t.current();else return e({shouldCallAuthOnSuccess:!1})},[e])}},ky=({open:e})=>{let{app:t}=_(),{gracefulClosePrivyModal:r}=TE(),[o,n]=vE(!1);Tl({onMfaRequired:()=>{t?.mfa.noPromptOnMfaRequired||n(!0)}});let a=Ge(Sy,{children:Ge(EE,{isMfaVerifying:o,onMfaVerificationComplete:()=>n(!1)})}),i=e||o,l=t?.render.inDialog?Ge(Xf,{open:i,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:a}):a;if(typeof window<"u"&&t?.render.inParentNodeId){let s=document.getElementById(t.render.inParentNodeId);if(s)return wE.createPortal(l,s)}return l};import{useState as PE}from"react";import{useEffect as Ry,useRef as Iy}from"react";var qs=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:connect":return o;case"privy:wallet:recover":return o;case"privy:wallet:rpc":return o;case"privy:wallet:set-recovery-password":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:submit-cast":return o;case"privy:farcaster:remove-cast":return o;case"privy:farcaster:react-to-cast":return o;case"privy:farcaster:submit-link":return o;case"privy:farcaster:remove-link":return o;default:throw new Error(`invalid wallet event type ${t}`)}}};async function Wo(e,t,r,o,n,a=!1){let i=a,l=async u=>{if(i&&t&&t.length>0){u===(a?0:1)?n("configureMfa","onMfaRequired",t):o.current?.reject(new ye("missing_or_invalid_mfa","MFA verification failed, retry."));let y=await new Promise((f,g)=>{r.current={resolve:f,reject:g};let E=1e3*60*5;setTimeout(()=>{let v=new ye("mfa_timeout","Timed out waiting for MFA code");o.current?.reject(v),g(v)},E)});return await e(y)}return await e()},s=4,d=null;for(let u=0;u<s;u++)try{d=await l(u),o.current?.resolve(void 0);break}catch(y){if(y.type==="missing_or_invalid_mfa")i=!0;else throw o.current?.resolve(void 0),y}if(d===null){let u=new ye("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw o.current?.reject(u),u}return d}import{jsx as RE}from"react/jsx-runtime";var xE=function(e){return()=>`id-${e++}`}(0);function SE(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Ve(e){return e.error!==void 0}var Ie=new qs,Qc=new Map,_E=(e,t)=>typeof t=="bigint"?t.toString():t,AE=(e,t)=>`${e}${JSON.stringify(t,_E)}`;function ze(e,t,r,o){let n=r.contentWindow;if(!n)throw new Error("iframe not initialized");let a=AE(e,t);if(e==="privy:wallet:create"){let l=Qc.get(a);if(l)return l}let i=new Promise((l,s)=>{let d=xE();Ie.enqueue(d,{resolve:l,reject:s}),n.postMessage({id:d,event:e,data:t},o)}).finally(()=>{Qc.delete(a)});return Qc.set(a,i),i}function kE(e){switch(e.event){case"privy:iframe:ready":let t=Ie.dequeue(e.event,e.id);return Ve(e)?t.reject(new ye(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let r=Ie.dequeue(e.event,e.id);return Ve(e)?r.reject(new ye(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:connect":let o=Ie.dequeue(e.event,e.id);return Ve(e)?o.reject(new ye(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:recover":let n=Ie.dequeue(e.event,e.id);return Ve(e)?n.reject(new ye(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:rpc":let a=Ie.dequeue(e.event,e.id);return Ve(e)?a.reject(new ye(e.error.type,e.error.message)):a.resolve(e.data);case"privy:wallet:set-recovery-password":let i=Ie.dequeue(e.event,e.id);return Ve(e)?i.reject(new ye(e.error.type,e.error.message)):i.resolve(e.data);case"privy:mfa:verify":let l=Ie.dequeue(e.event,e.id);return Ve(e)?l.reject(new ye(e.error.type,e.error.message)):l.resolve(e.data);case"privy:mfa:init-enrollment":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:submit-enrollment":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:unenroll":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:clear":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:init-signer":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:submit-cast":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:remove-cast":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:react-to-cast":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:submit-link":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:remove-link":{let s=Ie.dequeue(e.event,e.id);return Ve(e)?s.reject(new ye(e.error.type,e.error.message)):s.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}function My(e){let t=Iy(null),r=Iy(e.mfaMethods),o=nu(),[n,a]=PE(!1);return Ry(()=>{r.current=e.mfaMethods},[e.mfaMethods]),Ry(()=>{if(!n)return;let i=t.current;if(!i)return;function l(f){f&&f.origin===e.origin&&SE(f.data)&&kE(f.data)}let s={create(f){return ze("privy:wallet:create",f,i,e.origin)},connect(f){return ze("privy:wallet:connect",f,i,e.origin)},recover(f){return Wo(g=>ze("privy:wallet:recover",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},rpc(f){return Wo(g=>ze("privy:wallet:rpc",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},setRecoveryPassword(f){return Wo(g=>ze("privy:wallet:set-recovery-password",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},verifyMfa(f){return Wo(g=>ze("privy:mfa:verify",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},initEnrollMfa(f){return Wo(g=>ze("privy:mfa:init-enrollment",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},submitEnrollMfa(f){return ze("privy:mfa:submit-enrollment",f,i,e.origin)},unenrollMfa(f){return Wo(g=>ze("privy:mfa:unenroll",{...f,...g},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},clearMfa(f){return ze("privy:mfa:clear",f,i,e.origin)},initFarcasterSigner(f){return ze("privy:farcaster:init-signer",f,i,e.origin)},submitCast(f){return ze("privy:farcaster:submit-cast",f,i,e.origin)},removeCast(f){return ze("privy:farcaster:remove-cast",f,i,e.origin)},reactToCast(f){return ze("privy:farcaster:react-to-cast",f,i,e.origin)},submitLink(f){return ze("privy:farcaster:submit-link",f,i,e.origin)},removeLink(f){return ze("privy:farcaster:remove-link",f,i,e.origin)}};window.addEventListener("message",l);let d=()=>e.onLoad(s),u=(...f)=>{console.warn("Privy iframe failed to load: ",...f),e.onLoadFailed()},y=new AbortController;return Jd(()=>ze("privy:iframe:ready",{},i,e.origin),{abortSignal:y.signal}).then(d,u),()=>{window.removeEventListener("message",l),y.abort()}},[n]),RE("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>a(!0),src:Zi(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId})})}function $s(e){let t=e.toLowerCase();return["fbav","fban","instagram","snapchat"].some(o=>t.includes(o))}var js=class{constructor(t,r){this.meta={action:t,phoneNumber:r}}async init(){if(!this.meta.action)throw new S("action required");if(!this.api)throw new S("Auth flow has no API instance");if(this.meta.action==="enroll"&&!this.meta.phoneNumber)throw new S("phone number must be set when initialzing authentication.");try{await this.api.post(kd,{action:this.meta.action,phoneNumber:this.meta.phoneNumber})}catch(t){throw ue(t)}}async authenticate(){if(!this.meta.action)throw new S("action required");if(!this.api)throw new S("Mfa flow has no API instance");if(!this.meta.smsCode)throw new S("sms code must be set prior to calling authenticate.");if(this.meta.action==="enroll"&&!this.meta.phoneNumber)throw new S("phone number must be set prior to calling authenticate.");try{let t=await this.api.post(Rd,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return Ct(t)}catch(t){throw ue(t)}}};import{jsx as Er,jsxs as Wy}from"react/jsx-runtime";var Un;function LE(e){return typeof e=="string"&&e.length===25}function ve(){if(!Un){let e=j.get(mo);return Promise.resolve(e||null)}return Un.getAccessToken()}var Ly,hp=(e,t)=>Ly(e,t),Oy,yp=(e,t)=>Oy(e,t),Ny,gp=(e,t)=>Ny(e,t),Dy,vp=()=>Dy(),OE=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;j.put(Hn,t);let r=new URL(window.location.href);r.searchParams.delete("privy_token"),window.history.pushState({},"",r)},NE=({config:e,...t})=>{if(!LE(t.appId))throw new S("Cannot initialize the Privy provider with an invalid Privy app ID");Un||(Un=new Qn({appId:t.appId,apiUrl:t.apiUrl||$i}));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."),Er(qp,{client:Un,clientConfig:r,legacyCreateEmbeddedWalletFlag:t.createPrivyWalletOnLogin,children:Er(DE,{...t,config:r,client:Un})})},DE=e=>{let t=e.client,[r,o]=Me(!1),[n,a]=Me(!1),[i,l]=Me(!1),[s,d]=Me(null),[u,y]=Me([]),f=Fn(u),[g,E]=Me(!1),[v,x]=Me(null),[C,P]=Me(!1),[R,M]=Me({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:b}),[k,B]=Me(null),[U,H]=Me(null),[T,q]=Me(null),O=Sa(),Y=_a(),[se,re]=Me(!0),[te,z]=Me({}),[Pe,we]=Me(null),[Tr,yt]=Me(null),[Ae,ge]=Me(!1),[gt,Ut]=Me(!1),Nr=Fn(null),tr=Fn(null),L=Fn(ru);t.onStoreToken=c=>{c&&N(L,"accessToken","onAccessTokenGranted",c)},t.onDeleteToken=()=>{N(L,"accessToken","onAccessTokenRemoved")};let J=Fn(null),Q=Fn(null),Bn=ME(c=>{let p=t.connectors?.walletsReady||!1;return i&&s?.linkedAccounts?.some(h=>h.type==="wallet"&&h.walletClientType==="privy")?p&&c?.some(h=>h?.walletClientType==="privy"):p},[i,s?.linkedAccounts,t?.connectors?.walletsReady]),$=c=>{x(c),setTimeout(()=>{o(!0)},15),t.createAnalyticsEvent("modal_open",{initialScreen:c})},We=c=>{O.embeddedWallets.createOnLogin!=="off"&&re(!0),$(c)};Or(()=>{if(!T||!s){t.connectors?.removeEmbeddedWalletConnector();return}let c=s?.linkedAccounts.filter(p=>p.type==="wallet"&&p.walletClientType==="privy");if(c&&c.length>0){let p=c[0].address;t.connectors?.addEmbeddedWalletConnector(T,p,O.defaultChain,e.appId)}},[T,s]),Or(()=>{T&&Tr?.(T)},[T]),Or(()=>{(async()=>{if(!O.customAuth?.enabled)return;re(!0);let{getCustomAccessToken:p,isLoading:m}=O.customAuth;if(!(!n||m))try{let h=await p();if(!h){await Lo.logout();return}if(i)return;t.startAuthFlow(new No(h));let{user:I,isNewUser:D}=await t.authenticate();I||await Lo.logout(),d(I||null),E(D||!1),l(!0),Ut(!0)}catch(h){console.warn(h),i&&await Lo.logout()}})()},[O.customAuth?.enabled,O.customAuth?.getCustomAccessToken,O.customAuth?.isLoading,n,i]),Or(()=>{gt&&T&&s&&At(s,e.config?.embeddedWallets?.createOnLogin)&&(Ut(!1),or(s,Fo).catch(console.error))},[gt&&T&&s]),Or(()=>{async function c(){let p=pt();OE();let m=IE();B(m),t.initializeConnectorManager({walletConnectCloudProjectId:O.walletConnectCloudProjectId,rpcConfig:O.rpcConfig,chains:O.chains,defaultChain:O.defaultChain,store:m,walletList:O.appearance.walletList,shouldEnforceDefaultChainOnConnect:O.shouldEnforceDefaultChainOnConnect,appName:O.name??"Privy"}),t.connectors?.initialize().then(()=>{Ys()});let h=await t.getAuthenticatedUser();e.config?.customAuth?.enabled||(l(!!h),h&&N(L,"login","onComplete",h,!1,!0,null),d(h)),p||ie.setReadyToTrue(),p&&(h?Q.current="link":Q.current="login")}!n&&Y&&c()},[t,Pe,n,Y]);let pt=()=>{let c=qn();return!c.inProgress||c.headless?!1:(t.startAuthFlow(new ir(c)),We("AWAITING_OAUTH_SCREEN"),!0)},co=async(c,p,m,h)=>{let I=await t.connectors?.createWalletConnector(c,p)||null;Bt(I,p,m,h)};async function Bt(c,p,m,h){if(c)M({status:"disconnected",connectedWallet:null,connectError:null,connector:c,connectRetry:b});else return M({status:"disconnected",connectedWallet:null,connectError:new Z("Unable to connect to wallet."),connector:null,connectRetry:b}),h?.(null,m);c instanceof cr&&p&&await c.resetConnection(p),M({connector:c,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Bt(c,p,m,h)});try{let I=await c.connect({showPrompt:!0});if(O.shouldEnforceDefaultChainOnConnect&&!O.chains.find(D=>D.id===Number(I?.chainId))&&!(I?.connectorType==="wallet_connect_v2"&&I?.walletClientType==="metamask")){M(D=>({...D,connector:c,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:b}));try{await I?.switchChain(O.defaultChain.id),I&&(I.chainId=Bo(go(O.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${O.defaultChain.id}`)}}return M(D=>({...D,status:"connected",connectedWallet:I,connectError:null,connectRetry:b})),I&&!Q.current&&N(L,"connectWallet","onSuccess",I),h?.(I,m)}catch(I){return I instanceof $e?(console.warn(I.cause?I.cause:I.message),Q.current||N(L,"connectWallet","onError",I.privyErrorCode||"generic_connect_wallet_error")):(console.warn(I),Q.current||N(L,"connectWallet","onError","unknown_connect_wallet_error")),M(D=>({...D,status:"disconnected",connectedWallet:null,connectError:I})),h?.(null,m)}}let po=async(c,p)=>{if(c===null)return;let m=new vo(c,p);t.startAuthFlow(m)},Ys=()=>{let c=new URLSearchParams(window.location.search),p=c.get("privy_connector"),m=c.get("privy_wallet_client");if(!p||!m)return;if(m==="phantom"&&!Ur()&&We("LOGIN_FAILED_SCREEN"),!t.connectors)throw new S("Connector not initialized");$("AWAITING_CONNECTION");let h=new URL(window.location.href);h.searchParams.delete("privy_connector"),h.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",h),co(p,m,void 0,po)};Or(()=>{n&&i&&s===null&&t.getAuthenticatedUser().then(d)},[n,i,s,t]);let Le=()=>{if(!i)throw N(L,"linkAccount","onError","must_be_authenticated"),new S("User must be authenticated before linking an account.")},uo=()=>{Le(),J.current="siwe",Q.current="link",$("LINK_WALLET_SCREEN")},vt=c=>{if(!i||!s)return!1;if(c.walletClientType==="privy")return!0;for(let p of s.linkedAccounts)if(p.type==="wallet"&&p.address===c.address&&p.walletClientType!=="privy")return!0;return!1},qe=async c=>{if(!t.connectors)throw new S("Connector not initialized");let p=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null;if(M(m=>({...m,connector:p,status:"connected",connectedWallet:c,connectError:null,connectRetry:b})),O.captchaEnabled&&!i){let m={callback:h=>po(c,h),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"};z({captchaModalData:m}),We("CAPTCHA_SCREEN")}else await po(c),We("AWAITING_CONNECTION")},rr=async(c,p)=>{if(!O.fiatOnRamp.enabled)throw new S("Fiat on-ramp is not enabled");if(!p||!p.provider||p.provider==="moonpay"){let{signedUrl:m,externalTransactionId:h}=await cf(t,c,p?.config??{},O.appearance.palette,O.fiatOnRamp.useSandbox);return{signedUrl:m,externalTransactionId:h}}else throw new S("Unsupported fund provider. Currently supported option is `moonpay`.")},Dr=()=>{y(c=>{let p=t.connectors?.wallets.map(m=>({...m,linked:vt(m),loginOrLink:async()=>{if(!await m.isConnected())throw new S("Wallet is not connected");if(m.connectorType==="embedded"&&m.walletClientType==="privy")throw new S("Cannot link or login with embedded wallet");qe(m)},fund:async h=>{let{signedUrl:I,externalTransactionId:D}=await rr(m.address,h);z({fiatOnRampPrompt:{signedUrl:I},fiatOnRampStatus:{externalTransactionId:D}}),$("FIAT_ON_RAMP_PROMPT_SCREEN")},unlink:async()=>{if(!i)throw new S("User is not authenticated.");if(m.connectorType==="embedded"&&m.walletClientType==="privy")throw new S("Cannot unlink an embedded wallet");let h=await t.unlinkWallet(m.address);d(h)}}))||[];return ge(Bn(p)),ia(c,p)?c:p})};Or(()=>{Dr()},[s?.linkedAccounts,i,n]),Or(()=>{if(n){if(!t.connectors)throw new S("Connector not initialized");Dr(),t.connectors.on("walletsUpdated",Dr)}},[n]);let Ni=()=>{$(i?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};Or(()=>{if(!u[0])return;let c=u[0],p=f.current.find(h=>h.address===c.address),m;if(c.walletClientType==="privy"?m=s?.linkedAccounts.find(h=>h.type==="wallet"&&h.address===c.address&&h.walletClientType==="privy"):m=s?.linkedAccounts.find(h=>h.type==="wallet"&&h.address===c.address&&h.walletClientType!=="privy"),!p&&m){let h=Object.assign({},s);h.wallet=m&&{address:m.address,chainType:m.chainType,chainId:m.chainId,walletClient:m.walletClient,walletClientType:m.walletClientType,connectorType:m.connectorType},d(h)}f.current=u},[u]);let or=async(c,p)=>{if(Ce(c))throw N(L,"createWallet","onError","embedded_wallet_already_exists"),new Error("Only one Privy wallet per user is currently allowed");let[h,I]=await Promise.all([ie.initializeWalletProxy(p),ve()]);if(!h&&e.config?.customAuth?.enabled)throw N(L,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!h||!I||e.config?.embeddedWallets?.requireUserPasswordOnCreate)return new Promise((D,le)=>{re(!0),z({createWallet:{onSuccess:ut=>{N(L,"createWallet","onSuccess",ut),D(ut)},onFailure:ut=>{N(L,"createWallet","onError","unknown_embedded_wallet_error"),le(ut)},callAuthOnSuccessOnClose:!1}}),$("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{await h.create({accessToken:I});let D=await ie.refreshUser(),le=Ce(D);if(!le)throw N(L,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return N(L,"createWallet","onSuccess",le),le}},Js=c=>{if(!O.chains.map(p=>p.id).includes(c))throw new Z(`Chain ID ${c} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},ed=(c,p,m)=>new Promise(async(h,I)=>{if(!i||!s){N(L,"sendTransaction","onError","must_be_authenticated"),I(new Error("User must be authenticated before signing with a Privy wallet"));return}let D=Ce(s);if(!D){N(L,"sendTransaction","onError","embedded_wallet_not_found"),I(new Error("Must have a Privy wallet before signing"));return}re(!0);let le=t.connectors?.findWalletConnector("embedded","privy")?.proxyProvider,et=c.chainId?Number(c.chainId):le.chainId;Js(et);let ut=Object.assign({},c,{chainId:et}),Pr=async()=>{let tt=await ve();if(!tt||!T){N(L,"sendTransaction","onError","embedded_wallet_not_found"),I(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await ie.recoverEmbeddedWallet()){N(L,"sendTransaction","onError","unknown_connect_wallet_error"),I(new Error("Unable to connect to wallet"));return}let Vt=Sr(ut.chainId,O.chains,O.rpcConfig,{appId:e.appId}),Zs=await Ln(D.address,ut,Vt);if(O.embeddedWallets.noPromptOnSignature){let{totalGasEstimate:Gy}=await Wn(Zs,Vt),{hasSufficientFunds:Vy}=await Bs(D.address,Zs,Gy,Vt);if(!Vy)throw new xe(new kt("Wallet has insufficient funds for this transaction.",je.E32603_DEFAULT_INTERNAL_ERROR.eipCode))}let od=await Us(tt,D.address,T,Zs,Vt);N(L,"sendTransaction","onSuccess",od),h(od)}catch(Gt){N(L,"sendTransaction","onError","transaction_failure"),I(Gt)}};if(O.embeddedWallets.noPromptOnSignature)p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),Pr();else{let tt={transactionRequest:ut,onSuccess:Vt=>{N(L,"sendTransaction","onSuccess",Vt),h(Vt)},onFailure:Vt=>{N(L,"sendTransaction","onError","transaction_failure"),I(Vt)},uiOptions:p||{},fundWalletConfig:m},Gt={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:Vt=>{N(L,"sendTransaction","onError","unknown_connect_wallet_error"),I(Vt)}};z({connectWallet:Gt,sendTransaction:tt}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")}});function td(){return new Promise(async(c,p)=>{let m=await ve();if(!m||!T)throw new Error("Must have valid access token to enroll in MFA");try{await T.verifyMfa({accessToken:m}),c()}catch(h){p(h)}})}let Ht=c=>{if(s?.[c])throw N(L,"linkAccount","onError","cannot_link_more_of_type"),new S(`User already has an account of type ${c} linked.`)},Lo={ready:n,authenticated:i,user:s,walletConnectors:t.connectors||null,connectWallet:Ni,linkWallet:uo,linkEmail:()=>{Le(),Ht("email"),J.current="email",Q.current="link",$("LINK_EMAIL_SCREEN")},linkPhone:()=>{Le(),Ht("phone"),J.current="sms",Q.current="link",$("LINK_PHONE_SCREEN")},linkGoogle:async()=>{Le(),Ht("google"),Q.current="link",await ie.initLoginWithOAuth("google")},linkTwitter:async()=>{Le(),Ht("twitter"),Q.current="link",await ie.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Le(),Ht("discord"),Q.current="link",await ie.initLoginWithOAuth("discord")},linkGithub:async()=>{Le(),Ht("github"),Q.current="link",await ie.initLoginWithOAuth("github")},linkSpotify:async()=>{Le(),Ht("spotify"),Q.current="link",await ie.initLoginWithOAuth("spotify")},linkTiktok:async()=>{Le(),Ht("tiktok"),Q.current="link",await ie.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Le(),Ht("linkedin"),Q.current="link",await ie.initLoginWithOAuth("linkedin")},linkApple:async()=>{Le(),Ht("apple"),Q.current="link",await ie.initLoginWithOAuth("apple")},linkFarcaster:async()=>{Le(),Ht("farcaster"),await ie.initLoginWithFarcaster(),Q.current="link",J.current="farcaster",$("AWAITING_FARCASTER_CONNECTION")},updateEmail:()=>{if(Le(),!s?.email)throw new S("User does not have an email linked to their account.");Q.current="link",J.current="email",$("UPDATE_EMAIL_SCREEN")},login:async()=>{if(n||(await new Promise(c=>{we(()=>c)}),we(null)),i){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}Q.current="login",We("LANDING")},connectOrCreateWallet:async()=>{if(n||(await new Promise(c=>{we(()=>c)}),we(null)),i){console.warn("User must be unauthenticated to `connectOrCreateWallet`");return}if(u[0]){console.warn("User must have no connected wallets to `connectOrCreateWallet`");return}We("CONNECT_OR_CREATE")},logout:async()=>{if(await t.logout(),s&&T)try{await T.clearMfa({userId:s.id})}catch{}d(null),l(!1),x(null),N(L,"logout","onSuccess"),Q.current=null,J.current=null,o(!1),j.del(Gn)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{if(!s||!s.wallet)return new be;let c=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(h=>h.address===c?.address));return!c||!p?new be:p.proxyProvider},getEthersProvider:()=>{if(!s||!s.wallet)return new Xc(new ar(new be));let c=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(h=>h.address===c?.address));return!c||!p?new Xc(new ar(new be)):new Xc(new ar(p.proxyProvider))},getWeb3jsProvider:()=>{if(!s||!s.wallet)return new Gr(new be);let c=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(h=>h.address===c?.address));return!c||!p?new Gr(new be):new Gr(p.proxyProvider)},unlinkWallet:async c=>{let p=await t.unlinkWallet(c);return d(p),p},unlinkEmail:async c=>{let p=await t.unlinkEmail(c);return d(p),p},unlinkPhone:async c=>{let p=await t.unlinkPhone(c);return d(p),p},unlinkGoogle:async c=>{let p=await t.unlinkOAuth("google",c);return d(p),p},unlinkTwitter:async c=>{let p=await t.unlinkOAuth("twitter",c);return d(p),p},unlinkDiscord:async c=>{let p=await t.unlinkOAuth("discord",c);return d(p),p},unlinkGithub:async c=>{let p=await t.unlinkOAuth("github",c);return d(p),p},unlinkSpotify:async c=>{let p=await t.unlinkOAuth("spotify",c);return d(p),p},unlinkTiktok:async c=>{let p=await t.unlinkOAuth("tiktok",c);return d(p),p},unlinkLinkedIn:async c=>{let p=await t.unlinkOAuth("linkedin",c);return d(p),p},unlinkApple:async c=>{let p=await t.unlinkOAuth("apple",c);return d(p),p},unlinkFarcaster:async c=>{let p=await t.unlinkFarcaster(c);return d(p),p},setActiveWallet:async c=>{let p=u.find(h=>Ks(h.address)===Ks(c)),m=s?.linkedAccounts.find(h=>h.type==="wallet"&&Ks(h.address)===Ks(c));if(!p||!await p.isConnected())H(c),uo();else if(!p.linked)p.loginOrLink();else{let h=Object.assign({},s);h.wallet=m&&{address:m.address,chainType:m.chainType,chainId:m.chainId,walletClient:m.walletClient,walletClientType:m.walletClientType,connectorType:m.connectorType},d(h)}},forkSession:()=>t.forkSession(),createWallet:async()=>{if(!i||!s)throw N(L,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return or(s,15e3)},setWalletPassword:async()=>{if(!i||!s)throw N(L,"setWalletPassword","onError","must_be_authenticated"),new Error("User must be authenticated before adding password to Privy wallet");let c=Ce(s);if(!c||!T)throw N(L,"setWalletPassword","onError","embedded_wallet_not_found"),new Error("Must have a Privy wallet to add a password");if(c.recoveryMethod==="user-passcode")throw N(L,"setWalletPassword","onError","embedded_wallet_password_already_exists"),new Error("Cannot set password. Embedded wallet already has a password.");try{await td()}catch(p){throw N(L,"setWalletPassword","onError","missing_mfa_credentials"),p}return new Promise((p,m)=>{re(!0);let h={onSuccess:D=>{N(L,"setWalletPassword","onSuccess",D),p(D)},onFailure:D=>{N(L,"setWalletPassword","onError","user_exited_set_password_flow"),m(D)},callAuthOnSuccessOnClose:!1},I={onCompleteNavigateTo:"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",onFailure:D=>{N(L,"setWalletPassword","onError","unknown_connect_wallet_error"),m(D)}};z({setWalletPassword:h,connectWallet:I}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")})},signMessage:(c,p)=>new Promise(async(m,h)=>{if(!i||!s){N(L,"signMessage","onError","must_be_authenticated"),h(new Error("User must be authenticated before signing with a Privy wallet"));return}let I=Ce(s);if(!I){N(L,"signMessage","onError","embedded_wallet_not_found"),h(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){N(L,"signMessage","onError","invalid_message"),h(new Error("Message must be a non-empty string"));return}re(!0);let D=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let le=await ve();if(!T||!le)throw new Error("Unable to connect to wallet");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:I.address});let{response:ut}=await T.rpc({accessToken:le,address:I.address,request:{method:"personal_sign",params:[c,I.address]}}),Pr=ut.data;return t.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:I.address}),Pr};if(O.embeddedWallets.noPromptOnSignature){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let le=await D();N(L,"signMessage","onSuccess",le),m(le)}catch(le){N(L,"signMessage","onError","unable_to_sign"),h(le??new xe("Unable to sign message"))}}else{let ut={method:"personal_sign",data:c,confirmAndSign:D,onSuccess:tt=>{N(L,"signMessage","onSuccess",tt),m(tt)},onFailure:tt=>{N(L,"signMessage","onError","unable_to_sign"),h(tt)},uiOptions:p||{}},Pr={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:tt=>{N(L,"signMessage","onError","unknown_connect_wallet_error"),h(tt)}};z({signMessage:ut,connectWallet:Pr}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),signTypedData:(c,p)=>new Promise(async(m,h)=>{if(!i||!s){N(L,"signTypedData","onError","must_be_authenticated"),h(new Error("User must be authenticated before signing with a Privy wallet"));return}let I=Ce(s);if(!I){N(L,"signTypedData","onError","embedded_wallet_not_found"),h(new Error("Must have a Privy wallet before signing"));return}re(!0);let D=Xi(c),le=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let et=await ve();if(!T||!et)throw new Error("Unable to connect to wallet");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent("embedded_wallet_sign_typed_data_started",{walletAddress:I.address});let{response:Pr}=await T.rpc({accessToken:et,address:I.address,request:{method:"eth_signTypedData_v4",params:[I.address,D]}}),tt=Pr.data;return t.createAnalyticsEvent("embedded_wallet_sign_typed_data_completed",{walletAddress:I.address}),tt};if(O.embeddedWallets.noPromptOnSignature||(O.legacyWalletUiConfig??!1)){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let et=await le();N(L,"signTypedData","onSuccess",et),m(et)}catch(et){N(L,"signTypedData","onError","unable_to_sign"),h(et??new xe("Unable to sign message"))}}else{let Pr={method:"eth_signTypedData_v4",data:D,confirmAndSign:le,onSuccess:Gt=>{N(L,"signTypedData","onSuccess",Gt),m(Gt)},onFailure:Gt=>{N(L,"signTypedData","onError","unable_to_sign"),h(Gt)},uiOptions:p||{}},tt={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Gt=>{N(L,"signMessage","onError","unknown_connect_wallet_error"),h(Gt)}};z({signMessage:Pr,connectWallet:tt}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:async(c,p,m)=>{let I=await(await ed(c,p,m)).wait();return Hs(I)},exportWallet:()=>new Promise(async(c,p)=>{if(!i||!s){p(new Error("User must be authenticated before exporting their Privy wallet"));return}let m=Ce(s);if(!m){p(new Error("Must have a Privy wallet before exporting"));return}re(!0);let h={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:p},I=await ve();if(!I||!T){p(new Error("Must have valid access token to enroll in MFA"));return}if(!T){p(new Error("Must have a Privy wallet before exporting"));return}try{try{await T.connect({accessToken:I,address:m.address}),await T.verifyMfa({accessToken:I})}catch(le){if(So(le))await ie.recoverEmbeddedWallet();else throw le}}catch(le){p(le);return}let D={appId:e.appId,origin:t.apiUrl,onSuccess:c,onFailure:p};z({keyExport:D,connectWallet:h}),$("EMBEDDED_WALLET_CONNECTING_SCREEN")}),promptMfa:td,async init(c){let p;switch(c){case"sms":p=new js("verify");break;case"totp":return;default:throw new Error(`Unsupported MFA method: ${c}`)}t.startMfaFlow(p),await p.init()},async submit(c,p){switch(c){case"totp":case"sms":Nr.current?.resolve({mfaMethod:c,mfaCode:p}),await new Promise((m,h)=>{tr.current={resolve:m,reject:h}});break;default:throw Nr.current?.reject(new S("Unsupported MFA method")),new S(`Unsupported MFA method: ${c}`)}},cancel(){Nr.current?.reject(new S("MFA canceled"))},async initEnrollmentWithSms(c){let p=await ve();if(!p||!T)throw new Error("Must have valid access token to enroll in MFA");await T.initEnrollMfa({method:"sms",accessToken:p,phoneNumber:c.phoneNumber})},enrollInMfa(c){return new Promise((p,m)=>{if(!c){ie.closePrivyModal(),p();return}O.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."),z({mfaEnrollmentFlow:{mfaMethods:O.mfa.methods,onSuccess:p,onFailure:m}}),$("MFA_ENROLLMENT_FLOW_SCREEN")})},async initEnrollmentWithTotp(){let c=await ve();if(!c||!T)throw new Error("Must have valid access token to enroll in MFA");let p=await T.initEnrollMfa({method:"totp",accessToken:c});return{secret:p.secret,authUrl:p.authUrl}},async submitEnrollmentWithSms(c){let p=await ve();if(!p||!T)throw new Error("Must have valid access token to enroll in MFA");await T.submitEnrollMfa({method:"sms",accessToken:p,phoneNumber:c.phoneNumber,code:c.mfaCode});let m=await t.getAuthenticatedUser();d(m)},async submitEnrollmentWithTotp(c){let p=await ve();if(!p||!T)throw new Error("Must have valid access token to enroll in MFA");await T.submitEnrollMfa({method:"totp",accessToken:p,code:c.mfaCode});let m=await t.getAuthenticatedUser();d(m)},async unenroll(c){let p=await ve();if(!p||!T)throw new Error("Must have valid access token to remove MFA");await T.unenrollMfa({method:c,accessToken:p});let m=await t.getAuthenticatedUser();d(m)},requestFarcasterSigner:async()=>{let c=await ve(),p=s?.linkedAccounts.find(I=>I.type==="wallet"&&I.walletClientType==="privy");if(!c)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!p)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");let h=await T.initFarcasterSigner({address:p.address,hdWalletIndex:null,accessToken:c,mfaCode:null,mfaMethod:null});if(h.status==="approved"){let I=await t.getAuthenticatedUser();d(I||s||null)}z({farcasterSigner:h}),$("AWAITING_FARCASTER_SIGNER")},submitCast:async c=>{let p=await ve(),m=s?.linkedAccounts.find(D=>D.type==="wallet"&&D.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.submitCast({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:c,fid:BigInt(s.farcaster.fid)})).response.hash}},removeCast:async({castHash:c})=>{let p=await ve(),m=s?.linkedAccounts.find(D=>D.type==="wallet"&&D.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.removeCast({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:c,fid:BigInt(s.farcaster.fid)})).response.hash}},likeCast:async({castHash:c,castAuthorFid:p})=>{let m=await ve(),h=s?.linkedAccounts.find(le=>le.type==="wallet"&&le.walletClientType==="privy");if(!m)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!h)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.reactToCast({address:h.address,hdWalletIndex:null,accessToken:m,mfaCode:null,mfaMethod:null,payload:{type:1,castId:{hash:c,fid:p}},fid:BigInt(s.farcaster.fid)})).response.hash}},recastCast:async({castHash:c,castAuthorFid:p})=>{let m=await ve(),h=s?.linkedAccounts.find(le=>le.type==="wallet"&&le.walletClientType==="privy");if(!m)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!h)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.reactToCast({address:h.address,hdWalletIndex:null,accessToken:m,mfaCode:null,mfaMethod:null,payload:{type:2,castId:{hash:c,fid:p}},fid:BigInt(s.farcaster.fid)})).response.hash}},followUser:async({fid:c})=>{let p=await ve(),m=s?.linkedAccounts.find(D=>D.type==="wallet"&&D.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.submitLink({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{type:"follow",targetFid:c},fid:BigInt(s.farcaster.fid)})).response.hash}},unfollowUser:async({fid:c})=>{let p=await ve(),m=s?.linkedAccounts.find(D=>D.type==="wallet"&&D.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await ie.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await T.removeLink({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{type:"follow",targetFid:c},fid:BigInt(s.farcaster.fid)})).response.hash}},isHeadlessOAuthLoading:C,loginWithCode(c){return ie.loginWithCode(c)},initLoginWithEmail(c){return ie.initLoginWithEmail(c)},initLoginWithSms(c){return ie.initLoginWithSms(c)},fundWallet(c,p){return ie.fundWallet(c,p)},initLoginWithHeadlessOAuth(c,p){return ie.initLoginWithHeadlessOAuth(c,p)},loginWithHeadlessOAuth(c){return ie.loginWithHeadlessOAuth(c)},isModalOpen:r};Ly=Lo.signMessage,Oy=Lo.signTypedData,Ny=async(...c)=>{let p=await ed(...c);return O.embeddedWallets.waitForTransactionConfirmation&&await p.wait(),p};let rd=!!e.config?.headless,ie=(()=>({headless:rd,isNewUserThisSession:g,linkingHint:U,pendingTransaction:null,walletConnectionStatus:R,mipdStore:k,connectors:t.connectors?.walletConnectors??[],rpcConfig:O.rpcConfig,chains:O.chains,appId:e.appId,showFiatPrices:O.embeddedWallets.priceDisplay.primary!=="native-token",clientAnalyticsId:t.clientAnalyticsId,nativeTokenSymbolForChainId:c=>O.chains.find(p=>p.id===Number(c))?.nativeCurrency.symbol,initializeWalletProxy:async c=>{if(T)return T;let p=new Promise(I=>{yt(()=>D=>I(D))}),m=new Promise(I=>setTimeout(()=>I(null),c)),h=await Promise.race([p,m]);return yt(null),h},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>t.authFlow?.meta,closePrivyModal:(c={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let p=n&&i&&s;Q.current==="login"?c.shouldCallAuthOnSuccess&&p?(N(L,"login","onComplete",s,g,!1,J.current??null),e.onSuccess?.(s,g)):N(L,"login","onError","exited_auth_flow"):Q.current==="link"&&J.current&&(c.isSuccess&&p?N(L,"linkAccount","onSuccess",s,J.current):N(L,"linkAccount","onError","exited_link_flow")),H(null),Q.current=null,J.current=null,E(!1),o(!1),setTimeout(()=>{t.authFlow=void 0},200),t.createAnalyticsEvent("modal_closed")},openPrivyModal:$,connectWallet:Bt,initLoginWithWallet:async(c,p)=>{J.current="siwe",po(c,p)},loginWithWallet:async()=>{if(!n)throw new Oo;if(!(t.authFlow instanceof vo))throw new S("Must initialize SIWE flow first.");let c,p;if(i)try{c=await t.link(),J.current="siwe"}catch(m){throw N(L,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{({user:c,isNewUser:p}=await t.authenticate()),J.current="siwe"}catch(m){throw N(L,"login","onError",m.privyErrorCode||"generic_connect_wallet_error"),m}d(c||s||null),E(p||!1),l(!0)},initLoginWithFarcaster:async c=>{let p=new Vn(c);t.startAuthFlow(p);try{J.current="farcaster",await p.initializeFarcasterConnect()}catch(m){throw Q.current==="login"?N(L,"login","onError",m.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",m.privyErrorCode||"unknown_auth_error"),m}},loginWithFarcaster:async()=>{if(!n)throw new Oo;if(!(t.authFlow instanceof Vn))throw new S("Must initialize Farcaster flow first.");let c,p;if(i)try{c=await t.link(),J.current="farcaster"}catch(m){throw N(L,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{({user:c,isNewUser:p}=await t.authenticate()),J.current="farcaster"}catch(m){throw N(L,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}d(c||null),E(p||!1),l(!0)},async initLoginWithOAuth(c,p){if(J.current=c,tl()){if(c==="google"&&$s(window.navigator.userAgent)){We("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}}else{We("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}j.del(ho);let m=new ir({provider:c});p&&m.addCaptchaToken(p),t.startAuthFlow(m);let h=await t.authFlow.getAuthorizationUrl();h&&h.url&&window.location.assign(h.url)},async loginWithOAuth(c){if(!(t.authFlow instanceof ir))throw new S("Must initialize OAuth flow before calling loginWithOAuth");let p=j.get(fo),m=t.authFlow.meta.stateCode;if(p!==m)throw t.createAnalyticsEvent("possible_phishing_attempt",{provider:c,storedStateCode:p??"",returnedStateCode:m??""}),new S("Unexpected auth flow. This may be a phishing attempt.");let h,I;if(i)try{h=await t.link(),J.current=c}catch(D){throw N(L,"linkAccount","onError",D.privyErrorCode||"failed_to_link_account"),D}else try{({user:h,isNewUser:I}=await t.authenticate()),J.current=c}catch(D){throw Q.current==="login"?N(L,"login","onError",D.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",D.privyErrorCode||"failed_to_link_account"),D}d(h),E(I||!1),l(!0)},async initLoginWithHeadlessOAuth(c,p){if(tl()){if(c==="google"&&$s(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 m=new ir({provider:c,headless:!0});p&&m.addCaptchaToken(p);let h=await t.startAuthFlow(m).getAuthorizationUrl();h?.url&&window.location.assign(h.url)},async loginWithHeadlessOAuth(c){P(!0),t.startAuthFlow(new ir(c));let p=j.get(fo),m=c.stateCode;if(p!==m)throw t.createAnalyticsEvent("possible_phishing_attempt",{provider:c.provider,storedStateCode:p??"",returnedStateCode:m??""}),P(!1),new S("Unexpected auth flow. This may be a phishing attempt.");let h,I;if(i)try{h=await t.link(),J.current=c.provider}catch(D){throw N(L,"linkAccount","onError",D.privyErrorCode||"failed_to_link_account"),D}else try{({user:h,isNewUser:I}=await t.authenticate()),J.current=c.provider}catch(D){throw Q.current==="login"?N(L,"login","onError",D.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",D.privyErrorCode||"failed_to_link_account"),D}return d(h),E(I||!1),l(!0),P(!1),h??void 0},initLoginWithEmail:async(c,p)=>{let m=new Fr(c,p);t.startAuthFlow(m);try{J.current="email",await m.sendCodeEmail()}catch(h){throw Q.current==="login"?N(L,"login","onError",h.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",h.privyErrorCode||"failed_to_link_account"),h}},initUpdateEmail:async(c,p,m)=>{let h=new Vi(c,p,m);t.startAuthFlow(h),await h.sendCodeEmail()},initLoginWithSms:async(c,p)=>{let m=new wo(c,p);t.startAuthFlow(m);try{J.current="sms",await m.sendSmsCode()}catch(h){throw Q.current==="login"?N(L,"login","onError",h.privyErrorCode||"unknown_auth_error"):Q.current==="link"&&N(L,"linkAccount","onError",h.privyErrorCode||"failed_to_link_account"),h}},resendEmailCode:async()=>{await t.authFlow?.sendCodeEmail()},resendSmsCode:async()=>{await t.authFlow?.sendSmsCode()},loginWithCode:async c=>{if(!n)throw new Oo;if(t.authFlow instanceof Fr)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof wo)t.authFlow.meta.smsCode=c.trim();else throw new S("Must initialize a passwordless code flow first");let p,m;if(i)try{p=await t.link()}catch(h){throw N(L,"linkAccount","onError",h.privyErrorCode||"failed_to_link_account"),h}else try{({user:p,isNewUser:m}=await t.authenticate())}catch(h){throw N(L,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}d(p||s||null),E(m||!1),l(!0)},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return d(c),c},walletProxy:T,createAnalyticsEvent:(c,p,m)=>t.createAnalyticsEvent(c,p,m),acceptTerms:async()=>{let c=await t.acceptTerms();return d(c),c},getUsdTokenPrice:c=>t.getUsdTokenPrice(c),recoverEmbeddedWallet:async()=>new Promise(async(c,p)=>{let m=s?.linkedAccounts.find(I=>I.type==="wallet"&&I.walletClientType==="privy"),h=await ve();if(!h||!T||!m){p(new Error("Must have valid access token and Privy wallet to recover wallet"));return}re(!0);try{await T.connect({accessToken:h,address:m.address}),c(!0)}catch(I){So(I)&&m.recoveryMethod==="privy"?(t.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:m.address}),(await T.recover({address:m.address,accessToken:h})).address||p(new Error("Unable to recover wallet")),t.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:m.address}),c(!0)):So(I)?(z({recoverWallet:{privyWallet:m,onFailure:p,onSuccess:()=>c(!0)}}),$("EMBEDDED_WALLET_RECOVERY_SCREEN")):p(I)}}),getFiatOnRampConfig:rr,setReadyToTrue:()=>{a(!0),Pe?.()},updateWallets:()=>Dr(),fundWallet:async(c,p)=>{let{signedUrl:m,externalTransactionId:h}=await rr(c,p);z({fiatOnRampPrompt:{signedUrl:m},fiatOnRampStatus:{externalTransactionId:h}}),$("FIAT_ON_RAMP_PROMPT_SCREEN")},requestFarcasterSignerStatus:async c=>{let p=await ve(),m=s?.linkedAccounts.find(I=>I.type==="wallet"&&I.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!T||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");let h=await t.requestFarcasterSignerStatus(c);if(h.status==="approved"){let I=await t.getAuthenticatedUser();d(I||s||null)}return h}}))();Dy=ie.recoverEmbeddedWallet;let Hy=WE(()=>({wallets:u,ready:Ae}),[u,Ae]);return Er(ce.Provider,{value:Lo,children:Er(El.Provider,{value:L,children:Er(qc.Provider,{value:Hy,children:Wy(Xp,{...O,children:[e.children,Wy(bl.Provider,{value:ie,children:[!rd&&O.captchaEnabled&&n&&!i&&Er(Cl,{delayedExecution:!1}),Er(xy,{theme:{...O.appearance.palette||{}}}),Er(jp,{data:te,setModalData:z,setInitialScreen:x,initialScreen:v,authenticated:i,open:r,children:Er(ky,{open:r})}),se&&Y?Er(My,{appId:e.appId,clientAnalyticsId:t.clientAnalyticsId,origin:t.apiUrl,mfaMethods:s?.mfaMethods,mfaPromise:Nr,mfaSubmitPromise:tr,onLoad:q,onLoadFailed:()=>null}):null]})]})})})})};import{useContext as FE}from"react";function UE(e){let{login:t}=FE(ce);return Ee("login",e),{login:t}}import{useContext as BE}from"react";function HE(e){let{logout:t}=BE(ce);return Ee("logout",e),{logout:t}}import{useCallback as Fy,useEffect as GE}from"react";function VE(){let e=fe(),t=_a(),{initLoginWithHeadlessOAuth:r,loginWithHeadlessOAuth:o,isHeadlessOAuthLoading:n,ready:a,user:i}=G(),l=Fy(async d=>{if(e.enabled&&e.status!=="success")throw new qt(e.error,null,"captcha_failure");return r(d.provider,e.token)},[r,e]),s=Fy(async()=>{let d=qn();if(i)return console.warn("Cannot login with OAuth when already logged in"),i;if(!d.inProgress)throw new Error("Cannot login with OAuth because no OAuth flow is in progress");try{return await o(d)}catch(u){throw u}finally{$n()}},[o]);return GE(()=>{let d=qn();a&&t&&d.inProgress&&d.headless&&s()},[a,t]),{initOAuth:l,loginWithOAuth:s,loading:n}}import{useCallback as Uy}from"react";var zE=()=>{let e=fe(),{initLoginWithEmail:t,loginWithCode:r}=G(),o=Uy(async({email:a})=>{if(!a)throw new Error("Email required to send OTP code");return t(a)},[t]),n=Uy(async({code:a})=>{if(e.enabled&&e.status==="error")throw new qt(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};import{useCallback as By}from"react";var qE=()=>{let e=fe(),{initLoginWithSms:t,loginWithCode:r}=G(),o=By(async({phoneNumber:a})=>{if(!a)throw new Error("SMS required to send OTP code");return t(a)},[t]),n=By(async({code:a})=>{if(e.enabled&&e.status!=="success")throw new qt(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};import{useContext as $E}from"react";function jE(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:l,linkGithub:s,linkLinkedIn:d,linkTiktok:u,linkSpotify:y,linkFarcaster:f}=$E(ce);return Ee("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:l,linkGithub:s,linkLinkedIn:d,linkTiktok:u,linkSpotify:y,linkFarcaster:f}}import{useContext as KE}from"react";function YE(e){let{connectWallet:t}=KE(ce);return Ee("connectWallet",e),{connectWallet:t}}import{useContext as JE}from"react";function ZE(e){let{createWallet:t}=JE(ce);return Ee("createWallet",e),{createWallet:t}}var QE=()=>{let{fundWallet:e}=G();return{fundWallet:e}};import{useContext as XE}from"react";function e4(e){let{sendTransaction:t}=XE(ce);return Ee("sendTransaction",e),{sendTransaction:t}}import{useContext as t4}from"react";function r4(e){let{setWalletPassword:t}=t4(ce);return Ee("setWalletPassword",e),{setWalletPassword:t}}import{useContext as o4}from"react";function n4(e){let{signMessage:t}=o4(ce);return Ee("signMessage",e),{signMessage:t}}import{useContext as i4}from"react";function a4(e){let{signTypedData:t}=i4(ce);return Ee("signTypedData",e),{signTypedData:t}}import{useContext as s4}from"react";var l4=()=>{let{isModalOpen:e}=s4(ce);return{isOpen:e}};import{useContext as c4}from"react";function d4(e){let{getAccessToken:t}=c4(ce);return Ee("accessToken",e),{getAccessToken:t}}function p4(){let{submitCast:e,removeCast:t,likeCast:r,recastCast:o,followUser:n,unfollowUser:a,requestFarcasterSigner:i}=G();return{followUser:n,unfollowUser:a,submitCast:e,removeCast:t,likeCast:r,recastCast:o,requestFarcasterSigner:i}}function u4(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}export{ar as AsExternalProvider,Cl as Captcha,Zn as ConnectorManager,Qn as PrivyClient,NE as PrivyProvider,be as PrivyProxyProvider,Yn as SUPPORTED_CHAINS,il as VERSION,mt as WalletConnector,u4 as addRpcUrlOverrideToChain,Yl as errorIndicatesMaxMfaRetries,mn as errorIndicatesMfaTimeout,fn as errorIndicatesMfaVerificationFailed,ve as getAccessToken,YE as useConnectWallet,ZE as useCreateWallet,p4 as useExperimentalFarcasterSigner,QE as useFundWallet,jE as useLinkAccount,UE as useLogin,zE as useLoginWithEmail,VE as useLoginWithOAuth,qE as useLoginWithSms,HE as useLogout,An as useMfa,Si as useMfaEnrollment,l4 as useModalStatus,G as usePrivy,Tl as useRegisterMfaListener,e4 as useSendTransaction,r4 as useSetWalletPassword,n4 as useSignMessage,a4 as useSignTypedData,d4 as useToken,Wi as useWallets};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var L1=Object.create;var xa=Object.defineProperty;var O1=Object.getOwnPropertyDescriptor;var N1=Object.getOwnPropertyNames;var D1=Object.getPrototypeOf,F1=Object.prototype.hasOwnProperty;var U1=(e,t)=>{for(var r in t)xa(e,r,{get:t[r],enumerable:!0})},Nd=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of N1(t))!F1.call(e,n)&&n!==r&&xa(e,n,{get:()=>t[n],enumerable:!(o=O1(t,n))||o.enumerable});return e};var y=(e,t,r)=>(r=e!=null?L1(D1(e)):{},Nd(t||!e||!e.__esModule?xa(r,"default",{value:e,enumerable:!0}):r,e)),B1=e=>Nd(xa({},"__esModule",{value:!0}),e);var jl=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var Dd=(e,t,r)=>(jl(e,t,"read from private field"),r?r.call(e):t.get(e)),Sa=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Kl=(e,t,r,o)=>(jl(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var Fd=(e,t,r)=>(jl(e,t,"access private method"),r);var i2={};U1(i2,{AsExternalProvider:()=>br,Captcha:()=>Ps,ConnectorManager:()=>Gn,PrivyClient:()=>Vn,PrivyProvider:()=>r1,PrivyProxyProvider:()=>Le,SUPPORTED_CHAINS:()=>Bn,VERSION:()=>Na,WalletConnector:()=>St,addRpcUrlOverrideToChain:()=>R1,errorIndicatesMaxMfaRetries:()=>qs,errorIndicatesMfaTimeout:()=>cn,errorIndicatesMfaVerificationFailed:()=>dn,getAccessToken:()=>Se,useConnectWallet:()=>m1,useCreateWallet:()=>h1,useExperimentalFarcasterSigner:()=>k1,useFundWallet:()=>y1,useLinkAccount:()=>p1,useLogin:()=>n1,useLoginWithEmail:()=>l1,useLoginWithOAuth:()=>s1,useLoginWithSms:()=>c1,useLogout:()=>a1,useMfa:()=>vn,useMfaEnrollment:()=>bi,useModalStatus:()=>S1,usePrivy:()=>V,useRegisterMfaListener:()=>As,useSendTransaction:()=>v1,useSetWalletPassword:()=>C1,useSignMessage:()=>E1,useSignTypedData:()=>P1,useToken:()=>A1,useWallets:()=>ki});module.exports=B1(i2);var Ea=require("@ethersproject/address"),Vl=require("@ethersproject/providers"),Zg=require("mipd"),ee=require("react");var Ud=require("ofetch"),mt=class extends Error{constructor(r,o,n){super(r);o instanceof Error&&(this.cause=o),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},Br=class extends mt{constructor(r,o,n,a,i){super(n,a,i);this.type=r;this.status=o}},_=class extends mt{constructor(r,o,n){super(r,o,n);this.type="client_error"}},_a=class extends _{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var oe=class extends mt{constructor(r,o,n){super(r,o,n);this.type="connector_error"}},we=e=>{if(e instanceof mt)return e;if(!(e instanceof Ud.FetchError))return Tt(e);if(!e.response)return new Br("api_error",null,e.message,e);let{type:t,message:r,error:o,code:n}=e.data;return new Br(t||"ApiError",e.response.status,r||o,e,n)},Tt=e=>e instanceof mt?e:e instanceof Error?new _(e.message,e):new _(`Internal error: ${e}`);var xn=class extends _{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},qt=class extends _{constructor(t="Embedded wallet error",r){super(t,r,"unknown_embedded_wallet_error")}},Aa=class extends _{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var ka="/api/v1/sessions",Ra="/api/v1/sessions/logout",Bd="/api/v1/sessions/fork",Ia="/api/v1/sessions/fork/recover",Hd="/api/v1/siwe/init",Gd="/api/v1/siwe/authenticate",Vd="/api/v1/siwe/link",zd="/api/v1/siwe/unlink",qd="/api/v1/farcaster/init",$d="/api/v1/farcaster/authenticate",jd="/api/v1/farcaster/link",Kd="/api/v1/farcaster/status",Yd="/api/v1/farcaster/unlink",Jd="/api/v1/passwordless/init",Zd="/api/v1/passwordless/authenticate",Qd="/api/v1/passwordless/link",Xd="/api/v1/passwordless/unlink",ep="/api/v1/passwordless/update",tp="/api/v1/passwordless_sms/init",rp="/api/v1/passwordless_sms/link",op="/api/v1/passwordless_sms/unlink",np="/api/v1/passwordless_sms/authenticate",ip="/api/v1/oauth/init",ap="/api/v1/oauth/authenticate",sp="/api/v1/oauth/link",lp="/api/v1/oauth/unlink";var cp="/api/v1/mfa/passwordless_sms/init",dp="/api/v1/mfa/passwordless_sms/enroll";var pp="/api/v1/users/me/accept_terms",up="/api/v1/analytics_events",mp="/api/v1/plugins/moonpay_on_ramp/sign",fp="/api/v1/custom_jwt_account/authenticate";var Sn=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new _("Auth flow has no API instance");try{let t=await this.api.post(fp,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw we(t)}}async link(){throw new Error("Unimplemented")}};var xo=class{constructor(t,r){this.meta={email:t,captchaToken:r}}async authenticate(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new _("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Zd,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw we(t)}}async link(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new _("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Qd,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw we(t)}}async sendCodeEmail(t,r){if(!this.api)throw new _("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new _("Email must be set when initialzing authentication.");try{return await this.api.post(Jd,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw we(o)}}},Ma=class extends xo{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r}}async link(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new _("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(ep,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw we(r)}}};var $a=require("react-device-detect");var Yl=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,r){r!==void 0?this._cache[t]=r:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},Wa=class{get(t){let r=localStorage.getItem(t);return r===null?void 0:JSON.parse(r)}put(t,r){r!==void 0?localStorage.setItem(t,JSON.stringify(r)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Jl(){try{let e="privy:__session_storage__test",t="blobby",r=new Wa;return r.put(e,t),r.del(e),!0}catch{return!1}}function H1(){return typeof window<"u"&&window.localStorage?new Wa:new Yl}var Q=H1();var tn=require("@ethersproject/providers");function hp(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let o of t.providers)o&&r.push(o);return r.push(e.ethereum),r}var La=e=>{if(e.isApexWallet)return"Apex Wallet";if(e.isAvalanche)return"Core Wallet";if(e.isBackpack)return"Backpack";if(e.isBifrost)return"Bifrost Wallet";if(e.isBitKeep)return"BitKeep";if(e.isBitski)return"Bitski";if(e.isBlockWallet)return"BlockWallet";if(e.isBraveWallet)return"Brave Wallet";if(e.isClover)return"Clover";if(e.isCoin98)return"Coin98 Wallet";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isDawn)return"Dawn Wallet";if(e.isDefiant)return"Defiant";if(e.isDesig)return"Desig Wallet";if(e.isEnkrypt)return"Enkrypt";if(e.isExodus)return"Exodus";if(e.isFordefi)return"Fordefi";if(e.isFrame)return"Frame";if(e.isFrontier)return"Frontier Wallet";if(e.isGamestop)return"GameStop Wallet";if(e.isHaqqWallet)return"HAQQ Wallet";if(e.isHyperPay)return"HyperPay Wallet";if(e.isImToken)return"ImToken";if(e.isHaloWallet)return"Halo Wallet";if(e.isKuCoinWallet)return"KuCoin Wallet";if(e.isMathWallet)return"MathWallet";if(e.isNovaWallet)return"Nova Wallet";if(e.isOkxWallet||e.isOKExWallet)return"OKX Wallet";if(e.isOneInchIOSWallet||e.isOneInchAndroidWallet)return"1inch Wallet";if(e.isOneKey)return"OneKey Wallet";if(e.isOpera)return"Opera";if(e.isPhantom)return"Phantom";if(e.isPortal)return"Ripio Portal";if(e.isRabby)return"Rabby Wallet";if(e.isRainbow)return"Rainbow";if(e.isSafePal)return"SafePal Wallet";if(e.isStatus)return"Status";if(e.isSubWallet)return"SubWallet";if(e.isTalisman)return"Talisman";if(e.isTally||e.isTaho)return"Taho";if(e.isTokenPocket)return"TokenPocket";if(e.isTokenary)return"Tokenary";if(e.isTrust||e.isTrustWallet)return"Trust Wallet";if(e.isTTWallet)return"TTWallet";if(e.isXDEFI)return"XDEFI Wallet";if(e.isZeal)return"Zeal";if(e.isZerion)return"Zerion";if(e.isMetaMask)return"MetaMask"};var Zl=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||La(e)!=="MetaMask")return!1;if(e.providers){for(let r of e.providers)if(!Zl(r))return!1}return!0},So=()=>!!("phantom"in window&&window?.phantom?.ethereum?.isPhantom),yp=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0}return!1};var gp="1.59.7-beta-20240326191824";var Ql="4df5e2316331463a9130964bd6078dfa",Xl="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",vp="34357d3c125c2bcf2ce2bc3309d98715",Oa="https://auth.privy.io",wp=2e4,at=1400,Cp=2500,Na=gp;var Zo="privy:token",ec="privy-token",Da="privy:refresh_token",tc="privy-refresh-token",Fa="privy-session",Oi="privy:session_transfer_token",V1="privy:wallet",Ni="privy:caid",Qo="privy:state_code",_n="privy:code_verifier",Xo="privy:headless_oauth",Ua=e=>`${V1}:${e}`,rc="privy:connectors",oc="privy:connections";var en=12e4,ao=1,nc="0x1",An=3e4,bp="https://api.moonpay.com/v1",Ep="https://api.moonpay.com/v1",Tp="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Pp="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",xp="0x420000000000000000000000000000000000000F",Sp=["function getL1Fee(bytes memory _data) external view returns (uint256)"];var _p=(e,t)=>{let r=[],o=[];for(let[n,a]of e.entries())n<t?r.push(a):o.push(a);return[r,o]},Ba=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),Ap=(e,t)=>{let r=e.slice(0),o=[];for(;r.length;)o.push(r.splice(0,t));return o},_o=(e,t=3,r=4)=>{if(!e)return"";let o=2,n=3;if(t+r+o+n>=e.length)return e;let a=e.slice(0,o+t),i=e.slice(e.length-r,e.length);return`${a}...${i}`},ic=e=>new Promise(t=>setTimeout(t,e));function kp(e,{interval:t=100,timeout:r=5e3}={}){return new Promise((o,n)=>{let a=0,i,l=()=>{if(a>=r){n("Max attempts reached without result");return}if(i=e(),a+=t,i!=null){o(i);return}setTimeout(l,t)};l()})}var Rp=(e,t={})=>{let r=t.delayMs||150,o=t.maxAttempts||270;return new Promise(async(n,a)=>{let i=!1,l=0;for(;!i&&l<o;){if(t.abortSignal?.aborted)return;e().then(()=>{i=!0,n()},(...s)=>{i=!0,a(...s)}),l+=1,await ic(r)}i||a(new Error("Exceeded max attempts before resolving function"))})},Ha=(e,t,r={})=>{let o=new URL(t,e);for(let[n,a]of Object.entries(r))o.searchParams.set(n,a);return o.href};var Ip=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),rn=e=>typeof e=="string"?e:"0x"+e.toString(16);async function Mp(e,t,r=3e3){let o=!1,n=window;return new Promise(a=>{n.ethereum?i():(window.addEventListener("ethereum#initialized",i,{once:!0}),setTimeout(()=>{i()},r));function i(){if(o)return;o=!0,window.removeEventListener("ethereum#initialized",i);let l=e.getProviders(),s=[];for(let d of l)t.includes("coinbase_wallet")&&d.info.rdns==="com.coinbase.wallet"||s.push({type:d.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:d});for(let d of hp()){let u=La(d);if(!l.some(v=>v.info.name===u)){if(Zl(d,!0)&&!s.find(v=>v.type==="metamask")){s.push({type:"metamask",legacyInjectedProvider:d});continue}if(u==="Phantom"&&!s.find(v=>v.type==="phantom")){s.push({type:"phantom",legacyInjectedProvider:d});continue}s.find(v=>v.type==="unknown_browser_extension")||s.push({type:"unknown_browser_extension",legacyInjectedProvider:d})}}a(s)}})}function kn(e){return`eip155:${String(Number(e))}`}var Ga=(e,t,r,o)=>{let n=Number(e),a=t.find(l=>l.id===n);if(!a)throw new oe(`Unsupported chainId ${e}`,4901);let i;if(a.rpcUrls.privyWalletOverride&&a.rpcUrls.privyWalletOverride.http[0])i=a.rpcUrls.privyWalletOverride.http[0];else if(r.rpcUrls&&r.rpcUrls[n])i=r.rpcUrls[n];else if(a.rpcUrls.privy?.http[0]){let l=new URL(a.rpcUrls.privy.http[0]);l.searchParams.append("privyAppId",o),i=l.toString()}else a.rpcUrls.infura?.http[0]?i=a.rpcUrls.infura.http[0]+"/"+Ql:a.rpcUrls.blast?.http[0]?i=a.rpcUrls.blast.http[0]+"/"+Xl:i=a.rpcUrls.default?.http[0];if(!i)throw new oe(`No RPC url found for ${e}`);return i},Wp=(e,t)=>{let r=Number(e),o=t.find(n=>n.id===r);if(!o)throw new oe(`Unsupported chainId ${e}`,4901);return o.blockExplorers?.default.url},so=(e,t,r,o)=>{let n=Number(e),a=t.find(l=>l.id===n);if(!a)throw new oe(`Unsupported chainId ${e}`,4901);let i;if(a.rpcUrls.privyWalletOverride&&a.rpcUrls.privyWalletOverride.http[0]?i=new tn.StaticJsonRpcProvider(a.rpcUrls.privyWalletOverride.http[0]):r.rpcUrls&&r.rpcUrls[n]?i=new tn.StaticJsonRpcProvider(r.rpcUrls[n]):a.rpcUrls.privy?.http[0]?i=new tn.StaticJsonRpcProvider({url:a.rpcUrls.privy.http[0],headers:{"privy-app-id":o.appId}}):a.rpcUrls.infura?.http[0]?i=new tn.StaticJsonRpcProvider(a.rpcUrls.infura.http[0]+"/"+Ql):a.rpcUrls.blast?.http[0]?i=new tn.StaticJsonRpcProvider(a.rpcUrls.blast.http[0]+"/"+Xl):i=new tn.StaticJsonRpcProvider(a.rpcUrls.default?.http[0]),!i)throw new oe(`No RPC url found for ${e}`);return i},Va=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map(([o,n])=>{if(n!=null&&typeof o=="string"&&o in t)return{name:o,type:t[o]}}).filter(o=>o!==void 0);return{...e,types:{...e.types,EIP712Domain:r}}};var za=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(Rn))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var Rn={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"}}};function z1(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}var Lp=e=>e in Rn,Op=e=>{let t=Rn[e].mobile;if("native"in t)return t.native};function Np(e,t){let r=z1(t);if(r.deepLink)return Hp(r.deepLink,e);if(r.universalLink)return Gp(r.universalLink,e);throw new _(`Unsupported wallet ${t.id}`)}var Dp="WALLETCONNECT_DEEPLINK_CHOICE";function Fp(){try{localStorage.removeItem(Dp)}catch{}}function Up({href:e,name:t}){try{localStorage.setItem(Dp,JSON.stringify({href:e,name:t}))}catch{}}function Bp(e){return e.startsWith("http://")||e.startsWith("https://")}function Hp(e,t){if(Bp(e))return Gp(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 Gp(e,t){if(!Bp(e))return Hp(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function qa(e,t){window.open(e,t,"noreferrer noopener")}var Pt=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 Di=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Pt(this._startChannelOnce.bind(this)),this.pollForReady=new Pt(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.channelToken)throw new _("Auth flow must be initialized first");try{let t=await this.api.post($d,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new _("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw we(t)}}async link(){if(!this.api)throw new _("Auth flow has no API instance");try{return await this.api.post(jd,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw we(t)}}async _startChannelOnce(){if(!this.api)throw new _("Auth flow has no API instance");let t=await this.api.post(qd,{token:this.captchaToken});$a.isMobile&&!$a.isIOS&&t.connect_uri&&qa(t.connect_uri,"_blank"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new _("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.channelToken)throw new _("Auth flow must be initialized first");let t=await this.api.get(Kd,{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}};var ac=require("jose");async function Vp(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function zp(e){return crypto.getRandomValues(new Uint8Array(e))}function ja(){return!!Q.get(Xo)}var q1="S256",$1="S256",Hr=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:ja();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 _("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new _("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new _("User denied confirmation during OAuth flow");let t=Q.get(_n);if(!t)throw new _("Authentication error.");try{let r=await this.api.post(ap,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Q.del(_n),this.meta.headless&&Q.del(Xo),{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(r){let o=we(r);throw o.privyErrorCode?new _(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new _("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new _("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new _("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new _("User denied confirmation during OAuth flow");let t=Q.get(_n);if(!t)throw new _("Authentication error.");try{let r=await this.api.post(sp,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Q.del(_n),r}catch(r){throw we(r)}}createCodeVerifier(){return ac.base64url.encode(zp(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,r=q1){if(r==$1){let o=await Vp(t);return ac.base64url.encode(o)}else return t}async getAuthorizationUrl(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.provider)throw new _("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();Q.put(_n,t);let r=this.createStateCode();Q.put(Qo,r);let o=await this.deriveCodeChallengeFromCodeVerifier(t);this.meta.headless&&Q.put(Xo,!0);try{return await this.api.post(ip,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw we(n)}}};function sc(e){return e.charAt(0).toUpperCase()+e.slice(1)}function qp(e,t){let r={detail:"",retryable:!1},o=sc(t);return 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==="oauth_account_suspended"&&(r.detail=`Your ${o} account is suspended. Please try another login method.`),r}function Ui(){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");return!t||!r||!o?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:ja()}}function Bi(){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"),Q.del(Qo),window.history.replaceState({},"",e)}var on=class{constructor(t,r){this.createSiweMessage=(t,r,o,n,a,i,l)=>`${o} wants you to sign in with your Ethereum account:
|
|
1
|
+
"use strict";var L1=Object.create;var xa=Object.defineProperty;var O1=Object.getOwnPropertyDescriptor;var N1=Object.getOwnPropertyNames;var D1=Object.getPrototypeOf,F1=Object.prototype.hasOwnProperty;var U1=(e,t)=>{for(var r in t)xa(e,r,{get:t[r],enumerable:!0})},Nd=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of N1(t))!F1.call(e,n)&&n!==r&&xa(e,n,{get:()=>t[n],enumerable:!(o=O1(t,n))||o.enumerable});return e};var y=(e,t,r)=>(r=e!=null?L1(D1(e)):{},Nd(t||!e||!e.__esModule?xa(r,"default",{value:e,enumerable:!0}):r,e)),B1=e=>Nd(xa({},"__esModule",{value:!0}),e);var jl=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var Dd=(e,t,r)=>(jl(e,t,"read from private field"),r?r.call(e):t.get(e)),Sa=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Kl=(e,t,r,o)=>(jl(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var Fd=(e,t,r)=>(jl(e,t,"access private method"),r);var i2={};U1(i2,{AsExternalProvider:()=>br,Captcha:()=>Ps,ConnectorManager:()=>Gn,PrivyClient:()=>Vn,PrivyProvider:()=>r1,PrivyProxyProvider:()=>Le,SUPPORTED_CHAINS:()=>Bn,VERSION:()=>Na,WalletConnector:()=>St,addRpcUrlOverrideToChain:()=>R1,errorIndicatesMaxMfaRetries:()=>qs,errorIndicatesMfaTimeout:()=>cn,errorIndicatesMfaVerificationFailed:()=>dn,getAccessToken:()=>Se,useConnectWallet:()=>m1,useCreateWallet:()=>h1,useExperimentalFarcasterSigner:()=>k1,useFundWallet:()=>y1,useLinkAccount:()=>p1,useLogin:()=>n1,useLoginWithEmail:()=>l1,useLoginWithOAuth:()=>s1,useLoginWithSms:()=>c1,useLogout:()=>a1,useMfa:()=>vn,useMfaEnrollment:()=>bi,useModalStatus:()=>S1,usePrivy:()=>V,useRegisterMfaListener:()=>As,useSendTransaction:()=>v1,useSetWalletPassword:()=>C1,useSignMessage:()=>E1,useSignTypedData:()=>P1,useToken:()=>A1,useWallets:()=>ki});module.exports=B1(i2);var Ea=require("@ethersproject/address"),Vl=require("@ethersproject/providers"),Zg=require("mipd"),ee=require("react");var Ud=require("ofetch"),mt=class extends Error{constructor(r,o,n){super(r);o instanceof Error&&(this.cause=o),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},Br=class extends mt{constructor(r,o,n,a,i){super(n,a,i);this.type=r;this.status=o}},_=class extends mt{constructor(r,o,n){super(r,o,n);this.type="client_error"}},_a=class extends _{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var oe=class extends mt{constructor(r,o,n){super(r,o,n);this.type="connector_error"}},we=e=>{if(e instanceof mt)return e;if(!(e instanceof Ud.FetchError))return Tt(e);if(!e.response)return new Br("api_error",null,e.message,e);let{type:t,message:r,error:o,code:n}=e.data;return new Br(t||"ApiError",e.response.status,r||o,e,n)},Tt=e=>e instanceof mt?e:e instanceof Error?new _(e.message,e):new _(`Internal error: ${e}`);var xn=class extends _{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},qt=class extends _{constructor(t="Embedded wallet error",r){super(t,r,"unknown_embedded_wallet_error")}},Aa=class extends _{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var ka="/api/v1/sessions",Ra="/api/v1/sessions/logout",Bd="/api/v1/sessions/fork",Ia="/api/v1/sessions/fork/recover",Hd="/api/v1/siwe/init",Gd="/api/v1/siwe/authenticate",Vd="/api/v1/siwe/link",zd="/api/v1/siwe/unlink",qd="/api/v1/farcaster/init",$d="/api/v1/farcaster/authenticate",jd="/api/v1/farcaster/link",Kd="/api/v1/farcaster/status",Yd="/api/v1/farcaster/unlink",Jd="/api/v1/passwordless/init",Zd="/api/v1/passwordless/authenticate",Qd="/api/v1/passwordless/link",Xd="/api/v1/passwordless/unlink",ep="/api/v1/passwordless/update",tp="/api/v1/passwordless_sms/init",rp="/api/v1/passwordless_sms/link",op="/api/v1/passwordless_sms/unlink",np="/api/v1/passwordless_sms/authenticate",ip="/api/v1/oauth/init",ap="/api/v1/oauth/authenticate",sp="/api/v1/oauth/link",lp="/api/v1/oauth/unlink";var cp="/api/v1/mfa/passwordless_sms/init",dp="/api/v1/mfa/passwordless_sms/enroll";var pp="/api/v1/users/me/accept_terms",up="/api/v1/analytics_events",mp="/api/v1/plugins/moonpay_on_ramp/sign",fp="/api/v1/custom_jwt_account/authenticate";var Sn=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new _("Auth flow has no API instance");try{let t=await this.api.post(fp,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw we(t)}}async link(){throw new Error("Unimplemented")}};var xo=class{constructor(t,r){this.meta={email:t,captchaToken:r}}async authenticate(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new _("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Zd,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw we(t)}}async link(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new _("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Qd,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw we(t)}}async sendCodeEmail(t,r){if(!this.api)throw new _("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new _("Email must be set when initialzing authentication.");try{return await this.api.post(Jd,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw we(o)}}},Ma=class extends xo{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r}}async link(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new _("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(ep,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw we(r)}}};var $a=require("react-device-detect");var Yl=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,r){r!==void 0?this._cache[t]=r:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},Wa=class{get(t){let r=localStorage.getItem(t);return r===null?void 0:JSON.parse(r)}put(t,r){r!==void 0?localStorage.setItem(t,JSON.stringify(r)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Jl(){try{let e="privy:__session_storage__test",t="blobby",r=new Wa;return r.put(e,t),r.del(e),!0}catch{return!1}}function H1(){return typeof window<"u"&&window.localStorage?new Wa:new Yl}var Q=H1();var tn=require("@ethersproject/providers");function hp(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let o of t.providers)o&&r.push(o);return r.push(e.ethereum),r}var La=e=>{if(e.isApexWallet)return"Apex Wallet";if(e.isAvalanche)return"Core Wallet";if(e.isBackpack)return"Backpack";if(e.isBifrost)return"Bifrost Wallet";if(e.isBitKeep)return"BitKeep";if(e.isBitski)return"Bitski";if(e.isBlockWallet)return"BlockWallet";if(e.isBraveWallet)return"Brave Wallet";if(e.isClover)return"Clover";if(e.isCoin98)return"Coin98 Wallet";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isDawn)return"Dawn Wallet";if(e.isDefiant)return"Defiant";if(e.isDesig)return"Desig Wallet";if(e.isEnkrypt)return"Enkrypt";if(e.isExodus)return"Exodus";if(e.isFordefi)return"Fordefi";if(e.isFrame)return"Frame";if(e.isFrontier)return"Frontier Wallet";if(e.isGamestop)return"GameStop Wallet";if(e.isHaqqWallet)return"HAQQ Wallet";if(e.isHyperPay)return"HyperPay Wallet";if(e.isImToken)return"ImToken";if(e.isHaloWallet)return"Halo Wallet";if(e.isKuCoinWallet)return"KuCoin Wallet";if(e.isMathWallet)return"MathWallet";if(e.isNovaWallet)return"Nova Wallet";if(e.isOkxWallet||e.isOKExWallet)return"OKX Wallet";if(e.isOneInchIOSWallet||e.isOneInchAndroidWallet)return"1inch Wallet";if(e.isOneKey)return"OneKey Wallet";if(e.isOpera)return"Opera";if(e.isPhantom)return"Phantom";if(e.isPortal)return"Ripio Portal";if(e.isRabby)return"Rabby Wallet";if(e.isRainbow)return"Rainbow";if(e.isSafePal)return"SafePal Wallet";if(e.isStatus)return"Status";if(e.isSubWallet)return"SubWallet";if(e.isTalisman)return"Talisman";if(e.isTally||e.isTaho)return"Taho";if(e.isTokenPocket)return"TokenPocket";if(e.isTokenary)return"Tokenary";if(e.isTrust||e.isTrustWallet)return"Trust Wallet";if(e.isTTWallet)return"TTWallet";if(e.isXDEFI)return"XDEFI Wallet";if(e.isZeal)return"Zeal";if(e.isZerion)return"Zerion";if(e.isMetaMask)return"MetaMask"};var Zl=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||La(e)!=="MetaMask")return!1;if(e.providers){for(let r of e.providers)if(!Zl(r))return!1}return!0},So=()=>!!("phantom"in window&&window?.phantom?.ethereum?.isPhantom),yp=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0}return!1};var gp="1.59.7";var Ql="4df5e2316331463a9130964bd6078dfa",Xl="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",vp="34357d3c125c2bcf2ce2bc3309d98715",Oa="https://auth.privy.io",wp=2e4,at=1400,Cp=2500,Na=gp;var Zo="privy:token",ec="privy-token",Da="privy:refresh_token",tc="privy-refresh-token",Fa="privy-session",Oi="privy:session_transfer_token",V1="privy:wallet",Ni="privy:caid",Qo="privy:state_code",_n="privy:code_verifier",Xo="privy:headless_oauth",Ua=e=>`${V1}:${e}`,rc="privy:connectors",oc="privy:connections";var en=12e4,ao=1,nc="0x1",An=3e4,bp="https://api.moonpay.com/v1",Ep="https://api.moonpay.com/v1",Tp="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Pp="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",xp="0x420000000000000000000000000000000000000F",Sp=["function getL1Fee(bytes memory _data) external view returns (uint256)"];var _p=(e,t)=>{let r=[],o=[];for(let[n,a]of e.entries())n<t?r.push(a):o.push(a);return[r,o]},Ba=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),Ap=(e,t)=>{let r=e.slice(0),o=[];for(;r.length;)o.push(r.splice(0,t));return o},_o=(e,t=3,r=4)=>{if(!e)return"";let o=2,n=3;if(t+r+o+n>=e.length)return e;let a=e.slice(0,o+t),i=e.slice(e.length-r,e.length);return`${a}...${i}`},ic=e=>new Promise(t=>setTimeout(t,e));function kp(e,{interval:t=100,timeout:r=5e3}={}){return new Promise((o,n)=>{let a=0,i,l=()=>{if(a>=r){n("Max attempts reached without result");return}if(i=e(),a+=t,i!=null){o(i);return}setTimeout(l,t)};l()})}var Rp=(e,t={})=>{let r=t.delayMs||150,o=t.maxAttempts||270;return new Promise(async(n,a)=>{let i=!1,l=0;for(;!i&&l<o;){if(t.abortSignal?.aborted)return;e().then(()=>{i=!0,n()},(...s)=>{i=!0,a(...s)}),l+=1,await ic(r)}i||a(new Error("Exceeded max attempts before resolving function"))})},Ha=(e,t,r={})=>{let o=new URL(t,e);for(let[n,a]of Object.entries(r))o.searchParams.set(n,a);return o.href};var Ip=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),rn=e=>typeof e=="string"?e:"0x"+e.toString(16);async function Mp(e,t,r=3e3){let o=!1,n=window;return new Promise(a=>{n.ethereum?i():(window.addEventListener("ethereum#initialized",i,{once:!0}),setTimeout(()=>{i()},r));function i(){if(o)return;o=!0,window.removeEventListener("ethereum#initialized",i);let l=e.getProviders(),s=[];for(let d of l)t.includes("coinbase_wallet")&&d.info.rdns==="com.coinbase.wallet"||s.push({type:d.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:d});for(let d of hp()){let u=La(d);if(!l.some(v=>v.info.name===u)){if(Zl(d,!0)&&!s.find(v=>v.type==="metamask")){s.push({type:"metamask",legacyInjectedProvider:d});continue}if(u==="Phantom"&&!s.find(v=>v.type==="phantom")){s.push({type:"phantom",legacyInjectedProvider:d});continue}s.find(v=>v.type==="unknown_browser_extension")||s.push({type:"unknown_browser_extension",legacyInjectedProvider:d})}}a(s)}})}function kn(e){return`eip155:${String(Number(e))}`}var Ga=(e,t,r,o)=>{let n=Number(e),a=t.find(l=>l.id===n);if(!a)throw new oe(`Unsupported chainId ${e}`,4901);let i;if(a.rpcUrls.privyWalletOverride&&a.rpcUrls.privyWalletOverride.http[0])i=a.rpcUrls.privyWalletOverride.http[0];else if(r.rpcUrls&&r.rpcUrls[n])i=r.rpcUrls[n];else if(a.rpcUrls.privy?.http[0]){let l=new URL(a.rpcUrls.privy.http[0]);l.searchParams.append("privyAppId",o),i=l.toString()}else a.rpcUrls.infura?.http[0]?i=a.rpcUrls.infura.http[0]+"/"+Ql:a.rpcUrls.blast?.http[0]?i=a.rpcUrls.blast.http[0]+"/"+Xl:i=a.rpcUrls.default?.http[0];if(!i)throw new oe(`No RPC url found for ${e}`);return i},Wp=(e,t)=>{let r=Number(e),o=t.find(n=>n.id===r);if(!o)throw new oe(`Unsupported chainId ${e}`,4901);return o.blockExplorers?.default.url},so=(e,t,r,o)=>{let n=Number(e),a=t.find(l=>l.id===n);if(!a)throw new oe(`Unsupported chainId ${e}`,4901);let i;if(a.rpcUrls.privyWalletOverride&&a.rpcUrls.privyWalletOverride.http[0]?i=new tn.StaticJsonRpcProvider(a.rpcUrls.privyWalletOverride.http[0]):r.rpcUrls&&r.rpcUrls[n]?i=new tn.StaticJsonRpcProvider(r.rpcUrls[n]):a.rpcUrls.privy?.http[0]?i=new tn.StaticJsonRpcProvider({url:a.rpcUrls.privy.http[0],headers:{"privy-app-id":o.appId}}):a.rpcUrls.infura?.http[0]?i=new tn.StaticJsonRpcProvider(a.rpcUrls.infura.http[0]+"/"+Ql):a.rpcUrls.blast?.http[0]?i=new tn.StaticJsonRpcProvider(a.rpcUrls.blast.http[0]+"/"+Xl):i=new tn.StaticJsonRpcProvider(a.rpcUrls.default?.http[0]),!i)throw new oe(`No RPC url found for ${e}`);return i},Va=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map(([o,n])=>{if(n!=null&&typeof o=="string"&&o in t)return{name:o,type:t[o]}}).filter(o=>o!==void 0);return{...e,types:{...e.types,EIP712Domain:r}}};var za=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(Rn))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var Rn={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"}}};function z1(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}var Lp=e=>e in Rn,Op=e=>{let t=Rn[e].mobile;if("native"in t)return t.native};function Np(e,t){let r=z1(t);if(r.deepLink)return Hp(r.deepLink,e);if(r.universalLink)return Gp(r.universalLink,e);throw new _(`Unsupported wallet ${t.id}`)}var Dp="WALLETCONNECT_DEEPLINK_CHOICE";function Fp(){try{localStorage.removeItem(Dp)}catch{}}function Up({href:e,name:t}){try{localStorage.setItem(Dp,JSON.stringify({href:e,name:t}))}catch{}}function Bp(e){return e.startsWith("http://")||e.startsWith("https://")}function Hp(e,t){if(Bp(e))return Gp(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 Gp(e,t){if(!Bp(e))return Hp(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function qa(e,t){window.open(e,t,"noreferrer noopener")}var Pt=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 Di=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Pt(this._startChannelOnce.bind(this)),this.pollForReady=new Pt(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.channelToken)throw new _("Auth flow must be initialized first");try{let t=await this.api.post($d,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new _("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw we(t)}}async link(){if(!this.api)throw new _("Auth flow has no API instance");try{return await this.api.post(jd,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw we(t)}}async _startChannelOnce(){if(!this.api)throw new _("Auth flow has no API instance");let t=await this.api.post(qd,{token:this.captchaToken});$a.isMobile&&!$a.isIOS&&t.connect_uri&&qa(t.connect_uri,"_blank"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new _("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.channelToken)throw new _("Auth flow must be initialized first");let t=await this.api.get(Kd,{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}};var ac=require("jose");async function Vp(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function zp(e){return crypto.getRandomValues(new Uint8Array(e))}function ja(){return!!Q.get(Xo)}var q1="S256",$1="S256",Hr=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:ja();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 _("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new _("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new _("User denied confirmation during OAuth flow");let t=Q.get(_n);if(!t)throw new _("Authentication error.");try{let r=await this.api.post(ap,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Q.del(_n),this.meta.headless&&Q.del(Xo),{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(r){let o=we(r);throw o.privyErrorCode?new _(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new _("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new _("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new _("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new _("User denied confirmation during OAuth flow");let t=Q.get(_n);if(!t)throw new _("Authentication error.");try{let r=await this.api.post(sp,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Q.del(_n),r}catch(r){throw we(r)}}createCodeVerifier(){return ac.base64url.encode(zp(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,r=q1){if(r==$1){let o=await Vp(t);return ac.base64url.encode(o)}else return t}async getAuthorizationUrl(){if(!this.api)throw new _("Auth flow has no API instance");if(!this.meta.provider)throw new _("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();Q.put(_n,t);let r=this.createStateCode();Q.put(Qo,r);let o=await this.deriveCodeChallengeFromCodeVerifier(t);this.meta.headless&&Q.put(Xo,!0);try{return await this.api.post(ip,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw we(n)}}};function sc(e){return e.charAt(0).toUpperCase()+e.slice(1)}function qp(e,t){let r={detail:"",retryable:!1},o=sc(t);return 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==="oauth_account_suspended"&&(r.detail=`Your ${o} account is suspended. Please try another login method.`),r}function Ui(){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");return!t||!r||!o?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:ja()}}function Bi(){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"),Q.del(Qo),window.history.replaceState({},"",e)}var on=class{constructor(t,r){this.createSiweMessage=(t,r,o,n,a,i,l)=>`${o} wants you to sign in with your Ethereum account:
|
|
2
2
|
${r}
|
|
3
3
|
|
|
4
4
|
${l}
|
|
@@ -2749,4 +2749,4 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2749
2749
|
opacity: 1;
|
|
2750
2750
|
}
|
|
2751
2751
|
}
|
|
2752
|
-
`;var qe=require("react/jsx-runtime"),j0={["LANDING"]:my,["CONNECT_OR_CREATE"]:uy,["AWAITING_PASSWORDLESS_CODE"]:um,["AWAITING_CONNECTION"]:Fm,["AWAITING_CONNECT_ONLY_CONNECTION"]:Hm,["AWAITING_FARCASTER_CONNECTION"]:mh,["AWAITING_FARCASTER_SIGNER"]:vh,["PHANTOM_INTERSTITIAL_SCREEN"]:kg,["LOGIN_FAILED_SCREEN"]:Cy,["AWAITING_OAUTH_SCREEN"]:xg,["ALLOWLIST_REJECTION_SCREEN"]:tm,["INSTALL_PHANTOM_SCREEN"]:Bh,["LINK_EMAIL_SCREEN"]:hy,["LINK_PHONE_SCREEN"]:gy,["LINK_WALLET_SCREEN"]:vy,["UPDATE_EMAIL_SCREEN"]:Gg,["CONNECT_ONLY_LANDING_SCREEN"]:Om,["CONNECT_ONLY_AUTHENTICATED_SCREEN"]:km,["EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN"]:Hf,["EMBEDDED_WALLET_CREATED_SCREEN"]:Jm,["EMBEDDED_WALLET_CONNECTING_SCREEN"]:jm,["EMBEDDED_WALLET_RECOVERY_SCREEN"]:Kf,["EMBEDDED_WALLET_KEY_EXPORT_SCREEN"]:tf,["EMBEDDED_WALLET_SIGN_REQUEST_SCREEN"]:Dg,["EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN"]:Lg,["FIAT_ON_RAMP_PROMPT_SCREEN"]:_h,["FIAT_ON_RAMP_STATUS_SCREEN"]:Mh,["EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN"]:$f,["EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN"]:Gf,["MFA_ENROLLMENT_FLOW_SCREEN"]:Dy,["CAPTCHA_SCREEN"]:Cm,["ERROR_SCREEN"]:Zf,["IN_APP_BROWSER_LOGIN_NOT_POSSIBLE"]:Oh,["AFFIRMATIVE_CONSENT_SCREEN"]:Xu},K0=["LANDING","AWAITING_CONNECTION"],Y0=({isMfaVerifying:e,onMfaVerificationComplete:t})=>{let{ready:r,isModalOpen:o}=V(),{headless:n}=L(),{ready:a,currentScreen:i}=A(),{status:l,execute:s,reset:d,enabled:u}=_e(),v=(0,Eo.useRef)(null),h=Uu(v),w=o&&i&&K0.includes(i)&&!n&&l==="ready";if((0,Eo.useEffect)(()=>{w&&s()},[w]),(0,Eo.useEffect)(()=>{!o&&u&&d()},[o,u]),(!r||!a)&&i!=="AWAITING_OAUTH_SCREEN")return(0,qe.jsxs)(wi,{children:[(0,qe.jsx)(k,{}),(0,qe.jsx)(X,{}),(0,qe.jsx)(Ey,{children:(0,qe.jsx)(Lt,{})}),(0,qe.jsx)(le,{}),(0,qe.jsx)(ie,{})]});if(!i&&e)return(0,qe.jsx)(wi,{style:{height:h},children:(0,qe.jsx)("div",{ref:v,children:(0,qe.jsx)(xd,{open:e,onClose:t})})});if(!i)return null;let T=j0[i];return(0,qe.jsx)(wi,{style:{height:h},children:(0,qe.jsxs)("div",{ref:v,children:[(0,qe.jsx)(uo,{if:!!e,children:(0,qe.jsx)(T,{})}),(0,qe.jsx)(uo,{if:!e,children:(0,qe.jsx)(xd,{open:e,onClose:t})})]})})},J0=()=>{let{closePrivyModal:e}=L(),{onUserCloseViaDialogOrKeybindRef:t}=A();return{gracefulClosePrivyModal:(0,Eo.useCallback)(()=>{if(t?.current)t.current();else return e({shouldCallAuthOnSuccess:!1})},[e])}},jg=({open:e})=>{let{app:t}=A(),{gracefulClosePrivyModal:r}=J0(),[o,n]=(0,Eo.useState)(!1);As({onMfaRequired:()=>{t?.mfa.noPromptOnMfaRequired||n(!0)}});let a=(0,qe.jsx)(qg,{children:(0,qe.jsx)(Y0,{isMfaVerifying:o,onMfaVerificationComplete:()=>n(!1)})}),i=e||o,l=t?.render.inDialog?(0,qe.jsx)(by,{open:i,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:a}):a;if(typeof window<"u"&&t?.render.inParentNodeId){let s=document.getElementById(t.render.inParentNodeId);if(s)return $g.default.createPortal(l,s)}return l};var Kg=require("react"),Mi=require("react");var Bl=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:connect":return o;case"privy:wallet:recover":return o;case"privy:wallet:rpc":return o;case"privy:wallet:set-recovery-password":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:submit-cast":return o;case"privy:farcaster:remove-cast":return o;case"privy:farcaster:react-to-cast":return o;case"privy:farcaster:submit-link":return o;case"privy:farcaster:remove-link":return o;default:throw new Error(`invalid wallet event type ${t}`)}}};async function Tn(e,t,r,o,n,a=!1){let i=a,l=async u=>{if(i&&t&&t.length>0){u===(a?0:1)?n("configureMfa","onMfaRequired",t):o.current?.reject(new ke("missing_or_invalid_mfa","MFA verification failed, retry."));let v=await new Promise((h,w)=>{r.current={resolve:h,reject:w};let T=1e3*60*5;setTimeout(()=>{let C=new ke("mfa_timeout","Timed out waiting for MFA code");o.current?.reject(C),w(C)},T)});return await e(v)}return await e()},s=4,d=null;for(let u=0;u<s;u++)try{d=await l(u),o.current?.resolve(void 0);break}catch(v){if(v.type==="missing_or_invalid_mfa")i=!0;else throw o.current?.resolve(void 0),v}if(d===null){let u=new ke("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw o.current?.reject(u),u}return d}var Jg=require("react/jsx-runtime"),Z0=function(e){return()=>`id-${e++}`}(0);function Q0(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function dt(e){return e.error!==void 0}var ot=new Bl,kd=new Map,X0=(e,t)=>typeof t=="bigint"?t.toString():t,e2=(e,t)=>`${e}${JSON.stringify(t,X0)}`;function pt(e,t,r,o){let n=r.contentWindow;if(!n)throw new Error("iframe not initialized");let a=e2(e,t);if(e==="privy:wallet:create"){let l=kd.get(a);if(l)return l}let i=new Promise((l,s)=>{let d=Z0();ot.enqueue(d,{resolve:l,reject:s}),n.postMessage({id:d,event:e,data:t},o)}).finally(()=>{kd.delete(a)});return kd.set(a,i),i}function t2(e){switch(e.event){case"privy:iframe:ready":let t=ot.dequeue(e.event,e.id);return dt(e)?t.reject(new ke(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let r=ot.dequeue(e.event,e.id);return dt(e)?r.reject(new ke(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:connect":let o=ot.dequeue(e.event,e.id);return dt(e)?o.reject(new ke(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:recover":let n=ot.dequeue(e.event,e.id);return dt(e)?n.reject(new ke(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:rpc":let a=ot.dequeue(e.event,e.id);return dt(e)?a.reject(new ke(e.error.type,e.error.message)):a.resolve(e.data);case"privy:wallet:set-recovery-password":let i=ot.dequeue(e.event,e.id);return dt(e)?i.reject(new ke(e.error.type,e.error.message)):i.resolve(e.data);case"privy:mfa:verify":let l=ot.dequeue(e.event,e.id);return dt(e)?l.reject(new ke(e.error.type,e.error.message)):l.resolve(e.data);case"privy:mfa:init-enrollment":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:submit-enrollment":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:unenroll":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:clear":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:init-signer":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:submit-cast":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:remove-cast":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:react-to-cast":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:submit-link":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:remove-link":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}function Yg(e){let t=(0,Mi.useRef)(null),r=(0,Mi.useRef)(e.mfaMethods),o=Gu(),[n,a]=(0,Kg.useState)(!1);return(0,Mi.useEffect)(()=>{r.current=e.mfaMethods},[e.mfaMethods]),(0,Mi.useEffect)(()=>{if(!n)return;let i=t.current;if(!i)return;function l(h){h&&h.origin===e.origin&&Q0(h.data)&&t2(h.data)}let s={create(h){return pt("privy:wallet:create",h,i,e.origin)},connect(h){return pt("privy:wallet:connect",h,i,e.origin)},recover(h){return Tn(w=>pt("privy:wallet:recover",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},rpc(h){return Tn(w=>pt("privy:wallet:rpc",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},setRecoveryPassword(h){return Tn(w=>pt("privy:wallet:set-recovery-password",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},verifyMfa(h){return Tn(w=>pt("privy:mfa:verify",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},initEnrollMfa(h){return Tn(w=>pt("privy:mfa:init-enrollment",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},submitEnrollMfa(h){return pt("privy:mfa:submit-enrollment",h,i,e.origin)},unenrollMfa(h){return Tn(w=>pt("privy:mfa:unenroll",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},clearMfa(h){return pt("privy:mfa:clear",h,i,e.origin)},initFarcasterSigner(h){return pt("privy:farcaster:init-signer",h,i,e.origin)},submitCast(h){return pt("privy:farcaster:submit-cast",h,i,e.origin)},removeCast(h){return pt("privy:farcaster:remove-cast",h,i,e.origin)},reactToCast(h){return pt("privy:farcaster:react-to-cast",h,i,e.origin)},submitLink(h){return pt("privy:farcaster:submit-link",h,i,e.origin)},removeLink(h){return pt("privy:farcaster:remove-link",h,i,e.origin)}};window.addEventListener("message",l);let d=()=>e.onLoad(s),u=(...h)=>{console.warn("Privy iframe failed to load: ",...h),e.onLoadFailed()},v=new AbortController;return Rp(()=>pt("privy:iframe:ready",{},i,e.origin),{abortSignal:v.signal}).then(d,u),()=>{window.removeEventListener("message",l),v.abort()}},[n]),(0,Jg.jsx)("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>a(!0),src:Ha(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId})})}function Hl(e){let t=e.toLowerCase();return["fbav","fban","instagram","snapchat"].some(o=>t.includes(o))}var Gl=class{constructor(t,r){this.meta={action:t,phoneNumber:r}}async init(){if(!this.meta.action)throw new _("action required");if(!this.api)throw new _("Auth flow has no API instance");if(this.meta.action==="enroll"&&!this.meta.phoneNumber)throw new _("phone number must be set when initialzing authentication.");try{await this.api.post(cp,{action:this.meta.action,phoneNumber:this.meta.phoneNumber})}catch(t){throw we(t)}}async authenticate(){if(!this.meta.action)throw new _("action required");if(!this.api)throw new _("Mfa flow has no API instance");if(!this.meta.smsCode)throw new _("sms code must be set prior to calling authenticate.");if(this.meta.action==="enroll"&&!this.meta.phoneNumber)throw new _("phone number must be set prior to calling authenticate.");try{let t=await this.api.post(dp,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return $t(t)}catch(t){throw we(t)}}};var Ht=require("react/jsx-runtime"),Wi;function r2(e){return typeof e=="string"&&e.length===25}function Se(){if(!Wi){let e=Q.get(Zo);return Promise.resolve(e||null)}return Wi.getAccessToken()}var Qg,Yp=(e,t)=>Qg(e,t),Xg,Jp=(e,t)=>Xg(e,t),e1,Zp=(e,t)=>e1(e,t),t1,Qp=()=>t1(),o2=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;Q.put(Oi,t);let r=new URL(window.location.href);r.searchParams.delete("privy_token"),window.history.pushState({},"",r)},r1=({config:e,...t})=>{if(!r2(t.appId))throw new _("Cannot initialize the Privy provider with an invalid Privy app ID");Wi||(Wi=new Vn({appId:t.appId,apiUrl:t.apiUrl||Oa}));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."),(0,Ht.jsx)(Pu,{client:Wi,clientConfig:r,legacyCreateEmbeddedWalletFlag:t.createPrivyWalletOnLogin,children:(0,Ht.jsx)(n2,{...t,config:r,client:Wi})})},n2=e=>{let t=e.client,[r,o]=(0,ee.useState)(!1),[n,a]=(0,ee.useState)(!1),[i,l]=(0,ee.useState)(!1),[s,d]=(0,ee.useState)(null),[u,v]=(0,ee.useState)([]),h=(0,ee.useRef)(u),[w,T]=(0,ee.useState)(!1),[C,S]=(0,ee.useState)(null),[b,x]=(0,ee.useState)(!1),[I,W]=(0,ee.useState)({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:E}),[R,H]=(0,ee.useState)(null),[B,G]=(0,ee.useState)(null),[P,J]=(0,ee.useState)(null),N=gs(),te=vs(),[ue,se]=(0,ee.useState)(!0),[ae,j]=(0,ee.useState)({}),[Ue,Oe]=(0,ee.useState)(null),[no,Gt]=(0,ee.useState)(null),[je,Me]=(0,ee.useState)(!1),[Vt,hr]=(0,ee.useState)(!1),To=(0,ee.useRef)(null),Dr=(0,ee.useRef)(null),O=(0,ee.useRef)(Bu);t.onStoreToken=c=>{c&&D(O,"accessToken","onAccessTokenGranted",c)},t.onDeleteToken=()=>{D(O,"accessToken","onAccessTokenRemoved")};let re=(0,ee.useRef)(null),ne=(0,ee.useRef)(null),Li=(0,ee.useCallback)(c=>{let p=t.connectors?.walletsReady||!1;return i&&s?.linkedAccounts?.some(g=>g.type==="wallet"&&g.walletClientType==="privy")?p&&c?.some(g=>g?.walletClientType==="privy"):p},[i,s?.linkedAccounts,t?.connectors?.walletsReady]),Z=c=>{S(c),setTimeout(()=>{o(!0)},15),t.createAnalyticsEvent("modal_open",{initialScreen:c})},nt=c=>{N.embeddedWallets.createOnLogin!=="off"&&se(!0),Z(c)};(0,ee.useEffect)(()=>{if(!P||!s){t.connectors?.removeEmbeddedWalletConnector();return}let c=s?.linkedAccounts.filter(p=>p.type==="wallet"&&p.walletClientType==="privy");if(c&&c.length>0){let p=c[0].address;t.connectors?.addEmbeddedWalletConnector(P,p,N.defaultChain,e.appId)}},[P,s]),(0,ee.useEffect)(()=>{P&&no?.(P)},[P]),(0,ee.useEffect)(()=>{(async()=>{if(!N.customAuth?.enabled)return;se(!0);let{getCustomAccessToken:p,isLoading:f}=N.customAuth;if(!(!n||f))try{let g=await p();if(!g){await Pn.logout();return}if(i)return;t.startAuthFlow(new Sn(g));let{user:M,isNewUser:F}=await t.authenticate();M||await Pn.logout(),d(M||null),T(F||!1),l(!0),hr(!0)}catch(g){console.warn(g),i&&await Pn.logout()}})()},[N.customAuth?.enabled,N.customAuth?.getCustomAccessToken,N.customAuth?.isLoading,n,i]),(0,ee.useEffect)(()=>{Vt&&P&&s&&or(s,e.config?.embeddedWallets?.createOnLogin)&&(hr(!1),Ur(s,An).catch(console.error))},[Vt&&P&&s]),(0,ee.useEffect)(()=>{async function c(){let p=Mt();o2();let f=(0,Zg.createStore)();H(f),t.initializeConnectorManager({walletConnectCloudProjectId:N.walletConnectCloudProjectId,rpcConfig:N.rpcConfig,chains:N.chains,defaultChain:N.defaultChain,store:f,walletList:N.appearance.walletList,shouldEnforceDefaultChainOnConnect:N.shouldEnforceDefaultChainOnConnect,appName:N.name??"Privy"}),t.connectors?.initialize().then(()=>{zl()});let g=await t.getAuthenticatedUser();e.config?.customAuth?.enabled||(l(!!g),g&&D(O,"login","onComplete",g,!1,!0,null),d(g)),p||pe.setReadyToTrue(),p&&(g?ne.current="link":ne.current="login")}!n&&te&&c()},[t,Ue,n,te]);let Mt=()=>{let c=Ui();return!c.inProgress||c.headless?!1:(t.startAuthFlow(new Hr(c)),nt("AWAITING_OAUTH_SCREEN"),!0)},Ko=async(c,p,f,g)=>{let M=await t.connectors?.createWalletConnector(c,p)||null;yr(M,p,f,g)};async function yr(c,p,f,g){if(c)W({status:"disconnected",connectedWallet:null,connectError:null,connector:c,connectRetry:E});else return W({status:"disconnected",connectedWallet:null,connectError:new oe("Unable to connect to wallet."),connector:null,connectRetry:E}),g?.(null,f);c instanceof zr&&p&&await c.resetConnection(p),W({connector:c,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>yr(c,p,f,g)});try{let M=await c.connect({showPrompt:!0});if(N.shouldEnforceDefaultChainOnConnect&&!N.chains.find(F=>F.id===Number(M?.chainId))&&!(M?.connectorType==="wallet_connect_v2"&&M?.walletClientType==="metamask")){W(F=>({...F,connector:c,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:E}));try{await M?.switchChain(N.defaultChain.id),M&&(M.chainId=kn(rn(N.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${N.defaultChain.id}`)}}return W(F=>({...F,status:"connected",connectedWallet:M,connectError:null,connectRetry:E})),M&&!ne.current&&D(O,"connectWallet","onSuccess",M),g?.(M,f)}catch(M){return M instanceof mt?(console.warn(M.cause?M.cause:M.message),ne.current||D(O,"connectWallet","onError",M.privyErrorCode||"generic_connect_wallet_error")):(console.warn(M),ne.current||D(O,"connectWallet","onError","unknown_connect_wallet_error")),W(F=>({...F,status:"disconnected",connectedWallet:null,connectError:M})),g?.(null,f)}}let Yo=async(c,p)=>{if(c===null)return;let f=new on(c,p);t.startAuthFlow(f)},zl=()=>{let c=new URLSearchParams(window.location.search),p=c.get("privy_connector"),f=c.get("privy_wallet_client");if(!p||!f)return;if(f==="phantom"&&!So()&&nt("LOGIN_FAILED_SCREEN"),!t.connectors)throw new _("Connector not initialized");Z("AWAITING_CONNECTION");let g=new URL(window.location.href);g.searchParams.delete("privy_connector"),g.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",g),Ko(p,f,void 0,Yo)};(0,ee.useEffect)(()=>{n&&i&&s===null&&t.getAuthenticatedUser().then(d)},[n,i,s,t]);let it=()=>{if(!i)throw D(O,"linkAccount","onError","must_be_authenticated"),new _("User must be authenticated before linking an account.")},Jo=()=>{it(),re.current="siwe",ne.current="link",Z("LINK_WALLET_SCREEN")},zt=c=>{if(!i||!s)return!1;if(c.walletClientType==="privy")return!0;for(let p of s.linkedAccounts)if(p.type==="wallet"&&p.address===c.address&&p.walletClientType!=="privy")return!0;return!1},ut=async c=>{if(!t.connectors)throw new _("Connector not initialized");let p=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null;if(W(f=>({...f,connector:p,status:"connected",connectedWallet:c,connectError:null,connectRetry:E})),N.captchaEnabled&&!i){let f={callback:g=>Yo(c,g),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"};j({captchaModalData:f}),nt("CAPTCHA_SCREEN")}else await Yo(c),nt("AWAITING_CONNECTION")},Fr=async(c,p)=>{if(!N.fiatOnRamp.enabled)throw new _("Fiat on-ramp is not enabled");if(!p||!p.provider||p.provider==="moonpay"){let{signedUrl:f,externalTransactionId:g}=await xh(t,c,p?.config??{},N.appearance.palette,N.fiatOnRamp.useSandbox);return{signedUrl:f,externalTransactionId:g}}else throw new _("Unsupported fund provider. Currently supported option is `moonpay`.")},Po=()=>{v(c=>{let p=t.connectors?.wallets.map(f=>({...f,linked:zt(f),loginOrLink:async()=>{if(!await f.isConnected())throw new _("Wallet is not connected");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new _("Cannot link or login with embedded wallet");ut(f)},fund:async g=>{let{signedUrl:M,externalTransactionId:F}=await Fr(f.address,g);j({fiatOnRampPrompt:{signedUrl:M},fiatOnRampStatus:{externalTransactionId:F}}),Z("FIAT_ON_RAMP_PROMPT_SCREEN")},unlink:async()=>{if(!i)throw new _("User is not authenticated.");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new _("Cannot unlink an embedded wallet");let g=await t.unlinkWallet(f.address);d(g)}}))||[];return Me(Li(p)),Ja(c,p)?c:p})};(0,ee.useEffect)(()=>{Po()},[s?.linkedAccounts,i,n]),(0,ee.useEffect)(()=>{if(n){if(!t.connectors)throw new _("Connector not initialized");Po(),t.connectors.on("walletsUpdated",Po)}},[n]);let Pa=()=>{Z(i?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};(0,ee.useEffect)(()=>{if(!u[0])return;let c=u[0],p=h.current.find(g=>g.address===c.address),f;if(c.walletClientType==="privy"?f=s?.linkedAccounts.find(g=>g.type==="wallet"&&g.address===c.address&&g.walletClientType==="privy"):f=s?.linkedAccounts.find(g=>g.type==="wallet"&&g.address===c.address&&g.walletClientType!=="privy"),!p&&f){let g=Object.assign({},s);g.wallet=f&&{address:f.address,chainType:f.chainType,chainId:f.chainId,walletClient:f.walletClient,walletClientType:f.walletClientType,connectorType:f.connectorType},d(g)}h.current=u},[u]);let Ur=async(c,p)=>{if(Ne(c))throw D(O,"createWallet","onError","embedded_wallet_already_exists"),new Error("Only one Privy wallet per user is currently allowed");let[g,M]=await Promise.all([pe.initializeWalletProxy(p),Se()]);if(!g&&e.config?.customAuth?.enabled)throw D(O,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!g||!M||e.config?.embeddedWallets?.requireUserPasswordOnCreate)return new Promise((F,me)=>{se(!0),j({createWallet:{onSuccess:Wt=>{D(O,"createWallet","onSuccess",Wt),F(Wt)},onFailure:Wt=>{D(O,"createWallet","onError","unknown_embedded_wallet_error"),me(Wt)},callAuthOnSuccessOnClose:!1}}),Z("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{await g.create({accessToken:M});let F=await pe.refreshUser(),me=Ne(F);if(!me)throw D(O,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return D(O,"createWallet","onSuccess",me),me}},ql=c=>{if(!N.chains.map(p=>p.id).includes(c))throw new oe(`Chain ID ${c} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},Md=(c,p,f)=>new Promise(async(g,M)=>{if(!i||!s){D(O,"sendTransaction","onError","must_be_authenticated"),M(new Error("User must be authenticated before signing with a Privy wallet"));return}let F=Ne(s);if(!F){D(O,"sendTransaction","onError","embedded_wallet_not_found"),M(new Error("Must have a Privy wallet before signing"));return}se(!0);let me=t.connectors?.findWalletConnector("embedded","privy")?.proxyProvider,bt=c.chainId?Number(c.chainId):me.chainId;ql(bt);let Wt=Object.assign({},c,{chainId:bt}),io=async()=>{let Et=await Se();if(!Et||!P){D(O,"sendTransaction","onError","embedded_wallet_not_found"),M(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await pe.recoverEmbeddedWallet()){D(O,"sendTransaction","onError","unknown_connect_wallet_error"),M(new Error("Unable to connect to wallet"));return}let wr=so(Wt.chainId,N.chains,N.rpcConfig,{appId:e.appId}),$l=await _i(F.address,Wt,wr);if(N.embeddedWallets.noPromptOnSignature){let{totalGasEstimate:M1}=await Si($l,wr),{hasSufficientFunds:W1}=await Ll(F.address,$l,M1,wr);if(!W1)throw new Be(new nr("Wallet has insufficient funds for this transaction.",ft.E32603_DEFAULT_INTERNAL_ERROR.eipCode))}let Od=await Wl(Et,F.address,P,$l,wr);D(O,"sendTransaction","onSuccess",Od),g(Od)}catch(vr){D(O,"sendTransaction","onError","transaction_failure"),M(vr)}};if(N.embeddedWallets.noPromptOnSignature)p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),io();else{let Et={transactionRequest:Wt,onSuccess:wr=>{D(O,"sendTransaction","onSuccess",wr),g(wr)},onFailure:wr=>{D(O,"sendTransaction","onError","transaction_failure"),M(wr)},uiOptions:p||{},fundWalletConfig:f},vr={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:wr=>{D(O,"sendTransaction","onError","unknown_connect_wallet_error"),M(wr)}};j({connectWallet:vr,sendTransaction:Et}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")}});function Wd(){return new Promise(async(c,p)=>{let f=await Se();if(!f||!P)throw new Error("Must have valid access token to enroll in MFA");try{await P.verifyMfa({accessToken:f}),c()}catch(g){p(g)}})}let gr=c=>{if(s?.[c])throw D(O,"linkAccount","onError","cannot_link_more_of_type"),new _(`User already has an account of type ${c} linked.`)},Pn={ready:n,authenticated:i,user:s,walletConnectors:t.connectors||null,connectWallet:Pa,linkWallet:Jo,linkEmail:()=>{it(),gr("email"),re.current="email",ne.current="link",Z("LINK_EMAIL_SCREEN")},linkPhone:()=>{it(),gr("phone"),re.current="sms",ne.current="link",Z("LINK_PHONE_SCREEN")},linkGoogle:async()=>{it(),gr("google"),ne.current="link",await pe.initLoginWithOAuth("google")},linkTwitter:async()=>{it(),gr("twitter"),ne.current="link",await pe.initLoginWithOAuth("twitter")},linkDiscord:async()=>{it(),gr("discord"),ne.current="link",await pe.initLoginWithOAuth("discord")},linkGithub:async()=>{it(),gr("github"),ne.current="link",await pe.initLoginWithOAuth("github")},linkSpotify:async()=>{it(),gr("spotify"),ne.current="link",await pe.initLoginWithOAuth("spotify")},linkTiktok:async()=>{it(),gr("tiktok"),ne.current="link",await pe.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{it(),gr("linkedin"),ne.current="link",await pe.initLoginWithOAuth("linkedin")},linkApple:async()=>{it(),gr("apple"),ne.current="link",await pe.initLoginWithOAuth("apple")},linkFarcaster:async()=>{it(),gr("farcaster"),await pe.initLoginWithFarcaster(),ne.current="link",re.current="farcaster",Z("AWAITING_FARCASTER_CONNECTION")},updateEmail:()=>{if(it(),!s?.email)throw new _("User does not have an email linked to their account.");ne.current="link",re.current="email",Z("UPDATE_EMAIL_SCREEN")},login:async()=>{if(n||(await new Promise(c=>{Oe(()=>c)}),Oe(null)),i){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}ne.current="login",nt("LANDING")},connectOrCreateWallet:async()=>{if(n||(await new Promise(c=>{Oe(()=>c)}),Oe(null)),i){console.warn("User must be unauthenticated to `connectOrCreateWallet`");return}if(u[0]){console.warn("User must have no connected wallets to `connectOrCreateWallet`");return}nt("CONNECT_OR_CREATE")},logout:async()=>{await t.logout(),s&&P&&await P.clearMfa({userId:s.id}),d(null),l(!1),S(null),D(O,"logout","onSuccess"),ne.current=null,re.current=null,o(!1),Q.del(Ni)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{if(!s||!s.wallet)return new Le;let c=u.find(f=>s.wallet&&f.address===s.wallet.address),p=t.connectors?.walletConnectors.find(f=>f.wallets.find(g=>g.address===c?.address));return!c||!p?new Le:p.proxyProvider},getEthersProvider:()=>{if(!s||!s.wallet)return new Vl.Web3Provider(new br(new Le));let c=u.find(f=>s.wallet&&f.address===s.wallet.address),p=t.connectors?.walletConnectors.find(f=>f.wallets.find(g=>g.address===c?.address));return!c||!p?new Vl.Web3Provider(new br(new Le)):new Vl.Web3Provider(new br(p.proxyProvider))},getWeb3jsProvider:()=>{if(!s||!s.wallet)return new ko(new Le);let c=u.find(f=>s.wallet&&f.address===s.wallet.address),p=t.connectors?.walletConnectors.find(f=>f.wallets.find(g=>g.address===c?.address));return!c||!p?new ko(new Le):new ko(p.proxyProvider)},unlinkWallet:async c=>{let p=await t.unlinkWallet(c);return d(p),p},unlinkEmail:async c=>{let p=await t.unlinkEmail(c);return d(p),p},unlinkPhone:async c=>{let p=await t.unlinkPhone(c);return d(p),p},unlinkGoogle:async c=>{let p=await t.unlinkOAuth("google",c);return d(p),p},unlinkTwitter:async c=>{let p=await t.unlinkOAuth("twitter",c);return d(p),p},unlinkDiscord:async c=>{let p=await t.unlinkOAuth("discord",c);return d(p),p},unlinkGithub:async c=>{let p=await t.unlinkOAuth("github",c);return d(p),p},unlinkSpotify:async c=>{let p=await t.unlinkOAuth("spotify",c);return d(p),p},unlinkTiktok:async c=>{let p=await t.unlinkOAuth("tiktok",c);return d(p),p},unlinkLinkedIn:async c=>{let p=await t.unlinkOAuth("linkedin",c);return d(p),p},unlinkApple:async c=>{let p=await t.unlinkOAuth("apple",c);return d(p),p},unlinkFarcaster:async c=>{let p=await t.unlinkFarcaster(c);return d(p),p},setActiveWallet:async c=>{let p=u.find(g=>(0,Ea.getAddress)(g.address)===(0,Ea.getAddress)(c)),f=s?.linkedAccounts.find(g=>g.type==="wallet"&&(0,Ea.getAddress)(g.address)===(0,Ea.getAddress)(c));if(!p||!await p.isConnected())G(c),Jo();else if(!p.linked)p.loginOrLink();else{let g=Object.assign({},s);g.wallet=f&&{address:f.address,chainType:f.chainType,chainId:f.chainId,walletClient:f.walletClient,walletClientType:f.walletClientType,connectorType:f.connectorType},d(g)}},forkSession:()=>t.forkSession(),createWallet:async()=>{if(!i||!s)throw D(O,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return Ur(s,15e3)},setWalletPassword:async()=>{if(!i||!s)throw D(O,"setWalletPassword","onError","must_be_authenticated"),new Error("User must be authenticated before adding password to Privy wallet");let c=Ne(s);if(!c||!P)throw D(O,"setWalletPassword","onError","embedded_wallet_not_found"),new Error("Must have a Privy wallet to add a password");if(c.recoveryMethod==="user-passcode")throw D(O,"setWalletPassword","onError","embedded_wallet_password_already_exists"),new Error("Cannot set password. Embedded wallet already has a password.");try{await Wd()}catch(p){throw D(O,"setWalletPassword","onError","missing_mfa_credentials"),p}return new Promise((p,f)=>{se(!0);let g={onSuccess:F=>{D(O,"setWalletPassword","onSuccess",F),p(F)},onFailure:F=>{D(O,"setWalletPassword","onError","user_exited_set_password_flow"),f(F)},callAuthOnSuccessOnClose:!1},M={onCompleteNavigateTo:"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",onFailure:F=>{D(O,"setWalletPassword","onError","unknown_connect_wallet_error"),f(F)}};j({setWalletPassword:g,connectWallet:M}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")})},signMessage:(c,p)=>new Promise(async(f,g)=>{if(!i||!s){D(O,"signMessage","onError","must_be_authenticated"),g(new Error("User must be authenticated before signing with a Privy wallet"));return}let M=Ne(s);if(!M){D(O,"signMessage","onError","embedded_wallet_not_found"),g(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){D(O,"signMessage","onError","invalid_message"),g(new Error("Message must be a non-empty string"));return}se(!0);let F=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let me=await Se();if(!P||!me)throw new Error("Unable to connect to wallet");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:M.address});let{response:Wt}=await P.rpc({accessToken:me,address:M.address,request:{method:"personal_sign",params:[c,M.address]}}),io=Wt.data;return t.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:M.address}),io};if(N.embeddedWallets.noPromptOnSignature){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let me=await F();D(O,"signMessage","onSuccess",me),f(me)}catch(me){D(O,"signMessage","onError","unable_to_sign"),g(me??new Be("Unable to sign message"))}}else{let Wt={method:"personal_sign",data:c,confirmAndSign:F,onSuccess:Et=>{D(O,"signMessage","onSuccess",Et),f(Et)},onFailure:Et=>{D(O,"signMessage","onError","unable_to_sign"),g(Et)},uiOptions:p||{}},io={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Et=>{D(O,"signMessage","onError","unknown_connect_wallet_error"),g(Et)}};j({signMessage:Wt,connectWallet:io}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),signTypedData:(c,p)=>new Promise(async(f,g)=>{if(!i||!s){D(O,"signTypedData","onError","must_be_authenticated"),g(new Error("User must be authenticated before signing with a Privy wallet"));return}let M=Ne(s);if(!M){D(O,"signTypedData","onError","embedded_wallet_not_found"),g(new Error("Must have a Privy wallet before signing"));return}se(!0);let F=Va(c),me=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let bt=await Se();if(!P||!bt)throw new Error("Unable to connect to wallet");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent("embedded_wallet_sign_typed_data_started",{walletAddress:M.address});let{response:io}=await P.rpc({accessToken:bt,address:M.address,request:{method:"eth_signTypedData_v4",params:[M.address,F]}}),Et=io.data;return t.createAnalyticsEvent("embedded_wallet_sign_typed_data_completed",{walletAddress:M.address}),Et};if(N.embeddedWallets.noPromptOnSignature||(N.legacyWalletUiConfig??!1)){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let bt=await me();D(O,"signTypedData","onSuccess",bt),f(bt)}catch(bt){D(O,"signTypedData","onError","unable_to_sign"),g(bt??new Be("Unable to sign message"))}}else{let io={method:"eth_signTypedData_v4",data:F,confirmAndSign:me,onSuccess:vr=>{D(O,"signTypedData","onSuccess",vr),f(vr)},onFailure:vr=>{D(O,"signTypedData","onError","unable_to_sign"),g(vr)},uiOptions:p||{}},Et={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:vr=>{D(O,"signMessage","onError","unknown_connect_wallet_error"),g(vr)}};j({signMessage:io,connectWallet:Et}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:async(c,p,f)=>{let M=await(await Md(c,p,f)).wait();return Ol(M)},exportWallet:()=>new Promise(async(c,p)=>{if(!i||!s){p(new Error("User must be authenticated before exporting their Privy wallet"));return}let f=Ne(s);if(!f){p(new Error("Must have a Privy wallet before exporting"));return}se(!0);let g={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:p},M=await Se();if(!M||!P){p(new Error("Must have valid access token to enroll in MFA"));return}if(!P){p(new Error("Must have a Privy wallet before exporting"));return}try{try{await P.connect({accessToken:M,address:f.address}),await P.verifyMfa({accessToken:M})}catch(me){if(ln(me))await pe.recoverEmbeddedWallet();else throw me}}catch(me){p(me);return}let F={appId:e.appId,origin:t.apiUrl,onSuccess:c,onFailure:p};j({keyExport:F,connectWallet:g}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")}),promptMfa:Wd,async init(c){let p;switch(c){case"sms":p=new Gl("verify");break;case"totp":return;default:throw new Error(`Unsupported MFA method: ${c}`)}t.startMfaFlow(p),await p.init()},async submit(c,p){switch(c){case"totp":case"sms":To.current?.resolve({mfaMethod:c,mfaCode:p}),await new Promise((f,g)=>{Dr.current={resolve:f,reject:g}});break;default:throw To.current?.reject(new _("Unsupported MFA method")),new _(`Unsupported MFA method: ${c}`)}},cancel(){To.current?.reject(new _("MFA canceled"))},async initEnrollmentWithSms(c){let p=await Se();if(!p||!P)throw new Error("Must have valid access token to enroll in MFA");await P.initEnrollMfa({method:"sms",accessToken:p,phoneNumber:c.phoneNumber})},enrollInMfa(c){return new Promise((p,f)=>{if(!c){pe.closePrivyModal(),p();return}N.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."),j({mfaEnrollmentFlow:{mfaMethods:N.mfa.methods,onSuccess:p,onFailure:f}}),Z("MFA_ENROLLMENT_FLOW_SCREEN")})},async initEnrollmentWithTotp(){let c=await Se();if(!c||!P)throw new Error("Must have valid access token to enroll in MFA");let p=await P.initEnrollMfa({method:"totp",accessToken:c});return{secret:p.secret,authUrl:p.authUrl}},async submitEnrollmentWithSms(c){let p=await Se();if(!p||!P)throw new Error("Must have valid access token to enroll in MFA");await P.submitEnrollMfa({method:"sms",accessToken:p,phoneNumber:c.phoneNumber,code:c.mfaCode});let f=await t.getAuthenticatedUser();d(f)},async submitEnrollmentWithTotp(c){let p=await Se();if(!p||!P)throw new Error("Must have valid access token to enroll in MFA");await P.submitEnrollMfa({method:"totp",accessToken:p,code:c.mfaCode});let f=await t.getAuthenticatedUser();d(f)},async unenroll(c){let p=await Se();if(!p||!P)throw new Error("Must have valid access token to remove MFA");await P.unenrollMfa({method:c,accessToken:p});let f=await t.getAuthenticatedUser();d(f)},requestFarcasterSigner:async()=>{let c=await Se(),p=s?.linkedAccounts.find(M=>M.type==="wallet"&&M.walletClientType==="privy");if(!c)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!p)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");let g=await P.initFarcasterSigner({address:p.address,hdWalletIndex:null,accessToken:c,mfaCode:null,mfaMethod:null});if(g.status==="approved"){let M=await t.getAuthenticatedUser();d(M||s||null)}j({farcasterSigner:g}),Z("AWAITING_FARCASTER_SIGNER")},submitCast:async c=>{let p=await Se(),f=s?.linkedAccounts.find(F=>F.type==="wallet"&&F.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.submitCast({address:f.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:c,fid:BigInt(s.farcaster.fid)})).response.hash}},removeCast:async({castHash:c})=>{let p=await Se(),f=s?.linkedAccounts.find(F=>F.type==="wallet"&&F.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.removeCast({address:f.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:c,fid:BigInt(s.farcaster.fid)})).response.hash}},likeCast:async({castHash:c,castAuthorFid:p})=>{let f=await Se(),g=s?.linkedAccounts.find(me=>me.type==="wallet"&&me.walletClientType==="privy");if(!f)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!g)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.reactToCast({address:g.address,hdWalletIndex:null,accessToken:f,mfaCode:null,mfaMethod:null,payload:{type:1,castId:{hash:c,fid:p}},fid:BigInt(s.farcaster.fid)})).response.hash}},recastCast:async({castHash:c,castAuthorFid:p})=>{let f=await Se(),g=s?.linkedAccounts.find(me=>me.type==="wallet"&&me.walletClientType==="privy");if(!f)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!g)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.reactToCast({address:g.address,hdWalletIndex:null,accessToken:f,mfaCode:null,mfaMethod:null,payload:{type:2,castId:{hash:c,fid:p}},fid:BigInt(s.farcaster.fid)})).response.hash}},followUser:async({fid:c})=>{let p=await Se(),f=s?.linkedAccounts.find(F=>F.type==="wallet"&&F.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.submitLink({address:f.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{type:"follow",targetFid:c},fid:BigInt(s.farcaster.fid)})).response.hash}},unfollowUser:async({fid:c})=>{let p=await Se(),f=s?.linkedAccounts.find(F=>F.type==="wallet"&&F.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.removeLink({address:f.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{type:"follow",targetFid:c},fid:BigInt(s.farcaster.fid)})).response.hash}},isHeadlessOAuthLoading:b,loginWithCode(c){return pe.loginWithCode(c)},initLoginWithEmail(c){return pe.initLoginWithEmail(c)},initLoginWithSms(c){return pe.initLoginWithSms(c)},fundWallet(c,p){return pe.fundWallet(c,p)},initLoginWithHeadlessOAuth(c,p){return pe.initLoginWithHeadlessOAuth(c,p)},loginWithHeadlessOAuth(c){return pe.loginWithHeadlessOAuth(c)},isModalOpen:r};Qg=Pn.signMessage,Xg=Pn.signTypedData,e1=async(...c)=>{let p=await Md(...c);return N.embeddedWallets.waitForTransactionConfirmation&&await p.wait(),p};let Ld=!!e.config?.headless,pe=(()=>({headless:Ld,isNewUserThisSession:w,linkingHint:B,pendingTransaction:null,walletConnectionStatus:I,mipdStore:R,connectors:t.connectors?.walletConnectors??[],rpcConfig:N.rpcConfig,chains:N.chains,appId:e.appId,showFiatPrices:N.embeddedWallets.priceDisplay.primary!=="native-token",clientAnalyticsId:t.clientAnalyticsId,nativeTokenSymbolForChainId:c=>N.chains.find(p=>p.id===Number(c))?.nativeCurrency.symbol,initializeWalletProxy:async c=>{if(P)return P;let p=new Promise(M=>{Gt(()=>F=>M(F))}),f=new Promise(M=>setTimeout(()=>M(null),c)),g=await Promise.race([p,f]);return Gt(null),g},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>t.authFlow?.meta,closePrivyModal:(c={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let p=n&&i&&s;ne.current==="login"?c.shouldCallAuthOnSuccess&&p?(D(O,"login","onComplete",s,w,!1,re.current??null),e.onSuccess?.(s,w)):D(O,"login","onError","exited_auth_flow"):ne.current==="link"&&re.current&&(c.isSuccess&&p?D(O,"linkAccount","onSuccess",s,re.current):D(O,"linkAccount","onError","exited_link_flow")),G(null),ne.current=null,re.current=null,T(!1),o(!1),setTimeout(()=>{t.authFlow=void 0},200),t.createAnalyticsEvent("modal_closed")},openPrivyModal:Z,connectWallet:yr,initLoginWithWallet:async(c,p)=>{re.current="siwe",Yo(c,p)},loginWithWallet:async()=>{if(!n)throw new xn;if(!(t.authFlow instanceof on))throw new _("Must initialize SIWE flow first.");let c,p;if(i)try{c=await t.link(),re.current="siwe"}catch(f){throw D(O,"linkAccount","onError",f.privyErrorCode||"failed_to_link_account"),f}else try{({user:c,isNewUser:p}=await t.authenticate()),re.current="siwe"}catch(f){throw D(O,"login","onError",f.privyErrorCode||"generic_connect_wallet_error"),f}d(c||s||null),T(p||!1),l(!0)},initLoginWithFarcaster:async c=>{let p=new Di(c);t.startAuthFlow(p);try{re.current="farcaster",await p.initializeFarcasterConnect()}catch(f){throw ne.current==="login"?D(O,"login","onError",f.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",f.privyErrorCode||"unknown_auth_error"),f}},loginWithFarcaster:async()=>{if(!n)throw new xn;if(!(t.authFlow instanceof Di))throw new _("Must initialize Farcaster flow first.");let c,p;if(i)try{c=await t.link(),re.current="farcaster"}catch(f){throw D(O,"linkAccount","onError",f.privyErrorCode||"failed_to_link_account"),f}else try{({user:c,isNewUser:p}=await t.authenticate()),re.current="farcaster"}catch(f){throw D(O,"login","onError",f.privyErrorCode||"unknown_auth_error"),f}d(c||null),T(p||!1),l(!0)},async initLoginWithOAuth(c,p){if(re.current=c,Jl()){if(c==="google"&&Hl(window.navigator.userAgent)){nt("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}}else{nt("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}Q.del(Xo);let f=new Hr({provider:c});p&&f.addCaptchaToken(p),t.startAuthFlow(f);let g=await t.authFlow.getAuthorizationUrl();g&&g.url&&window.location.assign(g.url)},async loginWithOAuth(c){if(!(t.authFlow instanceof Hr))throw new _("Must initialize OAuth flow before calling loginWithOAuth");let p=Q.get(Qo),f=t.authFlow.meta.stateCode;if(p!==f)throw t.createAnalyticsEvent("possible_phishing_attempt",{provider:c,storedStateCode:p??"",returnedStateCode:f??""}),new _("Unexpected auth flow. This may be a phishing attempt.");let g,M;if(i)try{g=await t.link(),re.current=c}catch(F){throw D(O,"linkAccount","onError",F.privyErrorCode||"failed_to_link_account"),F}else try{({user:g,isNewUser:M}=await t.authenticate()),re.current=c}catch(F){throw ne.current==="login"?D(O,"login","onError",F.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",F.privyErrorCode||"failed_to_link_account"),F}d(g),T(M||!1),l(!0)},async initLoginWithHeadlessOAuth(c,p){if(Jl()){if(c==="google"&&Hl(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 Hr({provider:c,headless:!0});p&&f.addCaptchaToken(p);let g=await t.startAuthFlow(f).getAuthorizationUrl();g?.url&&window.location.assign(g.url)},async loginWithHeadlessOAuth(c){x(!0),t.startAuthFlow(new Hr(c));let p=Q.get(Qo),f=c.stateCode;if(p!==f)throw t.createAnalyticsEvent("possible_phishing_attempt",{provider:c.provider,storedStateCode:p??"",returnedStateCode:f??""}),x(!1),new _("Unexpected auth flow. This may be a phishing attempt.");let g,M;if(i)try{g=await t.link(),re.current=c.provider}catch(F){throw D(O,"linkAccount","onError",F.privyErrorCode||"failed_to_link_account"),F}else try{({user:g,isNewUser:M}=await t.authenticate()),re.current=c.provider}catch(F){throw ne.current==="login"?D(O,"login","onError",F.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",F.privyErrorCode||"failed_to_link_account"),F}return d(g),T(M||!1),l(!0),x(!1),g??void 0},initLoginWithEmail:async(c,p)=>{let f=new xo(c,p);t.startAuthFlow(f);try{re.current="email",await f.sendCodeEmail()}catch(g){throw ne.current==="login"?D(O,"login","onError",g.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",g.privyErrorCode||"failed_to_link_account"),g}},initUpdateEmail:async(c,p,f)=>{let g=new Ma(c,p,f);t.startAuthFlow(g),await g.sendCodeEmail()},initLoginWithSms:async(c,p)=>{let f=new nn(c,p);t.startAuthFlow(f);try{re.current="sms",await f.sendSmsCode()}catch(g){throw ne.current==="login"?D(O,"login","onError",g.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",g.privyErrorCode||"failed_to_link_account"),g}},resendEmailCode:async()=>{await t.authFlow?.sendCodeEmail()},resendSmsCode:async()=>{await t.authFlow?.sendSmsCode()},loginWithCode:async c=>{if(!n)throw new xn;if(t.authFlow instanceof xo)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof nn)t.authFlow.meta.smsCode=c.trim();else throw new _("Must initialize a passwordless code flow first");let p,f;if(i)try{p=await t.link()}catch(g){throw D(O,"linkAccount","onError",g.privyErrorCode||"failed_to_link_account"),g}else try{({user:p,isNewUser:f}=await t.authenticate())}catch(g){throw D(O,"login","onError",g.privyErrorCode||"unknown_auth_error"),g}d(p||s||null),T(f||!1),l(!0)},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return d(c),c},walletProxy:P,createAnalyticsEvent:(c,p,f)=>t.createAnalyticsEvent(c,p,f),acceptTerms:async()=>{let c=await t.acceptTerms();return d(c),c},getUsdTokenPrice:c=>t.getUsdTokenPrice(c),recoverEmbeddedWallet:async()=>new Promise(async(c,p)=>{let f=s?.linkedAccounts.find(M=>M.type==="wallet"&&M.walletClientType==="privy"),g=await Se();if(!g||!P||!f){p(new Error("Must have valid access token and Privy wallet to recover wallet"));return}se(!0);try{await P.connect({accessToken:g,address:f.address}),c(!0)}catch(M){ln(M)&&f.recoveryMethod==="privy"?(t.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:f.address}),(await P.recover({address:f.address,accessToken:g})).address||p(new Error("Unable to recover wallet")),t.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:f.address}),c(!0)):ln(M)?(j({recoverWallet:{privyWallet:f,onFailure:p,onSuccess:()=>c(!0)}}),Z("EMBEDDED_WALLET_RECOVERY_SCREEN")):p(M)}}),getFiatOnRampConfig:Fr,setReadyToTrue:()=>{a(!0),Ue?.()},updateWallets:()=>Po(),fundWallet:async(c,p)=>{let{signedUrl:f,externalTransactionId:g}=await Fr(c,p);j({fiatOnRampPrompt:{signedUrl:f},fiatOnRampStatus:{externalTransactionId:g}}),Z("FIAT_ON_RAMP_PROMPT_SCREEN")},requestFarcasterSignerStatus:async c=>{let p=await Se(),f=s?.linkedAccounts.find(M=>M.type==="wallet"&&M.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");let g=await t.requestFarcasterSignerStatus(c);if(g.status==="approved"){let M=await t.getAuthenticatedUser();d(M||s||null)}return g}}))();t1=pe.recoverEmbeddedWallet;let I1=(0,ee.useMemo)(()=>({wallets:u,ready:je}),[u,je]);return(0,Ht.jsx)(ye.Provider,{value:Pn,children:(0,Ht.jsx)(wc.Provider,{value:O,children:(0,Ht.jsx)(Ed.Provider,{value:I1,children:(0,Ht.jsxs)(Nu,{...N,children:[e.children,(0,Ht.jsxs)(vc.Provider,{value:pe,children:[!Ld&&N.captchaEnabled&&n&&!i&&(0,Ht.jsx)(Ps,{delayedExecution:!1}),(0,Ht.jsx)(zg,{theme:{...N.appearance.palette||{}}}),(0,Ht.jsx)(_u,{data:ae,setModalData:j,setInitialScreen:S,initialScreen:C,authenticated:i,open:r,children:(0,Ht.jsx)(jg,{open:r})}),ue&&te?(0,Ht.jsx)(Yg,{appId:e.appId,clientAnalyticsId:t.clientAnalyticsId,origin:t.apiUrl,mfaMethods:s?.mfaMethods,mfaPromise:To,mfaSubmitPromise:Dr,onLoad:J,onLoadFailed:()=>null}):null]})]})})})})};var o1=require("react");function n1(e){let{login:t}=(0,o1.useContext)(ye);return De("login",e),{login:t}}var i1=require("react");function a1(e){let{logout:t}=(0,i1.useContext)(ye);return De("logout",e),{logout:t}}var Ta=require("react");function s1(){let e=_e(),t=vs(),{initLoginWithHeadlessOAuth:r,loginWithHeadlessOAuth:o,isHeadlessOAuthLoading:n,ready:a,user:i}=V(),l=(0,Ta.useCallback)(async d=>{if(e.enabled&&e.status!=="success")throw new Tr(e.error,null,"captcha_failure");return r(d.provider,e.token)},[r,e]),s=(0,Ta.useCallback)(async()=>{let d=Ui();if(i)return console.warn("Cannot login with OAuth when already logged in"),i;if(!d.inProgress)throw new Error("Cannot login with OAuth because no OAuth flow is in progress");try{return await o(d)}catch(u){throw u}finally{Bi()}},[o]);return(0,Ta.useEffect)(()=>{let d=Ui();a&&t&&d.inProgress&&d.headless&&s()},[a,t]),{initOAuth:l,loginWithOAuth:s,loading:n}}var Rd=require("react");var l1=()=>{let e=_e(),{initLoginWithEmail:t,loginWithCode:r}=V(),o=(0,Rd.useCallback)(async({email:a})=>{if(!a)throw new Error("Email required to send OTP code");return t(a)},[t]),n=(0,Rd.useCallback)(async({code:a})=>{if(e.enabled&&e.status==="error")throw new Tr(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};var Id=require("react");var c1=()=>{let e=_e(),{initLoginWithSms:t,loginWithCode:r}=V(),o=(0,Id.useCallback)(async({phoneNumber:a})=>{if(!a)throw new Error("SMS required to send OTP code");return t(a)},[t]),n=(0,Id.useCallback)(async({code:a})=>{if(e.enabled&&e.status!=="success")throw new Tr(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};var d1=require("react");function p1(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:l,linkGithub:s,linkLinkedIn:d,linkTiktok:u,linkSpotify:v,linkFarcaster:h}=(0,d1.useContext)(ye);return De("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:l,linkGithub:s,linkLinkedIn:d,linkTiktok:u,linkSpotify:v,linkFarcaster:h}}var u1=require("react");function m1(e){let{connectWallet:t}=(0,u1.useContext)(ye);return De("connectWallet",e),{connectWallet:t}}var f1=require("react");function h1(e){let{createWallet:t}=(0,f1.useContext)(ye);return De("createWallet",e),{createWallet:t}}var y1=()=>{let{fundWallet:e}=V();return{fundWallet:e}};var g1=require("react");function v1(e){let{sendTransaction:t}=(0,g1.useContext)(ye);return De("sendTransaction",e),{sendTransaction:t}}var w1=require("react");function C1(e){let{setWalletPassword:t}=(0,w1.useContext)(ye);return De("setWalletPassword",e),{setWalletPassword:t}}var b1=require("react");function E1(e){let{signMessage:t}=(0,b1.useContext)(ye);return De("signMessage",e),{signMessage:t}}var T1=require("react");function P1(e){let{signTypedData:t}=(0,T1.useContext)(ye);return De("signTypedData",e),{signTypedData:t}}var x1=require("react");var S1=()=>{let{isModalOpen:e}=(0,x1.useContext)(ye);return{isOpen:e}};var _1=require("react");function A1(e){let{getAccessToken:t}=(0,_1.useContext)(ye);return De("accessToken",e),{getAccessToken:t}}function k1(){let{submitCast:e,removeCast:t,likeCast:r,recastCast:o,followUser:n,unfollowUser:a,requestFarcasterSigner:i}=V();return{followUser:n,unfollowUser:a,submitCast:e,removeCast:t,likeCast:r,recastCast:o,requestFarcasterSigner:i}}function R1(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}0&&(module.exports={AsExternalProvider,Captcha,ConnectorManager,PrivyClient,PrivyProvider,PrivyProxyProvider,SUPPORTED_CHAINS,VERSION,WalletConnector,addRpcUrlOverrideToChain,errorIndicatesMaxMfaRetries,errorIndicatesMfaTimeout,errorIndicatesMfaVerificationFailed,getAccessToken,useConnectWallet,useCreateWallet,useExperimentalFarcasterSigner,useFundWallet,useLinkAccount,useLogin,useLoginWithEmail,useLoginWithOAuth,useLoginWithSms,useLogout,useMfa,useMfaEnrollment,useModalStatus,usePrivy,useRegisterMfaListener,useSendTransaction,useSetWalletPassword,useSignMessage,useSignTypedData,useToken,useWallets});
|
|
2752
|
+
`;var qe=require("react/jsx-runtime"),j0={["LANDING"]:my,["CONNECT_OR_CREATE"]:uy,["AWAITING_PASSWORDLESS_CODE"]:um,["AWAITING_CONNECTION"]:Fm,["AWAITING_CONNECT_ONLY_CONNECTION"]:Hm,["AWAITING_FARCASTER_CONNECTION"]:mh,["AWAITING_FARCASTER_SIGNER"]:vh,["PHANTOM_INTERSTITIAL_SCREEN"]:kg,["LOGIN_FAILED_SCREEN"]:Cy,["AWAITING_OAUTH_SCREEN"]:xg,["ALLOWLIST_REJECTION_SCREEN"]:tm,["INSTALL_PHANTOM_SCREEN"]:Bh,["LINK_EMAIL_SCREEN"]:hy,["LINK_PHONE_SCREEN"]:gy,["LINK_WALLET_SCREEN"]:vy,["UPDATE_EMAIL_SCREEN"]:Gg,["CONNECT_ONLY_LANDING_SCREEN"]:Om,["CONNECT_ONLY_AUTHENTICATED_SCREEN"]:km,["EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN"]:Hf,["EMBEDDED_WALLET_CREATED_SCREEN"]:Jm,["EMBEDDED_WALLET_CONNECTING_SCREEN"]:jm,["EMBEDDED_WALLET_RECOVERY_SCREEN"]:Kf,["EMBEDDED_WALLET_KEY_EXPORT_SCREEN"]:tf,["EMBEDDED_WALLET_SIGN_REQUEST_SCREEN"]:Dg,["EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN"]:Lg,["FIAT_ON_RAMP_PROMPT_SCREEN"]:_h,["FIAT_ON_RAMP_STATUS_SCREEN"]:Mh,["EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN"]:$f,["EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN"]:Gf,["MFA_ENROLLMENT_FLOW_SCREEN"]:Dy,["CAPTCHA_SCREEN"]:Cm,["ERROR_SCREEN"]:Zf,["IN_APP_BROWSER_LOGIN_NOT_POSSIBLE"]:Oh,["AFFIRMATIVE_CONSENT_SCREEN"]:Xu},K0=["LANDING","AWAITING_CONNECTION"],Y0=({isMfaVerifying:e,onMfaVerificationComplete:t})=>{let{ready:r,isModalOpen:o}=V(),{headless:n}=L(),{ready:a,currentScreen:i}=A(),{status:l,execute:s,reset:d,enabled:u}=_e(),v=(0,Eo.useRef)(null),h=Uu(v),w=o&&i&&K0.includes(i)&&!n&&l==="ready";if((0,Eo.useEffect)(()=>{w&&s()},[w]),(0,Eo.useEffect)(()=>{!o&&u&&d()},[o,u]),(!r||!a)&&i!=="AWAITING_OAUTH_SCREEN")return(0,qe.jsxs)(wi,{children:[(0,qe.jsx)(k,{}),(0,qe.jsx)(X,{}),(0,qe.jsx)(Ey,{children:(0,qe.jsx)(Lt,{})}),(0,qe.jsx)(le,{}),(0,qe.jsx)(ie,{})]});if(!i&&e)return(0,qe.jsx)(wi,{style:{height:h},children:(0,qe.jsx)("div",{ref:v,children:(0,qe.jsx)(xd,{open:e,onClose:t})})});if(!i)return null;let T=j0[i];return(0,qe.jsx)(wi,{style:{height:h},children:(0,qe.jsxs)("div",{ref:v,children:[(0,qe.jsx)(uo,{if:!!e,children:(0,qe.jsx)(T,{})}),(0,qe.jsx)(uo,{if:!e,children:(0,qe.jsx)(xd,{open:e,onClose:t})})]})})},J0=()=>{let{closePrivyModal:e}=L(),{onUserCloseViaDialogOrKeybindRef:t}=A();return{gracefulClosePrivyModal:(0,Eo.useCallback)(()=>{if(t?.current)t.current();else return e({shouldCallAuthOnSuccess:!1})},[e])}},jg=({open:e})=>{let{app:t}=A(),{gracefulClosePrivyModal:r}=J0(),[o,n]=(0,Eo.useState)(!1);As({onMfaRequired:()=>{t?.mfa.noPromptOnMfaRequired||n(!0)}});let a=(0,qe.jsx)(qg,{children:(0,qe.jsx)(Y0,{isMfaVerifying:o,onMfaVerificationComplete:()=>n(!1)})}),i=e||o,l=t?.render.inDialog?(0,qe.jsx)(by,{open:i,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:a}):a;if(typeof window<"u"&&t?.render.inParentNodeId){let s=document.getElementById(t.render.inParentNodeId);if(s)return $g.default.createPortal(l,s)}return l};var Kg=require("react"),Mi=require("react");var Bl=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:connect":return o;case"privy:wallet:recover":return o;case"privy:wallet:rpc":return o;case"privy:wallet:set-recovery-password":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:submit-cast":return o;case"privy:farcaster:remove-cast":return o;case"privy:farcaster:react-to-cast":return o;case"privy:farcaster:submit-link":return o;case"privy:farcaster:remove-link":return o;default:throw new Error(`invalid wallet event type ${t}`)}}};async function Tn(e,t,r,o,n,a=!1){let i=a,l=async u=>{if(i&&t&&t.length>0){u===(a?0:1)?n("configureMfa","onMfaRequired",t):o.current?.reject(new ke("missing_or_invalid_mfa","MFA verification failed, retry."));let v=await new Promise((h,w)=>{r.current={resolve:h,reject:w};let T=1e3*60*5;setTimeout(()=>{let C=new ke("mfa_timeout","Timed out waiting for MFA code");o.current?.reject(C),w(C)},T)});return await e(v)}return await e()},s=4,d=null;for(let u=0;u<s;u++)try{d=await l(u),o.current?.resolve(void 0);break}catch(v){if(v.type==="missing_or_invalid_mfa")i=!0;else throw o.current?.resolve(void 0),v}if(d===null){let u=new ke("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw o.current?.reject(u),u}return d}var Jg=require("react/jsx-runtime"),Z0=function(e){return()=>`id-${e++}`}(0);function Q0(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function dt(e){return e.error!==void 0}var ot=new Bl,kd=new Map,X0=(e,t)=>typeof t=="bigint"?t.toString():t,e2=(e,t)=>`${e}${JSON.stringify(t,X0)}`;function pt(e,t,r,o){let n=r.contentWindow;if(!n)throw new Error("iframe not initialized");let a=e2(e,t);if(e==="privy:wallet:create"){let l=kd.get(a);if(l)return l}let i=new Promise((l,s)=>{let d=Z0();ot.enqueue(d,{resolve:l,reject:s}),n.postMessage({id:d,event:e,data:t},o)}).finally(()=>{kd.delete(a)});return kd.set(a,i),i}function t2(e){switch(e.event){case"privy:iframe:ready":let t=ot.dequeue(e.event,e.id);return dt(e)?t.reject(new ke(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let r=ot.dequeue(e.event,e.id);return dt(e)?r.reject(new ke(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:connect":let o=ot.dequeue(e.event,e.id);return dt(e)?o.reject(new ke(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:recover":let n=ot.dequeue(e.event,e.id);return dt(e)?n.reject(new ke(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:rpc":let a=ot.dequeue(e.event,e.id);return dt(e)?a.reject(new ke(e.error.type,e.error.message)):a.resolve(e.data);case"privy:wallet:set-recovery-password":let i=ot.dequeue(e.event,e.id);return dt(e)?i.reject(new ke(e.error.type,e.error.message)):i.resolve(e.data);case"privy:mfa:verify":let l=ot.dequeue(e.event,e.id);return dt(e)?l.reject(new ke(e.error.type,e.error.message)):l.resolve(e.data);case"privy:mfa:init-enrollment":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:submit-enrollment":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:unenroll":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:mfa:clear":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:init-signer":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:submit-cast":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:remove-cast":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:react-to-cast":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:submit-link":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}case"privy:farcaster:remove-link":{let s=ot.dequeue(e.event,e.id);return dt(e)?s.reject(new ke(e.error.type,e.error.message)):s.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}function Yg(e){let t=(0,Mi.useRef)(null),r=(0,Mi.useRef)(e.mfaMethods),o=Gu(),[n,a]=(0,Kg.useState)(!1);return(0,Mi.useEffect)(()=>{r.current=e.mfaMethods},[e.mfaMethods]),(0,Mi.useEffect)(()=>{if(!n)return;let i=t.current;if(!i)return;function l(h){h&&h.origin===e.origin&&Q0(h.data)&&t2(h.data)}let s={create(h){return pt("privy:wallet:create",h,i,e.origin)},connect(h){return pt("privy:wallet:connect",h,i,e.origin)},recover(h){return Tn(w=>pt("privy:wallet:recover",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},rpc(h){return Tn(w=>pt("privy:wallet:rpc",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},setRecoveryPassword(h){return Tn(w=>pt("privy:wallet:set-recovery-password",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},verifyMfa(h){return Tn(w=>pt("privy:mfa:verify",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},initEnrollMfa(h){return Tn(w=>pt("privy:mfa:init-enrollment",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},submitEnrollMfa(h){return pt("privy:mfa:submit-enrollment",h,i,e.origin)},unenrollMfa(h){return Tn(w=>pt("privy:mfa:unenroll",{...h,...w},i,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},clearMfa(h){return pt("privy:mfa:clear",h,i,e.origin)},initFarcasterSigner(h){return pt("privy:farcaster:init-signer",h,i,e.origin)},submitCast(h){return pt("privy:farcaster:submit-cast",h,i,e.origin)},removeCast(h){return pt("privy:farcaster:remove-cast",h,i,e.origin)},reactToCast(h){return pt("privy:farcaster:react-to-cast",h,i,e.origin)},submitLink(h){return pt("privy:farcaster:submit-link",h,i,e.origin)},removeLink(h){return pt("privy:farcaster:remove-link",h,i,e.origin)}};window.addEventListener("message",l);let d=()=>e.onLoad(s),u=(...h)=>{console.warn("Privy iframe failed to load: ",...h),e.onLoadFailed()},v=new AbortController;return Rp(()=>pt("privy:iframe:ready",{},i,e.origin),{abortSignal:v.signal}).then(d,u),()=>{window.removeEventListener("message",l),v.abort()}},[n]),(0,Jg.jsx)("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>a(!0),src:Ha(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId})})}function Hl(e){let t=e.toLowerCase();return["fbav","fban","instagram","snapchat"].some(o=>t.includes(o))}var Gl=class{constructor(t,r){this.meta={action:t,phoneNumber:r}}async init(){if(!this.meta.action)throw new _("action required");if(!this.api)throw new _("Auth flow has no API instance");if(this.meta.action==="enroll"&&!this.meta.phoneNumber)throw new _("phone number must be set when initialzing authentication.");try{await this.api.post(cp,{action:this.meta.action,phoneNumber:this.meta.phoneNumber})}catch(t){throw we(t)}}async authenticate(){if(!this.meta.action)throw new _("action required");if(!this.api)throw new _("Mfa flow has no API instance");if(!this.meta.smsCode)throw new _("sms code must be set prior to calling authenticate.");if(this.meta.action==="enroll"&&!this.meta.phoneNumber)throw new _("phone number must be set prior to calling authenticate.");try{let t=await this.api.post(dp,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return $t(t)}catch(t){throw we(t)}}};var Ht=require("react/jsx-runtime"),Wi;function r2(e){return typeof e=="string"&&e.length===25}function Se(){if(!Wi){let e=Q.get(Zo);return Promise.resolve(e||null)}return Wi.getAccessToken()}var Qg,Yp=(e,t)=>Qg(e,t),Xg,Jp=(e,t)=>Xg(e,t),e1,Zp=(e,t)=>e1(e,t),t1,Qp=()=>t1(),o2=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;Q.put(Oi,t);let r=new URL(window.location.href);r.searchParams.delete("privy_token"),window.history.pushState({},"",r)},r1=({config:e,...t})=>{if(!r2(t.appId))throw new _("Cannot initialize the Privy provider with an invalid Privy app ID");Wi||(Wi=new Vn({appId:t.appId,apiUrl:t.apiUrl||Oa}));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."),(0,Ht.jsx)(Pu,{client:Wi,clientConfig:r,legacyCreateEmbeddedWalletFlag:t.createPrivyWalletOnLogin,children:(0,Ht.jsx)(n2,{...t,config:r,client:Wi})})},n2=e=>{let t=e.client,[r,o]=(0,ee.useState)(!1),[n,a]=(0,ee.useState)(!1),[i,l]=(0,ee.useState)(!1),[s,d]=(0,ee.useState)(null),[u,v]=(0,ee.useState)([]),h=(0,ee.useRef)(u),[w,T]=(0,ee.useState)(!1),[C,S]=(0,ee.useState)(null),[b,x]=(0,ee.useState)(!1),[I,W]=(0,ee.useState)({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:E}),[R,H]=(0,ee.useState)(null),[B,G]=(0,ee.useState)(null),[P,J]=(0,ee.useState)(null),N=gs(),te=vs(),[ue,se]=(0,ee.useState)(!0),[ae,j]=(0,ee.useState)({}),[Ue,Oe]=(0,ee.useState)(null),[no,Gt]=(0,ee.useState)(null),[je,Me]=(0,ee.useState)(!1),[Vt,hr]=(0,ee.useState)(!1),To=(0,ee.useRef)(null),Dr=(0,ee.useRef)(null),O=(0,ee.useRef)(Bu);t.onStoreToken=c=>{c&&D(O,"accessToken","onAccessTokenGranted",c)},t.onDeleteToken=()=>{D(O,"accessToken","onAccessTokenRemoved")};let re=(0,ee.useRef)(null),ne=(0,ee.useRef)(null),Li=(0,ee.useCallback)(c=>{let p=t.connectors?.walletsReady||!1;return i&&s?.linkedAccounts?.some(g=>g.type==="wallet"&&g.walletClientType==="privy")?p&&c?.some(g=>g?.walletClientType==="privy"):p},[i,s?.linkedAccounts,t?.connectors?.walletsReady]),Z=c=>{S(c),setTimeout(()=>{o(!0)},15),t.createAnalyticsEvent("modal_open",{initialScreen:c})},nt=c=>{N.embeddedWallets.createOnLogin!=="off"&&se(!0),Z(c)};(0,ee.useEffect)(()=>{if(!P||!s){t.connectors?.removeEmbeddedWalletConnector();return}let c=s?.linkedAccounts.filter(p=>p.type==="wallet"&&p.walletClientType==="privy");if(c&&c.length>0){let p=c[0].address;t.connectors?.addEmbeddedWalletConnector(P,p,N.defaultChain,e.appId)}},[P,s]),(0,ee.useEffect)(()=>{P&&no?.(P)},[P]),(0,ee.useEffect)(()=>{(async()=>{if(!N.customAuth?.enabled)return;se(!0);let{getCustomAccessToken:p,isLoading:f}=N.customAuth;if(!(!n||f))try{let g=await p();if(!g){await Pn.logout();return}if(i)return;t.startAuthFlow(new Sn(g));let{user:M,isNewUser:F}=await t.authenticate();M||await Pn.logout(),d(M||null),T(F||!1),l(!0),hr(!0)}catch(g){console.warn(g),i&&await Pn.logout()}})()},[N.customAuth?.enabled,N.customAuth?.getCustomAccessToken,N.customAuth?.isLoading,n,i]),(0,ee.useEffect)(()=>{Vt&&P&&s&&or(s,e.config?.embeddedWallets?.createOnLogin)&&(hr(!1),Ur(s,An).catch(console.error))},[Vt&&P&&s]),(0,ee.useEffect)(()=>{async function c(){let p=Mt();o2();let f=(0,Zg.createStore)();H(f),t.initializeConnectorManager({walletConnectCloudProjectId:N.walletConnectCloudProjectId,rpcConfig:N.rpcConfig,chains:N.chains,defaultChain:N.defaultChain,store:f,walletList:N.appearance.walletList,shouldEnforceDefaultChainOnConnect:N.shouldEnforceDefaultChainOnConnect,appName:N.name??"Privy"}),t.connectors?.initialize().then(()=>{zl()});let g=await t.getAuthenticatedUser();e.config?.customAuth?.enabled||(l(!!g),g&&D(O,"login","onComplete",g,!1,!0,null),d(g)),p||pe.setReadyToTrue(),p&&(g?ne.current="link":ne.current="login")}!n&&te&&c()},[t,Ue,n,te]);let Mt=()=>{let c=Ui();return!c.inProgress||c.headless?!1:(t.startAuthFlow(new Hr(c)),nt("AWAITING_OAUTH_SCREEN"),!0)},Ko=async(c,p,f,g)=>{let M=await t.connectors?.createWalletConnector(c,p)||null;yr(M,p,f,g)};async function yr(c,p,f,g){if(c)W({status:"disconnected",connectedWallet:null,connectError:null,connector:c,connectRetry:E});else return W({status:"disconnected",connectedWallet:null,connectError:new oe("Unable to connect to wallet."),connector:null,connectRetry:E}),g?.(null,f);c instanceof zr&&p&&await c.resetConnection(p),W({connector:c,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>yr(c,p,f,g)});try{let M=await c.connect({showPrompt:!0});if(N.shouldEnforceDefaultChainOnConnect&&!N.chains.find(F=>F.id===Number(M?.chainId))&&!(M?.connectorType==="wallet_connect_v2"&&M?.walletClientType==="metamask")){W(F=>({...F,connector:c,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:E}));try{await M?.switchChain(N.defaultChain.id),M&&(M.chainId=kn(rn(N.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${N.defaultChain.id}`)}}return W(F=>({...F,status:"connected",connectedWallet:M,connectError:null,connectRetry:E})),M&&!ne.current&&D(O,"connectWallet","onSuccess",M),g?.(M,f)}catch(M){return M instanceof mt?(console.warn(M.cause?M.cause:M.message),ne.current||D(O,"connectWallet","onError",M.privyErrorCode||"generic_connect_wallet_error")):(console.warn(M),ne.current||D(O,"connectWallet","onError","unknown_connect_wallet_error")),W(F=>({...F,status:"disconnected",connectedWallet:null,connectError:M})),g?.(null,f)}}let Yo=async(c,p)=>{if(c===null)return;let f=new on(c,p);t.startAuthFlow(f)},zl=()=>{let c=new URLSearchParams(window.location.search),p=c.get("privy_connector"),f=c.get("privy_wallet_client");if(!p||!f)return;if(f==="phantom"&&!So()&&nt("LOGIN_FAILED_SCREEN"),!t.connectors)throw new _("Connector not initialized");Z("AWAITING_CONNECTION");let g=new URL(window.location.href);g.searchParams.delete("privy_connector"),g.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",g),Ko(p,f,void 0,Yo)};(0,ee.useEffect)(()=>{n&&i&&s===null&&t.getAuthenticatedUser().then(d)},[n,i,s,t]);let it=()=>{if(!i)throw D(O,"linkAccount","onError","must_be_authenticated"),new _("User must be authenticated before linking an account.")},Jo=()=>{it(),re.current="siwe",ne.current="link",Z("LINK_WALLET_SCREEN")},zt=c=>{if(!i||!s)return!1;if(c.walletClientType==="privy")return!0;for(let p of s.linkedAccounts)if(p.type==="wallet"&&p.address===c.address&&p.walletClientType!=="privy")return!0;return!1},ut=async c=>{if(!t.connectors)throw new _("Connector not initialized");let p=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null;if(W(f=>({...f,connector:p,status:"connected",connectedWallet:c,connectError:null,connectRetry:E})),N.captchaEnabled&&!i){let f={callback:g=>Yo(c,g),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"};j({captchaModalData:f}),nt("CAPTCHA_SCREEN")}else await Yo(c),nt("AWAITING_CONNECTION")},Fr=async(c,p)=>{if(!N.fiatOnRamp.enabled)throw new _("Fiat on-ramp is not enabled");if(!p||!p.provider||p.provider==="moonpay"){let{signedUrl:f,externalTransactionId:g}=await xh(t,c,p?.config??{},N.appearance.palette,N.fiatOnRamp.useSandbox);return{signedUrl:f,externalTransactionId:g}}else throw new _("Unsupported fund provider. Currently supported option is `moonpay`.")},Po=()=>{v(c=>{let p=t.connectors?.wallets.map(f=>({...f,linked:zt(f),loginOrLink:async()=>{if(!await f.isConnected())throw new _("Wallet is not connected");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new _("Cannot link or login with embedded wallet");ut(f)},fund:async g=>{let{signedUrl:M,externalTransactionId:F}=await Fr(f.address,g);j({fiatOnRampPrompt:{signedUrl:M},fiatOnRampStatus:{externalTransactionId:F}}),Z("FIAT_ON_RAMP_PROMPT_SCREEN")},unlink:async()=>{if(!i)throw new _("User is not authenticated.");if(f.connectorType==="embedded"&&f.walletClientType==="privy")throw new _("Cannot unlink an embedded wallet");let g=await t.unlinkWallet(f.address);d(g)}}))||[];return Me(Li(p)),Ja(c,p)?c:p})};(0,ee.useEffect)(()=>{Po()},[s?.linkedAccounts,i,n]),(0,ee.useEffect)(()=>{if(n){if(!t.connectors)throw new _("Connector not initialized");Po(),t.connectors.on("walletsUpdated",Po)}},[n]);let Pa=()=>{Z(i?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};(0,ee.useEffect)(()=>{if(!u[0])return;let c=u[0],p=h.current.find(g=>g.address===c.address),f;if(c.walletClientType==="privy"?f=s?.linkedAccounts.find(g=>g.type==="wallet"&&g.address===c.address&&g.walletClientType==="privy"):f=s?.linkedAccounts.find(g=>g.type==="wallet"&&g.address===c.address&&g.walletClientType!=="privy"),!p&&f){let g=Object.assign({},s);g.wallet=f&&{address:f.address,chainType:f.chainType,chainId:f.chainId,walletClient:f.walletClient,walletClientType:f.walletClientType,connectorType:f.connectorType},d(g)}h.current=u},[u]);let Ur=async(c,p)=>{if(Ne(c))throw D(O,"createWallet","onError","embedded_wallet_already_exists"),new Error("Only one Privy wallet per user is currently allowed");let[g,M]=await Promise.all([pe.initializeWalletProxy(p),Se()]);if(!g&&e.config?.customAuth?.enabled)throw D(O,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!g||!M||e.config?.embeddedWallets?.requireUserPasswordOnCreate)return new Promise((F,me)=>{se(!0),j({createWallet:{onSuccess:Wt=>{D(O,"createWallet","onSuccess",Wt),F(Wt)},onFailure:Wt=>{D(O,"createWallet","onError","unknown_embedded_wallet_error"),me(Wt)},callAuthOnSuccessOnClose:!1}}),Z("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{await g.create({accessToken:M});let F=await pe.refreshUser(),me=Ne(F);if(!me)throw D(O,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return D(O,"createWallet","onSuccess",me),me}},ql=c=>{if(!N.chains.map(p=>p.id).includes(c))throw new oe(`Chain ID ${c} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},Md=(c,p,f)=>new Promise(async(g,M)=>{if(!i||!s){D(O,"sendTransaction","onError","must_be_authenticated"),M(new Error("User must be authenticated before signing with a Privy wallet"));return}let F=Ne(s);if(!F){D(O,"sendTransaction","onError","embedded_wallet_not_found"),M(new Error("Must have a Privy wallet before signing"));return}se(!0);let me=t.connectors?.findWalletConnector("embedded","privy")?.proxyProvider,bt=c.chainId?Number(c.chainId):me.chainId;ql(bt);let Wt=Object.assign({},c,{chainId:bt}),io=async()=>{let Et=await Se();if(!Et||!P){D(O,"sendTransaction","onError","embedded_wallet_not_found"),M(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await pe.recoverEmbeddedWallet()){D(O,"sendTransaction","onError","unknown_connect_wallet_error"),M(new Error("Unable to connect to wallet"));return}let wr=so(Wt.chainId,N.chains,N.rpcConfig,{appId:e.appId}),$l=await _i(F.address,Wt,wr);if(N.embeddedWallets.noPromptOnSignature){let{totalGasEstimate:M1}=await Si($l,wr),{hasSufficientFunds:W1}=await Ll(F.address,$l,M1,wr);if(!W1)throw new Be(new nr("Wallet has insufficient funds for this transaction.",ft.E32603_DEFAULT_INTERNAL_ERROR.eipCode))}let Od=await Wl(Et,F.address,P,$l,wr);D(O,"sendTransaction","onSuccess",Od),g(Od)}catch(vr){D(O,"sendTransaction","onError","transaction_failure"),M(vr)}};if(N.embeddedWallets.noPromptOnSignature)p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),io();else{let Et={transactionRequest:Wt,onSuccess:wr=>{D(O,"sendTransaction","onSuccess",wr),g(wr)},onFailure:wr=>{D(O,"sendTransaction","onError","transaction_failure"),M(wr)},uiOptions:p||{},fundWalletConfig:f},vr={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:wr=>{D(O,"sendTransaction","onError","unknown_connect_wallet_error"),M(wr)}};j({connectWallet:vr,sendTransaction:Et}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")}});function Wd(){return new Promise(async(c,p)=>{let f=await Se();if(!f||!P)throw new Error("Must have valid access token to enroll in MFA");try{await P.verifyMfa({accessToken:f}),c()}catch(g){p(g)}})}let gr=c=>{if(s?.[c])throw D(O,"linkAccount","onError","cannot_link_more_of_type"),new _(`User already has an account of type ${c} linked.`)},Pn={ready:n,authenticated:i,user:s,walletConnectors:t.connectors||null,connectWallet:Pa,linkWallet:Jo,linkEmail:()=>{it(),gr("email"),re.current="email",ne.current="link",Z("LINK_EMAIL_SCREEN")},linkPhone:()=>{it(),gr("phone"),re.current="sms",ne.current="link",Z("LINK_PHONE_SCREEN")},linkGoogle:async()=>{it(),gr("google"),ne.current="link",await pe.initLoginWithOAuth("google")},linkTwitter:async()=>{it(),gr("twitter"),ne.current="link",await pe.initLoginWithOAuth("twitter")},linkDiscord:async()=>{it(),gr("discord"),ne.current="link",await pe.initLoginWithOAuth("discord")},linkGithub:async()=>{it(),gr("github"),ne.current="link",await pe.initLoginWithOAuth("github")},linkSpotify:async()=>{it(),gr("spotify"),ne.current="link",await pe.initLoginWithOAuth("spotify")},linkTiktok:async()=>{it(),gr("tiktok"),ne.current="link",await pe.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{it(),gr("linkedin"),ne.current="link",await pe.initLoginWithOAuth("linkedin")},linkApple:async()=>{it(),gr("apple"),ne.current="link",await pe.initLoginWithOAuth("apple")},linkFarcaster:async()=>{it(),gr("farcaster"),await pe.initLoginWithFarcaster(),ne.current="link",re.current="farcaster",Z("AWAITING_FARCASTER_CONNECTION")},updateEmail:()=>{if(it(),!s?.email)throw new _("User does not have an email linked to their account.");ne.current="link",re.current="email",Z("UPDATE_EMAIL_SCREEN")},login:async()=>{if(n||(await new Promise(c=>{Oe(()=>c)}),Oe(null)),i){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}ne.current="login",nt("LANDING")},connectOrCreateWallet:async()=>{if(n||(await new Promise(c=>{Oe(()=>c)}),Oe(null)),i){console.warn("User must be unauthenticated to `connectOrCreateWallet`");return}if(u[0]){console.warn("User must have no connected wallets to `connectOrCreateWallet`");return}nt("CONNECT_OR_CREATE")},logout:async()=>{if(await t.logout(),s&&P)try{await P.clearMfa({userId:s.id})}catch{}d(null),l(!1),S(null),D(O,"logout","onSuccess"),ne.current=null,re.current=null,o(!1),Q.del(Ni)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{if(!s||!s.wallet)return new Le;let c=u.find(f=>s.wallet&&f.address===s.wallet.address),p=t.connectors?.walletConnectors.find(f=>f.wallets.find(g=>g.address===c?.address));return!c||!p?new Le:p.proxyProvider},getEthersProvider:()=>{if(!s||!s.wallet)return new Vl.Web3Provider(new br(new Le));let c=u.find(f=>s.wallet&&f.address===s.wallet.address),p=t.connectors?.walletConnectors.find(f=>f.wallets.find(g=>g.address===c?.address));return!c||!p?new Vl.Web3Provider(new br(new Le)):new Vl.Web3Provider(new br(p.proxyProvider))},getWeb3jsProvider:()=>{if(!s||!s.wallet)return new ko(new Le);let c=u.find(f=>s.wallet&&f.address===s.wallet.address),p=t.connectors?.walletConnectors.find(f=>f.wallets.find(g=>g.address===c?.address));return!c||!p?new ko(new Le):new ko(p.proxyProvider)},unlinkWallet:async c=>{let p=await t.unlinkWallet(c);return d(p),p},unlinkEmail:async c=>{let p=await t.unlinkEmail(c);return d(p),p},unlinkPhone:async c=>{let p=await t.unlinkPhone(c);return d(p),p},unlinkGoogle:async c=>{let p=await t.unlinkOAuth("google",c);return d(p),p},unlinkTwitter:async c=>{let p=await t.unlinkOAuth("twitter",c);return d(p),p},unlinkDiscord:async c=>{let p=await t.unlinkOAuth("discord",c);return d(p),p},unlinkGithub:async c=>{let p=await t.unlinkOAuth("github",c);return d(p),p},unlinkSpotify:async c=>{let p=await t.unlinkOAuth("spotify",c);return d(p),p},unlinkTiktok:async c=>{let p=await t.unlinkOAuth("tiktok",c);return d(p),p},unlinkLinkedIn:async c=>{let p=await t.unlinkOAuth("linkedin",c);return d(p),p},unlinkApple:async c=>{let p=await t.unlinkOAuth("apple",c);return d(p),p},unlinkFarcaster:async c=>{let p=await t.unlinkFarcaster(c);return d(p),p},setActiveWallet:async c=>{let p=u.find(g=>(0,Ea.getAddress)(g.address)===(0,Ea.getAddress)(c)),f=s?.linkedAccounts.find(g=>g.type==="wallet"&&(0,Ea.getAddress)(g.address)===(0,Ea.getAddress)(c));if(!p||!await p.isConnected())G(c),Jo();else if(!p.linked)p.loginOrLink();else{let g=Object.assign({},s);g.wallet=f&&{address:f.address,chainType:f.chainType,chainId:f.chainId,walletClient:f.walletClient,walletClientType:f.walletClientType,connectorType:f.connectorType},d(g)}},forkSession:()=>t.forkSession(),createWallet:async()=>{if(!i||!s)throw D(O,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return Ur(s,15e3)},setWalletPassword:async()=>{if(!i||!s)throw D(O,"setWalletPassword","onError","must_be_authenticated"),new Error("User must be authenticated before adding password to Privy wallet");let c=Ne(s);if(!c||!P)throw D(O,"setWalletPassword","onError","embedded_wallet_not_found"),new Error("Must have a Privy wallet to add a password");if(c.recoveryMethod==="user-passcode")throw D(O,"setWalletPassword","onError","embedded_wallet_password_already_exists"),new Error("Cannot set password. Embedded wallet already has a password.");try{await Wd()}catch(p){throw D(O,"setWalletPassword","onError","missing_mfa_credentials"),p}return new Promise((p,f)=>{se(!0);let g={onSuccess:F=>{D(O,"setWalletPassword","onSuccess",F),p(F)},onFailure:F=>{D(O,"setWalletPassword","onError","user_exited_set_password_flow"),f(F)},callAuthOnSuccessOnClose:!1},M={onCompleteNavigateTo:"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",onFailure:F=>{D(O,"setWalletPassword","onError","unknown_connect_wallet_error"),f(F)}};j({setWalletPassword:g,connectWallet:M}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")})},signMessage:(c,p)=>new Promise(async(f,g)=>{if(!i||!s){D(O,"signMessage","onError","must_be_authenticated"),g(new Error("User must be authenticated before signing with a Privy wallet"));return}let M=Ne(s);if(!M){D(O,"signMessage","onError","embedded_wallet_not_found"),g(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){D(O,"signMessage","onError","invalid_message"),g(new Error("Message must be a non-empty string"));return}se(!0);let F=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let me=await Se();if(!P||!me)throw new Error("Unable to connect to wallet");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:M.address});let{response:Wt}=await P.rpc({accessToken:me,address:M.address,request:{method:"personal_sign",params:[c,M.address]}}),io=Wt.data;return t.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:M.address}),io};if(N.embeddedWallets.noPromptOnSignature){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let me=await F();D(O,"signMessage","onSuccess",me),f(me)}catch(me){D(O,"signMessage","onError","unable_to_sign"),g(me??new Be("Unable to sign message"))}}else{let Wt={method:"personal_sign",data:c,confirmAndSign:F,onSuccess:Et=>{D(O,"signMessage","onSuccess",Et),f(Et)},onFailure:Et=>{D(O,"signMessage","onError","unable_to_sign"),g(Et)},uiOptions:p||{}},io={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Et=>{D(O,"signMessage","onError","unknown_connect_wallet_error"),g(Et)}};j({signMessage:Wt,connectWallet:io}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),signTypedData:(c,p)=>new Promise(async(f,g)=>{if(!i||!s){D(O,"signTypedData","onError","must_be_authenticated"),g(new Error("User must be authenticated before signing with a Privy wallet"));return}let M=Ne(s);if(!M){D(O,"signTypedData","onError","embedded_wallet_not_found"),g(new Error("Must have a Privy wallet before signing"));return}se(!0);let F=Va(c),me=async()=>{if(!i)throw new Error("User must be authenticated before signing with a Privy wallet");let bt=await Se();if(!P||!bt)throw new Error("Unable to connect to wallet");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent("embedded_wallet_sign_typed_data_started",{walletAddress:M.address});let{response:io}=await P.rpc({accessToken:bt,address:M.address,request:{method:"eth_signTypedData_v4",params:[M.address,F]}}),Et=io.data;return t.createAnalyticsEvent("embedded_wallet_sign_typed_data_completed",{walletAddress:M.address}),Et};if(N.embeddedWallets.noPromptOnSignature||(N.legacyWalletUiConfig??!1)){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let bt=await me();D(O,"signTypedData","onSuccess",bt),f(bt)}catch(bt){D(O,"signTypedData","onError","unable_to_sign"),g(bt??new Be("Unable to sign message"))}}else{let io={method:"eth_signTypedData_v4",data:F,confirmAndSign:me,onSuccess:vr=>{D(O,"signTypedData","onSuccess",vr),f(vr)},onFailure:vr=>{D(O,"signTypedData","onError","unable_to_sign"),g(vr)},uiOptions:p||{}},Et={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:vr=>{D(O,"signMessage","onError","unknown_connect_wallet_error"),g(vr)}};j({signMessage:io,connectWallet:Et}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:async(c,p,f)=>{let M=await(await Md(c,p,f)).wait();return Ol(M)},exportWallet:()=>new Promise(async(c,p)=>{if(!i||!s){p(new Error("User must be authenticated before exporting their Privy wallet"));return}let f=Ne(s);if(!f){p(new Error("Must have a Privy wallet before exporting"));return}se(!0);let g={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:p},M=await Se();if(!M||!P){p(new Error("Must have valid access token to enroll in MFA"));return}if(!P){p(new Error("Must have a Privy wallet before exporting"));return}try{try{await P.connect({accessToken:M,address:f.address}),await P.verifyMfa({accessToken:M})}catch(me){if(ln(me))await pe.recoverEmbeddedWallet();else throw me}}catch(me){p(me);return}let F={appId:e.appId,origin:t.apiUrl,onSuccess:c,onFailure:p};j({keyExport:F,connectWallet:g}),Z("EMBEDDED_WALLET_CONNECTING_SCREEN")}),promptMfa:Wd,async init(c){let p;switch(c){case"sms":p=new Gl("verify");break;case"totp":return;default:throw new Error(`Unsupported MFA method: ${c}`)}t.startMfaFlow(p),await p.init()},async submit(c,p){switch(c){case"totp":case"sms":To.current?.resolve({mfaMethod:c,mfaCode:p}),await new Promise((f,g)=>{Dr.current={resolve:f,reject:g}});break;default:throw To.current?.reject(new _("Unsupported MFA method")),new _(`Unsupported MFA method: ${c}`)}},cancel(){To.current?.reject(new _("MFA canceled"))},async initEnrollmentWithSms(c){let p=await Se();if(!p||!P)throw new Error("Must have valid access token to enroll in MFA");await P.initEnrollMfa({method:"sms",accessToken:p,phoneNumber:c.phoneNumber})},enrollInMfa(c){return new Promise((p,f)=>{if(!c){pe.closePrivyModal(),p();return}N.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."),j({mfaEnrollmentFlow:{mfaMethods:N.mfa.methods,onSuccess:p,onFailure:f}}),Z("MFA_ENROLLMENT_FLOW_SCREEN")})},async initEnrollmentWithTotp(){let c=await Se();if(!c||!P)throw new Error("Must have valid access token to enroll in MFA");let p=await P.initEnrollMfa({method:"totp",accessToken:c});return{secret:p.secret,authUrl:p.authUrl}},async submitEnrollmentWithSms(c){let p=await Se();if(!p||!P)throw new Error("Must have valid access token to enroll in MFA");await P.submitEnrollMfa({method:"sms",accessToken:p,phoneNumber:c.phoneNumber,code:c.mfaCode});let f=await t.getAuthenticatedUser();d(f)},async submitEnrollmentWithTotp(c){let p=await Se();if(!p||!P)throw new Error("Must have valid access token to enroll in MFA");await P.submitEnrollMfa({method:"totp",accessToken:p,code:c.mfaCode});let f=await t.getAuthenticatedUser();d(f)},async unenroll(c){let p=await Se();if(!p||!P)throw new Error("Must have valid access token to remove MFA");await P.unenrollMfa({method:c,accessToken:p});let f=await t.getAuthenticatedUser();d(f)},requestFarcasterSigner:async()=>{let c=await Se(),p=s?.linkedAccounts.find(M=>M.type==="wallet"&&M.walletClientType==="privy");if(!c)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!p)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");let g=await P.initFarcasterSigner({address:p.address,hdWalletIndex:null,accessToken:c,mfaCode:null,mfaMethod:null});if(g.status==="approved"){let M=await t.getAuthenticatedUser();d(M||s||null)}j({farcasterSigner:g}),Z("AWAITING_FARCASTER_SIGNER")},submitCast:async c=>{let p=await Se(),f=s?.linkedAccounts.find(F=>F.type==="wallet"&&F.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.submitCast({address:f.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:c,fid:BigInt(s.farcaster.fid)})).response.hash}},removeCast:async({castHash:c})=>{let p=await Se(),f=s?.linkedAccounts.find(F=>F.type==="wallet"&&F.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.removeCast({address:f.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:c,fid:BigInt(s.farcaster.fid)})).response.hash}},likeCast:async({castHash:c,castAuthorFid:p})=>{let f=await Se(),g=s?.linkedAccounts.find(me=>me.type==="wallet"&&me.walletClientType==="privy");if(!f)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!g)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.reactToCast({address:g.address,hdWalletIndex:null,accessToken:f,mfaCode:null,mfaMethod:null,payload:{type:1,castId:{hash:c,fid:p}},fid:BigInt(s.farcaster.fid)})).response.hash}},recastCast:async({castHash:c,castAuthorFid:p})=>{let f=await Se(),g=s?.linkedAccounts.find(me=>me.type==="wallet"&&me.walletClientType==="privy");if(!f)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!g)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.reactToCast({address:g.address,hdWalletIndex:null,accessToken:f,mfaCode:null,mfaMethod:null,payload:{type:2,castId:{hash:c,fid:p}},fid:BigInt(s.farcaster.fid)})).response.hash}},followUser:async({fid:c})=>{let p=await Se(),f=s?.linkedAccounts.find(F=>F.type==="wallet"&&F.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.submitLink({address:f.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{type:"follow",targetFid:c},fid:BigInt(s.farcaster.fid)})).response.hash}},unfollowUser:async({fid:c})=>{let p=await Se(),f=s?.linkedAccounts.find(F=>F.type==="wallet"&&F.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!s?.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster embedded signer write to Farcaster");if(!await pe.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");return{hash:(await P.removeLink({address:f.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{type:"follow",targetFid:c},fid:BigInt(s.farcaster.fid)})).response.hash}},isHeadlessOAuthLoading:b,loginWithCode(c){return pe.loginWithCode(c)},initLoginWithEmail(c){return pe.initLoginWithEmail(c)},initLoginWithSms(c){return pe.initLoginWithSms(c)},fundWallet(c,p){return pe.fundWallet(c,p)},initLoginWithHeadlessOAuth(c,p){return pe.initLoginWithHeadlessOAuth(c,p)},loginWithHeadlessOAuth(c){return pe.loginWithHeadlessOAuth(c)},isModalOpen:r};Qg=Pn.signMessage,Xg=Pn.signTypedData,e1=async(...c)=>{let p=await Md(...c);return N.embeddedWallets.waitForTransactionConfirmation&&await p.wait(),p};let Ld=!!e.config?.headless,pe=(()=>({headless:Ld,isNewUserThisSession:w,linkingHint:B,pendingTransaction:null,walletConnectionStatus:I,mipdStore:R,connectors:t.connectors?.walletConnectors??[],rpcConfig:N.rpcConfig,chains:N.chains,appId:e.appId,showFiatPrices:N.embeddedWallets.priceDisplay.primary!=="native-token",clientAnalyticsId:t.clientAnalyticsId,nativeTokenSymbolForChainId:c=>N.chains.find(p=>p.id===Number(c))?.nativeCurrency.symbol,initializeWalletProxy:async c=>{if(P)return P;let p=new Promise(M=>{Gt(()=>F=>M(F))}),f=new Promise(M=>setTimeout(()=>M(null),c)),g=await Promise.race([p,f]);return Gt(null),g},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>t.authFlow?.meta,closePrivyModal:(c={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let p=n&&i&&s;ne.current==="login"?c.shouldCallAuthOnSuccess&&p?(D(O,"login","onComplete",s,w,!1,re.current??null),e.onSuccess?.(s,w)):D(O,"login","onError","exited_auth_flow"):ne.current==="link"&&re.current&&(c.isSuccess&&p?D(O,"linkAccount","onSuccess",s,re.current):D(O,"linkAccount","onError","exited_link_flow")),G(null),ne.current=null,re.current=null,T(!1),o(!1),setTimeout(()=>{t.authFlow=void 0},200),t.createAnalyticsEvent("modal_closed")},openPrivyModal:Z,connectWallet:yr,initLoginWithWallet:async(c,p)=>{re.current="siwe",Yo(c,p)},loginWithWallet:async()=>{if(!n)throw new xn;if(!(t.authFlow instanceof on))throw new _("Must initialize SIWE flow first.");let c,p;if(i)try{c=await t.link(),re.current="siwe"}catch(f){throw D(O,"linkAccount","onError",f.privyErrorCode||"failed_to_link_account"),f}else try{({user:c,isNewUser:p}=await t.authenticate()),re.current="siwe"}catch(f){throw D(O,"login","onError",f.privyErrorCode||"generic_connect_wallet_error"),f}d(c||s||null),T(p||!1),l(!0)},initLoginWithFarcaster:async c=>{let p=new Di(c);t.startAuthFlow(p);try{re.current="farcaster",await p.initializeFarcasterConnect()}catch(f){throw ne.current==="login"?D(O,"login","onError",f.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",f.privyErrorCode||"unknown_auth_error"),f}},loginWithFarcaster:async()=>{if(!n)throw new xn;if(!(t.authFlow instanceof Di))throw new _("Must initialize Farcaster flow first.");let c,p;if(i)try{c=await t.link(),re.current="farcaster"}catch(f){throw D(O,"linkAccount","onError",f.privyErrorCode||"failed_to_link_account"),f}else try{({user:c,isNewUser:p}=await t.authenticate()),re.current="farcaster"}catch(f){throw D(O,"login","onError",f.privyErrorCode||"unknown_auth_error"),f}d(c||null),T(p||!1),l(!0)},async initLoginWithOAuth(c,p){if(re.current=c,Jl()){if(c==="google"&&Hl(window.navigator.userAgent)){nt("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}}else{nt("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}Q.del(Xo);let f=new Hr({provider:c});p&&f.addCaptchaToken(p),t.startAuthFlow(f);let g=await t.authFlow.getAuthorizationUrl();g&&g.url&&window.location.assign(g.url)},async loginWithOAuth(c){if(!(t.authFlow instanceof Hr))throw new _("Must initialize OAuth flow before calling loginWithOAuth");let p=Q.get(Qo),f=t.authFlow.meta.stateCode;if(p!==f)throw t.createAnalyticsEvent("possible_phishing_attempt",{provider:c,storedStateCode:p??"",returnedStateCode:f??""}),new _("Unexpected auth flow. This may be a phishing attempt.");let g,M;if(i)try{g=await t.link(),re.current=c}catch(F){throw D(O,"linkAccount","onError",F.privyErrorCode||"failed_to_link_account"),F}else try{({user:g,isNewUser:M}=await t.authenticate()),re.current=c}catch(F){throw ne.current==="login"?D(O,"login","onError",F.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",F.privyErrorCode||"failed_to_link_account"),F}d(g),T(M||!1),l(!0)},async initLoginWithHeadlessOAuth(c,p){if(Jl()){if(c==="google"&&Hl(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 Hr({provider:c,headless:!0});p&&f.addCaptchaToken(p);let g=await t.startAuthFlow(f).getAuthorizationUrl();g?.url&&window.location.assign(g.url)},async loginWithHeadlessOAuth(c){x(!0),t.startAuthFlow(new Hr(c));let p=Q.get(Qo),f=c.stateCode;if(p!==f)throw t.createAnalyticsEvent("possible_phishing_attempt",{provider:c.provider,storedStateCode:p??"",returnedStateCode:f??""}),x(!1),new _("Unexpected auth flow. This may be a phishing attempt.");let g,M;if(i)try{g=await t.link(),re.current=c.provider}catch(F){throw D(O,"linkAccount","onError",F.privyErrorCode||"failed_to_link_account"),F}else try{({user:g,isNewUser:M}=await t.authenticate()),re.current=c.provider}catch(F){throw ne.current==="login"?D(O,"login","onError",F.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",F.privyErrorCode||"failed_to_link_account"),F}return d(g),T(M||!1),l(!0),x(!1),g??void 0},initLoginWithEmail:async(c,p)=>{let f=new xo(c,p);t.startAuthFlow(f);try{re.current="email",await f.sendCodeEmail()}catch(g){throw ne.current==="login"?D(O,"login","onError",g.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",g.privyErrorCode||"failed_to_link_account"),g}},initUpdateEmail:async(c,p,f)=>{let g=new Ma(c,p,f);t.startAuthFlow(g),await g.sendCodeEmail()},initLoginWithSms:async(c,p)=>{let f=new nn(c,p);t.startAuthFlow(f);try{re.current="sms",await f.sendSmsCode()}catch(g){throw ne.current==="login"?D(O,"login","onError",g.privyErrorCode||"unknown_auth_error"):ne.current==="link"&&D(O,"linkAccount","onError",g.privyErrorCode||"failed_to_link_account"),g}},resendEmailCode:async()=>{await t.authFlow?.sendCodeEmail()},resendSmsCode:async()=>{await t.authFlow?.sendSmsCode()},loginWithCode:async c=>{if(!n)throw new xn;if(t.authFlow instanceof xo)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof nn)t.authFlow.meta.smsCode=c.trim();else throw new _("Must initialize a passwordless code flow first");let p,f;if(i)try{p=await t.link()}catch(g){throw D(O,"linkAccount","onError",g.privyErrorCode||"failed_to_link_account"),g}else try{({user:p,isNewUser:f}=await t.authenticate())}catch(g){throw D(O,"login","onError",g.privyErrorCode||"unknown_auth_error"),g}d(p||s||null),T(f||!1),l(!0)},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return d(c),c},walletProxy:P,createAnalyticsEvent:(c,p,f)=>t.createAnalyticsEvent(c,p,f),acceptTerms:async()=>{let c=await t.acceptTerms();return d(c),c},getUsdTokenPrice:c=>t.getUsdTokenPrice(c),recoverEmbeddedWallet:async()=>new Promise(async(c,p)=>{let f=s?.linkedAccounts.find(M=>M.type==="wallet"&&M.walletClientType==="privy"),g=await Se();if(!g||!P||!f){p(new Error("Must have valid access token and Privy wallet to recover wallet"));return}se(!0);try{await P.connect({accessToken:g,address:f.address}),c(!0)}catch(M){ln(M)&&f.recoveryMethod==="privy"?(t.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:f.address}),(await P.recover({address:f.address,accessToken:g})).address||p(new Error("Unable to recover wallet")),t.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:f.address}),c(!0)):ln(M)?(j({recoverWallet:{privyWallet:f,onFailure:p,onSuccess:()=>c(!0)}}),Z("EMBEDDED_WALLET_RECOVERY_SCREEN")):p(M)}}),getFiatOnRampConfig:Fr,setReadyToTrue:()=>{a(!0),Ue?.()},updateWallets:()=>Po(),fundWallet:async(c,p)=>{let{signedUrl:f,externalTransactionId:g}=await Fr(c,p);j({fiatOnRampPrompt:{signedUrl:f},fiatOnRampStatus:{externalTransactionId:g}}),Z("FIAT_ON_RAMP_PROMPT_SCREEN")},requestFarcasterSignerStatus:async c=>{let p=await Se(),f=s?.linkedAccounts.find(M=>M.type==="wallet"&&M.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!P||!f)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");let g=await t.requestFarcasterSignerStatus(c);if(g.status==="approved"){let M=await t.getAuthenticatedUser();d(M||s||null)}return g}}))();t1=pe.recoverEmbeddedWallet;let I1=(0,ee.useMemo)(()=>({wallets:u,ready:je}),[u,je]);return(0,Ht.jsx)(ye.Provider,{value:Pn,children:(0,Ht.jsx)(wc.Provider,{value:O,children:(0,Ht.jsx)(Ed.Provider,{value:I1,children:(0,Ht.jsxs)(Nu,{...N,children:[e.children,(0,Ht.jsxs)(vc.Provider,{value:pe,children:[!Ld&&N.captchaEnabled&&n&&!i&&(0,Ht.jsx)(Ps,{delayedExecution:!1}),(0,Ht.jsx)(zg,{theme:{...N.appearance.palette||{}}}),(0,Ht.jsx)(_u,{data:ae,setModalData:j,setInitialScreen:S,initialScreen:C,authenticated:i,open:r,children:(0,Ht.jsx)(jg,{open:r})}),ue&&te?(0,Ht.jsx)(Yg,{appId:e.appId,clientAnalyticsId:t.clientAnalyticsId,origin:t.apiUrl,mfaMethods:s?.mfaMethods,mfaPromise:To,mfaSubmitPromise:Dr,onLoad:J,onLoadFailed:()=>null}):null]})]})})})})};var o1=require("react");function n1(e){let{login:t}=(0,o1.useContext)(ye);return De("login",e),{login:t}}var i1=require("react");function a1(e){let{logout:t}=(0,i1.useContext)(ye);return De("logout",e),{logout:t}}var Ta=require("react");function s1(){let e=_e(),t=vs(),{initLoginWithHeadlessOAuth:r,loginWithHeadlessOAuth:o,isHeadlessOAuthLoading:n,ready:a,user:i}=V(),l=(0,Ta.useCallback)(async d=>{if(e.enabled&&e.status!=="success")throw new Tr(e.error,null,"captcha_failure");return r(d.provider,e.token)},[r,e]),s=(0,Ta.useCallback)(async()=>{let d=Ui();if(i)return console.warn("Cannot login with OAuth when already logged in"),i;if(!d.inProgress)throw new Error("Cannot login with OAuth because no OAuth flow is in progress");try{return await o(d)}catch(u){throw u}finally{Bi()}},[o]);return(0,Ta.useEffect)(()=>{let d=Ui();a&&t&&d.inProgress&&d.headless&&s()},[a,t]),{initOAuth:l,loginWithOAuth:s,loading:n}}var Rd=require("react");var l1=()=>{let e=_e(),{initLoginWithEmail:t,loginWithCode:r}=V(),o=(0,Rd.useCallback)(async({email:a})=>{if(!a)throw new Error("Email required to send OTP code");return t(a)},[t]),n=(0,Rd.useCallback)(async({code:a})=>{if(e.enabled&&e.status==="error")throw new Tr(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};var Id=require("react");var c1=()=>{let e=_e(),{initLoginWithSms:t,loginWithCode:r}=V(),o=(0,Id.useCallback)(async({phoneNumber:a})=>{if(!a)throw new Error("SMS required to send OTP code");return t(a)},[t]),n=(0,Id.useCallback)(async({code:a})=>{if(e.enabled&&e.status!=="success")throw new Tr(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:o,loginWithCode:n}};var d1=require("react");function p1(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:l,linkGithub:s,linkLinkedIn:d,linkTiktok:u,linkSpotify:v,linkFarcaster:h}=(0,d1.useContext)(ye);return De("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:a,linkTwitter:i,linkDiscord:l,linkGithub:s,linkLinkedIn:d,linkTiktok:u,linkSpotify:v,linkFarcaster:h}}var u1=require("react");function m1(e){let{connectWallet:t}=(0,u1.useContext)(ye);return De("connectWallet",e),{connectWallet:t}}var f1=require("react");function h1(e){let{createWallet:t}=(0,f1.useContext)(ye);return De("createWallet",e),{createWallet:t}}var y1=()=>{let{fundWallet:e}=V();return{fundWallet:e}};var g1=require("react");function v1(e){let{sendTransaction:t}=(0,g1.useContext)(ye);return De("sendTransaction",e),{sendTransaction:t}}var w1=require("react");function C1(e){let{setWalletPassword:t}=(0,w1.useContext)(ye);return De("setWalletPassword",e),{setWalletPassword:t}}var b1=require("react");function E1(e){let{signMessage:t}=(0,b1.useContext)(ye);return De("signMessage",e),{signMessage:t}}var T1=require("react");function P1(e){let{signTypedData:t}=(0,T1.useContext)(ye);return De("signTypedData",e),{signTypedData:t}}var x1=require("react");var S1=()=>{let{isModalOpen:e}=(0,x1.useContext)(ye);return{isOpen:e}};var _1=require("react");function A1(e){let{getAccessToken:t}=(0,_1.useContext)(ye);return De("accessToken",e),{getAccessToken:t}}function k1(){let{submitCast:e,removeCast:t,likeCast:r,recastCast:o,followUser:n,unfollowUser:a,requestFarcasterSigner:i}=V();return{followUser:n,unfollowUser:a,submitCast:e,removeCast:t,likeCast:r,recastCast:o,requestFarcasterSigner:i}}function R1(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}0&&(module.exports={AsExternalProvider,Captcha,ConnectorManager,PrivyClient,PrivyProvider,PrivyProxyProvider,SUPPORTED_CHAINS,VERSION,WalletConnector,addRpcUrlOverrideToChain,errorIndicatesMaxMfaRetries,errorIndicatesMfaTimeout,errorIndicatesMfaVerificationFailed,getAccessToken,useConnectWallet,useCreateWallet,useExperimentalFarcasterSigner,useFundWallet,useLinkAccount,useLogin,useLoginWithEmail,useLoginWithOAuth,useLoginWithSms,useLogout,useMfa,useMfaEnrollment,useModalStatus,usePrivy,useRegisterMfaListener,useSendTransaction,useSetWalletPassword,useSignMessage,useSignTypedData,useToken,useWallets});
|
package/package.json
CHANGED