@aidotnet/server-linux-x64 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/bin/astra-server +2 -2
  2. package/bin/wwwroot/assets/{ClientsPage-DEetiYfc.js → ClientsPage-CMvzWWAq.js} +2 -2
  3. package/bin/wwwroot/assets/{KeyPage-cq7HprCR.js → KeyPage-C8QfP545.js} +1 -1
  4. package/bin/wwwroot/assets/{ModelDetailPage-Uj6p-r8V.js → ModelDetailPage-Dj3Fuga6.js} +1 -1
  5. package/bin/wwwroot/assets/{ModelsPage-B-l5oEGF.js → ModelsPage-DIYCYGb2.js} +1 -1
  6. package/bin/wwwroot/assets/{PluginsPage-BH9KjyfC.js → PluginsPage-B2nac94b.js} +1 -1
  7. package/bin/wwwroot/assets/{PrivacyPage-C5XhVKZd.js → PrivacyPage-CeRqlQGU.js} +1 -1
  8. package/bin/wwwroot/assets/{ProviderDetailPage-uLPHWm2i.js → ProviderDetailPage-DWy8CIbx.js} +1 -1
  9. package/bin/wwwroot/assets/{ProvidersPage-CNU_ji4e.js → ProvidersPage-CeisTEUC.js} +1 -1
  10. package/bin/wwwroot/assets/{SettingsPage-B3tbYdLW.js → SettingsPage-Bcv3aAmF.js} +2 -2
  11. package/bin/wwwroot/assets/{TokenDetailPage-BVyb_-ev.js → TokenDetailPage-B9WJQ1HP.js} +1 -1
  12. package/bin/wwwroot/assets/{TokenPoolEditor-7LX143SO.js → TokenPoolEditor-D8mQHyNt.js} +1 -1
  13. package/bin/wwwroot/assets/TokensPage-Cx1hPs0r.js +1 -0
  14. package/bin/wwwroot/assets/{TracesPage-C9mYB_7E.js → TracesPage-Ckw0m9u0.js} +1 -1
  15. package/bin/wwwroot/assets/{TrayPanelPage-NIkRrLCt.js → TrayPanelPage-BfD_xXkg.js} +1 -1
  16. package/bin/wwwroot/assets/{TrayPanelView-BpQQa0qi.js → TrayPanelView-daUwEIRH.js} +1 -1
  17. package/bin/wwwroot/assets/{alert-CN1yWco4.js → alert-BzjF81CS.js} +3 -3
  18. package/bin/wwwroot/assets/{arrow-down-DP0xP3tk.js → arrow-down-BjT6LDhw.js} +1 -1
  19. package/bin/wwwroot/assets/{arrow-left-UUQiUGQ1.js → arrow-left-Bv8IR_At.js} +1 -1
  20. package/bin/wwwroot/assets/{checkbox-BEWRhO5r.js → checkbox-DQpzihMp.js} +1 -1
  21. package/bin/wwwroot/assets/{cloud-download-DebyBXx2.js → cloud-download-B7vzhwxM.js} +1 -1
  22. package/bin/wwwroot/assets/{confirm-morph-DwiVsert.js → confirm-morph-BOdW6fKN.js} +1 -1
  23. package/bin/wwwroot/assets/{download-C4--ZCHf.js → download-CI3oqkmw.js} +1 -1
  24. package/bin/wwwroot/assets/{ellipsis-D250KISp.js → ellipsis-Br3iFNj9.js} +1 -1
  25. package/bin/wwwroot/assets/{external-link-Bnshhxip.js → external-link-LUcufY2s.js} +1 -1
  26. package/bin/wwwroot/assets/{folder-open-BzVuhS53.js → folder-open-rO9o554n.js} +1 -1
  27. package/bin/wwwroot/assets/{index-CBrXkG99.js → index-D7HIE1TG.js} +3 -3
  28. package/bin/wwwroot/assets/{log-out-DEZofPIg.js → log-out-Ggrqw-Tp.js} +1 -1
  29. package/bin/wwwroot/assets/minus-2zK3DUtq.js +1 -0
  30. package/bin/wwwroot/assets/overlays-8ByMRpma.js +41 -0
  31. package/bin/wwwroot/assets/{pencil-DuD1bQje.js → pencil-o6T1_skE.js} +1 -1
  32. package/bin/wwwroot/assets/{power-LE8gLJKc.js → power-BJvJ4uzr.js} +1 -1
  33. package/bin/wwwroot/assets/{radio-cards-D1yOuSfh.js → radio-cards-CWiI0xhT.js} +1 -1
  34. package/bin/wwwroot/assets/{rotate-ccw-Cx9vNOkF.js → rotate-ccw-CqwU1cME.js} +1 -1
  35. package/bin/wwwroot/assets/{sortable.esm-B0eMzUNN.js → sortable.esm-BhxNcP2n.js} +1 -1
  36. package/bin/wwwroot/index.html +3 -3
  37. package/package.json +1 -1
  38. package/bin/wwwroot/assets/TokensPage-vRrXvqkK.js +0 -1
  39. package/bin/wwwroot/assets/minus-BAoIEc33.js +0 -1
  40. package/bin/wwwroot/assets/overlays-D2pWmtov.js +0 -41
package/bin/astra-server CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/astra-server
3
- size: 49650768 bytes
4
- sha256: 5976d4e0bcc31a3149d8dadc06e3d444246fcdb359cddd42857108526aaf059c
3
+ size: 49671360 bytes
4
+ sha256: 80cf7013bc3572d4e3cc34cf78c5198051247bb04186e1a1d4b556197ba2dc4c
@@ -1,8 +1,8 @@
1
- import{$n as e,Ar as t,Bt as n,Ca as r,Ct as i,Ea as a,Er as o,G as s,Gr as c,Gt as l,Ht as u,J as d,Kn as f,Kt as p,Rt as m,Sa as h,Sr as g,Tr as _,Ut as v,V as y,W as b,Wt as x,_ as S,_t as C,c as w,ct as T,d as ee,dn as te,dr as ne,it as E,ln as re,m as D,mn as ie,n as O,nr as ae,ot as k,pt as oe,r as A,s as se,t as j,u as M,v as N,vt as ce,xa as le,y as ue,yr as P,zt as F}from"./alert-CN1yWco4.js";import{a as I,gt as L,ht as de,i as fe,o as R,r as z}from"./overlays-D2pWmtov.js";import{n as B}from"./ProvidersPage-CNU_ji4e.js";import{t as pe}from"./download-C4--ZCHf.js";import{t as me}from"./external-link-Bnshhxip.js";import{t as he}from"./folder-open-BzVuhS53.js";import{a as ge,c as V,d as H,f as _e,i as U,l as W,n as ve,o as ye,p as G,r as be,s as xe,t as Se,u as Ce}from"./sortable.esm-B0eMzUNN.js";import{t as we}from"./rotate-ccw-Cx9vNOkF.js";import{B as Te,I as Ee,L as De,Q as K,R as q,S as J,Y as Oe,Z as ke,b as Ae,h as je,v as Me,x as Y,z as Ne}from"./index-CBrXkG99.js";var Pe={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Pe.node;var Fe=ce(Pe),Ie={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Ie.node;var Le=ce(Ie),Re={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};Re.node;var ze=ce(Re),X=a(r(),1),Z=h(),Be=`astra claude`;function Ve(e){return e.reduce((e,t)=>({requests:e.requests+1,inputTokens:e.inputTokens+t.inputTokens,totalInputTokens:e.totalInputTokens+t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,outputTokens:e.outputTokens+t.outputTokens,failed:e.failed+ +(t.status===`error`),estimatedCostNanoUsd:e.estimatedCostNanoUsd+(t.estimatedCostNanoUsd??0)}),{requests:0,inputTokens:0,totalInputTokens:0,outputTokens:0,failed:0,estimatedCostNanoUsd:0})}var He=e=>e.status===`active`&&e.enabled;function Ue(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return He(e)?n:`${n} · ${t}`}function We({enabled:e,gatewayEnabled:t}){let{t:n}=k(),{toast:r}=R(),i=ke(),a=u(e),o=g(),[s,c]=(0,X.useState)(null),l=a.data?.mode??`gateway`,d=a.data?.accounts??[],f=a.data?.accountId??null??d.find(He)?.id??null,p=d.find(e=>e.id===f),m=l===`direct`,h=t&&(m||a.data!=null),_=m&&p?.telemetryEnabled===!0,y=v(_?p?.id:null,_),b=o.isPending,x=e=>o.mutate(e,{onError:e=>r(I(e),`error`)});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(M,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Z.jsx)(D,{label:n(`clients.claudeDirect.mode`),detail:n(m?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Z.jsx)(S,{ariaLabel:n(`clients.claudeDirect.mode`),value:l,onChange:e=>{if(e===l||b||!a.data)return;let t=f??d.find(He)?.id??null;if(e===`direct`&&!t){r(n(`clients.claudeDirect.needAccountToast`),`error`);return}x({mode:e,accountId:t})},items:[{value:`gateway`,label:n(`clients.claudeDirect.gateway`)},{value:`direct`,label:n(`clients.claudeDirect.direct`)}]})}),(0,Z.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:n(`clients.claudeDirect.modeNote`)})]}),a.isLoading&&(0,Z.jsx)(N,{lines:3}),a.isError&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(j,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:I(a.error)})}),h&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(j,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),a.data&&(0,Z.jsx)(M,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:d.length===0?(0,Z.jsx)(w,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Z.jsx)(A,{variant:`primary`,onClick:()=>i(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Z.jsx)(D,{label:n(`clients.claudeDirect.account`),children:(0,Z.jsx)(z,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:f,onChange:e=>{b||e===f||x({mode:l,accountId:e})},options:d.map(e=>({value:e.id,label:Ue(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!He(e)}))})})}),a.data&&m&&p&&(0,Z.jsx)(M,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Z.jsx)(Ge,{command:Be,copied:s,onCopy:async e=>{await L.copy(e)&&(c(e),r(n(`common.copied`)))}})}),a.data&&m&&p&&(0,Z.jsxs)(M,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Z.jsx)(D,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Z.jsx)(ue,{label:n(`clients.claudeDirect.statsConsent`),checked:p.telemetryEnabled,disabled:b,onChange:e=>{p&&!b&&x({mode:l,accountId:p.id,telemetryEnabled:e})}})}),_&&(0,Z.jsx)(Ke,{requests:y})]})]})}function Ge({command:e,copied:t,onCopy:n}){let{t:r}=k();return(0,Z.jsx)(D,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Z.jsx)(A,{size:`sm`,icon:(0,Z.jsx)(oe,{className:`size-3`}),variant:t===e?`primary`:`glass`,"aria-label":r(`common.copy`),title:r(`common.copy`),onClick:()=>void n(e),children:r(t===e?`common.copied`:`common.copy`)})})}function Ke({requests:e}){let{t,locale:n}=k(),r=e.data??[],i=Ve(r);return e.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(N,{lines:3})}):e.isError?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(j,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:I(e.error)})}):r.length===0?(0,Z.jsx)(w,{icon:(0,Z.jsx)(Te,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(D,{label:t(`clients.claudeDirect.statsTotals`,{count:d(i.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:d(i.totalInputTokens),cache:d(r.reduce((e,t)=>e+t.cacheReadTokens,0)),output:d(i.outputTokens)})}),(0,Z.jsx)(D,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:s(r.some(e=>e.estimatedCostNanoUsd!=null)?i.estimatedCostNanoUsd:null)})}),i.failed>0&&(0,Z.jsx)(D,{label:t(`clients.claudeDirect.statsFailedCount`,{count:d(i.failed)}),children:(0,Z.jsx)(O,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),r.map(e=>(0,Z.jsx)(D,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.model}),e.status===`error`?(0,Z.jsx)(O,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Z.jsx)(O,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Z.jsx)(`span`,{className:`num`,children:[y(e.occurredAtUtc,n),t(`clients.claudeDirect.tokensDetail`,{input:d(e.inputTokens),output:d(e.outputTokens)}),e.durationMs==null?null:b(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:s(e.estimatedCostNanoUsd)})},e.id))]})}function qe({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=k(),a=(e,r)=>{let i={...t};r===void 0||r===!1||r===0||r==="default"||r===``?delete i[e]:i[e]=r,n(i)};return(0,Z.jsx)(M,{title:i(`clients.options.title`),footer:i(r?`clients.options.footerEnabled`:`clients.options.footer`),children:e.map(e=>{let n=i(`clients.option.${e.key}`),r=i(`clients.option.${e.key}.hint`),o=t[e.key];return(0,Z.jsxs)(D,{label:n,detail:r,children:[e.type===`bool`&&(0,Z.jsx)(ue,{label:n,checked:o===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(0,Z.jsx)(ee,{className:`w-36`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof o==`number`?String(o):``,onChange:t=>{let n=Number.parseInt(t.target.value.replace(/\D/g,``),10);a(e.key,Number.isFinite(n)?n:void 0)}}),e.type===`enum`&&(0,Z.jsx)(z,{ariaLabel:n,value:typeof o==`string`?o:`default`,onChange:t=>a(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-36`})]},e.key)})})}var Je=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],Ye=e=>typeof e==`string`&&Je.includes(e);function Xe(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))Ye(r)&&(n[e]=r);return n}function Ze(e){let t=e?.models;if(!t||typeof t!=`object`)return[];let n=[];for(let e of Object.values(t)){if(!e||typeof e!=`object`)continue;let t=e;typeof t.id==`string`&&t.id&&!n.some(e=>e.id===t.id)&&n.push({id:t.id,name:typeof t.name==`string`&&t.name?t.name:t.id,native:Array.isArray(t.protocols)?t.protocols.filter(Ye):[]})}return n}function Qe(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var $e=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
1
+ import{$n as e,Ar as t,Bt as n,Ca as r,Ct as i,Ea as a,Er as o,G as s,Gr as c,Gt as l,Ht as u,J as d,Kn as f,Kt as p,Rt as m,Sa as h,Sr as g,Tr as _,Ut as v,V as y,W as b,Wt as x,_ as S,_t as C,c as w,ct as T,d as ee,dn as te,dr as ne,it as E,ln as re,m as D,mn as ie,n as O,nr as ae,ot as k,pt as oe,r as A,s as se,t as j,u as M,v as N,vt as ce,xa as le,y as ue,yr as P,zt as F}from"./alert-BzjF81CS.js";import{a as I,gt as L,ht as de,i as fe,o as R,r as z}from"./overlays-8ByMRpma.js";import{n as B}from"./ProvidersPage-CeisTEUC.js";import{t as pe}from"./download-CI3oqkmw.js";import{t as me}from"./external-link-LUcufY2s.js";import{t as he}from"./folder-open-rO9o554n.js";import{a as ge,c as V,d as H,f as _e,i as U,l as W,n as ve,o as ye,p as G,r as be,s as xe,t as Se,u as Ce}from"./sortable.esm-BhxNcP2n.js";import{t as we}from"./rotate-ccw-CqwU1cME.js";import{B as Te,I as Ee,L as De,Q as K,R as q,S as J,Y as Oe,Z as ke,b as Ae,h as je,v as Me,x as Y,z as Ne}from"./index-D7HIE1TG.js";var Pe={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Pe.node;var Fe=ce(Pe),Ie={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Ie.node;var Le=ce(Ie),Re={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};Re.node;var ze=ce(Re),X=a(r(),1),Z=h(),Be=`astra claude`;function Ve(e){return e.reduce((e,t)=>({requests:e.requests+1,inputTokens:e.inputTokens+t.inputTokens,totalInputTokens:e.totalInputTokens+t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,outputTokens:e.outputTokens+t.outputTokens,failed:e.failed+ +(t.status===`error`),estimatedCostNanoUsd:e.estimatedCostNanoUsd+(t.estimatedCostNanoUsd??0)}),{requests:0,inputTokens:0,totalInputTokens:0,outputTokens:0,failed:0,estimatedCostNanoUsd:0})}var He=e=>e.status===`active`&&e.enabled;function Ue(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return He(e)?n:`${n} · ${t}`}function We({enabled:e,gatewayEnabled:t}){let{t:n}=k(),{toast:r}=R(),i=ke(),a=u(e),o=g(),[s,c]=(0,X.useState)(null),l=a.data?.mode??`gateway`,d=a.data?.accounts??[],f=a.data?.accountId??null??d.find(He)?.id??null,p=d.find(e=>e.id===f),m=l===`direct`,h=t&&(m||a.data!=null),_=m&&p?.telemetryEnabled===!0,y=v(_?p?.id:null,_),b=o.isPending,x=e=>o.mutate(e,{onError:e=>r(I(e),`error`)});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(M,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Z.jsx)(D,{label:n(`clients.claudeDirect.mode`),detail:n(m?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Z.jsx)(S,{ariaLabel:n(`clients.claudeDirect.mode`),value:l,onChange:e=>{if(e===l||b||!a.data)return;let t=f??d.find(He)?.id??null;if(e===`direct`&&!t){r(n(`clients.claudeDirect.needAccountToast`),`error`);return}x({mode:e,accountId:t})},items:[{value:`gateway`,label:n(`clients.claudeDirect.gateway`)},{value:`direct`,label:n(`clients.claudeDirect.direct`)}]})}),(0,Z.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:n(`clients.claudeDirect.modeNote`)})]}),a.isLoading&&(0,Z.jsx)(N,{lines:3}),a.isError&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(j,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:I(a.error)})}),h&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(j,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),a.data&&(0,Z.jsx)(M,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:d.length===0?(0,Z.jsx)(w,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Z.jsx)(A,{variant:`primary`,onClick:()=>i(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Z.jsx)(D,{label:n(`clients.claudeDirect.account`),children:(0,Z.jsx)(z,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:f,onChange:e=>{b||e===f||x({mode:l,accountId:e})},options:d.map(e=>({value:e.id,label:Ue(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!He(e)}))})})}),a.data&&m&&p&&(0,Z.jsx)(M,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Z.jsx)(Ge,{command:Be,copied:s,onCopy:async e=>{await L.copy(e)&&(c(e),r(n(`common.copied`)))}})}),a.data&&m&&p&&(0,Z.jsxs)(M,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Z.jsx)(D,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Z.jsx)(ue,{label:n(`clients.claudeDirect.statsConsent`),checked:p.telemetryEnabled,disabled:b,onChange:e=>{p&&!b&&x({mode:l,accountId:p.id,telemetryEnabled:e})}})}),_&&(0,Z.jsx)(Ke,{requests:y})]})]})}function Ge({command:e,copied:t,onCopy:n}){let{t:r}=k();return(0,Z.jsx)(D,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Z.jsx)(A,{size:`sm`,icon:(0,Z.jsx)(oe,{className:`size-3`}),variant:t===e?`primary`:`glass`,"aria-label":r(`common.copy`),title:r(`common.copy`),onClick:()=>void n(e),children:r(t===e?`common.copied`:`common.copy`)})})}function Ke({requests:e}){let{t,locale:n}=k(),r=e.data??[],i=Ve(r);return e.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(N,{lines:3})}):e.isError?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(j,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:I(e.error)})}):r.length===0?(0,Z.jsx)(w,{icon:(0,Z.jsx)(Te,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(D,{label:t(`clients.claudeDirect.statsTotals`,{count:d(i.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:d(i.totalInputTokens),cache:d(r.reduce((e,t)=>e+t.cacheReadTokens,0)),output:d(i.outputTokens)})}),(0,Z.jsx)(D,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:s(r.some(e=>e.estimatedCostNanoUsd!=null)?i.estimatedCostNanoUsd:null)})}),i.failed>0&&(0,Z.jsx)(D,{label:t(`clients.claudeDirect.statsFailedCount`,{count:d(i.failed)}),children:(0,Z.jsx)(O,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),r.map(e=>(0,Z.jsx)(D,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.model}),e.status===`error`?(0,Z.jsx)(O,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Z.jsx)(O,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Z.jsx)(`span`,{className:`num`,children:[y(e.occurredAtUtc,n),t(`clients.claudeDirect.tokensDetail`,{input:d(e.inputTokens),output:d(e.outputTokens)}),e.durationMs==null?null:b(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:s(e.estimatedCostNanoUsd)})},e.id))]})}function qe({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=k(),a=(e,r)=>{let i={...t};r===void 0||r===!1||r===0||r==="default"||r===``?delete i[e]:i[e]=r,n(i)};return(0,Z.jsx)(M,{title:i(`clients.options.title`),footer:i(r?`clients.options.footerEnabled`:`clients.options.footer`),children:e.map(e=>{let n=i(`clients.option.${e.key}`),r=i(`clients.option.${e.key}.hint`),o=t[e.key];return(0,Z.jsxs)(D,{label:n,detail:r,children:[e.type===`bool`&&(0,Z.jsx)(ue,{label:n,checked:o===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(0,Z.jsx)(ee,{className:`w-36`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof o==`number`?String(o):``,onChange:t=>{let n=Number.parseInt(t.target.value.replace(/\D/g,``),10);a(e.key,Number.isFinite(n)?n:void 0)}}),e.type===`enum`&&(0,Z.jsx)(z,{ariaLabel:n,value:typeof o==`string`?o:`default`,onChange:t=>a(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-36`})]},e.key)})})}var Je=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],Ye=e=>typeof e==`string`&&Je.includes(e);function Xe(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))Ye(r)&&(n[e]=r);return n}function Ze(e){let t=e?.models;if(!t||typeof t!=`object`)return[];let n=[];for(let e of Object.values(t)){if(!e||typeof e!=`object`)continue;let t=e;typeof t.id==`string`&&t.id&&!n.some(e=>e.id===t.id)&&n.push({id:t.id,name:typeof t.name==`string`&&t.name?t.name:t.id,native:Array.isArray(t.protocols)?t.protocols.filter(Ye):[]})}return n}function Qe(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var $e=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
2
2
  `),et=`auto`,tt=e=>B.find(t=>t.value===e)?.label??e;function nt({models:e,supported:t,values:n,onChange:r,enabled:i}){let{t:a}=k(),o=(e,t)=>{let i={...n};t===et?delete i[e]:i[e]=t,r(i)};return(0,Z.jsx)(M,{title:a(`clients.protocols.title`),footer:a(i?`clients.protocols.footerEnabled`:`clients.protocols.footer`),children:e.map(e=>{let r=Qe(e,t),i=e.native.filter(e=>t.includes(e));return(0,Z.jsx)(D,{label:e.name,detail:i.length>0?a(`clients.protocols.native`,{protocols:i.map(tt).join(` · `)}):a(`clients.protocols.noNative`),children:(0,Z.jsx)(z,{ariaLabel:e.name,className:`w-60`,value:n[e.id]&&t.includes(n[e.id])?n[e.id]:et,onChange:t=>o(e.id,t),options:[{value:et,label:a(r.translated?`clients.protocols.autoTranslated`:`clients.protocols.auto`,{protocol:tt(r.protocol)})},...t.map(e=>({value:e,label:tt(e)}))]})},e.id)})})}function rt(e,t){let n=e?.options,r={};if(!n||typeof n!=`object`)return r;for(let e of t??[]){let t=n[e.key];e.type===`bool`&&t===!0?r[e.key]=!0:(e.type===`int`&&typeof t==`number`&&t>0||e.type===`enum`&&typeof t==`string`&&t!=="default"&&e.choices?.includes(t))&&(r[e.key]=t)}return r}var it=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
3
3
  `),at=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`];function ot(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of at){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var st=e=>at.map(t=>e[t]??``).join(`
4
4
  `),Q=[`sonnet`,`opus`,`haiku`];function ct(e){let t=e?.roleMap,n={};if(!t||typeof t!=`object`)return n;for(let e of Q){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var $=e=>Q.map(t=>e[t]??``).join(`
5
- `),lt=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function ut(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!lt.test(e))??e[0],r=e.find(e=>lt.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function dt(){let{t:e}=k(),t=ke(),{toast:r}=R(),i=K(),a=p(),o=n(),s=(0,X.useMemo)(()=>new Map((a.data??[]).map(e=>[e.kind,e])),[a.data]),c=pt(a.data).includes(i.kind)?i.kind:`codex`,l=s.get(c);return(0,X.useEffect)(()=>o.mutate(!1),[]),(0,Z.jsx)(je,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Z.jsx)(A,{icon:(0,Z.jsx)(De,{className:`size-3.5`}),loading:o.isPending,onClick:()=>o.mutate(!0,{onSuccess:t=>{let n=t.filter(e=>e.install?.updateAvailable&&e.install.blocker!==`shadowed`).length;r(n>0?e(`clients.updatesFound`,{count:n}):e(`clients.allUpToDate`),n>0?void 0:`success`)},onError:e=>r(I(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Z.jsx)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Z.jsx)(_t,{clients:a.data,loading:a.isLoading,selected:c,onSelect:e=>t(`/clients/${e}`,{replace:!0})}),(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-[760px] min-w-0 flex-1`,children:[a.isLoading&&(0,Z.jsx)(N,{lines:4}),a.isError&&(0,Z.jsx)(j,{tone:`danger`,title:e(`common.error`),children:I(a.error)}),l&&(0,Z.jsx)(xt,{client:l})]})]})})})}var ft=new Set([`opencode`,`pi`,`minimax-code`,`copilot-cli`,`vscode-copilot`,`crush`,`qwen-code`,`droid`,`kimi-code`,`zed`,`vscode-insiders`,`vscodium`,`omp`,`mimo-code`,`deepseek-harness`,`workbuddy`,`workbuddy-ai`,`nextcowork`,`paseo`,`muse-code`,`codex`,`grok-build`,`hermes-agent`]);function pt(e){let t=(e??[]).filter(e=>!Me.includes(e.kind)).sort((e,t)=>e.name.localeCompare(t.name));return[...Me,...t.map(e=>e.kind)]}var mt=[`installed`,`notInstalled`,`comingSoon`];function ht(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function gt(e){return e.install?.version??e.detection.version??null}function _t({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=k(),a=new Map((e??[]).map(e=>[e.kind,e])),o=mt.map(t=>({group:t,items:pt(e).flatMap(e=>{let n=a.get(e);return n&&ht(n)===t?[n]:[]})})).filter(e=>e.items.length>0);return(0,Z.jsxs)(`nav`,{"aria-label":i(`nav.clients`),className:`card shrink-0 p-1.5 @3xl:sticky @3xl:top-0 @3xl:w-[232px]`,children:[t&&(0,Z.jsx)(N,{lines:6,className:`p-2`}),(0,Z.jsx)(`div`,{className:`flex gap-1 overflow-x-auto @3xl:flex-col @3xl:gap-0 @3xl:overflow-visible`,children:o.map(({group:e,items:t})=>(0,Z.jsxs)(`div`,{className:`contents @3xl:block`,children:[(0,Z.jsxs)(`h3`,{className:`hidden px-2.5 pt-2 pb-1 text-[11px] font-medium text-[var(--text-muted)] @3xl:block`,children:[i(`clients.group.${e}`),` · `,t.length]}),t.map(e=>(0,Z.jsx)(vt,{client:e,active:e.kind===n,onSelect:()=>r(e.kind)},e.kind))]},e))})]})}function vt({client:e,active:t,onSelect:n}){let{t:r}=k(),i=ht(e)!==`installed`,a=gt(e),o=e.install?.blocker===`shadowed`,s=e.install?.updateAvailable&&!o?e.install.latestVersion:null;return(0,Z.jsxs)(`button`,{type:`button`,"aria-label":J(e.kind,e.name),"aria-current":t?`page`:void 0,onClick:n,className:E(`flex shrink-0 items-center gap-2.5 rounded-[var(--radius-control)] px-2.5 py-1.5 text-left transition-colors @3xl:w-full`,t?`bg-[var(--accent-subtle)]`:`hover:bg-[var(--surface-muted)]`),children:[(0,Z.jsx)(`span`,{className:E(`inline-flex`,i&&!t&&`opacity-60`),children:(0,Z.jsx)(Ae,{kind:e.kind,size:24})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:E(`block truncate text-[13px] whitespace-nowrap`,t&&`font-medium`),children:J(e.kind,e.name)}),a&&(0,Z.jsxs)(`span`,{className:`hidden truncate text-[11px] text-[var(--text-secondary)] @3xl:block`,children:[a,s&&(0,Z.jsxs)(`span`,{className:`text-[var(--warning)]`,children:[` → `,s]})]})]}),e.install?.busy&&(0,Z.jsx)(yt,{}),s&&!e.install?.busy&&(0,Z.jsx)(O,{tone:`orange`,title:r(`clients.updateTo`,{version:s}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Z.jsx)(O,{tone:`orange`,title:r(`clients.shadowed.title`,{version:e.install?.latestVersion??``}),children:r(`clients.shadowedBadge`)}),e.status===`drifted`?(0,Z.jsx)(`span`,{title:r(`clients.drifted`),"aria-label":r(`clients.drifted`),className:`inline-flex`,children:(0,Z.jsx)(se,{tone:`orange`})}):e.enabled?(0,Z.jsx)(C,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function yt(){return(0,Z.jsx)(Ne,{className:`size-3.5 shrink-0 animate-spin text-[var(--text-secondary)] motion-reduce:animate-none`,"aria-hidden":!0})}function bt(e,t){return e.availability===`coming_soon`?(0,Z.jsx)(O,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Z.jsx)(O,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Z.jsx)(O,{tone:`green`,children:t(`clients.enabled`)}):(0,Z.jsx)(O,{children:t(`clients.disabled`)})}function xt({client:t}){let{t:n,locale:r}=k(),i=ke(),{toast:a,confirm:o}=R(),s=ae(),d=_(),f=re(),p=ie(),m=ne(),h=c(),g=l(t.kind,!!t.providerId),[v,b]=(0,X.useState)(t.selectedModel??null),[x,S]=(0,X.useState)(t.accountId??``),C=t.tokenId??`default`,[w,T]=(0,X.useState)(C),ee=(h.data??[]).filter(e=>e.enabled||e.id===C).map(e=>({value:e.id,label:e.enabled?e.name:n(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[te,E]=(0,X.useState)(!1),[se,ce]=(0,X.useState)(!1),[le,ue]=(0,X.useState)(null),P=t.availability===`coming_soon`,F=J(t.kind,t.name),fe=(s.data??[]).filter(e=>e.enabled),B=t.detection.configPaths[0],pe=fe.find(e=>e.id===t.providerId),me=pe?.authScheme===`oauth-subscription`||pe?.authScheme===`plugin`,ge=e(pe?.id,me),V=t.kind===`claude-desktop`,H=t.kind===`claude-code`,_e=u(H),U=H&&_e.data?.mode===`direct`,W=ct(t.extras),[ve,ye]=(0,X.useState)(W),G=Q.some(e=>ve[e]),be=$(ve)!==$(W),xe=ot(t.extras),[Se,Ce]=(0,X.useState)(xe),we=(v??null)!==(t.selectedModel??null)||st(Se)!==st(xe),Ee=H?at.filter(e=>e!==`ANTHROPIC_MODEL`):[],De=H?t.enabled?n(`clients.modelSlotsFooterEnabled`):n(`clients.modelSlotsFooter`):t.enabled?n(`clients.modelFooterEnabled`):n(`clients.modelFooter`),K=t.options??[],q=rt(t.extras,K),[Oe,je]=(0,X.useState)(q),Me=it(Oe)!==it(q),Y=t.protocols??[],Ne=Y.length>1?Ze(t.extras):[],Pe=Xe(t.extras),[Ie,Le]=(0,X.useState)(Pe),Re=$e(Ie)!==$e(Pe),ze=V?{...t.extras,roleMap:ve}:H?{...t.extras,models:Se,options:Oe}:K.length>0||Y.length>1?{...t.extras,...K.length>0?{options:Oe}:{},...Y.length>1?{protocolOverrides:Ie}:{}}:void 0;(0,X.useEffect)(()=>b(t.selectedModel??null),[t.kind,t.selectedModel]),(0,X.useEffect)(()=>S(t.accountId??``),[t.kind,t.providerId,t.accountId]),(0,X.useEffect)(()=>T(C),[t.kind,C]),(0,X.useEffect)(()=>ye(ct(t.extras)),[t.kind,$(W)]);let Be=(0,X.useRef)({});(0,X.useEffect)(()=>{if(!V||t.enabled||Q.some(e=>W[e]))return;let e=Be.current,n=ut(g.data??[]);Be.current=n,ye(t=>(!Q.some(e=>t[e])||$(t)===$(e))&&$(t)!==$(n)?n:t)},[t.kind,t.enabled,$(W),(g.data??[]).join(`
5
+ `),lt=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function ut(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!lt.test(e))??e[0],r=e.find(e=>lt.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function dt(){let{t:e}=k(),t=ke(),{toast:r}=R(),i=K(),a=p(),o=n(),s=(0,X.useMemo)(()=>new Map((a.data??[]).map(e=>[e.kind,e])),[a.data]),c=pt(a.data).includes(i.kind)?i.kind:`codex`,l=s.get(c);return(0,X.useEffect)(()=>o.mutate(!1),[]),(0,Z.jsx)(je,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Z.jsx)(A,{icon:(0,Z.jsx)(De,{className:`size-3.5`}),loading:o.isPending,onClick:()=>o.mutate(!0,{onSuccess:t=>{let n=t.filter(e=>e.install?.updateAvailable&&e.install.blocker!==`shadowed`).length;r(n>0?e(`clients.updatesFound`,{count:n}):e(`clients.allUpToDate`),n>0?void 0:`success`)},onError:e=>r(I(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Z.jsx)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Z.jsx)(_t,{clients:a.data,loading:a.isLoading,selected:c,onSelect:e=>t(`/clients/${e}`,{replace:!0})}),(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-[760px] min-w-0 flex-1`,children:[a.isLoading&&(0,Z.jsx)(N,{lines:4}),a.isError&&(0,Z.jsx)(j,{tone:`danger`,title:e(`common.error`),children:I(a.error)}),l&&(0,Z.jsx)(xt,{client:l})]})]})})})}var ft=new Set([`opencode`,`pi`,`minimax-code`,`copilot-cli`,`vscode-copilot`,`crush`,`qwen-code`,`droid`,`kimi-code`,`zed`,`vscode-insiders`,`vscodium`,`omp`,`mimo-code`,`deepseek-harness`,`workbuddy`,`workbuddy-ai`,`nextcowork`,`paseo`,`zcode`,`muse-code`,`codex`,`grok-build`,`hermes-agent`]);function pt(e){let t=(e??[]).filter(e=>!Me.includes(e.kind)).sort((e,t)=>e.name.localeCompare(t.name));return[...Me,...t.map(e=>e.kind)]}var mt=[`installed`,`notInstalled`,`comingSoon`];function ht(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function gt(e){return e.install?.version??e.detection.version??null}function _t({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=k(),a=new Map((e??[]).map(e=>[e.kind,e])),o=mt.map(t=>({group:t,items:pt(e).flatMap(e=>{let n=a.get(e);return n&&ht(n)===t?[n]:[]})})).filter(e=>e.items.length>0);return(0,Z.jsxs)(`nav`,{"aria-label":i(`nav.clients`),className:`card shrink-0 p-1.5 @3xl:sticky @3xl:top-0 @3xl:w-[232px]`,children:[t&&(0,Z.jsx)(N,{lines:6,className:`p-2`}),(0,Z.jsx)(`div`,{className:`flex gap-1 overflow-x-auto @3xl:flex-col @3xl:gap-0 @3xl:overflow-visible`,children:o.map(({group:e,items:t})=>(0,Z.jsxs)(`div`,{className:`contents @3xl:block`,children:[(0,Z.jsxs)(`h3`,{className:`hidden px-2.5 pt-2 pb-1 text-[11px] font-medium text-[var(--text-muted)] @3xl:block`,children:[i(`clients.group.${e}`),` · `,t.length]}),t.map(e=>(0,Z.jsx)(vt,{client:e,active:e.kind===n,onSelect:()=>r(e.kind)},e.kind))]},e))})]})}function vt({client:e,active:t,onSelect:n}){let{t:r}=k(),i=ht(e)!==`installed`,a=gt(e),o=e.install?.blocker===`shadowed`,s=e.install?.updateAvailable&&!o?e.install.latestVersion:null;return(0,Z.jsxs)(`button`,{type:`button`,"aria-label":J(e.kind,e.name),"aria-current":t?`page`:void 0,onClick:n,className:E(`flex shrink-0 items-center gap-2.5 rounded-[var(--radius-control)] px-2.5 py-1.5 text-left transition-colors @3xl:w-full`,t?`bg-[var(--accent-subtle)]`:`hover:bg-[var(--surface-muted)]`),children:[(0,Z.jsx)(`span`,{className:E(`inline-flex`,i&&!t&&`opacity-60`),children:(0,Z.jsx)(Ae,{kind:e.kind,size:24})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:E(`block truncate text-[13px] whitespace-nowrap`,t&&`font-medium`),children:J(e.kind,e.name)}),a&&(0,Z.jsxs)(`span`,{className:`hidden truncate text-[11px] text-[var(--text-secondary)] @3xl:block`,children:[a,s&&(0,Z.jsxs)(`span`,{className:`text-[var(--warning)]`,children:[` → `,s]})]})]}),e.install?.busy&&(0,Z.jsx)(yt,{}),s&&!e.install?.busy&&(0,Z.jsx)(O,{tone:`orange`,title:r(`clients.updateTo`,{version:s}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Z.jsx)(O,{tone:`orange`,title:r(`clients.shadowed.title`,{version:e.install?.latestVersion??``}),children:r(`clients.shadowedBadge`)}),e.status===`drifted`?(0,Z.jsx)(`span`,{title:r(`clients.drifted`),"aria-label":r(`clients.drifted`),className:`inline-flex`,children:(0,Z.jsx)(se,{tone:`orange`})}):e.enabled?(0,Z.jsx)(C,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function yt(){return(0,Z.jsx)(Ne,{className:`size-3.5 shrink-0 animate-spin text-[var(--text-secondary)] motion-reduce:animate-none`,"aria-hidden":!0})}function bt(e,t){return e.availability===`coming_soon`?(0,Z.jsx)(O,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Z.jsx)(O,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Z.jsx)(O,{tone:`green`,children:t(`clients.enabled`)}):(0,Z.jsx)(O,{children:t(`clients.disabled`)})}function xt({client:t}){let{t:n,locale:r}=k(),i=ke(),{toast:a,confirm:o}=R(),s=ae(),d=_(),f=re(),p=ie(),m=ne(),h=c(),g=l(t.kind,!!t.providerId),[v,b]=(0,X.useState)(t.selectedModel??null),[x,S]=(0,X.useState)(t.accountId??``),C=t.tokenId??`default`,[w,T]=(0,X.useState)(C),ee=(h.data??[]).filter(e=>e.enabled||e.id===C).map(e=>({value:e.id,label:e.enabled?e.name:n(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[te,E]=(0,X.useState)(!1),[se,ce]=(0,X.useState)(!1),[le,ue]=(0,X.useState)(null),P=t.availability===`coming_soon`,F=J(t.kind,t.name),fe=(s.data??[]).filter(e=>e.enabled),B=t.detection.configPaths[0],pe=fe.find(e=>e.id===t.providerId),me=pe?.authScheme===`oauth-subscription`||pe?.authScheme===`plugin`,ge=e(pe?.id,me),V=t.kind===`claude-desktop`,H=t.kind===`claude-code`,_e=u(H),U=H&&_e.data?.mode===`direct`,W=ct(t.extras),[ve,ye]=(0,X.useState)(W),G=Q.some(e=>ve[e]),be=$(ve)!==$(W),xe=ot(t.extras),[Se,Ce]=(0,X.useState)(xe),we=(v??null)!==(t.selectedModel??null)||st(Se)!==st(xe),Ee=H?at.filter(e=>e!==`ANTHROPIC_MODEL`):[],De=H?t.enabled?n(`clients.modelSlotsFooterEnabled`):n(`clients.modelSlotsFooter`):t.enabled?n(`clients.modelFooterEnabled`):n(`clients.modelFooter`),K=t.options??[],q=rt(t.extras,K),[Oe,je]=(0,X.useState)(q),Me=it(Oe)!==it(q),Y=t.protocols??[],Ne=Y.length>1?Ze(t.extras):[],Pe=Xe(t.extras),[Ie,Le]=(0,X.useState)(Pe),Re=$e(Ie)!==$e(Pe),ze=V?{...t.extras,roleMap:ve}:H?{...t.extras,models:Se,options:Oe}:K.length>0||Y.length>1?{...t.extras,...K.length>0?{options:Oe}:{},...Y.length>1?{protocolOverrides:Ie}:{}}:void 0;(0,X.useEffect)(()=>b(t.selectedModel??null),[t.kind,t.selectedModel]),(0,X.useEffect)(()=>S(t.accountId??``),[t.kind,t.providerId,t.accountId]),(0,X.useEffect)(()=>T(C),[t.kind,C]),(0,X.useEffect)(()=>ye(ct(t.extras)),[t.kind,$(W)]);let Be=(0,X.useRef)({});(0,X.useEffect)(()=>{if(!V||t.enabled||Q.some(e=>W[e]))return;let e=Be.current,n=ut(g.data??[]);Be.current=n,ye(t=>(!Q.some(e=>t[e])||$(t)===$(e))&&$(t)!==$(n)?n:t)},[t.kind,t.enabled,$(W),(g.data??[]).join(`
6
6
  `)]),(0,X.useEffect)(()=>Ce(ot(t.extras)),[t.kind,st(xe)]),(0,X.useEffect)(()=>je(rt(t.extras,t.options)),[t.kind,it(q)]),(0,X.useEffect)(()=>Le(Xe(t.extras)),[t.kind,$e(Pe)]);let Ve=()=>{t.providerId&&d.mutate({kind:t.kind,providerId:t.providerId,accountId:x},{onSuccess:()=>a(n(`common.saved`),`success`),onError:e=>a(I(e),`error`)})},He=async()=>{await o({title:n(`clients.disableConfirm`,{name:F}),detail:n(`clients.disableDetail`),confirmLabel:n(`clients.disable`)})&&f.mutate(t.kind,{onSuccess:async e=>{if(e.drifted.length===0){a(n(`clients.disabledToast`,{name:F}),`success`);return}await o({title:n(`clients.driftTitle`),detail:n(`clients.driftDetail`,{keys:e.drifted.join(`, `)}),confirmLabel:n(`clients.forceRestore`),destructive:!0})&&p.mutate(t.kind,{onSuccess:()=>a(n(`clients.disabledToast`,{name:F}),`success`),onError:e=>a(I(e),`error`)})},onError:e=>a(I(e),`error`)})},Ue=async()=>{B&&(L.canOpenPaths?await L.openPath(de(B)):await L.copy(B)&&a(n(`common.copied`)))};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(M,{children:[(0,Z.jsxs)(D,{icon:(0,Z.jsx)(Ae,{kind:t.kind,size:36}),label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[15px] font-medium`,children:F}),U?(0,Z.jsx)(O,{children:n(`clients.claudeDirect.direct`)}):bt(t,n)]}),detail:P?t.availabilityReason??n(`clients.comingSoonDetail`):[ht(t)===`installed`?n(`clients.detected`,{version:gt(t)??``}):n(`clients.notDetected`),U?null:B].filter(Boolean).join(` · `),className:`py-3`,children:[!P&&(0,Z.jsx)(Tt,{client:t,onOpen:ue}),U?(0,Z.jsx)(A,{variant:`primary`,onClick:()=>document.getElementById(Dt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:n(`clients.claudeDirect.configure`)}):t.enabled?(0,Z.jsx)(A,{onClick:()=>void He(),loading:f.isPending,children:n(`clients.disableRestore`)}):(0,Z.jsx)(A,{variant:`primary`,disabled:P||!t.providerId||V&&!G,onClick:()=>E(!0),title:t.providerId?V&&!G?n(`clients.roleMapRequired`):void 0:n(`clients.pickProviderFirst`),children:n(`clients.enable`)})]}),!U&&t.appliedAt&&(0,Z.jsx)(D,{label:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:n(`clients.appliedAt`,{time:y(t.appliedAt,r)})})})]}),!P&&!t.enabled&&V&&t.providerId&&!G&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsx)(j,{tone:`info`,className:`self-stretch`,title:n(`clients.roleMapHint`)}),(0,Z.jsx)(A,{onClick:()=>document.getElementById(Ot)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:n(`clients.roleMapGoto`)})]}),(t.repairs?.length??0)>0&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsxs)(j,{tone:`danger`,className:`self-stretch`,title:n(`clients.repair.title`,{name:F}),children:[t.repairs?.map(e=>(0,Z.jsxs)(`span`,{className:`block break-all`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.file}),` — `,n(`clients.repair.problem.${e.problem}`,{line:e.line})]},e.file)),(0,Z.jsx)(`span`,{className:`block`,children:n(`clients.repair.hint`)})]}),(0,Z.jsx)(A,{variant:`primary`,loading:m.isPending,onClick:()=>m.mutate(t.kind,{onSuccess:()=>a(n(`clients.repair.done`,{name:F}),`success`),onError:e=>a(I(e),`error`)}),children:n(`clients.repair.action`)})]}),!U&&t.warnings.length>0&&(0,Z.jsx)(`div`,{className:`mb-5 flex flex-col gap-2`,children:t.warnings.map((e,t)=>(0,Z.jsx)(j,{tone:`warning`,title:e},t))}),!U&&(0,Z.jsx)(Ct,{client:t,providers:s.data??[],loading:s.isLoading,soon:P}),!U&&me&&(0,Z.jsx)(M,{title:n(`clients.accountTitle`),footer:n(`clients.accountFooter`),children:ge.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(N,{lines:2})}):(0,Z.jsxs)(D,{label:n(`clients.account`),children:[(0,Z.jsx)(z,{className:`max-w-[300px]`,ariaLabel:n(`clients.account`),value:x,onChange:S,options:[{value:``,label:n(`clients.accountDefault`)},...(ge.data??[]).map(e=>({value:e.id,label:(e.displayName||e.id)+(e.status===`active`?``:` · ${n(`providers.subscription.status.${e.status}`)}`)}))]}),x!==(t.accountId??``)&&(0,Z.jsx)(A,{size:`sm`,variant:`primary`,loading:d.isPending,onClick:Ve,children:n(`common.apply`)})]})}),!P&&!U&&(0,Z.jsxs)(M,{title:n(`clients.tokenTitle`),footer:t.enabled?n(`clients.tokenFooterEnabled`):n(`clients.tokenFooter`),children:[(0,Z.jsxs)(D,{label:n(`clients.token`),children:[(0,Z.jsx)(z,{className:`max-w-[300px]`,ariaLabel:n(`clients.token`),value:w,onChange:T,options:ee}),t.enabled&&w!==C&&(0,Z.jsx)(A,{size:`sm`,variant:`primary`,onClick:()=>E(!0),children:n(`common.apply`)})]}),(0,Z.jsx)(D,{icon:(0,Z.jsx)(Te,{className:`size-4 text-[var(--text-secondary)]`}),label:n(`clients.manageTokens`),onClick:()=>i(`/tokens`)})]}),!P&&!U&&t.providerId&&V&&(0,Z.jsx)(`div`,{id:Ot,children:(0,Z.jsxs)(M,{title:n(`clients.roleMapTitle`),footer:t.enabled?n(`clients.roleMapFooterEnabled`):n(`clients.roleMapFooter`),children:[Q.map(e=>(0,Z.jsx)(D,{label:n(`clients.role.${e}`),children:(0,Z.jsx)(z,{ariaLabel:n(`clients.role.${e}`),value:ve[e]??``,onChange:t=>ye(n=>({...n,[e]:t||void 0})),placeholder:n(`clients.modelPlaceholder`),options:[{value:``,label:n(`clients.modelUnset`)},...(g.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),t.enabled&&be&&(0,Z.jsx)(D,{label:G?``:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--warning)]`,children:n(`clients.roleMapRequired`)}),children:(0,Z.jsx)(A,{size:`sm`,variant:`primary`,disabled:!G,onClick:()=>E(!0),children:n(`common.apply`)})})]})}),!P&&!U&&t.providerId&&!V&&(0,Z.jsxs)(M,{title:n(`clients.modelTitle`),footer:De,children:[(0,Z.jsx)(D,{label:n(`clients.defaultModel`),children:(0,Z.jsx)(z,{value:v??``,onChange:e=>b(e||null),placeholder:n(`clients.modelPlaceholder`),options:[{value:``,label:n(`clients.modelUnset`)},...(g.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})}),Ee.map(e=>(0,Z.jsx)(D,{label:n(`clients.modelSlot.${e}`),children:(0,Z.jsx)(z,{ariaLabel:n(`clients.modelSlot.${e}`),value:Se[e]??``,onChange:t=>Ce(n=>({...n,[e]:t||void 0})),placeholder:n(`clients.modelPlaceholder`),options:[{value:``,label:n(`clients.modelUnset`)},...(g.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),t.enabled&&(H?we:(v??null)!==(t.selectedModel??null))&&(0,Z.jsx)(D,{label:``,children:(0,Z.jsx)(A,{size:`sm`,variant:`primary`,onClick:()=>E(!0),children:n(`common.apply`)})})]}),!P&&!U&&K.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(qe,{descriptors:K,values:Oe,onChange:je,enabled:t.enabled}),t.enabled&&Me&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(A,{size:`sm`,variant:`primary`,onClick:()=>E(!0),children:n(`common.apply`)})})]}),!P&&Ne.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(nt,{models:Ne,supported:Y,values:Ie,onChange:Le,enabled:t.enabled}),t.enabled&&Re&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(A,{size:`sm`,variant:`primary`,onClick:()=>E(!0),children:n(`common.apply`)})})]}),!P&&t.install&&(0,Z.jsx)(kt,{client:t,onShowLog:()=>ue(`log`)}),H&&(0,Z.jsx)(`div`,{id:Dt,children:(0,Z.jsx)(We,{enabled:H,gatewayEnabled:t.enabled})}),!P&&!U&&(0,Z.jsxs)(M,{title:n(`clients.maintenance`),children:[B&&(0,Z.jsx)(D,{icon:L.canOpenPaths?(0,Z.jsx)(he,{className:`size-4 text-[var(--text-secondary)]`}):(0,Z.jsx)(oe,{className:`size-4 text-[var(--text-secondary)]`}),label:L.canOpenPaths?n(`clients.openConfigDir`):n(`clients.copyConfigPath`),detail:B,onClick:()=>void Ue()}),(0,Z.jsx)(D,{icon:(0,Z.jsx)(Fe,{className:`size-4 text-[var(--text-secondary)]`}),label:n(`clients.backups`),detail:n(`clients.backupsDetail`),onClick:()=>ce(!0)})]}),(0,Z.jsx)(jt,{open:te,onOpenChange:E,client:t,model:v,extras:ze,tokenId:w}),(0,Z.jsx)(Pt,{open:se,onOpenChange:ce,client:t}),(0,Z.jsx)(At,{mode:le,onClose:()=>ue(null),client:t})]})}function St(e,t){return[e.priceKey??e.templateId,t(`providers.modelCount`,{count:e.modelCount}),e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `)}function Ct({client:e,providers:t,loading:n,soon:r}){let{t:i}=k(),{toast:a}=R(),s=o(),c=(0,X.useMemo)(()=>e.bindings??(e.providerId?[{providerId:e.providerId,accountId:e.accountId}]:[]),[e.bindings,e.providerId,e.accountId]),[l,u]=(0,X.useState)(c);(0,X.useEffect)(()=>u(c),[c]);let d=(0,X.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),f=l.flatMap(e=>{let t=d.get(e.providerId);return t?[{binding:e,provider:t}]:[]}),p=t.filter(e=>e.enabled&&!l.some(t=>t.providerId===e.id)),m=H(Ce(V,{activationConstraint:{distance:4}}),Ce(xe,{coordinateGetter:be})),h=r||s.isPending,g=(t,n)=>{let r=l;u(t),s.mutate({kind:e.kind,bindings:t},{onSuccess:()=>a(ft.has(e.kind)&&e.enabled?i(`clients.providersModelsSynced`,{client:J(e.kind,e.name)}):n),onError:e=>{u(r),a(I(e),`error`)}})},_=({active:e,over:t})=>{if(!t||e.id===t.id)return;let n=l.findIndex(t=>t.providerId===e.id),r=l.findIndex(e=>e.providerId===t.id);n<0||r<0||g(ve(l,n,r),i(`clients.providerOrderSaved`))},v=e=>g([...l,{providerId:e.id}],i(`clients.providerAdded`,{provider:e.name})),y=e=>g(l.filter(t=>t.providerId!==e.id),i(`clients.providerRemoved`,{provider:e.name})),b=p.map(e=>(0,Z.jsx)(D,{icon:(0,Z.jsx)(Y,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24}),label:e.name,detail:St(e,i),onClick:h?void 0:()=>v(e),children:!r&&(0,Z.jsx)(q,{className:`size-4 text-[var(--text-secondary)]`,"aria-label":i(`common.add`)})},e.id));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(M,{title:i(`clients.providerTitle`),footer:i(`clients.providerFooter`),children:[n&&(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(N,{lines:2})}),!n&&f.length===0&&p.length===0&&(0,Z.jsx)(w,{title:i(`clients.noProviders`),detail:i(`clients.noProvidersDetail`),action:(0,Z.jsx)(Oe,{to:`/providers?new=1`,children:(0,Z.jsx)(A,{variant:`primary`,icon:(0,Z.jsx)(q,{className:`size-3.5`}),children:i(`providers.add`)})})}),f.length>0&&(0,Z.jsx)(ye,{sensors:m,collisionDetection:W,onDragEnd:_,children:(0,Z.jsx)(Se,{items:f.map(e=>e.provider.id),strategy:ge,children:f.map(({provider:e},t)=>(0,Z.jsx)(wt,{provider:e,primary:t===0,disabled:h,onRemove:f.length>1?()=>y(e):void 0},e.id))})}),!n&&f.length===0&&b]}),f.length>0&&p.length>0&&(0,Z.jsx)(M,{title:i(`clients.moreProvidersTitle`),children:b})]})}function wt({provider:e,primary:t,disabled:n,onRemove:r}){let{t:i}=k(),{attributes:a,listeners:o,setNodeRef:s,setActivatorNodeRef:c,transform:l,transition:u,isDragging:d}=U({id:e.id,disabled:n});return(0,Z.jsx)(`div`,{ref:s,style:{transform:_e.Transform.toString(l),transition:u},className:E(d&&`relative z-10 bg-[var(--surface)] shadow-lg`),children:(0,Z.jsx)(D,{icon:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`button`,{ref:c,type:`button`,"aria-label":i(`clients.dragToReorder`,{provider:e.name}),title:i(`clients.dragToReorder`,{provider:e.name}),className:`-ml-1 inline-flex cursor-grab touch-none text-[var(--text-muted)] hover:text-[var(--text-secondary)] active:cursor-grabbing disabled:cursor-default disabled:opacity-50`,...a,...o,children:(0,Z.jsx)(G,{className:`size-4`})}),(0,Z.jsx)(Y,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24})]}),label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),t&&(0,Z.jsx)(O,{tone:`accent`,children:i(`clients.primaryProvider`)}),!e.enabled&&(0,Z.jsx)(O,{tone:`orange`,children:i(`clients.providerDisabledBadge`)})]}),detail:St(e,i),children:r&&(0,Z.jsx)(A,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(T,{className:`size-3.5`}),"aria-label":i(`clients.removeProvider`,{provider:e.name}),title:i(`clients.removeProvider`,{provider:e.name}),disabled:n,onClick:r})})})}function Tt({client:e,onOpen:t}){let{t:n}=k(),r=e.install;if(!r)return null;let i=r.needsAdmin?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-[var(--warning)]`,children:[(0,Z.jsx)(ze,{className:`size-3`,"aria-hidden":!0}),n(`clients.admin.badge`)]}):null,a=r.needsAdmin?n(r.adminAvailable?`clients.admin.tip`:`clients.admin.tipManual`):void 0;return r.busy?(0,Z.jsx)(A,{icon:(0,Z.jsx)(yt,{}),onClick:()=>t(`log`),children:n(`clients.installRunning`)}):r.updateAvailable&&r.updateCommand&&r.latestVersion?(0,Z.jsxs)(A,{icon:(0,Z.jsx)(Le,{className:`size-3.5`}),title:a,onClick:()=>t(`update`),children:[n(`clients.updateTo`,{version:r.latestVersion}),i]}):r.updateAvailable&&r.blocker===`shadowed`?(0,Z.jsx)(A,{icon:(0,Z.jsx)(ze,{className:`size-3.5`}),onClick:()=>document.getElementById(Et)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:n(`clients.shadowedBadge`)}):!r.installed&&r.installCommand?(0,Z.jsxs)(A,{icon:(0,Z.jsx)(pe,{className:`size-3.5`}),title:a,onClick:()=>t(`install`),children:[n(`clients.install`),i]}):!r.installed&&r.method===`manual`?(0,Z.jsx)(A,{icon:(0,Z.jsx)(me,{className:`size-3.5`}),onClick:()=>window.open(r.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.download`)}):null}var Et=`client-shadowed-alert`,Dt=`claude-direct-panel`,Ot=`client-role-map`;function kt({client:e,onShowLog:t}){let{t:n,locale:r}=k(),i=e.install,a=x(e.kind),o=(e,t=!1)=>(0,Z.jsx)(`span`,{className:E(`text-[13px] tabular-nums selectable`,t&&`text-[var(--text-secondary)]`),children:e}),s=i.blocker===`external-install`?n(`clients.blocker.external-install`,{path:i.executable??``}):i.blocker?n(`clients.blocker.${i.blocker}`):void 0,c=i.otherCopies??[],l=c.find(e=>e.newer);return(0,Z.jsxs)(Z.Fragment,{children:[l&&(0,Z.jsx)(`div`,{id:Et,className:`mb-3`,children:(0,Z.jsx)(j,{tone:`warning`,title:n(`clients.shadowed.title`,{version:l.version}),children:n(`clients.shadowed.detail`,{path:i.executable??``,version:i.version??``,other:l.path,dir:de(l.path)})})}),!l&&i.notOnPath&&i.executable&&(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(j,{tone:`warning`,title:n(`clients.notOnPath.title`),children:n(`clients.notOnPath.detail`,{dir:de(i.executable)})})}),(0,Z.jsxs)(M,{title:n(`clients.versionTitle`),footer:s,children:[(0,Z.jsx)(D,{label:n(`clients.currentVersion`),detail:i.installed?i.executable:void 0,children:i.installed?o(i.version??n(`clients.versionUnknown`),!i.version):o(n(`clients.notInstalled`),!0)}),c.map(e=>(0,Z.jsxs)(D,{label:n(`clients.otherCopy`),detail:e.path,children:[e.newer&&(0,Z.jsx)(O,{tone:`orange`,children:n(`clients.otherCopyNewer`)}),o(e.version,!e.newer)]},e.path)),(i.method===`npm`||i.method===`script`)&&(0,Z.jsxs)(D,{label:n(`clients.latestVersion`),detail:i.latestError??(i.latestCheckedAt?n(`clients.checkedAt`,{time:y(i.latestCheckedAt,r)}):void 0),children:[i.updateAvailable&&(0,Z.jsx)(O,{tone:`orange`,children:n(`clients.updateBadge`)}),o(i.latestVersion??n(`clients.latestUnknown`),!i.latestVersion)]}),(0,Z.jsx)(D,{label:n(`clients.installMethod`),detail:n(`clients.method.${i.method}`,{package:i.package??``}),children:(0,Z.jsx)(A,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(me,{className:`size-3`}),onClick:()=>window.open(i.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.homepage`)})}),a.data&&(0,Z.jsx)(D,{icon:(0,Z.jsx)(Ee,{className:`size-4 text-[var(--text-secondary)]`}),label:n(`clients.installLog`),detail:`${a.data.command} · ${n(`clients.job.${a.data.state}`)}`,onClick:t})]})]})}function At({mode:e,onClose:n,client:r}){let{t:a}=k(),{toast:o}=R(),s=le(),c=e!==null,l=x(r.kind,c||!!r.install?.busy),u=t(),d=F(),[f,p]=(0,X.useState)(!1),m=(0,X.useRef)(null),h=(0,X.useRef)(void 0),g=J(r.kind,r.name),_=r.install,v=e===`install`||e===`update`?e:null,y=v===`install`?_?.installCommand:v===`update`?_?.updateCommand:null,b=l.data,S=v!==null&&!f&&b?.state!==`running`,C=!!_?.needsAdmin,T=!!_?.adminAvailable,ee=b?.state===`failed`&&b.hint===`permission-denied`&&!b.elevated&&T;(0,X.useEffect)(()=>{c&&p(!1)},[c,e]),(0,X.useEffect)(()=>{let e=b?.state;h.current===`running`&&e&&e!==`running`&&(s.invalidateQueries({queryKey:i.clients}),e===`succeeded`&&b.hint?o(a(`clients.notEffectiveToast`,{name:g})):e===`succeeded`&&o(a(b.action===`install`?`clients.installedToast`:`clients.updatedToast`,{name:g}),`success`)),h.current=e},[b?.state,b?.action,b?.hint,g,s,a,o]),(0,X.useEffect)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[b?.log.length]);let te=(e,t)=>u.mutate({kind:r.kind,action:e,elevated:t},{onSuccess:()=>p(!0),onError:e=>o(I(e),`error`)}),ne=async e=>{await L.copy(e)&&o(a(`common.copied`))},re=a((v??b?.action)===`update`?`clients.updateTitle`:`clients.installTitle`,{name:g}),D={running:`info`,succeeded:`success`,failed:`danger`,cancelled:`warning`},ie=`rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[12px] break-all whitespace-pre-wrap selectable`,O=_?.adminFixCommand?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-secondary)]`,children:a(`clients.admin.fixTip`)}),(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`pre`,{className:E(ie,`min-w-0 flex-1`),children:_.adminFixCommand}),(0,Z.jsx)(A,{size:`sm`,icon:(0,Z.jsx)(oe,{className:`size-3`}),"aria-label":a(`common.copy`),onClick:()=>void ne(_.adminFixCommand)})]})]}):null;return(0,Z.jsx)(fe,{open:c,onOpenChange:e=>!e&&n(),width:620,title:re,description:S?a(`clients.installRunDetail`):void 0,footer:S?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{onClick:n,children:a(`common.cancel`)}),C&&!T?(0,Z.jsx)(A,{variant:`primary`,icon:(0,Z.jsx)(oe,{className:`size-3.5`}),disabled:!y,onClick:()=>void ne(`sudo ${y}`),children:a(`clients.admin.copyCommand`)}):(0,Z.jsx)(A,{variant:`primary`,icon:C?(0,Z.jsx)(ze,{className:`size-3.5`}):void 0,disabled:!y,loading:u.isPending,onClick:()=>v&&te(v,C),children:a(C?`clients.admin.start`:`clients.installStart`)})]}):b?.state===`running`?(0,Z.jsxs)(Z.Fragment,{children:[!b.elevated&&(0,Z.jsx)(A,{variant:`destructive`,loading:d.isPending,onClick:()=>d.mutate(r.kind,{onError:e=>o(I(e),`error`)}),children:a(`clients.installStop`)}),(0,Z.jsx)(A,{onClick:n,children:a(`common.close`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{onClick:n,children:a(`common.done`)}),ee&&(0,Z.jsx)(A,{variant:`primary`,icon:(0,Z.jsx)(ze,{className:`size-3.5`}),loading:u.isPending,onClick:()=>te(b.action,!0),children:a(`clients.admin.retry`)})]}),children:S?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[C&&(0,Z.jsx)(j,{tone:`warning`,title:a(`clients.admin.title`),children:a(T?`clients.admin.prompt`:`clients.admin.manual`)}),y?(0,Z.jsx)(`pre`,{className:ie,children:C?`sudo ${y}`:y}):(0,Z.jsx)(j,{tone:`warning`,title:a(`clients.installUnavailable`)}),_?.method===`npm`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`clients.installNpmNote`)}),C&&O]}):b?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(j,{tone:b.state===`succeeded`&&b.hint?`warning`:D[b.state],title:a(b.state===`succeeded`&&b.hint?`clients.job.notEffective`:`clients.job.${b.state}`),children:b.state===`running`&&b.elevated?a(`clients.admin.running`):b.hint?a(`clients.hint.${b.hint}`)+(ee?a(`clients.admin.retryHint`):``):void 0}),(0,Z.jsx)(`pre`,{ref:m,className:`scroll max-h-[340px] min-h-[160px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[11px] leading-relaxed break-all whitespace-pre-wrap selectable`,children:b.log.join(`
7
7
  `)}),b.hint===`permission-denied`&&O]}):l.isLoading?(0,Z.jsx)(N,{lines:4}):(0,Z.jsx)(w,{icon:(0,Z.jsx)(Ee,{className:`size-6`}),title:a(`clients.noInstallLog`)})})}function jt({open:e,onOpenChange:t,client:n,model:r,extras:i,tokenId:a}){let{t:o}=k(),{toast:s}=R(),c=f(),l=te(),u=J(n.kind,n.name),d=i?{providerId:n.providerId,model:r,extras:i,tokenId:a}:{providerId:n.providerId,model:r,tokenId:a};return(0,X.useEffect)(()=>{e&&c.mutate({kind:n.kind,req:d})},[e]),(0,Z.jsxs)(fe,{open:e,onOpenChange:t,width:620,title:o(`clients.enableTitle`,{name:u}),description:o(`clients.enableDetail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{onClick:()=>t(!1),children:o(`common.cancel`)}),(0,Z.jsx)(A,{variant:`primary`,disabled:!c.data,loading:l.isPending,onClick:()=>l.mutate({kind:n.kind,req:d},{onSuccess:e=>{t(!1),s(e.requiresRestart?o(`clients.enabledRestart`,{name:u}):o(`clients.enabledToast`,{name:u}),`success`)},onError:e=>s(I(e),`error`)}),children:n.enabled?o(`common.apply`):o(`clients.enable`)})]}),children:[c.isPending&&(0,Z.jsx)(N,{lines:4}),c.isError&&(0,Z.jsx)(j,{tone:`danger`,title:o(`common.error`),children:I(c.error)}),c.data&&(0,Z.jsx)(Mt,{preview:c.data})]})}function Mt({preview:e}){let{t}=k();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.warnings.map((e,t)=>(0,Z.jsx)(j,{tone:`warning`,title:e},t)),e.changes.length===0&&(0,Z.jsx)(j,{tone:`info`,title:t(`clients.noChanges`)}),e.diffs.map(e=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`mb-2 font-mono text-[11px] text-[var(--text-secondary)]`,children:e.file}),(0,Z.jsx)(Nt,{diff:e.unifiedDiff})]},e.file))]})}function Nt({diff:e}){return(0,Z.jsx)(`pre`,{className:`scroll max-h-[300px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] py-2 font-mono text-[11px] leading-relaxed selectable`,children:e.split(`
8
8
  `).map((e,t)=>(0,Z.jsx)(`div`,{className:E(`px-3 whitespace-pre-wrap break-all`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-[color-mix(in_oklab,var(--success)_12%,transparent)] text-[var(--success)]`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-[color-mix(in_oklab,var(--danger)_10%,transparent)] text-[var(--danger)]`,e.startsWith(`@@`)&&`text-[var(--text-muted)]`),children:e||` `},t))})}function Pt({open:e,onOpenChange:t,client:n}){let{t:r,locale:i}=k(),{toast:a,confirm:o}=R(),s=m(n.kind,e),c=P();return(0,Z.jsxs)(fe,{open:e,onOpenChange:t,width:520,title:r(`clients.backups`),description:r(`clients.backupsDetail`),footer:(0,Z.jsx)(A,{onClick:()=>t(!1),children:r(`common.done`)}),children:[s.isLoading&&(0,Z.jsx)(N,{lines:3}),s.isError&&(0,Z.jsx)(j,{tone:`danger`,title:r(`common.error`),children:I(s.error)}),s.data?.length===0&&(0,Z.jsx)(w,{icon:(0,Z.jsx)(Fe,{className:`size-6`}),title:r(`clients.noBackups`)}),(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:s.data?.map(e=>(0,Z.jsx)(D,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[y(e.createdAt,i),e.firstWrite&&(0,Z.jsx)(O,{tone:`accent`,children:r(`clients.firstWrite`)})]}),detail:e.files.join(`, `),children:(0,Z.jsx)(A,{size:`sm`,icon:(0,Z.jsx)(we,{className:`size-3`}),loading:c.isPending&&c.variables?.id===e.id,onClick:async()=>{await o({title:r(`clients.restoreConfirm`),detail:e.files.join(`
@@ -1 +1 @@
1
- import{Ca as e,Ea as t,J as n,K as r,Sa as i,St as a,V as o,W as s,Z as c,_ as l,bt as u,n as d,ot as f,q as p,r as m,t as h,xt as g,yt as _}from"./alert-CN1yWco4.js";import{A as v,_ as y,k as b}from"./index-CBrXkG99.js";var x=t(e(),1),S=i(),C=`astra.keyLookup`;function w(){try{return sessionStorage.getItem(C)??``}catch{return``}}function T(e){try{e?sessionStorage.setItem(C,e):sessionStorage.removeItem(C)}catch{}}function E(){let{t:e}=f(),[t,n]=(0,x.useState)(``),[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(null),[l,d]=(0,x.useState)(!1),p=(0,x.useCallback)(async t=>{let n=t.trim();if(n){d(!0),c(null);try{i(await u(n)),o(n),T(n)}catch(t){i(null),T(null),c(t instanceof _&&t.status===401?e(`key.invalid`):e(`key.error`,{error:t.message}))}finally{d(!1)}}},[e]);return(0,x.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`key`);e&&window.history.replaceState(null,``,window.location.pathname);let t=e??w();t&&(n(t),p(t))},[]),(0,S.jsx)(`div`,{className:`wallpaper flex min-h-full justify-center overflow-y-auto p-4 sm:items-start sm:py-12`,children:(0,S.jsxs)(`div`,{className:`flex w-full max-w-[720px] flex-col gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(v,{className:`size-10 rounded-[12px]`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-[17px] font-medium`,children:e(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:e(`key.subtitle`)})]})]}),!r&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p(t)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(b,{label:e(`key.title`),placeholder:e(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:t,"aria-invalid":s?!0:void 0,onChange:e=>n(e.target.value)}),s&&(0,S.jsx)(h,{tone:`danger`,title:s}),(0,S.jsx)(m,{type:`submit`,variant:`primary`,loading:l,disabled:!t.trim(),children:e(`key.submit`)})]}),r&&(0,S.jsx)(D,{info:r,apiKey:a,onForget:()=>{T(null),i(null),n(``)}})]})})}function D({info:e,apiKey:t,onForget:r}){let{t:i,locale:a}=f(),[s,u]=(0,x.useState)(`overview`),p=e.allowedClients==null?i(`key.clientsAny`):e.allowedClients.length===0?i(`key.directOnly`):e.allowedClients.map(e=>y[e]?.name??e).join(`, `),h=[[i(`key.today`),e.usage.today],[i(`key.week`),e.usage.week],[i(`key.month`),e.usage.month],[i(`key.total`),e.usage.total]],g=Math.max(...e.daily.map(e=>e.costUsd),0);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium`,children:e.name}),(0,S.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)]`,children:e.keyPrefix}),!e.enabled&&(0,S.jsx)(d,{tone:`orange`,children:i(`key.disabled`)}),(0,S.jsx)(m,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:r,children:i(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[i(`key.clients`),`: `,p,` · `,i(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(l,{ariaLabel:i(`key.title`),value:s,onChange:u,items:[{value:`overview`,label:i(`key.tab.overview`)},{value:`stats`,label:i(`key.tab.stats`)},{value:`requests`,label:i(`key.tab.requests`)}]})]}),s===`stats`&&(0,S.jsx)(k,{apiKey:t}),s===`requests`&&(0,S.jsx)(M,{apiKey:t}),s===`overview`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:i(`key.unlimited`)}),(0,S.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.limits.map(e=>{let t=t=>e.metric===`cost`?c(t):n(t,!0),r=Math.max(0,Math.min(100,Math.round(e.usedPercent))),s=r>=90?`var(--danger)`:r>=70?`var(--warning)`:`var(--accent)`,l=`${i(`tokens.period.${e.period}`)} · ${i(`tokens.metric.${e.metric}`)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[12px]`,children:[(0,S.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:l}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":l,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${r}%`,background:s}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?i(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?i(`key.resets`,{time:o(e.resetsAt,a)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:i(`key.rpm`,{used:e.rpm.used,limit:e.rpm.limit})})]}),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.usage`)}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:h.map(([e,t])=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`py-1 text-left font-medium text-[var(--text-secondary)]`,children:e}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:c(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:n(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:n(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:i(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":i(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${c(e.costUsd)} · ${n(e.requests)} ${i(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${g>0?Math.max(2,e.costUsd/g*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=f(),[i,o]=(0,x.useState)(`7d`),[u,p]=(0,x.useState)(null),[m,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return g(null),a(e,i).then(e=>n&&p(e),e=>n&&g(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,i,t]);let _=u?.summary,v=Math.max(...(u?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(l,{ariaLabel:t(`overview.range`),value:i,onChange:o,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),m&&(0,S.jsx)(h,{tone:`danger`,title:m}),!u||!_?!m&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:`…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsx)(A,{label:t(`key.stats.requests`),value:n(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?r(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:c(_.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:s(_.avgTtftMs)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.trend`)}),(0,S.jsx)(`div`,{className:`flex h-20 items-end gap-[2px]`,role:`list`,"aria-label":t(`key.stats.trend`),children:u.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${n(e.requests)} ${t(`key.requests`)} · ${c(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${v>0?Math.max(2,e.requests/v*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:t(`key.stats.byModel`),rows:u.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:u.clients.map(e=>({name:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`),...e}))}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.errors`)}),u.errors.length===0?(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`key.stats.noErrors`)}):(0,S.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:u.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(d,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,n(e.count)]})},e.category))})]}),u.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:u.retentionDays})})]})]})}function A({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`div`,{className:`num truncate text-[17px] font-semibold`,children:t})]})}function j({title:e,rows:t}){let{t:i}=f();return t.length===0?null:(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`caption`,{className:`mb-1 text-left text-[12px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.cost`)})]})}),(0,S.jsx)(`tbody`,{children:t.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`max-w-[240px] truncate py-1 text-left font-medium text-[var(--text-secondary)]`,children:e.name}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:n(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?r(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:n(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:c(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:r}=f(),[i,a]=(0,x.useState)(`all`),[u,_]=(0,x.useState)([]),[v,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),D=(0,x.useCallback)(async n=>{w(!0),E(null);try{let t=await g(e,{before:n,status:i===`failed`?N:void 0});_(e=>n?[...e,...t.items]:t.items),b(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,i,t]);return(0,x.useEffect)(()=>{D(null)},[D]),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(l,{ariaLabel:t(`key.requests.status`),value:i,onChange:a,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(h,{tone:`danger`,title:T}),u.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),u.length>0&&(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.time`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.model`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.client`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.status`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.latency`)})]})}),(0,S.jsx)(`tbody`,{children:u.map(e=>(0,S.jsxs)(`tr`,{className:`border-t border-[var(--border-subtle)]`,children:[(0,S.jsx)(`td`,{className:`py-1.5 whitespace-nowrap text-[var(--text-secondary)]`,title:o(e.time,r),children:p(e.time,r)}),(0,S.jsx)(`td`,{className:`max-w-[200px] truncate py-1.5 font-mono`,title:e.model??``,children:e.model??`—`}),(0,S.jsx)(`td`,{className:`py-1.5 text-[var(--text-secondary)]`,children:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(d,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(d,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[n(e.inputTokens,!0),` / `,n(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:c(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[s(e.ttftMs),` / `,s(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(m,{size:`sm`,loading:C,onClick:()=>void D(v),children:t(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
1
+ import{Ca as e,Ea as t,J as n,K as r,Sa as i,St as a,V as o,W as s,Z as c,_ as l,bt as u,n as d,ot as f,q as p,r as m,t as h,xt as g,yt as _}from"./alert-BzjF81CS.js";import{A as v,_ as y,k as b}from"./index-D7HIE1TG.js";var x=t(e(),1),S=i(),C=`astra.keyLookup`;function w(){try{return sessionStorage.getItem(C)??``}catch{return``}}function T(e){try{e?sessionStorage.setItem(C,e):sessionStorage.removeItem(C)}catch{}}function E(){let{t:e}=f(),[t,n]=(0,x.useState)(``),[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(null),[l,d]=(0,x.useState)(!1),p=(0,x.useCallback)(async t=>{let n=t.trim();if(n){d(!0),c(null);try{i(await u(n)),o(n),T(n)}catch(t){i(null),T(null),c(t instanceof _&&t.status===401?e(`key.invalid`):e(`key.error`,{error:t.message}))}finally{d(!1)}}},[e]);return(0,x.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`key`);e&&window.history.replaceState(null,``,window.location.pathname);let t=e??w();t&&(n(t),p(t))},[]),(0,S.jsx)(`div`,{className:`wallpaper flex min-h-full justify-center overflow-y-auto p-4 sm:items-start sm:py-12`,children:(0,S.jsxs)(`div`,{className:`flex w-full max-w-[720px] flex-col gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(v,{className:`size-10 rounded-[12px]`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-[17px] font-medium`,children:e(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:e(`key.subtitle`)})]})]}),!r&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p(t)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(b,{label:e(`key.title`),placeholder:e(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:t,"aria-invalid":s?!0:void 0,onChange:e=>n(e.target.value)}),s&&(0,S.jsx)(h,{tone:`danger`,title:s}),(0,S.jsx)(m,{type:`submit`,variant:`primary`,loading:l,disabled:!t.trim(),children:e(`key.submit`)})]}),r&&(0,S.jsx)(D,{info:r,apiKey:a,onForget:()=>{T(null),i(null),n(``)}})]})})}function D({info:e,apiKey:t,onForget:r}){let{t:i,locale:a}=f(),[s,u]=(0,x.useState)(`overview`),p=e.allowedClients==null?i(`key.clientsAny`):e.allowedClients.length===0?i(`key.directOnly`):e.allowedClients.map(e=>y[e]?.name??e).join(`, `),h=[[i(`key.today`),e.usage.today],[i(`key.week`),e.usage.week],[i(`key.month`),e.usage.month],[i(`key.total`),e.usage.total]],g=Math.max(...e.daily.map(e=>e.costUsd),0);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium`,children:e.name}),(0,S.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)]`,children:e.keyPrefix}),!e.enabled&&(0,S.jsx)(d,{tone:`orange`,children:i(`key.disabled`)}),(0,S.jsx)(m,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:r,children:i(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[i(`key.clients`),`: `,p,` · `,i(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(l,{ariaLabel:i(`key.title`),value:s,onChange:u,items:[{value:`overview`,label:i(`key.tab.overview`)},{value:`stats`,label:i(`key.tab.stats`)},{value:`requests`,label:i(`key.tab.requests`)}]})]}),s===`stats`&&(0,S.jsx)(k,{apiKey:t}),s===`requests`&&(0,S.jsx)(M,{apiKey:t}),s===`overview`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:i(`key.unlimited`)}),(0,S.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.limits.map(e=>{let t=t=>e.metric===`cost`?c(t):n(t,!0),r=Math.max(0,Math.min(100,Math.round(e.usedPercent))),s=r>=90?`var(--danger)`:r>=70?`var(--warning)`:`var(--accent)`,l=`${i(`tokens.period.${e.period}`)} · ${i(`tokens.metric.${e.metric}`)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[12px]`,children:[(0,S.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:l}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":l,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${r}%`,background:s}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?i(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?i(`key.resets`,{time:o(e.resetsAt,a)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:i(`key.rpm`,{used:e.rpm.used,limit:e.rpm.limit})})]}),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.usage`)}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:h.map(([e,t])=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`py-1 text-left font-medium text-[var(--text-secondary)]`,children:e}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:c(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:n(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:n(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:i(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":i(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${c(e.costUsd)} · ${n(e.requests)} ${i(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${g>0?Math.max(2,e.costUsd/g*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=f(),[i,o]=(0,x.useState)(`7d`),[u,p]=(0,x.useState)(null),[m,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return g(null),a(e,i).then(e=>n&&p(e),e=>n&&g(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,i,t]);let _=u?.summary,v=Math.max(...(u?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(l,{ariaLabel:t(`overview.range`),value:i,onChange:o,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),m&&(0,S.jsx)(h,{tone:`danger`,title:m}),!u||!_?!m&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:`…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsx)(A,{label:t(`key.stats.requests`),value:n(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?r(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:c(_.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:s(_.avgTtftMs)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.trend`)}),(0,S.jsx)(`div`,{className:`flex h-20 items-end gap-[2px]`,role:`list`,"aria-label":t(`key.stats.trend`),children:u.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${n(e.requests)} ${t(`key.requests`)} · ${c(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${v>0?Math.max(2,e.requests/v*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:t(`key.stats.byModel`),rows:u.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:u.clients.map(e=>({name:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`),...e}))}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.errors`)}),u.errors.length===0?(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`key.stats.noErrors`)}):(0,S.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:u.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(d,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,n(e.count)]})},e.category))})]}),u.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:u.retentionDays})})]})]})}function A({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`div`,{className:`num truncate text-[17px] font-semibold`,children:t})]})}function j({title:e,rows:t}){let{t:i}=f();return t.length===0?null:(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`caption`,{className:`mb-1 text-left text-[12px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.cost`)})]})}),(0,S.jsx)(`tbody`,{children:t.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`max-w-[240px] truncate py-1 text-left font-medium text-[var(--text-secondary)]`,children:e.name}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:n(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?r(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:n(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:c(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:r}=f(),[i,a]=(0,x.useState)(`all`),[u,_]=(0,x.useState)([]),[v,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),D=(0,x.useCallback)(async n=>{w(!0),E(null);try{let t=await g(e,{before:n,status:i===`failed`?N:void 0});_(e=>n?[...e,...t.items]:t.items),b(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,i,t]);return(0,x.useEffect)(()=>{D(null)},[D]),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(l,{ariaLabel:t(`key.requests.status`),value:i,onChange:a,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(h,{tone:`danger`,title:T}),u.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),u.length>0&&(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.time`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.model`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.client`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.status`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.latency`)})]})}),(0,S.jsx)(`tbody`,{children:u.map(e=>(0,S.jsxs)(`tr`,{className:`border-t border-[var(--border-subtle)]`,children:[(0,S.jsx)(`td`,{className:`py-1.5 whitespace-nowrap text-[var(--text-secondary)]`,title:o(e.time,r),children:p(e.time,r)}),(0,S.jsx)(`td`,{className:`max-w-[200px] truncate py-1.5 font-mono`,title:e.model??``,children:e.model??`—`}),(0,S.jsx)(`td`,{className:`py-1.5 text-[var(--text-secondary)]`,children:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(d,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(d,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[n(e.inputTokens,!0),` / `,n(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:c(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[s(e.ttftMs),` / `,s(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(m,{size:`sm`,loading:C,onClick:()=>void D(v),children:t(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
@@ -1 +1 @@
1
- import{Ca as e,Ea as t,Sa as n,V as r,d as i,ei as a,fi as o,g as s,gr as c,kn as l,l as u,m as d,n as f,nn as p,nt as m,ot as h,p as g,qn as _,r as v,t as y,tn as b,u as x,v as S,y as C}from"./alert-CN1yWco4.js";import{a as w,i as T,o as E,r as D}from"./overlays-D2pWmtov.js";import{t as O}from"./arrow-left-UUQiUGQ1.js";import{t as k}from"./pencil-DuD1bQje.js";import{t as A}from"./rotate-ccw-Cx9vNOkF.js";import{N as j,Q as M,R as N,Y as ee,Z as te,h as P,i as ne,o as F}from"./index-CBrXkG99.js";import{t as I}from"./checkbox-BEWRhO5r.js";import{t as L}from"./confirm-morph-DwiVsert.js";var R=t(e(),1),z=n(),B=[{key:`vision`,label:`cap.vision`},{key:`tools`,label:`cap.tools`},{key:`reasoning`,label:`cap.reasoning`},{key:`promptCache`,label:`cap.promptCache`},{key:`audio`,label:`cap.audio`},{key:`pdf`,label:`cap.pdf`},{key:`structuredOutput`,label:`cap.structuredOutput`}];function V(e){return{displayName:e.displayName,vendor:e.vendor,family:e.family??null,aliases:e.aliases,contextWindow:e.contextWindow??null,maxOutputTokens:e.maxOutputTokens??null,capabilities:e.capabilities,pricing:e.pricing??null,enabled:e.enabled}}function H(){let{t:e,locale:t}=h(),n=te(),{id:o=``}=M(),u=decodeURIComponent(o),p=l(u),_=a(u),T=c(u),D=b(),{toast:k}=E(),j=(0,R.useMemo)(()=>p.data?V(p.data):null,[p.data]),[N,L]=(0,R.useState)(j),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(j),G(j?.aliases?.join(`, `)??``)},[j]);let q=(0,z.jsx)(v,{variant:`glass`,icon:(0,z.jsx)(O,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>n(`/models`)});if(p.isError)return(0,z.jsx)(P,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(y,{tone:`danger`,title:e(`common.error`),children:w(p.error)})});let J=p.data;if(!J||!N)return(0,z.jsx)(P,{title:``,leading:q,children:(0,z.jsx)(S,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...N,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(j),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>_.mutate(X,{onSuccess:()=>k(e(`common.saved`),`success`),onError:e=>k(w(e),`error`)}),$=t=>re.has(t)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(f,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(A,{className:`size-3`}),title:e(`models.resetField`),"aria-label":e(`models.resetField`),onClick:()=>T.mutate(t,{onSuccess:()=>k(e(`models.fieldReset`)),onError:e=>k(w(e),`error`)})})]}):null;return(0,z.jsx)(P,{title:J.displayName,subtitle:`${J.id} · ${e(`models.source.${J.source}`)} · ${e(`models.updated`,{time:r(J.updatedAt,t)})}`,leading:q,actions:(0,z.jsxs)(z.Fragment,{children:[J.source===`user`&&(0,z.jsx)(K,{label:e(`common.delete`),prompt:e(`models.deleteConfirm`,{id:J.id}),onConfirm:async()=>{await D.mutateAsync(J.id),n(`/models`)}}),Z&&(0,z.jsx)(v,{onClick:()=>{L(j),G(j?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(v,{variant:`primary`,disabled:!Z,loading:_.isPending,onClick:ie,children:e(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`mx-auto grid max-w-[1100px] gap-x-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(x,{title:e(`models.section.basic`),footer:Q?e(`models.modifiedFooter`):void 0,children:[(0,z.jsx)(U,{label:e(`models.field.displayName`),marker:$(`displayName`),children:(0,z.jsx)(i,{className:`w-60`,"aria-label":e(`models.field.displayName`),value:N.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.vendor`),children:(0,z.jsx)(i,{className:`w-60`,"aria-label":e(`models.field.vendor`),value:N.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(i,{className:`w-60`,"aria-label":e(`models.field.family`),value:N.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:e(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(i,{className:`w-60 font-mono`,"aria-label":e(`models.field.aliases`),value:H,onChange:e=>G(e.target.value),placeholder:`a, b, c`})}),(0,z.jsx)(U,{label:e(`models.field.contextWindow`),marker:$(`contextWindow`),children:(0,z.jsx)(g,{className:`w-36`,label:e(`models.field.contextWindow`),value:N.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:e(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(g,{className:`w-36`,label:e(`models.field.maxOutputTokens`),value:N.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:e(`common.enabled`),children:(0,z.jsx)(C,{checked:N.enabled??!0,label:e(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(x,{title:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e(`models.section.capabilities`),` `,$(`capabilities`)]}),children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 px-4 py-4`,children:B.map(t=>(0,z.jsx)(I,{label:e(t.label),checked:!!N.capabilities?.[t.key],onCheckedChange:e=>Y({capabilities:{...N.capabilities,[t.key]:e===!0}})},t.key))})}),(0,z.jsx)(W,{model:J}),J.providerOverrides.length>0&&(0,z.jsx)(x,{title:e(`models.section.overrides`),footer:e(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(d,{label:(0,z.jsx)(ee,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${m(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(s,{action:$(`pricing`),children:e(`models.section.pricing`)}),(0,z.jsx)(`p`,{className:`mb-3 px-1 text-[12px] text-[var(--text-secondary)]`,children:e(`models.pricingHint`)}),(0,z.jsx)(`div`,{className:`card p-4`,children:(0,z.jsx)(F,{value:N.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(s,{children:e(`models.section.simulator`)}),(0,z.jsxs)(`div`,{className:`card p-4`,children:[(0,z.jsx)(ne,{modelId:Z?void 0:J.id,pricing:Z?X.pricing:null}),Z&&(0,z.jsx)(`p`,{className:`mt-3 text-[12px] text-[var(--text-muted)]`,children:e(`models.simulatorUnsaved`)})]})]})]})]})})}function U({label:e,marker:t,children:n}){return(0,z.jsx)(d,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=h(),n=p(e.id),[r,i]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(x,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(N,{className:`size-3.5`}),onClick:()=>i(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(d,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(d,{label:(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:e.priceKey}),e.userModified&&(0,z.jsx)(f,{tone:`orange`,children:t(`models.modified`)})]}),detail:[m(e.pricing),e.upstreamModelId,e.pricing.time_windows?.length?t(`models.hasTimeWindows`):null,e.pricing.context_tiers?.length?t(`models.hasTiers`):null].filter(Boolean).join(` · `),children:[(0,z.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{className:`size-3.5`}),"aria-label":t(`common.edit`),onClick:()=>i(e)}),(0,z.jsx)(K,{label:t(`common.delete`),prompt:t(`models.deletePrice`,{key:e.priceKey}),onConfirm:()=>n.mutateAsync(e.priceKey)})]},e.priceKey))]}),(0,z.jsx)(G,{model:e,editing:r,onClose:()=>i(null)})]})}function G({model:e,editing:t,onClose:n}){let{t:r}=h(),{toast:a}=E(),s=_(),c=o(e.id),l=t===`new`,[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(``),[g,y]=(0,R.useState)(null);(0,R.useEffect)(()=>{t&&(t===`new`?(f(``),m(``),y(e.pricing?structuredClone(e.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(f(t.priceKey),m(t.upstreamModelId??``),y(structuredClone(t.pricing))))},[t,e.pricing]);let b=new Set(e.providerPrices.map(e=>e.priceKey));return(0,z.jsx)(T,{open:t!==null,onOpenChange:e=>!e&&n(),width:680,title:l?r(`models.addPrice`):r(`models.editPrice`,{key:d}),description:r(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(v,{onClick:n,children:r(`common.cancel`)}),(0,z.jsx)(v,{variant:`primary`,disabled:!d||!g,loading:c.isPending,onClick:()=>c.mutate({priceKey:d,upstreamModelId:p||null,pricing:g},{onSuccess:()=>{a(r(`common.saved`),`success`),n()},onError:e=>a(w(e),`error`)}),children:r(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,z.jsx)(u,{label:r(`providers.priceKey`),children:l?(0,z.jsx)(D,{value:d,onChange:f,placeholder:r(`models.pickPriceKey`),options:(s.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:b.has(e.priceKey)}))}):(0,z.jsx)(i,{value:d,disabled:!0,className:`font-mono`})}),(0,z.jsx)(u,{label:r(`models.upstreamId`),hint:r(`models.upstreamIdHint`),children:(0,z.jsx)(i,{className:`font-mono`,value:p,onChange:e=>m(e.target.value),placeholder:e.id})})]}),l&&(0,z.jsx)(i,{className:`font-mono`,"aria-label":r(`models.customPriceKey`),placeholder:r(`models.customPriceKey`),value:d,onChange:e=>f(e.target.value.trim())}),(0,z.jsx)(F,{value:g,onChange:y})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:r}=h();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(j,{className:`size-4`}),prompt:t,confirmLabel:r(`common.delete`),cancelLabel:r(`common.cancel`),pendingLabel:r(`common.deleting`),doneLabel:r(`common.deleted`),errorLabel:r(`common.error`),retryLabel:r(`common.retry`),onConfirm:n})}export{H as ModelDetailPage};
1
+ import{Ca as e,Ea as t,Sa as n,V as r,d as i,ei as a,fi as o,g as s,gr as c,kn as l,l as u,m as d,n as f,nn as p,nt as m,ot as h,p as g,qn as _,r as v,t as y,tn as b,u as x,v as S,y as C}from"./alert-BzjF81CS.js";import{a as w,i as T,o as E,r as D}from"./overlays-8ByMRpma.js";import{t as O}from"./arrow-left-Bv8IR_At.js";import{t as k}from"./pencil-o6T1_skE.js";import{t as A}from"./rotate-ccw-CqwU1cME.js";import{N as j,Q as M,R as N,Y as ee,Z as te,h as P,i as ne,o as F}from"./index-D7HIE1TG.js";import{t as I}from"./checkbox-DQpzihMp.js";import{t as L}from"./confirm-morph-BOdW6fKN.js";var R=t(e(),1),z=n(),B=[{key:`vision`,label:`cap.vision`},{key:`tools`,label:`cap.tools`},{key:`reasoning`,label:`cap.reasoning`},{key:`promptCache`,label:`cap.promptCache`},{key:`audio`,label:`cap.audio`},{key:`pdf`,label:`cap.pdf`},{key:`structuredOutput`,label:`cap.structuredOutput`}];function V(e){return{displayName:e.displayName,vendor:e.vendor,family:e.family??null,aliases:e.aliases,contextWindow:e.contextWindow??null,maxOutputTokens:e.maxOutputTokens??null,capabilities:e.capabilities,pricing:e.pricing??null,enabled:e.enabled}}function H(){let{t:e,locale:t}=h(),n=te(),{id:o=``}=M(),u=decodeURIComponent(o),p=l(u),_=a(u),T=c(u),D=b(),{toast:k}=E(),j=(0,R.useMemo)(()=>p.data?V(p.data):null,[p.data]),[N,L]=(0,R.useState)(j),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(j),G(j?.aliases?.join(`, `)??``)},[j]);let q=(0,z.jsx)(v,{variant:`glass`,icon:(0,z.jsx)(O,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>n(`/models`)});if(p.isError)return(0,z.jsx)(P,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(y,{tone:`danger`,title:e(`common.error`),children:w(p.error)})});let J=p.data;if(!J||!N)return(0,z.jsx)(P,{title:``,leading:q,children:(0,z.jsx)(S,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...N,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(j),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>_.mutate(X,{onSuccess:()=>k(e(`common.saved`),`success`),onError:e=>k(w(e),`error`)}),$=t=>re.has(t)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(f,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(A,{className:`size-3`}),title:e(`models.resetField`),"aria-label":e(`models.resetField`),onClick:()=>T.mutate(t,{onSuccess:()=>k(e(`models.fieldReset`)),onError:e=>k(w(e),`error`)})})]}):null;return(0,z.jsx)(P,{title:J.displayName,subtitle:`${J.id} · ${e(`models.source.${J.source}`)} · ${e(`models.updated`,{time:r(J.updatedAt,t)})}`,leading:q,actions:(0,z.jsxs)(z.Fragment,{children:[J.source===`user`&&(0,z.jsx)(K,{label:e(`common.delete`),prompt:e(`models.deleteConfirm`,{id:J.id}),onConfirm:async()=>{await D.mutateAsync(J.id),n(`/models`)}}),Z&&(0,z.jsx)(v,{onClick:()=>{L(j),G(j?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(v,{variant:`primary`,disabled:!Z,loading:_.isPending,onClick:ie,children:e(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`mx-auto grid max-w-[1100px] gap-x-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(x,{title:e(`models.section.basic`),footer:Q?e(`models.modifiedFooter`):void 0,children:[(0,z.jsx)(U,{label:e(`models.field.displayName`),marker:$(`displayName`),children:(0,z.jsx)(i,{className:`w-60`,"aria-label":e(`models.field.displayName`),value:N.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.vendor`),children:(0,z.jsx)(i,{className:`w-60`,"aria-label":e(`models.field.vendor`),value:N.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(i,{className:`w-60`,"aria-label":e(`models.field.family`),value:N.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:e(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(i,{className:`w-60 font-mono`,"aria-label":e(`models.field.aliases`),value:H,onChange:e=>G(e.target.value),placeholder:`a, b, c`})}),(0,z.jsx)(U,{label:e(`models.field.contextWindow`),marker:$(`contextWindow`),children:(0,z.jsx)(g,{className:`w-36`,label:e(`models.field.contextWindow`),value:N.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:e(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(g,{className:`w-36`,label:e(`models.field.maxOutputTokens`),value:N.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:e(`common.enabled`),children:(0,z.jsx)(C,{checked:N.enabled??!0,label:e(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(x,{title:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e(`models.section.capabilities`),` `,$(`capabilities`)]}),children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 px-4 py-4`,children:B.map(t=>(0,z.jsx)(I,{label:e(t.label),checked:!!N.capabilities?.[t.key],onCheckedChange:e=>Y({capabilities:{...N.capabilities,[t.key]:e===!0}})},t.key))})}),(0,z.jsx)(W,{model:J}),J.providerOverrides.length>0&&(0,z.jsx)(x,{title:e(`models.section.overrides`),footer:e(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(d,{label:(0,z.jsx)(ee,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${m(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(s,{action:$(`pricing`),children:e(`models.section.pricing`)}),(0,z.jsx)(`p`,{className:`mb-3 px-1 text-[12px] text-[var(--text-secondary)]`,children:e(`models.pricingHint`)}),(0,z.jsx)(`div`,{className:`card p-4`,children:(0,z.jsx)(F,{value:N.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(s,{children:e(`models.section.simulator`)}),(0,z.jsxs)(`div`,{className:`card p-4`,children:[(0,z.jsx)(ne,{modelId:Z?void 0:J.id,pricing:Z?X.pricing:null}),Z&&(0,z.jsx)(`p`,{className:`mt-3 text-[12px] text-[var(--text-muted)]`,children:e(`models.simulatorUnsaved`)})]})]})]})]})})}function U({label:e,marker:t,children:n}){return(0,z.jsx)(d,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=h(),n=p(e.id),[r,i]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(x,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(N,{className:`size-3.5`}),onClick:()=>i(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(d,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(d,{label:(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:e.priceKey}),e.userModified&&(0,z.jsx)(f,{tone:`orange`,children:t(`models.modified`)})]}),detail:[m(e.pricing),e.upstreamModelId,e.pricing.time_windows?.length?t(`models.hasTimeWindows`):null,e.pricing.context_tiers?.length?t(`models.hasTiers`):null].filter(Boolean).join(` · `),children:[(0,z.jsx)(v,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{className:`size-3.5`}),"aria-label":t(`common.edit`),onClick:()=>i(e)}),(0,z.jsx)(K,{label:t(`common.delete`),prompt:t(`models.deletePrice`,{key:e.priceKey}),onConfirm:()=>n.mutateAsync(e.priceKey)})]},e.priceKey))]}),(0,z.jsx)(G,{model:e,editing:r,onClose:()=>i(null)})]})}function G({model:e,editing:t,onClose:n}){let{t:r}=h(),{toast:a}=E(),s=_(),c=o(e.id),l=t===`new`,[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(``),[g,y]=(0,R.useState)(null);(0,R.useEffect)(()=>{t&&(t===`new`?(f(``),m(``),y(e.pricing?structuredClone(e.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(f(t.priceKey),m(t.upstreamModelId??``),y(structuredClone(t.pricing))))},[t,e.pricing]);let b=new Set(e.providerPrices.map(e=>e.priceKey));return(0,z.jsx)(T,{open:t!==null,onOpenChange:e=>!e&&n(),width:680,title:l?r(`models.addPrice`):r(`models.editPrice`,{key:d}),description:r(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(v,{onClick:n,children:r(`common.cancel`)}),(0,z.jsx)(v,{variant:`primary`,disabled:!d||!g,loading:c.isPending,onClick:()=>c.mutate({priceKey:d,upstreamModelId:p||null,pricing:g},{onSuccess:()=>{a(r(`common.saved`),`success`),n()},onError:e=>a(w(e),`error`)}),children:r(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,z.jsx)(u,{label:r(`providers.priceKey`),children:l?(0,z.jsx)(D,{value:d,onChange:f,placeholder:r(`models.pickPriceKey`),options:(s.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:b.has(e.priceKey)}))}):(0,z.jsx)(i,{value:d,disabled:!0,className:`font-mono`})}),(0,z.jsx)(u,{label:r(`models.upstreamId`),hint:r(`models.upstreamIdHint`),children:(0,z.jsx)(i,{className:`font-mono`,value:p,onChange:e=>m(e.target.value),placeholder:e.id})})]}),l&&(0,z.jsx)(i,{className:`font-mono`,"aria-label":r(`models.customPriceKey`),placeholder:r(`models.customPriceKey`),value:d,onChange:e=>f(e.target.value.trim())}),(0,z.jsx)(F,{value:g,onChange:y})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:r}=h();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(j,{className:`size-4`}),prompt:t,confirmLabel:r(`common.delete`),cancelLabel:r(`common.cancel`),pendingLabel:r(`common.deleting`),doneLabel:r(`common.deleted`),errorLabel:r(`common.error`),retryLabel:r(`common.retry`),onConfirm:n})}export{H as ModelDetailPage};
@@ -1 +1 @@
1
- import{An as e,B as t,Ca as n,Ea as r,Ir as i,Lr as a,Sa as o,X as s,Xt as c,c as l,d as u,h as d,it as f,l as p,n as m,ot as h,p as g,r as _,t as v,tt as y,v as b}from"./alert-CN1yWco4.js";import{a as x,i as S,o as C,r as w}from"./overlays-D2pWmtov.js";import{t as T}from"./cloud-download-DebyBXx2.js";import{D as E,M as D,R as O,U as k,V as A,Z as j,h as M,j as N}from"./index-CBrXkG99.js";import{t as P}from"./checkbox-BEWRhO5r.js";var F=r(n(),1),I=o();function L(){let{t}=h(),n=j(),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(!1),[u,f]=(0,F.useState)(!1),p=(0,F.useRef)(null),m=D(r),g=e(),y=e(m,a),S=(0,F.useMemo)(()=>[...new Set((g.data??[]).map(e=>e.vendor))].sort(),[g.data]);return N(e=>{e===`find`&&p.current?.focus()}),(0,I.jsxs)(M,{title:t(`nav.models`),subtitle:y.data?t(`models.count`,{count:y.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{inputRef:p,className:`w-52`,value:r,onChange:i,placeholder:t(`models.search`)}),(0,I.jsx)(w,{value:a,onChange:o,options:[{value:``,label:t(`models.allVendors`)},...S.map(e=>({value:e,label:e}))]}),(0,I.jsx)(_,{icon:(0,I.jsx)(T,{className:`size-3.5`}),onClick:()=>f(!0),children:t(`models.sync`)}),(0,I.jsx)(_,{variant:`primary`,icon:(0,I.jsx)(O,{className:`size-3.5`}),onClick:()=>c(!0),children:t(`models.new`)})]}),children:[y.isLoading&&(0,I.jsx)(b,{lines:5}),y.isError&&(0,I.jsx)(v,{tone:`danger`,title:t(`common.error`),children:x(y.error)}),y.data?.length===0&&(0,I.jsx)(l,{icon:(0,I.jsx)(k,{className:`size-6`}),title:t(`models.empty`)}),y.data&&y.data.length>0&&(0,I.jsx)(E,{caption:t(`nav.models`),rowKey:`id`,rows:y.data.map(e=>({id:e.id,name:e.displayName,vendor:e.vendor,context:e.contextWindow??0,input:e.pricing?.base.input??0,providerPrices:e.providerPriceKeys.length,m:e})),columns:R(t,e=>n(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:s,onOpenChange:c,onCreated:e=>n(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:u,onOpenChange:f})]})}function R(e,n){return[{key:`name`,label:e(`models.col.model`),render:(t,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>n(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:f(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(m,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(m,{tone:`orange`,children:e(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:r.id})]})},{key:`vendor`,label:e(`models.col.vendor`),width:120},{key:`context`,label:e(`models.col.context`),numeric:!0,width:96,render:(e,n)=>t(n.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${s(n.input)} / ${s(n.output)}`:`—`}},{key:`providerPrices`,label:e(`models.col.providerPrices`),numeric:!0,width:130,render:(t,n)=>n.providerPrices?e(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:e,onOpenChange:t,onCreated:n}){let{t:r}=h(),{toast:i}=C(),a=c(),[o,s]=(0,F.useState)(``),[l,d]=(0,F.useState)(``),[f,m]=(0,F.useState)(``),[v,y]=(0,F.useState)(null),[b,w]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(S,{open:e,onOpenChange:t,title:r(`models.new`),description:r(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(_,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(_,{variant:`primary`,disabled:!o.trim()||!f.trim(),loading:a.isPending,onClick:()=>a.mutate({id:o.trim(),displayName:l.trim()||o.trim(),vendor:f.trim(),contextWindow:v,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{t(!1),s(``),d(``),n(e.id)},onError:e=>i(x(e),`error`)}),children:r(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(p,{label:r(`models.field.id`),hint:r(`models.field.idHint`),children:(0,I.jsx)(u,{className:`font-mono`,value:o,onChange:e=>s(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(p,{label:r(`models.field.displayName`),children:(0,I.jsx)(u,{value:l,onChange:e=>d(e.target.value)})}),(0,I.jsx)(p,{label:r(`models.field.vendor`),children:(0,I.jsx)(u,{value:f,onChange:e=>m(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(p,{label:r(`models.field.contextWindow`),children:(0,I.jsx)(g,{value:v,onChange:y})}),(0,I.jsx)(p,{label:r(`models.field.inputPrice`),children:(0,I.jsx)(g,{value:b,onChange:w})}),(0,I.jsx)(p,{label:r(`models.field.outputPrice`),children:(0,I.jsx)(g,{value:T,onChange:E})})]})]})})}var B=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V(e,t=``,n=new Map){if(B(e)&&Object.keys(e).length>0)for(let[r,i]of Object.entries(e))V(i,t?`${t}.${r}`:r,n);else e!=null&&n.set(t,e);return n}function H(e,t){let n=V(e),r=V(t);return[...r.keys(),...[...n.keys()].filter(e=>!r.has(e))].filter(e=>JSON.stringify(n.get(e))!==JSON.stringify(r.get(e))).map(e=>({path:e.replace(/^pricing\./,``),before:n.get(e),after:r.get(e)}))}var U=e=>typeof e==`string`?e:JSON.stringify(e),W=4;function G({before:e,after:t}){let{t:n}=h(),r=H(e,t),i=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${y(e)||`∅`}\n→\n${y(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),i>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:i})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:i}=h(),[a,o]=(0,F.useState)(new Set),s=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),c=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},l=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},u=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),d=e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(m,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(m,{tone:`orange`,children:i(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),p=e.map(e=>e.id);return(0,I.jsx)(`div`,{className:`card max-h-[520px] overflow-auto`,children:(0,I.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,I.jsxs)(`li`,{className:`sticky top-0 z-10 flex items-center gap-3 bg-[var(--surface)] px-4 py-2`,children:[(0,I.jsx)(P,{checked:c(p),onCheckedChange:e=>l(p,e!==!1),"aria-label":i(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.selectedOf`,{n:n.size,total:p.length,models:s.length})})]}),s.map(([e,r])=>{let o=r.map(e=>e.id),s=r.length===1?r[0]:void 0,p=!a.has(e);return(0,I.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:c(o),onCheckedChange:e=>l(o,e!==!1),"aria-label":e,className:`mt-0.5`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[s?(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}):(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1 text-left`,"aria-expanded":p,onClick:()=>u(e),children:[(0,I.jsx)(A,{className:f(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,p&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.groupCount`,{n:r.length})})]}),s&&d(s)]})]}),!s&&p&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:r.map(r=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:n.has(r.id),onCheckedChange:e=>l([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),d(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:n}=h(),{toast:r}=C(),o=a(),s=i(),[c,l]=(0,F.useState)(new Set),u=()=>o.mutate(void 0,{onSuccess:e=>l(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),d=o.data?.changes??[];return(0,I.jsxs)(S,{open:e,onOpenChange:e=>{t(e),e&&!o.data&&u()},width:720,title:n(`models.sync`),description:n(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(_,{className:`mr-auto`,variant:`plain`,onClick:u,loading:o.isPending,children:n(`common.refresh`)}),(0,I.jsx)(_,{onClick:()=>t(!1),children:n(`common.cancel`)}),(0,I.jsx)(_,{variant:`primary`,disabled:c.size===0,loading:s.isPending,onClick:()=>s.mutate([...c],{onSuccess:e=>{r(n(`models.sync.applied`,{count:e.applied}),`success`),t(!1),o.reset()},onError:e=>r(x(e),`error`)}),children:n(`models.sync.apply`,{count:c.size})})]}),children:[e&&!o.data&&!o.isPending&&!o.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(_,{variant:`primary`,onClick:u,children:n(`models.sync.check`)})}),o.isPending&&(0,I.jsx)(b,{lines:4}),o.isError&&(0,I.jsx)(v,{tone:`danger`,title:n(`common.error`),children:x(o.error)}),o.data&&d.length===0&&(0,I.jsx)(v,{tone:`success`,title:n(`models.sync.none`)}),d.length>0&&(0,I.jsx)(K,{changes:d,label:e=>e.kind===`new_model`?n(`models.sync.newModel`):e.kind===`price`?n(`models.sync.price`,{key:e.priceKey??``}):n(`models.sync.field`,{field:e.field??``}),checked:c,onChange:l})]})}export{L as ModelsPage};
1
+ import{An as e,B as t,Ca as n,Ea as r,Ir as i,Lr as a,Sa as o,X as s,Xt as c,c as l,d as u,h as d,it as f,l as p,n as m,ot as h,p as g,r as _,t as v,tt as y,v as b}from"./alert-BzjF81CS.js";import{a as x,i as S,o as C,r as w}from"./overlays-8ByMRpma.js";import{t as T}from"./cloud-download-B7vzhwxM.js";import{D as E,M as D,R as O,U as k,V as A,Z as j,h as M,j as N}from"./index-D7HIE1TG.js";import{t as P}from"./checkbox-DQpzihMp.js";var F=r(n(),1),I=o();function L(){let{t}=h(),n=j(),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(!1),[u,f]=(0,F.useState)(!1),p=(0,F.useRef)(null),m=D(r),g=e(),y=e(m,a),S=(0,F.useMemo)(()=>[...new Set((g.data??[]).map(e=>e.vendor))].sort(),[g.data]);return N(e=>{e===`find`&&p.current?.focus()}),(0,I.jsxs)(M,{title:t(`nav.models`),subtitle:y.data?t(`models.count`,{count:y.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{inputRef:p,className:`w-52`,value:r,onChange:i,placeholder:t(`models.search`)}),(0,I.jsx)(w,{value:a,onChange:o,options:[{value:``,label:t(`models.allVendors`)},...S.map(e=>({value:e,label:e}))]}),(0,I.jsx)(_,{icon:(0,I.jsx)(T,{className:`size-3.5`}),onClick:()=>f(!0),children:t(`models.sync`)}),(0,I.jsx)(_,{variant:`primary`,icon:(0,I.jsx)(O,{className:`size-3.5`}),onClick:()=>c(!0),children:t(`models.new`)})]}),children:[y.isLoading&&(0,I.jsx)(b,{lines:5}),y.isError&&(0,I.jsx)(v,{tone:`danger`,title:t(`common.error`),children:x(y.error)}),y.data?.length===0&&(0,I.jsx)(l,{icon:(0,I.jsx)(k,{className:`size-6`}),title:t(`models.empty`)}),y.data&&y.data.length>0&&(0,I.jsx)(E,{caption:t(`nav.models`),rowKey:`id`,rows:y.data.map(e=>({id:e.id,name:e.displayName,vendor:e.vendor,context:e.contextWindow??0,input:e.pricing?.base.input??0,providerPrices:e.providerPriceKeys.length,m:e})),columns:R(t,e=>n(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:s,onOpenChange:c,onCreated:e=>n(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:u,onOpenChange:f})]})}function R(e,n){return[{key:`name`,label:e(`models.col.model`),render:(t,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>n(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:f(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(m,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(m,{tone:`orange`,children:e(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:r.id})]})},{key:`vendor`,label:e(`models.col.vendor`),width:120},{key:`context`,label:e(`models.col.context`),numeric:!0,width:96,render:(e,n)=>t(n.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${s(n.input)} / ${s(n.output)}`:`—`}},{key:`providerPrices`,label:e(`models.col.providerPrices`),numeric:!0,width:130,render:(t,n)=>n.providerPrices?e(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:e,onOpenChange:t,onCreated:n}){let{t:r}=h(),{toast:i}=C(),a=c(),[o,s]=(0,F.useState)(``),[l,d]=(0,F.useState)(``),[f,m]=(0,F.useState)(``),[v,y]=(0,F.useState)(null),[b,w]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(S,{open:e,onOpenChange:t,title:r(`models.new`),description:r(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(_,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(_,{variant:`primary`,disabled:!o.trim()||!f.trim(),loading:a.isPending,onClick:()=>a.mutate({id:o.trim(),displayName:l.trim()||o.trim(),vendor:f.trim(),contextWindow:v,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{t(!1),s(``),d(``),n(e.id)},onError:e=>i(x(e),`error`)}),children:r(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(p,{label:r(`models.field.id`),hint:r(`models.field.idHint`),children:(0,I.jsx)(u,{className:`font-mono`,value:o,onChange:e=>s(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(p,{label:r(`models.field.displayName`),children:(0,I.jsx)(u,{value:l,onChange:e=>d(e.target.value)})}),(0,I.jsx)(p,{label:r(`models.field.vendor`),children:(0,I.jsx)(u,{value:f,onChange:e=>m(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(p,{label:r(`models.field.contextWindow`),children:(0,I.jsx)(g,{value:v,onChange:y})}),(0,I.jsx)(p,{label:r(`models.field.inputPrice`),children:(0,I.jsx)(g,{value:b,onChange:w})}),(0,I.jsx)(p,{label:r(`models.field.outputPrice`),children:(0,I.jsx)(g,{value:T,onChange:E})})]})]})})}var B=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V(e,t=``,n=new Map){if(B(e)&&Object.keys(e).length>0)for(let[r,i]of Object.entries(e))V(i,t?`${t}.${r}`:r,n);else e!=null&&n.set(t,e);return n}function H(e,t){let n=V(e),r=V(t);return[...r.keys(),...[...n.keys()].filter(e=>!r.has(e))].filter(e=>JSON.stringify(n.get(e))!==JSON.stringify(r.get(e))).map(e=>({path:e.replace(/^pricing\./,``),before:n.get(e),after:r.get(e)}))}var U=e=>typeof e==`string`?e:JSON.stringify(e),W=4;function G({before:e,after:t}){let{t:n}=h(),r=H(e,t),i=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${y(e)||`∅`}\n→\n${y(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),i>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:i})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:i}=h(),[a,o]=(0,F.useState)(new Set),s=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),c=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},l=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},u=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),d=e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(m,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(m,{tone:`orange`,children:i(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),p=e.map(e=>e.id);return(0,I.jsx)(`div`,{className:`card max-h-[520px] overflow-auto`,children:(0,I.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,I.jsxs)(`li`,{className:`sticky top-0 z-10 flex items-center gap-3 bg-[var(--surface)] px-4 py-2`,children:[(0,I.jsx)(P,{checked:c(p),onCheckedChange:e=>l(p,e!==!1),"aria-label":i(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.selectedOf`,{n:n.size,total:p.length,models:s.length})})]}),s.map(([e,r])=>{let o=r.map(e=>e.id),s=r.length===1?r[0]:void 0,p=!a.has(e);return(0,I.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:c(o),onCheckedChange:e=>l(o,e!==!1),"aria-label":e,className:`mt-0.5`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[s?(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}):(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1 text-left`,"aria-expanded":p,onClick:()=>u(e),children:[(0,I.jsx)(A,{className:f(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,p&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.groupCount`,{n:r.length})})]}),s&&d(s)]})]}),!s&&p&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:r.map(r=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:n.has(r.id),onCheckedChange:e=>l([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),d(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:n}=h(),{toast:r}=C(),o=a(),s=i(),[c,l]=(0,F.useState)(new Set),u=()=>o.mutate(void 0,{onSuccess:e=>l(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),d=o.data?.changes??[];return(0,I.jsxs)(S,{open:e,onOpenChange:e=>{t(e),e&&!o.data&&u()},width:720,title:n(`models.sync`),description:n(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(_,{className:`mr-auto`,variant:`plain`,onClick:u,loading:o.isPending,children:n(`common.refresh`)}),(0,I.jsx)(_,{onClick:()=>t(!1),children:n(`common.cancel`)}),(0,I.jsx)(_,{variant:`primary`,disabled:c.size===0,loading:s.isPending,onClick:()=>s.mutate([...c],{onSuccess:e=>{r(n(`models.sync.applied`,{count:e.applied}),`success`),t(!1),o.reset()},onError:e=>r(x(e),`error`)}),children:n(`models.sync.apply`,{count:c.size})})]}),children:[e&&!o.data&&!o.isPending&&!o.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(_,{variant:`primary`,onClick:u,children:n(`models.sync.check`)})}),o.isPending&&(0,I.jsx)(b,{lines:4}),o.isError&&(0,I.jsx)(v,{tone:`danger`,title:n(`common.error`),children:x(o.error)}),o.data&&d.length===0&&(0,I.jsx)(v,{tone:`success`,title:n(`models.sync.none`)}),d.length>0&&(0,I.jsx)(K,{changes:d,label:e=>e.kind===`new_model`?n(`models.sync.newModel`):e.kind===`price`?n(`models.sync.price`,{key:e.priceKey??``}):n(`models.sync.field`,{field:e.field??``}),checked:c,onChange:l})]})}export{L as ModelsPage};
@@ -1,2 +1,2 @@
1
- import{At as e,Ca as t,Ea as n,Fn as r,Gn as i,In as a,Ln as o,On as s,Sa as c,Sn as l,Un as u,V as d,_ as f,_t as p,b as m,c as h,cr as g,d as _,dt as v,f as y,h as b,i as x,it as S,jn as C,l as w,lr as T,n as E,ot as D,r as O,t as k,ti as A,v as j,vt as M,y as N,yn as ee,zn as te}from"./alert-CN1yWco4.js";import{a as P,i as F,n as ne,o as I}from"./overlays-D2pWmtov.js";import{t as re}from"./arrow-down-DP0xP3tk.js";import{t as ie}from"./download-C4--ZCHf.js";import{t as ae}from"./ellipsis-D250KISp.js";import{t as oe}from"./external-link-Bnshhxip.js";import{$ as se,C as ce,E as L,G as le,L as R,N as z,P as B,Q as V,R as H,T as U,Z as W,h as ue,q as de,w as G,x as fe}from"./index-CBrXkG99.js";var K={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};K.node;var pe=M(K),q=n(t(),1),J=c(),me=/^(?:(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*|github:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/,Y={provider:`plugins.kind.provider`,middleware:`plugins.kind.middleware`,agent:`plugins.kind.agent`,pi:`plugins.kind.pi`},he={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`};function X({name:e,icon:t,kind:n,size:r=32}){let i=Math.round(r*.28);return t&&/^(https:|data:image\/)/i.test(t)?(0,J.jsx)(`img`,{src:t,alt:``,width:r,height:r,className:`shrink-0 object-contain`,style:{borderRadius:i},draggable:!1}):n===`middleware`||n===`agent`?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex shrink-0 items-center justify-center text-white`,style:{width:r,height:r,borderRadius:i,background:n===`middleware`?`#0a84ff`:`#30b0a0`},children:(0,J.jsx)(n===`middleware`?B:de,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(fe,{name:e,icon:t,size:r})}function Z(){let{t:e}=D(),t=W(),{tab:n}=V(),r=n===`market`||n===`runtime`?n:`installed`,i=u(),a=A(),{toast:o}=I(),[s,c]=(0,q.useState)(!1),[l,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null);return(0,J.jsxs)(ue,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(O,{icon:(0,J.jsx)(R,{className:`size-3.5`}),onClick:()=>a.mutate(void 0,{onSuccess:e=>p(e.id),onError:e=>o(P(e),`error`)}),disabled:!i.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(O,{variant:`primary`,icon:(0,J.jsx)(H,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[i.data?.off&&(0,J.jsx)(k,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(ce,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(U,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(L,{value:`installed`,children:[e(`plugins.tab.installed`),i.data&&i.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:i.data.plugins.length})]}),(0,J.jsx)(L,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(L,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(G,{value:`installed`,className:`pt-1`,children:[i.isLoading&&(0,J.jsx)(j,{lines:4}),i.isError&&(0,J.jsx)(k,{tone:`danger`,title:e(`common.error`),children:P(i.error)}),i.data&&(0,J.jsx)(ge,{plugins:i.data.plugins,preferences:i.data.preferences,onJob:p,onBrowse:()=>t(`/plugins/market`),onImport:()=>d(!0)})]}),(0,J.jsx)(G,{value:`market`,className:`pt-1`,children:(0,J.jsx)(Se,{installed:i.data?.plugins??[],onJob:p})}),(0,J.jsx)(G,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Ce,{onJob:p})})]})]}),(0,J.jsx)(ye,{open:s,onOpenChange:c,onJob:p}),(0,J.jsx)(be,{open:l,onOpenChange:d,onJob:p}),(0,J.jsx)(xe,{id:f,onClose:()=>p(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:i,onImport:a}){let{t:o}=D(),c=r(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),l=s(),u=T(),{toast:d}=I(),f=!!(l.data?.found&&l.data.plugins.some(e=>!e.installed))&&(0,J.jsxs)(`div`,{className:`card flex flex-wrap items-center gap-3 p-4`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:o(`plugins.magpie.banner`,{count:l.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(O,{size:`sm`,icon:(0,J.jsx)(ie,{className:`size-3.5`}),onClick:a,children:o(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(h,{icon:(0,J.jsx)(v,{className:`size-6`}),title:o(`plugins.empty`),detail:o(`plugins.emptyDetail`),action:(0,J.jsx)(O,{variant:`primary`,onClick:i,children:o(`plugins.browseMarket`)})})})]});let p=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),u.mutate(r,{onError:e=>d(P(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((r,i)=>(0,J.jsx)(_e,{plugin:r,host:c.data,preferences:t,onJob:n,onUp:i>0?()=>p(i,-1):void 0,onDown:i<e.length-1?()=>p(i,1):void 0},r.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:o(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:n,onJob:r,onUp:a,onDown:o}){let{t:s}=D(),c=W(),{toast:l,confirm:u}=I(),d=C(),f=A(),p=g(),m=i(),[h,_]=(0,q.useState)(!1),v=t?.plugins.find(t=>t.spec===e.spec),y=e.middleware,b=e.kinds[0]??`provider`,x=async()=>{await u({title:s(`plugins.removeConfirm`,{name:e.shortName}),detail:s(`plugins.removeDetail`),confirmLabel:s(`common.delete`),destructive:!0})&&p.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>l(P(e),`error`)})},w=[];return y&&!y.error&&w.push((0,J.jsxs)(Q,{label:s(`plugins.kind.middleware`),children:[s(`plugins.mw.stats`,{hooks:y.hooks.join(`, `),calls:y.calls,micros:y.avgMicros.toFixed(1),failures:y.failures}),y.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:s(`plugins.mw.lastError`,{error:y.lastError})})]},`mw`)),e.agent?.kind&&w.push((0,J.jsx)(Q,{label:s(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>c(`/clients/${e.agent.kind}`),children:s(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),v&&v.provides.length>0&&w.push((0,J.jsxs)(Q,{label:s(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:s(`plugins.provides`,{providers:v.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>c(`/providers`),children:s(`plugins.openProviders`)}),Object.entries(v.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[s(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(O,{size:`sm`,onClick:()=>m.mutate({spec:e.spec,provider:t},{onError:e=>l(P(e),`error`)}),children:s(`plugins.useFor`,{provider:t})})]},t)),v.provides.some(t=>n[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:s(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:S(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:S(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:b})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.shortName}),e.version&&(0,J.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:[`v`,e.version]}),e.kinds.map(e=>(0,J.jsx)(E,{tone:he[e],children:s(Y[e])},e)),e.isPath&&(0,J.jsx)(E,{tone:`orange`,children:s(`plugins.local`)})]}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:e.spec,children:e.spec})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[y&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(O,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveUp`),title:s(`plugins.moveUp`),disabled:!a,onClick:a,icon:(0,J.jsx)(le,{className:`size-3.5`})}),(0,J.jsx)(O,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveDown`),title:s(`plugins.moveDown`),disabled:!o,onClick:o,icon:(0,J.jsx)(re,{className:`size-3.5`})})]}),(0,J.jsx)(N,{checked:e.enabled,label:s(`plugins.enabled`),onChange:t=>d.mutate({spec:e.spec,enabled:t},{onError:e=>l(P(e),`error`)})}),(0,J.jsx)(ne,{label:s(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ae,{className:`size-4`}),items:[{id:`options`,label:s(`plugins.options`),icon:(0,J.jsx)(pe,{className:`size-3.5`}),onSelect:()=>_(!0)},...e.isPath?[]:[{id:`update`,label:s(`plugins.update`),icon:(0,J.jsx)(R,{className:`size-3.5`}),onSelect:()=>f.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>l(P(e),`error`)})}],{id:`remove`,label:s(`common.delete`),icon:(0,J.jsx)(z,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void x()}]})]})]}),e.error&&(0,J.jsx)(k,{tone:`danger`,title:s(`plugins.cantLoad`),children:e.error}),v?.error&&(0,J.jsx)(k,{tone:`danger`,title:s(`plugins.hostCantLoad`),children:v.error}),y?.error&&(0,J.jsx)(k,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.mw.error`,{error:y.error})}),e.agent?.error&&(0,J.jsx)(k,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.agent.error`,{error:e.agent.error})}),w.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:w})]}),(0,J.jsx)(ve,{plugin:e,open:h,onOpenChange:_})]})}function Q({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex gap-3 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[var(--text-muted)]`,children:e}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 text-[var(--text-secondary)]`,children:t})]})}function ve({plugin:e,open:t,onOpenChange:n}){let{t:r}=D(),{toast:i}=I(),a=C(),[o,s]=(0,q.useState)(``),[c,l]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(s(JSON.stringify(e.options??e.optionsExample??{},null,2)),l(null))},[t,e.options,e.optionsExample]);let u=t=>a.mutate({spec:e.spec,options:t},{onSuccess:()=>(i(r(`plugins.optionsSaved`)),n(!1)),onError:e=>i(P(e),`error`)});return(0,J.jsxs)(F,{open:t,onOpenChange:n,title:r(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?r(`plugins.optionsExample`):r(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(O,{onClick:()=>u(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(O,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(o||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(r(`plugins.optionsObject`));u(e)}catch(e){l(e instanceof Error?e.message:String(e))}},disabled:a.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(m,{mono:!0,rows:14,value:o,invalid:!!c,onChange:e=>(s(e.target.value),l(null)),label:r(`plugins.options`)}),c&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:c})]})}function ye({open:t,onOpenChange:n,onJob:r}){let{t:i}=D(),{toast:a}=I(),o=e(),[s,c]=(0,q.useState)(``);return(0,q.useEffect)(()=>{t&&c(``)},[t]),(0,J.jsxs)(F,{open:t,onOpenChange:n,title:i(`plugins.addTitle`),description:i(`plugins.addDetail`),footer:(0,J.jsx)(O,{variant:`primary`,disabled:!s.trim()||o.isPending,onClick:()=>o.mutate({spec:s.trim()},{onSuccess:e=>(r(e.id),n(!1)),onError:e=>a(P(e),`error`)}),children:i(`plugins.install`)}),children:[(0,J.jsx)(w,{label:i(`plugins.spec`),hint:i(`plugins.specHint`),children:(0,J.jsx)(_,{mono:!0,value:s,onChange:e=>c(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(k,{tone:`warning`,title:i(`plugins.trustTitle`),className:`mt-4`,children:i(`plugins.trustDetail`)})]})}function be({open:e,onOpenChange:t,onJob:n}){let{t:r}=D(),{toast:i}=I(),a=s(e),o=ee(),[c,l]=(0,q.useState)(!1),u=a.data;return(0,J.jsxs)(F,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:u?.path,width:560,footer:(0,J.jsx)(O,{variant:`primary`,disabled:!u?.found||o.isPending,onClick:()=>o.mutate(c,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(P(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[a.isLoading&&(0,J.jsx)(j,{lines:3}),u?.error&&(0,J.jsx)(k,{tone:`danger`,title:r(`common.error`),children:u.error}),u&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:u.plugins.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.spec}),e.off&&(0,J.jsx)(E,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(E,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(E,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),u.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(N,{checked:c,onChange:l,label:r(`plugins.magpie.signIns`,{count:u.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`plugins.magpie.signInsDetail`)})]})]})]})}function xe({id:e,onClose:t}){let{t:n}=D(),r=a(e).data;return(0,J.jsxs)(F,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:r?n(r.state===`running`?`plugins.job.running`:r.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:r.target}):void 0,width:620,footer:(0,J.jsx)(O,{onClick:t,children:n(`common.close`)}),children:[!r&&(0,J.jsx)(j,{lines:3}),r&&(0,J.jsx)(x,{language:`text`,children:r.log.length?r.log.join(`
1
+ import{At as e,Ca as t,Ea as n,Fn as r,Gn as i,In as a,Ln as o,On as s,Sa as c,Sn as l,Un as u,V as d,_ as f,_t as p,b as m,c as h,cr as g,d as _,dt as v,f as y,h as b,i as x,it as S,jn as C,l as w,lr as T,n as E,ot as D,r as O,t as k,ti as A,v as j,vt as M,y as N,yn as ee,zn as te}from"./alert-BzjF81CS.js";import{a as P,i as F,n as ne,o as I}from"./overlays-8ByMRpma.js";import{t as re}from"./arrow-down-BjT6LDhw.js";import{t as ie}from"./download-CI3oqkmw.js";import{t as ae}from"./ellipsis-Br3iFNj9.js";import{t as oe}from"./external-link-LUcufY2s.js";import{$ as se,C as ce,E as L,G as le,L as R,N as z,P as B,Q as V,R as H,T as U,Z as W,h as ue,q as de,w as G,x as fe}from"./index-D7HIE1TG.js";var K={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};K.node;var pe=M(K),q=n(t(),1),J=c(),me=/^(?:(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*|github:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/,Y={provider:`plugins.kind.provider`,middleware:`plugins.kind.middleware`,agent:`plugins.kind.agent`,pi:`plugins.kind.pi`},he={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`};function X({name:e,icon:t,kind:n,size:r=32}){let i=Math.round(r*.28);return t&&/^(https:|data:image\/)/i.test(t)?(0,J.jsx)(`img`,{src:t,alt:``,width:r,height:r,className:`shrink-0 object-contain`,style:{borderRadius:i},draggable:!1}):n===`middleware`||n===`agent`?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex shrink-0 items-center justify-center text-white`,style:{width:r,height:r,borderRadius:i,background:n===`middleware`?`#0a84ff`:`#30b0a0`},children:(0,J.jsx)(n===`middleware`?B:de,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(fe,{name:e,icon:t,size:r})}function Z(){let{t:e}=D(),t=W(),{tab:n}=V(),r=n===`market`||n===`runtime`?n:`installed`,i=u(),a=A(),{toast:o}=I(),[s,c]=(0,q.useState)(!1),[l,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null);return(0,J.jsxs)(ue,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(O,{icon:(0,J.jsx)(R,{className:`size-3.5`}),onClick:()=>a.mutate(void 0,{onSuccess:e=>p(e.id),onError:e=>o(P(e),`error`)}),disabled:!i.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(O,{variant:`primary`,icon:(0,J.jsx)(H,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[i.data?.off&&(0,J.jsx)(k,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(ce,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(U,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(L,{value:`installed`,children:[e(`plugins.tab.installed`),i.data&&i.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:i.data.plugins.length})]}),(0,J.jsx)(L,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(L,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(G,{value:`installed`,className:`pt-1`,children:[i.isLoading&&(0,J.jsx)(j,{lines:4}),i.isError&&(0,J.jsx)(k,{tone:`danger`,title:e(`common.error`),children:P(i.error)}),i.data&&(0,J.jsx)(ge,{plugins:i.data.plugins,preferences:i.data.preferences,onJob:p,onBrowse:()=>t(`/plugins/market`),onImport:()=>d(!0)})]}),(0,J.jsx)(G,{value:`market`,className:`pt-1`,children:(0,J.jsx)(Se,{installed:i.data?.plugins??[],onJob:p})}),(0,J.jsx)(G,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Ce,{onJob:p})})]})]}),(0,J.jsx)(ye,{open:s,onOpenChange:c,onJob:p}),(0,J.jsx)(be,{open:l,onOpenChange:d,onJob:p}),(0,J.jsx)(xe,{id:f,onClose:()=>p(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:i,onImport:a}){let{t:o}=D(),c=r(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),l=s(),u=T(),{toast:d}=I(),f=!!(l.data?.found&&l.data.plugins.some(e=>!e.installed))&&(0,J.jsxs)(`div`,{className:`card flex flex-wrap items-center gap-3 p-4`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:o(`plugins.magpie.banner`,{count:l.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(O,{size:`sm`,icon:(0,J.jsx)(ie,{className:`size-3.5`}),onClick:a,children:o(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(h,{icon:(0,J.jsx)(v,{className:`size-6`}),title:o(`plugins.empty`),detail:o(`plugins.emptyDetail`),action:(0,J.jsx)(O,{variant:`primary`,onClick:i,children:o(`plugins.browseMarket`)})})})]});let p=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),u.mutate(r,{onError:e=>d(P(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((r,i)=>(0,J.jsx)(_e,{plugin:r,host:c.data,preferences:t,onJob:n,onUp:i>0?()=>p(i,-1):void 0,onDown:i<e.length-1?()=>p(i,1):void 0},r.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:o(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:n,onJob:r,onUp:a,onDown:o}){let{t:s}=D(),c=W(),{toast:l,confirm:u}=I(),d=C(),f=A(),p=g(),m=i(),[h,_]=(0,q.useState)(!1),v=t?.plugins.find(t=>t.spec===e.spec),y=e.middleware,b=e.kinds[0]??`provider`,x=async()=>{await u({title:s(`plugins.removeConfirm`,{name:e.shortName}),detail:s(`plugins.removeDetail`),confirmLabel:s(`common.delete`),destructive:!0})&&p.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>l(P(e),`error`)})},w=[];return y&&!y.error&&w.push((0,J.jsxs)(Q,{label:s(`plugins.kind.middleware`),children:[s(`plugins.mw.stats`,{hooks:y.hooks.join(`, `),calls:y.calls,micros:y.avgMicros.toFixed(1),failures:y.failures}),y.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:s(`plugins.mw.lastError`,{error:y.lastError})})]},`mw`)),e.agent?.kind&&w.push((0,J.jsx)(Q,{label:s(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>c(`/clients/${e.agent.kind}`),children:s(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),v&&v.provides.length>0&&w.push((0,J.jsxs)(Q,{label:s(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:s(`plugins.provides`,{providers:v.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>c(`/providers`),children:s(`plugins.openProviders`)}),Object.entries(v.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[s(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(O,{size:`sm`,onClick:()=>m.mutate({spec:e.spec,provider:t},{onError:e=>l(P(e),`error`)}),children:s(`plugins.useFor`,{provider:t})})]},t)),v.provides.some(t=>n[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:s(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:S(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:S(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:b})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.shortName}),e.version&&(0,J.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:[`v`,e.version]}),e.kinds.map(e=>(0,J.jsx)(E,{tone:he[e],children:s(Y[e])},e)),e.isPath&&(0,J.jsx)(E,{tone:`orange`,children:s(`plugins.local`)})]}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:e.spec,children:e.spec})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[y&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(O,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveUp`),title:s(`plugins.moveUp`),disabled:!a,onClick:a,icon:(0,J.jsx)(le,{className:`size-3.5`})}),(0,J.jsx)(O,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveDown`),title:s(`plugins.moveDown`),disabled:!o,onClick:o,icon:(0,J.jsx)(re,{className:`size-3.5`})})]}),(0,J.jsx)(N,{checked:e.enabled,label:s(`plugins.enabled`),onChange:t=>d.mutate({spec:e.spec,enabled:t},{onError:e=>l(P(e),`error`)})}),(0,J.jsx)(ne,{label:s(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ae,{className:`size-4`}),items:[{id:`options`,label:s(`plugins.options`),icon:(0,J.jsx)(pe,{className:`size-3.5`}),onSelect:()=>_(!0)},...e.isPath?[]:[{id:`update`,label:s(`plugins.update`),icon:(0,J.jsx)(R,{className:`size-3.5`}),onSelect:()=>f.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>l(P(e),`error`)})}],{id:`remove`,label:s(`common.delete`),icon:(0,J.jsx)(z,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void x()}]})]})]}),e.error&&(0,J.jsx)(k,{tone:`danger`,title:s(`plugins.cantLoad`),children:e.error}),v?.error&&(0,J.jsx)(k,{tone:`danger`,title:s(`plugins.hostCantLoad`),children:v.error}),y?.error&&(0,J.jsx)(k,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.mw.error`,{error:y.error})}),e.agent?.error&&(0,J.jsx)(k,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.agent.error`,{error:e.agent.error})}),w.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:w})]}),(0,J.jsx)(ve,{plugin:e,open:h,onOpenChange:_})]})}function Q({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex gap-3 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[var(--text-muted)]`,children:e}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 text-[var(--text-secondary)]`,children:t})]})}function ve({plugin:e,open:t,onOpenChange:n}){let{t:r}=D(),{toast:i}=I(),a=C(),[o,s]=(0,q.useState)(``),[c,l]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(s(JSON.stringify(e.options??e.optionsExample??{},null,2)),l(null))},[t,e.options,e.optionsExample]);let u=t=>a.mutate({spec:e.spec,options:t},{onSuccess:()=>(i(r(`plugins.optionsSaved`)),n(!1)),onError:e=>i(P(e),`error`)});return(0,J.jsxs)(F,{open:t,onOpenChange:n,title:r(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?r(`plugins.optionsExample`):r(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(O,{onClick:()=>u(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(O,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(o||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(r(`plugins.optionsObject`));u(e)}catch(e){l(e instanceof Error?e.message:String(e))}},disabled:a.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(m,{mono:!0,rows:14,value:o,invalid:!!c,onChange:e=>(s(e.target.value),l(null)),label:r(`plugins.options`)}),c&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:c})]})}function ye({open:t,onOpenChange:n,onJob:r}){let{t:i}=D(),{toast:a}=I(),o=e(),[s,c]=(0,q.useState)(``);return(0,q.useEffect)(()=>{t&&c(``)},[t]),(0,J.jsxs)(F,{open:t,onOpenChange:n,title:i(`plugins.addTitle`),description:i(`plugins.addDetail`),footer:(0,J.jsx)(O,{variant:`primary`,disabled:!s.trim()||o.isPending,onClick:()=>o.mutate({spec:s.trim()},{onSuccess:e=>(r(e.id),n(!1)),onError:e=>a(P(e),`error`)}),children:i(`plugins.install`)}),children:[(0,J.jsx)(w,{label:i(`plugins.spec`),hint:i(`plugins.specHint`),children:(0,J.jsx)(_,{mono:!0,value:s,onChange:e=>c(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(k,{tone:`warning`,title:i(`plugins.trustTitle`),className:`mt-4`,children:i(`plugins.trustDetail`)})]})}function be({open:e,onOpenChange:t,onJob:n}){let{t:r}=D(),{toast:i}=I(),a=s(e),o=ee(),[c,l]=(0,q.useState)(!1),u=a.data;return(0,J.jsxs)(F,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:u?.path,width:560,footer:(0,J.jsx)(O,{variant:`primary`,disabled:!u?.found||o.isPending,onClick:()=>o.mutate(c,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(P(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[a.isLoading&&(0,J.jsx)(j,{lines:3}),u?.error&&(0,J.jsx)(k,{tone:`danger`,title:r(`common.error`),children:u.error}),u&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:u.plugins.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.spec}),e.off&&(0,J.jsx)(E,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(E,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(E,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),u.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(N,{checked:c,onChange:l,label:r(`plugins.magpie.signIns`,{count:u.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`plugins.magpie.signInsDetail`)})]})]})]})}function xe({id:e,onClose:t}){let{t:n}=D(),r=a(e).data;return(0,J.jsxs)(F,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:r?n(r.state===`running`?`plugins.job.running`:r.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:r.target}):void 0,width:620,footer:(0,J.jsx)(O,{onClick:t,children:n(`common.close`)}),children:[!r&&(0,J.jsx)(j,{lines:3}),r&&(0,J.jsx)(x,{language:`text`,children:r.log.length?r.log.join(`
2
2
  `):`…`}),r?.state===`failed`&&r.error&&(0,J.jsx)(k,{tone:`danger`,title:n(`plugins.job.failedTitle`),className:`mt-3`,children:r.error})]})}function Se({installed:t,onJob:n}){let{t:r,locale:i}=D(),{toast:a,confirm:s}=I(),c=o(),l=e(),[u,d]=(0,q.useState)(``),[p,m]=(0,q.useState)(``),[g,_]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>m(u.trim()),400);return()=>clearTimeout(e)},[u]);let y=te(p),x=(0,q.useMemo)(()=>new Set(t.map(e=>e.name)),[t]),S=(e,n)=>x.has(n)||t.some(t=>t.spec===e),C=async(e,t)=>{await s({title:r(`plugins.installConfirm`,{name:e}),detail:r(`plugins.trustDetail`),confirmLabel:r(`plugins.install`)})&&l.mutate({spec:e,source:t},{onSuccess:e=>n(e.id),onError:e=>a(P(e),`error`)})},[w,T]=se(),E=w.get(`install`),O=(0,q.useRef)(null);(0,q.useEffect)(()=>{E&&O.current!==E&&(O.current=E,T({},{replace:!0}),me.test(E)?C(E,`market`):a(r(`plugins.linkInvalid`),`error`))},[E]);let A=(c.data??[]).filter(e=>g===`all`||e.kind===g),M=e=>(c.data??[]).filter(t=>e===`all`||t.kind===e).length,N=p.length>=2;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(b,{className:`min-w-[220px] flex-1`,value:u,onChange:d,placeholder:r(`plugins.searchPlaceholder`)}),!N&&(0,J.jsx)(f,{ariaLabel:r(`plugins.kindFilter`),value:g,onChange:_,items:[`all`,`provider`,`middleware`,`agent`].map(e=>({value:e,label:`${r(e===`all`?`plugins.kind.all`:Y[e])} ${M(e)}`}))})]}),N?(0,J.jsxs)(J.Fragment,{children:[y.isLoading&&(0,J.jsx)(j,{lines:3}),y.data?.length===0&&(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(h,{icon:(0,J.jsx)(v,{className:`size-6`}),title:r(`plugins.noResults`)})}),y.data&&y.data.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:y.data.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.spec,icon:(0,J.jsx)(X,{name:e.name,kind:e.kind}),detail:e.description??void 0,tags:[r(Y[e.kind]),e.source===`github`?`★ ${e.stars}`:e.version?`v${e.version}`:``,e.source===`astra`?r(`plugins.origin.astra`):``],installed:S(e.spec,e.name),onInstall:()=>void C(e.spec,e.source===`github`?`github`:e.source===`astra`?`market`:`npm`)},e.spec))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:r(`plugins.searchNote`)})]}):(0,J.jsxs)(J.Fragment,{children:[c.isLoading&&(0,J.jsx)(j,{lines:4}),c.isError&&(0,J.jsx)(k,{tone:`danger`,title:r(`common.error`),children:P(c.error)}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:A.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.package,icon:(0,J.jsx)(X,{name:e.name,icon:e.icon,kind:e.kind}),detail:e.summary[i]??e.summary.en??e.description??void 0,tags:[r(Y[e.kind]),e.latest?`v${e.latest}`:``,e.origin===`astra`?r(`plugins.origin.astra`):``,e.minAstraVersion?r(`plugins.minVersion`,{version:e.minAstraVersion}):``].filter(Boolean),installed:S(e.package,e.package),onInstall:()=>void C(e.package,`market`)},e.package))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:r(`plugins.marketNote`)})]})]})}function $({title:e,subtitle:t,icon:n,detail:r,tags:i,installed:a,onInstall:o}){let{t:s}=D();return(0,J.jsxs)(`div`,{className:`card flex flex-col gap-3 p-4 transition-colors hover:border-[var(--border)]`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[n,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e,children:e}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:t,children:t})]})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 min-h-[2lh] text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:r??``}),(0,J.jsxs)(`div`,{className:`mt-auto flex items-center gap-1.5`,children:[i.filter(Boolean).map(e=>(0,J.jsx)(E,{children:e},e)),(0,J.jsx)(`span`,{className:`flex-1`}),a?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-[var(--success)]`,children:[(0,J.jsx)(p,{className:`size-3.5`}),s(`plugins.installed`)]}):(0,J.jsx)(O,{size:`sm`,variant:`primary`,onClick:o,children:s(`plugins.install`)})]})]})}function Ce({onJob:e}){let{t,locale:n}=D(),{toast:i}=I(),a=u(),o=r(),s=l(),c=a.data?.runtime;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:`Bun`}),c&&(0,J.jsx)(E,{tone:c.path?`green`:`neutral`,children:c.path?t(`plugins.bunReady`):t(`plugins.bunMissing`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.bunDetail`)}),c&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c.path&&(0,J.jsx)(y,{label:t(`plugins.bunPath`),mono:!0,children:c.path}),c.version&&(0,J.jsx)(y,{label:t(`plugins.bunVersion`),mono:!0,children:c.version}),(0,J.jsx)(y,{label:t(`plugins.bunTarget`),mono:!0,children:c.target??t(`plugins.bunNoBuild`)})]}),c?.error&&(0,J.jsx)(k,{tone:`danger`,title:t(`plugins.bunFailed`),children:c.error}),c&&!c.path&&(0,J.jsx)(`div`,{children:(0,J.jsx)(O,{variant:`primary`,disabled:c.downloading||s.isPending||!c.target,onClick:()=>s.mutate(void 0,{onSuccess:t=>e(t.id),onError:e=>i(P(e),`error`)}),children:c.downloading?t(`plugins.bunDownloading`):t(`plugins.bunDownload`,{version:c.version??``})})})]}),(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:t(`plugins.host`)}),o.data&&(0,J.jsx)(E,{tone:o.data.running?`green`:`neutral`,children:o.data.running?t(`plugins.hostRunning`):t(`plugins.hostStopped`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.hostDetail`)}),o.data?.startError&&(0,J.jsx)(k,{tone:`danger`,title:t(`plugins.hostStartFailed`),children:o.data.startError}),o.data?.goneReason&&(0,J.jsx)(k,{tone:`warning`,title:t(`plugins.hostGone`),children:o.data.goneReason}),o.data&&o.data.plugins.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.data.plugins.map(e=>(0,J.jsx)(y,{label:e.spec,mono:!0,children:e.error?t(`plugins.hostPluginError`,{error:e.error}):e.provides.join(`, `)||`—`},e.spec))}),o.data?.recent&&o.data.recent.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-t border-[var(--border-subtle)] pt-3`,children:[(0,J.jsx)(`h4`,{className:`text-[12px] font-medium text-[var(--text-secondary)]`,children:t(`plugins.hostRecent`)}),o.data.recent.map((e,t)=>(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-[12px]`,children:[(0,J.jsx)(E,{tone:e.variant===`error`?`red`:e.variant===`warning`?`orange`:e.variant===`success`?`green`:`neutral`,children:d(e.at,n)}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.title&&(0,J.jsxs)(`span`,{className:`font-medium`,children:[e.title,` `]}),e.message]})]},t))]})]}),(0,J.jsxs)(`a`,{className:`flex items-center gap-1 px-1 text-[12px] text-[var(--text-muted)] hover:text-[var(--accent)] lg:col-span-2`,href:`https://github.com/astragate-community/astra-gate-plugins`,target:`_blank`,rel:`noreferrer`,children:[(0,J.jsx)(oe,{className:`size-3`}),` astragate-community/astra-gate-plugins`]})]})}export{Z as PluginsPage};