@naculus/connect-appkit-react 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Us=Object.create;var Lt=Object.defineProperty;var Ps=Object.getOwnPropertyDescriptor;var Ws=Object.getOwnPropertyNames;var Os=Object.getPrototypeOf,Ns=Object.prototype.hasOwnProperty;var _s=(e,t)=>{for(var o in t)Lt(e,o,{get:t[o],enumerable:!0})},yr=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ws(t))!Ns.call(e,n)&&n!==o&&Lt(e,n,{get:()=>t[n],enumerable:!(s=Ps(t,n))||s.enumerable});return e};var He=(e,t,o)=>(o=e!=null?Us(Os(e)):{},yr(t||!e||!e.__esModule?Lt(o,"default",{value:e,enumerable:!0}):o,e)),Ds=e=>yr(Lt({},"__esModule",{value:!0}),e);var oa={};_s(oa,{AppkitAccordion:()=>ns,AppkitAccountButton:()=>rs,AppkitAlertDialog:()=>os,AppkitAvatar:()=>ss,AppkitBadge:()=>as,AppkitButton:()=>is,AppkitCard:()=>ls,AppkitCardContent:()=>cs,AppkitCardDescription:()=>us,AppkitCardFooter:()=>ps,AppkitCardHeader:()=>ds,AppkitCardTitle:()=>ms,AppkitCheckbox:()=>fs,AppkitCollapsible:()=>gs,AppkitConnectButton:()=>hs,AppkitDialog:()=>ys,AppkitDropdownMenu:()=>Cs,AppkitInput:()=>Ss,AppkitPopover:()=>Es,AppkitProgress:()=>ws,AppkitScrollArea:()=>ks,AppkitSelect:()=>vs,AppkitSeparator:()=>xs,AppkitSkeleton:()=>As,AppkitSwitch:()=>bs,AppkitTabs:()=>Rs,AppkitToggleGroup:()=>Ts,AppkitTooltip:()=>Is,DEFAULT_EVM_CHAINS:()=>nr,LAMPORTS_PER_SOL:()=>Z.LAMPORTS_PER_SOL,PassphraseCancelledError:()=>Z.PassphraseCancelledError,PassphraseGate:()=>Z.PassphraseGate,SolanaRpcError:()=>Z.SolanaRpcError,TokenSelector:()=>hr,TxMonitorContext:()=>or,WALLET_ERROR_DESCRIPTIONS:()=>fr,WALLET_ERROR_TITLES:()=>mr,Web3ConnectProvider:()=>Rr,Web3Context:()=>Vt,buildDelegationPolicyMessage:()=>rr.buildDelegationPolicyMessage,clearClient:()=>kr,createClient:()=>Ft,formatSol:()=>Z.formatSol,getChainById:()=>br,getClient:()=>Kt,getDefaultChains:()=>qt,getLatestBlockhash:()=>Z.getLatestBlockhash,getLocale:()=>jo,getSignatureStatus:()=>Z.getSignatureStatus,getSolanaBalance:()=>Z.getSolanaBalance,getUserFriendlyError:()=>kt,isRetryableError:()=>kn,parseSol:()=>Z.parseSol,resetSessionKeyManager:()=>Gr,setLocale:()=>zo,t:()=>wn,useAccount:()=>K,useAuthorizations:()=>Ur,useBalance:()=>Wr,useCapabilities:()=>jt,useChain:()=>pe,useCompareCosts:()=>Jn,useConnect:()=>Nr,useCreateSessionKey:()=>zr,useDelegate:()=>Dr,useDelegation:()=>ct,useDelegationPolicy:()=>Xr,useDisconnect:()=>Yr,useERC20Allowance:()=>no,useERC20Approve:()=>ro,useERC20Transfer:()=>oo,useERC20TransferSimulation:()=>lo,useEmbeddedWallet:()=>Jr,useExecuteCalls:()=>Zt,useExecuteRoute:()=>Zn,useLastTx:()=>uo,useLookupAddress:()=>fo,useMppSession:()=>Br,useNotification:()=>ho,usePassphraseGate:()=>Co,usePaymentFetch:()=>Mr,useResolveName:()=>Eo,useRevokeSession:()=>jr,useRouteQuote:()=>er,useSIWxLogin:()=>mn,useSIWxSession:()=>vo,useSendCalls:()=>Yt,useSendTransaction:()=>ft,useSendUserOperation:()=>wo,useSendWithSession:()=>$r,useSession:()=>ko,useSessionKeys:()=>tn,useSignInWithEthereum:()=>xo,useSignInWithX:()=>Ct,useSignMessage:()=>rn,useSimulateTransfer:()=>Ro,useSiwxAuthSession:()=>To,useSmartAccount:()=>Uo,useSolanaAccount:()=>Sn,useSolanaBalance:()=>Oo,useSolanaRoles:()=>Do,useSolanaSessionKey:()=>Hr,useSolanaTransaction:()=>Lo,useSwitchChain:()=>Fo,useTokenBalance:()=>Ko,useTokenList:()=>Dt,useTokenSearch:()=>Mt,useTransactionSimulation:()=>ln,useTxHistory:()=>Ho,useTxMonitor:()=>co,useUserOpStatus:()=>qo,useValidateDestination:()=>Qo,useViemClient:()=>de,useWallet:()=>Xo,useWeb3:()=>U,useWeb3ErrorHandler:()=>Yo,validateDestination:()=>dr});module.exports=Ds(oa);var Z=require("@naculus/connect-core");var Cr=require("@naculus/connect-appkit-core"),ge=require("react");function Jn(e,t){let{operation:o,chains:s,options:n}=e,[u,i]=(0,ge.useState)([]),[h,c]=(0,ge.useState)(!1),[l,g]=(0,ge.useState)(null),r=(0,ge.useRef)(!0),a=(0,ge.useRef)(0),p=(0,Cr.compareCostsKey)(e),d=(0,ge.useCallback)(async()=>{if(!s||s.length===0){i([]);return}if(!t)return;let C=++a.current;c(!0),g(null);try{let E=await t(o,s,n);r.current&&C===a.current&&i(E)}catch(E){r.current&&C===a.current&&(g(E instanceof Error?E:new Error(String(E))),i([]))}finally{r.current&&C===a.current&&c(!1)}},[p,t]);(0,ge.useEffect)(()=>{d()},[d]),(0,ge.useEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]);let m=(0,ge.useCallback)(async()=>{await d()},[d]);return{comparisons:u,loading:h,error:l,refresh:m}}var Bt=require("@naculus/connect-appkit-core"),Se=require("react");function Zn(e){let[t,o]=(0,Se.useState)(!1),[s,n]=(0,Se.useState)(null),[u,i]=(0,Se.useState)(null),h=(0,Se.useRef)(!0),c=(0,Se.useRef)(!1);(0,Se.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let l=(0,Se.useCallback)(async(r,a,p)=>{if(!e)return i({code:"no_executor",message:"No executeRoute function provided"}),n(null),null;let d=(0,Bt.validateRouteRecipient)(r,a);if(d)return i(d),n(null),null;if(c.current)return i({code:"execution_in_progress",message:"A route execution is already in progress"}),null;c.current=!0,o(!0),i(null),n(null);try{let m=await e(r,a,p);return h.current&&n(m),m}catch(m){return h.current&&i((0,Bt.toExecuteRouteError)(m)),null}finally{c.current=!1,h.current&&o(!1)}},[e]),g=(0,Se.useCallback)(()=>{n(null),i(null),o(!1)},[]);return{execute:l,executing:t,result:s,error:u,reset:g}}var Sr=require("@naculus/connect-appkit-core"),ce=require("react");function er(e,t){let{fromChain:o,toChain:s,fromToken:n,toToken:u,amount:i,options:h}=e,[c,l]=(0,ce.useState)([]),[g,r]=(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,Sr.isQuotableInput)({fromChain:o,toChain:s,fromToken:n,amount:i})){l([]);return}if(t){r(!0),p(null);try{let y=await t(o,s,n,i,h,u);m.current&&l(y)}catch(y){m.current&&(p(y instanceof Error?y:new Error(String(y))),l([]))}finally{m.current&&r(!1)}}},[o,s,n,u,i,h,t]);(0,ce.useEffect)(()=>{if(d.current&&clearTimeout(d.current),!o||!s||!n||!i){l([]);return}return d.current=setTimeout(()=>{C()},300),()=>{d.current&&clearTimeout(d.current)}},[C,o,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),r(!1)},[]);return{quotes:c,loading:g,error:a,refresh:E,clear:A}}var Y=require("@naculus/connect-core"),te=require("@naculus/connector-evm-injected"),Er=require("@naculus/connect-core"),wr=require("@naculus/connector-walletconnect"),tr=null;function Ft(e){let t=null,o=(0,wr.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,u=null,i=null,h=e.passphrasePrompt&&e.enableEmbedded&&!e.embeddedConfig?.encryptionPassphrase?new Er.PassphraseGate:null;e.enableEmbedded&&(n=import("@naculus/connector-embedded").then(r=>{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=u;return m?.hasCredential()?m.derivePrfKey(d):null}}),s=r.createPocketConnector(a),t?._setEmbeddedConnector(s)}).catch(r=>{Y.logger.warn("react/client","Embedded wallet connector not available:",r),s=null})),e.enablePasskeys&&(i=import("@naculus/connector-passkeys").then(r=>{u=r.createPasskeysConnector(),t?._setPasskeysConnector(u)}).catch(r=>{Y.logger.warn("react/client","Passkeys connector not available:",r),u=null}));let c=null,l=null;e.enableSolana&&(l=import("@naculus/connector-solana").then(r=>{let a=r.solanaConnector;e.solanaDefaultChain&&"configure"in a&&a.configure({defaultChain:e.solanaDefaultChain}),c=a,typeof window<"u"&&"startDiscovery"in a&&a.startDiscovery();for(let p of e.solanaWallets??[])a.registerWallet?.(p);t?._setSolanaConnector(c)}).catch(r=>{Y.logger.warn("react/client","Solana connector not available:",r),c=null})),typeof window<"u"&&te.eip6963Connector.startDiscovery();for(let{info:r,provider:a}of e.injectedProviders??[])te.eip6963Connector.registerProvider(r,a);let g={connector:o,get embeddedConnector(){return s},getEmbeddedConnector:async()=>(n&&await n,s),get passkeysConnector(){return u},passphraseGate:h,solanaRpcUrl:e.solanaRpcUrl??null,get solanaConnector(){return c},connect:()=>o.connect(),connectInjected:async r=>te.eip6963Connector.connect(r),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,!u)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return u.connect()},startPairing:()=>o.startPairing(),completePairing:()=>o.completePairing(),cancelPairing:()=>o.cancelPairing?.(),signMessage:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return te.eip6963Connector.signMessage(r,a);if(r.walletType==="passkeys"&&u)return u.signMessage(r,a);if(r.walletType==="embedded"){if(!s)throw new Y.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signMessage(r,a)}if(r.walletType==="solana"){if(l&&await l,c)return c.signMessage(r,a);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.signMessage(r,a)},signTransaction:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return te.eip6963Connector.signTransaction(r,a);if(r.walletType==="embedded"){if(!s)throw new Y.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signTransaction(r,a)}if(r.walletType==="solana"){if(l&&await l,c)return c.signTransaction(r,a);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.signTransaction(r,a)},sendTransaction:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return te.eip6963Connector.sendTransaction(r,a);if(r.walletType==="passkeys"&&u)return u.sendTransaction(r,a);if(r.walletType==="embedded"){if(!s)throw new Y.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.sendTransaction(r,a)}if(r.walletType==="solana"){if(l&&await l,c)return c.sendTransaction(r,a);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.sendTransaction(r,a)},onAccountsChanged:(r,a)=>{let p=()=>{};return r.id?.startsWith("eip6963-")?te.eip6963Connector.onAccountsChanged?.(r,a)??p:r.walletType==="embedded"?s?.onAccountsChanged?.(r,a)??p:r.walletType==="passkeys"?p:r.walletType==="solana"?c?.onAccountsChanged?.(r,a)??p:o.onAccountsChanged?.(r,a)??p},onChainChanged:(r,a)=>{let p=()=>{};return r.id?.startsWith("eip6963-")?te.eip6963Connector.onChainChanged?.(r,a)??p:r.walletType==="passkeys"||r.walletType==="embedded"?p:r.walletType==="solana"?c?.onChainChanged?.(r,a)??p:o.onChainChanged?.(r,a)??p},getCapabilities:r=>r.id?.startsWith("eip6963-")?te.eip6963Connector.getCapabilities?.(r):r.walletType==="passkeys"?u?.getCapabilities?.(r):r.walletType==="solana"?c?.getCapabilities?.(r):r.walletType==="embedded"?s?.getCapabilities?.(r):o.getCapabilities?.(r),sendCalls:async(r,a,p,d)=>{if(r.id?.startsWith("eip6963-"))return te.eip6963Connector.sendCalls(r,a,p,d);if(r.walletType==="passkeys"&&u)return u.sendCalls(r,a,p,d);if(r.walletType==="solana"){if(l&&await l,c)return c.sendCalls(r,a,p,d);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}if(r.walletType==="embedded"){if(!s?.sendCalls)throw new Y.WalletError("method_not_allowed","Embedded wallet does not support sendCalls");return s.sendCalls(r,a,p,d)}if(!o.sendCalls)throw new Y.WalletError("method_not_allowed","sendCalls not supported by this connector");return o.sendCalls(r,a,p,d)},showCallsStatus:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return te.eip6963Connector.showCallsStatus(r,a);if(r.walletType==="passkeys"||r.walletType==="embedded")throw new Y.WalletError("method_unsupported",`${r.walletType} wallets have no UI to display a call bundle.`);if(!o.showCallsStatus)throw new Y.WalletError("method_unsupported","This connector cannot display call status.");return o.showCallsStatus(r,a)},getCallsStatus:async(r,a)=>{if(r.id?.startsWith("eip6963-")&&te.eip6963Connector.getCallsStatus)return te.eip6963Connector.getCallsStatus(r,a);if(r.walletType==="passkeys"&&u?.getCallsStatus)return u.getCallsStatus(r,a);if(r.walletType==="embedded")throw new Y.WalletError("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!o.getCallsStatus)throw new Y.WalletError("method_not_allowed","getCallsStatus not supported by this connector");return o.getCallsStatus(r,a)},reconnect:async r=>r.walletType==="eip6963"?te.eip6963Connector.reconnect(r):r.walletType==="embedded"?s?s.reconnect(r):r:r.walletType==="solana"?r:o.reconnect(r),disconnect:async r=>{if(r.id?.startsWith("eip6963-")||r.walletType==="eip6963")return te.eip6963Connector.disconnect(r);if(r.walletType==="embedded"&&s)return s.disconnect();if(r.walletType==="passkeys"&&u)return u.disconnect(r);if(r.walletType==="solana"){if(l&&await l,c)return c.disconnect(r);throw new Y.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.disconnect(r)},getAllConnectors:()=>{let r=[o];return s&&r.push(s),u&&r.push(u),c&&r.push(c),r},_setEmbeddedConnector:r=>{s=r},_setPasskeysConnector:r=>{u=r},_setSolanaConnector:r=>{c=r}};return t=g,tr=g,g}function Kt(){return tr}function kr(){tr=null}var bt=require("@naculus/connect-core"),Ir=require("react");var ee=require("@naculus/connect-core"),At=require("@naculus/connector-evm-injected"),N=require("react");var vr=require("@naculus/connect-core"),Ht=require("@naculus/siwx");function rt(e,t){let o=t.split(":",1)[0],n=(e.namespaces[o]?.accounts??[]).filter(u=>u.startsWith(`${o}:`)).map(u=>({namespace:o,caip10:u}))[0];if(n)return{...n,address:n.caip10.split(":").pop()??n.caip10}}function Ms(e){return e.namespaces.eip155?.chains?.[0]??e.namespaces.solana?.chains?.[0]??e.namespaces.xrpl?.chains?.[0]??"eip155:1"}async function xr(e){let{session:t,siwx:o,signMessage:s}=e;if(!o||!t)return{kind:"skipped"};try{let n=Ms(t),u=rt(t,n);if(!u)throw new Error("No account found in session");let{address:i}=u,h=await o.createMessage({address:i,chainId:n}),c=(0,Ht.parseSiwxMessage)(h);if(!c?.nonce)throw new Error("SIWx message must contain a nonce");await(0,Ht.issueNonce)(c.nonce);let l=await s(t,{message:h,address:i,chainId:n});return await o.handleSignComplete?.({message:h,signature:l}),{kind:"authenticated",address:i,chainId:n}}catch(n){let u=n instanceof Error?n:new Error("Wallet authentication failed");return vr.logger.error("appkit/core","SIWx authentication failed:",n),{kind:"failed",error:u,fatal:o.required!==!1}}}var Fe=require("@naculus/connect-appkit-core");var Ar=require("@naculus/connect-appkit-core"),be=require("@naculus/connect-core"),Ls=[{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 Bs(e){let t=be.CHAINS[e];if(!t||!t.explorerUrl)return null;let o=t.caip2Id;return{caip2:o,name:t.name,rpcUrl:(0,be.getRpcUrl)(o,be.DEFAULT_RPC_URLS[o]??""),explorerUrl:t.explorerUrl,token:t.nativeCurrency.symbol}}function Fs(){if(!be.CHAINS)return[];let e=[],t=Object.keys(be.CHAINS).map(Number).sort((o,s)=>o-s);for(let o of t){let s=Bs(o);s&&e.push(s)}for(let o of Ls){let s=(0,be.eip155Reference)(o.caip2);(s===null||!be.CHAINS[s])&&e.push(o)}return e}var nr=Fs();function br(e,t){return(0,Ar.resolveChain)(e,t)??void 0}function qt(){return[...nr]}var Tr=require("react/jsx-runtime"),Vt=(0,N.createContext)(null);function Rr({children:e,config:t,autoConnect:o=!0}){let[s,n]=(0,N.useReducer)(Fe.web3Reducer,Fe.initialWeb3State),u=(0,N.useMemo)(()=>t.chains??qt(),[t.chains]),i=t.connectionTimeout??3e4,h=t.maxRetries??2,c=(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),r=(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 u){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,u,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=()=>{c.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,c]),(0,N.useEffect)(()=>{let f=()=>{c.clear(),n({type:"RESET"})};l.connector.onSessionExpiry(f)},[l,c]);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){c.clear().finally(()=>n({type:"RESET"}));return}m(f),c.save(f)})},[s.session,l,c,m]),(0,N.useEffect)(()=>{let f=s.session,S=l;if(!(!f||!S?.onChainChanged))return S.onChainChanged(f,x=>{m(f),c.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)});r.current=O,O.finally(()=>{r.current===O&&(r.current=null)})})},[s.session,l,c,m,a]);let C=(0,N.useCallback)(async f=>{if(!t.siwx||!f)return!0;n({type:"SET_STATUS",payload:"authenticating"});let S=await xr({session:f,siwx:t.siwx,signMessage:(x,P)=>l.signMessage(x,P)});return S.kind==="failed"&&S.fatal?(await c.clear(),n({type:"RESET"}),n({type:"SET_ERROR",payload:S.error}),!1):!0},[t.siwx,l,c]),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 c.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,c,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 c.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,c,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 c.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,c,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 c.clear(),n({type:"RESET"})},[l,s.session,c]),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 c.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,c,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 c.save(f),m(f),await d(f),await C(f)&&n({type:"SET_STATUS",payload:"connected"}),f},[l,c,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]),I=(0,N.useCallback)(async()=>{let f=await c.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 c.clear(),n({type:"SET_STATUS",payload:"disconnected"}),n({type:"SET_SESSION",payload:null})}},[l,c,m,h,p,b]),W=(0,N.useCallback)(async f=>{r.current&&await r.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)(()=>{o&&I()},[o,I]);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:I,switchChain:W,startPairing:k,completePairing:v,cancelPairing:T,connectInjected:R,clearError:D,isConnected:s.status==="connected",chains:u,client:l,sessionManager:a}),[s,E,A,y,w,I,W,k,v,T,R,D,u,l,a]);return(0,Tr.jsx)(Vt.Provider,{value:B,children:e})}function U(){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}=U(),o=(0,Ir.useMemo)(()=>!t||e.length===0?null:e.map(n=>{let u=(0,bt.parseCaip10)(n);return u?{address:n,namespace:u.namespace,isEVM:u.namespace==="eip155"&&(0,bt.isEvmAddress)(u.address)}:{address:n,namespace:null,isEVM:(0,bt.isEvmAddress)(n)}}),[e,t]),s=o?.find(n=>n.isEVM)?.address??null;return{accounts:o,evmAccount:s,primaryAccount:e[0]??null,isConnected:t,count:e.length}}var zt=require("@naculus/connect-core"),ue=require("react");function Ur({managers:e}){let t=(0,ue.useRef)(e);t.current=e;let o=(0,ue.useRef)(0),s=(0,ue.useRef)(!0),[n,u]=(0,ue.useState)([]),[i,h]=(0,ue.useState)(!1),[c,l]=(0,ue.useState)(null);(0,ue.useEffect)(()=>()=>{s.current=!1,o.current+=1},[]);let g=(0,ue.useCallback)(async()=>{let a=++o.current;h(!0),l(null);try{let p=await(0,zt.listAuthorizations)(t.current);s.current&&a===o.current&&u(p)}catch(p){s.current&&a===o.current&&l(p instanceof Error?p:new Error("Failed to list authorizations"))}finally{s.current&&a===o.current&&h(!1)}},[]);(0,ue.useEffect)(()=>{g()},[g]);let r=(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:c,refresh:g,revoke:r}}var ot=require("@naculus/connect-appkit-core"),X=require("react");var st=require("viem"),Pr=require("@naculus/connect-core");function Wr(e){let{evmAccount:t,isConnected:o}=K(),{chainId:s,chains:n}=U(),[u,i]=(0,X.useState)(null),[h,c]=(0,X.useState)(!1),[l,g]=(0,X.useState)(null),[r,a]=(0,X.useState)(null),p=e?.refreshInterval,d=(0,X.useRef)(null),m=(0,X.useMemo)(()=>(0,ot.resolveChain)(n,s),[s,n]),C=m?(0,ot.chainNumber)(m):null,E=(0,X.useMemo)(()=>m?(0,ot.toViemChain)(m,C):null,[m,C]),A=(0,X.useMemo)(()=>m?.token??null,[m]),[y,w]=(0,X.useState)(null);(0,X.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,X.useCallback)(async()=>{if(!t||!y){i(null);return}c(!0),g(null);try{let b=t.includes(":")?t.split(":").pop():t,[I,W]=await Promise.all([y.getBalance({address:b}),s?(0,Pr.getNativeTokenPriceUsd)(s,m?.rpcUrl).catch(()=>null):Promise.resolve(null)]);i(I.toString()),a(W)}catch(v){g(v instanceof Error?v:new Error("Failed to fetch balance")),i(null),a(null)}finally{c(!1)}},[t,y,s,m?.rpcUrl]);(0,X.useEffect)(()=>{o&&t&&R()},[o,t,R]),(0,X.useEffect)(()=>(p&&p>0&&o&&t&&(d.current=setInterval(R,p)),()=>{d.current&&(clearInterval(d.current),d.current=null)}),[p,o,t,R]);let k=(0,X.useMemo)(()=>{if(u===null)return null;try{return(0,st.formatEther)(BigInt(u))}catch{return null}},[u]),T=(0,X.useMemo)(()=>{if(r===null||k===null)return null;let v=parseFloat(k);if(Number.isNaN(v))return null;let b=v*r;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(b)},[r,k]);return{balance:u,formatted:k,symbol:A,usdPrice:r,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:o}=U(),[s,n]=(0,Pe.useState)(null),[u,i]=(0,Pe.useState)(!1),[h,c]=(0,Pe.useState)(null),l=(0,Pe.useRef)(0),g=(0,Pe.useCallback)(async()=>{let r=++l.current,a=_(e);if(!a?.getCapabilities||!t){n(null),i(!1),c(null);return}i(!0),c(null);try{let p=await a.getCapabilities(t);if(r!==l.current)return;n((0,at.normalizeCapabilities)(p))}catch(p){if(r!==l.current)return;n(null),c(p instanceof Error?p:new Error("Capability query failed"))}finally{r===l.current&&i(!1)}},[e,t]);return(0,Pe.useEffect)(()=>{g()},[g]),{capabilities:s,current:(0,at.selectChainCapabilities)(s,o),atomic:(0,at.atomicSupportFor)(s,o),isFetching:u,error:h,refetch:g}}var $t=require("react"),it=require("@naculus/connect-appkit-core");function pe(){let{chainId:e,session:t,switchChain:o,chains:s}=U(),n=(0,$t.useMemo)(()=>(0,it.resolveChain)(s,e),[s,e]),u=(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:u,availableChains:i,chains:i,isEvm:e?.startsWith("eip155:")??!1,switchChain:o}}var Rt=require("react");var Or=require("@naculus/connect-core");function Nr(){let{connect:e,status:t}=U(),[o,s]=(0,Rt.useState)(!1),[n,u]=(0,Rt.useState)(null);return{connect:(0,Rt.useCallback)(async()=>{s(!0),u(null);try{await e()}catch(h){let c=h instanceof Error?h.message:"Connection failed";u(h instanceof Or.WalletError?h:new Error(c))}finally{s(!1)}},[e]),isConnecting:o||t==="connecting",error:n}}var _r=require("@naculus/connect-appkit-core"),Ke=require("@naculus/connect-core"),ne=require("react");var Qt=require("@naculus/connect-appkit-core"),Gt=require("react"),$e=require("viem");function de(){let{evmAccount:e,isConnected:t}=K(),{currentChain:o,chains:s}=pe(),n=o?(0,Qt.chainNumber)(o):null,u=(0,Gt.useMemo)(()=>o?(0,Qt.toViemChain)(o,n):null,[o,n]),i=(0,Gt.useMemo)(()=>u?(0,$e.createPublicClient)({transport:(0,$e.http)(u.rpcUrls.default.http[0]),chain:u}):null,[u]),h=(0,Gt.useMemo)(()=>{if(!t||!e||!u)return null;let c=e.includes(":")?e.split(":").pop():e;return(0,$e.createWalletClient)({transport:(0,$e.http)(u.rpcUrls.default.http[0]),chain:u,account:c})},[t,e,u]);return{publicClient:i,walletClient:h,chains:s}}function Dr(e){let{evmAccount:t}=K(),{session:o,chainId:s,client:n}=U(),{publicClient:u}=de(),[i,h]=(0,ne.useState)(null),[c,l]=(0,ne.useState)(!1),[g,r]=(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),r(null)},[o,s,t]);let d=(0,ne.useCallback)(async(A,y)=>{let w=v=>(r(v),null);if(p.current)return w(new Error("A delegation is already in progress"));let R=(0,_r.bareEvmAddress)(t);if(!o||!R||!s)return w(new Ke.WalletError("wallet_unavailable","No connected EVM account"));if(!u||u.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=o.walletType==="embedded"?_(n)?.embeddedConnector??{}:{},T=++a.current;p.current=!0,l(!0),r(null),h(null);try{let v=await(0,Ke.delegateAccount)({connector:k,session:o,account:R,chainId:s,delegate:A,allowlist:y,getTransactionCount:(b,I)=>u.getTransactionCount({address:b,blockTag:I})});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,u,o]),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),r(null)},[]);return{delegate:m,revoke:C,result:i,isPending:c,error:g,reset:E}}var Ge=require("@naculus/connect-appkit-core"),re=require("react");function Mr(e,t={}){let[o,s]=(0,re.useState)(0),[n,u]=(0,re.useState)(null),[i,h]=(0,re.useState)(null),c=(0,re.useRef)(0),l=(0,re.useRef)(0),g=(0,re.useRef)(e);g.current=e;let r=(0,re.useRef)(t);r.current=t;let a=(0,re.useRef)(0);(0,re.useEffect)(()=>()=>{c.current+=1,l.current+=1,a.current+=1},[]);let p=(0,re.useCallback)(async(m,C)=>{let E=++c.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=r.current.verify;if(!R)u(w);else{w=(0,Ge.applySettlementVerification)(w,{status:"pending"}),u(w);let k=++a.current,T=r.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(I=>setTimeout(I,T.delayMs)),A!==l.current||k!==a.current)return;try{v=await R(y)}catch(I){v={status:"unavailable",reason:I instanceof Error?I.message:"Settlement verification failed"}}if(v.status!=="pending")break}A===l.current&&k===a.current&&u(b=>b&&(0,Ge.applySettlementVerification)(b,v))})}}return y}catch(y){let w=y instanceof Error?y:new Error("Paid request failed");throw E===c.current&&h(w),w}finally{s(y=>y-1)}},[]),d=(0,re.useCallback)(()=>{c.current+=1,l.current+=1,a.current+=1,u(null),h(null)},[]);return{payFetch:p,isPending:o>0,lastPayment:n,error:i,reset:d}}var Ee=require("@naculus/connect-appkit-core"),q=require("react");function Lr(e){return e instanceof Error?e:new Error("MPP session operation failed")}function Br(e){let[t,o]=(0,q.useState)(0),[s,n]=(0,q.useState)(()=>e.meter.pending),[u,i]=(0,q.useState)(()=>(0,Ee.readCurrentMppSessionChannel)(e)),[h,c]=(0,q.useState)(null),[l,g]=(0,q.useState)(null),[r,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,o(0),n(e.meter.pending),i((0,Ee.readCurrentMppSessionChannel)(e)),c(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,I=!1)=>{let W=++p.current,D=d.current,B=C.current;o(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),(I||!S)&&g(null)}return f}catch(f){let S=Lr(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&&o(f=>f-1)}},[]),A=(0,q.useCallback)((v,b)=>E(I=>I(v,b),I=>{let W=(0,Ee.readMppSessionReceipt)(I.receipt);W&&c(W)}),[E]),y=(0,q.useCallback)(()=>E(v=>v.close(),v=>{let b=(0,Ee.readMppSessionReceipt)(v.receipt);b&&c(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 I=Lr(b);throw a(I),g((0,Ee.readMppRecoveryChannelId)(b)),I}},[]),k=(0,q.useCallback)(()=>{p.current+=1,d.current+=1,o(0),n(C.current.meter.pending),i((0,Ee.readCurrentMppSessionChannel)(C.current)),c(null),g(null),a(null)},[]),T=(0,q.useMemo)(()=>({add:R}),[R]);return{fetch:A,meter:T,pending:s,channel:u,lastReceipt:h,recoveryChannelId:l,isPending:t>0,error:r,close:y,forceClose:w,reset:k}}var Kr=require("@naculus/connect-appkit-core"),oe=require("react");function Fr(){return Promise.reject(new Error("No Solana session key manager is connected"))}function Hr(e){let[t,o]=(0,oe.useState)([]),[s,n]=(0,oe.useState)(0),[u,i]=(0,oe.useState)(null),h=(0,oe.useRef)(0),c=e?.manager,l=e?.rpc,g=e?.owner,r=(0,oe.useMemo)(()=>c&&l&&g?(0,Kr.createSolanaSessionKeyFlow)({manager:c,rpc:l,owner:g}):null,[c,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(r&&A===h.current){let y=await r.list().catch(()=>null);y&&A===h.current&&o(y)}n(y=>y-1)}},[r]),p=(0,oe.useCallback)(async()=>{if(!r){o([]);return}let C=h.current,E=await r.list();C===h.current&&o(E)},[r]);(0,oe.useEffect)(()=>(h.current+=1,p().catch(()=>{}),()=>{h.current+=1}),[p]);let d=(0,oe.useCallback)(C=>r?a(()=>r.create(C),"Could not create the key"):Fr(),[r,a]),m=(0,oe.useCallback)(C=>r?a(()=>r.revoke(C),"Could not revoke the key"):Fr(),[r,a]);return{keys:t,create:d,revoke:m,refresh:p,isPending:s>0,error:u}}var lt=require("@naculus/connect-core"),We=require("react");function ct(){let{publicClient:e}=de(),{evmAccount:t}=K(),[o,s]=(0,We.useState)(lt.UNKNOWN_DELEGATION),[n,u]=(0,We.useState)(!1),[i,h]=(0,We.useState)(null),c=(0,We.useRef)(0),l=t?.includes(":")?t.split(":").pop():t,g=(0,We.useCallback)(async()=>{let r=++c.current;if(!e||!l){s(lt.UNKNOWN_DELEGATION),u(!1),h(null);return}u(!0),h(null);try{let a=await e.getCode({address:l});if(r!==c.current)return;s((0,lt.readDelegation)(a??"0x"))}catch(a){if(r!==c.current)return;s(lt.UNKNOWN_DELEGATION),h(a instanceof Error?a:new Error("Code read failed"))}finally{r===c.current&&u(!1)}},[e,l]);return(0,We.useEffect)(()=>{g()},[g]),{...o,isFetching:n,error:i,refetch:g}}var pt=require("@naculus/connect-appkit-core"),se=require("react"),Qr=require("viem");var Jt=require("@naculus/connect-core");var Qe=require("react");var he=require("@naculus/connect-core"),Re=require("react");var qr=require("@naculus/connect-core");function Xt(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 qr.WalletError("tx_failed","Wallet did not return a valid 32-byte transaction hash")}function Yt(){let{session:e,chainId:t,client:o}=U(),[s,n]=(0,Re.useState)("idle"),[u,i]=(0,Re.useState)(null),[h,c]=(0,Re.useState)(null),[l,g]=(0,Re.useState)(null),[r,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),c(null);try{let y=_(o);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"),c(T),T}let k="";for(let T=0;T<E.length;T++){let v=E[T];try{k=Xt(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"),c(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,o]),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&&r==="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=_(o);if(!y)throw new he.WalletError("wallet_unavailable","Client not initialized");let w=await y.getCallsStatus(e,A);return g(w),w},[e,h,o,r]),m=(0,Re.useCallback)(async E=>{if(!e)return!1;let A=E??h;if(!A||!E&&r==="sequential")return!1;let y=_(o);if(!y?.showCallsStatus)return!1;try{return await y.showCallsStatus(e,A),!0}catch{return!1}},[e,h,o,r]),C=(0,Re.useCallback)(()=>{n("idle"),i(null),c(null),g(null),a(null)},[]);return{sendCalls:p,getCallsStatus:d,showCallsStatus:m,status:s,error:u,batchHash:h,callsStatus:l,execution:r,reset:C,isSending:s==="awaiting_approval"}}function Zt(e={}){let{current:t,atomic:o}=jt(),{delegated:s,delegate:n}=ct(),{sendCalls:u}=Yt(),[i,h]=(0,Qe.useState)(!1),[c,l]=(0,Qe.useState)(null),[g,r]=(0,Qe.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,Qe.useCallback)((w,R=a)=>{let k=(0,Jt.planExecution)({atomicBatch:o==="supported",discovered:o!=="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&&o!=="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"}},[o,t,E,m,C,a,p,s,n]),y=(0,Qe.useCallback)(async(w,R=a)=>{h(!0),l(null);try{let k=A(w.length,R);if(k.route===null)throw new Jt.WalletError("method_not_allowed",k.reason);return r(k.route),k.route==="user-operation"?await m(w):await u(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,u,m,a,d,E]);return{preview:A,execute:y,isExecuting:i,error:c,lastRoute:g,reset:()=>{l(null),r(null)}}}var en=require("@naculus/connect-appkit-core"),Vr=require("@naculus/connect-core"),H=require("react");function ut(e){return(0,en.getSharedSessionKeyManager)(e)}function tn(e){let{session:t}=U(),[o,s]=(0,H.useState)([]),[n,u]=(0,H.useState)(!1),[i,h]=(0,H.useState)(null),c=(0,H.useRef)(!0),l=(0,H.useCallback)(()=>h(null),[]),g=ut(e),r=g.isStorageAvailable(),a=(0,H.useCallback)(async()=>{if(!t){s([]);return}u(!0),h(null);try{let d=await g.listSessions();c.current&&s(d)}catch(d){c.current&&h(d instanceof Error?d:new Error("Failed to load session keys"))}finally{c.current&&u(!1)}},[t,g]);(0,H.useEffect)(()=>(c.current=!0,a(),()=>{c.current=!1}),[a]);let p=o.filter(d=>d.status==="active");return{sessions:o,activeSessions:p,loading:n,error:i,refresh:a,clearError:l,storageAvailable:r}}function zr(e){let{session:t}=U(),[o,s]=(0,H.useState)(null),[n,u]=(0,H.useState)(!1),[i,h]=(0,H.useState)(null),c=(0,H.useCallback)(()=>h(null),[]),l=ut(e);return{createSessionKey:(0,H.useCallback)(async(r,a)=>{if(!t)throw new Vr.WalletError("wallet_unavailable","No active wallet session");u(!0),h(null);try{let p=a??void 0,d=await l.createSessionKey(r,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{u(!1)}},[t,l]),lastCreated:o,isCreating:n,error:i,clearError:c}}function jr(e){let[t,o]=(0,H.useState)(!1),[s,n]=(0,H.useState)(null),u=(0,H.useCallback)(()=>n(null),[]),i=ut(e);return{revokeSession:(0,H.useCallback)(async c=>{o(!0),n(null);try{await i.revokeSession(c)}catch(l){let g=l instanceof Error?l:new Error("Failed to revoke session key");throw n(g),g}finally{o(!1)}},[i]),isRevoking:t,error:s,clearError:u}}function $r(e){let[t,o]=(0,H.useState)(!1),[s,n]=(0,H.useState)(null),u=(0,H.useCallback)(()=>n(null),[]),i=ut(e),h=(0,H.useCallback)(async(l,g,r)=>{o(!0),n(null);try{return await i.signWithSessionKey(l,g,r)}catch(a){let p=a instanceof Error?a:new Error("Failed to sign with session key");throw n(p),p}finally{o(!1)}},[i]),c=(0,H.useCallback)(async(l,g)=>{o(!0),n(null);try{return await i.checkSessionScope(l,g)}catch(r){let a=r instanceof Error?r:new Error("Failed to check session scope");throw n(a),a}finally{o(!1)}},[i]);return{signWithSession:h,checkScope:c,isBusy:t,error:s,clearError:u}}function Gr(){(0,en.resetSharedSessionKeyManager)()}var Tt=require("react");var nn=require("@naculus/connect-core");function rn(){let{session:e,chainId:t,client:o}=U(),[s,n]=(0,Tt.useState)(!1),[u,i]=(0,Tt.useState)(null);return{signMessage:(0,Tt.useCallback)(async c=>{if(!e){let g=new nn.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 nn.WalletError("wallet_unavailable","No account found");throw i(g),g}n(!0),i(null);try{let g=_(o);if(!g)throw new nn.WalletError("wallet_unavailable","Client not initialized");return await g.signMessage(e,{message:c,address:l,chainId:t??void 0})}catch(g){let r=g instanceof Error?g.message:"Signing failed",a=g instanceof Error?g:new Error(r);throw i(a),a}finally{n(!1)}},[e,t,o]),isSigning:s,error:u}}var rr=require("@naculus/connect-appkit-core");function Xr(e={}){let{evmAccount:t}=K(),o=(0,pt.bareEvmAddress)(t),s=ct(),n=Zt(e.execution),{signMessage:u}=rn(),i=tn(e.managerConfig),h=ut(e.managerConfig),[c,l]=(0,se.useState)(!1),[g,r]=(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:()=>o,signMessage:u,verifySignature:async({message:S,signature:x,signerAddress:P})=>(await(0,Qr.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,o,u,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),r(P instanceof Error?P:new Error("Policy verification failed")))}).finally(()=>{S||m(!1)}),()=>{S=!0})},[i.sessions,v]);let b=(0,se.useCallback)(()=>{r(null),i.clearError()},[i]),I=(0,se.useCallback)(async(S,x)=>{l(!0),r(null);try{return await S()}catch(P){let O=P instanceof Error?P:new Error(x);throw r(O),O}finally{l(!1)}},[]),W=(0,se.useCallback)(S=>I(()=>v.createPolicy(S),"Policy creation failed"),[v,I]),D=(0,se.useCallback)(S=>I(()=>v.revokePolicy(S),"Policy revocation failed"),[v,I]),B=(0,se.useCallback)((S,x)=>I(()=>v.executePolicy(S,x),"Policy execution failed"),[v,I]),f=i.activeSessions.filter(S=>a.has(S.id));return{policies:i.sessions,activePolicies:f,storageAvailable:i.storageAvailable,loading:i.loading||d,isBusy:c,error:g??i.error,delegation:s,createPolicy:W,revokePolicy:D,previewPolicyExecution:v.previewPolicyExecution,signPolicyDigest:v.signPolicyDigest,executePolicy:B,refresh:i.refresh,clearError:b}}var Xe=require("react");function Yr(){let{disconnect:e,status:t}=U(),[o,s]=(0,Xe.useState)(!1),[n,u]=(0,Xe.useState)(null),i=(0,Xe.useRef)(!0);return{disconnect:(0,Xe.useCallback)(async()=>{if(t!=="disconnected"){s(!0),u(null);try{await e()}catch(c){if(!i.current)return;u(c instanceof Error?c:new Error("Disconnect failed"))}finally{i.current&&s(!1)}}},[e,t]),isDisconnecting:o,error:n,cleanup:()=>{i.current=!1}}}var on=require("@naculus/connect-core"),$=require("react");function qe(e){let t=e.activeNamespace??"eip155",o=Array.isArray(e.accounts)?e.accounts.map(({namespace:s,address:n,derivationPath:u})=>({namespace:s,address:n,...u?{derivationPath:u}:{}})):e.address?[{namespace:t,address:e.address}]:[];return{accounts:o,activeNamespace:t,createdAt:e.createdAt??0,...e.chainId?{chainId:e.chainId}:{},...e.version?{version:e.version}:{},recoveryAvailable:!!e.mnemonic,address:o.find(s=>s.namespace===t)?.address??e.address}}function Jr(){let{connectEmbedded:e,client:t}=U(),[o,s]=(0,$.useState)(null),n=(0,$.useRef)(null),u=(0,$.useRef)(4),i=(0,$.useRef)(!1),h=(0,$.useRef)(null),[c,l]=(0,$.useState)(!1),[g,r]=(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 on.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 on.WalletError("wallet_unavailable","Embedded wallet not enabled.");let S=f.getEmbeddedConnector?await f.getEmbeddedConnector():f.embeddedConnector;if(!S)throw new on.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()=>{r(!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{r(!1)}},T=async()=>{r(!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{r(!1)}},v=async f=>{r(!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{r(!1)}},b=async f=>{r(!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{r(!1)}},I=async()=>{r(!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{r(!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:I,wallet:o,hasWallet:o!==null,address:o?.address??null,accounts:o?.accounts??[],activeNamespace:o?.activeNamespace??null,setActiveNamespace:W,backfillAccounts:D,seedPhrase:n.current,getSeedPhrase:m,getPrivateKey:E,backupPending:c,confirmBackup:B,isBusy:g,error:a,clearError:d,storageSecurityLevel:(()=>{try{let f=C(),S=f.getStorageSecurityLevel?.()??4;return f.getWallet()?(u.current=S,S):o?u.current:S}catch{return o?u.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 to=require("@naculus/connect-appkit-core"),ke=require("react");var Zr=require("@naculus/connect-core"),we=require("react"),eo=require("@naculus/connect-appkit-core");function Ks(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:o}=e,s=t.address.toLowerCase(),n=Ks(e),u=(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 c=(0,we.useCallback)(()=>h.current&&i.current===n,[n]),l=(0,we.useCallback)(()=>{if(!c())throw new Zr.WalletError("session_inactive","Wallet or token context changed. Retry the operation with the current account and chain.");let g=(0,eo.tokenChainMismatch)({address:s,chainId:t.chainId},o);if(g)throw g},[c,s,t.chainId,o]);return{identity:u,isCurrent:c,assertCurrent:l}}var sn=require("@naculus/connect-core");function no(e){let{publicClient:t}=de(),{currentChain:o}=pe(),{identity:s,isCurrent:n,assertCurrent:u}=dt({token:e.token,chainId:o?(0,to.chainNumber)(o)??void 0:void 0,owner:e.owner,spender:e.spender,publicClient:t}),[i,h]=(0,ke.useState)(null),c=i?.identity===s?i.raw:null,l=i?.identity===s&&i.fetching,g=i?.identity===s?i.error:null,r=(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{u();let E=await t.readContract({address:e.token.address,abi:sn.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,u]);return(0,ke.useEffect)(()=>{p().catch(m=>console.warn("useERC20Allowance: initial fetch failed:",m))},[p]),(0,ke.useEffect)(()=>(e.refreshInterval&&e.refreshInterval>0&&(r.current=setInterval(p,e.refreshInterval)),()=>{r.current&&(clearInterval(r.current),r.current=null)}),[e.refreshInterval,p]),{allowance:(0,ke.useMemo)(()=>{if(c===null)return null;let m=e.token.decimals;return m===void 0?null:(0,sn.formatUnits)(c,m)},[c,e.token.decimals]),allowanceRaw:c,isFetching:l,error:g,refetch:p}}var ye=require("@naculus/connect-appkit-core"),ae=require("@naculus/connect-core"),ve=require("react");var an=require("@naculus/connect-core"),mt=require("react");function ft(){let{session:e,chainId:t,client:o}=U(),[s,n]=(0,mt.useState)("idle"),[u,i]=(0,mt.useState)(null),h=(0,mt.useCallback)(async l=>{if(!e){n("failed");let r=new an.WalletError("wallet_unavailable","No active session");throw i(r),r}let g=e.namespaces.eip155?.accounts.find(r=>/^eip155:\d+:0x[0-9a-fA-F]{40}$/.test(r)||/^0x[0-9a-fA-F]{40}$/.test(r));if(!g){n("failed");let r=new an.WalletError("wallet_unavailable","No EVM account found");throw i(r),r}n("awaiting_approval"),i(null);try{let r={...l,from:l.from??g.split(":").pop()},a=_(o);if(!a)throw new an.WalletError("wallet_unavailable","Client not initialized");let p=await a.sendTransaction(e,{transaction:r,chainId:t??void 0}),d=Xt(p);return n("submitted"),d}catch(r){n("failed");let a=r instanceof Error?r.message:"Transaction failed";throw i(r instanceof Error?r:new Error(a)),r}},[e,t,o]),c=(0,mt.useCallback)(()=>{n("idle"),i(null)},[]);return{sendTransaction:h,status:s,error:u,reset:c,isSending:s==="awaiting_approval"}}function Hs(e){return e.includes(":")?e.split(":").pop():e}var qs=2n**256n-1n;function ro(e){let{publicClient:t,walletClient:o}=de(),{evmAccount:s,isConnected:n}=K(),{currentChain:u}=pe(),{session:i,client:h}=U(),{sendTransaction:c,isSending:l,error:g,reset:r}=ft(),[a,p]=(0,ve.useState)(null),{identity:d,isCurrent:m,assertCurrent:C}=dt({token:e.token,chainId:u?(0,ye.chainNumber)(u)??void 0:void 0,owner:s,spender:e.spender,connected:n,publicClient:t,walletClient:o,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?Hs(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]),I=(()=>{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),r(),!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 c({to:e.token.address,data:x,value:"0"});return b(),z}if(o){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 o.writeContract(z);return b(),je}let O=await c({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,o,s,n,i,h,v,c,r,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(qs),[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:I,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 Vs(e){return e.includes(":")?e.split(":").pop():e}function oo(e){let{publicClient:t,walletClient:o}=de(),{evmAccount:s,isConnected:n}=K(),{currentChain:u}=pe(),{session:i,client:h}=U(),{sendTransaction:c,isSending:l,error:g,reset:r}=ft(),[a,p]=(0,gt.useState)(null),{isCurrent:d,assertCurrent:m}=dt({token:e.token,chainId:u?(0,Oe.chainNumber)(u)??void 0:void 0,owner:s,connected:n,publicClient:t,walletClient:o,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),r(),!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=Vs(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 c({to:e.token.address,data:v,value:"0"});if(o){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 o.writeContract(W)}return await c({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,o,s,n,i,h,c,r,m,d]),isSending:l,error:E}}var cn=require("@naculus/connect-appkit-core"),ao=require("@naculus/connect-core"),io=require("react");var so=require("@naculus/connect-appkit-core"),Te=require("react");function ln(e,t){U();let{evmAccount:o}=K(),{currentChain:s}=pe(),{publicClient:n}=de(),[u,i]=(0,Te.useState)(void 0),[h,c]=(0,Te.useState)(!1),[l,g]=(0,Te.useState)(null),r=(0,Te.useRef)(void 0),a=(0,Te.useCallback)(async()=>{e&&(c(!0),g(null));try{let d=await(0,so.simulateTransactionPreview)(e,{chainId:t,currentChain:s,publicClient:n,evmAccount:o});return i(d),d}catch(d){let m=d instanceof Error?d:new Error("Simulation failed");throw g(m),m}finally{e&&c(!1)}},[e,t,s,n,o]);(0,Te.useEffect)(()=>{if(e)return r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{a().catch(()=>{})},300),()=>{r.current&&clearTimeout(r.current)}},[e,a]);let p=(0,Te.useCallback)(()=>{i(void 0),g(null),c(!1)},[]);return{result:u,isSimulating:h,error:l,simulate:a,reset:p}}function lo(e){let{evmAccount:t,isConnected:o}=K(),{currentChain:s}=pe(),n=e.token.chainId??(s?(0,cn.chainNumber)(s)??void 0:void 0),u=(0,io.useMemo)(()=>{if(!(!o||!t))try{let h=e.token.decimals;if(h===void 0)return;let c=(0,ao.parseUnits)(e.amount,h),l=(0,cn.encodeErc20Transfer)(e.to,c);return{to:e.token.address,data:l,value:"0"}}catch{return}},[e.token.address,e.token.decimals,e.to,e.amount,t,o]),i=ln(u,n);return{result:u?i.result:void 0,isSimulating:!!u&&i.isSimulating,error:u?i.error:null,reSimulate:i.simulate,reset:i.reset}}var Ne=require("react");var xe=require("react"),un=require("react"),or=(0,un.createContext)(null);function It(){return(0,un.useContext)(or)}function co(e,t,o){let s=It(),n=o??s,[u,i]=(0,xe.useState)(null),[h,c]=(0,xe.useState)(!1),[l,g]=(0,xe.useState)(!1),[r,a]=(0,xe.useState)(null),p=(0,xe.useRef)(void 0),d=(0,xe.useCallback)(async()=>{if(!(!n||!e)){c(!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{c(!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),c(!0),a(null);let A=n.getTxStatus(e,t);A&&(i(A),c(!1)),n.watchTx(e,t,{}).then(w=>{E||(i(w),c(!1))}).catch(w=>{E||(a(w instanceof Error?w:new Error(String(w))),c(!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=u?.status??"idle";return{entry:u,status:C,isLoading:h,isWatching:l,error:r,refresh:d,stopWatching:m}}function uo(e){let t=It(),o=e??t,[s,n]=(0,Ne.useState)(null),[u,i]=(0,Ne.useState)(null),[h,c]=(0,Ne.useState)(null),l=(0,Ne.useRef)(null),g=(0,Ne.useRef)(null),r=(0,Ne.useRef)(null);o&&(g.current||(g.current=p=>{i(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},o.on("confirmed",g.current)),r.current||(r.current=p=>{c(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},o.on("failed",r.current)));let a=(0,Ne.useCallback)(()=>{n(null),i(null),c(null),l.current=null},[]);return{lastTx:s,lastConfirmedTx:u,lastFailedTx:h,clear:a}}var mo=require("react");var me=require("react"),po=require("@naculus/connect-appkit-core");function pn({input:e,skip:t=!1,resolverConfig:o,scope:s,query:n}){let[u,i]=(0,me.useState)(null),[h,c]=(0,me.useState)(!1),[l,g]=(0,me.useState)(null),r=(0,me.useRef)(0),a=(0,me.useRef)(!0);(0,me.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let p=(0,me.useMemo)(()=>(0,po.getResolver)(o),[o]),d=(0,me.useCallback)(()=>{let m=e.trim();if(!m||t){r.current+=1,i(null),c(!1),g(null);return}let C=++r.current;c(!0),g(null),n(p,m,s).then(E=>{!a.current||C!==r.current||(i(E),c(!1))}).catch(E=>{!a.current||C!==r.current||(g(E instanceof Error?E:new Error(String(E))),i(null),c(!1))})},[e,t,s,p,n]);return(0,me.useEffect)(()=>{d()},[d]),{data:u,isLoading:h,error:l,refetch:d}}function fo(e,t){let o=(0,mo.useCallback)((s,n,u)=>s.lookupAddress(n,u),[]);return pn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,scope:t?.chainId,query:o})}var G=require("react"),j=require("@naculus/connect-appkit-core"),go=require("@naculus/connect-core");function ho(e){let t=(0,G.useRef)(null);t.current||(t.current=e?.channel??new go.InAppChannel);let o=t.current,[s,n]=(0,G.useState)(()=>o.getHistory()),[u,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)(()=>(o.onNotification=y=>{n(w=>[...w,y])},o.restore().then(()=>{n(o.getHistory())}),()=>{o.onNotification=void 0}),[]);let c=(0,G.useMemo)(()=>s.filter(y=>!y.read).length,[s]),l=(0,G.useCallback)(()=>{o.clear(),n([])},[o]),g=(0,G.useCallback)(y=>{(0,j.clearOneInAppNotification)(o,y).then(()=>{n(o.getHistory())})},[o]),r=(0,G.useCallback)(y=>{o.markAsRead(y),n(w=>w.map(R=>R.id===y?{...R,read:!0}:R))},[o]),a=(0,G.useCallback)(()=>{o.markAllAsRead(),n(y=>y.map(w=>({...w,read:!0})))},[o]),p=(0,G.useCallback)(y=>{(0,j.addInAppNotification)(o,y)},[o]),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:c,addNotification:p,clear:l,clearOne:g,markAsRead:r,markAllAsRead:a,settings:u,updateSettings:m,setChannels:C,muteChain:E,unmuteChain:A}}var ht=require("react");var yo=()=>null,zs=()=>()=>{};function Co(){let{client:e}=U(),t=_(e)?.passphraseGate??null,o=(0,ht.useSyncExternalStore)(t?.subscribe??zs,t?.getSnapshot??yo,yo),s=(0,ht.useCallback)(i=>t?.submit(i),[t]),n=(0,ht.useCallback)(()=>t?.cancel(),[t]),u=(0,ht.useCallback)(i=>t?.forget(i),[t]);return{request:o,submit:s,cancel:n,forget:u,isUnlocked:t?.isUnlocked??!1,gate:t}}var So=require("react");function Eo(e,t){let o=(0,So.useCallback)((s,n)=>s.resolveName(n),[]);return pn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,query:o})}var _e=require("@naculus/connect-appkit-core"),Ye=require("@naculus/connect-core"),ie=require("react");async function js(e,t,o,s,n){let u=_(t);if(!u)throw new Ye.WalletError("wallet_unavailable","Client not initialized");let i=[o,s];if(e.walletType==="eip6963"||e.id?.startsWith("eip6963-")){let{eip6963Connector:h}=await import("@naculus/connector-evm-injected"),c=h.getDiscoveredWallets().find(g=>g.id===e.walletId),l=c?await c.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 u.connector.request({method:"personal_sign",params:i}));if(e.walletType==="embedded"){let h=u.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,o))}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 wo(e){let{evmAccount:t}=K(),{session:o,chainId:s,client:n}=U(),[u,i]=(0,ie.useState)(null),[h,c]=(0,ie.useState)(null),[l,g]=(0,ie.useState)(!1),[r,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),c(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,o]);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&&!o)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),c(null);try{let{SmartAccountManager:b}=await import("@naculus/connect-core"),I=e.signer??(f=>js(o,n,f,k,T)),W=new b({rpcUrl:e.rpcUrl,bundlerClient:{url:e.bundlerUrl},chainId:T,signer:I,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&&c(f)}).catch(()=>{}),B)}catch(b){if(v!==m.current)return null;let I=b instanceof Error?b:new Error("Failed to send UserOperation");return d(I),null}finally{C.current=!1,v===m.current&&(g(!1),a(!1))}},[n,s,t,e,o]),A=(0,ie.useCallback)(()=>{m.current+=1,i(null),c(null),g(!1),a(!1),d(null)},[]);return{sendUserOp:E,userOpHash:u,receipt:h,isPending:l,isEstimating:r,error:p,reset:A}}var Ut=require("react");function $s(e,t){if(!e)return()=>{};let o=()=>t();return e.on("sessionConnected",o),e.on("sessionDisconnected",o),e.on("chainChanged",o),e.on("sessionScopeChanged",o),e.on("sessionRevoked",o),()=>{e.off("sessionConnected",o),e.off("sessionDisconnected",o),e.off("chainChanged",o),e.off("sessionScopeChanged",o),e.off("sessionRevoked",o)}}var sr=Object.freeze({session:null,chainSessions:[],activeChainId:null,isConnected:!1,connectorId:null}),ar=new WeakMap;function Gs(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}function Qs(e){if(!e)return sr;let t=e.getActiveBundle(),o=ar.get(e);if(!t)return o&&o.session===null?o:(ar.set(e,sr),sr);let s=Array.from(t.chainSessions.values());if(o&&o.session===t.walletSession&&o.activeChainId===t.activeChainId&&Gs(o.chainSessions,s))return o;let n={session:t.walletSession,chainSessions:s,activeChainId:t.activeChainId,isConnected:!0,connectorId:t.walletSession.walletType};return ar.set(e,n),n}function ko(e){let t=U(),o=e??t.sessionManager??null,s=(0,Ut.useCallback)(u=>$s(o,u),[o]),n=(0,Ut.useCallback)(()=>Qs(o),[o]);return(0,Ut.useSyncExternalStore)(s,n)}var dn=require("@naculus/connect-appkit-core"),Pt=require("@naculus/connect-core"),De=require("@naculus/siwx"),yt=require("react");var Xs=86400;function mn(){let{session:e,chainId:t,client:o}=U(),[s,n]=(0,yt.useState)(!1),[u,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 r=rt(e,g);if(!r)throw new Pt.WalletError("wallet_unavailable","No account found");let a=_(o);if(!a)throw new Pt.WalletError("wallet_unavailable","Client not initialized");let{address:p}=r,d=typeof window>"u"?void 0:window.location,m=l?.domain??(0,dn.defaultSiwxDomain)(d),C=l?.uri??(0,dn.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??Xs,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,o]),isSigningIn:s,error:u,clearError:h}}var ir=require("@naculus/connect-appkit-core"),fn=require("@naculus/connect-core"),Wt=require("@naculus/siwx"),le=require("react");function vo(e){let{storagePrefix:t="naculus_",autoRestore:o=!0,defaultExpirySeconds:s=86400}=e??{},[n,u]=(0,le.useState)(null),[i,h]=(0,le.useState)(o),[c,l]=(0,le.useState)(!1),[g,r]=(0,le.useState)(null),{chainId:a}=U(),p=mn(),d=(0,le.useRef)((0,Wt.createLocalStorageSiwxSessionStorage)(`${t}siwx_session`)),m=(0,le.useCallback)(()=>r(null),[]);(0,le.useEffect)(()=>{if(!o){h(!1);return}let k=!1;return(async()=>{try{let v=await d.current.get();if(k)return;v?(fn.logger.info("react/useSIWxSession","Restored persisted SIWx session"),u(v),r(null)):u(null)}catch(T){fn.logger.warn("react/useSIWxSession","Failed to restore SIWx session:",T),u(null)}finally{k||h(!1)}})(),()=>{k=!0}},[o]),(0,le.useEffect)(()=>{if(!n?.expiresAt)return;let k=new Date(n.expiresAt).getTime()-Date.now();if(k<=0){u(null);return}let T=setTimeout(()=>{u(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),r(null);try{let T={expirySeconds:s,chainId:a??void 0,...k},v=await p.signIn(T),b=(0,ir.siwxResultToSession)(v);return await d.current.set(b),u(b),l(!1),b}catch(T){let v=T instanceof Error?T:new Error("SIWx sign-in failed");throw r(v),l(!1),v}},[p,a,s]),E=(0,le.useCallback)(async()=>{try{await d.current.remove()}catch(k){fn.logger.warn("react/useSIWxSession","Failed to clear session:",k)}u(null),r(null)},[]),A=(0,le.useCallback)(async()=>{if(!n)throw new Error("No active session to refresh");l(!0),r(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,ir.siwxResultToSession)(k),id:n.id,refreshedAt:new Date().toISOString()};return await d.current.set(T),u(T),l(!1),T}catch(k){let T=k instanceof Error?k:new Error("Session refresh failed");throw r(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:c,isExpired:w,timeUntilExpiry:R,signIn:C,signOut:E,refresh:A,error:g,clearError:m}}var gn=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:o}=U(),[s,n]=(0,Je.useState)(!1),[u,i]=(0,Je.useState)(null),[h,c]=(0,Je.useState)(null),l=(0,Je.useCallback)(()=>c(null),[]);return{signIn:(0,Je.useCallback)(async r=>{if(!e)throw new Ot.WalletError("wallet_unavailable","No active session");let a=r?.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=_(o);if(!d)throw new Ot.WalletError("wallet_unavailable","Client not initialized");let{address:m}=p,C=typeof window>"u"?void 0:window.location,E=r?.domain??(0,gn.defaultSiwxDomain)(C),A=r?.uri??(0,gn.defaultSiwxUri)(C);n(!0),c(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:r?.statement,expirationTime:r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():void 0,resources:r?.resources,requestId:r?.requestId}),k=await d.signMessage(e,{message:R,address:m,chainId:a??void 0}),T=r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():null,v={message:{raw:R,domain:E,address:m,statement:r?.statement??null,uri:A,version:1,chainId:a,nonce:y,issuedAt:w,blockchain:(0,Me.getBlockchainName)(a),expirationTime:T,notBefore:null,resources:r?.resources??[],requestId:r?.requestId??null},signature:k};return i(v),v}catch(y){let w=y instanceof Error?y:new Error("SIWx sign-in failed");throw c(w),w}finally{n(!1)}},[e,t,o]),isSigningIn:s,result:u,error:h,clearError:l}}var hn=require("@naculus/connect-core");var lr=require("react");function Ys(){let{session:e,chainId:t}=U();return(0,lr.useCallback)(o=>{if(!e)throw new hn.WalletError("wallet_unavailable","No active session");let s=o??t;if(s&&!s.startsWith("eip155:"))throw new hn.WalletError("namespace_mismatch",`Ethereum SIWx requires an eip155 chain, received ${s}`);let n=e.namespaces.eip155;if(!n||n.accounts.length===0)throw new hn.WalletError("namespace_mismatch","No EVM (eip155) accounts found in session")},[e,t])}function xo(){let e=Ys(),t=Ct();return{signIn:(0,lr.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 Ao=require("@naculus/connect-appkit-core"),bo=require("@naculus/wallet-engine"),Le=require("react");function Ro(e){let t=e?.rpcUrl,o=e?.chainId,s=(0,Le.useRef)(null),n=(0,Le.useCallback)(()=>(s.current||(s.current=new bo.SimulationManager({enabled:!0,rpcUrl:t,autoSimulate:!1})),s.current),[t]),[u,i]=(0,Le.useState)(null),[h,c]=(0,Le.useState)(!1),[l,g]=(0,Le.useState)(null),r=(0,Le.useCallback)(async(p,d,m,C,E)=>{c(!0),g(null);try{let A=n(),y=(0,Ao.resolveSimulationEndpoint)(E?.chainId,o,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{c(!1)}},[t,o,n]),a=(0,Le.useCallback)(()=>{i(null),g(null),c(!1)},[]);return{result:u,loading:h,error:l,simulate:r,reset:a}}var Cn=require("@naculus/connect-appkit-core"),Ze=require("@naculus/connect-core"),Ce=require("react");var yn="siwx_auth";function Js(e){return new Ze.LocalStorageAdapter(e)}function To(e){let{storagePrefix:t="naculus_",autoRestore:o=!0}=e??{},[s,n]=(0,Ce.useState)(null),[u,i]=(0,Ce.useState)(o),[h,c]=(0,Ce.useState)(!1),[l,g]=(0,Ce.useState)(null),r=Ct(),a=(0,Ce.useRef)(Js(t)),p=(0,Ce.useCallback)(()=>g(null),[]);(0,Ce.useEffect)(()=>{if(!o){i(!1);return}let C=!1;return(async()=>{try{let E=a.current,A=await E.get(yn);if(C)return;A&&!(0,Cn.isSiwxExpired)(A,new Date)&&(0,Cn.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(yn))}catch(E){Ze.logger.warn("react/useSiwxAuthSession","Failed to restore SIWx auth:",E)}finally{C||i(!1)}})(),()=>{C=!0}},[o]);let d=(0,Ce.useCallback)(async C=>{c(!0),g(null);try{let E=await r.signIn(C);return await a.current.set(yn,E),n(E),c(!1),E}catch(E){let A=E instanceof Error?E:new Error("SIWx sign-in failed");throw g(A),c(!1),A}},[r]),m=(0,Ce.useCallback)(async()=>{try{await a.current.remove(yn)}catch(C){Ze.logger.warn("react/useSiwxAuthSession","Failed to clear SIWx auth:",C)}n(null),g(null)},[]);return{isSignedIn:s!==null,isRestoring:u,siwxResult:s,isSigningIn:h,error:l,signIn:d,signOut:m,clearError:p}}var et=require("@naculus/connect-appkit-core"),cr=require("@naculus/connect-core"),Q=require("react");function Io(e){return new cr.WalletError("wallet_unavailable",e)}function Uo(e){let{evmAccount:t}=K(),{session:o,chainId:s,client:n}=U(),[u,i]=(0,Q.useState)(null),[h,c]=(0,Q.useState)(!1),[l,g]=(0,Q.useState)(null),[r,a]=(0,Q.useState)(!1),[p,d]=(0,Q.useState)(null),m=(0,Q.useRef)(null),C=(0,Q.useRef)(0),E=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(m.current=null,!e?.rpcUrl)return;let b=!1;return import("@naculus/connect-core").then(({SmartAccountManager:I})=>{if(b)return;let W=(0,et.resolveEvmChainId)(e.chainId,s);W&&(m.current=new I({rpcUrl:e.rpcUrl,chainId:W,bundlerClient:{url:e.bundlerUrl??""}}))}).catch(I=>{b||d(I instanceof Error?I:new Error("Failed to load account-abstraction module"))}),()=>{b=!0}},[s,e?.rpcUrl,e?.bundlerUrl,e?.chainId]),(0,Q.useEffect)(()=>{C.current+=1,E.current=!1,i(null),c(!1),g(null),a(!1),d(null)},[t,s,e?.rpcUrl,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.accountType,e?.salt]);let A=(0,Q.useCallback)(()=>{let b=(0,et.bareEvmAddress)(t);if(!b||!m.current)return null;let I=(0,et.resolveEvmChainId)(e?.chainId,s);return I?(0,et.buildSmartAccountConfig)(b,I,{accountType:e?.accountType,entryPoint:e?.entryPoint,salt:e?.salt}):null},[t,s,e?.accountType,e?.chainId,e?.entryPoint,e?.salt]),y=(0,Q.useCallback)(b=>(d(b),null),[]),w=(0,Q.useCallback)(()=>E.current?null:(E.current=!0,C.current),[]),R=(0,Q.useCallback)(b=>{C.current===b&&(E.current=!1)},[]),k=(0,Q.useCallback)(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));let I=w();if(I===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!==I?null:(i(D.address),c(D.isDeployed),g(D),D)}catch(W){if(C.current!==I)return null;let D=W instanceof Error?W:new Error("Failed to create smart account");return d(D),null}finally{C.current===I&&a(!1),R(I)}},[w,y,R,A]),T=(0,Q.useCallback)(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));if(!o)return y(Io("No active session"));let I=_(n);if(!I)return y(Io("Client not initialized"));if(s&&s!==b.chainId)return y(new cr.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),c(!0),g(B),B.address;let f=await D.getDeployCallData(b),S=await I.sendTransaction(o,{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),c(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,o]),v=(0,Q.useCallback)(async()=>{let b=A();if(!b||!m.current)return null;let I=C.current;try{let W=await m.current.getAccountAddress(b);return C.current!==I?null:(i(W),W)}catch(W){return C.current!==I||d(W instanceof Error?W:new Error("Failed to get smart account address")),null}},[A]);return{address:u,isDeployed:h,accountInfo:l,isLoading:r,error:p,createWallet:k,deployWallet:T,getAddress:v}}var Po=require("react");function Sn(){let{accounts:e,isConnected:t}=U();return(0,Po.useMemo)(()=>{if(!t)return{address:null,caip10:null,chainId:null,isConnected:!1};let o=e.find(i=>i.startsWith("solana:"))??null;if(!o)return{address:null,caip10:null,chainId:null,isConnected:t};let s=o.split(":"),n=s.length>=3?s[s.length-1]:null,u=s.length>=3?s.slice(0,-1).join(":"):null;return{address:n,caip10:o,chainId:u,isConnected:t}},[e,t])}var Ie=require("react"),Wo=require("@naculus/connect-core");function Oo(e={}){let{client:t}=U(),{address:o}=Sn(),s=e.address??o,n=e.rpcUrl??_(t)?.solanaRpcUrl??null,[u,i]=(0,Ie.useState)(null),[h,c]=(0,Ie.useState)(!1),[l,g]=(0,Ie.useState)(null),r=(0,Ie.useRef)(0),a=(0,Ie.useCallback)(async()=>{if(!s||!n){i(null);return}let p=++r.current;c(!0),g(null);try{let d=await(0,Wo.getSolanaBalance)(n,s);if(p!==r.current)return;i(d)}catch(d){if(p!==r.current)return;i(null),g(d instanceof Error?d:new Error("Balance read failed"))}finally{p===r.current&&c(!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:u,isFetching:h,error:l,isConfigured:!!n,refetch:a}}var No=require("@naculus/connect-appkit-core"),_o=require("react");function Do(){let{client:e,session:t,accounts:o}=U();return(0,_o.useMemo)(()=>{let s=_(e)?.solanaConnector,{roles:n,absence:u}=(0,No.readSolanaRoles)(s,t);return{roles:n,absence:u,identity:n?.identity??null,signer:n?.signer??null,payer:n?.payer??null}},[e,t,o])}var ur=require("@naculus/connect-core"),ze=require("react"),Mo=require("@naculus/connect-core");function Lo(){let{client:e,session:t}=U(),[o,s]=(0,ze.useState)(!1),[n,u]=(0,ze.useState)(!1),[i,h]=(0,ze.useState)(null),c=()=>{let a=_(e);if(!a||!t)throw new ur.WalletError("wallet_unavailable","No connected wallet.");return a},l=(0,ze.useCallback)(async a=>{s(!0),h(null);try{return await c().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=>{u(!0),h(null);try{return await c().sendTransaction(t,{transaction:a})}catch(p){let d=p instanceof Error?p:new Error("Send failed");throw h(d),d}finally{u(!1)}},[e,t]),r=(0,ze.useCallback)(async a=>{let p=_(e)?.solanaRpcUrl;if(!p)throw new ur.WalletError("no_rpc","Set solanaRpcUrl on the client to read a signature's status.");return(0,Mo.getSignatureStatus)(p,a)},[e]);return{signTransaction:l,sendTransaction:g,getStatus:r,isSigning:o,isSending:n,error:i,reset:()=>h(null)}}var St=require("react"),Bo=require("@naculus/connect-appkit-core");function Fo(){let{switchChain:e,chainId:t}=U(),[o,s]=(0,St.useState)(!1),[n,u]=(0,St.useState)(null),i=(0,St.useCallback)(async c=>{s(!0),u(null);try{await e(c)}catch(l){let g=(0,Bo.toChainSwitchError)(l);throw u(g),g}finally{s(!1)}},[e]),h=(0,St.useCallback)(()=>{u(null)},[]);return{switchChain:i,isSwitching:o,currentChainId:t,error:n,clearError:h}}var Et=require("@naculus/connect-appkit-core"),J=require("react");var wt=require("viem"),Zs=[{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"balance",type:"uint256"}]}];function Ko(e){let{evmAccount:t,isConnected:o}=K(),{chainId:s,chains:n}=U(),[u,i]=(0,J.useState)([]),[h,c]=(0,J.useState)(!1),[l,g]=(0,J.useState)(null),{tokens:r,refreshInterval:a}=e,p=(0,J.useRef)(null),d=(0,J.useMemo)(()=>r.map(k=>k.address.toLowerCase()+"|"+k.decimals+"|"+k.symbol).join(","),[r]),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||r.length===0){i([]);return}c(!0),g(null);try{let k=t.includes(":")?t.split(":").pop():t,v=(await Promise.allSettled(r.map(async b=>{try{let I=await A.readContract({address:b.address,abi:Zs,functionName:"balanceOf",args:[k]});return{address:b.address,symbol:b.symbol,decimals:b.decimals,name:b.name,balance:I.toString(),formatted:(0,wt.formatUnits)(I,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{c(!1)}},[t,A,d]);(0,J.useEffect)(()=>{o&&t&&r.length>0&&w()},[o,t,d,w]),(0,J.useEffect)(()=>(a&&a>0&&o&&t&&r.length>0&&(p.current=setInterval(w,a)),()=>{p.current&&(clearInterval(p.current),p.current=null)}),[a,o,t,d,w]);let R=(0,J.useCallback)(k=>u.find(T=>T.address.toLowerCase()===k.toLowerCase()),[u]);return{tokenBalances:u,isLoading:h,error:l,refetch:w,getTokenBalance:R,chain:m}}var Ue=require("react");function Ho(e,t,o){let s=It(),n=o??s,[u,i]=(0,Ue.useState)([]),[h,c]=(0,Ue.useState)(!1),[l,g]=(0,Ue.useState)(null),r=(0,Ue.useRef)(0),a=(0,Ue.useCallback)(async()=>{if(n){c(!0),g(null),r.current++;try{let d=await n.getTxHistory(e,t);i(d)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{c(!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:u.filter(d=>d.status==="pending").length,confirmed:u.filter(d=>d.status==="confirmed").length,failed:u.filter(d=>d.status==="failed").length};return{entries:u,isLoading:h,error:l,refresh:a,summary:p}}var En=require("@naculus/connect-appkit-core"),V=require("react");function qo(e){let t=e?.bundlerUrl,o=e?.pollInterval??2e3,s=e?.maxRetries??30,[n,u]=(0,V.useState)("idle"),[i,h]=(0,V.useState)(null),[c,l]=(0,V.useState)(e?.userOpHash??null),[g,r]=(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&&(u("not_found"),p(!1),v(),r(fe))},je=fe=>{if(x===R.current){if(P<=s){w.current=setTimeout(()=>{b(S,x)},o);return}z(fe)}};try{let fe=await(0,En.fetchUserOperationReceipt)(t,S,O.signal);if(x!==R.current)return;if(fe){h(fe),u(fe.success?"confirmed":"failed"),p(!1),v();return}u("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 En.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,o,s,v]),I=(0,V.useCallback)(S=>{R.current+=1;let x=R.current;if(T.current?.abort(),T.current=null,v(),l(S),h(null),r(null),k.current=0,m(0),A(0),C.current=Date.now(),!t){u("not_found"),p(!1),r(new Error("Bundler URL not configured"));return}u("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),u("idle"),h(null),r(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&&I(B)},[B,f,I]),(0,V.useEffect)(()=>()=>{R.current+=1,T.current?.abort(),T.current=null,v()},[v]),{status:n,receipt:i,userOpHash:c,error:g,isPolling:a,elapsedMs:E,attempts:d,start:I,stop:W,reset:D}}var $o=require("@naculus/connect-appkit-core"),Go=require("react");var ea={"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."},ta={"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"},Vo={en:ea,zh:ta},pr="en";function zo(e){pr=e}function jo(){return pr}function wn(e){return Vo[pr][e]??Vo.en[e]??e}function dr(e){let{isValid:t,level:o,issue:s}=(0,$o.validateDestination)(e);return{isValid:t,level:o,warning:s?wn(`address.${s}`):null}}function Qo({address:e}){return{validation:(0,Go.useMemo)(()=>dr(e),[e])}}function Xo(){let{status:e,session:t,accounts:o,chainId:s,error:n,connect:u,disconnect:i,reconnect:h,switchChain:c}=U(),l=e==="connected",g=e==="connecting",r=e==="reconnecting",a=o[0]??null;return{status:e,session:t,accounts:o,chainId:s,error:n,isConnected:l,isConnecting:g,isReconnecting:r,isDisconnected:e==="disconnected",currentAccount:a,connect:u,disconnect:i,reconnect:h,switchChain:c}}var tt=require("react");var mr={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"},fr={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 o=t.code,s=mr[o]??Nt,n=fr[o]??t.message??_t;return{title:s,description:n,code:o}}if(e instanceof Error){let o=e.message;return/user rejected/i.test(o)||/rejected/.test(o)?{title:"Request Rejected",description:"The request was declined.",code:"user_rejected"}:/timeout/i.test(o)||/timed? ?out/i.test(o)?{title:"Request Timed Out",description:"The request took too long. Please try again.",code:"deeplink_timeout"}:/insufficient funds/i.test(o)?{title:"Insufficient Funds",description:"You don't have enough funds to complete this transaction.",code:"tx_failed"}:/network/i.test(o)||/chain/i.test(o)?{title:"Network Error",description:o,code:"chain_unsupported"}:{title:Nt,description:o||_t}}return typeof e=="string"?{title:Nt,description:e||_t}:{title:Nt,description:_t}}function kn(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 Yo(){let{error:e,clearError:t}=U(),o=(0,tt.useMemo)(()=>e?kt(e):null,[e]),s=(0,tt.useMemo)(()=>e?kn(e):!1,[e]),n=(0,tt.useCallback)(()=>{t()},[t]),u=(0,tt.useCallback)(h=>kt(h),[]),i=(0,tt.useCallback)(h=>async()=>{try{return await h()}catch(c){let l=kt(c);if(c instanceof Error){let g=c;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:c}),{title:l.title,code:l.code,friendlyMessage:l.description})}},[]);return{error:e,friendlyError:o,clearError:n,isRetryable:s,formatError:u,wrapAsync:i}}var Ae=require("react"),Jo=require("@naculus/connect-core"),gr=require("@naculus/connect-appkit-core");function Dt(e,t){let o=(0,Ae.useRef)(null),[s,n]=(0,Ae.useState)([]),[u,i]=(0,Ae.useState)(t?.autoLoad!==!1),[h,c]=(0,Ae.useState)(!1),[l,g]=(0,Ae.useState)(null);if(!o.current){let p={};t?.sources&&(p.sources=t.sources),o.current=new Jo.TokenListManager(p)}let r=(0,Ae.useCallback)(async()=>{let p=o.current;if(p){i(!0),g(null);try{await p.load();let d=e?(0,gr.eip155ChainIdToNumber)(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),c(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]),a=(0,Ae.useCallback)(async()=>{let p=o.current;if(p){i(!0),g(null);try{await p.refresh();let d=e?(0,gr.eip155ChainIdToNumber)(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),c(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]);return(0,Ae.useEffect)(()=>{t?.autoLoad!==!1&&r()},[r,t?.autoLoad]),{tokens:s,isLoading:u,isLoaded:h,error:l,refetch:a}}var nt=require("react"),es=require("@naculus/connect-core");var Be=require("@naculus/connect-core");function Zo(){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 ts=require("@naculus/connect-appkit-core"),na=300,vn=null;function ra(){return vn||(vn=new es.TokenListManager({sources:Zo()}),vn.load().catch(()=>{})),vn}function Mt(e,t){let[o,s]=(0,nt.useState)({exact:[],fuzzy:[],hasMore:!1}),[n,u]=(0,nt.useState)(!1),i=(0,nt.useRef)(null),h=e.trim();return(0,nt.useEffect)(()=>{if(!h){s({exact:[],fuzzy:[],hasMore:!1}),u(!1);return}return i.current&&clearTimeout(i.current),u(!0),i.current=setTimeout(()=>{let c=ra(),l=t?(0,ts.eip155ChainIdToNumber)(t):void 0,g=c.search(h,{chainId:l,limit:20});s(g),u(!1)},na),()=>{i.current&&clearTimeout(i.current)}},[h,t]),{results:o,isSearching:n}}var vt=He(require("react"),1);var F=require("react/jsx-runtime");function hr({chainId:e,onSelect:t,onClose:o,options:s}){let[n,u]=vt.default.useState(""),{tokens:i,isLoading:h,error:c}=Dt(e),{results:l,isSearching:g}=Mt(n,n?e:void 0),r=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(()=>!r||n.trim()?[]:i.slice(0,6),[i,r,n]),d=(0,vt.useCallback)(m=>{t(m),o()},[t,o]);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:o,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=>u(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..."}),c&&(0,F.jsxs)("div",{style:{textAlign:"center",padding:"12px",color:"hsl(var(--destructive))",fontSize:"13px"},children:["Error: ",c.message]}),r&&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),xn=require("@naculus/connect-appkit-wc/dist/components/appkit-accordion.js"),An=require("@naculus/connect-appkit-wc/dist/components/appkit-account-button.js"),bn=require("@naculus/connect-appkit-wc/dist/components/appkit-alert-dialog.js"),Rn=require("@naculus/connect-appkit-wc/dist/components/appkit-avatar.js"),Tn=require("@naculus/connect-appkit-wc/dist/components/appkit-badge.js"),In=require("@naculus/connect-appkit-wc/dist/components/appkit-button.js"),Un=require("@naculus/connect-appkit-wc/dist/components/appkit-card-content.js"),Pn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-description.js"),Wn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-footer.js"),On=require("@naculus/connect-appkit-wc/dist/components/appkit-card-header.js"),Nn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-title.js"),_n=require("@naculus/connect-appkit-wc/dist/components/appkit-card.js"),Dn=require("@naculus/connect-appkit-wc/dist/components/appkit-checkbox.js"),Mn=require("@naculus/connect-appkit-wc/dist/components/appkit-collapsible.js"),Ln=require("@naculus/connect-appkit-wc/dist/components/appkit-connect-button.js"),Bn=require("@naculus/connect-appkit-wc/dist/components/appkit-dialog.js"),Fn=require("@naculus/connect-appkit-wc/dist/components/appkit-dropdown-menu.js"),Kn=require("@naculus/connect-appkit-wc/dist/components/appkit-input.js"),Hn=require("@naculus/connect-appkit-wc/dist/components/appkit-popover.js"),qn=require("@naculus/connect-appkit-wc/dist/components/appkit-progress.js"),Vn=require("@naculus/connect-appkit-wc/dist/components/appkit-scroll-area.js"),zn=require("@naculus/connect-appkit-wc/dist/components/appkit-select.js"),jn=require("@naculus/connect-appkit-wc/dist/components/appkit-separator.js"),$n=require("@naculus/connect-appkit-wc/dist/components/appkit-skeleton.js"),Gn=require("@naculus/connect-appkit-wc/dist/components/appkit-switch.js"),Qn=require("@naculus/connect-appkit-wc/dist/components/appkit-tabs.js"),Xn=require("@naculus/connect-appkit-wc/dist/components/appkit-toggle-group.js"),Yn=require("@naculus/connect-appkit-wc/dist/components/appkit-tooltip.js"),ns=(0,M.createComponent)({tagName:"appkit-accordion",elementClass:xn.AppkitAccordion,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:xn.defineCustomElement}),rs=(0,M.createComponent)({tagName:"appkit-account-button",elementClass:An.AppkitAccountButton,react:L.default,events:{},defineCustomElement:An.defineCustomElement}),os=(0,M.createComponent)({tagName:"appkit-alert-dialog",elementClass:bn.AppkitAlertDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:bn.defineCustomElement}),ss=(0,M.createComponent)({tagName:"appkit-avatar",elementClass:Rn.AppkitAvatar,react:L.default,events:{},defineCustomElement:Rn.defineCustomElement}),as=(0,M.createComponent)({tagName:"appkit-badge",elementClass:Tn.AppkitBadge,react:L.default,events:{},defineCustomElement:Tn.defineCustomElement}),is=(0,M.createComponent)({tagName:"appkit-button",elementClass:In.AppkitButton,react:L.default,events:{},defineCustomElement:In.defineCustomElement}),ls=(0,M.createComponent)({tagName:"appkit-card",elementClass:_n.AppkitCard,react:L.default,events:{},defineCustomElement:_n.defineCustomElement}),cs=(0,M.createComponent)({tagName:"appkit-card-content",elementClass:Un.AppkitCardContent,react:L.default,events:{},defineCustomElement:Un.defineCustomElement}),us=(0,M.createComponent)({tagName:"appkit-card-description",elementClass:Pn.AppkitCardDescription,react:L.default,events:{},defineCustomElement:Pn.defineCustomElement}),ps=(0,M.createComponent)({tagName:"appkit-card-footer",elementClass:Wn.AppkitCardFooter,react:L.default,events:{},defineCustomElement:Wn.defineCustomElement}),ds=(0,M.createComponent)({tagName:"appkit-card-header",elementClass:On.AppkitCardHeader,react:L.default,events:{},defineCustomElement:On.defineCustomElement}),ms=(0,M.createComponent)({tagName:"appkit-card-title",elementClass:Nn.AppkitCardTitle,react:L.default,events:{},defineCustomElement:Nn.defineCustomElement}),fs=(0,M.createComponent)({tagName:"appkit-checkbox",elementClass:Dn.AppkitCheckbox,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Dn.defineCustomElement}),gs=(0,M.createComponent)({tagName:"appkit-collapsible",elementClass:Mn.AppkitCollapsible,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:Mn.defineCustomElement}),hs=(0,M.createComponent)({tagName:"appkit-connect-button",elementClass:Ln.AppkitConnectButton,react:L.default,events:{onAppkitConnect:"appkitConnect",onAppkitDisconnect:"appkitDisconnect",onAppkitStartPairing:"appkitStartPairing",onAppkitRetry:"appkitRetry",onAppkitCancelPairing:"appkitCancelPairing",onAppkitMobileDeepLink:"appkitMobileDeepLink",onAppkitCopyAddress:"appkitCopyAddress"},defineCustomElement:Ln.defineCustomElement}),ys=(0,M.createComponent)({tagName:"appkit-dialog",elementClass:Bn.AppkitDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Bn.defineCustomElement}),Cs=(0,M.createComponent)({tagName:"appkit-dropdown-menu",elementClass:Fn.AppkitDropdownMenu,react:L.default,events:{onAppkitSelect:"appkitSelect"},defineCustomElement:Fn.defineCustomElement}),Ss=(0,M.createComponent)({tagName:"appkit-input",elementClass:Kn.AppkitInput,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Kn.defineCustomElement}),Es=(0,M.createComponent)({tagName:"appkit-popover",elementClass:Hn.AppkitPopover,react:L.default,events:{onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Hn.defineCustomElement}),ws=(0,M.createComponent)({tagName:"appkit-progress",elementClass:qn.AppkitProgress,react:L.default,events:{},defineCustomElement:qn.defineCustomElement}),ks=(0,M.createComponent)({tagName:"appkit-scroll-area",elementClass:Vn.AppkitScrollArea,react:L.default,events:{},defineCustomElement:Vn.defineCustomElement}),vs=(0,M.createComponent)({tagName:"appkit-select",elementClass:zn.AppkitSelect,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:zn.defineCustomElement}),xs=(0,M.createComponent)({tagName:"appkit-separator",elementClass:jn.AppkitSeparator,react:L.default,events:{},defineCustomElement:jn.defineCustomElement}),As=(0,M.createComponent)({tagName:"appkit-skeleton",elementClass:$n.AppkitSkeleton,react:L.default,events:{},defineCustomElement:$n.defineCustomElement}),bs=(0,M.createComponent)({tagName:"appkit-switch",elementClass:Gn.AppkitSwitch,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Gn.defineCustomElement}),Rs=(0,M.createComponent)({tagName:"appkit-tabs",elementClass:Qn.AppkitTabs,react:L.default,events:{onAppkitTabChange:"appkitTabChange"},defineCustomElement:Qn.defineCustomElement}),Ts=(0,M.createComponent)({tagName:"appkit-toggle-group",elementClass:Xn.AppkitToggleGroup,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Xn.defineCustomElement}),Is=(0,M.createComponent)({tagName:"appkit-tooltip",elementClass:Yn.AppkitTooltip,react:L.default,events:{},defineCustomElement:Yn.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,validateDestination});
|
|
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});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|