PageSourceSearch

https://pancakeswap.finance/_next/static/chunks/8514-e2e6e4b7deb4fae5.js

js pancakeswap.finance collected 2026-09-24 08:43:30 UTC 21,826 bytes, 1 lines download raw bytes

1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="49ff366f-7b74-40ad-94f1-c354b2a77342",e._sentryDebugIdIdentifier="sentry-dbid-49ff366f-7b74-40ad-94f1-c354b2a77342")}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8514],{776133:(e,t,n)=>{n.d(t,{Mi:()=>Z,lF:()=>X,t7:()=>q});var r=n(968349),a=n(105493),l=n(25963),o=n(228876),i=n(381725),s=n(486200),c=n(21684),u=n(999523),d=n(350979),f=n(398805),h=n(326848),g=n(889810),w=n(225572),v=n(39076),p=n(341305),m=n(318050),y=n(993445),E=n(936800),C=n(763105),b=n(17581),I=n(539502),T=n(118708),S=n(656862),k=n(654882),_=n(862373),W=n(765853),A=n(807094),F=n(985148),L=n(179087),x=n(367142),R=n(272235),P=n(924627),D=n(916626),O=(0,i.Wp)({apiKey:"AIzaSyBdSzdwgfy2-YHslDoArmorEZ8LscJEsGw",authDomain:"pancakeswap-prod-firebase.firebaseapp.com",projectId:"pancakeswap-prod-firebase",storageBucket:"pancakeswap-prod-firebase.firebasestorage.app",messagingSenderId:"901250967709",appId:"1:901250967709:web:f6861f05b9bb294ce2cc74"});async function U(e){var t,n;await new Promise((e,t)=>{var n,r;if(null==(r=window.Telegram)||null==(n=r.Login)?void 0:n.auth)return void e();let a=document.createElement("script");a.src="https://telegram.org/js/telegram-widget.js?7",a.async=!0,a.onload=()=>e(),a.onerror=t,document.body.appendChild(a)}),(null==(n=window.Telegram)||null==(t=n.Login)?void 0:t.auth)&&window.Telegram.Login.auth({bot_id:"8152068602",request_access:!0,lang:"en"},async t=>{if(!t)return void alert("Login failed or cancelled.");try{let n=await fetch("/api/auth/telegram-callback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json();r.customToken?e(r.customToken):alert("fail to login")}catch(e){console.error("Telegram login failed:",e)}})}o.Cb.SOLANA,o.Cb.APTOS;var N=(0,l.createContext)(void 0);function j(e){let{children:t}=e,[n,a]=(0,l.useState)(!1),[o,i]=(0,l.useState)(),f=(0,l.useRef)(o),[,h]=(0,r.R2)(),[,g]=(0,r.kB)(),w=(0,l.useCallback)(e=>{f.current=e,i(e)},[]),v=async()=>{try{let e=(0,s.xI)(O),t=new s.HF;return await (0,s.df)(e,t)}catch(e){if((null==e?void 0:e.code)==="auth/cancelled-popup-request"||(null==e?void 0:e.code)==="auth/popup-closed-by-user")throw console.info("Google login popup was cancelled by user"),Error("LOGIN_CANCELLED");throw console.error("Google login error:",e),alert(`Google login failed: ${(null==e?void 0:e.message)||e}`),e}},p=async()=>{try{let e=(0,s.xI)(O),t=new s.ny;return await (0,s.df)(e,t)}catch(e){if((null==e?void 0:e.code)==="auth/cancelled-popup-request"||(null==e?void 0:e.code)==="auth/popup-closed-by-user")throw console.info("X login popup was cancelled by user"),Error("LOGIN_CANCELLED");throw console.error("X login error:",e),alert(`X login failed: ${(null==e?void 0:e.message)||e}`),e}},m=(0,l.useCallback)(async()=>{try{h(!0),g("google"),a(!0);let e=await v();if(!(0,r.Vn)(e.user))throw Error("GOOGLE_EMAIL_NOT_VERIFIED");let t=await e.user.getIdToken(!0);w(t)}catch(e){if((null==e?void 0:e.message)==="LOGIN_CANCELLED"){console.info("Google login was cancelled by user"),h(!1),g(null);return}if((null==e?void 0:e.message)==="GOOGLE_EMAIL_NOT_VERIFIED"){console.error("Google login failed: verified email is required"),h(!1),g(null);return}console.error("Google login error:",e)}finally{a(!1)}},[h,g,w]),y=(0,l.useCallback)(async()=>{try{h(!0),g("x"),a(!0);let e=await p();if(!(0,r.Vn)(e.user))throw Error("X_EMAIL_NOT_VERIFIED");let t=await e.user.getIdToken(!0);w(t)}catch(e){if((null==e?void 0:e.message)==="LOGIN_CANCELLED"){console.info("X login was cancelled by user"),h(!1),g(null);return}if((null==e?void 0:e.message)==="X_EMAIL_NOT_VERIFIED"){console.error("X login failed: verified email is required"),h(!1),g(null);return}console.error("X login error:",e)}finally{a(!1)}},[h,g,w]),E=(0,l.useCallback)(async e=>{try{h(!0);let t=(0,s.xI)(O),n=await (0,s.p)(t,e),r=await n.user.getIdToken(!0);return w(r),!0}catch(e){return console.error("Error signing in with custom token:",e),!1}},[h,w]),C=(0,l.useCallback)(async()=>{try{h(!0),a(!0),g("discord");let e=(0,c.Ak)(21);u.A.set("discordAuthState",e,{sameSite:"Lax",secure:"https:"===window.location.protocol,path:"/"});let t=window.location.pathname+window.location.search+window.location.hash;localStorage.setItem("discordAuthFrom",t);let n=`${window.location.origin}/auth/discord`;window.location.href=`https://discord.com/api/oauth2/authorize?client_id=1391264935379468338&redirect_uri=${encodeURIComponent(n)}&response_type=code&scope=identify%20email&state=${e}`}catch(e){console.error(e)}finally{a(!1)}},[h,g]),b=(0,l.useCallback)(async()=>{try{h(!0),g("telegram"),a(!0),U(e=>{E(e)})}catch(e){console.error(e)}finally{a(!1)}},[E,h,g]),I=(0,l.useCallback)(async()=>
1{if(f.current)return f.current;let e=(0,s.xI)(O);if(!e.currentUser)return;let t=await e.currentUser.getIdToken(!0);return w(t),t},[w]);(0,l.useEffect)(()=>{let e=(0,s.xI)(O),t=e.onAuthStateChanged(async e=>{if(console.info("Firebase auth state changed, user:",e?"exists":"null"),e)try{let t=await e.getIdToken(!0);w(t),console.info("Token set from Firebase auth state change")}catch(e){console.error("Failed to get token on auth state change:",e)}else w(void 0),console.info("Firebase user signed out, token cleared");a(!1)}),n=e.onIdTokenChanged(e=>{console.info("Firebase token changed, user:",e?"exists":"null")}),r=e=>{let{token:t}=e.detail;console.info("Received Firebase retrigger event, updating token..."),w(void 0),setTimeout(()=>{w(t),console.info("Token updated for Privy re-authentication")},100)};return window.addEventListener("firebase-auth-retrigger",r),()=>{t(),n(),window.removeEventListener("firebase-auth-retrigger",r)}},[w]);let T=(0,l.useCallback)(async()=>{let e=(0,s.xI)(O);try{await (0,s.CI)(e)}catch(e){console.error(e)}},[]),S=(0,l.useCallback)(async()=>{await T(),w(void 0),a(!1),g(null)},[g,T,w]),k=(0,l.useMemo)(()=>({token:o,isLoading:n,getToken:I,loginWithGoogle:m,loginWithX:y,loginWithDiscord:C,loginWithTelegram:b,loginWithCustomToken:E,signOutAndClearUserStates:S}),[I,n,C,m,E,b,y,S,o]);return(0,d.jsx)(N.Provider,{value:k,children:t})}function q(){let e=(0,l.useContext)(N);if(void 0===e)throw Error("useFirebaseAuth must be used within an FirebaseAuthProvider");return e}async function M(){try{let{currentUser:e}=(0,s.xI)(O);if(!e)return!1;console.info("Current Firebase user exists, retriggering token...");let t=await e.getIdToken(!0),n=new CustomEvent("firebase-auth-retrigger",{detail:{token:t}});return window.dispatchEvent(n),await new Promise(e=>setTimeout(e,500)),!0}catch(e){return console.error("Failed to retrigger Firebase auth:",e),!1}}var G=class extends f.EventEmitter{async request(e){var t,n,a,l,o;let{method:i,params:s=[]}=e;switch(i){case"eth_requestAccounts":case"eth_accounts":return this.handleEthRequestAccounts();case"eth_sendTransaction":return this.handleEthSendTransaction(s);case"personal_sign":return this.handlePersonalSign(s);case"eth_signTypedData":case"eth_signTypedData_v4":return this.handleEthSignTypedDataV4(s);case"eth_signTransaction":throw Error("eth_signTransaction is not supported. Use eth_sendTransaction instead.");case"wallet_switchEthereumChain":try{let e=null==s||null==(t=s[0])?void 0:t.chainId;if(!e)throw new r.kU(void 0,"Invalid or missing chainId");let a=parseInt(e,16);if(!(null==(n=this.smartWalletClient)?void 0:n.account))throw new r.kU(a,"Account not connected!");let l=await this.getClientForChain({id:a});if(!l)throw new r.kU(a,`No smart wallet client found for chain ID ${a}`);return this.smartWalletClient=l,this.emit("chainChanged",e),null}catch(t){if(t instanceof r.kU)throw Error(t.message);let e=parseInt(null==s||null==(a=s[0])?void 0:a.chainId,16);throw new r.kU(e,null!=(l=null==t?void 0:t.message)?l:"Failed to switch chain")}default:return null==(o=this.smartWalletClient)?void 0:o.transport.request({method:i,params:s})}}async handleEthRequestAccounts(){var e;return(null==(e=this.smartWalletClient)?void 0:e.account)?[this.smartWalletClient.account.address]:[]}async handleEthSendTransaction(e){var t;let[n]=e;if(!(null==(t=this.smartWalletClient)?void 0:t.account))throw Error("account not connected!");return this.smartWalletClient.sendTransaction({...n,value:n.value?(0,g.uU)(n.value):void 0})}async handlePersonalSign(e){var t;if(!(null==(t=this.smartWalletClient)?void 0:t.account))throw Error("account not connected!");let[n,r]=e;if((0,w.b)(r)!==(0,w.b)(this.smartWalletClient.account.address))throw Error("cannot sign for address that is not the current account");return this.smartWalletClient.signMessage({message:n})}async handleEthSignTypedDataV4(e){var t;if(!(null==(t=this.smartWalletClient)?void 0:t.account))throw Error("account not connected!");let n=e[0];if((0,w.b)(n)!==(0,w.b)(this.smartWalletClient.account.address))throw Error("cannot sign for address that is not the current account");let r="string"==typeof e[1]?JSON.parse(e[1]):e[1];return this.smartWalletClient.signTypedData(r)}
1constructor(e,t){super(),this.smartWalletClient=e,this.getClientForChain=t}},X=()=>{let{address:e,connector:t}=(0,b.F)(),{client:n}=(0,C.R)(),{ready:r,authenticated:o,user:i,logout:s}=(0,a.H)(),c=(0,v.U)(),{isSmartWalletReady:u,isSettingUp:d,shouldUseAAWallet:f,hasSetupFailed:g}=(()=>{let e=(0,v.U)(),t=(0,p.U)(),n=(0,m.i)(),{client:r,getClientForChain:a}=(0,C.R)(),{reconnect:o}=(0,y.R)(),i=(0,h.useRouter)(),[s,c]=(0,l.useState)(!1),[u,d]=(0,l.useState)(!1),[f,g]=(0,l.useState)(0),[w,b]=(0,l.useState)(!1),[I,T]=(0,l.useState)(null),S="false"!==i.query.aawallet;return(0,l.useEffect)(()=>{(async()=>{if(0!==f||I||T(Date.now()),I){let e=(Date.now()-I)/1e3;if(e>10){console.error(`[PrivySmartAccount] \u274C Total setup time exceeded 10 seconds (${e.toFixed(2)}s), giving up`),c(!0),d(!1),b(!0),T(null);return}}if(!S){c(!0),d(!1),b(!1),T(null);return}if(f>=3){let e=I?((Date.now()-I)/1e3).toFixed(2):"0";console.error("[PrivySmartAccount] ❌ Setup failed after 3 attempts",{retryCount:f,totalDuration:`${e}s`,timestamp:new Date().toISOString()}),c(!0),d(!1),b(!0),T(null);return}if(e.find(e=>"io.privy.smart_wallet"===e.id)||!r){c(!0),d(!1),b(!1),T(null);return}d(!0);let l=setTimeout(()=>{console.error(`[PrivySmartAccount] \u23F1\uFE0F Setup timeout after 3 seconds (attempt ${f+1}/3)`),g(e=>e+1),c(!1)},3e3);try{var i;let e=await a({id:n});if(!e||!a){console.warn("[PrivySmartAccount] ⚠️ Unable to get smart wallet client, falling back to embedded wallet"),clearTimeout(l),c(!0),d(!1);return}let r=new G(e,a),s=(0,E.b)({target:{provider:r,id:"io.privy.smart_wallet",name:"io.privy.smart_wallet",icon:""}}),u=t._internal.connectors.setup(s);t._internal.connectors.setState([u]),await (null==(i=t.storage)?void 0:i.setItem("recentConnectorId",u.id)),clearTimeout(l),c(!0),d(!1),b(!1),g(0),T(null),o()}catch(e){clearTimeout(l),console.error("[PrivySmartAccount] ❌ Setup error:",{error:e,message:e instanceof Error?e.message:"Unknown error",attempt:f+1,timestamp:new Date().toISOString()}),g(e=>e+1),c(!1)}})()},[t,e,a,n,r,o,i.query,S,f,I]),{isSmartWalletReady:s,isSettingUp:u,shouldUseAAWallet:S,hasSetupFailed:w}})(),[w,I]=(0,l.useState)(void 0),[T,S]=(0,l.useState)(!0),[k,_]=(0,l.useState)(null),[W,A]=(0,l.useState)(null);return(0,l.useEffect)(()=>{T&&!W?A(Date.now()):!T&&W&&A(null)},[T,W]),(0,l.useEffect)(()=>{if(W){let e=setTimeout(()=>{let e=(Date.now()-W)/1e3;console.error(`[PrivyWalletAddress] \u26A0\uFE0F Loading timeout after ${e.toFixed(2)} seconds!`),console.error("[PrivyWalletAddress] Forcing error state to prevent infinite loading"),A(null),I(void 0),_(null),S(!1),o&&s()},1e4);return()=>clearTimeout(e)}},[W,s,o]),(0,l.useEffect)(()=>{if((null==t?void 0:t.id)==="io.privy.smart_wallet"&&e){I(e),_("smart"),S(!1);return}if(!r||!o){I(void 0),_(null),S(!0);return}return f?d||!u?void S(!0):void(c.find(e=>"io.privy.smart_wallet"===e.id)?(console.warn("[PrivyWalletAddress] ⚠️ Smart wallet exists but not connected, waiting...",{connectorId:null==t?void 0:t.id,hasAddress:!!e}),S(!0)):(null==i?void 0:i.wallet)?(console.warn("[PrivyWalletAddress] ⚠️ User has wallet but no smart wallet connector, waiting for setup..."),S(!0)):(I(void 0),_(null),S(!1))):void((null==i?void 0:i.wallet)&&e?(I(e),_("embedded"),S(!1)):(null==i?void 0:i.wallet)?S(!0):(I(void 0),_(null),S(!1)))},[r,o,i,n,e,t,c,u,d,f]),{address:w,isLoading:T,addressType:k,hasSmartWallet:!!n,isSmartWalletReady:u,isSettingUp:d,hasSetupFailed:g}};function $(e){let{children:t,chains:n,appId:r="cm9jd1prg03msl80mz1jnuv9f",clientId:o="client-WY5iumRXNUjYdviuz7nf3m3z3atS4iHaRMWLTekR5Qpjp"}=e,{isLoading:i,getToken:s}=q(),c=(0,h.useRouter)();r&&o||console.error("Missing required Privy environment variables");let u=c.pathname.includes("/bridge"),f=(0,l.useMemo)(()=>({defaultChain:n[0],customAuth:{isLoading:i,getCustomAccessToken:s},supportedChains:n,appearance:{accentColor:"#6A6FF5",theme:"#222224",showWalletLoginFirst:!1,logo:"https://auth.privy.io/logos/privy-logo-dark.png",walletChainType:"ethereum-only",walletList:["detected_wallets","metamask"]},fundingMethodConfig:{moonpay:{useSandbox:!1}},embeddedWallets:{requireUserPasswordOnCreate:!1,showWalletUIs:u,ethereum:{createOnLogin:"users-without-wallets"},solana:{createOnLogin:"off"}}
1,mfa:{noPromptOnMfaRequired:!1},externalWallets:{walletConnect:{enabled:!1}}}),[n,i,s,u]);return(0,d.jsx)(a.P,{appId:null!=r?r:"",clientId:null!=o?o:"",config:f,children:(0,d.jsx)(C.b,{children:t})})}var V=(0,F.eU)(void 0),B=null;(0,D.n)();var H=()=>{let{connected:e,connecting:t,publicKey:n,disconnect:a}=(0,P.v)(),o=(0,T.Xr)(r.sY);return(0,l.useEffect)(()=>{let e=(null==n?void 0:n.toBase58())||null;o(t=>({...t,solanaAccount:e}))},[e,t,n,o]),(0,l.useEffect)(()=>{var e,t,n,r,l,o;let i=null==(t=window)||null==(e=t.trustwallet)?void 0:e.solana,s=null==(n=window)?void 0:n.trustwallet;if(!i)return void console.info("[TW] Solana not found");if("function"!=typeof i.on||"function"!=typeof i.off)return void console.warn("[TW] Provider does not support .on/.off — skipping listener binding");let c=async()=>{console.info("[TW] Disconnecting Solana wallet...");try{var e;await a(),await (null==(e=i.disconnect)?void 0:e.call(i)),console.info("[TW] Solana wallet disconnected")}catch(e){console.warn("[TW] Solana disconnect failed",e)}},u=async e=>{let t=Array.isArray(e)?e[0]:e||null;console.info(`[TW] EVM accountChanged \u2192 ${t||"null"}`),t&&(console.info(`[TW] EVM account active \u2192 disconnecting Solana`),await c())};s&&(console.info("[TW] Attaching evm listeners"),null==(l=s.on)||l.call(s,"accountsChanged",u),null==(o=s.on)||o.call(s,"accountChanged",u));let d=async e=>{var t;let n=(null==e||null==(t=e.toString)?void 0:t.call(e))||null;console.info(`[TW] Solana accountChanged \u2192 ${n||"null"}`),await c()};return null==(r=i.on)||r.call(i,"accountChanged",d),()=>{var e,t,n;console.info("[TW] Cleaning up all listeners"),null==s||null==(e=s.off)||e.call(s,"accountsChanged",u),null==s||null==(t=s.off)||t.call(s,"accountChanged",u),null==i||null==(n=i.off)||n.call(i,"accountChanged",d)}},[a]),null},Y=(0,S.tG)("pcs:socialLogin:walletRecoveryRecords",{}),z=e=>{var t,n;let{children:o,fallback:i,baseAccountConnector:s,createWagmiConfig:c,createW3WWagmiConfig:u,allowServerRender:f}=e,h=(0,T.md)(_._A),g=(0,T.md)(W.yY);(()=>{var e,t;let{authenticated:n,ready:r,user:o,createWallet:i,setWalletRecovery:s}=(0,a.H)(),[c,u]=(0,T.fp)(Y),d=(0,l.useRef)(!1),f=(0,l.useCallback)(()=>{var e,t;let a=null==o||null==(e=o.smartWallet)?void 0:e.address,l=a&&c[a]||0;if(n&&r&&(null==o||null==(t=o.wallet)?void 0:t.recoveryMethod)==="privy"&&(null==o?void 0:o.smartWallet)&&a){let e=Date.now();e-l>6048e5&&(s(),u(t=>({...t,[a]:e})))}},[r,o,n,c,u,s]);(0,l.useEffect)(()=>{var e,t;r&&n&&(null==o||null==(e=o.wallet)?void 0:e.address)&&(null==o||null==(t=o.smartWallet)?void 0:t.address)&&f()},[r,n,null==o||null==(e=o.wallet)?void 0:e.address,null==o||null==(t=o.smartWallet)?void 0:t.address,f]),(0,l.useEffect)(()=>{(async()=>{if(r&&n&&(null==o?void 0:o.wallet)===void 0&&!1===d.current){d.current=!0;try{await i()}catch(e){console.error("Failed to create wallet, retriggering auth lifecycle:",e);try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&n.startsWith("privy:")&&e.push(n)}e.forEach(e=>{localStorage.removeItem(e)}),await M()}catch(e){console.error("Failed to retrigger auth:",e)}d.current=!1}}})()},[r,o,n,i])})();let w=(e=>{let{createWagmiConfig:t,createW3WWagmiConfig:n,allowServerRender:a=!1}=e,[o,i]=(0,T.fp)(V),s=(0,l.useRef)(void 0);s.current||(s.current=(0,I.YN)()?n():t());let c=null!=o?o:s.current;return(0,l.useEffect)(()=>{let e=e=>{if(!(null==e?void 0:e.detail)||"object"!=typeof e.detail)return void console.warn("[wallet] Ignored 'eip6963:announceProvider' event: invalid detail: ",null==e?void 0:e.detail);let{provider:t,info:n}=e.detail;t&&(null==n?void 0:n.uuid)&&(r.JR.some(e=>e.info.uuid===n.uuid)||r.JR.push({provider:t,info:n}))};window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider"));let t=setTimeout(()=>{console.log("[wallet] init wagmi config"),i(c)});return()=>{window.removeEventListener("eip6963:announceProvider",e),clearTimeout(t)}},[c,i]),c})({createWagmiConfig:c,createW3WWagmiConfig:u,allowServerRender:f}),v=(0,l.useMemo)(()=>{let e=()=>(0,d.jsx)(K,{baseAccountConnector:s});return e.displayName="WalletRuntimeSync",e},[s]);
1return w?(0,d.jsx)(r.Hb,{WagmiProvider:k.x,wagmiConfig:w,reconnectOnMount:null==(t=e.reconnectOnMount)||t,isW3W:(0,I.YN)(),selectedWalletId:null!=(n=null==g?void 0:g.id)?n:null,solanaEndpoint:h,ChainGate:J,Sync:v,SolanaProvider:A.g,SolanaStateUpdater:H,fallback:i,children:o}):(0,d.jsx)(d.Fragment,{children:null!=i?i:null})},J=e=>{let{children:t}=e;return(()=>{let e=(0,h.useRouter)(),{query:t}=e,n=t.chain||"",a=t.persistChain?String(t.persistChain):null,{switchNetwork:i}=(0,r.O3)(),s=(0,r.lB)(),c=n?o.rV[n]:null,u=!!c&&!!a&&s.current!==c,d=(0,l.useRef)(!1),{setLastUpdated:f}=(0,L.H8)();return(0,l.useEffect)(()=>{let t=()=>{e.query.persistChain||(B=e.pathname)};return e.events.on("routeChangeComplete",t),()=>e.events.off("routeChangeComplete",t)},[e]),u&&!d.current&&(d.current=!0,i(c).then(t=>{let n=s.current===c;t||n?f():setTimeout(()=>{B?e.replace(B):e.replace("/")},0),d.current=!1}))})(),(0,d.jsx)(d.Fragment,{children:t})},K=e=>{let{baseAccountConnector:t}=e;return(e=>{let{address:t,connector:n,isConnected:a}=(0,b.F)(),{chainId:i}=(0,r.ax)(),{connectAsync:s,isPending:c}=(0,R.e)(),{switchNetwork:u,canSwitch:d,isLoading:f}=(0,r.O3)(),h=(0,T.md)(r.wN),g=(0,T.Xr)(r.yT),{env:w,wallet:v}=(0,r.j6)(),p="wallet_app"===w&&v===x.c.BaseApp,m=(0,l.useRef)(!1),y=(0,l.useRef)(!1),E=(0,l.useRef)(!1);(0,l.useEffect)(()=>{m.current=!1,y.current=!1,E.current=!1},[h]),(0,l.useEffect)(()=>{if(m.current||y.current)return;if(t||n||a){m.current=!0,g("connected");return}if(c)return;if(!p){m.current=!0,g("idle");return}let r=!1;return y.current=!0,g("connecting"),(async()=>{try{let t=async n=>{try{await new Promise(e=>setTimeout(e,500)),await s({connector:e})}catch(e){if(r||n<=1)throw e;await new Promise(e=>setTimeout(e,500)),await t(n-1)}};await t(5),m.current=!0,g("connected")}catch(e){r||(m.current=!0,g("failed"),console.warn("[wallet] Base miniapp auto-connect failed",e))}finally{y.current=!1}})(),()=>{r=!0}},[t,n,s,p,a,c,h,g]),(0,l.useEffect)(()=>{if(p&&t&&n&&a){if(i===o.nU.BASE){E.current=!1;return}!d||f||E.current||(E.current=!0,u(o.nU.BASE,{from:"switch"}).catch(e=>{E.current=!1,console.warn("[wallet] Base miniapp switch-to-base failed",e)}))}},[t,d,i,n,p,a,f,u])})(t),!function(){let{chainId:e,address:t,connector:n,status:o}=(0,b.F)(),{reconnectAsync:i}=(0,y.R)(),s=(0,T.Xr)(r.sY),c=(0,T.Xr)(r.kf),u=(0,T.Xr)(r.Pq),d=(0,T.Xr)(r.r9),f=(0,T.md)(r.sY).account,{switchNetwork:h}=(0,r.O3)(),{ready:g,authenticated:w}=(0,a.H)(),{address:v,isLoading:p}=X(),m=(0,l.useRef)(e),E=(0,l.useRef)(!1);(0,l.useEffect)(()=>{(async()=>{!m.current&&e&&h((0,r.xJ)()||e,{from:"connect",replaceUrl:!0}).then(()=>{m.current=e}),e&&m.current&&m.current!==e&&h(e,{replaceUrl:!0,from:"wagmi"}).then(()=>{m.current=e})})()},[e,h]),(0,l.useEffect)(()=>{c(null!=n?n:null)},[n,c]),(0,l.useEffect)(()=>{g&&u(w)},[g,w,u]),(0,l.useEffect)(()=>{if(!g){s(e=>({...e,account:e.account,status:e.account?"reconnecting":null})),d(f?"session-resolved":"session-restoring");return}if(w){if(p){s(e=>({...e,account:void 0,status:null})),d("session-restoring");return}s(e=>({...e,account:v,status:v?"connected":"disconnected"})),d("session-resolved");return}if("reconnecting"===o){s(e=>({...e,account:void 0,status:o})),d("session-restoring");return}if(!t&&!n&&!E.current&&(0,r.pw)()){E.current=!0,s(e=>({...e,account:void 0,status:null})),d("session-restoring"),i().then(async e=>{var t;let n=e[0],r=null==n||null==(t=n.accounts)?void 0:t[0];s(e=>({...e,account:r,status:r?"connected":"disconnected"})),(null==n?void 0:n.chainId)&&await h(n.chainId,{from:"reconnect",replaceUrl:!0})}).catch(()=>{s(e=>({...e,account:void 0,status:"disconnected"}))}).finally(()=>{d("session-resolved")});return}s(e=>({...e,account:t,status:o})),d("session-resolved")},[g,w,v,p,t,o,n,i,s,d,f,h])}(),null},Q=()=>{let{logout:e,ready:t,authenticated:n}=(0,a.H)(),{signOutAndClearUserStates:o}=q();return(0,l.useEffect)(()=>((0,r.UT)(async()=>!!t&&!!n&&(await o(),await e(),!0)),()=>(0,r.UT)(void 0)),[n,e,t,o]),null},Z=e=>{let{children:t,allowServerRender:n}=e;return(0,d.jsx)(j,{children:(0,d.jsx)($,{chains:r.c7.chains,appId:r.c7.wallet.privyAppId,clientId:r.c7.wallet.privyClientId,children:(0,d.jsxs)(z,{baseAccountConnector:r.FX,createWagmiConfig:r.py,createW3WWagmiConfig:r.K6,allowServerRender:n,children:[(0,d.jsx)(Q,{}),t]})})})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.