@privy-io/react-auth 1.35.0-beta.9 → 1.35.0
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
|
@@ -9,7 +9,7 @@ Chain ID: ${t}
|
|
|
9
9
|
Nonce: ${a}
|
|
10
10
|
Issued At: ${i}
|
|
11
11
|
Resources:
|
|
12
|
-
- https://privy.io`;this.getNonceOnce=new We(this._getNonceOnce.bind(this)),this.wallet=t}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType}}async authenticate(){if(!this.api)throw new x("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Pa(),{message:t,signature:o,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType});return{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(t){throw Q(t)}}async link(){if(!this.api)throw new x("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign();return await this.api.post(_a(),{message:t,signature:o,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw Q(t)}}async sign(){if(!this.api)throw new x("Auth flow has no API instance");if(await this.buildSiweMessage(),!this.preparedMessage)throw new x("Could not prepare SIWE message");let t=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async _getNonceOnce(){if(!this.api)throw new x("Auth flow has no API instance");let t=this.wallet.address;return(await this.api.post(Ta(),{address:t})).nonce}async buildSiweMessage(){if(!this.api)throw new x("Auth flow has no API instance");let t=this.wallet.address,o=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=this.prepareMessage(o,t,this.nonce),this.preparedMessage}prepareMessage(t,o,r){let n=window.location.host,i=window.location.origin,a="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",l=new Date().toISOString();return this.createSiweMessage(t,o,n,i,l,r,a)}};var Xt=class{constructor(t,o){this.meta={phoneNumber:t,captchaToken:o}}async authenticate(){if(!this.api)throw new x("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new x("phone number and sms code must be set prior to calling authenticate.");try{let t=Ia(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw Q(t)}}async link(){if(!this.api)throw new x("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new x("phone number and sms code must be set prior to calling authenticate.");try{let t=Wa();return await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw Q(t)}}async sendSmsCode(t,o){if(!this.api)throw new x("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),o&&(this.meta.captchaToken=o),!this.meta.phoneNumber)throw new x("phone nNumber must be set when initialzing authentication.");try{let r=Ra();return await this.api.post(r,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(r){throw Q(r)}}};import{v4 as Np}from"uuid";function Qe(e){return new Date(e*1e3)}function Kd(e){let t=[];for(let o of e){let r=o.type;switch(o.type){case"wallet":let n={address:o.address,type:o.type,verifiedAt:Qe(o.verified_at),chainType:"ethereum",chainId:o.chain_id,walletClient:o.wallet_client_type==="privy"?"privy":"unknown",walletClientType:o.wallet_client_type,connectorType:o.connector_type,recoveryMethod:o.recovery_method};t.push(n);break;case"email":let i={address:o.address,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(i);break;case"phone":let a={number:o.phoneNumber,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(a);break;case"google_oauth":let l={subject:o.subject,email:o.email,name:o.name,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(l);break;case"twitter_oauth":let s={subject:o.subject,username:o.username,name:o.name,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(s);break;case"discord_oauth":let d={subject:o.subject,username:o.username,email:o.email,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(d);break;case"github_oauth":let w={subject:o.subject,username:o.username,name:o.name,email:o.email,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(w);break;case"apple_oauth":let y={subject:o.subject,email:o.email,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(y);break;case"custom_auth":t.push({type:o.type,customUserId:o.custom_user_id,verifiedAt:Qe(o.verified_at)});break;default:console.warn(`Unrecognized account type: ${r}. Please consider upgrading the Privy SDK.`)}}return t}function St(e,t){return e.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),e.find(o=>o.type===t)}var te=e=>e==null?void 0:e.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClient==="privy"),Yd=e=>e.linkedAccounts.filter(t=>t.type==="wallet"),kt=(e,t)=>{var o;return t==="all-users"&&!te(e)||t==="users-without-wallets"&&!((o=Yd(e))!=null&&o.length)};function ut(e){if(!e)return null;let t=Kd(e.linked_accounts),o=St(t,"wallet"),r=St(t,"email"),n=St(t,"phone"),i=St(t,"google_oauth"),a=St(t,"twitter_oauth"),l=St(t,"discord_oauth"),s=St(t,"github_oauth"),d=St(t,"apple_oauth");return{id:e.id,createdAt:Qe(e.created_at),linkedAccounts:t,email:r&&{address:r==null?void 0:r.address},phone:n&&{number:n==null?void 0:n.number},wallet:o&&{address:o.address,chainType:o.chainType,chainId:o.chainId,walletClient:o.walletClient,walletClientType:o.walletClientType,connectorType:o.connectorType,recoveryMethod:o.recoveryMethod},google:i&&{subject:i.subject,email:i.email,name:i.name},twitter:a&&{subject:a.subject,username:a.username,name:a.name},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:s&&{subject:s.subject,username:s.username,name:s.name,email:s.email},apple:d&&{subject:d.subject,email:d.email}}}import{getAddress as Fs}from"@ethersproject/address";import Sp from"eventemitter3";var Ha="1.35.0-beta.9";var Nr="4df5e2316331463a9130964bd6078dfa",za="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",Va="34357d3c125c2bcf2ce2bc3309d98715",$a="0x4AAAAAAAJFhr_rDU7HKpyw",Lr="https://auth.privy.io",qa=2e4,He=1400,ja=4500,Vn=Ha;var go="privy:token",$n="privy-token",Mr="privy:refresh_token",qn="privy-refresh-token",Jo="privy:session_transfer_token",Qd="privy:wallet",jn=e=>`${Qd}:${e}`,Kn="privy:connectors",Yn="privy:connections";var ze=1,Or="0x1";var Jn=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},Qn=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Zd(){return typeof window<"u"&&window.localStorage?new Qn:new Jn}var $=Zd();import{isPossiblePhoneNumber as Xd}from"libphonenumber-js/min";var Ka={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var Ya={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var Ja={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}};var Qa={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0};var Za={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var Xa={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var es={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1};var ts={id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0};var os={id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}};var rs={id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}};var ns={id:5,network:"goerli",name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-goerli.g.alchemy.com/v2"],webSocket:["wss://eth-goerli.g.alchemy.com/v2"]},infura:{http:["https://goerli.infura.io/v3"],webSocket:["wss://goerli.infura.io/ws/v3"]},default:{http:["https://rpc.ankr.com/eth_goerli"]},public:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli.etherscan.io"},default:{name:"Etherscan",url:"https://goerli.etherscan.io"}},testnet:!0};var is={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-mainnet.infura.io/v3"],webSocket:["wss://linea-mainnet.infura.io/ws/v3"]},default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1};var as={id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0};var ss={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}};var ls={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var cs={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var ds={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var ps={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mumbai.g.alchemy.com/v2"],webSocket:["wss://polygon-mumbai.g.alchemy.com/v2"]},infura:{http:["https://polygon-mumbai.infura.io/v3"],webSocket:["wss://polygon-mumbai.infura.io/ws/v3"]},default:{http:["https://matic-mumbai.chainstacklabs.com"]},public:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"},default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var us={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0};var eo=[Ka,Ya,ns,us,ss,ls,cs,ds,ps,es,ts,os,rs,Za,Xa,is,as,Ja,Qa],Zn=e=>eo.find(t=>t.id===e),mt=e=>{var t;return(t=Zn(e))==null?void 0:t.nativeCurrency.symbol};var Ur=()=>{let e=window;if(!e.ethereum)return!1;if(Dr(window.ethereum,!0))return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(Dr(t,!0))return!0}return!1},Qo=()=>{let e=window;if(!e.ethereum)return!1;if(Dr(window.ethereum,!1))return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(Dr(t,!1))return!0}return!1},Dr=(e,t)=>e.isMetaMask?e.isMetaMask&&!t?!0:!(e.isBraveWallet&&!e._events&&!e._state||e.isApexWallet||e.isAvalanche||e.isBitKeep||e.isBlockWallet||e.isKuCoinWallet||e.isMathWallet||e.isOkxWallet||e.isOKExWallet||e.isOneInchIOSWallet||e.isOneInchAndroidWallet||e.isOpera||e.isPhantom||e.isPortal||e.isRabby||e.isRainbow||e.isTokenPocket||e.isTokenary||e.isZerion):!1,Ne=()=>{var e,t;if("phantom"in window){let o=window;if((t=(e=o==null?void 0:o.phantom)==null?void 0:e.ethereum)!=null&&t.isPhantom)return!0}return!1},Rt=()=>{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.isCoinbaseWallet)return!0}return!1};var ms=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,}))$/),hs=e=>Xd(String(e),"US"),fs=(e,t)=>{let o=e.slice(0),r=[];for(;o.length;)r.push(o.splice(0,t));return r},vo=(e,t=3,o=4)=>{if(!e)return"";let r=2,n=3;if(t+o+r+n>=e.length)return e;let i=e.slice(0,r+t),a=e.slice(e.length-o,e.length);return`${i}...${a}`},Xn=e=>new Promise(t=>setTimeout(t,e)),ys=(e,t={})=>{let o=t.delayMs||150,r=t.maxAttempts||270;return new Promise(async(n,i)=>{var s;let a=!1,l=0;for(;!a&&l<r;){if((s=t.abortSignal)!=null&&s.aborted)return;e().then(()=>{a=!0,n()},(...d)=>{a=!0,i(...d)}),l+=1,await Xn(o)}a||i(new Error("Exceeded max attempts before resolving function"))})},Fr=(e,t,o={})=>{let r=new URL(t,e);for(let[n,i]of Object.entries(o))r.searchParams.set(n,i);return r.href};var ei=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),Zo=e=>typeof e=="string"?e:"0x"+e.toString(16);async function gs(e=3e3){let t=!1,o=window;return new Promise(r=>{o.ethereum?n():(window.addEventListener("ethereum#initialized",n,{once:!0}),setTimeout(()=>{n()},e));function n(){if(t)return;t=!0,window.removeEventListener("ethereum#initialized",n);let i=[];Ur()&&i.push("metamask"),Ne()&&i.push("phantom"),o.ethereum&&o.ethereum.isBraveWallet&&i.push("brave"),r(i)}})}function Br(e){return`eip155:${String(Number(e))}`}var Ze=(e,t)=>{var n,i,a;let o=eo.find(l=>l.id===e);if(!o)throw new B(`Unsupported chainId ${e}`,4901);let r;if(t.rpcUrls[e]?r=t.rpcUrls[e]:(n=o.rpcUrls.infura)!=null&&n.http[0]?r=o.rpcUrls.infura.http[0]+"/"+Nr:(i=o.rpcUrls.blast)!=null&&i.http[0]?r=o.rpcUrls.blast.http[0]+"/"+za:r=(a=o.rpcUrls.default)==null?void 0:a.http[0],!r)throw new B(`No RPC url found for ${e}`);return r};import cp from"@coinbase/wallet-sdk";import{jsx as vs,jsxs as ep}from"react/jsx-runtime";var Le=({style:e,...t})=>ep("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[vs("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),vs("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});import{getAddress as Lt}from"@ethersproject/address";import{Web3Provider as Ts}from"@ethersproject/providers";import{default as lp}from"eventemitter3";import{JsonRpcProvider as ws}from"@ethersproject/providers";import ap from"eventemitter3";var tp=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4"],bs=e=>tp.includes(e);import{ErrorCode as op}from"@ethersproject/logger";var bo=class extends B{constructor(){super("Wallet timeout");this.type="wallet_error"}},wo=class extends B{constructor(){super("User rejected connection");this.type="wallet_error"}},Xe=e=>{if(e instanceof B)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new It(e);return e.code===op.ACTION_REJECTED&&(t.details=ht.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new It(e):new B("Unknown connector error",e)},Xo=class extends Ge{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},It=class extends Xo{constructor(o){var i,a,l;let r=o;super(r.message,r.code,r.data);let n=Object.values(ht).find(s=>s.eipCode===r.code);this.details=n||ht.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=ht.E32002_CONNECTION_ALREADY_PENDING:this.details=ht.E32002_REQUEST_ALREADY_PENDING:(l=r.message)!=null&&l.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=ht.E32002_WALLET_LOCKED))}},rp={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},np={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},ip={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},ht={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...ip,...np},ft={...rp,...ht};var sp=12e4,ti=(e=new bo,t=sp)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),J=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(t,o)}catch{console.warn("Unable to remove wallet provider listener")}};this.setWalletProvider=t=>{this.walletProvider&&this._subscriptions.forEach(o=>{this.removeListener(o.eventName,o.listener)}),this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new B(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),ti()]).catch(o=>{throw Xe(o)})}},Wt=class extends Error{constructor(o,r,n){super(o);this.code=r,this.data=n}},Gr=class extends ap{constructor(o,r,n,i=1){super();this.walletProxy=o,this.address=r,this.chainId=i,this.rpcConfig=n,this.provider=new ws(Ze(i,n))}async handleSendTransaction(o){if(!o.params||!Array.isArray(o.params))throw new Wt(`Invalid params for ${o.method}`,4200);let r=o.params[0];if(!await yt()||!this.address)throw new Wt("Disconnected",4900);return(await Es(r)).transactionHash}handleSwitchEthereumChain(o){if(!o.params||!Array.isArray(o.params))throw new Wt(`Invalid params for ${o.method}`,4200);let r;if(typeof o.params[0]=="string")r=o.params[0];else if("chainId"in o.params[0]&&typeof o.params[0].chainId=="string")r=o.params[0].chainId;else throw new Wt(`Invalid params for ${o.method}`,4200);this.chainId=Number(r),this.provider=new ws(Ze(this.chainId,this.rpcConfig)),this.emit("chainChanged",r)}async handlePersonalSign(o){if(!o.params||!Array.isArray(o.params))throw new Error("Invalid params for eth_estimateGas");let r=o.params[0];return await Cs(r)}async handleEstimateGas(o){if(!o.params||!Array.isArray(o.params))throw new Error("Invalid params for eth_estimateGas");delete o.params[0].gasPrice,delete o.params[0].maxFeePerGas,delete o.params[0].maxPriorityFeePerGas;let r={...o.params[0],chainId:Zo(this.chainId)};try{return await this.provider.send("eth_estimateGas",[r])}catch{return delete r.from,await this.provider.send("eth_estimateGas",[r])}}async request(o){switch(console.debug("Embedded1193Provider.request() called with args",o),o.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return Zo(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(o);case"eth_sendTransaction":return this.handleSendTransaction(o);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(o);case"personal_sign":return this.handlePersonalSign(o);default:break}if(bs(o.method)){let r=await yt();if(await xs(),!r||!this.address)throw new Wt("Disconnected",4900);try{return(await this.walletProxy.rpc({address:this.address,accessToken:r,request:{method:o.method,params:o.params}})).response.data}catch(n){throw console.error(n),new Wt("Disconnected",4900)}}else return this.provider.send(o.method,o.params)}async connect(){let o=await yt();if(!o||!this.address)return null;try{return(await this.walletProxy.connect({address:this.address,accessToken:o})).address}catch(r){return console.error(r),null}}},et=class extends J{constructor(o){super(o)}},Nt=class extends J{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var xe=class extends lp{constructor(o){super();this.onAccountsChanged=o=>{o.length===0?this.onDisconnect():this.syncAccounts(o)};this.onChainChanged=o=>{this.wallets.forEach(r=>{r.chainId=Br(o),this.walletClientType==="privy"&&$.put(jn(r.address),o)}),this.emit("walletsUpdated")};this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")};this.onConnect=()=>{this.connected=!0,this.syncAccounts()};this.wallets=[],this.walletClientType=o,this.connected=!1,this.initialized=!1}buildConnectedWallet(o,r){let n=async()=>!!this.wallets.find(i=>Lt(i.address)===Lt(o));return{address:Lt(o),chainId:r,switchChain:async i=>{var w,y,g;if(!n)throw new B("Wallet is not currently connected.");let a,l;if(typeof i=="number"?(a=`0x${i.toString(16)}`,l=i):(a=i,l=Number(i)),r===Br(a))return;let s=Zn(l);if(!s)throw new B(`Unsupported chainId: ${i}`);let d=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:a}]})};try{return await d()}catch(p){if(p.code===4902||((w=p.message)==null?void 0:w.includes("4902")))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:a,chainName:s.name,nativeCurrency:s.nativeCurrency,rpcUrls:[((y=s.rpcUrls.public)==null?void 0:y.http[0])??""]}]}),d();throw this.walletClientType==="rainbow"&&((g=p.message)==null?void 0:g.includes("wallet_switchEthereumChain"))?new B(`Rainbow does not support the chainId ${r}`):p}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:n,getEthereumProvider:async()=>{if(!await n())throw new B("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await n())throw new B("Wallet is not currently connected.");return new Ts(new et(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await n())throw new B("Wallet is not currently connected.");return new Nt(this.proxyProvider)},sign:async i=>{if(!await n())throw new B("Wallet is not currently connected.");return await this.sign(i)},disconnect:()=>{this.disconnect()}}}async syncAccounts(o){let r=o;if(r===void 0){let d=await this.proxyProvider.request({method:"eth_accounts"});Array.isArray(d)&&(r=d)}if(!r||!Array.isArray(r)||r.length<=0||!r[0])return;let n=r[0],i=Lt(n),a=[],l;if(this.walletClientType==="privy"){l=$.get(jn(i))||Or;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:l}]})}catch{console.warn(`Unable to switch embedded wallet to chain ID ${l} on initialization`)}}else try{let d=await this.proxyProvider.request({method:"eth_chainId"});if(typeof d!="string")throw new Error("Invalid chainId returned from provider");l=d}catch(d){console.warn(`Failed to get chainId from provider, defaulting to ${Or}`,d),l=Or}let s=Br(l);a.find(d=>Lt(d.address)===i)||a.push(this.buildConnectedWallet(Lt(n),s)),Hr(a,this.wallets)||(this.wallets=a,this.emit("walletsUpdated"))}async getConnectedWallet(){let o=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort((r,n)=>n.connectedAt-r.connectedAt).find(r=>o.find(n=>Lt(n)===Lt(r.address)))||null}async isConnected(){let o=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(o)&&o.length>0}async sign(o){return await this.connect({showPrompt:!1}),new Ts(new et(this.proxyProvider)).getSigner().signMessage(o)}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}};var dp=e=>{let t=`https://mainnet.infura.io/v3/${Nr}`,o=1;return e.makeWeb3Provider(t,o)},zr,Vr=class extends xe{constructor(){super("coinbase_wallet");this.connectorType="coinbase_wallet";this.proxyProvider=new J,this.subscribeListeners(),zr||(zr=new cp({appName:"Privy",darkMode:!1,headlessMode:!1})),this.proxyProvider.setWalletProvider(dp(zr)),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){zr.disconnect()}get walletBranding(){return{name:"Coinbase Wallet",icon:Le}}async promptConnection(){try{let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new B("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([o[0]])}catch(o){throw Xe(o)}}};import{jsx as Ps}from"react/jsx-runtime";var Co=({...e})=>Ps("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:Ps("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:e.color||"var(--privy-color-foreground-3)"})});var $r=class extends xe{constructor(o){super("privy");this.connectorType="embedded";this.proxyProvider=o,this.subscribeListeners(),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[Zo((o==null?void 0:o.chainId)||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Co}}disconnect(){this.connected=!1}async promptConnection(){}};import{getAddress as cv}from"@ethersproject/address";import{Web3Provider as pv}from"@ethersproject/providers";import{isMobile as up}from"react-device-detect";import{jsx as Te,jsxs as pp}from"react/jsx-runtime";var he=({style:e,...t})=>pp("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...e},...t,children:[Te("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),Te("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),Te("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),Te("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),Te("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),Te("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),Te("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),Te("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),Te("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),Te("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),Te("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),Te("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),Te("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]});var qr=class extends xe{constructor(){super("metamask");this.connectorType="injected";this.proxyProvider=new J,this.subscribeListeners();let o=window,r=o.ethereum,n=o.ethereum.providers||[];for(let i of n)if(i.isMetaMask){r=i;break}this.proxyProvider.setWalletProvider(r),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:"MetaMask",icon:he}}disconnect(){console.warn("Metamask does not support programmatic disconnect.")}async promptConnection(){try{!up&&Ur()&&await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new B("Unable to retrieve accounts");await this.syncAccounts([o[0]])}catch(o){throw Xe(o)}}};import{jsx as _s,jsxs as mp}from"react/jsx-runtime";var Me=({style:e,...t})=>mp("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...e},...t,children:[_s("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),_s("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});var jr=class extends xe{constructor(){super("phantom");this.connectorType="injected";this.proxyProvider=new J,this.subscribeListeners(),this.proxyProvider.setWalletProvider(window.phantom.ethereum),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:"Phantom",icon:Me}}disconnect(){console.warn("Phantom does not support programmatic disconnect.")}async promptConnection(){try{let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new B("Unable to retrieve accounts");await this.syncAccounts([o[0]])}catch(o){throw Xe(o)}}};import{EthereumProvider as xp,OPTIONAL_EVENTS as Tp,OPTIONAL_METHODS as Pp}from"@walletconnect/ethereum-provider";import ni from"@walletconnect/qrcode-modal";import{isAndroid as _p,isMobile as Ap}from"react-device-detect";import{createContext as fp,useContext as yp,useEffect as oi,useState as Ss}from"react";import{jsx as hp}from"react/jsx-runtime";function As(e){return hp("link",{rel:"prefetch",href:e.src})}import{jsx as gp,jsxs as vp}from"react/jsx-runtime";var Ve="LANDING",ks=fp({ready:!1,app:null,currentScreen:Ve,lastScreen:Ve,navigate:T,navigateBack:T,resetNavigation:T,setModalData:T}),Rs=e=>{var w,y,g;let t=e.appConfig,o=e.authenticated,r=e.visible,[n,i]=Ss(e.initialScreen||Ve),[a,l]=Ss(e.initialScreen||Ve);oi(()=>{o||i(Ve)},[o]),oi(()=>{r||(l(Ve),i(Ve))},[r]),oi(()=>{e.initialScreen&&n===Ve&&(i(e.initialScreen),l(e.initialScreen))},[e.initialScreen]);let s=e.initialScreen&&n===Ve?e.initialScreen:n,d={ready:!!(t!=null&&t.id),app:t,data:e.data,setModalData:e.setModalData,currentScreen:s,lastScreen:a,navigate:p=>{l(n),i(p)},navigateBack:()=>{i(a)},resetNavigation:()=>{e.setInitialScreen(null),l(Ve),i(Ve)}};return vp(ks.Provider,{value:d,children:[(typeof((w=t==null?void 0:t.appearance)==null?void 0:w.logo)=="string"||((g=(y=t==null?void 0:t.appearance)==null?void 0:y.logo)==null?void 0:g.type)==="img")&&gp(As,{src:typeof t.appearance.logo=="string"?t.appearance.logo:t.appearance.logo.props.src}),e.children]})},E=()=>yp(ks);import{jsx as Eo,jsxs as bp}from"react/jsx-runtime";var xo=({style:e,...t})=>{let{app:o}=E();return bp("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[Eo("rect",{width:"28",height:"28",rx:"3",fill:(o==null?void 0:o.appearance.palette.colorScheme)==="dark"?"#3396ff":"#141414"}),Eo("g",{clipPath:"url(#clip0_1765_9946)",children:Eo("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),Eo("defs",{children:Eo("clipPath",{id:"clip0_1765_9946",children:Eo("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};import{isAndroid as Ws,isDesktop as wp,isMobileOnly as Cp}from"react-device-detect";var Kr=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[o,r]of Object.entries(Ns))if(r.hostname===t)return{walletClientType:o,entry:r}};var Ns={metamask:{id:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",displayName:"MetaMask",image_id:"5195e9db-94d8-4579-6f11-ef553be95100",hostname:"metamask.io",mobile:{native:"metamask:"}},trust:{id:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",displayName:"Trust",image_id:"0528ee7e-16d1-4089-21e3-bbfb41933100",hostname:"trustwallet.com",mobile:{universal:"https://link.trustwallet.com"}},safe:{id:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",displayName:"Safe",image_id:"a1cb2777-f8f9-49b0-53fd-443d20ee0b00",hostname:"safe.global",mobile:{universal:"https://app.safe.global/"}},rainbow:{id:"1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",displayName:"Rainbow",image_id:"7a33d7f1-3d12-4b5c-f3ee-5cd83cb1b500",hostname:"rainbow.me",mobile:{universal:"https://rnbwapp.com"}},uniswap:{id:"c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a",displayName:"Uniswap",image_id:"bff9cf1f-df19-42ce-f62a-87f04df13c00",hostname:"uniswap.org",mobile:{universal:"https://uniswap.org/app"}},zerion:{id:"ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18",displayName:"Zerion",image_id:"f216b371-96cf-409a-9d88-296392b85800",hostname:"zerion.io",mobile:{universal:"https://wallet.zerion.io"}},argent:{id:"bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6",displayName:"Argent",image_id:"215158d2-614b-49c9-410f-77aa661c3900",hostname:"www.argent.xyz",mobile:{universal:"https://www.argent.xyz/app"}},spot:{id:"74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d",displayName:"Spot",image_id:"1bf33a89-b049-4a1c-d1f6-4dd7419ee400",hostname:"www.spot-wallet.com",mobile:{universal:"https://spot.so"}},omni:{id:"afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7",displayName:"Omni",image_id:"2cd67b4c-282b-4809-e7c0-a88cd5116f00",hostname:"omni.app",mobile:{universal:"https://links.omni.app"}},cryptocom:{id:"f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d",displayName:"Crypto.com",image_id:"7c5ff577-a68d-49c5-02cd-3d83637b0b00",hostname:"crypto.com",mobile:{universal:"https://wallet.crypto.com"}},blockchain:{id:"84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04",displayName:"Blockchain",image_id:"6f913b80-86c0-46f9-61ca-cc90a1805900",hostname:"www.blockchain.com",mobile:{universal:"https://www.blockchain.com"}},safepal:{id:"0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150",displayName:"SafePal",image_id:"252753e7-b783-4e03-7f77-d39864530900",hostname:"safepal.com",mobile:{universal:"https://link.safepal.io"}},bitkeep:{id:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",displayName:"BitKeep",image_id:"3f7075d0-4ab7-4db5-404d-3e4c05e6fe00",hostname:"bitkeep.com",mobile:{universal:"https://bkapp.vip"}},zengo:{id:"9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0",displayName:"ZenGo",image_id:"cfc07342-23ea-4f3f-f071-ec9d2cd86b00",hostname:"zengo.com",mobile:{universal:"https://get.zengo.com/"}},"1inch":{id:"c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576",displayName:"1inch",image_id:"52b1da3c-9e72-40ae-5dac-6142addd9c00",hostname:"wallet.1inch.io",mobile:{universal:"https://wallet.1inch.io/wc/"}},binance:{id:"8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4",displayName:"Binance",image_id:"ebac7b39-688c-41e3-7912-a4fefba74600",hostname:"www.binance.com",mobile:{universal:"https://app.binance.com/cedefi"}},exodus:{id:"e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4",displayName:"Exodus",image_id:"4c16cad4-cac9-4643-6726-c696efaf5200",hostname:"exodus.com",mobile:{universal:"https://exodus.com/m"}},mew_wallet:{id:"f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2",displayName:"MEW wallet",image_id:"e2024511-2c9b-46d7-3111-52df3d241700",hostname:"mewwallet.com",mobile:{universal:"https://mewwallet.com"}},alphawallet:{id:"138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98",displayName:"AlphaWallet",image_id:"5b1cddfb-056e-4e78-029a-54de5d70c500",hostname:"alphawallet.com",mobile:{universal:"https://aw.app"}},keyring_pro:{id:"47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83",displayName:"KEYRING PRO",image_id:"dda0f0fb-34e8-4a57-dcea-b008e7d1ff00",hostname:"keyring.app",mobile:{universal:"https://keyring.app/"}},mathwallet:{id:"7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26",displayName:"MathWallet",image_id:"26a8f588-3231-4411-60ce-5bb6b805a700",hostname:"mathwallet.org",mobile:{universal:"https://www.mathwallet.org"}},unstoppable:{id:"8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3",displayName:"Unstoppable",image_id:"4725dda0-4471-4d0f-7adf-6bbe8b929c00",hostname:"unstoppabledomains.com",mobile:{universal:"https://unstoppabledomains.com/mobile"}},obvious:{id:"031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa",displayName:"Obvious",image_id:"61abe2ca-b06d-4a8b-de3e-8326f523e900",hostname:"obvious.technology",mobile:{universal:"https://wallet.obvious.technology"}},ambire:{id:"2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568",displayName:"Ambire",image_id:"c39b3a16-1a38-4588-f089-cb7aeb584700",hostname:"www.ambire.com",mobile:{universal:"https://mobile.ambire.com"}},internet_money_wallet:{id:"dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd",displayName:"Internet Money Wallet",image_id:"204b2240-5ce4-4996-6ec4-f06a22726900",hostname:"internetmoney.io",mobile:{universal:"https://internetmoney.io"}},coin98:{id:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",displayName:"Coin98",image_id:"fc460647-ea95-447a-99f0-1bff8fa4be00",hostname:"coin98.com",mobile:{universal:"https://coin98.services"}},abc_wallet:{id:"b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f",displayName:"ABC Wallet",image_id:"f9854c79-14ba-4987-42e1-4a82abbf5700",hostname:"myabcwallet.io",mobile:{universal:"https://abcwalletconnect.page.link"}},arculus_wallet:{id:"0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92",displayName:"Arculus Wallet",image_id:"f78dab27-7165-4a3d-fdb1-fcff06c0a700",hostname:"www.getarculus.com",mobile:{universal:"https://gw.arculus.co/app"}},haha:{id:"719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3",displayName:"HaHa",image_id:"79285c9f-2630-451e-0680-c71b42fb7400",hostname:"www.haha.me",mobile:{universal:"https://haha.me"}},cling_wallet:{id:"942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef",displayName:"Cling Wallet",image_id:"2d8006c3-852b-458a-d6b0-916c5ba76800",hostname:"clingon.io",mobile:{universal:"https://cling.carrieverse.com/apple-app-site-association"}},broearn:{id:"8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2",displayName:"Broearn",image_id:"339b9e9d-e2a7-46eb-4ed3-272321257a00",hostname:"www.broearn.com",mobile:{universal:"https://www.broearn.com/link/wallet/"}},copiosa:{id:"07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80",displayName:"Copiosa",image_id:"cae1be94-9f53-4eba-b915-f6e381d5a500",hostname:"copiosa.io",mobile:{universal:"https://copiosa.io/action/"}},burrito_wallet:{id:"8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819",displayName:"Burrito Wallet",image_id:"7eec7187-3f48-4fda-53bb-b0ad55749a00",hostname:"burritowallet.com",mobile:{universal:"https://burritowallet.com/wc?uri="}},enjin_wallet:{id:"bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a",displayName:"Enjin Wallet",image_id:"add9626b-a5fa-4c12-178c-e5584e6dcd00",hostname:"enjin.io",mobile:{universal:"https://deeplink.wallet.enjin.io/"}},plasma_wallet:{id:"cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e",displayName:"Plasma Wallet",image_id:"c268e78d-ffb0-4c8b-5cad-04c3add48500",hostname:"plasma-wallet.com",mobile:{universal:"https://plasma-wallet.com"}},avacus:{id:"94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43",displayName:"Avacus",image_id:"a7106965-91cc-4a73-4688-c5c72ae0ed00",hostname:"avacus.cc",mobile:{universal:"https://avacus.app.link"}},bee:{id:"2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715",displayName:"Bee",image_id:"f90bc33f-f085-40cf-7538-fae5ae84f900",hostname:"www.beewallet.app",mobile:{universal:"https://beewallet.app/wc"}},pitaka:{id:"14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc",displayName:"Pitaka",image_id:"691c0716-5213-4b99-e837-079268313800",hostname:"pitaka.io",mobile:{universal:"https://app.pitaka.io"}},pltwallet:{id:"576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd",displayName:"PLTwallet",image_id:"a5d9dd15-8cef-42de-8bed-09e01a8b0200",hostname:"pltwallet.io",mobile:{universal:"https://pltwallet.io/"}},minerva:{id:"49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd",displayName:"Minerva",image_id:"b57b2163-1bd8-4f6b-3311-470767e6d200",hostname:"minerva.digital",mobile:{universal:"https://minerva.digital"}},kryptogo:{id:"19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b",displayName:"KryptoGO",image_id:"3ccbd966-97e8-45a0-1ceb-6141a8978e00",hostname:"kryptogo.com",mobile:{universal:"https://kryptogo.page.link"}},prema:{id:"5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b",displayName:"PREMA",image_id:"6487869b-1165-4f30-aa3a-115665be8300",hostname:"premanft.com",mobile:{universal:"https://premanft.com"}},slingshot:{id:"d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b",displayName:"Slingshot",image_id:"10c75467-6612-48ad-b97b-63985e922200",hostname:"slingshot.finance",mobile:{universal:"https://app.slingshot.finance"}},kriptonio:{id:"50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b",displayName:"Kriptonio",image_id:"363fae03-882a-4d81-a721-6e6f6e9ac500",hostname:"kriptonio.com",mobile:{universal:"https://app.kriptonio.com/mobile"}},timeless:{id:"9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8",displayName:"Timeless",image_id:"32e89601-0490-42fc-0cc4-8627d62a2000",hostname:"timelesswallet.xyz",mobile:{universal:"https://timelesswallet.xyz"}},secux:{id:"6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa",displayName:"SecuX",image_id:"98183be0-3125-45ee-a6b6-fbd47ebefd00",hostname:"secuxtech.com",mobile:{universal:"https://wsweb.secuxtech.com"}},bitizen:{id:"41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071",displayName:"Bitizen",image_id:"75dd1471-77e9-4811-ce57-ec8fc980ec00",hostname:"bitizen.org",mobile:{universal:"https://bitizen.org/wallet"}},blocto:{id:"14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd",displayName:"Blocto",image_id:"374258d3-c749-4f37-7815-77e61f798c00",hostname:"blocto.io",mobile:{universal:"https://blocto.app"}},safemoon:{id:"a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1",displayName:"SafeMoon",image_id:"ea0140c7-787c-43a4-838f-d5ab6a342000",hostname:"safemoon.com",mobile:{universal:"https://safemoon.com/wc"}}},Ls=(e,t="md")=>`https://registry.walletconnect.com/v2/logo/${t}/${e}`;function ri(e){return{name:e.displayName||"",universalLink:e.mobile.universal||"",deepLink:e.mobile.native||""}}function Ep(e){let t="mobile";return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>ri(o))}function Ms(){return Ep(Ns)}function Os(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${e}`:""}function Ds(e,t){return Ws?e:Os(e,ri(t))}var Us="WALLETCONNECT_DEEPLINK_CHOICE";function Is(e){let t=e.href.split("?")[0];$.put(Us,{...e,href:t})}var er=(e,t)=>{if(!e||wp){$.del(Us);return}if(Ws){Is({name:"Unknown",href:t||"wc:"});return}else if(Cp){let o=Os(t||"wc:",ri(e));Is({name:(e==null?void 0:e.displayName)||"",href:o})}};var tr=class extends xe{constructor(o,r,n){super(n||"unknown");this.connectorType="wallet_connect_v2";this.walletConnectCloudProjectId=o,this.rpcConfig=r,this.proxyProvider=new J,this.createProvider().then(i=>{var a,l;if(this.provider=i,this.proxyProvider.setWalletProvider(i),this.subscribeListeners(),i.session){if((a=this.walletProvider.session)!=null&&a.peer.metadata.url){let s=Kr((l=this.walletProvider.session)==null?void 0:l.peer.metadata.url);this.walletEntry=s==null?void 0:s.entry,this.walletClientType=(s==null?void 0:s.walletClientType)||"unknown",er(this.walletEntry)}this.connected=!0,this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}else this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return this.walletProvider.connected}get walletBranding(){var o,r,n;return this.walletEntry?{name:this.walletEntry.displayName,icon:this.walletClientType==="metamask"?he:Ls(this.walletEntry.image_id)}:{name:ei(((o=this.walletProvider.session)==null?void 0:o.peer.metadata.name)||"")||"WalletConnect",icon:((n=(r=this.walletProvider.session)==null?void 0:r.peer.metadata.icons)==null?void 0:n[0])||xo}}resetConnection(){this.walletProvider&&this.walletProvider.connected&&(this.walletProvider.signer.session=void 0,this.walletEntry=void 0,er(void 0),this.onDisconnect())}async promptConnection(){if(!!this.provider)return new Promise((o,r)=>{let n=()=>{r(new wo)};this.onQrModalClosed=n,(async()=>{var s,d;let a="",l=await Promise.race([this.walletProvider.enable(),ti()]);if(l.length>0&&(a=l[0]),!a||a==="")throw new B("Unable to retrieve address");if((s=this.walletProvider.session)!=null&&s.peer.metadata.url){let w=Kr((d=this.walletProvider.session)==null?void 0:d.peer.metadata.url);this.walletEntry=w==null?void 0:w.entry,this.walletClientType=(w==null?void 0:w.walletClientType)||"unknown"}this.connected=!0,await this.syncAccounts(l),o()})().catch(a=>{if(a){r(Xe(a));return}r(new B("Unknown error during connection"))}).finally(()=>ni.close())})}disconnect(){this.walletProvider.disconnect().then(()=>this.onDisconnect()).catch(()=>console.warn("Unable to disconnect Wallet Connect provider"))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(o){this.proxyProvider.setWalletProvider(o)}async createProvider(){let o={};for(let n of eo){let i=Ze(n.id,this.rpcConfig);i&&(o[n.id]=i)}let r=await xp.init({projectId:this.walletConnectCloudProjectId,chains:[1],optionalChains:eo.map(n=>n.id),optionalEvents:Tp,optionalMethods:Pp,rpcMap:o,showQrModal:!1});return r.on("display_uri",n=>{if(_p)window.open(n,"_self");else if(Ap&&this.walletEntry){er(this.walletEntry,n);let a=Ds(n,this.walletEntry);window.open(a,"_self","noopener,noreferrer")}else ni.open(n,()=>{this.onQrModalClosed&&this.onQrModalClosed()},{mobileLinks:Ms().map(i=>i.name)})}),r.on("connect",()=>{var n,i;if(ni.close(),(n=r.session)!=null&&n.peer.metadata.url){let a=Kr((i=r.session)==null?void 0:i.peer.metadata.url);this.walletEntry=a==null?void 0:a.entry,this.walletClientType=(a==null?void 0:a.walletClientType)||"unknown",er(this.walletEntry)}}),r}async enableProvider(){return this.walletProvider.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider.enable()}};var ii=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses");return t?!!(e==null?void 0:e.linkedAccounts.filter(r=>r.type=="wallet"&&r.address===Fs(t)).length):!1},or=class extends Sp{constructor(o,r){super();this.getEthereumProvider=()=>{let o=this.wallets[0],r=this.walletConnectors.find(n=>n.wallets.find(i=>i.address===(o==null?void 0:o.address)));return!o||!r?new J:r.proxyProvider};this.walletConnectCloudProjectId=o,this.rpcConfig=r,this.walletConnectors=[],this.initialized=!1,this.storedConnections=this.loadConnectionHistory()}get wallets(){let o=new Set,r=this.walletConnectors.flatMap(i=>i.wallets).sort((i,a)=>i.connectedAt&&a.connectedAt?a.connectedAt-i.connectedAt:0).filter(i=>{let a=`${i.address}${i.walletClientType}${i.connectorType}`;return o.has(a)?!1:(o.add(a),!0)}),n=r.findIndex(i=>i.address===(this.activeWallet?this.activeWallet:"unknown"));return n>=0&&r.unshift(r.splice(n,1)[0]),r}initialize(){this.initialized||($.get(Kn)&&($.getKeys().forEach(o=>{o.startsWith("walletconnect")&&$.del(o)}),$.del(Kn)),gs().then(o=>o.forEach(r=>{switch(r){case"metamask":this.createWalletConnector("injected","metamask");break;case"phantom":this.createWalletConnector("injected","phantom");break;case"unknown":default:break}})),(Rt()||$.getKeys().find(o=>o.startsWith("-walletlink")))&&this.createWalletConnector("coinbase_wallet","coinbase_wallet"),this.createWalletConnector("wallet_connect_v2","unknown"),this.initialized=!0)}findWalletConnector(o,r){return o==="wallet_connect_v2"?this.walletConnectors.find(n=>n.connectorType===o)||null:this.walletConnectors.find(n=>n.connectorType===o&&n.walletClientType===r)||null}onInitialized(o){o.wallets.forEach(r=>{let n=this.storedConnections.find(i=>i.address===r.address&&i.connectorType===r.connectorType&&i.walletClientType===r.walletClientType);n&&(r.connectedAt=n.connectedAt)}),this.saveConnectionHistory(),this.emit("walletsUpdated")}onWalletsUpdated(o){o.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnector(o,r){if(!this.findWalletConnector("embedded","privy")){let i=new Gr(o,r,this.rpcConfig),a=new $r(i);this.addWalletConnector(a)}}removeEmbeddedWalletConnector(){let o=this.findWalletConnector("embedded","privy");if(o){let r=this.walletConnectors.indexOf(o);this.walletConnectors.splice(r,1),this.saveConnectionHistory(),this.emit("walletsUpdated")}}async createWalletConnector(o,r){let n=this.findWalletConnector(o,r);if(n)return n instanceof tr&&n.resetConnection(),n;let a=(()=>{switch(o){case"injected":switch(r){case"phantom":return Ne()?new jr:null;case"metamask":default:return Qo()?new qr:null}case"coinbase_wallet":return new Vr;case"wallet_connect_v2":return new tr(this.walletConnectCloudProjectId,this.rpcConfig)}})();return a&&this.addWalletConnector(a),a||null}addWalletConnector(o){this.walletConnectors.push(o),o.on("initialized",()=>this.onInitialized(o)),o.on("walletsUpdated",()=>this.onWalletsUpdated(o))}loadConnectionHistory(){let o=a=>a&&typeof a.address=="string"&&typeof a.connectorType=="string"&&typeof a.walletClientType=="string"&&typeof a.connectedAt=="number",r=$.get(Yn);return r&&Array.isArray(r)&&r.map(a=>o(a)).every(Boolean)?r:[]}saveConnectionHistory(){let o=this.wallets.map(r=>({address:r.address,connectorType:r.connectorType,walletClientType:r.walletClientType,connectedAt:r.connectedAt}));$.put(Yn,o)}async activeWalletSign(o){let r=this.wallets,n=r.length>0?r[0]:null;return n?n.sign(o):null}setActiveWallet(o){this.activeWallet=Fs(o),this.emit("walletsUpdated")}};function Hr(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++){let r=e[o],n=t[o];if((r==null?void 0:r.address)!==(n==null?void 0:n.address)||(r==null?void 0:r.chainId)!==(n==null?void 0:n.chainId)||(r==null?void 0:r.connectorType)!==(n==null?void 0:n.connectorType)||(r==null?void 0:r.connectedAt)!==(n==null?void 0:n.connectedAt)||(r==null?void 0:r.walletClientType)!==(n==null?void 0:n.walletClientType)||(r==null?void 0:r.isConnected)!==(n==null?void 0:n.isConnected)||(r==null?void 0:r.linked)!==(n==null?void 0:n.linked))return!1}return!0}import{ofetch as kp}from"ofetch";var Rp=[Ir(),Wr()],Ip=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Yr=class{constructor(t,o,r){this.appId=t,this.sdkVersion=Vn,this.client=o,this.defaults=r,this.fallbackApiUrl=o.fallbackApiUrl,this.baseFetch=kp.create({baseURL:this.defaults.baseURL,retry:3,retryDelay:500,credentials:"include",onRequest:async({request:n,options:i})=>{let a=new Headers(i.headers);a.set("privy-app-id",this.appId),a.set("privy-client",`react-auth:${this.sdkVersion}`);let l=!Rp.includes(n.toString());if(!a.has("authorization")&&l){let s=await this.client.getAccessToken();s!==null&&a.set("authorization",`Bearer ${s}`)}i.headers=a,i.signal||(i.signal=Ip(this.defaults.timeout))},onRequestError:({error:n})=>{if(n instanceof DOMException&&n.name==="AbortError")throw new Rr}})}async get(t,o){try{return await this.baseFetch(t,o)}catch(r){throw Q(r)}}async post(t,o,r){try{return await this.baseFetch(t,{method:"POST",...o?{body:o}:{},...r})}catch(n){throw Q(n)}}async delete(t,o){try{return await this.baseFetch(t,{method:"DELETE",...o})}catch(r){throw Q(r)}}};import Jr from"js-cookie";function Bs(e){return e instanceof Qt?"email":e instanceof Xt?"sms":e instanceof Zt?"siwe":e instanceof yo?"custom_auth":e instanceof At?e.meta.provider:null}import*as Gs from"jose";var tt=class{static parse(t){try{return new tt(t)}catch{return null}}constructor(t){this.value=t,this._decoded=Gs.decodeJwt(t)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(t=0){let o=Date.now(),r=(this.expiration-t)*1e3;return o>=r}};var Wp=30,Qr=class{constructor(){this.authenticateOnce=new We(async t=>this._authenticate(t)),this.linkOnce=new We(async t=>this._link(t)),this.refreshOnce=new We(this._refresh.bind(this)),this.destroyOnce=new We(this._destroy.bind(this)),this.forkSessionOnce=new We(this._forkSession.bind(this))}get token(){try{let t=$.get(go);return typeof t=="string"?new tt(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=$.get(Mr);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=$.get(Jo);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}hasRefreshCredentials(){var t;return((t=this.client)==null?void 0:t.useServerCookies)||typeof this.token=="string"&&typeof this.refreshToken=="string"}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=tt.parse(this.token);return t!==null&&!t.isExpired(Wp)}authenticate(t){return this.authenticateOnce.execute(t)}link(t){return this.linkOnce.execute(t)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(t){try{let{token:o,refresh_token:r,user:n,is_new_user:i}=await t.authenticate();this.storeToken(o),this.storeRefreshToken(r);let a=Bs(t);return a&&this.client&&this.client.createAnalyticsEvent("sdk_authenticate",{method:a,isNewUser:i}),a==="siwe"&&this.client&&this.client.createAnalyticsEvent("sdk_authenticate_siwe",{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}),{user:ut(n),isNewUser:i}}catch(o){throw console.warn("Error authenticating session"),Ie(o)}}async _link(t){try{let o=await t.link();return ut(o)}catch(o){throw console.warn("Error linking account"),Ie(o)}}async _refresh(){if(!this.api)throw new x("Session has no API instance");if(!this.client)throw new x("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,o=this.refreshToken,r=this.forkedToken;try{let n;if(t&&o)n=await this.api.post(Ir(),{refresh_token:o},{headers:{authorization:`Bearer ${t}`}}),r&&this.clearForkedToken();else if(r)n=await this.api.post(Wr(),{refresh_token:r}),this.clearForkedToken();else return null;return this.storeToken(n.token),this.storeRefreshToken(n.refresh_token),ut(n.user)}catch(n){if(n instanceof ho&&n.status===400&&n.message==="Invalid auth token")return this.destroyLocalState(),null;throw Ie(n)}}async _destroy(){var t;try{await((t=this.api)==null?void 0:t.post(Ea(),{refresh_token:this.refreshToken}))}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new x("Session has no API instance");let t=this.refreshToken;try{let o=await this.api.post(xa(),{refresh_token:t});return this.storeToken(o.token),this.storeRefreshToken(o.refresh_token),o.new_session_refresh_token}catch(o){throw Ie(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),this.clearForkedToken()}storeToken(t){var o,r;if(typeof t=="string"){if($.put(go,t),!((o=this.client)!=null&&o.useServerCookies)){let n=(r=tt.parse(t))==null?void 0:r.expiration;Jr.set($n,t,{sameSite:"Strict",secure:!0,expires:n?new Date(n*1e3):void 0})}}else $.del(go),Jr.remove($n)}storeRefreshToken(t){var o;typeof t=="string"?($.put(Mr,t),(o=this.client)!=null&&o.useServerCookies||Jr.set(qn,t,{sameSite:"Strict",secure:!0,expires:30})):($.del(Mr),Jr.remove(qn))}clearForkedToken(){$.del(Jo)}};var ai,rr=class{constructor(t){this.apiUrl=t.apiUrl||Lr,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!1,this.timeout=t.timeout||qa,this.appId=t.appId,this.clientAnalyticsId=typeof window>"u"?null:Np(),ai||(ai=new Qr),this.session=ai,this.api=this.generateApi(),this.session.client=this}initializeConnectorManager(t,o){this.connectors||(this.connectors=new or(t,o))}generateApi(){let t=new Yr(this.appId,this,{baseURL:this.apiUrl,timeout:this.timeout});return this.session.api=t,t}updateApiUrl(t){this.apiUrl=t||this.fallbackApiUrl,this.api=this.generateApi(),t&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new x("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new x("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.authFlow=void 0}startAuthFlow(t){t.api=this.api,this.authFlow=t}async unlinkEmail(t){try{let o=await this.api.post(Da(),{address:t});return ut(o)}catch(o){throw Ie(o)}}async unlinkPhone(t){try{let o=await this.api.post(Ua(),{phoneNumber:t});return ut(o)}catch(o){throw Ie(o)}}async unlinkWallet(t){try{let o=await this.api.post(Oa(),{address:t});return ut(o)}catch(o){throw Ie(o)}}async unlinkOAuth(t,o){try{let r=await this.api.post(Fa(),{provider:t,subject:o});return ut(r)}catch(r){throw Ie(r)}}async createAnalyticsEvent(t,o,r){if(!(typeof window>"u"))try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(Ba(),{event_name:t,client_id:this.clientAnalyticsId,payload:{...o||{},clientTimestamp:r?r.toISOString():new Date().toISOString()}})}catch{}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){var o;return this.session.hasActiveToken()?((o=tt.parse(this.session.token))==null?void 0:o.audience)!==this.appId?(await this.logout(),null):this.session.token:!(t!=null&&t.disableAutoRefresh)&&this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getServerConfig(){var t,o;try{let r=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl});return{id:r.id,name:r.name,verificationKey:r.verification_key,logoUrl:r.logo_url||void 0,accentColor:r.accent_color||void 0,showWalletLoginFirst:r.show_wallet_login_first,allowlistConfig:{errorTitle:r.allowlist_config.error_title,errorDetail:r.allowlist_config.error_detail,errorCtaText:r.allowlist_config.cta_text,errorCtaLink:r.allowlist_config.cta_link},walletAuth:r.wallet_auth,emailAuth:r.email_auth,smsAuth:r.sms_auth,googleOAuth:r.google_oauth,twitterOAuth:r.twitter_oauth,discordOAuth:r.discord_oauth,githubOAuth:r.github_oauth,appleOAuth:r.apple_oauth,termsAndConditionsUrl:r.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:(t=r.embedded_wallet_config)==null?void 0:t.create_on_login,requireUserPasswordOnCreate:(o=r.embedded_wallet_config)==null?void 0:o.require_user_password_on_create},privacyPolicyUrl:r.privacy_policy_url,customApiUrl:r.custom_api_url,walletConnectCloudProjectId:r.wallet_connect_cloud_project_id,captchaEnabled:r.captcha_enabled,createdAt:new Date(r.created_at*1e3),updatedAt:new Date(r.updated_at*1e3)}}catch(r){throw Ie(r)}}async getUsdTokenPrice(t){try{return(await this.api.get(`/api/v1/token_price?chainId=${t}`)).usd}catch{console.warn(`Unable to fetch token price for chain with id ${t}`);return}}async forkSession(){return await this.session.forkSession()}};import"wicg-inert";import{disableBodyScroll as ly,clearAllBodyScrollLocks as cy}from"body-scroll-lock";import{useRef as dy,useCallback as py}from"react";import{useEffect as Pd}from"react";import uy from"react-dom";import pa from"styled-components";import{createContext as Lp,useContext as Mp}from"react";var si=Lp({isNewUserThisSession:!1,isLinking:!1,linkingHint:null,walletConnectionStatus:null,rpcConfig:{rpcUrls:{}},captchaData:{enabled:!1,ready:!1,execute:T,remove:T,token:void 0,error:void 0},initializeWalletProxy:T,getAuthMeta:T,getAuthFlow:T,closePrivyModal:T,connectWallet:T,initLoginWithWallet:T,loginWithWallet:T,loginWithCode:T,initLoginWithEmail:T,initLoginWithSms:T,resendEmailCode:T,resendSmsCode:T,initLoginWithOAuth:T,loginWithOAuth:T,refreshUser:T,walletProxy:null,createAnalyticsEvent:T,getUsdTokenPrice:T,recoverEmbeddedWallet:T}),W=()=>Mp(si);import{createContext as Op,useContext as Dp}from"react";var gt=Op({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:T,login:T,linkEmail:T,linkPhone:T,linkWallet:T,linkGoogle:T,linkTwitter:T,linkDiscord:T,linkGithub:T,linkApple:T,logout:T,getAccessToken:T,getEthereumProvider:T,getEthersProvider:T,getWeb3jsProvider:T,unlinkEmail:T,unlinkPhone:T,unlinkWallet:T,unlinkGoogle:T,unlinkTwitter:T,unlinkDiscord:T,unlinkGithub:T,unlinkApple:T,setActiveWallet:T,forkSession:T,createWallet:T,signMessage:T,sendTransaction:T,exportWallet:T}),z=()=>Dp(gt);import mi from"styled-components";import To,{css as Hs}from"styled-components";import ci from"styled-components";import{Fragment as Bp,jsx as li,jsxs as Gp}from"react/jsx-runtime";var Zr=({success:e,fail:t})=>Gp(Bp,{children:[li(nr,{className:e?"success":t?"fail":""}),li(Up,{className:e?"success":t?"fail":""})]}),nr=ci.span`
|
|
12
|
+
- https://privy.io`;this.getNonceOnce=new We(this._getNonceOnce.bind(this)),this.wallet=t}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType}}async authenticate(){if(!this.api)throw new x("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Pa(),{message:t,signature:o,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType});return{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(t){throw Q(t)}}async link(){if(!this.api)throw new x("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign();return await this.api.post(_a(),{message:t,signature:o,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw Q(t)}}async sign(){if(!this.api)throw new x("Auth flow has no API instance");if(await this.buildSiweMessage(),!this.preparedMessage)throw new x("Could not prepare SIWE message");let t=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async _getNonceOnce(){if(!this.api)throw new x("Auth flow has no API instance");let t=this.wallet.address;return(await this.api.post(Ta(),{address:t})).nonce}async buildSiweMessage(){if(!this.api)throw new x("Auth flow has no API instance");let t=this.wallet.address,o=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=this.prepareMessage(o,t,this.nonce),this.preparedMessage}prepareMessage(t,o,r){let n=window.location.host,i=window.location.origin,a="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",l=new Date().toISOString();return this.createSiweMessage(t,o,n,i,l,r,a)}};var Xt=class{constructor(t,o){this.meta={phoneNumber:t,captchaToken:o}}async authenticate(){if(!this.api)throw new x("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new x("phone number and sms code must be set prior to calling authenticate.");try{let t=Ia(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw Q(t)}}async link(){if(!this.api)throw new x("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new x("phone number and sms code must be set prior to calling authenticate.");try{let t=Wa();return await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw Q(t)}}async sendSmsCode(t,o){if(!this.api)throw new x("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),o&&(this.meta.captchaToken=o),!this.meta.phoneNumber)throw new x("phone nNumber must be set when initialzing authentication.");try{let r=Ra();return await this.api.post(r,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(r){throw Q(r)}}};import{v4 as Np}from"uuid";function Qe(e){return new Date(e*1e3)}function Kd(e){let t=[];for(let o of e){let r=o.type;switch(o.type){case"wallet":let n={address:o.address,type:o.type,verifiedAt:Qe(o.verified_at),chainType:"ethereum",chainId:o.chain_id,walletClient:o.wallet_client_type==="privy"?"privy":"unknown",walletClientType:o.wallet_client_type,connectorType:o.connector_type,recoveryMethod:o.recovery_method};t.push(n);break;case"email":let i={address:o.address,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(i);break;case"phone":let a={number:o.phoneNumber,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(a);break;case"google_oauth":let l={subject:o.subject,email:o.email,name:o.name,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(l);break;case"twitter_oauth":let s={subject:o.subject,username:o.username,name:o.name,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(s);break;case"discord_oauth":let d={subject:o.subject,username:o.username,email:o.email,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(d);break;case"github_oauth":let w={subject:o.subject,username:o.username,name:o.name,email:o.email,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(w);break;case"apple_oauth":let y={subject:o.subject,email:o.email,type:o.type,verifiedAt:Qe(o.verified_at)};t.push(y);break;case"custom_auth":t.push({type:o.type,customUserId:o.custom_user_id,verifiedAt:Qe(o.verified_at)});break;default:console.warn(`Unrecognized account type: ${r}. Please consider upgrading the Privy SDK.`)}}return t}function St(e,t){return e.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),e.find(o=>o.type===t)}var te=e=>e==null?void 0:e.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClient==="privy"),Yd=e=>e.linkedAccounts.filter(t=>t.type==="wallet"),kt=(e,t)=>{var o;return t==="all-users"&&!te(e)||t==="users-without-wallets"&&!((o=Yd(e))!=null&&o.length)};function ut(e){if(!e)return null;let t=Kd(e.linked_accounts),o=St(t,"wallet"),r=St(t,"email"),n=St(t,"phone"),i=St(t,"google_oauth"),a=St(t,"twitter_oauth"),l=St(t,"discord_oauth"),s=St(t,"github_oauth"),d=St(t,"apple_oauth");return{id:e.id,createdAt:Qe(e.created_at),linkedAccounts:t,email:r&&{address:r==null?void 0:r.address},phone:n&&{number:n==null?void 0:n.number},wallet:o&&{address:o.address,chainType:o.chainType,chainId:o.chainId,walletClient:o.walletClient,walletClientType:o.walletClientType,connectorType:o.connectorType,recoveryMethod:o.recoveryMethod},google:i&&{subject:i.subject,email:i.email,name:i.name},twitter:a&&{subject:a.subject,username:a.username,name:a.name},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:s&&{subject:s.subject,username:s.username,name:s.name,email:s.email},apple:d&&{subject:d.subject,email:d.email}}}import{getAddress as Fs}from"@ethersproject/address";import Sp from"eventemitter3";var Ha="1.35.0";var Nr="4df5e2316331463a9130964bd6078dfa",za="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",Va="34357d3c125c2bcf2ce2bc3309d98715",$a="0x4AAAAAAAJFhr_rDU7HKpyw",Lr="https://auth.privy.io",qa=2e4,He=1400,ja=4500,Vn=Ha;var go="privy:token",$n="privy-token",Mr="privy:refresh_token",qn="privy-refresh-token",Jo="privy:session_transfer_token",Qd="privy:wallet",jn=e=>`${Qd}:${e}`,Kn="privy:connectors",Yn="privy:connections";var ze=1,Or="0x1";var Jn=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},Qn=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Zd(){return typeof window<"u"&&window.localStorage?new Qn:new Jn}var $=Zd();import{isPossiblePhoneNumber as Xd}from"libphonenumber-js/min";var Ka={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var Ya={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var Ja={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}};var Qa={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0};var Za={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var Xa={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var es={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1};var ts={id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0};var os={id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}};var rs={id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}};var ns={id:5,network:"goerli",name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-goerli.g.alchemy.com/v2"],webSocket:["wss://eth-goerli.g.alchemy.com/v2"]},infura:{http:["https://goerli.infura.io/v3"],webSocket:["wss://goerli.infura.io/ws/v3"]},default:{http:["https://rpc.ankr.com/eth_goerli"]},public:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli.etherscan.io"},default:{name:"Etherscan",url:"https://goerli.etherscan.io"}},testnet:!0};var is={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-mainnet.infura.io/v3"],webSocket:["wss://linea-mainnet.infura.io/ws/v3"]},default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1};var as={id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0};var ss={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}};var ls={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var cs={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var ds={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var ps={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mumbai.g.alchemy.com/v2"],webSocket:["wss://polygon-mumbai.g.alchemy.com/v2"]},infura:{http:["https://polygon-mumbai.infura.io/v3"],webSocket:["wss://polygon-mumbai.infura.io/ws/v3"]},default:{http:["https://matic-mumbai.chainstacklabs.com"]},public:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"},default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var us={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0};var eo=[Ka,Ya,ns,us,ss,ls,cs,ds,ps,es,ts,os,rs,Za,Xa,is,as,Ja,Qa],Zn=e=>eo.find(t=>t.id===e),mt=e=>{var t;return(t=Zn(e))==null?void 0:t.nativeCurrency.symbol};var Ur=()=>{let e=window;if(!e.ethereum)return!1;if(Dr(window.ethereum,!0))return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(Dr(t,!0))return!0}return!1},Qo=()=>{let e=window;if(!e.ethereum)return!1;if(Dr(window.ethereum,!1))return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(Dr(t,!1))return!0}return!1},Dr=(e,t)=>e.isMetaMask?e.isMetaMask&&!t?!0:!(e.isBraveWallet&&!e._events&&!e._state||e.isApexWallet||e.isAvalanche||e.isBitKeep||e.isBlockWallet||e.isKuCoinWallet||e.isMathWallet||e.isOkxWallet||e.isOKExWallet||e.isOneInchIOSWallet||e.isOneInchAndroidWallet||e.isOpera||e.isPhantom||e.isPortal||e.isRabby||e.isRainbow||e.isTokenPocket||e.isTokenary||e.isZerion):!1,Ne=()=>{var e,t;if("phantom"in window){let o=window;if((t=(e=o==null?void 0:o.phantom)==null?void 0:e.ethereum)!=null&&t.isPhantom)return!0}return!1},Rt=()=>{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.isCoinbaseWallet)return!0}return!1};var ms=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,}))$/),hs=e=>Xd(String(e),"US"),fs=(e,t)=>{let o=e.slice(0),r=[];for(;o.length;)r.push(o.splice(0,t));return r},vo=(e,t=3,o=4)=>{if(!e)return"";let r=2,n=3;if(t+o+r+n>=e.length)return e;let i=e.slice(0,r+t),a=e.slice(e.length-o,e.length);return`${i}...${a}`},Xn=e=>new Promise(t=>setTimeout(t,e)),ys=(e,t={})=>{let o=t.delayMs||150,r=t.maxAttempts||270;return new Promise(async(n,i)=>{var s;let a=!1,l=0;for(;!a&&l<r;){if((s=t.abortSignal)!=null&&s.aborted)return;e().then(()=>{a=!0,n()},(...d)=>{a=!0,i(...d)}),l+=1,await Xn(o)}a||i(new Error("Exceeded max attempts before resolving function"))})},Fr=(e,t,o={})=>{let r=new URL(t,e);for(let[n,i]of Object.entries(o))r.searchParams.set(n,i);return r.href};var ei=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),Zo=e=>typeof e=="string"?e:"0x"+e.toString(16);async function gs(e=3e3){let t=!1,o=window;return new Promise(r=>{o.ethereum?n():(window.addEventListener("ethereum#initialized",n,{once:!0}),setTimeout(()=>{n()},e));function n(){if(t)return;t=!0,window.removeEventListener("ethereum#initialized",n);let i=[];Ur()&&i.push("metamask"),Ne()&&i.push("phantom"),o.ethereum&&o.ethereum.isBraveWallet&&i.push("brave"),r(i)}})}function Br(e){return`eip155:${String(Number(e))}`}var Ze=(e,t)=>{var n,i,a;let o=eo.find(l=>l.id===e);if(!o)throw new B(`Unsupported chainId ${e}`,4901);let r;if(t.rpcUrls[e]?r=t.rpcUrls[e]:(n=o.rpcUrls.infura)!=null&&n.http[0]?r=o.rpcUrls.infura.http[0]+"/"+Nr:(i=o.rpcUrls.blast)!=null&&i.http[0]?r=o.rpcUrls.blast.http[0]+"/"+za:r=(a=o.rpcUrls.default)==null?void 0:a.http[0],!r)throw new B(`No RPC url found for ${e}`);return r};import cp from"@coinbase/wallet-sdk";import{jsx as vs,jsxs as ep}from"react/jsx-runtime";var Le=({style:e,...t})=>ep("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[vs("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),vs("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});import{getAddress as Lt}from"@ethersproject/address";import{Web3Provider as Ts}from"@ethersproject/providers";import{default as lp}from"eventemitter3";import{JsonRpcProvider as ws}from"@ethersproject/providers";import ap from"eventemitter3";var tp=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4"],bs=e=>tp.includes(e);import{ErrorCode as op}from"@ethersproject/logger";var bo=class extends B{constructor(){super("Wallet timeout");this.type="wallet_error"}},wo=class extends B{constructor(){super("User rejected connection");this.type="wallet_error"}},Xe=e=>{if(e instanceof B)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new It(e);return e.code===op.ACTION_REJECTED&&(t.details=ht.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new It(e):new B("Unknown connector error",e)},Xo=class extends Ge{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},It=class extends Xo{constructor(o){var i,a,l;let r=o;super(r.message,r.code,r.data);let n=Object.values(ht).find(s=>s.eipCode===r.code);this.details=n||ht.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=ht.E32002_CONNECTION_ALREADY_PENDING:this.details=ht.E32002_REQUEST_ALREADY_PENDING:(l=r.message)!=null&&l.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=ht.E32002_WALLET_LOCKED))}},rp={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},np={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},ip={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},ht={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...ip,...np},ft={...rp,...ht};var sp=12e4,ti=(e=new bo,t=sp)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),J=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(t,o)}catch{console.warn("Unable to remove wallet provider listener")}};this.setWalletProvider=t=>{this.walletProvider&&this._subscriptions.forEach(o=>{this.removeListener(o.eventName,o.listener)}),this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new B(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),ti()]).catch(o=>{throw Xe(o)})}},Wt=class extends Error{constructor(o,r,n){super(o);this.code=r,this.data=n}},Gr=class extends ap{constructor(o,r,n,i=1){super();this.walletProxy=o,this.address=r,this.chainId=i,this.rpcConfig=n,this.provider=new ws(Ze(i,n))}async handleSendTransaction(o){if(!o.params||!Array.isArray(o.params))throw new Wt(`Invalid params for ${o.method}`,4200);let r=o.params[0];if(!await yt()||!this.address)throw new Wt("Disconnected",4900);return(await Es(r)).transactionHash}handleSwitchEthereumChain(o){if(!o.params||!Array.isArray(o.params))throw new Wt(`Invalid params for ${o.method}`,4200);let r;if(typeof o.params[0]=="string")r=o.params[0];else if("chainId"in o.params[0]&&typeof o.params[0].chainId=="string")r=o.params[0].chainId;else throw new Wt(`Invalid params for ${o.method}`,4200);this.chainId=Number(r),this.provider=new ws(Ze(this.chainId,this.rpcConfig)),this.emit("chainChanged",r)}async handlePersonalSign(o){if(!o.params||!Array.isArray(o.params))throw new Error("Invalid params for eth_estimateGas");let r=o.params[0];return await Cs(r)}async handleEstimateGas(o){if(!o.params||!Array.isArray(o.params))throw new Error("Invalid params for eth_estimateGas");delete o.params[0].gasPrice,delete o.params[0].maxFeePerGas,delete o.params[0].maxPriorityFeePerGas;let r={...o.params[0],chainId:Zo(this.chainId)};try{return await this.provider.send("eth_estimateGas",[r])}catch{return delete r.from,await this.provider.send("eth_estimateGas",[r])}}async request(o){switch(console.debug("Embedded1193Provider.request() called with args",o),o.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return Zo(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(o);case"eth_sendTransaction":return this.handleSendTransaction(o);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(o);case"personal_sign":return this.handlePersonalSign(o);default:break}if(bs(o.method)){let r=await yt();if(await xs(),!r||!this.address)throw new Wt("Disconnected",4900);try{return(await this.walletProxy.rpc({address:this.address,accessToken:r,request:{method:o.method,params:o.params}})).response.data}catch(n){throw console.error(n),new Wt("Disconnected",4900)}}else return this.provider.send(o.method,o.params)}async connect(){let o=await yt();if(!o||!this.address)return null;try{return(await this.walletProxy.connect({address:this.address,accessToken:o})).address}catch(r){return console.error(r),null}}},et=class extends J{constructor(o){super(o)}},Nt=class extends J{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var xe=class extends lp{constructor(o){super();this.onAccountsChanged=o=>{o.length===0?this.onDisconnect():this.syncAccounts(o)};this.onChainChanged=o=>{this.wallets.forEach(r=>{r.chainId=Br(o),this.walletClientType==="privy"&&$.put(jn(r.address),o)}),this.emit("walletsUpdated")};this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")};this.onConnect=()=>{this.connected=!0,this.syncAccounts()};this.wallets=[],this.walletClientType=o,this.connected=!1,this.initialized=!1}buildConnectedWallet(o,r){let n=async()=>!!this.wallets.find(i=>Lt(i.address)===Lt(o));return{address:Lt(o),chainId:r,switchChain:async i=>{var w,y,g;if(!n)throw new B("Wallet is not currently connected.");let a,l;if(typeof i=="number"?(a=`0x${i.toString(16)}`,l=i):(a=i,l=Number(i)),r===Br(a))return;let s=Zn(l);if(!s)throw new B(`Unsupported chainId: ${i}`);let d=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:a}]})};try{return await d()}catch(p){if(p.code===4902||((w=p.message)==null?void 0:w.includes("4902")))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:a,chainName:s.name,nativeCurrency:s.nativeCurrency,rpcUrls:[((y=s.rpcUrls.public)==null?void 0:y.http[0])??""]}]}),d();throw this.walletClientType==="rainbow"&&((g=p.message)==null?void 0:g.includes("wallet_switchEthereumChain"))?new B(`Rainbow does not support the chainId ${r}`):p}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:n,getEthereumProvider:async()=>{if(!await n())throw new B("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await n())throw new B("Wallet is not currently connected.");return new Ts(new et(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await n())throw new B("Wallet is not currently connected.");return new Nt(this.proxyProvider)},sign:async i=>{if(!await n())throw new B("Wallet is not currently connected.");return await this.sign(i)},disconnect:()=>{this.disconnect()}}}async syncAccounts(o){let r=o;if(r===void 0){let d=await this.proxyProvider.request({method:"eth_accounts"});Array.isArray(d)&&(r=d)}if(!r||!Array.isArray(r)||r.length<=0||!r[0])return;let n=r[0],i=Lt(n),a=[],l;if(this.walletClientType==="privy"){l=$.get(jn(i))||Or;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:l}]})}catch{console.warn(`Unable to switch embedded wallet to chain ID ${l} on initialization`)}}else try{let d=await this.proxyProvider.request({method:"eth_chainId"});if(typeof d!="string")throw new Error("Invalid chainId returned from provider");l=d}catch(d){console.warn(`Failed to get chainId from provider, defaulting to ${Or}`,d),l=Or}let s=Br(l);a.find(d=>Lt(d.address)===i)||a.push(this.buildConnectedWallet(Lt(n),s)),Hr(a,this.wallets)||(this.wallets=a,this.emit("walletsUpdated"))}async getConnectedWallet(){let o=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort((r,n)=>n.connectedAt-r.connectedAt).find(r=>o.find(n=>Lt(n)===Lt(r.address)))||null}async isConnected(){let o=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(o)&&o.length>0}async sign(o){return await this.connect({showPrompt:!1}),new Ts(new et(this.proxyProvider)).getSigner().signMessage(o)}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}};var dp=e=>{let t=`https://mainnet.infura.io/v3/${Nr}`,o=1;return e.makeWeb3Provider(t,o)},zr,Vr=class extends xe{constructor(){super("coinbase_wallet");this.connectorType="coinbase_wallet";this.proxyProvider=new J,this.subscribeListeners(),zr||(zr=new cp({appName:"Privy",darkMode:!1,headlessMode:!1})),this.proxyProvider.setWalletProvider(dp(zr)),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){zr.disconnect()}get walletBranding(){return{name:"Coinbase Wallet",icon:Le}}async promptConnection(){try{let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new B("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([o[0]])}catch(o){throw Xe(o)}}};import{jsx as Ps}from"react/jsx-runtime";var Co=({...e})=>Ps("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:Ps("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:e.color||"var(--privy-color-foreground-3)"})});var $r=class extends xe{constructor(o){super("privy");this.connectorType="embedded";this.proxyProvider=o,this.subscribeListeners(),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[Zo((o==null?void 0:o.chainId)||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Co}}disconnect(){this.connected=!1}async promptConnection(){}};import{getAddress as cv}from"@ethersproject/address";import{Web3Provider as pv}from"@ethersproject/providers";import{isMobile as up}from"react-device-detect";import{jsx as Te,jsxs as pp}from"react/jsx-runtime";var he=({style:e,...t})=>pp("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...e},...t,children:[Te("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),Te("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),Te("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),Te("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),Te("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),Te("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),Te("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),Te("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),Te("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),Te("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),Te("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),Te("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),Te("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]});var qr=class extends xe{constructor(){super("metamask");this.connectorType="injected";this.proxyProvider=new J,this.subscribeListeners();let o=window,r=o.ethereum,n=o.ethereum.providers||[];for(let i of n)if(i.isMetaMask){r=i;break}this.proxyProvider.setWalletProvider(r),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:"MetaMask",icon:he}}disconnect(){console.warn("Metamask does not support programmatic disconnect.")}async promptConnection(){try{!up&&Ur()&&await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new B("Unable to retrieve accounts");await this.syncAccounts([o[0]])}catch(o){throw Xe(o)}}};import{jsx as _s,jsxs as mp}from"react/jsx-runtime";var Me=({style:e,...t})=>mp("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...e},...t,children:[_s("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),_s("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});var jr=class extends xe{constructor(){super("phantom");this.connectorType="injected";this.proxyProvider=new J,this.subscribeListeners(),this.proxyProvider.setWalletProvider(window.phantom.ethereum),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:"Phantom",icon:Me}}disconnect(){console.warn("Phantom does not support programmatic disconnect.")}async promptConnection(){try{let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new B("Unable to retrieve accounts");await this.syncAccounts([o[0]])}catch(o){throw Xe(o)}}};import{EthereumProvider as xp,OPTIONAL_EVENTS as Tp,OPTIONAL_METHODS as Pp}from"@walletconnect/ethereum-provider";import ni from"@walletconnect/qrcode-modal";import{isAndroid as _p,isMobile as Ap}from"react-device-detect";import{createContext as fp,useContext as yp,useEffect as oi,useState as Ss}from"react";import{jsx as hp}from"react/jsx-runtime";function As(e){return hp("link",{rel:"prefetch",href:e.src})}import{jsx as gp,jsxs as vp}from"react/jsx-runtime";var Ve="LANDING",ks=fp({ready:!1,app:null,currentScreen:Ve,lastScreen:Ve,navigate:T,navigateBack:T,resetNavigation:T,setModalData:T}),Rs=e=>{var w,y,g;let t=e.appConfig,o=e.authenticated,r=e.visible,[n,i]=Ss(e.initialScreen||Ve),[a,l]=Ss(e.initialScreen||Ve);oi(()=>{o||i(Ve)},[o]),oi(()=>{r||(l(Ve),i(Ve))},[r]),oi(()=>{e.initialScreen&&n===Ve&&(i(e.initialScreen),l(e.initialScreen))},[e.initialScreen]);let s=e.initialScreen&&n===Ve?e.initialScreen:n,d={ready:!!(t!=null&&t.id),app:t,data:e.data,setModalData:e.setModalData,currentScreen:s,lastScreen:a,navigate:p=>{l(n),i(p)},navigateBack:()=>{i(a)},resetNavigation:()=>{e.setInitialScreen(null),l(Ve),i(Ve)}};return vp(ks.Provider,{value:d,children:[(typeof((w=t==null?void 0:t.appearance)==null?void 0:w.logo)=="string"||((g=(y=t==null?void 0:t.appearance)==null?void 0:y.logo)==null?void 0:g.type)==="img")&&gp(As,{src:typeof t.appearance.logo=="string"?t.appearance.logo:t.appearance.logo.props.src}),e.children]})},E=()=>yp(ks);import{jsx as Eo,jsxs as bp}from"react/jsx-runtime";var xo=({style:e,...t})=>{let{app:o}=E();return bp("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[Eo("rect",{width:"28",height:"28",rx:"3",fill:(o==null?void 0:o.appearance.palette.colorScheme)==="dark"?"#3396ff":"#141414"}),Eo("g",{clipPath:"url(#clip0_1765_9946)",children:Eo("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),Eo("defs",{children:Eo("clipPath",{id:"clip0_1765_9946",children:Eo("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};import{isAndroid as Ws,isDesktop as wp,isMobileOnly as Cp}from"react-device-detect";var Kr=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[o,r]of Object.entries(Ns))if(r.hostname===t)return{walletClientType:o,entry:r}};var Ns={metamask:{id:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",displayName:"MetaMask",image_id:"5195e9db-94d8-4579-6f11-ef553be95100",hostname:"metamask.io",mobile:{native:"metamask:"}},trust:{id:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",displayName:"Trust",image_id:"0528ee7e-16d1-4089-21e3-bbfb41933100",hostname:"trustwallet.com",mobile:{universal:"https://link.trustwallet.com"}},safe:{id:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",displayName:"Safe",image_id:"a1cb2777-f8f9-49b0-53fd-443d20ee0b00",hostname:"safe.global",mobile:{universal:"https://app.safe.global/"}},rainbow:{id:"1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",displayName:"Rainbow",image_id:"7a33d7f1-3d12-4b5c-f3ee-5cd83cb1b500",hostname:"rainbow.me",mobile:{universal:"https://rnbwapp.com"}},uniswap:{id:"c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a",displayName:"Uniswap",image_id:"bff9cf1f-df19-42ce-f62a-87f04df13c00",hostname:"uniswap.org",mobile:{universal:"https://uniswap.org/app"}},zerion:{id:"ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18",displayName:"Zerion",image_id:"f216b371-96cf-409a-9d88-296392b85800",hostname:"zerion.io",mobile:{universal:"https://wallet.zerion.io"}},argent:{id:"bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6",displayName:"Argent",image_id:"215158d2-614b-49c9-410f-77aa661c3900",hostname:"www.argent.xyz",mobile:{universal:"https://www.argent.xyz/app"}},spot:{id:"74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d",displayName:"Spot",image_id:"1bf33a89-b049-4a1c-d1f6-4dd7419ee400",hostname:"www.spot-wallet.com",mobile:{universal:"https://spot.so"}},omni:{id:"afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7",displayName:"Omni",image_id:"2cd67b4c-282b-4809-e7c0-a88cd5116f00",hostname:"omni.app",mobile:{universal:"https://links.omni.app"}},cryptocom:{id:"f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d",displayName:"Crypto.com",image_id:"7c5ff577-a68d-49c5-02cd-3d83637b0b00",hostname:"crypto.com",mobile:{universal:"https://wallet.crypto.com"}},blockchain:{id:"84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04",displayName:"Blockchain",image_id:"6f913b80-86c0-46f9-61ca-cc90a1805900",hostname:"www.blockchain.com",mobile:{universal:"https://www.blockchain.com"}},safepal:{id:"0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150",displayName:"SafePal",image_id:"252753e7-b783-4e03-7f77-d39864530900",hostname:"safepal.com",mobile:{universal:"https://link.safepal.io"}},bitkeep:{id:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",displayName:"BitKeep",image_id:"3f7075d0-4ab7-4db5-404d-3e4c05e6fe00",hostname:"bitkeep.com",mobile:{universal:"https://bkapp.vip"}},zengo:{id:"9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0",displayName:"ZenGo",image_id:"cfc07342-23ea-4f3f-f071-ec9d2cd86b00",hostname:"zengo.com",mobile:{universal:"https://get.zengo.com/"}},"1inch":{id:"c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576",displayName:"1inch",image_id:"52b1da3c-9e72-40ae-5dac-6142addd9c00",hostname:"wallet.1inch.io",mobile:{universal:"https://wallet.1inch.io/wc/"}},binance:{id:"8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4",displayName:"Binance",image_id:"ebac7b39-688c-41e3-7912-a4fefba74600",hostname:"www.binance.com",mobile:{universal:"https://app.binance.com/cedefi"}},exodus:{id:"e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4",displayName:"Exodus",image_id:"4c16cad4-cac9-4643-6726-c696efaf5200",hostname:"exodus.com",mobile:{universal:"https://exodus.com/m"}},mew_wallet:{id:"f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2",displayName:"MEW wallet",image_id:"e2024511-2c9b-46d7-3111-52df3d241700",hostname:"mewwallet.com",mobile:{universal:"https://mewwallet.com"}},alphawallet:{id:"138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98",displayName:"AlphaWallet",image_id:"5b1cddfb-056e-4e78-029a-54de5d70c500",hostname:"alphawallet.com",mobile:{universal:"https://aw.app"}},keyring_pro:{id:"47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83",displayName:"KEYRING PRO",image_id:"dda0f0fb-34e8-4a57-dcea-b008e7d1ff00",hostname:"keyring.app",mobile:{universal:"https://keyring.app/"}},mathwallet:{id:"7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26",displayName:"MathWallet",image_id:"26a8f588-3231-4411-60ce-5bb6b805a700",hostname:"mathwallet.org",mobile:{universal:"https://www.mathwallet.org"}},unstoppable:{id:"8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3",displayName:"Unstoppable",image_id:"4725dda0-4471-4d0f-7adf-6bbe8b929c00",hostname:"unstoppabledomains.com",mobile:{universal:"https://unstoppabledomains.com/mobile"}},obvious:{id:"031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa",displayName:"Obvious",image_id:"61abe2ca-b06d-4a8b-de3e-8326f523e900",hostname:"obvious.technology",mobile:{universal:"https://wallet.obvious.technology"}},ambire:{id:"2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568",displayName:"Ambire",image_id:"c39b3a16-1a38-4588-f089-cb7aeb584700",hostname:"www.ambire.com",mobile:{universal:"https://mobile.ambire.com"}},internet_money_wallet:{id:"dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd",displayName:"Internet Money Wallet",image_id:"204b2240-5ce4-4996-6ec4-f06a22726900",hostname:"internetmoney.io",mobile:{universal:"https://internetmoney.io"}},coin98:{id:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",displayName:"Coin98",image_id:"fc460647-ea95-447a-99f0-1bff8fa4be00",hostname:"coin98.com",mobile:{universal:"https://coin98.services"}},abc_wallet:{id:"b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f",displayName:"ABC Wallet",image_id:"f9854c79-14ba-4987-42e1-4a82abbf5700",hostname:"myabcwallet.io",mobile:{universal:"https://abcwalletconnect.page.link"}},arculus_wallet:{id:"0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92",displayName:"Arculus Wallet",image_id:"f78dab27-7165-4a3d-fdb1-fcff06c0a700",hostname:"www.getarculus.com",mobile:{universal:"https://gw.arculus.co/app"}},haha:{id:"719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3",displayName:"HaHa",image_id:"79285c9f-2630-451e-0680-c71b42fb7400",hostname:"www.haha.me",mobile:{universal:"https://haha.me"}},cling_wallet:{id:"942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef",displayName:"Cling Wallet",image_id:"2d8006c3-852b-458a-d6b0-916c5ba76800",hostname:"clingon.io",mobile:{universal:"https://cling.carrieverse.com/apple-app-site-association"}},broearn:{id:"8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2",displayName:"Broearn",image_id:"339b9e9d-e2a7-46eb-4ed3-272321257a00",hostname:"www.broearn.com",mobile:{universal:"https://www.broearn.com/link/wallet/"}},copiosa:{id:"07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80",displayName:"Copiosa",image_id:"cae1be94-9f53-4eba-b915-f6e381d5a500",hostname:"copiosa.io",mobile:{universal:"https://copiosa.io/action/"}},burrito_wallet:{id:"8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819",displayName:"Burrito Wallet",image_id:"7eec7187-3f48-4fda-53bb-b0ad55749a00",hostname:"burritowallet.com",mobile:{universal:"https://burritowallet.com/wc?uri="}},enjin_wallet:{id:"bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a",displayName:"Enjin Wallet",image_id:"add9626b-a5fa-4c12-178c-e5584e6dcd00",hostname:"enjin.io",mobile:{universal:"https://deeplink.wallet.enjin.io/"}},plasma_wallet:{id:"cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e",displayName:"Plasma Wallet",image_id:"c268e78d-ffb0-4c8b-5cad-04c3add48500",hostname:"plasma-wallet.com",mobile:{universal:"https://plasma-wallet.com"}},avacus:{id:"94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43",displayName:"Avacus",image_id:"a7106965-91cc-4a73-4688-c5c72ae0ed00",hostname:"avacus.cc",mobile:{universal:"https://avacus.app.link"}},bee:{id:"2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715",displayName:"Bee",image_id:"f90bc33f-f085-40cf-7538-fae5ae84f900",hostname:"www.beewallet.app",mobile:{universal:"https://beewallet.app/wc"}},pitaka:{id:"14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc",displayName:"Pitaka",image_id:"691c0716-5213-4b99-e837-079268313800",hostname:"pitaka.io",mobile:{universal:"https://app.pitaka.io"}},pltwallet:{id:"576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd",displayName:"PLTwallet",image_id:"a5d9dd15-8cef-42de-8bed-09e01a8b0200",hostname:"pltwallet.io",mobile:{universal:"https://pltwallet.io/"}},minerva:{id:"49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd",displayName:"Minerva",image_id:"b57b2163-1bd8-4f6b-3311-470767e6d200",hostname:"minerva.digital",mobile:{universal:"https://minerva.digital"}},kryptogo:{id:"19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b",displayName:"KryptoGO",image_id:"3ccbd966-97e8-45a0-1ceb-6141a8978e00",hostname:"kryptogo.com",mobile:{universal:"https://kryptogo.page.link"}},prema:{id:"5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b",displayName:"PREMA",image_id:"6487869b-1165-4f30-aa3a-115665be8300",hostname:"premanft.com",mobile:{universal:"https://premanft.com"}},slingshot:{id:"d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b",displayName:"Slingshot",image_id:"10c75467-6612-48ad-b97b-63985e922200",hostname:"slingshot.finance",mobile:{universal:"https://app.slingshot.finance"}},kriptonio:{id:"50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b",displayName:"Kriptonio",image_id:"363fae03-882a-4d81-a721-6e6f6e9ac500",hostname:"kriptonio.com",mobile:{universal:"https://app.kriptonio.com/mobile"}},timeless:{id:"9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8",displayName:"Timeless",image_id:"32e89601-0490-42fc-0cc4-8627d62a2000",hostname:"timelesswallet.xyz",mobile:{universal:"https://timelesswallet.xyz"}},secux:{id:"6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa",displayName:"SecuX",image_id:"98183be0-3125-45ee-a6b6-fbd47ebefd00",hostname:"secuxtech.com",mobile:{universal:"https://wsweb.secuxtech.com"}},bitizen:{id:"41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071",displayName:"Bitizen",image_id:"75dd1471-77e9-4811-ce57-ec8fc980ec00",hostname:"bitizen.org",mobile:{universal:"https://bitizen.org/wallet"}},blocto:{id:"14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd",displayName:"Blocto",image_id:"374258d3-c749-4f37-7815-77e61f798c00",hostname:"blocto.io",mobile:{universal:"https://blocto.app"}},safemoon:{id:"a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1",displayName:"SafeMoon",image_id:"ea0140c7-787c-43a4-838f-d5ab6a342000",hostname:"safemoon.com",mobile:{universal:"https://safemoon.com/wc"}}},Ls=(e,t="md")=>`https://registry.walletconnect.com/v2/logo/${t}/${e}`;function ri(e){return{name:e.displayName||"",universalLink:e.mobile.universal||"",deepLink:e.mobile.native||""}}function Ep(e){let t="mobile";return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>ri(o))}function Ms(){return Ep(Ns)}function Os(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${e}`:""}function Ds(e,t){return Ws?e:Os(e,ri(t))}var Us="WALLETCONNECT_DEEPLINK_CHOICE";function Is(e){let t=e.href.split("?")[0];$.put(Us,{...e,href:t})}var er=(e,t)=>{if(!e||wp){$.del(Us);return}if(Ws){Is({name:"Unknown",href:t||"wc:"});return}else if(Cp){let o=Os(t||"wc:",ri(e));Is({name:(e==null?void 0:e.displayName)||"",href:o})}};var tr=class extends xe{constructor(o,r,n){super(n||"unknown");this.connectorType="wallet_connect_v2";this.walletConnectCloudProjectId=o,this.rpcConfig=r,this.proxyProvider=new J,this.createProvider().then(i=>{var a,l;if(this.provider=i,this.proxyProvider.setWalletProvider(i),this.subscribeListeners(),i.session){if((a=this.walletProvider.session)!=null&&a.peer.metadata.url){let s=Kr((l=this.walletProvider.session)==null?void 0:l.peer.metadata.url);this.walletEntry=s==null?void 0:s.entry,this.walletClientType=(s==null?void 0:s.walletClientType)||"unknown",er(this.walletEntry)}this.connected=!0,this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}else this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return this.walletProvider.connected}get walletBranding(){var o,r,n;return this.walletEntry?{name:this.walletEntry.displayName,icon:this.walletClientType==="metamask"?he:Ls(this.walletEntry.image_id)}:{name:ei(((o=this.walletProvider.session)==null?void 0:o.peer.metadata.name)||"")||"WalletConnect",icon:((n=(r=this.walletProvider.session)==null?void 0:r.peer.metadata.icons)==null?void 0:n[0])||xo}}resetConnection(){this.walletProvider&&this.walletProvider.connected&&(this.walletProvider.signer.session=void 0,this.walletEntry=void 0,er(void 0),this.onDisconnect())}async promptConnection(){if(!!this.provider)return new Promise((o,r)=>{let n=()=>{r(new wo)};this.onQrModalClosed=n,(async()=>{var s,d;let a="",l=await Promise.race([this.walletProvider.enable(),ti()]);if(l.length>0&&(a=l[0]),!a||a==="")throw new B("Unable to retrieve address");if((s=this.walletProvider.session)!=null&&s.peer.metadata.url){let w=Kr((d=this.walletProvider.session)==null?void 0:d.peer.metadata.url);this.walletEntry=w==null?void 0:w.entry,this.walletClientType=(w==null?void 0:w.walletClientType)||"unknown"}this.connected=!0,await this.syncAccounts(l),o()})().catch(a=>{if(a){r(Xe(a));return}r(new B("Unknown error during connection"))}).finally(()=>ni.close())})}disconnect(){this.walletProvider.disconnect().then(()=>this.onDisconnect()).catch(()=>console.warn("Unable to disconnect Wallet Connect provider"))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(o){this.proxyProvider.setWalletProvider(o)}async createProvider(){let o={};for(let n of eo){let i=Ze(n.id,this.rpcConfig);i&&(o[n.id]=i)}let r=await xp.init({projectId:this.walletConnectCloudProjectId,chains:[1],optionalChains:eo.map(n=>n.id),optionalEvents:Tp,optionalMethods:Pp,rpcMap:o,showQrModal:!1});return r.on("display_uri",n=>{if(_p)window.open(n,"_self");else if(Ap&&this.walletEntry){er(this.walletEntry,n);let a=Ds(n,this.walletEntry);window.open(a,"_self","noopener,noreferrer")}else ni.open(n,()=>{this.onQrModalClosed&&this.onQrModalClosed()},{mobileLinks:Ms().map(i=>i.name)})}),r.on("connect",()=>{var n,i;if(ni.close(),(n=r.session)!=null&&n.peer.metadata.url){let a=Kr((i=r.session)==null?void 0:i.peer.metadata.url);this.walletEntry=a==null?void 0:a.entry,this.walletClientType=(a==null?void 0:a.walletClientType)||"unknown",er(this.walletEntry)}}),r}async enableProvider(){return this.walletProvider.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider.enable()}};var ii=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses");return t?!!(e==null?void 0:e.linkedAccounts.filter(r=>r.type=="wallet"&&r.address===Fs(t)).length):!1},or=class extends Sp{constructor(o,r){super();this.getEthereumProvider=()=>{let o=this.wallets[0],r=this.walletConnectors.find(n=>n.wallets.find(i=>i.address===(o==null?void 0:o.address)));return!o||!r?new J:r.proxyProvider};this.walletConnectCloudProjectId=o,this.rpcConfig=r,this.walletConnectors=[],this.initialized=!1,this.storedConnections=this.loadConnectionHistory()}get wallets(){let o=new Set,r=this.walletConnectors.flatMap(i=>i.wallets).sort((i,a)=>i.connectedAt&&a.connectedAt?a.connectedAt-i.connectedAt:0).filter(i=>{let a=`${i.address}${i.walletClientType}${i.connectorType}`;return o.has(a)?!1:(o.add(a),!0)}),n=r.findIndex(i=>i.address===(this.activeWallet?this.activeWallet:"unknown"));return n>=0&&r.unshift(r.splice(n,1)[0]),r}initialize(){this.initialized||($.get(Kn)&&($.getKeys().forEach(o=>{o.startsWith("walletconnect")&&$.del(o)}),$.del(Kn)),gs().then(o=>o.forEach(r=>{switch(r){case"metamask":this.createWalletConnector("injected","metamask");break;case"phantom":this.createWalletConnector("injected","phantom");break;case"unknown":default:break}})),(Rt()||$.getKeys().find(o=>o.startsWith("-walletlink")))&&this.createWalletConnector("coinbase_wallet","coinbase_wallet"),this.createWalletConnector("wallet_connect_v2","unknown"),this.initialized=!0)}findWalletConnector(o,r){return o==="wallet_connect_v2"?this.walletConnectors.find(n=>n.connectorType===o)||null:this.walletConnectors.find(n=>n.connectorType===o&&n.walletClientType===r)||null}onInitialized(o){o.wallets.forEach(r=>{let n=this.storedConnections.find(i=>i.address===r.address&&i.connectorType===r.connectorType&&i.walletClientType===r.walletClientType);n&&(r.connectedAt=n.connectedAt)}),this.saveConnectionHistory(),this.emit("walletsUpdated")}onWalletsUpdated(o){o.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnector(o,r){if(!this.findWalletConnector("embedded","privy")){let i=new Gr(o,r,this.rpcConfig),a=new $r(i);this.addWalletConnector(a)}}removeEmbeddedWalletConnector(){let o=this.findWalletConnector("embedded","privy");if(o){let r=this.walletConnectors.indexOf(o);this.walletConnectors.splice(r,1),this.saveConnectionHistory(),this.emit("walletsUpdated")}}async createWalletConnector(o,r){let n=this.findWalletConnector(o,r);if(n)return n instanceof tr&&n.resetConnection(),n;let a=(()=>{switch(o){case"injected":switch(r){case"phantom":return Ne()?new jr:null;case"metamask":default:return Qo()?new qr:null}case"coinbase_wallet":return new Vr;case"wallet_connect_v2":return new tr(this.walletConnectCloudProjectId,this.rpcConfig)}})();return a&&this.addWalletConnector(a),a||null}addWalletConnector(o){this.walletConnectors.push(o),o.on("initialized",()=>this.onInitialized(o)),o.on("walletsUpdated",()=>this.onWalletsUpdated(o))}loadConnectionHistory(){let o=a=>a&&typeof a.address=="string"&&typeof a.connectorType=="string"&&typeof a.walletClientType=="string"&&typeof a.connectedAt=="number",r=$.get(Yn);return r&&Array.isArray(r)&&r.map(a=>o(a)).every(Boolean)?r:[]}saveConnectionHistory(){let o=this.wallets.map(r=>({address:r.address,connectorType:r.connectorType,walletClientType:r.walletClientType,connectedAt:r.connectedAt}));$.put(Yn,o)}async activeWalletSign(o){let r=this.wallets,n=r.length>0?r[0]:null;return n?n.sign(o):null}setActiveWallet(o){this.activeWallet=Fs(o),this.emit("walletsUpdated")}};function Hr(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++){let r=e[o],n=t[o];if((r==null?void 0:r.address)!==(n==null?void 0:n.address)||(r==null?void 0:r.chainId)!==(n==null?void 0:n.chainId)||(r==null?void 0:r.connectorType)!==(n==null?void 0:n.connectorType)||(r==null?void 0:r.connectedAt)!==(n==null?void 0:n.connectedAt)||(r==null?void 0:r.walletClientType)!==(n==null?void 0:n.walletClientType)||(r==null?void 0:r.isConnected)!==(n==null?void 0:n.isConnected)||(r==null?void 0:r.linked)!==(n==null?void 0:n.linked))return!1}return!0}import{ofetch as kp}from"ofetch";var Rp=[Ir(),Wr()],Ip=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Yr=class{constructor(t,o,r){this.appId=t,this.sdkVersion=Vn,this.client=o,this.defaults=r,this.fallbackApiUrl=o.fallbackApiUrl,this.baseFetch=kp.create({baseURL:this.defaults.baseURL,retry:3,retryDelay:500,credentials:"include",onRequest:async({request:n,options:i})=>{let a=new Headers(i.headers);a.set("privy-app-id",this.appId),a.set("privy-client",`react-auth:${this.sdkVersion}`);let l=!Rp.includes(n.toString());if(!a.has("authorization")&&l){let s=await this.client.getAccessToken();s!==null&&a.set("authorization",`Bearer ${s}`)}i.headers=a,i.signal||(i.signal=Ip(this.defaults.timeout))},onRequestError:({error:n})=>{if(n instanceof DOMException&&n.name==="AbortError")throw new Rr}})}async get(t,o){try{return await this.baseFetch(t,o)}catch(r){throw Q(r)}}async post(t,o,r){try{return await this.baseFetch(t,{method:"POST",...o?{body:o}:{},...r})}catch(n){throw Q(n)}}async delete(t,o){try{return await this.baseFetch(t,{method:"DELETE",...o})}catch(r){throw Q(r)}}};import Jr from"js-cookie";function Bs(e){return e instanceof Qt?"email":e instanceof Xt?"sms":e instanceof Zt?"siwe":e instanceof yo?"custom_auth":e instanceof At?e.meta.provider:null}import*as Gs from"jose";var tt=class{static parse(t){try{return new tt(t)}catch{return null}}constructor(t){this.value=t,this._decoded=Gs.decodeJwt(t)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(t=0){let o=Date.now(),r=(this.expiration-t)*1e3;return o>=r}};var Wp=30,Qr=class{constructor(){this.authenticateOnce=new We(async t=>this._authenticate(t)),this.linkOnce=new We(async t=>this._link(t)),this.refreshOnce=new We(this._refresh.bind(this)),this.destroyOnce=new We(this._destroy.bind(this)),this.forkSessionOnce=new We(this._forkSession.bind(this))}get token(){try{let t=$.get(go);return typeof t=="string"?new tt(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=$.get(Mr);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=$.get(Jo);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}hasRefreshCredentials(){var t;return((t=this.client)==null?void 0:t.useServerCookies)||typeof this.token=="string"&&typeof this.refreshToken=="string"}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=tt.parse(this.token);return t!==null&&!t.isExpired(Wp)}authenticate(t){return this.authenticateOnce.execute(t)}link(t){return this.linkOnce.execute(t)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(t){try{let{token:o,refresh_token:r,user:n,is_new_user:i}=await t.authenticate();this.storeToken(o),this.storeRefreshToken(r);let a=Bs(t);return a&&this.client&&this.client.createAnalyticsEvent("sdk_authenticate",{method:a,isNewUser:i}),a==="siwe"&&this.client&&this.client.createAnalyticsEvent("sdk_authenticate_siwe",{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}),{user:ut(n),isNewUser:i}}catch(o){throw console.warn("Error authenticating session"),Ie(o)}}async _link(t){try{let o=await t.link();return ut(o)}catch(o){throw console.warn("Error linking account"),Ie(o)}}async _refresh(){if(!this.api)throw new x("Session has no API instance");if(!this.client)throw new x("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,o=this.refreshToken,r=this.forkedToken;try{let n;if(t&&o)n=await this.api.post(Ir(),{refresh_token:o},{headers:{authorization:`Bearer ${t}`}}),r&&this.clearForkedToken();else if(r)n=await this.api.post(Wr(),{refresh_token:r}),this.clearForkedToken();else return null;return this.storeToken(n.token),this.storeRefreshToken(n.refresh_token),ut(n.user)}catch(n){if(n instanceof ho&&n.status===400&&n.message==="Invalid auth token")return this.destroyLocalState(),null;throw Ie(n)}}async _destroy(){var t;try{await((t=this.api)==null?void 0:t.post(Ea(),{refresh_token:this.refreshToken}))}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new x("Session has no API instance");let t=this.refreshToken;try{let o=await this.api.post(xa(),{refresh_token:t});return this.storeToken(o.token),this.storeRefreshToken(o.refresh_token),o.new_session_refresh_token}catch(o){throw Ie(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),this.clearForkedToken()}storeToken(t){var o,r;if(typeof t=="string"){if($.put(go,t),!((o=this.client)!=null&&o.useServerCookies)){let n=(r=tt.parse(t))==null?void 0:r.expiration;Jr.set($n,t,{sameSite:"Strict",secure:!0,expires:n?new Date(n*1e3):void 0})}}else $.del(go),Jr.remove($n)}storeRefreshToken(t){var o;typeof t=="string"?($.put(Mr,t),(o=this.client)!=null&&o.useServerCookies||Jr.set(qn,t,{sameSite:"Strict",secure:!0,expires:30})):($.del(Mr),Jr.remove(qn))}clearForkedToken(){$.del(Jo)}};var ai,rr=class{constructor(t){this.apiUrl=t.apiUrl||Lr,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!1,this.timeout=t.timeout||qa,this.appId=t.appId,this.clientAnalyticsId=typeof window>"u"?null:Np(),ai||(ai=new Qr),this.session=ai,this.api=this.generateApi(),this.session.client=this}initializeConnectorManager(t,o){this.connectors||(this.connectors=new or(t,o))}generateApi(){let t=new Yr(this.appId,this,{baseURL:this.apiUrl,timeout:this.timeout});return this.session.api=t,t}updateApiUrl(t){this.apiUrl=t||this.fallbackApiUrl,this.api=this.generateApi(),t&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new x("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new x("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.authFlow=void 0}startAuthFlow(t){t.api=this.api,this.authFlow=t}async unlinkEmail(t){try{let o=await this.api.post(Da(),{address:t});return ut(o)}catch(o){throw Ie(o)}}async unlinkPhone(t){try{let o=await this.api.post(Ua(),{phoneNumber:t});return ut(o)}catch(o){throw Ie(o)}}async unlinkWallet(t){try{let o=await this.api.post(Oa(),{address:t});return ut(o)}catch(o){throw Ie(o)}}async unlinkOAuth(t,o){try{let r=await this.api.post(Fa(),{provider:t,subject:o});return ut(r)}catch(r){throw Ie(r)}}async createAnalyticsEvent(t,o,r){if(!(typeof window>"u"))try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(Ba(),{event_name:t,client_id:this.clientAnalyticsId,payload:{...o||{},clientTimestamp:r?r.toISOString():new Date().toISOString()}})}catch{}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){var o;return this.session.hasActiveToken()?((o=tt.parse(this.session.token))==null?void 0:o.audience)!==this.appId?(await this.logout(),null):this.session.token:!(t!=null&&t.disableAutoRefresh)&&this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getServerConfig(){var t,o;try{let r=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl});return{id:r.id,name:r.name,verificationKey:r.verification_key,logoUrl:r.logo_url||void 0,accentColor:r.accent_color||void 0,showWalletLoginFirst:r.show_wallet_login_first,allowlistConfig:{errorTitle:r.allowlist_config.error_title,errorDetail:r.allowlist_config.error_detail,errorCtaText:r.allowlist_config.cta_text,errorCtaLink:r.allowlist_config.cta_link},walletAuth:r.wallet_auth,emailAuth:r.email_auth,smsAuth:r.sms_auth,googleOAuth:r.google_oauth,twitterOAuth:r.twitter_oauth,discordOAuth:r.discord_oauth,githubOAuth:r.github_oauth,appleOAuth:r.apple_oauth,termsAndConditionsUrl:r.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:(t=r.embedded_wallet_config)==null?void 0:t.create_on_login,requireUserPasswordOnCreate:(o=r.embedded_wallet_config)==null?void 0:o.require_user_password_on_create},privacyPolicyUrl:r.privacy_policy_url,customApiUrl:r.custom_api_url,walletConnectCloudProjectId:r.wallet_connect_cloud_project_id,captchaEnabled:r.captcha_enabled,createdAt:new Date(r.created_at*1e3),updatedAt:new Date(r.updated_at*1e3)}}catch(r){throw Ie(r)}}async getUsdTokenPrice(t){try{return(await this.api.get(`/api/v1/token_price?chainId=${t}`)).usd}catch{console.warn(`Unable to fetch token price for chain with id ${t}`);return}}async forkSession(){return await this.session.forkSession()}};import"wicg-inert";import{disableBodyScroll as ly,clearAllBodyScrollLocks as cy}from"body-scroll-lock";import{useRef as dy,useCallback as py}from"react";import{useEffect as Pd}from"react";import uy from"react-dom";import pa from"styled-components";import{createContext as Lp,useContext as Mp}from"react";var si=Lp({isNewUserThisSession:!1,isLinking:!1,linkingHint:null,walletConnectionStatus:null,rpcConfig:{rpcUrls:{}},captchaData:{enabled:!1,ready:!1,execute:T,remove:T,token:void 0,error:void 0},initializeWalletProxy:T,getAuthMeta:T,getAuthFlow:T,closePrivyModal:T,connectWallet:T,initLoginWithWallet:T,loginWithWallet:T,loginWithCode:T,initLoginWithEmail:T,initLoginWithSms:T,resendEmailCode:T,resendSmsCode:T,initLoginWithOAuth:T,loginWithOAuth:T,refreshUser:T,walletProxy:null,createAnalyticsEvent:T,getUsdTokenPrice:T,recoverEmbeddedWallet:T}),W=()=>Mp(si);import{createContext as Op,useContext as Dp}from"react";var gt=Op({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:T,login:T,linkEmail:T,linkPhone:T,linkWallet:T,linkGoogle:T,linkTwitter:T,linkDiscord:T,linkGithub:T,linkApple:T,logout:T,getAccessToken:T,getEthereumProvider:T,getEthersProvider:T,getWeb3jsProvider:T,unlinkEmail:T,unlinkPhone:T,unlinkWallet:T,unlinkGoogle:T,unlinkTwitter:T,unlinkDiscord:T,unlinkGithub:T,unlinkApple:T,setActiveWallet:T,forkSession:T,createWallet:T,signMessage:T,sendTransaction:T,exportWallet:T}),z=()=>Dp(gt);import mi from"styled-components";import To,{css as Hs}from"styled-components";import ci from"styled-components";import{Fragment as Bp,jsx as li,jsxs as Gp}from"react/jsx-runtime";var Zr=({success:e,fail:t})=>Gp(Bp,{children:[li(nr,{className:e?"success":t?"fail":""}),li(Up,{className:e?"success":t?"fail":""})]}),nr=ci.span`
|
|
13
13
|
&& {
|
|
14
14
|
width: 82px;
|
|
15
15
|
height: 82px;
|
|
@@ -2116,4 +2116,4 @@ Resources:
|
|
|
2116
2116
|
align-items: center;
|
|
2117
2117
|
justify-content: center;
|
|
2118
2118
|
height: 100%;
|
|
2119
|
-
`;import{useEffect as Cy}from"react";import{Fragment as xy,jsx as Ty}from"react/jsx-runtime";var Ey=({onLoad:e})=>{let t=window;return Cy(()=>{if(document.getElementById("cf-script")!==null||t.turnstile)return;t.onloadTurnstileCallback=e;let o=document.createElement("script");o.setAttribute("src","https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback&render=explicit"),o.setAttribute("id","cf-script"),o.setAttribute("async","true"),document.body.appendChild(o)},[]),Ty(xy,{})},Ad=Ey;import $o from"tinycolor2";var Sd="#FFFFFF",Py="#000000",_y=Sd,Ay="#1E1E1D";function Sy(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function jt(e,t){let o=Math.max(0,Math.min(1,e.toHsl().l+t));return $o({...e.toHsl(),l:o})}function kd({backgroundTheme:e,accentHex:t,successHex:o="#51BA81",errorHex:r="#EC6351",whiteHex:n=Sd,blackHex:i=Py}){let a;switch(e){case"light":a=_y;break;case"dark":a=Ay;break;default:a=e;break}let l=$o(a),s=$o(t),d=$o(o),w=$o(r),y=Sy(l.getLuminance()),g=jt(l,y==="light"?-.04:.11),p=jt(l,y==="light"?-.88:.87),b=jt(l,y==="light"?-.77:.75),f=jt(l,y==="light"?-.43:.45).desaturate(y==="light"?60:20),C=jt(l,y==="light"?-.08:.25).desaturate(y==="light"?60:20),k=jt(s,.15),v=jt(s,-.06),L=$o(s.getLuminance()>.5?i:n),_=jt(d,-.16);return{colorScheme:y,background:l.toHslString(),background2:g.toHslString(),foreground:p.toHslString(),foreground2:b.toHslString(),foreground3:f.toHslString(),foreground4:C.toHslString(),accent:s.toHslString(),accentLight:k.toHslString(),accentDark:v.toHslString(),foregroundAccent:L.toHslString(),success:d.toHslString(),successDark:_.toHslString(),error:w.toHslString()}}var co={appearance:{theme:"light",accentColor:"#676FFF"},walletConnectCloudProjectId:Va,rpcConfig:{rpcUrls:{}},captchaEnabled:!1,_render:{inDialog:!0,inParentNodeId:null}};function Un(e,t){var g,p,b,f,C,k,v,L,_,U;let o,r,n,i,a,l,s,d;if(t!=null&&t.loginMethods?(o=t.loginMethods.includes("email"),r=t.loginMethods.includes("sms"),n=t.loginMethods.includes("wallet"),i=t.loginMethods.includes("google"),a=t.loginMethods.includes("twitter"),l=t.loginMethods.includes("discord"),s=t.loginMethods.includes("github"),d=t.loginMethods.includes("apple")):(o=e.emailAuth,r=e.smsAuth,n=e.walletAuth,i=e.googleOAuth,a=e.twitterOAuth,l=e.discordOAuth,s=e.githubOAuth,d=e.appleOAuth),o&&r&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),r=!1),!o&&!r&&[i,a,l,s,d].some(N=>N))throw new Error("To enable social logins you must also enable either SMS or Email login");if(![o,r,n,i,a,l,s,d].some(N=>N))throw new Error("You must enable at least one login method");let w=((g=t==null?void 0:t.customAuth)==null?void 0:g.getCustomAccessToken)&&((p=t==null?void 0:t.customAuth)==null?void 0:p.enabled)!==!1;return{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,appearance:{logo:((b=t==null?void 0:t.appearance)==null?void 0:b.logo)??e.logoUrl,palette:kd({backgroundTheme:((f=t==null?void 0:t.appearance)==null?void 0:f.theme)??co.appearance.theme,accentHex:((C=t==null?void 0:t.appearance)==null?void 0:C.accentColor)??e.accentColor??co.appearance.accentColor}),showWalletLoginFirst:((k=t==null?void 0:t.appearance)==null?void 0:k.showWalletLoginFirst)??e.showWalletLoginFirst},loginMethods:{wallet:n,email:o,sms:r,google:i,twitter:a,discord:l,github:s,apple:d},legal:{termsAndConditionsUrl:((v=t==null?void 0:t.legal)==null?void 0:v.termsAndConditionsUrl)??e.termsAndConditionsUrl,privacyPolicyUrl:((L=t==null?void 0:t.legal)==null?void 0:L.privacyPolicyUrl)??e.privacyPolicyUrl},walletConnectCloudProjectId:(t==null?void 0:t.walletConnectCloudProjectId)??e.walletConnectCloudProjectId??co.walletConnectCloudProjectId,rpcConfig:(t==null?void 0:t.rpcConfig)??co.rpcConfig,captchaEnabled:e.captchaEnabled??co.captchaEnabled,embeddedWallets:{...e.embeddedWalletConfig,...w?{createOnLogin:"all-users",requireUserPasswordOnCreate:!1,noPromptOnSignature:!0}:{},...t==null?void 0:t.embeddedWallets},customAuth:w?{enabled:!0,...t.customAuth}:void 0,render:{inDialog:((_=t==null?void 0:t._render)==null?void 0:_.inDialog)??co._render.inDialog,inParentNodeId:((U=t==null?void 0:t._render)==null?void 0:U.inParentNodeId)??co._render.inParentNodeId}}}function Rd(e,t){var o;return((o=e==null?void 0:e.appearance)==null?void 0:o.logo)&&typeof e.appearance.logo=="object"&&(e.appearance.logo="component"),{...e,legacyCreateEmbeddedWalletFlag:t}}import{useRef as ky,useEffect as Ry}from"react";var Fn=class{constructor(){this.callbacks={}}enqueue(t,o){this.callbacks[t]=o}dequeue(t,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${t} event: no event found for id ${o}`);switch(delete this.callbacks[o],t){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:connect":return r;case"privy:wallet:recover":return r;case"privy:wallet:rpc":return r;default:throw new Error(`invalid wallet event type ${t}`)}}};import{jsx as Oy}from"react/jsx-runtime";var Iy=function(e){return()=>`id-${e++}`}(0);function Wy(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Cr(e){return e.error!==void 0}var qo=new Fn,ua=new Map,Ny=(e,t)=>typeof t=="bigint"?t.toString():t,Ly=(e,t)=>`${e}${JSON.stringify(t,Ny)}`;function Er(e,t,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");let n=Ly(e,t);if(e==="privy:wallet:create"){let a=ua.get(n);if(a)return a}let i=new Promise((a,l)=>{let s=Iy();qo.enqueue(s,{resolve:a,reject:l}),r.postMessage({id:s,event:e,data:t},"*")}).finally(()=>{ua.delete(n)});return ua.set(n,i),i}function My(e){switch(e.event){case"privy:iframe:ready":let t=qo.dequeue(e.event,e.id);return Cr(e)?t.reject(new Bt(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let o=qo.dequeue(e.event,e.id);return Cr(e)?o.reject(new Bt(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let r=qo.dequeue(e.event,e.id);return Cr(e)?r.reject(new Bt(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:recover":let n=qo.dequeue(e.event,e.id);return Cr(e)?n.reject(new Bt(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:rpc":let i=qo.dequeue(e.event,e.id);return Cr(e)?i.reject(new Bt(e.error.type,e.error.message)):i.resolve(e.data)}}function Id(e){let t=ky(null);return Ry(()=>{let o=t.current;if(!o)return;function r(s){s&&s.origin===e.origin&&Wy(s.data)&&My(s.data)}let n={create(s){return Er("privy:wallet:create",s,o)},connect(s){return Er("privy:wallet:connect",s,o)},recover(s){return Er("privy:wallet:recover",s,o)},rpc(s){return Er("privy:wallet:rpc",s,o)}};window.addEventListener("message",r);let i=()=>e.onLoad(n),a=(...s)=>{console.warn("Privy iframe failed to load: ",...s),e.onLoadFailed()},l=new AbortController;return ys(()=>Er("privy:iframe:ready",{},o),{abortSignal:l.signal}).then(i,a),()=>{window.removeEventListener("message",r),l.abort()}},[t.current]),Oy("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},src:Fr(e.origin,`/apps/${e.appId}/embedded-wallets`)})}import{createContext as Dy,useContext as Uy,useEffect as Fy}from"react";var Wd={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]}},ma=Dy(void 0),By=()=>Uy(ma);function jo(e,t){if(!t)return;let r=By().current[e];return Fy(()=>{var n;for(let[i,a]of Object.entries(t))r.hasOwnProperty(i)||console.warn(`Invalid event type "${i}" for action "${e}"`),(n=r[i])==null||n.push(a);return()=>{var i;for(let[a,l]of Object.entries(t))r.hasOwnProperty(a)||console.warn(`Invalid event type "${a}" for action "${e}"`),r[a]=(i=r[a])==null?void 0:i.filter(s=>s!==l)}},[t])}function Fe(e,t,o,...r){for(let n of e.current[t][o])n(...r)}import{createContext as Gy,useContext as Hy}from"react";var ha=Gy({wallets:[]});function zy(){return Hy(ha)}import{jsx as Kt,jsxs as Ld}from"react/jsx-runtime";function $y(e){return typeof e=="string"&&e.length===25}var xr;function yt(){if(!xr){let e=$.get(go);return Promise.resolve(e||null)}return xr.getAccessToken()}var Md,Cs=(e,t)=>Md(e,t),Od,Es=(e,t)=>Od(e,t),Dd,xs=()=>Dd(),qy=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;$.put(Jo,t);let o=new URL(window.location.href);o.searchParams.delete("privy_token"),window.history.pushState({},"",o)},jy=({config:e,...t})=>{var r,n;if(!$y(t.appId))throw new x("Cannot initialize the Privy provider with an invalid Privy app ID");xr||(xr=new rr({appId:t.appId,apiUrl:t.apiUrl||Lr}));let o=Object.assign({},e);return t.createPrivyWalletOnLogin!==void 0&&((r=o.embeddedWallets)==null?void 0:r.createOnLogin)===void 0&&(o.embeddedWallets||(o.embeddedWallets={}),o.embeddedWallets.createOnLogin=t.createPrivyWalletOnLogin?"users-without-wallets":"off"),t.createPrivyWalletOnLogin!==void 0&&((n=e==null?void 0:e.embeddedWallets)==null?void 0:n.createOnLogin)&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),Kt(Ky,{...t,config:o,client:xr})},Ky=e=>{var ba,wa,Ca;let t=e.client,[o,r]=K(!1),[n,i]=K(!1),[a,l]=K(!1),[s,d]=K(null),[w,y]=K(!1),[g,p]=K([]),b=Nd(g),[f,C]=K(!1),[k,v]=K(null),[L,_]=K(!1),[U,N]=K({status:"disconnected",connectError:null,connector:null,connectRetry:T}),[G,ee]=K(null),[M,se]=K(null),[pe,F]=K({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,appleOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserPasswordOnCreate:!1},captchaEnabled:!1}),[R,D]=K(()=>{let c=Rd(e.config,e.createPrivyWalletOnLogin);return t.createAnalyticsEvent("sdk_initialize",c),Un(pe,e.config)}),[V,Y]=K(!0),[je,Ae]=K({}),[Ke,ue]=K(null),[Ye,Ko]=K(null),[Tr,Pr]=K(!1),[_r,po]=K(),[Ar,q]=K(),[Je,Yt]=K(),[uo,Sr]=K(!1),Se=Nd(Wd),ke=c=>{c&&v(c),r(!0),t.createAnalyticsEvent("modal_open",{initialScreen:c})},kr=c=>{R.embeddedWallets.createOnLogin!=="off"&&Y(!0),ke(c)};dt(()=>{var u,m;if(!M||!s){(u=t.connectors)==null||u.removeEmbeddedWalletConnector();return}let c=s==null?void 0:s.linkedAccounts.filter(h=>h.type==="wallet"&&h.walletClient==="privy");if(c&&c.length>0){let h=c[0].address;(m=t.connectors)==null||m.addEmbeddedWalletConnector(M,h)}},[M,s]),dt(()=>{!M||Ye==null||Ye(M)},[M]),dt(()=>{(async()=>{var h;if(!((h=R.customAuth)!=null&&h.enabled))return;Y(!0);let{getCustomAccessToken:u,isLoading:m}=R.customAuth;if(!(!n||m))try{let I=await u();if(!I){await mo.logout();return}if(a)return;t.startAuthFlow(new yo(I));let{user:me,isNewUser:ge}=await t.authenticate();me||await mo.logout(),d(me||null),C(ge||!1),l(!0),Sr(!0)}catch(I){console.warn(I),a&&await mo.logout()}})()},[(ba=R.customAuth)==null?void 0:ba.enabled,(wa=R.customAuth)==null?void 0:wa.getCustomAccessToken,(Ca=R.customAuth)==null?void 0:Ca.isLoading,n,a]),dt(()=>{var c,u;uo&&M&&s&&kt(s,(u=(c=e.config)==null?void 0:c.embeddedWallets)==null?void 0:u.createOnLogin)&&(Sr(!1),va(s,3e4).catch(console.error))},[uo&&M&&s]),dt(()=>{async function c(){var me,ge,Re;let u=await t.getServerConfig();F(u);let m=Un(u,e.config);D(m),u.customApiUrl&&t.updateApiUrl(u.customApiUrl),t.initializeConnectorManager(m.walletConnectCloudProjectId,m.rpcConfig),(me=t.connectors)==null||me.initialize();let h=Ud();qy();let I=await t.getAuthenticatedUser();(Re=(ge=e.config)==null?void 0:ge.customAuth)!=null&&Re.enabled||(l(!!I),I&&Fe(Se,"login","onComplete",I,!1,!0),d(I)),i(!0),Ke==null||Ke(),h&&I&&y(!0),Fd()}n||c()},[t,Ke,n]),dt(()=>{let c=Un(pe,e.config);D(c)},[e.config]);let Ud=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_oauth_code"),m=c.get("privy_oauth_state"),h=c.get("privy_oauth_provider");return u&&m&&h?(t.startAuthFlow(new At(h,u,m)),kr("AWAITING_OAUTH_SCREEN"),!0):!1},Gn=async(c,u,m)=>{var I;let h=await((I=t.connectors)==null?void 0:I.createWalletConnector(c,u))||null;ya(h,m)};async function ya(c,u){if(!c)return N({status:"disconnected",connectError:new B("Unable to connect to wallet."),connector:null,connectRetry:T}),u==null?void 0:u(null);N({connector:c,status:"connecting",connectError:null,connectRetry:()=>ya(c,u)});try{let m=await c.connect({showPrompt:!0});return N(h=>({...h,status:"connected",connectError:null,connectRetry:T})),m&&!L&&Fe(Se,"connectWallet","onSuccess",m),u==null?void 0:u(m)}catch(m){return m instanceof Ge?(console.warn(m.cause?m.cause:m.message),L||Fe(Se,"connectWallet","onError",m.privyErrorCode||"generic_connect_wallet_error")):(console.warn(m),L||Fe(Se,"connectWallet","onError","unknown_connect_wallet_error")),N(h=>({...h,status:"disconnected",connectError:m})),u==null?void 0:u(null)}}let Hn=c=>{c!==null&&t.startAuthFlow(new Zt(c))},Fd=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_connector"),m=c.get("privy_wallet_client");if(!u||!m)return;if(m==="phantom"&&!Ne()&&kr("LOGIN_FAILED_SCREEN"),!t.connectors)throw new x("Connector not initialized");ke("AWAITING_CONNECTION");let h=new URL(window.location.href);h.searchParams.delete("privy_connector"),h.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",h),Gn(u,m,Hn)};dt(()=>{n&&a&&s===null&&t.getAuthenticatedUser().then(d)},[n,a,s,t]);let ga=()=>{y(!0),ke("LINK_WALLET_SCREEN")},Bd=c=>{if(!a||!s)return!1;for(let u of s.linkedAccounts)if(u.type==="wallet"&&u.address===c.address)return!0;return!1},Gd=async c=>{if(!t.connectors)throw new x("Connector not initialized");let u=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null;N(m=>({...m,connector:u,status:"connected",connectError:null,connectRetry:T})),Hn(c),kr("AWAITING_CONNECTION")},Hd=async(c,u)=>{if(!t.connectors)throw new x("Connector not initialized");await Gn(c,u,Hn)},zn=()=>{p(c=>{var m;let u=((m=t.connectors)==null?void 0:m.wallets.map(h=>({...h,linked:Bd(h),loginOrLink:async()=>{if(!await h.isConnected())throw new x("Wallet is not connected");if(h.connectorType==="embedded"&&h.walletClientType==="privy")throw new x("Cannot link or login with embedded wallet");Gd(h)},unlink:async()=>{if(!a)throw new x("User is not authenticated.");if(h.connectorType==="embedded"&&h.walletClientType==="privy")throw new x("Cannot unlink an embedded wallet");let I=await t.unlinkWallet(h.address);d(I)}})))||[];return Hr(c,u)?c:u})};dt(()=>{zn()},[s==null?void 0:s.linkedAccounts,a]),dt(()=>{if(n){if(!t.connectors)throw new x("Connector not initialized");zn(),t.connectors.on("walletsUpdated",zn)}},[n]);let zd=()=>{ke(a?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};dt(()=>{if(!g[0])return;let c=g[0],u=b.current.find(h=>h.address===c.address),m=s==null?void 0:s.linkedAccounts.find(h=>h.type==="wallet"&&h.address===c.address);if(!u&&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)}b.current=g},[g]);let va=async(c,u)=>{var me,ge,Re,Jt;if(te(c))throw new Error("Only one Privy wallet per user is currently allowed");let[h,I]=await Promise.all([Be.initializeWalletProxy(u),yt()]);if(!h&&((ge=(me=e.config)==null?void 0:me.customAuth)==null?void 0:ge.enabled))throw new Error("Failed to connect to wallet proxy");if(!h||!I||((Jt=(Re=e.config)==null?void 0:Re.embeddedWallets)==null?void 0:Jt.requireUserPasswordOnCreate))return new Promise((Pt,pt)=>{Y(!0),Ae({createWallet:{onSuccess:Pt,onFailure:pt,callAuthOnSuccessOnClose:!1}}),ke("EMBEDDED_WALLET_SCREEN")});{await h.create({accessToken:I});let Pt=await Be.refreshUser(),pt=te(Pt);if(!pt)throw new Error("Failed to create wallet");return pt}},mo={ready:n,authenticated:a,user:s,walletConnectors:t.connectors||null,connectWallet:zd,linkWallet:ga,linkEmail:()=>{if(s!=null&&s.email)throw new x("User already has an email linked to their account.");y(!0),ke("LINK_EMAIL_SCREEN")},linkPhone:()=>{if(s!=null&&s.phone)throw new x("User already has a phone number linked to their account.");y(!0),ke("LINK_PHONE_SCREEN")},linkGoogle:async()=>{if(s!=null&&s.google)throw new x("User already has a Google account linked to their account.");await Be.initLoginWithOAuth("google")},linkTwitter:async()=>{if(s!=null&&s.twitter)throw new x("User already has a Twitter account linked to their account.");await Be.initLoginWithOAuth("twitter")},linkDiscord:async()=>{if(s!=null&&s.discord)throw new x("User already has a Discord account linked to their account.");await Be.initLoginWithOAuth("discord")},linkGithub:async()=>{if(s!=null&&s.github)throw new x("User already has a Github account linked to their account.");await Be.initLoginWithOAuth("github")},linkApple:async()=>{await Be.initLoginWithOAuth("apple")},login:async()=>{if(n||(await new Promise(c=>{ue(()=>c)}),ue(null)),a){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}_(!0),kr()},logout:async()=>{await t.logout(),d(null),l(!1),v(null),Fe(Se,"logout","onSuccess"),y(!1),r(!1)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{var m;if(!s||!s.wallet)return new J;let c=g.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(I=>I.address===(c==null?void 0:c.address)));return!c||!u?new J:u.proxyProvider},getEthersProvider:()=>{var m;if(!s||!s.wallet)return new fa(new et(new J));let c=g.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(I=>I.address===(c==null?void 0:c.address)));return!c||!u?new fa(new et(new J)):new fa(new et(u.proxyProvider))},getWeb3jsProvider:()=>{var m;if(!s||!s.wallet)return new Nt(new J);let c=g.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(I=>I.address===(c==null?void 0:c.address)));return!c||!u?new Nt(new J):new Nt(u.proxyProvider)},unlinkWallet:async c=>{let u=await t.unlinkWallet(c);return d(u),u},unlinkEmail:async c=>{let u=await t.unlinkEmail(c);return d(u),u},unlinkPhone:async c=>{let u=await t.unlinkPhone(c);return d(u),u},unlinkGoogle:async c=>{let u=await t.unlinkOAuth("google",c);return d(u),u},unlinkTwitter:async c=>{let u=await t.unlinkOAuth("twitter",c);return d(u),u},unlinkDiscord:async c=>{let u=await t.unlinkOAuth("discord",c);return d(u),u},unlinkGithub:async c=>{let u=await t.unlinkOAuth("github",c);return d(u),u},unlinkApple:async c=>{let u=await t.unlinkOAuth("apple",c);return d(u),u},setActiveWallet:async c=>{let u=g.find(h=>Bn(h.address)===Bn(c)),m=s==null?void 0:s.linkedAccounts.find(h=>h.type==="wallet"&&Bn(h.address)===Bn(c));if(!u||!await u.isConnected())ee(c),ga();else if(!u.linked)u.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(!a||!s)throw new Error("User must be authenticated before creating a Privy wallet");return va(s,5e3)},signMessage:(c,u)=>new Promise((m,h)=>{if(!a||!s){h(new Error("User must be authenticated before signing with a Privy wallet"));return}let I=te(s);if(!I){h(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){h(new Error("Message must be a non-empty string"));return}Y(!0);let me=async()=>{a||h(new Error("User must be authenticated before signing with a Privy wallet"));let ge=await yt();if(M&&ge)try{if(!await Be.recoverEmbeddedWallet()){h(new Error("Unable to connect to wallet"));return}t.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:I.address});let{response:Jt}=await M.rpc({accessToken:ge,address:I.address,request:{method:"personal_sign",params:[c,I.address]}}),Pt=Jt.data;m(Pt),t.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:I.address})}catch(Re){h(Re)}};if(R.embeddedWallets.noPromptOnSignature)u&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),me();else{let ge={message:c,confirmAndSignMessage:me,uiOptions:u||{}},Re={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:h};Ae({signMessage:ge,connectWallet:Re}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:(c,u)=>new Promise(async(m,h)=>{var Jt,Pt;if(!a||!s){h(new Error("User must be authenticated before signing with a Privy wallet"));return}let I=te(s);if(!I){h(new Error("Must have a Privy wallet before signing"));return}Y(!0);let me=(Pt=(Jt=t.connectors)==null?void 0:Jt.findWalletConnector("embedded","privy"))==null?void 0:Pt.proxyProvider,ge=Object.assign({},c,{chainId:c.chainId||me.chainId}),Re=async()=>{let pt=await yt();if(!pt||!M){h(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await Be.recoverEmbeddedWallet()){h(new Error("Unable to connect to wallet"));return}let $d=await Wn(I.address,ge,R.rpcConfig),qd=await Nn(pt,I.address,M,$d,R.rpcConfig);m(qd)}catch(Yo){h(Yo)}};if(R.embeddedWallets.noPromptOnSignature)u&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),Re();else{let pt={transactionRequest:ge,onSuccess:m,onFailure:h,uiOptions:u||{}},Yo={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:h};Ae({connectWallet:Yo,sendTransaction:pt}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),exportWallet:()=>new Promise((c,u)=>{if(!a||!s){u(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!te(s)){u(new Error("Must have a Privy wallet before exporting"));return}Y(!0);let h={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:u},I={appId:e.appId,origin:t.apiUrl,onSuccess:c,onFailure:u};Ae({keyExport:I,connectWallet:h}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")})};Md=mo.signMessage,Od=mo.sendTransaction;let Be=(()=>({isNewUserThisSession:f,isLinking:w,linkingHint:G,walletConnectionStatus:U,rpcConfig:R.rpcConfig,captchaData:{ready:Tr,enabled:R.captchaEnabled,execute:()=>{let c=window.turnstile;if(!c)return;let u=c.render("#cf-turnstile",{sitekey:$a,action:R.id,callback:po,"error-callback":q,"expired-callback":()=>{try{c.reset(Je),q(void 0),po(void 0)}catch{q("expired_and_failed_reset")}},"unsupported-callback":()=>{console.warn("Browser does not support Turnstile.")}});u||console.warn("Failed to render challenge."),Yt(u)},remove:()=>{let c=window.turnstile;!(c!=null&&c.remove)||!Je||(c.remove(Je),Yt(void 0),q(void 0),po(void 0))},token:_r,error:Ar},initializeWalletProxy:async c=>{if(M)return M;let u=new Promise(I=>{Ko(()=>me=>I(me))}),m=new Promise(I=>setTimeout(()=>I(null),c)),h=await Promise.race([u,m]);return Ko(null),h},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>{var c;return(c=t.authFlow)==null?void 0:c.meta},closePrivyModal:(c={shouldCallAuthOnSuccess:!0})=>{var m;let u=n&&a&&s;c.shouldCallAuthOnSuccess&&u?(Fe(Se,"login","onComplete",s,f,!1),(m=e.onSuccess)==null||m.call(e,s,f)):L&&Fe(Se,"login","onError","exited_auth_flow"),t.authFlow=void 0,ee(null),v(null),_(!1),y(!1),C(!1),r(!1),t.createAnalyticsEvent("modal_closed")},connectWallet:Gn,initLoginWithWallet:Hd,loginWithWallet:async()=>{if(!n)throw new fo;if(!(t.authFlow instanceof Zt))throw new x("Must initialize SIWE flow first.");let c,u;if(a)c=await t.link();else try{({user:c,isNewUser:u}=await t.authenticate())}catch(m){throw Fe(Se,"login","onError",m.privyErrorCode||"generic_connect_wallet_error"),m}d(c||s||null),C(u||!1),l(!0)},initLoginWithOAuth:async c=>{t.startAuthFlow(new At(c));let u=await t.authFlow.getAuthorizationUrl();u&&u.url&&window.location.assign(u.url)},loginWithOAuth:async()=>{if(!n)throw new fo;if(!(t.authFlow instanceof At))throw new x("Must initialize OAuth flow before calling loginWithOAuth");let c,u;if(a)c=await t.link();else try{({user:c,isNewUser:u}=await t.authenticate())}catch(m){throw Fe(Se,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}d(c),C(u||!1),l(!0)},initLoginWithEmail:async(c,u)=>{let m=new Qt(c,u);t.startAuthFlow(m);try{await m.sendCodeEmail()}catch(h){throw Fe(Se,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}},initLoginWithSms:async(c,u)=>{let m=new Xt(c,u);t.startAuthFlow(m);try{await m.sendSmsCode()}catch(h){throw Fe(Se,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}},resendEmailCode:async()=>{var c;await((c=t.authFlow)==null?void 0:c.sendCodeEmail())},resendSmsCode:async()=>{var c;await((c=t.authFlow)==null?void 0:c.sendSmsCode())},loginWithCode:async c=>{if(!n)throw new fo;if(t.authFlow instanceof Qt)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof Xt)t.authFlow.meta.smsCode=c.trim();else throw new x("Must initialize a passwordless code flow first");let u,m;a?u=await t.link():{user:u,isNewUser:m}=await t.authenticate(),d(u||s||null),C(m||!1),l(!0)},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return d(c),c},walletProxy:M,createAnalyticsEvent:(c,u,m)=>t.createAnalyticsEvent(c,u,m),getUsdTokenPrice:c=>t.getUsdTokenPrice(c),recoverEmbeddedWallet:async()=>new Promise(async(c,u)=>{let m=s==null?void 0:s.linkedAccounts.find(I=>I.type==="wallet"&&I.walletClientType==="privy"),h=await yt();if(!h||!M||!m){u(new Error("Must have valid access token and Privy wallet to recover wallet"));return}Y(!0);try{await M.connect({accessToken:h,address:m.address}),c(!0)}catch(I){Ro(I)&&m.recoveryMethod==="privy"?(t.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:m.address}),(await M.recover({address:m.address,accessToken:h})).address||u(new Error("Unable to recover wallet")),t.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:m.address}),c(!0)):Ro(I)?(Ae({recoverWallet:{privyWallet:m,onFailure:u,onSuccess:()=>c(!0)}}),ke("EMBEDDED_WALLET_RECOVERY_SCREEN")):u(I)}})}))();Dd=Be.recoverEmbeddedWallet;let Vd=Vy(()=>({wallets:g}),[g]);return Kt(gt.Provider,{value:mo,children:Kt(ma.Provider,{value:Se,children:Ld(ha.Provider,{value:Vd,children:[e.children,Ld(si.Provider,{value:Be,children:[Kt(xd,{theme:{...R.appearance.palette||{}}}),Kt(Rs,{appConfig:R,data:je,setModalData:Ae,setInitialScreen:v,initialScreen:k,visible:o,authenticated:a,children:o?Kt(_d,{}):null}),V&&pe.id?Kt(Id,{appId:e.appId,origin:t.apiUrl,onLoad:se,onLoadFailed:()=>null}):null]}),R.captchaEnabled&&Kt(Ad,{onLoad:()=>Pr(!0)})]})})})};import{useContext as Yy}from"react";function Jy(e){let{login:t}=Yy(gt);return jo("login",e),{login:t}}import{useContext as Qy}from"react";function Zy(e){let{logout:t}=Qy(gt);return jo("logout",e),{logout:t}}import{useContext as Xy}from"react";function e1(e){let{connectWallet:t}=Xy(gt);return jo("connectWallet",e),{connectWallet:t}}export{et as AsExternalProvider,or as ConnectorManager,rr as PrivyClient,jy as PrivyProvider,J as PrivyProxyProvider,eo as SUPPORTED_CHAINS,Vn as VERSION,xe as WalletConnector,yt as getAccessToken,e1 as useConnectWallet,Jy as useLogin,Zy as useLogout,z as usePrivy,zy as useWallets};
|
|
2119
|
+
`;import{useEffect as Cy}from"react";import{Fragment as xy,jsx as Ty}from"react/jsx-runtime";var Ey=({onLoad:e})=>{let t=window;return Cy(()=>{if(document.getElementById("cf-script")!==null||t.turnstile)return;t.onloadTurnstileCallback=e;let o=document.createElement("script");o.setAttribute("src","https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback&render=explicit"),o.setAttribute("id","cf-script"),o.setAttribute("async","true"),document.body.appendChild(o)},[]),Ty(xy,{})},Ad=Ey;import $o from"tinycolor2";var Sd="#FFFFFF",Py="#000000",_y=Sd,Ay="#1E1E1D";function Sy(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function jt(e,t){let o=Math.max(0,Math.min(1,e.toHsl().l+t));return $o({...e.toHsl(),l:o})}function kd({backgroundTheme:e,accentHex:t,successHex:o="#51BA81",errorHex:r="#EC6351",whiteHex:n=Sd,blackHex:i=Py}){let a;switch(e){case"light":a=_y;break;case"dark":a=Ay;break;default:a=e;break}let l=$o(a),s=$o(t),d=$o(o),w=$o(r),y=Sy(l.getLuminance()),g=jt(l,y==="light"?-.04:.11),p=jt(l,y==="light"?-.88:.87),b=jt(l,y==="light"?-.77:.75),f=jt(l,y==="light"?-.43:.45).desaturate(y==="light"?60:20),C=jt(l,y==="light"?-.08:.25).desaturate(y==="light"?60:20),k=jt(s,.15),v=jt(s,-.06),L=$o(s.getLuminance()>.5?i:n),_=jt(d,-.16);return{colorScheme:y,background:l.toHslString(),background2:g.toHslString(),foreground:p.toHslString(),foreground2:b.toHslString(),foreground3:f.toHslString(),foreground4:C.toHslString(),accent:s.toHslString(),accentLight:k.toHslString(),accentDark:v.toHslString(),foregroundAccent:L.toHslString(),success:d.toHslString(),successDark:_.toHslString(),error:w.toHslString()}}var co={appearance:{theme:"light",accentColor:"#676FFF"},walletConnectCloudProjectId:Va,rpcConfig:{rpcUrls:{}},captchaEnabled:!1,_render:{inDialog:!0,inParentNodeId:null}};function Un(e,t){var g,p,b,f,C,k,v,L,_,U;let o,r,n,i,a,l,s,d;if(t!=null&&t.loginMethods?(o=t.loginMethods.includes("email"),r=t.loginMethods.includes("sms"),n=t.loginMethods.includes("wallet"),i=t.loginMethods.includes("google"),a=t.loginMethods.includes("twitter"),l=t.loginMethods.includes("discord"),s=t.loginMethods.includes("github"),d=t.loginMethods.includes("apple")):(o=e.emailAuth,r=e.smsAuth,n=e.walletAuth,i=e.googleOAuth,a=e.twitterOAuth,l=e.discordOAuth,s=e.githubOAuth,d=e.appleOAuth),o&&r&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),r=!1),!o&&!r&&[i,a,l,s,d].some(N=>N))throw new Error("To enable social logins you must also enable either SMS or Email login");if(![o,r,n,i,a,l,s,d].some(N=>N))throw new Error("You must enable at least one login method");let w=((g=t==null?void 0:t.customAuth)==null?void 0:g.getCustomAccessToken)&&((p=t==null?void 0:t.customAuth)==null?void 0:p.enabled)!==!1;return{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,appearance:{logo:((b=t==null?void 0:t.appearance)==null?void 0:b.logo)??e.logoUrl,palette:kd({backgroundTheme:((f=t==null?void 0:t.appearance)==null?void 0:f.theme)??co.appearance.theme,accentHex:((C=t==null?void 0:t.appearance)==null?void 0:C.accentColor)??e.accentColor??co.appearance.accentColor}),showWalletLoginFirst:((k=t==null?void 0:t.appearance)==null?void 0:k.showWalletLoginFirst)??e.showWalletLoginFirst},loginMethods:{wallet:n,email:o,sms:r,google:i,twitter:a,discord:l,github:s,apple:d},legal:{termsAndConditionsUrl:((v=t==null?void 0:t.legal)==null?void 0:v.termsAndConditionsUrl)??e.termsAndConditionsUrl,privacyPolicyUrl:((L=t==null?void 0:t.legal)==null?void 0:L.privacyPolicyUrl)??e.privacyPolicyUrl},walletConnectCloudProjectId:(t==null?void 0:t.walletConnectCloudProjectId)??e.walletConnectCloudProjectId??co.walletConnectCloudProjectId,rpcConfig:(t==null?void 0:t.rpcConfig)??co.rpcConfig,captchaEnabled:e.captchaEnabled??co.captchaEnabled,embeddedWallets:{...e.embeddedWalletConfig,...w?{createOnLogin:"all-users",requireUserPasswordOnCreate:!1,noPromptOnSignature:!0}:{},...t==null?void 0:t.embeddedWallets},customAuth:w?{enabled:!0,...t.customAuth}:void 0,render:{inDialog:((_=t==null?void 0:t._render)==null?void 0:_.inDialog)??co._render.inDialog,inParentNodeId:((U=t==null?void 0:t._render)==null?void 0:U.inParentNodeId)??co._render.inParentNodeId}}}function Rd(e,t){var o;return((o=e==null?void 0:e.appearance)==null?void 0:o.logo)&&typeof e.appearance.logo=="object"&&(e.appearance.logo="component"),{...e,legacyCreateEmbeddedWalletFlag:t}}import{useRef as ky,useEffect as Ry}from"react";var Fn=class{constructor(){this.callbacks={}}enqueue(t,o){this.callbacks[t]=o}dequeue(t,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${t} event: no event found for id ${o}`);switch(delete this.callbacks[o],t){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:connect":return r;case"privy:wallet:recover":return r;case"privy:wallet:rpc":return r;default:throw new Error(`invalid wallet event type ${t}`)}}};import{jsx as Oy}from"react/jsx-runtime";var Iy=function(e){return()=>`id-${e++}`}(0);function Wy(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Cr(e){return e.error!==void 0}var qo=new Fn,ua=new Map,Ny=(e,t)=>typeof t=="bigint"?t.toString():t,Ly=(e,t)=>`${e}${JSON.stringify(t,Ny)}`;function Er(e,t,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");let n=Ly(e,t);if(e==="privy:wallet:create"){let a=ua.get(n);if(a)return a}let i=new Promise((a,l)=>{let s=Iy();qo.enqueue(s,{resolve:a,reject:l}),r.postMessage({id:s,event:e,data:t},"*")}).finally(()=>{ua.delete(n)});return ua.set(n,i),i}function My(e){switch(e.event){case"privy:iframe:ready":let t=qo.dequeue(e.event,e.id);return Cr(e)?t.reject(new Bt(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let o=qo.dequeue(e.event,e.id);return Cr(e)?o.reject(new Bt(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let r=qo.dequeue(e.event,e.id);return Cr(e)?r.reject(new Bt(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:recover":let n=qo.dequeue(e.event,e.id);return Cr(e)?n.reject(new Bt(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:rpc":let i=qo.dequeue(e.event,e.id);return Cr(e)?i.reject(new Bt(e.error.type,e.error.message)):i.resolve(e.data)}}function Id(e){let t=ky(null);return Ry(()=>{let o=t.current;if(!o)return;function r(s){s&&s.origin===e.origin&&Wy(s.data)&&My(s.data)}let n={create(s){return Er("privy:wallet:create",s,o)},connect(s){return Er("privy:wallet:connect",s,o)},recover(s){return Er("privy:wallet:recover",s,o)},rpc(s){return Er("privy:wallet:rpc",s,o)}};window.addEventListener("message",r);let i=()=>e.onLoad(n),a=(...s)=>{console.warn("Privy iframe failed to load: ",...s),e.onLoadFailed()},l=new AbortController;return ys(()=>Er("privy:iframe:ready",{},o),{abortSignal:l.signal}).then(i,a),()=>{window.removeEventListener("message",r),l.abort()}},[t.current]),Oy("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},src:Fr(e.origin,`/apps/${e.appId}/embedded-wallets`)})}import{createContext as Dy,useContext as Uy,useEffect as Fy}from"react";var Wd={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]}},ma=Dy(void 0),By=()=>Uy(ma);function jo(e,t){if(!t)return;let r=By().current[e];return Fy(()=>{var n;for(let[i,a]of Object.entries(t))r.hasOwnProperty(i)||console.warn(`Invalid event type "${i}" for action "${e}"`),(n=r[i])==null||n.push(a);return()=>{var i;for(let[a,l]of Object.entries(t))r.hasOwnProperty(a)||console.warn(`Invalid event type "${a}" for action "${e}"`),r[a]=(i=r[a])==null?void 0:i.filter(s=>s!==l)}},[t])}function Fe(e,t,o,...r){for(let n of e.current[t][o])n(...r)}import{createContext as Gy,useContext as Hy}from"react";var ha=Gy({wallets:[]});function zy(){return Hy(ha)}import{jsx as Kt,jsxs as Ld}from"react/jsx-runtime";function $y(e){return typeof e=="string"&&e.length===25}var xr;function yt(){if(!xr){let e=$.get(go);return Promise.resolve(e||null)}return xr.getAccessToken()}var Md,Cs=(e,t)=>Md(e,t),Od,Es=(e,t)=>Od(e,t),Dd,xs=()=>Dd(),qy=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;$.put(Jo,t);let o=new URL(window.location.href);o.searchParams.delete("privy_token"),window.history.pushState({},"",o)},jy=({config:e,...t})=>{var r,n;if(!$y(t.appId))throw new x("Cannot initialize the Privy provider with an invalid Privy app ID");xr||(xr=new rr({appId:t.appId,apiUrl:t.apiUrl||Lr}));let o=Object.assign({},e);return t.createPrivyWalletOnLogin!==void 0&&((r=o.embeddedWallets)==null?void 0:r.createOnLogin)===void 0&&(o.embeddedWallets||(o.embeddedWallets={}),o.embeddedWallets.createOnLogin=t.createPrivyWalletOnLogin?"users-without-wallets":"off"),t.createPrivyWalletOnLogin!==void 0&&((n=e==null?void 0:e.embeddedWallets)==null?void 0:n.createOnLogin)&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),Kt(Ky,{...t,config:o,client:xr})},Ky=e=>{var ba,wa,Ca;let t=e.client,[o,r]=K(!1),[n,i]=K(!1),[a,l]=K(!1),[s,d]=K(null),[w,y]=K(!1),[g,p]=K([]),b=Nd(g),[f,C]=K(!1),[k,v]=K(null),[L,_]=K(!1),[U,N]=K({status:"disconnected",connectError:null,connector:null,connectRetry:T}),[G,ee]=K(null),[M,se]=K(null),[pe,F]=K({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,appleOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserPasswordOnCreate:!1},captchaEnabled:!1}),[R,D]=K(()=>{let c=Rd(e.config,e.createPrivyWalletOnLogin);return t.createAnalyticsEvent("sdk_initialize",c),Un(pe,e.config)}),[V,Y]=K(!0),[je,Ae]=K({}),[Ke,ue]=K(null),[Ye,Ko]=K(null),[Tr,Pr]=K(!1),[_r,po]=K(),[Ar,q]=K(),[Je,Yt]=K(),[uo,Sr]=K(!1),Se=Nd(Wd),ke=c=>{c&&v(c),r(!0),t.createAnalyticsEvent("modal_open",{initialScreen:c})},kr=c=>{R.embeddedWallets.createOnLogin!=="off"&&Y(!0),ke(c)};dt(()=>{var u,m;if(!M||!s){(u=t.connectors)==null||u.removeEmbeddedWalletConnector();return}let c=s==null?void 0:s.linkedAccounts.filter(h=>h.type==="wallet"&&h.walletClient==="privy");if(c&&c.length>0){let h=c[0].address;(m=t.connectors)==null||m.addEmbeddedWalletConnector(M,h)}},[M,s]),dt(()=>{!M||Ye==null||Ye(M)},[M]),dt(()=>{(async()=>{var h;if(!((h=R.customAuth)!=null&&h.enabled))return;Y(!0);let{getCustomAccessToken:u,isLoading:m}=R.customAuth;if(!(!n||m))try{let I=await u();if(!I){await mo.logout();return}if(a)return;t.startAuthFlow(new yo(I));let{user:me,isNewUser:ge}=await t.authenticate();me||await mo.logout(),d(me||null),C(ge||!1),l(!0),Sr(!0)}catch(I){console.warn(I),a&&await mo.logout()}})()},[(ba=R.customAuth)==null?void 0:ba.enabled,(wa=R.customAuth)==null?void 0:wa.getCustomAccessToken,(Ca=R.customAuth)==null?void 0:Ca.isLoading,n,a]),dt(()=>{var c,u;uo&&M&&s&&kt(s,(u=(c=e.config)==null?void 0:c.embeddedWallets)==null?void 0:u.createOnLogin)&&(Sr(!1),va(s,3e4).catch(console.error))},[uo&&M&&s]),dt(()=>{async function c(){var me,ge,Re;let u=await t.getServerConfig();F(u);let m=Un(u,e.config);D(m),u.customApiUrl&&t.updateApiUrl(u.customApiUrl),t.initializeConnectorManager(m.walletConnectCloudProjectId,m.rpcConfig),(me=t.connectors)==null||me.initialize();let h=Ud();qy();let I=await t.getAuthenticatedUser();(Re=(ge=e.config)==null?void 0:ge.customAuth)!=null&&Re.enabled||(l(!!I),I&&Fe(Se,"login","onComplete",I,!1,!0),d(I)),i(!0),Ke==null||Ke(),h&&I&&y(!0),Fd()}n||c()},[t,Ke,n]),dt(()=>{let c=Un(pe,e.config);D(c)},[e.config]);let Ud=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_oauth_code"),m=c.get("privy_oauth_state"),h=c.get("privy_oauth_provider");return u&&m&&h?(t.startAuthFlow(new At(h,u,m)),kr("AWAITING_OAUTH_SCREEN"),!0):!1},Gn=async(c,u,m)=>{var I;let h=await((I=t.connectors)==null?void 0:I.createWalletConnector(c,u))||null;ya(h,m)};async function ya(c,u){if(!c)return N({status:"disconnected",connectError:new B("Unable to connect to wallet."),connector:null,connectRetry:T}),u==null?void 0:u(null);N({connector:c,status:"connecting",connectError:null,connectRetry:()=>ya(c,u)});try{let m=await c.connect({showPrompt:!0});return N(h=>({...h,status:"connected",connectError:null,connectRetry:T})),m&&!L&&Fe(Se,"connectWallet","onSuccess",m),u==null?void 0:u(m)}catch(m){return m instanceof Ge?(console.warn(m.cause?m.cause:m.message),L||Fe(Se,"connectWallet","onError",m.privyErrorCode||"generic_connect_wallet_error")):(console.warn(m),L||Fe(Se,"connectWallet","onError","unknown_connect_wallet_error")),N(h=>({...h,status:"disconnected",connectError:m})),u==null?void 0:u(null)}}let Hn=c=>{c!==null&&t.startAuthFlow(new Zt(c))},Fd=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_connector"),m=c.get("privy_wallet_client");if(!u||!m)return;if(m==="phantom"&&!Ne()&&kr("LOGIN_FAILED_SCREEN"),!t.connectors)throw new x("Connector not initialized");ke("AWAITING_CONNECTION");let h=new URL(window.location.href);h.searchParams.delete("privy_connector"),h.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",h),Gn(u,m,Hn)};dt(()=>{n&&a&&s===null&&t.getAuthenticatedUser().then(d)},[n,a,s,t]);let ga=()=>{y(!0),ke("LINK_WALLET_SCREEN")},Bd=c=>{if(!a||!s)return!1;for(let u of s.linkedAccounts)if(u.type==="wallet"&&u.address===c.address)return!0;return!1},Gd=async c=>{if(!t.connectors)throw new x("Connector not initialized");let u=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null;N(m=>({...m,connector:u,status:"connected",connectError:null,connectRetry:T})),Hn(c),kr("AWAITING_CONNECTION")},Hd=async(c,u)=>{if(!t.connectors)throw new x("Connector not initialized");await Gn(c,u,Hn)},zn=()=>{p(c=>{var m;let u=((m=t.connectors)==null?void 0:m.wallets.map(h=>({...h,linked:Bd(h),loginOrLink:async()=>{if(!await h.isConnected())throw new x("Wallet is not connected");if(h.connectorType==="embedded"&&h.walletClientType==="privy")throw new x("Cannot link or login with embedded wallet");Gd(h)},unlink:async()=>{if(!a)throw new x("User is not authenticated.");if(h.connectorType==="embedded"&&h.walletClientType==="privy")throw new x("Cannot unlink an embedded wallet");let I=await t.unlinkWallet(h.address);d(I)}})))||[];return Hr(c,u)?c:u})};dt(()=>{zn()},[s==null?void 0:s.linkedAccounts,a]),dt(()=>{if(n){if(!t.connectors)throw new x("Connector not initialized");zn(),t.connectors.on("walletsUpdated",zn)}},[n]);let zd=()=>{ke(a?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};dt(()=>{if(!g[0])return;let c=g[0],u=b.current.find(h=>h.address===c.address),m=s==null?void 0:s.linkedAccounts.find(h=>h.type==="wallet"&&h.address===c.address);if(!u&&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)}b.current=g},[g]);let va=async(c,u)=>{var me,ge,Re,Jt;if(te(c))throw new Error("Only one Privy wallet per user is currently allowed");let[h,I]=await Promise.all([Be.initializeWalletProxy(u),yt()]);if(!h&&((ge=(me=e.config)==null?void 0:me.customAuth)==null?void 0:ge.enabled))throw new Error("Failed to connect to wallet proxy");if(!h||!I||((Jt=(Re=e.config)==null?void 0:Re.embeddedWallets)==null?void 0:Jt.requireUserPasswordOnCreate))return new Promise((Pt,pt)=>{Y(!0),Ae({createWallet:{onSuccess:Pt,onFailure:pt,callAuthOnSuccessOnClose:!1}}),ke("EMBEDDED_WALLET_SCREEN")});{await h.create({accessToken:I});let Pt=await Be.refreshUser(),pt=te(Pt);if(!pt)throw new Error("Failed to create wallet");return pt}},mo={ready:n,authenticated:a,user:s,walletConnectors:t.connectors||null,connectWallet:zd,linkWallet:ga,linkEmail:()=>{if(s!=null&&s.email)throw new x("User already has an email linked to their account.");y(!0),ke("LINK_EMAIL_SCREEN")},linkPhone:()=>{if(s!=null&&s.phone)throw new x("User already has a phone number linked to their account.");y(!0),ke("LINK_PHONE_SCREEN")},linkGoogle:async()=>{if(s!=null&&s.google)throw new x("User already has a Google account linked to their account.");await Be.initLoginWithOAuth("google")},linkTwitter:async()=>{if(s!=null&&s.twitter)throw new x("User already has a Twitter account linked to their account.");await Be.initLoginWithOAuth("twitter")},linkDiscord:async()=>{if(s!=null&&s.discord)throw new x("User already has a Discord account linked to their account.");await Be.initLoginWithOAuth("discord")},linkGithub:async()=>{if(s!=null&&s.github)throw new x("User already has a Github account linked to their account.");await Be.initLoginWithOAuth("github")},linkApple:async()=>{await Be.initLoginWithOAuth("apple")},login:async()=>{if(n||(await new Promise(c=>{ue(()=>c)}),ue(null)),a){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}_(!0),kr()},logout:async()=>{await t.logout(),d(null),l(!1),v(null),Fe(Se,"logout","onSuccess"),y(!1),r(!1)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{var m;if(!s||!s.wallet)return new J;let c=g.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(I=>I.address===(c==null?void 0:c.address)));return!c||!u?new J:u.proxyProvider},getEthersProvider:()=>{var m;if(!s||!s.wallet)return new fa(new et(new J));let c=g.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(I=>I.address===(c==null?void 0:c.address)));return!c||!u?new fa(new et(new J)):new fa(new et(u.proxyProvider))},getWeb3jsProvider:()=>{var m;if(!s||!s.wallet)return new Nt(new J);let c=g.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(I=>I.address===(c==null?void 0:c.address)));return!c||!u?new Nt(new J):new Nt(u.proxyProvider)},unlinkWallet:async c=>{let u=await t.unlinkWallet(c);return d(u),u},unlinkEmail:async c=>{let u=await t.unlinkEmail(c);return d(u),u},unlinkPhone:async c=>{let u=await t.unlinkPhone(c);return d(u),u},unlinkGoogle:async c=>{let u=await t.unlinkOAuth("google",c);return d(u),u},unlinkTwitter:async c=>{let u=await t.unlinkOAuth("twitter",c);return d(u),u},unlinkDiscord:async c=>{let u=await t.unlinkOAuth("discord",c);return d(u),u},unlinkGithub:async c=>{let u=await t.unlinkOAuth("github",c);return d(u),u},unlinkApple:async c=>{let u=await t.unlinkOAuth("apple",c);return d(u),u},setActiveWallet:async c=>{let u=g.find(h=>Bn(h.address)===Bn(c)),m=s==null?void 0:s.linkedAccounts.find(h=>h.type==="wallet"&&Bn(h.address)===Bn(c));if(!u||!await u.isConnected())ee(c),ga();else if(!u.linked)u.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(!a||!s)throw new Error("User must be authenticated before creating a Privy wallet");return va(s,15e3)},signMessage:(c,u)=>new Promise((m,h)=>{if(!a||!s){h(new Error("User must be authenticated before signing with a Privy wallet"));return}let I=te(s);if(!I){h(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){h(new Error("Message must be a non-empty string"));return}Y(!0);let me=async()=>{a||h(new Error("User must be authenticated before signing with a Privy wallet"));let ge=await yt();if(M&&ge)try{if(!await Be.recoverEmbeddedWallet()){h(new Error("Unable to connect to wallet"));return}t.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:I.address});let{response:Jt}=await M.rpc({accessToken:ge,address:I.address,request:{method:"personal_sign",params:[c,I.address]}}),Pt=Jt.data;m(Pt),t.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:I.address})}catch(Re){h(Re)}};if(R.embeddedWallets.noPromptOnSignature)u&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),me();else{let ge={message:c,confirmAndSignMessage:me,uiOptions:u||{}},Re={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:h};Ae({signMessage:ge,connectWallet:Re}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:(c,u)=>new Promise(async(m,h)=>{var Jt,Pt;if(!a||!s){h(new Error("User must be authenticated before signing with a Privy wallet"));return}let I=te(s);if(!I){h(new Error("Must have a Privy wallet before signing"));return}Y(!0);let me=(Pt=(Jt=t.connectors)==null?void 0:Jt.findWalletConnector("embedded","privy"))==null?void 0:Pt.proxyProvider,ge=Object.assign({},c,{chainId:c.chainId||me.chainId}),Re=async()=>{let pt=await yt();if(!pt||!M){h(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await Be.recoverEmbeddedWallet()){h(new Error("Unable to connect to wallet"));return}let $d=await Wn(I.address,ge,R.rpcConfig),qd=await Nn(pt,I.address,M,$d,R.rpcConfig);m(qd)}catch(Yo){h(Yo)}};if(R.embeddedWallets.noPromptOnSignature)u&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),Re();else{let pt={transactionRequest:ge,onSuccess:m,onFailure:h,uiOptions:u||{}},Yo={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:h};Ae({connectWallet:Yo,sendTransaction:pt}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),exportWallet:()=>new Promise((c,u)=>{if(!a||!s){u(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!te(s)){u(new Error("Must have a Privy wallet before exporting"));return}Y(!0);let h={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:u},I={appId:e.appId,origin:t.apiUrl,onSuccess:c,onFailure:u};Ae({keyExport:I,connectWallet:h}),ke("EMBEDDED_WALLET_CONNECTING_SCREEN")})};Md=mo.signMessage,Od=mo.sendTransaction;let Be=(()=>({isNewUserThisSession:f,isLinking:w,linkingHint:G,walletConnectionStatus:U,rpcConfig:R.rpcConfig,captchaData:{ready:Tr,enabled:R.captchaEnabled,execute:()=>{let c=window.turnstile;if(!c)return;let u=c.render("#cf-turnstile",{sitekey:$a,action:R.id,callback:po,"error-callback":q,"expired-callback":()=>{try{c.reset(Je),q(void 0),po(void 0)}catch{q("expired_and_failed_reset")}},"unsupported-callback":()=>{console.warn("Browser does not support Turnstile.")}});u||console.warn("Failed to render challenge."),Yt(u)},remove:()=>{let c=window.turnstile;!(c!=null&&c.remove)||!Je||(c.remove(Je),Yt(void 0),q(void 0),po(void 0))},token:_r,error:Ar},initializeWalletProxy:async c=>{if(M)return M;let u=new Promise(I=>{Ko(()=>me=>I(me))}),m=new Promise(I=>setTimeout(()=>I(null),c)),h=await Promise.race([u,m]);return Ko(null),h},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>{var c;return(c=t.authFlow)==null?void 0:c.meta},closePrivyModal:(c={shouldCallAuthOnSuccess:!0})=>{var m;let u=n&&a&&s;c.shouldCallAuthOnSuccess&&u?(Fe(Se,"login","onComplete",s,f,!1),(m=e.onSuccess)==null||m.call(e,s,f)):L&&Fe(Se,"login","onError","exited_auth_flow"),t.authFlow=void 0,ee(null),v(null),_(!1),y(!1),C(!1),r(!1),t.createAnalyticsEvent("modal_closed")},connectWallet:Gn,initLoginWithWallet:Hd,loginWithWallet:async()=>{if(!n)throw new fo;if(!(t.authFlow instanceof Zt))throw new x("Must initialize SIWE flow first.");let c,u;if(a)c=await t.link();else try{({user:c,isNewUser:u}=await t.authenticate())}catch(m){throw Fe(Se,"login","onError",m.privyErrorCode||"generic_connect_wallet_error"),m}d(c||s||null),C(u||!1),l(!0)},initLoginWithOAuth:async c=>{t.startAuthFlow(new At(c));let u=await t.authFlow.getAuthorizationUrl();u&&u.url&&window.location.assign(u.url)},loginWithOAuth:async()=>{if(!n)throw new fo;if(!(t.authFlow instanceof At))throw new x("Must initialize OAuth flow before calling loginWithOAuth");let c,u;if(a)c=await t.link();else try{({user:c,isNewUser:u}=await t.authenticate())}catch(m){throw Fe(Se,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}d(c),C(u||!1),l(!0)},initLoginWithEmail:async(c,u)=>{let m=new Qt(c,u);t.startAuthFlow(m);try{await m.sendCodeEmail()}catch(h){throw Fe(Se,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}},initLoginWithSms:async(c,u)=>{let m=new Xt(c,u);t.startAuthFlow(m);try{await m.sendSmsCode()}catch(h){throw Fe(Se,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}},resendEmailCode:async()=>{var c;await((c=t.authFlow)==null?void 0:c.sendCodeEmail())},resendSmsCode:async()=>{var c;await((c=t.authFlow)==null?void 0:c.sendSmsCode())},loginWithCode:async c=>{if(!n)throw new fo;if(t.authFlow instanceof Qt)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof Xt)t.authFlow.meta.smsCode=c.trim();else throw new x("Must initialize a passwordless code flow first");let u,m;a?u=await t.link():{user:u,isNewUser:m}=await t.authenticate(),d(u||s||null),C(m||!1),l(!0)},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return d(c),c},walletProxy:M,createAnalyticsEvent:(c,u,m)=>t.createAnalyticsEvent(c,u,m),getUsdTokenPrice:c=>t.getUsdTokenPrice(c),recoverEmbeddedWallet:async()=>new Promise(async(c,u)=>{let m=s==null?void 0:s.linkedAccounts.find(I=>I.type==="wallet"&&I.walletClientType==="privy"),h=await yt();if(!h||!M||!m){u(new Error("Must have valid access token and Privy wallet to recover wallet"));return}Y(!0);try{await M.connect({accessToken:h,address:m.address}),c(!0)}catch(I){Ro(I)&&m.recoveryMethod==="privy"?(t.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:m.address}),(await M.recover({address:m.address,accessToken:h})).address||u(new Error("Unable to recover wallet")),t.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:m.address}),c(!0)):Ro(I)?(Ae({recoverWallet:{privyWallet:m,onFailure:u,onSuccess:()=>c(!0)}}),ke("EMBEDDED_WALLET_RECOVERY_SCREEN")):u(I)}})}))();Dd=Be.recoverEmbeddedWallet;let Vd=Vy(()=>({wallets:g}),[g]);return Kt(gt.Provider,{value:mo,children:Kt(ma.Provider,{value:Se,children:Ld(ha.Provider,{value:Vd,children:[e.children,Ld(si.Provider,{value:Be,children:[Kt(xd,{theme:{...R.appearance.palette||{}}}),Kt(Rs,{appConfig:R,data:je,setModalData:Ae,setInitialScreen:v,initialScreen:k,visible:o,authenticated:a,children:o?Kt(_d,{}):null}),V&&pe.id?Kt(Id,{appId:e.appId,origin:t.apiUrl,onLoad:se,onLoadFailed:()=>null}):null]}),R.captchaEnabled&&Kt(Ad,{onLoad:()=>Pr(!0)})]})})})};import{useContext as Yy}from"react";function Jy(e){let{login:t}=Yy(gt);return jo("login",e),{login:t}}import{useContext as Qy}from"react";function Zy(e){let{logout:t}=Qy(gt);return jo("logout",e),{logout:t}}import{useContext as Xy}from"react";function e1(e){let{connectWallet:t}=Xy(gt);return jo("connectWallet",e),{connectWallet:t}}export{et as AsExternalProvider,or as ConnectorManager,rr as PrivyClient,jy as PrivyProvider,J as PrivyProxyProvider,eo as SUPPORTED_CHAINS,Vn as VERSION,xe as WalletConnector,yt as getAccessToken,e1 as useConnectWallet,Jy as useLogin,Zy as useLogout,z as usePrivy,zy as useWallets};
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ Chain ID: ${t}
|
|
|
9
9
|
Nonce: ${a}
|
|
10
10
|
Issued At: ${i}
|
|
11
11
|
Resources:
|
|
12
|
-
- https://privy.io`;this.getNonceOnce=new rt(this._getNonceOnce.bind(this)),this.wallet=t}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType}}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Xa(),{message:t,signature:o,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType});return{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(t){throw ae(t)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign();return await this.api.post(es(),{message:t,signature:o,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw ae(t)}}async sign(){if(!this.api)throw new T("Auth flow has no API instance");if(await this.buildSiweMessage(),!this.preparedMessage)throw new T("Could not prepare SIWE message");let t=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async _getNonceOnce(){if(!this.api)throw new T("Auth flow has no API instance");let t=this.wallet.address;return(await this.api.post(Za(),{address:t})).nonce}async buildSiweMessage(){if(!this.api)throw new T("Auth flow has no API instance");let t=this.wallet.address,o=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=this.prepareMessage(o,t,this.nonce),this.preparedMessage}prepareMessage(t,o,r){let n=window.location.host,i=window.location.origin,a="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",l=new Date().toISOString();return this.createSiweMessage(t,o,n,i,l,r,a)}};var Ao=class{constructor(t,o){this.meta={phoneNumber:t,captchaToken:o}}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{let t=is(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ae(t)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{let t=as();return await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw ae(t)}}async sendSmsCode(t,o){if(!this.api)throw new T("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),o&&(this.meta.captchaToken=o),!this.meta.phoneNumber)throw new T("phone nNumber must be set when initialzing authentication.");try{let r=ns();return await this.api.post(r,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(r){throw ae(r)}}};var gl=require("uuid");function At(e){return new Date(e*1e3)}function gp(e){let t=[];for(let o of e){let r=o.type;switch(o.type){case"wallet":let n={address:o.address,type:o.type,verifiedAt:At(o.verified_at),chainType:"ethereum",chainId:o.chain_id,walletClient:o.wallet_client_type==="privy"?"privy":"unknown",walletClientType:o.wallet_client_type,connectorType:o.connector_type,recoveryMethod:o.recovery_method};t.push(n);break;case"email":let i={address:o.address,type:o.type,verifiedAt:At(o.verified_at)};t.push(i);break;case"phone":let a={number:o.phoneNumber,type:o.type,verifiedAt:At(o.verified_at)};t.push(a);break;case"google_oauth":let l={subject:o.subject,email:o.email,name:o.name,type:o.type,verifiedAt:At(o.verified_at)};t.push(l);break;case"twitter_oauth":let s={subject:o.subject,username:o.username,name:o.name,type:o.type,verifiedAt:At(o.verified_at)};t.push(s);break;case"discord_oauth":let d={subject:o.subject,username:o.username,email:o.email,type:o.type,verifiedAt:At(o.verified_at)};t.push(d);break;case"github_oauth":let C={subject:o.subject,username:o.username,name:o.name,email:o.email,type:o.type,verifiedAt:At(o.verified_at)};t.push(C);break;case"apple_oauth":let g={subject:o.subject,email:o.email,type:o.type,verifiedAt:At(o.verified_at)};t.push(g);break;case"custom_auth":t.push({type:o.type,customUserId:o.custom_user_id,verifiedAt:At(o.verified_at)});break;default:console.warn(`Unrecognized account type: ${r}. Please consider upgrading the Privy SDK.`)}}return t}function oo(e,t){return e.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),e.find(o=>o.type===t)}var ce=e=>e==null?void 0:e.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClient==="privy"),vp=e=>e.linkedAccounts.filter(t=>t.type==="wallet"),ro=(e,t)=>{var o;return t==="all-users"&&!ce(e)||t==="users-without-wallets"&&!((o=vp(e))!=null&&o.length)};function Ft(e){if(!e)return null;let t=gp(e.linked_accounts),o=oo(t,"wallet"),r=oo(t,"email"),n=oo(t,"phone"),i=oo(t,"google_oauth"),a=oo(t,"twitter_oauth"),l=oo(t,"discord_oauth"),s=oo(t,"github_oauth"),d=oo(t,"apple_oauth");return{id:e.id,createdAt:At(e.created_at),linkedAccounts:t,email:r&&{address:r==null?void 0:r.address},phone:n&&{number:n==null?void 0:n.number},wallet:o&&{address:o.address,chainType:o.chainType,chainId:o.chainId,walletClient:o.walletClient,walletClientType:o.walletClientType,connectorType:o.connectorType,recoveryMethod:o.recoveryMethod},google:i&&{subject:i.subject,email:i.email,name:i.name},twitter:a&&{subject:a.subject,username:a.username,name:a.name},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:s&&{subject:s.subject,username:s.username,name:s.name,email:s.email},apple:d&&{subject:d.subject,email:d.email}}}var Zi=require("@ethersproject/address"),ml=_(require("eventemitter3"));var ys="1.35.0-beta.9";var pn="4df5e2316331463a9130964bd6078dfa",gs="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",vs="34357d3c125c2bcf2ce2bc3309d98715",bs="0x4AAAAAAAJFhr_rDU7HKpyw",un="https://auth.privy.io",ws=2e4,yt=1400,Cs=4500,mn=ys;var Vo="privy:token",Di="privy-token",hn="privy:refresh_token",Ui="privy-refresh-token",Tr="privy:session_transfer_token",wp="privy:wallet",Fi=e=>`${wp}:${e}`,Bi="privy:connectors",Gi="privy:connections";var gt=1,fn="0x1";var Hi=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},zi=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Cp(){return typeof window<"u"&&window.localStorage?new zi:new Hi}var Z=Cp();var Gs=require("libphonenumber-js/min");var Es={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var xs={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var Ts={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}};var Ps={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0};var _s={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var As={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var Ss={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1};var ks={id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0};var Rs={id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}};var Is={id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}};var Ws={id:5,network:"goerli",name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-goerli.g.alchemy.com/v2"],webSocket:["wss://eth-goerli.g.alchemy.com/v2"]},infura:{http:["https://goerli.infura.io/v3"],webSocket:["wss://goerli.infura.io/ws/v3"]},default:{http:["https://rpc.ankr.com/eth_goerli"]},public:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli.etherscan.io"},default:{name:"Etherscan",url:"https://goerli.etherscan.io"}},testnet:!0};var Ns={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-mainnet.infura.io/v3"],webSocket:["wss://linea-mainnet.infura.io/ws/v3"]},default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1};var Ls={id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0};var Ms={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}};var Os={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var Ds={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var Us={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var Fs={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mumbai.g.alchemy.com/v2"],webSocket:["wss://polygon-mumbai.g.alchemy.com/v2"]},infura:{http:["https://polygon-mumbai.infura.io/v3"],webSocket:["wss://polygon-mumbai.infura.io/ws/v3"]},default:{http:["https://matic-mumbai.chainstacklabs.com"]},public:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"},default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var Bs={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0};var no=[Es,xs,Ws,Bs,Ms,Os,Ds,Us,Fs,Ss,ks,Rs,Is,_s,As,Ns,Ls,Ts,Ps],Vi=e=>no.find(t=>t.id===e),Bt=e=>{var t;return(t=Vi(e))==null?void 0:t.nativeCurrency.symbol};var gn=()=>{let e=window;if(!e.ethereum)return!1;if(yn(window.ethereum,!0))return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(yn(t,!0))return!0}return!1},Pr=()=>{let e=window;if(!e.ethereum)return!1;if(yn(window.ethereum,!1))return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(yn(t,!1))return!0}return!1},yn=(e,t)=>e.isMetaMask?e.isMetaMask&&!t?!0:!(e.isBraveWallet&&!e._events&&!e._state||e.isApexWallet||e.isAvalanche||e.isBitKeep||e.isBlockWallet||e.isKuCoinWallet||e.isMathWallet||e.isOkxWallet||e.isOKExWallet||e.isOneInchIOSWallet||e.isOneInchAndroidWallet||e.isOpera||e.isPhantom||e.isPortal||e.isRabby||e.isRainbow||e.isTokenPocket||e.isTokenary||e.isZerion):!1,nt=()=>{var e,t;if("phantom"in window){let o=window;if((t=(e=o==null?void 0:o.phantom)==null?void 0:e.ethereum)!=null&&t.isPhantom)return!0}return!1},io=()=>{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.isCoinbaseWallet)return!0}return!1};var Hs=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,}))$/),zs=e=>(0,Gs.isPossiblePhoneNumber)(String(e),"US"),Vs=(e,t)=>{let o=e.slice(0),r=[];for(;o.length;)r.push(o.splice(0,t));return r},$o=(e,t=3,o=4)=>{if(!e)return"";let r=2,n=3;if(t+o+r+n>=e.length)return e;let i=e.slice(0,r+t),a=e.slice(e.length-o,e.length);return`${i}...${a}`},$i=e=>new Promise(t=>setTimeout(t,e)),$s=(e,t={})=>{let o=t.delayMs||150,r=t.maxAttempts||270;return new Promise(async(n,i)=>{var s;let a=!1,l=0;for(;!a&&l<r;){if((s=t.abortSignal)!=null&&s.aborted)return;e().then(()=>{a=!0,n()},(...d)=>{a=!0,i(...d)}),l+=1,await $i(o)}a||i(new Error("Exceeded max attempts before resolving function"))})},vn=(e,t,o={})=>{let r=new URL(t,e);for(let[n,i]of Object.entries(o))r.searchParams.set(n,i);return r.href};var qi=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),_r=e=>typeof e=="string"?e:"0x"+e.toString(16);async function qs(e=3e3){let t=!1,o=window;return new Promise(r=>{o.ethereum?n():(window.addEventListener("ethereum#initialized",n,{once:!0}),setTimeout(()=>{n()},e));function n(){if(t)return;t=!0,window.removeEventListener("ethereum#initialized",n);let i=[];gn()&&i.push("metamask"),nt()&&i.push("phantom"),o.ethereum&&o.ethereum.isBraveWallet&&i.push("brave"),r(i)}})}function bn(e){return`eip155:${String(Number(e))}`}var St=(e,t)=>{var n,i,a;let o=no.find(l=>l.id===e);if(!o)throw new $(`Unsupported chainId ${e}`,4901);let r;if(t.rpcUrls[e]?r=t.rpcUrls[e]:(n=o.rpcUrls.infura)!=null&&n.http[0]?r=o.rpcUrls.infura.http[0]+"/"+pn:(i=o.rpcUrls.blast)!=null&&i.http[0]?r=o.rpcUrls.blast.http[0]+"/"+gs:r=(a=o.rpcUrls.default)==null?void 0:a.http[0],!r)throw new $(`No RPC url found for ${e}`);return r};var el=_(require("@coinbase/wallet-sdk"));var Ar=require("react/jsx-runtime"),it=({style:e,...t})=>(0,Ar.jsxs)("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,Ar.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,Ar.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});var zt=require("@ethersproject/address"),Yi=require("@ethersproject/providers"),Xs=_(require("eventemitter3"));var ji=require("@ethersproject/providers"),Ys=_(require("eventemitter3"));var Ep=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4"],js=e=>Ep.includes(e);var Ks=require("@ethersproject/logger");var qo=class extends ${constructor(){super("Wallet timeout");this.type="wallet_error"}},jo=class extends ${constructor(){super("User rejected connection");this.type="wallet_error"}},kt=e=>{if(e instanceof $)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new ao(e);return e.code===Ks.ErrorCode.ACTION_REJECTED&&(t.details=Gt.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new ao(e):new $("Unknown connector error",e)},Sr=class extends ft{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},ao=class extends Sr{constructor(o){var i,a,l;let r=o;super(r.message,r.code,r.data);let n=Object.values(Gt).find(s=>s.eipCode===r.code);this.details=n||Gt.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=Gt.E32002_CONNECTION_ALREADY_PENDING:this.details=Gt.E32002_REQUEST_ALREADY_PENDING:(l=r.message)!=null&&l.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Gt.E32002_WALLET_LOCKED))}},xp={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Tp={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Pp={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},Gt={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Pp,...Tp},Ht={...xp,...Gt};var _p=12e4,Ki=(e=new qo,t=_p)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),oe=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(t,o)}catch{console.warn("Unable to remove wallet provider listener")}};this.setWalletProvider=t=>{this.walletProvider&&this._subscriptions.forEach(o=>{this.removeListener(o.eventName,o.listener)}),this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new $(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),Ki()]).catch(o=>{throw kt(o)})}},so=class extends Error{constructor(o,r,n){super(o);this.code=r,this.data=n}},wn=class extends Ys.default{constructor(o,r,n,i=1){super();this.walletProxy=o,this.address=r,this.chainId=i,this.rpcConfig=n,this.provider=new ji.JsonRpcProvider(St(i,n))}async handleSendTransaction(o){if(!o.params||!Array.isArray(o.params))throw new so(`Invalid params for ${o.method}`,4200);let r=o.params[0];if(!await Rt()||!this.address)throw new so("Disconnected",4900);return(await Qs(r)).transactionHash}handleSwitchEthereumChain(o){if(!o.params||!Array.isArray(o.params))throw new so(`Invalid params for ${o.method}`,4200);let r;if(typeof o.params[0]=="string")r=o.params[0];else if("chainId"in o.params[0]&&typeof o.params[0].chainId=="string")r=o.params[0].chainId;else throw new so(`Invalid params for ${o.method}`,4200);this.chainId=Number(r),this.provider=new ji.JsonRpcProvider(St(this.chainId,this.rpcConfig)),this.emit("chainChanged",r)}async handlePersonalSign(o){if(!o.params||!Array.isArray(o.params))throw new Error("Invalid params for eth_estimateGas");let r=o.params[0];return await Js(r)}async handleEstimateGas(o){if(!o.params||!Array.isArray(o.params))throw new Error("Invalid params for eth_estimateGas");delete o.params[0].gasPrice,delete o.params[0].maxFeePerGas,delete o.params[0].maxPriorityFeePerGas;let r={...o.params[0],chainId:_r(this.chainId)};try{return await this.provider.send("eth_estimateGas",[r])}catch{return delete r.from,await this.provider.send("eth_estimateGas",[r])}}async request(o){switch(console.debug("Embedded1193Provider.request() called with args",o),o.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return _r(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(o);case"eth_sendTransaction":return this.handleSendTransaction(o);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(o);case"personal_sign":return this.handlePersonalSign(o);default:break}if(js(o.method)){let r=await Rt();if(await Zs(),!r||!this.address)throw new so("Disconnected",4900);try{return(await this.walletProxy.rpc({address:this.address,accessToken:r,request:{method:o.method,params:o.params}})).response.data}catch(n){throw console.error(n),new so("Disconnected",4900)}}else return this.provider.send(o.method,o.params)}async connect(){let o=await Rt();if(!o||!this.address)return null;try{return(await this.walletProxy.connect({address:this.address,accessToken:o})).address}catch(r){return console.error(r),null}}},vt=class extends oe{constructor(o){super(o)}},lo=class extends oe{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Le=class extends Xs.default{constructor(o){super();this.onAccountsChanged=o=>{o.length===0?this.onDisconnect():this.syncAccounts(o)};this.onChainChanged=o=>{this.wallets.forEach(r=>{r.chainId=bn(o),this.walletClientType==="privy"&&Z.put(Fi(r.address),o)}),this.emit("walletsUpdated")};this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")};this.onConnect=()=>{this.connected=!0,this.syncAccounts()};this.wallets=[],this.walletClientType=o,this.connected=!1,this.initialized=!1}buildConnectedWallet(o,r){let n=async()=>!!this.wallets.find(i=>(0,zt.getAddress)(i.address)===(0,zt.getAddress)(o));return{address:(0,zt.getAddress)(o),chainId:r,switchChain:async i=>{var C,g,v;if(!n)throw new $("Wallet is not currently connected.");let a,l;if(typeof i=="number"?(a=`0x${i.toString(16)}`,l=i):(a=i,l=Number(i)),r===bn(a))return;let s=Vi(l);if(!s)throw new $(`Unsupported chainId: ${i}`);let d=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:a}]})};try{return await d()}catch(p){if(p.code===4902||((C=p.message)==null?void 0:C.includes("4902")))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:a,chainName:s.name,nativeCurrency:s.nativeCurrency,rpcUrls:[((g=s.rpcUrls.public)==null?void 0:g.http[0])??""]}]}),d();throw this.walletClientType==="rainbow"&&((v=p.message)==null?void 0:v.includes("wallet_switchEthereumChain"))?new $(`Rainbow does not support the chainId ${r}`):p}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:n,getEthereumProvider:async()=>{if(!await n())throw new $("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await n())throw new $("Wallet is not currently connected.");return new Yi.Web3Provider(new vt(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await n())throw new $("Wallet is not currently connected.");return new lo(this.proxyProvider)},sign:async i=>{if(!await n())throw new $("Wallet is not currently connected.");return await this.sign(i)},disconnect:()=>{this.disconnect()}}}async syncAccounts(o){let r=o;if(r===void 0){let d=await this.proxyProvider.request({method:"eth_accounts"});Array.isArray(d)&&(r=d)}if(!r||!Array.isArray(r)||r.length<=0||!r[0])return;let n=r[0],i=(0,zt.getAddress)(n),a=[],l;if(this.walletClientType==="privy"){l=Z.get(Fi(i))||fn;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:l}]})}catch{console.warn(`Unable to switch embedded wallet to chain ID ${l} on initialization`)}}else try{let d=await this.proxyProvider.request({method:"eth_chainId"});if(typeof d!="string")throw new Error("Invalid chainId returned from provider");l=d}catch(d){console.warn(`Failed to get chainId from provider, defaulting to ${fn}`,d),l=fn}let s=bn(l);a.find(d=>(0,zt.getAddress)(d.address)===i)||a.push(this.buildConnectedWallet((0,zt.getAddress)(n),s)),Cn(a,this.wallets)||(this.wallets=a,this.emit("walletsUpdated"))}async getConnectedWallet(){let o=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort((r,n)=>n.connectedAt-r.connectedAt).find(r=>o.find(n=>(0,zt.getAddress)(n)===(0,zt.getAddress)(r.address)))||null}async isConnected(){let o=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(o)&&o.length>0}async sign(o){return await this.connect({showPrompt:!1}),new Yi.Web3Provider(new vt(this.proxyProvider)).getSigner().signMessage(o)}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}};var Ap=e=>{let t=`https://mainnet.infura.io/v3/${pn}`,o=1;return e.makeWeb3Provider(t,o)},En,xn=class extends Le{constructor(){super("coinbase_wallet");this.connectorType="coinbase_wallet";this.proxyProvider=new oe,this.subscribeListeners(),En||(En=new el.default({appName:"Privy",darkMode:!1,headlessMode:!1})),this.proxyProvider.setWalletProvider(Ap(En)),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){En.disconnect()}get walletBranding(){return{name:"Coinbase Wallet",icon:it}}async promptConnection(){try{let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new $("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([o[0]])}catch(o){throw kt(o)}}};var Ji=require("react/jsx-runtime"),Ko=({...e})=>(0,Ji.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,Ji.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:e.color||"var(--privy-color-foreground-3)"})});var Tn=class extends Le{constructor(o){super("privy");this.connectorType="embedded";this.proxyProvider=o,this.subscribeListeners(),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[_r((o==null?void 0:o.chainId)||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Ko}}disconnect(){this.connected=!1}async promptConnection(){}};var Sp=require("@ethersproject/address"),kp=require("@ethersproject/providers"),tl=require("react-device-detect");var Pe=require("react/jsx-runtime"),_e=({style:e,...t})=>(0,Pe.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...e},...t,children:[(0,Pe.jsx)("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),(0,Pe.jsx)("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),(0,Pe.jsx)("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),(0,Pe.jsx)("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),(0,Pe.jsx)("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),(0,Pe.jsx)("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),(0,Pe.jsx)("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),(0,Pe.jsx)("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),(0,Pe.jsx)("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),(0,Pe.jsx)("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),(0,Pe.jsx)("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),(0,Pe.jsx)("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),(0,Pe.jsx)("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]});var Pn=class extends Le{constructor(){super("metamask");this.connectorType="injected";this.proxyProvider=new oe,this.subscribeListeners();let o=window,r=o.ethereum,n=o.ethereum.providers||[];for(let i of n)if(i.isMetaMask){r=i;break}this.proxyProvider.setWalletProvider(r),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:"MetaMask",icon:_e}}disconnect(){console.warn("Metamask does not support programmatic disconnect.")}async promptConnection(){try{!tl.isMobile&&gn()&&await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new $("Unable to retrieve accounts");await this.syncAccounts([o[0]])}catch(o){throw kt(o)}}};var kr=require("react/jsx-runtime"),at=({style:e,...t})=>(0,kr.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...e},...t,children:[(0,kr.jsx)("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),(0,kr.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});var _n=class extends Le{constructor(){super("phantom");this.connectorType="injected";this.proxyProvider=new oe,this.subscribeListeners(),this.proxyProvider.setWalletProvider(window.phantom.ethereum),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:"Phantom",icon:at}}disconnect(){console.warn("Phantom does not support programmatic disconnect.")}async promptConnection(){try{let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new $("Unable to retrieve accounts");await this.syncAccounts([o[0]])}catch(o){throw kt(o)}}};var Jo=require("@walletconnect/ethereum-provider"),kn=_(require("@walletconnect/qrcode-modal")),Rn=require("react-device-detect");var wt=require("react");var rl=require("react/jsx-runtime");function ol(e){return(0,rl.jsx)("link",{rel:"prefetch",href:e.src})}var An=require("react/jsx-runtime"),bt="LANDING",nl=(0,wt.createContext)({ready:!1,app:null,currentScreen:bt,lastScreen:bt,navigate:P,navigateBack:P,resetNavigation:P,setModalData:P}),il=e=>{var C,g,v;let t=e.appConfig,o=e.authenticated,r=e.visible,[n,i]=(0,wt.useState)(e.initialScreen||bt),[a,l]=(0,wt.useState)(e.initialScreen||bt);(0,wt.useEffect)(()=>{o||i(bt)},[o]),(0,wt.useEffect)(()=>{r||(l(bt),i(bt))},[r]),(0,wt.useEffect)(()=>{e.initialScreen&&n===bt&&(i(e.initialScreen),l(e.initialScreen))},[e.initialScreen]);let s=e.initialScreen&&n===bt?e.initialScreen:n,d={ready:!!(t!=null&&t.id),app:t,data:e.data,setModalData:e.setModalData,currentScreen:s,lastScreen:a,navigate:p=>{l(n),i(p)},navigateBack:()=>{i(a)},resetNavigation:()=>{e.setInitialScreen(null),l(bt),i(bt)}};return(0,An.jsxs)(nl.Provider,{value:d,children:[(typeof((C=t==null?void 0:t.appearance)==null?void 0:C.logo)=="string"||((v=(g=t==null?void 0:t.appearance)==null?void 0:g.logo)==null?void 0:v.type)==="img")&&(0,An.jsx)(ol,{src:typeof t.appearance.logo=="string"?t.appearance.logo:t.appearance.logo.props.src}),e.children]})},x=()=>(0,wt.useContext)(nl);var Vt=require("react/jsx-runtime"),Yo=({style:e,...t})=>{let{app:o}=x();return(0,Vt.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,Vt.jsx)("rect",{width:"28",height:"28",rx:"3",fill:(o==null?void 0:o.appearance.palette.colorScheme)==="dark"?"#3396ff":"#141414"}),(0,Vt.jsx)("g",{clipPath:"url(#clip0_1765_9946)",children:(0,Vt.jsx)("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),(0,Vt.jsx)("defs",{children:(0,Vt.jsx)("clipPath",{id:"clip0_1765_9946",children:(0,Vt.jsx)("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};var So=require("react-device-detect");var Sn=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[o,r]of Object.entries(sl))if(r.hostname===t)return{walletClientType:o,entry:r}};var sl={metamask:{id:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",displayName:"MetaMask",image_id:"5195e9db-94d8-4579-6f11-ef553be95100",hostname:"metamask.io",mobile:{native:"metamask:"}},trust:{id:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",displayName:"Trust",image_id:"0528ee7e-16d1-4089-21e3-bbfb41933100",hostname:"trustwallet.com",mobile:{universal:"https://link.trustwallet.com"}},safe:{id:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",displayName:"Safe",image_id:"a1cb2777-f8f9-49b0-53fd-443d20ee0b00",hostname:"safe.global",mobile:{universal:"https://app.safe.global/"}},rainbow:{id:"1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",displayName:"Rainbow",image_id:"7a33d7f1-3d12-4b5c-f3ee-5cd83cb1b500",hostname:"rainbow.me",mobile:{universal:"https://rnbwapp.com"}},uniswap:{id:"c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a",displayName:"Uniswap",image_id:"bff9cf1f-df19-42ce-f62a-87f04df13c00",hostname:"uniswap.org",mobile:{universal:"https://uniswap.org/app"}},zerion:{id:"ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18",displayName:"Zerion",image_id:"f216b371-96cf-409a-9d88-296392b85800",hostname:"zerion.io",mobile:{universal:"https://wallet.zerion.io"}},argent:{id:"bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6",displayName:"Argent",image_id:"215158d2-614b-49c9-410f-77aa661c3900",hostname:"www.argent.xyz",mobile:{universal:"https://www.argent.xyz/app"}},spot:{id:"74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d",displayName:"Spot",image_id:"1bf33a89-b049-4a1c-d1f6-4dd7419ee400",hostname:"www.spot-wallet.com",mobile:{universal:"https://spot.so"}},omni:{id:"afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7",displayName:"Omni",image_id:"2cd67b4c-282b-4809-e7c0-a88cd5116f00",hostname:"omni.app",mobile:{universal:"https://links.omni.app"}},cryptocom:{id:"f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d",displayName:"Crypto.com",image_id:"7c5ff577-a68d-49c5-02cd-3d83637b0b00",hostname:"crypto.com",mobile:{universal:"https://wallet.crypto.com"}},blockchain:{id:"84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04",displayName:"Blockchain",image_id:"6f913b80-86c0-46f9-61ca-cc90a1805900",hostname:"www.blockchain.com",mobile:{universal:"https://www.blockchain.com"}},safepal:{id:"0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150",displayName:"SafePal",image_id:"252753e7-b783-4e03-7f77-d39864530900",hostname:"safepal.com",mobile:{universal:"https://link.safepal.io"}},bitkeep:{id:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",displayName:"BitKeep",image_id:"3f7075d0-4ab7-4db5-404d-3e4c05e6fe00",hostname:"bitkeep.com",mobile:{universal:"https://bkapp.vip"}},zengo:{id:"9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0",displayName:"ZenGo",image_id:"cfc07342-23ea-4f3f-f071-ec9d2cd86b00",hostname:"zengo.com",mobile:{universal:"https://get.zengo.com/"}},"1inch":{id:"c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576",displayName:"1inch",image_id:"52b1da3c-9e72-40ae-5dac-6142addd9c00",hostname:"wallet.1inch.io",mobile:{universal:"https://wallet.1inch.io/wc/"}},binance:{id:"8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4",displayName:"Binance",image_id:"ebac7b39-688c-41e3-7912-a4fefba74600",hostname:"www.binance.com",mobile:{universal:"https://app.binance.com/cedefi"}},exodus:{id:"e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4",displayName:"Exodus",image_id:"4c16cad4-cac9-4643-6726-c696efaf5200",hostname:"exodus.com",mobile:{universal:"https://exodus.com/m"}},mew_wallet:{id:"f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2",displayName:"MEW wallet",image_id:"e2024511-2c9b-46d7-3111-52df3d241700",hostname:"mewwallet.com",mobile:{universal:"https://mewwallet.com"}},alphawallet:{id:"138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98",displayName:"AlphaWallet",image_id:"5b1cddfb-056e-4e78-029a-54de5d70c500",hostname:"alphawallet.com",mobile:{universal:"https://aw.app"}},keyring_pro:{id:"47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83",displayName:"KEYRING PRO",image_id:"dda0f0fb-34e8-4a57-dcea-b008e7d1ff00",hostname:"keyring.app",mobile:{universal:"https://keyring.app/"}},mathwallet:{id:"7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26",displayName:"MathWallet",image_id:"26a8f588-3231-4411-60ce-5bb6b805a700",hostname:"mathwallet.org",mobile:{universal:"https://www.mathwallet.org"}},unstoppable:{id:"8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3",displayName:"Unstoppable",image_id:"4725dda0-4471-4d0f-7adf-6bbe8b929c00",hostname:"unstoppabledomains.com",mobile:{universal:"https://unstoppabledomains.com/mobile"}},obvious:{id:"031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa",displayName:"Obvious",image_id:"61abe2ca-b06d-4a8b-de3e-8326f523e900",hostname:"obvious.technology",mobile:{universal:"https://wallet.obvious.technology"}},ambire:{id:"2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568",displayName:"Ambire",image_id:"c39b3a16-1a38-4588-f089-cb7aeb584700",hostname:"www.ambire.com",mobile:{universal:"https://mobile.ambire.com"}},internet_money_wallet:{id:"dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd",displayName:"Internet Money Wallet",image_id:"204b2240-5ce4-4996-6ec4-f06a22726900",hostname:"internetmoney.io",mobile:{universal:"https://internetmoney.io"}},coin98:{id:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",displayName:"Coin98",image_id:"fc460647-ea95-447a-99f0-1bff8fa4be00",hostname:"coin98.com",mobile:{universal:"https://coin98.services"}},abc_wallet:{id:"b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f",displayName:"ABC Wallet",image_id:"f9854c79-14ba-4987-42e1-4a82abbf5700",hostname:"myabcwallet.io",mobile:{universal:"https://abcwalletconnect.page.link"}},arculus_wallet:{id:"0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92",displayName:"Arculus Wallet",image_id:"f78dab27-7165-4a3d-fdb1-fcff06c0a700",hostname:"www.getarculus.com",mobile:{universal:"https://gw.arculus.co/app"}},haha:{id:"719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3",displayName:"HaHa",image_id:"79285c9f-2630-451e-0680-c71b42fb7400",hostname:"www.haha.me",mobile:{universal:"https://haha.me"}},cling_wallet:{id:"942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef",displayName:"Cling Wallet",image_id:"2d8006c3-852b-458a-d6b0-916c5ba76800",hostname:"clingon.io",mobile:{universal:"https://cling.carrieverse.com/apple-app-site-association"}},broearn:{id:"8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2",displayName:"Broearn",image_id:"339b9e9d-e2a7-46eb-4ed3-272321257a00",hostname:"www.broearn.com",mobile:{universal:"https://www.broearn.com/link/wallet/"}},copiosa:{id:"07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80",displayName:"Copiosa",image_id:"cae1be94-9f53-4eba-b915-f6e381d5a500",hostname:"copiosa.io",mobile:{universal:"https://copiosa.io/action/"}},burrito_wallet:{id:"8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819",displayName:"Burrito Wallet",image_id:"7eec7187-3f48-4fda-53bb-b0ad55749a00",hostname:"burritowallet.com",mobile:{universal:"https://burritowallet.com/wc?uri="}},enjin_wallet:{id:"bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a",displayName:"Enjin Wallet",image_id:"add9626b-a5fa-4c12-178c-e5584e6dcd00",hostname:"enjin.io",mobile:{universal:"https://deeplink.wallet.enjin.io/"}},plasma_wallet:{id:"cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e",displayName:"Plasma Wallet",image_id:"c268e78d-ffb0-4c8b-5cad-04c3add48500",hostname:"plasma-wallet.com",mobile:{universal:"https://plasma-wallet.com"}},avacus:{id:"94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43",displayName:"Avacus",image_id:"a7106965-91cc-4a73-4688-c5c72ae0ed00",hostname:"avacus.cc",mobile:{universal:"https://avacus.app.link"}},bee:{id:"2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715",displayName:"Bee",image_id:"f90bc33f-f085-40cf-7538-fae5ae84f900",hostname:"www.beewallet.app",mobile:{universal:"https://beewallet.app/wc"}},pitaka:{id:"14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc",displayName:"Pitaka",image_id:"691c0716-5213-4b99-e837-079268313800",hostname:"pitaka.io",mobile:{universal:"https://app.pitaka.io"}},pltwallet:{id:"576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd",displayName:"PLTwallet",image_id:"a5d9dd15-8cef-42de-8bed-09e01a8b0200",hostname:"pltwallet.io",mobile:{universal:"https://pltwallet.io/"}},minerva:{id:"49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd",displayName:"Minerva",image_id:"b57b2163-1bd8-4f6b-3311-470767e6d200",hostname:"minerva.digital",mobile:{universal:"https://minerva.digital"}},kryptogo:{id:"19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b",displayName:"KryptoGO",image_id:"3ccbd966-97e8-45a0-1ceb-6141a8978e00",hostname:"kryptogo.com",mobile:{universal:"https://kryptogo.page.link"}},prema:{id:"5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b",displayName:"PREMA",image_id:"6487869b-1165-4f30-aa3a-115665be8300",hostname:"premanft.com",mobile:{universal:"https://premanft.com"}},slingshot:{id:"d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b",displayName:"Slingshot",image_id:"10c75467-6612-48ad-b97b-63985e922200",hostname:"slingshot.finance",mobile:{universal:"https://app.slingshot.finance"}},kriptonio:{id:"50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b",displayName:"Kriptonio",image_id:"363fae03-882a-4d81-a721-6e6f6e9ac500",hostname:"kriptonio.com",mobile:{universal:"https://app.kriptonio.com/mobile"}},timeless:{id:"9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8",displayName:"Timeless",image_id:"32e89601-0490-42fc-0cc4-8627d62a2000",hostname:"timelesswallet.xyz",mobile:{universal:"https://timelesswallet.xyz"}},secux:{id:"6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa",displayName:"SecuX",image_id:"98183be0-3125-45ee-a6b6-fbd47ebefd00",hostname:"secuxtech.com",mobile:{universal:"https://wsweb.secuxtech.com"}},bitizen:{id:"41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071",displayName:"Bitizen",image_id:"75dd1471-77e9-4811-ce57-ec8fc980ec00",hostname:"bitizen.org",mobile:{universal:"https://bitizen.org/wallet"}},blocto:{id:"14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd",displayName:"Blocto",image_id:"374258d3-c749-4f37-7815-77e61f798c00",hostname:"blocto.io",mobile:{universal:"https://blocto.app"}},safemoon:{id:"a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1",displayName:"SafeMoon",image_id:"ea0140c7-787c-43a4-838f-d5ab6a342000",hostname:"safemoon.com",mobile:{universal:"https://safemoon.com/wc"}}},ll=(e,t="md")=>`https://registry.walletconnect.com/v2/logo/${t}/${e}`;function Qi(e){return{name:e.displayName||"",universalLink:e.mobile.universal||"",deepLink:e.mobile.native||""}}function Rp(e){let t="mobile";return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Qi(o))}function cl(){return Rp(sl)}function dl(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${e}`:""}function pl(e,t){return So.isAndroid?e:dl(e,Qi(t))}var ul="WALLETCONNECT_DEEPLINK_CHOICE";function al(e){let t=e.href.split("?")[0];Z.put(ul,{...e,href:t})}var Rr=(e,t)=>{if(!e||So.isDesktop){Z.del(ul);return}if(So.isAndroid){al({name:"Unknown",href:t||"wc:"});return}else if(So.isMobileOnly){let o=dl(t||"wc:",Qi(e));al({name:(e==null?void 0:e.displayName)||"",href:o})}};var Ir=class extends Le{constructor(o,r,n){super(n||"unknown");this.connectorType="wallet_connect_v2";this.walletConnectCloudProjectId=o,this.rpcConfig=r,this.proxyProvider=new oe,this.createProvider().then(i=>{var a,l;if(this.provider=i,this.proxyProvider.setWalletProvider(i),this.subscribeListeners(),i.session){if((a=this.walletProvider.session)!=null&&a.peer.metadata.url){let s=Sn((l=this.walletProvider.session)==null?void 0:l.peer.metadata.url);this.walletEntry=s==null?void 0:s.entry,this.walletClientType=(s==null?void 0:s.walletClientType)||"unknown",Rr(this.walletEntry)}this.connected=!0,this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}else this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return this.walletProvider.connected}get walletBranding(){var o,r,n;return this.walletEntry?{name:this.walletEntry.displayName,icon:this.walletClientType==="metamask"?_e:ll(this.walletEntry.image_id)}:{name:qi(((o=this.walletProvider.session)==null?void 0:o.peer.metadata.name)||"")||"WalletConnect",icon:((n=(r=this.walletProvider.session)==null?void 0:r.peer.metadata.icons)==null?void 0:n[0])||Yo}}resetConnection(){this.walletProvider&&this.walletProvider.connected&&(this.walletProvider.signer.session=void 0,this.walletEntry=void 0,Rr(void 0),this.onDisconnect())}async promptConnection(){if(!!this.provider)return new Promise((o,r)=>{let n=()=>{r(new jo)};this.onQrModalClosed=n,(async()=>{var s,d;let a="",l=await Promise.race([this.walletProvider.enable(),Ki()]);if(l.length>0&&(a=l[0]),!a||a==="")throw new $("Unable to retrieve address");if((s=this.walletProvider.session)!=null&&s.peer.metadata.url){let C=Sn((d=this.walletProvider.session)==null?void 0:d.peer.metadata.url);this.walletEntry=C==null?void 0:C.entry,this.walletClientType=(C==null?void 0:C.walletClientType)||"unknown"}this.connected=!0,await this.syncAccounts(l),o()})().catch(a=>{if(a){r(kt(a));return}r(new $("Unknown error during connection"))}).finally(()=>kn.default.close())})}disconnect(){this.walletProvider.disconnect().then(()=>this.onDisconnect()).catch(()=>console.warn("Unable to disconnect Wallet Connect provider"))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(o){this.proxyProvider.setWalletProvider(o)}async createProvider(){let o={};for(let n of no){let i=St(n.id,this.rpcConfig);i&&(o[n.id]=i)}let r=await Jo.EthereumProvider.init({projectId:this.walletConnectCloudProjectId,chains:[1],optionalChains:no.map(n=>n.id),optionalEvents:Jo.OPTIONAL_EVENTS,optionalMethods:Jo.OPTIONAL_METHODS,rpcMap:o,showQrModal:!1});return r.on("display_uri",n=>{if(Rn.isAndroid)window.open(n,"_self");else if(Rn.isMobile&&this.walletEntry){Rr(this.walletEntry,n);let a=pl(n,this.walletEntry);window.open(a,"_self","noopener,noreferrer")}else kn.default.open(n,()=>{this.onQrModalClosed&&this.onQrModalClosed()},{mobileLinks:cl().map(i=>i.name)})}),r.on("connect",()=>{var n,i;if(kn.default.close(),(n=r.session)!=null&&n.peer.metadata.url){let a=Sn((i=r.session)==null?void 0:i.peer.metadata.url);this.walletEntry=a==null?void 0:a.entry,this.walletClientType=(a==null?void 0:a.walletClientType)||"unknown",Rr(this.walletEntry)}}),r}async enableProvider(){return this.walletProvider.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider.enable()}};var Xi=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses");return t?!!(e==null?void 0:e.linkedAccounts.filter(r=>r.type=="wallet"&&r.address===(0,Zi.getAddress)(t)).length):!1},Qo=class extends ml.default{constructor(o,r){super();this.getEthereumProvider=()=>{let o=this.wallets[0],r=this.walletConnectors.find(n=>n.wallets.find(i=>i.address===(o==null?void 0:o.address)));return!o||!r?new oe:r.proxyProvider};this.walletConnectCloudProjectId=o,this.rpcConfig=r,this.walletConnectors=[],this.initialized=!1,this.storedConnections=this.loadConnectionHistory()}get wallets(){let o=new Set,r=this.walletConnectors.flatMap(i=>i.wallets).sort((i,a)=>i.connectedAt&&a.connectedAt?a.connectedAt-i.connectedAt:0).filter(i=>{let a=`${i.address}${i.walletClientType}${i.connectorType}`;return o.has(a)?!1:(o.add(a),!0)}),n=r.findIndex(i=>i.address===(this.activeWallet?this.activeWallet:"unknown"));return n>=0&&r.unshift(r.splice(n,1)[0]),r}initialize(){this.initialized||(Z.get(Bi)&&(Z.getKeys().forEach(o=>{o.startsWith("walletconnect")&&Z.del(o)}),Z.del(Bi)),qs().then(o=>o.forEach(r=>{switch(r){case"metamask":this.createWalletConnector("injected","metamask");break;case"phantom":this.createWalletConnector("injected","phantom");break;case"unknown":default:break}})),(io()||Z.getKeys().find(o=>o.startsWith("-walletlink")))&&this.createWalletConnector("coinbase_wallet","coinbase_wallet"),this.createWalletConnector("wallet_connect_v2","unknown"),this.initialized=!0)}findWalletConnector(o,r){return o==="wallet_connect_v2"?this.walletConnectors.find(n=>n.connectorType===o)||null:this.walletConnectors.find(n=>n.connectorType===o&&n.walletClientType===r)||null}onInitialized(o){o.wallets.forEach(r=>{let n=this.storedConnections.find(i=>i.address===r.address&&i.connectorType===r.connectorType&&i.walletClientType===r.walletClientType);n&&(r.connectedAt=n.connectedAt)}),this.saveConnectionHistory(),this.emit("walletsUpdated")}onWalletsUpdated(o){o.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnector(o,r){if(!this.findWalletConnector("embedded","privy")){let i=new wn(o,r,this.rpcConfig),a=new Tn(i);this.addWalletConnector(a)}}removeEmbeddedWalletConnector(){let o=this.findWalletConnector("embedded","privy");if(o){let r=this.walletConnectors.indexOf(o);this.walletConnectors.splice(r,1),this.saveConnectionHistory(),this.emit("walletsUpdated")}}async createWalletConnector(o,r){let n=this.findWalletConnector(o,r);if(n)return n instanceof Ir&&n.resetConnection(),n;let a=(()=>{switch(o){case"injected":switch(r){case"phantom":return nt()?new _n:null;case"metamask":default:return Pr()?new Pn:null}case"coinbase_wallet":return new xn;case"wallet_connect_v2":return new Ir(this.walletConnectCloudProjectId,this.rpcConfig)}})();return a&&this.addWalletConnector(a),a||null}addWalletConnector(o){this.walletConnectors.push(o),o.on("initialized",()=>this.onInitialized(o)),o.on("walletsUpdated",()=>this.onWalletsUpdated(o))}loadConnectionHistory(){let o=a=>a&&typeof a.address=="string"&&typeof a.connectorType=="string"&&typeof a.walletClientType=="string"&&typeof a.connectedAt=="number",r=Z.get(Gi);return r&&Array.isArray(r)&&r.map(a=>o(a)).every(Boolean)?r:[]}saveConnectionHistory(){let o=this.wallets.map(r=>({address:r.address,connectorType:r.connectorType,walletClientType:r.walletClientType,connectedAt:r.connectedAt}));Z.put(Gi,o)}async activeWalletSign(o){let r=this.wallets,n=r.length>0?r[0]:null;return n?n.sign(o):null}setActiveWallet(o){this.activeWallet=(0,Zi.getAddress)(o),this.emit("walletsUpdated")}};function Cn(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++){let r=e[o],n=t[o];if((r==null?void 0:r.address)!==(n==null?void 0:n.address)||(r==null?void 0:r.chainId)!==(n==null?void 0:n.chainId)||(r==null?void 0:r.connectorType)!==(n==null?void 0:n.connectorType)||(r==null?void 0:r.connectedAt)!==(n==null?void 0:n.connectedAt)||(r==null?void 0:r.walletClientType)!==(n==null?void 0:n.walletClientType)||(r==null?void 0:r.isConnected)!==(n==null?void 0:n.isConnected)||(r==null?void 0:r.linked)!==(n==null?void 0:n.linked))return!1}return!0}var hl=require("ofetch");var Ip=[cn(),dn()],Wp=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},In=class{constructor(t,o,r){this.appId=t,this.sdkVersion=mn,this.client=o,this.defaults=r,this.fallbackApiUrl=o.fallbackApiUrl,this.baseFetch=hl.ofetch.create({baseURL:this.defaults.baseURL,retry:3,retryDelay:500,credentials:"include",onRequest:async({request:n,options:i})=>{let a=new Headers(i.headers);a.set("privy-app-id",this.appId),a.set("privy-client",`react-auth:${this.sdkVersion}`);let l=!Ip.includes(n.toString());if(!a.has("authorization")&&l){let s=await this.client.getAccessToken();s!==null&&a.set("authorization",`Bearer ${s}`)}i.headers=a,i.signal||(i.signal=Wp(this.defaults.timeout))},onRequestError:({error:n})=>{if(n instanceof DOMException&&n.name==="AbortError")throw new ln}})}async get(t,o){try{return await this.baseFetch(t,o)}catch(r){throw ae(r)}}async post(t,o,r){try{return await this.baseFetch(t,{method:"POST",...o?{body:o}:{},...r})}catch(n){throw ae(n)}}async delete(t,o){try{return await this.baseFetch(t,{method:"DELETE",...o})}catch(r){throw ae(r)}}};var Wr=_(require("js-cookie"));function fl(e){return e instanceof Po?"email":e instanceof Ao?"sms":e instanceof _o?"siwe":e instanceof zo?"custom_auth":e instanceof to?e.meta.provider:null}var yl=_(require("jose")),It=class{static parse(t){try{return new It(t)}catch{return null}}constructor(t){this.value=t,this._decoded=yl.decodeJwt(t)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(t=0){let o=Date.now(),r=(this.expiration-t)*1e3;return o>=r}};var Np=30,Wn=class{constructor(){this.authenticateOnce=new rt(async t=>this._authenticate(t)),this.linkOnce=new rt(async t=>this._link(t)),this.refreshOnce=new rt(this._refresh.bind(this)),this.destroyOnce=new rt(this._destroy.bind(this)),this.forkSessionOnce=new rt(this._forkSession.bind(this))}get token(){try{let t=Z.get(Vo);return typeof t=="string"?new It(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=Z.get(hn);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=Z.get(Tr);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}hasRefreshCredentials(){var t;return((t=this.client)==null?void 0:t.useServerCookies)||typeof this.token=="string"&&typeof this.refreshToken=="string"}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=It.parse(this.token);return t!==null&&!t.isExpired(Np)}authenticate(t){return this.authenticateOnce.execute(t)}link(t){return this.linkOnce.execute(t)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(t){try{let{token:o,refresh_token:r,user:n,is_new_user:i}=await t.authenticate();this.storeToken(o),this.storeRefreshToken(r);let a=fl(t);return a&&this.client&&this.client.createAnalyticsEvent("sdk_authenticate",{method:a,isNewUser:i}),a==="siwe"&&this.client&&this.client.createAnalyticsEvent("sdk_authenticate_siwe",{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}),{user:Ft(n),isNewUser:i}}catch(o){throw console.warn("Error authenticating session"),ot(o)}}async _link(t){try{let o=await t.link();return Ft(o)}catch(o){throw console.warn("Error linking account"),ot(o)}}async _refresh(){if(!this.api)throw new T("Session has no API instance");if(!this.client)throw new T("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,o=this.refreshToken,r=this.forkedToken;try{let n;if(t&&o)n=await this.api.post(cn(),{refresh_token:o},{headers:{authorization:`Bearer ${t}`}}),r&&this.clearForkedToken();else if(r)n=await this.api.post(dn(),{refresh_token:r}),this.clearForkedToken();else return null;return this.storeToken(n.token),this.storeRefreshToken(n.refresh_token),Ft(n.user)}catch(n){if(n instanceof Go&&n.status===400&&n.message==="Invalid auth token")return this.destroyLocalState(),null;throw ot(n)}}async _destroy(){var t;try{await((t=this.api)==null?void 0:t.post(Ja(),{refresh_token:this.refreshToken}))}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new T("Session has no API instance");let t=this.refreshToken;try{let o=await this.api.post(Qa(),{refresh_token:t});return this.storeToken(o.token),this.storeRefreshToken(o.refresh_token),o.new_session_refresh_token}catch(o){throw ot(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),this.clearForkedToken()}storeToken(t){var o,r;if(typeof t=="string"){if(Z.put(Vo,t),!((o=this.client)!=null&&o.useServerCookies)){let n=(r=It.parse(t))==null?void 0:r.expiration;Wr.default.set(Di,t,{sameSite:"Strict",secure:!0,expires:n?new Date(n*1e3):void 0})}}else Z.del(Vo),Wr.default.remove(Di)}storeRefreshToken(t){var o;typeof t=="string"?(Z.put(hn,t),(o=this.client)!=null&&o.useServerCookies||Wr.default.set(Ui,t,{sameSite:"Strict",secure:!0,expires:30})):(Z.del(hn),Wr.default.remove(Ui))}clearForkedToken(){Z.del(Tr)}};var ea,Zo=class{constructor(t){this.apiUrl=t.apiUrl||un,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!1,this.timeout=t.timeout||ws,this.appId=t.appId,this.clientAnalyticsId=typeof window>"u"?null:(0,gl.v4)(),ea||(ea=new Wn),this.session=ea,this.api=this.generateApi(),this.session.client=this}initializeConnectorManager(t,o){this.connectors||(this.connectors=new Qo(t,o))}generateApi(){let t=new In(this.appId,this,{baseURL:this.apiUrl,timeout:this.timeout});return this.session.api=t,t}updateApiUrl(t){this.apiUrl=t||this.fallbackApiUrl,this.api=this.generateApi(),t&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new T("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new T("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.authFlow=void 0}startAuthFlow(t){t.api=this.api,this.authFlow=t}async unlinkEmail(t){try{let o=await this.api.post(ps(),{address:t});return Ft(o)}catch(o){throw ot(o)}}async unlinkPhone(t){try{let o=await this.api.post(us(),{phoneNumber:t});return Ft(o)}catch(o){throw ot(o)}}async unlinkWallet(t){try{let o=await this.api.post(ds(),{address:t});return Ft(o)}catch(o){throw ot(o)}}async unlinkOAuth(t,o){try{let r=await this.api.post(ms(),{provider:t,subject:o});return Ft(r)}catch(r){throw ot(r)}}async createAnalyticsEvent(t,o,r){if(!(typeof window>"u"))try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(hs(),{event_name:t,client_id:this.clientAnalyticsId,payload:{...o||{},clientTimestamp:r?r.toISOString():new Date().toISOString()}})}catch{}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){var o;return this.session.hasActiveToken()?((o=It.parse(this.session.token))==null?void 0:o.audience)!==this.appId?(await this.logout(),null):this.session.token:!(t!=null&&t.disableAutoRefresh)&&this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getServerConfig(){var t,o;try{let r=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl});return{id:r.id,name:r.name,verificationKey:r.verification_key,logoUrl:r.logo_url||void 0,accentColor:r.accent_color||void 0,showWalletLoginFirst:r.show_wallet_login_first,allowlistConfig:{errorTitle:r.allowlist_config.error_title,errorDetail:r.allowlist_config.error_detail,errorCtaText:r.allowlist_config.cta_text,errorCtaLink:r.allowlist_config.cta_link},walletAuth:r.wallet_auth,emailAuth:r.email_auth,smsAuth:r.sms_auth,googleOAuth:r.google_oauth,twitterOAuth:r.twitter_oauth,discordOAuth:r.discord_oauth,githubOAuth:r.github_oauth,appleOAuth:r.apple_oauth,termsAndConditionsUrl:r.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:(t=r.embedded_wallet_config)==null?void 0:t.create_on_login,requireUserPasswordOnCreate:(o=r.embedded_wallet_config)==null?void 0:o.require_user_password_on_create},privacyPolicyUrl:r.privacy_policy_url,customApiUrl:r.custom_api_url,walletConnectCloudProjectId:r.wallet_connect_cloud_project_id,captchaEnabled:r.captcha_enabled,createdAt:new Date(r.created_at*1e3),updatedAt:new Date(r.updated_at*1e3)}}catch(r){throw ot(r)}}async getUsdTokenPrice(t){try{return(await this.api.get(`/api/v1/token_price?chainId=${t}`)).usd}catch{console.warn(`Unable to fetch token price for chain with id ${t}`);return}}async forkSession(){return await this.session.forkSession()}};var XC=require("wicg-inert"),Pi=require("body-scroll-lock"),_i=require("react"),Ua=require("react"),Ld=_(require("react-dom")),Ai=_(require("styled-components"));var Nn=require("react");var ta=(0,Nn.createContext)({isNewUserThisSession:!1,isLinking:!1,linkingHint:null,walletConnectionStatus:null,rpcConfig:{rpcUrls:{}},captchaData:{enabled:!1,ready:!1,execute:P,remove:P,token:void 0,error:void 0},initializeWalletProxy:P,getAuthMeta:P,getAuthFlow:P,closePrivyModal:P,connectWallet:P,initLoginWithWallet:P,loginWithWallet:P,loginWithCode:P,initLoginWithEmail:P,initLoginWithSms:P,resendEmailCode:P,resendSmsCode:P,initLoginWithOAuth:P,loginWithOAuth:P,refreshUser:P,walletProxy:null,createAnalyticsEvent:P,getUsdTokenPrice:P,recoverEmbeddedWallet:P}),N=()=>(0,Nn.useContext)(ta);var Ln=require("react");var $t=(0,Ln.createContext)({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:P,login:P,linkEmail:P,linkPhone:P,linkWallet:P,linkGoogle:P,linkTwitter:P,linkDiscord:P,linkGithub:P,linkApple:P,logout:P,getAccessToken:P,getEthereumProvider:P,getEthersProvider:P,getWeb3jsProvider:P,unlinkEmail:P,unlinkPhone:P,unlinkWallet:P,unlinkGoogle:P,unlinkTwitter:P,unlinkDiscord:P,unlinkGithub:P,unlinkApple:P,setActiveWallet:P,forkSession:P,createWallet:P,signMessage:P,sendTransaction:P,exportWallet:P}),Y=()=>(0,Ln.useContext)($t);var Hn=_(require("styled-components"));var Wt=_(require("styled-components"));var Mn=_(require("styled-components")),co=require("react/jsx-runtime"),On=({success:e,fail:t})=>(0,co.jsxs)(co.Fragment,{children:[(0,co.jsx)(Nr,{className:e?"success":t?"fail":""}),(0,co.jsx)(Lp,{className:e?"success":t?"fail":""})]}),Nr=Mn.default.span`
|
|
12
|
+
- https://privy.io`;this.getNonceOnce=new rt(this._getNonceOnce.bind(this)),this.wallet=t}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType}}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Xa(),{message:t,signature:o,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType});return{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(t){throw ae(t)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign();return await this.api.post(es(),{message:t,signature:o,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw ae(t)}}async sign(){if(!this.api)throw new T("Auth flow has no API instance");if(await this.buildSiweMessage(),!this.preparedMessage)throw new T("Could not prepare SIWE message");let t=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async _getNonceOnce(){if(!this.api)throw new T("Auth flow has no API instance");let t=this.wallet.address;return(await this.api.post(Za(),{address:t})).nonce}async buildSiweMessage(){if(!this.api)throw new T("Auth flow has no API instance");let t=this.wallet.address,o=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=this.prepareMessage(o,t,this.nonce),this.preparedMessage}prepareMessage(t,o,r){let n=window.location.host,i=window.location.origin,a="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",l=new Date().toISOString();return this.createSiweMessage(t,o,n,i,l,r,a)}};var Ao=class{constructor(t,o){this.meta={phoneNumber:t,captchaToken:o}}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{let t=is(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ae(t)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{let t=as();return await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw ae(t)}}async sendSmsCode(t,o){if(!this.api)throw new T("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),o&&(this.meta.captchaToken=o),!this.meta.phoneNumber)throw new T("phone nNumber must be set when initialzing authentication.");try{let r=ns();return await this.api.post(r,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(r){throw ae(r)}}};var gl=require("uuid");function At(e){return new Date(e*1e3)}function gp(e){let t=[];for(let o of e){let r=o.type;switch(o.type){case"wallet":let n={address:o.address,type:o.type,verifiedAt:At(o.verified_at),chainType:"ethereum",chainId:o.chain_id,walletClient:o.wallet_client_type==="privy"?"privy":"unknown",walletClientType:o.wallet_client_type,connectorType:o.connector_type,recoveryMethod:o.recovery_method};t.push(n);break;case"email":let i={address:o.address,type:o.type,verifiedAt:At(o.verified_at)};t.push(i);break;case"phone":let a={number:o.phoneNumber,type:o.type,verifiedAt:At(o.verified_at)};t.push(a);break;case"google_oauth":let l={subject:o.subject,email:o.email,name:o.name,type:o.type,verifiedAt:At(o.verified_at)};t.push(l);break;case"twitter_oauth":let s={subject:o.subject,username:o.username,name:o.name,type:o.type,verifiedAt:At(o.verified_at)};t.push(s);break;case"discord_oauth":let d={subject:o.subject,username:o.username,email:o.email,type:o.type,verifiedAt:At(o.verified_at)};t.push(d);break;case"github_oauth":let C={subject:o.subject,username:o.username,name:o.name,email:o.email,type:o.type,verifiedAt:At(o.verified_at)};t.push(C);break;case"apple_oauth":let g={subject:o.subject,email:o.email,type:o.type,verifiedAt:At(o.verified_at)};t.push(g);break;case"custom_auth":t.push({type:o.type,customUserId:o.custom_user_id,verifiedAt:At(o.verified_at)});break;default:console.warn(`Unrecognized account type: ${r}. Please consider upgrading the Privy SDK.`)}}return t}function oo(e,t){return e.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),e.find(o=>o.type===t)}var ce=e=>e==null?void 0:e.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClient==="privy"),vp=e=>e.linkedAccounts.filter(t=>t.type==="wallet"),ro=(e,t)=>{var o;return t==="all-users"&&!ce(e)||t==="users-without-wallets"&&!((o=vp(e))!=null&&o.length)};function Ft(e){if(!e)return null;let t=gp(e.linked_accounts),o=oo(t,"wallet"),r=oo(t,"email"),n=oo(t,"phone"),i=oo(t,"google_oauth"),a=oo(t,"twitter_oauth"),l=oo(t,"discord_oauth"),s=oo(t,"github_oauth"),d=oo(t,"apple_oauth");return{id:e.id,createdAt:At(e.created_at),linkedAccounts:t,email:r&&{address:r==null?void 0:r.address},phone:n&&{number:n==null?void 0:n.number},wallet:o&&{address:o.address,chainType:o.chainType,chainId:o.chainId,walletClient:o.walletClient,walletClientType:o.walletClientType,connectorType:o.connectorType,recoveryMethod:o.recoveryMethod},google:i&&{subject:i.subject,email:i.email,name:i.name},twitter:a&&{subject:a.subject,username:a.username,name:a.name},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:s&&{subject:s.subject,username:s.username,name:s.name,email:s.email},apple:d&&{subject:d.subject,email:d.email}}}var Zi=require("@ethersproject/address"),ml=_(require("eventemitter3"));var ys="1.35.0";var pn="4df5e2316331463a9130964bd6078dfa",gs="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",vs="34357d3c125c2bcf2ce2bc3309d98715",bs="0x4AAAAAAAJFhr_rDU7HKpyw",un="https://auth.privy.io",ws=2e4,yt=1400,Cs=4500,mn=ys;var Vo="privy:token",Di="privy-token",hn="privy:refresh_token",Ui="privy-refresh-token",Tr="privy:session_transfer_token",wp="privy:wallet",Fi=e=>`${wp}:${e}`,Bi="privy:connectors",Gi="privy:connections";var gt=1,fn="0x1";var Hi=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},zi=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Cp(){return typeof window<"u"&&window.localStorage?new zi:new Hi}var Z=Cp();var Gs=require("libphonenumber-js/min");var Es={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var xs={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var Ts={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}};var Ps={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0};var _s={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var As={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var Ss={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1};var ks={id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0};var Rs={id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}};var Is={id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}};var Ws={id:5,network:"goerli",name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-goerli.g.alchemy.com/v2"],webSocket:["wss://eth-goerli.g.alchemy.com/v2"]},infura:{http:["https://goerli.infura.io/v3"],webSocket:["wss://goerli.infura.io/ws/v3"]},default:{http:["https://rpc.ankr.com/eth_goerli"]},public:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli.etherscan.io"},default:{name:"Etherscan",url:"https://goerli.etherscan.io"}},testnet:!0};var Ns={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-mainnet.infura.io/v3"],webSocket:["wss://linea-mainnet.infura.io/ws/v3"]},default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1};var Ls={id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0};var Ms={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}};var Os={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var Ds={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var Us={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var Fs={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mumbai.g.alchemy.com/v2"],webSocket:["wss://polygon-mumbai.g.alchemy.com/v2"]},infura:{http:["https://polygon-mumbai.infura.io/v3"],webSocket:["wss://polygon-mumbai.infura.io/ws/v3"]},default:{http:["https://matic-mumbai.chainstacklabs.com"]},public:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"},default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var Bs={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0};var no=[Es,xs,Ws,Bs,Ms,Os,Ds,Us,Fs,Ss,ks,Rs,Is,_s,As,Ns,Ls,Ts,Ps],Vi=e=>no.find(t=>t.id===e),Bt=e=>{var t;return(t=Vi(e))==null?void 0:t.nativeCurrency.symbol};var gn=()=>{let e=window;if(!e.ethereum)return!1;if(yn(window.ethereum,!0))return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(yn(t,!0))return!0}return!1},Pr=()=>{let e=window;if(!e.ethereum)return!1;if(yn(window.ethereum,!1))return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(yn(t,!1))return!0}return!1},yn=(e,t)=>e.isMetaMask?e.isMetaMask&&!t?!0:!(e.isBraveWallet&&!e._events&&!e._state||e.isApexWallet||e.isAvalanche||e.isBitKeep||e.isBlockWallet||e.isKuCoinWallet||e.isMathWallet||e.isOkxWallet||e.isOKExWallet||e.isOneInchIOSWallet||e.isOneInchAndroidWallet||e.isOpera||e.isPhantom||e.isPortal||e.isRabby||e.isRainbow||e.isTokenPocket||e.isTokenary||e.isZerion):!1,nt=()=>{var e,t;if("phantom"in window){let o=window;if((t=(e=o==null?void 0:o.phantom)==null?void 0:e.ethereum)!=null&&t.isPhantom)return!0}return!1},io=()=>{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.isCoinbaseWallet)return!0}return!1};var Hs=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,}))$/),zs=e=>(0,Gs.isPossiblePhoneNumber)(String(e),"US"),Vs=(e,t)=>{let o=e.slice(0),r=[];for(;o.length;)r.push(o.splice(0,t));return r},$o=(e,t=3,o=4)=>{if(!e)return"";let r=2,n=3;if(t+o+r+n>=e.length)return e;let i=e.slice(0,r+t),a=e.slice(e.length-o,e.length);return`${i}...${a}`},$i=e=>new Promise(t=>setTimeout(t,e)),$s=(e,t={})=>{let o=t.delayMs||150,r=t.maxAttempts||270;return new Promise(async(n,i)=>{var s;let a=!1,l=0;for(;!a&&l<r;){if((s=t.abortSignal)!=null&&s.aborted)return;e().then(()=>{a=!0,n()},(...d)=>{a=!0,i(...d)}),l+=1,await $i(o)}a||i(new Error("Exceeded max attempts before resolving function"))})},vn=(e,t,o={})=>{let r=new URL(t,e);for(let[n,i]of Object.entries(o))r.searchParams.set(n,i);return r.href};var qi=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),_r=e=>typeof e=="string"?e:"0x"+e.toString(16);async function qs(e=3e3){let t=!1,o=window;return new Promise(r=>{o.ethereum?n():(window.addEventListener("ethereum#initialized",n,{once:!0}),setTimeout(()=>{n()},e));function n(){if(t)return;t=!0,window.removeEventListener("ethereum#initialized",n);let i=[];gn()&&i.push("metamask"),nt()&&i.push("phantom"),o.ethereum&&o.ethereum.isBraveWallet&&i.push("brave"),r(i)}})}function bn(e){return`eip155:${String(Number(e))}`}var St=(e,t)=>{var n,i,a;let o=no.find(l=>l.id===e);if(!o)throw new $(`Unsupported chainId ${e}`,4901);let r;if(t.rpcUrls[e]?r=t.rpcUrls[e]:(n=o.rpcUrls.infura)!=null&&n.http[0]?r=o.rpcUrls.infura.http[0]+"/"+pn:(i=o.rpcUrls.blast)!=null&&i.http[0]?r=o.rpcUrls.blast.http[0]+"/"+gs:r=(a=o.rpcUrls.default)==null?void 0:a.http[0],!r)throw new $(`No RPC url found for ${e}`);return r};var el=_(require("@coinbase/wallet-sdk"));var Ar=require("react/jsx-runtime"),it=({style:e,...t})=>(0,Ar.jsxs)("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,Ar.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,Ar.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});var zt=require("@ethersproject/address"),Yi=require("@ethersproject/providers"),Xs=_(require("eventemitter3"));var ji=require("@ethersproject/providers"),Ys=_(require("eventemitter3"));var Ep=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4"],js=e=>Ep.includes(e);var Ks=require("@ethersproject/logger");var qo=class extends ${constructor(){super("Wallet timeout");this.type="wallet_error"}},jo=class extends ${constructor(){super("User rejected connection");this.type="wallet_error"}},kt=e=>{if(e instanceof $)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new ao(e);return e.code===Ks.ErrorCode.ACTION_REJECTED&&(t.details=Gt.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new ao(e):new $("Unknown connector error",e)},Sr=class extends ft{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},ao=class extends Sr{constructor(o){var i,a,l;let r=o;super(r.message,r.code,r.data);let n=Object.values(Gt).find(s=>s.eipCode===r.code);this.details=n||Gt.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=Gt.E32002_CONNECTION_ALREADY_PENDING:this.details=Gt.E32002_REQUEST_ALREADY_PENDING:(l=r.message)!=null&&l.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Gt.E32002_WALLET_LOCKED))}},xp={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Tp={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Pp={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},Gt={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Pp,...Tp},Ht={...xp,...Gt};var _p=12e4,Ki=(e=new qo,t=_p)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),oe=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(t,o)}catch{console.warn("Unable to remove wallet provider listener")}};this.setWalletProvider=t=>{this.walletProvider&&this._subscriptions.forEach(o=>{this.removeListener(o.eventName,o.listener)}),this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new $(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),Ki()]).catch(o=>{throw kt(o)})}},so=class extends Error{constructor(o,r,n){super(o);this.code=r,this.data=n}},wn=class extends Ys.default{constructor(o,r,n,i=1){super();this.walletProxy=o,this.address=r,this.chainId=i,this.rpcConfig=n,this.provider=new ji.JsonRpcProvider(St(i,n))}async handleSendTransaction(o){if(!o.params||!Array.isArray(o.params))throw new so(`Invalid params for ${o.method}`,4200);let r=o.params[0];if(!await Rt()||!this.address)throw new so("Disconnected",4900);return(await Qs(r)).transactionHash}handleSwitchEthereumChain(o){if(!o.params||!Array.isArray(o.params))throw new so(`Invalid params for ${o.method}`,4200);let r;if(typeof o.params[0]=="string")r=o.params[0];else if("chainId"in o.params[0]&&typeof o.params[0].chainId=="string")r=o.params[0].chainId;else throw new so(`Invalid params for ${o.method}`,4200);this.chainId=Number(r),this.provider=new ji.JsonRpcProvider(St(this.chainId,this.rpcConfig)),this.emit("chainChanged",r)}async handlePersonalSign(o){if(!o.params||!Array.isArray(o.params))throw new Error("Invalid params for eth_estimateGas");let r=o.params[0];return await Js(r)}async handleEstimateGas(o){if(!o.params||!Array.isArray(o.params))throw new Error("Invalid params for eth_estimateGas");delete o.params[0].gasPrice,delete o.params[0].maxFeePerGas,delete o.params[0].maxPriorityFeePerGas;let r={...o.params[0],chainId:_r(this.chainId)};try{return await this.provider.send("eth_estimateGas",[r])}catch{return delete r.from,await this.provider.send("eth_estimateGas",[r])}}async request(o){switch(console.debug("Embedded1193Provider.request() called with args",o),o.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return _r(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(o);case"eth_sendTransaction":return this.handleSendTransaction(o);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(o);case"personal_sign":return this.handlePersonalSign(o);default:break}if(js(o.method)){let r=await Rt();if(await Zs(),!r||!this.address)throw new so("Disconnected",4900);try{return(await this.walletProxy.rpc({address:this.address,accessToken:r,request:{method:o.method,params:o.params}})).response.data}catch(n){throw console.error(n),new so("Disconnected",4900)}}else return this.provider.send(o.method,o.params)}async connect(){let o=await Rt();if(!o||!this.address)return null;try{return(await this.walletProxy.connect({address:this.address,accessToken:o})).address}catch(r){return console.error(r),null}}},vt=class extends oe{constructor(o){super(o)}},lo=class extends oe{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Le=class extends Xs.default{constructor(o){super();this.onAccountsChanged=o=>{o.length===0?this.onDisconnect():this.syncAccounts(o)};this.onChainChanged=o=>{this.wallets.forEach(r=>{r.chainId=bn(o),this.walletClientType==="privy"&&Z.put(Fi(r.address),o)}),this.emit("walletsUpdated")};this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")};this.onConnect=()=>{this.connected=!0,this.syncAccounts()};this.wallets=[],this.walletClientType=o,this.connected=!1,this.initialized=!1}buildConnectedWallet(o,r){let n=async()=>!!this.wallets.find(i=>(0,zt.getAddress)(i.address)===(0,zt.getAddress)(o));return{address:(0,zt.getAddress)(o),chainId:r,switchChain:async i=>{var C,g,v;if(!n)throw new $("Wallet is not currently connected.");let a,l;if(typeof i=="number"?(a=`0x${i.toString(16)}`,l=i):(a=i,l=Number(i)),r===bn(a))return;let s=Vi(l);if(!s)throw new $(`Unsupported chainId: ${i}`);let d=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:a}]})};try{return await d()}catch(p){if(p.code===4902||((C=p.message)==null?void 0:C.includes("4902")))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:a,chainName:s.name,nativeCurrency:s.nativeCurrency,rpcUrls:[((g=s.rpcUrls.public)==null?void 0:g.http[0])??""]}]}),d();throw this.walletClientType==="rainbow"&&((v=p.message)==null?void 0:v.includes("wallet_switchEthereumChain"))?new $(`Rainbow does not support the chainId ${r}`):p}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:n,getEthereumProvider:async()=>{if(!await n())throw new $("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await n())throw new $("Wallet is not currently connected.");return new Yi.Web3Provider(new vt(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await n())throw new $("Wallet is not currently connected.");return new lo(this.proxyProvider)},sign:async i=>{if(!await n())throw new $("Wallet is not currently connected.");return await this.sign(i)},disconnect:()=>{this.disconnect()}}}async syncAccounts(o){let r=o;if(r===void 0){let d=await this.proxyProvider.request({method:"eth_accounts"});Array.isArray(d)&&(r=d)}if(!r||!Array.isArray(r)||r.length<=0||!r[0])return;let n=r[0],i=(0,zt.getAddress)(n),a=[],l;if(this.walletClientType==="privy"){l=Z.get(Fi(i))||fn;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:l}]})}catch{console.warn(`Unable to switch embedded wallet to chain ID ${l} on initialization`)}}else try{let d=await this.proxyProvider.request({method:"eth_chainId"});if(typeof d!="string")throw new Error("Invalid chainId returned from provider");l=d}catch(d){console.warn(`Failed to get chainId from provider, defaulting to ${fn}`,d),l=fn}let s=bn(l);a.find(d=>(0,zt.getAddress)(d.address)===i)||a.push(this.buildConnectedWallet((0,zt.getAddress)(n),s)),Cn(a,this.wallets)||(this.wallets=a,this.emit("walletsUpdated"))}async getConnectedWallet(){let o=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort((r,n)=>n.connectedAt-r.connectedAt).find(r=>o.find(n=>(0,zt.getAddress)(n)===(0,zt.getAddress)(r.address)))||null}async isConnected(){let o=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(o)&&o.length>0}async sign(o){return await this.connect({showPrompt:!1}),new Yi.Web3Provider(new vt(this.proxyProvider)).getSigner().signMessage(o)}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}};var Ap=e=>{let t=`https://mainnet.infura.io/v3/${pn}`,o=1;return e.makeWeb3Provider(t,o)},En,xn=class extends Le{constructor(){super("coinbase_wallet");this.connectorType="coinbase_wallet";this.proxyProvider=new oe,this.subscribeListeners(),En||(En=new el.default({appName:"Privy",darkMode:!1,headlessMode:!1})),this.proxyProvider.setWalletProvider(Ap(En)),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){En.disconnect()}get walletBranding(){return{name:"Coinbase Wallet",icon:it}}async promptConnection(){try{let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new $("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([o[0]])}catch(o){throw kt(o)}}};var Ji=require("react/jsx-runtime"),Ko=({...e})=>(0,Ji.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,Ji.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:e.color||"var(--privy-color-foreground-3)"})});var Tn=class extends Le{constructor(o){super("privy");this.connectorType="embedded";this.proxyProvider=o,this.subscribeListeners(),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[_r((o==null?void 0:o.chainId)||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Ko}}disconnect(){this.connected=!1}async promptConnection(){}};var Sp=require("@ethersproject/address"),kp=require("@ethersproject/providers"),tl=require("react-device-detect");var Pe=require("react/jsx-runtime"),_e=({style:e,...t})=>(0,Pe.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...e},...t,children:[(0,Pe.jsx)("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),(0,Pe.jsx)("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),(0,Pe.jsx)("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),(0,Pe.jsx)("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),(0,Pe.jsx)("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),(0,Pe.jsx)("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),(0,Pe.jsx)("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),(0,Pe.jsx)("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),(0,Pe.jsx)("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),(0,Pe.jsx)("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),(0,Pe.jsx)("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),(0,Pe.jsx)("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),(0,Pe.jsx)("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]});var Pn=class extends Le{constructor(){super("metamask");this.connectorType="injected";this.proxyProvider=new oe,this.subscribeListeners();let o=window,r=o.ethereum,n=o.ethereum.providers||[];for(let i of n)if(i.isMetaMask){r=i;break}this.proxyProvider.setWalletProvider(r),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:"MetaMask",icon:_e}}disconnect(){console.warn("Metamask does not support programmatic disconnect.")}async promptConnection(){try{!tl.isMobile&&gn()&&await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new $("Unable to retrieve accounts");await this.syncAccounts([o[0]])}catch(o){throw kt(o)}}};var kr=require("react/jsx-runtime"),at=({style:e,...t})=>(0,kr.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...e},...t,children:[(0,kr.jsx)("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),(0,kr.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});var _n=class extends Le{constructor(){super("phantom");this.connectorType="injected";this.proxyProvider=new oe,this.subscribeListeners(),this.proxyProvider.setWalletProvider(window.phantom.ethereum),this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:"Phantom",icon:at}}disconnect(){console.warn("Phantom does not support programmatic disconnect.")}async promptConnection(){try{let o=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!o||o.length===0||!o[0])throw new $("Unable to retrieve accounts");await this.syncAccounts([o[0]])}catch(o){throw kt(o)}}};var Jo=require("@walletconnect/ethereum-provider"),kn=_(require("@walletconnect/qrcode-modal")),Rn=require("react-device-detect");var wt=require("react");var rl=require("react/jsx-runtime");function ol(e){return(0,rl.jsx)("link",{rel:"prefetch",href:e.src})}var An=require("react/jsx-runtime"),bt="LANDING",nl=(0,wt.createContext)({ready:!1,app:null,currentScreen:bt,lastScreen:bt,navigate:P,navigateBack:P,resetNavigation:P,setModalData:P}),il=e=>{var C,g,v;let t=e.appConfig,o=e.authenticated,r=e.visible,[n,i]=(0,wt.useState)(e.initialScreen||bt),[a,l]=(0,wt.useState)(e.initialScreen||bt);(0,wt.useEffect)(()=>{o||i(bt)},[o]),(0,wt.useEffect)(()=>{r||(l(bt),i(bt))},[r]),(0,wt.useEffect)(()=>{e.initialScreen&&n===bt&&(i(e.initialScreen),l(e.initialScreen))},[e.initialScreen]);let s=e.initialScreen&&n===bt?e.initialScreen:n,d={ready:!!(t!=null&&t.id),app:t,data:e.data,setModalData:e.setModalData,currentScreen:s,lastScreen:a,navigate:p=>{l(n),i(p)},navigateBack:()=>{i(a)},resetNavigation:()=>{e.setInitialScreen(null),l(bt),i(bt)}};return(0,An.jsxs)(nl.Provider,{value:d,children:[(typeof((C=t==null?void 0:t.appearance)==null?void 0:C.logo)=="string"||((v=(g=t==null?void 0:t.appearance)==null?void 0:g.logo)==null?void 0:v.type)==="img")&&(0,An.jsx)(ol,{src:typeof t.appearance.logo=="string"?t.appearance.logo:t.appearance.logo.props.src}),e.children]})},x=()=>(0,wt.useContext)(nl);var Vt=require("react/jsx-runtime"),Yo=({style:e,...t})=>{let{app:o}=x();return(0,Vt.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,Vt.jsx)("rect",{width:"28",height:"28",rx:"3",fill:(o==null?void 0:o.appearance.palette.colorScheme)==="dark"?"#3396ff":"#141414"}),(0,Vt.jsx)("g",{clipPath:"url(#clip0_1765_9946)",children:(0,Vt.jsx)("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),(0,Vt.jsx)("defs",{children:(0,Vt.jsx)("clipPath",{id:"clip0_1765_9946",children:(0,Vt.jsx)("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};var So=require("react-device-detect");var Sn=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[o,r]of Object.entries(sl))if(r.hostname===t)return{walletClientType:o,entry:r}};var sl={metamask:{id:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",displayName:"MetaMask",image_id:"5195e9db-94d8-4579-6f11-ef553be95100",hostname:"metamask.io",mobile:{native:"metamask:"}},trust:{id:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",displayName:"Trust",image_id:"0528ee7e-16d1-4089-21e3-bbfb41933100",hostname:"trustwallet.com",mobile:{universal:"https://link.trustwallet.com"}},safe:{id:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",displayName:"Safe",image_id:"a1cb2777-f8f9-49b0-53fd-443d20ee0b00",hostname:"safe.global",mobile:{universal:"https://app.safe.global/"}},rainbow:{id:"1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",displayName:"Rainbow",image_id:"7a33d7f1-3d12-4b5c-f3ee-5cd83cb1b500",hostname:"rainbow.me",mobile:{universal:"https://rnbwapp.com"}},uniswap:{id:"c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a",displayName:"Uniswap",image_id:"bff9cf1f-df19-42ce-f62a-87f04df13c00",hostname:"uniswap.org",mobile:{universal:"https://uniswap.org/app"}},zerion:{id:"ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18",displayName:"Zerion",image_id:"f216b371-96cf-409a-9d88-296392b85800",hostname:"zerion.io",mobile:{universal:"https://wallet.zerion.io"}},argent:{id:"bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6",displayName:"Argent",image_id:"215158d2-614b-49c9-410f-77aa661c3900",hostname:"www.argent.xyz",mobile:{universal:"https://www.argent.xyz/app"}},spot:{id:"74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d",displayName:"Spot",image_id:"1bf33a89-b049-4a1c-d1f6-4dd7419ee400",hostname:"www.spot-wallet.com",mobile:{universal:"https://spot.so"}},omni:{id:"afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7",displayName:"Omni",image_id:"2cd67b4c-282b-4809-e7c0-a88cd5116f00",hostname:"omni.app",mobile:{universal:"https://links.omni.app"}},cryptocom:{id:"f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d",displayName:"Crypto.com",image_id:"7c5ff577-a68d-49c5-02cd-3d83637b0b00",hostname:"crypto.com",mobile:{universal:"https://wallet.crypto.com"}},blockchain:{id:"84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04",displayName:"Blockchain",image_id:"6f913b80-86c0-46f9-61ca-cc90a1805900",hostname:"www.blockchain.com",mobile:{universal:"https://www.blockchain.com"}},safepal:{id:"0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150",displayName:"SafePal",image_id:"252753e7-b783-4e03-7f77-d39864530900",hostname:"safepal.com",mobile:{universal:"https://link.safepal.io"}},bitkeep:{id:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",displayName:"BitKeep",image_id:"3f7075d0-4ab7-4db5-404d-3e4c05e6fe00",hostname:"bitkeep.com",mobile:{universal:"https://bkapp.vip"}},zengo:{id:"9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0",displayName:"ZenGo",image_id:"cfc07342-23ea-4f3f-f071-ec9d2cd86b00",hostname:"zengo.com",mobile:{universal:"https://get.zengo.com/"}},"1inch":{id:"c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576",displayName:"1inch",image_id:"52b1da3c-9e72-40ae-5dac-6142addd9c00",hostname:"wallet.1inch.io",mobile:{universal:"https://wallet.1inch.io/wc/"}},binance:{id:"8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4",displayName:"Binance",image_id:"ebac7b39-688c-41e3-7912-a4fefba74600",hostname:"www.binance.com",mobile:{universal:"https://app.binance.com/cedefi"}},exodus:{id:"e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4",displayName:"Exodus",image_id:"4c16cad4-cac9-4643-6726-c696efaf5200",hostname:"exodus.com",mobile:{universal:"https://exodus.com/m"}},mew_wallet:{id:"f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2",displayName:"MEW wallet",image_id:"e2024511-2c9b-46d7-3111-52df3d241700",hostname:"mewwallet.com",mobile:{universal:"https://mewwallet.com"}},alphawallet:{id:"138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98",displayName:"AlphaWallet",image_id:"5b1cddfb-056e-4e78-029a-54de5d70c500",hostname:"alphawallet.com",mobile:{universal:"https://aw.app"}},keyring_pro:{id:"47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83",displayName:"KEYRING PRO",image_id:"dda0f0fb-34e8-4a57-dcea-b008e7d1ff00",hostname:"keyring.app",mobile:{universal:"https://keyring.app/"}},mathwallet:{id:"7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26",displayName:"MathWallet",image_id:"26a8f588-3231-4411-60ce-5bb6b805a700",hostname:"mathwallet.org",mobile:{universal:"https://www.mathwallet.org"}},unstoppable:{id:"8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3",displayName:"Unstoppable",image_id:"4725dda0-4471-4d0f-7adf-6bbe8b929c00",hostname:"unstoppabledomains.com",mobile:{universal:"https://unstoppabledomains.com/mobile"}},obvious:{id:"031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa",displayName:"Obvious",image_id:"61abe2ca-b06d-4a8b-de3e-8326f523e900",hostname:"obvious.technology",mobile:{universal:"https://wallet.obvious.technology"}},ambire:{id:"2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568",displayName:"Ambire",image_id:"c39b3a16-1a38-4588-f089-cb7aeb584700",hostname:"www.ambire.com",mobile:{universal:"https://mobile.ambire.com"}},internet_money_wallet:{id:"dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd",displayName:"Internet Money Wallet",image_id:"204b2240-5ce4-4996-6ec4-f06a22726900",hostname:"internetmoney.io",mobile:{universal:"https://internetmoney.io"}},coin98:{id:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",displayName:"Coin98",image_id:"fc460647-ea95-447a-99f0-1bff8fa4be00",hostname:"coin98.com",mobile:{universal:"https://coin98.services"}},abc_wallet:{id:"b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f",displayName:"ABC Wallet",image_id:"f9854c79-14ba-4987-42e1-4a82abbf5700",hostname:"myabcwallet.io",mobile:{universal:"https://abcwalletconnect.page.link"}},arculus_wallet:{id:"0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92",displayName:"Arculus Wallet",image_id:"f78dab27-7165-4a3d-fdb1-fcff06c0a700",hostname:"www.getarculus.com",mobile:{universal:"https://gw.arculus.co/app"}},haha:{id:"719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3",displayName:"HaHa",image_id:"79285c9f-2630-451e-0680-c71b42fb7400",hostname:"www.haha.me",mobile:{universal:"https://haha.me"}},cling_wallet:{id:"942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef",displayName:"Cling Wallet",image_id:"2d8006c3-852b-458a-d6b0-916c5ba76800",hostname:"clingon.io",mobile:{universal:"https://cling.carrieverse.com/apple-app-site-association"}},broearn:{id:"8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2",displayName:"Broearn",image_id:"339b9e9d-e2a7-46eb-4ed3-272321257a00",hostname:"www.broearn.com",mobile:{universal:"https://www.broearn.com/link/wallet/"}},copiosa:{id:"07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80",displayName:"Copiosa",image_id:"cae1be94-9f53-4eba-b915-f6e381d5a500",hostname:"copiosa.io",mobile:{universal:"https://copiosa.io/action/"}},burrito_wallet:{id:"8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819",displayName:"Burrito Wallet",image_id:"7eec7187-3f48-4fda-53bb-b0ad55749a00",hostname:"burritowallet.com",mobile:{universal:"https://burritowallet.com/wc?uri="}},enjin_wallet:{id:"bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a",displayName:"Enjin Wallet",image_id:"add9626b-a5fa-4c12-178c-e5584e6dcd00",hostname:"enjin.io",mobile:{universal:"https://deeplink.wallet.enjin.io/"}},plasma_wallet:{id:"cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e",displayName:"Plasma Wallet",image_id:"c268e78d-ffb0-4c8b-5cad-04c3add48500",hostname:"plasma-wallet.com",mobile:{universal:"https://plasma-wallet.com"}},avacus:{id:"94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43",displayName:"Avacus",image_id:"a7106965-91cc-4a73-4688-c5c72ae0ed00",hostname:"avacus.cc",mobile:{universal:"https://avacus.app.link"}},bee:{id:"2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715",displayName:"Bee",image_id:"f90bc33f-f085-40cf-7538-fae5ae84f900",hostname:"www.beewallet.app",mobile:{universal:"https://beewallet.app/wc"}},pitaka:{id:"14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc",displayName:"Pitaka",image_id:"691c0716-5213-4b99-e837-079268313800",hostname:"pitaka.io",mobile:{universal:"https://app.pitaka.io"}},pltwallet:{id:"576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd",displayName:"PLTwallet",image_id:"a5d9dd15-8cef-42de-8bed-09e01a8b0200",hostname:"pltwallet.io",mobile:{universal:"https://pltwallet.io/"}},minerva:{id:"49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd",displayName:"Minerva",image_id:"b57b2163-1bd8-4f6b-3311-470767e6d200",hostname:"minerva.digital",mobile:{universal:"https://minerva.digital"}},kryptogo:{id:"19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b",displayName:"KryptoGO",image_id:"3ccbd966-97e8-45a0-1ceb-6141a8978e00",hostname:"kryptogo.com",mobile:{universal:"https://kryptogo.page.link"}},prema:{id:"5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b",displayName:"PREMA",image_id:"6487869b-1165-4f30-aa3a-115665be8300",hostname:"premanft.com",mobile:{universal:"https://premanft.com"}},slingshot:{id:"d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b",displayName:"Slingshot",image_id:"10c75467-6612-48ad-b97b-63985e922200",hostname:"slingshot.finance",mobile:{universal:"https://app.slingshot.finance"}},kriptonio:{id:"50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b",displayName:"Kriptonio",image_id:"363fae03-882a-4d81-a721-6e6f6e9ac500",hostname:"kriptonio.com",mobile:{universal:"https://app.kriptonio.com/mobile"}},timeless:{id:"9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8",displayName:"Timeless",image_id:"32e89601-0490-42fc-0cc4-8627d62a2000",hostname:"timelesswallet.xyz",mobile:{universal:"https://timelesswallet.xyz"}},secux:{id:"6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa",displayName:"SecuX",image_id:"98183be0-3125-45ee-a6b6-fbd47ebefd00",hostname:"secuxtech.com",mobile:{universal:"https://wsweb.secuxtech.com"}},bitizen:{id:"41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071",displayName:"Bitizen",image_id:"75dd1471-77e9-4811-ce57-ec8fc980ec00",hostname:"bitizen.org",mobile:{universal:"https://bitizen.org/wallet"}},blocto:{id:"14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd",displayName:"Blocto",image_id:"374258d3-c749-4f37-7815-77e61f798c00",hostname:"blocto.io",mobile:{universal:"https://blocto.app"}},safemoon:{id:"a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1",displayName:"SafeMoon",image_id:"ea0140c7-787c-43a4-838f-d5ab6a342000",hostname:"safemoon.com",mobile:{universal:"https://safemoon.com/wc"}}},ll=(e,t="md")=>`https://registry.walletconnect.com/v2/logo/${t}/${e}`;function Qi(e){return{name:e.displayName||"",universalLink:e.mobile.universal||"",deepLink:e.mobile.native||""}}function Rp(e){let t="mobile";return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Qi(o))}function cl(){return Rp(sl)}function dl(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${e}`:""}function pl(e,t){return So.isAndroid?e:dl(e,Qi(t))}var ul="WALLETCONNECT_DEEPLINK_CHOICE";function al(e){let t=e.href.split("?")[0];Z.put(ul,{...e,href:t})}var Rr=(e,t)=>{if(!e||So.isDesktop){Z.del(ul);return}if(So.isAndroid){al({name:"Unknown",href:t||"wc:"});return}else if(So.isMobileOnly){let o=dl(t||"wc:",Qi(e));al({name:(e==null?void 0:e.displayName)||"",href:o})}};var Ir=class extends Le{constructor(o,r,n){super(n||"unknown");this.connectorType="wallet_connect_v2";this.walletConnectCloudProjectId=o,this.rpcConfig=r,this.proxyProvider=new oe,this.createProvider().then(i=>{var a,l;if(this.provider=i,this.proxyProvider.setWalletProvider(i),this.subscribeListeners(),i.session){if((a=this.walletProvider.session)!=null&&a.peer.metadata.url){let s=Sn((l=this.walletProvider.session)==null?void 0:l.peer.metadata.url);this.walletEntry=s==null?void 0:s.entry,this.walletClientType=(s==null?void 0:s.walletClientType)||"unknown",Rr(this.walletEntry)}this.connected=!0,this.syncAccounts().then(()=>{this.emit("initialized"),this.initialized=!0})}else this.emit("initialized"),this.initialized=!0})}async connect(o){return o.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return this.walletProvider.connected}get walletBranding(){var o,r,n;return this.walletEntry?{name:this.walletEntry.displayName,icon:this.walletClientType==="metamask"?_e:ll(this.walletEntry.image_id)}:{name:qi(((o=this.walletProvider.session)==null?void 0:o.peer.metadata.name)||"")||"WalletConnect",icon:((n=(r=this.walletProvider.session)==null?void 0:r.peer.metadata.icons)==null?void 0:n[0])||Yo}}resetConnection(){this.walletProvider&&this.walletProvider.connected&&(this.walletProvider.signer.session=void 0,this.walletEntry=void 0,Rr(void 0),this.onDisconnect())}async promptConnection(){if(!!this.provider)return new Promise((o,r)=>{let n=()=>{r(new jo)};this.onQrModalClosed=n,(async()=>{var s,d;let a="",l=await Promise.race([this.walletProvider.enable(),Ki()]);if(l.length>0&&(a=l[0]),!a||a==="")throw new $("Unable to retrieve address");if((s=this.walletProvider.session)!=null&&s.peer.metadata.url){let C=Sn((d=this.walletProvider.session)==null?void 0:d.peer.metadata.url);this.walletEntry=C==null?void 0:C.entry,this.walletClientType=(C==null?void 0:C.walletClientType)||"unknown"}this.connected=!0,await this.syncAccounts(l),o()})().catch(a=>{if(a){r(kt(a));return}r(new $("Unknown error during connection"))}).finally(()=>kn.default.close())})}disconnect(){this.walletProvider.disconnect().then(()=>this.onDisconnect()).catch(()=>console.warn("Unable to disconnect Wallet Connect provider"))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(o){this.proxyProvider.setWalletProvider(o)}async createProvider(){let o={};for(let n of no){let i=St(n.id,this.rpcConfig);i&&(o[n.id]=i)}let r=await Jo.EthereumProvider.init({projectId:this.walletConnectCloudProjectId,chains:[1],optionalChains:no.map(n=>n.id),optionalEvents:Jo.OPTIONAL_EVENTS,optionalMethods:Jo.OPTIONAL_METHODS,rpcMap:o,showQrModal:!1});return r.on("display_uri",n=>{if(Rn.isAndroid)window.open(n,"_self");else if(Rn.isMobile&&this.walletEntry){Rr(this.walletEntry,n);let a=pl(n,this.walletEntry);window.open(a,"_self","noopener,noreferrer")}else kn.default.open(n,()=>{this.onQrModalClosed&&this.onQrModalClosed()},{mobileLinks:cl().map(i=>i.name)})}),r.on("connect",()=>{var n,i;if(kn.default.close(),(n=r.session)!=null&&n.peer.metadata.url){let a=Sn((i=r.session)==null?void 0:i.peer.metadata.url);this.walletEntry=a==null?void 0:a.entry,this.walletClientType=(a==null?void 0:a.walletClientType)||"unknown",Rr(this.walletEntry)}}),r}async enableProvider(){return this.walletProvider.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider.enable()}};var Xi=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses");return t?!!(e==null?void 0:e.linkedAccounts.filter(r=>r.type=="wallet"&&r.address===(0,Zi.getAddress)(t)).length):!1},Qo=class extends ml.default{constructor(o,r){super();this.getEthereumProvider=()=>{let o=this.wallets[0],r=this.walletConnectors.find(n=>n.wallets.find(i=>i.address===(o==null?void 0:o.address)));return!o||!r?new oe:r.proxyProvider};this.walletConnectCloudProjectId=o,this.rpcConfig=r,this.walletConnectors=[],this.initialized=!1,this.storedConnections=this.loadConnectionHistory()}get wallets(){let o=new Set,r=this.walletConnectors.flatMap(i=>i.wallets).sort((i,a)=>i.connectedAt&&a.connectedAt?a.connectedAt-i.connectedAt:0).filter(i=>{let a=`${i.address}${i.walletClientType}${i.connectorType}`;return o.has(a)?!1:(o.add(a),!0)}),n=r.findIndex(i=>i.address===(this.activeWallet?this.activeWallet:"unknown"));return n>=0&&r.unshift(r.splice(n,1)[0]),r}initialize(){this.initialized||(Z.get(Bi)&&(Z.getKeys().forEach(o=>{o.startsWith("walletconnect")&&Z.del(o)}),Z.del(Bi)),qs().then(o=>o.forEach(r=>{switch(r){case"metamask":this.createWalletConnector("injected","metamask");break;case"phantom":this.createWalletConnector("injected","phantom");break;case"unknown":default:break}})),(io()||Z.getKeys().find(o=>o.startsWith("-walletlink")))&&this.createWalletConnector("coinbase_wallet","coinbase_wallet"),this.createWalletConnector("wallet_connect_v2","unknown"),this.initialized=!0)}findWalletConnector(o,r){return o==="wallet_connect_v2"?this.walletConnectors.find(n=>n.connectorType===o)||null:this.walletConnectors.find(n=>n.connectorType===o&&n.walletClientType===r)||null}onInitialized(o){o.wallets.forEach(r=>{let n=this.storedConnections.find(i=>i.address===r.address&&i.connectorType===r.connectorType&&i.walletClientType===r.walletClientType);n&&(r.connectedAt=n.connectedAt)}),this.saveConnectionHistory(),this.emit("walletsUpdated")}onWalletsUpdated(o){o.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnector(o,r){if(!this.findWalletConnector("embedded","privy")){let i=new wn(o,r,this.rpcConfig),a=new Tn(i);this.addWalletConnector(a)}}removeEmbeddedWalletConnector(){let o=this.findWalletConnector("embedded","privy");if(o){let r=this.walletConnectors.indexOf(o);this.walletConnectors.splice(r,1),this.saveConnectionHistory(),this.emit("walletsUpdated")}}async createWalletConnector(o,r){let n=this.findWalletConnector(o,r);if(n)return n instanceof Ir&&n.resetConnection(),n;let a=(()=>{switch(o){case"injected":switch(r){case"phantom":return nt()?new _n:null;case"metamask":default:return Pr()?new Pn:null}case"coinbase_wallet":return new xn;case"wallet_connect_v2":return new Ir(this.walletConnectCloudProjectId,this.rpcConfig)}})();return a&&this.addWalletConnector(a),a||null}addWalletConnector(o){this.walletConnectors.push(o),o.on("initialized",()=>this.onInitialized(o)),o.on("walletsUpdated",()=>this.onWalletsUpdated(o))}loadConnectionHistory(){let o=a=>a&&typeof a.address=="string"&&typeof a.connectorType=="string"&&typeof a.walletClientType=="string"&&typeof a.connectedAt=="number",r=Z.get(Gi);return r&&Array.isArray(r)&&r.map(a=>o(a)).every(Boolean)?r:[]}saveConnectionHistory(){let o=this.wallets.map(r=>({address:r.address,connectorType:r.connectorType,walletClientType:r.walletClientType,connectedAt:r.connectedAt}));Z.put(Gi,o)}async activeWalletSign(o){let r=this.wallets,n=r.length>0?r[0]:null;return n?n.sign(o):null}setActiveWallet(o){this.activeWallet=(0,Zi.getAddress)(o),this.emit("walletsUpdated")}};function Cn(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++){let r=e[o],n=t[o];if((r==null?void 0:r.address)!==(n==null?void 0:n.address)||(r==null?void 0:r.chainId)!==(n==null?void 0:n.chainId)||(r==null?void 0:r.connectorType)!==(n==null?void 0:n.connectorType)||(r==null?void 0:r.connectedAt)!==(n==null?void 0:n.connectedAt)||(r==null?void 0:r.walletClientType)!==(n==null?void 0:n.walletClientType)||(r==null?void 0:r.isConnected)!==(n==null?void 0:n.isConnected)||(r==null?void 0:r.linked)!==(n==null?void 0:n.linked))return!1}return!0}var hl=require("ofetch");var Ip=[cn(),dn()],Wp=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},In=class{constructor(t,o,r){this.appId=t,this.sdkVersion=mn,this.client=o,this.defaults=r,this.fallbackApiUrl=o.fallbackApiUrl,this.baseFetch=hl.ofetch.create({baseURL:this.defaults.baseURL,retry:3,retryDelay:500,credentials:"include",onRequest:async({request:n,options:i})=>{let a=new Headers(i.headers);a.set("privy-app-id",this.appId),a.set("privy-client",`react-auth:${this.sdkVersion}`);let l=!Ip.includes(n.toString());if(!a.has("authorization")&&l){let s=await this.client.getAccessToken();s!==null&&a.set("authorization",`Bearer ${s}`)}i.headers=a,i.signal||(i.signal=Wp(this.defaults.timeout))},onRequestError:({error:n})=>{if(n instanceof DOMException&&n.name==="AbortError")throw new ln}})}async get(t,o){try{return await this.baseFetch(t,o)}catch(r){throw ae(r)}}async post(t,o,r){try{return await this.baseFetch(t,{method:"POST",...o?{body:o}:{},...r})}catch(n){throw ae(n)}}async delete(t,o){try{return await this.baseFetch(t,{method:"DELETE",...o})}catch(r){throw ae(r)}}};var Wr=_(require("js-cookie"));function fl(e){return e instanceof Po?"email":e instanceof Ao?"sms":e instanceof _o?"siwe":e instanceof zo?"custom_auth":e instanceof to?e.meta.provider:null}var yl=_(require("jose")),It=class{static parse(t){try{return new It(t)}catch{return null}}constructor(t){this.value=t,this._decoded=yl.decodeJwt(t)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(t=0){let o=Date.now(),r=(this.expiration-t)*1e3;return o>=r}};var Np=30,Wn=class{constructor(){this.authenticateOnce=new rt(async t=>this._authenticate(t)),this.linkOnce=new rt(async t=>this._link(t)),this.refreshOnce=new rt(this._refresh.bind(this)),this.destroyOnce=new rt(this._destroy.bind(this)),this.forkSessionOnce=new rt(this._forkSession.bind(this))}get token(){try{let t=Z.get(Vo);return typeof t=="string"?new It(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=Z.get(hn);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=Z.get(Tr);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}hasRefreshCredentials(){var t;return((t=this.client)==null?void 0:t.useServerCookies)||typeof this.token=="string"&&typeof this.refreshToken=="string"}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=It.parse(this.token);return t!==null&&!t.isExpired(Np)}authenticate(t){return this.authenticateOnce.execute(t)}link(t){return this.linkOnce.execute(t)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(t){try{let{token:o,refresh_token:r,user:n,is_new_user:i}=await t.authenticate();this.storeToken(o),this.storeRefreshToken(r);let a=fl(t);return a&&this.client&&this.client.createAnalyticsEvent("sdk_authenticate",{method:a,isNewUser:i}),a==="siwe"&&this.client&&this.client.createAnalyticsEvent("sdk_authenticate_siwe",{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}),{user:Ft(n),isNewUser:i}}catch(o){throw console.warn("Error authenticating session"),ot(o)}}async _link(t){try{let o=await t.link();return Ft(o)}catch(o){throw console.warn("Error linking account"),ot(o)}}async _refresh(){if(!this.api)throw new T("Session has no API instance");if(!this.client)throw new T("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,o=this.refreshToken,r=this.forkedToken;try{let n;if(t&&o)n=await this.api.post(cn(),{refresh_token:o},{headers:{authorization:`Bearer ${t}`}}),r&&this.clearForkedToken();else if(r)n=await this.api.post(dn(),{refresh_token:r}),this.clearForkedToken();else return null;return this.storeToken(n.token),this.storeRefreshToken(n.refresh_token),Ft(n.user)}catch(n){if(n instanceof Go&&n.status===400&&n.message==="Invalid auth token")return this.destroyLocalState(),null;throw ot(n)}}async _destroy(){var t;try{await((t=this.api)==null?void 0:t.post(Ja(),{refresh_token:this.refreshToken}))}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new T("Session has no API instance");let t=this.refreshToken;try{let o=await this.api.post(Qa(),{refresh_token:t});return this.storeToken(o.token),this.storeRefreshToken(o.refresh_token),o.new_session_refresh_token}catch(o){throw ot(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),this.clearForkedToken()}storeToken(t){var o,r;if(typeof t=="string"){if(Z.put(Vo,t),!((o=this.client)!=null&&o.useServerCookies)){let n=(r=It.parse(t))==null?void 0:r.expiration;Wr.default.set(Di,t,{sameSite:"Strict",secure:!0,expires:n?new Date(n*1e3):void 0})}}else Z.del(Vo),Wr.default.remove(Di)}storeRefreshToken(t){var o;typeof t=="string"?(Z.put(hn,t),(o=this.client)!=null&&o.useServerCookies||Wr.default.set(Ui,t,{sameSite:"Strict",secure:!0,expires:30})):(Z.del(hn),Wr.default.remove(Ui))}clearForkedToken(){Z.del(Tr)}};var ea,Zo=class{constructor(t){this.apiUrl=t.apiUrl||un,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!1,this.timeout=t.timeout||ws,this.appId=t.appId,this.clientAnalyticsId=typeof window>"u"?null:(0,gl.v4)(),ea||(ea=new Wn),this.session=ea,this.api=this.generateApi(),this.session.client=this}initializeConnectorManager(t,o){this.connectors||(this.connectors=new Qo(t,o))}generateApi(){let t=new In(this.appId,this,{baseURL:this.apiUrl,timeout:this.timeout});return this.session.api=t,t}updateApiUrl(t){this.apiUrl=t||this.fallbackApiUrl,this.api=this.generateApi(),t&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new T("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new T("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.authFlow=void 0}startAuthFlow(t){t.api=this.api,this.authFlow=t}async unlinkEmail(t){try{let o=await this.api.post(ps(),{address:t});return Ft(o)}catch(o){throw ot(o)}}async unlinkPhone(t){try{let o=await this.api.post(us(),{phoneNumber:t});return Ft(o)}catch(o){throw ot(o)}}async unlinkWallet(t){try{let o=await this.api.post(ds(),{address:t});return Ft(o)}catch(o){throw ot(o)}}async unlinkOAuth(t,o){try{let r=await this.api.post(ms(),{provider:t,subject:o});return Ft(r)}catch(r){throw ot(r)}}async createAnalyticsEvent(t,o,r){if(!(typeof window>"u"))try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(hs(),{event_name:t,client_id:this.clientAnalyticsId,payload:{...o||{},clientTimestamp:r?r.toISOString():new Date().toISOString()}})}catch{}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){var o;return this.session.hasActiveToken()?((o=It.parse(this.session.token))==null?void 0:o.audience)!==this.appId?(await this.logout(),null):this.session.token:!(t!=null&&t.disableAutoRefresh)&&this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getServerConfig(){var t,o;try{let r=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl});return{id:r.id,name:r.name,verificationKey:r.verification_key,logoUrl:r.logo_url||void 0,accentColor:r.accent_color||void 0,showWalletLoginFirst:r.show_wallet_login_first,allowlistConfig:{errorTitle:r.allowlist_config.error_title,errorDetail:r.allowlist_config.error_detail,errorCtaText:r.allowlist_config.cta_text,errorCtaLink:r.allowlist_config.cta_link},walletAuth:r.wallet_auth,emailAuth:r.email_auth,smsAuth:r.sms_auth,googleOAuth:r.google_oauth,twitterOAuth:r.twitter_oauth,discordOAuth:r.discord_oauth,githubOAuth:r.github_oauth,appleOAuth:r.apple_oauth,termsAndConditionsUrl:r.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:(t=r.embedded_wallet_config)==null?void 0:t.create_on_login,requireUserPasswordOnCreate:(o=r.embedded_wallet_config)==null?void 0:o.require_user_password_on_create},privacyPolicyUrl:r.privacy_policy_url,customApiUrl:r.custom_api_url,walletConnectCloudProjectId:r.wallet_connect_cloud_project_id,captchaEnabled:r.captcha_enabled,createdAt:new Date(r.created_at*1e3),updatedAt:new Date(r.updated_at*1e3)}}catch(r){throw ot(r)}}async getUsdTokenPrice(t){try{return(await this.api.get(`/api/v1/token_price?chainId=${t}`)).usd}catch{console.warn(`Unable to fetch token price for chain with id ${t}`);return}}async forkSession(){return await this.session.forkSession()}};var XC=require("wicg-inert"),Pi=require("body-scroll-lock"),_i=require("react"),Ua=require("react"),Ld=_(require("react-dom")),Ai=_(require("styled-components"));var Nn=require("react");var ta=(0,Nn.createContext)({isNewUserThisSession:!1,isLinking:!1,linkingHint:null,walletConnectionStatus:null,rpcConfig:{rpcUrls:{}},captchaData:{enabled:!1,ready:!1,execute:P,remove:P,token:void 0,error:void 0},initializeWalletProxy:P,getAuthMeta:P,getAuthFlow:P,closePrivyModal:P,connectWallet:P,initLoginWithWallet:P,loginWithWallet:P,loginWithCode:P,initLoginWithEmail:P,initLoginWithSms:P,resendEmailCode:P,resendSmsCode:P,initLoginWithOAuth:P,loginWithOAuth:P,refreshUser:P,walletProxy:null,createAnalyticsEvent:P,getUsdTokenPrice:P,recoverEmbeddedWallet:P}),N=()=>(0,Nn.useContext)(ta);var Ln=require("react");var $t=(0,Ln.createContext)({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:P,login:P,linkEmail:P,linkPhone:P,linkWallet:P,linkGoogle:P,linkTwitter:P,linkDiscord:P,linkGithub:P,linkApple:P,logout:P,getAccessToken:P,getEthereumProvider:P,getEthersProvider:P,getWeb3jsProvider:P,unlinkEmail:P,unlinkPhone:P,unlinkWallet:P,unlinkGoogle:P,unlinkTwitter:P,unlinkDiscord:P,unlinkGithub:P,unlinkApple:P,setActiveWallet:P,forkSession:P,createWallet:P,signMessage:P,sendTransaction:P,exportWallet:P}),Y=()=>(0,Ln.useContext)($t);var Hn=_(require("styled-components"));var Wt=_(require("styled-components"));var Mn=_(require("styled-components")),co=require("react/jsx-runtime"),On=({success:e,fail:t})=>(0,co.jsxs)(co.Fragment,{children:[(0,co.jsx)(Nr,{className:e?"success":t?"fail":""}),(0,co.jsx)(Lp,{className:e?"success":t?"fail":""})]}),Nr=Mn.default.span`
|
|
13
13
|
&& {
|
|
14
14
|
width: 82px;
|
|
15
15
|
height: 82px;
|
|
@@ -2116,4 +2116,4 @@ Resources:
|
|
|
2116
2116
|
align-items: center;
|
|
2117
2117
|
justify-content: center;
|
|
2118
2118
|
height: 100%;
|
|
2119
|
-
`;var Od=require("react"),Si=require("react/jsx-runtime"),yh=({onLoad:e})=>{let t=window;return(0,Od.useEffect)(()=>{if(document.getElementById("cf-script")!==null||t.turnstile)return;t.onloadTurnstileCallback=e;let o=document.createElement("script");o.setAttribute("src","https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback&render=explicit"),o.setAttribute("id","cf-script"),o.setAttribute("async","true"),document.body.appendChild(o)},[]),(0,Si.jsx)(Si.Fragment,{})},Dd=yh;var Oo=_(require("tinycolor2")),Ud="#FFFFFF",gh="#000000",vh=Ud,bh="#1E1E1D";function wh(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function Eo(e,t){let o=Math.max(0,Math.min(1,e.toHsl().l+t));return(0,Oo.default)({...e.toHsl(),l:o})}function Fd({backgroundTheme:e,accentHex:t,successHex:o="#51BA81",errorHex:r="#EC6351",whiteHex:n=Ud,blackHex:i=gh}){let a;switch(e){case"light":a=vh;break;case"dark":a=bh;break;default:a=e;break}let l=(0,Oo.default)(a),s=(0,Oo.default)(t),d=(0,Oo.default)(o),C=(0,Oo.default)(r),g=wh(l.getLuminance()),v=Eo(l,g==="light"?-.04:.11),p=Eo(l,g==="light"?-.88:.87),w=Eo(l,g==="light"?-.77:.75),f=Eo(l,g==="light"?-.43:.45).desaturate(g==="light"?60:20),E=Eo(l,g==="light"?-.08:.25).desaturate(g==="light"?60:20),R=Eo(s,.15),b=Eo(s,-.06),M=(0,Oo.default)(s.getLuminance()>.5?i:n),S=Eo(d,-.16);return{colorScheme:g,background:l.toHslString(),background2:v.toHslString(),foreground:p.toHslString(),foreground2:w.toHslString(),foreground3:f.toHslString(),foreground4:E.toHslString(),accent:s.toHslString(),accentLight:R.toHslString(),accentDark:b.toHslString(),foregroundAccent:M.toHslString(),success:d.toHslString(),successDark:S.toHslString(),error:C.toHslString()}}var Do={appearance:{theme:"light",accentColor:"#676FFF"},walletConnectCloudProjectId:vs,rpcConfig:{rpcUrls:{}},captchaEnabled:!1,_render:{inDialog:!0,inParentNodeId:null}};function ki(e,t){var v,p,w,f,E,R,b,M,S,B;let o,r,n,i,a,l,s,d;if(t!=null&&t.loginMethods?(o=t.loginMethods.includes("email"),r=t.loginMethods.includes("sms"),n=t.loginMethods.includes("wallet"),i=t.loginMethods.includes("google"),a=t.loginMethods.includes("twitter"),l=t.loginMethods.includes("discord"),s=t.loginMethods.includes("github"),d=t.loginMethods.includes("apple")):(o=e.emailAuth,r=e.smsAuth,n=e.walletAuth,i=e.googleOAuth,a=e.twitterOAuth,l=e.discordOAuth,s=e.githubOAuth,d=e.appleOAuth),o&&r&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),r=!1),!o&&!r&&[i,a,l,s,d].some(L=>L))throw new Error("To enable social logins you must also enable either SMS or Email login");if(![o,r,n,i,a,l,s,d].some(L=>L))throw new Error("You must enable at least one login method");let C=((v=t==null?void 0:t.customAuth)==null?void 0:v.getCustomAccessToken)&&((p=t==null?void 0:t.customAuth)==null?void 0:p.enabled)!==!1;return{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,appearance:{logo:((w=t==null?void 0:t.appearance)==null?void 0:w.logo)??e.logoUrl,palette:Fd({backgroundTheme:((f=t==null?void 0:t.appearance)==null?void 0:f.theme)??Do.appearance.theme,accentHex:((E=t==null?void 0:t.appearance)==null?void 0:E.accentColor)??e.accentColor??Do.appearance.accentColor}),showWalletLoginFirst:((R=t==null?void 0:t.appearance)==null?void 0:R.showWalletLoginFirst)??e.showWalletLoginFirst},loginMethods:{wallet:n,email:o,sms:r,google:i,twitter:a,discord:l,github:s,apple:d},legal:{termsAndConditionsUrl:((b=t==null?void 0:t.legal)==null?void 0:b.termsAndConditionsUrl)??e.termsAndConditionsUrl,privacyPolicyUrl:((M=t==null?void 0:t.legal)==null?void 0:M.privacyPolicyUrl)??e.privacyPolicyUrl},walletConnectCloudProjectId:(t==null?void 0:t.walletConnectCloudProjectId)??e.walletConnectCloudProjectId??Do.walletConnectCloudProjectId,rpcConfig:(t==null?void 0:t.rpcConfig)??Do.rpcConfig,captchaEnabled:e.captchaEnabled??Do.captchaEnabled,embeddedWallets:{...e.embeddedWalletConfig,...C?{createOnLogin:"all-users",requireUserPasswordOnCreate:!1,noPromptOnSignature:!0}:{},...t==null?void 0:t.embeddedWallets},customAuth:C?{enabled:!0,...t.customAuth}:void 0,render:{inDialog:((S=t==null?void 0:t._render)==null?void 0:S.inDialog)??Do._render.inDialog,inParentNodeId:((B=t==null?void 0:t._render)==null?void 0:B.inParentNodeId)??Do._render.inParentNodeId}}}function Bd(e,t){var o;return((o=e==null?void 0:e.appearance)==null?void 0:o.logo)&&typeof e.appearance.logo=="object"&&(e.appearance.logo="component"),{...e,legacyCreateEmbeddedWalletFlag:t}}var Ii=require("react");var Ri=class{constructor(){this.callbacks={}}enqueue(t,o){this.callbacks[t]=o}dequeue(t,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${t} event: no event found for id ${o}`);switch(delete this.callbacks[o],t){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:connect":return r;case"privy:wallet:recover":return r;case"privy:wallet:rpc":return r;default:throw new Error(`invalid wallet event type ${t}`)}}};var Hd=require("react/jsx-runtime"),Ch=function(e){return()=>`id-${e++}`}(0);function Eh(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Jr(e){return e.error!==void 0}var br=new Ri,Fa=new Map,xh=(e,t)=>typeof t=="bigint"?t.toString():t,Th=(e,t)=>`${e}${JSON.stringify(t,xh)}`;function Qr(e,t,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");let n=Th(e,t);if(e==="privy:wallet:create"){let a=Fa.get(n);if(a)return a}let i=new Promise((a,l)=>{let s=Ch();br.enqueue(s,{resolve:a,reject:l}),r.postMessage({id:s,event:e,data:t},"*")}).finally(()=>{Fa.delete(n)});return Fa.set(n,i),i}function Ph(e){switch(e.event){case"privy:iframe:ready":let t=br.dequeue(e.event,e.id);return Jr(e)?t.reject(new fo(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let o=br.dequeue(e.event,e.id);return Jr(e)?o.reject(new fo(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let r=br.dequeue(e.event,e.id);return Jr(e)?r.reject(new fo(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:recover":let n=br.dequeue(e.event,e.id);return Jr(e)?n.reject(new fo(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:rpc":let i=br.dequeue(e.event,e.id);return Jr(e)?i.reject(new fo(e.error.type,e.error.message)):i.resolve(e.data)}}function Gd(e){let t=(0,Ii.useRef)(null);return(0,Ii.useEffect)(()=>{let o=t.current;if(!o)return;function r(s){s&&s.origin===e.origin&&Eh(s.data)&&Ph(s.data)}let n={create(s){return Qr("privy:wallet:create",s,o)},connect(s){return Qr("privy:wallet:connect",s,o)},recover(s){return Qr("privy:wallet:recover",s,o)},rpc(s){return Qr("privy:wallet:rpc",s,o)}};window.addEventListener("message",r);let i=()=>e.onLoad(n),a=(...s)=>{console.warn("Privy iframe failed to load: ",...s),e.onLoadFailed()},l=new AbortController;return $s(()=>Qr("privy:iframe:ready",{},o),{abortSignal:l.signal}).then(i,a),()=>{window.removeEventListener("message",r),l.abort()}},[t.current]),(0,Hd.jsx)("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},src:vn(e.origin,`/apps/${e.appId}/embedded-wallets`)})}var wr=require("react"),zd={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]}},Ba=(0,wr.createContext)(void 0),_h=()=>(0,wr.useContext)(Ba);function Cr(e,t){if(!t)return;let r=_h().current[e];return(0,wr.useEffect)(()=>{var n;for(let[i,a]of Object.entries(t))r.hasOwnProperty(i)||console.warn(`Invalid event type "${i}" for action "${e}"`),(n=r[i])==null||n.push(a);return()=>{var i;for(let[a,l]of Object.entries(t))r.hasOwnProperty(a)||console.warn(`Invalid event type "${a}" for action "${e}"`),r[a]=(i=r[a])==null?void 0:i.filter(s=>s!==l)}},[t])}function ut(e,t,o,...r){for(let n of e.current[t][o])n(...r)}var Wi=require("react"),Ga=(0,Wi.createContext)({wallets:[]});function Vd(){return(0,Wi.useContext)(Ga)}var mt=require("react/jsx-runtime");function Ah(e){return typeof e=="string"&&e.length===25}var Xr;function Rt(){if(!Xr){let e=Z.get(Vo);return Promise.resolve(e||null)}return Xr.getAccessToken()}var $d,Js=(e,t)=>$d(e,t),qd,Qs=(e,t)=>qd(e,t),jd,Zs=()=>jd(),Sh=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;Z.put(Tr,t);let o=new URL(window.location.href);o.searchParams.delete("privy_token"),window.history.pushState({},"",o)},Kd=({config:e,...t})=>{var r,n;if(!Ah(t.appId))throw new T("Cannot initialize the Privy provider with an invalid Privy app ID");Xr||(Xr=new Zo({appId:t.appId,apiUrl:t.apiUrl||un}));let o=Object.assign({},e);return t.createPrivyWalletOnLogin!==void 0&&((r=o.embeddedWallets)==null?void 0:r.createOnLogin)===void 0&&(o.embeddedWallets||(o.embeddedWallets={}),o.embeddedWallets.createOnLogin=t.createPrivyWalletOnLogin?"users-without-wallets":"off"),t.createPrivyWalletOnLogin!==void 0&&((n=e==null?void 0:e.embeddedWallets)==null?void 0:n.createOnLogin)&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),(0,mt.jsx)(kh,{...t,config:o,client:Xr})},kh=e=>{var $a,qa,ja;let t=e.client,[o,r]=(0,F.useState)(!1),[n,i]=(0,F.useState)(!1),[a,l]=(0,F.useState)(!1),[s,d]=(0,F.useState)(null),[C,g]=(0,F.useState)(!1),[v,p]=(0,F.useState)([]),w=(0,F.useRef)(v),[f,E]=(0,F.useState)(!1),[R,b]=(0,F.useState)(null),[M,S]=(0,F.useState)(!1),[B,L]=(0,F.useState)({status:"disconnected",connectError:null,connector:null,connectRetry:P}),[j,le]=(0,F.useState)(null),[O,he]=(0,F.useState)(null),[Ee,H]=(0,F.useState)({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,appleOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserPasswordOnCreate:!1},captchaEnabled:!1}),[I,U]=(0,F.useState)(()=>{let c=Bd(e.config,e.createPrivyWalletOnLogin);return t.createAnalyticsEvent("sdk_initialize",c),ki(Ee,e.config)}),[Q,ne]=(0,F.useState)(!0),[xt,Ze]=(0,F.useState)({}),[Tt,xe]=(0,F.useState)(null),[Pt,Er]=(0,F.useState)(null),[en,tn]=(0,F.useState)(!1),[on,Uo]=(0,F.useState)(),[rn,te]=(0,F.useState)(),[_t,xo]=(0,F.useState)(),[Fo,nn]=(0,F.useState)(!1),Xe=(0,F.useRef)(zd),et=c=>{c&&b(c),r(!0),t.createAnalyticsEvent("modal_open",{initialScreen:c})},an=c=>{I.embeddedWallets.createOnLogin!=="off"&&ne(!0),et(c)};(0,F.useEffect)(()=>{var u,m;if(!O||!s){(u=t.connectors)==null||u.removeEmbeddedWalletConnector();return}let c=s==null?void 0:s.linkedAccounts.filter(h=>h.type==="wallet"&&h.walletClient==="privy");if(c&&c.length>0){let h=c[0].address;(m=t.connectors)==null||m.addEmbeddedWalletConnector(O,h)}},[O,s]),(0,F.useEffect)(()=>{!O||Pt==null||Pt(O)},[O]),(0,F.useEffect)(()=>{(async()=>{var h;if(!((h=I.customAuth)!=null&&h.enabled))return;ne(!0);let{getCustomAccessToken:u,isLoading:m}=I.customAuth;if(!(!n||m))try{let W=await u();if(!W){await Bo.logout();return}if(a)return;t.startAuthFlow(new zo(W));let{user:Te,isNewUser:Re}=await t.authenticate();Te||await Bo.logout(),d(Te||null),E(Re||!1),l(!0),nn(!0)}catch(W){console.warn(W),a&&await Bo.logout()}})()},[($a=I.customAuth)==null?void 0:$a.enabled,(qa=I.customAuth)==null?void 0:qa.getCustomAccessToken,(ja=I.customAuth)==null?void 0:ja.isLoading,n,a]),(0,F.useEffect)(()=>{var c,u;Fo&&O&&s&&ro(s,(u=(c=e.config)==null?void 0:c.embeddedWallets)==null?void 0:u.createOnLogin)&&(nn(!1),Va(s,3e4).catch(console.error))},[Fo&&O&&s]),(0,F.useEffect)(()=>{async function c(){var Te,Re,tt;let u=await t.getServerConfig();H(u);let m=ki(u,e.config);U(m),u.customApiUrl&&t.updateApiUrl(u.customApiUrl),t.initializeConnectorManager(m.walletConnectCloudProjectId,m.rpcConfig),(Te=t.connectors)==null||Te.initialize();let h=tp();Sh();let W=await t.getAuthenticatedUser();(tt=(Re=e.config)==null?void 0:Re.customAuth)!=null&&tt.enabled||(l(!!W),W&&ut(Xe,"login","onComplete",W,!1,!0),d(W)),i(!0),Tt==null||Tt(),h&&W&&g(!0),op()}n||c()},[t,Tt,n]),(0,F.useEffect)(()=>{let c=ki(Ee,e.config);U(c)},[e.config]);let tp=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_oauth_code"),m=c.get("privy_oauth_state"),h=c.get("privy_oauth_provider");return u&&m&&h?(t.startAuthFlow(new to(h,u,m)),an("AWAITING_OAUTH_SCREEN"),!0):!1},Li=async(c,u,m)=>{var W;let h=await((W=t.connectors)==null?void 0:W.createWalletConnector(c,u))||null;Ha(h,m)};async function Ha(c,u){if(!c)return L({status:"disconnected",connectError:new $("Unable to connect to wallet."),connector:null,connectRetry:P}),u==null?void 0:u(null);L({connector:c,status:"connecting",connectError:null,connectRetry:()=>Ha(c,u)});try{let m=await c.connect({showPrompt:!0});return L(h=>({...h,status:"connected",connectError:null,connectRetry:P})),m&&!M&&ut(Xe,"connectWallet","onSuccess",m),u==null?void 0:u(m)}catch(m){return m instanceof ft?(console.warn(m.cause?m.cause:m.message),M||ut(Xe,"connectWallet","onError",m.privyErrorCode||"generic_connect_wallet_error")):(console.warn(m),M||ut(Xe,"connectWallet","onError","unknown_connect_wallet_error")),L(h=>({...h,status:"disconnected",connectError:m})),u==null?void 0:u(null)}}let Mi=c=>{c!==null&&t.startAuthFlow(new _o(c))},op=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_connector"),m=c.get("privy_wallet_client");if(!u||!m)return;if(m==="phantom"&&!nt()&&an("LOGIN_FAILED_SCREEN"),!t.connectors)throw new T("Connector not initialized");et("AWAITING_CONNECTION");let h=new URL(window.location.href);h.searchParams.delete("privy_connector"),h.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",h),Li(u,m,Mi)};(0,F.useEffect)(()=>{n&&a&&s===null&&t.getAuthenticatedUser().then(d)},[n,a,s,t]);let za=()=>{g(!0),et("LINK_WALLET_SCREEN")},rp=c=>{if(!a||!s)return!1;for(let u of s.linkedAccounts)if(u.type==="wallet"&&u.address===c.address)return!0;return!1},np=async c=>{if(!t.connectors)throw new T("Connector not initialized");let u=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null;L(m=>({...m,connector:u,status:"connected",connectError:null,connectRetry:P})),Mi(c),an("AWAITING_CONNECTION")},ip=async(c,u)=>{if(!t.connectors)throw new T("Connector not initialized");await Li(c,u,Mi)},Oi=()=>{p(c=>{var m;let u=((m=t.connectors)==null?void 0:m.wallets.map(h=>({...h,linked:rp(h),loginOrLink:async()=>{if(!await h.isConnected())throw new T("Wallet is not connected");if(h.connectorType==="embedded"&&h.walletClientType==="privy")throw new T("Cannot link or login with embedded wallet");np(h)},unlink:async()=>{if(!a)throw new T("User is not authenticated.");if(h.connectorType==="embedded"&&h.walletClientType==="privy")throw new T("Cannot unlink an embedded wallet");let W=await t.unlinkWallet(h.address);d(W)}})))||[];return Cn(c,u)?c:u})};(0,F.useEffect)(()=>{Oi()},[s==null?void 0:s.linkedAccounts,a]),(0,F.useEffect)(()=>{if(n){if(!t.connectors)throw new T("Connector not initialized");Oi(),t.connectors.on("walletsUpdated",Oi)}},[n]);let ap=()=>{et(a?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};(0,F.useEffect)(()=>{if(!v[0])return;let c=v[0],u=w.current.find(h=>h.address===c.address),m=s==null?void 0:s.linkedAccounts.find(h=>h.type==="wallet"&&h.address===c.address);if(!u&&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)}w.current=v},[v]);let Va=async(c,u)=>{var Te,Re,tt,To;if(ce(c))throw new Error("Only one Privy wallet per user is currently allowed");let[h,W]=await Promise.all([ht.initializeWalletProxy(u),Rt()]);if(!h&&((Re=(Te=e.config)==null?void 0:Te.customAuth)==null?void 0:Re.enabled))throw new Error("Failed to connect to wallet proxy");if(!h||!W||((To=(tt=e.config)==null?void 0:tt.embeddedWallets)==null?void 0:To.requireUserPasswordOnCreate))return new Promise((Xt,Ut)=>{ne(!0),Ze({createWallet:{onSuccess:Xt,onFailure:Ut,callAuthOnSuccessOnClose:!1}}),et("EMBEDDED_WALLET_SCREEN")});{await h.create({accessToken:W});let Xt=await ht.refreshUser(),Ut=ce(Xt);if(!Ut)throw new Error("Failed to create wallet");return Ut}},Bo={ready:n,authenticated:a,user:s,walletConnectors:t.connectors||null,connectWallet:ap,linkWallet:za,linkEmail:()=>{if(s!=null&&s.email)throw new T("User already has an email linked to their account.");g(!0),et("LINK_EMAIL_SCREEN")},linkPhone:()=>{if(s!=null&&s.phone)throw new T("User already has a phone number linked to their account.");g(!0),et("LINK_PHONE_SCREEN")},linkGoogle:async()=>{if(s!=null&&s.google)throw new T("User already has a Google account linked to their account.");await ht.initLoginWithOAuth("google")},linkTwitter:async()=>{if(s!=null&&s.twitter)throw new T("User already has a Twitter account linked to their account.");await ht.initLoginWithOAuth("twitter")},linkDiscord:async()=>{if(s!=null&&s.discord)throw new T("User already has a Discord account linked to their account.");await ht.initLoginWithOAuth("discord")},linkGithub:async()=>{if(s!=null&&s.github)throw new T("User already has a Github account linked to their account.");await ht.initLoginWithOAuth("github")},linkApple:async()=>{await ht.initLoginWithOAuth("apple")},login:async()=>{if(n||(await new Promise(c=>{xe(()=>c)}),xe(null)),a){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}S(!0),an()},logout:async()=>{await t.logout(),d(null),l(!1),b(null),ut(Xe,"logout","onSuccess"),g(!1),r(!1)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{var m;if(!s||!s.wallet)return new oe;let c=v.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(W=>W.address===(c==null?void 0:c.address)));return!c||!u?new oe:u.proxyProvider},getEthersProvider:()=>{var m;if(!s||!s.wallet)return new Ni.Web3Provider(new vt(new oe));let c=v.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(W=>W.address===(c==null?void 0:c.address)));return!c||!u?new Ni.Web3Provider(new vt(new oe)):new Ni.Web3Provider(new vt(u.proxyProvider))},getWeb3jsProvider:()=>{var m;if(!s||!s.wallet)return new lo(new oe);let c=v.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(W=>W.address===(c==null?void 0:c.address)));return!c||!u?new lo(new oe):new lo(u.proxyProvider)},unlinkWallet:async c=>{let u=await t.unlinkWallet(c);return d(u),u},unlinkEmail:async c=>{let u=await t.unlinkEmail(c);return d(u),u},unlinkPhone:async c=>{let u=await t.unlinkPhone(c);return d(u),u},unlinkGoogle:async c=>{let u=await t.unlinkOAuth("google",c);return d(u),u},unlinkTwitter:async c=>{let u=await t.unlinkOAuth("twitter",c);return d(u),u},unlinkDiscord:async c=>{let u=await t.unlinkOAuth("discord",c);return d(u),u},unlinkGithub:async c=>{let u=await t.unlinkOAuth("github",c);return d(u),u},unlinkApple:async c=>{let u=await t.unlinkOAuth("apple",c);return d(u),u},setActiveWallet:async c=>{let u=v.find(h=>(0,Zr.getAddress)(h.address)===(0,Zr.getAddress)(c)),m=s==null?void 0:s.linkedAccounts.find(h=>h.type==="wallet"&&(0,Zr.getAddress)(h.address)===(0,Zr.getAddress)(c));if(!u||!await u.isConnected())le(c),za();else if(!u.linked)u.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(!a||!s)throw new Error("User must be authenticated before creating a Privy wallet");return Va(s,5e3)},signMessage:(c,u)=>new Promise((m,h)=>{if(!a||!s){h(new Error("User must be authenticated before signing with a Privy wallet"));return}let W=ce(s);if(!W){h(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){h(new Error("Message must be a non-empty string"));return}ne(!0);let Te=async()=>{a||h(new Error("User must be authenticated before signing with a Privy wallet"));let Re=await Rt();if(O&&Re)try{if(!await ht.recoverEmbeddedWallet()){h(new Error("Unable to connect to wallet"));return}t.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:W.address});let{response:To}=await O.rpc({accessToken:Re,address:W.address,request:{method:"personal_sign",params:[c,W.address]}}),Xt=To.data;m(Xt),t.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:W.address})}catch(tt){h(tt)}};if(I.embeddedWallets.noPromptOnSignature)u&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),Te();else{let Re={message:c,confirmAndSignMessage:Te,uiOptions:u||{}},tt={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:h};Ze({signMessage:Re,connectWallet:tt}),et("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:(c,u)=>new Promise(async(m,h)=>{var To,Xt;if(!a||!s){h(new Error("User must be authenticated before signing with a Privy wallet"));return}let W=ce(s);if(!W){h(new Error("Must have a Privy wallet before signing"));return}ne(!0);let Te=(Xt=(To=t.connectors)==null?void 0:To.findWalletConnector("embedded","privy"))==null?void 0:Xt.proxyProvider,Re=Object.assign({},c,{chainId:c.chainId||Te.chainId}),tt=async()=>{let Ut=await Rt();if(!Ut||!O){h(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await ht.recoverEmbeddedWallet()){h(new Error("Unable to connect to wallet"));return}let lp=await bi(W.address,Re,I.rpcConfig),cp=await wi(Ut,W.address,O,lp,I.rpcConfig);m(cp)}catch(xr){h(xr)}};if(I.embeddedWallets.noPromptOnSignature)u&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),tt();else{let Ut={transactionRequest:Re,onSuccess:m,onFailure:h,uiOptions:u||{}},xr={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:h};Ze({connectWallet:xr,sendTransaction:Ut}),et("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),exportWallet:()=>new Promise((c,u)=>{if(!a||!s){u(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!ce(s)){u(new Error("Must have a Privy wallet before exporting"));return}ne(!0);let h={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:u},W={appId:e.appId,origin:t.apiUrl,onSuccess:c,onFailure:u};Ze({keyExport:W,connectWallet:h}),et("EMBEDDED_WALLET_CONNECTING_SCREEN")})};$d=Bo.signMessage,qd=Bo.sendTransaction;let ht=(()=>({isNewUserThisSession:f,isLinking:C,linkingHint:j,walletConnectionStatus:B,rpcConfig:I.rpcConfig,captchaData:{ready:en,enabled:I.captchaEnabled,execute:()=>{let c=window.turnstile;if(!c)return;let u=c.render("#cf-turnstile",{sitekey:bs,action:I.id,callback:Uo,"error-callback":te,"expired-callback":()=>{try{c.reset(_t),te(void 0),Uo(void 0)}catch{te("expired_and_failed_reset")}},"unsupported-callback":()=>{console.warn("Browser does not support Turnstile.")}});u||console.warn("Failed to render challenge."),xo(u)},remove:()=>{let c=window.turnstile;!(c!=null&&c.remove)||!_t||(c.remove(_t),xo(void 0),te(void 0),Uo(void 0))},token:on,error:rn},initializeWalletProxy:async c=>{if(O)return O;let u=new Promise(W=>{Er(()=>Te=>W(Te))}),m=new Promise(W=>setTimeout(()=>W(null),c)),h=await Promise.race([u,m]);return Er(null),h},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>{var c;return(c=t.authFlow)==null?void 0:c.meta},closePrivyModal:(c={shouldCallAuthOnSuccess:!0})=>{var m;let u=n&&a&&s;c.shouldCallAuthOnSuccess&&u?(ut(Xe,"login","onComplete",s,f,!1),(m=e.onSuccess)==null||m.call(e,s,f)):M&&ut(Xe,"login","onError","exited_auth_flow"),t.authFlow=void 0,le(null),b(null),S(!1),g(!1),E(!1),r(!1),t.createAnalyticsEvent("modal_closed")},connectWallet:Li,initLoginWithWallet:ip,loginWithWallet:async()=>{if(!n)throw new Ho;if(!(t.authFlow instanceof _o))throw new T("Must initialize SIWE flow first.");let c,u;if(a)c=await t.link();else try{({user:c,isNewUser:u}=await t.authenticate())}catch(m){throw ut(Xe,"login","onError",m.privyErrorCode||"generic_connect_wallet_error"),m}d(c||s||null),E(u||!1),l(!0)},initLoginWithOAuth:async c=>{t.startAuthFlow(new to(c));let u=await t.authFlow.getAuthorizationUrl();u&&u.url&&window.location.assign(u.url)},loginWithOAuth:async()=>{if(!n)throw new Ho;if(!(t.authFlow instanceof to))throw new T("Must initialize OAuth flow before calling loginWithOAuth");let c,u;if(a)c=await t.link();else try{({user:c,isNewUser:u}=await t.authenticate())}catch(m){throw ut(Xe,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}d(c),E(u||!1),l(!0)},initLoginWithEmail:async(c,u)=>{let m=new Po(c,u);t.startAuthFlow(m);try{await m.sendCodeEmail()}catch(h){throw ut(Xe,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}},initLoginWithSms:async(c,u)=>{let m=new Ao(c,u);t.startAuthFlow(m);try{await m.sendSmsCode()}catch(h){throw ut(Xe,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}},resendEmailCode:async()=>{var c;await((c=t.authFlow)==null?void 0:c.sendCodeEmail())},resendSmsCode:async()=>{var c;await((c=t.authFlow)==null?void 0:c.sendSmsCode())},loginWithCode:async c=>{if(!n)throw new Ho;if(t.authFlow instanceof Po)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof Ao)t.authFlow.meta.smsCode=c.trim();else throw new T("Must initialize a passwordless code flow first");let u,m;a?u=await t.link():{user:u,isNewUser:m}=await t.authenticate(),d(u||s||null),E(m||!1),l(!0)},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return d(c),c},walletProxy:O,createAnalyticsEvent:(c,u,m)=>t.createAnalyticsEvent(c,u,m),getUsdTokenPrice:c=>t.getUsdTokenPrice(c),recoverEmbeddedWallet:async()=>new Promise(async(c,u)=>{let m=s==null?void 0:s.linkedAccounts.find(W=>W.type==="wallet"&&W.walletClientType==="privy"),h=await Rt();if(!h||!O||!m){u(new Error("Must have valid access token and Privy wallet to recover wallet"));return}ne(!0);try{await O.connect({accessToken:h,address:m.address}),c(!0)}catch(W){ir(W)&&m.recoveryMethod==="privy"?(t.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:m.address}),(await O.recover({address:m.address,accessToken:h})).address||u(new Error("Unable to recover wallet")),t.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:m.address}),c(!0)):ir(W)?(Ze({recoverWallet:{privyWallet:m,onFailure:u,onSuccess:()=>c(!0)}}),et("EMBEDDED_WALLET_RECOVERY_SCREEN")):u(W)}})}))();jd=ht.recoverEmbeddedWallet;let sp=(0,F.useMemo)(()=>({wallets:v}),[v]);return(0,mt.jsx)($t.Provider,{value:Bo,children:(0,mt.jsx)(Ba.Provider,{value:Xe,children:(0,mt.jsxs)(Ga.Provider,{value:sp,children:[e.children,(0,mt.jsxs)(ta.Provider,{value:ht,children:[(0,mt.jsx)(Wd,{theme:{...I.appearance.palette||{}}}),(0,mt.jsx)(il,{appConfig:I,data:xt,setModalData:Ze,setInitialScreen:b,initialScreen:R,visible:o,authenticated:a,children:o?(0,mt.jsx)(Md,{}):null}),Q&&Ee.id?(0,mt.jsx)(Gd,{appId:e.appId,origin:t.apiUrl,onLoad:he,onLoadFailed:()=>null}):null]}),I.captchaEnabled&&(0,mt.jsx)(Dd,{onLoad:()=>tn(!0)})]})})})};var Yd=require("react");function Jd(e){let{login:t}=(0,Yd.useContext)($t);return Cr("login",e),{login:t}}var Qd=require("react");function Zd(e){let{logout:t}=(0,Qd.useContext)($t);return Cr("logout",e),{logout:t}}var Xd=require("react");function ep(e){let{connectWallet:t}=(0,Xd.useContext)($t);return Cr("connectWallet",e),{connectWallet:t}}0&&(module.exports={AsExternalProvider,ConnectorManager,PrivyClient,PrivyProvider,PrivyProxyProvider,SUPPORTED_CHAINS,VERSION,WalletConnector,getAccessToken,useConnectWallet,useLogin,useLogout,usePrivy,useWallets});
|
|
2119
|
+
`;var Od=require("react"),Si=require("react/jsx-runtime"),yh=({onLoad:e})=>{let t=window;return(0,Od.useEffect)(()=>{if(document.getElementById("cf-script")!==null||t.turnstile)return;t.onloadTurnstileCallback=e;let o=document.createElement("script");o.setAttribute("src","https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback&render=explicit"),o.setAttribute("id","cf-script"),o.setAttribute("async","true"),document.body.appendChild(o)},[]),(0,Si.jsx)(Si.Fragment,{})},Dd=yh;var Oo=_(require("tinycolor2")),Ud="#FFFFFF",gh="#000000",vh=Ud,bh="#1E1E1D";function wh(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function Eo(e,t){let o=Math.max(0,Math.min(1,e.toHsl().l+t));return(0,Oo.default)({...e.toHsl(),l:o})}function Fd({backgroundTheme:e,accentHex:t,successHex:o="#51BA81",errorHex:r="#EC6351",whiteHex:n=Ud,blackHex:i=gh}){let a;switch(e){case"light":a=vh;break;case"dark":a=bh;break;default:a=e;break}let l=(0,Oo.default)(a),s=(0,Oo.default)(t),d=(0,Oo.default)(o),C=(0,Oo.default)(r),g=wh(l.getLuminance()),v=Eo(l,g==="light"?-.04:.11),p=Eo(l,g==="light"?-.88:.87),w=Eo(l,g==="light"?-.77:.75),f=Eo(l,g==="light"?-.43:.45).desaturate(g==="light"?60:20),E=Eo(l,g==="light"?-.08:.25).desaturate(g==="light"?60:20),R=Eo(s,.15),b=Eo(s,-.06),M=(0,Oo.default)(s.getLuminance()>.5?i:n),S=Eo(d,-.16);return{colorScheme:g,background:l.toHslString(),background2:v.toHslString(),foreground:p.toHslString(),foreground2:w.toHslString(),foreground3:f.toHslString(),foreground4:E.toHslString(),accent:s.toHslString(),accentLight:R.toHslString(),accentDark:b.toHslString(),foregroundAccent:M.toHslString(),success:d.toHslString(),successDark:S.toHslString(),error:C.toHslString()}}var Do={appearance:{theme:"light",accentColor:"#676FFF"},walletConnectCloudProjectId:vs,rpcConfig:{rpcUrls:{}},captchaEnabled:!1,_render:{inDialog:!0,inParentNodeId:null}};function ki(e,t){var v,p,w,f,E,R,b,M,S,B;let o,r,n,i,a,l,s,d;if(t!=null&&t.loginMethods?(o=t.loginMethods.includes("email"),r=t.loginMethods.includes("sms"),n=t.loginMethods.includes("wallet"),i=t.loginMethods.includes("google"),a=t.loginMethods.includes("twitter"),l=t.loginMethods.includes("discord"),s=t.loginMethods.includes("github"),d=t.loginMethods.includes("apple")):(o=e.emailAuth,r=e.smsAuth,n=e.walletAuth,i=e.googleOAuth,a=e.twitterOAuth,l=e.discordOAuth,s=e.githubOAuth,d=e.appleOAuth),o&&r&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),r=!1),!o&&!r&&[i,a,l,s,d].some(L=>L))throw new Error("To enable social logins you must also enable either SMS or Email login");if(![o,r,n,i,a,l,s,d].some(L=>L))throw new Error("You must enable at least one login method");let C=((v=t==null?void 0:t.customAuth)==null?void 0:v.getCustomAccessToken)&&((p=t==null?void 0:t.customAuth)==null?void 0:p.enabled)!==!1;return{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,appearance:{logo:((w=t==null?void 0:t.appearance)==null?void 0:w.logo)??e.logoUrl,palette:Fd({backgroundTheme:((f=t==null?void 0:t.appearance)==null?void 0:f.theme)??Do.appearance.theme,accentHex:((E=t==null?void 0:t.appearance)==null?void 0:E.accentColor)??e.accentColor??Do.appearance.accentColor}),showWalletLoginFirst:((R=t==null?void 0:t.appearance)==null?void 0:R.showWalletLoginFirst)??e.showWalletLoginFirst},loginMethods:{wallet:n,email:o,sms:r,google:i,twitter:a,discord:l,github:s,apple:d},legal:{termsAndConditionsUrl:((b=t==null?void 0:t.legal)==null?void 0:b.termsAndConditionsUrl)??e.termsAndConditionsUrl,privacyPolicyUrl:((M=t==null?void 0:t.legal)==null?void 0:M.privacyPolicyUrl)??e.privacyPolicyUrl},walletConnectCloudProjectId:(t==null?void 0:t.walletConnectCloudProjectId)??e.walletConnectCloudProjectId??Do.walletConnectCloudProjectId,rpcConfig:(t==null?void 0:t.rpcConfig)??Do.rpcConfig,captchaEnabled:e.captchaEnabled??Do.captchaEnabled,embeddedWallets:{...e.embeddedWalletConfig,...C?{createOnLogin:"all-users",requireUserPasswordOnCreate:!1,noPromptOnSignature:!0}:{},...t==null?void 0:t.embeddedWallets},customAuth:C?{enabled:!0,...t.customAuth}:void 0,render:{inDialog:((S=t==null?void 0:t._render)==null?void 0:S.inDialog)??Do._render.inDialog,inParentNodeId:((B=t==null?void 0:t._render)==null?void 0:B.inParentNodeId)??Do._render.inParentNodeId}}}function Bd(e,t){var o;return((o=e==null?void 0:e.appearance)==null?void 0:o.logo)&&typeof e.appearance.logo=="object"&&(e.appearance.logo="component"),{...e,legacyCreateEmbeddedWalletFlag:t}}var Ii=require("react");var Ri=class{constructor(){this.callbacks={}}enqueue(t,o){this.callbacks[t]=o}dequeue(t,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${t} event: no event found for id ${o}`);switch(delete this.callbacks[o],t){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:connect":return r;case"privy:wallet:recover":return r;case"privy:wallet:rpc":return r;default:throw new Error(`invalid wallet event type ${t}`)}}};var Hd=require("react/jsx-runtime"),Ch=function(e){return()=>`id-${e++}`}(0);function Eh(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Jr(e){return e.error!==void 0}var br=new Ri,Fa=new Map,xh=(e,t)=>typeof t=="bigint"?t.toString():t,Th=(e,t)=>`${e}${JSON.stringify(t,xh)}`;function Qr(e,t,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");let n=Th(e,t);if(e==="privy:wallet:create"){let a=Fa.get(n);if(a)return a}let i=new Promise((a,l)=>{let s=Ch();br.enqueue(s,{resolve:a,reject:l}),r.postMessage({id:s,event:e,data:t},"*")}).finally(()=>{Fa.delete(n)});return Fa.set(n,i),i}function Ph(e){switch(e.event){case"privy:iframe:ready":let t=br.dequeue(e.event,e.id);return Jr(e)?t.reject(new fo(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let o=br.dequeue(e.event,e.id);return Jr(e)?o.reject(new fo(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let r=br.dequeue(e.event,e.id);return Jr(e)?r.reject(new fo(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:recover":let n=br.dequeue(e.event,e.id);return Jr(e)?n.reject(new fo(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:rpc":let i=br.dequeue(e.event,e.id);return Jr(e)?i.reject(new fo(e.error.type,e.error.message)):i.resolve(e.data)}}function Gd(e){let t=(0,Ii.useRef)(null);return(0,Ii.useEffect)(()=>{let o=t.current;if(!o)return;function r(s){s&&s.origin===e.origin&&Eh(s.data)&&Ph(s.data)}let n={create(s){return Qr("privy:wallet:create",s,o)},connect(s){return Qr("privy:wallet:connect",s,o)},recover(s){return Qr("privy:wallet:recover",s,o)},rpc(s){return Qr("privy:wallet:rpc",s,o)}};window.addEventListener("message",r);let i=()=>e.onLoad(n),a=(...s)=>{console.warn("Privy iframe failed to load: ",...s),e.onLoadFailed()},l=new AbortController;return $s(()=>Qr("privy:iframe:ready",{},o),{abortSignal:l.signal}).then(i,a),()=>{window.removeEventListener("message",r),l.abort()}},[t.current]),(0,Hd.jsx)("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},src:vn(e.origin,`/apps/${e.appId}/embedded-wallets`)})}var wr=require("react"),zd={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]}},Ba=(0,wr.createContext)(void 0),_h=()=>(0,wr.useContext)(Ba);function Cr(e,t){if(!t)return;let r=_h().current[e];return(0,wr.useEffect)(()=>{var n;for(let[i,a]of Object.entries(t))r.hasOwnProperty(i)||console.warn(`Invalid event type "${i}" for action "${e}"`),(n=r[i])==null||n.push(a);return()=>{var i;for(let[a,l]of Object.entries(t))r.hasOwnProperty(a)||console.warn(`Invalid event type "${a}" for action "${e}"`),r[a]=(i=r[a])==null?void 0:i.filter(s=>s!==l)}},[t])}function ut(e,t,o,...r){for(let n of e.current[t][o])n(...r)}var Wi=require("react"),Ga=(0,Wi.createContext)({wallets:[]});function Vd(){return(0,Wi.useContext)(Ga)}var mt=require("react/jsx-runtime");function Ah(e){return typeof e=="string"&&e.length===25}var Xr;function Rt(){if(!Xr){let e=Z.get(Vo);return Promise.resolve(e||null)}return Xr.getAccessToken()}var $d,Js=(e,t)=>$d(e,t),qd,Qs=(e,t)=>qd(e,t),jd,Zs=()=>jd(),Sh=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;Z.put(Tr,t);let o=new URL(window.location.href);o.searchParams.delete("privy_token"),window.history.pushState({},"",o)},Kd=({config:e,...t})=>{var r,n;if(!Ah(t.appId))throw new T("Cannot initialize the Privy provider with an invalid Privy app ID");Xr||(Xr=new Zo({appId:t.appId,apiUrl:t.apiUrl||un}));let o=Object.assign({},e);return t.createPrivyWalletOnLogin!==void 0&&((r=o.embeddedWallets)==null?void 0:r.createOnLogin)===void 0&&(o.embeddedWallets||(o.embeddedWallets={}),o.embeddedWallets.createOnLogin=t.createPrivyWalletOnLogin?"users-without-wallets":"off"),t.createPrivyWalletOnLogin!==void 0&&((n=e==null?void 0:e.embeddedWallets)==null?void 0:n.createOnLogin)&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),(0,mt.jsx)(kh,{...t,config:o,client:Xr})},kh=e=>{var $a,qa,ja;let t=e.client,[o,r]=(0,F.useState)(!1),[n,i]=(0,F.useState)(!1),[a,l]=(0,F.useState)(!1),[s,d]=(0,F.useState)(null),[C,g]=(0,F.useState)(!1),[v,p]=(0,F.useState)([]),w=(0,F.useRef)(v),[f,E]=(0,F.useState)(!1),[R,b]=(0,F.useState)(null),[M,S]=(0,F.useState)(!1),[B,L]=(0,F.useState)({status:"disconnected",connectError:null,connector:null,connectRetry:P}),[j,le]=(0,F.useState)(null),[O,he]=(0,F.useState)(null),[Ee,H]=(0,F.useState)({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,appleOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserPasswordOnCreate:!1},captchaEnabled:!1}),[I,U]=(0,F.useState)(()=>{let c=Bd(e.config,e.createPrivyWalletOnLogin);return t.createAnalyticsEvent("sdk_initialize",c),ki(Ee,e.config)}),[Q,ne]=(0,F.useState)(!0),[xt,Ze]=(0,F.useState)({}),[Tt,xe]=(0,F.useState)(null),[Pt,Er]=(0,F.useState)(null),[en,tn]=(0,F.useState)(!1),[on,Uo]=(0,F.useState)(),[rn,te]=(0,F.useState)(),[_t,xo]=(0,F.useState)(),[Fo,nn]=(0,F.useState)(!1),Xe=(0,F.useRef)(zd),et=c=>{c&&b(c),r(!0),t.createAnalyticsEvent("modal_open",{initialScreen:c})},an=c=>{I.embeddedWallets.createOnLogin!=="off"&&ne(!0),et(c)};(0,F.useEffect)(()=>{var u,m;if(!O||!s){(u=t.connectors)==null||u.removeEmbeddedWalletConnector();return}let c=s==null?void 0:s.linkedAccounts.filter(h=>h.type==="wallet"&&h.walletClient==="privy");if(c&&c.length>0){let h=c[0].address;(m=t.connectors)==null||m.addEmbeddedWalletConnector(O,h)}},[O,s]),(0,F.useEffect)(()=>{!O||Pt==null||Pt(O)},[O]),(0,F.useEffect)(()=>{(async()=>{var h;if(!((h=I.customAuth)!=null&&h.enabled))return;ne(!0);let{getCustomAccessToken:u,isLoading:m}=I.customAuth;if(!(!n||m))try{let W=await u();if(!W){await Bo.logout();return}if(a)return;t.startAuthFlow(new zo(W));let{user:Te,isNewUser:Re}=await t.authenticate();Te||await Bo.logout(),d(Te||null),E(Re||!1),l(!0),nn(!0)}catch(W){console.warn(W),a&&await Bo.logout()}})()},[($a=I.customAuth)==null?void 0:$a.enabled,(qa=I.customAuth)==null?void 0:qa.getCustomAccessToken,(ja=I.customAuth)==null?void 0:ja.isLoading,n,a]),(0,F.useEffect)(()=>{var c,u;Fo&&O&&s&&ro(s,(u=(c=e.config)==null?void 0:c.embeddedWallets)==null?void 0:u.createOnLogin)&&(nn(!1),Va(s,3e4).catch(console.error))},[Fo&&O&&s]),(0,F.useEffect)(()=>{async function c(){var Te,Re,tt;let u=await t.getServerConfig();H(u);let m=ki(u,e.config);U(m),u.customApiUrl&&t.updateApiUrl(u.customApiUrl),t.initializeConnectorManager(m.walletConnectCloudProjectId,m.rpcConfig),(Te=t.connectors)==null||Te.initialize();let h=tp();Sh();let W=await t.getAuthenticatedUser();(tt=(Re=e.config)==null?void 0:Re.customAuth)!=null&&tt.enabled||(l(!!W),W&&ut(Xe,"login","onComplete",W,!1,!0),d(W)),i(!0),Tt==null||Tt(),h&&W&&g(!0),op()}n||c()},[t,Tt,n]),(0,F.useEffect)(()=>{let c=ki(Ee,e.config);U(c)},[e.config]);let tp=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_oauth_code"),m=c.get("privy_oauth_state"),h=c.get("privy_oauth_provider");return u&&m&&h?(t.startAuthFlow(new to(h,u,m)),an("AWAITING_OAUTH_SCREEN"),!0):!1},Li=async(c,u,m)=>{var W;let h=await((W=t.connectors)==null?void 0:W.createWalletConnector(c,u))||null;Ha(h,m)};async function Ha(c,u){if(!c)return L({status:"disconnected",connectError:new $("Unable to connect to wallet."),connector:null,connectRetry:P}),u==null?void 0:u(null);L({connector:c,status:"connecting",connectError:null,connectRetry:()=>Ha(c,u)});try{let m=await c.connect({showPrompt:!0});return L(h=>({...h,status:"connected",connectError:null,connectRetry:P})),m&&!M&&ut(Xe,"connectWallet","onSuccess",m),u==null?void 0:u(m)}catch(m){return m instanceof ft?(console.warn(m.cause?m.cause:m.message),M||ut(Xe,"connectWallet","onError",m.privyErrorCode||"generic_connect_wallet_error")):(console.warn(m),M||ut(Xe,"connectWallet","onError","unknown_connect_wallet_error")),L(h=>({...h,status:"disconnected",connectError:m})),u==null?void 0:u(null)}}let Mi=c=>{c!==null&&t.startAuthFlow(new _o(c))},op=()=>{let c=new URLSearchParams(window.location.search),u=c.get("privy_connector"),m=c.get("privy_wallet_client");if(!u||!m)return;if(m==="phantom"&&!nt()&&an("LOGIN_FAILED_SCREEN"),!t.connectors)throw new T("Connector not initialized");et("AWAITING_CONNECTION");let h=new URL(window.location.href);h.searchParams.delete("privy_connector"),h.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",h),Li(u,m,Mi)};(0,F.useEffect)(()=>{n&&a&&s===null&&t.getAuthenticatedUser().then(d)},[n,a,s,t]);let za=()=>{g(!0),et("LINK_WALLET_SCREEN")},rp=c=>{if(!a||!s)return!1;for(let u of s.linkedAccounts)if(u.type==="wallet"&&u.address===c.address)return!0;return!1},np=async c=>{if(!t.connectors)throw new T("Connector not initialized");let u=t.connectors.findWalletConnector(c.connectorType,c.walletClientType)||null;L(m=>({...m,connector:u,status:"connected",connectError:null,connectRetry:P})),Mi(c),an("AWAITING_CONNECTION")},ip=async(c,u)=>{if(!t.connectors)throw new T("Connector not initialized");await Li(c,u,Mi)},Oi=()=>{p(c=>{var m;let u=((m=t.connectors)==null?void 0:m.wallets.map(h=>({...h,linked:rp(h),loginOrLink:async()=>{if(!await h.isConnected())throw new T("Wallet is not connected");if(h.connectorType==="embedded"&&h.walletClientType==="privy")throw new T("Cannot link or login with embedded wallet");np(h)},unlink:async()=>{if(!a)throw new T("User is not authenticated.");if(h.connectorType==="embedded"&&h.walletClientType==="privy")throw new T("Cannot unlink an embedded wallet");let W=await t.unlinkWallet(h.address);d(W)}})))||[];return Cn(c,u)?c:u})};(0,F.useEffect)(()=>{Oi()},[s==null?void 0:s.linkedAccounts,a]),(0,F.useEffect)(()=>{if(n){if(!t.connectors)throw new T("Connector not initialized");Oi(),t.connectors.on("walletsUpdated",Oi)}},[n]);let ap=()=>{et(a?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};(0,F.useEffect)(()=>{if(!v[0])return;let c=v[0],u=w.current.find(h=>h.address===c.address),m=s==null?void 0:s.linkedAccounts.find(h=>h.type==="wallet"&&h.address===c.address);if(!u&&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)}w.current=v},[v]);let Va=async(c,u)=>{var Te,Re,tt,To;if(ce(c))throw new Error("Only one Privy wallet per user is currently allowed");let[h,W]=await Promise.all([ht.initializeWalletProxy(u),Rt()]);if(!h&&((Re=(Te=e.config)==null?void 0:Te.customAuth)==null?void 0:Re.enabled))throw new Error("Failed to connect to wallet proxy");if(!h||!W||((To=(tt=e.config)==null?void 0:tt.embeddedWallets)==null?void 0:To.requireUserPasswordOnCreate))return new Promise((Xt,Ut)=>{ne(!0),Ze({createWallet:{onSuccess:Xt,onFailure:Ut,callAuthOnSuccessOnClose:!1}}),et("EMBEDDED_WALLET_SCREEN")});{await h.create({accessToken:W});let Xt=await ht.refreshUser(),Ut=ce(Xt);if(!Ut)throw new Error("Failed to create wallet");return Ut}},Bo={ready:n,authenticated:a,user:s,walletConnectors:t.connectors||null,connectWallet:ap,linkWallet:za,linkEmail:()=>{if(s!=null&&s.email)throw new T("User already has an email linked to their account.");g(!0),et("LINK_EMAIL_SCREEN")},linkPhone:()=>{if(s!=null&&s.phone)throw new T("User already has a phone number linked to their account.");g(!0),et("LINK_PHONE_SCREEN")},linkGoogle:async()=>{if(s!=null&&s.google)throw new T("User already has a Google account linked to their account.");await ht.initLoginWithOAuth("google")},linkTwitter:async()=>{if(s!=null&&s.twitter)throw new T("User already has a Twitter account linked to their account.");await ht.initLoginWithOAuth("twitter")},linkDiscord:async()=>{if(s!=null&&s.discord)throw new T("User already has a Discord account linked to their account.");await ht.initLoginWithOAuth("discord")},linkGithub:async()=>{if(s!=null&&s.github)throw new T("User already has a Github account linked to their account.");await ht.initLoginWithOAuth("github")},linkApple:async()=>{await ht.initLoginWithOAuth("apple")},login:async()=>{if(n||(await new Promise(c=>{xe(()=>c)}),xe(null)),a){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}S(!0),an()},logout:async()=>{await t.logout(),d(null),l(!1),b(null),ut(Xe,"logout","onSuccess"),g(!1),r(!1)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{var m;if(!s||!s.wallet)return new oe;let c=v.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(W=>W.address===(c==null?void 0:c.address)));return!c||!u?new oe:u.proxyProvider},getEthersProvider:()=>{var m;if(!s||!s.wallet)return new Ni.Web3Provider(new vt(new oe));let c=v.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(W=>W.address===(c==null?void 0:c.address)));return!c||!u?new Ni.Web3Provider(new vt(new oe)):new Ni.Web3Provider(new vt(u.proxyProvider))},getWeb3jsProvider:()=>{var m;if(!s||!s.wallet)return new lo(new oe);let c=v.find(h=>s.wallet&&h.address===s.wallet.address),u=(m=t.connectors)==null?void 0:m.walletConnectors.find(h=>h.wallets.find(W=>W.address===(c==null?void 0:c.address)));return!c||!u?new lo(new oe):new lo(u.proxyProvider)},unlinkWallet:async c=>{let u=await t.unlinkWallet(c);return d(u),u},unlinkEmail:async c=>{let u=await t.unlinkEmail(c);return d(u),u},unlinkPhone:async c=>{let u=await t.unlinkPhone(c);return d(u),u},unlinkGoogle:async c=>{let u=await t.unlinkOAuth("google",c);return d(u),u},unlinkTwitter:async c=>{let u=await t.unlinkOAuth("twitter",c);return d(u),u},unlinkDiscord:async c=>{let u=await t.unlinkOAuth("discord",c);return d(u),u},unlinkGithub:async c=>{let u=await t.unlinkOAuth("github",c);return d(u),u},unlinkApple:async c=>{let u=await t.unlinkOAuth("apple",c);return d(u),u},setActiveWallet:async c=>{let u=v.find(h=>(0,Zr.getAddress)(h.address)===(0,Zr.getAddress)(c)),m=s==null?void 0:s.linkedAccounts.find(h=>h.type==="wallet"&&(0,Zr.getAddress)(h.address)===(0,Zr.getAddress)(c));if(!u||!await u.isConnected())le(c),za();else if(!u.linked)u.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(!a||!s)throw new Error("User must be authenticated before creating a Privy wallet");return Va(s,15e3)},signMessage:(c,u)=>new Promise((m,h)=>{if(!a||!s){h(new Error("User must be authenticated before signing with a Privy wallet"));return}let W=ce(s);if(!W){h(new Error("Must have a Privy wallet before signing"));return}if(typeof c!="string"||c.length<1){h(new Error("Message must be a non-empty string"));return}ne(!0);let Te=async()=>{a||h(new Error("User must be authenticated before signing with a Privy wallet"));let Re=await Rt();if(O&&Re)try{if(!await ht.recoverEmbeddedWallet()){h(new Error("Unable to connect to wallet"));return}t.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:W.address});let{response:To}=await O.rpc({accessToken:Re,address:W.address,request:{method:"personal_sign",params:[c,W.address]}}),Xt=To.data;m(Xt),t.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:W.address})}catch(tt){h(tt)}};if(I.embeddedWallets.noPromptOnSignature)u&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),Te();else{let Re={message:c,confirmAndSignMessage:Te,uiOptions:u||{}},tt={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:h};Ze({signMessage:Re,connectWallet:tt}),et("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:(c,u)=>new Promise(async(m,h)=>{var To,Xt;if(!a||!s){h(new Error("User must be authenticated before signing with a Privy wallet"));return}let W=ce(s);if(!W){h(new Error("Must have a Privy wallet before signing"));return}ne(!0);let Te=(Xt=(To=t.connectors)==null?void 0:To.findWalletConnector("embedded","privy"))==null?void 0:Xt.proxyProvider,Re=Object.assign({},c,{chainId:c.chainId||Te.chainId}),tt=async()=>{let Ut=await Rt();if(!Ut||!O){h(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await ht.recoverEmbeddedWallet()){h(new Error("Unable to connect to wallet"));return}let lp=await bi(W.address,Re,I.rpcConfig),cp=await wi(Ut,W.address,O,lp,I.rpcConfig);m(cp)}catch(xr){h(xr)}};if(I.embeddedWallets.noPromptOnSignature)u&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),tt();else{let Ut={transactionRequest:Re,onSuccess:m,onFailure:h,uiOptions:u||{}},xr={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:h};Ze({connectWallet:xr,sendTransaction:Ut}),et("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),exportWallet:()=>new Promise((c,u)=>{if(!a||!s){u(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!ce(s)){u(new Error("Must have a Privy wallet before exporting"));return}ne(!0);let h={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:u},W={appId:e.appId,origin:t.apiUrl,onSuccess:c,onFailure:u};Ze({keyExport:W,connectWallet:h}),et("EMBEDDED_WALLET_CONNECTING_SCREEN")})};$d=Bo.signMessage,qd=Bo.sendTransaction;let ht=(()=>({isNewUserThisSession:f,isLinking:C,linkingHint:j,walletConnectionStatus:B,rpcConfig:I.rpcConfig,captchaData:{ready:en,enabled:I.captchaEnabled,execute:()=>{let c=window.turnstile;if(!c)return;let u=c.render("#cf-turnstile",{sitekey:bs,action:I.id,callback:Uo,"error-callback":te,"expired-callback":()=>{try{c.reset(_t),te(void 0),Uo(void 0)}catch{te("expired_and_failed_reset")}},"unsupported-callback":()=>{console.warn("Browser does not support Turnstile.")}});u||console.warn("Failed to render challenge."),xo(u)},remove:()=>{let c=window.turnstile;!(c!=null&&c.remove)||!_t||(c.remove(_t),xo(void 0),te(void 0),Uo(void 0))},token:on,error:rn},initializeWalletProxy:async c=>{if(O)return O;let u=new Promise(W=>{Er(()=>Te=>W(Te))}),m=new Promise(W=>setTimeout(()=>W(null),c)),h=await Promise.race([u,m]);return Er(null),h},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>{var c;return(c=t.authFlow)==null?void 0:c.meta},closePrivyModal:(c={shouldCallAuthOnSuccess:!0})=>{var m;let u=n&&a&&s;c.shouldCallAuthOnSuccess&&u?(ut(Xe,"login","onComplete",s,f,!1),(m=e.onSuccess)==null||m.call(e,s,f)):M&&ut(Xe,"login","onError","exited_auth_flow"),t.authFlow=void 0,le(null),b(null),S(!1),g(!1),E(!1),r(!1),t.createAnalyticsEvent("modal_closed")},connectWallet:Li,initLoginWithWallet:ip,loginWithWallet:async()=>{if(!n)throw new Ho;if(!(t.authFlow instanceof _o))throw new T("Must initialize SIWE flow first.");let c,u;if(a)c=await t.link();else try{({user:c,isNewUser:u}=await t.authenticate())}catch(m){throw ut(Xe,"login","onError",m.privyErrorCode||"generic_connect_wallet_error"),m}d(c||s||null),E(u||!1),l(!0)},initLoginWithOAuth:async c=>{t.startAuthFlow(new to(c));let u=await t.authFlow.getAuthorizationUrl();u&&u.url&&window.location.assign(u.url)},loginWithOAuth:async()=>{if(!n)throw new Ho;if(!(t.authFlow instanceof to))throw new T("Must initialize OAuth flow before calling loginWithOAuth");let c,u;if(a)c=await t.link();else try{({user:c,isNewUser:u}=await t.authenticate())}catch(m){throw ut(Xe,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}d(c),E(u||!1),l(!0)},initLoginWithEmail:async(c,u)=>{let m=new Po(c,u);t.startAuthFlow(m);try{await m.sendCodeEmail()}catch(h){throw ut(Xe,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}},initLoginWithSms:async(c,u)=>{let m=new Ao(c,u);t.startAuthFlow(m);try{await m.sendSmsCode()}catch(h){throw ut(Xe,"login","onError",h.privyErrorCode||"unknown_auth_error"),h}},resendEmailCode:async()=>{var c;await((c=t.authFlow)==null?void 0:c.sendCodeEmail())},resendSmsCode:async()=>{var c;await((c=t.authFlow)==null?void 0:c.sendSmsCode())},loginWithCode:async c=>{if(!n)throw new Ho;if(t.authFlow instanceof Po)t.authFlow.meta.emailCode=c.trim();else if(t.authFlow instanceof Ao)t.authFlow.meta.smsCode=c.trim();else throw new T("Must initialize a passwordless code flow first");let u,m;a?u=await t.link():{user:u,isNewUser:m}=await t.authenticate(),d(u||s||null),E(m||!1),l(!0)},refreshUser:async()=>{let c=await t.getAuthenticatedUser();return d(c),c},walletProxy:O,createAnalyticsEvent:(c,u,m)=>t.createAnalyticsEvent(c,u,m),getUsdTokenPrice:c=>t.getUsdTokenPrice(c),recoverEmbeddedWallet:async()=>new Promise(async(c,u)=>{let m=s==null?void 0:s.linkedAccounts.find(W=>W.type==="wallet"&&W.walletClientType==="privy"),h=await Rt();if(!h||!O||!m){u(new Error("Must have valid access token and Privy wallet to recover wallet"));return}ne(!0);try{await O.connect({accessToken:h,address:m.address}),c(!0)}catch(W){ir(W)&&m.recoveryMethod==="privy"?(t.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:m.address}),(await O.recover({address:m.address,accessToken:h})).address||u(new Error("Unable to recover wallet")),t.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:m.address}),c(!0)):ir(W)?(Ze({recoverWallet:{privyWallet:m,onFailure:u,onSuccess:()=>c(!0)}}),et("EMBEDDED_WALLET_RECOVERY_SCREEN")):u(W)}})}))();jd=ht.recoverEmbeddedWallet;let sp=(0,F.useMemo)(()=>({wallets:v}),[v]);return(0,mt.jsx)($t.Provider,{value:Bo,children:(0,mt.jsx)(Ba.Provider,{value:Xe,children:(0,mt.jsxs)(Ga.Provider,{value:sp,children:[e.children,(0,mt.jsxs)(ta.Provider,{value:ht,children:[(0,mt.jsx)(Wd,{theme:{...I.appearance.palette||{}}}),(0,mt.jsx)(il,{appConfig:I,data:xt,setModalData:Ze,setInitialScreen:b,initialScreen:R,visible:o,authenticated:a,children:o?(0,mt.jsx)(Md,{}):null}),Q&&Ee.id?(0,mt.jsx)(Gd,{appId:e.appId,origin:t.apiUrl,onLoad:he,onLoadFailed:()=>null}):null]}),I.captchaEnabled&&(0,mt.jsx)(Dd,{onLoad:()=>tn(!0)})]})})})};var Yd=require("react");function Jd(e){let{login:t}=(0,Yd.useContext)($t);return Cr("login",e),{login:t}}var Qd=require("react");function Zd(e){let{logout:t}=(0,Qd.useContext)($t);return Cr("logout",e),{logout:t}}var Xd=require("react");function ep(e){let{connectWallet:t}=(0,Xd.useContext)($t);return Cr("connectWallet",e),{connectWallet:t}}0&&(module.exports={AsExternalProvider,ConnectorManager,PrivyClient,PrivyProvider,PrivyProxyProvider,SUPPORTED_CHAINS,VERSION,WalletConnector,getAccessToken,useConnectWallet,useLogin,useLogout,usePrivy,useWallets});
|