@antseed/gateway-console 0.1.11 → 0.1.12
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/assets/{Activity-UaQeZdKk.js → Activity-BcXN_DqV.js} +1 -1
- package/dist/assets/Audit-nk0K4aQy.js +1 -0
- package/dist/assets/{BrandIcon-dTKznfCA.js → BrandIcon-6gq42Dg-.js} +1 -1
- package/dist/assets/{ChainGate-DpChfDOP.js → ChainGate-Do1wYOPQ.js} +1 -1
- package/dist/assets/{ChannelClose-DpNV5MqB.js → ChannelClose-CdHUKMFm.js} +1 -1
- package/dist/assets/{Charts-C65ZE2xP.js → Charts-BMsoEfDr.js} +1 -1
- package/dist/assets/{Chat-BbM_y6mh.js → Chat-C4DsUQG-.js} +3 -3
- package/dist/assets/{ConnectWallet-CLv0c-JB.js → ConnectWallet-BYdqZipy.js} +1 -1
- package/dist/assets/{DataTable-BkJdorEh.js → DataTable-BCgVRqY6.js} +1 -1
- package/dist/assets/{Disclosure-DMLE7rCw.js → Disclosure-CQMtWM0M.js} +1 -1
- package/dist/assets/{KeyHolder-Cjko0nrs.js → KeyHolder-JK1zjm4r.js} +1 -1
- package/dist/assets/{Keys-DLKN6Sna.js → Keys-BndDLQdj.js} +1 -1
- package/dist/assets/{Logs-DIPNoSb8.js → Logs-DfacvRY6.js} +1 -1
- package/dist/assets/{Members-CgP9OTz9.js → Members-pSSyfBFp.js} +1 -1
- package/dist/assets/{Migrate-DDHZ-rux.js → Migrate-Bqnu-HEP.js} +1 -1
- package/dist/assets/{ModelDetails-CkDNU2Px.js → ModelDetails-Sgq3MjfG.js} +1 -1
- package/dist/assets/{Models-DXbiNymT.js → Models-C6QzCAh4.js} +1 -1
- package/dist/assets/{OperatorActions-BuEpaCiH.js → OperatorActions-DWX4uK6I.js} +1 -1
- package/dist/assets/{OperatorGateAlert-grMRoFdV.js → OperatorGateAlert-cpvsO9yT.js} +1 -1
- package/dist/assets/{Overview-BU9HCltc.js → Overview-C4Bu8z8u.js} +1 -1
- package/dist/assets/{PeerPicker-CfsXTUyK.js → PeerPicker-CcMSXxY3.js} +1 -1
- package/dist/assets/PolicyEditor-COREmE0O.js +1 -0
- package/dist/assets/PolicyField-ldIq_Yw-.js +1 -0
- package/dist/assets/{Presets-szQETQLM.js → Presets-DFKw93HK.js} +2 -2
- package/dist/assets/Providers-D_0V31og.js +1 -0
- package/dist/assets/{RequestLog-DJl6FJhq.js → RequestLog-ChzJA1hM.js} +1 -1
- package/dist/assets/{Rewards-BOfJumNk.js → Rewards-Cgw7r3bc.js} +2 -2
- package/dist/assets/{RewardsClaim-DHvgMfZ4.js → RewardsClaim-Df0QQMHb.js} +1 -1
- package/dist/assets/Routing-KpWxzlwc.js +1 -0
- package/dist/assets/{Segmented-D3e0aBDU.js → Segmented-DYnoemT9.js} +1 -1
- package/dist/assets/{SelectField-Cl4acfcI.js → SelectField-m1sMIgMa.js} +1 -1
- package/dist/assets/Settings-D2MkmqAU.js +7 -0
- package/dist/assets/{SidePanel-D0rNElh3.js → SidePanel-BFQArkoa.js} +1 -1
- package/dist/assets/{Staking-1D2HNu5P.js → Staking-2rSdK2Ob.js} +1 -1
- package/dist/assets/{StakingDashboard-C5Ib_AUs.js → StakingDashboard-DvLxJ1j4.js} +1 -1
- package/dist/assets/{Switch-B2AEvyu7.js → Switch-Db8Sm64J.js} +1 -1
- package/dist/assets/{Tabs-Cv10NtDy.js → Tabs-CCabxVNK.js} +1 -1
- package/dist/assets/{TextAreaField-Dbr655cs.js → TextAreaField-BCi-qMua.js} +1 -1
- package/dist/assets/{UsageByModel-BfvCLwo9.js → UsageByModel-Fb68pvpD.js} +1 -1
- package/dist/assets/{VerificationLinks-CERoRvCR.js → VerificationLinks-CWyl6ZEp.js} +1 -1
- package/dist/assets/{Wallet-CVS_hzu0.js → Wallet-BVuVEAB5.js} +7 -7
- package/dist/assets/{WalletConfirm-C8Kazsh7.js → WalletConfirm-Bs7CFRaa.js} +1 -1
- package/dist/assets/{WalletFunding-BbhXB813.js → WalletFunding-w9MlXB0t.js} +1 -1
- package/dist/assets/{WalletSignIn-Tzs38aME.js → WalletSignIn-CFxQjhbw.js} +1 -1
- package/dist/assets/{Workspaces-DGgrOEZk.js → Workspaces-DktyLm08.js} +1 -1
- package/dist/assets/{add-CdcnAnIQ.js → add-CWU7ACA6.js} +1 -1
- package/dist/assets/{all-wallets-CaMIS0WH.js → all-wallets-C7xN3fay.js} +1 -1
- package/dist/assets/{app-store-BJlWsf36.js → app-store-C9LYdcrl.js} +1 -1
- package/dist/assets/{apple-sOU-w3fg.js → apple-DyeheYaR.js} +1 -1
- package/dist/assets/{arrow-bottom-CTOfZJ7E.js → arrow-bottom-C-Ld0QTs.js} +1 -1
- package/dist/assets/{arrow-bottom-circle-B6IrOSiK.js → arrow-bottom-circle-CBZDZ8Ab.js} +1 -1
- package/dist/assets/{arrow-left-D0Qm9EWX.js → arrow-left-DpJrY7yH.js} +1 -1
- package/dist/assets/{arrow-right-XMSWQLiv.js → arrow-right-C12AYUbo.js} +1 -1
- package/dist/assets/{arrow-top-Bym-ayRK.js → arrow-top-DTpoR1JD.js} +1 -1
- package/dist/assets/{bank-NJF8WYDR.js → bank-Ce19qcX5.js} +1 -1
- package/dist/assets/{basic-bO70Xvle.js → basic-xSJded8g.js} +1 -1
- package/dist/assets/{browser-ucjw1tpv.js → browser-efLjW-nE.js} +1 -1
- package/dist/assets/{bundle-full-idGWmtvy.js → bundle-full-Bo_XusKG.js} +1 -1
- package/dist/assets/{card-DcpyI2qX.js → card-C5hP1T57.js} +1 -1
- package/dist/assets/{ccip-DBXxv0FH.js → ccip-B61TPyfu.js} +1 -1
- package/dist/assets/{checkmark-RFLSeCgj.js → checkmark-D6TDn2nt.js} +1 -1
- package/dist/assets/{checkmark-bold-Dl1q9Kby.js → checkmark-bold-D6Dl_7lL.js} +1 -1
- package/dist/assets/{chevron-bottom-ilycsYd4.js → chevron-bottom-BN93pLQ-.js} +1 -1
- package/dist/assets/{chevron-left-DFK2Xbq1.js → chevron-left-BRtPfxLq.js} +1 -1
- package/dist/assets/{chevron-right-Ew8XV9m9.js → chevron-right-q6ckJ6mb.js} +1 -1
- package/dist/assets/{chevron-top-CxoXH2-q.js → chevron-top-C1AX5sm6.js} +1 -1
- package/dist/assets/{chrome-store-ClmhY3B0.js → chrome-store-Bo_BoLHJ.js} +1 -1
- package/dist/assets/{clock-CCiukNBf.js → clock-BhAO_7G0.js} +1 -1
- package/dist/assets/{close-B0KBYbXe.js → close-BtzdVDHu.js} +1 -1
- package/dist/assets/{code-block-DxUcjw4S.js → code-block-DqMh9vFo.js} +1 -1
- package/dist/assets/{coinPlaceholder-D2ugxr3r.js → coinPlaceholder-Di1b8fYJ.js} +1 -1
- package/dist/assets/{compass-CutyEYmW.js → compass-C10lNmou.js} +1 -1
- package/dist/assets/{copy-CJ0RBt1e.js → copy-B5e38uFc.js} +1 -1
- package/dist/assets/{core-BCJdIbrO.js → core-B0f6zAPS.js} +3 -3
- package/dist/assets/{cursor-transparent-BQ_jwSfb.js → cursor-transparent-DzGICXfN.js} +1 -1
- package/dist/assets/cursor-zACYQT2t.js +3 -0
- package/dist/assets/{desktop-CsfFLaEs.js → desktop-DSb6a3DL.js} +1 -1
- package/dist/assets/{disconnect-B62slDXp.js → disconnect-DRzHq1ok.js} +1 -1
- package/dist/assets/{discord-B8GwtWtL.js → discord-c_RQc3fB.js} +1 -1
- package/dist/assets/{en_US-Y4ZOVFV4-sKQksBWU.js → en_US-Y4ZOVFV4-Bkc-z49M.js} +4 -4
- package/dist/assets/{etherscan-BT9zhNhd.js → etherscan-CQGvGKJu.js} +1 -1
- package/dist/assets/{exclamation-triangle-BSoPK6uq.js → exclamation-triangle-CPWxzsHw.js} +1 -1
- package/dist/assets/{extension-CQxJq6bp.js → extension-ytWXOqXr.js} +1 -1
- package/dist/assets/{external-link-BnfAKGN2.js → external-link-BYoSE2u3.js} +1 -1
- package/dist/assets/{facebook-DiAqdu4i.js → facebook-CMBv0nnN.js} +1 -1
- package/dist/assets/{farcaster-B1y2in5M.js → farcaster-CJmfWTQP.js} +1 -1
- package/dist/assets/{filters-BkVUp9NW.js → filters-DEiNVvyn.js} +1 -1
- package/dist/assets/{github-IRwi-GM-.js → github-CdMwJkf8.js} +1 -1
- package/dist/assets/{google-k2ysL2bi.js → google-CHI5gfH8.js} +1 -1
- package/dist/assets/{help-circle-DLj9trmu.js → help-circle-dA36a8fM.js} +1 -1
- package/dist/assets/highlighted-body-KQOG7T2V-BFlyrf-z.js +1 -0
- package/dist/assets/{id-BY4HWjv7.js → id-Dm0-1g1D.js} +1 -1
- package/dist/assets/{image-BtUeZe1t.js → image-BL3ODVX_.js} +1 -1
- package/dist/assets/{index-DYK1gWhP.css → index-BAcoKUeC.css} +1 -1
- package/dist/assets/{index-DiB9Y59V.js → index-BRgGxCKs.js} +3 -3
- package/dist/assets/{index-Cmb-H95F.js → index-BXzZZOmS.js} +1 -1
- package/dist/assets/{index-BXwAwVaO.js → index-CHeO_lLD.js} +1 -1
- package/dist/assets/{index-DsRX2D_O.js → index-D1OXThJP.js} +1 -1
- package/dist/assets/{index-cESr4Zze.js → index-DPXW_JSn.js} +10 -10
- package/dist/assets/{index.es-DP9EmOYi.js → index.es-XdMmjy3e.js} +3 -3
- package/dist/assets/{info-BaKj81_D.js → info-BbBzpLWs.js} +1 -1
- package/dist/assets/{info-circle-ecoA_B_t.js → info-circle-CKgnYdF-.js} +1 -1
- package/dist/assets/{lightbulb-DGQG-WWk.js → lightbulb-B6Xv9kMK.js} +1 -1
- package/dist/assets/{limits-D2JvFgaN.js → limits-uCwhqY-O.js} +1 -1
- package/dist/assets/{mail-BvEbsX3q.js → mail-BdCMypwE.js} +1 -1
- package/dist/assets/{mermaid-MCJ5UELQ-B8uOykea.js → mermaid-MCJ5UELQ-BaHsArCB.js} +3 -3
- package/dist/assets/{metamask-sdk-BYmYI1f3.js → metamask-sdk-BL7QLxcU.js} +1 -1
- package/dist/assets/{mobile-CwlM4JMX.js → mobile-F_82dhUb.js} +1 -1
- package/dist/assets/{more-CT36TpLm.js → more-CtMTtAsM.js} +1 -1
- package/dist/assets/{network-placeholder-DG1Vvm-U.js → network-placeholder-BRs4Lylz.js} +1 -1
- package/dist/assets/{nftPlaceholder-D6USOn7p.js → nftPlaceholder-DONTHyad.js} +1 -1
- package/dist/assets/{off-BNSO7pY1.js → off-Bwru40fy.js} +1 -1
- package/dist/assets/{play-store-PUfM0qU0.js → play-store-CDeNquGq.js} +1 -1
- package/dist/assets/{plus-C8fnGfp3.js → plus-EcrYfJFM.js} +1 -1
- package/dist/assets/{qr-code-CjdrQ0pR.js → qr-code-CF-SIZQq.js} +1 -1
- package/dist/assets/{recycle-horizontal-BMxBgeB4.js → recycle-horizontal-CQAPujmy.js} +1 -1
- package/dist/assets/{refresh-C2D196Fq.js → refresh-BErGEy2b.js} +1 -1
- package/dist/assets/{reown-logo-CLN2ORKJ.js → reown-logo-Ge2o4AAI.js} +1 -1
- package/dist/assets/{search-C9voC8dq.js → search-Ca88O9BA.js} +1 -1
- package/dist/assets/selection-BV37SUs_.js +1 -0
- package/dist/assets/{send-BAxcrGbA.js → send-VS1TUwft.js} +1 -1
- package/dist/assets/{sendTransaction-Cmz5eiPq.js → sendTransaction-k8aDYfd4.js} +1 -1
- package/dist/assets/stored-e0tX90bC.js +1 -0
- package/dist/assets/{swapHorizontal-CHCTyoP7.js → swapHorizontal-UNJ9wJ3Z.js} +1 -1
- package/dist/assets/{swapHorizontalBold-LQsONWBk.js → swapHorizontalBold-eQTpC4fd.js} +1 -1
- package/dist/assets/{swapHorizontalMedium-BxrBEjrx.js → swapHorizontalMedium-DaFWQu14.js} +1 -1
- package/dist/assets/{swapHorizontalRoundedBold-CEHDoSv1.js → swapHorizontalRoundedBold-BbRZUmJZ.js} +1 -1
- package/dist/assets/{swapVertical-DMylrYB1.js → swapVertical-CrZ6Be2R.js} +1 -1
- package/dist/assets/{telegram-BhVfpln1.js → telegram-CDAYT0ej.js} +1 -1
- package/dist/assets/{three-dots-nkXRRS-E.js → three-dots-CK__4w5S.js} +1 -1
- package/dist/assets/{twitch-CYroZH_7.js → twitch-BS50nSpU.js} +1 -1
- package/dist/assets/{twitterIcon-DpHUqlyA.js → twitterIcon-BtVx5zJI.js} +1 -1
- package/dist/assets/{usage-8BBeTlF-.js → usage-DQGKL0DJ.js} +1 -1
- package/dist/assets/{useInfiniteQuery-zD1WIYBy.js → useInfiniteQuery-CAj47QRO.js} +1 -1
- package/dist/assets/{useTx-DsLsc5bB.js → useTx-DzRlz7Ez.js} +1 -1
- package/dist/assets/{verify-filled-EsNi41IB.js → verify-filled-E4LyUumx.js} +1 -1
- package/dist/assets/{verify-DARDbLiQ.js → verify-hRAQBjoS.js} +1 -1
- package/dist/assets/{w3m-modal-CIUN4uxE.js → w3m-modal-CLSVKDRP.js} +1 -1
- package/dist/assets/{waitForCallsStatus-DlpsNYx1.js → waitForCallsStatus-C51Vv8Tt.js} +1 -1
- package/dist/assets/{wallet-B2vgeP1E.js → wallet-D-TGx4VA.js} +1 -1
- package/dist/assets/{wallet-placeholder-DQsissb3.js → wallet-placeholder-SjwHckDA.js} +1 -1
- package/dist/assets/{walletconnect-DylNgC0Z.js → walletconnect-7nuI2nwG.js} +1 -1
- package/dist/assets/{warning-circle-CVEgsVb4.js → warning-circle-BI2BfSeD.js} +1 -1
- package/dist/assets/{writeContract-Cqg_OlRQ.js → writeContract-CaMlmKcK.js} +1 -1
- package/dist/assets/{x-DSURRh6S.js → x-DoGk7CZD.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/Audit-Cd26xOlL.js +0 -1
- package/dist/assets/PolicyEditor-ptFDJhFh.js +0 -1
- package/dist/assets/PolicyField-CHhm50jF.js +0 -1
- package/dist/assets/Providers-B6xbFeNU.js +0 -1
- package/dist/assets/Routing-DFuhPfzU.js +0 -1
- package/dist/assets/Settings--0bbw1dn.js +0 -7
- package/dist/assets/cursor-Bg_hT9DN.js +0 -3
- package/dist/assets/highlighted-body-KQOG7T2V-CJM-VU3I.js +0 -1
- package/dist/assets/selection-HN8SZ52c.js +0 -1
- package/dist/assets/stored-CETnaQtE.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var wn=Object.defineProperty;var vn=(t,s,n)=>s in t?wn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Ve=(t,s,n)=>vn(t,typeof s!="symbol"?s+"":s,n);import{F as yn,r as u,j as e,cn as kn,co as Nn,cp as Ns,C as Dt,u as Sn,H as Cn,cq as An,cr as En,y as os,a9 as St,cs as In,ct as Tn}from"./index-cESr4Zze.js";import{K as ct,ad as $n,ae as Pn,p as et,af as Rn,g as Te,A as dt,i as Ss,j as Mn,B as Ln,k as Wt,l as Cs,m as cs,n as Bn,L as Un,a7 as Fn,ag as Dn,o as As,q as Wn,ah as Es,t as at,v as _n,ai as On,aj as zn,ak as qn,al as Yn,s as Vn,am as Hn,a4 as Kn,Z as Jn,c as Gn,u as _t,_ as Qn,$ as Zn,an as Xn,ao as ea,ap as ta,aq as sa,ar as na,as as aa,C as Is,W as ra}from"./en_US-Y4ZOVFV4-sKQksBWU.js";import{A as la,a as ia}from"./index-BhwNCc8y.js";import{s as Ts,a as $s}from"./sendTransaction-Cmz5eiPq.js";import{s as Ps,w as Rs,p as Ms,g as oa}from"./waitForCallsStatus-DlpsNYx1.js";import{w as Ls}from"./writeContract-Cqg_OlRQ.js";import{C as ca}from"./ChainGate-DpChfDOP.js";async function da(t,{chain:s}){const{id:n,name:a,nativeCurrency:r,rpcUrls:l,blockExplorers:i}=s;await t.request({method:"wallet_addEthereumChain",params:[{chainId:ct(n),chainName:a,nativeCurrency:r,rpcUrls:l.default.http,blockExplorerUrls:i?Object.values(i).map(({url:c})=>c):void 0}]},{dedupe:!0,retryCount:0})}function ua(t,s){const{abi:n,args:a,bytecode:r,...l}=s,i=$n({abi:n,args:a,bytecode:r});return Ts(t,{...l,...l.authorizationList?{to:null}:{},data:i})}async function ha(t){var n;return((n=t.account)==null?void 0:n.type)==="local"?[t.account.address]:(await t.request({method:"eth_accounts"},{dedupe:!0})).map(a=>Pn(a))}async function ma(t,s={}){const{account:n=t.account,chainId:a}=s,r=n?et(n):void 0,l=a?[r==null?void 0:r.address,[ct(a)]]:[r==null?void 0:r.address],i=await t.request({method:"wallet_getCapabilities",params:l}),c={};for(const[o,h]of Object.entries(i)){c[Number(o)]={};for(let[d,m]of Object.entries(h))d==="addSubAccount"&&(d="unstable_addSubAccount"),c[Number(o)][d]=m}return typeof a=="number"?c[a]:c}async function pa(t){return await t.request({method:"wallet_getPermissions"},{dedupe:!0})}async function xa(t){return(await t.request({method:"eth_requestAccounts"},{dedupe:!0,retryCount:0})).map(n=>Rn(n))}async function fa(t,s){return t.request({method:"wallet_requestPermissions",params:[s]},{retryCount:0})}async function ga(t,s){const{chain:n=t.chain}=s,a=s.timeout??Math.max(((n==null?void 0:n.blockTime)??0)*3,5e3),r=await Te(t,Ps,"sendCalls")(s);return await Te(t,Rs,"waitForCallsStatus")({...s,id:r.id,timeout:a})}const bt=new Un(128);async function Bs(t,s){var B,b,v,L,D;const{account:n=t.account,assertChainId:a=!0,chain:r=t.chain,accessList:l,authorizationList:i,blobs:c,data:o,dataSuffix:h=typeof t.dataSuffix=="string"?t.dataSuffix:(B=t.dataSuffix)==null?void 0:B.value,gas:d,gasPrice:m,maxFeePerBlobGas:x,maxFeePerGas:f,maxPriorityFeePerGas:j,nonce:y,pollingInterval:E,throwOnReceiptRevert:P,type:T,value:A,...N}=s,U=s.timeout??Math.max(((r==null?void 0:r.blockTime)??0)*3,5e3);if(typeof n>"u")throw new dt({docsPath:"/docs/actions/wallet/sendTransactionSync"});const k=n?et(n):null;try{Ss(s);const S=await(async()=>{if(s.to)return s.to;if(s.to!==null&&i&&i.length>0)return await Mn({authorization:i[0]}).catch(()=>{throw new Ln("`to` is required. Could not infer from `authorizationList`.")})})();if((k==null?void 0:k.type)==="json-rpc"||k===null){let g;r!==null&&(g=await Te(t,Wt,"getChainId")({}),a&&$s({currentChainId:g,chain:r}));const w=(L=(v=(b=t.chain)==null?void 0:b.formatters)==null?void 0:v.transactionRequest)==null?void 0:L.format,I=(w||Cs)({...Bn(N,{format:w}),accessList:l,account:k,authorizationList:i,blobs:c,chainId:g,data:o&&cs([o,h??"0x"]),gas:d,gasPrice:m,maxFeePerBlobGas:x,maxFeePerGas:f,maxPriorityFeePerGas:j,nonce:y,to:S,type:T,value:A},"sendTransaction"),_=bt.get(t.uid),$=_?"wallet_sendTransaction":"eth_sendTransaction",M=await(async()=>{try{return await t.request({method:$,params:[I]},{retryCount:0})}catch(H){if(_===!1)throw H;const Y=H;if(Y.name==="InvalidInputRpcError"||Y.name==="InvalidParamsRpcError"||Y.name==="MethodNotFoundRpcError"||Y.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[I]},{retryCount:0}).then(ee=>(bt.set(t.uid,!0),ee)).catch(ee=>{const pe=ee;throw pe.name==="MethodNotFoundRpcError"||pe.name==="MethodNotSupportedRpcError"?(bt.set(t.uid,!1),Y):pe});throw Y}})(),O=await Te(t,Fn,"waitForTransactionReceipt")({checkReplacement:!1,hash:M,pollingInterval:E,timeout:U});if(P&&O.status==="reverted")throw new Dn({receipt:O});return O}if((k==null?void 0:k.type)==="local"){const g=await Te(t,As,"prepareTransactionRequest")({account:k,accessList:l,authorizationList:i,blobs:c,chain:r,data:o&&cs([o,h??"0x"]),gas:d,gasPrice:m,maxFeePerBlobGas:x,maxFeePerGas:f,maxPriorityFeePerGas:j,nonce:y,nonceManager:k.nonceManager,parameters:[...Wn,"sidecars"],type:T,value:A,...N,to:S}),w=(D=r==null?void 0:r.serializers)==null?void 0:D.transaction,p=await k.signTransaction(g,{serializer:w});return await Te(t,Es,"sendRawTransactionSync")({serializedTransaction:p,throwOnReceiptRevert:P,timeout:s.timeout})}throw(k==null?void 0:k.type)==="smart"?new at({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new at({docsPath:"/docs/actions/wallet/sendTransactionSync",type:k==null?void 0:k.type})}catch(S){throw S instanceof at?S:_n(S,{...s,account:k,chain:s.chain||void 0})}}async function ba(t,s){const{id:n}=s;await t.request({method:"wallet_showCallsStatus",params:[n]})}async function ja(t,s){const{account:n=t.account}=s;if(!n)throw new dt({docsPath:"/docs/eip7702/signAuthorization"});const a=et(n);if(!a.signAuthorization)throw new at({docsPath:"/docs/eip7702/signAuthorization",metaMessages:["The `signAuthorization` Action does not support JSON-RPC Accounts."],type:a.type});const r=await Ms(t,s);return a.signAuthorization(r)}async function wa(t,s){var h,d,m,x;const{account:n=t.account,chain:a=t.chain,...r}=s;if(!n)throw new dt({docsPath:"/docs/actions/wallet/signTransaction"});const l=et(n);Ss({account:l,...s});const i=await Te(t,Wt,"getChainId")({});a!==null&&$s({currentChainId:i,chain:a});const c=(a==null?void 0:a.formatters)||((h=t.chain)==null?void 0:h.formatters),o=((d=c==null?void 0:c.transactionRequest)==null?void 0:d.format)||Cs;return l.signTransaction?l.signTransaction({...r,chainId:i},{serializer:(x=(m=t.chain)==null?void 0:m.serializers)==null?void 0:x.transaction}):await t.request({method:"eth_signTransaction",params:[{...o({...r,account:l},"signTransaction"),chainId:ct(i),from:l.address}]},{retryCount:0})}async function va(t,s){const{account:n=t.account,domain:a,message:r,primaryType:l}=s;if(!n)throw new dt({docsPath:"/docs/actions/wallet/signTypedData"});const i=et(n),c={EIP712Domain:On({domain:a}),...s.types};if(zn({domain:a,message:r,primaryType:l,types:c}),i.signTypedData)return i.signTypedData({domain:a,message:r,primaryType:l,types:c});const o=qn({domain:a,message:r,primaryType:l,types:c});return t.request({method:"eth_signTypedData_v4",params:[i.address,o]},{retryCount:0})}async function ya(t,{id:s}){await t.request({method:"wallet_switchEthereumChain",params:[{chainId:ct(s)}]},{retryCount:0})}async function ka(t,s){return await t.request({method:"wallet_watchAsset",params:s},{retryCount:0})}async function Na(t,s){return Ls.internal(t,Bs,"sendTransactionSync",s)}function Sa(t){return{addChain:s=>da(t,s),deployContract:s=>ua(t,s),fillTransaction:s=>Hn(t,s),getAddresses:()=>ha(t),getCallsStatus:s=>oa(t,s),getCapabilities:s=>ma(t,s),getChainId:()=>Wt(t),getPermissions:()=>pa(t),prepareAuthorization:s=>Ms(t,s),prepareTransactionRequest:s=>As(t,s),requestAddresses:()=>xa(t),requestPermissions:s=>fa(t,s),sendCalls:s=>Ps(t,s),sendCallsSync:s=>ga(t,s),sendRawTransaction:s=>Vn(t,s),sendRawTransactionSync:s=>Es(t,s),sendTransaction:s=>Ts(t,s),sendTransactionSync:s=>Bs(t,s),showCallsStatus:s=>ba(t,s),signAuthorization:s=>ja(t,s),signMessage:s=>Yn(t,s),signTransaction:s=>wa(t,s),signTypedData:s=>va(t,s),switchChain:s=>ya(t,s),waitForCallsStatus:s=>Rs(t,s),watchAsset:s=>ka(t,s),writeContract:s=>Ls(t,s),writeContractSync:s=>Na(t,s)}}async function Ca(t,s={}){return(await Kn(t,s)).extend(Sa)}function Aa(t,s={}){return{gcTime:0,async queryFn({queryKey:n}){const{connector:a}=s,{connectorUid:r,scopeKey:l,...i}=n[1];return Ca(t,{...i,connector:a})},queryKey:Ea(s)}}function Ea(t={}){const{connector:s,...n}=t;return["walletClient",{...Jn(n),connectorUid:s==null?void 0:s.uid}]}function Us(t={}){const{query:s={},...n}=t,a=Gn(n),r=yn(),{address:l,connector:i,status:c}=_t({config:a}),o=Qn({config:a}),h=t.connector??i,{queryKey:d,...m}=Aa(a,{...t,chainId:t.chainId??o,connector:t.connector??i}),x=!!((c==="connected"||c==="reconnecting"&&(h!=null&&h.getProvider))&&(s.enabled??!0)),f=u.useRef(l);return u.useEffect(()=>{const j=f.current;!l&&j?(r.removeQueries({queryKey:d}),f.current=void 0):l!==j&&(r.invalidateQueries({queryKey:d}),f.current=l)},[l,r]),Zn({...s,...m,queryKey:d,enabled:x,staleTime:Number.POSITIVE_INFINITY})}class Fs extends Error{constructor(s="Waiting for Antscan to catch up with your transaction"){super(s),this.name="IndexerSyncingError"}}const Ia=[{label:"Market",items:[{id:"stake",label:"Sellers"}]},{label:"You",items:[{id:"positions",label:"My positions"},{id:"rewards",label:"Rewards"},{id:"seller",label:"Seller"}]},{label:"Protocol",items:[{id:"network",label:"Network"},{id:"addresses",label:"Addresses"}]}],Ds=["stake","positions","rewards","seller","network","addresses"],ni={stake:"staking",positions:"staking",rewards:"rewards",seller:"seller",network:"protocol",addresses:"protocol"},Ta="ants.dashboard.token";function $a(){try{return window.sessionStorage.getItem(Ta)}catch{return null}}const Pa={embedded:!1,apiUrl:t=>t,headers:()=>({Authorization:`Bearer ${$a()??""}`}),href:t=>`#/${t}`,currentPath:()=>window.location.hash.replace(/^#\/?/,""),replace:t=>window.history.replaceState(null,"",`#/${t}`),subscribe:t=>(window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)),portalTarget:()=>document.body,pages:Ds,buyerRewards:!0};let Ws=Pa;function ae(){return Ws}function Ra(t){Ws=t}class Ne extends Error{constructor(n,a){super(n);Ve(this,"status");this.name="ApiError",this.status=a}}const Ma=new Set;async function $e(t,s){const n={...ae().headers()};let a;(s==null?void 0:s.body)!==void 0&&(n["Content-Type"]="application/json",a=JSON.stringify(s.body));let r;try{r=await fetch(ae().apiUrl(t),{method:(s==null?void 0:s.method)??"GET",headers:n,body:a})}catch(i){throw new Ne(`Network error: ${i instanceof Error?i.message:String(i)}`,0)}if(r.status===401){for(const i of Ma)i();throw new Ne("Unauthorized",401)}let l=null;try{l=await r.json()}catch{l=null}if(!l||typeof l!="object")throw new Ne(`HTTP ${r.status}`,r.status);if(!l.ok)throw"state"in l&&l.state==="syncing"?new Fs:new Ne("error"in l&&l.error||`HTTP ${r.status}`,r.status);return l.data}function te(t){return $e(t)}function ds(t,s){return $e(t,{method:"POST",body:s})}const q={config:()=>te("/api/config"),overview:()=>te("/api/overview"),positions:()=>te("/api/positions"),rewards:()=>te("/api/rewards"),pools:()=>te("/api/pools"),sellerModels:async t=>{try{const s=await te(`/api/sellers/${encodeURIComponent(t)}/models`);if(!s||!("period"in s)||!("totals"in s))throw new Ne("The running dashboard server still uses sampled model data. Restart the updated desktop or dashboard process to load last-epoch totals.",502);return s}catch(s){throw s instanceof Ne&&s.status===404?new Ne("The running dashboard server does not have the model-data endpoint (HTTP 404). Restart the updated desktop or dashboard process, then reopen staking.",404):s}},pool:t=>te(`/api/pools/${t}`),usage:t=>te(`/api/usage?epochs=${t}`),emissions:()=>te("/api/emissions"),network:()=>te("/api/network"),networkLegacy:()=>te("/api/network/legacy"),verification:t=>te(`/api/verification${t?`?seller=${encodeURIComponent(t)}`:""}`),proofStatus:t=>te(`/api/verification/proofs/${encodeURIComponent(t)}`),seller:()=>te("/api/seller"),jobs:()=>te("/api/jobs"),job:t=>te(`/api/jobs/${encodeURIComponent(t)}`),withdrawPreview:t=>ds("/api/positions/withdraw/preview",{positionIds:t}),startJob:(t,s)=>ds(t,s)};function Ct(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}function J(t){if(t==null||t==="")return null;try{return BigInt(t)}catch{return null}}function _s(t,s,n=2){const a=typeof t=="bigint"?t:J(t);if(a===null)return"—";const r=a<0n,l=r?-a:a,i=10n**BigInt(s),c=l/i,o=l%i;let h="";if(n>0&&s>0&&(h=o.toString().padStart(s,"0").slice(0,n).replace(/0+$/,"")),l>0n&&c===0n&&h===""){const d=n===0?"1":`0.${"0".repeat(n-1)}1`;return`${r?"-":""}<${d}`}return`${r?"-":""}${Ct(c.toString())}${h?`.${h}`:""}`}function C(t,s=2){return _s(t,18,s)}function ce(t,s=2){return _s(t,6,s)}function W(t){if(typeof t=="number")return Number.isFinite(t)?Ct(Math.trunc(t).toString()):"—";const s=typeof t=="bigint"?t:J(t);if(s===null)return"—";const n=s<0n;return`${n?"-":""}${Ct((n?-s:s).toString())}`}function ie(t){return t==null||!Number.isFinite(t)?"—":`${(t/100).toFixed(2)}%`}function se(t){const s=J(t);return s===null||s===0n}function jt(t,s){const n=J(t)??0n,a=J(s)??0n;return n<a?-1:n>a?1:0}function At(t){return t.reduce((s,n)=>s+(J(n)??0n),0n).toString()}function ut(t){return t.length<=13?t:`${t.slice(0,6)}…${t.slice(-4)}`}function Et(t){return t.length<=18?t:`${t.slice(0,10)}…${t.slice(-6)}`}function La(t){return/^0x[0-9a-fA-F]{40}$/.test(t)}function ue(t){return Number.isFinite(t)?`${new Date(t*1e3).toISOString().slice(0,16).replace("T"," ")} UTC`:"—"}function rt(t){return Number.isFinite(t)?new Date(t*1e3).toISOString().slice(0,10):"—"}function De(t,s,n){return s+t*n}function ht(t){const s=Math.max(0,Math.floor(t)),n=Math.floor(s/86400),a=Math.floor(s%86400/3600),r=Math.floor(s%3600/60),l=s%60,i=c=>c.toString().padStart(2,"0");return`${n}d ${i(a)}:${i(r)}:${i(l)}`}function Os(t){return t%86400===0?`${t/86400} days`:t%3600===0?`${t/3600} hours`:`${W(t)} s`}function Ot(t){return t===8453?"https://basescan.org":t===84532?"https://sepolia.basescan.org":null}function Ba(t){return Ot(t)?"Basescan":null}function Ua(t,s=Date.now()){const n=Math.max(0,Math.round((s-t)/1e3));if(n<5)return"just now";if(n<60)return`${n}s ago`;const a=Math.floor(n/60);if(a<60)return`${a}m ago`;const r=Math.floor(a/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function zs(t,s){const n=Ot(t);return n?`${n}/tx/${s}`:null}function Fa(t,s){const n=Ot(t);return n?`${n}/address/${s}`:null}function Je(t){return/^\d+(\.\d+)?$/.test(t.trim())?/[1-9]/.test(t):!1}function Da(t){return/^\d+$/.test(t.trim())&&Number(t)>0}function It(t,s){const n=/^(\d+)(?:\.(\d+))?$/.exec(t.trim());if(!n)return null;const a=n[1]??"0",r=(n[2]??"").slice(0,s).padEnd(s,"0");try{return BigInt(a)*10n**BigInt(s)+BigInt(r||"0")}catch{return null}}function Ce(t){return t instanceof Error?t.message:String(t)}function us(t,s){return t==null||!Number.isFinite(t)||!s?"—":`${(t*100/s).toFixed(2)}%`}function We(t){const s=typeof t=="bigint"?t:J(t);if(s===null)return"—";const n=s<0n,a=(n?-s:s)/10000n,r=Number(a)/100,l=n?"-":"";return r>=1e6?`${l}$${(r/1e6).toFixed(r>=1e7?0:1)}M`:r>=1e3?`${l}$${(r/1e3).toFixed(r>=1e4?0:1)}k`:r>=100?`${l}$${r.toFixed(0)}`:`${l}$${r.toFixed(2)}`}const Wa=3e3;let He=0;const ke=new Map,Ke=new Map,Tt=new Set;function lt({clear:t=!1,confirmed:s=!1}={}){if(He++,Ke.clear(),t)ke.clear();else for(const n of ke.values())n.at=0,n.reconciling||(n.reconciling=s);for(const n of Tt)n(t,s)}function _a(t,s=document,n=window){let a=!1;const r=()=>{a||s.visibilityState!=="visible"||(a=!0,t())},l=n.setTimeout(r,Wa);return s.addEventListener("visibilitychange",r),()=>{a=!0,n.clearTimeout(l),s.removeEventListener("visibilitychange",r)}}function ye(t){const s=t!==null?ke.get(t):void 0;return s?{key:t,data:s.data,error:null,loading:!1,reconciling:s.reconciling??!1,partial:s.partial??!1,updatedAt:s.at}:{key:t,data:null,error:null,loading:t!==null,reconciling:!1,partial:!1,updatedAt:null}}function V(t,s,n=6e4,a={}){const[r,l]=u.useState(()=>ye(t)),i=u.useRef(s);i.current=s;const c=u.useRef(a);c.current=a;const o=u.useRef(t);o.current=t;const h=u.useRef(!0),d=u.useRef(0);u.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const m=u.useCallback((y,E=!1)=>{const P=He;l(A=>{const N=A.key===y?A:ye(y);return{...N,loading:!0,error:null,reconciling:E||N.reconciling}});let T=Ke.get(y);if(!T){const A=i.current();T=A,Ke.set(y,A),A.then(N=>{var b,v,L,D,S,g;if(P!==He)return;const U=((v=(b=c.current).isPartial)==null?void 0:v.call(b,N))??!1,k=ke.get(y);if((D=(L=c.current).isSyncing)!=null&&D.call(L,N)){const w=k&&!c.current.isSyncing(k.data);ke.set(y,{data:w?k.data:N,at:0,partial:w?k.partial:U,reconciling:!0});return}const B=U&&k&&!((g=(S=c.current).isPartial)!=null&&g.call(S,k.data));ke.set(y,{data:B?k.data:N,at:B?k.at:Date.now(),partial:U})}).catch(()=>{}).finally(()=>{Ke.get(y)===A&&Ke.delete(y)})}T.then(()=>{!h.current||o.current!==y||P!==He||l(ye(y))},A=>{if(!h.current||o.current!==y||P!==He)return;const N=A instanceof Fs,U=ke.get(y);N&&U&&(U.at=0,U.reconciling=!0),l(k=>{const B=k.key===y?k:ye(y);return{...B,key:y,loading:!1,reconciling:N||B.reconciling,error:N?null:Ce(A)}})})},[]);u.useEffect(()=>{if(t===null){l(ye(null));return}const y=ke.get(t);y&&(l(ye(t)),!y.partial&&Date.now()-y.at<n)||m(t)},[t,m,n]),u.useEffect(()=>{const y=(E,P)=>{o.current!==null&&(E&&o.current!=="config"&&l(ye(o.current)),m(o.current,P&&!E))};return Tt.add(y),()=>{Tt.delete(y)}},[m]);const x=u.useCallback(()=>{o.current!==null&&m(o.current)},[m]);u.useEffect(()=>{d.current=0},[t]),u.useEffect(()=>{if(!r.error){r.loading||(d.current=0);return}if(c.current.retryOnError===!1||t===null||d.current>=2||!/rate limit|network error|HTTP 5\d\d|timeout/i.test(r.error))return;const y=window.setTimeout(()=>{d.current+=1,m(t)},25e3*(d.current+1));return()=>window.clearTimeout(y)},[t,r.error,r.loading,m]);const f=r.key===t&&r.reconciling&&!r.error;u.useEffect(()=>{if(!(!f||r.loading||t===null))return _a(()=>m(t))},[t,f,r.loading,m]);const j=r.key===t?r:ye(t);return{data:j.data,error:j.error,loading:j.loading,reconciling:j.reconciling,partial:j.partial,updatedAt:j.updatedAt,refresh:x}}const Oa={overview:"stake",pools:"stake",usage:"network",emissions:"network",verification:"network"};function za(t){return Ds.some(s=>s===t)}function qa(t){const s=t.startsWith("#")?t.slice(1):t,[n="",a=""]=s.split("?"),r=n.split("/").filter(Boolean),l=r[0],i=l!==void 0?Oa[l]:void 0,c=za(l)?l:i??"stake",o=ae().pages;return{page:o.includes(c)?c:o[0]??c,segments:r.slice(1),query:new URLSearchParams(a),redirected:i!==void 0}}function hs(){const t=qa(ae().currentPath());return t.redirected&&ae().replace(t.page),t}function Ya(){const[t,s]=u.useState(hs);return u.useEffect(()=>{const n=()=>s(hs());return ae().subscribe(n)},[]),t}function _e(t,...s){return ae().href([t,...s].join("/"))}const qs="ants.dashboard.started-jobs";function Va(){try{const t=JSON.parse(sessionStorage.getItem(qs)??"[]");return new Set(Array.isArray(t)?t.filter(s=>typeof s=="string").slice(-100):[])}catch{return new Set}}function Ha(t,s){const n=new Set([...t,s].slice(-100));try{sessionStorage.setItem(qs,JSON.stringify([...n]))}catch{}return n}const Ys=u.createContext(null),Vs=()=>u.useContext(Ys);function Ka(t,s){var n,a;return t.browserWallet?s.status==="connecting"||s.status==="reconnecting"?{label:"Connecting wallet…",reason:"Wait for the wallet connection to finish."}:s.status!=="connected"||!s.address?{label:"Connect wallet",reason:"Connect wallet before submitting a transaction."}:s.chainId!==t.evmChainId?{label:"Switch network",reason:`Switch your wallet to ${t.chainId}.`}:t.readOnly||s.address.toLowerCase()!==((n=t.walletAddress)==null?void 0:n.toLowerCase())?{label:"Waiting for wallet sync…",reason:"Wait for the connected wallet to sync with the dashboard."}:((a=s.clientAddress)==null?void 0:a.toLowerCase())!==s.address.toLowerCase()||s.clientChainId!==t.evmChainId?{label:"Waiting for wallet…",reason:"The connected wallet is not ready to sign yet."}:{}:{}}const Ja=2e3,Ga=8e3,Qa=new Set(["stake","restake","stake-usage","compound"]),Hs=u.createContext(null);function Ae(){const t=u.useContext(Hs);if(!t)throw new Error("JobsContext is not mounted");return t}const Za={stake:"Stake",move:"Move stake",split:"Split position",merge:"Merge positions",extend:"Extend lock","max-lock":"Max lock",withdraw:"Withdraw",claim:"Claim rewards",restake:"Stake rewards","stake-usage":"Stake rewards",compound:"Stake rewards","verify-submit":"Submit proof","seller-register":"Register seller","claim-starter":"Claim starter"};function zt(t){const s=Za[t];if(s)return s;const n=t.replace(/[-_]+/g," ").trim();return n?n.charAt(0).toUpperCase()+n.slice(1):"Transaction"}function Xa(t,s){const n=s,r=(Array.isArray(n==null?void 0:n.positionIds)?n.positionIds:[n==null?void 0:n.positionId]).filter(l=>typeof l=="number"&&Number.isSafeInteger(l)&&l>0);return`${zt(t)}${r.length?` · position${r.length>1?"s":""} ${r.map(l=>`#${l}`).join(", ")}`:""}`}function ms(t){return[...t].sort((s,n)=>n.startedAt-s.startedAt)}function er({children:t}){const s=Vs(),n=u.useRef(s);n.current=s;const a=u.useRef(new Map),r=u.useCallback(S=>a.current.get(S)??"Transaction",[]),[l,i]=u.useState([]),[c,o]=u.useState(Va),h=u.useRef(c),[d,m]=u.useState(!1),[x,f]=u.useState(null),[j,y]=u.useState([]),E=u.useRef(new Map),P=u.useRef(0),T=u.useRef(new Map),A=u.useCallback(S=>{const g=T.current.get(S);g!==void 0&&(window.clearTimeout(g),T.current.delete(S)),y(w=>w.filter(p=>p.id!==S))},[]),N=u.useCallback(S=>{const g=++P.current;y(w=>[...w.filter(p=>!S.jobId||p.jobId!==S.jobId),{...S,id:g}]),S.sticky||T.current.set(g,window.setTimeout(()=>A(g),Ga))},[A]);u.useEffect(()=>{const S=T.current;return()=>{for(const g of S.values())window.clearTimeout(g);S.clear()}},[]);const U=u.useCallback((S,g)=>{var I,_;let w=!1,p=!1;for(const $ of S){a.current.has($.id)||a.current.set($.id,zt($.kind));let M=E.current.get($.id);if(!M){const O=g||$.status!=="running"&&!h.current.has($.id);if(M={hashes:new Set,terminal:O&&$.status!=="running"},O)for(const H of $.steps)H.hash&&M.hashes.add(H.hash);E.current.set($.id,M)}for(const O of $.steps)!O.hash||M.hashes.has(O.hash)||(M.hashes.add(O.hash),g||N({tone:"success",jobId:$.id,title:`${r($.id)} · Confirmed`,body:O.label,hash:O.hash,sticky:!1}));if($.status!=="running"&&!M.terminal){if(M.terminal=!0,w=!0,p||(p=$.steps.some(O=>!!O.hash)),$.status==="failed")N({tone:"danger",jobId:$.id,title:`${r($.id)} · ${(I=$.error)!=null&&I.startsWith("You rejected")?"Rejected":"Failed"}`,body:$.error??"The transaction did not complete.",sticky:!0});else if(!g){const O=Qa.has($.kind)?{href:_e("positions"),label:"View my positions"}:void 0;N({tone:"success",jobId:$.id,title:`${r($.id)} · ${$.steps.some(H=>!!H.hash)?"Confirmed":"Complete"}`,hash:(_=[...$.steps].reverse().find(H=>!!H.hash))==null?void 0:_.hash,sticky:!!O,link:O})}}}i(ms(S)),w&&!g&<({confirmed:p})},[N,r]),k=u.useRef(!0),B=u.useCallback(async()=>{const S=k.current;try{const g=await q.jobs();U(g,S),k.current=!1,f(null)}catch(g){f(Ce(g))}},[U]);u.useEffect(()=>{B()},[B]);const b=u.useMemo(()=>l.filter(S=>S.status==="running").length,[l]),v=b>0;u.useEffect(()=>{if(!d&&!v)return;let S=!1,g=0;const w=async()=>{S||(await B(),!S&&(g=window.setTimeout(()=>void w(),Ja)))};return w(),()=>{S=!0,window.clearTimeout(g)}},[d,v,B]);const L=u.useCallback(async(S,g)=>{var p;(p=n.current)==null||p.assertReady();const w=await q.startJob(S,g);return a.current.set(w.id,Xa(w.kind,g)),h.current=Ha(h.current,w.id),o(h.current),k.current=!1,E.current.has(w.id)||E.current.set(w.id,{hashes:new Set,terminal:!1}),f(null),i(I=>ms([w,...I.filter(_=>_.id!==w.id)])),w},[]),D=u.useMemo(()=>({jobs:l,locallyStartedJobIds:c,pending:b,running:v,drawerOpen:d,pollError:x,toasts:j,setDrawerOpen:m,dismissToast:A,pushToast:N,titleForJob:r,start:L}),[l,c,b,v,d,x,j,A,N,r,L]);return e.jsx(Hs.Provider,{value:D,children:t})}const Me={rejected:"You rejected the wallet request. This request was not submitted.",disconnected:"The wallet disconnected or no longer permits this request. Reconnect before retrying.",network:"The wallet is on the wrong network. Switch to the dashboard network before retrying.",reverted:"The contract rejected this transaction during wallet simulation. Refresh the position and review its action restrictions.",unknown:"The wallet could not complete the request. Check its activity before retrying; the submission status is unknown."};function tr(t){const s=new Set;let n=t,a=Me.unknown;for(;n&&typeof n=="object"&&!s.has(n);){s.add(n);const r=n;if(r.code===4001||r.name==="UserRejectedRequestError")return Me.rejected;if(r.code===4100||r.code===4900||r.name==="ProviderDisconnectedError"||r.name==="ConnectorNotConnectedError")return Me.disconnected;if(r.code===4901)return Me.network;(r.name==="ChainMismatchError"||r.name==="SwitchChainError"||r.name==="ChainDisconnectedError")&&(a=Me.network),(r.name==="ContractFunctionRevertedError"||r.name==="ExecutionRevertedError")&&(a=Me.reverted),n=r.cause}return a}class sr{constructor(){Ve(this,"attempted",new Set)}canPrompt(s){var a,r;const n=s.transaction;return!!(n!=null&&n.jobId)&&s.locallyStartedJobIds.has(n.jobId)&&!s.busy&&!s.settling&&!n.approvalStarted&&!n.submittedHash&&!this.attempted.has(n.id)&&((a=s.accountAddress)==null?void 0:a.toLowerCase())===n.from.toLowerCase()&&((r=s.walletAddress)==null?void 0:r.toLowerCase())===n.from.toLowerCase()&&s.expectedChainId===n.chainId&&s.accountChainId===n.chainId&&s.walletChainId===n.chainId}claim(s){return this.canPrompt(s)?(this.attempted.add(s.transaction.id),!0):!1}}class nr{constructor(s){Ve(this,"results",new Map);Ve(this,"delivering",new Set);this.send=s}enqueue(s){this.results.has(s.id)||this.results.set(s.id,s)}async deliver(s){if(!s||this.delivering.has(s))return;const n=this.results.get(s);if(n){this.delivering.add(s);try{await this.send(n),this.results.delete(s)}catch{return}finally{this.delivering.delete(s)}}}}const ar=new Nn,rr=aa(ia),lr=sa;function ir({config:t,children:s}){const n=u.useMemo(()=>Xn({appName:"AntSeed Staking",projectId:la,chains:[ta({id:t.evmChainId,name:t.chainId,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[t.walletRpcUrl??(t.evmChainId===8453?"https://mainnet.base.org":t.evmChainId===84532?"https://sepolia.base.org":"http://127.0.0.1:8545")]}}})],transports:{[t.evmChainId]:ea()}}),[t.chainId,t.evmChainId,t.walletRpcUrl]);return t.browserWallet?ae().embedded?e.jsx(ps,{config:t,children:s}):e.jsx(lr,{config:n,children:e.jsx(kn,{client:ar,children:e.jsx(na,{theme:rr,children:e.jsx(ps,{config:t,children:s})})})}):e.jsx(e.Fragment,{children:s})}function ps({config:t,children:s}){const n=_t(),{data:a}=Us(),r=Ka(t,{status:n.status,address:n.address,chainId:n.chainId,clientAddress:a==null?void 0:a.account.address,clientChainId:a==null?void 0:a.chain.id}),l=u.useRef(r);l.current=r;const i=u.useCallback(()=>{if(l.current.reason)throw new Error(l.current.reason)},[]);return e.jsx(Ys.Provider,{value:{...r,assertReady:i},children:s})}function Ks({config:t}){const s=_t(),{jobs:n,running:a,locallyStartedJobIds:r,pushToast:l,titleForJob:i}=Ae(),{data:c}=Us(),[o,h]=u.useState(null),[d,m]=u.useState(null),[x,f]=u.useState(!1),j=u.useRef(!1),y=u.useRef(new sr),E=u.useRef(new Map),P=u.useRef(null),T=u.useRef(Promise.resolve()),A=u.useRef(new nr(v=>$e("/api/wallet/result",{method:"POST",body:v}))),N=u.useRef(!1);N.current=a||x||o!==null;const U=!!s.address&&s.chainId!==t.evmChainId,k=s.status==="connecting"||s.status==="reconnecting";u.useEffect(()=>{d&&l({tone:"danger",title:"Wallet request failed",body:d,sticky:!0})},[d,l]),u.useEffect(()=>{var I;if(k)return;let v=!1,L;const D=`${((I=s.address)==null?void 0:I.toLowerCase())??""}:${s.chainId??""}`,S=!!P.current&&!P.current.startsWith(":");let g=!1;function w(_=!1){g||v||(g=!0,T.current=T.current.catch(()=>{}).then(async()=>{if(!v)try{const $=_&&!U,M=U||!s.address&&S,O=await $e("/api/wallet",{method:"POST",body:{address:U?void 0:s.address,chainId:s.chainId,refresh:$,disconnect:M}});if(!v){const H=O.changed??P.current!==D;P.current=D,m(null),(H||$)&<({clear:H})}}catch($){v||(m($ instanceof Error?$.message:String($)),t.selectedAddress&&$ instanceof Ne&&$.status===400?lt():L=setTimeout(()=>w(_),1500))}finally{g=!1}}))}w();const p=()=>{N.current||w(!0)};return window.addEventListener("focus",p),()=>{v=!0,clearTimeout(L),window.removeEventListener("focus",p)}},[s.address,s.chainId,U,k,t.selectedAddress]),u.useEffect(()=>{let v=!1,L;const D=async()=>{try{const S=await $e("/api/wallet/request");v||(h(S),await A.current.deliver((S==null?void 0:S.id)??null))}catch{}finally{v||(L=setTimeout(()=>void D(),a||o!==null?1e3:3e4))}};return D(),()=>{v=!0,clearTimeout(L)}},[a,o!==null]),u.useEffect(()=>{if(!(o!=null&&o.jobId))return;const v=n.find(D=>D.id===o.jobId);if(!v||v.status!=="running")return;const L=o.submittedHash?"Submitted":"Awaiting wallet approval";E.current.get(o.id)!==L&&E.current.get(o.id)!=="Submitted"&&(E.current.set(o.id,L),l({tone:"info",jobId:o.jobId,title:`${i(o.jobId)} · ${L}`,body:o.submittedHash?"Waiting for on-chain confirmation.":"No transaction has been submitted yet.",hash:o.submittedHash,sticky:!0}))},[o,n,l,i]);const B=u.useCallback(async()=>{var L;if(!o||!c||j.current||o.submittedHash)return;j.current=!0,f(!0),m(null);let v=!1;try{if(c.account.address.toLowerCase()!==o.from.toLowerCase()||((L=s.address)==null?void 0:L.toLowerCase())!==o.from.toLowerCase()||s.chainId!==o.chainId||c.chain.id!==o.chainId||t.evmChainId!==o.chainId)throw new Error("Connect the wallet and network shown in this request.");await $e("/api/wallet/begin",{method:"POST",body:{id:o.id}}),v=!0;const D=await c.sendTransaction({account:c.account,chain:c.chain,to:o.to,data:o.data,value:BigInt(o.value)});A.current.enqueue({id:o.id,hash:D}),E.current.set(o.id,"Submitted"),l({tone:"info",jobId:o.jobId,title:`${i(o.jobId??"")} · Submitted`,body:"Waiting for on-chain confirmation.",hash:D,sticky:!0}),await A.current.deliver(o.id)}catch(D){const S=tr(D);v?(A.current.enqueue({id:o.id,error:S}),await A.current.deliver(o.id)):m(S)}finally{j.current=!1,f(!1)}},[o,c,s.address,s.chainId,t.evmChainId,l,i]),b=u.useMemo(()=>({transaction:o,locallyStartedJobIds:r,accountAddress:s.address,accountChainId:s.chainId,walletAddress:c==null?void 0:c.account.address,walletChainId:c==null?void 0:c.chain.id,expectedChainId:t.evmChainId,busy:x,settling:k}),[o,r,s.address,s.chainId,c,t.evmChainId,x,k]);return u.useEffect(()=>{y.current.claim(b)&&B()},[b,B]),e.jsxs("div",{className:"browser-wallet",children:[e.jsx(Is,{accountStatus:"address",chainStatus:"icon",showBalance:!1}),U&&e.jsxs("span",{className:"hint",children:["Switch to ",t.chainId," to continue."]})]})}function or(){return e.jsx(Is.Custom,{children:({account:t,chain:s,openConnectModal:n,openAccountModal:a,openChainModal:r,mounted:l})=>e.jsx("button",{className:"btn",disabled:!l,onClick:t?s!=null&&s.unsupported?r:a:n,children:t?s!=null&&s.unsupported?"Switch network":"Change wallet":"Connect wallet"})})}function ze(...t){return t.filter(Boolean).join(" ")}function G({children:t,className:s,fullWidth:n=!1,leadingIcon:a,size:r="md",type:l="button",variant:i="primary",...c}){return e.jsxs("button",{type:l,className:ze("btn",`btn--${i}`,`btn--${r}`,n&&"btn--full",s),...c,children:[a?e.jsx("span",{className:"btn__icon","aria-hidden":"true",children:a}):null,e.jsx("span",{className:"btn__label",children:t})]})}function we({children:t,className:s,tone:n="surface",...a}){return e.jsx("div",{className:ze("card",n!=="surface"&&`card--${n}`,s),...a,children:t})}function Qe({action:t,children:s,className:n,title:a,tone:r="info",...l}){return e.jsxs("div",{className:ze("alert",`alert--${r}`,n),role:r==="danger"||r==="warning"?"alert":"status",...l,children:[e.jsxs("div",{className:"alert__content",children:[a?e.jsx("div",{className:"alert__title",children:a}):null,e.jsx("div",{className:"alert__body",children:s})]}),t?e.jsx("div",{className:"alert__action",children:t}):null]})}function qt({className:t,height:s,radius:n,style:a,width:r,...l}){return e.jsx("div",{className:ze("skeleton",t),style:{...a,...s!==void 0?{height:s}:{},...n!==void 0?{borderRadius:n}:{},...r!==void 0?{width:r}:{}},...l})}function cr({className:t,error:s,hint:n,id:a,label:r,...l}){const i=a??l.name;return e.jsxs("label",{className:ze("field",t),htmlFor:i,children:[r?e.jsx("span",{className:"field__label",children:r}):null,e.jsx("input",{id:i,className:"field__input",...l}),s?e.jsx("span",{className:"field__error",children:s}):n?e.jsx("span",{className:"field__hint",children:n}):null]})}function Yt({children:t,className:s,label:n,type:a="button",...r}){return e.jsx("button",{type:a,className:ze("icon-button",s),"aria-label":n,title:r.title??n,...r,children:t})}const Js=u.createContext(null);function Ee(){const t=u.useContext(Js);if(!t)throw new Error("AppContext is not mounted");return t}function Ie(){return Ee().config}function he(){var t;return((t=Ee().overview)==null?void 0:t.epoch)??null}function tt({rows:t=4,width:s}){return e.jsx("div",{className:"skel-list","aria-busy":"true",children:Array.from({length:t},(n,a)=>e.jsx(qt,{height:14,width:s??`${60+a*17%40}%`},a))})}function ne({error:t,onRetry:s,title:n}){return e.jsx(Qe,{tone:"danger",title:n,action:s?e.jsx(G,{variant:"outline",size:"sm",onClick:s,children:"Retry"}):void 0,children:e.jsx("span",{className:"break",children:t})})}function mt(){return e.jsx("span",{className:"spinner","aria-label":"loading"})}function pt(t=1e3){const[s,n]=u.useState(()=>Date.now());return u.useEffect(()=>{const a=window.setInterval(()=>n(Date.now()),t);return()=>window.clearInterval(a)},[t]),s}function Gs(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}function dr(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2.5 6.2l2.4 2.4 4.6-4.9",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function ur(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M3 3l6 6M9 3l-6 6",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function Qs({status:t}){return t==="running"?e.jsx("span",{className:"status-icon status-icon--running",title:"Pending",children:e.jsx(mt,{})}):t==="done"?e.jsx("span",{className:"status-icon status-icon--done",title:"Confirmed",children:e.jsx(dr,{})}):e.jsx("span",{className:"status-icon status-icon--failed",title:"Failed",children:e.jsx(ur,{})})}function Zs({hash:t,showHash:s=!1}){const{evmChainId:n}=Ie(),a=zs(n,t),r=Ba(n);return!a||!r?e.jsx("span",{className:"activity-hash mono",title:t,children:Et(t)}):e.jsxs("span",{className:"activity-link-wrap",children:[e.jsxs("a",{className:"activity-link",href:a,target:"_blank",rel:"noreferrer",title:t,children:["View on ",r]}),s?e.jsx("span",{className:"activity-hash mono dim",children:Et(t)}):null]})}function xs(){const{drawerOpen:t,setDrawerOpen:s}=Ae();if(u.useEffect(()=>{if(!t)return;const a=r=>{r.key==="Escape"&&s(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,s]),!t)return null;const n=()=>s(!1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"drawer-backdrop",onClick:n}),e.jsxs("aside",{className:"drawer activity-drawer",role:"dialog","aria-modal":"true","aria-label":"Activity",children:[e.jsxs("header",{className:"drawer-header",children:[e.jsx("div",{className:"drawer-titles",children:e.jsx("h2",{className:"drawer-title",children:"Activity"})}),e.jsx(Yt,{label:"Close",className:"drawer-close",onClick:n,children:e.jsx(Gs,{})})]}),e.jsx("div",{className:"drawer-body",children:e.jsx(hr,{})})]})]})}function hr(){const{jobs:t,pollError:s}=Ae(),n=pt(1e3);return e.jsxs(e.Fragment,{children:[t.length===0?e.jsx("div",{className:"activity-empty",children:"No recorded transactions. Signed-wallet activity is saved locally for 30 days."}):e.jsx("ol",{className:"activity-list",children:t.map(a=>e.jsx(mr,{job:a,now:n},a.id))}),s?e.jsxs("div",{className:"activity-poll-error",children:["Could not refresh activity: ",s]}):null]})}function mr({job:t,now:s}){var r;const n=t.steps.filter(l=>l.hash),a=(r=t.steps[0])==null?void 0:r.label;return e.jsxs("li",{className:`activity-row activity-row--${t.status}`,children:[e.jsxs("div",{className:"activity-main",children:[e.jsx("div",{className:"activity-title",children:zt(t.kind)}),a?e.jsx("div",{className:"activity-sub",children:a}):null,t.steps.length>1?e.jsxs("details",{children:[e.jsx("summary",{children:"Action steps"}),e.jsx("ol",{children:t.steps.map((l,i)=>e.jsx("li",{children:l.label},i))})]}):null,t.status==="failed"&&t.error?e.jsx("div",{className:"activity-error",children:t.error}):null,n.length>0?e.jsx("div",{className:"activity-links",children:n.map(l=>e.jsx(Zs,{hash:l.hash,showHash:n.length>1},l.hash))}):null]}),e.jsxs("div",{className:"activity-side",children:[e.jsx(Qs,{status:t.status}),e.jsx("span",{className:"activity-time",children:Ua(t.startedAt,s)})]})]})}function K({value:t,kind:s="address",short:n=!0,label:a,copy:r=!1,className:l}){const{evmChainId:i}=Ie(),c=s==="tx"?zs(i,t):Fa(i,t),o=a??(n?s==="tx"?Et(t):ut(t):t),h=`mono ${l??""}`.trim();return e.jsxs("span",{className:"nowrap",children:[c?e.jsx("a",{className:h,href:c,target:"_blank",rel:"noreferrer",title:t,children:o}):e.jsx("span",{className:h,title:t,children:o}),r?e.jsx(pr,{value:t}):null]})}function pr({value:t}){const[s,n]=u.useState(!1),a=()=>{var r;(r=navigator.clipboard)==null||r.writeText(t).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)}).catch(()=>{})};return e.jsx("button",{className:"link-button",style:{marginLeft:6},onClick:a,type:"button",title:"Copy",children:s?"copied":"copy"})}function fs(){const{toasts:t,dismissToast:s}=Ae();return t.length===0?null:e.jsx("div",{className:"toasts",role:"region","aria-label":"Transaction notifications",children:t.map(n=>e.jsxs("div",{className:`toast toast--${n.tone}`,role:n.tone==="danger"?"alert":"status",children:[e.jsx(Qs,{status:n.tone==="danger"?"failed":n.tone==="info"?"running":"done"}),e.jsxs("div",{className:"toast-body",children:[e.jsx("div",{className:"toast-title",children:n.title}),n.body?e.jsx("div",{className:"toast-text",children:n.body}):null,n.hash?e.jsx(Zs,{hash:n.hash}):null,n.link?e.jsxs("a",{className:"toast-link",href:n.link.href,children:[n.link.label," →"]}):null]}),e.jsx(Yt,{label:"Dismiss",className:"toast-close",onClick:()=>s(n.id),children:e.jsx(Gs,{})})]},n.id))})}function xr({page:t,updatedAt:s,children:n}){return ae().embedded?e.jsxs("div",{className:"app app--embedded",children:[e.jsx(gr,{updatedAt:s}),e.jsx("main",{className:"main",children:n}),e.jsx(xs,{}),e.jsx(fs,{})]}):e.jsxs("div",{className:"app",children:[e.jsx(fr,{page:t,updatedAt:s}),e.jsx("div",{className:"content",children:e.jsx("main",{className:"main",children:n})}),e.jsx(xs,{}),e.jsx(fs,{})]})}function fr({page:t,updatedAt:s}){const{config:n,theme:a,toggleTheme:r}=Ee();return e.jsxs("aside",{className:"sidebar",children:[e.jsxs("a",{className:"wordmark",href:_e("stake"),children:["ANTS",e.jsx("span",{children:"staking"})]}),e.jsx("nav",{className:"sidenav","aria-label":"Main",children:Ia.map(l=>e.jsxs("div",{className:"sidenav-group",children:[e.jsx("div",{className:"sidenav-label",children:l.label}),l.items.map(i=>e.jsxs("a",{href:_e(i.id),className:i.id===t?"sidenav-item active":"sidenav-item","aria-current":i.id===t?"page":void 0,children:[e.jsx(br,{page:i.id}),e.jsx("span",{children:i.label})]},i.id))]},l.label))}),e.jsxs("div",{className:"sidebar-foot",children:[e.jsx(Xs,{updatedAt:s}),n.selectedAddress&&e.jsxs("div",{className:"small",children:["Selected account ",e.jsx(K,{value:n.selectedAddress,copy:!0})]}),e.jsxs("div",{className:"sidebar-foot-row",children:[n.browserWallet?e.jsx(Ks,{config:n}):e.jsx("span",{className:"wallet-chip",children:e.jsx(K,{value:n.address,copy:!0,className:"wallet-chip-addr"})}),e.jsx(Yt,{label:a==="dark"?"Switch to light theme":"Switch to dark theme",className:"theme-toggle",onClick:r,children:a==="dark"?e.jsx(jr,{}):e.jsx(wr,{})})]})]})]})}function gr({updatedAt:t}){const{config:s}=Ee();return e.jsxs("div",{className:"embedded-toolbar",children:[e.jsx(Xs,{updatedAt:t}),s.selectedAddress&&e.jsxs("div",{className:"small",children:["Selected account ",e.jsx(K,{value:s.selectedAddress,copy:!0})]}),e.jsx("div",{className:"embedded-toolbar__wallet",children:s.browserWallet?e.jsx(Ks,{config:s}):e.jsx("span",{className:"wallet-chip",children:e.jsx(K,{value:s.address,copy:!0,className:"wallet-chip-addr"})})})]})}function Xs({updatedAt:t}){const{overview:s}=Ee(),n=pt(3e4);if(!s)return null;const a=s.epoch,r=t!==null?t+a.secondsToBoundary*1e3:a.nextBoundaryAt*1e3,l=Math.max(0,Math.floor((r-n)/1e3)),i=e.jsxs(e.Fragment,{children:[e.jsx("i",{"aria-hidden":"true"}),e.jsxs("span",{children:["epoch ",e.jsx("strong",{children:a.current})]}),e.jsxs("span",{children:["· ",e.jsx("strong",{children:ht(l)})," left"]})]}),c="Current epoch and time until the next boundary";return ae().pages.includes("network")?e.jsx("a",{className:"epoch-chip",href:_e("network"),title:c,children:i}):e.jsx("span",{className:"epoch-chip",title:c,children:i})}function br({page:t}){const s={width:16,height:16,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};switch(t){case"stake":return e.jsx("svg",{...s,children:e.jsx("path",{d:"M2 13h12M3.5 10.5v-3M7 10.5V4M10.5 10.5V6.5M14 10.5V2.5"})});case"positions":return e.jsxs("svg",{...s,children:[e.jsx("path",{d:"M8 2.5 14 5.5 8 8.5 2 5.5Z"}),e.jsx("path",{d:"m2 8.5 6 3 6-3M2 11.5l6 3 6-3"})]});case"rewards":return e.jsxs("svg",{...s,children:[e.jsx("circle",{cx:"8",cy:"8",r:"5.5"}),e.jsx("path",{d:"M8 5v6M6.2 6.6c0-.9.8-1.4 1.8-1.4s1.8.5 1.8 1.2c0 1.6-3.6.9-3.6 2.5 0 .8.8 1.3 1.8 1.3s1.8-.5 1.8-1.3"})]});case"seller":return e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),e.jsx("circle",{cx:"6",cy:"7",r:"1.5"}),e.jsx("path",{d:"M4 11c.5-1 1.2-1.5 2-1.5s1.5.5 2 1.5M9.5 6.5h2.5M9.5 9h2.5"})]});case"network":return e.jsxs("svg",{...s,children:[e.jsx("circle",{cx:"8",cy:"8",r:"5.5"}),e.jsx("path",{d:"M2.5 8h11M8 2.5c1.8 1.8 1.8 9.2 0 11M8 2.5c-1.8 1.8-1.8 9.2 0 11"})]});case"addresses":return e.jsxs("svg",{...s,children:[e.jsx("path",{d:"M6.5 9.5a2.5 2.5 0 0 0 3.5 0l2-2a2.5 2.5 0 0 0-3.5-3.5l-.8.8"}),e.jsx("path",{d:"M9.5 6.5a2.5 2.5 0 0 0-3.5 0l-2 2a2.5 2.5 0 0 0 3.5 3.5l.8-.8"})]});default:return null}}function jr(){return e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"8",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.4 3.4l1.4 1.4M11.2 11.2l1.4 1.4M3.4 12.6l1.4-1.4M11.2 4.8l1.4-1.4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function wr(){return e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M13.5 9.5A6 6 0 0 1 6.5 2.5a6 6 0 1 0 7 7z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})})}function Z({title:t,actions:s,children:n,className:a,tone:r}){return e.jsxs(we,{className:`panel ${a??""}`.trim(),tone:r,children:[t||s?e.jsxs("div",{className:"panel-head",children:[t?e.jsx("h3",{children:t}):e.jsx("span",{}),s?e.jsx("div",{className:"row",children:s}):null]}):null,n]})}function X({items:t}){return e.jsx("dl",{className:"facts",children:t.map(([s,n])=>e.jsx(vr,{label:s,value:n},s))})}function vr({label:t,value:s}){return e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s??"—"})]})}function Oe({columns:t,rows:s,rowKey:n,empty:a,loading:r,onRowClick:l,footer:i}){const c=o=>[o.align==="right"?"num":"",o.mono?"mono":"",o.className??""].filter(Boolean).join(" ")||void 0;return e.jsx("div",{className:"table-wrap",tabIndex:0,role:"region","aria-label":"Data table; scroll horizontally to see all columns",children:e.jsxs("table",{className:"table",children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map(o=>e.jsx("th",{className:[o.align==="right"?"num":"",o.className??""].filter(Boolean).join(" ")||void 0,title:o.title,"aria-sort":o.sortDirection,children:o.label},o.key))})}),e.jsxs("tbody",{children:[r&&s.length===0?Array.from({length:3},(o,h)=>e.jsx("tr",{children:t.map(d=>e.jsx("td",{children:e.jsx(qt,{width:"70%",height:12})},d.key))},`skel-${h}`)):null,!r&&s.length===0?e.jsx("tr",{children:e.jsx("td",{className:"empty",colSpan:t.length,children:a??"Nothing to show."})}):null,s.map((o,h)=>e.jsx("tr",{className:l?"clickable":void 0,onClick:l?()=>l(o):void 0,children:t.map(d=>e.jsx("td",{className:c(d),children:d.render(o,h)},d.key))},n(o)))]}),i?e.jsx("tfoot",{children:i}):null]})})}function yr(){const t=V("overview",q.overview),s=t.data,n=Object.entries((s==null?void 0:s.addresses)??{}).map(([a,r])=>({name:a,address:r})).sort((a,r)=>a.name.localeCompare(r.name));return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"page-title",children:"Addresses"}),t.error&&!s?e.jsx(ne,{error:t.error,onRetry:t.refresh}):null,e.jsx(Z,{title:"Protocol contracts",children:e.jsx(Oe,{columns:[{key:"name",label:"Contract",render:a=>a.name},{key:"address",label:"Address",render:a=>e.jsx(K,{value:a.address,short:!1,copy:!0})}],rows:n,rowKey:a=>a.name,loading:t.loading&&!s,empty:"No contract addresses are configured for this chain."})})]})}function de({summary:t,children:s,open:n,className:a,lazy:r=!1}){const[l,i]=u.useState(n??!1);return e.jsxs("details",{className:["details",a??""].filter(Boolean).join(" "),open:n,onToggle:c=>i(c.currentTarget.open),children:[e.jsx("summary",{children:t}),e.jsx("div",{className:"details-body",children:!r||l?s:null})]})}function wt(t,s){if(t===null||s===null||BigInt(s)===0n)return"—";const n=BigInt(t)*10000n/BigInt(s);return`${n/100n}.${(n%100n).toString().padStart(2,"0")}%`}const kr="Early withdrawal permanently burns some principal, based on the remaining lock and configured limits. No penalty after expiry. Preview shows the exact burn and payout. Claim rewards separately.";function $t(){return e.jsx(Ze,{label:"About the early-exit penalty",children:kr})}function Ze({label:t,children:s,symbol:n="?"}){const a=u.useId(),r=u.useRef(),l=()=>{clearTimeout(r.current)},i=()=>{r.current=setTimeout(()=>h(null),150)};u.useEffect(()=>()=>clearTimeout(r.current),[]);const c=u.useRef(null),[o,h]=u.useState(null),d=()=>{var f;l();const m=(f=c.current)==null?void 0:f.getBoundingClientRect();if(!m)return;const x=m.bottom+240>window.innerHeight;h({left:Math.max(8,Math.min(m.left,window.innerWidth-328)),top:x?m.top-8:m.bottom+8,above:x})};return u.useEffect(()=>{if(!o)return;const m=()=>h(null),x=f=>{f.key==="Escape"&&(f.stopPropagation(),m())};return window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),document.addEventListener("keydown",x,!0),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m),document.removeEventListener("keydown",x,!0)}},[o]),e.jsxs("span",{className:"early-exit-help",children:[e.jsx("button",{ref:c,type:"button",className:"early-exit-help__trigger","aria-label":t,"aria-describedby":o?a:void 0,onMouseEnter:d,onMouseLeave:i,onFocus:d,onBlur:()=>h(null),onClick:d,children:n}),o&&Ns.createPortal(e.jsx("span",{id:a,role:"tooltip",className:"early-exit-help__tooltip",onMouseEnter:l,onMouseLeave:i,style:{left:o.left,top:o.top,transform:o.above?"translateY(-100%)":void 0},children:s}),ae().portalTarget())]})}function re(t){return t===null?"Unavailable":`${C(t)} ANTS`}const gs={"seller-pools":"Seller pools",usage:"Usage rewards",team:"Team",reserve:"Reserve — base allowance",verification:"Verification"};function Nr({data:t}){var m,x;const s=[{key:"name",label:"Bucket",render:f=>gs[f.name]??f.name},{key:"share",label:"Share of scheduled emission",align:"right",mono:!0,render:f=>wt(f.budget,t.emission)},{key:"budget",label:"Bucket allowance",align:"right",mono:!0,render:f=>re(f.budget)}],n=[{name:"Staker rewards",budget:t.budgets.staker},{name:"Buyer usage rewards",budget:t.budgets.buyer},{name:"Seller usage rewards",budget:t.budgets.seller}],a=t.buckets.filter(f=>f.budget!==null&&f.nextBudget!==null&&f.budget!==f.nextBudget),r=t.stakerConfig,l=t.usageConfig,i=t.nextStakerConfig,c=t.nextUsageConfig,o=r&&i&&JSON.stringify(r)!==JSON.stringify(i),h=l&&c&&JSON.stringify(l)!==JSON.stringify(c),d=(f,j)=>`${us(f,t.shareDenominator)} – ${us(j,t.shareDenominator)}`;return e.jsxs(e.Fragment,{children:[e.jsxs(Z,{title:e.jsxs(e.Fragment,{children:[`Current epoch reward budgets · epoch ${t.epoch.current}`," ",e.jsx(Ze,{label:"When reward budgets become final",symbol:"i",children:"Budgets can change during the epoch. After it ends, each reward contract fixes its budgets on the first claim or settlement—not at rollover."})]}),children:[e.jsx("p",{className:"hint",children:"Live network-wide budgets—not your wallet rewards or amounts already paid."}),e.jsx(Oe,{columns:[{key:"name",label:"Recipient",render:f=>f.name},{key:"budget",label:"Calculated epoch budget",align:"right",mono:!0,render:f=>re(f.budget)},{key:"share",label:"Share of epoch emission",align:"right",mono:!0,render:f=>wt(f.budget,t.emission)}],rows:n,rowKey:f=>f.name}),e.jsxs(de,{summary:"How these budgets are calculated",children:[e.jsx("div",{className:"section-label",children:"Staker rewards"}),r?e.jsx(X,{items:[["Configured share range",d(r.minShareBps,r.maxShareBps)],["Network active stake used by the contract",re(t.totalActiveStake)],["Stake target for this epoch",re(t.scaledStakeTarget)],["Initial-emission stake target",re(r.stakeShareTarget)],["Seller-pools budget cap",re(((m=t.buckets.find(f=>f.name==="seller-pools"))==null?void 0:m.budget)??null)]]}):e.jsx("p",{className:"muted",children:"Staker configuration unavailable."}),e.jsx("p",{className:"hint",children:"With positive active stake, the share rises toward the configured maximum as stake grows. The stake target scales with the epoch emission; it is not a hard threshold. Zero active stake produces a zero budget."}),e.jsx("div",{className:"section-label mt",children:"Buyer and seller rewards"}),l?e.jsx(X,{items:[["Buyer share range",d(l.buyerMinShareBps,l.buyerMaxShareBps)],["Seller share range",d(l.sellerMinShareBps,l.sellerMaxShareBps)],["Accounted usage input",t.usageVolume===null?"Unavailable":`${ce(t.usageVolume)} USDC-equivalent`],["Usage target",`${ce(l.volumeShareTarget)} USDC-equivalent / epoch`],["Combined usage budget cap",re(((x=t.buckets.find(f=>f.name==="usage"))==null?void 0:x.budget)??null)]]}):e.jsx("p",{className:"muted",children:"Usage configuration unavailable."}),e.jsx("p",{className:"hint",children:"The usage input is the larger of the epoch’s total buyer points and total seller points—not their sum. With positive usage, each share rises toward its maximum. If the combined desired budgets exceed the usage bucket limit, the contract scales them proportionally. Zero usage produces zero budgets."}),e.jsx("p",{className:"hint",children:"For a positive input, the curve is minimum + (maximum − minimum) × input / (input + target), with contract integer rounding. A zero target selects the maximum. Displayed budgets come directly from contract getters, not a browser calculation."})]})]}),e.jsxs(Z,{title:`Emission bucket allowances · epoch ${t.epoch.current}`,children:[e.jsx("p",{className:"hint",children:"Bucket limits, not payouts. Shares use this epoch’s scheduled emission."}),e.jsx(Oe,{columns:s,rows:t.buckets,rowKey:f=>f.id,empty:"No emission buckets available."}),e.jsx("p",{className:"hint mt",children:"Unallocated seller-pool and usage allowances go to the burn destination (combined cap: 30% of scheduled emission), then Reserve on top of its base allowance. Requires an on-chain settlement."}),(a.length>0||o||h||t.nextEmission!==t.emission)&&e.jsxs(de,{summary:`Next epoch · ${t.epoch.current+1}`,children:[e.jsx(X,{items:[["Scheduled emission",re(t.nextEmission)],...a.map(f=>[gs[f.name]??f.name,`${re(f.nextBudget)} · ${wt(f.nextBudget,t.nextEmission)}`]),...o?[["Staker share range",d(i.minShareBps,i.maxShareBps)],["Staker target at initial emission",re(i.stakeShareTarget)]]:[],...h?[["Buyer share range",d(c.buyerMinShareBps,c.buyerMaxShareBps)],["Seller share range",d(c.sellerMinShareBps,c.sellerMaxShareBps)],["Usage target",`${ce(c.volumeShareTarget)} USDC-equivalent / epoch`]]:[]]}),e.jsx("p",{className:"hint",children:"Next-epoch allowances and configuration are shown separately. They are not a prediction of next epoch’s earned rewards."})]})]})]})}function me({label:t,value:s,unit:n,sub:a,loading:r,title:l}){return e.jsxs(we,{className:"tile",title:l,children:[e.jsx("div",{className:"tile-label",children:t}),r?e.jsx(qt,{width:"60%",height:22,style:{marginTop:3}}):e.jsxs("div",{className:"tile-value",children:[s,n?e.jsx("span",{className:"unit",children:n}):null]}),a?e.jsx("div",{className:"tile-sub",children:a}):null]})}function Vt({children:t}){return e.jsx("div",{className:"tiles",children:t})}function st({epoch:t,dateOnly:s=!1}){const n=he();if(t==null)return e.jsx("span",{className:"mono",children:"—"});const a=n?ue(De(t,n.genesis,n.epochDuration)):null;return s?e.jsx("span",{className:"mono",children:a??"—"}):e.jsxs("span",{className:"mono",title:a??void 0,children:[t,a?e.jsxs("span",{className:"muted small",children:[" ",a.slice(0,10)]}):null]})}function Ue({label:t,hint:s,width:n,children:a}){return e.jsxs("label",{className:["field",n?`field-w-${n}`:""].filter(Boolean).join(" "),children:[e.jsx("span",{className:"field__label",children:t}),a,s?e.jsx("span",{className:"field__hint",children:s}):null]})}function qe({mono:t=!0,width:s="md",className:n,...a}){const r=[`field-w-${s}`,n??""].filter(Boolean).join(" ");return e.jsx(cr,{className:r,...a,style:t?{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",...a.style}:a.style})}function Fe({className:t,children:s,...n}){const a=["field__input",t??""].filter(Boolean).join(" ");return e.jsx("span",{className:"select-wrap",children:e.jsx("select",{className:a,...n,children:s})})}const Sr=[4,8,12,26,52];function Cr(){const{overview:t}=Ee(),[s,n]=u.useState(8),[a,r]=u.useState(!1),l=V(`usage:${s}`,()=>q.usage(s)),i=l.data,c=[{key:"epoch",label:"Epoch",render:d=>e.jsx(st,{epoch:d.epoch})},{key:"buyer",label:"Your buyer pts",align:"right",mono:!0,render:d=>W(d.buyerPoints)},...a?[{key:"wbuyer",label:"Weighted",align:"right",mono:!0,title:"Buyer points after pool weighting",render:d=>W(d.weightedBuyerPoints)}]:[],{key:"seller",label:"Your seller pts",align:"right",mono:!0,render:d=>W(d.sellerPoints)},{key:"nbuyer",label:"Network buyer",align:"right",mono:!0,render:d=>W(d.totalBuyerPoints)},{key:"nseller",label:"Network seller",align:"right",mono:!0,render:d=>W(d.totalSellerPoints)},{key:"pool",label:"Pool pts",align:"right",mono:!0,render:d=>W(d.totalPoolPoints)},...a?[{key:"wpool",label:"Weighted pool pts",align:"right",mono:!0,render:d=>W(d.totalWeightedPoolPoints)}]:[]],o=(i==null?void 0:i.firstRewardedEpoch)??(t==null?void 0:t.epoch.effective)??null,h=o!==null&&(!i||i.currentEpoch<o)?`Usage accounting starts at epoch ${o}.`:"No usage has been recorded for this wallet in the selected epochs.";return e.jsxs(Z,{title:"Your usage · historical network comparisons",actions:e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"check small",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:d=>r(d.target.checked)}),"weighted columns"]}),e.jsxs("label",{className:"row small",children:[e.jsx("span",{className:"muted",children:"epochs"}),e.jsx(Fe,{value:s,onChange:d=>n(Number(d.target.value)),style:{width:72,minHeight:30,padding:"4px 8px"},children:Sr.map(d=>e.jsx("option",{value:d,children:d},d))})]})]}),children:[l.error&&!i?e.jsx(ne,{error:l.error,onRetry:l.refresh}):null,l.error&&i?e.jsxs("div",{className:"status-line",children:["Refresh failed: ",l.error]}):null,i&&e.jsxs("p",{className:"hint",children:[i.source==="indexer"?"Historical rows are indexed data and may lag the current contract snapshot.":"Historical rows are unavailable without the explorer; current totals are read from the chain.",i.sourceError?` ${i.sourceError}`:""]}),e.jsx(X,{items:[["Your buyer points",i?W(i.totals.buyerPoints):"…"],["Network buyer points",i?W(i.totals.networkBuyerPoints):"…"],["Network seller points",i?W(i.totals.networkSellerPoints):"…"],["First rewarded epoch",i?i.firstRewardedEpoch??"—":"…"]]}),e.jsx("div",{className:"mt",children:e.jsx(Oe,{columns:c,rows:(i==null?void 0:i.epochs)??[],rowKey:d=>d.epoch,loading:l.loading&&!i,empty:h,footer:i&&i.epochs.length>0?e.jsxs("tr",{children:[e.jsx("td",{children:"Total"}),e.jsx("td",{className:"num mono",children:W(i.totals.buyerPoints)}),a?e.jsx("td",{className:"num mono",children:W(i.totals.buyerWeightedPoints)}):null,e.jsx("td",{className:"num mono",children:W(Ar(i.epochs.map(d=>d.sellerPoints)))}),e.jsx("td",{className:"num mono",children:W(i.totals.networkBuyerPoints)}),e.jsx("td",{className:"num mono",children:W(i.totals.networkSellerPoints)}),e.jsx("td",{}),a?e.jsx("td",{}):null]}):null})}),e.jsxs(de,{summary:"Policies",children:[e.jsx(X,{items:[["Points policy",i!=null&&i.pointsPolicy?e.jsx(K,{value:i.pointsPolicy,short:!1}):e.jsx("span",{className:"muted",children:"not set"})],["Pool weight policy",i!=null&&i.poolWeightPolicy?e.jsx(K,{value:i.poolWeightPolicy,short:!1}):e.jsx("span",{className:"muted",children:"not set"})],["Minimum accounted pool power",i!=null&&i.minimumAccountedPoolPower?`${C(i.minimumAccountedPoolPower,4)} ANTS`:"—"],["Your weighted buyer points",i?W(i.totals.buyerWeightedPoints):"…"]]}),e.jsx("p",{className:"hint mt",children:"Points are raw usage units recorded on chain per epoch. Weighted points apply the pool weight policy; pools below the minimum accounted power earn no usage rewards."})]})]})}function Ar(t){return t.reduce((s,n)=>{try{return s+BigInt(n)}catch{return s}},0n).toString()}const Ht=u.createContext(null),en=typeof document>"u"?u.useEffect:u.useLayoutEffect;function Kt({title:t,children:s,onClose:n,busy:a=!1}){const r=u.useRef(!1),l=u.useRef(a);en(()=>{l.current=a},[a]);const[i]=u.useState(()=>typeof document<"u"&&document.activeElement instanceof HTMLElement?document.activeElement:null);u.useEffect(()=>()=>{queueMicrotask(()=>{i!=null&&i.isConnected&&i.focus({preventScroll:!0})})},[i]);const c=e.jsx(Dt,{isOpen:!0,title:t,size:"lg",overlayClassName:"ants-stake-overlay ants-action-overlay",onClose:()=>{!l.current&&!r.current&&n()},children:e.jsx(Ht.Provider,{value:r,children:s})});return typeof document>"u"?c:Ns.createPortal(c,ae().portalTarget())}function tn({title:t,hideTitle:s=!1,summary:n,children:a,confirmLabel:r="Confirm",danger:l,disabled:i,busy:c,error:o,onConfirm:h,onCancel:d,embedded:m,cancelLabel:x="Cancel"}){const f=u.useContext(Ht),j=m||f!==null;en(()=>(f&&(f.current=c===!0),()=>{f&&(f.current=!1)}),[c,f]);const y=e.jsxs(we,{className:"confirm",tone:l?"danger":"surface",role:"region","aria-label":t,children:[j&&!s?e.jsx("div",{className:"confirm-title",children:t}):null,n&&n.length>0?e.jsx("dl",{className:"facts",children:n.map(([E,P],T)=>e.jsx(Er,{label:E,value:P},`${E}-${T}`))}):null,a,o?e.jsx("div",{className:"error-text",children:o}):null,e.jsxs("div",{className:"confirm-actions",children:[e.jsx(G,{variant:l?"danger":"primary",onClick:h,disabled:i||c,children:c?"Sending…":r}),e.jsx(G,{variant:"outline",onClick:d,disabled:c,children:x})]})]});return j?y:e.jsx(Kt,{title:t,onClose:d,busy:c,children:y})}function Er({label:t,value:s}){return e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Jt(t=!1){const{config:{readOnly:s,selectedAddress:n,walletAddress:a,browserWallet:r},overview:l,overviewError:i}=Ee(),{running:c}=Ae(),o=Vs();return r&&!o?{blocked:!0,label:"Connect wallet",reason:"Connect wallet before submitting a transaction."}:o!=null&&o.reason?{blocked:!0,reason:o.reason,label:o.label}:s?{blocked:!0,reason:"Read-only mode: no wallet is available to sign."}:n&&!t&&n.toLowerCase()!==(a==null?void 0:a.toLowerCase())?{blocked:!0,reason:`Connect the selected account wallet ${n} for seller and staking actions.`}:!l||i?{blocked:!0,reason:"Wallet information is unavailable. Refresh before sending a transaction."}:BigInt(l.wallet.signingWalletEth??l.wallet.eth)===0n?{blocked:!0,reason:"The signing wallet needs ETH on the selected network for transaction fees."}:c?{blocked:!0,reason:"Another action is still running."}:{blocked:!1,reason:void 0}}function ge(t){const s=Ae(),n=t.body,a=t.path==="/api/rewards/claim"&&(n==null?void 0:n.scope)==="buyer"||t.path==="/api/rewards/stake-usage"&&(n==null?void 0:n.side)==="buyer",r=Jt(a),[l,i]=u.useState(!1),[c,o]=u.useState(null),[h,d]=u.useState(!1),m=u.useRef(!1),x=u.useContext(Ht),f=!t.children,j=r.blocked||t.disabled===!0,y=r.reason??(t.disabled?t.disabledReason:void 0),E=async()=>{var N;if(j||m.current||f&&t.confirmDisabled)return;const A=((N=t.validate)==null?void 0:N.call(t))??null;o(A),A===null&&(f?await P():i(!0))},P=async()=>{var N,U;if(j||t.confirmDisabled||m.current)return;const A=((N=t.validate)==null?void 0:N.call(t))??null;if(A!==null){o(A);return}m.current=!0,f&&x&&(x.current=!0),d(!0),o(null);try{await s.start(t.path,t.body),i(!1),(U=t.onStarted)==null||U.call(t)}catch(k){s.pushToast({tone:"danger",title:`${t.title??t.label} failed`,body:Ce(k),sticky:!0})}finally{m.current=!1,f&&x&&(x.current=!1),d(!1)}},T=t.variant==="primary"?"primary":t.variant==="danger"?"danger":"outline";return e.jsxs("div",{className:"action",children:[l?null:e.jsx("span",{className:"btn-wrap",title:y,children:e.jsx(G,{variant:T,size:t.size==="sm"?"sm":"md",onClick:E,disabled:j||h||f&&t.confirmDisabled,children:h&&f?"Sending…":r.label??t.label})}),c&&!l?e.jsx("div",{className:"error-text",children:c}):null,l?e.jsx(tn,{title:t.title??t.label,summary:t.summary,confirmLabel:r.label??t.confirmLabel??t.label,danger:t.variant==="danger",disabled:j||t.confirmDisabled,busy:h,error:c,onConfirm:()=>{P()},onCancel:()=>{i(!1),o(null)},children:t.children}):null]})}function le({tone:t="neutral",mono:s,title:n,children:a}){const r=["pill",t!=="neutral"?`pill--${t}`:"",s?"pill--mono":""].filter(Boolean).join(" ");return e.jsx("span",{className:r,title:n,children:a})}const vt="antseed-wash-trading-seller-proof";function Ir({data:t}){const s=t.registry;return e.jsx("div",{className:"stack",children:s?e.jsxs(e.Fragment,{children:[e.jsx(X,{items:[["Registry",e.jsx(K,{value:s.address})],["Enforced",t.enforced?e.jsx(le,{tone:"accent",children:"enforced"}):e.jsx(le,{tone:"muted",children:"not enforced"})],["Flag threshold",`${ie(s.thresholdBps)} of seller volume`],["Period blocks",`${W(s.periodStartBlock)} – ${W(s.periodEndBlock)}`]]}),e.jsxs(de,{summary:"Details",children:[e.jsx(X,{items:[["Verifier",e.jsx(K,{value:s.verifier,short:!1})],["Verifier hash",e.jsx("span",{className:"break mono small",children:s.verifierHash})],["Blockhash store",e.jsx(K,{value:s.blockhashStore,short:!1})],["Seller program vkey",e.jsx("span",{className:"break mono small",children:s.sellerProgramVKey})],["Points policy",t.pointsPolicy?e.jsx(K,{value:t.pointsPolicy,short:!1}):e.jsx("span",{className:"muted",children:"not set"})],...t.policies.map(n=>["Policy → pinned registry",e.jsxs("span",{children:[e.jsx(K,{value:n.address})," → ",n.washTradingRegistry?e.jsx(K,{value:n.washTradingRegistry}):e.jsx("span",{className:"muted",children:"not pinned"})]})])]}),e.jsx("div",{className:"hint mt",children:"Enforced means the active points policy pins the registry, so flagged sellers earn no usage points."})]})]}):e.jsx("span",{className:"muted",children:"No wash-trading registry is deployed on this chain."})})}function sn({data:t,seller:s}){const n=t.seller;return n?e.jsxs("div",{className:"stack",children:[e.jsxs("div",{className:"row",children:[n.isProvenWashTrader?e.jsx(le,{tone:"danger",children:"flagged wash trader"}):e.jsx(le,{tone:"accent",children:"not flagged"}),e.jsxs("span",{className:"muted small",children:["proven share ",e.jsx("span",{className:`mono ${n.isProvenWashTrader?"danger":""}`,children:ie(n.provenWashShareBps)})]})]}),e.jsx(X,{items:[["Proven wash volume",`${ce(n.provenWashVolume)} USDC`],["Total seller volume",`${ce(n.totalSellerVolume)} USDC`]]}),e.jsx(de,{summary:"Evidence",children:e.jsx(X,{items:[["Seller",e.jsx(K,{value:n.seller,short:!1})],["Evidence digest",e.jsx("span",{className:"break mono small",children:n.evidenceDigest})]]})})]}):e.jsxs("div",{className:"muted small",children:["No verification record for ",e.jsx(K,{value:s}),"."]})}function Tr(){const{address:t}=Ie(),s=V("verification:own",()=>q.verification(),5*6e4);return s.error&&!s.data?e.jsx(ne,{error:s.error,onRetry:s.refresh}):s.data?s.data.registry?e.jsx(sn,{data:s.data,seller:t}):e.jsx("span",{className:"muted",children:"No wash-trading registry is deployed on this chain."}):e.jsxs("span",{className:"muted small",children:[e.jsx(mt,{})," loading…"]})}function $r(){const[t,s]=u.useState(""),[n,a]=u.useState(null),r=V(n?`verification:${n.toLowerCase()}`:null,()=>q.verification(n??void 0),5*6e4),l=La(t.trim());return e.jsxs("div",{className:"stack",children:[e.jsxs("div",{className:"form-row",children:[e.jsx(qe,{label:"Seller address",width:"lg",value:t,onChange:i=>s(i.target.value),placeholder:"0x…"}),e.jsx(G,{variant:"outline",onClick:()=>a(t.trim()),disabled:!l,children:"Look up"})]}),t.trim()&&!l?e.jsx("div",{className:"error-text",children:"Enter a 0x-prefixed 20-byte address."}):null,n&&r.loading&&!r.data?e.jsxs("span",{className:"muted small",children:[e.jsx(mt,{})," loading…"]}):null,n&&r.error&&!r.data?e.jsx(ne,{error:r.error,onRetry:r.refresh}):null,n&&r.data?e.jsx(sn,{data:r.data,seller:n}):null]})}function Pr(t){if(typeof t!="object"||t===null)return null;const s=t.kind;return typeof s=="string"?s:null}function Rr(t){if(typeof t!="object"||t===null)return null;const s=t,n=s.seller;if(typeof n=="string")return n;const a=s.claim;if(typeof a=="object"&&a!==null){const r=a.seller;if(typeof r=="string")return r}return null}function Mr(){const[t,s]=u.useState(null),[n,a]=u.useState(null),r=async l=>{var c;const i=(c=l.target.files)==null?void 0:c[0];if(s(null),a(null),!!i)try{const o=JSON.parse(await i.text()),h=Pr(o);if(h!==vt){a(`Expected a proof file with kind "${vt}"${h?`, got "${h}"`:""}.`);return}s({name:i.name,artifact:o,kind:h,seller:Rr(o)})}catch(o){a(`Could not parse file as JSON: ${Ce(o)}`)}};return e.jsxs("div",{className:"stack",children:[e.jsxs("div",{className:"hint",children:["Pick a seller proof produced by the loop-proof tooling (",e.jsx("code",{children:vt}),"). Only the kind is checked here; the registry verifies the proof on chain. Submission may take several transactions (block references, chunks, finalize)."]}),e.jsxs("div",{className:"form-row",children:[e.jsx(Ue,{label:"Proof file",children:e.jsx("input",{type:"file",accept:"application/json,.json",onChange:l=>{r(l)}})}),e.jsx(ge,{label:"Submit proof",variant:"primary",title:"Submit seller proof",path:"/api/verification/submit",body:{artifact:t==null?void 0:t.artifact},disabled:!t,disabledReason:"Choose a valid proof file first."})]}),n?e.jsx("div",{className:"error-text",children:n}):null]})}function Lr(){const[t,s]=u.useState(""),[n,a]=u.useState(null),[r,l]=u.useState(null),[i,c]=u.useState(!1),o=async()=>{const h=t.trim();if(h){c(!0),l(null),a(null);try{a(await q.proofStatus(h))}catch(d){l(Ce(d))}finally{c(!1)}}};return e.jsxs("div",{className:"stack",children:[e.jsxs("div",{className:"form-row",children:[e.jsx(qe,{label:"Proof id",width:"lg",value:t,onChange:h=>s(h.target.value),placeholder:"0x…"}),e.jsx(G,{variant:"outline",onClick:()=>{o()},disabled:!t.trim()||i,children:i?"Looking up…":"Look up"})]}),r?e.jsx("div",{className:"error-text",children:r}):null,n?e.jsx(X,{items:[["Proof id",e.jsx("span",{className:"break mono small",children:n.proofId})],["Staged",n.staged?"yes":"no"],["Finalized",n.finalized?"yes":"no"],["Authenticated block references",W(n.authenticatedBlockReferenceCount)],["Authenticated block chunks",W(n.authenticatedBlockChunkCount)]]}):null]})}function Br(){const t=V("network",q.network,2e4),{data:s,refresh:n}=t,a=pt(1e3),r=u.useRef(null);u.useEffect(()=>{const i=()=>{document.visibilityState==="visible"&&n()},c=window.setInterval(i,6e4);return document.addEventListener("visibilitychange",i),()=>{window.clearInterval(c),document.removeEventListener("visibilitychange",i)}},[n]),u.useEffect(()=>{if(!s||r.current===s.epoch.current)return;const i=Math.max(1e3,s.epoch.secondsToBoundary*1e3-(Date.now()-s.fetchedAt)),c=window.setTimeout(()=>{r.current=s.epoch.current,document.visibilityState==="visible"&&n()},i);return()=>window.clearTimeout(c)},[s,n]);const l=!!s&&(!!t.error||a-s.fetchedAt>9e4);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"row",children:[e.jsx("h1",{className:"page-title",children:"Network"}),e.jsx(G,{variant:"outline",size:"sm",onClick:n,disabled:t.loading,children:"Refresh network"})]}),t.error&&!s?e.jsx(ne,{error:t.error,onRetry:n}):null,!s&&t.loading?e.jsx(tt,{rows:5}):null,s&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"hint",children:[s.evmChainId===31337?"Local Anvil · test-chain data, not live production":`${s.chainId} · chain ${s.evmChainId}`," · block ",s.blockNumber," · ",ue(s.blockTimestamp)]}),s.activation!=="active"&&e.jsx("p",{className:"status-line",children:s.activation==="not-active"?"The configured reward stack is not the registry’s active stack. These are its configured allowances, not a claim of active reward distribution.":"Registry activation could not be verified."}),s.epoch.effective!==null&&s.epoch.current<s.epoch.effective&&e.jsxs("p",{className:"hint",children:["Recognized-usage rewards start at epoch ",s.epoch.effective,". The current epoch is before reward activation."]}),l&&e.jsxs("p",{className:"status-line",role:"status",children:["Stale network snapshot. ",t.error??"Refresh to read the latest contract state."]}),s.errors.length>0&&e.jsxs("div",{className:"status-line",role:"status",children:["Some contract reads are unavailable: ",s.errors.join(" ")]}),e.jsx(Ur,{data:s,now:a}),e.jsx(Nr,{data:s}),e.jsx(Z,{children:e.jsxs(de,{summary:"Emission schedule and contract details",children:[e.jsx(X,{items:[["First recognized-usage reward epoch",s.epoch.effective??"Unavailable"],["Epoch length",ht(s.epoch.epochDuration)],["Genesis",ue(s.epoch.genesis)],["Initial scheduled emission",re(s.initialEmission)],["Halving interval",`${s.halvingInterval} epochs`],["Scheduled cumulative emission through this epoch",re(s.cumulativeScheduled)],["Total active stake",re(s.totalActiveStake)],["Total power weight",s.totalPowerWeight===null?"Unavailable":C(s.totalPowerWeight)],...Object.entries(s.contracts).map(([i,c])=>[i,e.jsx(K,{value:c,short:!1})])]}),e.jsx("p",{className:"hint",children:"Scheduled emission is an allowance, not a minted-token counter. Current supply is read separately from the token contract. All main network figures use the same snapshot block."})]})})]}),e.jsx(Z,{children:e.jsx(de,{summary:"Your usage history and network comparisons",lazy:!0,children:e.jsx(Cr,{})})}),e.jsx(Z,{children:e.jsx(de,{summary:"Legacy emissions",lazy:!0,children:e.jsx(Fr,{})})}),e.jsx(Z,{children:e.jsx(de,{summary:"Verification registry",lazy:!0,children:e.jsx(Dr,{})})})]})}function Ur({data:t,now:s}){const n=Math.max(0,t.epoch.secondsToBoundary-Math.floor((s-t.fetchedAt)/1e3));return e.jsxs(Vt,{children:[e.jsx(me,{label:"Current epoch",value:t.epoch.current,sub:ue(t.epoch.genesis+t.epoch.current*t.epoch.epochDuration)}),e.jsx(me,{label:"Next epoch starts in",value:n>0?ht(n):"Awaiting chain update",sub:ue(t.epoch.nextBoundaryAt)}),e.jsx(me,{label:"Scheduled epoch emission · ANTS",value:t.emission===null?"Unavailable":C(t.emission),sub:"Allowance, not tokens already minted"}),e.jsx(me,{label:"Current token supply · ANTS",value:t.totalSupply===null?"Unavailable":C(t.totalSupply),sub:`Maximum supply: ${re(t.maxSupply)}`})]})}function Fr(){const t=V("network:legacy",q.networkLegacy,3e5);if(t.error)return e.jsx(ne,{error:t.error,onRetry:t.refresh});if(t.loading&&!t.data)return e.jsx(tt,{rows:2});const s=t.data;return s?e.jsxs(e.Fragment,{children:[e.jsx(X,{items:[["Legacy contract",e.jsx(K,{value:s.contract})],["Legacy epoch",s.currentEpoch],["Legacy configured split",`Sellers ${s.sellerPct}% · buyers ${s.buyerPct}% · reserve ${s.reservePct}% · team ${s.teamPct}%`]]}),e.jsx("p",{className:"hint",children:"Historical reward-system configuration. These percentages do not describe the current recognized-usage reward budgets."})]}):e.jsx("p",{className:"muted",children:"No legacy emissions contract configured."})}function Dr(){const t=V("verification:own",()=>q.verification(),3e5);return t.error?e.jsx(ne,{error:t.error,onRetry:t.refresh}):t.data?e.jsx(Ir,{data:t.data}):e.jsx(tt,{rows:3})}const Wr=10000n*10n**18n,Pt=86400,it=1e4,xt=">10.000%",_r=`APY is shown as ${xt} when either end of the range exceeds 10,000%. Ranges at or below 10,000% remain visible.`;function Xe(t){return t==null||!Number.isFinite(t)?"—":t>it?xt:`${t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}%`}function nn(t,s,n){const a=Number(t*10n**18n/s)/1e18,r=Math.expm1(Math.log1p(a)*(365*Pt/n))*100;return Number.isFinite(r)?r:null}function Or(t,s,n,a){const r=s==null?void 0:s.yield;if(!s||s.agentId!==t.agentId||!r||r.status==="unavailable"||r.epoch<0||r.reward==null||n===void 0||!Number.isSafeInteger(n)||n<0||t.withdrawn||t.closedAtEpoch!==0||t.state==="closed"||t.state==="withdrawn"||t.state==="matured")return null;const l=r.endsAt-r.startsAt;if(!Number.isFinite(l)||l<=0)return null;try{const i=BigInt(t.amount),c=BigInt(s.weight),o=BigInt(r.reward);if(i<=0n||c<0n||o<0n)return null;const h=t.stakeStartEpoch>n,d=h?t.stakeStartEpoch===n+1?t.nextPower:void 0:t.power;let m;if(d!=null)m=BigInt(d);else{const j=(h?t.maxLockedNext:t.maxLocked)?a:t.stakeEndEpoch-Math.max(n,t.stakeStartEpoch);if(j===void 0||!Number.isSafeInteger(j)||j<=0)return null;const y=BigInt(t.weightAmount);if(y<=0n)return null;m=y*BigInt(j)}if(m<=0n)return null;const x=h?c+m:c;return x<=0n||m>x?null:nn(o*m/x,i,l)}catch{return null}}function an(t,s){const n=t?t.endsAt-t.startsAt:0;if(!t||!Number.isFinite(n)||n<=0||t.minLockEpochs==null||t.maxLockEpochs==null)return{epochs:null,actualDays:null,status:"unavailable"};const a=Math.round(s*Pt/n);return!Number.isSafeInteger(a)||a<1||a<t.minLockEpochs||a>t.maxLockEpochs?{epochs:null,actualDays:null,status:"unsupported"}:{epochs:a,actualDays:a*n/Pt,status:"supported"}}function Rt(t,s){const{epochs:n}=an(t,s);if(n===null)return{epochs:null,apy:null};const a=rn(t,n,Wr.toString());return{epochs:a===null?null:n,apy:a}}function rn(t,s,n,a=0){if(!t||t.status==="unavailable"||t.epoch<0||t.reward==null||t.power==null||t.minLockEpochs==null||t.maxLockEpochs==null)return null;const r=t.endsAt-t.startsAt;if(!Number.isFinite(r)||r<=0||!Number.isSafeInteger(s)||s<1||s<t.minLockEpochs||s>t.maxLockEpochs||!Number.isSafeInteger(a)||a<0)return null;try{const l=BigInt(t.reward),i=BigInt(t.power),c=BigInt(n);if(l<0n||i<=0n||c<=0n)return null;const h=c*(10000n+BigInt(a))/10000n*BigInt(s),d=l*h/(i+h);return nn(d,c,r)}catch{return null}}function Gt(t){return{oneWeek:Rt(t,7),twoYears:Rt(t,730)}}function zr(t){return[{label:"1 day",days:1},{label:"1 month",days:30},{label:"1 year",days:365},{label:"2 years",days:730}].map(s=>({...s,...an(t,s.days),apy:Rt(t,s.days).apy}))}const Qt={isPartial:t=>t.source==="chain"&&!!t.sourceError,isSyncing:t=>!!t.walletSyncing,retryOnError:!1},qr={isSyncing:t=>!!t.walletSyncing};function Zt({left:t,top:s,title:n,rows:a}){const r=typeof window<"u"&&t>window.innerWidth-240;return e.jsxs("div",{className:r?"chart-tip chart-tip--left":"chart-tip",style:{left:t,top:s},role:"status","aria-live":"polite",children:[e.jsx("div",{className:"chart-tip-title",children:n}),a.map(l=>e.jsxs("div",{className:"chart-tip-row",children:[e.jsx("i",{style:l.color?{background:l.color}:void 0,"aria-hidden":"true"}),e.jsx("span",{className:"chart-tip-name",children:l.name}),e.jsxs("span",{className:"chart-tip-value",children:[l.value,l.note?e.jsxs("small",{children:[" ",l.note]}):null]})]},l.name))]})}function Yr(t,s,n,a){if(a<=0||n<=0)return null;const r=Math.floor((t-s)/n);return r<0||r>=a?null:r}function ln(t,s){let n=null,a=Number.POSITIVE_INFINITY;return s.forEach((r,l)=>{const i=Math.abs(r-t);i<a&&(a=i,n=l)}),n}function Xt(t,s,n,a){const[r,l]=u.useState(null);return{hover:r,onPointerMove:h=>{var x;const d=(x=t.current)==null?void 0:x.getBoundingClientRect();if(!d||d.width===0)return;const m=a((h.clientX-d.left)*(s/d.width));m===null?l(null):m!==(r==null?void 0:r.index)&&l({index:m})},onPointerLeave:()=>l(null),setHover:l,clientPoint:(h,d)=>{var x;const m=(x=t.current)==null?void 0:x.getBoundingClientRect();return!m||m.width===0?{left:h,top:d}:{left:m.left+h*(m.width/s),top:m.top+d*(m.height/n)}}}}function Vr(t,s,n){const a=new Map(s.map(r=>[r.epoch,J(r.usdc)]));return t.filter(r=>r.epoch<n).sort((r,l)=>r.epoch-l.epoch).map(r=>{const l=J(r.usdc),i=a.get(r.epoch);return{epoch:r.epoch,volume:l!==null&&l>=0n?l:null,network:i??null,share:l!==null&&l>=0n&&i!=null&&i>0n&&l<=i?l*10000n/i:null}})}function Hr({points:t}){var D,S;const s=u.useId(),n=u.useRef(null),[a,r]=u.useState(800);u.useEffect(()=>{if(!n.current||typeof ResizeObserver>"u")return;const g=new ResizeObserver(w=>{const p=w[0];p&&r(Math.max(280,Math.round(p.contentRect.width)))});return g.observe(n.current),()=>g.disconnect()},[]);const l=t.flatMap(g=>g.volume===null?[]:[g.volume]),i=l.reduce((g,w)=>w>g?w:g,0n)||1000000n,c=t.some(g=>g.share!==null),o=64,h=a-64,d=((D=t[0])==null?void 0:D.epoch)??0,m=((S=t.at(-1))==null?void 0:S.epoch)??d,x=g=>d===m?a/2:o+(g-d)/(m-d)*(h-o),f=(g,w)=>218-Number(g*1000000n/w)/1e6*180,j=[{key:"volume",name:"Settled volume",scale:i,format:g=>`${ce(String(g))} USDC`},{key:"share",name:"Network volume share",scale:10000n,format:g=>ie(Number(g))}],y=(g,w)=>{let p=null;return t.map(I=>{const _=I[g];if(_===null)return p=null,"";const $=p!==null&&I.epoch===p+1?"L":"M";return p=I.epoch,`${$}${x(I.epoch)},${f(_,w)}`}).join(" ")},E=a<500?3:6,P=Math.max(1,Math.ceil((t.length-1)/(E-1))),T=u.useRef(null),A=t.map(g=>x(g.epoch)),{hover:N,onPointerMove:U,onPointerLeave:k,setHover:B,clientPoint:b}=Xt(T,a,270,g=>ln(g,A)),v=N!==null?t[N.index]??null:null,L=[];return v&&(v.volume!==null&&L.push({name:"Settled volume",value:`${ce(String(v.volume))} USDC`,color:"var(--pc-accent)"}),v.network!==null&&L.push({name:"Network volume",value:`${ce(String(v.network))} USDC`,color:"var(--pc-sub)"}),v.share!==null&&L.push({name:"Network share",value:ie(Number(v.share)),color:"var(--pc-blue)"})),e.jsxs("div",{className:"pool-chart",children:[e.jsxs("div",{className:"pool-chart-legend",children:[e.jsxs("h4",{children:[e.jsx("span",{className:"pool-chart-dot"}),"Settled volume · left axis"]}),e.jsxs("h4",{className:"pool-chart--share",children:[e.jsx("span",{className:"pool-chart-dot"}),"Network volume share · right axis"]})]}),e.jsxs("div",{ref:n,className:"pool-chart-plot",children:[l.length?e.jsxs("svg",{ref:T,viewBox:`0 0 ${a} 270`,role:"img","aria-labelledby":s,onPointerMove:U,onPointerLeave:k,children:[e.jsx("title",{id:s,children:"Settled volume and network volume share by completed epoch. USDC on the left axis; 0–100% on the right axis. Hover anywhere over the chart for that epoch's values."}),v?e.jsx("line",{x1:x(v.epoch),x2:x(v.epoch),y1:38,y2:218,className:"chart-crosshair","aria-hidden":"true"}):null,e.jsx("text",{x:o,y:"16",className:"pool-chart-axis-volume",children:"USDC"}),e.jsx("text",{x:h,y:"16",textAnchor:"end",className:"pool-chart-axis-share",children:"Share · %"}),[0,1,2,3,4].map(g=>e.jsxs("g",{children:[e.jsx("line",{x1:o,x2:h,y1:38+g*45,y2:38+g*45,className:"pool-chart-grid"}),e.jsx("text",{x:o-9,y:42+g*45,textAnchor:"end",className:"pool-chart-axis-volume",children:We(String(i*BigInt(4-g)/4n))}),e.jsxs("text",{x:h+9,y:42+g*45,textAnchor:"start",className:"pool-chart-axis-share",children:[100-g*25,"%"]})]},g)),j.map(g=>e.jsxs("g",{className:g.key==="share"?"pool-chart--share":void 0,children:[t.some(w=>w[g.key]!==null)&&e.jsx("path",{d:y(g.key,g.scale),className:"pool-chart-line","data-series":g.key}),t.map((w,p)=>{const I=w[g.key];if(I===null)return null;const _=`${g.name}, epoch ${w.epoch}: ${g.format(I)}`;return e.jsx("circle",{cx:x(w.epoch),cy:f(I,g.scale),r:v===w?5.5:4,tabIndex:0,role:"img","aria-label":_,onFocus:()=>B({index:p}),onBlur:k,children:e.jsx("title",{children:_})},w.epoch)})]},g.key)),t.filter((g,w)=>w%P===0||w===t.length-1).map(g=>e.jsx("text",{x:x(g.epoch),y:"242",textAnchor:"middle",children:g.epoch},g.epoch)),e.jsx("text",{x:a/2,y:"265",textAnchor:"middle",children:"Epoch"})]}):e.jsx("div",{className:"pool-chart-empty",children:"Settlement volume unavailable for completed epochs."}),v&&L.length>0?e.jsx(Zt,{...b(x(v.epoch),38),title:`Epoch ${v.epoch}`,rows:L}):null]}),l.length>0&&!c&&e.jsx("p",{className:"hint",children:"Network share unavailable for these epochs."})]})}function Kr({volumes:t,networkVolumes:s,currentEpoch:n}){const a=Vr(t,s,n);return e.jsxs(e.Fragment,{children:[e.jsx(Hr,{points:a}),e.jsx("p",{className:"hint",children:"Network share = seller settled volume ÷ total network settled volume in the same epoch. The right axis stays at 0–100%; each line uses its own units. Missing observations leave gaps; a missing or zero network total is not a 0% share."})]})}function Jr(t){const s=new Map;for(const n of t){const a=n.name.trim(),r=a.toLowerCase(),l=s.get(r)??{name:a,providers:[]};l.providers.includes(n.provider)||l.providers.push(n.provider),s.set(r,l)}return[...s.values()]}function Gr({address:t}){const s=V(t?`seller-models:${t}`:null,()=>q.sellerModels(t)),n=s.data;return e.jsxs("section",{className:"pool-section",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Models & usage"}),e.jsx("span",{className:"small muted",children:"Sourced from Antscan"})]}),t?n?e.jsxs(e.Fragment,{children:[s.error&&e.jsx("p",{className:"hint",children:"Model data could not refresh. Showing the previously loaded snapshot."}),e.jsxs("h4",{className:"pool-subheading",children:["Observed model usage ",e.jsxs("span",{className:"small muted",children:["Last completed epoch",n.period?` · Epoch ${n.period.epoch}`:""]})]}),n.usageStatus==="unavailable"?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"hint",children:n.usageError??"Model usage is unavailable."}),e.jsx("button",{type:"button",className:"link-button",onClick:s.refresh,disabled:s.loading,children:"Retry model data"})]}):n.usage.length?e.jsx("div",{className:"table-wrap",tabIndex:0,role:"region","aria-label":"Observed model usage",children:e.jsxs("table",{className:"table pool-model-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Model"}),e.jsx("th",{className:"num",children:"Requests"}),e.jsx("th",{className:"num",children:"Input tokens"}),e.jsx("th",{className:"num",children:"Output tokens"}),e.jsx("th",{className:"num",children:"Volume · USDC"})]})}),e.jsx("tbody",{children:n.usage.map(a=>e.jsxs("tr",{children:[e.jsx("td",{children:a.name}),e.jsx("td",{className:"num",children:W(a.requests)}),e.jsx("td",{className:"num",children:W(a.inputTokens)}),e.jsx("td",{className:"num",children:W(a.outputTokens)}),e.jsx("td",{className:"num",children:ce(a.volumeUsdc)})]},a.serviceId))})]})}):e.jsx("p",{className:"hint",children:"No indexed model usage for this seller in this epoch."}),n.totals&&e.jsxs("p",{className:"hint",children:["Settled volume: ",ce(n.totals.settledVolumeUsdc)," USDC · Model-attributed: ",ce(n.totals.attributedVolumeUsdc)," USDC · Unattributed: ",n.totals.unattributedVolumeUsdc===null?"unavailable (model totals exceed settlements)":`${ce(n.totals.unattributedVolumeUsdc)} USDC`]}),e.jsxs("section",{className:"pool-catalog","aria-label":"Advertised models",children:[e.jsxs("h4",{className:"pool-subheading",children:["Advertised models ",e.jsx("span",{className:"small muted",children:n.catalogStatus==="live"?"Latest discovered catalog":n.catalogStatus==="stale"?"Stale catalog":"Unavailable"})]}),e.jsx("p",{className:"hint",children:"Seller-advertised models, not a guarantee of availability."}),n.catalogStatus==="unavailable"?e.jsx("p",{className:"hint",children:"Antscan model catalog is unavailable."}):n.offerings.length?e.jsx("ul",{className:"pool-model-tags","aria-label":"Advertised model names",children:Jr(n.offerings).map(a=>e.jsx("li",{children:e.jsx(le,{title:`Providers: ${a.providers.join(", ")}`,children:a.name})},a.name))}):e.jsx("p",{className:"hint",children:"No advertised models found in Antscan’s catalog."}),n.catalogUpdatedAt!==null&&e.jsxs("p",{className:"small muted",children:["Catalog snapshot ",ue(Math.floor(n.catalogUpdatedAt/1e3))]})]})]}):s.error?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"hint",children:"Model data could not load. Pool statistics remain available."}),e.jsx("p",{className:"hint",children:s.error}),e.jsx("button",{type:"button",className:"link-button",onClick:s.refresh,disabled:s.loading,children:"Retry model data"})]}):e.jsx("p",{className:"hint",children:"Loading provider models and last-epoch usage…"}):e.jsx("p",{className:"hint",children:"Bind a seller to see its model catalog."})]})}function Qr(t){const s=u.useRef(null),[n,a]=u.useState(t);return u.useEffect(()=>{if(!s.current||typeof ResizeObserver>"u")return;const r=new ResizeObserver(l=>{const i=l[0];i&&a(Math.max(240,Math.round(i.contentRect.width)))});return r.observe(s.current),()=>r.disconnect()},[]),{ref:s,width:n}}function bs(t){if(t.max!==void 0)return t.max;const n=t.values.filter(a=>a!==null&&a>0n).reduce((a,r)=>r>a?r:a,0n);return n===0n?1n:n}function js({epochs:t,bars:s,line:n,title:a,height:r=200,compact:l=!1}){var xe;const i=u.useId(),{ref:c,width:o}=Qr(640),h=l?48:60,d=n?l?44:56:12,m=14,x=28,f=Math.max(40,o-h-d),j=r-m-x,y=Math.max(1,t.length),E=f/y,P=Math.max(3,Math.min(28,E*.58)),T=bs(s),A=n?bs(n):1n,N=(F,z)=>Number(F*1000000n/z)/1e6,U=F=>m+j-N(F,T)*j,k=F=>m+j-N(F,A)*j,B=F=>h+E*F+E/2,b=s.values.some(F=>F!==null),v=!!n&&n.values.some(F=>F!==null),L=[0,1,2,3,4],D=o<480?4:8,S=Math.max(1,Math.ceil(y/D)),g=s.tick??s.format,w=n?n.tick??n.format:null,p=u.useRef(null),{hover:I,onPointerMove:_,onPointerLeave:$,setHover:M,clientPoint:O}=Xt(p,o,r,F=>Yr(F,h,E,t.length)),H=F=>M({index:F}),Y=(I==null?void 0:I.index)??null,ee=[];if(Y!==null){const F=s.values[Y];F!=null&&ee.push({name:s.name,value:s.format(F),color:"var(--pc-accent)",note:(xe=s.provisional)!=null&&xe[Y]?"estimated":void 0});const z=n==null?void 0:n.values[Y];n&&z!=null&&ee.push({name:n.name,value:n.format(z),color:"var(--pc-blue)"})}let pe="";if(n){let F=null;pe=n.values.map((z,oe)=>{if(z===null)return F=null,"";const ve=F!==null&&oe===F+1?"L":"M";return F=oe,`${ve}${B(oe).toFixed(1)},${k(z).toFixed(1)}`}).join(" ")}return e.jsxs("div",{className:"chart",children:[e.jsxs("div",{className:"chart-legend",children:[e.jsxs("span",{className:"chart-legend-item chart-legend-item--bars",children:[e.jsx("i",{}),s.name]}),n?e.jsxs("span",{className:"chart-legend-item chart-legend-item--line",children:[e.jsx("i",{}),n.name]}):null]}),e.jsxs("div",{ref:c,className:"chart-plot",children:[b||v?e.jsxs("svg",{ref:p,viewBox:`0 0 ${o} ${r}`,role:"img","aria-labelledby":i,onPointerMove:_,onPointerLeave:$,children:[e.jsx("title",{id:i,children:a}),Y!==null?e.jsxs("g",{className:"chart-hover","aria-hidden":"true",children:[e.jsx("rect",{x:B(Y)-E/2,y:m,width:E,height:j,className:"chart-hover-band"}),e.jsx("line",{x1:B(Y),x2:B(Y),y1:m,y2:m+j,className:"chart-crosshair"})]}):null,L.map(F=>{const z=m+j*F/4,oe=T*BigInt(4-F)/4n,ve=A*BigInt(4-F)/4n;return e.jsxs("g",{children:[e.jsx("line",{x1:h,x2:h+f,y1:z,y2:z,className:"chart-grid"}),e.jsx("text",{x:h-8,y:z+4,textAnchor:"end",className:"chart-axis chart-axis--bars",children:g(oe)}),n&&w?e.jsx("text",{x:h+f+8,y:z+4,textAnchor:"start",className:"chart-axis chart-axis--line",children:w(ve)}):null]},F)}),e.jsx("g",{className:"chart-bars",children:s.values.map((F,z)=>{var Ye;if(F===null)return null;const oe=((Ye=s.provisional)==null?void 0:Ye[z])===!0,ve=U(F),be=`${s.name}, epoch ${t[z]}: ${s.format(F)}${oe?" (estimated)":""}`;return e.jsx("rect",{x:B(z)-P/2,y:Math.min(ve,m+j-1),width:P,height:Math.max(1,m+j-ve),rx:Math.min(3,P/3),className:`${oe?"chart-bar chart-bar--provisional":"chart-bar"}${Y===z?" chart-bar--hover":""}`,tabIndex:0,role:"img","aria-label":be,onFocus:()=>H(z),onBlur:$,children:e.jsx("title",{children:be})},t[z])})}),n&&v?e.jsxs("g",{className:"chart-line-group",children:[e.jsx("path",{d:pe,className:"chart-line","data-series":n.key}),n.values.map((F,z)=>{if(F===null)return null;const oe=`${n.name}, epoch ${t[z]}: ${n.format(F)}`;return e.jsx("circle",{cx:B(z),cy:k(F),r:Y===z?5:3.5,className:"chart-dot",tabIndex:0,role:"img","aria-label":oe,onFocus:()=>H(z),onBlur:$,children:e.jsx("title",{children:oe})},t[z])})]}):null,t.map((F,z)=>z%S===0||z===t.length-1?e.jsx("text",{x:B(z),y:r-8,textAnchor:"middle",className:"chart-axis chart-axis--x",children:F},F):null)]}):e.jsx("div",{className:"chart-empty",children:"No indexed data for these epochs."}),Y!==null&&ee.length>0?e.jsx(Zt,{...O(B(Y),m),title:`Epoch ${t[Y]}`,rows:ee}):null]})]})}function Zr({values:t,width:s=96,height:n=26,label:a,tone:r="accent",labels:l,format:i}){const c=u.useId(),o=t.map(p=>p===null?null:Number(p)),h=o.filter(p=>p!==null&&Number.isFinite(p)),d=u.useRef(null),m=o.length>1?(s-2)/(o.length-1):0,x=p=>1+p*m,f=o.map((p,I)=>p===null||!Number.isFinite(p)?Number.POSITIVE_INFINITY:x(I)),{hover:j,onPointerMove:y,onPointerLeave:E,clientPoint:P}=Xt(d,s,n,p=>l?ln(p,f):null);if(h.length<2)return e.jsx("span",{className:"sparkline sparkline--empty","aria-label":a,role:"img",children:"·"});const T=Math.max(...h),A=Math.min(...h,0),N=T-A||1,U=2,k=p=>n-U-(p-A)/N*(n-U*2);let B="",b="",v=null;o.forEach((p,I)=>{if(p===null||!Number.isFinite(p)){v=null;return}B+=`${v===null?"M":"L"}${x(I).toFixed(1)},${k(p).toFixed(1)} `,v=I});const L=o.findIndex(p=>p!==null),D=o.length-1-[...o].reverse().findIndex(p=>p!==null);L>=0&&D>=L&&(b=`${B.trim()} L${x(D).toFixed(1)},${n} L${x(L).toFixed(1)},${n} Z`);const S=o[D],g=j!==null?o[j.index]:null,w=j!==null&&g!==null&&g!==void 0&&Number.isFinite(g)?{index:j.index,value:g}:null;return e.jsxs("span",{className:"sparkline-wrap",children:[e.jsxs("svg",{ref:d,className:`sparkline sparkline--${r}`,width:s,height:n,viewBox:`0 0 ${s} ${n}`,role:"img","aria-label":a,onPointerMove:y,onPointerLeave:E,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:c,x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0",stopColor:"currentColor",stopOpacity:"0.28"}),e.jsx("stop",{offset:"1",stopColor:"currentColor",stopOpacity:"0"})]})}),b?e.jsx("path",{d:b,fill:`url(#${c})`,stroke:"none"}):null,e.jsx("path",{d:B.trim(),fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round"}),S!=null&&Number.isFinite(S)?e.jsx("circle",{cx:x(D),cy:k(S),r:"2",fill:"currentColor"}):null,w?e.jsx("circle",{cx:x(w.index),cy:k(w.value),r:"3",className:"sparkline-hover","aria-hidden":"true"}):null]}),w?e.jsx(Zt,{...P(x(w.index),0),title:(l==null?void 0:l[w.index])??"",rows:[{name:"Settled volume",value:i?i(w.value):String(w.value)}]}):null]})}function es({value:t,min:s=1,max:n,onChange:a,label:r="Lock",disabled:l,startEpoch:i,showUnlockDate:c=!0}){const o=he(),h=Math.min(Math.max(t,s),n),d=i==null?null:i+h,m=o&&d!==null?rt(De(d,o.genesis,o.epochDuration)):null;return e.jsxs("label",{className:"field lock-slider",children:[e.jsx("span",{className:"field__label",children:r}),e.jsx("input",{type:"range",className:"range",min:s,max:n,step:1,value:h,disabled:l,onChange:x=>a(Number(x.target.value)),"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":h,"aria-valuetext":`${h} ${h===1?"epoch":"epochs"}${m?`; unlocks ${m}`:""}`}),e.jsxs("span",{className:"lock-slider-readout",children:[e.jsx("span",{className:"mono",children:h})," ",h===1?"epoch":"epochs",o?` (${h*o.epochDuration/86400} days)`:"",c&&m?e.jsxs("span",{className:"muted",children:[" ","· unlocks ",e.jsx("span",{className:"mono",children:m})]}):null,h===n?e.jsx("span",{className:"dim",children:" · max"}):null]})]})}function Xr(t,s,n){const a=[];if(t){BigInt(t.buyerUsage.total)>0n&&a.push({id:"buyer",kind:"buyer",label:"Unclaimed buyer rewards",amount:t.buyerUsage.total,available:t.buyerUsage.claimable}),BigInt(t.sellerUsage.total)>0n&&a.push({id:"seller",kind:"seller",label:"Unclaimed seller rewards",amount:t.sellerUsage.total,available:t.sellerUsage.claimable,agentId:t.sellerUsage.agentId});for(const r of t.staker.positions)BigInt(r.amount)>0n&&a.push({id:`staker:${r.id}`,kind:"staker",label:`Staking rewards · position #${r.id}`,amount:r.amount,available:!0,agentId:r.agentId,positionId:r.id})}return n&&a.push({id:"wallet",kind:"wallet",label:"Wallet balance",amount:s,available:!0}),a}function el(t,s,n,a){if(!t.available)throw new Error("This staking source is unavailable.");if(t.agentId!==void 0&&t.agentId!==s)throw new Error("These rewards must be staked into their source pool.");return t.kind==="wallet"?{path:"/api/positions/stake",body:{agentId:s,amount:n,epochs:a}}:t.kind==="staker"?{path:"/api/rewards/restake",body:{positionIds:[t.positionId],epochs:a}}:{path:"/api/rewards/stake-usage",body:{side:t.kind,epochs:a,...t.kind==="buyer"?{stakeAgentId:s}:{}}}}const tl=86400,ws=t=>C(t,18).replace(/,/g,""),sl=[{label:"1w",days:7},{label:"1m",days:30},{label:"6m",days:182},{label:"1y",days:365},{label:"max",days:"max"}];function nl(t){return t.kind==="wallet"?"Stakes wallet ANTS; token approval may be needed.":t.kind==="buyer"?"AI buying rewards. Choose any seller; no claim needed.":t.kind==="seller"?"AI selling rewards. Stakes into your own pool.":"Position rewards. Restakes into the same pool."}function on({config:t,pools:s,balance:n,rewards:a=null,rewardsError:r,defaultAgentId:l,lockedPool:i=!1,onStarted:c,onClose:o,onBusyChange:h}){var as,rs,ls;const{overview:d,config:m}=Ee(),x=he(),f=Ae(),[j,y]=u.useState(null),[E,P]=u.useState(!1),T=u.useRef(!1),[A,N]=u.useState(()=>{var R;return String(l??((R=s[0])==null?void 0:R.agentId)??"")}),[U,k]=u.useState(""),[B,b]=u.useState(null),v=(d==null?void 0:d.wallet.canTransfer)??!1,L=!m.selectedAddress||m.selectedAddress.toLowerCase()===((as=m.walletAddress)==null?void 0:as.toLowerCase()),D=Xr(r?null:a,n??"0",v).filter(R=>L||R.kind==="buyer"),S=i&&l?D.filter(R=>R.agentId===void 0||R.agentId===l):D,g=i?D.length-S.length:0,w=S.find(R=>R.id===B),p=w??S.find(R=>R.available&&R.kind!=="wallet")??S[0]??null,I=Jt((p==null?void 0:p.kind)==="buyer"),_=B!==null&&!w,$=(p==null?void 0:p.kind)==="wallet",M=p===null?"":$?U:ws(p.amount),O=(p==null?void 0:p.agentId)??Number(A),H=(t==null?void 0:t.maxStakeEpochs)??1,Y=Math.max(1,(t==null?void 0:t.minStakeEpochs)??1),[ee,pe]=u.useState(Y);u.useEffect(()=>{t&&pe(R=>Math.max(t.minStakeEpochs,Math.min(R,t.maxStakeEpochs)))},[t==null?void 0:t.minStakeEpochs,t==null?void 0:t.maxStakeEpochs]),u.useEffect(()=>{l&&N(String(l))},[l]),u.useEffect(()=>{!A&&s[0]&&N(String(s[0].agentId))},[A,s]);const xe=s.find(R=>R.agentId===O)??null;let F=null;if(t&&(p!=null&&p.available)&&!_&&Je(M)){const R=It(M,18),Q=p.kind==="staker"?Math.floor(t.restakedRewardWeightBonusBps*ee/t.maxStakeEpochs):0;R!==null&&(F=rn(xe==null?void 0:xe.yield,ee,R.toString(),Q))}const z=()=>{n!==void 0&&k(ws(n))},oe=()=>{if(!p)return"Nothing is available to stake.";if(!O||p.agentId===void 0&&!xe)return"Choose a pool.";if(!Je(M))return"Amount must be a positive decimal number of ANTS.";const R=It(M,18);if(R===null)return"Amount must have no more than 18 decimal places.";if($&&n!==void 0&&R!==null){let Q=0n;try{Q=BigInt(n)}catch{Q=0n}if(R>Q)return`Amount exceeds wallet balance (${C(n,4)} ANTS).`}return t?ee<Y||ee>H?`Lock must be between ${Y} and ${H} epochs.`:null:"Pool configuration is still loading."},ve=t&&d?d.epoch.current+t.stakeActivationDelay:null,be=(p==null?void 0:p.agentId)===void 0&&s.length===0,Ye=m.browserWallet&&m.readOnly?"Connect wallet to stake.":d?_?"The selected rewards are no longer available. Choose a source again.":p&&!p.available?"Use the wallet button above to switch to the authorized wallet for these rewards.":BigInt(d.wallet.signingWalletEth??d.wallet.eth)===0n?"The signing wallet needs ETH on the selected network to pay transaction fees.":null:"Wallet information is unavailable. Refresh before staking.",ss=I.blocked||be||!!Ye||p===null,ns=Ye??I.reason??(be?"No stakeable pools yet.":null),gn=R=>x?Math.max(Y,Math.min(H,Math.round(R*tl/x.epochDuration))):null,bn=async()=>{if(T.current||ss||!p)return;const R=oe();if(R){y(R);return}T.current=!0,P(!0),h==null||h(!0),y(null);try{const Q=el(p,O,M.trim(),ee);await f.start(Q.path,Q.body),c==null||c()}catch(Q){f.pushToast({tone:"danger",title:`${$?"Stake":"Stake rewards"} failed`,body:Ce(Q),sticky:!0})}finally{T.current=!1,P(!1),h==null||h(!1)}},jn=!a&&!r;return m.browserWallet&&m.readOnly?e.jsxs("form",{className:"stake-form",onSubmit:R=>R.preventDefault(),children:[e.jsx("div",{className:"status-line status-line--muted",role:"status",children:"Connect your wallet to see what you can stake. Unclaimed rewards can be staked directly; wallet ANTS are stakeable once transfers are enabled."}),o?e.jsx("div",{className:"stake-form-actions",children:e.jsx(G,{variant:"outline",onClick:o,children:"Close"})}):null]}):e.jsxs("form",{className:"stake-form",onSubmit:R=>{R.preventDefault(),bn()},children:[ns?e.jsx("div",{className:"status-line status-line--muted",role:"status",children:ns}):null,r?e.jsxs("p",{className:"error-text",children:["Rewards could not be loaded: ",r]}):null,S.length===0?e.jsx("div",{className:"stake-empty",role:"status",children:jn?e.jsx("span",{children:"Loading unclaimed rewards…"}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Nothing to stake yet"}),v?"Your wallet holds no ANTS and no eligible rewards are unclaimed.":"ANTS transfers are not enabled for this wallet, so staking from the wallet balance is unavailable. Rewards you earn buying, selling or staking can be staked here directly as they accrue.",g>0?` ${g} reward source${g===1?"":"s"} belong to other pools.`:""]})}):e.jsxs("div",{className:"field",children:[e.jsx(Ue,{label:"Stake from",hint:p?nl(p):void 0,children:e.jsx(Fe,{value:(p==null?void 0:p.id)??"",disabled:E,onChange:R=>{b(R.target.value),y(null)},children:S.map(R=>e.jsxs("option",{value:R.id,children:[R.label,R.available?"":" · other wallet"," · ",C(R.amount,4)," ANTS"]},R.id))})}),v?null:e.jsx("span",{className:"field__hint",children:"Rewards only: wallet ANTS transfers are disabled."}),g>0?e.jsxs("span",{className:"field__hint",children:[g," reward source",g===1?"":"s"," bound to other pools ",g===1?"is":"are"," not shown here."]}):null]}),p?e.jsxs("div",{className:"form-row",children:[!i&&p.agentId===void 0?e.jsx(Ue,{label:"Seller pool",width:"lg",children:e.jsxs(Fe,{value:String(O||""),onChange:R=>N(R.target.value),disabled:E||be,children:[be?e.jsx("option",{value:"",children:"No stakeable pools"}):null,s.map(R=>{var Q,is;return e.jsx("option",{value:R.agentId,children:((is=(Q=R.profile)==null?void 0:Q.name)==null?void 0:is.trim())||`Agent ID ${R.agentId}`},R.agentId)})]})}):p.agentId!==void 0&&!i?e.jsx(Ue,{label:"Seller pool",width:"lg",hint:"These rewards can only be staked into this seller pool.",children:e.jsx(Fe,{value:String(p.agentId),disabled:!0,children:e.jsx("option",{value:p.agentId,children:((ls=(rs=xe==null?void 0:xe.profile)==null?void 0:rs.name)==null?void 0:ls.trim())||`Agent ID ${p.agentId}`})})}):null,$?e.jsx(qe,{label:"Amount (ANTS)",hint:n!==void 0?e.jsxs(e.Fragment,{children:["Balance ",e.jsx("span",{className:"mono",children:C(n,4)})," ·"," ",e.jsx("button",{type:"button",className:"link-button",onClick:z,disabled:E,children:"Max"})]}):void 0,inputMode:"decimal",value:M,onChange:R=>k(R.target.value),placeholder:"0.0",disabled:E||be}):null,e.jsxs("div",{className:"stake-lock-settings",children:[e.jsx(es,{value:ee,min:Y,max:H,startEpoch:ve,onChange:pe,disabled:E||!t||be}),e.jsx("div",{className:"lock-presets","aria-label":"Lock presets",children:sl.map(R=>{const Q=R.days==="max"?H:gn(R.days);return Q===null?null:e.jsx("button",{type:"button",className:"lock-preset","aria-pressed":ee===Q,disabled:E||!t,onClick:()=>pe(Q),children:R.label},R.label)})}),e.jsxs("div",{className:"stake-apy","aria-live":"polite",children:[e.jsxs("span",{className:"small",children:["Estimated APY ",e.jsx("strong",{className:"mono",children:Xe(F)}),e.jsx(Ze,{label:"About estimated APY",children:"Uses your initial power, restaking bonus and added pool power. Assumes past rewards repeat with per-epoch compounding—not automatic. Excludes declining power and activation delays. Returns aren’t guaranteed."})]}),F===null?e.jsx("span",{className:"field__hint",children:$&&!Je(M)?"Enter an amount to estimate APY.":"APY unavailable: missing reward history or staking data."}):null]})]})]}):null,p&&(t||!$)?e.jsxs("div",{className:"hint",children:["Staking details",e.jsxs(Ze,{label:"About staking and early withdrawal",children:[t?e.jsxs(e.Fragment,{children:["Longer locks increase power. Early exit burns ",ie(t.minEarlyExitSlashBps),"–",ie(t.maxSlashBps)," of principal; preview shows the amount. Dates assume confirmation this epoch. "]}):null,$?null:e.jsx(e.Fragment,{children:"Stakes all eligible rewards, verified on-chain. Usage rewards may need approval per epoch."})]})]}):null,j?e.jsx("div",{className:"error-text",role:"alert",children:j}):null,p?e.jsxs("div",{className:"stake-form-actions",children:[e.jsx("button",{type:"submit",className:"btn btn--primary btn--md",disabled:ss||E,children:E?"Sending…":I.label??($?"Stake":"Stake rewards")}),o?e.jsx(G,{variant:"outline",onClick:o,disabled:E,children:"Cancel"}):null]}):o?e.jsx("div",{className:"stake-form-actions",children:e.jsx(G,{variant:"outline",onClick:o,children:"Close"})}):null]})}function ot(t){var s,n;return((n=(s=t.profile)==null?void 0:s.name)==null?void 0:n.trim())||`Seller pool #${t.agentId}`}const yt=20;function cn(t){return[...t].sort((s,n)=>{var i,c;if(s.stakeable!==n.stakeable)return s.stakeable?-1:1;const a=s.lastEpochRewardPer1kPower,r=n.lastEpochRewardPer1kPower;if(a!==null&&r!==null){const o=jt(r,a);if(o!==0)return o}else{if(a!==null)return-1;if(r!==null)return 1}const l=jt(n.weight,s.weight);return l!==0?l:jt(((i=n.volumes[0])==null?void 0:i.usdc)??"0",((c=s.volumes[0])==null?void 0:c.usdc)??"0")})}function Mt(t,s){if(t.volumeStatus!=="available")return null;const n=t.volumes.find(a=>a.epoch===s-1);return n?J(n.usdc):null}function Se(t){return J(t??null)??0n}function kt(t){var s,n;return((n=(s=t.profile)==null?void 0:s.name)==null?void 0:n.trim())||"Unnamed seller"}function al(t,s,n,a){const r=l=>s==="apy"?Gt(l.yield).oneWeek.apy:s==="stake"?J(l.activeStake):Mt(l,a);return[...t].sort((l,i)=>{const c=r(l),o=r(i);if(c===null)return o===null?0:1;if(o===null)return-1;const h=c<o?-1:c>o?1:0;return n==="ascending"?h:-h})}function rl(t,s){var a;if(!s)return!0;const n=s.toLowerCase();return String(t.agentId)===s||(((a=t.profile)==null?void 0:a.name)??"").toLowerCase().includes(n)||(t.seller??"").toLowerCase().includes(n)}function ll(t,s){return dn(t,s).map(n=>J(n.usdc))}function dn(t,s){return t.volumeStatus!=="available"?[]:[...t.volumes].filter(n=>n.epoch<s).sort((n,a)=>n.epoch-a.epoch)}function vs(t){return Se(t.yourStake)+Se(t.yourPendingStake)}function un({amount:t,pending:s,sub:n,className:a}){return e.jsxs("span",{className:a?`cell-stack ${a}`:"cell-stack",children:[C(t),e.jsx("span",{className:"cell-sub",children:s>0n?e.jsxs("span",{className:"pending-amount",children:["+",C(s)," pending"]}):n})]})}function il({pool:t}){const s=Se(t.yourStake),n=Se(t.yourPendingStake);return s===0n&&n===0n?e.jsx("span",{className:"dim",children:"—"}):s===0n?e.jsxs("span",{className:"cell-stack pending-amount",children:[C(n),e.jsx("span",{className:"cell-sub",children:"pending activation"})]}):e.jsx(un,{amount:t.yourStake,pending:n,sub:`${ie(t.yourPoolShareBps)} of pool`,className:"accent"})}function ol({pools:t,currentEpoch:s,loading:n,walletSyncing:a=!1,onOpen:r,onStake:l}){const[i,c]=u.useState(""),[o,h]=u.useState(!1),[d,m]=u.useState("apy"),[x,f]=u.useState("descending"),[j,y]=u.useState(!1),E=(b,v)=>e.jsxs("button",{type:"button",className:"table-sort","aria-label":`Sort by ${v}, ${d===b&&x==="descending"?"ascending":"descending"}`,onClick:()=>{f(d===b&&x==="descending"?"ascending":"descending"),m(b),h(!1)},children:[v," ",e.jsx("span",{"aria-hidden":"true",children:d===b?x==="descending"?"↓":"↑":"↕"})]}),P=i.trim(),T=u.useMemo(()=>t.filter(b=>b.stakeable),[t]),A=u.useMemo(()=>T.filter(b=>vs(b)>0n).length,[T]),N=u.useMemo(()=>al(T.filter(b=>rl(b,P)&&(!j||vs(b)>0n)),d,x,s),[T,P,d,x,s,j]),k=!o&&N.length>yt?N.slice(0,yt):N,B=[{key:"seller",label:"Seller",render:b=>{var v;return e.jsxs("div",{className:"seller-cell",children:[e.jsx("button",{type:"button",className:"pool-details-trigger","aria-label":`View ${kt(b)} overview`,"aria-haspopup":"dialog",onClick:L=>{L.stopPropagation(),r(b)},children:kt(b)}),e.jsxs("span",{className:"seller-cell-meta",children:[b.stakers!=null?e.jsxs("span",{children:[W(b.stakers)," ",b.stakers===1?"staker":"stakers"]}):b.openPositions!==void 0?e.jsxs("span",{children:[W(b.openPositions)," ",b.openPositions===1?"position":"positions"]}):null,((v=b.profile)==null?void 0:v.modelsServed)!=null?e.jsxs("span",{children:[W(b.profile.modelsServed)," models"]}):null]})]})}},{key:"trend",label:"Volume trend",title:"Settled USDC volume over the last completed epochs.",render:b=>e.jsx(Zr,{values:ll(b,s),labels:dn(b,s).map(v=>`Epoch ${v.epoch}`),format:v=>`${We(BigInt(Math.round(v)))} USDC`,label:`${kt(b)} settled volume over recent epochs`,tone:(Mt(b,s)??0n)>0n?"accent":"muted"})},{key:"apy",label:E("apy","APY"),sortDirection:d==="apy"?x:"none",align:"right",mono:!0,render:b=>e.jsx(pl,{pool:b})},{key:"stake",label:E("stake","TVL"),sortDirection:d==="stake"?x:"none",title:"Total active stake in this pool (ANTS).",align:"right",mono:!0,render:b=>e.jsx(un,{amount:b.activeStake,pending:Se(b.pendingStake),sub:`${ie(b.powerShareBps)} power`})},{key:"volume",label:E("volume","Last epoch"),sortDirection:d==="volume"?x:"none",title:"Settled USDC volume in the last completed epoch.",align:"right",mono:!0,render:b=>{const v=Mt(b,s);return v===null?"—":We(v)}},{key:"yours",label:"Your stake",align:"right",mono:!0,render:b=>a?e.jsx("span",{className:"dim",children:"Updating…"}):e.jsx(il,{pool:b})},{key:"actions",label:"",align:"right",className:"col-actions",render:b=>b.stakeable?e.jsx("span",{onClick:v=>v.stopPropagation(),children:e.jsx(G,{variant:"outline",size:"sm",onClick:()=>l(b),children:"Stake"})}):null}];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pools-toolbar",children:[T.length>5?e.jsx(qe,{label:"",mono:!1,width:"md",placeholder:"Search seller or agent id",value:i,onChange:b=>c(b.target.value),"aria-label":"Filter pools"}):null,A>0&&!a?e.jsxs("button",{type:"button",className:"lock-preset","aria-pressed":j,onClick:()=>y(b=>!b),children:["my pools · ",A]}):null,n?null:e.jsxs("span",{className:"muted small",children:[P||j?`${W(N.length)} of `:"",W(T.length)," ",T.length===1?"seller":"sellers"]})]}),T.some(b=>{var v;return(v=b.displaySource)==null?void 0:v.error})?e.jsx("p",{className:"hint",children:"Some Antscan statistics are unavailable or may lag. Missing historical yield is shown as —; open a provider for details."}):null,e.jsx(Oe,{columns:B,rows:k,rowKey:b=>b.agentId,loading:n,onRowClick:r,empty:P?`No seller matches "${P}" in this view.`:j?"You have no stake in any seller yet.":"No sellers are ready for staking yet."}),N.length>yt?e.jsxs("div",{className:"pools-more",children:[e.jsxs("span",{className:"muted small",children:["Showing ",W(k.length)," of ",W(N.length)]}),e.jsx("button",{type:"button",className:"link-button",onClick:()=>h(b=>!b),children:o?"Show fewer":"Show all"})]}):null]})}function cl({pool:t,view:s,onClose:n,stake:a}){var E,P,T,A,N,U;const r=V(`pool:${t.agentId}`,()=>q.pool(t.agentId),6e4,qr),l=r.data??t,i=r.data?r.reconciling:!!s.walletSyncing,c=!!r.error||!!r.data&&r.data.volumeStatus!=="available",o=c&&t.volumeStatus==="available"?t:l,h=o===t?s.currentEpoch:((E=r.data)==null?void 0:E.currentEpoch)??s.currentEpoch,d=l.profile,m=s.explorer&&l.seller?`${s.explorer.replace(/\/$/,"")}/account/${l.seller}`:null,x=o.volumes.find(k=>k.epoch===h-1),f=Se(l.yourStake),j=Se(l.yourPendingStake),y=Se(l.pendingStake);return e.jsx(Dt,{isOpen:!0,onClose:n,size:"lg",overlayClassName:"ants-stake-overlay ants-pool-overlay",className:"pool-overview",title:ot(l),eyebrow:"SELLER",subtitle:e.jsxs(e.Fragment,{children:["Agent ",e.jsx("span",{className:"mono",children:l.agentId})," · ",l.seller?e.jsx(K,{value:l.seller,copy:!0}):"No seller bound",m?e.jsxs(e.Fragment,{children:[" · ",e.jsx("a",{href:m,target:"_blank",rel:"noreferrer",children:"View on Antscan ↗"})]}):null]}),children:e.jsxs("div",{className:"vault",children:[e.jsxs("div",{className:"vault-main",children:[e.jsxs("div",{className:"pool-overview-status",children:[e.jsx(le,{tone:l.stakeable?"accent":"muted",children:l.hasPool?"Staking pool":"No pool yet"}),d!=null&&d.providers.length?d.providers.slice(0,4).map(k=>e.jsx(le,{tone:"muted",children:k},k)):null,l.openPositions!==void 0?e.jsxs("span",{children:[W(l.openPositions)," open positions",l.stakers!=null?` · ${W(l.stakers)} stakers`:""]}):null,((P=l.displaySource)==null?void 0:P.source)==="indexer"?e.jsxs("span",{className:"dim",children:["Antscan block ",l.displaySource.indexedBlock]}):null]}),(T=l.displaySource)!=null&&T.error?e.jsxs("p",{className:"hint",children:["Antscan: ",l.displaySource.error,((A=l.yield)==null?void 0:A.status)==="unavailable"?" Historical yield is unavailable.":""]}):null,e.jsxs("div",{className:"pool-metrics",children:[e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Total value locked"}),e.jsxs("strong",{children:[C(l.activeStake)," ",e.jsx("small",{children:"ANTS"})]}),y>0n?e.jsxs("span",{className:"small pending-amount",children:["+",C(y)," ANTS pending activation"]}):null]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Last epoch volume"}),e.jsxs("strong",{children:[x&&o.volumeStatus==="available"?We(x.usdc):"—"," ",e.jsx("small",{children:"USDC"})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Power share"}),e.jsx("strong",{children:ie(l.powerShareBps)}),e.jsx("span",{className:"small muted",children:"of all pools' staking power"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Last epoch rewards"}),e.jsxs("strong",{children:[l.lastEpochEmission!=null?C(l.lastEpochEmission):"—"," ",e.jsx("small",{children:"ANTS"})]}),e.jsx("span",{className:"small muted",children:l.lastEpochEmission!=null?l.lastEpochEmissionSettled?"settled to stakers":"estimated, not settled":"no usage yet"})]})]}),e.jsxs("section",{className:"pool-apy-section","aria-label":"Estimated APY by lock",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Estimated APY by lock"}),e.jsx("span",{className:"small muted",children:"10,000 ANTS reference stake · longer locks earn more power"})]}),e.jsx(hl,{pool:l})]}),e.jsxs("section",{className:"pool-section",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Settled volume · completed epochs"}),e.jsx("span",{className:"small muted",children:"Includes legacy seller activity."})]}),c&&o===t&&o.volumeStatus==="available"&&e.jsx("p",{className:"hint",children:"Seller history could not refresh. Showing previously loaded history."}),o.volumeStatus!=="available"&&e.jsxs("p",{className:"hint",children:["Settlement volume ",o.volumeStatus==="stale"?"is stale":"is unavailable",". Usage points are not revenue."]}),e.jsx(Kr,{volumes:o.volumes,networkVolumes:s.networkVolumes,currentEpoch:h}),o.statsUpdatedAt&&e.jsxs("p",{className:"small muted",children:["History fetched ",ue(Math.floor(o.statsUpdatedAt/1e3))]})]}),e.jsxs("section",{className:"pool-section",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Stake, power and staker rewards"}),e.jsx("span",{className:"small muted",children:r.loading&&!r.data?"loading history…":(N=l.history)!=null&&N.length?`${l.history.length} indexed epochs`:"no indexed history"})]}),e.jsx(ul,{history:l.history??[],currentEpoch:h})]}),e.jsxs("section",{className:"pool-section",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Seller profile · lifetime activity"}),e.jsx("span",{className:"small muted",children:"Antscan indexed totals"})]}),(d==null?void 0:d.stale)&&e.jsx("p",{className:"hint",children:"Seller activity is stale; the indexer could not refresh."}),d?e.jsxs("div",{className:"pool-lifetime",children:[e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Settled volume"}),e.jsx("strong",{children:d.lifetimeVolumeUsdc!=null?`${We(d.lifetimeVolumeUsdc)} USDC`:"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Requests"}),e.jsx("strong",{children:d.requestCount!=null?W(d.requestCount):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Unique buyers"}),e.jsx("strong",{children:d.uniqueBuyers!=null?W(d.uniqueBuyers):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Models served"}),e.jsx("strong",{children:d.modelsServed!=null?W(d.modelsServed):"—"})]})]}):e.jsx("p",{className:"hint",children:"The explorer has no record for this seller."}),e.jsx(X,{items:[["Providers",d!=null&&d.providers.length?d.providers.join(", "):"—"],["Last epoch emission",l.lastEpochEmission!=null?`${C(l.lastEpochEmission,4)} ANTS`:"—"],["Ghost rate",(d==null?void 0:d.ghostRate)!=null&&Number.isFinite(d.ghostRate)&&d.ghostRate>=0&&d.ghostRate<=100?`${d.ghostRate.toFixed(1)}%`:"Unavailable"],["Last settled",(d==null?void 0:d.lastSettledAt)!=null?ue(d.lastSettledAt):"—"]]}),(d==null?void 0:d.fetchedAt)&&e.jsxs("p",{className:"small muted",children:["Profile fetched ",ue(Math.floor(d.fetchedAt/1e3))]})]}),e.jsx(Gr,{address:l.seller})]}),e.jsxs("aside",{className:"vault-side","aria-label":"Your position and staking",children:[e.jsxs(we,{children:[e.jsx("h3",{children:"Your position"}),i?e.jsx("p",{className:"hint",role:"status",children:"Updating… Waiting for Antscan to include your latest transaction."}):e.jsxs("div",{className:"vault-your",children:[e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Staked"}),e.jsx("strong",{children:f>0n?C(l.yourStake):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Pending activation"}),e.jsx("strong",{className:j>0n?"pending-amount":void 0,children:j>0n?C(l.yourPendingStake):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Power"}),e.jsx("strong",{children:f>0n?C(l.yourPower):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Pool share"}),e.jsx("strong",{children:f>0n?ie(l.yourPoolShareBps):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Positions"}),e.jsx("strong",{children:((U=l.yourPositionIds)==null?void 0:U.length)||"—"})]})]}),!i&&j>0n?e.jsxs("p",{className:"hint",children:["Pending stake starts earning at its activation epoch; it is listed under ",e.jsx("a",{href:_e("positions"),children:"My positions"})," with its start date."]}):null]}),e.jsxs(we,{children:[e.jsxs("h3",{children:["Stake into ",ot(l)]}),a?e.jsx(on,{config:a.config,pools:[l],balance:a.balance,rewards:a.rewards,rewardsError:a.rewardsError,defaultAgentId:l.agentId,lockedPool:!0},`${l.agentId}:${a.walletReady}`):e.jsx("p",{className:"hint",children:"Open this seller from the Stake page to stake into it."})]})]})]})})}const dl=10n**18n,Nt=t=>{const s=t/dl;return s>=1000000n?`${(Number(s)/1e6).toFixed(1)}M`:s>=10000n?`${(Number(s)/1e3).toFixed(0)}k`:s>=1000n?`${(Number(s)/1e3).toFixed(1)}k`:s>=100n?s.toString():C(t,2)};function ul({history:t,currentEpoch:s}){const n=t.filter(o=>o.epoch<=s),a=n.map(o=>o.epoch),r=n.map(o=>J(o.activeStake)),l=n.map(o=>J(o.weight)),i=n.map(o=>J(o.emission)),c=n.map(o=>!o.settled);return e.jsxs("div",{className:"chart-grid-2",children:[e.jsx(js,{epochs:a,title:"Active stake per epoch as bars (ANTS, left axis) with pool power as a line (right axis).",bars:{key:"stake",name:"Active stake · ANTS",values:r,format:o=>`${C(o)} ANTS`,tick:Nt},line:{key:"power",name:"Pool power",values:l,format:o=>C(o),tick:Nt}}),e.jsx(js,{epochs:a,title:"Staker rewards per epoch (ANTS). Hollow bars are estimates for epochs not yet settled.",bars:{key:"emission",name:"Staker rewards · ANTS",values:i,format:o=>`${C(o,2)} ANTS`,tick:Nt,provisional:c}})]})}function hl({pool:t}){return e.jsx("dl",{className:"pool-apy-estimates",children:zr(t.yield).map(s=>{var n,a;return e.jsxs("div",{title:s.status==="unsupported"?`${s.label} is not supported by this pool's whole-epoch lock limits.`:s.apy===null?"APY is unavailable because reward or epoch data is missing.":`10,000 ANTS reference stake. ${s.epochs} epoch(s), ${s.actualDays} days. Annualized initial earning rate with hypothetical compounding; not the return over this lock. APY above 10,000% is shown as ${xt}. Source epoch ${t.yield.epoch}.${((n=t.yield)==null?void 0:n.status)==="estimated"?" Rewards are not yet settled.":""}`,children:[e.jsx("dt",{children:s.label}),e.jsx("dd",{children:s.status==="unsupported"?e.jsx("span",{className:"pool-apy-unavailable",children:"Unsupported"}):e.jsxs(e.Fragment,{children:[Xe(s.apy),s.apy!==null&&s.apy<=it&&((a=t.yield)==null?void 0:a.status)==="estimated"?e.jsx("span",{className:"dim small",children:" est."}):null]})})]},s.label)})})}function ml(t){const s=t.yield;if(!s||s.status==="unavailable")return"Last-epoch yield is unavailable.";const n=Gt(s),a=s.endsAt-s.startsAt,r=l=>l===null?"unavailable":`${l} epoch(s), ${l*a/86400} days`;return`10,000 ANTS reference stake, including added pool power. 1 week: ${r(n.oneWeek.epochs)}; 2 years: ${r(n.twoYears.epochs)}. Source epoch ${s.epoch}: ${ue(s.startsAt)} – ${ue(s.endsAt)}. Assumes rewards and initial rates repeat each epoch; compounding is not automatic. Excludes declining power and activation delays. Returns aren’t guaranteed. — means unavailable.${s.status==="estimated"?" Rewards not yet settled.":""}`}function pl({pool:t}){var c;const{oneWeek:s,twoYears:n}=Gt(t.yield),a=s.apy!==null||n.apy!==null,r=(s.apy??0)>it||(n.apy??0)>it,l=Xe(s.apy),i=Xe(n.apy);return e.jsxs("span",{className:`yield-percent${a?" yield-percent--hot":""}`,title:`${ml(t)}${r?` ${_r}`:""}`,children:[r?xt:a?`${l} – ${i}`:"—",a&&!r&&((c=t.yield)==null?void 0:c.status)==="estimated"?e.jsx("span",{className:"dim small",children:" est."}):null]})}function hn(t){return t.maxLockedNext??t.maxLocked}function ts(t,s,n){return t==="enable-max-lock"||t==="disable-max-lock"?s+1:Math.max(s+1,...n.map(a=>a.stakeStartEpoch))}function mn(t,s,n){if(t.withdrawn||t.closedAtEpoch!==0)return"This position is already closed or withdrawn.";if(n===null)return"Waiting for current epoch information.";const a=hn(t);return s==="disable-max-lock"?a?null:"This position is not scheduled for max lock.":a?s==="enable-max-lock"?"This position is already scheduled for max lock.":"Disable maximum lock before this action.":s==="enable-max-lock"&&n<t.stakeStartEpoch?`Max lock can be enabled when the next epoch reaches activation epoch ${t.stakeStartEpoch}.`:t.stakeEndEpoch===0||n>=t.stakeEndEpoch?"The position has no remaining lock when this action takes effect. Withdraw it, then stake again to start a new lock.":null}function xl({items:t,label:s="More actions"}){const[n,a]=u.useState(!1),r=u.useRef(null),l=u.useRef(null),[i,c]=u.useState({});return u.useLayoutEffect(()=>{if(!n||!l.current)return;const o=l.current.getBoundingClientRect();c({top:o.bottom+4,right:Math.max(8,window.innerWidth-o.right)})},[n]),u.useEffect(()=>{if(!n)return;const o=m=>{r.current&&!r.current.contains(m.target)&&a(!1)},h=m=>{m.key==="Escape"&&a(!1)},d=()=>a(!1);return document.addEventListener("mousedown",o),window.addEventListener("keydown",h),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",h),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[n]),e.jsxs("span",{className:"menu",ref:r,onClick:o=>o.stopPropagation(),children:[e.jsx("button",{ref:l,type:"button",className:"menu-trigger","aria-label":s,"aria-haspopup":"menu","aria-expanded":n,title:s,onClick:()=>a(o=>!o),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"3",cy:"8",r:"1.4"}),e.jsx("circle",{cx:"8",cy:"8",r:"1.4"}),e.jsx("circle",{cx:"13",cy:"8",r:"1.4"})]})}),n?e.jsx("div",{className:"menu-list",role:"menu",style:i,children:t.map(o=>e.jsx("button",{type:"button",role:"menuitem",className:"menu-item",disabled:o.disabled,title:o.title,onClick:()=>{var h;a(!1),(h=l.current)==null||h.focus({preventScroll:!0}),o.onSelect()},children:o.label},o.label))}):null]})}function pn({positionId:t,positionIds:s,size:n,autoOpen:a=!1,onStarted:r,onCancel:l}){const i=s??(t!==void 0?[t]:[]),c=Ae(),o=Jt(),[h,d]=u.useState(a),[m,x]=u.useState(null),[f,j]=u.useState(null),[y,E]=u.useState(!1),[P,T]=u.useState(!1),[A,N]=u.useState(null),[U,k]=u.useState(!1),B=u.useRef(!1),b=i.length===0||i.some(w=>!Number.isSafeInteger(w)||w<=0),v=async()=>{if(!b){E(!0),x(null),j(null),T(!1);try{const w=await q.withdrawPreview(i);x(i.length===1?fl(w,i[0]):w)}catch(w){j(Ce(w))}finally{E(!1)}}},L=()=>{b||(d(!0),N(null),v())};u.useEffect(()=>{a&&!b&&L()},[]);const D=async()=>{if(!g||!m||B.current)return;const w={positionIds:i,acceptSlashing:m.earlyExit&&P,maxSlashedAmount:m.totalSlashed};B.current=!0,k(!0),N(null);try{await c.start("/api/positions/withdraw",w),d(!1),r==null||r()}catch(p){c.pushToast({tone:"danger",title:`Withdraw · position${i.length>1?"s":""} ${i.map(I=>`#${I}`).join(", ")} failed`,body:Ce(p),sticky:!0})}finally{B.current=!1,k(!1)}},S=o.reason??(b?"Choose at least one position to withdraw.":void 0),g=!b&&!o.blocked&&!U&&m!==null&&!m.simulationError&&(!m.earlyExit||P);return e.jsxs("div",{className:"action",children:[h&&a?null:e.jsx("span",{className:"btn-wrap",title:S,children:e.jsx(G,{variant:"outline",size:n==="sm"?"sm":"md",onClick:L,disabled:b,children:"Withdraw"})}),h?e.jsxs(tn,{title:i.length>1?`Withdraw ${i.length} positions`:"Withdraw position",hideTitle:a,confirmLabel:o.label??(m!=null&&m.earlyExit?"Withdraw and burn slashed principal":"Withdraw"),danger:(m==null?void 0:m.earlyExit)===!0,disabled:!g,busy:U,error:A,onConfirm:()=>{D()},onCancel:()=>{d(!1),l==null||l()},children:[o.reason?e.jsxs("div",{className:"hint",children:[o.reason," You can still review this estimate."]}):null,y?e.jsxs("div",{className:"muted small",children:[e.jsx(mt,{})," Computing slashing preview…"]}):null,f?e.jsxs("div",{children:[e.jsx("div",{className:"error-text",children:f}),e.jsx("div",{className:"mt",children:e.jsx(G,{variant:"outline",size:"sm",onClick:()=>void v(),children:"Retry preview"})})]}):null,(m==null?void 0:m.simulationError)&&e.jsxs("div",{className:"error-text",children:["Withdrawal cannot execute: ",m.simulationError]}),m?e.jsxs("div",{className:"hint",children:["Rewards to claim separately: ",C(m.pendingRewards,4)," ANTS. ",m.transfersRestricted?"Returned ANTS remain transfer-restricted in this wallet. Ending a position does not enable token transfers. Consider moving your allocation directly to another seller.":"ANTS transfers are currently enabled for this wallet."]}):null,m?e.jsxs("div",{className:"stack",children:[e.jsx(gl,{preview:m}),m.earlyExit?e.jsxs("div",{className:"row",children:[e.jsxs("label",{className:"check danger",children:[e.jsx("input",{type:"checkbox",checked:P,onChange:w=>T(w.target.checked)}),e.jsxs("span",{children:["I accept burning ",e.jsx("span",{className:"mono",children:C(m.totalSlashed,4)})," ANTS of principal (early exit)."]})]}),e.jsx($t,{})]}):e.jsxs("div",{className:"hint",children:["No early-exit penalty applies. Withdrawal returns principal; rewards must be claimed separately.",e.jsx($t,{})]})]}):null]}):null]})}function fl(t,s){var n;if(t.positions.length!==1||((n=t.positions[0])==null?void 0:n.id)!==s)throw new Error("Withdrawal preview does not match this position. Refresh and try again.");return t}function gl({preview:t}){const s=t.positions.length===1;return e.jsx(X,{items:[...s?[["Early-exit penalty",e.jsxs("span",{className:t.earlyExit?"danger":void 0,children:[ie(t.positions[0].slashBps),e.jsx($t,{})]})]]:t.positions.map(n=>[`Position #${n.id}`,e.jsxs("span",{className:n.slashBps>0?"danger":void 0,children:[C(n.amount,4)," ANTS · penalty ",ie(n.slashBps)]})]),["Burned",e.jsxs("span",{className:t.earlyExit?"danger":void 0,children:[C(t.totalSlashed,4)," ANTS"]})],["You receive",`${C(t.totalReturned,4)} ANTS`]]})}function bl({pools:t,enabled:s=!0}){var S,g,w;const n=he(),a=V(s?"positions:current":null,q.positions),[r,l]=u.useState(!1),[i,c]=u.useState(null),[o,h]=u.useState(null),[d,m]=u.useState(()=>new Set),x=a.data,f=a.reconciling||!!a.error,j=u.useMemo(()=>(x==null?void 0:x.positions)??[],[x]),y=u.useMemo(()=>j.filter(p=>!je(p)).length,[j]),E=u.useMemo(()=>r?j:j.filter(je),[j,r]),P=i?E.find(p=>p.id===i.id)??null:null,T=u.useMemo(()=>new Map(t.map(p=>[p.agentId,p])),[t]),A=u.useMemo(()=>E.filter(je),[E]),N=u.useMemo(()=>A.filter(p=>d.has(p.id)),[A,d]),U=xn(N,n==null?void 0:n.current),k=(p,I)=>c({id:p,kind:I}),B=p=>m(I=>{const _=new Set(I);return _.has(p)?_.delete(p):_.add(p),_}),b=()=>m(p=>p.size===A.length?new Set:new Set(A.map(I=>I.id))),v=()=>m(new Set),L=p=>p.stopPropagation(),D=[{key:"select",className:"col-select",label:A.length>0?e.jsx("input",{type:"checkbox","aria-label":"Select all open positions",disabled:f,checked:d.size>0&&d.size===A.length,onChange:b}):"",render:p=>je(p)?e.jsx("input",{type:"checkbox","aria-label":`Select position ${p.id}`,disabled:f,checked:d.has(p.id),onChange:()=>B(p.id),onClick:L}):null},{key:"seller",label:"Seller",render:p=>{var _,$;const I=T.get(p.agentId);return e.jsxs("span",{className:"cell-stack",title:(I==null?void 0:I.seller)??void 0,children:[e.jsx("span",{children:(($=(_=I==null?void 0:I.profile)==null?void 0:_.name)==null?void 0:$.trim())||(I!=null&&I.seller?ut(I.seller):"Unknown seller")}),e.jsxs("span",{className:"cell-sub",children:["#",p.id,jl(p)]})]})}},{key:"amount",label:"Amount",align:"right",mono:!0,render:p=>e.jsxs("span",{className:"cell-stack",children:[C(p.amount,4),e.jsxs("span",{className:"cell-sub",title:p.nextPower!=null?`Next epoch power: ${C(p.nextPower,0)}`:void 0,children:["power ",C(p.power??p.weightAmount,0)]})]})},{key:"apy",label:e.jsxs(e.Fragment,{children:["Est. APY",e.jsx(Ze,{label:"About position APY",children:"Illustrative annualized return using the pool’s historical epoch reward budget and current pool power. Active positions use their current power, already included in the pool total. Pending positions use their activation power added to the current pool total; other pending changes are not projected. Assumes the rate repeats and compounds every epoch. Compounding is not automatic, normal-lock power declines, and activation delays are excluded. Missing data and closed or expired positions show —. Future rewards are not guaranteed."})]}),align:"right",mono:!0,render:p=>{var M,O,H;const I=T.get(p.agentId),_=(x==null?void 0:x.currentEpoch)??(n==null?void 0:n.current),$=Or(p,I,_,(M=x==null?void 0:x.config)==null?void 0:M.maxStakeEpochs);return e.jsx("span",{title:$===null?"APY unavailable for this position.":`Based on ${((O=I==null?void 0:I.yield)==null?void 0:O.status)==="estimated"?"estimated ":""}pool rewards in epoch ${(H=I==null?void 0:I.yield)==null?void 0:H.epoch}.${_!==void 0&&p.stakeStartEpoch>_?" Estimate for when this position activates.":""}`,children:Xe($)})}},{key:"unlocks",label:"Unlocks",title:"Epoch and date when the lock expires. Funds are not withdrawn automatically.",render:p=>e.jsx(ft,{position:p})},{key:"state",label:"Status",title:"The current stage of this staking position.",render:p=>e.jsx(yl,{position:p})},{key:"reward",label:"Pending reward",align:"right",mono:!0,render:p=>C(p.pendingReward,4)},{key:"actions",label:"",align:"right",className:"col-actions",render:p=>je(p)&&!f?e.jsx("span",{className:"row-nowrap",onClick:L,children:e.jsx(xl,{label:`More actions for position ${p.id}`,items:[{label:"Split",onSelect:()=>k(p.id,"split"),disabled:fe(p,"split",n==null?void 0:n.current)!==null,title:fe(p,"split",n==null?void 0:n.current)??void 0},{label:"Extend lock",onSelect:()=>k(p.id,"extend"),disabled:fe(p,"extend",n==null?void 0:n.current)!==null,title:fe(p,"extend",n==null?void 0:n.current)??void 0},{label:Re(p)?"Disable max lock":"Enable max lock",onSelect:()=>k(p.id,"max-lock"),disabled:Bt(p,n==null?void 0:n.current)!==null,title:Bt(p,n==null?void 0:n.current)??void 0},{label:"Move allocation",onSelect:()=>k(p.id,"move"),disabled:fe(p,"move",n==null?void 0:n.current)!==null,title:fe(p,"move",n==null?void 0:n.current)??void 0},{label:"Withdraw",onSelect:()=>k(p.id,"withdraw")}]})}):null}];return e.jsxs(Z,{title:`Your positions${x?` (${E.length})`:""}`,className:"positions-card",actions:y>0?e.jsx("button",{type:"button",className:"link-button",onClick:()=>l(p=>!p),children:r?"hide closed":`show ${y} closed`}):null,children:[a.error&&!x?e.jsx(ne,{error:a.error,onRetry:a.refresh}):null,a.error&&x?e.jsxs("div",{className:"status-line",children:["Refresh failed: ",a.error]}):null,a.reconciling&&!a.error?e.jsx("p",{role:"status",className:"hint",children:"Updating… Waiting for the latest position data."}):null,(x==null?void 0:x.historySource)==="local"?e.jsx("p",{className:"hint",children:"Includes closed positions from verified local transactions. Older history may be incomplete without an indexer."}):null,(x==null?void 0:x.historySource)==="chain"?e.jsx("div",{className:"status-line status-line--muted",children:"Closed-position history is unavailable. Open positions are shown from the chain; rewards on closed positions may be missing."}):null,N.length>0&&!f?e.jsxs("div",{className:"bulk-bar",role:"region","aria-label":"Selected positions",children:[e.jsxs("span",{className:"bulk-bar-count",children:[N.length," selected · ",C(Lt(N),4)," ANTS"]}),e.jsx("button",{type:"button",className:"link-button",onClick:v,children:"clear"}),e.jsxs("div",{className:"bulk-bar-actions",children:[e.jsx("span",{className:"btn-wrap",title:U??"Combine the selected positions into one.",children:e.jsxs(G,{variant:"outline",size:"sm",disabled:U!==null,onClick:()=>h("merge"),children:["Merge ",N.length>1?N.length:""]})}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>h("withdraw"),children:["Withdraw ",N.length]})]})]}):null,i&&P&&x&&!f?e.jsx(Al,{kind:i.kind,position:P,config:x.config,pools:t,onClose:()=>c(null)},`${i.id}:${i.kind}`):null,o&&x&&N.length>0&&!f?e.jsx(El,{kind:o,positions:N,pools:t,onClose:()=>h(null),onStarted:()=>{h(null),v()}}):null,e.jsx(Oe,{columns:D,rows:E,rowKey:p=>p.id,empty:s?a.error?"Positions are currently unavailable.":x?a.reconciling?"Updating positions…":"No open positions. Stake rewards into a seller to open one.":"Loading positions…":"Connect a wallet to see your positions."}),((S=x==null?void 0:x.displaySource)==null?void 0:S.source)==="indexer"?e.jsx("p",{className:"hint",children:"Position status from Antscan. Withdrawal amounts and transaction eligibility are checked live before signing."}):null,((g=x==null?void 0:x.rewardSource)==null?void 0:g.indexedBlock)!==void 0?e.jsxs("p",{className:"hint",children:["Reward estimates from Antscan at block ",x.rewardSource.indexedBlock,"."]}):null,(w=x==null?void 0:x.rewardSource)!=null&&w.error?e.jsxs("p",{role:"status",className:"hint",children:["Indexed rewards unavailable: ",x.rewardSource.error,". Unknown amounts are shown as —, not zero."]}):null]})}function Lt(t){return t.reduce((s,n)=>s+(J(n.amount)??0n),0n).toString()}function xn(t,s){if(t.length<2)return"Select at least two positions to merge.";if(new Set(t.map(a=>a.id)).size!==t.length)return"Select each position only once.";if(new Set(t.map(a=>a.agentId)).size!==1)return"Merged positions must stake the same seller.";const n=s===void 0?null:ts("merge",s,t);for(const a of t){const r=mn(a,"merge",n);if(r)return r}return new Set(t.map(a=>a.stakeEndEpoch)).size!==1?"Merged positions must share the same unlock epoch. Extend the shorter ones first.":null}function Re(t){return hn(t)}function jl(t){const s=Re(t);return s&&t.maxLocked?" · max lock":s?" · max lock from next epoch":t.maxLocked?" · max lock ends next epoch":""}function je(t){return!t.withdrawn&&t.closedAtEpoch===0&&t.state!=="withdrawn"&&t.state!=="closed"}const wl={pending:"amber",active:"accent",matured:"muted",closed:"muted",withdrawn:"muted"},vl={pending:"Waiting for the stake activation epoch.",active:"The staking position is active and its lock has not expired.",matured:"The lock has expired. Withdraw to receive your funds; withdrawal is not automatic.",closed:"This position has been closed, for example by a split, merge, or move.",withdrawn:"Funds have been withdrawn from this position."};function yl({position:t}){const{state:s}=t,n=je(t)&&(s==="pending"||t.changePending);return e.jsx(le,{tone:n?"amber":wl[s],title:n?"The transaction is confirmed. This position starts contributing staking power at its activation epoch.":vl[s],children:n?`Activates epoch ${t.stakeStartEpoch}`:s})}function fe(t,s,n){const a=n===void 0?null:ts(s,n,[t]);return mn(t,s,a)}function Bt(t,s){return fe(t,Re(t)?"disable-max-lock":"enable-max-lock",s)}function ft({position:t,dateOnly:s=!1}){const n=he();if(!je(t))return e.jsx("span",{className:"muted",children:"—"});const a=n?`epoch ${n.current+1}`:"next epoch";return Re(t)?e.jsxs("span",{className:"cell-stack",children:[e.jsx("span",{className:"muted",title:"Disable max lock to start the countdown.",children:"Max lock"}),!t.maxLocked&&e.jsxs("span",{className:"cell-sub",children:["Max lock starts ",a]})]}):e.jsxs("span",{className:"cell-stack",children:[e.jsx(st,{epoch:t.stakeEndEpoch,dateOnly:s}),t.maxLocked&&e.jsxs("span",{className:"cell-sub",children:["Countdown starts ",a]})]})}function gt(t,s){var a,r;const n=s.find(l=>l.agentId===t);return((r=(a=n==null?void 0:n.profile)==null?void 0:a.name)==null?void 0:r.trim())||(n!=null&&n.seller?ut(n.seller):"Unknown seller")}function kl({position:t,pools:s}){const n=he(),a=t.epochsRemaining,r=n?rt(De(t.stakeEndEpoch,n.genesis,n.epochDuration)):null,l=n?rt(De(t.stakeStartEpoch,n.genesis,n.epochDuration)):null;return e.jsxs("div",{children:[e.jsxs("div",{children:[gt(t.agentId,s)," · ",e.jsxs("span",{className:"mono",children:[C(t.amount,4)," ANTS"]})]}),e.jsxs("div",{className:"muted small",children:[je(t)?Re(t)||t.maxLocked?e.jsx(ft,{position:t,dateOnly:!0}):t.state==="matured"?"Lock expired":e.jsxs(e.Fragment,{children:[t.state==="pending"?"Lock duration":"Remaining lock",": ",a," ",a===1?"epoch":"epochs",n?` (${t.state==="pending"?"":"up to "}${Os(a*n.epochDuration)})`:"",t.state==="pending"?` · starts ${l?`${l} UTC`:`epoch ${t.stakeStartEpoch}`}`:""]}):"Position closed",!t.maxLocked&&je(t)?` · ${t.state==="matured"?"unlocked":"unlocks"} ${r?`${r} UTC`:`epoch ${t.stakeEndEpoch}`}`:""]})]})}function Nl({position:t,config:s,pools:n,onStarted:a}){const r=he(),l=n.filter(x=>x.stakeable&&x.agentId!==t.agentId),[i,c]=u.useState(()=>{var x;return String(((x=l[0])==null?void 0:x.agentId)??"")}),o=l.find(x=>String(x.agentId)===i)??null,h={positionIds:[t.id],toAgentId:Number(i)},d=fe(t,"move",r==null?void 0:r.current),m=Math.max(((r==null?void 0:r.current)??0)+1,t.stakeStartEpoch);return e.jsxs("div",{className:"form-row",children:[e.jsx("p",{className:"hint",children:"Move your allocation directly to another seller. Principal stays staked and the lock end date is preserved. Accrued rewards remain claimable on the source position."}),e.jsxs("p",{className:"hint",children:["Effective ",r?`${rt(De(m,r.genesis,r.epochDuration))} UTC (epoch ${m})`:`epoch ${m}`,". One transaction; your wallet will ask you to approve it."]}),d&&e.jsx("p",{className:"error-text",children:d}),e.jsx(Ue,{label:"To seller",hint:s.moveWeightPenaltyBps===0?"No move penalty is currently configured. Moving does not burn your ANTS.":`Moving reduces future staking power by ${ie(s.moveWeightPenaltyBps)}. Your ANTS principal is not burned.`,width:"lg",children:e.jsxs(Fe,{value:i,onChange:x=>c(x.target.value),disabled:l.length===0,children:[l.length===0?e.jsx("option",{value:"",children:"No other seller to move to"}):null,l.map(x=>e.jsx("option",{value:x.agentId,children:gt(x.agentId,n)},x.agentId))]})}),e.jsx(ge,{label:"Move allocation",disabled:d!==null,disabledReason:d??void 0,variant:"primary",path:"/api/positions/move",body:h,validate:()=>o?null:"Choose a target seller.",onStarted:a})]})}function Sl({position:t,onStarted:s}){const n=he(),a=J(t.amount)??0n,r=J(t.weightAmount)??0n,[l,i]=u.useState(""),c=Je(l)?It(l,18):null,o=c!==null&&c>0n&&c<a,h=o?r*c/a:0n,d=fe(t,"split",n==null?void 0:n.current),m=f=>i(C(a*BigInt(Math.round(f*1e4))/10000n,18).replace(/,/g,"")),x={positionId:t.id,amount:l.trim()};return e.jsxs("div",{className:"stack",children:[e.jsx("p",{className:"hint",children:"Splitting replaces this position with two positions with the same seller and lock terms. Power splits in proportion to the amount, so total power is unchanged. Disable max lock before splitting; you can enable it on the new positions before they activate."}),d&&e.jsx("p",{className:"error-text",children:d}),e.jsx("div",{className:"form-row",children:e.jsx(qe,{label:"Amount to split off (ANTS)",inputMode:"decimal",value:l,onChange:f=>i(f.target.value),placeholder:"0.0",hint:e.jsxs(e.Fragment,{children:["of ",e.jsx("span",{className:"mono",children:C(t.amount,4)})," ·"," ",[.25,.5,.75].map(f=>e.jsxs("button",{type:"button",className:"link-button",style:{marginRight:8},onClick:()=>m(f),children:[f*100,"%"]},f))]})})}),e.jsxs("div",{className:"split-preview","aria-live":"polite",children:[e.jsxs("div",{className:"split-part",children:[e.jsxs("span",{className:"tile-label",children:["Keeps position #",t.id]}),e.jsxs("strong",{children:[C(o?a-c:a,4)," ANTS"]}),e.jsxs("span",{className:"small muted",children:["power ",C(o?r-h:r,0)]})]}),e.jsxs("div",{className:"split-part split-part--new",children:[e.jsx("span",{className:"tile-label",children:"New position"}),e.jsxs("strong",{children:[o?C(c,4):"—"," ANTS"]}),e.jsxs("span",{className:"small muted",children:["power ",o?C(h,0):"—"]})]})]}),e.jsx(ge,{label:"Split position",variant:"primary",path:"/api/positions/split",body:x,disabled:d!==null,disabledReason:d??void 0,validate:()=>Je(l)?c===null?"Amount must have no more than 18 decimal places.":c>=a?`Amount must be below the position's ${C(t.amount,4)} ANTS.`:h===0n||r-h===0n?"Amount is too small: both parts need non-zero power.":null:"Amount must be a positive decimal number of ANTS.",onStarted:s})]})}function Cl({position:t,config:s,onStarted:n}){const a=he(),r=!Re(t),l={positionId:t.id,enable:r},i=Bt(t,a==null?void 0:a.current),c=a?a.current+1+s.maxStakeEpochs:null;return e.jsxs("div",{className:"stack",children:[r?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"hint",children:["Max lock pins this position at the maximum lock (",s.maxStakeEpochs," epochs",a?`, ${Os(s.maxStakeEpochs*a.epochDuration)}`:"",") so its staking power stays at the maximum instead of decaying as the lock runs down."]}),e.jsx("p",{className:"hint",children:"The lock no longer counts down. To withdraw later, disable max lock first: a fresh full countdown then starts from the next epoch. Disabling before activation does not restore the original shorter lock. Moves and merges require max lock to be disabled at their effective epoch."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"hint",children:["Disabling max lock starts a fresh ",s.maxStakeEpochs,"-epoch countdown from the next epoch",c!==null?e.jsxs(e.Fragment,{children:[" (unlocks ",e.jsx(st,{epoch:c,dateOnly:!0}),")"]}):null,". Power then decays as the lock runs down."]}),e.jsx("p",{className:"hint",children:"Withdrawing before that countdown ends is an early exit and burns part of the principal."})]}),i&&e.jsx("p",{className:"error-text",children:i}),e.jsx(ge,{label:r?"Enable max lock":"Disable max lock",variant:r?"primary":"default",path:"/api/positions/max-lock",body:l,disabled:i!==null,disabledReason:i??void 0,onStarted:n})]})}function Al({kind:t,position:s,config:n,pools:a=[],onClose:r}){const l=he(),i=l?ts("extend",l.current,[s]):null,c=i===null?null:s.stakeEndEpoch,o=c===null||i===null?0:Math.max(n.maxStakeEpochs-(c-i),0),h=fe(s,"extend",l==null?void 0:l.current),[d,m]=u.useState(Math.min(1,o)||1),x={move:"Move allocation",extend:"Extend position",split:"Split position","max-lock":Re(s)?"Disable max lock":"Enable max lock",withdraw:"Withdraw positions"},f={positionId:s.id,epochs:d},j=()=>h||(o<=0?`This position is already at the maximum lock (${n.maxStakeEpochs} epochs).`:d<1||d>o?`At most ${o} more epoch(s) can be added (max lock ${n.maxStakeEpochs}).`:null);return e.jsxs(Kt,{title:x[t],onClose:r,children:[t!=="extend"?e.jsx("div",{className:"small mb",children:e.jsx(kl,{position:s,pools:a})}):null,t==="withdraw"?e.jsxs("div",{className:"stack",children:[s.changePending?e.jsxs("div",{className:"error-text",children:["Withdrawals are blocked until activation epoch ",s.withdrawableEpoch,". The position change is already confirmed."]}):null,e.jsx(pn,{positionId:s.id,autoOpen:!0,onStarted:r,onCancel:r})]}):null,t==="move"?e.jsx(Nl,{position:s,config:n,pools:a,onStarted:r}):null,t==="split"?e.jsx(Sl,{position:s,onStarted:r}):null,t==="max-lock"?e.jsx(Cl,{position:s,config:n,onStarted:r}):null,t==="extend"?e.jsxs("div",{className:"stack",children:[e.jsxs("dl",{className:"facts",children:[e.jsx("dt",{children:"Amount"}),e.jsxs("dd",{children:[C(s.amount,4)," ANTS"]}),e.jsx("dt",{children:"Current unlock time"}),e.jsx("dd",{children:e.jsx(ft,{position:s,dateOnly:!0})})]}),h&&e.jsx("p",{className:"error-text",children:h}),e.jsx(es,{label:"Add",value:d,min:1,max:Math.max(o,1),startEpoch:c,onChange:m,disabled:h!==null||o<=0,showUnlockDate:!1}),e.jsxs("dl",{className:"facts","aria-live":"polite",children:[e.jsx("dt",{children:"New unlock date"}),e.jsx("dd",{children:e.jsx(st,{epoch:c!==null&&o>0&&!h?c+d:null,dateOnly:!0})})]}),e.jsx(ge,{label:"Extend",variant:"primary",path:"/api/positions/extend",body:f,disabled:h!==null||o<=0,disabledReason:h??(o<=0?"This position is already at the maximum lock.":void 0),validate:j,onStarted:r})]}):null]})}function El({kind:t,positions:s,pools:n,onClose:a,onStarted:r}){const l=he(),i=s.map(d=>d.id),c=xn(s,l==null?void 0:l.current),o={positionIds:i},h=s[0];return e.jsx(Kt,{title:t==="merge"?`Merge ${s.length} positions`:`Withdraw ${s.length} positions`,onClose:a,children:e.jsxs("div",{className:"stack",children:[e.jsxs("dl",{className:"facts",children:[s.map(d=>e.jsx(Il,{position:d,pools:n},d.id)),e.jsx("dt",{children:"Total"}),e.jsxs("dd",{children:[C(Lt(s),4)," ANTS"]})]}),t==="merge"?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"hint",children:["Merging combines these positions into one position of ",C(Lt(s),4)," ANTS in ",gt(h.agentId,n)," with the shared unlock epoch ",h.stakeEndEpoch,". Power is preserved. The source positions close; their accrued rewards stay claimable. The contract verifies matching underlying lock start and end terms before wallet approval; matching unlock dates alone are not sufficient."]}),c?e.jsx("p",{className:"error-text",children:c}):null,e.jsx(ge,{label:"Merge positions",variant:"primary",path:"/api/positions/merge",body:o,disabled:c!==null,disabledReason:c??void 0,onStarted:r})]}):e.jsxs(e.Fragment,{children:[s.some(d=>d.changePending)?e.jsx("div",{className:"error-text",children:"A selected position has not activated. Withdrawals remain blocked until its activation epoch."}):null,e.jsx(pn,{positionIds:i,autoOpen:!0,onStarted:r,onCancel:a})]})]})})}function Il({position:t,pools:s}){return e.jsxs(e.Fragment,{children:[e.jsxs("dt",{children:["#",t.id," · ",gt(t.agentId,s)]}),e.jsxs("dd",{children:[C(t.amount,4)," ANTS · ",e.jsx(ft,{position:t,dateOnly:!0})]})]})}function Tl(){var d;const t=Ie(),s=!t.browserWallet||!t.readOnly,n=s||!!(t.selectedAddress||t.walletAddress)&&!/^0x0{40}$/i.test(t.address),a=V("overview",q.overview),r=V("rewards",q.rewards,5*6e4),l=V("pools",q.pools,5*6e4,Qt),i=u.useMemo(()=>{var m;return cn(((m=l.data)==null?void 0:m.pools)??[])},[l.data]),c=a.data,o=(c==null?void 0:c.wallet.canTransfer)??!1,h=l.reconciling?0n:J(((d=l.data)==null?void 0:d.yourPendingStake)??null)??0n;return e.jsxs(e.Fragment,{children:[ae().embedded?null:e.jsx("h1",{className:"page-title",children:"My positions"}),a.error&&!c?e.jsx(ne,{error:a.error,onRetry:a.refresh}):null,e.jsxs(Vt,{children:[e.jsx(me,{label:"Your total staked",value:c?C(c.wallet.totalActiveStake):"…",unit:"ANTS",loading:!c,sub:a.reconciling&&!a.error?"Updating…":c?e.jsxs(e.Fragment,{children:[W(c.wallet.positionCount)," position",c.wallet.positionCount===1?"":"s",h>0n?e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"pending-amount",children:[C(h)," ANTS pending activation"]})]}):null]}):void 0}),e.jsx(me,{label:"Your power",value:l.reconciling&&!l.error?"…":l.data?C(l.data.yourTotalPower):l.error?"—":"…",loading:l.loading&&!l.data,sub:l.reconciling&&!l.error?"Updating…":l.data?`${ie(l.data.yourNetworkShareBps)} of all pools`:l.error?e.jsx("span",{className:"danger",children:l.error}):"scanning pools…"}),e.jsx(me,{label:s?"Claimable rewards":"Buyer rewards",value:r.data?C(r.data.total):r.error?"—":"…",unit:"ANTS",loading:r.loading&&!r.data,sub:r.error?e.jsxs("span",{className:"danger",children:[r.error," ",e.jsx("button",{className:"link-button",onClick:r.refresh,type:"button",children:"retry"})]}):r.reconciling?"Updating…":r.data?e.jsx("a",{href:_e("rewards"),children:s?"Stake rewards or claim →":"View buyer rewards →"}):"loading from chain…"}),e.jsx(me,{label:"Wallet balance",value:c?C(c.wallet.ants,4):"…",unit:"ANTS",loading:!c,sub:a.reconciling&&!a.error?"Updating…":c?o?"transfers enabled · stakeable":"transfers not enabled · stake from rewards":void 0})]}),e.jsx(bl,{pools:i,enabled:n})]})}const nt=u.createContext({updating:!1,stale:!1});function $l(){const t=V("rewards",q.rewards,3e5),s=t.data,n=t.reconciling&&(!t.error||t.loading),a=!!s&&(t.reconciling||!!t.error);return e.jsxs(e.Fragment,{children:[t.error&&!s?e.jsx(ne,{error:t.error,onRetry:t.refresh}):null,t.error&&s&&!t.loading?e.jsx(ne,{title:"Rewards could not be refreshed",error:`Shown amounts may be out of date. Retry refreshing before another action. This does not mean a confirmed transaction failed. ${t.error}`,onRetry:t.refresh}):null,n?e.jsx("p",{role:"status",className:"hint",children:"Updating… Waiting for the latest reward data."}):null,!s&&t.loading?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"muted small mb",children:"Loading rewards from the blockchain and indexer…"}),e.jsx(tt,{rows:6})]}):null,s?e.jsxs(nt.Provider,{value:{updating:n,stale:a},children:[ae().buyerRewards?e.jsx(Pl,{data:s}):null,s.scope!=="buyer"?e.jsx(Rl,{onRefresh:t.refresh,data:s}):ae().buyerRewards?null:e.jsx("p",{className:"hint",children:"Connect the wallet that holds your staking positions to see its staking rewards."})]}):null]})}function Ut(){const{updating:t,stale:s}=u.useContext(nt);return s?e.jsx("span",{className:"reward-refresh-state",children:t?"Updating…":"Out of date"}):null}function Pe({children:t}){const{updating:s}=u.useContext(nt);return s?e.jsx("span",{className:"muted","aria-busy":"true",children:t}):e.jsx(e.Fragment,{children:t})}function Pl({data:t}){var j;const s=Ie(),[n,a]=u.useState(null),[r,l]=u.useState(!1),i=At([t.buyerUsage.total,t.legacy.buyer]),c=t.buyerUsage.operator,o=!!c&&c.toLowerCase()===(s.walletAddress??s.address).toLowerCase()&&!s.readOnly,h=!c&&s.canAuthorize,d=c&&!o&&s.browserWallet,m=se(t.buyerUsage.total)?"No current buyer rewards are available to stake yet.":o?t.buyerUsage.claimable?null:"These buyer rewards are not currently eligible for direct staking.":"Connect the authorized buyer wallet to stake these rewards.",x=V(o&&!se(t.buyerUsage.total)?"positions:current":null,q.positions),f=async()=>{l(!0),a(null);try{await $e("/api/wallet/authorize",{method:"POST"})}catch(y){a(y instanceof Error?y.message:String(y))}finally{l(!1)}};return e.jsxs(we,{className:"hero",children:[e.jsx("div",{className:"tile-label",children:"Buyer rewards"}),e.jsxs("p",{className:"hint",children:["Earned by buyer account ",e.jsx(K,{value:s.buyerAddress??s.address}),"."]}),e.jsxs("div",{className:"hero-value",children:[e.jsx(Pe,{children:C(i,4)}),e.jsx("span",{className:"unit",children:"ANTS"}),e.jsx(Ut,{})]}),se(i)?e.jsx("p",{className:"hero-sub muted",children:"Nothing to claim yet. Rewards accrue at each epoch boundary."}):null,c?o?null:e.jsxs("p",{className:"hint",children:["Connect the authorized wallet ",e.jsx(K,{value:c})," on ",s.chainId," to claim or stake."]}):e.jsx("p",{className:"hint",children:"Authorize a wallet to claim or stake this buyer’s rewards."}),o&&s.selectedAddress&&(c==null?void 0:c.toLowerCase())!==s.selectedAddress.toLowerCase()?e.jsxs("p",{className:"hint",children:["Buyer rewards and positions created by staking them belong to operator ",e.jsx(K,{value:c}),". Select that address to manage those positions."]}):null,h||d?e.jsxs("div",{className:"hero-actions",children:[h?e.jsx("button",{className:"btn",disabled:r,onClick:()=>void f(),children:r?"Opening…":"Authorize wallet ↗"}):null,d?e.jsx(or,{}):null]}):null,n?e.jsx("p",{role:"alert",className:"hint",children:n}):null,e.jsxs("div",{className:"buckets",children:[e.jsx(Ge,{visible:!0,name:"Current buyer rewards",amount:t.buyerUsage.total,note:"Earned from using AI services.",actions:e.jsxs(e.Fragment,{children:[e.jsx(Be,{bucket:"buyer",scope:"buyer",amount:t.buyerUsage.total,title:"Claim current buyer rewards",disabled:!o||!t.buyerUsage.claimable,reason:"Connect the authorized wallet and check buyer reward eligibility."}),m?e.jsx("span",{className:"btn-wrap",title:m,children:e.jsx(G,{variant:"outline",size:"sm",disabled:!0,children:"Stake rewards"})}):e.jsx(Ft,{kind:"buyer",data:t,maxEpochs:((j=x.data)==null?void 0:j.config.maxStakeEpochs)??null})]})}),e.jsx(Ge,{visible:!se(t.legacy.buyer),name:"Legacy buyer rewards",amount:t.legacy.buyer,note:"Earned from using AI services under the previous rewards system.",actions:e.jsx(Be,{bucket:"legacy",scope:"buyer",amount:t.legacy.buyer,title:"Claim legacy buyer rewards",disabled:!o||!t.legacy.buyerClaimable,reason:"Connect the authorized wallet for this buyer account."})})]})]})}function Rl({data:t,onRefresh:s}){var f,j,y;const n=Ie(),a=t.sellerUsage.claimable?t.sellerUsage.total:"0",r=t.legacy.seller,l=At([t.sellerUsage.total,t.legacy.seller,t.locked.claimable]),i=At([t.sellerUsage.claimable?"0":t.sellerUsage.total,t.legacy.seller,t.locked.claimable]),o=((f=V("positions:current",q.positions).data)==null?void 0:f.config.maxStakeEpochs)??null,h=se(l),d=t.legacy.sellerPayout,m=!!(d!=null&&d.recipient)&&d.destination!=="unknown",x=(d==null?void 0:d.destination)==="locked";return e.jsxs(e.Fragment,{children:[e.jsxs(we,{className:"hero","aria-label":"Staking rewards",children:[t.historySource==="chain"?e.jsx("p",{className:"status-line status-line--muted",children:"Closed-position history is unavailable. Without an indexer, some rewards may be missing. Refresh to retry."}):null,t.historySource==="local"?e.jsx("p",{className:"status-line status-line--muted",children:"Local transaction history included. Older closed positions—and their rewards—may be missing without an indexer."}):null,e.jsx("div",{className:"tile-label",children:"Staking rewards"}),e.jsxs("p",{className:"hint",children:["Unclaimed staking rewards for ",e.jsx(K,{value:n.address}),"—not your wallet balance."]}),e.jsxs("div",{className:"hero-value",children:[e.jsx(Pe,{children:C(t.staker.total,4)}),e.jsx("span",{className:"unit",children:"ANTS"}),e.jsx(Ut,{})]}),((j=t.staker.source)==null?void 0:j.indexedBlock)!==void 0?e.jsxs("p",{className:"hint",children:["Estimated by Antscan at block ",t.staker.source.indexedBlock,". Claims and restaking are checked live."]}):null,t.staker.total===null?e.jsxs("p",{role:"status",className:"hint",children:["Staking rewards unavailable: ",((y=t.staker.source)==null?void 0:y.error)??"Antscan has not finished indexing these rewards."," ",e.jsx("button",{className:"link-button",onClick:s,children:"Retry"})]}):se(t.staker.total)?e.jsx("p",{className:"hero-sub muted",children:"Nothing to claim yet. Rewards accrue at each epoch boundary."}):e.jsxs("div",{className:"hero-actions",children:[e.jsx(Be,{bucket:"staker",amount:t.staker.total}),e.jsx(Ft,{kind:"staker",data:t,maxEpochs:o})]})]}),!ae().pages.includes("seller")&&h&&se(t.locked.locked)?null:e.jsxs(we,{className:"hero","aria-label":"Seller rewards",children:[e.jsx("div",{className:"tile-label",children:"Seller rewards"}),e.jsxs("p",{className:"hint",children:["Unclaimed AI selling rewards for ",e.jsx(K,{value:n.address}),"—not your wallet balance."]}),e.jsxs("div",{className:"hero-value",children:[e.jsx(Pe,{children:C(l,4)}),e.jsx("span",{className:"unit",children:"ANTS"}),e.jsx(Ut,{})]}),h?null:e.jsxs("div",{className:"hero-sub",children:["Available to stake directly ",e.jsx("span",{className:"mono",children:e.jsx(Pe,{children:C(a,4)})})," · other rewards ",e.jsx("span",{className:"mono",children:e.jsx(Pe,{children:C(i,4)})})]}),h?e.jsx("div",{className:"hero-sub muted",children:"Nothing to claim yet. Rewards accrue at each epoch boundary."}):null,h&&se(t.locked.locked)?null:e.jsxs("div",{className:"buckets",children:[e.jsx(Ge,{visible:!se(t.sellerUsage.total),name:"Current seller rewards",note:"Earned from providing AI services.",amount:t.sellerUsage.total,actions:e.jsxs(e.Fragment,{children:[e.jsx(Be,{bucket:"seller",amount:t.sellerUsage.total,disabled:!t.sellerUsage.claimable,reason:"Seller usage rewards are not claimable from this wallet."}),e.jsx(Ft,{kind:"seller",data:t,maxEpochs:o})]})}),e.jsx(Ge,{visible:!se(t.legacy.seller),name:"Legacy seller rewards",note:"Earned from providing AI services under the previous rewards system.",amount:t.legacy.seller,actions:e.jsxs(e.Fragment,{children:[e.jsx(Be,{bucket:"legacy",amount:r,title:"Claim legacy seller rewards",label:m?x?"Claim not available yet":"Claim to wallet":"Claim unavailable",disabled:!m||x,reason:m&&x?"Claiming legacy seller rewards into the locked pool is currently unavailable in this dashboard.":"Payout destination could not be verified. Refresh rewards before claiming.",expectedLegacySellerRecipient:(d==null?void 0:d.recipient)??void 0}),m?null:e.jsx(G,{variant:"outline",size:"sm",onClick:s,children:"Refresh rewards"})]})}),e.jsx(Ge,{visible:!se(t.locked.claimable)||!se(t.locked.locked),name:"Locked seller rewards",note:"Past seller rewards held in the locked pool.",amount:t.locked.claimable,amountDetail:`${C(t.locked.locked,4)} ANTS locked`,actions:e.jsx(Be,{bucket:"locked",amount:t.locked.claimable,label:"Withdraw available amount",title:"Withdraw released seller rewards",disabled:!t.locked.policy,reason:t.locked.policy?se(t.locked.claimable)?"No rewards are currently released for withdrawal.":void 0:"M002 (unlock policy) is not installed."})})]})]})]})}function Ge({visible:t,name:s,note:n,amount:a,amountDetail:r,actions:l}){return t?e.jsxs("div",{className:"bucket",children:[e.jsxs("div",{className:"bucket-main",children:[e.jsx("div",{className:"bucket-name",children:s}),n?e.jsx("div",{className:"bucket-note",children:n}):null]}),e.jsxs("div",{className:`bucket-amount mono${r?" bucket-amount--detailed":""}`,children:[e.jsxs("span",{children:[e.jsx(Pe,{children:C(a,4)})," ",e.jsx("span",{className:"unit",children:"ANTS"})]}),r?e.jsx("span",{className:"bucket-amount-detail",children:e.jsx(Pe,{children:r})}):null]}),e.jsx("div",{className:"bucket-actions",children:l})]}):null}function Be({bucket:t,amount:s,label:n,title:a,disabled:r,reason:l,scope:i="wallet",expectedLegacySellerRecipient:c}){const{stale:o}=u.useContext(nt),h={buckets:[t],scope:i,...c?{expectedLegacySellerRecipient:c}:{}},d=se(s);return e.jsx(ge,{label:n??"Claim to wallet",size:"sm",title:a??(t==="staker"?"Claim staking rewards":"Claim current seller rewards"),path:"/api/rewards/claim",body:h,disabled:o||r||d,disabledReason:o?"Wait for rewards to refresh before another action.":l??(d?"Nothing to claim.":void 0)})}function Ml(t){var l;const s=he(),n=V("positions:current",q.positions),[a,r]=u.useState(t??1);return u.useEffect(()=>{t!==null&&r(t)},[t]),{epochs:a,setEpochs:r,positions:n,slider:e.jsx(es,{value:a,min:((l=n.data)==null?void 0:l.config.minStakeEpochs)??1,max:t??1,startEpoch:s&&n.data?s.current+n.data.config.stakeActivationDelay:null,onChange:r,disabled:t===null})}}function Ll({data:t,pools:s}){const n=new Map;for(const a of t.staker.positions){const r=J(a.amount)??0n;r>0n&&n.set(a.agentId,(n.get(a.agentId)??0n)+r)}return n.size===0?e.jsx(e.Fragment,{children:"Destination unavailable"}):e.jsx("div",{children:[...n].map(([a,r])=>{const l=s.find(i=>i.agentId===a);return e.jsxs("div",{children:[l?ot(l):`Seller pool #${a}`," · ",C(r.toString(),4)," ANTS"]},a)})})}function Ft({kind:t,data:s,maxEpochs:n}){var P;const{stale:a}=u.useContext(nt),{epochs:r,slider:l,positions:i}=Ml(n),c=V("pools",q.pools,5*6e4,Qt),[o,h]=u.useState(()=>s.sellerUsage.agentId?String(s.sellerUsage.agentId):""),d=((P=c.data)==null?void 0:P.pools)??[];u.useEffect(()=>{!o&&d[0]&&h(String(d[0].agentId))},[o,d]);const m=t==="staker"?s.staker.total:t==="seller"?s.sellerUsage.total:s.buyerUsage.total,x=t==="staker"?!0:t==="seller"?s.sellerUsage.claimable:s.buyerUsage.claimable,f=t==="staker"?"/api/rewards/restake":"/api/rewards/stake-usage",j=t==="staker"?{epochs:r}:{side:t,epochs:r,...t==="buyer"&&o?{stakeAgentId:Number(o)}:{}},y=d.find(T=>T.agentId===s.sellerUsage.agentId),E=t==="staker"?e.jsx(Ll,{data:s,pools:d}):y?ot(y):s.sellerUsage.agentId?`Seller pool #${s.sellerUsage.agentId}`:"Destination unavailable";return n===null&&x&&!se(m)?i.error&&!i.loading?e.jsx("span",{className:"btn-wrap",title:`Staking configuration could not be loaded: ${i.error}`,children:e.jsx(G,{variant:"outline",size:"sm",onClick:i.refresh,children:"Retry loading"})}):e.jsx(G,{variant:"outline",size:"sm",disabled:!0,"aria-busy":"true","aria-label":"Loading staking configuration",children:"Loading…"}):e.jsx(ge,{label:"Stake rewards",size:"sm",title:t==="staker"?"Stake position rewards":`Stake current ${t} rewards`,path:f,body:j,disabled:a||se(m)||!x||n===null,disabledReason:a?"Wait for rewards to refresh before another action.":x?"No rewards are available to stake.":`${t} usage rewards are not claimable from this wallet.`,validate:()=>n===null?"Pool configuration is still loading.":t==="buyer"&&!o?"Choose a pool to stake into.":null,summary:t==="buyer"?[["Amount",e.jsxs("span",{className:"mono",children:[C(m,4)," ANTS"]})]]:[["Amount",e.jsxs("span",{className:"mono",children:[C(m,4)," ANTS"]})],["Into",E],["Lock",e.jsxs("span",{className:"mono",children:[r," epochs"]})]],children:e.jsxs("div",{className:"stack mt",children:[l,t==="buyer"?e.jsx(Ue,{label:"Pool",width:"lg",hint:c.loading&&!c.data?"loading pools…":void 0,children:e.jsx(Fe,{value:o,onChange:T=>h(T.target.value),children:d.map(T=>{var A,N;return e.jsx("option",{value:T.agentId,children:((N=(A=T.profile)==null?void 0:A.name)==null?void 0:N.trim())||`Agent ID ${T.agentId}`},T.agentId)})})}):null]})})}function Bl(){const t=Ie(),s=/^0x0{40}$/i.test(t.address),n=V(s?null:`seller:${t.address.toLowerCase()}`,q.seller),a=n.data;return s?e.jsx(Z,{title:"Open your seller dashboard",children:e.jsxs("p",{className:"muted",children:["Open this dashboard with ",e.jsx("code",{children:"antseed ants --address 0x..."})," using your seller’s address, then connect that seller’s wallet."]})}):a?e.jsxs(e.Fragment,{children:[n.error&&a?e.jsxs("div",{className:"status-line",children:["Refresh failed: ",n.error]}):null,a.agentId===0?e.jsx(Z,{title:"Not registered as a seller",children:e.jsx("p",{className:"muted",children:"The connected wallet has no seller identity on this network. Switch to your seller wallet, or register this wallet below to create its identity and bind it in the seller registry."})}):null,e.jsx(Ul,{data:a}),e.jsx(Z,{title:"Wash-trading status",children:e.jsx(Tr,{})}),e.jsx(Z,{className:"panel-collapsible",children:e.jsx(de,{summary:"Advanced: submit a seller proof",children:e.jsxs("div",{className:"stack-lg",children:[e.jsx(Mr,{}),e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:"Proof status"}),e.jsx(Lr,{})]})]})})}),e.jsx(Z,{className:"panel-collapsible",children:e.jsx(de,{summary:"Look up another seller",children:e.jsx($r,{})})})]}):n.error?e.jsx(ne,{error:n.error,onRetry:n.refresh}):e.jsx(tt,{rows:6})}function Le({value:t}){return t===null?e.jsx("span",{className:"muted",children:"n/a"}):t?e.jsx(le,{tone:"accent",children:"yes"}):e.jsx(le,{tone:"muted",children:"no"})}function Ul({data:t}){const s=t.starter;return e.jsxs(e.Fragment,{children:[e.jsxs(Vt,{children:[e.jsx(me,{label:"Agent id",value:t.agentId||"—",sub:t.identityRegistered?"identity registered":"no ERC-8004 identity"}),e.jsx(me,{label:"Eligible",value:t.eligible?"yes":"no",sub:t.registryBound?"bound in seller registry":"not bound"}),e.jsx(me,{label:"Pool active stake",value:C(t.poolActiveStake),unit:"ANTS",sub:t.minPoolStake!==null?`min ${C(t.minPoolStake)} ANTS`:void 0})]}),e.jsxs(Z,{title:"Identity and registry",children:[e.jsx(X,{items:[["ERC-8004 identity",e.jsx(Le,{value:t.identityRegistered})],["Seller registry binding",e.jsx(Le,{value:t.registryBound})],["Legacy stake",`${ce(t.legacyStake)} USDC`],["Legacy eligibility path",e.jsx(Le,{value:t.legacyEligibilityEnabled})]]}),e.jsx("div",{className:"mt",children:e.jsx(Fl,{data:t})}),e.jsxs("div",{className:"hint mt",children:["CLI equivalent: ",e.jsx("code",{children:"antseed seller register"})]})]}),e.jsx(Z,{title:"Starter grant",actions:s?s.claimable?e.jsx(le,{tone:"accent",children:"claimable"}):s.expired?e.jsx(le,{tone:"muted",children:"expired"}):s.initialized?e.jsx(le,{tone:"amber",children:"initialized"}):e.jsx(le,{tone:"muted",children:"not initialized"}):null,children:s?e.jsxs(e.Fragment,{children:[e.jsx(X,{items:[["Grants remaining",W(s.remaining)],["Grant amount",`${C(s.amount,4)} ANTS`],["Claim window ends",e.jsx(st,{epoch:s.endEpoch})],["Legacy eligible",e.jsx(Le,{value:s.legacyEligible})]]}),e.jsx("div",{className:"mt",children:e.jsx(ge,{label:s.initialized?"Grant already claimed":"Claim starter",variant:"primary",title:"Claim starter grant",path:"/api/seller/claim-starter",body:{},disabled:s.initialized||!s.claimable,disabledReason:s.initialized?"This starter grant has already been claimed.":s.expired?"The starter grant window has expired.":"The starter grant is not claimable for this wallet."})}),e.jsxs(de,{summary:"Details",className:"mt",children:[e.jsx(X,{items:[["Contract",s.contract?e.jsx(K,{value:s.contract,short:!1}):"—"],["Initialized",e.jsx(Le,{value:s.initialized})],["Expired",e.jsx(Le,{value:s.expired})]]}),e.jsxs("div",{className:"hint mt",children:["CLI equivalent: ",e.jsx("code",{children:"antseed seller legacy claim-starter"})]})]})]}):e.jsx("span",{className:"muted",children:"No starter grant contract on this chain."})})]})}function Fl({data:t}){const[s,n]=u.useState(t.agentId>0?String(t.agentId):""),a=s.trim()?{agentId:Number(s)}:{};return e.jsxs("div",{className:"form-row",children:[e.jsx(qe,{label:"Agent id (optional)",hint:"Use an existing ID, or leave empty to create an identity if this wallet has none.",width:"md",inputMode:"numeric",value:s,onChange:r=>n(r.target.value)}),e.jsx(ge,{label:t.registryBound?"Re-register binding":"Register binding",variant:"primary",title:"Register seller binding",path:"/api/seller/register",body:a,validate:()=>s.trim()&&!Da(s)?"Agent id must be a positive integer.":null}),e.jsx("p",{className:"hint mt",children:"Binds this wallet to its agent id in the seller registry. Without an id, it reuses a known identity or creates one if this wallet has none. Creating and binding can require separate transactions."})]})}function Dl(){var L,D,S,g,w,p,I,_,$;const t=Ie(),s=!t.browserWallet||!t.readOnly,n=V("overview",q.overview),a=V(s?"positions:current":null,q.positions),r=V("rewards",q.rewards,5*6e4),l=V("pools",q.pools,5*6e4,Qt),i=n.data,c=(L=r.data)==null?void 0:L.buyerUsage.operator,o=s&&!!c&&c.toLowerCase()!==t.address.toLowerCase()&&BigInt(((D=r.data)==null?void 0:D.buyerUsage.total)??"0")>0n,h=(i==null?void 0:i.notices.filter(M=>!M.startsWith("ANTS transfers are not enabled")))??[],[d,m]=u.useState(void 0),[x,f]=u.useState(!1),j=u.useRef(null),[y,E]=u.useState(null),P=u.useRef(null),T=()=>{E(null),requestAnimationFrame(()=>{var M;(M=P.current)!=null&&M.isConnected&&P.current.focus({preventScroll:!0})})},A=u.useMemo(()=>{var M;return cn(((M=l.data)==null?void 0:M.pools)??[])},[l.data]),N=u.useRef(null),U=y!==null?A.find(M=>M.agentId===y):void 0;U&&l.data&&(N.current={pool:U,view:l.data});const k=y!==null&&((S=N.current)==null?void 0:S.pool.agentId)===y?N.current:null,B=M=>{P.current=document.activeElement instanceof HTMLElement?document.activeElement:null,E(M.agentId)},b=()=>{m(void 0),requestAnimationFrame(()=>{var O;const M=j.current;M!=null&&M.isConnected?M.focus({preventScroll:!0}):(O=document.querySelector("[data-stake-trigger]"))==null||O.focus({preventScroll:!0})})},v={config:((g=a.data)==null?void 0:g.config)??null,balance:i==null?void 0:i.wallet.ants,rewards:r.data,rewardsError:r.error,walletReady:s};return e.jsxs(e.Fragment,{children:[t.browserWallet&&o?e.jsxs(Qe,{tone:"info",title:"Connect your authorized wallet",children:["To stake buyer rewards, use the wallet button above to switch to ",e.jsx("span",{className:"mono",title:c,children:ut(c)}),", the authorized wallet for your buyer account."]}):null,n.error&&!i?e.jsx(ne,{error:n.error,onRetry:n.refresh}):null,n.error&&i?e.jsxs("div",{className:"status-line",children:["Refresh failed: ",n.error]}):null,i&&i.phase!=="active"?e.jsx(_l,{data:i}):null,h.length>0?e.jsx(Qe,{tone:"info",children:e.jsx("ul",{className:"notices-list",children:h.map((M,O)=>e.jsx("li",{children:M},O))})}):null,l.data?e.jsx(Wl,{view:l.data}):null,e.jsxs(Z,{title:"Sellers",className:"pools-card",actions:e.jsx(G,{"data-stake-trigger":!0,variant:"primary",size:"sm",onClick:M=>{j.current=M.currentTarget,m(null)},disabled:!l.data,children:"Stake rewards"}),children:[l.error&&!l.data?e.jsx(ne,{error:l.error,onRetry:l.refresh}):null,l.loading?e.jsx("p",{className:"hint",role:"status",children:l.data?"Updating sellers… Showing previously loaded data.":"Loading sellers…"}):null,!l.loading&&l.reconciling?e.jsx("p",{className:"hint",role:"status",children:"Updating your stake… Waiting for Antscan to include your latest transaction."}):null,!l.loading&&(l.partial||l.error&&l.data)?e.jsxs("div",{className:l.error?"status-line":"status-line status-line--muted",role:"status",children:[l.error?`Could not update sellers: ${l.error}. `:"Could not load the full seller list. ",l.error||((w=l.data)==null?void 0:w.source)==="indexer"?"Showing previously loaded data; statistics may be out of date.":"Only pools you stake in are shown, read live from the chain."," ",e.jsx(G,{variant:"outline",size:"sm",onClick:l.refresh,children:"Try again"})]}):null,!l.loading&&((p=l.data)==null?void 0:p.source)==="chain"&&!l.partial&&!l.error?e.jsx("div",{className:"status-line status-line--muted",children:"No explorer configured. Only pools you stake in are listed, read live from the chain."}):null,!l.loading&&((I=l.data)==null?void 0:I.source)==="chain"&&A.length===0?l.reconciling?null:e.jsx("p",{className:"hint",children:"You have no staked pools to show."}):l.data||l.loading?e.jsx(ol,{pools:A,currentEpoch:((_=l.data)==null?void 0:_.currentEpoch)??0,loading:l.loading&&!l.data,walletSyncing:l.reconciling,onOpen:B,onStake:B}):null]}),d!==void 0&&l.data?e.jsxs(Dt,{isOpen:!0,title:"Stake rewards",size:"lg",overlayClassName:"ants-stake-overlay",onClose:()=>{x||b()},children:[a.error&&!a.data?e.jsx(ne,{error:a.error,onRetry:a.refresh}):null,e.jsx(on,{config:(($=a.data)==null?void 0:$.config)??null,pools:A.filter(M=>M.stakeable),balance:i==null?void 0:i.wallet.ants,rewards:r.data,rewardsError:r.error,defaultAgentId:d,onStarted:b,onClose:b,onBusyChange:f},`${t.address}:${t.evmChainId}:${d??"any"}`)]}):null,k?e.jsx(cl,{pool:k.pool,view:k.view,onClose:T,stake:v}):null]})}function Wl({view:t}){const s=t.networkVolumes.find(a=>a.epoch===t.currentEpoch-1),n=t.pools.filter(a=>a.stakeable).length;return e.jsxs("div",{className:"ticker",role:"list","aria-label":"Network",children:[e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Total staked"}),e.jsxs("span",{className:"ticker-value",children:[C(t.totalActiveStake),e.jsx("small",{children:"ANTS"})]})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Total power"}),e.jsx("span",{className:"ticker-value",children:C(t.totalPowerWeight)})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Staker budget · epoch"}),e.jsxs("span",{className:"ticker-value",children:[C(t.stakerBudget),e.jsx("small",{children:"ANTS"})]})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Network volume · last epoch"}),e.jsxs("span",{className:"ticker-value",children:[s?We(s.usdc):"—",e.jsx("small",{children:"USDC"})]})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Sellers"}),e.jsxs("span",{className:"ticker-value",children:[W(n),e.jsx("small",{children:"stakeable"})]})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Epoch"}),e.jsxs("span",{className:"ticker-value",children:[t.currentEpoch,e.jsx("small",{children:t.source==="indexer"?"indexed":"chain"})]})]})]})}function _l({data:t}){const s=pt(1e3),{phase:n,epoch:a}=t;if(n==="legacy")return e.jsx(Qe,{tone:"info",title:"Legacy protocol",children:"The recognized-usage stack (M001) is not deployed on this chain. Pool staking, usage rewards and emissions views are unavailable."});if(n==="deployed"&&a.effective!==null){const r=De(a.effective,a.genesis,a.epochDuration),l=Math.max(0,Math.floor(r-s/1e3));return e.jsxs(Qe,{tone:"warning",title:"Deployed, not active yet",children:["Recognized usage activates at epoch ",e.jsx("span",{className:"mono",children:a.effective})," (",ue(r),") — in ",e.jsx("span",{className:"mono",children:ht(l)}),". Positions staked now become active from the effective epoch."]})}return null}const Ol=6e4;function zl({theme:t,toggleTheme:s}){const n=V("config",q.config,Number.POSITIVE_INFINITY),a=V("overview",q.overview),r=Ya(),l=a.refresh;u.useEffect(()=>{const c=window.setInterval(()=>{document.visibilityState==="visible"&&l()},Ol);return()=>window.clearInterval(c)},[l]);const i=u.useMemo(()=>n.data?{config:n.data,overview:a.data,overviewError:a.error,theme:t,toggleTheme:s}:null,[n.data,a.data,a.error,t,s]);return i?e.jsx(ir,{config:i.config,children:e.jsx(Js.Provider,{value:i,children:e.jsx(er,{children:e.jsx(xr,{page:r.page,updatedAt:a.updatedAt,loading:a.loading,children:e.jsx(ql,{page:r.page})})})})}):e.jsx("div",{className:"full-page",children:e.jsx(we,{className:"full-page-inner",children:n.error?e.jsx(ne,{error:n.error,onRetry:n.refresh,title:"Could not load dashboard config"}):e.jsx("span",{className:"muted",children:"Connecting to the local server…"})})})}function ql({page:t}){switch(t){case"positions":return e.jsx(Tl,{});case"rewards":return e.jsx($l,{});case"seller":return e.jsx(Bl,{});case"network":return e.jsx(Br,{});case"addresses":return e.jsx(yr,{});case"stake":default:return e.jsx(Dl,{})}}const Yl=()=>{};function Vl({host:t,theme:s}){const n=u.useRef(null),[a,r]=u.useState(!1);return u.useEffect(()=>{Ra({...t,embedded:!0,portalTarget:()=>n.current??document.body}),lt({clear:!0}),r(!0)},[]),e.jsxs("div",{className:"ants-embed",children:[a&&e.jsx(zl,{theme:s,toggleTheme:Yl}),e.jsx("div",{ref:n})]})}const fn="staking";function ys(t){return t==="rewards"||t.startsWith("rewards/")||t.startsWith("rewards?")?"rewards":`${fn}/${t}`}function Hl(){const t=St(fn),{pathname:s,search:n}=window.location;return`${s.startsWith(`${t}/`)?s.slice(t.length+1):""}${n}`}const ks=()=>{};function Kl({pages:t,buyerRewards:s}){const{workspace:n}=Sn(),a=Cn(),r=t.length>1,l=u.useMemo(()=>({apiUrl:c=>`${En}/workspaces/${encodeURIComponent(n.id)}/ants/${c.replace(/^\/api\//,"")}`,headers:()=>({[In]:"1"}),href:c=>St(ys(c)),currentPath:r?Hl:()=>t[0]??"",replace:r?c=>os(ys(c),{replace:!0}):ks,subscribe:r?An:()=>ks,pages:t,buyerRewards:s}),[n.id,t,s,r]),i=c=>{if(c.defaultPrevented||c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||c.altKey)return;const o=c.target.closest("a"),h=o==null?void 0:o.getAttribute("href"),d=St("");!o||o.target||!(h!=null&&h.startsWith(d))||(c.preventDefault(),os(h.slice(d.length)))};return e.jsx("div",{onClick:i,children:e.jsx(ca,{chain:a.data,error:a.error,children:c=>e.jsx(ra,{chain:c,children:e.jsx(Vl,{host:l,theme:Tn()?"dark":"light"},n.id)})})})}const ai=Object.freeze(Object.defineProperty({__proto__:null,StakingDashboard:Kl},Symbol.toStringTag,{value:"Module"}));export{Ia as N,Ds as P,Kl as S,ni as a,ai as b};
|
|
1
|
+
var wn=Object.defineProperty;var vn=(t,s,n)=>s in t?wn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Ve=(t,s,n)=>vn(t,typeof s!="symbol"?s+"":s,n);import{F as yn,r as u,j as e,co as kn,cp as Nn,b_ as Ns,C as Dt,u as Sn,H as Cn,cq as An,cr as En,y as os,bN as St,cs as In,ct as Tn}from"./index-DPXW_JSn.js";import{K as ct,ad as $n,ae as Pn,p as et,af as Rn,g as Te,A as dt,i as Ss,j as Mn,B as Ln,k as Wt,l as Cs,m as cs,n as Bn,L as Un,a7 as Fn,ag as Dn,o as As,q as Wn,ah as Es,t as at,v as _n,ai as On,aj as zn,ak as qn,al as Yn,s as Vn,am as Hn,a4 as Kn,Z as Jn,c as Gn,u as _t,_ as Qn,$ as Zn,an as Xn,ao as ea,ap as ta,aq as sa,ar as na,as as aa,C as Is,W as ra}from"./en_US-Y4ZOVFV4-Bkc-z49M.js";import{A as la,a as ia}from"./index-BhwNCc8y.js";import{s as Ts,a as $s}from"./sendTransaction-k8aDYfd4.js";import{s as Ps,w as Rs,p as Ms,g as oa}from"./waitForCallsStatus-C51Vv8Tt.js";import{w as Ls}from"./writeContract-CaMlmKcK.js";import{C as ca}from"./ChainGate-Do1wYOPQ.js";async function da(t,{chain:s}){const{id:n,name:a,nativeCurrency:r,rpcUrls:l,blockExplorers:i}=s;await t.request({method:"wallet_addEthereumChain",params:[{chainId:ct(n),chainName:a,nativeCurrency:r,rpcUrls:l.default.http,blockExplorerUrls:i?Object.values(i).map(({url:c})=>c):void 0}]},{dedupe:!0,retryCount:0})}function ua(t,s){const{abi:n,args:a,bytecode:r,...l}=s,i=$n({abi:n,args:a,bytecode:r});return Ts(t,{...l,...l.authorizationList?{to:null}:{},data:i})}async function ha(t){var n;return((n=t.account)==null?void 0:n.type)==="local"?[t.account.address]:(await t.request({method:"eth_accounts"},{dedupe:!0})).map(a=>Pn(a))}async function ma(t,s={}){const{account:n=t.account,chainId:a}=s,r=n?et(n):void 0,l=a?[r==null?void 0:r.address,[ct(a)]]:[r==null?void 0:r.address],i=await t.request({method:"wallet_getCapabilities",params:l}),c={};for(const[o,h]of Object.entries(i)){c[Number(o)]={};for(let[d,m]of Object.entries(h))d==="addSubAccount"&&(d="unstable_addSubAccount"),c[Number(o)][d]=m}return typeof a=="number"?c[a]:c}async function pa(t){return await t.request({method:"wallet_getPermissions"},{dedupe:!0})}async function xa(t){return(await t.request({method:"eth_requestAccounts"},{dedupe:!0,retryCount:0})).map(n=>Rn(n))}async function fa(t,s){return t.request({method:"wallet_requestPermissions",params:[s]},{retryCount:0})}async function ga(t,s){const{chain:n=t.chain}=s,a=s.timeout??Math.max(((n==null?void 0:n.blockTime)??0)*3,5e3),r=await Te(t,Ps,"sendCalls")(s);return await Te(t,Rs,"waitForCallsStatus")({...s,id:r.id,timeout:a})}const bt=new Un(128);async function Bs(t,s){var B,b,v,L,D;const{account:n=t.account,assertChainId:a=!0,chain:r=t.chain,accessList:l,authorizationList:i,blobs:c,data:o,dataSuffix:h=typeof t.dataSuffix=="string"?t.dataSuffix:(B=t.dataSuffix)==null?void 0:B.value,gas:d,gasPrice:m,maxFeePerBlobGas:x,maxFeePerGas:f,maxPriorityFeePerGas:j,nonce:y,pollingInterval:E,throwOnReceiptRevert:P,type:T,value:A,...N}=s,U=s.timeout??Math.max(((r==null?void 0:r.blockTime)??0)*3,5e3);if(typeof n>"u")throw new dt({docsPath:"/docs/actions/wallet/sendTransactionSync"});const k=n?et(n):null;try{Ss(s);const S=await(async()=>{if(s.to)return s.to;if(s.to!==null&&i&&i.length>0)return await Mn({authorization:i[0]}).catch(()=>{throw new Ln("`to` is required. Could not infer from `authorizationList`.")})})();if((k==null?void 0:k.type)==="json-rpc"||k===null){let g;r!==null&&(g=await Te(t,Wt,"getChainId")({}),a&&$s({currentChainId:g,chain:r}));const w=(L=(v=(b=t.chain)==null?void 0:b.formatters)==null?void 0:v.transactionRequest)==null?void 0:L.format,I=(w||Cs)({...Bn(N,{format:w}),accessList:l,account:k,authorizationList:i,blobs:c,chainId:g,data:o&&cs([o,h??"0x"]),gas:d,gasPrice:m,maxFeePerBlobGas:x,maxFeePerGas:f,maxPriorityFeePerGas:j,nonce:y,to:S,type:T,value:A},"sendTransaction"),_=bt.get(t.uid),$=_?"wallet_sendTransaction":"eth_sendTransaction",M=await(async()=>{try{return await t.request({method:$,params:[I]},{retryCount:0})}catch(H){if(_===!1)throw H;const Y=H;if(Y.name==="InvalidInputRpcError"||Y.name==="InvalidParamsRpcError"||Y.name==="MethodNotFoundRpcError"||Y.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[I]},{retryCount:0}).then(ee=>(bt.set(t.uid,!0),ee)).catch(ee=>{const pe=ee;throw pe.name==="MethodNotFoundRpcError"||pe.name==="MethodNotSupportedRpcError"?(bt.set(t.uid,!1),Y):pe});throw Y}})(),O=await Te(t,Fn,"waitForTransactionReceipt")({checkReplacement:!1,hash:M,pollingInterval:E,timeout:U});if(P&&O.status==="reverted")throw new Dn({receipt:O});return O}if((k==null?void 0:k.type)==="local"){const g=await Te(t,As,"prepareTransactionRequest")({account:k,accessList:l,authorizationList:i,blobs:c,chain:r,data:o&&cs([o,h??"0x"]),gas:d,gasPrice:m,maxFeePerBlobGas:x,maxFeePerGas:f,maxPriorityFeePerGas:j,nonce:y,nonceManager:k.nonceManager,parameters:[...Wn,"sidecars"],type:T,value:A,...N,to:S}),w=(D=r==null?void 0:r.serializers)==null?void 0:D.transaction,p=await k.signTransaction(g,{serializer:w});return await Te(t,Es,"sendRawTransactionSync")({serializedTransaction:p,throwOnReceiptRevert:P,timeout:s.timeout})}throw(k==null?void 0:k.type)==="smart"?new at({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new at({docsPath:"/docs/actions/wallet/sendTransactionSync",type:k==null?void 0:k.type})}catch(S){throw S instanceof at?S:_n(S,{...s,account:k,chain:s.chain||void 0})}}async function ba(t,s){const{id:n}=s;await t.request({method:"wallet_showCallsStatus",params:[n]})}async function ja(t,s){const{account:n=t.account}=s;if(!n)throw new dt({docsPath:"/docs/eip7702/signAuthorization"});const a=et(n);if(!a.signAuthorization)throw new at({docsPath:"/docs/eip7702/signAuthorization",metaMessages:["The `signAuthorization` Action does not support JSON-RPC Accounts."],type:a.type});const r=await Ms(t,s);return a.signAuthorization(r)}async function wa(t,s){var h,d,m,x;const{account:n=t.account,chain:a=t.chain,...r}=s;if(!n)throw new dt({docsPath:"/docs/actions/wallet/signTransaction"});const l=et(n);Ss({account:l,...s});const i=await Te(t,Wt,"getChainId")({});a!==null&&$s({currentChainId:i,chain:a});const c=(a==null?void 0:a.formatters)||((h=t.chain)==null?void 0:h.formatters),o=((d=c==null?void 0:c.transactionRequest)==null?void 0:d.format)||Cs;return l.signTransaction?l.signTransaction({...r,chainId:i},{serializer:(x=(m=t.chain)==null?void 0:m.serializers)==null?void 0:x.transaction}):await t.request({method:"eth_signTransaction",params:[{...o({...r,account:l},"signTransaction"),chainId:ct(i),from:l.address}]},{retryCount:0})}async function va(t,s){const{account:n=t.account,domain:a,message:r,primaryType:l}=s;if(!n)throw new dt({docsPath:"/docs/actions/wallet/signTypedData"});const i=et(n),c={EIP712Domain:On({domain:a}),...s.types};if(zn({domain:a,message:r,primaryType:l,types:c}),i.signTypedData)return i.signTypedData({domain:a,message:r,primaryType:l,types:c});const o=qn({domain:a,message:r,primaryType:l,types:c});return t.request({method:"eth_signTypedData_v4",params:[i.address,o]},{retryCount:0})}async function ya(t,{id:s}){await t.request({method:"wallet_switchEthereumChain",params:[{chainId:ct(s)}]},{retryCount:0})}async function ka(t,s){return await t.request({method:"wallet_watchAsset",params:s},{retryCount:0})}async function Na(t,s){return Ls.internal(t,Bs,"sendTransactionSync",s)}function Sa(t){return{addChain:s=>da(t,s),deployContract:s=>ua(t,s),fillTransaction:s=>Hn(t,s),getAddresses:()=>ha(t),getCallsStatus:s=>oa(t,s),getCapabilities:s=>ma(t,s),getChainId:()=>Wt(t),getPermissions:()=>pa(t),prepareAuthorization:s=>Ms(t,s),prepareTransactionRequest:s=>As(t,s),requestAddresses:()=>xa(t),requestPermissions:s=>fa(t,s),sendCalls:s=>Ps(t,s),sendCallsSync:s=>ga(t,s),sendRawTransaction:s=>Vn(t,s),sendRawTransactionSync:s=>Es(t,s),sendTransaction:s=>Ts(t,s),sendTransactionSync:s=>Bs(t,s),showCallsStatus:s=>ba(t,s),signAuthorization:s=>ja(t,s),signMessage:s=>Yn(t,s),signTransaction:s=>wa(t,s),signTypedData:s=>va(t,s),switchChain:s=>ya(t,s),waitForCallsStatus:s=>Rs(t,s),watchAsset:s=>ka(t,s),writeContract:s=>Ls(t,s),writeContractSync:s=>Na(t,s)}}async function Ca(t,s={}){return(await Kn(t,s)).extend(Sa)}function Aa(t,s={}){return{gcTime:0,async queryFn({queryKey:n}){const{connector:a}=s,{connectorUid:r,scopeKey:l,...i}=n[1];return Ca(t,{...i,connector:a})},queryKey:Ea(s)}}function Ea(t={}){const{connector:s,...n}=t;return["walletClient",{...Jn(n),connectorUid:s==null?void 0:s.uid}]}function Us(t={}){const{query:s={},...n}=t,a=Gn(n),r=yn(),{address:l,connector:i,status:c}=_t({config:a}),o=Qn({config:a}),h=t.connector??i,{queryKey:d,...m}=Aa(a,{...t,chainId:t.chainId??o,connector:t.connector??i}),x=!!((c==="connected"||c==="reconnecting"&&(h!=null&&h.getProvider))&&(s.enabled??!0)),f=u.useRef(l);return u.useEffect(()=>{const j=f.current;!l&&j?(r.removeQueries({queryKey:d}),f.current=void 0):l!==j&&(r.invalidateQueries({queryKey:d}),f.current=l)},[l,r]),Zn({...s,...m,queryKey:d,enabled:x,staleTime:Number.POSITIVE_INFINITY})}class Fs extends Error{constructor(s="Waiting for Antscan to catch up with your transaction"){super(s),this.name="IndexerSyncingError"}}const Ia=[{label:"Market",items:[{id:"stake",label:"Sellers"}]},{label:"You",items:[{id:"positions",label:"My positions"},{id:"rewards",label:"Rewards"},{id:"seller",label:"Seller"}]},{label:"Protocol",items:[{id:"network",label:"Network"},{id:"addresses",label:"Addresses"}]}],Ds=["stake","positions","rewards","seller","network","addresses"],ni={stake:"staking",positions:"staking",rewards:"rewards",seller:"seller",network:"protocol",addresses:"protocol"},Ta="ants.dashboard.token";function $a(){try{return window.sessionStorage.getItem(Ta)}catch{return null}}const Pa={embedded:!1,apiUrl:t=>t,headers:()=>({Authorization:`Bearer ${$a()??""}`}),href:t=>`#/${t}`,currentPath:()=>window.location.hash.replace(/^#\/?/,""),replace:t=>window.history.replaceState(null,"",`#/${t}`),subscribe:t=>(window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)),portalTarget:()=>document.body,pages:Ds,buyerRewards:!0};let Ws=Pa;function ae(){return Ws}function Ra(t){Ws=t}class Ne extends Error{constructor(n,a){super(n);Ve(this,"status");this.name="ApiError",this.status=a}}const Ma=new Set;async function $e(t,s){const n={...ae().headers()};let a;(s==null?void 0:s.body)!==void 0&&(n["Content-Type"]="application/json",a=JSON.stringify(s.body));let r;try{r=await fetch(ae().apiUrl(t),{method:(s==null?void 0:s.method)??"GET",headers:n,body:a})}catch(i){throw new Ne(`Network error: ${i instanceof Error?i.message:String(i)}`,0)}if(r.status===401){for(const i of Ma)i();throw new Ne("Unauthorized",401)}let l=null;try{l=await r.json()}catch{l=null}if(!l||typeof l!="object")throw new Ne(`HTTP ${r.status}`,r.status);if(!l.ok)throw"state"in l&&l.state==="syncing"?new Fs:new Ne("error"in l&&l.error||`HTTP ${r.status}`,r.status);return l.data}function te(t){return $e(t)}function ds(t,s){return $e(t,{method:"POST",body:s})}const q={config:()=>te("/api/config"),overview:()=>te("/api/overview"),positions:()=>te("/api/positions"),rewards:()=>te("/api/rewards"),pools:()=>te("/api/pools"),sellerModels:async t=>{try{const s=await te(`/api/sellers/${encodeURIComponent(t)}/models`);if(!s||!("period"in s)||!("totals"in s))throw new Ne("The running dashboard server still uses sampled model data. Restart the updated desktop or dashboard process to load last-epoch totals.",502);return s}catch(s){throw s instanceof Ne&&s.status===404?new Ne("The running dashboard server does not have the model-data endpoint (HTTP 404). Restart the updated desktop or dashboard process, then reopen staking.",404):s}},pool:t=>te(`/api/pools/${t}`),usage:t=>te(`/api/usage?epochs=${t}`),emissions:()=>te("/api/emissions"),network:()=>te("/api/network"),networkLegacy:()=>te("/api/network/legacy"),verification:t=>te(`/api/verification${t?`?seller=${encodeURIComponent(t)}`:""}`),proofStatus:t=>te(`/api/verification/proofs/${encodeURIComponent(t)}`),seller:()=>te("/api/seller"),jobs:()=>te("/api/jobs"),job:t=>te(`/api/jobs/${encodeURIComponent(t)}`),withdrawPreview:t=>ds("/api/positions/withdraw/preview",{positionIds:t}),startJob:(t,s)=>ds(t,s)};function Ct(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}function J(t){if(t==null||t==="")return null;try{return BigInt(t)}catch{return null}}function _s(t,s,n=2){const a=typeof t=="bigint"?t:J(t);if(a===null)return"—";const r=a<0n,l=r?-a:a,i=10n**BigInt(s),c=l/i,o=l%i;let h="";if(n>0&&s>0&&(h=o.toString().padStart(s,"0").slice(0,n).replace(/0+$/,"")),l>0n&&c===0n&&h===""){const d=n===0?"1":`0.${"0".repeat(n-1)}1`;return`${r?"-":""}<${d}`}return`${r?"-":""}${Ct(c.toString())}${h?`.${h}`:""}`}function C(t,s=2){return _s(t,18,s)}function ce(t,s=2){return _s(t,6,s)}function W(t){if(typeof t=="number")return Number.isFinite(t)?Ct(Math.trunc(t).toString()):"—";const s=typeof t=="bigint"?t:J(t);if(s===null)return"—";const n=s<0n;return`${n?"-":""}${Ct((n?-s:s).toString())}`}function ie(t){return t==null||!Number.isFinite(t)?"—":`${(t/100).toFixed(2)}%`}function se(t){const s=J(t);return s===null||s===0n}function jt(t,s){const n=J(t)??0n,a=J(s)??0n;return n<a?-1:n>a?1:0}function At(t){return t.reduce((s,n)=>s+(J(n)??0n),0n).toString()}function ut(t){return t.length<=13?t:`${t.slice(0,6)}…${t.slice(-4)}`}function Et(t){return t.length<=18?t:`${t.slice(0,10)}…${t.slice(-6)}`}function La(t){return/^0x[0-9a-fA-F]{40}$/.test(t)}function ue(t){return Number.isFinite(t)?`${new Date(t*1e3).toISOString().slice(0,16).replace("T"," ")} UTC`:"—"}function rt(t){return Number.isFinite(t)?new Date(t*1e3).toISOString().slice(0,10):"—"}function De(t,s,n){return s+t*n}function ht(t){const s=Math.max(0,Math.floor(t)),n=Math.floor(s/86400),a=Math.floor(s%86400/3600),r=Math.floor(s%3600/60),l=s%60,i=c=>c.toString().padStart(2,"0");return`${n}d ${i(a)}:${i(r)}:${i(l)}`}function Os(t){return t%86400===0?`${t/86400} days`:t%3600===0?`${t/3600} hours`:`${W(t)} s`}function Ot(t){return t===8453?"https://basescan.org":t===84532?"https://sepolia.basescan.org":null}function Ba(t){return Ot(t)?"Basescan":null}function Ua(t,s=Date.now()){const n=Math.max(0,Math.round((s-t)/1e3));if(n<5)return"just now";if(n<60)return`${n}s ago`;const a=Math.floor(n/60);if(a<60)return`${a}m ago`;const r=Math.floor(a/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function zs(t,s){const n=Ot(t);return n?`${n}/tx/${s}`:null}function Fa(t,s){const n=Ot(t);return n?`${n}/address/${s}`:null}function Je(t){return/^\d+(\.\d+)?$/.test(t.trim())?/[1-9]/.test(t):!1}function Da(t){return/^\d+$/.test(t.trim())&&Number(t)>0}function It(t,s){const n=/^(\d+)(?:\.(\d+))?$/.exec(t.trim());if(!n)return null;const a=n[1]??"0",r=(n[2]??"").slice(0,s).padEnd(s,"0");try{return BigInt(a)*10n**BigInt(s)+BigInt(r||"0")}catch{return null}}function Ce(t){return t instanceof Error?t.message:String(t)}function us(t,s){return t==null||!Number.isFinite(t)||!s?"—":`${(t*100/s).toFixed(2)}%`}function We(t){const s=typeof t=="bigint"?t:J(t);if(s===null)return"—";const n=s<0n,a=(n?-s:s)/10000n,r=Number(a)/100,l=n?"-":"";return r>=1e6?`${l}$${(r/1e6).toFixed(r>=1e7?0:1)}M`:r>=1e3?`${l}$${(r/1e3).toFixed(r>=1e4?0:1)}k`:r>=100?`${l}$${r.toFixed(0)}`:`${l}$${r.toFixed(2)}`}const Wa=3e3;let He=0;const ke=new Map,Ke=new Map,Tt=new Set;function lt({clear:t=!1,confirmed:s=!1}={}){if(He++,Ke.clear(),t)ke.clear();else for(const n of ke.values())n.at=0,n.reconciling||(n.reconciling=s);for(const n of Tt)n(t,s)}function _a(t,s=document,n=window){let a=!1;const r=()=>{a||s.visibilityState!=="visible"||(a=!0,t())},l=n.setTimeout(r,Wa);return s.addEventListener("visibilitychange",r),()=>{a=!0,n.clearTimeout(l),s.removeEventListener("visibilitychange",r)}}function ye(t){const s=t!==null?ke.get(t):void 0;return s?{key:t,data:s.data,error:null,loading:!1,reconciling:s.reconciling??!1,partial:s.partial??!1,updatedAt:s.at}:{key:t,data:null,error:null,loading:t!==null,reconciling:!1,partial:!1,updatedAt:null}}function V(t,s,n=6e4,a={}){const[r,l]=u.useState(()=>ye(t)),i=u.useRef(s);i.current=s;const c=u.useRef(a);c.current=a;const o=u.useRef(t);o.current=t;const h=u.useRef(!0),d=u.useRef(0);u.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const m=u.useCallback((y,E=!1)=>{const P=He;l(A=>{const N=A.key===y?A:ye(y);return{...N,loading:!0,error:null,reconciling:E||N.reconciling}});let T=Ke.get(y);if(!T){const A=i.current();T=A,Ke.set(y,A),A.then(N=>{var b,v,L,D,S,g;if(P!==He)return;const U=((v=(b=c.current).isPartial)==null?void 0:v.call(b,N))??!1,k=ke.get(y);if((D=(L=c.current).isSyncing)!=null&&D.call(L,N)){const w=k&&!c.current.isSyncing(k.data);ke.set(y,{data:w?k.data:N,at:0,partial:w?k.partial:U,reconciling:!0});return}const B=U&&k&&!((g=(S=c.current).isPartial)!=null&&g.call(S,k.data));ke.set(y,{data:B?k.data:N,at:B?k.at:Date.now(),partial:U})}).catch(()=>{}).finally(()=>{Ke.get(y)===A&&Ke.delete(y)})}T.then(()=>{!h.current||o.current!==y||P!==He||l(ye(y))},A=>{if(!h.current||o.current!==y||P!==He)return;const N=A instanceof Fs,U=ke.get(y);N&&U&&(U.at=0,U.reconciling=!0),l(k=>{const B=k.key===y?k:ye(y);return{...B,key:y,loading:!1,reconciling:N||B.reconciling,error:N?null:Ce(A)}})})},[]);u.useEffect(()=>{if(t===null){l(ye(null));return}const y=ke.get(t);y&&(l(ye(t)),!y.partial&&Date.now()-y.at<n)||m(t)},[t,m,n]),u.useEffect(()=>{const y=(E,P)=>{o.current!==null&&(E&&o.current!=="config"&&l(ye(o.current)),m(o.current,P&&!E))};return Tt.add(y),()=>{Tt.delete(y)}},[m]);const x=u.useCallback(()=>{o.current!==null&&m(o.current)},[m]);u.useEffect(()=>{d.current=0},[t]),u.useEffect(()=>{if(!r.error){r.loading||(d.current=0);return}if(c.current.retryOnError===!1||t===null||d.current>=2||!/rate limit|network error|HTTP 5\d\d|timeout/i.test(r.error))return;const y=window.setTimeout(()=>{d.current+=1,m(t)},25e3*(d.current+1));return()=>window.clearTimeout(y)},[t,r.error,r.loading,m]);const f=r.key===t&&r.reconciling&&!r.error;u.useEffect(()=>{if(!(!f||r.loading||t===null))return _a(()=>m(t))},[t,f,r.loading,m]);const j=r.key===t?r:ye(t);return{data:j.data,error:j.error,loading:j.loading,reconciling:j.reconciling,partial:j.partial,updatedAt:j.updatedAt,refresh:x}}const Oa={overview:"stake",pools:"stake",usage:"network",emissions:"network",verification:"network"};function za(t){return Ds.some(s=>s===t)}function qa(t){const s=t.startsWith("#")?t.slice(1):t,[n="",a=""]=s.split("?"),r=n.split("/").filter(Boolean),l=r[0],i=l!==void 0?Oa[l]:void 0,c=za(l)?l:i??"stake",o=ae().pages;return{page:o.includes(c)?c:o[0]??c,segments:r.slice(1),query:new URLSearchParams(a),redirected:i!==void 0}}function hs(){const t=qa(ae().currentPath());return t.redirected&&ae().replace(t.page),t}function Ya(){const[t,s]=u.useState(hs);return u.useEffect(()=>{const n=()=>s(hs());return ae().subscribe(n)},[]),t}function _e(t,...s){return ae().href([t,...s].join("/"))}const qs="ants.dashboard.started-jobs";function Va(){try{const t=JSON.parse(sessionStorage.getItem(qs)??"[]");return new Set(Array.isArray(t)?t.filter(s=>typeof s=="string").slice(-100):[])}catch{return new Set}}function Ha(t,s){const n=new Set([...t,s].slice(-100));try{sessionStorage.setItem(qs,JSON.stringify([...n]))}catch{}return n}const Ys=u.createContext(null),Vs=()=>u.useContext(Ys);function Ka(t,s){var n,a;return t.browserWallet?s.status==="connecting"||s.status==="reconnecting"?{label:"Connecting wallet…",reason:"Wait for the wallet connection to finish."}:s.status!=="connected"||!s.address?{label:"Connect wallet",reason:"Connect wallet before submitting a transaction."}:s.chainId!==t.evmChainId?{label:"Switch network",reason:`Switch your wallet to ${t.chainId}.`}:t.readOnly||s.address.toLowerCase()!==((n=t.walletAddress)==null?void 0:n.toLowerCase())?{label:"Waiting for wallet sync…",reason:"Wait for the connected wallet to sync with the dashboard."}:((a=s.clientAddress)==null?void 0:a.toLowerCase())!==s.address.toLowerCase()||s.clientChainId!==t.evmChainId?{label:"Waiting for wallet…",reason:"The connected wallet is not ready to sign yet."}:{}:{}}const Ja=2e3,Ga=8e3,Qa=new Set(["stake","restake","stake-usage","compound"]),Hs=u.createContext(null);function Ae(){const t=u.useContext(Hs);if(!t)throw new Error("JobsContext is not mounted");return t}const Za={stake:"Stake",move:"Move stake",split:"Split position",merge:"Merge positions",extend:"Extend lock","max-lock":"Max lock",withdraw:"Withdraw",claim:"Claim rewards",restake:"Stake rewards","stake-usage":"Stake rewards",compound:"Stake rewards","verify-submit":"Submit proof","seller-register":"Register seller","claim-starter":"Claim starter"};function zt(t){const s=Za[t];if(s)return s;const n=t.replace(/[-_]+/g," ").trim();return n?n.charAt(0).toUpperCase()+n.slice(1):"Transaction"}function Xa(t,s){const n=s,r=(Array.isArray(n==null?void 0:n.positionIds)?n.positionIds:[n==null?void 0:n.positionId]).filter(l=>typeof l=="number"&&Number.isSafeInteger(l)&&l>0);return`${zt(t)}${r.length?` · position${r.length>1?"s":""} ${r.map(l=>`#${l}`).join(", ")}`:""}`}function ms(t){return[...t].sort((s,n)=>n.startedAt-s.startedAt)}function er({children:t}){const s=Vs(),n=u.useRef(s);n.current=s;const a=u.useRef(new Map),r=u.useCallback(S=>a.current.get(S)??"Transaction",[]),[l,i]=u.useState([]),[c,o]=u.useState(Va),h=u.useRef(c),[d,m]=u.useState(!1),[x,f]=u.useState(null),[j,y]=u.useState([]),E=u.useRef(new Map),P=u.useRef(0),T=u.useRef(new Map),A=u.useCallback(S=>{const g=T.current.get(S);g!==void 0&&(window.clearTimeout(g),T.current.delete(S)),y(w=>w.filter(p=>p.id!==S))},[]),N=u.useCallback(S=>{const g=++P.current;y(w=>[...w.filter(p=>!S.jobId||p.jobId!==S.jobId),{...S,id:g}]),S.sticky||T.current.set(g,window.setTimeout(()=>A(g),Ga))},[A]);u.useEffect(()=>{const S=T.current;return()=>{for(const g of S.values())window.clearTimeout(g);S.clear()}},[]);const U=u.useCallback((S,g)=>{var I,_;let w=!1,p=!1;for(const $ of S){a.current.has($.id)||a.current.set($.id,zt($.kind));let M=E.current.get($.id);if(!M){const O=g||$.status!=="running"&&!h.current.has($.id);if(M={hashes:new Set,terminal:O&&$.status!=="running"},O)for(const H of $.steps)H.hash&&M.hashes.add(H.hash);E.current.set($.id,M)}for(const O of $.steps)!O.hash||M.hashes.has(O.hash)||(M.hashes.add(O.hash),g||N({tone:"success",jobId:$.id,title:`${r($.id)} · Confirmed`,body:O.label,hash:O.hash,sticky:!1}));if($.status!=="running"&&!M.terminal){if(M.terminal=!0,w=!0,p||(p=$.steps.some(O=>!!O.hash)),$.status==="failed")N({tone:"danger",jobId:$.id,title:`${r($.id)} · ${(I=$.error)!=null&&I.startsWith("You rejected")?"Rejected":"Failed"}`,body:$.error??"The transaction did not complete.",sticky:!0});else if(!g){const O=Qa.has($.kind)?{href:_e("positions"),label:"View my positions"}:void 0;N({tone:"success",jobId:$.id,title:`${r($.id)} · ${$.steps.some(H=>!!H.hash)?"Confirmed":"Complete"}`,hash:(_=[...$.steps].reverse().find(H=>!!H.hash))==null?void 0:_.hash,sticky:!!O,link:O})}}}i(ms(S)),w&&!g&<({confirmed:p})},[N,r]),k=u.useRef(!0),B=u.useCallback(async()=>{const S=k.current;try{const g=await q.jobs();U(g,S),k.current=!1,f(null)}catch(g){f(Ce(g))}},[U]);u.useEffect(()=>{B()},[B]);const b=u.useMemo(()=>l.filter(S=>S.status==="running").length,[l]),v=b>0;u.useEffect(()=>{if(!d&&!v)return;let S=!1,g=0;const w=async()=>{S||(await B(),!S&&(g=window.setTimeout(()=>void w(),Ja)))};return w(),()=>{S=!0,window.clearTimeout(g)}},[d,v,B]);const L=u.useCallback(async(S,g)=>{var p;(p=n.current)==null||p.assertReady();const w=await q.startJob(S,g);return a.current.set(w.id,Xa(w.kind,g)),h.current=Ha(h.current,w.id),o(h.current),k.current=!1,E.current.has(w.id)||E.current.set(w.id,{hashes:new Set,terminal:!1}),f(null),i(I=>ms([w,...I.filter(_=>_.id!==w.id)])),w},[]),D=u.useMemo(()=>({jobs:l,locallyStartedJobIds:c,pending:b,running:v,drawerOpen:d,pollError:x,toasts:j,setDrawerOpen:m,dismissToast:A,pushToast:N,titleForJob:r,start:L}),[l,c,b,v,d,x,j,A,N,r,L]);return e.jsx(Hs.Provider,{value:D,children:t})}const Me={rejected:"You rejected the wallet request. This request was not submitted.",disconnected:"The wallet disconnected or no longer permits this request. Reconnect before retrying.",network:"The wallet is on the wrong network. Switch to the dashboard network before retrying.",reverted:"The contract rejected this transaction during wallet simulation. Refresh the position and review its action restrictions.",unknown:"The wallet could not complete the request. Check its activity before retrying; the submission status is unknown."};function tr(t){const s=new Set;let n=t,a=Me.unknown;for(;n&&typeof n=="object"&&!s.has(n);){s.add(n);const r=n;if(r.code===4001||r.name==="UserRejectedRequestError")return Me.rejected;if(r.code===4100||r.code===4900||r.name==="ProviderDisconnectedError"||r.name==="ConnectorNotConnectedError")return Me.disconnected;if(r.code===4901)return Me.network;(r.name==="ChainMismatchError"||r.name==="SwitchChainError"||r.name==="ChainDisconnectedError")&&(a=Me.network),(r.name==="ContractFunctionRevertedError"||r.name==="ExecutionRevertedError")&&(a=Me.reverted),n=r.cause}return a}class sr{constructor(){Ve(this,"attempted",new Set)}canPrompt(s){var a,r;const n=s.transaction;return!!(n!=null&&n.jobId)&&s.locallyStartedJobIds.has(n.jobId)&&!s.busy&&!s.settling&&!n.approvalStarted&&!n.submittedHash&&!this.attempted.has(n.id)&&((a=s.accountAddress)==null?void 0:a.toLowerCase())===n.from.toLowerCase()&&((r=s.walletAddress)==null?void 0:r.toLowerCase())===n.from.toLowerCase()&&s.expectedChainId===n.chainId&&s.accountChainId===n.chainId&&s.walletChainId===n.chainId}claim(s){return this.canPrompt(s)?(this.attempted.add(s.transaction.id),!0):!1}}class nr{constructor(s){Ve(this,"results",new Map);Ve(this,"delivering",new Set);this.send=s}enqueue(s){this.results.has(s.id)||this.results.set(s.id,s)}async deliver(s){if(!s||this.delivering.has(s))return;const n=this.results.get(s);if(n){this.delivering.add(s);try{await this.send(n),this.results.delete(s)}catch{return}finally{this.delivering.delete(s)}}}}const ar=new Nn,rr=aa(ia),lr=sa;function ir({config:t,children:s}){const n=u.useMemo(()=>Xn({appName:"AntSeed Staking",projectId:la,chains:[ta({id:t.evmChainId,name:t.chainId,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[t.walletRpcUrl??(t.evmChainId===8453?"https://mainnet.base.org":t.evmChainId===84532?"https://sepolia.base.org":"http://127.0.0.1:8545")]}}})],transports:{[t.evmChainId]:ea()}}),[t.chainId,t.evmChainId,t.walletRpcUrl]);return t.browserWallet?ae().embedded?e.jsx(ps,{config:t,children:s}):e.jsx(lr,{config:n,children:e.jsx(kn,{client:ar,children:e.jsx(na,{theme:rr,children:e.jsx(ps,{config:t,children:s})})})}):e.jsx(e.Fragment,{children:s})}function ps({config:t,children:s}){const n=_t(),{data:a}=Us(),r=Ka(t,{status:n.status,address:n.address,chainId:n.chainId,clientAddress:a==null?void 0:a.account.address,clientChainId:a==null?void 0:a.chain.id}),l=u.useRef(r);l.current=r;const i=u.useCallback(()=>{if(l.current.reason)throw new Error(l.current.reason)},[]);return e.jsx(Ys.Provider,{value:{...r,assertReady:i},children:s})}function Ks({config:t}){const s=_t(),{jobs:n,running:a,locallyStartedJobIds:r,pushToast:l,titleForJob:i}=Ae(),{data:c}=Us(),[o,h]=u.useState(null),[d,m]=u.useState(null),[x,f]=u.useState(!1),j=u.useRef(!1),y=u.useRef(new sr),E=u.useRef(new Map),P=u.useRef(null),T=u.useRef(Promise.resolve()),A=u.useRef(new nr(v=>$e("/api/wallet/result",{method:"POST",body:v}))),N=u.useRef(!1);N.current=a||x||o!==null;const U=!!s.address&&s.chainId!==t.evmChainId,k=s.status==="connecting"||s.status==="reconnecting";u.useEffect(()=>{d&&l({tone:"danger",title:"Wallet request failed",body:d,sticky:!0})},[d,l]),u.useEffect(()=>{var I;if(k)return;let v=!1,L;const D=`${((I=s.address)==null?void 0:I.toLowerCase())??""}:${s.chainId??""}`,S=!!P.current&&!P.current.startsWith(":");let g=!1;function w(_=!1){g||v||(g=!0,T.current=T.current.catch(()=>{}).then(async()=>{if(!v)try{const $=_&&!U,M=U||!s.address&&S,O=await $e("/api/wallet",{method:"POST",body:{address:U?void 0:s.address,chainId:s.chainId,refresh:$,disconnect:M}});if(!v){const H=O.changed??P.current!==D;P.current=D,m(null),(H||$)&<({clear:H})}}catch($){v||(m($ instanceof Error?$.message:String($)),t.selectedAddress&&$ instanceof Ne&&$.status===400?lt():L=setTimeout(()=>w(_),1500))}finally{g=!1}}))}w();const p=()=>{N.current||w(!0)};return window.addEventListener("focus",p),()=>{v=!0,clearTimeout(L),window.removeEventListener("focus",p)}},[s.address,s.chainId,U,k,t.selectedAddress]),u.useEffect(()=>{let v=!1,L;const D=async()=>{try{const S=await $e("/api/wallet/request");v||(h(S),await A.current.deliver((S==null?void 0:S.id)??null))}catch{}finally{v||(L=setTimeout(()=>void D(),a||o!==null?1e3:3e4))}};return D(),()=>{v=!0,clearTimeout(L)}},[a,o!==null]),u.useEffect(()=>{if(!(o!=null&&o.jobId))return;const v=n.find(D=>D.id===o.jobId);if(!v||v.status!=="running")return;const L=o.submittedHash?"Submitted":"Awaiting wallet approval";E.current.get(o.id)!==L&&E.current.get(o.id)!=="Submitted"&&(E.current.set(o.id,L),l({tone:"info",jobId:o.jobId,title:`${i(o.jobId)} · ${L}`,body:o.submittedHash?"Waiting for on-chain confirmation.":"No transaction has been submitted yet.",hash:o.submittedHash,sticky:!0}))},[o,n,l,i]);const B=u.useCallback(async()=>{var L;if(!o||!c||j.current||o.submittedHash)return;j.current=!0,f(!0),m(null);let v=!1;try{if(c.account.address.toLowerCase()!==o.from.toLowerCase()||((L=s.address)==null?void 0:L.toLowerCase())!==o.from.toLowerCase()||s.chainId!==o.chainId||c.chain.id!==o.chainId||t.evmChainId!==o.chainId)throw new Error("Connect the wallet and network shown in this request.");await $e("/api/wallet/begin",{method:"POST",body:{id:o.id}}),v=!0;const D=await c.sendTransaction({account:c.account,chain:c.chain,to:o.to,data:o.data,value:BigInt(o.value)});A.current.enqueue({id:o.id,hash:D}),E.current.set(o.id,"Submitted"),l({tone:"info",jobId:o.jobId,title:`${i(o.jobId??"")} · Submitted`,body:"Waiting for on-chain confirmation.",hash:D,sticky:!0}),await A.current.deliver(o.id)}catch(D){const S=tr(D);v?(A.current.enqueue({id:o.id,error:S}),await A.current.deliver(o.id)):m(S)}finally{j.current=!1,f(!1)}},[o,c,s.address,s.chainId,t.evmChainId,l,i]),b=u.useMemo(()=>({transaction:o,locallyStartedJobIds:r,accountAddress:s.address,accountChainId:s.chainId,walletAddress:c==null?void 0:c.account.address,walletChainId:c==null?void 0:c.chain.id,expectedChainId:t.evmChainId,busy:x,settling:k}),[o,r,s.address,s.chainId,c,t.evmChainId,x,k]);return u.useEffect(()=>{y.current.claim(b)&&B()},[b,B]),e.jsxs("div",{className:"browser-wallet",children:[e.jsx(Is,{accountStatus:"address",chainStatus:"icon",showBalance:!1}),U&&e.jsxs("span",{className:"hint",children:["Switch to ",t.chainId," to continue."]})]})}function or(){return e.jsx(Is.Custom,{children:({account:t,chain:s,openConnectModal:n,openAccountModal:a,openChainModal:r,mounted:l})=>e.jsx("button",{className:"btn",disabled:!l,onClick:t?s!=null&&s.unsupported?r:a:n,children:t?s!=null&&s.unsupported?"Switch network":"Change wallet":"Connect wallet"})})}function ze(...t){return t.filter(Boolean).join(" ")}function G({children:t,className:s,fullWidth:n=!1,leadingIcon:a,size:r="md",type:l="button",variant:i="primary",...c}){return e.jsxs("button",{type:l,className:ze("btn",`btn--${i}`,`btn--${r}`,n&&"btn--full",s),...c,children:[a?e.jsx("span",{className:"btn__icon","aria-hidden":"true",children:a}):null,e.jsx("span",{className:"btn__label",children:t})]})}function we({children:t,className:s,tone:n="surface",...a}){return e.jsx("div",{className:ze("card",n!=="surface"&&`card--${n}`,s),...a,children:t})}function Qe({action:t,children:s,className:n,title:a,tone:r="info",...l}){return e.jsxs("div",{className:ze("alert",`alert--${r}`,n),role:r==="danger"||r==="warning"?"alert":"status",...l,children:[e.jsxs("div",{className:"alert__content",children:[a?e.jsx("div",{className:"alert__title",children:a}):null,e.jsx("div",{className:"alert__body",children:s})]}),t?e.jsx("div",{className:"alert__action",children:t}):null]})}function qt({className:t,height:s,radius:n,style:a,width:r,...l}){return e.jsx("div",{className:ze("skeleton",t),style:{...a,...s!==void 0?{height:s}:{},...n!==void 0?{borderRadius:n}:{},...r!==void 0?{width:r}:{}},...l})}function cr({className:t,error:s,hint:n,id:a,label:r,...l}){const i=a??l.name;return e.jsxs("label",{className:ze("field",t),htmlFor:i,children:[r?e.jsx("span",{className:"field__label",children:r}):null,e.jsx("input",{id:i,className:"field__input",...l}),s?e.jsx("span",{className:"field__error",children:s}):n?e.jsx("span",{className:"field__hint",children:n}):null]})}function Yt({children:t,className:s,label:n,type:a="button",...r}){return e.jsx("button",{type:a,className:ze("icon-button",s),"aria-label":n,title:r.title??n,...r,children:t})}const Js=u.createContext(null);function Ee(){const t=u.useContext(Js);if(!t)throw new Error("AppContext is not mounted");return t}function Ie(){return Ee().config}function he(){var t;return((t=Ee().overview)==null?void 0:t.epoch)??null}function tt({rows:t=4,width:s}){return e.jsx("div",{className:"skel-list","aria-busy":"true",children:Array.from({length:t},(n,a)=>e.jsx(qt,{height:14,width:s??`${60+a*17%40}%`},a))})}function ne({error:t,onRetry:s,title:n}){return e.jsx(Qe,{tone:"danger",title:n,action:s?e.jsx(G,{variant:"outline",size:"sm",onClick:s,children:"Retry"}):void 0,children:e.jsx("span",{className:"break",children:t})})}function mt(){return e.jsx("span",{className:"spinner","aria-label":"loading"})}function pt(t=1e3){const[s,n]=u.useState(()=>Date.now());return u.useEffect(()=>{const a=window.setInterval(()=>n(Date.now()),t);return()=>window.clearInterval(a)},[t]),s}function Gs(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}function dr(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2.5 6.2l2.4 2.4 4.6-4.9",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function ur(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M3 3l6 6M9 3l-6 6",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function Qs({status:t}){return t==="running"?e.jsx("span",{className:"status-icon status-icon--running",title:"Pending",children:e.jsx(mt,{})}):t==="done"?e.jsx("span",{className:"status-icon status-icon--done",title:"Confirmed",children:e.jsx(dr,{})}):e.jsx("span",{className:"status-icon status-icon--failed",title:"Failed",children:e.jsx(ur,{})})}function Zs({hash:t,showHash:s=!1}){const{evmChainId:n}=Ie(),a=zs(n,t),r=Ba(n);return!a||!r?e.jsx("span",{className:"activity-hash mono",title:t,children:Et(t)}):e.jsxs("span",{className:"activity-link-wrap",children:[e.jsxs("a",{className:"activity-link",href:a,target:"_blank",rel:"noreferrer",title:t,children:["View on ",r]}),s?e.jsx("span",{className:"activity-hash mono dim",children:Et(t)}):null]})}function xs(){const{drawerOpen:t,setDrawerOpen:s}=Ae();if(u.useEffect(()=>{if(!t)return;const a=r=>{r.key==="Escape"&&s(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,s]),!t)return null;const n=()=>s(!1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"drawer-backdrop",onClick:n}),e.jsxs("aside",{className:"drawer activity-drawer",role:"dialog","aria-modal":"true","aria-label":"Activity",children:[e.jsxs("header",{className:"drawer-header",children:[e.jsx("div",{className:"drawer-titles",children:e.jsx("h2",{className:"drawer-title",children:"Activity"})}),e.jsx(Yt,{label:"Close",className:"drawer-close",onClick:n,children:e.jsx(Gs,{})})]}),e.jsx("div",{className:"drawer-body",children:e.jsx(hr,{})})]})]})}function hr(){const{jobs:t,pollError:s}=Ae(),n=pt(1e3);return e.jsxs(e.Fragment,{children:[t.length===0?e.jsx("div",{className:"activity-empty",children:"No recorded transactions. Signed-wallet activity is saved locally for 30 days."}):e.jsx("ol",{className:"activity-list",children:t.map(a=>e.jsx(mr,{job:a,now:n},a.id))}),s?e.jsxs("div",{className:"activity-poll-error",children:["Could not refresh activity: ",s]}):null]})}function mr({job:t,now:s}){var r;const n=t.steps.filter(l=>l.hash),a=(r=t.steps[0])==null?void 0:r.label;return e.jsxs("li",{className:`activity-row activity-row--${t.status}`,children:[e.jsxs("div",{className:"activity-main",children:[e.jsx("div",{className:"activity-title",children:zt(t.kind)}),a?e.jsx("div",{className:"activity-sub",children:a}):null,t.steps.length>1?e.jsxs("details",{children:[e.jsx("summary",{children:"Action steps"}),e.jsx("ol",{children:t.steps.map((l,i)=>e.jsx("li",{children:l.label},i))})]}):null,t.status==="failed"&&t.error?e.jsx("div",{className:"activity-error",children:t.error}):null,n.length>0?e.jsx("div",{className:"activity-links",children:n.map(l=>e.jsx(Zs,{hash:l.hash,showHash:n.length>1},l.hash))}):null]}),e.jsxs("div",{className:"activity-side",children:[e.jsx(Qs,{status:t.status}),e.jsx("span",{className:"activity-time",children:Ua(t.startedAt,s)})]})]})}function K({value:t,kind:s="address",short:n=!0,label:a,copy:r=!1,className:l}){const{evmChainId:i}=Ie(),c=s==="tx"?zs(i,t):Fa(i,t),o=a??(n?s==="tx"?Et(t):ut(t):t),h=`mono ${l??""}`.trim();return e.jsxs("span",{className:"nowrap",children:[c?e.jsx("a",{className:h,href:c,target:"_blank",rel:"noreferrer",title:t,children:o}):e.jsx("span",{className:h,title:t,children:o}),r?e.jsx(pr,{value:t}):null]})}function pr({value:t}){const[s,n]=u.useState(!1),a=()=>{var r;(r=navigator.clipboard)==null||r.writeText(t).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)}).catch(()=>{})};return e.jsx("button",{className:"link-button",style:{marginLeft:6},onClick:a,type:"button",title:"Copy",children:s?"copied":"copy"})}function fs(){const{toasts:t,dismissToast:s}=Ae();return t.length===0?null:e.jsx("div",{className:"toasts",role:"region","aria-label":"Transaction notifications",children:t.map(n=>e.jsxs("div",{className:`toast toast--${n.tone}`,role:n.tone==="danger"?"alert":"status",children:[e.jsx(Qs,{status:n.tone==="danger"?"failed":n.tone==="info"?"running":"done"}),e.jsxs("div",{className:"toast-body",children:[e.jsx("div",{className:"toast-title",children:n.title}),n.body?e.jsx("div",{className:"toast-text",children:n.body}):null,n.hash?e.jsx(Zs,{hash:n.hash}):null,n.link?e.jsxs("a",{className:"toast-link",href:n.link.href,children:[n.link.label," →"]}):null]}),e.jsx(Yt,{label:"Dismiss",className:"toast-close",onClick:()=>s(n.id),children:e.jsx(Gs,{})})]},n.id))})}function xr({page:t,updatedAt:s,children:n}){return ae().embedded?e.jsxs("div",{className:"app app--embedded",children:[e.jsx(gr,{updatedAt:s}),e.jsx("main",{className:"main",children:n}),e.jsx(xs,{}),e.jsx(fs,{})]}):e.jsxs("div",{className:"app",children:[e.jsx(fr,{page:t,updatedAt:s}),e.jsx("div",{className:"content",children:e.jsx("main",{className:"main",children:n})}),e.jsx(xs,{}),e.jsx(fs,{})]})}function fr({page:t,updatedAt:s}){const{config:n,theme:a,toggleTheme:r}=Ee();return e.jsxs("aside",{className:"sidebar",children:[e.jsxs("a",{className:"wordmark",href:_e("stake"),children:["ANTS",e.jsx("span",{children:"staking"})]}),e.jsx("nav",{className:"sidenav","aria-label":"Main",children:Ia.map(l=>e.jsxs("div",{className:"sidenav-group",children:[e.jsx("div",{className:"sidenav-label",children:l.label}),l.items.map(i=>e.jsxs("a",{href:_e(i.id),className:i.id===t?"sidenav-item active":"sidenav-item","aria-current":i.id===t?"page":void 0,children:[e.jsx(br,{page:i.id}),e.jsx("span",{children:i.label})]},i.id))]},l.label))}),e.jsxs("div",{className:"sidebar-foot",children:[e.jsx(Xs,{updatedAt:s}),n.selectedAddress&&e.jsxs("div",{className:"small",children:["Selected account ",e.jsx(K,{value:n.selectedAddress,copy:!0})]}),e.jsxs("div",{className:"sidebar-foot-row",children:[n.browserWallet?e.jsx(Ks,{config:n}):e.jsx("span",{className:"wallet-chip",children:e.jsx(K,{value:n.address,copy:!0,className:"wallet-chip-addr"})}),e.jsx(Yt,{label:a==="dark"?"Switch to light theme":"Switch to dark theme",className:"theme-toggle",onClick:r,children:a==="dark"?e.jsx(jr,{}):e.jsx(wr,{})})]})]})]})}function gr({updatedAt:t}){const{config:s}=Ee();return e.jsxs("div",{className:"embedded-toolbar",children:[e.jsx(Xs,{updatedAt:t}),s.selectedAddress&&e.jsxs("div",{className:"small",children:["Selected account ",e.jsx(K,{value:s.selectedAddress,copy:!0})]}),e.jsx("div",{className:"embedded-toolbar__wallet",children:s.browserWallet?e.jsx(Ks,{config:s}):e.jsx("span",{className:"wallet-chip",children:e.jsx(K,{value:s.address,copy:!0,className:"wallet-chip-addr"})})})]})}function Xs({updatedAt:t}){const{overview:s}=Ee(),n=pt(3e4);if(!s)return null;const a=s.epoch,r=t!==null?t+a.secondsToBoundary*1e3:a.nextBoundaryAt*1e3,l=Math.max(0,Math.floor((r-n)/1e3)),i=e.jsxs(e.Fragment,{children:[e.jsx("i",{"aria-hidden":"true"}),e.jsxs("span",{children:["epoch ",e.jsx("strong",{children:a.current})]}),e.jsxs("span",{children:["· ",e.jsx("strong",{children:ht(l)})," left"]})]}),c="Current epoch and time until the next boundary";return ae().pages.includes("network")?e.jsx("a",{className:"epoch-chip",href:_e("network"),title:c,children:i}):e.jsx("span",{className:"epoch-chip",title:c,children:i})}function br({page:t}){const s={width:16,height:16,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};switch(t){case"stake":return e.jsx("svg",{...s,children:e.jsx("path",{d:"M2 13h12M3.5 10.5v-3M7 10.5V4M10.5 10.5V6.5M14 10.5V2.5"})});case"positions":return e.jsxs("svg",{...s,children:[e.jsx("path",{d:"M8 2.5 14 5.5 8 8.5 2 5.5Z"}),e.jsx("path",{d:"m2 8.5 6 3 6-3M2 11.5l6 3 6-3"})]});case"rewards":return e.jsxs("svg",{...s,children:[e.jsx("circle",{cx:"8",cy:"8",r:"5.5"}),e.jsx("path",{d:"M8 5v6M6.2 6.6c0-.9.8-1.4 1.8-1.4s1.8.5 1.8 1.2c0 1.6-3.6.9-3.6 2.5 0 .8.8 1.3 1.8 1.3s1.8-.5 1.8-1.3"})]});case"seller":return e.jsxs("svg",{...s,children:[e.jsx("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),e.jsx("circle",{cx:"6",cy:"7",r:"1.5"}),e.jsx("path",{d:"M4 11c.5-1 1.2-1.5 2-1.5s1.5.5 2 1.5M9.5 6.5h2.5M9.5 9h2.5"})]});case"network":return e.jsxs("svg",{...s,children:[e.jsx("circle",{cx:"8",cy:"8",r:"5.5"}),e.jsx("path",{d:"M2.5 8h11M8 2.5c1.8 1.8 1.8 9.2 0 11M8 2.5c-1.8 1.8-1.8 9.2 0 11"})]});case"addresses":return e.jsxs("svg",{...s,children:[e.jsx("path",{d:"M6.5 9.5a2.5 2.5 0 0 0 3.5 0l2-2a2.5 2.5 0 0 0-3.5-3.5l-.8.8"}),e.jsx("path",{d:"M9.5 6.5a2.5 2.5 0 0 0-3.5 0l-2 2a2.5 2.5 0 0 0 3.5 3.5l.8-.8"})]});default:return null}}function jr(){return e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"8",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.4 3.4l1.4 1.4M11.2 11.2l1.4 1.4M3.4 12.6l1.4-1.4M11.2 4.8l1.4-1.4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function wr(){return e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M13.5 9.5A6 6 0 0 1 6.5 2.5a6 6 0 1 0 7 7z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})})}function Z({title:t,actions:s,children:n,className:a,tone:r}){return e.jsxs(we,{className:`panel ${a??""}`.trim(),tone:r,children:[t||s?e.jsxs("div",{className:"panel-head",children:[t?e.jsx("h3",{children:t}):e.jsx("span",{}),s?e.jsx("div",{className:"row",children:s}):null]}):null,n]})}function X({items:t}){return e.jsx("dl",{className:"facts",children:t.map(([s,n])=>e.jsx(vr,{label:s,value:n},s))})}function vr({label:t,value:s}){return e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s??"—"})]})}function Oe({columns:t,rows:s,rowKey:n,empty:a,loading:r,onRowClick:l,footer:i}){const c=o=>[o.align==="right"?"num":"",o.mono?"mono":"",o.className??""].filter(Boolean).join(" ")||void 0;return e.jsx("div",{className:"table-wrap",tabIndex:0,role:"region","aria-label":"Data table; scroll horizontally to see all columns",children:e.jsxs("table",{className:"table",children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map(o=>e.jsx("th",{className:[o.align==="right"?"num":"",o.className??""].filter(Boolean).join(" ")||void 0,title:o.title,"aria-sort":o.sortDirection,children:o.label},o.key))})}),e.jsxs("tbody",{children:[r&&s.length===0?Array.from({length:3},(o,h)=>e.jsx("tr",{children:t.map(d=>e.jsx("td",{children:e.jsx(qt,{width:"70%",height:12})},d.key))},`skel-${h}`)):null,!r&&s.length===0?e.jsx("tr",{children:e.jsx("td",{className:"empty",colSpan:t.length,children:a??"Nothing to show."})}):null,s.map((o,h)=>e.jsx("tr",{className:l?"clickable":void 0,onClick:l?()=>l(o):void 0,children:t.map(d=>e.jsx("td",{className:c(d),children:d.render(o,h)},d.key))},n(o)))]}),i?e.jsx("tfoot",{children:i}):null]})})}function yr(){const t=V("overview",q.overview),s=t.data,n=Object.entries((s==null?void 0:s.addresses)??{}).map(([a,r])=>({name:a,address:r})).sort((a,r)=>a.name.localeCompare(r.name));return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"page-title",children:"Addresses"}),t.error&&!s?e.jsx(ne,{error:t.error,onRetry:t.refresh}):null,e.jsx(Z,{title:"Protocol contracts",children:e.jsx(Oe,{columns:[{key:"name",label:"Contract",render:a=>a.name},{key:"address",label:"Address",render:a=>e.jsx(K,{value:a.address,short:!1,copy:!0})}],rows:n,rowKey:a=>a.name,loading:t.loading&&!s,empty:"No contract addresses are configured for this chain."})})]})}function de({summary:t,children:s,open:n,className:a,lazy:r=!1}){const[l,i]=u.useState(n??!1);return e.jsxs("details",{className:["details",a??""].filter(Boolean).join(" "),open:n,onToggle:c=>i(c.currentTarget.open),children:[e.jsx("summary",{children:t}),e.jsx("div",{className:"details-body",children:!r||l?s:null})]})}function wt(t,s){if(t===null||s===null||BigInt(s)===0n)return"—";const n=BigInt(t)*10000n/BigInt(s);return`${n/100n}.${(n%100n).toString().padStart(2,"0")}%`}const kr="Early withdrawal permanently burns some principal, based on the remaining lock and configured limits. No penalty after expiry. Preview shows the exact burn and payout. Claim rewards separately.";function $t(){return e.jsx(Ze,{label:"About the early-exit penalty",children:kr})}function Ze({label:t,children:s,symbol:n="?"}){const a=u.useId(),r=u.useRef(),l=()=>{clearTimeout(r.current)},i=()=>{r.current=setTimeout(()=>h(null),150)};u.useEffect(()=>()=>clearTimeout(r.current),[]);const c=u.useRef(null),[o,h]=u.useState(null),d=()=>{var f;l();const m=(f=c.current)==null?void 0:f.getBoundingClientRect();if(!m)return;const x=m.bottom+240>window.innerHeight;h({left:Math.max(8,Math.min(m.left,window.innerWidth-328)),top:x?m.top-8:m.bottom+8,above:x})};return u.useEffect(()=>{if(!o)return;const m=()=>h(null),x=f=>{f.key==="Escape"&&(f.stopPropagation(),m())};return window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),document.addEventListener("keydown",x,!0),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m),document.removeEventListener("keydown",x,!0)}},[o]),e.jsxs("span",{className:"early-exit-help",children:[e.jsx("button",{ref:c,type:"button",className:"early-exit-help__trigger","aria-label":t,"aria-describedby":o?a:void 0,onMouseEnter:d,onMouseLeave:i,onFocus:d,onBlur:()=>h(null),onClick:d,children:n}),o&&Ns.createPortal(e.jsx("span",{id:a,role:"tooltip",className:"early-exit-help__tooltip",onMouseEnter:l,onMouseLeave:i,style:{left:o.left,top:o.top,transform:o.above?"translateY(-100%)":void 0},children:s}),ae().portalTarget())]})}function re(t){return t===null?"Unavailable":`${C(t)} ANTS`}const gs={"seller-pools":"Seller pools",usage:"Usage rewards",team:"Team",reserve:"Reserve — base allowance",verification:"Verification"};function Nr({data:t}){var m,x;const s=[{key:"name",label:"Bucket",render:f=>gs[f.name]??f.name},{key:"share",label:"Share of scheduled emission",align:"right",mono:!0,render:f=>wt(f.budget,t.emission)},{key:"budget",label:"Bucket allowance",align:"right",mono:!0,render:f=>re(f.budget)}],n=[{name:"Staker rewards",budget:t.budgets.staker},{name:"Buyer usage rewards",budget:t.budgets.buyer},{name:"Seller usage rewards",budget:t.budgets.seller}],a=t.buckets.filter(f=>f.budget!==null&&f.nextBudget!==null&&f.budget!==f.nextBudget),r=t.stakerConfig,l=t.usageConfig,i=t.nextStakerConfig,c=t.nextUsageConfig,o=r&&i&&JSON.stringify(r)!==JSON.stringify(i),h=l&&c&&JSON.stringify(l)!==JSON.stringify(c),d=(f,j)=>`${us(f,t.shareDenominator)} – ${us(j,t.shareDenominator)}`;return e.jsxs(e.Fragment,{children:[e.jsxs(Z,{title:e.jsxs(e.Fragment,{children:[`Current epoch reward budgets · epoch ${t.epoch.current}`," ",e.jsx(Ze,{label:"When reward budgets become final",symbol:"i",children:"Budgets can change during the epoch. After it ends, each reward contract fixes its budgets on the first claim or settlement—not at rollover."})]}),children:[e.jsx("p",{className:"hint",children:"Live network-wide budgets—not your wallet rewards or amounts already paid."}),e.jsx(Oe,{columns:[{key:"name",label:"Recipient",render:f=>f.name},{key:"budget",label:"Calculated epoch budget",align:"right",mono:!0,render:f=>re(f.budget)},{key:"share",label:"Share of epoch emission",align:"right",mono:!0,render:f=>wt(f.budget,t.emission)}],rows:n,rowKey:f=>f.name}),e.jsxs(de,{summary:"How these budgets are calculated",children:[e.jsx("div",{className:"section-label",children:"Staker rewards"}),r?e.jsx(X,{items:[["Configured share range",d(r.minShareBps,r.maxShareBps)],["Network active stake used by the contract",re(t.totalActiveStake)],["Stake target for this epoch",re(t.scaledStakeTarget)],["Initial-emission stake target",re(r.stakeShareTarget)],["Seller-pools budget cap",re(((m=t.buckets.find(f=>f.name==="seller-pools"))==null?void 0:m.budget)??null)]]}):e.jsx("p",{className:"muted",children:"Staker configuration unavailable."}),e.jsx("p",{className:"hint",children:"With positive active stake, the share rises toward the configured maximum as stake grows. The stake target scales with the epoch emission; it is not a hard threshold. Zero active stake produces a zero budget."}),e.jsx("div",{className:"section-label mt",children:"Buyer and seller rewards"}),l?e.jsx(X,{items:[["Buyer share range",d(l.buyerMinShareBps,l.buyerMaxShareBps)],["Seller share range",d(l.sellerMinShareBps,l.sellerMaxShareBps)],["Accounted usage input",t.usageVolume===null?"Unavailable":`${ce(t.usageVolume)} USDC-equivalent`],["Usage target",`${ce(l.volumeShareTarget)} USDC-equivalent / epoch`],["Combined usage budget cap",re(((x=t.buckets.find(f=>f.name==="usage"))==null?void 0:x.budget)??null)]]}):e.jsx("p",{className:"muted",children:"Usage configuration unavailable."}),e.jsx("p",{className:"hint",children:"The usage input is the larger of the epoch’s total buyer points and total seller points—not their sum. With positive usage, each share rises toward its maximum. If the combined desired budgets exceed the usage bucket limit, the contract scales them proportionally. Zero usage produces zero budgets."}),e.jsx("p",{className:"hint",children:"For a positive input, the curve is minimum + (maximum − minimum) × input / (input + target), with contract integer rounding. A zero target selects the maximum. Displayed budgets come directly from contract getters, not a browser calculation."})]})]}),e.jsxs(Z,{title:`Emission bucket allowances · epoch ${t.epoch.current}`,children:[e.jsx("p",{className:"hint",children:"Bucket limits, not payouts. Shares use this epoch’s scheduled emission."}),e.jsx(Oe,{columns:s,rows:t.buckets,rowKey:f=>f.id,empty:"No emission buckets available."}),e.jsx("p",{className:"hint mt",children:"Unallocated seller-pool and usage allowances go to the burn destination (combined cap: 30% of scheduled emission), then Reserve on top of its base allowance. Requires an on-chain settlement."}),(a.length>0||o||h||t.nextEmission!==t.emission)&&e.jsxs(de,{summary:`Next epoch · ${t.epoch.current+1}`,children:[e.jsx(X,{items:[["Scheduled emission",re(t.nextEmission)],...a.map(f=>[gs[f.name]??f.name,`${re(f.nextBudget)} · ${wt(f.nextBudget,t.nextEmission)}`]),...o?[["Staker share range",d(i.minShareBps,i.maxShareBps)],["Staker target at initial emission",re(i.stakeShareTarget)]]:[],...h?[["Buyer share range",d(c.buyerMinShareBps,c.buyerMaxShareBps)],["Seller share range",d(c.sellerMinShareBps,c.sellerMaxShareBps)],["Usage target",`${ce(c.volumeShareTarget)} USDC-equivalent / epoch`]]:[]]}),e.jsx("p",{className:"hint",children:"Next-epoch allowances and configuration are shown separately. They are not a prediction of next epoch’s earned rewards."})]})]})]})}function me({label:t,value:s,unit:n,sub:a,loading:r,title:l}){return e.jsxs(we,{className:"tile",title:l,children:[e.jsx("div",{className:"tile-label",children:t}),r?e.jsx(qt,{width:"60%",height:22,style:{marginTop:3}}):e.jsxs("div",{className:"tile-value",children:[s,n?e.jsx("span",{className:"unit",children:n}):null]}),a?e.jsx("div",{className:"tile-sub",children:a}):null]})}function Vt({children:t}){return e.jsx("div",{className:"tiles",children:t})}function st({epoch:t,dateOnly:s=!1}){const n=he();if(t==null)return e.jsx("span",{className:"mono",children:"—"});const a=n?ue(De(t,n.genesis,n.epochDuration)):null;return s?e.jsx("span",{className:"mono",children:a??"—"}):e.jsxs("span",{className:"mono",title:a??void 0,children:[t,a?e.jsxs("span",{className:"muted small",children:[" ",a.slice(0,10)]}):null]})}function Ue({label:t,hint:s,width:n,children:a}){return e.jsxs("label",{className:["field",n?`field-w-${n}`:""].filter(Boolean).join(" "),children:[e.jsx("span",{className:"field__label",children:t}),a,s?e.jsx("span",{className:"field__hint",children:s}):null]})}function qe({mono:t=!0,width:s="md",className:n,...a}){const r=[`field-w-${s}`,n??""].filter(Boolean).join(" ");return e.jsx(cr,{className:r,...a,style:t?{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",...a.style}:a.style})}function Fe({className:t,children:s,...n}){const a=["field__input",t??""].filter(Boolean).join(" ");return e.jsx("span",{className:"select-wrap",children:e.jsx("select",{className:a,...n,children:s})})}const Sr=[4,8,12,26,52];function Cr(){const{overview:t}=Ee(),[s,n]=u.useState(8),[a,r]=u.useState(!1),l=V(`usage:${s}`,()=>q.usage(s)),i=l.data,c=[{key:"epoch",label:"Epoch",render:d=>e.jsx(st,{epoch:d.epoch})},{key:"buyer",label:"Your buyer pts",align:"right",mono:!0,render:d=>W(d.buyerPoints)},...a?[{key:"wbuyer",label:"Weighted",align:"right",mono:!0,title:"Buyer points after pool weighting",render:d=>W(d.weightedBuyerPoints)}]:[],{key:"seller",label:"Your seller pts",align:"right",mono:!0,render:d=>W(d.sellerPoints)},{key:"nbuyer",label:"Network buyer",align:"right",mono:!0,render:d=>W(d.totalBuyerPoints)},{key:"nseller",label:"Network seller",align:"right",mono:!0,render:d=>W(d.totalSellerPoints)},{key:"pool",label:"Pool pts",align:"right",mono:!0,render:d=>W(d.totalPoolPoints)},...a?[{key:"wpool",label:"Weighted pool pts",align:"right",mono:!0,render:d=>W(d.totalWeightedPoolPoints)}]:[]],o=(i==null?void 0:i.firstRewardedEpoch)??(t==null?void 0:t.epoch.effective)??null,h=o!==null&&(!i||i.currentEpoch<o)?`Usage accounting starts at epoch ${o}.`:"No usage has been recorded for this wallet in the selected epochs.";return e.jsxs(Z,{title:"Your usage · historical network comparisons",actions:e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"check small",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:d=>r(d.target.checked)}),"weighted columns"]}),e.jsxs("label",{className:"row small",children:[e.jsx("span",{className:"muted",children:"epochs"}),e.jsx(Fe,{value:s,onChange:d=>n(Number(d.target.value)),style:{width:72,minHeight:30,padding:"4px 8px"},children:Sr.map(d=>e.jsx("option",{value:d,children:d},d))})]})]}),children:[l.error&&!i?e.jsx(ne,{error:l.error,onRetry:l.refresh}):null,l.error&&i?e.jsxs("div",{className:"status-line",children:["Refresh failed: ",l.error]}):null,i&&e.jsxs("p",{className:"hint",children:[i.source==="indexer"?"Historical rows are indexed data and may lag the current contract snapshot.":"Historical rows are unavailable without the explorer; current totals are read from the chain.",i.sourceError?` ${i.sourceError}`:""]}),e.jsx(X,{items:[["Your buyer points",i?W(i.totals.buyerPoints):"…"],["Network buyer points",i?W(i.totals.networkBuyerPoints):"…"],["Network seller points",i?W(i.totals.networkSellerPoints):"…"],["First rewarded epoch",i?i.firstRewardedEpoch??"—":"…"]]}),e.jsx("div",{className:"mt",children:e.jsx(Oe,{columns:c,rows:(i==null?void 0:i.epochs)??[],rowKey:d=>d.epoch,loading:l.loading&&!i,empty:h,footer:i&&i.epochs.length>0?e.jsxs("tr",{children:[e.jsx("td",{children:"Total"}),e.jsx("td",{className:"num mono",children:W(i.totals.buyerPoints)}),a?e.jsx("td",{className:"num mono",children:W(i.totals.buyerWeightedPoints)}):null,e.jsx("td",{className:"num mono",children:W(Ar(i.epochs.map(d=>d.sellerPoints)))}),e.jsx("td",{className:"num mono",children:W(i.totals.networkBuyerPoints)}),e.jsx("td",{className:"num mono",children:W(i.totals.networkSellerPoints)}),e.jsx("td",{}),a?e.jsx("td",{}):null]}):null})}),e.jsxs(de,{summary:"Policies",children:[e.jsx(X,{items:[["Points policy",i!=null&&i.pointsPolicy?e.jsx(K,{value:i.pointsPolicy,short:!1}):e.jsx("span",{className:"muted",children:"not set"})],["Pool weight policy",i!=null&&i.poolWeightPolicy?e.jsx(K,{value:i.poolWeightPolicy,short:!1}):e.jsx("span",{className:"muted",children:"not set"})],["Minimum accounted pool power",i!=null&&i.minimumAccountedPoolPower?`${C(i.minimumAccountedPoolPower,4)} ANTS`:"—"],["Your weighted buyer points",i?W(i.totals.buyerWeightedPoints):"…"]]}),e.jsx("p",{className:"hint mt",children:"Points are raw usage units recorded on chain per epoch. Weighted points apply the pool weight policy; pools below the minimum accounted power earn no usage rewards."})]})]})}function Ar(t){return t.reduce((s,n)=>{try{return s+BigInt(n)}catch{return s}},0n).toString()}const Ht=u.createContext(null),en=typeof document>"u"?u.useEffect:u.useLayoutEffect;function Kt({title:t,children:s,onClose:n,busy:a=!1}){const r=u.useRef(!1),l=u.useRef(a);en(()=>{l.current=a},[a]);const[i]=u.useState(()=>typeof document<"u"&&document.activeElement instanceof HTMLElement?document.activeElement:null);u.useEffect(()=>()=>{queueMicrotask(()=>{i!=null&&i.isConnected&&i.focus({preventScroll:!0})})},[i]);const c=e.jsx(Dt,{isOpen:!0,title:t,size:"lg",overlayClassName:"ants-stake-overlay ants-action-overlay",onClose:()=>{!l.current&&!r.current&&n()},children:e.jsx(Ht.Provider,{value:r,children:s})});return typeof document>"u"?c:Ns.createPortal(c,ae().portalTarget())}function tn({title:t,hideTitle:s=!1,summary:n,children:a,confirmLabel:r="Confirm",danger:l,disabled:i,busy:c,error:o,onConfirm:h,onCancel:d,embedded:m,cancelLabel:x="Cancel"}){const f=u.useContext(Ht),j=m||f!==null;en(()=>(f&&(f.current=c===!0),()=>{f&&(f.current=!1)}),[c,f]);const y=e.jsxs(we,{className:"confirm",tone:l?"danger":"surface",role:"region","aria-label":t,children:[j&&!s?e.jsx("div",{className:"confirm-title",children:t}):null,n&&n.length>0?e.jsx("dl",{className:"facts",children:n.map(([E,P],T)=>e.jsx(Er,{label:E,value:P},`${E}-${T}`))}):null,a,o?e.jsx("div",{className:"error-text",children:o}):null,e.jsxs("div",{className:"confirm-actions",children:[e.jsx(G,{variant:l?"danger":"primary",onClick:h,disabled:i||c,children:c?"Sending…":r}),e.jsx(G,{variant:"outline",onClick:d,disabled:c,children:x})]})]});return j?y:e.jsx(Kt,{title:t,onClose:d,busy:c,children:y})}function Er({label:t,value:s}){return e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Jt(t=!1){const{config:{readOnly:s,selectedAddress:n,walletAddress:a,browserWallet:r},overview:l,overviewError:i}=Ee(),{running:c}=Ae(),o=Vs();return r&&!o?{blocked:!0,label:"Connect wallet",reason:"Connect wallet before submitting a transaction."}:o!=null&&o.reason?{blocked:!0,reason:o.reason,label:o.label}:s?{blocked:!0,reason:"Read-only mode: no wallet is available to sign."}:n&&!t&&n.toLowerCase()!==(a==null?void 0:a.toLowerCase())?{blocked:!0,reason:`Connect the selected account wallet ${n} for seller and staking actions.`}:!l||i?{blocked:!0,reason:"Wallet information is unavailable. Refresh before sending a transaction."}:BigInt(l.wallet.signingWalletEth??l.wallet.eth)===0n?{blocked:!0,reason:"The signing wallet needs ETH on the selected network for transaction fees."}:c?{blocked:!0,reason:"Another action is still running."}:{blocked:!1,reason:void 0}}function ge(t){const s=Ae(),n=t.body,a=t.path==="/api/rewards/claim"&&(n==null?void 0:n.scope)==="buyer"||t.path==="/api/rewards/stake-usage"&&(n==null?void 0:n.side)==="buyer",r=Jt(a),[l,i]=u.useState(!1),[c,o]=u.useState(null),[h,d]=u.useState(!1),m=u.useRef(!1),x=u.useContext(Ht),f=!t.children,j=r.blocked||t.disabled===!0,y=r.reason??(t.disabled?t.disabledReason:void 0),E=async()=>{var N;if(j||m.current||f&&t.confirmDisabled)return;const A=((N=t.validate)==null?void 0:N.call(t))??null;o(A),A===null&&(f?await P():i(!0))},P=async()=>{var N,U;if(j||t.confirmDisabled||m.current)return;const A=((N=t.validate)==null?void 0:N.call(t))??null;if(A!==null){o(A);return}m.current=!0,f&&x&&(x.current=!0),d(!0),o(null);try{await s.start(t.path,t.body),i(!1),(U=t.onStarted)==null||U.call(t)}catch(k){s.pushToast({tone:"danger",title:`${t.title??t.label} failed`,body:Ce(k),sticky:!0})}finally{m.current=!1,f&&x&&(x.current=!1),d(!1)}},T=t.variant==="primary"?"primary":t.variant==="danger"?"danger":"outline";return e.jsxs("div",{className:"action",children:[l?null:e.jsx("span",{className:"btn-wrap",title:y,children:e.jsx(G,{variant:T,size:t.size==="sm"?"sm":"md",onClick:E,disabled:j||h||f&&t.confirmDisabled,children:h&&f?"Sending…":r.label??t.label})}),c&&!l?e.jsx("div",{className:"error-text",children:c}):null,l?e.jsx(tn,{title:t.title??t.label,summary:t.summary,confirmLabel:r.label??t.confirmLabel??t.label,danger:t.variant==="danger",disabled:j||t.confirmDisabled,busy:h,error:c,onConfirm:()=>{P()},onCancel:()=>{i(!1),o(null)},children:t.children}):null]})}function le({tone:t="neutral",mono:s,title:n,children:a}){const r=["pill",t!=="neutral"?`pill--${t}`:"",s?"pill--mono":""].filter(Boolean).join(" ");return e.jsx("span",{className:r,title:n,children:a})}const vt="antseed-wash-trading-seller-proof";function Ir({data:t}){const s=t.registry;return e.jsx("div",{className:"stack",children:s?e.jsxs(e.Fragment,{children:[e.jsx(X,{items:[["Registry",e.jsx(K,{value:s.address})],["Enforced",t.enforced?e.jsx(le,{tone:"accent",children:"enforced"}):e.jsx(le,{tone:"muted",children:"not enforced"})],["Flag threshold",`${ie(s.thresholdBps)} of seller volume`],["Period blocks",`${W(s.periodStartBlock)} – ${W(s.periodEndBlock)}`]]}),e.jsxs(de,{summary:"Details",children:[e.jsx(X,{items:[["Verifier",e.jsx(K,{value:s.verifier,short:!1})],["Verifier hash",e.jsx("span",{className:"break mono small",children:s.verifierHash})],["Blockhash store",e.jsx(K,{value:s.blockhashStore,short:!1})],["Seller program vkey",e.jsx("span",{className:"break mono small",children:s.sellerProgramVKey})],["Points policy",t.pointsPolicy?e.jsx(K,{value:t.pointsPolicy,short:!1}):e.jsx("span",{className:"muted",children:"not set"})],...t.policies.map(n=>["Policy → pinned registry",e.jsxs("span",{children:[e.jsx(K,{value:n.address})," → ",n.washTradingRegistry?e.jsx(K,{value:n.washTradingRegistry}):e.jsx("span",{className:"muted",children:"not pinned"})]})])]}),e.jsx("div",{className:"hint mt",children:"Enforced means the active points policy pins the registry, so flagged sellers earn no usage points."})]})]}):e.jsx("span",{className:"muted",children:"No wash-trading registry is deployed on this chain."})})}function sn({data:t,seller:s}){const n=t.seller;return n?e.jsxs("div",{className:"stack",children:[e.jsxs("div",{className:"row",children:[n.isProvenWashTrader?e.jsx(le,{tone:"danger",children:"flagged wash trader"}):e.jsx(le,{tone:"accent",children:"not flagged"}),e.jsxs("span",{className:"muted small",children:["proven share ",e.jsx("span",{className:`mono ${n.isProvenWashTrader?"danger":""}`,children:ie(n.provenWashShareBps)})]})]}),e.jsx(X,{items:[["Proven wash volume",`${ce(n.provenWashVolume)} USDC`],["Total seller volume",`${ce(n.totalSellerVolume)} USDC`]]}),e.jsx(de,{summary:"Evidence",children:e.jsx(X,{items:[["Seller",e.jsx(K,{value:n.seller,short:!1})],["Evidence digest",e.jsx("span",{className:"break mono small",children:n.evidenceDigest})]]})})]}):e.jsxs("div",{className:"muted small",children:["No verification record for ",e.jsx(K,{value:s}),"."]})}function Tr(){const{address:t}=Ie(),s=V("verification:own",()=>q.verification(),5*6e4);return s.error&&!s.data?e.jsx(ne,{error:s.error,onRetry:s.refresh}):s.data?s.data.registry?e.jsx(sn,{data:s.data,seller:t}):e.jsx("span",{className:"muted",children:"No wash-trading registry is deployed on this chain."}):e.jsxs("span",{className:"muted small",children:[e.jsx(mt,{})," loading…"]})}function $r(){const[t,s]=u.useState(""),[n,a]=u.useState(null),r=V(n?`verification:${n.toLowerCase()}`:null,()=>q.verification(n??void 0),5*6e4),l=La(t.trim());return e.jsxs("div",{className:"stack",children:[e.jsxs("div",{className:"form-row",children:[e.jsx(qe,{label:"Seller address",width:"lg",value:t,onChange:i=>s(i.target.value),placeholder:"0x…"}),e.jsx(G,{variant:"outline",onClick:()=>a(t.trim()),disabled:!l,children:"Look up"})]}),t.trim()&&!l?e.jsx("div",{className:"error-text",children:"Enter a 0x-prefixed 20-byte address."}):null,n&&r.loading&&!r.data?e.jsxs("span",{className:"muted small",children:[e.jsx(mt,{})," loading…"]}):null,n&&r.error&&!r.data?e.jsx(ne,{error:r.error,onRetry:r.refresh}):null,n&&r.data?e.jsx(sn,{data:r.data,seller:n}):null]})}function Pr(t){if(typeof t!="object"||t===null)return null;const s=t.kind;return typeof s=="string"?s:null}function Rr(t){if(typeof t!="object"||t===null)return null;const s=t,n=s.seller;if(typeof n=="string")return n;const a=s.claim;if(typeof a=="object"&&a!==null){const r=a.seller;if(typeof r=="string")return r}return null}function Mr(){const[t,s]=u.useState(null),[n,a]=u.useState(null),r=async l=>{var c;const i=(c=l.target.files)==null?void 0:c[0];if(s(null),a(null),!!i)try{const o=JSON.parse(await i.text()),h=Pr(o);if(h!==vt){a(`Expected a proof file with kind "${vt}"${h?`, got "${h}"`:""}.`);return}s({name:i.name,artifact:o,kind:h,seller:Rr(o)})}catch(o){a(`Could not parse file as JSON: ${Ce(o)}`)}};return e.jsxs("div",{className:"stack",children:[e.jsxs("div",{className:"hint",children:["Pick a seller proof produced by the loop-proof tooling (",e.jsx("code",{children:vt}),"). Only the kind is checked here; the registry verifies the proof on chain. Submission may take several transactions (block references, chunks, finalize)."]}),e.jsxs("div",{className:"form-row",children:[e.jsx(Ue,{label:"Proof file",children:e.jsx("input",{type:"file",accept:"application/json,.json",onChange:l=>{r(l)}})}),e.jsx(ge,{label:"Submit proof",variant:"primary",title:"Submit seller proof",path:"/api/verification/submit",body:{artifact:t==null?void 0:t.artifact},disabled:!t,disabledReason:"Choose a valid proof file first."})]}),n?e.jsx("div",{className:"error-text",children:n}):null]})}function Lr(){const[t,s]=u.useState(""),[n,a]=u.useState(null),[r,l]=u.useState(null),[i,c]=u.useState(!1),o=async()=>{const h=t.trim();if(h){c(!0),l(null),a(null);try{a(await q.proofStatus(h))}catch(d){l(Ce(d))}finally{c(!1)}}};return e.jsxs("div",{className:"stack",children:[e.jsxs("div",{className:"form-row",children:[e.jsx(qe,{label:"Proof id",width:"lg",value:t,onChange:h=>s(h.target.value),placeholder:"0x…"}),e.jsx(G,{variant:"outline",onClick:()=>{o()},disabled:!t.trim()||i,children:i?"Looking up…":"Look up"})]}),r?e.jsx("div",{className:"error-text",children:r}):null,n?e.jsx(X,{items:[["Proof id",e.jsx("span",{className:"break mono small",children:n.proofId})],["Staged",n.staged?"yes":"no"],["Finalized",n.finalized?"yes":"no"],["Authenticated block references",W(n.authenticatedBlockReferenceCount)],["Authenticated block chunks",W(n.authenticatedBlockChunkCount)]]}):null]})}function Br(){const t=V("network",q.network,2e4),{data:s,refresh:n}=t,a=pt(1e3),r=u.useRef(null);u.useEffect(()=>{const i=()=>{document.visibilityState==="visible"&&n()},c=window.setInterval(i,6e4);return document.addEventListener("visibilitychange",i),()=>{window.clearInterval(c),document.removeEventListener("visibilitychange",i)}},[n]),u.useEffect(()=>{if(!s||r.current===s.epoch.current)return;const i=Math.max(1e3,s.epoch.secondsToBoundary*1e3-(Date.now()-s.fetchedAt)),c=window.setTimeout(()=>{r.current=s.epoch.current,document.visibilityState==="visible"&&n()},i);return()=>window.clearTimeout(c)},[s,n]);const l=!!s&&(!!t.error||a-s.fetchedAt>9e4);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"row",children:[e.jsx("h1",{className:"page-title",children:"Network"}),e.jsx(G,{variant:"outline",size:"sm",onClick:n,disabled:t.loading,children:"Refresh network"})]}),t.error&&!s?e.jsx(ne,{error:t.error,onRetry:n}):null,!s&&t.loading?e.jsx(tt,{rows:5}):null,s&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"hint",children:[s.evmChainId===31337?"Local Anvil · test-chain data, not live production":`${s.chainId} · chain ${s.evmChainId}`," · block ",s.blockNumber," · ",ue(s.blockTimestamp)]}),s.activation!=="active"&&e.jsx("p",{className:"status-line",children:s.activation==="not-active"?"The configured reward stack is not the registry’s active stack. These are its configured allowances, not a claim of active reward distribution.":"Registry activation could not be verified."}),s.epoch.effective!==null&&s.epoch.current<s.epoch.effective&&e.jsxs("p",{className:"hint",children:["Recognized-usage rewards start at epoch ",s.epoch.effective,". The current epoch is before reward activation."]}),l&&e.jsxs("p",{className:"status-line",role:"status",children:["Stale network snapshot. ",t.error??"Refresh to read the latest contract state."]}),s.errors.length>0&&e.jsxs("div",{className:"status-line",role:"status",children:["Some contract reads are unavailable: ",s.errors.join(" ")]}),e.jsx(Ur,{data:s,now:a}),e.jsx(Nr,{data:s}),e.jsx(Z,{children:e.jsxs(de,{summary:"Emission schedule and contract details",children:[e.jsx(X,{items:[["First recognized-usage reward epoch",s.epoch.effective??"Unavailable"],["Epoch length",ht(s.epoch.epochDuration)],["Genesis",ue(s.epoch.genesis)],["Initial scheduled emission",re(s.initialEmission)],["Halving interval",`${s.halvingInterval} epochs`],["Scheduled cumulative emission through this epoch",re(s.cumulativeScheduled)],["Total active stake",re(s.totalActiveStake)],["Total power weight",s.totalPowerWeight===null?"Unavailable":C(s.totalPowerWeight)],...Object.entries(s.contracts).map(([i,c])=>[i,e.jsx(K,{value:c,short:!1})])]}),e.jsx("p",{className:"hint",children:"Scheduled emission is an allowance, not a minted-token counter. Current supply is read separately from the token contract. All main network figures use the same snapshot block."})]})})]}),e.jsx(Z,{children:e.jsx(de,{summary:"Your usage history and network comparisons",lazy:!0,children:e.jsx(Cr,{})})}),e.jsx(Z,{children:e.jsx(de,{summary:"Legacy emissions",lazy:!0,children:e.jsx(Fr,{})})}),e.jsx(Z,{children:e.jsx(de,{summary:"Verification registry",lazy:!0,children:e.jsx(Dr,{})})})]})}function Ur({data:t,now:s}){const n=Math.max(0,t.epoch.secondsToBoundary-Math.floor((s-t.fetchedAt)/1e3));return e.jsxs(Vt,{children:[e.jsx(me,{label:"Current epoch",value:t.epoch.current,sub:ue(t.epoch.genesis+t.epoch.current*t.epoch.epochDuration)}),e.jsx(me,{label:"Next epoch starts in",value:n>0?ht(n):"Awaiting chain update",sub:ue(t.epoch.nextBoundaryAt)}),e.jsx(me,{label:"Scheduled epoch emission · ANTS",value:t.emission===null?"Unavailable":C(t.emission),sub:"Allowance, not tokens already minted"}),e.jsx(me,{label:"Current token supply · ANTS",value:t.totalSupply===null?"Unavailable":C(t.totalSupply),sub:`Maximum supply: ${re(t.maxSupply)}`})]})}function Fr(){const t=V("network:legacy",q.networkLegacy,3e5);if(t.error)return e.jsx(ne,{error:t.error,onRetry:t.refresh});if(t.loading&&!t.data)return e.jsx(tt,{rows:2});const s=t.data;return s?e.jsxs(e.Fragment,{children:[e.jsx(X,{items:[["Legacy contract",e.jsx(K,{value:s.contract})],["Legacy epoch",s.currentEpoch],["Legacy configured split",`Sellers ${s.sellerPct}% · buyers ${s.buyerPct}% · reserve ${s.reservePct}% · team ${s.teamPct}%`]]}),e.jsx("p",{className:"hint",children:"Historical reward-system configuration. These percentages do not describe the current recognized-usage reward budgets."})]}):e.jsx("p",{className:"muted",children:"No legacy emissions contract configured."})}function Dr(){const t=V("verification:own",()=>q.verification(),3e5);return t.error?e.jsx(ne,{error:t.error,onRetry:t.refresh}):t.data?e.jsx(Ir,{data:t.data}):e.jsx(tt,{rows:3})}const Wr=10000n*10n**18n,Pt=86400,it=1e4,xt=">10.000%",_r=`APY is shown as ${xt} when either end of the range exceeds 10,000%. Ranges at or below 10,000% remain visible.`;function Xe(t){return t==null||!Number.isFinite(t)?"—":t>it?xt:`${t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}%`}function nn(t,s,n){const a=Number(t*10n**18n/s)/1e18,r=Math.expm1(Math.log1p(a)*(365*Pt/n))*100;return Number.isFinite(r)?r:null}function Or(t,s,n,a){const r=s==null?void 0:s.yield;if(!s||s.agentId!==t.agentId||!r||r.status==="unavailable"||r.epoch<0||r.reward==null||n===void 0||!Number.isSafeInteger(n)||n<0||t.withdrawn||t.closedAtEpoch!==0||t.state==="closed"||t.state==="withdrawn"||t.state==="matured")return null;const l=r.endsAt-r.startsAt;if(!Number.isFinite(l)||l<=0)return null;try{const i=BigInt(t.amount),c=BigInt(s.weight),o=BigInt(r.reward);if(i<=0n||c<0n||o<0n)return null;const h=t.stakeStartEpoch>n,d=h?t.stakeStartEpoch===n+1?t.nextPower:void 0:t.power;let m;if(d!=null)m=BigInt(d);else{const j=(h?t.maxLockedNext:t.maxLocked)?a:t.stakeEndEpoch-Math.max(n,t.stakeStartEpoch);if(j===void 0||!Number.isSafeInteger(j)||j<=0)return null;const y=BigInt(t.weightAmount);if(y<=0n)return null;m=y*BigInt(j)}if(m<=0n)return null;const x=h?c+m:c;return x<=0n||m>x?null:nn(o*m/x,i,l)}catch{return null}}function an(t,s){const n=t?t.endsAt-t.startsAt:0;if(!t||!Number.isFinite(n)||n<=0||t.minLockEpochs==null||t.maxLockEpochs==null)return{epochs:null,actualDays:null,status:"unavailable"};const a=Math.round(s*Pt/n);return!Number.isSafeInteger(a)||a<1||a<t.minLockEpochs||a>t.maxLockEpochs?{epochs:null,actualDays:null,status:"unsupported"}:{epochs:a,actualDays:a*n/Pt,status:"supported"}}function Rt(t,s){const{epochs:n}=an(t,s);if(n===null)return{epochs:null,apy:null};const a=rn(t,n,Wr.toString());return{epochs:a===null?null:n,apy:a}}function rn(t,s,n,a=0){if(!t||t.status==="unavailable"||t.epoch<0||t.reward==null||t.power==null||t.minLockEpochs==null||t.maxLockEpochs==null)return null;const r=t.endsAt-t.startsAt;if(!Number.isFinite(r)||r<=0||!Number.isSafeInteger(s)||s<1||s<t.minLockEpochs||s>t.maxLockEpochs||!Number.isSafeInteger(a)||a<0)return null;try{const l=BigInt(t.reward),i=BigInt(t.power),c=BigInt(n);if(l<0n||i<=0n||c<=0n)return null;const h=c*(10000n+BigInt(a))/10000n*BigInt(s),d=l*h/(i+h);return nn(d,c,r)}catch{return null}}function Gt(t){return{oneWeek:Rt(t,7),twoYears:Rt(t,730)}}function zr(t){return[{label:"1 day",days:1},{label:"1 month",days:30},{label:"1 year",days:365},{label:"2 years",days:730}].map(s=>({...s,...an(t,s.days),apy:Rt(t,s.days).apy}))}const Qt={isPartial:t=>t.source==="chain"&&!!t.sourceError,isSyncing:t=>!!t.walletSyncing,retryOnError:!1},qr={isSyncing:t=>!!t.walletSyncing};function Zt({left:t,top:s,title:n,rows:a}){const r=typeof window<"u"&&t>window.innerWidth-240;return e.jsxs("div",{className:r?"chart-tip chart-tip--left":"chart-tip",style:{left:t,top:s},role:"status","aria-live":"polite",children:[e.jsx("div",{className:"chart-tip-title",children:n}),a.map(l=>e.jsxs("div",{className:"chart-tip-row",children:[e.jsx("i",{style:l.color?{background:l.color}:void 0,"aria-hidden":"true"}),e.jsx("span",{className:"chart-tip-name",children:l.name}),e.jsxs("span",{className:"chart-tip-value",children:[l.value,l.note?e.jsxs("small",{children:[" ",l.note]}):null]})]},l.name))]})}function Yr(t,s,n,a){if(a<=0||n<=0)return null;const r=Math.floor((t-s)/n);return r<0||r>=a?null:r}function ln(t,s){let n=null,a=Number.POSITIVE_INFINITY;return s.forEach((r,l)=>{const i=Math.abs(r-t);i<a&&(a=i,n=l)}),n}function Xt(t,s,n,a){const[r,l]=u.useState(null);return{hover:r,onPointerMove:h=>{var x;const d=(x=t.current)==null?void 0:x.getBoundingClientRect();if(!d||d.width===0)return;const m=a((h.clientX-d.left)*(s/d.width));m===null?l(null):m!==(r==null?void 0:r.index)&&l({index:m})},onPointerLeave:()=>l(null),setHover:l,clientPoint:(h,d)=>{var x;const m=(x=t.current)==null?void 0:x.getBoundingClientRect();return!m||m.width===0?{left:h,top:d}:{left:m.left+h*(m.width/s),top:m.top+d*(m.height/n)}}}}function Vr(t,s,n){const a=new Map(s.map(r=>[r.epoch,J(r.usdc)]));return t.filter(r=>r.epoch<n).sort((r,l)=>r.epoch-l.epoch).map(r=>{const l=J(r.usdc),i=a.get(r.epoch);return{epoch:r.epoch,volume:l!==null&&l>=0n?l:null,network:i??null,share:l!==null&&l>=0n&&i!=null&&i>0n&&l<=i?l*10000n/i:null}})}function Hr({points:t}){var D,S;const s=u.useId(),n=u.useRef(null),[a,r]=u.useState(800);u.useEffect(()=>{if(!n.current||typeof ResizeObserver>"u")return;const g=new ResizeObserver(w=>{const p=w[0];p&&r(Math.max(280,Math.round(p.contentRect.width)))});return g.observe(n.current),()=>g.disconnect()},[]);const l=t.flatMap(g=>g.volume===null?[]:[g.volume]),i=l.reduce((g,w)=>w>g?w:g,0n)||1000000n,c=t.some(g=>g.share!==null),o=64,h=a-64,d=((D=t[0])==null?void 0:D.epoch)??0,m=((S=t.at(-1))==null?void 0:S.epoch)??d,x=g=>d===m?a/2:o+(g-d)/(m-d)*(h-o),f=(g,w)=>218-Number(g*1000000n/w)/1e6*180,j=[{key:"volume",name:"Settled volume",scale:i,format:g=>`${ce(String(g))} USDC`},{key:"share",name:"Network volume share",scale:10000n,format:g=>ie(Number(g))}],y=(g,w)=>{let p=null;return t.map(I=>{const _=I[g];if(_===null)return p=null,"";const $=p!==null&&I.epoch===p+1?"L":"M";return p=I.epoch,`${$}${x(I.epoch)},${f(_,w)}`}).join(" ")},E=a<500?3:6,P=Math.max(1,Math.ceil((t.length-1)/(E-1))),T=u.useRef(null),A=t.map(g=>x(g.epoch)),{hover:N,onPointerMove:U,onPointerLeave:k,setHover:B,clientPoint:b}=Xt(T,a,270,g=>ln(g,A)),v=N!==null?t[N.index]??null:null,L=[];return v&&(v.volume!==null&&L.push({name:"Settled volume",value:`${ce(String(v.volume))} USDC`,color:"var(--pc-accent)"}),v.network!==null&&L.push({name:"Network volume",value:`${ce(String(v.network))} USDC`,color:"var(--pc-sub)"}),v.share!==null&&L.push({name:"Network share",value:ie(Number(v.share)),color:"var(--pc-blue)"})),e.jsxs("div",{className:"pool-chart",children:[e.jsxs("div",{className:"pool-chart-legend",children:[e.jsxs("h4",{children:[e.jsx("span",{className:"pool-chart-dot"}),"Settled volume · left axis"]}),e.jsxs("h4",{className:"pool-chart--share",children:[e.jsx("span",{className:"pool-chart-dot"}),"Network volume share · right axis"]})]}),e.jsxs("div",{ref:n,className:"pool-chart-plot",children:[l.length?e.jsxs("svg",{ref:T,viewBox:`0 0 ${a} 270`,role:"img","aria-labelledby":s,onPointerMove:U,onPointerLeave:k,children:[e.jsx("title",{id:s,children:"Settled volume and network volume share by completed epoch. USDC on the left axis; 0–100% on the right axis. Hover anywhere over the chart for that epoch's values."}),v?e.jsx("line",{x1:x(v.epoch),x2:x(v.epoch),y1:38,y2:218,className:"chart-crosshair","aria-hidden":"true"}):null,e.jsx("text",{x:o,y:"16",className:"pool-chart-axis-volume",children:"USDC"}),e.jsx("text",{x:h,y:"16",textAnchor:"end",className:"pool-chart-axis-share",children:"Share · %"}),[0,1,2,3,4].map(g=>e.jsxs("g",{children:[e.jsx("line",{x1:o,x2:h,y1:38+g*45,y2:38+g*45,className:"pool-chart-grid"}),e.jsx("text",{x:o-9,y:42+g*45,textAnchor:"end",className:"pool-chart-axis-volume",children:We(String(i*BigInt(4-g)/4n))}),e.jsxs("text",{x:h+9,y:42+g*45,textAnchor:"start",className:"pool-chart-axis-share",children:[100-g*25,"%"]})]},g)),j.map(g=>e.jsxs("g",{className:g.key==="share"?"pool-chart--share":void 0,children:[t.some(w=>w[g.key]!==null)&&e.jsx("path",{d:y(g.key,g.scale),className:"pool-chart-line","data-series":g.key}),t.map((w,p)=>{const I=w[g.key];if(I===null)return null;const _=`${g.name}, epoch ${w.epoch}: ${g.format(I)}`;return e.jsx("circle",{cx:x(w.epoch),cy:f(I,g.scale),r:v===w?5.5:4,tabIndex:0,role:"img","aria-label":_,onFocus:()=>B({index:p}),onBlur:k,children:e.jsx("title",{children:_})},w.epoch)})]},g.key)),t.filter((g,w)=>w%P===0||w===t.length-1).map(g=>e.jsx("text",{x:x(g.epoch),y:"242",textAnchor:"middle",children:g.epoch},g.epoch)),e.jsx("text",{x:a/2,y:"265",textAnchor:"middle",children:"Epoch"})]}):e.jsx("div",{className:"pool-chart-empty",children:"Settlement volume unavailable for completed epochs."}),v&&L.length>0?e.jsx(Zt,{...b(x(v.epoch),38),title:`Epoch ${v.epoch}`,rows:L}):null]}),l.length>0&&!c&&e.jsx("p",{className:"hint",children:"Network share unavailable for these epochs."})]})}function Kr({volumes:t,networkVolumes:s,currentEpoch:n}){const a=Vr(t,s,n);return e.jsxs(e.Fragment,{children:[e.jsx(Hr,{points:a}),e.jsx("p",{className:"hint",children:"Network share = seller settled volume ÷ total network settled volume in the same epoch. The right axis stays at 0–100%; each line uses its own units. Missing observations leave gaps; a missing or zero network total is not a 0% share."})]})}function Jr(t){const s=new Map;for(const n of t){const a=n.name.trim(),r=a.toLowerCase(),l=s.get(r)??{name:a,providers:[]};l.providers.includes(n.provider)||l.providers.push(n.provider),s.set(r,l)}return[...s.values()]}function Gr({address:t}){const s=V(t?`seller-models:${t}`:null,()=>q.sellerModels(t)),n=s.data;return e.jsxs("section",{className:"pool-section",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Models & usage"}),e.jsx("span",{className:"small muted",children:"Sourced from Antscan"})]}),t?n?e.jsxs(e.Fragment,{children:[s.error&&e.jsx("p",{className:"hint",children:"Model data could not refresh. Showing the previously loaded snapshot."}),e.jsxs("h4",{className:"pool-subheading",children:["Observed model usage ",e.jsxs("span",{className:"small muted",children:["Last completed epoch",n.period?` · Epoch ${n.period.epoch}`:""]})]}),n.usageStatus==="unavailable"?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"hint",children:n.usageError??"Model usage is unavailable."}),e.jsx("button",{type:"button",className:"link-button",onClick:s.refresh,disabled:s.loading,children:"Retry model data"})]}):n.usage.length?e.jsx("div",{className:"table-wrap",tabIndex:0,role:"region","aria-label":"Observed model usage",children:e.jsxs("table",{className:"table pool-model-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Model"}),e.jsx("th",{className:"num",children:"Requests"}),e.jsx("th",{className:"num",children:"Input tokens"}),e.jsx("th",{className:"num",children:"Output tokens"}),e.jsx("th",{className:"num",children:"Volume · USDC"})]})}),e.jsx("tbody",{children:n.usage.map(a=>e.jsxs("tr",{children:[e.jsx("td",{children:a.name}),e.jsx("td",{className:"num",children:W(a.requests)}),e.jsx("td",{className:"num",children:W(a.inputTokens)}),e.jsx("td",{className:"num",children:W(a.outputTokens)}),e.jsx("td",{className:"num",children:ce(a.volumeUsdc)})]},a.serviceId))})]})}):e.jsx("p",{className:"hint",children:"No indexed model usage for this seller in this epoch."}),n.totals&&e.jsxs("p",{className:"hint",children:["Settled volume: ",ce(n.totals.settledVolumeUsdc)," USDC · Model-attributed: ",ce(n.totals.attributedVolumeUsdc)," USDC · Unattributed: ",n.totals.unattributedVolumeUsdc===null?"unavailable (model totals exceed settlements)":`${ce(n.totals.unattributedVolumeUsdc)} USDC`]}),e.jsxs("section",{className:"pool-catalog","aria-label":"Advertised models",children:[e.jsxs("h4",{className:"pool-subheading",children:["Advertised models ",e.jsx("span",{className:"small muted",children:n.catalogStatus==="live"?"Latest discovered catalog":n.catalogStatus==="stale"?"Stale catalog":"Unavailable"})]}),e.jsx("p",{className:"hint",children:"Seller-advertised models, not a guarantee of availability."}),n.catalogStatus==="unavailable"?e.jsx("p",{className:"hint",children:"Antscan model catalog is unavailable."}):n.offerings.length?e.jsx("ul",{className:"pool-model-tags","aria-label":"Advertised model names",children:Jr(n.offerings).map(a=>e.jsx("li",{children:e.jsx(le,{title:`Providers: ${a.providers.join(", ")}`,children:a.name})},a.name))}):e.jsx("p",{className:"hint",children:"No advertised models found in Antscan’s catalog."}),n.catalogUpdatedAt!==null&&e.jsxs("p",{className:"small muted",children:["Catalog snapshot ",ue(Math.floor(n.catalogUpdatedAt/1e3))]})]})]}):s.error?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"hint",children:"Model data could not load. Pool statistics remain available."}),e.jsx("p",{className:"hint",children:s.error}),e.jsx("button",{type:"button",className:"link-button",onClick:s.refresh,disabled:s.loading,children:"Retry model data"})]}):e.jsx("p",{className:"hint",children:"Loading provider models and last-epoch usage…"}):e.jsx("p",{className:"hint",children:"Bind a seller to see its model catalog."})]})}function Qr(t){const s=u.useRef(null),[n,a]=u.useState(t);return u.useEffect(()=>{if(!s.current||typeof ResizeObserver>"u")return;const r=new ResizeObserver(l=>{const i=l[0];i&&a(Math.max(240,Math.round(i.contentRect.width)))});return r.observe(s.current),()=>r.disconnect()},[]),{ref:s,width:n}}function bs(t){if(t.max!==void 0)return t.max;const n=t.values.filter(a=>a!==null&&a>0n).reduce((a,r)=>r>a?r:a,0n);return n===0n?1n:n}function js({epochs:t,bars:s,line:n,title:a,height:r=200,compact:l=!1}){var xe;const i=u.useId(),{ref:c,width:o}=Qr(640),h=l?48:60,d=n?l?44:56:12,m=14,x=28,f=Math.max(40,o-h-d),j=r-m-x,y=Math.max(1,t.length),E=f/y,P=Math.max(3,Math.min(28,E*.58)),T=bs(s),A=n?bs(n):1n,N=(F,z)=>Number(F*1000000n/z)/1e6,U=F=>m+j-N(F,T)*j,k=F=>m+j-N(F,A)*j,B=F=>h+E*F+E/2,b=s.values.some(F=>F!==null),v=!!n&&n.values.some(F=>F!==null),L=[0,1,2,3,4],D=o<480?4:8,S=Math.max(1,Math.ceil(y/D)),g=s.tick??s.format,w=n?n.tick??n.format:null,p=u.useRef(null),{hover:I,onPointerMove:_,onPointerLeave:$,setHover:M,clientPoint:O}=Xt(p,o,r,F=>Yr(F,h,E,t.length)),H=F=>M({index:F}),Y=(I==null?void 0:I.index)??null,ee=[];if(Y!==null){const F=s.values[Y];F!=null&&ee.push({name:s.name,value:s.format(F),color:"var(--pc-accent)",note:(xe=s.provisional)!=null&&xe[Y]?"estimated":void 0});const z=n==null?void 0:n.values[Y];n&&z!=null&&ee.push({name:n.name,value:n.format(z),color:"var(--pc-blue)"})}let pe="";if(n){let F=null;pe=n.values.map((z,oe)=>{if(z===null)return F=null,"";const ve=F!==null&&oe===F+1?"L":"M";return F=oe,`${ve}${B(oe).toFixed(1)},${k(z).toFixed(1)}`}).join(" ")}return e.jsxs("div",{className:"chart",children:[e.jsxs("div",{className:"chart-legend",children:[e.jsxs("span",{className:"chart-legend-item chart-legend-item--bars",children:[e.jsx("i",{}),s.name]}),n?e.jsxs("span",{className:"chart-legend-item chart-legend-item--line",children:[e.jsx("i",{}),n.name]}):null]}),e.jsxs("div",{ref:c,className:"chart-plot",children:[b||v?e.jsxs("svg",{ref:p,viewBox:`0 0 ${o} ${r}`,role:"img","aria-labelledby":i,onPointerMove:_,onPointerLeave:$,children:[e.jsx("title",{id:i,children:a}),Y!==null?e.jsxs("g",{className:"chart-hover","aria-hidden":"true",children:[e.jsx("rect",{x:B(Y)-E/2,y:m,width:E,height:j,className:"chart-hover-band"}),e.jsx("line",{x1:B(Y),x2:B(Y),y1:m,y2:m+j,className:"chart-crosshair"})]}):null,L.map(F=>{const z=m+j*F/4,oe=T*BigInt(4-F)/4n,ve=A*BigInt(4-F)/4n;return e.jsxs("g",{children:[e.jsx("line",{x1:h,x2:h+f,y1:z,y2:z,className:"chart-grid"}),e.jsx("text",{x:h-8,y:z+4,textAnchor:"end",className:"chart-axis chart-axis--bars",children:g(oe)}),n&&w?e.jsx("text",{x:h+f+8,y:z+4,textAnchor:"start",className:"chart-axis chart-axis--line",children:w(ve)}):null]},F)}),e.jsx("g",{className:"chart-bars",children:s.values.map((F,z)=>{var Ye;if(F===null)return null;const oe=((Ye=s.provisional)==null?void 0:Ye[z])===!0,ve=U(F),be=`${s.name}, epoch ${t[z]}: ${s.format(F)}${oe?" (estimated)":""}`;return e.jsx("rect",{x:B(z)-P/2,y:Math.min(ve,m+j-1),width:P,height:Math.max(1,m+j-ve),rx:Math.min(3,P/3),className:`${oe?"chart-bar chart-bar--provisional":"chart-bar"}${Y===z?" chart-bar--hover":""}`,tabIndex:0,role:"img","aria-label":be,onFocus:()=>H(z),onBlur:$,children:e.jsx("title",{children:be})},t[z])})}),n&&v?e.jsxs("g",{className:"chart-line-group",children:[e.jsx("path",{d:pe,className:"chart-line","data-series":n.key}),n.values.map((F,z)=>{if(F===null)return null;const oe=`${n.name}, epoch ${t[z]}: ${n.format(F)}`;return e.jsx("circle",{cx:B(z),cy:k(F),r:Y===z?5:3.5,className:"chart-dot",tabIndex:0,role:"img","aria-label":oe,onFocus:()=>H(z),onBlur:$,children:e.jsx("title",{children:oe})},t[z])})]}):null,t.map((F,z)=>z%S===0||z===t.length-1?e.jsx("text",{x:B(z),y:r-8,textAnchor:"middle",className:"chart-axis chart-axis--x",children:F},F):null)]}):e.jsx("div",{className:"chart-empty",children:"No indexed data for these epochs."}),Y!==null&&ee.length>0?e.jsx(Zt,{...O(B(Y),m),title:`Epoch ${t[Y]}`,rows:ee}):null]})]})}function Zr({values:t,width:s=96,height:n=26,label:a,tone:r="accent",labels:l,format:i}){const c=u.useId(),o=t.map(p=>p===null?null:Number(p)),h=o.filter(p=>p!==null&&Number.isFinite(p)),d=u.useRef(null),m=o.length>1?(s-2)/(o.length-1):0,x=p=>1+p*m,f=o.map((p,I)=>p===null||!Number.isFinite(p)?Number.POSITIVE_INFINITY:x(I)),{hover:j,onPointerMove:y,onPointerLeave:E,clientPoint:P}=Xt(d,s,n,p=>l?ln(p,f):null);if(h.length<2)return e.jsx("span",{className:"sparkline sparkline--empty","aria-label":a,role:"img",children:"·"});const T=Math.max(...h),A=Math.min(...h,0),N=T-A||1,U=2,k=p=>n-U-(p-A)/N*(n-U*2);let B="",b="",v=null;o.forEach((p,I)=>{if(p===null||!Number.isFinite(p)){v=null;return}B+=`${v===null?"M":"L"}${x(I).toFixed(1)},${k(p).toFixed(1)} `,v=I});const L=o.findIndex(p=>p!==null),D=o.length-1-[...o].reverse().findIndex(p=>p!==null);L>=0&&D>=L&&(b=`${B.trim()} L${x(D).toFixed(1)},${n} L${x(L).toFixed(1)},${n} Z`);const S=o[D],g=j!==null?o[j.index]:null,w=j!==null&&g!==null&&g!==void 0&&Number.isFinite(g)?{index:j.index,value:g}:null;return e.jsxs("span",{className:"sparkline-wrap",children:[e.jsxs("svg",{ref:d,className:`sparkline sparkline--${r}`,width:s,height:n,viewBox:`0 0 ${s} ${n}`,role:"img","aria-label":a,onPointerMove:y,onPointerLeave:E,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:c,x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0",stopColor:"currentColor",stopOpacity:"0.28"}),e.jsx("stop",{offset:"1",stopColor:"currentColor",stopOpacity:"0"})]})}),b?e.jsx("path",{d:b,fill:`url(#${c})`,stroke:"none"}):null,e.jsx("path",{d:B.trim(),fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round"}),S!=null&&Number.isFinite(S)?e.jsx("circle",{cx:x(D),cy:k(S),r:"2",fill:"currentColor"}):null,w?e.jsx("circle",{cx:x(w.index),cy:k(w.value),r:"3",className:"sparkline-hover","aria-hidden":"true"}):null]}),w?e.jsx(Zt,{...P(x(w.index),0),title:(l==null?void 0:l[w.index])??"",rows:[{name:"Settled volume",value:i?i(w.value):String(w.value)}]}):null]})}function es({value:t,min:s=1,max:n,onChange:a,label:r="Lock",disabled:l,startEpoch:i,showUnlockDate:c=!0}){const o=he(),h=Math.min(Math.max(t,s),n),d=i==null?null:i+h,m=o&&d!==null?rt(De(d,o.genesis,o.epochDuration)):null;return e.jsxs("label",{className:"field lock-slider",children:[e.jsx("span",{className:"field__label",children:r}),e.jsx("input",{type:"range",className:"range",min:s,max:n,step:1,value:h,disabled:l,onChange:x=>a(Number(x.target.value)),"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":h,"aria-valuetext":`${h} ${h===1?"epoch":"epochs"}${m?`; unlocks ${m}`:""}`}),e.jsxs("span",{className:"lock-slider-readout",children:[e.jsx("span",{className:"mono",children:h})," ",h===1?"epoch":"epochs",o?` (${h*o.epochDuration/86400} days)`:"",c&&m?e.jsxs("span",{className:"muted",children:[" ","· unlocks ",e.jsx("span",{className:"mono",children:m})]}):null,h===n?e.jsx("span",{className:"dim",children:" · max"}):null]})]})}function Xr(t,s,n){const a=[];if(t){BigInt(t.buyerUsage.total)>0n&&a.push({id:"buyer",kind:"buyer",label:"Unclaimed buyer rewards",amount:t.buyerUsage.total,available:t.buyerUsage.claimable}),BigInt(t.sellerUsage.total)>0n&&a.push({id:"seller",kind:"seller",label:"Unclaimed seller rewards",amount:t.sellerUsage.total,available:t.sellerUsage.claimable,agentId:t.sellerUsage.agentId});for(const r of t.staker.positions)BigInt(r.amount)>0n&&a.push({id:`staker:${r.id}`,kind:"staker",label:`Staking rewards · position #${r.id}`,amount:r.amount,available:!0,agentId:r.agentId,positionId:r.id})}return n&&a.push({id:"wallet",kind:"wallet",label:"Wallet balance",amount:s,available:!0}),a}function el(t,s,n,a){if(!t.available)throw new Error("This staking source is unavailable.");if(t.agentId!==void 0&&t.agentId!==s)throw new Error("These rewards must be staked into their source pool.");return t.kind==="wallet"?{path:"/api/positions/stake",body:{agentId:s,amount:n,epochs:a}}:t.kind==="staker"?{path:"/api/rewards/restake",body:{positionIds:[t.positionId],epochs:a}}:{path:"/api/rewards/stake-usage",body:{side:t.kind,epochs:a,...t.kind==="buyer"?{stakeAgentId:s}:{}}}}const tl=86400,ws=t=>C(t,18).replace(/,/g,""),sl=[{label:"1w",days:7},{label:"1m",days:30},{label:"6m",days:182},{label:"1y",days:365},{label:"max",days:"max"}];function nl(t){return t.kind==="wallet"?"Stakes wallet ANTS; token approval may be needed.":t.kind==="buyer"?"AI buying rewards. Choose any seller; no claim needed.":t.kind==="seller"?"AI selling rewards. Stakes into your own pool.":"Position rewards. Restakes into the same pool."}function on({config:t,pools:s,balance:n,rewards:a=null,rewardsError:r,defaultAgentId:l,lockedPool:i=!1,onStarted:c,onClose:o,onBusyChange:h}){var as,rs,ls;const{overview:d,config:m}=Ee(),x=he(),f=Ae(),[j,y]=u.useState(null),[E,P]=u.useState(!1),T=u.useRef(!1),[A,N]=u.useState(()=>{var R;return String(l??((R=s[0])==null?void 0:R.agentId)??"")}),[U,k]=u.useState(""),[B,b]=u.useState(null),v=(d==null?void 0:d.wallet.canTransfer)??!1,L=!m.selectedAddress||m.selectedAddress.toLowerCase()===((as=m.walletAddress)==null?void 0:as.toLowerCase()),D=Xr(r?null:a,n??"0",v).filter(R=>L||R.kind==="buyer"),S=i&&l?D.filter(R=>R.agentId===void 0||R.agentId===l):D,g=i?D.length-S.length:0,w=S.find(R=>R.id===B),p=w??S.find(R=>R.available&&R.kind!=="wallet")??S[0]??null,I=Jt((p==null?void 0:p.kind)==="buyer"),_=B!==null&&!w,$=(p==null?void 0:p.kind)==="wallet",M=p===null?"":$?U:ws(p.amount),O=(p==null?void 0:p.agentId)??Number(A),H=(t==null?void 0:t.maxStakeEpochs)??1,Y=Math.max(1,(t==null?void 0:t.minStakeEpochs)??1),[ee,pe]=u.useState(Y);u.useEffect(()=>{t&&pe(R=>Math.max(t.minStakeEpochs,Math.min(R,t.maxStakeEpochs)))},[t==null?void 0:t.minStakeEpochs,t==null?void 0:t.maxStakeEpochs]),u.useEffect(()=>{l&&N(String(l))},[l]),u.useEffect(()=>{!A&&s[0]&&N(String(s[0].agentId))},[A,s]);const xe=s.find(R=>R.agentId===O)??null;let F=null;if(t&&(p!=null&&p.available)&&!_&&Je(M)){const R=It(M,18),Q=p.kind==="staker"?Math.floor(t.restakedRewardWeightBonusBps*ee/t.maxStakeEpochs):0;R!==null&&(F=rn(xe==null?void 0:xe.yield,ee,R.toString(),Q))}const z=()=>{n!==void 0&&k(ws(n))},oe=()=>{if(!p)return"Nothing is available to stake.";if(!O||p.agentId===void 0&&!xe)return"Choose a pool.";if(!Je(M))return"Amount must be a positive decimal number of ANTS.";const R=It(M,18);if(R===null)return"Amount must have no more than 18 decimal places.";if($&&n!==void 0&&R!==null){let Q=0n;try{Q=BigInt(n)}catch{Q=0n}if(R>Q)return`Amount exceeds wallet balance (${C(n,4)} ANTS).`}return t?ee<Y||ee>H?`Lock must be between ${Y} and ${H} epochs.`:null:"Pool configuration is still loading."},ve=t&&d?d.epoch.current+t.stakeActivationDelay:null,be=(p==null?void 0:p.agentId)===void 0&&s.length===0,Ye=m.browserWallet&&m.readOnly?"Connect wallet to stake.":d?_?"The selected rewards are no longer available. Choose a source again.":p&&!p.available?"Use the wallet button above to switch to the authorized wallet for these rewards.":BigInt(d.wallet.signingWalletEth??d.wallet.eth)===0n?"The signing wallet needs ETH on the selected network to pay transaction fees.":null:"Wallet information is unavailable. Refresh before staking.",ss=I.blocked||be||!!Ye||p===null,ns=Ye??I.reason??(be?"No stakeable pools yet.":null),gn=R=>x?Math.max(Y,Math.min(H,Math.round(R*tl/x.epochDuration))):null,bn=async()=>{if(T.current||ss||!p)return;const R=oe();if(R){y(R);return}T.current=!0,P(!0),h==null||h(!0),y(null);try{const Q=el(p,O,M.trim(),ee);await f.start(Q.path,Q.body),c==null||c()}catch(Q){f.pushToast({tone:"danger",title:`${$?"Stake":"Stake rewards"} failed`,body:Ce(Q),sticky:!0})}finally{T.current=!1,P(!1),h==null||h(!1)}},jn=!a&&!r;return m.browserWallet&&m.readOnly?e.jsxs("form",{className:"stake-form",onSubmit:R=>R.preventDefault(),children:[e.jsx("div",{className:"status-line status-line--muted",role:"status",children:"Connect your wallet to see what you can stake. Unclaimed rewards can be staked directly; wallet ANTS are stakeable once transfers are enabled."}),o?e.jsx("div",{className:"stake-form-actions",children:e.jsx(G,{variant:"outline",onClick:o,children:"Close"})}):null]}):e.jsxs("form",{className:"stake-form",onSubmit:R=>{R.preventDefault(),bn()},children:[ns?e.jsx("div",{className:"status-line status-line--muted",role:"status",children:ns}):null,r?e.jsxs("p",{className:"error-text",children:["Rewards could not be loaded: ",r]}):null,S.length===0?e.jsx("div",{className:"stake-empty",role:"status",children:jn?e.jsx("span",{children:"Loading unclaimed rewards…"}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Nothing to stake yet"}),v?"Your wallet holds no ANTS and no eligible rewards are unclaimed.":"ANTS transfers are not enabled for this wallet, so staking from the wallet balance is unavailable. Rewards you earn buying, selling or staking can be staked here directly as they accrue.",g>0?` ${g} reward source${g===1?"":"s"} belong to other pools.`:""]})}):e.jsxs("div",{className:"field",children:[e.jsx(Ue,{label:"Stake from",hint:p?nl(p):void 0,children:e.jsx(Fe,{value:(p==null?void 0:p.id)??"",disabled:E,onChange:R=>{b(R.target.value),y(null)},children:S.map(R=>e.jsxs("option",{value:R.id,children:[R.label,R.available?"":" · other wallet"," · ",C(R.amount,4)," ANTS"]},R.id))})}),v?null:e.jsx("span",{className:"field__hint",children:"Rewards only: wallet ANTS transfers are disabled."}),g>0?e.jsxs("span",{className:"field__hint",children:[g," reward source",g===1?"":"s"," bound to other pools ",g===1?"is":"are"," not shown here."]}):null]}),p?e.jsxs("div",{className:"form-row",children:[!i&&p.agentId===void 0?e.jsx(Ue,{label:"Seller pool",width:"lg",children:e.jsxs(Fe,{value:String(O||""),onChange:R=>N(R.target.value),disabled:E||be,children:[be?e.jsx("option",{value:"",children:"No stakeable pools"}):null,s.map(R=>{var Q,is;return e.jsx("option",{value:R.agentId,children:((is=(Q=R.profile)==null?void 0:Q.name)==null?void 0:is.trim())||`Agent ID ${R.agentId}`},R.agentId)})]})}):p.agentId!==void 0&&!i?e.jsx(Ue,{label:"Seller pool",width:"lg",hint:"These rewards can only be staked into this seller pool.",children:e.jsx(Fe,{value:String(p.agentId),disabled:!0,children:e.jsx("option",{value:p.agentId,children:((ls=(rs=xe==null?void 0:xe.profile)==null?void 0:rs.name)==null?void 0:ls.trim())||`Agent ID ${p.agentId}`})})}):null,$?e.jsx(qe,{label:"Amount (ANTS)",hint:n!==void 0?e.jsxs(e.Fragment,{children:["Balance ",e.jsx("span",{className:"mono",children:C(n,4)})," ·"," ",e.jsx("button",{type:"button",className:"link-button",onClick:z,disabled:E,children:"Max"})]}):void 0,inputMode:"decimal",value:M,onChange:R=>k(R.target.value),placeholder:"0.0",disabled:E||be}):null,e.jsxs("div",{className:"stake-lock-settings",children:[e.jsx(es,{value:ee,min:Y,max:H,startEpoch:ve,onChange:pe,disabled:E||!t||be}),e.jsx("div",{className:"lock-presets","aria-label":"Lock presets",children:sl.map(R=>{const Q=R.days==="max"?H:gn(R.days);return Q===null?null:e.jsx("button",{type:"button",className:"lock-preset","aria-pressed":ee===Q,disabled:E||!t,onClick:()=>pe(Q),children:R.label},R.label)})}),e.jsxs("div",{className:"stake-apy","aria-live":"polite",children:[e.jsxs("span",{className:"small",children:["Estimated APY ",e.jsx("strong",{className:"mono",children:Xe(F)}),e.jsx(Ze,{label:"About estimated APY",children:"Uses your initial power, restaking bonus and added pool power. Assumes past rewards repeat with per-epoch compounding—not automatic. Excludes declining power and activation delays. Returns aren’t guaranteed."})]}),F===null?e.jsx("span",{className:"field__hint",children:$&&!Je(M)?"Enter an amount to estimate APY.":"APY unavailable: missing reward history or staking data."}):null]})]})]}):null,p&&(t||!$)?e.jsxs("div",{className:"hint",children:["Staking details",e.jsxs(Ze,{label:"About staking and early withdrawal",children:[t?e.jsxs(e.Fragment,{children:["Longer locks increase power. Early exit burns ",ie(t.minEarlyExitSlashBps),"–",ie(t.maxSlashBps)," of principal; preview shows the amount. Dates assume confirmation this epoch. "]}):null,$?null:e.jsx(e.Fragment,{children:"Stakes all eligible rewards, verified on-chain. Usage rewards may need approval per epoch."})]})]}):null,j?e.jsx("div",{className:"error-text",role:"alert",children:j}):null,p?e.jsxs("div",{className:"stake-form-actions",children:[e.jsx("button",{type:"submit",className:"btn btn--primary btn--md",disabled:ss||E,children:E?"Sending…":I.label??($?"Stake":"Stake rewards")}),o?e.jsx(G,{variant:"outline",onClick:o,disabled:E,children:"Cancel"}):null]}):o?e.jsx("div",{className:"stake-form-actions",children:e.jsx(G,{variant:"outline",onClick:o,children:"Close"})}):null]})}function ot(t){var s,n;return((n=(s=t.profile)==null?void 0:s.name)==null?void 0:n.trim())||`Seller pool #${t.agentId}`}const yt=20;function cn(t){return[...t].sort((s,n)=>{var i,c;if(s.stakeable!==n.stakeable)return s.stakeable?-1:1;const a=s.lastEpochRewardPer1kPower,r=n.lastEpochRewardPer1kPower;if(a!==null&&r!==null){const o=jt(r,a);if(o!==0)return o}else{if(a!==null)return-1;if(r!==null)return 1}const l=jt(n.weight,s.weight);return l!==0?l:jt(((i=n.volumes[0])==null?void 0:i.usdc)??"0",((c=s.volumes[0])==null?void 0:c.usdc)??"0")})}function Mt(t,s){if(t.volumeStatus!=="available")return null;const n=t.volumes.find(a=>a.epoch===s-1);return n?J(n.usdc):null}function Se(t){return J(t??null)??0n}function kt(t){var s,n;return((n=(s=t.profile)==null?void 0:s.name)==null?void 0:n.trim())||"Unnamed seller"}function al(t,s,n,a){const r=l=>s==="apy"?Gt(l.yield).oneWeek.apy:s==="stake"?J(l.activeStake):Mt(l,a);return[...t].sort((l,i)=>{const c=r(l),o=r(i);if(c===null)return o===null?0:1;if(o===null)return-1;const h=c<o?-1:c>o?1:0;return n==="ascending"?h:-h})}function rl(t,s){var a;if(!s)return!0;const n=s.toLowerCase();return String(t.agentId)===s||(((a=t.profile)==null?void 0:a.name)??"").toLowerCase().includes(n)||(t.seller??"").toLowerCase().includes(n)}function ll(t,s){return dn(t,s).map(n=>J(n.usdc))}function dn(t,s){return t.volumeStatus!=="available"?[]:[...t.volumes].filter(n=>n.epoch<s).sort((n,a)=>n.epoch-a.epoch)}function vs(t){return Se(t.yourStake)+Se(t.yourPendingStake)}function un({amount:t,pending:s,sub:n,className:a}){return e.jsxs("span",{className:a?`cell-stack ${a}`:"cell-stack",children:[C(t),e.jsx("span",{className:"cell-sub",children:s>0n?e.jsxs("span",{className:"pending-amount",children:["+",C(s)," pending"]}):n})]})}function il({pool:t}){const s=Se(t.yourStake),n=Se(t.yourPendingStake);return s===0n&&n===0n?e.jsx("span",{className:"dim",children:"—"}):s===0n?e.jsxs("span",{className:"cell-stack pending-amount",children:[C(n),e.jsx("span",{className:"cell-sub",children:"pending activation"})]}):e.jsx(un,{amount:t.yourStake,pending:n,sub:`${ie(t.yourPoolShareBps)} of pool`,className:"accent"})}function ol({pools:t,currentEpoch:s,loading:n,walletSyncing:a=!1,onOpen:r,onStake:l}){const[i,c]=u.useState(""),[o,h]=u.useState(!1),[d,m]=u.useState("apy"),[x,f]=u.useState("descending"),[j,y]=u.useState(!1),E=(b,v)=>e.jsxs("button",{type:"button",className:"table-sort","aria-label":`Sort by ${v}, ${d===b&&x==="descending"?"ascending":"descending"}`,onClick:()=>{f(d===b&&x==="descending"?"ascending":"descending"),m(b),h(!1)},children:[v," ",e.jsx("span",{"aria-hidden":"true",children:d===b?x==="descending"?"↓":"↑":"↕"})]}),P=i.trim(),T=u.useMemo(()=>t.filter(b=>b.stakeable),[t]),A=u.useMemo(()=>T.filter(b=>vs(b)>0n).length,[T]),N=u.useMemo(()=>al(T.filter(b=>rl(b,P)&&(!j||vs(b)>0n)),d,x,s),[T,P,d,x,s,j]),k=!o&&N.length>yt?N.slice(0,yt):N,B=[{key:"seller",label:"Seller",render:b=>{var v;return e.jsxs("div",{className:"seller-cell",children:[e.jsx("button",{type:"button",className:"pool-details-trigger","aria-label":`View ${kt(b)} overview`,"aria-haspopup":"dialog",onClick:L=>{L.stopPropagation(),r(b)},children:kt(b)}),e.jsxs("span",{className:"seller-cell-meta",children:[b.stakers!=null?e.jsxs("span",{children:[W(b.stakers)," ",b.stakers===1?"staker":"stakers"]}):b.openPositions!==void 0?e.jsxs("span",{children:[W(b.openPositions)," ",b.openPositions===1?"position":"positions"]}):null,((v=b.profile)==null?void 0:v.modelsServed)!=null?e.jsxs("span",{children:[W(b.profile.modelsServed)," models"]}):null]})]})}},{key:"trend",label:"Volume trend",title:"Settled USDC volume over the last completed epochs.",render:b=>e.jsx(Zr,{values:ll(b,s),labels:dn(b,s).map(v=>`Epoch ${v.epoch}`),format:v=>`${We(BigInt(Math.round(v)))} USDC`,label:`${kt(b)} settled volume over recent epochs`,tone:(Mt(b,s)??0n)>0n?"accent":"muted"})},{key:"apy",label:E("apy","APY"),sortDirection:d==="apy"?x:"none",align:"right",mono:!0,render:b=>e.jsx(pl,{pool:b})},{key:"stake",label:E("stake","TVL"),sortDirection:d==="stake"?x:"none",title:"Total active stake in this pool (ANTS).",align:"right",mono:!0,render:b=>e.jsx(un,{amount:b.activeStake,pending:Se(b.pendingStake),sub:`${ie(b.powerShareBps)} power`})},{key:"volume",label:E("volume","Last epoch"),sortDirection:d==="volume"?x:"none",title:"Settled USDC volume in the last completed epoch.",align:"right",mono:!0,render:b=>{const v=Mt(b,s);return v===null?"—":We(v)}},{key:"yours",label:"Your stake",align:"right",mono:!0,render:b=>a?e.jsx("span",{className:"dim",children:"Updating…"}):e.jsx(il,{pool:b})},{key:"actions",label:"",align:"right",className:"col-actions",render:b=>b.stakeable?e.jsx("span",{onClick:v=>v.stopPropagation(),children:e.jsx(G,{variant:"outline",size:"sm",onClick:()=>l(b),children:"Stake"})}):null}];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pools-toolbar",children:[T.length>5?e.jsx(qe,{label:"",mono:!1,width:"md",placeholder:"Search seller or agent id",value:i,onChange:b=>c(b.target.value),"aria-label":"Filter pools"}):null,A>0&&!a?e.jsxs("button",{type:"button",className:"lock-preset","aria-pressed":j,onClick:()=>y(b=>!b),children:["my pools · ",A]}):null,n?null:e.jsxs("span",{className:"muted small",children:[P||j?`${W(N.length)} of `:"",W(T.length)," ",T.length===1?"seller":"sellers"]})]}),T.some(b=>{var v;return(v=b.displaySource)==null?void 0:v.error})?e.jsx("p",{className:"hint",children:"Some Antscan statistics are unavailable or may lag. Missing historical yield is shown as —; open a provider for details."}):null,e.jsx(Oe,{columns:B,rows:k,rowKey:b=>b.agentId,loading:n,onRowClick:r,empty:P?`No seller matches "${P}" in this view.`:j?"You have no stake in any seller yet.":"No sellers are ready for staking yet."}),N.length>yt?e.jsxs("div",{className:"pools-more",children:[e.jsxs("span",{className:"muted small",children:["Showing ",W(k.length)," of ",W(N.length)]}),e.jsx("button",{type:"button",className:"link-button",onClick:()=>h(b=>!b),children:o?"Show fewer":"Show all"})]}):null]})}function cl({pool:t,view:s,onClose:n,stake:a}){var E,P,T,A,N,U;const r=V(`pool:${t.agentId}`,()=>q.pool(t.agentId),6e4,qr),l=r.data??t,i=r.data?r.reconciling:!!s.walletSyncing,c=!!r.error||!!r.data&&r.data.volumeStatus!=="available",o=c&&t.volumeStatus==="available"?t:l,h=o===t?s.currentEpoch:((E=r.data)==null?void 0:E.currentEpoch)??s.currentEpoch,d=l.profile,m=s.explorer&&l.seller?`${s.explorer.replace(/\/$/,"")}/account/${l.seller}`:null,x=o.volumes.find(k=>k.epoch===h-1),f=Se(l.yourStake),j=Se(l.yourPendingStake),y=Se(l.pendingStake);return e.jsx(Dt,{isOpen:!0,onClose:n,size:"lg",overlayClassName:"ants-stake-overlay ants-pool-overlay",className:"pool-overview",title:ot(l),eyebrow:"SELLER",subtitle:e.jsxs(e.Fragment,{children:["Agent ",e.jsx("span",{className:"mono",children:l.agentId})," · ",l.seller?e.jsx(K,{value:l.seller,copy:!0}):"No seller bound",m?e.jsxs(e.Fragment,{children:[" · ",e.jsx("a",{href:m,target:"_blank",rel:"noreferrer",children:"View on Antscan ↗"})]}):null]}),children:e.jsxs("div",{className:"vault",children:[e.jsxs("div",{className:"vault-main",children:[e.jsxs("div",{className:"pool-overview-status",children:[e.jsx(le,{tone:l.stakeable?"accent":"muted",children:l.hasPool?"Staking pool":"No pool yet"}),d!=null&&d.providers.length?d.providers.slice(0,4).map(k=>e.jsx(le,{tone:"muted",children:k},k)):null,l.openPositions!==void 0?e.jsxs("span",{children:[W(l.openPositions)," open positions",l.stakers!=null?` · ${W(l.stakers)} stakers`:""]}):null,((P=l.displaySource)==null?void 0:P.source)==="indexer"?e.jsxs("span",{className:"dim",children:["Antscan block ",l.displaySource.indexedBlock]}):null]}),(T=l.displaySource)!=null&&T.error?e.jsxs("p",{className:"hint",children:["Antscan: ",l.displaySource.error,((A=l.yield)==null?void 0:A.status)==="unavailable"?" Historical yield is unavailable.":""]}):null,e.jsxs("div",{className:"pool-metrics",children:[e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Total value locked"}),e.jsxs("strong",{children:[C(l.activeStake)," ",e.jsx("small",{children:"ANTS"})]}),y>0n?e.jsxs("span",{className:"small pending-amount",children:["+",C(y)," ANTS pending activation"]}):null]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Last epoch volume"}),e.jsxs("strong",{children:[x&&o.volumeStatus==="available"?We(x.usdc):"—"," ",e.jsx("small",{children:"USDC"})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Power share"}),e.jsx("strong",{children:ie(l.powerShareBps)}),e.jsx("span",{className:"small muted",children:"of all pools' staking power"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Last epoch rewards"}),e.jsxs("strong",{children:[l.lastEpochEmission!=null?C(l.lastEpochEmission):"—"," ",e.jsx("small",{children:"ANTS"})]}),e.jsx("span",{className:"small muted",children:l.lastEpochEmission!=null?l.lastEpochEmissionSettled?"settled to stakers":"estimated, not settled":"no usage yet"})]})]}),e.jsxs("section",{className:"pool-apy-section","aria-label":"Estimated APY by lock",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Estimated APY by lock"}),e.jsx("span",{className:"small muted",children:"10,000 ANTS reference stake · longer locks earn more power"})]}),e.jsx(hl,{pool:l})]}),e.jsxs("section",{className:"pool-section",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Settled volume · completed epochs"}),e.jsx("span",{className:"small muted",children:"Includes legacy seller activity."})]}),c&&o===t&&o.volumeStatus==="available"&&e.jsx("p",{className:"hint",children:"Seller history could not refresh. Showing previously loaded history."}),o.volumeStatus!=="available"&&e.jsxs("p",{className:"hint",children:["Settlement volume ",o.volumeStatus==="stale"?"is stale":"is unavailable",". Usage points are not revenue."]}),e.jsx(Kr,{volumes:o.volumes,networkVolumes:s.networkVolumes,currentEpoch:h}),o.statsUpdatedAt&&e.jsxs("p",{className:"small muted",children:["History fetched ",ue(Math.floor(o.statsUpdatedAt/1e3))]})]}),e.jsxs("section",{className:"pool-section",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Stake, power and staker rewards"}),e.jsx("span",{className:"small muted",children:r.loading&&!r.data?"loading history…":(N=l.history)!=null&&N.length?`${l.history.length} indexed epochs`:"no indexed history"})]}),e.jsx(ul,{history:l.history??[],currentEpoch:h})]}),e.jsxs("section",{className:"pool-section",children:[e.jsxs("div",{className:"pool-section-heading",children:[e.jsx("h3",{children:"Seller profile · lifetime activity"}),e.jsx("span",{className:"small muted",children:"Antscan indexed totals"})]}),(d==null?void 0:d.stale)&&e.jsx("p",{className:"hint",children:"Seller activity is stale; the indexer could not refresh."}),d?e.jsxs("div",{className:"pool-lifetime",children:[e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Settled volume"}),e.jsx("strong",{children:d.lifetimeVolumeUsdc!=null?`${We(d.lifetimeVolumeUsdc)} USDC`:"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Requests"}),e.jsx("strong",{children:d.requestCount!=null?W(d.requestCount):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Unique buyers"}),e.jsx("strong",{children:d.uniqueBuyers!=null?W(d.uniqueBuyers):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Models served"}),e.jsx("strong",{children:d.modelsServed!=null?W(d.modelsServed):"—"})]})]}):e.jsx("p",{className:"hint",children:"The explorer has no record for this seller."}),e.jsx(X,{items:[["Providers",d!=null&&d.providers.length?d.providers.join(", "):"—"],["Last epoch emission",l.lastEpochEmission!=null?`${C(l.lastEpochEmission,4)} ANTS`:"—"],["Ghost rate",(d==null?void 0:d.ghostRate)!=null&&Number.isFinite(d.ghostRate)&&d.ghostRate>=0&&d.ghostRate<=100?`${d.ghostRate.toFixed(1)}%`:"Unavailable"],["Last settled",(d==null?void 0:d.lastSettledAt)!=null?ue(d.lastSettledAt):"—"]]}),(d==null?void 0:d.fetchedAt)&&e.jsxs("p",{className:"small muted",children:["Profile fetched ",ue(Math.floor(d.fetchedAt/1e3))]})]}),e.jsx(Gr,{address:l.seller})]}),e.jsxs("aside",{className:"vault-side","aria-label":"Your position and staking",children:[e.jsxs(we,{children:[e.jsx("h3",{children:"Your position"}),i?e.jsx("p",{className:"hint",role:"status",children:"Updating… Waiting for Antscan to include your latest transaction."}):e.jsxs("div",{className:"vault-your",children:[e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Staked"}),e.jsx("strong",{children:f>0n?C(l.yourStake):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Pending activation"}),e.jsx("strong",{className:j>0n?"pending-amount":void 0,children:j>0n?C(l.yourPendingStake):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Power"}),e.jsx("strong",{children:f>0n?C(l.yourPower):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Pool share"}),e.jsx("strong",{children:f>0n?ie(l.yourPoolShareBps):"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"tile-label",children:"Positions"}),e.jsx("strong",{children:((U=l.yourPositionIds)==null?void 0:U.length)||"—"})]})]}),!i&&j>0n?e.jsxs("p",{className:"hint",children:["Pending stake starts earning at its activation epoch; it is listed under ",e.jsx("a",{href:_e("positions"),children:"My positions"})," with its start date."]}):null]}),e.jsxs(we,{children:[e.jsxs("h3",{children:["Stake into ",ot(l)]}),a?e.jsx(on,{config:a.config,pools:[l],balance:a.balance,rewards:a.rewards,rewardsError:a.rewardsError,defaultAgentId:l.agentId,lockedPool:!0},`${l.agentId}:${a.walletReady}`):e.jsx("p",{className:"hint",children:"Open this seller from the Stake page to stake into it."})]})]})]})})}const dl=10n**18n,Nt=t=>{const s=t/dl;return s>=1000000n?`${(Number(s)/1e6).toFixed(1)}M`:s>=10000n?`${(Number(s)/1e3).toFixed(0)}k`:s>=1000n?`${(Number(s)/1e3).toFixed(1)}k`:s>=100n?s.toString():C(t,2)};function ul({history:t,currentEpoch:s}){const n=t.filter(o=>o.epoch<=s),a=n.map(o=>o.epoch),r=n.map(o=>J(o.activeStake)),l=n.map(o=>J(o.weight)),i=n.map(o=>J(o.emission)),c=n.map(o=>!o.settled);return e.jsxs("div",{className:"chart-grid-2",children:[e.jsx(js,{epochs:a,title:"Active stake per epoch as bars (ANTS, left axis) with pool power as a line (right axis).",bars:{key:"stake",name:"Active stake · ANTS",values:r,format:o=>`${C(o)} ANTS`,tick:Nt},line:{key:"power",name:"Pool power",values:l,format:o=>C(o),tick:Nt}}),e.jsx(js,{epochs:a,title:"Staker rewards per epoch (ANTS). Hollow bars are estimates for epochs not yet settled.",bars:{key:"emission",name:"Staker rewards · ANTS",values:i,format:o=>`${C(o,2)} ANTS`,tick:Nt,provisional:c}})]})}function hl({pool:t}){return e.jsx("dl",{className:"pool-apy-estimates",children:zr(t.yield).map(s=>{var n,a;return e.jsxs("div",{title:s.status==="unsupported"?`${s.label} is not supported by this pool's whole-epoch lock limits.`:s.apy===null?"APY is unavailable because reward or epoch data is missing.":`10,000 ANTS reference stake. ${s.epochs} epoch(s), ${s.actualDays} days. Annualized initial earning rate with hypothetical compounding; not the return over this lock. APY above 10,000% is shown as ${xt}. Source epoch ${t.yield.epoch}.${((n=t.yield)==null?void 0:n.status)==="estimated"?" Rewards are not yet settled.":""}`,children:[e.jsx("dt",{children:s.label}),e.jsx("dd",{children:s.status==="unsupported"?e.jsx("span",{className:"pool-apy-unavailable",children:"Unsupported"}):e.jsxs(e.Fragment,{children:[Xe(s.apy),s.apy!==null&&s.apy<=it&&((a=t.yield)==null?void 0:a.status)==="estimated"?e.jsx("span",{className:"dim small",children:" est."}):null]})})]},s.label)})})}function ml(t){const s=t.yield;if(!s||s.status==="unavailable")return"Last-epoch yield is unavailable.";const n=Gt(s),a=s.endsAt-s.startsAt,r=l=>l===null?"unavailable":`${l} epoch(s), ${l*a/86400} days`;return`10,000 ANTS reference stake, including added pool power. 1 week: ${r(n.oneWeek.epochs)}; 2 years: ${r(n.twoYears.epochs)}. Source epoch ${s.epoch}: ${ue(s.startsAt)} – ${ue(s.endsAt)}. Assumes rewards and initial rates repeat each epoch; compounding is not automatic. Excludes declining power and activation delays. Returns aren’t guaranteed. — means unavailable.${s.status==="estimated"?" Rewards not yet settled.":""}`}function pl({pool:t}){var c;const{oneWeek:s,twoYears:n}=Gt(t.yield),a=s.apy!==null||n.apy!==null,r=(s.apy??0)>it||(n.apy??0)>it,l=Xe(s.apy),i=Xe(n.apy);return e.jsxs("span",{className:`yield-percent${a?" yield-percent--hot":""}`,title:`${ml(t)}${r?` ${_r}`:""}`,children:[r?xt:a?`${l} – ${i}`:"—",a&&!r&&((c=t.yield)==null?void 0:c.status)==="estimated"?e.jsx("span",{className:"dim small",children:" est."}):null]})}function hn(t){return t.maxLockedNext??t.maxLocked}function ts(t,s,n){return t==="enable-max-lock"||t==="disable-max-lock"?s+1:Math.max(s+1,...n.map(a=>a.stakeStartEpoch))}function mn(t,s,n){if(t.withdrawn||t.closedAtEpoch!==0)return"This position is already closed or withdrawn.";if(n===null)return"Waiting for current epoch information.";const a=hn(t);return s==="disable-max-lock"?a?null:"This position is not scheduled for max lock.":a?s==="enable-max-lock"?"This position is already scheduled for max lock.":"Disable maximum lock before this action.":s==="enable-max-lock"&&n<t.stakeStartEpoch?`Max lock can be enabled when the next epoch reaches activation epoch ${t.stakeStartEpoch}.`:t.stakeEndEpoch===0||n>=t.stakeEndEpoch?"The position has no remaining lock when this action takes effect. Withdraw it, then stake again to start a new lock.":null}function xl({items:t,label:s="More actions"}){const[n,a]=u.useState(!1),r=u.useRef(null),l=u.useRef(null),[i,c]=u.useState({});return u.useLayoutEffect(()=>{if(!n||!l.current)return;const o=l.current.getBoundingClientRect();c({top:o.bottom+4,right:Math.max(8,window.innerWidth-o.right)})},[n]),u.useEffect(()=>{if(!n)return;const o=m=>{r.current&&!r.current.contains(m.target)&&a(!1)},h=m=>{m.key==="Escape"&&a(!1)},d=()=>a(!1);return document.addEventListener("mousedown",o),window.addEventListener("keydown",h),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",h),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[n]),e.jsxs("span",{className:"menu",ref:r,onClick:o=>o.stopPropagation(),children:[e.jsx("button",{ref:l,type:"button",className:"menu-trigger","aria-label":s,"aria-haspopup":"menu","aria-expanded":n,title:s,onClick:()=>a(o=>!o),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"3",cy:"8",r:"1.4"}),e.jsx("circle",{cx:"8",cy:"8",r:"1.4"}),e.jsx("circle",{cx:"13",cy:"8",r:"1.4"})]})}),n?e.jsx("div",{className:"menu-list",role:"menu",style:i,children:t.map(o=>e.jsx("button",{type:"button",role:"menuitem",className:"menu-item",disabled:o.disabled,title:o.title,onClick:()=>{var h;a(!1),(h=l.current)==null||h.focus({preventScroll:!0}),o.onSelect()},children:o.label},o.label))}):null]})}function pn({positionId:t,positionIds:s,size:n,autoOpen:a=!1,onStarted:r,onCancel:l}){const i=s??(t!==void 0?[t]:[]),c=Ae(),o=Jt(),[h,d]=u.useState(a),[m,x]=u.useState(null),[f,j]=u.useState(null),[y,E]=u.useState(!1),[P,T]=u.useState(!1),[A,N]=u.useState(null),[U,k]=u.useState(!1),B=u.useRef(!1),b=i.length===0||i.some(w=>!Number.isSafeInteger(w)||w<=0),v=async()=>{if(!b){E(!0),x(null),j(null),T(!1);try{const w=await q.withdrawPreview(i);x(i.length===1?fl(w,i[0]):w)}catch(w){j(Ce(w))}finally{E(!1)}}},L=()=>{b||(d(!0),N(null),v())};u.useEffect(()=>{a&&!b&&L()},[]);const D=async()=>{if(!g||!m||B.current)return;const w={positionIds:i,acceptSlashing:m.earlyExit&&P,maxSlashedAmount:m.totalSlashed};B.current=!0,k(!0),N(null);try{await c.start("/api/positions/withdraw",w),d(!1),r==null||r()}catch(p){c.pushToast({tone:"danger",title:`Withdraw · position${i.length>1?"s":""} ${i.map(I=>`#${I}`).join(", ")} failed`,body:Ce(p),sticky:!0})}finally{B.current=!1,k(!1)}},S=o.reason??(b?"Choose at least one position to withdraw.":void 0),g=!b&&!o.blocked&&!U&&m!==null&&!m.simulationError&&(!m.earlyExit||P);return e.jsxs("div",{className:"action",children:[h&&a?null:e.jsx("span",{className:"btn-wrap",title:S,children:e.jsx(G,{variant:"outline",size:n==="sm"?"sm":"md",onClick:L,disabled:b,children:"Withdraw"})}),h?e.jsxs(tn,{title:i.length>1?`Withdraw ${i.length} positions`:"Withdraw position",hideTitle:a,confirmLabel:o.label??(m!=null&&m.earlyExit?"Withdraw and burn slashed principal":"Withdraw"),danger:(m==null?void 0:m.earlyExit)===!0,disabled:!g,busy:U,error:A,onConfirm:()=>{D()},onCancel:()=>{d(!1),l==null||l()},children:[o.reason?e.jsxs("div",{className:"hint",children:[o.reason," You can still review this estimate."]}):null,y?e.jsxs("div",{className:"muted small",children:[e.jsx(mt,{})," Computing slashing preview…"]}):null,f?e.jsxs("div",{children:[e.jsx("div",{className:"error-text",children:f}),e.jsx("div",{className:"mt",children:e.jsx(G,{variant:"outline",size:"sm",onClick:()=>void v(),children:"Retry preview"})})]}):null,(m==null?void 0:m.simulationError)&&e.jsxs("div",{className:"error-text",children:["Withdrawal cannot execute: ",m.simulationError]}),m?e.jsxs("div",{className:"hint",children:["Rewards to claim separately: ",C(m.pendingRewards,4)," ANTS. ",m.transfersRestricted?"Returned ANTS remain transfer-restricted in this wallet. Ending a position does not enable token transfers. Consider moving your allocation directly to another seller.":"ANTS transfers are currently enabled for this wallet."]}):null,m?e.jsxs("div",{className:"stack",children:[e.jsx(gl,{preview:m}),m.earlyExit?e.jsxs("div",{className:"row",children:[e.jsxs("label",{className:"check danger",children:[e.jsx("input",{type:"checkbox",checked:P,onChange:w=>T(w.target.checked)}),e.jsxs("span",{children:["I accept burning ",e.jsx("span",{className:"mono",children:C(m.totalSlashed,4)})," ANTS of principal (early exit)."]})]}),e.jsx($t,{})]}):e.jsxs("div",{className:"hint",children:["No early-exit penalty applies. Withdrawal returns principal; rewards must be claimed separately.",e.jsx($t,{})]})]}):null]}):null]})}function fl(t,s){var n;if(t.positions.length!==1||((n=t.positions[0])==null?void 0:n.id)!==s)throw new Error("Withdrawal preview does not match this position. Refresh and try again.");return t}function gl({preview:t}){const s=t.positions.length===1;return e.jsx(X,{items:[...s?[["Early-exit penalty",e.jsxs("span",{className:t.earlyExit?"danger":void 0,children:[ie(t.positions[0].slashBps),e.jsx($t,{})]})]]:t.positions.map(n=>[`Position #${n.id}`,e.jsxs("span",{className:n.slashBps>0?"danger":void 0,children:[C(n.amount,4)," ANTS · penalty ",ie(n.slashBps)]})]),["Burned",e.jsxs("span",{className:t.earlyExit?"danger":void 0,children:[C(t.totalSlashed,4)," ANTS"]})],["You receive",`${C(t.totalReturned,4)} ANTS`]]})}function bl({pools:t,enabled:s=!0}){var S,g,w;const n=he(),a=V(s?"positions:current":null,q.positions),[r,l]=u.useState(!1),[i,c]=u.useState(null),[o,h]=u.useState(null),[d,m]=u.useState(()=>new Set),x=a.data,f=a.reconciling||!!a.error,j=u.useMemo(()=>(x==null?void 0:x.positions)??[],[x]),y=u.useMemo(()=>j.filter(p=>!je(p)).length,[j]),E=u.useMemo(()=>r?j:j.filter(je),[j,r]),P=i?E.find(p=>p.id===i.id)??null:null,T=u.useMemo(()=>new Map(t.map(p=>[p.agentId,p])),[t]),A=u.useMemo(()=>E.filter(je),[E]),N=u.useMemo(()=>A.filter(p=>d.has(p.id)),[A,d]),U=xn(N,n==null?void 0:n.current),k=(p,I)=>c({id:p,kind:I}),B=p=>m(I=>{const _=new Set(I);return _.has(p)?_.delete(p):_.add(p),_}),b=()=>m(p=>p.size===A.length?new Set:new Set(A.map(I=>I.id))),v=()=>m(new Set),L=p=>p.stopPropagation(),D=[{key:"select",className:"col-select",label:A.length>0?e.jsx("input",{type:"checkbox","aria-label":"Select all open positions",disabled:f,checked:d.size>0&&d.size===A.length,onChange:b}):"",render:p=>je(p)?e.jsx("input",{type:"checkbox","aria-label":`Select position ${p.id}`,disabled:f,checked:d.has(p.id),onChange:()=>B(p.id),onClick:L}):null},{key:"seller",label:"Seller",render:p=>{var _,$;const I=T.get(p.agentId);return e.jsxs("span",{className:"cell-stack",title:(I==null?void 0:I.seller)??void 0,children:[e.jsx("span",{children:(($=(_=I==null?void 0:I.profile)==null?void 0:_.name)==null?void 0:$.trim())||(I!=null&&I.seller?ut(I.seller):"Unknown seller")}),e.jsxs("span",{className:"cell-sub",children:["#",p.id,jl(p)]})]})}},{key:"amount",label:"Amount",align:"right",mono:!0,render:p=>e.jsxs("span",{className:"cell-stack",children:[C(p.amount,4),e.jsxs("span",{className:"cell-sub",title:p.nextPower!=null?`Next epoch power: ${C(p.nextPower,0)}`:void 0,children:["power ",C(p.power??p.weightAmount,0)]})]})},{key:"apy",label:e.jsxs(e.Fragment,{children:["Est. APY",e.jsx(Ze,{label:"About position APY",children:"Illustrative annualized return using the pool’s historical epoch reward budget and current pool power. Active positions use their current power, already included in the pool total. Pending positions use their activation power added to the current pool total; other pending changes are not projected. Assumes the rate repeats and compounds every epoch. Compounding is not automatic, normal-lock power declines, and activation delays are excluded. Missing data and closed or expired positions show —. Future rewards are not guaranteed."})]}),align:"right",mono:!0,render:p=>{var M,O,H;const I=T.get(p.agentId),_=(x==null?void 0:x.currentEpoch)??(n==null?void 0:n.current),$=Or(p,I,_,(M=x==null?void 0:x.config)==null?void 0:M.maxStakeEpochs);return e.jsx("span",{title:$===null?"APY unavailable for this position.":`Based on ${((O=I==null?void 0:I.yield)==null?void 0:O.status)==="estimated"?"estimated ":""}pool rewards in epoch ${(H=I==null?void 0:I.yield)==null?void 0:H.epoch}.${_!==void 0&&p.stakeStartEpoch>_?" Estimate for when this position activates.":""}`,children:Xe($)})}},{key:"unlocks",label:"Unlocks",title:"Epoch and date when the lock expires. Funds are not withdrawn automatically.",render:p=>e.jsx(ft,{position:p})},{key:"state",label:"Status",title:"The current stage of this staking position.",render:p=>e.jsx(yl,{position:p})},{key:"reward",label:"Pending reward",align:"right",mono:!0,render:p=>C(p.pendingReward,4)},{key:"actions",label:"",align:"right",className:"col-actions",render:p=>je(p)&&!f?e.jsx("span",{className:"row-nowrap",onClick:L,children:e.jsx(xl,{label:`More actions for position ${p.id}`,items:[{label:"Split",onSelect:()=>k(p.id,"split"),disabled:fe(p,"split",n==null?void 0:n.current)!==null,title:fe(p,"split",n==null?void 0:n.current)??void 0},{label:"Extend lock",onSelect:()=>k(p.id,"extend"),disabled:fe(p,"extend",n==null?void 0:n.current)!==null,title:fe(p,"extend",n==null?void 0:n.current)??void 0},{label:Re(p)?"Disable max lock":"Enable max lock",onSelect:()=>k(p.id,"max-lock"),disabled:Bt(p,n==null?void 0:n.current)!==null,title:Bt(p,n==null?void 0:n.current)??void 0},{label:"Move allocation",onSelect:()=>k(p.id,"move"),disabled:fe(p,"move",n==null?void 0:n.current)!==null,title:fe(p,"move",n==null?void 0:n.current)??void 0},{label:"Withdraw",onSelect:()=>k(p.id,"withdraw")}]})}):null}];return e.jsxs(Z,{title:`Your positions${x?` (${E.length})`:""}`,className:"positions-card",actions:y>0?e.jsx("button",{type:"button",className:"link-button",onClick:()=>l(p=>!p),children:r?"hide closed":`show ${y} closed`}):null,children:[a.error&&!x?e.jsx(ne,{error:a.error,onRetry:a.refresh}):null,a.error&&x?e.jsxs("div",{className:"status-line",children:["Refresh failed: ",a.error]}):null,a.reconciling&&!a.error?e.jsx("p",{role:"status",className:"hint",children:"Updating… Waiting for the latest position data."}):null,(x==null?void 0:x.historySource)==="local"?e.jsx("p",{className:"hint",children:"Includes closed positions from verified local transactions. Older history may be incomplete without an indexer."}):null,(x==null?void 0:x.historySource)==="chain"?e.jsx("div",{className:"status-line status-line--muted",children:"Closed-position history is unavailable. Open positions are shown from the chain; rewards on closed positions may be missing."}):null,N.length>0&&!f?e.jsxs("div",{className:"bulk-bar",role:"region","aria-label":"Selected positions",children:[e.jsxs("span",{className:"bulk-bar-count",children:[N.length," selected · ",C(Lt(N),4)," ANTS"]}),e.jsx("button",{type:"button",className:"link-button",onClick:v,children:"clear"}),e.jsxs("div",{className:"bulk-bar-actions",children:[e.jsx("span",{className:"btn-wrap",title:U??"Combine the selected positions into one.",children:e.jsxs(G,{variant:"outline",size:"sm",disabled:U!==null,onClick:()=>h("merge"),children:["Merge ",N.length>1?N.length:""]})}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>h("withdraw"),children:["Withdraw ",N.length]})]})]}):null,i&&P&&x&&!f?e.jsx(Al,{kind:i.kind,position:P,config:x.config,pools:t,onClose:()=>c(null)},`${i.id}:${i.kind}`):null,o&&x&&N.length>0&&!f?e.jsx(El,{kind:o,positions:N,pools:t,onClose:()=>h(null),onStarted:()=>{h(null),v()}}):null,e.jsx(Oe,{columns:D,rows:E,rowKey:p=>p.id,empty:s?a.error?"Positions are currently unavailable.":x?a.reconciling?"Updating positions…":"No open positions. Stake rewards into a seller to open one.":"Loading positions…":"Connect a wallet to see your positions."}),((S=x==null?void 0:x.displaySource)==null?void 0:S.source)==="indexer"?e.jsx("p",{className:"hint",children:"Position status from Antscan. Withdrawal amounts and transaction eligibility are checked live before signing."}):null,((g=x==null?void 0:x.rewardSource)==null?void 0:g.indexedBlock)!==void 0?e.jsxs("p",{className:"hint",children:["Reward estimates from Antscan at block ",x.rewardSource.indexedBlock,"."]}):null,(w=x==null?void 0:x.rewardSource)!=null&&w.error?e.jsxs("p",{role:"status",className:"hint",children:["Indexed rewards unavailable: ",x.rewardSource.error,". Unknown amounts are shown as —, not zero."]}):null]})}function Lt(t){return t.reduce((s,n)=>s+(J(n.amount)??0n),0n).toString()}function xn(t,s){if(t.length<2)return"Select at least two positions to merge.";if(new Set(t.map(a=>a.id)).size!==t.length)return"Select each position only once.";if(new Set(t.map(a=>a.agentId)).size!==1)return"Merged positions must stake the same seller.";const n=s===void 0?null:ts("merge",s,t);for(const a of t){const r=mn(a,"merge",n);if(r)return r}return new Set(t.map(a=>a.stakeEndEpoch)).size!==1?"Merged positions must share the same unlock epoch. Extend the shorter ones first.":null}function Re(t){return hn(t)}function jl(t){const s=Re(t);return s&&t.maxLocked?" · max lock":s?" · max lock from next epoch":t.maxLocked?" · max lock ends next epoch":""}function je(t){return!t.withdrawn&&t.closedAtEpoch===0&&t.state!=="withdrawn"&&t.state!=="closed"}const wl={pending:"amber",active:"accent",matured:"muted",closed:"muted",withdrawn:"muted"},vl={pending:"Waiting for the stake activation epoch.",active:"The staking position is active and its lock has not expired.",matured:"The lock has expired. Withdraw to receive your funds; withdrawal is not automatic.",closed:"This position has been closed, for example by a split, merge, or move.",withdrawn:"Funds have been withdrawn from this position."};function yl({position:t}){const{state:s}=t,n=je(t)&&(s==="pending"||t.changePending);return e.jsx(le,{tone:n?"amber":wl[s],title:n?"The transaction is confirmed. This position starts contributing staking power at its activation epoch.":vl[s],children:n?`Activates epoch ${t.stakeStartEpoch}`:s})}function fe(t,s,n){const a=n===void 0?null:ts(s,n,[t]);return mn(t,s,a)}function Bt(t,s){return fe(t,Re(t)?"disable-max-lock":"enable-max-lock",s)}function ft({position:t,dateOnly:s=!1}){const n=he();if(!je(t))return e.jsx("span",{className:"muted",children:"—"});const a=n?`epoch ${n.current+1}`:"next epoch";return Re(t)?e.jsxs("span",{className:"cell-stack",children:[e.jsx("span",{className:"muted",title:"Disable max lock to start the countdown.",children:"Max lock"}),!t.maxLocked&&e.jsxs("span",{className:"cell-sub",children:["Max lock starts ",a]})]}):e.jsxs("span",{className:"cell-stack",children:[e.jsx(st,{epoch:t.stakeEndEpoch,dateOnly:s}),t.maxLocked&&e.jsxs("span",{className:"cell-sub",children:["Countdown starts ",a]})]})}function gt(t,s){var a,r;const n=s.find(l=>l.agentId===t);return((r=(a=n==null?void 0:n.profile)==null?void 0:a.name)==null?void 0:r.trim())||(n!=null&&n.seller?ut(n.seller):"Unknown seller")}function kl({position:t,pools:s}){const n=he(),a=t.epochsRemaining,r=n?rt(De(t.stakeEndEpoch,n.genesis,n.epochDuration)):null,l=n?rt(De(t.stakeStartEpoch,n.genesis,n.epochDuration)):null;return e.jsxs("div",{children:[e.jsxs("div",{children:[gt(t.agentId,s)," · ",e.jsxs("span",{className:"mono",children:[C(t.amount,4)," ANTS"]})]}),e.jsxs("div",{className:"muted small",children:[je(t)?Re(t)||t.maxLocked?e.jsx(ft,{position:t,dateOnly:!0}):t.state==="matured"?"Lock expired":e.jsxs(e.Fragment,{children:[t.state==="pending"?"Lock duration":"Remaining lock",": ",a," ",a===1?"epoch":"epochs",n?` (${t.state==="pending"?"":"up to "}${Os(a*n.epochDuration)})`:"",t.state==="pending"?` · starts ${l?`${l} UTC`:`epoch ${t.stakeStartEpoch}`}`:""]}):"Position closed",!t.maxLocked&&je(t)?` · ${t.state==="matured"?"unlocked":"unlocks"} ${r?`${r} UTC`:`epoch ${t.stakeEndEpoch}`}`:""]})]})}function Nl({position:t,config:s,pools:n,onStarted:a}){const r=he(),l=n.filter(x=>x.stakeable&&x.agentId!==t.agentId),[i,c]=u.useState(()=>{var x;return String(((x=l[0])==null?void 0:x.agentId)??"")}),o=l.find(x=>String(x.agentId)===i)??null,h={positionIds:[t.id],toAgentId:Number(i)},d=fe(t,"move",r==null?void 0:r.current),m=Math.max(((r==null?void 0:r.current)??0)+1,t.stakeStartEpoch);return e.jsxs("div",{className:"form-row",children:[e.jsx("p",{className:"hint",children:"Move your allocation directly to another seller. Principal stays staked and the lock end date is preserved. Accrued rewards remain claimable on the source position."}),e.jsxs("p",{className:"hint",children:["Effective ",r?`${rt(De(m,r.genesis,r.epochDuration))} UTC (epoch ${m})`:`epoch ${m}`,". One transaction; your wallet will ask you to approve it."]}),d&&e.jsx("p",{className:"error-text",children:d}),e.jsx(Ue,{label:"To seller",hint:s.moveWeightPenaltyBps===0?"No move penalty is currently configured. Moving does not burn your ANTS.":`Moving reduces future staking power by ${ie(s.moveWeightPenaltyBps)}. Your ANTS principal is not burned.`,width:"lg",children:e.jsxs(Fe,{value:i,onChange:x=>c(x.target.value),disabled:l.length===0,children:[l.length===0?e.jsx("option",{value:"",children:"No other seller to move to"}):null,l.map(x=>e.jsx("option",{value:x.agentId,children:gt(x.agentId,n)},x.agentId))]})}),e.jsx(ge,{label:"Move allocation",disabled:d!==null,disabledReason:d??void 0,variant:"primary",path:"/api/positions/move",body:h,validate:()=>o?null:"Choose a target seller.",onStarted:a})]})}function Sl({position:t,onStarted:s}){const n=he(),a=J(t.amount)??0n,r=J(t.weightAmount)??0n,[l,i]=u.useState(""),c=Je(l)?It(l,18):null,o=c!==null&&c>0n&&c<a,h=o?r*c/a:0n,d=fe(t,"split",n==null?void 0:n.current),m=f=>i(C(a*BigInt(Math.round(f*1e4))/10000n,18).replace(/,/g,"")),x={positionId:t.id,amount:l.trim()};return e.jsxs("div",{className:"stack",children:[e.jsx("p",{className:"hint",children:"Splitting replaces this position with two positions with the same seller and lock terms. Power splits in proportion to the amount, so total power is unchanged. Disable max lock before splitting; you can enable it on the new positions before they activate."}),d&&e.jsx("p",{className:"error-text",children:d}),e.jsx("div",{className:"form-row",children:e.jsx(qe,{label:"Amount to split off (ANTS)",inputMode:"decimal",value:l,onChange:f=>i(f.target.value),placeholder:"0.0",hint:e.jsxs(e.Fragment,{children:["of ",e.jsx("span",{className:"mono",children:C(t.amount,4)})," ·"," ",[.25,.5,.75].map(f=>e.jsxs("button",{type:"button",className:"link-button",style:{marginRight:8},onClick:()=>m(f),children:[f*100,"%"]},f))]})})}),e.jsxs("div",{className:"split-preview","aria-live":"polite",children:[e.jsxs("div",{className:"split-part",children:[e.jsxs("span",{className:"tile-label",children:["Keeps position #",t.id]}),e.jsxs("strong",{children:[C(o?a-c:a,4)," ANTS"]}),e.jsxs("span",{className:"small muted",children:["power ",C(o?r-h:r,0)]})]}),e.jsxs("div",{className:"split-part split-part--new",children:[e.jsx("span",{className:"tile-label",children:"New position"}),e.jsxs("strong",{children:[o?C(c,4):"—"," ANTS"]}),e.jsxs("span",{className:"small muted",children:["power ",o?C(h,0):"—"]})]})]}),e.jsx(ge,{label:"Split position",variant:"primary",path:"/api/positions/split",body:x,disabled:d!==null,disabledReason:d??void 0,validate:()=>Je(l)?c===null?"Amount must have no more than 18 decimal places.":c>=a?`Amount must be below the position's ${C(t.amount,4)} ANTS.`:h===0n||r-h===0n?"Amount is too small: both parts need non-zero power.":null:"Amount must be a positive decimal number of ANTS.",onStarted:s})]})}function Cl({position:t,config:s,onStarted:n}){const a=he(),r=!Re(t),l={positionId:t.id,enable:r},i=Bt(t,a==null?void 0:a.current),c=a?a.current+1+s.maxStakeEpochs:null;return e.jsxs("div",{className:"stack",children:[r?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"hint",children:["Max lock pins this position at the maximum lock (",s.maxStakeEpochs," epochs",a?`, ${Os(s.maxStakeEpochs*a.epochDuration)}`:"",") so its staking power stays at the maximum instead of decaying as the lock runs down."]}),e.jsx("p",{className:"hint",children:"The lock no longer counts down. To withdraw later, disable max lock first: a fresh full countdown then starts from the next epoch. Disabling before activation does not restore the original shorter lock. Moves and merges require max lock to be disabled at their effective epoch."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"hint",children:["Disabling max lock starts a fresh ",s.maxStakeEpochs,"-epoch countdown from the next epoch",c!==null?e.jsxs(e.Fragment,{children:[" (unlocks ",e.jsx(st,{epoch:c,dateOnly:!0}),")"]}):null,". Power then decays as the lock runs down."]}),e.jsx("p",{className:"hint",children:"Withdrawing before that countdown ends is an early exit and burns part of the principal."})]}),i&&e.jsx("p",{className:"error-text",children:i}),e.jsx(ge,{label:r?"Enable max lock":"Disable max lock",variant:r?"primary":"default",path:"/api/positions/max-lock",body:l,disabled:i!==null,disabledReason:i??void 0,onStarted:n})]})}function Al({kind:t,position:s,config:n,pools:a=[],onClose:r}){const l=he(),i=l?ts("extend",l.current,[s]):null,c=i===null?null:s.stakeEndEpoch,o=c===null||i===null?0:Math.max(n.maxStakeEpochs-(c-i),0),h=fe(s,"extend",l==null?void 0:l.current),[d,m]=u.useState(Math.min(1,o)||1),x={move:"Move allocation",extend:"Extend position",split:"Split position","max-lock":Re(s)?"Disable max lock":"Enable max lock",withdraw:"Withdraw positions"},f={positionId:s.id,epochs:d},j=()=>h||(o<=0?`This position is already at the maximum lock (${n.maxStakeEpochs} epochs).`:d<1||d>o?`At most ${o} more epoch(s) can be added (max lock ${n.maxStakeEpochs}).`:null);return e.jsxs(Kt,{title:x[t],onClose:r,children:[t!=="extend"?e.jsx("div",{className:"small mb",children:e.jsx(kl,{position:s,pools:a})}):null,t==="withdraw"?e.jsxs("div",{className:"stack",children:[s.changePending?e.jsxs("div",{className:"error-text",children:["Withdrawals are blocked until activation epoch ",s.withdrawableEpoch,". The position change is already confirmed."]}):null,e.jsx(pn,{positionId:s.id,autoOpen:!0,onStarted:r,onCancel:r})]}):null,t==="move"?e.jsx(Nl,{position:s,config:n,pools:a,onStarted:r}):null,t==="split"?e.jsx(Sl,{position:s,onStarted:r}):null,t==="max-lock"?e.jsx(Cl,{position:s,config:n,onStarted:r}):null,t==="extend"?e.jsxs("div",{className:"stack",children:[e.jsxs("dl",{className:"facts",children:[e.jsx("dt",{children:"Amount"}),e.jsxs("dd",{children:[C(s.amount,4)," ANTS"]}),e.jsx("dt",{children:"Current unlock time"}),e.jsx("dd",{children:e.jsx(ft,{position:s,dateOnly:!0})})]}),h&&e.jsx("p",{className:"error-text",children:h}),e.jsx(es,{label:"Add",value:d,min:1,max:Math.max(o,1),startEpoch:c,onChange:m,disabled:h!==null||o<=0,showUnlockDate:!1}),e.jsxs("dl",{className:"facts","aria-live":"polite",children:[e.jsx("dt",{children:"New unlock date"}),e.jsx("dd",{children:e.jsx(st,{epoch:c!==null&&o>0&&!h?c+d:null,dateOnly:!0})})]}),e.jsx(ge,{label:"Extend",variant:"primary",path:"/api/positions/extend",body:f,disabled:h!==null||o<=0,disabledReason:h??(o<=0?"This position is already at the maximum lock.":void 0),validate:j,onStarted:r})]}):null]})}function El({kind:t,positions:s,pools:n,onClose:a,onStarted:r}){const l=he(),i=s.map(d=>d.id),c=xn(s,l==null?void 0:l.current),o={positionIds:i},h=s[0];return e.jsx(Kt,{title:t==="merge"?`Merge ${s.length} positions`:`Withdraw ${s.length} positions`,onClose:a,children:e.jsxs("div",{className:"stack",children:[e.jsxs("dl",{className:"facts",children:[s.map(d=>e.jsx(Il,{position:d,pools:n},d.id)),e.jsx("dt",{children:"Total"}),e.jsxs("dd",{children:[C(Lt(s),4)," ANTS"]})]}),t==="merge"?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"hint",children:["Merging combines these positions into one position of ",C(Lt(s),4)," ANTS in ",gt(h.agentId,n)," with the shared unlock epoch ",h.stakeEndEpoch,". Power is preserved. The source positions close; their accrued rewards stay claimable. The contract verifies matching underlying lock start and end terms before wallet approval; matching unlock dates alone are not sufficient."]}),c?e.jsx("p",{className:"error-text",children:c}):null,e.jsx(ge,{label:"Merge positions",variant:"primary",path:"/api/positions/merge",body:o,disabled:c!==null,disabledReason:c??void 0,onStarted:r})]}):e.jsxs(e.Fragment,{children:[s.some(d=>d.changePending)?e.jsx("div",{className:"error-text",children:"A selected position has not activated. Withdrawals remain blocked until its activation epoch."}):null,e.jsx(pn,{positionIds:i,autoOpen:!0,onStarted:r,onCancel:a})]})]})})}function Il({position:t,pools:s}){return e.jsxs(e.Fragment,{children:[e.jsxs("dt",{children:["#",t.id," · ",gt(t.agentId,s)]}),e.jsxs("dd",{children:[C(t.amount,4)," ANTS · ",e.jsx(ft,{position:t,dateOnly:!0})]})]})}function Tl(){var d;const t=Ie(),s=!t.browserWallet||!t.readOnly,n=s||!!(t.selectedAddress||t.walletAddress)&&!/^0x0{40}$/i.test(t.address),a=V("overview",q.overview),r=V("rewards",q.rewards,5*6e4),l=V("pools",q.pools,5*6e4,Qt),i=u.useMemo(()=>{var m;return cn(((m=l.data)==null?void 0:m.pools)??[])},[l.data]),c=a.data,o=(c==null?void 0:c.wallet.canTransfer)??!1,h=l.reconciling?0n:J(((d=l.data)==null?void 0:d.yourPendingStake)??null)??0n;return e.jsxs(e.Fragment,{children:[ae().embedded?null:e.jsx("h1",{className:"page-title",children:"My positions"}),a.error&&!c?e.jsx(ne,{error:a.error,onRetry:a.refresh}):null,e.jsxs(Vt,{children:[e.jsx(me,{label:"Your total staked",value:c?C(c.wallet.totalActiveStake):"…",unit:"ANTS",loading:!c,sub:a.reconciling&&!a.error?"Updating…":c?e.jsxs(e.Fragment,{children:[W(c.wallet.positionCount)," position",c.wallet.positionCount===1?"":"s",h>0n?e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"pending-amount",children:[C(h)," ANTS pending activation"]})]}):null]}):void 0}),e.jsx(me,{label:"Your power",value:l.reconciling&&!l.error?"…":l.data?C(l.data.yourTotalPower):l.error?"—":"…",loading:l.loading&&!l.data,sub:l.reconciling&&!l.error?"Updating…":l.data?`${ie(l.data.yourNetworkShareBps)} of all pools`:l.error?e.jsx("span",{className:"danger",children:l.error}):"scanning pools…"}),e.jsx(me,{label:s?"Claimable rewards":"Buyer rewards",value:r.data?C(r.data.total):r.error?"—":"…",unit:"ANTS",loading:r.loading&&!r.data,sub:r.error?e.jsxs("span",{className:"danger",children:[r.error," ",e.jsx("button",{className:"link-button",onClick:r.refresh,type:"button",children:"retry"})]}):r.reconciling?"Updating…":r.data?e.jsx("a",{href:_e("rewards"),children:s?"Stake rewards or claim →":"View buyer rewards →"}):"loading from chain…"}),e.jsx(me,{label:"Wallet balance",value:c?C(c.wallet.ants,4):"…",unit:"ANTS",loading:!c,sub:a.reconciling&&!a.error?"Updating…":c?o?"transfers enabled · stakeable":"transfers not enabled · stake from rewards":void 0})]}),e.jsx(bl,{pools:i,enabled:n})]})}const nt=u.createContext({updating:!1,stale:!1});function $l(){const t=V("rewards",q.rewards,3e5),s=t.data,n=t.reconciling&&(!t.error||t.loading),a=!!s&&(t.reconciling||!!t.error);return e.jsxs(e.Fragment,{children:[t.error&&!s?e.jsx(ne,{error:t.error,onRetry:t.refresh}):null,t.error&&s&&!t.loading?e.jsx(ne,{title:"Rewards could not be refreshed",error:`Shown amounts may be out of date. Retry refreshing before another action. This does not mean a confirmed transaction failed. ${t.error}`,onRetry:t.refresh}):null,n?e.jsx("p",{role:"status",className:"hint",children:"Updating… Waiting for the latest reward data."}):null,!s&&t.loading?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"muted small mb",children:"Loading rewards from the blockchain and indexer…"}),e.jsx(tt,{rows:6})]}):null,s?e.jsxs(nt.Provider,{value:{updating:n,stale:a},children:[ae().buyerRewards?e.jsx(Pl,{data:s}):null,s.scope!=="buyer"?e.jsx(Rl,{onRefresh:t.refresh,data:s}):ae().buyerRewards?null:e.jsx("p",{className:"hint",children:"Connect the wallet that holds your staking positions to see its staking rewards."})]}):null]})}function Ut(){const{updating:t,stale:s}=u.useContext(nt);return s?e.jsx("span",{className:"reward-refresh-state",children:t?"Updating…":"Out of date"}):null}function Pe({children:t}){const{updating:s}=u.useContext(nt);return s?e.jsx("span",{className:"muted","aria-busy":"true",children:t}):e.jsx(e.Fragment,{children:t})}function Pl({data:t}){var j;const s=Ie(),[n,a]=u.useState(null),[r,l]=u.useState(!1),i=At([t.buyerUsage.total,t.legacy.buyer]),c=t.buyerUsage.operator,o=!!c&&c.toLowerCase()===(s.walletAddress??s.address).toLowerCase()&&!s.readOnly,h=!c&&s.canAuthorize,d=c&&!o&&s.browserWallet,m=se(t.buyerUsage.total)?"No current buyer rewards are available to stake yet.":o?t.buyerUsage.claimable?null:"These buyer rewards are not currently eligible for direct staking.":"Connect the authorized buyer wallet to stake these rewards.",x=V(o&&!se(t.buyerUsage.total)?"positions:current":null,q.positions),f=async()=>{l(!0),a(null);try{await $e("/api/wallet/authorize",{method:"POST"})}catch(y){a(y instanceof Error?y.message:String(y))}finally{l(!1)}};return e.jsxs(we,{className:"hero",children:[e.jsx("div",{className:"tile-label",children:"Buyer rewards"}),e.jsxs("p",{className:"hint",children:["Earned by buyer account ",e.jsx(K,{value:s.buyerAddress??s.address}),"."]}),e.jsxs("div",{className:"hero-value",children:[e.jsx(Pe,{children:C(i,4)}),e.jsx("span",{className:"unit",children:"ANTS"}),e.jsx(Ut,{})]}),se(i)?e.jsx("p",{className:"hero-sub muted",children:"Nothing to claim yet. Rewards accrue at each epoch boundary."}):null,c?o?null:e.jsxs("p",{className:"hint",children:["Connect the authorized wallet ",e.jsx(K,{value:c})," on ",s.chainId," to claim or stake."]}):e.jsx("p",{className:"hint",children:"Authorize a wallet to claim or stake this buyer’s rewards."}),o&&s.selectedAddress&&(c==null?void 0:c.toLowerCase())!==s.selectedAddress.toLowerCase()?e.jsxs("p",{className:"hint",children:["Buyer rewards and positions created by staking them belong to operator ",e.jsx(K,{value:c}),". Select that address to manage those positions."]}):null,h||d?e.jsxs("div",{className:"hero-actions",children:[h?e.jsx("button",{className:"btn",disabled:r,onClick:()=>void f(),children:r?"Opening…":"Authorize wallet ↗"}):null,d?e.jsx(or,{}):null]}):null,n?e.jsx("p",{role:"alert",className:"hint",children:n}):null,e.jsxs("div",{className:"buckets",children:[e.jsx(Ge,{visible:!0,name:"Current buyer rewards",amount:t.buyerUsage.total,note:"Earned from using AI services.",actions:e.jsxs(e.Fragment,{children:[e.jsx(Be,{bucket:"buyer",scope:"buyer",amount:t.buyerUsage.total,title:"Claim current buyer rewards",disabled:!o||!t.buyerUsage.claimable,reason:"Connect the authorized wallet and check buyer reward eligibility."}),m?e.jsx("span",{className:"btn-wrap",title:m,children:e.jsx(G,{variant:"outline",size:"sm",disabled:!0,children:"Stake rewards"})}):e.jsx(Ft,{kind:"buyer",data:t,maxEpochs:((j=x.data)==null?void 0:j.config.maxStakeEpochs)??null})]})}),e.jsx(Ge,{visible:!se(t.legacy.buyer),name:"Legacy buyer rewards",amount:t.legacy.buyer,note:"Earned from using AI services under the previous rewards system.",actions:e.jsx(Be,{bucket:"legacy",scope:"buyer",amount:t.legacy.buyer,title:"Claim legacy buyer rewards",disabled:!o||!t.legacy.buyerClaimable,reason:"Connect the authorized wallet for this buyer account."})})]})]})}function Rl({data:t,onRefresh:s}){var f,j,y;const n=Ie(),a=t.sellerUsage.claimable?t.sellerUsage.total:"0",r=t.legacy.seller,l=At([t.sellerUsage.total,t.legacy.seller,t.locked.claimable]),i=At([t.sellerUsage.claimable?"0":t.sellerUsage.total,t.legacy.seller,t.locked.claimable]),o=((f=V("positions:current",q.positions).data)==null?void 0:f.config.maxStakeEpochs)??null,h=se(l),d=t.legacy.sellerPayout,m=!!(d!=null&&d.recipient)&&d.destination!=="unknown",x=(d==null?void 0:d.destination)==="locked";return e.jsxs(e.Fragment,{children:[e.jsxs(we,{className:"hero","aria-label":"Staking rewards",children:[t.historySource==="chain"?e.jsx("p",{className:"status-line status-line--muted",children:"Closed-position history is unavailable. Without an indexer, some rewards may be missing. Refresh to retry."}):null,t.historySource==="local"?e.jsx("p",{className:"status-line status-line--muted",children:"Local transaction history included. Older closed positions—and their rewards—may be missing without an indexer."}):null,e.jsx("div",{className:"tile-label",children:"Staking rewards"}),e.jsxs("p",{className:"hint",children:["Unclaimed staking rewards for ",e.jsx(K,{value:n.address}),"—not your wallet balance."]}),e.jsxs("div",{className:"hero-value",children:[e.jsx(Pe,{children:C(t.staker.total,4)}),e.jsx("span",{className:"unit",children:"ANTS"}),e.jsx(Ut,{})]}),((j=t.staker.source)==null?void 0:j.indexedBlock)!==void 0?e.jsxs("p",{className:"hint",children:["Estimated by Antscan at block ",t.staker.source.indexedBlock,". Claims and restaking are checked live."]}):null,t.staker.total===null?e.jsxs("p",{role:"status",className:"hint",children:["Staking rewards unavailable: ",((y=t.staker.source)==null?void 0:y.error)??"Antscan has not finished indexing these rewards."," ",e.jsx("button",{className:"link-button",onClick:s,children:"Retry"})]}):se(t.staker.total)?e.jsx("p",{className:"hero-sub muted",children:"Nothing to claim yet. Rewards accrue at each epoch boundary."}):e.jsxs("div",{className:"hero-actions",children:[e.jsx(Be,{bucket:"staker",amount:t.staker.total}),e.jsx(Ft,{kind:"staker",data:t,maxEpochs:o})]})]}),!ae().pages.includes("seller")&&h&&se(t.locked.locked)?null:e.jsxs(we,{className:"hero","aria-label":"Seller rewards",children:[e.jsx("div",{className:"tile-label",children:"Seller rewards"}),e.jsxs("p",{className:"hint",children:["Unclaimed AI selling rewards for ",e.jsx(K,{value:n.address}),"—not your wallet balance."]}),e.jsxs("div",{className:"hero-value",children:[e.jsx(Pe,{children:C(l,4)}),e.jsx("span",{className:"unit",children:"ANTS"}),e.jsx(Ut,{})]}),h?null:e.jsxs("div",{className:"hero-sub",children:["Available to stake directly ",e.jsx("span",{className:"mono",children:e.jsx(Pe,{children:C(a,4)})})," · other rewards ",e.jsx("span",{className:"mono",children:e.jsx(Pe,{children:C(i,4)})})]}),h?e.jsx("div",{className:"hero-sub muted",children:"Nothing to claim yet. Rewards accrue at each epoch boundary."}):null,h&&se(t.locked.locked)?null:e.jsxs("div",{className:"buckets",children:[e.jsx(Ge,{visible:!se(t.sellerUsage.total),name:"Current seller rewards",note:"Earned from providing AI services.",amount:t.sellerUsage.total,actions:e.jsxs(e.Fragment,{children:[e.jsx(Be,{bucket:"seller",amount:t.sellerUsage.total,disabled:!t.sellerUsage.claimable,reason:"Seller usage rewards are not claimable from this wallet."}),e.jsx(Ft,{kind:"seller",data:t,maxEpochs:o})]})}),e.jsx(Ge,{visible:!se(t.legacy.seller),name:"Legacy seller rewards",note:"Earned from providing AI services under the previous rewards system.",amount:t.legacy.seller,actions:e.jsxs(e.Fragment,{children:[e.jsx(Be,{bucket:"legacy",amount:r,title:"Claim legacy seller rewards",label:m?x?"Claim not available yet":"Claim to wallet":"Claim unavailable",disabled:!m||x,reason:m&&x?"Claiming legacy seller rewards into the locked pool is currently unavailable in this dashboard.":"Payout destination could not be verified. Refresh rewards before claiming.",expectedLegacySellerRecipient:(d==null?void 0:d.recipient)??void 0}),m?null:e.jsx(G,{variant:"outline",size:"sm",onClick:s,children:"Refresh rewards"})]})}),e.jsx(Ge,{visible:!se(t.locked.claimable)||!se(t.locked.locked),name:"Locked seller rewards",note:"Past seller rewards held in the locked pool.",amount:t.locked.claimable,amountDetail:`${C(t.locked.locked,4)} ANTS locked`,actions:e.jsx(Be,{bucket:"locked",amount:t.locked.claimable,label:"Withdraw available amount",title:"Withdraw released seller rewards",disabled:!t.locked.policy,reason:t.locked.policy?se(t.locked.claimable)?"No rewards are currently released for withdrawal.":void 0:"M002 (unlock policy) is not installed."})})]})]})]})}function Ge({visible:t,name:s,note:n,amount:a,amountDetail:r,actions:l}){return t?e.jsxs("div",{className:"bucket",children:[e.jsxs("div",{className:"bucket-main",children:[e.jsx("div",{className:"bucket-name",children:s}),n?e.jsx("div",{className:"bucket-note",children:n}):null]}),e.jsxs("div",{className:`bucket-amount mono${r?" bucket-amount--detailed":""}`,children:[e.jsxs("span",{children:[e.jsx(Pe,{children:C(a,4)})," ",e.jsx("span",{className:"unit",children:"ANTS"})]}),r?e.jsx("span",{className:"bucket-amount-detail",children:e.jsx(Pe,{children:r})}):null]}),e.jsx("div",{className:"bucket-actions",children:l})]}):null}function Be({bucket:t,amount:s,label:n,title:a,disabled:r,reason:l,scope:i="wallet",expectedLegacySellerRecipient:c}){const{stale:o}=u.useContext(nt),h={buckets:[t],scope:i,...c?{expectedLegacySellerRecipient:c}:{}},d=se(s);return e.jsx(ge,{label:n??"Claim to wallet",size:"sm",title:a??(t==="staker"?"Claim staking rewards":"Claim current seller rewards"),path:"/api/rewards/claim",body:h,disabled:o||r||d,disabledReason:o?"Wait for rewards to refresh before another action.":l??(d?"Nothing to claim.":void 0)})}function Ml(t){var l;const s=he(),n=V("positions:current",q.positions),[a,r]=u.useState(t??1);return u.useEffect(()=>{t!==null&&r(t)},[t]),{epochs:a,setEpochs:r,positions:n,slider:e.jsx(es,{value:a,min:((l=n.data)==null?void 0:l.config.minStakeEpochs)??1,max:t??1,startEpoch:s&&n.data?s.current+n.data.config.stakeActivationDelay:null,onChange:r,disabled:t===null})}}function Ll({data:t,pools:s}){const n=new Map;for(const a of t.staker.positions){const r=J(a.amount)??0n;r>0n&&n.set(a.agentId,(n.get(a.agentId)??0n)+r)}return n.size===0?e.jsx(e.Fragment,{children:"Destination unavailable"}):e.jsx("div",{children:[...n].map(([a,r])=>{const l=s.find(i=>i.agentId===a);return e.jsxs("div",{children:[l?ot(l):`Seller pool #${a}`," · ",C(r.toString(),4)," ANTS"]},a)})})}function Ft({kind:t,data:s,maxEpochs:n}){var P;const{stale:a}=u.useContext(nt),{epochs:r,slider:l,positions:i}=Ml(n),c=V("pools",q.pools,5*6e4,Qt),[o,h]=u.useState(()=>s.sellerUsage.agentId?String(s.sellerUsage.agentId):""),d=((P=c.data)==null?void 0:P.pools)??[];u.useEffect(()=>{!o&&d[0]&&h(String(d[0].agentId))},[o,d]);const m=t==="staker"?s.staker.total:t==="seller"?s.sellerUsage.total:s.buyerUsage.total,x=t==="staker"?!0:t==="seller"?s.sellerUsage.claimable:s.buyerUsage.claimable,f=t==="staker"?"/api/rewards/restake":"/api/rewards/stake-usage",j=t==="staker"?{epochs:r}:{side:t,epochs:r,...t==="buyer"&&o?{stakeAgentId:Number(o)}:{}},y=d.find(T=>T.agentId===s.sellerUsage.agentId),E=t==="staker"?e.jsx(Ll,{data:s,pools:d}):y?ot(y):s.sellerUsage.agentId?`Seller pool #${s.sellerUsage.agentId}`:"Destination unavailable";return n===null&&x&&!se(m)?i.error&&!i.loading?e.jsx("span",{className:"btn-wrap",title:`Staking configuration could not be loaded: ${i.error}`,children:e.jsx(G,{variant:"outline",size:"sm",onClick:i.refresh,children:"Retry loading"})}):e.jsx(G,{variant:"outline",size:"sm",disabled:!0,"aria-busy":"true","aria-label":"Loading staking configuration",children:"Loading…"}):e.jsx(ge,{label:"Stake rewards",size:"sm",title:t==="staker"?"Stake position rewards":`Stake current ${t} rewards`,path:f,body:j,disabled:a||se(m)||!x||n===null,disabledReason:a?"Wait for rewards to refresh before another action.":x?"No rewards are available to stake.":`${t} usage rewards are not claimable from this wallet.`,validate:()=>n===null?"Pool configuration is still loading.":t==="buyer"&&!o?"Choose a pool to stake into.":null,summary:t==="buyer"?[["Amount",e.jsxs("span",{className:"mono",children:[C(m,4)," ANTS"]})]]:[["Amount",e.jsxs("span",{className:"mono",children:[C(m,4)," ANTS"]})],["Into",E],["Lock",e.jsxs("span",{className:"mono",children:[r," epochs"]})]],children:e.jsxs("div",{className:"stack mt",children:[l,t==="buyer"?e.jsx(Ue,{label:"Pool",width:"lg",hint:c.loading&&!c.data?"loading pools…":void 0,children:e.jsx(Fe,{value:o,onChange:T=>h(T.target.value),children:d.map(T=>{var A,N;return e.jsx("option",{value:T.agentId,children:((N=(A=T.profile)==null?void 0:A.name)==null?void 0:N.trim())||`Agent ID ${T.agentId}`},T.agentId)})})}):null]})})}function Bl(){const t=Ie(),s=/^0x0{40}$/i.test(t.address),n=V(s?null:`seller:${t.address.toLowerCase()}`,q.seller),a=n.data;return s?e.jsx(Z,{title:"Open your seller dashboard",children:e.jsxs("p",{className:"muted",children:["Open this dashboard with ",e.jsx("code",{children:"antseed ants --address 0x..."})," using your seller’s address, then connect that seller’s wallet."]})}):a?e.jsxs(e.Fragment,{children:[n.error&&a?e.jsxs("div",{className:"status-line",children:["Refresh failed: ",n.error]}):null,a.agentId===0?e.jsx(Z,{title:"Not registered as a seller",children:e.jsx("p",{className:"muted",children:"The connected wallet has no seller identity on this network. Switch to your seller wallet, or register this wallet below to create its identity and bind it in the seller registry."})}):null,e.jsx(Ul,{data:a}),e.jsx(Z,{title:"Wash-trading status",children:e.jsx(Tr,{})}),e.jsx(Z,{className:"panel-collapsible",children:e.jsx(de,{summary:"Advanced: submit a seller proof",children:e.jsxs("div",{className:"stack-lg",children:[e.jsx(Mr,{}),e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:"Proof status"}),e.jsx(Lr,{})]})]})})}),e.jsx(Z,{className:"panel-collapsible",children:e.jsx(de,{summary:"Look up another seller",children:e.jsx($r,{})})})]}):n.error?e.jsx(ne,{error:n.error,onRetry:n.refresh}):e.jsx(tt,{rows:6})}function Le({value:t}){return t===null?e.jsx("span",{className:"muted",children:"n/a"}):t?e.jsx(le,{tone:"accent",children:"yes"}):e.jsx(le,{tone:"muted",children:"no"})}function Ul({data:t}){const s=t.starter;return e.jsxs(e.Fragment,{children:[e.jsxs(Vt,{children:[e.jsx(me,{label:"Agent id",value:t.agentId||"—",sub:t.identityRegistered?"identity registered":"no ERC-8004 identity"}),e.jsx(me,{label:"Eligible",value:t.eligible?"yes":"no",sub:t.registryBound?"bound in seller registry":"not bound"}),e.jsx(me,{label:"Pool active stake",value:C(t.poolActiveStake),unit:"ANTS",sub:t.minPoolStake!==null?`min ${C(t.minPoolStake)} ANTS`:void 0})]}),e.jsxs(Z,{title:"Identity and registry",children:[e.jsx(X,{items:[["ERC-8004 identity",e.jsx(Le,{value:t.identityRegistered})],["Seller registry binding",e.jsx(Le,{value:t.registryBound})],["Legacy stake",`${ce(t.legacyStake)} USDC`],["Legacy eligibility path",e.jsx(Le,{value:t.legacyEligibilityEnabled})]]}),e.jsx("div",{className:"mt",children:e.jsx(Fl,{data:t})}),e.jsxs("div",{className:"hint mt",children:["CLI equivalent: ",e.jsx("code",{children:"antseed seller register"})]})]}),e.jsx(Z,{title:"Starter grant",actions:s?s.claimable?e.jsx(le,{tone:"accent",children:"claimable"}):s.expired?e.jsx(le,{tone:"muted",children:"expired"}):s.initialized?e.jsx(le,{tone:"amber",children:"initialized"}):e.jsx(le,{tone:"muted",children:"not initialized"}):null,children:s?e.jsxs(e.Fragment,{children:[e.jsx(X,{items:[["Grants remaining",W(s.remaining)],["Grant amount",`${C(s.amount,4)} ANTS`],["Claim window ends",e.jsx(st,{epoch:s.endEpoch})],["Legacy eligible",e.jsx(Le,{value:s.legacyEligible})]]}),e.jsx("div",{className:"mt",children:e.jsx(ge,{label:s.initialized?"Grant already claimed":"Claim starter",variant:"primary",title:"Claim starter grant",path:"/api/seller/claim-starter",body:{},disabled:s.initialized||!s.claimable,disabledReason:s.initialized?"This starter grant has already been claimed.":s.expired?"The starter grant window has expired.":"The starter grant is not claimable for this wallet."})}),e.jsxs(de,{summary:"Details",className:"mt",children:[e.jsx(X,{items:[["Contract",s.contract?e.jsx(K,{value:s.contract,short:!1}):"—"],["Initialized",e.jsx(Le,{value:s.initialized})],["Expired",e.jsx(Le,{value:s.expired})]]}),e.jsxs("div",{className:"hint mt",children:["CLI equivalent: ",e.jsx("code",{children:"antseed seller legacy claim-starter"})]})]})]}):e.jsx("span",{className:"muted",children:"No starter grant contract on this chain."})})]})}function Fl({data:t}){const[s,n]=u.useState(t.agentId>0?String(t.agentId):""),a=s.trim()?{agentId:Number(s)}:{};return e.jsxs("div",{className:"form-row",children:[e.jsx(qe,{label:"Agent id (optional)",hint:"Use an existing ID, or leave empty to create an identity if this wallet has none.",width:"md",inputMode:"numeric",value:s,onChange:r=>n(r.target.value)}),e.jsx(ge,{label:t.registryBound?"Re-register binding":"Register binding",variant:"primary",title:"Register seller binding",path:"/api/seller/register",body:a,validate:()=>s.trim()&&!Da(s)?"Agent id must be a positive integer.":null}),e.jsx("p",{className:"hint mt",children:"Binds this wallet to its agent id in the seller registry. Without an id, it reuses a known identity or creates one if this wallet has none. Creating and binding can require separate transactions."})]})}function Dl(){var L,D,S,g,w,p,I,_,$;const t=Ie(),s=!t.browserWallet||!t.readOnly,n=V("overview",q.overview),a=V(s?"positions:current":null,q.positions),r=V("rewards",q.rewards,5*6e4),l=V("pools",q.pools,5*6e4,Qt),i=n.data,c=(L=r.data)==null?void 0:L.buyerUsage.operator,o=s&&!!c&&c.toLowerCase()!==t.address.toLowerCase()&&BigInt(((D=r.data)==null?void 0:D.buyerUsage.total)??"0")>0n,h=(i==null?void 0:i.notices.filter(M=>!M.startsWith("ANTS transfers are not enabled")))??[],[d,m]=u.useState(void 0),[x,f]=u.useState(!1),j=u.useRef(null),[y,E]=u.useState(null),P=u.useRef(null),T=()=>{E(null),requestAnimationFrame(()=>{var M;(M=P.current)!=null&&M.isConnected&&P.current.focus({preventScroll:!0})})},A=u.useMemo(()=>{var M;return cn(((M=l.data)==null?void 0:M.pools)??[])},[l.data]),N=u.useRef(null),U=y!==null?A.find(M=>M.agentId===y):void 0;U&&l.data&&(N.current={pool:U,view:l.data});const k=y!==null&&((S=N.current)==null?void 0:S.pool.agentId)===y?N.current:null,B=M=>{P.current=document.activeElement instanceof HTMLElement?document.activeElement:null,E(M.agentId)},b=()=>{m(void 0),requestAnimationFrame(()=>{var O;const M=j.current;M!=null&&M.isConnected?M.focus({preventScroll:!0}):(O=document.querySelector("[data-stake-trigger]"))==null||O.focus({preventScroll:!0})})},v={config:((g=a.data)==null?void 0:g.config)??null,balance:i==null?void 0:i.wallet.ants,rewards:r.data,rewardsError:r.error,walletReady:s};return e.jsxs(e.Fragment,{children:[t.browserWallet&&o?e.jsxs(Qe,{tone:"info",title:"Connect your authorized wallet",children:["To stake buyer rewards, use the wallet button above to switch to ",e.jsx("span",{className:"mono",title:c,children:ut(c)}),", the authorized wallet for your buyer account."]}):null,n.error&&!i?e.jsx(ne,{error:n.error,onRetry:n.refresh}):null,n.error&&i?e.jsxs("div",{className:"status-line",children:["Refresh failed: ",n.error]}):null,i&&i.phase!=="active"?e.jsx(_l,{data:i}):null,h.length>0?e.jsx(Qe,{tone:"info",children:e.jsx("ul",{className:"notices-list",children:h.map((M,O)=>e.jsx("li",{children:M},O))})}):null,l.data?e.jsx(Wl,{view:l.data}):null,e.jsxs(Z,{title:"Sellers",className:"pools-card",actions:e.jsx(G,{"data-stake-trigger":!0,variant:"primary",size:"sm",onClick:M=>{j.current=M.currentTarget,m(null)},disabled:!l.data,children:"Stake rewards"}),children:[l.error&&!l.data?e.jsx(ne,{error:l.error,onRetry:l.refresh}):null,l.loading?e.jsx("p",{className:"hint",role:"status",children:l.data?"Updating sellers… Showing previously loaded data.":"Loading sellers…"}):null,!l.loading&&l.reconciling?e.jsx("p",{className:"hint",role:"status",children:"Updating your stake… Waiting for Antscan to include your latest transaction."}):null,!l.loading&&(l.partial||l.error&&l.data)?e.jsxs("div",{className:l.error?"status-line":"status-line status-line--muted",role:"status",children:[l.error?`Could not update sellers: ${l.error}. `:"Could not load the full seller list. ",l.error||((w=l.data)==null?void 0:w.source)==="indexer"?"Showing previously loaded data; statistics may be out of date.":"Only pools you stake in are shown, read live from the chain."," ",e.jsx(G,{variant:"outline",size:"sm",onClick:l.refresh,children:"Try again"})]}):null,!l.loading&&((p=l.data)==null?void 0:p.source)==="chain"&&!l.partial&&!l.error?e.jsx("div",{className:"status-line status-line--muted",children:"No explorer configured. Only pools you stake in are listed, read live from the chain."}):null,!l.loading&&((I=l.data)==null?void 0:I.source)==="chain"&&A.length===0?l.reconciling?null:e.jsx("p",{className:"hint",children:"You have no staked pools to show."}):l.data||l.loading?e.jsx(ol,{pools:A,currentEpoch:((_=l.data)==null?void 0:_.currentEpoch)??0,loading:l.loading&&!l.data,walletSyncing:l.reconciling,onOpen:B,onStake:B}):null]}),d!==void 0&&l.data?e.jsxs(Dt,{isOpen:!0,title:"Stake rewards",size:"lg",overlayClassName:"ants-stake-overlay",onClose:()=>{x||b()},children:[a.error&&!a.data?e.jsx(ne,{error:a.error,onRetry:a.refresh}):null,e.jsx(on,{config:(($=a.data)==null?void 0:$.config)??null,pools:A.filter(M=>M.stakeable),balance:i==null?void 0:i.wallet.ants,rewards:r.data,rewardsError:r.error,defaultAgentId:d,onStarted:b,onClose:b,onBusyChange:f},`${t.address}:${t.evmChainId}:${d??"any"}`)]}):null,k?e.jsx(cl,{pool:k.pool,view:k.view,onClose:T,stake:v}):null]})}function Wl({view:t}){const s=t.networkVolumes.find(a=>a.epoch===t.currentEpoch-1),n=t.pools.filter(a=>a.stakeable).length;return e.jsxs("div",{className:"ticker",role:"list","aria-label":"Network",children:[e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Total staked"}),e.jsxs("span",{className:"ticker-value",children:[C(t.totalActiveStake),e.jsx("small",{children:"ANTS"})]})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Total power"}),e.jsx("span",{className:"ticker-value",children:C(t.totalPowerWeight)})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Staker budget · epoch"}),e.jsxs("span",{className:"ticker-value",children:[C(t.stakerBudget),e.jsx("small",{children:"ANTS"})]})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Network volume · last epoch"}),e.jsxs("span",{className:"ticker-value",children:[s?We(s.usdc):"—",e.jsx("small",{children:"USDC"})]})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Sellers"}),e.jsxs("span",{className:"ticker-value",children:[W(n),e.jsx("small",{children:"stakeable"})]})]}),e.jsxs("div",{className:"ticker-item",role:"listitem",children:[e.jsx("span",{className:"ticker-label",children:"Epoch"}),e.jsxs("span",{className:"ticker-value",children:[t.currentEpoch,e.jsx("small",{children:t.source==="indexer"?"indexed":"chain"})]})]})]})}function _l({data:t}){const s=pt(1e3),{phase:n,epoch:a}=t;if(n==="legacy")return e.jsx(Qe,{tone:"info",title:"Legacy protocol",children:"The recognized-usage stack (M001) is not deployed on this chain. Pool staking, usage rewards and emissions views are unavailable."});if(n==="deployed"&&a.effective!==null){const r=De(a.effective,a.genesis,a.epochDuration),l=Math.max(0,Math.floor(r-s/1e3));return e.jsxs(Qe,{tone:"warning",title:"Deployed, not active yet",children:["Recognized usage activates at epoch ",e.jsx("span",{className:"mono",children:a.effective})," (",ue(r),") — in ",e.jsx("span",{className:"mono",children:ht(l)}),". Positions staked now become active from the effective epoch."]})}return null}const Ol=6e4;function zl({theme:t,toggleTheme:s}){const n=V("config",q.config,Number.POSITIVE_INFINITY),a=V("overview",q.overview),r=Ya(),l=a.refresh;u.useEffect(()=>{const c=window.setInterval(()=>{document.visibilityState==="visible"&&l()},Ol);return()=>window.clearInterval(c)},[l]);const i=u.useMemo(()=>n.data?{config:n.data,overview:a.data,overviewError:a.error,theme:t,toggleTheme:s}:null,[n.data,a.data,a.error,t,s]);return i?e.jsx(ir,{config:i.config,children:e.jsx(Js.Provider,{value:i,children:e.jsx(er,{children:e.jsx(xr,{page:r.page,updatedAt:a.updatedAt,loading:a.loading,children:e.jsx(ql,{page:r.page})})})})}):e.jsx("div",{className:"full-page",children:e.jsx(we,{className:"full-page-inner",children:n.error?e.jsx(ne,{error:n.error,onRetry:n.refresh,title:"Could not load dashboard config"}):e.jsx("span",{className:"muted",children:"Connecting to the local server…"})})})}function ql({page:t}){switch(t){case"positions":return e.jsx(Tl,{});case"rewards":return e.jsx($l,{});case"seller":return e.jsx(Bl,{});case"network":return e.jsx(Br,{});case"addresses":return e.jsx(yr,{});case"stake":default:return e.jsx(Dl,{})}}const Yl=()=>{};function Vl({host:t,theme:s}){const n=u.useRef(null),[a,r]=u.useState(!1);return u.useEffect(()=>{Ra({...t,embedded:!0,portalTarget:()=>n.current??document.body}),lt({clear:!0}),r(!0)},[]),e.jsxs("div",{className:"ants-embed",children:[a&&e.jsx(zl,{theme:s,toggleTheme:Yl}),e.jsx("div",{ref:n})]})}const fn="staking";function ys(t){return t==="rewards"||t.startsWith("rewards/")||t.startsWith("rewards?")?"rewards":`${fn}/${t}`}function Hl(){const t=St(fn),{pathname:s,search:n}=window.location;return`${s.startsWith(`${t}/`)?s.slice(t.length+1):""}${n}`}const ks=()=>{};function Kl({pages:t,buyerRewards:s}){const{workspace:n}=Sn(),a=Cn(),r=t.length>1,l=u.useMemo(()=>({apiUrl:c=>`${En}/workspaces/${encodeURIComponent(n.id)}/ants/${c.replace(/^\/api\//,"")}`,headers:()=>({[In]:"1"}),href:c=>St(ys(c)),currentPath:r?Hl:()=>t[0]??"",replace:r?c=>os(ys(c),{replace:!0}):ks,subscribe:r?An:()=>ks,pages:t,buyerRewards:s}),[n.id,t,s,r]),i=c=>{if(c.defaultPrevented||c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||c.altKey)return;const o=c.target.closest("a"),h=o==null?void 0:o.getAttribute("href"),d=St("");!o||o.target||!(h!=null&&h.startsWith(d))||(c.preventDefault(),os(h.slice(d.length)))};return e.jsx("div",{onClick:i,children:e.jsx(ca,{chain:a.data,error:a.error,children:c=>e.jsx(ra,{chain:c,children:e.jsx(Vl,{host:l,theme:Tn()?"dark":"light"},n.id)})})})}const ai=Object.freeze(Object.defineProperty({__proto__:null,StakingDashboard:Kl},Symbol.toStringTag,{value:"Module"}));export{Ia as N,Ds as P,Kl as S,ni as a,ai as b};
|