@naculus/connect-appkit-react 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{formatSol as aC,getLatestBlockhash as iC,getSignatureStatus as lC,getSolanaBalance as cC,LAMPORTS_PER_SOL as uC,PassphraseCancelledError as pC,PassphraseGate as dC,parseSol as mC,SolanaRpcError as fC}from"@naculus/connect-core";import{compareCostsKey as hr}from"@naculus/connect-appkit-core";import{useCallback as Xt,useEffect as Yt,useRef as Jt,useState as Qe}from"react";function Zt(e,t){let{operation:o,chains:s,options:n}=e,[l,a]=Qe([]),[C,u]=Qe(!1),[c,g]=Qe(null),r=Jt(!0),i=Jt(0),p=hr(e),f=Xt(async()=>{if(!s||s.length===0){a([]);return}if(!t)return;let S=++i.current;u(!0),g(null);try{let h=await t(o,s,n);r.current&&S===i.current&&a(h)}catch(h){r.current&&S===i.current&&(g(h instanceof Error?h:new Error(String(h))),a([]))}finally{r.current&&S===i.current&&u(!1)}},[p,t]);Yt(()=>{f()},[f]),Yt(()=>(r.current=!0,()=>{r.current=!1}),[]);let d=Xt(async()=>{await f()},[f]);return{comparisons:l,loading:C,error:c,refresh:d}}import{toExecuteRouteError as yr,validateRouteRecipient as Sr}from"@naculus/connect-appkit-core";import{useCallback as en,useEffect as Er,useRef as tn,useState as Xe}from"react";function nn(e){let[t,o]=Xe(!1),[s,n]=Xe(null),[l,a]=Xe(null),C=tn(!0),u=tn(!1);Er(()=>(C.current=!0,()=>{C.current=!1}),[]);let c=en(async(r,i,p)=>{if(!e)return a({code:"no_executor",message:"No executeRoute function provided"}),n(null),null;let f=Sr(r,i);if(f)return a(f),n(null),null;if(u.current)return a({code:"execution_in_progress",message:"A route execution is already in progress"}),null;u.current=!0,o(!0),a(null),n(null);try{let d=await e(r,i,p);return C.current&&n(d),d}catch(d){return C.current&&a(yr(d)),null}finally{u.current=!1,C.current&&o(!1)}},[e]),g=en(()=>{n(null),a(null),o(!1)},[]);return{execute:c,executing:t,result:s,error:l,reset:g}}import{isQuotableInput as wr}from"@naculus/connect-appkit-core";import{useCallback as Ye,useEffect as rn,useRef as on,useState as Je}from"react";function sn(e,t){let{fromChain:o,toChain:s,fromToken:n,toToken:l,amount:a,options:C}=e,[u,c]=Je([]),[g,r]=Je(!1),[i,p]=Je(null),f=on(null),d=on(!0),S=Ye(async()=>{if(!wr({fromChain:o,toChain:s,fromToken:n,amount:a})){c([]);return}if(t){r(!0),p(null);try{let E=await t(o,s,n,a,C,l);d.current&&c(E)}catch(E){d.current&&(p(E instanceof Error?E:new Error(String(E))),c([]))}finally{d.current&&r(!1)}}},[o,s,n,l,a,C,t]);rn(()=>{if(f.current&&clearTimeout(f.current),!o||!s||!n||!a){c([]);return}return f.current=setTimeout(()=>{S()},300),()=>{f.current&&clearTimeout(f.current)}},[S,o,s,n,a]),rn(()=>(d.current=!0,()=>{d.current=!1}),[]);let h=Ye(async()=>{await S()},[S]),w=Ye(()=>{c([]),p(null),r(!1)},[]);return{quotes:u,loading:g,error:i,refresh:h,clear:w}}import{logger as Ze,WalletError as K}from"@naculus/connect-core";import{eip6963Connector as q}from"@naculus/connector-evm-injected";import{PassphraseGate as kr}from"@naculus/connect-core";import{createWalletConnectConnector as xr}from"@naculus/connector-walletconnect";var et=null;function tt(e){let t=null,o=xr({projectId:e.projectId,metadata:e.metadata}),s=null,n=null,l=null,a=null,C=e.passphrasePrompt&&e.enableEmbedded&&!e.embeddedConfig?.encryptionPassphrase?new kr:null;e.enableEmbedded&&(n=import("@naculus/connector-embedded").then(r=>{let i={...e.embeddedConfig};C&&(i.encryptionPassphrase=C.request),e.enablePasskeys&&i.encryptionPassphrase&&!i.prfUnlock&&(i.prfUnlock={async derive(f){a&&await a;let d=l;return d?.hasCredential()?d.derivePrfKey(f):null}}),s=r.createPocketConnector(i),t?._setEmbeddedConnector(s)}).catch(r=>{Ze.warn("react/client","Embedded wallet connector not available:",r),s=null})),e.enablePasskeys&&(a=import("@naculus/connector-passkeys").then(r=>{l=r.createPasskeysConnector(),t?._setPasskeysConnector(l)}).catch(r=>{Ze.warn("react/client","Passkeys connector not available:",r),l=null}));let u=null,c=null;e.enableSolana&&(c=import("@naculus/connector-solana").then(r=>{let i=r.solanaConnector;e.solanaDefaultChain&&"configure"in i&&i.configure({defaultChain:e.solanaDefaultChain}),u=i,typeof window<"u"&&"startDiscovery"in i&&i.startDiscovery(),t?._setSolanaConnector(u)}).catch(r=>{Ze.warn("react/client","Solana connector not available:",r),u=null})),typeof window<"u"&&q.startDiscovery();let g={connector:o,get embeddedConnector(){return s},getEmbeddedConnector:async()=>(n&&await n,s),get passkeysConnector(){return l},passphraseGate:C,solanaRpcUrl:e.solanaRpcUrl??null,get solanaConnector(){return u},connect:()=>o.connect(),connectInjected:async r=>q.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(a&&await a,!l)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return l.connect()},startPairing:()=>o.startPairing(),completePairing:()=>o.completePairing(),cancelPairing:()=>o.cancelPairing?.(),signMessage:async(r,i)=>{if(r.id?.startsWith("eip6963-"))return q.signMessage(r,i);if(r.walletType==="passkeys"&&l)return l.signMessage(r,i);if(r.walletType==="embedded"){if(!s)throw new K("wallet_unavailable","Embedded wallet connector not available.");return s.signMessage(r,i)}if(r.walletType==="solana"){if(c&&await c,u)return u.signMessage(r,i);throw new K("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.signMessage(r,i)},signTransaction:async(r,i)=>{if(r.id?.startsWith("eip6963-"))return q.signTransaction(r,i);if(r.walletType==="embedded"){if(!s)throw new K("wallet_unavailable","Embedded wallet connector not available.");return s.signTransaction(r,i)}if(r.walletType==="solana"){if(c&&await c,u)return u.signTransaction(r,i);throw new K("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.signTransaction(r,i)},sendTransaction:async(r,i)=>{if(r.id?.startsWith("eip6963-"))return q.sendTransaction(r,i);if(r.walletType==="passkeys"&&l)return l.sendTransaction(r,i);if(r.walletType==="embedded"){if(!s)throw new K("wallet_unavailable","Embedded wallet connector not available.");return s.sendTransaction(r,i)}if(r.walletType==="solana"){if(c&&await c,u)return u.sendTransaction(r,i);throw new K("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.sendTransaction(r,i)},onAccountsChanged:(r,i)=>{let p=()=>{};return r.id?.startsWith("eip6963-")?q.onAccountsChanged?.(r,i)??p:r.walletType==="embedded"?s?.onAccountsChanged?.(r,i)??p:r.walletType==="passkeys"?p:r.walletType==="solana"?u?.onAccountsChanged?.(r,i)??p:o.onAccountsChanged?.(r,i)??p},onChainChanged:(r,i)=>{let p=()=>{};return r.id?.startsWith("eip6963-")?q.onChainChanged?.(r,i)??p:r.walletType==="passkeys"||r.walletType==="embedded"?p:r.walletType==="solana"?u?.onChainChanged?.(r,i)??p:o.onChainChanged?.(r,i)??p},getCapabilities:r=>r.id?.startsWith("eip6963-")?q.getCapabilities?.(r):r.walletType==="passkeys"?l?.getCapabilities?.(r):r.walletType==="solana"?u?.getCapabilities?.(r):r.walletType==="embedded"?s?.getCapabilities?.(r):o.getCapabilities?.(r),sendCalls:async(r,i,p,f)=>{if(r.id?.startsWith("eip6963-"))return q.sendCalls(r,i,p,f);if(r.walletType==="passkeys"&&l)return l.sendCalls(r,i,p,f);if(r.walletType==="solana"){if(c&&await c,u)return u.sendCalls(r,i,p,f);throw new K("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 K("method_not_allowed","Embedded wallet does not support sendCalls");return s.sendCalls(r,i,p,f)}if(!o.sendCalls)throw new K("method_not_allowed","sendCalls not supported by this connector");return o.sendCalls(r,i,p,f)},showCallsStatus:async(r,i)=>{if(r.id?.startsWith("eip6963-"))return q.showCallsStatus(r,i);if(r.walletType==="passkeys"||r.walletType==="embedded")throw new K("method_unsupported",`${r.walletType} wallets have no UI to display a call bundle.`);if(!o.showCallsStatus)throw new K("method_unsupported","This connector cannot display call status.");return o.showCallsStatus(r,i)},getCallsStatus:async(r,i)=>{if(r.id?.startsWith("eip6963-")&&q.getCallsStatus)return q.getCallsStatus(r,i);if(r.walletType==="passkeys"&&l?.getCallsStatus)return l.getCallsStatus(r,i);if(r.walletType==="embedded")throw new K("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!o.getCallsStatus)throw new K("method_not_allowed","getCallsStatus not supported by this connector");return o.getCallsStatus(r,i)},reconnect:async r=>r.walletType==="eip6963"?q.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 q.disconnect(r);if(r.walletType==="embedded"&&s)return s.disconnect();if(r.walletType==="passkeys"&&l)return l.disconnect(r);if(r.walletType==="solana"){if(c&&await c,u)return u.disconnect(r);throw new K("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),l&&r.push(l),u&&r.push(u),r},_setEmbeddedConnector:r=>{s=r},_setPasskeysConnector:r=>{l=r},_setSolanaConnector:r=>{u=r}};return t=g,et=g,g}function nt(){return et}function vr(){et=null}import{isEvmAddress as pn,parseCaip10 as Qr}from"@naculus/connect-core";import{useMemo as Xr}from"react";import{createConnectorManager as Mr,createSessionManager as Lr,LocalStorageSessionStorage as Br,logger as J,WalletError as Hr}from"@naculus/connect-core";import{eip6963Connector as Re}from"@naculus/connector-evm-injected";import{createContext as Fr,useCallback as F,useContext as Kr,useEffect as ce,useMemo as ue,useReducer as qr,useRef as cn}from"react";import{logger as Ar}from"@naculus/connect-core";import{issueNonce as br,parseSiwxMessage as Rr}from"@naculus/siwx";function oe(e,t){let o=t.split(":",1)[0],n=(e.namespaces[o]?.accounts??[]).filter(l=>l.startsWith(`${o}:`)).map(l=>({namespace:o,caip10:l}))[0];if(n)return{...n,address:n.caip10.split(":").pop()??n.caip10}}function Tr(e){return e.namespaces.eip155?.chains?.[0]??e.namespaces.solana?.chains?.[0]??e.namespaces.xrpl?.chains?.[0]??"eip155:1"}async function an(e){let{session:t,siwx:o,signMessage:s}=e;if(!o||!t)return{kind:"skipped"};try{let n=Tr(t),l=oe(t,n);if(!l)throw new Error("No account found in session");let{address:a}=l,C=await o.createMessage({address:a,chainId:n}),u=Rr(C);if(!u?.nonce)throw new Error("SIWx message must contain a nonce");await br(u.nonce);let c=await s(t,{message:C,address:a,chainId:n});return await o.handleSignComplete?.({message:C,signature:c}),{kind:"authenticated",address:a,chainId:n}}catch(n){let l=n instanceof Error?n:new Error("Wallet authentication failed");return Ar.error("appkit/core","SIWx authentication failed:",n),{kind:"failed",error:l,fatal:o.required!==!1}}}import{initialWeb3State as Vr,web3Reducer as $r,withRetry as Gr,withTimeout as un}from"@naculus/connect-appkit-core";import{resolveChain as Ir}from"@naculus/connect-appkit-core";import{CHAINS as be,DEFAULT_RPC_URLS as Ur,eip155Reference as Pr,getRpcUrl as Wr}from"@naculus/connect-core";var Or=[{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 Nr(e){let t=be[e];if(!t||!t.explorerUrl)return null;let o=t.caip2Id;return{caip2:o,name:t.name,rpcUrl:Wr(o,Ur[o]??""),explorerUrl:t.explorerUrl,token:t.nativeCurrency.symbol}}function _r(){if(!be)return[];let e=[],t=Object.keys(be).map(Number).sort((o,s)=>o-s);for(let o of t){let s=Nr(o);s&&e.push(s)}for(let o of Or){let s=Pr(o.caip2);(s===null||!be[s])&&e.push(o)}return e}var ln=_r();function Dr(e,t){return Ir(e,t)??void 0}function rt(){return[...ln]}import{jsx as zr}from"react/jsx-runtime";var ot=Fr(null);function jr({children:e,config:t,autoConnect:o=!0}){let[s,n]=qr($r,Vr),l=ue(()=>t.chains??rt(),[t.chains]),a=t.connectionTimeout??3e4,C=t.maxRetries??2,u=ue(()=>new Br(t.storageKey??"naculus_web3_session",t.encryptionKey),[t.storageKey,t.encryptionKey]),c=ue(()=>tt({projectId:t.projectId,metadata:t.metadata,enableEmbedded:t.enableEmbedded,embeddedConfig:t.embeddedConfig,enablePasskeys:t.enablePasskeys,enableSolana:t.enableSolana,solanaDefaultChain:t.solanaDefaultChain}),[t.projectId,t.metadata,t.enableEmbedded,t.embeddedConfig,t.enablePasskeys,t.enableSolana,t.solanaDefaultChain]),g=cn(null),r=cn(null),i=ue(()=>{let m=Mr();for(let O of[Re,...c.getAllConnectors()])m.register(O.id,O);let y={},k={};for(let O of l){let L=O.caip2;O.rpcUrl&&(y[L]=O.rpcUrl),O.token&&(k[L]={name:O.name,symbol:O.token,decimals:18})}let P=Lr(m,{autoRefreshFeeOnSwitch:t.autoRefreshFeeOnSwitch??!0,defaultRpcUrls:y,defaultCurrencies:k,encryptionKey:t.encryptionKey});return g.current=P,P},[c,l,t.autoRefreshFeeOnSwitch,t.encryptionKey]);ce(()=>{let m=P=>{let{walletSession:O}=P.bundle;n({type:"SET_SESSION",payload:O});let L=[];Object.values(O.namespaces).forEach(te=>{L.push(...te.accounts)}),n({type:"SET_ACCOUNTS",payload:L}),n({type:"SET_CHAIN",payload:P.bundle.activeChainId}),n({type:"SET_STATUS",payload:"connected"})},y=()=>{n({type:"RESET"})},k=P=>{n({type:"SET_CHAIN",payload:P.newChainId})};return i.on("sessionConnected",m),i.on("sessionDisconnected",y),i.on("chainChanged",k),()=>{i.off("sessionConnected",m),i.off("sessionDisconnected",y),i.off("chainChanged",k)}},[i]),ce(()=>{let m=()=>{u.clear(),n({type:"RESET"})};c.connector.onSessionExpiry(m)},[c,u]);let p=F(()=>{for(let m of[Re,...c.getAllConnectors()])i.registerConnector(m)},[c,i]),f=F(async m=>{p();let y=[Re,...c.getAllConnectors()].find(P=>P.id===m.walletType||P.kind===m.walletType);y&&!m.connectorId&&(m.connectorId=y.id);let k=m.namespaces.eip155?.chains?.[0]??m.namespaces.solana?.chains?.[0]??m.namespaces.xrpl?.chains?.[0];k&&await i.attach(m,k)},[c,i,p]),d=F(m=>{if(n({type:"SET_SESSION",payload:m}),m){let y=[];Object.values(m.namespaces).forEach(L=>{y.push(...L.accounts)}),n({type:"SET_ACCOUNTS",payload:y});let k=m.namespaces.eip155?.chains?.[0],P=m.namespaces.solana?.chains?.[0],O=m.namespaces.xrpl?.chains?.[0];n({type:"SET_CHAIN",payload:k??P??O??null})}else n({type:"SET_ACCOUNTS",payload:[]}),n({type:"SET_CHAIN",payload:null})},[]);ce(()=>{let m=s.session,y=c;return!m||!y?.onAccountsChanged?void 0:y.onAccountsChanged(m,P=>{if(P.length===0){u.clear().finally(()=>n({type:"RESET"}));return}d(m),u.save(m)})},[s.session,c,u,d]),ce(()=>{let m=s.session,y=c;if(!(!m||!y?.onChainChanged))return y.onChainChanged(m,k=>{d(m),u.save(m);let P=i.syncExternalChain;if(!P)return;let O=P.call(i,k).catch(L=>{J.warn("react/provider","External chain sync error:",L)});r.current=O,O.finally(()=>{r.current===O&&(r.current=null)})})},[s.session,c,u,d,i]);let S=F(async m=>{if(!t.siwx||!m)return!0;n({type:"SET_STATUS",payload:"authenticating"});let y=await an({session:m,siwx:t.siwx,signMessage:(k,P)=>c.signMessage(k,P)});return y.kind==="failed"&&y.fatal?(await u.clear(),n({type:"RESET"}),n({type:"SET_ERROR",payload:y.error}),!1):!0},[t.siwx,c,u]),h=F(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await un(c.connect(),a,"Wallet connect");await u.save(m),d(m);try{await f(m)}catch(y){J.warn("react/provider","SessionManager sync error:",y)}if(!await S(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let y=m instanceof Error?m.message:"Connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(y)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,a,S,f]),w=F(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await c.connectEmbedded();if(await u.save(m),d(m),await f(m),!await S(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let y=m instanceof Error?m.message:"Embedded wallet connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(y)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,S,f]),E=F(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await c.connectPasskeys();if(await u.save(m),d(m),await f(m),!await S(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let y=m instanceof Error?m.message:"Passkeys connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(y)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,S,f]),R=F(async()=>{if(!s.session){n({type:"RESET"});return}try{await c.disconnect(s.session)}catch(m){J.error("react/provider","Disconnect error:",m)}try{let m=g.current;m&&await m.disconnect()}catch(m){J.warn("react/provider","SessionManager disconnect error:",m)}await u.clear(),n({type:"RESET"})},[c,s.session,u]),A=F(async m=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let y=await un(c.connectInjected(m),a,"Injected wallet connect");await u.save(y),d(y);try{await f(y)}catch(k){J.warn("react/provider","SessionManager sync error:",k)}if(!await S(y))return;n({type:"SET_STATUS",payload:"connected"})}catch(y){let k=y instanceof Error?y.message:"Connection failed";n({type:"SET_ERROR",payload:y instanceof Error?y:new Error(k)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,a,S,f]),T=F(async()=>c.startPairing(),[c]),v=F(()=>{c.cancelPairing?.()},[c]),x=F(async()=>{let m=await c.completePairing();return await u.save(m),d(m),await f(m),await S(m)&&n({type:"SET_STATUS",payload:"connected"}),m},[c,u,d,S,f]),b=F(async m=>{let y=t.siwx;if(!y||y.required===!1)return!0;try{if(await y.hasValidSession?.())return!0}catch(k){J.warn("react/provider","siwx.hasValidSession failed",k)}return S(m)},[t.siwx,S]),I=F(async()=>{let m=await u.load();if(!m){n({type:"SET_STATUS",payload:"disconnected"});return}n({type:"SET_STATUS",payload:"reconnecting"});try{let y=await Gr(()=>c.reconnect(m),{maxRetries:C,baseDelay:1e3,label:"reconnect"});d(y);try{let k=g.current;k&&(p(),await k.restoreFromPersistence())}catch(k){J.warn("react/provider","SessionManager restore error:",k)}if(!await b(y))return;n({type:"SET_STATUS",payload:"connected"})}catch(y){J.error("react/provider","Reconnect error:",y),await u.clear(),n({type:"SET_STATUS",payload:"disconnected"}),n({type:"SET_SESSION",payload:null})}},[c,u,d,C,p,b]),W=F(async m=>{r.current&&await r.current;let y=g.current;if(y?.getActiveBundle()){await y.switchChain(m),d(s.session);return}if(!s.session)throw new Error("No active session");try{s.session.walletType==="eip6963"||s.session.id?.startsWith("eip6963-")?await Re.switchChain(s.session,m):s.session.walletType==="embedded"&&c.embeddedConnector?await c.embeddedConnector.switchChain?.(s.session,m):s.session.walletType==="passkeys"&&c.passkeysConnector?await c.passkeysConnector.switchChain?.(s.session,m):s.session.walletType==="solana"&&c.solanaConnector?await c.solanaConnector.switchChain?.(s.session,m):await c.connector.switchChain(s.session,m),d(s.session)}catch(k){throw new Hr("chain_unsupported","Failed to switch chain",k)}},[c,s.session,d]);ce(()=>{o&&I()},[o,I]);let M=F(()=>{n({type:"SET_ERROR",payload:null})},[]),B=ue(()=>({...s,connect:h,connectEmbedded:w,connectPasskeys:E,disconnect:R,reconnect:I,switchChain:W,startPairing:T,completePairing:x,cancelPairing:v,connectInjected:A,clearError:M,isConnected:s.status==="connected",chains:l,client:c,sessionManager:i}),[s,h,w,E,R,I,W,T,x,A,M,l,c,i]);return zr(ot.Provider,{value:B,children:e})}function U(){let e=Kr(ot);if(!e)throw new Error("useWeb3 must be used within a Web3ConnectProvider");return e}function H(){let{accounts:e,isConnected:t}=U(),o=Xr(()=>!t||e.length===0?null:e.map(n=>{let l=Qr(n);return l?{address:n,namespace:l.namespace,isEVM:l.namespace==="eip155"&&pn(l.address)}:{address:n,namespace:null,isEVM:pn(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}}import{chainNumber as Yr,resolveChain as Jr,toViemChain as Zr}from"@naculus/connect-appkit-core";import{useState as pe,useEffect as st,useCallback as eo,useMemo as de,useRef as to}from"react";import{createPublicClient as no,http as ro,formatEther as oo}from"viem";import{getNativeTokenPriceUsd as so}from"@naculus/connect-core";function ao(e){let{evmAccount:t,isConnected:o}=H(),{chainId:s,chains:n}=U(),[l,a]=pe(null),[C,u]=pe(!1),[c,g]=pe(null),[r,i]=pe(null),p=e?.refreshInterval,f=to(null),d=de(()=>Jr(n,s),[s,n]),S=d?Yr(d):null,h=de(()=>d?Zr(d,S):null,[d,S]),w=de(()=>d?.token??null,[d]),[E,R]=pe(null);st(()=>{if(!h||!d?.rpcUrl){R(null);return}let x=no({transport:ro(d.rpcUrl),chain:h});return R(x),()=>{}},[d]);let A=eo(async()=>{if(!t||!E){a(null);return}u(!0),g(null);try{let b=t.includes(":")?t.split(":").pop():t,[I,W]=await Promise.all([E.getBalance({address:b}),s?so(s,d?.rpcUrl).catch(()=>null):Promise.resolve(null)]);a(I.toString()),i(W)}catch(x){g(x instanceof Error?x:new Error("Failed to fetch balance")),a(null),i(null)}finally{u(!1)}},[t,E,s,d?.rpcUrl]);st(()=>{o&&t&&A()},[o,t,A]),st(()=>(p&&p>0&&o&&t&&(f.current=setInterval(A,p)),()=>{f.current&&(clearInterval(f.current),f.current=null)}),[p,o,t,A]);let T=de(()=>{if(l===null)return null;try{return oo(BigInt(l))}catch{return null}},[l]),v=de(()=>{if(r===null||T===null)return null;let x=parseFloat(T);if(isNaN(x))return null;let b=x*r;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(b)},[r,T]);return{balance:l,formatted:T,symbol:w,usdPrice:r,usdValue:v,isLoading:C,error:c,refetch:A,chain:d}}import{atomicSupportFor as io,normalizeCapabilities as lo,selectChainCapabilities as co}from"@naculus/connect-appkit-core";import{useCallback as uo,useEffect as po,useRef as mo,useState as at}from"react";function N(e){return e??nt()}function it(){let{client:e,session:t,chainId:o}=U(),[s,n]=at(null),[l,a]=at(!1),[C,u]=at(null),c=mo(0),g=uo(async()=>{let r=++c.current,i=N(e);if(!i?.getCapabilities||!t){n(null),a(!1),u(null);return}a(!0),u(null);try{let p=await i.getCapabilities(t);if(r!==c.current)return;n(lo(p))}catch(p){if(r!==c.current)return;n(null),u(p instanceof Error?p:new Error("Capability query failed"))}finally{r===c.current&&a(!1)}},[e,t]);return po(()=>{g()},[g]),{capabilities:s,current:co(s,o),atomic:io(s,o),isFetching:l,error:C,refetch:g}}import{useMemo as lt}from"react";import{chainsForNamespace as fo,describeChain as go,resolveChain as Co}from"@naculus/connect-appkit-core";function V(){let{chainId:e,session:t,switchChain:o,chains:s}=U(),n=lt(()=>Co(s,e),[s,e]),l=lt(()=>t?go(s,e):null,[s,e,t]),a=lt(()=>fo(s,e),[s,e]);return{chainId:e,currentChain:n,chainInfo:l,availableChains:a,chains:a,isEvm:e?.startsWith("eip155:")??!1,switchChain:o}}import{useCallback as ho,useState as dn}from"react";import{WalletError as yo}from"@naculus/connect-core";function So(){let{connect:e,status:t}=U(),[o,s]=dn(!1),[n,l]=dn(null);return{connect:ho(async()=>{s(!0),l(null);try{await e()}catch(C){let u=C instanceof Error?C.message:"Connection failed";l(C instanceof yo?C:new Error(u))}finally{s(!1)}},[e]),isConnecting:o||t==="connecting",error:n}}import{readDelegation as vo,UNKNOWN_DELEGATION as ut}from"@naculus/connect-core";import{useCallback as Ao,useEffect as bo,useRef as Ro,useState as pt}from"react";import{chainNumber as Eo,toViemChain as wo}from"@naculus/connect-appkit-core";import{useMemo as ct}from"react";import{createPublicClient as ko,http as mn,createWalletClient as xo}from"viem";function G(){let{evmAccount:e,isConnected:t}=H(),{currentChain:o,chains:s}=V(),n=o?Eo(o):null,l=ct(()=>o?wo(o,n):null,[o,n]),a=ct(()=>l?ko({transport:mn(l.rpcUrls.default.http[0]),chain:l}):null,[o,l]),C=ct(()=>{if(!t||!e||!l)return null;let u=e.includes(":")?e.split(":").pop():e;return xo({transport:mn(l.rpcUrls.default.http[0]),chain:l,account:u})},[t,e,o,l]);return{publicClient:a,walletClient:C,chains:s}}function me(){let{publicClient:e}=G(),{evmAccount:t}=H(),[o,s]=pt(ut),[n,l]=pt(!1),[a,C]=pt(null),u=Ro(0),c=t?.includes(":")?t.split(":").pop():t,g=Ao(async()=>{let r=++u.current;if(!e||!c){s(ut),l(!1),C(null);return}l(!0),C(null);try{let i=await e.getCode({address:c});if(r!==u.current)return;s(vo(i??"0x"))}catch(i){if(r!==u.current)return;s(ut),C(i instanceof Error?i:new Error("Code read failed"))}finally{r===u.current&&l(!1)}},[e,c]);return bo(()=>{g()},[g]),{...o,isFetching:n,error:a,refetch:g}}import{bareEvmAddress as qo,createDelegationPolicyFlow as Vo,isVerifiablePolicy as $o}from"@naculus/connect-appkit-core";import{useCallback as ge,useEffect as Go,useMemo as jo,useState as Ue}from"react";import{recoverMessageAddress as zo}from"viem";import{planExecution as Po,WalletError as Wo}from"@naculus/connect-core";import{useCallback as fn,useState as mt}from"react";import{chooseExecutionStrategy as Io,getAccountCapabilities as Uo,WalletError as Z}from"@naculus/connect-core";import{useCallback as Ie,useState as fe}from"react";import{WalletError as To}from"@naculus/connect-core";function Te(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 To("tx_failed","Wallet did not return a valid 32-byte transaction hash")}function dt(){let{session:e,chainId:t,client:o}=U(),[s,n]=fe("idle"),[l,a]=fe(null),[C,u]=fe(null),[c,g]=fe(null),[r,i]=fe(null),p=Ie(async(h,w)=>{if(!e){n("failed");let E=new Z("wallet_unavailable","No active session");throw a(E),E}if(h.length===0){n("failed");let E=new Z("invalid_input","At least one call is required");throw a(E),E}n("awaiting_approval"),a(null),u(null);try{let E=N(o);if(!E)throw new Z("wallet_unavailable","Client not initialized");let R=w?.chainId??t??void 0,A=w?.strategy??Io(await Uo(E,e,R),h.length);if(i(A),A==="atomic-batch"){let v=await E.sendCalls(e,h,R,{atomicRequired:!0,...w?.paymasterService?{paymasterService:w.paymasterService}:{}});return n("submitted"),u(v),v}let T="";for(let v=0;v<h.length;v++){let x=h[v];try{T=Te(await E.sendTransaction(e,{transaction:{to:x.to,data:x.data,value:x.value},chainId:R}))}catch(b){throw new Z("tx_failed",`Call ${v+1} of ${h.length} failed after ${v} already landed (sent sequentially \u2014 this wallet cannot batch atomically): ${b instanceof Error?b.message:String(b)}`)}}return n("submitted"),u(T),T}catch(E){n("failed");let R=E instanceof Error?E.message:"sendCalls failed";throw a(E instanceof Error?E:new Error(R)),E}},[e,t,o]),f=Ie(async h=>{if(!e)throw new Z("wallet_unavailable","No active session");let w=h??C;if(!w)throw new Z("invalid_input","No bundle hash available");if(!h&&r==="sequential")throw new Z("invalid_input","Calls were sent sequentially, so there is no bundle to query. Track the returned transaction hash instead.");let E=N(o);if(!E)throw new Z("wallet_unavailable","Client not initialized");let R=await E.getCallsStatus(e,w);return g(R),R},[e,C,o,r]),d=Ie(async h=>{if(!e)return!1;let w=h??C;if(!w||!h&&r==="sequential")return!1;let E=N(o);if(!E?.showCallsStatus)return!1;try{return await E.showCallsStatus(e,w),!0}catch{return!1}},[e,C,o,r]),S=Ie(()=>{n("idle"),a(null),u(null),g(null),i(null)},[]);return{sendCalls:p,getCallsStatus:f,showCallsStatus:d,status:s,error:l,batchHash:C,callsStatus:c,execution:r,reset:S,isSending:s==="awaiting_approval"}}function ft(e={}){let{current:t,atomic:o}=it(),{delegated:s,delegate:n}=me(),{sendCalls:l}=dt(),[a,C]=mt(!1),[u,c]=mt(null),[g,r]=mt(null),i=e.atomicity??"preferred",p=e.sponsorship??"any",f=e.paymasterService,d=e.userOperation,S=e.userOperationSponsored??!1,h=!!(t?.raw?.paymasterService?.supported&&f),w=fn((R,A=i)=>{let T=Po({atomicBatch:o==="supported",discovered:o!=="unknown",sponsoredTransactions:!1,...t?.maxBatchSize===void 0?{}:{maxBatchSize:t.maxBatchSize}},R,{atomicity:A,sponsorship:p}),v=p==="required"&&!S;if(T.strategy==="atomic-batch"&&!v)return{...T,reason:T.reason+(h?" A paymaster service will be requested, but the wallet's final fee payer must be checked after execution.":""),route:"wallet-batch"};let x=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=A!=="any"&&!T.atomic||p==="required";return d&&b&&!v?{strategy:"atomic-batch",atomic:!0,sponsored:S,reason:p==="required"&&!T.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"}:v?{strategy:"refuse",atomic:T.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}:T.strategy==="refuse"?{...T,reason:T.reason+x,route:null}:{...T,reason:T.reason+x,route:"sequential"}},[o,t,f,h,d,S,i,p,s,n]),E=fn(async(R,A=i)=>{C(!0),c(null);try{let T=w(R.length,A);if(T.route===null)throw new Wo("method_not_allowed",T.reason);return r(T.route),T.route==="user-operation"?await d(R):await l(R,{strategy:T.route==="wallet-batch"?"atomic-batch":"sequential",...T.route==="wallet-batch"&&h?{paymasterService:f}:{}})}catch(T){let v=T instanceof Error?T:new Error("Execution failed");throw c(v),v}finally{C(!1)}},[w,l,d,i,f,h]);return{preview:w,execute:E,isExecuting:a,error:u,lastRoute:g,reset:()=>{c(null),r(null)}}}import{getSharedSessionKeyManager as Oo,resetSharedSessionKeyManager as No}from"@naculus/connect-appkit-core";import{WalletError as _o}from"@naculus/connect-core";import{useCallback as Q,useEffect as Do,useRef as Mo,useState as z}from"react";function se(e){return Oo(e)}function gt(e){let{session:t}=U(),[o,s]=z([]),[n,l]=z(!1),[a,C]=z(null),u=Mo(!0),c=Q(()=>C(null),[]),g=se(e),r=g.isStorageAvailable(),i=Q(async()=>{if(!t){s([]);return}l(!0),C(null);try{let f=await g.listSessions();u.current&&s(f)}catch(f){u.current&&C(f instanceof Error?f:new Error("Failed to load session keys"))}finally{u.current&&l(!1)}},[t,g]);Do(()=>(u.current=!0,i(),()=>{u.current=!1}),[i]);let p=o.filter(f=>f.status==="active");return{sessions:o,activeSessions:p,loading:n,error:a,refresh:i,clearError:c,storageAvailable:r}}function Lo(e){let{session:t}=U(),[o,s]=z(null),[n,l]=z(!1),[a,C]=z(null),u=Q(()=>C(null),[]),c=se(e);return{createSessionKey:Q(async(r,i)=>{if(!t)throw new _o("wallet_unavailable","No active wallet session");l(!0),C(null);try{let p=i??void 0,f=await c.createSessionKey(r,p);return s(f),f}catch(p){let f=p instanceof Error?p:new Error("Failed to create session key");throw C(f),f}finally{l(!1)}},[t,c]),lastCreated:o,isCreating:n,error:a,clearError:u}}function Bo(e){let[t,o]=z(!1),[s,n]=z(null),l=Q(()=>n(null),[]),a=se(e);return{revokeSession:Q(async u=>{o(!0),n(null);try{await a.revokeSession(u)}catch(c){let g=c instanceof Error?c:new Error("Failed to revoke session key");throw n(g),g}finally{o(!1)}},[a]),isRevoking:t,error:s,clearError:l}}function Ho(e){let[t,o]=z(!1),[s,n]=z(null),l=Q(()=>n(null),[]),a=se(e),C=Q(async(c,g,r)=>{o(!0),n(null);try{return await a.signWithSessionKey(c,g,r)}catch(i){let p=i instanceof Error?i:new Error("Failed to sign with session key");throw n(p),p}finally{o(!1)}},[a]),u=Q(async(c,g)=>{o(!0),n(null);try{return await a.checkSessionScope(c,g)}catch(r){let i=r instanceof Error?r:new Error("Failed to check session scope");throw n(i),i}finally{o(!1)}},[a]);return{signWithSession:C,checkScope:u,isBusy:t,error:s,clearError:l}}function Fo(){No()}import{useState as gn,useCallback as Ko}from"react";import{WalletError as Ct}from"@naculus/connect-core";function ht(){let{session:e,chainId:t,client:o}=U(),[s,n]=gn(!1),[l,a]=gn(null);return{signMessage:Ko(async u=>{if(!e){let g=new Ct("wallet_unavailable","No active session");throw a(g),g}let c=e.namespaces.eip155?.accounts[0]??Object.values(e.namespaces)[0]?.accounts[0];if(!c){let g=new Ct("wallet_unavailable","No account found");throw a(g),g}n(!0),a(null);try{let g=N(o);if(!g)throw new Ct("wallet_unavailable","Client not initialized");return await g.signMessage(e,{message:u,address:c,chainId:t??void 0})}catch(g){let r=g instanceof Error?g.message:"Signing failed",i=g instanceof Error?g:new Error(r);throw a(i),i}finally{n(!1)}},[e,t,o]),isSigning:s,error:l}}import{buildDelegationPolicyMessage as Xo}from"@naculus/connect-appkit-core";function Qo(e={}){let{evmAccount:t}=H(),o=qo(t),s=me(),n=ft(e.execution),{signMessage:l}=ht(),a=gt(e.managerConfig),C=se(e.managerConfig),[u,c]=Ue(!1),[g,r]=Ue(null),[i,p]=Ue(()=>new Set),[f,d]=Ue(!1),S=e.origin??(typeof window<"u"?window.location.origin:"unknown"),h=!!e.managerConfig?.encryptionKey,w=e.execution?.sponsorship,{refresh:E,storageAvailable:R}=a,{preview:A}=n,{delegated:T,delegate:v}=s,x=jo(()=>Vo({manager:C,origin:S,signer:()=>o,signMessage:l,verifySignature:async({message:y,signature:k,signerAddress:P})=>(await zo({message:y,signature:k})).toLowerCase()===P.toLowerCase(),previewExecution:A,sponsorship:w,adapter:e.adapter,delegation:()=>({delegated:T,delegate:v}),encryptionKeyConfigured:h,storageAvailable:()=>R,refresh:E}),[C,S,o,l,A,w,e.adapter,T,v,h,R,E]);Go(()=>{let y=!1,k=a.sessions.filter($o);return k.length===0?(p(new Set),d(!1),()=>{y=!0}):(d(!0),Promise.all(k.map(async P=>[P.id,await x.verifyStoredPolicy(P)])).then(P=>{y||p(new Set(P.filter(([,O])=>O).map(([O])=>O)))}).catch(P=>{y||(p(new Set),r(P instanceof Error?P:new Error("Policy verification failed")))}).finally(()=>{y||d(!1)}),()=>{y=!0})},[a.sessions,x]);let b=ge(()=>{r(null),a.clearError()},[a]),I=ge(async(y,k)=>{c(!0),r(null);try{return await y()}catch(P){let O=P instanceof Error?P:new Error(k);throw r(O),O}finally{c(!1)}},[]),W=ge(y=>I(()=>x.createPolicy(y),"Policy creation failed"),[x,I]),M=ge(y=>I(()=>x.revokePolicy(y),"Policy revocation failed"),[x,I]),B=ge((y,k)=>I(()=>x.executePolicy(y,k),"Policy execution failed"),[x,I]),m=a.activeSessions.filter(y=>i.has(y.id));return{policies:a.sessions,activePolicies:m,storageAvailable:a.storageAvailable,loading:a.loading||f,isBusy:u,error:g??a.error,delegation:s,createPolicy:W,revokePolicy:M,previewPolicyExecution:x.previewPolicyExecution,signPolicyDigest:x.signPolicyDigest,executePolicy:B,refresh:a.refresh,clearError:b}}import{useCallback as Yo,useRef as Jo,useState as Cn}from"react";function Zo(){let{disconnect:e,status:t}=U(),[o,s]=Cn(!1),[n,l]=Cn(null),a=Jo(!0);return{disconnect:Yo(async()=>{if(t!=="disconnected"){s(!0),l(null);try{await e()}catch(u){if(!a.current)return;l(u instanceof Error?u:new Error("Disconnect failed"))}finally{a.current&&s(!1)}}},[e,t]),isDisconnecting:o,error:n,cleanup:()=>{a.current=!1}}}import{WalletError as yt}from"@naculus/connect-core";import{useCallback as X,useEffect as es,useRef as Pe,useState as We}from"react";function ee(e){let t=e.activeNamespace??"eip155",o=Array.isArray(e.accounts)?e.accounts.map(({namespace:s,address:n,derivationPath:l})=>({namespace:s,address:n,...l?{derivationPath:l}:{}})):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 ts(){let{connectEmbedded:e,client:t}=U(),[o,s]=We(null),n=Pe(null),l=Pe(4),a=Pe(!1),C=Pe(null),[u,c]=We(!1),[g,r]=We(!1),[i,p]=We(null),f=()=>p(null),d=X(()=>{let m=n.current;return n.current=null,m},[]),S=X(()=>{let m=N(t);if(!m?.embeddedConnector)throw new yt("wallet_unavailable","Embedded wallet not enabled.");return m.embeddedConnector},[t]),h=X(()=>{try{return S().getWallet()?.privateKey??null}catch{return null}},[S]),w=X(async()=>{let m=N(t);if(!m)throw new yt("wallet_unavailable","Embedded wallet not enabled.");let y=m.getEmbeddedConnector?await m.getEmbeddedConnector():m.embeddedConnector;if(!y)throw new yt("wallet_unavailable","Embedded wallet not enabled.");return y},[t]),E=X(()=>{try{return N(t)?.passphraseGate??null}catch{return null}},[t]),R=X(m=>{m?.code==="decryption_failed"&&E()?.forget("That passphrase did not open the wallet.")},[E]),A=X(async()=>{a.current=!1,p(null);try{let m=await w();if(!await m.load())return!1;let k=m.getWallet();return k?(n.current=null,c(!1),s(ee(k)),!0):!1}catch(m){return a.current=!0,R(m),p(m instanceof Error?m:new Error("Failed to restore embedded wallet")),!1}},[R,w]);es(()=>{let m=!1,y=null;return A().then(k=>{m||k||a.current||(y=setTimeout(()=>{m||A()},100))}),()=>{m=!0,y&&clearTimeout(y)}},[A]);let T=async()=>{r(!0),p(null);try{let m=await w(),y=await m.load(),k=m.getWallet();y&&k&&(s(ee(k)),n.current=k.mnemonic||null,c(!k.mnemonic)),await e();let P=m.getWallet();P&&(s(ee(P)),P.mnemonic&&!y&&(n.current=P.mnemonic,c(!0)))}catch(m){R(m),p(m instanceof Error?m:new Error("Embedded wallet connection failed"))}finally{r(!1)}},v=async()=>{r(!0),p(null);try{let m=await w();E()?.expect("create");let y=await m.generateWallet();return s(ee(y)),n.current=y.mnemonic,c(!0),y}catch(m){return p(m instanceof Error?m:new Error("Failed to generate wallet")),null}finally{r(!1)}},x=async m=>{r(!0),p(null);try{let y=await w();E()?.expect("create");let k=await y.importFromMnemonic(m);return s(ee(k)),n.current=null,c(!1),k}catch(y){return p(y instanceof Error?y:new Error("Failed to import wallet")),null}finally{r(!1)}},b=async m=>{r(!0),p(null);try{let y=await w();E()?.expect("create");let k=await y.importFromPrivateKey(m);return s(ee(k)),n.current=null,c(!1),k}catch(y){return p(y instanceof Error?y:new Error("Failed to import wallet")),null}finally{r(!1)}},I=async()=>{r(!0),p(null);try{await(await w()).wipe(),s(null),n.current=null,c(!1)}catch(m){p(m instanceof Error?m:new Error("Failed to wipe wallet"))}finally{r(!1)}},W=X(m=>{let y=S();y.setActiveNamespace(m);let k=y.getWallet();s(k?ee(k):null)},[S]),M=X(async()=>{let m=await w(),y=await m.backfillAccounts();if(y.length>0){let k=m.getWallet();s(k?ee(k):null)}return y.map(({namespace:k,address:P,derivationPath:O})=>({namespace:k,address:P,...O?{derivationPath:O}:{}}))},[w]),B=()=>{n.current=null,c(!1)};return{connectEmbedded:T,restoreWallet:A,generateWallet:v,importFromMnemonic:x,importFromPrivateKey:b,wipe:I,wallet:o,hasWallet:o!==null,address:o?.address??null,accounts:o?.accounts??[],activeNamespace:o?.activeNamespace??null,setActiveNamespace:W,backfillAccounts:M,seedPhrase:n.current,getSeedPhrase:d,getPrivateKey:h,backupPending:u,confirmBackup:B,isBusy:g,error:i,clearError:f,storageSecurityLevel:(()=>{try{let m=S(),y=m.getStorageSecurityLevel?.()??4;return m.getWallet()?(l.current=y,y):o?l.current:y}catch{return o?l.current:4}})(),securityReport:(()=>{let m=null;try{m=S().getStorageSecurityReport?.()??null}catch{m=null}if(!m)return C.current=null,null;let y=JSON.stringify(m);return C.current?.json===y?C.current.value:(C.current={json:y,value:m},m)})()}}import{chainNumber as ls}from"@naculus/connect-appkit-core";import{useState as cs,useCallback as us,useEffect as Sn,useRef as En,useMemo as ps}from"react";import{WalletError as ns}from"@naculus/connect-core";import{useCallback as hn,useEffect as rs,useLayoutEffect as os,useMemo as ss,useRef as yn}from"react";import{tokenChainMismatch as as}from"@naculus/connect-appkit-core";function is(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 ae(e){let{token:t,chainId:o}=e,s=t.address.toLowerCase(),n=is(e),l=ss(()=>({key:n}),[n]),a=yn(n),C=yn(!0);os(()=>{a.current=n},[n]),rs(()=>(C.current=!0,()=>{C.current=!1}),[]);let u=hn(()=>C.current&&a.current===n,[n]),c=hn(()=>{if(!u())throw new ns("session_inactive","Wallet or token context changed. Retry the operation with the current account and chain.");let g=as({address:s,chainId:t.chainId},o);if(g)throw g},[u,s,t.chainId,o]);return{identity:l,isCurrent:u,assertCurrent:c}}import{ERC20_MIN_ABI as ds,formatUnits as ms}from"@naculus/connect-core";function fs(e){let{publicClient:t}=G(),{currentChain:o}=V(),{identity:s,isCurrent:n,assertCurrent:l}=ae({token:e.token,chainId:o?ls(o)??void 0:void 0,owner:e.owner,spender:e.spender,publicClient:t}),[a,C]=cs(null),u=a?.identity===s?a.raw:null,c=a?.identity===s&&a.fetching,g=a?.identity===s?a.error:null,r=En(null),i=En(0),p=us(async()=>{if(!n())return;let d=++i.current,S=()=>n()&&d===i.current;if(C({identity:s,raw:null,fetching:!!t,error:null}),!!t)try{l();let h=await t.readContract({address:e.token.address,abi:ds,functionName:"allowance",args:[e.owner,e.spender]});if(!S())return;C({identity:s,raw:h,fetching:!1,error:null})}catch(h){if(!S())return;C({identity:s,raw:null,fetching:!1,error:h instanceof Error?h:new Error("Failed to fetch allowance")})}},[t,e.token.address,e.token.chainId,e.owner,e.spender,s,n,l]);return Sn(()=>{p().catch(d=>console.warn("useERC20Allowance: initial fetch failed:",d))},[p]),Sn(()=>(e.refreshInterval&&e.refreshInterval>0&&(r.current=setInterval(p,e.refreshInterval)),()=>{r.current&&(clearInterval(r.current),r.current=null)}),[e.refreshInterval,p]),{allowance:ps(()=>{if(u===null)return null;let d=e.token.decimals;return d===void 0?null:ms(u,d)},[u,e.token.decimals]),allowanceRaw:u,isFetching:c,error:g,refetch:p}}import{chainNumber as gs,createDecimalsCache as Cs,encodeErc20Approve as hs,readDecimals as Et,writeDecimals as xn}from"@naculus/connect-appkit-core";import{ERC20_MIN_ABI as Oe,formatUnits as ys,parseUnits as vn,WalletError as Ne}from"@naculus/connect-core";import{useCallback as he,useRef as An,useState as bn}from"react";import{WalletError as St}from"@naculus/connect-core";import{useCallback as wn,useState as kn}from"react";function Ce(){let{session:e,chainId:t,client:o}=U(),[s,n]=kn("idle"),[l,a]=kn(null),C=wn(async c=>{if(!e){n("failed");let r=new St("wallet_unavailable","No active session");throw a(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 St("wallet_unavailable","No EVM account found");throw a(r),r}n("awaiting_approval"),a(null);try{let r={...c,from:c.from??g.split(":").pop()},i=N(o);if(!i)throw new St("wallet_unavailable","Client not initialized");let p=await i.sendTransaction(e,{transaction:r,chainId:t??void 0}),f=Te(p);return n("submitted"),f}catch(r){n("failed");let i=r instanceof Error?r.message:"Transaction failed";throw a(r instanceof Error?r:new Error(i)),r}},[e,t,o]),u=wn(()=>{n("idle"),a(null)},[]);return{sendTransaction:C,status:s,error:l,reset:u,isSending:s==="awaiting_approval"}}function Ss(e){return e.includes(":")?e.split(":").pop():e}var Es=2n**256n-1n;function ws(e){let{publicClient:t,walletClient:o}=G(),{evmAccount:s,isConnected:n}=H(),{currentChain:l}=V(),{session:a,client:C}=U(),{sendTransaction:u,isSending:c,error:g,reset:r}=Ce(),[i,p]=bn(null),{identity:f,isCurrent:d,assertCurrent:S}=ae({token:e.token,chainId:l?gs(l)??void 0:void 0,owner:s,spender:e.spender,connected:n,publicClient:t,walletClient:o,session:a,client:C}),[h,w]=bn(null),E=h?.identity===f?h.raw:null,R=h?.identity===f&&h.fetching,A=An(Cs(e.token,e.token.decimals)),T=An(0),v=i??g,x=s?Ss(s):null,b=he(async()=>{if(!d())return null;let y=++T.current,k=()=>d()&&y===T.current;if(w({identity:f,raw:null,fetching:!!t&&!!x&&n}),p(null),!t||!x||!n)return null;try{S();let P=await t.readContract({address:e.token.address,abi:Oe,functionName:"allowance",args:[x,e.spender]});return k()?(w({identity:f,raw:P,fetching:!1}),P):null}catch(P){return k()&&(w({identity:f,raw:null,fetching:!1}),p(P instanceof Error?P:new Error("Failed to fetch allowance"))),null}},[t,x,e.token.address,e.token.chainId,e.spender,f,d,S,n]),I=(()=>{if(E===null)return null;let y=Et(A.current,e.token,e.token.decimals);return y===void 0?null:ys(E,y)})(),W=he(async y=>{if(p(null),r(),!n||!s){let k=new Ne("wallet_unavailable","No connected account");throw p(k),k}if(!t){let k=new Ne("wallet_unavailable","No public client");throw p(k),k}try{S();let k=hs(e.spender,y),P=N(C);if(a&&P){let L=await u({to:e.token.address,data:k,value:"0"});return b(),L}if(o){let{request:L}=await t.simulateContract({address:e.token.address,abi:Oe,functionName:"approve",args:[e.spender,y],account:x});S();let te=await o.writeContract(L);return b(),te}let O=await u({to:e.token.address,data:k,value:"0"});return b(),O}catch(k){let P=k instanceof Error?k:new Error("Approve failed");throw d()&&p(P),P}},[e,t,o,s,n,a,C,x,u,r,b,S,d]),M=he(async y=>{try{if(S(),!t)throw new Ne("wallet_unavailable","No public client");let k=Et(A.current,e.token,e.token.decimals);k===void 0&&(k=await t.readContract({address:e.token.address,abi:Oe,functionName:"decimals"}),S(),xn(A.current,e.token,k));let P=vn(y,k);return await W(P)}catch(k){throw d()&&p(k instanceof Error?k:new Error("Approve failed")),k}},[e.token,t,W,S,d]),B=he(async()=>W(Es),[W]),m=he(async y=>{if(!d()||!n||!x||!t)return!1;try{S()}catch(L){return p(L instanceof Error?L:new Error("Cannot check allowance")),!1}let k=E??await b();if(k===null)return!1;let P=Et(A.current,e.token,e.token.decimals);if(P===void 0){if(!t)throw new Ne("wallet_unavailable","Cannot check allowance: no public client to read token decimals.");if(P=await t.readContract({address:e.token.address,abi:Oe,functionName:"decimals"}),!d())return!1;xn(A.current,e.token,P)}let O=vn(y,P);return d()&&k>=O},[E,b,e.token.address,e.token.chainId,e.token.decimals,t,d,S,n,x]);return{approve:M,approveMax:B,allowance:I,allowanceRaw:E,hasAllowance:m,isApproving:c,isFetchingAllowance:R,error:v,refetchAllowance:b}}import{chainNumber as ks,createDecimalsCache as xs,encodeErc20Transfer as vs,readDecimals as As,writeDecimals as bs}from"@naculus/connect-appkit-core";import{ERC20_MIN_ABI as Rn,parseUnits as Rs,WalletError as Tn}from"@naculus/connect-core";import{useCallback as Ts,useRef as Is,useState as Us}from"react";function Ps(e){return e.includes(":")?e.split(":").pop():e}function Ws(e){let{publicClient:t,walletClient:o}=G(),{evmAccount:s,isConnected:n}=H(),{currentChain:l}=V(),{session:a,client:C}=U(),{sendTransaction:u,isSending:c,error:g,reset:r}=Ce(),[i,p]=Us(null),{isCurrent:f,assertCurrent:d}=ae({token:e.token,chainId:l?ks(l)??void 0:void 0,owner:s,connected:n,publicClient:t,walletClient:o,session:a,client:C}),S=Is(xs(e.token,e.token.decimals)),h=i??g;return{sendTransfer:Ts(async(E,R)=>{if(p(null),r(),!n||!s){let A=new Tn("wallet_unavailable","No connected account");throw p(A),A}if(!t){let A=new Tn("wallet_unavailable","No public client available");throw p(A),A}try{d();let A=Ps(s),T=As(S.current,e.token,e.token.decimals);T===void 0&&(T=await t.readContract({address:e.token.address,abi:Rn,functionName:"decimals"}),d(),bs(S.current,e.token,T));let v=Rs(R,T),x=vs(E,v),b=N(C);if(a&&b)return await u({to:e.token.address,data:x,value:"0"});if(o){let{request:W}=await t.simulateContract({address:e.token.address,abi:Rn,functionName:"transfer",args:[E,v],account:A});return d(),await o.writeContract(W)}return await u({to:e.token.address,data:x,value:"0"})}catch(A){let T=A instanceof Error?A:new Error("Transfer failed");throw f()&&p(T),T}},[e.token,t,o,s,n,a,C,u,r,d,f]),isSending:c,error:h}}import{chainNumber as Ds,encodeErc20Transfer as Ms}from"@naculus/connect-appkit-core";import{parseUnits as Ls}from"@naculus/connect-core";import{useMemo as Bs}from"react";import{simulateTransactionPreview as Os}from"@naculus/connect-appkit-core";import{useCallback as In,useEffect as Ns,useRef as _s,useState as wt}from"react";function kt(e,t){U();let{evmAccount:o}=H(),{currentChain:s}=V(),{publicClient:n}=G(),[l,a]=wt(void 0),[C,u]=wt(!1),[c,g]=wt(null),r=_s(void 0),i=In(async()=>{e&&(u(!0),g(null));try{let f=await Os(e,{chainId:t,currentChain:s,publicClient:n,evmAccount:o});return a(f),f}catch(f){let d=f instanceof Error?f:new Error("Simulation failed");throw g(d),d}finally{e&&u(!1)}},[e,t,s,n,o]);Ns(()=>{if(e)return r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{i().catch(()=>{})},300),()=>{r.current&&clearTimeout(r.current)}},[e,i]);let p=In(()=>{a(void 0),g(null),u(!1)},[]);return{result:l,isSimulating:C,error:c,simulate:i,reset:p}}function Hs(e){let{evmAccount:t,isConnected:o}=H(),{currentChain:s}=V(),n=e.token.chainId??(s?Ds(s)??void 0:void 0),l=Bs(()=>{if(!(!o||!t))try{let C=e.token.decimals;if(C===void 0)return;let u=Ls(e.amount,C),c=Ms(e.to,u);return{to:e.token.address,data:c,value:"0"}}catch{return}},[e.token.address,e.token.decimals,e.to,e.amount,t,o]),a=kt(l,n);return{result:l?a.result:void 0,isSimulating:!!l&&a.isSimulating,error:l?a.error:null,reSimulate:a.simulate,reset:a.reset}}import{useState as xt,useCallback as Gs,useRef as vt}from"react";import{useState as _e,useEffect as Fs,useCallback as Un,useRef as Ks}from"react";import{createContext as qs,useContext as Vs}from"react";var Pn=qs(null);function ye(){return Vs(Pn)}function $s(e,t,o){let s=ye(),n=o??s,[l,a]=_e(null),[C,u]=_e(!1),[c,g]=_e(!1),[r,i]=_e(null),p=Ks(void 0),f=Un(async()=>{if(!(!n||!e)){u(!0),i(null);try{await n.refreshTx(e,t);let h=n.getTxStatus(e,t);h&&a(h)}catch(h){i(h instanceof Error?h:new Error(String(h)))}finally{u(!1)}}},[n,e,t]),d=Un(()=>{!n||!e||(n.stopWatching(e,t),g(!1))},[n,e,t]);Fs(()=>{if(!n||!e||!t){a(null),g(!1);return}p.current&&p.current!==e&&n.stopWatching(p.current),p.current=e;let h=!1;g(!0),u(!0),i(null);let w=n.getTxStatus(e,t);w&&(a(w),u(!1)),n.watchTx(e,t,{}).then(R=>{h||(a(R),u(!1))}).catch(R=>{h||(i(R instanceof Error?R:new Error(String(R))),u(!1))});let E=R=>{h||a({...R})};return n.on("statusChange",E),()=>{h=!0,g(!1),n.off("statusChange",E)}},[n,e,t]);let S=l?.status??"idle";return{entry:l,status:S,isLoading:C,isWatching:c,error:r,refresh:f,stopWatching:d}}function js(e){let t=ye(),o=e??t,[s,n]=xt(null),[l,a]=xt(null),[C,u]=xt(null),c=vt(null),g=vt(null),r=vt(null);o&&(g.current||(g.current=p=>{a(p),(!c.current||p.createdAt>=c.current.createdAt)&&(n(p),c.current=p)},o.on("confirmed",g.current)),r.current||(r.current=p=>{u(p),(!c.current||p.createdAt>=c.current.createdAt)&&(n(p),c.current=p)},o.on("failed",r.current)));let i=Gs(()=>{n(null),a(null),u(null),c.current=null},[]);return{lastTx:s,lastConfirmedTx:l,lastFailedTx:C,clear:i}}import{useCallback as Ys}from"react";import{useCallback as zs,useEffect as Wn,useMemo as Qs,useRef as On,useState as At}from"react";import{getResolver as Xs}from"@naculus/connect-appkit-core";function De({input:e,skip:t=!1,resolverConfig:o,scope:s,query:n}){let[l,a]=At(null),[C,u]=At(!1),[c,g]=At(null),r=On(0),i=On(!0);Wn(()=>(i.current=!0,()=>{i.current=!1}),[]);let p=Qs(()=>Xs(o),[o]),f=zs(()=>{let d=e.trim();if(!d||t){r.current+=1,a(null),u(!1),g(null);return}let S=++r.current;u(!0),g(null),n(p,d,s).then(h=>{!i.current||S!==r.current||(a(h),u(!1))}).catch(h=>{!i.current||S!==r.current||(g(h instanceof Error?h:new Error(String(h))),a(null),u(!1))})},[e,t,s,p,n]);return Wn(()=>{f()},[f]),{data:l,isLoading:C,error:c,refetch:f}}function Js(e,t){let o=Ys((s,n,l)=>s.lookupAddress(n,l),[]);return De({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,scope:t?.chainId,query:o})}import{useState as Nn,useCallback as Y,useMemo as Zs,useEffect as _n,useRef as ea}from"react";import{addInAppNotification as ta,channelsUpdate as na,clearOneInAppNotification as ra,createNotificationSettingsStorage as Dn,DEFAULT_NOTIFICATION_SETTINGS as oa,loadNotificationSettings as sa,mutedChainSettings as Mn,saveNotificationSettings as aa,updateNotificationSettings as ia}from"@naculus/connect-appkit-core";import{InAppChannel as la}from"@naculus/connect-core";function ca(e){let t=ea(null);t.current||(t.current=e?.channel??new la);let o=t.current,[s,n]=Nn(()=>o.getHistory()),[l,a]=Nn(()=>oa);_n(()=>{let h=e?.storage??Dn();sa(h).then(w=>{w&&a(w)})},[]),_n(()=>(o.onNotification=h=>{n(w=>[...w,h])},o.restore().then(()=>{n(o.getHistory())}),()=>{o.onNotification=void 0}),[]);let C=Zs(()=>s.filter(h=>!h.read).length,[s]),u=Y(()=>{o.clear(),n([])},[o]),c=Y(h=>{ra(o,h).then(()=>{n(o.getHistory())})},[o]),g=Y(h=>{o.markAsRead(h),n(w=>w.map(E=>E.id===h?{...E,read:!0}:E))},[o]),r=Y(()=>{o.markAllAsRead(),n(h=>h.map(w=>({...w,read:!0})))},[o]),i=Y(h=>{ta(o,h)},[o]),p=Y(h=>{a(w=>{let E=ia(w,h),R=e?.storage??Dn();return aa(R,E),E})},[e?.storage]),f=Y(h=>{p(na(h))},[p]),d=Y(h=>{p(Mn(l,h,!0))},[l.mutedChains,p]),S=Y(h=>{p(Mn(l,h,!1))},[l.mutedChains,p]);return{notifications:s,unreadCount:C,addNotification:i,clear:u,clearOne:c,markAsRead:g,markAllAsRead:r,settings:l,updateSettings:p,setChannels:f,muteChain:d,unmuteChain:S}}import{useCallback as bt,useSyncExternalStore as ua}from"react";var Ln=()=>null,pa=()=>()=>{};function da(){let{client:e}=U(),t=N(e)?.passphraseGate??null,o=ua(t?.subscribe??pa,t?.getSnapshot??Ln,Ln),s=bt(a=>t?.submit(a),[t]),n=bt(()=>t?.cancel(),[t]),l=bt(a=>t?.forget(a),[t]);return{request:o,submit:s,cancel:n,forget:l,isUnlocked:t?.isUnlocked??!1,gate:t}}import{useCallback as ma}from"react";function fa(e,t){let o=ma((s,n)=>s.resolveName(n),[]);return De({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,query:o})}import{assertHexSignature as Rt,bareEvmAddress as ga,buildSmartAccountConfig as Ca,resolveUserOpChain as ha}from"@naculus/connect-appkit-core";import{WalletError as ie}from"@naculus/connect-core";import{useCallback as Bn,useEffect as Hn,useRef as Fn,useState as Se}from"react";async function ya(e,t,o,s,n){let l=N(t);if(!l)throw new ie("wallet_unavailable","Client not initialized");let a=[o,s];if(e.walletType==="eip6963"||e.id?.startsWith("eip6963-")){let{eip6963Connector:C}=await import("@naculus/connector-evm-injected"),u=C.getDiscoveredWallets().find(g=>g.id===e.walletId),c=u?await u.provider.request({method:"personal_sign",params:a}):await C.request({method:"personal_sign",params:a});return Rt(c)}if(e.walletType==="walletconnect")return Rt(await l.connector.request({method:"personal_sign",params:a}));if(e.walletType==="embedded"){let C=l.embeddedConnector;if(!C?.signHash)throw new ie("method_unsupported","This embedded wallet build cannot sign a raw digest. Upgrade @naculus/connector-embedded or pass an explicit signer.");return Rt(await C.signHash(e,o))}throw e.walletType==="passkeys"?new ie("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 ie("method_unsupported",`Raw UserOperation signing is not available for ${e.walletType} on ${n}. Pass a signer that signs the raw 32-byte hash.`)}function Sa(e){let{evmAccount:t}=H(),{session:o,chainId:s,client:n}=U(),[l,a]=Se(null),[C,u]=Se(null),[c,g]=Se(!1),[r,i]=Se(!1),[p,f]=Se(null),d=Fn(0),S=Fn(!1);Hn(()=>()=>{d.current+=1,S.current=!1},[]),Hn(()=>{d.current+=1,S.current=!1,a(null),u(null),g(!1),i(!1),f(null)},[n,s,t,e?.accountType,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.owner,e?.rpcUrl,e?.salt,e?.signerMode,o]);let h=Bn(async(E,R)=>{let A=b=>(f(b),null);if(!e?.rpcUrl)return A(new Error("RPC URL not configured"));if(!e.bundlerUrl)return A(new Error("Bundler URL not configured"));if(!E.length)return A(new Error("At least one call is required"));if(S.current)return A(new Error("A UserOperation is already in progress"));let T=ga(e.owner??t);if(!T)return A(new ie("wallet_unavailable","No EVM account found"));let v;try{v=ha(e.chainId,s)}catch(b){return A(b)}if(!e.signer&&!o)return A(new ie("wallet_unavailable","No active session"));let x=++d.current;S.current=!0,g(!0),i(!0),f(null),a(null),u(null);try{let{SmartAccountManager:b}=await import("@naculus/connect-core"),I=e.signer??(m=>ya(o,n,m,T,v)),W=new b({rpcUrl:e.rpcUrl,bundlerClient:{url:e.bundlerUrl},chainId:v,signer:I,signerMode:e.signer?e.signerMode??"eip191":"raw"}),M=Ca(T,v,e),B=await W.sendUserOperation(M,E,R);return x!==d.current?null:(i(!1),a(B.userOpHash),W.getUserOperationReceipt(B.userOpHash).then(m=>{x===d.current&&u(m)}).catch(()=>{}),B)}catch(b){if(x!==d.current)return null;let I=b instanceof Error?b:new Error("Failed to send UserOperation");return f(I),null}finally{S.current=!1,x===d.current&&(g(!1),i(!1))}},[n,s,t,e,o]),w=Bn(()=>{d.current+=1,a(null),u(null),g(!1),i(!1),f(null)},[]);return{sendUserOp:h,userOpHash:l,receipt:C,isPending:c,isEstimating:r,error:p,reset:w}}import{useSyncExternalStore as Ea,useCallback as Kn}from"react";function wa(e,t){if(!e)return()=>{};let o=()=>t();return e.on("sessionConnected",o),e.on("sessionDisconnected",o),e.on("chainChanged",o),()=>{e.off("sessionConnected",o),e.off("sessionDisconnected",o),e.off("chainChanged",o)}}var Tt=Object.freeze({session:null,chainSessions:[],activeChainId:null,isConnected:!1,connectorId:null}),It=new WeakMap;function ka(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 xa(e){if(!e)return Tt;let t=e.getActiveBundle(),o=It.get(e);if(!t)return o&&o.session===null?o:(It.set(e,Tt),Tt);let s=Array.from(t.chainSessions.values());if(o&&o.session===t.walletSession&&o.activeChainId===t.activeChainId&&ka(o.chainSessions,s))return o;let n={session:t.walletSession,chainSessions:s,activeChainId:t.activeChainId,isConnected:!0,connectorId:t.walletSession.walletType};return It.set(e,n),n}function va(e){let t=U(),o=e??t.sessionManager??null,s=Kn(l=>wa(o,l),[o]),n=Kn(()=>xa(o),[o]);return Ea(s,n)}import{defaultSiwxDomain as Aa,defaultSiwxUri as ba}from"@naculus/connect-appkit-core";import{WalletError as Me}from"@naculus/connect-core";import{createSiwxMessage as Ra,generateNonce as Ta,getBlockchainName as Ia,issueNonce as Ua,nowISO as Pa}from"@naculus/siwx";import{useCallback as qn,useState as Vn}from"react";var Wa=86400;function Ut(){let{session:e,chainId:t,client:o}=U(),[s,n]=Vn(!1),[l,a]=Vn(null),C=qn(()=>a(null),[]);return{signIn:qn(async c=>{if(!e)throw new Me("wallet_unavailable","No active session");let g=c?.chainId??t;if(!g)throw new Me("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let r=oe(e,g);if(!r)throw new Me("wallet_unavailable","No account found");let i=N(o);if(!i)throw new Me("wallet_unavailable","Client not initialized");let{address:p}=r,f=typeof window>"u"?void 0:window.location,d=c?.domain??Aa(f),S=c?.uri??ba(f);n(!0),a(null);try{let h=Ta();await Ua(h);let w=Pa(),E=c?.expirySeconds??Wa,R=new Date(Date.now()+E*1e3).toISOString(),A=Ra({domain:d,address:p,uri:S,version:1,chainId:g,nonce:h,issuedAt:w,expirationTime:R,statement:c?.statement,resources:c?.resources,requestId:c?.requestId}),T=await i.signMessage(e,{message:A,address:p,chainId:g??void 0}),v={message:{raw:A,domain:d,address:p,statement:c?.statement??null,uri:S,version:1,chainId:g,nonce:h,issuedAt:w,blockchain:Ia(g),expirationTime:R,notBefore:null,resources:c?.resources??[],requestId:c?.requestId??null},signature:T};return n(!1),v}catch(h){let w=h instanceof Error?h:new Error("SIWx sign-in failed");throw a(w),n(!1),w}},[e,t,o]),isSigningIn:s,error:l,clearError:C}}import{siwxResultToSession as $n}from"@naculus/connect-appkit-core";import{logger as Pt}from"@naculus/connect-core";import{checkSessionExpired as Gn,createLocalStorageSiwxSessionStorage as Oa}from"@naculus/siwx";import{useCallback as Le,useEffect as jn,useRef as Na,useState as Be}from"react";function _a(e){let{storagePrefix:t="naculus_",autoRestore:o=!0,defaultExpirySeconds:s=86400}=e??{},[n,l]=Be(null),[a,C]=Be(o),[u,c]=Be(!1),[g,r]=Be(null),{session:i,chainId:p}=U(),f=Ut(),d=Na(Oa(`${t}siwx_session`)),S=Le(()=>r(null),[]);jn(()=>{if(!o){C(!1);return}let v=!1;return(async()=>{try{let b=await d.current.get();if(v)return;b?(Pt.info("react/useSIWxSession","Restored persisted SIWx session"),l(b),r(null)):l(null)}catch(x){Pt.warn("react/useSIWxSession","Failed to restore SIWx session:",x),l(null)}finally{v||C(!1)}})(),()=>{v=!0}},[o]),jn(()=>{if(!n?.expiresAt)return;let v=new Date(n.expiresAt).getTime()-Date.now();if(v<=0){l(null);return}let x=setTimeout(()=>{l(b=>b&&b.id===n.id?null:b)},v);return()=>clearTimeout(x)},[n?.id,n?.expiresAt]);let h=Le(async v=>{c(!0),r(null);try{let x={expirySeconds:s,chainId:p??void 0,...v},b=await f.signIn(x),I=$n(b);return await d.current.set(I),l(I),c(!1),I}catch(x){let b=x instanceof Error?x:new Error("SIWx sign-in failed");throw r(b),c(!1),b}},[f,p,s]),w=Le(async()=>{try{await d.current.remove()}catch(v){Pt.warn("react/useSIWxSession","Failed to clear session:",v)}l(null),r(null)},[]),E=Le(async()=>{if(!n)throw new Error("No active session to refresh");c(!0),r(null);try{let v=await f.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}),x={...$n(v),id:n.id,refreshedAt:new Date().toISOString()};return await d.current.set(x),l(x),c(!1),x}catch(v){let x=v instanceof Error?v:new Error("Session refresh failed");throw r(x),c(!1),x}},[n,f,s]),R=n!==null&&!Gn(n),A=Gn(n),T=n?.expiresAt?Math.max(0,new Date(n.expiresAt).getTime()-Date.now()):null;return{session:R?n:null,isAuthenticated:R,isRestoring:a,isSigningIn:u,isExpired:A,timeUntilExpiry:T,signIn:h,signOut:w,refresh:E,error:g,clearError:S}}import{defaultSiwxDomain as Da,defaultSiwxUri as Ma}from"@naculus/connect-appkit-core";import{WalletError as He}from"@naculus/connect-core";import{createSiwxMessage as La,generateNonce as Ba,getBlockchainName as Ha,issueNonce as Fa,nowISO as Ka}from"@naculus/siwx";import{useCallback as zn,useState as Wt}from"react";function Ee(){let{session:e,chainId:t,client:o}=U(),[s,n]=Wt(!1),[l,a]=Wt(null),[C,u]=Wt(null),c=zn(()=>u(null),[]);return{signIn:zn(async r=>{if(!e)throw new He("wallet_unavailable","No active session");let i=r?.chainId??t;if(!i)throw new He("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let p=oe(e,i);if(!p)throw new He("wallet_unavailable","No account found");let f=N(o);if(!f)throw new He("wallet_unavailable","Client not initialized");let{address:d}=p,S=typeof window>"u"?void 0:window.location,h=r?.domain??Da(S),w=r?.uri??Ma(S);n(!0),u(null);try{let E=Ba();await Fa(E);let R=Ka(),A=La({domain:h,address:d,uri:w,version:1,chainId:i,nonce:E,issuedAt:R,statement:r?.statement,expirationTime:r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():void 0,resources:r?.resources,requestId:r?.requestId}),T=await f.signMessage(e,{message:A,address:d,chainId:i??void 0}),v=r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():null,x={message:{raw:A,domain:h,address:d,statement:r?.statement??null,uri:w,version:1,chainId:i,nonce:E,issuedAt:R,blockchain:Ha(i),expirationTime:v,notBefore:null,resources:r?.resources??[],requestId:r?.requestId??null},signature:T};return a(x),x}catch(E){let R=E instanceof Error?E:new Error("SIWx sign-in failed");throw u(R),R}finally{n(!1)}},[e,t,o]),isSigningIn:s,result:l,error:C,clearError:c}}import{WalletError as Ot}from"@naculus/connect-core";import{useCallback as Qn}from"react";function qa(){let{session:e,chainId:t}=U();return Qn(o=>{if(!e)throw new Ot("wallet_unavailable","No active session");let s=o??t;if(s&&!s.startsWith("eip155:"))throw new Ot("namespace_mismatch",`Ethereum SIWx requires an eip155 chain, received ${s}`);let n=e.namespaces.eip155;if(!n||n.accounts.length===0)throw new Ot("namespace_mismatch","No EVM (eip155) accounts found in session")},[e,t])}function Va(){let e=qa(),t=Ee();return{signIn:Qn(async s=>(e(s?.chainId),t.signIn(s)),[e,t.signIn]),isSigningIn:t.isSigningIn,result:t.result,error:t.error,clearError:t.clearError}}import{resolveSimulationEndpoint as $a}from"@naculus/connect-appkit-core";import{SimulationManager as Ga}from"@naculus/wallet-engine";import{useCallback as Nt,useRef as ja,useState as _t}from"react";function za(e){let t=e?.rpcUrl,o=e?.chainId,s=ja(null),n=Nt(()=>(s.current||(s.current=new Ga({enabled:!0,rpcUrl:t,autoSimulate:!1})),s.current),[t]),[l,a]=_t(null),[C,u]=_t(!1),[c,g]=_t(null),r=Nt(async(p,f,d,S,h)=>{u(!0),g(null);try{let w=n(),E=$a(h?.chainId,o,h?.rpcUrl,t),R=await w.simulateERC20Transfer(p,f,d,S,E.chainId,h?.decimals,E.rpcUrl);return a(R),R}catch(w){let E=w instanceof Error?w:new Error(String(w));throw g(E),E}finally{u(!1)}},[t,o,n]),i=Nt(()=>{a(null),g(null),u(!1)},[]);return{result:l,loading:C,error:c,simulate:r,reset:i}}import{isSiwxExpired as Qa,isSiwxNotBeforeValid as Xa}from"@naculus/connect-appkit-core";import{LocalStorageAdapter as Ya,logger as Fe}from"@naculus/connect-core";import{useCallback as Dt,useEffect as Ja,useRef as Za,useState as Ke}from"react";var qe="siwx_auth";function ei(e){return new Ya(e)}function ti(e){let{storagePrefix:t="naculus_",autoRestore:o=!0}=e??{},[s,n]=Ke(null),[l,a]=Ke(o),[C,u]=Ke(!1),[c,g]=Ke(null),r=Ee(),i=Za(ei(t)),p=Dt(()=>g(null),[]);Ja(()=>{if(!o){a(!1);return}let S=!1;return(async()=>{try{let h=i.current,w=await h.get(qe);if(S)return;w&&!Qa(w,new Date)&&Xa(w,new Date)?(Fe.info("react/useSiwxAuthSession","Restored persisted SIWx auth session"),n(w),g(null)):w&&(Fe.info("react/useSiwxAuthSession","Persisted SIWx auth expired, clearing"),await h.remove(qe))}catch(h){Fe.warn("react/useSiwxAuthSession","Failed to restore SIWx auth:",h)}finally{S||a(!1)}})(),()=>{S=!0}},[o]);let f=Dt(async S=>{u(!0),g(null);try{let h=await r.signIn(S);return await i.current.set(qe,h),n(h),u(!1),h}catch(h){let w=h instanceof Error?h:new Error("SIWx sign-in failed");throw g(w),u(!1),w}},[r]),d=Dt(async()=>{try{await i.current.remove(qe)}catch(S){Fe.warn("react/useSiwxAuthSession","Failed to clear SIWx auth:",S)}n(null),g(null)},[]);return{isSignedIn:s!==null,isRestoring:l,siwxResult:s,isSigningIn:C,error:c,signIn:f,signOut:d,clearError:p}}import{bareEvmAddress as ni,buildSmartAccountConfig as ri,resolveEvmChainId as Xn}from"@naculus/connect-appkit-core";import{WalletError as Zn}from"@naculus/connect-core";import{useCallback as ne,useEffect as Yn,useRef as Mt,useState as we}from"react";function Jn(e){return new Zn("wallet_unavailable",e)}function oi(e){let{evmAccount:t}=H(),{session:o,chainId:s,client:n}=U(),[l,a]=we(null),[C,u]=we(!1),[c,g]=we(null),[r,i]=we(!1),[p,f]=we(null),d=Mt(null),S=Mt(0),h=Mt(!1);Yn(()=>{if(d.current=null,!e?.rpcUrl)return;let b=!1;return import("@naculus/connect-core").then(({SmartAccountManager:I})=>{if(b)return;let W=Xn(e.chainId,s);W&&(d.current=new I({rpcUrl:e.rpcUrl,chainId:W,bundlerClient:{url:e.bundlerUrl??""}}))}).catch(I=>{b||f(I instanceof Error?I:new Error("Failed to load account-abstraction module"))}),()=>{b=!0}},[s,e?.rpcUrl,e?.bundlerUrl,e?.chainId]),Yn(()=>{S.current+=1,h.current=!1,a(null),u(!1),g(null),i(!1),f(null)},[t,s,e?.rpcUrl,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.accountType,e?.salt]);let w=ne(()=>{let b=ni(t);if(!b||!d.current)return null;let I=Xn(e?.chainId,s);return I?ri(b,I,{accountType:e?.accountType,entryPoint:e?.entryPoint,salt:e?.salt}):null},[t,s,e?.accountType,e?.chainId,e?.entryPoint,e?.salt]),E=ne(b=>(f(b),null),[]),R=ne(()=>h.current?null:(h.current=!0,S.current),[]),A=ne(b=>{S.current===b&&(h.current=!1)},[]),T=ne(async()=>{let b=w();if(!b||!d.current)return E(new Error("Smart account not configured"));let I=R();if(I===null)return E(new Error("Smart account operation already in progress"));i(!0),f(null);try{let M=await d.current.createAccount(b);return S.current!==I?null:(a(M.address),u(M.isDeployed),g(M),M)}catch(W){if(S.current!==I)return null;let M=W instanceof Error?W:new Error("Failed to create smart account");return f(M),null}finally{S.current===I&&i(!1),A(I)}},[R,E,A,w]),v=ne(async()=>{let b=w();if(!b||!d.current)return E(new Error("Smart account not configured"));if(!o)return E(Jn("No active session"));let I=N(n);if(!I)return E(Jn("Client not initialized"));if(s&&s!==b.chainId)return E(new Zn("chain_mismatch",`Connected chain ${s} does not match smart account chain ${b.chainId}.`));let W=R();if(W===null)return E(new Error("Smart account operation already in progress"));i(!0),f(null);try{let M=d.current,B=await M.createAccount(b);if(S.current!==W)return null;if(B.isDeployed)return a(B.address),u(!0),g(B),B.address;let m=await M.getDeployCallData(b),y=await I.sendTransaction(o,{transaction:{to:m.to,data:m.data,value:m.value.toString()},chainId:b.chainId});if(S.current!==W)return null;let k=await M.createAccount(b);return a(k.address),u(k.isDeployed),g(k),y}catch(M){if(S.current!==W)return null;let B=M instanceof Error?M:new Error("Failed to deploy smart account");return f(B),null}finally{S.current===W&&i(!1),A(W)}},[n,s,R,E,A,w,o]),x=ne(async()=>{let b=w();if(!b||!d.current)return null;let I=S.current;try{let W=await d.current.getAccountAddress(b);return S.current!==I?null:(a(W),W)}catch(W){return S.current!==I||f(W instanceof Error?W:new Error("Failed to get smart account address")),null}},[w]);return{address:l,isDeployed:C,accountInfo:c,isLoading:r,error:p,createWallet:T,deployWallet:v,getAddress:x}}import{useMemo as si}from"react";function Lt(){let{accounts:e,isConnected:t}=U();return si(()=>{if(!t)return{address:null,caip10:null,chainId:null,isConnected:!1};let o=e.find(a=>a.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,l=s.length>=3?s.slice(0,-1).join(":"):null;return{address:n,caip10:o,chainId:l,isConnected:t}},[e,t])}import{useCallback as ai,useEffect as er,useRef as ii,useState as Bt}from"react";import{getSolanaBalance as li}from"@naculus/connect-core";function ci(e={}){let{client:t}=U(),{address:o}=Lt(),s=e.address??o,n=e.rpcUrl??N(t)?.solanaRpcUrl??null,[l,a]=Bt(null),[C,u]=Bt(!1),[c,g]=Bt(null),r=ii(0),i=ai(async()=>{if(!s||!n){a(null);return}let p=++r.current;u(!0),g(null);try{let f=await li(n,s);if(p!==r.current)return;a(f)}catch(f){if(p!==r.current)return;a(null),g(f instanceof Error?f:new Error("Balance read failed"))}finally{p===r.current&&u(!1)}},[s,n]);return er(()=>{i()},[i]),er(()=>{if(!e.refreshInterval||e.refreshInterval<=0)return;let p=setInterval(()=>{i()},e.refreshInterval);return()=>clearInterval(p)},[e.refreshInterval,i]),{balance:l,isFetching:C,error:c,isConfigured:!!n,refetch:i}}import{readSolanaRoles as ui}from"@naculus/connect-appkit-core";import{useMemo as pi}from"react";function di(){let{client:e,session:t,accounts:o}=U();return pi(()=>{let s=N(e)?.solanaConnector,{roles:n,absence:l}=ui(s,t);return{roles:n,absence:l,identity:n?.identity??null,signer:n?.signer??null,payer:n?.payer??null}},[e,t,o])}import{WalletError as tr}from"@naculus/connect-core";import{useCallback as Ht,useState as Ft}from"react";import{getSignatureStatus as mi}from"@naculus/connect-core";function fi(){let{client:e,session:t}=U(),[o,s]=Ft(!1),[n,l]=Ft(!1),[a,C]=Ft(null),u=()=>{let i=N(e);if(!i||!t)throw new tr("wallet_unavailable","No connected wallet.");return i},c=Ht(async i=>{s(!0),C(null);try{return await u().signTransaction(t,{transaction:i})}catch(p){let f=p instanceof Error?p:new Error("Signing failed");throw C(f),f}finally{s(!1)}},[e,t]),g=Ht(async i=>{l(!0),C(null);try{return await u().sendTransaction(t,{transaction:i})}catch(p){let f=p instanceof Error?p:new Error("Send failed");throw C(f),f}finally{l(!1)}},[e,t]),r=Ht(async i=>{let p=N(e)?.solanaRpcUrl;if(!p)throw new tr("no_rpc","Set solanaRpcUrl on the client to read a signature's status.");return mi(p,i)},[e]);return{signTransaction:c,sendTransaction:g,getStatus:r,isSigning:o,isSending:n,error:a,reset:()=>C(null)}}import{useCallback as nr,useState as rr}from"react";import{toChainSwitchError as gi}from"@naculus/connect-appkit-core";function Ci(){let{switchChain:e,chainId:t}=U(),[o,s]=rr(!1),[n,l]=rr(null),a=nr(async u=>{s(!0),l(null);try{await e(u)}catch(c){let g=gi(c);throw l(g),g}finally{s(!1)}},[e]),C=nr(()=>{l(null)},[]);return{switchChain:a,isSwitching:o,currentChainId:t,error:n,clearError:C}}import{chainNumber as hi,resolveChain as yi,toViemChain as Si}from"@naculus/connect-appkit-core";import{useState as Ve,useEffect as Kt,useCallback as or,useMemo as qt,useRef as Ei}from"react";import{createPublicClient as wi,http as ki,formatUnits as xi}from"viem";function vi(e){let{evmAccount:t,isConnected:o}=H(),{chainId:s,chains:n}=U(),[l,a]=Ve([]),[C,u]=Ve(!1),[c,g]=Ve(null),{tokens:r,refreshInterval:i}=e,p=Ei(null),f=qt(()=>r.map(v=>v.address.toLowerCase()+"|"+v.decimals+"|"+v.symbol).join(","),[r]),d=qt(()=>yi(n,s),[s,n]),S=d?hi(d):null,h=qt(()=>d?Si(d,S):null,[d,S]),[w,E]=Ve(null);Kt(()=>{if(!h||!d?.rpcUrl){E(null);return}let v=wi({transport:ki(d.rpcUrl),chain:h});E(v)},[d,h]);let R=[{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"balance",type:"uint256"}]}],A=or(async()=>{if(!t||!w||r.length===0){a([]);return}u(!0),g(null);try{let v=t.includes(":")?t.split(":").pop():t,b=(await Promise.allSettled(r.map(async I=>{try{let W=await w.readContract({address:I.address,abi:R,functionName:"balanceOf",args:[v]});return{address:I.address,symbol:I.symbol,decimals:I.decimals,name:I.name,balance:W.toString(),formatted:xi(W,I.decimals)}}catch{return{address:I.address,symbol:I.symbol,decimals:I.decimals,name:I.name,balance:null,formatted:null}}}))).map(I=>I.status==="fulfilled"?I.value:{address:"",symbol:"?",decimals:0,balance:null,formatted:null});a(b)}catch(v){g(v instanceof Error?v:new Error("Failed to fetch token balances"))}finally{u(!1)}},[t,w,f]);Kt(()=>{o&&t&&r.length>0&&A()},[o,t,f,A]),Kt(()=>(i&&i>0&&o&&t&&r.length>0&&(p.current=setInterval(A,i)),()=>{p.current&&(clearInterval(p.current),p.current=null)}),[i,o,t,f,A]);let T=or(v=>l.find(x=>x.address.toLowerCase()===v.toLowerCase()),[l]);return{tokenBalances:l,isLoading:C,error:c,refetch:A,getTokenBalance:T,chain:d}}import{useState as Vt,useEffect as sr,useCallback as Ai,useRef as bi}from"react";function Ri(e,t,o){let s=ye(),n=o??s,[l,a]=Vt([]),[C,u]=Vt(!1),[c,g]=Vt(null),r=bi(0),i=Ai(async()=>{if(n){u(!0),g(null),r.current++;try{let f=await n.getTxHistory(e,t);a(f)}catch(f){g(f instanceof Error?f:new Error(String(f)))}finally{u(!1)}}},[n,e,t]);sr(()=>{i().catch(()=>{})},[i]),sr(()=>{if(!n)return;let f=()=>{i().catch(()=>{})};return n.on("statusChange",f),()=>{n.off("statusChange",f)}},[n,i]);let p={pending:l.filter(f=>f.status==="pending").length,confirmed:l.filter(f=>f.status==="confirmed").length,failed:l.filter(f=>f.status==="failed").length};return{entries:l,isLoading:C,error:c,refresh:i,summary:p}}import{fetchUserOperationReceipt as Ti,InvalidUserOperationReceiptError as Ii}from"@naculus/connect-appkit-core";import{useCallback as ke,useEffect as ar,useRef as le,useState as re}from"react";function Ui(e){let t=e?.bundlerUrl,o=e?.pollInterval??2e3,s=e?.maxRetries??30,[n,l]=re("idle"),[a,C]=re(null),[u,c]=re(e?.userOpHash??null),[g,r]=re(null),[i,p]=re(!1),[f,d]=re(0),S=le(0),[h,w]=re(0),E=le(null),R=le(null),A=le(0),T=le(0),v=le(null),x=ke(()=>{E.current&&(clearInterval(E.current),E.current=null),R.current&&(clearTimeout(R.current),R.current=null)},[]),b=ke(async(B,m)=>{if(!t||m!==A.current)return;let y=T.current+1;T.current=y,d(y);let k=new AbortController;v.current=k;let P=L=>{m===A.current&&(l("not_found"),p(!1),x(),r(L))},O=L=>{if(m===A.current){if(y<=s){R.current=setTimeout(()=>{b(B,m)},o);return}P(L)}};try{let L=await Ti(t,B,k.signal);if(m!==A.current)return;if(L){C(L),l(L.success?"confirmed":"failed"),p(!1),x();return}l("pending"),O(new Error("UserOperation not included after maximum retries"))}catch(L){if(m!==A.current||k.signal.aborted)return;let te=L instanceof Error?L:new Error("Unknown bundler response failure");if(te instanceof Ii){P(te);return}O(new Error(`UserOperation status unavailable after ${y} attempt${y===1?"":"s"}: ${te.message}`))}finally{v.current===k&&(v.current=null)}},[t,o,s,x]),I=ke(B=>{A.current+=1;let m=A.current;if(v.current?.abort(),v.current=null,x(),c(B),C(null),r(null),T.current=0,d(0),w(0),S.current=Date.now(),!t){l("not_found"),p(!1),r(new Error("Bundler URL not configured"));return}l("pending"),p(!0),E.current=setInterval(()=>{w(Date.now()-S.current)},1e3),b(B,m)},[t,x,b]),W=ke(()=>{A.current+=1,v.current?.abort(),v.current=null,x(),p(!1)},[x]),M=ke(()=>{A.current+=1,v.current?.abort(),v.current=null,x(),c(null),l("idle"),C(null),r(null),p(!1),T.current=0,d(0),w(0)},[x]);return ar(()=>{e?.userOpHash&&e?.autoStart!==!1&&I(e.userOpHash)},[]),ar(()=>()=>{A.current+=1,v.current?.abort(),v.current=null,x()},[x]),{status:n,receipt:a,userOpHash:u,error:g,isPolling:i,elapsedMs:h,attempts:f,start:I,stop:W,reset:M}}import{validateDestination as _i}from"@naculus/connect-appkit-core";import{useMemo as Di}from"react";var Pi={"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."},Wi={"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"},ir={en:Pi,zh:Wi},$t="en";function Oi(e){$t=e}function Ni(){return $t}function Gt(e){return ir[$t][e]??ir.en[e]??e}function lr(e){let{isValid:t,level:o,issue:s}=_i(e);return{isValid:t,level:o,warning:s?Gt(`address.${s}`):null}}function Mi({address:e}){return{validation:Di(()=>lr(e),[e])}}function Li(){let{status:e,session:t,accounts:o,chainId:s,error:n,connect:l,disconnect:a,reconnect:C,switchChain:u}=U(),c=e==="connected",g=e==="connecting",r=e==="reconnecting",i=o[0]??null;return{status:e,session:t,accounts:o,chainId:s,error:n,isConnected:c,isConnecting:g,isReconnecting:r,isDisconnected:e==="disconnected",currentAccount:i,connect:l,disconnect:a,reconnect:C,switchChain:u}}import{useCallback as zt,useMemo as pr}from"react";var cr={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"},ur={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."},xe="Something went wrong",ve="An unexpected error occurred. Please try again. If the problem persists, check your connection and wallet configuration.";function Ae(e){if(!e)return{title:xe,description:ve};let t=e;if(t.name==="WalletError"&&t.code){let o=t.code,s=cr[o]??xe,n=ur[o]??t.message??ve;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:xe,description:o||ve}}return typeof e=="string"?{title:xe,description:e||ve}:{title:xe,description:ve}}function jt(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 Bi(){let{error:e,clearError:t}=U(),o=pr(()=>e?Ae(e):null,[e]),s=pr(()=>e?jt(e):!1,[e]),n=zt(()=>{t()},[t]),l=zt(C=>Ae(C),[]),a=zt(C=>async()=>{try{return await C()}catch(u){let c=Ae(u);if(u instanceof Error){let g=u;try{g.title=c.title,g.friendlyMessage=c.description,g.code===void 0&&c.code!==void 0&&(g.code=c.code)}catch{}throw g}throw Object.assign(new Error(c.description,{cause:u}),{title:c.title,code:c.code,friendlyMessage:c.description})}},[]);return{error:e,friendlyError:o,clearError:n,isRetryable:s,formatError:l,wrapAsync:a}}import{useState as $e,useEffect as Hi,useCallback as dr,useRef as Fi}from"react";import{TokenListManager as Ki}from"@naculus/connect-core";import{eip155ChainIdToNumber as mr}from"@naculus/connect-appkit-core";function Ge(e,t){let o=Fi(null),[s,n]=$e([]),[l,a]=$e(t?.autoLoad!==!1),[C,u]=$e(!1),[c,g]=$e(null);if(!o.current){let p={};t?.sources&&(p.sources=t.sources),o.current=new Ki(p)}let r=dr(async()=>{let p=o.current;if(p){a(!0),g(null);try{await p.load();let f=e?mr(e):void 0,d=p.getTokens(f!==void 0?{chainId:f}:void 0);n(d),u(!0)}catch(f){g(f instanceof Error?f:new Error(String(f)))}finally{a(!1)}}},[e]),i=dr(async()=>{let p=o.current;if(p){a(!0),g(null);try{await p.refresh();let f=e?mr(e):void 0,d=p.getTokens(f!==void 0?{chainId:f}:void 0);n(d),u(!0)}catch(f){g(f instanceof Error?f:new Error(String(f)))}finally{a(!1)}}},[e]);return Hi(()=>{t?.autoLoad!==!1&&r()},[r,t?.autoLoad]),{tokens:s,isLoading:l,isLoaded:C,error:c,refetch:i}}import{useState as gr,useEffect as zi,useRef as Qi}from"react";import{TokenListManager as Xi}from"@naculus/connect-core";import{ETHEREUM_MAINNET_TOKENS as qi,POLYGON_TOKENS as Vi,OPTIMISM_TOKENS as $i,ARBITRUM_TOKENS as Gi,BASE_TOKENS as ji}from"@naculus/connect-core";function fr(){return[{name:"built-in",tokens:[...qi,...Vi,...$i,...Gi,...ji],enabled:!0},{name:"uniswap-default",url:"https://tokens.uniswap.org",enabled:!0,refreshInterval:1440*60*1e3}]}import{eip155ChainIdToNumber as Yi}from"@naculus/connect-appkit-core";var Ji=300,je=null;function Zi(){return je||(je=new Xi({sources:fr()}),je.load().catch(()=>{})),je}function ze(e,t){let[o,s]=gr({exact:[],fuzzy:[],hasMore:!1}),[n,l]=gr(!1),a=Qi(null),C=e.trim();return zi(()=>{if(!C){s({exact:[],fuzzy:[],hasMore:!1}),l(!1);return}return a.current&&clearTimeout(a.current),l(!0),a.current=setTimeout(()=>{let u=Zi(),c=t?Yi(t):void 0,g=u.search(C,{chainId:c,limit:20});s(g),l(!1)},Ji),()=>{a.current&&clearTimeout(a.current)}},[C,t]),{results:o,isSearching:n}}import Qt,{useCallback as el}from"react";import{Fragment as tl,jsx as $,jsxs as j}from"react/jsx-runtime";function Cr({chainId:e,onSelect:t,onClose:o,options:s}){let[n,l]=Qt.useState(""),{tokens:a,isLoading:C,error:u}=Ge(e),{results:c,isSearching:g}=ze(n,n?e:void 0),r=s?.showRecommendations??!0,i=Qt.useMemo(()=>{if(n.trim()){let S=[...c.exact,...c.fuzzy].map(h=>h.token);return s?.filter?S.filter(s.filter):S}let d=a;return s?.filter?d.filter(s.filter):d},[n,c,a,s?.filter]),p=Qt.useMemo(()=>!r||n.trim()?[]:a.slice(0,6),[a,r,n]),f=el(d=>{t(d),o()},[t,o]);return j("div",{style:{background:"hsl(var(--background))",borderRadius:"12px",padding:"16px",color:"hsl(var(--foreground))",minWidth:"320px",maxWidth:"400px",fontFamily:"system-ui, sans-serif"},children:[j("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[$("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Select Token"}),$("button",{onClick:o,style:{background:"none",border:"none",color:"hsl(var(--muted-foreground))",cursor:"pointer",fontSize:"18px",padding:"4px 8px"},children:"\u2715"})]}),$("input",{type:"text",placeholder:"Search token name or paste address",value:n,onChange:d=>l(d.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}),C&&!g&&$("div",{style:{textAlign:"center",padding:"20px",color:"hsl(var(--muted-foreground))"},children:"Loading tokens..."}),u&&j("div",{style:{textAlign:"center",padding:"12px",color:"hsl(var(--destructive))",fontSize:"13px"},children:["Error: ",u.message]}),r&&p.length>0&&!n.trim()&&j("div",{style:{marginBottom:"12px"},children:[$("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},children:"Popular"}),$("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:p.map(d=>j("button",{onClick:()=>f(d),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:[d.logoURI?$("img",{src:d.logoURI,alt:"",style:{width:"16px",height:"16px",borderRadius:"50%"},onError:S=>{S.target.style.display="none"}}):null,d.symbol]},`${d.chainId}:${d.address}`))})]}),n.trim()&&!C&&$("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",marginBottom:"8px"},children:i.length>0?j(tl,{children:[c.exact.length," exact, ",c.fuzzy.length," fuzzy",c.hasMore?" (more available)":""]}):"No results found"}),$("div",{style:{maxHeight:"320px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"2px"},children:i.map(d=>j("button",{onClick:()=>f(d),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:S=>{S.target.style.background="hsl(var(--card))"},onMouseLeave:S=>{S.target.style.background="transparent"},children:[$("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:d.logoURI?$("img",{src:d.logoURI,alt:d.symbol,style:{width:"100%",height:"100%"},onError:S=>{let h=S.target;h.style.display="none",h.parentElement.textContent=d.symbol.slice(0,2)}}):d.symbol.slice(0,2)}),j("div",{style:{flex:1,minWidth:0},children:[$("div",{style:{fontWeight:600,fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.symbol}),$("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.name})]}),j("div",{style:{fontSize:"11px",color:"#666",textAlign:"right",flexShrink:0},children:[j("div",{children:[d.decimals," decimals"]}),j("div",{children:["Chain ",d.chainId]})]})]},`${d.chainId}:${d.address}`))})]})}import{createComponent as _}from"@stencil/react-output-target/runtime";import D from"react";import{AppkitAccordion as nl,defineCustomElement as rl}from"@naculus/connect-appkit-wc/dist/components/appkit-accordion.js";import{AppkitAccountButton as ol,defineCustomElement as sl}from"@naculus/connect-appkit-wc/dist/components/appkit-account-button.js";import{AppkitAlertDialog as al,defineCustomElement as il}from"@naculus/connect-appkit-wc/dist/components/appkit-alert-dialog.js";import{AppkitAvatar as ll,defineCustomElement as cl}from"@naculus/connect-appkit-wc/dist/components/appkit-avatar.js";import{AppkitBadge as ul,defineCustomElement as pl}from"@naculus/connect-appkit-wc/dist/components/appkit-badge.js";import{AppkitButton as dl,defineCustomElement as ml}from"@naculus/connect-appkit-wc/dist/components/appkit-button.js";import{AppkitCardContent as fl,defineCustomElement as gl}from"@naculus/connect-appkit-wc/dist/components/appkit-card-content.js";import{AppkitCardDescription as Cl,defineCustomElement as hl}from"@naculus/connect-appkit-wc/dist/components/appkit-card-description.js";import{AppkitCardFooter as yl,defineCustomElement as Sl}from"@naculus/connect-appkit-wc/dist/components/appkit-card-footer.js";import{AppkitCardHeader as El,defineCustomElement as wl}from"@naculus/connect-appkit-wc/dist/components/appkit-card-header.js";import{AppkitCardTitle as kl,defineCustomElement as xl}from"@naculus/connect-appkit-wc/dist/components/appkit-card-title.js";import{AppkitCard as vl,defineCustomElement as Al}from"@naculus/connect-appkit-wc/dist/components/appkit-card.js";import{AppkitCheckbox as bl,defineCustomElement as Rl}from"@naculus/connect-appkit-wc/dist/components/appkit-checkbox.js";import{AppkitCollapsible as Tl,defineCustomElement as Il}from"@naculus/connect-appkit-wc/dist/components/appkit-collapsible.js";import{AppkitConnectButton as Ul,defineCustomElement as Pl}from"@naculus/connect-appkit-wc/dist/components/appkit-connect-button.js";import{AppkitDialog as Wl,defineCustomElement as Ol}from"@naculus/connect-appkit-wc/dist/components/appkit-dialog.js";import{AppkitDropdownMenu as Nl,defineCustomElement as _l}from"@naculus/connect-appkit-wc/dist/components/appkit-dropdown-menu.js";import{AppkitInput as Dl,defineCustomElement as Ml}from"@naculus/connect-appkit-wc/dist/components/appkit-input.js";import{AppkitPopover as Ll,defineCustomElement as Bl}from"@naculus/connect-appkit-wc/dist/components/appkit-popover.js";import{AppkitProgress as Hl,defineCustomElement as Fl}from"@naculus/connect-appkit-wc/dist/components/appkit-progress.js";import{AppkitScrollArea as Kl,defineCustomElement as ql}from"@naculus/connect-appkit-wc/dist/components/appkit-scroll-area.js";import{AppkitSelect as Vl,defineCustomElement as $l}from"@naculus/connect-appkit-wc/dist/components/appkit-select.js";import{AppkitSeparator as Gl,defineCustomElement as jl}from"@naculus/connect-appkit-wc/dist/components/appkit-separator.js";import{AppkitSkeleton as zl,defineCustomElement as Ql}from"@naculus/connect-appkit-wc/dist/components/appkit-skeleton.js";import{AppkitSwitch as Xl,defineCustomElement as Yl}from"@naculus/connect-appkit-wc/dist/components/appkit-switch.js";import{AppkitTabs as Jl,defineCustomElement as Zl}from"@naculus/connect-appkit-wc/dist/components/appkit-tabs.js";import{AppkitToggleGroup as ec,defineCustomElement as tc}from"@naculus/connect-appkit-wc/dist/components/appkit-toggle-group.js";import{AppkitTooltip as nc,defineCustomElement as rc}from"@naculus/connect-appkit-wc/dist/components/appkit-tooltip.js";var oc=_({tagName:"appkit-accordion",elementClass:nl,react:D,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:rl}),sc=_({tagName:"appkit-account-button",elementClass:ol,react:D,events:{},defineCustomElement:sl}),ac=_({tagName:"appkit-alert-dialog",elementClass:al,react:D,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:il}),ic=_({tagName:"appkit-avatar",elementClass:ll,react:D,events:{},defineCustomElement:cl}),lc=_({tagName:"appkit-badge",elementClass:ul,react:D,events:{},defineCustomElement:pl}),cc=_({tagName:"appkit-button",elementClass:dl,react:D,events:{},defineCustomElement:ml}),uc=_({tagName:"appkit-card",elementClass:vl,react:D,events:{},defineCustomElement:Al}),pc=_({tagName:"appkit-card-content",elementClass:fl,react:D,events:{},defineCustomElement:gl}),dc=_({tagName:"appkit-card-description",elementClass:Cl,react:D,events:{},defineCustomElement:hl}),mc=_({tagName:"appkit-card-footer",elementClass:yl,react:D,events:{},defineCustomElement:Sl}),fc=_({tagName:"appkit-card-header",elementClass:El,react:D,events:{},defineCustomElement:wl}),gc=_({tagName:"appkit-card-title",elementClass:kl,react:D,events:{},defineCustomElement:xl}),Cc=_({tagName:"appkit-checkbox",elementClass:bl,react:D,events:{onAppkitChange:"appkitChange"},defineCustomElement:Rl}),hc=_({tagName:"appkit-collapsible",elementClass:Tl,react:D,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:Il}),yc=_({tagName:"appkit-connect-button",elementClass:Ul,react:D,events:{onAppkitConnect:"appkitConnect",onAppkitDisconnect:"appkitDisconnect",onAppkitStartPairing:"appkitStartPairing",onAppkitRetry:"appkitRetry",onAppkitCancelPairing:"appkitCancelPairing",onAppkitMobileDeepLink:"appkitMobileDeepLink",onAppkitCopyAddress:"appkitCopyAddress"},defineCustomElement:Pl}),Sc=_({tagName:"appkit-dialog",elementClass:Wl,react:D,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Ol}),Ec=_({tagName:"appkit-dropdown-menu",elementClass:Nl,react:D,events:{onAppkitSelect:"appkitSelect"},defineCustomElement:_l}),wc=_({tagName:"appkit-input",elementClass:Dl,react:D,events:{onAppkitChange:"appkitChange"},defineCustomElement:Ml}),kc=_({tagName:"appkit-popover",elementClass:Ll,react:D,events:{onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Bl}),xc=_({tagName:"appkit-progress",elementClass:Hl,react:D,events:{},defineCustomElement:Fl}),vc=_({tagName:"appkit-scroll-area",elementClass:Kl,react:D,events:{},defineCustomElement:ql}),Ac=_({tagName:"appkit-select",elementClass:Vl,react:D,events:{onAppkitChange:"appkitChange"},defineCustomElement:$l}),bc=_({tagName:"appkit-separator",elementClass:Gl,react:D,events:{},defineCustomElement:jl}),Rc=_({tagName:"appkit-skeleton",elementClass:zl,react:D,events:{},defineCustomElement:Ql}),Tc=_({tagName:"appkit-switch",elementClass:Xl,react:D,events:{onAppkitChange:"appkitChange"},defineCustomElement:Yl}),Ic=_({tagName:"appkit-tabs",elementClass:Jl,react:D,events:{onAppkitTabChange:"appkitTabChange"},defineCustomElement:Zl}),Uc=_({tagName:"appkit-toggle-group",elementClass:ec,react:D,events:{onAppkitChange:"appkitChange"},defineCustomElement:tc}),Pc=_({tagName:"appkit-tooltip",elementClass:nc,react:D,events:{},defineCustomElement:rc});export{oc as AppkitAccordion,sc as AppkitAccountButton,ac as AppkitAlertDialog,ic as AppkitAvatar,lc as AppkitBadge,cc as AppkitButton,uc as AppkitCard,pc as AppkitCardContent,dc as AppkitCardDescription,mc as AppkitCardFooter,fc as AppkitCardHeader,gc as AppkitCardTitle,Cc as AppkitCheckbox,hc as AppkitCollapsible,yc as AppkitConnectButton,Sc as AppkitDialog,Ec as AppkitDropdownMenu,wc as AppkitInput,kc as AppkitPopover,xc as AppkitProgress,vc as AppkitScrollArea,Ac as AppkitSelect,bc as AppkitSeparator,Rc as AppkitSkeleton,Tc as AppkitSwitch,Ic as AppkitTabs,Uc as AppkitToggleGroup,Pc as AppkitTooltip,ln as DEFAULT_EVM_CHAINS,uC as LAMPORTS_PER_SOL,pC as PassphraseCancelledError,dC as PassphraseGate,fC as SolanaRpcError,Cr as TokenSelector,Pn as TxMonitorContext,ur as WALLET_ERROR_DESCRIPTIONS,cr as WALLET_ERROR_TITLES,jr as Web3ConnectProvider,ot as Web3Context,Xo as buildDelegationPolicyMessage,vr as clearClient,tt as createClient,aC as formatSol,Dr as getChainById,nt as getClient,rt as getDefaultChains,iC as getLatestBlockhash,Ni as getLocale,lC as getSignatureStatus,cC as getSolanaBalance,Ae as getUserFriendlyError,jt as isRetryableError,mC as parseSol,Fo as resetSessionKeyManager,Oi as setLocale,Gt as t,H as useAccount,ao as useBalance,it as useCapabilities,V as useChain,Zt as useCompareCosts,So as useConnect,Lo as useCreateSessionKey,me as useDelegation,Qo as useDelegationPolicy,Zo as useDisconnect,fs as useERC20Allowance,ws as useERC20Approve,Ws as useERC20Transfer,Hs as useERC20TransferSimulation,ts as useEmbeddedWallet,ft as useExecuteCalls,nn as useExecuteRoute,js as useLastTx,Js as useLookupAddress,ca as useNotification,da as usePassphraseGate,fa as useResolveName,Bo as useRevokeSession,sn as useRouteQuote,Ut as useSIWxLogin,_a as useSIWxSession,dt as useSendCalls,Ce as useSendTransaction,Sa as useSendUserOperation,Ho as useSendWithSession,va as useSession,gt as useSessionKeys,Va as useSignInWithEthereum,Ee as useSignInWithX,ht as useSignMessage,za as useSimulateTransfer,ti as useSiwxAuthSession,oi as useSmartAccount,Lt as useSolanaAccount,ci as useSolanaBalance,di as useSolanaRoles,fi as useSolanaTransaction,Ci as useSwitchChain,vi as useTokenBalance,Ge as useTokenList,ze as useTokenSearch,kt as useTransactionSimulation,Ri as useTxHistory,$s as useTxMonitor,Ui as useUserOpStatus,Mi as useValidateDestination,G as useViemClient,Li as useWallet,U as useWeb3,Bi as useWeb3ErrorHandler,lr as validateDestination};
|
|
1
|
+
import{formatSol as bC,getLatestBlockhash as RC,getSignatureStatus as TC,getSolanaBalance as IC,LAMPORTS_PER_SOL as UC,PassphraseCancelledError as PC,PassphraseGate as WC,parseSol as OC,SolanaRpcError as NC}from"@naculus/connect-core";import{compareCostsKey as vr}from"@naculus/connect-appkit-core";import{useCallback as Zt,useEffect as en,useRef as tn,useState as Xe}from"react";function nn(e,t){let{operation:o,chains:s,options:n}=e,[l,i]=Xe([]),[C,u]=Xe(!1),[c,g]=Xe(null),r=tn(!0),a=tn(0),p=vr(e),f=Zt(async()=>{if(!s||s.length===0){i([]);return}if(!t)return;let S=++a.current;u(!0),g(null);try{let h=await t(o,s,n);r.current&&S===a.current&&i(h)}catch(h){r.current&&S===a.current&&(g(h instanceof Error?h:new Error(String(h))),i([]))}finally{r.current&&S===a.current&&u(!1)}},[p,t]);en(()=>{f()},[f]),en(()=>(r.current=!0,()=>{r.current=!1}),[]);let d=Zt(async()=>{await f()},[f]);return{comparisons:l,loading:C,error:c,refresh:d}}import{toExecuteRouteError as Ar,validateRouteRecipient as br}from"@naculus/connect-appkit-core";import{useCallback as rn,useEffect as Rr,useRef as on,useState as Ye}from"react";function sn(e){let[t,o]=Ye(!1),[s,n]=Ye(null),[l,i]=Ye(null),C=on(!0),u=on(!1);Rr(()=>(C.current=!0,()=>{C.current=!1}),[]);let c=rn(async(r,a,p)=>{if(!e)return i({code:"no_executor",message:"No executeRoute function provided"}),n(null),null;let f=br(r,a);if(f)return i(f),n(null),null;if(u.current)return i({code:"execution_in_progress",message:"A route execution is already in progress"}),null;u.current=!0,o(!0),i(null),n(null);try{let d=await e(r,a,p);return C.current&&n(d),d}catch(d){return C.current&&i(Ar(d)),null}finally{u.current=!1,C.current&&o(!1)}},[e]),g=rn(()=>{n(null),i(null),o(!1)},[]);return{execute:c,executing:t,result:s,error:l,reset:g}}import{isQuotableInput as Tr}from"@naculus/connect-appkit-core";import{useCallback as Je,useEffect as an,useRef as ln,useState as Ze}from"react";function cn(e,t){let{fromChain:o,toChain:s,fromToken:n,toToken:l,amount:i,options:C}=e,[u,c]=Ze([]),[g,r]=Ze(!1),[a,p]=Ze(null),f=ln(null),d=ln(!0),S=Je(async()=>{if(!Tr({fromChain:o,toChain:s,fromToken:n,amount:i})){c([]);return}if(t){r(!0),p(null);try{let E=await t(o,s,n,i,C,l);d.current&&c(E)}catch(E){d.current&&(p(E instanceof Error?E:new Error(String(E))),c([]))}finally{d.current&&r(!1)}}},[o,s,n,l,i,C,t]);an(()=>{if(f.current&&clearTimeout(f.current),!o||!s||!n||!i){c([]);return}return f.current=setTimeout(()=>{S()},300),()=>{f.current&&clearTimeout(f.current)}},[S,o,s,n,i]),an(()=>(d.current=!0,()=>{d.current=!1}),[]);let h=Je(async()=>{await S()},[S]),w=Je(()=>{c([]),p(null),r(!1)},[]);return{quotes:u,loading:g,error:a,refresh:h,clear:w}}import{logger as et,WalletError as K}from"@naculus/connect-core";import{eip6963Connector as q}from"@naculus/connector-evm-injected";import{PassphraseGate as Ir}from"@naculus/connect-core";import{createWalletConnectConnector as Ur}from"@naculus/connector-walletconnect";var tt=null;function nt(e){let t=null,o=Ur({projectId:e.projectId,metadata:e.metadata}),s=null,n=null,l=null,i=null,C=e.passphrasePrompt&&e.enableEmbedded&&!e.embeddedConfig?.encryptionPassphrase?new Ir:null;e.enableEmbedded&&(n=import("@naculus/connector-embedded").then(r=>{let a={...e.embeddedConfig};C&&(a.encryptionPassphrase=C.request),e.enablePasskeys&&a.encryptionPassphrase&&!a.prfUnlock&&(a.prfUnlock={async derive(f){i&&await i;let d=l;return d?.hasCredential()?d.derivePrfKey(f):null}}),s=r.createPocketConnector(a),t?._setEmbeddedConnector(s)}).catch(r=>{et.warn("react/client","Embedded wallet connector not available:",r),s=null})),e.enablePasskeys&&(i=import("@naculus/connector-passkeys").then(r=>{l=r.createPasskeysConnector(),t?._setPasskeysConnector(l)}).catch(r=>{et.warn("react/client","Passkeys connector not available:",r),l=null}));let u=null,c=null;e.enableSolana&&(c=import("@naculus/connector-solana").then(r=>{let a=r.solanaConnector;e.solanaDefaultChain&&"configure"in a&&a.configure({defaultChain:e.solanaDefaultChain}),u=a,typeof window<"u"&&"startDiscovery"in a&&a.startDiscovery(),t?._setSolanaConnector(u)}).catch(r=>{et.warn("react/client","Solana connector not available:",r),u=null})),typeof window<"u"&&q.startDiscovery();let g={connector:o,get embeddedConnector(){return s},getEmbeddedConnector:async()=>(n&&await n,s),get passkeysConnector(){return l},passphraseGate:C,solanaRpcUrl:e.solanaRpcUrl??null,get solanaConnector(){return u},connect:()=>o.connect(),connectInjected:async r=>q.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,!l)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return l.connect()},startPairing:()=>o.startPairing(),completePairing:()=>o.completePairing(),cancelPairing:()=>o.cancelPairing?.(),signMessage:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return q.signMessage(r,a);if(r.walletType==="passkeys"&&l)return l.signMessage(r,a);if(r.walletType==="embedded"){if(!s)throw new K("wallet_unavailable","Embedded wallet connector not available.");return s.signMessage(r,a)}if(r.walletType==="solana"){if(c&&await c,u)return u.signMessage(r,a);throw new K("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 q.signTransaction(r,a);if(r.walletType==="embedded"){if(!s)throw new K("wallet_unavailable","Embedded wallet connector not available.");return s.signTransaction(r,a)}if(r.walletType==="solana"){if(c&&await c,u)return u.signTransaction(r,a);throw new K("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 q.sendTransaction(r,a);if(r.walletType==="passkeys"&&l)return l.sendTransaction(r,a);if(r.walletType==="embedded"){if(!s)throw new K("wallet_unavailable","Embedded wallet connector not available.");return s.sendTransaction(r,a)}if(r.walletType==="solana"){if(c&&await c,u)return u.sendTransaction(r,a);throw new K("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-")?q.onAccountsChanged?.(r,a)??p:r.walletType==="embedded"?s?.onAccountsChanged?.(r,a)??p:r.walletType==="passkeys"?p:r.walletType==="solana"?u?.onAccountsChanged?.(r,a)??p:o.onAccountsChanged?.(r,a)??p},onChainChanged:(r,a)=>{let p=()=>{};return r.id?.startsWith("eip6963-")?q.onChainChanged?.(r,a)??p:r.walletType==="passkeys"||r.walletType==="embedded"?p:r.walletType==="solana"?u?.onChainChanged?.(r,a)??p:o.onChainChanged?.(r,a)??p},getCapabilities:r=>r.id?.startsWith("eip6963-")?q.getCapabilities?.(r):r.walletType==="passkeys"?l?.getCapabilities?.(r):r.walletType==="solana"?u?.getCapabilities?.(r):r.walletType==="embedded"?s?.getCapabilities?.(r):o.getCapabilities?.(r),sendCalls:async(r,a,p,f)=>{if(r.id?.startsWith("eip6963-"))return q.sendCalls(r,a,p,f);if(r.walletType==="passkeys"&&l)return l.sendCalls(r,a,p,f);if(r.walletType==="solana"){if(c&&await c,u)return u.sendCalls(r,a,p,f);throw new K("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 K("method_not_allowed","Embedded wallet does not support sendCalls");return s.sendCalls(r,a,p,f)}if(!o.sendCalls)throw new K("method_not_allowed","sendCalls not supported by this connector");return o.sendCalls(r,a,p,f)},showCallsStatus:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return q.showCallsStatus(r,a);if(r.walletType==="passkeys"||r.walletType==="embedded")throw new K("method_unsupported",`${r.walletType} wallets have no UI to display a call bundle.`);if(!o.showCallsStatus)throw new K("method_unsupported","This connector cannot display call status.");return o.showCallsStatus(r,a)},getCallsStatus:async(r,a)=>{if(r.id?.startsWith("eip6963-")&&q.getCallsStatus)return q.getCallsStatus(r,a);if(r.walletType==="passkeys"&&l?.getCallsStatus)return l.getCallsStatus(r,a);if(r.walletType==="embedded")throw new K("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!o.getCallsStatus)throw new K("method_not_allowed","getCallsStatus not supported by this connector");return o.getCallsStatus(r,a)},reconnect:async r=>r.walletType==="eip6963"?q.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 q.disconnect(r);if(r.walletType==="embedded"&&s)return s.disconnect();if(r.walletType==="passkeys"&&l)return l.disconnect(r);if(r.walletType==="solana"){if(c&&await c,u)return u.disconnect(r);throw new K("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),l&&r.push(l),u&&r.push(u),r},_setEmbeddedConnector:r=>{s=r},_setPasskeysConnector:r=>{l=r},_setSolanaConnector:r=>{u=r}};return t=g,tt=g,g}function rt(){return tt}function Pr(){tt=null}import{isEvmAddress as fn,parseCaip10 as no}from"@naculus/connect-core";import{useMemo as ro}from"react";import{createConnectorManager as Vr,createSessionManager as $r,LocalStorageSessionStorage as Gr,logger as Z,WalletError as jr}from"@naculus/connect-core";import{eip6963Connector as Re}from"@naculus/connector-evm-injected";import{createContext as zr,useCallback as H,useContext as Qr,useEffect as ce,useMemo as ue,useReducer as Xr,useRef as dn}from"react";import{logger as Wr}from"@naculus/connect-core";import{issueNonce as Or,parseSiwxMessage as Nr}from"@naculus/siwx";function oe(e,t){let o=t.split(":",1)[0],n=(e.namespaces[o]?.accounts??[]).filter(l=>l.startsWith(`${o}:`)).map(l=>({namespace:o,caip10:l}))[0];if(n)return{...n,address:n.caip10.split(":").pop()??n.caip10}}function _r(e){return e.namespaces.eip155?.chains?.[0]??e.namespaces.solana?.chains?.[0]??e.namespaces.xrpl?.chains?.[0]??"eip155:1"}async function un(e){let{session:t,siwx:o,signMessage:s}=e;if(!o||!t)return{kind:"skipped"};try{let n=_r(t),l=oe(t,n);if(!l)throw new Error("No account found in session");let{address:i}=l,C=await o.createMessage({address:i,chainId:n}),u=Nr(C);if(!u?.nonce)throw new Error("SIWx message must contain a nonce");await Or(u.nonce);let c=await s(t,{message:C,address:i,chainId:n});return await o.handleSignComplete?.({message:C,signature:c}),{kind:"authenticated",address:i,chainId:n}}catch(n){let l=n instanceof Error?n:new Error("Wallet authentication failed");return Wr.error("appkit/core","SIWx authentication failed:",n),{kind:"failed",error:l,fatal:o.required!==!1}}}import{initialWeb3State as Yr,web3Reducer as Jr,withRetry as Zr,withTimeout as mn}from"@naculus/connect-appkit-core";import{resolveChain as Dr}from"@naculus/connect-appkit-core";import{CHAINS as be,DEFAULT_RPC_URLS as Mr,eip155Reference as Lr,getRpcUrl as Br}from"@naculus/connect-core";var Fr=[{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 Hr(e){let t=be[e];if(!t||!t.explorerUrl)return null;let o=t.caip2Id;return{caip2:o,name:t.name,rpcUrl:Br(o,Mr[o]??""),explorerUrl:t.explorerUrl,token:t.nativeCurrency.symbol}}function Kr(){if(!be)return[];let e=[],t=Object.keys(be).map(Number).sort((o,s)=>o-s);for(let o of t){let s=Hr(o);s&&e.push(s)}for(let o of Fr){let s=Lr(o.caip2);(s===null||!be[s])&&e.push(o)}return e}var pn=Kr();function qr(e,t){return Dr(e,t)??void 0}function ot(){return[...pn]}import{jsx as to}from"react/jsx-runtime";var st=zr(null);function eo({children:e,config:t,autoConnect:o=!0}){let[s,n]=Xr(Jr,Yr),l=ue(()=>t.chains??ot(),[t.chains]),i=t.connectionTimeout??3e4,C=t.maxRetries??2,u=ue(()=>new Gr(t.storageKey??"naculus_web3_session",t.encryptionKey),[t.storageKey,t.encryptionKey]),c=ue(()=>nt({projectId:t.projectId,metadata:t.metadata,enableEmbedded:t.enableEmbedded,embeddedConfig:t.embeddedConfig,enablePasskeys:t.enablePasskeys,enableSolana:t.enableSolana,solanaDefaultChain:t.solanaDefaultChain}),[t.projectId,t.metadata,t.enableEmbedded,t.embeddedConfig,t.enablePasskeys,t.enableSolana,t.solanaDefaultChain]),g=dn(null),r=dn(null),a=ue(()=>{let m=Vr();for(let N of[Re,...c.getAllConnectors()])m.register(N.id,N);let y={},k={};for(let N of l){let _=N.caip2;N.rpcUrl&&(y[_]=N.rpcUrl),N.token&&(k[_]={name:N.name,symbol:N.token,decimals:18})}let P=$r(m,{autoRefreshFeeOnSwitch:t.autoRefreshFeeOnSwitch??!0,defaultRpcUrls:y,defaultCurrencies:k,encryptionKey:t.encryptionKey});return g.current=P,P},[c,l,t.autoRefreshFeeOnSwitch,t.encryptionKey]);ce(()=>{let m=_=>{let{walletSession:J}=_.bundle;n({type:"SET_SESSION",payload:J});let Jt=[];Object.values(J.namespaces).forEach(xr=>{Jt.push(...xr.accounts)}),n({type:"SET_ACCOUNTS",payload:Jt}),n({type:"SET_CHAIN",payload:_.bundle.activeChainId}),n({type:"SET_STATUS",payload:"connected"})},y=()=>{n({type:"RESET"})},k=_=>{n({type:"SET_CHAIN",payload:_.newChainId})},P=_=>m(_),N=()=>{u.clear(),n({type:"RESET"})};return a.on("sessionConnected",m),a.on("sessionDisconnected",y),a.on("chainChanged",k),a.on("sessionScopeChanged",P),a.on("sessionRevoked",N),()=>{a.off("sessionConnected",m),a.off("sessionDisconnected",y),a.off("chainChanged",k),a.off("sessionScopeChanged",P),a.off("sessionRevoked",N)}},[a,u]),ce(()=>{let m=()=>{u.clear(),n({type:"RESET"})};c.connector.onSessionExpiry(m)},[c,u]);let p=H(()=>{for(let m of[Re,...c.getAllConnectors()])a.registerConnector(m)},[c,a]),f=H(async m=>{p();let y=[Re,...c.getAllConnectors()].find(P=>P.id===m.walletType||P.kind===m.walletType);y&&!m.connectorId&&(m.connectorId=y.id);let k=m.namespaces.eip155?.chains?.[0]??m.namespaces.solana?.chains?.[0]??m.namespaces.xrpl?.chains?.[0];k&&await a.attach(m,k)},[c,a,p]),d=H(m=>{if(n({type:"SET_SESSION",payload:m}),m){let y=[];Object.values(m.namespaces).forEach(_=>{y.push(..._.accounts)}),n({type:"SET_ACCOUNTS",payload:y});let k=m.namespaces.eip155?.chains?.[0],P=m.namespaces.solana?.chains?.[0],N=m.namespaces.xrpl?.chains?.[0];n({type:"SET_CHAIN",payload:k??P??N??null})}else n({type:"SET_ACCOUNTS",payload:[]}),n({type:"SET_CHAIN",payload:null})},[]);ce(()=>{let m=s.session,y=c;return!m||!y?.onAccountsChanged?void 0:y.onAccountsChanged(m,P=>{if(P.length===0){u.clear().finally(()=>n({type:"RESET"}));return}d(m),u.save(m)})},[s.session,c,u,d]),ce(()=>{let m=s.session,y=c;if(!(!m||!y?.onChainChanged))return y.onChainChanged(m,k=>{d(m),u.save(m);let P=a.syncExternalChain;if(!P)return;let N=P.call(a,k).catch(_=>{Z.warn("react/provider","External chain sync error:",_)});r.current=N,N.finally(()=>{r.current===N&&(r.current=null)})})},[s.session,c,u,d,a]);let S=H(async m=>{if(!t.siwx||!m)return!0;n({type:"SET_STATUS",payload:"authenticating"});let y=await un({session:m,siwx:t.siwx,signMessage:(k,P)=>c.signMessage(k,P)});return y.kind==="failed"&&y.fatal?(await u.clear(),n({type:"RESET"}),n({type:"SET_ERROR",payload:y.error}),!1):!0},[t.siwx,c,u]),h=H(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await mn(c.connect(),i,"Wallet connect");await u.save(m),d(m);try{await f(m)}catch(y){Z.warn("react/provider","SessionManager sync error:",y)}if(!await S(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let y=m instanceof Error?m.message:"Connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(y)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,i,S,f]),w=H(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await c.connectEmbedded();if(await u.save(m),d(m),await f(m),!await S(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let y=m instanceof Error?m.message:"Embedded wallet connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(y)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,S,f]),E=H(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await c.connectPasskeys();if(await u.save(m),d(m),await f(m),!await S(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let y=m instanceof Error?m.message:"Passkeys connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(y)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,S,f]),R=H(async()=>{if(!s.session){n({type:"RESET"});return}try{await c.disconnect(s.session)}catch(m){Z.error("react/provider","Disconnect error:",m)}try{let m=g.current;m&&await m.disconnect()}catch(m){Z.warn("react/provider","SessionManager disconnect error:",m)}await u.clear(),n({type:"RESET"})},[c,s.session,u]),A=H(async m=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let y=await mn(c.connectInjected(m),i,"Injected wallet connect");await u.save(y),d(y);try{await f(y)}catch(k){Z.warn("react/provider","SessionManager sync error:",k)}if(!await S(y))return;n({type:"SET_STATUS",payload:"connected"})}catch(y){let k=y instanceof Error?y.message:"Connection failed";n({type:"SET_ERROR",payload:y instanceof Error?y:new Error(k)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,i,S,f]),T=H(async()=>c.startPairing(),[c]),v=H(()=>{c.cancelPairing?.()},[c]),x=H(async()=>{let m=await c.completePairing();return await u.save(m),d(m),await f(m),await S(m)&&n({type:"SET_STATUS",payload:"connected"}),m},[c,u,d,S,f]),b=H(async m=>{let y=t.siwx;if(!y||y.required===!1)return!0;try{if(await y.hasValidSession?.())return!0}catch(k){Z.warn("react/provider","siwx.hasValidSession failed",k)}return S(m)},[t.siwx,S]),I=H(async()=>{let m=await u.load();if(!m){n({type:"SET_STATUS",payload:"disconnected"});return}n({type:"SET_STATUS",payload:"reconnecting"});try{let y=await Zr(()=>c.reconnect(m),{maxRetries:C,baseDelay:1e3,label:"reconnect"});d(y);try{let k=g.current;k&&(p(),await k.restoreFromPersistence())}catch(k){Z.warn("react/provider","SessionManager restore error:",k)}if(!await b(y))return;n({type:"SET_STATUS",payload:"connected"})}catch(y){Z.error("react/provider","Reconnect error:",y),await u.clear(),n({type:"SET_STATUS",payload:"disconnected"}),n({type:"SET_SESSION",payload:null})}},[c,u,d,C,p,b]),W=H(async m=>{r.current&&await r.current;let y=g.current;if(y?.getActiveBundle()){await y.switchChain(m),d(s.session);return}if(!s.session)throw new Error("No active session");try{s.session.walletType==="eip6963"||s.session.id?.startsWith("eip6963-")?await Re.switchChain(s.session,m):s.session.walletType==="embedded"&&c.embeddedConnector?await c.embeddedConnector.switchChain?.(s.session,m):s.session.walletType==="passkeys"&&c.passkeysConnector?await c.passkeysConnector.switchChain?.(s.session,m):s.session.walletType==="solana"&&c.solanaConnector?await c.solanaConnector.switchChain?.(s.session,m):await c.connector.switchChain(s.session,m),d(s.session)}catch(k){throw new jr("chain_unsupported","Failed to switch chain",k)}},[c,s.session,d]);ce(()=>{o&&I()},[o,I]);let L=H(()=>{n({type:"SET_ERROR",payload:null})},[]),F=ue(()=>({...s,connect:h,connectEmbedded:w,connectPasskeys:E,disconnect:R,reconnect:I,switchChain:W,startPairing:T,completePairing:x,cancelPairing:v,connectInjected:A,clearError:L,isConnected:s.status==="connected",chains:l,client:c,sessionManager:a}),[s,h,w,E,R,I,W,T,x,A,L,l,c,a]);return to(st.Provider,{value:F,children:e})}function U(){let e=Qr(st);if(!e)throw new Error("useWeb3 must be used within a Web3ConnectProvider");return e}function B(){let{accounts:e,isConnected:t}=U(),o=ro(()=>!t||e.length===0?null:e.map(n=>{let l=no(n);return l?{address:n,namespace:l.namespace,isEVM:l.namespace==="eip155"&&fn(l.address)}:{address:n,namespace:null,isEVM:fn(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}}import{chainNumber as oo,resolveChain as so,toViemChain as ao}from"@naculus/connect-appkit-core";import{useState as pe,useEffect as at,useCallback as io,useMemo as de,useRef as lo}from"react";import{createPublicClient as co,http as uo,formatEther as po}from"viem";import{getNativeTokenPriceUsd as mo}from"@naculus/connect-core";function fo(e){let{evmAccount:t,isConnected:o}=B(),{chainId:s,chains:n}=U(),[l,i]=pe(null),[C,u]=pe(!1),[c,g]=pe(null),[r,a]=pe(null),p=e?.refreshInterval,f=lo(null),d=de(()=>so(n,s),[s,n]),S=d?oo(d):null,h=de(()=>d?ao(d,S):null,[d,S]),w=de(()=>d?.token??null,[d]),[E,R]=pe(null);at(()=>{if(!h||!d?.rpcUrl){R(null);return}let x=co({transport:uo(d.rpcUrl),chain:h});return R(x),()=>{}},[d]);let A=io(async()=>{if(!t||!E){i(null);return}u(!0),g(null);try{let b=t.includes(":")?t.split(":").pop():t,[I,W]=await Promise.all([E.getBalance({address:b}),s?mo(s,d?.rpcUrl).catch(()=>null):Promise.resolve(null)]);i(I.toString()),a(W)}catch(x){g(x instanceof Error?x:new Error("Failed to fetch balance")),i(null),a(null)}finally{u(!1)}},[t,E,s,d?.rpcUrl]);at(()=>{o&&t&&A()},[o,t,A]),at(()=>(p&&p>0&&o&&t&&(f.current=setInterval(A,p)),()=>{f.current&&(clearInterval(f.current),f.current=null)}),[p,o,t,A]);let T=de(()=>{if(l===null)return null;try{return po(BigInt(l))}catch{return null}},[l]),v=de(()=>{if(r===null||T===null)return null;let x=parseFloat(T);if(isNaN(x))return null;let b=x*r;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(b)},[r,T]);return{balance:l,formatted:T,symbol:w,usdPrice:r,usdValue:v,isLoading:C,error:c,refetch:A,chain:d}}import{atomicSupportFor as go,normalizeCapabilities as Co,selectChainCapabilities as ho}from"@naculus/connect-appkit-core";import{useCallback as yo,useEffect as So,useRef as Eo,useState as it}from"react";function O(e){return e??rt()}function lt(){let{client:e,session:t,chainId:o}=U(),[s,n]=it(null),[l,i]=it(!1),[C,u]=it(null),c=Eo(0),g=yo(async()=>{let r=++c.current,a=O(e);if(!a?.getCapabilities||!t){n(null),i(!1),u(null);return}i(!0),u(null);try{let p=await a.getCapabilities(t);if(r!==c.current)return;n(Co(p))}catch(p){if(r!==c.current)return;n(null),u(p instanceof Error?p:new Error("Capability query failed"))}finally{r===c.current&&i(!1)}},[e,t]);return So(()=>{g()},[g]),{capabilities:s,current:ho(s,o),atomic:go(s,o),isFetching:l,error:C,refetch:g}}import{useMemo as ct}from"react";import{chainsForNamespace as wo,describeChain as ko,resolveChain as xo}from"@naculus/connect-appkit-core";function V(){let{chainId:e,session:t,switchChain:o,chains:s}=U(),n=ct(()=>xo(s,e),[s,e]),l=ct(()=>t?ko(s,e):null,[s,e,t]),i=ct(()=>wo(s,e),[s,e]);return{chainId:e,currentChain:n,chainInfo:l,availableChains:i,chains:i,isEvm:e?.startsWith("eip155:")??!1,switchChain:o}}import{useCallback as vo,useState as gn}from"react";import{WalletError as Ao}from"@naculus/connect-core";function bo(){let{connect:e,status:t}=U(),[o,s]=gn(!1),[n,l]=gn(null);return{connect:vo(async()=>{s(!0),l(null);try{await e()}catch(C){let u=C instanceof Error?C.message:"Connection failed";l(C instanceof Ao?C:new Error(u))}finally{s(!1)}},[e]),isConnecting:o||t==="connecting",error:n}}import{bareEvmAddress as Po}from"@naculus/connect-appkit-core";import{delegateAccount as Wo,eip155Reference as Oo,REVOKE_DELEGATE as No,WalletError as hn}from"@naculus/connect-core";import{useCallback as Te,useEffect as yn,useRef as Sn,useState as pt}from"react";import{chainNumber as Ro,toViemChain as To}from"@naculus/connect-appkit-core";import{useMemo as ut}from"react";import{createPublicClient as Io,http as Cn,createWalletClient as Uo}from"viem";function $(){let{evmAccount:e,isConnected:t}=B(),{currentChain:o,chains:s}=V(),n=o?Ro(o):null,l=ut(()=>o?To(o,n):null,[o,n]),i=ut(()=>l?Io({transport:Cn(l.rpcUrls.default.http[0]),chain:l}):null,[o,l]),C=ut(()=>{if(!t||!e||!l)return null;let u=e.includes(":")?e.split(":").pop():e;return Uo({transport:Cn(l.rpcUrls.default.http[0]),chain:l,account:u})},[t,e,o,l]);return{publicClient:i,walletClient:C,chains:s}}function _o(e){let{evmAccount:t}=B(),{session:o,chainId:s,client:n}=U(),{publicClient:l}=$(),[i,C]=pt(null),[u,c]=pt(!1),[g,r]=pt(null),a=Sn(0),p=Sn(!1);yn(()=>()=>{a.current+=1},[]),yn(()=>{a.current+=1,C(null),c(!1),r(null)},[o,s,t]);let f=Te(async(w,E)=>{let R=x=>(r(x),null);if(p.current)return R(new Error("A delegation is already in progress"));let A=Po(t);if(!o||!A||!s)return R(new hn("wallet_unavailable","No connected EVM account"));if(!l||l.chain?.id!==Oo(s))return R(new hn("chain_mismatch",`No RPC client for ${s}; refusing to read the nonce elsewhere.`));let T=o.walletType==="embedded"?O(n)?.embeddedConnector??{}:{},v=++a.current;p.current=!0,c(!0),r(null),C(null);try{let x=await Wo({connector:T,session:o,account:A,chainId:s,delegate:w,allowlist:E,getTransactionCount:(b,I)=>l.getTransactionCount({address:b,blockTag:I})});return v!==a.current?null:(C(x),x)}catch(x){return v!==a.current?null:R(x instanceof Error?x:new Error("Failed to send delegation"))}finally{p.current=!1,v===a.current&&c(!1)}},[s,n,t,l,o]),d=Te(w=>f(w,e.allowlist),[f,e.allowlist]),S=Te(()=>f(No,[]),[f]),h=Te(()=>{a.current+=1,C(null),c(!1),r(null)},[]);return{delegate:d,revoke:S,result:i,isPending:u,error:g,reset:h}}import{readDelegation as Do,UNKNOWN_DELEGATION as dt}from"@naculus/connect-core";import{useCallback as Mo,useEffect as Lo,useRef as Bo,useState as mt}from"react";function me(){let{publicClient:e}=$(),{evmAccount:t}=B(),[o,s]=mt(dt),[n,l]=mt(!1),[i,C]=mt(null),u=Bo(0),c=t?.includes(":")?t.split(":").pop():t,g=Mo(async()=>{let r=++u.current;if(!e||!c){s(dt),l(!1),C(null);return}l(!0),C(null);try{let a=await e.getCode({address:c});if(r!==u.current)return;s(Do(a??"0x"))}catch(a){if(r!==u.current)return;s(dt),C(a instanceof Error?a:new Error("Code read failed"))}finally{r===u.current&&l(!1)}},[e,c]);return Lo(()=>{g()},[g]),{...o,isFetching:n,error:i,refetch:g}}import{bareEvmAddress as ts,createDelegationPolicyFlow as ns,isVerifiablePolicy as rs}from"@naculus/connect-appkit-core";import{useCallback as ge,useEffect as os,useMemo as ss,useState as Pe}from"react";import{recoverMessageAddress as as}from"viem";import{planExecution as qo,WalletError as Vo}from"@naculus/connect-core";import{useCallback as En,useState as gt}from"react";import{chooseExecutionStrategy as Ho,getAccountCapabilities as Ko,WalletError as ee}from"@naculus/connect-core";import{useCallback as Ue,useState as fe}from"react";import{WalletError as Fo}from"@naculus/connect-core";function Ie(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 Fo("tx_failed","Wallet did not return a valid 32-byte transaction hash")}function ft(){let{session:e,chainId:t,client:o}=U(),[s,n]=fe("idle"),[l,i]=fe(null),[C,u]=fe(null),[c,g]=fe(null),[r,a]=fe(null),p=Ue(async(h,w)=>{if(!e){n("failed");let E=new ee("wallet_unavailable","No active session");throw i(E),E}if(h.length===0){n("failed");let E=new ee("invalid_input","At least one call is required");throw i(E),E}n("awaiting_approval"),i(null),u(null);try{let E=O(o);if(!E)throw new ee("wallet_unavailable","Client not initialized");let R=w?.chainId??t??void 0,A=w?.strategy??Ho(await Ko(E,e,R),h.length);if(a(A),A==="atomic-batch"){let v=await E.sendCalls(e,h,R,{atomicRequired:!0,...w?.paymasterService?{paymasterService:w.paymasterService}:{}});return n("submitted"),u(v),v}let T="";for(let v=0;v<h.length;v++){let x=h[v];try{T=Ie(await E.sendTransaction(e,{transaction:{to:x.to,data:x.data,value:x.value},chainId:R}))}catch(b){throw new ee("tx_failed",`Call ${v+1} of ${h.length} failed after ${v} already landed (sent sequentially \u2014 this wallet cannot batch atomically): ${b instanceof Error?b.message:String(b)}`)}}return n("submitted"),u(T),T}catch(E){n("failed");let R=E instanceof Error?E.message:"sendCalls failed";throw i(E instanceof Error?E:new Error(R)),E}},[e,t,o]),f=Ue(async h=>{if(!e)throw new ee("wallet_unavailable","No active session");let w=h??C;if(!w)throw new ee("invalid_input","No bundle hash available");if(!h&&r==="sequential")throw new ee("invalid_input","Calls were sent sequentially, so there is no bundle to query. Track the returned transaction hash instead.");let E=O(o);if(!E)throw new ee("wallet_unavailable","Client not initialized");let R=await E.getCallsStatus(e,w);return g(R),R},[e,C,o,r]),d=Ue(async h=>{if(!e)return!1;let w=h??C;if(!w||!h&&r==="sequential")return!1;let E=O(o);if(!E?.showCallsStatus)return!1;try{return await E.showCallsStatus(e,w),!0}catch{return!1}},[e,C,o,r]),S=Ue(()=>{n("idle"),i(null),u(null),g(null),a(null)},[]);return{sendCalls:p,getCallsStatus:f,showCallsStatus:d,status:s,error:l,batchHash:C,callsStatus:c,execution:r,reset:S,isSending:s==="awaiting_approval"}}function Ct(e={}){let{current:t,atomic:o}=lt(),{delegated:s,delegate:n}=me(),{sendCalls:l}=ft(),[i,C]=gt(!1),[u,c]=gt(null),[g,r]=gt(null),a=e.atomicity??"preferred",p=e.sponsorship??"any",f=e.paymasterService,d=e.userOperation,S=e.userOperationSponsored??!1,h=!!(t?.raw?.paymasterService?.supported&&f),w=En((R,A=a)=>{let T=qo({atomicBatch:o==="supported",discovered:o!=="unknown",sponsoredTransactions:!1,...t?.maxBatchSize===void 0?{}:{maxBatchSize:t.maxBatchSize}},R,{atomicity:A,sponsorship:p}),v=p==="required"&&!S;if(T.strategy==="atomic-batch"&&!v)return{...T,reason:T.reason+(h?" A paymaster service will be requested, but the wallet's final fee payer must be checked after execution.":""),route:"wallet-batch"};let x=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=A!=="any"&&!T.atomic||p==="required";return d&&b&&!v?{strategy:"atomic-batch",atomic:!0,sponsored:S,reason:p==="required"&&!T.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"}:v?{strategy:"refuse",atomic:T.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}:T.strategy==="refuse"?{...T,reason:T.reason+x,route:null}:{...T,reason:T.reason+x,route:"sequential"}},[o,t,f,h,d,S,a,p,s,n]),E=En(async(R,A=a)=>{C(!0),c(null);try{let T=w(R.length,A);if(T.route===null)throw new Vo("method_not_allowed",T.reason);return r(T.route),T.route==="user-operation"?await d(R):await l(R,{strategy:T.route==="wallet-batch"?"atomic-batch":"sequential",...T.route==="wallet-batch"&&h?{paymasterService:f}:{}})}catch(T){let v=T instanceof Error?T:new Error("Execution failed");throw c(v),v}finally{C(!1)}},[w,l,d,a,f,h]);return{preview:w,execute:E,isExecuting:i,error:u,lastRoute:g,reset:()=>{c(null),r(null)}}}import{getSharedSessionKeyManager as $o,resetSharedSessionKeyManager as Go}from"@naculus/connect-appkit-core";import{WalletError as jo}from"@naculus/connect-core";import{useCallback as Q,useEffect as zo,useRef as Qo,useState as z}from"react";function se(e){return $o(e)}function ht(e){let{session:t}=U(),[o,s]=z([]),[n,l]=z(!1),[i,C]=z(null),u=Qo(!0),c=Q(()=>C(null),[]),g=se(e),r=g.isStorageAvailable(),a=Q(async()=>{if(!t){s([]);return}l(!0),C(null);try{let f=await g.listSessions();u.current&&s(f)}catch(f){u.current&&C(f instanceof Error?f:new Error("Failed to load session keys"))}finally{u.current&&l(!1)}},[t,g]);zo(()=>(u.current=!0,a(),()=>{u.current=!1}),[a]);let p=o.filter(f=>f.status==="active");return{sessions:o,activeSessions:p,loading:n,error:i,refresh:a,clearError:c,storageAvailable:r}}function Xo(e){let{session:t}=U(),[o,s]=z(null),[n,l]=z(!1),[i,C]=z(null),u=Q(()=>C(null),[]),c=se(e);return{createSessionKey:Q(async(r,a)=>{if(!t)throw new jo("wallet_unavailable","No active wallet session");l(!0),C(null);try{let p=a??void 0,f=await c.createSessionKey(r,p);return s(f),f}catch(p){let f=p instanceof Error?p:new Error("Failed to create session key");throw C(f),f}finally{l(!1)}},[t,c]),lastCreated:o,isCreating:n,error:i,clearError:u}}function Yo(e){let[t,o]=z(!1),[s,n]=z(null),l=Q(()=>n(null),[]),i=se(e);return{revokeSession:Q(async u=>{o(!0),n(null);try{await i.revokeSession(u)}catch(c){let g=c instanceof Error?c:new Error("Failed to revoke session key");throw n(g),g}finally{o(!1)}},[i]),isRevoking:t,error:s,clearError:l}}function Jo(e){let[t,o]=z(!1),[s,n]=z(null),l=Q(()=>n(null),[]),i=se(e),C=Q(async(c,g,r)=>{o(!0),n(null);try{return await i.signWithSessionKey(c,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]),u=Q(async(c,g)=>{o(!0),n(null);try{return await i.checkSessionScope(c,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:C,checkScope:u,isBusy:t,error:s,clearError:l}}function Zo(){Go()}import{useState as wn,useCallback as es}from"react";import{WalletError as yt}from"@naculus/connect-core";function St(){let{session:e,chainId:t,client:o}=U(),[s,n]=wn(!1),[l,i]=wn(null);return{signMessage:es(async u=>{if(!e){let g=new yt("wallet_unavailable","No active session");throw i(g),g}let c=e.namespaces.eip155?.accounts[0]??Object.values(e.namespaces)[0]?.accounts[0];if(!c){let g=new yt("wallet_unavailable","No account found");throw i(g),g}n(!0),i(null);try{let g=O(o);if(!g)throw new yt("wallet_unavailable","Client not initialized");return await g.signMessage(e,{message:u,address:c,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:l}}import{buildDelegationPolicyMessage as ls}from"@naculus/connect-appkit-core";function is(e={}){let{evmAccount:t}=B(),o=ts(t),s=me(),n=Ct(e.execution),{signMessage:l}=St(),i=ht(e.managerConfig),C=se(e.managerConfig),[u,c]=Pe(!1),[g,r]=Pe(null),[a,p]=Pe(()=>new Set),[f,d]=Pe(!1),S=e.origin??(typeof window<"u"?window.location.origin:"unknown"),h=!!e.managerConfig?.encryptionKey,w=e.execution?.sponsorship,{refresh:E,storageAvailable:R}=i,{preview:A}=n,{delegated:T,delegate:v}=s,x=ss(()=>ns({manager:C,origin:S,signer:()=>o,signMessage:l,verifySignature:async({message:y,signature:k,signerAddress:P})=>(await as({message:y,signature:k})).toLowerCase()===P.toLowerCase(),previewExecution:A,sponsorship:w,adapter:e.adapter,delegation:()=>({delegated:T,delegate:v}),encryptionKeyConfigured:h,storageAvailable:()=>R,refresh:E}),[C,S,o,l,A,w,e.adapter,T,v,h,R,E]);os(()=>{let y=!1,k=i.sessions.filter(rs);return k.length===0?(p(new Set),d(!1),()=>{y=!0}):(d(!0),Promise.all(k.map(async P=>[P.id,await x.verifyStoredPolicy(P)])).then(P=>{y||p(new Set(P.filter(([,N])=>N).map(([N])=>N)))}).catch(P=>{y||(p(new Set),r(P instanceof Error?P:new Error("Policy verification failed")))}).finally(()=>{y||d(!1)}),()=>{y=!0})},[i.sessions,x]);let b=ge(()=>{r(null),i.clearError()},[i]),I=ge(async(y,k)=>{c(!0),r(null);try{return await y()}catch(P){let N=P instanceof Error?P:new Error(k);throw r(N),N}finally{c(!1)}},[]),W=ge(y=>I(()=>x.createPolicy(y),"Policy creation failed"),[x,I]),L=ge(y=>I(()=>x.revokePolicy(y),"Policy revocation failed"),[x,I]),F=ge((y,k)=>I(()=>x.executePolicy(y,k),"Policy execution failed"),[x,I]),m=i.activeSessions.filter(y=>a.has(y.id));return{policies:i.sessions,activePolicies:m,storageAvailable:i.storageAvailable,loading:i.loading||f,isBusy:u,error:g??i.error,delegation:s,createPolicy:W,revokePolicy:L,previewPolicyExecution:x.previewPolicyExecution,signPolicyDigest:x.signPolicyDigest,executePolicy:F,refresh:i.refresh,clearError:b}}import{useCallback as cs,useRef as us,useState as kn}from"react";function ps(){let{disconnect:e,status:t}=U(),[o,s]=kn(!1),[n,l]=kn(null),i=us(!0);return{disconnect:cs(async()=>{if(t!=="disconnected"){s(!0),l(null);try{await e()}catch(u){if(!i.current)return;l(u instanceof Error?u:new Error("Disconnect failed"))}finally{i.current&&s(!1)}}},[e,t]),isDisconnecting:o,error:n,cleanup:()=>{i.current=!1}}}import{WalletError as Et}from"@naculus/connect-core";import{useCallback as X,useEffect as ds,useRef as We,useState as Oe}from"react";function te(e){let t=e.activeNamespace??"eip155",o=Array.isArray(e.accounts)?e.accounts.map(({namespace:s,address:n,derivationPath:l})=>({namespace:s,address:n,...l?{derivationPath:l}:{}})):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 ms(){let{connectEmbedded:e,client:t}=U(),[o,s]=Oe(null),n=We(null),l=We(4),i=We(!1),C=We(null),[u,c]=Oe(!1),[g,r]=Oe(!1),[a,p]=Oe(null),f=()=>p(null),d=X(()=>{let m=n.current;return n.current=null,m},[]),S=X(()=>{let m=O(t);if(!m?.embeddedConnector)throw new Et("wallet_unavailable","Embedded wallet not enabled.");return m.embeddedConnector},[t]),h=X(()=>{try{return S().getWallet()?.privateKey??null}catch{return null}},[S]),w=X(async()=>{let m=O(t);if(!m)throw new Et("wallet_unavailable","Embedded wallet not enabled.");let y=m.getEmbeddedConnector?await m.getEmbeddedConnector():m.embeddedConnector;if(!y)throw new Et("wallet_unavailable","Embedded wallet not enabled.");return y},[t]),E=X(()=>{try{return O(t)?.passphraseGate??null}catch{return null}},[t]),R=X(m=>{m?.code==="decryption_failed"&&E()?.forget("That passphrase did not open the wallet.")},[E]),A=X(async()=>{i.current=!1,p(null);try{let m=await w();if(!await m.load())return!1;let k=m.getWallet();return k?(n.current=null,c(!1),s(te(k)),!0):!1}catch(m){return i.current=!0,R(m),p(m instanceof Error?m:new Error("Failed to restore embedded wallet")),!1}},[R,w]);ds(()=>{let m=!1,y=null;return A().then(k=>{m||k||i.current||(y=setTimeout(()=>{m||A()},100))}),()=>{m=!0,y&&clearTimeout(y)}},[A]);let T=async()=>{r(!0),p(null);try{let m=await w(),y=await m.load(),k=m.getWallet();y&&k&&(s(te(k)),n.current=k.mnemonic||null,c(!k.mnemonic)),await e();let P=m.getWallet();P&&(s(te(P)),P.mnemonic&&!y&&(n.current=P.mnemonic,c(!0)))}catch(m){R(m),p(m instanceof Error?m:new Error("Embedded wallet connection failed"))}finally{r(!1)}},v=async()=>{r(!0),p(null);try{let m=await w();E()?.expect("create");let y=await m.generateWallet();return s(te(y)),n.current=y.mnemonic,c(!0),y}catch(m){return p(m instanceof Error?m:new Error("Failed to generate wallet")),null}finally{r(!1)}},x=async m=>{r(!0),p(null);try{let y=await w();E()?.expect("create");let k=await y.importFromMnemonic(m);return s(te(k)),n.current=null,c(!1),k}catch(y){return p(y instanceof Error?y:new Error("Failed to import wallet")),null}finally{r(!1)}},b=async m=>{r(!0),p(null);try{let y=await w();E()?.expect("create");let k=await y.importFromPrivateKey(m);return s(te(k)),n.current=null,c(!1),k}catch(y){return p(y instanceof Error?y:new Error("Failed to import wallet")),null}finally{r(!1)}},I=async()=>{r(!0),p(null);try{await(await w()).wipe(),s(null),n.current=null,c(!1)}catch(m){p(m instanceof Error?m:new Error("Failed to wipe wallet"))}finally{r(!1)}},W=X(m=>{let y=S();y.setActiveNamespace(m);let k=y.getWallet();s(k?te(k):null)},[S]),L=X(async()=>{let m=await w(),y=await m.backfillAccounts();if(y.length>0){let k=m.getWallet();s(k?te(k):null)}return y.map(({namespace:k,address:P,derivationPath:N})=>({namespace:k,address:P,...N?{derivationPath:N}:{}}))},[w]),F=()=>{n.current=null,c(!1)};return{connectEmbedded:T,restoreWallet:A,generateWallet:v,importFromMnemonic:x,importFromPrivateKey:b,wipe:I,wallet:o,hasWallet:o!==null,address:o?.address??null,accounts:o?.accounts??[],activeNamespace:o?.activeNamespace??null,setActiveNamespace:W,backfillAccounts:L,seedPhrase:n.current,getSeedPhrase:d,getPrivateKey:h,backupPending:u,confirmBackup:F,isBusy:g,error:a,clearError:f,storageSecurityLevel:(()=>{try{let m=S(),y=m.getStorageSecurityLevel?.()??4;return m.getWallet()?(l.current=y,y):o?l.current:y}catch{return o?l.current:4}})(),securityReport:(()=>{let m=null;try{m=S().getStorageSecurityReport?.()??null}catch{m=null}if(!m)return C.current=null,null;let y=JSON.stringify(m);return C.current?.json===y?C.current.value:(C.current={json:y,value:m},m)})()}}import{chainNumber as Es}from"@naculus/connect-appkit-core";import{useState as ws,useCallback as ks,useEffect as An,useRef as bn,useMemo as xs}from"react";import{WalletError as fs}from"@naculus/connect-core";import{useCallback as xn,useEffect as gs,useLayoutEffect as Cs,useMemo as hs,useRef as vn}from"react";import{tokenChainMismatch as ys}from"@naculus/connect-appkit-core";function Ss(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 ae(e){let{token:t,chainId:o}=e,s=t.address.toLowerCase(),n=Ss(e),l=hs(()=>({key:n}),[n]),i=vn(n),C=vn(!0);Cs(()=>{i.current=n},[n]),gs(()=>(C.current=!0,()=>{C.current=!1}),[]);let u=xn(()=>C.current&&i.current===n,[n]),c=xn(()=>{if(!u())throw new fs("session_inactive","Wallet or token context changed. Retry the operation with the current account and chain.");let g=ys({address:s,chainId:t.chainId},o);if(g)throw g},[u,s,t.chainId,o]);return{identity:l,isCurrent:u,assertCurrent:c}}import{ERC20_MIN_ABI as vs,formatUnits as As}from"@naculus/connect-core";function bs(e){let{publicClient:t}=$(),{currentChain:o}=V(),{identity:s,isCurrent:n,assertCurrent:l}=ae({token:e.token,chainId:o?Es(o)??void 0:void 0,owner:e.owner,spender:e.spender,publicClient:t}),[i,C]=ws(null),u=i?.identity===s?i.raw:null,c=i?.identity===s&&i.fetching,g=i?.identity===s?i.error:null,r=bn(null),a=bn(0),p=ks(async()=>{if(!n())return;let d=++a.current,S=()=>n()&&d===a.current;if(C({identity:s,raw:null,fetching:!!t,error:null}),!!t)try{l();let h=await t.readContract({address:e.token.address,abi:vs,functionName:"allowance",args:[e.owner,e.spender]});if(!S())return;C({identity:s,raw:h,fetching:!1,error:null})}catch(h){if(!S())return;C({identity:s,raw:null,fetching:!1,error:h instanceof Error?h:new Error("Failed to fetch allowance")})}},[t,e.token.address,e.token.chainId,e.owner,e.spender,s,n,l]);return An(()=>{p().catch(d=>console.warn("useERC20Allowance: initial fetch failed:",d))},[p]),An(()=>(e.refreshInterval&&e.refreshInterval>0&&(r.current=setInterval(p,e.refreshInterval)),()=>{r.current&&(clearInterval(r.current),r.current=null)}),[e.refreshInterval,p]),{allowance:xs(()=>{if(u===null)return null;let d=e.token.decimals;return d===void 0?null:As(u,d)},[u,e.token.decimals]),allowanceRaw:u,isFetching:c,error:g,refetch:p}}import{chainNumber as Rs,createDecimalsCache as Ts,encodeErc20Approve as Is,readDecimals as kt,writeDecimals as In}from"@naculus/connect-appkit-core";import{ERC20_MIN_ABI as Ne,formatUnits as Us,parseUnits as Un,WalletError as _e}from"@naculus/connect-core";import{useCallback as he,useRef as Pn,useState as Wn}from"react";import{WalletError as wt}from"@naculus/connect-core";import{useCallback as Rn,useState as Tn}from"react";function Ce(){let{session:e,chainId:t,client:o}=U(),[s,n]=Tn("idle"),[l,i]=Tn(null),C=Rn(async c=>{if(!e){n("failed");let r=new wt("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 wt("wallet_unavailable","No EVM account found");throw i(r),r}n("awaiting_approval"),i(null);try{let r={...c,from:c.from??g.split(":").pop()},a=O(o);if(!a)throw new wt("wallet_unavailable","Client not initialized");let p=await a.sendTransaction(e,{transaction:r,chainId:t??void 0}),f=Ie(p);return n("submitted"),f}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]),u=Rn(()=>{n("idle"),i(null)},[]);return{sendTransaction:C,status:s,error:l,reset:u,isSending:s==="awaiting_approval"}}function Ps(e){return e.includes(":")?e.split(":").pop():e}var Ws=2n**256n-1n;function Os(e){let{publicClient:t,walletClient:o}=$(),{evmAccount:s,isConnected:n}=B(),{currentChain:l}=V(),{session:i,client:C}=U(),{sendTransaction:u,isSending:c,error:g,reset:r}=Ce(),[a,p]=Wn(null),{identity:f,isCurrent:d,assertCurrent:S}=ae({token:e.token,chainId:l?Rs(l)??void 0:void 0,owner:s,spender:e.spender,connected:n,publicClient:t,walletClient:o,session:i,client:C}),[h,w]=Wn(null),E=h?.identity===f?h.raw:null,R=h?.identity===f&&h.fetching,A=Pn(Ts(e.token,e.token.decimals)),T=Pn(0),v=a??g,x=s?Ps(s):null,b=he(async()=>{if(!d())return null;let y=++T.current,k=()=>d()&&y===T.current;if(w({identity:f,raw:null,fetching:!!t&&!!x&&n}),p(null),!t||!x||!n)return null;try{S();let P=await t.readContract({address:e.token.address,abi:Ne,functionName:"allowance",args:[x,e.spender]});return k()?(w({identity:f,raw:P,fetching:!1}),P):null}catch(P){return k()&&(w({identity:f,raw:null,fetching:!1}),p(P instanceof Error?P:new Error("Failed to fetch allowance"))),null}},[t,x,e.token.address,e.token.chainId,e.spender,f,d,S,n]),I=(()=>{if(E===null)return null;let y=kt(A.current,e.token,e.token.decimals);return y===void 0?null:Us(E,y)})(),W=he(async y=>{if(p(null),r(),!n||!s){let k=new _e("wallet_unavailable","No connected account");throw p(k),k}if(!t){let k=new _e("wallet_unavailable","No public client");throw p(k),k}try{S();let k=Is(e.spender,y),P=O(C);if(i&&P){let _=await u({to:e.token.address,data:k,value:"0"});return b(),_}if(o){let{request:_}=await t.simulateContract({address:e.token.address,abi:Ne,functionName:"approve",args:[e.spender,y],account:x});S();let J=await o.writeContract(_);return b(),J}let N=await u({to:e.token.address,data:k,value:"0"});return b(),N}catch(k){let P=k instanceof Error?k:new Error("Approve failed");throw d()&&p(P),P}},[e,t,o,s,n,i,C,x,u,r,b,S,d]),L=he(async y=>{try{if(S(),!t)throw new _e("wallet_unavailable","No public client");let k=kt(A.current,e.token,e.token.decimals);k===void 0&&(k=await t.readContract({address:e.token.address,abi:Ne,functionName:"decimals"}),S(),In(A.current,e.token,k));let P=Un(y,k);return await W(P)}catch(k){throw d()&&p(k instanceof Error?k:new Error("Approve failed")),k}},[e.token,t,W,S,d]),F=he(async()=>W(Ws),[W]),m=he(async y=>{if(!d()||!n||!x||!t)return!1;try{S()}catch(_){return p(_ instanceof Error?_:new Error("Cannot check allowance")),!1}let k=E??await b();if(k===null)return!1;let P=kt(A.current,e.token,e.token.decimals);if(P===void 0){if(!t)throw new _e("wallet_unavailable","Cannot check allowance: no public client to read token decimals.");if(P=await t.readContract({address:e.token.address,abi:Ne,functionName:"decimals"}),!d())return!1;In(A.current,e.token,P)}let N=Un(y,P);return d()&&k>=N},[E,b,e.token.address,e.token.chainId,e.token.decimals,t,d,S,n,x]);return{approve:L,approveMax:F,allowance:I,allowanceRaw:E,hasAllowance:m,isApproving:c,isFetchingAllowance:R,error:v,refetchAllowance:b}}import{chainNumber as Ns,createDecimalsCache as _s,encodeErc20Transfer as Ds,readDecimals as Ms,writeDecimals as Ls}from"@naculus/connect-appkit-core";import{ERC20_MIN_ABI as On,parseUnits as Bs,WalletError as Nn}from"@naculus/connect-core";import{useCallback as Fs,useRef as Hs,useState as Ks}from"react";function qs(e){return e.includes(":")?e.split(":").pop():e}function Vs(e){let{publicClient:t,walletClient:o}=$(),{evmAccount:s,isConnected:n}=B(),{currentChain:l}=V(),{session:i,client:C}=U(),{sendTransaction:u,isSending:c,error:g,reset:r}=Ce(),[a,p]=Ks(null),{isCurrent:f,assertCurrent:d}=ae({token:e.token,chainId:l?Ns(l)??void 0:void 0,owner:s,connected:n,publicClient:t,walletClient:o,session:i,client:C}),S=Hs(_s(e.token,e.token.decimals)),h=a??g;return{sendTransfer:Fs(async(E,R)=>{if(p(null),r(),!n||!s){let A=new Nn("wallet_unavailable","No connected account");throw p(A),A}if(!t){let A=new Nn("wallet_unavailable","No public client available");throw p(A),A}try{d();let A=qs(s),T=Ms(S.current,e.token,e.token.decimals);T===void 0&&(T=await t.readContract({address:e.token.address,abi:On,functionName:"decimals"}),d(),Ls(S.current,e.token,T));let v=Bs(R,T),x=Ds(E,v),b=O(C);if(i&&b)return await u({to:e.token.address,data:x,value:"0"});if(o){let{request:W}=await t.simulateContract({address:e.token.address,abi:On,functionName:"transfer",args:[E,v],account:A});return d(),await o.writeContract(W)}return await u({to:e.token.address,data:x,value:"0"})}catch(A){let T=A instanceof Error?A:new Error("Transfer failed");throw f()&&p(T),T}},[e.token,t,o,s,n,i,C,u,r,d,f]),isSending:c,error:h}}import{chainNumber as zs,encodeErc20Transfer as Qs}from"@naculus/connect-appkit-core";import{parseUnits as Xs}from"@naculus/connect-core";import{useMemo as Ys}from"react";import{simulateTransactionPreview as $s}from"@naculus/connect-appkit-core";import{useCallback as _n,useEffect as Gs,useRef as js,useState as xt}from"react";function vt(e,t){U();let{evmAccount:o}=B(),{currentChain:s}=V(),{publicClient:n}=$(),[l,i]=xt(void 0),[C,u]=xt(!1),[c,g]=xt(null),r=js(void 0),a=_n(async()=>{e&&(u(!0),g(null));try{let f=await $s(e,{chainId:t,currentChain:s,publicClient:n,evmAccount:o});return i(f),f}catch(f){let d=f instanceof Error?f:new Error("Simulation failed");throw g(d),d}finally{e&&u(!1)}},[e,t,s,n,o]);Gs(()=>{if(e)return r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{a().catch(()=>{})},300),()=>{r.current&&clearTimeout(r.current)}},[e,a]);let p=_n(()=>{i(void 0),g(null),u(!1)},[]);return{result:l,isSimulating:C,error:c,simulate:a,reset:p}}function Js(e){let{evmAccount:t,isConnected:o}=B(),{currentChain:s}=V(),n=e.token.chainId??(s?zs(s)??void 0:void 0),l=Ys(()=>{if(!(!o||!t))try{let C=e.token.decimals;if(C===void 0)return;let u=Xs(e.amount,C),c=Qs(e.to,u);return{to:e.token.address,data:c,value:"0"}}catch{return}},[e.token.address,e.token.decimals,e.to,e.amount,t,o]),i=vt(l,n);return{result:l?i.result:void 0,isSimulating:!!l&&i.isSimulating,error:l?i.error:null,reSimulate:i.simulate,reset:i.reset}}import{useState as At,useCallback as oa,useRef as bt}from"react";import{useState as De,useEffect as Zs,useCallback as Dn,useRef as ea}from"react";import{createContext as ta,useContext as na}from"react";var Mn=ta(null);function ye(){return na(Mn)}function ra(e,t,o){let s=ye(),n=o??s,[l,i]=De(null),[C,u]=De(!1),[c,g]=De(!1),[r,a]=De(null),p=ea(void 0),f=Dn(async()=>{if(!(!n||!e)){u(!0),a(null);try{await n.refreshTx(e,t);let h=n.getTxStatus(e,t);h&&i(h)}catch(h){a(h instanceof Error?h:new Error(String(h)))}finally{u(!1)}}},[n,e,t]),d=Dn(()=>{!n||!e||(n.stopWatching(e,t),g(!1))},[n,e,t]);Zs(()=>{if(!n||!e||!t){i(null),g(!1);return}p.current&&p.current!==e&&n.stopWatching(p.current),p.current=e;let h=!1;g(!0),u(!0),a(null);let w=n.getTxStatus(e,t);w&&(i(w),u(!1)),n.watchTx(e,t,{}).then(R=>{h||(i(R),u(!1))}).catch(R=>{h||(a(R instanceof Error?R:new Error(String(R))),u(!1))});let E=R=>{h||i({...R})};return n.on("statusChange",E),()=>{h=!0,g(!1),n.off("statusChange",E)}},[n,e,t]);let S=l?.status??"idle";return{entry:l,status:S,isLoading:C,isWatching:c,error:r,refresh:f,stopWatching:d}}function sa(e){let t=ye(),o=e??t,[s,n]=At(null),[l,i]=At(null),[C,u]=At(null),c=bt(null),g=bt(null),r=bt(null);o&&(g.current||(g.current=p=>{i(p),(!c.current||p.createdAt>=c.current.createdAt)&&(n(p),c.current=p)},o.on("confirmed",g.current)),r.current||(r.current=p=>{u(p),(!c.current||p.createdAt>=c.current.createdAt)&&(n(p),c.current=p)},o.on("failed",r.current)));let a=oa(()=>{n(null),i(null),u(null),c.current=null},[]);return{lastTx:s,lastConfirmedTx:l,lastFailedTx:C,clear:a}}import{useCallback as ca}from"react";import{useCallback as aa,useEffect as Ln,useMemo as ia,useRef as Bn,useState as Rt}from"react";import{getResolver as la}from"@naculus/connect-appkit-core";function Me({input:e,skip:t=!1,resolverConfig:o,scope:s,query:n}){let[l,i]=Rt(null),[C,u]=Rt(!1),[c,g]=Rt(null),r=Bn(0),a=Bn(!0);Ln(()=>(a.current=!0,()=>{a.current=!1}),[]);let p=ia(()=>la(o),[o]),f=aa(()=>{let d=e.trim();if(!d||t){r.current+=1,i(null),u(!1),g(null);return}let S=++r.current;u(!0),g(null),n(p,d,s).then(h=>{!a.current||S!==r.current||(i(h),u(!1))}).catch(h=>{!a.current||S!==r.current||(g(h instanceof Error?h:new Error(String(h))),i(null),u(!1))})},[e,t,s,p,n]);return Ln(()=>{f()},[f]),{data:l,isLoading:C,error:c,refetch:f}}function ua(e,t){let o=ca((s,n,l)=>s.lookupAddress(n,l),[]);return Me({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,scope:t?.chainId,query:o})}import{useState as Fn,useCallback as Y,useMemo as pa,useEffect as Hn,useRef as da}from"react";import{addInAppNotification as ma,channelsUpdate as fa,clearOneInAppNotification as ga,createNotificationSettingsStorage as Kn,DEFAULT_NOTIFICATION_SETTINGS as Ca,loadNotificationSettings as ha,mutedChainSettings as qn,saveNotificationSettings as ya,updateNotificationSettings as Sa}from"@naculus/connect-appkit-core";import{InAppChannel as Ea}from"@naculus/connect-core";function wa(e){let t=da(null);t.current||(t.current=e?.channel??new Ea);let o=t.current,[s,n]=Fn(()=>o.getHistory()),[l,i]=Fn(()=>Ca);Hn(()=>{let h=e?.storage??Kn();ha(h).then(w=>{w&&i(w)})},[]),Hn(()=>(o.onNotification=h=>{n(w=>[...w,h])},o.restore().then(()=>{n(o.getHistory())}),()=>{o.onNotification=void 0}),[]);let C=pa(()=>s.filter(h=>!h.read).length,[s]),u=Y(()=>{o.clear(),n([])},[o]),c=Y(h=>{ga(o,h).then(()=>{n(o.getHistory())})},[o]),g=Y(h=>{o.markAsRead(h),n(w=>w.map(E=>E.id===h?{...E,read:!0}:E))},[o]),r=Y(()=>{o.markAllAsRead(),n(h=>h.map(w=>({...w,read:!0})))},[o]),a=Y(h=>{ma(o,h)},[o]),p=Y(h=>{i(w=>{let E=Sa(w,h),R=e?.storage??Kn();return ya(R,E),E})},[e?.storage]),f=Y(h=>{p(fa(h))},[p]),d=Y(h=>{p(qn(l,h,!0))},[l.mutedChains,p]),S=Y(h=>{p(qn(l,h,!1))},[l.mutedChains,p]);return{notifications:s,unreadCount:C,addNotification:a,clear:u,clearOne:c,markAsRead:g,markAllAsRead:r,settings:l,updateSettings:p,setChannels:f,muteChain:d,unmuteChain:S}}import{useCallback as Tt,useSyncExternalStore as ka}from"react";var Vn=()=>null,xa=()=>()=>{};function va(){let{client:e}=U(),t=O(e)?.passphraseGate??null,o=ka(t?.subscribe??xa,t?.getSnapshot??Vn,Vn),s=Tt(i=>t?.submit(i),[t]),n=Tt(()=>t?.cancel(),[t]),l=Tt(i=>t?.forget(i),[t]);return{request:o,submit:s,cancel:n,forget:l,isUnlocked:t?.isUnlocked??!1,gate:t}}import{useCallback as Aa}from"react";function ba(e,t){let o=Aa((s,n)=>s.resolveName(n),[]);return Me({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,query:o})}import{assertHexSignature as It,bareEvmAddress as Ra,buildSmartAccountConfig as Ta,resolveUserOpChain as Ia}from"@naculus/connect-appkit-core";import{WalletError as ie}from"@naculus/connect-core";import{useCallback as $n,useEffect as Gn,useRef as jn,useState as Se}from"react";async function Ua(e,t,o,s,n){let l=O(t);if(!l)throw new ie("wallet_unavailable","Client not initialized");let i=[o,s];if(e.walletType==="eip6963"||e.id?.startsWith("eip6963-")){let{eip6963Connector:C}=await import("@naculus/connector-evm-injected"),u=C.getDiscoveredWallets().find(g=>g.id===e.walletId),c=u?await u.provider.request({method:"personal_sign",params:i}):await C.request({method:"personal_sign",params:i});return It(c)}if(e.walletType==="walletconnect")return It(await l.connector.request({method:"personal_sign",params:i}));if(e.walletType==="embedded"){let C=l.embeddedConnector;if(!C?.signHash)throw new ie("method_unsupported","This embedded wallet build cannot sign a raw digest. Upgrade @naculus/connector-embedded or pass an explicit signer.");return It(await C.signHash(e,o))}throw e.walletType==="passkeys"?new ie("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 ie("method_unsupported",`Raw UserOperation signing is not available for ${e.walletType} on ${n}. Pass a signer that signs the raw 32-byte hash.`)}function Pa(e){let{evmAccount:t}=B(),{session:o,chainId:s,client:n}=U(),[l,i]=Se(null),[C,u]=Se(null),[c,g]=Se(!1),[r,a]=Se(!1),[p,f]=Se(null),d=jn(0),S=jn(!1);Gn(()=>()=>{d.current+=1,S.current=!1},[]),Gn(()=>{d.current+=1,S.current=!1,i(null),u(null),g(!1),a(!1),f(null)},[n,s,t,e?.accountType,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.owner,e?.rpcUrl,e?.salt,e?.signerMode,o]);let h=$n(async(E,R)=>{let A=b=>(f(b),null);if(!e?.rpcUrl)return A(new Error("RPC URL not configured"));if(!e.bundlerUrl)return A(new Error("Bundler URL not configured"));if(!E.length)return A(new Error("At least one call is required"));if(S.current)return A(new Error("A UserOperation is already in progress"));let T=Ra(e.owner??t);if(!T)return A(new ie("wallet_unavailable","No EVM account found"));let v;try{v=Ia(e.chainId,s)}catch(b){return A(b)}if(!e.signer&&!o)return A(new ie("wallet_unavailable","No active session"));let x=++d.current;S.current=!0,g(!0),a(!0),f(null),i(null),u(null);try{let{SmartAccountManager:b}=await import("@naculus/connect-core"),I=e.signer??(m=>Ua(o,n,m,T,v)),W=new b({rpcUrl:e.rpcUrl,bundlerClient:{url:e.bundlerUrl},chainId:v,signer:I,signerMode:e.signer?e.signerMode??"eip191":"raw"}),L=Ta(T,v,e),F=await W.sendUserOperation(L,E,R);return x!==d.current?null:(a(!1),i(F.userOpHash),W.getUserOperationReceipt(F.userOpHash).then(m=>{x===d.current&&u(m)}).catch(()=>{}),F)}catch(b){if(x!==d.current)return null;let I=b instanceof Error?b:new Error("Failed to send UserOperation");return f(I),null}finally{S.current=!1,x===d.current&&(g(!1),a(!1))}},[n,s,t,e,o]),w=$n(()=>{d.current+=1,i(null),u(null),g(!1),a(!1),f(null)},[]);return{sendUserOp:h,userOpHash:l,receipt:C,isPending:c,isEstimating:r,error:p,reset:w}}import{useSyncExternalStore as Wa,useCallback as zn}from"react";function Oa(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 Ut=Object.freeze({session:null,chainSessions:[],activeChainId:null,isConnected:!1,connectorId:null}),Pt=new WeakMap;function Na(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 _a(e){if(!e)return Ut;let t=e.getActiveBundle(),o=Pt.get(e);if(!t)return o&&o.session===null?o:(Pt.set(e,Ut),Ut);let s=Array.from(t.chainSessions.values());if(o&&o.session===t.walletSession&&o.activeChainId===t.activeChainId&&Na(o.chainSessions,s))return o;let n={session:t.walletSession,chainSessions:s,activeChainId:t.activeChainId,isConnected:!0,connectorId:t.walletSession.walletType};return Pt.set(e,n),n}function Da(e){let t=U(),o=e??t.sessionManager??null,s=zn(l=>Oa(o,l),[o]),n=zn(()=>_a(o),[o]);return Wa(s,n)}import{defaultSiwxDomain as Ma,defaultSiwxUri as La}from"@naculus/connect-appkit-core";import{WalletError as Le}from"@naculus/connect-core";import{createSiwxMessage as Ba,generateNonce as Fa,getBlockchainName as Ha,issueNonce as Ka,nowISO as qa}from"@naculus/siwx";import{useCallback as Qn,useState as Xn}from"react";var Va=86400;function Wt(){let{session:e,chainId:t,client:o}=U(),[s,n]=Xn(!1),[l,i]=Xn(null),C=Qn(()=>i(null),[]);return{signIn:Qn(async c=>{if(!e)throw new Le("wallet_unavailable","No active session");let g=c?.chainId??t;if(!g)throw new Le("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let r=oe(e,g);if(!r)throw new Le("wallet_unavailable","No account found");let a=O(o);if(!a)throw new Le("wallet_unavailable","Client not initialized");let{address:p}=r,f=typeof window>"u"?void 0:window.location,d=c?.domain??Ma(f),S=c?.uri??La(f);n(!0),i(null);try{let h=Fa();await Ka(h);let w=qa(),E=c?.expirySeconds??Va,R=new Date(Date.now()+E*1e3).toISOString(),A=Ba({domain:d,address:p,uri:S,version:1,chainId:g,nonce:h,issuedAt:w,expirationTime:R,statement:c?.statement,resources:c?.resources,requestId:c?.requestId}),T=await a.signMessage(e,{message:A,address:p,chainId:g??void 0}),v={message:{raw:A,domain:d,address:p,statement:c?.statement??null,uri:S,version:1,chainId:g,nonce:h,issuedAt:w,blockchain:Ha(g),expirationTime:R,notBefore:null,resources:c?.resources??[],requestId:c?.requestId??null},signature:T};return n(!1),v}catch(h){let w=h instanceof Error?h:new Error("SIWx sign-in failed");throw i(w),n(!1),w}},[e,t,o]),isSigningIn:s,error:l,clearError:C}}import{siwxResultToSession as Yn}from"@naculus/connect-appkit-core";import{logger as Ot}from"@naculus/connect-core";import{checkSessionExpired as Jn,createLocalStorageSiwxSessionStorage as $a}from"@naculus/siwx";import{useCallback as Be,useEffect as Zn,useRef as Ga,useState as Fe}from"react";function ja(e){let{storagePrefix:t="naculus_",autoRestore:o=!0,defaultExpirySeconds:s=86400}=e??{},[n,l]=Fe(null),[i,C]=Fe(o),[u,c]=Fe(!1),[g,r]=Fe(null),{session:a,chainId:p}=U(),f=Wt(),d=Ga($a(`${t}siwx_session`)),S=Be(()=>r(null),[]);Zn(()=>{if(!o){C(!1);return}let v=!1;return(async()=>{try{let b=await d.current.get();if(v)return;b?(Ot.info("react/useSIWxSession","Restored persisted SIWx session"),l(b),r(null)):l(null)}catch(x){Ot.warn("react/useSIWxSession","Failed to restore SIWx session:",x),l(null)}finally{v||C(!1)}})(),()=>{v=!0}},[o]),Zn(()=>{if(!n?.expiresAt)return;let v=new Date(n.expiresAt).getTime()-Date.now();if(v<=0){l(null);return}let x=setTimeout(()=>{l(b=>b&&b.id===n.id?null:b)},v);return()=>clearTimeout(x)},[n?.id,n?.expiresAt]);let h=Be(async v=>{c(!0),r(null);try{let x={expirySeconds:s,chainId:p??void 0,...v},b=await f.signIn(x),I=Yn(b);return await d.current.set(I),l(I),c(!1),I}catch(x){let b=x instanceof Error?x:new Error("SIWx sign-in failed");throw r(b),c(!1),b}},[f,p,s]),w=Be(async()=>{try{await d.current.remove()}catch(v){Ot.warn("react/useSIWxSession","Failed to clear session:",v)}l(null),r(null)},[]),E=Be(async()=>{if(!n)throw new Error("No active session to refresh");c(!0),r(null);try{let v=await f.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}),x={...Yn(v),id:n.id,refreshedAt:new Date().toISOString()};return await d.current.set(x),l(x),c(!1),x}catch(v){let x=v instanceof Error?v:new Error("Session refresh failed");throw r(x),c(!1),x}},[n,f,s]),R=n!==null&&!Jn(n),A=Jn(n),T=n?.expiresAt?Math.max(0,new Date(n.expiresAt).getTime()-Date.now()):null;return{session:R?n:null,isAuthenticated:R,isRestoring:i,isSigningIn:u,isExpired:A,timeUntilExpiry:T,signIn:h,signOut:w,refresh:E,error:g,clearError:S}}import{defaultSiwxDomain as za,defaultSiwxUri as Qa}from"@naculus/connect-appkit-core";import{WalletError as He}from"@naculus/connect-core";import{createSiwxMessage as Xa,generateNonce as Ya,getBlockchainName as Ja,issueNonce as Za,nowISO as ei}from"@naculus/siwx";import{useCallback as er,useState as Nt}from"react";function Ee(){let{session:e,chainId:t,client:o}=U(),[s,n]=Nt(!1),[l,i]=Nt(null),[C,u]=Nt(null),c=er(()=>u(null),[]);return{signIn:er(async r=>{if(!e)throw new He("wallet_unavailable","No active session");let a=r?.chainId??t;if(!a)throw new He("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let p=oe(e,a);if(!p)throw new He("wallet_unavailable","No account found");let f=O(o);if(!f)throw new He("wallet_unavailable","Client not initialized");let{address:d}=p,S=typeof window>"u"?void 0:window.location,h=r?.domain??za(S),w=r?.uri??Qa(S);n(!0),u(null);try{let E=Ya();await Za(E);let R=ei(),A=Xa({domain:h,address:d,uri:w,version:1,chainId:a,nonce:E,issuedAt:R,statement:r?.statement,expirationTime:r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():void 0,resources:r?.resources,requestId:r?.requestId}),T=await f.signMessage(e,{message:A,address:d,chainId:a??void 0}),v=r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():null,x={message:{raw:A,domain:h,address:d,statement:r?.statement??null,uri:w,version:1,chainId:a,nonce:E,issuedAt:R,blockchain:Ja(a),expirationTime:v,notBefore:null,resources:r?.resources??[],requestId:r?.requestId??null},signature:T};return i(x),x}catch(E){let R=E instanceof Error?E:new Error("SIWx sign-in failed");throw u(R),R}finally{n(!1)}},[e,t,o]),isSigningIn:s,result:l,error:C,clearError:c}}import{WalletError as _t}from"@naculus/connect-core";import{useCallback as tr}from"react";function ti(){let{session:e,chainId:t}=U();return tr(o=>{if(!e)throw new _t("wallet_unavailable","No active session");let s=o??t;if(s&&!s.startsWith("eip155:"))throw new _t("namespace_mismatch",`Ethereum SIWx requires an eip155 chain, received ${s}`);let n=e.namespaces.eip155;if(!n||n.accounts.length===0)throw new _t("namespace_mismatch","No EVM (eip155) accounts found in session")},[e,t])}function ni(){let e=ti(),t=Ee();return{signIn:tr(async s=>(e(s?.chainId),t.signIn(s)),[e,t.signIn]),isSigningIn:t.isSigningIn,result:t.result,error:t.error,clearError:t.clearError}}import{resolveSimulationEndpoint as ri}from"@naculus/connect-appkit-core";import{SimulationManager as oi}from"@naculus/wallet-engine";import{useCallback as Dt,useRef as si,useState as Mt}from"react";function ai(e){let t=e?.rpcUrl,o=e?.chainId,s=si(null),n=Dt(()=>(s.current||(s.current=new oi({enabled:!0,rpcUrl:t,autoSimulate:!1})),s.current),[t]),[l,i]=Mt(null),[C,u]=Mt(!1),[c,g]=Mt(null),r=Dt(async(p,f,d,S,h)=>{u(!0),g(null);try{let w=n(),E=ri(h?.chainId,o,h?.rpcUrl,t),R=await w.simulateERC20Transfer(p,f,d,S,E.chainId,h?.decimals,E.rpcUrl);return i(R),R}catch(w){let E=w instanceof Error?w:new Error(String(w));throw g(E),E}finally{u(!1)}},[t,o,n]),a=Dt(()=>{i(null),g(null),u(!1)},[]);return{result:l,loading:C,error:c,simulate:r,reset:a}}import{isSiwxExpired as ii,isSiwxNotBeforeValid as li}from"@naculus/connect-appkit-core";import{LocalStorageAdapter as ci,logger as Ke}from"@naculus/connect-core";import{useCallback as Lt,useEffect as ui,useRef as pi,useState as qe}from"react";var Ve="siwx_auth";function di(e){return new ci(e)}function mi(e){let{storagePrefix:t="naculus_",autoRestore:o=!0}=e??{},[s,n]=qe(null),[l,i]=qe(o),[C,u]=qe(!1),[c,g]=qe(null),r=Ee(),a=pi(di(t)),p=Lt(()=>g(null),[]);ui(()=>{if(!o){i(!1);return}let S=!1;return(async()=>{try{let h=a.current,w=await h.get(Ve);if(S)return;w&&!ii(w,new Date)&&li(w,new Date)?(Ke.info("react/useSiwxAuthSession","Restored persisted SIWx auth session"),n(w),g(null)):w&&(Ke.info("react/useSiwxAuthSession","Persisted SIWx auth expired, clearing"),await h.remove(Ve))}catch(h){Ke.warn("react/useSiwxAuthSession","Failed to restore SIWx auth:",h)}finally{S||i(!1)}})(),()=>{S=!0}},[o]);let f=Lt(async S=>{u(!0),g(null);try{let h=await r.signIn(S);return await a.current.set(Ve,h),n(h),u(!1),h}catch(h){let w=h instanceof Error?h:new Error("SIWx sign-in failed");throw g(w),u(!1),w}},[r]),d=Lt(async()=>{try{await a.current.remove(Ve)}catch(S){Ke.warn("react/useSiwxAuthSession","Failed to clear SIWx auth:",S)}n(null),g(null)},[]);return{isSignedIn:s!==null,isRestoring:l,siwxResult:s,isSigningIn:C,error:c,signIn:f,signOut:d,clearError:p}}import{bareEvmAddress as fi,buildSmartAccountConfig as gi,resolveEvmChainId as nr}from"@naculus/connect-appkit-core";import{WalletError as sr}from"@naculus/connect-core";import{useCallback as ne,useEffect as rr,useRef as Bt,useState as we}from"react";function or(e){return new sr("wallet_unavailable",e)}function Ci(e){let{evmAccount:t}=B(),{session:o,chainId:s,client:n}=U(),[l,i]=we(null),[C,u]=we(!1),[c,g]=we(null),[r,a]=we(!1),[p,f]=we(null),d=Bt(null),S=Bt(0),h=Bt(!1);rr(()=>{if(d.current=null,!e?.rpcUrl)return;let b=!1;return import("@naculus/connect-core").then(({SmartAccountManager:I})=>{if(b)return;let W=nr(e.chainId,s);W&&(d.current=new I({rpcUrl:e.rpcUrl,chainId:W,bundlerClient:{url:e.bundlerUrl??""}}))}).catch(I=>{b||f(I instanceof Error?I:new Error("Failed to load account-abstraction module"))}),()=>{b=!0}},[s,e?.rpcUrl,e?.bundlerUrl,e?.chainId]),rr(()=>{S.current+=1,h.current=!1,i(null),u(!1),g(null),a(!1),f(null)},[t,s,e?.rpcUrl,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.accountType,e?.salt]);let w=ne(()=>{let b=fi(t);if(!b||!d.current)return null;let I=nr(e?.chainId,s);return I?gi(b,I,{accountType:e?.accountType,entryPoint:e?.entryPoint,salt:e?.salt}):null},[t,s,e?.accountType,e?.chainId,e?.entryPoint,e?.salt]),E=ne(b=>(f(b),null),[]),R=ne(()=>h.current?null:(h.current=!0,S.current),[]),A=ne(b=>{S.current===b&&(h.current=!1)},[]),T=ne(async()=>{let b=w();if(!b||!d.current)return E(new Error("Smart account not configured"));let I=R();if(I===null)return E(new Error("Smart account operation already in progress"));a(!0),f(null);try{let L=await d.current.createAccount(b);return S.current!==I?null:(i(L.address),u(L.isDeployed),g(L),L)}catch(W){if(S.current!==I)return null;let L=W instanceof Error?W:new Error("Failed to create smart account");return f(L),null}finally{S.current===I&&a(!1),A(I)}},[R,E,A,w]),v=ne(async()=>{let b=w();if(!b||!d.current)return E(new Error("Smart account not configured"));if(!o)return E(or("No active session"));let I=O(n);if(!I)return E(or("Client not initialized"));if(s&&s!==b.chainId)return E(new sr("chain_mismatch",`Connected chain ${s} does not match smart account chain ${b.chainId}.`));let W=R();if(W===null)return E(new Error("Smart account operation already in progress"));a(!0),f(null);try{let L=d.current,F=await L.createAccount(b);if(S.current!==W)return null;if(F.isDeployed)return i(F.address),u(!0),g(F),F.address;let m=await L.getDeployCallData(b),y=await I.sendTransaction(o,{transaction:{to:m.to,data:m.data,value:m.value.toString()},chainId:b.chainId});if(S.current!==W)return null;let k=await L.createAccount(b);return i(k.address),u(k.isDeployed),g(k),y}catch(L){if(S.current!==W)return null;let F=L instanceof Error?L:new Error("Failed to deploy smart account");return f(F),null}finally{S.current===W&&a(!1),A(W)}},[n,s,R,E,A,w,o]),x=ne(async()=>{let b=w();if(!b||!d.current)return null;let I=S.current;try{let W=await d.current.getAccountAddress(b);return S.current!==I?null:(i(W),W)}catch(W){return S.current!==I||f(W instanceof Error?W:new Error("Failed to get smart account address")),null}},[w]);return{address:l,isDeployed:C,accountInfo:c,isLoading:r,error:p,createWallet:T,deployWallet:v,getAddress:x}}import{useMemo as hi}from"react";function Ft(){let{accounts:e,isConnected:t}=U();return hi(()=>{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,l=s.length>=3?s.slice(0,-1).join(":"):null;return{address:n,caip10:o,chainId:l,isConnected:t}},[e,t])}import{useCallback as yi,useEffect as ar,useRef as Si,useState as Ht}from"react";import{getSolanaBalance as Ei}from"@naculus/connect-core";function wi(e={}){let{client:t}=U(),{address:o}=Ft(),s=e.address??o,n=e.rpcUrl??O(t)?.solanaRpcUrl??null,[l,i]=Ht(null),[C,u]=Ht(!1),[c,g]=Ht(null),r=Si(0),a=yi(async()=>{if(!s||!n){i(null);return}let p=++r.current;u(!0),g(null);try{let f=await Ei(n,s);if(p!==r.current)return;i(f)}catch(f){if(p!==r.current)return;i(null),g(f instanceof Error?f:new Error("Balance read failed"))}finally{p===r.current&&u(!1)}},[s,n]);return ar(()=>{a()},[a]),ar(()=>{if(!e.refreshInterval||e.refreshInterval<=0)return;let p=setInterval(()=>{a()},e.refreshInterval);return()=>clearInterval(p)},[e.refreshInterval,a]),{balance:l,isFetching:C,error:c,isConfigured:!!n,refetch:a}}import{readSolanaRoles as ki}from"@naculus/connect-appkit-core";import{useMemo as xi}from"react";function vi(){let{client:e,session:t,accounts:o}=U();return xi(()=>{let s=O(e)?.solanaConnector,{roles:n,absence:l}=ki(s,t);return{roles:n,absence:l,identity:n?.identity??null,signer:n?.signer??null,payer:n?.payer??null}},[e,t,o])}import{WalletError as ir}from"@naculus/connect-core";import{useCallback as Kt,useState as qt}from"react";import{getSignatureStatus as Ai}from"@naculus/connect-core";function bi(){let{client:e,session:t}=U(),[o,s]=qt(!1),[n,l]=qt(!1),[i,C]=qt(null),u=()=>{let a=O(e);if(!a||!t)throw new ir("wallet_unavailable","No connected wallet.");return a},c=Kt(async a=>{s(!0),C(null);try{return await u().signTransaction(t,{transaction:a})}catch(p){let f=p instanceof Error?p:new Error("Signing failed");throw C(f),f}finally{s(!1)}},[e,t]),g=Kt(async a=>{l(!0),C(null);try{return await u().sendTransaction(t,{transaction:a})}catch(p){let f=p instanceof Error?p:new Error("Send failed");throw C(f),f}finally{l(!1)}},[e,t]),r=Kt(async a=>{let p=O(e)?.solanaRpcUrl;if(!p)throw new ir("no_rpc","Set solanaRpcUrl on the client to read a signature's status.");return Ai(p,a)},[e]);return{signTransaction:c,sendTransaction:g,getStatus:r,isSigning:o,isSending:n,error:i,reset:()=>C(null)}}import{useCallback as lr,useState as cr}from"react";import{toChainSwitchError as Ri}from"@naculus/connect-appkit-core";function Ti(){let{switchChain:e,chainId:t}=U(),[o,s]=cr(!1),[n,l]=cr(null),i=lr(async u=>{s(!0),l(null);try{await e(u)}catch(c){let g=Ri(c);throw l(g),g}finally{s(!1)}},[e]),C=lr(()=>{l(null)},[]);return{switchChain:i,isSwitching:o,currentChainId:t,error:n,clearError:C}}import{chainNumber as Ii,resolveChain as Ui,toViemChain as Pi}from"@naculus/connect-appkit-core";import{useState as $e,useEffect as Vt,useCallback as ur,useMemo as $t,useRef as Wi}from"react";import{createPublicClient as Oi,http as Ni,formatUnits as _i}from"viem";function Di(e){let{evmAccount:t,isConnected:o}=B(),{chainId:s,chains:n}=U(),[l,i]=$e([]),[C,u]=$e(!1),[c,g]=$e(null),{tokens:r,refreshInterval:a}=e,p=Wi(null),f=$t(()=>r.map(v=>v.address.toLowerCase()+"|"+v.decimals+"|"+v.symbol).join(","),[r]),d=$t(()=>Ui(n,s),[s,n]),S=d?Ii(d):null,h=$t(()=>d?Pi(d,S):null,[d,S]),[w,E]=$e(null);Vt(()=>{if(!h||!d?.rpcUrl){E(null);return}let v=Oi({transport:Ni(d.rpcUrl),chain:h});E(v)},[d,h]);let R=[{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"balance",type:"uint256"}]}],A=ur(async()=>{if(!t||!w||r.length===0){i([]);return}u(!0),g(null);try{let v=t.includes(":")?t.split(":").pop():t,b=(await Promise.allSettled(r.map(async I=>{try{let W=await w.readContract({address:I.address,abi:R,functionName:"balanceOf",args:[v]});return{address:I.address,symbol:I.symbol,decimals:I.decimals,name:I.name,balance:W.toString(),formatted:_i(W,I.decimals)}}catch{return{address:I.address,symbol:I.symbol,decimals:I.decimals,name:I.name,balance:null,formatted:null}}}))).map(I=>I.status==="fulfilled"?I.value:{address:"",symbol:"?",decimals:0,balance:null,formatted:null});i(b)}catch(v){g(v instanceof Error?v:new Error("Failed to fetch token balances"))}finally{u(!1)}},[t,w,f]);Vt(()=>{o&&t&&r.length>0&&A()},[o,t,f,A]),Vt(()=>(a&&a>0&&o&&t&&r.length>0&&(p.current=setInterval(A,a)),()=>{p.current&&(clearInterval(p.current),p.current=null)}),[a,o,t,f,A]);let T=ur(v=>l.find(x=>x.address.toLowerCase()===v.toLowerCase()),[l]);return{tokenBalances:l,isLoading:C,error:c,refetch:A,getTokenBalance:T,chain:d}}import{useState as Gt,useEffect as pr,useCallback as Mi,useRef as Li}from"react";function Bi(e,t,o){let s=ye(),n=o??s,[l,i]=Gt([]),[C,u]=Gt(!1),[c,g]=Gt(null),r=Li(0),a=Mi(async()=>{if(n){u(!0),g(null),r.current++;try{let f=await n.getTxHistory(e,t);i(f)}catch(f){g(f instanceof Error?f:new Error(String(f)))}finally{u(!1)}}},[n,e,t]);pr(()=>{a().catch(()=>{})},[a]),pr(()=>{if(!n)return;let f=()=>{a().catch(()=>{})};return n.on("statusChange",f),()=>{n.off("statusChange",f)}},[n,a]);let p={pending:l.filter(f=>f.status==="pending").length,confirmed:l.filter(f=>f.status==="confirmed").length,failed:l.filter(f=>f.status==="failed").length};return{entries:l,isLoading:C,error:c,refresh:a,summary:p}}import{fetchUserOperationReceipt as Fi,InvalidUserOperationReceiptError as Hi}from"@naculus/connect-appkit-core";import{useCallback as ke,useEffect as dr,useRef as le,useState as re}from"react";function Ki(e){let t=e?.bundlerUrl,o=e?.pollInterval??2e3,s=e?.maxRetries??30,[n,l]=re("idle"),[i,C]=re(null),[u,c]=re(e?.userOpHash??null),[g,r]=re(null),[a,p]=re(!1),[f,d]=re(0),S=le(0),[h,w]=re(0),E=le(null),R=le(null),A=le(0),T=le(0),v=le(null),x=ke(()=>{E.current&&(clearInterval(E.current),E.current=null),R.current&&(clearTimeout(R.current),R.current=null)},[]),b=ke(async(F,m)=>{if(!t||m!==A.current)return;let y=T.current+1;T.current=y,d(y);let k=new AbortController;v.current=k;let P=_=>{m===A.current&&(l("not_found"),p(!1),x(),r(_))},N=_=>{if(m===A.current){if(y<=s){R.current=setTimeout(()=>{b(F,m)},o);return}P(_)}};try{let _=await Fi(t,F,k.signal);if(m!==A.current)return;if(_){C(_),l(_.success?"confirmed":"failed"),p(!1),x();return}l("pending"),N(new Error("UserOperation not included after maximum retries"))}catch(_){if(m!==A.current||k.signal.aborted)return;let J=_ instanceof Error?_:new Error("Unknown bundler response failure");if(J instanceof Hi){P(J);return}N(new Error(`UserOperation status unavailable after ${y} attempt${y===1?"":"s"}: ${J.message}`))}finally{v.current===k&&(v.current=null)}},[t,o,s,x]),I=ke(F=>{A.current+=1;let m=A.current;if(v.current?.abort(),v.current=null,x(),c(F),C(null),r(null),T.current=0,d(0),w(0),S.current=Date.now(),!t){l("not_found"),p(!1),r(new Error("Bundler URL not configured"));return}l("pending"),p(!0),E.current=setInterval(()=>{w(Date.now()-S.current)},1e3),b(F,m)},[t,x,b]),W=ke(()=>{A.current+=1,v.current?.abort(),v.current=null,x(),p(!1)},[x]),L=ke(()=>{A.current+=1,v.current?.abort(),v.current=null,x(),c(null),l("idle"),C(null),r(null),p(!1),T.current=0,d(0),w(0)},[x]);return dr(()=>{e?.userOpHash&&e?.autoStart!==!1&&I(e.userOpHash)},[]),dr(()=>()=>{A.current+=1,v.current?.abort(),v.current=null,x()},[x]),{status:n,receipt:i,userOpHash:u,error:g,isPolling:a,elapsedMs:h,attempts:f,start:I,stop:W,reset:L}}import{validateDestination as ji}from"@naculus/connect-appkit-core";import{useMemo as zi}from"react";var qi={"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."},Vi={"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"},mr={en:qi,zh:Vi},jt="en";function $i(e){jt=e}function Gi(){return jt}function zt(e){return mr[jt][e]??mr.en[e]??e}function fr(e){let{isValid:t,level:o,issue:s}=ji(e);return{isValid:t,level:o,warning:s?zt(`address.${s}`):null}}function Qi({address:e}){return{validation:zi(()=>fr(e),[e])}}function Xi(){let{status:e,session:t,accounts:o,chainId:s,error:n,connect:l,disconnect:i,reconnect:C,switchChain:u}=U(),c=e==="connected",g=e==="connecting",r=e==="reconnecting",a=o[0]??null;return{status:e,session:t,accounts:o,chainId:s,error:n,isConnected:c,isConnecting:g,isReconnecting:r,isDisconnected:e==="disconnected",currentAccount:a,connect:l,disconnect:i,reconnect:C,switchChain:u}}import{useCallback as Xt,useMemo as hr}from"react";var gr={wallet_unavailable:"Wallet Not Detected",user_rejected:"Connection Rejected",deeplink_timeout:"Wallet Connection Timed Out",session_expired:"Session Expired",intent_expired:"Connection Request Expired",namespace_mismatch:"Network Mismatch",chain_unsupported:"Unsupported Network",method_not_allowed:"Action Not Allowed",signature_rejected:"Signature Rejected",tx_failed:"Transaction Failed"},Cr={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."},xe="Something went wrong",ve="An unexpected error occurred. Please try again. If the problem persists, check your connection and wallet configuration.";function Ae(e){if(!e)return{title:xe,description:ve};let t=e;if(t.name==="WalletError"&&t.code){let o=t.code,s=gr[o]??xe,n=Cr[o]??t.message??ve;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:xe,description:o||ve}}return typeof e=="string"?{title:xe,description:e||ve}:{title:xe,description:ve}}function Qt(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 Yi(){let{error:e,clearError:t}=U(),o=hr(()=>e?Ae(e):null,[e]),s=hr(()=>e?Qt(e):!1,[e]),n=Xt(()=>{t()},[t]),l=Xt(C=>Ae(C),[]),i=Xt(C=>async()=>{try{return await C()}catch(u){let c=Ae(u);if(u instanceof Error){let g=u;try{g.title=c.title,g.friendlyMessage=c.description,g.code===void 0&&c.code!==void 0&&(g.code=c.code)}catch{}throw g}throw Object.assign(new Error(c.description,{cause:u}),{title:c.title,code:c.code,friendlyMessage:c.description})}},[]);return{error:e,friendlyError:o,clearError:n,isRetryable:s,formatError:l,wrapAsync:i}}import{useState as Ge,useEffect as Ji,useCallback as yr,useRef as Zi}from"react";import{TokenListManager as el}from"@naculus/connect-core";import{eip155ChainIdToNumber as Sr}from"@naculus/connect-appkit-core";function je(e,t){let o=Zi(null),[s,n]=Ge([]),[l,i]=Ge(t?.autoLoad!==!1),[C,u]=Ge(!1),[c,g]=Ge(null);if(!o.current){let p={};t?.sources&&(p.sources=t.sources),o.current=new el(p)}let r=yr(async()=>{let p=o.current;if(p){i(!0),g(null);try{await p.load();let f=e?Sr(e):void 0,d=p.getTokens(f!==void 0?{chainId:f}:void 0);n(d),u(!0)}catch(f){g(f instanceof Error?f:new Error(String(f)))}finally{i(!1)}}},[e]),a=yr(async()=>{let p=o.current;if(p){i(!0),g(null);try{await p.refresh();let f=e?Sr(e):void 0,d=p.getTokens(f!==void 0?{chainId:f}:void 0);n(d),u(!0)}catch(f){g(f instanceof Error?f:new Error(String(f)))}finally{i(!1)}}},[e]);return Ji(()=>{t?.autoLoad!==!1&&r()},[r,t?.autoLoad]),{tokens:s,isLoading:l,isLoaded:C,error:c,refetch:a}}import{useState as wr,useEffect as al,useRef as il}from"react";import{TokenListManager as ll}from"@naculus/connect-core";import{ETHEREUM_MAINNET_TOKENS as tl,POLYGON_TOKENS as nl,OPTIMISM_TOKENS as rl,ARBITRUM_TOKENS as ol,BASE_TOKENS as sl}from"@naculus/connect-core";function Er(){return[{name:"built-in",tokens:[...tl,...nl,...rl,...ol,...sl],enabled:!0},{name:"uniswap-default",url:"https://tokens.uniswap.org",enabled:!0,refreshInterval:1440*60*1e3}]}import{eip155ChainIdToNumber as cl}from"@naculus/connect-appkit-core";var ul=300,ze=null;function pl(){return ze||(ze=new ll({sources:Er()}),ze.load().catch(()=>{})),ze}function Qe(e,t){let[o,s]=wr({exact:[],fuzzy:[],hasMore:!1}),[n,l]=wr(!1),i=il(null),C=e.trim();return al(()=>{if(!C){s({exact:[],fuzzy:[],hasMore:!1}),l(!1);return}return i.current&&clearTimeout(i.current),l(!0),i.current=setTimeout(()=>{let u=pl(),c=t?cl(t):void 0,g=u.search(C,{chainId:c,limit:20});s(g),l(!1)},ul),()=>{i.current&&clearTimeout(i.current)}},[C,t]),{results:o,isSearching:n}}import Yt,{useCallback as dl}from"react";import{Fragment as ml,jsx as G,jsxs as j}from"react/jsx-runtime";function kr({chainId:e,onSelect:t,onClose:o,options:s}){let[n,l]=Yt.useState(""),{tokens:i,isLoading:C,error:u}=je(e),{results:c,isSearching:g}=Qe(n,n?e:void 0),r=s?.showRecommendations??!0,a=Yt.useMemo(()=>{if(n.trim()){let S=[...c.exact,...c.fuzzy].map(h=>h.token);return s?.filter?S.filter(s.filter):S}let d=i;return s?.filter?d.filter(s.filter):d},[n,c,i,s?.filter]),p=Yt.useMemo(()=>!r||n.trim()?[]:i.slice(0,6),[i,r,n]),f=dl(d=>{t(d),o()},[t,o]);return j("div",{style:{background:"hsl(var(--background))",borderRadius:"12px",padding:"16px",color:"hsl(var(--foreground))",minWidth:"320px",maxWidth:"400px",fontFamily:"system-ui, sans-serif"},children:[j("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[G("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Select Token"}),G("button",{onClick:o,style:{background:"none",border:"none",color:"hsl(var(--muted-foreground))",cursor:"pointer",fontSize:"18px",padding:"4px 8px"},children:"\u2715"})]}),G("input",{type:"text",placeholder:"Search token name or paste address",value:n,onChange:d=>l(d.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}),C&&!g&&G("div",{style:{textAlign:"center",padding:"20px",color:"hsl(var(--muted-foreground))"},children:"Loading tokens..."}),u&&j("div",{style:{textAlign:"center",padding:"12px",color:"hsl(var(--destructive))",fontSize:"13px"},children:["Error: ",u.message]}),r&&p.length>0&&!n.trim()&&j("div",{style:{marginBottom:"12px"},children:[G("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},children:"Popular"}),G("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:p.map(d=>j("button",{onClick:()=>f(d),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:[d.logoURI?G("img",{src:d.logoURI,alt:"",style:{width:"16px",height:"16px",borderRadius:"50%"},onError:S=>{S.target.style.display="none"}}):null,d.symbol]},`${d.chainId}:${d.address}`))})]}),n.trim()&&!C&&G("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",marginBottom:"8px"},children:a.length>0?j(ml,{children:[c.exact.length," exact, ",c.fuzzy.length," fuzzy",c.hasMore?" (more available)":""]}):"No results found"}),G("div",{style:{maxHeight:"320px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"2px"},children:a.map(d=>j("button",{onClick:()=>f(d),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:S=>{S.target.style.background="hsl(var(--card))"},onMouseLeave:S=>{S.target.style.background="transparent"},children:[G("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:d.logoURI?G("img",{src:d.logoURI,alt:d.symbol,style:{width:"100%",height:"100%"},onError:S=>{let h=S.target;h.style.display="none",h.parentElement.textContent=d.symbol.slice(0,2)}}):d.symbol.slice(0,2)}),j("div",{style:{flex:1,minWidth:0},children:[G("div",{style:{fontWeight:600,fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.symbol}),G("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.name})]}),j("div",{style:{fontSize:"11px",color:"#666",textAlign:"right",flexShrink:0},children:[j("div",{children:[d.decimals," decimals"]}),j("div",{children:["Chain ",d.chainId]})]})]},`${d.chainId}:${d.address}`))})]})}import{createComponent as D}from"@stencil/react-output-target/runtime";import M from"react";import{AppkitAccordion as fl,defineCustomElement as gl}from"@naculus/connect-appkit-wc/dist/components/appkit-accordion.js";import{AppkitAccountButton as Cl,defineCustomElement as hl}from"@naculus/connect-appkit-wc/dist/components/appkit-account-button.js";import{AppkitAlertDialog as yl,defineCustomElement as Sl}from"@naculus/connect-appkit-wc/dist/components/appkit-alert-dialog.js";import{AppkitAvatar as El,defineCustomElement as wl}from"@naculus/connect-appkit-wc/dist/components/appkit-avatar.js";import{AppkitBadge as kl,defineCustomElement as xl}from"@naculus/connect-appkit-wc/dist/components/appkit-badge.js";import{AppkitButton as vl,defineCustomElement as Al}from"@naculus/connect-appkit-wc/dist/components/appkit-button.js";import{AppkitCardContent as bl,defineCustomElement as Rl}from"@naculus/connect-appkit-wc/dist/components/appkit-card-content.js";import{AppkitCardDescription as Tl,defineCustomElement as Il}from"@naculus/connect-appkit-wc/dist/components/appkit-card-description.js";import{AppkitCardFooter as Ul,defineCustomElement as Pl}from"@naculus/connect-appkit-wc/dist/components/appkit-card-footer.js";import{AppkitCardHeader as Wl,defineCustomElement as Ol}from"@naculus/connect-appkit-wc/dist/components/appkit-card-header.js";import{AppkitCardTitle as Nl,defineCustomElement as _l}from"@naculus/connect-appkit-wc/dist/components/appkit-card-title.js";import{AppkitCard as Dl,defineCustomElement as Ml}from"@naculus/connect-appkit-wc/dist/components/appkit-card.js";import{AppkitCheckbox as Ll,defineCustomElement as Bl}from"@naculus/connect-appkit-wc/dist/components/appkit-checkbox.js";import{AppkitCollapsible as Fl,defineCustomElement as Hl}from"@naculus/connect-appkit-wc/dist/components/appkit-collapsible.js";import{AppkitConnectButton as Kl,defineCustomElement as ql}from"@naculus/connect-appkit-wc/dist/components/appkit-connect-button.js";import{AppkitDialog as Vl,defineCustomElement as $l}from"@naculus/connect-appkit-wc/dist/components/appkit-dialog.js";import{AppkitDropdownMenu as Gl,defineCustomElement as jl}from"@naculus/connect-appkit-wc/dist/components/appkit-dropdown-menu.js";import{AppkitInput as zl,defineCustomElement as Ql}from"@naculus/connect-appkit-wc/dist/components/appkit-input.js";import{AppkitPopover as Xl,defineCustomElement as Yl}from"@naculus/connect-appkit-wc/dist/components/appkit-popover.js";import{AppkitProgress as Jl,defineCustomElement as Zl}from"@naculus/connect-appkit-wc/dist/components/appkit-progress.js";import{AppkitScrollArea as ec,defineCustomElement as tc}from"@naculus/connect-appkit-wc/dist/components/appkit-scroll-area.js";import{AppkitSelect as nc,defineCustomElement as rc}from"@naculus/connect-appkit-wc/dist/components/appkit-select.js";import{AppkitSeparator as oc,defineCustomElement as sc}from"@naculus/connect-appkit-wc/dist/components/appkit-separator.js";import{AppkitSkeleton as ac,defineCustomElement as ic}from"@naculus/connect-appkit-wc/dist/components/appkit-skeleton.js";import{AppkitSwitch as lc,defineCustomElement as cc}from"@naculus/connect-appkit-wc/dist/components/appkit-switch.js";import{AppkitTabs as uc,defineCustomElement as pc}from"@naculus/connect-appkit-wc/dist/components/appkit-tabs.js";import{AppkitToggleGroup as dc,defineCustomElement as mc}from"@naculus/connect-appkit-wc/dist/components/appkit-toggle-group.js";import{AppkitTooltip as fc,defineCustomElement as gc}from"@naculus/connect-appkit-wc/dist/components/appkit-tooltip.js";var Cc=D({tagName:"appkit-accordion",elementClass:fl,react:M,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:gl}),hc=D({tagName:"appkit-account-button",elementClass:Cl,react:M,events:{},defineCustomElement:hl}),yc=D({tagName:"appkit-alert-dialog",elementClass:yl,react:M,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Sl}),Sc=D({tagName:"appkit-avatar",elementClass:El,react:M,events:{},defineCustomElement:wl}),Ec=D({tagName:"appkit-badge",elementClass:kl,react:M,events:{},defineCustomElement:xl}),wc=D({tagName:"appkit-button",elementClass:vl,react:M,events:{},defineCustomElement:Al}),kc=D({tagName:"appkit-card",elementClass:Dl,react:M,events:{},defineCustomElement:Ml}),xc=D({tagName:"appkit-card-content",elementClass:bl,react:M,events:{},defineCustomElement:Rl}),vc=D({tagName:"appkit-card-description",elementClass:Tl,react:M,events:{},defineCustomElement:Il}),Ac=D({tagName:"appkit-card-footer",elementClass:Ul,react:M,events:{},defineCustomElement:Pl}),bc=D({tagName:"appkit-card-header",elementClass:Wl,react:M,events:{},defineCustomElement:Ol}),Rc=D({tagName:"appkit-card-title",elementClass:Nl,react:M,events:{},defineCustomElement:_l}),Tc=D({tagName:"appkit-checkbox",elementClass:Ll,react:M,events:{onAppkitChange:"appkitChange"},defineCustomElement:Bl}),Ic=D({tagName:"appkit-collapsible",elementClass:Fl,react:M,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:Hl}),Uc=D({tagName:"appkit-connect-button",elementClass:Kl,react:M,events:{onAppkitConnect:"appkitConnect",onAppkitDisconnect:"appkitDisconnect",onAppkitStartPairing:"appkitStartPairing",onAppkitRetry:"appkitRetry",onAppkitCancelPairing:"appkitCancelPairing",onAppkitMobileDeepLink:"appkitMobileDeepLink",onAppkitCopyAddress:"appkitCopyAddress"},defineCustomElement:ql}),Pc=D({tagName:"appkit-dialog",elementClass:Vl,react:M,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:$l}),Wc=D({tagName:"appkit-dropdown-menu",elementClass:Gl,react:M,events:{onAppkitSelect:"appkitSelect"},defineCustomElement:jl}),Oc=D({tagName:"appkit-input",elementClass:zl,react:M,events:{onAppkitChange:"appkitChange"},defineCustomElement:Ql}),Nc=D({tagName:"appkit-popover",elementClass:Xl,react:M,events:{onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Yl}),_c=D({tagName:"appkit-progress",elementClass:Jl,react:M,events:{},defineCustomElement:Zl}),Dc=D({tagName:"appkit-scroll-area",elementClass:ec,react:M,events:{},defineCustomElement:tc}),Mc=D({tagName:"appkit-select",elementClass:nc,react:M,events:{onAppkitChange:"appkitChange"},defineCustomElement:rc}),Lc=D({tagName:"appkit-separator",elementClass:oc,react:M,events:{},defineCustomElement:sc}),Bc=D({tagName:"appkit-skeleton",elementClass:ac,react:M,events:{},defineCustomElement:ic}),Fc=D({tagName:"appkit-switch",elementClass:lc,react:M,events:{onAppkitChange:"appkitChange"},defineCustomElement:cc}),Hc=D({tagName:"appkit-tabs",elementClass:uc,react:M,events:{onAppkitTabChange:"appkitTabChange"},defineCustomElement:pc}),Kc=D({tagName:"appkit-toggle-group",elementClass:dc,react:M,events:{onAppkitChange:"appkitChange"},defineCustomElement:mc}),qc=D({tagName:"appkit-tooltip",elementClass:fc,react:M,events:{},defineCustomElement:gc});export{Cc as AppkitAccordion,hc as AppkitAccountButton,yc as AppkitAlertDialog,Sc as AppkitAvatar,Ec as AppkitBadge,wc as AppkitButton,kc as AppkitCard,xc as AppkitCardContent,vc as AppkitCardDescription,Ac as AppkitCardFooter,bc as AppkitCardHeader,Rc as AppkitCardTitle,Tc as AppkitCheckbox,Ic as AppkitCollapsible,Uc as AppkitConnectButton,Pc as AppkitDialog,Wc as AppkitDropdownMenu,Oc as AppkitInput,Nc as AppkitPopover,_c as AppkitProgress,Dc as AppkitScrollArea,Mc as AppkitSelect,Lc as AppkitSeparator,Bc as AppkitSkeleton,Fc as AppkitSwitch,Hc as AppkitTabs,Kc as AppkitToggleGroup,qc as AppkitTooltip,pn as DEFAULT_EVM_CHAINS,UC as LAMPORTS_PER_SOL,PC as PassphraseCancelledError,WC as PassphraseGate,NC as SolanaRpcError,kr as TokenSelector,Mn as TxMonitorContext,Cr as WALLET_ERROR_DESCRIPTIONS,gr as WALLET_ERROR_TITLES,eo as Web3ConnectProvider,st as Web3Context,ls as buildDelegationPolicyMessage,Pr as clearClient,nt as createClient,bC as formatSol,qr as getChainById,rt as getClient,ot as getDefaultChains,RC as getLatestBlockhash,Gi as getLocale,TC as getSignatureStatus,IC as getSolanaBalance,Ae as getUserFriendlyError,Qt as isRetryableError,OC as parseSol,Zo as resetSessionKeyManager,$i as setLocale,zt as t,B as useAccount,fo as useBalance,lt as useCapabilities,V as useChain,nn as useCompareCosts,bo as useConnect,Xo as useCreateSessionKey,_o as useDelegate,me as useDelegation,is as useDelegationPolicy,ps as useDisconnect,bs as useERC20Allowance,Os as useERC20Approve,Vs as useERC20Transfer,Js as useERC20TransferSimulation,ms as useEmbeddedWallet,Ct as useExecuteCalls,sn as useExecuteRoute,sa as useLastTx,ua as useLookupAddress,wa as useNotification,va as usePassphraseGate,ba as useResolveName,Yo as useRevokeSession,cn as useRouteQuote,Wt as useSIWxLogin,ja as useSIWxSession,ft as useSendCalls,Ce as useSendTransaction,Pa as useSendUserOperation,Jo as useSendWithSession,Da as useSession,ht as useSessionKeys,ni as useSignInWithEthereum,Ee as useSignInWithX,St as useSignMessage,ai as useSimulateTransfer,mi as useSiwxAuthSession,Ci as useSmartAccount,Ft as useSolanaAccount,wi as useSolanaBalance,vi as useSolanaRoles,bi as useSolanaTransaction,Ti as useSwitchChain,Di as useTokenBalance,je as useTokenList,Qe as useTokenSearch,vt as useTransactionSimulation,Bi as useTxHistory,ra as useTxMonitor,Ki as useUserOpStatus,Qi as useValidateDestination,$ as useViemClient,Xi as useWallet,U as useWeb3,Yi as useWeb3ErrorHandler,fr as validateDestination};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|