@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.
Files changed (157) hide show
  1. package/dist/assets/{Activity-UaQeZdKk.js → Activity-BcXN_DqV.js} +1 -1
  2. package/dist/assets/Audit-nk0K4aQy.js +1 -0
  3. package/dist/assets/{BrandIcon-dTKznfCA.js → BrandIcon-6gq42Dg-.js} +1 -1
  4. package/dist/assets/{ChainGate-DpChfDOP.js → ChainGate-Do1wYOPQ.js} +1 -1
  5. package/dist/assets/{ChannelClose-DpNV5MqB.js → ChannelClose-CdHUKMFm.js} +1 -1
  6. package/dist/assets/{Charts-C65ZE2xP.js → Charts-BMsoEfDr.js} +1 -1
  7. package/dist/assets/{Chat-BbM_y6mh.js → Chat-C4DsUQG-.js} +3 -3
  8. package/dist/assets/{ConnectWallet-CLv0c-JB.js → ConnectWallet-BYdqZipy.js} +1 -1
  9. package/dist/assets/{DataTable-BkJdorEh.js → DataTable-BCgVRqY6.js} +1 -1
  10. package/dist/assets/{Disclosure-DMLE7rCw.js → Disclosure-CQMtWM0M.js} +1 -1
  11. package/dist/assets/{KeyHolder-Cjko0nrs.js → KeyHolder-JK1zjm4r.js} +1 -1
  12. package/dist/assets/{Keys-DLKN6Sna.js → Keys-BndDLQdj.js} +1 -1
  13. package/dist/assets/{Logs-DIPNoSb8.js → Logs-DfacvRY6.js} +1 -1
  14. package/dist/assets/{Members-CgP9OTz9.js → Members-pSSyfBFp.js} +1 -1
  15. package/dist/assets/{Migrate-DDHZ-rux.js → Migrate-Bqnu-HEP.js} +1 -1
  16. package/dist/assets/{ModelDetails-CkDNU2Px.js → ModelDetails-Sgq3MjfG.js} +1 -1
  17. package/dist/assets/{Models-DXbiNymT.js → Models-C6QzCAh4.js} +1 -1
  18. package/dist/assets/{OperatorActions-BuEpaCiH.js → OperatorActions-DWX4uK6I.js} +1 -1
  19. package/dist/assets/{OperatorGateAlert-grMRoFdV.js → OperatorGateAlert-cpvsO9yT.js} +1 -1
  20. package/dist/assets/{Overview-BU9HCltc.js → Overview-C4Bu8z8u.js} +1 -1
  21. package/dist/assets/{PeerPicker-CfsXTUyK.js → PeerPicker-CcMSXxY3.js} +1 -1
  22. package/dist/assets/PolicyEditor-COREmE0O.js +1 -0
  23. package/dist/assets/PolicyField-ldIq_Yw-.js +1 -0
  24. package/dist/assets/{Presets-szQETQLM.js → Presets-DFKw93HK.js} +2 -2
  25. package/dist/assets/Providers-D_0V31og.js +1 -0
  26. package/dist/assets/{RequestLog-DJl6FJhq.js → RequestLog-ChzJA1hM.js} +1 -1
  27. package/dist/assets/{Rewards-BOfJumNk.js → Rewards-Cgw7r3bc.js} +2 -2
  28. package/dist/assets/{RewardsClaim-DHvgMfZ4.js → RewardsClaim-Df0QQMHb.js} +1 -1
  29. package/dist/assets/Routing-KpWxzlwc.js +1 -0
  30. package/dist/assets/{Segmented-D3e0aBDU.js → Segmented-DYnoemT9.js} +1 -1
  31. package/dist/assets/{SelectField-Cl4acfcI.js → SelectField-m1sMIgMa.js} +1 -1
  32. package/dist/assets/Settings-D2MkmqAU.js +7 -0
  33. package/dist/assets/{SidePanel-D0rNElh3.js → SidePanel-BFQArkoa.js} +1 -1
  34. package/dist/assets/{Staking-1D2HNu5P.js → Staking-2rSdK2Ob.js} +1 -1
  35. package/dist/assets/{StakingDashboard-C5Ib_AUs.js → StakingDashboard-DvLxJ1j4.js} +1 -1
  36. package/dist/assets/{Switch-B2AEvyu7.js → Switch-Db8Sm64J.js} +1 -1
  37. package/dist/assets/{Tabs-Cv10NtDy.js → Tabs-CCabxVNK.js} +1 -1
  38. package/dist/assets/{TextAreaField-Dbr655cs.js → TextAreaField-BCi-qMua.js} +1 -1
  39. package/dist/assets/{UsageByModel-BfvCLwo9.js → UsageByModel-Fb68pvpD.js} +1 -1
  40. package/dist/assets/{VerificationLinks-CERoRvCR.js → VerificationLinks-CWyl6ZEp.js} +1 -1
  41. package/dist/assets/{Wallet-CVS_hzu0.js → Wallet-BVuVEAB5.js} +7 -7
  42. package/dist/assets/{WalletConfirm-C8Kazsh7.js → WalletConfirm-Bs7CFRaa.js} +1 -1
  43. package/dist/assets/{WalletFunding-BbhXB813.js → WalletFunding-w9MlXB0t.js} +1 -1
  44. package/dist/assets/{WalletSignIn-Tzs38aME.js → WalletSignIn-CFxQjhbw.js} +1 -1
  45. package/dist/assets/{Workspaces-DGgrOEZk.js → Workspaces-DktyLm08.js} +1 -1
  46. package/dist/assets/{add-CdcnAnIQ.js → add-CWU7ACA6.js} +1 -1
  47. package/dist/assets/{all-wallets-CaMIS0WH.js → all-wallets-C7xN3fay.js} +1 -1
  48. package/dist/assets/{app-store-BJlWsf36.js → app-store-C9LYdcrl.js} +1 -1
  49. package/dist/assets/{apple-sOU-w3fg.js → apple-DyeheYaR.js} +1 -1
  50. package/dist/assets/{arrow-bottom-CTOfZJ7E.js → arrow-bottom-C-Ld0QTs.js} +1 -1
  51. package/dist/assets/{arrow-bottom-circle-B6IrOSiK.js → arrow-bottom-circle-CBZDZ8Ab.js} +1 -1
  52. package/dist/assets/{arrow-left-D0Qm9EWX.js → arrow-left-DpJrY7yH.js} +1 -1
  53. package/dist/assets/{arrow-right-XMSWQLiv.js → arrow-right-C12AYUbo.js} +1 -1
  54. package/dist/assets/{arrow-top-Bym-ayRK.js → arrow-top-DTpoR1JD.js} +1 -1
  55. package/dist/assets/{bank-NJF8WYDR.js → bank-Ce19qcX5.js} +1 -1
  56. package/dist/assets/{basic-bO70Xvle.js → basic-xSJded8g.js} +1 -1
  57. package/dist/assets/{browser-ucjw1tpv.js → browser-efLjW-nE.js} +1 -1
  58. package/dist/assets/{bundle-full-idGWmtvy.js → bundle-full-Bo_XusKG.js} +1 -1
  59. package/dist/assets/{card-DcpyI2qX.js → card-C5hP1T57.js} +1 -1
  60. package/dist/assets/{ccip-DBXxv0FH.js → ccip-B61TPyfu.js} +1 -1
  61. package/dist/assets/{checkmark-RFLSeCgj.js → checkmark-D6TDn2nt.js} +1 -1
  62. package/dist/assets/{checkmark-bold-Dl1q9Kby.js → checkmark-bold-D6Dl_7lL.js} +1 -1
  63. package/dist/assets/{chevron-bottom-ilycsYd4.js → chevron-bottom-BN93pLQ-.js} +1 -1
  64. package/dist/assets/{chevron-left-DFK2Xbq1.js → chevron-left-BRtPfxLq.js} +1 -1
  65. package/dist/assets/{chevron-right-Ew8XV9m9.js → chevron-right-q6ckJ6mb.js} +1 -1
  66. package/dist/assets/{chevron-top-CxoXH2-q.js → chevron-top-C1AX5sm6.js} +1 -1
  67. package/dist/assets/{chrome-store-ClmhY3B0.js → chrome-store-Bo_BoLHJ.js} +1 -1
  68. package/dist/assets/{clock-CCiukNBf.js → clock-BhAO_7G0.js} +1 -1
  69. package/dist/assets/{close-B0KBYbXe.js → close-BtzdVDHu.js} +1 -1
  70. package/dist/assets/{code-block-DxUcjw4S.js → code-block-DqMh9vFo.js} +1 -1
  71. package/dist/assets/{coinPlaceholder-D2ugxr3r.js → coinPlaceholder-Di1b8fYJ.js} +1 -1
  72. package/dist/assets/{compass-CutyEYmW.js → compass-C10lNmou.js} +1 -1
  73. package/dist/assets/{copy-CJ0RBt1e.js → copy-B5e38uFc.js} +1 -1
  74. package/dist/assets/{core-BCJdIbrO.js → core-B0f6zAPS.js} +3 -3
  75. package/dist/assets/{cursor-transparent-BQ_jwSfb.js → cursor-transparent-DzGICXfN.js} +1 -1
  76. package/dist/assets/cursor-zACYQT2t.js +3 -0
  77. package/dist/assets/{desktop-CsfFLaEs.js → desktop-DSb6a3DL.js} +1 -1
  78. package/dist/assets/{disconnect-B62slDXp.js → disconnect-DRzHq1ok.js} +1 -1
  79. package/dist/assets/{discord-B8GwtWtL.js → discord-c_RQc3fB.js} +1 -1
  80. package/dist/assets/{en_US-Y4ZOVFV4-sKQksBWU.js → en_US-Y4ZOVFV4-Bkc-z49M.js} +4 -4
  81. package/dist/assets/{etherscan-BT9zhNhd.js → etherscan-CQGvGKJu.js} +1 -1
  82. package/dist/assets/{exclamation-triangle-BSoPK6uq.js → exclamation-triangle-CPWxzsHw.js} +1 -1
  83. package/dist/assets/{extension-CQxJq6bp.js → extension-ytWXOqXr.js} +1 -1
  84. package/dist/assets/{external-link-BnfAKGN2.js → external-link-BYoSE2u3.js} +1 -1
  85. package/dist/assets/{facebook-DiAqdu4i.js → facebook-CMBv0nnN.js} +1 -1
  86. package/dist/assets/{farcaster-B1y2in5M.js → farcaster-CJmfWTQP.js} +1 -1
  87. package/dist/assets/{filters-BkVUp9NW.js → filters-DEiNVvyn.js} +1 -1
  88. package/dist/assets/{github-IRwi-GM-.js → github-CdMwJkf8.js} +1 -1
  89. package/dist/assets/{google-k2ysL2bi.js → google-CHI5gfH8.js} +1 -1
  90. package/dist/assets/{help-circle-DLj9trmu.js → help-circle-dA36a8fM.js} +1 -1
  91. package/dist/assets/highlighted-body-KQOG7T2V-BFlyrf-z.js +1 -0
  92. package/dist/assets/{id-BY4HWjv7.js → id-Dm0-1g1D.js} +1 -1
  93. package/dist/assets/{image-BtUeZe1t.js → image-BL3ODVX_.js} +1 -1
  94. package/dist/assets/{index-DYK1gWhP.css → index-BAcoKUeC.css} +1 -1
  95. package/dist/assets/{index-DiB9Y59V.js → index-BRgGxCKs.js} +3 -3
  96. package/dist/assets/{index-Cmb-H95F.js → index-BXzZZOmS.js} +1 -1
  97. package/dist/assets/{index-BXwAwVaO.js → index-CHeO_lLD.js} +1 -1
  98. package/dist/assets/{index-DsRX2D_O.js → index-D1OXThJP.js} +1 -1
  99. package/dist/assets/{index-cESr4Zze.js → index-DPXW_JSn.js} +10 -10
  100. package/dist/assets/{index.es-DP9EmOYi.js → index.es-XdMmjy3e.js} +3 -3
  101. package/dist/assets/{info-BaKj81_D.js → info-BbBzpLWs.js} +1 -1
  102. package/dist/assets/{info-circle-ecoA_B_t.js → info-circle-CKgnYdF-.js} +1 -1
  103. package/dist/assets/{lightbulb-DGQG-WWk.js → lightbulb-B6Xv9kMK.js} +1 -1
  104. package/dist/assets/{limits-D2JvFgaN.js → limits-uCwhqY-O.js} +1 -1
  105. package/dist/assets/{mail-BvEbsX3q.js → mail-BdCMypwE.js} +1 -1
  106. package/dist/assets/{mermaid-MCJ5UELQ-B8uOykea.js → mermaid-MCJ5UELQ-BaHsArCB.js} +3 -3
  107. package/dist/assets/{metamask-sdk-BYmYI1f3.js → metamask-sdk-BL7QLxcU.js} +1 -1
  108. package/dist/assets/{mobile-CwlM4JMX.js → mobile-F_82dhUb.js} +1 -1
  109. package/dist/assets/{more-CT36TpLm.js → more-CtMTtAsM.js} +1 -1
  110. package/dist/assets/{network-placeholder-DG1Vvm-U.js → network-placeholder-BRs4Lylz.js} +1 -1
  111. package/dist/assets/{nftPlaceholder-D6USOn7p.js → nftPlaceholder-DONTHyad.js} +1 -1
  112. package/dist/assets/{off-BNSO7pY1.js → off-Bwru40fy.js} +1 -1
  113. package/dist/assets/{play-store-PUfM0qU0.js → play-store-CDeNquGq.js} +1 -1
  114. package/dist/assets/{plus-C8fnGfp3.js → plus-EcrYfJFM.js} +1 -1
  115. package/dist/assets/{qr-code-CjdrQ0pR.js → qr-code-CF-SIZQq.js} +1 -1
  116. package/dist/assets/{recycle-horizontal-BMxBgeB4.js → recycle-horizontal-CQAPujmy.js} +1 -1
  117. package/dist/assets/{refresh-C2D196Fq.js → refresh-BErGEy2b.js} +1 -1
  118. package/dist/assets/{reown-logo-CLN2ORKJ.js → reown-logo-Ge2o4AAI.js} +1 -1
  119. package/dist/assets/{search-C9voC8dq.js → search-Ca88O9BA.js} +1 -1
  120. package/dist/assets/selection-BV37SUs_.js +1 -0
  121. package/dist/assets/{send-BAxcrGbA.js → send-VS1TUwft.js} +1 -1
  122. package/dist/assets/{sendTransaction-Cmz5eiPq.js → sendTransaction-k8aDYfd4.js} +1 -1
  123. package/dist/assets/stored-e0tX90bC.js +1 -0
  124. package/dist/assets/{swapHorizontal-CHCTyoP7.js → swapHorizontal-UNJ9wJ3Z.js} +1 -1
  125. package/dist/assets/{swapHorizontalBold-LQsONWBk.js → swapHorizontalBold-eQTpC4fd.js} +1 -1
  126. package/dist/assets/{swapHorizontalMedium-BxrBEjrx.js → swapHorizontalMedium-DaFWQu14.js} +1 -1
  127. package/dist/assets/{swapHorizontalRoundedBold-CEHDoSv1.js → swapHorizontalRoundedBold-BbRZUmJZ.js} +1 -1
  128. package/dist/assets/{swapVertical-DMylrYB1.js → swapVertical-CrZ6Be2R.js} +1 -1
  129. package/dist/assets/{telegram-BhVfpln1.js → telegram-CDAYT0ej.js} +1 -1
  130. package/dist/assets/{three-dots-nkXRRS-E.js → three-dots-CK__4w5S.js} +1 -1
  131. package/dist/assets/{twitch-CYroZH_7.js → twitch-BS50nSpU.js} +1 -1
  132. package/dist/assets/{twitterIcon-DpHUqlyA.js → twitterIcon-BtVx5zJI.js} +1 -1
  133. package/dist/assets/{usage-8BBeTlF-.js → usage-DQGKL0DJ.js} +1 -1
  134. package/dist/assets/{useInfiniteQuery-zD1WIYBy.js → useInfiniteQuery-CAj47QRO.js} +1 -1
  135. package/dist/assets/{useTx-DsLsc5bB.js → useTx-DzRlz7Ez.js} +1 -1
  136. package/dist/assets/{verify-filled-EsNi41IB.js → verify-filled-E4LyUumx.js} +1 -1
  137. package/dist/assets/{verify-DARDbLiQ.js → verify-hRAQBjoS.js} +1 -1
  138. package/dist/assets/{w3m-modal-CIUN4uxE.js → w3m-modal-CLSVKDRP.js} +1 -1
  139. package/dist/assets/{waitForCallsStatus-DlpsNYx1.js → waitForCallsStatus-C51Vv8Tt.js} +1 -1
  140. package/dist/assets/{wallet-B2vgeP1E.js → wallet-D-TGx4VA.js} +1 -1
  141. package/dist/assets/{wallet-placeholder-DQsissb3.js → wallet-placeholder-SjwHckDA.js} +1 -1
  142. package/dist/assets/{walletconnect-DylNgC0Z.js → walletconnect-7nuI2nwG.js} +1 -1
  143. package/dist/assets/{warning-circle-CVEgsVb4.js → warning-circle-BI2BfSeD.js} +1 -1
  144. package/dist/assets/{writeContract-Cqg_OlRQ.js → writeContract-CaMlmKcK.js} +1 -1
  145. package/dist/assets/{x-DSURRh6S.js → x-DoGk7CZD.js} +1 -1
  146. package/dist/index.html +2 -2
  147. package/package.json +1 -1
  148. package/dist/assets/Audit-Cd26xOlL.js +0 -1
  149. package/dist/assets/PolicyEditor-ptFDJhFh.js +0 -1
  150. package/dist/assets/PolicyField-CHhm50jF.js +0 -1
  151. package/dist/assets/Providers-B6xbFeNU.js +0 -1
  152. package/dist/assets/Routing-DFuhPfzU.js +0 -1
  153. package/dist/assets/Settings--0bbw1dn.js +0 -7
  154. package/dist/assets/cursor-Bg_hT9DN.js +0 -3
  155. package/dist/assets/highlighted-body-KQOG7T2V-CJM-VU3I.js +0 -1
  156. package/dist/assets/selection-HN8SZ52c.js +0 -1
  157. package/dist/assets/stored-CETnaQtE.js +0 -1
@@ -1 +1 @@
1
- import{m as h}from"./index-cESr4Zze.js";const p=864e5;function k(t){const e=new Date(t);return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function S(t){return new Date(t).toISOString().slice(0,10)}const D="\0others";function O(t){return t.group!==D?t.label||t.group:t.others===void 0?"Other users":`${t.others} other ${t.others===1?"user":"users"}`}function C(t,e,o){const s=new Map;for(const n of(t==null?void 0:t.groups)??[])s.set(n.group.slice(0,10),{spent:h(n.spent),requests:n.requests});const r=[];for(let n=k(e);n<=o;n+=p){const c=S(n),u=s.get(c),l=new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});r.push({label:l,value:(u==null?void 0:u.spent)??0,sub:`${(u==null?void 0:u.requests)??0} requests`})}return r}const U=[{id:"24h",label:"24 hours",ms:p},{id:"7d",label:"7 days",ms:7*p},{id:"30d",label:"30 days",ms:30*p},{id:"90d",label:"90 days",ms:90*p}];function q(t,e=Date.now()){const o=U.find(s=>s.id===t);return t==="24h"?e-o.ms:k(e-o.ms+p)}const d=36e5;function E(t,e=Date.now()){const o=[];if(t==="24h"){const n=Math.floor(e/d)*d+d;for(let c=n-24*d;c<n;c+=d){const u=new Date(c).toLocaleTimeString("en-US",{hour:"numeric",timeZone:"UTC"});o.push({from:c,to:Math.min(c+d,e+1),label:u})}return o}const s=t==="90d"?7*p:p,r=q(t,e);for(let n=r;n<=e;n+=s){const c=new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});o.push({from:n,to:Math.min(n+s,e+1),label:c})}return o}function m(t,e){return e==="spend"?h(t.spent):e==="requests"?t.requests:t.inputTokens+t.outputTokens}const T="__other__";function M(t,e,o=6){const s=new Map;for(const a of t)for(const i of(a==null?void 0:a.groups)??[]){const f=s.get(i.group)??{label:O(i),total:0};f.total+=m(i,e),s.set(i.group,f)}const r=[...s.entries()].filter(([,a])=>a.total>0).sort((a,i)=>i[1].total-a[1].total),n=r.slice(0,o),c=new Set(n.map(([a])=>a)),u=r.slice(o).reduce((a,[,i])=>a+i.total,0),l=n.map(([a,i])=>({key:a,label:i.label,total:i.total}));u>0&&l.push({key:T,label:"Other",total:u});const b=t.map(a=>{const i={};for(const f of(a==null?void 0:a.groups)??[]){const g=c.has(f.group)?f.group:T;i[g]=(i[g]??0)+m(f,e)}return i});return{series:l,columns:b}}function _(t){return t==="24h"?"hour":"day"}function v(t){return/^\d{4}-\d{2}-\d{2}T\d{2}$/.test(t)?Date.parse(`${t}:00:00Z`):/^\d{4}-\d{2}-\d{2}$/.test(t)?Date.parse(`${t}T00:00:00Z`):Number.NaN}function y(t,e){const o=e.map(()=>new Map);for(const s of(t==null?void 0:t.groups)??[]){const r=v(s.group),n=e.findIndex(u=>r>=u.from&&r<u.to);if(n===-1)continue;const c=o[n];for(const u of s.splits??[]){const l=c.get(u.group);if(!l){c.set(u.group,{...u});continue}l.requests+=u.requests,l.failedRequests+=u.failedRequests,l.spent=(h(l.spent)+h(u.spent)).toFixed(6),l.inputTokens+=u.inputTokens,l.cachedInputTokens+=u.cachedInputTokens,l.outputTokens+=u.outputTokens}}return o.map(s=>({groups:[...s.values()]}))}const R=[{key:"input",label:"Input"},{key:"cached",label:"Cached input"},{key:"output",label:"Output"}];function N(t){const e={input:0,cached:0,output:0},o=t.map(s=>{const r={input:0,cached:0,output:0};for(const n of(s==null?void 0:s.groups)??[])r.cached+=n.cachedInputTokens,r.input+=Math.max(0,n.inputTokens-n.cachedInputTokens),r.output+=n.outputTokens;return e.input+=r.input,e.cached+=r.cached,e.output+=r.output,r});return{series:R.map(s=>({...s,total:e[s.key]})),columns:o}}function w(t){return t.reduce((e,o)=>e+((o==null?void 0:o.groups)??[]).reduce((s,r)=>s+r.requests,0),0)}const I=600*1e3;function x(t,e){return t===null?"ranking failed":e===null?t===1?"trying its first pick":`trying its pick #${t}`:e<400?t===1?"its first pick served it":`its pick #${t} served it (the ones before failed)`:t===1?"its first pick failed":`its picks #1–${t} all failed`}function Z(t,e){var o,s;return t.spent!==null&&!t.costPending?"spent":((o=t.video)==null?void 0:o.action)==="create"?t.video.charged!==null?"video-charged":"on-delivery":((s=t.video)==null?void 0:s.action)==="poll"?"not-charged":t.servedFree?"free":t.costPending?e-(t.finishedAt??t.startedAt)<I?"pending":"not-recorded":t.spent!==null?"spent":null}export{T as O,U as R,E as a,y as b,w as c,_ as d,C as e,Z as f,O as g,x as h,q as r,M as s,N as t};
1
+ import{m as h}from"./index-DPXW_JSn.js";const p=864e5;function k(t){const e=new Date(t);return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function S(t){return new Date(t).toISOString().slice(0,10)}const D="\0others";function O(t){return t.group!==D?t.label||t.group:t.others===void 0?"Other users":`${t.others} other ${t.others===1?"user":"users"}`}function C(t,e,o){const s=new Map;for(const n of(t==null?void 0:t.groups)??[])s.set(n.group.slice(0,10),{spent:h(n.spent),requests:n.requests});const r=[];for(let n=k(e);n<=o;n+=p){const c=S(n),u=s.get(c),l=new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});r.push({label:l,value:(u==null?void 0:u.spent)??0,sub:`${(u==null?void 0:u.requests)??0} requests`})}return r}const U=[{id:"24h",label:"24 hours",ms:p},{id:"7d",label:"7 days",ms:7*p},{id:"30d",label:"30 days",ms:30*p},{id:"90d",label:"90 days",ms:90*p}];function q(t,e=Date.now()){const o=U.find(s=>s.id===t);return t==="24h"?e-o.ms:k(e-o.ms+p)}const d=36e5;function E(t,e=Date.now()){const o=[];if(t==="24h"){const n=Math.floor(e/d)*d+d;for(let c=n-24*d;c<n;c+=d){const u=new Date(c).toLocaleTimeString("en-US",{hour:"numeric",timeZone:"UTC"});o.push({from:c,to:Math.min(c+d,e+1),label:u})}return o}const s=t==="90d"?7*p:p,r=q(t,e);for(let n=r;n<=e;n+=s){const c=new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});o.push({from:n,to:Math.min(n+s,e+1),label:c})}return o}function m(t,e){return e==="spend"?h(t.spent):e==="requests"?t.requests:t.inputTokens+t.outputTokens}const T="__other__";function M(t,e,o=6){const s=new Map;for(const a of t)for(const i of(a==null?void 0:a.groups)??[]){const f=s.get(i.group)??{label:O(i),total:0};f.total+=m(i,e),s.set(i.group,f)}const r=[...s.entries()].filter(([,a])=>a.total>0).sort((a,i)=>i[1].total-a[1].total),n=r.slice(0,o),c=new Set(n.map(([a])=>a)),u=r.slice(o).reduce((a,[,i])=>a+i.total,0),l=n.map(([a,i])=>({key:a,label:i.label,total:i.total}));u>0&&l.push({key:T,label:"Other",total:u});const b=t.map(a=>{const i={};for(const f of(a==null?void 0:a.groups)??[]){const g=c.has(f.group)?f.group:T;i[g]=(i[g]??0)+m(f,e)}return i});return{series:l,columns:b}}function _(t){return t==="24h"?"hour":"day"}function v(t){return/^\d{4}-\d{2}-\d{2}T\d{2}$/.test(t)?Date.parse(`${t}:00:00Z`):/^\d{4}-\d{2}-\d{2}$/.test(t)?Date.parse(`${t}T00:00:00Z`):Number.NaN}function y(t,e){const o=e.map(()=>new Map);for(const s of(t==null?void 0:t.groups)??[]){const r=v(s.group),n=e.findIndex(u=>r>=u.from&&r<u.to);if(n===-1)continue;const c=o[n];for(const u of s.splits??[]){const l=c.get(u.group);if(!l){c.set(u.group,{...u});continue}l.requests+=u.requests,l.failedRequests+=u.failedRequests,l.spent=(h(l.spent)+h(u.spent)).toFixed(6),l.inputTokens+=u.inputTokens,l.cachedInputTokens+=u.cachedInputTokens,l.outputTokens+=u.outputTokens}}return o.map(s=>({groups:[...s.values()]}))}const R=[{key:"input",label:"Input"},{key:"cached",label:"Cached input"},{key:"output",label:"Output"}];function N(t){const e={input:0,cached:0,output:0},o=t.map(s=>{const r={input:0,cached:0,output:0};for(const n of(s==null?void 0:s.groups)??[])r.cached+=n.cachedInputTokens,r.input+=Math.max(0,n.inputTokens-n.cachedInputTokens),r.output+=n.outputTokens;return e.input+=r.input,e.cached+=r.cached,e.output+=r.output,r});return{series:R.map(s=>({...s,total:e[s.key]})),columns:o}}function w(t){return t.reduce((e,o)=>e+((o==null?void 0:o.groups)??[]).reduce((s,r)=>s+r.requests,0),0)}const I=600*1e3;function x(t,e){return t===null?"ranking failed":e===null?t===1?"trying its first pick":`trying its pick #${t}`:e<400?t===1?"its first pick served it":`its pick #${t} served it (the ones before failed)`:t===1?"its first pick failed":`its picks #1–${t} all failed`}function Z(t,e){var o,s;return t.spent!==null&&!t.costPending?"spent":((o=t.video)==null?void 0:o.action)==="create"?t.video.charged!==null?"video-charged":"on-delivery":((s=t.video)==null?void 0:s.action)==="poll"?"not-charged":t.servedFree?"free":t.costPending?e-(t.finishedAt??t.startedAt)<I?"pending":"not-recorded":t.spent!==null?"spent":null}export{T as O,U as R,E as a,y as b,w as c,_ as d,C as e,Z as f,O as g,x as h,q as r,M as s,N as t};
@@ -1 +1 @@
1
- import{bn as v,bo as g,bp as x,bq as p,br as l}from"./index-cESr4Zze.js";var N=class extends v{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:g()})}getOptimisticResult(e){return e.behavior=g(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var f,P;const{state:s}=e,i=super.createResult(e,t),{isFetching:a,isRefetching:d,isError:c,isRefetchError:b}=i,r=(P=(f=s.fetchMeta)==null?void 0:f.fetchMore)==null?void 0:P.direction,h=c&&r==="forward",o=a&&r==="forward",n=c&&r==="backward",u=a&&r==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:p(t,s.data),hasPreviousPage:x(t,s.data),isFetchNextPageError:h,isFetchingNextPage:o,isFetchPreviousPageError:n,isFetchingPreviousPage:u,isRefetchError:b&&!h&&!n,isRefetching:d&&!o&&!u}}};function w(e,t){return l(e,N)}export{w as u};
1
+ import{b7 as v,b8 as g,b9 as x,ba as l,bb as p}from"./index-DPXW_JSn.js";var N=class extends v{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:g()})}getOptimisticResult(e){return e.behavior=g(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var f,P;const{state:s}=e,i=super.createResult(e,t),{isFetching:a,isRefetching:d,isError:c,isRefetchError:b}=i,r=(P=(f=s.fetchMeta)==null?void 0:f.fetchMore)==null?void 0:P.direction,h=c&&r==="forward",o=a&&r==="forward",n=c&&r==="backward",u=a&&r==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:l(t,s.data),hasPreviousPage:x(t,s.data),isFetchNextPageError:h,isFetchingNextPage:o,isFetchPreviousPageError:n,isFetchingPreviousPage:u,isRefetchError:b&&!h&&!n,isRefetching:d&&!o&&!u}}};function w(e,t){return p(e,N)}export{w as u};
@@ -1 +1 @@
1
- import{a4 as E,a5 as C,a6 as N,a7 as v,a8 as P,G as F,a9 as k,c as O,a1 as p,u as j,aa as B,w as H}from"./en_US-Y4ZOVFV4-sKQksBWU.js";import{bI as $,c6 as G,j as y,ah as S,r as m,c7 as q,aO as L}from"./index-cESr4Zze.js";import{w as U}from"./writeContract-Cqg_OlRQ.js";async function J(e,t){const{abi:n,chainId:r,connector:s,...a}=t;let c;t.account?c=t.account:c=(await E(e,{assertChainId:!1,chainId:r,connector:s})).account;const i=e.getClient({chainId:r}),f=C(i,N,"simulateContract"),{result:h,request:u}=await f({...a,abi:n,account:c});return{chainId:i.chain.id,result:h,request:{...u,chainId:r}}}async function z(e,t){const{chainId:n,timeout:r=0,...s}=t,a=e.getClient({chainId:n}),i=await C(a,v,"waitForTransactionReceipt")({...s,timeout:r});if(i.status==="reverted"){const f=C(a,P,"getTransaction"),{from:h,...u}=await f({hash:i.transactionHash}),w=await C(a,F,"call")({...u,account:h,data:u.input,gasPrice:u.type!=="eip1559"?u.gasPrice:void 0,maxFeePerGas:u.type==="eip1559"?u.maxFeePerGas:void 0,maxPriorityFeePerGas:u.type==="eip1559"?u.maxPriorityFeePerGas:void 0}),A=w!=null&&w.data?k(`0x${w.data.substring(138)}`):"unknown reason";throw new Error(A)}return{...i,chainId:a.chain.id}}async function D(e,t){const{account:n,chainId:r,connector:s,...a}=t;let c;return typeof n=="object"&&(n==null?void 0:n.type)==="local"?c=e.getClient({chainId:r}):c=await E(e,{account:n??void 0,assertChainId:!1,chainId:r,connector:s}),await C(c,U,"writeContract")({...a,...n?{account:n}:{},chain:r?{id:r}:null})}function M(e){return{mutationFn(t){return D(e,t)},mutationKey:["writeContract"]}}function Q(e={}){const{mutation:t}=e,n=O(e),r=M(n),{mutate:s,mutateAsync:a,...c}=$({...t,...r});return{...c,writeContract:s,writeContractAsync:a}}const X=p(["function getOperator(address buyer) view returns (address)","function getOperatorNonce(address buyer) view returns (uint256)","function setOperator(address buyer, address operator, uint256 nonce, bytes buyerSig)","function transferOperator(address buyer, address newOperator)","function withdraw(address buyer, uint256 amount)","error NotAuthorized()","error InvalidAmount()","error InvalidAddress()","error InsufficientBalance()","error InvalidSignature()","error InvalidNonce()","error OperatorAlreadySet()"]),Z=p(["function claimBuyerReward(address buyer, uint256 epoch)","error NotRewardRecipient()","error RewardRecipientUnavailable()"]),tt=p(["function channels(bytes32 channelId) view returns (address buyer, address seller, uint128 deposit, uint128 settled, bytes32 metadataHash, uint256 deadline, uint256 settledAt, uint256 closeRequestedAt, uint8 status)","function requestClose(bytes32 channelId)","function withdraw(bytes32 channelId)","error ChannelNotActive()","error NotAuthorized()","error CloseAlreadyRequested()","error CloseNotReady()"]),et=p(["function claimBuyerEmissions(address buyer, uint256[] epochs)","error NotAuthorized()","error EpochNotFinalized()"]);function nt({chain:e,runner:t,done:n="Confirmed on chain."}){const r=t.lastHash?G(e,t.lastHash):null,s=r&&y.jsx("a",{className:"gc-link",href:r,target:"_blank",rel:"noopener noreferrer",children:"View transaction"});return y.jsxs(y.Fragment,{children:[t.status&&y.jsxs(S,{tone:"info",children:[t.status," ",t.running&&t.lastHash&&s]}),t.error&&y.jsxs(S,{tone:"danger",children:[t.error," ",!t.running&&s]}),!t.running&&!t.error&&t.confirmed&&y.jsxs(S,{tone:"success",children:[n," ",s]})]})}function at(e){const t=O(),{chainId:n}=j(),{switchChainAsync:r}=B(),[s,a]=m.useState(null),[c,i]=m.useState(null),[f,h]=m.useState(null),[u,g]=m.useState(null),[w,A]=m.useState(!1);async function T(_,l={}){var I,x,R;let b=null;A(!0),i(null),g(null),h(null);try{n!==e&&(a("Switch network in your wallet…"),await r({chainId:e}));for(const o of _){o.check&&(a(`${o.label}: checking…`),await o.check()),a(`${o.label}: confirm in your wallet…`);const d=await o.send();if(b=d,h(d),a(`${o.label}: waiting for confirmation…`),(await z(t,{hash:d,chainId:e})).status!=="success")throw new Error(`${o.label} reverted on chain.`)}return a(null),g(b),b}catch(o){a(null);const d=q(o);return d?(i(d.message),d.refresh&&((I=l.onStale)==null||I.call(l))):o instanceof L?(i(o.message),o.refresh&&((x=l.onStale)==null||x.call(l))):(i(H(o)),b&&((R=l.onStale)==null||R.call(l))),null}finally{A(!1)}}return{run:T,running:w,status:s,setStatus:a,error:c,lastHash:f,confirmed:u,wrongChain:n!==void 0&&n!==e,setError:i}}export{tt as C,X as D,et as L,nt as T,Z as U,Q as a,J as s,at as u};
1
+ import{a4 as E,a5 as C,a6 as N,a7 as v,a8 as P,G as F,a9 as k,c as O,a1 as p,u as j,aa as B,w as H}from"./en_US-Y4ZOVFV4-Bkc-z49M.js";import{bm as $,c7 as G,j as y,af as S,r as m,c8 as q,aw as L}from"./index-DPXW_JSn.js";import{w as U}from"./writeContract-CaMlmKcK.js";async function J(e,t){const{abi:n,chainId:r,connector:s,...a}=t;let c;t.account?c=t.account:c=(await E(e,{assertChainId:!1,chainId:r,connector:s})).account;const i=e.getClient({chainId:r}),f=C(i,N,"simulateContract"),{result:h,request:u}=await f({...a,abi:n,account:c});return{chainId:i.chain.id,result:h,request:{...u,chainId:r}}}async function z(e,t){const{chainId:n,timeout:r=0,...s}=t,a=e.getClient({chainId:n}),i=await C(a,v,"waitForTransactionReceipt")({...s,timeout:r});if(i.status==="reverted"){const f=C(a,P,"getTransaction"),{from:h,...u}=await f({hash:i.transactionHash}),w=await C(a,F,"call")({...u,account:h,data:u.input,gasPrice:u.type!=="eip1559"?u.gasPrice:void 0,maxFeePerGas:u.type==="eip1559"?u.maxFeePerGas:void 0,maxPriorityFeePerGas:u.type==="eip1559"?u.maxPriorityFeePerGas:void 0}),A=w!=null&&w.data?k(`0x${w.data.substring(138)}`):"unknown reason";throw new Error(A)}return{...i,chainId:a.chain.id}}async function D(e,t){const{account:n,chainId:r,connector:s,...a}=t;let c;return typeof n=="object"&&(n==null?void 0:n.type)==="local"?c=e.getClient({chainId:r}):c=await E(e,{account:n??void 0,assertChainId:!1,chainId:r,connector:s}),await C(c,U,"writeContract")({...a,...n?{account:n}:{},chain:r?{id:r}:null})}function M(e){return{mutationFn(t){return D(e,t)},mutationKey:["writeContract"]}}function Q(e={}){const{mutation:t}=e,n=O(e),r=M(n),{mutate:s,mutateAsync:a,...c}=$({...t,...r});return{...c,writeContract:s,writeContractAsync:a}}const X=p(["function getOperator(address buyer) view returns (address)","function getOperatorNonce(address buyer) view returns (uint256)","function setOperator(address buyer, address operator, uint256 nonce, bytes buyerSig)","function transferOperator(address buyer, address newOperator)","function withdraw(address buyer, uint256 amount)","error NotAuthorized()","error InvalidAmount()","error InvalidAddress()","error InsufficientBalance()","error InvalidSignature()","error InvalidNonce()","error OperatorAlreadySet()"]),Z=p(["function claimBuyerReward(address buyer, uint256 epoch)","error NotRewardRecipient()","error RewardRecipientUnavailable()"]),tt=p(["function channels(bytes32 channelId) view returns (address buyer, address seller, uint128 deposit, uint128 settled, bytes32 metadataHash, uint256 deadline, uint256 settledAt, uint256 closeRequestedAt, uint8 status)","function requestClose(bytes32 channelId)","function withdraw(bytes32 channelId)","error ChannelNotActive()","error NotAuthorized()","error CloseAlreadyRequested()","error CloseNotReady()"]),et=p(["function claimBuyerEmissions(address buyer, uint256[] epochs)","error NotAuthorized()","error EpochNotFinalized()"]);function nt({chain:e,runner:t,done:n="Confirmed on chain."}){const r=t.lastHash?G(e,t.lastHash):null,s=r&&y.jsx("a",{className:"gc-link",href:r,target:"_blank",rel:"noopener noreferrer",children:"View transaction"});return y.jsxs(y.Fragment,{children:[t.status&&y.jsxs(S,{tone:"info",children:[t.status," ",t.running&&t.lastHash&&s]}),t.error&&y.jsxs(S,{tone:"danger",children:[t.error," ",!t.running&&s]}),!t.running&&!t.error&&t.confirmed&&y.jsxs(S,{tone:"success",children:[n," ",s]})]})}function at(e){const t=O(),{chainId:n}=j(),{switchChainAsync:r}=B(),[s,a]=m.useState(null),[c,i]=m.useState(null),[f,h]=m.useState(null),[u,g]=m.useState(null),[w,A]=m.useState(!1);async function T(_,l={}){var x,I,R;let b=null;A(!0),i(null),g(null),h(null);try{n!==e&&(a("Switch network in your wallet…"),await r({chainId:e}));for(const o of _){o.check&&(a(`${o.label}: checking…`),await o.check()),a(`${o.label}: confirm in your wallet…`);const d=await o.send();if(b=d,h(d),a(`${o.label}: waiting for confirmation…`),(await z(t,{hash:d,chainId:e})).status!=="success")throw new Error(`${o.label} reverted on chain.`)}return a(null),g(b),b}catch(o){a(null);const d=q(o);return d?(i(d.message),d.refresh&&((x=l.onStale)==null||x.call(l))):o instanceof L?(i(o.message),o.refresh&&((I=l.onStale)==null||I.call(l))):(i(H(o)),b&&((R=l.onStale)==null||R.call(l))),null}finally{A(!1)}}return{run:T,running:w,status:s,setStatus:a,error:c,lastHash:f,confirmed:u,wrongChain:n!==void 0&&n!==e,setError:i}}export{tt as C,X as D,et as L,nt as T,Z as U,Q as a,J as s,at as u};
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-BCJdIbrO.js";import"./index-cESr4Zze.js";import"./index.es-DP9EmOYi.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-sKQksBWU.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const c=l`<svg fill="none" viewBox="0 0 14 14">
1
+ import{w as l}from"./core-B0f6zAPS.js";import"./index-DPXW_JSn.js";import"./index.es-XdMmjy3e.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-Bkc-z49M.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const c=l`<svg fill="none" viewBox="0 0 14 14">
2
2
  <path
3
3
  fill="currentColor"
4
4
  fill-rule="evenodd"
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-BCJdIbrO.js";import"./index-cESr4Zze.js";import"./index.es-DP9EmOYi.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-sKQksBWU.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const p=l`<svg fill="none" viewBox="0 0 28 28">
1
+ import{w as l}from"./core-B0f6zAPS.js";import"./index-DPXW_JSn.js";import"./index.es-XdMmjy3e.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-Bkc-z49M.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const p=l`<svg fill="none" viewBox="0 0 28 28">
2
2
  <path
3
3
  fill="currentColor"
4
4
  fill-rule="evenodd"
@@ -1,4 +1,4 @@
1
- import{a as ve,s as fe,b as ge,p as be,M as g,S as se,R as l,i as v,r as P,c as f,d as a,A as K,e as ce,f as le,C as m,g as Y,h as ye,j as S,E as ie,O as E,k as q,l as oe,m as T,n as H,T as xe,o as Ce,q as ke,t as Se}from"./core-BCJdIbrO.js";import{c as u,n as w,r as d,o as F,U as We}from"./index-DiB9Y59V.js";import"./index-cESr4Zze.js";import"./index.es-DP9EmOYi.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-sKQksBWU.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const p=be({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),Re={state:p,subscribe(r){return ge(p,()=>r(p))},subscribeKey(r,e){return fe(p,r,e)},showTooltip({message:r,triggerRect:e,variant:t}){p.open=!0,p.message=r,p.triggerRect=e,p.variant=t},hide(){p.open=!1,p.message="",p.triggerRect={width:0,height:0,top:0,left:0}}},O=ve(Re),de={isUnsupportedChainView(){return l.state.view==="UnsupportedChain"||l.state.view==="SwitchNetwork"&&l.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){g.shake();return}if(await se.isSIWXCloseDisabled()){g.shake();return}g.close()}},$e=v`
1
+ import{a as ve,s as fe,b as ge,p as be,M as g,S as se,R as l,i as v,r as P,c as f,d as a,A as K,e as ce,f as le,C as m,g as Y,h as ye,j as S,E as ie,O as E,k as q,l as oe,m as T,n as H,T as xe,o as Ce,q as ke,t as Se}from"./core-B0f6zAPS.js";import{c as u,n as w,r as d,o as F,U as We}from"./index-BRgGxCKs.js";import"./index-DPXW_JSn.js";import"./index.es-XdMmjy3e.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-Bkc-z49M.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const p=be({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),Re={state:p,subscribe(r){return ge(p,()=>r(p))},subscribeKey(r,e){return fe(p,r,e)},showTooltip({message:r,triggerRect:e,variant:t}){p.open=!0,p.message=r,p.triggerRect=e,p.variant=t},hide(){p.open=!1,p.message="",p.triggerRect={width:0,height:0,top:0,left:0}}},O=ve(Re),de={isUnsupportedChainView(){return l.state.view==="UnsupportedChain"||l.state.view==="SwitchNetwork"&&l.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){g.shake();return}if(await se.isSIWXCloseDisabled()){g.shake();return}g.close()}},$e=v`
2
2
  :host {
3
3
  display: block;
4
4
  border-radius: clamp(0px, var(--wui-border-radius-l), 44px);
@@ -1 +1 @@
1
- import{K as y,e as _,m as I,U as O,B as C,M as R,N as x,v as q,p as S,O as L,P as E,Q as B,R as N,A as P,g as T,k as j,S as D,D as M,y as z,T as U,V as W,X as $,Y as H}from"./en_US-Y4ZOVFV4-sKQksBWU.js";import{s as G}from"./sendTransaction-Cmz5eiPq.js";const k="0x5792579257925792579257925792579257925792579257925792579257925792",A=y(0,{size:32});async function J(s,a){var g;const{account:l=s.account,chain:p=s.chain,experimental_fallback:m,experimental_fallbackDelay:d=32,forceAtomic:c=!1,id:r,version:w="2.0.0"}=a,h=l?S(l):null;let t=a.capabilities;s.dataSuffix&&!((g=a.capabilities)!=null&&g.dataSuffix)&&(typeof s.dataSuffix=="string"?t={...a.capabilities,dataSuffix:{value:s.dataSuffix,optional:!0}}:t={...a.capabilities,dataSuffix:{value:s.dataSuffix.value,...s.dataSuffix.required?{}:{optional:!0}}});const b=a.calls.map(u=>{const e=u,i=e.abi?_({abi:e.abi,functionName:e.functionName,args:e.args}):e.data;return{data:e.dataSuffix&&i?I([i,e.dataSuffix]):i,to:e.to,value:e.value?y(e.value):void 0}});try{const u=await s.request({method:"wallet_sendCalls",params:[{atomicRequired:c,calls:b,capabilities:t,chainId:y(p.id),from:h==null?void 0:h.address,id:r,version:w}]},{retryCount:0});return typeof u=="string"?{id:u}:u}catch(u){const e=u;if(m&&(e.name==="MethodNotFoundRpcError"||e.name==="MethodNotSupportedRpcError"||e.name==="UnknownRpcError"||e.details.toLowerCase().includes("does not exist / is not available")||e.details.toLowerCase().includes("missing or invalid. request()")||e.details.toLowerCase().includes("did not match any variant of untagged enum")||e.details.toLowerCase().includes("account upgraded to unsupported contract")||e.details.toLowerCase().includes("eip-7702 not supported")||e.details.toLowerCase().includes("unsupported wc_ method")||e.details.toLowerCase().includes("feature toggled misconfigured")||e.details.toLowerCase().includes("jsonrpcengine: response has no error or result for request"))){if(t&&Object.values(t).some(f=>!f.optional)){const f="non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";throw new O(new C(f,{details:f}))}if(c&&b.length>1){const n="`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";throw new R(new C(n,{details:n}))}const i=[];for(const n of b){const f=G(s,{account:h,chain:p,data:n.data,to:n.to,value:n.value?x(n.value):void 0});i.push(f),d>0&&await new Promise(F=>setTimeout(F,d))}const o=await Promise.allSettled(i);if(o.every(n=>n.status==="rejected"))throw o[0].reason;const v=o.map(n=>n.status==="fulfilled"?n.value:A);return{id:I([...v,y(p.id,{size:32}),k])}}throw q(u,{...a,account:h,chain:a.chain})}}async function K(s,a){async function l(t){if(t.endsWith(k.slice(2))){const g=B(N(t,-64,-32)),u=N(t,0,-64).slice(2).match(/.{1,64}/g),e=await Promise.all(u.map(o=>A.slice(2)!==o?s.request({method:"eth_getTransactionReceipt",params:[`0x${o}`]},{dedupe:!0}):void 0)),i=e.some(o=>o===null)?100:e.every(o=>(o==null?void 0:o.status)==="0x1")?200:e.every(o=>(o==null?void 0:o.status)==="0x0")?500:600;return{atomic:!1,chainId:E(g),receipts:e.filter(Boolean),status:i,version:"2.0.0"}}return s.request({method:"wallet_getCallsStatus",params:[t]})}const{atomic:p=!1,chainId:m,receipts:d,version:c="2.0.0",...r}=await l(a.id),[w,h]=(()=>{const t=r.status;return t>=100&&t<200?["pending",t]:t>=200&&t<300?["success",t]:t>=300&&t<700?["failure",t]:t==="CONFIRMED"?["success",200]:t==="PENDING"?["pending",100]:[void 0,t]})();return{...r,atomic:p,chainId:m?E(m):void 0,receipts:(d==null?void 0:d.map(t=>({...t,blockNumber:x(t.blockNumber),gasUsed:x(t.gasUsed),status:L[t.status]})))??[],statusCode:h,status:w,version:c}}async function Z(s,a){var w;const{account:l=s.account,chainId:p,nonce:m}=a;if(!l)throw new P({docsPath:"/docs/eip7702/prepareAuthorization"});const d=S(l),c=(()=>{if(a.executor)return a.executor==="self"?a.executor:S(a.executor)})(),r={address:a.contractAddress??a.address,chainId:p,nonce:m};return typeof r.chainId>"u"&&(r.chainId=((w=s.chain)==null?void 0:w.id)??await T(s,j,"getChainId")({})),typeof r.nonce>"u"&&(r.nonce=await T(s,D,"getTransactionCount")({address:d.address,blockTag:"pending"}),(c==="self"||c!=null&&c.address&&M(c.address,d.address))&&(r.nonce+=1)),r}class Q extends C{constructor(a){super(`Call bundle failed with status: ${a.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=a}}async function tt(s,a){const{id:l,pollingInterval:p=s.pollingInterval,status:m=({statusCode:i})=>i===200||i>=300,retryCount:d=4,retryDelay:c=({count:i})=>~~(1<<i)*200,timeout:r=6e4,throwOnFailure:w=!1}=a,h=z(["waitForCallsStatus",s.uid,l]),{promise:t,resolve:b,reject:g}=U();let u;const e=W(h,{resolve:b,reject:g},i=>{const o=$(async()=>{const v=n=>{clearTimeout(u),o(),n(),e()};try{const n=await H(async()=>{const f=await T(s,K,"getCallsStatus")({id:l});if(w&&f.status==="failure")throw new Q(f);return f},{retryCount:d,delay:c});if(!m(n))return;v(()=>i.resolve(n))}catch(n){v(()=>i.reject(n))}},{interval:p,emitOnBegin:!0});return o});return u=r?setTimeout(()=>{e(),clearTimeout(u),g(new V({id:l}))},r):void 0,await t}class V extends C{constructor({id:a}){super(`Timed out while waiting for call bundle with id "${a}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}export{K as g,Z as p,J as s,tt as w};
1
+ import{K as y,e as _,m as I,U as O,B as C,M as R,N as x,v as q,p as S,O as L,P as E,Q as B,R as N,A as P,g as T,k as j,S as D,D as M,y as z,T as U,V as W,X as $,Y as H}from"./en_US-Y4ZOVFV4-Bkc-z49M.js";import{s as G}from"./sendTransaction-k8aDYfd4.js";const k="0x5792579257925792579257925792579257925792579257925792579257925792",A=y(0,{size:32});async function J(s,a){var g;const{account:l=s.account,chain:p=s.chain,experimental_fallback:m,experimental_fallbackDelay:d=32,forceAtomic:c=!1,id:r,version:w="2.0.0"}=a,h=l?S(l):null;let t=a.capabilities;s.dataSuffix&&!((g=a.capabilities)!=null&&g.dataSuffix)&&(typeof s.dataSuffix=="string"?t={...a.capabilities,dataSuffix:{value:s.dataSuffix,optional:!0}}:t={...a.capabilities,dataSuffix:{value:s.dataSuffix.value,...s.dataSuffix.required?{}:{optional:!0}}});const b=a.calls.map(u=>{const e=u,i=e.abi?_({abi:e.abi,functionName:e.functionName,args:e.args}):e.data;return{data:e.dataSuffix&&i?I([i,e.dataSuffix]):i,to:e.to,value:e.value?y(e.value):void 0}});try{const u=await s.request({method:"wallet_sendCalls",params:[{atomicRequired:c,calls:b,capabilities:t,chainId:y(p.id),from:h==null?void 0:h.address,id:r,version:w}]},{retryCount:0});return typeof u=="string"?{id:u}:u}catch(u){const e=u;if(m&&(e.name==="MethodNotFoundRpcError"||e.name==="MethodNotSupportedRpcError"||e.name==="UnknownRpcError"||e.details.toLowerCase().includes("does not exist / is not available")||e.details.toLowerCase().includes("missing or invalid. request()")||e.details.toLowerCase().includes("did not match any variant of untagged enum")||e.details.toLowerCase().includes("account upgraded to unsupported contract")||e.details.toLowerCase().includes("eip-7702 not supported")||e.details.toLowerCase().includes("unsupported wc_ method")||e.details.toLowerCase().includes("feature toggled misconfigured")||e.details.toLowerCase().includes("jsonrpcengine: response has no error or result for request"))){if(t&&Object.values(t).some(f=>!f.optional)){const f="non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";throw new O(new C(f,{details:f}))}if(c&&b.length>1){const n="`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";throw new R(new C(n,{details:n}))}const i=[];for(const n of b){const f=G(s,{account:h,chain:p,data:n.data,to:n.to,value:n.value?x(n.value):void 0});i.push(f),d>0&&await new Promise(F=>setTimeout(F,d))}const o=await Promise.allSettled(i);if(o.every(n=>n.status==="rejected"))throw o[0].reason;const v=o.map(n=>n.status==="fulfilled"?n.value:A);return{id:I([...v,y(p.id,{size:32}),k])}}throw q(u,{...a,account:h,chain:a.chain})}}async function K(s,a){async function l(t){if(t.endsWith(k.slice(2))){const g=B(N(t,-64,-32)),u=N(t,0,-64).slice(2).match(/.{1,64}/g),e=await Promise.all(u.map(o=>A.slice(2)!==o?s.request({method:"eth_getTransactionReceipt",params:[`0x${o}`]},{dedupe:!0}):void 0)),i=e.some(o=>o===null)?100:e.every(o=>(o==null?void 0:o.status)==="0x1")?200:e.every(o=>(o==null?void 0:o.status)==="0x0")?500:600;return{atomic:!1,chainId:E(g),receipts:e.filter(Boolean),status:i,version:"2.0.0"}}return s.request({method:"wallet_getCallsStatus",params:[t]})}const{atomic:p=!1,chainId:m,receipts:d,version:c="2.0.0",...r}=await l(a.id),[w,h]=(()=>{const t=r.status;return t>=100&&t<200?["pending",t]:t>=200&&t<300?["success",t]:t>=300&&t<700?["failure",t]:t==="CONFIRMED"?["success",200]:t==="PENDING"?["pending",100]:[void 0,t]})();return{...r,atomic:p,chainId:m?E(m):void 0,receipts:(d==null?void 0:d.map(t=>({...t,blockNumber:x(t.blockNumber),gasUsed:x(t.gasUsed),status:L[t.status]})))??[],statusCode:h,status:w,version:c}}async function Z(s,a){var w;const{account:l=s.account,chainId:p,nonce:m}=a;if(!l)throw new P({docsPath:"/docs/eip7702/prepareAuthorization"});const d=S(l),c=(()=>{if(a.executor)return a.executor==="self"?a.executor:S(a.executor)})(),r={address:a.contractAddress??a.address,chainId:p,nonce:m};return typeof r.chainId>"u"&&(r.chainId=((w=s.chain)==null?void 0:w.id)??await T(s,j,"getChainId")({})),typeof r.nonce>"u"&&(r.nonce=await T(s,D,"getTransactionCount")({address:d.address,blockTag:"pending"}),(c==="self"||c!=null&&c.address&&M(c.address,d.address))&&(r.nonce+=1)),r}class Q extends C{constructor(a){super(`Call bundle failed with status: ${a.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=a}}async function tt(s,a){const{id:l,pollingInterval:p=s.pollingInterval,status:m=({statusCode:i})=>i===200||i>=300,retryCount:d=4,retryDelay:c=({count:i})=>~~(1<<i)*200,timeout:r=6e4,throwOnFailure:w=!1}=a,h=z(["waitForCallsStatus",s.uid,l]),{promise:t,resolve:b,reject:g}=U();let u;const e=W(h,{resolve:b,reject:g},i=>{const o=$(async()=>{const v=n=>{clearTimeout(u),o(),n(),e()};try{const n=await H(async()=>{const f=await T(s,K,"getCallsStatus")({id:l});if(w&&f.status==="failure")throw new Q(f);return f},{retryCount:d,delay:c});if(!m(n))return;v(()=>i.resolve(n))}catch(n){v(()=>i.reject(n))}},{interval:p,emitOnBegin:!0});return o});return u=r?setTimeout(()=>{e(),clearTimeout(u),g(new V({id:l}))},r):void 0,await t}class V extends C{constructor({id:a}){super(`Timed out while waiting for call bundle with id "${a}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}export{K as g,Z as p,J as s,tt as w};
@@ -1,4 +1,4 @@
1
- import{w as o}from"./core-BCJdIbrO.js";import"./index-cESr4Zze.js";import"./index.es-DP9EmOYi.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-sKQksBWU.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const m=o`<svg fill="none" viewBox="0 0 20 20">
1
+ import{w as o}from"./core-B0f6zAPS.js";import"./index-DPXW_JSn.js";import"./index.es-XdMmjy3e.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-Bkc-z49M.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const m=o`<svg fill="none" viewBox="0 0 20 20">
2
2
  <path
3
3
  fill="currentColor"
4
4
  fill-rule="evenodd"
@@ -1,4 +1,4 @@
1
- import{w as a}from"./core-BCJdIbrO.js";import"./index-cESr4Zze.js";import"./index.es-DP9EmOYi.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-sKQksBWU.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const c=a`
1
+ import{w as a}from"./core-B0f6zAPS.js";import"./index-DPXW_JSn.js";import"./index.es-XdMmjy3e.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-Bkc-z49M.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const c=a`
2
2
  <svg fill="none" viewBox="0 0 48 44">
3
3
  <path
4
4
  style="fill: var(--wui-color-bg-300);"
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-BCJdIbrO.js";import"./index-cESr4Zze.js";import"./index.es-DP9EmOYi.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-sKQksBWU.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const r=l`<svg fill="none" viewBox="0 0 96 67">
1
+ import{w as l}from"./core-B0f6zAPS.js";import"./index-DPXW_JSn.js";import"./index.es-XdMmjy3e.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-Bkc-z49M.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const r=l`<svg fill="none" viewBox="0 0 96 67">
2
2
  <path
3
3
  fill="currentColor"
4
4
  d="M25.32 18.8a32.56 32.56 0 0 1 45.36 0l1.5 1.47c.63.62.63 1.61 0 2.22l-5.15 5.05c-.31.3-.82.3-1.14 0l-2.07-2.03a22.71 22.71 0 0 0-31.64 0l-2.22 2.18c-.31.3-.82.3-1.14 0l-5.15-5.05a1.55 1.55 0 0 1 0-2.22l1.65-1.62Zm56.02 10.44 4.59 4.5c.63.6.63 1.6 0 2.21l-20.7 20.26c-.62.61-1.63.61-2.26 0L48.28 41.83a.4.4 0 0 0-.56 0L33.03 56.21c-.63.61-1.64.61-2.27 0L10.07 35.95a1.55 1.55 0 0 1 0-2.22l4.59-4.5a1.63 1.63 0 0 1 2.27 0L31.6 43.63a.4.4 0 0 0 .57 0l14.69-14.38a1.63 1.63 0 0 1 2.26 0l14.69 14.38a.4.4 0 0 0 .57 0l14.68-14.38a1.63 1.63 0 0 1 2.27 0Z"
@@ -1,4 +1,4 @@
1
- import{w as r}from"./core-BCJdIbrO.js";import"./index-cESr4Zze.js";import"./index.es-DP9EmOYi.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-sKQksBWU.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const n=r`<svg fill="none" viewBox="0 0 20 20">
1
+ import{w as r}from"./core-B0f6zAPS.js";import"./index-DPXW_JSn.js";import"./index.es-XdMmjy3e.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-Bkc-z49M.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const n=r`<svg fill="none" viewBox="0 0 20 20">
2
2
  <path
3
3
  fill="currentColor"
4
4
  d="M11 6.67a1 1 0 1 0-2 0v2.66a1 1 0 0 0 2 0V6.67ZM10 14.5a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z"
@@ -1 +1 @@
1
- import{A as g,e as l,g as y,d as A,p as C}from"./en_US-Y4ZOVFV4-sKQksBWU.js";import{s as E}from"./sendTransaction-Cmz5eiPq.js";async function a(n,r){return a.internal(n,E,"sendTransaction",r)}(function(n){async function r(c,u,f,w){const{abi:s,account:o=c.account,address:e,args:i,functionName:d,...p}=w;if(typeof o>"u")throw new g({docsPath:"/docs/contract/writeContract"});const t=o?C(o):null,h=l({abi:s,args:i,functionName:d});try{return await y(c,u,f)({data:h,to:e,account:t,...p})}catch(m){throw A(m,{abi:s,address:e,args:i,docsPath:"/docs/contract/writeContract",functionName:d,sender:t==null?void 0:t.address})}}n.internal=r})(a||(a={}));export{a as w};
1
+ import{A as g,e as l,g as y,d as A,p as C}from"./en_US-Y4ZOVFV4-Bkc-z49M.js";import{s as E}from"./sendTransaction-k8aDYfd4.js";async function a(n,r){return a.internal(n,E,"sendTransaction",r)}(function(n){async function r(c,u,f,w){const{abi:s,account:o=c.account,address:e,args:i,functionName:d,...p}=w;if(typeof o>"u")throw new g({docsPath:"/docs/contract/writeContract"});const t=o?C(o):null,h=l({abi:s,args:i,functionName:d});try{return await y(c,u,f)({data:h,to:e,account:t,...p})}catch(m){throw A(m,{abi:s,address:e,args:i,docsPath:"/docs/contract/writeContract",functionName:d,sender:t==null?void 0:t.address})}}n.internal=r})(a||(a={}));export{a as w};
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-BCJdIbrO.js";import"./index-cESr4Zze.js";import"./index.es-DP9EmOYi.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-sKQksBWU.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const r=l`<svg fill="none" viewBox="0 0 41 40">
1
+ import{w as l}from"./core-B0f6zAPS.js";import"./index-DPXW_JSn.js";import"./index.es-XdMmjy3e.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-Bkc-z49M.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const r=l`<svg fill="none" viewBox="0 0 41 40">
2
2
  <g clip-path="url(#a)">
3
3
  <path fill="#000" d="M.8 0h40v40H.8z" />
4
4
  <path
package/dist/index.html CHANGED
@@ -7,8 +7,8 @@
7
7
  <meta name="referrer" content="no-referrer" />
8
8
  <title>Antseed Console</title>
9
9
  <link rel="icon" type="image/svg+xml" href="/console/assets/antseed-mark-3TDLhfuw.svg" />
10
- <script type="module" crossorigin src="/console/assets/index-cESr4Zze.js"></script>
11
- <link rel="stylesheet" crossorigin href="/console/assets/index-DYK1gWhP.css">
10
+ <script type="module" crossorigin src="/console/assets/index-DPXW_JSn.js"></script>
11
+ <link rel="stylesheet" crossorigin href="/console/assets/index-BAcoKUeC.css">
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antseed/gateway-console",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Antseed gateway console: the web app the gateway serves at /console",
5
5
  "type": "module",
6
6
  "files": [
@@ -1 +0,0 @@
1
- import{r as o,U as A,V as y,j as e,P as w,B as b,l as P,W as N,X as S,M as d,Y as C,Z as x,L as E,$ as I,E as g,I as m,o as L,v as T,f as F,q as M}from"./index-cESr4Zze.js";import{u as $}from"./useInfiniteQuery-zD1WIYBy.js";import{S as h}from"./SelectField-Cl4acfcI.js";import{D as z}from"./DataTable-BkJdorEh.js";const B=50,W=[{value:"",label:"All actions"},{value:"auth",label:"Sign-ins"},{value:"key",label:"API keys"},{value:"member",label:"Members"},{value:"invite",label:"Invites"},{value:"workspace",label:"Workspaces"},{value:"routing",label:"Gateway routing"},{value:"peer_list",label:"Peer lists"},{value:"preset",label:"Presets"},{value:"wallet",label:"Wallets"},{value:"channel",label:"Channels"},{value:"settings",label:"Settings"},{value:"token",label:"Management tokens"}],u={member:"Member",token:"Token",key:"API key",system:"System",cli:"CLI"};function c(t){return t.actor.label??t.actor.id??u[t.actor.kind]}function D(t){return $({queryKey:M.audit(t),queryFn:({pageParam:i})=>F.audit.list({...t,before:i??void 0,limit:B}),initialPageParam:null,getNextPageParam:i=>i.nextBefore})}function R({query:t,filtered:i,onSelect:l}){var s;if(t.isLoading)return e.jsx(E,{rows:8});if(I(t.error)&&t.error.status===404)return e.jsx(g,{icon:e.jsx(m.audit,{size:18}),title:"Audit log not available",body:"This gateway version does not record an audit log yet."});if(t.error)return e.jsx(L,{error:t.error,onRetry:()=>void t.refetch()});const n=((s=t.data)==null?void 0:s.pages.flatMap(a=>a.entries))??[];return e.jsxs(e.Fragment,{children:[e.jsx(z,{label:"Audit log",rows:n,rowKey:a=>a.id,onRowClick:l,rowLabel:a=>`${a.action} by ${c(a)}`,empty:e.jsx(g,{icon:e.jsx(m.audit,{size:18}),title:i?"No entries match":"Nothing recorded yet"}),columns:[{key:"at",header:"When",render:a=>e.jsx("span",{className:"gc-nowrap",children:x(a.at)})},{key:"actor",header:"Who",secondary:!0,render:a=>e.jsxs("span",{children:[c(a)," ",e.jsx(T,{children:u[a.actor.kind]})]})},{key:"action",header:"Action",render:a=>e.jsxs(e.Fragment,{children:[e.jsx(d,{children:a.action}),e.jsx("div",{className:"gc-narrow-only gc-muted",children:c(a)})]})},{key:"target",header:"Target",secondary:!0,render:a=>a.target?a.target.label??a.target.id??a.target.kind:"—"},{key:"ip",header:"IP",secondary:!0,optional:!0,render:a=>a.ip?e.jsx(d,{children:a.ip}):"—"}]}),t.hasNextPage&&e.jsx("div",{className:"gc-load-more",children:e.jsx(b,{variant:"outline",size:"sm",disabled:t.isFetchingNextPage,onClick:()=>void t.fetchNextPage(),children:t.isFetchingNextPage?"Loading…":"Load older entries"})})]})}function Z(){const[t,i]=o.useState(""),[l,n]=o.useState(""),[s,a]=o.useState(null),v=A(),j=y(),p=[{value:"",label:"Anyone"},...(v.data??[]).map(r=>({value:r.id,label:r.label})),...(j.data??[]).map(r=>({value:r.id,label:`Token: ${r.label}`}))],k=o.useMemo(()=>({actor:t||void 0,action:l||void 0}),[t,l]),f=D(k);return e.jsxs("div",{className:"gc-page",children:[e.jsx(w,{title:"Audit log",description:"Who changed what in this organization: keys, members, workspaces, routing, wallets and settings."}),e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(h,{size:"sm","aria-label":"Filter by who",value:t,onChange:i,options:p}),e.jsx(h,{size:"sm","aria-label":"Filter by action",value:l,onChange:n,options:W}),(t||l)&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>{i(""),n("")},children:"Clear filters"})]}),e.jsx(P,{flush:!0,children:e.jsx(R,{query:f,filtered:!!(t||l),onSelect:a})}),e.jsx(N,{isOpen:s!==null,onClose:()=>a(null),eyebrow:"Audit entry",title:(s==null?void 0:s.action)??"",subtitle:s?x(s.at):void 0,children:s&&e.jsxs(e.Fragment,{children:[e.jsx(S,{items:[["Who",`${c(s)} (${u[s.actor.kind]})`],["Actor id",s.actor.id?e.jsx(d,{children:s.actor.id},"a"):"—"],["Target",s.target?`${s.target.kind}: ${s.target.label??s.target.id??"—"}`:"—"],["IP address",s.ip??"—"],["Entry id",e.jsx(d,{children:s.id},"i")]]}),Object.keys(s.details).length>0&&e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("div",{className:"as-field__label",children:"Details"}),e.jsx(C,{code:JSON.stringify(s.details,null,2)})]})]})})]})}export{Z as default};
@@ -1 +0,0 @@
1
- import{r as y,a3 as G,a4 as J,a5 as K,a6 as B,u as X,a7 as Z,j as e,a8 as ee,a9 as se,aa as le,ab as A,B as j,ac as ie,ad as F,T as z,D as ne,ae as E,I as ae,af as te,ag as re,ah as ce,ai as oe,aj as de,ak as me,al as he}from"./index-cESr4Zze.js";import{P as k,C as ue}from"./PeerPicker-CfsXTUyK.js";import{S}from"./SelectField-Cl4acfcI.js";import{S as v}from"./Segmented-D3e0aBDU.js";import{S as T}from"./Switch-B2AEvyu7.js";import{D as R}from"./Disclosure-DMLE7rCw.js";function pe({draft:l,parent:d,above:t,peers:c,lists:m}){const n=y.useMemo(()=>{if(!c||c.length===0)return null;let h;try{h=te(l,m)}catch{return null}return{matched:re(B(d,h),c,m).length,total:c.length}},[l,d,c,m]);return n?n.matched===0?e.jsxs(ce,{tone:"warning",title:"No seller matches this policy",children:["With ",t?`${t} and `:"","these settings, none of the ",n.total," sellers this gateway sees can serve a request. Requests will fail until you loosen it."]}):e.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",n.matched," of ",n.total," sellers",t?` after ${t}`:"","."]}):null}function Ne({value:l,onChange:d,peers:t,lists:c,showTemplates:m=!0,parent:n,disabled:h}){const[x,b]=y.useState(""),[o,p]=y.useState(null),a=(s,r)=>d({...l,[s]:r}),N=G(t),I=c.map(s=>({value:s.id,label:`${s.name} (${s.peerIds.length})`})),g=J(K().data),i=y.useMemo(()=>g||n?B(g,n):null,[g,n]),D=g&&n?"the buyer config and the levels above":g?"the buyer config":n?"the levels above":"",w=s=>(g==null?void 0:g[s])!==void 0&&g[s]===(i==null?void 0:i[s])?"The buyer config":"The levels above",{viewer:W}=X(),Y=Z("settings",W)?e.jsx("a",{className:"gc-link",href:se("settings?tab=buyer"),onClick:ee("settings?tab=buyer"),children:"Change"}):null,O=s=>w(s)==="The buyer config"?Y:null,H=le(t)||l.minReputation!==""||(i==null?void 0:i.minReputation)!==void 0;function q(s){var $;let r;if(s==="own"){const C=c.find(Q=>Q.id===x);if(!C)return;r={allowMode:"only",allowedPeerIds:[],allowedListIds:[C.id]}}else r=oe(de(s));const u=me(l,r),f=(($=A.find(C=>C.id===s))==null?void 0:$.label)??s;u.length>0?p({label:f,template:r,conflicts:u}):d(E(l,r))}function P(s,r){a("routes",l.routes.map((u,f)=>f===s?r:u))}const M=[l.maxInputUsdPerMillion,l.maxOutputUsdPerMillion,l.maxCachedInputUsdPerMillion,l.maxImageUsdPerImage].filter(s=>s.trim()!=="").length,_=(s,r)=>e.jsx(z,{size:"sm",className:"gc-num",label:r,inputMode:"decimal",value:l[s],placeholder:(i==null?void 0:i[s])!==void 0?`≤ ${he(i[s])} above`:"No cap",onChange:u=>a(s,u.target.value)}),L=e.jsxs(e.Fragment,{children:[e.jsx(pe,{draft:l,parent:i,above:D,peers:t,lists:c}),m&&!h&&e.jsxs("div",{className:"gc-policy__templates",children:[e.jsx("span",{className:"gc-muted",children:"Start from"}),A.filter(s=>s.id!=="own").map(s=>e.jsx(j,{size:"sm",variant:"outline",title:s.description,onClick:()=>q(s.id),children:s.label},s.id)),c.length>0&&e.jsxs("span",{className:"gc-inline",children:[e.jsx(S,{size:"sm","aria-label":"Peer list for Own peers only",value:x,onChange:b,options:[{value:"",label:"Own peer list…"},...I]}),e.jsx(j,{size:"sm",variant:"outline",disabled:!x,onClick:()=>q("own"),children:"Use"})]}),e.jsx(j,{size:"sm",variant:"link",className:"gc-policy__clear",onClick:()=>d(ie()),children:"Clear policy"})]}),e.jsxs("div",{className:"gc-policy__cols",children:[e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Sellers"}),e.jsx(v,{label:"Which sellers may serve",value:l.allowMode,onChange:s=>a("allowMode",s),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),l.allowMode==="only"&&e.jsxs(e.Fragment,{children:[e.jsx(k,{label:"Allowed sellers",value:l.allowedPeerIds,onChange:s=>a("allowedPeerIds",s),peers:t}),e.jsx(V,{label:"Allowed peer lists",lists:c,value:l.allowedListIds,onChange:s=>a("allowedListIds",s)}),l.allowedPeerIds.length===0&&l.allowedListIds.length===0&&e.jsx("p",{className:"gc-warn",children:"An empty allow list means no seller can serve."})]}),e.jsx(k,{label:"Blocked sellers",value:l.blockedPeerIds,onChange:s=>a("blockedPeerIds",s),peers:t}),e.jsx(V,{label:"Blocked peer lists",lists:c,value:l.blockedListIds,onChange:s=>a("blockedListIds",s)})]}),e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Quality and ranking"}),e.jsx(U,{label:"Minimum trust score",value:l.minTrustScore,onChange:s=>a("minTrustScore",s),floor:i==null?void 0:i.minTrustScore,floorSource:w("minTrustScore"),floorAction:O("minTrustScore")}),e.jsxs("div",{className:"gc-policy__switches",children:[e.jsx(T,{checked:l.requireTee||!!(i!=null&&i.requireTee),disabled:!!(i!=null&&i.requireTee),onChange:s=>a("requireTee",s),label:"TEE sellers only"}),e.jsx(T,{checked:l.requireVerified||!!(i!=null&&i.requireVerified),disabled:!!(i!=null&&i.requireVerified),onChange:s=>a("requireVerified",s),label:"Verified sellers only"})]}),((i==null?void 0:i.requireTee)||(i==null?void 0:i.requireVerified))&&e.jsxs("span",{className:"as-field__hint",children:[i.requireTee&&i.requireVerified?"TEE and verified sellers are":i.requireTee?"TEE sellers are":"Verified sellers are"," already required above."]}),e.jsxs("div",{className:"gc-policy__pair",children:[e.jsx(S,{size:"sm",label:"Sort by",value:l.sort,onChange:s=>a("sort",s),options:[{value:"",label:"Inherit"},...Object.keys(F).map(s=>({value:s,label:F[s]}))]}),e.jsx(S,{size:"sm",label:"Free sellers first",value:l.preferFreePeers,onChange:s=>a("preferFreePeers",s),options:[{value:"inherit",label:"Inherit"},{value:"yes",label:"Yes"},{value:"no",label:"No"}]})]}),e.jsx(v,{label:"Which models may be used",value:l.modelsMode,onChange:s=>a("modelsMode",s),options:[{value:"any",label:"Any model"},{value:"only",label:"Only these models"}]}),l.modelsMode==="only"&&e.jsx(ue,{label:"Allowed models",value:l.allowedModels,onChange:s=>a("allowedModels",s),suggestions:N,placeholder:"Model id"})]})]}),e.jsxs("div",{className:"gc-policy__advanced",children:[e.jsx(R,{title:"Price caps",summary:M?`${M} set`:"None",defaultOpen:h&&M>0,children:e.jsxs("div",{className:"gc-policy__caps",children:[_("maxInputUsdPerMillion","Input $/M"),_("maxOutputUsdPerMillion","Output $/M"),_("maxCachedInputUsdPerMillion","Cached input $/M"),_("maxImageUsdPerImage","$ per image")]})}),e.jsxs(R,{title:"Fallback chains",summary:l.routes.length?`${l.routes.length} chain${l.routes.length===1?"":"s"}`:"None",defaultOpen:h&&l.routes.length>0,children:[e.jsx("p",{className:"gc-fineprint",children:"Sellers to try first for a model, in order. After the chain, normal ranking continues unless the chain is strict."}),l.routes.map((s,r)=>e.jsxs("div",{className:"gc-route",children:[e.jsxs("div",{className:"gc-inline",children:[e.jsx(z,{size:"sm",label:"Model",list:"gc-policy-models",value:s.model,placeholder:"Model id",onChange:u=>P(r,{...s,model:u.target.value})}),e.jsx(T,{checked:s.strict,onChange:u=>P(r,{...s,strict:u}),label:"Strict"}),e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>a("routes",l.routes.filter((u,f)=>f!==r)),children:"Remove"})]}),e.jsx(k,{label:"Sellers, in order",ordered:!0,value:s.peerIds,onChange:u=>P(r,{...s,peerIds:u}),peers:t})]},r)),e.jsx("datalist",{id:"gc-policy-models",children:N.map(s=>e.jsx("option",{value:s},s))}),e.jsx("div",{children:e.jsx(j,{variant:"outline",size:"sm",onClick:()=>a("routes",[...l.routes,{model:"",peerIds:[],strict:!1}]),children:"Add fallback chain"})})]}),H&&e.jsx(R,{title:"Reputation",summary:l.minReputation!==""?`≥ ${l.minReputation}`:(i==null?void 0:i.minReputation)!==void 0?`Inherit (≥ ${i.minReputation})`:"Inherit",defaultOpen:h&&l.minReputation!=="",children:e.jsx(U,{label:"Minimum reputation",value:l.minReputation,onChange:s=>a("minReputation",s),floor:i==null?void 0:i.minReputation,floorSource:w("minReputation"),floorAction:O("minReputation")})})]}),e.jsx(ne,{isOpen:o!==null,tone:"primary",title:`Apply “${(o==null?void 0:o.label)??""}”?`,confirmLabel:"Replace and apply",body:e.jsxs(e.Fragment,{children:["This template changes settings you already set: ",e.jsx("strong",{children:o==null?void 0:o.conflicts.join(", ")}),". Your other settings stay."]}),onClose:()=>p(null),onConfirm:()=>{o&&d(E(l,o.template)),p(null)}})]});return h?e.jsx("fieldset",{className:"gc-policy gc-policy--readonly",disabled:!0,children:L}):e.jsx("div",{className:"gc-policy",children:L})}function U({label:l,value:d,onChange:t,clearable:c=!0,hint:m,floor:n,floorSource:h="The levels above",floorAction:x}){const b=y.useId(),o=d!=="",p=n!==void 0&&n>0,a=p&&o&&Number(d)<=n,N=a?String(n):o?d:p?`${n} inherited`:"Inherit";return e.jsxs("div",{className:"gc-slider",children:[e.jsxs("div",{className:"gc-slider__head",children:[e.jsx("span",{className:"as-field__label",id:b,children:l}),e.jsx("span",{className:o?"gc-slider__value":"gc-slider__value gc-slider__value--inherit",children:N})]}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{type:"range",min:0,max:100,step:5,value:o?Math.max(Number(d),p?n:0):p?n:0,"aria-labelledby":b,onChange:I=>t(String(Math.max(Number(I.target.value),p?n:0)))}),c&&o&&e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>t(""),children:"Clear"})]}),p&&(o&&!a?e.jsxs("span",{className:"as-field__hint",children:[h," requires ≥ ",n,". Only a higher value narrows it."]}):e.jsxs("span",{className:"as-field__hint gc-override",children:[e.jsx(ae.lock,{size:12})," Locked at ",n," by ",h.replace(/^The /,"the "),".",x?e.jsxs(e.Fragment,{children:[" ",x]}):null]})),m&&e.jsx("span",{className:"as-field__hint",children:m})]})}function V({label:l,lists:d,value:t,onChange:c}){return d.length===0?null:e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:l}),d.map(m=>e.jsxs("label",{className:"gc-check",children:[e.jsx("input",{type:"checkbox",checked:t.includes(m.id),onChange:n=>c(n.target.checked?[...t,m.id]:t.filter(h=>h!==m.id))}),m.name," ",e.jsxs("span",{className:"gc-muted",children:["(",m.peerIds.length,")"]})]},m.id))]})}export{Ne as P,U as S};
@@ -1 +0,0 @@
1
- import{bs as p,r as d,j as e,D as m,bt as x,bu as v,bv as b,v as j,bw as f,bx as w,af as y,b as C,B as h,C as k}from"./index-cESr4Zze.js";import{P}from"./PolicyEditor-ptFDJhFh.js";function B(){const a=p(),[s,n]=d.useState(null),l=d.useRef(null),r=t=>new Promise(u=>{l.current=u,n(t)}),o=t=>{var u;n(null),(u=l.current)==null||u.call(l,t),l.current=null},i=(t,u)=>x(t.some(g=>v(g,a.data??null)),u,r),c=(s==null?void 0:s.kind)==="narrowed"?e.jsx(m,{isOpen:!0,tone:"primary",title:"The levels above allow less",confirmLabel:"Save anyway",cancelLabel:"Go back",onClose:()=>o(!1),onConfirm:()=>o(!0),body:e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("span",{children:"Part of this change has no effect, because a workspace, member or admin restriction above it is tighter. Saving stores it as you entered it; only what the levels above allow applies."}),s.lines.length>0&&e.jsx("ul",{className:"gc-list",children:s.lines.map(t=>e.jsx("li",{children:t},t))})]})}):e.jsx(m,{isOpen:(s==null?void 0:s.kind)==="empty",tone:"danger",title:"Save an empty allow list?",confirmLabel:"Save anyway",cancelLabel:"Go back",onClose:()=>o(!1),onConfirm:()=>o(!0),body:e.jsxs(e.Fragment,{children:["With this allow list ",e.jsx("strong",{children:"no seller can serve"})," requests here (it names no seller, or none the levels above allow), so they fail until you change it. To let any seller serve, choose “Any seller” instead."]})});return{save:i,dialog:c}}function S({policy:a,invalid:s,empty:n="Inherits everything"}){if(s)return e.jsx("span",{className:"gc-warn",children:"Has an invalid setting; open it to fix."});const l=b(a);return l.length===0?e.jsx("span",{className:"gc-muted",children:n}):e.jsx("span",{className:"gc-chiprow",children:l.map(r=>e.jsx(j,{children:r},r))})}function D(a){const[s,n]=d.useState(()=>f(a)),l=p();return{draft:s,setDraft:n,reset:r=>n(f(r)),build:()=>w(y(s,l.data??null))}}function N(a,s){try{return{policy:y(a,s),error:null}}catch(n){return{policy:null,error:n instanceof Error?n.message:String(n)}}}function O({draft:a,setDraft:s,title:n="Routing policy"}){const l=C(),r=p(),[o,i]=d.useState(null),c=N(a,r.data??null),t=()=>{o&&s(o),i(null)};return e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx("span",{className:"as-field__label",children:n}),e.jsx(S,{policy:c.policy,invalid:c.error!==null})]}),e.jsx(h,{size:"sm",variant:"outline",onClick:()=>i(a),children:"Edit"}),e.jsx(k,{isOpen:o!==null,onClose:()=>i(null),size:"xl",title:n,subtitle:"Blank settings inherit from the level above, which this can only narrow. Saved with the form.",footer:e.jsxs(e.Fragment,{children:[c.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:c.error}),e.jsx(h,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(h,{onClick:()=>i(null),children:"Done"})]}),children:e.jsx(P,{value:a,onChange:s,peers:l.data,lists:r.data??[]})})]})}export{O as P,B as a,N as d,D as u};
@@ -1 +0,0 @@
1
- import{b$ as Ke,ay as pe,b5 as Ge,u as Z,a as fe,F as Qe,G as Ye,n as we,i as ye,r as p,U as He,c as ve,e as Je,c0 as We,bI as Ze,$ as q,c1 as Xe,c2 as es,f as A,aF as ss,j as s,C as X,ah as Q,o as ee,B as k,L as be,A as ts,bs as rs,t as ke,q as xe,l as je,Q as Pe,E as W,I as U,D as ns,T as V,w as F,M as Se,aN as Ce,v as L,at as as,bZ as N,aw as Ie,ax as Ne,h as $e,Z as os,bi as Ae,c3 as Fe,bf as ls,bm as is,c4 as cs,Y as ds,bh as us,O as ms,R as hs,by as gs,b as ps,a3 as fs,aa as ws,bD as ys,bE as vs,bk as ce,c5 as bs,y as de,bl as ks,P as xs}from"./index-cESr4Zze.js";import{p as Y,P as js}from"./PeerPicker-CfsXTUyK.js";import{S as $}from"./SelectField-Cl4acfcI.js";import{D as Le}from"./DataTable-BkJdorEh.js";import{V as Te,T as Me}from"./VerificationLinks-CERoRvCR.js";import{P as De,a as Ps,p as Ss,S as Cs}from"./SidePanel-D0rNElh3.js";import{f as Is}from"./ants-B38m9Phv.js";import{PresetForm as Ns}from"./Presets-szQETQLM.js";import{T as $s,a as As}from"./Tabs-Cv10NtDy.js";import{S as H}from"./Switch-B2AEvyu7.js";import"./PolicyField-CHhm50jF.js";import"./PolicyEditor-ptFDJhFh.js";import"./Segmented-D3e0aBDU.js";import"./roving-DkptacxO.js";import"./Disclosure-DMLE7rCw.js";import"./TextAreaField-Dbr655cs.js";function Ee(e,t="admin"){return t==="owner"&&Ge(e)?"ownerRoutingPolicy":"routingPolicy"}async function Oe(e,t){const r=(await e.keys.list({workspace:t.workspaceId})).find(a=>a.id===t.keyId);if(!r)throw new Error("That key no longer exists.");return r}async function Re(e,t){switch(t.kind){case"gateway":return e.network.gatewayPolicy();case"workspace-org":return(await e.workspaces.get(t.workspaceId)).orgRoutingPolicy;case"workspace":return(await e.workspaces.get(t.workspaceId)).routingPolicy;case"member":{const r=(await e.members.list()).find(a=>a.id===t.memberId);if(!r)throw new Error("That member no longer exists.");return r.routingPolicy}case"key":{const r=await Oe(e,t);return r[Ee(r,t.layer)]??null}}}async function Fs(e,t,r,a){const o=a!=null&&a.confirmEmpty||a!=null&&a.acceptNarrowed?[a]:[];switch(t.kind){case"gateway":await e.network.setGatewayPolicy(r??{},...o);return;case"workspace-org":await e.workspaces.update(t.workspaceId,{orgRoutingPolicy:r},...o);return;case"workspace":await e.workspaces.update(t.workspaceId,{routingPolicy:r},...o);return;case"member":await e.members.update(t.memberId,{routingPolicy:r},...o);return;case"key":{const i=t.layer==="owner"?Ee(await Oe(e,t),"owner"):"routingPolicy";await e.keys.update(t.keyId,{[i]:r},...o);return}}}const ue=e=>JSON.stringify(e??{},Object.keys(e??{}).sort());async function Ls(e,t,r,a,o,i){const m=await Re(e,t),c=Ke(m,r,a,o),g=ue(m)!==ue(c)||JSON.stringify(m??{})!==JSON.stringify(c);return g&&await Fs(e,t,c,i),{before:m,after:c,changed:g}}function Ts(e,t,r){return e.kind==="key"?{model:t,key:e.keyId,workspace:e.workspaceId}:e.kind==="member"?{model:t,member:e.memberId,workspace:r}:e.kind==="gateway"?{model:t,workspace:r}:{model:t,workspace:e.workspaceId}}const Ms={allow:"Allowed",block:"Blocked",prefer:"Preferred"};function Ds(e){const{action:t,name:r,scopeLabel:a,changed:o,model:i,preview:m,peerId:c}=e,g=Ms[t],f=t==="prefer"?`already first for ${i}`:`already ${g.toLowerCase()}`,l=o?`${g} ${r} ${t==="prefer"?`for ${i} `:""}on ${a}`:`${r} was ${f} on ${a}; nothing changed`;if(!m)return t==="block"?{tone:o?"success":"info",text:`${l}.`}:{tone:"info",text:`${l}. ${e.previewError?`Could not check whether it can serve: ${e.previewError}`:"Could not check whether it can serve."}`};const u=m.candidates.find(v=>pe(v.peerId,c));if(t==="block")return u!=null&&u.eligible?{tone:"warning",text:`${l}, but the route preview still lists it as eligible for ${i}. Reload and check the policy.`}:{tone:o?"success":"info",text:`${l}.`};if(!m.modelAllowed)return{tone:"warning",text:`${l}, but ${i} is not an allowed model here, so it still cannot serve it.`};if(!u)return{tone:"info",text:`${l}. It does not offer ${i} right now, so the preview cannot show its rank.`};if(!u.eligible){const v=u.reasons.length?u.reasons.join("; "):"another level excludes it";return{tone:"warning",text:`${l}, but it still cannot serve ${i} here: ${v}.`}}return t==="prefer"&&u.rank!==null&&u.rank>1?{tone:"warning",text:`${l}, but it ranks #${u.rank} for ${i}: a fallback chain on another level comes first.`}:{tone:o?"success":"info",text:`${l}.${u.rank?` It ranks #${u.rank} for ${i}.`:""}`}}function Es(e,t,r,a){return e==="gateway"?{kind:e}:e==="workspace"||e==="workspace-org"?{kind:e,workspaceId:r}:t?e==="member"?{kind:e,memberId:t}:{kind:"key",keyId:t,workspaceId:r,layer:a?"admin":"owner"}:null}function Os(e){return e.canForce?"Not allowed above":e.tone==="warning"?"Check the result":"Done"}function Rs({fetching:e,error:t,ready:r,policy:a}){return e?s.jsx(be,{rows:1}):t?s.jsx(ee,{error:t,title:"Could not load this scope's policy"}):r?s.jsxs("p",{className:"gc-muted",children:["Current policy: ",ts(a)]}):null}const me={allow:{title:"Allow seller",verb:"Allow"},block:{title:"Block seller",verb:"Block"},prefer:{title:"Prefer seller",verb:"Prefer"}};function Be({peer:e,action:t,onClose:r,peers:a}){var te,re,ne,ae;const{viewer:o,workspace:i,me:m}=Z(),c=fe(),g=Qe(),f=Ye(),l=we(o),u=ye(o),v=[...l?[{value:"gateway",label:"Gateway default (everyone)"}]:[],...l?[{value:"workspace-org",label:`${i.name}: organization policy`}]:[],...u?[{value:"workspace",label:`${i.name}: workspace policy`}]:[],...l?[{value:"member",label:"A member"}]:[],{value:"key",label:"An API key"}],[y,h]=p.useState(v[0].value),[n,b]=p.useState(""),[x,E]=p.useState(""),O=He(y==="member"),R=ve(c,y==="key");p.useEffect(()=>{b("")},[y]),p.useEffect(()=>{var d;E(((d=e==null?void 0:e.services[0])==null?void 0:d.service)??"")},[e]);const w=(R.data??[]).filter(d=>d.status==="active"&&(u||d.ownerMemberId===m.member.id)),j=Es(y,n,i.id,u),[C,M]=p.useState(null);p.useEffect(()=>{M(null)},[y,n,e]);const B=Je({queryKey:["routing","scope-policy",j],queryFn:()=>Re(A,j),enabled:j!==null&&e!==null,staleTime:0}),z=j!==null&&B.isSuccess&&(t!=="prefer"||x!==""),I=B.data??null,Ue=t==="allow"&&z&&!(I!=null&&I.allowedPeerIds)&&!(I!=null&&I.allowedPeerLists),Ve=t==="block"&&z&&e!==null&&We(I,e.peerId);let D=((te=v.find(d=>d.value===y))==null?void 0:te.label.replace(/^A[n]? /,"the "))??"this scope";y==="key"&&(D=`key “${((re=w.find(d=>d.id===n))==null?void 0:re.label)??n}”`),y==="member"&&(D=`member “${((ae=(ne=O.data)==null?void 0:ne.find(d=>d.id===n))==null?void 0:ae.label)??n}”`);const P=Ze({mutationFn:async(d={})=>{var ie;if(!e||!j)return null;const S=x||((ie=e.services[0])==null?void 0:ie.service)||"",{changed:G}=await Ls(A,j,t,e.peerId,x||void 0,d);let oe=null,le=null;if(S)try{oe=await A.network.routePreview(Ts(j,S,i.id))}catch(_e){le=ss(_e)}return Ds({action:t,name:Y(a,e.peerId),scopeLabel:D,changed:G,model:S,preview:oe,peerId:e.peerId,previewError:le})},onSuccess:d=>{for(const S of es)g.invalidateQueries({queryKey:[S]});d&&(d.tone==="success"?(f(d.text),r()):M(d))},onError:d=>{const S=e?Y(a,e.peerId):"this seller";if(q(d,"narrowed"))M({tone:"warning",canForce:!0,text:`Nothing changed yet. The levels above ${D} do not allow ${S}, so saving this would not let it serve. ${Xe(d.details).join(" ")}`.trim()});else if(q(d,"empty_allow_list")){const G=t==="block"?`Blocking ${S}`:`Allowing only ${S}`;M({tone:"warning",text:`Nothing changed. ${G} on ${D} would leave no seller that the levels above allow, so requests would fail. Change the policy on the Routing page if you really want that.`})}}}),K=e?Y(a,e.peerId):"";return s.jsx(X,{isOpen:e!==null,onClose:r,title:me[t].title,subtitle:K,children:s.jsxs("div",{className:"gc-stack",children:[s.jsx($,{label:"Apply to",value:y,onChange:d=>h(d),options:v}),y==="member"&&s.jsx($,{label:"Member",value:n,onChange:b,options:[{value:"",label:"Choose a member"},...(O.data??[]).filter(d=>d.status!=="disabled").map(d=>({value:d.id,label:d.label}))]}),y==="key"&&s.jsx($,{label:"Key",value:n,onChange:b,options:[{value:"",label:w.length?"Choose a key":"No keys you can edit"},...w.map(d=>({value:d.id,label:d.label}))]}),t==="prefer"&&e&&s.jsx($,{label:"For model",value:x,onChange:E,options:e.services.map(d=>({value:d.service,label:d.service})),hint:"The seller goes first in this model's fallback chain."}),s.jsx(Rs,{fetching:B.isFetching,error:B.error,ready:z,policy:I}),Ue&&s.jsxs(Q,{tone:"warning",children:["This scope has no allow list yet. Allowing ",K," creates one, so only allowed sellers can serve it."]}),Ve&&s.jsxs(Q,{tone:"warning",title:"This is the only allowed seller",children:["Blocking ",K," empties this scope's allow list, so the allow list is removed: any seller that is not blocked may serve it again."]}),t==="block"&&s.jsx("p",{className:"gc-muted",children:"Blocked sellers never serve this scope or anything under it."}),y==="key"&&!u&&s.jsx("p",{className:"gc-muted",children:"This changes your own restrictions on the key. Restrictions a workspace admin set still apply."}),P.error&&!q(P.error,"narrowed")&&!q(P.error,"empty_allow_list")?s.jsx(ee,{error:P.error,title:"Could not update the policy"}):null,C?s.jsxs(s.Fragment,{children:[s.jsx(Q,{tone:C.tone,title:Os(C),children:C.text}),s.jsxs("div",{className:"gc-actions",children:[C.canForce&&s.jsx(k,{variant:"ghost",disabled:P.isPending,onClick:()=>{M(null),P.mutate({acceptNarrowed:!0})},children:"Save it anyway"}),s.jsx(k,{onClick:r,children:C.canForce?"Cancel":"Done"})]})]}):s.jsxs("div",{className:"gc-actions",children:[s.jsx(k,{variant:"ghost",onClick:r,children:"Cancel"}),s.jsx(k,{variant:t==="block"?"danger":"primary",disabled:!z||P.isPending,onClick:()=>P.mutate({}),children:P.isPending?"Saving…":me[t].verb})]})]})})}function Bs({initial:e,peers:t,onDone:r}){const[a,o]=p.useState((e==null?void 0:e.name)??""),[i,m]=p.useState((e==null?void 0:e.description)??""),[c,g]=p.useState((e==null?void 0:e.peerIds)??[]),f=ke({mutationFn:()=>{const l={name:a.trim(),description:i.trim()||null,peerIds:c};return e?A.network.updatePeerList(e.id,l):A.network.createPeerList(l)},onSuccess:r,invalidate:[xe.peerLists]});return s.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),f.mutate()},children:[s.jsx(V,{label:"Name",required:!0,placeholder:"e.g. Our own sellers",value:a,onChange:l=>o(l.target.value)}),s.jsx(V,{label:"Description",value:i,onChange:l=>m(l.target.value)}),s.jsx(js,{label:"Sellers",value:c,onChange:g,peers:t}),s.jsx("p",{className:"gc-fineprint",children:"Policies refer to a list by name, so editing it changes every policy that uses it."}),f.error?s.jsx(ee,{error:f.error,title:"Could not save the list"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(k,{variant:"ghost",onClick:r,children:"Cancel"}),s.jsx(k,{type:"submit",disabled:f.isPending||!a.trim(),children:f.isPending?"Saving…":"Save list"})]})]})}function zs({peers:e}){const{viewer:t}=Z(),r=we(t),a=rs(),[o,i]=p.useState(null),[m,c]=p.useState(null),g=ke({mutationFn:f=>A.network.removePeerList(f.id),onSuccess:()=>c(null),invalidate:[xe.peerLists]});return s.jsxs(je,{flush:!0,title:"Peer lists",description:"Named groups of sellers to allow or block in one step.",actions:r&&s.jsx(k,{size:"sm",variant:"outline",leadingIcon:s.jsx(U.plus,{size:14}),onClick:()=>i("new"),children:"New list"}),children:[s.jsx(Pe,{query:a,children:f=>s.jsx(Le,{label:"Peer lists",rows:f,rowKey:l=>l.id,rowLabel:l=>l.name,actions:l=>r?[{label:"Edit",onSelect:()=>i(l)},{label:"Delete",tone:"danger",onSelect:()=>c(l)}]:[],empty:s.jsx(W,{icon:s.jsx(U.network,{size:18}),title:"No peer lists",body:"Group sellers you trust, or ones you run yourself."}),columns:[{key:"name",header:"Name",render:l=>s.jsx("span",{className:"gc-strong",children:l.name})},{key:"desc",header:"Description",secondary:!0,render:l=>s.jsx("span",{className:"gc-muted",children:l.description??"—"})},{key:"count",header:"Sellers",align:"right",render:l=>l.peerIds.length}]})}),s.jsx(X,{isOpen:o!==null,onClose:()=>i(null),title:o==="new"?"New peer list":"Edit peer list",size:"lg",children:o!==null&&s.jsx(Bs,{initial:o==="new"?null:o,peers:e,onDone:()=>i(null)})}),s.jsx(ns,{isOpen:m!==null,busy:g.isPending,error:g.error,onClose:()=>c(null),onConfirm:()=>m&&g.mutate(m),title:"Delete this list?",confirmLabel:"Delete",body:"Policies refer to lists by reference: once deleted, the list adds no sellers to them. An allow list made only of deleted lists lets no seller serve."})]})}function ze(e,t){return t?e.services.filter(r=>r.service===t):e.services}function _(e,t,r=""){const a=ze(e,r).map(o=>o[t]).filter(o=>o!==null);return a.length?{min:Math.min(...a),max:Math.max(...a)}:null}function qs(e,t=""){var r;return((r=_(e,"inputUsdPerMillion",t))==null?void 0:r.min)??null}function Us(e,t=""){var r;return((r=_(e,"outputUsdPerMillion",t))==null?void 0:r.min)??null}function se(e,t=""){return ze(e,t).some(r=>r.inputUsdPerMillion===0&&(r.outputUsdPerMillion??0)===0)}function Vs(e,t){const r=t.search.trim().toLowerCase();return e.filter(a=>{var o;return!(r&&!a.peerId.toLowerCase().includes(r)&&!(a.displayName??"").toLowerCase().includes(r)&&!a.services.some(i=>i.service.toLowerCase().includes(r))||t.model&&!a.services.some(i=>i.service===t.model)||t.tee&&!a.tee||t.linked&&!((o=a.verificationLinks)!=null&&o.length)||t.free&&!se(a,t.model))})}const qe={"openai-chat-completions":"Chat completions","openai-responses":"Responses","anthropic-messages":"Messages","openai-images":"Images"};function he(e){return e===null?"—":String(Math.round(e))}function J(e){return e.displayName??F(e.peerId,8,4)}function T(e){return`${e.provider}:${e.service}`}function _s({peer:e}){const t=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("span",{className:"gc-seller__meta",children:[s.jsxs("span",{className:"gc-peer-id",children:[s.jsx(Se,{title:e.peerId,children:F(e.peerId,6,4)}),s.jsx(Ce,{iconOnly:!0,value:e.peerId,label:"Copy peer id"})]}),s.jsx(Te,{links:e.verificationLinks}),s.jsx(Me,{tee:e.tee,scope:e.teeScope}),se(e,"")&&s.jsx(L,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(L,{tone:"danger",children:"Flagged"}),t&&s.jsx(L,{tone:"warning",children:"Cooling down"}),s.jsxs("span",{className:"gc-muted",children:["Last seen ",as(e.lastSeen)]})]})}function Ks({peer:e,showReputation:t}){const r=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-grid gc-grid--2 gc-figures gc-panel-figures",children:[s.jsx(N,{label:"Trust score",value:he(e.trustScore)}),t&&s.jsx(N,{label:"Reputation",value:he(e.reputationScore)}),s.jsx(N,{label:"Stake",value:e.stakeAnts?Is(e.stakeAnts):"—"}),s.jsx(N,{label:"Network usage share",value:e.usageShareBps===null?"—":`${(e.usageShareBps/100).toFixed(2)}%`}),s.jsx(N,{label:"First token p50 (this gateway)",value:Ie(e.firstTokenMsP50)}),s.jsx(N,{label:"Speed p50 (this gateway)",value:Ne(e.tokensPerSecondP50)}),s.jsx(N,{label:"Requests, 24h (this gateway)",value:$e(e.requests24h)}),s.jsx(N,{label:"Failure streak",value:r?`${e.health.failureStreak}, cooling down until ${os(e.health.coolingDownUntil)}`:String(e.health.failureStreak)})]})}function Gs({peer:e,selected:t,onSelect:r}){const[a,o]=p.useState(""),i=a.trim().toLowerCase(),m=e.services.filter(c=>!i||c.service.toLowerCase().includes(i));return s.jsx(De,{title:`Models (${e.services.length})`,actions:e.services.length>6&&s.jsx(V,{size:"sm",type:"search","aria-label":"Search this provider's models",placeholder:"Search models",value:a,onChange:c=>o(c.target.value)}),children:m.length===0?s.jsx("p",{className:"gc-fineprint",children:i?"No models match.":"This provider lists no models."}):s.jsx("ul",{className:"gc-panel-rows","aria-label":"Models and prices",children:m.map(c=>{const g=t!==null&&T(t)===T(c);return s.jsx(Ps,{selected:g,title:s.jsx("span",{className:"gc-strong",children:c.service}),meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Ss(c)}),s.jsx("span",{children:qe[Fe(c)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(Ce,{iconOnly:!0,value:Ae(e.peerId,c.service),label:`Copy ${c.service} pinned to this provider (peer@model)`}),s.jsx(k,{size:"sm",variant:g?"outline":"ghost","aria-pressed":g,title:"Show the API call for this model",onClick:()=>r(c),children:"API call"})]})},T(c))})})})}function Qs({peer:e,service:t,onSelect:r}){var R;const{workspace:a,viewer:o}=Z(),i=fe(),m=ls(),c=ve(i),g=is(a.id),[f,l]=p.useState("curl"),[u,v]=p.useState(!1),y=Fe(t),h=Ae(e.peerId,t.service),n=((R=g.data)==null?void 0:R.find(w=>w.model===h))??null,b=cs(m,e.peerId,t.service,y,n?`@preset/${n.slug}`:null),x=b.find(w=>w.id===f)??b[0],E=(c.data??[]).some(w=>w.status==="active"),O=ye(o);return s.jsxs(De,{title:"API call",actions:e.services.length>1&&s.jsx($,{size:"sm","aria-label":"Model",value:T(t),onChange:w=>{const j=e.services.find(C=>T(C)===w);j&&r(j)},options:e.services.map(w=>({value:T(w),label:w.service}))}),children:[s.jsxs("p",{className:"gc-fineprint",children:["Pinned to this provider with ",s.jsx("code",{children:F(h,10,12)}),"."]}),s.jsx($s,{id:"gc-connect",label:"Ways to connect",value:x.id,onChange:l,className:"gc-connect-tabs",tabs:b.map(w=>({id:w.id,label:w.label}))}),s.jsxs(As,{tabsId:"gc-connect",tab:x.id,className:"gc-stack",children:[x.id==="codex"&&s.jsxs("div",{className:"gc-summary-row",children:[s.jsx("p",{className:"gc-fineprint gc-summary-row__text",children:n?s.jsxs(s.Fragment,{children:["Uses the preset ",s.jsxs("code",{children:["@preset/",n.slug]})," for this model. Codex needs a preset: with a raw GPT model name it switches to a tool format some sellers drop."]}):s.jsx(s.Fragment,{children:"Codex needs a preset, not a raw model name: with a GPT model name it switches to a tool format some sellers drop. Create one for this model, then use its slug."})}),!n&&O&&s.jsx(k,{size:"sm",variant:"outline",onClick:()=>v(!0),children:"Create preset for this model"})]}),x.id==="claude-code"&&y!=="anthropic-messages"&&s.jsxs("p",{className:"gc-fineprint",children:["This model speaks ",qe[y],"; the gateway translates Claude Code's requests for it."]}),s.jsx(ds,{code:x.code,label:`${t.service} · ${x.label}`})]}),s.jsxs("p",{className:"gc-fineprint",children:["Set ",s.jsx("code",{children:us})," to one of your API keys first."," ",c.data&&!E&&s.jsx(ms,{to:"keys",children:"Create an API key"})]}),s.jsx(X,{isOpen:u,onClose:()=>v(!1),size:"lg",title:"New preset",children:u&&s.jsx(Ns,{initial:null,prefill:{name:t.service,model:h},onDone:w=>{v(!1),w&&l("codex")}})})]})}function Ys({peer:e,peers:t,showReputation:r}){const[a,o]=p.useState(null),[i,m]=p.useState(null),c=p.useRef(null),g=i??e.services[0]??null,f=l=>{var u;m(l),(u=c.current)==null||u.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"gc-stack",children:[s.jsx(_s,{peer:e}),s.jsxs("div",{className:"gc-panel-actions",children:[s.jsx(k,{size:"sm",variant:"outline",onClick:()=>o("allow"),children:"Allow"}),s.jsx(k,{size:"sm",variant:"outline",onClick:()=>o("prefer"),children:"Prefer"}),s.jsx(k,{size:"sm",variant:"danger",onClick:()=>o("block"),children:"Block"})]}),s.jsx(Ks,{peer:e,showReputation:r})]}),s.jsx(Gs,{peer:e,selected:g,onSelect:f}),g&&s.jsx("div",{ref:c,className:"gc-scroll-target",children:s.jsx(Qs,{peer:e,service:g,onSelect:m})}),a&&s.jsx(Be,{peer:e,action:a,peers:t,onClose:()=>o(null)})]})}function ge(e){return e===null?"—":String(Math.round(e))}function Hs({peer:e,model:t}){const r=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-badges",children:[s.jsx(Me,{tee:e.tee,scope:e.teeScope}),se(e,t)&&s.jsx(L,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(L,{tone:"danger",children:"Flagged"}),r&&s.jsx(L,{tone:"warning",children:"Cooling down"})]})}function mt(){const e=hs(),t=gs(e.rest),r=ps(),a=p.useMemo(()=>{var h;return t?((h=r.data)==null?void 0:h.find(n=>pe(n.peerId,t)))??null:null},[r.data,t]),[o,i]=p.useState({search:"",model:"",tee:!1,linked:!1,free:!1}),[m,c]=p.useState(null),g=p.useMemo(()=>fs(r.data),[r.data]),f=ws(r.data),l=ys(),u=(h,n)=>i(b=>({...b,[h]:n})),v=t===null?null:{eyebrow:"Provider",title:a?J(a):F(t,8,6),body:r.isLoading?s.jsx(be,{rows:6}):a?s.jsx(Ys,{peer:a,peers:r.data,showReputation:f},a.peerId):s.jsx(W,{icon:s.jsx(U.providers,{size:18}),title:"Provider not found",body:`This gateway does not see ${F(t,8,6)} right now.`})},y=s.jsxs("div",{className:"gc-page",children:[s.jsx(je,{flush:!0,children:s.jsx(Pe,{query:r,rows:8,children:h=>s.jsx(Le,{label:"Providers",rows:Vs(h,o),rowKey:n=>n.peerId,selectedKey:(a==null?void 0:a.peerId)??null,onRowClick:n=>de(ks("providers",n.peerId)),rowLabel:n=>J(n),actions:n=>[o.model!==""&&bs(l,n.peerId,o.model),{label:"Allow…",onSelect:()=>c({peer:n,kind:"allow"})},{label:"Prefer…",onSelect:()=>c({peer:n,kind:"prefer"})},{label:"Block…",tone:"danger",onSelect:()=>c({peer:n,kind:"block"})}],initialSort:{key:"trust",direction:"desc"},empty:s.jsx(W,{icon:s.jsx(U.providers,{size:18}),title:h.length?"No providers match these filters":"No providers found yet",body:h.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"name",header:"Provider",sortValue:n=>n.displayName??n.peerId,render:n=>s.jsxs("div",{className:"gc-cell-lines",children:[s.jsx("div",{className:"gc-strong gc-ellipsis",title:n.displayName??n.peerId,children:J(n)}),n.displayName&&s.jsx("div",{className:"gc-muted gc-ellipsis",children:s.jsx(Se,{title:n.peerId,children:F(n.peerId,6,4)})}),s.jsx(Hs,{peer:n,model:o.model})]}),after:n=>s.jsx(vs,{value:n.peerId,label:`Copy peer id ${n.peerId}`})},{key:"identity",header:"Domain / GitHub",secondary:!0,render:n=>{var b;return(b=n.verificationLinks)!=null&&b.length?s.jsx(Te,{links:n.verificationLinks}):s.jsx("span",{className:"gc-muted",children:"—"})}},{key:"models",header:"Models",secondary:!0,optional:!0,render:n=>s.jsx("span",{className:"gc-muted",children:n.services.length})},{key:"input",header:"Input $/M",align:"right",sortValue:n=>qs(n,o.model),render:n=>ce(_(n,"inputUsdPerMillion",o.model))},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:n=>Us(n,o.model),render:n=>ce(_(n,"outputUsdPerMillion",o.model))},{key:"trust",header:"Trust",align:"right",sortValue:n=>n.trustScore,render:n=>ge(n.trustScore)},...f?[{key:"reputation",header:"Reputation",align:"right",secondary:!0,optional:!0,sortValue:n=>n.reputationScore,render:n=>ge(n.reputationScore)}]:[],{key:"firstToken",header:"First token",align:"right",secondary:!0,optional:!0,sortValue:n=>n.firstTokenMsP50,render:n=>Ie(n.firstTokenMsP50)},{key:"speed",header:"Speed",align:"right",secondary:!0,optional:!0,sortValue:n=>n.tokensPerSecondP50,render:n=>Ne(n.tokensPerSecondP50)},{key:"usage",header:"Your 24h",align:"right",secondary:!0,sortValue:n=>n.requests24h,render:n=>$e(n.requests24h)}]})})}),s.jsx(zs,{peers:r.data})]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(xs,{title:"Providers",description:"Providers on the network this gateway can route to. Open one to copy its models and an API call, or allow, block or prefer it for any scope."}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(V,{size:"sm",type:"search","aria-label":"Search providers",placeholder:"Search name, peer id or model",value:o.search,onChange:h=>u("search",h.target.value)}),s.jsx($,{size:"sm","aria-label":"Filter by model",value:o.model,onChange:h=>u("model",h),options:[{value:"",label:"All models"},...g.map(h=>({value:h,label:h}))]}),s.jsx(H,{checked:o.linked,onChange:h=>u("linked",h),label:"Domain or GitHub"}),s.jsx(H,{checked:o.tee,onChange:h=>u("tee",h),label:"TEE"}),s.jsx(H,{checked:o.free,onChange:h=>u("free",h),label:"Free"})]}),s.jsx(Cs,{list:y,panel:v,onClose:()=>de("providers"),closeLabel:"Close provider"}),m&&s.jsx(Be,{peer:m.peer,action:m.kind,peers:r.data,onClose:()=>c(null)})]})}export{mt as default};
@@ -1 +0,0 @@
1
- import{bF as S,bG as L,al as _,w as fe,r as w,j as e,B as C,I as W,C as ae,T as xe,L as ie,E as le,bk as ye,v as z,u as B,a as ce,bz as de,bB as ue,b as X,bs as Z,c as he,d as we,bm as me,l as H,n as O,o as A,ah as V,e as je,P as ve,F as ke,a5 as be,bH as Pe,b7 as Me,a4 as Se,a6 as ee,O as D,f as E,q as U,bx as se,i as $e,G as Ne,bw as q,bI as Ce,af as _e,b9 as Ie}from"./index-cESr4Zze.js";import{a as Re,d as Le}from"./PolicyField-CHhm50jF.js";import{P as Fe}from"./PolicyEditor-ptFDJhFh.js";import{M as qe}from"./SidePanel-D0rNElh3.js";import{B as te}from"./BrandIcon-dTKznfCA.js";import{S as Oe,l as Ee,s as Ue}from"./stored-CETnaQtE.js";import{S as ne}from"./SelectField-Cl4acfcI.js";import"./PeerPicker-CfsXTUyK.js";import"./Segmented-D3e0aBDU.js";import"./roving-DkptacxO.js";import"./Switch-B2AEvyu7.js";import"./Disclosure-DMLE7rCw.js";import"./selection-HN8SZ52c.js";function G(s,n,a=3){const t=s.map(o=>{var i;return((i=n==null?void 0:n.find(d=>S(d.peerId)===S(o)))==null?void 0:i.displayName)??fe(o,8,4)});return t.length<=a?t.join(", "):`${t.slice(0,a).join(", ")} and ${t.length-a} more`}function re(s,n){return(s??[]).map(a=>{var t;return`the “${((t=n.find(o=>o.id===a))==null?void 0:t.name)??a}” list`}).join(", ")}function J(s,n,a=[]){var d,h,u,p;if(!s)return[];const t=s,o=[];if(t.allowedModels&&o.push(t.allowedModels.length===0?"No model is allowed.":`Only these models: ${t.allowedModels.join(", ")}.`),t.allowedPeerIds||t.allowedPeerLists){const l=[(d=t.allowedPeerIds)!=null&&d.length?G(t.allowedPeerIds,n):"",re(t.allowedPeerLists,a)].filter(Boolean);o.push(l.length?`Only these sellers: ${l.join(", ")}.`:"No seller is allowed.")}if((h=t.blockedPeerIds)!=null&&h.length||(u=t.blockedPeerLists)!=null&&u.length){const l=[(p=t.blockedPeerIds)!=null&&p.length?G(t.blockedPeerIds,n):"",re(t.blockedPeerLists,a)].filter(Boolean);o.push(`Never uses ${l.join(", ")}.`)}t.requireTee&&o.push("Only sellers running in a TEE."),t.requireVerified&&o.push("Only sellers with a verified domain or GitHub account."),t.minTrustScore!==void 0&&o.push(`Only sellers with trust ${t.minTrustScore} or more.`),t.minReputation!==void 0&&o.push(`Only sellers with reputation ${t.minReputation} or more.`);const i=[t.maxInputUsdPerMillion!==void 0?`${_(t.maxInputUsdPerMillion)}/M input`:null,t.maxOutputUsdPerMillion!==void 0?`${_(t.maxOutputUsdPerMillion)}/M output`:null,t.maxCachedInputUsdPerMillion!==void 0?`${_(t.maxCachedInputUsdPerMillion)}/M cached input`:null,t.maxImageUsdPerImage!==void 0?`$${t.maxImageUsdPerImage} per image`:null].filter(l=>l!==null);i.length&&o.push(`Pays at most ${i.join(", ")}.`);for(const[l,x]of Object.entries(t.modelRoutes??{}))o.push(`For ${l}: tries ${G(x.peerIds,n,4).replace(/, ([^,]*)$/,", then $1")} first${x.strict?", and no other seller":""}.`);return t.sort==="price"?o.push("Ranks the cheapest seller first."):t.sort==="latency"?o.push("Ranks the fastest seller first."):t.sort==="trust"&&o.push("Ranks the most trusted seller first."),t.preferFreePeers&&o.push("Free sellers first."),o}function Te(s,n,a,t){var d,h;const o=S(n.peerId);if((d=s.blockedPeerIds)!=null&&d.some(u=>S(u)===o))return"blocks it";if(s.allowedPeerIds&&!s.allowedPeerIds.some(u=>S(u)===o))return"does not allow it";if(s.requireTee&&a&&!a.tee)return"requires a TEE";if(s.requireVerified&&a&&!a.verified)return"requires a verified seller";if(s.minTrustScore!==void 0&&(n.trustScore??0)<s.minTrustScore)return`requires trust ${s.minTrustScore}+ (it has ${Math.round(n.trustScore??0)})`;if(s.minReputation!==void 0&&a&&(a.reputationScore??0)<s.minReputation)return`requires reputation ${s.minReputation}+`;if(s.maxInputUsdPerMillion!==void 0&&n.inputUsdPerMillion!==null&&n.inputUsdPerMillion>s.maxInputUsdPerMillion)return`caps input at ${_(s.maxInputUsdPerMillion)}/M (it asks ${_(n.inputUsdPerMillion)})`;if(s.maxOutputUsdPerMillion!==void 0&&n.outputUsdPerMillion!==null&&n.outputUsdPerMillion>s.maxOutputUsdPerMillion)return`caps output at ${_(s.maxOutputUsdPerMillion)}/M (it asks ${_(n.outputUsdPerMillion)})`;const i=(h=s.modelRoutes)==null?void 0:h[t];return i!=null&&i.strict&&!i.peerIds.some(u=>S(u)===o)?"only allows its route for this model":null}function pe(s,n,a,t=[]){if(n.eligible)return[];const o=a==null?void 0:a.find(i=>S(i.peerId)===S(n.peerId));return s.sources.flatMap(i=>{if(!i.policy)return[];const d=Te(L(i.policy,t),n,o,s.model);return d?[{level:i.level,levelId:i.id,rule:d}]:[]})}function ze(s,n,a=[]){const t=new Map;for(const o of(s==null?void 0:s.candidates)??[])for(const i of new Set(pe(s,o,n,a).map(d=>d.level)))t.set(i,(t.get(i)??0)+1);return t}function Ae(s,n){if(!n)return!0;const a=n.toLowerCase();return[s.id,s.name,...s.aliases,...s.tags].some(t=>t.toLowerCase().includes(a))}function Be({models:s,loading:n,value:a,onChange:t,favorites:o=[],label:i="Model"}){const[d,h]=w.useState(!1),[u,p]=w.useState(""),l=(s==null?void 0:s.find(r=>r.id===a))??null,x=w.useMemo(()=>new Set(o.map(r=>r.toLowerCase())),[o]),c=w.useMemo(()=>[...s??[]].filter(r=>Ae(r,u.trim())).sort((r,y)=>Number(x.has(y.id.toLowerCase()))-Number(x.has(r.id.toLowerCase()))||y.offers.length-r.offers.length||r.name.localeCompare(y.name)),[s,u,x]),f=r=>{t(r),h(!1),p("")};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"outline",size:"sm",className:"gc-model-chooser","aria-label":`${i}: ${(l==null?void 0:l.name)??a??"none"}`,onClick:()=>h(!0),children:[e.jsx("span",{className:"gc-model-chooser__mark","aria-hidden":"true",children:l?e.jsx(te,{name:l.id,hints:[l.name],size:16}):e.jsx(W.models,{size:15})}),e.jsx("span",{className:"gc-ellipsis",children:(l==null?void 0:l.name)??a??"Choose a model"}),e.jsx("span",{className:"gc-model-chooser__caret","aria-hidden":"true",children:e.jsx(W.down,{size:14})})]}),e.jsx(ae,{isOpen:d,onClose:()=>h(!1),title:"Choose a model",size:"md",children:e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx(xe,{size:"sm",type:"search",autoFocus:!0,"aria-label":"Search models",placeholder:"Search by name, id or tag",value:u,onChange:r=>p(r.target.value),onKeyDown:r=>{r.key==="Enter"&&c[0]&&f(c[0].id)}}),n?e.jsx(ie,{rows:5}):c.length===0?e.jsx(le,{title:"No model matches"}):e.jsx("ul",{className:"gc-choice-list","aria-label":"Models",children:c.map(r=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:r.id===a?"gc-choice gc-choice--on":"gc-choice",onClick:()=>f(r.id),children:[e.jsx(te,{name:r.id,hints:[r.name],size:18}),e.jsxs("span",{className:"gc-choice__main",children:[e.jsxs("span",{className:"gc-choice__title",children:[r.name,x.has(r.id.toLowerCase())&&e.jsx(W.starFilled,{size:12})]}),e.jsxs("span",{className:"gc-choice__meta",children:[r.name!==r.id&&e.jsx("code",{children:r.id}),e.jsx("span",{children:qe[r.type]}),e.jsxs("span",{children:[r.offers.length," provider",r.offers.length===1?"":"s"]}),r.inputUsdPerMillion&&e.jsxs("span",{children:[ye(r.inputUsdPerMillion),"/M in"]})]})]}),r.free&&e.jsx(z,{tone:"success",children:"Free"})]})},r.id))})]})})]})}const ge={buyer:"Buyer config",gateway:"Gateway default","workspace-org":"Organization policy",workspace:"Workspace policy",member:"Member policy",key:"Key policy (admin)","key-owner":"Key policy (owner)",preset:"Preset"};function Ke(s,n,a,t){return s==="key"?(n??[]).filter(o=>o.status==="active").map(o=>({value:o.id,label:o.label})):s==="member"?(a??[]).map(({member:o})=>({value:o.id,label:o.label})):s==="preset"?(t??[]).map(o=>({value:o.slug,label:o.name})):[]}function We(s,n){return!s.model||s.target!=="workspace"&&!s.targetId?null:{model:s.model,workspace:n,...s.target!=="workspace"?{[s.target]:s.targetId}:{}}}function De({exclusions:s}){return s.length===0?null:e.jsx("span",{className:"gc-fineprint",children:s.map((n,a)=>e.jsxs("span",{children:[a>0?"; ":"",e.jsx("strong",{children:ge[n.level]})," ",n.rule]},`${n.level}-${a}`))})}function Ge({state:s,onChange:n,preview:a}){const{workspace:t,viewer:o}=B(),i=ce(),d=de(),h=ue(),u=X(),p=Z(),l=he(i,s.target==="key"),x=we(t.id,s.target==="member"),c=me(t.id,s.target==="preset"),f=Ke(s.target,l.data,x.data,c.data),r=a.data,y=(r==null?void 0:r.candidates.filter(m=>m.eligible).length)??0,j=r&&!r.modelAllowed?r.sources.filter(m=>{var $;return(($=m.policy)==null?void 0:$.allowedModels)&&!m.policy.allowedModels.some(v=>v.toLowerCase()===r.model.toLowerCase())}):[];return e.jsxs(H,{title:"Try a request",description:"Pick a model to see which sellers a request goes to, in what order, and what keeps the others out.",children:[e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(Be,{models:d.data,loading:d.isLoading,value:s.model,favorites:h.data,onChange:m=>n({...s,model:m})}),e.jsx(ne,{size:"sm","aria-label":"Request from",value:s.target,onChange:m=>n({...s,target:m,targetId:""}),options:[{value:"workspace",label:`From workspace ${t.name}`},{value:"key",label:"From a key"},...O(o)?[{value:"member",label:"From a member"}]:[],{value:"preset",label:"With a preset"}]}),s.target!=="workspace"&&e.jsx(ne,{size:"sm","aria-label":`Choose a ${s.target}`,value:s.targetId,onChange:m=>n({...s,targetId:m}),options:[{value:"",label:`Choose a ${s.target}`},...f]})]}),a.error?e.jsx(A,{error:a.error}):null,!s.model&&e.jsx(le,{title:"Pick a model",body:"The preview shows the sellers a request for it would use."}),r&&!r.modelAllowed&&e.jsx(V,{tone:"danger",title:`${r.model} is not allowed`,children:j.length?e.jsxs(e.Fragment,{children:[j.map(m=>ge[m.level]).join(" and ")," only allow",j.length===1?"s":""," ",j[0].policy.allowedModels.join(", ")||"no model",". Requests for ",r.model," get a 403."]}):e.jsxs(e.Fragment,{children:["Requests for ",r.model," get a 403."]})}),r&&r.modelAllowed&&e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsxs("p",{className:"gc-try__summary",children:[e.jsxs(z,{tone:y>0?"success":"warning",children:[y," of ",r.candidates.length]})," ",y>0?`sellers can serve ${r.model}.`:`No seller can serve ${r.model} with these rules.`]}),e.jsx(Oe,{title:"Sellers, in the order they are tried",preview:r,loading:a.isFetching&&!r,skippedOpen:!0,explainSkipped:m=>e.jsx(De,{exclusions:pe(r,m,u.data,p.data??[])})})]})]})}const R={gateway:{title:"Gateway default",description:()=>"Set by organization admins. Applies to every request through this gateway."},org:{title:"Organization policy",description:s=>`Set by organization admins for the ${s} workspace. Workspace admins cannot loosen it.`},workspace:{title:"Workspace policy",description:s=>`Set by ${s}'s admins for their own keys.`}},Q=(s,n)=>JSON.stringify(s)===JSON.stringify(n);function T({index:s,title:n,who:a,sentences:t,empty:o="No rules of its own.",impact:i,badge:d,action:h,result:u}){return e.jsxs("li",{className:u?"gc-funnel__step gc-funnel__step--result":"gc-funnel__step",children:[e.jsx("span",{className:"gc-funnel__index","aria-hidden":"true",children:s}),e.jsxs("div",{className:"gc-funnel__body",children:[e.jsxs("div",{className:"gc-funnel__head",children:[e.jsx("span",{className:"gc-funnel__title",children:n}),d,h&&e.jsx("span",{className:"gc-funnel__action",children:h})]}),e.jsx("div",{className:"gc-fineprint",children:a}),t.length>0?e.jsx("ul",{className:"gc-funnel__rules",children:t.map(p=>e.jsx("li",{children:p},p))}):e.jsx("p",{className:"gc-funnel__none",children:o}),i&&e.jsx("p",{className:i.excluded>0?"gc-funnel__impact gc-funnel__impact--on":"gc-funnel__impact",children:i.excluded>0?`Keeps ${i.excluded} of ${i.total} seller${i.total===1?"":"s"} of ${i.model} out.`:`Keeps no seller of ${i.model} out.`})]})]})}function Y({index:s,layer:n,source:a,parent:t,canEdit:o,impact:i,onSave:d}){const{workspace:h}=B(),u=Ne(),p=X(),l=Z(),x=Re(),[c,f]=w.useState(()=>q(a)),[r,y]=w.useState(()=>q(a)),[j,m]=w.useState(null),[$,v]=w.useState(!1),P=w.useMemo(()=>q(a),[a]),k=!Q(c,r);w.useEffect(()=>{Q(P,r)||(!k||Q(P,c)?(f(P),y(P),m(null)):m(P))},[P]);const M=Ce({mutationFn:async()=>{const g=_e(c,l.data??null);return await x.save([g],K=>d(g,K))===Ie?null:g},onSuccess:g=>{if(!g)return;const b=q(g);f(b),y(b),m(null),v(!1),u(`${R[n].title} saved`)}}),N=Le(c,l.data??null),F=k?N.policy:a,I=!a||Object.keys(a).length===0;return e.jsxs(e.Fragment,{children:[e.jsx(T,{index:s,title:R[n].title,who:R[n].description(h.name),sentences:k&&N.error?[]:J(F,p.data,l.data??[]),empty:k&&N.error?"Has an invalid setting; open it to fix.":"No rules of its own: passes on everything above.",impact:i,badge:k?e.jsx(z,{tone:"warning",children:"Unsaved changes"}):o?void 0:e.jsx(z,{children:"Read only"}),action:e.jsx(C,{size:"sm",variant:o&&I?"outline":"ghost",onClick:()=>v(!0),children:o?I?"Add rules":"Edit":"View"})}),j&&o&&!$&&e.jsx("li",{className:"gc-funnel__note",children:e.jsx(V,{tone:"warning",title:"Changed elsewhere",children:"Someone saved this policy while you were editing it. Open it to reload theirs or keep yours."})}),e.jsx(ae,{isOpen:$,onClose:()=>v(!1),size:"xl",title:R[n].title,subtitle:R[n].description(h.name),footer:o?e.jsxs(e.Fragment,{children:[N.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:N.error}),e.jsx(C,{variant:"ghost",disabled:!k,onClick:()=>{f(r),m(null)},children:"Discard changes"}),e.jsx(C,{disabled:M.isPending||!k,onClick:()=>M.mutate(),children:M.isPending?"Saving…":"Save policy"})]}):e.jsx(C,{variant:"outline",onClick:()=>v(!1),children:"Close"}),children:e.jsxs("div",{className:"gc-stack",children:[j&&o&&e.jsx(V,{tone:"warning",title:"Changed elsewhere",action:e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(C,{size:"sm",variant:"outline",onClick:()=>{f(j),y(j),m(null)},children:"Reload"}),e.jsx(C,{size:"sm",variant:"ghost",onClick:()=>{y(j),m(null)},children:"Keep editing"})]}),children:"Someone saved this policy while you were editing it. Reload to see their version (your edits are dropped), or keep editing and save to replace it."}),M.error?e.jsx(A,{error:M.error,title:"Could not save"}):null,e.jsx(Fe,{value:c,onChange:f,peers:p.data,lists:l.data??[],parent:t,disabled:!o})]})}),x.dialog]})}function Qe({preview:s}){var F,I;const{workspace:n,viewer:a}=B(),t=ke(),o=ce(),i=X(),d=Z(),h=be(),u=Pe(),p=Me(n.id),l=he(o),x=me(n.id),c=d.data??[],f=u.data?L(u.data,c):null,r=((F=p.data)==null?void 0:F.orgRoutingPolicy)??null,y=((I=p.data)==null?void 0:I.routingPolicy)??null,j=w.useMemo(()=>Se(h.data),[h.data]),m=w.useMemo(()=>ee(j,f,r&&L(r,c),y&&L(y,c)),[j,f,r,y,c]),$=w.useMemo(()=>ze(s,i.data,c),[s,i.data,c]),v=(...g)=>s&&s.modelAllowed?{model:s.model,total:s.candidates.length,excluded:g.reduce((b,K)=>b+($.get(K)??0),0)}:null;if(u.isLoading||p.isLoading)return e.jsx(H,{title:"Rules that apply",children:e.jsx(ie,{rows:6})});if(u.error)return e.jsx(A,{error:u.error,onRetry:()=>void u.refetch()});if(p.error)return e.jsx(A,{error:p.error,onRetry:()=>void p.refetch()});const P=async()=>{await t.invalidateQueries({queryKey:U.group("workspaces")}),await t.invalidateQueries({queryKey:U.group("routing")})},k=(l.data??[]).filter(g=>g.status==="active"&&g.routingPolicy).length,M=(x.data??[]).filter(g=>g.routingPolicy).length,N=[k?`${k} key${k===1?" has its":"s have their"} own rules.`:null,M?`${M} preset${M===1?" has":"s have"} rules.`:null].filter(g=>g!==null);return e.jsx(H,{title:"Rules that apply",description:"A request passes every level, top to bottom. Each level can only narrow the ones above it, never loosen them.",children:e.jsxs("ol",{className:"gc-funnel",children:[e.jsx(T,{index:1,title:"Buyer config",who:e.jsxs(e.Fragment,{children:["The buyer's own limits",O(a)?e.jsxs(e.Fragment,{children:[", set under ",e.jsx(D,{to:"settings",children:"Settings"})]}):"",". Everything below can only narrow them."]}),sentences:J(j,i.data,c),empty:"No limits.",impact:v("buyer")}),e.jsx(Y,{index:2,layer:"gateway",source:u.data??null,parent:j,canEdit:O(a),impact:v("gateway"),onSave:async(g,b)=>{await E.network.setGatewayPolicy(g,b),await t.invalidateQueries({queryKey:U.group("routing")})}}),e.jsx(Y,{index:3,layer:"org",source:r,parent:f,canEdit:O(a),impact:v("workspace-org"),onSave:async(g,b)=>{await E.workspaces.update(n.id,{orgRoutingPolicy:se(g)},b),await P()}}),e.jsx(Y,{index:4,layer:"workspace",source:y,parent:ee(f,r&&L(r,c)),canEdit:$e(a),impact:v("workspace"),onSave:async(g,b)=>{await E.workspaces.update(n.id,{routingPolicy:se(g)},b),await P()}}),e.jsx(T,{index:5,title:"Members, keys and presets",who:e.jsxs(e.Fragment,{children:["Can narrow the rules further for one member, one key or one preset: see ",e.jsx(D,{to:"keys",children:"Keys"})," and ",e.jsx(D,{to:"presets",children:"Presets"}),"."]}),sentences:N,empty:"None in this workspace narrows it.",impact:v("member","key","key-owner","preset")}),e.jsx(T,{index:"=",result:!0,title:`Effective for ${n.name}`,who:"What every key in this workspace gets before its own rules.",sentences:J(m,i.data,c),empty:"No rules: every seller the network offers."})]})})}const oe="antseed-console-routing:try";function is(){var h;const{workspace:s}=B(),n=de(),a=ue(),[t,o]=w.useState(()=>({target:"workspace",targetId:"",model:Ee(oe,null)}));w.useEffect(()=>{Ue(oe,t.model)},[t.model]),w.useEffect(()=>{var l,x;if(t.model||!((l=n.data)!=null&&l.length))return;const u=(x=a.data)==null?void 0:x.find(c=>n.data.some(f=>f.id===c)),p=[...n.data].filter(c=>c.type==="text").sort((c,f)=>f.offers.length-c.offers.length)[0]??n.data[0];o(c=>({...c,model:u??p.id}))},[n.data,a.data,t.model]);const i=We(t,s.id),d=je({queryKey:U.routePreview(i??{}),queryFn:()=>E.network.routePreview(i),enabled:i!==null,staleTime:15e3});return e.jsxs("div",{className:"gc-page",children:[e.jsx(ve,{title:"Routing",description:"Which sellers serve your requests, and why. Try a model to see its route, then change the rules that shape it."}),e.jsx(Ge,{state:t,onChange:o,preview:{data:i?d.data:void 0,isFetching:d.isFetching,error:d.error}}),e.jsx(Qe,{preview:i&&((h=d.data)==null?void 0:h.model)===t.model?d.data:void 0})]})}export{is as default};
@@ -1,7 +0,0 @@
1
- import{F as re,G as ne,b as ge,bs as xe,r as d,bI as ae,q as U,f as E,ag as ve,a6 as be,al as K,g as fe,j as t,ah as D,aa as ye,T as O,B as y,o as $,D as ie,e as Se,P as je,bJ as we,Q as z,aC as ke,l as A,X as le,M as Pe,v as M,u as Re,V as Ce,t as Q,b3 as Ne,au as W,bc as Me,at as Ie,E as Ue,I as G,C as J,b2 as qe,$ as Te}from"./index-cESr4Zze.js";import{P as Y}from"./PeerPicker-CfsXTUyK.js";import{S as X}from"./PolicyEditor-ptFDJhFh.js";import{S as Oe}from"./Segmented-D3e0aBDU.js";import{S as I}from"./Switch-B2AEvyu7.js";import{D as F}from"./Disclosure-DMLE7rCw.js";import{T as oe}from"./TextAreaField-Dbr655cs.js";import{T as Ee,a as Ae}from"./Tabs-Cv10NtDy.js";import{D as Fe}from"./DataTable-BkJdorEh.js";import{S as B}from"./SelectField-Cl4acfcI.js";import"./roving-DkptacxO.js";function De(e){return Object.entries(e).map(([s,r])=>`${s}: ${r}`).join(`
2
- `)}function $e(e){const s={};for(const[r,n]of e.split(`
3
- `).entries()){if(!n.trim())continue;const c=n.indexOf(":");if(c<=0)throw new Error(`Line ${r+1}: use "Name: value".`);const u=n.slice(0,c).trim();if(!/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(u))throw new Error(`Line ${r+1}: "${u}" is not a valid header name.`);s[u]=n.slice(c+1).trim()}return s}const ce="••••";function _e(e){return e.split(`
4
- `).map(s=>{const r=s.indexOf(":");return r>0&&s.slice(r+1).trim()===ce?s.slice(0,r).trim():null}).filter(s=>!!s)}function Z(e){return e.split(`
5
- `).map(s=>{const r=s.indexOf(":");return r>0&&s.slice(r+1).trim()===ce?`${s.slice(0,r)}: `:s}).join(`
6
- `)}function Le(e,s){if(!e||!s)return!1;try{return new URL(e).origin!==new URL(s).origin}catch{return e!==s}}function Be(e){const s={},r=(n,c,u)=>{const a=e[n].trim();if(a===""){c&&(s[n]="Required.");return}const h=Number(a);!Number.isFinite(h)||h<0?s[n]="Use a number of 0 or more.":u!==void 0&&h>u&&(s[n]=`At most ${u}.`)};return r("input",!0),r("output",!0),r("cached",!1),r("reputation",!0,100),s}function w(e,s={}){const r=e.trim();if(r==="")return s.required?"Required.":void 0;const n=Number(r),c=s.min??0;if(!Number.isFinite(n))return"Use a number.";if(s.integer&&!Number.isInteger(n))return"Use a whole number.";if(n<c)return`Use ${c} or more.`;if(s.max!==void 0&&n>s.max)return`At most ${s.max}.`}function V(e){return e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)}function ee(e){const s=e.find(r=>!/^(?:0x)?[0-9a-f]{40}$/i.test(r));return s?`"${s}" is not a 40-character hex seller id.`:void 0}function te(e){const s=e.find(r=>!/^https?:\/\/\S+$/.test(r));return s?`"${s}" is not an http(s) URL.`:void 0}function ue(e,s){return e.some(r=>r===s||s.startsWith(`${r}.`)||r.startsWith(`${s}.`))}function Ve(){return t.jsxs("span",{className:"gc-override",children:[t.jsx("span",{className:"gc-attention","aria-hidden":"true"}),"Overridden by the buyer's environment or start flags"]})}function se(e){const s=e.routingPreferences,r=n=>n===null?"":String(n);return{allowMode:s.allowedPeerIds.length>0?"only":"any",allowedPeerIds:[...s.allowedPeerIds],blockedPeerIds:[...s.blockedPeerIds],minTrustScore:String(s.minTrustScore),minReputation:String(e.minPeerReputation),preferFree:s.preferFreePeers,softInputCap:String(s.maxInputUsdPerMillion),maxInput:String(e.maxPricing.inputUsdPerMillion),maxOutput:String(e.maxPricing.outputUsdPerMillion),maxCached:r(e.maxPricing.cachedInputUsdPerMillion),verify:e.verifier.enabled,requireVerified:e.verifier.require,verifiers:e.verifier.prefer.join(", "),sampleRate:r(e.evidence.sampleRate),maxSampleBytes:r(e.evidence.maxSampleBytes),autoSweep:e.payments.autoSweep,maxPerRequest:String(e.payments.maxPerRequestUsdc),maxReserve:String(e.payments.maxReserveUsdc),rpcUrl:e.payments.rpcUrl??"",fallbackRpcUrls:e.payments.fallbackRpcUrls.join(`
7
- `),peerRefreshMs:String(e.network.peerRefreshIntervalMs),metadataTimeoutMs:String(e.network.metadataFetchTimeoutMs),requestTimeoutMs:String(e.network.requestTimeoutMs),maxStreamMs:String(e.network.maxStreamDurationMs),perServiceMetadata:!e.network.disableMetadataV2Services}}function ze(e){const s=Be({input:e.maxInput,output:e.maxOutput,cached:e.maxCached,reputation:e.minReputation}),r={maxInput:s.input,maxOutput:s.output,maxCached:s.cached,softInputCap:w(e.softInputCap,{required:!0}),allowedPeerIds:e.allowMode==="only"?ee(e.allowedPeerIds):void 0,blockedPeerIds:ee(e.blockedPeerIds),sampleRate:w(e.sampleRate,{max:1}),maxSampleBytes:w(e.maxSampleBytes,{min:1,integer:!0}),maxPerRequest:w(e.maxPerRequest,{required:!0,min:1e-6}),maxReserve:w(e.maxReserve,{required:!0,min:1e-6}),rpcUrl:e.rpcUrl.trim()?te([e.rpcUrl.trim()]):void 0,fallbackRpcUrls:te(V(e.fallbackRpcUrls)),peerRefreshMs:w(e.peerRefreshMs,{required:!0,min:1e3,integer:!0}),metadataTimeoutMs:w(e.metadataTimeoutMs,{required:!0,min:100,integer:!0}),requestTimeoutMs:w(e.requestTimeoutMs,{required:!0,min:1,integer:!0}),maxStreamMs:w(e.maxStreamMs,{required:!0,min:1,integer:!0})};return Object.fromEntries(Object.entries(r).filter(([,n])=>n))}function He(e){const s=r=>r.trim()?Number(r):null;return{routingPreferences:{minTrustScore:Number(e.minTrustScore),maxInputUsdPerMillion:Number(e.softInputCap),preferFreePeers:e.preferFree,allowedPeerIds:e.allowMode==="only"?e.allowedPeerIds:[],blockedPeerIds:e.blockedPeerIds},maxPricing:{inputUsdPerMillion:Number(e.maxInput),outputUsdPerMillion:Number(e.maxOutput),cachedInputUsdPerMillion:s(e.maxCached)},minPeerReputation:Number(e.minReputation),verifier:{enabled:e.verify,require:e.verify&&e.requireVerified,prefer:e.verify?V(e.verifiers):[]},evidence:{sampleRate:s(e.sampleRate),maxSampleBytes:s(e.maxSampleBytes)},payments:{autoSweep:e.autoSweep,maxPerRequestUsdc:Number(e.maxPerRequest),maxReserveUsdc:Number(e.maxReserve),rpcUrl:e.rpcUrl.trim()||null,fallbackRpcUrls:V(e.fallbackRpcUrls)},network:{peerRefreshIntervalMs:Number(e.peerRefreshMs),metadataFetchTimeoutMs:Number(e.metadataTimeoutMs),requestTimeoutMs:Number(e.requestTimeoutMs),maxStreamDurationMs:Number(e.maxStreamMs),disableMetadataV2Services:!e.perServiceMetadata}}}const Ke=["allowMode","allowedPeerIds","blockedPeerIds","minTrustScore","preferFree","softInputCap"];function L(e,s){return Object.keys(s).filter(r=>JSON.stringify(e[r])!==JSON.stringify(s[r]))}function Qe(e){const s=r=>r.trim()&&Number.isFinite(Number(r))?Number(r):void 0;return{...e.allowMode==="only"&&e.allowedPeerIds.length>0?{allowedPeerIds:e.allowedPeerIds}:{},...e.blockedPeerIds.length>0?{blockedPeerIds:e.blockedPeerIds}:{},...s(e.minTrustScore)?{minTrustScore:s(e.minTrustScore)}:{},...s(e.minReputation)?{minReputation:s(e.minReputation)}:{},...s(e.maxInput)!==void 0?{maxInputUsdPerMillion:s(e.maxInput)}:{},...s(e.maxOutput)!==void 0?{maxOutputUsdPerMillion:s(e.maxOutput)}:{},...s(e.maxCached)!==void 0?{maxCachedInputUsdPerMillion:s(e.maxCached)}:{}}}function We({buyer:e}){const s=re(),r=ne(),n=ge(),c=xe(),u=d.useMemo(()=>se(e),[e]),[a,h]=d.useState(u),[k,P]=d.useState(u),[v,S]=d.useState(null),[b,p]=d.useState(!1),[j,g]=d.useState(!1),l=(i,R)=>h(C=>({...C,[i]:R})),m=i=>{h(i),P(i),S(null)},o=ze(a),q=L(k,a);d.useEffect(()=>{L(k,u).length!==0&&(q.length===0||L(u,a).length===0?m(u):S(u))},[u]);const _=q.some(i=>!Ke.includes(i)),N=i=>ue(e.overrides,i)?t.jsx(Ve,{}):void 0,H=(i,R)=>N(i)??R,f=ae({mutationFn:()=>E.settings.updateBuyer(He(a)),onSuccess:i=>{const{restartRequired:R,...C}=i;s.setQueryData(U.settings,C),m(se(C.buyer)),s.invalidateQueries({queryKey:U.buyerLimits}),p(!1),g(R===!0),r(_?R?"Saved. Restart the buyer to apply them.":"Saved. The buyer is restarting.":"Saved. The buyer applies these at once.")}}),T=d.useMemo(()=>!n.data||n.data.length===0?null:{matched:ve(be(Qe(a)),n.data,c.data??[]).length,total:n.data.length},[a,n.data,c.data]),de=`${K(Number(a.maxInput))} in · ${K(Number(a.maxOutput))} out`,me=a.verify?a.requireVerified?"Required":"On":"Off",pe=`${a.autoSweep?"Auto-sweep on":"Auto-sweep off"} · ${fe(Number(a.maxPerRequest))} per request`,x=(i,R,C={})=>t.jsx(O,{size:"sm",className:C.className??"gc-num",label:R,inputMode:"decimal",placeholder:C.placeholder,value:a[i],error:o[i],hint:C.hint,onChange:he=>l(i,he.target.value)});return t.jsxs("div",{className:"gc-stack",children:[t.jsxs("div",{className:"gc-policy",children:[T&&(T.matched===0?t.jsxs(D,{tone:"warning",title:"No seller matches these settings",children:["None of the ",T.total," sellers this gateway sees passes them, so every request will fail."]}):t.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",T.matched," of ",T.total," sellers. Every key can only narrow this."]})),t.jsxs("div",{className:"gc-policy__cols",children:[t.jsxs("section",{className:"gc-policy__section",children:[t.jsx("h3",{children:"Sellers"}),t.jsx(Oe,{label:"Which sellers may serve",value:a.allowMode,onChange:i=>l("allowMode",i),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),a.allowMode==="only"&&t.jsxs(t.Fragment,{children:[t.jsx(Y,{label:"Allowed sellers",value:a.allowedPeerIds,onChange:i=>l("allowedPeerIds",i),peers:n.data}),o.allowedPeerIds&&t.jsx("p",{className:"gc-warn",children:o.allowedPeerIds}),a.allowedPeerIds.length===0&&t.jsx("p",{className:"gc-fineprint",children:"With no sellers listed, any seller may serve."})]}),t.jsx(Y,{label:"Blocked sellers",value:a.blockedPeerIds,onChange:i=>l("blockedPeerIds",i),peers:n.data}),o.blockedPeerIds&&t.jsx("p",{className:"gc-warn",children:o.blockedPeerIds}),t.jsx("p",{className:"gc-fineprint",children:"Blocked here means blocked for every key."})]}),t.jsxs("section",{className:"gc-policy__section",children:[t.jsx("h3",{children:"Quality and ranking"}),t.jsx(X,{label:"Minimum trust score",clearable:!1,value:a.minTrustScore,onChange:i=>l("minTrustScore",i),hint:"Keys can raise it, not lower it."}),(ye(n.data)||a.minReputation!=="0")&&t.jsx(X,{label:"Minimum reputation",clearable:!1,value:a.minReputation,onChange:i=>l("minReputation",i),hint:H("minPeerReputation","Applies to pinned sellers too.")}),t.jsx("div",{className:"gc-policy__switches",children:t.jsx(I,{checked:a.preferFree,onChange:i=>l("preferFree",i),label:"Free sellers first"})}),x("softInputCap","Soft input price limit $/M",{hint:"Pricier sellers rank lower; none is excluded.",className:"gc-num gc-num--wide"})]})]}),t.jsxs("div",{className:"gc-policy__advanced",children:[t.jsxs(F,{title:"Price caps",summary:de,children:[t.jsx("p",{className:"gc-fineprint",children:"Hard limits for every request, pinned sellers included."}),t.jsxs("div",{className:"gc-policy__caps",children:[x("maxInput","Input $/M",{hint:N("maxPricing.inputUsdPerMillion")}),x("maxOutput","Output $/M",{hint:N("maxPricing.outputUsdPerMillion")}),x("maxCached","Cached input $/M",{placeholder:"Same as input"})]})]}),t.jsxs(F,{title:"Verification",summary:me,children:[N("verifier"),t.jsxs("div",{className:"gc-policy__switches",children:[t.jsx(I,{checked:a.verify,onChange:i=>l("verify",i),label:"Verify sellers"}),t.jsx(I,{checked:a.verify&&a.requireVerified,disabled:!a.verify,onChange:i=>l("requireVerified",i),label:"Require verification"})]}),t.jsx(O,{size:"sm",label:"Verifiers",value:a.verifiers,disabled:!a.verify,placeholder:"Seller's trusted default",hint:"Ordered, comma-separated verifier ids, e.g. TEE attestation.",onChange:i=>l("verifiers",i.target.value)}),t.jsxs("div",{className:"gc-policy__caps",children:[x("sampleRate","Evidence sample rate",{placeholder:"Default",hint:"Share of responses kept, 0 to 1."}),x("maxSampleBytes","Largest sample (bytes)",{placeholder:"Default",className:"gc-num gc-num--wide"})]})]}),t.jsxs(F,{title:"Payments",summary:pe,children:[t.jsx(I,{checked:a.autoSweep,onChange:i=>l("autoSweep",i),label:"Sweep deposits automatically",description:"Move USDC that arrives in the workspace wallets into their deposits."}),t.jsxs("div",{className:"gc-policy__caps",children:[x("maxPerRequest","Max per request (USDC)",{className:"gc-num gc-num--wide"}),x("maxReserve","Max channel reserve (USDC)",{className:"gc-num gc-num--wide"})]}),t.jsx(O,{size:"sm",label:"Base RPC URL",value:a.rpcUrl,error:o.rpcUrl,placeholder:"Chain default",hint:H("payments.rpcUrl","Your own endpoint avoids public rate limits. Saved URLs show without their path; leave them as they are to keep them."),onChange:i=>l("rpcUrl",i.target.value)}),t.jsx(oe,{label:"Fallback RPC URLs",rows:2,mono:!0,value:a.fallbackRpcUrls,error:o.fallbackRpcUrls,hint:"One per line, tried in order.",onChange:i=>l("fallbackRpcUrls",i.target.value)})]}),t.jsxs(F,{title:"Network and timeouts",summary:`Refresh ${Math.round(Number(a.peerRefreshMs)/1e3)} s`,children:[t.jsxs("div",{className:"gc-policy__caps",children:[x("peerRefreshMs","Peer refresh (ms)",{className:"gc-num gc-num--wide"}),x("metadataTimeoutMs","Metadata timeout (ms)",{className:"gc-num gc-num--wide",hint:N("network.metadataFetchTimeoutMs")}),x("requestTimeoutMs","Response start timeout (ms)",{className:"gc-num gc-num--wide"}),x("maxStreamMs","Longest stream (ms)",{className:"gc-num gc-num--wide",hint:N("network.maxStreamDurationMs")})]}),t.jsx(I,{checked:a.perServiceMetadata,onChange:i=>l("perServiceMetadata",i),label:"Per-service attribution in signed metadata",description:N("network.disableMetadataV2Services")??"Tells sellers which service each request used."})]})]})]}),j&&t.jsxs(D,{tone:"warning",title:"Restart the buyer to apply",children:["Saved, but this buyer was not restarted automatically. Restart it (for example ",t.jsx("code",{children:"systemctl restart antseed-buyer"}),", or stop and start ",t.jsx("code",{children:"antseed buyer start"}),") to use the new settings."]}),v&&t.jsx(D,{tone:"warning",title:"Changed elsewhere",action:t.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[t.jsx(y,{size:"sm",variant:"outline",onClick:()=>m(v),children:"Reload"}),t.jsx(y,{size:"sm",variant:"ghost",onClick:()=>{P(v),S(null)},children:"Keep editing"})]}),children:"Someone saved the buyer settings while you were editing them. Reload to see their version (your edits are dropped), or keep editing and save to replace it."}),!b&&f.error?t.jsx($,{error:f.error,title:"Could not save"}):null,t.jsxs("div",{className:"gc-actions",children:[t.jsx("span",{className:"gc-fineprint gc-actions__note",children:q.length===0?"No changes.":_?"Saving restarts the buyer.":"Applies at once, without a restart."}),t.jsx(y,{variant:"ghost",disabled:q.length===0||f.isPending,onClick:()=>m(v??k),children:"Reset"}),t.jsx(y,{disabled:q.length===0||Object.keys(o).length>0||f.isPending,onClick:()=>_?p(!0):f.mutate(),children:f.isPending?"Saving…":"Save"})]}),t.jsx(ie,{isOpen:b,busy:f.isPending,error:f.error,onClose:()=>{p(!1),f.reset()},onConfirm:()=>f.mutate(),title:"Restart the buyer?",confirmLabel:"Save and restart",tone:"primary",body:"These changes need a buyer restart. Requests in flight finish first; new requests wait a few seconds while it reconnects."})]})}const Ge=["general","buyer","observability","tokens","auth"];function Je(){const e=ke();return t.jsx(A,{title:"Gateway",children:t.jsx(z,{query:e,children:s=>t.jsx(le,{items:[["Public URL",s.publicUrl?t.jsx(Pe,{children:s.publicUrl},"u"):t.jsx("span",{className:"gc-muted",children:"Not set. Clients use this console's address."})],["Buyer",s.buyer.reachable?t.jsx(M,{tone:"success",children:"Connected"},"b"):t.jsx(M,{tone:"danger",children:"Unreachable"},"b")],["Sellers seen",String(s.buyer.peers)],["Spend feed",s.spendFeed],["USDC top-ups (x402)",s.x402?"On":"Off"]]})})})}function Ye({settings:e}){const s=e.buyer;return t.jsx(A,{title:"Buyer",description:t.jsxs(t.Fragment,{children:["The top of every routing policy: workspaces, members, keys and presets can only narrow it. Saved to the config file of the buyer on port ",s.proxyPort,ue(s.overrides,"proxyPort")?" (set by its start flags)":"","."]}),children:t.jsx(We,{buyer:s})})}function Xe({settings:e}){const s=re(),r=ne(),n=e.observability,[c,u]=d.useState(n.otlpEndpoint??""),[a,h]=d.useState(De(n.otlpHeaders)),[k,P]=d.useState(n.logContent),[v,S]=d.useState(n.retentionDays===null?"":String(n.retentionDays)),b=c.trim()&&!/^https?:\/\/\S+$/.test(c.trim())?"Use an http:// or https:// URL.":void 0,p=Le(n.otlpEndpoint,c.trim()||null)?_e(a):[],j=p.length?`Enter the value of ${p.join(", ")} again: saved values are not sent to a new endpoint.`:void 0,g=ae({mutationFn:()=>{if(b)throw new Error(b);if(j)throw new Error(j);const l=v===""?null:Number(v);return E.settings.setObservability({otlpEndpoint:c.trim()||null,otlpHeaders:$e(a),logContent:k,retentionDays:l})},onSuccess:l=>{const{restartRequired:m,...o}=l;s.setQueryData(U.settings,o),r(m?"Observability saved. Restart the gateway to apply it.":"Observability saved")},onError:l=>{Te(l,"otlp_headers_required")&&h(Z(a))}});return t.jsx(A,{title:"Observability",description:"Send one OpenTelemetry trace per request, and choose what the request log keeps.",children:t.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),g.mutate()},children:[t.jsx(O,{label:"OTLP/HTTP endpoint",placeholder:"https://otel.example.com/v1/traces",value:c,error:b,onChange:l=>u(l.target.value)}),t.jsx(oe,{label:"Headers",rows:3,mono:!0,placeholder:"Authorization: Bearer …",value:a,onChange:l=>h(l.target.value),error:j,hint:"One per line, as Name: value. Saved values show as ••••; leave them as they are to keep them (for the same endpoint only)."}),p.length>0&&t.jsx("div",{children:t.jsx(y,{size:"sm",variant:"outline",onClick:()=>h(Z(a)),children:"Clear saved values to re-enter them"})}),t.jsx(I,{checked:k,onChange:P,label:"Store request and response bodies",description:"Off by default. Bodies can contain personal data; only turn this on if you need it."}),t.jsx(B,{label:"Keep the request log for",value:v,onChange:S,options:[{value:"7",label:"7 days"},{value:"30",label:"30 days"},{value:"90",label:"90 days"},{value:"365",label:"1 year"},{value:"",label:"Forever"}]}),g.error?t.jsx($,{error:g.error,title:"Could not save"}):null,t.jsx("div",{className:"gc-actions",children:t.jsx(y,{type:"submit",disabled:g.isPending,children:g.isPending?"Saving…":"Save"})})]})})}function Ze(){const{me:e}=Re(),s=e.member.orgRole==="owner",r=Ce(),[n,c]=d.useState(!1),[u,a]=d.useState(""),[h,k]=d.useState("read"),[P,v]=d.useState("90"),[S,b]=d.useState(null),[p,j]=d.useState(null),g=Q({mutationFn:()=>E.adminTokens.create(u.trim(),h,P==="never"?null:Number(P)),onSuccess:m=>{c(!1),a(""),b(m.secret)},invalidate:[U.adminTokens]}),l=Q({mutationFn:m=>E.adminTokens.revoke(m.id),onSuccess:()=>j(null),invalidate:[U.adminTokens]});return t.jsxs(A,{flush:!0,title:"Management tokens",description:t.jsxs(t.Fragment,{children:["For scripts and CI. Send as ",t.jsx("code",{children:"Authorization: Bearer …"})," to ",t.jsx("code",{children:"/console/api"}),"."]}),actions:t.jsx(y,{size:"sm",leadingIcon:t.jsx(G.plus,{size:14}),onClick:()=>c(!0),children:"New token"}),children:[t.jsx(z,{query:r,children:m=>t.jsx(Fe,{label:"Management tokens",rows:m,rowKey:o=>o.id,rowLabel:o=>o.label,actions:o=>[{label:"Revoke",tone:"danger",onSelect:()=>j(o)}],empty:t.jsx(Ue,{icon:t.jsx(G.keys,{size:18}),title:"No management tokens"}),columns:[{key:"label",header:"Name",render:o=>t.jsx(Ne,{name:o.label,hint:o.hint})},{key:"scope",header:"Scope",render:o=>o.scope==="admin"?t.jsx(M,{tone:"warning",children:"Admin"}):t.jsx(M,{children:"Read only"})},{key:"created",header:"Created",secondary:!0,optional:!0,render:o=>W(o.createdAt)},{key:"expires",header:"Expires",secondary:!0,render:o=>t.jsx(Me,{at:o.expiresAt,format:W})},{key:"used",header:"Last used",secondary:!0,optional:!0,render:o=>Ie(o.lastUsedAt)}]})}),t.jsx(J,{isOpen:n,onClose:()=>c(!1),title:"New management token",children:t.jsxs("form",{className:"gc-stack",onSubmit:m=>{m.preventDefault(),g.mutate()},children:[t.jsx(O,{label:"Name",required:!0,value:u,onChange:m=>a(m.target.value),placeholder:"e.g. Terraform"}),t.jsx(B,{label:"Scope",value:h,onChange:m=>k(m),options:[{value:"read",label:"Read only (GET requests)"},{value:"admin",label:"Admin (everything an org admin can do)"}]}),t.jsx(B,{label:"Expires after",value:P,onChange:v,options:[{value:"30",label:"30 days"},{value:"90",label:"90 days"},{value:"365",label:"1 year"},...s?[{value:"never",label:"Never"}]:[]],hint:"Short-lived tokens limit the damage if one leaks."}),g.error?t.jsx($,{error:g.error,title:"Could not create the token"}):null,t.jsxs("div",{className:"gc-actions",children:[t.jsx(y,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),t.jsx(y,{type:"submit",disabled:g.isPending||!u.trim(),children:"Create token"})]})]})}),t.jsx(J,{isOpen:S!==null,onClose:()=>b(null),title:"Token created",children:S&&t.jsxs("div",{className:"gc-stack",children:[t.jsx(qe,{secret:S}),t.jsx("div",{className:"gc-actions",children:t.jsx(y,{onClick:()=>b(null),children:"Done"})})]})}),t.jsx(ie,{isOpen:p!==null,busy:l.isPending,error:l.error,onClose:()=>j(null),onConfirm:()=>p&&l.mutate(p),title:"Revoke this token?",confirmLabel:"Revoke",body:`Anything using ${(p==null?void 0:p.label)??"this token"} loses access immediately.`})]})}function et({settings:e}){const s=e.auth,r=n=>n?t.jsx(M,{tone:"success",children:"On"}):t.jsx(M,{children:"Off"});return t.jsx(A,{title:"Sign-in methods",description:"Configured on the gateway host with environment variables. Read only here.",children:t.jsxs("div",{className:"gc-stack",children:[t.jsx(le,{items:[["Passkeys",r(s.passkey)],["Wallet (Sign-In with Ethereum)",r(s.wallet)],["OpenID Connect",s.oidc?t.jsx(M,{tone:"success",children:s.oidc.label},"o"):r(!1)],["Cloudflare Access",r(s.cloudflareAccess)],["API key view for key holders",r(s.apiKeyLogin)]]}),t.jsx(D,{tone:"info",title:"Using your own identity provider",children:"Set the OpenID Connect issuer, client id and secret in the gateway's environment and restart it, or put the console behind Cloudflare Access and enable trusted Access headers. The gateway docs list the exact variables. Antseed runs no sign-in service of its own."})]})})}function tt({tab:e,settings:s}){return e==="buyer"?t.jsx(Ye,{settings:s}):e==="observability"?t.jsx(Xe,{settings:s}):t.jsx(et,{settings:s})}function pt(){const[e,s]=d.useState(()=>{const n=new URLSearchParams(window.location.search).get("tab");return Ge.includes(n)?n:"general"}),r=Se({queryKey:U.settings,queryFn:E.settings.get});return d.useEffect(()=>{var n;(n=window.scrollTo)==null||n.call(window,0,0)},[e]),t.jsxs("div",{className:"gc-page",children:[t.jsx(je,{title:"Settings"}),t.jsx(Ee,{id:"gc-settings",label:"Settings sections",value:e,onChange:s,tabs:[{id:"general",label:"General"},{id:"buyer",label:"Buyer"},{id:"observability",label:"Observability"},{id:"tokens",label:"Management tokens"},{id:"auth",label:"Sign-in"}]}),t.jsxs(Ae,{tabsId:"gc-settings",tab:e,className:"gc-stack",children:[e==="general"&&t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsx(we,{})]}),e==="tokens"&&t.jsx(Ze,{}),(e==="buyer"||e==="observability"||e==="auth")&&t.jsx(z,{query:r,children:n=>t.jsx(tt,{tab:e,settings:n})}),r.error&&e==="general"?t.jsx($,{error:r.error}):null]})]})}export{pt as default};
@@ -1,3 +0,0 @@
1
- import{w as o}from"./core-BCJdIbrO.js";import"./index-cESr4Zze.js";import"./index.es-DP9EmOYi.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-sKQksBWU.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const n=o` <svg fill="none" viewBox="0 0 13 4">
2
- <path fill="currentColor" d="M.5 0h12L8.9 3.13a3.76 3.76 0 0 1-4.8 0L.5 0Z" />
3
- </svg>`;export{n as cursorSvg};
@@ -1 +0,0 @@
1
- import{S as d,F as H,a as N}from"./mermaid-MCJ5UELQ-B8uOykea.js";import{r as o,j}from"./index-cESr4Zze.js";import"./bundle-full-idGWmtvy.js";import"./clsx-B-dksMZM.js";import"./Chat-BbM_y6mh.js";import"./SidePanel-D0rNElh3.js";import"./selection-HN8SZ52c.js";import"./ModelDetails-CkDNU2Px.js";import"./Tabs-Cv10NtDy.js";import"./roving-DkptacxO.js";import"./stored-CETnaQtE.js";import"./Disclosure-DMLE7rCw.js";import"./VerificationLinks-CERoRvCR.js";import"./SelectField-Cl4acfcI.js";var q=({code:m,isIncomplete:a=!1,language:e,maxHeight:n,raw:t,className:u,startLine:g,lineNumbers:c,...h})=>{let{shikiTheme:s}=o.useContext(d),r=H(),[x,i]=o.useState(t);return o.useEffect(()=>{if(!r){i(t);return}let p=!0,l=r.highlight({code:m,isIncomplete:a,language:e,themes:s},f=>{p&&i(f)});return l&&i(l),()=>{p=!1}},[m,a,e,s,r,t]),j.jsx(N,{className:u,language:e,lineNumbers:c,maxHeight:n,result:x,startLine:g,...h})};export{q as HighlightedCodeBlockBody};
@@ -1 +0,0 @@
1
- import{at as n,g as o,aw as i,ax as l}from"./index-cESr4Zze.js";function f(e,t){switch(e){case"expected-cost":return t>1?`Ranked by the expected cost of a good answer: price plus waiting time, divided by the success rate this gateway has seen. The ${t} sellers within 30% of the best share the traffic, cheaper and more reliable ones more often.`:"Ranked by the expected cost of a good answer: price plus waiting time, divided by the success rate this gateway has seen. The best seller takes the traffic; no other is close enough to share it.";case"trust":return"Ranked by trust score, highest first. Sellers failing lately go after the healthy ones, and cooling-down sellers last.";case"price":return"Your routing policy sorts by price: cheapest first. Failing and cooling-down sellers still go last.";case"latency":return"Your routing policy sorts by speed: fastest first token first. Failing and cooling-down sellers still go last."}}function a(e){return`${Math.round(e*100)}%`}function u(e){const t=e>=10?Math.round(e):Math.round(e*10)/10;return`${t} recent request${t===1?"":"s"}`}function h(e){if(e.record==="none")return"No requests yet: assumed 80% success until it has answered some.";const t=`${a(e.successRate)} success over ${u(e.observations)}`;return e.record==="other-models"?`${t} on its other models (counted at half weight)`:t}function p(e,t=Date.now()){const r=e.lastFailureReason?`: ${e.lastFailureReason}`:"",s=e.lastFailureAt?`, ${n(e.lastFailureAt,t)}`:"";return e.coolingDown?`Cooling down after failures in a row${r}${s}. Tried last.`:e.failing?`Failing lately${r}${s}. Tried after the healthy sellers.`:null}function d(e){const t=[];return e.ordering==="expected-cost"&&t.push(`${o(e.expectedCostUsd)} expected per good answer`),t.push(h(e)),e.firstTokenMs!==null&&t.push(`${i(e.firstTokenMs)} first token`),e.tokensPerSecond!==null&&t.push(l(e.tokensPerSecond)),e.sharesTraffic&&e.trafficShare!==null&&t.push(`takes ~${a(e.trafficShare)} of the traffic`),e.channel==="open"?t.push("payment channel open"):e.channel==="new"&&t.push("first request opens a payment channel (~5 s)"),e.maxConcurrency!==null&&e.inFlight>=e.maxConcurrency?t.push(`at capacity (${e.inFlight}/${e.maxConcurrency} in flight): tried after sellers with room`):e.inFlight>0&&t.push(`${e.inFlight}${e.maxConcurrency!==null?`/${e.maxConcurrency}`:""} in flight`),t}function g(e){const t=`#${e.rank} of ${e.of} eligible seller${e.of===1?"":"s"}`;switch(e.pick){case"spread":return`Drawn from the ${e.poolSize} sellers sharing this model's traffic (${t}).`;case"best":return`The best seller for this model on its own (${t}).`;case"conversation":return`The seller this conversation stays on, so its prompt cache keeps working (${t}).`;case"exploration":return`A probe: one request in twenty tries a seller with no recent record, so routing keeps learning (${t}).`;case"failover":return`${e.attempt===1?"The seller before it":`The ${e.attempt} sellers before it`} failed this request, so it went to the next one (${t}).`;case"order":return e.attempt>0?`${e.attempt===1?"The seller before it":`The ${e.attempt} sellers before it`} could not take this request (${t}).`:e.routeChainPosition!==null?`Seller #${e.routeChainPosition} in your routing policy's route for this model (${t}).`:e.ordering==="trust"?`The most trusted healthy seller (${t}).`:`First in the order your routing policy sets (${t}).`}}export{p as h,f as o,g as p,h as r,d as s};
@@ -1 +0,0 @@
1
- import{u as v,n as b,t as F,q as L,f as D,j as s,L as O,B as f,v as i,O as w,bl as N,w as R}from"./index-cESr4Zze.js";import{o as q,h as z,s as B}from"./selection-HN8SZ52c.js";import{P as y,a as P}from"./SidePanel-D0rNElh3.js";import{D as A}from"./Disclosure-DMLE7rCw.js";function C(n){return n.displayName??R(n.peerId,8,4)}function $({preview:n,loading:o,pin:t,title:j="Seller selection",explainSkipped:c,skippedOpen:S=!1}){var x;const{viewer:k}=v(),I=b(k),p=F({mutationFn:r=>D.network.resetSellerHistory(r),invalidate:[L.group("routing"),["chat-route-preview"]],toast:"History cleared: the seller starts fresh."});if(o)return s.jsx(y,{title:j,children:s.jsx(O,{rows:3})});if(!n)return null;const h=n.candidates.filter(r=>r.eligible).sort((r,e)=>(r.rank??1e9)-(e.rank??1e9)),g=n.candidates.filter(r=>!r.eligible),u=((x=h[0])==null?void 0:x.selection)??null,d=(t==null?void 0:t.peerId)??null;return s.jsxs(y,{title:j,children:[n.modelAllowed?h.length===0?s.jsx("p",{className:"gc-fineprint",children:"No seller passes your routing settings for this model right now."}):s.jsxs("p",{className:"gc-fineprint",children:[d?"Pinned: every request goes to the pinned seller. Without the pin, automatic routing works like this. ":"",u?q(u.ordering,u.poolSize):"Sellers in the order automatic routing tries them; the next one takes over when one fails."]}):s.jsx("p",{className:"gc-fineprint",children:"Your routing policy does not allow this model: requests for it are refused."}),h.length>0&&s.jsx("ol",{className:"gc-panel-rows","aria-label":"Sellers in routing order",children:h.map(r=>{const e=r.selection,m=e?z(e):null,a=d!==null&&d===r.peerId.toLowerCase();return s.jsx(P,{selected:a,title:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"gc-muted",children:["#",r.rank]})," ",s.jsx(w,{to:N("providers",r.peerId),children:C(r)})]}),meta:e?B(e).map(l=>s.jsx("span",{children:l},l)):r.reasons.map(l=>s.jsx("span",{children:l},l)),badges:((e==null?void 0:e.sharesTraffic)||m||(e==null?void 0:e.stale)||(e==null?void 0:e.channel)==="free"||(e==null?void 0:e.routeChainPosition))&&s.jsxs("div",{className:"gc-stack gc-stack--tight",children:[s.jsxs("div",{className:"gc-badges",children:[(e==null?void 0:e.routeChainPosition)!=null&&s.jsxs(i,{children:["Route #",e.routeChainPosition]}),(e==null?void 0:e.sharesTraffic)&&s.jsx(i,{children:"Shares traffic"}),(e==null?void 0:e.channel)==="free"&&s.jsx(i,{tone:"success",children:"Free"}),e!=null&&e.coolingDown?s.jsx(i,{tone:"warning",children:"Cooling down"}):e!=null&&e.failing?s.jsx(i,{tone:"warning",children:"Failing"}):null,(e==null?void 0:e.stale)&&!e.failing&&!e.coolingDown&&s.jsx(i,{children:e.record==="none"?"New":"Not seen lately"})]}),m&&s.jsx("span",{className:"gc-fineprint",children:m})]}),actions:s.jsxs(s.Fragment,{children:[I&&e&&(e.failing||e.coolingDown)&&s.jsx(f,{size:"sm",variant:"ghost",disabled:p.isPending,title:"Forget what this gateway has seen of the seller, so routing gives it a fresh start",onClick:()=>p.mutate(r.peerId),children:"Reset history"}),t&&s.jsx(f,{size:"sm",variant:a?"outline":"ghost","aria-pressed":a,onClick:()=>t.onChange(a?null:r.peerId.toLowerCase()),children:a?"Pinned":"Pin"})]})},r.peerId)})}),g.length>0&&s.jsx(A,{title:"Not used",summary:`${g.length} seller${g.length===1?"":"s"}`,defaultOpen:S,children:s.jsx("ul",{className:"gc-panel-rows","aria-label":"Sellers automatic routing skips",children:g.map(r=>s.jsx(P,{title:s.jsx(w,{to:N("providers",r.peerId),children:C(r)}),meta:s.jsx("span",{children:r.reasons.join(" · ")||"not eligible"}),badges:c==null?void 0:c(r),actions:t&&s.jsx(f,{size:"sm",variant:"ghost",title:"Pinning skips your routing settings' ranking, not the hard limits",onClick:()=>t.onChange(r.peerId.toLowerCase()),children:"Pin"})},r.peerId))})})]})}function E(n,o){try{const t=localStorage.getItem(n);return t?JSON.parse(t):o}catch{return o}}function M(n,o){try{localStorage.setItem(n,JSON.stringify(o))}catch{}}export{$ as S,E as l,M as s};