@antseed/gateway-console 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Activity-BHckTctH.js → Activity-BsmDMcni.js} +1 -1
- package/dist/assets/{Audit-CheQE0ki.js → Audit-TIDz29y6.js} +1 -1
- package/dist/assets/{ChainGate-BO2NzC31.js → ChainGate-Dvm-SUef.js} +1 -1
- package/dist/assets/{ChannelClose-ODGHySRH.js → ChannelClose-9Lq8KHLH.js} +1 -1
- package/dist/assets/{Charts-CrCKBk_i.js → Charts-DAh9h4sf.js} +1 -1
- package/dist/assets/Chat-Dtte195G.css +1 -0
- package/dist/assets/Chat-DznobJkE.js +220 -0
- package/dist/assets/{ConnectWallet-BqD3R1R9.js → ConnectWallet-DSqRjyNA.js} +1 -1
- package/dist/assets/{DataTable-B36eMErM.js → DataTable-CDFSD9Kq.js} +1 -1
- package/dist/assets/{Disclosure-DS6GTz8G.js → Disclosure-UjXa2WU7.js} +1 -1
- package/dist/assets/{KeyHolder-CG5sSLQK.js → KeyHolder-e5NvqLQn.js} +1 -1
- package/dist/assets/{Keys-Cxz0K09V.js → Keys-CxaYteT3.js} +1 -1
- package/dist/assets/{Logs-DV-trPqy.js → Logs-CNCQTTeZ.js} +1 -1
- package/dist/assets/{Members-Cp_3A-Dy.js → Members-Bme-PLUh.js} +1 -1
- package/dist/assets/{Migrate-BD-0-NY-.js → Migrate-I3FULNOQ.js} +1 -1
- package/dist/assets/{Models-DHeLeAiN.js → Models-Bt59XWgD.js} +1 -1
- package/dist/assets/{OperatorActions-Bety6436.js → OperatorActions-DTrUYN6Z.js} +1 -1
- package/dist/assets/{OperatorGateAlert-Jd5E0V_d.js → OperatorGateAlert-CCPFpK6Y.js} +1 -1
- package/dist/assets/{Overview-37mja3y-.js → Overview-zEyUG_qA.js} +1 -1
- package/dist/assets/PolicyEditor-BdoaX9gK.js +1 -0
- package/dist/assets/{PolicyField-D7O5D7fl.js → PolicyField-DIPl0B1x.js} +1 -1
- package/dist/assets/{Presets-CgfFG3fw.js → Presets-CoTmwoy_.js} +1 -1
- package/dist/assets/{Providers-sZFgSVHV.js → Providers-BxpNjH9s.js} +1 -1
- package/dist/assets/{RequestLog-BbR8E_9_.js → RequestLog-DhID_VN7.js} +1 -1
- package/dist/assets/{Rewards-CuWsg5m7.js → Rewards-XyWhpm9Z.js} +2 -2
- package/dist/assets/{RewardsClaim-CRgTiF93.js → RewardsClaim-BSNDTCMG.js} +1 -1
- package/dist/assets/{Routing-BebcQMko.js → Routing-Du8GLQCH.js} +1 -1
- package/dist/assets/{Segmented-C9jux-Mr.js → Segmented-Qx6JB6EU.js} +1 -1
- package/dist/assets/{SelectField-BSNXjRiC.js → SelectField-D8fxDUNO.js} +1 -1
- package/dist/assets/Settings-CvfS7lxA.js +7 -0
- package/dist/assets/{Switch-hSHNLapF.js → Switch-Ba56zux7.js} +1 -1
- package/dist/assets/{Tabs-Dle_Eq4t.js → Tabs-BmjCmD5T.js} +1 -1
- package/dist/assets/{TextAreaField-9B3_7w3L.js → TextAreaField-CF9_zjuC.js} +1 -1
- package/dist/assets/{UsageByModel-6qZIqVRY.js → UsageByModel-BBqXiIqo.js} +1 -1
- package/dist/assets/Wallet-DggtuX-0.js +9 -0
- package/dist/assets/{WalletConfirm-Dm8Lr6DT.js → WalletConfirm-BQCbOnNv.js} +1 -1
- package/dist/assets/{WalletFunding-CSVVBvPP.js → WalletFunding-CvDkcGVU.js} +1 -1
- package/dist/assets/{WalletSignIn-DLX6sQbD.js → WalletSignIn-B9g_MY0h.js} +1 -1
- package/dist/assets/{Workspaces-DZmGjFFI.js → Workspaces-DUn5iA_D.js} +1 -1
- package/dist/assets/{add-DXI2Cp6k.js → add-1gRRQJKT.js} +1 -1
- package/dist/assets/{all-wallets-LQt3S9MV.js → all-wallets-vhiMb1eR.js} +1 -1
- package/dist/assets/{app-store-CRiNXiqm.js → app-store-DFWwIQzp.js} +1 -1
- package/dist/assets/{apple-BXH3yGFL.js → apple-DgwSchgH.js} +1 -1
- package/dist/assets/{arrow-bottom-D3S4BxFo.js → arrow-bottom-Cq4YmOQg.js} +1 -1
- package/dist/assets/{arrow-bottom-circle-Zukia-8I.js → arrow-bottom-circle-PbZ344lB.js} +1 -1
- package/dist/assets/{arrow-left-DHP2QErV.js → arrow-left-BLB_Dkvm.js} +1 -1
- package/dist/assets/{arrow-right-Co_bi7Vn.js → arrow-right-DpKTBsRx.js} +1 -1
- package/dist/assets/{arrow-top-D3hEtyvW.js → arrow-top-DSAScZJW.js} +1 -1
- package/dist/assets/{bank-CZ3b6K7o.js → bank-wStsFuNb.js} +1 -1
- package/dist/assets/{basic-nJtiapU4.js → basic-CsVGrHuh.js} +1 -1
- package/dist/assets/{browser-CRgINMXV.js → browser-DlwffXFC.js} +1 -1
- package/dist/assets/bundle-full-sn1k_IQV.js +13 -0
- package/dist/assets/{card-ZwByuY3V.js → card-pVIbVhmB.js} +1 -1
- package/dist/assets/{ccip-DpVxliwq.js → ccip-DAldItLP.js} +1 -1
- package/dist/assets/{checkmark-BS_v4cXd.js → checkmark-BpTw56ma.js} +1 -1
- package/dist/assets/{checkmark-bold-gJWlj_By.js → checkmark-bold-kTaP3XxB.js} +1 -1
- package/dist/assets/{chevron-bottom-DB25HS1C.js → chevron-bottom-bMFNlOX_.js} +1 -1
- package/dist/assets/{chevron-left-nQo8fTuX.js → chevron-left-BvUO5nig.js} +1 -1
- package/dist/assets/{chevron-right-D18s-hRU.js → chevron-right-CsjPzxKK.js} +1 -1
- package/dist/assets/{chevron-top-Dj1C_edY.js → chevron-top-k0xp7Can.js} +1 -1
- package/dist/assets/{chrome-store-BM7Ft7N1.js → chrome-store-PaJUtH_w.js} +1 -1
- package/dist/assets/{clock-Gp9Oq3uQ.js → clock-CMJ0qXc5.js} +1 -1
- package/dist/assets/{close-CvZGqQc2.js → close-D_Xc77Yh.js} +1 -1
- package/dist/assets/code-block-xCUZ4Wg2.js +3 -0
- package/dist/assets/{coinPlaceholder-CxGDG0FR.js → coinPlaceholder-D-kUAKbs.js} +1 -1
- package/dist/assets/{compass-D_QgO5G3.js → compass-CGS5aeKg.js} +1 -1
- package/dist/assets/{copy-ClteGnkV.js → copy-BES3eNqf.js} +1 -1
- package/dist/assets/{core-BGzEHhOa.js → core-Cw7VIz-a.js} +3 -3
- package/dist/assets/cursor-BG-gmA3f.js +3 -0
- package/dist/assets/{cursor-transparent-D2iBVjlE.js → cursor-transparent-Dqx5HyjH.js} +1 -1
- package/dist/assets/{desktop-C7ehLazj.js → desktop-83z42M8J.js} +1 -1
- package/dist/assets/{disconnect-DfCN-2S3.js → disconnect-D49VmdOl.js} +1 -1
- package/dist/assets/{discord-wpQmn3Vb.js → discord-MHKJZWwF.js} +1 -1
- package/dist/assets/{en_US-Y4ZOVFV4-BuTiJwkw.js → en_US-Y4ZOVFV4-CzjJ6dvA.js} +4 -4
- package/dist/assets/{etherscan-2pj2VsLB.js → etherscan-_rlcuy0M.js} +1 -1
- package/dist/assets/{exclamation-triangle-D3kTTS0o.js → exclamation-triangle-Bw5MhRmd.js} +1 -1
- package/dist/assets/{extension-BaGxTMr_.js → extension-D7frsaxu.js} +1 -1
- package/dist/assets/{external-link-DPkcev-7.js → external-link-C7l3-PhY.js} +1 -1
- package/dist/assets/{facebook-B-3uuPNQ.js → facebook-D2S1lToP.js} +1 -1
- package/dist/assets/{farcaster-CP4KBXgf.js → farcaster-BKD1k1GK.js} +1 -1
- package/dist/assets/{filters-DayLkPQN.js → filters-LINb1X7z.js} +1 -1
- package/dist/assets/{github-nb58vW5j.js → github-CanBnK1J.js} +1 -1
- package/dist/assets/{google-Cbr4pP2d.js → google-DcyjnYXY.js} +1 -1
- package/dist/assets/{help-circle-dO8TgJbO.js → help-circle-EWFFZOKF.js} +1 -1
- package/dist/assets/highlighted-body-KQOG7T2V-4q_hgdCF.js +1 -0
- package/dist/assets/{id-FL_XAzzL.js → id-CwpQkL3B.js} +1 -1
- package/dist/assets/{image-D0cgJ5JG.js → image-Bru4L9C0.js} +1 -1
- package/dist/assets/{index-Bv4ef0pT.js → index-BTqmifYb.js} +1 -1
- package/dist/assets/{index-CWuVUb-3.js → index-CO2ldxDL.js} +3 -3
- package/dist/assets/index-D5ERwHFX.js +1 -0
- package/dist/assets/{index-DvqgpSC-.js → index-DI3oIpGN.js} +1 -1
- package/dist/assets/index-DqdaAEyo.js +91 -0
- package/dist/assets/{index-CqEPMnZS.css → index-M34IaZVB.css} +1 -1
- package/dist/assets/{index-Vg8tZZdB.js → index-mLThkLKM.js} +1 -1
- package/dist/assets/{index.es-D7XOFxw2.js → index.es-Dajqanx_.js} +4 -4
- package/dist/assets/{info-DtK2iYRv.js → info-BiKqTS2d.js} +1 -1
- package/dist/assets/{info-circle-D7UwRt4U.js → info-circle-BBN-kA77.js} +1 -1
- package/dist/assets/{lightbulb-ClVdo2zx.js → lightbulb-DOHEz8mA.js} +1 -1
- package/dist/assets/{limits-BjBtkRFh.js → limits-DETkh9Vy.js} +1 -1
- package/dist/assets/{mail-D7xIfGjE.js → mail-B58fLIk0.js} +1 -1
- package/dist/assets/mermaid-MCJ5UELQ-CNEVzFUk.js +562 -0
- package/dist/assets/{metamask-sdk-BFHzYYth.js → metamask-sdk-CgV17tbH.js} +1 -1
- package/dist/assets/{mobile-oyVoYDtW.js → mobile-Der0Vnyo.js} +1 -1
- package/dist/assets/{models-D5AfPpBK.js → models-Ben8ko6c.js} +1 -1
- package/dist/assets/{more-DWZmSEse.js → more-BoKgpjap.js} +1 -1
- package/dist/assets/{network-placeholder-DkrrPbIk.js → network-placeholder-DgO-AHV1.js} +1 -1
- package/dist/assets/{nftPlaceholder-y-NnnMjT.js → nftPlaceholder-DQN5ewFX.js} +1 -1
- package/dist/assets/{off-Bq6ESslh.js → off-M-ZEZL9r.js} +1 -1
- package/dist/assets/{play-store-BVSRtmaK.js → play-store-DGLOVnal.js} +1 -1
- package/dist/assets/{plus-CiV0r3Hz.js → plus-BiSIXTnl.js} +1 -1
- package/dist/assets/{qr-code-CQuLdjAg.js → qr-code-CqHp65c8.js} +1 -1
- package/dist/assets/{recycle-horizontal-Dz6rR748.js → recycle-horizontal-CRSsOzCz.js} +1 -1
- package/dist/assets/{refresh-DNo0Vden.js → refresh-CNcLCWXe.js} +1 -1
- package/dist/assets/{reown-logo-sOWGngZq.js → reown-logo-DHp9kF6o.js} +1 -1
- package/dist/assets/{search-rho6BP4J.js → search-Bk2sMNiB.js} +1 -1
- package/dist/assets/{secp256k1-eMq7yeYD.js → secp256k1-eRLZxtys.js} +1 -1
- package/dist/assets/{send-DxwNodDV.js → send-Ctv_HF2O.js} +1 -1
- package/dist/assets/{swapHorizontal-CJ1qgU06.js → swapHorizontal-zaD-84iv.js} +1 -1
- package/dist/assets/{swapHorizontalBold-G3QDMS0U.js → swapHorizontalBold-f_5MNh3F.js} +1 -1
- package/dist/assets/{swapHorizontalMedium-CRUvBpIN.js → swapHorizontalMedium-CnARNDiR.js} +1 -1
- package/dist/assets/{swapHorizontalRoundedBold-DOVIZTm_.js → swapHorizontalRoundedBold-BxdOAjIc.js} +1 -1
- package/dist/assets/{swapVertical-KviDiZLh.js → swapVertical-BS-jDYcd.js} +1 -1
- package/dist/assets/{telegram-96Q1zZ7u.js → telegram-DfO33sxQ.js} +1 -1
- package/dist/assets/{three-dots-CLIQcjDl.js → three-dots-K3AmCfOo.js} +1 -1
- package/dist/assets/{twitch-8bwY5wnt.js → twitch-DfjpmeLa.js} +1 -1
- package/dist/assets/{twitterIcon-yigFfTCz.js → twitterIcon-CXaUDkHK.js} +1 -1
- package/dist/assets/{usage-4421Rf6_.js → usage-CjxizGfE.js} +1 -1
- package/dist/assets/{useInfiniteQuery-DXLHm6RI.js → useInfiniteQuery-Dm7RR6wI.js} +1 -1
- package/dist/assets/{useTx-JDF5s1ox.js → useTx-BRRWrJlB.js} +1 -1
- package/dist/assets/{verify-BvV_kZ_V.js → verify-CplHry9Z.js} +1 -1
- package/dist/assets/{verify-filled-D31I1gjO.js → verify-filled-CLSOHfSX.js} +1 -1
- package/dist/assets/{w3m-modal-BSlq8p9f.js → w3m-modal-CQNWLiT9.js} +1 -1
- package/dist/assets/{wallet-CBsAqlQ7.js → wallet-C3roxttu.js} +1 -1
- package/dist/assets/{wallet-placeholder-DHTeowzX.js → wallet-placeholder-CC9q2-xU.js} +1 -1
- package/dist/assets/{walletconnect-CR_egxhB.js → walletconnect-Bnkz4udx.js} +1 -1
- package/dist/assets/{warning-circle-BP-YPvjB.js → warning-circle-Be9gSeqg.js} +1 -1
- package/dist/assets/{x-CpVuDSxb.js → x-5eg1spDB.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/PolicyEditor-B5BAs2vC.js +0 -1
- package/dist/assets/Settings-BLIkiFNw.js +0 -7
- package/dist/assets/Wallet-BbwYd9fm.js +0 -9
- package/dist/assets/ant-icon-zZhiTevn.svg +0 -25
- package/dist/assets/cursor-CrB_GPgJ.js +0 -3
- package/dist/assets/highlighted-body-KQOG7T2V-D_9pxxPW.js +0 -1
- package/dist/assets/index-BjRmy3XE.js +0 -91
- package/dist/assets/index-iM-80gy8.js +0 -1
- package/dist/assets/mermaid-MCJ5UELQ-BFJCTi2D.css +0 -1
- package/dist/assets/mermaid-MCJ5UELQ-DTUKqcxP.js +0 -793
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bW as qe,bh as pe,aI as Ve,u as X,a as fe,D as Ke,F as Ge,m as we,i as ye,r as p,O as Ye,b as ve,d as Qe,bX as We,bf as He,Y as U,bY as Je,bZ as Xe,e as L,ag as Ze,j as s,A as Z,ac as Y,n as ee,B as x,L as be,z as es,b9 as ss,s as xe,q as ke,k as je,Q as Pe,E as J,I as _,C as ts,T as q,v as F,M as Ce,ap as Se,t as N,a8 as ns,bU as $,ab as Ie,g as Ne,X as rs,b0 as $e,b_ as Ae,aS as as,b4 as os,b$ as ls,W as is,aU as cs,N as ds,aV as us,aW as ms,b2 as hs,b3 as gs,bl as ps,aY as fs,aZ as ws,a_ as ce,b6 as ys,x as de,a$ as vs,P as bs}from"./index-BjRmy3XE.js";import{p as Q,a as xs}from"./PolicyEditor-B5BAs2vC.js";import{S as A}from"./SelectField-BSNXjRiC.js";import{D as Le}from"./DataTable-B36eMErM.js";import{V as Fe,P as Me,b as ks,p as js,S as Ps}from"./models-D5AfPpBK.js";import{f as Cs}from"./ants-B38m9Phv.js";import{PresetForm as Ss}from"./Presets-CgfFG3fw.js";import{T as Is,a as Ns}from"./Tabs-Dle_Eq4t.js";import{S as W}from"./Switch-hSHNLapF.js";import"./Segmented-C9jux-Mr.js";import"./roving-DkptacxO.js";import"./Disclosure-DS6GTz8G.js";import"./index-iM-80gy8.js";import"./PolicyField-D7O5D7fl.js";import"./TextAreaField-9B3_7w3L.js";function Te(e,t="admin"){return t==="owner"&&Ve(e)?"ownerRoutingPolicy":"routingPolicy"}async function Ee(e,t){const n=(await e.keys.list({workspace:t.workspaceId})).find(a=>a.id===t.keyId);if(!n)throw new Error("That key no longer exists.");return n}async function De(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 n=(await e.members.list()).find(a=>a.id===t.memberId);if(!n)throw new Error("That member no longer exists.");return n.routingPolicy}case"key":{const n=await Ee(e,t);return n[Te(n,t.layer)]??null}}}async function $s(e,t,n,a){const o=a!=null&&a.confirmEmpty||a!=null&&a.acceptNarrowed?[a]:[];switch(t.kind){case"gateway":await e.network.setGatewayPolicy(n??{},...o);return;case"workspace-org":await e.workspaces.update(t.workspaceId,{orgRoutingPolicy:n},...o);return;case"workspace":await e.workspaces.update(t.workspaceId,{routingPolicy:n},...o);return;case"member":await e.members.update(t.memberId,{routingPolicy:n},...o);return;case"key":{const i=t.layer==="owner"?Te(await Ee(e,t),"owner"):"routingPolicy";await e.keys.update(t.keyId,{[i]:n},...o);return}}}const ue=e=>JSON.stringify(e??{},Object.keys(e??{}).sort());async function As(e,t,n,a,o,i){const m=await De(e,t),c=qe(m,n,a,o),g=ue(m)!==ue(c)||JSON.stringify(m??{})!==JSON.stringify(c);return g&&await $s(e,t,c,i),{before:m,after:c,changed:g}}function Ls(e,t,n){return e.kind==="key"?{model:t,key:e.keyId,workspace:e.workspaceId}:e.kind==="member"?{model:t,member:e.memberId,workspace:n}:e.kind==="gateway"?{model:t,workspace:n}:{model:t,workspace:e.workspaceId}}const Fs={allow:"Allowed",block:"Blocked",prefer:"Preferred"};function Ms(e){const{action:t,name:n,scopeLabel:a,changed:o,model:i,preview:m,peerId:c}=e,g=Fs[t],f=t==="prefer"?`already first for ${i}`:`already ${g.toLowerCase()}`,l=o?`${g} ${n} ${t==="prefer"?`for ${i} `:""}on ${a}`:`${n} was ${f} on ${a}; nothing changed`;if(!m)return t==="block"?{tone:o?"success":"info",text:`${l}.`}:{tone:"info",text:`${l}. ${e.previewError?`Could not check whether it can serve: ${e.previewError}`:"Could not check whether it can serve."}`};const u=m.candidates.find(v=>pe(v.peerId,c));if(t==="block")return u!=null&&u.eligible?{tone:"warning",text:`${l}, but the route preview still lists it as eligible for ${i}. Reload and check the policy.`}:{tone:o?"success":"info",text:`${l}.`};if(!m.modelAllowed)return{tone:"warning",text:`${l}, but ${i} is not an allowed model here, so it still cannot serve it.`};if(!u)return{tone:"info",text:`${l}. It does not offer ${i} right now, so the preview cannot show its rank.`};if(!u.eligible){const v=u.reasons.length?u.reasons.join("; "):"another level excludes it";return{tone:"warning",text:`${l}, but it still cannot serve ${i} here: ${v}.`}}return t==="prefer"&&u.rank!==null&&u.rank>1?{tone:"warning",text:`${l}, but it ranks #${u.rank} for ${i}: a fallback chain on another level comes first.`}:{tone:o?"success":"info",text:`${l}.${u.rank?` It ranks #${u.rank} for ${i}.`:""}`}}function Ts(e,t,n,a){return e==="gateway"?{kind:e}:e==="workspace"||e==="workspace-org"?{kind:e,workspaceId:n}:t?e==="member"?{kind:e,memberId:t}:{kind:"key",keyId:t,workspaceId:n,layer:a?"admin":"owner"}:null}function Es(e){return e.canForce?"Not allowed above":e.tone==="warning"?"Check the result":"Done"}function Ds({fetching:e,error:t,ready:n,policy:a}){return e?s.jsx(be,{rows:1}):t?s.jsx(ee,{error:t,title:"Could not load this scope's policy"}):n?s.jsxs("p",{className:"gc-muted",children:["Current policy: ",es(a)]}):null}const me={allow:{title:"Allow seller",verb:"Allow"},block:{title:"Block seller",verb:"Block"},prefer:{title:"Prefer seller",verb:"Prefer"}};function Oe({peer:e,action:t,onClose:n,peers:a}){var te,ne,re,ae;const{viewer:o,workspace:i,me:m}=X(),c=fe(),g=Ke(),f=Ge(),l=we(o),u=ye(o),v=[...l?[{value:"gateway",label:"Gateway default (everyone)"}]:[],...l?[{value:"workspace-org",label:`${i.name}: organization policy`}]:[],...u?[{value:"workspace",label:`${i.name}: workspace policy`}]:[],...l?[{value:"member",label:"A member"}]:[],{value:"key",label:"An API key"}],[y,h]=p.useState(v[0].value),[r,b]=p.useState(""),[k,D]=p.useState(""),O=Ye(y==="member"),R=ve(c,y==="key");p.useEffect(()=>{b("")},[y]),p.useEffect(()=>{var d;D(((d=e==null?void 0:e.services[0])==null?void 0:d.service)??"")},[e]);const w=(R.data??[]).filter(d=>d.status==="active"&&(u||d.ownerMemberId===m.member.id)),j=Ts(y,r,i.id,u),[S,T]=p.useState(null);p.useEffect(()=>{T(null)},[y,r,e]);const B=Qe({queryKey:["routing","scope-policy",j],queryFn:()=>De(L,j),enabled:j!==null&&e!==null,staleTime:0}),z=j!==null&&B.isSuccess&&(t!=="prefer"||k!==""),I=B.data??null,ze=t==="allow"&&z&&!(I!=null&&I.allowedPeerIds)&&!(I!=null&&I.allowedPeerLists),Ue=t==="block"&&z&&e!==null&&We(I,e.peerId);let E=((te=v.find(d=>d.value===y))==null?void 0:te.label.replace(/^A[n]? /,"the "))??"this scope";y==="key"&&(E=`key “${((ne=w.find(d=>d.id===r))==null?void 0:ne.label)??r}”`),y==="member"&&(E=`member “${((ae=(re=O.data)==null?void 0:re.find(d=>d.id===r))==null?void 0:ae.label)??r}”`);const P=He({mutationFn:async(d={})=>{var ie;if(!e||!j)return null;const C=k||((ie=e.services[0])==null?void 0:ie.service)||"",{changed:G}=await As(L,j,t,e.peerId,k||void 0,d);let oe=null,le=null;if(C)try{oe=await L.network.routePreview(Ls(j,C,i.id))}catch(_e){le=Ze(_e)}return Ms({action:t,name:Q(a,e.peerId),scopeLabel:E,changed:G,model:C,preview:oe,peerId:e.peerId,previewError:le})},onSuccess:d=>{for(const C of Xe)g.invalidateQueries({queryKey:[C]});d&&(d.tone==="success"?(f(d.text),n()):T(d))},onError:d=>{const C=e?Q(a,e.peerId):"this seller";if(U(d,"narrowed"))T({tone:"warning",canForce:!0,text:`Nothing changed yet. The levels above ${E} do not allow ${C}, so saving this would not let it serve. ${Je(d.details).join(" ")}`.trim()});else if(U(d,"empty_allow_list")){const G=t==="block"?`Blocking ${C}`:`Allowing only ${C}`;T({tone:"warning",text:`Nothing changed. ${G} on ${E} would leave no seller that the levels above allow, so requests would fail. Change the policy on the Routing page if you really want that.`})}}}),K=e?Q(a,e.peerId):"";return s.jsx(Z,{isOpen:e!==null,onClose:n,title:me[t].title,subtitle:K,children:s.jsxs("div",{className:"gc-stack",children:[s.jsx(A,{label:"Apply to",value:y,onChange:d=>h(d),options:v}),y==="member"&&s.jsx(A,{label:"Member",value:r,onChange:b,options:[{value:"",label:"Choose a member"},...(O.data??[]).filter(d=>d.status!=="disabled").map(d=>({value:d.id,label:d.label}))]}),y==="key"&&s.jsx(A,{label:"Key",value:r,onChange:b,options:[{value:"",label:w.length?"Choose a key":"No keys you can edit"},...w.map(d=>({value:d.id,label:d.label}))]}),t==="prefer"&&e&&s.jsx(A,{label:"For model",value:k,onChange:D,options:e.services.map(d=>({value:d.service,label:d.service})),hint:"The seller goes first in this model's fallback chain."}),s.jsx(Ds,{fetching:B.isFetching,error:B.error,ready:z,policy:I}),ze&&s.jsxs(Y,{tone:"warning",children:["This scope has no allow list yet. Allowing ",K," creates one, so only allowed sellers can serve it."]}),Ue&&s.jsxs(Y,{tone:"warning",title:"This is the only allowed seller",children:["Blocking ",K," empties this scope's allow list, so the allow list is removed: any seller that is not blocked may serve it again."]}),t==="block"&&s.jsx("p",{className:"gc-muted",children:"Blocked sellers never serve this scope or anything under it."}),y==="key"&&!u&&s.jsx("p",{className:"gc-muted",children:"This changes your own restrictions on the key. Restrictions a workspace admin set still apply."}),P.error&&!U(P.error,"narrowed")&&!U(P.error,"empty_allow_list")?s.jsx(ee,{error:P.error,title:"Could not update the policy"}):null,S?s.jsxs(s.Fragment,{children:[s.jsx(Y,{tone:S.tone,title:Es(S),children:S.text}),s.jsxs("div",{className:"gc-actions",children:[S.canForce&&s.jsx(x,{variant:"ghost",disabled:P.isPending,onClick:()=>{T(null),P.mutate({acceptNarrowed:!0})},children:"Save it anyway"}),s.jsx(x,{onClick:n,children:S.canForce?"Cancel":"Done"})]})]}):s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{variant:t==="block"?"danger":"primary",disabled:!z||P.isPending,onClick:()=>P.mutate({}),children:P.isPending?"Saving…":me[t].verb})]})]})})}function Os({initial:e,peers:t,onDone:n}){const[a,o]=p.useState((e==null?void 0:e.name)??""),[i,m]=p.useState((e==null?void 0:e.description)??""),[c,g]=p.useState((e==null?void 0:e.peerIds)??[]),f=xe({mutationFn:()=>{const l={name:a.trim(),description:i.trim()||null,peerIds:c};return e?L.network.updatePeerList(e.id,l):L.network.createPeerList(l)},onSuccess:n,invalidate:[ke.peerLists]});return s.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),f.mutate()},children:[s.jsx(q,{label:"Name",required:!0,placeholder:"e.g. Our own sellers",value:a,onChange:l=>o(l.target.value)}),s.jsx(q,{label:"Description",value:i,onChange:l=>m(l.target.value)}),s.jsx(xs,{label:"Sellers",value:c,onChange:g,peers:t}),s.jsx("p",{className:"gc-fineprint",children:"Policies refer to a list by name, so editing it changes every policy that uses it."}),f.error?s.jsx(ee,{error:f.error,title:"Could not save the list"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{type:"submit",disabled:f.isPending||!a.trim(),children:f.isPending?"Saving…":"Save list"})]})]})}function Rs({peers:e}){const{viewer:t}=X(),n=we(t),a=ss(),[o,i]=p.useState(null),[m,c]=p.useState(null),g=xe({mutationFn:f=>L.network.removePeerList(f.id),onSuccess:()=>c(null),invalidate:[ke.peerLists]});return s.jsxs(je,{flush:!0,title:"Peer lists",description:"Named groups of sellers to allow or block in one step.",actions:n&&s.jsx(x,{size:"sm",variant:"outline",leadingIcon:s.jsx(_.plus,{size:14}),onClick:()=>i("new"),children:"New list"}),children:[s.jsx(Pe,{query:a,children:f=>s.jsx(Le,{label:"Peer lists",rows:f,rowKey:l=>l.id,rowLabel:l=>l.name,actions:l=>n?[{label:"Edit",onSelect:()=>i(l)},{label:"Delete",tone:"danger",onSelect:()=>c(l)}]:[],empty:s.jsx(J,{icon:s.jsx(_.network,{size:18}),title:"No peer lists",body:"Group sellers you trust, or ones you run yourself."}),columns:[{key:"name",header:"Name",render:l=>s.jsx("span",{className:"gc-strong",children:l.name})},{key:"desc",header:"Description",secondary:!0,render:l=>s.jsx("span",{className:"gc-muted",children:l.description??"—"})},{key:"count",header:"Sellers",align:"right",render:l=>l.peerIds.length}]})}),s.jsx(Z,{isOpen:o!==null,onClose:()=>i(null),title:o==="new"?"New peer list":"Edit peer list",size:"lg",children:o!==null&&s.jsx(Os,{initial:o==="new"?null:o,peers:e,onDone:()=>i(null)})}),s.jsx(ts,{isOpen:m!==null,busy:g.isPending,error:g.error,onClose:()=>c(null),onConfirm:()=>m&&g.mutate(m),title:"Delete this list?",confirmLabel:"Delete",body:"Policies refer to lists by reference: once deleted, the list adds no sellers to them. An allow list made only of deleted lists lets no seller serve."})]})}function Re(e,t){return t?e.services.filter(n=>n.service===t):e.services}function V(e,t,n=""){const a=Re(e,n).map(o=>o[t]).filter(o=>o!==null);return a.length?{min:Math.min(...a),max:Math.max(...a)}:null}function Bs(e,t=""){var n;return((n=V(e,"inputUsdPerMillion",t))==null?void 0:n.min)??null}function zs(e,t=""){var n;return((n=V(e,"outputUsdPerMillion",t))==null?void 0:n.min)??null}function se(e,t=""){return Re(e,t).some(n=>n.inputUsdPerMillion===0&&(n.outputUsdPerMillion??0)===0)}function Us(e,t){const n=t.search.trim().toLowerCase();return e.filter(a=>{var o;return!(n&&!a.peerId.toLowerCase().includes(n)&&!(a.displayName??"").toLowerCase().includes(n)&&!a.services.some(i=>i.service.toLowerCase().includes(n))||t.model&&!a.services.some(i=>i.service===t.model)||t.tee&&!a.tee||t.linked&&!((o=a.verificationLinks)!=null&&o.length)||t.free&&!se(a,t.model))})}const Be={"openai-chat-completions":"Chat completions","openai-responses":"Responses","anthropic-messages":"Messages","openai-images":"Images"};function he(e){return e===null?"—":String(Math.round(e))}function H(e){return e.displayName??F(e.peerId,8,4)}function M(e){return`${e.provider}:${e.service}`}function _s({peer:e}){const t=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("span",{className:"gc-seller__meta",children:[s.jsxs("span",{className:"gc-peer-id",children:[s.jsx(Ce,{title:e.peerId,children:F(e.peerId,6,4)}),s.jsx(Se,{iconOnly:!0,value:e.peerId,label:"Copy peer id"})]}),s.jsx(Fe,{links:e.verificationLinks}),e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,"")&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),t&&s.jsx(N,{tone:"warning",children:"Cooling down"}),s.jsxs("span",{className:"gc-muted",children:["Last seen ",ns(e.lastSeen)]})]})}function qs({peer:e,showReputation:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-grid gc-grid--2 gc-figures gc-panel-figures",children:[s.jsx($,{label:"Trust score",value:he(e.trustScore)}),t&&s.jsx($,{label:"Reputation",value:he(e.reputationScore)}),s.jsx($,{label:"Stake",value:e.stakeAnts?Cs(e.stakeAnts):"—"}),s.jsx($,{label:"Network usage share",value:e.usageShareBps===null?"—":`${(e.usageShareBps/100).toFixed(2)}%`}),s.jsx($,{label:"Latency p50 (this gateway)",value:Ie(e.latencyMsP50)}),s.jsx($,{label:"Requests, 24h (this gateway)",value:Ne(e.requests24h)}),s.jsx($,{label:"Failure streak",value:n?`${e.health.failureStreak}, cooling down until ${rs(e.health.coolingDownUntil)}`:String(e.health.failureStreak)})]})}function Vs({peer:e,selected:t,onSelect:n}){const[a,o]=p.useState(""),i=a.trim().toLowerCase(),m=e.services.filter(c=>!i||c.service.toLowerCase().includes(i));return s.jsx(Me,{title:`Models (${e.services.length})`,actions:e.services.length>6&&s.jsx(q,{size:"sm",type:"search","aria-label":"Search this provider's models",placeholder:"Search models",value:a,onChange:c=>o(c.target.value)}),children:m.length===0?s.jsx("p",{className:"gc-fineprint",children:i?"No models match.":"This provider lists no models."}):s.jsx("ul",{className:"gc-panel-rows","aria-label":"Models and prices",children:m.map(c=>{const g=t!==null&&M(t)===M(c);return s.jsx(ks,{selected:g,title:s.jsx("span",{className:"gc-strong",children:c.service}),meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:js(c)}),s.jsx("span",{children:Be[Ae(c)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(Se,{iconOnly:!0,value:$e(e.peerId,c.service),label:`Copy ${c.service} pinned to this provider (peer@model)`}),s.jsx(x,{size:"sm",variant:g?"outline":"ghost","aria-pressed":g,title:"Show the API call for this model",onClick:()=>n(c),children:"API call"})]})},M(c))})})})}function Ks({peer:e,service:t,onSelect:n}){var R;const{workspace:a,viewer:o}=X(),i=fe(),m=as(),c=ve(i),g=os(a.id),[f,l]=p.useState("curl"),[u,v]=p.useState(!1),y=Ae(t),h=$e(e.peerId,t.service),r=((R=g.data)==null?void 0:R.find(w=>w.model===h))??null,b=ls(m,e.peerId,t.service,y,r?`@preset/${r.slug}`:null),k=b.find(w=>w.id===f)??b[0],D=(c.data??[]).some(w=>w.status==="active"),O=ye(o);return s.jsxs(Me,{title:"API call",actions:e.services.length>1&&s.jsx(A,{size:"sm","aria-label":"Model",value:M(t),onChange:w=>{const j=e.services.find(S=>M(S)===w);j&&n(j)},options:e.services.map(w=>({value:M(w),label:w.service}))}),children:[s.jsxs("p",{className:"gc-fineprint",children:["Pinned to this provider with ",s.jsx("code",{children:F(h,10,12)}),"."]}),s.jsx(Is,{id:"gc-connect",label:"Ways to connect",value:k.id,onChange:l,className:"gc-connect-tabs",tabs:b.map(w=>({id:w.id,label:w.label}))}),s.jsxs(Ns,{tabsId:"gc-connect",tab:k.id,className:"gc-stack",children:[k.id==="codex"&&s.jsxs("div",{className:"gc-summary-row",children:[s.jsx("p",{className:"gc-fineprint gc-summary-row__text",children:r?s.jsxs(s.Fragment,{children:["Uses the preset ",s.jsxs("code",{children:["@preset/",r.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."})}),!r&&O&&s.jsx(x,{size:"sm",variant:"outline",onClick:()=>v(!0),children:"Create preset for this model"})]}),k.id==="claude-code"&&y!=="anthropic-messages"&&s.jsxs("p",{className:"gc-fineprint",children:["This model speaks ",Be[y],"; the gateway translates Claude Code's requests for it."]}),s.jsx(is,{code:k.code,label:`${t.service} · ${k.label}`})]}),s.jsxs("p",{className:"gc-fineprint",children:["Set ",s.jsx("code",{children:cs})," to one of your API keys first."," ",c.data&&!D&&s.jsx(ds,{to:"keys",children:"Create an API key"})]}),s.jsx(Z,{isOpen:u,onClose:()=>v(!1),size:"lg",title:"New preset",children:u&&s.jsx(Ss,{initial:null,prefill:{name:t.service,model:h},onDone:w=>{v(!1),w&&l("codex")}})})]})}function Gs({peer:e,peers:t,showReputation:n}){const[a,o]=p.useState(null),[i,m]=p.useState(null),c=p.useRef(null),g=i??e.services[0]??null,f=l=>{var u;m(l),(u=c.current)==null||u.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"gc-stack",children:[s.jsx(_s,{peer:e}),s.jsxs("div",{className:"gc-panel-actions",children:[s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("allow"),children:"Allow"}),s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("prefer"),children:"Prefer"}),s.jsx(x,{size:"sm",variant:"danger",onClick:()=>o("block"),children:"Block"})]}),s.jsx(qs,{peer:e,showReputation:n})]}),s.jsx(Vs,{peer:e,selected:g,onSelect:f}),g&&s.jsx("div",{ref:c,className:"gc-scroll-target",children:s.jsx(Ks,{peer:e,service:g,onSelect:m})}),a&&s.jsx(Oe,{peer:e,action:a,peers:t,onClose:()=>o(null)})]})}function ge(e){return e===null?"—":String(Math.round(e))}function Ys({peer:e,model:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-badges",children:[e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,t)&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),n&&s.jsx(N,{tone:"warning",children:"Cooling down"})]})}function ct(){const e=us(),t=ms(e.rest),n=hs(),a=p.useMemo(()=>{var h;return t?((h=n.data)==null?void 0:h.find(r=>pe(r.peerId,t)))??null:null},[n.data,t]),[o,i]=p.useState({search:"",model:"",tee:!1,linked:!1,free:!1}),[m,c]=p.useState(null),g=p.useMemo(()=>gs(n.data),[n.data]),f=ps(n.data),l=fs(),u=(h,r)=>i(b=>({...b,[h]:r})),v=t===null?null:{eyebrow:"Provider",title:a?H(a):F(t,8,6),body:n.isLoading?s.jsx(be,{rows:6}):a?s.jsx(Gs,{peer:a,peers:n.data,showReputation:f},a.peerId):s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:"Provider not found",body:`This gateway does not see ${F(t,8,6)} right now.`})},y=s.jsxs("div",{className:"gc-page",children:[s.jsx(je,{flush:!0,children:s.jsx(Pe,{query:n,rows:8,children:h=>s.jsx(Le,{label:"Providers",rows:Us(h,o),rowKey:r=>r.peerId,selectedKey:(a==null?void 0:a.peerId)??null,onRowClick:r=>de(vs("providers",r.peerId)),rowLabel:r=>H(r),actions:r=>[o.model!==""&&ys(l,r.peerId,o.model),{label:"Allow…",onSelect:()=>c({peer:r,kind:"allow"})},{label:"Prefer…",onSelect:()=>c({peer:r,kind:"prefer"})},{label:"Block…",tone:"danger",onSelect:()=>c({peer:r,kind:"block"})}],initialSort:{key:"trust",direction:"desc"},empty:s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:h.length?"No providers match these filters":"No providers found yet",body:h.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"name",header:"Provider",sortValue:r=>r.displayName??r.peerId,render:r=>s.jsxs("div",{className:"gc-cell-lines",children:[s.jsx("div",{className:"gc-strong gc-ellipsis",title:r.displayName??r.peerId,children:H(r)}),r.displayName&&s.jsx("div",{className:"gc-muted gc-ellipsis",children:s.jsx(Ce,{title:r.peerId,children:F(r.peerId,6,4)})}),s.jsx(Ys,{peer:r,model:o.model})]}),after:r=>s.jsx(ws,{value:r.peerId,label:`Copy peer id ${r.peerId}`})},{key:"identity",header:"Domain / GitHub",secondary:!0,render:r=>{var b;return(b=r.verificationLinks)!=null&&b.length?s.jsx(Fe,{links:r.verificationLinks}):s.jsx("span",{className:"gc-muted",children:"—"})}},{key:"models",header:"Models",secondary:!0,optional:!0,render:r=>s.jsx("span",{className:"gc-muted",children:r.services.length})},{key:"input",header:"Input $/M",align:"right",sortValue:r=>Bs(r,o.model),render:r=>ce(V(r,"inputUsdPerMillion",o.model))},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:r=>zs(r,o.model),render:r=>ce(V(r,"outputUsdPerMillion",o.model))},{key:"trust",header:"Trust",align:"right",sortValue:r=>r.trustScore,render:r=>ge(r.trustScore)},...f?[{key:"reputation",header:"Reputation",align:"right",secondary:!0,optional:!0,sortValue:r=>r.reputationScore,render:r=>ge(r.reputationScore)}]:[],{key:"latency",header:"Latency",align:"right",secondary:!0,optional:!0,sortValue:r=>r.latencyMsP50,render:r=>Ie(r.latencyMsP50)},{key:"usage",header:"Your 24h",align:"right",secondary:!0,sortValue:r=>r.requests24h,render:r=>Ne(r.requests24h)}]})})}),s.jsx(Rs,{peers:n.data})]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(bs,{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(q,{size:"sm",type:"search","aria-label":"Search providers",placeholder:"Search name, peer id or model",value:o.search,onChange:h=>u("search",h.target.value)}),s.jsx(A,{size:"sm","aria-label":"Filter by model",value:o.model,onChange:h=>u("model",h),options:[{value:"",label:"All models"},...g.map(h=>({value:h,label:h}))]}),s.jsx(W,{checked:o.linked,onChange:h=>u("linked",h),label:"Domain or GitHub"}),s.jsx(W,{checked:o.tee,onChange:h=>u("tee",h),label:"TEE"}),s.jsx(W,{checked:o.free,onChange:h=>u("free",h),label:"Free"})]}),s.jsx(Ps,{list:y,panel:v,onClose:()=>de("providers"),closeLabel:"Close provider"}),m&&s.jsx(Oe,{peer:m.peer,action:m.kind,peers:n.data,onClose:()=>c(null)})]})}export{ct as default};
|
|
1
|
+
import{bW as qe,bh as pe,aI as Ve,u as X,a as fe,D as Ke,F as Ge,m as we,i as ye,r as p,O as Ye,b as ve,d as Qe,bX as We,bf as He,Y as U,bY as Je,bZ as Xe,e as L,ag as Ze,j as s,A as Z,ac as Y,n as ee,B as x,L as be,z as es,b9 as ss,s as xe,q as ke,k as je,Q as Pe,E as J,I as _,C as ts,T as q,v as F,M as Ce,ap as Se,t as N,a8 as ns,bU as $,ab as Ie,g as Ne,X as rs,b0 as $e,b_ as Ae,aS as as,b4 as os,b$ as ls,W as is,aU as cs,N as ds,aV as us,aW as ms,b2 as hs,b3 as gs,bo as ps,aY as fs,aZ as ws,a_ as ce,b6 as ys,x as de,a$ as vs,P as bs}from"./index-DqdaAEyo.js";import{p as Q,a as xs}from"./PolicyEditor-BdoaX9gK.js";import{S as A}from"./SelectField-D8fxDUNO.js";import{D as Le}from"./DataTable-CDFSD9Kq.js";import{V as Fe,P as Me,b as ks,p as js,S as Ps}from"./models-Ben8ko6c.js";import{f as Cs}from"./ants-B38m9Phv.js";import{PresetForm as Ss}from"./Presets-CoTmwoy_.js";import{T as Is,a as Ns}from"./Tabs-BmjCmD5T.js";import{S as W}from"./Switch-Ba56zux7.js";import"./Segmented-Qx6JB6EU.js";import"./roving-DkptacxO.js";import"./Disclosure-UjXa2WU7.js";import"./index-D5ERwHFX.js";import"./PolicyField-DIPl0B1x.js";import"./TextAreaField-CF9_zjuC.js";function Te(e,t="admin"){return t==="owner"&&Ve(e)?"ownerRoutingPolicy":"routingPolicy"}async function Ee(e,t){const n=(await e.keys.list({workspace:t.workspaceId})).find(a=>a.id===t.keyId);if(!n)throw new Error("That key no longer exists.");return n}async function De(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 n=(await e.members.list()).find(a=>a.id===t.memberId);if(!n)throw new Error("That member no longer exists.");return n.routingPolicy}case"key":{const n=await Ee(e,t);return n[Te(n,t.layer)]??null}}}async function $s(e,t,n,a){const o=a!=null&&a.confirmEmpty||a!=null&&a.acceptNarrowed?[a]:[];switch(t.kind){case"gateway":await e.network.setGatewayPolicy(n??{},...o);return;case"workspace-org":await e.workspaces.update(t.workspaceId,{orgRoutingPolicy:n},...o);return;case"workspace":await e.workspaces.update(t.workspaceId,{routingPolicy:n},...o);return;case"member":await e.members.update(t.memberId,{routingPolicy:n},...o);return;case"key":{const i=t.layer==="owner"?Te(await Ee(e,t),"owner"):"routingPolicy";await e.keys.update(t.keyId,{[i]:n},...o);return}}}const ue=e=>JSON.stringify(e??{},Object.keys(e??{}).sort());async function As(e,t,n,a,o,i){const m=await De(e,t),c=qe(m,n,a,o),g=ue(m)!==ue(c)||JSON.stringify(m??{})!==JSON.stringify(c);return g&&await $s(e,t,c,i),{before:m,after:c,changed:g}}function Ls(e,t,n){return e.kind==="key"?{model:t,key:e.keyId,workspace:e.workspaceId}:e.kind==="member"?{model:t,member:e.memberId,workspace:n}:e.kind==="gateway"?{model:t,workspace:n}:{model:t,workspace:e.workspaceId}}const Fs={allow:"Allowed",block:"Blocked",prefer:"Preferred"};function Ms(e){const{action:t,name:n,scopeLabel:a,changed:o,model:i,preview:m,peerId:c}=e,g=Fs[t],f=t==="prefer"?`already first for ${i}`:`already ${g.toLowerCase()}`,l=o?`${g} ${n} ${t==="prefer"?`for ${i} `:""}on ${a}`:`${n} was ${f} on ${a}; nothing changed`;if(!m)return t==="block"?{tone:o?"success":"info",text:`${l}.`}:{tone:"info",text:`${l}. ${e.previewError?`Could not check whether it can serve: ${e.previewError}`:"Could not check whether it can serve."}`};const u=m.candidates.find(v=>pe(v.peerId,c));if(t==="block")return u!=null&&u.eligible?{tone:"warning",text:`${l}, but the route preview still lists it as eligible for ${i}. Reload and check the policy.`}:{tone:o?"success":"info",text:`${l}.`};if(!m.modelAllowed)return{tone:"warning",text:`${l}, but ${i} is not an allowed model here, so it still cannot serve it.`};if(!u)return{tone:"info",text:`${l}. It does not offer ${i} right now, so the preview cannot show its rank.`};if(!u.eligible){const v=u.reasons.length?u.reasons.join("; "):"another level excludes it";return{tone:"warning",text:`${l}, but it still cannot serve ${i} here: ${v}.`}}return t==="prefer"&&u.rank!==null&&u.rank>1?{tone:"warning",text:`${l}, but it ranks #${u.rank} for ${i}: a fallback chain on another level comes first.`}:{tone:o?"success":"info",text:`${l}.${u.rank?` It ranks #${u.rank} for ${i}.`:""}`}}function Ts(e,t,n,a){return e==="gateway"?{kind:e}:e==="workspace"||e==="workspace-org"?{kind:e,workspaceId:n}:t?e==="member"?{kind:e,memberId:t}:{kind:"key",keyId:t,workspaceId:n,layer:a?"admin":"owner"}:null}function Es(e){return e.canForce?"Not allowed above":e.tone==="warning"?"Check the result":"Done"}function Ds({fetching:e,error:t,ready:n,policy:a}){return e?s.jsx(be,{rows:1}):t?s.jsx(ee,{error:t,title:"Could not load this scope's policy"}):n?s.jsxs("p",{className:"gc-muted",children:["Current policy: ",es(a)]}):null}const me={allow:{title:"Allow seller",verb:"Allow"},block:{title:"Block seller",verb:"Block"},prefer:{title:"Prefer seller",verb:"Prefer"}};function Oe({peer:e,action:t,onClose:n,peers:a}){var te,ne,re,ae;const{viewer:o,workspace:i,me:m}=X(),c=fe(),g=Ke(),f=Ge(),l=we(o),u=ye(o),v=[...l?[{value:"gateway",label:"Gateway default (everyone)"}]:[],...l?[{value:"workspace-org",label:`${i.name}: organization policy`}]:[],...u?[{value:"workspace",label:`${i.name}: workspace policy`}]:[],...l?[{value:"member",label:"A member"}]:[],{value:"key",label:"An API key"}],[y,h]=p.useState(v[0].value),[r,b]=p.useState(""),[k,D]=p.useState(""),O=Ye(y==="member"),R=ve(c,y==="key");p.useEffect(()=>{b("")},[y]),p.useEffect(()=>{var d;D(((d=e==null?void 0:e.services[0])==null?void 0:d.service)??"")},[e]);const w=(R.data??[]).filter(d=>d.status==="active"&&(u||d.ownerMemberId===m.member.id)),j=Ts(y,r,i.id,u),[S,T]=p.useState(null);p.useEffect(()=>{T(null)},[y,r,e]);const B=Qe({queryKey:["routing","scope-policy",j],queryFn:()=>De(L,j),enabled:j!==null&&e!==null,staleTime:0}),z=j!==null&&B.isSuccess&&(t!=="prefer"||k!==""),I=B.data??null,ze=t==="allow"&&z&&!(I!=null&&I.allowedPeerIds)&&!(I!=null&&I.allowedPeerLists),Ue=t==="block"&&z&&e!==null&&We(I,e.peerId);let E=((te=v.find(d=>d.value===y))==null?void 0:te.label.replace(/^A[n]? /,"the "))??"this scope";y==="key"&&(E=`key “${((ne=w.find(d=>d.id===r))==null?void 0:ne.label)??r}”`),y==="member"&&(E=`member “${((ae=(re=O.data)==null?void 0:re.find(d=>d.id===r))==null?void 0:ae.label)??r}”`);const P=He({mutationFn:async(d={})=>{var ie;if(!e||!j)return null;const C=k||((ie=e.services[0])==null?void 0:ie.service)||"",{changed:G}=await As(L,j,t,e.peerId,k||void 0,d);let oe=null,le=null;if(C)try{oe=await L.network.routePreview(Ls(j,C,i.id))}catch(_e){le=Ze(_e)}return Ms({action:t,name:Q(a,e.peerId),scopeLabel:E,changed:G,model:C,preview:oe,peerId:e.peerId,previewError:le})},onSuccess:d=>{for(const C of Xe)g.invalidateQueries({queryKey:[C]});d&&(d.tone==="success"?(f(d.text),n()):T(d))},onError:d=>{const C=e?Q(a,e.peerId):"this seller";if(U(d,"narrowed"))T({tone:"warning",canForce:!0,text:`Nothing changed yet. The levels above ${E} do not allow ${C}, so saving this would not let it serve. ${Je(d.details).join(" ")}`.trim()});else if(U(d,"empty_allow_list")){const G=t==="block"?`Blocking ${C}`:`Allowing only ${C}`;T({tone:"warning",text:`Nothing changed. ${G} on ${E} would leave no seller that the levels above allow, so requests would fail. Change the policy on the Routing page if you really want that.`})}}}),K=e?Q(a,e.peerId):"";return s.jsx(Z,{isOpen:e!==null,onClose:n,title:me[t].title,subtitle:K,children:s.jsxs("div",{className:"gc-stack",children:[s.jsx(A,{label:"Apply to",value:y,onChange:d=>h(d),options:v}),y==="member"&&s.jsx(A,{label:"Member",value:r,onChange:b,options:[{value:"",label:"Choose a member"},...(O.data??[]).filter(d=>d.status!=="disabled").map(d=>({value:d.id,label:d.label}))]}),y==="key"&&s.jsx(A,{label:"Key",value:r,onChange:b,options:[{value:"",label:w.length?"Choose a key":"No keys you can edit"},...w.map(d=>({value:d.id,label:d.label}))]}),t==="prefer"&&e&&s.jsx(A,{label:"For model",value:k,onChange:D,options:e.services.map(d=>({value:d.service,label:d.service})),hint:"The seller goes first in this model's fallback chain."}),s.jsx(Ds,{fetching:B.isFetching,error:B.error,ready:z,policy:I}),ze&&s.jsxs(Y,{tone:"warning",children:["This scope has no allow list yet. Allowing ",K," creates one, so only allowed sellers can serve it."]}),Ue&&s.jsxs(Y,{tone:"warning",title:"This is the only allowed seller",children:["Blocking ",K," empties this scope's allow list, so the allow list is removed: any seller that is not blocked may serve it again."]}),t==="block"&&s.jsx("p",{className:"gc-muted",children:"Blocked sellers never serve this scope or anything under it."}),y==="key"&&!u&&s.jsx("p",{className:"gc-muted",children:"This changes your own restrictions on the key. Restrictions a workspace admin set still apply."}),P.error&&!U(P.error,"narrowed")&&!U(P.error,"empty_allow_list")?s.jsx(ee,{error:P.error,title:"Could not update the policy"}):null,S?s.jsxs(s.Fragment,{children:[s.jsx(Y,{tone:S.tone,title:Es(S),children:S.text}),s.jsxs("div",{className:"gc-actions",children:[S.canForce&&s.jsx(x,{variant:"ghost",disabled:P.isPending,onClick:()=>{T(null),P.mutate({acceptNarrowed:!0})},children:"Save it anyway"}),s.jsx(x,{onClick:n,children:S.canForce?"Cancel":"Done"})]})]}):s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{variant:t==="block"?"danger":"primary",disabled:!z||P.isPending,onClick:()=>P.mutate({}),children:P.isPending?"Saving…":me[t].verb})]})]})})}function Os({initial:e,peers:t,onDone:n}){const[a,o]=p.useState((e==null?void 0:e.name)??""),[i,m]=p.useState((e==null?void 0:e.description)??""),[c,g]=p.useState((e==null?void 0:e.peerIds)??[]),f=xe({mutationFn:()=>{const l={name:a.trim(),description:i.trim()||null,peerIds:c};return e?L.network.updatePeerList(e.id,l):L.network.createPeerList(l)},onSuccess:n,invalidate:[ke.peerLists]});return s.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),f.mutate()},children:[s.jsx(q,{label:"Name",required:!0,placeholder:"e.g. Our own sellers",value:a,onChange:l=>o(l.target.value)}),s.jsx(q,{label:"Description",value:i,onChange:l=>m(l.target.value)}),s.jsx(xs,{label:"Sellers",value:c,onChange:g,peers:t}),s.jsx("p",{className:"gc-fineprint",children:"Policies refer to a list by name, so editing it changes every policy that uses it."}),f.error?s.jsx(ee,{error:f.error,title:"Could not save the list"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{type:"submit",disabled:f.isPending||!a.trim(),children:f.isPending?"Saving…":"Save list"})]})]})}function Rs({peers:e}){const{viewer:t}=X(),n=we(t),a=ss(),[o,i]=p.useState(null),[m,c]=p.useState(null),g=xe({mutationFn:f=>L.network.removePeerList(f.id),onSuccess:()=>c(null),invalidate:[ke.peerLists]});return s.jsxs(je,{flush:!0,title:"Peer lists",description:"Named groups of sellers to allow or block in one step.",actions:n&&s.jsx(x,{size:"sm",variant:"outline",leadingIcon:s.jsx(_.plus,{size:14}),onClick:()=>i("new"),children:"New list"}),children:[s.jsx(Pe,{query:a,children:f=>s.jsx(Le,{label:"Peer lists",rows:f,rowKey:l=>l.id,rowLabel:l=>l.name,actions:l=>n?[{label:"Edit",onSelect:()=>i(l)},{label:"Delete",tone:"danger",onSelect:()=>c(l)}]:[],empty:s.jsx(J,{icon:s.jsx(_.network,{size:18}),title:"No peer lists",body:"Group sellers you trust, or ones you run yourself."}),columns:[{key:"name",header:"Name",render:l=>s.jsx("span",{className:"gc-strong",children:l.name})},{key:"desc",header:"Description",secondary:!0,render:l=>s.jsx("span",{className:"gc-muted",children:l.description??"—"})},{key:"count",header:"Sellers",align:"right",render:l=>l.peerIds.length}]})}),s.jsx(Z,{isOpen:o!==null,onClose:()=>i(null),title:o==="new"?"New peer list":"Edit peer list",size:"lg",children:o!==null&&s.jsx(Os,{initial:o==="new"?null:o,peers:e,onDone:()=>i(null)})}),s.jsx(ts,{isOpen:m!==null,busy:g.isPending,error:g.error,onClose:()=>c(null),onConfirm:()=>m&&g.mutate(m),title:"Delete this list?",confirmLabel:"Delete",body:"Policies refer to lists by reference: once deleted, the list adds no sellers to them. An allow list made only of deleted lists lets no seller serve."})]})}function Re(e,t){return t?e.services.filter(n=>n.service===t):e.services}function V(e,t,n=""){const a=Re(e,n).map(o=>o[t]).filter(o=>o!==null);return a.length?{min:Math.min(...a),max:Math.max(...a)}:null}function Bs(e,t=""){var n;return((n=V(e,"inputUsdPerMillion",t))==null?void 0:n.min)??null}function zs(e,t=""){var n;return((n=V(e,"outputUsdPerMillion",t))==null?void 0:n.min)??null}function se(e,t=""){return Re(e,t).some(n=>n.inputUsdPerMillion===0&&(n.outputUsdPerMillion??0)===0)}function Us(e,t){const n=t.search.trim().toLowerCase();return e.filter(a=>{var o;return!(n&&!a.peerId.toLowerCase().includes(n)&&!(a.displayName??"").toLowerCase().includes(n)&&!a.services.some(i=>i.service.toLowerCase().includes(n))||t.model&&!a.services.some(i=>i.service===t.model)||t.tee&&!a.tee||t.linked&&!((o=a.verificationLinks)!=null&&o.length)||t.free&&!se(a,t.model))})}const Be={"openai-chat-completions":"Chat completions","openai-responses":"Responses","anthropic-messages":"Messages","openai-images":"Images"};function he(e){return e===null?"—":String(Math.round(e))}function H(e){return e.displayName??F(e.peerId,8,4)}function M(e){return`${e.provider}:${e.service}`}function _s({peer:e}){const t=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("span",{className:"gc-seller__meta",children:[s.jsxs("span",{className:"gc-peer-id",children:[s.jsx(Ce,{title:e.peerId,children:F(e.peerId,6,4)}),s.jsx(Se,{iconOnly:!0,value:e.peerId,label:"Copy peer id"})]}),s.jsx(Fe,{links:e.verificationLinks}),e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,"")&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),t&&s.jsx(N,{tone:"warning",children:"Cooling down"}),s.jsxs("span",{className:"gc-muted",children:["Last seen ",ns(e.lastSeen)]})]})}function qs({peer:e,showReputation:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-grid gc-grid--2 gc-figures gc-panel-figures",children:[s.jsx($,{label:"Trust score",value:he(e.trustScore)}),t&&s.jsx($,{label:"Reputation",value:he(e.reputationScore)}),s.jsx($,{label:"Stake",value:e.stakeAnts?Cs(e.stakeAnts):"—"}),s.jsx($,{label:"Network usage share",value:e.usageShareBps===null?"—":`${(e.usageShareBps/100).toFixed(2)}%`}),s.jsx($,{label:"Latency p50 (this gateway)",value:Ie(e.latencyMsP50)}),s.jsx($,{label:"Requests, 24h (this gateway)",value:Ne(e.requests24h)}),s.jsx($,{label:"Failure streak",value:n?`${e.health.failureStreak}, cooling down until ${rs(e.health.coolingDownUntil)}`:String(e.health.failureStreak)})]})}function Vs({peer:e,selected:t,onSelect:n}){const[a,o]=p.useState(""),i=a.trim().toLowerCase(),m=e.services.filter(c=>!i||c.service.toLowerCase().includes(i));return s.jsx(Me,{title:`Models (${e.services.length})`,actions:e.services.length>6&&s.jsx(q,{size:"sm",type:"search","aria-label":"Search this provider's models",placeholder:"Search models",value:a,onChange:c=>o(c.target.value)}),children:m.length===0?s.jsx("p",{className:"gc-fineprint",children:i?"No models match.":"This provider lists no models."}):s.jsx("ul",{className:"gc-panel-rows","aria-label":"Models and prices",children:m.map(c=>{const g=t!==null&&M(t)===M(c);return s.jsx(ks,{selected:g,title:s.jsx("span",{className:"gc-strong",children:c.service}),meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:js(c)}),s.jsx("span",{children:Be[Ae(c)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(Se,{iconOnly:!0,value:$e(e.peerId,c.service),label:`Copy ${c.service} pinned to this provider (peer@model)`}),s.jsx(x,{size:"sm",variant:g?"outline":"ghost","aria-pressed":g,title:"Show the API call for this model",onClick:()=>n(c),children:"API call"})]})},M(c))})})})}function Ks({peer:e,service:t,onSelect:n}){var R;const{workspace:a,viewer:o}=X(),i=fe(),m=as(),c=ve(i),g=os(a.id),[f,l]=p.useState("curl"),[u,v]=p.useState(!1),y=Ae(t),h=$e(e.peerId,t.service),r=((R=g.data)==null?void 0:R.find(w=>w.model===h))??null,b=ls(m,e.peerId,t.service,y,r?`@preset/${r.slug}`:null),k=b.find(w=>w.id===f)??b[0],D=(c.data??[]).some(w=>w.status==="active"),O=ye(o);return s.jsxs(Me,{title:"API call",actions:e.services.length>1&&s.jsx(A,{size:"sm","aria-label":"Model",value:M(t),onChange:w=>{const j=e.services.find(S=>M(S)===w);j&&n(j)},options:e.services.map(w=>({value:M(w),label:w.service}))}),children:[s.jsxs("p",{className:"gc-fineprint",children:["Pinned to this provider with ",s.jsx("code",{children:F(h,10,12)}),"."]}),s.jsx(Is,{id:"gc-connect",label:"Ways to connect",value:k.id,onChange:l,className:"gc-connect-tabs",tabs:b.map(w=>({id:w.id,label:w.label}))}),s.jsxs(Ns,{tabsId:"gc-connect",tab:k.id,className:"gc-stack",children:[k.id==="codex"&&s.jsxs("div",{className:"gc-summary-row",children:[s.jsx("p",{className:"gc-fineprint gc-summary-row__text",children:r?s.jsxs(s.Fragment,{children:["Uses the preset ",s.jsxs("code",{children:["@preset/",r.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."})}),!r&&O&&s.jsx(x,{size:"sm",variant:"outline",onClick:()=>v(!0),children:"Create preset for this model"})]}),k.id==="claude-code"&&y!=="anthropic-messages"&&s.jsxs("p",{className:"gc-fineprint",children:["This model speaks ",Be[y],"; the gateway translates Claude Code's requests for it."]}),s.jsx(is,{code:k.code,label:`${t.service} · ${k.label}`})]}),s.jsxs("p",{className:"gc-fineprint",children:["Set ",s.jsx("code",{children:cs})," to one of your API keys first."," ",c.data&&!D&&s.jsx(ds,{to:"keys",children:"Create an API key"})]}),s.jsx(Z,{isOpen:u,onClose:()=>v(!1),size:"lg",title:"New preset",children:u&&s.jsx(Ss,{initial:null,prefill:{name:t.service,model:h},onDone:w=>{v(!1),w&&l("codex")}})})]})}function Gs({peer:e,peers:t,showReputation:n}){const[a,o]=p.useState(null),[i,m]=p.useState(null),c=p.useRef(null),g=i??e.services[0]??null,f=l=>{var u;m(l),(u=c.current)==null||u.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"gc-stack",children:[s.jsx(_s,{peer:e}),s.jsxs("div",{className:"gc-panel-actions",children:[s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("allow"),children:"Allow"}),s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("prefer"),children:"Prefer"}),s.jsx(x,{size:"sm",variant:"danger",onClick:()=>o("block"),children:"Block"})]}),s.jsx(qs,{peer:e,showReputation:n})]}),s.jsx(Vs,{peer:e,selected:g,onSelect:f}),g&&s.jsx("div",{ref:c,className:"gc-scroll-target",children:s.jsx(Ks,{peer:e,service:g,onSelect:m})}),a&&s.jsx(Oe,{peer:e,action:a,peers:t,onClose:()=>o(null)})]})}function ge(e){return e===null?"—":String(Math.round(e))}function Ys({peer:e,model:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-badges",children:[e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,t)&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),n&&s.jsx(N,{tone:"warning",children:"Cooling down"})]})}function ct(){const e=us(),t=ms(e.rest),n=hs(),a=p.useMemo(()=>{var h;return t?((h=n.data)==null?void 0:h.find(r=>pe(r.peerId,t)))??null:null},[n.data,t]),[o,i]=p.useState({search:"",model:"",tee:!1,linked:!1,free:!1}),[m,c]=p.useState(null),g=p.useMemo(()=>gs(n.data),[n.data]),f=ps(n.data),l=fs(),u=(h,r)=>i(b=>({...b,[h]:r})),v=t===null?null:{eyebrow:"Provider",title:a?H(a):F(t,8,6),body:n.isLoading?s.jsx(be,{rows:6}):a?s.jsx(Gs,{peer:a,peers:n.data,showReputation:f},a.peerId):s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:"Provider not found",body:`This gateway does not see ${F(t,8,6)} right now.`})},y=s.jsxs("div",{className:"gc-page",children:[s.jsx(je,{flush:!0,children:s.jsx(Pe,{query:n,rows:8,children:h=>s.jsx(Le,{label:"Providers",rows:Us(h,o),rowKey:r=>r.peerId,selectedKey:(a==null?void 0:a.peerId)??null,onRowClick:r=>de(vs("providers",r.peerId)),rowLabel:r=>H(r),actions:r=>[o.model!==""&&ys(l,r.peerId,o.model),{label:"Allow…",onSelect:()=>c({peer:r,kind:"allow"})},{label:"Prefer…",onSelect:()=>c({peer:r,kind:"prefer"})},{label:"Block…",tone:"danger",onSelect:()=>c({peer:r,kind:"block"})}],initialSort:{key:"trust",direction:"desc"},empty:s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:h.length?"No providers match these filters":"No providers found yet",body:h.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"name",header:"Provider",sortValue:r=>r.displayName??r.peerId,render:r=>s.jsxs("div",{className:"gc-cell-lines",children:[s.jsx("div",{className:"gc-strong gc-ellipsis",title:r.displayName??r.peerId,children:H(r)}),r.displayName&&s.jsx("div",{className:"gc-muted gc-ellipsis",children:s.jsx(Ce,{title:r.peerId,children:F(r.peerId,6,4)})}),s.jsx(Ys,{peer:r,model:o.model})]}),after:r=>s.jsx(ws,{value:r.peerId,label:`Copy peer id ${r.peerId}`})},{key:"identity",header:"Domain / GitHub",secondary:!0,render:r=>{var b;return(b=r.verificationLinks)!=null&&b.length?s.jsx(Fe,{links:r.verificationLinks}):s.jsx("span",{className:"gc-muted",children:"—"})}},{key:"models",header:"Models",secondary:!0,optional:!0,render:r=>s.jsx("span",{className:"gc-muted",children:r.services.length})},{key:"input",header:"Input $/M",align:"right",sortValue:r=>Bs(r,o.model),render:r=>ce(V(r,"inputUsdPerMillion",o.model))},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:r=>zs(r,o.model),render:r=>ce(V(r,"outputUsdPerMillion",o.model))},{key:"trust",header:"Trust",align:"right",sortValue:r=>r.trustScore,render:r=>ge(r.trustScore)},...f?[{key:"reputation",header:"Reputation",align:"right",secondary:!0,optional:!0,sortValue:r=>r.reputationScore,render:r=>ge(r.reputationScore)}]:[],{key:"latency",header:"Latency",align:"right",secondary:!0,optional:!0,sortValue:r=>r.latencyMsP50,render:r=>Ie(r.latencyMsP50)},{key:"usage",header:"Your 24h",align:"right",secondary:!0,sortValue:r=>r.requests24h,render:r=>Ne(r.requests24h)}]})})}),s.jsx(Rs,{peers:n.data})]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(bs,{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(q,{size:"sm",type:"search","aria-label":"Search providers",placeholder:"Search name, peer id or model",value:o.search,onChange:h=>u("search",h.target.value)}),s.jsx(A,{size:"sm","aria-label":"Filter by model",value:o.model,onChange:h=>u("model",h),options:[{value:"",label:"All models"},...g.map(h=>({value:h,label:h}))]}),s.jsx(W,{checked:o.linked,onChange:h=>u("linked",h),label:"Domain or GitHub"}),s.jsx(W,{checked:o.tee,onChange:h=>u("tee",h),label:"TEE"}),s.jsx(W,{checked:o.free,onChange:h=>u("free",h),label:"Free"})]}),s.jsx(Ps,{list:y,panel:v,onClose:()=>de("providers"),closeLabel:"Close provider"}),m&&s.jsx(Oe,{peer:m.peer,action:m.kind,peers:n.data,onClose:()=>c(null)})]})}export{ct as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as R,j as e,L as p,n as x,X as y,M as d,v as I,ab as u,g as o,E as L,I as P,B as v,U as S,e as f,q as j,t as l,f as T,d as C,Y as M,ac as w,V as A,W as D}from"./index-
|
|
1
|
+
import{r as R,j as e,L as p,n as x,X as y,M as d,v as I,ab as u,g as o,E as L,I as P,B as v,U as S,e as f,q as j,t as l,f as T,d as C,Y as M,ac as w,V as A,W as D}from"./index-DqdaAEyo.js";import{u as E}from"./useInfiniteQuery-Dm7RR6wI.js";import{f as q}from"./usage-CjxizGfE.js";import{D as F}from"./DataTable-CDFSD9Kq.js";const K=50;function c(r){return r===null?e.jsx(l,{tone:"info",children:"In flight"}):r<400?e.jsx(l,{tone:"success",children:r}):r<500?e.jsx(l,{tone:"warning",children:r}):e.jsx(l,{tone:"danger",children:r})}function k({entry:r}){const n=q(r,Date.now());return n==="free"?e.jsx("span",{className:"gc-muted",title:"Served by a free seller: $0",children:"Free"}):n==="pending"?e.jsx("span",{className:"gc-muted",title:"The buyer reports spend a moment after the response",children:"pending"}):n==="not-recorded"?e.jsx("span",{className:"gc-muted",title:"No spend was reported for this request: the buyer lost it",children:"not recorded"}):e.jsx(e.Fragment,{children:T(r.spent)})}function O(r){try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}}function m({title:r,body:n}){return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("div",{className:"as-field__label",children:r}),e.jsx(D,{code:O(n)})]})}function $({detail:r}){return!r.requestBody&&!r.responseBody?e.jsx("p",{className:"gc-fineprint",children:"Bodies are not stored for this request. Turn on content logging under Settings → Observability to keep them."}):e.jsxs(e.Fragment,{children:[r.requestBody&&e.jsx(m,{title:"Request body",body:r.requestBody}),r.responseBody&&e.jsx(m,{title:"Response body",body:r.responseBody})]})}function U({entry:r}){const n=C({queryKey:j.request(r.tag),queryFn:()=>f.usage.request(r.tag),retry:!1,staleTime:6e4}),t=n.data??r,i=M(n.error)&&n.error.status===404;return e.jsxs(e.Fragment,{children:[t.errorCode||t.errorMessage?e.jsx(w,{tone:"danger",title:t.errorCode??"Request failed",children:t.errorMessage??"No message was returned."}):null,e.jsx(A,{items:[["Status",c(t.status)],["Request",e.jsxs(d,{children:[t.method," ",t.path]},"p")],["Model",t.model??"—"],["Key",t.keyLabel],["End user",t.endUser??"—"],["Seller",t.sellerPeerId?e.jsx(d,{children:t.sellerPeerId},"s"):"—"],["Latency",u(t.latencyMs)],["Duration",t.finishedAt?u(t.finishedAt-t.startedAt):"—"],["Input tokens",o(t.inputTokens)],["Cached input",o(t.cachedInputTokens)],["Output tokens",o(t.outputTokens)],["Cost",e.jsx(k,{entry:t},"c")],["Tag",e.jsx(d,{children:t.tag},"t")]]}),n.isLoading&&e.jsx(p,{rows:2}),n.error&&!i?e.jsx(x,{error:n.error,title:"Could not load the bodies"}):null,n.data&&e.jsx($,{detail:n.data})]})}function V({filter:r,showKey:n=!0}){var g;const[t,i]=R.useState(null),a=E({queryKey:j.requests(r),queryFn:({pageParam:s})=>f.usage.requests({...r,before:s??void 0,limit:K}),initialPageParam:null,getNextPageParam:s=>s.nextBefore,refetchInterval:s=>{var h;return(h=s.state.data)!=null&&h.pages.some(N=>N.requests.some(B=>q(B,Date.now())==="pending"))?5e3:!1}});if(a.isLoading)return e.jsx(p,{rows:8});if(a.error)return e.jsx(x,{error:a.error,onRetry:()=>void a.refetch()});const b=((g=a.data)==null?void 0:g.pages.flatMap(s=>s.requests))??[];return e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Request log",rows:b,rowKey:s=>s.tag,onRowClick:i,rowLabel:s=>`request ${s.tag}`,empty:e.jsx(L,{icon:e.jsx(P.logs,{size:18}),title:"No requests found",body:"Requests appear here as soon as a key is used. Check the filters if you expected some."}),columns:[{key:"time",header:"Time",render:s=>e.jsx("span",{className:"gc-nowrap",children:y(s.startedAt)})},...n?[{key:"key",header:"Key",secondary:!0,render:s=>s.keyLabel}]:[],{key:"model",header:"Model",render:s=>e.jsxs("span",{className:"gc-ellipsis",children:[s.model??s.path,s.status!==null&&s.status>=400?e.jsxs("span",{className:"gc-narrow-only",children:[" ",c(s.status)]}):null]})},{key:"seller",header:"Seller",secondary:!0,optional:!0,render:s=>s.sellerPeerId?e.jsx(d,{title:s.sellerPeerId,children:I(s.sellerPeerId)}):"—"},{key:"status",header:"Status",secondary:!0,render:s=>e.jsx("span",{title:s.errorMessage??void 0,children:c(s.status)})},{key:"latency",header:"Latency",align:"right",secondary:!0,optional:!0,render:s=>u(s.latencyMs)},{key:"tokens",header:"Tokens",align:"right",secondary:!0,render:s=>`${o(s.inputTokens)} → ${o(s.outputTokens)}`},{key:"cost",header:"Cost",align:"right",render:s=>e.jsx(k,{entry:s})}]}),a.hasNextPage&&e.jsx("div",{className:"gc-load-more",children:e.jsx(v,{variant:"outline",size:"sm",disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:a.isFetchingNextPage?"Loading…":"Load older requests"})}),e.jsx(S,{isOpen:t!==null,onClose:()=>i(null),title:(t==null?void 0:t.model)??"Request",subtitle:t?y(t.startedAt):void 0,eyebrow:"Request",children:t&&e.jsx(U,{entry:t},t.tag)})]})}export{V as R};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RewardsClaim-
|
|
2
|
-
import{u as v,D as b,F as k,d as N,q as m,G as S,H as R,r as c,j as e,P as z,Q as _,J as q,S as l,K as o,M as E,v as d,k as g,N as F,B as P,A as T,L as D,t as w,E as I,I as Q,_ as K,e as L}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RewardsClaim-BSNDTCMG.js","assets/index-DqdaAEyo.js","assets/index-M34IaZVB.css","assets/ants-B38m9Phv.js","assets/useTx-BRRWrJlB.js","assets/en_US-Y4ZOVFV4-CzjJ6dvA.js","assets/clsx-B-dksMZM.js","assets/index-D5ERwHFX.js","assets/index-BwpQbdIU.js","assets/en_US-Y4ZOVFV4-CcVPgXVa.css","assets/ConnectWallet-DSqRjyNA.js","assets/OperatorGateAlert-CCPFpK6Y.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as v,D as b,F as k,d as N,q as m,G as S,H as R,r as c,j as e,P as z,Q as _,J as q,S as l,K as o,M as E,v as d,k as g,N as F,B as P,A as T,L as D,t as w,E as I,I as Q,_ as K,e as L}from"./index-DqdaAEyo.js";import{C as O}from"./ChainGate-Dvm-SUef.js";import{f as r,a as $}from"./ants-B38m9Phv.js";import{D as B}from"./DataTable-CDFSD9Kq.js";import"./index-D5ERwHFX.js";const H=c.lazy(()=>K(()=>import("./RewardsClaim-BSNDTCMG.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])));function W(){const{workspace:t}=v(),x=b(),y=k(),j=N({queryKey:m.rewards(t.id),queryFn:()=>L.wallet.rewards(t.id)}),h=S(),p=R(t.id),[C,i]=c.useState(!1);return e.jsxs("div",{className:"gc-page",children:[e.jsx(z,{title:"Rewards",description:"ANTS earned by this workspace's usage. Claimed ANTS go to the authorized wallet."}),e.jsx(_,{query:j,rows:3,children:n=>{var u;const A=p.data?p.data.operator:n.operator,a={...n,operator:A};return e.jsxs(e.Fragment,{children:[e.jsx(q,{stale:n.stale}),e.jsxs("div",{className:"gc-grid gc-grid--3",children:[e.jsx(l,{label:"Ready to claim",value:r(a.pendingAnts)}),e.jsx(l,{label:"From the legacy program",value:r(((u=a.legacy)==null?void 0:u.pendingAnts)??"0"),sub:a.legacy?"Claimed together with the rest":void 0}),e.jsx(l,{label:"Authorized wallet",value:o(a.operator)?e.jsx(E,{title:a.operator,children:d(a.operator)}):"Not set"})]}),e.jsx(g,{children:e.jsxs("div",{className:"gc-summary-row",children:[e.jsxs("div",{className:"gc-summary-row__text",children:[e.jsx("span",{className:"gc-strong",children:$(a.pendingAnts)?`${r(a.pendingAnts)} ready to claim`:"Nothing to claim yet"}),e.jsx("span",{className:"gc-fineprint",children:o(a.operator)?e.jsxs(e.Fragment,{children:["Claimed ANTS go to the authorized wallet ",d(a.operator),", which signs the claim."]}):e.jsxs(e.Fragment,{children:["Only the authorized wallet can claim, and none is set. Authorize one on ",e.jsx(F,{to:"wallet",children:"Wallet & Funding"}),"."]})})]}),e.jsx(P,{size:"sm",variant:"outline",disabled:!o(a.operator),onClick:()=>i(!0),children:"Claim rewards"})]})}),e.jsx(T,{isOpen:C,onClose:()=>i(!1),title:"Claim rewards",subtitle:`${r(a.pendingAnts)} ready. Sent to the authorized wallet${o(a.operator)?` ${d(a.operator)}`:""}.`,children:e.jsx(O,{chain:h.data,error:h.error,children:s=>e.jsx(c.Suspense,{fallback:e.jsx(D,{rows:2}),children:e.jsx(H,{rewards:a,chain:s,onDone:()=>{y("Rewards claimed"),i(!1),x.invalidateQueries({queryKey:m.rewards(t.id)})}})})})}),e.jsx(g,{flush:!0,title:"Current program by epoch",description:"Rewards accrue at each epoch boundary from this workspace's paid usage.",children:e.jsx(B,{label:"Reward epochs",rows:[...a.epochs].sort((s,f)=>f.epoch-s.epoch),rowKey:s=>String(s.epoch),empty:e.jsx(I,{icon:e.jsx(Q.rewards,{size:18}),title:"No rewards yet",body:"Rewards accrue per epoch as this workspace's keys are used."}),columns:[{key:"epoch",header:"Epoch",render:s=>s.epoch},{key:"amount",header:"Amount",align:"right",render:s=>r(s.pendingAnts)},{key:"state",header:"Status",render:s=>s.claimed?e.jsx(w,{tone:"success",children:"Claimed"}):e.jsx(w,{tone:"warning",children:"Unclaimed"})}]})})]})}})]})}export{W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,u as R,H as B,aj as N,ak as E,ac as b,al as k,v as w,B as v}from"./index-
|
|
1
|
+
import{j as e,u as R,H as B,aj as N,ak as E,ac as b,al as k,v as w,B as v}from"./index-DqdaAEyo.js";import{a as I}from"./ants-B38m9Phv.js";import{u as O,a as S,T,U as x,s as C,L as j}from"./useTx-BRRWrJlB.js";import{a as _}from"./ConnectWallet-DSqRjyNA.js";import{O as W}from"./OperatorGateAlert-CCPFpK6Y.js";import{W as G,u as L,c as P}from"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";function U(a,s){return a?"Claiming…":s===0?"Nothing to claim":s===1?"Claim":`Claim (${s} transactions)`}function Y({rewards:a,chain:s,onDone:A}){const{address:r}=L(),u=P(),{workspace:h}=R(),p=B(h.id),{refresh:y}=N(h.id),i=O(s.chainId),{writeContractAsync:g}=S(),d=E(s,"usageRewards"),f=a.epochs.filter(t=>!t.claimed&&I(t.pendingAnts)),o=a.legacy&&I(a.legacy.pendingAnts)?a.legacy:null,l=f.length+(o?1:0);if(!d)return e.jsx(b,{tone:"warning",children:"The gateway did not report the usage rewards contract address."});const m=k(p.data,r,"claim rewards");return m.ok?e.jsxs("div",{className:"gc-stack",children:[e.jsxs("p",{className:"gc-fineprint",children:["The ANTS go to ",w(m.operator),", the connected authorized wallet."]}),e.jsx(T,{chain:s,runner:i,done:"Rewards claimed."}),e.jsx(v,{disabled:i.running||l===0,onClick:async()=>{const t=f.map(n=>{const c=[a.address,BigInt(n.epoch)];return{label:`Claim epoch ${n.epoch}`,check:()=>C(u,{account:r,address:d,abi:x,functionName:"claimBuyerReward",args:c,chainId:s.chainId}),send:()=>g({address:d,abi:x,functionName:"claimBuyerReward",args:c,chainId:s.chainId})}});if(o){const n=[a.address,o.epochs.map(BigInt)],c=o.contract;t.push({label:"Claim legacy emissions",check:()=>C(u,{account:r,address:c,abi:j,functionName:"claimBuyerEmissions",args:n,chainId:s.chainId}),send:()=>g({address:c,abi:j,functionName:"claimBuyerEmissions",args:n,chainId:s.chainId})})}await i.run(t,{onStale:()=>void y().catch(()=>{})})&&A()},children:U(i.running,l)}),l>1&&e.jsx("p",{className:"gc-fineprint",children:"Each current-program epoch is its own transaction; legacy emissions are one more."})]}):e.jsx(W,{gate:m,state:p.data,connected:r})}function V(a){return e.jsx(G,{chain:a.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(_,{}),e.jsx(Y,{...a})]})})}export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as C,a as se,b2 as O,b3 as ae,m as D,r as u,b as te,c as re,b4 as ie,d as ne,j as e,k as K,T as le,B as b,L as $,n as z,aY as oe,ac as q,z as N,t as A,b5 as G,E as ce,b6 as de,e as T,q as W,P as ue,b7 as pe,b8 as ge,D as V,b9 as H,aK as ye,ba as X,bb as M,bc as _,bd as Q,i as me,F as he,be as R,bf as we,bg as fe,aM as ve,A as xe}from"./index-BjRmy3XE.js";import{b as Z,a as je,d as be}from"./PolicyField-D7O5D7fl.js";import{p as Y,P as ke}from"./PolicyEditor-B5BAs2vC.js";import{S as U}from"./SelectField-BSNXjRiC.js";import{D as Pe}from"./DataTable-B36eMErM.js";import{T as Se,a as Ne}from"./Tabs-Dle_Eq4t.js";import"./Segmented-C9jux-Mr.js";import"./roving-DkptacxO.js";import"./Switch-hSHNLapF.js";import"./Disclosure-DS6GTz8G.js";import"./index-iM-80gy8.js";function P({level:a,children:t,result:i}){return e.jsxs("div",{className:i?"gc-source gc-source--result":"gc-source",children:[e.jsx("div",{className:"gc-source__level",children:a}),e.jsx("div",{className:"gc-source__policy",children:t})]})}function Ce(a,t,i,n){return a==="key"?(t??[]).filter(r=>r.status==="active").map(r=>({value:r.id,label:r.label})):a==="member"?(i??[]).map(({member:r})=>({value:r.id,label:r.label})):a==="preset"?(n??[]).map(r=>({value:r.slug,label:r.name})):[]}function Le(){const{workspace:a,viewer:t}=C(),i=se(),n=O(),r=ae(n.data),p=D(t),[s,c]=u.useState("workspace"),[l,g]=u.useState(""),[y,w]=u.useState(""),[f,v]=u.useState(null),m=te(i,s==="key"),d=re(a.id,s==="member"),L=ie(a.id,s==="preset"),h=ne({queryKey:W.routePreview(f??{}),queryFn:()=>T.network.routePreview(f),enabled:f!==null}),j=Ce(s,m.data,d.data,L.data);function x(){const o={model:y.trim(),workspace:a.id};s!=="workspace"&&l&&(o[s]=l),v(o)}return e.jsxs(K,{title:"Route preview",description:"See which sellers a request would go to, and why.",children:[e.jsxs("form",{className:"gc-toolbar",onSubmit:o=>{o.preventDefault(),x()},children:[e.jsx(U,{size:"sm","aria-label":"Preview for",value:s,onChange:o=>{c(o),g("")},options:[{value:"workspace",label:`Workspace: ${a.name}`},{value:"key",label:"A key"},...p?[{value:"member",label:"A member"}]:[],{value:"preset",label:"A preset"}]}),s!=="workspace"&&e.jsx(U,{size:"sm","aria-label":`Choose a ${s}`,value:l,onChange:g,options:[{value:"",label:`Choose a ${s}`},...j]}),e.jsx(le,{size:"sm","aria-label":"Model",placeholder:"Model id",list:"gc-preview-models",value:y,onChange:o=>w(o.target.value)}),e.jsx("datalist",{id:"gc-preview-models",children:r.map(o=>e.jsx("option",{value:o},o))}),e.jsx(b,{type:"submit",size:"sm",disabled:!y.trim()||s!=="workspace"&&!l,children:"Preview"})]}),h.isFetching&&e.jsx($,{rows:4}),h.error?e.jsx(z,{error:h.error}):null,h.data&&!h.isFetching&&e.jsx(Re,{preview:h.data})]})}const Ee={buyer:"Buyer",gateway:"Gateway","workspace-org":"Workspace (org policy)",workspace:"Workspace",member:"Member",key:"Key (admin)","key-owner":"Key (owner)",preset:"Preset"};function Me(a){return a.policy!==null?N(a.policy):e.jsx("span",{className:"gc-muted",children:a.level==="buyer"?"No hard limits":"Inherits"})}function Re({preview:a}){const{me:t}=C(),i=O(),n=oe(),r=a.candidates.filter(s=>s.eligible).length,p=s=>{var c;return s.id?s.level==="workspace"||s.level==="workspace-org"?((c=t.workspaces.find(l=>l.workspace.id===s.id))==null?void 0:c.workspace.name)??s.id:s.id:null};return e.jsxs("div",{className:"gc-stack",children:[!a.modelAllowed&&e.jsxs(q,{tone:"danger",title:"Model not allowed",children:["The policy does not allow ",a.model,". Requests for it get a 403."]}),e.jsxs("div",{className:"gc-sources",children:[a.sources.map((s,c)=>e.jsx(P,{level:e.jsxs(e.Fragment,{children:[Ee[s.level],p(s)?e.jsxs("span",{className:"gc-muted",children:[" · ",p(s)]}):null]}),children:Me(s)},`${s.level}-${c}`)),e.jsx(P,{level:"Effective",result:!0,children:N(a.policy)})]}),e.jsxs("p",{className:"gc-muted",children:[r," of ",a.candidates.length," sellers eligible."]}),r===0&&a.candidates.length>0&&e.jsxs(q,{tone:"warning",title:"No eligible seller",children:["Requests for ",a.model," fail with this policy. The reasons below show what excludes each seller."]}),e.jsx(Pe,{label:"Candidates",rows:[...a.candidates].sort((s,c)=>(s.rank??1e9)-(c.rank??1e9)),rowKey:s=>s.peerId,rowLabel:s=>s.displayName??Y(i.data,s.peerId),actions:s=>[de(n,s.peerId,a.model)],empty:e.jsx(ce,{title:"No seller offers this model"}),columns:[{key:"rank",header:"#",render:s=>s.rank??"—",width:"3rem"},{key:"seller",header:"Seller",render:s=>s.displayName??Y(i.data,s.peerId)},{key:"eligible",header:"Eligible",render:s=>s.eligible?e.jsx(A,{tone:"success",children:"Yes"}):e.jsx(A,{tone:"neutral",children:"No"})},{key:"reasons",header:"Why",render:s=>e.jsx("span",{className:"gc-muted",children:s.reasons.join(" · ")||"—"})},{key:"input",header:"Input $/M",align:"right",secondary:!0,render:s=>G(s.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,render:s=>G(s.outputUsdPerMillion)},{key:"trust",header:"Trust",align:"right",secondary:!0,render:s=>s.trustScore===null?"—":Math.round(s.trustScore)}]})]})}const S={gateway:{title:"Gateway default",description:()=>"Applies to every request through this gateway. Workspaces, members, keys and presets can only narrow it."},org:{title:"Organization policy",description:a=>`Set by organization admins for ${a}. Workspace admins can only narrow it.`},workspace:{title:"Workspace policy",description:a=>`Set by ${a}'s admins, on top of the gateway default and the organization policy.`}},B=(a,t)=>JSON.stringify(a)===JSON.stringify(t);function qe(a,t){if(!a)return e.jsx(A,{children:"Read only"});if(t)return e.jsx(A,{tone:"warning",children:"Unsaved changes"})}function I({layer:a,source:t,parent:i,canEdit:n,onSave:r}){const{workspace:p}=C(),s=he(),c=O(),l=H(),g=je(),[y,w]=u.useState(()=>R(t)),[f,v]=u.useState(()=>R(t)),[m,d]=u.useState(null),[L,h]=u.useState(!1),j=u.useMemo(()=>R(t),[t]),x=!B(y,f);u.useEffect(()=>{B(j,f)||(!x||B(j,y)?(w(j),v(j),d(null)):d(j))},[j]);const o=we({mutationFn:async()=>{const k=fe(y,l.data??null);return await g.save([k],ee=>r(k,ee))===ve?null:k},onSuccess:k=>{if(!k)return;const F=R(k);w(F),v(F),d(null),h(!1),s(`${S[a].title} saved`)}}),E=be(y,l.data??null);return e.jsxs(K,{title:S[a].title,description:S[a].description(p.name),actions:qe(n,x),children:[e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx(Z,{policy:x?E.policy:t,invalid:x&&E.error!==null}),x&&e.jsx("span",{className:"gc-fineprint",children:"Showing your unsaved edits."})]}),e.jsx(b,{size:"sm",variant:"outline",onClick:()=>h(!0),children:n?"Edit":"View"})]}),m&&n&&!L&&e.jsx(q,{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(xe,{isOpen:L,onClose:()=>h(!1),size:"xl",title:S[a].title,subtitle:S[a].description(p.name),footer:n?e.jsxs(e.Fragment,{children:[E.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:E.error}),e.jsx(b,{variant:"ghost",disabled:!x,onClick:()=>{w(f),d(null)},children:"Discard changes"}),e.jsx(b,{disabled:o.isPending||!x,onClick:()=>o.mutate(),children:o.isPending?"Saving…":"Save policy"})]}):e.jsx(b,{variant:"outline",onClick:()=>h(!1),children:"Close"}),children:e.jsxs("div",{className:"gc-stack",children:[m&&n&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",action:e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{w(m),v(m),d(null)},children:"Reload"}),e.jsx(b,{size:"sm",variant:"ghost",onClick:()=>{v(m),d(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."}),o.error?e.jsx(z,{error:o.error,title:"Could not save"}):null,e.jsx(ke,{value:y,onChange:w,peers:c.data,lists:l.data??[],parent:i,disabled:!n})]})}),g.dialog]})}function Ae(){const a=V(),t=X();return t.isLoading?e.jsx($,{rows:6}):t.error?e.jsx(z,{error:t.error,onRetry:()=>void t.refetch()}):e.jsx(I,{layer:"gateway",source:t.data??null,parent:null,canEdit:!0,onSave:async(i,n)=>{await T.network.setGatewayPolicy(i,n),await a.invalidateQueries({queryKey:W.group("routing")})}})}function J(){var f,v;const{workspace:a,viewer:t}=C(),i=V(),n=H(),r=ye(a.id),p=X(),s=n.data??[],c=p.data?M(p.data,s):null,l=((f=r.data)==null?void 0:f.orgRoutingPolicy)??null,g=((v=r.data)==null?void 0:v.routingPolicy)??null,y=u.useMemo(()=>_(c,l&&M(l,s),g&&M(g,s)),[c,l,g,s]);if(r.isLoading)return e.jsx($,{rows:6});if(r.error)return e.jsx(z,{error:r.error,onRetry:()=>void r.refetch()});const w=async()=>{await i.invalidateQueries({queryKey:W.group("workspaces")}),await i.invalidateQueries({queryKey:W.group("routing")})};return e.jsxs("div",{className:"gc-stack",children:[e.jsx(K,{title:"Effective for this workspace",description:"What keys in this workspace get before member, key and preset policies narrow it further.",children:e.jsxs("div",{className:"gc-sources",children:[e.jsx(P,{level:"Gateway default",children:N(p.data)}),e.jsx(P,{level:"Organization",children:N(l)}),e.jsx(P,{level:"Workspace",children:N(g)}),e.jsx(P,{level:"Effective",result:!0,children:e.jsx(Z,{policy:y})})]})}),e.jsx(I,{layer:"org",source:l,parent:c,canEdit:D(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{orgRoutingPolicy:Q(m)},d),await w()}}),e.jsx(I,{layer:"workspace",source:g,parent:_(c,l&&M(l,s)),canEdit:me(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{routingPolicy:Q(m)},d),await w()}})]})}function Te(){const a=pe();if(!a.data)return null;const t=ge(a.data);return e.jsxs("p",{className:"gc-fineprint",children:["Buyer config, which every policy here can only narrow: ",t.length>0?t.join(" · "):"none","."]})}function We(){const{viewer:a}=C(),t=D(a),[i,n]=u.useState(t?"gateway":"workspace");return t?e.jsxs(e.Fragment,{children:[e.jsx(Se,{id:"gc-routing-level",label:"Policy level",value:i,onChange:n,tabs:[{id:"gateway",label:"Gateway default"},{id:"workspace",label:"This workspace"}]}),e.jsx(Ne,{tabsId:"gc-routing-level",tab:i,children:i==="gateway"?e.jsx(Ae,{}):e.jsx(J,{})})]}):e.jsx(J,{})}function Ye(){return e.jsxs("div",{className:"gc-page",children:[e.jsx(ue,{title:"Routing",description:"Which sellers serve your requests and how they are ranked. Each level can only narrow the one above."}),e.jsx(Te,{}),e.jsx(We,{}),e.jsx(Le,{})]})}export{Ye as default};
|
|
1
|
+
import{u as C,a as se,b2 as O,b3 as ae,m as D,r as u,b as te,c as re,b4 as ie,d as ne,j as e,k as K,T as le,B as b,L as $,n as z,aY as oe,ac as q,z as N,t as A,b5 as G,E as ce,b6 as de,e as T,q as W,P as ue,b7 as pe,b8 as ge,D as V,b9 as H,aK as ye,ba as X,bb as M,bc as _,bd as Q,i as me,F as he,be as R,bf as we,bg as fe,aM as ve,A as xe}from"./index-DqdaAEyo.js";import{b as Z,a as je,d as be}from"./PolicyField-DIPl0B1x.js";import{p as Y,P as ke}from"./PolicyEditor-BdoaX9gK.js";import{S as U}from"./SelectField-D8fxDUNO.js";import{D as Pe}from"./DataTable-CDFSD9Kq.js";import{T as Se,a as Ne}from"./Tabs-BmjCmD5T.js";import"./Segmented-Qx6JB6EU.js";import"./roving-DkptacxO.js";import"./Switch-Ba56zux7.js";import"./Disclosure-UjXa2WU7.js";import"./index-D5ERwHFX.js";function P({level:a,children:t,result:i}){return e.jsxs("div",{className:i?"gc-source gc-source--result":"gc-source",children:[e.jsx("div",{className:"gc-source__level",children:a}),e.jsx("div",{className:"gc-source__policy",children:t})]})}function Ce(a,t,i,n){return a==="key"?(t??[]).filter(r=>r.status==="active").map(r=>({value:r.id,label:r.label})):a==="member"?(i??[]).map(({member:r})=>({value:r.id,label:r.label})):a==="preset"?(n??[]).map(r=>({value:r.slug,label:r.name})):[]}function Le(){const{workspace:a,viewer:t}=C(),i=se(),n=O(),r=ae(n.data),p=D(t),[s,c]=u.useState("workspace"),[l,g]=u.useState(""),[y,w]=u.useState(""),[f,v]=u.useState(null),m=te(i,s==="key"),d=re(a.id,s==="member"),L=ie(a.id,s==="preset"),h=ne({queryKey:W.routePreview(f??{}),queryFn:()=>T.network.routePreview(f),enabled:f!==null}),j=Ce(s,m.data,d.data,L.data);function x(){const o={model:y.trim(),workspace:a.id};s!=="workspace"&&l&&(o[s]=l),v(o)}return e.jsxs(K,{title:"Route preview",description:"See which sellers a request would go to, and why.",children:[e.jsxs("form",{className:"gc-toolbar",onSubmit:o=>{o.preventDefault(),x()},children:[e.jsx(U,{size:"sm","aria-label":"Preview for",value:s,onChange:o=>{c(o),g("")},options:[{value:"workspace",label:`Workspace: ${a.name}`},{value:"key",label:"A key"},...p?[{value:"member",label:"A member"}]:[],{value:"preset",label:"A preset"}]}),s!=="workspace"&&e.jsx(U,{size:"sm","aria-label":`Choose a ${s}`,value:l,onChange:g,options:[{value:"",label:`Choose a ${s}`},...j]}),e.jsx(le,{size:"sm","aria-label":"Model",placeholder:"Model id",list:"gc-preview-models",value:y,onChange:o=>w(o.target.value)}),e.jsx("datalist",{id:"gc-preview-models",children:r.map(o=>e.jsx("option",{value:o},o))}),e.jsx(b,{type:"submit",size:"sm",disabled:!y.trim()||s!=="workspace"&&!l,children:"Preview"})]}),h.isFetching&&e.jsx($,{rows:4}),h.error?e.jsx(z,{error:h.error}):null,h.data&&!h.isFetching&&e.jsx(Re,{preview:h.data})]})}const Ee={buyer:"Buyer",gateway:"Gateway","workspace-org":"Workspace (org policy)",workspace:"Workspace",member:"Member",key:"Key (admin)","key-owner":"Key (owner)",preset:"Preset"};function Me(a){return a.policy!==null?N(a.policy):e.jsx("span",{className:"gc-muted",children:a.level==="buyer"?"No hard limits":"Inherits"})}function Re({preview:a}){const{me:t}=C(),i=O(),n=oe(),r=a.candidates.filter(s=>s.eligible).length,p=s=>{var c;return s.id?s.level==="workspace"||s.level==="workspace-org"?((c=t.workspaces.find(l=>l.workspace.id===s.id))==null?void 0:c.workspace.name)??s.id:s.id:null};return e.jsxs("div",{className:"gc-stack",children:[!a.modelAllowed&&e.jsxs(q,{tone:"danger",title:"Model not allowed",children:["The policy does not allow ",a.model,". Requests for it get a 403."]}),e.jsxs("div",{className:"gc-sources",children:[a.sources.map((s,c)=>e.jsx(P,{level:e.jsxs(e.Fragment,{children:[Ee[s.level],p(s)?e.jsxs("span",{className:"gc-muted",children:[" · ",p(s)]}):null]}),children:Me(s)},`${s.level}-${c}`)),e.jsx(P,{level:"Effective",result:!0,children:N(a.policy)})]}),e.jsxs("p",{className:"gc-muted",children:[r," of ",a.candidates.length," sellers eligible."]}),r===0&&a.candidates.length>0&&e.jsxs(q,{tone:"warning",title:"No eligible seller",children:["Requests for ",a.model," fail with this policy. The reasons below show what excludes each seller."]}),e.jsx(Pe,{label:"Candidates",rows:[...a.candidates].sort((s,c)=>(s.rank??1e9)-(c.rank??1e9)),rowKey:s=>s.peerId,rowLabel:s=>s.displayName??Y(i.data,s.peerId),actions:s=>[de(n,s.peerId,a.model)],empty:e.jsx(ce,{title:"No seller offers this model"}),columns:[{key:"rank",header:"#",render:s=>s.rank??"—",width:"3rem"},{key:"seller",header:"Seller",render:s=>s.displayName??Y(i.data,s.peerId)},{key:"eligible",header:"Eligible",render:s=>s.eligible?e.jsx(A,{tone:"success",children:"Yes"}):e.jsx(A,{tone:"neutral",children:"No"})},{key:"reasons",header:"Why",render:s=>e.jsx("span",{className:"gc-muted",children:s.reasons.join(" · ")||"—"})},{key:"input",header:"Input $/M",align:"right",secondary:!0,render:s=>G(s.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,render:s=>G(s.outputUsdPerMillion)},{key:"trust",header:"Trust",align:"right",secondary:!0,render:s=>s.trustScore===null?"—":Math.round(s.trustScore)}]})]})}const S={gateway:{title:"Gateway default",description:()=>"Applies to every request through this gateway. Workspaces, members, keys and presets can only narrow it."},org:{title:"Organization policy",description:a=>`Set by organization admins for ${a}. Workspace admins can only narrow it.`},workspace:{title:"Workspace policy",description:a=>`Set by ${a}'s admins, on top of the gateway default and the organization policy.`}},B=(a,t)=>JSON.stringify(a)===JSON.stringify(t);function qe(a,t){if(!a)return e.jsx(A,{children:"Read only"});if(t)return e.jsx(A,{tone:"warning",children:"Unsaved changes"})}function I({layer:a,source:t,parent:i,canEdit:n,onSave:r}){const{workspace:p}=C(),s=he(),c=O(),l=H(),g=je(),[y,w]=u.useState(()=>R(t)),[f,v]=u.useState(()=>R(t)),[m,d]=u.useState(null),[L,h]=u.useState(!1),j=u.useMemo(()=>R(t),[t]),x=!B(y,f);u.useEffect(()=>{B(j,f)||(!x||B(j,y)?(w(j),v(j),d(null)):d(j))},[j]);const o=we({mutationFn:async()=>{const k=fe(y,l.data??null);return await g.save([k],ee=>r(k,ee))===ve?null:k},onSuccess:k=>{if(!k)return;const F=R(k);w(F),v(F),d(null),h(!1),s(`${S[a].title} saved`)}}),E=be(y,l.data??null);return e.jsxs(K,{title:S[a].title,description:S[a].description(p.name),actions:qe(n,x),children:[e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx(Z,{policy:x?E.policy:t,invalid:x&&E.error!==null}),x&&e.jsx("span",{className:"gc-fineprint",children:"Showing your unsaved edits."})]}),e.jsx(b,{size:"sm",variant:"outline",onClick:()=>h(!0),children:n?"Edit":"View"})]}),m&&n&&!L&&e.jsx(q,{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(xe,{isOpen:L,onClose:()=>h(!1),size:"xl",title:S[a].title,subtitle:S[a].description(p.name),footer:n?e.jsxs(e.Fragment,{children:[E.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:E.error}),e.jsx(b,{variant:"ghost",disabled:!x,onClick:()=>{w(f),d(null)},children:"Discard changes"}),e.jsx(b,{disabled:o.isPending||!x,onClick:()=>o.mutate(),children:o.isPending?"Saving…":"Save policy"})]}):e.jsx(b,{variant:"outline",onClick:()=>h(!1),children:"Close"}),children:e.jsxs("div",{className:"gc-stack",children:[m&&n&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",action:e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{w(m),v(m),d(null)},children:"Reload"}),e.jsx(b,{size:"sm",variant:"ghost",onClick:()=>{v(m),d(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."}),o.error?e.jsx(z,{error:o.error,title:"Could not save"}):null,e.jsx(ke,{value:y,onChange:w,peers:c.data,lists:l.data??[],parent:i,disabled:!n})]})}),g.dialog]})}function Ae(){const a=V(),t=X();return t.isLoading?e.jsx($,{rows:6}):t.error?e.jsx(z,{error:t.error,onRetry:()=>void t.refetch()}):e.jsx(I,{layer:"gateway",source:t.data??null,parent:null,canEdit:!0,onSave:async(i,n)=>{await T.network.setGatewayPolicy(i,n),await a.invalidateQueries({queryKey:W.group("routing")})}})}function J(){var f,v;const{workspace:a,viewer:t}=C(),i=V(),n=H(),r=ye(a.id),p=X(),s=n.data??[],c=p.data?M(p.data,s):null,l=((f=r.data)==null?void 0:f.orgRoutingPolicy)??null,g=((v=r.data)==null?void 0:v.routingPolicy)??null,y=u.useMemo(()=>_(c,l&&M(l,s),g&&M(g,s)),[c,l,g,s]);if(r.isLoading)return e.jsx($,{rows:6});if(r.error)return e.jsx(z,{error:r.error,onRetry:()=>void r.refetch()});const w=async()=>{await i.invalidateQueries({queryKey:W.group("workspaces")}),await i.invalidateQueries({queryKey:W.group("routing")})};return e.jsxs("div",{className:"gc-stack",children:[e.jsx(K,{title:"Effective for this workspace",description:"What keys in this workspace get before member, key and preset policies narrow it further.",children:e.jsxs("div",{className:"gc-sources",children:[e.jsx(P,{level:"Gateway default",children:N(p.data)}),e.jsx(P,{level:"Organization",children:N(l)}),e.jsx(P,{level:"Workspace",children:N(g)}),e.jsx(P,{level:"Effective",result:!0,children:e.jsx(Z,{policy:y})})]})}),e.jsx(I,{layer:"org",source:l,parent:c,canEdit:D(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{orgRoutingPolicy:Q(m)},d),await w()}}),e.jsx(I,{layer:"workspace",source:g,parent:_(c,l&&M(l,s)),canEdit:me(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{routingPolicy:Q(m)},d),await w()}})]})}function Te(){const a=pe();if(!a.data)return null;const t=ge(a.data);return e.jsxs("p",{className:"gc-fineprint",children:["Buyer config, which every policy here can only narrow: ",t.length>0?t.join(" · "):"none","."]})}function We(){const{viewer:a}=C(),t=D(a),[i,n]=u.useState(t?"gateway":"workspace");return t?e.jsxs(e.Fragment,{children:[e.jsx(Se,{id:"gc-routing-level",label:"Policy level",value:i,onChange:n,tabs:[{id:"gateway",label:"Gateway default"},{id:"workspace",label:"This workspace"}]}),e.jsx(Ne,{tabsId:"gc-routing-level",tab:i,children:i==="gateway"?e.jsx(Ae,{}):e.jsx(J,{})})]}):e.jsx(J,{})}function Ye(){return e.jsxs("div",{className:"gc-page",children:[e.jsx(ue,{title:"Routing",description:"Which sellers serve your requests and how they are ranked. Each level can only narrow the one above."}),e.jsx(Te,{}),e.jsx(We,{}),e.jsx(Le,{})]})}export{Ye as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as m}from"./index-
|
|
1
|
+
import{j as m}from"./index-DqdaAEyo.js";import{r as f,f as g}from"./roving-DkptacxO.js";function _({value:l,onChange:n,options:a,label:u,className:c}){const o=Math.max(0,a.findIndex(e=>e.value===l));return m.jsx("div",{className:["as-segmented",c].filter(Boolean).join(" "),role:"radiogroup","aria-label":u,children:a.map((e,d)=>{const i=e.value===l;return m.jsx("button",{type:"button",role:"radio","aria-checked":i,tabIndex:d===o?0:-1,disabled:e.disabled,className:i?"as-segmented__item as-segmented__item--on":"as-segmented__item",onClick:()=>n(e.value),onKeyDown:t=>{const r=f(t,d,a.length);if(r===null)return;t.preventDefault();const s=a[r];!s||s.disabled||(n(s.value),g(t,r,".as-segmented__item"))},children:e.label},e.value)})})}export{_ as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as j,j as e,Z as o,$ as h,a0 as f}from"./index-
|
|
1
|
+
import{r as j,j as e,Z as o,$ as h,a0 as f}from"./index-DqdaAEyo.js";function b({label:a,hint:d,error:t,options:c,onChange:r,className:i,id:n,size:u,...x}){const m=j.useId(),l=n??m;return e.jsxs("label",{className:f(i,u),htmlFor:l,children:[a&&e.jsx("span",{className:"as-field__label",children:a}),e.jsx("select",{id:l,className:o("as-field__select"),onChange:s=>r(s.target.value),...x,children:c.map(s=>e.jsx("option",{value:s.value,disabled:s.disabled,children:s.label},s.value))}),e.jsx(h,{error:t,hint:d})]})}export{b as S};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{D as re,F as ne,b2 as ge,b9 as xe,r as d,bf as ae,q as U,e as E,bt as ve,bc as be,b5 as K,f as fe,j as t,ac as D,bo as ye,T as O,B as y,n as $,C as ie,d as Se,P as je,Q as z,ad as we,k as A,V as le,M as ke,t as M,u as Pe,R as Re,s as Q,aG as Ne,a9 as W,aP as Ce,a8 as Me,E as Ie,I as G,A as Y,aF as Ue,Y as qe}from"./index-DqdaAEyo.js";import{a as J,S as Z}from"./PolicyEditor-BdoaX9gK.js";import{S as Te}from"./Segmented-Qx6JB6EU.js";import{S as I}from"./Switch-Ba56zux7.js";import{D as F}from"./Disclosure-UjXa2WU7.js";import{T as oe}from"./TextAreaField-CF9_zjuC.js";import{T as Oe,a as Ee}from"./Tabs-BmjCmD5T.js";import{D as Ae}from"./DataTable-CDFSD9Kq.js";import{S as B}from"./SelectField-D8fxDUNO.js";import"./roving-DkptacxO.js";import"./index-D5ERwHFX.js";function Fe(e){return Object.entries(e).map(([s,r])=>`${s}: ${r}`).join(`
|
|
2
|
+
`)}function De(e){const s={};for(const[r,n]of e.split(`
|
|
3
|
+
`).entries()){if(!n.trim())continue;const c=n.indexOf(":");if(c<=0)throw new Error(`Line ${r+1}: use "Name: value".`);const u=n.slice(0,c).trim();if(!/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(u))throw new Error(`Line ${r+1}: "${u}" is not a valid header name.`);s[u]=n.slice(c+1).trim()}return s}const ce="••••";function $e(e){return e.split(`
|
|
4
|
+
`).map(s=>{const r=s.indexOf(":");return r>0&&s.slice(r+1).trim()===ce?s.slice(0,r).trim():null}).filter(s=>!!s)}function X(e){return e.split(`
|
|
5
|
+
`).map(s=>{const r=s.indexOf(":");return r>0&&s.slice(r+1).trim()===ce?`${s.slice(0,r)}: `:s}).join(`
|
|
6
|
+
`)}function _e(e,s){if(!e||!s)return!1;try{return new URL(e).origin!==new URL(s).origin}catch{return e!==s}}function Le(e){const s={},r=(n,c,u)=>{const a=e[n].trim();if(a===""){c&&(s[n]="Required.");return}const h=Number(a);!Number.isFinite(h)||h<0?s[n]="Use a number of 0 or more.":u!==void 0&&h>u&&(s[n]=`At most ${u}.`)};return r("input",!0),r("output",!0),r("cached",!1),r("reputation",!0,100),s}function w(e,s={}){const r=e.trim();if(r==="")return s.required?"Required.":void 0;const n=Number(r),c=s.min??0;if(!Number.isFinite(n))return"Use a number.";if(s.integer&&!Number.isInteger(n))return"Use a whole number.";if(n<c)return`Use ${c} or more.`;if(s.max!==void 0&&n>s.max)return`At most ${s.max}.`}function V(e){return e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)}function ee(e){const s=e.find(r=>!/^(?:0x)?[0-9a-f]{40}$/i.test(r));return s?`"${s}" is not a 40-character hex seller id.`:void 0}function te(e){const s=e.find(r=>!/^https?:\/\/\S+$/.test(r));return s?`"${s}" is not an http(s) URL.`:void 0}function ue(e,s){return e.some(r=>r===s||s.startsWith(`${r}.`)||r.startsWith(`${s}.`))}function Be(){return t.jsxs("span",{className:"gc-override",children:[t.jsx("span",{className:"gc-attention","aria-hidden":"true"}),"Overridden by the buyer's environment or start flags"]})}function se(e){const s=e.routingPreferences,r=n=>n===null?"":String(n);return{allowMode:s.allowedPeerIds.length>0?"only":"any",allowedPeerIds:[...s.allowedPeerIds],blockedPeerIds:[...s.blockedPeerIds],minTrustScore:String(s.minTrustScore),minReputation:String(e.minPeerReputation),preferFree:s.preferFreePeers,softInputCap:String(s.maxInputUsdPerMillion),maxInput:String(e.maxPricing.inputUsdPerMillion),maxOutput:String(e.maxPricing.outputUsdPerMillion),maxCached:r(e.maxPricing.cachedInputUsdPerMillion),verify:e.verifier.enabled,requireVerified:e.verifier.require,verifiers:e.verifier.prefer.join(", "),sampleRate:r(e.evidence.sampleRate),maxSampleBytes:r(e.evidence.maxSampleBytes),autoSweep:e.payments.autoSweep,maxPerRequest:String(e.payments.maxPerRequestUsdc),maxReserve:String(e.payments.maxReserveUsdc),rpcUrl:e.payments.rpcUrl??"",fallbackRpcUrls:e.payments.fallbackRpcUrls.join(`
|
|
7
|
+
`),peerRefreshMs:String(e.network.peerRefreshIntervalMs),metadataTimeoutMs:String(e.network.metadataFetchTimeoutMs),requestTimeoutMs:String(e.network.requestTimeoutMs),maxStreamMs:String(e.network.maxStreamDurationMs),perServiceMetadata:!e.network.disableMetadataV2Services}}function Ve(e){const s=Le({input:e.maxInput,output:e.maxOutput,cached:e.maxCached,reputation:e.minReputation}),r={maxInput:s.input,maxOutput:s.output,maxCached:s.cached,softInputCap:w(e.softInputCap,{required:!0}),allowedPeerIds:e.allowMode==="only"?ee(e.allowedPeerIds):void 0,blockedPeerIds:ee(e.blockedPeerIds),sampleRate:w(e.sampleRate,{max:1}),maxSampleBytes:w(e.maxSampleBytes,{min:1,integer:!0}),maxPerRequest:w(e.maxPerRequest,{required:!0,min:1e-6}),maxReserve:w(e.maxReserve,{required:!0,min:1e-6}),rpcUrl:e.rpcUrl.trim()?te([e.rpcUrl.trim()]):void 0,fallbackRpcUrls:te(V(e.fallbackRpcUrls)),peerRefreshMs:w(e.peerRefreshMs,{required:!0,min:1e3,integer:!0}),metadataTimeoutMs:w(e.metadataTimeoutMs,{required:!0,min:100,integer:!0}),requestTimeoutMs:w(e.requestTimeoutMs,{required:!0,min:1,integer:!0}),maxStreamMs:w(e.maxStreamMs,{required:!0,min:1,integer:!0})};return Object.fromEntries(Object.entries(r).filter(([,n])=>n))}function ze(e){const s=r=>r.trim()?Number(r):null;return{routingPreferences:{minTrustScore:Number(e.minTrustScore),maxInputUsdPerMillion:Number(e.softInputCap),preferFreePeers:e.preferFree,allowedPeerIds:e.allowMode==="only"?e.allowedPeerIds:[],blockedPeerIds:e.blockedPeerIds},maxPricing:{inputUsdPerMillion:Number(e.maxInput),outputUsdPerMillion:Number(e.maxOutput),cachedInputUsdPerMillion:s(e.maxCached)},minPeerReputation:Number(e.minReputation),verifier:{enabled:e.verify,require:e.verify&&e.requireVerified,prefer:e.verify?V(e.verifiers):[]},evidence:{sampleRate:s(e.sampleRate),maxSampleBytes:s(e.maxSampleBytes)},payments:{autoSweep:e.autoSweep,maxPerRequestUsdc:Number(e.maxPerRequest),maxReserveUsdc:Number(e.maxReserve),rpcUrl:e.rpcUrl.trim()||null,fallbackRpcUrls:V(e.fallbackRpcUrls)},network:{peerRefreshIntervalMs:Number(e.peerRefreshMs),metadataFetchTimeoutMs:Number(e.metadataTimeoutMs),requestTimeoutMs:Number(e.requestTimeoutMs),maxStreamDurationMs:Number(e.maxStreamMs),disableMetadataV2Services:!e.perServiceMetadata}}}const He=["allowMode","allowedPeerIds","blockedPeerIds","minTrustScore","preferFree","softInputCap"];function L(e,s){return Object.keys(s).filter(r=>JSON.stringify(e[r])!==JSON.stringify(s[r]))}function Ke(e){const s=r=>r.trim()&&Number.isFinite(Number(r))?Number(r):void 0;return{...e.allowMode==="only"&&e.allowedPeerIds.length>0?{allowedPeerIds:e.allowedPeerIds}:{},...e.blockedPeerIds.length>0?{blockedPeerIds:e.blockedPeerIds}:{},...s(e.minTrustScore)?{minTrustScore:s(e.minTrustScore)}:{},...s(e.minReputation)?{minReputation:s(e.minReputation)}:{},...s(e.maxInput)!==void 0?{maxInputUsdPerMillion:s(e.maxInput)}:{},...s(e.maxOutput)!==void 0?{maxOutputUsdPerMillion:s(e.maxOutput)}:{},...s(e.maxCached)!==void 0?{maxCachedInputUsdPerMillion:s(e.maxCached)}:{}}}function Qe({buyer:e}){const s=re(),r=ne(),n=ge(),c=xe(),u=d.useMemo(()=>se(e),[e]),[a,h]=d.useState(u),[k,P]=d.useState(u),[v,S]=d.useState(null),[b,p]=d.useState(!1),[j,g]=d.useState(!1),l=(i,R)=>h(N=>({...N,[i]:R})),m=i=>{h(i),P(i),S(null)},o=Ve(a),q=L(k,a);d.useEffect(()=>{L(k,u).length!==0&&(q.length===0||L(u,a).length===0?m(u):S(u))},[u]);const _=q.some(i=>!He.includes(i)),C=i=>ue(e.overrides,i)?t.jsx(Be,{}):void 0,H=(i,R)=>C(i)??R,f=ae({mutationFn:()=>E.settings.updateBuyer(ze(a)),onSuccess:i=>{const{restartRequired:R,...N}=i;s.setQueryData(U.settings,N),m(se(N.buyer)),s.invalidateQueries({queryKey:U.buyerLimits}),p(!1),g(R===!0),r(_?R?"Saved. Restart the buyer to apply them.":"Saved. The buyer is restarting.":"Saved. The buyer applies these at once.")}}),T=d.useMemo(()=>!n.data||n.data.length===0?null:{matched:ve(be(Ke(a)),n.data,c.data??[]).length,total:n.data.length},[a,n.data,c.data]),de=`${K(Number(a.maxInput))} in · ${K(Number(a.maxOutput))} out`,me=a.verify?a.requireVerified?"Required":"On":"Off",pe=`${a.autoSweep?"Auto-sweep on":"Auto-sweep off"} · ${fe(Number(a.maxPerRequest))} per request`,x=(i,R,N={})=>t.jsx(O,{size:"sm",className:N.className??"gc-num",label:R,inputMode:"decimal",placeholder:N.placeholder,value:a[i],error:o[i],hint:N.hint,onChange:he=>l(i,he.target.value)});return t.jsxs("div",{className:"gc-stack",children:[t.jsxs("div",{className:"gc-policy",children:[T&&(T.matched===0?t.jsxs(D,{tone:"warning",title:"No seller matches these settings",children:["None of the ",T.total," sellers this gateway sees passes them, so every request will fail."]}):t.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",T.matched," of ",T.total," sellers. Every key can only narrow this."]})),t.jsxs("div",{className:"gc-policy__cols",children:[t.jsxs("section",{className:"gc-policy__section",children:[t.jsx("h3",{children:"Sellers"}),t.jsx(Te,{label:"Which sellers may serve",value:a.allowMode,onChange:i=>l("allowMode",i),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),a.allowMode==="only"&&t.jsxs(t.Fragment,{children:[t.jsx(J,{label:"Allowed sellers",value:a.allowedPeerIds,onChange:i=>l("allowedPeerIds",i),peers:n.data}),o.allowedPeerIds&&t.jsx("p",{className:"gc-warn",children:o.allowedPeerIds}),a.allowedPeerIds.length===0&&t.jsx("p",{className:"gc-fineprint",children:"With no sellers listed, any seller may serve."})]}),t.jsx(J,{label:"Blocked sellers",value:a.blockedPeerIds,onChange:i=>l("blockedPeerIds",i),peers:n.data}),o.blockedPeerIds&&t.jsx("p",{className:"gc-warn",children:o.blockedPeerIds}),t.jsx("p",{className:"gc-fineprint",children:"Blocked here means blocked for every key."})]}),t.jsxs("section",{className:"gc-policy__section",children:[t.jsx("h3",{children:"Quality and ranking"}),t.jsx(Z,{label:"Minimum trust score",clearable:!1,value:a.minTrustScore,onChange:i=>l("minTrustScore",i),hint:"Keys can raise it, not lower it."}),(ye(n.data)||a.minReputation!=="0")&&t.jsx(Z,{label:"Minimum reputation",clearable:!1,value:a.minReputation,onChange:i=>l("minReputation",i),hint:H("minPeerReputation","Applies to pinned sellers too.")}),t.jsx("div",{className:"gc-policy__switches",children:t.jsx(I,{checked:a.preferFree,onChange:i=>l("preferFree",i),label:"Free sellers first"})}),x("softInputCap","Soft input price limit $/M",{hint:"Pricier sellers rank lower; none is excluded.",className:"gc-num gc-num--wide"})]})]}),t.jsxs("div",{className:"gc-policy__advanced",children:[t.jsxs(F,{title:"Price caps",summary:de,children:[t.jsx("p",{className:"gc-fineprint",children:"Hard limits for every request, pinned sellers included."}),t.jsxs("div",{className:"gc-policy__caps",children:[x("maxInput","Input $/M",{hint:C("maxPricing.inputUsdPerMillion")}),x("maxOutput","Output $/M",{hint:C("maxPricing.outputUsdPerMillion")}),x("maxCached","Cached input $/M",{placeholder:"Same as input"})]})]}),t.jsxs(F,{title:"Verification",summary:me,children:[C("verifier"),t.jsxs("div",{className:"gc-policy__switches",children:[t.jsx(I,{checked:a.verify,onChange:i=>l("verify",i),label:"Verify sellers"}),t.jsx(I,{checked:a.verify&&a.requireVerified,disabled:!a.verify,onChange:i=>l("requireVerified",i),label:"Require verification"})]}),t.jsx(O,{size:"sm",label:"Verifiers",value:a.verifiers,disabled:!a.verify,placeholder:"Seller's trusted default",hint:"Ordered, comma-separated verifier ids, e.g. TEE attestation.",onChange:i=>l("verifiers",i.target.value)}),t.jsxs("div",{className:"gc-policy__caps",children:[x("sampleRate","Evidence sample rate",{placeholder:"Default",hint:"Share of responses kept, 0 to 1."}),x("maxSampleBytes","Largest sample (bytes)",{placeholder:"Default",className:"gc-num gc-num--wide"})]})]}),t.jsxs(F,{title:"Payments",summary:pe,children:[t.jsx(I,{checked:a.autoSweep,onChange:i=>l("autoSweep",i),label:"Sweep deposits automatically",description:"Move USDC that arrives in the workspace wallets into their deposits."}),t.jsxs("div",{className:"gc-policy__caps",children:[x("maxPerRequest","Max per request (USDC)",{className:"gc-num gc-num--wide"}),x("maxReserve","Max channel reserve (USDC)",{className:"gc-num gc-num--wide"})]}),t.jsx(O,{size:"sm",label:"Base RPC URL",value:a.rpcUrl,error:o.rpcUrl,placeholder:"Chain default",hint:H("payments.rpcUrl","Your own endpoint avoids public rate limits. Saved URLs show without their path; leave them as they are to keep them."),onChange:i=>l("rpcUrl",i.target.value)}),t.jsx(oe,{label:"Fallback RPC URLs",rows:2,mono:!0,value:a.fallbackRpcUrls,error:o.fallbackRpcUrls,hint:"One per line, tried in order.",onChange:i=>l("fallbackRpcUrls",i.target.value)})]}),t.jsxs(F,{title:"Network and timeouts",summary:`Refresh ${Math.round(Number(a.peerRefreshMs)/1e3)} s`,children:[t.jsxs("div",{className:"gc-policy__caps",children:[x("peerRefreshMs","Peer refresh (ms)",{className:"gc-num gc-num--wide"}),x("metadataTimeoutMs","Metadata timeout (ms)",{className:"gc-num gc-num--wide",hint:C("network.metadataFetchTimeoutMs")}),x("requestTimeoutMs","Response start timeout (ms)",{className:"gc-num gc-num--wide"}),x("maxStreamMs","Longest stream (ms)",{className:"gc-num gc-num--wide",hint:C("network.maxStreamDurationMs")})]}),t.jsx(I,{checked:a.perServiceMetadata,onChange:i=>l("perServiceMetadata",i),label:"Per-service attribution in signed metadata",description:C("network.disableMetadataV2Services")??"Tells sellers which service each request used."})]})]})]}),j&&t.jsxs(D,{tone:"warning",title:"Restart the buyer to apply",children:["Saved, but this buyer was not restarted automatically. Restart it (for example ",t.jsx("code",{children:"systemctl restart antseed-buyer"}),", or stop and start ",t.jsx("code",{children:"antseed buyer start"}),") to use the new settings."]}),v&&t.jsx(D,{tone:"warning",title:"Changed elsewhere",action:t.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[t.jsx(y,{size:"sm",variant:"outline",onClick:()=>m(v),children:"Reload"}),t.jsx(y,{size:"sm",variant:"ghost",onClick:()=>{P(v),S(null)},children:"Keep editing"})]}),children:"Someone saved the buyer settings while you were editing them. Reload to see their version (your edits are dropped), or keep editing and save to replace it."}),!b&&f.error?t.jsx($,{error:f.error,title:"Could not save"}):null,t.jsxs("div",{className:"gc-actions",children:[t.jsx("span",{className:"gc-fineprint gc-actions__note",children:q.length===0?"No changes.":_?"Saving restarts the buyer.":"Applies at once, without a restart."}),t.jsx(y,{variant:"ghost",disabled:q.length===0||f.isPending,onClick:()=>m(v??k),children:"Reset"}),t.jsx(y,{disabled:q.length===0||Object.keys(o).length>0||f.isPending,onClick:()=>_?p(!0):f.mutate(),children:f.isPending?"Saving…":"Save"})]}),t.jsx(ie,{isOpen:b,busy:f.isPending,error:f.error,onClose:()=>{p(!1),f.reset()},onConfirm:()=>f.mutate(),title:"Restart the buyer?",confirmLabel:"Save and restart",tone:"primary",body:"These changes need a buyer restart. Requests in flight finish first; new requests wait a few seconds while it reconnects."})]})}const We=["general","buyer","observability","tokens","auth"];function Ge(){const e=we();return t.jsx(A,{title:"Gateway",children:t.jsx(z,{query:e,children:s=>t.jsx(le,{items:[["Public URL",s.publicUrl?t.jsx(ke,{children:s.publicUrl},"u"):t.jsx("span",{className:"gc-muted",children:"Not set. Clients use this console's address."})],["Version",s.version],["Buyer",s.buyer.reachable?t.jsx(M,{tone:"success",children:"Connected"},"b"):t.jsx(M,{tone:"danger",children:"Unreachable"},"b")],["Sellers seen",String(s.buyer.peers)],["Spend feed",s.spendFeed],["USDC top-ups (x402)",s.x402?"On":"Off"]]})})})}function Ye({settings:e}){const s=e.buyer;return t.jsx(A,{title:"Buyer",description:t.jsxs(t.Fragment,{children:["The top of every routing policy: workspaces, members, keys and presets can only narrow it. Saved to the config file of the buyer on port ",s.proxyPort,ue(s.overrides,"proxyPort")?" (set by its start flags)":"","."]}),children:t.jsx(Qe,{buyer:s})})}function Je({settings:e}){const s=re(),r=ne(),n=e.observability,[c,u]=d.useState(n.otlpEndpoint??""),[a,h]=d.useState(Fe(n.otlpHeaders)),[k,P]=d.useState(n.logContent),[v,S]=d.useState(n.retentionDays===null?"":String(n.retentionDays)),b=c.trim()&&!/^https?:\/\/\S+$/.test(c.trim())?"Use an http:// or https:// URL.":void 0,p=_e(n.otlpEndpoint,c.trim()||null)?$e(a):[],j=p.length?`Enter the value of ${p.join(", ")} again: saved values are not sent to a new endpoint.`:void 0,g=ae({mutationFn:()=>{if(b)throw new Error(b);if(j)throw new Error(j);const l=v===""?null:Number(v);return E.settings.setObservability({otlpEndpoint:c.trim()||null,otlpHeaders:De(a),logContent:k,retentionDays:l})},onSuccess:l=>{const{restartRequired:m,...o}=l;s.setQueryData(U.settings,o),r(m?"Observability saved. Restart the gateway to apply it.":"Observability saved")},onError:l=>{qe(l,"otlp_headers_required")&&h(X(a))}});return t.jsx(A,{title:"Observability",description:"Send one OpenTelemetry trace per request, and choose what the request log keeps.",children:t.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),g.mutate()},children:[t.jsx(O,{label:"OTLP/HTTP endpoint",placeholder:"https://otel.example.com/v1/traces",value:c,error:b,onChange:l=>u(l.target.value)}),t.jsx(oe,{label:"Headers",rows:3,mono:!0,placeholder:"Authorization: Bearer …",value:a,onChange:l=>h(l.target.value),error:j,hint:"One per line, as Name: value. Saved values show as ••••; leave them as they are to keep them (for the same endpoint only)."}),p.length>0&&t.jsx("div",{children:t.jsx(y,{size:"sm",variant:"outline",onClick:()=>h(X(a)),children:"Clear saved values to re-enter them"})}),t.jsx(I,{checked:k,onChange:P,label:"Store request and response bodies",description:"Off by default. Bodies can contain personal data; only turn this on if you need it."}),t.jsx(B,{label:"Keep the request log for",value:v,onChange:S,options:[{value:"7",label:"7 days"},{value:"30",label:"30 days"},{value:"90",label:"90 days"},{value:"365",label:"1 year"},{value:"",label:"Forever"}]}),g.error?t.jsx($,{error:g.error,title:"Could not save"}):null,t.jsx("div",{className:"gc-actions",children:t.jsx(y,{type:"submit",disabled:g.isPending,children:g.isPending?"Saving…":"Save"})})]})})}function Ze(){const{me:e}=Pe(),s=e.member.orgRole==="owner",r=Re(),[n,c]=d.useState(!1),[u,a]=d.useState(""),[h,k]=d.useState("read"),[P,v]=d.useState("90"),[S,b]=d.useState(null),[p,j]=d.useState(null),g=Q({mutationFn:()=>E.adminTokens.create(u.trim(),h,P==="never"?null:Number(P)),onSuccess:m=>{c(!1),a(""),b(m.secret)},invalidate:[U.adminTokens]}),l=Q({mutationFn:m=>E.adminTokens.revoke(m.id),onSuccess:()=>j(null),invalidate:[U.adminTokens]});return t.jsxs(A,{flush:!0,title:"Management tokens",description:t.jsxs(t.Fragment,{children:["For scripts and CI. Send as ",t.jsx("code",{children:"Authorization: Bearer …"})," to ",t.jsx("code",{children:"/console/api"}),"."]}),actions:t.jsx(y,{size:"sm",leadingIcon:t.jsx(G.plus,{size:14}),onClick:()=>c(!0),children:"New token"}),children:[t.jsx(z,{query:r,children:m=>t.jsx(Ae,{label:"Management tokens",rows:m,rowKey:o=>o.id,rowLabel:o=>o.label,actions:o=>[{label:"Revoke",tone:"danger",onSelect:()=>j(o)}],empty:t.jsx(Ie,{icon:t.jsx(G.keys,{size:18}),title:"No management tokens"}),columns:[{key:"label",header:"Name",render:o=>t.jsx(Ne,{name:o.label,hint:o.hint})},{key:"scope",header:"Scope",render:o=>o.scope==="admin"?t.jsx(M,{tone:"warning",children:"Admin"}):t.jsx(M,{children:"Read only"})},{key:"created",header:"Created",secondary:!0,optional:!0,render:o=>W(o.createdAt)},{key:"expires",header:"Expires",secondary:!0,render:o=>t.jsx(Ce,{at:o.expiresAt,format:W})},{key:"used",header:"Last used",secondary:!0,optional:!0,render:o=>Me(o.lastUsedAt)}]})}),t.jsx(Y,{isOpen:n,onClose:()=>c(!1),title:"New management token",children:t.jsxs("form",{className:"gc-stack",onSubmit:m=>{m.preventDefault(),g.mutate()},children:[t.jsx(O,{label:"Name",required:!0,value:u,onChange:m=>a(m.target.value),placeholder:"e.g. Terraform"}),t.jsx(B,{label:"Scope",value:h,onChange:m=>k(m),options:[{value:"read",label:"Read only (GET requests)"},{value:"admin",label:"Admin (everything an org admin can do)"}]}),t.jsx(B,{label:"Expires after",value:P,onChange:v,options:[{value:"30",label:"30 days"},{value:"90",label:"90 days"},{value:"365",label:"1 year"},...s?[{value:"never",label:"Never"}]:[]],hint:"Short-lived tokens limit the damage if one leaks."}),g.error?t.jsx($,{error:g.error,title:"Could not create the token"}):null,t.jsxs("div",{className:"gc-actions",children:[t.jsx(y,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),t.jsx(y,{type:"submit",disabled:g.isPending||!u.trim(),children:"Create token"})]})]})}),t.jsx(Y,{isOpen:S!==null,onClose:()=>b(null),title:"Token created",children:S&&t.jsxs("div",{className:"gc-stack",children:[t.jsx(Ue,{secret:S}),t.jsx("div",{className:"gc-actions",children:t.jsx(y,{onClick:()=>b(null),children:"Done"})})]})}),t.jsx(ie,{isOpen:p!==null,busy:l.isPending,error:l.error,onClose:()=>j(null),onConfirm:()=>p&&l.mutate(p),title:"Revoke this token?",confirmLabel:"Revoke",body:`Anything using ${(p==null?void 0:p.label)??"this token"} loses access immediately.`})]})}function Xe({settings:e}){const s=e.auth,r=n=>n?t.jsx(M,{tone:"success",children:"On"}):t.jsx(M,{children:"Off"});return t.jsx(A,{title:"Sign-in methods",description:"Configured on the gateway host with environment variables. Read only here.",children:t.jsxs("div",{className:"gc-stack",children:[t.jsx(le,{items:[["Passkeys",r(s.passkey)],["Wallet (Sign-In with Ethereum)",r(s.wallet)],["OpenID Connect",s.oidc?t.jsx(M,{tone:"success",children:s.oidc.label},"o"):r(!1)],["Cloudflare Access",r(s.cloudflareAccess)],["API key view for key holders",r(s.apiKeyLogin)]]}),t.jsx(D,{tone:"info",title:"Using your own identity provider",children:"Set the OpenID Connect issuer, client id and secret in the gateway's environment and restart it, or put the console behind Cloudflare Access and enable trusted Access headers. The gateway docs list the exact variables. Antseed runs no sign-in service of its own."})]})})}function et({tab:e,settings:s}){return e==="buyer"?t.jsx(Ye,{settings:s}):e==="observability"?t.jsx(Je,{settings:s}):t.jsx(Xe,{settings:s})}function mt(){const[e,s]=d.useState(()=>{const n=new URLSearchParams(window.location.search).get("tab");return We.includes(n)?n:"general"}),r=Se({queryKey:U.settings,queryFn:E.settings.get});return d.useEffect(()=>{var n;(n=window.scrollTo)==null||n.call(window,0,0)},[e]),t.jsxs("div",{className:"gc-page",children:[t.jsx(je,{title:"Settings"}),t.jsx(Oe,{id:"gc-settings",label:"Settings sections",value:e,onChange:s,tabs:[{id:"general",label:"General"},{id:"buyer",label:"Buyer"},{id:"observability",label:"Observability"},{id:"tokens",label:"Management tokens"},{id:"auth",label:"Sign-in"}]}),t.jsxs(Ee,{tabsId:"gc-settings",tab:e,className:"gc-stack",children:[e==="general"&&t.jsx(Ge,{}),e==="tokens"&&t.jsx(Ze,{}),(e==="buyer"||e==="observability"||e==="auth")&&t.jsx(z,{query:r,children:n=>t.jsx(et,{tab:e,settings:n})}),r.error&&e==="general"?t.jsx($,{error:r.error}):null]})]})}export{mt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,j as s}from"./index-
|
|
1
|
+
import{r as e,j as s}from"./index-DqdaAEyo.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 +1 @@
|
|
|
1
|
-
import{r as _,j as l}from"./index-
|
|
1
|
+
import{r as _,j as l}from"./index-DqdaAEyo.js";import{r as j,f as I}from"./roving-DkptacxO.js";function u(a,n){return`${a}-tab-${n}`}function f(a,n){return`${a}-panel-${n}`}function y({value:a,onChange:n,tabs:e,id:s,label:o,className:x}){const p=_.useId(),d=s??p,m=Math.max(0,e.findIndex(t=>t.id===a));return l.jsx("div",{className:["as-tabs",x].filter(Boolean).join(" "),role:"tablist","aria-label":o,children:e.map((t,c)=>{const b=t.id===a;return l.jsx("button",{id:u(d,t.id),type:"button",role:"tab","aria-selected":b,"aria-controls":f(d,t.id),tabIndex:c===m?0:-1,className:b?"as-tabs__tab as-tabs__tab--on":"as-tabs__tab",onClick:()=>n(t.id),onKeyDown:r=>{const i=j(r,c,e.length);i!==null&&(r.preventDefault(),n(e[i].id),I(r,i,".as-tabs__tab"))},children:t.label},t.id)})})}function N({tabsId:a,tab:n,children:e,className:s,...o}){return l.jsx("div",{id:f(a,n),role:"tabpanel","aria-labelledby":u(a,n),tabIndex:0,className:["as-tabpanel",s].filter(Boolean).join(" "),...o,children:e})}export{y as T,N as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as s,Z as c,$ as m,a0 as u}from"./index-
|
|
1
|
+
import{r as o,j as s,Z as c,$ as m,a0 as u}from"./index-DqdaAEyo.js";function j({label:a,hint:i,error:e,className:l,id:d,mono:r,...n}){const x=o.useId(),t=d??x;return s.jsxs("label",{className:u(l),htmlFor:t,children:[a&&s.jsx("span",{className:"as-field__label",children:a}),s.jsx("textarea",{id:t,className:c("as-field__textarea",r),"aria-invalid":e?!0:void 0,...n}),s.jsx(m,{error:e,hint:i})]})}export{j as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as y,d as q,j as t,L as O,n as x,E as j,I as C,l as M,g as b,f as R,h as v,e as w,q as I}from"./index-
|
|
1
|
+
import{r as y,d as q,j as t,L as O,n as x,E as j,I as C,l as M,g as b,f as R,h as v,e as w,q as I}from"./index-DqdaAEyo.js";import{a as L,b as U,c as B,t as N,s as _,O as F,d as $}from"./usage-CjxizGfE.js";import{S as c,O as A,a as H}from"./Charts-DAh9h4sf.js";const K=[{value:"spend",label:"Spend"},{value:"requests",label:"Requests"},{value:"tokens",label:"Tokens"}],z={spend:e=>R(e),requests:e=>b(e,{compact:!0}),tokens:e=>v(e)};function h(e){return e==="24h"?"hour":e==="90d"?"week":"day"}const D={input:c[0],cached:c[5],output:c[2]};function P(e,r){return e==="tokens"?`Tokens per ${h(r)} by type (input, cached input, output), UTC.`:`${K.find(l=>l.value===e).label} per ${h(r)} by model, UTC. The largest models get their own colour.`}function V({filter:e,range:r,now:l,metric:o,height:d}){const n=y.useMemo(()=>L(r,l),[r,l]),k={...e,from:n[0].from,to:n.at(-1).to-1,groupBy:$(r),splitBy:"model"},a=q({queryKey:I.usage(k),queryFn:()=>w.usage.report(k)}),i=y.useMemo(()=>U(a.data,n),[a.data,n]);if(a.isLoading)return t.jsx(O,{rows:1,height:d??240});if(a.error)return t.jsx(x,{error:a.error,onRetry:()=>void a.refetch()});const p=B(i);if(p===0)return t.jsx(j,{icon:t.jsx(C.activity,{size:18}),title:"No usage in this range",body:"Requests made with this workspace's keys show up here."});const m=o==="tokens"?N(i):_(i,o),f=m.series.map((s,u)=>({...s,color:o==="tokens"?D[s.key]:s.key===F?A:c[u%c.length]})),E=f.reduce((s,u)=>s+u.total,0),g=i.reduce((s,u)=>s+u.groups.reduce((S,T)=>S+M(T.spent),0),0);return t.jsxs(t.Fragment,{children:[t.jsx(H,{label:o==="tokens"?"tokens by type":`${o} by model`,labels:n.map(s=>s.label),columns:m.columns,series:f,format:z[o],height:d}),E===0&&t.jsxs("p",{className:"gc-fineprint",children:[b(p)," ",p===1?"request":"requests",", ",R(g)," recorded so far",o==="tokens"?" (no token counts reported yet)":"","."]})]})}export{K as M,V as U,P as c};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalletFunding-CvDkcGVU.js","assets/index-DqdaAEyo.js","assets/index-M34IaZVB.css","assets/en_US-Y4ZOVFV4-CzjJ6dvA.js","assets/clsx-B-dksMZM.js","assets/index-D5ERwHFX.js","assets/index-BwpQbdIU.js","assets/en_US-Y4ZOVFV4-CcVPgXVa.css","assets/useTx-BRRWrJlB.js","assets/ConnectWallet-DSqRjyNA.js","assets/OperatorGateAlert-CCPFpK6Y.js","assets/OperatorActions-DTrUYN6Z.js","assets/ChannelClose-9Lq8KHLH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as t,r as L,Y as Dt,e as te,D as ae,c3 as qt,F as re,c4 as Bt,f as T,l as W,c5 as Mt,ak as Ut,c0 as Ft,B as P,I as z,q as J,L as le,v as H,ap as Ue,A as X,ac as ne,_ as ce,ag as Fe,H as Rt,G as ue,aj as Ot,k as Oe,Q as Ve,K as He,c6 as Vt,av as Ht,t as Lt,a8 as Kt,u as Wt,bS as Jt,P as Qt,J as Yt,m as Gt,c7 as Zt,c8 as Xt,bU as ie,c9 as $t,M as kt,d as en,am as tn,s as nn,ca as rn,cb as sn,cc as on,cd as an,an as Qe,X as ln,E as cn,ce as Ye,cf as un}from"./index-DqdaAEyo.js";import{C as de}from"./ChainGate-Dvm-SUef.js";import{b as dn}from"./index-BwpQbdIU.js";import{r as hn}from"./dijkstra-COg3n3zL.js";import{D as fn}from"./Disclosure-UjXa2WU7.js";import{D as gn}from"./DataTable-CDFSD9Kq.js";import{S as mn}from"./Switch-Ba56zux7.js";import"./index-D5ERwHFX.js";const pn="#2775CA";function wn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:pn}),t.jsx("text",{x:"12",y:"16.6",textAnchor:"middle",fontSize:"13.5",fontWeight:"700",fill:"#fff",children:"$"})]})}function yn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:"#0052FF"}),t.jsx("rect",{x:"1",y:"10.95",width:"15.85",height:"2.1",fill:"#fff"})]})}const xn="M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-164-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.5 0 130.9 2.6 198.3 99.2zm-234-181.5c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.5 32.4-55.1 83.6-55.1 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 135.5-71.3z";function vn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11.5",fill:"#fff",stroke:"#d5d7db"}),t.jsx("path",{d:xn,fill:"#000",transform:"translate(7.3 6.4) scale(0.0115)"})]})}function Ge({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11.5",fill:"#fff",stroke:"#d5d7db"}),t.jsx("circle",{cx:"9.4",cy:"12",r:"4.6",fill:"#EB001B"}),t.jsx("circle",{cx:"14.6",cy:"12",r:"4.6",fill:"#F79E1B",fillOpacity:"0.9"})]})}function Cn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11.5",fill:"#fff",stroke:"#d5d7db"}),t.jsxs("g",{transform:"translate(6 6) scale(0.5)",children:[t.jsx("path",{fill:"#4285F4",d:"M23.49 12.27c0-.79-.07-1.54-.19-2.27H12v4.51h6.47c-.29 1.48-1.14 2.73-2.4 3.58v3h3.86c2.26-2.09 3.56-5.17 3.56-8.82z"}),t.jsx("path",{fill:"#34A853",d:"M12 24c3.24 0 5.95-1.08 7.93-2.91l-3.86-3c-1.08.72-2.45 1.16-4.07 1.16-3.13 0-5.78-2.11-6.73-4.96H1.29v3.09C3.26 21.31 7.31 24 12 24z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.27 14.29c-.25-.72-.38-1.49-.38-2.29s.14-1.57.38-2.29V6.62H1.29C.47 8.24 0 10.06 0 12s.47 3.76 1.29 5.38l3.98-3.09z"}),t.jsx("path",{fill:"#EA4335",d:"M12 4.75c1.77 0 3.35.61 4.6 1.8l3.42-3.42C17.95 1.19 15.24 0 12 0 7.31 0 3.26 2.69 1.29 6.62l3.98 3.09C6.22 6.86 8.87 4.75 12 4.75z"})]})]})}function Ze({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:"#1434CB"}),t.jsx("text",{x:"12",y:"14.6",textAnchor:"middle",fontSize:"7",fontWeight:"800",fontStyle:"italic",fill:"#fff",children:"VISA"})]})}function jn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:"#016FD0"}),t.jsx("text",{x:"12",y:"14.6",textAnchor:"middle",fontSize:"6",fontWeight:"800",fill:"#fff",children:"AMEX"})]})}function bn({size:e=22}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 512 512","aria-hidden":"true",children:[t.jsx("rect",{width:"512",height:"512",rx:"64",fill:"#533AFD"}),t.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M120 392L392 334.317V120L120 178.357V392Z",fill:"#fff"})]})}function En({size:e=20}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 542.25 542.25",fill:"#34D399","aria-hidden":"true",children:[t.jsx("path",{d:"M493.18,424.48l-106.09,106.09c-7.48,7.48-17.63,11.69-28.21,11.69h-192.03l250.27-250.27,76.06,76.06c15.58,15.58,15.58,40.85,0,56.43Z"}),t.jsx("path",{d:"M375.41,0L125.14,250.27l-76.06-76.06c-15.58-15.58-15.58-40.85,0-56.43L155.16,11.69c7.48-7.48,17.63-11.69,28.21-11.69h192.03Z"}),t.jsx("path",{d:"M542.25,375.41l-250.27-250.27,76.06-76.06c15.58-15.58,40.85-15.58,56.43,0l106.09,106.09c7.48,7.48,11.69,17.63,11.69,28.21v192.03Z"}),t.jsx("path",{d:"M250.27,417.12l-76.06,76.06c-15.58,15.58-40.85,15.58-56.43,0L11.69,387.09c-7.48-7.48-11.69-17.63-11.69-28.21v-192.03l250.27,250.27Z"})]})}function Nn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 2500 2500","aria-hidden":"true",children:[t.jsx("path",{fill:"#213147",d:"M226,760v980c0,63,33,120,88,152l849,490c54,31,121,31,175,0l849-490c54-31,88-89,88-152V760c0-63-33-120-88-152l-849-490c-54-31-121-31-175,0L314,608c-54,31-87,89-87,152H226z"}),t.jsx("path",{fill:"#12AAFF",d:"M1435,1440l-121,332c-3,9-3,19,0,29l208,571l241-139l-289-793C1467,1422,1442,1422,1435,1440z"}),t.jsx("path",{fill:"#12AAFF",d:"M1678,882c-7-18-32-18-39,0l-121,332c-3,9-3,19,0,29l341,935l241-139L1678,883V882z"}),t.jsx("path",{fill:"#9DCCED",d:"M1250,155c6,0,12,2,17,5l918,530c11,6,17,18,17,30v1060c0,12-7,24-17,30l-918,530c-5,3-11,5-17,5s-12-2-17-5l-918-530c-11-6-17-18-17-30V719c0-12,7-24,17-30l918-530c5-3,11-5,17-5l0,0V155z M1250,0c-33,0-65,8-95,25L237,555c-59,34-95,96-95,164v1060c0,68,36,130,95,164l918,530c29,17,62,25,95,25s65-8,95-25l918-530c59-34,95-96,95-164V719c0-68-36-130-95-164L1344,25c-29-17-62-25-95-25l0,0H1250z"}),t.jsx("polygon",{fill:"#213147",points:"642,2179 727,1947 897,2088 738,2234"}),t.jsx("path",{fill:"#fff",d:"M1172,644H939c-17,0-33,11-39,27L401,2039l241,139l550-1507c5-14-5-28-19-28L1172,644z"}),t.jsx("path",{fill:"#fff",d:"M1580,644h-233c-17,0-33,11-39,27L738,2233l241,139l620-1701c5-14-5-28-19-28V644z"})]})}function An({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 2496 2496","aria-hidden":"true",children:[t.jsx("path",{fill:"#F0B90B",fillRule:"evenodd",clipRule:"evenodd",d:"M1248,0c689.3,0,1248,558.7,1248,1248s-558.7,1248-1248,1248S0,1937.3,0,1248S558.7,0,1248,0L1248,0z"}),t.jsxs("g",{fill:"#fff",children:[t.jsx("path",{d:"M685.9,1248l0.9,330l280.4,165v193.2l-444.5-260.7v-524L685.9,1248L685.9,1248z M685.9,918v192.3l-163.3-96.6V821.4l163.3-96.6l164.1,96.6L685.9,918L685.9,918z M1084.3,821.4l163.3-96.6l164.1,96.6L1247.6,918L1084.3,821.4L1084.3,821.4z"}),t.jsx("path",{d:"M803.9,1509.6v-193.2l163.3,96.6v192.3L803.9,1509.6L803.9,1509.6z M1084.3,1812.2l163.3,96.6l164.1-96.6v192.3l-164.1,96.6l-163.3-96.6V1812.2L1084.3,1812.2z M1645.9,821.4l163.3-96.6l164.1,96.6v192.3l-164.1,96.6V918L1645.9,821.4L1645.9,821.4L1645.9,821.4z M1809.2,1578l0.9-330l163.3-96.6v524l-444.5,260.7v-193.2L1809.2,1578L1809.2,1578L1809.2,1578z"}),t.jsx("polygon",{points:"1692.1,1509.6 1528.8,1605.3 1528.8,1413 1692.1,1316.4 1692.1,1509.6"}),t.jsx("path",{d:"M1692.1,986.4l0.9,193.2l-281.2,165v330.8l-163.3,95.7l-163.3-95.7v-330.8l-281.2-165V986.4L968,889.8l279.5,165.8l281.2-165.8l164.1,96.6H1692.1L1692.1,986.4z M803.9,656.5l443.7-261.6l444.5,261.6l-163.3,96.6l-281.2-165.8L967.2,753.1L803.9,656.5L803.9,656.5z"})]})]})}function Sn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"12",fill:"#6C00F6"}),t.jsx("path",{fill:"#fff",transform:"translate(5.5 6.15) scale(0.0731)",d:"M66.8,54.7l-16.7-9.7L0,74.1v58l50.1,29l50.1-29V41.9L128,25.8l27.8,16.1v32.2L128,90.2l-16.7-9.7v25.8l16.7,9.7l50.1-29V29L128,0L77.9,29v90.2l-27.8,16.1l-27.8-16.1V86.9l27.8-16.1l16.7,9.7V54.7z"})]})}function Bn({size:e=18}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32","aria-hidden":"true",children:[t.jsx("circle",{cx:"16",cy:"16",r:"16",fill:"#627EEA"}),t.jsxs("g",{fill:"#fff",fillRule:"nonzero",children:[t.jsx("path",{fillOpacity:"0.602",d:"M16.498 4v8.87l7.497 3.35z"}),t.jsx("path",{d:"M16.498 4L9 16.22l7.498-3.35z"}),t.jsx("path",{fillOpacity:"0.602",d:"M16.498 21.968v6.027L24 17.616z"}),t.jsx("path",{d:"M16.498 27.995v-6.028L9 17.616z"}),t.jsx("path",{fillOpacity:"0.2",d:"M16.498 20.573l7.497-4.353-7.497-3.348z"}),t.jsx("path",{fillOpacity:"0.602",d:"M9 16.22l7.498 4.353v-7.701z"})]})]})}const Mn=6e4;function Rn(e,s,o=document){let n,r=!1,i=!1;const a=g=>{r||(i=g==="active",s.wallet.watch(e,g).catch(y=>{Dt(y)&&y.status===409&&(r=!0)}))},l=()=>{clearInterval(n),a("active"),n=setInterval(()=>a("active"),Mn)},c=()=>{clearInterval(n),i&&a("background")},f=()=>o.visibilityState==="hidden"?c():l();return o.visibilityState!=="hidden"&&l(),o.addEventListener("visibilitychange",f),()=>{o.removeEventListener("visibilitychange",f),c(),r=!0}}function Ln(e){L.useEffect(()=>Rn(e,te),[e])}const oe=3e4;function kn(e,s=oe,{minIntervalMs:o=oe,doc:n=document}={}){const r=Math.max(s,o);let i;const a=()=>{clearInterval(i),i=setInterval(e,r)},l=()=>{n.visibilityState==="hidden"?(clearInterval(i),i=void 0):(e(),a())};return n.visibilityState!=="hidden"&&a(),n.addEventListener("visibilitychange",l),()=>{clearInterval(i),n.removeEventListener("visibilitychange",l)}}function Tn(e,s=oe,o=oe){const n=ae(),r=JSON.stringify(e);L.useEffect(()=>kn(()=>void n.invalidateQueries({queryKey:JSON.parse(r)}),s,{minIntervalMs:o}),[r,s,o,n])}var Z={},pe,Xe;function Pn(){return Xe||(Xe=1,pe=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),pe}var we={},V={},$e;function Q(){if($e)return V;$e=1;let e;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return V.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},V.getSymbolTotalCodewords=function(n){return s[n]},V.getBCHDigit=function(o){let n=0;for(;o!==0;)n++,o>>>=1;return n},V.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');e=n},V.isKanjiModeEnabled=function(){return typeof e<"u"},V.toSJIS=function(n){return e(n)},V}var ye={},et;function Ke(){return et||(et=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function s(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+o)}}e.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return s(n)}catch{return r}}})(ye)),ye}var xe,tt;function In(){if(tt)return xe;tt=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(s){const o=Math.floor(s/8);return(this.buffer[o]>>>7-s%8&1)===1},put:function(s,o){for(let n=0;n<o;n++)this.putBit((s>>>o-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),s&&(this.buffer[o]|=128>>>this.length%8),this.length++}},xe=e,xe}var ve,nt;function _n(){if(nt)return ve;nt=1;function e(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return e.prototype.set=function(s,o,n,r){const i=s*this.size+o;this.data[i]=n,r&&(this.reservedBit[i]=!0)},e.prototype.get=function(s,o){return this.data[s*this.size+o]},e.prototype.xor=function(s,o,n){this.data[s*this.size+o]^=n},e.prototype.isReserved=function(s,o){return this.reservedBit[s*this.size+o]},ve=e,ve}var Ce={},rt;function zn(){return rt||(rt=1,(function(e){const s=Q().getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const r=Math.floor(n/7)+2,i=s(n),a=i===145?26:Math.ceil((i-13)/(2*r-2))*2,l=[i-7];for(let c=1;c<r-1;c++)l[c]=l[c-1]-a;return l.push(6),l.reverse()},e.getPositions=function(n){const r=[],i=e.getRowColCoords(n),a=i.length;for(let l=0;l<a;l++)for(let c=0;c<a;c++)l===0&&c===0||l===0&&c===a-1||l===a-1&&c===0||r.push([i[l],i[c]]);return r}})(Ce)),Ce}var je={},it;function Dn(){if(it)return je;it=1;const e=Q().getSymbolSize,s=7;return je.getPositions=function(n){const r=e(n);return[[0,0],[r-s,0],[0,r-s]]},je}var be={},st;function qn(){return st||(st=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};e.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},e.from=function(r){return e.isValid(r)?parseInt(r,10):void 0},e.getPenaltyN1=function(r){const i=r.size;let a=0,l=0,c=0,f=null,g=null;for(let y=0;y<i;y++){l=c=0,f=g=null;for(let m=0;m<i;m++){let h=r.get(y,m);h===f?l++:(l>=5&&(a+=s.N1+(l-5)),f=h,l=1),h=r.get(m,y),h===g?c++:(c>=5&&(a+=s.N1+(c-5)),g=h,c=1)}l>=5&&(a+=s.N1+(l-5)),c>=5&&(a+=s.N1+(c-5))}return a},e.getPenaltyN2=function(r){const i=r.size;let a=0;for(let l=0;l<i-1;l++)for(let c=0;c<i-1;c++){const f=r.get(l,c)+r.get(l,c+1)+r.get(l+1,c)+r.get(l+1,c+1);(f===4||f===0)&&a++}return a*s.N2},e.getPenaltyN3=function(r){const i=r.size;let a=0,l=0,c=0;for(let f=0;f<i;f++){l=c=0;for(let g=0;g<i;g++)l=l<<1&2047|r.get(f,g),g>=10&&(l===1488||l===93)&&a++,c=c<<1&2047|r.get(g,f),g>=10&&(c===1488||c===93)&&a++}return a*s.N3},e.getPenaltyN4=function(r){let i=0;const a=r.data.length;for(let c=0;c<a;c++)i+=r.data[c];return Math.abs(Math.ceil(i*100/a/5)-10)*s.N4};function o(n,r,i){switch(n){case e.Patterns.PATTERN000:return(r+i)%2===0;case e.Patterns.PATTERN001:return r%2===0;case e.Patterns.PATTERN010:return i%3===0;case e.Patterns.PATTERN011:return(r+i)%3===0;case e.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(i/3))%2===0;case e.Patterns.PATTERN101:return r*i%2+r*i%3===0;case e.Patterns.PATTERN110:return(r*i%2+r*i%3)%2===0;case e.Patterns.PATTERN111:return(r*i%3+(r+i)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}e.applyMask=function(r,i){const a=i.size;for(let l=0;l<a;l++)for(let c=0;c<a;c++)i.isReserved(c,l)||i.xor(c,l,o(r,c,l))},e.getBestMask=function(r,i){const a=Object.keys(e.Patterns).length;let l=0,c=1/0;for(let f=0;f<a;f++){i(f),e.applyMask(f,r);const g=e.getPenaltyN1(r)+e.getPenaltyN2(r)+e.getPenaltyN3(r)+e.getPenaltyN4(r);e.applyMask(f,r),g<c&&(c=g,l=f)}return l}})(be)),be}var se={},ot;function Tt(){if(ot)return se;ot=1;const e=Ke(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return se.getBlocksCount=function(r,i){switch(i){case e.L:return s[(r-1)*4+0];case e.M:return s[(r-1)*4+1];case e.Q:return s[(r-1)*4+2];case e.H:return s[(r-1)*4+3];default:return}},se.getTotalCodewordsCount=function(r,i){switch(i){case e.L:return o[(r-1)*4+0];case e.M:return o[(r-1)*4+1];case e.Q:return o[(r-1)*4+2];case e.H:return o[(r-1)*4+3];default:return}},se}var Ee={},ee={},at;function Un(){if(at)return ee;at=1;const e=new Uint8Array(512),s=new Uint8Array(256);return(function(){let n=1;for(let r=0;r<255;r++)e[r]=n,s[n]=r,n<<=1,n&256&&(n^=285);for(let r=255;r<512;r++)e[r]=e[r-255]})(),ee.log=function(n){if(n<1)throw new Error("log("+n+")");return s[n]},ee.exp=function(n){return e[n]},ee.mul=function(n,r){return n===0||r===0?0:e[s[n]+s[r]]},ee}var lt;function Fn(){return lt||(lt=1,(function(e){const s=Un();e.mul=function(n,r){const i=new Uint8Array(n.length+r.length-1);for(let a=0;a<n.length;a++)for(let l=0;l<r.length;l++)i[a+l]^=s.mul(n[a],r[l]);return i},e.mod=function(n,r){let i=new Uint8Array(n);for(;i.length-r.length>=0;){const a=i[0];for(let c=0;c<r.length;c++)i[c]^=s.mul(r[c],a);let l=0;for(;l<i.length&&i[l]===0;)l++;i=i.slice(l)}return i},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,s.exp(i)]));return r}})(Ee)),Ee}var Ne,ct;function On(){if(ct)return Ne;ct=1;const e=Fn();function s(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(n){this.degree=n,this.genPoly=e.generateECPolynomial(this.degree)},s.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(n.length+this.degree);r.set(n);const i=e.mod(r,this.genPoly),a=this.degree-i.length;if(a>0){const l=new Uint8Array(this.degree);return l.set(i,a),l}return i},Ne=s,Ne}var Ae={},Se={},Be={},ut;function Pt(){return ut||(ut=1,Be.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),Be}var q={},dt;function It(){if(dt)return q;dt=1;const e="[0-9]+",s="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
|
|
3
|
+
]))+`;q.KANJI=new RegExp(o,"g"),q.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),q.BYTE=new RegExp(n,"g"),q.NUMERIC=new RegExp(e,"g"),q.ALPHANUMERIC=new RegExp(s,"g");const r=new RegExp("^"+o+"$"),i=new RegExp("^"+e+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return q.testKanji=function(c){return r.test(c)},q.testNumeric=function(c){return i.test(c)},q.testAlphanumeric=function(c){return a.test(c)},q}var ht;function Y(){return ht||(ht=1,(function(e){const s=Pt(),o=It();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(i,a){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!s.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?i.ccBits[0]:a<27?i.ccBits[1]:i.ccBits[2]},e.getBestModeForData=function(i){return o.testNumeric(i)?e.NUMERIC:o.testAlphanumeric(i)?e.ALPHANUMERIC:o.testKanji(i)?e.KANJI:e.BYTE},e.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},e.isValid=function(i){return i&&i.bit&&i.ccBits};function n(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+r)}}e.from=function(i,a){if(e.isValid(i))return i;try{return n(i)}catch{return a}}})(Se)),Se}var ft;function Vn(){return ft||(ft=1,(function(e){const s=Q(),o=Tt(),n=Ke(),r=Y(),i=Pt(),a=7973,l=s.getBCHDigit(a);function c(m,h,B){for(let S=1;S<=40;S++)if(h<=e.getCapacity(S,B,m))return S}function f(m,h){return r.getCharCountIndicator(m,h)+4}function g(m,h){let B=0;return m.forEach(function(S){const k=f(S.mode,h);B+=k+S.getBitsLength()}),B}function y(m,h){for(let B=1;B<=40;B++)if(g(m,B)<=e.getCapacity(B,h,r.MIXED))return B}e.from=function(h,B){return i.isValid(h)?parseInt(h,10):B},e.getCapacity=function(h,B,S){if(!i.isValid(h))throw new Error("Invalid QR Code version");typeof S>"u"&&(S=r.BYTE);const k=s.getSymbolTotalCodewords(h),N=o.getTotalCodewordsCount(h,B),x=(k-N)*8;if(S===r.MIXED)return x;const C=x-f(S,h);switch(S){case r.NUMERIC:return Math.floor(C/10*3);case r.ALPHANUMERIC:return Math.floor(C/11*2);case r.KANJI:return Math.floor(C/13);case r.BYTE:default:return Math.floor(C/8)}},e.getBestVersionForData=function(h,B){let S;const k=n.from(B,n.M);if(Array.isArray(h)){if(h.length>1)return y(h,k);if(h.length===0)return 1;S=h[0]}else S=h;return c(S.mode,S.getLength(),k)},e.getEncodedBits=function(h){if(!i.isValid(h)||h<7)throw new Error("Invalid QR Code version");let B=h<<12;for(;s.getBCHDigit(B)-l>=0;)B^=a<<s.getBCHDigit(B)-l;return h<<12|B}})(Ae)),Ae}var Me={},gt;function Hn(){if(gt)return Me;gt=1;const e=Q(),s=1335,o=21522,n=e.getBCHDigit(s);return Me.getEncodedBits=function(i,a){const l=i.bit<<3|a;let c=l<<10;for(;e.getBCHDigit(c)-n>=0;)c^=s<<e.getBCHDigit(c)-n;return(l<<10|c)^o},Me}var Re={},Le,mt;function Kn(){if(mt)return Le;mt=1;const e=Y();function s(o){this.mode=e.NUMERIC,this.data=o.toString()}return s.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(n){let r,i,a;for(r=0;r+3<=this.data.length;r+=3)i=this.data.substr(r,3),a=parseInt(i,10),n.put(a,10);const l=this.data.length-r;l>0&&(i=this.data.substr(r),a=parseInt(i,10),n.put(a,l*3+1))},Le=s,Le}var ke,pt;function Wn(){if(pt)return ke;pt=1;const e=Y(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(n){this.mode=e.ALPHANUMERIC,this.data=n}return o.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(r){let i;for(i=0;i+2<=this.data.length;i+=2){let a=s.indexOf(this.data[i])*45;a+=s.indexOf(this.data[i+1]),r.put(a,11)}this.data.length%2&&r.put(s.indexOf(this.data[i]),6)},ke=o,ke}var Te,wt;function Jn(){if(wt)return Te;wt=1;const e=Y();function s(o){this.mode=e.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return s.getBitsLength=function(n){return n*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(o){for(let n=0,r=this.data.length;n<r;n++)o.put(this.data[n],8)},Te=s,Te}var Pe,yt;function Qn(){if(yt)return Pe;yt=1;const e=Y(),s=Q();function o(n){this.mode=e.KANJI,this.data=n}return o.getBitsLength=function(r){return r*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(n){let r;for(r=0;r<this.data.length;r++){let i=s.toSJIS(this.data[r]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
|
|
4
|
+
Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),n.put(i,13)}},Pe=o,Pe}var xt;function Yn(){return xt||(xt=1,(function(e){const s=Y(),o=Kn(),n=Wn(),r=Jn(),i=Qn(),a=It(),l=Q(),c=hn();function f(N){return unescape(encodeURIComponent(N)).length}function g(N,x,C){const p=[];let R;for(;(R=N.exec(C))!==null;)p.push({data:R[0],index:R.index,mode:x,length:R[0].length});return p}function y(N){const x=g(a.NUMERIC,s.NUMERIC,N),C=g(a.ALPHANUMERIC,s.ALPHANUMERIC,N);let p,R;return l.isKanjiModeEnabled()?(p=g(a.BYTE,s.BYTE,N),R=g(a.KANJI,s.KANJI,N)):(p=g(a.BYTE_KANJI,s.BYTE,N),R=[]),x.concat(C,p,R).sort(function(d,w){return d.index-w.index}).map(function(d){return{data:d.data,mode:d.mode,length:d.length}})}function m(N,x){switch(x){case s.NUMERIC:return o.getBitsLength(N);case s.ALPHANUMERIC:return n.getBitsLength(N);case s.KANJI:return i.getBitsLength(N);case s.BYTE:return r.getBitsLength(N)}}function h(N){return N.reduce(function(x,C){const p=x.length-1>=0?x[x.length-1]:null;return p&&p.mode===C.mode?(x[x.length-1].data+=C.data,x):(x.push(C),x)},[])}function B(N){const x=[];for(let C=0;C<N.length;C++){const p=N[C];switch(p.mode){case s.NUMERIC:x.push([p,{data:p.data,mode:s.ALPHANUMERIC,length:p.length},{data:p.data,mode:s.BYTE,length:p.length}]);break;case s.ALPHANUMERIC:x.push([p,{data:p.data,mode:s.BYTE,length:p.length}]);break;case s.KANJI:x.push([p,{data:p.data,mode:s.BYTE,length:f(p.data)}]);break;case s.BYTE:x.push([{data:p.data,mode:s.BYTE,length:f(p.data)}])}}return x}function S(N,x){const C={},p={start:{}};let R=["start"];for(let u=0;u<N.length;u++){const d=N[u],w=[];for(let v=0;v<d.length;v++){const A=d[v],j=""+u+v;w.push(j),C[j]={node:A,lastCount:0},p[j]={};for(let E=0;E<R.length;E++){const b=R[E];C[b]&&C[b].node.mode===A.mode?(p[b][j]=m(C[b].lastCount+A.length,A.mode)-m(C[b].lastCount,A.mode),C[b].lastCount+=A.length):(C[b]&&(C[b].lastCount=A.length),p[b][j]=m(A.length,A.mode)+4+s.getCharCountIndicator(A.mode,x))}}R=w}for(let u=0;u<R.length;u++)p[R[u]].end=0;return{map:p,table:C}}function k(N,x){let C;const p=s.getBestModeForData(N);if(C=s.from(x,p),C!==s.BYTE&&C.bit<p.bit)throw new Error('"'+N+'" cannot be encoded with mode '+s.toString(C)+`.
|
|
5
|
+
Suggested mode is: `+s.toString(p));switch(C===s.KANJI&&!l.isKanjiModeEnabled()&&(C=s.BYTE),C){case s.NUMERIC:return new o(N);case s.ALPHANUMERIC:return new n(N);case s.KANJI:return new i(N);case s.BYTE:return new r(N)}}e.fromArray=function(x){return x.reduce(function(C,p){return typeof p=="string"?C.push(k(p,null)):p.data&&C.push(k(p.data,p.mode)),C},[])},e.fromString=function(x,C){const p=y(x,l.isKanjiModeEnabled()),R=B(p),u=S(R,C),d=c.find_path(u.map,"start","end"),w=[];for(let v=1;v<d.length-1;v++)w.push(u.table[d[v]].node);return e.fromArray(h(w))},e.rawSplit=function(x){return e.fromArray(y(x,l.isKanjiModeEnabled()))}})(Re)),Re}var vt;function Gn(){if(vt)return we;vt=1;const e=Q(),s=Ke(),o=In(),n=_n(),r=zn(),i=Dn(),a=qn(),l=Tt(),c=On(),f=Vn(),g=Hn(),y=Y(),m=Yn();function h(u,d){const w=u.size,v=i.getPositions(d);for(let A=0;A<v.length;A++){const j=v[A][0],E=v[A][1];for(let b=-1;b<=7;b++)if(!(j+b<=-1||w<=j+b))for(let M=-1;M<=7;M++)E+M<=-1||w<=E+M||(b>=0&&b<=6&&(M===0||M===6)||M>=0&&M<=6&&(b===0||b===6)||b>=2&&b<=4&&M>=2&&M<=4?u.set(j+b,E+M,!0,!0):u.set(j+b,E+M,!1,!0))}}function B(u){const d=u.size;for(let w=8;w<d-8;w++){const v=w%2===0;u.set(w,6,v,!0),u.set(6,w,v,!0)}}function S(u,d){const w=r.getPositions(d);for(let v=0;v<w.length;v++){const A=w[v][0],j=w[v][1];for(let E=-2;E<=2;E++)for(let b=-2;b<=2;b++)E===-2||E===2||b===-2||b===2||E===0&&b===0?u.set(A+E,j+b,!0,!0):u.set(A+E,j+b,!1,!0)}}function k(u,d){const w=u.size,v=f.getEncodedBits(d);let A,j,E;for(let b=0;b<18;b++)A=Math.floor(b/3),j=b%3+w-8-3,E=(v>>b&1)===1,u.set(A,j,E,!0),u.set(j,A,E,!0)}function N(u,d,w){const v=u.size,A=g.getEncodedBits(d,w);let j,E;for(j=0;j<15;j++)E=(A>>j&1)===1,j<6?u.set(j,8,E,!0):j<8?u.set(j+1,8,E,!0):u.set(v-15+j,8,E,!0),j<8?u.set(8,v-j-1,E,!0):j<9?u.set(8,15-j-1+1,E,!0):u.set(8,15-j-1,E,!0);u.set(v-8,8,1,!0)}function x(u,d){const w=u.size;let v=-1,A=w-1,j=7,E=0;for(let b=w-1;b>0;b-=2)for(b===6&&b--;;){for(let M=0;M<2;M++)if(!u.isReserved(A,b-M)){let D=!1;E<d.length&&(D=(d[E]>>>j&1)===1),u.set(A,b-M,D),j--,j===-1&&(E++,j=7)}if(A+=v,A<0||w<=A){A-=v,v=-v;break}}}function C(u,d,w){const v=new o;w.forEach(function(M){v.put(M.mode.bit,4),v.put(M.getLength(),y.getCharCountIndicator(M.mode,u)),M.write(v)});const A=e.getSymbolTotalCodewords(u),j=l.getTotalCodewordsCount(u,d),E=(A-j)*8;for(v.getLengthInBits()+4<=E&&v.put(0,4);v.getLengthInBits()%8!==0;)v.putBit(0);const b=(E-v.getLengthInBits())/8;for(let M=0;M<b;M++)v.put(M%2?17:236,8);return p(v,u,d)}function p(u,d,w){const v=e.getSymbolTotalCodewords(d),A=l.getTotalCodewordsCount(d,w),j=v-A,E=l.getBlocksCount(d,w),b=v%E,M=E-b,D=Math.floor(v/E),K=Math.floor(j/E),he=K+1,$=D-K,I=new c($);let _=0;const U=new Array(E),We=new Array(E);let fe=0;const zt=new Uint8Array(u.buffer);for(let G=0;G<E;G++){const me=G<M?K:he;U[G]=zt.slice(_,_+me),We[G]=I.encode(U[G]),_+=me,fe=Math.max(fe,me)}const ge=new Uint8Array(v);let Je=0,F,O;for(F=0;F<fe;F++)for(O=0;O<E;O++)F<U[O].length&&(ge[Je++]=U[O][F]);for(F=0;F<$;F++)for(O=0;O<E;O++)ge[Je++]=We[O][F];return ge}function R(u,d,w,v){let A;if(Array.isArray(u))A=m.fromArray(u);else if(typeof u=="string"){let D=d;if(!D){const K=m.rawSplit(u);D=f.getBestVersionForData(K,w)}A=m.fromString(u,D||40)}else throw new Error("Invalid data");const j=f.getBestVersionForData(A,w);if(!j)throw new Error("The amount of data is too big to be stored in a QR Code");if(!d)d=j;else if(d<j)throw new Error(`
|
|
6
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
7
|
+
Minimum version required to store current data is: `+j+`.
|
|
8
|
+
`);const E=C(d,w,A),b=e.getSymbolSize(d),M=new n(b);return h(M,d),B(M),S(M,d),N(M,w,0),d>=7&&k(M,d),x(M,E),isNaN(v)&&(v=a.getBestMask(M,N.bind(null,M,w))),a.applyMask(v,M),N(M,w,v),{modules:M,version:d,errorCorrectionLevel:w,maskPattern:v,segments:A}}return we.create=function(d,w){if(typeof d>"u"||d==="")throw new Error("No input text");let v=s.M,A,j;return typeof w<"u"&&(v=s.from(w.errorCorrectionLevel,s.M),A=f.from(w.version),j=a.from(w.maskPattern),w.toSJISFunc&&e.setToSJISFunction(w.toSJISFunc)),R(d,A,v,j)},we}var Ie={},_e={},Ct;function _t(){return Ct||(Ct=1,(function(e){function s(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let n=o.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+o);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(i){return[i,i]}))),n.length===6&&n.push("F","F");const r=parseInt(n.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+n.slice(0,6).join("")}}e.getOptions=function(n){n||(n={}),n.color||(n.color={});const r=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,i=n.width&&n.width>=21?n.width:void 0,a=n.scale||4;return{width:i,scale:i?4:a,margin:r,color:{dark:s(n.color.dark||"#000000ff"),light:s(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},e.getScale=function(n,r){return r.width&&r.width>=n+r.margin*2?r.width/(n+r.margin*2):r.scale},e.getImageWidth=function(n,r){const i=e.getScale(n,r);return Math.floor((n+r.margin*2)*i)},e.qrToImageData=function(n,r,i){const a=r.modules.size,l=r.modules.data,c=e.getScale(a,i),f=Math.floor((a+i.margin*2)*c),g=i.margin*c,y=[i.color.light,i.color.dark];for(let m=0;m<f;m++)for(let h=0;h<f;h++){let B=(m*f+h)*4,S=i.color.light;if(m>=g&&h>=g&&m<f-g&&h<f-g){const k=Math.floor((m-g)/c),N=Math.floor((h-g)/c);S=y[l[k*a+N]?1:0]}n[B++]=S.r,n[B++]=S.g,n[B++]=S.b,n[B]=S.a}}})(_e)),_e}var jt;function Zn(){return jt||(jt=1,(function(e){const s=_t();function o(r,i,a){r.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=a,i.width=a,i.style.height=a+"px",i.style.width=a+"px"}function n(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(i,a,l){let c=l,f=a;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),a||(f=n()),c=s.getOptions(c);const g=s.getImageWidth(i.modules.size,c),y=f.getContext("2d"),m=y.createImageData(g,g);return s.qrToImageData(m.data,i,c),o(y,f,g),y.putImageData(m,0,0),f},e.renderToDataURL=function(i,a,l){let c=l;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),c||(c={});const f=e.render(i,a,c),g=c.type||"image/png",y=c.rendererOpts||{};return f.toDataURL(g,y.quality)}})(Ie)),Ie}var ze={},bt;function Xn(){if(bt)return ze;bt=1;const e=_t();function s(r,i){const a=r.a/255,l=i+'="'+r.hex+'"';return a<1?l+" "+i+'-opacity="'+a.toFixed(2).slice(1)+'"':l}function o(r,i,a){let l=r+i;return typeof a<"u"&&(l+=" "+a),l}function n(r,i,a){let l="",c=0,f=!1,g=0;for(let y=0;y<r.length;y++){const m=Math.floor(y%i),h=Math.floor(y/i);!m&&!f&&(f=!0),r[y]?(g++,y>0&&m>0&&r[y-1]||(l+=f?o("M",m+a,.5+h+a):o("m",c,0),c=0,f=!1),m+1<i&&r[y+1]||(l+=o("h",g),g=0)):c++}return l}return ze.render=function(i,a,l){const c=e.getOptions(a),f=i.modules.size,g=i.modules.data,y=f+c.margin*2,m=c.color.light.a?"<path "+s(c.color.light,"fill")+' d="M0 0h'+y+"v"+y+'H0z"/>':"",h="<path "+s(c.color.dark,"stroke")+' d="'+n(g,f,c.margin)+'"/>',B='viewBox="0 0 '+y+" "+y+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+B+' shape-rendering="crispEdges">'+m+h+`</svg>
|
|
9
|
+
`;return typeof l=="function"&&l(null,k),k},ze}var Et;function $n(){if(Et)return Z;Et=1;const e=Pn(),s=Gn(),o=Zn(),n=Xn();function r(i,a,l,c,f){const g=[].slice.call(arguments,1),y=g.length,m=typeof g[y-1]=="function";if(!m&&!e())throw new Error("Callback required as last argument");if(m){if(y<2)throw new Error("Too few arguments provided");y===2?(f=l,l=a,a=c=void 0):y===3&&(a.getContext&&typeof f>"u"?(f=c,c=void 0):(f=c,c=l,l=a,a=void 0))}else{if(y<1)throw new Error("Too few arguments provided");return y===1?(l=a,a=c=void 0):y===2&&!a.getContext&&(c=l,l=a,a=void 0),new Promise(function(h,B){try{const S=s.create(l,c);h(i(S,a,c))}catch(S){B(S)}})}try{const h=s.create(l,c);f(null,i(h,a,c))}catch(h){f(h)}}return Z.create=s.create,Z.toCanvas=r.bind(null,o.render),Z.toDataURL=r.bind(null,o.renderToDataURL),Z.toString=r.bind(null,function(i,a,l){return n.render(i,l)}),Z}var er=$n();const tr=qt(er),nr="M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.72532 0 0.578514 4.81465 0.0491943 10.9512H15.8916V13.0488H0.0491943C0.578514 19.1853 5.72532 24 12 24Z";function De(e,s,o,n,r){return`M${e+r},${s} h${o-2*r} a${r},${r} 0 0 1 ${r},${r} v${n-2*r} a${r},${r} 0 0 1 ${-r},${r} h${-(o-2*r)} a${r},${r} 0 0 1 ${-r},${-r} v${-(n-2*r)} a${r},${r} 0 0 1 ${r},${-r} z`}function rr(e,s){return[De(e,s,7,7,2.2)+" "+De(e+1,s+1,5,5,1.6),De(e+2,s+2,3,3,1.05)]}function ir({text:e,label:s}){const o=L.useMemo(()=>{try{const m=tr.create(e,{errorCorrectionLevel:"Q"});return{size:m.modules.size,data:m.modules.data}}catch{return null}},[e]);if(!o)return t.jsx("div",{className:"gc-qr gc-qr--placeholder","aria-hidden":"true"});const{size:n,data:r}=o,i=n/2,a=n*.11,l=a+.6,c=a*.82,f=(m,h)=>m<7&&h<7||m<7&&h>=n-7||m>=n-7&&h<7,g=(m,h)=>Math.hypot(m+.5-i,h+.5-i)<l,y=[];for(let m=0;m<n;m++)for(let h=0;h<n;h++)r[m*n+h]&&(f(m,h)||g(m,h)||y.push(t.jsx("circle",{cx:h+.5,cy:m+.5,r:.34},`${m}-${h}`)));return t.jsxs("svg",{className:"gc-qr",viewBox:`0 0 ${n} ${n}`,role:"img","aria-label":s,children:[t.jsxs("g",{fill:"currentColor",children:[y,[[0,0],[n-7,0],[0,n-7]].map(([m,h])=>{const[B,S]=rr(m,h);return t.jsxs("g",{children:[t.jsx("path",{d:B,fillRule:"evenodd"}),t.jsx("path",{d:S})]},`${m}-${h}`)})]}),t.jsx("circle",{cx:i,cy:i,r:a,className:"gc-qr__badge"}),t.jsx("circle",{cx:i,cy:i,r:c,fill:"#fff"}),t.jsx("path",{d:nr,fill:"#0052FF",transform:`translate(${i-c}, ${i-c}) scale(${c*2/24})`})]})}const sr=L.lazy(()=>ce(()=>import("./WalletFunding-CvDkcGVU.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),or=["5","10","25"],Nt=200,ar="https://antseed.mrdn.finance/";function lr(){const e=window.open("about:blank","_blank");return e&&(e.opener=null),e}function cr(e,s){if(e.mode==="off")return{tone:"error",text:e.status==="buyer-unreachable"?"The buyer is not reachable, so deposits are not watched right now.":"This wallet is not watched for deposits right now; USDC sent to it is credited once the buyer watches it again."};const o=e.event&&e.event.seq>s?e.event:null;if(!o||o.phase==="deferred")return{tone:"idle",text:"Waiting for USDC on Base…"};const n=o.amount?T(o.amount):"USDC";return o.phase==="received"?{tone:"busy",text:`Received ${n}, preparing the deposit…`}:o.phase==="sweeping"?{tone:"busy",text:`Depositing ${n} to the credits…`}:o.phase==="credited"?{tone:"done",text:`${n} added to the balance`}:{tone:"error",text:o.error??"The deposit failed. USDC stays in the workspace wallet and is retried."}}function At({line:e}){return t.jsxs("div",{className:`gc-depwatch gc-depwatch--${e.tone}`,role:"status",children:[e.tone==="done"?t.jsx(z.check,{size:15}):t.jsx("span",{className:"gc-depwatch__dot","aria-hidden":"true"}),e.text]})}function St({amount:e,setAmount:s,firstDeposit:o}){return t.jsxs("div",{className:"gc-fund-amount",children:[t.jsx("span",{className:"gc-fund-amount__label",children:"Amount to add"}),t.jsxs("div",{className:"gc-fund-amount__row",children:[or.map(n=>t.jsxs("button",{type:"button",className:e===n?"gc-preset gc-preset--on":"gc-preset","aria-pressed":e===n,onClick:()=>s(n),children:["$",n]},n)),t.jsxs("label",{className:"gc-fund-amount__input",children:[t.jsx("span",{"aria-hidden":"true",children:"$"}),t.jsx("input",{type:"text",inputMode:"decimal",value:e,"aria-label":"Amount in USD",onChange:n=>s(n.target.value.replace(/[^0-9.]/g,""))})]})]}),t.jsxs("span",{className:"gc-fineprint",children:["1 credit = 1 USDC",o?" · The first deposit must be at least $1":""]})]})}function qe({icon:e,title:s,caption:o,badges:n,onClick:r,arrow:i}){return t.jsxs("button",{type:"button",className:"gc-method",onClick:r,children:[t.jsx("span",{className:"gc-method__icon",children:e}),t.jsxs("span",{className:"gc-method__text",children:[t.jsx("span",{className:"gc-method__title",children:s}),t.jsx("span",{className:"gc-method__caption",children:o})]}),t.jsx("span",{className:"gc-method__badges","aria-hidden":"true",children:n}),i?t.jsx(z.right,{size:16,className:"gc-method__arrow"}):t.jsx(z.external,{size:14,className:"gc-method__arrow"})]})}function ur({wallet:e,chain:s,workspaceId:o}){var $;const[n,r]=L.useState("choose"),[i,a]=L.useState("10"),[l,c]=L.useState(!1),[f,g]=L.useState(null),[y,m]=L.useState(null),h=ae(),B=re(),S=Bt(o);Ln(o);const k=L.useRef((($=e.deposit.event)==null?void 0:$.seq)??0),N=e.deposit.event!==null&&e.deposit.event.seq>k.current&&(e.deposit.event.phase==="received"||e.deposit.event.phase==="sweeping");Tn(J.wallet(o),N?4e3:8e3,4e3);const[x,C]=L.useState(null),p=e.deposit.event,R=p&&p.seq>k.current&&p.phase==="credited"?p:null;L.useEffect(()=>{R&&(B(`${R.amount?T(R.amount):"Your deposit"} added to the balance`),C(null),h.invalidateQueries({queryKey:["channels",o]}))},[R==null?void 0:R.seq]);const u=Number(i),d=Number.isFinite(u)&&u>=1,w=W(e.available)+W(e.reserved),v=Math.max(0,w-(S.data?Mt(S.data):0))+W(e.walletUsdc),A=w===0,j=Ut(s,"usdc"),E=cr(e.deposit,k.current),b=R!=null&&R.txHash?Ft(s,R.txHash):null;async function M(I){if(!d){g("Enter an amount of at least $1.");return}if(u>Nt){g(`Card deposits are limited to $${Nt}. Send more as USDC instead.`);return}m(I),g(null);try{const{url:_}=await te.wallet.cardLink(o,u,I),U=URL.canParse(_)?new URL(_).origin:null;if(!(U!=null&&U.startsWith("https://")))throw new Error("The gateway returned an invalid checkout link.");C({url:_,origin:U,provider:I})}catch(_){g(Fe(_))}finally{m(null)}}function D(){const I=lr(),_=`${ar}?buyer=${encodeURIComponent(e.address)}`;I?I.location.replace(_):window.location.href=_}const K=t.jsxs("div",{className:"gc-fund-balance",children:[t.jsx("span",{className:"gc-fund-balance__label",children:"Workspace balance"}),t.jsx("span",{className:"gc-fund-balance__value",children:T(v)}),t.jsxs("span",{className:"gc-fineprint",children:[T(e.available)," available · ",T(e.reserved)," reserved",W(e.walletUsdc)>0?` · ${T(e.walletUsdc)} in the wallet`:""]})]});if(n==="wallet")return t.jsxs("div",{className:"gc-fund",children:[t.jsx(P,{variant:"link",size:"sm",leadingIcon:t.jsx(z.left,{size:14}),onClick:()=>r("crypto"),children:"Back"}),t.jsx(de,{chain:s,children:I=>t.jsx(L.Suspense,{fallback:t.jsx(le,{rows:2}),children:t.jsx(sr,{action:"deposit",workspaceId:o,wallet:e,chain:I,onDone:()=>{B("Deposit confirmed"),h.invalidateQueries({queryKey:J.wallet(o)})}})})})]});if(n==="crypto")return t.jsxs("div",{className:"gc-fund",children:[t.jsx(P,{variant:"link",size:"sm",leadingIcon:t.jsx(z.left,{size:14}),onClick:()=>r("choose"),children:"All options"}),t.jsx(St,{amount:i,setAmount:a,firstDeposit:A}),t.jsxs("div",{className:"gc-fund-pay",children:[j&&s?t.jsx(ir,{text:dn({usdcAddress:j,chainId:s.chainId,address:e.address},d?i:""),label:`Scan to send USDC on ${s.name} to this workspace's wallet`}):t.jsx("div",{className:"gc-qr gc-qr--placeholder","aria-hidden":"true"}),t.jsxs("div",{className:"gc-fund-pay__address",children:[t.jsx("code",{className:"gc-mono",title:e.address,children:H(e.address)}),t.jsx(Ue,{iconOnly:!0,value:e.address,label:"Copy address"})]}),t.jsx(At,{line:E}),t.jsx("span",{className:"gc-fineprint",children:"Credits update automatically · a small fixed relay fee is deducted"}),b&&t.jsx("a",{className:"gc-link gc-fineprint",href:b,target:"_blank",rel:"noopener noreferrer",children:"View transaction"}),t.jsxs("div",{className:"gc-fund-pay__warn",children:["Only send USDC on ",t.jsx("strong",{children:(s==null?void 0:s.name)??"Base"}),". Other tokens or networks are not deposited."]})]}),t.jsx(P,{variant:"link",size:"sm",trailingIcon:t.jsx(z.right,{size:14}),onClick:()=>r("wallet"),children:"No wallet on your phone? Pay from a connected wallet instead"})]});const he=t.jsx(X,{isOpen:x!==null,onClose:()=>C(null),size:"md",title:"Secure checkout",bodyClassName:"gc-checkout",subtitle:x&&t.jsxs(t.Fragment,{children:[x.provider==="stripe"?"Card checkout by Outerfound, powered by Stripe (US only).":"Card checkout by Crossmint."," Closes by itself once the funds arrive."," ",t.jsx("a",{className:"gc-link",href:x.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>C(null),children:"Open in a new tab"})]}),children:x&&t.jsx("iframe",{className:"gc-checkout__frame",src:x.url,title:"Antseed Pay checkout",allow:`payment ${x.origin}; clipboard-write`})});return t.jsxs("div",{className:"gc-fund",children:[he,K,t.jsx(St,{amount:i,setAmount:a,firstDeposit:A}),t.jsxs("button",{type:"button",className:"gc-method gc-method--primary",disabled:y!==null,onClick:()=>void M("crossmint"),children:[t.jsxs("span",{className:"gc-method__text",children:[t.jsx("span",{className:"gc-method__title",children:y==="crossmint"?"Opening checkout…":`Deposit${d?` ${T(u)}`:""} by card`}),t.jsx("span",{className:"gc-method__caption",children:"Powered by Crossmint"})]}),t.jsxs("span",{className:"gc-method__badges","aria-hidden":"true",children:[t.jsx(Ge,{}),t.jsx(vn,{}),t.jsx(Cn,{}),t.jsx(Ze,{})]})]}),t.jsxs("div",{className:"gc-fund-group",children:[t.jsx(qe,{icon:t.jsx(yn,{size:22}),title:"Quick deposit",caption:`USDC on ${(s==null?void 0:s.name)??"Base"}`,arrow:!0,onClick:()=>r("crypto"),badges:t.jsxs(t.Fragment,{children:[t.jsx(wn,{}),t.jsx("span",{className:"gc-fund-chip",children:t.jsx(z.qr,{size:12})})]})}),t.jsx("span",{className:"gc-fineprint",children:"* Deposited to the credits by the Antseed relayer network"})]}),f&&t.jsx(ne,{tone:"danger",children:f}),t.jsxs("button",{type:"button",className:"gc-fund-more","aria-expanded":l,onClick:()=>c(I=>!I),children:["More options ",t.jsx(z.down,{size:16,className:l?"gc-fund-more__chevron gc-fund-more__chevron--open":"gc-fund-more__chevron"})]}),l&&t.jsxs("div",{className:"gc-fund-options",children:[t.jsx(qe,{icon:t.jsx(En,{}),title:"Deposit using Meridian",caption:"USDC from any chain",onClick:D,badges:t.jsxs(t.Fragment,{children:[t.jsx(Bn,{}),t.jsx(Nn,{}),t.jsx(An,{}),t.jsx(Sn,{})]})}),t.jsx(qe,{icon:t.jsx(bn,{size:20}),title:y==="stripe"?"Opening checkout…":"Deposit using Outerfound",caption:"Card · US only",onClick:()=>void M("stripe"),badges:t.jsxs(t.Fragment,{children:[t.jsx(Ze,{}),t.jsx(Ge,{}),t.jsx(jn,{})]})})]}),t.jsx(At,{line:E}),t.jsxs("div",{className:"gc-fund-trust",children:[t.jsxs("span",{children:[t.jsx(z.lock,{size:12})," Encrypted & secure · Non-custodial escrow on ",(s==null?void 0:s.name)??"Base"]}),t.jsxs("span",{children:[t.jsx(z.check,{size:12})," Pay per request · No subscriptions, no lock-in"]})]}),t.jsx("p",{className:"gc-fineprint gc-fund-fine",children:"Card checkout opens here and closes itself once the funds arrive. It is not available in every region."})]})}const dr=L.lazy(()=>ce(()=>import("./OperatorActions-DTrUYN6Z.js"),__vite__mapDeps([11,1,2,8,3,4,5,6,7,9]))),hr={info:"neutral",success:"success",warning:"warning",danger:"danger"},fr={authorize:"Authorize a wallet",manage:"Transfer or remove the authorized wallet"};function gr({workspaceId:e,action:s,onActionChange:o}){const n=Rt(e),r=ue(),i=re(),{apply:a,refresh:l}=Ot(e),[c,f]=L.useState(null),g=s!==void 0?s:c,y=p=>o?o(p):f(p),[m,h]=L.useState(!1),[B,S]=L.useState(!1),[k,N]=L.useState(null);async function x(){S(!0),N(null);try{await l()}catch(p){N(p)}finally{S(!1)}}return t.jsxs(Oe,{title:"Authorized wallet",description:"Receives this workspace's withdrawals and ANTS rewards, and is the only wallet that can sign them.",children:[t.jsx(Ve,{query:n,rows:2,children:p=>{var R;return t.jsx(mr,{state:p,explorerUrl:((R=r.data)==null?void 0:R.explorerUrl)??null,refreshing:B,onReload:()=>void x(),onAction:y,onLink:()=>h(!0)})}}),k?t.jsx(ne,{tone:"danger",children:Fe(k)}):null,t.jsx(X,{isOpen:g!==null&&n.data!==void 0,onClose:()=>y(null),size:"md",title:g?fr[g]:"",subtitle:g==="manage"&&n.data?`Signed by ${H(n.data.operator)} itself; the gateway cannot do it.`:"Withdrawals and ANTS rewards will go to the wallet you authorize, and only it can hand the role on.",children:g&&n.data&&t.jsx(de,{chain:r.data,error:r.error,children:p=>t.jsx(L.Suspense,{fallback:t.jsx(le,{rows:2}),children:t.jsx(dr,{mode:g,workspaceId:e,state:n.data,chain:p,onStale:()=>void x(),onChanged:R=>{a(R),y(null),i(He(R.operator)?`Authorized wallet is now ${H(R.operator)}`:"Authorized wallet removed")}})})})}),m&&n.data&&t.jsx(Vt,{isOpen:!0,startWith:"wallet",onClose:()=>h(!1),intro:t.jsxs("p",{className:"gc-muted",children:["Connect ",t.jsx("code",{className:"gc-mono",children:H(n.data.operator)})," and sign the message to add it as one of your sign-in methods. It then shows here as your wallet, and you can manage it."]}),onCredentialAdded:()=>{x(),i("Wallet linked to your account")}})]})}function mr({state:e,explorerUrl:s,refreshing:o,onReload:n,onAction:r,onLink:i}){const a=Ht(e,null),l=He(e.operator),c=s&&l?`${s.replace(/\/+$/,"")}/address/${e.operator}`:null,f=l&&e.relation!=="self";return t.jsxs("div",{className:"gc-operator",children:[t.jsxs("div",{className:"gc-operator__main",children:[t.jsxs("div",{className:"gc-operator__title",children:[t.jsx("span",{className:"gc-strong",children:a.title}),l&&t.jsx(Ue,{iconOnly:!0,value:e.operator,label:"Copy address"}),t.jsx(Lt,{tone:hr[a.tone],children:a.badge})]}),t.jsx("p",{className:"gc-operator__summary",children:a.summary}),t.jsxs("p",{className:"gc-fineprint gc-operator__meta",children:[c&&t.jsxs(t.Fragment,{children:[t.jsx("a",{className:"gc-link",href:c,target:"_blank",rel:"noopener noreferrer",children:"explorer"})," · "]}),"Checked ",Kt(e.checkedAt)," ·"," ",t.jsx(P,{variant:"link",size:"sm",disabled:o,onClick:n,children:o?"checking…":"check again"})]})]}),t.jsxs("div",{className:"gc-operator__actions",children:[a.canAuthorize&&t.jsx(P,{size:"sm",onClick:()=>r("authorize"),children:"Authorize a wallet"}),a.canLink&&t.jsx(P,{size:"sm",onClick:i,children:"Link to my account"}),f&&t.jsx(P,{size:"sm",variant:"outline",onClick:()=>r("manage"),children:"Transfer or remove"})]}),(a.body!==a.summary||e.relation==="none"&&!e.canAuthorize)&&t.jsxs(fn,{className:"gc-operator__details",title:"What does this mean?",children:[t.jsx("p",{className:"gc-muted",children:a.body}),e.relation==="none"&&!e.canAuthorize&&t.jsx("p",{className:"gc-fineprint",children:"Only the organization owner can authorize a wallet, with one of their own sign-in wallets added at least 24 hours ago."})]})]})}const pr=L.lazy(()=>ce(()=>import("./WalletFunding-CvDkcGVU.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),wr=L.lazy(()=>ce(()=>import("./ChannelClose-9Lq8KHLH.js"),__vite__mapDeps([12,1,2,8,3,4,5,6,7,9,10])));function yr(e,s=15e3){const[o,n]=L.useState(()=>Date.now());return L.useEffect(()=>{if(!e)return;n(Date.now());const r=setInterval(()=>n(Date.now()),s);return()=>clearInterval(r)},[e,s]),o}function xr({workspaceId:e,canCooperate:s,onAuthorize:o}){const[n,r]=L.useState(!1),[i,a]=L.useState(null),[l,c]=L.useState(()=>new Set),f=ae(),g=re(),y=ue(),m=en({queryKey:J.channels(e,n),queryFn:()=>te.wallet.channels(e,n)}),h=m.data??[],B=h.some(u=>u.status==="closing"),S=yr(B),k=async()=>{const u=await te.wallet.channels(e,n,!0);f.setQueryData(J.channels(e,n),u),f.invalidateQueries({queryKey:["channels",e]}),f.invalidateQueries({queryKey:J.wallet(e)})},N=h.map(tn).filter(u=>u!==null&&u>S).sort((u,d)=>u-d)[0];L.useEffect(()=>{if(N===void 0)return;const u=setTimeout(()=>void k().catch(()=>{}),Math.max(1e3,N-Date.now()+5e3));return()=>clearTimeout(u)},[N]);const x=nn({mutationFn:u=>te.wallet.closeChannel(e,u.peerId),onSuccess:()=>{a(null),g("Channel closed by the seller")},onError:(u,d)=>c(w=>new Set(w).add(d.channelId)),invalidate:[["channels",e],J.wallet(e)]}),C=(u,d=l.has(u.channelId))=>{x.reset();const w=Ye(u,d||!s);w==="cooperative"?a({channel:u,mode:"cooperative"}):w==="on-chain"?a({channel:u,mode:"request"}):w==="withdraw"&&a({channel:u,mode:"withdraw"})},p=rn(h),R=u=>u.sellerName??H(u.peerId);return t.jsx("section",{id:"gc-channels",className:"gc-anchor",children:t.jsxs(Oe,{flush:!0,title:"Payment channels",description:"Funds reserved with sellers. Closing a channel returns what was not spent.",actions:t.jsx(mn,{checked:n,onChange:r,label:"Include closed"}),children:[p.count>0&&t.jsxs(ne,{tone:"warning",title:`${p.count} channel${p.count===1?"":"s"} ready to withdraw`,action:t.jsx(P,{size:"sm",onClick:()=>C(h.find(u=>u.status==="withdrawable")),children:"Withdraw"}),children:["About ",T(p.amount)," of unused reserve can return to the balance. The authorized wallet signs the withdrawal."]}),t.jsx(Ve,{query:m,children:u=>t.jsx(gn,{label:"Payment channels",rows:u,rowKey:d=>d.channelId,rowLabel:d=>`channel with ${R(d)}`,actions:d=>{const w=Ye(d,l.has(d.channelId)||!s);return[w==="cooperative"&&{label:"Close channel",onSelect:()=>C(d)},(w==="cooperative"||w==="on-chain")&&{label:"Close on chain",onSelect:()=>C(d,!0)},w==="withdraw"&&{label:"Withdraw reserve",onSelect:()=>C(d)}]},empty:t.jsx(cn,{icon:t.jsx(z.wallet,{size:18}),title:n?"No channels yet":"No open channels",body:"A channel opens the first time a seller serves this workspace."}),columns:[{key:"seller",header:"Seller",render:d=>d.sellerName??t.jsx(kt,{title:d.peerId,children:H(d.peerId)})},{key:"status",header:"Status",render:d=>t.jsx(Lt,{tone:on(d),children:sn(d,S)})},{key:"reserved",header:"Reserved",align:"right",render:d=>T(d.reserved)},{key:"spent",header:"Spent",align:"right",render:d=>T(d.spent)},{key:"returns",header:"Returns on close",align:"right",secondary:!0,optional:!0,render:d=>an(d)?T(Qe(d)):"—"},{key:"opened",header:"Opened",secondary:!0,render:d=>ln(d.openedAt)}]})}),!s&&h.some(u=>u.canCooperativeClose)&&t.jsx("p",{className:"gc-fineprint gc-panel-note",children:"Asking a seller to close needs an organization admin; you can still close on chain with the authorized wallet."}),t.jsx(X,{isOpen:(i==null?void 0:i.mode)==="cooperative",onClose:()=>{a(null),x.reset()},size:"md",title:"Close this channel?",subtitle:i?`With ${R(i.channel)}. About ${T(Qe(i.channel))} returns to the balance.`:void 0,footer:i&&t.jsxs("div",{className:"gc-actions",children:[t.jsx(P,{variant:"ghost",onClick:()=>{a(null),x.reset()},children:"Cancel"}),x.error?t.jsxs(t.Fragment,{children:[t.jsx(P,{variant:"outline",disabled:x.isPending,onClick:()=>x.mutate(i.channel),children:"Try again"}),t.jsx(P,{onClick:()=>{x.reset(),a({channel:i.channel,mode:"request"})},children:"Close on chain instead"})]}):t.jsx(P,{disabled:x.isPending,onClick:()=>x.mutate(i.channel),children:x.isPending?"Asking the seller…":"Close channel"})]}),children:t.jsxs("div",{className:"gc-stack",children:[t.jsx("p",{className:"gc-muted",children:"The seller settles what was spent and the rest returns to your available balance at once. A new channel opens if this seller is used again."}),x.isPending&&t.jsx("p",{className:"gc-fineprint",children:"Waiting for the seller (up to a minute)…"}),x.error?t.jsx(ne,{tone:"danger",title:"The seller did not close it",children:un(Fe(x.error))}):null]})}),t.jsx(X,{isOpen:(i==null?void 0:i.mode)==="request"||(i==null?void 0:i.mode)==="withdraw",onClose:()=>a(null),size:"md",title:(i==null?void 0:i.mode)==="withdraw"?"Withdraw the unused reserve":"Close on chain",subtitle:i?`Channel with ${R(i.channel)}. Does not need the seller.`:void 0,children:i&&i.mode!=="cooperative"&&t.jsx(de,{chain:y.data,error:y.error,children:u=>t.jsx(L.Suspense,{fallback:t.jsx(le,{rows:2}),children:t.jsx(wr,{workspaceId:e,channel:i.channel,chain:u,step:i.mode,onAuthorize:()=>{a(null),o()},onDone:d=>{k().catch(()=>{}),d==="request"?g("Close requested. Withdraw in 15 minutes."):(g("Reserve returned to the balance"),a(null))}})})})})]})})}function vr({wallet:e,workspaceId:s,onWithdraw:o}){const n=Bt(s),r=n.data?Mt(n.data):null,i=()=>{const l=document.getElementById("gc-channels");if(!l)return;l.scrollIntoView({behavior:"smooth",block:"start"}),l.classList.remove("gc-flash"),l.offsetWidth,l.classList.add("gc-flash");let c=!1;const f=()=>{var y;if(c)return;c=!0;const g=l.querySelectorAll('[aria-haspopup="menu"]');g.length===1?g[0].click():(y=g[0])==null||y.focus({preventScroll:!0})};window.addEventListener("scrollend",f,{once:!0}),window.setTimeout(f,700)},a=Zt(e);return Cr(e,a),t.jsxs(Oe,{title:"Balance",actions:t.jsx(P,{size:"sm",variant:"outline",onClick:o,children:"Withdraw"}),children:[Xt(e)&&t.jsx("div",{className:"gc-panel-alert",children:t.jsx(ne,{tone:"warning",title:"The whole balance is reserved in channels",action:t.jsx(P,{size:"sm",variant:"outline",onClick:i,children:"Manage channels"}),children:"Nothing is available for new sellers or withdrawals. Close channels you no longer use to return their unused reserve, or add funds."})}),t.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[t.jsx(ie,{label:"Available",value:T(e.available),strong:!0}),t.jsx(ie,{label:"Reserved in channels",value:T(e.reserved)}),t.jsx(ie,{label:"Authorized, not yet charged",value:r===null?"…":T(r)}),t.jsx(ie,{label:"Credit limit",value:e.creditLimit===null?"None":T(e.creditLimit)})]}),a?t.jsxs("p",{className:"gc-wallet-meta gc-pending",role:"status",children:[t.jsx("span",{className:"gc-attention","aria-hidden":"true"}),t.jsxs("span",{children:[t.jsxs("strong",{children:["Pending: ",T(e.walletUsdc)]})," arrived in the workspace wallet and is moving into the available balance. This page updates by itself."]})]}):W(e.walletUsdc)>0&&t.jsxs("p",{className:"gc-fineprint gc-wallet-meta",children:[T(e.walletUsdc)," in the wallet, not deposited yet. ",$t(e)]}),t.jsxs("p",{className:"gc-fineprint gc-wallet-meta",children:["Workspace wallet ",t.jsx(kt,{title:e.address,children:H(e.address)})," ",t.jsx(Ue,{iconOnly:!0,value:e.address,label:"Copy address"}),t.jsx("span",{"aria-hidden":"true",children:"·"})," Authorized spend is charged from channel reserves when sellers settle. Withdrawals go to the authorized wallet below."]})]})}function Cr(e,s){const o=re(),n=L.useRef(null);L.useEffect(()=>{if(s){n.current??(n.current=W(e.available));return}if(n.current===null)return;const r=W(e.available)-n.current;n.current=null,r>0&&o(`Payment received: ${T(String(r))} added to the available balance`)},[s,e.available,o])}function jr({wallet:e,workspaceId:s,isOpen:o,onClose:n,onAuthorize:r}){const i=ae(),a=re(),l=ue(),c=Rt(s),f=c.data&&He(c.data.operator)?c.data.operator:null;return t.jsx(X,{isOpen:o,onClose:n,title:"Withdraw",subtitle:`${T(e.available)} available. ${f?`Sent to the authorized wallet ${H(f)}, which must sign it.`:"Withdrawals go to the authorized wallet, which must sign them."}`,children:t.jsx(de,{chain:l.data,error:l.error,children:g=>t.jsx(L.Suspense,{fallback:t.jsx(le,{rows:2}),children:t.jsx(pr,{action:"withdraw",workspaceId:s,wallet:e,chain:g,onAuthorize:()=>{n(),r()},onDone:()=>{a("Withdrawal confirmed"),i.invalidateQueries({queryKey:J.wallet(s)})}})})})})}function Lr(){const{workspace:e,viewer:s}=Wt(),o=Jt(e.id),n=ue(),[r,i]=L.useState(()=>new URLSearchParams(window.location.search).get("fund")==="1"?"fund":null),[a,l]=L.useState(null);return t.jsxs("div",{className:"gc-page",children:[t.jsx(Qt,{title:"Wallet & Funding",description:`Credits that pay for ${e.name}'s requests.`,actions:t.jsx(P,{variant:"brand",leadingIcon:t.jsx(z.plus,{size:14}),onClick:()=>i("fund"),children:"Add funds"})}),t.jsx(Ve,{query:o,rows:2,children:c=>t.jsxs(t.Fragment,{children:[t.jsx(Yt,{stale:c.stale}),t.jsx(vr,{wallet:c,workspaceId:e.id,onWithdraw:()=>i("withdraw")}),t.jsx(gr,{workspaceId:e.id,action:a,onActionChange:l}),t.jsx(X,{isOpen:r==="fund",onClose:()=>i(null),size:"md",title:"Add funds",subtitle:`Credits that pay for ${e.name}'s requests.`,children:t.jsx(ur,{wallet:c,chain:n.data,workspaceId:e.id})}),t.jsx(jr,{wallet:c,workspaceId:e.id,isOpen:r==="withdraw",onClose:()=>i(null),onAuthorize:()=>l("authorize")})]})}),t.jsx(xr,{workspaceId:e.id,canCooperate:Gt(s),onAuthorize:()=>l("authorize")})]})}export{Lr as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,r as c,B as o,v as f,ah as g,ag as w,ac as x}from"./index-
|
|
1
|
+
import{j as s,r as c,B as o,v as f,ah as g,ag as w,ac as x}from"./index-DqdaAEyo.js";import{C as j}from"./ConnectWallet-DSqRjyNA.js";import{W as p,u as y,a as C,b as W,w as v}from"./en_US-Y4ZOVFV4-CzjJ6dvA.js";import"./clsx-B-dksMZM.js";import"./index-D5ERwHFX.js";import"./index-BwpQbdIU.js";function k({onConfirmed:e}){const{address:t,isConnected:u}=y(),{disconnect:d}=C(),{signMessageAsync:h}=W(),[r,n]=c.useState(!1),[i,l]=c.useState(null);return!u||!t?s.jsx(j,{label:"Connect your wallet",size:"sm",variant:"outline",fullWidth:!1}):s.jsxs("div",{className:"gc-stack gc-stack--tight",children:[s.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[s.jsx(o,{size:"sm",disabled:r,onClick:async()=>{n(!0),l(null);try{e(await g(t,async a=>{try{return await h({message:a})}catch(m){throw new Error(v(m,"Signing was cancelled."))}}))}catch(a){l(w(a))}finally{n(!1)}},children:r?"Check your wallet…":`Confirm with ${f(t)}`}),s.jsx(o,{size:"sm",variant:"ghost",onClick:()=>d(),children:"Use a different wallet"})]}),i&&s.jsx(x,{tone:"danger",children:i})]})}function M(e){return s.jsx(p,{chain:null,children:s.jsx(k,{...e})})}export{M as default};
|