@privy-io/react-auth 2.6.3 → 2.6.4

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.
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("mipd"),r=require("react"),n=require("react-device-detect"),a=require("viem/utils"),i=require("./internal-context-HesndSYh.js"),o=require("viem"),s=require("uuid"),l=require("jose"),c=require("eventemitter3"),d=require("@coinbase/wallet-sdk"),u=require("@privy-io/js-sdk-core"),p=require("@marsidev/react-turnstile"),h=require("styled-components"),m=require("tinycolor2"),y=require("@heroicons/react/24/outline/ArrowLeftIcon"),f=require("@heroicons/react/24/outline/ArrowRightIcon"),g=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),w=require("@heroicons/react/24/outline/XMarkIcon"),v=require("@heroicons/react/24/outline/CheckIcon"),x=require("@heroicons/react/24/outline/Square2StackIcon"),C=require("@heroicons/react/24/outline/WalletIcon"),b=require("zustand"),j=require("@walletconnect/ethereum-provider"),k=require("@heroicons/react/24/outline/UserCircleIcon"),E=require("@heroicons/react/24/outline/EnvelopeIcon"),T=require("@heroicons/react/20/solid/CheckIcon"),A=require("@heroicons/react/24/outline/PhoneIcon"),I=require("@heroicons/react/24/outline/ExclamationTriangleIcon"),S=require("@heroicons/react/24/outline/ExclamationCircleIcon"),P=require("@heroicons/react/24/outline/ArrowTopRightOnSquareIcon"),_=require("@heroicons/react/24/solid/DocumentCheckIcon"),N=require("@heroicons/react/24/solid/XCircleIcon"),M=require("fast-password-entropy"),W=require("secure-password-utilities"),O=require("secure-password-utilities/wordlists"),U=require("@heroicons/react/24/outline/LockClosedIcon"),F=require("@heroicons/react/24/outline/PencilSquareIcon"),R=require("@heroicons/react/24/solid/CheckCircleIcon"),L=require("@heroicons/react/24/outline/ArrowPathIcon"),D=require("@heroicons/react/24/outline/EyeIcon"),B=require("@heroicons/react/24/outline/EyeSlashIcon"),z=require("@heroicons/react/24/outline/KeyIcon"),$=require("@heroicons/react/24/outline/ArrowDownTrayIcon"),V=require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),q=require("@heroicons/react/24/outline/DocumentDuplicateIcon"),H=require("@heroicons/react/24/solid/LockClosedIcon"),K=require("@heroicons/react/24/outline/ShieldCheckIcon"),Z=require("qrcode"),G=require("@heroicons/react/24/outline/FingerPrintIcon"),Y=require("@heroicons/react/24/outline/ChevronRightIcon"),J=require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),X=require("@heroicons/react/24/outline/ChevronDownIcon"),Q=require("@heroicons/react/24/outline/CalendarIcon"),ee=require("@headlessui/react"),te=require("@heroicons/react/24/outline/CheckCircleIcon"),re=require("@heroicons/react/24/outline/InformationCircleIcon"),ne=require("@heroicons/react/24/outline/CreditCardIcon"),ae=require("@heroicons/react/24/outline/QrCodeIcon"),ie=require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),oe=require("@heroicons/react/24/outline/GlobeAltIcon"),se=require("ofetch"),le=require("@heroicons/react/24/outline"),ce=require("@heroicons/react/24/outline/ClipboardDocumentIcon"),de=require("@heroicons/react/24/outline/CloudArrowUpIcon"),ue=require("@heroicons/react/24/outline/NoSymbolIcon"),pe=require("@heroicons/react/24/outline/ClockIcon"),he=require("@heroicons/react/24/outline/TrashIcon"),me=require("@heroicons/react/24/solid/CheckBadgeIcon"),ye=require("@heroicons/react/24/solid/IdentificationIcon"),fe=require("@heroicons/react/24/outline/MinusCircleIcon"),ge=require("@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon"),we=require("@heroicons/react/24/solid/ShieldCheckIcon"),ve=require("js-cookie");function xe(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function Ce(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var be=/*#__PURE__*/xe(r),je=/*#__PURE__*/Ce(n),ke=/*#__PURE__*/Ce(l),Ee=/*#__PURE__*/xe(c),Te=/*#__PURE__*/xe(m),Ae=/*#__PURE__*/xe(y),Ie=/*#__PURE__*/xe(f),Se=/*#__PURE__*/xe(g),Pe=/*#__PURE__*/xe(w),_e=/*#__PURE__*/xe(v),Ne=/*#__PURE__*/xe(x),Me=/*#__PURE__*/xe(C),We=/*#__PURE__*/xe(k),Oe=/*#__PURE__*/xe(E),Ue=/*#__PURE__*/xe(T),Fe=/*#__PURE__*/xe(A),Re=/*#__PURE__*/xe(I),Le=/*#__PURE__*/xe(S),De=/*#__PURE__*/xe(P),Be=/*#__PURE__*/xe(_),ze=/*#__PURE__*/xe(N),$e=/*#__PURE__*/xe(M),Ve=/*#__PURE__*/Ce(W),qe=/*#__PURE__*/xe(U),He=/*#__PURE__*/xe(F),Ke=/*#__PURE__*/xe(R),Ze=/*#__PURE__*/xe(L),Ge=/*#__PURE__*/xe(D),Ye=/*#__PURE__*/xe(B),Je=/*#__PURE__*/xe(z),Xe=/*#__PURE__*/xe($),Qe=/*#__PURE__*/xe(V),et=/*#__PURE__*/xe(q),tt=/*#__PURE__*/xe(H),rt=/*#__PURE__*/xe(K),nt=/*#__PURE__*/xe(Z),at=/*#__PURE__*/xe(G),it=/*#__PURE__*/xe(Y),ot=/*#__PURE__*/xe(J),st=/*#__PURE__*/xe(X),lt=/*#__PURE__*/xe(Q),ct=/*#__PURE__*/xe(te),dt=/*#__PURE__*/xe(re),ut=/*#__PURE__*/xe(ne),pt=/*#__PURE__*/xe(ae),ht=/*#__PURE__*/xe(ie),mt=/*#__PURE__*/xe(oe),yt=/*#__PURE__*/xe(ce),ft=/*#__PURE__*/xe(de),gt=/*#__PURE__*/xe(ue),wt=/*#__PURE__*/xe(pe),vt=/*#__PURE__*/xe(he),xt=/*#__PURE__*/xe(me),Ct=/*#__PURE__*/xe(ye),bt=/*#__PURE__*/xe(fe),jt=/*#__PURE__*/xe(ge),kt=/*#__PURE__*/xe(we),Et=/*#__PURE__*/xe(ve);class Tt{async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(i.customJwtAccountAuthenticatePath,{token:this.meta.token})}catch(e){throw i.formatApiError(e)}}async link(){throw Error("Unimplemented")}constructor(e){this.meta={token:e}}}function At(e){return e?{"privy-ui":"t"}:void 0}class It{async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new i.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(i.passwordlessAuthenticatePath,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new i.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(i.passwordlessLinkPath,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw i.formatApiError(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new i.PrivyClientError("Email must be set when initialzing authentication.");let n=At(r);try{return await this.api.post(i.passwordlessInitPath,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw i.formatApiError(e)}}constructor({email:e,captchaToken:t,disableSignup:r}){this.meta={email:e,captchaToken:t,disableSignup:r??!1}}}class St extends It{async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new i.PrivyClientError("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(i.updateEmailPath,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw i.formatApiError(e)}}constructor(e,t,r){super({email:t,captchaToken:r}),this.meta={email:t,captchaToken:r,oldAddress:e,disableSignup:!1}}}class Pt{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e)}del(e){localStorage.removeItem(e)}getKeys(){return Object.entries(localStorage).map((([e])=>e))}}function _t(){try{let e="privy:__session_storage__test",t=new Pt;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var Nt="undefined"!=typeof window&&window.localStorage?new Pt:new class{get(e){return this._cache[e]}put(e,t){void 0!==t?this._cache[e]=t:this.del(e)}del(e){delete this._cache[e]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};const Mt=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom||"isPhantom"in e?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,Wt=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==Mt(e))return!1;if(e.providers)for(let t of e.providers)if(!Wt(t))return!1;return!0},Ot=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers)for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0;return!1},Ut=(e,t,r,n)=>{let a=Number(e),s=t.find((e=>e.id===a));if(!s)throw new i.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return o.createPublicClient({transport:o.http(Ft(s,r,n.appId)),chain:s})},Ft=(e,t,r)=>{let n,a=e.id,o=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])n=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[o])n=t.rpcUrls[o];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",r),n=t.toString()}else n=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!n)throw new i.PrivyConnectorError(`No RPC url found for ${a}`);return n},Rt=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,}))$/),Lt=(e,t=3,r=4,n="ethereum")=>{if(!e)return"";let a="ethereum"===n?2:0;return t+r+a+3>=e.length?e:`${e.slice(0,a+t)}...${e.slice(e.length-r,e.length)}`},Dt=(e,t=3,r=4)=>Lt(e,t,r,"solana"),Bt=e=>new Promise((t=>setTimeout(t,e)));const zt=(e,t={})=>{let r=t.delayMs||150,n=t.maxAttempts||270;return new Promise((async(a,i)=>{let o=!1,s=0;for(;!o&&s<n;){if(t.abortSignal?.aborted)return;e().then((e=>{o=!0,a(e)}),((...e)=>{o=!0,i(...e)})),s+=1,await Bt(r)}o||i(Error("Exceeded max attempts before resolving function"))}))},$t=(e,t,r={},n={})=>{let a=new URL(t,e);for(let[e,t]of Object.entries(r))void 0!==t&&a.searchParams.set(e,t);let i=Object.entries(n);if(i.length>0){let e=new URLSearchParams;for(let[t,r]of i)e.append(t,r);a.hash=e.toString()}return a.href},Vt=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),qt=e=>"string"==typeof e?e:"0x"+e.toString(16);async function Ht({store:e,walletList:t,externalWalletConfig:r,walletChainType:n,timeout:a=3e3}){let i=!1,o=window;return new Promise((s=>{function l(){if(i)return;i=!0,window.removeEventListener("ethereum#initialized",l);let a=e.getProviders();console.debug("Detected injected providers:",a.map((e=>e.info)));let o=[];for(let e of a)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===n&&"app.phantom"===e.info.rdns||o.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==n)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let e of t.providers)e&&r.push(e);return r.push(e.ethereum),r}()){let t=Mt(e);if(!a.some((e=>e.info.name===t))){if(Wt(e,!0)&&!o.find((e=>"metamask"===e.type))){o.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!o.find((e=>"phantom"===e.type))){o.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!o.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==r.coinbaseWallet?.connectionOptions))){o.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}o.find((e=>"unknown_browser_extension"===e.type))||o.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}s(o)}o.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout((()=>{l()}),a))}))}function Kt(e){return`eip155:${String(Number(e))}`}const Zt=(e,t,r,n)=>{let a=Number(e),o=t.find((e=>e.id===a));if(!o)throw new i.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return Ft(o,r,n)},Gt=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map((([e,r])=>{if(null!=r&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:r}}};const Yt=["c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96","4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0","225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f","1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369","c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a","ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18","bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6","74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d","afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7","f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d","84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04","0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150","38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662","9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0","c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576","8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4","e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4","f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2","138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98","47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83","7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26","8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3","031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa","2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568","dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd","2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01","b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f","0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92","719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3","942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef","8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2","07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80","8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819","bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a","cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e","94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43","2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715","14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc","576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd","49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd","19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b","5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b","d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b","50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b","9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8","6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa","41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071","14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd","a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1","971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709","18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1","15c8b91ade1a4e58f3ce4e7a0dd7f42b47db0c8df7e0d84f63eb39bcb96c4e0f","541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf"];function Jt(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let Xt="WALLETCONNECT_DEEPLINK_CHOICE";function Qt(e){return e.startsWith("http://")||e.startsWith("https://")}function er(e,t){if(Qt(e))return tr(e,t);let r=e;return r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function tr(e,t){if(!Qt(e))return er(e,t);let r=e;return r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function rr(e,t){window.open(e,t,"noreferrer noopener")}class nr{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}class ar{get meta(){return this._meta}async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new i.PrivyClientError("Auth flow must be initialized first");try{let e=await this.api.post(i.farcasterAuthenticatePath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new i.PrivyClientError("No response from authentication");return e}catch(e){throw i.formatApiError(e)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(i.farcasterLinkPath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw i.formatApiError(e)}}async _startChannelOnce(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");let e=await this.api.post(i.farcasterInitPath,{token:this.captchaToken});n.isMobile&&!n.isIOS&&e.connect_uri&&rr(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new i.PrivyClientError("Auth flow must be initialized first");let e=await this.api.get(i.farcasterStatusPath,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new nr(this._startChannelOnce.bind(this)),this.pollForReady=new nr(this._pollForReady.bind(this)),this._meta.disableSignup=t}}const ir="https://auth.privy.io",or=1400,sr=2500,lr=4e3,cr="2.6.3",dr="privy:token",ur="privy-token",pr="privy:refresh_token",hr="privy:pat",mr="privy:id_token",yr="privy-id-token",fr="privy-session",gr="privy:caid",wr=e=>`privy:guest:${e}`,vr=e=>`privy:cross-app:${e}`,xr="privy:state_code",Cr="privy:code_verifier",br="privy:headless_oauth",jr="privy:oauth_disable_signup",kr=e=>`privy:wallet:${e}`,Er="privy:connectors",Tr="privy:connections",Ar=12e4,Ir=3e4,Sr="https://api.moonpay.com/v1",Pr="https://api.moonpay.com/v1",_r="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Nr="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";function Mr(e){return crypto.getRandomValues(new Uint8Array(e))}function Wr(){return l.base64url.encode(Mr(36))}function Or(){return Wr()}async function Ur(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return l.base64url.encode(t)}}class Fr{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new i.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new i.PrivyClientError("User denied confirmation during OAuth flow");let e=function(){let e=Nt.get(Cr);if(!e)throw new i.PrivyClientError("Authentication error.");return e}();try{let t=await this.api.post(i.oAuthAuthenticatePath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Nt.del(Cr),Nt.del(br),Nt.del(jr),t}catch(e){let t=i.formatApiError(e);if(t.privyErrorCode)throw new i.PrivyClientError(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new i.PrivyClientError("Invalid code during oauth flow.",void 0,i.PrivyErrorCode.OAUTH_USER_DENIED);throw new i.PrivyClientError("Invalid code during OAuth flow.",void 0,i.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new i.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new i.PrivyClientError("User denied confirmation during OAuth flow");let e=Nt.get(Cr);if(!e)throw new i.PrivyClientError("Authentication error.");try{let t=await this.api.post(i.oAuthLinkPath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return Nt.del(Cr),t}catch(e){throw i.formatApiError(e)}}async getAuthorizationUrl(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.provider)throw new i.PrivyClientError("Provider must be set when initializing OAuth authentication.");let e=Wr();Nt.put(Cr,e);let t=Or();Nt.put(xr,t);let r=await Ur(e);this.meta.withPrivyUi||Nt.put(br,!0),this.meta.disableSignup&&Nt.put(jr,!0);let n=At(this.meta.withPrivyUi);try{return await this.api.post(i.oAuthInitPath,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:t},{headers:{...n}})}catch(e){throw i.formatApiError(e)}}constructor(e){this.meta=e}}function Rr(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Lr=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...t},...r,children:[/*#__PURE__*/e.jsx("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),/*#__PURE__*/e.jsx("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]}),Dr=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...t},...r,children:[/*#__PURE__*/e.jsx("g",{clipPath:"url(#clip0)",children:/*#__PURE__*/e.jsx("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),/*#__PURE__*/e.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0",children:/*#__PURE__*/e.jsx("rect",{width:"71",height:"55",fill:"white"})})})]}),Br=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...t},...r,children:/*#__PURE__*/e.jsx("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})}),zr=({style:t})=>/*#__PURE__*/e.jsx(mt.default,{style:{color:"var(--privy-color-error)",...t}}),$r=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...t},...r,children:[/*#__PURE__*/e.jsx("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),/*#__PURE__*/e.jsx("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),/*#__PURE__*/e.jsx("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),/*#__PURE__*/e.jsx("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});function Vr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...t,children:[/*#__PURE__*/e.jsxs("defs",{children:[/*#__PURE__*/e.jsxs("linearGradient",{id:"b",children:[/*#__PURE__*/e.jsx("stop",{offset:"0",stopColor:"#3771c8"}),/*#__PURE__*/e.jsx("stop",{stopColor:"#3771c8",offset:".128"}),/*#__PURE__*/e.jsx("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),/*#__PURE__*/e.jsxs("linearGradient",{id:"a",children:[/*#__PURE__*/e.jsx("stop",{offset:"0",stopColor:"#fd5"}),/*#__PURE__*/e.jsx("stop",{offset:".1",stopColor:"#fd5"}),/*#__PURE__*/e.jsx("stop",{offset:".5",stopColor:"#ff543e"}),/*#__PURE__*/e.jsx("stop",{offset:"1",stopColor:"#c837ab"})]}),/*#__PURE__*/e.jsx("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),/*#__PURE__*/e.jsx("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),/*#__PURE__*/e.jsx("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/e.jsx("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/e.jsx("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}function qr({style:t,...r}){/*#__PURE__*/return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...t},...r,children:/*#__PURE__*/e.jsx("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:/*#__PURE__*/e.jsx("g",{transform:"scale(5.12,5.12)",children:/*#__PURE__*/e.jsx("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}function Hr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...t,children:[/*#__PURE__*/e.jsx("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),/*#__PURE__*/e.jsx("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}function Kr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...t,children:[/*#__PURE__*/e.jsx("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),/*#__PURE__*/e.jsx("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),/*#__PURE__*/e.jsx("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}const Zr=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...t},...r,children:/*#__PURE__*/e.jsx("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})});let Gr={google:{name:"Google",component:$r},discord:{name:"Discord",component:Dr},github:{name:"Github",component:Br},linkedin:{name:"LinkedIn",component:qr},twitter:{name:"Twitter",component:Zr},spotify:{name:"Spotify",component:Hr},instagram:{name:"Instagram",component:Vr},tiktok:{name:"Tiktok",component:Kr},apple:{name:"Apple",component:Lr}};const Yr=e=>e in Gr?Gr[e]:{name:"Unknown",component:zr};function Jr(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),n=e.get("privy_oauth_provider");if(!t||!r||!n)return{inProgress:!1};let a=!1;try{a=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:n,withPrivyUi:!Nt.get(br),popupFlow:null!==window.opener&&a,disableSignup:!!Nt.get(jr)}}function Xr(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Nt.del(xr),window.history.replaceState({},"",e)}class Qr{async initRegisterFlow(e){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new i.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,r=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(i.passkeyRegisterPath,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new i.PrivyClientError("Passkey request timed out or rejected by user.",void 0,i.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw i.formatApiError(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new i.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let r=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(i.passkeyAuthenticatePath,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new i.PrivyClientError("Passkey request timed out or rejected by user.",void 0,i.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw i.formatApiError(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new i.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,r=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(i.passkeyLinkPath,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new i.PrivyClientError("Passkey request timed out or rejected by user.",void 0,i.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw i.formatApiError(e)}}async _initRegisterOnce(e){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");let t=At(e);return await this.api.post(i.passkeyInitRegisterPath,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");let t=At(e);return await this.api.post(i.passkeyInitAuthenticatePath,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");return await this.api.post(i.passkeyInitLinkPath,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new nr(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new nr(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new nr(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}const en=({address:e,chainId:t,nonce:r})=>`${window.location.host} wants you to sign in with your Ethereum account:\n${e}\n\nBy signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: ${t}\nNonce: ${r}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class tn{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,chainId:this.wallet.chainId,address:this.wallet.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw i.formatApiError(e)}}async sign(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new i.PrivyClientError("Could not prepare SIWE message");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=en({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1){this._meta={disableSignup:!1},this.getNonceOnce=new nr(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=r,this.client=t,this._meta.disableSignup=n}}class rn{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw i.formatApiError(e)}}async sign(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new i.PrivyClientError("Could not prepare SIWS message");if(!this.wallet.signMessage)throw new i.PrivyClientError("Wallet does not support signMessage");let e=await this.wallet.signMessage(Buffer.from(this.preparedMessage));return{message:this.preparedMessage,signature:Buffer.from(e).toString("base64")}}async _getNonceOnce(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=(({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\nYou are proving you own ${e}.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: mainnet\nNonce: ${t}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`)({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1){this._meta={disableSignup:!1},this.getNonceOnce=new nr(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=r,this.client=t,this._meta.disableSignup=n}}class nn{async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new i.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(i.passwordlessSmsAuthenticatePath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new i.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(i.passwordlessSmsLinkPath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw i.formatApiError(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new i.PrivyClientError("phone nNumber must be set when initialzing authentication.");let n=At(r);try{return await this.api.post(i.passwordlessSmsInitPath,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw i.formatApiError(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:r}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:r??!1}}}class an extends nn{async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new i.PrivyClientError("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(i.updatePhonePath,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw i.formatApiError(e)}}constructor(e,t,r){super({phoneNumber:t,captchaToken:r}),this.meta={phoneNumber:t,captchaToken:r,oldPhoneNumber:e,disableSignup:!1}}}const on=/*#__PURE__*/r.createContext({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:i.notImplemented,setError:i.notImplemented,setExecuting:i.notImplemented,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:i.notImplemented,reset:i.notImplemented,execute:i.notImplemented});class sn extends i.PrivyError{constructor(e,t,r){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=r}}const ln=({children:t,id:n,captchaSiteKey:a,captchaEnabled:o})=>{let s=r.useRef(null),[l,c]=r.useState(),[d,u]=r.useState(),[p,h]=r.useState(!1),m=r.useMemo((()=>o?p||l||d?!p||l||d?l&&!d?{status:"success",token:l}:d?{status:"error",error:d}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[o,l,d,p]);/*#__PURE__*/return e.jsx(on.Provider,{value:{...m,ref:s,enabled:o,siteKey:a,appId:n,setToken:c,setError:u,setExecuting:h,remove(){o&&(s.current?.remove(),h(!1),u(void 0),c(void 0))},reset(){o&&(s.current?.reset(),h(!1),u(void 0),c(void 0))},execute(){o&&(h(!0),s.current?.execute())},async waitForResult(){if(!o)return"";try{return await function(e,{interval:t=100,timeout:r=5e3}={}){return new Promise(((n,a)=>{let i,o=0,s=()=>{o>=r?a("Max attempts reached without result"):(i=e(),o+=t,null==i?setTimeout(s,t):n(i))};s()}))}((()=>s.current?.getResponse()),{interval:200,timeout:2e4})}catch(e){throw new sn("Captcha failed",null,i.PrivyErrorCode.CAPTCHA_TIMEOUT)}}},children:t})},cn=()=>r.useContext(on);class dn{async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(i.telegramAccountAuthenticatePath,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(i.telegramAccountLinkPath,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw i.formatApiError(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function un(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===i.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===i.PrivyErrorCode.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===i.PrivyErrorCode.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===i.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===i.PrivyErrorCode.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===i.PrivyErrorCode.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===i.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof sn&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function pn(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function hn(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}class mn{static parse(e){try{return new mn(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return ke.decodeJwt(e),e}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=ke.decodeJwt(e)}}class yn extends mn{static parse(e){try{return new yn(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}function fn(e){return e?new Date(1e3*e):null}function gn(e,t){return e.slice().sort(((e,t)=>(e.firstVerifiedAt??e.verifiedAt).getTime()-(t.firstVerifiedAt??t.verifiedAt).getTime())).find((e=>e.type===t))}const wn=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType&&0===e.walletIndex))||null,vn=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType)),xn=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType)),Cn=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType&&0===e.walletIndex))||null,bn=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType))||null,jn=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType))||null,kn=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.address===t))||null,En=e=>wn(e)??Cn(e);function Tn(e){if(!e)return null;let t=function(e){let t=[];for(let r of e){let e=r.type;switch(r.type){case"wallet":let n={id:r.id,address:r.address,type:r.type,imported:r.imported,delegated:r.delegated,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at),chainType:r.chain_type,walletClientType:r.wallet_client_type,connectorType:r.connector_type,recoveryMethod:r.recovery_method,walletIndex:r.wallet_index};t.push(n);break;case"smart_wallet":let a={address:r.address,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at),smartWalletType:r.smart_wallet_type};t.push(a);break;case"cross_app":let i={type:r.type,subject:r.subject,embeddedWallets:r.embedded_wallets,smartWallets:r.smart_wallets,providerApp:{id:r.provider_app_id},verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(i);break;case"email":let o={address:r.address,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(o);break;case"phone":let s={number:r.phoneNumber,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(s);break;case"google_oauth":let l={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(l);break;case"spotify_oauth":let c={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(c);break;case"instagram_oauth":let d={subject:r.subject,username:r.username,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(d);break;case"twitter_oauth":let u={subject:r.subject,username:r.username,name:r.name,type:r.type,profilePictureUrl:r.profile_picture_url,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(u);break;case"discord_oauth":let p={subject:r.subject,username:r.username,email:r.email,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(p);break;case"github_oauth":let h={subject:r.subject,username:r.username,name:r.name,email:r.email,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(h);break;case"tiktok_oauth":let m={subject:r.subject,username:r.username,name:r.name,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(m);break;case"linkedin_oauth":let y={subject:r.subject,name:r.name,email:r.email,vanityName:r.vanity_name,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(y);break;case"apple_oauth":let f={subject:r.subject,email:r.email,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(f);break;case"custom_auth":t.push({type:r.type,customUserId:r.custom_user_id,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)});break;case"farcaster":let g={type:r.type,fid:r.fid,ownerAddress:r.owner_address,displayName:r.display_name,username:r.username,bio:r.bio,pfp:r.profile_picture_url,url:r.homepage_url,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at),signerPublicKey:r.signer_public_key};t.push(g);break;case"passkey":let w={type:r.type,enrolledInMfa:r.enrolled_in_mfa,credentialId:r.credential_id,authenticatorName:r.authenticator_name,createdWithDevice:r.created_with_device,createdWithOs:r.created_with_os,createdWithBrowser:r.created_with_browser,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(w);break;case"telegram":let v={type:r.type,telegramUserId:r.telegram_user_id,firstName:r.first_name,lastName:r.last_name,username:r.username,photoUrl:r.photo_url,verifiedAt:fn(r.first_verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(v);break;case"authorization_key":let x={type:r.type,publicKey:r.public_key,verifiedAt:fn(r.first_verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(x);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),r=gn(t,"wallet"),n=gn(t,"smart_wallet"),a=gn(t,"email"),i=gn(t,"phone"),o=gn(t,"google_oauth"),s=gn(t,"twitter_oauth"),l=gn(t,"discord_oauth"),c=gn(t,"github_oauth"),d=gn(t,"spotify_oauth"),u=gn(t,"instagram_oauth"),p=gn(t,"tiktok_oauth"),h=gn(t,"linkedin_oauth"),m=gn(t,"apple_oauth"),y=gn(t,"farcaster"),f=gn(t,"telegram"),g=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:fn(t)})));return{id:e.id,createdAt:fn(e.created_at),linkedAccounts:t,email:a&&{address:a?.address},phone:i&&{number:i?.number},wallet:r&&{id:r.id,address:r.address,chainType:r.chainType,walletClientType:r.walletClientType,connectorType:r.connectorType,recoveryMethod:r.recoveryMethod,imported:r.imported,delegated:r.delegated,walletIndex:r.walletIndex},smartWallet:n&&{address:n.address,smartWalletType:n.smartWalletType},google:o&&{subject:o.subject,email:o.email,name:o.name},twitter:s&&{subject:s.subject,username:s.username,name:s.name,profilePictureUrl:s.profilePictureUrl},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:c&&{subject:c.subject,username:c.username,name:c.name,email:c.email},spotify:d&&{subject:d.subject,email:d.email,name:d.name},instagram:u&&{subject:u.subject,username:u.username},tiktok:p&&{subject:p.subject,username:p.username,name:p.name},linkedin:h&&{subject:h.subject,name:h.name,email:h.email,vanityName:h.vanityName},apple:m&&{subject:m.subject,email:m.email},farcaster:y&&{fid:y.fid,ownerAddress:y.ownerAddress,displayName:y.displayName,username:y.username,bio:y.bio,pfp:y.pfp,url:y.url,signerPublicKey:y.signerPublicKey},telegram:f&&{telegramUserId:f.telegramUserId,firstName:f.firstName,lastName:f.lastName,username:f.username,photoUrl:f.photoUrl},delegatedWallets:[],mfaMethods:g.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}const An=e=>e?.linkedAccounts.find((e=>"authorization_key"===e.type));let In=e=>{if("ethereum"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier"};if("solana"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"solana-address-verifier"};throw Error("Failed to get account entropy details")};const Sn=(e,t)=>{let r=An(e);if(r)return{entropyId:r.publicKey,entropyIdVerifier:"p256"};if(t?.imported)return In(t);let n=En(e);if(!n)throw Error("Failed to find primary wallet");return In(n)},Pn=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),/*#__PURE__*/e.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"})]}),_n={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-mainnet.rpc.privy.systems"]},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"}}},Nn={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0},Mn={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"}}},Wn={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},On={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-mainnet.rpc.privy.systems"]},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"}}},Un={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0},Fn={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},Rn={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{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},Ln={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://mainnet.rpc.privy.systems"]},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"}}},Dn={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-mainnet.rpc.privy.systems"]},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"}}},Bn={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0},zn={id:137,name:"Polygon Mainnet",network:"polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-mainnet.rpc.privy.systems"]},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"}}},$n={id:80002,name:"Polygon Amoy",network:"polygon-amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-amoy.rpc.privy.systems"]},infura:{http:["https://polygon-amoy.infura.io/v3"],webSocket:["wss://polygon-amoy.infura.io/ws/v3"]},default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"OK LINK",url:"https://www.oklink.com/amoy"}},testnet:!0},Vn={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{privy:{http:["https://sepolia.rpc.privy.systems"]},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},qn={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}},Hn=[_n,Nn,Vn,Ln,Dn,Bn,zn,$n,Fn,{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},{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"}}},{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"}}},On,Un,{id:80085,network:"berachain-artio",name:"Berachain Artio",nativeCurrency:{name:"BERA",symbol:"BERA",decimals:18},rpcUrls:{default:{http:["https://berachain-artio.rpc.privy.systems"]},public:{http:["https://berachain-artio.rpc.privy.systems"]}},blockExplorers:{default:{name:"Beratrail",url:"https://artio.beratrail.io"}},testnet:!0},{id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network"}}},Rn,{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},Mn,Wn,qn,{id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0},{id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0},{id:17e3,name:"Holesky",network:"holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://ethereum-holesky.publicnode.com"]},public:{http:["https://ethereum-holesky.publicnode.com"]}},blockExplorers:{etherscan:{name:"EtherScan",url:"https://holesky.etherscan.io"},default:{name:"EtherScan",url:"https://holesky.etherscan.io"}}},{id:690,name:"Redstone",network:"redstone",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.redstonechain.com"]},public:{http:["https://rpc.redstonechain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.redstone.xyz/"}}},{id:17069,name:"Garnet Holesky",network:"garnet-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.garnetchain.com"]},public:{http:["https://rpc.garnetchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.garnetchain.com"}}}],Kn=new Set(Hn.map((e=>e.id)));class Zn extends i.PrivyConnectorError{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class Gn extends i.PrivyConnectorError{constructor(){super("User rejected connection"),this.type="wallet_error"}}const Yn=e=>e instanceof i.PrivyConnectorError?e:e?.code?new Xn(e):new i.PrivyConnectorError("Unknown connector error",e);class Jn extends i.PrivyError{constructor(e,t,r){super(e),this.type="provider_error",this.code=t,this.data=r}}class Xn extends Jn{constructor(e){super(e.message,e.code,e.data);let t=Object.values(u.ProviderErrors).find((t=>t.eipCode===e.code));this.details=t||u.ProviderErrors.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=u.ProviderErrors.E32002_CONNECTION_ALREADY_PENDING:this.details=u.ProviderErrors.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=u.ProviderErrors.E32002_WALLET_LOCKED))}}const Qn={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...u.ProviderErrors};function ea(e){return"ethereum"===e.type}function ta(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let n=e[r],a=t[r];if(n?.address!==a?.address||n&&a&&ea(n)&&ea(a)&&n?.chainId!==a?.chainId||n?.connectorType!==a?.connectorType||n?.connectedAt!==a?.connectedAt||n?.walletClientType!==a?.walletClientType||n?.isConnected!==a?.isConnected||n?.linked!==a?.linked)return!1}return!0}class ra extends Ee.default{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const na=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||Ar;let aa;function ia(e){return"ethereum"===e.chainType}class oa extends ra{buildConnectedWallet(e,t,r,n){let o=async()=>!!this.wallets.find((t=>a.getAddress(t.address)===a.getAddress(e)));return{type:"ethereum",address:a.getAddress(e),chainId:t,meta:r,imported:n,switchChain:async r=>{let n,s;if(!o)throw new i.PrivyConnectorError("Wallet is not currently connected.");let l=this.wallets.find((t=>a.getAddress(t.address)===a.getAddress(e)))?.chainId;if(!l)throw new i.PrivyConnectorError("Unable to determine current chainId.");if("number"==typeof r?(n=`0x${r.toString(16)}`,s=r):(n=r,s=Number(r)),l===Kt(n))return;let c=this.chains.find((e=>e.id===s));if(!c)throw new i.PrivyConnectorError(`Unsupported chainId: ${r}`);let d=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:n}]})};try{return await d()}catch(e){if(((e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");case"rabby_wallet":return e.message.includes("Unrecognized chain ID");default:return 4902===e.code||e.message?.includes("4902")}})(e,this.walletClientType))return"rabby_wallet"===this.walletClientType&&await Bt(300),await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:n,chainName:c.name,nativeCurrency:c.nativeCurrency,rpcUrls:[c.rpcUrls.default?.http[0]??""],blockExplorerUrls:[c.blockExplorers?.default.url??""]}]}),d();if("rainbow"===this.walletClientType&&e.message?.includes("wallet_switchEthereumChain"))throw new i.PrivyConnectorError(`Rainbow does not support the chainId ${t}`);throw e}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:o,getEthereumProvider:async()=>{if(!await o())throw new i.PrivyConnectorError("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await o())throw new i.PrivyConnectorError("Wallet is not currently connected.");return await this.sign(e)},disconnect:()=>{this.disconnect()}}}async syncAccounts(e){let t,r=e;try{if(void 0===r){let e=await zt((()=>this.proxyProvider.request({method:"eth_accounts"})),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,e),Array.isArray(e)&&(r=e)}}catch(e){console.debug("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",e)}if(!r||!Array.isArray(r)||r.length<=0||!r[0])return;let n=r[0],i=a.getAddress(n),o=[];if("privy"===this.walletClientType){let e=Nt.get(kr(i));this.chains.find((t=>t.id===Number(e)))||(Nt.del(kr(i)),e=null),t=e||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}catch(e){console.warn(`Unable to switch embedded wallet to chain ID ${t} on initialization`)}}else try{let e=await zt((()=>this.proxyProvider.request({method:"eth_chainId"})),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,e),"string"==typeof e)t=e;else{if("number"!=typeof e)throw Error("Invalid chainId returned from provider");t=`0x${e.toString(16)}`}}catch(e){console.warn("Failed to get chainId from provider, defaulting to 0x1",e),t="0x1"}let s=Kt(t);if(!o.find((e=>a.getAddress(e.address)===i))){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};o.push(this.buildConnectedWallet(a.getAddress(n),s,e,"embedded_imported"===this.connectorType))}ta(o,this.wallets)||(this.wallets=o,this.emit("walletsUpdated"))}async getConnectedWallet(){let e=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt)).find((t=>e.find((e=>a.getAddress(e)===a.getAddress(t.address)))))||null}async isConnected(){let e=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0}async sign(e){return await this.connect({showPrompt:!1}),this.proxyProvider.request({method:"personal_sign",params:[a.toHex(e),this.wallets[0]?.address]})}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)}constructor(e,t,r,n){super(e),this.chainType="ethereum",this.onAccountsChanged=e=>{0===e.length?this.onDisconnect():this.syncAccounts(e)},this.onChainChanged=e=>{this.wallets.forEach((t=>{t.chainId=Kt(e),"privy"===this.walletClientType&&Nt.put(kr(t.address),e)})),this.emit("walletsUpdated")},this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")},this.onConnect=async()=>{this.connected=!0,"coinbase_wallet"===this.connectorType&&await Bt(300),this.syncAccounts()},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=r,this.rpcConfig=n,this.rpcTimeoutDuration=na(n,e),this.connected=!1,this.initialized=!1}}class sa{on(e,t){if(this.walletProvider)return this.walletProvider.on(e,t);this._subscriptions.push({eventName:e,listener:t})}async request(e){if(!this.walletProvider)throw new i.PrivyConnectorError(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),this.walletTimeout()]).catch((e=>{throw Yn(e)}))}constructor(e,t){this.removeListener=(e,t)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(e,t)}catch(e){console.warn("Unable to remove wallet provider listener")}},this.walletTimeout=(e=new Zn,t=this.rpcTimeoutDuration)=>new Promise(((r,n)=>setTimeout((()=>{n(e)}),t))),this.setWalletProvider=e=>{this.walletProvider&&this._subscriptions.forEach((e=>{this.removeListener(e.eventName,e.listener)})),this.walletProvider=e,this._subscriptions.forEach((e=>{this.walletProvider?.on(e.eventName,e.listener)}))},this.walletProvider=e,this.rpcTimeoutDuration=t||Ar,this._subscriptions=[]}}let la=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],ca=(e,t)=>e.makeWeb3Provider({options:t});class da extends oa{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new i.PrivyConnectorError("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw Yn(e)}}updateConnectionPreference(e){this.connectionOptions=e,this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(ca(aa,this.connectionOptions))}constructor(e,t,r,n,a,i){if(super("coinbase_wallet",e,t,r),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new sa(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=n.coinbaseWallet.connectionOptions??"all",this.walletClientType="smartWalletOnly"===this.connectionOptions?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!aa){let r=[t.id].concat(e.map((e=>e.id))),n="eoaOnly"!==this.connectionOptions?r.filter((e=>!la.includes(e))):[];n.length>0&&!n.every((e=>Kn.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${n.join(", ")}`),aa=new d.CoinbaseWalletSDK({appName:a,appLogoUrl:i,appChainIds:r})}this.proxyProvider.setWalletProvider(ca(aa,this.connectionOptions))}}const ua=({...t})=>/*#__PURE__*/e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:/*#__PURE__*/e.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:t.color||"var(--privy-color-foreground-3)"})});class pa extends oa{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[qt(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:ua,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}constructor({provider:e,chains:t,defaultChain:r,rpcConfig:n,imported:a,walletIndex:i}){super("privy",t,r,n),this.connectorType="embedded",this.proxyProvider=e,this.walletIndex=i,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}}const ha=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];let ma={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844"};const ya={legacy:0,eip2930:1,eip1559:2,eip4844:3};let fa=e=>void 0!==e?BigInt(e):void 0;function ga(e){let t,{type:r=2,...n}=e;n.accessList&&Array.isArray(n.accessList)?t=n.accessList.map((e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e)):n.accessList&&(t=Object.entries(n.accessList).map((e=>({address:e[0],storageKeys:e[1]}))));let a=Number(n.chainId??1),s=o.isHex(n.data)?n.data:n.data?o.toHex(Uint8Array.from(n.data)):void 0,l=n.nonce?Number(n.nonce):void 0,c={chainId:a,data:s,nonce:l,value:fa(n.value),gas:fa(n.gas??n.gasLimit)},d=Number(r);if(0===d)return{...n,type:ma[d],...c,gasPrice:fa(n.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===d)return{...n,type:ma[d],...c,gasPrice:fa(n.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===d)return{...n,type:ma[d],...c,nonce:l,accessList:t,maxFeePerGas:fa(n.maxFeePerGas),maxPriorityFeePerGas:fa(n.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw new i.PrivyClientError(`Unsupported transaction type: ${r}`)}class wa extends Error{constructor(e,t,r){super(e),this.code=t,this.data=r}}class va extends Ee.default{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new wa(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await bv()||!this.address)throw new wa("Disconnected",4900);let{hash:r}=await Tv(t,{address:this.address});return r}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new wa(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await bv()||!this.address)throw new wa("Disconnected",4900);let{signature:r}=await Ev(t,{address:this.address});return r}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new wa(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new wa(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Ut(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],r=e.params[1],{signature:n}=await jv({message:t},{address:r});return n}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],r="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:n}=await kv(Gt(r),{address:t});return n}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:qt(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...ga(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return qt(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>ha.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await bv();if(await Av(),!t||!this.address)throw new wa("Disconnected",4900);try{return(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:{method:e.method,params:e.params}})).response.data}catch(e){throw console.error(e),new wa("Disconnected",4900)}}}constructor({walletProxy:e,address:t,entropyId:r,entropyIdVerifier:n,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l}){super(),this.walletProxy=e,this.address=t,this.entropyId=r,this.entropyIdVerifier=n,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Ut(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=na(a,"privy"),this.appId=o,this.walletIndex=l}}class xa extends oa{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:r,walletClientType:n,defaultChain:a}){super(n,[],a,{}),this.connectorType="null",this.proxyProvider=new sa(void 0,Ar),this.id=e,this.name=t,this.icon=r,this.connectorType=n}}const Ca=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...t},...r,children:/*#__PURE__*/e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})}),ba=({style:t,...r})=>/*#__PURE__*/e.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",...t},...r,children:[/*#__PURE__*/e.jsx("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),/*#__PURE__*/e.jsx("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"})]}),ja=({style:t,...r})=>/*#__PURE__*/e.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",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),/*#__PURE__*/e.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"})]});function ka(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Ea=0;class Ta extends oa{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new i.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Yn(e)}}constructor(e,t,r,n,a){super(a||"unknown",e,t,r),this.connectorType="injected",this.proxyProvider=new sa(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=n;let i=n.provider;this.proxyProvider.setWalletProvider(i)}}var Aa="__private_"+Ea+++"__walletBranding";class Ia extends oa{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return ka(this,Aa)[Aa]??{name:"Browser Extension",icon:Ca,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new i.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Yn(e)}}constructor(e,t,r,n,a){super(a??"unknown",e,t,r),Object.defineProperty(this,Aa,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new sa(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(n),"metamask"===a?ka(this,Aa)[Aa]={name:"MetaMask",icon:ba,id:"io.metamask"}:"phantom"===a&&(ka(this,Aa)[Aa]={name:"Phantom",icon:ja,id:"phantom"})}}class Sa extends Ta{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{n.isMobile||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new i.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Yn(e)}}}const Pa=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","crypto.com_wallet_extension","crypto.com_onchain","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","privy","unknown","phantom","solflare","glow","backpack"],_a=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:je.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=Ma({client:this.client,isSolana:t,connectOnly:r});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${n}?ref=${n}`}},solflare:{client:"solflare",name:"Solflare",installLink:je.isFirefox?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=Ma({client:this.client,isSolana:t,connectOnly:r});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${n}?ref=${n}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcbcmnbpgliof",chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=Ma({client:this.client,isSolana:t,connectOnly:r});return`${e?"backpack://ul/v1/":"https://backpack.com/ul/v1/"}browse/${n}?ref=${n}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",chainTypes:["solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return"https://www.okx.com/download?deeplink="+encodeURIComponent("okx://wallet/dapp/url?dappUrl="+Ma({client:this.client,isSolana:e,connectOnly:t}))}}});function Na({connectorType:e,walletClientType:t}){for(let r of Pa)if(e===r||t===r)return _a[r]}function Ma({client:e,isSolana:t,connectOnly:r}){let n=new URL(window.location.href);return n.searchParams.set("privy_connector",t?"solana_adapter":"injected"),n.searchParams.set("privy_wallet_client",e),n.searchParams.set("privy_connect_only",String(r)),encodeURIComponent(n.href.replace(/\/$/g,""))}const Wa=()=>{let e=Nt.get(Tr);return e&&Array.isArray(e)&&e.map((e=>(e=>e&&"string"==typeof e.address&&"string"==typeof e.connectorType&&"string"==typeof e.walletClientType&&"number"==typeof e.connectedAt)(e))).every(Boolean)?e:[]};let Oa=["phantom","glow","solflare","backpack","okx_wallet"];function Ua(e){return"solana"===e.chainType}function Fa(e){return"solana"===e.type}class Ra extends ra{get isInstalled(){return"Installed"===this.adapter.readyState}buildConnectedWallet(e,t){let r,n,a,o;if("Installed"!==e.readyState||!e.publicKey)throw Error("Wallet is not connected.");return"signMessage"in e&&(r=async(...t)=>{if(!e.connected)throw Error("Wallet is not connected.");return await e.signMessage(t[0])}),"sendTransaction"in e&&(n=async(...t)=>await e.sendTransaction(t[0],t[1],t[2])),"signTransaction"in e&&(a=async t=>await e.signTransaction(t)),"signAllTransactions"in e&&(o=async t=>await e.signAllTransactions(t)),{type:"solana",address:e.publicKey.toBase58(),meta:t,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>e.connected,disconnect:()=>{try{e.disconnect()}catch(e){console.error("Wallet does not support programmatic disconnect")}},getProvider:i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:r??i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:n??i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:a??i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signTransaction'`),signAllTransactions:o??i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signAllTransactions'`)}}async syncAccounts(){if("Installed"===this.adapter.readyState&&this.adapter.publicKey){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find((e=>this.adapter.publicKey&&e.address===this.adapter.publicKey.toBase58()))||(this.wallets=[this.buildConnectedWallet(this.adapter,e)],this.emit("walletsUpdated"))}else this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"))}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAttemptAutoConnect()&&await this.adapter.autoConnect().catch((()=>{})),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}shouldAttemptAutoConnect(){return!(!this.autoConnectEnabled||!Oa.includes(this.walletClientType))&&("phantom"!==this.walletClientType||Wa().some((({walletClientType:e})=>"phantom"===e)))}constructor(e,t){super(function(e){return e.name.toLowerCase().split(" ").join("_")}(e)),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=()=>{this.adapter.disconnect().then((()=>this.onDisconnect())).catch((e=>console.error("Error disconnecting",e)))},this.promptConnection=async()=>{try{await this.adapter.connect()}catch(e){throw Yn(e)}},this.onDisconnect=()=>{this.syncAccounts()},this.onConnect=e=>{this.syncAccounts()},this.onError=e=>{this.syncAccounts()},this.onReadyStateChange=e=>{"Installed"!==e&&(this.connected=!1),this.syncAccounts()},this.adapter=e,this.autoConnectEnabled=t,this.wallets=[]}}class La extends Ra{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:r}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new sa(void 0,Ar),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=r}}const Da=b.create((()=>({listings:[]}))),Ba=Da.setState,za=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return Da.getState().listings.find((({homepage:e})=>{let r;try{r=new URL(e).hostname}catch(e){return!1}return t.includes(r)}))},$a=e=>Da((({listings:t})=>t.find((({slug:t})=>Va(t)===Va(e)))));function Va(e){return"cryptocom"===e?"cryptocom-defi":e.replace(/[-_]wallet$/,"")}function qa({src:t,...r}){/*#__PURE__*/return e.jsx("img",{src:t,...r,style:{display:"none"}})}const Ha={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",externalWallets:{coinbaseWallet:{connectionOptions:"all"}},embeddedWallets:{extendedCalldataDecoding:!1},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};let Ka=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","ronin_wallet","haha_wallet","wallet_connect","detected_wallets","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe","solflare","backpack"]),Za=e=>Ka.has(e),Ga=(e,t,r)=>r.indexOf(e)===t;function Ya(e){let t=e.filter((e=>!Kn.has(e.id)));return Hn.concat(t)}function Ja(e,t){return{...e,rpcUrls:{...e.rpcUrls,privy:{http:[t]}}}}const Xa=792703809,Qa="11111111111111111111111111111111";function ei(e){return e.includes("testnet")?"testnet":e.includes("devnet")?"devnet":"mainnet-beta"}function ti(e,t){return`https://explorer.solana.com/account/${e}?cluster=${t}`}let ri="#FFFFFF";function ni(e,t){let r=Math.max(0,Math.min(1,e.toHsl().l+t));return Te.default({...e.toHsl(),l:r})}function ai({backgroundTheme:e,accentHex:t}){let r;switch(e){case"light":r=ri;break;case"dark":r="#1E1E1D";break;default:r=e}let n=Te.default(r),a=Te.default(t),i=Te.default("#51BA81"),o=Te.default("#FFB74D"),s=Te.default("#EC6351"),l=function(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"}(n.getLuminance()),c=ni(n,"light"===l?-.04:.11),d=ni(n,"light"===l?-.08:.16),u=ni(n,"light"===l?-.88:.87),p=ni(n,"light"===l?-.7:.75),h=ni(n,"light"===l?-.43:.45).desaturate("light"===l?60:20),m=ni(n,"light"===l?-.08:.25).desaturate("light"===l?60:20),y=ni(a,.15),f=ni(a,.25),g=ni(a,-.06),w=ni(a,-.6),v=ni(s,.3),x=ni(o,.3),C=Te.default(a.getLuminance()>.5?"#040217":ri),b=ni(i,-.16),j=ni(i,.4);return{colorScheme:l,background:n.toHslString(),background2:c.toHslString(),background3:d.toHslString(),foreground:u.toHslString(),foreground2:p.toHslString(),foreground3:h.toHslString(),foreground4:m.toHslString(),accent:a.toHslString(),accentLight:y.toHslString(),accentLightest:f.toHslString(),accentDark:g.toHslString(),accentDarkest:w.toHslString(),foregroundAccent:C.toHslString(),success:i.toHslString(),successDark:b.toHslString(),successLight:j.toHslString(),error:s.toHslString(),errorLight:v.toHslString(),warn:o.toHslString(),warnLight:x.toHslString()}}function ii(e,t,r,n){let a,i,o,s,l,c,d,u,p,h,m,y,f,g,w,v=r?console.warn:()=>{};t?.loginMethods?(a=t.loginMethods.includes("email"),i=t.loginMethods.includes("sms"),s=t.loginMethods.includes("wallet"),l=t.loginMethods.includes("google"),c=t.loginMethods.includes("twitter"),d=t.loginMethods.includes("discord"),p=t.loginMethods.includes("spotify"),h=t.loginMethods.includes("instagram"),u=t.loginMethods.includes("tiktok"),y=t.loginMethods.includes("github"),m=t.loginMethods.includes("linkedin"),f=t.loginMethods.includes("apple"),g=t.loginMethods.includes("farcaster"),w=t.loginMethods.includes("telegram"),o=t.loginMethods.includes("passkey")):(a=e.emailAuth,i=e.smsAuth,s=e.walletAuth||e.solanaWalletAuth,l=e.googleOAuth,c=e.twitterOAuth,d=e.discordOAuth,y=e.githubOAuth,p=e.spotifyOAuth,h=e.instagramOAuth,u=e.tiktokOAuth,m=e.linkedinOAuth,f=e.appleOAuth,g=e.farcasterAuth,w=e.telegramAuth,o=e.passkeyAuth),e.passkeyAuth&&(o=!0),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(o=!1);let x=[a,i].filter(Boolean),C=[l,c,d,y,p,h,u,m,f,g,w].filter(Boolean),b=[s].filter(Boolean),j=t?.loginMethods?.includes("passkey")??!1,k=e.passkeysForSignupEnabled??!1,E=[o&&(k||j)].filter(Boolean);if(x.length+C.length+b.length+E.length===0)throw Error("You must enable at least one login method");let T=void 0!==t?.appearance?.showWalletLoginFirst?t?.appearance?.showWalletLoginFirst:e.showWalletLoginFirst;T&&0===b.length?(v("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),T=!1):T||C.length+x.length!==0||(v("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),T=!0);let A=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&v("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let I=(({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(Za).filter(Ga):e?e.filter(Za).filter(Ga):Ha.appearance.walletList)({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),S=(({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],r=[];for(let r of(e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`"),e.primary.slice(1)))t.includes(r)?console.warn(`Duplicated login method: ${r}`):t.push(r);for(let n of e.overflow??[])t.includes(n)||r.includes(n)?console.warn(`Duplicated login method: ${n}`):r.push(n);return{primary:t,overflow:r}})({input:t?.loginMethodsAndOrder}),P=t?.intl?.defaultCountry??"US",{chains:_,defaultChain:N}=function({supportedChains:e,defaultChainFromConfig:t}){let r;if(e){if(0===e.length)throw Error("`supportedChains` must contain at least one chain");r=e.map((e=>{if(e.rpcUrls.privyWalletOverride)return e;let t=Hn.find((t=>t.id===e.id)),r=t?.rpcUrls.privy?.http[0];return r?Ja(e,r):e}))}else r=[...Hn];let n=e?r[0]:Ln,a=t??n;if(!r.find((e=>e.id===a.id)))throw Error("`defaultChain` must be included in `supportedChains`");return{chains:r,defaultChain:a}}({supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain}),M=!!t?.defaultChain,W=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,O=t?.embeddedWallets?.requireUserPasswordOnCreate,U=t?.embeddedWallets?.createOnLogin,F=W?"all-users":e.embeddedWalletConfig.ethereum.createOnLogin,R=e.embeddedWalletConfig.solana.createOnLogin,L=t?.solanaClusters??[];return e.solanaWalletAuth&&!t?.externalWallets?.solana?.connectors&&console.warn("App configuration has Solana wallet login enabled, but no Solana wallet connectors have been passed to Privy. Make sure to pass Solana connectors to the `config.externalWallets.solana.connectors` field of the `PrivyProvider`"),{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,legacyWalletUiConfig:e.legacyWalletUiConfig,appearance:{logo:t?.appearance?.logo??e.logoUrl,landingHeader:t?.appearance?.landingHeader??Ha.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:ai({backgroundTheme:t?.appearance?.theme??Ha.appearance.theme,accentHex:t?.appearance?.accentColor??e.accentColor??Ha.appearance.accentColor}),loginGroupPriority:T?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:I,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.walletAuth??!1,solanaWalletAuth:e.solanaWalletAuth??!1})},loginMethods:{wallet:s,email:a,sms:i,passkey:o,google:l,twitter:c,discord:d,github:y,spotify:p,instagram:h,tiktok:u,linkedin:m,apple:f,farcaster:g,telegram:w},disablePlusEmails:e.disablePlusEmails,loginMethodsAndOrder:S,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.termsAndConditionsUrl,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacyPolicyUrl,requireUsersAcceptTerms:e.requireUsersAcceptTerms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.walletConnectCloudProjectId??Ha.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:{}},chains:_,solanaClusters:{"mainnet-beta":L.find((e=>"mainnet-beta"===e.name))?.rpcUrl||"https://api.mainnet-beta.solana.com",testnet:L.find((e=>"testnet"===e.name))?.rpcUrl||"https://api.testnet.solana.com",devnet:L.find((e=>"devnet"===e.name))?.rpcUrl||"https://api.devnet.solana.com"},defaultChain:N,intl:{defaultCountry:P},shouldEnforceDefaultChainOnConnect:M,captchaEnabled:e.captchaEnabled??Ha.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??Ha.externalWallets.coinbaseWallet.connectionOptions},walletConnect:{enabled:A},solana:{connectors:t?.externalWallets?.solana?.connectors}},embeddedWallets:{requireUserOwnedRecoveryOnCreate:O??(!W&&e.embeddedWalletConfig.requireUserOwnedRecoveryOnCreate),userOwnedRecoveryOptions:W?["user-passcode"]:e.embeddedWalletConfig.userOwnedRecoveryOptions,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:U??t?.embeddedWallets?.ethereum?.createOnLogin??F},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??R},showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforceWalletUis??!0,extendedCalldataDecoding:t?.embeddedWallets?.extendedCalldataDecoding??!1,transactionScanning:{enabled:t?.embeddedWallets?.transactionScanning?.enabled??!1,domain:t?.embeddedWallets?.transactionScanning?.domain??n??"https://auth.privy.io"}},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink},customAuth:W?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:e.telegramAuthConfiguration,passkeysForSignupEnabled:e.passkeysForSignupEnabled},headless:!!t?.headless,render:{standalone:t?._render?.standalone??Ha._render.standalone},fundingConfig:e.fundingConfig,fundingMethodConfig:{...t?.fundingMethodConfig??Ha.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??Ha.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??Ha.fundingMethodConfig.moonpay.useSandbox}}}}let oi={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,linkedinOAuth:!1,appleOAuth:!1,disablePlusEmails:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{ethereum:{createOnLogin:"off"},solana:{createOnLogin:"off"},requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]},fiatOnRampEnabled:!1,captchaEnabled:!1,captchaSiteKey:"",enforceWalletUis:!1,legacyWalletUiConfig:!1};const si=ii(oi,void 0,!1);let li=/*#__PURE__*/r.createContext({appConfig:si,isServerConfigLoaded:!1});const ci=({children:t,client:n,clientConfig:a})=>{let[i,o]=r.useState(null),s=r.useMemo((()=>ii(i??oi,a,!!i,"undefined"!=typeof window?window.location.origin:void 0)),[i,a]);return r.useEffect((()=>{if(!i)return;let e=function(e){if(!e)return{};let{appearance:t,supportedChains:r,defaultChain:n,externalWallets:a,...i}=e;return{...i,...r?{supportedChains:r.map((e=>e.id))}:void 0,...n?{defaultChain:n.id}:void 0,...a?{walletConnect:a.walletConnect,coinbaseWallet:a.coinbaseWallet,solana:{connectors:a.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0}}(a),t=function(e,t=0){let r=3735928559^t,n=1103547991^t;for(let t,a=0;a<e.length;a++)r=Math.imul(r^(t=e.charCodeAt(a)),2654435761),n=Math.imul(n^t,1597334677);return r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&(n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909)))+(r>>>0)}(JSON.stringify(e)).toString(),r=`privy:sent:${i.id}:${t}`;localStorage.getItem(r)||(n.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(r,"t"))}),[a,i]),r.useEffect((()=>{i||(async()=>{try{let e=await n.getServerConfig();e.customApiUrl&&n.updateApiUrl(e.customApiUrl),o(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),/*#__PURE__*/e.jsx(li.Provider,{value:{appConfig:s,isServerConfigLoaded:!!i},children:t})},di=()=>{let{appConfig:e}=r.useContext(li);return e},ui=()=>{let{isServerConfigLoaded:e}=r.useContext(li);return e};function pi(t){/*#__PURE__*/return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 460 40",...t,children:/*#__PURE__*/e.jsx("g",{fill:t.color||"var(--privy-color-foreground)",children:/*#__PURE__*/e.jsx("path",{d:"M0 15.4v15.38h4.64V19.96h3.58c2.47 0 3.63-.01 3.77-.02 1-.08 1.49-.15 2.18-.3a9.45 9.45 0 0 0 4.6-2.37c1.66-1.57 2.64-3.87 2.81-6.56.02-.3.02-1.19 0-1.49-.1-1.77-.56-3.35-1.36-4.72A8.84 8.84 0 0 0 15.14.57c-.93-.3-1.75-.43-3.09-.54C11.9.02 10.2 0 5.93 0H0ZM10.85 4c1.85.05 3.1.45 4.16 1.3.22.17.54.49.69.68a5.97 5.97 0 0 1 1.19 3.13c.04.35.04 1.36 0 1.71-.08.68-.23 1.3-.44 1.85a4.8 4.8 0 0 1-1.09 1.68A5.63 5.63 0 0 1 12 15.92c-.6.08-.4.08-4.01.09H4.64V3.98h2.9c1.6 0 3.08 0 3.31.02ZM187.65 5.71v5.72h-.27l-.09-.14a15.9 15.9 0 0 0-1.21-1.73c-.43-.5-1-.95-1.7-1.36-.54-.3-1.05-.5-1.73-.63a8.98 8.98 0 0 0-1.7-.17 8.84 8.84 0 0 0-7.8 4.03 12.95 12.95 0 0 0-2.03 6.39c-.07.98-.06 2.15.02 3.13.2 2.47.87 4.53 2.02 6.25a8.98 8.98 0 0 0 10.22 3.65 6.5 6.5 0 0 0 2.8-1.93c.41-.51.84-1.1 1.1-1.55l.1-.17h.37v3.58h4.38V0h-4.48Zm-5.24 5.54c1.3.14 2.3.6 3.17 1.48.9.9 1.5 2.09 1.85 3.64.36 1.6.39 3.72.06 5.43a8.13 8.13 0 0 1-1.54 3.62 5.1 5.1 0 0 1-3.93 1.96 6.13 6.13 0 0 1-2.32-.31 5.87 5.87 0 0 1-3.33-3.5c-.39-1-.62-2.05-.72-3.32-.03-.32-.04-1.35-.02-1.73.08-1.56.4-2.91.96-4.05a6.2 6.2 0 0 1 1.06-1.58 5.08 5.08 0 0 1 3.6-1.66c.25-.02.9 0 1.16.02ZM210.07 15.39l.01 15.38h4.38l.01-3.57h.37l.09.15c.24.44.84 1.26 1.21 1.7a6.79 6.79 0 0 0 2.57 1.75 9.3 9.3 0 0 0 6.86-.49 9.28 9.28 0 0 0 4.05-4.07A13.05 13.05 0 0 0 231 21.6c.21-1.73.18-3.7-.09-5.32a13.03 13.03 0 0 0-1.5-4.3 9.1 9.1 0 0 0-3.75-3.63 9.15 9.15 0 0 0-4.43-.96 7.46 7.46 0 0 0-2.8.5A7.07 7.07 0 0 0 216 9.7c-.4.52-.82 1.12-1.1 1.59l-.07.14h-.27V0h-4.5Zm11.13-4.14c1.07.1 1.94.44 2.7 1.04a6.1 6.1 0 0 1 1.64 1.98c.43.84.78 2 .94 3.11.15 1.16.16 2.4.02 3.54a9.34 9.34 0 0 1-1.39 4.03 5.33 5.33 0 0 1-2.69 2.15c-.9.3-2.04.38-3.06.2a5.14 5.14 0 0 1-3.45-2.37 6.03 6.03 0 0 1-.45-.8c-.5-1.03-.8-2.2-.92-3.58-.04-.49-.06-.89-.05-1.53.01-.76.05-1.23.13-1.85.38-2.53 1.47-4.38 3.15-5.31a5.46 5.46 0 0 1 2.3-.63 10 10 0 0 1 1.13.02ZM69.05 2.17l-.01 2.77V7.7h-3.36v3.6h3.36v6.8l.01 7.15c.06 1.4.4 2.44 1.1 3.37a5.8 5.8 0 0 0 2.97 2.07c.91.3 1.83.42 2.9.38a8.71 8.71 0 0 0 2.66-.48l-.8-3.7-.38.06a4.96 4.96 0 0 1-2.43-.06c-.33-.1-.56-.25-.8-.49-.4-.41-.6-.88-.7-1.67-.02-.2-.02-.62-.03-6.82v-6.6h4.73V7.7h-4.73V2.16h-4.49ZM133.34 2.17V7.7h-3.39v3.6h3.38v6.9l.01 7.17a5.66 5.66 0 0 0 2.36 4.49c.85.6 2.03 1.03 3.26 1.17.85.1 2.03.05 2.81-.1.3-.06.75-.18 1-.26l.2-.06v-.05l-.81-3.67-.37.06a4.99 4.99 0 0 1-1.8.09c-.85-.13-1.32-.4-1.7-.97a2.63 2.63 0 0 1-.39-1.04c-.06-.4-.06 0-.06-7.1V11.3h4.7V7.7h-4.7l-.01-2.77V2.16h-4.49ZM293.41 2.36a14.56 14.56 0 0 0-13.7 16.07 14.59 14.59 0 0 0 21.86 11.08 14.5 14.5 0 0 0 7.11-14.07 14.61 14.61 0 0 0-6.53-10.73 14.49 14.49 0 0 0-8.74-2.35ZM350.8 2.36a10.17 10.17 0 0 0-7.56 4.2c-.16.2-.45.63-.58.83l-.05.1h-.47l-.01-4.36h-7.36v36.4h7.82V27.27h.49l.05.07a11.3 11.3 0 0 0 7.49 4.15 10.52 10.52 0 0 0 9.38-4.1c1.66-2.1 2.73-4.9 3.07-8.06.1-.87.13-1.4.13-2.37 0-.8 0-1.1-.07-1.76a15.95 15.95 0 0 0-3.23-8.72 12.8 12.8 0 0 0-1.85-1.84 10.49 10.49 0 0 0-7.26-2.28Zm-.94 6.05c1.27.15 2.33.65 3.2 1.5.98.96 1.67 2.31 2.03 4 .34 1.57.38 3.68.12 5.39a9.78 9.78 0 0 1-1.04 3.25c-.14.25-.44.69-.6.89a5.35 5.35 0 0 1-4.31 2.07 5.25 5.25 0 0 1-4.41-1.9 7.35 7.35 0 0 1-1.26-2.32 14.09 14.09 0 0 1-.62-4.83c.05-1.98.38-3.53 1.02-4.85a5.63 5.63 0 0 1 2.5-2.65c.66-.34 1.3-.5 2.14-.58.18-.02 1.04 0 1.23.03ZM363.63 3.1l-.01 3.2v3.16h1.43c1.26.01 1.44.02 1.54.04.42.09.66.28.79.62.08.23.08.08.08 2.96a911.57 911.57 0 0 1 .03 10.18v7.54h7.82v-7.4l.01-7.83c.03-.94.11-1.63.27-2.28.46-1.9 1.54-2.93 3.35-3.23.52-.08.2-.08 5-.08h4.4V3.08h-3.1c-3.48 0-3.91.01-4.67.1-1.83.2-3.04.79-3.96 1.88-.5.6-.9 1.32-1.26 2.26l-.06.17h-.46V3.09h-5.6c-4.46 0-5.6 0-5.6.02ZM390.8 16.95V30.8h3.87l3.86-.01V3.09h-7.73ZM400.6 3.1l-.01.4v.38l4.66 13.4 4.69 13.47.02.05h10.3l.03-.05 4.67-13.45 4.67-13.4V3.1h-7.43l-6.7 19.26h-.5l-3.28-9.5-3.31-9.64-.05-.12h-3.88l-3.88.01ZM430.98 3.1c-.01 0-.02.19-.02.4v.39l5.08 14.59c2.8 8.02 5.08 14.6 5.08 14.61.01.02-.22.02-4.8.02h-4.82v6.42h4.95c5.09 0 5.23 0 5.87-.06 3.15-.28 5.29-1.63 6.63-4.15.28-.55.44-.95.87-2.16L459 6.78l1-2.89v-.8h-7.43l-6.69 19.26h-.5l-3.27-9.46-3.31-9.64-.06-.16h-3.88l-3.88.01ZM36.57 7.36c-1.36.1-2.6.6-3.62 1.45a5.65 5.65 0 0 0-1.67 2.42l-.05.13H31V7.7h-4.35v23.08h4.5v-7.3c0-8 0-7.34.08-7.82a4.89 4.89 0 0 1 2.06-3.18c.83-.58 1.74-.89 2.87-.98a11.87 11.87 0 0 1 2.8.25H39v-4.3l-.21-.02c-.61-.07-1.74-.1-2.22-.07ZM51.08 7.41c-2.33.12-4.3.84-5.95 2.16a9.89 9.89 0 0 0-2.03 2.2 12.5 12.5 0 0 0-2 5.78 18.04 18.04 0 0 0 0 3.65 12.13 12.13 0 0 0 2.26 6.05 9.74 9.74 0 0 0 5 3.52c2.11.64 4.7.64 6.8 0a9.78 9.78 0 0 0 4.88-3.37c1.38-1.78 2.19-4 2.4-6.58.13-1.46.06-3.06-.18-4.42a11.24 11.24 0 0 0-3.58-6.6 10 10 0 0 0-5.75-2.35c-.56-.06-1.31-.07-1.85-.04Zm1.42 3.78c.88.1 1.62.34 2.28.75a6.13 6.13 0 0 1 1.99 2.15 10.31 10.31 0 0 1 1.2 5c.02 1.23-.12 2.44-.42 3.51a7.14 7.14 0 0 1-1.81 3.32c-.61.6-1.2.98-1.95 1.24a6 6 0 0 1-2 .3 5.7 5.7 0 0 1-2.72-.6 5 5 0 0 1-1.28-.94A7.1 7.1 0 0 1 46 22.73c-.57-1.99-.6-4.46-.08-6.5a7.24 7.24 0 0 1 2.03-3.67 5.13 5.13 0 0 1 3.35-1.4 11 11 0 0 1 1.2.03ZM92.05 7.4c-.96.06-1.56.15-2.3.33a9.62 9.62 0 0 0-6.09 4.66 13.5 13.5 0 0 0-1.71 7c0 .83 0 1.04.06 1.6.16 1.77.58 3.32 1.29 4.7A9.72 9.72 0 0 0 90.28 31c1.84.37 4.08.32 5.85-.13a9.07 9.07 0 0 0 5.02-3.1A7.64 7.64 0 0 0 102.5 25l-2.11-.39-2.11-.38-.08.13a4.72 4.72 0 0 1-2.35 2.55 6.3 6.3 0 0 1-2.23.58c-.29.03-1.13.03-1.44 0a6.35 6.35 0 0 1-3.02-1.04 5.93 5.93 0 0 1-2.02-2.43 8.44 8.44 0 0 1-.72-3.18v-.26h16.38v-.81c0-1.83-.06-2.76-.25-3.87-.2-1.22-.53-2.24-1.05-3.28a8.9 8.9 0 0 0-2.66-3.26 10.1 10.1 0 0 0-5.34-1.94 18.3 18.3 0 0 0-1.46-.03Zm1.3 3.75c1.2.13 2.19.55 3.05 1.3a5.8 5.8 0 0 1 1.78 2.96c.13.51.21 1.17.21 1.66v.15H86.43v-.12c.08-.97.3-1.78.72-2.61.5-1 1.2-1.8 2.14-2.42a5.32 5.32 0 0 1 2.9-.95c.2-.01.97 0 1.17.03ZM116.79 7.41c-2 .1-3.73.65-5.22 1.65a10.7 10.7 0 0 0-4.25 6.06 16.1 16.1 0 0 0-.5 5.8c.2 2.17.84 4.13 1.88 5.76.58.9 1.32 1.73 2.15 2.4a9.37 9.37 0 0 0 3.6 1.8 12.06 12.06 0 0 0 3.92.34 10.2 10.2 0 0 0 3.84-.95 8.31 8.31 0 0 0 4.76-6.75l.01-.04h-4.37l-.05.16a4.87 4.87 0 0 1-4.24 3.75c-.59.07-1.32.06-1.93-.05a5.47 5.47 0 0 1-3.5-2.27c-.56-.75-1-1.73-1.26-2.79a13.8 13.8 0 0 1-.16-5.24 7.77 7.77 0 0 1 2.1-4.3 5.48 5.48 0 0 1 2.15-1.3 6.4 6.4 0 0 1 3.89.1c.59.21 1.03.5 1.5.96a5.32 5.32 0 0 1 1.46 2.5l.04.15h4.37v-.06a8.22 8.22 0 0 0-5.31-6.94 10.98 10.98 0 0 0-4.88-.74ZM156.2 7.41a9.87 9.87 0 0 0-6 2.29 11.02 11.02 0 0 0-3.41 5.43c-.52 1.78-.68 3.9-.48 5.97.17 1.8.63 3.38 1.37 4.8a9.68 9.68 0 0 0 5.91 4.86c1.65.48 3.63.61 5.53.36 3.72-.49 6.55-2.62 7.56-5.69.12-.39.13-.42.1-.43-.02 0-4.13-.75-4.19-.75-.03 0-.04 0-.1.16-.18.42-.45.9-.72 1.22-.16.2-.49.53-.7.7-.67.54-1.5.9-2.43 1.08-.48.08-.83.11-1.41.11-.64 0-1.07-.04-1.6-.15a5.76 5.76 0 0 1-3.93-2.83 8 8 0 0 1-.99-3.79v-.16h16.38v-1.11l-.02-1.43c-.1-2.25-.53-4-1.35-5.59a9.24 9.24 0 0 0-6.18-4.75c-1.04-.26-2.2-.36-3.33-.3Zm1.45 3.74a5.35 5.35 0 0 1 3.66 1.94 6.1 6.1 0 0 1 1.38 4.01v.12h-11.97v-.06c0-.02 0-.14.02-.25a6.6 6.6 0 0 1 2.15-4.32 5.73 5.73 0 0 1 3.5-1.46c.25-.02 1 0 1.26.02ZM233.58 7.82l8.37 23.22a49.22 49.22 0 0 1-.67 1.9 5.36 5.36 0 0 1-1.14 1.8c-.41.4-.82.58-1.48.69-.27.04-1.03.03-1.35 0a8.05 8.05 0 0 1-1.1-.23l-1.08 3.67c0 .02.32.14.66.22.83.21 1.57.29 2.56.28.56-.01.8-.03 1.24-.1 2.71-.4 4.66-2.09 5.86-5.08l9.64-26.44c0-.02-4.82-.06-4.83-.05l-2.93 8.96-2.91 8.94h-.24l-.22-.65-2.91-8.95-2.7-8.3H233.53ZM293.05 35.8c-1.18.04-1.93.09-2.8.16-2.52.24-4.53.69-5.43 1.23-.7.41-.76.86-.2 1.28.88.66 3.29 1.19 6.36 1.4a48.55 48.55 0 0 0 5.75.05c3.47-.19 6.24-.78 7.11-1.5.22-.19.3-.34.3-.53 0-.1 0-.12-.04-.22-.35-.69-2.32-1.3-5.25-1.63a41.09 41.09 0 0 0-5.8-.24Zm0 0"})})})}let hi=/*#__PURE__*/h.styled.div.withConfig({displayName:"TermsAndConditionsContainer",componentId:"sc-bdb69ecc-0"})(["margin-top:16px;font-size:13px;text-align:center;color:var(--privy-color-foreground-3);&& > a{color:var(--privy-color-accent);}"]);function mi({app:{legal:{privacyPolicyUrl:t,termsAndConditionsUrl:r,requireUsersAcceptTerms:n}},alwaysShowImplicitConsent:a}){let i=!(!t||!r);return n&&!a||!r&&!t?
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("mipd"),r=require("react"),n=require("react-device-detect"),a=require("viem/utils"),i=require("./internal-context-HesndSYh.js"),o=require("viem"),s=require("uuid"),l=require("jose"),c=require("eventemitter3"),d=require("@coinbase/wallet-sdk"),u=require("@privy-io/js-sdk-core"),p=require("@marsidev/react-turnstile"),h=require("styled-components"),m=require("tinycolor2"),y=require("@heroicons/react/24/outline/ArrowLeftIcon"),f=require("@heroicons/react/24/outline/ArrowRightIcon"),g=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),w=require("@heroicons/react/24/outline/XMarkIcon"),v=require("@heroicons/react/24/outline/CheckIcon"),x=require("@heroicons/react/24/outline/Square2StackIcon"),C=require("@heroicons/react/24/outline/WalletIcon"),b=require("zustand"),j=require("@walletconnect/ethereum-provider"),k=require("@heroicons/react/24/outline/UserCircleIcon"),E=require("@heroicons/react/24/outline/EnvelopeIcon"),T=require("@heroicons/react/20/solid/CheckIcon"),A=require("@heroicons/react/24/outline/PhoneIcon"),I=require("@heroicons/react/24/outline/ExclamationTriangleIcon"),S=require("@heroicons/react/24/outline/ExclamationCircleIcon"),P=require("@heroicons/react/24/outline/ArrowTopRightOnSquareIcon"),_=require("@heroicons/react/24/solid/DocumentCheckIcon"),N=require("@heroicons/react/24/solid/XCircleIcon"),M=require("fast-password-entropy"),W=require("secure-password-utilities"),O=require("secure-password-utilities/wordlists"),U=require("@heroicons/react/24/outline/LockClosedIcon"),F=require("@heroicons/react/24/outline/PencilSquareIcon"),R=require("@heroicons/react/24/solid/CheckCircleIcon"),L=require("@heroicons/react/24/outline/ArrowPathIcon"),D=require("@heroicons/react/24/outline/EyeIcon"),B=require("@heroicons/react/24/outline/EyeSlashIcon"),z=require("@heroicons/react/24/outline/KeyIcon"),$=require("@heroicons/react/24/outline/ArrowDownTrayIcon"),V=require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),q=require("@heroicons/react/24/outline/DocumentDuplicateIcon"),H=require("@heroicons/react/24/solid/LockClosedIcon"),K=require("@heroicons/react/24/outline/ShieldCheckIcon"),Z=require("qrcode"),G=require("@heroicons/react/24/outline/FingerPrintIcon"),Y=require("@heroicons/react/24/outline/ChevronRightIcon"),J=require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),X=require("@heroicons/react/24/outline/ChevronDownIcon"),Q=require("@heroicons/react/24/outline/CalendarIcon"),ee=require("@headlessui/react"),te=require("@heroicons/react/24/outline/CheckCircleIcon"),re=require("@heroicons/react/24/outline/InformationCircleIcon"),ne=require("@heroicons/react/24/outline/CreditCardIcon"),ae=require("@heroicons/react/24/outline/QrCodeIcon"),ie=require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),oe=require("@heroicons/react/24/outline/GlobeAltIcon"),se=require("ofetch"),le=require("@heroicons/react/24/outline"),ce=require("@heroicons/react/24/outline/ClipboardDocumentIcon"),de=require("@heroicons/react/24/outline/CloudArrowUpIcon"),ue=require("@heroicons/react/24/outline/NoSymbolIcon"),pe=require("@heroicons/react/24/outline/ClockIcon"),he=require("@heroicons/react/24/outline/TrashIcon"),me=require("@heroicons/react/24/solid/CheckBadgeIcon"),ye=require("@heroicons/react/24/solid/IdentificationIcon"),fe=require("@heroicons/react/24/outline/MinusCircleIcon"),ge=require("@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon"),we=require("@heroicons/react/24/solid/ShieldCheckIcon"),ve=require("js-cookie");function xe(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function Ce(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var be=/*#__PURE__*/xe(r),je=/*#__PURE__*/Ce(n),ke=/*#__PURE__*/Ce(l),Ee=/*#__PURE__*/xe(c),Te=/*#__PURE__*/xe(m),Ae=/*#__PURE__*/xe(y),Ie=/*#__PURE__*/xe(f),Se=/*#__PURE__*/xe(g),Pe=/*#__PURE__*/xe(w),_e=/*#__PURE__*/xe(v),Ne=/*#__PURE__*/xe(x),Me=/*#__PURE__*/xe(C),We=/*#__PURE__*/xe(k),Oe=/*#__PURE__*/xe(E),Ue=/*#__PURE__*/xe(T),Fe=/*#__PURE__*/xe(A),Re=/*#__PURE__*/xe(I),Le=/*#__PURE__*/xe(S),De=/*#__PURE__*/xe(P),Be=/*#__PURE__*/xe(_),ze=/*#__PURE__*/xe(N),$e=/*#__PURE__*/xe(M),Ve=/*#__PURE__*/Ce(W),qe=/*#__PURE__*/xe(U),He=/*#__PURE__*/xe(F),Ke=/*#__PURE__*/xe(R),Ze=/*#__PURE__*/xe(L),Ge=/*#__PURE__*/xe(D),Ye=/*#__PURE__*/xe(B),Je=/*#__PURE__*/xe(z),Xe=/*#__PURE__*/xe($),Qe=/*#__PURE__*/xe(V),et=/*#__PURE__*/xe(q),tt=/*#__PURE__*/xe(H),rt=/*#__PURE__*/xe(K),nt=/*#__PURE__*/xe(Z),at=/*#__PURE__*/xe(G),it=/*#__PURE__*/xe(Y),ot=/*#__PURE__*/xe(J),st=/*#__PURE__*/xe(X),lt=/*#__PURE__*/xe(Q),ct=/*#__PURE__*/xe(te),dt=/*#__PURE__*/xe(re),ut=/*#__PURE__*/xe(ne),pt=/*#__PURE__*/xe(ae),ht=/*#__PURE__*/xe(ie),mt=/*#__PURE__*/xe(oe),yt=/*#__PURE__*/xe(ce),ft=/*#__PURE__*/xe(de),gt=/*#__PURE__*/xe(ue),wt=/*#__PURE__*/xe(pe),vt=/*#__PURE__*/xe(he),xt=/*#__PURE__*/xe(me),Ct=/*#__PURE__*/xe(ye),bt=/*#__PURE__*/xe(fe),jt=/*#__PURE__*/xe(ge),kt=/*#__PURE__*/xe(we),Et=/*#__PURE__*/xe(ve);class Tt{async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(i.customJwtAccountAuthenticatePath,{token:this.meta.token})}catch(e){throw i.formatApiError(e)}}async link(){throw Error("Unimplemented")}constructor(e){this.meta={token:e}}}function At(e){return e?{"privy-ui":"t"}:void 0}class It{async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new i.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(i.passwordlessAuthenticatePath,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new i.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(i.passwordlessLinkPath,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw i.formatApiError(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new i.PrivyClientError("Email must be set when initialzing authentication.");let n=At(r);try{return await this.api.post(i.passwordlessInitPath,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw i.formatApiError(e)}}constructor({email:e,captchaToken:t,disableSignup:r}){this.meta={email:e,captchaToken:t,disableSignup:r??!1}}}class St extends It{async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new i.PrivyClientError("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(i.updateEmailPath,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw i.formatApiError(e)}}constructor(e,t,r){super({email:t,captchaToken:r}),this.meta={email:t,captchaToken:r,oldAddress:e,disableSignup:!1}}}class Pt{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e)}del(e){localStorage.removeItem(e)}getKeys(){return Object.entries(localStorage).map((([e])=>e))}}function _t(){try{let e="privy:__session_storage__test",t=new Pt;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var Nt="undefined"!=typeof window&&window.localStorage?new Pt:new class{get(e){return this._cache[e]}put(e,t){void 0!==t?this._cache[e]=t:this.del(e)}del(e){delete this._cache[e]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};const Mt=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom||"isPhantom"in e?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,Wt=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==Mt(e))return!1;if(e.providers)for(let t of e.providers)if(!Wt(t))return!1;return!0},Ot=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers)for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0;return!1},Ut=(e,t,r,n)=>{let a=Number(e),s=t.find((e=>e.id===a));if(!s)throw new i.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return o.createPublicClient({transport:o.http(Ft(s,r,n.appId)),chain:s})},Ft=(e,t,r)=>{let n,a=e.id,o=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])n=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[o])n=t.rpcUrls[o];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",r),n=t.toString()}else n=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!n)throw new i.PrivyConnectorError(`No RPC url found for ${a}`);return n},Rt=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,}))$/),Lt=(e,t=3,r=4,n="ethereum")=>{if(!e)return"";let a="ethereum"===n?2:0;return t+r+a+3>=e.length?e:`${e.slice(0,a+t)}...${e.slice(e.length-r,e.length)}`},Dt=(e,t=3,r=4)=>Lt(e,t,r,"solana"),Bt=e=>new Promise((t=>setTimeout(t,e)));const zt=(e,t={})=>{let r=t.delayMs||150,n=t.maxAttempts||270;return new Promise((async(a,i)=>{let o=!1,s=0;for(;!o&&s<n;){if(t.abortSignal?.aborted)return;e().then((e=>{o=!0,a(e)}),((...e)=>{o=!0,i(...e)})),s+=1,await Bt(r)}o||i(Error("Exceeded max attempts before resolving function"))}))},$t=(e,t,r={},n={})=>{let a=new URL(t,e);for(let[e,t]of Object.entries(r))void 0!==t&&a.searchParams.set(e,t);let i=Object.entries(n);if(i.length>0){let e=new URLSearchParams;for(let[t,r]of i)e.append(t,r);a.hash=e.toString()}return a.href},Vt=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),qt=e=>"string"==typeof e?e:"0x"+e.toString(16);async function Ht({store:e,walletList:t,externalWalletConfig:r,walletChainType:n,timeout:a=3e3}){let i=!1,o=window;return new Promise((s=>{function l(){if(i)return;i=!0,window.removeEventListener("ethereum#initialized",l);let a=e.getProviders();console.debug("Detected injected providers:",a.map((e=>e.info)));let o=[];for(let e of a)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===n&&"app.phantom"===e.info.rdns||o.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==n)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let e of t.providers)e&&r.push(e);return r.push(e.ethereum),r}()){let t=Mt(e);if(!a.some((e=>e.info.name===t))){if(Wt(e,!0)&&!o.find((e=>"metamask"===e.type))){o.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!o.find((e=>"phantom"===e.type))){o.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!o.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==r.coinbaseWallet?.connectionOptions))){o.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}o.find((e=>"unknown_browser_extension"===e.type))||o.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}s(o)}o.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout((()=>{l()}),a))}))}function Kt(e){return`eip155:${String(Number(e))}`}const Zt=(e,t,r,n)=>{let a=Number(e),o=t.find((e=>e.id===a));if(!o)throw new i.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return Ft(o,r,n)},Gt=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map((([e,r])=>{if(null!=r&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:r}}};const Yt=["c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96","4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0","225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f","1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369","c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a","ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18","bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6","74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d","afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7","f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d","84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04","0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150","38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662","9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0","c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576","8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4","e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4","f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2","138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98","47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83","7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26","8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3","031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa","2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568","dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd","2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01","b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f","0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92","719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3","942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef","8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2","07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80","8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819","bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a","cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e","94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43","2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715","14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc","576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd","49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd","19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b","5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b","d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b","50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b","9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8","6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa","41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071","14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd","a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1","971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709","18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1","15c8b91ade1a4e58f3ce4e7a0dd7f42b47db0c8df7e0d84f63eb39bcb96c4e0f","541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf"];function Jt(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let Xt="WALLETCONNECT_DEEPLINK_CHOICE";function Qt(e){return e.startsWith("http://")||e.startsWith("https://")}function er(e,t){if(Qt(e))return tr(e,t);let r=e;return r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function tr(e,t){if(!Qt(e))return er(e,t);let r=e;return r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function rr(e,t){window.open(e,t,"noreferrer noopener")}class nr{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}class ar{get meta(){return this._meta}async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new i.PrivyClientError("Auth flow must be initialized first");try{let e=await this.api.post(i.farcasterAuthenticatePath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new i.PrivyClientError("No response from authentication");return e}catch(e){throw i.formatApiError(e)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(i.farcasterLinkPath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw i.formatApiError(e)}}async _startChannelOnce(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");let e=await this.api.post(i.farcasterInitPath,{token:this.captchaToken});n.isMobile&&!n.isIOS&&e.connect_uri&&rr(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new i.PrivyClientError("Auth flow must be initialized first");let e=await this.api.get(i.farcasterStatusPath,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new nr(this._startChannelOnce.bind(this)),this.pollForReady=new nr(this._pollForReady.bind(this)),this._meta.disableSignup=t}}const ir="https://auth.privy.io",or=1400,sr=2500,lr=4e3,cr="2.6.4",dr="privy:token",ur="privy-token",pr="privy:refresh_token",hr="privy:pat",mr="privy:id_token",yr="privy-id-token",fr="privy-session",gr="privy:caid",wr=e=>`privy:guest:${e}`,vr=e=>`privy:cross-app:${e}`,xr="privy:state_code",Cr="privy:code_verifier",br="privy:headless_oauth",jr="privy:oauth_disable_signup",kr=e=>`privy:wallet:${e}`,Er="privy:connectors",Tr="privy:connections",Ar=12e4,Ir=3e4,Sr="https://api.moonpay.com/v1",Pr="https://api.moonpay.com/v1",_r="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Nr="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";function Mr(e){return crypto.getRandomValues(new Uint8Array(e))}function Wr(){return l.base64url.encode(Mr(36))}function Or(){return Wr()}async function Ur(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return l.base64url.encode(t)}}class Fr{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new i.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new i.PrivyClientError("User denied confirmation during OAuth flow");let e=function(){let e=Nt.get(Cr);if(!e)throw new i.PrivyClientError("Authentication error.");return e}();try{let t=await this.api.post(i.oAuthAuthenticatePath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Nt.del(Cr),Nt.del(br),Nt.del(jr),t}catch(e){let t=i.formatApiError(e);if(t.privyErrorCode)throw new i.PrivyClientError(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new i.PrivyClientError("Invalid code during oauth flow.",void 0,i.PrivyErrorCode.OAUTH_USER_DENIED);throw new i.PrivyClientError("Invalid code during OAuth flow.",void 0,i.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new i.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new i.PrivyClientError("User denied confirmation during OAuth flow");let e=Nt.get(Cr);if(!e)throw new i.PrivyClientError("Authentication error.");try{let t=await this.api.post(i.oAuthLinkPath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return Nt.del(Cr),t}catch(e){throw i.formatApiError(e)}}async getAuthorizationUrl(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.provider)throw new i.PrivyClientError("Provider must be set when initializing OAuth authentication.");let e=Wr();Nt.put(Cr,e);let t=Or();Nt.put(xr,t);let r=await Ur(e);this.meta.withPrivyUi||Nt.put(br,!0),this.meta.disableSignup&&Nt.put(jr,!0);let n=At(this.meta.withPrivyUi);try{return await this.api.post(i.oAuthInitPath,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:t},{headers:{...n}})}catch(e){throw i.formatApiError(e)}}constructor(e){this.meta=e}}function Rr(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Lr=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...t},...r,children:[/*#__PURE__*/e.jsx("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),/*#__PURE__*/e.jsx("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]}),Dr=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...t},...r,children:[/*#__PURE__*/e.jsx("g",{clipPath:"url(#clip0)",children:/*#__PURE__*/e.jsx("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),/*#__PURE__*/e.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0",children:/*#__PURE__*/e.jsx("rect",{width:"71",height:"55",fill:"white"})})})]}),Br=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...t},...r,children:/*#__PURE__*/e.jsx("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})}),zr=({style:t})=>/*#__PURE__*/e.jsx(mt.default,{style:{color:"var(--privy-color-error)",...t}}),$r=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...t},...r,children:[/*#__PURE__*/e.jsx("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),/*#__PURE__*/e.jsx("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),/*#__PURE__*/e.jsx("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),/*#__PURE__*/e.jsx("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});function Vr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...t,children:[/*#__PURE__*/e.jsxs("defs",{children:[/*#__PURE__*/e.jsxs("linearGradient",{id:"b",children:[/*#__PURE__*/e.jsx("stop",{offset:"0",stopColor:"#3771c8"}),/*#__PURE__*/e.jsx("stop",{stopColor:"#3771c8",offset:".128"}),/*#__PURE__*/e.jsx("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),/*#__PURE__*/e.jsxs("linearGradient",{id:"a",children:[/*#__PURE__*/e.jsx("stop",{offset:"0",stopColor:"#fd5"}),/*#__PURE__*/e.jsx("stop",{offset:".1",stopColor:"#fd5"}),/*#__PURE__*/e.jsx("stop",{offset:".5",stopColor:"#ff543e"}),/*#__PURE__*/e.jsx("stop",{offset:"1",stopColor:"#c837ab"})]}),/*#__PURE__*/e.jsx("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),/*#__PURE__*/e.jsx("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),/*#__PURE__*/e.jsx("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/e.jsx("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/e.jsx("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}function qr({style:t,...r}){/*#__PURE__*/return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...t},...r,children:/*#__PURE__*/e.jsx("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:/*#__PURE__*/e.jsx("g",{transform:"scale(5.12,5.12)",children:/*#__PURE__*/e.jsx("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}function Hr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...t,children:[/*#__PURE__*/e.jsx("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),/*#__PURE__*/e.jsx("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}function Kr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...t,children:[/*#__PURE__*/e.jsx("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),/*#__PURE__*/e.jsx("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),/*#__PURE__*/e.jsx("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}const Zr=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...t},...r,children:/*#__PURE__*/e.jsx("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})});let Gr={google:{name:"Google",component:$r},discord:{name:"Discord",component:Dr},github:{name:"Github",component:Br},linkedin:{name:"LinkedIn",component:qr},twitter:{name:"Twitter",component:Zr},spotify:{name:"Spotify",component:Hr},instagram:{name:"Instagram",component:Vr},tiktok:{name:"Tiktok",component:Kr},apple:{name:"Apple",component:Lr}};const Yr=e=>e in Gr?Gr[e]:{name:"Unknown",component:zr};function Jr(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),n=e.get("privy_oauth_provider");if(!t||!r||!n)return{inProgress:!1};let a=!1;try{a=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:n,withPrivyUi:!Nt.get(br),popupFlow:null!==window.opener&&a,disableSignup:!!Nt.get(jr)}}function Xr(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Nt.del(xr),window.history.replaceState({},"",e)}class Qr{async initRegisterFlow(e){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new i.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,r=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(i.passkeyRegisterPath,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new i.PrivyClientError("Passkey request timed out or rejected by user.",void 0,i.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw i.formatApiError(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new i.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let r=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(i.passkeyAuthenticatePath,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new i.PrivyClientError("Passkey request timed out or rejected by user.",void 0,i.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw i.formatApiError(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new i.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,r=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(i.passkeyLinkPath,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new i.PrivyClientError("Passkey request timed out or rejected by user.",void 0,i.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw i.formatApiError(e)}}async _initRegisterOnce(e){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");let t=At(e);return await this.api.post(i.passkeyInitRegisterPath,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");let t=At(e);return await this.api.post(i.passkeyInitAuthenticatePath,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");return await this.api.post(i.passkeyInitLinkPath,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new nr(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new nr(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new nr(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}const en=({address:e,chainId:t,nonce:r})=>`${window.location.host} wants you to sign in with your Ethereum account:\n${e}\n\nBy signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: ${t}\nNonce: ${r}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class tn{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,chainId:this.wallet.chainId,address:this.wallet.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw i.formatApiError(e)}}async sign(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new i.PrivyClientError("Could not prepare SIWE message");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new i.PrivyClientError("SiweFlow has no client instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=en({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1){this._meta={disableSignup:!1},this.getNonceOnce=new nr(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=r,this.client=t,this._meta.disableSignup=n}}class rn{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw i.formatApiError(e)}}async sign(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new i.PrivyClientError("Could not prepare SIWS message");if(!this.wallet.signMessage)throw new i.PrivyClientError("Wallet does not support signMessage");let e=await this.wallet.signMessage(Buffer.from(this.preparedMessage));return{message:this.preparedMessage,signature:Buffer.from(e).toString("base64")}}async _getNonceOnce(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new i.PrivyClientError("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=(({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\nYou are proving you own ${e}.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: mainnet\nNonce: ${t}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`)({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1){this._meta={disableSignup:!1},this.getNonceOnce=new nr(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=r,this.client=t,this._meta.disableSignup=n}}class nn{async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new i.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(i.passwordlessSmsAuthenticatePath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new i.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(i.passwordlessSmsLinkPath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw i.formatApiError(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new i.PrivyClientError("phone nNumber must be set when initialzing authentication.");let n=At(r);try{return await this.api.post(i.passwordlessSmsInitPath,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw i.formatApiError(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:r}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:r??!1}}}class an extends nn{async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new i.PrivyClientError("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(i.updatePhonePath,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw i.formatApiError(e)}}constructor(e,t,r){super({phoneNumber:t,captchaToken:r}),this.meta={phoneNumber:t,captchaToken:r,oldPhoneNumber:e,disableSignup:!1}}}const on=/*#__PURE__*/r.createContext({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:i.notImplemented,setError:i.notImplemented,setExecuting:i.notImplemented,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:i.notImplemented,reset:i.notImplemented,execute:i.notImplemented});class sn extends i.PrivyError{constructor(e,t,r){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=r}}const ln=({children:t,id:n,captchaSiteKey:a,captchaEnabled:o})=>{let s=r.useRef(null),[l,c]=r.useState(),[d,u]=r.useState(),[p,h]=r.useState(!1),m=r.useMemo((()=>o?p||l||d?!p||l||d?l&&!d?{status:"success",token:l}:d?{status:"error",error:d}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[o,l,d,p]);/*#__PURE__*/return e.jsx(on.Provider,{value:{...m,ref:s,enabled:o,siteKey:a,appId:n,setToken:c,setError:u,setExecuting:h,remove(){o&&(s.current?.remove(),h(!1),u(void 0),c(void 0))},reset(){o&&(s.current?.reset(),h(!1),u(void 0),c(void 0))},execute(){o&&(h(!0),s.current?.execute())},async waitForResult(){if(!o)return"";try{return await function(e,{interval:t=100,timeout:r=5e3}={}){return new Promise(((n,a)=>{let i,o=0,s=()=>{o>=r?a("Max attempts reached without result"):(i=e(),o+=t,null==i?setTimeout(s,t):n(i))};s()}))}((()=>s.current?.getResponse()),{interval:200,timeout:2e4})}catch(e){throw new sn("Captcha failed",null,i.PrivyErrorCode.CAPTCHA_TIMEOUT)}}},children:t})},cn=()=>r.useContext(on);class dn{async authenticate(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(i.telegramAccountAuthenticatePath,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw i.formatApiError(e)}}async link(){if(!this.api)throw new i.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(i.telegramAccountLinkPath,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw i.formatApiError(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function un(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===i.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===i.PrivyErrorCode.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===i.PrivyErrorCode.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===i.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===i.PrivyErrorCode.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===i.PrivyErrorCode.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===i.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof sn&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function pn(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function hn(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}class mn{static parse(e){try{return new mn(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return ke.decodeJwt(e),e}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=ke.decodeJwt(e)}}class yn extends mn{static parse(e){try{return new yn(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}function fn(e){return e?new Date(1e3*e):null}function gn(e,t){return e.slice().sort(((e,t)=>(e.firstVerifiedAt??e.verifiedAt).getTime()-(t.firstVerifiedAt??t.verifiedAt).getTime())).find((e=>e.type===t))}const wn=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType&&0===e.walletIndex))||null,vn=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType)),xn=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType)),Cn=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType&&0===e.walletIndex))||null,bn=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType))||null,jn=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType))||null,kn=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.address===t))||null,En=e=>wn(e)??Cn(e);function Tn(e){if(!e)return null;let t=function(e){let t=[];for(let r of e){let e=r.type;switch(r.type){case"wallet":let n={id:r.id,address:r.address,type:r.type,imported:r.imported,delegated:r.delegated,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at),chainType:r.chain_type,walletClientType:r.wallet_client_type,connectorType:r.connector_type,recoveryMethod:r.recovery_method,walletIndex:r.wallet_index};t.push(n);break;case"smart_wallet":let a={address:r.address,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at),smartWalletType:r.smart_wallet_type};t.push(a);break;case"cross_app":let i={type:r.type,subject:r.subject,embeddedWallets:r.embedded_wallets,smartWallets:r.smart_wallets,providerApp:{id:r.provider_app_id},verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(i);break;case"email":let o={address:r.address,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(o);break;case"phone":let s={number:r.phoneNumber,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(s);break;case"google_oauth":let l={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(l);break;case"spotify_oauth":let c={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(c);break;case"instagram_oauth":let d={subject:r.subject,username:r.username,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(d);break;case"twitter_oauth":let u={subject:r.subject,username:r.username,name:r.name,type:r.type,profilePictureUrl:r.profile_picture_url,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(u);break;case"discord_oauth":let p={subject:r.subject,username:r.username,email:r.email,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(p);break;case"github_oauth":let h={subject:r.subject,username:r.username,name:r.name,email:r.email,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(h);break;case"tiktok_oauth":let m={subject:r.subject,username:r.username,name:r.name,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(m);break;case"linkedin_oauth":let y={subject:r.subject,name:r.name,email:r.email,vanityName:r.vanity_name,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(y);break;case"apple_oauth":let f={subject:r.subject,email:r.email,type:r.type,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(f);break;case"custom_auth":t.push({type:r.type,customUserId:r.custom_user_id,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)});break;case"farcaster":let g={type:r.type,fid:r.fid,ownerAddress:r.owner_address,displayName:r.display_name,username:r.username,bio:r.bio,pfp:r.profile_picture_url,url:r.homepage_url,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at),signerPublicKey:r.signer_public_key};t.push(g);break;case"passkey":let w={type:r.type,enrolledInMfa:r.enrolled_in_mfa,credentialId:r.credential_id,authenticatorName:r.authenticator_name,createdWithDevice:r.created_with_device,createdWithOs:r.created_with_os,createdWithBrowser:r.created_with_browser,verifiedAt:fn(r.verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(w);break;case"telegram":let v={type:r.type,telegramUserId:r.telegram_user_id,firstName:r.first_name,lastName:r.last_name,username:r.username,photoUrl:r.photo_url,verifiedAt:fn(r.first_verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(v);break;case"authorization_key":let x={type:r.type,publicKey:r.public_key,verifiedAt:fn(r.first_verified_at),firstVerifiedAt:fn(r.first_verified_at),latestVerifiedAt:fn(r.latest_verified_at)};t.push(x);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),r=gn(t,"wallet"),n=gn(t,"smart_wallet"),a=gn(t,"email"),i=gn(t,"phone"),o=gn(t,"google_oauth"),s=gn(t,"twitter_oauth"),l=gn(t,"discord_oauth"),c=gn(t,"github_oauth"),d=gn(t,"spotify_oauth"),u=gn(t,"instagram_oauth"),p=gn(t,"tiktok_oauth"),h=gn(t,"linkedin_oauth"),m=gn(t,"apple_oauth"),y=gn(t,"farcaster"),f=gn(t,"telegram"),g=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:fn(t)})));return{id:e.id,createdAt:fn(e.created_at),linkedAccounts:t,email:a&&{address:a?.address},phone:i&&{number:i?.number},wallet:r&&{id:r.id,address:r.address,chainType:r.chainType,walletClientType:r.walletClientType,connectorType:r.connectorType,recoveryMethod:r.recoveryMethod,imported:r.imported,delegated:r.delegated,walletIndex:r.walletIndex},smartWallet:n&&{address:n.address,smartWalletType:n.smartWalletType},google:o&&{subject:o.subject,email:o.email,name:o.name},twitter:s&&{subject:s.subject,username:s.username,name:s.name,profilePictureUrl:s.profilePictureUrl},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:c&&{subject:c.subject,username:c.username,name:c.name,email:c.email},spotify:d&&{subject:d.subject,email:d.email,name:d.name},instagram:u&&{subject:u.subject,username:u.username},tiktok:p&&{subject:p.subject,username:p.username,name:p.name},linkedin:h&&{subject:h.subject,name:h.name,email:h.email,vanityName:h.vanityName},apple:m&&{subject:m.subject,email:m.email},farcaster:y&&{fid:y.fid,ownerAddress:y.ownerAddress,displayName:y.displayName,username:y.username,bio:y.bio,pfp:y.pfp,url:y.url,signerPublicKey:y.signerPublicKey},telegram:f&&{telegramUserId:f.telegramUserId,firstName:f.firstName,lastName:f.lastName,username:f.username,photoUrl:f.photoUrl},delegatedWallets:[],mfaMethods:g.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}const An=e=>e?.linkedAccounts.find((e=>"authorization_key"===e.type));let In=e=>{if("ethereum"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier"};if("solana"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"solana-address-verifier"};throw Error("Failed to get account entropy details")};const Sn=(e,t)=>{let r=An(e);if(r)return{entropyId:r.publicKey,entropyIdVerifier:"p256"};if(t?.imported)return In(t);let n=En(e);if(!n)throw Error("Failed to find primary wallet");return In(n)},Pn=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),/*#__PURE__*/e.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"})]}),_n={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-mainnet.rpc.privy.systems"]},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"}}},Nn={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0},Mn={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"}}},Wn={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},On={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-mainnet.rpc.privy.systems"]},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"}}},Un={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0},Fn={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},Rn={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{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},Ln={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://mainnet.rpc.privy.systems"]},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"}}},Dn={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-mainnet.rpc.privy.systems"]},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"}}},Bn={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0},zn={id:137,name:"Polygon Mainnet",network:"polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-mainnet.rpc.privy.systems"]},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"}}},$n={id:80002,name:"Polygon Amoy",network:"polygon-amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-amoy.rpc.privy.systems"]},infura:{http:["https://polygon-amoy.infura.io/v3"],webSocket:["wss://polygon-amoy.infura.io/ws/v3"]},default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"OK LINK",url:"https://www.oklink.com/amoy"}},testnet:!0},Vn={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{privy:{http:["https://sepolia.rpc.privy.systems"]},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},qn={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}},Hn=[_n,Nn,Vn,Ln,Dn,Bn,zn,$n,Fn,{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},{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"}}},{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"}}},On,Un,{id:80085,network:"berachain-artio",name:"Berachain Artio",nativeCurrency:{name:"BERA",symbol:"BERA",decimals:18},rpcUrls:{default:{http:["https://berachain-artio.rpc.privy.systems"]},public:{http:["https://berachain-artio.rpc.privy.systems"]}},blockExplorers:{default:{name:"Beratrail",url:"https://artio.beratrail.io"}},testnet:!0},{id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network"}}},Rn,{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},Mn,Wn,qn,{id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0},{id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0},{id:17e3,name:"Holesky",network:"holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://ethereum-holesky.publicnode.com"]},public:{http:["https://ethereum-holesky.publicnode.com"]}},blockExplorers:{etherscan:{name:"EtherScan",url:"https://holesky.etherscan.io"},default:{name:"EtherScan",url:"https://holesky.etherscan.io"}}},{id:690,name:"Redstone",network:"redstone",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.redstonechain.com"]},public:{http:["https://rpc.redstonechain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.redstone.xyz/"}}},{id:17069,name:"Garnet Holesky",network:"garnet-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.garnetchain.com"]},public:{http:["https://rpc.garnetchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.garnetchain.com"}}}],Kn=new Set(Hn.map((e=>e.id)));class Zn extends i.PrivyConnectorError{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class Gn extends i.PrivyConnectorError{constructor(){super("User rejected connection"),this.type="wallet_error"}}const Yn=e=>e instanceof i.PrivyConnectorError?e:e?.code?new Xn(e):new i.PrivyConnectorError("Unknown connector error",e);class Jn extends i.PrivyError{constructor(e,t,r){super(e),this.type="provider_error",this.code=t,this.data=r}}class Xn extends Jn{constructor(e){super(e.message,e.code,e.data);let t=Object.values(u.ProviderErrors).find((t=>t.eipCode===e.code));this.details=t||u.ProviderErrors.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=u.ProviderErrors.E32002_CONNECTION_ALREADY_PENDING:this.details=u.ProviderErrors.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=u.ProviderErrors.E32002_WALLET_LOCKED))}}const Qn={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...u.ProviderErrors};function ea(e){return"ethereum"===e.type}function ta(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let n=e[r],a=t[r];if(n?.address!==a?.address||n&&a&&ea(n)&&ea(a)&&n?.chainId!==a?.chainId||n?.connectorType!==a?.connectorType||n?.connectedAt!==a?.connectedAt||n?.walletClientType!==a?.walletClientType||n?.isConnected!==a?.isConnected||n?.linked!==a?.linked)return!1}return!0}class ra extends Ee.default{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const na=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||Ar;let aa;function ia(e){return"ethereum"===e.chainType}class oa extends ra{buildConnectedWallet(e,t,r,n){let o=async()=>!!this.wallets.find((t=>a.getAddress(t.address)===a.getAddress(e)));return{type:"ethereum",address:a.getAddress(e),chainId:t,meta:r,imported:n,switchChain:async r=>{let n,s;if(!o)throw new i.PrivyConnectorError("Wallet is not currently connected.");let l=this.wallets.find((t=>a.getAddress(t.address)===a.getAddress(e)))?.chainId;if(!l)throw new i.PrivyConnectorError("Unable to determine current chainId.");if("number"==typeof r?(n=`0x${r.toString(16)}`,s=r):(n=r,s=Number(r)),l===Kt(n))return;let c=this.chains.find((e=>e.id===s));if(!c)throw new i.PrivyConnectorError(`Unsupported chainId: ${r}`);let d=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:n}]})};try{return await d()}catch(e){if(((e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");case"rabby_wallet":return e.message.includes("Unrecognized chain ID");default:return 4902===e.code||e.message?.includes("4902")}})(e,this.walletClientType))return"rabby_wallet"===this.walletClientType&&await Bt(300),await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:n,chainName:c.name,nativeCurrency:c.nativeCurrency,rpcUrls:[c.rpcUrls.default?.http[0]??""],blockExplorerUrls:[c.blockExplorers?.default.url??""]}]}),d();if("rainbow"===this.walletClientType&&e.message?.includes("wallet_switchEthereumChain"))throw new i.PrivyConnectorError(`Rainbow does not support the chainId ${t}`);throw e}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:o,getEthereumProvider:async()=>{if(!await o())throw new i.PrivyConnectorError("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await o())throw new i.PrivyConnectorError("Wallet is not currently connected.");return await this.sign(e)},disconnect:()=>{this.disconnect()}}}async syncAccounts(e){let t,r=e;try{if(void 0===r){let e=await zt((()=>this.proxyProvider.request({method:"eth_accounts"})),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,e),Array.isArray(e)&&(r=e)}}catch(e){console.debug("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",e)}if(!r||!Array.isArray(r)||r.length<=0||!r[0])return;let n=r[0],i=a.getAddress(n),o=[];if("privy"===this.walletClientType){let e=Nt.get(kr(i));this.chains.find((t=>t.id===Number(e)))||(Nt.del(kr(i)),e=null),t=e||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}catch(e){console.warn(`Unable to switch embedded wallet to chain ID ${t} on initialization`)}}else try{let e=await zt((()=>this.proxyProvider.request({method:"eth_chainId"})),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,e),"string"==typeof e)t=e;else{if("number"!=typeof e)throw Error("Invalid chainId returned from provider");t=`0x${e.toString(16)}`}}catch(e){console.warn("Failed to get chainId from provider, defaulting to 0x1",e),t="0x1"}let s=Kt(t);if(!o.find((e=>a.getAddress(e.address)===i))){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};o.push(this.buildConnectedWallet(a.getAddress(n),s,e,"embedded_imported"===this.connectorType))}ta(o,this.wallets)||(this.wallets=o,this.emit("walletsUpdated"))}async getConnectedWallet(){let e=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt)).find((t=>e.find((e=>a.getAddress(e)===a.getAddress(t.address)))))||null}async isConnected(){let e=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0}async sign(e){return await this.connect({showPrompt:!1}),this.proxyProvider.request({method:"personal_sign",params:[a.toHex(e),this.wallets[0]?.address]})}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)}constructor(e,t,r,n){super(e),this.chainType="ethereum",this.onAccountsChanged=e=>{0===e.length?this.onDisconnect():this.syncAccounts(e)},this.onChainChanged=e=>{this.wallets.forEach((t=>{t.chainId=Kt(e),"privy"===this.walletClientType&&Nt.put(kr(t.address),e)})),this.emit("walletsUpdated")},this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")},this.onConnect=async()=>{this.connected=!0,"coinbase_wallet"===this.connectorType&&await Bt(300),this.syncAccounts()},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=r,this.rpcConfig=n,this.rpcTimeoutDuration=na(n,e),this.connected=!1,this.initialized=!1}}class sa{on(e,t){if(this.walletProvider)return this.walletProvider.on(e,t);this._subscriptions.push({eventName:e,listener:t})}async request(e){if(!this.walletProvider)throw new i.PrivyConnectorError(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),this.walletTimeout()]).catch((e=>{throw Yn(e)}))}constructor(e,t){this.removeListener=(e,t)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(e,t)}catch(e){console.warn("Unable to remove wallet provider listener")}},this.walletTimeout=(e=new Zn,t=this.rpcTimeoutDuration)=>new Promise(((r,n)=>setTimeout((()=>{n(e)}),t))),this.setWalletProvider=e=>{this.walletProvider&&this._subscriptions.forEach((e=>{this.removeListener(e.eventName,e.listener)})),this.walletProvider=e,this._subscriptions.forEach((e=>{this.walletProvider?.on(e.eventName,e.listener)}))},this.walletProvider=e,this.rpcTimeoutDuration=t||Ar,this._subscriptions=[]}}let la=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],ca=(e,t)=>e.makeWeb3Provider({options:t});class da extends oa{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new i.PrivyConnectorError("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw Yn(e)}}updateConnectionPreference(e){this.connectionOptions=e,this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(ca(aa,this.connectionOptions))}constructor(e,t,r,n,a,i){if(super("coinbase_wallet",e,t,r),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new sa(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=n.coinbaseWallet.connectionOptions??"all",this.walletClientType="smartWalletOnly"===this.connectionOptions?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!aa){let r=[t.id].concat(e.map((e=>e.id))),n="eoaOnly"!==this.connectionOptions?r.filter((e=>!la.includes(e))):[];n.length>0&&!n.every((e=>Kn.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${n.join(", ")}`),aa=new d.CoinbaseWalletSDK({appName:a,appLogoUrl:i,appChainIds:r})}this.proxyProvider.setWalletProvider(ca(aa,this.connectionOptions))}}const ua=({...t})=>/*#__PURE__*/e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:/*#__PURE__*/e.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:t.color||"var(--privy-color-foreground-3)"})});class pa extends oa{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[qt(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:ua,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}constructor({provider:e,chains:t,defaultChain:r,rpcConfig:n,imported:a,walletIndex:i}){super("privy",t,r,n),this.connectorType="embedded",this.proxyProvider=e,this.walletIndex=i,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}}const ha=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];let ma={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844"};const ya={legacy:0,eip2930:1,eip1559:2,eip4844:3};let fa=e=>void 0!==e?BigInt(e):void 0;function ga(e){let t,{type:r=2,...n}=e;n.accessList&&Array.isArray(n.accessList)?t=n.accessList.map((e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e)):n.accessList&&(t=Object.entries(n.accessList).map((e=>({address:e[0],storageKeys:e[1]}))));let a=Number(n.chainId??1),s=o.isHex(n.data)?n.data:n.data?o.toHex(Uint8Array.from(n.data)):void 0,l=n.nonce?Number(n.nonce):void 0,c={chainId:a,data:s,nonce:l,value:fa(n.value),gas:fa(n.gas??n.gasLimit)},d=Number(r);if(0===d)return{...n,type:ma[d],...c,gasPrice:fa(n.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===d)return{...n,type:ma[d],...c,gasPrice:fa(n.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===d)return{...n,type:ma[d],...c,nonce:l,accessList:t,maxFeePerGas:fa(n.maxFeePerGas),maxPriorityFeePerGas:fa(n.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw new i.PrivyClientError(`Unsupported transaction type: ${r}`)}class wa extends Error{constructor(e,t,r){super(e),this.code=t,this.data=r}}class va extends Ee.default{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new wa(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await bv()||!this.address)throw new wa("Disconnected",4900);let{hash:r}=await Tv(t,{address:this.address});return r}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new wa(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await bv()||!this.address)throw new wa("Disconnected",4900);let{signature:r}=await Ev(t,{address:this.address});return r}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new wa(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new wa(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Ut(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],r=e.params[1],{signature:n}=await jv({message:t},{address:r});return n}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],r="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:n}=await kv(Gt(r),{address:t});return n}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:qt(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...ga(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return qt(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>ha.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await bv();if(await Av(),!t||!this.address)throw new wa("Disconnected",4900);try{return(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:{method:e.method,params:e.params}})).response.data}catch(e){throw console.error(e),new wa("Disconnected",4900)}}}constructor({walletProxy:e,address:t,entropyId:r,entropyIdVerifier:n,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l}){super(),this.walletProxy=e,this.address=t,this.entropyId=r,this.entropyIdVerifier=n,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Ut(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=na(a,"privy"),this.appId=o,this.walletIndex=l}}class xa extends oa{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:r,walletClientType:n,defaultChain:a}){super(n,[],a,{}),this.connectorType="null",this.proxyProvider=new sa(void 0,Ar),this.id=e,this.name=t,this.icon=r,this.connectorType=n}}const Ca=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...t},...r,children:/*#__PURE__*/e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})}),ba=({style:t,...r})=>/*#__PURE__*/e.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",...t},...r,children:[/*#__PURE__*/e.jsx("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),/*#__PURE__*/e.jsx("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"}),/*#__PURE__*/e.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"})]}),ja=({style:t,...r})=>/*#__PURE__*/e.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",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),/*#__PURE__*/e.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"})]});function ka(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Ea=0;class Ta extends oa{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new i.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Yn(e)}}constructor(e,t,r,n,a){super(a||"unknown",e,t,r),this.connectorType="injected",this.proxyProvider=new sa(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=n;let i=n.provider;this.proxyProvider.setWalletProvider(i)}}var Aa="__private_"+Ea+++"__walletBranding";class Ia extends oa{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return ka(this,Aa)[Aa]??{name:"Browser Extension",icon:Ca,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new i.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Yn(e)}}constructor(e,t,r,n,a){super(a??"unknown",e,t,r),Object.defineProperty(this,Aa,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new sa(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(n),"metamask"===a?ka(this,Aa)[Aa]={name:"MetaMask",icon:ba,id:"io.metamask"}:"phantom"===a&&(ka(this,Aa)[Aa]={name:"Phantom",icon:ja,id:"phantom"})}}class Sa extends Ta{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{n.isMobile||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new i.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Yn(e)}}}const Pa=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","crypto.com_wallet_extension","crypto.com_onchain","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","privy","unknown","phantom","solflare","glow","backpack"],_a=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:je.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=Ma({client:this.client,isSolana:t,connectOnly:r});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${n}?ref=${n}`}},solflare:{client:"solflare",name:"Solflare",installLink:je.isFirefox?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=Ma({client:this.client,isSolana:t,connectOnly:r});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${n}?ref=${n}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcbcmnbpgliof",chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=Ma({client:this.client,isSolana:t,connectOnly:r});return`${e?"backpack://ul/v1/":"https://backpack.com/ul/v1/"}browse/${n}?ref=${n}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",chainTypes:["solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return"https://www.okx.com/download?deeplink="+encodeURIComponent("okx://wallet/dapp/url?dappUrl="+Ma({client:this.client,isSolana:e,connectOnly:t}))}}});function Na({connectorType:e,walletClientType:t}){for(let r of Pa)if(e===r||t===r)return _a[r]}function Ma({client:e,isSolana:t,connectOnly:r}){let n=new URL(window.location.href);return n.searchParams.set("privy_connector",t?"solana_adapter":"injected"),n.searchParams.set("privy_wallet_client",e),n.searchParams.set("privy_connect_only",String(r)),encodeURIComponent(n.href.replace(/\/$/g,""))}const Wa=()=>{let e=Nt.get(Tr);return e&&Array.isArray(e)&&e.map((e=>(e=>e&&"string"==typeof e.address&&"string"==typeof e.connectorType&&"string"==typeof e.walletClientType&&"number"==typeof e.connectedAt)(e))).every(Boolean)?e:[]};let Oa=["phantom","glow","solflare","backpack","okx_wallet"];function Ua(e){return"solana"===e.chainType}function Fa(e){return"solana"===e.type}class Ra extends ra{get isInstalled(){return"Installed"===this.adapter.readyState}buildConnectedWallet(e,t){let r,n,a,o;if("Installed"!==e.readyState||!e.publicKey)throw Error("Wallet is not connected.");return"signMessage"in e&&(r=async(...t)=>{if(!e.connected)throw Error("Wallet is not connected.");return await e.signMessage(t[0])}),"sendTransaction"in e&&(n=async(...t)=>await e.sendTransaction(t[0],t[1],t[2])),"signTransaction"in e&&(a=async t=>await e.signTransaction(t)),"signAllTransactions"in e&&(o=async t=>await e.signAllTransactions(t)),{type:"solana",address:e.publicKey.toBase58(),meta:t,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>e.connected,disconnect:()=>{try{e.disconnect()}catch(e){console.error("Wallet does not support programmatic disconnect")}},getProvider:i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:r??i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:n??i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:a??i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signTransaction'`),signAllTransactions:o??i.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signAllTransactions'`)}}async syncAccounts(){if("Installed"===this.adapter.readyState&&this.adapter.publicKey){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find((e=>this.adapter.publicKey&&e.address===this.adapter.publicKey.toBase58()))||(this.wallets=[this.buildConnectedWallet(this.adapter,e)],this.emit("walletsUpdated"))}else this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"))}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAttemptAutoConnect()&&await this.adapter.autoConnect().catch((()=>{})),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}shouldAttemptAutoConnect(){return!(!this.autoConnectEnabled||!Oa.includes(this.walletClientType))&&("phantom"!==this.walletClientType||Wa().some((({walletClientType:e})=>"phantom"===e)))}constructor(e,t){super(function(e){return e.name.toLowerCase().split(" ").join("_")}(e)),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=()=>{this.adapter.disconnect().then((()=>this.onDisconnect())).catch((e=>console.error("Error disconnecting",e)))},this.promptConnection=async()=>{try{await this.adapter.connect()}catch(e){throw Yn(e)}},this.onDisconnect=()=>{this.syncAccounts()},this.onConnect=e=>{this.syncAccounts()},this.onError=e=>{this.syncAccounts()},this.onReadyStateChange=e=>{"Installed"!==e&&(this.connected=!1),this.syncAccounts()},this.adapter=e,this.autoConnectEnabled=t,this.wallets=[]}}class La extends Ra{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:r}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new sa(void 0,Ar),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=r}}const Da=b.create((()=>({listings:[]}))),Ba=Da.setState,za=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return Da.getState().listings.find((({homepage:e})=>{let r;try{r=new URL(e).hostname}catch(e){return!1}return t.includes(r)}))},$a=e=>Da((({listings:t})=>t.find((({slug:t})=>Va(t)===Va(e)))));function Va(e){return"cryptocom"===e?"cryptocom-defi":e.replace(/[-_]wallet$/,"")}function qa({src:t,...r}){/*#__PURE__*/return e.jsx("img",{src:t,...r,style:{display:"none"}})}const Ha={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",externalWallets:{coinbaseWallet:{connectionOptions:"all"}},embeddedWallets:{extendedCalldataDecoding:!1},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};let Ka=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","ronin_wallet","haha_wallet","wallet_connect","detected_wallets","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe","solflare","backpack"]),Za=e=>Ka.has(e),Ga=(e,t,r)=>r.indexOf(e)===t;function Ya(e){let t=e.filter((e=>!Kn.has(e.id)));return Hn.concat(t)}function Ja(e,t){return{...e,rpcUrls:{...e.rpcUrls,privy:{http:[t]}}}}const Xa=792703809,Qa="11111111111111111111111111111111";function ei(e){return e.includes("testnet")?"testnet":e.includes("devnet")?"devnet":"mainnet-beta"}function ti(e,t){return`https://explorer.solana.com/account/${e}?cluster=${t}`}let ri="#FFFFFF";function ni(e,t){let r=Math.max(0,Math.min(1,e.toHsl().l+t));return Te.default({...e.toHsl(),l:r})}function ai({backgroundTheme:e,accentHex:t}){let r;switch(e){case"light":r=ri;break;case"dark":r="#1E1E1D";break;default:r=e}let n=Te.default(r),a=Te.default(t),i=Te.default("#51BA81"),o=Te.default("#FFB74D"),s=Te.default("#EC6351"),l=function(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"}(n.getLuminance()),c=ni(n,"light"===l?-.04:.11),d=ni(n,"light"===l?-.08:.16),u=ni(n,"light"===l?-.88:.87),p=ni(n,"light"===l?-.7:.75),h=ni(n,"light"===l?-.43:.45).desaturate("light"===l?60:20),m=ni(n,"light"===l?-.08:.25).desaturate("light"===l?60:20),y=ni(a,.15),f=ni(a,.25),g=ni(a,-.06),w=ni(a,-.6),v=ni(s,.3),x=ni(o,.3),C=Te.default(a.getLuminance()>.5?"#040217":ri),b=ni(i,-.16),j=ni(i,.4);return{colorScheme:l,background:n.toHslString(),background2:c.toHslString(),background3:d.toHslString(),foreground:u.toHslString(),foreground2:p.toHslString(),foreground3:h.toHslString(),foreground4:m.toHslString(),accent:a.toHslString(),accentLight:y.toHslString(),accentLightest:f.toHslString(),accentDark:g.toHslString(),accentDarkest:w.toHslString(),foregroundAccent:C.toHslString(),success:i.toHslString(),successDark:b.toHslString(),successLight:j.toHslString(),error:s.toHslString(),errorLight:v.toHslString(),warn:o.toHslString(),warnLight:x.toHslString()}}function ii(e,t,r,n){let a,i,o,s,l,c,d,u,p,h,m,y,f,g,w,v=r?console.warn:()=>{};t?.loginMethods?(a=t.loginMethods.includes("email"),i=t.loginMethods.includes("sms"),s=t.loginMethods.includes("wallet"),l=t.loginMethods.includes("google"),c=t.loginMethods.includes("twitter"),d=t.loginMethods.includes("discord"),p=t.loginMethods.includes("spotify"),h=t.loginMethods.includes("instagram"),u=t.loginMethods.includes("tiktok"),y=t.loginMethods.includes("github"),m=t.loginMethods.includes("linkedin"),f=t.loginMethods.includes("apple"),g=t.loginMethods.includes("farcaster"),w=t.loginMethods.includes("telegram"),o=t.loginMethods.includes("passkey")):(a=e.emailAuth,i=e.smsAuth,s=e.walletAuth||e.solanaWalletAuth,l=e.googleOAuth,c=e.twitterOAuth,d=e.discordOAuth,y=e.githubOAuth,p=e.spotifyOAuth,h=e.instagramOAuth,u=e.tiktokOAuth,m=e.linkedinOAuth,f=e.appleOAuth,g=e.farcasterAuth,w=e.telegramAuth,o=e.passkeyAuth),e.passkeyAuth&&(o=!0),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(o=!1);let x=[a,i].filter(Boolean),C=[l,c,d,y,p,h,u,m,f,g,w].filter(Boolean),b=[s].filter(Boolean),j=t?.loginMethods?.includes("passkey")??!1,k=e.passkeysForSignupEnabled??!1,E=[o&&(k||j)].filter(Boolean);if(x.length+C.length+b.length+E.length===0)throw Error("You must enable at least one login method");let T=void 0!==t?.appearance?.showWalletLoginFirst?t?.appearance?.showWalletLoginFirst:e.showWalletLoginFirst;T&&0===b.length?(v("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),T=!1):T||C.length+x.length!==0||(v("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),T=!0);let A=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&v("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let I=(({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(Za).filter(Ga):e?e.filter(Za).filter(Ga):Ha.appearance.walletList)({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),S=(({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],r=[];for(let r of(e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`"),e.primary.slice(1)))t.includes(r)?console.warn(`Duplicated login method: ${r}`):t.push(r);for(let n of e.overflow??[])t.includes(n)||r.includes(n)?console.warn(`Duplicated login method: ${n}`):r.push(n);return{primary:t,overflow:r}})({input:t?.loginMethodsAndOrder}),P=t?.intl?.defaultCountry??"US",{chains:_,defaultChain:N}=function({supportedChains:e,defaultChainFromConfig:t}){let r;if(e){if(0===e.length)throw Error("`supportedChains` must contain at least one chain");r=e.map((e=>{if(e.rpcUrls.privyWalletOverride)return e;let t=Hn.find((t=>t.id===e.id)),r=t?.rpcUrls.privy?.http[0];return r?Ja(e,r):e}))}else r=[...Hn];let n=e?r[0]:Ln,a=t??n;if(!r.find((e=>e.id===a.id)))throw Error("`defaultChain` must be included in `supportedChains`");return{chains:r,defaultChain:a}}({supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain}),M=!!t?.defaultChain,W=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,O=t?.embeddedWallets?.requireUserPasswordOnCreate,U=t?.embeddedWallets?.createOnLogin,F=W?"all-users":e.embeddedWalletConfig.ethereum.createOnLogin,R=e.embeddedWalletConfig.solana.createOnLogin,L=t?.solanaClusters??[];return e.solanaWalletAuth&&!t?.externalWallets?.solana?.connectors&&console.warn("App configuration has Solana wallet login enabled, but no Solana wallet connectors have been passed to Privy. Make sure to pass Solana connectors to the `config.externalWallets.solana.connectors` field of the `PrivyProvider`"),{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,legacyWalletUiConfig:e.legacyWalletUiConfig,appearance:{logo:t?.appearance?.logo??e.logoUrl,landingHeader:t?.appearance?.landingHeader??Ha.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:ai({backgroundTheme:t?.appearance?.theme??Ha.appearance.theme,accentHex:t?.appearance?.accentColor??e.accentColor??Ha.appearance.accentColor}),loginGroupPriority:T?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:I,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.walletAuth??!1,solanaWalletAuth:e.solanaWalletAuth??!1})},loginMethods:{wallet:s,email:a,sms:i,passkey:o,google:l,twitter:c,discord:d,github:y,spotify:p,instagram:h,tiktok:u,linkedin:m,apple:f,farcaster:g,telegram:w},disablePlusEmails:e.disablePlusEmails,loginMethodsAndOrder:S,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.termsAndConditionsUrl,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacyPolicyUrl,requireUsersAcceptTerms:e.requireUsersAcceptTerms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.walletConnectCloudProjectId??Ha.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:{}},chains:_,solanaClusters:{"mainnet-beta":L.find((e=>"mainnet-beta"===e.name))?.rpcUrl||"https://api.mainnet-beta.solana.com",testnet:L.find((e=>"testnet"===e.name))?.rpcUrl||"https://api.testnet.solana.com",devnet:L.find((e=>"devnet"===e.name))?.rpcUrl||"https://api.devnet.solana.com"},defaultChain:N,intl:{defaultCountry:P},shouldEnforceDefaultChainOnConnect:M,captchaEnabled:e.captchaEnabled??Ha.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??Ha.externalWallets.coinbaseWallet.connectionOptions},walletConnect:{enabled:A},solana:{connectors:t?.externalWallets?.solana?.connectors}},embeddedWallets:{requireUserOwnedRecoveryOnCreate:O??(!W&&e.embeddedWalletConfig.requireUserOwnedRecoveryOnCreate),userOwnedRecoveryOptions:W?["user-passcode"]:e.embeddedWalletConfig.userOwnedRecoveryOptions,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:U??t?.embeddedWallets?.ethereum?.createOnLogin??F},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??R},showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforceWalletUis??!0,extendedCalldataDecoding:t?.embeddedWallets?.extendedCalldataDecoding??!1,transactionScanning:{enabled:t?.embeddedWallets?.transactionScanning?.enabled??!1,domain:t?.embeddedWallets?.transactionScanning?.domain??n??"https://auth.privy.io"}},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink},customAuth:W?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:e.telegramAuthConfiguration,passkeysForSignupEnabled:e.passkeysForSignupEnabled},headless:!!t?.headless,render:{standalone:t?._render?.standalone??Ha._render.standalone},fundingConfig:e.fundingConfig,fundingMethodConfig:{...t?.fundingMethodConfig??Ha.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??Ha.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??Ha.fundingMethodConfig.moonpay.useSandbox}}}}let oi={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,linkedinOAuth:!1,appleOAuth:!1,disablePlusEmails:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{ethereum:{createOnLogin:"off"},solana:{createOnLogin:"off"},requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]},fiatOnRampEnabled:!1,captchaEnabled:!1,captchaSiteKey:"",enforceWalletUis:!1,legacyWalletUiConfig:!1};const si=ii(oi,void 0,!1);let li=/*#__PURE__*/r.createContext({appConfig:si,isServerConfigLoaded:!1});const ci=({children:t,client:n,clientConfig:a})=>{let[i,o]=r.useState(null),s=r.useMemo((()=>ii(i??oi,a,!!i,"undefined"!=typeof window?window.location.origin:void 0)),[i,a]);return r.useEffect((()=>{if(!i)return;let e=function(e){if(!e)return{};let{appearance:t,supportedChains:r,defaultChain:n,externalWallets:a,...i}=e;return{...i,...r?{supportedChains:r.map((e=>e.id))}:void 0,...n?{defaultChain:n.id}:void 0,...a?{walletConnect:a.walletConnect,coinbaseWallet:a.coinbaseWallet,solana:{connectors:a.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0}}(a),t=function(e,t=0){let r=3735928559^t,n=1103547991^t;for(let t,a=0;a<e.length;a++)r=Math.imul(r^(t=e.charCodeAt(a)),2654435761),n=Math.imul(n^t,1597334677);return r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&(n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909)))+(r>>>0)}(JSON.stringify(e)).toString(),r=`privy:sent:${i.id}:${t}`;localStorage.getItem(r)||(n.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(r,"t"))}),[a,i]),r.useEffect((()=>{i||(async()=>{try{let e=await n.getServerConfig();e.customApiUrl&&n.updateApiUrl(e.customApiUrl),o(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),/*#__PURE__*/e.jsx(li.Provider,{value:{appConfig:s,isServerConfigLoaded:!!i},children:t})},di=()=>{let{appConfig:e}=r.useContext(li);return e},ui=()=>{let{isServerConfigLoaded:e}=r.useContext(li);return e};function pi(t){/*#__PURE__*/return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 460 40",...t,children:/*#__PURE__*/e.jsx("g",{fill:t.color||"var(--privy-color-foreground)",children:/*#__PURE__*/e.jsx("path",{d:"M0 15.4v15.38h4.64V19.96h3.58c2.47 0 3.63-.01 3.77-.02 1-.08 1.49-.15 2.18-.3a9.45 9.45 0 0 0 4.6-2.37c1.66-1.57 2.64-3.87 2.81-6.56.02-.3.02-1.19 0-1.49-.1-1.77-.56-3.35-1.36-4.72A8.84 8.84 0 0 0 15.14.57c-.93-.3-1.75-.43-3.09-.54C11.9.02 10.2 0 5.93 0H0ZM10.85 4c1.85.05 3.1.45 4.16 1.3.22.17.54.49.69.68a5.97 5.97 0 0 1 1.19 3.13c.04.35.04 1.36 0 1.71-.08.68-.23 1.3-.44 1.85a4.8 4.8 0 0 1-1.09 1.68A5.63 5.63 0 0 1 12 15.92c-.6.08-.4.08-4.01.09H4.64V3.98h2.9c1.6 0 3.08 0 3.31.02ZM187.65 5.71v5.72h-.27l-.09-.14a15.9 15.9 0 0 0-1.21-1.73c-.43-.5-1-.95-1.7-1.36-.54-.3-1.05-.5-1.73-.63a8.98 8.98 0 0 0-1.7-.17 8.84 8.84 0 0 0-7.8 4.03 12.95 12.95 0 0 0-2.03 6.39c-.07.98-.06 2.15.02 3.13.2 2.47.87 4.53 2.02 6.25a8.98 8.98 0 0 0 10.22 3.65 6.5 6.5 0 0 0 2.8-1.93c.41-.51.84-1.1 1.1-1.55l.1-.17h.37v3.58h4.38V0h-4.48Zm-5.24 5.54c1.3.14 2.3.6 3.17 1.48.9.9 1.5 2.09 1.85 3.64.36 1.6.39 3.72.06 5.43a8.13 8.13 0 0 1-1.54 3.62 5.1 5.1 0 0 1-3.93 1.96 6.13 6.13 0 0 1-2.32-.31 5.87 5.87 0 0 1-3.33-3.5c-.39-1-.62-2.05-.72-3.32-.03-.32-.04-1.35-.02-1.73.08-1.56.4-2.91.96-4.05a6.2 6.2 0 0 1 1.06-1.58 5.08 5.08 0 0 1 3.6-1.66c.25-.02.9 0 1.16.02ZM210.07 15.39l.01 15.38h4.38l.01-3.57h.37l.09.15c.24.44.84 1.26 1.21 1.7a6.79 6.79 0 0 0 2.57 1.75 9.3 9.3 0 0 0 6.86-.49 9.28 9.28 0 0 0 4.05-4.07A13.05 13.05 0 0 0 231 21.6c.21-1.73.18-3.7-.09-5.32a13.03 13.03 0 0 0-1.5-4.3 9.1 9.1 0 0 0-3.75-3.63 9.15 9.15 0 0 0-4.43-.96 7.46 7.46 0 0 0-2.8.5A7.07 7.07 0 0 0 216 9.7c-.4.52-.82 1.12-1.1 1.59l-.07.14h-.27V0h-4.5Zm11.13-4.14c1.07.1 1.94.44 2.7 1.04a6.1 6.1 0 0 1 1.64 1.98c.43.84.78 2 .94 3.11.15 1.16.16 2.4.02 3.54a9.34 9.34 0 0 1-1.39 4.03 5.33 5.33 0 0 1-2.69 2.15c-.9.3-2.04.38-3.06.2a5.14 5.14 0 0 1-3.45-2.37 6.03 6.03 0 0 1-.45-.8c-.5-1.03-.8-2.2-.92-3.58-.04-.49-.06-.89-.05-1.53.01-.76.05-1.23.13-1.85.38-2.53 1.47-4.38 3.15-5.31a5.46 5.46 0 0 1 2.3-.63 10 10 0 0 1 1.13.02ZM69.05 2.17l-.01 2.77V7.7h-3.36v3.6h3.36v6.8l.01 7.15c.06 1.4.4 2.44 1.1 3.37a5.8 5.8 0 0 0 2.97 2.07c.91.3 1.83.42 2.9.38a8.71 8.71 0 0 0 2.66-.48l-.8-3.7-.38.06a4.96 4.96 0 0 1-2.43-.06c-.33-.1-.56-.25-.8-.49-.4-.41-.6-.88-.7-1.67-.02-.2-.02-.62-.03-6.82v-6.6h4.73V7.7h-4.73V2.16h-4.49ZM133.34 2.17V7.7h-3.39v3.6h3.38v6.9l.01 7.17a5.66 5.66 0 0 0 2.36 4.49c.85.6 2.03 1.03 3.26 1.17.85.1 2.03.05 2.81-.1.3-.06.75-.18 1-.26l.2-.06v-.05l-.81-3.67-.37.06a4.99 4.99 0 0 1-1.8.09c-.85-.13-1.32-.4-1.7-.97a2.63 2.63 0 0 1-.39-1.04c-.06-.4-.06 0-.06-7.1V11.3h4.7V7.7h-4.7l-.01-2.77V2.16h-4.49ZM293.41 2.36a14.56 14.56 0 0 0-13.7 16.07 14.59 14.59 0 0 0 21.86 11.08 14.5 14.5 0 0 0 7.11-14.07 14.61 14.61 0 0 0-6.53-10.73 14.49 14.49 0 0 0-8.74-2.35ZM350.8 2.36a10.17 10.17 0 0 0-7.56 4.2c-.16.2-.45.63-.58.83l-.05.1h-.47l-.01-4.36h-7.36v36.4h7.82V27.27h.49l.05.07a11.3 11.3 0 0 0 7.49 4.15 10.52 10.52 0 0 0 9.38-4.1c1.66-2.1 2.73-4.9 3.07-8.06.1-.87.13-1.4.13-2.37 0-.8 0-1.1-.07-1.76a15.95 15.95 0 0 0-3.23-8.72 12.8 12.8 0 0 0-1.85-1.84 10.49 10.49 0 0 0-7.26-2.28Zm-.94 6.05c1.27.15 2.33.65 3.2 1.5.98.96 1.67 2.31 2.03 4 .34 1.57.38 3.68.12 5.39a9.78 9.78 0 0 1-1.04 3.25c-.14.25-.44.69-.6.89a5.35 5.35 0 0 1-4.31 2.07 5.25 5.25 0 0 1-4.41-1.9 7.35 7.35 0 0 1-1.26-2.32 14.09 14.09 0 0 1-.62-4.83c.05-1.98.38-3.53 1.02-4.85a5.63 5.63 0 0 1 2.5-2.65c.66-.34 1.3-.5 2.14-.58.18-.02 1.04 0 1.23.03ZM363.63 3.1l-.01 3.2v3.16h1.43c1.26.01 1.44.02 1.54.04.42.09.66.28.79.62.08.23.08.08.08 2.96a911.57 911.57 0 0 1 .03 10.18v7.54h7.82v-7.4l.01-7.83c.03-.94.11-1.63.27-2.28.46-1.9 1.54-2.93 3.35-3.23.52-.08.2-.08 5-.08h4.4V3.08h-3.1c-3.48 0-3.91.01-4.67.1-1.83.2-3.04.79-3.96 1.88-.5.6-.9 1.32-1.26 2.26l-.06.17h-.46V3.09h-5.6c-4.46 0-5.6 0-5.6.02ZM390.8 16.95V30.8h3.87l3.86-.01V3.09h-7.73ZM400.6 3.1l-.01.4v.38l4.66 13.4 4.69 13.47.02.05h10.3l.03-.05 4.67-13.45 4.67-13.4V3.1h-7.43l-6.7 19.26h-.5l-3.28-9.5-3.31-9.64-.05-.12h-3.88l-3.88.01ZM430.98 3.1c-.01 0-.02.19-.02.4v.39l5.08 14.59c2.8 8.02 5.08 14.6 5.08 14.61.01.02-.22.02-4.8.02h-4.82v6.42h4.95c5.09 0 5.23 0 5.87-.06 3.15-.28 5.29-1.63 6.63-4.15.28-.55.44-.95.87-2.16L459 6.78l1-2.89v-.8h-7.43l-6.69 19.26h-.5l-3.27-9.46-3.31-9.64-.06-.16h-3.88l-3.88.01ZM36.57 7.36c-1.36.1-2.6.6-3.62 1.45a5.65 5.65 0 0 0-1.67 2.42l-.05.13H31V7.7h-4.35v23.08h4.5v-7.3c0-8 0-7.34.08-7.82a4.89 4.89 0 0 1 2.06-3.18c.83-.58 1.74-.89 2.87-.98a11.87 11.87 0 0 1 2.8.25H39v-4.3l-.21-.02c-.61-.07-1.74-.1-2.22-.07ZM51.08 7.41c-2.33.12-4.3.84-5.95 2.16a9.89 9.89 0 0 0-2.03 2.2 12.5 12.5 0 0 0-2 5.78 18.04 18.04 0 0 0 0 3.65 12.13 12.13 0 0 0 2.26 6.05 9.74 9.74 0 0 0 5 3.52c2.11.64 4.7.64 6.8 0a9.78 9.78 0 0 0 4.88-3.37c1.38-1.78 2.19-4 2.4-6.58.13-1.46.06-3.06-.18-4.42a11.24 11.24 0 0 0-3.58-6.6 10 10 0 0 0-5.75-2.35c-.56-.06-1.31-.07-1.85-.04Zm1.42 3.78c.88.1 1.62.34 2.28.75a6.13 6.13 0 0 1 1.99 2.15 10.31 10.31 0 0 1 1.2 5c.02 1.23-.12 2.44-.42 3.51a7.14 7.14 0 0 1-1.81 3.32c-.61.6-1.2.98-1.95 1.24a6 6 0 0 1-2 .3 5.7 5.7 0 0 1-2.72-.6 5 5 0 0 1-1.28-.94A7.1 7.1 0 0 1 46 22.73c-.57-1.99-.6-4.46-.08-6.5a7.24 7.24 0 0 1 2.03-3.67 5.13 5.13 0 0 1 3.35-1.4 11 11 0 0 1 1.2.03ZM92.05 7.4c-.96.06-1.56.15-2.3.33a9.62 9.62 0 0 0-6.09 4.66 13.5 13.5 0 0 0-1.71 7c0 .83 0 1.04.06 1.6.16 1.77.58 3.32 1.29 4.7A9.72 9.72 0 0 0 90.28 31c1.84.37 4.08.32 5.85-.13a9.07 9.07 0 0 0 5.02-3.1A7.64 7.64 0 0 0 102.5 25l-2.11-.39-2.11-.38-.08.13a4.72 4.72 0 0 1-2.35 2.55 6.3 6.3 0 0 1-2.23.58c-.29.03-1.13.03-1.44 0a6.35 6.35 0 0 1-3.02-1.04 5.93 5.93 0 0 1-2.02-2.43 8.44 8.44 0 0 1-.72-3.18v-.26h16.38v-.81c0-1.83-.06-2.76-.25-3.87-.2-1.22-.53-2.24-1.05-3.28a8.9 8.9 0 0 0-2.66-3.26 10.1 10.1 0 0 0-5.34-1.94 18.3 18.3 0 0 0-1.46-.03Zm1.3 3.75c1.2.13 2.19.55 3.05 1.3a5.8 5.8 0 0 1 1.78 2.96c.13.51.21 1.17.21 1.66v.15H86.43v-.12c.08-.97.3-1.78.72-2.61.5-1 1.2-1.8 2.14-2.42a5.32 5.32 0 0 1 2.9-.95c.2-.01.97 0 1.17.03ZM116.79 7.41c-2 .1-3.73.65-5.22 1.65a10.7 10.7 0 0 0-4.25 6.06 16.1 16.1 0 0 0-.5 5.8c.2 2.17.84 4.13 1.88 5.76.58.9 1.32 1.73 2.15 2.4a9.37 9.37 0 0 0 3.6 1.8 12.06 12.06 0 0 0 3.92.34 10.2 10.2 0 0 0 3.84-.95 8.31 8.31 0 0 0 4.76-6.75l.01-.04h-4.37l-.05.16a4.87 4.87 0 0 1-4.24 3.75c-.59.07-1.32.06-1.93-.05a5.47 5.47 0 0 1-3.5-2.27c-.56-.75-1-1.73-1.26-2.79a13.8 13.8 0 0 1-.16-5.24 7.77 7.77 0 0 1 2.1-4.3 5.48 5.48 0 0 1 2.15-1.3 6.4 6.4 0 0 1 3.89.1c.59.21 1.03.5 1.5.96a5.32 5.32 0 0 1 1.46 2.5l.04.15h4.37v-.06a8.22 8.22 0 0 0-5.31-6.94 10.98 10.98 0 0 0-4.88-.74ZM156.2 7.41a9.87 9.87 0 0 0-6 2.29 11.02 11.02 0 0 0-3.41 5.43c-.52 1.78-.68 3.9-.48 5.97.17 1.8.63 3.38 1.37 4.8a9.68 9.68 0 0 0 5.91 4.86c1.65.48 3.63.61 5.53.36 3.72-.49 6.55-2.62 7.56-5.69.12-.39.13-.42.1-.43-.02 0-4.13-.75-4.19-.75-.03 0-.04 0-.1.16-.18.42-.45.9-.72 1.22-.16.2-.49.53-.7.7-.67.54-1.5.9-2.43 1.08-.48.08-.83.11-1.41.11-.64 0-1.07-.04-1.6-.15a5.76 5.76 0 0 1-3.93-2.83 8 8 0 0 1-.99-3.79v-.16h16.38v-1.11l-.02-1.43c-.1-2.25-.53-4-1.35-5.59a9.24 9.24 0 0 0-6.18-4.75c-1.04-.26-2.2-.36-3.33-.3Zm1.45 3.74a5.35 5.35 0 0 1 3.66 1.94 6.1 6.1 0 0 1 1.38 4.01v.12h-11.97v-.06c0-.02 0-.14.02-.25a6.6 6.6 0 0 1 2.15-4.32 5.73 5.73 0 0 1 3.5-1.46c.25-.02 1 0 1.26.02ZM233.58 7.82l8.37 23.22a49.22 49.22 0 0 1-.67 1.9 5.36 5.36 0 0 1-1.14 1.8c-.41.4-.82.58-1.48.69-.27.04-1.03.03-1.35 0a8.05 8.05 0 0 1-1.1-.23l-1.08 3.67c0 .02.32.14.66.22.83.21 1.57.29 2.56.28.56-.01.8-.03 1.24-.1 2.71-.4 4.66-2.09 5.86-5.08l9.64-26.44c0-.02-4.82-.06-4.83-.05l-2.93 8.96-2.91 8.94h-.24l-.22-.65-2.91-8.95-2.7-8.3H233.53ZM293.05 35.8c-1.18.04-1.93.09-2.8.16-2.52.24-4.53.69-5.43 1.23-.7.41-.76.86-.2 1.28.88.66 3.29 1.19 6.36 1.4a48.55 48.55 0 0 0 5.75.05c3.47-.19 6.24-.78 7.11-1.5.22-.19.3-.34.3-.53 0-.1 0-.12-.04-.22-.35-.69-2.32-1.3-5.25-1.63a41.09 41.09 0 0 0-5.8-.24Zm0 0"})})})}let hi=/*#__PURE__*/h.styled.div.withConfig({displayName:"TermsAndConditionsContainer",componentId:"sc-bdb69ecc-0"})(["margin-top:16px;font-size:13px;text-align:center;color:var(--privy-color-foreground-3);&& > a{color:var(--privy-color-accent);}"]);function mi({app:{legal:{privacyPolicyUrl:t,termsAndConditionsUrl:r,requireUsersAcceptTerms:n}},alwaysShowImplicitConsent:a}){let i=!(!t||!r);return n&&!a||!r&&!t?
2
2
  /*#__PURE__*/e.jsx(hi,{}):
3
3
  /*#__PURE__*/ /*#__PURE__*/e.jsxs(hi,{children:["By logging in I agree to the"," ",r&&/*#__PURE__*/e.jsx("a",{href:r,target:"_blank",children:i?"Terms":"Terms of Service"}),i&&" & ",t&&/*#__PURE__*/e.jsx("a",{href:t,target:"_blank",children:"Privacy Policy"})]})}const yi=()=>{let{appearance:t}=di();/*#__PURE__*/return e.jsx(fi,{children:t.footerLogo??/*#__PURE__*/e.jsx("a",{href:"https://www.privy.io/",target:"_blank",id:"protected-by-privy",children:/*#__PURE__*/e.jsx(pi,{height:13,width:150})})})},fi=/*#__PURE__*/h.styled.div.withConfig({displayName:"ModalFooter",componentId:"sc-bdb69ecc-1"})(["display:flex;align-items:center;justify-content:center;padding-top:8px;padding-bottom:12px;gap:8px;font-size:13px;&& a{padding:0.5rem 0;&:hover{text-decoration:none;}}@media all and (display-mode:standalone){padding-bottom:30px;}"]),gi=({backFn:t})=>/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(bi,{onClick:t,children:/*#__PURE__*/e.jsx(Ae.default,{height:"16px",width:"16px",strokeWidth:2})})}),wi=({nextFn:t})=>/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(bi,{onClick:t,children:/*#__PURE__*/e.jsx(Ie.default,{height:"16px",width:"16px",strokeWidth:2})})}),vi=({infoFn:t})=>/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(ji,{"aria-label":"info",onClick:t,children:/*#__PURE__*/e.jsx(Se.default,{height:"22px",width:"22px",strokeWidth:2})})}),xi=t=>/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(bi,{"aria-label":"close modal",onClick:t.onClose,children:/*#__PURE__*/e.jsx(Pe.default,{height:"16px",width:"16px",strokeWidth:2})})}),Ci=({backFn:t,infoFn:r,onClose:n,title:a,closeable:o=!0})=>{let{closePrivyModal:s}=i.usePrivyInternal(),l=di();/*#__PURE__*/return e.jsxs(ki,{children:[/*#__PURE__*/e.jsxs(Ei,{children:[t&&/*#__PURE__*/e.jsx(gi,{backFn:t}),r&&/*#__PURE__*/e.jsx(vi,{infoFn:r})]}),a&&/*#__PURE__*/e.jsx(Ai,{id:"privy-dialog-title",children:a}),/*#__PURE__*/e.jsx(Ti,{children:!l.render.standalone&&o&&/*#__PURE__*/e.jsx(xi,{onClose:n||(()=>s())})})]})};let bi=/*#__PURE__*/h.styled.button.withConfig({displayName:"StyledButton",componentId:"sc-f295093d-0"})(["&&{cursor:pointer;display:flex;opacity:0.6;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-full);padding:4px;> svg{margin:auto;color:var(--privy-color-foreground);}:hover{opacity:1;}}"]),ji=/*#__PURE__*/h.styled(bi).withConfig({displayName:"TransparentStyledButton",componentId:"sc-f295093d-1"})(["&&{background-color:transparent;}"]),ki=/*#__PURE__*/h.styled.div.withConfig({displayName:"StyledHeader",componentId:"sc-f295093d-2"})(["padding:16px 0;display:flex;align-items:center;justify-content:space-between;h2{font-size:16px;line-height:24px;font-weight:600;color:var(--privy-color-foreground);}"]),Ei=/*#__PURE__*/h.styled.div.withConfig({displayName:"LeftActionContainer",componentId:"sc-f295093d-3"})(["flex:1;align-items:center;display:flex;gap:8px;"]),Ti=/*#__PURE__*/h.styled.div.withConfig({displayName:"RightActionContainer",componentId:"sc-f295093d-4"})(["flex:1;display:flex;justify-content:flex-end;"]),Ai=/*#__PURE__*/h.styled.div.withConfig({displayName:"TitleContainer",componentId:"sc-f295093d-5"})(["overflow:hidden;white-space:nowrap;max-width:100%;text-overflow:ellipsis;text-align:center;color:var(--privy-color-foreground-2);"]);const Ii=({title:t,description:r,children:n,...a})=>
4
4
  /*#__PURE__*/e.jsx(_i,{...a,children:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("h3",{children:t}),"string"==typeof r?/*#__PURE__*/e.jsx("p",{children:r}):r,n]})}),Si=/*#__PURE__*/h.styled(Ii).withConfig({displayName:"PaddedScreenHeader",componentId:"sc-523a75d6-0"})(["margin-bottom:24px;"]),Pi=({title:t,description:r,icon:n,children:a,...i})=>/*#__PURE__*/e.jsxs(Ni,{...i,children:[n||null,/*#__PURE__*/e.jsx("h3",{children:t}),r&&"string"==typeof r?/*#__PURE__*/e.jsx("p",{children:r}):r,a]});let _i=/*#__PURE__*/h.styled.div.withConfig({displayName:"StyledSection",componentId:"sc-523a75d6-1"})(["display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;text-align:left;gap:8px;width:100%;margin-bottom:24px;&& h3{font-size:17px;color:var(--privy-color-foreground);}&& p{color:var(--privy-color-foreground-2);font-size:14px;}"]),Ni=/*#__PURE__*/h.styled(_i).withConfig({displayName:"CenteredStyledSection",componentId:"sc-523a75d6-2"})(["align-items:center;text-align:center;gap:16px;h3{margin-bottom:24px;}"]);const Mi=({address:t,showCopyIcon:n,url:a,className:i})=>{let[o,s]=r.useState(!1);return r.useEffect((()=>{if(o){let e=setTimeout((()=>s(!1)),2e3);return()=>clearTimeout(e)}}),[o]),a?/*#__PURE__*/e.jsx("a",{title:t,className:i,href:`${a}/address/${t}`,target:"_blank",children:Lt(t)}):/*#__PURE__*/e.jsxs("button",{title:t,className:i,onClick:e=>(e.stopPropagation(),navigator.clipboard.writeText(t).then((()=>s(!0))).catch(console.error)),children:[Lt(t),n&&(o?/*#__PURE__*/e.jsx(Oi,{}):/*#__PURE__*/e.jsx(Wi,{}))]})};let Wi=/*#__PURE__*/h.styled(Ne.default).withConfig({displayName:"StyledSquare2StackIcon",componentId:"sc-6eaa0c94-0"})(["&&{display:inline;}stroke-width:2;height:0.875rem;width:0.875rem;margin-left:0.125rem;color:var(--privy-color-foreground-3);"]),Oi=/*#__PURE__*/h.styled(_e.default).withConfig({displayName:"StyledCheckIcon",componentId:"sc-6eaa0c94-1"})(["&&{display:inline;}stroke-width:2;height:0.875rem;width:0.875rem;margin-left:0.125rem;color:var(--privy-color-success);"]);const Ui=/*#__PURE__*/h.styled.div.withConfig({displayName:"Grow",componentId:"sc-ddbf22b4-0"})(["text-align:left;flex-grow:1;"]),Fi=/*#__PURE__*/h.styled.div.withConfig({displayName:"AlignBottom",componentId:"sc-ddbf22b4-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),Ri=/*#__PURE__*/h.styled.div.withConfig({displayName:"LoginMethodContainer",componentId:"sc-ddbf22b4-2"})(["display:flex;flex-direction:column;gap:12px;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]),Li=/*#__PURE__*/h.styled(Ri).withConfig({displayName:"LoginMethodContainerWithScrollShadows",componentId:"sc-ddbf22b4-3"})([""," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;max-height:400px;overflow-y:auto;scrollbar-width:none;padding:2px;"],(e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0));let Di=/*#__PURE__*/h.css(["&&{width:100%;font-size:16px;line-height:24px;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-mdlg);transition:background-color 200ms ease;cursor:pointer;&:hover{background-color:var(--privy-color-background-2);}&:disabled{cursor:pointer;background-color:var(--privy-color-background-2);}svg{height:24px;max-height:24px;max-width:24px;}}"]);const Bi=/*#__PURE__*/h.styled.div.withConfig({displayName:"Subtitle",componentId:"sc-ddbf22b4-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),zi=/*#__PURE__*/h.styled.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-ddbf22b4-5"})(["",""],Di),$i=/*#__PURE__*/h.styled.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-ddbf22b4-6"})(["",""],Di),Vi=/*#__PURE__*/h.styled.div.withConfig({displayName:"Hide",componentId:"sc-ddbf22b4-7"})(["width:100%;height:100%;min-height:inherit;display:flex;flex-direction:column;",""],(e=>e.$if?"display: none;":"")),qi=/*#__PURE__*/h.styled.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-ddbf22b4-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),Hi=/*#__PURE__*/h.styled.div.withConfig({displayName:"Header",componentId:"sc-ddbf22b4-9"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-bottom:32px;gap:12px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]),Ki=({chainType:t,withPadding:r})=>{let n="";return n="ethereum-only"===t||"ethereum-and-solana"===t?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/e.jsx(qi,{$withPadding:r,children:/*#__PURE__*/e.jsxs(Hi,{children:[/*#__PURE__*/e.jsx(Se.default,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/e.jsx("h3",{children:"No wallets available"}),/*#__PURE__*/e.jsxs("p",{children:["Please download an external wallet provider, like ",n,"."]})]})},"empty-wallet-state")},Zi=({icon:t,name:r})=>"string"==typeof t?/*#__PURE__*/e.jsx("img",{alt:`${r||"wallet"} logo`,src:t,style:{height:24,width:24,borderRadius:4}}):void 0===t?/*#__PURE__*/e.jsx(Me.default,{}):t?/*#__PURE__*/e.jsx(t,{}):null;let Gi=/*#__PURE__*/h.keyframes(["from,to{background:var(--privy-color-foreground-4);color:var(--privy-color-foreground-4);}50%{background:var(--privy-color-foreground-accent);color:var(--privy-color-foreground-accent);}"]);const Yi=/*#__PURE__*/h.css(["",""],(e=>e.$isLoading?/*#__PURE__*/h.css(["width:35%;animation:"," 2s linear infinite;border-radius:var(--privy-border-radius-sm);"],Gi):"")),Ji=({children:t,color:r,isLoading:n,isPulsing:a,...i})=>/*#__PURE__*/e.jsx(Xi,{$color:r,$isLoading:n,$isPulsing:a,...i,children:t});let Xi=/*#__PURE__*/h.styled.span.withConfig({displayName:"StyledSpan",componentId:"sc-eba15c9-0"})(["padding:0.125rem 0.5rem;font-size:0.75rem;font-weight:500;line-height:1.125rem;border-radius:var(--privy-border-radius-sm);display:flex;align-items:center;"," ",""],(e=>{let t,r;"green"===e.$color&&(t="var(--privy-color-success-dark)",r="var(--privy-color-success-light)"),"red"===e.$color&&(t="var(--privy-color-error)",r="var(--privy-color-error-light)"),"gray"===e.$color&&(t="var(--privy-color-foreground-2)",r="var(--privy-color-background-2)");let n=/*#__PURE__*/h.keyframes(["from,to{background-color:",";}50%{background-color:rgba(",",0.8);}"],r,r);/*#__PURE__*/return h.css(["color:",";background-color:",";",";"],t,r,e.$isPulsing&&/*#__PURE__*/h.css(["animation:"," 3s linear infinite;"],n))}),Yi);function Qi(e){let t=e.toLowerCase();return!!window?.webkit?.messageHandlers?.ReactNativeWebView||!!window?.ReactNativeWebView||["fbav","fban","instagram","snapchat","linkedinapp"].some((e=>t.includes(e)))}const eo={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},connectOrCreateWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},update:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},setWalletRecovery:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},signTransaction:{onSuccess:[],onError:[]},signSolanaTransaction:{onSuccess:[],onError:[]},signSolanaMessage:{onSuccess:[],onError:[]},sendSolanaTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]},fundSolanaWallet:{onUserExited:[]},customAuth:{onAuthenticated:[],onUnauthenticated:[]}},to=/*#__PURE__*/r.createContext(void 0);let ro=()=>r.useContext(to);function no(e,t){if(!t)return;let n=ro().current[e];return r.useEffect((()=>{for(let[r,a]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,r)||console.warn(`Invalid event type "${r}" for action "${e}"`),n[r]?.push(a);return()=>{for(let[r,a]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,r)||console.warn(`Invalid event type "${r}" for action "${e}"`),n[r]=n[r]?.filter((e=>e!==a))}}),[t])}function ao(e,t,r,...n){for(let a of e.current[t][r])a(...n)}function io(){let e=ro();return(t,r,...n)=>ao(e,t,r,...n)}let oo=/*#__PURE__*/r.createContext({});const so=({children:t})=>{let n=di(),[a,i]=r.useState({});return no("login",{onComplete:({loginAccount:e})=>{e&&"passkey"!==e.type&&"cross_app"!==e.type&&("wallet"!==e.type||"privy"!==e.walletClientType)&&(Nt.put(lo(n.id),e.type),"wallet"===e.type?(Nt.put(co(n.id),e.walletClientType),Nt.put(uo(n.id),e.chainType),i({accountType:e.type,walletClientType:e.walletClientType,chainType:e.chainType})):(Nt.del(co(n.id)),Nt.del(uo(n.id)),i({accountType:e.type})))}}),r.useEffect((()=>{if(!n.id)return;let e=Nt.get(lo(n.id)),t=Nt.get(co(n.id)),r=Nt.get(uo(n.id));e&&i("wallet"===e?{accountType:e,walletClientType:t,chainType:r}:{accountType:e})}),[n.id]),/*#__PURE__*/e.jsx(oo.Provider,{value:a,children:t})};let lo=e=>`privy:${e}:recent-login-method`,co=e=>`privy:${e}:recent-login-wallet-client`,uo=e=>`privy:${e}:recent-login-chain-type`;const po=()=>r.useContext(oo),ho=({success:t,fail:r})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(mo,{className:t?"success":r?"fail":""}),/*#__PURE__*/e.jsx(yo,{className:t?"success":r?"fail":""})]}),mo=/*#__PURE__*/h.styled.span.withConfig({displayName:"Loader",componentId:"sc-ce7792e2-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";border-bottom-color:transparent;border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1.2s linear infinite;transition:border-color 800ms;}@keyframes rotation{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}&&&.success{border-color:var(--privy-color-success);border-bottom-color:var(--privy-color-success);}&&&.fail{border-color:var(--privy-color-error);border-bottom-color:var(--privy-color-error);}"],(e=>e.color??"var(--privy-color-accent)")),yo=/*#__PURE__*/h.styled(mo).withConfig({displayName:"LoaderFaint",componentId:"sc-ce7792e2-1"})(["&&{border-bottom-color:",";animation:none;opacity:0.5;}"],(e=>e.color??"var(--privy-color-accent)")),fo=t=>/*#__PURE__*/e.jsx(go,{color:t.color||"var(--privy-color-foreground-3)"});let go=/*#__PURE__*/h.styled(mo).withConfig({displayName:"StyledButtonLoader",componentId:"sc-ce7792e2-2"})(["&&{height:1rem;width:1rem;margin:2px 0;border-width:1.5px;transition:border-color 200ms ease;}"]);const wo=/*#__PURE__*/h.styled.button.withConfig({displayName:"Button",componentId:"sc-3253171f-0"})(["display:flex;flex-direction:row;align-items:center;justify-content:center;user-select:none;&{width:100%;cursor:pointer;border-radius:var(--privy-border-radius-md);font-size:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{padding:12px 16px;}"]),vo=({children:t,loading:r,disabled:n,success:a,loadingText:i="Loading...",...o})=>/*#__PURE__*/e.jsx(jo,{disabled:r||n,success:a,...o,children:r?/*#__PURE__*/e.jsxs("span",{children:[/*#__PURE__*/e.jsx(fo,{}),i?/*#__PURE__*/e.jsx("span",{children:i}):null]}):t}),xo=({children:t,loading:r,disabled:n,...a})=>/*#__PURE__*/e.jsx(Co,{disabled:n,...a,children:r?/*#__PURE__*/e.jsx(fo,{color:"var(--privy-color-foreground-accent)"}):t});let Co=/*#__PURE__*/h.styled(wo).withConfig({displayName:"StyledPrimaryButtonWithoutGray",componentId:"sc-3253171f-1"})(["position:relative;&&{background-color:var(--privy-color-accent);color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:disabled,&:hover:disabled,&:active:disabled{cursor:not-allowed;pointer-events:none;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent-dark);}"]);const bo=({children:t,loading:r,disabled:n,loadingText:a="Loading...",...i})=>/*#__PURE__*/e.jsx(jo,{as:"a",disabled:r||n,...i,children:r?/*#__PURE__*/e.jsxs("span",{children:[/*#__PURE__*/e.jsx(fo,{}),a?/*#__PURE__*/e.jsx("span",{children:a}):null]}):t});let jo=/*#__PURE__*/h.styled(wo).withConfig({displayName:"StyledPrimaryButton",componentId:"sc-3253171f-2"})(["position:relative;&&{background-color:",";color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:",";}&:active{background-color:",";}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}"," > span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],(e=>e.warn?"var(--privy-color-error)":e.success?"var(--privy-color-success)":"var(--privy-color-accent)"),(e=>e.warn?"var(--privy-color-error)":e.success?"var(--privy-color-success)":"var(--privy-color-accent-dark)"),(e=>e.warn?"var(--privy-color-error)":e.success?"var(--privy-color-success)":"var(--privy-color-accent-dark)"),(e=>e.disabled?/*#__PURE__*/h.css(["&&&,&&&:hover,&&&:active{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;pointer-events:none;}"]):""));const ko=({children:t,loading:r,disabled:n,loadingText:a="Loading...",...i})=>/*#__PURE__*/e.jsx(Eo,{disabled:r||n,...i,children:r?/*#__PURE__*/e.jsxs("span",{children:[/*#__PURE__*/e.jsx(fo,{}),a?/*#__PURE__*/e.jsx("span",{children:a}):null]}):t});let Eo=/*#__PURE__*/h.styled(wo).withConfig({displayName:"StyledSecondaryButton",componentId:"sc-3253171f-3"})(["&&{border-width:1px;border-color:",";color:var(--privy-color-foreground);transition:border-color 200ms ease;}&:hover,&:active{border-color:",";}&:hover:disabled,&:active:disabled{border-color:var(--privy-color-foreground-accent);color:var(--privy-color-foreground-3);cursor:not-allowed;}> span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],(e=>e.warn?"var(--privy-color-error)":"var(--privy-color-foreground-4)"),(e=>e.warn?"var(--privy-color-error)":"var(--privy-color-foreground-3)"));const To=/*#__PURE__*/h.styled.button.withConfig({displayName:"SoftCtaButton",componentId:"sc-3253171f-4"})(["&&{padding:12px 16px;font-weight:500;text-align:center;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent);border-radius:var(--privy-border-radius-sm);min-width:144px;opacity:",";transition:opacity 200ms ease,background-color 200ms ease,color 200ms ease;user-select:none;"," &:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}}"],(e=>e.invisible?"0":"1"),(e=>e.invisible&&/*#__PURE__*/h.css(["pointer-events:none;"]))),Ao=({children:t,onClick:r,disabled:n,isSubmitting:a,...i})=>/*#__PURE__*/e.jsxs(Io,{$isSubmitting:a,onClick:r,disabled:n,...i,children:[/*#__PURE__*/e.jsx("span",{children:t}),
@@ -22,6 +22,6 @@ return e.jsx(uh,{...di().render.standalone?{defaultValue:"details"}:{},children:
22
22
  /*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(xw,{}),/*#__PURE__*/e.jsx(ey,{}),/*#__PURE__*/e.jsx("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/e.jsx(yi,{})]})}},lf={component:()=>{let{data:t,setModalData:n}=Qu(),a=t?.funding,i="solana"===a.chainType,o=r.useRef(null),{tokenPrice:s}=Ph(i?"solana":a.chain.id),l=i?void 0:a,c=!(!l?.erc20Address||l?.erc20ContractInfo),d=i?"SOL":a.erc20Address?a.erc20ContractInfo?.symbol:a.chain.nativeCurrency.symbol||"ETH",u=parseFloat(a.amount),p=!isNaN(u)&&u>0,h=s?Wp(a.amount,s):void 0;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(xw,{}),/*#__PURE__*/e.jsx(sc,{children:"Confirm or edit amount"}),/*#__PURE__*/e.jsxs(Wo,{style:{marginTop:"32px"},children:[/*#__PURE__*/e.jsx(Yy,{children:c?/*#__PURE__*/e.jsx(ey,{size:"50px"}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(Jy,{onClick:()=>o.current?.focus(),children:[/*#__PURE__*/e.jsx(Qy,{ref:o,value:a.amount,onChange:e=>{let r=e.target.value;/^[0-9.]*$/.test(r)&&r.split(".").length-1<=1&&n({...t,funding:{...a,amount:r}})}}),/*#__PURE__*/e.jsx(ef,{children:d})]}),!l?.erc20Address&&/*#__PURE__*/e.jsx(tf,{children:h&&p?`${h} USD`:""})]})}),/*#__PURE__*/e.jsx(xo,{style:{marginTop:"1rem"},disabled:!p,onClick:a.onContinueWithExternalWallet,children:"Continue"})]}),/*#__PURE__*/e.jsx(yi,{})]})}},cf={component:()=>{let t,{connectors:n}=i.usePrivyInternal(),{app:a,setModalData:o,data:s,navigate:l}=Qu(),{wallets:c}=Nh(),{wallets:d}=Gg(),[u,p]=r.useState("default"),h="solana"===s?.funding?.chainType,m=!!s?.funding?.crossChainBridgingEnabled;t="ethereum"===s?.funding?.chainType?s.funding.erc20Address&&!s.funding.isUSDC?"ethereum-only":m&&!s.funding.chain.testnet?"ethereum-and-solana":"ethereum-only":m?"ethereum-and-solana":"solana-only";let y=c.filter((e=>"privy"!==e.walletClientType)),f=y.map((e=>e.walletClientType)),g=d.filter((e=>"privy"!==e.walletClientType)),w=g.map((e=>e.walletClientType)),v=[],x={...s.funding};x.usingDefaultFundingMethod&&(x.usingDefaultFundingMethod=!1);let C=({address:e,walletChainType:t})=>{o({...s,funding:{...x,connectedWalletAddress:e,onContinueWithExternalWallet:()=>l(j({destChainType:h?"solana":"ethereum",sourceChainType:t}))}}),l(lf)};"solana-only"!==t&&v.push(...y.map(((t,r)=>/*#__PURE__*/e.jsx(df,{onClick:()=>C({address:t.address,walletChainType:"ethereum"}),icon:t.meta.icon,name:t.meta.name,chainType:t.type},r)))),"ethereum-only"!==t&&v.push(...g.map(((t,r)=>/*#__PURE__*/e.jsx(df,{onClick:()=>C({address:t.address,walletChainType:"solana"}),icon:t.meta.icon,name:t.meta.name,chainType:t.type},r)))),v.push(...Zu({walletList:a.appearance.walletList.filter((e=>!y.some((t=>t.walletClientType===e))&&!g.some((t=>t.walletClientType===e)))),walletChainType:t,connectors:n,connectOnly:!0,ignore:[...a.appearance.walletList,...f,...w],walletConnectEnabled:a.externalWallets.walletConnect.enabled}));let b=/*#__PURE__*/e.jsx(Dd,{text:"More wallets",onClick:()=>p("overflow")}),j=({sourceChainType:e,destChainType:t})=>"ethereum"===e&&"solana"===t?Cw:"ethereum"===e&&"ethereum"===t?of:"solana"===e&&"ethereum"===t?sf:yy;return r.useEffect((()=>{o({...s,externalConnectWallet:{onCompleteNavigateTo:({walletChainType:e})=>(o({...s,funding:{...x,onContinueWithExternalWallet:()=>{l(j({destChainType:h?"solana":"ethereum",sourceChainType:e??"ethereum"}))}}}),lf)}})}),[]),"overflow"===u?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:()=>p("default")},"header"),/*#__PURE__*/e.jsxs(Ri,{children:[/*#__PURE__*/e.jsx(oc,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),v]}),/*#__PURE__*/e.jsx(yi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(xw,{}),/*#__PURE__*/e.jsx(Pi,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),/*#__PURE__*/e.jsxs(Ri,{children:[v.length>4?v.slice(0,3):v,v.length>4&&b]}),/*#__PURE__*/e.jsx(yi,{})]})}};let df=({onClick:t,icon:r,name:n,chainType:a})=>/*#__PURE__*/e.jsxs(zi,{onClick:t,children:[/*#__PURE__*/e.jsx(Gy,{style:{width:20},children:/*#__PURE__*/e.jsx("img",{src:r})}),n,/*#__PURE__*/e.jsx(Ji,{color:"gray",style:{marginLeft:"auto"},children:"Connected"}),"solana"===a&&/*#__PURE__*/e.jsx(Ji,{color:"gray",children:"Solana"})]});const uf={component:()=>{let{data:t,setModalData:n,navigate:a,navigateBack:o}=Qu(),{closePrivyModal:s,createAnalyticsEvent:l,client:c}=i.usePrivyInternal(),[d,u]=r.useState("pending-in-flow"),p=r.useRef(0),h={...t?.funding,showAlternateFundingMethod:!0};h.usingDefaultFundingMethod&&(h.usingDefaultFundingMethod=!1);let{partnerUserId:m,popup:y}=t?.coinbaseOnrampStatus??{};return r.useEffect((()=>{if("pending-in-flow"===d||"pending-after-flow"===d){let e=setInterval((async()=>{if(m)try{let{status:e}=await c.getCoinbaseOnRampStatus({partnerUserId:m});if("success"===e)return void u("success");if("failure"===e)throw Error("There was an error completing Coinbase Onramp flow.");if(p.current>=3)return n({funding:h}),void a(If);y?.closed&&(p.current=p.current+1,u("pending-after-flow"))}catch(e){console.error(e),u("error"),l({eventName:_m,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),n({funding:{...h,errorMessage:"Something went wrong adding funds. Please try again or use another method."}}),a(If)}}),1500);return()=>clearInterval(e)}}),[m,y,d]),/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{title:"Fund account",backFn:()=>{n({funding:h}),o()}},"header"),/*#__PURE__*/e.jsx(pf,{status:d,onClickCta:s}),/*#__PURE__*/e.jsx(yi,{})]})}};let pf=({status:t,onClickCta:n})=>{let{title:a,body:i,cta:o}=r.useMemo((()=>(e=>{switch(e){case"success":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"pending-after-flow":return{title:"In Progress",body:"Almost done. Retrieving transaction status from Coinbase",cta:""};case"error":case"pending-in-flow":return{title:"In Progress",body:"Go back to Coinbase Onramp to finish funding your account.",cta:""}}})(t)),[t]);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(yf,{children:[/*#__PURE__*/e.jsx(hf,{isSucccess:"success"===t}),/*#__PURE__*/e.jsxs(Oo,{children:[/*#__PURE__*/e.jsx("h3",{children:a}),/*#__PURE__*/e.jsx(mf,{children:i})]})]}),o&&/*#__PURE__*/e.jsx(vo,{onClick:n,children:o})]})},hf=({isSucccess:t})=>{if(!t){let t="var(--privy-color-foreground-4)";/*#__PURE__*/return e.jsxs("div",{style:{position:"relative"},children:[/*#__PURE__*/e.jsx(mo,{color:t,style:{position:"absolute"}}),/*#__PURE__*/e.jsx(yo,{color:t}),/*#__PURE__*/e.jsx(Pn,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let r=(t=>t?Ke.default:()=>/*#__PURE__*/e.jsx(ht.default,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}}))(t),n=(e=>e?"var(--privy-color-success)":"var(--privy-color-foreground-4)")(t);/*#__PURE__*/return e.jsx("div",{style:{borderColor:n,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:r&&/*#__PURE__*/e.jsx(r,{width:"4rem",height:"4rem",color:n})})},mf=/*#__PURE__*/h.styled.p.withConfig({displayName:"StatusBody",componentId:"sc-ebf88779-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),yf=/*#__PURE__*/h.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-ebf88779-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);let ff={[Ln.id]:"ethereum",[On.id]:"base",[Dn.id]:"optimism",[zn.id]:"polygon",[_n.id]:"arbitrum"};const gf=(e,t,r,n,a,o)=>new Promise((async(s,l)=>{let c=wm();if(!c)return void l(Error("Unable to initialize flow"));let d="ethereum"===t.chainType?function(e){let t=ff[e];if(!t)throw new i.PrivyClientError(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}(t.chain.id):"solana",p=t.isUSDC?"USDC":"ethereum"===t.chainType?"ETH":"SOL",h=await e.initCoinbaseOnRamp({addresses:[{address:t.address,blockchains:[d]}],assets:[p]}),{url:m}=u.getCoinbaseOnRampUrl({input:h,amount:t.amount,blockchain:d,asset:p,experience:o});c.location=m.toString();let y={...a?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(y.usingDefaultFundingMethod=!1),r({funding:y,coinbaseOnrampStatus:{popup:c}}),n(uf),e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),setTimeout((()=>{r({funding:y,coinbaseOnrampStatus:{partnerUserId:h.partner_user_id,popup:c}})}),5e3),s()})),wf=({size:t=61,...r})=>/*#__PURE__*/e.jsx("svg",{width:t,height:t,viewBox:"0 0 61 61",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:/*#__PURE__*/e.jsxs("g",{id:"moonpay_symbol_wht 2",children:[/*#__PURE__*/e.jsx("rect",{x:"1.3374",y:"1",width:"59",height:"59",rx:"11.5",fill:"#7715F5"}),/*#__PURE__*/e.jsx("path",{id:"Vector",d:"M43.8884 23.3258C45.0203 23.3258 46.1268 22.9901 47.068 22.3613C48.0091 21.7324 48.7427 20.8386 49.1759 19.7928C49.6091 18.747 49.7224 17.5962 49.5016 16.4861C49.2807 15.3759 48.7357 14.3561 47.9353 13.5557C47.1349 12.7553 46.1151 12.2102 45.0049 11.9893C43.8947 11.7685 42.7439 11.8819 41.6982 12.3151C40.6524 12.7482 39.7585 13.4818 39.1297 14.423C38.5008 15.3641 38.1651 16.4707 38.1651 17.6026C38.165 18.3542 38.3131 19.0985 38.6007 19.7929C38.8883 20.4873 39.3098 21.1182 39.8413 21.6496C40.3728 22.1811 41.0037 22.6027 41.6981 22.8903C42.3925 23.1778 43.1367 23.3259 43.8884 23.3258ZM26.3395 49.1017C23.5804 49.1017 20.8832 48.2836 18.5891 46.7507C16.295 45.2178 14.5069 43.039 13.4511 40.49C12.3952 37.9409 12.1189 35.1359 12.6572 32.4298C13.1955 29.7237 14.5241 27.238 16.4751 25.287C18.4262 23.336 20.9118 22.0074 23.6179 21.4691C26.324 20.9308 29.129 21.2071 31.6781 22.2629C34.2272 23.3189 36.406 25.1069 37.9389 27.401C39.4717 29.6952 40.2899 32.3923 40.2899 35.1514C40.2899 36.9835 39.9291 38.7975 39.2281 40.49C38.527 42.1826 37.4994 43.7205 36.204 45.0159C34.9086 46.3113 33.3707 47.3389 31.6781 48.04C29.9856 48.741 28.1715 49.1018 26.3395 49.1017Z",fill:"white"})]})});const vf={component:()=>{let{app:t,data:n,setModalData:a,navigateBack:o}=Qu(),{closePrivyModal:s}=i.usePrivyInternal(),{externalTransactionId:l}=n?.moonpayStatus,c=function(e,t=!1){let[n,a]=r.useState(null),{createAnalyticsEvent:o}=i.usePrivyInternal(),{data:s,navigate:l,setModalData:c}=Qu(),d=s?.funding,u=r.useRef(0);return r.useEffect((()=>{let r=setInterval((async()=>{if(e)try{let[n]=await async function(e,t){return se.ofetch(`${t?Pr:Sr}/transactions/ext/${e}`,{query:{apiKey:t?Nr:_r}})}(e,t),i="waitingAuthorization"===n.status&&"credit_debit_card"===n.paymentMethod?"pending":n.status;if(["failed","completed","awaitingAuthorization"].includes(i)&&(o({eventName:_m,payload:{status:i,provider:Sf,paymentMethod:n.paymentMethod,cardPaymentType:n.cardPaymentType,currency:n.currency?.code,baseCurrencyAmount:n.baseCurrencyAmount,quoteCurrencyAmount:n.quoteCurrencyAmount,feeAmount:n.feeAmount,extraFeeAmount:n.extraFeeAmount,networkFeeAmount:n.networkFeeAmount,isSandbox:t}}),clearInterval(r)),"failed"===i||"serviceFailure"===i)return c({funding:{...d,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),void l(If);a(i)}catch(e){404!==e.response?.status&&(u.current+=1),u.current>=3&&(o({eventName:_m,payload:{status:"serviceFailure",provider:Sf}}),clearInterval(r),c({funding:{...d,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),l(If))}}),3e3);return()=>clearInterval(r)}),[e,u]),n}(l||null,t.fundingMethodConfig.moonpay.useSandbox??!1);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{title:"Fund account",backFn:()=>{let e={...n?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),a({funding:e}),o()}}),/*#__PURE__*/e.jsx(xf,{status:c,onClickCta:s}),/*#__PURE__*/e.jsx(yi,{})]})}};let xf=({status:t,onClickCta:n})=>{let{title:a,body:i,cta:o}=r.useMemo((()=>(e=>{switch(e){case"completed":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"waitingAuthorization":return{title:"Processing payment",body:"This may take up to a few hours. You will receive an email when the purchase is complete.",cta:"Continue"};default:return{title:"In Progress",body:"Go back to MoonPay to finish funding your account.",cta:""}}})(t)),[t]);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(jf,{children:[/*#__PURE__*/e.jsx(Cf,{status:t}),/*#__PURE__*/e.jsxs(Oo,{children:[/*#__PURE__*/e.jsx("h3",{children:a}),/*#__PURE__*/e.jsx(bf,{children:i})]})]}),o&&/*#__PURE__*/e.jsx(vo,{onClick:n,children:o})]})},Cf=({status:t})=>{if(!t||"pending"===t){let t="var(--privy-color-foreground-4)";/*#__PURE__*/return e.jsxs("div",{style:{position:"relative"},children:[/*#__PURE__*/e.jsx(mo,{color:t,style:{position:"absolute"}}),/*#__PURE__*/e.jsx(yo,{color:t}),/*#__PURE__*/e.jsx(wf,{size:"3rem",style:{position:"absolute",top:"1rem",left:"1rem"}})]})}let r=(t=>{switch(t){case"completed":return Ke.default;case"waitingAuthorization":return()=>/*#__PURE__*/e.jsx(ht.default,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}});default:return}})(t),n=(e=>e?{completed:"var(--privy-color-success)",failed:"var(--privy-color-error)",serviceFailure:"var(--privy-color-error)",waitingAuthorization:"var(--privy-color-accent)",pending:"var(--privy-color-foreground-4)"}[e]:"var(--privy-color-foreground-4)")(t);/*#__PURE__*/return e.jsx("div",{style:{borderColor:n,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:r&&/*#__PURE__*/e.jsx(r,{width:"4rem",height:"4rem",color:n})})},bf=/*#__PURE__*/h.styled.p.withConfig({displayName:"StatusBody",componentId:"sc-7f0a56e4-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),jf=/*#__PURE__*/h.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-7f0a56e4-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const kf=async(e,t,r,n,a,i,o,s)=>{let l=wm();if(!l)throw Error("Unable to initialize flow");let c="ethereum"===t.chainType?t.moonpayConfigOverride?.currencyCode??u.chainToMoonpayCurrency(t.chain.id,n):"SOL",{signedUrl:d,externalTransactionId:p}=await e.signMoonpayOnRampUrl({address:t.address,useSandbox:r.fundingMethodConfig.moonpay.useSandbox??!1,config:{uiConfig:{accentColor:r.appearance.palette.accent,theme:r.appearance.palette.colorScheme},...t.moonpayConfigOverride,paymentMethod:s,currencyCode:c,quoteCurrencyAmount:t.moonpayConfigOverride?.quoteCurrencyAmount??Pf(t.amount)}});e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"moonpay",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),l.location=d;let h={...o?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(h.usingDefaultFundingMethod=!1),a({moonpayStatus:{},funding:h}),i(vf),setTimeout((()=>{a({moonpayStatus:{externalTransactionId:p},funding:h})}),8e3)};let Ef=async e=>"undefined"!=typeof window&&"PaymentRequest"in window&&await new window.PaymentRequest([{supportedMethods:e}],{id:"0",total:{label:"Item",amount:{currency:"USD",value:"1.00"}}}).canMakePayment();const Tf=()=>Ef("https://apple.com/apple-pay"),Af=()=>Ef("https://google.com/pay"),If={component:()=>{let{wallets:t}=Nh(),{wallets:n}=Gg(),{navigate:o,data:s,setModalData:l}=Qu(),{client:c}=i.usePrivyInternal(),d=di(),p=s?.funding,h=Ym(Tf),m=Ym(Af),y="solana"===p.chainType,f=y?void 0:p,g=r.useMemo((()=>((e,t,r,n,a,i)=>{let o,s,l="solana"===r.chainType,c=l?void 0:r,d=r.isUSDC?"USDC":c?.erc20Address?void 0:"native-currency",p=!!l||d&&u.isSupportedChainIdForMoonpay(Number(r.chain.id),d),h=!!l||d&&u.isSupportedChainIdForCoinbaseOnramp(Number(r.chain.id),d),m=[];for(let o of(r.preferredCardProvider&&r.supportedOptions.sort((e=>e.provider===r.preferredCardProvider?-1:1)),r.supportedOptions))"card"===o.method&&"coinbase"===o.provider&&h&&m.push((()=>gf(t,r,n,a,i,"buy"))),"card"===o.method&&"moonpay"===o.provider&&p&&d&&m.push((()=>kf(t,r,e,d,n,a,i,"credit_debit_card")));for(let e of r.supportedOptions)"exchange"===e.method&&"coinbase"===e.provider&&h&&(o=()=>gf(t,r,n,a,i,"buy"));for(let e of i?.funding?.supportedOptions??[])"wallets"===e.method&&(s=()=>a(cf));return{onFundWithCard:m,onFundWithExchange:o,onFundWithWallet:s}})(d,c,p,l,o,s)),[d,c,p,s,l,o]);r.useEffect((()=>{if(p?.defaultFundingMethod&&p.usingDefaultFundingMethod)switch(l({funding:{...p,usingDefaultFundingMethod:!1}}),p?.defaultFundingMethod){case"card":g.onFundWithCard[0]&&g.onFundWithCard[0]();break;case"exchange":g.onFundWithExchange&&g.onFundWithExchange();break;case"wallet":g.onFundWithWallet&&g.onFundWithWallet();break;case"manual":o(Yg)}}),[]),r.useEffect((()=>{f?.erc20Address&&!f.erc20ContractInfo&&Xm({address:f.erc20Address,chain:f.chain,rpcConfig:d.rpcConfig,privyAppId:d.id}).then((e=>{l({...s,funding:{...f,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}})})).catch(console.error)}),[f?.erc20Address,f?.chain]);let w=y?n.find((({address:e})=>e===p.address)):t.find((({address:e})=>a.getAddress(e)===a.getAddress(p.address))),v=$a(w?.walletClientType||"unknown"),x=v?.name||"wallet",C=w&&"privy"!==w.walletClientType?x:d.name,b=!(!f?.erc20Address||f?.erc20ContractInfo);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(xw,{}),/*#__PURE__*/e.jsxs("h3",{children:["Add funds to your"," ",C?.toLowerCase().endsWith("wallet")?C:C+" wallet"]}),/*#__PURE__*/e.jsxs(Zy,{children:[p.errorMessage&&/*#__PURE__*/e.jsx(Hm,{theme:d.appearance.palette.colorScheme,children:p.errorMessage}),g.onFundWithCard?.[0]&&/*#__PURE__*/e.jsxs(zi,{disabled:b,onClick:g.onFundWithCard[0],children:[/*#__PURE__*/e.jsx(Gy,{children:/*#__PURE__*/e.jsx(ut.default,{style:{width:24}})}),"Pay with card",h?/*#__PURE__*/e.jsx(Zm,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):m?/*#__PURE__*/e.jsx(Gm,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):null]}),g.onFundWithExchange&&/*#__PURE__*/e.jsxs(zi,{disabled:b,onClick:g.onFundWithExchange,children:[/*#__PURE__*/e.jsx(Gy,{children:/*#__PURE__*/e.jsx(ht.default,{style:{width:24}})}),"Transfer from an exchange"]}),g.onFundWithWallet&&/*#__PURE__*/e.jsxs(zi,{disabled:b,onClick:g.onFundWithWallet,children:[/*#__PURE__*/e.jsx(Gy,{children:/*#__PURE__*/e.jsx(Jm,{style:{width:24}})}),"Transfer from wallet"]}),/*#__PURE__*/e.jsxs(zi,{disabled:b,onClick:()=>o(Yg),children:[/*#__PURE__*/e.jsx(Gy,{children:/*#__PURE__*/e.jsx(pt.default,{style:{width:24}})}),"Receive funds"]}),p?.showAlternateFundingMethod&&g.onFundWithCard?.[1]&&/*#__PURE__*/e.jsx(jm,{theme:d.appearance.palette.colorScheme,children:/*#__PURE__*/e.jsxs(rf,{children:["Having trouble or facing location restrictions?"," ",/*#__PURE__*/e.jsx(nf,{onClick:g.onFundWithCard[1],children:"Try a different provider."})]})})]}),/*#__PURE__*/e.jsx(yi,{})]})}},Sf="moonpay";function Pf(e){return parseFloat(e)}function _f(e){return!!e&&void 0!==e.config&&void 0!==e.provider}function Nf(e){return!!e&&(void 0!==e.chain||void 0!==e.amount)}const Mf={[Ln.id]:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",[Vn.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[Dn.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[Bn.id]:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",[zn.id]:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",[$n.id]:"0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",[On.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[Un.id]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[Mn.id]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[Wn.id]:"0x5425890298aed601595a70ab815c96711a31bc65",[_n.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[Nn.id]:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},Wf=({address:e,appConfig:t,fundWalletConfig:r,methodScreen:n,chainIdOverride:a,comingFromSendTransactionScreen:o=!1})=>{let s,l;if(!t.fundingConfig)throw Error("Wallet funding is not enabled");let c=Vm(t.fundingConfig.options);if(c.length<1)throw Error("Wallet funding is not enabled");s=a||(Nf(r)&&r.chain?r.chain.id:hm(t.fundingConfig.defaultRecommendedCurrency.chain));let d=t.chains.find((e=>e.id===s));if(!d)throw new i.PrivyClientError(`Funding chain ${s} is not in PrivyProvider chains list`);let u=Nf(r)&&r.amount?r.amount:t.fundingConfig.defaultRecommendedAmount,p=!1;function h(){if(!s)return;let e=Mf[s];c.find((e=>"wallets"===e.method))&&!e&&console.warn("Attempting to fund with USDC on chain where USDC address is not known. Funding via external wallet will be disabled."),l=e,p=!0}Nf(r)&&"asset"in r?"USDC"===r.asset?h():"string"!=typeof r.asset&&"erc20"in r.asset&&(p=((e,t)=>e===Mf[t.id])(l=r.asset.erc20,d)):"USDC"===t.fundingConfig.defaultRecommendedCurrency.asset&&h();let m=r?.defaultFundingMethod;return{chainType:"ethereum",address:e,amount:u,chain:d,erc20Address:l,erc20ContractInfo:p?{symbol:"USDC",decimals:6}:void 0,isUSDC:p,methodScreen:n,supportedOptions:c,comingFromSendTransactionScreen:o,defaultFundingMethod:m,usingDefaultFundingMethod:!!m,preferredCardProvider:r?.card?.preferredProvider,crossChainBridgingEnabled:t.fundingConfig.crossChainBridgingEnabled??!1,cluster:{name:"mainnet-beta",rpcUrl:t.solanaClusters["mainnet-beta"]},..._f(r)?{moonpayConfigOverride:r.config}:{},uiConfig:r&&"uiConfig"in r?r.uiConfig:void 0}};function Of({address:e,fundWalletConfig:t,appConfig:r,comingFromSendTransactionScreen:n,methodScreen:a}){if(!r.fundingConfig)throw Error("Wallet funding is not enabled");let i=Vm(r.fundingConfig.options);if(i.length<1)throw Error("Wallet funding is not enabled");let o=t?.amount??r.fundingConfig.defaultRecommendedAmount,s=t?.defaultFundingMethod;return{chainType:"solana",address:e,supportedOptions:i,amount:o,isUSDC:!1,methodScreen:a,comingFromSendTransactionScreen:n,cluster:{name:t?.cluster?.name??"mainnet-beta",rpcUrl:r.solanaClusters[t?.cluster?.name??"mainnet-beta"]},crossChainBridgingEnabled:r.fundingConfig.crossChainBridgingEnabled??!1,defaultFundingMethod:s,preferredCardProvider:t?.card?.preferredProvider,usingDefaultFundingMethod:!!s,uiConfig:t?.uiConfig}}const Uf=({children:t,theme:r})=>/*#__PURE__*/e.jsxs(Ff,{$theme:r,children:[/*#__PURE__*/e.jsx(Re.default,{width:"1.25rem",color:"dark"===r?"#FDE68A":"var(--privy-color-warn)"}),t]});let Ff=/*#__PURE__*/h.styled.div.withConfig({displayName:"Container",componentId:"sc-97f152b3-0"})(["display:flex;gap:0.5rem;background-color:",";"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);}"],(e=>"dark"===e.$theme?"var(--privy-color-background-2)":"var(--privy-color-warn-light)"),(e=>"dark"===e.$theme?"color: #FDE68A;":""));function Rf(t){let[n,a]=r.useState(t.dimensions.width),[i,o]=r.useState(void 0),s=r.useRef(null);r.useEffect((()=>{if(s.current&&void 0===n){let{width:e}=s.current.getBoundingClientRect();a(e)}let e=getComputedStyle(document.documentElement);o({background:e.getPropertyValue("--privy-color-background"),background2:e.getPropertyValue("--privy-color-background-2"),foreground3:e.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:e.getPropertyValue("--privy-color-foreground-accent"),accent:e.getPropertyValue("--privy-color-accent"),accentDark:e.getPropertyValue("--privy-color-accent-dark"),success:e.getPropertyValue("--privy-color-success")})}),[]);let l="ethereum"===t.walletToExport.chainType&&!t.walletToExport.imported;/*#__PURE__*/return e.jsx("div",{ref:s,children:n&&
23
23
  /*#__PURE__*/e.jsxs(Bf,{children:[/*#__PURE__*/e.jsx("iframe",{style:{position:"absolute",zIndex:1},width:n,height:t.dimensions.height,allow:"clipboard-write self *",src:$t(t.origin,`/apps/${t.appId}/embedded-wallets/export`,{client_id:t.appClientId,primaryAddress:t.primaryWallet.address,address:t.walletToExport.address,walletIndex:t.walletToExport.walletIndex,width:`${n}px`,caid:t.clientAnalyticsId,phrase_export:l,...i},{token:t.accessToken})}),/*#__PURE__*/e.jsx(zf,{children:"Loading..."}),l&&/*#__PURE__*/e.jsx(zf,{children:"Loading..."})]})})}const Lf={component:()=>{let[t,n]=r.useState(null),{authenticated:a,user:o,getAccessToken:s}=Vo(),{closePrivyModal:l,createAnalyticsEvent:c,clientAnalyticsId:d}=i.usePrivyInternal(),u=di(),{data:p,onUserCloseViaDialogOrKeybindRef:h}=Qu(),{onFailure:m,onSuccess:y,origin:f,appId:g,appClientId:w,walletToExport:v,primaryWallet:x}=p.keyExport,C=e=>{l({shouldCallAuthOnSuccess:!1}),m("string"==typeof e?Error(e):e)},b=()=>{l({shouldCallAuthOnSuccess:!1}),y(),c({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:v.address}})};return r.useEffect((()=>{if(!a||!v)return C("User must be authenticated before exporting their wallet");s().then(n,C)}),[a,o]),h.current=b,/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:b}),/*#__PURE__*/e.jsxs(Df,{children:[/*#__PURE__*/e.jsx(sc,{children:"Transfer wallet"}),/*#__PURE__*/e.jsxs(oc,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",/*#__PURE__*/e.jsx("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),/*#__PURE__*/e.jsx(Uf,{theme:u.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),/*#__PURE__*/e.jsx(Sm,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:v.address,showIcon:!0}),/*#__PURE__*/e.jsx("div",{style:{width:"100%"},children:t&&/*#__PURE__*/e.jsx(Rf,{origin:f,appId:g,appClientId:w,accessToken:t,clientAnalyticsId:d,walletToExport:v,primaryWallet:x,dimensions:{height:"44px"}})})]}),/*#__PURE__*/e.jsx(yi,{})]})}};let Df=/*#__PURE__*/h.styled.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-f9e8f1f7-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),Bf=/*#__PURE__*/h.styled.div.withConfig({displayName:"ButtonContainer",componentId:"sc-f9e8f1f7-1"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),zf=/*#__PURE__*/h.styled.div.withConfig({displayName:"LoadingButton",componentId:"sc-f9e8f1f7-2"})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:16px;font-weight:500;border-radius:var(--privy-border-radius-md);background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);"]);const $f={component:()=>{let{authenticated:t,user:n,getAccessToken:a}=Vo(),{closePrivyModal:o,createAnalyticsEvent:s,walletProxy:l}=i.usePrivyInternal(),{navigate:c,data:d,setModalData:u,onUserCloseViaDialogOrKeybindRef:p}=Qu(),h=r.useMemo((()=>Date.now()),[]),[m,y]=r.useState(!1),{onCompleteNavigateTo:f,onFailure:g,shouldForceMFA:w,entropyId:v,entropyIdVerifier:x,recoveryMethod:C,connectingWalletAddress:b}=d?.connectWallet,j=e=>{m||(y(!0),g("string"==typeof e?Error(e):e))};r.useEffect((()=>{let e;return t?l?((async()=>{let t=await a();if(!t)return j("User must be authenticated and have a Privy wallet before it can be connected");try{await l.connect({accessToken:t,entropyId:v,entropyIdVerifier:x}),w&&await l.verifyMfa({accessToken:t});let r=(Date.now()-h)/1e3;f===Lf&&r<1?e=setTimeout((()=>{c(f,!1)}),1e3*(1-r)):c(f,!1)}catch(e){if(ds(e)&&"privy"===C){let e=await a();if(!e)return j("User must be authenticated and have a Privy wallet before it can be recovered");try{s({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:b}});let t=await(l?.recover({accessToken:e,entropyId:v,entropyIdVerifier:x}));t?.entropyId||j(Error("Unable to recover wallet")),f?c(f):o({shouldCallAuthOnSuccess:!1}),s({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:b}}),c(f)}catch(e){j("An error has occurred, please try again.")}}else ds(e)&&"privy"!==C?(u({...d,recoverWallet:{entropyId:v,entropyIdVerifier:x,onCompleteNavigateTo:f,onFailure:g},recoveryOAuthStatus:{provider:C,action:"recover",isInAccountCreateFlow:!1}}),c(uc(C))):j(e)}})(),()=>clearTimeout(e)):void 0:j("User must be authenticated and have a Privy wallet before it can be connected")}),[t,n,l]);let k=()=>{j("User exited before wallet could be connected"),o({shouldCallAuthOnSuccess:!1})};return p.current=k,/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:k}),m?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(Mo,{children:[/*#__PURE__*/e.jsx(ze.default,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/e.jsx(Pi,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),/*#__PURE__*/e.jsx(vo,{onClick:()=>o({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):/*#__PURE__*/e.jsx(Vs,{}),/*#__PURE__*/e.jsx(Vf,{})]})}};let Vf=/*#__PURE__*/h.styled.div.withConfig({displayName:"BottomSpacing",componentId:"sc-dfa076bb-0"})(["height:44px;"]);const qf=/*#__PURE__*/h.styled(sy).withConfig({displayName:"InteractiveLabel",componentId:"sc-b57d0824-0"})(["cursor:pointer;display:inline-flex;gap:8px;align-items:center;color:var(--privy-color-accent);svg{fill:var(--privy-color-accent);}"]);var Hf=({iconUrl:t,value:r,symbol:n,usdValue:a,nftName:i,$isLoading:o})=>o?/*#__PURE__*/e.jsx(Kf,{$isLoading:o}):/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsxs(Kf,{$isLoading:o,children:[t&&/*#__PURE__*/e.jsx(Gf,{src:t,alt:"Token icon"}),i,r," ",n]}),a&&/*#__PURE__*/e.jsxs(Zf,{$isLoading:o,children:["$",a]})]});let Kf=/*#__PURE__*/h.styled.span.withConfig({displayName:"Value",componentId:"sc-d8e62921-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],Yi);const Zf=/*#__PURE__*/h.styled.span.withConfig({displayName:"Subvalue",componentId:"sc-d8e62921-1"})(["color:var(--privy-color-foreground-2);font-size:12px;font-weight:400;line-height:18px;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],Yi);let Gf=/*#__PURE__*/h.styled.img.withConfig({displayName:"TokenIcon",componentId:"sc-d8e62921-2"})(["height:14px;width:14px;margin-right:4px;object-fit:contain;"]);const Yf=t=>{let{chain:r,transactionDetails:n,isTokenContractInfoLoading:a,symbol:i}=t,{action:s,functionName:l}=n;/*#__PURE__*/return e.jsx(Im,{children:/*#__PURE__*/e.jsxs(iy,{children:["transaction"!==s&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Action"}),/*#__PURE__*/e.jsx(cy,{children:l})]}),"mint"===l&&"args"in n&&n.args.filter((e=>e)).map(((t,n)=>/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:`Param ${n}`}),/*#__PURE__*/e.jsx(cy,{children:"string"==typeof t&&o.isAddress(t)?/*#__PURE__*/e.jsx(Mi,{address:t,url:r?.blockExplorers?.default?.url,showCopyIcon:!1}):t?.toString()})]},n))),"setApprovalForAll"===l&&n.operator&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Operator"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:n.operator,url:r?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===l&&void 0!==n.approved&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Set approval to"}),/*#__PURE__*/e.jsx(cy,{children:n.approved?"true":"false"})]}),"transfer"===l||"transferFrom"===l||"safeTransferFrom"===l||"approve"===l?/*#__PURE__*/e.jsxs(e.Fragment,{children:["formattedAmount"in n&&n.formattedAmount&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Amount"}),/*#__PURE__*/e.jsxs(cy,{$isLoading:a,children:[n.formattedAmount," ",i]})]}),"tokenId"in n&&n.tokenId&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Token ID"}),/*#__PURE__*/e.jsx(cy,{children:n.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===l&&/*#__PURE__*/e.jsxs(e.Fragment,{children:["amounts"in n&&n.amounts&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Amounts"}),/*#__PURE__*/e.jsx(cy,{children:n.amounts.join(", ")})]}),"tokenIds"in n&&n.tokenIds&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Token IDs"}),/*#__PURE__*/e.jsx(cy,{children:n.tokenIds.join(", ")})]})]}),"approve"===l&&n.spender&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Spender"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:n.spender,url:r?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===l||"safeTransferFrom"===l||"safeBatchTransferFrom"===l)&&n.transferFrom&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Transferring from"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:n.transferFrom,url:r?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===l||"safeTransferFrom"===l||"safeBatchTransferFrom"===l)&&n.transferTo&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Transferring to"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:n.transferTo,url:r?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})};let Jf={success:"background: var(--privy-color-success-lightest, #dcfce7);",warn:"background: var(--privy-color-warn-lightest, #fff7e6);",error:"background: var(--privy-color-error-lightest, #fde8e8);"};const Xf=/*#__PURE__*/h.styled.div.withConfig({displayName:"Pill",componentId:"sc-8c138024-0"})(["border-radius:var(--privy-border-radius-md,8px);padding:12px;text-align:left;margin-top:23px;",""],(e=>Jf[e.variant])),Qf=({variant:t,setPreventMaliciousTransaction:r,preventMaliciousTransaction:n})=>"warn"===t?/*#__PURE__*/e.jsx(Xf,{variant:t,children:/*#__PURE__*/e.jsxs("div",{className:"flex flex-row",children:[/*#__PURE__*/e.jsx(eg,{variant:t}),/*#__PURE__*/e.jsxs("p",{children:[/*#__PURE__*/e.jsx("b",{children:"Warning: Suspicious transaction"}),/*#__PURE__*/e.jsx("br",{}),"This has been flagged as a potentially deceptive request. Approving could put your assets or funds at risk."]})]})}):"error"===t?/*#__PURE__*/e.jsx(Xf,{variant:t,children:/*#__PURE__*/e.jsxs("div",{className:"flex flex-col",children:[/*#__PURE__*/e.jsxs("div",{className:"flex flex-row",children:[/*#__PURE__*/e.jsx(eg,{variant:t}),/*#__PURE__*/e.jsxs("p",{children:[/*#__PURE__*/e.jsx("b",{children:"This is a malicious transaction"}),/*#__PURE__*/e.jsx("br",{}),"This transaction transfers tokens to a known malicious address. Proceeding may result in the loss of valuable assets."]})]}),/*#__PURE__*/e.jsxs("div",{className:"mt-3 flex flex-row gap-2",children:[/*#__PURE__*/e.jsx(El,{color:"var(--privy-color-error)",checked:!n,readOnly:!0,onClick:()=>r(!n)}),/*#__PURE__*/e.jsx("p",{children:"I understand and want to proceed anyways."})]})]})}):void 0;let eg=/*#__PURE__*/h.styled(Re.default).withConfig({displayName:"StyledExclamationTriangleIcon",componentId:"sc-e6305f32-0"})(["width:20px;height:20px;stroke-width:2px;flex-shrink:0;display:inline-block;margin-right:8px;",";"],(e=>"error"===e.variant?"color: var(--privy-color-error)":"color: var(--privy-color-warn)"));const tg=({transactionIndex:e,maxIndex:t})=>"number"!=typeof e||0===t?"":` (${e+1} / ${t+1})`,rg=({img:t,submitError:n,prepareError:a,onClose:i,action:o,title:s,subtitle:l,txValue:c,to:d,tokenAddress:u,network:p,missingFunds:h,fee:m,from:y,cta:f,disabled:g,chain:w,isSubmitting:v,isPreparing:x,isTokenPriceLoading:C,isTokenContractInfoLoading:b,isSponsored:j,symbol:k,balance:E,onClick:T,transactionDetails:A,transactionIndex:I,maxIndex:S,onBack:P,chainName:_,validation:N,hasScanDetails:M,setIsScanDetailsOpen:W,preventMaliciousTransaction:O,setPreventMaliciousTransaction:U,tokensSent:F,tokensReceived:R,isScanning:L,isCancellable:D})=>{let{showTransactionDetails:B,setShowTransactionDetails:z,hasMoreDetails:$,isErc20Ish:V}=(e=>{let[t,n]=r.useState(!1),a=!0,i=!1;return(!e||e.isErc20Ish||"transaction"===e.action)&&(a=!1),a&&(i=Object.entries(e||{}).some((([e,t])=>t&&!["action","isErc20Ish","isNFTIsh"].includes(e)))),{showTransactionDetails:t,setShowTransactionDetails:n,hasMoreDetails:a&&i,isErc20Ish:e?.isErc20Ish}})(A),q=V&&b||x||C||L;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:i,backFn:P}),t&&/*#__PURE__*/e.jsx(og,{children:t}),/*#__PURE__*/e.jsxs(sc,{style:{marginTop:t?"1.5rem":0},children:[s,/*#__PURE__*/e.jsx(tg,{maxIndex:S,transactionIndex:I})]}),/*#__PURE__*/e.jsx(oc,{children:l}),/*#__PURE__*/e.jsxs(iy,{style:{marginTop:"2rem"},children:[(!!F[0]||q)&&/*#__PURE__*/e.jsxs(oy,{children:[R.length>0?/*#__PURE__*/e.jsx(sy,{children:"Send"}):/*#__PURE__*/e.jsx(sy,{children:"Amount"}),/*#__PURE__*/e.jsx(Hf,{iconUrl:F[0]?.iconUrl,value:F[0]?.value,usdValue:F[0]?.usdValue,symbol:F[0]?.symbol,nftName:F[0]?.nftName,$isLoading:q})]}),R.length>0&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Receive"}),/*#__PURE__*/e.jsx("div",{className:"flex flex-col",children:R.map(((t,r)=>/*#__PURE__*/e.jsx(Hf,{iconUrl:t.iconUrl,value:t.value,usdValue:t.usdValue,symbol:t.symbol,nftName:t.nftName},r)))})]}),A&&"spender"in A&&A?.spender?/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Spender"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:A.spender,url:w?.blockExplorers?.default?.url,showCopyIcon:!1})})]}):null,d&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"To"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:d,url:w?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),u&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Token address"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:u,url:w?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Network"}),/*#__PURE__*/e.jsx(cy,{children:p})]}),/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Estimated fee"}),/*#__PURE__*/e.jsx(cy,{$isLoading:x||C||void 0===j,children:j?"Sponsored":m})]}),$&&!M&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(oy,{className:"cursor-pointer",onClick:()=>z(!B),children:/*#__PURE__*/e.jsxs(ly,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/e.jsx(le.ChevronDownIcon,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:B?"rotate(180deg)":void 0}})]})}),B&&A&&/*#__PURE__*/e.jsx(Yf,{action:o,chain:w,transactionDetails:A,isTokenContractInfoLoading:b,symbol:k})]}),M&&/*#__PURE__*/e.jsx(oy,{children:/*#__PURE__*/e.jsxs(qf,{onClick:()=>W(!0),children:[/*#__PURE__*/e.jsx("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/e.jsx(le.ArrowRightIcon,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/e.jsx(Ui,{}),n?/*#__PURE__*/e.jsx(lu,{style:{marginTop:"2rem"},children:n.message}):a?/*#__PURE__*/e.jsx(lu,{style:{marginTop:"2rem"},children:a.shortMessage??ig}):null,/*#__PURE__*/e.jsx(Qf,{variant:N,preventMaliciousTransaction:O,setPreventMaliciousTransaction:U}),/*#__PURE__*/e.jsx(ag,{$useSmallMargins:!(!a&&!n&&"warn"!==N&&"error"!==N),title:Number(c)>0?void 0:!1!==j?"Your wallet":void 0,address:y,balance:E,isLoading:x||C,errMsg:x||a||n||!h?void 0:`Add funds on ${w?.name??_} to complete transaction.`}),/*#__PURE__*/e.jsx(vo,{style:{marginTop:"1rem"},loading:v,disabled:g||x,onClick:T,children:f}),D&&/*#__PURE__*/e.jsx(Ao,{style:{marginTop:"1rem"},onClick:i,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/e.jsx(yi,{})]})},ng=({img:t,title:r,subtitle:n,cta:a,network:i,blockExplorerUrl:o,transactionIndex:s,maxIndex:l,isMissingFunds:c,submitError:d,parseError:u,total:p,amount:h,fee:m,balance:y,from:f,to:g,tokenAddress:w,tokenAccount:v,tokenAccountOwner:x,programAddress:C,transactingWalletAddress:b,disabled:j,isSubmitting:k,isPreparing:E,isTokenPriceLoading:T,onClick:A,onClose:I,onBack:S})=>{let P=E||T;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:I,backFn:S}),t&&/*#__PURE__*/e.jsx(og,{children:t}),/*#__PURE__*/e.jsxs(sc,{style:{marginTop:t?"1.5rem":0},children:[r,/*#__PURE__*/e.jsx(tg,{maxIndex:l,transactionIndex:s})]}),/*#__PURE__*/e.jsx(oc,{children:n}),/*#__PURE__*/e.jsxs(iy,{style:{marginTop:"2rem"},children:[(p||P)&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Total"}),/*#__PURE__*/e.jsx(cy,{$isLoading:P,children:p})]}),f&&f!==b&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"From"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:f,url:o,showCopyIcon:!1})})]}),g&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"To"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:g,url:o,showCopyIcon:!1})})]}),x&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Token account owner"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:x,url:o,showCopyIcon:!1})})]}),v&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Token account"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:v,url:o,showCopyIcon:!1})})]}),w&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Token address"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:w,url:o,showCopyIcon:!1})})]}),C&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Program address"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Mi,{address:C,url:o,showCopyIcon:!1})})]}),i&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Network"}),/*#__PURE__*/e.jsx(cy,{children:i})]}),(h||P)&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Amount"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(cy,{$isLoading:P,children:h})})]}),(m||P)&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Estimated fee"}),/*#__PURE__*/e.jsx(cy,{$isLoading:P,children:m})]})]}),/*#__PURE__*/e.jsx(Ui,{}),d?/*#__PURE__*/e.jsx(lu,{style:{marginTop:"2rem"},children:d.message}):u?/*#__PURE__*/e.jsx(lu,{style:{marginTop:"2rem"},children:ig}):null,/*#__PURE__*/e.jsx(ag,{$useSmallMargins:!(!u&&!d),title:"Your wallet",address:b,balance:y,isLoading:E||T,errMsg:E||u||d||!c?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/e.jsx(vo,{style:{marginTop:"1rem"},loading:k,disabled:j||E,onClick:A,children:a}),/*#__PURE__*/e.jsx(yi,{})]})};let ag=/*#__PURE__*/h.styled(Sm).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-4bd3bb7d-0"})(["",""],(e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;")),ig="There was an error preparing your transaction. Your transaction request will likely fail.",og=/*#__PURE__*/h.styled.div.withConfig({displayName:"ImageContainer",componentId:"sc-4bd3bb7d-1"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),sg=()=>/*#__PURE__*/e.jsxs(pg,{children:[/*#__PURE__*/e.jsx(mg,{}),/*#__PURE__*/e.jsx(hg,{})]});const lg=({transactionError:t,chainId:n,onClose:a,onRetry:o,network:s,connection:l,transactionHash:c})=>{let{chains:d}=i.usePrivyInternal(),[u,p]=r.useState(!1),{errorCode:h,errorMessage:m}=((e,t)=>{if("ethereum"===t)return{errorCode:e.details??e.message,errorMessage:e.shortMessage};let r=e.txSignature,n=e?.transactionMessage||"Something went wrong.";if(Array.isArray(e.logs)){let t=e.logs.find((e=>/insufficient (lamports|funds)/gi.test(e)));t&&(n=t)}return{transactionHash:r,errorMessage:n}})(t,s),y=(({chains:e,chainId:t,network:r,connection:n,transactionHash:a})=>"ethereum"===r?e.find((e=>e.id===t))?.blockExplorers?.default.url??"https://etherscan.io":function(e,t){return`https://explorer.solana.com/tx/${e}?cluster=${t}`}(a||"",ei(n?.rpcEndpoint||"")))({chains:d,chainId:n,network:s,connection:l,transactionHash:c});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:a}),/*#__PURE__*/e.jsxs(cg,{children:[/*#__PURE__*/e.jsx(sg,{}),/*#__PURE__*/e.jsx(dg,{children:h}),/*#__PURE__*/e.jsx(ug,{children:"Please try again."}),/*#__PURE__*/e.jsxs(gg,{children:[/*#__PURE__*/e.jsx(fg,{children:"Error message"}),/*#__PURE__*/e.jsx(vg,{$clickable:!1,children:m})]}),c&&/*#__PURE__*/e.jsxs(gg,{children:[/*#__PURE__*/e.jsx(fg,{children:"Transaction hash"}),/*#__PURE__*/e.jsxs(wg,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/e.jsx("u",{children:/*#__PURE__*/e.jsx("a",{href:y,children:"block explorer"})}),"."]}),/*#__PURE__*/e.jsxs(vg,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(c),p(!0)},children:[c,/*#__PURE__*/e.jsx(bg,{clicked:u})]})]}),/*#__PURE__*/e.jsx(yg,{onClick:()=>o({resetNonce:!!c}),children:"Retry transaction"})]}),/*#__PURE__*/e.jsx(fi,{})]})};let cg=/*#__PURE__*/h.styled.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-6e9001c5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),dg=/*#__PURE__*/h.styled.span.withConfig({displayName:"ErrorCode",componentId:"sc-6e9001c5-1"})(["color:var(--privy-color-foreground);text-align:center;font-size:1.125rem;font-weight:500;line-height:1.25rem;text-align:center;margin:10px;"]),ug=/*#__PURE__*/h.styled.span.withConfig({displayName:"Subtitle",componentId:"sc-6e9001c5-2"})(["margin-top:4px;margin-bottom:10px;color:var(--privy-color-foreground-3);text-align:center;font-size:0.875rem;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;"]),pg=/*#__PURE__*/h.styled.div.withConfig({displayName:"CircleContainer",componentId:"sc-6e9001c5-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),hg=/*#__PURE__*/h.styled(Le.default).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-6e9001c5-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),mg=/*#__PURE__*/h.styled.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-6e9001c5-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),yg=/*#__PURE__*/h.styled(vo).withConfig({displayName:"RetryButton",componentId:"sc-6e9001c5-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),fg=/*#__PURE__*/h.styled.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-6e9001c5-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),gg=/*#__PURE__*/h.styled.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-6e9001c5-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),wg=/*#__PURE__*/h.styled.text.withConfig({displayName:"HelperText",componentId:"sc-6e9001c5-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),vg=/*#__PURE__*/h.styled.span.withConfig({displayName:"TextBox",componentId:"sc-6e9001c5-10"})(["position:relative;width:100%;background-color:var(--privy-color-background-2);padding:8px 12px;border-radius:10px;margin-top:5px;font-size:14px;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;",""],(e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }")),xg=/*#__PURE__*/h.styled(yt.default).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-6e9001c5-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),Cg=/*#__PURE__*/h.styled(Qe.default).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-6e9001c5-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),bg=({clicked:t})=>t?/*#__PURE__*/e.jsx(Cg,{}):/*#__PURE__*/e.jsx(xg,{});const jg=({instructions:t,fees:n,transactionInfo:a,solPrice:i,rpcEndpoint:o})=>{let s=t.reduce(((e,{amount:t,token:r})=>t&&"SOL"===r?.symbol?e+t:e),0n),[l,c]=r.useState(0),[d,u]=r.useState(!1),p=t[l];/*#__PURE__*/return e.jsxs(iy,{children:[/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Total"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Qp,{quantities:[s,n],tokenPrice:i})})]}),a&&a.action&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Action"}),/*#__PURE__*/e.jsx(cy,{children:a.action})]}),/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Fees"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Qp,{quantities:[n||0n],tokenPrice:i})})]}),t.length>1?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(oy,{children:/*#__PURE__*/e.jsxs(qf,{onClick:()=>u((e=>!e)),children:[/*#__PURE__*/e.jsx("span",{children:"Details"}),/*#__PURE__*/e.jsx(st.default,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:d?"rotate(180deg)":void 0}})]})}),d&&/*#__PURE__*/e.jsx(oy,{children:/*#__PURE__*/e.jsxs(Eg,{children:[/*#__PURE__*/e.jsxs(Tg,{children:[/*#__PURE__*/e.jsxs(Ag,{children:[l+1," of ",t.length," instructions"]}),/*#__PURE__*/e.jsxs(Sg,{children:[l>0&&/*#__PURE__*/e.jsx(gi,{backFn:()=>c((e=>e-1))}),l<t.length-1&&/*#__PURE__*/e.jsx(wi,{nextFn:()=>c((e=>e+1))})]})]}),/*#__PURE__*/e.jsx(Ig,{children:/*#__PURE__*/e.jsx(kg,{instruction:p,rpcEndpoint:o,solPrice:i})})]})})]}):/*#__PURE__*/e.jsx(kg,{instruction:p,rpcEndpoint:o,solPrice:i,hideAmount:!0})]})};function kg({instruction:t,rpcEndpoint:r,solPrice:n,hideAmount:a}){return t?/*#__PURE__*/e.jsxs(iy,{children:[!a&&!!t.amount&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Amount"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(Qp,{quantities:[t.amount],tokenPrice:n,tokenSymbol:t.token?.symbol??"SOL",tokenDecimals:t.token?.decimals??9})})]}),t.to&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"To"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(kh,{walletAddress:t.to,rpcEndpoint:r,network:"solana"})})]}),t.tokenAccount&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Token account"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(kh,{walletAddress:t.tokenAccount,rpcEndpoint:r,network:"solana"})})]}),t.tokenAccountOwner&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"Token account owner"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(kh,{walletAddress:t.tokenAccountOwner,rpcEndpoint:r,network:"solana"})})]}),t.from&&/*#__PURE__*/e.jsxs(oy,{children:[/*#__PURE__*/e.jsx(sy,{children:"From"}),/*#__PURE__*/e.jsx(cy,{children:/*#__PURE__*/e.jsx(kh,{walletAddress:t.from,rpcEndpoint:r,network:"solana"})})]})]}):null}let Eg=/*#__PURE__*/h.styled.div.withConfig({displayName:"InstructionsBox",componentId:"sc-5a140027-0"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),Tg=/*#__PURE__*/h.styled.header.withConfig({displayName:"InstructionsBoxHeader",componentId:"sc-5a140027-1"})(["display:flex;justify-content:space-between;align-items:center;padding:12px;background-color:var(--privy-color-background-2);"]),Ag=/*#__PURE__*/h.styled.h4.withConfig({displayName:"HeaderTitle",componentId:"sc-5a140027-2"})(["font-size:14px;font-weight:500;line-height:19.6px;"]),Ig=/*#__PURE__*/h.styled.div.withConfig({displayName:"InstructionsBoxContent",componentId:"sc-5a140027-3"})(["padding:12px;"]),Sg=/*#__PURE__*/h.styled.div.withConfig({displayName:"NavigationButtonsConatiner",componentId:"sc-5a140027-4"})(["display:flex;gap:8px;align-items:center;"]);const Pg=({instructions:t,fees:r,onClose:n,receiptHeader:a,receiptDescription:i,transactionInfo:o,solPrice:s,rpcEndpoint:l,signOnly:c})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:n}),/*#__PURE__*/e.jsx(Jo,{style:{marginBottom:"16px"},children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(Yo,{color:"var(--privy-color-success-light)"}),/*#__PURE__*/e.jsx(ct.default,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),/*#__PURE__*/e.jsx(Pi,{title:a??`Transaction ${c?"signed":"complete"}!`,description:i??"You're all set."}),/*#__PURE__*/e.jsx(jg,{solPrice:s,instructions:t,fees:r,transactionInfo:o,rpcEndpoint:l}),/*#__PURE__*/e.jsx(Ui,{}),/*#__PURE__*/e.jsx(_g,{loading:!1,onClick:n,children:"Close"}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]});let _g=/*#__PURE__*/h.styled(vo).withConfig({displayName:"SubmitButton",componentId:"sc-6f95cdcf-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const Ng={component:()=>{let{data:t,onUserCloseViaDialogOrKeybindRef:n,setModalData:a,navigate:s}=Qu(),{client:l,closePrivyModal:c,walletProxy:d,showFiatPrices:p}=i.usePrivyInternal(),h=di(),{user:m,getAccessToken:y}=Vo(),[f,g]=r.useState(t?.sendSolanaTransaction?.transactionRequest),[w,v]=r.useState(),[x,C]=r.useState(),[b,j]=r.useState(0),[k,E]=r.useState({value:0n,isLoading:!1}),[T,A]=r.useState(!1),[I,S]=r.useState(),[P,_]=r.useState(),N=t?.sendSolanaTransaction?.connection,M=t?.sendSolanaTransaction?.transactingWallet,W=t?.sendSolanaTransaction?.signOnly??!1,O=w?.instructions.length??1,U=M?.imported?jn(m):En(m),F=ei(N?.rpcEndpoint||""),{solPrice:R,isSolPriceLoading:L}=Sh({enabled:p}),D=r.useMemo((()=>{let e,t;if(!w)return;let r=w.spender;0===b&&M?.address===r&&(e=zp(w.fee));let n=zp(k.value,3,!0),a=w.instructions[b];if(!a)return{fee:e,spender:r,balance:n};if("unknown"===a.type)return{fee:e,spender:r,program:a.program,balance:n};if("ata-creation"===a.type)return{fee:e,spender:r,balance:n,tokenAccountOwner:a.owner,tokenAccount:a.ata,tokenAddress:a.mint};let i=a.fromAccount,s="sol-transfer"===a.type?a.toAccount:a.toAccount||a.toAta,l="spl-transfer"===a.type?a.token.address:void 0;return null!=e&&"SOL"===a.token.symbol&&(t=zp(a.value+w.fee)),{fee:e,spender:r,from:i,to:s,tokenAddress:l,amount:`${o.formatUnits(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:n}}),[w,b,M?.address,k]),B=r.useMemo((()=>{let e,t;if(!w||!p||!R||L)return;function r(...e){return $p(e.reduce(((e,t)=>e+t),0n),R??0)}0===b&&M?.address===w.spender&&(e=r(w.fee));let n=r(k.value),a=w.instructions[b];return a&&"unknown"!==a.type&&"ata-creation"!==a.type?(null!=e&&"SOL"===a.token.symbol&&(t=r(a.value,w.fee)),{fee:e,amount:"SOL"===a.token.symbol?r(a.value):`${o.formatUnits(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:n}):{fee:e,balance:n}}),[w,p,R,L,M?.address,b,k]),z=r.useMemo((()=>{if(W||!w||k.isLoading||b>0)return!1;let e=w.instructions[b];if(!e)return!1;let t=0n;return M?.address===w.spender&&(t+=w.fee),"value"in e&&M?.address===e.fromAccount&&"SOL"===e.token.symbol&&(t+=e.value),k.value<t}),[w,k,b,W]);if(r.useEffect((()=>{!async function(){if(f&&N&&l)try{C(void 0);let e=await Kp({tx:f,connection:N,client:l});v(e),j(0)}catch(e){console.error("Failed to prepare transaction",e),C(e)}}()}),[f,N,l]),r.useEffect((()=>{(async function(){if(!M||!N)return;E({value:k.value,isLoading:!0});let e=new u.SolanaClient({name:"mainnet-beta",rpcUrl:N.rpcEndpoint});E({value:await e.getBalance(M.address).catch((()=>0n))??0n,isLoading:!1})})().catch(console.error)}),[w,N]),!(f&&t?.sendSolanaTransaction&&M&&N)){let r=Error("Invalid transaction request");/*#__PURE__*/return e.jsx(Ts,{error:r,onClick:()=>{t?.sendSolanaTransaction?.onFailure(r),c({shouldCallAuthOnSuccess:!1})}})}let $=()=>{if(!T)return I?t?.sendSolanaTransaction?.onSuccess(I):(t?.sendSolanaTransaction?.onFailure(P??x??Error("User exited the modal before submitting the transaction")),j(0)),c({shouldCallAuthOnSuccess:!1})};n.current=$;let V=t.sendSolanaTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/e.jsx("img",{src:t.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:t.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,q=!!(t.funding&&t.funding.supportedOptions.length>0),H=z&&q;return I?/*#__PURE__*/e.jsx(Pg,{instructions:w?.instructions.reduce(((e,t)=>("ata-creation"===t.type&&e.push({tokenAccountOwner:t.owner,tokenAccount:t.ata}),"spl-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount||t.toAta,amount:t.value,token:t.token}),"sol-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount,amount:t.value,token:t.token}),e)),[])??[],fees:0===b?I.fees:0n,onClose:$,transactionInfo:t.sendSolanaTransaction?.uiOptions.transactionInfo,solPrice:R,receiptHeader:t.sendSolanaTransaction?.uiOptions.successHeader,receiptDescription:t.sendSolanaTransaction?.uiOptions.successDescription,rpcEndpoint:N.rpcEndpoint,signOnly:W}):P?/*#__PURE__*/e.jsx(lg,{transactionError:P,connection:N,onClose:$,network:"solana",onRetry:async()=>{_(void 0);let{blockhash:e}=await N.getLatestBlockhash();qp(f)?f.message.recentBlockhash=e:f.recentBlockhash=e,g(f)}}):/*#__PURE__*/e.jsx(ng,{img:V,title:t.sendSolanaTransaction?.uiOptions?.transactionInfo?.title||"Confirm transaction",subtitle:t.sendSolanaTransaction?.uiOptions?.description||`${h.name} wants your permission to approve the following transaction.`,cta:H?"Add funds":t.sendSolanaTransaction?.uiOptions?.buttonText||"Approve",transactionIndex:b,maxIndex:O-1,network:"mainnet-beta"==F?"Solana":F,blockExplorerUrl:"https://explorer.solana.com",total:p?B?.total:D?.total,amount:p?B?.amount:D?.amount,fee:p?B?.fee:D?.fee,balance:p?B?.balance:D?.balance,from:D?.from,to:D?.to,tokenAccount:D?.tokenAccount,tokenAccountOwner:D?.tokenAccountOwner,tokenAddress:D?.tokenAddress,transactingWalletAddress:M.address,programAddress:D?.program,disabled:z&&!q,isSubmitting:T,isPreparing:!w||k.isLoading,isTokenPriceLoading:p&&L,isMissingFunds:z,submitError:P??void 0,parseError:x,onClick:H?async()=>{if(M){if(!q)throw Error("Funding wallet is not enabled");a({...t,funding:{...t.funding,methodScreen:If}}),s(If)}}:async()=>{if(b<(w?.instructions.length??1)-1)j(b+1);else try{A(!0);let e=await y();if(T||!e||!M||!d||!m||!U)return;let r=kn(m,M.address);if(!r)throw Error("No root wallet for transacting wallet found");let{entropyId:n,entropyIdVerifier:a}=Sn(m,r);if(W)await Dm({tx:f,accessToken:e,walletProxy:d,entropyId:n,entropyIdVerifier:a,transactingWalletAddress:M.address,transactingWalletIndex:M.walletIndex??0}),S(Hp("",f,null));else{let{signature:r,receipt:i}=await Bm({tx:f,accessToken:e,connection:N,walletProxy:d,entropyId:n,entropyIdVerifier:a,transactingWalletAddress:M.address,transactingWalletIndex:M.walletIndex??0,transactionOptions:t.sendSolanaTransaction?.transactionOptions});S(Hp(r,f,i))}}catch(e){console.warn({transaction:f,error:e}),_(e)}finally{A(!1)}},onClose:$,onBack:b>0&&O>1?()=>j(b-1):void 0})}},Mg=({appConfig:e,getAccessToken:t,isHeadlessSigning:r,emitPrivyEvent:n,setModalData:a,openModal:o,walletProxy:s,user:l,recoverPrimaryWallet:c},{transaction:d,connection:u,transactionOptions:p,fundWalletConfig:h,uiOptions:m,address:y,signOnly:f})=>new Promise((async(g,w)=>{let{requesterAppId:v}=m||{},x=f?"signSolanaTransaction":"sendSolanaTransaction";if(!l)return n(x,"onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),void w(new i.PrivyClientError("User must be authenticated before signing with a Privy wallet",i.PrivyErrorCode.MUST_BE_AUTHENTICATED));let C=y?kn(l,y):Cn(l);if(!C)return n(x,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void w(new i.PrivyClientError("Must have a Privy wallet before signing",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND));if(!await c().catch((()=>!1)))throw n(x,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),new i.PrivyClientError(`Cannot sendSolanaTransaction before embedded wallet ${C.address} is connected`,i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND);if(r({showWalletUIs:m?.showWalletUIs}))(async()=>{let e=await t();if(!e||!s)return n(x,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void w(new i.PrivyClientError("Must have valid access token and Privy wallet to send transaction",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND));try{let t;if(!await c())return n(x,"onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),void w(new i.PrivyClientError("Unable to connect to wallet",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR));if(r({showWalletUIs:m?.showWalletUIs})&&!f)try{if(!await async function(e,t){let{value:r}=await t.simulateTransaction(e);if("BlockhashNotFound"===r.err)throw Error("Simulation failed: Blockhash not found");return null==r.err&&r.logs?.every((e=>!/insufficient funds/gi.test(e)))}(d,u))return n(x,"onError",i.PrivyErrorCode.INSUFFICIENT_BALANCE),void w(new i.PrivyClientError("Solana wallet has insufficient funds for this transaction.",i.PrivyErrorCode.INSUFFICIENT_BALANCE))}catch(e){return console.error(e),n(x,"onError",i.PrivyErrorCode.TRANSACTION_FAILURE),void w(new i.PrivyClientError(e instanceof Error?e.message:"Transaction failed.",i.PrivyErrorCode.TRANSACTION_FAILURE))}let{entropyId:a,entropyIdVerifier:o}=Sn(l);if(f)await Dm({accessToken:e,tx:d,walletProxy:s,entropyId:a,entropyIdVerifier:o,transactingWalletAddress:C.address,transactingWalletIndex:C.walletIndex??0}),t=Hp("",d,null),n("signSolanaTransaction","onSuccess",{signedTransaction:d});else{let{signature:r,receipt:i}=await Bm({accessToken:e,tx:d,connection:u,walletProxy:s,transactionOptions:p,entropyId:a,entropyIdVerifier:o,transactingWalletAddress:C.address,transactingWalletIndex:C.walletIndex??0});t=Hp(r,d,i),n("sendSolanaTransaction","onSuccess",{response:t})}g(t)}catch(e){n(x,"onError",i.PrivyErrorCode.TRANSACTION_FAILURE),w(e)}})();else{let{entropyId:t,entropyIdVerifier:r}=Sn(l,C),s={recoveryMethod:C.recoveryMethod,connectingWalletAddress:C.address,entropyId:t,entropyIdVerifier:r,onCompleteNavigateTo:Ng,onFailure:e=>{n(x,"onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),w(e)}},c=qm(e)?Of({address:C.address,appConfig:e,methodScreen:If,fundWalletConfig:h,comingFromSendTransactionScreen:!0}):void 0;a({connectWallet:s,sendSolanaTransaction:{transactionRequest:d,connection:u,transactionOptions:p,transactingWallet:C,onSuccess:e=>{f?n("signSolanaTransaction","onSuccess",{signedTransaction:e.signedTransaction}):n("sendSolanaTransaction","onSuccess",{response:e}),g(e)},onFailure:e=>{n(x,"onError",i.PrivyErrorCode.TRANSACTION_FAILURE),w(e)},uiOptions:m||{},requesterAppId:v,signOnly:f},funding:c}),o($f)}}));function Wg(e){let t=di(),{getAccessToken:r,user:n}=$m(),{setModalData:a}=Qu(),{isHeadlessSigning:o,openModal:s,walletProxy:l,recoverPrimaryWallet:c}=i.usePrivyInternal(),d=io();return no("sendSolanaTransaction",e),{sendTransaction:async({transaction:e,connection:i,uiOptions:u,transactionOptions:p,fundWalletConfig:h,address:m})=>await Mg({appConfig:t,getAccessToken:r,isHeadlessSigning:o,emitPrivyEvent:d,setModalData:a,openModal:s,walletProxy:l,user:n,recoverPrimaryWallet:c},{transaction:e,connection:i,transactionOptions:p,uiOptions:u,fundWalletConfig:h,address:m,signOnly:!1})}}const Og=/*#__PURE__*/h.styled.img.withConfig({displayName:"StyledLogo",componentId:"sc-68c1b1ea-0"})(["&&{height:",";width:",";border-radius:16px;margin-bottom:12px;}"],(e=>"sm"===e.size?"65px":"140px"),(e=>"sm"===e.size?"65px":"140px"));let Ug=({data:t})=>{let r=t=>"object"==typeof t&&null!==t?/*#__PURE__*/e.jsx(Rg,{children:Object.entries(t).map((([t,n])=>/*#__PURE__*/e.jsxs("li",{children:[/*#__PURE__*/e.jsxs("strong",{children:[t,":"]})," ",r(n)]},t)))}):/*#__PURE__*/e.jsx("span",{children:String(t)});/*#__PURE__*/return e.jsx("div",{children:r(t)})};const Fg=/*#__PURE__*/h.styled.div.withConfig({displayName:"Message",componentId:"sc-ccf49562-0"})(["margin-top:1.5rem;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-md);padding:12px;text-align:left;max-height:310px;overflow:scroll;white-space:pre-wrap;width:100%;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]);let Rg=/*#__PURE__*/h.styled.ul.withConfig({displayName:"MessageList",componentId:"sc-ccf49562-1"})(["margin-left:12px !important;white-space:nowrap;&:first-child{margin-left:0 !important;}strong{font-weight:500 !important;}"]);const Lg=({data:t})=>/*#__PURE__*/e.jsx(Fg,{children:/*#__PURE__*/e.jsx(Ug,{data:t})});let Dg=e=>{if(!o.isHex(e))return e;try{return o.hexToString(e)}catch{return e}},Bg=e=>JSON.stringify(e,null,2),zg=t=>{let{types:r,primaryType:n,...a}=t.typedData;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Lg,{data:a}),/*#__PURE__*/e.jsx(qc,{text:Bg(t.typedData),itemName:"full payload to clipboard"})," "]})};const $g={component:()=>{let{authenticated:t}=Vo(),{initializeWalletProxy:n,closePrivyModal:a}=i.usePrivyInternal(),{navigate:o,data:s,onUserCloseViaDialogOrKeybindRef:l}=Qu(),[c,d]=r.useState(!0),[p,h]=r.useState(""),[m,y]=r.useState(),[f,g]=r.useState(null),[w,v]=r.useState(!1),x=null!==f;r.useEffect((()=>{t||o(xu)}),[t]),r.useEffect((()=>{n(Ir).then((e=>{d(!1),e||(h("An error has occurred, please try again."),y(new Xn(new Jn(p,u.ProviderErrors.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:C,data:b,confirmAndSign:j,onSuccess:k,onFailure:E,uiOptions:T}=s.signMessage,A={title:T?.title||"Sign message",description:T?.description||"Signing this message will not cost you any fees.",buttonText:T?.buttonText||"Sign and continue"},I=e=>{e?k(e):E(m||new Xn(new Jn("The user rejected the request.",u.ProviderErrors.E4001_USER_REJECTED_REQUEST.eipCode))),a({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{g(null),h(""),y(void 0)}),200)};return l.current=()=>{I(f)},/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:()=>I(f)}),/*#__PURE__*/e.jsx(Fo,{}),T?.iconUrl&&"string"==typeof T.iconUrl?/*#__PURE__*/e.jsx(Hg,{children:/*#__PURE__*/e.jsx(Og,{size:"sm",src:T.iconUrl,alt:"app image"})}):null,/*#__PURE__*/e.jsx(sc,{children:A.title}),/*#__PURE__*/e.jsx(oc,{children:A.description}),"personal_sign"===C&&/*#__PURE__*/e.jsx(Fg,{children:Dg(b)}),"eth_signTypedData_v4"===C&&/*#__PURE__*/e.jsx(zg,{typedData:b}),"solana_signMessage"===C&&/*#__PURE__*/e.jsx(Fg,{children:b}),/*#__PURE__*/e.jsx(Kg,{}),/*#__PURE__*/e.jsx(Vg,{$fail:!0,children:p}),/*#__PURE__*/e.jsx(xo,{disabled:w||x||c,loading:w,onClick:async()=>{v(!0),h("");try{let e=await j();g(e),v(!1),setTimeout((()=>{I(e)}),or)}catch(e){console.error(e),h("An error has occurred, please try again."),y(new Xn(new Jn(p,u.ProviderErrors.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),v(!1)}},children:w?"Signing...":x?/*#__PURE__*/e.jsxs(qg,{children:[/*#__PURE__*/e.jsx($c,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",/*#__PURE__*/e.jsx("span",{children:"Success"})]}):A.buttonText}),T?.isCancellable&&/*#__PURE__*/e.jsx(Ao,{style:{marginTop:"1rem"},onClick:()=>I(null),isSubmitting:!1,children:"Not now"}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}};let Vg=/*#__PURE__*/h.styled.div.withConfig({displayName:"InputHelp",componentId:"sc-1a9f17a4-0"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-start;width:100%;margin-top:16px;margin-bottom:4px;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),qg=/*#__PURE__*/h.styled.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-1a9f17a4-1"})(["display:flex;align-items:center;gap:8px;"]),Hg=/*#__PURE__*/h.styled.div.withConfig({displayName:"IconContainer",componentId:"sc-1a9f17a4-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),Kg=/*#__PURE__*/h.styled.div.withConfig({displayName:"Grow",componentId:"sc-1a9f17a4-3"})(["flex-grow:1;"]);function Zg(e){let{isHeadlessSigning:t,walletProxy:r,initializeWalletProxy:n,recoverPrimaryWallet:a,openModal:o}=i.usePrivyInternal(),{user:s,getAccessToken:l}=$m(),c=io(),{setModalData:d}=Qu();return no("signSolanaMessage",e),{signMessage:({message:e,options:u})=>new Promise((async(p,h)=>{if(!s)return c("signSolanaMessage","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),void h(Error("User must be authenticated before signing with a Privy wallet"));let m=u?.address?kn(s,u.address):Cn(s);if(!m)return c("signSolanaMessage","onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void h(Error("Must have a Privy wallet before signing"));let{entropyId:y,entropyIdVerifier:f}=Sn(s,m),g=Buffer.from(e).toString("base64");if(g.length<1)return c("signMessage","onError",i.PrivyErrorCode.INVALID_MESSAGE),void h(Error("Message must be a non-empty string"));let w=async()=>{if(!s)throw Error("User must be authenticated before signing with a Privy wallet");let e=await l();if(!e)throw Error("User must be authenticated to use their embedded wallet.");let t=r??await n(15e3);if(!t)throw Error("Failed to initialize embedded wallet proxy.");if(!await a())throw Error("Unable to connect to wallet");let{response:i}=await t.rpc({accessToken:e,entropyId:y,entropyIdVerifier:f,chainType:"solana",hdWalletIndex:m.walletIndex??0,request:{method:"signMessage",params:{message:g}}});return i.data.signature};if(t({showWalletUIs:u?.uiOptions?.showWalletUIs}))try{let e=await w(),t=new Uint8Array(Buffer.from(e,"base64"));c("signSolanaMessage","onSuccess",{signature:t}),p(t)}catch(e){h(e)}else d({signMessage:{method:"solana_signMessage",data:g,confirmAndSign:w,onSuccess:e=>{let t=new Uint8Array(Buffer.from(e,"base64"));c("signSolanaMessage","onSuccess",{signature:t}),p(t)},onFailure:e=>{h(e)},uiOptions:u?.uiOptions},connectWallet:{recoveryMethod:m.recoveryMethod,connectingWalletAddress:m.address,entropyId:y,entropyIdVerifier:f,onCompleteNavigateTo:$g,onFailure:e=>{c("signSolanaMessage","onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),h(e)}}}),o($f)}))}}const Gg=()=>{let{exportSolanaWallet:e,createEmbeddedSolanaWallet:t,solanaWallets:r,walletProxy:n,recoverPrimaryWallet:a}=i.usePrivyInternal(),{sendTransaction:o}=Wg(),{signMessage:s}=Zg(),{user:l,getAccessToken:c}=$m(),{ready:d}=Nh(),u=n?[...xn(l),jn(l)].filter((e=>!!e)).map((e=>({type:"solana",imported:e.imported,address:e.address,connectedAt:Date.now(),walletClientType:"privy",connectorType:"embedded",walletIndex:e.walletIndex??void 0,meta:{name:"Privy Wallet",icon:void 0,id:"io.privy.solana.wallet"},linked:!0,fund(){throw new i.PrivyClientError("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:()=>{throw new i.PrivyClientError("Cannot unlink an embedded Solana wallet")},async getProvider(){return new Lm(n,e.address,this.signMessage)},signMessage:async t=>await s({message:t,options:{address:e.address,uiOptions:{showWalletUIs:!1}}}),async sendTransaction(t,r,n){let{signature:a}=await o({transaction:t,connection:r,transactionOptions:n,address:e.address});return a},async signTransaction(t){let r=await c();if(!r||!n)throw new i.PrivyClientError("Must have valid access token and Privy wallet to send transaction",i.PrivyErrorCode.MUST_BE_AUTHENTICATED);if(!await a().catch((()=>!1)))throw new i.PrivyClientError("Wallet couldn't be connected",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:o,entropyIdVerifier:s}=Sn(l,e);return await Dm({tx:t,accessToken:r,walletProxy:n,entropyId:o,entropyIdVerifier:s,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0}),t},async signAllTransactions(t){let r=await c();if(!r||!n)throw new i.PrivyClientError("Must have valid access token and Privy wallet to send transaction",i.PrivyErrorCode.MUST_BE_AUTHENTICATED);if(!await a().catch((()=>!1)))throw new i.PrivyClientError("Wallet couldn't be connected",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:o,entropyIdVerifier:s}=Sn(l,e);for(let a of t)await Dm({tx:a,accessToken:r,walletProxy:n,entropyId:o,entropyIdVerifier:s,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0});return t},loginOrLink:async()=>{throw new i.PrivyClientError("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{},isConnected:async()=>!0}))):[];return{ready:!(!d||!n),createWallet:t,exportWallet:e,wallets:r.concat(u)}},Yg={component:()=>{let{wallets:t}=Nh(),{wallets:n}=Gg(),{data:a,setModalData:s,navigate:l,lastScreen:c}=Qu(),{rpcConfig:d,appId:p,createAnalyticsEvent:h,closePrivyModal:m}=i.usePrivyInternal(),y=di(),[f,g]=r.useState(void 0),[w,v]=r.useState(!1),x=Um(),C=a?.funding,{reloadBalance:b}=Pm({rpcConfig:d,appId:p,address:"ethereum"===C.chainType?C.address:void 0,chain:"ethereum"===C.chainType?C.chain:void 0}),j="solana"===C.chainType,k=j?"SOL":C.erc20Address?C.erc20ContractInfo?.symbol:C.chain.nativeCurrency.symbol,E=j?n.find((({address:e})=>e===C.address)):t.find((({address:e})=>Lt(e)===Lt(C.address)));if(!C)return s({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:c||If},funding:a?.funding,sendTransaction:a?.sendTransaction}),l(Es),/*#__PURE__*/e.jsx(e.Fragment,{});r.useEffect((()=>{let e=j?async function(){if("solana"!==C.chainType)return;let e=x(Fm);e?e.getBalance({address:C.address,cluster:C.cluster}).then((e=>{let t=BigInt(e);f&&t>f&&(v(!0),h({eventName:_m,payload:{provider:"manual",status:"success",chainType:"solana",address:E?.address,value:o.formatUnits(t-f,9),token:"SOL"}})),g(t)})):console.warn("Unable to load solana plugin, skipping balance")}:async function(){"ethereum"===C.chainType&&(async()=>{if(!C.erc20Address)return await b()??BigInt(0);{let{balance:e}=await Nm({chain:C.chain,address:C.address,erc20Address:C.erc20Address,rpcConfig:d,appId:p});return e}})().then((e=>{f&&e>f&&(v(!0),h({eventName:_m,payload:{provider:"manual",status:"success",chainType:"ethereum",address:E?.address,chainId:C.chain.id,value:o.formatUnits(e-f,C.erc20ContractInfo?.decimals??18),token:C.erc20ContractInfo?.symbol??C.erc20Address??"ETH"}})),g(e)})).catch((()=>g(void 0)))},t=setInterval(e,2e3);return e(),()=>clearInterval(t)}),[f]);let T=r.useMemo((()=>void 0!==f&&f>=parseFloat(C.amount)),[f,C.amount]),A=r.useMemo((()=>null==f?"":C.isUSDC?u.formatTokenAmount({amount:f,decimals:6}):j?zp(f,3,!0,!0):null!=C.erc20ContractInfo?.decimals?u.formatTokenAmount({amount:f,decimals:C.erc20ContractInfo.decimals}):u.formatWeiAmount({wei:f})),[f,j,C]),I="ethereum"===C.chainType?C.chain.name:Xg[C.cluster.name],S=r.useMemo((()=>""===C.uiConfig?.receiveFundsTitle?null:/*#__PURE__*/e.jsx(sc,{children:C.uiConfig?.receiveFundsTitle??`Receive ${C.amount} ${k??""}`.trim()})),[C.uiConfig?.receiveFundsTitle,C.amount,k]),P=r.useMemo((()=>""===C.uiConfig?.receiveFundsSubtitle?null:/*#__PURE__*/e.jsx(oc,{children:C.uiConfig?.receiveFundsSubtitle??`Scan this code or copy your wallet address to receive funds on ${I}.`})),[C.uiConfig?.receiveFundsSubtitle,I]);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(xw,{}),S,P,/*#__PURE__*/e.jsxs(Wo,{style:{gap:"1rem",margin:S||P?"1rem 0":"0"},children:[/*#__PURE__*/e.jsx(nd,{url:`${C.chainType}:${C.address}`,size:200,squareLogoElement:Jg}),/*#__PURE__*/e.jsxs(jm,{theme:y.appearance.palette.colorScheme,children:["Make sure to send funds on ",I,"."]}),/*#__PURE__*/e.jsx(Sm,{title:"Your wallet",errMsg:void 0,showIcon:!0,isLoading:!C||void 0===f,isPulsing:!T,balance:`${A} ${k}`,address:C.address,statusColor:T?"green":"gray"}),w&&/*#__PURE__*/e.jsx(vo,{onClick:()=>m({shouldCallAuthOnSuccess:!1,isSuccess:!0}),children:"Continue"})]}),/*#__PURE__*/e.jsx(yi,{})]})}};let Jg=({...t})=>/*#__PURE__*/e.jsx(ua,{color:"black",...t}),Xg={devnet:"Devnet","mainnet-beta":"Solana",testnet:"Testnet"},Qg=/*#__PURE__*/h.styled.div.withConfig({displayName:"Container",componentId:"sc-b3a607dd-0"})(["display:flex;flex-direction:column;min-height:72px;"]);var ew=({onBack:t,details:r})=>/*#__PURE__*/e.jsxs(Qg,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:t}),/*#__PURE__*/e.jsx(Lg,{data:r}),/*#__PURE__*/e.jsx(yi,{})]});let tw=({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return o.toHex(e*t)}catch(e){return}};const rw=({txn:t,receipt:r,transactionInfo:n,onClose:a,tokenPrice:i,tokenSymbol:o,receiptHeader:s,receiptDescription:l})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:a}),/*#__PURE__*/e.jsx(Ii,{title:s??"Transaction complete!",description:l??"You're all set."}),/*#__PURE__*/e.jsx(Th,{tokenPrice:i,from:r.from,to:r.to,gas:tw(r),txn:t,transactionInfo:n,tokenSymbol:o}),/*#__PURE__*/e.jsx(Ui,{}),/*#__PURE__*/e.jsx(nw,{loading:!1,onClick:a,children:"All Done"}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]});let nw=/*#__PURE__*/h.styled(vo).withConfig({displayName:"SubmitButton",componentId:"sc-f857236b-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const aw=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],iw=[{name:"from",type:"address"},{name:"param2",type:"address"},{name:"param3",type:"bytes"},{name:"param4",type:"tuple",components:[]},{type:"tuple",components:[{name:"param5",type:"address"},{name:"param6",type:"uint256"},{name:"param7",type:"uint256"},{name:"encodedInitData",type:"bytes"}]}],ow=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],sw=[{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"payable",type:"function"}],lw=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],cw=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],dw=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],uw=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenIds",type:"uint256[]"},{name:"_amounts",type:"uint256[]"},{name:"_data",type:"bytes"}],name:"safeBatchTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],pw=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"},{name:"_amount",type:"uint256"},{name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],hw=(e,t)=>{let r=mw(ow,e);if(r)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:r.args[0],amount:r.args[1]};let n=mw(fy,e);if(n)return{action:"transfer",functionName:"transfer",isErc20Ish:!0,isNFTIsh:!1,transferTo:n.args[0],amount:n.args[1]};if(!t)return{action:"transaction",functionName:"",isErc20Ish:!1,isNFTIsh:!1};let a=mw(aw,e);if(a&&"string"==typeof a.args[1]){let e=yw(a.args[1]);if(e&&e[4].encodedInitData)return hw(e[4].encodedInitData,t)}let i=mw(cw,e);if(i)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:i.args[0],approved:i.args[1]};let o=mw(dw,e);if(o)return{action:"transfer",functionName:"transferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:o.args[0],transferTo:o.args[1],tokenId:o.args[2]};let s=mw(lw,e);if(s)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:s.args[0],transferTo:s.args[1],tokenId:s.args[2]};let l=mw(pw,e);if(l)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:l.args[0],transferTo:l.args[1],tokenId:l.args[2],amount:l.args[3]};let c=mw(uw,e);if(c)return{action:"batch transfer",functionName:"safeBatchTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:c.args[0],transferTo:c.args[1],tokenIds:c.args[2],amounts:c.args[3]};let d=mw(sw,e);return d?{action:"mint",functionName:d.functionName,isNFTIsh:!0,isErc20Ish:!1,args:d.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}};let mw=(e,t)=>{try{let r=o.decodeFunctionData({abi:e,data:t});return{functionName:r.functionName,args:r.args||[]}}catch(e){return null}},yw=e=>{try{if("string"==typeof e)return o.decodeAbiParameters(iw,`0x${e.slice(10)}`)}catch(e){return null}};const fw=(e,t,n)=>{let[a,o]=r.useState(null),{getAccessToken:s}=Vo(),{walletProxy:l}=i.usePrivyInternal();return r.useEffect((()=>{a&&o(null),(async()=>{if(!await s()||!l||!t)return null;let r=[],a=!0,i=await Mh(e,n,t).catch((t=>(t.details.includes("insufficient funds")?a=!1:r.push(t),e)));return{tx:i,totalGasEstimate:i.gas,hasFunds:a,errors:r}})().then(o)}),[e]),a};let gw=new Xn(new Jn("There was an issue preparing your transaction",u.ProviderErrors.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),ww=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0;const vw={component:()=>{let{data:t,onUserCloseViaDialogOrKeybindRef:n,setModalData:a,navigate:s}=Qu(),{rpcConfig:l,chains:c,closePrivyModal:d,walletProxy:p,client:h,showFiatPrices:m}=i.usePrivyInternal(),{getAccessToken:y,user:f}=Vo(),g=di(),[w,v]=r.useState(0),x=(e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(t),[C,b]=r.useState(ww(t,w)),[j,k]=r.useState(null),[E,T]=r.useState(),[A,I]=r.useState(!1),[S,P]=r.useState(null),[_,N]=r.useState(null),[M,W]=r.useState(null),[O,U]=r.useState(void 0),[F,R]=r.useState(void 0),[L,D]=r.useState(!1),[B,z]=r.useState(!1),[$,V]=r.useState([]),[q,H]=r.useState([]),[K,Z]=r.useState(!1),[G,Y]=r.useState(void 0);if(!C||!t?.sendTransaction||!t?.sendTransaction)/*#__PURE__*/return e.jsx(Ts,{error:Error("Invalid transaction request"),onClick:()=>{t?.sendTransaction?.onFailure(gw),d({shouldCallAuthOnSuccess:!1})}});let{entropyId:J,entropyIdVerifier:X,transactingWalletIndex:Q,transactingWalletAddress:ee}=t.sendTransaction,te=r.useMemo((()=>c.find((e=>Number(e.id)===Number(C.chainId)))),[C.chainId]),re=te?.nativeCurrency.symbol??"ETH",ne=r.useMemo((()=>hw(C.data,!!g.embeddedWallets.extendedCalldataDecoding)),[C.data]),{action:ae,isErc20Ish:ie,isNFTIsh:oe}=ne,{toAddress:se,tokenAddress:le}=r.useMemo((()=>({toAddress:ne.isErc20Ish?ne.transferTo:C.to??void 0,tokenAddress:ne.isErc20Ish?C.to:void 0})),[ne]);r.useEffect((()=>{C.to&&te&&ie&&Xm({address:C.to,chain:te,rpcConfig:g.rpcConfig,privyAppId:g.id}).then(k).catch(console.error)}),[C.to,te]);let{tokenPrice:ce,isTokenPriceLoading:de}=Ph(C.chainId),{balance:ue}=Pm({rpcConfig:g.rpcConfig,appId:g.id,address:ee,chain:te}),pe=r.useMemo((()=>Ut(Number(C.chainId),c,l,{appId:g.id})),[C.chainId,l]),he=fw(C,ee,pe);r.useEffect((()=>{b(ww(t,w))}),[w]),r.useEffect((()=>{t.sendTransaction?.getIsSponsored?t.sendTransaction.getIsSponsored().then(T).catch(console.error):T(!1)}),[t.sendTransaction.getIsSponsored]);let me=()=>{if(!A)return S?t?.sendTransaction?.onSuccess({hash:S}):M||he?.errors[0]?t?.sendTransaction?.onFailure(M??he?.errors[0]??gw):t?.sendTransaction?.onFailure(new Xn(new Jn("The user rejected the request",u.ProviderErrors.E4001_USER_REJECTED_REQUEST.eipCode))),d({shouldCallAuthOnSuccess:!1})};n.current=me;let ye=!!(t.funding&&t.funding.supportedOptions.length>0),fe=Up(BigInt(he?.totalGasEstimate??0n),re),ge=m&&ce?Op(BigInt(he?.totalGasEstimate??0n),ce):void 0,we=Up(ue??0n,re,void 0,!0),ve=m&&ce?Op(ue??0n,ce):void 0,xe=t.sendTransaction?.uiOptions?.transactionInfo?.title;xe||(xe="approve"===ae?ie?"Confirm address":"Confirm action":`Approve ${ae}`);let Ce=t.sendTransaction?.uiOptions?.description||(ie&&"approve"===ae?`${g.name} would like your permission for ${Lt(ne.spender)} to spend tokens on your behalf.`:`${g.name} wants your permission to approve the following transaction.`),be=t.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/e.jsx("img",{src:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,je=!(!he||he.errors[0]||he.hasFunds||!1!==E),ke=je&&ye,Ee=ke?"Add funds":t.sendTransaction?.uiOptions?.buttonText||(w<x?"Continue":"Approve");if(r.useEffect((()=>{let e=(e,t,r)=>{if(t.isErc20Ish&&t.amount&&r)Y(wy({amount:t.amount,decimals:r.decimals})),V([{value:G,symbol:r?.symbol}]);else if(e.value){let t=BigInt(e.value),r=ce&&Op(t,ce);V(m&&r?[{value:r}]:[{value:Fp(t),symbol:re}])}else V(m?[{value:"$0"}]:[{value:"0",symbol:re}])},t=he?.tx??C;g.embeddedWallets.transactionScanning.enabled&&t?(Z(!0),(async e=>{if(h)return await h.scanTransaction({metadata:{domain:g.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})})(t).then((e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?R("safe"):"Warning"===e.validation.result_type?R("warn"):"Malicious"===e.validation.result_type&&(R("error"),z(!0))),"Success"!==e.simulation.status)throw Error("Simulation failed");{U(e.simulation.params);let{assetsIn:t,assetsOut:r}=function(e,t){let r=[],n=[];if(e)for(let t of e)if(t.in[0]){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.in[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price},r.push(e)}else if(t.out[0]?.value){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.out[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.out[0].value,symbol:t.asset.symbol,usdValue:t.out[0].usd_price},n.push(e)}for(let e of t)for(let t of Object.keys(e.spenders)){let r;r="ERC721"===e.asset.type||"approve_for_all"===e.spenders[t]?.value?{nftName:e.asset.name}:{iconUrl:e.asset.logo_url,value:e.spenders[t]?.value,symbol:e.asset.symbol,usdValue:e.spenders[t]?.usd_price},n.push(r)}return{assetsIn:r,assetsOut:n}}(e.simulation.assets_diffs,e.simulation.exposures);if(0===r.length&&0===t.length)throw Error("No tokens found");V(r),H(t)}Z(!1)})).catch((()=>{Z(!1),e(t,ne,j)}))):e(t,ne,j)}),[C,he?.tx,ne,j]),_/*#__PURE__*/)return e.jsx(rw,{txn:he?.tx??C,onClose:me,receipt:_,transactionInfo:t.sendTransaction?.uiOptions.transactionInfo,tokenPrice:ce,tokenSymbol:re,receiptHeader:t.sendTransaction?.uiOptions.successHeader,receiptDescription:t.sendTransaction?.uiOptions.successDescription});if(M)/*#__PURE__*/return e.jsx(lg,{transactionError:M,transactionHash:S??void 0,network:"ethereum",chainId:he?.tx.chainId??C.chainId,onClose:me,onRetry:({resetNonce:e})=>{W(null);let t={...he?.tx??C};e&&(t.nonce=void 0),b(t)}});let Te=0!==x&&"number"==typeof w&&0!==w?()=>{v(w-1)}:void 0;return L&&O?/*#__PURE__*/e.jsx(ew,{details:O,onBack:()=>D(!1)}):/*#__PURE__*/e.jsx(rg,{transactionIndex:w,onBack:Te,maxIndex:x,disabled:je&&!ye||B,isSubmitting:A,submitError:M,isPreparing:!he,isTokenPriceLoading:de,isTokenContractInfoLoading:!oe&&!j,prepareError:he?.errors[0],symbol:j?.symbol,chain:te,img:be,title:xe,subtitle:Ce,txValue:C.value,fee:ge??fe,isSponsored:E,from:ee??"",to:se,tokenAddress:le??void 0,network:g.chains.find((e=>e.id===C.chainId))?.name??"",transactionDetails:{...ne,formattedAmount:G},cta:Ee,missingFunds:je,action:ae,balance:ve??we,onClose:me,onClick:ke?async()=>{if(ee){if(!ye)throw Error("Funding wallet is not enabled");a({...t,funding:{...t.funding,methodScreen:If,chainType:"ethereum",amount:o.formatEther(BigInt(he?.tx.value??0)+BigInt(he?.totalGasEstimate?.toString()??0)),chain:te}}),s(If)}}:async()=>{if(w<x)v(w+1);else{I(!0);try{let e=await y();if(A||!e||!p||!f)return;let r=t?.sendTransaction?.onConfirm?await t.sendTransaction.onConfirm():await dm({accessToken:e,transactingWalletIndex:Q,entropyId:J,entropyIdVerifier:X,walletProxy:p,transactionRequest:he?.tx??C,publicClient:pe,requesterAppId:t.sendTransaction?.requesterAppId});if(P(r),t.sendTransaction?.signOnly)return await new Promise((e=>setTimeout(e,or))),t?.sendTransaction?.onSuccess({hash:r}),d({shouldCallAuthOnSuccess:!1});let n=await pe.waitForTransactionReceipt({hash:r});if("reverted"===n.status)throw Error("Transaction failed");N(n)}catch(e){console.warn({transaction:he?.tx??C,error:e}),W(e)}finally{I(!1)}}},validation:F,hasScanDetails:!!O,setIsScanDetailsOpen:D,preventMaliciousTransaction:B,setPreventMaliciousTransaction:z,tokensSent:$,tokensReceived:q,isScanning:K,isCancellable:t.sendTransaction?.uiOptions?.isCancellable??!1})}};function xw({title:t}){let{currentScreen:r,navigateBack:n,navigate:a,data:i,setModalData:o}=Qu();/*#__PURE__*/return e.jsx(Ci,{title:t,backFn:r===Yg?n:r===i?.funding?.methodScreen?i.funding.comingFromSendTransactionScreen?()=>a(vw):void 0:i?.funding?.methodScreen?()=>{let e=i.funding;e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),o({funding:e}),a(e.methodScreen)}:void 0})}const Cw={component:()=>{let{rpcConfig:t,appId:n,closePrivyModal:a,createAnalyticsEvent:s}=i.usePrivyInternal(),{navigate:l,setModalData:c,app:d,data:u}=Qu(),{wallets:p}=Nh(),h=Um(),[m,y]=r.useState(null),[f,g]=r.useState(null),[w,v]=r.useState([]),[x,C]=r.useState(0),[b,j]=r.useState(!1),[k,E]=r.useState(!1),[T,A]=r.useState(!1),[I,S]=r.useState(!1),[P,_]=r.useState(),[N,M]=r.useState();if(!u?.funding||"solana"!==u.funding.chainType)throw Error("Invalid funding data");let{address:W,cluster:O,connectedWalletAddress:U}=u.funding,[F,R]=r.useState(u.funding.amount),L=U?p.find((({address:e})=>e===U)):p[0],D=$a(L?.walletClientType||"unknown"),B=D?.name||"wallet",[z,$]=r.useState(null);r.useEffect((()=>{(async()=>{if(!L)return;let e=await L.getEthereumProvider();$(o.createWalletClient({account:L.address,transport:o.custom(e)}).extend(o.publicActions))})().catch(console.error)}),[L]);let[V,q]=r.useState(0n),H=zp(V);r.useEffect((()=>{let e=h(Fm);e?e.getBalance({address:W,cluster:O}).then((e=>q(BigInt(e)))):console.warn("Unable to load solana plugin, skipping balance")}),[]);let[K,Z]=r.useState(),{tokenPrice:G}=Ph("solana"),{fundingAmountInBaseUnit:Y,fundingAmountInUsd:J}=Vp({amount:F,fee:0n,tokenPrice:G});if(r.useEffect((()=>{(async()=>{if(!z||!L)return;let e=["testnet","devnet"].includes(O.name);e&&console.warn("Solana testnets are not supported for bridging");let r=Ya(d.chains).filter((({testnet:t})=>!!t===e)),a=(await vy({chains:r,address:L.address,appId:n,rpcConfig:t})).filter((e=>e.balance>0n));if(a.length<1)return void y(new i.PrivyClientError(`Wallet ${Lt(L.address)} does not have enough funds.`,void 0,i.PrivyErrorCode.INSUFFICIENT_BALANCE));a.sort(((e,t)=>Number(t.balance-e.balance)));let o=(await Promise.allSettled(a.map((async e=>({...e,quote:await xs({isTestnet:!1,input:gs({amount:Y.toString(),user:L.address,recipient:W,destinationChainId:Xa,destinationCurrency:Qa,originChainId:e.chain.id})})}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(o.length<1)return void y(new i.PrivyClientError(`Unable to fetch quotes for bridging. Wallet ${Lt(L.address)} does not have enough funds.`,void 0,i.PrivyErrorCode.INSUFFICIENT_BALANCE));let s=o.map((({quote:e,balance:t,chain:r})=>({bridgeTx:Cs(e),balance:t,chain:r}))).filter((({bridgeTx:e})=>!!e));if(s.length>1)return void v(s);let l=s.at(0);l?(E(!0),Z({data:l.bridgeTx.data,to:l.bridgeTx.to,value:l.bridgeTx.value,chain:l.chain})):y(new i.PrivyClientError(`Unable to select bridge option from quotes. Wallet ${Lt(L.address)} does not have enough funds.`,void 0,i.PrivyErrorCode.INSUFFICIENT_BALANCE))})().catch(console.error)}),[z]),r.useEffect((()=>{(async()=>{let e,r;if(!z||!L||b||T||!K)return;j(!0);let a=o.createPublicClient({chain:K.chain,transport:o.http(Ft(K.chain,t,n))});try{e=await a.prepareTransactionRequest({account:L.address,to:K.to,chain:K.chain,data:K.data,value:BigInt(K.value??0)})}catch(e){console.error(e),w.length>1&&g(e.shortMessage??"Something went wrong")}if(e){j(!1),A(!0);try{await z.switchChain({id:K.chain.id})}catch(e){await z.addChain({chain:K.chain}),await z.switchChain({id:K.chain.id})}try{r=await z.sendTransaction(e)}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(w.length<1?y(new i.PrivyClientError(e.shortMessage,void 0,i.PrivyErrorCode.TRANSACTION_FAILURE)):g(e.shortMessage??"Something went wrong"))}if(r)return await z.waitForTransactionReceipt({hash:r}),k?(M("pending"),void _(r)):(A(!1),S(!0),void s({eventName:_m,payload:{provider:"external",status:"success",txHash:r,address:L.address,chainId:K.chain.id,chainType:"ethereum",value:K.value?o.formatUnits(BigInt(K.value),18):void 0,token:"ETH",destination:W,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:o.formatUnits(Y,9),destinationToken:"SOL"}}));A(!1)}else j(!1)})().catch(console.error)}),[z,K]),bs({transactionHash:P,wallet:L,isTestnet:!1,bridgingStatus:N,setBridgingStatus:M,onSuccess({transactionHash:e,wallet:t}){E(!1),S(!0),s({eventName:_m,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:K?.chain.id,chainType:"ethereum",value:K?.value?o.formatUnits(BigInt(K.value),18):void 0,token:"ETH",destination:W,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:o.formatUnits(Y,9),destinationToken:"SOL"}})},onFailure({error:e}){E(!1),y(e)}}),r.useEffect((()=>{m&&(c({funding:u?.funding,sendTransaction:u?.sendTransaction,errorModalData:{error:m,previousScreen:cf}}),l(Es,!1))}),[m]),r.useEffect((()=>{if(!I)return;let e=setTimeout(a,lr);return()=>clearTimeout(e)}),[I]),I/*#__PURE__*/)return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(xw,{}),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsxs(Mo,{children:[/*#__PURE__*/e.jsx(ct.default,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/e.jsx(Pi,{title:"Success!",description:`You’ve successfully added ${F} SOL to your ${d.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]});let X=w[x];return w.length>1&&X?/*#__PURE__*/e.jsx(af,{displayName:B,configuredFundingChain:O,formattedBalance:H,fundingAmount:F,fundingCurrency:"SOL",fundingAmountInUsd:J,options:w,selectedOption:X,isPreparing:b,isSubmitting:T,addressToFund:W,fundingWalletAddress:L?.address||"",errorMessage:f,onSubmit:()=>{u.funding?.amount!==F?async function(){if(L&&X)try{let e=await xs({isTestnet:!1,input:gs({amount:Y.toString(),user:L.address,recipient:W,destinationChainId:Xa,destinationCurrency:Qa,originChainId:X.chain.id})}),t=Cs(e);if(!t)throw Error("Invalid transaction request");E(!0),Z({data:t.data,to:t.to,value:t.value,chain:X.chain})}catch(e){console.error(e),y(new i.PrivyClientError("Unable to fetch quotes for bridging",e,i.PrivyErrorCode.INSUFFICIENT_BALANCE))}}().catch(console.error):Z({to:X.bridgeTx.to,data:X.bridgeTx.data,value:X.bridgeTx.value,chain:X.chain})},onSelect:e=>{e!==x&&(g(null),C(e))},onAmountChange:R}):T&&L?/*#__PURE__*/e.jsx(hy,{wallet:L,displayName:B,addressToFund:W,isBridging:k,isErc20Flow:!1,chainId:"solana",chainName:O.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
24
24
  /*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(xw,{}),/*#__PURE__*/e.jsx(ey,{}),/*#__PURE__*/e.jsx("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/e.jsx(yi,{})]})}},bw=new Map([[If,null],[cf,"external"],[of,"external"],[yy,"external"],[Cw,"external"],[sf,"external"],[Yg,"manual"],[vf,"moonpay"]]);async function jw({url:e,popup:t,provider:r}){return t.location=e,new Promise(((e,r)=>{function n(){t?.close(),window.removeEventListener("message",a)}function a(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(e(t.data),n()),"https://cdn.apple-cloudkit.com"===t.origin&&t.data.ckSession&&(e({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:t.data.ckSession}),n()),"PRIVY_OAUTH_ERROR"===t.data.type&&(r(t.data.error),n()))}window.addEventListener("message",a)}))}const kw={component:()=>{let{app:t,data:r}=Qu(),n=di(),a=r?.externalConnectWallet?.suggestedAddress,o=a?`Connect the wallet with address ${Lt(a)} ${t?.name?`to ${t.name}.`:"."}`:`Connect a wallet to ${t?.name}`,{connectors:s}=i.usePrivyInternal(),l=Zu({walletList:r?.externalConnectWallet?.walletList??t.appearance.walletList,walletChainType:r?.externalConnectWallet?.walletChainType??t.appearance.walletChainType,connectors:s,connectOnly:!0,ignore:t.appearance.walletList,walletConnectEnabled:t.externalWallets.walletConnect.enabled});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),l.length>0&&/*#__PURE__*/e.jsx(Si,{title:"Connect your wallet",description:o}),/*#__PURE__*/e.jsx(Li,{$colorScheme:n.appearance.palette.colorScheme,children:/*#__PURE__*/e.jsx(Ku,{wallets:l})}),/*#__PURE__*/e.jsx(yi,{})]})}};function Ew(e){let{logout:t}=r.useContext($o);return no("logout",e),{logout:t}}const Tw={component:()=>{let t=di(),{data:n,navigate:a,setModalData:o,onUserCloseViaDialogOrKeybindRef:s}=Qu(),{crossAppAuthFlow:l,updateWallets:c,closePrivyModal:d,createAnalyticsEvent:u}=i.usePrivyInternal(),{logout:p}=Ew(),[h,m]=r.useState({}),y=n?.crossAppAuth,f={id:y.appId,name:y.name,logoUrl:y.logoUrl},g=new i.PrivyClientError(`There was an issue connecting your ${f.name} account. Please try again.`),w=new nr((async e=>{if(y.popup)try{let t=await l({appId:e,popup:y.popup,action:y.action});m({data:t})}catch(e){e instanceof i.PrivyClientError?m({error:e}):(e instanceof i.PrivyApiError&&y.popup&&y.popup.close(),m({error:g}))}else m({error:g})})),v=()=>{h.data&&(c(),y.onSuccess(h.data),d({shouldCallAuthOnSuccess:!0,isSuccess:!0})),y.onError(h.error??new i.PrivyClientError("User canceled flow")),d({shouldCallAuthOnSuccess:!1,isSuccess:!1})};s.current=v,r.useEffect((()=>{f.id.length&&w.execute(f.id)}),[f.id]),r.useEffect((()=>{if(!h.data)return;let e=h.data;if(t.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{a(Wc)}),or);return()=>clearTimeout(e)}if(Go(e,t.embeddedWallets)){let e=setTimeout((()=>{o({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),u({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${f.id}`,screen:"CrossAppAuthScreen"}}),p()},callAuthOnSuccessOnClose:!0}}),a(mc)}),or);return()=>clearTimeout(e)}let r=setTimeout(v,or);return()=>clearTimeout(r)}),[h.data]);let{title:x,subtitle:C}=r.useMemo((()=>h.data?{title:`Successfully connected with ${f.name}`,subtitle:"You're good to go!"}:h.error?{title:"Authentication failed",subtitle:h.error.message}:{title:`Connecting to ${f.name}`,subtitle:`Please check the pop-up from ${f.name} to continue`}),[h,f.name]);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:v}),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsxs(Aw,{children:[/*#__PURE__*/e.jsx(Jo,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(ho,{success:!!h.data,fail:!!h.error}),/*#__PURE__*/e.jsx(ns,{name:f.name,logoUrl:f.logoUrl})]})}),/*#__PURE__*/e.jsxs(Oo,{children:[/*#__PURE__*/e.jsx("h3",{children:x}),/*#__PURE__*/e.jsx("p",{children:C})]})]}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(fi,{})]})}};let Aw=/*#__PURE__*/h.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-33c02367-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const Iw={component:()=>{let{app:t,data:n}=Qu(),{closePrivyModal:a}=i.usePrivyInternal(),[o,s]=r.useState(!1),[l,c]=r.useState(),{address:d,onDelegate:u,onSuccess:p,onError:h}=n.delegatedActions.consent,m=async()=>{o?p():h(l??new i.PrivyClientError("User declined delegating actions.")),a({shouldCallAuthOnSuccess:!1})};return r.useEffect((()=>{if(!o&&!l)return;let e=setTimeout(m,sr);return()=>clearTimeout(e)}),[o,l]),o||l?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:m}),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsxs(_o,{children:[l?/*#__PURE__*/e.jsx(Le.default,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/e.jsx(ct.default,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/e.jsx(Do,{height:20}),/*#__PURE__*/e.jsx(Pi,{title:l?"Something went wrong":"Success!",description:l?"Please try again.":`You’ve successfully granted delegated action permissions to ${t.name}.`})]}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{closeable:!0,onClose:m}),/*#__PURE__*/e.jsx(ft.default,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/e.jsx(gc,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),/*#__PURE__*/e.jsxs(wc,{style:{marginBottom:24,textWrap:"pretty"},children:["By confirming, ",t.name," will be able to use your wallet for you even when you're not around. You can revoke this later."]}),/*#__PURE__*/e.jsx(Pw,{showIcon:!0,address:d,title:"Wallet",isLoading:!1}),/*#__PURE__*/e.jsxs(Sw,{style:{marginTop:24},children:[/*#__PURE__*/e.jsx(ko,{onClick:m,children:"Not now"}),/*#__PURE__*/e.jsx(vo,{onClick:async()=>{try{await u(),s(!0)}catch(e){c(e)}},children:"Accept"})]}),/*#__PURE__*/e.jsx(yi,{})]})}};let Sw=/*#__PURE__*/h.styled.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-bdb7bc51-0"})(["display:flex;gap:10px;"]),Pw=/*#__PURE__*/h.styled(Sm).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-bdb7bc51-1"})(["margin-top:1.5rem;"]);const _w={component:()=>{let{app:t,data:n}=Qu(),{closePrivyModal:a}=i.usePrivyInternal(),[o,s]=r.useState(!1),[l,c]=r.useState(),{onRevoke:d,onSuccess:u,onError:p}=n.delegatedActions.revoke,h=async()=>{o?u():p(l??new i.PrivyClientError("User declined revoking access to their delegated wallet.")),a({shouldCallAuthOnSuccess:!1})};return r.useEffect((()=>{if(!o&&!l)return;let e=setTimeout(h,sr);return()=>clearTimeout(e)}),[o,l]),o||l?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:h}),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsxs(_o,{children:[l?/*#__PURE__*/e.jsx(Le.default,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/e.jsx(ct.default,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/e.jsx(Do,{height:20}),/*#__PURE__*/e.jsx(Pi,{title:l?"Something went wrong":"Success!",description:l?"Please try again.":"You've successfully revoked permissions."})]}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{closeable:!0,onClose:h}),/*#__PURE__*/e.jsx(gt.default,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/e.jsx(gc,{style:{marginTop:24},children:"Revoke offline access to wallet"}),/*#__PURE__*/e.jsxs(wc,{children:["By confirming, ",t.name," will no longer be able to use this wallet on your behalf when you are not online."]}),/*#__PURE__*/e.jsxs(Nw,{style:{marginTop:24},children:[/*#__PURE__*/e.jsx(ko,{onClick:h,children:"Deny"}),/*#__PURE__*/e.jsx(vo,{onClick:async()=>{try{await d(),s(!0)}catch(e){c(e)}},children:"Confirm"})]}),/*#__PURE__*/e.jsx(yi,{})]})}};let Nw=/*#__PURE__*/h.styled.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-993a839-0"})(["display:flex;gap:10px;"]),Mw="#8a63d2";const Ww={component:()=>{let{lastScreen:t,navigateBack:a,data:o,app:s}=Qu(),{requestFarcasterSignerStatus:l,closePrivyModal:c}=i.usePrivyInternal(),[d,u]=r.useState(void 0),[p,h]=r.useState(!1),[m,y]=r.useState(!1),f=r.useRef([]),g=o?.farcasterSigner;r.useEffect((()=>{let e=Date.now(),t=setInterval((async()=>{if(!g?.public_key)return clearInterval(t),void u({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===g.status&&(clearInterval(t),h(!1),y(!0),f.current.push(setTimeout((()=>c({shouldCallAuthOnSuccess:!1,isSuccess:!0})),or)));let r=await l(g?.public_key),n=Date.now()-e;"approved"===r.status?(clearInterval(t),h(!1),y(!0),f.current.push(setTimeout((()=>c({shouldCallAuthOnSuccess:!1,isSuccess:!0})),or))):n>3e5?(clearInterval(t),u({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===r.status&&(clearInterval(t),u({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),f.current.forEach((e=>clearTimeout(e)))}}),[]);let w="pending_approval"===g?.status?g.signer_approval_url:void 0;return n.isMobile||p?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:t?a:void 0,onClose:c},"header"),/*#__PURE__*/e.jsx(Fo,{}),n.isIOS?
25
- /*#__PURE__*/e.jsx(e.Fragment,{children:/*#__PURE__*/e.jsxs(Uw,{children:[/*#__PURE__*/e.jsx(Jo,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(ho,{success:m,fail:!!d}),/*#__PURE__*/e.jsx(Rc,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e.jsxs(Oo,{children:[/*#__PURE__*/e.jsx(gc,{children:d?d.message:"Add a signer to Farcaster"}),/*#__PURE__*/e.jsx(wc,{children:d?d.detail:"This will allow "+s.name+" to add casts, likes, follows, and more on your behalf."})]}),w&&/*#__PURE__*/e.jsx(vo,{onClick:e=>{e.preventDefault(),window.location.href=w},children:"Open Warpcast app"})]})}):/*#__PURE__*/e.jsx(e.Fragment,{children:/*#__PURE__*/e.jsxs(Ow,{children:[/*#__PURE__*/e.jsx(Jo,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(ho,{success:m,fail:!!d}),/*#__PURE__*/e.jsx(Rc,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e.jsxs(Oo,{children:[/*#__PURE__*/e.jsx(gc,{children:d?d.message:"Requesting signer from Farcaster"}),/*#__PURE__*/e.jsx(wc,{children:d?d.detail:"This should only take a moment"}),/*#__PURE__*/e.jsx(Po,{children:w&&n.isMobile&&/*#__PURE__*/e.jsx(Kc,{text:"Take me to Warpcast",url:w,color:Mw})})]})]})}),/*#__PURE__*/e.jsx(fi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:t?a:void 0,onClose:c},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Ow,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(gc,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e.jsxs(wc,{children:["This will allow ",s.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/e.jsx(No,{children:"pending_approval"===g?.status?/*#__PURE__*/e.jsx(nd,{url:g.signer_approval_url,size:275,squareLogoElement:Rc}):/*#__PURE__*/e.jsx(mo,{})}),/*#__PURE__*/e.jsxs(Po,{children:[/*#__PURE__*/e.jsx(wc,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===g?.status&&/*#__PURE__*/e.jsx(qc,{text:g.signer_approval_url,itemName:"link",color:Mw})]})]})}),/*#__PURE__*/e.jsx(fi,{})]})}};let Ow=/*#__PURE__*/h.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-6e8f76e5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),Uw=/*#__PURE__*/h.styled.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e8f76e5-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Fw={component:()=>{let{closePrivyModal:t}=i.usePrivyInternal();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Rw,{children:/*#__PURE__*/e.jsx(De.default,{style:{width:32,height:32}})}),/*#__PURE__*/e.jsx(Si,{title:"Could not log in with provider",description:"It looks like you're using an in-app browser. To log in, please try again using an external browser.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(vo,{onClick:()=>t(),children:"Close"})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}};let Rw=/*#__PURE__*/h.styled.div.withConfig({displayName:"StyledCircle",componentId:"sc-7bde5742-0"})(["border-radius:50%;height:68px;width:68px;display:flex;align-items:center;justify-content:center;background-color:var(--privy-color-accent);color:white;margin:0 auto 24px auto;"]);const Lw={component:()=>{let{app:t}=Qu();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Pi,{title:"Connect your email",description:`Add your email to your ${t?.name} account`,icon:/*#__PURE__*/e.jsx(Oe.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(hu,{stacked:!0})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}},Dw={component:()=>{let{app:t,currentScreen:r,data:n,navigate:a,setModalData:o}=Qu(),{initLoginWithSms:s}=i.usePrivyInternal();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Pi,{title:"Connect your phone",description:`Add your number to your ${t?.name} account`,icon:/*#__PURE__*/e.jsx(Fe.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(Id,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await s({phoneNumber:e,withPrivyUi:!0}),a(eu)}catch(e){o({errorModalData:{error:e,previousScreen:n?.errorModalData?.previousScreen||r||Dw}}),a(Es)}},hideRecent:!0})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}},Bw={component:()=>{let{app:t,data:r}=Qu(),n=r?.externalConnectWallet?.suggestedAddress,a=n?/*#__PURE__*/e.jsxs("span",{children:["Link the wallet with address ",/*#__PURE__*/e.jsx(Mi,{showCopyIcon:!1,address:n})," ",t?.name?`to ${t.name}.`:"."]}):`Link a wallet to your ${t?.name} account`,{connectors:o}=i.usePrivyInternal(),s=Zu({walletList:r?.externalConnectWallet?.walletList??t.appearance.walletList,walletChainType:r?.externalConnectWallet?.walletChainType??t.appearance.walletChainType,connectors:o,connectOnly:!1,ignore:t.appearance.walletList,walletConnectEnabled:t.externalWallets.walletConnect.enabled});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),s.length>0&&/*#__PURE__*/e.jsx(Si,{title:"Link your wallet",description:a}),/*#__PURE__*/e.jsx(Ri,{children:/*#__PURE__*/e.jsx(Ku,{wallets:s})}),/*#__PURE__*/e.jsx(yi,{})]})}},zw=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{width:"164",height:"164",viewBox:"0 0 164 164",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...t},...r,children:[/*#__PURE__*/e.jsx("circle",{cx:"82",cy:"82",r:"80",stroke:"#EC6351","stroke-width":"4","stroke-linecap":"round"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M81.9999 100.788C93.3288 100.788 102.513 91.6043 102.513 80.2754C102.513 68.9465 93.3288 59.7626 81.9999 59.7626C70.671 59.7626 61.4871 68.9465 61.4871 80.2754C61.4871 91.6043 70.671 100.788 81.9999 100.788ZM88.3236 71.8304C88.9093 71.2446 89.8591 71.2446 90.4449 71.8304C91.0307 72.4161 91.0307 73.3659 90.4449 73.9517L84.121 80.2756L90.445 86.5996C91.0308 87.1854 91.0308 88.1351 90.445 88.7209C89.8592 89.3067 88.9095 89.3067 88.3237 88.7209L81.9997 82.3969L75.6756 88.7209C75.0899 89.3067 74.1401 89.3067 73.5543 88.7209C72.9685 88.1351 72.9685 87.1854 73.5543 86.5996L79.8783 80.2756L73.5544 73.9517C72.9686 73.3659 72.9686 72.4161 73.5544 71.8304C74.1402 71.2446 75.09 71.2446 75.6758 71.8304L81.9997 78.1543L88.3236 71.8304Z",fill:"#EC6351"})]}),$w={component:()=>{let{closePrivyModal:t}=i.usePrivyInternal(),{navigate:r}=Qu();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(zw,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/e.jsx(Si,{title:"Could not connect with wallet",description:"Please check that Phantom multichain is enabled and try again.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/e.jsxs(So,{children:[/*#__PURE__*/e.jsx(vo,{onClick:()=>r(xu),children:"Try again"}),/*#__PURE__*/e.jsx(ko,{onClick:()=>t(),children:"Cancel"})]}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}};function Vw(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:a,submitEnrollmentWithTotp:i,submitEnrollmentWithPasskey:o,unenroll:s,enrollInMfa:l}=r.useContext($o);return{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:a,submitEnrollmentWithTotp:i,submitEnrollmentWithPasskey:o,unenrollWithSms:()=>s("sms"),unenrollWithTotp:()=>s("totp"),unenrollWithPasskey:e=>s("passkey",e),showMfaEnrollmentModal:()=>l(!0),closeMfaEnrollmentModal:()=>l(!1)}}const qw=t=>/*#__PURE__*/e.jsxs(Hw,{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"88",height:"89",viewBox:"0 0 88 89",...t,children:[/*#__PURE__*/e.jsx("rect",{y:"0.666016",width:"88",height:"88",rx:"44"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M45.2463 20.9106C44.5473 20.2486 43.4527 20.2486 42.7537 20.9106C37.8798 25.5263 31.3034 28.3546 24.0625 28.3546C23.9473 28.3546 23.8323 28.3539 23.7174 28.3525C22.9263 28.3427 22.2202 28.8471 21.9731 29.5987C20.9761 32.6311 20.4375 35.8693 20.4375 39.2297C20.4375 53.5896 30.259 65.651 43.5482 69.0714C43.8446 69.1477 44.1554 69.1477 44.4518 69.0714C57.741 65.651 67.5625 53.5896 67.5625 39.2297C67.5625 35.8693 67.0239 32.6311 66.0269 29.5987C65.7798 28.8471 65.0737 28.3427 64.2826 28.3525C64.1677 28.3539 64.0527 28.3546 63.9375 28.3546C56.6966 28.3546 50.1202 25.5263 45.2463 20.9106ZM52.7249 40.2829C53.3067 39.4683 53.1181 38.3363 52.3035 37.7545C51.4889 37.1726 50.3569 37.3613 49.7751 38.1759L41.9562 49.1223L38.0316 45.1977C37.3238 44.4899 36.1762 44.4899 35.4684 45.1977C34.7605 45.9056 34.7605 47.0532 35.4684 47.761L40.9059 53.1985C41.2826 53.5752 41.806 53.7671 42.337 53.7232C42.868 53.6792 43.3527 53.4039 43.6624 52.9704L52.7249 40.2829Z"})]});let Hw=/*#__PURE__*/h.styled.svg.withConfig({displayName:"StyledSvg",componentId:"sc-59fa943f-0"})(["height:90px;width:90px;> rect{","}> path{fill:white;}"],(e=>"success"===e.color?"fill: var(--privy-color-success);":"fill: var(--privy-color-accent);"));const Kw=({showIntro:t,userMfaMethods:r,appMfaMethods:n,userHasAuthSms:a,isTotpLoading:i,isPasskeyLoading:o,error:s,onClose:l,onBackToIntro:c,handleSelectMethod:d,setRemovingMfaMethod:u})=>{let p=r.reduce(((e,t)=>({...e,[t]:!0})),{}),h=n.reduce(((e,t)=>({...e,[t]:!0})),{});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:t?c:void 0,onClose:l},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(rt.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Choose a verification method"}),r.length>0?/*#__PURE__*/e.jsx(wc,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/e.jsx(wc,{children:"How would you like to verify your identity? You can change this later."}),s&&/*#__PURE__*/e.jsx(Mc,{style:{marginTop:"1.25rem"},children:s.message}),/*#__PURE__*/e.jsxs(kc,{children:[(h.totp||p.totp)&&/*#__PURE__*/e.jsxs(Ec,{children:[/*#__PURE__*/e.jsx(zi,{style:{justifyContent:"center"},disabled:p.totp||i,onClick:()=>d("totp"),children:i?/*#__PURE__*/e.jsx(mo,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e.jsxs(Sc,{children:[/*#__PURE__*/e.jsxs(Ac,{children:[/*#__PURE__*/e.jsx(ot.default,{}),"Authenticator app"]}),p.totp?/*#__PURE__*/e.jsx(Zw,{color:"green",children:"Enabled"}):/*#__PURE__*/e.jsx(Ic,{children:"Recommended"})]})}),p.totp&&/*#__PURE__*/e.jsx(Tc,{style:{position:"absolute",right:0},onClick:()=>u("totp"),children:/*#__PURE__*/e.jsx(bt.default,{})})]},"totp"),(h.sms||p.sms)&&/*#__PURE__*/e.jsxs(Ec,{children:[/*#__PURE__*/e.jsx(zi,{disabled:p.sms||a,onClick:()=>d("sms"),children:/*#__PURE__*/e.jsxs(Sc,{children:[/*#__PURE__*/e.jsxs(Ac,{children:[/*#__PURE__*/e.jsx(Fe.default,{}),"SMS"]}),p.sms&&/*#__PURE__*/e.jsx(Zw,{color:"green",children:"Enabled"}),a&&/*#__PURE__*/e.jsx(Ic,{children:"Disabled"})]})}),p.sms&&/*#__PURE__*/e.jsx(Tc,{style:{position:"absolute",right:0},onClick:()=>u("sms"),children:/*#__PURE__*/e.jsx(bt.default,{})})]},"sms"),(h.passkey||p.passkey)&&/*#__PURE__*/e.jsxs(Ec,{children:[/*#__PURE__*/e.jsx(zi,{style:{justifyContent:"center"},onClick:()=>d("passkey"),disabled:p.passkey||o,children:o?/*#__PURE__*/e.jsx(mo,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e.jsxs(Sc,{children:[/*#__PURE__*/e.jsxs(Ac,{children:[/*#__PURE__*/e.jsx(at.default,{}),"Passkey"]}),p.passkey?/*#__PURE__*/e.jsx(Zw,{color:"green",children:"Enabled"}):/*#__PURE__*/e.jsx(Ic,{isAccent:!0,children:/*#__PURE__*/e.jsx(it.default,{})})]})}),p.passkey&&/*#__PURE__*/e.jsx(Tc,{style:{position:"absolute",right:0},onClick:()=>u("passkey"),children:/*#__PURE__*/e.jsx(bt.default,{})})]},"passkey")]}),/*#__PURE__*/e.jsx(fi,{})]})};let Zw=/*#__PURE__*/h.styled(Ji).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const Gw=({appName:t,onComplete:n,onClose:a,onReset:o})=>{let{user:s}=Vo(),{data:l}=Qu(),{initLinkWithPasskey:c,linkWithPasskey:d}=i.usePrivyInternal(),{initEnrollmentWithPasskey:u,submitEnrollmentWithPasskey:p}=Vw(),[h,m]=r.useState(!1),[y,f]=r.useState(!1),[g,w]=r.useState(!1),[v,x]=r.useState(null),C=r.useMemo((()=>s?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[s]),b=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},j=async e=>{m(!0);try{await u(),await p({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),w(!0)}catch(e){x(e)}finally{m(!1)}},k=async()=>{f(!0),x(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await j(t)}catch(e){x(e)}finally{f(!1)}};return 0===C.length||y?/*#__PURE__*/e.jsx(Yw,{onReset:o,onClose:a,onClick:k,isCreating:y}):g?/*#__PURE__*/e.jsx(Xw,{appName:t,onClick:b,onClose:b}):v?/*#__PURE__*/e.jsx(Ts,{error:v,backFn:()=>x(null),onClick:()=>x(null)}):/*#__PURE__*/e.jsx(Jw,{passkeys:C,isSubmitting:h,isCreating:y,onReset:o,onClose:a,onSubmitEnrollment:()=>j(C.map((e=>e.credentialId))),onAddPasskey:k})};let Yw=({onReset:t,onClose:r,onClick:n,isCreating:a})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:t,onClose:r},"header"),/*#__PURE__*/e.jsx(fc,{children:/*#__PURE__*/e.jsxs(Wy,{children:[/*#__PURE__*/e.jsx(wd,{}),/*#__PURE__*/e.jsx(vd,{})]})}),/*#__PURE__*/e.jsx(gc,{children:"Set up passkey verification"}),/*#__PURE__*/e.jsxs(xc,{children:[/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(rt.default,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(wt.default,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(jt.default,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/e.jsx(vo,{style:{marginTop:"2.25rem"},onClick:n,loading:a,children:"Add a new passkey"}),/*#__PURE__*/e.jsx(fi,{})]}),Jw=({onReset:t,onClose:n,onAddPasskey:a,onSubmitEnrollment:i,passkeys:o,isSubmitting:s,isCreating:l})=>{let[c,d]=r.useState(!1),u=c?o.length:o.length>3?2:3;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:c?()=>d(!1):t,onClose:n},"header"),!c&&/*#__PURE__*/e.jsx(fc,{children:/*#__PURE__*/e.jsxs(Wy,{children:[/*#__PURE__*/e.jsx(wd,{}),/*#__PURE__*/e.jsx(vd,{})]})}),/*#__PURE__*/e.jsx(gc,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e.jsxs(xc,{children:[o.slice(0,u).map((t=>/*#__PURE__*/e.jsxs(Qw,{children:[/*#__PURE__*/e.jsx(ev,{children:rv(t)}),/*#__PURE__*/e.jsxs(tv,{children:["Last used: ",t.latestVerifiedAt?.toLocaleString()]})]},t.credentialId))),!c&&o.length>3&&/*#__PURE__*/e.jsx(nv,{onClick:()=>d(!0),children:"View All"})]}),/*#__PURE__*/e.jsx(vo,{style:{marginTop:"1.5rem"},onClick:i,loading:s,children:"Enable passkeys"}),o.length<5&&/*#__PURE__*/e.jsx(nv,{style:{marginTop:"0.5rem"},onClick:a,disabled:l,children:l?/*#__PURE__*/e.jsx(mo,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/e.jsx(fi,{})]})},Xw=({appName:t,onClick:r,onClose:n})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:n},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ct.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Passkey verification added"}),/*#__PURE__*/e.jsxs(wc,{children:["From now on, you'll use the passkey whenever you use your ",t," wallet."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{onClick:r,children:"Done"})}),/*#__PURE__*/e.jsx(fi,{})]}),Qw=/*#__PURE__*/h.styled.div.withConfig({displayName:"PasskeyItem",componentId:"sc-d5b2bf9c-0"})(["&&{padding:0.75rem 1rem;text-align:left;border-radius:0.5rem;border:1px solid var(--privy-color-foreground-4);width:100%;}"]),ev=/*#__PURE__*/h.styled.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-d5b2bf9c-1"})(["font-size:0.875rem;line-height:1.375rem;font-weight:500;color:var(--privy-color-foreground-1);"]),tv=/*#__PURE__*/h.styled.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-d5b2bf9c-2"})(["font-size:0.75rem;font-weight:400;line-height:1.125rem;color:var(--privy-color-foreground-2);"]),rv=e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device";const nv=/*#__PURE__*/h.styled.button.withConfig({displayName:"StyledLink",componentId:"sc-d5b2bf9c-3"})(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:0.75rem 1rem;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent);:focus{outline:none;box-shadow:none;}}"]),av=({appName:t,onComplete:n,onReset:a,onClose:i})=>{let[o,s]=r.useState(""),[l,c]=r.useState(!1),[d,p]=r.useState(null),[h,m]=r.useState("enroll"),{initEnrollmentWithSms:y,submitEnrollmentWithSms:f}=Vw(),{app:g,data:w}=Qu();function v(){w?.mfaEnrollmentFlow?.onSuccess(),n()}return d?/*#__PURE__*/e.jsx(Ts,{error:d,backFn:()=>p(null),onClick:()=>p(null)}):"enroll"===h?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:a,onClose:i},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Fe.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Set up SMS verification"}),/*#__PURE__*/e.jsxs(wc,{children:["We'll text a verification code to this mobile device whenever you use your ",t," ","wallet."]}),/*#__PURE__*/e.jsxs(vc,{children:[/*#__PURE__*/e.jsx(Id,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await y({phoneNumber:e}),s(e),m("verify")}catch(e){p(e)}},hideRecent:!0}),/*#__PURE__*/e.jsxs(Pc,{children:["By providing your mobile number, you agree to receive text messages from ",g?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/e.jsx(fi,{})]}):l?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:v},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ct.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"SMS verification added"}),/*#__PURE__*/e.jsxs(wc,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",t," wallet."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{onClick:v,children:"Done"})}),/*#__PURE__*/e.jsx(fi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:function(){"verify"===h?m("enroll"):a()},onClose:i},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Fe.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Enter enrollment code"}),/*#__PURE__*/e.jsxs(vc,{children:[/*#__PURE__*/e.jsx(Tp,{onChange:async function(e){try{if(!e)return;await f({phoneNumber:o,mfaCode:e}),c(!0)}catch(e){if(ms(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(ps(e))throw Error("The code you entered is not valid");if(us(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw ys(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e.jsxs(wc,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/e.jsx("strong",{children:u.lastFourDigits(o)})]})]}),/*#__PURE__*/e.jsx(fi,{})]})},iv=({size:t,authUrl:r})=>/*#__PURE__*/e.jsx(nd,{url:r,squareLogoElement:kt.default,size:t,fgColor:"#1F1F1F"}),ov=({onComplete:t,onClose:n,onReset:a,totpInfo:i})=>{let[o,s]=r.useState("enroll"),[l,c]=r.useState(!1),{submitEnrollmentWithTotp:d}=Vw(),{data:u}=Qu();function p(){u?.mfaEnrollmentFlow?.onSuccess(),t()}return"enroll"===o?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:a,onClose:n},"header"),/*#__PURE__*/e.jsx(gc,{children:"Scan QR code"}),/*#__PURE__*/e.jsx(wc,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/e.jsx(No,{children:/*#__PURE__*/e.jsx(iv,{authUrl:i.authUrl,size:200})}),/*#__PURE__*/e.jsxs(jc,{children:[/*#__PURE__*/e.jsx(Po,{children:/*#__PURE__*/e.jsx(qc,{itemName:"setup key",text:i.secret})}),/*#__PURE__*/e.jsx(vo,{onClick:function(){s("verify")},children:"Continue"})]}),/*#__PURE__*/e.jsx(fi,{})]}):l?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:p},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ct.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Authenticator app verification added"}),/*#__PURE__*/e.jsxs(wc,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",i.appName," wallet."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{onClick:p,children:"Done"})}),/*#__PURE__*/e.jsx(fi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:function(){"verify"===o?s("enroll"):a()},onClose:n},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ot.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Enter enrollment code"}),/*#__PURE__*/e.jsx(vc,{children:/*#__PURE__*/e.jsx(Tp,{onChange:async function(e){try{if(!e)return;await d({mfaCode:e}),c(!0)}catch(e){if(ms(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(ps(e))throw Error("The code you entered is not valid");if(us(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw ys(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e.jsxs(wc,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/e.jsx("strong",{children:"authenticator app"})]}),/*#__PURE__*/e.jsx(fi,{})]})},sv={component:()=>{let{user:t,enrollInMfa:n,ready:a}=Vo(),[o,s]=r.useState(null),{unenrollWithSms:l,unenrollWithTotp:c,unenrollWithPasskey:d}=Vw(),{app:u,data:p,onUserCloseViaDialogOrKeybindRef:h}=Qu(),{closePrivyModal:m}=i.usePrivyInternal(),{promptMfa:y}=Uh(),{initEnrollmentWithTotp:f}=Vw(),[g,w]=r.useState(!1),[v,x]=r.useState(null),[C,b]=r.useState(null),j=()=>{m({shouldCallAuthOnSuccess:!0}),n(!1),setTimeout((()=>{s(null),x(null)}),500)},{initEnrollmentWithPasskey:k,submitEnrollmentWithPasskey:E}=Vw(),[T,A]=r.useState(!1),[I,S]=r.useState(null);h.current=j;let P=t?.mfaMethods.includes("sms"),_=!!t?.phone,N=t?.mfaMethods.includes("totp"),M=t?.mfaMethods.includes("passkey"),W=P||N||M,O=t?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function U(){s(null),x(null)}if(r.useEffect((()=>{W&&w(!0)}),[W]),!a||!t||!u/*#__PURE__*/)return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:j},"header"),/*#__PURE__*/e.jsx(fc,{children:/*#__PURE__*/e.jsx(qw,{})}),/*#__PURE__*/e.jsx(vc,{children:/*#__PURE__*/e.jsx(mo,{})}),/*#__PURE__*/e.jsx(fi,{})]});if("sms"===o)/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:U,onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Se.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Remove SMS verification?"}),/*#__PURE__*/e.jsxs(wc,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{warn:!0,onClick:async function(){s(null);try{await l()}catch(e){s(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/e.jsx(fi,{})]});if("totp"===o)/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:U,onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Se.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e.jsxs(wc,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{warn:!0,onClick:async function(){s(null);try{await c()}catch(e){s(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/e.jsx(fi,{})]});if("passkey"===o){let t=p?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:U,onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Se.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/e.jsx(wc,{children:t?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{warn:!0,onClick:async function(){s(null);try{await d({removeForLogin:p?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){s(null)}},children:"Yes, remove"})}),/*#__PURE__*/e.jsx(fi,{})]})}if(0===p.mfaEnrollmentFlow.mfaMethods.length&&!W)/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(rt.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Add more security"}),/*#__PURE__*/e.jsxs(wc,{children:[u?.name," does not have any verification methods enabled."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{onClick:j,children:"Close"})}),/*#__PURE__*/e.jsx(fi,{})]});let F=!W&&!g;return F?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(rt.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Transaction Protection"}),/*#__PURE__*/e.jsx(wc,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e.jsxs(xc,{children:[/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(xt.default,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(Ct.default,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e.jsxs(jc,{children:[/*#__PURE__*/e.jsx(vo,{onClick:()=>w(!0),children:"Continue"}),/*#__PURE__*/e.jsx(ko,{onClick:j,children:"Not now"})]}),/*#__PURE__*/e.jsx(fi,{})]}):"sms"===v?/*#__PURE__*/e.jsx(av,{appName:u?.name||"Privy",onComplete:j,onReset:U,onClose:j}):"totp"===v&&C?/*#__PURE__*/e.jsx(ov,{onComplete:j,onClose:j,onReset:U,totpInfo:{...C,appName:u?.name||"Privy"}}):"passkey"===v?/*#__PURE__*/e.jsx(Gw,{appName:u?.name||"Privy",onComplete:j,onReset:U,onClose:j}):/*#__PURE__*/e.jsx(Kw,{showIntro:F,userMfaMethods:t.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:_,onBackToIntro:function(){w(!1)},handleSelectMethod:async function(e){return await y().catch(S),"totp"===e?(x(e),b(null),void f().then((e=>{b(e)})).catch((()=>{b(null),U()}))):"passkey"===e&&1===O.length?await async function(){A(!0);try{await k(),await E({credentialIds:O},{removeForLogin:p?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){S(e)}finally{A(!1)}}():void x(e)},isTotpLoading:"totp"===v&&!C,isPasskeyLoading:T,error:I,onClose:j,setRemovingMfaMethod:async e=>{await y().catch(S),s(e)}})}},lv={component:()=>{let{authenticated:t,logout:n,ready:a,user:o}=Vo(),{app:s,setModalData:l,navigate:c,resetNavigation:d}=Qu(),{getAuthMeta:u,initLoginWithOAuth:p,loginWithOAuth:h,updateWallets:m,setReadyToTrue:y,closePrivyModal:f,createAnalyticsEvent:g}=i.usePrivyInternal(),[w,v]=r.useState(!1),[x,C]=r.useState(void 0),b=u()?.provider||"google",{name:j,component:k}=Yr(b);r.useEffect((()=>{h(b).then((()=>{v(!0),y(!0)})).catch((e=>{if(y(!1),e?.privyErrorCode===i.PrivyErrorCode.ALLOWLIST_REJECTED)return C(void 0),d(),void c(ad);if(e?.privyErrorCode===i.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new i.PrivyUserLimitReachedError(e).toString()),C(void 0),d(),void c(ld);if(e?.privyErrorCode===i.PrivyErrorCode.USER_DOES_NOT_EXIST)return C(void 0),d(),void c(Cu);if(e?.privyErrorCode===i.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return C(void 0),d(),l({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:u()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void c(Bs);let{retryable:t,detail:r}=function(e,t){let r={detail:"",retryable:!1},n=Rr(t);if(e?.privyErrorCode===i.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(r.detail="This account has already been linked to another user."),e?.privyErrorCode===i.PrivyErrorCode.INVALID_CREDENTIALS&&(r.retryable=!0,r.detail="Something went wrong. Try again."),e.privyErrorCode===i.PrivyErrorCode.OAUTH_USER_DENIED&&(r.detail=`Retry and check ${n} to finish connecting your account.`,r.retryable=!0),e?.privyErrorCode===i.PrivyErrorCode.TOO_MANY_REQUESTS&&(r.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===i.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=Yr(t).name;r.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===i.PrivyErrorCode.OAUTH_ACCOUNT_SUSPENDED){let e=Yr(t).name;r.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===i.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(r.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===i.PrivyErrorCode.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(r.detail="Something went wrong. Please try again."),r}(e,b);C({retryable:t,detail:r,message:"Authentication failed"})})).finally((()=>{Xr()}))}),[j,b]),r.useEffect((()=>{if(a&&t&&w&&o){if(s?.legal.requireUsersAcceptTerms&&!o.hasAcceptedTerms){let e=setTimeout((()=>{c(Wc)}),or);return()=>clearTimeout(e)}if(Go(o,s.embeddedWallets)){let e=setTimeout((()=>{l({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),g({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:b,screen:"OAuthStatusScreen"}}),n()},callAuthOnSuccessOnClose:!0}}),c(mc)}),or);return()=>clearTimeout(e)}{let e=setTimeout((()=>f({shouldCallAuthOnSuccess:!0,isSuccess:!0})),or);return m(),()=>clearTimeout(e)}}}),[a,t,w,o]);let E=w?`Successfully connected with ${j}`:x?x.message:`Verifying connection to ${j}`,T="";return T=w?"You’re good to go!":x?x.detail:"Just a few moments more",/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{}),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsxs(cv,{children:[/*#__PURE__*/e.jsx(Jo,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(ho,{success:w,fail:!!x}),/*#__PURE__*/e.jsx(k,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e.jsxs(Oo,{children:[/*#__PURE__*/e.jsx("h3",{children:E}),/*#__PURE__*/e.jsx("p",{children:T})]}),x&&x?.retryable?/*#__PURE__*/e.jsx(To,{onClick:()=>{Xr(),p(b),C(void 0)},disabled:!w&&!x?.retryable,children:"Retry"}):null]}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(fi,{})]})}};let cv=/*#__PURE__*/h.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-89bb91a9-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const dv=/*#__PURE__*/r.forwardRef(((t,n)=>{let[a,o]=r.useState(""),[s,l]=r.useState(""),[c,d]=r.useState(!1),{authenticated:u,user:p}=Vo(),{initUpdateEmail:h}=i.usePrivyInternal(),{navigate:m,setModalData:y,currentScreen:f}=Qu(),{enabled:g,token:w}=cn(),v=di(),x=Rt(a)&&(v.disablePlusEmails&&a.includes("+")?(s||l("Please enter a valid email address without a '+'."),!1):(s&&l(""),!0)),C=c||!x,b=()=>{!g||w||u?(async e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");d(!0);try{await h(p.email.address,a,e),m(eu)}catch(e){y({errorModalData:{error:e,previousScreen:f||xu}})}d(!1)})(w):(y({captchaModalData:{callback:e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");return h(p.email.address,a,e)},userIntentRequired:!1,onSuccessNavigateTo:eu,onErrorNavigateTo:Es}}),m(Bc))};/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(uv,{children:[s&&/*#__PURE__*/e.jsx(lu,{style:{marginTop:"0.25rem",textAlign:"left"},children:s}),/*#__PURE__*/e.jsxs(pv,{$error:!!s,children:[/*#__PURE__*/e.jsx(Oe.default,{}),/*#__PURE__*/e.jsx("input",{ref:n,id:"email-input",type:"email",placeholder:"your@email.com",onChange:e=>o(e.target.value),onKeyUp:e=>{"Enter"===e.key&&b()},value:a,autoComplete:"email"}),t.stacked?null:/*#__PURE__*/e.jsx(Ao,{isSubmitting:c,onClick:b,disabled:C,children:"Submit"})]})]}),t.stacked?/*#__PURE__*/e.jsx(vo,{loadingText:null,loading:c,disabled:C,onClick:b,children:"Submit"}):null]})}));let uv=pu,pv=du;const hv={component:()=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Pi,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/e.jsx(Oe.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(dv,{stacked:!0})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})},mv={component:()=>{let{currentScreen:t,data:r,navigate:n,setModalData:a}=Qu(),{user:o}=Vo(),{initUpdatePhone:s}=i.usePrivyInternal();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Pi,{title:"Update your phone number",description:"Add the phone number you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/e.jsx(Fe.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(Id,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{if(!o?.phone?.number)throw Error("User is required to have an phone number to update it.");await s(o?.phone?.number,e),n(eu)}catch(e){a({errorModalData:{error:e,previousScreen:r?.errorModalData?.previousScreen||t||Dw}}),n(Es)}},hideRecent:!0})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}};let yv,fv,gv,wv,vv,xv,Cv;async function bv(){return yv?yv.getAccessToken():Promise.resolve(Nt.get(hr)||Nt.get(dr)||null)}const jv=(e,t)=>fv(e,t),kv=(e,t)=>gv(e,t),Ev=(e,t)=>wv(e,t),Tv=(e,t)=>vv(e,t),Av=()=>xv(),Iv=()=>Cv();let Sv=o=>{let s=o.client,l=Um();pm();let[c,d]=r.useState(!1),[u,p]=r.useState(!1),[h,m]=r.useState(!1),[y,f]=r.useState(null),[g,w]=r.useState([]),[v,x]=r.useState([]),[C,b]=r.useState(!1),[j,k]=r.useState(null),[E,T]=r.useState(!1),[A,I]=r.useState({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:i.notImplemented}),[S,P]=r.useState({status:"initial"}),[_,N]=r.useState({status:"initial"}),[M,W]=r.useState({status:"initial"}),[O,U]=r.useState({status:"initial"}),[F,R]=r.useState({status:"initial"}),[L,D]=r.useState({status:"initial"}),[B,z]=r.useState(null),$=di(),V=ui(),[q,H]=r.useState({}),[K,Z]=r.useState(null),[G,Y]=r.useState(null),[J,X]=r.useState(!1),[Q,ee]=r.useState(!1),[te,re]=r.useState($.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),ne=r.useRef(null),ae=r.useRef(null),ie=r.useRef(eo),[oe,se]=r.useState(!1);s.onStoreCustomerAccessToken=e=>{e&&ao(ie,"accessToken","onAccessTokenGranted",{accessToken:e})},s.onDeleteCustomerAccessToken=()=>{f(null),m(!1),ao(ie,"accessToken","onAccessTokenRemoved")};let le=r.useRef(null),ce=r.useRef(null),de=r.useRef(!1),ue=({showWalletUIs:e})=>de.current?de.current:void 0!==e?!e:!$.embeddedWallets.showWalletUIs,pe=e=>{k(e),setTimeout((()=>{d(!0)}),15)};r.useEffect((()=>{if(!y)return void s.connectors?.removeEmbeddedWalletConnectors();let e=wn(y),t=vn(y),r=bn(y);e&&t.length||s.connectors?.removeEmbeddedWalletConnectors(),r||s.connectors?.removeImportedWalletConnector(),s.connectors?B?(e&&s.connectors.addEmbeddedWalletConnectors({walletProxy:B,user:y,embeddedWallets:t,defaultChain:$.defaultChain,appId:o.appId}),r&&s.connectors.addImportedWalletConnector(B,r.address,$.defaultChain,o.appId)):console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized"):console.debug("Failed to add embedded wallet connector: Client connectors not initialized")}),[B,y]),r.useEffect((()=>{B&&G?.(B)}),[B]);let he=r.useRef();r.useEffect((()=>{(async()=>{if(!$.customAuth?.enabled)return void re({status:"not-enabled"});let{getCustomAccessToken:e,isLoading:t}=$.customAuth;if(u&&!t&&"loading"!==te.status){re({status:"loading"});try{let t=await e();if(t===he.current)return void re({status:"done"});if(!t&&h)return he.current=t,await Fe.logout(),re({status:"done"}),void ao(ie,"customAuth","onUnauthenticated");if(!t)return he.current=t,void re({status:"done"});s.startAuthFlow(new Tt(t));let{user:r,isNewUser:n}=await s.authenticate();if(!r)return await Fe.logout(),re({status:"error",error:new i.PrivyClientError("Failed to sync with custom auth provider")}),void ao(ie,"customAuth","onUnauthenticated");void 0!==n&&ao(ie,"login","onComplete",{user:r,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),he.current=t,ao(ie,"customAuth","onAuthenticated",{user:r}),re({status:"done"}),f(r||null),b(n||!1),m(!0),ee(!0)}catch(e){if(console.warn(e),await Fe.logout(),ao(ie,"customAuth","onUnauthenticated"),"User already exists with provided custom JWT account."===e.message)return void re({status:"initial"});ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),re({status:"error",error:e})}}})()}),["initial"===te.status,$.customAuth?.enabled,$.customAuth?.getCustomAccessToken,$.customAuth?.isLoading,u,h]),r.useEffect((()=>{Q&&B&&y&&(async()=>{let e=qo(y,$.embeddedWallets.ethereum.createOnLogin),t=Ko(y,$.embeddedWallets.solana.createOnLogin),r=await bv();if(r){if(e&&t){let e=await Ee(y,Ir);return await B.createSolana({accessToken:r,ethereumAddress:e?.address}),void ee(!1)}if(t)return await B.createSolana({accessToken:r,ethereumAddress:wn(y)?.address}),await Re.refreshSessionAndUser(),void ee(!1);if(e)return await Ee(y,Ir),void ee(!1)}})().catch(console.error)}),[Q&&B&&y]),r.useEffect((()=>{if($.externalWallets.solana.connectors)return $.externalWallets.solana.connectors.onMount(),()=>$.externalWallets.solana.connectors?.onUnmount()}),[$.externalWallets.solana.connectors]),r.useEffect((()=>{!u&&V&&async function(){let e,r=me(),n=ye(),a=t.createStore();s.initializeConnectorManager({walletConnectCloudProjectId:$.walletConnectCloudProjectId,rpcConfig:$.rpcConfig,chains:$.chains,defaultChain:$.defaultChain,store:a,walletList:$.appearance.walletList,shouldEnforceDefaultChainOnConnect:$.shouldEnforceDefaultChainOnConnect,externalWalletConfig:$.externalWallets,appName:$.name??"Privy",walletChainType:$.appearance.walletChainType}),s.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=s.connectors.walletConnectors.length,r=s.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);r===t?se(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:r,expected:t}),se(!0)}),1500)})),s.connectors?.initialize().then((()=>{xe()}));let i=await s.getAuthenticatedUser(),o=!!i;$.legal.requireUsersAcceptTerms&&i&&!i.hasAcceptedTerms?(await s.logout(),Re.setReadyToTrue(!0),ao(ie,"logout","onSuccess")):($.customAuth?.enabled||(m(!!i),i&&ao(ie,"login","onComplete",{user:i,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),f(i)),r?ce.current=o?"link":"login":n&&!o?(ce.current="login",H({telegramAuthModalData:{seamlessAuth:!0}}),pe(Ud)):Re.setReadyToTrue(!!i))}()}),[s,K,u,V]),r.useEffect((()=>{if(u){if(!y||!y.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType))||[...g].some((e=>"privy"===e.walletClientType)))return void X(!0);X(!!B)}}),[u,y,g]),r.useEffect((()=>{s.connectors?.setWalletList($.appearance.walletList)}),[$.appearance.walletList.join()]);let me=()=>{let e=Jr();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&function(e){return e.startsWith("privy:")}(e.provider)&&!e.popupFlow&&(new BroadcastChannel(mm).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(s.startAuthFlow(new Fr(e)),pe(lv),!0))},ye=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),r=e.get("hash"),n=Number(e.get("auth_date")||""),a=e.get("first_name");if(t&&a&&n&&r)return Object.fromEntries(e.entries())}())?(hn(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=pn(e.replace("#tgWebAppData=","")),{user:r,auth_date:n,hash:a}=t;return r&&n&&a?t:void 0}())?(hn(),{flowType:"web-app",authData:e}):void 0}();if(!e||!$.loginMethods.telegram||!$.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new dn;return s.startAuthFlow(t),"login-url"===e.flowType&&(t.meta.telegramWebAppData=void 0,t.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=e.authData),!0},fe=async(e,t,r,n)=>{if("solana_adapter"!==e)ge(await(s.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,r,n);else{let e=s.connectors?.findSolanaWalletConnector(t);if(!e)return;ge(e,t,r,n)}};async function ge(e,t,r,n){if(!e)return I({status:"disconnected",connectedWallet:null,connectError:new i.PrivyConnectorError("Unable to connect to wallet."),connector:null,connectRetry:i.notImplemented}),n?.(null,r);I({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:i.notImplemented}),e instanceof ep&&t&&await e.resetConnection(t),I({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>ge(e,t,r,n)});try{let t=await e.connect({showPrompt:!0});if((!t||ea(t))&&$.shouldEnforceDefaultChainOnConnect&&!$.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){I((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:i.notImplemented})));try{await(t?.switchChain($.defaultChain.id)),t&&(t.chainId=Kt(qt($.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${$.defaultChain.id}`)}}return I((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:i.notImplemented}))),t&&ao(ie,"connectWallet","onSuccess",{wallet:t}),n?.(t,r)}catch(e){return e instanceof i.PrivyError?(console.warn(e.cause?e.cause:e.message),ao(ie,"connectWallet","onError",e.privyErrorCode||i.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),ao(ie,"connectWallet","onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR)),I((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),n?.(null,r)}}let we=async(e,t,r)=>{if(null===e||!ea(e))return;let n=new tn(e,s,t,r);s.startAuthFlow(n)},ve=async(e,t,r)=>{if(null===e||!Fa(e))return;let n=new rn(e,s,t,r);s.startAuthFlow(n)},xe=()=>{let e=new URLSearchParams(window.location.search),t=e.get("privy_connector"),r=e.get("privy_wallet_client"),n="true"===e.get("privy_connect_only");if(!t||!r)return;let a=Na({connectorType:t,walletClientType:r});if(!a||!a.isInstalled)return pe($w);if(!s.connectors)throw new i.PrivyClientError("Connector not initialized");pe(n?Su:Eu);let o=new URL(window.location.href);o.searchParams.delete("privy_connector"),o.searchParams.delete("privy_wallet_client"),o.searchParams.delete("privy_connect_only"),window.history.pushState({},"",o),fe(t,r,void 0,n?void 0:"solana_adapter"===t?ve:we)};r.useEffect((()=>{u&&h&&null===y&&s.getAuthenticatedUser().then(f)}),[u,h,y,s]);let Ce=e=>{if(!h)throw ao(ie,"linkAccount","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:e}),new i.PrivyClientError("User must be authenticated before linking an account.")},be=e=>{if(!h||!y)return!1;if("privy"===e.walletClientType)return!0;for(let t of y.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},je=async e=>{let t;if(!s.connectors)throw new i.PrivyClientError("Connector not initialized");t="ethereum"===e.type?s.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:s.connectors.findSolanaWalletConnector(e.walletClientType)||null,I((r=>({...r,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:i.notImplemented}))),$.captchaEnabled&&!h?(H({captchaModalData:{callback:t=>ea(e)?we(e,t):ve(e,t),userIntentRequired:!1,onSuccessNavigateTo:Eu,onErrorNavigateTo:Es}}),pe(Bc)):(ea(e)?await we(e):await ve(e),pe(Eu))},ke=()=>{w((e=>{let t=s.connectors?.wallets.filter(ea).map((e=>({...e,linked:be(e),loginOrLink:async()=>{if(!await e.isConnected())throw new i.PrivyClientError("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new i.PrivyClientError("Cannot link or login with embedded wallet");je(e)},fund:async t=>{await Re.fundWallet(e.address,t)},unlink:async()=>{if(!h)throw new i.PrivyClientError("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new i.PrivyClientError("Cannot unlink an embedded wallet");f(await s.unlinkEthereumWallet(e.address))}})))||[];return ta(e,t)?e:t})),x((e=>{let t=(s.connectors?.wallets??[]).filter(Fa).map((e=>({...e,linked:be(e),loginOrLink:async()=>{if(!await e.isConnected())throw new i.PrivyClientError("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new i.PrivyClientError("Cannot link or login with embedded wallet");je(e)},fund:async()=>{throw new i.PrivyClientError("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!h)throw new i.PrivyClientError("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new i.PrivyClientError("Cannot unlink an embedded wallet");f(await s.unlinkSolanaWallet(e.address))}})));return ta(e,t)?e:t}))};r.useEffect((()=>{ke()}),[y?.linkedAccounts,h,u]),r.useEffect((()=>{if(u){if(!s.connectors)throw new i.PrivyClientError("Connector not initialized");ke(),s.connectors.on("walletsUpdated",ke)}}),[u]),r.useEffect((()=>{[...$.loginMethodsAndOrder?.primary??[],...$.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>s.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!s]);let Ee=async(e,t,r)=>{let n=wn(e),a=Cn(e);if(r&&"walletIndex"in r&&"number"==typeof r.walletIndex)return Ie(e,t,r.walletIndex,n,a);let o=r&&"createAdditional"in r&&r.createAdditional;if(n&&!o)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");let[s,l]=await Promise.all([Re.initializeWalletProxy(t),bv()]);if(!s&&$.customAuth?.enabled)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!s||!l||$.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return Ae();if(!n)return a&&await Re.recoverPrimaryWallet(),await s.create({accessToken:l,solanaAddress:a?.address}),Pe(0,"ethereum");{let t=((e=>vn(e).reduce(((e,t)=>!e||e.walletIndex<t.walletIndex?t:e),null))(e)?.walletIndex??0)+1,{entropyId:r,entropyIdVerifier:n}=Sn(e);return await Re.recoverPrimaryWallet(),await s.addWallet({accessToken:l,entropyId:r,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:t}),Pe(t,"ethereum")}},Te=async(e,t,r)=>{let n=wn(e),a=Cn(e),o=r&&"createAdditional"in r&&r.createAdditional,s=r&&"walletIndex"in r?r.walletIndex:void 0,l=((e=>xn(e).reduce(((e,t)=>!e||e.walletIndex<t.walletIndex?t:e),null))(e)?.walletIndex??-1)+1;if(a&&!o&&"number"!=typeof s)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");if("number"==typeof s&&s<0)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${s}) is invalid.`);let[c,d]=await Promise.all([Re.initializeWalletProxy(t),bv()]);if(!c||!d)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return await Se({user:e,wp:c,accessToken:d,walletIndex:s??l,ethereumWallet:n})},Ae=async()=>new Promise(((e,t)=>{H({createWallet:{onSuccess:t=>{ao(ie,"createWallet","onSuccess",{wallet:t}),e(t)},onFailure:e=>{ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),t(e)},callAuthOnSuccessOnClose:!1}}),pe(mc)})),Ie=async(e,t,r,n,a)=>{if(r<0)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${r}) is invalid.`);let[o,s]=await Promise.all([Re.initializeWalletProxy(t),bv()]);if(!o&&$.customAuth?.enabled)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!o||!s||$.embeddedWallets?.requireUserOwnedRecoveryOnCreate){if(0==r)return Ae();throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Create wallet UI can only be displayed when walletIndex is 0.")}if(0===r){if(n)return n;await o.create({accessToken:s,solanaAddress:a?.address})}else{if(!n)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error("A user must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let t=vn(e).find((e=>e.walletIndex===r));if(t)return t;let{entropyId:a,entropyIdVerifier:l}=Sn(e);await Re.recoverPrimaryWallet(),await o.addWallet({accessToken:s,entropyId:a,entropyIdVerifier:l,chainType:"ethereum",hdWalletIndex:r})}return Pe(r,"ethereum")},Se=async({user:e,wp:t,accessToken:r,walletIndex:n,ethereumWallet:a})=>{let o=xn(e).find((e=>e.walletIndex===n));if(o)return o;if(0===n)a&&await Re.recoverPrimaryWallet(),await t.createSolana({accessToken:r,ethereumAddress:a?.address});else{if(!En(e))throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error("User must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let{entropyId:a,entropyIdVerifier:o}=Sn(e);await Re.recoverPrimaryWallet(),await t.addWallet({accessToken:r,entropyId:a,entropyIdVerifier:o,chainType:"solana",hdWalletIndex:n})}return Pe(n,"solana")},Pe=async(e,t)=>{let r=await Re.refreshSessionAndUser(),n=("ethereum"===t?vn(r):xn(r)).find((t=>t.walletIndex===e));if(!n)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");return ao(ie,"createWallet","onSuccess",{wallet:n}),n},_e=({transaction:e,uiOptions:t,fundWalletConfig:r,address:n,signOnly:s})=>new Promise((async(l,c)=>{let{requesterAppId:d}=t||{},u=s?"signTransaction":"sendTransaction";if(!h||!y)return ao(ie,u,"onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),void c(Error("User must be authenticated before signing with a Privy wallet"));let p=n?kn(y,n):wn(y);if(!p)return ao(ie,u,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void c(new i.PrivyClientError("User must have an embedded wallet to send a transaction."));let m=p.address,f=p.walletIndex??0,{entropyId:g,entropyIdVerifier:w}=Sn(y,p),v=Le.wallets.find((e=>"privy"===e.walletClientType&&a.getAddress(e.address)===a.getAddress(m)));if(!v)return ao(ie,u,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have a Privy wallet before signing"));let x=await v.getEthereumProvider(),C=await x.request({method:"eth_chainId"}),b=e.chainId?Number(e.chainId):hm(C);(e=>{if(!$.chains.map((e=>e.id)).includes(e))throw new i.PrivyConnectorError(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,i.PrivyErrorCode.UNSUPPORTED_CHAIN_ID)})(b);let j={...e,from:e.from??m,chainId:b},k=await bv();if(!k||!B)return ao(ie,u,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have valid access token and Privy wallet to send transaction"));let E=Ut(j.chainId,$.chains,$.rpcConfig,{appId:o.appId});if(ue({showWalletUIs:t?.showWalletUIs}))(async()=>{try{if(!await Re.recoverPrimaryWallet())return ao(ie,u,"onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),void c(Error("Unable to connect to wallet"));let e=await Mh(j,E,j.from),t=s?await um({accessToken:k,entropyId:g,entropyIdVerifier:w,transactingWalletIndex:f,walletProxy:B,transactionRequest:j,requesterAppId:d}):await dm({accessToken:k,entropyId:g,entropyIdVerifier:w,transactingWalletIndex:f,walletProxy:B,transactionRequest:e,publicClient:E,requesterAppId:d});s?ao(ie,"signTransaction","onSuccess",{signature:t}):ao(ie,"sendTransaction","onSuccess",{hash:t}),l({hash:t})}catch(e){ao(ie,u,"onError",i.PrivyErrorCode.TRANSACTION_FAILURE),c(e)}})();else{let e={connectingWalletAddress:m,recoveryMethod:p.recoveryMethod,entropyId:g,entropyIdVerifier:w,onCompleteNavigateTo:vw,onFailure:e=>{ao(ie,u,"onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),c(e)}},n=qm($)?Wf({address:m,appConfig:$,fundWalletConfig:r,methodScreen:If,chainIdOverride:j.chainId,comingFromSendTransactionScreen:!0}):void 0;H({connectWallet:e,sendTransaction:{transactionRequest:j,transactingWalletIndex:f,transactingWalletAddress:m,entropyId:g,entropyIdVerifier:w,signOnly:s,onConfirm:s?async()=>await um({accessToken:k,entropyId:g,entropyIdVerifier:w,transactingWalletIndex:f,walletProxy:B,transactionRequest:j,requesterAppId:d}):void 0,onSuccess:e=>{s?ao(ie,"signTransaction","onSuccess",{signature:e.hash}):ao(ie,"sendTransaction","onSuccess",{hash:e.hash}),l(e)},onFailure:e=>{ao(ie,u,"onError",i.PrivyErrorCode.TRANSACTION_FAILURE),c(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:d},funding:n}),pe($f)}}));function Ne(){return new Promise((async(e,t)=>{let r=await bv();if(!r||!B)throw Error("Must have valid access token to enroll in MFA");try{await B.verifyMfa({accessToken:r}),e()}catch(e){t(e)}}))}let Me=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],We=e=>{let t=y?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:r,loginMethod:n}=Qo(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw ao(ie,"linkAccount","onError",i.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:n}),new i.PrivyClientError(`User already has an account of type ${r} linked.`)};async function Oe({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){k(null);let r=t?"setWalletPassword":"setWalletRecovery";if(!h||!y)throw ao(ie,r,"onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let n=En(y);if(!n||!B)throw ao(ie,r,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");try{await Ne()}catch(e){throw ao(ie,r,"onError",i.PrivyErrorCode.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,o)=>{let s={onSuccess:e=>{ao(ie,r,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{ao(ie,r,"onError",i.PrivyErrorCode.USER_EXITED_SET_PASSWORD_FLOW),o(e)},callAuthOnSuccessOnClose:!1},l="user-passcode"===n.recoveryMethod,c=dc({walletAction:"update",availableRecoveryMethods:$.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:l,showAutomaticRecovery:e}),{entropyId:d,entropyIdVerifier:u}=Sn(y),p={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,onCompleteNavigateTo:c,shouldForceMFA:!1,entropyId:d,entropyIdVerifier:u,onFailure:e=>{ao(ie,r,"onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),o(e)}};H({setWalletPassword:s,recoverWallet:{entropyId:d,entropyIdVerifier:u,onFailure:o},createWallet:s,connectWallet:p,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:l}}),pe($f)}))}async function Ue({appId:e,action:t}){let r=await bv();if("link"===t&&!r)throw ao(ie,"linkAccount","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new i.PrivyClientError("User must be authenticated before linking an account.");if("login"===t&&r)throw ao(ie,"login","onError",i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),new i.PrivyClientError("Attempted to log in, but user is already logged in. Use a `link` helper instead.");le.current=`privy:${e}`,ce.current=t;let n=wm();return s.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(r,a)=>{let{name:i,logoUrl:o}=await gm({api:s.api,providerAppId:e,requesterAppId:$.id});H({crossAppAuth:{appId:e,name:i,logoUrl:o,action:t,popup:n,onSuccess:r,onError:a}}),pe(Tw)}))}let Fe={ready:u,authenticated:h,user:y,walletConnectors:s.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),H({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),pe(h?kw:Gu)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),Ce("siwe"),le.current="siwe",ce.current="link",H({...q,externalConnectWallet:{...q.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),pe(Bw)},startCrossAppAuthFlow:Ue,linkEmail:()=>{Ce("email"),We("email"),le.current="email",ce.current="link",pe(Lw)},linkPhone:()=>{Ce("sms"),We("phone"),le.current="sms",ce.current="link",pe(Dw)},linkGoogle:async()=>{Ce("google"),We("google_oauth"),ce.current="link",await Re.initLoginWithOAuth("google")},linkTwitter:async()=>{Ce("twitter"),We("twitter_oauth"),ce.current="link",await Re.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Ce("discord"),We("discord_oauth"),ce.current="link",await Re.initLoginWithOAuth("discord")},linkGithub:async()=>{Ce("github"),We("github_oauth"),ce.current="link",await Re.initLoginWithOAuth("github")},linkSpotify:async()=>{Ce("spotify"),We("spotify_oauth"),ce.current="link",await Re.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Ce("instagram"),We("instagram_oauth"),ce.current="link",await Re.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Ce("tiktok"),We("tiktok_oauth"),ce.current="link",await Re.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Ce("linkedin"),We("linkedin_oauth"),ce.current="link",await Re.initLoginWithOAuth("linkedin")},linkApple:async()=>{Ce("apple"),We("apple_oauth"),ce.current="link",await Re.initLoginWithOAuth("apple")},linkPasskey:async()=>{Ce("passkey"),We("passkey"),await Re.initLinkWithPasskey(),pe(My)},linkTelegram:async e=>{if(Ce("telegram"),We("telegram"),ce.current="link",le.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new dn;s.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=pn(e.launchParams.initDataRaw),H({telegramAuthModalData:{seamlessAuth:!0}}),pe(Ud)}else ao(ie,"linkAccount","onError",i.PrivyErrorCode.INVALID_DATA,{linkMethod:"telegram"});else await Re.initLoginWithTelegram();pe(Ud)},linkFarcaster:async()=>{Ce("farcaster"),We("farcaster"),await Re.initLoginWithFarcaster(),ce.current="link",le.current="farcaster",pe(hd)},updateEmail:()=>{if(Ce("email"),!y?.email)throw new i.PrivyClientError("User does not have an email linked to their account.");ce.current="update",le.current="email",pe(hv)},updatePhone:()=>{if(Ce("sms"),!y?.phone)throw new i.PrivyClientError("User does not have a phone number linked to their account.");ce.current="update",le.current="sms",pe(mv)},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!u){let e=await new Promise((e=>{Z((t=>e.bind(t)))}));if(Z(null),e)return void console.warn(t)}!y||y.isGuest?(ce.current="login",H({login:e}),pe(xu)):console.warn(t)},connectOrCreateWallet:async()=>{u||(await new Promise((e=>{Z((()=>e))})),Z(null)),h?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(ce.current="connect-or-create",pe(Zd))},logout:async()=>{if(ce.current=null,le.current=null,y&&s.clearProviderAcccessTokens(y),k(null),await s.logout(),y&&B)try{await B.clearMfa({userId:y.id})}catch(e){}f(null),m(!1),ao(ie,"logout","onSuccess"),d(!1),Nt.del(gr),Nt.del(wr($.id))},getAccessToken:r.useCallback((()=>s.getCustomerAccessToken()),[s]),unlinkWallet:async e=>{let t;return f(t=e.startsWith("0x")?await s.unlinkEthereumWallet(e):await s.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await s.unlinkEmail(e);return f(t),t},unlinkPhone:async e=>{let t=await s.unlinkPhone(e);return f(t),t},unlinkGoogle:async e=>{let t=await s.unlinkOAuth("google",e);return f(t),t},unlinkTwitter:async e=>{let t=await s.unlinkOAuth("twitter",e);return f(t),t},unlinkDiscord:async e=>{let t=await s.unlinkOAuth("discord",e);return f(t),t},unlinkGithub:async e=>{let t=await s.unlinkOAuth("github",e);return f(t),t},unlinkSpotify:async e=>{let t=await s.unlinkOAuth("spotify",e);return f(t),t},unlinkInstagram:async e=>{let t=await s.unlinkOAuth("instagram",e);return f(t),t},unlinkTiktok:async e=>{let t=await s.unlinkOAuth("tiktok",e);return f(t),t},unlinkLinkedIn:async e=>{let t=await s.unlinkOAuth("linkedin",e);return f(t),t},unlinkApple:async e=>{let t=await s.unlinkOAuth("apple",e);return f(t),t},unlinkFarcaster:async e=>{let t=await s.unlinkFarcaster(e);return f(t),t},unlinkTelegram:async e=>{let t=await s.unlinkTelegram(e);return f(t),t},unlinkPasskey:async e=>{let t=await bv();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!B)throw Error("Wallet proxy not initialized.");let r=$.passkeys.shouldUnenrollMfaOnUnlink;await B.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:r});let n=await s.getAuthenticatedUser();return f(n),n},unlinkCrossAppAccount:async({subject:e})=>{let t=y?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new i.PrivyClientError("Invalid subject");s.storeProviderAccessToken(t.id,null);let r=await s.unlinkOAuth(`privy:${t.id}`,e);return f(r),r},createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let t=await Re.refreshSessionAndUser();if(!t)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return Ee(t,15e3,e)},setWalletRecovery:async e=>Oe({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>Oe({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(r,n)=>{let{requesterAppId:a}=t?.uiOptions||{},o=e.message;if(!h||!y)return ao(ie,"signMessage","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),void n(Error("User must be authenticated before signing with a Privy wallet"));let l=t?.address?kn(y,t.address):wn(y);if(!l)throw new i.PrivyClientError("User must have an embedded wallet to send a transaction.");let c=l.address,d=l.walletIndex??0,{entropyId:u,entropyIdVerifier:p}=Sn(y,l);if("string"!=typeof o||o.length<1)return ao(ie,"signMessage","onError",i.PrivyErrorCode.INVALID_MESSAGE),void n(Error("Message must be a non-empty string"));let m=async()=>{if(!h)throw Error("User must be authenticated before signing with a Privy wallet");let e=await bv();if(!B||!e||!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");s.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:c,requesterAppId:a}});let{response:t}=await B.rpc({accessToken:e,entropyId:u,entropyIdVerifier:p,chainType:"ethereum",hdWalletIndex:d,requesterAppId:a,request:{method:"personal_sign",params:[o,c]}}),r=t.data;return s.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:c,requesterAppId:a}}),r};if(ue({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await m();ao(ie,"signMessage","onSuccess",{signature:e}),r({signature:e})}catch(e){ao(ie,"signMessage","onError",i.PrivyErrorCode.UNABLE_TO_SIGN),n(e??new Xn("Unable to sign message"))}else H({signMessage:{method:"personal_sign",data:o,confirmAndSign:m,onSuccess:e=>{ao(ie,"signMessage","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{ao(ie,"signMessage","onError",i.PrivyErrorCode.UNABLE_TO_SIGN),n(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:c,entropyId:u,entropyIdVerifier:p,onCompleteNavigateTo:$g,onFailure:e=>{ao(ie,"signMessage","onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),n(e)}}}),pe($f)})),signTypedData:(e,t)=>new Promise((async(r,n)=>{let{requesterAppId:a}=t?.uiOptions||{};if(!h||!y)return ao(ie,"signTypedData","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),void n(Error("User must be authenticated before signing with a Privy wallet"));let o=t?.address?kn(y,t.address):wn(y);if(!o)throw new i.PrivyClientError("User must have an embedded wallet to send a transaction.");let l=o.address,c=o.walletIndex??0,{entropyId:d,entropyIdVerifier:u}=Sn(y,o),p=Gt(e),m=async()=>{if(!h)throw Error("User must be authenticated before signing with a Privy wallet");let e=await bv();if(!B||!e||!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");s.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:l,requesterAppId:a}});let{response:t}=await B.rpc({accessToken:e,entropyId:d,entropyIdVerifier:u,chainType:"ethereum",hdWalletIndex:c,requesterAppId:a,request:{method:"eth_signTypedData_v4",params:[l,p]}}),r=t.data;return s.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:l,requesterAppId:a}}),r};if(ue({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await m();ao(ie,"signTypedData","onSuccess",{signature:e}),r({signature:e})}catch(e){ao(ie,"signTypedData","onError",i.PrivyErrorCode.UNABLE_TO_SIGN),n(e??new Xn("Unable to sign message"))}else H({signMessage:{method:"eth_signTypedData_v4",data:p,confirmAndSign:m,onSuccess:e=>{ao(ie,"signTypedData","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{ao(ie,"signTypedData","onError",i.PrivyErrorCode.UNABLE_TO_SIGN),n(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:$g,onFailure:e=>{ao(ie,"signMessage","onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),n(e)}}}),pe($f)})),sendTransaction:async(e,t)=>await _e({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await _e({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!h||!y)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let n=e?.address?kn(y,e.address):wn(y),l=En(y);if(!n||!l)return void r(new i.PrivyClientError("User must have an embedded wallet to send a transaction."));let c=n.address,{entropyId:d,entropyIdVerifier:u}=Sn(y,n);if(!c)return void r(Error("User does not have an HD Ethereum wallet. To export an imported wallet, pass the `address` of the wallet to `exportWallet`."));if(!a.isAddress(c))return void r(Error("Must provide a valid Ethereum address."));let p={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:Lf,onFailure:r,shouldForceMFA:!0};H(q),await bv()&&B?B?(H({keyExport:{appId:o.appId,appClientId:o.clientId,origin:s.apiUrl,walletToExport:n,primaryWallet:l,onSuccess:t,onFailure:r},connectWallet:p}),pe($f)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:Ne,async init(e){switch(e){case"sms":return void await s.initMfaSmsVerification();case"passkey":return await s.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new i.PrivyClientError("Invalid MFA code");ne.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{ae.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new i.PrivyClientError("Invalid authenticator response");let r=await import("@simplewebauthn/browser"),n=(e=>({id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}))(await r.startAuthentication(t));ne.current?.resolve({mfaMethod:e,mfaCode:n,relyingParty:window.origin}),await new Promise(((e,t)=>{ae.current={resolve:e,reject:t}}));break;default:throw ne.current?.reject(new i.PrivyClientError("Unsupported MFA method")),new i.PrivyClientError(`Unsupported MFA method: ${e}`)}},cancel(){ne.current?.reject(new i.PrivyClientError("MFA canceled"))},async initEnrollmentWithSms(e){let t=await bv();if(!t||!B)throw Error("Must have valid access token to enroll in MFA");await B.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,r)=>{if(!e)return Re.closePrivyModal(),void t();$.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),H({mfaEnrollmentFlow:{mfaMethods:$.mfa.methods,shouldUnlinkOnUnenrollMfa:$.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:r}}),pe(sv)})),async initEnrollmentWithTotp(){let e=await bv();if(!e||!B)throw Error("Must have valid access token to enroll in MFA");let t=await B.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await bv();if(!t||!B)throw Error("Must have valid access token to enroll in MFA");await B.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),f(await s.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await bv();if(!t||!B)throw Error("Must have valid access token to enroll in MFA");await B.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),f(await s.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let r=await bv();if(!r||!B)throw Error("Must have valid access token to enroll in MFA");await B.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:e,removeForLogin:t.removeForLogin}),f(await s.getAuthenticatedUser())},async unenroll(e,t={}){let r=await bv();if(!r||!B)throw Error("Must have valid access token to remove MFA");"passkey"===e?await B.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:[],removeForLogin:t.removeForLogin}):await B.unenrollMfa({method:e,accessToken:r}),f(await s.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await bv(),t=y?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!B||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(!y?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");let r=await B.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===r.status&&f(await s.getAuthenticatedUser()||y||null),H({farcasterSigner:r}),pe(Ww)},getFarcasterSignerPublicKey:async()=>{let e,t=await bv(),r=y?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!B||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(!y?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!y.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=y.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await bv(),r=y?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!B||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(!y?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!y.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let n=await import("@simplewebauthn/browser"),a=await B.signFarcasterMessage({address:r.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:n.bufferToBase64URLString(e)},fid:BigInt(y.farcaster.fid),relyingParty:window.origin});return new Uint8Array(n.base64URLStringToBuffer(a.signature))},signMessageWithCrossAppWallet(e,{address:t,chainId:r}){let n=y?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return xm({user:y,client:s,address:t,requesterAppId:$.id,request:{method:n?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:r},reconnect:Ue})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:r}){let n=y?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),a=Gt(e);return xm({user:y,client:s,address:t,requesterAppId:$.id,request:{method:n?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,a],chainId:r},reconnect:Ue})},sendTransactionWithCrossAppWallet(e,{address:t}){let r=y?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return xm({user:y,client:s,address:t,requesterAppId:$.id,request:{method:r?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:Ue})},isModalOpen:c,mfaMethods:$.mfa.methods};fv=Fe.signMessage,gv=Fe.signTypedData,vv=async(e,t)=>await _e({transaction:e,...t,signOnly:!1}),wv=async(e,t)=>({signature:(await _e({transaction:e,...t,signOnly:!0})).hash});let Re={setAuthenticated:m,setUser:f,setIsNewUser:b,isNewUserThisSession:C,pendingTransaction:null,walletConnectionStatus:A,connectors:s.connectors?.walletConnectors??[],solanaWallets:v,rpcConfig:$.rpcConfig,chains:$.chains,appId:o.appId,showFiatPrices:"native-token"!==$.embeddedWallets.priceDisplay.primary,clientAnalyticsId:s.clientAnalyticsId,customAuthStatus:te,hideWalletUIs:de,isHeadlessSigning:r.useCallback(ue,[$.embeddedWallets.showWalletUIs]),emailOtpState:_,setEmailOtpState:N,smsOtpState:M,setSmsOtpState:W,oAuthState:F,setOAuthState:R,telegramAuthState:L,setTelegramAuthState:D,siweState:O,setSiweState:U,isHeadlessOAuthLoading:E,nativeTokenSymbolForChainId:e=>$.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(B)return B;let t=new Promise((e=>{Y((()=>t=>e(t)))})),r=new Promise((t=>setTimeout((()=>t(null)),e))),n=await Promise.race([t,r]);return Y(null),n},getAuthFlow:()=>s.authFlow,getAuthMeta:()=>s.authFlow?.meta,client:s,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=u&&h&&y;r&&le.current&&(t=Me(y)),"login"===ce.current?e.shouldCallAuthOnSuccess&&r&&le.current?ao(ie,"login","onComplete",{user:y,isNewUser:C,wasAlreadyAuthenticated:!1,loginMethod:le.current,loginAccount:t??null}):ao(ie,"login","onError",i.PrivyErrorCode.USER_EXITED_AUTH_FLOW):"link"===ce.current&&t?e.isSuccess&&r&&le.current?ao(ie,"linkAccount","onSuccess",{user:y,linkMethod:le.current,linkedAccount:t}):le.current&&ao(ie,"linkAccount","onError",i.PrivyErrorCode.USER_EXITED_LINK_FLOW,{linkMethod:le.current}):"update"===ce.current&&t?e.isSuccess&&r&&le.current?ao(ie,"update","onSuccess",{user:y,updateMethod:le.current,updatedAccount:t}):le.current&&ao(ie,"update","onError",i.PrivyErrorCode.USER_EXITED_UPDATE_FLOW,{linkMethod:le.current}):"connect-or-create"===ce.current&&(g[0]?ao(ie,"connectOrCreateWallet","onSuccess",{wallet:g[0]}):ao(ie,"connectOrCreateWallet","onError",i.PrivyErrorCode.USER_EXITED_AUTH_FLOW));let n=j&&bw.has(j),a=j===Es&&q.errorModalData&&bw.has(q.errorModalData.previousScreen);if((n||a)&&q.funding){let e,t=bw.get(j)??null;if("solana"===q.funding.chainType){let r=l(Fm);if(r)try{e=BigInt(await r.getBalance({address:q.funding.address,cluster:q.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");ao(ie,"fundSolanaWallet","onUserExited",{address:q.funding.address,cluster:q.funding.cluster,fundingMethod:t,balance:e})}else{let r=Ut(q.funding.chain.id,$.chains,$.rpcConfig,{appId:o.appId});try{e=await r.getBalance({address:q.funding.address})}catch{console.error("Unable to pull wallet balance")}ao(ie,"fundWallet","onUserExited",{address:q.funding.address,chain:q.funding.chain,fundingMethod:t,balance:e})}}H({...q,externalConnectWallet:{suggestedAddress:void 0}}),ce.current=null,le.current=null,b(!1),d(!1),setTimeout((()=>{s.authFlow=void 0}),200)},openPrivyModal:pe,connectWallet:ge,initLoginWithWallet:async(e,t,r)=>{ea(e)?(le.current="siwe",we(e,t,r)):(le.current="siws",ve(e,t,r))},loginWithWallet:async()=>{let e,t,r;if(!u)throw new i.PrivyNotReadyError;if(s.authFlow instanceof tn?e="siwe":s.authFlow instanceof rn&&(e="siws"),!e)throw new i.PrivyClientError("Must initialize SIWE/SIWS flow first.");if(null!==await s.getAccessToken())try{({user:t}=await s.link()),le.current=e}catch(t){throw ao(ie,"linkAccount","onError",t.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:r}=await s.authenticate()),le.current=e}catch(e){throw ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR),e}f(t||y||null),b(r||!1),m(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:r})=>new Promise((async(n,a)=>{let o=await bv();if(!h||!y||!o)throw new i.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new i.PrivyClientError("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let s=Re.walletProxy??await Re.initializeWalletProxy(15e3);if(!s)throw new i.PrivyClientError("Wallet proxy not initialized.");if((({address:e,chainType:t,user:r})=>!!cm(r).find((r=>r.address===e&&r.chainType===t)))({address:e,chainType:t,user:y}))return n();let l=(({address:e,user:t})=>{let r=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!r)throw new i.PrivyClientError("Address to delegate is not associated with current user.");return{address:r.address,chainType:r.chainType,walletIndex:r.walletIndex??0}})({address:e,user:y}),c=(({address:e,user:t})=>{let r=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!r)throw new i.PrivyClientError("Address to delegate is not associated with current user.");let n=r.imported?r:En(t);if(!n)throw new i.PrivyClientError("Unable to determine root address for delegated address.");return{address:n.address,chainType:n.chainType,imported:n.imported}})({address:e,user:y}),d=async()=>{await s.createDelegatedAction({accessToken:o,rootWallet:c,delegatedWallets:[l]}),await Re.refreshSessionAndUser()};if(await Re.recoverPrimaryWallet(),r)H({delegatedActions:{consent:{address:e,onDelegate:d,onSuccess:async()=>{n()},onError:async e=>{a(e)}}}}),pe(Iw);else try{await d(),n()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,r)=>{if(!h||!y)throw new i.PrivyClientError("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");if(0===cm(y).length)throw new i.PrivyClientError("User has no delegated wallets to revoke.");let n=async()=>{await s.revokeDelegatedWallet(),await Re.refreshSessionAndUser()};if(e)H({delegatedActions:{revoke:{onRevoke:n,onSuccess:async()=>{t()},onError:async e=>{r(e)}}}}),pe(_w);else try{await n(),t()}catch(e){r(e)}})),initLoginWithFarcaster:async(e,t)=>{let r=new ar(e,t);s.startAuthFlow(r);try{le.current="farcaster",await r.initializeFarcasterConnect()}catch(e){throw"login"===ce.current?ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===ce.current&&ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!u)throw new i.PrivyNotReadyError;if(!(s.authFlow instanceof ar))throw new i.PrivyClientError("Must initialize Farcaster flow first.");if(null!==await s.getAccessToken())try{({user:e}=await s.link()),le.current="farcaster"}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await s.authenticate()),le.current="farcaster"}catch(e){throw ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}f(e||null),b(t||!1),m(!0)},async crossAppAuthFlow({appId:e,popup:t,action:r}){let n=`privy:${e}`;le.current=n;let{url:a,stateCode:o,codeVerifier:l}=await async function({api:e,appId:t}){let r=Wr(),n=Or(),a=await Ur(r);try{let{url:o}=await e.post(i.oAuthInitPath,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:n});return{url:o,stateCode:n,codeVerifier:r}}catch(e){throw i.formatApiError(e)}}({api:s.api,appId:e});if(!a)throw s.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new i.PrivyClientError("No authorization URL returned for cross-app auth.");try{let c=await async function({url:e,popup:t}){return t.location=e,new Promise(((e,r)=>{let n,a=setTimeout((()=>{r(new i.PrivyClientError("Authorization request timed out after 2 minutes.")),o()}),12e4);function o(){t?.close(),window.removeEventListener("message",l)}let s=setInterval((()=>{t?.closed&&!n&&(o(),clearInterval(s),clearTimeout(a),r(new i.PrivyClientError("User rejected request")))}),300);function l(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(a),e(t.data),o()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(a),r(new i.PrivyClientError(t.data.error)),o()),t.data.type===ym&&((n=new BroadcastChannel(mm)).onmessage=l))}window.addEventListener("message",l)}))}({url:a,popup:t,provider:n}),d=c.stateCode,u=c.authorizationCode;if(d!==o)throw s.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:n,storedStateCode:o??"",returnedStateCode:d??""}}),new i.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,i.PrivyErrorCode.OAUTH_UNEXPECTED);let p=await async function({appId:e,stateCode:t,codeVerifier:r,authorizationCode:n,action:a,client:o}){if(!n||!t)throw new i.PrivyClientError("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===n)throw new i.PrivyClientError("User denied confirmation during cross-app auth flow");try{let i=new fm({authorizationCode:n,stateCode:t,codeVerifier:r,provider:`privy:${e}`});o.startAuthFlow(i);let s="link"===a?await o.link():await o.authenticate(),l=s.oAuthTokens?.accessToken;return console.debug(),l}catch(e){let t=i.formatApiError(e);if(t.privyErrorCode)throw new i.PrivyClientError(t.message||"Invalid code during cross-app auth flow.",void 0,t.privyErrorCode);if("User denied confirmation during cross-app auth flow"===t.message)throw new i.PrivyClientError("Invalid code during cross-app auth flow.",void 0,i.PrivyErrorCode.OAUTH_USER_DENIED);throw new i.PrivyClientError("Invalid code during cross-app auth flow.",void 0,i.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:l,stateCode:d,authorizationCode:u,action:r,client:s});p&&s.storeProviderAccessToken(e,p);let h=await Re.refreshSessionAndUser();if(!h)throw new i.PrivyClientError("Unable to update user");return s.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),h}catch(e){throw s.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:n}}),e}},async initLoginWithOAuth(e,t,r){if(le.current=e,!_t())return void pe(Fw);if("google"===e&&Qi(window.navigator.userAgent))return void pe(Fw);"twitter"===e&&window.opener&&window.opener.postMessage({type:ym},"*"),Nt.del(br),Nt.del(jr);let a=new Fr({provider:e,disableSignup:!!r,withPrivyUi:!0});t&&a.addCaptchaToken(t),s.startAuthFlow(a);let i=await s.authFlow.getAuthorizationUrl();i&&i.url&&("twitter"===e&&n.isAndroid&&(i.url=i.url.replace("x.com","twitter.com")),window.location.assign(i.url))},async initLoginWithTelegram(e,t){if(!u)throw new i.PrivyNotReadyError;le.current="telegram";let r=new dn(e,t);s.startAuthFlow(r),D({status:"loading"}),r.meta.telegramWebAppData=void 0,r.meta.telegramAuthResult=await new Promise(((e,t)=>$.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:$.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(r=>r?e(r):t(new i.PrivyClientError("Telegram auth failed or was canceled by the client")))):t(new i.PrivyClientError("Telegram was not initialized")):t(new i.PrivyClientError("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,r;if(!(s.authFlow instanceof dn))throw new i.PrivyClientError("Must initialize Telegram flow before calling loginWithTelegram");s.authFlow.meta.captchaToken||=e?.captchaToken;let n=await bv(),a=e?.intent||ce.current;if("login"===a)try{let e=await s.authenticate();t=e.user,r=e.isNewUser,le.current="telegram"}catch(e){throw ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}else{if("link"!==a)throw new i.PrivyClientError("Unknown auth intent");try{t=(await s.link()).user,le.current="telegram"}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}f(t),b(r||!1),m(!0),D({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:o}},async recoveryOAuthFlow(e,t,r){let n,a;function o(t){if(!t)throw s.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:e}}),new i.PrivyClientError("Recovery OAuth failed")}switch(e){case"google-drive":{let t,l,{url:c,codeVerifier:d,stateCode:u}=await pc({api:yv.api,provider:e});o(c);try{let n=await jw({url:c,popup:r,provider:e});if(t=n.stateCode,l=n.authorizationCode,t!==u)throw s.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:u??"",returnedStateCode:t??""}}),new i.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,i.PrivyErrorCode.OAUTH_UNEXPECTED)}catch(t){throw s.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:e}}),new i.PrivyClientError("Recovery OAuth failed")}[n,a]=await Promise.all([bv(),hc({api:yv.api,provider:e,codeVerifier:d,stateCode:t,authorizationCode:l})]);break}case"icloud":{let{url:t}=await pc({api:yv.api,provider:e});o(t);let{ckWebAuthToken:i}=await jw({url:t,popup:r,provider:e});a=i,n=await bv()}}if(!B)throw new i.PrivyClientError("Cannot connect to wallet proxy");if(!n)throw new i.PrivyClientError("Unable to authorize user");switch(t){case"recover":{let t=q.recoverWallet?.entropyId,r=q.recoverWallet?.entropyIdVerifier;if(!t||!r)throw new i.PrivyClientError("Recovery OAuth failed");s.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t,recoveryMethod:e}}),await B.recover({accessToken:n,entropyId:t,entropyIdVerifier:r,recoveryAccessToken:a}),s.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t,recoveryMethod:e}});break}case"create-wallet":{s.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await B.create({accessToken:n,recoveryAccessToken:a,recoveryMethod:e});let t=wn(await Re.refreshSessionAndUser());if(!t)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");s.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.address}}),ao(ie,"createWallet","onSuccess",{wallet:t});break}case"set-recovery":{let t=En(y);if(!t)throw ao(ie,"setWalletRecovery","onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");s.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}});let{entropyId:r,entropyIdVerifier:o}=Sn(y);await B.setRecovery({accessToken:n,entropyId:r,entropyIdVerifier:o,recoveryMethod:e,recoveryAccessToken:a});let l=En(await Re.refreshSessionAndUser());if(!l)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");s.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}}),ao(ie,"setWalletRecovery","onSuccess",{method:e,wallet:l});break}default:throw new i.PrivyClientError("Unsupported recovery action")}},async loginWithOAuth(e){let t,r,n;if(!(s.authFlow instanceof Fr))throw new i.PrivyClientError("Must initialize OAuth flow before calling loginWithOAuth");let a=Nt.get(xr),o=s.authFlow.meta.stateCode;if(a!==o)throw s.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:a??"",returnedStateCode:o??""}}),new i.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,i.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await s.getAccessToken())try{let r=await s.link();t=r.user,n=r.oAuthTokens,le.current=e}catch(t){throw ao(ie,"linkAccount","onError",t.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let a=await s.authenticate();t=a.user,r=a.isNewUser,n=a.oAuthTokens,le.current=e}catch(t){throw"login"===ce.current?ao(ie,"login","onError",t.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===ce.current&&ao(ie,"linkAccount","onError",t.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return f(t),b(r||!1),m(!0),n&&t&&ao(ie,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),n},passkeyAuthState:S,setPasskeyAuthState:P,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new Qr({captchaToken:e,setPasskeyAuthState:P});s.startAuthFlow(r),ce.current="login";try{le.current="passkey",P({status:"generating-challenge"}),await r.initRegisterFlow(t),P({status:"awaiting-passkey"})}catch(e){throw P({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!u)throw new i.PrivyNotReadyError;if(!(s.authFlow instanceof Qr))throw new i.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==le.current){let e=new i.PrivyClientError("Must init login with Passkey flow first.");throw P({status:"error",error:e}),e}let r=await bv();try{le.current="passkey",P({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await s.authenticate())}catch(e){throw P({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}f(e),b(t||!1),m(!0),P({status:"done"});let n=e?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:e,isNewUser:t||!1,wasAlreadyAuthenticated:!!r,loginAccount:n}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new Qr({captchaToken:e,setPasskeyAuthState:P});s.startAuthFlow(r),ce.current="login";try{le.current="passkey",P({status:"generating-challenge"}),await r.initAuthenticationFlow(t),P({status:"awaiting-passkey"})}catch(e){throw P({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,r;if(!u)throw new i.PrivyNotReadyError;if(!(s.authFlow instanceof Qr))throw new i.PrivyClientError("Must initialize Passkey flow first.");if(e?.credentialIds&&(s.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==le.current){let e=new i.PrivyClientError("Must init login with Passkey flow first.");throw P({status:"error",error:e}),e}let n=await bv();try{le.current="passkey",P({status:"awaiting-passkey"}),({user:t,isNewUser:r}=await s.authenticate())}catch(e){throw P({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}f(t),b(r||!1),m(!0),P({status:"done"});let a=t?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:a}},async initLinkWithPasskey(e){let t=new Qr({captchaToken:e});s.startAuthFlow(t),ce.current="link",le.current="passkey",P({status:"generating-challenge"});try{await t.initLinkFlow(),P({status:"awaiting-passkey"})}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),P({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!u)throw new i.PrivyNotReadyError;if(!(s.authFlow instanceof Qr))throw new i.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==le.current)throw new i.PrivyClientError("Must init login with Passkey flow first.");try{le.current="passkey",({user:e}=await s.link())}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return f(e||y||null),P({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,r){if(!_t())throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");if("google"===e&&Qi(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let n=new Fr({provider:e,withPrivyUi:!1,disableSignup:r??!1});t&&n.addCaptchaToken(t),R({status:"loading"});let a=await s.startAuthFlow(n).getAuthorizationUrl();a?.url&&window.location.assign(a.url)},async loginWithHeadlessOAuth(e){let t,r,n;T(!0),R({status:"loading"}),s.startAuthFlow(new Fr(e));let a=Nt.get(xr),o=e.stateCode;if(a!==o)throw s.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:a??"",returnedStateCode:o??""}}),T(!1),new i.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,i.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await s.getAccessToken())try{({user:t,oAuthTokens:n}=await s.link()),le.current=e.provider;let r=Me(t);t&&r&&ao(ie,"linkAccount","onSuccess",{user:t,linkMethod:le.current,linkedAccount:r})}catch(t){throw T(!1),ao(ie,"linkAccount","onError",t.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:r,oAuthTokens:n}=await s.authenticate()),le.current=e.provider;let a=Me(t);t&&a&&void 0!==r&&ao(ie,"login","onComplete",{user:t,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:le.current,loginAccount:a})}catch(e){throw T(!1),R({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}return f(t),b(r||!1),m(!0),T(!1),R({status:"done"}),n&&t&&ao(ie,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{let a=new It({email:e,captchaToken:t,disableSignup:r});s.startAuthFlow(a);try{le.current="email",N({status:"sending-code"}),await a.sendCodeEmail({withPrivyUi:n}),N({status:"awaiting-code-input"})}catch(e){throw N({status:"error",error:e}),"login"===ce.current?ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===ce.current&&ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,r)=>{let n=new St(e,t,r);s.startAuthFlow(n);try{await n.sendCodeEmail({withPrivyUi:!0})}catch(e){ao(ie,"update","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:le.current})}},initUpdatePhone:async(e,t,r)=>{let n=new an(e,t,r);s.startAuthFlow(n);try{await n.sendSmsCode({withPrivyUi:!0})}catch(e){ao(ie,"update","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:le.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{W({status:"sending-code"});let a=new nn({phoneNumber:e,captchaToken:t,disableSignup:r});s.startAuthFlow(a);try{le.current="sms",await a.sendSmsCode({withPrivyUi:n}),W({status:"awaiting-code-input"})}catch(e){throw W({status:"error",error:e}),"login"===ce.current?ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===ce.current&&ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await(s.authFlow?.sendCodeEmail({withPrivyUi:!0}))},resendSmsCode:async()=>{await(s.authFlow?.sendSmsCode({withPrivyUi:!0}))},loginWithCode:async e=>{let t,r;function n(e){s.authFlow instanceof It?N(e):s.authFlow instanceof nn&&W(e)}if(n({status:"submitting-code"}),!u){let e=new i.PrivyNotReadyError;throw n({status:"error",error:e}),e}if(s.authFlow instanceof It)s.authFlow.meta.emailCode=e.trim();else{if(!(s.authFlow instanceof nn)){let e=new i.PrivyClientError("Must initialize a passwordless code flow first");throw n({status:"error",error:e}),e}s.authFlow.meta.smsCode=e.trim()}let a=await bv();if("link"===ce.current)try{({user:t}=await s.link())}catch(e){throw n({status:"error",error:e}),ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:le.current}),e}else if("update"===ce.current)try{({user:t}=await s.link())}catch(e){throw n({status:"error",error:e}),ao(ie,"update","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:le.current}),e}else try{({user:t,isNewUser:r}=await s.authenticate())}catch(e){throw n({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}let o=t||y;f(o||null),b(r||!1),m(!0),n({status:"done"});let l=null;return s.authFlow instanceof It?l=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:s.authFlow instanceof nn&&(l=o?.linkedAccounts.find((({type:e})=>"phone"===e))||null),{user:o,isNewUser:r||!1,wasAlreadyAuthenticated:!!a,linkedAccount:l}},generateSiweMessage:async({address:e,chainId:t,captchaToken:r})=>{ce.current="link",le.current="siwe",U({status:"generating-message"});let n=await s.generateSiweNonce({address:e,captchaToken:r});return U({status:"awaiting-signature"}),en({address:e,chainId:t.replace("eip155:",""),nonce:n})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let r=await s.generateSiweNonce({address:e});return en({address:e,chainId:t.replace("eip155:",""),nonce:r})},linkSmartWallet:async({message:e,signature:t,smartWalletType:r})=>{let n;n=await s.linkSmartWallet({message:e,signature:t,smartWalletType:r}),f((n=await Re.refreshSessionAndUser()??n)||y||null)},linkWithSiwe:async({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a})=>{let o;Ce("siwe");let l=null;try{U({status:"submitting-signature"}),o=await s.linkWithSiwe({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a}),o=await Re.refreshSessionAndUser()??o,U({status:"done"}),(l=Me(o)||null)&&ao(ie,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:l})}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),ce.current=null,le.current=null,U({status:"error",error:e}),e}let c=o||y;return f(c||null),ce.current=null,le.current=null,{user:c,linkedAccount:l}},refreshSessionAndUser:async()=>{let e=await s.getAuthenticatedUser();return m(!!e),f(e),e},walletProxy:B,createAnalyticsEvent:({eventName:e,payload:t,timestamp:r})=>s.createAnalyticsEvent({eventName:e,payload:t,timestamp:r}),acceptTerms:async()=>{let e=await s.acceptTerms();return f(e),e},getUsdTokenPrice:e=>s.getUsdTokenPrice(e),getUsdPriceForSol:()=>s.getUsdPriceForSol(),getSplTokenMetadata:e=>s.getSplTokenMetadata(e),recoverPrimaryWallet:async e=>new Promise((async(t,r)=>{if(!y)return void t(!0);let n=An(e?.user??y),a=En(e?.user??y)||bn(e?.user??y)||jn(e?.user??y);if(!n&&!a)return void t(!0);let i=await bv();if(!i||!B||!a)return void r(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:o,entropyIdVerifier:l}=Sn(y,a);try{await B.connect({accessToken:i,entropyId:o,entropyIdVerifier:l}),t(!0)}catch(e){ds(e)&&"privy"===a.recoveryMethod?(s.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:a.address}}),(await B.recover({entropyId:o,entropyIdVerifier:l,accessToken:i})).entropyId||r(Error("Unable to recover wallet")),s.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:a.address}}),t(!0)):ds(e)&&"privy"!==a.recoveryMethod?(H({recoverWallet:{entropyId:o,entropyIdVerifier:l,onFailure:r,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:a.recoveryMethod,action:"recover"}}),pe(uc(a.recoveryMethod))):r(e)}})),createEmbeddedSolanaWallet:async e=>{e&&"target"in e&&(e=void 0);let t=await Re.refreshSessionAndUser();if(!t)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return Te(t,15e3,e)},exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!h||!y)return void r(Error("User must be authenticated before exporting their Privy wallet"));let n=e?.address?kn(y,e.address):Cn(y),a=En(y);if(!n||!a)return void r(Error("Must have a Privy wallet before exporting"));let{entropyId:i,entropyIdVerifier:l}=Sn(y,n);await bv()&&B?B?(H({connectWallet:{recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,entropyId:i,entropyIdVerifier:l,onCompleteNavigateTo:Lf,onFailure:r,shouldForceMFA:!0},keyExport:{appId:o.appId,appClientId:o.clientId,origin:s.apiUrl,walletToExport:n,primaryWallet:a,onSuccess:t,onFailure:r}}),pe($f)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),setReadyToTrue:e=>{p(!0),K?.(e)},updateWallets:()=>ke(),fundWallet:async(e,t)=>{H({funding:Wf({address:e,appConfig:$,fundWalletConfig:t,methodScreen:If})}),pe(If)},openModal:pe,requestFarcasterSignerStatus:async e=>{let t=await bv(),r=y?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!B||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(!y?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let n=await s.requestFarcasterSignerStatus(e);return"approved"===n.status&&f(await s.getAuthenticatedUser()||y||null),n},connectCoinbaseSmartWallet:async()=>{$.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let e=s.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||s.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),ge(e);await fe("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:l})=>{let c=await s.sendAccountTransferRequest({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:l});return f(c),c}};xv=Re.recoverPrimaryWallet,Cv=Re.recoverPrimaryWallet;let Le=r.useMemo((()=>({wallets:g,ready:J&&oe})),[g,J,oe]),De=s.authFlow instanceof dn,Be=!$.headless&&$.captchaEnabled&&!h&&(u||De);/*#__PURE__*/return e.jsx($o.Provider,{value:Fe,children:/*#__PURE__*/e.jsx(to.Provider,{value:ie,children:/*#__PURE__*/e.jsx(_h.Provider,{value:Le,children:/*#__PURE__*/e.jsx(ln,{...$,children:/*#__PURE__*/e.jsxs(i.InternalPrivyContext.Provider,{value:Re,children:[/*#__PURE__*/e.jsx(so,{children:/*#__PURE__*/e.jsxs(Xu,{data:q,setModalData:H,setInitialScreen:k,initialScreen:j,authenticated:h,open:c,children:[o.children,Be&&/*#__PURE__*/e.jsx(wp,{delayedExecution:!1}),/*#__PURE__*/e.jsx(Dh,{theme:{...$.appearance.palette||{}}}),!$.render.standalone&&/*#__PURE__*/e.jsx(Yh,{open:c})]})}),/*#__PURE__*/e.jsx(lm,{appId:o.appId,appClientId:o.clientId,clientAnalyticsId:s.clientAnalyticsId,origin:s.apiUrl,mfaMethods:y?.mfaMethods,mfaPromise:ne,mfaSubmitPromise:ae,onLoad:z,onLoadFailed:()=>null}),$.loginConfig.telegramAuthConfiguration&&
25
+ /*#__PURE__*/e.jsx(e.Fragment,{children:/*#__PURE__*/e.jsxs(Uw,{children:[/*#__PURE__*/e.jsx(Jo,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(ho,{success:m,fail:!!d}),/*#__PURE__*/e.jsx(Rc,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e.jsxs(Oo,{children:[/*#__PURE__*/e.jsx(gc,{children:d?d.message:"Add a signer to Farcaster"}),/*#__PURE__*/e.jsx(wc,{children:d?d.detail:"This will allow "+s.name+" to add casts, likes, follows, and more on your behalf."})]}),w&&/*#__PURE__*/e.jsx(vo,{onClick:e=>{e.preventDefault(),window.location.href=w},children:"Open Warpcast app"})]})}):/*#__PURE__*/e.jsx(e.Fragment,{children:/*#__PURE__*/e.jsxs(Ow,{children:[/*#__PURE__*/e.jsx(Jo,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(ho,{success:m,fail:!!d}),/*#__PURE__*/e.jsx(Rc,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e.jsxs(Oo,{children:[/*#__PURE__*/e.jsx(gc,{children:d?d.message:"Requesting signer from Farcaster"}),/*#__PURE__*/e.jsx(wc,{children:d?d.detail:"This should only take a moment"}),/*#__PURE__*/e.jsx(Po,{children:w&&n.isMobile&&/*#__PURE__*/e.jsx(Kc,{text:"Take me to Warpcast",url:w,color:Mw})})]})]})}),/*#__PURE__*/e.jsx(fi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:t?a:void 0,onClose:c},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Ow,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(gc,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e.jsxs(wc,{children:["This will allow ",s.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/e.jsx(No,{children:"pending_approval"===g?.status?/*#__PURE__*/e.jsx(nd,{url:g.signer_approval_url,size:275,squareLogoElement:Rc}):/*#__PURE__*/e.jsx(mo,{})}),/*#__PURE__*/e.jsxs(Po,{children:[/*#__PURE__*/e.jsx(wc,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===g?.status&&/*#__PURE__*/e.jsx(qc,{text:g.signer_approval_url,itemName:"link",color:Mw})]})]})}),/*#__PURE__*/e.jsx(fi,{})]})}};let Ow=/*#__PURE__*/h.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-6e8f76e5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),Uw=/*#__PURE__*/h.styled.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e8f76e5-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Fw={component:()=>{let{closePrivyModal:t}=i.usePrivyInternal();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Rw,{children:/*#__PURE__*/e.jsx(De.default,{style:{width:32,height:32}})}),/*#__PURE__*/e.jsx(Si,{title:"Could not log in with provider",description:"It looks like you're using an in-app browser. To log in, please try again using an external browser.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(vo,{onClick:()=>t(),children:"Close"})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}};let Rw=/*#__PURE__*/h.styled.div.withConfig({displayName:"StyledCircle",componentId:"sc-7bde5742-0"})(["border-radius:50%;height:68px;width:68px;display:flex;align-items:center;justify-content:center;background-color:var(--privy-color-accent);color:white;margin:0 auto 24px auto;"]);const Lw={component:()=>{let{app:t}=Qu();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Pi,{title:"Connect your email",description:`Add your email to your ${t?.name} account`,icon:/*#__PURE__*/e.jsx(Oe.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(hu,{stacked:!0})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}},Dw={component:()=>{let{app:t,currentScreen:r,data:n,navigate:a,setModalData:o}=Qu(),{initLoginWithSms:s}=i.usePrivyInternal();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Pi,{title:"Connect your phone",description:`Add your number to your ${t?.name} account`,icon:/*#__PURE__*/e.jsx(Fe.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(Id,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await s({phoneNumber:e,withPrivyUi:!0}),a(eu)}catch(e){o({errorModalData:{error:e,previousScreen:n?.errorModalData?.previousScreen||r||Dw}}),a(Es)}},hideRecent:!0})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}},Bw={component:()=>{let{app:t,data:r}=Qu(),n=r?.externalConnectWallet?.suggestedAddress,a=n?/*#__PURE__*/e.jsxs("span",{children:["Link the wallet with address ",/*#__PURE__*/e.jsx(Mi,{showCopyIcon:!1,address:n})," ",t?.name?`to ${t.name}.`:"."]}):`Link a wallet to your ${t?.name} account`,{connectors:o}=i.usePrivyInternal(),s=Zu({walletList:r?.externalConnectWallet?.walletList??t.appearance.walletList,walletChainType:r?.externalConnectWallet?.walletChainType??t.appearance.walletChainType,connectors:o,connectOnly:!1,ignore:t.appearance.walletList,walletConnectEnabled:t.externalWallets.walletConnect.enabled});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),s.length>0&&/*#__PURE__*/e.jsx(Si,{title:"Link your wallet",description:a}),/*#__PURE__*/e.jsx(Ri,{children:/*#__PURE__*/e.jsx(Ku,{wallets:s})}),/*#__PURE__*/e.jsx(yi,{})]})}},zw=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{width:"164",height:"164",viewBox:"0 0 164 164",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...t},...r,children:[/*#__PURE__*/e.jsx("circle",{cx:"82",cy:"82",r:"80",stroke:"#EC6351","stroke-width":"4","stroke-linecap":"round"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M81.9999 100.788C93.3288 100.788 102.513 91.6043 102.513 80.2754C102.513 68.9465 93.3288 59.7626 81.9999 59.7626C70.671 59.7626 61.4871 68.9465 61.4871 80.2754C61.4871 91.6043 70.671 100.788 81.9999 100.788ZM88.3236 71.8304C88.9093 71.2446 89.8591 71.2446 90.4449 71.8304C91.0307 72.4161 91.0307 73.3659 90.4449 73.9517L84.121 80.2756L90.445 86.5996C91.0308 87.1854 91.0308 88.1351 90.445 88.7209C89.8592 89.3067 88.9095 89.3067 88.3237 88.7209L81.9997 82.3969L75.6756 88.7209C75.0899 89.3067 74.1401 89.3067 73.5543 88.7209C72.9685 88.1351 72.9685 87.1854 73.5543 86.5996L79.8783 80.2756L73.5544 73.9517C72.9686 73.3659 72.9686 72.4161 73.5544 71.8304C74.1402 71.2446 75.09 71.2446 75.6758 71.8304L81.9997 78.1543L88.3236 71.8304Z",fill:"#EC6351"})]}),$w={component:()=>{let{closePrivyModal:t}=i.usePrivyInternal(),{navigate:r}=Qu();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(zw,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/e.jsx(Si,{title:"Could not connect with wallet",description:"Please check that Phantom multichain is enabled and try again.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/e.jsxs(So,{children:[/*#__PURE__*/e.jsx(vo,{onClick:()=>r(xu),children:"Try again"}),/*#__PURE__*/e.jsx(ko,{onClick:()=>t(),children:"Cancel"})]}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}};function Vw(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:a,submitEnrollmentWithTotp:i,submitEnrollmentWithPasskey:o,unenroll:s,enrollInMfa:l}=r.useContext($o);return{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:a,submitEnrollmentWithTotp:i,submitEnrollmentWithPasskey:o,unenrollWithSms:()=>s("sms"),unenrollWithTotp:()=>s("totp"),unenrollWithPasskey:e=>s("passkey",e),showMfaEnrollmentModal:()=>l(!0),closeMfaEnrollmentModal:()=>l(!1)}}const qw=t=>/*#__PURE__*/e.jsxs(Hw,{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"88",height:"89",viewBox:"0 0 88 89",...t,children:[/*#__PURE__*/e.jsx("rect",{y:"0.666016",width:"88",height:"88",rx:"44"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M45.2463 20.9106C44.5473 20.2486 43.4527 20.2486 42.7537 20.9106C37.8798 25.5263 31.3034 28.3546 24.0625 28.3546C23.9473 28.3546 23.8323 28.3539 23.7174 28.3525C22.9263 28.3427 22.2202 28.8471 21.9731 29.5987C20.9761 32.6311 20.4375 35.8693 20.4375 39.2297C20.4375 53.5896 30.259 65.651 43.5482 69.0714C43.8446 69.1477 44.1554 69.1477 44.4518 69.0714C57.741 65.651 67.5625 53.5896 67.5625 39.2297C67.5625 35.8693 67.0239 32.6311 66.0269 29.5987C65.7798 28.8471 65.0737 28.3427 64.2826 28.3525C64.1677 28.3539 64.0527 28.3546 63.9375 28.3546C56.6966 28.3546 50.1202 25.5263 45.2463 20.9106ZM52.7249 40.2829C53.3067 39.4683 53.1181 38.3363 52.3035 37.7545C51.4889 37.1726 50.3569 37.3613 49.7751 38.1759L41.9562 49.1223L38.0316 45.1977C37.3238 44.4899 36.1762 44.4899 35.4684 45.1977C34.7605 45.9056 34.7605 47.0532 35.4684 47.761L40.9059 53.1985C41.2826 53.5752 41.806 53.7671 42.337 53.7232C42.868 53.6792 43.3527 53.4039 43.6624 52.9704L52.7249 40.2829Z"})]});let Hw=/*#__PURE__*/h.styled.svg.withConfig({displayName:"StyledSvg",componentId:"sc-59fa943f-0"})(["height:90px;width:90px;> rect{","}> path{fill:white;}"],(e=>"success"===e.color?"fill: var(--privy-color-success);":"fill: var(--privy-color-accent);"));const Kw=({showIntro:t,userMfaMethods:r,appMfaMethods:n,userHasAuthSms:a,isTotpLoading:i,isPasskeyLoading:o,error:s,onClose:l,onBackToIntro:c,handleSelectMethod:d,setRemovingMfaMethod:u})=>{let p=r.reduce(((e,t)=>({...e,[t]:!0})),{}),h=n.reduce(((e,t)=>({...e,[t]:!0})),{});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:t?c:void 0,onClose:l},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(rt.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Choose a verification method"}),r.length>0?/*#__PURE__*/e.jsx(wc,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/e.jsx(wc,{children:"How would you like to verify your identity? You can change this later."}),s&&/*#__PURE__*/e.jsx(Mc,{style:{marginTop:"1.25rem"},children:s.message}),/*#__PURE__*/e.jsxs(kc,{children:[(h.totp||p.totp)&&/*#__PURE__*/e.jsxs(Ec,{children:[/*#__PURE__*/e.jsx(zi,{style:{justifyContent:"center"},disabled:p.totp||i,onClick:()=>d("totp"),children:i?/*#__PURE__*/e.jsx(mo,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e.jsxs(Sc,{children:[/*#__PURE__*/e.jsxs(Ac,{children:[/*#__PURE__*/e.jsx(ot.default,{}),"Authenticator app"]}),p.totp?/*#__PURE__*/e.jsx(Zw,{color:"green",children:"Enabled"}):/*#__PURE__*/e.jsx(Ic,{children:"Recommended"})]})}),p.totp&&/*#__PURE__*/e.jsx(Tc,{style:{position:"absolute",right:0},onClick:()=>u("totp"),children:/*#__PURE__*/e.jsx(bt.default,{})})]},"totp"),(h.sms||p.sms)&&/*#__PURE__*/e.jsxs(Ec,{children:[/*#__PURE__*/e.jsx(zi,{disabled:p.sms||a,onClick:()=>d("sms"),children:/*#__PURE__*/e.jsxs(Sc,{children:[/*#__PURE__*/e.jsxs(Ac,{children:[/*#__PURE__*/e.jsx(Fe.default,{}),"SMS"]}),p.sms&&/*#__PURE__*/e.jsx(Zw,{color:"green",children:"Enabled"}),a&&/*#__PURE__*/e.jsx(Ic,{children:"Disabled"})]})}),p.sms&&/*#__PURE__*/e.jsx(Tc,{style:{position:"absolute",right:0},onClick:()=>u("sms"),children:/*#__PURE__*/e.jsx(bt.default,{})})]},"sms"),(h.passkey||p.passkey)&&/*#__PURE__*/e.jsxs(Ec,{children:[/*#__PURE__*/e.jsx(zi,{style:{justifyContent:"center"},onClick:()=>d("passkey"),disabled:p.passkey||o,children:o?/*#__PURE__*/e.jsx(mo,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e.jsxs(Sc,{children:[/*#__PURE__*/e.jsxs(Ac,{children:[/*#__PURE__*/e.jsx(at.default,{}),"Passkey"]}),p.passkey?/*#__PURE__*/e.jsx(Zw,{color:"green",children:"Enabled"}):/*#__PURE__*/e.jsx(Ic,{isAccent:!0,children:/*#__PURE__*/e.jsx(it.default,{})})]})}),p.passkey&&/*#__PURE__*/e.jsx(Tc,{style:{position:"absolute",right:0},onClick:()=>u("passkey"),children:/*#__PURE__*/e.jsx(bt.default,{})})]},"passkey")]}),/*#__PURE__*/e.jsx(fi,{})]})};let Zw=/*#__PURE__*/h.styled(Ji).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const Gw=({appName:t,onComplete:n,onClose:a,onReset:o})=>{let{user:s}=Vo(),{data:l}=Qu(),{initLinkWithPasskey:c,linkWithPasskey:d}=i.usePrivyInternal(),{initEnrollmentWithPasskey:u,submitEnrollmentWithPasskey:p}=Vw(),[h,m]=r.useState(!1),[y,f]=r.useState(!1),[g,w]=r.useState(!1),[v,x]=r.useState(null),C=r.useMemo((()=>s?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[s]),b=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},j=async e=>{m(!0);try{await u(),await p({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),w(!0)}catch(e){x(e)}finally{m(!1)}},k=async()=>{f(!0),x(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await j(t)}catch(e){x(e)}finally{f(!1)}};return 0===C.length||y?/*#__PURE__*/e.jsx(Yw,{onReset:o,onClose:a,onClick:k,isCreating:y}):g?/*#__PURE__*/e.jsx(Xw,{appName:t,onClick:b,onClose:b}):v?/*#__PURE__*/e.jsx(Ts,{error:v,backFn:()=>x(null),onClick:()=>x(null)}):/*#__PURE__*/e.jsx(Jw,{passkeys:C,isSubmitting:h,isCreating:y,onReset:o,onClose:a,onSubmitEnrollment:()=>j(C.map((e=>e.credentialId))),onAddPasskey:k})};let Yw=({onReset:t,onClose:r,onClick:n,isCreating:a})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:t,onClose:r},"header"),/*#__PURE__*/e.jsx(fc,{children:/*#__PURE__*/e.jsxs(Wy,{children:[/*#__PURE__*/e.jsx(wd,{}),/*#__PURE__*/e.jsx(vd,{})]})}),/*#__PURE__*/e.jsx(gc,{children:"Set up passkey verification"}),/*#__PURE__*/e.jsxs(xc,{children:[/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(rt.default,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(wt.default,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(jt.default,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/e.jsx(vo,{style:{marginTop:"2.25rem"},onClick:n,loading:a,children:"Add a new passkey"}),/*#__PURE__*/e.jsx(fi,{})]}),Jw=({onReset:t,onClose:n,onAddPasskey:a,onSubmitEnrollment:i,passkeys:o,isSubmitting:s,isCreating:l})=>{let[c,d]=r.useState(!1),u=c?o.length:o.length>3?2:3;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:c?()=>d(!1):t,onClose:n},"header"),!c&&/*#__PURE__*/e.jsx(fc,{children:/*#__PURE__*/e.jsxs(Wy,{children:[/*#__PURE__*/e.jsx(wd,{}),/*#__PURE__*/e.jsx(vd,{})]})}),/*#__PURE__*/e.jsx(gc,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e.jsxs(xc,{children:[o.slice(0,u).map((t=>/*#__PURE__*/e.jsxs(Qw,{children:[/*#__PURE__*/e.jsx(ev,{children:rv(t)}),/*#__PURE__*/e.jsxs(tv,{children:["Last used: ",t.latestVerifiedAt?.toLocaleString()]})]},t.credentialId))),!c&&o.length>3&&/*#__PURE__*/e.jsx(nv,{onClick:()=>d(!0),children:"View All"})]}),/*#__PURE__*/e.jsx(vo,{style:{marginTop:"1.5rem"},onClick:i,loading:s,children:"Enable passkeys"}),o.length<5&&/*#__PURE__*/e.jsx(nv,{style:{marginTop:"0.5rem"},onClick:a,disabled:l,children:l?/*#__PURE__*/e.jsx(mo,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/e.jsx(fi,{})]})},Xw=({appName:t,onClick:r,onClose:n})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:n},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ct.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Passkey verification added"}),/*#__PURE__*/e.jsxs(wc,{children:["From now on, you'll use the passkey whenever you use your ",t," wallet."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{onClick:r,children:"Done"})}),/*#__PURE__*/e.jsx(fi,{})]}),Qw=/*#__PURE__*/h.styled.div.withConfig({displayName:"PasskeyItem",componentId:"sc-d5b2bf9c-0"})(["&&{padding:0.75rem 1rem;text-align:left;border-radius:0.5rem;border:1px solid var(--privy-color-foreground-4);width:100%;}"]),ev=/*#__PURE__*/h.styled.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-d5b2bf9c-1"})(["font-size:0.875rem;line-height:1.375rem;font-weight:500;color:var(--privy-color-foreground-1);"]),tv=/*#__PURE__*/h.styled.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-d5b2bf9c-2"})(["font-size:0.75rem;font-weight:400;line-height:1.125rem;color:var(--privy-color-foreground-2);"]),rv=e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device";const nv=/*#__PURE__*/h.styled.button.withConfig({displayName:"StyledLink",componentId:"sc-d5b2bf9c-3"})(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:0.75rem 1rem;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent);:focus{outline:none;box-shadow:none;}}"]),av=({appName:t,onComplete:n,onReset:a,onClose:i})=>{let[o,s]=r.useState(""),[l,c]=r.useState(!1),[d,p]=r.useState(null),[h,m]=r.useState("enroll"),{initEnrollmentWithSms:y,submitEnrollmentWithSms:f}=Vw(),{app:g,data:w}=Qu();function v(){w?.mfaEnrollmentFlow?.onSuccess(),n()}return d?/*#__PURE__*/e.jsx(Ts,{error:d,backFn:()=>p(null),onClick:()=>p(null)}):"enroll"===h?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:a,onClose:i},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Fe.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Set up SMS verification"}),/*#__PURE__*/e.jsxs(wc,{children:["We'll text a verification code to this mobile device whenever you use your ",t," ","wallet."]}),/*#__PURE__*/e.jsxs(vc,{children:[/*#__PURE__*/e.jsx(Id,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await y({phoneNumber:e}),s(e),m("verify")}catch(e){p(e)}},hideRecent:!0}),/*#__PURE__*/e.jsxs(Pc,{children:["By providing your mobile number, you agree to receive text messages from ",g?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/e.jsx(fi,{})]}):l?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:v},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ct.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"SMS verification added"}),/*#__PURE__*/e.jsxs(wc,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",t," wallet."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{onClick:v,children:"Done"})}),/*#__PURE__*/e.jsx(fi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:function(){"verify"===h?m("enroll"):a()},onClose:i},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Fe.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Enter enrollment code"}),/*#__PURE__*/e.jsxs(vc,{children:[/*#__PURE__*/e.jsx(Tp,{onChange:async function(e){try{if(!e)return;await f({phoneNumber:o,mfaCode:e}),c(!0)}catch(e){if(ms(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(ps(e))throw Error("The code you entered is not valid");if(us(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw ys(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e.jsxs(wc,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/e.jsx("strong",{children:u.lastFourDigits(o)})]})]}),/*#__PURE__*/e.jsx(fi,{})]})},iv=({size:t,authUrl:r})=>/*#__PURE__*/e.jsx(nd,{url:r,squareLogoElement:kt.default,size:t,fgColor:"#1F1F1F"}),ov=({onComplete:t,onClose:n,onReset:a,totpInfo:i})=>{let[o,s]=r.useState("enroll"),[l,c]=r.useState(!1),{submitEnrollmentWithTotp:d}=Vw(),{data:u}=Qu();function p(){u?.mfaEnrollmentFlow?.onSuccess(),t()}return"enroll"===o?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:a,onClose:n},"header"),/*#__PURE__*/e.jsx(gc,{children:"Scan QR code"}),/*#__PURE__*/e.jsx(wc,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/e.jsx(No,{children:/*#__PURE__*/e.jsx(iv,{authUrl:i.authUrl,size:200})}),/*#__PURE__*/e.jsxs(jc,{children:[/*#__PURE__*/e.jsx(Po,{children:/*#__PURE__*/e.jsx(qc,{itemName:"setup key",text:i.secret})}),/*#__PURE__*/e.jsx(vo,{onClick:function(){s("verify")},children:"Continue"})]}),/*#__PURE__*/e.jsx(fi,{})]}):l?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:p},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ct.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Authenticator app verification added"}),/*#__PURE__*/e.jsxs(wc,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",i.appName," wallet."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{onClick:p,children:"Done"})}),/*#__PURE__*/e.jsx(fi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:function(){"verify"===o?s("enroll"):a()},onClose:n},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ot.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Enter enrollment code"}),/*#__PURE__*/e.jsx(vc,{children:/*#__PURE__*/e.jsx(Tp,{onChange:async function(e){try{if(!e)return;await d({mfaCode:e}),c(!0)}catch(e){if(ms(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(ps(e))throw Error("The code you entered is not valid");if(us(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw ys(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e.jsxs(wc,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/e.jsx("strong",{children:"authenticator app"})]}),/*#__PURE__*/e.jsx(fi,{})]})},sv={component:()=>{let{user:t,enrollInMfa:n,ready:a}=Vo(),[o,s]=r.useState(null),{unenrollWithSms:l,unenrollWithTotp:c,unenrollWithPasskey:d}=Vw(),{app:u,data:p,onUserCloseViaDialogOrKeybindRef:h}=Qu(),{closePrivyModal:m}=i.usePrivyInternal(),{promptMfa:y}=Uh(),{initEnrollmentWithTotp:f}=Vw(),[g,w]=r.useState(!1),[v,x]=r.useState(null),[C,b]=r.useState(null),j=()=>{m({shouldCallAuthOnSuccess:!0}),n(!1),setTimeout((()=>{s(null),x(null)}),500)},{initEnrollmentWithPasskey:k,submitEnrollmentWithPasskey:E}=Vw(),[T,A]=r.useState(!1),[I,S]=r.useState(null);h.current=j;let P=t?.mfaMethods.includes("sms"),_=!!t?.phone,N=t?.mfaMethods.includes("totp"),M=t?.mfaMethods.includes("passkey"),W=P||N||M,O=t?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function U(){s(null),x(null)}if(r.useEffect((()=>{W&&w(!0)}),[W]),!a||!t||!u/*#__PURE__*/)return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:j},"header"),/*#__PURE__*/e.jsx(fc,{children:/*#__PURE__*/e.jsx(qw,{})}),/*#__PURE__*/e.jsx(vc,{children:/*#__PURE__*/e.jsx(mo,{})}),/*#__PURE__*/e.jsx(fi,{})]});if("sms"===o)/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:U,onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Se.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Remove SMS verification?"}),/*#__PURE__*/e.jsxs(wc,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{warn:!0,onClick:async function(){s(null);try{await l()}catch(e){s(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/e.jsx(fi,{})]});if("totp"===o)/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:U,onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Se.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e.jsxs(wc,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{warn:!0,onClick:async function(){s(null);try{await c()}catch(e){s(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/e.jsx(fi,{})]});if("passkey"===o){let t=p?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{backFn:U,onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Se.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/e.jsx(wc,{children:t?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{warn:!0,onClick:async function(){s(null);try{await d({removeForLogin:p?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){s(null)}},children:"Yes, remove"})}),/*#__PURE__*/e.jsx(fi,{})]})}if(0===p.mfaEnrollmentFlow.mfaMethods.length&&!W)/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(rt.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Add more security"}),/*#__PURE__*/e.jsxs(wc,{children:[u?.name," does not have any verification methods enabled."]}),/*#__PURE__*/e.jsx(jc,{children:/*#__PURE__*/e.jsx(vo,{onClick:j,children:"Close"})}),/*#__PURE__*/e.jsx(fi,{})]});let F=!W&&!g;return F?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{onClose:j},"header"),/*#__PURE__*/e.jsx(Nc,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(rt.default,{})}),/*#__PURE__*/e.jsx(gc,{children:"Transaction Protection"}),/*#__PURE__*/e.jsx(wc,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e.jsxs(xc,{children:[/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(xt.default,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),/*#__PURE__*/e.jsxs(bc,{children:[/*#__PURE__*/e.jsx(Cc,{children:/*#__PURE__*/e.jsx(Ct.default,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e.jsxs(jc,{children:[/*#__PURE__*/e.jsx(vo,{onClick:()=>w(!0),children:"Continue"}),/*#__PURE__*/e.jsx(ko,{onClick:j,children:"Not now"})]}),/*#__PURE__*/e.jsx(fi,{})]}):"sms"===v?/*#__PURE__*/e.jsx(av,{appName:u?.name||"Privy",onComplete:j,onReset:U,onClose:j}):"totp"===v&&C?/*#__PURE__*/e.jsx(ov,{onComplete:j,onClose:j,onReset:U,totpInfo:{...C,appName:u?.name||"Privy"}}):"passkey"===v?/*#__PURE__*/e.jsx(Gw,{appName:u?.name||"Privy",onComplete:j,onReset:U,onClose:j}):/*#__PURE__*/e.jsx(Kw,{showIntro:F,userMfaMethods:t.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:_,onBackToIntro:function(){w(!1)},handleSelectMethod:async function(e){return await y().catch(S),"totp"===e?(x(e),b(null),void f().then((e=>{b(e)})).catch((()=>{b(null),U()}))):"passkey"===e&&1===O.length?await async function(){A(!0);try{await k(),await E({credentialIds:O},{removeForLogin:p?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){S(e)}finally{A(!1)}}():void x(e)},isTotpLoading:"totp"===v&&!C,isPasskeyLoading:T,error:I,onClose:j,setRemovingMfaMethod:async e=>{await y().catch(S),s(e)}})}},lv={component:()=>{let{authenticated:t,logout:n,ready:a,user:o}=Vo(),{app:s,setModalData:l,navigate:c,resetNavigation:d}=Qu(),{getAuthMeta:u,initLoginWithOAuth:p,loginWithOAuth:h,updateWallets:m,setReadyToTrue:y,closePrivyModal:f,createAnalyticsEvent:g}=i.usePrivyInternal(),[w,v]=r.useState(!1),[x,C]=r.useState(void 0),b=u()?.provider||"google",{name:j,component:k}=Yr(b);r.useEffect((()=>{h(b).then((()=>{v(!0),y(!0)})).catch((e=>{if(y(!1),e?.privyErrorCode===i.PrivyErrorCode.ALLOWLIST_REJECTED)return C(void 0),d(),void c(ad);if(e?.privyErrorCode===i.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new i.PrivyUserLimitReachedError(e).toString()),C(void 0),d(),void c(ld);if(e?.privyErrorCode===i.PrivyErrorCode.USER_DOES_NOT_EXIST)return C(void 0),d(),void c(Cu);if(e?.privyErrorCode===i.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return C(void 0),d(),l({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:u()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void c(Bs);let{retryable:t,detail:r}=function(e,t){let r={detail:"",retryable:!1},n=Rr(t);if(e?.privyErrorCode===i.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(r.detail="This account has already been linked to another user."),e?.privyErrorCode===i.PrivyErrorCode.INVALID_CREDENTIALS&&(r.retryable=!0,r.detail="Something went wrong. Try again."),e.privyErrorCode===i.PrivyErrorCode.OAUTH_USER_DENIED&&(r.detail=`Retry and check ${n} to finish connecting your account.`,r.retryable=!0),e?.privyErrorCode===i.PrivyErrorCode.TOO_MANY_REQUESTS&&(r.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===i.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=Yr(t).name;r.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===i.PrivyErrorCode.OAUTH_ACCOUNT_SUSPENDED){let e=Yr(t).name;r.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===i.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(r.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===i.PrivyErrorCode.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(r.detail="Something went wrong. Please try again."),r}(e,b);C({retryable:t,detail:r,message:"Authentication failed"})})).finally((()=>{Xr()}))}),[j,b]),r.useEffect((()=>{if(a&&t&&w&&o){if(s?.legal.requireUsersAcceptTerms&&!o.hasAcceptedTerms){let e=setTimeout((()=>{c(Wc)}),or);return()=>clearTimeout(e)}if(Go(o,s.embeddedWallets)){let e=setTimeout((()=>{l({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),g({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:b,screen:"OAuthStatusScreen"}}),n()},callAuthOnSuccessOnClose:!0}}),c(mc)}),or);return()=>clearTimeout(e)}{let e=setTimeout((()=>f({shouldCallAuthOnSuccess:!0,isSuccess:!0})),or);return m(),()=>clearTimeout(e)}}}),[a,t,w,o]);let E=w?`Successfully connected with ${j}`:x?x.message:`Verifying connection to ${j}`,T="";return T=w?"You’re good to go!":x?x.detail:"Just a few moments more",/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{}),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsxs(cv,{children:[/*#__PURE__*/e.jsx(Jo,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(ho,{success:w,fail:!!x}),/*#__PURE__*/e.jsx(k,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e.jsxs(Oo,{children:[/*#__PURE__*/e.jsx("h3",{children:E}),/*#__PURE__*/e.jsx("p",{children:T})]}),x&&x?.retryable?/*#__PURE__*/e.jsx(To,{onClick:()=>{Xr(),p(b),C(void 0)},disabled:!w&&!x?.retryable,children:"Retry"}):null]}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(fi,{})]})}};let cv=/*#__PURE__*/h.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-89bb91a9-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const dv=/*#__PURE__*/r.forwardRef(((t,n)=>{let[a,o]=r.useState(""),[s,l]=r.useState(""),[c,d]=r.useState(!1),{authenticated:u,user:p}=Vo(),{initUpdateEmail:h}=i.usePrivyInternal(),{navigate:m,setModalData:y,currentScreen:f}=Qu(),{enabled:g,token:w}=cn(),v=di(),x=Rt(a)&&(v.disablePlusEmails&&a.includes("+")?(s||l("Please enter a valid email address without a '+'."),!1):(s&&l(""),!0)),C=c||!x,b=()=>{!g||w||u?(async e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");d(!0);try{await h(p.email.address,a,e),m(eu)}catch(e){y({errorModalData:{error:e,previousScreen:f||xu}})}d(!1)})(w):(y({captchaModalData:{callback:e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");return h(p.email.address,a,e)},userIntentRequired:!1,onSuccessNavigateTo:eu,onErrorNavigateTo:Es}}),m(Bc))};/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(uv,{children:[s&&/*#__PURE__*/e.jsx(lu,{style:{marginTop:"0.25rem",textAlign:"left"},children:s}),/*#__PURE__*/e.jsxs(pv,{$error:!!s,children:[/*#__PURE__*/e.jsx(Oe.default,{}),/*#__PURE__*/e.jsx("input",{ref:n,id:"email-input",type:"email",placeholder:"your@email.com",onChange:e=>o(e.target.value),onKeyUp:e=>{"Enter"===e.key&&b()},value:a,autoComplete:"email"}),t.stacked?null:/*#__PURE__*/e.jsx(Ao,{isSubmitting:c,onClick:b,disabled:C,children:"Submit"})]})]}),t.stacked?/*#__PURE__*/e.jsx(vo,{loadingText:null,loading:c,disabled:C,onClick:b,children:"Submit"}):null]})}));let uv=pu,pv=du;const hv={component:()=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Pi,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/e.jsx(Oe.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(dv,{stacked:!0})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})},mv={component:()=>{let{currentScreen:t,data:r,navigate:n,setModalData:a}=Qu(),{user:o}=Vo(),{initUpdatePhone:s}=i.usePrivyInternal();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Ci,{},"header"),/*#__PURE__*/e.jsx(Fo,{}),/*#__PURE__*/e.jsx(Pi,{title:"Update your phone number",description:"Add the phone number you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/e.jsx(Fe.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/e.jsx(So,{children:/*#__PURE__*/e.jsx(Id,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{if(!o?.phone?.number)throw Error("User is required to have an phone number to update it.");await s(o?.phone?.number,e),n(eu)}catch(e){a({errorModalData:{error:e,previousScreen:r?.errorModalData?.previousScreen||t||Dw}}),n(Es)}},hideRecent:!0})}),/*#__PURE__*/e.jsx(Ro,{}),/*#__PURE__*/e.jsx(yi,{})]})}};let yv,fv,gv,wv,vv,xv,Cv;async function bv(){return yv?yv.getAccessToken():Promise.resolve(Nt.get(hr)||Nt.get(dr)||null)}const jv=(e,t)=>fv(e,t),kv=(e,t)=>gv(e,t),Ev=(e,t)=>wv(e,t),Tv=(e,t)=>vv(e,t),Av=()=>xv(),Iv=()=>Cv();let Sv=o=>{let s=o.client,l=Um();pm();let[c,d]=r.useState(!1),[u,p]=r.useState(!1),[h,m]=r.useState(!1),[y,f]=r.useState(null),[g,w]=r.useState([]),[v,x]=r.useState([]),[C,b]=r.useState(!1),[j,k]=r.useState(null),[E,T]=r.useState(!1),[A,I]=r.useState({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:i.notImplemented}),[S,P]=r.useState({status:"initial"}),[_,N]=r.useState({status:"initial"}),[M,W]=r.useState({status:"initial"}),[O,U]=r.useState({status:"initial"}),[F,R]=r.useState({status:"initial"}),[L,D]=r.useState({status:"initial"}),[B,z]=r.useState(null),$=di(),V=ui(),[q,H]=r.useState({}),[K,Z]=r.useState(null),[G,Y]=r.useState(null),[J,X]=r.useState(!1),[Q,ee]=r.useState(!1),[te,re]=r.useState($.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),ne=r.useRef(null),ae=r.useRef(null),ie=r.useRef(eo),[oe,se]=r.useState(!1);s.onStoreCustomerAccessToken=e=>{e&&ao(ie,"accessToken","onAccessTokenGranted",{accessToken:e})},s.onDeleteCustomerAccessToken=()=>{f(null),m(!1),ao(ie,"accessToken","onAccessTokenRemoved")};let le=r.useRef(null),ce=r.useRef(null),de=r.useRef(!1),ue=({showWalletUIs:e})=>de.current?de.current:void 0!==e?!e:!$.embeddedWallets.showWalletUIs,pe=e=>{k(e),setTimeout((()=>{d(!0)}),15)};r.useEffect((()=>{if(!y)return void s.connectors?.removeEmbeddedWalletConnectors();let e=wn(y),t=vn(y),r=bn(y);e&&t.length||s.connectors?.removeEmbeddedWalletConnectors(),r||s.connectors?.removeImportedWalletConnector(),s.connectors?B?(e&&s.connectors.addEmbeddedWalletConnectors({walletProxy:B,user:y,embeddedWallets:t,defaultChain:$.defaultChain,appId:o.appId}),r&&s.connectors.addImportedWalletConnector(B,r.address,$.defaultChain,o.appId)):console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized"):console.debug("Failed to add embedded wallet connector: Client connectors not initialized")}),[B,y]),r.useEffect((()=>{B&&G?.(B)}),[B]);let he=r.useRef();r.useEffect((()=>{(async()=>{if(!$.customAuth?.enabled)return void re({status:"not-enabled"});let{getCustomAccessToken:e,isLoading:t}=$.customAuth;if(u&&!t&&"loading"!==te.status){re({status:"loading"});try{let t=await e();if(t===he.current)return void re({status:"done"});if(!t&&h)return he.current=t,await Fe.logout(),re({status:"done"}),void ao(ie,"customAuth","onUnauthenticated");if(!t)return he.current=t,void re({status:"done"});s.startAuthFlow(new Tt(t));let{user:r,isNewUser:n}=await s.authenticate();if(!r)return await Fe.logout(),re({status:"error",error:new i.PrivyClientError("Failed to sync with custom auth provider")}),void ao(ie,"customAuth","onUnauthenticated");void 0!==n&&ao(ie,"login","onComplete",{user:r,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),he.current=t,ao(ie,"customAuth","onAuthenticated",{user:r}),re({status:"done"}),f(r||null),b(n||!1),m(!0),ee(!0)}catch(e){if(console.warn(e),await Fe.logout(),ao(ie,"customAuth","onUnauthenticated"),"User already exists with provided custom JWT account."===e.message)return void re({status:"initial"});ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),re({status:"error",error:e})}}})()}),["initial"===te.status,$.customAuth?.enabled,$.customAuth?.getCustomAccessToken,$.customAuth?.isLoading,u,h]),r.useEffect((()=>{Q&&B&&y&&(async()=>{let e=qo(y,$.embeddedWallets.ethereum.createOnLogin),t=Ko(y,$.embeddedWallets.solana.createOnLogin),r=await bv();if(r){if(e&&t){let e=await Ee(y,Ir);return await B.createSolana({accessToken:r,ethereumAddress:e?.address}),void ee(!1)}if(t)return await B.createSolana({accessToken:r,ethereumAddress:wn(y)?.address}),await Re.refreshSessionAndUser(),void ee(!1);if(e)return await Ee(y,Ir),void ee(!1)}})().catch(console.error)}),[Q&&B&&y]),r.useEffect((()=>{if($.externalWallets.solana.connectors)return $.externalWallets.solana.connectors.onMount(),()=>$.externalWallets.solana.connectors?.onUnmount()}),[$.externalWallets.solana.connectors]),r.useEffect((()=>{!u&&V&&async function(){let e,r=me(),n=ye(),a=t.createStore();s.initializeConnectorManager({walletConnectCloudProjectId:$.walletConnectCloudProjectId,rpcConfig:$.rpcConfig,chains:$.chains,defaultChain:$.defaultChain,store:a,walletList:$.appearance.walletList,shouldEnforceDefaultChainOnConnect:$.shouldEnforceDefaultChainOnConnect,externalWalletConfig:$.externalWallets,appName:$.name??"Privy",walletChainType:$.appearance.walletChainType}),s.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=s.connectors.walletConnectors.length,r=s.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);r===t?se(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:r,expected:t}),se(!0)}),1500)})),s.connectors?.initialize().then((()=>{xe()}));let i=await s.getAuthenticatedUser(),o=!!i;$.legal.requireUsersAcceptTerms&&i&&!i.hasAcceptedTerms?(await s.logout(),Re.setReadyToTrue(!0),ao(ie,"logout","onSuccess")):($.customAuth?.enabled||(m(!!i),i&&ao(ie,"login","onComplete",{user:i,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),f(i)),r?ce.current=o?"link":"login":n&&!o?(ce.current="login",H({telegramAuthModalData:{seamlessAuth:!0}}),pe(Ud)):Re.setReadyToTrue(!!i))}()}),[s,K,u,V]),r.useEffect((()=>{if(u){if(!y||!y.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType))||[...g].some((e=>"privy"===e.walletClientType)))return void X(!0);X(!!B)}}),[u,y,g,B]),r.useEffect((()=>{s.connectors?.setWalletList($.appearance.walletList)}),[$.appearance.walletList.join()]);let me=()=>{let e=Jr();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&function(e){return e.startsWith("privy:")}(e.provider)&&!e.popupFlow&&(new BroadcastChannel(mm).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(s.startAuthFlow(new Fr(e)),pe(lv),!0))},ye=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),r=e.get("hash"),n=Number(e.get("auth_date")||""),a=e.get("first_name");if(t&&a&&n&&r)return Object.fromEntries(e.entries())}())?(hn(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=pn(e.replace("#tgWebAppData=","")),{user:r,auth_date:n,hash:a}=t;return r&&n&&a?t:void 0}())?(hn(),{flowType:"web-app",authData:e}):void 0}();if(!e||!$.loginMethods.telegram||!$.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new dn;return s.startAuthFlow(t),"login-url"===e.flowType&&(t.meta.telegramWebAppData=void 0,t.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=e.authData),!0},fe=async(e,t,r,n)=>{if("solana_adapter"!==e)ge(await(s.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,r,n);else{let e=s.connectors?.findSolanaWalletConnector(t);if(!e)return;ge(e,t,r,n)}};async function ge(e,t,r,n){if(!e)return I({status:"disconnected",connectedWallet:null,connectError:new i.PrivyConnectorError("Unable to connect to wallet."),connector:null,connectRetry:i.notImplemented}),n?.(null,r);I({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:i.notImplemented}),e instanceof ep&&t&&await e.resetConnection(t),I({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>ge(e,t,r,n)});try{let t=await e.connect({showPrompt:!0});if((!t||ea(t))&&$.shouldEnforceDefaultChainOnConnect&&!$.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){I((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:i.notImplemented})));try{await(t?.switchChain($.defaultChain.id)),t&&(t.chainId=Kt(qt($.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${$.defaultChain.id}`)}}return I((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:i.notImplemented}))),t&&ao(ie,"connectWallet","onSuccess",{wallet:t}),n?.(t,r)}catch(e){return e instanceof i.PrivyError?(console.warn(e.cause?e.cause:e.message),ao(ie,"connectWallet","onError",e.privyErrorCode||i.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),ao(ie,"connectWallet","onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR)),I((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),n?.(null,r)}}let we=async(e,t,r)=>{if(null===e||!ea(e))return;let n=new tn(e,s,t,r);s.startAuthFlow(n)},ve=async(e,t,r)=>{if(null===e||!Fa(e))return;let n=new rn(e,s,t,r);s.startAuthFlow(n)},xe=()=>{let e=new URLSearchParams(window.location.search),t=e.get("privy_connector"),r=e.get("privy_wallet_client"),n="true"===e.get("privy_connect_only");if(!t||!r)return;let a=Na({connectorType:t,walletClientType:r});if(!a||!a.isInstalled)return pe($w);if(!s.connectors)throw new i.PrivyClientError("Connector not initialized");pe(n?Su:Eu);let o=new URL(window.location.href);o.searchParams.delete("privy_connector"),o.searchParams.delete("privy_wallet_client"),o.searchParams.delete("privy_connect_only"),window.history.pushState({},"",o),fe(t,r,void 0,n?void 0:"solana_adapter"===t?ve:we)};r.useEffect((()=>{u&&h&&null===y&&s.getAuthenticatedUser().then(f)}),[u,h,y,s]);let Ce=e=>{if(!h)throw ao(ie,"linkAccount","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:e}),new i.PrivyClientError("User must be authenticated before linking an account.")},be=e=>{if(!h||!y)return!1;if("privy"===e.walletClientType)return!0;for(let t of y.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},je=async e=>{let t;if(!s.connectors)throw new i.PrivyClientError("Connector not initialized");t="ethereum"===e.type?s.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:s.connectors.findSolanaWalletConnector(e.walletClientType)||null,I((r=>({...r,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:i.notImplemented}))),$.captchaEnabled&&!h?(H({captchaModalData:{callback:t=>ea(e)?we(e,t):ve(e,t),userIntentRequired:!1,onSuccessNavigateTo:Eu,onErrorNavigateTo:Es}}),pe(Bc)):(ea(e)?await we(e):await ve(e),pe(Eu))},ke=()=>{w((e=>{let t=s.connectors?.wallets.filter(ea).map((e=>({...e,linked:be(e),loginOrLink:async()=>{if(!await e.isConnected())throw new i.PrivyClientError("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new i.PrivyClientError("Cannot link or login with embedded wallet");je(e)},fund:async t=>{await Re.fundWallet(e.address,t)},unlink:async()=>{if(!h)throw new i.PrivyClientError("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new i.PrivyClientError("Cannot unlink an embedded wallet");f(await s.unlinkEthereumWallet(e.address))}})))||[];return ta(e,t)?e:t})),x((e=>{let t=(s.connectors?.wallets??[]).filter(Fa).map((e=>({...e,linked:be(e),loginOrLink:async()=>{if(!await e.isConnected())throw new i.PrivyClientError("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new i.PrivyClientError("Cannot link or login with embedded wallet");je(e)},fund:async()=>{throw new i.PrivyClientError("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!h)throw new i.PrivyClientError("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new i.PrivyClientError("Cannot unlink an embedded wallet");f(await s.unlinkSolanaWallet(e.address))}})));return ta(e,t)?e:t}))};r.useEffect((()=>{ke()}),[y?.linkedAccounts,h,u]),r.useEffect((()=>{if(u){if(!s.connectors)throw new i.PrivyClientError("Connector not initialized");ke(),s.connectors.on("walletsUpdated",ke)}}),[u]),r.useEffect((()=>{[...$.loginMethodsAndOrder?.primary??[],...$.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>s.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!s]);let Ee=async(e,t,r)=>{let n=wn(e),a=Cn(e);if(r&&"walletIndex"in r&&"number"==typeof r.walletIndex)return Ie(e,t,r.walletIndex,n,a);let o=r&&"createAdditional"in r&&r.createAdditional;if(n&&!o)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");let[s,l]=await Promise.all([Re.initializeWalletProxy(t),bv()]);if(!s&&$.customAuth?.enabled)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!s||!l||$.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return Ae();if(!n)return a&&await Re.recoverPrimaryWallet(),await s.create({accessToken:l,solanaAddress:a?.address}),Pe(0,"ethereum");{let t=((e=>vn(e).reduce(((e,t)=>!e||e.walletIndex<t.walletIndex?t:e),null))(e)?.walletIndex??0)+1,{entropyId:r,entropyIdVerifier:n}=Sn(e);return await Re.recoverPrimaryWallet(),await s.addWallet({accessToken:l,entropyId:r,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:t}),Pe(t,"ethereum")}},Te=async(e,t,r)=>{let n=wn(e),a=Cn(e),o=r&&"createAdditional"in r&&r.createAdditional,s=r&&"walletIndex"in r?r.walletIndex:void 0,l=((e=>xn(e).reduce(((e,t)=>!e||e.walletIndex<t.walletIndex?t:e),null))(e)?.walletIndex??-1)+1;if(a&&!o&&"number"!=typeof s)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");if("number"==typeof s&&s<0)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${s}) is invalid.`);let[c,d]=await Promise.all([Re.initializeWalletProxy(t),bv()]);if(!c||!d)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return await Se({user:e,wp:c,accessToken:d,walletIndex:s??l,ethereumWallet:n})},Ae=async()=>new Promise(((e,t)=>{H({createWallet:{onSuccess:t=>{ao(ie,"createWallet","onSuccess",{wallet:t}),e(t)},onFailure:e=>{ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),t(e)},callAuthOnSuccessOnClose:!1}}),pe(mc)})),Ie=async(e,t,r,n,a)=>{if(r<0)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${r}) is invalid.`);let[o,s]=await Promise.all([Re.initializeWalletProxy(t),bv()]);if(!o&&$.customAuth?.enabled)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!o||!s||$.embeddedWallets?.requireUserOwnedRecoveryOnCreate){if(0==r)return Ae();throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Create wallet UI can only be displayed when walletIndex is 0.")}if(0===r){if(n)return n;await o.create({accessToken:s,solanaAddress:a?.address})}else{if(!n)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error("A user must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let t=vn(e).find((e=>e.walletIndex===r));if(t)return t;let{entropyId:a,entropyIdVerifier:l}=Sn(e);await Re.recoverPrimaryWallet(),await o.addWallet({accessToken:s,entropyId:a,entropyIdVerifier:l,chainType:"ethereum",hdWalletIndex:r})}return Pe(r,"ethereum")},Se=async({user:e,wp:t,accessToken:r,walletIndex:n,ethereumWallet:a})=>{let o=xn(e).find((e=>e.walletIndex===n));if(o)return o;if(0===n)a&&await Re.recoverPrimaryWallet(),await t.createSolana({accessToken:r,ethereumAddress:a?.address});else{if(!En(e))throw ao(ie,"createWallet","onError",i.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error("User must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let{entropyId:a,entropyIdVerifier:o}=Sn(e);await Re.recoverPrimaryWallet(),await t.addWallet({accessToken:r,entropyId:a,entropyIdVerifier:o,chainType:"solana",hdWalletIndex:n})}return Pe(n,"solana")},Pe=async(e,t)=>{let r=await Re.refreshSessionAndUser(),n=("ethereum"===t?vn(r):xn(r)).find((t=>t.walletIndex===e));if(!n)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");return ao(ie,"createWallet","onSuccess",{wallet:n}),n},_e=({transaction:e,uiOptions:t,fundWalletConfig:r,address:n,signOnly:s})=>new Promise((async(l,c)=>{let{requesterAppId:d}=t||{},u=s?"signTransaction":"sendTransaction";if(!h||!y)return ao(ie,u,"onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),void c(Error("User must be authenticated before signing with a Privy wallet"));let p=n?kn(y,n):wn(y);if(!p)return ao(ie,u,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void c(new i.PrivyClientError("User must have an embedded wallet to send a transaction."));let m=p.address,f=p.walletIndex??0,{entropyId:g,entropyIdVerifier:w}=Sn(y,p),v=Le.wallets.find((e=>"privy"===e.walletClientType&&a.getAddress(e.address)===a.getAddress(m)));if(!v)return ao(ie,u,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have a Privy wallet before signing"));let x=await v.getEthereumProvider(),C=await x.request({method:"eth_chainId"}),b=e.chainId?Number(e.chainId):hm(C);(e=>{if(!$.chains.map((e=>e.id)).includes(e))throw new i.PrivyConnectorError(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,i.PrivyErrorCode.UNSUPPORTED_CHAIN_ID)})(b);let j={...e,from:e.from??m,chainId:b},k=await bv();if(!k||!B)return ao(ie,u,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have valid access token and Privy wallet to send transaction"));let E=Ut(j.chainId,$.chains,$.rpcConfig,{appId:o.appId});if(ue({showWalletUIs:t?.showWalletUIs}))(async()=>{try{if(!await Re.recoverPrimaryWallet())return ao(ie,u,"onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),void c(Error("Unable to connect to wallet"));let e=await Mh(j,E,j.from),t=s?await um({accessToken:k,entropyId:g,entropyIdVerifier:w,transactingWalletIndex:f,walletProxy:B,transactionRequest:j,requesterAppId:d}):await dm({accessToken:k,entropyId:g,entropyIdVerifier:w,transactingWalletIndex:f,walletProxy:B,transactionRequest:e,publicClient:E,requesterAppId:d});s?ao(ie,"signTransaction","onSuccess",{signature:t}):ao(ie,"sendTransaction","onSuccess",{hash:t}),l({hash:t})}catch(e){ao(ie,u,"onError",i.PrivyErrorCode.TRANSACTION_FAILURE),c(e)}})();else{let e={connectingWalletAddress:m,recoveryMethod:p.recoveryMethod,entropyId:g,entropyIdVerifier:w,onCompleteNavigateTo:vw,onFailure:e=>{ao(ie,u,"onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),c(e)}},n=qm($)?Wf({address:m,appConfig:$,fundWalletConfig:r,methodScreen:If,chainIdOverride:j.chainId,comingFromSendTransactionScreen:!0}):void 0;H({connectWallet:e,sendTransaction:{transactionRequest:j,transactingWalletIndex:f,transactingWalletAddress:m,entropyId:g,entropyIdVerifier:w,signOnly:s,onConfirm:s?async()=>await um({accessToken:k,entropyId:g,entropyIdVerifier:w,transactingWalletIndex:f,walletProxy:B,transactionRequest:j,requesterAppId:d}):void 0,onSuccess:e=>{s?ao(ie,"signTransaction","onSuccess",{signature:e.hash}):ao(ie,"sendTransaction","onSuccess",{hash:e.hash}),l(e)},onFailure:e=>{ao(ie,u,"onError",i.PrivyErrorCode.TRANSACTION_FAILURE),c(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:d},funding:n}),pe($f)}}));function Ne(){return new Promise((async(e,t)=>{let r=await bv();if(!r||!B)throw Error("Must have valid access token to enroll in MFA");try{await B.verifyMfa({accessToken:r}),e()}catch(e){t(e)}}))}let Me=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],We=e=>{let t=y?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:r,loginMethod:n}=Qo(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw ao(ie,"linkAccount","onError",i.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:n}),new i.PrivyClientError(`User already has an account of type ${r} linked.`)};async function Oe({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){k(null);let r=t?"setWalletPassword":"setWalletRecovery";if(!h||!y)throw ao(ie,r,"onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let n=En(y);if(!n||!B)throw ao(ie,r,"onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");try{await Ne()}catch(e){throw ao(ie,r,"onError",i.PrivyErrorCode.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,o)=>{let s={onSuccess:e=>{ao(ie,r,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{ao(ie,r,"onError",i.PrivyErrorCode.USER_EXITED_SET_PASSWORD_FLOW),o(e)},callAuthOnSuccessOnClose:!1},l="user-passcode"===n.recoveryMethod,c=dc({walletAction:"update",availableRecoveryMethods:$.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:l,showAutomaticRecovery:e}),{entropyId:d,entropyIdVerifier:u}=Sn(y),p={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,onCompleteNavigateTo:c,shouldForceMFA:!1,entropyId:d,entropyIdVerifier:u,onFailure:e=>{ao(ie,r,"onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),o(e)}};H({setWalletPassword:s,recoverWallet:{entropyId:d,entropyIdVerifier:u,onFailure:o},createWallet:s,connectWallet:p,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:l}}),pe($f)}))}async function Ue({appId:e,action:t}){let r=await bv();if("link"===t&&!r)throw ao(ie,"linkAccount","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new i.PrivyClientError("User must be authenticated before linking an account.");if("login"===t&&r)throw ao(ie,"login","onError",i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),new i.PrivyClientError("Attempted to log in, but user is already logged in. Use a `link` helper instead.");le.current=`privy:${e}`,ce.current=t;let n=wm();return s.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(r,a)=>{let{name:i,logoUrl:o}=await gm({api:s.api,providerAppId:e,requesterAppId:$.id});H({crossAppAuth:{appId:e,name:i,logoUrl:o,action:t,popup:n,onSuccess:r,onError:a}}),pe(Tw)}))}let Fe={ready:u,authenticated:h,user:y,walletConnectors:s.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),H({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),pe(h?kw:Gu)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),Ce("siwe"),le.current="siwe",ce.current="link",H({...q,externalConnectWallet:{...q.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),pe(Bw)},startCrossAppAuthFlow:Ue,linkEmail:()=>{Ce("email"),We("email"),le.current="email",ce.current="link",pe(Lw)},linkPhone:()=>{Ce("sms"),We("phone"),le.current="sms",ce.current="link",pe(Dw)},linkGoogle:async()=>{Ce("google"),We("google_oauth"),ce.current="link",await Re.initLoginWithOAuth("google")},linkTwitter:async()=>{Ce("twitter"),We("twitter_oauth"),ce.current="link",await Re.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Ce("discord"),We("discord_oauth"),ce.current="link",await Re.initLoginWithOAuth("discord")},linkGithub:async()=>{Ce("github"),We("github_oauth"),ce.current="link",await Re.initLoginWithOAuth("github")},linkSpotify:async()=>{Ce("spotify"),We("spotify_oauth"),ce.current="link",await Re.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Ce("instagram"),We("instagram_oauth"),ce.current="link",await Re.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Ce("tiktok"),We("tiktok_oauth"),ce.current="link",await Re.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Ce("linkedin"),We("linkedin_oauth"),ce.current="link",await Re.initLoginWithOAuth("linkedin")},linkApple:async()=>{Ce("apple"),We("apple_oauth"),ce.current="link",await Re.initLoginWithOAuth("apple")},linkPasskey:async()=>{Ce("passkey"),We("passkey"),await Re.initLinkWithPasskey(),pe(My)},linkTelegram:async e=>{if(Ce("telegram"),We("telegram"),ce.current="link",le.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new dn;s.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=pn(e.launchParams.initDataRaw),H({telegramAuthModalData:{seamlessAuth:!0}}),pe(Ud)}else ao(ie,"linkAccount","onError",i.PrivyErrorCode.INVALID_DATA,{linkMethod:"telegram"});else await Re.initLoginWithTelegram();pe(Ud)},linkFarcaster:async()=>{Ce("farcaster"),We("farcaster"),await Re.initLoginWithFarcaster(),ce.current="link",le.current="farcaster",pe(hd)},updateEmail:()=>{if(Ce("email"),!y?.email)throw new i.PrivyClientError("User does not have an email linked to their account.");ce.current="update",le.current="email",pe(hv)},updatePhone:()=>{if(Ce("sms"),!y?.phone)throw new i.PrivyClientError("User does not have a phone number linked to their account.");ce.current="update",le.current="sms",pe(mv)},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!u){let e=await new Promise((e=>{Z((t=>e.bind(t)))}));if(Z(null),e)return void console.warn(t)}!y||y.isGuest?(ce.current="login",H({login:e}),pe(xu)):console.warn(t)},connectOrCreateWallet:async()=>{u||(await new Promise((e=>{Z((()=>e))})),Z(null)),h?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(ce.current="connect-or-create",pe(Zd))},logout:async()=>{if(ce.current=null,le.current=null,y&&s.clearProviderAcccessTokens(y),k(null),await s.logout(),y&&B)try{await B.clearMfa({userId:y.id})}catch(e){}f(null),m(!1),ao(ie,"logout","onSuccess"),d(!1),Nt.del(gr),Nt.del(wr($.id))},getAccessToken:r.useCallback((()=>s.getCustomerAccessToken()),[s]),unlinkWallet:async e=>{let t;return f(t=e.startsWith("0x")?await s.unlinkEthereumWallet(e):await s.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await s.unlinkEmail(e);return f(t),t},unlinkPhone:async e=>{let t=await s.unlinkPhone(e);return f(t),t},unlinkGoogle:async e=>{let t=await s.unlinkOAuth("google",e);return f(t),t},unlinkTwitter:async e=>{let t=await s.unlinkOAuth("twitter",e);return f(t),t},unlinkDiscord:async e=>{let t=await s.unlinkOAuth("discord",e);return f(t),t},unlinkGithub:async e=>{let t=await s.unlinkOAuth("github",e);return f(t),t},unlinkSpotify:async e=>{let t=await s.unlinkOAuth("spotify",e);return f(t),t},unlinkInstagram:async e=>{let t=await s.unlinkOAuth("instagram",e);return f(t),t},unlinkTiktok:async e=>{let t=await s.unlinkOAuth("tiktok",e);return f(t),t},unlinkLinkedIn:async e=>{let t=await s.unlinkOAuth("linkedin",e);return f(t),t},unlinkApple:async e=>{let t=await s.unlinkOAuth("apple",e);return f(t),t},unlinkFarcaster:async e=>{let t=await s.unlinkFarcaster(e);return f(t),t},unlinkTelegram:async e=>{let t=await s.unlinkTelegram(e);return f(t),t},unlinkPasskey:async e=>{let t=await bv();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!B)throw Error("Wallet proxy not initialized.");let r=$.passkeys.shouldUnenrollMfaOnUnlink;await B.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:r});let n=await s.getAuthenticatedUser();return f(n),n},unlinkCrossAppAccount:async({subject:e})=>{let t=y?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new i.PrivyClientError("Invalid subject");s.storeProviderAccessToken(t.id,null);let r=await s.unlinkOAuth(`privy:${t.id}`,e);return f(r),r},createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let t=await Re.refreshSessionAndUser();if(!t)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return Ee(t,15e3,e)},setWalletRecovery:async e=>Oe({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>Oe({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(r,n)=>{let{requesterAppId:a}=t?.uiOptions||{},o=e.message;if(!h||!y)return ao(ie,"signMessage","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),void n(Error("User must be authenticated before signing with a Privy wallet"));let l=t?.address?kn(y,t.address):wn(y);if(!l)throw new i.PrivyClientError("User must have an embedded wallet to send a transaction.");let c=l.address,d=l.walletIndex??0,{entropyId:u,entropyIdVerifier:p}=Sn(y,l);if("string"!=typeof o||o.length<1)return ao(ie,"signMessage","onError",i.PrivyErrorCode.INVALID_MESSAGE),void n(Error("Message must be a non-empty string"));let m=async()=>{if(!h)throw Error("User must be authenticated before signing with a Privy wallet");let e=await bv();if(!B||!e||!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");s.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:c,requesterAppId:a}});let{response:t}=await B.rpc({accessToken:e,entropyId:u,entropyIdVerifier:p,chainType:"ethereum",hdWalletIndex:d,requesterAppId:a,request:{method:"personal_sign",params:[o,c]}}),r=t.data;return s.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:c,requesterAppId:a}}),r};if(ue({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await m();ao(ie,"signMessage","onSuccess",{signature:e}),r({signature:e})}catch(e){ao(ie,"signMessage","onError",i.PrivyErrorCode.UNABLE_TO_SIGN),n(e??new Xn("Unable to sign message"))}else H({signMessage:{method:"personal_sign",data:o,confirmAndSign:m,onSuccess:e=>{ao(ie,"signMessage","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{ao(ie,"signMessage","onError",i.PrivyErrorCode.UNABLE_TO_SIGN),n(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:l.recoveryMethod,connectingWalletAddress:c,entropyId:u,entropyIdVerifier:p,onCompleteNavigateTo:$g,onFailure:e=>{ao(ie,"signMessage","onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),n(e)}}}),pe($f)})),signTypedData:(e,t)=>new Promise((async(r,n)=>{let{requesterAppId:a}=t?.uiOptions||{};if(!h||!y)return ao(ie,"signTypedData","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),void n(Error("User must be authenticated before signing with a Privy wallet"));let o=t?.address?kn(y,t.address):wn(y);if(!o)throw new i.PrivyClientError("User must have an embedded wallet to send a transaction.");let l=o.address,c=o.walletIndex??0,{entropyId:d,entropyIdVerifier:u}=Sn(y,o),p=Gt(e),m=async()=>{if(!h)throw Error("User must be authenticated before signing with a Privy wallet");let e=await bv();if(!B||!e||!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");s.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:l,requesterAppId:a}});let{response:t}=await B.rpc({accessToken:e,entropyId:d,entropyIdVerifier:u,chainType:"ethereum",hdWalletIndex:c,requesterAppId:a,request:{method:"eth_signTypedData_v4",params:[l,p]}}),r=t.data;return s.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:l,requesterAppId:a}}),r};if(ue({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await m();ao(ie,"signTypedData","onSuccess",{signature:e}),r({signature:e})}catch(e){ao(ie,"signTypedData","onError",i.PrivyErrorCode.UNABLE_TO_SIGN),n(e??new Xn("Unable to sign message"))}else H({signMessage:{method:"eth_signTypedData_v4",data:p,confirmAndSign:m,onSuccess:e=>{ao(ie,"signTypedData","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{ao(ie,"signTypedData","onError",i.PrivyErrorCode.UNABLE_TO_SIGN),n(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:$g,onFailure:e=>{ao(ie,"signMessage","onError",i.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),n(e)}}}),pe($f)})),sendTransaction:async(e,t)=>await _e({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await _e({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!h||!y)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let n=e?.address?kn(y,e.address):wn(y),l=En(y);if(!n||!l)return void r(new i.PrivyClientError("User must have an embedded wallet to send a transaction."));let c=n.address,{entropyId:d,entropyIdVerifier:u}=Sn(y,n);if(!c)return void r(Error("User does not have an HD Ethereum wallet. To export an imported wallet, pass the `address` of the wallet to `exportWallet`."));if(!a.isAddress(c))return void r(Error("Must provide a valid Ethereum address."));let p={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,entropyId:d,entropyIdVerifier:u,onCompleteNavigateTo:Lf,onFailure:r,shouldForceMFA:!0};H(q),await bv()&&B?B?(H({keyExport:{appId:o.appId,appClientId:o.clientId,origin:s.apiUrl,walletToExport:n,primaryWallet:l,onSuccess:t,onFailure:r},connectWallet:p}),pe($f)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:Ne,async init(e){switch(e){case"sms":return void await s.initMfaSmsVerification();case"passkey":return await s.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new i.PrivyClientError("Invalid MFA code");ne.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{ae.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new i.PrivyClientError("Invalid authenticator response");let r=await import("@simplewebauthn/browser"),n=(e=>({id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}))(await r.startAuthentication(t));ne.current?.resolve({mfaMethod:e,mfaCode:n,relyingParty:window.origin}),await new Promise(((e,t)=>{ae.current={resolve:e,reject:t}}));break;default:throw ne.current?.reject(new i.PrivyClientError("Unsupported MFA method")),new i.PrivyClientError(`Unsupported MFA method: ${e}`)}},cancel(){ne.current?.reject(new i.PrivyClientError("MFA canceled"))},async initEnrollmentWithSms(e){let t=await bv();if(!t||!B)throw Error("Must have valid access token to enroll in MFA");await B.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,r)=>{if(!e)return Re.closePrivyModal(),void t();$.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),H({mfaEnrollmentFlow:{mfaMethods:$.mfa.methods,shouldUnlinkOnUnenrollMfa:$.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:r}}),pe(sv)})),async initEnrollmentWithTotp(){let e=await bv();if(!e||!B)throw Error("Must have valid access token to enroll in MFA");let t=await B.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await bv();if(!t||!B)throw Error("Must have valid access token to enroll in MFA");await B.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),f(await s.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await bv();if(!t||!B)throw Error("Must have valid access token to enroll in MFA");await B.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),f(await s.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let r=await bv();if(!r||!B)throw Error("Must have valid access token to enroll in MFA");await B.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:e,removeForLogin:t.removeForLogin}),f(await s.getAuthenticatedUser())},async unenroll(e,t={}){let r=await bv();if(!r||!B)throw Error("Must have valid access token to remove MFA");"passkey"===e?await B.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:[],removeForLogin:t.removeForLogin}):await B.unenrollMfa({method:e,accessToken:r}),f(await s.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await bv(),t=y?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!B||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(!y?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");let r=await B.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===r.status&&f(await s.getAuthenticatedUser()||y||null),H({farcasterSigner:r}),pe(Ww)},getFarcasterSignerPublicKey:async()=>{let e,t=await bv(),r=y?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!B||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(!y?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!y.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=y.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await bv(),r=y?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!B||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(!y?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Re.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!y.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let n=await import("@simplewebauthn/browser"),a=await B.signFarcasterMessage({address:r.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:n.bufferToBase64URLString(e)},fid:BigInt(y.farcaster.fid),relyingParty:window.origin});return new Uint8Array(n.base64URLStringToBuffer(a.signature))},signMessageWithCrossAppWallet(e,{address:t,chainId:r}){let n=y?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return xm({user:y,client:s,address:t,requesterAppId:$.id,request:{method:n?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:r},reconnect:Ue})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:r}){let n=y?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),a=Gt(e);return xm({user:y,client:s,address:t,requesterAppId:$.id,request:{method:n?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,a],chainId:r},reconnect:Ue})},sendTransactionWithCrossAppWallet(e,{address:t}){let r=y?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return xm({user:y,client:s,address:t,requesterAppId:$.id,request:{method:r?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:Ue})},isModalOpen:c,mfaMethods:$.mfa.methods};fv=Fe.signMessage,gv=Fe.signTypedData,vv=async(e,t)=>await _e({transaction:e,...t,signOnly:!1}),wv=async(e,t)=>({signature:(await _e({transaction:e,...t,signOnly:!0})).hash});let Re={setAuthenticated:m,setUser:f,setIsNewUser:b,isNewUserThisSession:C,pendingTransaction:null,walletConnectionStatus:A,connectors:s.connectors?.walletConnectors??[],solanaWallets:v,rpcConfig:$.rpcConfig,chains:$.chains,appId:o.appId,showFiatPrices:"native-token"!==$.embeddedWallets.priceDisplay.primary,clientAnalyticsId:s.clientAnalyticsId,customAuthStatus:te,hideWalletUIs:de,isHeadlessSigning:r.useCallback(ue,[$.embeddedWallets.showWalletUIs]),emailOtpState:_,setEmailOtpState:N,smsOtpState:M,setSmsOtpState:W,oAuthState:F,setOAuthState:R,telegramAuthState:L,setTelegramAuthState:D,siweState:O,setSiweState:U,isHeadlessOAuthLoading:E,nativeTokenSymbolForChainId:e=>$.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(B)return B;let t=new Promise((e=>{Y((()=>t=>e(t)))})),r=new Promise((t=>setTimeout((()=>t(null)),e))),n=await Promise.race([t,r]);return Y(null),n},getAuthFlow:()=>s.authFlow,getAuthMeta:()=>s.authFlow?.meta,client:s,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=u&&h&&y;r&&le.current&&(t=Me(y)),"login"===ce.current?e.shouldCallAuthOnSuccess&&r&&le.current?ao(ie,"login","onComplete",{user:y,isNewUser:C,wasAlreadyAuthenticated:!1,loginMethod:le.current,loginAccount:t??null}):ao(ie,"login","onError",i.PrivyErrorCode.USER_EXITED_AUTH_FLOW):"link"===ce.current&&t?e.isSuccess&&r&&le.current?ao(ie,"linkAccount","onSuccess",{user:y,linkMethod:le.current,linkedAccount:t}):le.current&&ao(ie,"linkAccount","onError",i.PrivyErrorCode.USER_EXITED_LINK_FLOW,{linkMethod:le.current}):"update"===ce.current&&t?e.isSuccess&&r&&le.current?ao(ie,"update","onSuccess",{user:y,updateMethod:le.current,updatedAccount:t}):le.current&&ao(ie,"update","onError",i.PrivyErrorCode.USER_EXITED_UPDATE_FLOW,{linkMethod:le.current}):"connect-or-create"===ce.current&&(g[0]?ao(ie,"connectOrCreateWallet","onSuccess",{wallet:g[0]}):ao(ie,"connectOrCreateWallet","onError",i.PrivyErrorCode.USER_EXITED_AUTH_FLOW));let n=j&&bw.has(j),a=j===Es&&q.errorModalData&&bw.has(q.errorModalData.previousScreen);if((n||a)&&q.funding){let e,t=bw.get(j)??null;if("solana"===q.funding.chainType){let r=l(Fm);if(r)try{e=BigInt(await r.getBalance({address:q.funding.address,cluster:q.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");ao(ie,"fundSolanaWallet","onUserExited",{address:q.funding.address,cluster:q.funding.cluster,fundingMethod:t,balance:e})}else{let r=Ut(q.funding.chain.id,$.chains,$.rpcConfig,{appId:o.appId});try{e=await r.getBalance({address:q.funding.address})}catch{console.error("Unable to pull wallet balance")}ao(ie,"fundWallet","onUserExited",{address:q.funding.address,chain:q.funding.chain,fundingMethod:t,balance:e})}}H({...q,externalConnectWallet:{suggestedAddress:void 0}}),ce.current=null,le.current=null,b(!1),d(!1),setTimeout((()=>{s.authFlow=void 0}),200)},openPrivyModal:pe,connectWallet:ge,initLoginWithWallet:async(e,t,r)=>{ea(e)?(le.current="siwe",we(e,t,r)):(le.current="siws",ve(e,t,r))},loginWithWallet:async()=>{let e,t,r;if(!u)throw new i.PrivyNotReadyError;if(s.authFlow instanceof tn?e="siwe":s.authFlow instanceof rn&&(e="siws"),!e)throw new i.PrivyClientError("Must initialize SIWE/SIWS flow first.");if(null!==await s.getAccessToken())try{({user:t}=await s.link()),le.current=e}catch(t){throw ao(ie,"linkAccount","onError",t.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:r}=await s.authenticate()),le.current=e}catch(e){throw ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR),e}f(t||y||null),b(r||!1),m(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:r})=>new Promise((async(n,a)=>{let o=await bv();if(!h||!y||!o)throw new i.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new i.PrivyClientError("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let s=Re.walletProxy??await Re.initializeWalletProxy(15e3);if(!s)throw new i.PrivyClientError("Wallet proxy not initialized.");if((({address:e,chainType:t,user:r})=>!!cm(r).find((r=>r.address===e&&r.chainType===t)))({address:e,chainType:t,user:y}))return n();let l=(({address:e,user:t})=>{let r=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!r)throw new i.PrivyClientError("Address to delegate is not associated with current user.");return{address:r.address,chainType:r.chainType,walletIndex:r.walletIndex??0}})({address:e,user:y}),c=(({address:e,user:t})=>{let r=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!r)throw new i.PrivyClientError("Address to delegate is not associated with current user.");let n=r.imported?r:En(t);if(!n)throw new i.PrivyClientError("Unable to determine root address for delegated address.");return{address:n.address,chainType:n.chainType,imported:n.imported}})({address:e,user:y}),d=async()=>{await s.createDelegatedAction({accessToken:o,rootWallet:c,delegatedWallets:[l]}),await Re.refreshSessionAndUser()};if(await Re.recoverPrimaryWallet(),r)H({delegatedActions:{consent:{address:e,onDelegate:d,onSuccess:async()=>{n()},onError:async e=>{a(e)}}}}),pe(Iw);else try{await d(),n()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,r)=>{if(!h||!y)throw new i.PrivyClientError("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");if(0===cm(y).length)throw new i.PrivyClientError("User has no delegated wallets to revoke.");let n=async()=>{await s.revokeDelegatedWallet(),await Re.refreshSessionAndUser()};if(e)H({delegatedActions:{revoke:{onRevoke:n,onSuccess:async()=>{t()},onError:async e=>{r(e)}}}}),pe(_w);else try{await n(),t()}catch(e){r(e)}})),initLoginWithFarcaster:async(e,t)=>{let r=new ar(e,t);s.startAuthFlow(r);try{le.current="farcaster",await r.initializeFarcasterConnect()}catch(e){throw"login"===ce.current?ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===ce.current&&ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!u)throw new i.PrivyNotReadyError;if(!(s.authFlow instanceof ar))throw new i.PrivyClientError("Must initialize Farcaster flow first.");if(null!==await s.getAccessToken())try{({user:e}=await s.link()),le.current="farcaster"}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await s.authenticate()),le.current="farcaster"}catch(e){throw ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}f(e||null),b(t||!1),m(!0)},async crossAppAuthFlow({appId:e,popup:t,action:r}){let n=`privy:${e}`;le.current=n;let{url:a,stateCode:o,codeVerifier:l}=await async function({api:e,appId:t}){let r=Wr(),n=Or(),a=await Ur(r);try{let{url:o}=await e.post(i.oAuthInitPath,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:n});return{url:o,stateCode:n,codeVerifier:r}}catch(e){throw i.formatApiError(e)}}({api:s.api,appId:e});if(!a)throw s.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new i.PrivyClientError("No authorization URL returned for cross-app auth.");try{let c=await async function({url:e,popup:t}){return t.location=e,new Promise(((e,r)=>{let n,a=setTimeout((()=>{r(new i.PrivyClientError("Authorization request timed out after 2 minutes.")),o()}),12e4);function o(){t?.close(),window.removeEventListener("message",l)}let s=setInterval((()=>{t?.closed&&!n&&(o(),clearInterval(s),clearTimeout(a),r(new i.PrivyClientError("User rejected request")))}),300);function l(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(a),e(t.data),o()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(a),r(new i.PrivyClientError(t.data.error)),o()),t.data.type===ym&&((n=new BroadcastChannel(mm)).onmessage=l))}window.addEventListener("message",l)}))}({url:a,popup:t,provider:n}),d=c.stateCode,u=c.authorizationCode;if(d!==o)throw s.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:n,storedStateCode:o??"",returnedStateCode:d??""}}),new i.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,i.PrivyErrorCode.OAUTH_UNEXPECTED);let p=await async function({appId:e,stateCode:t,codeVerifier:r,authorizationCode:n,action:a,client:o}){if(!n||!t)throw new i.PrivyClientError("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===n)throw new i.PrivyClientError("User denied confirmation during cross-app auth flow");try{let i=new fm({authorizationCode:n,stateCode:t,codeVerifier:r,provider:`privy:${e}`});o.startAuthFlow(i);let s="link"===a?await o.link():await o.authenticate(),l=s.oAuthTokens?.accessToken;return console.debug(),l}catch(e){let t=i.formatApiError(e);if(t.privyErrorCode)throw new i.PrivyClientError(t.message||"Invalid code during cross-app auth flow.",void 0,t.privyErrorCode);if("User denied confirmation during cross-app auth flow"===t.message)throw new i.PrivyClientError("Invalid code during cross-app auth flow.",void 0,i.PrivyErrorCode.OAUTH_USER_DENIED);throw new i.PrivyClientError("Invalid code during cross-app auth flow.",void 0,i.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:l,stateCode:d,authorizationCode:u,action:r,client:s});p&&s.storeProviderAccessToken(e,p);let h=await Re.refreshSessionAndUser();if(!h)throw new i.PrivyClientError("Unable to update user");return s.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),h}catch(e){throw s.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:n}}),e}},async initLoginWithOAuth(e,t,r){if(le.current=e,!_t())return void pe(Fw);if("google"===e&&Qi(window.navigator.userAgent))return void pe(Fw);"twitter"===e&&window.opener&&window.opener.postMessage({type:ym},"*"),Nt.del(br),Nt.del(jr);let a=new Fr({provider:e,disableSignup:!!r,withPrivyUi:!0});t&&a.addCaptchaToken(t),s.startAuthFlow(a);let i=await s.authFlow.getAuthorizationUrl();i&&i.url&&("twitter"===e&&n.isAndroid&&(i.url=i.url.replace("x.com","twitter.com")),window.location.assign(i.url))},async initLoginWithTelegram(e,t){if(!u)throw new i.PrivyNotReadyError;le.current="telegram";let r=new dn(e,t);s.startAuthFlow(r),D({status:"loading"}),r.meta.telegramWebAppData=void 0,r.meta.telegramAuthResult=await new Promise(((e,t)=>$.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:$.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(r=>r?e(r):t(new i.PrivyClientError("Telegram auth failed or was canceled by the client")))):t(new i.PrivyClientError("Telegram was not initialized")):t(new i.PrivyClientError("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,r;if(!(s.authFlow instanceof dn))throw new i.PrivyClientError("Must initialize Telegram flow before calling loginWithTelegram");s.authFlow.meta.captchaToken||=e?.captchaToken;let n=await bv(),a=e?.intent||ce.current;if("login"===a)try{let e=await s.authenticate();t=e.user,r=e.isNewUser,le.current="telegram"}catch(e){throw ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}else{if("link"!==a)throw new i.PrivyClientError("Unknown auth intent");try{t=(await s.link()).user,le.current="telegram"}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}f(t),b(r||!1),m(!0),D({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:o}},async recoveryOAuthFlow(e,t,r){let n,a;function o(t){if(!t)throw s.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:e}}),new i.PrivyClientError("Recovery OAuth failed")}switch(e){case"google-drive":{let t,l,{url:c,codeVerifier:d,stateCode:u}=await pc({api:yv.api,provider:e});o(c);try{let n=await jw({url:c,popup:r,provider:e});if(t=n.stateCode,l=n.authorizationCode,t!==u)throw s.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:u??"",returnedStateCode:t??""}}),new i.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,i.PrivyErrorCode.OAUTH_UNEXPECTED)}catch(t){throw s.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:e}}),new i.PrivyClientError("Recovery OAuth failed")}[n,a]=await Promise.all([bv(),hc({api:yv.api,provider:e,codeVerifier:d,stateCode:t,authorizationCode:l})]);break}case"icloud":{let{url:t}=await pc({api:yv.api,provider:e});o(t);let{ckWebAuthToken:i}=await jw({url:t,popup:r,provider:e});a=i,n=await bv()}}if(!B)throw new i.PrivyClientError("Cannot connect to wallet proxy");if(!n)throw new i.PrivyClientError("Unable to authorize user");switch(t){case"recover":{let t=q.recoverWallet?.entropyId,r=q.recoverWallet?.entropyIdVerifier;if(!t||!r)throw new i.PrivyClientError("Recovery OAuth failed");s.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t,recoveryMethod:e}}),await B.recover({accessToken:n,entropyId:t,entropyIdVerifier:r,recoveryAccessToken:a}),s.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t,recoveryMethod:e}});break}case"create-wallet":{s.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await B.create({accessToken:n,recoveryAccessToken:a,recoveryMethod:e});let t=wn(await Re.refreshSessionAndUser());if(!t)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");s.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.address}}),ao(ie,"createWallet","onSuccess",{wallet:t});break}case"set-recovery":{let t=En(y);if(!t)throw ao(ie,"setWalletRecovery","onError",i.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");s.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}});let{entropyId:r,entropyIdVerifier:o}=Sn(y);await B.setRecovery({accessToken:n,entropyId:r,entropyIdVerifier:o,recoveryMethod:e,recoveryAccessToken:a});let l=En(await Re.refreshSessionAndUser());if(!l)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");s.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}}),ao(ie,"setWalletRecovery","onSuccess",{method:e,wallet:l});break}default:throw new i.PrivyClientError("Unsupported recovery action")}},async loginWithOAuth(e){let t,r,n;if(!(s.authFlow instanceof Fr))throw new i.PrivyClientError("Must initialize OAuth flow before calling loginWithOAuth");let a=Nt.get(xr),o=s.authFlow.meta.stateCode;if(a!==o)throw s.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:a??"",returnedStateCode:o??""}}),new i.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,i.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await s.getAccessToken())try{let r=await s.link();t=r.user,n=r.oAuthTokens,le.current=e}catch(t){throw ao(ie,"linkAccount","onError",t.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let a=await s.authenticate();t=a.user,r=a.isNewUser,n=a.oAuthTokens,le.current=e}catch(t){throw"login"===ce.current?ao(ie,"login","onError",t.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===ce.current&&ao(ie,"linkAccount","onError",t.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return f(t),b(r||!1),m(!0),n&&t&&ao(ie,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),n},passkeyAuthState:S,setPasskeyAuthState:P,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new Qr({captchaToken:e,setPasskeyAuthState:P});s.startAuthFlow(r),ce.current="login";try{le.current="passkey",P({status:"generating-challenge"}),await r.initRegisterFlow(t),P({status:"awaiting-passkey"})}catch(e){throw P({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!u)throw new i.PrivyNotReadyError;if(!(s.authFlow instanceof Qr))throw new i.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==le.current){let e=new i.PrivyClientError("Must init login with Passkey flow first.");throw P({status:"error",error:e}),e}let r=await bv();try{le.current="passkey",P({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await s.authenticate())}catch(e){throw P({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}f(e),b(t||!1),m(!0),P({status:"done"});let n=e?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:e,isNewUser:t||!1,wasAlreadyAuthenticated:!!r,loginAccount:n}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new Qr({captchaToken:e,setPasskeyAuthState:P});s.startAuthFlow(r),ce.current="login";try{le.current="passkey",P({status:"generating-challenge"}),await r.initAuthenticationFlow(t),P({status:"awaiting-passkey"})}catch(e){throw P({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,r;if(!u)throw new i.PrivyNotReadyError;if(!(s.authFlow instanceof Qr))throw new i.PrivyClientError("Must initialize Passkey flow first.");if(e?.credentialIds&&(s.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==le.current){let e=new i.PrivyClientError("Must init login with Passkey flow first.");throw P({status:"error",error:e}),e}let n=await bv();try{le.current="passkey",P({status:"awaiting-passkey"}),({user:t,isNewUser:r}=await s.authenticate())}catch(e){throw P({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}f(t),b(r||!1),m(!0),P({status:"done"});let a=t?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:a}},async initLinkWithPasskey(e){let t=new Qr({captchaToken:e});s.startAuthFlow(t),ce.current="link",le.current="passkey",P({status:"generating-challenge"});try{await t.initLinkFlow(),P({status:"awaiting-passkey"})}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),P({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!u)throw new i.PrivyNotReadyError;if(!(s.authFlow instanceof Qr))throw new i.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==le.current)throw new i.PrivyClientError("Must init login with Passkey flow first.");try{le.current="passkey",({user:e}=await s.link())}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return f(e||y||null),P({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,r){if(!_t())throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");if("google"===e&&Qi(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let n=new Fr({provider:e,withPrivyUi:!1,disableSignup:r??!1});t&&n.addCaptchaToken(t),R({status:"loading"});let a=await s.startAuthFlow(n).getAuthorizationUrl();a?.url&&window.location.assign(a.url)},async loginWithHeadlessOAuth(e){let t,r,n;T(!0),R({status:"loading"}),s.startAuthFlow(new Fr(e));let a=Nt.get(xr),o=e.stateCode;if(a!==o)throw s.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:a??"",returnedStateCode:o??""}}),T(!1),new i.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,i.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await s.getAccessToken())try{({user:t,oAuthTokens:n}=await s.link()),le.current=e.provider;let r=Me(t);t&&r&&ao(ie,"linkAccount","onSuccess",{user:t,linkMethod:le.current,linkedAccount:r})}catch(t){throw T(!1),ao(ie,"linkAccount","onError",t.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:r,oAuthTokens:n}=await s.authenticate()),le.current=e.provider;let a=Me(t);t&&a&&void 0!==r&&ao(ie,"login","onComplete",{user:t,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:le.current,loginAccount:a})}catch(e){throw T(!1),R({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}return f(t),b(r||!1),m(!0),T(!1),R({status:"done"}),n&&t&&ao(ie,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{let a=new It({email:e,captchaToken:t,disableSignup:r});s.startAuthFlow(a);try{le.current="email",N({status:"sending-code"}),await a.sendCodeEmail({withPrivyUi:n}),N({status:"awaiting-code-input"})}catch(e){throw N({status:"error",error:e}),"login"===ce.current?ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===ce.current&&ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,r)=>{let n=new St(e,t,r);s.startAuthFlow(n);try{await n.sendCodeEmail({withPrivyUi:!0})}catch(e){ao(ie,"update","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:le.current})}},initUpdatePhone:async(e,t,r)=>{let n=new an(e,t,r);s.startAuthFlow(n);try{await n.sendSmsCode({withPrivyUi:!0})}catch(e){ao(ie,"update","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:le.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{W({status:"sending-code"});let a=new nn({phoneNumber:e,captchaToken:t,disableSignup:r});s.startAuthFlow(a);try{le.current="sms",await a.sendSmsCode({withPrivyUi:n}),W({status:"awaiting-code-input"})}catch(e){throw W({status:"error",error:e}),"login"===ce.current?ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===ce.current&&ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await(s.authFlow?.sendCodeEmail({withPrivyUi:!0}))},resendSmsCode:async()=>{await(s.authFlow?.sendSmsCode({withPrivyUi:!0}))},loginWithCode:async e=>{let t,r;function n(e){s.authFlow instanceof It?N(e):s.authFlow instanceof nn&&W(e)}if(n({status:"submitting-code"}),!u){let e=new i.PrivyNotReadyError;throw n({status:"error",error:e}),e}if(s.authFlow instanceof It)s.authFlow.meta.emailCode=e.trim();else{if(!(s.authFlow instanceof nn)){let e=new i.PrivyClientError("Must initialize a passwordless code flow first");throw n({status:"error",error:e}),e}s.authFlow.meta.smsCode=e.trim()}let a=await bv();if("link"===ce.current)try{({user:t}=await s.link())}catch(e){throw n({status:"error",error:e}),ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:le.current}),e}else if("update"===ce.current)try{({user:t}=await s.link())}catch(e){throw n({status:"error",error:e}),ao(ie,"update","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:le.current}),e}else try{({user:t,isNewUser:r}=await s.authenticate())}catch(e){throw n({status:"error",error:e}),ao(ie,"login","onError",e.privyErrorCode||i.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}let o=t||y;f(o||null),b(r||!1),m(!0),n({status:"done"});let l=null;return s.authFlow instanceof It?l=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:s.authFlow instanceof nn&&(l=o?.linkedAccounts.find((({type:e})=>"phone"===e))||null),{user:o,isNewUser:r||!1,wasAlreadyAuthenticated:!!a,linkedAccount:l}},generateSiweMessage:async({address:e,chainId:t,captchaToken:r})=>{ce.current="link",le.current="siwe",U({status:"generating-message"});let n=await s.generateSiweNonce({address:e,captchaToken:r});return U({status:"awaiting-signature"}),en({address:e,chainId:t.replace("eip155:",""),nonce:n})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let r=await s.generateSiweNonce({address:e});return en({address:e,chainId:t.replace("eip155:",""),nonce:r})},linkSmartWallet:async({message:e,signature:t,smartWalletType:r})=>{let n;n=await s.linkSmartWallet({message:e,signature:t,smartWalletType:r}),f((n=await Re.refreshSessionAndUser()??n)||y||null)},linkWithSiwe:async({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a})=>{let o;Ce("siwe");let l=null;try{U({status:"submitting-signature"}),o=await s.linkWithSiwe({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a}),o=await Re.refreshSessionAndUser()??o,U({status:"done"}),(l=Me(o)||null)&&ao(ie,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:l})}catch(e){throw ao(ie,"linkAccount","onError",e.privyErrorCode||i.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),ce.current=null,le.current=null,U({status:"error",error:e}),e}let c=o||y;return f(c||null),ce.current=null,le.current=null,{user:c,linkedAccount:l}},refreshSessionAndUser:async()=>{let e=await s.getAuthenticatedUser();return m(!!e),f(e),e},walletProxy:B,createAnalyticsEvent:({eventName:e,payload:t,timestamp:r})=>s.createAnalyticsEvent({eventName:e,payload:t,timestamp:r}),acceptTerms:async()=>{let e=await s.acceptTerms();return f(e),e},getUsdTokenPrice:e=>s.getUsdTokenPrice(e),getUsdPriceForSol:()=>s.getUsdPriceForSol(),getSplTokenMetadata:e=>s.getSplTokenMetadata(e),recoverPrimaryWallet:async e=>new Promise((async(t,r)=>{if(!y)return void t(!0);let n=An(e?.user??y),a=En(e?.user??y)||bn(e?.user??y)||jn(e?.user??y);if(!n&&!a)return void t(!0);let i=await bv();if(!i||!B||!a)return void r(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:o,entropyIdVerifier:l}=Sn(y,a);try{await B.connect({accessToken:i,entropyId:o,entropyIdVerifier:l}),t(!0)}catch(e){ds(e)&&"privy"===a.recoveryMethod?(s.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:a.address}}),(await B.recover({entropyId:o,entropyIdVerifier:l,accessToken:i})).entropyId||r(Error("Unable to recover wallet")),s.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:a.address}}),t(!0)):ds(e)&&"privy"!==a.recoveryMethod?(H({recoverWallet:{entropyId:o,entropyIdVerifier:l,onFailure:r,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:a.recoveryMethod,action:"recover"}}),pe(uc(a.recoveryMethod))):r(e)}})),createEmbeddedSolanaWallet:async e=>{e&&"target"in e&&(e=void 0);let t=await Re.refreshSessionAndUser();if(!t)throw ao(ie,"createWallet","onError",i.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return Te(t,15e3,e)},exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!h||!y)return void r(Error("User must be authenticated before exporting their Privy wallet"));let n=e?.address?kn(y,e.address):Cn(y),a=En(y);if(!n||!a)return void r(Error("Must have a Privy wallet before exporting"));let{entropyId:i,entropyIdVerifier:l}=Sn(y,n);await bv()&&B?B?(H({connectWallet:{recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,entropyId:i,entropyIdVerifier:l,onCompleteNavigateTo:Lf,onFailure:r,shouldForceMFA:!0},keyExport:{appId:o.appId,appClientId:o.clientId,origin:s.apiUrl,walletToExport:n,primaryWallet:a,onSuccess:t,onFailure:r}}),pe($f)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),setReadyToTrue:e=>{p(!0),K?.(e)},updateWallets:()=>ke(),fundWallet:async(e,t)=>{H({funding:Wf({address:e,appConfig:$,fundWalletConfig:t,methodScreen:If})}),pe(If)},openModal:pe,requestFarcasterSignerStatus:async e=>{let t=await bv(),r=y?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!B||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(!y?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let n=await s.requestFarcasterSignerStatus(e);return"approved"===n.status&&f(await s.getAuthenticatedUser()||y||null),n},connectCoinbaseSmartWallet:async()=>{$.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let e=s.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||s.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),ge(e);await fe("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:l})=>{let c=await s.sendAccountTransferRequest({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:l});return f(c),c}};xv=Re.recoverPrimaryWallet,Cv=Re.recoverPrimaryWallet;let Le=r.useMemo((()=>({wallets:g,ready:J&&oe})),[g,J,oe]),De=s.authFlow instanceof dn,Be=!$.headless&&$.captchaEnabled&&!h&&(u||De);/*#__PURE__*/return e.jsx($o.Provider,{value:Fe,children:/*#__PURE__*/e.jsx(to.Provider,{value:ie,children:/*#__PURE__*/e.jsx(_h.Provider,{value:Le,children:/*#__PURE__*/e.jsx(ln,{...$,children:/*#__PURE__*/e.jsxs(i.InternalPrivyContext.Provider,{value:Re,children:[/*#__PURE__*/e.jsx(so,{children:/*#__PURE__*/e.jsxs(Xu,{data:q,setModalData:H,setInitialScreen:k,initialScreen:j,authenticated:h,open:c,children:[o.children,Be&&/*#__PURE__*/e.jsx(wp,{delayedExecution:!1}),/*#__PURE__*/e.jsx(Dh,{theme:{...$.appearance.palette||{}}}),!$.render.standalone&&/*#__PURE__*/e.jsx(Yh,{open:c})]})}),/*#__PURE__*/e.jsx(lm,{appId:o.appId,appClientId:o.clientId,clientAnalyticsId:s.clientAnalyticsId,origin:s.apiUrl,mfaMethods:y?.mfaMethods,mfaPromise:ne,mfaSubmitPromise:ae,onLoad:z,onLoadFailed:()=>null}),$.loginConfig.telegramAuthConfiguration&&
26
26
  /*#__PURE__*/e.jsx(Vi,{$if:!0,children:/*#__PURE__*/e.jsx(Qh,{scriptHost:o.apiUrl||ir,botUsername:$.loginConfig.telegramAuthConfiguration.botName})})]})})})})})};exports.Address=Mi,exports.BlobbyFooter=yi,exports.ButtonLoader=fo,exports.Captcha=wp,exports.CaptchaError=sn,exports.Column=Em,exports.ConnectorManager=tp,exports.Copy=Vc,exports.DEFAULT_SUCCESS_SCREEN_DURATION_MS=or,exports.DEFAULT_SUPPORTED_CHAINS=Hn,exports.EmailUpdateForm=du,exports.EmbeddedWalletConnectingScreen=$f,exports.EthereumWalletConnector=oa,exports.FundingMethodSelectionScreen=If,exports.GuestFlow=sp,exports.LoginModal=Yh,exports.NetworkIcon=py,exports.PrimaryButton=vo,exports.PrivyClient=fp,exports.PrivyContext=$o,exports.PrivyProvider=({config:t,...r})=>{var n;if("undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new i.PrivyClientError("Embedded wallet is only available over HTTPS");if("string"!=typeof(n=r.appId)||25!==n.length)throw new i.PrivyClientError("Cannot initialize the Privy provider with an invalid Privy app ID");yv||(yv=new fp({appId:r.appId,appClientId:r.clientId,apiUrl:r.apiUrl}));let a=Object.assign({},t);/*#__PURE__*/
27
27
  return e.jsx(ci,{client:yv,clientConfig:a,children:/*#__PURE__*/e.jsx(Om,{children:/*#__PURE__*/e.jsx(Sv,{...r,client:yv})})})},exports.QrCode=nd,exports.Row=oy,exports.Rows=iy,exports.SOLANA_FUNDING_PLUGIN_ID=Fm,exports.SendTransactionScreen=vw,exports.SignRequestScreen=$g,exports.SolanaWalletConnector=Ra,exports.Subtitle=oc,exports.Title=sc,exports.VERSION=cr,exports.WALLET_PROXY_TIMEOUT=Ir,exports.WalletCards=Jm,exports.WalletConnect=({style:t,...r})=>{let{app:n}=Qu();/*#__PURE__*/return e.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",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"28",height:"28",rx:"3",fill:"dark"===n?.appearance.palette.colorScheme?"#3396ff":"#141414"}),/*#__PURE__*/e.jsx("g",{clipPath:"url(#clip0_1765_9946)",children:/*#__PURE__*/e.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"})}),/*#__PURE__*/e.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0_1765_9946",children:/*#__PURE__*/e.jsx("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})},exports.WalletConnector=ra,exports.WalletInfoCard=Sm,exports.WalletLoading=Iu,exports.addPrivyRpcToChain=Ja,exports.addRpcUrlOverrideToChain=function(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}},exports.detectCompletingOAuthFlow=Jr,exports.errorIndicatesMaxMfaRetries=hs,exports.errorIndicatesMfaTimeout=us,exports.errorIndicatesMfaVerificationFailed=ps,exports.extractChainIdFromCAIP2=hm,exports.formatErc20TokenAmount=wy,exports.formatWalletAddress=Lt,exports.getCustomerAccessToken=function(){return yv?yv.getCustomerAccessToken():Promise.resolve(Nt.get(dr)||null)},exports.getEntropyDetailsForUser=Sn,exports.getErc20Balance=Nm,exports.getErc20TokenInfo=Xm,exports.getJsonRpcEndpointFromChain=Ft,exports.getNativeCurrencyFromWei=Up,exports.getPrivyEthereumWallet=wn,exports.importWallet=Rm,exports.isBaseConnectedEthereumWallet=ea,exports.isBaseConnectedSolanaWallet=Fa,exports.prepareSolanaFundingModalData=Of,exports.s=Nt,exports.shouldCreateEmbeddedEthWallet=qo,exports.shouldCreateEmbeddedSolWallet=Ko,exports.signOrSendSolanaTransactionInternal=Mg,exports.stripUrlOAuthParamsAndRemoveStateCode=Xr,exports.useAppConfig=di,exports.useCaptcha=cn,exports.useElementHeight=vp,exports.useEmitPrivyEvent=io,exports.useExternalWalletState=Da,exports.useIdentityToken=function(){let{identityToken:e}=cp();return{identityToken:e}},exports.useImportWallet=zm,exports.useIsServerConfigLoaded=ui,exports.useLogout=Ew,exports.useMfa=Uh,exports.useMfaEnrollment=Vw,exports.usePrivy=$m,exports.usePrivyContext=Vo,exports.usePrivyEventSubscription=no,exports.usePrivyModal=Qu,exports.useRecentlyUsedLogin=po,exports.useRegisterMfaListener=xp,exports.useRegisterPlugin=(...e)=>{let{plugins:t}=r.useContext(Wm);r.useEffect((()=>{for(let r of e)t.current[r.id]=r;return()=>{for(let r of e)delete t.current[r.id]}}),[t])},exports.useSendTransaction=Wg,exports.useSignMessage=Zg,exports.useSolanaWallets=Gg,exports.useWalletBalance=Pm,exports.useWallets=Nh;