@naculus/connect-appkit-react 0.11.1 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -15
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Ns=Object.create;var Lt=Object.defineProperty;var _s=Object.getOwnPropertyDescriptor;var Ds=Object.getOwnPropertyNames;var Ms=Object.getPrototypeOf,Ls=Object.prototype.hasOwnProperty;var Bs=(e,t)=>{for(var r in t)Lt(e,r,{get:t[r],enumerable:!0})},Cr=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ds(t))!Ls.call(e,n)&&n!==r&&Lt(e,n,{get:()=>t[n],enumerable:!(s=_s(t,n))||s.enumerable});return e};var He=(e,t,r)=>(r=e!=null?Ns(Ms(e)):{},Cr(t||!e||!e.__esModule?Lt(r,"default",{value:e,enumerable:!0}):r,e)),Fs=e=>Cr(Lt({},"__esModule",{value:!0}),e);var la={};Bs(la,{AppkitAccordion:()=>as,AppkitAccountButton:()=>is,AppkitAlertDialog:()=>ls,AppkitAvatar:()=>cs,AppkitBadge:()=>us,AppkitButton:()=>ps,AppkitCard:()=>ds,AppkitCardContent:()=>ms,AppkitCardDescription:()=>fs,AppkitCardFooter:()=>gs,AppkitCardHeader:()=>hs,AppkitCardTitle:()=>ys,AppkitCheckbox:()=>Cs,AppkitCollapsible:()=>Ss,AppkitConnectButton:()=>Es,AppkitDialog:()=>ws,AppkitDropdownMenu:()=>ks,AppkitInput:()=>vs,AppkitPopover:()=>xs,AppkitProgress:()=>As,AppkitScrollArea:()=>bs,AppkitSelect:()=>Rs,AppkitSeparator:()=>Ts,AppkitSkeleton:()=>Is,AppkitSwitch:()=>Us,AppkitTabs:()=>Ps,AppkitToggleGroup:()=>Ws,AppkitTooltip:()=>Os,DEFAULT_EVM_CHAINS:()=>rr,LAMPORTS_PER_SOL:()=>Z.LAMPORTS_PER_SOL,PassphraseCancelledError:()=>Z.PassphraseCancelledError,PassphraseGate:()=>Z.PassphraseGate,SolanaRpcError:()=>Z.SolanaRpcError,TokenSelector:()=>yr,TxMonitorContext:()=>sr,WALLET_ERROR_DESCRIPTIONS:()=>gr,WALLET_ERROR_TITLES:()=>fr,Web3ConnectProvider:()=>Tr,Web3Context:()=>Vt,buildDelegationPolicyMessage:()=>or.buildDelegationPolicyMessage,clearClient:()=>vr,createClient:()=>Ft,formatSol:()=>Z.formatSol,getChainById:()=>Rr,getClient:()=>Kt,getDefaultChains:()=>qt,getLatestBlockhash:()=>Z.getLatestBlockhash,getLocale:()=>Qo,getSignatureStatus:()=>Z.getSignatureStatus,getSolanaBalance:()=>Z.getSolanaBalance,getUserFriendlyError:()=>kt,isRetryableError:()=>vn,parseSol:()=>Z.parseSol,resetSessionKeyManager:()=>Jr,setLocale:()=>Xo,t:()=>kn,useAccount:()=>K,useAuthorizations:()=>Pr,useBalance:()=>Or,useCapabilities:()=>jt,useChain:()=>pe,useCompareCosts:()=>Zn,useConnect:()=>_r,useCreateSessionKey:()=>Xr,useDelegate:()=>Mr,useDelegation:()=>ct,useDelegationPolicy:()=>eo,useDisconnect:()=>to,useERC20Allowance:()=>ao,useERC20Approve:()=>io,useERC20Transfer:()=>lo,useERC20TransferSimulation:()=>mo,useEmbeddedWallet:()=>no,useExecuteCalls:()=>en,useExecuteRoute:()=>er,useLastTx:()=>go,useLookupAddress:()=>Co,useMppSession:()=>qr,useNotification:()=>Eo,usePassphraseGate:()=>ko,usePaymentFetch:()=>Lr,useResolveName:()=>xo,useRevokeSession:()=>Qr,useRouteQuote:()=>tr,useSIWxLogin:()=>fn,useSIWxSession:()=>Ro,useSendCalls:()=>Jt,useSendTransaction:()=>ft,useSendUserOperation:()=>Ao,useSendWithSession:()=>Yr,useSession:()=>bo,useSessionKeys:()=>nn,useSignInWithEthereum:()=>To,useSignInWithX:()=>Ct,useSignMessage:()=>on,useSimulateTransfer:()=>Po,useSiwxAuthSession:()=>Wo,useSmartAccount:()=>No,useSolanaAccount:()=>En,useSolanaBalance:()=>Mo,useSolanaRoles:()=>Fo,useSolanaSessionKey:()=>jr,useSolanaTransaction:()=>Ho,useSwitchChain:()=>Vo,useTokenBalance:()=>zo,useTokenList:()=>Dt,useTokenSearch:()=>Mt,useTransactionSimulation:()=>cn,useTxHistory:()=>jo,useTxMonitor:()=>fo,useUserOpStatus:()=>$o,useValidateDestination:()=>Zo,useViemClient:()=>de,useWallet:()=>es,useWeb3:()=>I,useWeb3ErrorHandler:()=>ts,useX402Signer:()=>Kr,validateDestination:()=>mr});module.exports=Fs(la);var Z=require("@naculus/connect-core");var Sr=require("@naculus/connect-appkit-core"),ge=require("react");function Zn(e,t){let{operation:r,chains:s,options:n}=e,[c,i]=(0,ge.useState)([]),[h,u]=(0,ge.useState)(!1),[l,g]=(0,ge.useState)(null),o=(0,ge.useRef)(!0),a=(0,ge.useRef)(0),p=(0,Sr.compareCostsKey)(e),d=(0,ge.useCallback)(async()=>{if(!s||s.length===0){i([]);return}if(!t)return;let C=++a.current;u(!0),g(null);try{let E=await t(r,s,n);o.current&&C===a.current&&i(E)}catch(E){o.current&&C===a.current&&(g(E instanceof Error?E:new Error(String(E))),i([]))}finally{o.current&&C===a.current&&u(!1)}},[p,t]);(0,ge.useEffect)(()=>{d()},[d]),(0,ge.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let m=(0,ge.useCallback)(async()=>{await d()},[d]);return{comparisons:c,loading:h,error:l,refresh:m}}var Bt=require("@naculus/connect-appkit-core"),Se=require("react");function er(e){let[t,r]=(0,Se.useState)(!1),[s,n]=(0,Se.useState)(null),[c,i]=(0,Se.useState)(null),h=(0,Se.useRef)(!0),u=(0,Se.useRef)(!1);(0,Se.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let l=(0,Se.useCallback)(async(o,a,p)=>{if(!e)return i({code:"no_executor",message:"No executeRoute function provided"}),n(null),null;let d=(0,Bt.validateRouteRecipient)(o,a);if(d)return i(d),n(null),null;if(u.current)return i({code:"execution_in_progress",message:"A route execution is already in progress"}),null;u.current=!0,r(!0),i(null),n(null);try{let m=await e(o,a,p);return h.current&&n(m),m}catch(m){return h.current&&i((0,Bt.toExecuteRouteError)(m)),null}finally{u.current=!1,h.current&&r(!1)}},[e]),g=(0,Se.useCallback)(()=>{n(null),i(null),r(!1)},[]);return{execute:l,executing:t,result:s,error:c,reset:g}}var Er=require("@naculus/connect-appkit-core"),ce=require("react");function tr(e,t){let{fromChain:r,toChain:s,fromToken:n,toToken:c,amount:i,options:h}=e,[u,l]=(0,ce.useState)([]),[g,o]=(0,ce.useState)(!1),[a,p]=(0,ce.useState)(null),d=(0,ce.useRef)(null),m=(0,ce.useRef)(!0),C=(0,ce.useCallback)(async()=>{if(!(0,Er.isQuotableInput)({fromChain:r,toChain:s,fromToken:n,amount:i})){l([]);return}if(t){o(!0),p(null);try{let y=await t(r,s,n,i,h,c);m.current&&l(y)}catch(y){m.current&&(p(y instanceof Error?y:new Error(String(y))),l([]))}finally{m.current&&o(!1)}}},[r,s,n,c,i,h,t]);(0,ce.useEffect)(()=>{if(d.current&&clearTimeout(d.current),!r||!s||!n||!i){l([]);return}return d.current=setTimeout(()=>{C()},300),()=>{d.current&&clearTimeout(d.current)}},[C,r,s,n,i]),(0,ce.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let E=(0,ce.useCallback)(async()=>{await C()},[C]),A=(0,ce.useCallback)(()=>{l([]),p(null),o(!1)},[]);return{quotes:u,loading:g,error:a,refresh:E,clear:A}}var Y=require("@naculus/connect-core"),te=require("@naculus/connector-evm-injected"),wr=require("@naculus/connect-core"),kr=require("@naculus/connector-walletconnect"),nr=null;function Ft(e){let t=null,r=(0,kr.createWalletConnectConnector)({projectId:e.projectId,metadata:e.metadata,...e.walletConnect?.client?{client:e.walletConnect.client}:{},...e.walletConnect?.openUrl?{openUrl:e.walletConnect.openUrl}:{}}),s=null,n=null,c=null,i=null,h=e.passphrasePrompt&&e.enableEmbedded&&!e.embeddedConfig?.encryptionPassphrase?new wr.PassphraseGate:null;e.enableEmbedded&&(n=import("@naculus/connector-embedded").then(o=>{let a={...e.embeddedConfig};h&&(a.encryptionPassphrase=h.request),e.enablePasskeys&&a.encryptionPassphrase&&!a.prfUnlock&&(a.prfUnlock={async derive(d){i&&await i;let m=c;return m?.hasCredential()?m.derivePrfKey(d):null}}),s=o.createPocketConnector(a),t?._setEmbeddedConnector(s)}).catch(o=>{Y.logger.warn("react/client","Embedded wallet connector not available:",o),s=null})),e.enablePasskeys&&(i=import("@naculus/connector-passkeys").then(o=>{c=o.createPasskeysConnector(),t?._setPasskeysConnector(c)}).catch(o=>{Y.logger.warn("react/client","Passkeys connector not available:",o),c=null}));let u=null,l=null;e.enableSolana&&(l=import("@naculus/connector-solana").then(o=>{let a=o.solanaConnector;e.solanaDefaultChain&&"configure"in a&&a.configure({defaultChain:e.solanaDefaultChain}),u=a,typeof window<"u"&&"startDiscovery"in a&&a.startDiscovery();for(let p of e.solanaWallets??[])a.registerWallet?.(p);t?._setSolanaConnector(u)}).catch(o=>{Y.logger.warn("react/client","Solana connector not available:",o),u=null})),typeof window<"u"&&te.eip6963Connector.startDiscovery();for(let{info:o,provider:a}of e.injectedProviders??[])te.eip6963Connector.registerProvider(o,a);let g={connector:r,get embeddedConnector(){return s},getEmbeddedConnector:async()=>(n&&await n,s),get passkeysConnector(){return c},passphraseGate:h,solanaRpcUrl:e.solanaRpcUrl??null,get solanaConnector(){return u},connect:()=>r.connect(),connectInjected:async o=>te.eip6963Connector.connect(o),connectEmbedded:async()=>{if(n&&await n,!s)throw new Error("Embedded wallet not enabled. Set enableEmbedded: true in config.");return s.connect()},connectPasskeys:async()=>{if(i&&await i,!c)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return c.connect()},startPairing:()=>r.startPairing(),completePairing:()=>r.completePairing(),cancelPairing:()=>r.cancelPairing?.(),signMessage:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.signMessage(o,a);if(o.walletType==="passkeys"&&c)return c.signMessage(o,a);if(o.walletType==="embedded"){if(!s)throw new Y.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signMessage(o,a)}if(o.walletType==="solana"){if(l&&await l,u)return u.signMessage(o,a);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.signMessage(o,a)},signTransaction:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.signTransaction(o,a);if(o.walletType==="embedded"){if(!s)throw new Y.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signTransaction(o,a)}if(o.walletType==="solana"){if(l&&await l,u)return u.signTransaction(o,a);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.signTransaction(o,a)},sendTransaction:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.sendTransaction(o,a);if(o.walletType==="passkeys"&&c)return c.sendTransaction(o,a);if(o.walletType==="embedded"){if(!s)throw new Y.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.sendTransaction(o,a)}if(o.walletType==="solana"){if(l&&await l,u)return u.sendTransaction(o,a);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.sendTransaction(o,a)},onAccountsChanged:(o,a)=>{let p=()=>{};return o.id?.startsWith("eip6963-")?te.eip6963Connector.onAccountsChanged?.(o,a)??p:o.walletType==="embedded"?s?.onAccountsChanged?.(o,a)??p:o.walletType==="passkeys"?p:o.walletType==="solana"?u?.onAccountsChanged?.(o,a)??p:r.onAccountsChanged?.(o,a)??p},onChainChanged:(o,a)=>{let p=()=>{};return o.id?.startsWith("eip6963-")?te.eip6963Connector.onChainChanged?.(o,a)??p:o.walletType==="passkeys"||o.walletType==="embedded"?p:o.walletType==="solana"?u?.onChainChanged?.(o,a)??p:r.onChainChanged?.(o,a)??p},getCapabilities:o=>o.id?.startsWith("eip6963-")?te.eip6963Connector.getCapabilities?.(o):o.walletType==="passkeys"?c?.getCapabilities?.(o):o.walletType==="solana"?u?.getCapabilities?.(o):o.walletType==="embedded"?s?.getCapabilities?.(o):r.getCapabilities?.(o),sendCalls:async(o,a,p,d)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.sendCalls(o,a,p,d);if(o.walletType==="passkeys"&&c)return c.sendCalls(o,a,p,d);if(o.walletType==="solana"){if(l&&await l,u)return u.sendCalls(o,a,p,d);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}if(o.walletType==="embedded"){if(!s?.sendCalls)throw new Y.WalletError("method_not_allowed","Embedded wallet does not support sendCalls");return s.sendCalls(o,a,p,d)}if(!r.sendCalls)throw new Y.WalletError("method_not_allowed","sendCalls not supported by this connector");return r.sendCalls(o,a,p,d)},showCallsStatus:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.showCallsStatus(o,a);if(o.walletType==="passkeys"||o.walletType==="embedded")throw new Y.WalletError("method_unsupported",`${o.walletType} wallets have no UI to display a call bundle.`);if(!r.showCallsStatus)throw new Y.WalletError("method_unsupported","This connector cannot display call status.");return r.showCallsStatus(o,a)},getCallsStatus:async(o,a)=>{if(o.id?.startsWith("eip6963-")&&te.eip6963Connector.getCallsStatus)return te.eip6963Connector.getCallsStatus(o,a);if(o.walletType==="passkeys"&&c?.getCallsStatus)return c.getCallsStatus(o,a);if(o.walletType==="embedded")throw new Y.WalletError("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!r.getCallsStatus)throw new Y.WalletError("method_not_allowed","getCallsStatus not supported by this connector");return r.getCallsStatus(o,a)},reconnect:async o=>o.walletType==="eip6963"?te.eip6963Connector.reconnect(o):o.walletType==="embedded"?s?s.reconnect(o):o:o.walletType==="solana"?o:r.reconnect(o),disconnect:async o=>{if(o.id?.startsWith("eip6963-")||o.walletType==="eip6963")return te.eip6963Connector.disconnect(o);if(o.walletType==="embedded"&&s)return s.disconnect();if(o.walletType==="passkeys"&&c)return c.disconnect(o);if(o.walletType==="solana"){if(l&&await l,u)return u.disconnect(o);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.disconnect(o)},getAllConnectors:()=>{let o=[r];return s&&o.push(s),c&&o.push(c),u&&o.push(u),o},_setEmbeddedConnector:o=>{s=o},_setPasskeysConnector:o=>{c=o},_setSolanaConnector:o=>{u=o}};return t=g,nr=g,g}function Kt(){return nr}function vr(){nr=null}var bt=require("@naculus/connect-core"),Ur=require("react");var ee=require("@naculus/connect-core"),At=require("@naculus/connector-evm-injected"),N=require("react");var xr=require("@naculus/connect-core"),Ht=require("@naculus/siwx");function rt(e,t){let r=t.split(":",1)[0],n=(e.namespaces[r]?.accounts??[]).filter(c=>c.startsWith(`${r}:`)).map(c=>({namespace:r,caip10:c}))[0];if(n)return{...n,address:n.caip10.split(":").pop()??n.caip10}}function Ks(e){return e.namespaces.eip155?.chains?.[0]??e.namespaces.solana?.chains?.[0]??e.namespaces.xrpl?.chains?.[0]??"eip155:1"}async function Ar(e){let{session:t,siwx:r,signMessage:s}=e;if(!r||!t)return{kind:"skipped"};try{let n=Ks(t),c=rt(t,n);if(!c)throw new Error("No account found in session");let{address:i}=c,h=await r.createMessage({address:i,chainId:n}),u=(0,Ht.parseSiwxMessage)(h);if(!u?.nonce)throw new Error("SIWx message must contain a nonce");await(0,Ht.issueNonce)(u.nonce);let l=await s(t,{message:h,address:i,chainId:n});return await r.handleSignComplete?.({message:h,signature:l}),{kind:"authenticated",address:i,chainId:n}}catch(n){let c=n instanceof Error?n:new Error("Wallet authentication failed");return xr.logger.error("appkit/core","SIWx authentication failed:",n),{kind:"failed",error:c,fatal:r.required!==!1}}}var Fe=require("@naculus/connect-appkit-core");var br=require("@naculus/connect-appkit-core"),be=require("@naculus/connect-core"),Hs=[{caip2:"eip155:5",name:"Goerli",rpcUrl:"https://goerli.blockpi.network/v1/rpc/public",explorerUrl:"https://goerli.etherscan.io",token:"ETH"},{caip2:"eip155:80001",name:"Mumbai",rpcUrl:"https://rpc-mumbai.maticvigil.com",explorerUrl:"https://mumbai.polygonscan.com",token:"MATIC"},{caip2:"eip155:421613",name:"Arbitrum Goerli",rpcUrl:"https://goerli-rollup.arbitrum.io/rpc",explorerUrl:"https://goerli.arbiscan.io",token:"ETH"},{caip2:"eip155:420",name:"Optimism Goerli",rpcUrl:"https://goerli.optimism.io",explorerUrl:"https://goerli-optimism.etherscan.io",token:"ETH"}];function qs(e){let t=be.CHAINS[e];if(!t||!t.explorerUrl)return null;let r=t.caip2Id;return{caip2:r,name:t.name,rpcUrl:(0,be.getRpcUrl)(r,be.DEFAULT_RPC_URLS[r]??""),explorerUrl:t.explorerUrl,token:t.nativeCurrency.symbol}}function Vs(){if(!be.CHAINS)return[];let e=[],t=Object.keys(be.CHAINS).map(Number).sort((r,s)=>r-s);for(let r of t){let s=qs(r);s&&e.push(s)}for(let r of Hs){let s=(0,be.eip155Reference)(r.caip2);(s===null||!be.CHAINS[s])&&e.push(r)}return e}var rr=Vs();function Rr(e,t){return(0,br.resolveChain)(e,t)??void 0}function qt(){return[...rr]}var Ir=require("react/jsx-runtime"),Vt=(0,N.createContext)(null);function Tr({children:e,config:t,autoConnect:r=!0}){let[s,n]=(0,N.useReducer)(Fe.web3Reducer,Fe.initialWeb3State),c=(0,N.useMemo)(()=>t.chains??qt(),[t.chains]),i=t.connectionTimeout??3e4,h=t.maxRetries??2,u=(0,N.useMemo)(()=>t.sessionStorage??new ee.LocalStorageSessionStorage(t.storageKey??"naculus_web3_session",t.encryptionKey),[t.sessionStorage,t.storageKey,t.encryptionKey]),l=(0,N.useMemo)(()=>Ft({projectId:t.projectId,metadata:t.metadata,enableEmbedded:t.enableEmbedded,embeddedConfig:t.embeddedConfig,enablePasskeys:t.enablePasskeys,enableSolana:t.enableSolana,solanaDefaultChain:t.solanaDefaultChain,walletConnect:t.walletConnect,solanaWallets:t.solanaWallets,injectedProviders:t.injectedProviders}),[t.projectId,t.metadata,t.enableEmbedded,t.embeddedConfig,t.enablePasskeys,t.enableSolana,t.solanaDefaultChain,t.walletConnect,t.solanaWallets,t.injectedProviders]),g=(0,N.useRef)(null),o=(0,N.useRef)(null),a=(0,N.useMemo)(()=>{let f=(0,ee.createConnectorManager)();for(let O of[At.eip6963Connector,...l.getAllConnectors()])f.register(O.id,O);let S={},x={};for(let O of c){let z=O.caip2;O.rpcUrl&&(S[z]=O.rpcUrl),O.token&&(x[z]={name:O.name,symbol:O.token,decimals:18})}let P=(0,ee.createSessionManager)(f,{autoRefreshFeeOnSwitch:t.autoRefreshFeeOnSwitch??!0,defaultRpcUrls:S,defaultCurrencies:x,encryptionKey:t.encryptionKey});return g.current=P,P},[l,c,t.autoRefreshFeeOnSwitch,t.encryptionKey]);(0,N.useEffect)(()=>{let f=z=>{let{walletSession:je}=z.bundle;n({type:"SET_SESSION",payload:je});let fe=[];Object.values(je.namespaces).forEach(xt=>{fe.push(...xt.accounts)}),n({type:"SET_ACCOUNTS",payload:fe}),n({type:"SET_CHAIN",payload:z.bundle.activeChainId}),n({type:"SET_STATUS",payload:"connected"})},S=()=>{n({type:"RESET"})},x=z=>{n({type:"SET_CHAIN",payload:z.newChainId})},P=z=>f(z),O=()=>{u.clear(),n({type:"RESET"})};return a.on("sessionConnected",f),a.on("sessionDisconnected",S),a.on("chainChanged",x),a.on("sessionScopeChanged",P),a.on("sessionRevoked",O),()=>{a.off("sessionConnected",f),a.off("sessionDisconnected",S),a.off("chainChanged",x),a.off("sessionScopeChanged",P),a.off("sessionRevoked",O)}},[a,u]),(0,N.useEffect)(()=>{let f=()=>{u.clear(),n({type:"RESET"})};l.connector.onSessionExpiry(f)},[l,u]);let p=(0,N.useCallback)(()=>{for(let f of[At.eip6963Connector,...l.getAllConnectors()])a.registerConnector(f)},[l,a]),d=(0,N.useCallback)(async f=>{p();let S=[At.eip6963Connector,...l.getAllConnectors()].find(P=>P.id===f.walletType||P.kind===f.walletType);S&&!f.connectorId&&(f.connectorId=S.id);let x=f.namespaces.eip155?.chains?.[0]??f.namespaces.solana?.chains?.[0]??f.namespaces.xrpl?.chains?.[0];x&&await a.attach(f,x)},[l,a,p]),m=(0,N.useCallback)(f=>{if(n({type:"SET_SESSION",payload:f}),f){let S=[];Object.values(f.namespaces).forEach(z=>{S.push(...z.accounts)}),n({type:"SET_ACCOUNTS",payload:S});let x=f.namespaces.eip155?.chains?.[0],P=f.namespaces.solana?.chains?.[0],O=f.namespaces.xrpl?.chains?.[0];n({type:"SET_CHAIN",payload:x??P??O??null})}else n({type:"SET_ACCOUNTS",payload:[]}),n({type:"SET_CHAIN",payload:null})},[]);(0,N.useEffect)(()=>{let f=s.session,S=l;return!f||!S?.onAccountsChanged?void 0:S.onAccountsChanged(f,P=>{if(P.length===0){u.clear().finally(()=>n({type:"RESET"}));return}m(f),u.save(f)})},[s.session,l,u,m]),(0,N.useEffect)(()=>{let f=s.session,S=l;if(!(!f||!S?.onChainChanged))return S.onChainChanged(f,x=>{m(f),u.save(f);let P=a.syncExternalChain;if(!P)return;let O=P.call(a,x).catch(z=>{ee.logger.warn("react/provider","External chain sync error:",z)});o.current=O,O.finally(()=>{o.current===O&&(o.current=null)})})},[s.session,l,u,m,a]);let C=(0,N.useCallback)(async f=>{if(!t.siwx||!f)return!0;n({type:"SET_STATUS",payload:"authenticating"});let S=await Ar({session:f,siwx:t.siwx,signMessage:(x,P)=>l.signMessage(x,P)});return S.kind==="failed"&&S.fatal?(await u.clear(),n({type:"RESET"}),n({type:"SET_ERROR",payload:S.error}),!1):!0},[t.siwx,l,u]),E=(0,N.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await(0,Fe.withTimeout)(l.connect(),i,"Wallet connect");await u.save(f),m(f);try{await d(f)}catch(S){ee.logger.warn("react/provider","SessionManager sync error:",S)}if(!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,i,C,d]),A=(0,N.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await l.connectEmbedded();if(await u.save(f),m(f),await d(f),!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Embedded wallet connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,C,d]),y=(0,N.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await l.connectPasskeys();if(await u.save(f),m(f),await d(f),!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Passkeys connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,C,d]),w=(0,N.useCallback)(async()=>{if(!s.session){n({type:"RESET"});return}try{await l.disconnect(s.session)}catch(f){ee.logger.error("react/provider","Disconnect error:",f)}try{let f=g.current;f&&await f.disconnect()}catch(f){ee.logger.warn("react/provider","SessionManager disconnect error:",f)}await u.clear(),n({type:"RESET"})},[l,s.session,u]),R=(0,N.useCallback)(async f=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let S=await(0,Fe.withTimeout)(l.connectInjected(f),i,"Injected wallet connect");await u.save(S),m(S);try{await d(S)}catch(x){ee.logger.warn("react/provider","SessionManager sync error:",x)}if(!await C(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){let x=S instanceof Error?S.message:"Connection failed";n({type:"SET_ERROR",payload:S instanceof Error?S:new Error(x)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,i,C,d]),k=(0,N.useCallback)(async()=>l.startPairing(),[l]),T=(0,N.useCallback)(()=>{l.cancelPairing?.()},[l]),v=(0,N.useCallback)(async()=>{let f=await l.completePairing();return await u.save(f),m(f),await d(f),await C(f)&&n({type:"SET_STATUS",payload:"connected"}),f},[l,u,m,C,d]),b=(0,N.useCallback)(async f=>{let S=t.siwx;if(!S||S.required===!1)return!0;try{if(await S.hasValidSession?.())return!0}catch(x){ee.logger.warn("react/provider","siwx.hasValidSession failed",x)}return C(f)},[t.siwx,C]),U=(0,N.useCallback)(async()=>{let f=await u.load();if(!f){n({type:"SET_STATUS",payload:"disconnected"});return}n({type:"SET_STATUS",payload:"reconnecting"});try{let S=await(0,Fe.withRetry)(()=>l.reconnect(f),{maxRetries:h,baseDelay:1e3,label:"reconnect"});m(S);try{let x=g.current;x&&(p(),await x.restoreFromPersistence())}catch(x){ee.logger.warn("react/provider","SessionManager restore error:",x)}if(!await b(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){ee.logger.error("react/provider","Reconnect error:",S),await u.clear(),n({type:"SET_STATUS",payload:"disconnected"}),n({type:"SET_SESSION",payload:null})}},[l,u,m,h,p,b]),W=(0,N.useCallback)(async f=>{o.current&&await o.current;let S=g.current;if(S?.getActiveBundle()){await S.switchChain(f),m(s.session);return}if(!s.session)throw new Error("No active session");try{s.session.walletType==="eip6963"||s.session.id?.startsWith("eip6963-")?await At.eip6963Connector.switchChain(s.session,f):s.session.walletType==="embedded"&&l.embeddedConnector?await l.embeddedConnector.switchChain?.(s.session,f):s.session.walletType==="passkeys"&&l.passkeysConnector?await l.passkeysConnector.switchChain?.(s.session,f):s.session.walletType==="solana"&&l.solanaConnector?await l.solanaConnector.switchChain?.(s.session,f):await l.connector.switchChain(s.session,f),m(s.session)}catch(x){throw new ee.WalletError("chain_unsupported","Failed to switch chain",x)}},[l,s.session,m]);(0,N.useEffect)(()=>{r&&U()},[r,U]);let D=(0,N.useCallback)(()=>{n({type:"SET_ERROR",payload:null})},[]),B=(0,N.useMemo)(()=>({...s,connect:E,connectEmbedded:A,connectPasskeys:y,disconnect:w,reconnect:U,switchChain:W,startPairing:k,completePairing:v,cancelPairing:T,connectInjected:R,clearError:D,isConnected:s.status==="connected",chains:c,client:l,sessionManager:a}),[s,E,A,y,w,U,W,k,v,T,R,D,c,l,a]);return(0,Ir.jsx)(Vt.Provider,{value:B,children:e})}function I(){let e=(0,N.useContext)(Vt);if(!e)throw new Error("useWeb3 must be used within a Web3ConnectProvider");return e}function K(){let{accounts:e,isConnected:t}=I(),r=(0,Ur.useMemo)(()=>!t||e.length===0?null:e.map(n=>{let c=(0,bt.parseCaip10)(n);return c?{address:n,namespace:c.namespace,isEVM:c.namespace==="eip155"&&(0,bt.isEvmAddress)(c.address)}:{address:n,namespace:null,isEVM:(0,bt.isEvmAddress)(n)}}),[e,t]),s=r?.find(n=>n.isEVM)?.address??null;return{accounts:r,evmAccount:s,primaryAccount:e[0]??null,isConnected:t,count:e.length}}var zt=require("@naculus/connect-core"),ue=require("react");function Pr({managers:e}){let t=(0,ue.useRef)(e);t.current=e;let r=(0,ue.useRef)(0),s=(0,ue.useRef)(!0),[n,c]=(0,ue.useState)([]),[i,h]=(0,ue.useState)(!1),[u,l]=(0,ue.useState)(null);(0,ue.useEffect)(()=>()=>{s.current=!1,r.current+=1},[]);let g=(0,ue.useCallback)(async()=>{let a=++r.current;h(!0),l(null);try{let p=await(0,zt.listAuthorizations)(t.current);s.current&&a===r.current&&c(p)}catch(p){s.current&&a===r.current&&l(p instanceof Error?p:new Error("Failed to list authorizations"))}finally{s.current&&a===r.current&&h(!1)}},[]);(0,ue.useEffect)(()=>{g()},[g]);let o=(0,ue.useCallback)(async a=>{try{let p=await(0,zt.revokeListedAuthorization)(t.current,a);return await g(),p}catch(p){let d=p instanceof Error?p:new Error("Failed to revoke authorization");throw s.current&&l(d),d}},[g]);return{entries:n,loading:i,error:u,refresh:g,revoke:o}}var ot=require("@naculus/connect-appkit-core"),Q=require("react");var st=require("viem"),Wr=require("@naculus/connect-core");function Or(e){let{evmAccount:t,isConnected:r}=K(),{chainId:s,chains:n}=I(),[c,i]=(0,Q.useState)(null),[h,u]=(0,Q.useState)(!1),[l,g]=(0,Q.useState)(null),[o,a]=(0,Q.useState)(null),p=e?.refreshInterval,d=(0,Q.useRef)(null),m=(0,Q.useMemo)(()=>(0,ot.resolveChain)(n,s),[s,n]),C=m?(0,ot.chainNumber)(m):null,E=(0,Q.useMemo)(()=>m?(0,ot.toViemChain)(m,C):null,[m,C]),A=(0,Q.useMemo)(()=>m?.token??null,[m]),[y,w]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!E||!m?.rpcUrl){w(null);return}let v=(0,st.createPublicClient)({transport:(0,st.http)(m.rpcUrl),chain:E});return w(v),()=>{}},[m,E]);let R=(0,Q.useCallback)(async()=>{if(!t||!y){i(null);return}u(!0),g(null);try{let b=t.includes(":")?t.split(":").pop():t,[U,W]=await Promise.all([y.getBalance({address:b}),s?(0,Wr.getNativeTokenPriceUsd)(s,m?.rpcUrl).catch(()=>null):Promise.resolve(null)]);i(U.toString()),a(W)}catch(v){g(v instanceof Error?v:new Error("Failed to fetch balance")),i(null),a(null)}finally{u(!1)}},[t,y,s,m?.rpcUrl]);(0,Q.useEffect)(()=>{r&&t&&R()},[r,t,R]),(0,Q.useEffect)(()=>(p&&p>0&&r&&t&&(d.current=setInterval(R,p)),()=>{d.current&&(clearInterval(d.current),d.current=null)}),[p,r,t,R]);let k=(0,Q.useMemo)(()=>{if(c===null)return null;try{return(0,st.formatEther)(BigInt(c))}catch{return null}},[c]),T=(0,Q.useMemo)(()=>{if(o===null||k===null)return null;let v=parseFloat(k);if(Number.isNaN(v))return null;let b=v*o;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(b)},[o,k]);return{balance:c,formatted:k,symbol:A,usdPrice:o,usdValue:T,isLoading:h,error:l,refetch:R,chain:m}}var at=require("@naculus/connect-appkit-core"),Pe=require("react");function _(e){return e??Kt()}function jt(){let{client:e,session:t,chainId:r}=I(),[s,n]=(0,Pe.useState)(null),[c,i]=(0,Pe.useState)(!1),[h,u]=(0,Pe.useState)(null),l=(0,Pe.useRef)(0),g=(0,Pe.useCallback)(async()=>{let o=++l.current,a=_(e);if(!a?.getCapabilities||!t){n(null),i(!1),u(null);return}i(!0),u(null);try{let p=await a.getCapabilities(t);if(o!==l.current)return;n((0,at.normalizeCapabilities)(p))}catch(p){if(o!==l.current)return;n(null),u(p instanceof Error?p:new Error("Capability query failed"))}finally{o===l.current&&i(!1)}},[e,t]);return(0,Pe.useEffect)(()=>{g()},[g]),{capabilities:s,current:(0,at.selectChainCapabilities)(s,r),atomic:(0,at.atomicSupportFor)(s,r),isFetching:c,error:h,refetch:g}}var $t=require("react"),it=require("@naculus/connect-appkit-core");function pe(){let{chainId:e,session:t,switchChain:r,chains:s}=I(),n=(0,$t.useMemo)(()=>(0,it.resolveChain)(s,e),[s,e]),c=(0,$t.useMemo)(()=>t?(0,it.describeChain)(s,e):null,[s,e,t]),i=(0,$t.useMemo)(()=>(0,it.chainsForNamespace)(s,e),[s,e]);return{chainId:e,currentChain:n,chainInfo:c,availableChains:i,chains:i,isEvm:e?.startsWith("eip155:")??!1,switchChain:r}}var Rt=require("react");var Nr=require("@naculus/connect-core");function _r(){let{connect:e,status:t}=I(),[r,s]=(0,Rt.useState)(!1),[n,c]=(0,Rt.useState)(null);return{connect:(0,Rt.useCallback)(async()=>{s(!0),c(null);try{await e()}catch(h){let u=h instanceof Error?h.message:"Connection failed";c(h instanceof Nr.WalletError?h:new Error(u))}finally{s(!1)}},[e]),isConnecting:r||t==="connecting",error:n}}var Dr=require("@naculus/connect-appkit-core"),Ke=require("@naculus/connect-core"),ne=require("react");var Xt=require("@naculus/connect-appkit-core"),Gt=require("react"),$e=require("viem");function de(){let{evmAccount:e,isConnected:t}=K(),{currentChain:r,chains:s}=pe(),n=r?(0,Xt.chainNumber)(r):null,c=(0,Gt.useMemo)(()=>r?(0,Xt.toViemChain)(r,n):null,[r,n]),i=(0,Gt.useMemo)(()=>c?(0,$e.createPublicClient)({transport:(0,$e.http)(c.rpcUrls.default.http[0]),chain:c}):null,[c]),h=(0,Gt.useMemo)(()=>{if(!t||!e||!c)return null;let u=e.includes(":")?e.split(":").pop():e;return(0,$e.createWalletClient)({transport:(0,$e.http)(c.rpcUrls.default.http[0]),chain:c,account:u})},[t,e,c]);return{publicClient:i,walletClient:h,chains:s}}function Mr(e){let{evmAccount:t}=K(),{session:r,chainId:s,client:n}=I(),{publicClient:c}=de(),[i,h]=(0,ne.useState)(null),[u,l]=(0,ne.useState)(!1),[g,o]=(0,ne.useState)(null),a=(0,ne.useRef)(0),p=(0,ne.useRef)(!1);(0,ne.useEffect)(()=>()=>{a.current+=1},[]),(0,ne.useEffect)(()=>{a.current+=1,h(null),l(!1),o(null)},[r,s,t]);let d=(0,ne.useCallback)(async(A,y)=>{let w=v=>(o(v),null);if(p.current)return w(new Error("A delegation is already in progress"));let R=(0,Dr.bareEvmAddress)(t);if(!r||!R||!s)return w(new Ke.WalletError("wallet_unavailable","No connected EVM account"));if(!c||c.chain?.id!==(0,Ke.eip155Reference)(s))return w(new Ke.WalletError("chain_mismatch",`No RPC client for ${s}; refusing to read the nonce elsewhere.`));let k=r.walletType==="embedded"?_(n)?.embeddedConnector??{}:{},T=++a.current;p.current=!0,l(!0),o(null),h(null);try{let v=await(0,Ke.delegateAccount)({connector:k,session:r,account:R,chainId:s,delegate:A,allowlist:y,getTransactionCount:(b,U)=>c.getTransactionCount({address:b,blockTag:U})});return T!==a.current?null:(h(v),v)}catch(v){return T!==a.current?null:w(v instanceof Error?v:new Error("Failed to send delegation"))}finally{p.current=!1,T===a.current&&l(!1)}},[s,n,t,c,r]),m=(0,ne.useCallback)(A=>d(A,e.allowlist),[d,e.allowlist]),C=(0,ne.useCallback)(()=>d(Ke.REVOKE_DELEGATE,[]),[d]),E=(0,ne.useCallback)(()=>{a.current+=1,h(null),l(!1),o(null)},[]);return{delegate:m,revoke:C,result:i,isPending:u,error:g,reset:E}}var Ge=require("@naculus/connect-appkit-core"),re=require("react");function Lr(e,t={}){let[r,s]=(0,re.useState)(0),[n,c]=(0,re.useState)(null),[i,h]=(0,re.useState)(null),u=(0,re.useRef)(0),l=(0,re.useRef)(0),g=(0,re.useRef)(e);g.current=e;let o=(0,re.useRef)(t);o.current=t;let a=(0,re.useRef)(0);(0,re.useEffect)(()=>()=>{u.current+=1,l.current+=1,a.current+=1},[]);let p=(0,re.useCallback)(async(m,C)=>{let E=++u.current,A=l.current;s(y=>y+1),h(null);try{let y=await g.current(m,C),w=(0,Ge.describePayment)(m,y);if(w&&A===l.current){let R=o.current.verify;if(!R)c(w);else{w=(0,Ge.applySettlementVerification)(w,{status:"pending"}),c(w);let k=++a.current,T=o.current.verifyRetry??Ge.DEFAULT_VERIFY_RETRY;Promise.resolve().then(async()=>{let v={status:"pending"};for(let b=0;b<T.attempts;b+=1){if(b>0&&await new Promise(U=>setTimeout(U,T.delayMs)),A!==l.current||k!==a.current)return;try{v=await R(y)}catch(U){v={status:"unavailable",reason:U instanceof Error?U.message:"Settlement verification failed"}}if(v.status!=="pending")break}A===l.current&&k===a.current&&c(b=>b&&(0,Ge.applySettlementVerification)(b,v))})}}return y}catch(y){let w=y instanceof Error?y:new Error("Paid request failed");throw E===u.current&&h(w),w}finally{s(y=>y-1)}},[]),d=(0,re.useCallback)(()=>{u.current+=1,l.current+=1,a.current+=1,c(null),h(null)},[]);return{payFetch:p,isPending:r>0,lastPayment:n,error:i,reset:d}}var Qt=require("@naculus/connect-appkit-core"),Br=require("@naculus/connector-evm-injected"),Fr=require("react");function Kr(){let{session:e,accounts:t,chainId:r,client:s,switchChain:n}=I(),c=t.join("\0");return(0,Fr.useMemo)(()=>{let i=(0,Qt.findX402Provider)(e,{injected:Br.eip6963Connector.getDiscoveredWallets(),walletConnect:s.connector});return(0,Qt.createX402WalletSigner)(e,i,n)},[e,c,r,s.connector,n])}var Ee=require("@naculus/connect-appkit-core"),q=require("react");function Hr(e){return e instanceof Error?e:new Error("MPP session operation failed")}function qr(e){let[t,r]=(0,q.useState)(0),[s,n]=(0,q.useState)(()=>e.meter.pending),[c,i]=(0,q.useState)(()=>(0,Ee.readCurrentMppSessionChannel)(e)),[h,u]=(0,q.useState)(null),[l,g]=(0,q.useState)(null),[o,a]=(0,q.useState)(null),p=(0,q.useRef)(0),d=(0,q.useRef)(0),m=(0,q.useRef)(!0),C=(0,q.useRef)(e);C.current=e,(0,q.useEffect)(()=>{p.current+=1,d.current+=1,r(0),n(e.meter.pending),i((0,Ee.readCurrentMppSessionChannel)(e)),u(null),g(null),a(null)},[e]),(0,q.useEffect)(()=>()=>{m.current=!1,p.current+=1,d.current+=1},[]);let E=(0,q.useCallback)(async(v,b,U=!1)=>{let W=++p.current,D=d.current,B=C.current;r(f=>f+1),a(null);try{let f=await v(B);if(m.current&&D===d.current){b?.(f);let S=(0,Ee.readCurrentMppSessionChannel)(B);i(S),n(B.meter.pending),(U||!S)&&g(null)}return f}catch(f){let S=Hr(f);if(m.current&&D===d.current){let x=(0,Ee.readCurrentMppSessionChannel)(B);i(x),n(B.meter.pending);let P=(0,Ee.readMppRecoveryChannelId)(f);P?g(P):x||g(null),W===p.current&&a(S)}throw S}finally{m.current&&D===d.current&&r(f=>f-1)}},[]),A=(0,q.useCallback)((v,b)=>E(U=>U(v,b),U=>{let W=(0,Ee.readMppSessionReceipt)(U.receipt);W&&u(W)}),[E]),y=(0,q.useCallback)(()=>E(v=>v.close(),v=>{let b=(0,Ee.readMppSessionReceipt)(v.receipt);b&&u(b)},!0),[E]),w=(0,q.useCallback)(()=>E(v=>v.forceClose(),void 0,!0),[E]),R=(0,q.useCallback)(v=>{try{C.current.meter.add(v),n(C.current.meter.pending),a(null)}catch(b){let U=Hr(b);throw a(U),g((0,Ee.readMppRecoveryChannelId)(b)),U}},[]),k=(0,q.useCallback)(()=>{p.current+=1,d.current+=1,r(0),n(C.current.meter.pending),i((0,Ee.readCurrentMppSessionChannel)(C.current)),u(null),g(null),a(null)},[]),T=(0,q.useMemo)(()=>({add:R}),[R]);return{fetch:A,meter:T,pending:s,channel:c,lastReceipt:h,recoveryChannelId:l,isPending:t>0,error:o,close:y,forceClose:w,reset:k}}var zr=require("@naculus/connect-appkit-core"),oe=require("react");function Vr(){return Promise.reject(new Error("No Solana session key manager is connected"))}function jr(e){let[t,r]=(0,oe.useState)([]),[s,n]=(0,oe.useState)(0),[c,i]=(0,oe.useState)(null),h=(0,oe.useRef)(0),u=e?.manager,l=e?.rpc,g=e?.owner,o=(0,oe.useMemo)(()=>u&&l&&g?(0,zr.createSolanaSessionKeyFlow)({manager:u,rpc:l,owner:g}):null,[u,l,g]),a=(0,oe.useCallback)(async(C,E)=>{let A=++h.current;n(y=>y+1),i(null);try{return await C()}catch(y){let w=y instanceof Error?y:new Error(E);throw A===h.current&&i(w),w}finally{if(o&&A===h.current){let y=await o.list().catch(()=>null);y&&A===h.current&&r(y)}n(y=>y-1)}},[o]),p=(0,oe.useCallback)(async()=>{if(!o){r([]);return}let C=h.current,E=await o.list();C===h.current&&r(E)},[o]);(0,oe.useEffect)(()=>(h.current+=1,p().catch(()=>{}),()=>{h.current+=1}),[p]);let d=(0,oe.useCallback)(C=>o?a(()=>o.create(C),"Could not create the key"):Vr(),[o,a]),m=(0,oe.useCallback)(C=>o?a(()=>o.revoke(C),"Could not revoke the key"):Vr(),[o,a]);return{keys:t,create:d,revoke:m,refresh:p,isPending:s>0,error:c}}var lt=require("@naculus/connect-core"),We=require("react");function ct(){let{publicClient:e}=de(),{evmAccount:t}=K(),[r,s]=(0,We.useState)(lt.UNKNOWN_DELEGATION),[n,c]=(0,We.useState)(!1),[i,h]=(0,We.useState)(null),u=(0,We.useRef)(0),l=t?.includes(":")?t.split(":").pop():t,g=(0,We.useCallback)(async()=>{let o=++u.current;if(!e||!l){s(lt.UNKNOWN_DELEGATION),c(!1),h(null);return}c(!0),h(null);try{let a=await e.getCode({address:l});if(o!==u.current)return;s((0,lt.readDelegation)(a??"0x"))}catch(a){if(o!==u.current)return;s(lt.UNKNOWN_DELEGATION),h(a instanceof Error?a:new Error("Code read failed"))}finally{o===u.current&&c(!1)}},[e,l]);return(0,We.useEffect)(()=>{g()},[g]),{...r,isFetching:n,error:i,refetch:g}}var pt=require("@naculus/connect-appkit-core"),se=require("react"),Zr=require("viem");var Zt=require("@naculus/connect-core");var Xe=require("react");var he=require("@naculus/connect-core"),Re=require("react");var $r=require("@naculus/connect-core");function Yt(e){let t=typeof e=="string"?e:e&&typeof e=="object"&&"hash"in e?e.hash:void 0;if(typeof t=="string"&&/^0x[0-9a-fA-F]{64}$/.test(t))return t;throw new $r.WalletError("tx_failed","Wallet did not return a valid 32-byte transaction hash")}function Jt(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,Re.useState)("idle"),[c,i]=(0,Re.useState)(null),[h,u]=(0,Re.useState)(null),[l,g]=(0,Re.useState)(null),[o,a]=(0,Re.useState)(null),p=(0,Re.useCallback)(async(E,A)=>{if(!e){n("failed");let y=new he.WalletError("wallet_unavailable","No active session");throw i(y),y}if(E.length===0){n("failed");let y=new he.WalletError("invalid_input","At least one call is required");throw i(y),y}n("awaiting_approval"),i(null),u(null);try{let y=_(r);if(!y)throw new he.WalletError("wallet_unavailable","Client not initialized");let w=A?.chainId??t??void 0,R=A?.strategy??(0,he.chooseExecutionStrategy)(await(0,he.getAccountCapabilities)(y,e,w),E.length);if(a(R),R==="atomic-batch"){let T=await y.sendCalls(e,E,w,{atomicRequired:!0,...A?.paymasterService?{paymasterService:A.paymasterService}:{}});return n("submitted"),u(T),T}let k="";for(let T=0;T<E.length;T++){let v=E[T];try{k=Yt(await y.sendTransaction(e,{transaction:{to:v.to,data:v.data,value:v.value},chainId:w}))}catch(b){throw new he.WalletError("tx_failed",`Call ${T+1} of ${E.length} failed after ${T} already landed (sent sequentially \u2014 this wallet cannot batch atomically): ${b instanceof Error?b.message:String(b)}`)}}return n("submitted"),u(k),k}catch(y){n("failed");let w=y instanceof Error?y.message:"sendCalls failed";throw i(y instanceof Error?y:new Error(w)),y}},[e,t,r]),d=(0,Re.useCallback)(async E=>{if(!e)throw new he.WalletError("wallet_unavailable","No active session");let A=E??h;if(!A)throw new he.WalletError("invalid_input","No bundle hash available");if(!E&&o==="sequential")throw new he.WalletError("invalid_input","Calls were sent sequentially, so there is no bundle to query. Track the returned transaction hash instead.");let y=_(r);if(!y)throw new he.WalletError("wallet_unavailable","Client not initialized");let w=await y.getCallsStatus(e,A);return g(w),w},[e,h,r,o]),m=(0,Re.useCallback)(async E=>{if(!e)return!1;let A=E??h;if(!A||!E&&o==="sequential")return!1;let y=_(r);if(!y?.showCallsStatus)return!1;try{return await y.showCallsStatus(e,A),!0}catch{return!1}},[e,h,r,o]),C=(0,Re.useCallback)(()=>{n("idle"),i(null),u(null),g(null),a(null)},[]);return{sendCalls:p,getCallsStatus:d,showCallsStatus:m,status:s,error:c,batchHash:h,callsStatus:l,execution:o,reset:C,isSending:s==="awaiting_approval"}}function en(e={}){let{current:t,atomic:r}=jt(),{delegated:s,delegate:n}=ct(),{sendCalls:c}=Jt(),[i,h]=(0,Xe.useState)(!1),[u,l]=(0,Xe.useState)(null),[g,o]=(0,Xe.useState)(null),a=e.atomicity??"preferred",p=e.sponsorship??"any",d=e.paymasterService,m=e.userOperation,C=e.userOperationSponsored??!1,E=!!(t?.raw?.paymasterService?.supported&&d),A=(0,Xe.useCallback)((w,R=a)=>{let k=(0,Zt.planExecution)({atomicBatch:r==="supported",discovered:r!=="unknown",sponsoredTransactions:!1,...t?.maxBatchSize===void 0?{}:{maxBatchSize:t.maxBatchSize}},w,{atomicity:R,sponsorship:p}),T=p==="required"&&!C;if(k.strategy==="atomic-batch"&&!T)return{...k,reason:k.reason+(E?" A paymaster service will be requested, but the wallet's final fee payer must be checked after execution.":""),route:"wallet-batch"};let v=s&&r!=="supported"?` This account does delegate to ${n} under EIP-7702, so it is capable of batching even though the wallet has not offered to.`:"",b=R!=="any"&&!k.atomic||p==="required";return m&&b&&!T?{strategy:"atomic-batch",atomic:!0,sponsored:C,reason:p==="required"&&!k.sponsored?"The wallet batch is not configured for sponsored gas, so the calls are executed through the configured sponsored UserOperation route.":"This wallet cannot batch, so the calls are executed as a single UserOperation through the smart account, which lands as one transaction.",route:"user-operation"}:T?{strategy:"refuse",atomic:k.atomic,sponsored:!1,reason:"Sponsored gas was required, but there is no executable sponsored route: no paymaster is configured for a wallet batch, and capability advertising alone cannot pay for a sequential transaction.",route:null}:k.strategy==="refuse"?{...k,reason:k.reason+v,route:null}:{...k,reason:k.reason+v,route:"sequential"}},[r,t,E,m,C,a,p,s,n]),y=(0,Xe.useCallback)(async(w,R=a)=>{h(!0),l(null);try{let k=A(w.length,R);if(k.route===null)throw new Zt.WalletError("method_not_allowed",k.reason);return o(k.route),k.route==="user-operation"?await m(w):await c(w,{strategy:k.route==="wallet-batch"?"atomic-batch":"sequential",...k.route==="wallet-batch"&&E?{paymasterService:d}:{}})}catch(k){let T=k instanceof Error?k:new Error("Execution failed");throw l(T),T}finally{h(!1)}},[A,c,m,a,d,E]);return{preview:A,execute:y,isExecuting:i,error:u,lastRoute:g,reset:()=>{l(null),o(null)}}}var tn=require("@naculus/connect-appkit-core"),Gr=require("@naculus/connect-core"),H=require("react");function ut(e){return(0,tn.getSharedSessionKeyManager)(e)}function nn(e){let{session:t}=I(),[r,s]=(0,H.useState)([]),[n,c]=(0,H.useState)(!1),[i,h]=(0,H.useState)(null),u=(0,H.useRef)(!0),l=(0,H.useCallback)(()=>h(null),[]),g=ut(e),o=g.isStorageAvailable(),a=(0,H.useCallback)(async()=>{if(!t){s([]);return}c(!0),h(null);try{let d=await g.listSessions();u.current&&s(d)}catch(d){u.current&&h(d instanceof Error?d:new Error("Failed to load session keys"))}finally{u.current&&c(!1)}},[t,g]);(0,H.useEffect)(()=>(u.current=!0,a(),()=>{u.current=!1}),[a]);let p=r.filter(d=>d.status==="active");return{sessions:r,activeSessions:p,loading:n,error:i,refresh:a,clearError:l,storageAvailable:o}}function Xr(e){let{session:t}=I(),[r,s]=(0,H.useState)(null),[n,c]=(0,H.useState)(!1),[i,h]=(0,H.useState)(null),u=(0,H.useCallback)(()=>h(null),[]),l=ut(e);return{createSessionKey:(0,H.useCallback)(async(o,a)=>{if(!t)throw new Gr.WalletError("wallet_unavailable","No active wallet session");c(!0),h(null);try{let p=a??void 0,d=await l.createSessionKey(o,p);return s(d),d}catch(p){let d=p instanceof Error?p:new Error("Failed to create session key");throw h(d),d}finally{c(!1)}},[t,l]),lastCreated:r,isCreating:n,error:i,clearError:u}}function Qr(e){let[t,r]=(0,H.useState)(!1),[s,n]=(0,H.useState)(null),c=(0,H.useCallback)(()=>n(null),[]),i=ut(e);return{revokeSession:(0,H.useCallback)(async u=>{r(!0),n(null);try{await i.revokeSession(u)}catch(l){let g=l instanceof Error?l:new Error("Failed to revoke session key");throw n(g),g}finally{r(!1)}},[i]),isRevoking:t,error:s,clearError:c}}function Yr(e){let[t,r]=(0,H.useState)(!1),[s,n]=(0,H.useState)(null),c=(0,H.useCallback)(()=>n(null),[]),i=ut(e),h=(0,H.useCallback)(async(l,g,o)=>{r(!0),n(null);try{return await i.signWithSessionKey(l,g,o)}catch(a){let p=a instanceof Error?a:new Error("Failed to sign with session key");throw n(p),p}finally{r(!1)}},[i]),u=(0,H.useCallback)(async(l,g)=>{r(!0),n(null);try{return await i.checkSessionScope(l,g)}catch(o){let a=o instanceof Error?o:new Error("Failed to check session scope");throw n(a),a}finally{r(!1)}},[i]);return{signWithSession:h,checkScope:u,isBusy:t,error:s,clearError:c}}function Jr(){(0,tn.resetSharedSessionKeyManager)()}var Tt=require("react");var rn=require("@naculus/connect-core");function on(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,Tt.useState)(!1),[c,i]=(0,Tt.useState)(null);return{signMessage:(0,Tt.useCallback)(async u=>{if(!e){let g=new rn.WalletError("wallet_unavailable","No active session");throw i(g),g}let l=e.namespaces.eip155?.accounts[0]??Object.values(e.namespaces)[0]?.accounts[0];if(!l){let g=new rn.WalletError("wallet_unavailable","No account found");throw i(g),g}n(!0),i(null);try{let g=_(r);if(!g)throw new rn.WalletError("wallet_unavailable","Client not initialized");return await g.signMessage(e,{message:u,address:l,chainId:t??void 0})}catch(g){let o=g instanceof Error?g.message:"Signing failed",a=g instanceof Error?g:new Error(o);throw i(a),a}finally{n(!1)}},[e,t,r]),isSigning:s,error:c}}var or=require("@naculus/connect-appkit-core");function eo(e={}){let{evmAccount:t}=K(),r=(0,pt.bareEvmAddress)(t),s=ct(),n=en(e.execution),{signMessage:c}=on(),i=nn(e.managerConfig),h=ut(e.managerConfig),[u,l]=(0,se.useState)(!1),[g,o]=(0,se.useState)(null),[a,p]=(0,se.useState)(()=>new Set),[d,m]=(0,se.useState)(!1),C=e.origin??(typeof window<"u"?window.location.origin:"unknown"),E=!!e.managerConfig?.encryptionKey,A=e.execution?.sponsorship,{refresh:y,storageAvailable:w}=i,{preview:R}=n,{delegated:k,delegate:T}=s,v=(0,se.useMemo)(()=>(0,pt.createDelegationPolicyFlow)({manager:h,origin:C,signer:()=>r,signMessage:c,verifySignature:async({message:S,signature:x,signerAddress:P})=>(await(0,Zr.recoverMessageAddress)({message:S,signature:x})).toLowerCase()===P.toLowerCase(),previewExecution:R,sponsorship:A,adapter:e.adapter,signTypedData:e.signTypedData,chainId:()=>e.chainId??null,delegation:()=>({delegated:k,delegate:T}),encryptionKeyConfigured:E,storageAvailable:()=>w,refresh:y}),[h,C,r,c,R,A,e.adapter,e.signTypedData,e.chainId,k,T,E,w,y]);(0,se.useEffect)(()=>{let S=!1,x=i.sessions.filter(pt.isVerifiablePolicy);return x.length===0?(p(new Set),m(!1),()=>{S=!0}):(m(!0),Promise.all(x.map(async P=>[P.id,await v.verifyStoredPolicy(P)])).then(P=>{S||p(new Set(P.filter(([,O])=>O).map(([O])=>O)))}).catch(P=>{S||(p(new Set),o(P instanceof Error?P:new Error("Policy verification failed")))}).finally(()=>{S||m(!1)}),()=>{S=!0})},[i.sessions,v]);let b=(0,se.useCallback)(()=>{o(null),i.clearError()},[i]),U=(0,se.useCallback)(async(S,x)=>{l(!0),o(null);try{return await S()}catch(P){let O=P instanceof Error?P:new Error(x);throw o(O),O}finally{l(!1)}},[]),W=(0,se.useCallback)(S=>U(()=>v.createPolicy(S),"Policy creation failed"),[v,U]),D=(0,se.useCallback)(S=>U(()=>v.revokePolicy(S),"Policy revocation failed"),[v,U]),B=(0,se.useCallback)((S,x)=>U(()=>v.executePolicy(S,x),"Policy execution failed"),[v,U]),f=i.activeSessions.filter(S=>a.has(S.id));return{policies:i.sessions,activePolicies:f,storageAvailable:i.storageAvailable,loading:i.loading||d,isBusy:u,error:g??i.error,delegation:s,createPolicy:W,revokePolicy:D,previewPolicyExecution:v.previewPolicyExecution,signPolicyDigest:v.signPolicyDigest,executePolicy:B,refresh:i.refresh,clearError:b}}var Qe=require("react");function to(){let{disconnect:e,status:t}=I(),[r,s]=(0,Qe.useState)(!1),[n,c]=(0,Qe.useState)(null),i=(0,Qe.useRef)(!0);return{disconnect:(0,Qe.useCallback)(async()=>{if(t!=="disconnected"){s(!0),c(null);try{await e()}catch(u){if(!i.current)return;c(u instanceof Error?u:new Error("Disconnect failed"))}finally{i.current&&s(!1)}}},[e,t]),isDisconnecting:r,error:n,cleanup:()=>{i.current=!1}}}var sn=require("@naculus/connect-core"),$=require("react");function qe(e){let t=e.activeNamespace??"eip155",r=Array.isArray(e.accounts)?e.accounts.map(({namespace:s,address:n,derivationPath:c})=>({namespace:s,address:n,...c?{derivationPath:c}:{}})):e.address?[{namespace:t,address:e.address}]:[];return{accounts:r,activeNamespace:t,createdAt:e.createdAt??0,...e.chainId?{chainId:e.chainId}:{},...e.version?{version:e.version}:{},recoveryAvailable:!!e.mnemonic,address:r.find(s=>s.namespace===t)?.address??e.address}}function no(){let{connectEmbedded:e,client:t}=I(),[r,s]=(0,$.useState)(null),n=(0,$.useRef)(null),c=(0,$.useRef)(4),i=(0,$.useRef)(!1),h=(0,$.useRef)(null),[u,l]=(0,$.useState)(!1),[g,o]=(0,$.useState)(!1),[a,p]=(0,$.useState)(null),d=()=>p(null),m=(0,$.useCallback)(()=>{let f=n.current;return n.current=null,f},[]),C=(0,$.useCallback)(()=>{let f=_(t);if(!f?.embeddedConnector)throw new sn.WalletError("wallet_unavailable","Embedded wallet not enabled.");return f.embeddedConnector},[t]),E=(0,$.useCallback)(()=>{try{return C().getWallet()?.privateKey??null}catch{return null}},[C]),A=(0,$.useCallback)(async()=>{let f=_(t);if(!f)throw new sn.WalletError("wallet_unavailable","Embedded wallet not enabled.");let S=f.getEmbeddedConnector?await f.getEmbeddedConnector():f.embeddedConnector;if(!S)throw new sn.WalletError("wallet_unavailable","Embedded wallet not enabled.");return S},[t]),y=(0,$.useCallback)(()=>{try{return _(t)?.passphraseGate??null}catch{return null}},[t]),w=(0,$.useCallback)(f=>{f?.code==="decryption_failed"&&y()?.forget("That passphrase did not open the wallet.")},[y]),R=(0,$.useCallback)(async()=>{i.current=!1,p(null);try{let f=await A();if(!await f.load())return!1;let x=f.getWallet();return x?(n.current=null,l(!1),s(qe(x)),!0):!1}catch(f){return i.current=!0,w(f),p(f instanceof Error?f:new Error("Failed to restore embedded wallet")),!1}},[w,A]);(0,$.useEffect)(()=>{let f=!1,S=null;return R().then(x=>{f||x||i.current||(S=setTimeout(()=>{f||R()},100))}),()=>{f=!0,S&&clearTimeout(S)}},[R]);let k=async()=>{o(!0),p(null);try{let f=await A(),S=await f.load(),x=f.getWallet();S&&x&&(s(qe(x)),n.current=x.mnemonic||null,l(!x.mnemonic)),await e();let P=f.getWallet();P&&(s(qe(P)),P.mnemonic&&!S&&(n.current=P.mnemonic,l(!0)))}catch(f){w(f),p(f instanceof Error?f:new Error("Embedded wallet connection failed"))}finally{o(!1)}},T=async()=>{o(!0),p(null);try{let f=await A();y()?.expect("create");let S=await f.generateWallet();return s(qe(S)),n.current=S.mnemonic,l(!0),S}catch(f){return p(f instanceof Error?f:new Error("Failed to generate wallet")),null}finally{o(!1)}},v=async f=>{o(!0),p(null);try{let S=await A();y()?.expect("create");let x=await S.importFromMnemonic(f);return s(qe(x)),n.current=null,l(!1),x}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{o(!1)}},b=async f=>{o(!0),p(null);try{let S=await A();y()?.expect("create");let x=await S.importFromPrivateKey(f);return s(qe(x)),n.current=null,l(!1),x}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{o(!1)}},U=async()=>{o(!0),p(null);try{await(await A()).wipe(),s(null),n.current=null,l(!1)}catch(f){p(f instanceof Error?f:new Error("Failed to wipe wallet"))}finally{o(!1)}},W=(0,$.useCallback)(f=>{let S=C();S.setActiveNamespace(f);let x=S.getWallet();s(x?qe(x):null)},[C]),D=(0,$.useCallback)(async()=>{let f=await A(),S=await f.backfillAccounts();if(S.length>0){let x=f.getWallet();s(x?qe(x):null)}return S.map(({namespace:x,address:P,derivationPath:O})=>({namespace:x,address:P,...O?{derivationPath:O}:{}}))},[A]),B=()=>{n.current=null,l(!1)};return{connectEmbedded:k,restoreWallet:R,generateWallet:T,importFromMnemonic:v,importFromPrivateKey:b,wipe:U,wallet:r,hasWallet:r!==null,address:r?.address??null,accounts:r?.accounts??[],activeNamespace:r?.activeNamespace??null,setActiveNamespace:W,backfillAccounts:D,seedPhrase:n.current,getSeedPhrase:m,getPrivateKey:E,backupPending:u,confirmBackup:B,isBusy:g,error:a,clearError:d,storageSecurityLevel:(()=>{try{let f=C(),S=f.getStorageSecurityLevel?.()??4;return f.getWallet()?(c.current=S,S):r?c.current:S}catch{return r?c.current:4}})(),securityReport:(()=>{let f=null;try{f=C().getStorageSecurityReport?.()??null}catch{f=null}if(!f)return h.current=null,null;let S=JSON.stringify(f);return h.current?.json===S?h.current.value:(h.current={json:S,value:f},f)})()}}var so=require("@naculus/connect-appkit-core"),ke=require("react");var ro=require("@naculus/connect-core"),we=require("react"),oo=require("@naculus/connect-appkit-core");function zs(e){return[e.token.address.toLowerCase(),e.token.chainId??"",e.token.decimals??"",e.chainId??"",e.owner??"",e.spender??"",e.connected?"1":"0",e.publicClient?"1":"0",e.walletClient?"1":"0",e.session?.id??""].join("|")}function dt(e){let{token:t,chainId:r}=e,s=t.address.toLowerCase(),n=zs(e),c=(0,we.useMemo)(()=>({key:n}),[n]),i=(0,we.useRef)(n),h=(0,we.useRef)(!0);(0,we.useLayoutEffect)(()=>{i.current=n},[n]),(0,we.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let u=(0,we.useCallback)(()=>h.current&&i.current===n,[n]),l=(0,we.useCallback)(()=>{if(!u())throw new ro.WalletError("session_inactive","Wallet or token context changed. Retry the operation with the current account and chain.");let g=(0,oo.tokenChainMismatch)({address:s,chainId:t.chainId},r);if(g)throw g},[u,s,t.chainId,r]);return{identity:c,isCurrent:u,assertCurrent:l}}var an=require("@naculus/connect-core");function ao(e){let{publicClient:t}=de(),{currentChain:r}=pe(),{identity:s,isCurrent:n,assertCurrent:c}=dt({token:e.token,chainId:r?(0,so.chainNumber)(r)??void 0:void 0,owner:e.owner,spender:e.spender,publicClient:t}),[i,h]=(0,ke.useState)(null),u=i?.identity===s?i.raw:null,l=i?.identity===s&&i.fetching,g=i?.identity===s?i.error:null,o=(0,ke.useRef)(null),a=(0,ke.useRef)(0),p=(0,ke.useCallback)(async()=>{if(!n())return;let m=++a.current,C=()=>n()&&m===a.current;if(h({identity:s,raw:null,fetching:!!t,error:null}),!!t)try{c();let E=await t.readContract({address:e.token.address,abi:an.ERC20_MIN_ABI,functionName:"allowance",args:[e.owner,e.spender]});if(!C())return;h({identity:s,raw:E,fetching:!1,error:null})}catch(E){if(!C())return;h({identity:s,raw:null,fetching:!1,error:E instanceof Error?E:new Error("Failed to fetch allowance")})}},[t,e.token.address,e.token.chainId,e.owner,e.spender,s,n,c]);return(0,ke.useEffect)(()=>{p().catch(m=>console.warn("useERC20Allowance: initial fetch failed:",m))},[p]),(0,ke.useEffect)(()=>(e.refreshInterval&&e.refreshInterval>0&&(o.current=setInterval(p,e.refreshInterval)),()=>{o.current&&(clearInterval(o.current),o.current=null)}),[e.refreshInterval,p]),{allowance:(0,ke.useMemo)(()=>{if(u===null)return null;let m=e.token.decimals;return m===void 0?null:(0,an.formatUnits)(u,m)},[u,e.token.decimals]),allowanceRaw:u,isFetching:l,error:g,refetch:p}}var ye=require("@naculus/connect-appkit-core"),ae=require("@naculus/connect-core"),ve=require("react");var ln=require("@naculus/connect-core"),mt=require("react");function ft(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,mt.useState)("idle"),[c,i]=(0,mt.useState)(null),h=(0,mt.useCallback)(async l=>{if(!e){n("failed");let o=new ln.WalletError("wallet_unavailable","No active session");throw i(o),o}let g=e.namespaces.eip155?.accounts.find(o=>/^eip155:\d+:0x[0-9a-fA-F]{40}$/.test(o)||/^0x[0-9a-fA-F]{40}$/.test(o));if(!g){n("failed");let o=new ln.WalletError("wallet_unavailable","No EVM account found");throw i(o),o}n("awaiting_approval"),i(null);try{let o={...l,from:l.from??g.split(":").pop()},a=_(r);if(!a)throw new ln.WalletError("wallet_unavailable","Client not initialized");let p=await a.sendTransaction(e,{transaction:o,chainId:t??void 0}),d=Yt(p);return n("submitted"),d}catch(o){n("failed");let a=o instanceof Error?o.message:"Transaction failed";throw i(o instanceof Error?o:new Error(a)),o}},[e,t,r]),u=(0,mt.useCallback)(()=>{n("idle"),i(null)},[]);return{sendTransaction:h,status:s,error:c,reset:u,isSending:s==="awaiting_approval"}}function js(e){return e.includes(":")?e.split(":").pop():e}var $s=2n**256n-1n;function io(e){let{publicClient:t,walletClient:r}=de(),{evmAccount:s,isConnected:n}=K(),{currentChain:c}=pe(),{session:i,client:h}=I(),{sendTransaction:u,isSending:l,error:g,reset:o}=ft(),[a,p]=(0,ve.useState)(null),{identity:d,isCurrent:m,assertCurrent:C}=dt({token:e.token,chainId:c?(0,ye.chainNumber)(c)??void 0:void 0,owner:s,spender:e.spender,connected:n,publicClient:t,walletClient:r,session:i,client:h}),[E,A]=(0,ve.useState)(null),y=E?.identity===d?E.raw:null,w=E?.identity===d&&E.fetching,R=(0,ve.useRef)((0,ye.createDecimalsCache)(e.token,e.token.decimals)),k=(0,ve.useRef)(0),T=a??g,v=s?js(s):null,b=(0,ve.useCallback)(async()=>{if(!m())return null;let S=++k.current,x=()=>m()&&S===k.current;if(A({identity:d,raw:null,fetching:!!t&&!!v&&n}),p(null),!t||!v||!n)return null;try{C();let P=await t.readContract({address:e.token.address,abi:ae.ERC20_MIN_ABI,functionName:"allowance",args:[v,e.spender]});return x()?(A({identity:d,raw:P,fetching:!1}),P):null}catch(P){return x()&&(A({identity:d,raw:null,fetching:!1}),p(P instanceof Error?P:new Error("Failed to fetch allowance"))),null}},[t,v,e.token.address,e.token.chainId,e.spender,d,m,C,n]),U=(()=>{if(y===null)return null;let S=(0,ye.readDecimals)(R.current,e.token,e.token.decimals);return S===void 0?null:(0,ae.formatUnits)(y,S)})(),W=(0,ve.useCallback)(async S=>{if(p(null),o(),!n||!s){let x=new ae.WalletError("wallet_unavailable","No connected account");throw p(x),x}if(!t){let x=new ae.WalletError("wallet_unavailable","No public client");throw p(x),x}try{C();let x=(0,ye.encodeErc20Approve)(e.spender,S),P=_(h);if(i&&P){let z=await u({to:e.token.address,data:x,value:"0"});return b(),z}if(r){let{request:z}=await t.simulateContract({address:e.token.address,abi:ae.ERC20_MIN_ABI,functionName:"approve",args:[e.spender,S],account:v});C();let je=await r.writeContract(z);return b(),je}let O=await u({to:e.token.address,data:x,value:"0"});return b(),O}catch(x){let P=x instanceof Error?x:new Error("Approve failed");throw m()&&p(P),P}},[e,t,r,s,n,i,h,v,u,o,b,C,m]),D=(0,ve.useCallback)(async S=>{try{if(C(),!t)throw new ae.WalletError("wallet_unavailable","No public client");let x=(0,ye.readDecimals)(R.current,e.token,e.token.decimals);x===void 0&&(x=await t.readContract({address:e.token.address,abi:ae.ERC20_MIN_ABI,functionName:"decimals"}),C(),(0,ye.writeDecimals)(R.current,e.token,x));let P=(0,ae.parseUnits)(S,x);return await W(P)}catch(x){throw m()&&p(x instanceof Error?x:new Error("Approve failed")),x}},[e.token,t,W,C,m]),B=(0,ve.useCallback)(async()=>W($s),[W]),f=(0,ve.useCallback)(async S=>{if(!m()||!n||!v||!t)return!1;try{C()}catch(z){return p(z instanceof Error?z:new Error("Cannot check allowance")),!1}let x=y??await b();if(x===null)return!1;let P=(0,ye.readDecimals)(R.current,e.token,e.token.decimals);if(P===void 0){if(!t)throw new ae.WalletError("wallet_unavailable","Cannot check allowance: no public client to read token decimals.");if(P=await t.readContract({address:e.token.address,abi:ae.ERC20_MIN_ABI,functionName:"decimals"}),!m())return!1;(0,ye.writeDecimals)(R.current,e.token,P)}let O=(0,ae.parseUnits)(S,P);return m()&&x>=O},[y,b,e.token.address,e.token.chainId,e.token.decimals,t,m,C,n,v]);return{approve:D,approveMax:B,allowance:U,allowanceRaw:y,hasAllowance:f,isApproving:l,isFetchingAllowance:w,error:T,refetchAllowance:b}}var Oe=require("@naculus/connect-appkit-core"),Ve=require("@naculus/connect-core"),gt=require("react");function Gs(e){return e.includes(":")?e.split(":").pop():e}function lo(e){let{publicClient:t,walletClient:r}=de(),{evmAccount:s,isConnected:n}=K(),{currentChain:c}=pe(),{session:i,client:h}=I(),{sendTransaction:u,isSending:l,error:g,reset:o}=ft(),[a,p]=(0,gt.useState)(null),{isCurrent:d,assertCurrent:m}=dt({token:e.token,chainId:c?(0,Oe.chainNumber)(c)??void 0:void 0,owner:s,connected:n,publicClient:t,walletClient:r,session:i,client:h}),C=(0,gt.useRef)((0,Oe.createDecimalsCache)(e.token,e.token.decimals)),E=a??g;return{sendTransfer:(0,gt.useCallback)(async(y,w)=>{if(p(null),o(),!n||!s){let R=new Ve.WalletError("wallet_unavailable","No connected account");throw p(R),R}if(!t){let R=new Ve.WalletError("wallet_unavailable","No public client available");throw p(R),R}try{m();let R=Gs(s),k=(0,Oe.readDecimals)(C.current,e.token,e.token.decimals);k===void 0&&(k=await t.readContract({address:e.token.address,abi:Ve.ERC20_MIN_ABI,functionName:"decimals"}),m(),(0,Oe.writeDecimals)(C.current,e.token,k));let T=(0,Ve.parseUnits)(w,k),v=(0,Oe.encodeErc20Transfer)(y,T),b=_(h);if(i&&b)return await u({to:e.token.address,data:v,value:"0"});if(r){let{request:W}=await t.simulateContract({address:e.token.address,abi:Ve.ERC20_MIN_ABI,functionName:"transfer",args:[y,T],account:R});return m(),await r.writeContract(W)}return await u({to:e.token.address,data:v,value:"0"})}catch(R){let k=R instanceof Error?R:new Error("Transfer failed");throw d()&&p(k),k}},[e.token,t,r,s,n,i,h,u,o,m,d]),isSending:l,error:E}}var un=require("@naculus/connect-appkit-core"),uo=require("@naculus/connect-core"),po=require("react");var co=require("@naculus/connect-appkit-core"),Te=require("react");function cn(e,t){I();let{evmAccount:r}=K(),{currentChain:s}=pe(),{publicClient:n}=de(),[c,i]=(0,Te.useState)(void 0),[h,u]=(0,Te.useState)(!1),[l,g]=(0,Te.useState)(null),o=(0,Te.useRef)(void 0),a=(0,Te.useCallback)(async()=>{e&&(u(!0),g(null));try{let d=await(0,co.simulateTransactionPreview)(e,{chainId:t,currentChain:s,publicClient:n,evmAccount:r});return i(d),d}catch(d){let m=d instanceof Error?d:new Error("Simulation failed");throw g(m),m}finally{e&&u(!1)}},[e,t,s,n,r]);(0,Te.useEffect)(()=>{if(e)return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{a().catch(()=>{})},300),()=>{o.current&&clearTimeout(o.current)}},[e,a]);let p=(0,Te.useCallback)(()=>{i(void 0),g(null),u(!1)},[]);return{result:c,isSimulating:h,error:l,simulate:a,reset:p}}function mo(e){let{evmAccount:t,isConnected:r}=K(),{currentChain:s}=pe(),n=e.token.chainId??(s?(0,un.chainNumber)(s)??void 0:void 0),c=(0,po.useMemo)(()=>{if(!(!r||!t))try{let h=e.token.decimals;if(h===void 0)return;let u=(0,uo.parseUnits)(e.amount,h),l=(0,un.encodeErc20Transfer)(e.to,u);return{to:e.token.address,data:l,value:"0"}}catch{return}},[e.token.address,e.token.decimals,e.to,e.amount,t,r]),i=cn(c,n);return{result:c?i.result:void 0,isSimulating:!!c&&i.isSimulating,error:c?i.error:null,reSimulate:i.simulate,reset:i.reset}}var Ne=require("react");var xe=require("react"),pn=require("react"),sr=(0,pn.createContext)(null);function It(){return(0,pn.useContext)(sr)}function fo(e,t,r){let s=It(),n=r??s,[c,i]=(0,xe.useState)(null),[h,u]=(0,xe.useState)(!1),[l,g]=(0,xe.useState)(!1),[o,a]=(0,xe.useState)(null),p=(0,xe.useRef)(void 0),d=(0,xe.useCallback)(async()=>{if(!(!n||!e)){u(!0),a(null);try{await n.refreshTx(e,t);let E=n.getTxStatus(e,t);E&&i(E)}catch(E){a(E instanceof Error?E:new Error(String(E)))}finally{u(!1)}}},[n,e,t]),m=(0,xe.useCallback)(()=>{!n||!e||(n.stopWatching(e,t),g(!1))},[n,e,t]);(0,xe.useEffect)(()=>{if(!n||!e||!t){i(null),g(!1);return}p.current&&p.current!==e&&n.stopWatching(p.current),p.current=e;let E=!1;g(!0),u(!0),a(null);let A=n.getTxStatus(e,t);A&&(i(A),u(!1)),n.watchTx(e,t,{}).then(w=>{E||(i(w),u(!1))}).catch(w=>{E||(a(w instanceof Error?w:new Error(String(w))),u(!1))});let y=w=>{E||i({...w})};return n.on("statusChange",y),()=>{E=!0,g(!1),n.off("statusChange",y)}},[n,e,t]);let C=c?.status??"idle";return{entry:c,status:C,isLoading:h,isWatching:l,error:o,refresh:d,stopWatching:m}}function go(e){let t=It(),r=e??t,[s,n]=(0,Ne.useState)(null),[c,i]=(0,Ne.useState)(null),[h,u]=(0,Ne.useState)(null),l=(0,Ne.useRef)(null),g=(0,Ne.useRef)(null),o=(0,Ne.useRef)(null);r&&(g.current||(g.current=p=>{i(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},r.on("confirmed",g.current)),o.current||(o.current=p=>{u(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},r.on("failed",o.current)));let a=(0,Ne.useCallback)(()=>{n(null),i(null),u(null),l.current=null},[]);return{lastTx:s,lastConfirmedTx:c,lastFailedTx:h,clear:a}}var yo=require("react");var me=require("react"),ho=require("@naculus/connect-appkit-core");function dn({input:e,skip:t=!1,resolverConfig:r,scope:s,query:n}){let[c,i]=(0,me.useState)(null),[h,u]=(0,me.useState)(!1),[l,g]=(0,me.useState)(null),o=(0,me.useRef)(0),a=(0,me.useRef)(!0);(0,me.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let p=(0,me.useMemo)(()=>(0,ho.getResolver)(r),[r]),d=(0,me.useCallback)(()=>{let m=e.trim();if(!m||t){o.current+=1,i(null),u(!1),g(null);return}let C=++o.current;u(!0),g(null),n(p,m,s).then(E=>{!a.current||C!==o.current||(i(E),u(!1))}).catch(E=>{!a.current||C!==o.current||(g(E instanceof Error?E:new Error(String(E))),i(null),u(!1))})},[e,t,s,p,n]);return(0,me.useEffect)(()=>{d()},[d]),{data:c,isLoading:h,error:l,refetch:d}}function Co(e,t){let r=(0,yo.useCallback)((s,n,c)=>s.lookupAddress(n,c),[]);return dn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,scope:t?.chainId,query:r})}var G=require("react"),j=require("@naculus/connect-appkit-core"),So=require("@naculus/connect-core");function Eo(e){let t=(0,G.useRef)(null);t.current||(t.current=e?.channel??new So.InAppChannel);let r=t.current,[s,n]=(0,G.useState)(()=>r.getHistory()),[c,i]=(0,G.useState)(()=>j.DEFAULT_NOTIFICATION_SETTINGS),h=(0,G.useRef)([]);(0,G.useEffect)(()=>{let y=e?.storage??(0,j.createNotificationSettingsStorage)(),w=R=>{let k=h.current??[];if(h.current=null,k.length===0){R&&i(R);return}i(()=>{let T=(0,j.replayNotificationSettings)(R,k);return(0,j.saveNotificationSettings)(y,T),T})};(0,j.loadNotificationSettings)(y).then(w,()=>w(null))},[]),(0,G.useEffect)(()=>(r.onNotification=y=>{n(w=>[...w,y])},r.restore().then(()=>{n(r.getHistory())}),()=>{r.onNotification=void 0}),[]);let u=(0,G.useMemo)(()=>s.filter(y=>!y.read).length,[s]),l=(0,G.useCallback)(()=>{r.clear(),n([])},[r]),g=(0,G.useCallback)(y=>{(0,j.clearOneInAppNotification)(r,y).then(()=>{n(r.getHistory())})},[r]),o=(0,G.useCallback)(y=>{r.markAsRead(y),n(w=>w.map(R=>R.id===y?{...R,read:!0}:R))},[r]),a=(0,G.useCallback)(()=>{r.markAllAsRead(),n(y=>y.map(w=>({...w,read:!0})))},[r]),p=(0,G.useCallback)(y=>{(0,j.addInAppNotification)(r,y)},[r]),d=(0,G.useCallback)(y=>{h.current?.push(y),i(w=>{let R=(0,j.updateNotificationSettings)(w,y(w)),k=e?.storage??(0,j.createNotificationSettingsStorage)();return(0,j.saveNotificationSettings)(k,R),R})},[e?.storage]),m=(0,G.useCallback)(y=>d(()=>y),[d]),C=(0,G.useCallback)(y=>{m((0,j.channelsUpdate)(y))},[m]),E=(0,G.useCallback)(y=>{d(w=>(0,j.mutedChainSettings)(w,y,!0))},[d]),A=(0,G.useCallback)(y=>{d(w=>(0,j.mutedChainSettings)(w,y,!1))},[d]);return{notifications:s,unreadCount:u,addNotification:p,clear:l,clearOne:g,markAsRead:o,markAllAsRead:a,settings:c,updateSettings:m,setChannels:C,muteChain:E,unmuteChain:A}}var ht=require("react");var wo=()=>null,Xs=()=>()=>{};function ko(){let{client:e}=I(),t=_(e)?.passphraseGate??null,r=(0,ht.useSyncExternalStore)(t?.subscribe??Xs,t?.getSnapshot??wo,wo),s=(0,ht.useCallback)(i=>t?.submit(i),[t]),n=(0,ht.useCallback)(()=>t?.cancel(),[t]),c=(0,ht.useCallback)(i=>t?.forget(i),[t]);return{request:r,submit:s,cancel:n,forget:c,isUnlocked:t?.isUnlocked??!1,gate:t}}var vo=require("react");function xo(e,t){let r=(0,vo.useCallback)((s,n)=>s.resolveName(n),[]);return dn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,query:r})}var _e=require("@naculus/connect-appkit-core"),Ye=require("@naculus/connect-core"),ie=require("react");async function Qs(e,t,r,s,n){let c=_(t);if(!c)throw new Ye.WalletError("wallet_unavailable","Client not initialized");let i=[r,s];if(e.walletType==="eip6963"||e.id?.startsWith("eip6963-")){let{eip6963Connector:h}=await import("@naculus/connector-evm-injected"),u=h.getDiscoveredWallets().find(g=>g.id===e.walletId),l=u?await u.provider.request({method:"personal_sign",params:i}):await h.request({method:"personal_sign",params:i});return(0,_e.assertHexSignature)(l)}if(e.walletType==="walletconnect")return(0,_e.assertHexSignature)(await c.connector.request({method:"personal_sign",params:i}));if(e.walletType==="embedded"){let h=c.embeddedConnector;if(!h?.signHash)throw new Ye.WalletError("method_unsupported","This embedded wallet build cannot sign a raw digest. Upgrade @naculus/connector-embedded or pass an explicit signer.");return(0,_e.assertHexSignature)(await h.signHash(e,r))}throw e.walletType==="passkeys"?new Ye.WalletError("method_unsupported","Passkeys sign with P-256, which a SimpleAccount cannot verify. Use a smart account with a WebAuthn validator, or pass an explicit signer."):new Ye.WalletError("method_unsupported",`Raw UserOperation signing is not available for ${e.walletType} on ${n}. Pass a signer that signs the raw 32-byte hash.`)}function Ao(e){let{evmAccount:t}=K(),{session:r,chainId:s,client:n}=I(),[c,i]=(0,ie.useState)(null),[h,u]=(0,ie.useState)(null),[l,g]=(0,ie.useState)(!1),[o,a]=(0,ie.useState)(!1),[p,d]=(0,ie.useState)(null),m=(0,ie.useRef)(0),C=(0,ie.useRef)(!1);(0,ie.useEffect)(()=>()=>{m.current+=1,C.current=!1},[]),(0,ie.useEffect)(()=>{m.current+=1,C.current=!1,i(null),u(null),g(!1),a(!1),d(null)},[n,s,t,e?.accountType,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.owner,e?.rpcUrl,e?.salt,e?.signerMode,r]);let E=(0,ie.useCallback)(async(y,w)=>{let R=b=>(d(b),null);if(!e?.rpcUrl)return R(new Error("RPC URL not configured"));if(!e.bundlerUrl)return R(new Error("Bundler URL not configured"));if(!y.length)return R(new Error("At least one call is required"));if(C.current)return R(new Error("A UserOperation is already in progress"));let k=(0,_e.bareEvmAddress)(e.owner??t);if(!k)return R(new Ye.WalletError("wallet_unavailable","No EVM account found"));let T;try{T=(0,_e.resolveUserOpChain)(e.chainId,s)}catch(b){return R(b)}if(!e.signer&&!r)return R(new Ye.WalletError("wallet_unavailable","No active session"));let v=++m.current;C.current=!0,g(!0),a(!0),d(null),i(null),u(null);try{let{SmartAccountManager:b}=await import("@naculus/connect-core"),U=e.signer??(f=>Qs(r,n,f,k,T)),W=new b({rpcUrl:e.rpcUrl,bundlerClient:{url:e.bundlerUrl},chainId:T,signer:U,signerMode:e.signer?e.signerMode??"eip191":"raw"}),D=(0,_e.buildSmartAccountConfig)(k,T,e),B=await W.sendUserOperation(D,y,w);return v!==m.current?null:(a(!1),i(B.userOpHash),W.getUserOperationReceipt(B.userOpHash).then(f=>{v===m.current&&u(f)}).catch(()=>{}),B)}catch(b){if(v!==m.current)return null;let U=b instanceof Error?b:new Error("Failed to send UserOperation");return d(U),null}finally{C.current=!1,v===m.current&&(g(!1),a(!1))}},[n,s,t,e,r]),A=(0,ie.useCallback)(()=>{m.current+=1,i(null),u(null),g(!1),a(!1),d(null)},[]);return{sendUserOp:E,userOpHash:c,receipt:h,isPending:l,isEstimating:o,error:p,reset:A}}var Ut=require("react");function Ys(e,t){if(!e)return()=>{};let r=()=>t();return e.on("sessionConnected",r),e.on("sessionDisconnected",r),e.on("chainChanged",r),e.on("sessionScopeChanged",r),e.on("sessionRevoked",r),()=>{e.off("sessionConnected",r),e.off("sessionDisconnected",r),e.off("chainChanged",r),e.off("sessionScopeChanged",r),e.off("sessionRevoked",r)}}var ar=Object.freeze({session:null,chainSessions:[],activeChainId:null,isConnected:!1,connectorId:null}),ir=new WeakMap;function Js(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function Zs(e){if(!e)return ar;let t=e.getActiveBundle(),r=ir.get(e);if(!t)return r&&r.session===null?r:(ir.set(e,ar),ar);let s=Array.from(t.chainSessions.values());if(r&&r.session===t.walletSession&&r.activeChainId===t.activeChainId&&Js(r.chainSessions,s))return r;let n={session:t.walletSession,chainSessions:s,activeChainId:t.activeChainId,isConnected:!0,connectorId:t.walletSession.walletType};return ir.set(e,n),n}function bo(e){let t=I(),r=e??t.sessionManager??null,s=(0,Ut.useCallback)(c=>Ys(r,c),[r]),n=(0,Ut.useCallback)(()=>Zs(r),[r]);return(0,Ut.useSyncExternalStore)(s,n)}var mn=require("@naculus/connect-appkit-core"),Pt=require("@naculus/connect-core"),De=require("@naculus/siwx"),yt=require("react");var ea=86400;function fn(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,yt.useState)(!1),[c,i]=(0,yt.useState)(null),h=(0,yt.useCallback)(()=>i(null),[]);return{signIn:(0,yt.useCallback)(async l=>{if(!e)throw new Pt.WalletError("wallet_unavailable","No active session");let g=l?.chainId??t;if(!g)throw new Pt.WalletError("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let o=rt(e,g);if(!o)throw new Pt.WalletError("wallet_unavailable","No account found");let a=_(r);if(!a)throw new Pt.WalletError("wallet_unavailable","Client not initialized");let{address:p}=o,d=typeof window>"u"?void 0:window.location,m=l?.domain??(0,mn.defaultSiwxDomain)(d),C=l?.uri??(0,mn.defaultSiwxUri)(d);n(!0),i(null);try{let E=(0,De.generateNonce)();await(0,De.issueNonce)(E);let A=(0,De.nowISO)(),y=l?.expirySeconds??ea,w=new Date(Date.now()+y*1e3).toISOString(),R=(0,De.createSiwxMessage)({domain:m,address:p,uri:C,version:1,chainId:g,nonce:E,issuedAt:A,expirationTime:w,statement:l?.statement,resources:l?.resources,requestId:l?.requestId}),k=await a.signMessage(e,{message:R,address:p,chainId:g??void 0}),T={message:{raw:R,domain:m,address:p,statement:l?.statement??null,uri:C,version:1,chainId:g,nonce:E,issuedAt:A,blockchain:(0,De.getBlockchainName)(g),expirationTime:w,notBefore:null,resources:l?.resources??[],requestId:l?.requestId??null},signature:k};return n(!1),T}catch(E){let A=E instanceof Error?E:new Error("SIWx sign-in failed");throw i(A),n(!1),A}},[e,t,r]),isSigningIn:s,error:c,clearError:h}}var lr=require("@naculus/connect-appkit-core"),gn=require("@naculus/connect-core"),Wt=require("@naculus/siwx"),le=require("react");function Ro(e){let{storagePrefix:t="naculus_",autoRestore:r=!0,defaultExpirySeconds:s=86400}=e??{},[n,c]=(0,le.useState)(null),[i,h]=(0,le.useState)(r),[u,l]=(0,le.useState)(!1),[g,o]=(0,le.useState)(null),{chainId:a}=I(),p=fn(),d=(0,le.useRef)((0,Wt.createLocalStorageSiwxSessionStorage)(`${t}siwx_session`)),m=(0,le.useCallback)(()=>o(null),[]);(0,le.useEffect)(()=>{if(!r){h(!1);return}let k=!1;return(async()=>{try{let v=await d.current.get();if(k)return;v?(gn.logger.info("react/useSIWxSession","Restored persisted SIWx session"),c(v),o(null)):c(null)}catch(T){gn.logger.warn("react/useSIWxSession","Failed to restore SIWx session:",T),c(null)}finally{k||h(!1)}})(),()=>{k=!0}},[r]),(0,le.useEffect)(()=>{if(!n?.expiresAt)return;let k=new Date(n.expiresAt).getTime()-Date.now();if(k<=0){c(null);return}let T=setTimeout(()=>{c(v=>v&&v.id===n.id?null:v)},k);return()=>clearTimeout(T)},[n?.id,n?.expiresAt]);let C=(0,le.useCallback)(async k=>{l(!0),o(null);try{let T={expirySeconds:s,chainId:a??void 0,...k},v=await p.signIn(T),b=(0,lr.siwxResultToSession)(v);return await d.current.set(b),c(b),l(!1),b}catch(T){let v=T instanceof Error?T:new Error("SIWx sign-in failed");throw o(v),l(!1),v}},[p,a,s]),E=(0,le.useCallback)(async()=>{try{await d.current.remove()}catch(k){gn.logger.warn("react/useSIWxSession","Failed to clear session:",k)}c(null),o(null)},[]),A=(0,le.useCallback)(async()=>{if(!n)throw new Error("No active session to refresh");l(!0),o(null);try{let k=await p.signIn({domain:n.domain,statement:n.message.statement??void 0,uri:n.message.uri,chainId:n.chainId,expirySeconds:s,resources:n.message.resources.length>0?n.message.resources:void 0,requestId:n.message.requestId??void 0}),T={...(0,lr.siwxResultToSession)(k),id:n.id,refreshedAt:new Date().toISOString()};return await d.current.set(T),c(T),l(!1),T}catch(k){let T=k instanceof Error?k:new Error("Session refresh failed");throw o(T),l(!1),T}},[n,p,s]),y=n!==null&&!(0,Wt.checkSessionExpired)(n),w=(0,Wt.checkSessionExpired)(n),R=n?.expiresAt?Math.max(0,new Date(n.expiresAt).getTime()-Date.now()):null;return{session:y?n:null,isAuthenticated:y,isRestoring:i,isSigningIn:u,isExpired:w,timeUntilExpiry:R,signIn:C,signOut:E,refresh:A,error:g,clearError:m}}var hn=require("@naculus/connect-appkit-core"),Ot=require("@naculus/connect-core"),Me=require("@naculus/siwx"),Je=require("react");function Ct(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,Je.useState)(!1),[c,i]=(0,Je.useState)(null),[h,u]=(0,Je.useState)(null),l=(0,Je.useCallback)(()=>u(null),[]);return{signIn:(0,Je.useCallback)(async o=>{if(!e)throw new Ot.WalletError("wallet_unavailable","No active session");let a=o?.chainId??t;if(!a)throw new Ot.WalletError("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let p=rt(e,a);if(!p)throw new Ot.WalletError("wallet_unavailable","No account found");let d=_(r);if(!d)throw new Ot.WalletError("wallet_unavailable","Client not initialized");let{address:m}=p,C=typeof window>"u"?void 0:window.location,E=o?.domain??(0,hn.defaultSiwxDomain)(C),A=o?.uri??(0,hn.defaultSiwxUri)(C);n(!0),u(null);try{let y=(0,Me.generateNonce)();await(0,Me.issueNonce)(y);let w=(0,Me.nowISO)(),R=(0,Me.createSiwxMessage)({domain:E,address:m,uri:A,version:1,chainId:a,nonce:y,issuedAt:w,statement:o?.statement,expirationTime:o?.expirySeconds?new Date(Date.now()+o.expirySeconds*1e3).toISOString():void 0,resources:o?.resources,requestId:o?.requestId}),k=await d.signMessage(e,{message:R,address:m,chainId:a??void 0}),T=o?.expirySeconds?new Date(Date.now()+o.expirySeconds*1e3).toISOString():null,v={message:{raw:R,domain:E,address:m,statement:o?.statement??null,uri:A,version:1,chainId:a,nonce:y,issuedAt:w,blockchain:(0,Me.getBlockchainName)(a),expirationTime:T,notBefore:null,resources:o?.resources??[],requestId:o?.requestId??null},signature:k};return i(v),v}catch(y){let w=y instanceof Error?y:new Error("SIWx sign-in failed");throw u(w),w}finally{n(!1)}},[e,t,r]),isSigningIn:s,result:c,error:h,clearError:l}}var yn=require("@naculus/connect-core");var cr=require("react");function ta(){let{session:e,chainId:t}=I();return(0,cr.useCallback)(r=>{if(!e)throw new yn.WalletError("wallet_unavailable","No active session");let s=r??t;if(s&&!s.startsWith("eip155:"))throw new yn.WalletError("namespace_mismatch",`Ethereum SIWx requires an eip155 chain, received ${s}`);let n=e.namespaces.eip155;if(!n||n.accounts.length===0)throw new yn.WalletError("namespace_mismatch","No EVM (eip155) accounts found in session")},[e,t])}function To(){let e=ta(),t=Ct();return{signIn:(0,cr.useCallback)(async s=>(e(s?.chainId),t.signIn(s)),[e,t.signIn]),isSigningIn:t.isSigningIn,result:t.result,error:t.error,clearError:t.clearError}}var Io=require("@naculus/connect-appkit-core"),Uo=require("@naculus/wallet-engine"),Le=require("react");function Po(e){let t=e?.rpcUrl,r=e?.chainId,s=(0,Le.useRef)(null),n=(0,Le.useCallback)(()=>(s.current||(s.current=new Uo.SimulationManager({enabled:!0,rpcUrl:t,autoSimulate:!1})),s.current),[t]),[c,i]=(0,Le.useState)(null),[h,u]=(0,Le.useState)(!1),[l,g]=(0,Le.useState)(null),o=(0,Le.useCallback)(async(p,d,m,C,E)=>{u(!0),g(null);try{let A=n(),y=(0,Io.resolveSimulationEndpoint)(E?.chainId,r,E?.rpcUrl,t),w=await A.simulateERC20Transfer(p,d,m,C,y.chainId,E?.decimals,y.rpcUrl);return i(w),w}catch(A){let y=A instanceof Error?A:new Error(String(A));throw g(y),y}finally{u(!1)}},[t,r,n]),a=(0,Le.useCallback)(()=>{i(null),g(null),u(!1)},[]);return{result:c,loading:h,error:l,simulate:o,reset:a}}var Sn=require("@naculus/connect-appkit-core"),Ze=require("@naculus/connect-core"),Ce=require("react");var Cn="siwx_auth";function na(e){return new Ze.LocalStorageAdapter(e)}function Wo(e){let{storagePrefix:t="naculus_",autoRestore:r=!0}=e??{},[s,n]=(0,Ce.useState)(null),[c,i]=(0,Ce.useState)(r),[h,u]=(0,Ce.useState)(!1),[l,g]=(0,Ce.useState)(null),o=Ct(),a=(0,Ce.useRef)(na(t)),p=(0,Ce.useCallback)(()=>g(null),[]);(0,Ce.useEffect)(()=>{if(!r){i(!1);return}let C=!1;return(async()=>{try{let E=a.current,A=await E.get(Cn);if(C)return;A&&!(0,Sn.isSiwxExpired)(A,new Date)&&(0,Sn.isSiwxNotBeforeValid)(A,new Date)?(Ze.logger.info("react/useSiwxAuthSession","Restored persisted SIWx auth session"),n(A),g(null)):A&&(Ze.logger.info("react/useSiwxAuthSession","Persisted SIWx auth expired, clearing"),await E.remove(Cn))}catch(E){Ze.logger.warn("react/useSiwxAuthSession","Failed to restore SIWx auth:",E)}finally{C||i(!1)}})(),()=>{C=!0}},[r]);let d=(0,Ce.useCallback)(async C=>{u(!0),g(null);try{let E=await o.signIn(C);return await a.current.set(Cn,E),n(E),u(!1),E}catch(E){let A=E instanceof Error?E:new Error("SIWx sign-in failed");throw g(A),u(!1),A}},[o]),m=(0,Ce.useCallback)(async()=>{try{await a.current.remove(Cn)}catch(C){Ze.logger.warn("react/useSiwxAuthSession","Failed to clear SIWx auth:",C)}n(null),g(null)},[]);return{isSignedIn:s!==null,isRestoring:c,siwxResult:s,isSigningIn:h,error:l,signIn:d,signOut:m,clearError:p}}var et=require("@naculus/connect-appkit-core"),ur=require("@naculus/connect-core"),X=require("react");function Oo(e){return new ur.WalletError("wallet_unavailable",e)}function No(e){let{evmAccount:t}=K(),{session:r,chainId:s,client:n}=I(),[c,i]=(0,X.useState)(null),[h,u]=(0,X.useState)(!1),[l,g]=(0,X.useState)(null),[o,a]=(0,X.useState)(!1),[p,d]=(0,X.useState)(null),m=(0,X.useRef)(null),C=(0,X.useRef)(0),E=(0,X.useRef)(!1);(0,X.useEffect)(()=>{if(m.current=null,!e?.rpcUrl)return;let b=!1;return import("@naculus/connect-core").then(({SmartAccountManager:U})=>{if(b)return;let W=(0,et.resolveEvmChainId)(e.chainId,s);W&&(m.current=new U({rpcUrl:e.rpcUrl,chainId:W,bundlerClient:{url:e.bundlerUrl??""}}))}).catch(U=>{b||d(U instanceof Error?U:new Error("Failed to load account-abstraction module"))}),()=>{b=!0}},[s,e?.rpcUrl,e?.bundlerUrl,e?.chainId]),(0,X.useEffect)(()=>{C.current+=1,E.current=!1,i(null),u(!1),g(null),a(!1),d(null)},[t,s,e?.rpcUrl,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.accountType,e?.salt]);let A=(0,X.useCallback)(()=>{let b=(0,et.bareEvmAddress)(t);if(!b||!m.current)return null;let U=(0,et.resolveEvmChainId)(e?.chainId,s);return U?(0,et.buildSmartAccountConfig)(b,U,{accountType:e?.accountType,entryPoint:e?.entryPoint,salt:e?.salt}):null},[t,s,e?.accountType,e?.chainId,e?.entryPoint,e?.salt]),y=(0,X.useCallback)(b=>(d(b),null),[]),w=(0,X.useCallback)(()=>E.current?null:(E.current=!0,C.current),[]),R=(0,X.useCallback)(b=>{C.current===b&&(E.current=!1)},[]),k=(0,X.useCallback)(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));let U=w();if(U===null)return y(new Error("Smart account operation already in progress"));a(!0),d(null);try{let D=await m.current.createAccount(b);return C.current!==U?null:(i(D.address),u(D.isDeployed),g(D),D)}catch(W){if(C.current!==U)return null;let D=W instanceof Error?W:new Error("Failed to create smart account");return d(D),null}finally{C.current===U&&a(!1),R(U)}},[w,y,R,A]),T=(0,X.useCallback)(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));if(!r)return y(Oo("No active session"));let U=_(n);if(!U)return y(Oo("Client not initialized"));if(s&&s!==b.chainId)return y(new ur.WalletError("chain_mismatch",`Connected chain ${s} does not match smart account chain ${b.chainId}.`));let W=w();if(W===null)return y(new Error("Smart account operation already in progress"));a(!0),d(null);try{let D=m.current,B=await D.createAccount(b);if(C.current!==W)return null;if(B.isDeployed)return i(B.address),u(!0),g(B),B.address;let f=await D.getDeployCallData(b),S=await U.sendTransaction(r,{transaction:{to:f.to,data:f.data,value:f.value.toString()},chainId:b.chainId});if(C.current!==W)return null;let x=await D.createAccount(b);return i(x.address),u(x.isDeployed),g(x),S}catch(D){if(C.current!==W)return null;let B=D instanceof Error?D:new Error("Failed to deploy smart account");return d(B),null}finally{C.current===W&&a(!1),R(W)}},[n,s,w,y,R,A,r]),v=(0,X.useCallback)(async()=>{let b=A();if(!b||!m.current)return null;let U=C.current;try{let W=await m.current.getAccountAddress(b);return C.current!==U?null:(i(W),W)}catch(W){return C.current!==U||d(W instanceof Error?W:new Error("Failed to get smart account address")),null}},[A]);return{address:c,isDeployed:h,accountInfo:l,isLoading:o,error:p,createWallet:k,deployWallet:T,getAddress:v}}var _o=require("react");function En(){let{accounts:e,isConnected:t}=I();return(0,_o.useMemo)(()=>{if(!t)return{address:null,caip10:null,chainId:null,isConnected:!1};let r=e.find(i=>i.startsWith("solana:"))??null;if(!r)return{address:null,caip10:null,chainId:null,isConnected:t};let s=r.split(":"),n=s.length>=3?s[s.length-1]:null,c=s.length>=3?s.slice(0,-1).join(":"):null;return{address:n,caip10:r,chainId:c,isConnected:t}},[e,t])}var Ie=require("react"),Do=require("@naculus/connect-core");function Mo(e={}){let{client:t}=I(),{address:r}=En(),s=e.address??r,n=e.rpcUrl??_(t)?.solanaRpcUrl??null,[c,i]=(0,Ie.useState)(null),[h,u]=(0,Ie.useState)(!1),[l,g]=(0,Ie.useState)(null),o=(0,Ie.useRef)(0),a=(0,Ie.useCallback)(async()=>{if(!s||!n){i(null);return}let p=++o.current;u(!0),g(null);try{let d=await(0,Do.getSolanaBalance)(n,s);if(p!==o.current)return;i(d)}catch(d){if(p!==o.current)return;i(null),g(d instanceof Error?d:new Error("Balance read failed"))}finally{p===o.current&&u(!1)}},[s,n]);return(0,Ie.useEffect)(()=>{a()},[a]),(0,Ie.useEffect)(()=>{if(!e.refreshInterval||e.refreshInterval<=0)return;let p=setInterval(()=>{a()},e.refreshInterval);return()=>clearInterval(p)},[e.refreshInterval,a]),{balance:c,isFetching:h,error:l,isConfigured:!!n,refetch:a}}var Lo=require("@naculus/connect-appkit-core"),Bo=require("react");function Fo(){let{client:e,session:t,accounts:r}=I();return(0,Bo.useMemo)(()=>{let s=_(e)?.solanaConnector,{roles:n,absence:c}=(0,Lo.readSolanaRoles)(s,t);return{roles:n,absence:c,identity:n?.identity??null,signer:n?.signer??null,payer:n?.payer??null}},[e,t,r])}var pr=require("@naculus/connect-core"),ze=require("react"),Ko=require("@naculus/connect-core");function Ho(){let{client:e,session:t}=I(),[r,s]=(0,ze.useState)(!1),[n,c]=(0,ze.useState)(!1),[i,h]=(0,ze.useState)(null),u=()=>{let a=_(e);if(!a||!t)throw new pr.WalletError("wallet_unavailable","No connected wallet.");return a},l=(0,ze.useCallback)(async a=>{s(!0),h(null);try{return await u().signTransaction(t,{transaction:a})}catch(p){let d=p instanceof Error?p:new Error("Signing failed");throw h(d),d}finally{s(!1)}},[e,t]),g=(0,ze.useCallback)(async a=>{c(!0),h(null);try{return await u().sendTransaction(t,{transaction:a})}catch(p){let d=p instanceof Error?p:new Error("Send failed");throw h(d),d}finally{c(!1)}},[e,t]),o=(0,ze.useCallback)(async a=>{let p=_(e)?.solanaRpcUrl;if(!p)throw new pr.WalletError("no_rpc","Set solanaRpcUrl on the client to read a signature's status.");return(0,Ko.getSignatureStatus)(p,a)},[e]);return{signTransaction:l,sendTransaction:g,getStatus:o,isSigning:r,isSending:n,error:i,reset:()=>h(null)}}var St=require("react"),qo=require("@naculus/connect-appkit-core");function Vo(){let{switchChain:e,chainId:t}=I(),[r,s]=(0,St.useState)(!1),[n,c]=(0,St.useState)(null),i=(0,St.useCallback)(async u=>{s(!0),c(null);try{await e(u)}catch(l){let g=(0,qo.toChainSwitchError)(l);throw c(g),g}finally{s(!1)}},[e]),h=(0,St.useCallback)(()=>{c(null)},[]);return{switchChain:i,isSwitching:r,currentChainId:t,error:n,clearError:h}}var Et=require("@naculus/connect-appkit-core"),J=require("react");var wt=require("viem"),ra=[{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"balance",type:"uint256"}]}];function zo(e){let{evmAccount:t,isConnected:r}=K(),{chainId:s,chains:n}=I(),[c,i]=(0,J.useState)([]),[h,u]=(0,J.useState)(!1),[l,g]=(0,J.useState)(null),{tokens:o,refreshInterval:a}=e,p=(0,J.useRef)(null),d=(0,J.useMemo)(()=>o.map(k=>k.address.toLowerCase()+"|"+k.decimals+"|"+k.symbol).join(","),[o]),m=(0,J.useMemo)(()=>(0,Et.resolveChain)(n,s),[s,n]),C=m?(0,Et.chainNumber)(m):null,E=(0,J.useMemo)(()=>m?(0,Et.toViemChain)(m,C):null,[m,C]),[A,y]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!E||!m?.rpcUrl){y(null);return}let k=(0,wt.createPublicClient)({transport:(0,wt.http)(m.rpcUrl),chain:E});y(k)},[m,E]);let w=(0,J.useCallback)(async()=>{if(!t||!A||o.length===0){i([]);return}u(!0),g(null);try{let k=t.includes(":")?t.split(":").pop():t,v=(await Promise.allSettled(o.map(async b=>{try{let U=await A.readContract({address:b.address,abi:ra,functionName:"balanceOf",args:[k]});return{address:b.address,symbol:b.symbol,decimals:b.decimals,name:b.name,balance:U.toString(),formatted:(0,wt.formatUnits)(U,b.decimals)}}catch{return{address:b.address,symbol:b.symbol,decimals:b.decimals,name:b.name,balance:null,formatted:null}}}))).map(b=>b.status==="fulfilled"?b.value:{address:"",symbol:"?",decimals:0,balance:null,formatted:null});i(v)}catch(k){g(k instanceof Error?k:new Error("Failed to fetch token balances"))}finally{u(!1)}},[t,A,d]);(0,J.useEffect)(()=>{r&&t&&o.length>0&&w()},[r,t,d,w]),(0,J.useEffect)(()=>(a&&a>0&&r&&t&&o.length>0&&(p.current=setInterval(w,a)),()=>{p.current&&(clearInterval(p.current),p.current=null)}),[a,r,t,d,w]);let R=(0,J.useCallback)(k=>c.find(T=>T.address.toLowerCase()===k.toLowerCase()),[c]);return{tokenBalances:c,isLoading:h,error:l,refetch:w,getTokenBalance:R,chain:m}}var Ue=require("react");function jo(e,t,r){let s=It(),n=r??s,[c,i]=(0,Ue.useState)([]),[h,u]=(0,Ue.useState)(!1),[l,g]=(0,Ue.useState)(null),o=(0,Ue.useRef)(0),a=(0,Ue.useCallback)(async()=>{if(n){u(!0),g(null),o.current++;try{let d=await n.getTxHistory(e,t);i(d)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{u(!1)}}},[n,e,t]);(0,Ue.useEffect)(()=>{a().catch(()=>{})},[a]),(0,Ue.useEffect)(()=>{if(!n)return;let d=()=>{a().catch(()=>{})};return n.on("statusChange",d),()=>{n.off("statusChange",d)}},[n,a]);let p={pending:c.filter(d=>d.status==="pending").length,confirmed:c.filter(d=>d.status==="confirmed").length,failed:c.filter(d=>d.status==="failed").length};return{entries:c,isLoading:h,error:l,refresh:a,summary:p}}var wn=require("@naculus/connect-appkit-core"),V=require("react");function $o(e){let t=e?.bundlerUrl,r=e?.pollInterval??2e3,s=e?.maxRetries??30,[n,c]=(0,V.useState)("idle"),[i,h]=(0,V.useState)(null),[u,l]=(0,V.useState)(e?.userOpHash??null),[g,o]=(0,V.useState)(null),[a,p]=(0,V.useState)(!1),[d,m]=(0,V.useState)(0),C=(0,V.useRef)(0),[E,A]=(0,V.useState)(0),y=(0,V.useRef)(null),w=(0,V.useRef)(null),R=(0,V.useRef)(0),k=(0,V.useRef)(0),T=(0,V.useRef)(null),v=(0,V.useCallback)(()=>{y.current&&(clearInterval(y.current),y.current=null),w.current&&(clearTimeout(w.current),w.current=null)},[]),b=(0,V.useCallback)(async(S,x)=>{if(!t||x!==R.current)return;let P=k.current+1;k.current=P,m(P);let O=new AbortController;T.current=O;let z=fe=>{x===R.current&&(c("not_found"),p(!1),v(),o(fe))},je=fe=>{if(x===R.current){if(P<=s){w.current=setTimeout(()=>{b(S,x)},r);return}z(fe)}};try{let fe=await(0,wn.fetchUserOperationReceipt)(t,S,O.signal);if(x!==R.current)return;if(fe){h(fe),c(fe.success?"confirmed":"failed"),p(!1),v();return}c("pending"),je(new Error("UserOperation not included after maximum retries"))}catch(fe){if(x!==R.current||O.signal.aborted)return;let xt=fe instanceof Error?fe:new Error("Unknown bundler response failure");if(xt instanceof wn.InvalidUserOperationReceiptError){z(xt);return}je(new Error(`UserOperation status unavailable after ${P} attempt${P===1?"":"s"}: ${xt.message}`))}finally{T.current===O&&(T.current=null)}},[t,r,s,v]),U=(0,V.useCallback)(S=>{R.current+=1;let x=R.current;if(T.current?.abort(),T.current=null,v(),l(S),h(null),o(null),k.current=0,m(0),A(0),C.current=Date.now(),!t){c("not_found"),p(!1),o(new Error("Bundler URL not configured"));return}c("pending"),p(!0),y.current=setInterval(()=>{A(Date.now()-C.current)},1e3),b(S,x)},[t,v,b]),W=(0,V.useCallback)(()=>{R.current+=1,T.current?.abort(),T.current=null,v(),p(!1)},[v]),D=(0,V.useCallback)(()=>{R.current+=1,T.current?.abort(),T.current=null,v(),l(null),c("idle"),h(null),o(null),p(!1),k.current=0,m(0),A(0)},[v]),B=e?.userOpHash??null,f=e?.autoStart!==!1;return(0,V.useEffect)(()=>{B&&f&&U(B)},[B,f,U]),(0,V.useEffect)(()=>()=>{R.current+=1,T.current?.abort(),T.current=null,v()},[v]),{status:n,receipt:i,userOpHash:u,error:g,isPolling:a,elapsedMs:E,attempts:d,start:U,stop:W,reset:D}}var Yo=require("@naculus/connect-appkit-core"),Jo=require("react");var oa={"storage.critical.title":"Insecure Storage Detected","storage.critical.body":"Your browser does not support IndexedDB. Wallet data is stored in plaintext in localStorage and could be exposed to XSS attacks. We strongly recommend switching to a modern browser.","storage.warning.title":"Storage Security Warning","storage.warning.body":"Your browser does not support IndexedDB, but your wallet data is encrypted with AES-256-GCM. Consider switching browsers for better origin isolation.","address.empty":"Address is empty","address.invalid_format":"Invalid address format (expected 0x + 40 hex chars)","address.zero_address":"Address is the zero address \u2014 funds would be permanently lost","address.burn_address":"Address appears to be a burn address \u2014 funds would be permanently lost","wallet.connect":"Connect Wallet","wallet.disconnect":"Disconnect","wallet.connecting":"Connecting...","wallet.copy_address":"Copy address","wallet.copied":"Copied!","wallet.view_on_explorer":"View on Explorer","wallet.retry":"Retry","wallet.connection_failed":"Connection failed","wallet.scan_qr":"Scan with your wallet app","embedded.generate":"Create Wallet","embedded.import":"Import Wallet","embedded.backup_seed":"Back up your seed phrase","embedded.backup_warning":"Anyone with your seed phrase can access your funds. Store it securely.","embedded.backup_done":"I've saved my seed phrase","embedded.wipe":"Remove Wallet","embedded.wipe_confirm":"Are you sure? This cannot be undone."},sa={"storage.critical.title":"\u5075\u6E2C\u5230\u4E0D\u5B89\u5168\u5132\u5B58","storage.critical.body":"\u60A8\u7684\u700F\u89BD\u5668\u4E0D\u652F\u63F4 IndexedDB\u3002\u9322\u5305\u8CC7\u6599\u4EE5\u660E\u6587\u5132\u5B58\u5728 localStorage \u4E2D\uFF0C\u53EF\u80FD\u66B4\u9732\u65BC XSS \u653B\u64CA\u3002\u5F37\u70C8\u5EFA\u8B70\u66F4\u63DB\u81F3\u73FE\u4EE3\u700F\u89BD\u5668\u3002","storage.warning.title":"\u5132\u5B58\u5B89\u5168\u8B66\u544A","storage.warning.body":"\u60A8\u7684\u700F\u89BD\u5668\u4E0D\u652F\u63F4 IndexedDB\uFF0C\u4F46\u9322\u5305\u8CC7\u6599\u5DF2\u4F7F\u7528 AES-256-GCM \u52A0\u5BC6\u3002\u5EFA\u8B70\u66F4\u63DB\u700F\u89BD\u5668\u4EE5\u7372\u5F97\u66F4\u597D\u7684\u9694\u96E2\u4FDD\u8B77\u3002","address.empty":"\u5730\u5740\u70BA\u7A7A","address.invalid_format":"\u7121\u6548\u7684\u5730\u5740\u683C\u5F0F\uFF08\u61C9\u70BA 0x + 40 \u500B\u5341\u516D\u9032\u4F4D\u5B57\u5143\uFF09","address.zero_address":"\u6B64\u70BA\u96F6\u5730\u5740 \u2014 \u8CC7\u91D1\u5C07\u6C38\u4E45\u4E1F\u5931","address.burn_address":"\u6B64\u5730\u5740\u70BA\u71D2\u6BC0\u5730\u5740 \u2014 \u8CC7\u91D1\u5C07\u6C38\u4E45\u4E1F\u5931","wallet.connect":"\u9023\u63A5\u9322\u5305","wallet.disconnect":"\u65B7\u958B\u9023\u7DDA","wallet.connecting":"\u9023\u7DDA\u4E2D...","wallet.copy_address":"\u8907\u88FD\u5730\u5740","wallet.copied":"\u5DF2\u8907\u88FD\uFF01","wallet.view_on_explorer":"\u5728\u700F\u89BD\u5668\u67E5\u770B","wallet.retry":"\u91CD\u8A66","wallet.connection_failed":"\u9023\u7DDA\u5931\u6557","wallet.scan_qr":"\u4F7F\u7528\u9322\u5305 App \u6383\u63CF","embedded.generate":"\u5EFA\u7ACB\u9322\u5305","embedded.import":"\u532F\u5165\u9322\u5305","embedded.backup_seed":"\u5099\u4EFD\u52A9\u8A18\u8A5E","embedded.backup_warning":"\u4EFB\u4F55\u4EBA\u53D6\u5F97\u60A8\u7684\u52A9\u8A18\u8A5E\u90FD\u53EF\u4EE5\u5B58\u53D6\u60A8\u7684\u8CC7\u91D1\u3002\u8ACB\u5B89\u5168\u5132\u5B58\u3002","embedded.backup_done":"\u6211\u5DF2\u5132\u5B58\u52A9\u8A18\u8A5E","embedded.wipe":"\u79FB\u9664\u9322\u5305","embedded.wipe_confirm":"\u78BA\u5B9A\u8981\u79FB\u9664\u55CE\uFF1F\u6B64\u64CD\u4F5C\u7121\u6CD5\u5FA9\u539F\u3002"},Go={en:oa,zh:sa},dr="en";function Xo(e){dr=e}function Qo(){return dr}function kn(e){return Go[dr][e]??Go.en[e]??e}function mr(e){let{isValid:t,level:r,issue:s}=(0,Yo.validateDestination)(e);return{isValid:t,level:r,warning:s?kn(`address.${s}`):null}}function Zo({address:e}){return{validation:(0,Jo.useMemo)(()=>mr(e),[e])}}function es(){let{status:e,session:t,accounts:r,chainId:s,error:n,connect:c,disconnect:i,reconnect:h,switchChain:u}=I(),l=e==="connected",g=e==="connecting",o=e==="reconnecting",a=r[0]??null;return{status:e,session:t,accounts:r,chainId:s,error:n,isConnected:l,isConnecting:g,isReconnecting:o,isDisconnected:e==="disconnected",currentAccount:a,connect:c,disconnect:i,reconnect:h,switchChain:u}}var tt=require("react");var fr={wallet_unavailable:"Wallet Not Detected",user_rejected:"Connection Rejected",deeplink_timeout:"Wallet Connection Timed Out",session_expired:"Session Expired",intent_expired:"Connection Request Expired",namespace_mismatch:"Network Mismatch",chain_unsupported:"Unsupported Network",method_not_allowed:"Action Not Allowed",signature_rejected:"Signature Rejected",tx_failed:"Transaction Failed"},gr={wallet_unavailable:"No wallet found. Please install a compatible wallet (e.g., MetaMask, WalletConnect) and try again.",user_rejected:"The connection request was declined in your wallet. You can try again whenever you're ready.",deeplink_timeout:"The wallet didn't respond in time. This can happen if the wallet app isn't installed or takes too long to open.",session_expired:"Your wallet session has expired. Please reconnect to continue.",intent_expired:"The connection request expired. Please try connecting again.",namespace_mismatch:"This wallet doesn't support the required network. Try using a different wallet or network.",chain_unsupported:"This network isn't supported. Please switch to a supported network in your wallet.",method_not_allowed:"This action isn't supported by your current wallet or network.",signature_rejected:"The signature request was declined in your wallet.",tx_failed:"The transaction couldn't be completed. This could be due to insufficient funds, network congestion, or a contract error."},Nt="Something went wrong",_t="An unexpected error occurred. Please try again. If the problem persists, check your connection and wallet configuration.";function kt(e){if(!e)return{title:Nt,description:_t};let t=e;if(t.name==="WalletError"&&t.code){let r=t.code,s=fr[r]??Nt,n=gr[r]??t.message??_t;return{title:s,description:n,code:r}}if(e instanceof Error){let r=e.message;return/user rejected/i.test(r)||/rejected/.test(r)?{title:"Request Rejected",description:"The request was declined.",code:"user_rejected"}:/timeout/i.test(r)||/timed? ?out/i.test(r)?{title:"Request Timed Out",description:"The request took too long. Please try again.",code:"deeplink_timeout"}:/insufficient funds/i.test(r)?{title:"Insufficient Funds",description:"You don't have enough funds to complete this transaction.",code:"tx_failed"}:/network/i.test(r)||/chain/i.test(r)?{title:"Network Error",description:r,code:"chain_unsupported"}:{title:Nt,description:r||_t}}return typeof e=="string"?{title:Nt,description:e||_t}:{title:Nt,description:_t}}function vn(e){if(e===null||typeof e!="object")return!1;let t=e;return t.name!=="WalletError"||!t.code?!1:["deeplink_timeout","session_expired","intent_expired","tx_failed"].includes(t.code)}function ts(){let{error:e,clearError:t}=I(),r=(0,tt.useMemo)(()=>e?kt(e):null,[e]),s=(0,tt.useMemo)(()=>e?vn(e):!1,[e]),n=(0,tt.useCallback)(()=>{t()},[t]),c=(0,tt.useCallback)(h=>kt(h),[]),i=(0,tt.useCallback)(h=>async()=>{try{return await h()}catch(u){let l=kt(u);if(u instanceof Error){let g=u;try{g.title=l.title,g.friendlyMessage=l.description,g.code===void 0&&l.code!==void 0&&(g.code=l.code)}catch{}throw g}throw Object.assign(new Error(l.description,{cause:u}),{title:l.title,code:l.code,friendlyMessage:l.description})}},[]);return{error:e,friendlyError:r,clearError:n,isRetryable:s,formatError:c,wrapAsync:i}}var Ae=require("react"),ns=require("@naculus/connect-core"),hr=require("@naculus/connect-appkit-core");function Dt(e,t){let r=(0,Ae.useRef)(null),[s,n]=(0,Ae.useState)([]),[c,i]=(0,Ae.useState)(t?.autoLoad!==!1),[h,u]=(0,Ae.useState)(!1),[l,g]=(0,Ae.useState)(null);if(!r.current){let p={};t?.sources&&(p.sources=t.sources),r.current=new ns.TokenListManager(p)}let o=(0,Ae.useCallback)(async()=>{let p=r.current;if(p){i(!0),g(null);try{await p.load();let d=e?(0,hr.eip155ChainIdToNumber)(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),u(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]),a=(0,Ae.useCallback)(async()=>{let p=r.current;if(p){i(!0),g(null);try{await p.refresh();let d=e?(0,hr.eip155ChainIdToNumber)(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),u(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]);return(0,Ae.useEffect)(()=>{t?.autoLoad!==!1&&o()},[o,t?.autoLoad]),{tokens:s,isLoading:c,isLoaded:h,error:l,refetch:a}}var nt=require("react"),os=require("@naculus/connect-core");var Be=require("@naculus/connect-core");function rs(){return[{name:"built-in",tokens:[...Be.ETHEREUM_MAINNET_TOKENS,...Be.POLYGON_TOKENS,...Be.OPTIMISM_TOKENS,...Be.ARBITRUM_TOKENS,...Be.BASE_TOKENS],enabled:!0},{name:"uniswap-default",url:"https://tokens.uniswap.org",enabled:!0,refreshInterval:1440*60*1e3}]}var ss=require("@naculus/connect-appkit-core"),aa=300,xn=null;function ia(){return xn||(xn=new os.TokenListManager({sources:rs()}),xn.load().catch(()=>{})),xn}function Mt(e,t){let[r,s]=(0,nt.useState)({exact:[],fuzzy:[],hasMore:!1}),[n,c]=(0,nt.useState)(!1),i=(0,nt.useRef)(null),h=e.trim();return(0,nt.useEffect)(()=>{if(!h){s({exact:[],fuzzy:[],hasMore:!1}),c(!1);return}return i.current&&clearTimeout(i.current),c(!0),i.current=setTimeout(()=>{let u=ia(),l=t?(0,ss.eip155ChainIdToNumber)(t):void 0,g=u.search(h,{chainId:l,limit:20});s(g),c(!1)},aa),()=>{i.current&&clearTimeout(i.current)}},[h,t]),{results:r,isSearching:n}}var vt=He(require("react"),1);var F=require("react/jsx-runtime");function yr({chainId:e,onSelect:t,onClose:r,options:s}){let[n,c]=vt.default.useState(""),{tokens:i,isLoading:h,error:u}=Dt(e),{results:l,isSearching:g}=Mt(n,n?e:void 0),o=s?.showRecommendations??!0,a=vt.default.useMemo(()=>{if(n.trim()){let C=[...l.exact,...l.fuzzy].map(E=>E.token);return s?.filter?C.filter(s.filter):C}let m=i;return s?.filter?m.filter(s.filter):m},[n,l,i,s?.filter]),p=vt.default.useMemo(()=>!o||n.trim()?[]:i.slice(0,6),[i,o,n]),d=(0,vt.useCallback)(m=>{t(m),r()},[t,r]);return(0,F.jsxs)("div",{style:{background:"hsl(var(--background))",borderRadius:"12px",padding:"16px",color:"hsl(var(--foreground))",minWidth:"320px",maxWidth:"400px",fontFamily:"system-ui, sans-serif"},children:[(0,F.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[(0,F.jsx)("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Select Token"}),(0,F.jsx)("button",{type:"button",onClick:r,style:{background:"none",border:"none",color:"hsl(var(--muted-foreground))",cursor:"pointer",fontSize:"18px",padding:"4px 8px"},children:"\u2715"})]}),(0,F.jsx)("input",{type:"text",placeholder:"Search token name or paste address",value:n,onChange:m=>c(m.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:"8px",border:"1px solid #333",background:"hsl(var(--card))",color:"hsl(var(--foreground))",fontSize:"14px",outline:"none",boxSizing:"border-box",marginBottom:"12px"},autoFocus:!0}),h&&!g&&(0,F.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"hsl(var(--muted-foreground))"},children:"Loading tokens..."}),u&&(0,F.jsxs)("div",{style:{textAlign:"center",padding:"12px",color:"hsl(var(--destructive))",fontSize:"13px"},children:["Error: ",u.message]}),o&&p.length>0&&!n.trim()&&(0,F.jsxs)("div",{style:{marginBottom:"12px"},children:[(0,F.jsx)("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},children:"Popular"}),(0,F.jsx)("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:p.map(m=>(0,F.jsxs)("button",{type:"button",onClick:()=>d(m),style:{background:"hsl(var(--card))",border:"1px solid #333",borderRadius:"20px",padding:"6px 14px",color:"hsl(var(--foreground))",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"4px"},children:[m.logoURI?(0,F.jsx)("img",{src:m.logoURI,alt:"",style:{width:"16px",height:"16px",borderRadius:"50%"},onError:C=>{C.target.style.display="none"}}):null,m.symbol]},`${m.chainId}:${m.address}`))})]}),n.trim()&&!h&&(0,F.jsx)("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",marginBottom:"8px"},children:a.length>0?(0,F.jsxs)(F.Fragment,{children:[l.exact.length," exact, ",l.fuzzy.length," fuzzy",l.hasMore?" (more available)":""]}):"No results found"}),(0,F.jsx)("div",{style:{maxHeight:"320px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"2px"},children:a.map(m=>(0,F.jsxs)("button",{type:"button",onClick:()=>d(m),style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 8px",background:"transparent",border:"none",borderRadius:"8px",color:"hsl(var(--foreground))",cursor:"pointer",textAlign:"left",width:"100%",fontSize:"14px"},onMouseEnter:C=>{C.target.style.background="hsl(var(--card))"},onMouseLeave:C=>{C.target.style.background="transparent"},children:[(0,F.jsx)("div",{style:{width:"32px",height:"32px",borderRadius:"50%",background:"hsl(var(--border))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,overflow:"hidden"},children:m.logoURI?(0,F.jsx)("img",{src:m.logoURI,alt:m.symbol,style:{width:"100%",height:"100%"},onError:C=>{let E=C.target;E.style.display="none",E.parentElement.textContent=m.symbol.slice(0,2)}}):m.symbol.slice(0,2)}),(0,F.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,F.jsx)("div",{style:{fontWeight:600,fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.symbol}),(0,F.jsx)("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.name})]}),(0,F.jsxs)("div",{style:{fontSize:"11px",color:"#666",textAlign:"right",flexShrink:0},children:[(0,F.jsxs)("div",{children:[m.decimals," decimals"]}),(0,F.jsxs)("div",{children:["Chain ",m.chainId]})]})]},`${m.chainId}:${m.address}`))})]})}var M=require("@stencil/react-output-target/runtime"),L=He(require("react"),1),An=require("@naculus/connect-appkit-wc/dist/components/appkit-accordion.js"),bn=require("@naculus/connect-appkit-wc/dist/components/appkit-account-button.js"),Rn=require("@naculus/connect-appkit-wc/dist/components/appkit-alert-dialog.js"),Tn=require("@naculus/connect-appkit-wc/dist/components/appkit-avatar.js"),In=require("@naculus/connect-appkit-wc/dist/components/appkit-badge.js"),Un=require("@naculus/connect-appkit-wc/dist/components/appkit-button.js"),Pn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-content.js"),Wn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-description.js"),On=require("@naculus/connect-appkit-wc/dist/components/appkit-card-footer.js"),Nn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-header.js"),_n=require("@naculus/connect-appkit-wc/dist/components/appkit-card-title.js"),Dn=require("@naculus/connect-appkit-wc/dist/components/appkit-card.js"),Mn=require("@naculus/connect-appkit-wc/dist/components/appkit-checkbox.js"),Ln=require("@naculus/connect-appkit-wc/dist/components/appkit-collapsible.js"),Bn=require("@naculus/connect-appkit-wc/dist/components/appkit-connect-button.js"),Fn=require("@naculus/connect-appkit-wc/dist/components/appkit-dialog.js"),Kn=require("@naculus/connect-appkit-wc/dist/components/appkit-dropdown-menu.js"),Hn=require("@naculus/connect-appkit-wc/dist/components/appkit-input.js"),qn=require("@naculus/connect-appkit-wc/dist/components/appkit-popover.js"),Vn=require("@naculus/connect-appkit-wc/dist/components/appkit-progress.js"),zn=require("@naculus/connect-appkit-wc/dist/components/appkit-scroll-area.js"),jn=require("@naculus/connect-appkit-wc/dist/components/appkit-select.js"),$n=require("@naculus/connect-appkit-wc/dist/components/appkit-separator.js"),Gn=require("@naculus/connect-appkit-wc/dist/components/appkit-skeleton.js"),Xn=require("@naculus/connect-appkit-wc/dist/components/appkit-switch.js"),Qn=require("@naculus/connect-appkit-wc/dist/components/appkit-tabs.js"),Yn=require("@naculus/connect-appkit-wc/dist/components/appkit-toggle-group.js"),Jn=require("@naculus/connect-appkit-wc/dist/components/appkit-tooltip.js"),as=(0,M.createComponent)({tagName:"appkit-accordion",elementClass:An.AppkitAccordion,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:An.defineCustomElement}),is=(0,M.createComponent)({tagName:"appkit-account-button",elementClass:bn.AppkitAccountButton,react:L.default,events:{},defineCustomElement:bn.defineCustomElement}),ls=(0,M.createComponent)({tagName:"appkit-alert-dialog",elementClass:Rn.AppkitAlertDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Rn.defineCustomElement}),cs=(0,M.createComponent)({tagName:"appkit-avatar",elementClass:Tn.AppkitAvatar,react:L.default,events:{},defineCustomElement:Tn.defineCustomElement}),us=(0,M.createComponent)({tagName:"appkit-badge",elementClass:In.AppkitBadge,react:L.default,events:{},defineCustomElement:In.defineCustomElement}),ps=(0,M.createComponent)({tagName:"appkit-button",elementClass:Un.AppkitButton,react:L.default,events:{},defineCustomElement:Un.defineCustomElement}),ds=(0,M.createComponent)({tagName:"appkit-card",elementClass:Dn.AppkitCard,react:L.default,events:{},defineCustomElement:Dn.defineCustomElement}),ms=(0,M.createComponent)({tagName:"appkit-card-content",elementClass:Pn.AppkitCardContent,react:L.default,events:{},defineCustomElement:Pn.defineCustomElement}),fs=(0,M.createComponent)({tagName:"appkit-card-description",elementClass:Wn.AppkitCardDescription,react:L.default,events:{},defineCustomElement:Wn.defineCustomElement}),gs=(0,M.createComponent)({tagName:"appkit-card-footer",elementClass:On.AppkitCardFooter,react:L.default,events:{},defineCustomElement:On.defineCustomElement}),hs=(0,M.createComponent)({tagName:"appkit-card-header",elementClass:Nn.AppkitCardHeader,react:L.default,events:{},defineCustomElement:Nn.defineCustomElement}),ys=(0,M.createComponent)({tagName:"appkit-card-title",elementClass:_n.AppkitCardTitle,react:L.default,events:{},defineCustomElement:_n.defineCustomElement}),Cs=(0,M.createComponent)({tagName:"appkit-checkbox",elementClass:Mn.AppkitCheckbox,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Mn.defineCustomElement}),Ss=(0,M.createComponent)({tagName:"appkit-collapsible",elementClass:Ln.AppkitCollapsible,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:Ln.defineCustomElement}),Es=(0,M.createComponent)({tagName:"appkit-connect-button",elementClass:Bn.AppkitConnectButton,react:L.default,events:{onAppkitConnect:"appkitConnect",onAppkitDisconnect:"appkitDisconnect",onAppkitStartPairing:"appkitStartPairing",onAppkitRetry:"appkitRetry",onAppkitCancelPairing:"appkitCancelPairing",onAppkitMobileDeepLink:"appkitMobileDeepLink",onAppkitCopyAddress:"appkitCopyAddress"},defineCustomElement:Bn.defineCustomElement}),ws=(0,M.createComponent)({tagName:"appkit-dialog",elementClass:Fn.AppkitDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Fn.defineCustomElement}),ks=(0,M.createComponent)({tagName:"appkit-dropdown-menu",elementClass:Kn.AppkitDropdownMenu,react:L.default,events:{onAppkitSelect:"appkitSelect"},defineCustomElement:Kn.defineCustomElement}),vs=(0,M.createComponent)({tagName:"appkit-input",elementClass:Hn.AppkitInput,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Hn.defineCustomElement}),xs=(0,M.createComponent)({tagName:"appkit-popover",elementClass:qn.AppkitPopover,react:L.default,events:{onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:qn.defineCustomElement}),As=(0,M.createComponent)({tagName:"appkit-progress",elementClass:Vn.AppkitProgress,react:L.default,events:{},defineCustomElement:Vn.defineCustomElement}),bs=(0,M.createComponent)({tagName:"appkit-scroll-area",elementClass:zn.AppkitScrollArea,react:L.default,events:{},defineCustomElement:zn.defineCustomElement}),Rs=(0,M.createComponent)({tagName:"appkit-select",elementClass:jn.AppkitSelect,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:jn.defineCustomElement}),Ts=(0,M.createComponent)({tagName:"appkit-separator",elementClass:$n.AppkitSeparator,react:L.default,events:{},defineCustomElement:$n.defineCustomElement}),Is=(0,M.createComponent)({tagName:"appkit-skeleton",elementClass:Gn.AppkitSkeleton,react:L.default,events:{},defineCustomElement:Gn.defineCustomElement}),Us=(0,M.createComponent)({tagName:"appkit-switch",elementClass:Xn.AppkitSwitch,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Xn.defineCustomElement}),Ps=(0,M.createComponent)({tagName:"appkit-tabs",elementClass:Qn.AppkitTabs,react:L.default,events:{onAppkitTabChange:"appkitTabChange"},defineCustomElement:Qn.defineCustomElement}),Ws=(0,M.createComponent)({tagName:"appkit-toggle-group",elementClass:Yn.AppkitToggleGroup,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Yn.defineCustomElement}),Os=(0,M.createComponent)({tagName:"appkit-tooltip",elementClass:Jn.AppkitTooltip,react:L.default,events:{},defineCustomElement:Jn.defineCustomElement});0&&(module.exports={AppkitAccordion,AppkitAccountButton,AppkitAlertDialog,AppkitAvatar,AppkitBadge,AppkitButton,AppkitCard,AppkitCardContent,AppkitCardDescription,AppkitCardFooter,AppkitCardHeader,AppkitCardTitle,AppkitCheckbox,AppkitCollapsible,AppkitConnectButton,AppkitDialog,AppkitDropdownMenu,AppkitInput,AppkitPopover,AppkitProgress,AppkitScrollArea,AppkitSelect,AppkitSeparator,AppkitSkeleton,AppkitSwitch,AppkitTabs,AppkitToggleGroup,AppkitTooltip,DEFAULT_EVM_CHAINS,LAMPORTS_PER_SOL,PassphraseCancelledError,PassphraseGate,SolanaRpcError,TokenSelector,TxMonitorContext,WALLET_ERROR_DESCRIPTIONS,WALLET_ERROR_TITLES,Web3ConnectProvider,Web3Context,buildDelegationPolicyMessage,clearClient,createClient,formatSol,getChainById,getClient,getDefaultChains,getLatestBlockhash,getLocale,getSignatureStatus,getSolanaBalance,getUserFriendlyError,isRetryableError,parseSol,resetSessionKeyManager,setLocale,t,useAccount,useAuthorizations,useBalance,useCapabilities,useChain,useCompareCosts,useConnect,useCreateSessionKey,useDelegate,useDelegation,useDelegationPolicy,useDisconnect,useERC20Allowance,useERC20Approve,useERC20Transfer,useERC20TransferSimulation,useEmbeddedWallet,useExecuteCalls,useExecuteRoute,useLastTx,useLookupAddress,useMppSession,useNotification,usePassphraseGate,usePaymentFetch,useResolveName,useRevokeSession,useRouteQuote,useSIWxLogin,useSIWxSession,useSendCalls,useSendTransaction,useSendUserOperation,useSendWithSession,useSession,useSessionKeys,useSignInWithEthereum,useSignInWithX,useSignMessage,useSimulateTransfer,useSiwxAuthSession,useSmartAccount,useSolanaAccount,useSolanaBalance,useSolanaRoles,useSolanaSessionKey,useSolanaTransaction,useSwitchChain,useTokenBalance,useTokenList,useTokenSearch,useTransactionSimulation,useTxHistory,useTxMonitor,useUserOpStatus,useValidateDestination,useViemClient,useWallet,useWeb3,useWeb3ErrorHandler,useX402Signer,validateDestination});
|
|
1
|
+
"use strict";var _s=Object.create;var Lt=Object.defineProperty;var Ds=Object.getOwnPropertyDescriptor;var Ms=Object.getOwnPropertyNames;var Ls=Object.getPrototypeOf,Bs=Object.prototype.hasOwnProperty;var Fs=(e,t)=>{for(var r in t)Lt(e,r,{get:t[r],enumerable:!0})},Sr=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ms(t))!Bs.call(e,n)&&n!==r&&Lt(e,n,{get:()=>t[n],enumerable:!(s=Ds(t,n))||s.enumerable});return e};var He=(e,t,r)=>(r=e!=null?_s(Ls(e)):{},Sr(t||!e||!e.__esModule?Lt(r,"default",{value:e,enumerable:!0}):r,e)),Ks=e=>Sr(Lt({},"__esModule",{value:!0}),e);var ca={};Fs(ca,{AppkitAccordion:()=>is,AppkitAccountButton:()=>ls,AppkitAlertDialog:()=>cs,AppkitAvatar:()=>us,AppkitBadge:()=>ps,AppkitButton:()=>ds,AppkitCard:()=>ms,AppkitCardContent:()=>fs,AppkitCardDescription:()=>gs,AppkitCardFooter:()=>hs,AppkitCardHeader:()=>ys,AppkitCardTitle:()=>Cs,AppkitCheckbox:()=>Ss,AppkitCollapsible:()=>Es,AppkitConnectButton:()=>ws,AppkitDialog:()=>ks,AppkitDropdownMenu:()=>vs,AppkitInput:()=>xs,AppkitPopover:()=>As,AppkitProgress:()=>bs,AppkitScrollArea:()=>Rs,AppkitSelect:()=>Ts,AppkitSeparator:()=>Is,AppkitSkeleton:()=>Us,AppkitSwitch:()=>Ps,AppkitTabs:()=>Ws,AppkitToggleGroup:()=>Os,AppkitTooltip:()=>Ns,DEFAULT_EVM_CHAINS:()=>rr,LAMPORTS_PER_SOL:()=>Z.LAMPORTS_PER_SOL,PassphraseCancelledError:()=>Z.PassphraseCancelledError,PassphraseGate:()=>Z.PassphraseGate,SolanaRpcError:()=>Z.SolanaRpcError,TokenSelector:()=>Cr,TxMonitorContext:()=>ar,WALLET_ERROR_DESCRIPTIONS:()=>hr,WALLET_ERROR_TITLES:()=>gr,Web3ConnectProvider:()=>Ir,Web3Context:()=>Vt,buildDelegationPolicyMessage:()=>sr.buildDelegationPolicyMessage,clearClient:()=>xr,createClient:()=>Ft,formatSol:()=>Z.formatSol,getChainById:()=>Tr,getClient:()=>Kt,getDefaultChains:()=>qt,getLatestBlockhash:()=>Z.getLatestBlockhash,getLocale:()=>Yo,getSignatureStatus:()=>Z.getSignatureStatus,getSolanaBalance:()=>Z.getSolanaBalance,getUserFriendlyError:()=>kt,isRetryableError:()=>vn,parseSol:()=>Z.parseSol,resetSessionKeyManager:()=>Zr,setLocale:()=>Qo,t:()=>kn,useAccount:()=>K,useAuthorizations:()=>Wr,useBalance:()=>Nr,useCapabilities:()=>jt,useChain:()=>pe,useCompareCosts:()=>Zn,useConnect:()=>Dr,useCreateSessionKey:()=>Qr,useDelegate:()=>Lr,useDelegation:()=>ct,useDelegationPolicy:()=>to,useDisconnect:()=>no,useERC20Allowance:()=>io,useERC20Approve:()=>lo,useERC20Transfer:()=>co,useERC20TransferSimulation:()=>fo,useEmbeddedWallet:()=>ro,useExecuteCalls:()=>en,useExecuteRoute:()=>er,useLastTx:()=>ho,useLookupAddress:()=>So,useMppSession:()=>Vr,useNotification:()=>wo,usePassphraseGate:()=>vo,usePaymentFetch:()=>Br,useResolveName:()=>Ao,useRevokeSession:()=>Yr,useRouteQuote:()=>tr,useSIWxLogin:()=>fn,useSIWxSession:()=>To,useSendCalls:()=>Jt,useSendTransaction:()=>ft,useSendUserOperation:()=>bo,useSendWithSession:()=>Jr,useSession:()=>Ro,useSessionKeys:()=>nn,useSignInWithEthereum:()=>Io,useSignInWithX:()=>Ct,useSignMessage:()=>on,useSimulateTransfer:()=>Wo,useSiwxAuthSession:()=>Oo,useSmartAccount:()=>_o,useSolanaAccount:()=>En,useSolanaBalance:()=>Lo,useSolanaRoles:()=>Ko,useSolanaSessionKey:()=>$r,useSolanaTransaction:()=>qo,useSwitchChain:()=>zo,useTokenBalance:()=>jo,useTokenList:()=>Dt,useTokenSearch:()=>Mt,useTransactionSimulation:()=>cn,useTxHistory:()=>$o,useTxMonitor:()=>go,useUserOpStatus:()=>Go,useValidateDestination:()=>es,useViemClient:()=>de,useWallet:()=>ts,useWeb3:()=>I,useWeb3ErrorHandler:()=>ns,useX402Signer:()=>Hr,validateDestination:()=>fr});module.exports=Ks(ca);var Z=require("@naculus/connect-core");var Er=require("@naculus/connect-appkit-core"),ge=require("react");function Zn(e,t){let{operation:r,chains:s,options:n}=e,[c,i]=(0,ge.useState)([]),[h,u]=(0,ge.useState)(!1),[l,g]=(0,ge.useState)(null),o=(0,ge.useRef)(!0),a=(0,ge.useRef)(0),p=(0,Er.compareCostsKey)(e),d=(0,ge.useCallback)(async()=>{if(!s||s.length===0){i([]);return}if(!t)return;let C=++a.current;u(!0),g(null);try{let E=await t(r,s,n);o.current&&C===a.current&&i(E)}catch(E){o.current&&C===a.current&&(g(E instanceof Error?E:new Error(String(E))),i([]))}finally{o.current&&C===a.current&&u(!1)}},[p,t]);(0,ge.useEffect)(()=>{d()},[d]),(0,ge.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let m=(0,ge.useCallback)(async()=>{await d()},[d]);return{comparisons:c,loading:h,error:l,refresh:m}}var Bt=require("@naculus/connect-appkit-core"),Se=require("react");function er(e){let[t,r]=(0,Se.useState)(!1),[s,n]=(0,Se.useState)(null),[c,i]=(0,Se.useState)(null),h=(0,Se.useRef)(!0),u=(0,Se.useRef)(!1);(0,Se.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let l=(0,Se.useCallback)(async(o,a,p)=>{if(!e)return i({code:"no_executor",message:"No executeRoute function provided"}),n(null),null;let d=(0,Bt.validateRouteRecipient)(o,a);if(d)return i(d),n(null),null;if(u.current)return i({code:"execution_in_progress",message:"A route execution is already in progress"}),null;u.current=!0,r(!0),i(null),n(null);try{let m=await e(o,a,p);return h.current&&n(m),m}catch(m){return h.current&&i((0,Bt.toExecuteRouteError)(m)),null}finally{u.current=!1,h.current&&r(!1)}},[e]),g=(0,Se.useCallback)(()=>{n(null),i(null),r(!1)},[]);return{execute:l,executing:t,result:s,error:c,reset:g}}var wr=require("@naculus/connect-appkit-core"),ce=require("react");function tr(e,t){let{fromChain:r,toChain:s,fromToken:n,toToken:c,amount:i,options:h}=e,[u,l]=(0,ce.useState)([]),[g,o]=(0,ce.useState)(!1),[a,p]=(0,ce.useState)(null),d=(0,ce.useRef)(null),m=(0,ce.useRef)(!0),C=(0,ce.useCallback)(async()=>{if(!(0,wr.isQuotableInput)({fromChain:r,toChain:s,fromToken:n,amount:i})){l([]);return}if(t){o(!0),p(null);try{let y=await t(r,s,n,i,h,c);m.current&&l(y)}catch(y){m.current&&(p(y instanceof Error?y:new Error(String(y))),l([]))}finally{m.current&&o(!1)}}},[r,s,n,c,i,h,t]);(0,ce.useEffect)(()=>{if(d.current&&clearTimeout(d.current),!r||!s||!n||!i){l([]);return}return d.current=setTimeout(()=>{C()},300),()=>{d.current&&clearTimeout(d.current)}},[C,r,s,n,i]),(0,ce.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let E=(0,ce.useCallback)(async()=>{await C()},[C]),A=(0,ce.useCallback)(()=>{l([]),p(null),o(!1)},[]);return{quotes:u,loading:g,error:a,refresh:E,clear:A}}var Y=require("@naculus/connect-core"),te=require("@naculus/connector-evm-injected"),kr=require("@naculus/connect-core"),vr=require("@naculus/connector-walletconnect"),nr=null;function Ft(e){let t=null,r=(0,vr.createWalletConnectConnector)({projectId:e.projectId,metadata:e.metadata,...e.walletConnect?.client?{client:e.walletConnect.client}:{},...e.walletConnect?.openUrl?{openUrl:e.walletConnect.openUrl}:{}}),s=null,n=null,c=null,i=null,h=e.passphrasePrompt&&e.enableEmbedded&&!e.embeddedConfig?.encryptionPassphrase?new kr.PassphraseGate:null;e.enableEmbedded&&(n=import("@naculus/connector-embedded").then(o=>{let a={...e.embeddedConfig};h&&(a.encryptionPassphrase=h.request),e.enablePasskeys&&a.encryptionPassphrase&&!a.prfUnlock&&(a.prfUnlock={async derive(d){i&&await i;let m=c;return m?.hasCredential()?m.derivePrfKey(d):null}}),s=o.createPocketConnector(a),t?._setEmbeddedConnector(s)}).catch(o=>{Y.logger.warn("react/client","Embedded wallet connector not available:",o),s=null})),e.enablePasskeys&&(i=import("@naculus/connector-passkeys").then(o=>{c=o.createPasskeysConnector(),t?._setPasskeysConnector(c)}).catch(o=>{Y.logger.warn("react/client","Passkeys connector not available:",o),c=null}));let u=null,l=null;e.enableSolana&&(l=import("@naculus/connector-solana").then(o=>{let a=o.solanaConnector;e.solanaDefaultChain&&"configure"in a&&a.configure({defaultChain:e.solanaDefaultChain}),u=a,typeof window<"u"&&"startDiscovery"in a&&a.startDiscovery();for(let p of e.solanaWallets??[])a.registerWallet?.(p);t?._setSolanaConnector(u)}).catch(o=>{Y.logger.warn("react/client","Solana connector not available:",o),u=null})),typeof window<"u"&&te.eip6963Connector.startDiscovery();for(let{info:o,provider:a}of e.injectedProviders??[])te.eip6963Connector.registerProvider(o,a);let g={connector:r,get embeddedConnector(){return s},getEmbeddedConnector:async()=>(n&&await n,s),get passkeysConnector(){return c},passphraseGate:h,solanaRpcUrl:e.solanaRpcUrl??null,get solanaConnector(){return u},connect:()=>r.connect(),connectInjected:async o=>te.eip6963Connector.connect(o),connectEmbedded:async()=>{if(n&&await n,!s)throw new Error("Embedded wallet not enabled. Set enableEmbedded: true in config.");return s.connect()},connectPasskeys:async()=>{if(i&&await i,!c)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return c.connect()},startPairing:()=>r.startPairing(),completePairing:()=>r.completePairing(),cancelPairing:()=>r.cancelPairing?.(),signMessage:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.signMessage(o,a);if(o.walletType==="passkeys"&&c)return c.signMessage(o,a);if(o.walletType==="embedded"){if(!s)throw new Y.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signMessage(o,a)}if(o.walletType==="solana"){if(l&&await l,u)return u.signMessage(o,a);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.signMessage(o,a)},signTransaction:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.signTransaction(o,a);if(o.walletType==="embedded"){if(!s)throw new Y.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signTransaction(o,a)}if(o.walletType==="solana"){if(l&&await l,u)return u.signTransaction(o,a);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.signTransaction(o,a)},sendTransaction:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.sendTransaction(o,a);if(o.walletType==="passkeys"&&c)return c.sendTransaction(o,a);if(o.walletType==="embedded"){if(!s)throw new Y.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.sendTransaction(o,a)}if(o.walletType==="solana"){if(l&&await l,u)return u.sendTransaction(o,a);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.sendTransaction(o,a)},onAccountsChanged:(o,a)=>{let p=()=>{};return o.id?.startsWith("eip6963-")?te.eip6963Connector.onAccountsChanged?.(o,a)??p:o.walletType==="embedded"?s?.onAccountsChanged?.(o,a)??p:o.walletType==="passkeys"?p:o.walletType==="solana"?u?.onAccountsChanged?.(o,a)??p:r.onAccountsChanged?.(o,a)??p},onChainChanged:(o,a)=>{let p=()=>{};return o.id?.startsWith("eip6963-")?te.eip6963Connector.onChainChanged?.(o,a)??p:o.walletType==="passkeys"||o.walletType==="embedded"?p:o.walletType==="solana"?u?.onChainChanged?.(o,a)??p:r.onChainChanged?.(o,a)??p},getCapabilities:o=>o.id?.startsWith("eip6963-")?te.eip6963Connector.getCapabilities?.(o):o.walletType==="passkeys"?c?.getCapabilities?.(o):o.walletType==="solana"?u?.getCapabilities?.(o):o.walletType==="embedded"?s?.getCapabilities?.(o):r.getCapabilities?.(o),sendCalls:async(o,a,p,d)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.sendCalls(o,a,p,d);if(o.walletType==="passkeys"&&c)return c.sendCalls(o,a,p,d);if(o.walletType==="solana"){if(l&&await l,u)return u.sendCalls(o,a,p,d);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}if(o.walletType==="embedded"){if(!s?.sendCalls)throw new Y.WalletError("method_not_allowed","Embedded wallet does not support sendCalls");return s.sendCalls(o,a,p,d)}if(!r.sendCalls)throw new Y.WalletError("method_not_allowed","sendCalls not supported by this connector");return r.sendCalls(o,a,p,d)},showCallsStatus:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return te.eip6963Connector.showCallsStatus(o,a);if(o.walletType==="passkeys"||o.walletType==="embedded")throw new Y.WalletError("method_unsupported",`${o.walletType} wallets have no UI to display a call bundle.`);if(!r.showCallsStatus)throw new Y.WalletError("method_unsupported","This connector cannot display call status.");return r.showCallsStatus(o,a)},getCallsStatus:async(o,a)=>{if(o.id?.startsWith("eip6963-")&&te.eip6963Connector.getCallsStatus)return te.eip6963Connector.getCallsStatus(o,a);if(o.walletType==="passkeys"&&c?.getCallsStatus)return c.getCallsStatus(o,a);if(o.walletType==="embedded")throw new Y.WalletError("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!r.getCallsStatus)throw new Y.WalletError("method_not_allowed","getCallsStatus not supported by this connector");return r.getCallsStatus(o,a)},reconnect:async o=>o.walletType==="eip6963"?te.eip6963Connector.reconnect(o):o.walletType==="embedded"?s?s.reconnect(o):o:o.walletType==="solana"?o:r.reconnect(o),disconnect:async o=>{if(o.id?.startsWith("eip6963-")||o.walletType==="eip6963")return te.eip6963Connector.disconnect(o);if(o.walletType==="embedded"&&s)return s.disconnect();if(o.walletType==="passkeys"&&c)return c.disconnect(o);if(o.walletType==="solana"){if(l&&await l,u)return u.disconnect(o);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.disconnect(o)},getAllConnectors:()=>{let o=[r];return s&&o.push(s),c&&o.push(c),u&&o.push(u),o},_setEmbeddedConnector:o=>{s=o},_setPasskeysConnector:o=>{c=o},_setSolanaConnector:o=>{u=o}};return t=g,nr=g,g}function Kt(){return nr}function xr(){nr=null}var bt=require("@naculus/connect-core"),Pr=require("react");var ee=require("@naculus/connect-core"),At=require("@naculus/connector-evm-injected"),N=require("react");var Ar=require("@naculus/connect-core"),Ht=require("@naculus/siwx");function rt(e,t){let r=t.split(":",1)[0],n=(e.namespaces[r]?.accounts??[]).filter(c=>c.startsWith(`${r}:`)).map(c=>({namespace:r,caip10:c}))[0];if(n)return{...n,address:n.caip10.split(":").pop()??n.caip10}}function Hs(e){return e.namespaces.eip155?.chains?.[0]??e.namespaces.solana?.chains?.[0]??e.namespaces.xrpl?.chains?.[0]??"eip155:1"}async function br(e){let{session:t,siwx:r,signMessage:s}=e;if(!r||!t)return{kind:"skipped"};try{let n=Hs(t),c=rt(t,n);if(!c)throw new Error("No account found in session");let{address:i}=c,h=await r.createMessage({address:i,chainId:n}),u=(0,Ht.parseSiwxMessage)(h);if(!u?.nonce)throw new Error("SIWx message must contain a nonce");await(0,Ht.issueNonce)(u.nonce);let l=await s(t,{message:h,address:i,chainId:n});return await r.handleSignComplete?.({message:h,signature:l}),{kind:"authenticated",address:i,chainId:n}}catch(n){let c=n instanceof Error?n:new Error("Wallet authentication failed");return Ar.logger.error("appkit/core","SIWx authentication failed:",n),{kind:"failed",error:c,fatal:r.required!==!1}}}var Fe=require("@naculus/connect-appkit-core");var Rr=require("@naculus/connect-appkit-core"),be=require("@naculus/connect-core"),qs=[{caip2:"eip155:5",name:"Goerli",rpcUrl:"https://goerli.blockpi.network/v1/rpc/public",explorerUrl:"https://goerli.etherscan.io",token:"ETH"},{caip2:"eip155:80001",name:"Mumbai",rpcUrl:"https://rpc-mumbai.maticvigil.com",explorerUrl:"https://mumbai.polygonscan.com",token:"MATIC"},{caip2:"eip155:421613",name:"Arbitrum Goerli",rpcUrl:"https://goerli-rollup.arbitrum.io/rpc",explorerUrl:"https://goerli.arbiscan.io",token:"ETH"},{caip2:"eip155:420",name:"Optimism Goerli",rpcUrl:"https://goerli.optimism.io",explorerUrl:"https://goerli-optimism.etherscan.io",token:"ETH"}];function Vs(e){let t=be.CHAINS[e];if(!t||!t.explorerUrl)return null;let r=t.caip2Id;return{caip2:r,name:t.name,rpcUrl:(0,be.getRpcUrl)(r,be.DEFAULT_RPC_URLS[r]??""),explorerUrl:t.explorerUrl,token:t.nativeCurrency.symbol}}function zs(){if(!be.CHAINS)return[];let e=[],t=Object.keys(be.CHAINS).map(Number).sort((r,s)=>r-s);for(let r of t){let s=Vs(r);s&&e.push(s)}for(let r of qs){let s=(0,be.eip155Reference)(r.caip2);(s===null||!be.CHAINS[s])&&e.push(r)}return e}var rr=zs();function Tr(e,t){return(0,Rr.resolveChain)(e,t)??void 0}function qt(){return[...rr]}var Ur=require("react/jsx-runtime"),Vt=(0,N.createContext)(null);function Ir({children:e,config:t,autoConnect:r=!0}){let[s,n]=(0,N.useReducer)(Fe.web3Reducer,Fe.initialWeb3State),c=(0,N.useMemo)(()=>t.chains??qt(),[t.chains]),i=t.connectionTimeout??3e4,h=t.maxRetries??2,u=(0,N.useMemo)(()=>t.sessionStorage??new ee.LocalStorageSessionStorage(t.storageKey??"naculus_web3_session",t.encryptionKey),[t.sessionStorage,t.storageKey,t.encryptionKey]),l=(0,N.useMemo)(()=>Ft({projectId:t.projectId,metadata:t.metadata,enableEmbedded:t.enableEmbedded,embeddedConfig:t.embeddedConfig,enablePasskeys:t.enablePasskeys,enableSolana:t.enableSolana,solanaDefaultChain:t.solanaDefaultChain,walletConnect:t.walletConnect,solanaWallets:t.solanaWallets,injectedProviders:t.injectedProviders}),[t.projectId,t.metadata,t.enableEmbedded,t.embeddedConfig,t.enablePasskeys,t.enableSolana,t.solanaDefaultChain,t.walletConnect,t.solanaWallets,t.injectedProviders]),g=(0,N.useRef)(null),o=(0,N.useRef)(null),a=(0,N.useMemo)(()=>{let f=(0,ee.createConnectorManager)();for(let O of[At.eip6963Connector,...l.getAllConnectors()])f.register(O.id,O);let S={},x={};for(let O of c){let z=O.caip2;O.rpcUrl&&(S[z]=O.rpcUrl),O.token&&(x[z]={name:O.name,symbol:O.token,decimals:18})}let P=(0,ee.createSessionManager)(f,{autoRefreshFeeOnSwitch:t.autoRefreshFeeOnSwitch??!0,defaultRpcUrls:S,defaultCurrencies:x,encryptionKey:t.encryptionKey});return g.current=P,P},[l,c,t.autoRefreshFeeOnSwitch,t.encryptionKey]);(0,N.useEffect)(()=>{let f=z=>{let{walletSession:je}=z.bundle;n({type:"SET_SESSION",payload:je});let fe=[];Object.values(je.namespaces).forEach(xt=>{fe.push(...xt.accounts)}),n({type:"SET_ACCOUNTS",payload:fe}),n({type:"SET_CHAIN",payload:z.bundle.activeChainId}),n({type:"SET_STATUS",payload:"connected"})},S=()=>{n({type:"RESET"})},x=z=>{n({type:"SET_CHAIN",payload:z.newChainId})},P=z=>f(z),O=()=>{u.clear(),n({type:"RESET"})};return a.on("sessionConnected",f),a.on("sessionDisconnected",S),a.on("chainChanged",x),a.on("sessionScopeChanged",P),a.on("sessionRevoked",O),()=>{a.off("sessionConnected",f),a.off("sessionDisconnected",S),a.off("chainChanged",x),a.off("sessionScopeChanged",P),a.off("sessionRevoked",O)}},[a,u]),(0,N.useEffect)(()=>{let f=()=>{u.clear(),n({type:"RESET"})};l.connector.onSessionExpiry(f)},[l,u]);let p=(0,N.useCallback)(()=>{for(let f of[At.eip6963Connector,...l.getAllConnectors()])a.registerConnector(f)},[l,a]),d=(0,N.useCallback)(async f=>{p();let S=[At.eip6963Connector,...l.getAllConnectors()].find(P=>P.id===f.walletType||P.kind===f.walletType);S&&!f.connectorId&&(f.connectorId=S.id);let x=f.namespaces.eip155?.chains?.[0]??f.namespaces.solana?.chains?.[0]??f.namespaces.xrpl?.chains?.[0];x&&await a.attach(f,x)},[l,a,p]),m=(0,N.useCallback)(f=>{if(n({type:"SET_SESSION",payload:f}),f){let S=[];Object.values(f.namespaces).forEach(z=>{S.push(...z.accounts)}),n({type:"SET_ACCOUNTS",payload:S});let x=f.namespaces.eip155?.chains?.[0],P=f.namespaces.solana?.chains?.[0],O=f.namespaces.xrpl?.chains?.[0];n({type:"SET_CHAIN",payload:x??P??O??null})}else n({type:"SET_ACCOUNTS",payload:[]}),n({type:"SET_CHAIN",payload:null})},[]);(0,N.useEffect)(()=>{let f=s.session,S=l;return!f||!S?.onAccountsChanged?void 0:S.onAccountsChanged(f,P=>{if(P.length===0){u.clear().finally(()=>n({type:"RESET"}));return}m(f),u.save(f)})},[s.session,l,u,m]),(0,N.useEffect)(()=>{let f=s.session,S=l;if(!(!f||!S?.onChainChanged))return S.onChainChanged(f,x=>{m(f),u.save(f);let P=a.syncExternalChain;if(!P)return;let O=P.call(a,x).catch(z=>{ee.logger.warn("react/provider","External chain sync error:",z)});o.current=O,O.finally(()=>{o.current===O&&(o.current=null)})})},[s.session,l,u,m,a]);let C=(0,N.useCallback)(async f=>{if(!t.siwx||!f)return!0;n({type:"SET_STATUS",payload:"authenticating"});let S=await br({session:f,siwx:t.siwx,signMessage:(x,P)=>l.signMessage(x,P)});return S.kind==="failed"&&S.fatal?(await u.clear(),n({type:"RESET"}),n({type:"SET_ERROR",payload:S.error}),!1):!0},[t.siwx,l,u]),E=(0,N.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await(0,Fe.withTimeout)(l.connect(),i,"Wallet connect");await u.save(f),m(f);try{await d(f)}catch(S){ee.logger.warn("react/provider","SessionManager sync error:",S)}if(!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,i,C,d]),A=(0,N.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await l.connectEmbedded();if(await u.save(f),m(f),await d(f),!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Embedded wallet connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,C,d]),y=(0,N.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await l.connectPasskeys();if(await u.save(f),m(f),await d(f),!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Passkeys connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,C,d]),v=(0,N.useCallback)(async()=>{if(!s.session){n({type:"RESET"});return}try{await l.disconnect(s.session)}catch(f){ee.logger.error("react/provider","Disconnect error:",f)}try{let f=g.current;f&&await f.disconnect()}catch(f){ee.logger.warn("react/provider","SessionManager disconnect error:",f)}await u.clear(),n({type:"RESET"})},[l,s.session,u]),R=(0,N.useCallback)(async f=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let S=await(0,Fe.withTimeout)(l.connectInjected(f),i,"Injected wallet connect");await u.save(S),m(S);try{await d(S)}catch(x){ee.logger.warn("react/provider","SessionManager sync error:",x)}if(!await C(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){let x=S instanceof Error?S.message:"Connection failed";n({type:"SET_ERROR",payload:S instanceof Error?S:new Error(x)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,i,C,d]),w=(0,N.useCallback)(async()=>l.startPairing(),[l]),T=(0,N.useCallback)(()=>{l.cancelPairing?.()},[l]),k=(0,N.useCallback)(async()=>{let f=await l.completePairing();return await u.save(f),m(f),await d(f),await C(f)&&n({type:"SET_STATUS",payload:"connected"}),f},[l,u,m,C,d]),b=(0,N.useCallback)(async f=>{let S=t.siwx;if(!S||S.required===!1)return!0;try{if(await S.hasValidSession?.())return!0}catch(x){ee.logger.warn("react/provider","siwx.hasValidSession failed",x)}return C(f)},[t.siwx,C]),U=(0,N.useCallback)(async()=>{let f=await u.load();if(!f){n({type:"SET_STATUS",payload:"disconnected"});return}n({type:"SET_STATUS",payload:"reconnecting"});try{let S=await(0,Fe.withRetry)(()=>l.reconnect(f),{maxRetries:h,baseDelay:1e3,label:"reconnect"});m(S);try{let x=g.current;x&&(p(),await x.restoreFromPersistence())}catch(x){ee.logger.warn("react/provider","SessionManager restore error:",x)}if(!await b(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){ee.logger.error("react/provider","Reconnect error:",S),await u.clear(),n({type:"SET_STATUS",payload:"disconnected"}),n({type:"SET_SESSION",payload:null})}},[l,u,m,h,p,b]),W=(0,N.useCallback)(async f=>{o.current&&await o.current;let S=g.current;if(S?.getActiveBundle()){await S.switchChain(f),m(s.session);return}if(!s.session)throw new Error("No active session");try{s.session.walletType==="eip6963"||s.session.id?.startsWith("eip6963-")?await At.eip6963Connector.switchChain(s.session,f):s.session.walletType==="embedded"&&l.embeddedConnector?await l.embeddedConnector.switchChain?.(s.session,f):s.session.walletType==="passkeys"&&l.passkeysConnector?await l.passkeysConnector.switchChain?.(s.session,f):s.session.walletType==="solana"&&l.solanaConnector?await l.solanaConnector.switchChain?.(s.session,f):await l.connector.switchChain(s.session,f),m(s.session)}catch(x){throw new ee.WalletError("chain_unsupported","Failed to switch chain",x)}},[l,s.session,m]);(0,N.useEffect)(()=>{r&&U()},[r,U]);let D=(0,N.useCallback)(()=>{n({type:"SET_ERROR",payload:null})},[]),B=(0,N.useMemo)(()=>({...s,connect:E,connectEmbedded:A,connectPasskeys:y,disconnect:v,reconnect:U,switchChain:W,startPairing:w,completePairing:k,cancelPairing:T,connectInjected:R,clearError:D,isConnected:s.status==="connected",chains:c,client:l,sessionManager:a}),[s,E,A,y,v,U,W,w,k,T,R,D,c,l,a]);return(0,Ur.jsx)(Vt.Provider,{value:B,children:e})}function I(){let e=(0,N.useContext)(Vt);if(!e)throw new Error("useWeb3 must be used within a Web3ConnectProvider");return e}function K(){let{accounts:e,isConnected:t}=I(),r=(0,Pr.useMemo)(()=>!t||e.length===0?null:e.map(n=>{let c=(0,bt.parseCaip10)(n);return c?{address:n,namespace:c.namespace,isEVM:c.namespace==="eip155"&&(0,bt.isEvmAddress)(c.address)}:{address:n,namespace:null,isEVM:(0,bt.isEvmAddress)(n)}}),[e,t]),s=r?.find(n=>n.isEVM)?.address??null;return{accounts:r,evmAccount:s,primaryAccount:e[0]??null,isConnected:t,count:e.length}}var zt=require("@naculus/connect-core"),ue=require("react");function Wr({managers:e}){let t=(0,ue.useRef)(e);t.current=e;let r=(0,ue.useRef)(0),s=(0,ue.useRef)(!0),[n,c]=(0,ue.useState)([]),[i,h]=(0,ue.useState)(!1),[u,l]=(0,ue.useState)(null);(0,ue.useEffect)(()=>()=>{s.current=!1,r.current+=1},[]);let g=(0,ue.useCallback)(async()=>{let a=++r.current;h(!0),l(null);try{let p=await(0,zt.listAuthorizations)(t.current);s.current&&a===r.current&&c(p)}catch(p){s.current&&a===r.current&&l(p instanceof Error?p:new Error("Failed to list authorizations"))}finally{s.current&&a===r.current&&h(!1)}},[]);(0,ue.useEffect)(()=>{g()},[g]);let o=(0,ue.useCallback)(async a=>{try{let p=await(0,zt.revokeListedAuthorization)(t.current,a);return await g(),p}catch(p){let d=p instanceof Error?p:new Error("Failed to revoke authorization");throw s.current&&l(d),d}},[g]);return{entries:n,loading:i,error:u,refresh:g,revoke:o}}var ot=require("@naculus/connect-appkit-core"),Q=require("react");var st=require("viem"),Or=require("@naculus/connect-core");function Nr(e){let{evmAccount:t,isConnected:r}=K(),{chainId:s,chains:n}=I(),[c,i]=(0,Q.useState)(null),[h,u]=(0,Q.useState)(!1),[l,g]=(0,Q.useState)(null),[o,a]=(0,Q.useState)(null),p=e?.refreshInterval,d=(0,Q.useRef)(null),m=(0,Q.useMemo)(()=>(0,ot.resolveChain)(n,s),[s,n]),C=m?(0,ot.chainNumber)(m):null,E=(0,Q.useMemo)(()=>m?(0,ot.toViemChain)(m,C):null,[m,C]),A=(0,Q.useMemo)(()=>m?.token??null,[m]),[y,v]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!E||!m?.rpcUrl){v(null);return}let k=(0,st.createPublicClient)({transport:(0,st.http)(m.rpcUrl),chain:E});return v(k),()=>{}},[m,E]);let R=(0,Q.useCallback)(async()=>{if(!t||!y){i(null);return}u(!0),g(null);try{let b=t.includes(":")?t.split(":").pop():t,[U,W]=await Promise.all([y.getBalance({address:b}),s?(0,Or.getNativeTokenPriceUsd)(s,m?.rpcUrl).catch(()=>null):Promise.resolve(null)]);i(U.toString()),a(W)}catch(k){g(k instanceof Error?k:new Error("Failed to fetch balance")),i(null),a(null)}finally{u(!1)}},[t,y,s,m?.rpcUrl]);(0,Q.useEffect)(()=>{r&&t&&R()},[r,t,R]),(0,Q.useEffect)(()=>(p&&p>0&&r&&t&&(d.current=setInterval(R,p)),()=>{d.current&&(clearInterval(d.current),d.current=null)}),[p,r,t,R]);let w=(0,Q.useMemo)(()=>{if(c===null)return null;try{return(0,st.formatEther)(BigInt(c))}catch{return null}},[c]),T=(0,Q.useMemo)(()=>{if(o===null||w===null)return null;let k=parseFloat(w);if(Number.isNaN(k))return null;let b=k*o;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(b)},[o,w]);return{balance:c,formatted:w,symbol:A,usdPrice:o,usdValue:T,isLoading:h,error:l,refetch:R,chain:m}}var at=require("@naculus/connect-appkit-core"),Pe=require("react");function _(e){return e??Kt()}function jt(){let{client:e,session:t,chainId:r}=I(),[s,n]=(0,Pe.useState)(null),[c,i]=(0,Pe.useState)(!1),[h,u]=(0,Pe.useState)(null),l=(0,Pe.useRef)(0),g=(0,Pe.useCallback)(async()=>{let o=++l.current,a=_(e);if(!a?.getCapabilities||!t){n(null),i(!1),u(null);return}i(!0),u(null);try{let p=await a.getCapabilities(t);if(o!==l.current)return;n((0,at.normalizeCapabilities)(p))}catch(p){if(o!==l.current)return;n(null),u(p instanceof Error?p:new Error("Capability query failed"))}finally{o===l.current&&i(!1)}},[e,t]);return(0,Pe.useEffect)(()=>{g()},[g]),{capabilities:s,current:(0,at.selectChainCapabilities)(s,r),atomic:(0,at.atomicSupportFor)(s,r),isFetching:c,error:h,refetch:g}}var $t=require("react"),it=require("@naculus/connect-appkit-core");function pe(){let{chainId:e,session:t,switchChain:r,chains:s}=I(),n=(0,$t.useMemo)(()=>(0,it.resolveChain)(s,e),[s,e]),c=(0,$t.useMemo)(()=>t?(0,it.describeChain)(s,e):null,[s,e,t]),i=(0,$t.useMemo)(()=>(0,it.chainsForNamespace)(s,e),[s,e]);return{chainId:e,currentChain:n,chainInfo:c,availableChains:i,chains:i,isEvm:e?.startsWith("eip155:")??!1,switchChain:r}}var Rt=require("react");var _r=require("@naculus/connect-core");function Dr(){let{connect:e,status:t}=I(),[r,s]=(0,Rt.useState)(!1),[n,c]=(0,Rt.useState)(null);return{connect:(0,Rt.useCallback)(async()=>{s(!0),c(null);try{await e()}catch(h){let u=h instanceof Error?h.message:"Connection failed";c(h instanceof _r.WalletError?h:new Error(u))}finally{s(!1)}},[e]),isConnecting:r||t==="connecting",error:n}}var Mr=require("@naculus/connect-appkit-core"),Ke=require("@naculus/connect-core"),ne=require("react");var Xt=require("@naculus/connect-appkit-core"),Gt=require("react"),$e=require("viem");function de(){let{evmAccount:e,isConnected:t}=K(),{currentChain:r,chains:s}=pe(),n=r?(0,Xt.chainNumber)(r):null,c=(0,Gt.useMemo)(()=>r?(0,Xt.toViemChain)(r,n):null,[r,n]),i=(0,Gt.useMemo)(()=>c?(0,$e.createPublicClient)({transport:(0,$e.http)(c.rpcUrls.default.http[0]),chain:c}):null,[c]),h=(0,Gt.useMemo)(()=>{if(!t||!e||!c)return null;let u=e.includes(":")?e.split(":").pop():e;return(0,$e.createWalletClient)({transport:(0,$e.http)(c.rpcUrls.default.http[0]),chain:c,account:u})},[t,e,c]);return{publicClient:i,walletClient:h,chains:s}}function Lr(e){let{evmAccount:t}=K(),{session:r,chainId:s,client:n}=I(),{publicClient:c}=de(),[i,h]=(0,ne.useState)(null),[u,l]=(0,ne.useState)(!1),[g,o]=(0,ne.useState)(null),a=(0,ne.useRef)(0),p=(0,ne.useRef)(!1);(0,ne.useEffect)(()=>()=>{a.current+=1},[]),(0,ne.useEffect)(()=>{a.current+=1,h(null),l(!1),o(null)},[r,s,t]);let d=(0,ne.useCallback)(async(A,y)=>{let v=k=>(o(k),null);if(p.current)return v(new Error("A delegation is already in progress"));let R=(0,Mr.bareEvmAddress)(t);if(!r||!R||!s)return v(new Ke.WalletError("wallet_unavailable","No connected EVM account"));if(!c||c.chain?.id!==(0,Ke.eip155Reference)(s))return v(new Ke.WalletError("chain_mismatch",`No RPC client for ${s}; refusing to read the nonce elsewhere.`));let w=r.walletType==="embedded"?_(n)?.embeddedConnector??{}:{},T=++a.current;p.current=!0,l(!0),o(null),h(null);try{let k=await(0,Ke.delegateAccount)({connector:w,session:r,account:R,chainId:s,delegate:A,allowlist:y,getTransactionCount:(b,U)=>c.getTransactionCount({address:b,blockTag:U})});return T!==a.current?null:(h(k),k)}catch(k){return T!==a.current?null:v(k instanceof Error?k:new Error("Failed to send delegation"))}finally{p.current=!1,T===a.current&&l(!1)}},[s,n,t,c,r]),m=(0,ne.useCallback)(A=>d(A,e.allowlist),[d,e.allowlist]),C=(0,ne.useCallback)(()=>d(Ke.REVOKE_DELEGATE,[]),[d]),E=(0,ne.useCallback)(()=>{a.current+=1,h(null),l(!1),o(null)},[]);return{delegate:m,revoke:C,result:i,isPending:u,error:g,reset:E}}var Ge=require("@naculus/connect-appkit-core"),re=require("react");function Br(e,t={}){let[r,s]=(0,re.useState)(0),[n,c]=(0,re.useState)(null),[i,h]=(0,re.useState)(null),u=(0,re.useRef)(0),l=(0,re.useRef)(0),g=(0,re.useRef)(e);g.current=e;let o=(0,re.useRef)(t);o.current=t;let a=(0,re.useRef)(0);(0,re.useEffect)(()=>()=>{u.current+=1,l.current+=1,a.current+=1},[]);let p=(0,re.useCallback)(async(m,C)=>{let E=++u.current,A=l.current;s(y=>y+1),h(null);try{let y=await g.current(m,C),v=(0,Ge.describePayment)(m,y);if(v&&A===l.current){let R=o.current.verify;if(!R)c(v);else{v=(0,Ge.applySettlementVerification)(v,{status:"pending"}),c(v);let w=++a.current,T=o.current.verifyRetry??Ge.DEFAULT_VERIFY_RETRY;Promise.resolve().then(async()=>{let k={status:"pending"};for(let b=0;b<T.attempts;b+=1){if(b>0&&await new Promise(U=>setTimeout(U,T.delayMs)),A!==l.current||w!==a.current)return;try{k=await R(y)}catch(U){k={status:"unavailable",reason:U instanceof Error?U.message:"Settlement verification failed"}}if(k.status!=="pending")break}A===l.current&&w===a.current&&c(b=>b&&(0,Ge.applySettlementVerification)(b,k))})}}return y}catch(y){let v=y instanceof Error?y:new Error("Paid request failed");throw E===u.current&&h(v),v}finally{s(y=>y-1)}},[]),d=(0,re.useCallback)(()=>{u.current+=1,l.current+=1,a.current+=1,c(null),h(null)},[]);return{payFetch:p,isPending:r>0,lastPayment:n,error:i,reset:d}}var Qt=require("@naculus/connect-appkit-core"),Fr=require("@naculus/connector-evm-injected"),Kr=require("react");function Hr(){let{session:e,accounts:t,chainId:r,client:s,switchChain:n}=I(),c=t.join("\0");return(0,Kr.useMemo)(()=>{let i=(0,Qt.findX402Provider)(e,{injected:Fr.eip6963Connector.getDiscoveredWallets(),walletConnect:s.connector});return(0,Qt.createX402WalletSigner)(e,i,n)},[e,c,r,s.connector,n])}var Ee=require("@naculus/connect-appkit-core"),q=require("react");function qr(e){return e instanceof Error?e:new Error("MPP session operation failed")}function Vr(e){let[t,r]=(0,q.useState)(0),[s,n]=(0,q.useState)(()=>e.meter.pending),[c,i]=(0,q.useState)(()=>(0,Ee.readCurrentMppSessionChannel)(e)),[h,u]=(0,q.useState)(null),[l,g]=(0,q.useState)(null),[o,a]=(0,q.useState)(null),p=(0,q.useRef)(0),d=(0,q.useRef)(0),m=(0,q.useRef)(!0),C=(0,q.useRef)(e);C.current=e,(0,q.useEffect)(()=>{p.current+=1,d.current+=1,r(0),n(e.meter.pending),i((0,Ee.readCurrentMppSessionChannel)(e)),u(null),g(null),a(null)},[e]),(0,q.useEffect)(()=>()=>{m.current=!1,p.current+=1,d.current+=1},[]);let E=(0,q.useCallback)(async(k,b,U=!1)=>{let W=++p.current,D=d.current,B=C.current;r(f=>f+1),a(null);try{let f=await k(B);if(m.current&&D===d.current){b?.(f);let S=(0,Ee.readCurrentMppSessionChannel)(B);i(S),n(B.meter.pending),(U||!S)&&g(null)}return f}catch(f){let S=qr(f);if(m.current&&D===d.current){let x=(0,Ee.readCurrentMppSessionChannel)(B);i(x),n(B.meter.pending);let P=(0,Ee.readMppRecoveryChannelId)(f);P?g(P):x||g(null),W===p.current&&a(S)}throw S}finally{m.current&&D===d.current&&r(f=>f-1)}},[]),A=(0,q.useCallback)((k,b)=>E(U=>U(k,b),U=>{let W=(0,Ee.readMppSessionReceipt)(U.receipt);W&&u(W)}),[E]),y=(0,q.useCallback)(()=>E(k=>k.close(),k=>{let b=(0,Ee.readMppSessionReceipt)(k.receipt);b&&u(b)},!0),[E]),v=(0,q.useCallback)(()=>E(k=>k.forceClose(),void 0,!0),[E]),R=(0,q.useCallback)(k=>{try{C.current.meter.add(k),n(C.current.meter.pending),a(null)}catch(b){let U=qr(b);throw a(U),g((0,Ee.readMppRecoveryChannelId)(b)),U}},[]),w=(0,q.useCallback)(()=>{p.current+=1,d.current+=1,r(0),n(C.current.meter.pending),i((0,Ee.readCurrentMppSessionChannel)(C.current)),u(null),g(null),a(null)},[]),T=(0,q.useMemo)(()=>({add:R}),[R]);return{fetch:A,meter:T,pending:s,channel:c,lastReceipt:h,recoveryChannelId:l,isPending:t>0,error:o,close:y,forceClose:v,reset:w}}var jr=require("@naculus/connect-appkit-core"),oe=require("react");function zr(){return Promise.reject(new Error("No Solana session key manager is connected"))}function $r(e){let[t,r]=(0,oe.useState)([]),[s,n]=(0,oe.useState)(0),[c,i]=(0,oe.useState)(null),h=(0,oe.useRef)(0),u=e?.manager,l=e?.rpc,g=e?.owner,o=(0,oe.useMemo)(()=>u&&l&&g?(0,jr.createSolanaSessionKeyFlow)({manager:u,rpc:l,owner:g}):null,[u,l,g]),a=(0,oe.useCallback)(async(C,E)=>{let A=++h.current;n(y=>y+1),i(null);try{return await C()}catch(y){let v=y instanceof Error?y:new Error(E);throw A===h.current&&i(v),v}finally{if(o&&A===h.current){let y=await o.list().catch(()=>null);y&&A===h.current&&r(y)}n(y=>y-1)}},[o]),p=(0,oe.useCallback)(async()=>{if(!o){r([]);return}let C=h.current,E=await o.list();C===h.current&&r(E)},[o]);(0,oe.useEffect)(()=>(h.current+=1,p().catch(()=>{}),()=>{h.current+=1}),[p]);let d=(0,oe.useCallback)(C=>o?a(()=>o.create(C),"Could not create the key"):zr(),[o,a]),m=(0,oe.useCallback)(C=>o?a(()=>o.revoke(C),"Could not revoke the key"):zr(),[o,a]);return{keys:t,create:d,revoke:m,refresh:p,isPending:s>0,error:c}}var lt=require("@naculus/connect-core"),We=require("react");function ct(){let{publicClient:e}=de(),{evmAccount:t}=K(),[r,s]=(0,We.useState)(lt.UNKNOWN_DELEGATION),[n,c]=(0,We.useState)(!1),[i,h]=(0,We.useState)(null),u=(0,We.useRef)(0),l=t?.includes(":")?t.split(":").pop():t,g=(0,We.useCallback)(async()=>{let o=++u.current;if(!e||!l){s(lt.UNKNOWN_DELEGATION),c(!1),h(null);return}c(!0),h(null);try{let a=await e.getCode({address:l});if(o!==u.current)return;s((0,lt.readDelegation)(a??"0x"))}catch(a){if(o!==u.current)return;s(lt.UNKNOWN_DELEGATION),h(a instanceof Error?a:new Error("Code read failed"))}finally{o===u.current&&c(!1)}},[e,l]);return(0,We.useEffect)(()=>{g()},[g]),{...r,isFetching:n,error:i,refetch:g}}var pt=require("@naculus/connect-appkit-core"),se=require("react"),eo=require("viem");var Zt=require("@naculus/connect-core");var Xe=require("react");var or=require("@naculus/connect-appkit-core"),he=require("@naculus/connect-core"),Re=require("react");var Gr=require("@naculus/connect-core");function Yt(e){let t=typeof e=="string"?e:e&&typeof e=="object"&&"hash"in e?e.hash:void 0;if(typeof t=="string"&&/^0x[0-9a-fA-F]{64}$/.test(t))return t;throw new Gr.WalletError("tx_failed","Wallet did not return a valid 32-byte transaction hash")}function Jt(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,Re.useState)("idle"),[c,i]=(0,Re.useState)(null),[h,u]=(0,Re.useState)(null),[l,g]=(0,Re.useState)(null),[o,a]=(0,Re.useState)(null),p=(0,Re.useCallback)(async(E,A)=>{if(!e){n("failed");let y=new he.WalletError("wallet_unavailable","No active session");throw i(y),y}if(E.length===0){n("failed");let y=new he.WalletError("invalid_input","At least one call is required");throw i(y),y}n("awaiting_approval"),i(null),u(null);try{let y=_(r);if(!y)throw new he.WalletError("wallet_unavailable","Client not initialized");let v=A?.chainId??t??void 0,R=A?.strategy??(0,he.chooseExecutionStrategy)(await(0,he.getAccountCapabilities)(y,e,v),E.length);if(a(R),R==="atomic-batch"){let T=await y.sendCalls(e,E,v,{atomicRequired:!0,...A?.paymasterService?{paymasterService:A.paymasterService}:{}});return n("submitted"),u(T),T}let w="";for(let T=0;T<E.length;T++){let k=E[T];try{w=Yt(await y.sendTransaction(e,{transaction:{to:k.to,data:k.data,value:k.value},chainId:v}))}catch(b){throw new he.WalletError("tx_failed",`Call ${T+1} of ${E.length} failed after ${T} already landed (sent sequentially \u2014 this wallet cannot batch atomically): ${(0,or.errorMessage)(b)}`)}}return n("submitted"),u(w),w}catch(y){throw n("failed"),i(y instanceof Error?y:new Error((0,or.errorMessage)(y))),y}},[e,t,r]),d=(0,Re.useCallback)(async E=>{if(!e)throw new he.WalletError("wallet_unavailable","No active session");let A=E??h;if(!A)throw new he.WalletError("invalid_input","No bundle hash available");if(!E&&o==="sequential")throw new he.WalletError("invalid_input","Calls were sent sequentially, so there is no bundle to query. Track the returned transaction hash instead.");let y=_(r);if(!y)throw new he.WalletError("wallet_unavailable","Client not initialized");let v=await y.getCallsStatus(e,A);return g(v),v},[e,h,r,o]),m=(0,Re.useCallback)(async E=>{if(!e)return!1;let A=E??h;if(!A||!E&&o==="sequential")return!1;let y=_(r);if(!y?.showCallsStatus)return!1;try{return await y.showCallsStatus(e,A),!0}catch{return!1}},[e,h,r,o]),C=(0,Re.useCallback)(()=>{n("idle"),i(null),u(null),g(null),a(null)},[]);return{sendCalls:p,getCallsStatus:d,showCallsStatus:m,status:s,error:c,batchHash:h,callsStatus:l,execution:o,reset:C,isSending:s==="awaiting_approval"}}function en(e={}){let{current:t,atomic:r}=jt(),{delegated:s,delegate:n}=ct(),{sendCalls:c}=Jt(),[i,h]=(0,Xe.useState)(!1),[u,l]=(0,Xe.useState)(null),[g,o]=(0,Xe.useState)(null),a=e.atomicity??"preferred",p=e.sponsorship??"any",d=e.paymasterService,m=e.userOperation,C=e.userOperationSponsored??!1,E=!!(t?.raw?.paymasterService?.supported&&d),A=(0,Xe.useCallback)((v,R=a)=>{let w=(0,Zt.planExecution)({atomicBatch:r==="supported",discovered:r!=="unknown",sponsoredTransactions:!1,...t?.maxBatchSize===void 0?{}:{maxBatchSize:t.maxBatchSize}},v,{atomicity:R,sponsorship:p}),T=p==="required"&&!C;if(w.strategy==="atomic-batch"&&!T)return{...w,reason:w.reason+(E?" A paymaster service will be requested, but the wallet's final fee payer must be checked after execution.":""),route:"wallet-batch"};let k=s&&r!=="supported"?` This account does delegate to ${n} under EIP-7702, so it is capable of batching even though the wallet has not offered to.`:"",b=R!=="any"&&!w.atomic||p==="required";return m&&b&&!T?{strategy:"atomic-batch",atomic:!0,sponsored:C,reason:p==="required"&&!w.sponsored?"The wallet batch is not configured for sponsored gas, so the calls are executed through the configured sponsored UserOperation route.":"This wallet cannot batch, so the calls are executed as a single UserOperation through the smart account, which lands as one transaction.",route:"user-operation"}:T?{strategy:"refuse",atomic:w.atomic,sponsored:!1,reason:"Sponsored gas was required, but there is no executable sponsored route: no paymaster is configured for a wallet batch, and capability advertising alone cannot pay for a sequential transaction.",route:null}:w.strategy==="refuse"?{...w,reason:w.reason+k,route:null}:{...w,reason:w.reason+k,route:"sequential"}},[r,t,E,m,C,a,p,s,n]),y=(0,Xe.useCallback)(async(v,R=a)=>{h(!0),l(null);try{let w=A(v.length,R);if(w.route===null)throw new Zt.WalletError("method_not_allowed",w.reason);return o(w.route),w.route==="user-operation"?await m(v):await c(v,{strategy:w.route==="wallet-batch"?"atomic-batch":"sequential",...w.route==="wallet-batch"&&E?{paymasterService:d}:{}})}catch(w){let T=w instanceof Error?w:new Error("Execution failed");throw l(T),T}finally{h(!1)}},[A,c,m,a,d,E]);return{preview:A,execute:y,isExecuting:i,error:u,lastRoute:g,reset:()=>{l(null),o(null)}}}var tn=require("@naculus/connect-appkit-core"),Xr=require("@naculus/connect-core"),H=require("react");function ut(e){return(0,tn.getSharedSessionKeyManager)(e)}function nn(e){let{session:t}=I(),[r,s]=(0,H.useState)([]),[n,c]=(0,H.useState)(!1),[i,h]=(0,H.useState)(null),u=(0,H.useRef)(!0),l=(0,H.useCallback)(()=>h(null),[]),g=ut(e),o=g.isStorageAvailable(),a=(0,H.useCallback)(async()=>{if(!t){s([]);return}c(!0),h(null);try{let d=await g.listSessions();u.current&&s(d)}catch(d){u.current&&h(d instanceof Error?d:new Error("Failed to load session keys"))}finally{u.current&&c(!1)}},[t,g]);(0,H.useEffect)(()=>(u.current=!0,a(),()=>{u.current=!1}),[a]);let p=r.filter(d=>d.status==="active");return{sessions:r,activeSessions:p,loading:n,error:i,refresh:a,clearError:l,storageAvailable:o}}function Qr(e){let{session:t}=I(),[r,s]=(0,H.useState)(null),[n,c]=(0,H.useState)(!1),[i,h]=(0,H.useState)(null),u=(0,H.useCallback)(()=>h(null),[]),l=ut(e);return{createSessionKey:(0,H.useCallback)(async(o,a)=>{if(!t)throw new Xr.WalletError("wallet_unavailable","No active wallet session");c(!0),h(null);try{let p=a??void 0,d=await l.createSessionKey(o,p);return s(d),d}catch(p){let d=p instanceof Error?p:new Error("Failed to create session key");throw h(d),d}finally{c(!1)}},[t,l]),lastCreated:r,isCreating:n,error:i,clearError:u}}function Yr(e){let[t,r]=(0,H.useState)(!1),[s,n]=(0,H.useState)(null),c=(0,H.useCallback)(()=>n(null),[]),i=ut(e);return{revokeSession:(0,H.useCallback)(async u=>{r(!0),n(null);try{await i.revokeSession(u)}catch(l){let g=l instanceof Error?l:new Error("Failed to revoke session key");throw n(g),g}finally{r(!1)}},[i]),isRevoking:t,error:s,clearError:c}}function Jr(e){let[t,r]=(0,H.useState)(!1),[s,n]=(0,H.useState)(null),c=(0,H.useCallback)(()=>n(null),[]),i=ut(e),h=(0,H.useCallback)(async(l,g,o)=>{r(!0),n(null);try{return await i.signWithSessionKey(l,g,o)}catch(a){let p=a instanceof Error?a:new Error("Failed to sign with session key");throw n(p),p}finally{r(!1)}},[i]),u=(0,H.useCallback)(async(l,g)=>{r(!0),n(null);try{return await i.checkSessionScope(l,g)}catch(o){let a=o instanceof Error?o:new Error("Failed to check session scope");throw n(a),a}finally{r(!1)}},[i]);return{signWithSession:h,checkScope:u,isBusy:t,error:s,clearError:c}}function Zr(){(0,tn.resetSharedSessionKeyManager)()}var Tt=require("react");var rn=require("@naculus/connect-core");function on(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,Tt.useState)(!1),[c,i]=(0,Tt.useState)(null);return{signMessage:(0,Tt.useCallback)(async u=>{if(!e){let g=new rn.WalletError("wallet_unavailable","No active session");throw i(g),g}let l=e.namespaces.eip155?.accounts[0]??Object.values(e.namespaces)[0]?.accounts[0];if(!l){let g=new rn.WalletError("wallet_unavailable","No account found");throw i(g),g}n(!0),i(null);try{let g=_(r);if(!g)throw new rn.WalletError("wallet_unavailable","Client not initialized");return await g.signMessage(e,{message:u,address:l,chainId:t??void 0})}catch(g){let o=g instanceof Error?g.message:"Signing failed",a=g instanceof Error?g:new Error(o);throw i(a),a}finally{n(!1)}},[e,t,r]),isSigning:s,error:c}}var sr=require("@naculus/connect-appkit-core");function to(e={}){let{evmAccount:t}=K(),r=(0,pt.bareEvmAddress)(t),s=ct(),n=en(e.execution),{signMessage:c}=on(),i=nn(e.managerConfig),h=ut(e.managerConfig),[u,l]=(0,se.useState)(!1),[g,o]=(0,se.useState)(null),[a,p]=(0,se.useState)(()=>new Set),[d,m]=(0,se.useState)(!1),C=e.origin??(typeof window<"u"?window.location.origin:"unknown"),E=!!e.managerConfig?.encryptionKey,A=e.execution?.sponsorship,{refresh:y,storageAvailable:v}=i,{preview:R}=n,{delegated:w,delegate:T}=s,k=(0,se.useMemo)(()=>(0,pt.createDelegationPolicyFlow)({manager:h,origin:C,signer:()=>r,signMessage:c,verifySignature:async({message:S,signature:x,signerAddress:P})=>(await(0,eo.recoverMessageAddress)({message:S,signature:x})).toLowerCase()===P.toLowerCase(),previewExecution:R,sponsorship:A,adapter:e.adapter,signTypedData:e.signTypedData,chainId:()=>e.chainId??null,delegation:()=>({delegated:w,delegate:T}),encryptionKeyConfigured:E,storageAvailable:()=>v,refresh:y}),[h,C,r,c,R,A,e.adapter,e.signTypedData,e.chainId,w,T,E,v,y]);(0,se.useEffect)(()=>{let S=!1,x=i.sessions.filter(pt.isVerifiablePolicy);return x.length===0?(p(new Set),m(!1),()=>{S=!0}):(m(!0),Promise.all(x.map(async P=>[P.id,await k.verifyStoredPolicy(P)])).then(P=>{S||p(new Set(P.filter(([,O])=>O).map(([O])=>O)))}).catch(P=>{S||(p(new Set),o(P instanceof Error?P:new Error("Policy verification failed")))}).finally(()=>{S||m(!1)}),()=>{S=!0})},[i.sessions,k]);let b=(0,se.useCallback)(()=>{o(null),i.clearError()},[i]),U=(0,se.useCallback)(async(S,x)=>{l(!0),o(null);try{return await S()}catch(P){let O=P instanceof Error?P:new Error(x);throw o(O),O}finally{l(!1)}},[]),W=(0,se.useCallback)(S=>U(()=>k.createPolicy(S),"Policy creation failed"),[k,U]),D=(0,se.useCallback)(S=>U(()=>k.revokePolicy(S),"Policy revocation failed"),[k,U]),B=(0,se.useCallback)((S,x)=>U(()=>k.executePolicy(S,x),"Policy execution failed"),[k,U]),f=i.activeSessions.filter(S=>a.has(S.id));return{policies:i.sessions,activePolicies:f,storageAvailable:i.storageAvailable,loading:i.loading||d,isBusy:u,error:g??i.error,delegation:s,createPolicy:W,revokePolicy:D,previewPolicyExecution:k.previewPolicyExecution,signPolicyDigest:k.signPolicyDigest,executePolicy:B,refresh:i.refresh,clearError:b}}var Qe=require("react");function no(){let{disconnect:e,status:t}=I(),[r,s]=(0,Qe.useState)(!1),[n,c]=(0,Qe.useState)(null),i=(0,Qe.useRef)(!0);return{disconnect:(0,Qe.useCallback)(async()=>{if(t!=="disconnected"){s(!0),c(null);try{await e()}catch(u){if(!i.current)return;c(u instanceof Error?u:new Error("Disconnect failed"))}finally{i.current&&s(!1)}}},[e,t]),isDisconnecting:r,error:n,cleanup:()=>{i.current=!1}}}var sn=require("@naculus/connect-core"),$=require("react");function qe(e){let t=e.activeNamespace??"eip155",r=Array.isArray(e.accounts)?e.accounts.map(({namespace:s,address:n,derivationPath:c})=>({namespace:s,address:n,...c?{derivationPath:c}:{}})):e.address?[{namespace:t,address:e.address}]:[];return{accounts:r,activeNamespace:t,createdAt:e.createdAt??0,...e.chainId?{chainId:e.chainId}:{},...e.version?{version:e.version}:{},recoveryAvailable:!!e.mnemonic,address:r.find(s=>s.namespace===t)?.address??e.address}}function ro(){let{connectEmbedded:e,client:t}=I(),[r,s]=(0,$.useState)(null),n=(0,$.useRef)(null),c=(0,$.useRef)(4),i=(0,$.useRef)(!1),h=(0,$.useRef)(null),[u,l]=(0,$.useState)(!1),[g,o]=(0,$.useState)(!1),[a,p]=(0,$.useState)(null),d=()=>p(null),m=(0,$.useCallback)(()=>{let f=n.current;return n.current=null,f},[]),C=(0,$.useCallback)(()=>{let f=_(t);if(!f?.embeddedConnector)throw new sn.WalletError("wallet_unavailable","Embedded wallet not enabled.");return f.embeddedConnector},[t]),E=(0,$.useCallback)(()=>{try{return C().getWallet()?.privateKey??null}catch{return null}},[C]),A=(0,$.useCallback)(async()=>{let f=_(t);if(!f)throw new sn.WalletError("wallet_unavailable","Embedded wallet not enabled.");let S=f.getEmbeddedConnector?await f.getEmbeddedConnector():f.embeddedConnector;if(!S)throw new sn.WalletError("wallet_unavailable","Embedded wallet not enabled.");return S},[t]),y=(0,$.useCallback)(()=>{try{return _(t)?.passphraseGate??null}catch{return null}},[t]),v=(0,$.useCallback)(f=>{f?.code==="decryption_failed"&&y()?.forget("That passphrase did not open the wallet.")},[y]),R=(0,$.useCallback)(async()=>{i.current=!1,p(null);try{let f=await A();if(!await f.load())return!1;let x=f.getWallet();return x?(n.current=null,l(!1),s(qe(x)),!0):!1}catch(f){return i.current=!0,v(f),p(f instanceof Error?f:new Error("Failed to restore embedded wallet")),!1}},[v,A]);(0,$.useEffect)(()=>{let f=!1,S=null;return R().then(x=>{f||x||i.current||(S=setTimeout(()=>{f||R()},100))}),()=>{f=!0,S&&clearTimeout(S)}},[R]);let w=async()=>{o(!0),p(null);try{let f=await A(),S=await f.load(),x=f.getWallet();S&&x&&(s(qe(x)),n.current=x.mnemonic||null,l(!x.mnemonic)),await e();let P=f.getWallet();P&&(s(qe(P)),P.mnemonic&&!S&&(n.current=P.mnemonic,l(!0)))}catch(f){v(f),p(f instanceof Error?f:new Error("Embedded wallet connection failed"))}finally{o(!1)}},T=async()=>{o(!0),p(null);try{let f=await A();y()?.expect("create");let S=await f.generateWallet();return s(qe(S)),n.current=S.mnemonic,l(!0),S}catch(f){return p(f instanceof Error?f:new Error("Failed to generate wallet")),null}finally{o(!1)}},k=async f=>{o(!0),p(null);try{let S=await A();y()?.expect("create");let x=await S.importFromMnemonic(f);return s(qe(x)),n.current=null,l(!1),x}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{o(!1)}},b=async f=>{o(!0),p(null);try{let S=await A();y()?.expect("create");let x=await S.importFromPrivateKey(f);return s(qe(x)),n.current=null,l(!1),x}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{o(!1)}},U=async()=>{o(!0),p(null);try{await(await A()).wipe(),s(null),n.current=null,l(!1)}catch(f){p(f instanceof Error?f:new Error("Failed to wipe wallet"))}finally{o(!1)}},W=(0,$.useCallback)(f=>{let S=C();S.setActiveNamespace(f);let x=S.getWallet();s(x?qe(x):null)},[C]),D=(0,$.useCallback)(async()=>{let f=await A(),S=await f.backfillAccounts();if(S.length>0){let x=f.getWallet();s(x?qe(x):null)}return S.map(({namespace:x,address:P,derivationPath:O})=>({namespace:x,address:P,...O?{derivationPath:O}:{}}))},[A]),B=()=>{n.current=null,l(!1)};return{connectEmbedded:w,restoreWallet:R,generateWallet:T,importFromMnemonic:k,importFromPrivateKey:b,wipe:U,wallet:r,hasWallet:r!==null,address:r?.address??null,accounts:r?.accounts??[],activeNamespace:r?.activeNamespace??null,setActiveNamespace:W,backfillAccounts:D,seedPhrase:n.current,getSeedPhrase:m,getPrivateKey:E,backupPending:u,confirmBackup:B,isBusy:g,error:a,clearError:d,storageSecurityLevel:(()=>{try{let f=C(),S=f.getStorageSecurityLevel?.()??4;return f.getWallet()?(c.current=S,S):r?c.current:S}catch{return r?c.current:4}})(),securityReport:(()=>{let f=null;try{f=C().getStorageSecurityReport?.()??null}catch{f=null}if(!f)return h.current=null,null;let S=JSON.stringify(f);return h.current?.json===S?h.current.value:(h.current={json:S,value:f},f)})()}}var ao=require("@naculus/connect-appkit-core"),ke=require("react");var oo=require("@naculus/connect-core"),we=require("react"),so=require("@naculus/connect-appkit-core");function js(e){return[e.token.address.toLowerCase(),e.token.chainId??"",e.token.decimals??"",e.chainId??"",e.owner??"",e.spender??"",e.connected?"1":"0",e.publicClient?"1":"0",e.walletClient?"1":"0",e.session?.id??""].join("|")}function dt(e){let{token:t,chainId:r}=e,s=t.address.toLowerCase(),n=js(e),c=(0,we.useMemo)(()=>({key:n}),[n]),i=(0,we.useRef)(n),h=(0,we.useRef)(!0);(0,we.useLayoutEffect)(()=>{i.current=n},[n]),(0,we.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let u=(0,we.useCallback)(()=>h.current&&i.current===n,[n]),l=(0,we.useCallback)(()=>{if(!u())throw new oo.WalletError("session_inactive","Wallet or token context changed. Retry the operation with the current account and chain.");let g=(0,so.tokenChainMismatch)({address:s,chainId:t.chainId},r);if(g)throw g},[u,s,t.chainId,r]);return{identity:c,isCurrent:u,assertCurrent:l}}var an=require("@naculus/connect-core");function io(e){let{publicClient:t}=de(),{currentChain:r}=pe(),{identity:s,isCurrent:n,assertCurrent:c}=dt({token:e.token,chainId:r?(0,ao.chainNumber)(r)??void 0:void 0,owner:e.owner,spender:e.spender,publicClient:t}),[i,h]=(0,ke.useState)(null),u=i?.identity===s?i.raw:null,l=i?.identity===s&&i.fetching,g=i?.identity===s?i.error:null,o=(0,ke.useRef)(null),a=(0,ke.useRef)(0),p=(0,ke.useCallback)(async()=>{if(!n())return;let m=++a.current,C=()=>n()&&m===a.current;if(h({identity:s,raw:null,fetching:!!t,error:null}),!!t)try{c();let E=await t.readContract({address:e.token.address,abi:an.ERC20_MIN_ABI,functionName:"allowance",args:[e.owner,e.spender]});if(!C())return;h({identity:s,raw:E,fetching:!1,error:null})}catch(E){if(!C())return;h({identity:s,raw:null,fetching:!1,error:E instanceof Error?E:new Error("Failed to fetch allowance")})}},[t,e.token.address,e.token.chainId,e.owner,e.spender,s,n,c]);return(0,ke.useEffect)(()=>{p().catch(m=>console.warn("useERC20Allowance: initial fetch failed:",m))},[p]),(0,ke.useEffect)(()=>(e.refreshInterval&&e.refreshInterval>0&&(o.current=setInterval(p,e.refreshInterval)),()=>{o.current&&(clearInterval(o.current),o.current=null)}),[e.refreshInterval,p]),{allowance:(0,ke.useMemo)(()=>{if(u===null)return null;let m=e.token.decimals;return m===void 0?null:(0,an.formatUnits)(u,m)},[u,e.token.decimals]),allowanceRaw:u,isFetching:l,error:g,refetch:p}}var ye=require("@naculus/connect-appkit-core"),ae=require("@naculus/connect-core"),ve=require("react");var ln=require("@naculus/connect-core"),mt=require("react");function ft(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,mt.useState)("idle"),[c,i]=(0,mt.useState)(null),h=(0,mt.useCallback)(async l=>{if(!e){n("failed");let o=new ln.WalletError("wallet_unavailable","No active session");throw i(o),o}let g=e.namespaces.eip155?.accounts.find(o=>/^eip155:\d+:0x[0-9a-fA-F]{40}$/.test(o)||/^0x[0-9a-fA-F]{40}$/.test(o));if(!g){n("failed");let o=new ln.WalletError("wallet_unavailable","No EVM account found");throw i(o),o}n("awaiting_approval"),i(null);try{let o={...l,from:l.from??g.split(":").pop()},a=_(r);if(!a)throw new ln.WalletError("wallet_unavailable","Client not initialized");let p=await a.sendTransaction(e,{transaction:o,chainId:t??void 0}),d=Yt(p);return n("submitted"),d}catch(o){n("failed");let a=o instanceof Error?o.message:"Transaction failed";throw i(o instanceof Error?o:new Error(a)),o}},[e,t,r]),u=(0,mt.useCallback)(()=>{n("idle"),i(null)},[]);return{sendTransaction:h,status:s,error:c,reset:u,isSending:s==="awaiting_approval"}}function $s(e){return e.includes(":")?e.split(":").pop():e}var Gs=2n**256n-1n;function lo(e){let{publicClient:t,walletClient:r}=de(),{evmAccount:s,isConnected:n}=K(),{currentChain:c}=pe(),{session:i,client:h}=I(),{sendTransaction:u,isSending:l,error:g,reset:o}=ft(),[a,p]=(0,ve.useState)(null),{identity:d,isCurrent:m,assertCurrent:C}=dt({token:e.token,chainId:c?(0,ye.chainNumber)(c)??void 0:void 0,owner:s,spender:e.spender,connected:n,publicClient:t,walletClient:r,session:i,client:h}),[E,A]=(0,ve.useState)(null),y=E?.identity===d?E.raw:null,v=E?.identity===d&&E.fetching,R=(0,ve.useRef)((0,ye.createDecimalsCache)(e.token,e.token.decimals)),w=(0,ve.useRef)(0),T=a??g,k=s?$s(s):null,b=(0,ve.useCallback)(async()=>{if(!m())return null;let S=++w.current,x=()=>m()&&S===w.current;if(A({identity:d,raw:null,fetching:!!t&&!!k&&n}),p(null),!t||!k||!n)return null;try{C();let P=await t.readContract({address:e.token.address,abi:ae.ERC20_MIN_ABI,functionName:"allowance",args:[k,e.spender]});return x()?(A({identity:d,raw:P,fetching:!1}),P):null}catch(P){return x()&&(A({identity:d,raw:null,fetching:!1}),p(P instanceof Error?P:new Error("Failed to fetch allowance"))),null}},[t,k,e.token.address,e.token.chainId,e.spender,d,m,C,n]),U=(()=>{if(y===null)return null;let S=(0,ye.readDecimals)(R.current,e.token,e.token.decimals);return S===void 0?null:(0,ae.formatUnits)(y,S)})(),W=(0,ve.useCallback)(async S=>{if(p(null),o(),!n||!s){let x=new ae.WalletError("wallet_unavailable","No connected account");throw p(x),x}if(!t){let x=new ae.WalletError("wallet_unavailable","No public client");throw p(x),x}try{C();let x=(0,ye.encodeErc20Approve)(e.spender,S),P=_(h);if(i&&P){let z=await u({to:e.token.address,data:x,value:"0"});return b(),z}if(r){let{request:z}=await t.simulateContract({address:e.token.address,abi:ae.ERC20_MIN_ABI,functionName:"approve",args:[e.spender,S],account:k});C();let je=await r.writeContract(z);return b(),je}let O=await u({to:e.token.address,data:x,value:"0"});return b(),O}catch(x){let P=x instanceof Error?x:new Error("Approve failed");throw m()&&p(P),P}},[e,t,r,s,n,i,h,k,u,o,b,C,m]),D=(0,ve.useCallback)(async S=>{try{if(C(),!t)throw new ae.WalletError("wallet_unavailable","No public client");let x=(0,ye.readDecimals)(R.current,e.token,e.token.decimals);x===void 0&&(x=await t.readContract({address:e.token.address,abi:ae.ERC20_MIN_ABI,functionName:"decimals"}),C(),(0,ye.writeDecimals)(R.current,e.token,x));let P=(0,ae.parseUnits)(S,x);return await W(P)}catch(x){throw m()&&p(x instanceof Error?x:new Error("Approve failed")),x}},[e.token,t,W,C,m]),B=(0,ve.useCallback)(async()=>W(Gs),[W]),f=(0,ve.useCallback)(async S=>{if(!m()||!n||!k||!t)return!1;try{C()}catch(z){return p(z instanceof Error?z:new Error("Cannot check allowance")),!1}let x=y??await b();if(x===null)return!1;let P=(0,ye.readDecimals)(R.current,e.token,e.token.decimals);if(P===void 0){if(!t)throw new ae.WalletError("wallet_unavailable","Cannot check allowance: no public client to read token decimals.");if(P=await t.readContract({address:e.token.address,abi:ae.ERC20_MIN_ABI,functionName:"decimals"}),!m())return!1;(0,ye.writeDecimals)(R.current,e.token,P)}let O=(0,ae.parseUnits)(S,P);return m()&&x>=O},[y,b,e.token.address,e.token.chainId,e.token.decimals,t,m,C,n,k]);return{approve:D,approveMax:B,allowance:U,allowanceRaw:y,hasAllowance:f,isApproving:l,isFetchingAllowance:v,error:T,refetchAllowance:b}}var Oe=require("@naculus/connect-appkit-core"),Ve=require("@naculus/connect-core"),gt=require("react");function Xs(e){return e.includes(":")?e.split(":").pop():e}function co(e){let{publicClient:t,walletClient:r}=de(),{evmAccount:s,isConnected:n}=K(),{currentChain:c}=pe(),{session:i,client:h}=I(),{sendTransaction:u,isSending:l,error:g,reset:o}=ft(),[a,p]=(0,gt.useState)(null),{isCurrent:d,assertCurrent:m}=dt({token:e.token,chainId:c?(0,Oe.chainNumber)(c)??void 0:void 0,owner:s,connected:n,publicClient:t,walletClient:r,session:i,client:h}),C=(0,gt.useRef)((0,Oe.createDecimalsCache)(e.token,e.token.decimals)),E=a??g;return{sendTransfer:(0,gt.useCallback)(async(y,v)=>{if(p(null),o(),!n||!s){let R=new Ve.WalletError("wallet_unavailable","No connected account");throw p(R),R}if(!t){let R=new Ve.WalletError("wallet_unavailable","No public client available");throw p(R),R}try{m();let R=Xs(s),w=(0,Oe.readDecimals)(C.current,e.token,e.token.decimals);w===void 0&&(w=await t.readContract({address:e.token.address,abi:Ve.ERC20_MIN_ABI,functionName:"decimals"}),m(),(0,Oe.writeDecimals)(C.current,e.token,w));let T=(0,Ve.parseUnits)(v,w),k=(0,Oe.encodeErc20Transfer)(y,T),b=_(h);if(i&&b)return await u({to:e.token.address,data:k,value:"0"});if(r){let{request:W}=await t.simulateContract({address:e.token.address,abi:Ve.ERC20_MIN_ABI,functionName:"transfer",args:[y,T],account:R});return m(),await r.writeContract(W)}return await u({to:e.token.address,data:k,value:"0"})}catch(R){let w=R instanceof Error?R:new Error("Transfer failed");throw d()&&p(w),w}},[e.token,t,r,s,n,i,h,u,o,m,d]),isSending:l,error:E}}var un=require("@naculus/connect-appkit-core"),po=require("@naculus/connect-core"),mo=require("react");var uo=require("@naculus/connect-appkit-core"),Te=require("react");function cn(e,t){I();let{evmAccount:r}=K(),{currentChain:s}=pe(),{publicClient:n}=de(),[c,i]=(0,Te.useState)(void 0),[h,u]=(0,Te.useState)(!1),[l,g]=(0,Te.useState)(null),o=(0,Te.useRef)(void 0),a=(0,Te.useCallback)(async()=>{e&&(u(!0),g(null));try{let d=await(0,uo.simulateTransactionPreview)(e,{chainId:t,currentChain:s,publicClient:n,evmAccount:r});return i(d),d}catch(d){let m=d instanceof Error?d:new Error("Simulation failed");throw g(m),m}finally{e&&u(!1)}},[e,t,s,n,r]);(0,Te.useEffect)(()=>{if(e)return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{a().catch(()=>{})},300),()=>{o.current&&clearTimeout(o.current)}},[e,a]);let p=(0,Te.useCallback)(()=>{i(void 0),g(null),u(!1)},[]);return{result:c,isSimulating:h,error:l,simulate:a,reset:p}}function fo(e){let{evmAccount:t,isConnected:r}=K(),{currentChain:s}=pe(),n=e.token.chainId??(s?(0,un.chainNumber)(s)??void 0:void 0),c=(0,mo.useMemo)(()=>{if(!(!r||!t))try{let h=e.token.decimals;if(h===void 0)return;let u=(0,po.parseUnits)(e.amount,h),l=(0,un.encodeErc20Transfer)(e.to,u);return{to:e.token.address,data:l,value:"0"}}catch{return}},[e.token.address,e.token.decimals,e.to,e.amount,t,r]),i=cn(c,n);return{result:c?i.result:void 0,isSimulating:!!c&&i.isSimulating,error:c?i.error:null,reSimulate:i.simulate,reset:i.reset}}var Ne=require("react");var xe=require("react"),pn=require("react"),ar=(0,pn.createContext)(null);function It(){return(0,pn.useContext)(ar)}function go(e,t,r){let s=It(),n=r??s,[c,i]=(0,xe.useState)(null),[h,u]=(0,xe.useState)(!1),[l,g]=(0,xe.useState)(!1),[o,a]=(0,xe.useState)(null),p=(0,xe.useRef)(void 0),d=(0,xe.useCallback)(async()=>{if(!(!n||!e)){u(!0),a(null);try{await n.refreshTx(e,t);let E=n.getTxStatus(e,t);E&&i(E)}catch(E){a(E instanceof Error?E:new Error(String(E)))}finally{u(!1)}}},[n,e,t]),m=(0,xe.useCallback)(()=>{!n||!e||(n.stopWatching(e,t),g(!1))},[n,e,t]);(0,xe.useEffect)(()=>{if(!n||!e||!t){i(null),g(!1);return}p.current&&p.current!==e&&n.stopWatching(p.current),p.current=e;let E=!1;g(!0),u(!0),a(null);let A=n.getTxStatus(e,t);A&&(i(A),u(!1)),n.watchTx(e,t,{}).then(v=>{E||(i(v),u(!1))}).catch(v=>{E||(a(v instanceof Error?v:new Error(String(v))),u(!1))});let y=v=>{E||i({...v})};return n.on("statusChange",y),()=>{E=!0,g(!1),n.off("statusChange",y)}},[n,e,t]);let C=c?.status??"idle";return{entry:c,status:C,isLoading:h,isWatching:l,error:o,refresh:d,stopWatching:m}}function ho(e){let t=It(),r=e??t,[s,n]=(0,Ne.useState)(null),[c,i]=(0,Ne.useState)(null),[h,u]=(0,Ne.useState)(null),l=(0,Ne.useRef)(null),g=(0,Ne.useRef)(null),o=(0,Ne.useRef)(null);r&&(g.current||(g.current=p=>{i(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},r.on("confirmed",g.current)),o.current||(o.current=p=>{u(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},r.on("failed",o.current)));let a=(0,Ne.useCallback)(()=>{n(null),i(null),u(null),l.current=null},[]);return{lastTx:s,lastConfirmedTx:c,lastFailedTx:h,clear:a}}var Co=require("react");var me=require("react"),yo=require("@naculus/connect-appkit-core");function dn({input:e,skip:t=!1,resolverConfig:r,scope:s,query:n}){let[c,i]=(0,me.useState)(null),[h,u]=(0,me.useState)(!1),[l,g]=(0,me.useState)(null),o=(0,me.useRef)(0),a=(0,me.useRef)(!0);(0,me.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let p=(0,me.useMemo)(()=>(0,yo.getResolver)(r),[r]),d=(0,me.useCallback)(()=>{let m=e.trim();if(!m||t){o.current+=1,i(null),u(!1),g(null);return}let C=++o.current;u(!0),g(null),n(p,m,s).then(E=>{!a.current||C!==o.current||(i(E),u(!1))}).catch(E=>{!a.current||C!==o.current||(g(E instanceof Error?E:new Error(String(E))),i(null),u(!1))})},[e,t,s,p,n]);return(0,me.useEffect)(()=>{d()},[d]),{data:c,isLoading:h,error:l,refetch:d}}function So(e,t){let r=(0,Co.useCallback)((s,n,c)=>s.lookupAddress(n,c),[]);return dn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,scope:t?.chainId,query:r})}var G=require("react"),j=require("@naculus/connect-appkit-core"),Eo=require("@naculus/connect-core");function wo(e){let t=(0,G.useRef)(null);t.current||(t.current=e?.channel??new Eo.InAppChannel);let r=t.current,[s,n]=(0,G.useState)(()=>r.getHistory()),[c,i]=(0,G.useState)(()=>j.DEFAULT_NOTIFICATION_SETTINGS),h=(0,G.useRef)([]);(0,G.useEffect)(()=>{let y=e?.storage??(0,j.createNotificationSettingsStorage)(),v=R=>{let w=h.current??[];if(h.current=null,w.length===0){R&&i(R);return}i(()=>{let T=(0,j.replayNotificationSettings)(R,w);return(0,j.saveNotificationSettings)(y,T),T})};(0,j.loadNotificationSettings)(y).then(v,()=>v(null))},[]),(0,G.useEffect)(()=>(r.onNotification=y=>{n(v=>[...v,y])},r.restore().then(()=>{n(r.getHistory())}),()=>{r.onNotification=void 0}),[]);let u=(0,G.useMemo)(()=>s.filter(y=>!y.read).length,[s]),l=(0,G.useCallback)(()=>{r.clear(),n([])},[r]),g=(0,G.useCallback)(y=>{(0,j.clearOneInAppNotification)(r,y).then(()=>{n(r.getHistory())})},[r]),o=(0,G.useCallback)(y=>{r.markAsRead(y),n(v=>v.map(R=>R.id===y?{...R,read:!0}:R))},[r]),a=(0,G.useCallback)(()=>{r.markAllAsRead(),n(y=>y.map(v=>({...v,read:!0})))},[r]),p=(0,G.useCallback)(y=>{(0,j.addInAppNotification)(r,y)},[r]),d=(0,G.useCallback)(y=>{h.current?.push(y),i(v=>{let R=(0,j.updateNotificationSettings)(v,y(v)),w=e?.storage??(0,j.createNotificationSettingsStorage)();return(0,j.saveNotificationSettings)(w,R),R})},[e?.storage]),m=(0,G.useCallback)(y=>d(()=>y),[d]),C=(0,G.useCallback)(y=>{m((0,j.channelsUpdate)(y))},[m]),E=(0,G.useCallback)(y=>{d(v=>(0,j.mutedChainSettings)(v,y,!0))},[d]),A=(0,G.useCallback)(y=>{d(v=>(0,j.mutedChainSettings)(v,y,!1))},[d]);return{notifications:s,unreadCount:u,addNotification:p,clear:l,clearOne:g,markAsRead:o,markAllAsRead:a,settings:c,updateSettings:m,setChannels:C,muteChain:E,unmuteChain:A}}var ht=require("react");var ko=()=>null,Qs=()=>()=>{};function vo(){let{client:e}=I(),t=_(e)?.passphraseGate??null,r=(0,ht.useSyncExternalStore)(t?.subscribe??Qs,t?.getSnapshot??ko,ko),s=(0,ht.useCallback)(i=>t?.submit(i),[t]),n=(0,ht.useCallback)(()=>t?.cancel(),[t]),c=(0,ht.useCallback)(i=>t?.forget(i),[t]);return{request:r,submit:s,cancel:n,forget:c,isUnlocked:t?.isUnlocked??!1,gate:t}}var xo=require("react");function Ao(e,t){let r=(0,xo.useCallback)((s,n)=>s.resolveName(n),[]);return dn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,query:r})}var _e=require("@naculus/connect-appkit-core"),Ye=require("@naculus/connect-core"),ie=require("react");async function Ys(e,t,r,s,n){let c=_(t);if(!c)throw new Ye.WalletError("wallet_unavailable","Client not initialized");let i=[r,s];if(e.walletType==="eip6963"||e.id?.startsWith("eip6963-")){let{eip6963Connector:h}=await import("@naculus/connector-evm-injected"),u=h.getDiscoveredWallets().find(g=>g.id===e.walletId),l=u?await u.provider.request({method:"personal_sign",params:i}):await h.request({method:"personal_sign",params:i});return(0,_e.assertHexSignature)(l)}if(e.walletType==="walletconnect")return(0,_e.assertHexSignature)(await c.connector.request({method:"personal_sign",params:i}));if(e.walletType==="embedded"){let h=c.embeddedConnector;if(!h?.signHash)throw new Ye.WalletError("method_unsupported","This embedded wallet build cannot sign a raw digest. Upgrade @naculus/connector-embedded or pass an explicit signer.");return(0,_e.assertHexSignature)(await h.signHash(e,r))}throw e.walletType==="passkeys"?new Ye.WalletError("method_unsupported","Passkeys sign with P-256, which a SimpleAccount cannot verify. Use a smart account with a WebAuthn validator, or pass an explicit signer."):new Ye.WalletError("method_unsupported",`Raw UserOperation signing is not available for ${e.walletType} on ${n}. Pass a signer that signs the raw 32-byte hash.`)}function bo(e){let{evmAccount:t}=K(),{session:r,chainId:s,client:n}=I(),[c,i]=(0,ie.useState)(null),[h,u]=(0,ie.useState)(null),[l,g]=(0,ie.useState)(!1),[o,a]=(0,ie.useState)(!1),[p,d]=(0,ie.useState)(null),m=(0,ie.useRef)(0),C=(0,ie.useRef)(!1);(0,ie.useEffect)(()=>()=>{m.current+=1,C.current=!1},[]),(0,ie.useEffect)(()=>{m.current+=1,C.current=!1,i(null),u(null),g(!1),a(!1),d(null)},[n,s,t,e?.accountType,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.owner,e?.rpcUrl,e?.salt,e?.signerMode,r]);let E=(0,ie.useCallback)(async(y,v)=>{let R=b=>(d(b),null);if(!e?.rpcUrl)return R(new Error("RPC URL not configured"));if(!e.bundlerUrl)return R(new Error("Bundler URL not configured"));if(!y.length)return R(new Error("At least one call is required"));if(C.current)return R(new Error("A UserOperation is already in progress"));let w=(0,_e.bareEvmAddress)(e.owner??t);if(!w)return R(new Ye.WalletError("wallet_unavailable","No EVM account found"));let T;try{T=(0,_e.resolveUserOpChain)(e.chainId,s)}catch(b){return R(b)}if(!e.signer&&!r)return R(new Ye.WalletError("wallet_unavailable","No active session"));let k=++m.current;C.current=!0,g(!0),a(!0),d(null),i(null),u(null);try{let{SmartAccountManager:b}=await import("@naculus/connect-core"),U=e.signer??(f=>Ys(r,n,f,w,T)),W=new b({rpcUrl:e.rpcUrl,bundlerClient:{url:e.bundlerUrl},chainId:T,signer:U,signerMode:e.signer?e.signerMode??"eip191":"raw"}),D=(0,_e.buildSmartAccountConfig)(w,T,e),B=await W.sendUserOperation(D,y,v);return k!==m.current?null:(a(!1),i(B.userOpHash),W.getUserOperationReceipt(B.userOpHash).then(f=>{k===m.current&&u(f)}).catch(()=>{}),B)}catch(b){if(k!==m.current)return null;let U=b instanceof Error?b:new Error("Failed to send UserOperation");return d(U),null}finally{C.current=!1,k===m.current&&(g(!1),a(!1))}},[n,s,t,e,r]),A=(0,ie.useCallback)(()=>{m.current+=1,i(null),u(null),g(!1),a(!1),d(null)},[]);return{sendUserOp:E,userOpHash:c,receipt:h,isPending:l,isEstimating:o,error:p,reset:A}}var Ut=require("react");function Js(e,t){if(!e)return()=>{};let r=()=>t();return e.on("sessionConnected",r),e.on("sessionDisconnected",r),e.on("chainChanged",r),e.on("sessionScopeChanged",r),e.on("sessionRevoked",r),()=>{e.off("sessionConnected",r),e.off("sessionDisconnected",r),e.off("chainChanged",r),e.off("sessionScopeChanged",r),e.off("sessionRevoked",r)}}var ir=Object.freeze({session:null,chainSessions:[],activeChainId:null,isConnected:!1,connectorId:null}),lr=new WeakMap;function Zs(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function ea(e){if(!e)return ir;let t=e.getActiveBundle(),r=lr.get(e);if(!t)return r&&r.session===null?r:(lr.set(e,ir),ir);let s=Array.from(t.chainSessions.values());if(r&&r.session===t.walletSession&&r.activeChainId===t.activeChainId&&Zs(r.chainSessions,s))return r;let n={session:t.walletSession,chainSessions:s,activeChainId:t.activeChainId,isConnected:!0,connectorId:t.walletSession.walletType};return lr.set(e,n),n}function Ro(e){let t=I(),r=e??t.sessionManager??null,s=(0,Ut.useCallback)(c=>Js(r,c),[r]),n=(0,Ut.useCallback)(()=>ea(r),[r]);return(0,Ut.useSyncExternalStore)(s,n)}var mn=require("@naculus/connect-appkit-core"),Pt=require("@naculus/connect-core"),De=require("@naculus/siwx"),yt=require("react");var ta=86400;function fn(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,yt.useState)(!1),[c,i]=(0,yt.useState)(null),h=(0,yt.useCallback)(()=>i(null),[]);return{signIn:(0,yt.useCallback)(async l=>{if(!e)throw new Pt.WalletError("wallet_unavailable","No active session");let g=l?.chainId??t;if(!g)throw new Pt.WalletError("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let o=rt(e,g);if(!o)throw new Pt.WalletError("wallet_unavailable","No account found");let a=_(r);if(!a)throw new Pt.WalletError("wallet_unavailable","Client not initialized");let{address:p}=o,d=typeof window>"u"?void 0:window.location,m=l?.domain??(0,mn.defaultSiwxDomain)(d),C=l?.uri??(0,mn.defaultSiwxUri)(d);n(!0),i(null);try{let E=(0,De.generateNonce)();await(0,De.issueNonce)(E);let A=(0,De.nowISO)(),y=l?.expirySeconds??ta,v=new Date(Date.now()+y*1e3).toISOString(),R=(0,De.createSiwxMessage)({domain:m,address:p,uri:C,version:1,chainId:g,nonce:E,issuedAt:A,expirationTime:v,statement:l?.statement,resources:l?.resources,requestId:l?.requestId}),w=await a.signMessage(e,{message:R,address:p,chainId:g??void 0}),T={message:{raw:R,domain:m,address:p,statement:l?.statement??null,uri:C,version:1,chainId:g,nonce:E,issuedAt:A,blockchain:(0,De.getBlockchainName)(g),expirationTime:v,notBefore:null,resources:l?.resources??[],requestId:l?.requestId??null},signature:w};return n(!1),T}catch(E){let A=E instanceof Error?E:new Error("SIWx sign-in failed");throw i(A),n(!1),A}},[e,t,r]),isSigningIn:s,error:c,clearError:h}}var cr=require("@naculus/connect-appkit-core"),gn=require("@naculus/connect-core"),Wt=require("@naculus/siwx"),le=require("react");function To(e){let{storagePrefix:t="naculus_",autoRestore:r=!0,defaultExpirySeconds:s=86400}=e??{},[n,c]=(0,le.useState)(null),[i,h]=(0,le.useState)(r),[u,l]=(0,le.useState)(!1),[g,o]=(0,le.useState)(null),{chainId:a}=I(),p=fn(),d=(0,le.useRef)((0,Wt.createLocalStorageSiwxSessionStorage)(`${t}siwx_session`)),m=(0,le.useCallback)(()=>o(null),[]);(0,le.useEffect)(()=>{if(!r){h(!1);return}let w=!1;return(async()=>{try{let k=await d.current.get();if(w)return;k?(gn.logger.info("react/useSIWxSession","Restored persisted SIWx session"),c(k),o(null)):c(null)}catch(T){gn.logger.warn("react/useSIWxSession","Failed to restore SIWx session:",T),c(null)}finally{w||h(!1)}})(),()=>{w=!0}},[r]),(0,le.useEffect)(()=>{if(!n?.expiresAt)return;let w=new Date(n.expiresAt).getTime()-Date.now();if(w<=0){c(null);return}let T=setTimeout(()=>{c(k=>k&&k.id===n.id?null:k)},w);return()=>clearTimeout(T)},[n?.id,n?.expiresAt]);let C=(0,le.useCallback)(async w=>{l(!0),o(null);try{let T={expirySeconds:s,chainId:a??void 0,...w},k=await p.signIn(T),b=(0,cr.siwxResultToSession)(k);return await d.current.set(b),c(b),l(!1),b}catch(T){let k=T instanceof Error?T:new Error("SIWx sign-in failed");throw o(k),l(!1),k}},[p,a,s]),E=(0,le.useCallback)(async()=>{try{await d.current.remove()}catch(w){gn.logger.warn("react/useSIWxSession","Failed to clear session:",w)}c(null),o(null)},[]),A=(0,le.useCallback)(async()=>{if(!n)throw new Error("No active session to refresh");l(!0),o(null);try{let w=await p.signIn({domain:n.domain,statement:n.message.statement??void 0,uri:n.message.uri,chainId:n.chainId,expirySeconds:s,resources:n.message.resources.length>0?n.message.resources:void 0,requestId:n.message.requestId??void 0}),T={...(0,cr.siwxResultToSession)(w),id:n.id,refreshedAt:new Date().toISOString()};return await d.current.set(T),c(T),l(!1),T}catch(w){let T=w instanceof Error?w:new Error("Session refresh failed");throw o(T),l(!1),T}},[n,p,s]),y=n!==null&&!(0,Wt.checkSessionExpired)(n),v=(0,Wt.checkSessionExpired)(n),R=n?.expiresAt?Math.max(0,new Date(n.expiresAt).getTime()-Date.now()):null;return{session:y?n:null,isAuthenticated:y,isRestoring:i,isSigningIn:u,isExpired:v,timeUntilExpiry:R,signIn:C,signOut:E,refresh:A,error:g,clearError:m}}var hn=require("@naculus/connect-appkit-core"),Ot=require("@naculus/connect-core"),Me=require("@naculus/siwx"),Je=require("react");function Ct(){let{session:e,chainId:t,client:r}=I(),[s,n]=(0,Je.useState)(!1),[c,i]=(0,Je.useState)(null),[h,u]=(0,Je.useState)(null),l=(0,Je.useCallback)(()=>u(null),[]);return{signIn:(0,Je.useCallback)(async o=>{if(!e)throw new Ot.WalletError("wallet_unavailable","No active session");let a=o?.chainId??t;if(!a)throw new Ot.WalletError("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let p=rt(e,a);if(!p)throw new Ot.WalletError("wallet_unavailable","No account found");let d=_(r);if(!d)throw new Ot.WalletError("wallet_unavailable","Client not initialized");let{address:m}=p,C=typeof window>"u"?void 0:window.location,E=o?.domain??(0,hn.defaultSiwxDomain)(C),A=o?.uri??(0,hn.defaultSiwxUri)(C);n(!0),u(null);try{let y=(0,Me.generateNonce)();await(0,Me.issueNonce)(y);let v=(0,Me.nowISO)(),R=(0,Me.createSiwxMessage)({domain:E,address:m,uri:A,version:1,chainId:a,nonce:y,issuedAt:v,statement:o?.statement,expirationTime:o?.expirySeconds?new Date(Date.now()+o.expirySeconds*1e3).toISOString():void 0,resources:o?.resources,requestId:o?.requestId}),w=await d.signMessage(e,{message:R,address:m,chainId:a??void 0}),T=o?.expirySeconds?new Date(Date.now()+o.expirySeconds*1e3).toISOString():null,k={message:{raw:R,domain:E,address:m,statement:o?.statement??null,uri:A,version:1,chainId:a,nonce:y,issuedAt:v,blockchain:(0,Me.getBlockchainName)(a),expirationTime:T,notBefore:null,resources:o?.resources??[],requestId:o?.requestId??null},signature:w};return i(k),k}catch(y){let v=y instanceof Error?y:new Error("SIWx sign-in failed");throw u(v),v}finally{n(!1)}},[e,t,r]),isSigningIn:s,result:c,error:h,clearError:l}}var yn=require("@naculus/connect-core");var ur=require("react");function na(){let{session:e,chainId:t}=I();return(0,ur.useCallback)(r=>{if(!e)throw new yn.WalletError("wallet_unavailable","No active session");let s=r??t;if(s&&!s.startsWith("eip155:"))throw new yn.WalletError("namespace_mismatch",`Ethereum SIWx requires an eip155 chain, received ${s}`);let n=e.namespaces.eip155;if(!n||n.accounts.length===0)throw new yn.WalletError("namespace_mismatch","No EVM (eip155) accounts found in session")},[e,t])}function Io(){let e=na(),t=Ct();return{signIn:(0,ur.useCallback)(async s=>(e(s?.chainId),t.signIn(s)),[e,t.signIn]),isSigningIn:t.isSigningIn,result:t.result,error:t.error,clearError:t.clearError}}var Uo=require("@naculus/connect-appkit-core"),Po=require("@naculus/wallet-engine"),Le=require("react");function Wo(e){let t=e?.rpcUrl,r=e?.chainId,s=(0,Le.useRef)(null),n=(0,Le.useCallback)(()=>(s.current||(s.current=new Po.SimulationManager({enabled:!0,rpcUrl:t,autoSimulate:!1})),s.current),[t]),[c,i]=(0,Le.useState)(null),[h,u]=(0,Le.useState)(!1),[l,g]=(0,Le.useState)(null),o=(0,Le.useCallback)(async(p,d,m,C,E)=>{u(!0),g(null);try{let A=n(),y=(0,Uo.resolveSimulationEndpoint)(E?.chainId,r,E?.rpcUrl,t),v=await A.simulateERC20Transfer(p,d,m,C,y.chainId,E?.decimals,y.rpcUrl);return i(v),v}catch(A){let y=A instanceof Error?A:new Error(String(A));throw g(y),y}finally{u(!1)}},[t,r,n]),a=(0,Le.useCallback)(()=>{i(null),g(null),u(!1)},[]);return{result:c,loading:h,error:l,simulate:o,reset:a}}var Sn=require("@naculus/connect-appkit-core"),Ze=require("@naculus/connect-core"),Ce=require("react");var Cn="siwx_auth";function ra(e){return new Ze.LocalStorageAdapter(e)}function Oo(e){let{storagePrefix:t="naculus_",autoRestore:r=!0}=e??{},[s,n]=(0,Ce.useState)(null),[c,i]=(0,Ce.useState)(r),[h,u]=(0,Ce.useState)(!1),[l,g]=(0,Ce.useState)(null),o=Ct(),a=(0,Ce.useRef)(ra(t)),p=(0,Ce.useCallback)(()=>g(null),[]);(0,Ce.useEffect)(()=>{if(!r){i(!1);return}let C=!1;return(async()=>{try{let E=a.current,A=await E.get(Cn);if(C)return;A&&!(0,Sn.isSiwxExpired)(A,new Date)&&(0,Sn.isSiwxNotBeforeValid)(A,new Date)?(Ze.logger.info("react/useSiwxAuthSession","Restored persisted SIWx auth session"),n(A),g(null)):A&&(Ze.logger.info("react/useSiwxAuthSession","Persisted SIWx auth expired, clearing"),await E.remove(Cn))}catch(E){Ze.logger.warn("react/useSiwxAuthSession","Failed to restore SIWx auth:",E)}finally{C||i(!1)}})(),()=>{C=!0}},[r]);let d=(0,Ce.useCallback)(async C=>{u(!0),g(null);try{let E=await o.signIn(C);return await a.current.set(Cn,E),n(E),u(!1),E}catch(E){let A=E instanceof Error?E:new Error("SIWx sign-in failed");throw g(A),u(!1),A}},[o]),m=(0,Ce.useCallback)(async()=>{try{await a.current.remove(Cn)}catch(C){Ze.logger.warn("react/useSiwxAuthSession","Failed to clear SIWx auth:",C)}n(null),g(null)},[]);return{isSignedIn:s!==null,isRestoring:c,siwxResult:s,isSigningIn:h,error:l,signIn:d,signOut:m,clearError:p}}var et=require("@naculus/connect-appkit-core"),pr=require("@naculus/connect-core"),X=require("react");function No(e){return new pr.WalletError("wallet_unavailable",e)}function _o(e){let{evmAccount:t}=K(),{session:r,chainId:s,client:n}=I(),[c,i]=(0,X.useState)(null),[h,u]=(0,X.useState)(!1),[l,g]=(0,X.useState)(null),[o,a]=(0,X.useState)(!1),[p,d]=(0,X.useState)(null),m=(0,X.useRef)(null),C=(0,X.useRef)(0),E=(0,X.useRef)(!1);(0,X.useEffect)(()=>{if(m.current=null,!e?.rpcUrl)return;let b=!1;return import("@naculus/connect-core").then(({SmartAccountManager:U})=>{if(b)return;let W=(0,et.resolveEvmChainId)(e.chainId,s);W&&(m.current=new U({rpcUrl:e.rpcUrl,chainId:W,bundlerClient:{url:e.bundlerUrl??""}}))}).catch(U=>{b||d(U instanceof Error?U:new Error("Failed to load account-abstraction module"))}),()=>{b=!0}},[s,e?.rpcUrl,e?.bundlerUrl,e?.chainId]),(0,X.useEffect)(()=>{C.current+=1,E.current=!1,i(null),u(!1),g(null),a(!1),d(null)},[t,s,e?.rpcUrl,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.accountType,e?.salt]);let A=(0,X.useCallback)(()=>{let b=(0,et.bareEvmAddress)(t);if(!b||!m.current)return null;let U=(0,et.resolveEvmChainId)(e?.chainId,s);return U?(0,et.buildSmartAccountConfig)(b,U,{accountType:e?.accountType,entryPoint:e?.entryPoint,salt:e?.salt}):null},[t,s,e?.accountType,e?.chainId,e?.entryPoint,e?.salt]),y=(0,X.useCallback)(b=>(d(b),null),[]),v=(0,X.useCallback)(()=>E.current?null:(E.current=!0,C.current),[]),R=(0,X.useCallback)(b=>{C.current===b&&(E.current=!1)},[]),w=(0,X.useCallback)(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));let U=v();if(U===null)return y(new Error("Smart account operation already in progress"));a(!0),d(null);try{let D=await m.current.createAccount(b);return C.current!==U?null:(i(D.address),u(D.isDeployed),g(D),D)}catch(W){if(C.current!==U)return null;let D=W instanceof Error?W:new Error("Failed to create smart account");return d(D),null}finally{C.current===U&&a(!1),R(U)}},[v,y,R,A]),T=(0,X.useCallback)(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));if(!r)return y(No("No active session"));let U=_(n);if(!U)return y(No("Client not initialized"));if(s&&s!==b.chainId)return y(new pr.WalletError("chain_mismatch",`Connected chain ${s} does not match smart account chain ${b.chainId}.`));let W=v();if(W===null)return y(new Error("Smart account operation already in progress"));a(!0),d(null);try{let D=m.current,B=await D.createAccount(b);if(C.current!==W)return null;if(B.isDeployed)return i(B.address),u(!0),g(B),B.address;let f=await D.getDeployCallData(b),S=await U.sendTransaction(r,{transaction:{to:f.to,data:f.data,value:f.value.toString()},chainId:b.chainId});if(C.current!==W)return null;let x=await D.createAccount(b);return i(x.address),u(x.isDeployed),g(x),S}catch(D){if(C.current!==W)return null;let B=D instanceof Error?D:new Error("Failed to deploy smart account");return d(B),null}finally{C.current===W&&a(!1),R(W)}},[n,s,v,y,R,A,r]),k=(0,X.useCallback)(async()=>{let b=A();if(!b||!m.current)return null;let U=C.current;try{let W=await m.current.getAccountAddress(b);return C.current!==U?null:(i(W),W)}catch(W){return C.current!==U||d(W instanceof Error?W:new Error("Failed to get smart account address")),null}},[A]);return{address:c,isDeployed:h,accountInfo:l,isLoading:o,error:p,createWallet:w,deployWallet:T,getAddress:k}}var Do=require("react");function En(){let{accounts:e,isConnected:t}=I();return(0,Do.useMemo)(()=>{if(!t)return{address:null,caip10:null,chainId:null,isConnected:!1};let r=e.find(i=>i.startsWith("solana:"))??null;if(!r)return{address:null,caip10:null,chainId:null,isConnected:t};let s=r.split(":"),n=s.length>=3?s[s.length-1]:null,c=s.length>=3?s.slice(0,-1).join(":"):null;return{address:n,caip10:r,chainId:c,isConnected:t}},[e,t])}var Ie=require("react"),Mo=require("@naculus/connect-core");function Lo(e={}){let{client:t}=I(),{address:r}=En(),s=e.address??r,n=e.rpcUrl??_(t)?.solanaRpcUrl??null,[c,i]=(0,Ie.useState)(null),[h,u]=(0,Ie.useState)(!1),[l,g]=(0,Ie.useState)(null),o=(0,Ie.useRef)(0),a=(0,Ie.useCallback)(async()=>{if(!s||!n){i(null);return}let p=++o.current;u(!0),g(null);try{let d=await(0,Mo.getSolanaBalance)(n,s);if(p!==o.current)return;i(d)}catch(d){if(p!==o.current)return;i(null),g(d instanceof Error?d:new Error("Balance read failed"))}finally{p===o.current&&u(!1)}},[s,n]);return(0,Ie.useEffect)(()=>{a()},[a]),(0,Ie.useEffect)(()=>{if(!e.refreshInterval||e.refreshInterval<=0)return;let p=setInterval(()=>{a()},e.refreshInterval);return()=>clearInterval(p)},[e.refreshInterval,a]),{balance:c,isFetching:h,error:l,isConfigured:!!n,refetch:a}}var Bo=require("@naculus/connect-appkit-core"),Fo=require("react");function Ko(){let{client:e,session:t,accounts:r}=I();return(0,Fo.useMemo)(()=>{let s=_(e)?.solanaConnector,{roles:n,absence:c}=(0,Bo.readSolanaRoles)(s,t);return{roles:n,absence:c,identity:n?.identity??null,signer:n?.signer??null,payer:n?.payer??null}},[e,t,r])}var dr=require("@naculus/connect-core"),ze=require("react"),Ho=require("@naculus/connect-core");function qo(){let{client:e,session:t}=I(),[r,s]=(0,ze.useState)(!1),[n,c]=(0,ze.useState)(!1),[i,h]=(0,ze.useState)(null),u=()=>{let a=_(e);if(!a||!t)throw new dr.WalletError("wallet_unavailable","No connected wallet.");return a},l=(0,ze.useCallback)(async a=>{s(!0),h(null);try{return await u().signTransaction(t,{transaction:a})}catch(p){let d=p instanceof Error?p:new Error("Signing failed");throw h(d),d}finally{s(!1)}},[e,t]),g=(0,ze.useCallback)(async a=>{c(!0),h(null);try{return await u().sendTransaction(t,{transaction:a})}catch(p){let d=p instanceof Error?p:new Error("Send failed");throw h(d),d}finally{c(!1)}},[e,t]),o=(0,ze.useCallback)(async a=>{let p=_(e)?.solanaRpcUrl;if(!p)throw new dr.WalletError("no_rpc","Set solanaRpcUrl on the client to read a signature's status.");return(0,Ho.getSignatureStatus)(p,a)},[e]);return{signTransaction:l,sendTransaction:g,getStatus:o,isSigning:r,isSending:n,error:i,reset:()=>h(null)}}var St=require("react"),Vo=require("@naculus/connect-appkit-core");function zo(){let{switchChain:e,chainId:t}=I(),[r,s]=(0,St.useState)(!1),[n,c]=(0,St.useState)(null),i=(0,St.useCallback)(async u=>{s(!0),c(null);try{await e(u)}catch(l){let g=(0,Vo.toChainSwitchError)(l);throw c(g),g}finally{s(!1)}},[e]),h=(0,St.useCallback)(()=>{c(null)},[]);return{switchChain:i,isSwitching:r,currentChainId:t,error:n,clearError:h}}var Et=require("@naculus/connect-appkit-core"),J=require("react");var wt=require("viem"),oa=[{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"balance",type:"uint256"}]}];function jo(e){let{evmAccount:t,isConnected:r}=K(),{chainId:s,chains:n}=I(),[c,i]=(0,J.useState)([]),[h,u]=(0,J.useState)(!1),[l,g]=(0,J.useState)(null),{tokens:o,refreshInterval:a}=e,p=(0,J.useRef)(null),d=(0,J.useMemo)(()=>o.map(w=>w.address.toLowerCase()+"|"+w.decimals+"|"+w.symbol).join(","),[o]),m=(0,J.useMemo)(()=>(0,Et.resolveChain)(n,s),[s,n]),C=m?(0,Et.chainNumber)(m):null,E=(0,J.useMemo)(()=>m?(0,Et.toViemChain)(m,C):null,[m,C]),[A,y]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!E||!m?.rpcUrl){y(null);return}let w=(0,wt.createPublicClient)({transport:(0,wt.http)(m.rpcUrl),chain:E});y(w)},[m,E]);let v=(0,J.useCallback)(async()=>{if(!t||!A||o.length===0){i([]);return}u(!0),g(null);try{let w=t.includes(":")?t.split(":").pop():t,k=(await Promise.allSettled(o.map(async b=>{try{let U=await A.readContract({address:b.address,abi:oa,functionName:"balanceOf",args:[w]});return{address:b.address,symbol:b.symbol,decimals:b.decimals,name:b.name,balance:U.toString(),formatted:(0,wt.formatUnits)(U,b.decimals)}}catch{return{address:b.address,symbol:b.symbol,decimals:b.decimals,name:b.name,balance:null,formatted:null}}}))).map(b=>b.status==="fulfilled"?b.value:{address:"",symbol:"?",decimals:0,balance:null,formatted:null});i(k)}catch(w){g(w instanceof Error?w:new Error("Failed to fetch token balances"))}finally{u(!1)}},[t,A,d]);(0,J.useEffect)(()=>{r&&t&&o.length>0&&v()},[r,t,d,v]),(0,J.useEffect)(()=>(a&&a>0&&r&&t&&o.length>0&&(p.current=setInterval(v,a)),()=>{p.current&&(clearInterval(p.current),p.current=null)}),[a,r,t,d,v]);let R=(0,J.useCallback)(w=>c.find(T=>T.address.toLowerCase()===w.toLowerCase()),[c]);return{tokenBalances:c,isLoading:h,error:l,refetch:v,getTokenBalance:R,chain:m}}var Ue=require("react");function $o(e,t,r){let s=It(),n=r??s,[c,i]=(0,Ue.useState)([]),[h,u]=(0,Ue.useState)(!1),[l,g]=(0,Ue.useState)(null),o=(0,Ue.useRef)(0),a=(0,Ue.useCallback)(async()=>{if(n){u(!0),g(null),o.current++;try{let d=await n.getTxHistory(e,t);i(d)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{u(!1)}}},[n,e,t]);(0,Ue.useEffect)(()=>{a().catch(()=>{})},[a]),(0,Ue.useEffect)(()=>{if(!n)return;let d=()=>{a().catch(()=>{})};return n.on("statusChange",d),()=>{n.off("statusChange",d)}},[n,a]);let p={pending:c.filter(d=>d.status==="pending").length,confirmed:c.filter(d=>d.status==="confirmed").length,failed:c.filter(d=>d.status==="failed").length};return{entries:c,isLoading:h,error:l,refresh:a,summary:p}}var wn=require("@naculus/connect-appkit-core"),V=require("react");function Go(e){let t=e?.bundlerUrl,r=e?.pollInterval??2e3,s=e?.maxRetries??30,[n,c]=(0,V.useState)("idle"),[i,h]=(0,V.useState)(null),[u,l]=(0,V.useState)(e?.userOpHash??null),[g,o]=(0,V.useState)(null),[a,p]=(0,V.useState)(!1),[d,m]=(0,V.useState)(0),C=(0,V.useRef)(0),[E,A]=(0,V.useState)(0),y=(0,V.useRef)(null),v=(0,V.useRef)(null),R=(0,V.useRef)(0),w=(0,V.useRef)(0),T=(0,V.useRef)(null),k=(0,V.useCallback)(()=>{y.current&&(clearInterval(y.current),y.current=null),v.current&&(clearTimeout(v.current),v.current=null)},[]),b=(0,V.useCallback)(async(S,x)=>{if(!t||x!==R.current)return;let P=w.current+1;w.current=P,m(P);let O=new AbortController;T.current=O;let z=fe=>{x===R.current&&(c("not_found"),p(!1),k(),o(fe))},je=fe=>{if(x===R.current){if(P<=s){v.current=setTimeout(()=>{b(S,x)},r);return}z(fe)}};try{let fe=await(0,wn.fetchUserOperationReceipt)(t,S,O.signal);if(x!==R.current)return;if(fe){h(fe),c(fe.success?"confirmed":"failed"),p(!1),k();return}c("pending"),je(new Error("UserOperation not included after maximum retries"))}catch(fe){if(x!==R.current||O.signal.aborted)return;let xt=fe instanceof Error?fe:new Error("Unknown bundler response failure");if(xt instanceof wn.InvalidUserOperationReceiptError){z(xt);return}je(new Error(`UserOperation status unavailable after ${P} attempt${P===1?"":"s"}: ${xt.message}`))}finally{T.current===O&&(T.current=null)}},[t,r,s,k]),U=(0,V.useCallback)(S=>{R.current+=1;let x=R.current;if(T.current?.abort(),T.current=null,k(),l(S),h(null),o(null),w.current=0,m(0),A(0),C.current=Date.now(),!t){c("not_found"),p(!1),o(new Error("Bundler URL not configured"));return}c("pending"),p(!0),y.current=setInterval(()=>{A(Date.now()-C.current)},1e3),b(S,x)},[t,k,b]),W=(0,V.useCallback)(()=>{R.current+=1,T.current?.abort(),T.current=null,k(),p(!1)},[k]),D=(0,V.useCallback)(()=>{R.current+=1,T.current?.abort(),T.current=null,k(),l(null),c("idle"),h(null),o(null),p(!1),w.current=0,m(0),A(0)},[k]),B=e?.userOpHash??null,f=e?.autoStart!==!1;return(0,V.useEffect)(()=>{B&&f&&U(B)},[B,f,U]),(0,V.useEffect)(()=>()=>{R.current+=1,T.current?.abort(),T.current=null,k()},[k]),{status:n,receipt:i,userOpHash:u,error:g,isPolling:a,elapsedMs:E,attempts:d,start:U,stop:W,reset:D}}var Jo=require("@naculus/connect-appkit-core"),Zo=require("react");var sa={"storage.critical.title":"Insecure Storage Detected","storage.critical.body":"Your browser does not support IndexedDB. Wallet data is stored in plaintext in localStorage and could be exposed to XSS attacks. We strongly recommend switching to a modern browser.","storage.warning.title":"Storage Security Warning","storage.warning.body":"Your browser does not support IndexedDB, but your wallet data is encrypted with AES-256-GCM. Consider switching browsers for better origin isolation.","address.empty":"Address is empty","address.invalid_format":"Invalid address format (expected 0x + 40 hex chars)","address.zero_address":"Address is the zero address \u2014 funds would be permanently lost","address.burn_address":"Address appears to be a burn address \u2014 funds would be permanently lost","wallet.connect":"Connect Wallet","wallet.disconnect":"Disconnect","wallet.connecting":"Connecting...","wallet.copy_address":"Copy address","wallet.copied":"Copied!","wallet.view_on_explorer":"View on Explorer","wallet.retry":"Retry","wallet.connection_failed":"Connection failed","wallet.scan_qr":"Scan with your wallet app","embedded.generate":"Create Wallet","embedded.import":"Import Wallet","embedded.backup_seed":"Back up your seed phrase","embedded.backup_warning":"Anyone with your seed phrase can access your funds. Store it securely.","embedded.backup_done":"I've saved my seed phrase","embedded.wipe":"Remove Wallet","embedded.wipe_confirm":"Are you sure? This cannot be undone."},aa={"storage.critical.title":"\u5075\u6E2C\u5230\u4E0D\u5B89\u5168\u5132\u5B58","storage.critical.body":"\u60A8\u7684\u700F\u89BD\u5668\u4E0D\u652F\u63F4 IndexedDB\u3002\u9322\u5305\u8CC7\u6599\u4EE5\u660E\u6587\u5132\u5B58\u5728 localStorage \u4E2D\uFF0C\u53EF\u80FD\u66B4\u9732\u65BC XSS \u653B\u64CA\u3002\u5F37\u70C8\u5EFA\u8B70\u66F4\u63DB\u81F3\u73FE\u4EE3\u700F\u89BD\u5668\u3002","storage.warning.title":"\u5132\u5B58\u5B89\u5168\u8B66\u544A","storage.warning.body":"\u60A8\u7684\u700F\u89BD\u5668\u4E0D\u652F\u63F4 IndexedDB\uFF0C\u4F46\u9322\u5305\u8CC7\u6599\u5DF2\u4F7F\u7528 AES-256-GCM \u52A0\u5BC6\u3002\u5EFA\u8B70\u66F4\u63DB\u700F\u89BD\u5668\u4EE5\u7372\u5F97\u66F4\u597D\u7684\u9694\u96E2\u4FDD\u8B77\u3002","address.empty":"\u5730\u5740\u70BA\u7A7A","address.invalid_format":"\u7121\u6548\u7684\u5730\u5740\u683C\u5F0F\uFF08\u61C9\u70BA 0x + 40 \u500B\u5341\u516D\u9032\u4F4D\u5B57\u5143\uFF09","address.zero_address":"\u6B64\u70BA\u96F6\u5730\u5740 \u2014 \u8CC7\u91D1\u5C07\u6C38\u4E45\u4E1F\u5931","address.burn_address":"\u6B64\u5730\u5740\u70BA\u71D2\u6BC0\u5730\u5740 \u2014 \u8CC7\u91D1\u5C07\u6C38\u4E45\u4E1F\u5931","wallet.connect":"\u9023\u63A5\u9322\u5305","wallet.disconnect":"\u65B7\u958B\u9023\u7DDA","wallet.connecting":"\u9023\u7DDA\u4E2D...","wallet.copy_address":"\u8907\u88FD\u5730\u5740","wallet.copied":"\u5DF2\u8907\u88FD\uFF01","wallet.view_on_explorer":"\u5728\u700F\u89BD\u5668\u67E5\u770B","wallet.retry":"\u91CD\u8A66","wallet.connection_failed":"\u9023\u7DDA\u5931\u6557","wallet.scan_qr":"\u4F7F\u7528\u9322\u5305 App \u6383\u63CF","embedded.generate":"\u5EFA\u7ACB\u9322\u5305","embedded.import":"\u532F\u5165\u9322\u5305","embedded.backup_seed":"\u5099\u4EFD\u52A9\u8A18\u8A5E","embedded.backup_warning":"\u4EFB\u4F55\u4EBA\u53D6\u5F97\u60A8\u7684\u52A9\u8A18\u8A5E\u90FD\u53EF\u4EE5\u5B58\u53D6\u60A8\u7684\u8CC7\u91D1\u3002\u8ACB\u5B89\u5168\u5132\u5B58\u3002","embedded.backup_done":"\u6211\u5DF2\u5132\u5B58\u52A9\u8A18\u8A5E","embedded.wipe":"\u79FB\u9664\u9322\u5305","embedded.wipe_confirm":"\u78BA\u5B9A\u8981\u79FB\u9664\u55CE\uFF1F\u6B64\u64CD\u4F5C\u7121\u6CD5\u5FA9\u539F\u3002"},Xo={en:sa,zh:aa},mr="en";function Qo(e){mr=e}function Yo(){return mr}function kn(e){return Xo[mr][e]??Xo.en[e]??e}function fr(e){let{isValid:t,level:r,issue:s}=(0,Jo.validateDestination)(e);return{isValid:t,level:r,warning:s?kn(`address.${s}`):null}}function es({address:e}){return{validation:(0,Zo.useMemo)(()=>fr(e),[e])}}function ts(){let{status:e,session:t,accounts:r,chainId:s,error:n,connect:c,disconnect:i,reconnect:h,switchChain:u}=I(),l=e==="connected",g=e==="connecting",o=e==="reconnecting",a=r[0]??null;return{status:e,session:t,accounts:r,chainId:s,error:n,isConnected:l,isConnecting:g,isReconnecting:o,isDisconnected:e==="disconnected",currentAccount:a,connect:c,disconnect:i,reconnect:h,switchChain:u}}var tt=require("react");var gr={wallet_unavailable:"Wallet Not Detected",user_rejected:"Connection Rejected",deeplink_timeout:"Wallet Connection Timed Out",session_expired:"Session Expired",intent_expired:"Connection Request Expired",namespace_mismatch:"Network Mismatch",chain_unsupported:"Unsupported Network",method_not_allowed:"Action Not Allowed",signature_rejected:"Signature Rejected",tx_failed:"Transaction Failed"},hr={wallet_unavailable:"No wallet found. Please install a compatible wallet (e.g., MetaMask, WalletConnect) and try again.",user_rejected:"The connection request was declined in your wallet. You can try again whenever you're ready.",deeplink_timeout:"The wallet didn't respond in time. This can happen if the wallet app isn't installed or takes too long to open.",session_expired:"Your wallet session has expired. Please reconnect to continue.",intent_expired:"The connection request expired. Please try connecting again.",namespace_mismatch:"This wallet doesn't support the required network. Try using a different wallet or network.",chain_unsupported:"This network isn't supported. Please switch to a supported network in your wallet.",method_not_allowed:"This action isn't supported by your current wallet or network.",signature_rejected:"The signature request was declined in your wallet.",tx_failed:"The transaction couldn't be completed. This could be due to insufficient funds, network congestion, or a contract error."},Nt="Something went wrong",_t="An unexpected error occurred. Please try again. If the problem persists, check your connection and wallet configuration.";function kt(e){if(!e)return{title:Nt,description:_t};let t=e;if(t.name==="WalletError"&&t.code){let r=t.code,s=gr[r]??Nt,n=hr[r]??t.message??_t;return{title:s,description:n,code:r}}if(e instanceof Error){let r=e.message;return/user rejected/i.test(r)||/rejected/.test(r)?{title:"Request Rejected",description:"The request was declined.",code:"user_rejected"}:/timeout/i.test(r)||/timed? ?out/i.test(r)?{title:"Request Timed Out",description:"The request took too long. Please try again.",code:"deeplink_timeout"}:/insufficient funds/i.test(r)?{title:"Insufficient Funds",description:"You don't have enough funds to complete this transaction.",code:"tx_failed"}:/network/i.test(r)||/chain/i.test(r)?{title:"Network Error",description:r,code:"chain_unsupported"}:{title:Nt,description:r||_t}}return typeof e=="string"?{title:Nt,description:e||_t}:{title:Nt,description:_t}}function vn(e){if(e===null||typeof e!="object")return!1;let t=e;return t.name!=="WalletError"||!t.code?!1:["deeplink_timeout","session_expired","intent_expired","tx_failed"].includes(t.code)}function ns(){let{error:e,clearError:t}=I(),r=(0,tt.useMemo)(()=>e?kt(e):null,[e]),s=(0,tt.useMemo)(()=>e?vn(e):!1,[e]),n=(0,tt.useCallback)(()=>{t()},[t]),c=(0,tt.useCallback)(h=>kt(h),[]),i=(0,tt.useCallback)(h=>async()=>{try{return await h()}catch(u){let l=kt(u);if(u instanceof Error){let g=u;try{g.title=l.title,g.friendlyMessage=l.description,g.code===void 0&&l.code!==void 0&&(g.code=l.code)}catch{}throw g}throw Object.assign(new Error(l.description,{cause:u}),{title:l.title,code:l.code,friendlyMessage:l.description})}},[]);return{error:e,friendlyError:r,clearError:n,isRetryable:s,formatError:c,wrapAsync:i}}var Ae=require("react"),rs=require("@naculus/connect-core"),yr=require("@naculus/connect-appkit-core");function Dt(e,t){let r=(0,Ae.useRef)(null),[s,n]=(0,Ae.useState)([]),[c,i]=(0,Ae.useState)(t?.autoLoad!==!1),[h,u]=(0,Ae.useState)(!1),[l,g]=(0,Ae.useState)(null);if(!r.current){let p={};t?.sources&&(p.sources=t.sources),r.current=new rs.TokenListManager(p)}let o=(0,Ae.useCallback)(async()=>{let p=r.current;if(p){i(!0),g(null);try{await p.load();let d=e?(0,yr.eip155ChainIdToNumber)(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),u(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]),a=(0,Ae.useCallback)(async()=>{let p=r.current;if(p){i(!0),g(null);try{await p.refresh();let d=e?(0,yr.eip155ChainIdToNumber)(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),u(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]);return(0,Ae.useEffect)(()=>{t?.autoLoad!==!1&&o()},[o,t?.autoLoad]),{tokens:s,isLoading:c,isLoaded:h,error:l,refetch:a}}var nt=require("react"),ss=require("@naculus/connect-core");var Be=require("@naculus/connect-core");function os(){return[{name:"built-in",tokens:[...Be.ETHEREUM_MAINNET_TOKENS,...Be.POLYGON_TOKENS,...Be.OPTIMISM_TOKENS,...Be.ARBITRUM_TOKENS,...Be.BASE_TOKENS],enabled:!0},{name:"uniswap-default",url:"https://tokens.uniswap.org",enabled:!0,refreshInterval:1440*60*1e3}]}var as=require("@naculus/connect-appkit-core"),ia=300,xn=null;function la(){return xn||(xn=new ss.TokenListManager({sources:os()}),xn.load().catch(()=>{})),xn}function Mt(e,t){let[r,s]=(0,nt.useState)({exact:[],fuzzy:[],hasMore:!1}),[n,c]=(0,nt.useState)(!1),i=(0,nt.useRef)(null),h=e.trim();return(0,nt.useEffect)(()=>{if(!h){s({exact:[],fuzzy:[],hasMore:!1}),c(!1);return}return i.current&&clearTimeout(i.current),c(!0),i.current=setTimeout(()=>{let u=la(),l=t?(0,as.eip155ChainIdToNumber)(t):void 0,g=u.search(h,{chainId:l,limit:20});s(g),c(!1)},ia),()=>{i.current&&clearTimeout(i.current)}},[h,t]),{results:r,isSearching:n}}var vt=He(require("react"),1);var F=require("react/jsx-runtime");function Cr({chainId:e,onSelect:t,onClose:r,options:s}){let[n,c]=vt.default.useState(""),{tokens:i,isLoading:h,error:u}=Dt(e),{results:l,isSearching:g}=Mt(n,n?e:void 0),o=s?.showRecommendations??!0,a=vt.default.useMemo(()=>{if(n.trim()){let C=[...l.exact,...l.fuzzy].map(E=>E.token);return s?.filter?C.filter(s.filter):C}let m=i;return s?.filter?m.filter(s.filter):m},[n,l,i,s?.filter]),p=vt.default.useMemo(()=>!o||n.trim()?[]:i.slice(0,6),[i,o,n]),d=(0,vt.useCallback)(m=>{t(m),r()},[t,r]);return(0,F.jsxs)("div",{style:{background:"hsl(var(--background))",borderRadius:"12px",padding:"16px",color:"hsl(var(--foreground))",minWidth:"320px",maxWidth:"400px",fontFamily:"system-ui, sans-serif"},children:[(0,F.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[(0,F.jsx)("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Select Token"}),(0,F.jsx)("button",{type:"button",onClick:r,style:{background:"none",border:"none",color:"hsl(var(--muted-foreground))",cursor:"pointer",fontSize:"18px",padding:"4px 8px"},children:"\u2715"})]}),(0,F.jsx)("input",{type:"text",placeholder:"Search token name or paste address",value:n,onChange:m=>c(m.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:"8px",border:"1px solid #333",background:"hsl(var(--card))",color:"hsl(var(--foreground))",fontSize:"14px",outline:"none",boxSizing:"border-box",marginBottom:"12px"},autoFocus:!0}),h&&!g&&(0,F.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"hsl(var(--muted-foreground))"},children:"Loading tokens..."}),u&&(0,F.jsxs)("div",{style:{textAlign:"center",padding:"12px",color:"hsl(var(--destructive))",fontSize:"13px"},children:["Error: ",u.message]}),o&&p.length>0&&!n.trim()&&(0,F.jsxs)("div",{style:{marginBottom:"12px"},children:[(0,F.jsx)("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},children:"Popular"}),(0,F.jsx)("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:p.map(m=>(0,F.jsxs)("button",{type:"button",onClick:()=>d(m),style:{background:"hsl(var(--card))",border:"1px solid #333",borderRadius:"20px",padding:"6px 14px",color:"hsl(var(--foreground))",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"4px"},children:[m.logoURI?(0,F.jsx)("img",{src:m.logoURI,alt:"",style:{width:"16px",height:"16px",borderRadius:"50%"},onError:C=>{C.target.style.display="none"}}):null,m.symbol]},`${m.chainId}:${m.address}`))})]}),n.trim()&&!h&&(0,F.jsx)("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",marginBottom:"8px"},children:a.length>0?(0,F.jsxs)(F.Fragment,{children:[l.exact.length," exact, ",l.fuzzy.length," fuzzy",l.hasMore?" (more available)":""]}):"No results found"}),(0,F.jsx)("div",{style:{maxHeight:"320px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"2px"},children:a.map(m=>(0,F.jsxs)("button",{type:"button",onClick:()=>d(m),style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 8px",background:"transparent",border:"none",borderRadius:"8px",color:"hsl(var(--foreground))",cursor:"pointer",textAlign:"left",width:"100%",fontSize:"14px"},onMouseEnter:C=>{C.target.style.background="hsl(var(--card))"},onMouseLeave:C=>{C.target.style.background="transparent"},children:[(0,F.jsx)("div",{style:{width:"32px",height:"32px",borderRadius:"50%",background:"hsl(var(--border))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,overflow:"hidden"},children:m.logoURI?(0,F.jsx)("img",{src:m.logoURI,alt:m.symbol,style:{width:"100%",height:"100%"},onError:C=>{let E=C.target;E.style.display="none",E.parentElement.textContent=m.symbol.slice(0,2)}}):m.symbol.slice(0,2)}),(0,F.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,F.jsx)("div",{style:{fontWeight:600,fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.symbol}),(0,F.jsx)("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.name})]}),(0,F.jsxs)("div",{style:{fontSize:"11px",color:"#666",textAlign:"right",flexShrink:0},children:[(0,F.jsxs)("div",{children:[m.decimals," decimals"]}),(0,F.jsxs)("div",{children:["Chain ",m.chainId]})]})]},`${m.chainId}:${m.address}`))})]})}var M=require("@stencil/react-output-target/runtime"),L=He(require("react"),1),An=require("@naculus/connect-appkit-wc/dist/components/appkit-accordion.js"),bn=require("@naculus/connect-appkit-wc/dist/components/appkit-account-button.js"),Rn=require("@naculus/connect-appkit-wc/dist/components/appkit-alert-dialog.js"),Tn=require("@naculus/connect-appkit-wc/dist/components/appkit-avatar.js"),In=require("@naculus/connect-appkit-wc/dist/components/appkit-badge.js"),Un=require("@naculus/connect-appkit-wc/dist/components/appkit-button.js"),Pn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-content.js"),Wn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-description.js"),On=require("@naculus/connect-appkit-wc/dist/components/appkit-card-footer.js"),Nn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-header.js"),_n=require("@naculus/connect-appkit-wc/dist/components/appkit-card-title.js"),Dn=require("@naculus/connect-appkit-wc/dist/components/appkit-card.js"),Mn=require("@naculus/connect-appkit-wc/dist/components/appkit-checkbox.js"),Ln=require("@naculus/connect-appkit-wc/dist/components/appkit-collapsible.js"),Bn=require("@naculus/connect-appkit-wc/dist/components/appkit-connect-button.js"),Fn=require("@naculus/connect-appkit-wc/dist/components/appkit-dialog.js"),Kn=require("@naculus/connect-appkit-wc/dist/components/appkit-dropdown-menu.js"),Hn=require("@naculus/connect-appkit-wc/dist/components/appkit-input.js"),qn=require("@naculus/connect-appkit-wc/dist/components/appkit-popover.js"),Vn=require("@naculus/connect-appkit-wc/dist/components/appkit-progress.js"),zn=require("@naculus/connect-appkit-wc/dist/components/appkit-scroll-area.js"),jn=require("@naculus/connect-appkit-wc/dist/components/appkit-select.js"),$n=require("@naculus/connect-appkit-wc/dist/components/appkit-separator.js"),Gn=require("@naculus/connect-appkit-wc/dist/components/appkit-skeleton.js"),Xn=require("@naculus/connect-appkit-wc/dist/components/appkit-switch.js"),Qn=require("@naculus/connect-appkit-wc/dist/components/appkit-tabs.js"),Yn=require("@naculus/connect-appkit-wc/dist/components/appkit-toggle-group.js"),Jn=require("@naculus/connect-appkit-wc/dist/components/appkit-tooltip.js"),is=(0,M.createComponent)({tagName:"appkit-accordion",elementClass:An.AppkitAccordion,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:An.defineCustomElement}),ls=(0,M.createComponent)({tagName:"appkit-account-button",elementClass:bn.AppkitAccountButton,react:L.default,events:{},defineCustomElement:bn.defineCustomElement}),cs=(0,M.createComponent)({tagName:"appkit-alert-dialog",elementClass:Rn.AppkitAlertDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Rn.defineCustomElement}),us=(0,M.createComponent)({tagName:"appkit-avatar",elementClass:Tn.AppkitAvatar,react:L.default,events:{},defineCustomElement:Tn.defineCustomElement}),ps=(0,M.createComponent)({tagName:"appkit-badge",elementClass:In.AppkitBadge,react:L.default,events:{},defineCustomElement:In.defineCustomElement}),ds=(0,M.createComponent)({tagName:"appkit-button",elementClass:Un.AppkitButton,react:L.default,events:{},defineCustomElement:Un.defineCustomElement}),ms=(0,M.createComponent)({tagName:"appkit-card",elementClass:Dn.AppkitCard,react:L.default,events:{},defineCustomElement:Dn.defineCustomElement}),fs=(0,M.createComponent)({tagName:"appkit-card-content",elementClass:Pn.AppkitCardContent,react:L.default,events:{},defineCustomElement:Pn.defineCustomElement}),gs=(0,M.createComponent)({tagName:"appkit-card-description",elementClass:Wn.AppkitCardDescription,react:L.default,events:{},defineCustomElement:Wn.defineCustomElement}),hs=(0,M.createComponent)({tagName:"appkit-card-footer",elementClass:On.AppkitCardFooter,react:L.default,events:{},defineCustomElement:On.defineCustomElement}),ys=(0,M.createComponent)({tagName:"appkit-card-header",elementClass:Nn.AppkitCardHeader,react:L.default,events:{},defineCustomElement:Nn.defineCustomElement}),Cs=(0,M.createComponent)({tagName:"appkit-card-title",elementClass:_n.AppkitCardTitle,react:L.default,events:{},defineCustomElement:_n.defineCustomElement}),Ss=(0,M.createComponent)({tagName:"appkit-checkbox",elementClass:Mn.AppkitCheckbox,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Mn.defineCustomElement}),Es=(0,M.createComponent)({tagName:"appkit-collapsible",elementClass:Ln.AppkitCollapsible,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:Ln.defineCustomElement}),ws=(0,M.createComponent)({tagName:"appkit-connect-button",elementClass:Bn.AppkitConnectButton,react:L.default,events:{onAppkitConnect:"appkitConnect",onAppkitDisconnect:"appkitDisconnect",onAppkitStartPairing:"appkitStartPairing",onAppkitRetry:"appkitRetry",onAppkitCancelPairing:"appkitCancelPairing",onAppkitMobileDeepLink:"appkitMobileDeepLink",onAppkitCopyAddress:"appkitCopyAddress"},defineCustomElement:Bn.defineCustomElement}),ks=(0,M.createComponent)({tagName:"appkit-dialog",elementClass:Fn.AppkitDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Fn.defineCustomElement}),vs=(0,M.createComponent)({tagName:"appkit-dropdown-menu",elementClass:Kn.AppkitDropdownMenu,react:L.default,events:{onAppkitSelect:"appkitSelect"},defineCustomElement:Kn.defineCustomElement}),xs=(0,M.createComponent)({tagName:"appkit-input",elementClass:Hn.AppkitInput,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Hn.defineCustomElement}),As=(0,M.createComponent)({tagName:"appkit-popover",elementClass:qn.AppkitPopover,react:L.default,events:{onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:qn.defineCustomElement}),bs=(0,M.createComponent)({tagName:"appkit-progress",elementClass:Vn.AppkitProgress,react:L.default,events:{},defineCustomElement:Vn.defineCustomElement}),Rs=(0,M.createComponent)({tagName:"appkit-scroll-area",elementClass:zn.AppkitScrollArea,react:L.default,events:{},defineCustomElement:zn.defineCustomElement}),Ts=(0,M.createComponent)({tagName:"appkit-select",elementClass:jn.AppkitSelect,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:jn.defineCustomElement}),Is=(0,M.createComponent)({tagName:"appkit-separator",elementClass:$n.AppkitSeparator,react:L.default,events:{},defineCustomElement:$n.defineCustomElement}),Us=(0,M.createComponent)({tagName:"appkit-skeleton",elementClass:Gn.AppkitSkeleton,react:L.default,events:{},defineCustomElement:Gn.defineCustomElement}),Ps=(0,M.createComponent)({tagName:"appkit-switch",elementClass:Xn.AppkitSwitch,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Xn.defineCustomElement}),Ws=(0,M.createComponent)({tagName:"appkit-tabs",elementClass:Qn.AppkitTabs,react:L.default,events:{onAppkitTabChange:"appkitTabChange"},defineCustomElement:Qn.defineCustomElement}),Os=(0,M.createComponent)({tagName:"appkit-toggle-group",elementClass:Yn.AppkitToggleGroup,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Yn.defineCustomElement}),Ns=(0,M.createComponent)({tagName:"appkit-tooltip",elementClass:Jn.AppkitTooltip,react:L.default,events:{},defineCustomElement:Jn.defineCustomElement});0&&(module.exports={AppkitAccordion,AppkitAccountButton,AppkitAlertDialog,AppkitAvatar,AppkitBadge,AppkitButton,AppkitCard,AppkitCardContent,AppkitCardDescription,AppkitCardFooter,AppkitCardHeader,AppkitCardTitle,AppkitCheckbox,AppkitCollapsible,AppkitConnectButton,AppkitDialog,AppkitDropdownMenu,AppkitInput,AppkitPopover,AppkitProgress,AppkitScrollArea,AppkitSelect,AppkitSeparator,AppkitSkeleton,AppkitSwitch,AppkitTabs,AppkitToggleGroup,AppkitTooltip,DEFAULT_EVM_CHAINS,LAMPORTS_PER_SOL,PassphraseCancelledError,PassphraseGate,SolanaRpcError,TokenSelector,TxMonitorContext,WALLET_ERROR_DESCRIPTIONS,WALLET_ERROR_TITLES,Web3ConnectProvider,Web3Context,buildDelegationPolicyMessage,clearClient,createClient,formatSol,getChainById,getClient,getDefaultChains,getLatestBlockhash,getLocale,getSignatureStatus,getSolanaBalance,getUserFriendlyError,isRetryableError,parseSol,resetSessionKeyManager,setLocale,t,useAccount,useAuthorizations,useBalance,useCapabilities,useChain,useCompareCosts,useConnect,useCreateSessionKey,useDelegate,useDelegation,useDelegationPolicy,useDisconnect,useERC20Allowance,useERC20Approve,useERC20Transfer,useERC20TransferSimulation,useEmbeddedWallet,useExecuteCalls,useExecuteRoute,useLastTx,useLookupAddress,useMppSession,useNotification,usePassphraseGate,usePaymentFetch,useResolveName,useRevokeSession,useRouteQuote,useSIWxLogin,useSIWxSession,useSendCalls,useSendTransaction,useSendUserOperation,useSendWithSession,useSession,useSessionKeys,useSignInWithEthereum,useSignInWithX,useSignMessage,useSimulateTransfer,useSiwxAuthSession,useSmartAccount,useSolanaAccount,useSolanaBalance,useSolanaRoles,useSolanaSessionKey,useSolanaTransaction,useSwitchChain,useTokenBalance,useTokenList,useTokenSearch,useTransactionSimulation,useTxHistory,useTxMonitor,useUserOpStatus,useValidateDestination,useViemClient,useWallet,useWeb3,useWeb3ErrorHandler,useX402Signer,validateDestination});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|