@antseed/gateway-console 0.1.12 → 0.1.13

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 (163) hide show
  1. package/dist/assets/{Activity-BcXN_DqV.js → Activity-DATDm05n.js} +1 -1
  2. package/dist/assets/{Audit-nk0K4aQy.js → Audit-DoUfhCFC.js} +1 -1
  3. package/dist/assets/{BrandIcon-6gq42Dg-.js → BrandIcon-_kk81WuK.js} +1 -1
  4. package/dist/assets/{ChainGate-Do1wYOPQ.js → ChainGate-Bp0uTPIx.js} +1 -1
  5. package/dist/assets/{ChannelClose-CdHUKMFm.js → ChannelClose-BR31CpqA.js} +1 -1
  6. package/dist/assets/{Charts-BMsoEfDr.js → Charts-kvs4OmQ5.js} +1 -1
  7. package/dist/assets/{Chat-C4DsUQG-.js → Chat-DXeiNUvp.js} +3 -3
  8. package/dist/assets/{ConnectWallet-BYdqZipy.js → ConnectWallet-BgF0sOSn.js} +1 -1
  9. package/dist/assets/{DataTable-BCgVRqY6.js → DataTable-DsVQCeW0.js} +1 -1
  10. package/dist/assets/{KeyHolder-JK1zjm4r.js → KeyHolder-DxMTzn2W.js} +1 -1
  11. package/dist/assets/Keys-BjYvx7sT.js +1 -0
  12. package/dist/assets/{Logs-DfacvRY6.js → Logs-oKL9uKOU.js} +1 -1
  13. package/dist/assets/Members-T-UrNdtc.js +1 -0
  14. package/dist/assets/{Migrate-Bqnu-HEP.js → Migrate-Cf0OtMIJ.js} +1 -1
  15. package/dist/assets/ModelDetails-Cui5mNEy.js +1 -0
  16. package/dist/assets/Models-PTbGWvAC.js +1 -0
  17. package/dist/assets/{OperatorActions-DWX4uK6I.js → OperatorActions-CnSuoVIH.js} +1 -1
  18. package/dist/assets/{OperatorGateAlert-cpvsO9yT.js → OperatorGateAlert-B6C_5PEr.js} +1 -1
  19. package/dist/assets/{Overview-C4Bu8z8u.js → Overview-CJl9bY9L.js} +1 -1
  20. package/dist/assets/{PeerPicker-CcMSXxY3.js → PeerPicker-C_8PqMUU.js} +1 -1
  21. package/dist/assets/PolicyEditor-DAaebg1f.js +1 -0
  22. package/dist/assets/{PolicyField-ldIq_Yw-.js → PolicyField-CHfrLOyB.js} +1 -1
  23. package/dist/assets/Presets-wZYcL1FD.js +4 -0
  24. package/dist/assets/Providers-BAhStRFF.js +1 -0
  25. package/dist/assets/{RequestLog-ChzJA1hM.js → RequestLog-Bqg0utI3.js} +1 -1
  26. package/dist/assets/{Rewards-Cgw7r3bc.js → Rewards-DlbuI--y.js} +2 -2
  27. package/dist/assets/{RewardsClaim-Df0QQMHb.js → RewardsClaim-CAnaSpmX.js} +1 -1
  28. package/dist/assets/Routing-BlkYS_0B.js +1 -0
  29. package/dist/assets/{Segmented-DYnoemT9.js → Segmented-C2AVrIR7.js} +1 -1
  30. package/dist/assets/{SelectField-m1sMIgMa.js → SelectField-DjRyrny7.js} +1 -1
  31. package/dist/assets/{Settings-D2MkmqAU.js → Settings-yiWxbHdt.js} +3 -3
  32. package/dist/assets/SidePanel-DHP0GHL-.js +1 -0
  33. package/dist/assets/{Staking-2rSdK2Ob.js → Staking-Bmp79Jmy.js} +1 -1
  34. package/dist/assets/{StakingDashboard-DvLxJ1j4.js → StakingDashboard-Ijg1EDMe.js} +1 -1
  35. package/dist/assets/Switch-DClkimeN.js +1 -0
  36. package/dist/assets/{Tabs-CCabxVNK.js → Tabs-DOfs9pV6.js} +1 -1
  37. package/dist/assets/{TextAreaField-BCi-qMua.js → TextAreaField-BzOoHz0q.js} +1 -1
  38. package/dist/assets/{UsageByModel-Fb68pvpD.js → UsageByModel-Ck9YsQAj.js} +1 -1
  39. package/dist/assets/{VerificationLinks-CWyl6ZEp.js → VerificationLinks-CgB1oqeh.js} +1 -1
  40. package/dist/assets/{Wallet-BVuVEAB5.js → Wallet-CqvNVXRO.js} +3 -3
  41. package/dist/assets/{WalletConfirm-Bs7CFRaa.js → WalletConfirm-Ca7r5H8h.js} +1 -1
  42. package/dist/assets/{WalletFunding-w9MlXB0t.js → WalletFunding-CClRgkd3.js} +1 -1
  43. package/dist/assets/{WalletSignIn-CFxQjhbw.js → WalletSignIn-OeYy6k9J.js} +1 -1
  44. package/dist/assets/Workspaces-DdMaBlC2.js +1 -0
  45. package/dist/assets/{add-CWU7ACA6.js → add-BIV9ozpT.js} +1 -1
  46. package/dist/assets/{all-wallets-C7xN3fay.js → all-wallets-DTcdqYms.js} +1 -1
  47. package/dist/assets/{app-store-C9LYdcrl.js → app-store-sivsgaWo.js} +1 -1
  48. package/dist/assets/{apple-DyeheYaR.js → apple-CnEh2Z0o.js} +1 -1
  49. package/dist/assets/{arrow-bottom-C-Ld0QTs.js → arrow-bottom-CV61GKUR.js} +1 -1
  50. package/dist/assets/{arrow-bottom-circle-CBZDZ8Ab.js → arrow-bottom-circle-DFzyOmM2.js} +1 -1
  51. package/dist/assets/{arrow-left-DpJrY7yH.js → arrow-left-C15ZaZSP.js} +1 -1
  52. package/dist/assets/{arrow-right-C12AYUbo.js → arrow-right-91Gw6L2M.js} +1 -1
  53. package/dist/assets/{arrow-top-DTpoR1JD.js → arrow-top-DPQixVIo.js} +1 -1
  54. package/dist/assets/{bank-Ce19qcX5.js → bank-9Hiz5n1N.js} +1 -1
  55. package/dist/assets/{basic-xSJded8g.js → basic-BSP1_xZI.js} +1 -1
  56. package/dist/assets/{browser-efLjW-nE.js → browser-CyasGPFE.js} +1 -1
  57. package/dist/assets/{bundle-full-Bo_XusKG.js → bundle-full-C3z6oPNG.js} +1 -1
  58. package/dist/assets/{card-C5hP1T57.js → card-DuAFw0fG.js} +1 -1
  59. package/dist/assets/{ccip-B61TPyfu.js → ccip-CnjHj1RZ.js} +1 -1
  60. package/dist/assets/{checkmark-D6TDn2nt.js → checkmark-Did8RFKg.js} +1 -1
  61. package/dist/assets/{checkmark-bold-D6Dl_7lL.js → checkmark-bold-WTuNIh6X.js} +1 -1
  62. package/dist/assets/{chevron-bottom-BN93pLQ-.js → chevron-bottom-YjhZRIXC.js} +1 -1
  63. package/dist/assets/{chevron-left-BRtPfxLq.js → chevron-left-C9RIiMNF.js} +1 -1
  64. package/dist/assets/{chevron-right-q6ckJ6mb.js → chevron-right-n1LdC3Bu.js} +1 -1
  65. package/dist/assets/{chevron-top-C1AX5sm6.js → chevron-top-BukRfdTL.js} +1 -1
  66. package/dist/assets/{chrome-store-Bo_BoLHJ.js → chrome-store-BkN1NWnM.js} +1 -1
  67. package/dist/assets/{clock-BhAO_7G0.js → clock-D1bJyWIM.js} +1 -1
  68. package/dist/assets/{close-BtzdVDHu.js → close-DL88TIDj.js} +1 -1
  69. package/dist/assets/code-block-DwCsSJzh.js +3 -0
  70. package/dist/assets/{coinPlaceholder-Di1b8fYJ.js → coinPlaceholder-CfwG-TTk.js} +1 -1
  71. package/dist/assets/{compass-C10lNmou.js → compass-ZpTR_nrR.js} +1 -1
  72. package/dist/assets/{copy-B5e38uFc.js → copy-judiAK2Z.js} +1 -1
  73. package/dist/assets/{core-B0f6zAPS.js → core-CA5S1nbm.js} +3 -3
  74. package/dist/assets/cursor-DvOm1Cji.js +3 -0
  75. package/dist/assets/{cursor-transparent-DzGICXfN.js → cursor-transparent-BmGrLznf.js} +1 -1
  76. package/dist/assets/{desktop-DSb6a3DL.js → desktop-BuMTjH7M.js} +1 -1
  77. package/dist/assets/{disconnect-DRzHq1ok.js → disconnect-De2ZlK-6.js} +1 -1
  78. package/dist/assets/{discord-c_RQc3fB.js → discord-BNL_ltCn.js} +1 -1
  79. package/dist/assets/{en_US-Y4ZOVFV4-Bkc-z49M.js → en_US-Y4ZOVFV4-B7L59ik1.js} +4 -4
  80. package/dist/assets/{etherscan-CQGvGKJu.js → etherscan-HbcRO2IH.js} +1 -1
  81. package/dist/assets/{exclamation-triangle-CPWxzsHw.js → exclamation-triangle-x5ImWOJX.js} +1 -1
  82. package/dist/assets/{extension-ytWXOqXr.js → extension-rfKIvpqo.js} +1 -1
  83. package/dist/assets/{external-link-BYoSE2u3.js → external-link-7kjdDR71.js} +1 -1
  84. package/dist/assets/{facebook-CMBv0nnN.js → facebook-BclEg-_B.js} +1 -1
  85. package/dist/assets/{farcaster-CJmfWTQP.js → farcaster-D2oH1JNb.js} +1 -1
  86. package/dist/assets/{filters-DEiNVvyn.js → filters-JMxKoXjp.js} +1 -1
  87. package/dist/assets/{github-CdMwJkf8.js → github-MlVki9qk.js} +1 -1
  88. package/dist/assets/{google-CHI5gfH8.js → google-D65ws424.js} +1 -1
  89. package/dist/assets/{help-circle-dA36a8fM.js → help-circle-BK3cKTQP.js} +1 -1
  90. package/dist/assets/highlighted-body-KQOG7T2V-CAY_ZWoa.js +1 -0
  91. package/dist/assets/{id-Dm0-1g1D.js → id-B-GhJWbg.js} +1 -1
  92. package/dist/assets/{image-BL3ODVX_.js → image-CiFhN0rj.js} +1 -1
  93. package/dist/assets/{index-BRgGxCKs.js → index-B3lQX3LL.js} +3 -3
  94. package/dist/assets/{index-BAcoKUeC.css → index-B5U62otb.css} +1 -1
  95. package/dist/assets/{index-DPXW_JSn.js → index-BJa4Qaxt.js} +4 -4
  96. package/dist/assets/{index-CHeO_lLD.js → index-ByQIfYvU.js} +1 -1
  97. package/dist/assets/{index-D1OXThJP.js → index-DNDRe5Tn.js} +1 -1
  98. package/dist/assets/{index-BXzZZOmS.js → index-DuaHPDzN.js} +1 -1
  99. package/dist/assets/{index.es-XdMmjy3e.js → index.es-B6D0HpEZ.js} +3 -3
  100. package/dist/assets/{info-circle-CKgnYdF-.js → info-circle-xhU8sugp.js} +1 -1
  101. package/dist/assets/{info-BbBzpLWs.js → info-exBeWZDh.js} +1 -1
  102. package/dist/assets/{lightbulb-B6Xv9kMK.js → lightbulb-gxTCeOnq.js} +1 -1
  103. package/dist/assets/{limits-uCwhqY-O.js → limits-CFW9YnA7.js} +1 -1
  104. package/dist/assets/{mail-BdCMypwE.js → mail-DmWSDPhy.js} +1 -1
  105. package/dist/assets/{mermaid-MCJ5UELQ-BaHsArCB.js → mermaid-MCJ5UELQ-sIadr4pS.js} +3 -3
  106. package/dist/assets/{metamask-sdk-BL7QLxcU.js → metamask-sdk-DY00rxTf.js} +1 -1
  107. package/dist/assets/{mobile-F_82dhUb.js → mobile-B3BxvHa9.js} +1 -1
  108. package/dist/assets/{more-CtMTtAsM.js → more-BjVWPgrZ.js} +1 -1
  109. package/dist/assets/{network-placeholder-BRs4Lylz.js → network-placeholder-YeNSVIJz.js} +1 -1
  110. package/dist/assets/{nftPlaceholder-DONTHyad.js → nftPlaceholder-DbHcJNrA.js} +1 -1
  111. package/dist/assets/{off-Bwru40fy.js → off-CtPqpcbp.js} +1 -1
  112. package/dist/assets/{play-store-CDeNquGq.js → play-store-D9paBHV6.js} +1 -1
  113. package/dist/assets/{plus-EcrYfJFM.js → plus-D60mJLP4.js} +1 -1
  114. package/dist/assets/{qr-code-CF-SIZQq.js → qr-code-D7sh4LqT.js} +1 -1
  115. package/dist/assets/{recycle-horizontal-CQAPujmy.js → recycle-horizontal-G2tc-boO.js} +1 -1
  116. package/dist/assets/{refresh-BErGEy2b.js → refresh-DbRsPfeH.js} +1 -1
  117. package/dist/assets/{reown-logo-Ge2o4AAI.js → reown-logo-C7-J6a93.js} +1 -1
  118. package/dist/assets/{search-Ca88O9BA.js → search-Cifbb1kp.js} +1 -1
  119. package/dist/assets/selection-GKCY6QaK.js +1 -0
  120. package/dist/assets/{send-VS1TUwft.js → send-C7VNtheK.js} +1 -1
  121. package/dist/assets/{sendTransaction-k8aDYfd4.js → sendTransaction-OKix18Wz.js} +1 -1
  122. package/dist/assets/stored-C5eGF9Ho.js +1 -0
  123. package/dist/assets/{swapHorizontal-UNJ9wJ3Z.js → swapHorizontal-_un_Nt7W.js} +1 -1
  124. package/dist/assets/{swapHorizontalBold-eQTpC4fd.js → swapHorizontalBold-DipkGXtT.js} +1 -1
  125. package/dist/assets/{swapHorizontalMedium-DaFWQu14.js → swapHorizontalMedium-BwrG3AId.js} +1 -1
  126. package/dist/assets/{swapHorizontalRoundedBold-BbRZUmJZ.js → swapHorizontalRoundedBold-CzxQhZjN.js} +1 -1
  127. package/dist/assets/{swapVertical-CrZ6Be2R.js → swapVertical-DVrrmwGq.js} +1 -1
  128. package/dist/assets/{telegram-CDAYT0ej.js → telegram-CM4CyaZC.js} +1 -1
  129. package/dist/assets/{three-dots-CK__4w5S.js → three-dots-BCalKpaE.js} +1 -1
  130. package/dist/assets/{twitch-BS50nSpU.js → twitch-CfAHmkC8.js} +1 -1
  131. package/dist/assets/{twitterIcon-BtVx5zJI.js → twitterIcon-1tyE-UqP.js} +1 -1
  132. package/dist/assets/{usage-DQGKL0DJ.js → usage-CckQzwRu.js} +1 -1
  133. package/dist/assets/{useInfiniteQuery-CAj47QRO.js → useInfiniteQuery-Bq7y7uuf.js} +1 -1
  134. package/dist/assets/{useTx-DzRlz7Ez.js → useTx-B3hhNYvk.js} +1 -1
  135. package/dist/assets/{verify-hRAQBjoS.js → verify-CepTEVee.js} +1 -1
  136. package/dist/assets/{verify-filled-E4LyUumx.js → verify-filled-DgTBeCbs.js} +1 -1
  137. package/dist/assets/{w3m-modal-CLSVKDRP.js → w3m-modal-Cz6YrUSP.js} +1 -1
  138. package/dist/assets/{waitForCallsStatus-C51Vv8Tt.js → waitForCallsStatus-Bb1t_wzE.js} +1 -1
  139. package/dist/assets/{wallet-D-TGx4VA.js → wallet-CEqn1yNE.js} +1 -1
  140. package/dist/assets/{wallet-placeholder-SjwHckDA.js → wallet-placeholder-Dy7Awuau.js} +1 -1
  141. package/dist/assets/{walletconnect-7nuI2nwG.js → walletconnect-IC3BdQZa.js} +1 -1
  142. package/dist/assets/{warning-circle-BI2BfSeD.js → warning-circle-Csh8khJG.js} +1 -1
  143. package/dist/assets/{writeContract-CaMlmKcK.js → writeContract-D27zB12y.js} +1 -1
  144. package/dist/assets/{x-DoGk7CZD.js → x-fLBvtS6t.js} +1 -1
  145. package/dist/index.html +2 -2
  146. package/package.json +1 -1
  147. package/dist/assets/Disclosure-CQMtWM0M.js +0 -1
  148. package/dist/assets/Keys-BndDLQdj.js +0 -1
  149. package/dist/assets/Members-pSSyfBFp.js +0 -1
  150. package/dist/assets/ModelDetails-Sgq3MjfG.js +0 -1
  151. package/dist/assets/Models-C6QzCAh4.js +0 -1
  152. package/dist/assets/PolicyEditor-COREmE0O.js +0 -1
  153. package/dist/assets/Presets-DFKw93HK.js +0 -4
  154. package/dist/assets/Providers-D_0V31og.js +0 -1
  155. package/dist/assets/Routing-KpWxzlwc.js +0 -1
  156. package/dist/assets/SidePanel-BFQArkoa.js +0 -1
  157. package/dist/assets/Switch-Db8Sm64J.js +0 -1
  158. package/dist/assets/Workspaces-DktyLm08.js +0 -1
  159. package/dist/assets/code-block-DqMh9vFo.js +0 -3
  160. package/dist/assets/cursor-zACYQT2t.js +0 -3
  161. package/dist/assets/highlighted-body-KQOG7T2V-BFlyrf-z.js +0 -1
  162. package/dist/assets/selection-BV37SUs_.js +0 -1
  163. package/dist/assets/stored-e0tX90bC.js +0 -1
@@ -1 +1 @@
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
+ import{m as h}from"./index-BJa4Qaxt.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{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
+ import{b6 as v,b7 as g,b8 as x,b9 as l,ba as p}from"./index-BJa4Qaxt.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-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
+ 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-B7L59ik1.js";import{bu as $,c7 as G,j as y,af as S,r as m,c8 as q,aw as L}from"./index-BJa4Qaxt.js";import{w as U}from"./writeContract-D27zB12y.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-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">
1
+ import{w as l}from"./core-CA5S1nbm.js";import"./index-BJa4Qaxt.js";import"./index.es-B6D0HpEZ.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-B7L59ik1.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{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">
1
+ import{w as l}from"./core-CA5S1nbm.js";import"./index-BJa4Qaxt.js";import"./index.es-B6D0HpEZ.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-B7L59ik1.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{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`
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-CA5S1nbm.js";import{c as u,n as w,r as d,o as F,U as We}from"./index-B3lQX3LL.js";import"./index-BJa4Qaxt.js";import"./index.es-B6D0HpEZ.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-B7L59ik1.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-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
+ 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-B7L59ik1.js";import{s as G}from"./sendTransaction-OKix18Wz.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-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">
1
+ import{w as o}from"./core-CA5S1nbm.js";import"./index-BJa4Qaxt.js";import"./index.es-B6D0HpEZ.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-B7L59ik1.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-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`
1
+ import{w as a}from"./core-CA5S1nbm.js";import"./index-BJa4Qaxt.js";import"./index.es-B6D0HpEZ.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-B7L59ik1.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-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">
1
+ import{w as l}from"./core-CA5S1nbm.js";import"./index-BJa4Qaxt.js";import"./index.es-B6D0HpEZ.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-B7L59ik1.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-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">
1
+ import{w as r}from"./core-CA5S1nbm.js";import"./index-BJa4Qaxt.js";import"./index.es-B6D0HpEZ.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-B7L59ik1.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-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
+ import{A as g,e as l,g as y,d as A,p as C}from"./en_US-Y4ZOVFV4-B7L59ik1.js";import{s as E}from"./sendTransaction-OKix18Wz.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-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">
1
+ import{w as l}from"./core-CA5S1nbm.js";import"./index-BJa4Qaxt.js";import"./index.es-B6D0HpEZ.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-B7L59ik1.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-DPXW_JSn.js"></script>
11
- <link rel="stylesheet" crossorigin href="/console/assets/index-BAcoKUeC.css">
10
+ <script type="module" crossorigin src="/console/assets/index-BJa4Qaxt.js"></script>
11
+ <link rel="stylesheet" crossorigin href="/console/assets/index-B5U62otb.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.12",
3
+ "version": "0.1.13",
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{j as s}from"./index-DPXW_JSn.js";function n({title:i,summary:e,children:o,defaultOpen:r,className:a}){return s.jsxs("details",{className:["as-disclosure",a].filter(Boolean).join(" "),open:r,children:[s.jsxs("summary",{className:"as-disclosure__summary",children:[s.jsx("span",{className:"as-disclosure__title",children:i}),e!=null&&e!==""&&s.jsx("span",{className:"as-disclosure__meta",children:e}),s.jsx("svg",{className:"as-disclosure__chevron",width:"12",height:"12",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})]}),s.jsx("div",{className:"as-disclosure__body",children:o})]})}export{n as D};
@@ -1 +0,0 @@
1
- import{ak as ke,r as m,aK as je,aL as fe,j as s,C as ne,aM as ve,Y as Se,B as S,u as le,a as Ce,i as ce,d as de,c as Pe,t as ie,P as Le,I as K,T as U,l as Ne,Q as Ae,aN as Te,z as ue,aO as X,A as me,g as ye,m as Ee,aa as Re,E as Z,aP as pe,D as De,q as F,f as C,v,ab as J,e as Ie,aQ as Me,aR as Ke,aS as Ue,aT as ee,o as Fe,X as Oe}from"./index-DPXW_JSn.js";import{u as se,a as _e,P as Ye}from"./PolicyField-ldIq_Yw-.js";import{T as Be}from"./Tabs-CCabxVNK.js";import{l as te,d as ae,L as qe}from"./limits-uCwhqY-O.js";import{t as ze}from"./dates-Pi3-Ywng.js";import{r as We,e as $e}from"./usage-DQGKL0DJ.js";import{S as he}from"./Switch-Db8Sm64J.js";import{D as Qe,u as Ve,P as He}from"./DataTable-BCgVRqY6.js";import{b as Ge}from"./Charts-BMsoEfDr.js";import{S as Xe}from"./SelectField-m1sMIgMa.js";import"./PolicyEditor-COREmE0O.js";import"./PeerPicker-CcMSXxY3.js";import"./Segmented-DYnoemT9.js";import"./roving-DkptacxO.js";import"./Disclosure-CQMtWM0M.js";function Ze({result:e,onClose:l}){var r;const o=ke(),[c,y]=m.useState("curl"),d=je((r=o.data)==null?void 0:r.publicUrl,window.location.origin),i=e?fe(d,e.secret):[],a=i.find(h=>h.id===c);return s.jsx(ne,{isOpen:e!==null,onClose:l,size:"lg",eyebrow:"API key",title:e?`${e.key.label} is ready`:"",children:e&&s.jsxs("div",{className:"gc-stack",children:[s.jsx(ve,{secret:e.secret}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label",children:"Use it"}),s.jsxs("p",{className:"gc-muted",children:["Base URL ",s.jsxs("code",{children:[d,"/v1"]}),". Replace ",s.jsx("code",{children:"<model>"})," with a model from the Models page."]})]}),s.jsx(Be,{value:c,onChange:y,tabs:i.map(h=>({id:h.id,label:h.label}))}),a&&s.jsx(Se,{code:a.code}),s.jsx("div",{className:"gc-actions",children:s.jsx(S,{onClick:l,children:"Done"})})]})})}const Je="30d";function es({keyId:e}){const[l]=m.useState(()=>Date.now()),o=We(Je,l),c=Ie({queryKey:F.usage({key:e,from:o,groupBy:"day",spark:!0}),queryFn:()=>C.usage.report({key:e,from:o,to:l,groupBy:"day"}),staleTime:6e4});return c.data?s.jsx(Ge,{label:"Daily spend, last 30 days",format:ye,per:"a day",emptyText:"no spend",values:$e(c.data,o,l).map(y=>y.value)}):s.jsx("span",{className:"as-spark as-spark--empty","aria-hidden":"true"})}function ss(e){return e.status==="revoked"?s.jsx(v,{tone:"danger",children:"Revoked"}):e.expiresAt&&e.expiresAt<Date.now()?s.jsx(v,{tone:"warning",children:"Expired"}):e.expiresAt?s.jsxs(v,{tone:"neutral",title:`Expires ${J(e.expiresAt)}`,children:["Until ",J(e.expiresAt)]}):s.jsx(v,{tone:"success",children:"Active"})}function re({title:e,note:l,limits:o,policy:c}){return s.jsxs("div",{className:"gc-layer gc-layer--readonly",children:[s.jsxs("div",{className:"gc-inline gc-inline--between",children:[s.jsx("div",{className:"as-field__label",children:e}),s.jsx(v,{children:"Read only"})]}),s.jsx(Oe,{items:[["Spend limits",ue(o??null)],["Routing",me(c??null)]]}),s.jsx("p",{className:"gc-fineprint",children:l})]})}function oe({title:e,idPrefix:l,limits:o,onLimitsChange:c,limitsNote:y,policy:d}){return s.jsxs("div",{className:"gc-layer",children:[e&&s.jsx("div",{className:"as-field__label",children:e}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits (USD)"}),s.jsx(qe,{idPrefix:l,value:o,onChange:c}),s.jsx("p",{className:"gc-fineprint",children:y})]}),s.jsx(Ye,{draft:d.draft,setDraft:d.setDraft})]})}function ts({initial:e,layeredHint:l,onSaved:o,onCancel:c}){var W;const{workspace:y,viewer:d,me:i}=le(),a=ce(d),r=pe(e)?e:null,[h,k]=m.useState((e==null?void 0:e.label)??""),[b,P]=m.useState(te(e==null?void 0:e.limits)),[L,N]=m.useState(te(r?r.ownerLimits:e==null?void 0:e.limits)),[j,A]=m.useState(ze((e==null?void 0:e.expiresAt)??null)),[x,T]=m.useState((e==null?void 0:e.topupEnabled)??!1),[n,g]=m.useState((e==null?void 0:e.ownerMemberId)??i.member.id),w=se(e==null?void 0:e.routingPolicy),t=se(r?r.ownerRoutingPolicy:e==null?void 0:e.routingPolicy),p=Me(e,{memberId:i.member.id,workspaceAdmin:a},l),ge=Ke(y.id,a),O=((e==null?void 0:e.buyerIdentity)??((W=ge.data)==null?void 0:W.buyerIdentity))==="default",_=de(y.id,a&&!e),R=_e(),[Y,B]=m.useState(null),D=p.admin,q=e?p.owner&&(p.layered||!p.admin):!p.admin,E=e!==null&&p.layered;let z=null;E&&(z=p.admin?"Your restrictions as the key owner":"Your restrictions");const xe=e?"Save":"Create key",be=p.layered||!e?"UTC periods; weeks start Monday. Workspace, member and admin limits apply too.":"You can only tighten your key: a higher or cleared limit is ignored.",I=ie({mutationFn:async()=>{const u=j?Date.parse(`${j}T23:59:59Z`):null,$=D?w.build():null,Q=q?t.build():null,V=ae(b),H=ae(L);if(e){const f=Ue(p,e,{label:h.trim(),expiresAt:u,topupEnabled:x,adminLimits:V,adminPolicy:$,ownerLimits:H,ownerPolicy:Q}),G=await R.save([f.routingPolicy,f.ownerRoutingPolicy],we=>C.keys.update(e.id,f,we));return G===ee?ee:{key:G}}const M={label:h.trim(),workspaceId:y.id,limits:p.admin?V:H,routingPolicy:p.admin?$:Q,topupEnabled:p.admin?x:!1,expiresAt:u};return p.admin&&(M.ownerMemberId=n||null),R.save([M.routingPolicy],f=>C.keys.create(M,f))},onSuccess:o,invalidate:[F.group("keys")],toast:u=>u.secret?null:"Key saved",onError:B});return s.jsxs("form",{className:"gc-stack",onSubmit:u=>{u.preventDefault(),B(null),I.mutate()},children:[s.jsx(U,{label:"Name",required:!0,placeholder:"e.g. Production backend",value:h,onChange:u=>k(u.target.value)}),!e&&a&&_.data&&s.jsx(Xe,{label:"Owner",value:n,onChange:g,options:_.data.map(({member:u})=>({value:u.id,label:u.id===i.member.id?`${u.label} (you)`:u.label}))}),D&&s.jsx(oe,{title:E?"Workspace admin restrictions":null,idPrefix:"key-limit",limits:b,onLimitsChange:P,limitsNote:"UTC periods; weeks start Monday. The workspace and member budgets apply too.",policy:w}),!D&&E&&s.jsx(re,{title:"Set by workspace admins",limits:e.limits,policy:e.routingPolicy,note:"These always apply to this key. Your own restrictions below can only add to them."}),q&&s.jsx(oe,{title:z,idPrefix:"key-owner-limit",limits:L,onLimitsChange:N,limitsNote:be,policy:t}),E&&!p.owner&&s.jsx(re,{title:"Set by the key owner",limits:r==null?void 0:r.ownerLimits,policy:r==null?void 0:r.ownerRoutingPolicy,note:"Only the key's owner changes these. They apply on top of yours."}),s.jsx(U,{label:"Expires",type:"date",value:j,onChange:u=>A(u.target.value),hint:a?"Leave blank for no expiry.":"You can set or bring forward an expiry; only an admin can extend or remove it."}),a&&s.jsx(he,{checked:x,onChange:T,disabled:O&&!x,label:"Allow top-ups",description:O?"Keys paid from the default wallet cannot be topped up.":"Let the key holder add funds to this key with USDC (x402)."}),Y?s.jsx(Fe,{error:Y,title:"Could not save the key"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(S,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(S,{type:"submit",disabled:I.isPending||!h.trim(),children:I.isPending?"Saving…":xe})]}),R.dialog]})}const as=25;function rs({list:e,search:l,showRevoked:o,ownerLabel:c,render:y}){const d=l.trim().toLowerCase(),i=m.useMemo(()=>e.filter(r=>(o||r.status==="active")&&(!d||r.label.toLowerCase().includes(d)||r.hint.toLowerCase().includes(d)||c(r).toLowerCase().includes(d))),[e,o,d,c]),a=Ve(i,as,`${d}|${o}`);return s.jsxs(s.Fragment,{children:[y(a.items,i.length===0&&e.length>0),s.jsx(He,{pager:a,noun:"keys"})]})}function os(e){return(e==null?void 0:e.kind)==="rotate"?{title:"Rotate this key?",confirmLabel:"Rotate key",tone:"primary",body:s.jsxs(s.Fragment,{children:["The current secret for ",s.jsx("strong",{children:e.key.label})," stops working now. You get a new secret to replace it."]})}:{title:"Revoke this key?",confirmLabel:"Revoke key",tone:"danger",body:s.jsxs(s.Fragment,{children:["Requests with ",s.jsx("strong",{children:e==null?void 0:e.key.label})," fail from now on. This cannot be undone."]})}}function js(){const{workspace:e,me:l,viewer:o}=le(),c=Ce(),y=ce(o),d=de(e.id,y),[i,a]=m.useState(()=>new URLSearchParams(window.location.search).get("new")==="1"?"new":null),[r,h]=m.useState(null),[k,b]=m.useState(null),[P,L]=m.useState(!1),[N,j]=m.useState(""),A=Pe(c),x=ie({mutationFn:async({kind:n,key:g})=>{n==="rotate"?h(await C.keys.rotate(g.id)):await C.keys.revoke(g.id)},onSuccess:()=>b(null),invalidate:[F.group("keys")],toast:(n,{kind:g})=>g==="revoke"?"Key revoked":null}),T=n=>{var g,w;return n.ownerMemberId?n.ownerMemberId===l.member.id?"You":((w=(g=d.data)==null?void 0:g.find(({member:t})=>t.id===n.ownerMemberId))==null?void 0:w.member.label)??"Another member":"—"};return s.jsxs("div",{className:"gc-page",children:[s.jsx(Le,{title:"API keys",description:`Keys for the ${e.name} workspace. Each key spends from this workspace's wallet.`,actions:s.jsx(S,{variant:"brand",leadingIcon:s.jsx(K.plus,{size:14}),onClick:()=>a("new"),children:"Create key"})}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(U,{size:"sm",type:"search","aria-label":"Search keys",placeholder:"Search name, hint or owner",value:N,onChange:n=>j(n.target.value)}),s.jsx(he,{checked:P,onChange:L,label:"Show revoked"})]}),s.jsx(Ne,{flush:!0,children:s.jsx(Ae,{query:A,children:n=>s.jsx(rs,{list:n,search:N,showRevoked:P,ownerLabel:T,render:(g,w)=>s.jsx(Qe,{label:"API keys",rows:g,rowKey:t=>t.id,rowLabel:t=>t.label,onRowClick:t=>t.status==="active"&&a(t),actions:t=>t.status==="active"?[{label:"Edit",onSelect:()=>a(t)},{label:"Rotate secret",onSelect:()=>b({kind:"rotate",key:t})},{label:"Revoke",tone:"danger",onSelect:()=>b({kind:"revoke",key:t})}]:[],empty:w?s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys match",body:"Try another search, or show revoked keys."}):s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys yet",body:"Create a key to call models through this gateway.",action:s.jsx(S,{onClick:()=>a("new"),children:"Create key"})}),columns:[{key:"label",header:"Name",sortValue:t=>t.label,render:t=>s.jsx(Te,{name:t.label,hint:t.hint})},{key:"owner",header:"Owner",secondary:!0,render:T},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:ue(X(t).limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:me(X(t).policy)})},...y?[{key:"trend",header:"30 days",secondary:!0,render:t=>s.jsx(es,{keyId:t.id})}]:[],{key:"month",header:"This month",align:"right",sortValue:t=>Ee(t.usage.spentThisMonth),render:t=>ye(t.usage.spentThisMonth)},{key:"used",header:"Last used",secondary:!0,optional:!0,sortValue:t=>t.lastUsedAt,render:t=>Re(t.lastUsedAt)},{key:"status",header:"Status",secondary:!0,render:ss}]})})})}),s.jsx(ne,{isOpen:i!==null,onClose:()=>a(null),size:"lg",title:i==="new"?"Create API key":"Edit API key",children:i!==null&&s.jsx(ts,{initial:i==="new"?null:i,layeredHint:(A.data??[]).some(pe),onCancel:()=>a(null),onSaved:n=>{a(null),n.secret&&h({key:n.key,secret:n.secret})}})}),s.jsx(Ze,{result:r,onClose:()=>h(null)}),s.jsx(De,{isOpen:k!==null,busy:x.isPending,error:x.error,onClose:()=>{b(null),x.reset()},onConfirm:()=>k&&x.mutate(k),...os(k)})]})}export{js as default};
@@ -1 +0,0 @@
1
- import{u as K,n as V,r as d,d as ce,U as G,t as N,j as e,P as de,B as f,I as q,l as H,Q,aU as _,z as me,A as ue,E as ae,C as B,D as T,f as w,G as ge,q as P,an as be,v as D,ab as se,aV as ne,aW as he,aa as J,T as I,af as X,o as ie,aM as pe,av as ve}from"./index-DPXW_JSn.js";import{u as xe,a as je,P as ye}from"./PolicyField-ldIq_Yw-.js";import{l as ke,d as fe,L as we}from"./limits-uCwhqY-O.js";import{D as Y}from"./DataTable-BCgVRqY6.js";import{S as M}from"./SelectField-m1sMIgMa.js";import"./PolicyEditor-COREmE0O.js";import"./PeerPicker-CcMSXxY3.js";import"./Segmented-DYnoemT9.js";import"./roving-DkptacxO.js";import"./Switch-Db8Sm64J.js";import"./Disclosure-CQMtWM0M.js";const z=(s,t)=>!!s&&!!t&&s.trim().toLowerCase()===t.trim().toLowerCase();function Ce(s,t,o){const n=[],m=Date.now();for(const i of t)z(i.email,s.email)?n.push(`${i.label} already uses ${i.email}.`):z(i.label,s.label)&&n.push(`A member named ${i.label} already exists${i.status==="invited"?" (invited, not joined yet)":""}.`);for(const i of o)i.expiresAt<m||(z(i.email,s.email)?n.push(`A pending invite already goes to ${i.email}.`):z(i.label,s.label)&&n.push(`A pending invite for ${i.label} already exists.`));return[...new Set(n)]}const F=[P.group("members"),P.group("workspaces"),P.group("keys")],W=[...F,P.group("invites")],te=[{value:"member",label:"Member"},{value:"admin",label:"Admin"}];function U(s){return s.status==="disabled"?e.jsx(D,{tone:"danger",children:"Disabled"}):s.status==="invited"?e.jsx(D,{tone:"warning",children:"Invited"}):e.jsx(D,{tone:"success",children:"Active"})}function le(s,t){return s==="owner"?["member","admin","owner"]:t?["member","admin"]:["member"]}function re(s){return s.map(t=>({value:t,label:_[t]}))}function Se({onCreated:s,onCancel:t}){const{me:o,viewer:n,workspace:m}=K(),i=V(n),C=o.workspaces.filter(a=>i||a.role==="admin").map(a=>a.workspace),[c,u]=d.useState(""),[g,p]=d.useState(""),[v,R]=d.useState("member"),[j,E]=d.useState("72"),[y,b]=d.useState({[m.id]:"member"}),S=G(i),L=ne(),x=Ce({label:c,email:g},S.data??[],L.data??[]),h=N({mutationFn:()=>{const a={label:c.trim(),email:g.trim()||null,orgRole:v,workspaces:Object.entries(y).filter(([,k])=>k).map(([k,O])=>({workspaceId:k,role:O})),expiresInHours:Number(j)||72};return w.invites.create(a)},onSuccess:s,invalidate:W}),l=x.length?"Create anyway":"Create invite link";return e.jsxs("form",{className:"gc-stack",onSubmit:a=>{a.preventDefault(),h.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",required:!0,value:c,onChange:a=>u(a.target.value)}),e.jsx(I,{label:"Email (optional)",type:"email",value:g,onChange:a=>p(a.target.value),hint:"Required when they will sign in with your identity provider."})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(M,{label:"Organization role",value:v,onChange:a=>R(a),options:re(le(o.member.orgRole,i)),hint:v==="member"?"Sees only the workspaces below.":"Can manage every workspace."}),e.jsx(M,{label:"Link expires after",value:j,onChange:E,options:[{value:"24",label:"1 day"},{value:"72",label:"3 days"},{value:"168",label:"7 days"}]})]}),e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:"Workspaces"}),C.map(a=>e.jsxs("div",{className:"gc-inline gc-inline--between",children:[e.jsx("span",{children:a.name}),e.jsx(M,{"aria-label":`Role in ${a.name}`,value:y[a.id]??"",onChange:k=>b({...y,[a.id]:k}),options:[{value:"",label:"No access"},...te]})]},a.id))]}),x.length>0&&e.jsx(X,{tone:"warning",title:"Possible duplicate",children:e.jsx("ul",{className:"gc-list",children:x.map(a=>e.jsx("li",{children:a},a))})}),h.error?e.jsx(ie,{error:h.error,title:"Could not create the invite"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(f,{type:"submit",disabled:h.isPending||!c.trim(),children:h.isPending?"Creating…":l})]})]})}function Ne({member:s,onDone:t}){const{me:o,viewer:n}=K(),m=V(n),[i,C]=d.useState(s.label),[c,u]=d.useState(s.email??""),[g,p]=d.useState(s.orgRole),[v,R]=d.useState(ke(s.limits)),[j,E]=d.useState(s.maxKeys===null?"":String(s.maxKeys)),y=xe(s.routingPolicy),[b,S]=d.useState(null),[L,x]=d.useState(!1),h=je(),l=N({mutationFn:async()=>{const r=j.trim()===""?null:Number(j);if(r!==null&&(!Number.isInteger(r)||r<0))throw new Error("Key limit must be a whole number.");const ee={label:i.trim(),email:c.trim()||null,limits:fe(v),maxKeys:r,routingPolicy:y.build(),...m?{orgRole:g}:{}};return h.save([ee.routingPolicy],oe=>w.members.update(s.id,ee,oe))},onSuccess:t,invalidate:F,toast:"Member saved"}),a=N({mutationFn:()=>s.status==="disabled"?w.members.enable(s.id):w.members.disable(s.id),onSuccess:()=>{x(!1),t()},invalidate:F}),k=N({mutationFn:r=>w.members.removeCredential(s.id,r),onSuccess:()=>{S(null),t()},invalidate:F}),O=s.id===o.member.id,A=s.status==="disabled",$=m&&(s.orgRole!=="owner"||o.member.orgRole==="owner"),Z=O&&s.credentials.length<=1;return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),l.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",value:i,onChange:r=>C(r.target.value)}),e.jsx(I,{label:"Email",type:"email",value:c,onChange:r=>u(r.target.value)})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[m&&e.jsx(M,{label:"Organization role",value:g,disabled:O||s.orgRole==="owner"&&o.member.orgRole!=="owner",onChange:r=>p(r),options:re(le(o.member.orgRole,!0))}),e.jsx(I,{label:"Keys they may create",inputMode:"numeric",placeholder:"No limit",value:j,onChange:r=>E(r.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits across their keys (USD)"}),e.jsx(we,{idPrefix:"member-limit",value:v,onChange:R})]}),e.jsx(ye,{draft:y.draft,setDraft:y.setDraft}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Sign-in methods"}),s.credentials.length===0?e.jsx("p",{className:"gc-muted",children:"None yet."}):e.jsx("ul",{className:"gc-list",children:s.credentials.map(r=>e.jsxs("li",{className:"gc-inline gc-inline--between",children:[e.jsxs("span",{children:[e.jsx(D,{children:r.kind})," ",r.label," ",e.jsxs("span",{className:"gc-muted",children:["· last used ",J(r.lastUsedAt)]})]}),$&&e.jsx(f,{variant:"ghost",size:"sm",disabled:Z,title:Z?"Add another sign-in method first":void 0,onClick:()=>S(r),children:"Remove"})]},r.id))})]}),!$&&e.jsx(X,{tone:"info",children:"Only an owner can change an owner's profile, status or sign-in methods."}),l.error?e.jsx(ie,{error:l.error,title:"Could not save"}):null,e.jsxs("div",{className:"gc-actions gc-actions--split",children:[$&&!O?e.jsx(f,{variant:A?"outline":"danger",size:"sm",onClick:()=>x(!0),children:A?"Enable member":"Disable member"}):e.jsx("span",{}),e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),$&&e.jsx(f,{type:"submit",disabled:l.isPending,children:l.isPending?"Saving…":"Save"})]})]}),e.jsx(T,{isOpen:L,busy:a.isPending,error:a.error,onClose:()=>x(!1),onConfirm:()=>a.mutate(),title:A?"Enable this member?":"Disable this member?",tone:A?"primary":"danger",confirmLabel:A?"Enable":"Disable",body:A?`${s.label} can sign in again. Their revoked keys stay revoked.`:`${s.label} is signed out and all of their keys are revoked.`}),e.jsx(T,{isOpen:b!==null,busy:k.isPending,error:k.error,onClose:()=>S(null),onConfirm:()=>b&&k.mutate(b.id),title:"Remove this sign-in method?",confirmLabel:"Remove",body:`${(b==null?void 0:b.label)??""} can no longer be used to sign in as ${s.label}.`}),h.dialog]})}function Re({member:s,role:t}){const{workspace:o,me:n}=K(),m=ge(),i=N({mutationFn:c=>w.workspaces.setMember(o.id,s.id,c),invalidate:s.id===n.member.id?[P.workspaceMembers(o.id),P.me]:[P.workspaceMembers(o.id)],toast:(c,u)=>`${s.label} is now a workspace ${u}`,onError:c=>m(`Could not change ${s.label}'s role: ${be(c)}`,"danger")}),C=s.orgRole!=="member";return e.jsx("div",{onClick:c=>c.stopPropagation(),children:e.jsx(M,{size:"sm","aria-label":`Workspace role for ${s.label}`,value:t,disabled:i.isPending||C,title:C?"Organization admins administer every workspace":void 0,onChange:c=>i.mutate(c),options:te})})}function Pe({onEdit:s}){const t=G();return e.jsx(H,{flush:!0,title:"Everyone in the organization",children:e.jsx(Q,{query:t,children:o=>e.jsx(Y,{label:"All members",rows:o,rowKey:n=>n.id,onRowClick:s,rowLabel:n=>n.label,actions:n=>[{label:"Edit member",onSelect:()=>s(n)}],columns:[{key:"name",header:"Name",sortValue:n=>n.label,render:n=>e.jsxs("span",{className:"gc-strong",children:[n.label,n.status!=="active"&&e.jsxs("span",{className:"gc-narrow-only",children:[" ",U(n)]})]})},{key:"email",header:"Email",secondary:!0,render:n=>n.email??"—"},{key:"role",header:"Role",render:n=>_[n.orgRole]},{key:"keys",header:"Key limit",secondary:!0,optional:!0,render:n=>n.maxKeys??"No limit"},{key:"since",header:"Joined",secondary:!0,sortValue:n=>n.createdAt,render:n=>n.status==="invited"?e.jsxs("span",{className:"gc-muted",children:["Invited ",se(n.createdAt)]}):se(n.createdAt)},{key:"status",header:"Status",secondary:!0,render:U}]})})})}function Ee(){const s=ne(),[t,o]=d.useState(null),n=N({mutationFn:m=>w.invites.revoke(m.id),onSuccess:()=>o(null),invalidate:W});return e.jsxs(H,{flush:!0,title:"Pending invites",children:[e.jsx(Q,{query:s,children:m=>e.jsx(Y,{label:"Pending invites",rows:m,rowKey:i=>i.id,rowLabel:i=>`invite for ${i.label}`,empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No pending invites"}),actions:i=>[{label:"Revoke invite",tone:"danger",onSelect:()=>o(i)}],columns:[{key:"name",header:"Name",render:i=>e.jsx("span",{className:"gc-strong",children:i.label})},{key:"email",header:"Email",secondary:!0,render:i=>i.email??"—"},{key:"role",header:"Role",render:i=>_[i.orgRole]},{key:"expires",header:"Expires",secondary:!0,render:i=>e.jsx(he,{at:i.expiresAt,format:J})}]})}),e.jsx(T,{isOpen:t!==null,busy:n.isPending,error:n.error,onClose:()=>o(null),onConfirm:()=>t&&n.mutate(t),title:"Revoke this invite?",confirmLabel:"Revoke",body:"The link stops working."})]})}function Ae({invite:s,onClose:t}){return e.jsx(B,{isOpen:s!==null,onClose:t,title:"Invite link",size:"lg",children:s&&e.jsxs("div",{className:"gc-stack",children:[s.url?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Send this link to ",e.jsx("strong",{children:s.label}),". It works once and expires ",J(s.expiresAt),"."]}),e.jsx(pe,{secret:s.url,note:"This link is shown only once. Anyone with it can join as this member."})]}):e.jsx(X,{tone:"warning",children:"The gateway did not return a link for this invite."}),e.jsxs("div",{className:"gc-actions",children:[s.url&&e.jsx(ve,{value:s.url,label:"Copy link",size:"md"}),e.jsx(f,{onClick:t,children:"Done"})]})]})})}function _e(){var h;const{viewer:s,workspace:t,me:o}=K(),n=V(s),[m,i]=d.useState(!1),[C,c]=d.useState(null),[u,g]=d.useState(null),[p,v]=d.useState(null),[R,j]=d.useState(""),E=ce(t.id),y=G(n),b=N({mutationFn:l=>w.workspaces.removeMember(t.id,l.id),onSuccess:()=>v(null),invalidate:W,toast:"Removed from workspace"}),S=N({mutationFn:l=>w.workspaces.setMember(t.id,l,"member"),onSuccess:()=>j(""),invalidate:W,toast:"Added to workspace"}),L=new Set((h=E.data)==null?void 0:h.map(({member:l})=>l.id)),x=(y.data??[]).filter(l=>!L.has(l.id)&&l.status==="active");return e.jsxs("div",{className:"gc-page",children:[e.jsx(de,{title:"Members",description:"Who can use this gateway, their budgets and routing.",actions:e.jsx(f,{variant:"brand",leadingIcon:e.jsx(q.plus,{size:14}),onClick:()=>i(!0),children:"Invite member"})}),e.jsx(H,{flush:!0,title:`${t.name} workspace`,actions:n&&x.length>0?e.jsxs("div",{className:"gc-inline",children:[e.jsx(M,{size:"sm","aria-label":"Add an existing member",value:R,onChange:j,options:[{value:"",label:"Add existing member…"},...x.map(l=>({value:l.id,label:l.label}))]}),e.jsx(f,{size:"sm",variant:"outline",disabled:!R||S.isPending,onClick:()=>S.mutate(R),children:"Add"})]}):void 0,children:e.jsx(Q,{query:E,children:l=>e.jsx(Y,{label:"Workspace members",rows:l,rowKey:a=>a.member.id,onRowClick:n?a=>g(a.member):void 0,rowLabel:a=>a.member.label,actions:a=>[n&&{label:"Edit member",onSelect:()=>g(a.member)},a.member.id!==o.member.id&&{label:"Remove from workspace",tone:"danger",onSelect:()=>v(a.member)}],empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No members in this workspace"}),columns:[{key:"name",header:"Name",sortValue:a=>a.member.label,render:a=>e.jsxs("div",{children:[e.jsx("div",{className:"gc-strong",children:a.member.label}),e.jsx("div",{className:"gc-muted",children:a.member.email??_[a.member.orgRole]})]})},{key:"role",header:"Workspace role",render:a=>e.jsx(Re,{member:a.member,role:a.role})},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:me(a.member.limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:ue(a.member.routingPolicy)})},{key:"status",header:"Status",secondary:!0,render:a=>U(a.member)}]})})}),n&&e.jsx(Pe,{onEdit:g}),e.jsx(Ee,{}),e.jsx(B,{isOpen:m,onClose:()=>i(!1),size:"lg",title:"Invite a member",children:m&&e.jsx(Se,{onCancel:()=>i(!1),onCreated:l=>{i(!1),c(l)}})}),e.jsx(Ae,{invite:C,onClose:()=>c(null)}),e.jsx(B,{isOpen:u!==null,onClose:()=>g(null),size:"lg",title:(u==null?void 0:u.label)??"",eyebrow:"Member",children:u&&e.jsx(Ne,{member:u,onDone:()=>g(null)},u.id)}),e.jsx(T,{isOpen:p!==null,busy:b.isPending,error:b.error,onClose:()=>v(null),onConfirm:()=>p&&b.mutate(p),title:"Remove from workspace?",confirmLabel:"Remove",body:`${(p==null?void 0:p.label)??""} loses access to ${t.name}. Their keys in this workspace stop working.`})]})}export{_e as default};
@@ -1 +0,0 @@
1
- import{aZ as M,r as y,j as e,a_ as A,Y as w,a$ as B,O as T,b0 as P,b1 as F,M as m,av as v,v as p,X as E,b2 as I,B as R,ad as _,ae as $,b3 as O,w as C,k as U}from"./index-DPXW_JSn.js";import{M as f,C as Y,P as S,a as D,p as V}from"./SidePanel-BFQArkoa.js";import{T as z,a as K}from"./Tabs-CCabxVNK.js";import{S as q}from"./stored-e0tX90bC.js";import{T as k,V as G}from"./VerificationLinks-CWyl6ZEp.js";import{S as X}from"./SelectField-m1sMIgMa.js";function Z({model:s,format:o,id:h="gc-api-call",unsupported:n}){const x=M(),[j,t]=y.useState("curl");if(!o)return e.jsx("p",{className:"gc-fineprint",children:n??"The gateway does not serve this model through its API."});const d=A(x,s,o),i=d.find(r=>r.id===j)??d[0];return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx(z,{id:h,label:"Request examples",value:i.id,onChange:t,className:"gc-connect-tabs",tabs:d.map(r=>({id:r.id,label:r.label}))}),e.jsx(K,{tabsId:h,tab:i.id,children:e.jsx(w,{code:i.code,label:i.label})}),e.jsxs("p",{className:"gc-fineprint",children:["Set ",e.jsx("code",{children:B})," to one of your API keys first. ",e.jsx(T,{to:"keys",children:"API keys"})]})]})}function H(s){return s===null?"—":String(Math.round(s))}function J(s){return s===null?"—":U(s)}function Q(s){return s.fullTeeSellers>0?"end-to-end":s.offers.some(o=>o.teeScope==="seller-node")?"seller-node":null}function g(s){return s.displayName??C(s.peerId,8,4)}function c(s){return`${s.peerId}:${s.serviceId}`}function ie({model:s,preview:o,previewLoading:h,pin:n}){const[x,j]=y.useState(""),t=n?s.offers.find(a=>a.peerId.toLowerCase()===n.peerId)??null:s.offers.find(a=>c(a)===x)??null,d=t?c(t):"",i=a=>{if(!n)return j(a);const u=s.offers.find(l=>c(l)===a);n.onChange(u?u.peerId.toLowerCase():null)},r=t?P(t.peerId,t.serviceId):s.id,N=F(s.type,t),L=s.offers.some(a=>a.usdPerImage!==null);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsxs("span",{className:"gc-seller__meta",children:[e.jsxs("span",{className:"gc-peer-id",children:[e.jsx(m,{title:s.id,children:s.id}),e.jsx(v,{iconOnly:!0,value:s.id,label:"Copy model id"})]}),e.jsx(p,{children:f[s.type]}),s.free&&e.jsx(p,{tone:"success",children:"Free"}),e.jsx(k,{tee:s.teeSellers>0,scope:Q(s)})]}),e.jsx(E,{items:[["Context",J(s.contextLength)],["Capabilities",s.capabilities.length?e.jsx("span",{className:"gc-badges",children:s.capabilities.map(a=>e.jsx(p,{children:Y[a]},a))}):"—"],["Tags",s.tags.length?e.jsx("span",{className:"gc-badges",children:s.tags.map(a=>e.jsx(p,{children:a},a))}):"—"],["Aliases",s.aliases.length?e.jsx(m,{children:s.aliases.join(", ")}):"—"],...L?[]:[["Input $/M",I(s.inputUsdPerMillion)],["Output $/M",I(s.outputUsdPerMillion)]]]})]}),e.jsx(q,{preview:o,loading:h,pin:n}),e.jsx(S,{title:`Providers (${s.offers.length})`,children:s.offers.length===0?e.jsx("p",{className:"gc-fineprint",children:"No provider offers this model right now."}):e.jsx("ul",{className:"gc-panel-rows","aria-label":"Providers offering this model",children:s.offers.map(a=>{var b;const u=P(a.peerId,a.serviceId),l=d===c(a);return e.jsx(D,{selected:l,title:e.jsx(T,{to:O("providers",a.peerId),children:g(a)}),meta:e.jsxs(e.Fragment,{children:[e.jsx("span",{children:V(a)}),e.jsxs("span",{children:["Trust ",H(a.trustScore)]}),a.firstTokenMsP50!==null&&e.jsxs("span",{children:[_(a.firstTokenMsP50)," first token"]}),a.tokensPerSecondP50!==null&&e.jsx("span",{children:$(a.tokensPerSecondP50)}),a.serviceId!==s.id&&e.jsx(m,{children:a.serviceId})]}),badges:(((b=a.verificationLinks)==null?void 0:b.length)||a.tee||a.free)&&e.jsxs("div",{className:"gc-badges",children:[e.jsx(G,{links:a.verificationLinks}),e.jsx(k,{tee:a.tee,scope:a.teeScope}),a.free&&e.jsx(p,{tone:"success",children:"Free"})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(v,{iconOnly:!0,value:u,label:`Copy ${g(a)}'s model id (peer@model)`}),e.jsx(R,{size:"sm",variant:l?"outline":"ghost","aria-pressed":l,title:n?"Send this chat to this provider":"Use this provider in the API call below",onClick:()=>i(l?"":c(a)),children:l?"Pinned":"Pin"})]})},c(a))})})}),e.jsxs(S,{title:"API call",actions:s.offers.length>0&&e.jsx(X,{size:"sm","aria-label":"Route the call",value:d,onChange:i,options:[{value:"",label:"Best provider (automatic)"},...s.offers.map(a=>({value:c(a),label:g(a)}))]}),children:[e.jsx("p",{className:"gc-fineprint",children:t?e.jsxs(e.Fragment,{children:["Pinned to ",g(t)," with ",e.jsx("code",{children:C(r,10,12)}),"."]}):e.jsxs(e.Fragment,{children:["The gateway picks the best provider for ",e.jsx("code",{children:s.id})," under your routing policy."]})}),e.jsx(Z,{id:"gc-model-call",model:r,format:N,unsupported:`${f[s.type]} models are not served through the gateway's /v1 API.`})]})]})}export{Z as A,ie as M,J as c,Q as m,H as s};
@@ -1 +0,0 @@
1
- import{j as s,aj as ce,I as k,R as de,br as ue,bc as me,bs as pe,bd as he,bt as ge,r as b,bu as fe,L as xe,E as z,l as O,Q as je,B as V,P as ke,T as ve,y as U,bv as ye,M as j,h as be,g as W,b2 as D,b3 as J,w as X,av as we,v as f,X as Y,O as Se,Y as Le,u as Ce,e as Ne,q as Pe,ah as Me,f as Te}from"./index-DPXW_JSn.js";import{c as Fe,s as Ee,A as Ie,M as Ae,m as Be}from"./ModelDetails-Sgq3MjfG.js";import{V as _e,T as Re}from"./VerificationLinks-CWyl6ZEp.js";import{M as $e,f as qe,S as ze,P as M}from"./SidePanel-BFQArkoa.js";import{s as Oe,l as Ve}from"./stored-e0tX90bC.js";import{r as Ue,B as Z}from"./BrandIcon-6gq42Dg-.js";import{D as De}from"./DataTable-BCgVRqY6.js";import"./Tabs-CCabxVNK.js";import"./roving-DkptacxO.js";import"./SelectField-m1sMIgMa.js";import"./selection-BV37SUs_.js";import"./Disclosure-CQMtWM0M.js";const Ye={anthropic:"Anthropic",openai:"OpenAI",codex:"OpenAI",gemini:"Google",kimi:"Moonshot",glm:"Z.ai",deepseek:"DeepSeek",qwen:"Qwen",grok:"xAI",mistral:"Mistral",minimax:"MiniMax",llama:"Meta"};function K(e){return Ye[Ue(e.provider,e.label)]??null}function Q({label:e,values:t,options:i,onChange:c,width:d=240}){const n=new Set(t),o=l=>c(n.has(l)?t.filter(h=>h!==l):[...t,l]);return s.jsx(ce,{label:`Filter by ${e.toLowerCase()}`,multiple:!0,align:"start",width:d,triggerStyle:"plain",className:"as-button as-button--outline as-button--sm gc-filter-menu",trigger:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:e}),t.length>0&&s.jsx("span",{className:"gc-filter-menu__count",children:t.length}),s.jsx(k.down,{size:14})]}),items:[...i.map(l=>({label:l.label,checked:n.has(l.value),...l.icon?{icon:l.icon}:{},...l.section?{section:l.section}:{},onSelect:()=>o(l.value)})),t.length>0&&{label:"Clear",section:" ",onSelect:()=>c([])}]})}const F={search:"",types:[],tags:[],families:[],free:!1,tee:!1},E={...$e,router:"Router"},Ke=["text","image","video","decision","router"];function Qe(e,t){return[...e.map(i=>({kind:"model",key:i.id,model:i})),...t.map(i=>({kind:"router",key:i.id,router:i}))]}function S(e){return e.kind==="router"?"router":e.model.type}function w(e){return e.kind==="router"?e.router.name:e.model.name}function ee(e){return e.kind==="router"?[]:e.model.tags}function Ge(e){return e.kind==="router"?e.router.free:e.model.free}function He(e){return e.kind==="model"&&e.model.teeSellers>0}function I(e){var t;return e.kind==="router"?null:{provider:((t=e.model.offers[0])==null?void 0:t.provider)??"",label:`${e.model.name} ${e.model.id}`}}function We(e){if(e.kind==="router"){const{router:i}=e;return[i.name,i.id,i.serviceId,i.provider,i.sellerName??"",i.protocol,"router routing"].join(" ").toLowerCase()}const{model:t}=e;return[t.id,t.name,...t.aliases,...t.tags,...t.offers.map(i=>i.provider),E[t.type]].join(" ").toLowerCase()}function Je(e,t){const i=new Set(e.map(S)),c=new Set(e.flatMap(ee)),d=new Set(e.flatMap(n=>{const o=I(n),l=o?t(o):null;return l?[l]:[]}));return{types:Ke.filter(n=>i.has(n)),tags:[...c].sort((n,o)=>n.localeCompare(o)),families:[...d].sort((n,o)=>n.localeCompare(o))}}function Xe(e,t,i){const c=t.search.trim().toLowerCase(),d=new Set(t.types),n=new Set(t.families);return e.filter(o=>{if(d.size>0&&!d.has(S(o))||t.free&&!Ge(o)||t.tee&&!He(o))return!1;if(t.tags.length>0){const l=new Set(ee(o));if(!t.tags.every(h=>l.has(h)))return!1}if(n.size>0){const l=I(o),h=l?i(l):null;if(!h||!n.has(h))return!1}return!c||We(o).includes(c)})}function Ze(e){return!!(e.search.trim()||e.types.length||e.tags.length||e.families.length||e.free||e.tee)}function es(e,t){return t.flatMap(i=>{const c=i.toLowerCase(),d=e.find(n=>n.key.toLowerCase()===c)??e.find(n=>n.kind==="model"&&n.model.aliases.some(o=>o.toLowerCase()===c));return d?[d]:[]})}function G(e){return e.kind==="router"?1:e.model.sellers}function ss(e){var t;return e.kind==="router"?e.router.priceUsdPerRequest:((t=e.model.inputUsdPerMillion)==null?void 0:t.min)??null}const se="antseed-console-models:filter",T="Favorites";function te(e){return e.sellerName??X(e.peerId,8,4)}function ts(e){return e.priceUsdPerRequest===null?"No price advertised":e.free?"Free":`${W(e.priceUsdPerRequest)} per ranking`}function as(){const e=Ve(se,{});return{...F,...e,search:""}}function is({entry:e}){const t=I(e);return s.jsx("span",{className:"gc-model-name__mark","aria-hidden":"true",children:t?s.jsx(Z,{name:t.provider,hints:[t.label],size:18}):s.jsx(k.routing,{size:16})})}function ns({entry:e}){if(e.kind==="router")return s.jsxs("div",{className:"gc-badges",children:[s.jsx(f,{children:"Router"}),e.router.free&&s.jsx(f,{tone:"success",children:"Free"})]});const{model:t}=e;return s.jsxs("div",{className:"gc-badges",children:[t.free&&s.jsx(f,{tone:"success",children:"Free"}),s.jsx(Re,{tee:t.teeSellers>0,scope:Be(t)}),t.tags.slice(0,3).map(i=>s.jsx(f,{children:i},i))]})}function H({id:e,name:t,starred:i,onToggle:c}){return s.jsx(Me,{size:"sm",className:"gc-star",label:i?`Unstar ${t}`:`Star ${t}`,"aria-pressed":i,onClick:d=>{d.stopPropagation(),c(e,!i)},children:i?s.jsx(k.starFilled,{size:15}):s.jsx(k.star,{size:15})})}function ys(){const e=de(),t=ue(e.rest),i=me(),c=pe(),d=he(),n=ge(),[o,l]=b.useState(as),h=fe();b.useEffect(()=>{Oe(se,{...o,search:""})},[o]);const A=(r,g)=>l(p=>({...p,[r]:g})),x=b.useMemo(()=>Qe(i.data??[],c.data??[]),[i.data,c.data]),L=b.useMemo(()=>Je(x,K),[x]),B=b.useMemo(()=>new Set((d.data??[]).map(r=>r.toLowerCase())),[d.data]),C=r=>B.has(r.key.toLowerCase()),N=(r,g)=>n.mutate({id:r,favorite:g}),u=t?(c.data??[]).find(r=>r.id.toLowerCase()===t.toLowerCase())??null:null,m=t&&!u?qe(i.data,t):null,v=(u==null?void 0:u.id)??(m==null?void 0:m.id)??null,ae=t===null?null:{eyebrow:u?"Router":"Model",title:(u==null?void 0:u.name)??(m==null?void 0:m.name)??t,actions:v?s.jsx(H,{id:v,name:(u==null?void 0:u.name)??(m==null?void 0:m.name)??v,starred:B.has(v.toLowerCase()),onToggle:N}):void 0,body:i.isLoading||c.isLoading?s.jsx(xe,{rows:6}):u?s.jsx(ls,{router:u},u.id):m?s.jsx(rs,{model:m},m.id):s.jsx(z,{icon:s.jsx(k.models,{size:18}),title:"Model not found",body:`No provider on the network offers ${t} right now.`})},P=Ze(o),_=Xe(x,o,K),y=P?[]:es(x,d.data??[]),ie=y.length?_.filter(r=>!y.includes(r)):_,ne=[...L.types.map(r=>({value:`type:${r}`,label:E[r],section:"Type"})),{value:"free",label:"Free",section:"Price and privacy"},{value:"tee",label:"TEE",section:"Price and privacy"},...L.tags.map(r=>({value:`tag:${r}`,label:r,section:"Tags"}))],re=[...o.types.map(r=>`type:${r}`),...o.free?["free"]:[],...o.tee?["tee"]:[],...o.tags.map(r=>`tag:${r}`)],oe=r=>l(g=>({...g,types:r.filter(p=>p.startsWith("type:")).map(p=>p.slice(5)),tags:r.filter(p=>p.startsWith("tag:")).map(p=>p.slice(4)),free:r.includes("free"),tee:r.includes("tee")})),R=L.families.map(r=>({value:r,label:r,icon:s.jsx(Z,{name:r,hints:[r],size:16})})),$=(r,g,p)=>s.jsx(De,{label:r,rows:g,rowKey:a=>a.key,selectedKey:v,onRowClick:a=>U(J("models",a.key)),rowLabel:w,actions:a=>[{label:a.kind==="router"?"Copy router model id":"Copy model id",onSelect:()=>void h(a.key)},{label:C(a)?"Unstar":"Star",onSelect:()=>N(a.key,!C(a))}],initialSort:r===T?void 0:{key:"sellers",direction:"desc"},empty:p,columns:[{key:"model",header:"Model",sortValue:a=>w(a).toLowerCase(),render:a=>s.jsxs("div",{className:"gc-model-name",children:[s.jsx(is,{entry:a}),s.jsxs("div",{className:"gc-cell-lines",children:[s.jsx("div",{className:"gc-strong gc-ellipsis",title:a.key,children:w(a)}),a.kind==="router"?s.jsxs("div",{className:"gc-muted gc-ellipsis",children:["by ",te(a.router)," · ",s.jsx(j,{children:a.router.serviceId})]}):a.model.name!==a.model.id&&s.jsx("div",{className:"gc-muted gc-ellipsis",children:s.jsx(j,{children:a.model.id})}),s.jsx(ns,{entry:a})]})]}),after:a=>s.jsxs(s.Fragment,{children:[s.jsx(H,{id:a.key,name:w(a),starred:C(a),onToggle:N}),s.jsx(ye,{value:a.key,label:`Copy model id ${a.key}`})]})},{key:"type",header:"Type",secondary:!0,sortValue:S,render:a=>s.jsx("span",{className:"gc-muted",children:E[S(a)]})},{key:"sellers",header:"Providers",align:"right",sortValue:G,render:a=>be(G(a))},{key:"input",header:"Input $/M",align:"right",sortValue:ss,render:a=>a.kind==="router"?s.jsx("span",{className:"gc-muted",children:a.router.free?"Free":a.router.priceUsdPerRequest===null?"—":`${W(a.router.priceUsdPerRequest)}/ranking`}):D(a.model.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:a=>{var q;return a.kind==="model"?((q=a.model.outputUsdPerMillion)==null?void 0:q.min)??null:null},render:a=>a.kind==="model"?D(a.model.outputUsdPerMillion):"—"},{key:"context",header:"Context",align:"right",secondary:!0,optional:!0,sortValue:a=>a.kind==="model"?a.model.contextLength:null,render:a=>a.kind==="model"?Fe(a.model.contextLength):"—"}]}),le=s.jsxs("div",{className:"gc-stack",children:[y.length>0&&s.jsx(O,{flush:!0,title:T,children:$(T,y,null)}),s.jsx(O,{flush:!0,title:y.length>0?"All models":void 0,children:s.jsx(je,{query:i,rows:8,children:()=>$("Models",ie,s.jsx(z,{icon:s.jsx(k.models,{size:18}),title:x.length?"No models match these filters":"No models found yet",body:x.length?void 0:"The buyer is still discovering the network. Check back in a minute.",action:P?s.jsx(V,{variant:"outline",size:"sm",onClick:()=>l(F),children:"Clear filters"}):void 0}))})})]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(ke,{title:"Models",description:"Every model and router on the network. Star the ones you use; open one to see its providers, copy its id and get a ready-to-run API call."}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(ve,{size:"sm",type:"search","aria-label":"Search models or routers",placeholder:"Search models or routers",value:o.search,onChange:r=>A("search",r.target.value)}),s.jsx(Q,{label:"Type",values:re,options:ne,onChange:oe}),R.length>0&&s.jsx(Q,{label:"Family",values:o.families,options:R,onChange:r=>A("families",r)}),P&&s.jsx(V,{variant:"ghost",size:"sm",onClick:()=>l(F),children:"Clear filters"})]}),s.jsx(ze,{list:le,panel:ae,onClose:()=>U("models"),closeLabel:"Close model"})]})}function rs({model:e}){const{workspace:t}=Ce(),i=Ne({queryKey:Pe.routePreview({model:e.id,workspace:t.id}),queryFn:()=>Te.network.routePreview({model:e.id,workspace:t.id}),staleTime:3e4});return s.jsx(Ae,{model:e,preview:i.data,previewLoading:i.isLoading})}function os(e){return e.default===void 0?"—":String(e.default)}function ls({router:e}){var d;const t=((d=e.models)==null?void 0:d.includes("*"))??!1,i=(e.models??[]).filter(n=>n!=="*"),c=e.options.some(n=>n.key==="cost_quality_tradeoff")?JSON.stringify({model:e.id,routing:{cost_quality_tradeoff:3},messages:[{role:"user",content:"Hello"}]},null,2):null;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"gc-stack gc-stack--tight",children:[s.jsxs("span",{className:"gc-seller__meta",children:[s.jsxs("span",{className:"gc-peer-id",children:[s.jsx(j,{title:e.id,children:X(e.id,10,16)}),s.jsx(we,{iconOnly:!0,value:e.id,label:"Copy router model id"})]}),s.jsx(f,{children:"Router"}),e.free&&s.jsx(f,{tone:"success",children:"Free"})]}),s.jsxs("p",{className:"gc-fineprint",children:["Send ",s.jsx("code",{children:e.id})," as the model: the router ranks the models your key's routing policy allows and the gateway sends the request to its pick, falling back to the next one if a seller refuses. Logs show the router and the model it picked."]}),s.jsx(Y,{items:[["Offered by",s.jsx(Se,{to:J("providers",e.peerId),children:te(e)},"s")],["Service",s.jsx(j,{children:e.serviceId},"v")],["Protocol",s.jsx(j,{children:e.protocol||"—"},"p")],["Price",ts(e)],["Trust",Ee(e.trustScore)],...e.verificationLinks.length?[["Verified",s.jsx(_e,{links:e.verificationLinks},"l")]]:[]]})]}),e.options.length>0&&s.jsxs(M,{title:"Settings",children:[s.jsx(Y,{items:e.options.map(n=>[n.label,s.jsxs("div",{className:"gc-stack gc-stack--tight",children:[s.jsxs("span",{children:[s.jsx(j,{children:n.key})," · default ",os(n),"minimum"in n&&n.minimum!==void 0&&"maximum"in n&&n.maximum!==void 0?` · ${n.minimum}–${n.maximum}`:""]}),n.description&&s.jsx("span",{className:"gc-muted",children:n.description})]},n.key)])}),c&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"gc-fineprint",children:["Set them per request in a ",s.jsx("code",{children:"routing"})," object; they never reach the seller."]}),s.jsx(Le,{code:c,label:"Request body"})]})]}),s.jsx(M,{title:"Models it ranks",children:e.models===null?s.jsx("p",{className:"gc-fineprint",children:"This router did not list its models."}):t?s.jsx("p",{className:"gc-fineprint",children:"Any model: it ranks every model your key allows."}):i.length===0?s.jsx("p",{className:"gc-fineprint",children:"None listed."}):s.jsx("span",{className:"gc-badges",children:i.map(n=>s.jsx(f,{children:n},n))})}),s.jsx(M,{title:"API call",children:s.jsx(Ie,{id:"gc-router-call",model:e.id,format:"openai-chat-completions"})})]})}export{ys as default};
@@ -1 +0,0 @@
1
- import{j as e,r as f,I as M,u as q,n as G,be as me,t as Y,q as Q,f as O,l as he,Q as pe,E as ge,C as E,D as K,B as P,b_ as J,M as fe,w as X,T as C,o as xe,b4 as b,b$ as y,bh as je,b6 as be,bi as ye,bf as Pe,bj as Z,bL as Ne,bM as ve,bN as we,c0 as D,c1 as A,c2 as V,bn as Ie,bw as ke,af as Se,c3 as Me,c4 as Ce,c5 as _e,c6 as $e}from"./index-DPXW_JSn.js";import{p as ee,P as S,C as Te}from"./PeerPicker-CcMSXxY3.js";import{D as Le}from"./DataTable-BCgVRqY6.js";import{S as $}from"./SelectField-m1sMIgMa.js";import{S as B}from"./Segmented-DYnoemT9.js";import{S as T}from"./Switch-Db8Sm64J.js";import{D as Oe}from"./Disclosure-CQMtWM0M.js";const qe="https://antseed.com/docs/reputation";function Ee({label:s,children:r}){const[n,l]=f.useState(!1),a=f.useId();return e.jsxs("span",{className:n?"gc-tip gc-tip--open":"gc-tip",onMouseLeave:()=>l(!1),children:[e.jsx("button",{type:"button",className:"gc-tip__button","aria-label":s,"aria-describedby":a,onClick:()=>l(i=>!i),onBlur:()=>l(!1),children:e.jsx(M.info,{size:14})}),e.jsx("span",{role:"tooltip",id:a,className:"gc-tip__bubble",children:r})]})}function Ue(){return e.jsxs(Ee,{label:"What is the trust score?",children:[e.jsx("span",{className:"gc-tip__title",children:"Trust score, 0 to 100"}),"Your buyer works it out for each seller from records it can check: service history (up to 50), usage last week (20), staked ANTS (10) and a verified GitHub or domain (20), plus 5 for a free model. Proven wash traders score 0."," ",e.jsx("a",{href:qe,target:"_blank",rel:"noreferrer",children:"How it works"})]})}function Fe(s){return r=>{r.preventDefault(),r.stopPropagation(),s()}}function se({initial:s,peers:r,onDone:n}){const[l,a]=f.useState((s==null?void 0:s.name)??""),[i,o]=f.useState((s==null?void 0:s.description)??""),[h,p]=f.useState((s==null?void 0:s.peerIds)??[]),m=Y({mutationFn:()=>{const u={name:l.trim(),description:i.trim()||null,peerIds:h};return s?O.network.updatePeerList(s.id,u):O.network.createPeerList(u)},onSuccess:n,invalidate:[Q.peerLists]});return e.jsxs("form",{className:"gc-stack",onSubmit:Fe(()=>m.mutate()),children:[e.jsx(C,{label:"Name",required:!0,placeholder:"e.g. Our own sellers",value:l,onChange:u=>a(u.target.value)}),e.jsx(C,{label:"Description",value:i,onChange:u=>o(u.target.value)}),e.jsx(S,{label:"Sellers",value:h,onChange:p,peers:r}),e.jsx("p",{className:"gc-fineprint",children:"Policies refer to a list by name, so editing it changes every policy that uses it."}),m.error?e.jsx(xe,{error:m.error,title:"Could not save the list"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(P,{variant:"ghost",onClick:n,children:"Cancel"}),e.jsx(P,{type:"submit",disabled:m.isPending||!l.trim(),children:m.isPending?"Saving…":"Save list"})]})]})}const le="Named groups of sellers that routing rules allow or block in one step. Editing a list changes every rule that uses it.";function Re(s,r){const n=s.peerIds.map(l=>ee(r,l));return n.length<=4?n.join(", "):`${n.slice(0,4).join(", ")} and ${n.length-4} more`}function ze({peers:s,inDialog:r=!1}){const{viewer:n}=q(),l=G(n),a=me(),[i,o]=f.useState(null),[h,p]=f.useState(null),m=Y({mutationFn:u=>O.network.removePeerList(u.id),onSuccess:()=>p(null),invalidate:[Q.peerLists]});return e.jsxs(he,{flush:!r,title:r?void 0:"Seller lists",description:r?void 0:`${le}${l?"":" Organization admins edit them."}`,actions:l&&e.jsx(P,{size:"sm",variant:"outline",leadingIcon:e.jsx(M.plus,{size:14}),onClick:()=>o("new"),children:"New list"}),children:[e.jsx(pe,{query:a,children:u=>e.jsx(Le,{label:"Seller lists",rows:u,rowKey:c=>c.id,rowLabel:c=>c.name,actions:c=>l?[{label:"Edit",onSelect:()=>o(c)},{label:"Delete",tone:"danger",onSelect:()=>p(c)}]:[],empty:e.jsx(ge,{icon:e.jsx(M.network,{size:18}),title:"No seller lists",body:"Group sellers you trust, or ones you run yourself, then allow or block the whole group in a routing rule."}),columns:[{key:"name",header:"Name",render:c=>e.jsx("span",{className:"gc-strong",children:e.jsx(te,{list:c,peers:s})})},{key:"sellers",header:"Sellers",render:c=>e.jsx("span",{className:"gc-muted",children:c.peerIds.length?Re(c,s):"Empty"})},{key:"count",header:"Count",align:"right",secondary:!0,render:c=>c.peerIds.length},{key:"desc",header:"Description",secondary:!0,optional:!0,render:c=>e.jsx("span",{className:"gc-muted",children:c.description??"—"})}]})}),e.jsx(E,{isOpen:i!==null,onClose:()=>o(null),title:i==="new"?"New seller list":"Edit seller list",size:"lg",children:i!==null&&e.jsx(se,{initial:i==="new"?null:i,peers:s,onDone:()=>o(null)})}),e.jsx(K,{isOpen:h!==null,busy:m.isPending,error:m.error,onClose:()=>p(null),onConfirm:()=>h&&m.mutate(h),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 De({peers:s,label:r="Manage seller lists"}){const[n,l]=f.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"link",size:"sm",onClick:()=>l(!0),children:r}),J.createPortal(e.jsx(E,{isOpen:n,onClose:()=>l(!1),title:"Seller lists",subtitle:le,size:"lg",children:e.jsx(ze,{peers:s,inDialog:!0})}),document.body)]})}function te({list:s,peers:r}){const{viewer:n}=q(),l=G(n),[a,i]=f.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"gc-link-button",title:l?`Edit the “${s.name}” list`:`See the “${s.name}” list`,onClick:()=>i(!0),children:s.name}),J.createPortal(e.jsx(E,{isOpen:a,onClose:()=>i(!1),title:l?"Edit seller list":s.name,size:"lg",subtitle:l?void 0:`${s.peerIds.length} seller${s.peerIds.length===1?"":"s"}. Organization admins edit seller lists.`,children:l?e.jsx(se,{initial:s,peers:r,onDone:()=>i(!1)}):s.peerIds.length?e.jsx("ul",{className:"gc-plain-list",children:s.peerIds.map(o=>e.jsxs("li",{children:[ee(r,o)," ",e.jsx(fe,{children:X(o,6,4)})]},o))}):e.jsx("p",{className:"gc-muted",children:"No sellers yet."})}),document.body)]})}function L(s,r,n=3){const l=s.map(a=>{var i;return((i=r==null?void 0:r.find(o=>y(o.peerId)===y(a)))==null?void 0:i.displayName)??X(a,8,4)});return l.length<=n?l.join(", "):`${l.slice(0,n).join(", ")} and ${l.length-n} more`}function W(s,r){return(s??[]).map(n=>{const l=r.find(a=>a.id===n);return l?`the “${l.name}” seller list (${l.peerIds.length})`:"a deleted seller list"}).join(", ")}function Ae(s,r,n=[]){var o,h,p,m;if(!s)return[];const l=s,a=[];if(l.allowedModels&&a.push(l.allowedModels.length===0?"No model is allowed.":`Only these models: ${l.allowedModels.join(", ")}.`),l.allowedPeerIds||l.allowedPeerLists){const u=[(o=l.allowedPeerIds)!=null&&o.length?L(l.allowedPeerIds,r):"",W(l.allowedPeerLists,n)].filter(Boolean);a.push(u.length?`Only these sellers: ${u.join(", ")}.`:"No seller is allowed.")}if((h=l.blockedPeerIds)!=null&&h.length||(p=l.blockedPeerLists)!=null&&p.length){const u=[(m=l.blockedPeerIds)!=null&&m.length?L(l.blockedPeerIds,r):"",W(l.blockedPeerLists,n)].filter(Boolean);a.push(`Never uses ${u.join(", ")}.`)}l.requireTee&&a.push("Only sellers running in a TEE."),l.requireVerified&&a.push("Only sellers with a verified domain or GitHub account."),l.minTrustScore!==void 0&&a.push(`Only sellers with trust ${l.minTrustScore} or more.`),l.minReputation!==void 0&&a.push(`Only sellers with reputation ${l.minReputation} or more.`);const i=[l.maxInputUsdPerMillion!==void 0?`${b(l.maxInputUsdPerMillion)}/M input`:null,l.maxOutputUsdPerMillion!==void 0?`${b(l.maxOutputUsdPerMillion)}/M output`:null,l.maxCachedInputUsdPerMillion!==void 0?`${b(l.maxCachedInputUsdPerMillion)}/M cached input`:null,l.maxImageUsdPerImage!==void 0?`$${l.maxImageUsdPerImage} per image`:null].filter(u=>u!==null);i.length&&a.push(`Pays at most ${i.join(", ")}.`);for(const[u,c]of Object.entries(l.modelRoutes??{}))a.push(`For ${u}: tries ${L(c.peerIds,r,4).replace(/, ([^,]*)$/,", then $1")} first${c.strict?", and no other seller":""}.`);return l.sort==="price"?a.push("Ranks the cheapest seller first."):l.sort==="latency"?a.push("Ranks the fastest seller first."):l.sort==="trust"&&a.push("Ranks the most trusted seller first."),l.preferFreePeers&&a.push("Free sellers first."),a}function Ve(s,r,n,l){var o,h;const a=y(r.peerId);if((o=s.blockedPeerIds)!=null&&o.some(p=>y(p)===a))return"blocks it";if(s.allowedPeerIds&&!s.allowedPeerIds.some(p=>y(p)===a))return"does not allow it";if(s.requireTee&&n&&!n.tee)return"requires a TEE";if(s.requireVerified&&n&&!n.verified)return"requires a verified seller";if(s.minTrustScore!==void 0&&(r.trustScore??0)<s.minTrustScore)return`requires trust ${s.minTrustScore}+ (it has ${Math.round(r.trustScore??0)})`;if(s.minReputation!==void 0&&n&&(n.reputationScore??0)<s.minReputation)return`requires reputation ${s.minReputation}+`;if(s.maxInputUsdPerMillion!==void 0&&r.inputUsdPerMillion!==null&&r.inputUsdPerMillion>s.maxInputUsdPerMillion)return`caps input at ${b(s.maxInputUsdPerMillion)}/M (it asks ${b(r.inputUsdPerMillion)})`;if(s.maxOutputUsdPerMillion!==void 0&&r.outputUsdPerMillion!==null&&r.outputUsdPerMillion>s.maxOutputUsdPerMillion)return`caps output at ${b(s.maxOutputUsdPerMillion)}/M (it asks ${b(r.outputUsdPerMillion)})`;const i=(h=s.modelRoutes)==null?void 0:h[l];return i!=null&&i.strict&&!i.peerIds.some(p=>y(p)===a)?"only allows its route for this model":null}function Be(s,r,n,l=[]){if(r.eligible)return[];const a=n==null?void 0:n.find(i=>y(i.peerId)===y(r.peerId));return s.sources.flatMap(i=>{if(!i.policy)return[];const o=Ve(je(i.policy,l),r,a,s.model);return o?[{level:i.level,levelId:i.id,rule:o}]:[]})}function es(s,r,n=[]){const l=new Map;for(const a of(s==null?void 0:s.candidates)??[])for(const i of new Set(Be(s,a,r,n).map(o=>o.level)))l.set(i,(l.get(i)??0)+1);return l}function We({draft:s,parent:r,above:n,peers:l,lists:a}){const i=f.useMemo(()=>{try{return Ie(s,a)}catch{return null}},[s,a]),o=f.useMemo(()=>!i||!l||l.length===0?null:{matched:ke(Z(r,i),l,a).length,total:l.length},[i,r,l,a]),h=i?Ae(i,l,a):[];return e.jsxs("section",{className:"gc-policy__summary","aria-live":"polite",children:[e.jsxs("div",{className:"gc-policy__summary-head",children:[e.jsx("span",{className:"gc-strong",children:"What this level does"}),o&&o.matched>0&&e.jsxs("span",{className:"gc-muted",children:[o.matched," of ",o.total," sellers can serve",n?` after ${n}`:""]})]}),h.length?e.jsx("ul",{className:"gc-funnel__rules",children:h.map(p=>e.jsx("li",{children:p},p))}):e.jsx("p",{className:"gc-funnel__none",children:"Nothing of its own yet: it passes on everything above."}),o&&o.matched===0&&e.jsxs(Se,{tone:"warning",title:"No seller matches this policy",children:["With ",n?`${n} and `:"","these settings, none of the ",o.total," sellers this gateway sees can serve a request. Requests will fail until you loosen it."]})]})}function w({title:s,help:r,children:n}){return e.jsxs("section",{className:"gc-policy__group",children:[e.jsxs("div",{className:"gc-policy__group-head",children:[e.jsx("h3",{children:s}),e.jsx("p",{className:"gc-fineprint",children:r})]}),e.jsx("div",{className:"gc-policy__group-body",children:n})]})}function ss({value:s,onChange:r,peers:n,lists:l,showTemplates:a=!0,parent:i,disabled:o}){const[h,p]=f.useState(""),[m,u]=f.useState(null),c=(t,x)=>r({...s,[t]:x}),v=be(n),j=ye(Pe().data),d=f.useMemo(()=>j||i?Z(j,i):null,[j,i]),ne=j&&i?"the buyer config and the levels above":j?"the buyer config":i?"the levels above":"",U=t=>(j==null?void 0:j[t])!==void 0&&j[t]===(d==null?void 0:d[t])?"The buyer config":"The levels above",{viewer:re}=q(),ie=Ne("settings",re)?e.jsx("a",{className:"gc-link",href:we("settings?tab=buyer"),onClick:ve("settings?tab=buyer"),children:"Change"}):null,ae=t=>U(t)==="The buyer config"?ie:null;function F(t,x=h){var z;let g;if(t==="own"){const k=l.find(ue=>ue.id===x);if(!k)return;g={allowMode:"only",allowedPeerIds:[],allowedListIds:[k.id]}}else g=Ce(_e(t));const N=$e(s,g),de=((z=D.find(k=>k.id===t))==null?void 0:z.label)??t;N.length>0?u({label:de,template:g,conflicts:N}):r(V(s,g))}function _(t,x){c("routes",s.routes.map((g,N)=>N===t?x:g))}const I=(t,x)=>e.jsx(C,{size:"sm",className:"gc-num",label:x,inputMode:"decimal",value:s[t],placeholder:(d==null?void 0:d[t])!==void 0?`≤ ${b(d[t])} above`:"No cap",onChange:g=>c(t,g.target.value)}),oe="",ce=t=>{if(t==="clear")return r(Me());if(t.startsWith("list:"))return p(t.slice(5)),F("own",t.slice(5));t&&F(t)},R=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"gc-policy__top",children:[e.jsx(We,{draft:s,parent:d,above:ne,peers:n,lists:l}),a&&!o&&e.jsx($,{size:"sm","aria-label":"Start from a template",value:oe,onChange:ce,options:[{value:"",label:"Start from…"},...D.filter(t=>t.id!=="own").map(t=>({value:t.id,label:`${t.label}: ${t.description}`})),...l.map(t=>({value:`list:${t.id}`,label:`Only the “${t.name}” list (${t.peerIds.length})`})),{value:"clear",label:"Clear every setting"}]})]}),e.jsxs(w,{title:"Sellers",help:e.jsxs(e.Fragment,{children:["Who may serve requests. Blocked sellers never serve. ",e.jsx(De,{peers:n})]}),children:[e.jsx(B,{label:"Which sellers may serve",value:s.allowMode,onChange:t=>c("allowMode",t),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),s.allowMode==="only"&&e.jsxs(e.Fragment,{children:[e.jsx(H,{label:"Seller lists",lists:l,value:s.allowedListIds,onChange:t=>c("allowedListIds",t),peers:n}),e.jsx(S,{label:l.length?"And these sellers":"Allowed sellers",value:s.allowedPeerIds,onChange:t=>c("allowedPeerIds",t),peers:n}),s.allowedPeerIds.length===0&&s.allowedListIds.length===0&&e.jsx("p",{className:"gc-warn",children:"An empty allow list means no seller can serve."})]}),e.jsx(S,{label:"Never use",value:s.blockedPeerIds,onChange:t=>c("blockedPeerIds",t),peers:n}),e.jsx(H,{label:"Never use these lists",lists:l,value:s.blockedListIds,onChange:t=>c("blockedListIds",t),peers:n})]}),e.jsxs(w,{title:"Quality",help:"How trusted a seller must be, and what it must run, to serve.",children:[e.jsx(He,{label:"Minimum trust score",info:e.jsx(Ue,{}),value:s.minTrustScore,onChange:t=>c("minTrustScore",t),floor:d==null?void 0:d.minTrustScore,floorSource:U("minTrustScore"),floorAction:ae("minTrustScore")}),s.minReputation!==""&&e.jsxs("p",{className:"gc-fineprint",children:["This policy also asks for reputation ",s.minReputation," or more, an older score the trust score replaces."," ",e.jsx(P,{variant:"link",size:"sm",onClick:()=>c("minReputation",""),children:"Remove it"})]}),e.jsxs("div",{className:"gc-policy__switches",children:[e.jsx(T,{checked:s.requireTee||!!(d!=null&&d.requireTee),disabled:!!(d!=null&&d.requireTee),onChange:t=>c("requireTee",t),label:"TEE sellers only"}),e.jsx(T,{checked:s.requireVerified||!!(d!=null&&d.requireVerified),disabled:!!(d!=null&&d.requireVerified),onChange:t=>c("requireVerified",t),label:"Verified sellers only"})]}),((d==null?void 0:d.requireTee)||(d==null?void 0:d.requireVerified))&&e.jsxs("span",{className:"as-field__hint",children:[d.requireTee&&d.requireVerified?"TEE and verified sellers are":d.requireTee?"TEE sellers are":"Verified sellers are"," already required above."]})]}),e.jsx(w,{title:"Price limits",help:"Sellers asking more are skipped. Leave a field empty for no limit.",children:e.jsxs("div",{className:"gc-policy__caps",children:[I("maxInputUsdPerMillion","Input $/M"),I("maxOutputUsdPerMillion","Output $/M"),I("maxCachedInputUsdPerMillion","Cached input $/M"),I("maxImageUsdPerImage","$ per image")]})}),e.jsxs(w,{title:"Models",help:"Requests for any other model are refused.",children:[e.jsx(B,{label:"Which models may be used",value:s.modelsMode,onChange:t=>c("modelsMode",t),options:[{value:"any",label:"Any model"},{value:"only",label:"Only these models"}]}),s.modelsMode==="only"&&e.jsx(Te,{label:"Allowed models",value:s.allowedModels,onChange:t=>c("allowedModels",t),suggestions:v,placeholder:"Model id"})]}),e.jsxs(w,{title:"Ranking",help:"The order the allowed sellers are tried in. Inherit keeps automatic routing, which ranks by expected cost and success rate.",children:[e.jsxs("div",{className:"gc-policy__pair",children:[e.jsx($,{size:"sm",label:"Sort by",value:s.sort,onChange:t=>c("sort",t),options:[{value:"",label:"Inherit"},...Object.keys(A).map(t=>({value:t,label:A[t]}))]}),e.jsx($,{size:"sm",label:"Free sellers first",value:s.preferFreePeers,onChange:t=>c("preferFreePeers",t),options:[{value:"inherit",label:"Inherit"},{value:"yes",label:"Yes"},{value:"no",label:"No"}]})]}),e.jsxs(Oe,{title:"Fallback chains",summary:s.routes.length?`${s.routes.length} chain${s.routes.length===1?"":"s"}`:"None",defaultOpen:s.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."}),s.routes.map((t,x)=>e.jsxs("div",{className:"gc-route",children:[e.jsxs("div",{className:"gc-inline",children:[e.jsx(C,{size:"sm",label:"Model",list:"gc-policy-models",value:t.model,placeholder:"Model id",onChange:g=>_(x,{...t,model:g.target.value})}),e.jsx(T,{checked:t.strict,onChange:g=>_(x,{...t,strict:g}),label:"Strict"}),e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>c("routes",s.routes.filter((g,N)=>N!==x)),children:"Remove"})]}),e.jsx(S,{label:"Sellers, in order",ordered:!0,value:t.peerIds,onChange:g=>_(x,{...t,peerIds:g}),peers:n})]},x)),e.jsx("datalist",{id:"gc-policy-models",children:v.map(t=>e.jsx("option",{value:t},t))}),e.jsx("div",{children:e.jsx(P,{variant:"outline",size:"sm",onClick:()=>c("routes",[...s.routes,{model:"",peerIds:[],strict:!1}]),children:"Add fallback chain"})})]})]}),e.jsx(K,{isOpen:m!==null,tone:"primary",title:`Apply “${(m==null?void 0:m.label)??""}”?`,confirmLabel:"Replace and apply",body:e.jsxs(e.Fragment,{children:["This template changes settings you already set: ",e.jsx("strong",{children:m==null?void 0:m.conflicts.join(", ")}),". Your other settings stay."]}),onClose:()=>u(null),onConfirm:()=>{m&&r(V(s,m.template)),u(null)}})]});return o?e.jsx("fieldset",{className:"gc-policy gc-policy--readonly",disabled:!0,children:R}):e.jsx("div",{className:"gc-policy",children:R})}function He({label:s,info:r,value:n,onChange:l,clearable:a=!0,hint:i,floor:o,floorSource:h="The levels above",floorAction:p}){const m=f.useId(),u=n!=="",c=o!==void 0&&o>0,v=c&&u&&Number(n)<=o,j=v?String(o):u?n:c?`${o} inherited`:"Inherit";return e.jsxs("div",{className:"gc-slider",children:[e.jsxs("div",{className:"gc-slider__head",children:[e.jsxs("span",{className:"gc-info-label",children:[e.jsx("span",{className:"as-field__label",id:m,children:s}),r]}),e.jsx("span",{className:u?"gc-slider__value":"gc-slider__value gc-slider__value--inherit",children:j})]}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{type:"range",min:0,max:100,step:5,value:u?Math.max(Number(n),c?o:0):c?o:0,"aria-labelledby":m,onChange:d=>l(String(Math.max(Number(d.target.value),c?o:0)))}),a&&u&&e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>l(""),children:"Clear"})]}),c&&(u&&!v?e.jsxs("span",{className:"as-field__hint",children:[h," requires ≥ ",o,". Only a higher value narrows it."]}):e.jsxs("span",{className:"as-field__hint gc-override",children:[e.jsx(M.lock,{size:12})," Locked at ",o," by ",h.replace(/^The /,"the "),".",p?e.jsxs(e.Fragment,{children:[" ",p]}):null]})),i&&e.jsx("span",{className:"as-field__hint",children:i})]})}function H({label:s,lists:r,value:n,onChange:l,peers:a}){return r.length===0?null:e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:s}),r.map(i=>e.jsxs("span",{className:"gc-check",children:[e.jsx("input",{type:"checkbox","aria-label":`${s}: ${i.name}`,checked:n.includes(i.id),onChange:o=>l(o.target.checked?[...n,i.id]:n.filter(h=>h!==i.id))}),e.jsx(te,{list:i,peers:a})," ",e.jsxs("span",{className:"gc-muted",children:["(",i.peerIds.length,")"]})]},i.id))]})}export{ze as P,He as S,Ue as T,es as a,ss as b,De as c,Be as e,Ae as p};
@@ -1,4 +0,0 @@
1
- import{u as A,i as J,b5 as B,r as n,t as E,j as e,P as $,B as v,I as k,l as L,Q as R,M as Q,av as U,v as C,A as V,E as W,n as F,C as G,D as H,b as K,T as j,b6 as _,o as X,q as O,f as y}from"./index-DPXW_JSn.js";import{u as Y,a as Z,P as ee}from"./PolicyField-ldIq_Yw-.js";import{D as se}from"./DataTable-BCgVRqY6.js";import{S as re}from"./SelectField-m1sMIgMa.js";import{T as N}from"./TextAreaField-BCi-qMua.js";import"./PolicyEditor-COREmE0O.js";import"./PeerPicker-CcMSXxY3.js";import"./Segmented-DYnoemT9.js";import"./roving-DkptacxO.js";import"./Switch-Db8Sm64J.js";import"./Disclosure-CQMtWM0M.js";function D(s){return s.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function te(s){return/^[a-z0-9][a-z0-9-]{0,47}$/.test(s)}function ae(s){if(!s.trim())return{};let a;try{a=JSON.parse(s)}catch{throw new Error("Parameters must be valid JSON.")}if(!a||typeof a!="object"||Array.isArray(a))throw new Error('Parameters must be a JSON object, like {"temperature": 0.2}.');return a}function oe({initial:s,prefill:a,onDone:m}){const{workspace:p,viewer:c}=A(),u=K(),[o,g]=n.useState((s==null?void 0:s.name)??(a==null?void 0:a.name)??""),[l,d]=n.useState((s==null?void 0:s.slug)??(a?D(a.name):"")),[t,q]=n.useState(!!s),[h,I]=n.useState((s==null?void 0:s.model)??(a==null?void 0:a.model)??""),[b,M]=n.useState(s?s.workspaceId??"":p.id),[S,T]=n.useState((s==null?void 0:s.systemPrompt)??""),[w,z]=n.useState(s&&Object.keys(s.params).length?JSON.stringify(s.params,null,2):""),x=Y(s==null?void 0:s.routingPolicy),P=Z(),i=E({mutationFn:()=>{if(!te(l))throw new Error("Slug must be lowercase letters, numbers and dashes.");const r={name:o.trim(),slug:l,model:h.trim(),workspaceId:b||null,systemPrompt:S.trim()||null,params:ae(w),routingPolicy:x.build()};return P.save([r.routingPolicy],f=>s?y.presets.update(s.id,r,f):y.presets.create(r,f))},onSuccess:r=>m(r),invalidate:[O.group("presets")],toast:"Preset saved"});return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),i.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Name",required:!0,value:o,onChange:r=>{g(r.target.value),t||d(D(r.target.value))}}),e.jsx(j,{label:"Slug",required:!0,value:l,onChange:r=>{q(!0),d(r.target.value)},hint:e.jsxs(e.Fragment,{children:["Called as ",e.jsxs("code",{children:["@preset/",l||"slug"]})]})})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Model",required:!0,list:"gc-preset-models",value:h,onChange:r=>I(r.target.value)}),e.jsx("datalist",{id:"gc-preset-models",children:_(u.data).map(r=>e.jsx("option",{value:r},r))}),e.jsx(re,{label:"Available in",value:b,onChange:M,options:[{value:p.id,label:`${p.name} workspace`},...F(c)?[{value:"",label:"All workspaces"}]:[]]})]}),e.jsx(N,{label:"System prompt",rows:4,value:S,onChange:r=>T(r.target.value),hint:"Added before the client's messages."}),e.jsx(N,{label:"Parameters (JSON)",rows:4,mono:!0,value:w,placeholder:`{
2
- "temperature": 0.2,
3
- "max_tokens": 2048
4
- }`,onChange:r=>z(r.target.value),hint:"Defaults merged under the client's own parameters."}),e.jsx(ee,{draft:x.draft,setDraft:x.setDraft}),i.error?e.jsx(X,{error:i.error,title:"Could not save the preset"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(v,{variant:"ghost",onClick:()=>m(),children:"Cancel"}),e.jsx(v,{type:"submit",disabled:i.isPending||!o.trim()||!h.trim(),children:i.isPending?"Saving…":"Save preset"})]}),P.dialog]})}function je(){const{workspace:s,viewer:a}=A(),m=J(a),p=B(s.id),[c,u]=n.useState(null),[o,g]=n.useState(null),l=E({mutationFn:d=>y.presets.remove(d.id),onSuccess:()=>g(null),invalidate:[O.group("presets")]});return e.jsxs("div",{className:"gc-page",children:[e.jsx($,{title:"Presets",description:e.jsxs(e.Fragment,{children:["A saved model, prompt, parameters and routing. Use one by sending ",e.jsx("code",{children:'"model": "@preset/<slug>"'}),"."]}),actions:m&&e.jsx(v,{variant:"brand",leadingIcon:e.jsx(k.plus,{size:14}),onClick:()=>u("new"),children:"New preset"})}),e.jsx(L,{flush:!0,children:e.jsx(R,{query:p,children:d=>e.jsx(se,{label:"Presets",rows:d,rowKey:t=>t.id,rowLabel:t=>t.name,actions:t=>m&&(t.workspaceId||F(a))?[{label:"Edit",onSelect:()=>u(t)},{label:"Delete",tone:"danger",onSelect:()=>g(t)}]:[],empty:e.jsx(W,{icon:e.jsx(k.presets,{size:18}),title:"No presets yet",body:"Presets let every client share one tuned setup without changing code."}),columns:[{key:"name",header:"Name",render:t=>e.jsx("span",{className:"gc-strong",children:t.name})},{key:"usage",header:"Use as model",render:t=>e.jsxs("span",{className:"gc-inline gc-inline--wrap",children:[e.jsxs(Q,{children:["@preset/",t.slug]}),e.jsx(U,{value:`@preset/${t.slug}`})]})},{key:"model",header:"Model",secondary:!0,render:t=>t.model},{key:"scope",header:"Scope",secondary:!0,render:t=>t.workspaceId?e.jsx(C,{children:"Workspace"}):e.jsx(C,{tone:"info",children:"All workspaces"})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>e.jsx("span",{className:"gc-muted",children:V(t.routingPolicy)})}]})})}),e.jsx(G,{isOpen:c!==null,onClose:()=>u(null),size:"lg",title:c==="new"?"New preset":"Edit preset",children:c!==null&&e.jsx(oe,{initial:c==="new"?null:c,onDone:()=>u(null)})}),e.jsx(H,{isOpen:o!==null,busy:l.isPending,error:l.error,onClose:()=>g(null),onConfirm:()=>o&&l.mutate(o),title:"Delete this preset?",confirmLabel:"Delete preset",body:e.jsxs(e.Fragment,{children:["Requests that use ",e.jsxs("code",{children:["@preset/",o==null?void 0:o.slug]})," will fail."]})})]})}export{oe as PresetForm,je as default};
@@ -1 +0,0 @@
1
- import{bS as Ue,ag as me,aP as Ve,u as H,a as he,F as _e,G as ze,n as qe,i as ge,r as y,U as Ke,c as fe,e as Ge,bT as Qe,bm as Ye,$ as U,bU as He,bV as Je,f as q,an as We,j as s,C as we,af as K,o as pe,B as P,L as ye,A as Ze,w as A,M as be,av as ve,v as F,aa as Xe,bQ as I,ad as ke,ae as xe,h as je,Z as es,b0 as Pe,bW as Se,T as Ce,aZ as ss,b5 as ts,bX as as,Y as rs,a$ as ns,O as Ie,R as os,br as ls,b as is,b6 as cs,bY as ds,bu as us,E as re,I as ne,l as ms,Q as hs,bv as gs,b2 as oe,bZ as fs,y as le,b3 as ws,bL as ps,P as ys}from"./index-DPXW_JSn.js";import{p as G}from"./PeerPicker-CcMSXxY3.js";import{S as N}from"./SelectField-m1sMIgMa.js";import{V as $e,T as Ne}from"./VerificationLinks-CWyl6ZEp.js";import{P as Ae,a as bs,p as vs,S as ks}from"./SidePanel-BFQArkoa.js";import{c as xs}from"./PolicyEditor-COREmE0O.js";import{f as js}from"./ants-B38m9Phv.js";import{PresetForm as Ps}from"./Presets-DFKw93HK.js";import{T as Ss,a as Cs}from"./Tabs-CCabxVNK.js";import{D as Is}from"./DataTable-BCgVRqY6.js";import{S as Q}from"./Switch-Db8Sm64J.js";import"./Segmented-DYnoemT9.js";import"./roving-DkptacxO.js";import"./Disclosure-CQMtWM0M.js";import"./PolicyField-ldIq_Yw-.js";import"./TextAreaField-BCi-qMua.js";function Fe(e,t="admin"){return t==="owner"&&Ve(e)?"ownerRoutingPolicy":"routingPolicy"}async function Te(e,t){const r=(await e.keys.list({workspace:t.workspaceId})).find(n=>n.id===t.keyId);if(!r)throw new Error("That key no longer exists.");return r}async function Me(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(n=>n.id===t.memberId);if(!r)throw new Error("That member no longer exists.");return r.routingPolicy}case"key":{const r=await Te(e,t);return r[Fe(r,t.layer)]??null}}}async function $s(e,t,r,n){const l=n!=null&&n.confirmEmpty||n!=null&&n.acceptNarrowed?[n]:[];switch(t.kind){case"gateway":await e.network.setGatewayPolicy(r??{},...l);return;case"workspace-org":await e.workspaces.update(t.workspaceId,{orgRoutingPolicy:r},...l);return;case"workspace":await e.workspaces.update(t.workspaceId,{routingPolicy:r},...l);return;case"member":await e.members.update(t.memberId,{routingPolicy:r},...l);return;case"key":{const o=t.layer==="owner"?Fe(await Te(e,t),"owner"):"routingPolicy";await e.keys.update(t.keyId,{[o]:r},...l);return}}}const ie=e=>JSON.stringify(e??{},Object.keys(e??{}).sort());async function Ns(e,t,r,n,l,o){const g=await Me(e,t),d=Ue(g,r,n,l),m=ie(g)!==ie(d)||JSON.stringify(g??{})!==JSON.stringify(d);return m&&await $s(e,t,d,o),{before:g,after:d,changed:m}}function As(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 Fs={allow:"Allowed",block:"Blocked",prefer:"Preferred"};function Ts(e){const{action:t,name:r,scopeLabel:n,changed:l,model:o,preview:g,peerId:d}=e,m=Fs[t],k=t==="prefer"?`already first for ${o}`:`already ${m.toLowerCase()}`,h=l?`${m} ${r} ${t==="prefer"?`for ${o} `:""}on ${n}`:`${r} was ${k} on ${n}; nothing changed`;if(!g)return t==="block"?{tone:l?"success":"info",text:`${h}.`}:{tone:"info",text:`${h}. ${e.previewError?`Could not check whether it can serve: ${e.previewError}`:"Could not check whether it can serve."}`};const u=g.candidates.find(p=>me(p.peerId,d));if(t==="block")return u!=null&&u.eligible?{tone:"warning",text:`${h}, but the route preview still lists it as eligible for ${o}. Reload and check the policy.`}:{tone:l?"success":"info",text:`${h}.`};if(!g.modelAllowed)return{tone:"warning",text:`${h}, but ${o} is not an allowed model here, so it still cannot serve it.`};if(!u)return{tone:"info",text:`${h}. It does not offer ${o} right now, so the preview cannot show its rank.`};if(!u.eligible){const p=u.reasons.length?u.reasons.join("; "):"another level excludes it";return{tone:"warning",text:`${h}, but it still cannot serve ${o} here: ${p}.`}}return t==="prefer"&&u.rank!==null&&u.rank>1?{tone:"warning",text:`${h}, but it ranks #${u.rank} for ${o}: a fallback chain on another level comes first.`}:{tone:l?"success":"info",text:`${h}.${u.rank?` It ranks #${u.rank} for ${o}.`:""}`}}function Ms(e,t,r,n){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:n?"admin":"owner"}:null}function Ls(e){return e.canForce?"Not allowed above":e.tone==="warning"?"Check the result":"Done"}function Rs({fetching:e,error:t,ready:r,policy:n}){return e?s.jsx(ye,{rows:1}):t?s.jsx(pe,{error:t,title:"Could not load this scope's policy"}):r?s.jsxs("p",{className:"gc-muted",children:["Current policy: ",Ze(n)]}):null}const ce={allow:{title:"Allow seller",verb:"Allow"},block:{title:"Block seller",verb:"Block"},prefer:{title:"Prefer seller",verb:"Prefer"}};function Le({peer:e,action:t,onClose:r,peers:n}){var W,Z,X,ee;const{viewer:l,workspace:o,me:g}=H(),d=he(),m=_e(),k=ze(),h=qe(l),u=ge(l),p=[...h?[{value:"gateway",label:"Gateway default (everyone)"}]:[],...h?[{value:"workspace-org",label:`${o.name}: organization policy`}]:[],...u?[{value:"workspace",label:`${o.name}: workspace policy`}]:[],...h?[{value:"member",label:"A member"}]:[],{value:"key",label:"An API key"}],[w,$]=y.useState(p[0].value),[i,a]=y.useState(""),[b,R]=y.useState(""),B=Ke(w==="member"),E=fe(d,w==="key");y.useEffect(()=>{a("")},[w]),y.useEffect(()=>{var c;R(((c=e==null?void 0:e.services[0])==null?void 0:c.service)??"")},[e]);const f=(E.data??[]).filter(c=>c.status==="active"&&(u||c.ownerMemberId===g.member.id)),v=Ms(w,i,o.id,u),[S,M]=y.useState(null);y.useEffect(()=>{M(null)},[w,i,e]);const O=Ge({queryKey:["routing","scope-policy",v],queryFn:()=>Me(q,v),enabled:v!==null&&e!==null,staleTime:0}),D=v!==null&&O.isSuccess&&(t!=="prefer"||b!==""),C=O.data??null,Ee=t==="allow"&&D&&!(C!=null&&C.allowedPeerIds)&&!(C!=null&&C.allowedPeerLists),Oe=t==="block"&&D&&e!==null&&Qe(C,e.peerId);let L=((W=p.find(c=>c.value===w))==null?void 0:W.label.replace(/^A[n]? /,"the "))??"this scope";w==="key"&&(L=`key “${((Z=f.find(c=>c.id===i))==null?void 0:Z.label)??i}”`),w==="member"&&(L=`member “${((ee=(X=B.data)==null?void 0:X.find(c=>c.id===i))==null?void 0:ee.label)??i}”`);const x=Ye({mutationFn:async(c={})=>{var ae;if(!e||!v)return null;const j=b||((ae=e.services[0])==null?void 0:ae.service)||"",{changed:z}=await Ns(q,v,t,e.peerId,b||void 0,c);let se=null,te=null;if(j)try{se=await q.network.routePreview(As(v,j,o.id))}catch(De){te=We(De)}return Ts({action:t,name:G(n,e.peerId),scopeLabel:L,changed:z,model:j,preview:se,peerId:e.peerId,previewError:te})},onSuccess:c=>{for(const j of Je)m.invalidateQueries({queryKey:[j]});c&&(c.tone==="success"?(k(c.text),r()):M(c))},onError:c=>{const j=e?G(n,e.peerId):"this seller";if(U(c,"narrowed"))M({tone:"warning",canForce:!0,text:`Nothing changed yet. The levels above ${L} do not allow ${j}, so saving this would not let it serve. ${He(c.details).join(" ")}`.trim()});else if(U(c,"empty_allow_list")){const z=t==="block"?`Blocking ${j}`:`Allowing only ${j}`;M({tone:"warning",text:`Nothing changed. ${z} on ${L} 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.`})}}}),_=e?G(n,e.peerId):"";return s.jsx(we,{isOpen:e!==null,onClose:r,title:ce[t].title,subtitle:_,children:s.jsxs("div",{className:"gc-stack",children:[s.jsx(N,{label:"Apply to",value:w,onChange:c=>$(c),options:p}),w==="member"&&s.jsx(N,{label:"Member",value:i,onChange:a,options:[{value:"",label:"Choose a member"},...(B.data??[]).filter(c=>c.status!=="disabled").map(c=>({value:c.id,label:c.label}))]}),w==="key"&&s.jsx(N,{label:"Key",value:i,onChange:a,options:[{value:"",label:f.length?"Choose a key":"No keys you can edit"},...f.map(c=>({value:c.id,label:c.label}))]}),t==="prefer"&&e&&s.jsx(N,{label:"For model",value:b,onChange:R,options:e.services.map(c=>({value:c.service,label:c.service})),hint:"The seller goes first in this model's fallback chain."}),s.jsx(Rs,{fetching:O.isFetching,error:O.error,ready:D,policy:C}),Ee&&s.jsxs(K,{tone:"warning",children:["This scope has no allow list yet. Allowing ",_," creates one, so only allowed sellers can serve it."]}),Oe&&s.jsxs(K,{tone:"warning",title:"This is the only allowed seller",children:["Blocking ",_," 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."}),w==="key"&&!u&&s.jsx("p",{className:"gc-muted",children:"This changes your own restrictions on the key. Restrictions a workspace admin set still apply."}),x.error&&!U(x.error,"narrowed")&&!U(x.error,"empty_allow_list")?s.jsx(pe,{error:x.error,title:"Could not update the policy"}):null,S?s.jsxs(s.Fragment,{children:[s.jsx(K,{tone:S.tone,title:Ls(S),children:S.text}),s.jsxs("div",{className:"gc-actions",children:[S.canForce&&s.jsx(P,{variant:"ghost",disabled:x.isPending,onClick:()=>{M(null),x.mutate({acceptNarrowed:!0})},children:"Save it anyway"}),s.jsx(P,{onClick:r,children:S.canForce?"Cancel":"Done"})]})]}):s.jsxs("div",{className:"gc-actions",children:[s.jsx(P,{variant:"ghost",onClick:r,children:"Cancel"}),s.jsx(P,{variant:t==="block"?"danger":"primary",disabled:!D||x.isPending,onClick:()=>x.mutate({}),children:x.isPending?"Saving…":ce[t].verb})]})]})})}function Re(e,t){return t?e.services.filter(r=>r.service===t):e.services}function V(e,t,r=""){const n=Re(e,r).map(l=>l[t]).filter(l=>l!==null);return n.length?{min:Math.min(...n),max:Math.max(...n)}:null}function Bs(e,t=""){var r;return((r=V(e,"inputUsdPerMillion",t))==null?void 0:r.min)??null}function Es(e,t=""){var r;return((r=V(e,"outputUsdPerMillion",t))==null?void 0:r.min)??null}function J(e,t=""){return Re(e,t).some(r=>r.inputUsdPerMillion===0&&(r.outputUsdPerMillion??0)===0)}function Os(e,t){const r=t.search.trim().toLowerCase();return e.filter(n=>{var l;return!(r&&!n.peerId.toLowerCase().includes(r)&&!(n.displayName??"").toLowerCase().includes(r)&&!n.services.some(o=>o.service.toLowerCase().includes(r))||t.model&&!n.services.some(o=>o.service===t.model)||t.tee&&!n.tee||t.linked&&!((l=n.verificationLinks)!=null&&l.length)||t.free&&!J(n,t.model))})}const Be={"openai-chat-completions":"Chat completions","openai-responses":"Responses","anthropic-messages":"Messages","openai-images":"Images"};function de(e){return e===null?"—":String(Math.round(e))}function Y(e){return e.displayName??A(e.peerId,8,4)}function T(e){return`${e.provider}:${e.service}`}function Ds({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(be,{title:e.peerId,children:A(e.peerId,6,4)}),s.jsx(ve,{iconOnly:!0,value:e.peerId,label:"Copy peer id"})]}),s.jsx($e,{links:e.verificationLinks}),s.jsx(Ne,{tee:e.tee,scope:e.teeScope}),J(e,"")&&s.jsx(F,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(F,{tone:"danger",children:"Flagged"}),t&&s.jsx(F,{tone:"warning",children:"Cooling down"}),s.jsxs("span",{className:"gc-muted",children:["Last seen ",Xe(e.lastSeen)]})]})}function Us({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(I,{label:"Trust score",value:de(e.trustScore)}),t&&s.jsx(I,{label:"Reputation",value:de(e.reputationScore)}),s.jsx(I,{label:"Stake",value:e.stakeAnts?js(e.stakeAnts):"—"}),s.jsx(I,{label:"Network usage share",value:e.usageShareBps===null?"—":`${(e.usageShareBps/100).toFixed(2)}%`}),s.jsx(I,{label:"First token p50 (this gateway)",value:ke(e.firstTokenMsP50)}),s.jsx(I,{label:"Speed p50 (this gateway)",value:xe(e.tokensPerSecondP50)}),s.jsx(I,{label:"Requests, 24h (this gateway)",value:je(e.requests24h)}),s.jsx(I,{label:"Failure streak",value:r?`${e.health.failureStreak}, cooling down until ${es(e.health.coolingDownUntil)}`:String(e.health.failureStreak)})]})}function Vs({peer:e,selected:t,onSelect:r}){const[n,l]=y.useState(""),o=n.trim().toLowerCase(),g=e.services.filter(d=>!o||d.service.toLowerCase().includes(o));return s.jsx(Ae,{title:`Models (${e.services.length})`,actions:e.services.length>6&&s.jsx(Ce,{size:"sm",type:"search","aria-label":"Search this provider's models",placeholder:"Search models",value:n,onChange:d=>l(d.target.value)}),children:g.length===0?s.jsx("p",{className:"gc-fineprint",children:o?"No models match.":"This provider lists no models."}):s.jsx("ul",{className:"gc-panel-rows","aria-label":"Models and prices",children:g.map(d=>{const m=t!==null&&T(t)===T(d);return s.jsx(bs,{selected:m,title:s.jsx("span",{className:"gc-strong",children:d.service}),meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:vs(d)}),s.jsx("span",{children:Be[Se(d)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(ve,{iconOnly:!0,value:Pe(e.peerId,d.service),label:`Copy ${d.service} pinned to this provider (peer@model)`}),s.jsx(P,{size:"sm",variant:m?"outline":"ghost","aria-pressed":m,title:"Show the API call for this model",onClick:()=>r(d),children:"API call"})]})},T(d))})})})}function _s({peer:e,service:t,onSelect:r}){var E;const{workspace:n,viewer:l}=H(),o=he(),g=ss(),d=fe(o),m=ts(n.id),[k,h]=y.useState("curl"),[u,p]=y.useState(!1),w=Se(t),$=Pe(e.peerId,t.service),i=((E=m.data)==null?void 0:E.find(f=>f.model===$))??null,a=as(g,e.peerId,t.service,w,i?`@preset/${i.slug}`:null),b=a.find(f=>f.id===k)??a[0],R=(d.data??[]).some(f=>f.status==="active"),B=ge(l);return s.jsxs(Ae,{title:"API call",actions:e.services.length>1&&s.jsx(N,{size:"sm","aria-label":"Model",value:T(t),onChange:f=>{const v=e.services.find(S=>T(S)===f);v&&r(v)},options:e.services.map(f=>({value:T(f),label:f.service}))}),children:[s.jsxs("p",{className:"gc-fineprint",children:["Pinned to this provider with ",s.jsx("code",{children:A($,10,12)}),"."]}),s.jsx(Ss,{id:"gc-connect",label:"Ways to connect",value:b.id,onChange:h,className:"gc-connect-tabs",tabs:a.map(f=>({id:f.id,label:f.label}))}),s.jsxs(Cs,{tabsId:"gc-connect",tab:b.id,className:"gc-stack",children:[b.id==="codex"&&s.jsxs("div",{className:"gc-summary-row",children:[s.jsx("p",{className:"gc-fineprint gc-summary-row__text",children:i?s.jsxs(s.Fragment,{children:["Uses the preset ",s.jsxs("code",{children:["@preset/",i.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."})}),!i&&B&&s.jsx(P,{size:"sm",variant:"outline",onClick:()=>p(!0),children:"Create preset for this model"})]}),b.id==="claude-code"&&w!=="anthropic-messages"&&s.jsxs("p",{className:"gc-fineprint",children:["This model speaks ",Be[w],"; the gateway translates Claude Code's requests for it."]}),s.jsx(rs,{code:b.code,label:`${t.service} · ${b.label}`})]}),s.jsxs("p",{className:"gc-fineprint",children:["Set ",s.jsx("code",{children:ns})," to one of your API keys first."," ",d.data&&!R&&s.jsx(Ie,{to:"keys",children:"Create an API key"})]}),s.jsx(we,{isOpen:u,onClose:()=>p(!1),size:"lg",title:"New preset",children:u&&s.jsx(Ps,{initial:null,prefill:{name:t.service,model:$},onDone:f=>{p(!1),f&&h("codex")}})})]})}function zs({peer:e,peers:t,showReputation:r}){const[n,l]=y.useState(null),[o,g]=y.useState(null),d=y.useRef(null),m=o??e.services[0]??null,k=h=>{var u;g(h),(u=d.current)==null||u.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"gc-stack",children:[s.jsx(Ds,{peer:e}),s.jsxs("div",{className:"gc-panel-actions",children:[s.jsx(P,{size:"sm",variant:"outline",onClick:()=>l("allow"),children:"Allow"}),s.jsx(P,{size:"sm",variant:"outline",onClick:()=>l("prefer"),children:"Prefer"}),s.jsx(P,{size:"sm",variant:"danger",onClick:()=>l("block"),children:"Block"})]}),s.jsx(Us,{peer:e,showReputation:r})]}),s.jsx(Vs,{peer:e,selected:m,onSelect:k}),m&&s.jsx("div",{ref:d,className:"gc-scroll-target",children:s.jsx(_s,{peer:e,service:m,onSelect:g})}),n&&s.jsx(Le,{peer:e,action:n,peers:t,onClose:()=>l(null)})]})}function ue(e){return e===null?"—":String(Math.round(e))}function qs({peer:e,model:t}){const r=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-badges",children:[s.jsx(Ne,{tee:e.tee,scope:e.teeScope}),J(e,t)&&s.jsx(F,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(F,{tone:"danger",children:"Flagged"}),r&&s.jsx(F,{tone:"warning",children:"Cooling down"})]})}function lt(){const{viewer:e}=H(),t=os(),r=ls(t.rest),n=is(),l=y.useMemo(()=>{var i;return r?((i=n.data)==null?void 0:i.find(a=>me(a.peerId,r)))??null:null},[n.data,r]),[o,g]=y.useState({search:"",model:"",tee:!1,linked:!1,free:!1}),[d,m]=y.useState(null),k=y.useMemo(()=>cs(n.data),[n.data]),h=ds(n.data),u=us(),p=(i,a)=>g(b=>({...b,[i]:a})),w=r===null?null:{eyebrow:"Provider",title:l?Y(l):A(r,8,6),body:n.isLoading?s.jsx(ye,{rows:6}):l?s.jsx(zs,{peer:l,peers:n.data,showReputation:h},l.peerId):s.jsx(re,{icon:s.jsx(ne.providers,{size:18}),title:"Provider not found",body:`This gateway does not see ${A(r,8,6)} right now.`})},$=s.jsxs("div",{className:"gc-page",children:[s.jsx(ms,{flush:!0,children:s.jsx(hs,{query:n,rows:8,children:i=>s.jsx(Is,{label:"Providers",rows:Os(i,o),rowKey:a=>a.peerId,selectedKey:(l==null?void 0:l.peerId)??null,onRowClick:a=>le(ws("providers",a.peerId)),rowLabel:a=>Y(a),actions:a=>[o.model!==""&&fs(u,a.peerId,o.model),{label:"Allow…",onSelect:()=>m({peer:a,kind:"allow"})},{label:"Prefer…",onSelect:()=>m({peer:a,kind:"prefer"})},{label:"Block…",tone:"danger",onSelect:()=>m({peer:a,kind:"block"})}],initialSort:{key:"trust",direction:"desc"},empty:s.jsx(re,{icon:s.jsx(ne.providers,{size:18}),title:i.length?"No providers match these filters":"No providers found yet",body:i.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"name",header:"Provider",sortValue:a=>a.displayName??a.peerId,render:a=>s.jsxs("div",{className:"gc-cell-lines",children:[s.jsx("div",{className:"gc-strong gc-ellipsis",title:a.displayName??a.peerId,children:Y(a)}),a.displayName&&s.jsx("div",{className:"gc-muted gc-ellipsis",children:s.jsx(be,{title:a.peerId,children:A(a.peerId,6,4)})}),s.jsx(qs,{peer:a,model:o.model})]}),after:a=>s.jsx(gs,{value:a.peerId,label:`Copy peer id ${a.peerId}`})},{key:"identity",header:"Domain / GitHub",secondary:!0,render:a=>{var b;return(b=a.verificationLinks)!=null&&b.length?s.jsx($e,{links:a.verificationLinks}):s.jsx("span",{className:"gc-muted",children:"—"})}},{key:"models",header:"Models",secondary:!0,optional:!0,render:a=>s.jsx("span",{className:"gc-muted",children:a.services.length})},{key:"input",header:"Input $/M",align:"right",sortValue:a=>Bs(a,o.model),render:a=>oe(V(a,"inputUsdPerMillion",o.model))},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:a=>Es(a,o.model),render:a=>oe(V(a,"outputUsdPerMillion",o.model))},{key:"trust",header:"Trust",align:"right",sortValue:a=>a.trustScore,render:a=>ue(a.trustScore)},...h?[{key:"reputation",header:"Reputation",align:"right",secondary:!0,optional:!0,sortValue:a=>a.reputationScore,render:a=>ue(a.reputationScore)}]:[],{key:"firstToken",header:"First token",align:"right",secondary:!0,optional:!0,sortValue:a=>a.firstTokenMsP50,render:a=>ke(a.firstTokenMsP50)},{key:"speed",header:"Speed",align:"right",secondary:!0,optional:!0,sortValue:a=>a.tokensPerSecondP50,render:a=>xe(a.tokensPerSecondP50)},{key:"usage",header:"Your 24h",align:"right",secondary:!0,sortValue:a=>a.requests24h,render:a=>je(a.requests24h)}]})})}),s.jsxs("p",{className:"gc-fineprint",children:["Seller lists group sellers that routing rules allow or block together:"," ",ps("routing",e)?s.jsx(Ie,{to:"routing",children:"Routing → Seller lists"}):s.jsx(xs,{peers:n.data,label:"See seller lists"}),"."]})]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(ys,{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(Ce,{size:"sm",type:"search","aria-label":"Search providers",placeholder:"Search name, peer id or model",value:o.search,onChange:i=>p("search",i.target.value)}),s.jsx(N,{size:"sm","aria-label":"Filter by model",value:o.model,onChange:i=>p("model",i),options:[{value:"",label:"All models"},...k.map(i=>({value:i,label:i}))]}),s.jsx(Q,{checked:o.linked,onChange:i=>p("linked",i),label:"Domain or GitHub"}),s.jsx(Q,{checked:o.tee,onChange:i=>p("tee",i),label:"TEE"}),s.jsx(Q,{checked:o.free,onChange:i=>p("free",i),label:"Free"})]}),s.jsx(ks,{list:$,panel:w,onClose:()=>le("providers"),closeLabel:"Close provider"}),d&&s.jsx(Le,{peer:d.peer,action:d.kind,peers:n.data,onClose:()=>m(null)})]})}export{lt as default};
@@ -1 +0,0 @@
1
- import{r as f,j as e,B as N,I as D,C as H,T as ue,L as ae,E as ne,b2 as he,v as T,u as K,a as re,bc as oe,bd as ie,b as B,be as J,c as le,d as pe,b5 as ce,n as $,o as A,af as Y,e as ge,P as me,F as ye,bf as fe,bg as xe,aR as we,bh as E,bi as je,bj as V,l as X,O as I,f as q,q as z,bk as Z,i as ve,G as ke,bl as M,bm as be,bn as Ce,aT as Se}from"./index-DPXW_JSn.js";import{a as _e,d as Ne}from"./PolicyField-ldIq_Yw-.js";import{e as Pe,P as Le,a as Fe,p as U,b as Re}from"./PolicyEditor-COREmE0O.js";import{M as Ee}from"./SidePanel-BFQArkoa.js";import{B as ee}from"./BrandIcon-6gq42Dg-.js";import{S as Me,l as $e,s as qe}from"./stored-e0tX90bC.js";import{S as se}from"./SelectField-m1sMIgMa.js";import"./PeerPicker-CcMSXxY3.js";import"./DataTable-BCgVRqY6.js";import"./Segmented-DYnoemT9.js";import"./roving-DkptacxO.js";import"./Switch-Db8Sm64J.js";import"./Disclosure-CQMtWM0M.js";import"./selection-BV37SUs_.js";function ze(t,r){if(!r)return!0;const a=r.toLowerCase();return[t.id,t.name,...t.aliases,...t.tags].some(c=>c.toLowerCase().includes(a))}function Oe({models:t,loading:r,value:a,onChange:c,favorites:n=[],label:l="Model"}){const[k,x]=f.useState(!1),[h,p]=f.useState(""),u=(t==null?void 0:t.find(s=>s.id===a))??null,w=f.useMemo(()=>new Set(n.map(s=>s.toLowerCase())),[n]),o=f.useMemo(()=>[...t??[]].filter(s=>ze(s,h.trim())).sort((s,g)=>Number(w.has(g.id.toLowerCase()))-Number(w.has(s.id.toLowerCase()))||g.offers.length-s.offers.length||s.name.localeCompare(g.name)),[t,h,w]),m=s=>{c(s),x(!1),p("")};return e.jsxs(e.Fragment,{children:[e.jsxs(N,{variant:"outline",size:"sm",className:"gc-model-chooser","aria-label":`${l}: ${(u==null?void 0:u.name)??a??"none"}`,onClick:()=>x(!0),children:[e.jsx("span",{className:"gc-model-chooser__mark","aria-hidden":"true",children:u?e.jsx(ee,{name:u.id,hints:[u.name],size:16}):e.jsx(D.models,{size:15})}),e.jsx("span",{className:"gc-ellipsis",children:(u==null?void 0:u.name)??a??"Choose a model"}),e.jsx("span",{className:"gc-model-chooser__caret","aria-hidden":"true",children:e.jsx(D.down,{size:14})})]}),e.jsx(H,{isOpen:k,onClose:()=>x(!1),title:"Choose a model",size:"md",children:e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx(ue,{size:"sm",type:"search",autoFocus:!0,"aria-label":"Search models",placeholder:"Search by name, id or tag",value:h,onChange:s=>p(s.target.value),onKeyDown:s=>{s.key==="Enter"&&o[0]&&m(o[0].id)}}),r?e.jsx(ae,{rows:5}):o.length===0?e.jsx(ne,{title:"No model matches"}):e.jsx("ul",{className:"gc-choice-list","aria-label":"Models",children:o.map(s=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:s.id===a?"gc-choice gc-choice--on":"gc-choice",onClick:()=>m(s.id),children:[e.jsx(ee,{name:s.id,hints:[s.name],size:18}),e.jsxs("span",{className:"gc-choice__main",children:[e.jsxs("span",{className:"gc-choice__title",children:[s.name,w.has(s.id.toLowerCase())&&e.jsx(D.starFilled,{size:12})]}),e.jsxs("span",{className:"gc-choice__meta",children:[s.name!==s.id&&e.jsx("code",{children:s.id}),e.jsx("span",{children:Ee[s.type]}),e.jsxs("span",{children:[s.offers.length," provider",s.offers.length===1?"":"s"]}),s.inputUsdPerMillion&&e.jsxs("span",{children:[he(s.inputUsdPerMillion),"/M in"]})]})]}),s.free&&e.jsx(T,{tone:"success",children:"Free"})]})},s.id))})]})})]})}const de={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 Te(t,r,a,c){return t==="key"?(r??[]).filter(n=>n.status==="active").map(n=>({value:n.id,label:n.label})):t==="member"?(a??[]).map(({member:n})=>({value:n.id,label:n.label})):t==="preset"?(c??[]).map(n=>({value:n.slug,label:n.name})):[]}function Ae(t,r){return!t.model||t.target!=="workspace"&&!t.targetId?null:{model:t.model,workspace:r,...t.target!=="workspace"?{[t.target]:t.targetId}:{}}}function Ke({exclusions:t}){return t.length===0?null:e.jsx("span",{className:"gc-fineprint",children:t.map((r,a)=>e.jsxs("span",{children:[a>0?"; ":"",e.jsx("strong",{children:de[r.level]})," ",r.rule]},`${r.level}-${a}`))})}function Be({state:t,onChange:r,preview:a}){const{workspace:c,viewer:n}=K(),l=re(),k=oe(),x=ie(),h=B(),p=J(),u=le(l,t.target==="key"),w=pe(c.id,t.target==="member"),o=ce(c.id,t.target==="preset"),m=Te(t.target,u.data,w.data,o.data),s=a.data,g=(s==null?void 0:s.candidates.filter(i=>i.eligible).length)??0,y=s&&!s.modelAllowed?s.sources.filter(i=>{var v;return((v=i.policy)==null?void 0:v.allowedModels)&&!i.policy.allowedModels.some(j=>j.toLowerCase()===s.model.toLowerCase())}):[];return e.jsxs("div",{className:"gc-stack",children:[e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(Oe,{models:k.data,loading:k.isLoading,value:t.model,favorites:x.data,onChange:i=>r({...t,model:i})}),e.jsx(se,{size:"sm","aria-label":"Request from",value:t.target,onChange:i=>r({...t,target:i,targetId:""}),options:[{value:"workspace",label:`From workspace ${c.name}`},{value:"key",label:"From a key"},...$(n)?[{value:"member",label:"From a member"}]:[],{value:"preset",label:"With a preset"}]}),t.target!=="workspace"&&e.jsx(se,{size:"sm","aria-label":`Choose a ${t.target}`,value:t.targetId,onChange:i=>r({...t,targetId:i}),options:[{value:"",label:`Choose a ${t.target}`},...m]})]}),a.error?e.jsx(A,{error:a.error}):null,!t.model&&e.jsx(ne,{title:"Pick a model",body:"The preview shows the sellers a request for it would use."}),s&&!s.modelAllowed&&e.jsx(Y,{tone:"danger",title:`${s.model} is not allowed`,children:y.length?e.jsxs(e.Fragment,{children:[y.map(i=>de[i.level]).join(" and ")," only allow",y.length===1?"s":""," ",y[0].policy.allowedModels.join(", ")||"no model",". Requests for ",s.model," get a 403."]}):e.jsxs(e.Fragment,{children:["Requests for ",s.model," get a 403."]})}),s&&s.modelAllowed&&e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsxs("p",{className:"gc-try__summary",children:[e.jsxs(T,{tone:g>0?"success":"warning",children:[g," of ",s.candidates.length]})," ",g>0?`sellers can serve ${s.model}.`:`No seller can serve ${s.model} with these rules.`]}),e.jsx(Me,{title:"Sellers, in the order they are tried",preview:s,loading:a.isFetching&&!s,skippedOpen:!0,explainSkipped:i=>e.jsx(Ke,{exclusions:Pe(s,i,h.data,p.data??[])})})]})]})}const F={gateway:{title:"Gateway default",description:()=>"Set by organization admins. Applies to every request through this gateway."},org:{title:"Organization policy",description:t=>`Set by organization admins for the ${t} workspace. Workspace admins cannot loosen it.`},workspace:{title:"Workspace policy",description:t=>`Set by ${t}'s admins for their own keys.`}},Q=(t,r)=>JSON.stringify(t)===JSON.stringify(r);function O({index:t,title:r,who:a,sentences:c,empty:n="No rules of its own.",impact:l,badge:k,action:x,result:h}){return e.jsxs("li",{className:h?"gc-funnel__step gc-funnel__step--result":"gc-funnel__step",children:[e.jsx("span",{className:"gc-funnel__index","aria-hidden":"true",children:t}),e.jsxs("div",{className:"gc-funnel__body",children:[e.jsxs("div",{className:"gc-funnel__head",children:[e.jsx("span",{className:"gc-funnel__title",children:r}),k,x&&e.jsx("span",{className:"gc-funnel__action",children:x})]}),e.jsx("div",{className:"gc-fineprint",children:a}),c.length>0?e.jsx("ul",{className:"gc-funnel__rules",children:c.map(p=>e.jsx("li",{children:p},p))}):e.jsx("p",{className:"gc-funnel__none",children:n}),l&&e.jsx("p",{className:l.excluded>0?"gc-funnel__impact gc-funnel__impact--on":"gc-funnel__impact",children:l.excluded>0?`Keeps ${l.excluded} of ${l.total} seller${l.total===1?"":"s"} of ${l.model} out.`:`Keeps no seller of ${l.model} out.`})]})]})}function G({index:t,layer:r,source:a,parent:c,canEdit:n,impact:l,onSave:k}){const{workspace:x}=K(),h=ke(),p=B(),u=J(),w=_e(),[o,m]=f.useState(()=>M(a)),[s,g]=f.useState(()=>M(a)),[y,i]=f.useState(null),[v,j]=f.useState(!1),S=f.useMemo(()=>M(a),[a]),b=!Q(o,s);f.useEffect(()=>{Q(S,s)||(!b||Q(S,o)?(m(S),g(S),i(null)):i(S))},[S]);const _=be({mutationFn:async()=>{const d=Ce(o,u.data??null);return await w.save([d],W=>k(d,W))===Se?null:d},onSuccess:d=>{if(!d)return;const C=M(d);m(C),g(C),i(null),j(!1),h(`${F[r].title} saved`)}}),P=Ne(o,u.data??null),R=b?P.policy:a,L=!a||Object.keys(a).length===0;return e.jsxs(e.Fragment,{children:[e.jsx(O,{index:t,title:F[r].title,who:F[r].description(x.name),sentences:b&&P.error?[]:U(R,p.data,u.data??[]),empty:b&&P.error?"Has an invalid setting; open it to fix.":"No rules of its own: passes on everything above.",impact:l,badge:b?e.jsx(T,{tone:"warning",children:"Unsaved changes"}):n?void 0:e.jsx(T,{children:"Read only"}),action:e.jsx(N,{size:"sm",variant:n&&L?"outline":"ghost",onClick:()=>j(!0),children:n?L?"Add rules":"Edit":"View"})}),y&&n&&!v&&e.jsx("li",{className:"gc-funnel__note",children:e.jsx(Y,{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(H,{isOpen:v,onClose:()=>j(!1),size:"xl",title:F[r].title,subtitle:F[r].description(x.name),footer:n?e.jsxs(e.Fragment,{children:[P.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:P.error}),e.jsx(N,{variant:"ghost",disabled:!b,onClick:()=>{m(s),i(null)},children:"Discard changes"}),e.jsx(N,{disabled:_.isPending||!b,onClick:()=>_.mutate(),children:_.isPending?"Saving…":"Save policy"})]}):e.jsx(N,{variant:"outline",onClick:()=>j(!1),children:"Close"}),children:e.jsxs("div",{className:"gc-stack",children:[y&&n&&e.jsx(Y,{tone:"warning",title:"Changed elsewhere",action:e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(N,{size:"sm",variant:"outline",onClick:()=>{m(y),g(y),i(null)},children:"Reload"}),e.jsx(N,{size:"sm",variant:"ghost",onClick:()=>{g(y),i(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."}),_.error?e.jsx(A,{error:_.error,title:"Could not save"}):null,e.jsx(Re,{value:o,onChange:m,peers:p.data,lists:u.data??[],parent:c,disabled:!n})]})}),w.dialog]})}function We({preview:t}){var R,L;const{workspace:r,viewer:a}=K(),c=ye(),n=re(),l=B(),k=J(),x=fe(),h=xe(),p=we(r.id),u=le(n),w=ce(r.id),o=k.data??[],m=h.data?E(h.data,o):null,s=((R=p.data)==null?void 0:R.orgRoutingPolicy)??null,g=((L=p.data)==null?void 0:L.routingPolicy)??null,y=f.useMemo(()=>je(x.data),[x.data]),i=f.useMemo(()=>V(y,m,s&&E(s,o),g&&E(g,o)),[y,m,s,g,o]),v=f.useMemo(()=>Fe(t,l.data,o),[t,l.data,o]),j=(...d)=>t&&t.modelAllowed?{model:t.model,total:t.candidates.length,excluded:d.reduce((C,W)=>C+(v.get(W)??0),0)}:null;if(h.isLoading||p.isLoading)return e.jsx(X,{title:"Rules that apply",children:e.jsx(ae,{rows:6})});if(h.error)return e.jsx(A,{error:h.error,onRetry:()=>void h.refetch()});if(p.error)return e.jsx(A,{error:p.error,onRetry:()=>void p.refetch()});const S=async()=>{await c.invalidateQueries({queryKey:z.group("workspaces")}),await c.invalidateQueries({queryKey:z.group("routing")})},b=(u.data??[]).filter(d=>d.status==="active"&&d.routingPolicy).length,_=(w.data??[]).filter(d=>d.routingPolicy).length,P=[b?`${b} key${b===1?" has its":"s have their"} own rules.`:null,_?`${_} preset${_===1?" has":"s have"} rules.`:null].filter(d=>d!==null);return e.jsx(X,{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(O,{index:1,title:"Buyer config",who:e.jsxs(e.Fragment,{children:["The buyer's own limits",$(a)?e.jsxs(e.Fragment,{children:[", set under ",e.jsx(I,{to:"settings",children:"Settings"})]}):"",". Everything below can only narrow them."]}),sentences:U(y,l.data,o),empty:"No limits.",impact:j("buyer")}),e.jsx(G,{index:2,layer:"gateway",source:h.data??null,parent:y,canEdit:$(a),impact:j("gateway"),onSave:async(d,C)=>{await q.network.setGatewayPolicy(d,C),await c.invalidateQueries({queryKey:z.group("routing")})}}),e.jsx(G,{index:3,layer:"org",source:s,parent:m,canEdit:$(a),impact:j("workspace-org"),onSave:async(d,C)=>{await q.workspaces.update(r.id,{orgRoutingPolicy:Z(d)},C),await S()}}),e.jsx(G,{index:4,layer:"workspace",source:g,parent:V(m,s&&E(s,o)),canEdit:ve(a),impact:j("workspace"),onSave:async(d,C)=>{await q.workspaces.update(r.id,{routingPolicy:Z(d)},C),await S()}}),e.jsx(O,{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(I,{to:"keys",children:"Keys"})," and ",e.jsx(I,{to:"presets",children:"Presets"}),"."]}),sentences:P,empty:"None in this workspace narrows it.",impact:j("member","key","key-owner","preset")}),e.jsx(O,{index:"=",result:!0,title:`Effective for ${r.name}`,who:"What every key in this workspace gets before its own rules.",sentences:U(i,l.data,o),empty:"No rules: every seller the network offers."})]})})}const te="antseed-console-routing:try";function as(){var m;const{workspace:t}=K(),r=B(),a=oe(),c=ie(),[n,l]=f.useState(()=>({target:"workspace",targetId:"",model:$e(te,null)}));f.useEffect(()=>{qe(te,n.model)},[n.model]),f.useEffect(()=>{var y,i;if(n.model||!((y=a.data)!=null&&y.length))return;const s=(i=c.data)==null?void 0:i.find(v=>a.data.some(j=>j.id===v)),g=[...a.data].filter(v=>v.type==="text").sort((v,j)=>j.offers.length-v.offers.length)[0]??a.data[0];l(v=>({...v,model:s??g.id}))},[a.data,c.data,n.model]);const[k,x]=f.useState(!1),[h,p]=f.useState(!1),u=()=>{p(!0),x(!0)},w=h?Ae(n,t.id):null,o=ge({queryKey:z.routePreview(w??{}),queryFn:()=>q.network.routePreview(w),enabled:w!==null,staleTime:15e3});return e.jsxs("div",{className:"gc-page",children:[e.jsx(me,{title:"Routing",description:"The rules that decide which sellers serve your requests. Try a request to see where one for a model goes, and why.",actions:e.jsx(N,{variant:"brand",onClick:u,children:"Try a request"})}),e.jsx(We,{preview:w&&((m=o.data)==null?void 0:m.model)===n.model?o.data:void 0}),e.jsx(Le,{peers:r.data}),e.jsx(H,{isOpen:k,onClose:()=>x(!1),size:"xl",title:"Try a request",subtitle:"Pick a model to see which sellers a request goes to, in what order, and what keeps the others out.",children:e.jsx(Be,{state:n,onChange:l,preview:{data:w?o.data:void 0,isFetching:o.isFetching,error:o.error}})})]})}export{as as default};
@@ -1 +0,0 @@
1
- import{b2 as c,b4 as l,r as o,j as n,W as u}from"./index-DPXW_JSn.js";const m={text:"Text",image:"Image",video:"Video",decision:"Decision"},g={toolUse:"Tool use",reasoning:"Reasoning",structuredOutput:"Structured output",vision:"Vision"};function p(i,s){const t=s.trim().toLowerCase(),a=i??[];return a.find(r=>r.id.toLowerCase()===t)??a.find(r=>r.aliases.some(e=>e.toLowerCase()===t))??null}function f(i){if(i.usdPerImage)return i.usdPerImage.max===0?"Free":`${c(i.usdPerImage)} per image`;const{inputUsdPerMillion:s,outputUsdPerMillion:t}=i;return s===null&&t===null?i.free?"Free":"No price advertised":(s??0)===0&&(t??0)===0?"Free":`${l(s)} in · ${l(t)} out /M`}function x({list:i,panel:s,onClose:t,closeLabel:a="Close panel"}){const r=o.useRef(null);s&&(r.current=s);const e=s??r.current;return n.jsxs(n.Fragment,{children:[i,n.jsx(u,{isOpen:s!==null,onClose:t,closeLabel:a,className:"gc-side-panel",title:(e==null?void 0:e.title)??"",subtitle:e==null?void 0:e.subtitle,eyebrow:e==null?void 0:e.eyebrow,actions:e==null?void 0:e.actions,children:e==null?void 0:e.body})]})}function _({title:i,actions:s,children:t}){return n.jsxs("section",{className:"gc-panel-section",children:[n.jsxs("div",{className:"gc-panel-section__head",children:[n.jsx("h3",{className:"gc-panel-section__title",children:i}),s&&n.jsx("div",{className:"gc-panel-section__actions",children:s})]}),t]})}function j({title:i,meta:s,badges:t,actions:a,selected:r}){return n.jsxs("li",{className:r?"gc-panel-row gc-panel-row--on":"gc-panel-row",children:[n.jsxs("div",{className:"gc-panel-row__main",children:[n.jsx("div",{className:"gc-panel-row__title",children:i}),s&&n.jsx("div",{className:"gc-panel-row__meta",children:s}),t]}),a&&n.jsx("div",{className:"gc-panel-row__actions",children:a})]})}export{g as C,m as M,_ as P,x as S,j as a,p as f,f as p};
@@ -1 +0,0 @@
1
- import{r as e,j as s}from"./index-DPXW_JSn.js";function _({checked:a,onChange:r,label:l,description:t,disabled:n,className:o}){const c=e.useId(),i=e.useId();return s.jsxs("div",{className:["as-switch",o].filter(Boolean).join(" "),children:[s.jsx("button",{id:c,type:"button",role:"switch","aria-checked":a,"aria-describedby":t?i:void 0,disabled:n,className:a?"as-switch__track as-switch__track--on":"as-switch__track",onClick:()=>r(!a),children:s.jsx("span",{className:"as-switch__thumb"})}),s.jsxs("label",{htmlFor:c,className:"as-switch__text",children:[s.jsx("span",{className:"as-switch__label",children:l}),t&&s.jsx("span",{id:i,className:"as-switch__desc",children:t})]})]})}export{_ as S};
@@ -1 +0,0 @@
1
- import{u as S,n as W,p as L,s as I,r as p,t as A,j as s,P as O,B as b,I as z,l as B,Q as F,v as w,M as C,w as N,x as M,y as D,z as E,A as T,C as q,D as V,q as f,f as v,T as P,o as R}from"./index-DPXW_JSn.js";import{u as K,a as Q,P as _}from"./PolicyField-ldIq_Yw-.js";import{l as G,d as H,L as U}from"./limits-uCwhqY-O.js";import{D as J}from"./DataTable-BCgVRqY6.js";import"./PolicyEditor-COREmE0O.js";import"./PeerPicker-CcMSXxY3.js";import"./SelectField-m1sMIgMa.js";import"./Segmented-DYnoemT9.js";import"./roving-DkptacxO.js";import"./Switch-Db8Sm64J.js";import"./Disclosure-CQMtWM0M.js";function X({initial:r,onDone:d}){const{viewer:g}=S(),h=W(g),[i,k]=p.useState((r==null?void 0:r.name)??""),[y,x]=p.useState(G(r==null?void 0:r.limits)),[m,c]=p.useState(""),n=K(r==null?void 0:r.routingPolicy),o=Q(),l=A({mutationFn:()=>{const t={name:i.trim(),limits:H(y),routingPolicy:n.build()};return o.save([t.routingPolicy],e=>{if(r){const{limits:a,...j}=t;return v.workspaces.update(r.id,h?{...j,limits:a}:j,e)}return v.workspaces.create(m.trim()?{...t,buyerIdentity:m.trim()}:t,e)})},onSuccess:d,invalidate:[f.group("workspaces"),f.me],toast:r?"Workspace saved":"Workspace created"}),u=r?"Save":"Create workspace";return s.jsxs("form",{className:"gc-stack",onSubmit:t=>{t.preventDefault(),l.mutate()},children:[s.jsx(P,{label:"Name",required:!0,value:i,onChange:t=>k(t.target.value)}),!r&&s.jsx(P,{label:"Buyer identity (optional)",value:m,onChange:t=>c(t.target.value),hint:"Leave blank to create a new wallet for this workspace. Enter an existing identity name to reuse its wallet."}),h?s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label gc-label-row",children:"Workspace budgets (USD)"}),s.jsx(U,{idPrefix:"ws-limit",value:y,onChange:x})]}):s.jsxs("p",{className:"gc-muted",children:["Budgets: ",E(r==null?void 0:r.limits),". Organization admins set them."]}),s.jsx(_,{draft:n.draft,setDraft:n.setDraft}),l.error?s.jsx(R,{error:l.error,title:"Could not save"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(b,{variant:"ghost",onClick:d,children:"Cancel"}),s.jsx(b,{type:"submit",disabled:l.isPending||!i.trim(),children:l.isPending?"Saving…":u})]}),o.dialog]})}function ie(){const{viewer:r,setWorkspaceId:d,workspace:g,me:h}=S(),i=W(r),k=t=>i||h.workspaces.some(e=>e.workspace.id===t.id&&e.role==="admin"),y=L(),x=I(),m=t=>{var e;return(e=x.data)==null?void 0:e.find(a=>a.workspaceId===t.id)},[c,n]=p.useState(null),[o,l]=p.useState(null),u=A({mutationFn:t=>v.workspaces.remove(t.id),onSuccess:()=>l(null),invalidate:[f.group("workspaces"),f.me]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(O,{title:"Workspaces",description:"Each workspace has its own wallet, budgets, routing policy, members and keys.",actions:i&&s.jsx(b,{variant:"brand",leadingIcon:s.jsx(z.plus,{size:14}),onClick:()=>n("new"),children:"New workspace"})}),s.jsx(B,{flush:!0,children:s.jsx(F,{query:y,children:t=>s.jsx(J,{label:"Workspaces",rows:t,rowKey:e=>e.id,rowLabel:e=>e.name,onRowClick:e=>k(e)&&n(e),actions:e=>[e.id!==g.id&&{label:"Open",onSelect:()=>d(e.id)},{label:"Members",onSelect:()=>{d(e.id),D("members")}},k(e)&&{label:"Edit",onSelect:()=>n(e)},i&&!e.isDefault&&{label:"Delete",tone:"danger",onSelect:()=>l(e)}],columns:[{key:"name",header:"Name",sortValue:e=>e.name,render:e=>s.jsxs("span",{className:"gc-strong",children:[e.name," ",e.isDefault&&s.jsx(w,{children:"Default"})," ",e.id===g.id&&s.jsx(w,{tone:"info",children:"Open"})]})},{key:"wallet",header:"Wallet",secondary:!0,render:e=>e.walletAddress?s.jsx(C,{title:e.walletAddress,children:N(e.walletAddress)}):s.jsx("span",{className:"gc-muted",children:e.buyerIdentity})},{key:"operator",header:"Authorized wallet",secondary:!0,render:e=>{const a=m(e);return a?a.relation===null?s.jsx("span",{className:"gc-muted",title:"The wallet or the chain could not be read",children:"unknown"}):M(a)?s.jsxs("span",{className:"gc-inline",children:[s.jsx(w,{tone:"warning",children:"Not set"}),a.canAuthorize&&s.jsx(b,{variant:"link",size:"sm",onClick:j=>{j.stopPropagation(),d(e.id),D("wallet")},children:"Authorize"})]}):a.relation==="self"?s.jsx("span",{className:"gc-muted",children:"Workspace wallet"}):s.jsx(C,{title:a.operator??void 0,children:N(a.operator)}):s.jsx("span",{className:"gc-muted",children:x.isLoading?"…":"—"})}},{key:"members",header:"Members",align:"right",secondary:!0,sortValue:e=>e.memberCount,render:e=>e.memberCount},{key:"keys",header:"Keys",align:"right",sortValue:e=>e.keyCount,render:e=>e.keyCount},{key:"limits",header:"Budgets",secondary:!0,optional:!0,render:e=>s.jsx("span",{className:"gc-muted",children:E(e.limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:e=>s.jsx("span",{className:"gc-muted",children:T(e.routingPolicy)})}]})})}),s.jsx(q,{isOpen:c!==null,onClose:()=>n(null),size:"lg",title:c==="new"?"New workspace":"Edit workspace",children:c!==null&&s.jsx(X,{initial:c==="new"?null:c,onDone:()=>n(null)})}),s.jsx(V,{isOpen:o!==null,busy:u.isPending,error:u.error,onClose:()=>{l(null),u.reset()},onConfirm:()=>o&&u.mutate(o),title:"Delete this workspace?",confirmLabel:"Delete workspace",body:s.jsxs(s.Fragment,{children:["Deleting ",s.jsx("strong",{children:o==null?void 0:o.name})," is only possible once it has no active keys and no balance. Withdraw funds and revoke keys first."]})})]})}export{ie as default};
@@ -1,3 +0,0 @@
1
- import{j as n,r as c}from"./index-DPXW_JSn.js";import{c as f}from"./Chat-C4DsUQG-.js";import{c as C}from"./bundle-full-Bo_XusKG.js";import"./SidePanel-BFQArkoa.js";import"./selection-BV37SUs_.js";import"./ModelDetails-Sgq3MjfG.js";import"./Tabs-CCabxVNK.js";import"./roving-DkptacxO.js";import"./stored-e0tX90bC.js";import"./Disclosure-CQMtWM0M.js";import"./VerificationLinks-CWyl6ZEp.js";import"./SelectField-m1sMIgMa.js";import"./clsx-B-dksMZM.js";const j=e=>e&&e&1,v=e=>e&&e&2,N=e=>e&&e&4,T=e=>e.map((t,s)=>({key:`line-${s}`,tokens:t.map((o,r)=>({key:`line-${s}-${r}`,token:o}))})),w=({token:e})=>n.jsx("span",{className:"dark:!bg-[var(--shiki-dark-bg)] dark:!text-[var(--shiki-dark)]",style:{backgroundColor:e.bgColor,color:e.color,fontStyle:j(e.fontStyle)?"italic":void 0,fontWeight:v(e.fontStyle)?"bold":void 0,textDecoration:N(e.fontStyle)?"underline":void 0,...e.htmlStyle},children:e.content}),S=f("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-8","before:mr-4","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),B=({keyedLine:e,showLineNumbers:t})=>n.jsx("span",{className:t?S:"block",children:e.tokens.length===0?`
2
- `:e.tokens.map(({token:s,key:o})=>n.jsx(w,{token:s},o))}),k=new Map,g=new Map,h=new Map,M=(e,t)=>{const s=e.slice(0,100),o=e.length>100?e.slice(-100):"";return`${t}:${e.length}:${s}:${o}`},L=e=>{const t=k.get(e);if(t)return t;const s=C({langs:[e],themes:["github-light","github-dark"]});return k.set(e,s),s},$=e=>({bg:"transparent",fg:"inherit",tokens:e.split(`
3
- `).map(t=>t===""?[]:[{color:"inherit",content:t}])}),p=(e,t,s)=>{var i;const o=M(e,t),r=g.get(o);return r||(s&&(h.has(o)||h.set(o,new Set),(i=h.get(o))==null||i.add(s)),L(t).then(a=>{const u=a.getLoadedLanguages().includes(t)?t:"text",l=a.codeToTokens(e,{lang:u,themes:{dark:"github-dark",light:"github-light"}}),d={bg:l.bg??"transparent",fg:l.fg??"inherit",tokens:l.tokens};g.set(o,d);const b=h.get(o);if(b){for(const y of b)y(d);h.delete(o)}}).catch(a=>{console.error("Failed to highlight code:",a),h.delete(o)}),null)},x=c.memo(({tokenized:e,showLineNumbers:t,className:s})=>{const o=c.useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]),r=c.useMemo(()=>T(e.tokens),[e.tokens]);return n.jsx("pre",{className:f("dark:!bg-[var(--shiki-dark-bg)] dark:!text-[var(--shiki-dark)] m-0 p-4 text-sm",s),style:o,children:n.jsx("code",{className:f("font-mono text-sm",t&&"[counter-increment:line_0] [counter-reset:line]"),children:r.map(i=>n.jsx(B,{keyedLine:i,showLineNumbers:t},i.key))})})},(e,t)=>e.tokenized===t.tokenized&&e.showLineNumbers===t.showLineNumbers&&e.className===t.className);x.displayName="CodeBlockBody";const E=({className:e,language:t,style:s,...o})=>n.jsx("div",{className:f("group relative w-full overflow-hidden rounded-md border bg-background text-foreground",e),"data-language":t,style:{containIntrinsicSize:"auto 200px",contentVisibility:"auto",...s},...o}),R=({code:e,language:t,showLineNumbers:s=!1})=>{const o=c.useMemo(()=>$(e),[e]),r=c.useMemo(()=>p(e,t)??o,[e,t,o]),[i,a]=c.useState(null),m=c.useRef({code:e,language:t});(m.current.code!==e||m.current.language!==t)&&(m.current={code:e,language:t},a(null)),c.useEffect(()=>{let l=!1;return p(e,t,d=>{l||a(d)}),()=>{l=!0}},[e,t]);const u=i??r;return n.jsx("div",{className:"relative overflow-auto",children:n.jsx(x,{showLineNumbers:s,tokenized:u})})},J=({code:e,language:t,showLineNumbers:s=!1,className:o,children:r,...i})=>n.jsxs(E,{className:o,language:t,...i,children:[r,n.jsx(R,{code:e,language:t,showLineNumbers:s})]});export{J as CodeBlock};
@@ -1,3 +0,0 @@
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 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-BaHsArCB.js";import{r as o,j}from"./index-DPXW_JSn.js";import"./bundle-full-Bo_XusKG.js";import"./clsx-B-dksMZM.js";import"./Chat-C4DsUQG-.js";import"./SidePanel-BFQArkoa.js";import"./selection-BV37SUs_.js";import"./ModelDetails-Sgq3MjfG.js";import"./Tabs-CCabxVNK.js";import"./roving-DkptacxO.js";import"./stored-e0tX90bC.js";import"./Disclosure-CQMtWM0M.js";import"./VerificationLinks-CWyl6ZEp.js";import"./SelectField-m1sMIgMa.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};