@aidotnet/server-win32-x64 0.14.3108 → 0.14.3110

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 (29) hide show
  1. package/bin/astra-server.exe +2 -2
  2. package/bin/wwwroot/assets/{ClientsPage-G2RzDwxF.js → ClientsPage-DF3rflag.js} +1 -1
  3. package/bin/wwwroot/assets/{KeyPage-B5yEJIx1.js → KeyPage-B7_1Yr16.js} +1 -1
  4. package/bin/wwwroot/assets/{McpPage-Cqa0o8pN.js → McpPage-CvN5NYlZ.js} +2 -2
  5. package/bin/wwwroot/assets/{ModelDetailPage-7guGX9zo.js → ModelDetailPage-CyE8Xpqg.js} +1 -1
  6. package/bin/wwwroot/assets/{ModelsPage-BDyBn2ka.js → ModelsPage-Cct68Oc8.js} +1 -1
  7. package/bin/wwwroot/assets/{PluginsPage-DIXK68XW.js → PluginsPage-DiMYLnBv.js} +1 -1
  8. package/bin/wwwroot/assets/{PrivacyPage-BXSsUc19.js → PrivacyPage-Bdyo4YN_.js} +1 -1
  9. package/bin/wwwroot/assets/{ProviderDetailPage-ZAGqduuj.js → ProviderDetailPage-CZLD3Mo2.js} +1 -1
  10. package/bin/wwwroot/assets/{ProvidersPage-BtVpzabI.js → ProvidersPage-DhvpZLqS.js} +1 -1
  11. package/bin/wwwroot/assets/{SettingsPage-PTbLN9Jh.js → SettingsPage-QVURVf8n.js} +2 -2
  12. package/bin/wwwroot/assets/{SkillsPage-CX6F2OHt.js → SkillsPage-DUAhBBjy.js} +1 -1
  13. package/bin/wwwroot/assets/{SmartRoutingPage-Xs6563FH.js → SmartRoutingPage-yxPbwM3u.js} +1 -1
  14. package/bin/wwwroot/assets/{TokenDetailPage-BCsrS5MY.js → TokenDetailPage-jvkJ9wIf.js} +1 -1
  15. package/bin/wwwroot/assets/{TokenPoolEditor-yKDplMAk.js → TokenPoolEditor-eWoOGd9t.js} +1 -1
  16. package/bin/wwwroot/assets/{TokensPage-CovQvxys.js → TokensPage-BTnINKwi.js} +1 -1
  17. package/bin/wwwroot/assets/{TracesPage-nE3zf5Pt.js → TracesPage-CGAcVl3u.js} +2 -2
  18. package/bin/wwwroot/assets/{TrayPanelPage-NhkC5uY7.js → TrayPanelPage-CackS8OH.js} +1 -1
  19. package/bin/wwwroot/assets/{TrayPanelView-DsZLtFjY.js → TrayPanelView-Cj0Pwm7y.js} +1 -1
  20. package/bin/wwwroot/assets/{TrayTitleSource-U2fI0rGJ.js → TrayTitleSource-EINzpQeQ.js} +1 -1
  21. package/bin/wwwroot/assets/{checkbox-C7ORfHsK.js → checkbox-DFbPH3ZB.js} +1 -1
  22. package/bin/wwwroot/assets/{confirm-morph-Cm30hox1.js → confirm-morph-Cu1awcrW.js} +1 -1
  23. package/bin/wwwroot/assets/{format-hEAJVPjJ.js → format-Bw-mDeuE.js} +2 -2
  24. package/bin/wwwroot/assets/{index-CUXoLKaW.js → index-D2hgi2oA.js} +3 -3
  25. package/bin/wwwroot/assets/{radio-cards-B9j0qfgH.js → radio-cards-C0nGl7Px.js} +1 -1
  26. package/bin/wwwroot/assets/{sortable.esm-CiuAGjJv.js → sortable.esm-KYAcfdq_.js} +1 -1
  27. package/bin/wwwroot/assets/{use-transform-DS7fo517.js → use-transform-BEsJGrlr.js} +1 -1
  28. package/bin/wwwroot/index.html +4 -4
  29. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/astra-server.exe
3
- size: 73995776 bytes
4
- sha256: 355a37b905e3be54f20dc13596477f98073cdb749db622f9fa040f1d9afc58a7
3
+ size: 74009600 bytes
4
+ sha256: 1948776d33369ce117f4c02b6c201108b432068b078db660c4844b9d880e7ed6
@@ -1,4 +1,4 @@
1
- import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{Ar as n,Br as r,Bt as i,C as a,D as o,E as s,Er as c,F as l,Ft as u,H as d,Ht as f,Lt as p,M as m,Nt as h,P as g,Pt as _,R as v,Ri as y,Rt as b,Sn as x,To as S,U as C,Ut as w,V as T,Yr as E,_a as D,_n as O,_r as k,ai as A,ci as ee,gi as te,ht as ne,j as re,li as ie,mn as ae,o as j,r as oe,s as se,u as M,ut as N,wo as ce,x as P}from"./format-hEAJVPjJ.js";import{H as F,L as le,R as I,U as L,V as R,W as z}from"./TrayTitleSource-U2fI0rGJ.js";import{t as ue}from"./archive-CiVf7slo.js";import{t as B}from"./check-DKfsh0bQ.js";import{t as de}from"./chevron-right-Bgtn3ze-.js";import{t as V}from"./circle-arrow-up-x7NR55Yx.js";import{t as fe}from"./copy-48gwhhDO.js";import{t as H}from"./external-link-D6jQM2CZ.js";import{t as pe}from"./folder-open-z1RXMZa1.js";import{t as me}from"./grip-vertical-DFI2_ajd.js";import{t as he}from"./key-round-m9ps8ZDi.js";import{t as ge}from"./loader-circle-D-RkwQwX.js";import{t as U}from"./plus-c3HzV6VX.js";import{t as W}from"./refresh-cw-CoLAai2c.js";import{t as _e}from"./rotate-ccw-fsXoCwyv.js";import{t as G}from"./scroll-text-DjXe21uH.js";import{t as K}from"./shield-alert-psW-CN8y.js";import{t as ve}from"./trash-BHBJn5GS.js";import{t as ye}from"./x-AFrW8zH7.js";import{a as q,c as be,d as xe,f as Se,i as Ce,l as we,n as Te,o as Ee,r as J,s as De,t as Oe,u as ke}from"./sortable.esm-CiuAGjJv.js";import{B as Ae,C as je,G as Me,H as Ne,T as Y,W as Pe,i as Fe,o as Ie,v as Le,w as Re,x as ze}from"./index-CUXoLKaW.js";import{n as Be}from"./ProvidersPage-BtVpzabI.js";var X=e(t(),1),Z=S(),Ve=`astra claude`;function He(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 Ue=e=>e.status===`active`&&e.enabled;function We(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return Ue(e)?n:`${n} · ${t}`}function Ge({enabled:e,gatewayEnabled:t}){let{t:n}=a(),{toast:r}=z(),i=Pe(),s=p(e),c=A(),[l,u]=(0,X.useState)(null),f=s.data?.mode??`gateway`,h=s.data?.accounts??[],_=s.data?.accountId??null??h.find(Ue)?.id??null,y=h.find(e=>e.id===_),x=f===`direct`,S=t&&(x||s.data!=null),w=x&&y?.telemetryEnabled===!0,E=b(w?y?.id:null,w),D=c.isPending,O=e=>c.mutate(e,{onError:e=>r(L(e),`error`)});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(g,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Z.jsx)(v,{label:n(`clients.claudeDirect.mode`),detail:n(x?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Z.jsx)(T,{ariaLabel:n(`clients.claudeDirect.mode`),value:f,onChange:e=>{if(e===f||D||!s.data)return;let t=_??h.find(Ue)?.id??null;if(e===`direct`&&!t){r(n(`clients.claudeDirect.needAccountToast`),`error`);return}O({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`)})]}),s.isLoading&&(0,Z.jsx)(d,{lines:3}),s.isError&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(P,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:L(s.error)})}),S&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(P,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),s.data&&(0,Z.jsx)(g,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:h.length===0?(0,Z.jsx)(m,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Z.jsx)(o,{variant:`primary`,onClick:()=>i(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Z.jsx)(v,{label:n(`clients.claudeDirect.account`),children:(0,Z.jsx)(R,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:_,onChange:e=>{D||e===_||O({mode:f,accountId:e})},options:h.map(e=>({value:e.id,label:We(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!Ue(e)}))})})}),s.data&&x&&y&&(0,Z.jsx)(g,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Z.jsx)(Ke,{command:Ve,copied:l,onCopy:async e=>{await I.copy(e)&&(u(e),r(n(`common.copied`)))}})}),s.data&&x&&y&&(0,Z.jsxs)(g,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Z.jsx)(v,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Z.jsx)(C,{label:n(`clients.claudeDirect.statsConsent`),checked:y.telemetryEnabled,disabled:D,onChange:e=>{y&&!D&&O({mode:f,accountId:y.id,telemetryEnabled:e})}})}),w&&(0,Z.jsx)(qe,{requests:E})]})]})}function Ke({command:e,copied:t,onCopy:n}){let{t:r}=a();return(0,Z.jsx)(v,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Z.jsx)(o,{size:`sm`,icon:(0,Z.jsx)(fe,{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 qe({requests:e}){let{t,locale:n}=a(),r=e.data??[],i=He(r);return e.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(d,{lines:3})}):e.isError?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(P,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:L(e.error)})}):r.length===0?(0,Z.jsx)(m,{icon:(0,Z.jsx)(he,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(v,{label:t(`clients.claudeDirect.statsTotals`,{count:M(i.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:M(i.totalInputTokens),cache:M(r.reduce((e,t)=>e+t.cacheReadTokens,0)),output:M(i.outputTokens)})}),(0,Z.jsx)(v,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:se(r.some(e=>e.estimatedCostNanoUsd!=null)?i.estimatedCostNanoUsd:null)})}),i.failed>0&&(0,Z.jsx)(v,{label:t(`clients.claudeDirect.statsFailedCount`,{count:M(i.failed)}),children:(0,Z.jsx)(s,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),r.map(e=>(0,Z.jsx)(v,{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)(s,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Z.jsx)(s,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Z.jsx)(`span`,{className:`num`,children:[oe(e.occurredAtUtc,n),t(`clients.claudeDirect.tokensDetail`,{input:M(e.inputTokens),output:M(e.outputTokens)}),e.durationMs==null?null:j(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:se(e.estimatedCostNanoUsd)})},e.id))]})}function Je({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=a(),o=(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)(g,{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`),a=t[e.key];return(0,Z.jsxs)(v,{label:n,detail:r,children:[e.type===`bool`&&(0,Z.jsx)(C,{label:n,checked:a===!0,onChange:t=>o(e.key,t)}),e.type===`int`&&(0,Z.jsx)(l,{className:`w-36`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof a==`number`?String(a):``,onChange:t=>{let n=Number.parseInt(t.target.value.replace(/\D/g,``),10);o(e.key,Number.isFinite(n)?n:void 0)}}),e.type===`enum`&&(0,Z.jsx)(R,{ariaLabel:n,value:typeof a==`string`?a:`default`,onChange:t=>o(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-36`})]},e.key)})})}var Ye=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],Xe=e=>typeof e==`string`&&Ye.includes(e);function Ze(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))Xe(r)&&(n[e]=r);return n}function Qe(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(Xe):[]})}return n}function $e(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var et=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{Ar as n,Br as r,Bt as i,C as a,D as o,E as s,Er as c,F as l,Ft as u,H as d,Ht as f,Lt as p,M as m,Nt as h,P as g,Pt as _,R as v,Ri as y,Rt as b,Sn as x,To as S,U as C,Ut as w,V as T,Yr as E,_a as D,_n as O,_r as k,ai as A,ci as ee,gi as te,ht as ne,j as re,li as ie,mn as ae,o as j,r as oe,s as se,u as M,ut as N,wo as ce,x as P}from"./format-Bw-mDeuE.js";import{H as F,L as le,R as I,U as L,V as R,W as z}from"./TrayTitleSource-EINzpQeQ.js";import{t as ue}from"./archive-CiVf7slo.js";import{t as B}from"./check-DKfsh0bQ.js";import{t as de}from"./chevron-right-Bgtn3ze-.js";import{t as V}from"./circle-arrow-up-x7NR55Yx.js";import{t as fe}from"./copy-48gwhhDO.js";import{t as H}from"./external-link-D6jQM2CZ.js";import{t as pe}from"./folder-open-z1RXMZa1.js";import{t as me}from"./grip-vertical-DFI2_ajd.js";import{t as he}from"./key-round-m9ps8ZDi.js";import{t as ge}from"./loader-circle-D-RkwQwX.js";import{t as U}from"./plus-c3HzV6VX.js";import{t as W}from"./refresh-cw-CoLAai2c.js";import{t as _e}from"./rotate-ccw-fsXoCwyv.js";import{t as G}from"./scroll-text-DjXe21uH.js";import{t as K}from"./shield-alert-psW-CN8y.js";import{t as ve}from"./trash-BHBJn5GS.js";import{t as ye}from"./x-AFrW8zH7.js";import{a as q,c as be,d as xe,f as Se,i as Ce,l as we,n as Te,o as Ee,r as J,s as De,t as Oe,u as ke}from"./sortable.esm-KYAcfdq_.js";import{B as Ae,C as je,G as Me,H as Ne,T as Y,W as Pe,i as Fe,o as Ie,v as Le,w as Re,x as ze}from"./index-D2hgi2oA.js";import{n as Be}from"./ProvidersPage-DhvpZLqS.js";var X=e(t(),1),Z=S(),Ve=`astra claude`;function He(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 Ue=e=>e.status===`active`&&e.enabled;function We(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return Ue(e)?n:`${n} · ${t}`}function Ge({enabled:e,gatewayEnabled:t}){let{t:n}=a(),{toast:r}=z(),i=Pe(),s=p(e),c=A(),[l,u]=(0,X.useState)(null),f=s.data?.mode??`gateway`,h=s.data?.accounts??[],_=s.data?.accountId??null??h.find(Ue)?.id??null,y=h.find(e=>e.id===_),x=f===`direct`,S=t&&(x||s.data!=null),w=x&&y?.telemetryEnabled===!0,E=b(w?y?.id:null,w),D=c.isPending,O=e=>c.mutate(e,{onError:e=>r(L(e),`error`)});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(g,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Z.jsx)(v,{label:n(`clients.claudeDirect.mode`),detail:n(x?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Z.jsx)(T,{ariaLabel:n(`clients.claudeDirect.mode`),value:f,onChange:e=>{if(e===f||D||!s.data)return;let t=_??h.find(Ue)?.id??null;if(e===`direct`&&!t){r(n(`clients.claudeDirect.needAccountToast`),`error`);return}O({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`)})]}),s.isLoading&&(0,Z.jsx)(d,{lines:3}),s.isError&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(P,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:L(s.error)})}),S&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(P,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),s.data&&(0,Z.jsx)(g,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:h.length===0?(0,Z.jsx)(m,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Z.jsx)(o,{variant:`primary`,onClick:()=>i(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Z.jsx)(v,{label:n(`clients.claudeDirect.account`),children:(0,Z.jsx)(R,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:_,onChange:e=>{D||e===_||O({mode:f,accountId:e})},options:h.map(e=>({value:e.id,label:We(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!Ue(e)}))})})}),s.data&&x&&y&&(0,Z.jsx)(g,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Z.jsx)(Ke,{command:Ve,copied:l,onCopy:async e=>{await I.copy(e)&&(u(e),r(n(`common.copied`)))}})}),s.data&&x&&y&&(0,Z.jsxs)(g,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Z.jsx)(v,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Z.jsx)(C,{label:n(`clients.claudeDirect.statsConsent`),checked:y.telemetryEnabled,disabled:D,onChange:e=>{y&&!D&&O({mode:f,accountId:y.id,telemetryEnabled:e})}})}),w&&(0,Z.jsx)(qe,{requests:E})]})]})}function Ke({command:e,copied:t,onCopy:n}){let{t:r}=a();return(0,Z.jsx)(v,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Z.jsx)(o,{size:`sm`,icon:(0,Z.jsx)(fe,{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 qe({requests:e}){let{t,locale:n}=a(),r=e.data??[],i=He(r);return e.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(d,{lines:3})}):e.isError?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(P,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:L(e.error)})}):r.length===0?(0,Z.jsx)(m,{icon:(0,Z.jsx)(he,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(v,{label:t(`clients.claudeDirect.statsTotals`,{count:M(i.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:M(i.totalInputTokens),cache:M(r.reduce((e,t)=>e+t.cacheReadTokens,0)),output:M(i.outputTokens)})}),(0,Z.jsx)(v,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:se(r.some(e=>e.estimatedCostNanoUsd!=null)?i.estimatedCostNanoUsd:null)})}),i.failed>0&&(0,Z.jsx)(v,{label:t(`clients.claudeDirect.statsFailedCount`,{count:M(i.failed)}),children:(0,Z.jsx)(s,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),r.map(e=>(0,Z.jsx)(v,{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)(s,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Z.jsx)(s,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Z.jsx)(`span`,{className:`num`,children:[oe(e.occurredAtUtc,n),t(`clients.claudeDirect.tokensDetail`,{input:M(e.inputTokens),output:M(e.outputTokens)}),e.durationMs==null?null:j(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:se(e.estimatedCostNanoUsd)})},e.id))]})}function Je({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=a(),o=(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)(g,{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`),a=t[e.key];return(0,Z.jsxs)(v,{label:n,detail:r,children:[e.type===`bool`&&(0,Z.jsx)(C,{label:n,checked:a===!0,onChange:t=>o(e.key,t)}),e.type===`int`&&(0,Z.jsx)(l,{className:`w-36`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof a==`number`?String(a):``,onChange:t=>{let n=Number.parseInt(t.target.value.replace(/\D/g,``),10);o(e.key,Number.isFinite(n)?n:void 0)}}),e.type===`enum`&&(0,Z.jsx)(R,{ariaLabel:n,value:typeof a==`string`?a:`default`,onChange:t=>o(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-36`})]},e.key)})})}var Ye=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],Xe=e=>typeof e==`string`&&Ye.includes(e);function Ze(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))Xe(r)&&(n[e]=r);return n}function Qe(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(Xe):[]})}return n}function $e(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var et=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
2
2
  `),tt=`auto`,nt=e=>Be.find(t=>t.value===e)?.label??e;function rt({models:e,supported:t,values:n,onChange:r,enabled:i}){let{t:o}=a(),s=(e,t)=>{let i={...n};t===tt?delete i[e]:i[e]=t,r(i)};return(0,Z.jsx)(g,{title:o(`clients.protocols.title`),footer:o(i?`clients.protocols.footerEnabled`:`clients.protocols.footer`),children:e.map(e=>{let r=$e(e,t),i=e.native.filter(e=>t.includes(e));return(0,Z.jsx)(v,{label:e.name,detail:i.length>0?o(`clients.protocols.native`,{protocols:i.map(nt).join(` · `)}):o(`clients.protocols.noNative`),children:(0,Z.jsx)(R,{ariaLabel:e.name,className:`w-60`,value:n[e.id]&&t.includes(n[e.id])?n[e.id]:tt,onChange:t=>s(e.id,t),options:[{value:tt,label:o(r.translated?`clients.protocols.autoTranslated`:`clients.protocols.auto`,{protocol:nt(r.protocol)})},...t.map(e=>({value:e,label:nt(e)}))]})},e.id)})})}function it(e,t){if(!(e instanceof D)||e.status!==409)return null;let n=e.details;return n?.providerName?{title:t(`clients.providerDisabledTitle`,{name:n.providerName}),hint:t(n.pluginOff?`clients.providerDisabledPluginHint`:`clients.providerDisabledHint`)}:null}function at(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 ot=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
3
3
  `),st=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`CLAUDE_CODE_SUBAGENT_MODEL`];function ct(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of st){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var lt=e=>st.map(t=>e[t]??``).join(`
4
4
  `),Q=[`sonnet`,`opus`,`haiku`];function ut(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(`
@@ -1 +1 @@
1
- import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{C as n,D as r,E as i,To as a,V as o,c as s,dt as c,ft as l,l as u,mt as d,o as f,p,pt as m,r as h,u as g,x as _}from"./format-hEAJVPjJ.js";import{M as v,N as y,b}from"./index-CUXoLKaW.js";var x=e(t(),1),S=a(),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}=n(),[t,i]=(0,x.useState)(``),[a,o]=(0,x.useState)(null),[s,u]=(0,x.useState)(``),[d,f]=(0,x.useState)(null),[p,m]=(0,x.useState)(!1),h=(0,x.useCallback)(async t=>{let n=t.trim();if(n){m(!0),f(null);try{o(await l(n)),u(n),T(n)}catch(t){o(null),T(null),f(t instanceof c&&t.status===401?e(`key.invalid`):e(`key.error`,{error:t.message}))}finally{m(!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&&(i(t),h(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)(y,{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`)})]})]}),!a&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h(t)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(v,{label:e(`key.title`),placeholder:e(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:t,"aria-invalid":d?!0:void 0,onChange:e=>i(e.target.value)}),d&&(0,S.jsx)(_,{tone:`danger`,title:d}),(0,S.jsx)(r,{type:`submit`,variant:`primary`,loading:p,disabled:!t.trim(),children:e(`key.submit`)})]}),a&&(0,S.jsx)(D,{info:a,apiKey:s,onForget:()=>{T(null),o(null),i(``)}})]})})}function D({info:e,apiKey:t,onForget:a}){let{t:s,locale:c}=n(),[l,u]=(0,x.useState)(`overview`),d=e.allowedClients==null?s(`key.clientsAny`):e.allowedClients.length===0?s(`key.directOnly`):e.allowedClients.map(e=>b[e]?.name??e).join(`, `),f=[[s(`key.today`),e.usage.today],[s(`key.week`),e.usage.week],[s(`key.month`),e.usage.month],[s(`key.total`),e.usage.total]],m=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)(i,{tone:`orange`,children:s(`key.disabled`)}),(0,S.jsx)(r,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:a,children:s(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[s(`key.clients`),`: `,d,` · `,s(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(o,{ariaLabel:s(`key.title`),value:l,onChange:u,items:[{value:`overview`,label:s(`key.tab.overview`)},{value:`stats`,label:s(`key.tab.stats`)},{value:`requests`,label:s(`key.tab.requests`)}]})]}),l===`stats`&&(0,S.jsx)(k,{apiKey:t}),l===`requests`&&(0,S.jsx)(M,{apiKey:t}),l===`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:s(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:s(`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`?p(t):g(t,!0),n=Math.max(0,Math.min(100,Math.round(e.usedPercent))),r=n>=90?`var(--danger)`:n>=70?`var(--warning)`:`var(--accent)`,i=`${s(`tokens.period.${e.period}`)} · ${s(`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:i}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":n,"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:`${n}%`,background:r}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?s(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?s(`key.resets`,{time:h(e.resetsAt,c)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:s(`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:s(`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:s(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:s(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:s(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:f.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:p(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:g(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:g(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:s(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":s(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${p(e.costUsd)} · ${g(e.requests)} ${s(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${m>0?Math.max(2,e.costUsd/m*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=n(),[r,a]=(0,x.useState)(`7d`),[c,l]=(0,x.useState)(null),[u,m]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return m(null),d(e,r).then(e=>n&&l(e),e=>n&&m(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,r,t]);let h=c?.summary,v=Math.max(...(c?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(o,{ariaLabel:t(`overview.range`),value:r,onChange:a,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),u&&(0,S.jsx)(_,{tone:`danger`,title:u}),!c||!h?!u&&(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:g(h.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:h.requests?s(h.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:p(h.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:f(h.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:c.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${g(e.requests)} ${t(`key.requests`)} · ${p(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:c.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:c.clients.map(e=>({name:e.client?b[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`)}),c.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:c.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(i,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,g(e.count)]})},e.category))})]}),c.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:c.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:r}=n();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:r(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:r(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:r(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:r(`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:g(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?s(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:g(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:p(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:a}=n(),[s,c]=(0,x.useState)(`all`),[l,d]=(0,x.useState)([]),[v,y]=(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 m(e,{before:n,status:s===`failed`?N:void 0});d(e=>n?[...e,...t.items]:t.items),y(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,s,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)(o,{ariaLabel:t(`key.requests.status`),value:s,onChange:c,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(_,{tone:`danger`,title:T}),l.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),l.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:l.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:h(e.time,a),children:u(e.time,a)}),(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?b[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(i,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(i,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[g(e.inputTokens,!0),` / `,g(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:p(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[f(e.ttftMs),` / `,f(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(r,{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{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{C as n,D as r,E as i,To as a,V as o,c as s,dt as c,ft as l,l as u,mt as d,o as f,p,pt as m,r as h,u as g,x as _}from"./format-Bw-mDeuE.js";import{M as v,N as y,b}from"./index-D2hgi2oA.js";var x=e(t(),1),S=a(),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}=n(),[t,i]=(0,x.useState)(``),[a,o]=(0,x.useState)(null),[s,u]=(0,x.useState)(``),[d,f]=(0,x.useState)(null),[p,m]=(0,x.useState)(!1),h=(0,x.useCallback)(async t=>{let n=t.trim();if(n){m(!0),f(null);try{o(await l(n)),u(n),T(n)}catch(t){o(null),T(null),f(t instanceof c&&t.status===401?e(`key.invalid`):e(`key.error`,{error:t.message}))}finally{m(!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&&(i(t),h(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)(y,{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`)})]})]}),!a&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h(t)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(v,{label:e(`key.title`),placeholder:e(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:t,"aria-invalid":d?!0:void 0,onChange:e=>i(e.target.value)}),d&&(0,S.jsx)(_,{tone:`danger`,title:d}),(0,S.jsx)(r,{type:`submit`,variant:`primary`,loading:p,disabled:!t.trim(),children:e(`key.submit`)})]}),a&&(0,S.jsx)(D,{info:a,apiKey:s,onForget:()=>{T(null),o(null),i(``)}})]})})}function D({info:e,apiKey:t,onForget:a}){let{t:s,locale:c}=n(),[l,u]=(0,x.useState)(`overview`),d=e.allowedClients==null?s(`key.clientsAny`):e.allowedClients.length===0?s(`key.directOnly`):e.allowedClients.map(e=>b[e]?.name??e).join(`, `),f=[[s(`key.today`),e.usage.today],[s(`key.week`),e.usage.week],[s(`key.month`),e.usage.month],[s(`key.total`),e.usage.total]],m=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)(i,{tone:`orange`,children:s(`key.disabled`)}),(0,S.jsx)(r,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:a,children:s(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[s(`key.clients`),`: `,d,` · `,s(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(o,{ariaLabel:s(`key.title`),value:l,onChange:u,items:[{value:`overview`,label:s(`key.tab.overview`)},{value:`stats`,label:s(`key.tab.stats`)},{value:`requests`,label:s(`key.tab.requests`)}]})]}),l===`stats`&&(0,S.jsx)(k,{apiKey:t}),l===`requests`&&(0,S.jsx)(M,{apiKey:t}),l===`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:s(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:s(`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`?p(t):g(t,!0),n=Math.max(0,Math.min(100,Math.round(e.usedPercent))),r=n>=90?`var(--danger)`:n>=70?`var(--warning)`:`var(--accent)`,i=`${s(`tokens.period.${e.period}`)} · ${s(`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:i}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":n,"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:`${n}%`,background:r}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?s(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?s(`key.resets`,{time:h(e.resetsAt,c)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:s(`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:s(`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:s(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:s(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:s(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:f.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:p(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:g(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:g(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:s(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":s(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${p(e.costUsd)} · ${g(e.requests)} ${s(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${m>0?Math.max(2,e.costUsd/m*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=n(),[r,a]=(0,x.useState)(`7d`),[c,l]=(0,x.useState)(null),[u,m]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return m(null),d(e,r).then(e=>n&&l(e),e=>n&&m(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,r,t]);let h=c?.summary,v=Math.max(...(c?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(o,{ariaLabel:t(`overview.range`),value:r,onChange:a,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),u&&(0,S.jsx)(_,{tone:`danger`,title:u}),!c||!h?!u&&(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:g(h.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:h.requests?s(h.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:p(h.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:f(h.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:c.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${g(e.requests)} ${t(`key.requests`)} · ${p(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:c.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:c.clients.map(e=>({name:e.client?b[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`)}),c.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:c.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(i,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,g(e.count)]})},e.category))})]}),c.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:c.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:r}=n();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:r(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:r(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:r(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:r(`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:g(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?s(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:g(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:p(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:a}=n(),[s,c]=(0,x.useState)(`all`),[l,d]=(0,x.useState)([]),[v,y]=(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 m(e,{before:n,status:s===`failed`?N:void 0});d(e=>n?[...e,...t.items]:t.items),y(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,s,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)(o,{ariaLabel:t(`key.requests.status`),value:s,onChange:c,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(_,{tone:`danger`,title:T}),l.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),l.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:l.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:h(e.time,a),children:u(e.time,a)}),(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?b[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(i,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(i,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[g(e.inputTokens,!0),` / `,g(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:p(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[f(e.ttftMs),` / `,f(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(r,{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,9 +1,9 @@
1
- import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{An as n,Bn as r,C as i,Cn as a,D as o,E as s,F as c,Gn as l,H as u,Ir as d,Ji as f,Jt as p,Kn as m,L as h,M as g,N as _,Ot as v,P as y,R as b,Ri as x,To as S,U as C,V as w,Vn as T,Vt as E,W as D,Xi as O,Yi as k,_i as A,ki as j,kt as M,nn as N,o as P,qn as F,qt as I,r as L,rn as R,x as z}from"./format-hEAJVPjJ.js";import{B,H as V,R as H,U,V as W,W as G}from"./TrayTitleSource-U2fI0rGJ.js";import{t as K}from"./copy-48gwhhDO.js";import{t as q}from"./ellipsis-CidyZaW2.js";import{t as ee}from"./key-round-m9ps8ZDi.js";import{t as te}from"./pencil-CpF9MxGZ.js";import{t as ne}from"./plug-DKn7uRWT.js";import{t as J}from"./plus-c3HzV6VX.js";import{t as re}from"./shield-check-CD30JqBi.js";import{t as ie}from"./terminal-B-mEYDi0.js";import{t as Y}from"./trash-BHBJn5GS.js";import{t as ae}from"./zap-BiWUNaKt.js";import{B as oe,v as se}from"./index-CUXoLKaW.js";var X=e(t(),1),Z=S(),ce=[{kind:`claude-code`,name:`Claude Code`},{kind:`codex`,name:`Codex`}],le={missing:`neutral`,applied:`green`,drifted:`orange`,conflict:`red`};function ue(){let{t:e}=i(),t=E(),n=x(),r=(n.data??[]).filter(e=>e.enabled&&(e.mcpServers?.length??0)>0);return(0,Z.jsxs)(y,{title:e(`mcp.clients.title`),footer:e(`mcp.clients.stdio`),children:[(0,Z.jsx)(`p`,{className:`px-4 pt-3 text-[12px] text-[var(--text-muted)]`,children:e(`mcp.clients.hint`)}),t.isLoading&&(0,Z.jsx)(u,{lines:2}),t.data&&r.length===0&&n.data&&(0,Z.jsx)(`p`,{className:`px-4 py-2 text-[12px] text-[var(--text-muted)]`,children:e(`mcp.clients.noToken`)}),t.data&&ce.map(e=>{let n=t.data.find(t=>t.kind===e.kind);return n?(0,Z.jsx)(de,{name:e.name,entry:n,tokens:r.map(e=>({value:e.id,label:e.name}))},e.kind):null})]})}function de({name:e,entry:t,tokens:n}){let{t:r}=i(),{toast:a,confirm:c}=G(),l=v(),u=d(),[f,p]=(0,X.useState)(null),m=f??(n.some(e=>e.value===t.tokenId)?t.tokenId??null:n[0]?.value??null),h=l.isPending||u.isPending,g=t.state===`applied`||t.state===`drifted`,_=n=>{m&&l.mutate({kind:t.kind,tokenId:m,force:n},{onSuccess:()=>a(r(`mcp.clients.applied`,{client:e}),`success`),onError:e=>a(U(e),`error`)})},y=async n=>{(!n||await c({title:r(`mcp.clients.forceRemove`),detail:t.file,destructive:!0,confirmLabel:r(`mcp.clients.forceRemove`)}))&&u.mutate({kind:t.kind,force:n},{onSuccess:()=>a(r(`mcp.clients.removed`,{client:e}),`success`),onError:e=>a(U(e),`error`)})},x=(0,Z.jsxs)(`span`,{className:`block whitespace-normal`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:t.file,children:t.file}),t.state===`applied`&&t.tokenName&&(0,Z.jsx)(`span`,{className:`block`,children:r(`mcp.clients.usesToken`,{name:t.tokenName})}),t.error&&(0,Z.jsx)(`span`,{className:`block text-[var(--danger)]`,children:r(`mcp.clients.unreadable`,{error:t.error})})]});return(0,Z.jsxs)(`div`,{className:`border-t border-[var(--border)] first:border-t-0`,children:[(0,Z.jsxs)(b,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(0,Z.jsx)(s,{tone:le[t.state],children:r(`mcp.clients.state.${t.state}`)})]}),detail:x,children:[n.length>0&&(0,Z.jsx)(W,{className:`w-44`,ariaLabel:`${e} ${r(`mcp.clients.token`)}`,placeholder:r(`mcp.clients.pickToken`),value:m,onChange:p,options:n,disabled:h}),(0,Z.jsx)(o,{variant:`primary`,disabled:h||!m||t.state===`conflict`,onClick:()=>_(!1),children:r(g?`mcp.clients.replace`:`mcp.clients.apply`)}),g&&(0,Z.jsx)(o,{disabled:h,onClick:()=>void y(t.state===`drifted`),children:t.state===`drifted`?r(`mcp.clients.forceRemove`):r(`mcp.clients.remove`)})]}),!t.gatewayEnabled&&t.state!==`missing`&&(0,Z.jsx)(z,{tone:`warning`,className:`mx-4 mb-3`,title:r(`mcp.clients.gatewayOff`)}),!t.gatewayEnabled&&t.state===`missing`&&(0,Z.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:r(`mcp.clients.gatewayOff`)}),t.state===`conflict`&&!t.error&&(0,Z.jsx)(z,{tone:`warning`,className:`mx-4 mb-3`,title:r(`mcp.clients.conflict`)}),t.state===`drifted`&&(0,Z.jsxs)(`div`,{className:`mx-4 mb-3 flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`mcp.clients.drifted`)}),(0,Z.jsx)(o,{size:`sm`,disabled:h||!m,onClick:()=>_(!0),children:r(`mcp.clients.force`)})]})]})}var Q=[{kind:`claude-code`,name:`Claude Code`},{kind:`codex`,name:`Codex`},{kind:`gemini-cli`,name:`Gemini CLI`},{kind:`qwen-code`,name:`Qwen Code`},{kind:`opencode`,name:`OpenCode`}],fe={missing:`neutral`,applied:`green`,drifted:`orange`,conflict:`red`},$=e=>Q.find(t=>t.kind===e)?.name??e,pe=e=>e.split(`
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{An as n,Bn as r,C as i,Cn as a,D as o,E as s,F as c,Gn as l,H as u,Ir as d,Ji as f,Jt as p,Kn as m,L as h,M as g,N as _,Ot as v,P as y,R as b,Ri as x,To as S,U as C,V as w,Vn as T,Vt as E,W as D,Xi as O,Yi as k,_i as A,ki as j,kt as M,nn as N,o as P,qn as F,qt as I,r as L,rn as R,x as z}from"./format-Bw-mDeuE.js";import{B,H as V,R as H,U,V as W,W as G}from"./TrayTitleSource-EINzpQeQ.js";import{t as K}from"./copy-48gwhhDO.js";import{t as q}from"./ellipsis-CidyZaW2.js";import{t as ee}from"./key-round-m9ps8ZDi.js";import{t as te}from"./pencil-CpF9MxGZ.js";import{t as ne}from"./plug-DKn7uRWT.js";import{t as J}from"./plus-c3HzV6VX.js";import{t as re}from"./shield-check-CD30JqBi.js";import{t as ie}from"./terminal-B-mEYDi0.js";import{t as Y}from"./trash-BHBJn5GS.js";import{t as ae}from"./zap-BiWUNaKt.js";import{B as oe,v as se}from"./index-D2hgi2oA.js";var X=e(t(),1),Z=S(),ce=[{kind:`claude-code`,name:`Claude Code`},{kind:`codex`,name:`Codex`}],le={missing:`neutral`,applied:`green`,drifted:`orange`,conflict:`red`};function ue(){let{t:e}=i(),t=E(),n=x(),r=(n.data??[]).filter(e=>e.enabled&&(e.mcpServers?.length??0)>0);return(0,Z.jsxs)(y,{title:e(`mcp.clients.title`),footer:e(`mcp.clients.stdio`),children:[(0,Z.jsx)(`p`,{className:`px-4 pt-3 text-[12px] text-[var(--text-muted)]`,children:e(`mcp.clients.hint`)}),t.isLoading&&(0,Z.jsx)(u,{lines:2}),t.data&&r.length===0&&n.data&&(0,Z.jsx)(`p`,{className:`px-4 py-2 text-[12px] text-[var(--text-muted)]`,children:e(`mcp.clients.noToken`)}),t.data&&ce.map(e=>{let n=t.data.find(t=>t.kind===e.kind);return n?(0,Z.jsx)(de,{name:e.name,entry:n,tokens:r.map(e=>({value:e.id,label:e.name}))},e.kind):null})]})}function de({name:e,entry:t,tokens:n}){let{t:r}=i(),{toast:a,confirm:c}=G(),l=v(),u=d(),[f,p]=(0,X.useState)(null),m=f??(n.some(e=>e.value===t.tokenId)?t.tokenId??null:n[0]?.value??null),h=l.isPending||u.isPending,g=t.state===`applied`||t.state===`drifted`,_=n=>{m&&l.mutate({kind:t.kind,tokenId:m,force:n},{onSuccess:()=>a(r(`mcp.clients.applied`,{client:e}),`success`),onError:e=>a(U(e),`error`)})},y=async n=>{(!n||await c({title:r(`mcp.clients.forceRemove`),detail:t.file,destructive:!0,confirmLabel:r(`mcp.clients.forceRemove`)}))&&u.mutate({kind:t.kind,force:n},{onSuccess:()=>a(r(`mcp.clients.removed`,{client:e}),`success`),onError:e=>a(U(e),`error`)})},x=(0,Z.jsxs)(`span`,{className:`block whitespace-normal`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:t.file,children:t.file}),t.state===`applied`&&t.tokenName&&(0,Z.jsx)(`span`,{className:`block`,children:r(`mcp.clients.usesToken`,{name:t.tokenName})}),t.error&&(0,Z.jsx)(`span`,{className:`block text-[var(--danger)]`,children:r(`mcp.clients.unreadable`,{error:t.error})})]});return(0,Z.jsxs)(`div`,{className:`border-t border-[var(--border)] first:border-t-0`,children:[(0,Z.jsxs)(b,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(0,Z.jsx)(s,{tone:le[t.state],children:r(`mcp.clients.state.${t.state}`)})]}),detail:x,children:[n.length>0&&(0,Z.jsx)(W,{className:`w-44`,ariaLabel:`${e} ${r(`mcp.clients.token`)}`,placeholder:r(`mcp.clients.pickToken`),value:m,onChange:p,options:n,disabled:h}),(0,Z.jsx)(o,{variant:`primary`,disabled:h||!m||t.state===`conflict`,onClick:()=>_(!1),children:r(g?`mcp.clients.replace`:`mcp.clients.apply`)}),g&&(0,Z.jsx)(o,{disabled:h,onClick:()=>void y(t.state===`drifted`),children:t.state===`drifted`?r(`mcp.clients.forceRemove`):r(`mcp.clients.remove`)})]}),!t.gatewayEnabled&&t.state!==`missing`&&(0,Z.jsx)(z,{tone:`warning`,className:`mx-4 mb-3`,title:r(`mcp.clients.gatewayOff`)}),!t.gatewayEnabled&&t.state===`missing`&&(0,Z.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:r(`mcp.clients.gatewayOff`)}),t.state===`conflict`&&!t.error&&(0,Z.jsx)(z,{tone:`warning`,className:`mx-4 mb-3`,title:r(`mcp.clients.conflict`)}),t.state===`drifted`&&(0,Z.jsxs)(`div`,{className:`mx-4 mb-3 flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`mcp.clients.drifted`)}),(0,Z.jsx)(o,{size:`sm`,disabled:h||!m,onClick:()=>_(!0),children:r(`mcp.clients.force`)})]})]})}var Q=[{kind:`claude-code`,name:`Claude Code`},{kind:`codex`,name:`Codex`},{kind:`gemini-cli`,name:`Gemini CLI`},{kind:`qwen-code`,name:`Qwen Code`},{kind:`opencode`,name:`OpenCode`}],fe={missing:`neutral`,applied:`green`,drifted:`orange`,conflict:`red`},$=e=>Q.find(t=>t.kind===e)?.name??e,pe=e=>e.split(`
2
2
  `).map(e=>e.replace(/\r$/,``)).filter(e=>e.trim()!==``);function me(e){let t={};for(let n of e.split(`
3
3
  `)){let e=n.replace(/\r$/,``);if(e.trim()===``)continue;let r=e.indexOf(`=`);if(r<=0)return null;t[e.slice(0,r).trim()]=e.slice(r+1)}return t}function he(e){let t={};for(let n of e.split(`
4
4
  `)){let e=n.replace(/\r$/,``);if(e.trim()===``)continue;let r=e.indexOf(`:`);if(r<=0)return null;t[e.slice(0,r).trim()]=e.slice(r+1).trim()}return t}function ge(){let{t:e}=i(),{toast:t,confirm:n}=G(),r=T(),a=M(),s=N(),[c,l]=(0,X.useState)(null),[d,f]=(0,X.useState)(!1),p=async r=>{await n({title:e(`mcp.local.deleteTitle`,{name:r.name}),detail:e(`mcp.local.deleteDetail`),destructive:!0,confirmLabel:e(`common.delete`)})&&s.mutate({id:r.id},{onSuccess:()=>t(e(`mcp.local.deleted`,{name:r.name}),`success`),onError:e=>t(U(e),`error`)})},m=(n,r)=>a.mutate({id:n.id,force:r},{onSuccess:()=>t(e(`mcp.local.applied`,{name:n.name}),`success`),onError:e=>t(U(e),`error`)});return(0,Z.jsxs)(`section`,{className:`mt-6`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 px-1`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-semibold`,children:e(`mcp.local.title`)}),(0,Z.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:e(`mcp.local.hint`)})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsx)(o,{icon:(0,Z.jsx)(oe,{className:`size-4`}),onClick:()=>f(!0),children:e(`mcp.local.import`)}),(0,Z.jsx)(o,{variant:`primary`,icon:(0,Z.jsx)(J,{className:`size-4`}),onClick:()=>l(`new`),children:e(`mcp.local.add`)})]})]}),r.isLoading?(0,Z.jsx)(u,{}):!r.data||r.data.length===0?(0,Z.jsx)(g,{icon:(0,Z.jsx)(ie,{className:`size-6`}),title:e(`mcp.local.emptyTitle`),detail:e(`mcp.local.emptyDetail`)}):(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:r.data.map(e=>(0,Z.jsx)(_e,{server:e,busy:a.isPending||s.isPending,onEdit:()=>l(e),onDelete:()=>void p(e),onRewrite:t=>m(e,t)},e.id))}),(0,Z.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:e(`mcp.local.footer`)}),(0,Z.jsx)(ye,{server:c,onClose:()=>l(null)}),(0,Z.jsx)(be,{open:d,onClose:()=>f(!1)})]})}function _e({server:e,busy:t,onEdit:n,onDelete:r,onRewrite:a}){let{t:c}=i(),l=e.transport===`http`,u=l?e.url:[e.command,...e.args].join(` `),d=l?e.headerNames.length:e.envNames.length,f=e.placements.some(e=>e.wanted&&e.state!==`applied`);return(0,Z.jsxs)(`div`,{className:`px-1`,children:[(0,Z.jsxs)(b,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.name}),!e.enabled&&(0,Z.jsx)(s,{tone:`neutral`,children:c(`mcp.local.off`)})]}),detail:(0,Z.jsxs)(`span`,{className:`block truncate font-mono text-[11px]`,title:u,children:[u,d>0&&(0,Z.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[` · `,c(l?`mcp.local.headerCount`:`mcp.local.envCount`,{count:d})]})]}),children:[f&&(0,Z.jsx)(o,{size:`sm`,disabled:t,onClick:()=>a(!1),children:c(`mcp.local.rewrite`)}),(0,Z.jsx)(o,{size:`sm`,icon:(0,Z.jsx)(te,{className:`size-3.5`}),onClick:n,"aria-label":c(`common.edit`)}),(0,Z.jsx)(o,{size:`sm`,icon:(0,Z.jsx)(Y,{className:`size-3.5`}),disabled:t,onClick:r,"aria-label":c(`common.delete`)})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-3 px-4 pb-3`,children:e.placements.map(e=>(0,Z.jsx)(ve,{placement:e,onForce:()=>a(!0)},e.kind))})]})}function ve({placement:e,onForce:t}){let{t:n}=i();return!e.wanted&&e.state===`missing`?null:(0,Z.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px]`,title:e.file,children:[$(e.kind),(0,Z.jsx)(s,{tone:fe[e.state],children:n(`mcp.local.state.${e.state}`)}),e.state===`drifted`&&e.wanted&&(0,Z.jsx)(o,{size:`sm`,onClick:t,children:n(`mcp.clients.force`)})]}),e.error&&(0,Z.jsx)(`span`,{className:`max-w-md whitespace-normal text-[11px] text-[var(--danger)]`,children:e.error})]})}function ye({server:e,onClose:t}){let{t:n}=i(),{toast:r}=G(),a=I(),s=f(),l=e&&e!==`new`?e:null,[u,d]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(``),[v,y]=(0,X.useState)(``),[x,S]=(0,X.useState)(`stdio`),[T,E]=(0,X.useState)(``),[O,k]=(0,X.useState)(``),[A,j]=(0,X.useState)([]),[M,N]=(0,X.useState)(!0);(0,X.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;d(t?.name??``),m(t?.command??``),g((t?.args??[]).join(`
5
5
  `)),y(``),k(``),S(t?.transport??`stdio`),E(t?.url??``),j(t?.clients??Q.map(e=>e.kind)),N(t?.enabled??!0)},[e]);let P=x===`http`,F=l?.transport===`stdio`&&x===`stdio`&&l.envNames.length>0,L=l?.transport===`http`&&x===`http`&&l.headerNames.length>0,R=me(v),B=he(O),H=a.isPending||s.isPending,W=u.trim()!==``&&(P?T.trim()!==``&&B!==null:p.trim()!==``&&R!==null),K=()=>{let e=P?{name:u.trim(),transport:x,url:T.trim(),enabled:M,clients:A}:{name:u.trim(),transport:x,command:p.trim(),args:pe(h),enabled:M,clients:A},i=l?.transport===x;P&&B&&(O.trim()!==``||!i)&&(e.headers=B),!P&&R&&(v.trim()!==``||!i)&&(e.env=R);let o={onSuccess:e=>{t(),r(n(l?`mcp.local.saved`:`mcp.local.created`,{name:e.name}),`success`)},onError:e=>r(U(e),`error`)};l?s.mutate({id:l.id,body:e},o):a.mutate(e,o)},q=(e,t)=>j(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e));return(0,Z.jsx)(V,{open:e!==null,onOpenChange:e=>!e&&t(),width:560,title:l?n(`mcp.local.editTitle`,{name:l.name}):n(`mcp.local.addTitle`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{onClick:t,children:n(`common.cancel`)}),(0,Z.jsx)(o,{variant:`primary`,disabled:!W,loading:H,onClick:K,children:n(`common.save`)})]}),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(_,{label:n(`mcp.local.name`),hint:n(`mcp.local.nameHint`),children:(0,Z.jsx)(c,{mono:!0,value:u,maxLength:32,placeholder:`filesystem`,onChange:e=>d(e.target.value)})}),(0,Z.jsx)(_,{label:n(`mcp.local.transport`),children:(0,Z.jsx)(w,{ariaLabel:n(`mcp.local.transport`),value:x,onChange:S,items:[{value:`stdio`,label:n(`mcp.local.transport.stdio`)},{value:`http`,label:n(`mcp.local.transport.http`)}]})}),P?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{label:n(`mcp.local.url`),hint:n(`mcp.local.urlHint`),children:(0,Z.jsx)(c,{mono:!0,value:T,placeholder:`https://mcp.example.com/mcp`,onChange:e=>E(e.target.value)})}),(0,Z.jsx)(_,{label:n(`mcp.local.headers`),hint:L?n(`mcp.local.headersKept`,{names:l.headerNames.join(`, `)}):n(`mcp.local.headersHint`),children:(0,Z.jsx)(D,{mono:!0,rows:3,value:O,placeholder:`Authorization: Bearer ...`,onChange:e=>k(e.target.value)})}),B===null&&(0,Z.jsx)(z,{tone:`warning`,title:n(`mcp.local.headersInvalid`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{label:n(`mcp.local.command`),children:(0,Z.jsx)(c,{mono:!0,value:p,placeholder:`npx`,onChange:e=>m(e.target.value)})}),(0,Z.jsx)(_,{label:n(`mcp.local.args`),hint:n(`mcp.local.argsHint`),children:(0,Z.jsx)(D,{mono:!0,rows:4,value:h,placeholder:`-y
6
6
  @modelcontextprotocol/server-filesystem
7
7
  /Users/me/docs`,onChange:e=>g(e.target.value)})}),(0,Z.jsx)(_,{label:n(`mcp.local.env`),hint:F?n(`mcp.local.envKept`,{names:l.envNames.join(`, `)}):n(`mcp.local.envHint`),children:(0,Z.jsx)(D,{mono:!0,rows:3,value:v,placeholder:`API_KEY=...`,onChange:e=>y(e.target.value)})}),R===null&&(0,Z.jsx)(z,{tone:`warning`,title:n(`mcp.local.envInvalid`)})]}),(0,Z.jsx)(_,{label:n(`mcp.local.clients`),hint:n(`mcp.local.clientsHint`),children:(0,Z.jsx)(`div`,{className:`grid gap-1`,children:Q.map(e=>(0,Z.jsx)(b,{label:e.name,children:(0,Z.jsx)(C,{checked:A.includes(e.kind),label:e.name,onChange:t=>q(e.kind,t)})},e.kind))})}),(0,Z.jsx)(b,{label:n(`mcp.local.enabled`),children:(0,Z.jsx)(C,{checked:M,label:n(`mcp.local.enabled`),onChange:N})})]})})}function be({open:e,onClose:t}){let{t:a}=i(),{toast:c}=G(),l=r(e),d=n(),[f,p]=(0,X.useState)(new Set),m=e=>`${e.kind}\u0000${e.name}`;(0,X.useEffect)(()=>{e&&p(new Set)},[e]);let h=(l.data??[]).filter(e=>e.importable&&!e.taken),g=(e,t)=>p(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,Z.jsx)(V,{open:e,onOpenChange:e=>!e&&t(),width:560,title:a(`mcp.local.importTitle`),description:a(`mcp.local.importHint`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{onClick:t,children:a(`common.cancel`)}),(0,Z.jsx)(o,{variant:`primary`,disabled:f.size===0,loading:d.isPending,onClick:()=>{let e=h.filter(e=>f.has(m(e))).map(e=>({kind:e.kind,name:e.name}));d.mutate(e,{onSuccess:e=>{let n=a(`mcp.local.importDone`,{count:e.imported.length});c(e.skipped.length>0?`${n} ${a(`mcp.local.importSkipped`,{count:e.skipped.length,reasons:[...new Set(e.skipped.map(e=>e.reason))].join(`; `)})}`:n,e.imported.length>0?`success`:`error`),t()},onError:e=>c(U(e),`error`)})},children:a(`mcp.local.importRun`)})]}),children:l.isLoading?(0,Z.jsx)(u,{}):!l.data||l.data.length===0?(0,Z.jsx)(`p`,{className:`text-[13px] text-[var(--text-muted)]`,children:a(`mcp.local.importEmpty`)}):(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[l.data.map(e=>{let t=m(e),n=!e.importable||e.taken;return(0,Z.jsx)(b,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.name}),(0,Z.jsx)(s,{tone:`neutral`,children:$(e.kind)})]}),detail:(0,Z.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:e.summary,children:n?e.taken?a(`mcp.local.importTaken`):e.reason??``:e.summary}),children:(0,Z.jsx)(C,{checked:f.has(t),disabled:n,label:`${e.name} ${$(e.kind)}`,onChange:e=>g(t,e)})},t)}),(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--text-muted)]`,children:a(`mcp.local.importSecrets`)})]})})}var xe={unknown:`neutral`,ok:`green`,needs_auth:`orange`,auth_error:`red`,unreachable:`red`,version_unsupported:`red`};function Se(){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ce,{}),(0,Z.jsx)(ue,{}),(0,Z.jsx)(ge,{}),(0,Z.jsx)(we,{}),(0,Z.jsx)(De,{})]})}function Ce(){let{t:e}=i(),{toast:t}=G(),n=F(),r=O(),[a,s]=(0,X.useState)(``),c=n.data?.allowedOrigins.join(`
8
- `)??``;if((0,X.useEffect)(()=>s(c),[c]),!n.data)return(0,Z.jsx)(u,{});let l=n.data,d=n=>r.mutate(n,{onSuccess:()=>t(e(`common.saved`),`success`),onError:e=>t(U(e),`error`)});return(0,Z.jsxs)(y,{title:e(`mcp.gateway.title`),children:[(0,Z.jsx)(b,{label:e(`mcp.gateway.enable`),detail:e(`mcp.gateway.enableHint`),children:(0,Z.jsx)(C,{checked:l.enabled,disabled:r.isPending,label:e(`mcp.gateway.enable`),onChange:e=>d({enabled:e})})}),(0,Z.jsxs)(b,{label:e(`mcp.gateway.endpoint`),detail:(0,Z.jsx)(`span`,{className:`block whitespace-normal`,children:e(`mcp.gateway.endpointHint`)}),children:[(0,Z.jsx)(`code`,{className:`max-w-[22rem] truncate rounded bg-[var(--surface-muted,transparent)] px-1.5 py-0.5 font-mono text-[12px]`,title:l.endpoint,children:l.endpoint}),(0,Z.jsx)(o,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(K,{className:`size-3.5`}),"aria-label":e(`mcp.gateway.copyEndpoint`),onClick:()=>void H.copy(l.endpoint).then(n=>n&&t(e(`mcp.gateway.copied`),`success`))})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2 px-4 py-3`,children:[(0,Z.jsx)(_,{label:e(`mcp.gateway.origins`),hint:e(`mcp.gateway.originsHint`),children:(0,Z.jsx)(D,{mono:!0,rows:3,value:a,placeholder:`https://app.example.com`,onChange:e=>s(e.target.value)})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{size:`sm`,disabled:a.trim()===c.trim()||r.isPending,onClick:()=>d({allowedOrigins:a.split(`
8
+ `)??``;if((0,X.useEffect)(()=>s(c),[c]),!n.data)return(0,Z.jsx)(u,{});let l=n.data,d=n=>r.mutate(n,{onSuccess:()=>t(e(`common.saved`),`success`),onError:e=>t(U(e),`error`)});return(0,Z.jsxs)(y,{title:e(`mcp.gateway.title`),children:[(0,Z.jsx)(b,{label:e(`mcp.gateway.enable`),detail:e(`mcp.gateway.enableHint`),children:(0,Z.jsx)(C,{checked:l.enabled,disabled:r.isPending,label:e(`mcp.gateway.enable`),onChange:e=>d({enabled:e})})}),(0,Z.jsx)(b,{label:e(`mcp.gateway.remoteAdmin`),detail:e(`mcp.gateway.remoteAdminHint`),children:(0,Z.jsx)(C,{checked:l.allowRemoteAdmin,disabled:r.isPending,label:e(`mcp.gateway.remoteAdmin`),onChange:e=>d({allowRemoteAdmin:e})})}),(0,Z.jsxs)(b,{label:e(`mcp.gateway.endpoint`),detail:(0,Z.jsx)(`span`,{className:`block whitespace-normal`,children:e(`mcp.gateway.endpointHint`)}),children:[(0,Z.jsx)(`code`,{className:`max-w-[22rem] truncate rounded bg-[var(--surface-muted,transparent)] px-1.5 py-0.5 font-mono text-[12px]`,title:l.endpoint,children:l.endpoint}),(0,Z.jsx)(o,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(K,{className:`size-3.5`}),"aria-label":e(`mcp.gateway.copyEndpoint`),onClick:()=>void H.copy(l.endpoint).then(n=>n&&t(e(`mcp.gateway.copied`),`success`))})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2 px-4 py-3`,children:[(0,Z.jsx)(_,{label:e(`mcp.gateway.origins`),hint:e(`mcp.gateway.originsHint`),children:(0,Z.jsx)(D,{mono:!0,rows:3,value:a,placeholder:`https://app.example.com`,onChange:e=>s(e.target.value)})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{size:`sm`,disabled:a.trim()===c.trim()||r.isPending,onClick:()=>d({allowedOrigins:a.split(`
9
9
  `).map(e=>e.trim()).filter(Boolean)}),children:e(`mcp.gateway.originsSave`)})})]})]})}function we(){let{t:e}=i(),{toast:t,confirm:n}=G(),r=m(),s=j(),c=A(),l=a(),d=R(),[f,p]=(0,X.useState)(null),[h,_]=(0,X.useState)(null),v=n=>s.mutate(n.id,{onSuccess:r=>{r.ok?_({server:n,result:r}):t(e(`mcp.server.testFailed`,{message:r.message??r.status}),`error`)},onError:e=>t(U(e),`error`)}),y=n=>c.mutate(n.id,{onSuccess:n=>{n.authorizationUrl?(window.open(n.authorizationUrl,`_blank`,`noopener`),t(e(`mcp.server.authorizeOpened`),`success`)):t(n.message??e(`mcp.server.authorizeNotNeeded`),`success`)},onError:e=>t(U(e),`error`)}),b=async r=>{await n({title:e(`mcp.server.forgetConfirm`,{name:r.name}),detail:e(`mcp.server.forgetDetail`),confirmLabel:e(`mcp.server.forget`),destructive:!0})&&l.mutate(r.id,{onSuccess:()=>t(e(`mcp.server.forgotten`),`success`),onError:e=>t(U(e),`error`)})},x=async r=>{await n({title:e(`mcp.server.deleteConfirm`,{name:r.name}),detail:e(`mcp.server.deleteDetail`),confirmLabel:e(`common.delete`),destructive:!0})&&d.mutate(r.id,{onSuccess:()=>t(e(`mcp.server.deleted`,{name:r.name}),`success`),onError:e=>t(U(e),`error`)})};return(0,Z.jsxs)(`section`,{className:`mb-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between px-1`,children:[(0,Z.jsx)(`h3`,{className:`text-[12px] font-medium text-[var(--text-secondary)]`,children:e(`mcp.servers.title`)}),(0,Z.jsx)(o,{size:`sm`,variant:`primary`,icon:(0,Z.jsx)(J,{className:`size-3.5`}),onClick:()=>p(`new`),children:e(`mcp.servers.add`)})]}),r.data===void 0?(0,Z.jsx)(u,{}):r.data.length===0?(0,Z.jsx)(g,{icon:(0,Z.jsx)(ne,{className:`size-6`}),title:e(`mcp.servers.emptyTitle`),detail:e(`mcp.servers.emptyDetail`)}):(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:r.data.map(e=>(0,Z.jsx)(Te,{server:e,busy:s.isPending&&s.variables===e.id,onTest:()=>v(e),onEdit:()=>p(e),onAuthorize:()=>y(e),onForget:()=>void b(e),onDelete:()=>void x(e)},e.id))}),(0,Z.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:e(`mcp.servers.localOnly`)}),(0,Z.jsx)(Ee,{server:f,onClose:()=>p(null)}),(0,Z.jsx)(V,{open:h!==null,onOpenChange:e=>!e&&_(null),title:e(`mcp.server.testToolsTitle`,{name:h?.server.name??``}),description:h?e(`mcp.server.testOk`,{count:h.result.toolCount}):void 0,footer:(0,Z.jsx)(o,{onClick:()=>_(null),children:e(`common.close`)}),children:(0,Z.jsx)(`ul`,{className:`max-h-72 overflow-auto font-mono text-[12px] text-[var(--text-secondary)]`,children:h?.result.tools.map(e=>(0,Z.jsx)(`li`,{className:`truncate py-0.5`,children:e},e))})})]})}function Te({server:e,busy:t,onTest:n,onEdit:r,onAuthorize:a,onForget:c,onDelete:l}){let{t:u,locale:d}=i(),f=e.authType===`oauth`,p=e.oauth?.authorized===!0,m=[e.slug,e.protocolVersion?u(`mcp.server.protocol`,{version:e.protocolVersion}):null,u(`mcp.server.boundTokens`,{count:e.boundTokens}),e.checkedAt?L(e.checkedAt,d):null].filter(Boolean).join(` · `);return(0,Z.jsxs)(b,{label:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Z.jsx)(s,{tone:xe[e.status],title:e.statusMessage??void 0,children:u(`mcp.status.${e.status}`)}),!e.enabled&&(0,Z.jsx)(s,{children:u(`mcp.server.disabledBadge`)})]}),detail:(0,Z.jsxs)(`span`,{className:`block whitespace-normal`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.url}),(0,Z.jsx)(`span`,{className:`block`,children:m}),f&&p&&e.oauth?.issuer&&(0,Z.jsx)(`span`,{className:`block`,children:u(`mcp.server.authorizedBy`,{issuer:e.oauth.issuer})})]}),children:[f&&(0,Z.jsx)(o,{size:`sm`,variant:p?`glass`:`primary`,icon:(0,Z.jsx)(re,{className:`size-3.5`}),onClick:a,children:u(p?`mcp.server.reauthorize`:`mcp.server.authorize`)}),(0,Z.jsx)(o,{size:`sm`,icon:(0,Z.jsx)(ae,{className:`size-3.5`}),loading:t,onClick:n,children:u(`mcp.server.test`)}),(0,Z.jsx)(B,{label:e.name,iconOnly:!0,icon:(0,Z.jsx)(q,{className:`size-4`}),items:[{id:`edit`,label:u(`common.edit`),icon:(0,Z.jsx)(te,{className:`size-3.5`}),onSelect:r},...f&&p?[{id:`forget`,label:u(`mcp.server.forget`),icon:(0,Z.jsx)(ee,{className:`size-3.5`}),onSelect:c}]:[],{id:`delete`,label:u(`common.delete`),icon:(0,Z.jsx)(Y,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:l}]})]})}function Ee({server:e,onClose:t}){let{t:n}=i(),{toast:r}=G(),a=p(),s=k(),l=e&&e!==`new`?e:null,[u,d]=(0,X.useState)(``),[f,m]=(0,X.useState)(``),[g,v]=(0,X.useState)(``),[y,x]=(0,X.useState)(`http`),[S,T]=(0,X.useState)(`none`),[E,D]=(0,X.useState)([]),[O,A]=(0,X.useState)(60),[j,M]=(0,X.useState)(!0);(0,X.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;d(t?.name??``),m(t?.slug??``),v(t?.url??``),x(t?.transport??`http`),T(t?.authType??`none`),D((t?.headerNames??[]).map(e=>({name:e,value:``,kept:!0}))),A(t?.timeoutSeconds??60),M(t?.enabled??!0)},[e]);let N=a.isPending||s.isPending,P=u.trim()!==``&&g.trim()!==``&&(S!==`header`||E.some(e=>e.name.trim()!==``&&(e.value!==``||e.kept))),F=()=>{let e={name:u.trim(),url:g.trim(),transport:y,authType:S,enabled:j,...O==null?{}:{timeoutSeconds:Math.floor(O)},...f.trim()?{slug:f.trim()}:{}};S===`header`&&(e.headers=Object.fromEntries(E.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.kept&&e.value===``?null:e.value])));let i={onSuccess:e=>{t(),r(n(l?`mcp.server.saved`:`mcp.server.created`,{name:e.name}),`success`)},onError:e=>r(U(e),`error`)};l?s.mutate({id:l.id,body:e},i):a.mutate(e,i)},I=(e,t)=>D(n=>n.map((n,r)=>r===e?{...n,...t}:n));return(0,Z.jsx)(V,{open:e!==null,onOpenChange:e=>!e&&t(),width:560,title:l?n(`mcp.server.editTitle`,{name:l.name}):n(`mcp.server.addTitle`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{onClick:t,children:n(`common.cancel`)}),(0,Z.jsx)(o,{variant:`primary`,disabled:!P,loading:N,onClick:F,children:n(`common.save`)})]}),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(_,{label:n(`mcp.server.name`),children:(0,Z.jsx)(c,{value:u,maxLength:64,onChange:e=>d(e.target.value)})}),(0,Z.jsx)(_,{label:n(`mcp.server.url`),hint:n(`mcp.server.urlHint`),children:(0,Z.jsx)(c,{mono:!0,value:g,placeholder:`https://mcp.example.com/mcp`,onChange:e=>v(e.target.value)})}),(0,Z.jsx)(_,{label:n(`mcp.server.transport`),hint:n(`mcp.server.transportHint`),children:(0,Z.jsx)(w,{ariaLabel:n(`mcp.server.transport`),value:y,onChange:x,items:[{value:`http`,label:n(`mcp.server.transport.http`)},{value:`sse`,label:n(`mcp.server.transport.sse`)}]})}),(0,Z.jsx)(_,{label:n(`mcp.server.auth`),children:(0,Z.jsx)(w,{ariaLabel:n(`mcp.server.auth`),value:S,onChange:T,items:[{value:`none`,label:n(`mcp.server.auth.none`)},{value:`header`,label:n(`mcp.server.auth.header`)},{value:`oauth`,label:n(`mcp.server.auth.oauth`)}]})}),S===`oauth`&&(0,Z.jsx)(z,{tone:`warning`,title:n(`mcp.server.oauthNote`)}),S===`header`&&(0,Z.jsx)(_,{label:n(`mcp.server.headers`),hint:n(`mcp.server.headersHint`),children:(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[E.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(c,{className:`w-40`,mono:!0,label:n(`mcp.server.headerName`),placeholder:`Authorization`,value:e.name,readOnly:e.kept&&l!==null,onChange:e=>I(t,{name:e.target.value})}),(0,Z.jsx)(c,{className:`flex-1`,mono:!0,type:`password`,label:n(`mcp.server.headerValue`),placeholder:e.kept?n(`mcp.server.headerKept`):`Bearer …`,value:e.value,onChange:e=>I(t,{value:e.target.value})}),(0,Z.jsx)(o,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(Y,{className:`size-3.5`}),"aria-label":n(`mcp.server.removeHeader`),onClick:()=>D(e=>e.filter((e,n)=>n!==t))})]},t)),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{size:`sm`,icon:(0,Z.jsx)(J,{className:`size-3.5`}),onClick:()=>D(e=>[...e,{name:``,value:``,kept:!1}]),children:n(`mcp.server.addHeader`)})})]})}),(0,Z.jsx)(_,{label:n(`mcp.server.slug`),hint:n(`mcp.server.slugHint`),children:(0,Z.jsx)(c,{mono:!0,value:f,maxLength:32,placeholder:l?``:`github`,onChange:e=>m(e.target.value)})}),(0,Z.jsx)(_,{label:n(`mcp.server.timeout`),hint:n(`mcp.server.timeoutHint`),children:(0,Z.jsx)(h,{value:O,min:1,step:1,label:n(`mcp.server.timeout`),onChange:A})}),(0,Z.jsx)(b,{label:n(`mcp.server.enabled`),children:(0,Z.jsx)(C,{checked:j,label:n(`mcp.server.enabled`),onChange:M})})]})})}function De(){let{t:e,locale:t}=i(),n=l(50);return(0,Z.jsx)(y,{title:e(`mcp.calls.title`),footer:e(`mcp.calls.hint`),children:n.data===void 0?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(u,{})}):n.data.length===0?(0,Z.jsx)(`div`,{className:`px-4 py-6 text-center text-[12px] text-[var(--text-muted)]`,children:e(`mcp.calls.empty`)}):(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsxs)(`table`,{className:`w-full text-left text-[12px]`,children:[(0,Z.jsx)(`thead`,{className:`text-[var(--text-muted)]`,children:(0,Z.jsx)(`tr`,{children:[`time`,`token`,`tool`,`duration`,`result`].map(t=>(0,Z.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:e(`mcp.calls.${t}`)},t))})}),(0,Z.jsx)(`tbody`,{children:n.data.map(e=>(0,Z.jsx)(Oe,{call:e,locale:t},e.id))})]})})})}function Oe({call:e,locale:t}){let{t:n}=i();return(0,Z.jsxs)(`tr`,{className:`border-t border-[var(--border)]`,children:[(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-4 py-1.5 text-[var(--text-secondary)]`,children:L(e.at,t)}),(0,Z.jsx)(`td`,{className:`px-4 py-1.5`,children:e.tokenName??e.tokenId}),(0,Z.jsxs)(`td`,{className:`px-4 py-1.5 font-mono`,children:[e.serverSlug,(0,Z.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`/`}),e.tool,e.frontEra&&(0,Z.jsx)(`span`,{className:`ml-2 text-[10.5px] text-[var(--text-muted)]`,children:n(`mcp.calls.era.${e.frontEra}`)})]}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-4 py-1.5 tabular-nums text-[var(--text-secondary)]`,children:P(e.durationMs)}),(0,Z.jsx)(`td`,{className:`px-4 py-1.5`,children:e.ok?(0,Z.jsx)(s,{tone:`green`,children:n(`mcp.calls.ok`)}):(0,Z.jsx)(s,{tone:`red`,children:n(`mcp.calls.error.${e.errorCategory??`protocol`}`)})})]})}function ke(){let{t:e}=i();return(0,Z.jsx)(se,{title:e(`nav.mcp`),subtitle:e(`mcp.subtitle`),children:(0,Z.jsx)(Se,{})})}export{ke as McpPage};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{B as n,C as r,D as i,E as a,F as o,H as s,Kr as c,L as l,N as u,P as d,R as f,To as p,U as m,Xn as h,Zi as g,an as _,fa as v,in as y,r as b,v as x,x as S,yr as C}from"./format-hEAJVPjJ.js";import{H as w,U as T,V as E,W as D}from"./TrayTitleSource-U2fI0rGJ.js";import{t as O}from"./arrow-left-DhPqlXf4.js";import{t as k}from"./pencil-CpF9MxGZ.js";import{t as A}from"./plus-c3HzV6VX.js";import{t as j}from"./rotate-ccw-fsXoCwyv.js";import{t as M}from"./trash-BHBJn5GS.js";import{G as ee,H as te,W as ne,l as N,s as P,v as F}from"./index-CUXoLKaW.js";import{t as I}from"./checkbox-C7ORfHsK.js";import{t as L}from"./confirm-morph-Cm30hox1.js";var R=e(t(),1),z=p(),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}=r(),u=ne(),{id:p=``}=ee(),_=decodeURIComponent(p),v=h(_),C=g(_),w=c(_),E=y(),{toast:k}=D(),A=(0,R.useMemo)(()=>v.data?V(v.data):null,[v.data]),[M,L]=(0,R.useState)(A),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(A),G(A?.aliases?.join(`, `)??``)},[A]);let q=(0,z.jsx)(i,{variant:`glass`,icon:(0,z.jsx)(O,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>u(`/models`)});if(v.isError)return(0,z.jsx)(F,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(S,{tone:`danger`,title:e(`common.error`),children:T(v.error)})});let J=v.data;if(!J||!M)return(0,z.jsx)(F,{title:``,leading:q,children:(0,z.jsx)(s,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...M,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(A),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>C.mutate(X,{onSuccess:()=>k(e(`common.saved`),`success`),onError:e=>k(T(e),`error`)}),$=t=>re.has(t)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(a,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(i,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(j,{className:`size-3`}),title:e(`models.resetField`),"aria-label":e(`models.resetField`),onClick:()=>w.mutate(t,{onSuccess:()=>k(e(`models.fieldReset`)),onError:e=>k(T(e),`error`)})})]}):null;return(0,z.jsx)(F,{title:J.displayName,subtitle:`${J.id} · ${e(`models.source.${J.source}`)} · ${e(`models.updated`,{time:b(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 E.mutateAsync(J.id),u(`/models`)}}),Z&&(0,z.jsx)(i,{onClick:()=>{L(A),G(A?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(i,{variant:`primary`,disabled:!Z,loading:C.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)(d,{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)(o,{className:`w-60`,"aria-label":e(`models.field.displayName`),value:M.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.vendor`),children:(0,z.jsx)(o,{className:`w-60`,"aria-label":e(`models.field.vendor`),value:M.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(o,{className:`w-60`,"aria-label":e(`models.field.family`),value:M.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:e(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(o,{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)(l,{className:`w-36`,label:e(`models.field.contextWindow`),value:M.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:e(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(l,{className:`w-36`,label:e(`models.field.maxOutputTokens`),value:M.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:e(`common.enabled`),children:(0,z.jsx)(m,{checked:M.enabled??!0,label:e(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(d,{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:!!M.capabilities?.[t.key],onCheckedChange:e=>Y({capabilities:{...M.capabilities,[t.key]:e===!0}})},t.key))})}),(0,z.jsx)(W,{model:J}),J.providerOverrides.length>0&&(0,z.jsx)(d,{title:e(`models.section.overrides`),footer:e(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(f,{label:(0,z.jsx)(te,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${x(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(n,{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)(N,{value:M.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(n,{children:e(`models.section.simulator`)}),(0,z.jsxs)(`div`,{className:`card p-4`,children:[(0,z.jsx)(P,{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)(f,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=r(),n=_(e.id),[o,s]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(d,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(i,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(A,{className:`size-3.5`}),onClick:()=>s(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(f,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(f,{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)(a,{tone:`orange`,children:t(`models.modified`)})]}),detail:[x(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)(i,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{className:`size-3.5`}),"aria-label":t(`common.edit`),onClick:()=>s(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:o,onClose:()=>s(null)})]})}function G({model:e,editing:t,onClose:n}){let{t:a}=r(),{toast:s}=D(),c=C(),l=v(e.id),d=t===`new`,[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(``),[g,_]=(0,R.useState)(null);(0,R.useEffect)(()=>{t&&(t===`new`?(p(``),h(``),_(e.pricing?structuredClone(e.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(p(t.priceKey),h(t.upstreamModelId??``),_(structuredClone(t.pricing))))},[t,e.pricing]);let y=new Set(e.providerPrices.map(e=>e.priceKey));return(0,z.jsx)(w,{open:t!==null,onOpenChange:e=>!e&&n(),width:680,title:d?a(`models.addPrice`):a(`models.editPrice`,{key:f}),description:a(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(i,{onClick:n,children:a(`common.cancel`)}),(0,z.jsx)(i,{variant:`primary`,disabled:!f||!g,loading:l.isPending,onClick:()=>l.mutate({priceKey:f,upstreamModelId:m||null,pricing:g},{onSuccess:()=>{s(a(`common.saved`),`success`),n()},onError:e=>s(T(e),`error`)}),children:a(`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:a(`providers.priceKey`),children:d?(0,z.jsx)(E,{value:f,onChange:p,placeholder:a(`models.pickPriceKey`),options:(c.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:y.has(e.priceKey)}))}):(0,z.jsx)(o,{value:f,disabled:!0,className:`font-mono`})}),(0,z.jsx)(u,{label:a(`models.upstreamId`),hint:a(`models.upstreamIdHint`),children:(0,z.jsx)(o,{className:`font-mono`,value:m,onChange:e=>h(e.target.value),placeholder:e.id})})]}),d&&(0,z.jsx)(o,{className:`font-mono`,"aria-label":a(`models.customPriceKey`),placeholder:a(`models.customPriceKey`),value:f,onChange:e=>p(e.target.value.trim())}),(0,z.jsx)(N,{value:g,onChange:_})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:i}=r();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(M,{className:`size-4`}),prompt:t,confirmLabel:i(`common.delete`),cancelLabel:i(`common.cancel`),pendingLabel:i(`common.deleting`),doneLabel:i(`common.deleted`),errorLabel:i(`common.error`),retryLabel:i(`common.retry`),onConfirm:n})}export{H as ModelDetailPage};
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{B as n,C as r,D as i,E as a,F as o,H as s,Kr as c,L as l,N as u,P as d,R as f,To as p,U as m,Xn as h,Zi as g,an as _,fa as v,in as y,r as b,v as x,x as S,yr as C}from"./format-Bw-mDeuE.js";import{H as w,U as T,V as E,W as D}from"./TrayTitleSource-EINzpQeQ.js";import{t as O}from"./arrow-left-DhPqlXf4.js";import{t as k}from"./pencil-CpF9MxGZ.js";import{t as A}from"./plus-c3HzV6VX.js";import{t as j}from"./rotate-ccw-fsXoCwyv.js";import{t as M}from"./trash-BHBJn5GS.js";import{G as ee,H as te,W as ne,l as N,s as P,v as F}from"./index-D2hgi2oA.js";import{t as I}from"./checkbox-DFbPH3ZB.js";import{t as L}from"./confirm-morph-Cu1awcrW.js";var R=e(t(),1),z=p(),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}=r(),u=ne(),{id:p=``}=ee(),_=decodeURIComponent(p),v=h(_),C=g(_),w=c(_),E=y(),{toast:k}=D(),A=(0,R.useMemo)(()=>v.data?V(v.data):null,[v.data]),[M,L]=(0,R.useState)(A),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(A),G(A?.aliases?.join(`, `)??``)},[A]);let q=(0,z.jsx)(i,{variant:`glass`,icon:(0,z.jsx)(O,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>u(`/models`)});if(v.isError)return(0,z.jsx)(F,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(S,{tone:`danger`,title:e(`common.error`),children:T(v.error)})});let J=v.data;if(!J||!M)return(0,z.jsx)(F,{title:``,leading:q,children:(0,z.jsx)(s,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...M,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(A),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>C.mutate(X,{onSuccess:()=>k(e(`common.saved`),`success`),onError:e=>k(T(e),`error`)}),$=t=>re.has(t)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(a,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(i,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(j,{className:`size-3`}),title:e(`models.resetField`),"aria-label":e(`models.resetField`),onClick:()=>w.mutate(t,{onSuccess:()=>k(e(`models.fieldReset`)),onError:e=>k(T(e),`error`)})})]}):null;return(0,z.jsx)(F,{title:J.displayName,subtitle:`${J.id} · ${e(`models.source.${J.source}`)} · ${e(`models.updated`,{time:b(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 E.mutateAsync(J.id),u(`/models`)}}),Z&&(0,z.jsx)(i,{onClick:()=>{L(A),G(A?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(i,{variant:`primary`,disabled:!Z,loading:C.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)(d,{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)(o,{className:`w-60`,"aria-label":e(`models.field.displayName`),value:M.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.vendor`),children:(0,z.jsx)(o,{className:`w-60`,"aria-label":e(`models.field.vendor`),value:M.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(o,{className:`w-60`,"aria-label":e(`models.field.family`),value:M.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:e(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(o,{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)(l,{className:`w-36`,label:e(`models.field.contextWindow`),value:M.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:e(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(l,{className:`w-36`,label:e(`models.field.maxOutputTokens`),value:M.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:e(`common.enabled`),children:(0,z.jsx)(m,{checked:M.enabled??!0,label:e(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(d,{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:!!M.capabilities?.[t.key],onCheckedChange:e=>Y({capabilities:{...M.capabilities,[t.key]:e===!0}})},t.key))})}),(0,z.jsx)(W,{model:J}),J.providerOverrides.length>0&&(0,z.jsx)(d,{title:e(`models.section.overrides`),footer:e(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(f,{label:(0,z.jsx)(te,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${x(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(n,{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)(N,{value:M.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(n,{children:e(`models.section.simulator`)}),(0,z.jsxs)(`div`,{className:`card p-4`,children:[(0,z.jsx)(P,{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)(f,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=r(),n=_(e.id),[o,s]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(d,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(i,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(A,{className:`size-3.5`}),onClick:()=>s(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(f,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(f,{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)(a,{tone:`orange`,children:t(`models.modified`)})]}),detail:[x(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)(i,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{className:`size-3.5`}),"aria-label":t(`common.edit`),onClick:()=>s(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:o,onClose:()=>s(null)})]})}function G({model:e,editing:t,onClose:n}){let{t:a}=r(),{toast:s}=D(),c=C(),l=v(e.id),d=t===`new`,[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(``),[g,_]=(0,R.useState)(null);(0,R.useEffect)(()=>{t&&(t===`new`?(p(``),h(``),_(e.pricing?structuredClone(e.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(p(t.priceKey),h(t.upstreamModelId??``),_(structuredClone(t.pricing))))},[t,e.pricing]);let y=new Set(e.providerPrices.map(e=>e.priceKey));return(0,z.jsx)(w,{open:t!==null,onOpenChange:e=>!e&&n(),width:680,title:d?a(`models.addPrice`):a(`models.editPrice`,{key:f}),description:a(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(i,{onClick:n,children:a(`common.cancel`)}),(0,z.jsx)(i,{variant:`primary`,disabled:!f||!g,loading:l.isPending,onClick:()=>l.mutate({priceKey:f,upstreamModelId:m||null,pricing:g},{onSuccess:()=>{s(a(`common.saved`),`success`),n()},onError:e=>s(T(e),`error`)}),children:a(`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:a(`providers.priceKey`),children:d?(0,z.jsx)(E,{value:f,onChange:p,placeholder:a(`models.pickPriceKey`),options:(c.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:y.has(e.priceKey)}))}):(0,z.jsx)(o,{value:f,disabled:!0,className:`font-mono`})}),(0,z.jsx)(u,{label:a(`models.upstreamId`),hint:a(`models.upstreamIdHint`),children:(0,z.jsx)(o,{className:`font-mono`,value:m,onChange:e=>h(e.target.value),placeholder:e.id})})]}),d&&(0,z.jsx)(o,{className:`font-mono`,"aria-label":a(`models.customPriceKey`),placeholder:a(`models.customPriceKey`),value:f,onChange:e=>p(e.target.value.trim())}),(0,z.jsx)(N,{value:g,onChange:_})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:i}=r();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(M,{className:`size-4`}),prompt:t,confirmLabel:i(`common.delete`),cancelLabel:i(`common.cancel`),pendingLabel:i(`common.deleting`),doneLabel:i(`common.deleted`),errorLabel:i(`common.error`),retryLabel:i(`common.retry`),onConfirm:n})}export{H as ModelDetailPage};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{C as n,D as r,E as i,Ei as a,F as o,H as s,L as c,M as l,N as u,Ti as d,To as f,Yt as p,Zn as m,_ as h,f as g,n as _,ut as v,x as y,z as b}from"./format-hEAJVPjJ.js";import{H as x,U as S,V as C,W as w}from"./TrayTitleSource-U2fI0rGJ.js";import{t as T}from"./boxes-BLn3utsF.js";import{t as E}from"./chevron-right-Bgtn3ze-.js";import{t as D}from"./cloud-download-l1GjuXcO.js";import{t as O}from"./plus-c3HzV6VX.js";import{A as k,F as A,I as j,W as M,v as N}from"./index-CUXoLKaW.js";import{t as P}from"./checkbox-C7ORfHsK.js";var F=e(t(),1),I=f();function L(){let{t:e}=n(),t=M(),[i,a]=(0,F.useState)(``),[o,c]=(0,F.useState)(``),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),h=(0,F.useRef)(null),g=j(i),_=m(),v=m(g,o),x=(0,F.useMemo)(()=>[...new Set((_.data??[]).map(e=>e.vendor))].sort(),[_.data]);return A(e=>{e===`find`&&h.current?.focus()}),(0,I.jsxs)(N,{title:e(`nav.models`),subtitle:v.data?e(`models.count`,{count:v.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(b,{inputRef:h,className:`w-52`,value:i,onChange:a,placeholder:e(`models.search`)}),(0,I.jsx)(C,{value:o,onChange:c,options:[{value:``,label:e(`models.allVendors`)},...x.map(e=>({value:e,label:e}))]}),(0,I.jsx)(r,{icon:(0,I.jsx)(D,{className:`size-3.5`}),onClick:()=>p(!0),children:e(`models.sync`)}),(0,I.jsx)(r,{variant:`primary`,icon:(0,I.jsx)(O,{className:`size-3.5`}),onClick:()=>d(!0),children:e(`models.new`)})]}),children:[v.isLoading&&(0,I.jsx)(s,{lines:5}),v.isError&&(0,I.jsx)(y,{tone:`danger`,title:e(`common.error`),children:S(v.error)}),v.data?.length===0&&(0,I.jsx)(l,{icon:(0,I.jsx)(T,{className:`size-6`}),title:e(`models.empty`)}),v.data&&v.data.length>0&&(0,I.jsx)(k,{caption:e(`nav.models`),rowKey:`id`,rows:v.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(e,e=>t(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:u,onOpenChange:d,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:f,onOpenChange:p})]})}function R(e,t){return[{key:`name`,label:e(`models.col.model`),render:(n,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>t(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:v(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(i,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(i,{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,t)=>_(t.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${g(n.input)} / ${g(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:i}){let{t:a}=n(),{toast:s}=w(),l=p(),[d,f]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[g,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(null),[b,C]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(x,{open:e,onOpenChange:t,title:a(`models.new`),description:a(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{onClick:()=>t(!1),children:a(`common.cancel`)}),(0,I.jsx)(r,{variant:`primary`,disabled:!d.trim()||!g.trim(),loading:l.isPending,onClick:()=>l.mutate({id:d.trim(),displayName:m.trim()||d.trim(),vendor:g.trim(),contextWindow:v,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{t(!1),f(``),h(``),i(e.id)},onError:e=>s(S(e),`error`)}),children:a(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(u,{label:a(`models.field.id`),hint:a(`models.field.idHint`),children:(0,I.jsx)(o,{className:`font-mono`,value:d,onChange:e=>f(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(u,{label:a(`models.field.displayName`),children:(0,I.jsx)(o,{value:m,onChange:e=>h(e.target.value)})}),(0,I.jsx)(u,{label:a(`models.field.vendor`),children:(0,I.jsx)(o,{value:g,onChange:e=>_(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(u,{label:a(`models.field.contextWindow`),children:(0,I.jsx)(c,{value:v,onChange:y})}),(0,I.jsx)(u,{label:a(`models.field.inputPrice`),children:(0,I.jsx)(c,{value:b,onChange:C})}),(0,I.jsx)(u,{label:a(`models.field.outputPrice`),children:(0,I.jsx)(c,{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:r}=n(),i=H(e,t),a=i.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:`${h(e)||`∅`}\n→\n${h(t)||`∅`}`,children:[i.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)),a>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:r(`models.sync.more`,{n:a})})]})}function K({changes:e,label:t,checked:r,onChange:a}){let{t:o}=n(),[s,c]=(0,F.useState)(new Set),l=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),u=e=>{let t=e.filter(e=>r.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},d=(e,t)=>{let n=new Set(r);for(let r of e)t?n.add(r):n.delete(r);a(n)},f=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),p=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)(i,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(i,{tone:`orange`,children:o(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),m=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:u(m),onCheckedChange:e=>d(m,e!==!1),"aria-label":o(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:o(`models.sync.selectedOf`,{n:r.size,total:m.length,models:l.length})})]}),l.map(([e,n])=>{let i=n.map(e=>e.id),a=n.length===1?n[0]:void 0,c=!s.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:u(i),onCheckedChange:e=>d(i,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:[a?(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":c,onClick:()=>f(e),children:[(0,I.jsx)(E,{className:v(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,c&&`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:o(`models.sync.groupCount`,{n:n.length})})]}),a&&p(a)]})]}),!a&&c&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:n.map(n=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:r.has(n.id),onCheckedChange:e=>d([n.id],e!==!1),"aria-label":`${e} ${t(n)}`,className:`mt-0.5`}),p(n)]},n.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:i}=n(),{toast:o}=w(),c=a(),l=d(),[u,f]=(0,F.useState)(new Set),p=()=>c.mutate(void 0,{onSuccess:e=>f(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),m=c.data?.changes??[];return(0,I.jsxs)(x,{open:e,onOpenChange:e=>{t(e),e&&!c.data&&p()},width:720,title:i(`models.sync`),description:i(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{className:`mr-auto`,variant:`plain`,onClick:p,loading:c.isPending,children:i(`common.refresh`)}),(0,I.jsx)(r,{onClick:()=>t(!1),children:i(`common.cancel`)}),(0,I.jsx)(r,{variant:`primary`,disabled:u.size===0,loading:l.isPending,onClick:()=>l.mutate([...u],{onSuccess:e=>{o(i(`models.sync.applied`,{count:e.applied}),`success`),t(!1),c.reset()},onError:e=>o(S(e),`error`)}),children:i(`models.sync.apply`,{count:u.size})})]}),children:[e&&!c.data&&!c.isPending&&!c.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(r,{variant:`primary`,onClick:p,children:i(`models.sync.check`)})}),c.isPending&&(0,I.jsx)(s,{lines:4}),c.isError&&(0,I.jsx)(y,{tone:`danger`,title:i(`common.error`),children:S(c.error)}),c.data&&m.length===0&&(0,I.jsx)(y,{tone:`success`,title:i(`models.sync.none`)}),m.length>0&&(0,I.jsx)(K,{changes:m,label:e=>e.kind===`new_model`?i(`models.sync.newModel`):e.kind===`price`?i(`models.sync.price`,{key:e.priceKey??``}):i(`models.sync.field`,{field:e.field??``}),checked:u,onChange:f})]})}export{L as ModelsPage};
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{C as n,D as r,E as i,Ei as a,F as o,H as s,L as c,M as l,N as u,Ti as d,To as f,Yt as p,Zn as m,_ as h,f as g,n as _,ut as v,x as y,z as b}from"./format-Bw-mDeuE.js";import{H as x,U as S,V as C,W as w}from"./TrayTitleSource-EINzpQeQ.js";import{t as T}from"./boxes-BLn3utsF.js";import{t as E}from"./chevron-right-Bgtn3ze-.js";import{t as D}from"./cloud-download-l1GjuXcO.js";import{t as O}from"./plus-c3HzV6VX.js";import{A as k,F as A,I as j,W as M,v as N}from"./index-D2hgi2oA.js";import{t as P}from"./checkbox-DFbPH3ZB.js";var F=e(t(),1),I=f();function L(){let{t:e}=n(),t=M(),[i,a]=(0,F.useState)(``),[o,c]=(0,F.useState)(``),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),h=(0,F.useRef)(null),g=j(i),_=m(),v=m(g,o),x=(0,F.useMemo)(()=>[...new Set((_.data??[]).map(e=>e.vendor))].sort(),[_.data]);return A(e=>{e===`find`&&h.current?.focus()}),(0,I.jsxs)(N,{title:e(`nav.models`),subtitle:v.data?e(`models.count`,{count:v.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(b,{inputRef:h,className:`w-52`,value:i,onChange:a,placeholder:e(`models.search`)}),(0,I.jsx)(C,{value:o,onChange:c,options:[{value:``,label:e(`models.allVendors`)},...x.map(e=>({value:e,label:e}))]}),(0,I.jsx)(r,{icon:(0,I.jsx)(D,{className:`size-3.5`}),onClick:()=>p(!0),children:e(`models.sync`)}),(0,I.jsx)(r,{variant:`primary`,icon:(0,I.jsx)(O,{className:`size-3.5`}),onClick:()=>d(!0),children:e(`models.new`)})]}),children:[v.isLoading&&(0,I.jsx)(s,{lines:5}),v.isError&&(0,I.jsx)(y,{tone:`danger`,title:e(`common.error`),children:S(v.error)}),v.data?.length===0&&(0,I.jsx)(l,{icon:(0,I.jsx)(T,{className:`size-6`}),title:e(`models.empty`)}),v.data&&v.data.length>0&&(0,I.jsx)(k,{caption:e(`nav.models`),rowKey:`id`,rows:v.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(e,e=>t(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:u,onOpenChange:d,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:f,onOpenChange:p})]})}function R(e,t){return[{key:`name`,label:e(`models.col.model`),render:(n,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>t(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:v(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(i,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(i,{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,t)=>_(t.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${g(n.input)} / ${g(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:i}){let{t:a}=n(),{toast:s}=w(),l=p(),[d,f]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[g,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(null),[b,C]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(x,{open:e,onOpenChange:t,title:a(`models.new`),description:a(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{onClick:()=>t(!1),children:a(`common.cancel`)}),(0,I.jsx)(r,{variant:`primary`,disabled:!d.trim()||!g.trim(),loading:l.isPending,onClick:()=>l.mutate({id:d.trim(),displayName:m.trim()||d.trim(),vendor:g.trim(),contextWindow:v,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{t(!1),f(``),h(``),i(e.id)},onError:e=>s(S(e),`error`)}),children:a(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(u,{label:a(`models.field.id`),hint:a(`models.field.idHint`),children:(0,I.jsx)(o,{className:`font-mono`,value:d,onChange:e=>f(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(u,{label:a(`models.field.displayName`),children:(0,I.jsx)(o,{value:m,onChange:e=>h(e.target.value)})}),(0,I.jsx)(u,{label:a(`models.field.vendor`),children:(0,I.jsx)(o,{value:g,onChange:e=>_(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(u,{label:a(`models.field.contextWindow`),children:(0,I.jsx)(c,{value:v,onChange:y})}),(0,I.jsx)(u,{label:a(`models.field.inputPrice`),children:(0,I.jsx)(c,{value:b,onChange:C})}),(0,I.jsx)(u,{label:a(`models.field.outputPrice`),children:(0,I.jsx)(c,{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:r}=n(),i=H(e,t),a=i.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:`${h(e)||`∅`}\n→\n${h(t)||`∅`}`,children:[i.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)),a>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:r(`models.sync.more`,{n:a})})]})}function K({changes:e,label:t,checked:r,onChange:a}){let{t:o}=n(),[s,c]=(0,F.useState)(new Set),l=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),u=e=>{let t=e.filter(e=>r.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},d=(e,t)=>{let n=new Set(r);for(let r of e)t?n.add(r):n.delete(r);a(n)},f=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),p=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)(i,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(i,{tone:`orange`,children:o(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),m=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:u(m),onCheckedChange:e=>d(m,e!==!1),"aria-label":o(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:o(`models.sync.selectedOf`,{n:r.size,total:m.length,models:l.length})})]}),l.map(([e,n])=>{let i=n.map(e=>e.id),a=n.length===1?n[0]:void 0,c=!s.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:u(i),onCheckedChange:e=>d(i,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:[a?(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":c,onClick:()=>f(e),children:[(0,I.jsx)(E,{className:v(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,c&&`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:o(`models.sync.groupCount`,{n:n.length})})]}),a&&p(a)]})]}),!a&&c&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:n.map(n=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:r.has(n.id),onCheckedChange:e=>d([n.id],e!==!1),"aria-label":`${e} ${t(n)}`,className:`mt-0.5`}),p(n)]},n.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:i}=n(),{toast:o}=w(),c=a(),l=d(),[u,f]=(0,F.useState)(new Set),p=()=>c.mutate(void 0,{onSuccess:e=>f(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),m=c.data?.changes??[];return(0,I.jsxs)(x,{open:e,onOpenChange:e=>{t(e),e&&!c.data&&p()},width:720,title:i(`models.sync`),description:i(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{className:`mr-auto`,variant:`plain`,onClick:p,loading:c.isPending,children:i(`common.refresh`)}),(0,I.jsx)(r,{onClick:()=>t(!1),children:i(`common.cancel`)}),(0,I.jsx)(r,{variant:`primary`,disabled:u.size===0,loading:l.isPending,onClick:()=>l.mutate([...u],{onSuccess:e=>{o(i(`models.sync.applied`,{count:e.applied}),`success`),t(!1),c.reset()},onError:e=>o(S(e),`error`)}),children:i(`models.sync.apply`,{count:u.size})})]}),children:[e&&!c.data&&!c.isPending&&!c.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(r,{variant:`primary`,onClick:p,children:i(`models.sync.check`)})}),c.isPending&&(0,I.jsx)(s,{lines:4}),c.isError&&(0,I.jsx)(y,{tone:`danger`,title:i(`common.error`),children:S(c.error)}),c.data&&m.length===0&&(0,I.jsx)(y,{tone:`success`,title:i(`models.sync.none`)}),m.length>0&&(0,I.jsx)(K,{changes:m,label:e=>e.kind===`new_model`?i(`models.sync.newModel`):e.kind===`price`?i(`models.sync.price`,{key:e.priceKey??``}):i(`models.sync.field`,{field:e.field??``}),checked:u,onChange:f})]})}export{L as ModelsPage};
@@ -1,2 +1,2 @@
1
- import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{C as n,D as r,E as i,F as a,Fn as o,H as s,I as c,Lr as l,M as u,N as d,O as f,Qi as p,Qn as m,Rr as h,St as g,To as _,U as v,V as y,W as b,Wn as x,gr as S,ir as C,jn as w,nr as T,pr as E,r as D,rr as O,sr as ee,ut as k,x as A,z as te}from"./format-hEAJVPjJ.js";import{B as j,H as M,U as N,W as P}from"./TrayTitleSource-U2fI0rGJ.js";import{t as F}from"./app-window-C13qqwdi.js";import{t as ne}from"./arrow-down-Def8Fl70.js";import{t as re}from"./arrow-up-DE65OgjV.js";import{t as ie}from"./check-DKfsh0bQ.js";import{t as ae}from"./ellipsis-CidyZaW2.js";import{t as oe}from"./external-link-D6jQM2CZ.js";import{t as se}from"./plus-c3HzV6VX.js";import{t as I}from"./puzzle-Eesuewfj.js";import{t as L}from"./refresh-cw-CoLAai2c.js";import{t as ce}from"./settings-2-CSrxJ7TH.js";import{t as R}from"./shield-check-CD30JqBi.js";import{t as z}from"./trash-BHBJn5GS.js";import{B,D as V,E as H,G as U,K as W,L as le,O as ue,W as G,k as K,v as de,w as fe}from"./index-CUXoLKaW.js";var q=e(t(),1),J=_(),pe=/^(?:(?:@[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`,v2:`plugins.kind.v2`,ui:`plugins.kind.ui`,hooks:`plugins.kind.hooks`},me={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`,v2:`accent`,ui:`neutral`,hooks:`accent`};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`?R:F,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(fe,{name:e,icon:t,size:r})}function he(){let{t:e}=n(),t=G(),{tab:i}=U(),a=i===`market`||i===`runtime`?i:`installed`,o=E(),c=p(),{toast:l}=P(),[u,d]=(0,q.useState)(!1),[f,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(null);return(0,J.jsxs)(de,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(r,{icon:(0,J.jsx)(L,{className:`size-3.5`}),onClick:()=>c.mutate(void 0,{onSuccess:e=>g(e.id),onError:e=>l(N(e),`error`)}),disabled:!o.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(r,{variant:`primary`,icon:(0,J.jsx)(se,{className:`size-3.5`}),onClick:()=>d(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[o.data?.off&&(0,J.jsx)(A,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(H,{value:a,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(ue,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(K,{value:`installed`,children:[e(`plugins.tab.installed`),o.data&&o.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:o.data.plugins.length})]}),(0,J.jsx)(K,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(K,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(V,{value:`installed`,className:`pt-1`,children:[o.isLoading&&(0,J.jsx)(s,{lines:4}),o.isError&&(0,J.jsx)(A,{tone:`danger`,title:e(`common.error`),children:N(o.error)}),(0,J.jsx)(`div`,{className:`mb-4`,children:(0,J.jsx)(le,{onJob:g})}),o.data&&(0,J.jsx)(ge,{plugins:o.data.plugins.filter(e=>!e.kinds.includes(`v2`)),preferences:o.data.preferences,onJob:g,onBrowse:()=>t(`/plugins/market`),onImport:()=>m(!0)})]}),(0,J.jsx)(V,{value:`market`,className:`pt-1`,children:(0,J.jsx)(xe,{installed:o.data?.plugins??[],onJob:g})}),(0,J.jsx)(V,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Se,{onJob:g})})]})]}),(0,J.jsx)(ve,{open:u,onOpenChange:d,onJob:g}),(0,J.jsx)(ye,{open:f,onOpenChange:m,onJob:g}),(0,J.jsx)(be,{id:h,onClose:()=>g(null)})]})}function ge({plugins:e,preferences:t,onJob:i,onBrowse:a,onImport:o}){let{t:s}=n(),c=T(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),l=x(),d=h(),{toast:f}=P(),p=!!(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:s(`plugins.magpie.banner`,{count:l.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(r,{size:`sm`,icon:(0,J.jsx)(B,{className:`size-3.5`}),onClick:o,children:s(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(u,{icon:(0,J.jsx)(I,{className:`size-6`}),title:s(`plugins.empty`),detail:s(`plugins.emptyDetail`),action:(0,J.jsx)(r,{variant:`primary`,onClick:a,children:s(`plugins.browseMarket`)})})})]});let m=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),d.mutate(r,{onError:e=>f(N(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((n,r)=>(0,J.jsx)(_e,{plugin:n,host:c.data,preferences:t,onJob:i,onUp:r>0?()=>m(r,-1):void 0,onDown:r<e.length-1?()=>m(r,1):void 0},n.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:s(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:a,onJob:o,onUp:s,onDown:c}){let{t:u}=n(),d=G(),{toast:f,confirm:h}=P(),g=m(),_=p(),y=l(),b=S(),[x,C]=(0,q.useState)(!1),w=t?.plugins.find(t=>t.spec===e.spec),T=e.middleware,E=e.kinds[0]??`provider`,D=async()=>{await h({title:u(`plugins.removeConfirm`,{name:e.shortName}),detail:u(`plugins.removeDetail`),confirmLabel:u(`common.delete`),destructive:!0})&&y.mutate(e.spec,{onSuccess:e=>o(e.id),onError:e=>f(N(e),`error`)})},O=[];return T&&!T.error&&O.push((0,J.jsxs)(Z,{label:u(`plugins.kind.middleware`),children:[u(`plugins.mw.stats`,{hooks:T.hooks.join(`, `),calls:T.calls,micros:T.avgMicros.toFixed(1),failures:T.failures}),T.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:u(`plugins.mw.lastError`,{error:T.lastError})})]},`mw`)),e.agent?.kind&&O.push((0,J.jsx)(Z,{label:u(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>d(`/clients/${e.agent.kind}`),children:u(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),w&&w.provides.length>0&&O.push((0,J.jsxs)(Z,{label:u(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:u(`plugins.provides`,{providers:w.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>d(`/providers`),children:u(`plugins.openProviders`)}),Object.entries(w.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[u(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(r,{size:`sm`,onClick:()=>b.mutate({spec:e.spec,provider:t},{onError:e=>f(N(e),`error`)}),children:u(`plugins.useFor`,{provider:t})})]},t)),w.provides.some(t=>a[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:u(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:k(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:k(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:E})}),(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)(i,{tone:me[e],children:u(Y[e])},e)),e.isPath&&(0,J.jsx)(i,{tone:`orange`,children:u(`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:[T&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(r,{size:`sm`,variant:`plain`,"aria-label":u(`plugins.moveUp`),title:u(`plugins.moveUp`),disabled:!s,onClick:s,icon:(0,J.jsx)(re,{className:`size-3.5`})}),(0,J.jsx)(r,{size:`sm`,variant:`plain`,"aria-label":u(`plugins.moveDown`),title:u(`plugins.moveDown`),disabled:!c,onClick:c,icon:(0,J.jsx)(ne,{className:`size-3.5`})})]}),(0,J.jsx)(v,{checked:e.enabled,label:u(`plugins.enabled`),onChange:t=>g.mutate({spec:e.spec,enabled:t},{onError:e=>f(N(e),`error`)})}),(0,J.jsx)(j,{label:u(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ae,{className:`size-4`}),items:[{id:`options`,label:u(`plugins.options`),icon:(0,J.jsx)(ce,{className:`size-3.5`}),onSelect:()=>C(!0)},...e.isPath?[]:[{id:`update`,label:u(`plugins.update`),icon:(0,J.jsx)(L,{className:`size-3.5`}),onSelect:()=>_.mutate(e.spec,{onSuccess:e=>o(e.id),onError:e=>f(N(e),`error`)})}],{id:`remove`,label:u(`common.delete`),icon:(0,J.jsx)(z,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void D()}]})]})]}),e.error&&(0,J.jsx)(A,{tone:`danger`,title:u(`plugins.cantLoad`),children:e.error}),w?.error&&(0,J.jsx)(A,{tone:`danger`,title:u(`plugins.hostCantLoad`),children:w.error}),T?.error&&(0,J.jsx)(A,{tone:`danger`,title:u(`plugins.cantLoad`),children:u(`plugins.mw.error`,{error:T.error})}),e.agent?.error&&(0,J.jsx)(A,{tone:`danger`,title:u(`plugins.cantLoad`),children:u(`plugins.agent.error`,{error:e.agent.error})}),O.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:O})]}),(0,J.jsx)(Q,{plugin:e,open:x,onOpenChange:C})]})}function Z({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 Q({plugin:e,open:t,onOpenChange:i}){let{t:a}=n(),{toast:o}=P(),s=m(),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(l(JSON.stringify(e.options??e.optionsExample??{},null,2)),d(null))},[t,e.options,e.optionsExample]);let f=t=>s.mutate({spec:e.spec,options:t},{onSuccess:()=>(o(a(`plugins.optionsSaved`)),i(!1)),onError:e=>o(N(e),`error`)});return(0,J.jsxs)(M,{open:t,onOpenChange:i,title:a(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?a(`plugins.optionsExample`):a(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(r,{onClick:()=>f(null),children:a(`plugins.optionsClear`)}),(0,J.jsx)(r,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(c||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(a(`plugins.optionsObject`));f(e)}catch(e){d(e instanceof Error?e.message:String(e))}},disabled:s.isPending,children:a(`common.save`)})]}),children:[(0,J.jsx)(b,{mono:!0,rows:14,value:c,invalid:!!u,onChange:e=>(l(e.target.value),d(null)),label:a(`plugins.options`)}),u&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:u})]})}function ve({open:e,onOpenChange:t,onJob:i}){let{t:o}=n(),{toast:s}=P(),c=g(),[l,u]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&u(``)},[e]),(0,J.jsxs)(M,{open:e,onOpenChange:t,title:o(`plugins.addTitle`),description:o(`plugins.addDetail`),footer:(0,J.jsx)(r,{variant:`primary`,disabled:!l.trim()||c.isPending,onClick:()=>c.mutate({spec:l.trim()},{onSuccess:e=>(i(e.id),t(!1)),onError:e=>s(N(e),`error`)}),children:o(`plugins.install`)}),children:[(0,J.jsx)(d,{label:o(`plugins.spec`),hint:o(`plugins.specHint`),children:(0,J.jsx)(a,{mono:!0,value:l,onChange:e=>u(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(A,{tone:`warning`,title:o(`plugins.trustTitle`),className:`mt-4`,children:o(`plugins.trustDetail`)})]})}function ye({open:e,onOpenChange:t,onJob:a}){let{t:o}=n(),{toast:c}=P(),l=x(e),u=w(),[d,f]=(0,q.useState)(!1),p=l.data;return(0,J.jsxs)(M,{open:e,onOpenChange:t,title:o(`plugins.magpie.title`),description:p?.path,width:560,footer:(0,J.jsx)(r,{variant:`primary`,disabled:!p?.found||u.isPending,onClick:()=>u.mutate(d,{onSuccess:e=>(a(e.id),t(!1)),onError:e=>c(N(e),`error`)}),children:o(`plugins.magpie.import`)}),children:[l.isLoading&&(0,J.jsx)(s,{lines:3}),p?.error&&(0,J.jsx)(A,{tone:`danger`,title:o(`common.error`),children:p.error}),p&&(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:p.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)(i,{children:o(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(i,{tone:`accent`,children:o(`plugins.options`)}),e.installed&&(0,J.jsx)(i,{tone:`green`,children:o(`plugins.installed`)})]},e.spec))}),p.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(v,{checked:d,onChange:f,label:o(`plugins.magpie.signIns`,{count:p.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:o(`plugins.magpie.signInsDetail`)})]})]})]})}function be({id:e,onClose:t}){let{t:i}=n(),a=O(e).data;return(0,J.jsxs)(M,{open:!!e,onOpenChange:e=>!e&&t(),title:i(`plugins.job.title`),description:a?i(a.state===`running`?`plugins.job.running`:a.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:a.target}):void 0,width:620,footer:(0,J.jsx)(r,{onClick:t,children:i(`common.close`)}),children:[!a&&(0,J.jsx)(s,{lines:3}),a&&(0,J.jsx)(f,{language:`text`,children:a.log.length?a.log.join(`
1
+ import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{C as n,D as r,E as i,F as a,Fn as o,H as s,I as c,Lr as l,M as u,N as d,O as f,Qi as p,Qn as m,Rr as h,St as g,To as _,U as v,V as y,W as b,Wn as x,gr as S,ir as C,jn as w,nr as T,pr as E,r as D,rr as O,sr as ee,ut as k,x as A,z as te}from"./format-Bw-mDeuE.js";import{B as j,H as M,U as N,W as P}from"./TrayTitleSource-EINzpQeQ.js";import{t as F}from"./app-window-C13qqwdi.js";import{t as ne}from"./arrow-down-Def8Fl70.js";import{t as re}from"./arrow-up-DE65OgjV.js";import{t as ie}from"./check-DKfsh0bQ.js";import{t as ae}from"./ellipsis-CidyZaW2.js";import{t as oe}from"./external-link-D6jQM2CZ.js";import{t as se}from"./plus-c3HzV6VX.js";import{t as I}from"./puzzle-Eesuewfj.js";import{t as L}from"./refresh-cw-CoLAai2c.js";import{t as ce}from"./settings-2-CSrxJ7TH.js";import{t as R}from"./shield-check-CD30JqBi.js";import{t as z}from"./trash-BHBJn5GS.js";import{B,D as V,E as H,G as U,K as W,L as le,O as ue,W as G,k as K,v as de,w as fe}from"./index-D2hgi2oA.js";var q=e(t(),1),J=_(),pe=/^(?:(?:@[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`,v2:`plugins.kind.v2`,ui:`plugins.kind.ui`,hooks:`plugins.kind.hooks`},me={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`,v2:`accent`,ui:`neutral`,hooks:`accent`};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`?R:F,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(fe,{name:e,icon:t,size:r})}function he(){let{t:e}=n(),t=G(),{tab:i}=U(),a=i===`market`||i===`runtime`?i:`installed`,o=E(),c=p(),{toast:l}=P(),[u,d]=(0,q.useState)(!1),[f,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(null);return(0,J.jsxs)(de,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(r,{icon:(0,J.jsx)(L,{className:`size-3.5`}),onClick:()=>c.mutate(void 0,{onSuccess:e=>g(e.id),onError:e=>l(N(e),`error`)}),disabled:!o.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(r,{variant:`primary`,icon:(0,J.jsx)(se,{className:`size-3.5`}),onClick:()=>d(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[o.data?.off&&(0,J.jsx)(A,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(H,{value:a,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(ue,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(K,{value:`installed`,children:[e(`plugins.tab.installed`),o.data&&o.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:o.data.plugins.length})]}),(0,J.jsx)(K,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(K,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(V,{value:`installed`,className:`pt-1`,children:[o.isLoading&&(0,J.jsx)(s,{lines:4}),o.isError&&(0,J.jsx)(A,{tone:`danger`,title:e(`common.error`),children:N(o.error)}),(0,J.jsx)(`div`,{className:`mb-4`,children:(0,J.jsx)(le,{onJob:g})}),o.data&&(0,J.jsx)(ge,{plugins:o.data.plugins.filter(e=>!e.kinds.includes(`v2`)),preferences:o.data.preferences,onJob:g,onBrowse:()=>t(`/plugins/market`),onImport:()=>m(!0)})]}),(0,J.jsx)(V,{value:`market`,className:`pt-1`,children:(0,J.jsx)(xe,{installed:o.data?.plugins??[],onJob:g})}),(0,J.jsx)(V,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Se,{onJob:g})})]})]}),(0,J.jsx)(ve,{open:u,onOpenChange:d,onJob:g}),(0,J.jsx)(ye,{open:f,onOpenChange:m,onJob:g}),(0,J.jsx)(be,{id:h,onClose:()=>g(null)})]})}function ge({plugins:e,preferences:t,onJob:i,onBrowse:a,onImport:o}){let{t:s}=n(),c=T(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),l=x(),d=h(),{toast:f}=P(),p=!!(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:s(`plugins.magpie.banner`,{count:l.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(r,{size:`sm`,icon:(0,J.jsx)(B,{className:`size-3.5`}),onClick:o,children:s(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(u,{icon:(0,J.jsx)(I,{className:`size-6`}),title:s(`plugins.empty`),detail:s(`plugins.emptyDetail`),action:(0,J.jsx)(r,{variant:`primary`,onClick:a,children:s(`plugins.browseMarket`)})})})]});let m=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),d.mutate(r,{onError:e=>f(N(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((n,r)=>(0,J.jsx)(_e,{plugin:n,host:c.data,preferences:t,onJob:i,onUp:r>0?()=>m(r,-1):void 0,onDown:r<e.length-1?()=>m(r,1):void 0},n.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:s(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:a,onJob:o,onUp:s,onDown:c}){let{t:u}=n(),d=G(),{toast:f,confirm:h}=P(),g=m(),_=p(),y=l(),b=S(),[x,C]=(0,q.useState)(!1),w=t?.plugins.find(t=>t.spec===e.spec),T=e.middleware,E=e.kinds[0]??`provider`,D=async()=>{await h({title:u(`plugins.removeConfirm`,{name:e.shortName}),detail:u(`plugins.removeDetail`),confirmLabel:u(`common.delete`),destructive:!0})&&y.mutate(e.spec,{onSuccess:e=>o(e.id),onError:e=>f(N(e),`error`)})},O=[];return T&&!T.error&&O.push((0,J.jsxs)(Z,{label:u(`plugins.kind.middleware`),children:[u(`plugins.mw.stats`,{hooks:T.hooks.join(`, `),calls:T.calls,micros:T.avgMicros.toFixed(1),failures:T.failures}),T.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:u(`plugins.mw.lastError`,{error:T.lastError})})]},`mw`)),e.agent?.kind&&O.push((0,J.jsx)(Z,{label:u(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>d(`/clients/${e.agent.kind}`),children:u(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),w&&w.provides.length>0&&O.push((0,J.jsxs)(Z,{label:u(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:u(`plugins.provides`,{providers:w.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>d(`/providers`),children:u(`plugins.openProviders`)}),Object.entries(w.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[u(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(r,{size:`sm`,onClick:()=>b.mutate({spec:e.spec,provider:t},{onError:e=>f(N(e),`error`)}),children:u(`plugins.useFor`,{provider:t})})]},t)),w.provides.some(t=>a[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:u(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:k(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:k(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:E})}),(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)(i,{tone:me[e],children:u(Y[e])},e)),e.isPath&&(0,J.jsx)(i,{tone:`orange`,children:u(`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:[T&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(r,{size:`sm`,variant:`plain`,"aria-label":u(`plugins.moveUp`),title:u(`plugins.moveUp`),disabled:!s,onClick:s,icon:(0,J.jsx)(re,{className:`size-3.5`})}),(0,J.jsx)(r,{size:`sm`,variant:`plain`,"aria-label":u(`plugins.moveDown`),title:u(`plugins.moveDown`),disabled:!c,onClick:c,icon:(0,J.jsx)(ne,{className:`size-3.5`})})]}),(0,J.jsx)(v,{checked:e.enabled,label:u(`plugins.enabled`),onChange:t=>g.mutate({spec:e.spec,enabled:t},{onError:e=>f(N(e),`error`)})}),(0,J.jsx)(j,{label:u(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ae,{className:`size-4`}),items:[{id:`options`,label:u(`plugins.options`),icon:(0,J.jsx)(ce,{className:`size-3.5`}),onSelect:()=>C(!0)},...e.isPath?[]:[{id:`update`,label:u(`plugins.update`),icon:(0,J.jsx)(L,{className:`size-3.5`}),onSelect:()=>_.mutate(e.spec,{onSuccess:e=>o(e.id),onError:e=>f(N(e),`error`)})}],{id:`remove`,label:u(`common.delete`),icon:(0,J.jsx)(z,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void D()}]})]})]}),e.error&&(0,J.jsx)(A,{tone:`danger`,title:u(`plugins.cantLoad`),children:e.error}),w?.error&&(0,J.jsx)(A,{tone:`danger`,title:u(`plugins.hostCantLoad`),children:w.error}),T?.error&&(0,J.jsx)(A,{tone:`danger`,title:u(`plugins.cantLoad`),children:u(`plugins.mw.error`,{error:T.error})}),e.agent?.error&&(0,J.jsx)(A,{tone:`danger`,title:u(`plugins.cantLoad`),children:u(`plugins.agent.error`,{error:e.agent.error})}),O.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:O})]}),(0,J.jsx)(Q,{plugin:e,open:x,onOpenChange:C})]})}function Z({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 Q({plugin:e,open:t,onOpenChange:i}){let{t:a}=n(),{toast:o}=P(),s=m(),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(l(JSON.stringify(e.options??e.optionsExample??{},null,2)),d(null))},[t,e.options,e.optionsExample]);let f=t=>s.mutate({spec:e.spec,options:t},{onSuccess:()=>(o(a(`plugins.optionsSaved`)),i(!1)),onError:e=>o(N(e),`error`)});return(0,J.jsxs)(M,{open:t,onOpenChange:i,title:a(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?a(`plugins.optionsExample`):a(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(r,{onClick:()=>f(null),children:a(`plugins.optionsClear`)}),(0,J.jsx)(r,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(c||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(a(`plugins.optionsObject`));f(e)}catch(e){d(e instanceof Error?e.message:String(e))}},disabled:s.isPending,children:a(`common.save`)})]}),children:[(0,J.jsx)(b,{mono:!0,rows:14,value:c,invalid:!!u,onChange:e=>(l(e.target.value),d(null)),label:a(`plugins.options`)}),u&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:u})]})}function ve({open:e,onOpenChange:t,onJob:i}){let{t:o}=n(),{toast:s}=P(),c=g(),[l,u]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&u(``)},[e]),(0,J.jsxs)(M,{open:e,onOpenChange:t,title:o(`plugins.addTitle`),description:o(`plugins.addDetail`),footer:(0,J.jsx)(r,{variant:`primary`,disabled:!l.trim()||c.isPending,onClick:()=>c.mutate({spec:l.trim()},{onSuccess:e=>(i(e.id),t(!1)),onError:e=>s(N(e),`error`)}),children:o(`plugins.install`)}),children:[(0,J.jsx)(d,{label:o(`plugins.spec`),hint:o(`plugins.specHint`),children:(0,J.jsx)(a,{mono:!0,value:l,onChange:e=>u(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(A,{tone:`warning`,title:o(`plugins.trustTitle`),className:`mt-4`,children:o(`plugins.trustDetail`)})]})}function ye({open:e,onOpenChange:t,onJob:a}){let{t:o}=n(),{toast:c}=P(),l=x(e),u=w(),[d,f]=(0,q.useState)(!1),p=l.data;return(0,J.jsxs)(M,{open:e,onOpenChange:t,title:o(`plugins.magpie.title`),description:p?.path,width:560,footer:(0,J.jsx)(r,{variant:`primary`,disabled:!p?.found||u.isPending,onClick:()=>u.mutate(d,{onSuccess:e=>(a(e.id),t(!1)),onError:e=>c(N(e),`error`)}),children:o(`plugins.magpie.import`)}),children:[l.isLoading&&(0,J.jsx)(s,{lines:3}),p?.error&&(0,J.jsx)(A,{tone:`danger`,title:o(`common.error`),children:p.error}),p&&(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:p.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)(i,{children:o(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(i,{tone:`accent`,children:o(`plugins.options`)}),e.installed&&(0,J.jsx)(i,{tone:`green`,children:o(`plugins.installed`)})]},e.spec))}),p.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(v,{checked:d,onChange:f,label:o(`plugins.magpie.signIns`,{count:p.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:o(`plugins.magpie.signInsDetail`)})]})]})]})}function be({id:e,onClose:t}){let{t:i}=n(),a=O(e).data;return(0,J.jsxs)(M,{open:!!e,onOpenChange:e=>!e&&t(),title:i(`plugins.job.title`),description:a?i(a.state===`running`?`plugins.job.running`:a.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:a.target}):void 0,width:620,footer:(0,J.jsx)(r,{onClick:t,children:i(`common.close`)}),children:[!a&&(0,J.jsx)(s,{lines:3}),a&&(0,J.jsx)(f,{language:`text`,children:a.log.length?a.log.join(`
2
2
  `):`…`}),a?.state===`failed`&&a.error&&(0,J.jsx)(A,{tone:`danger`,title:i(`plugins.job.failedTitle`),className:`mt-3`,children:a.error})]})}function xe({installed:e,onJob:t}){let{t:r,locale:i}=n(),{toast:a,confirm:o}=P(),c=C(),l=g(),[d,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(``),[h,_]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>m(d.trim()),400);return()=>clearTimeout(e)},[d]);let v=ee(p),b=(0,q.useMemo)(()=>new Set(e.map(e=>e.name)),[e]),x=(t,n)=>b.has(n)||e.some(e=>e.spec===t),S=async(e,n)=>{await o({title:r(`plugins.installConfirm`,{name:e}),detail:r(`plugins.trustDetail`),confirmLabel:r(`plugins.install`)})&&l.mutate({spec:e,source:n},{onSuccess:e=>t(e.id),onError:e=>a(N(e),`error`)})},[w,T]=W(),E=w.get(`install`),D=(0,q.useRef)(null);(0,q.useEffect)(()=>{E&&D.current!==E&&(D.current=E,T({},{replace:!0}),pe.test(E)?S(E,`market`):a(r(`plugins.linkInvalid`),`error`))},[E]);let O=(c.data??[]).filter(e=>h===`all`||e.kind===h),k=e=>(c.data??[]).filter(t=>e===`all`||t.kind===e).length,j=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)(te,{className:`min-w-[220px] flex-1`,value:d,onChange:f,placeholder:r(`plugins.searchPlaceholder`)}),!j&&(0,J.jsx)(y,{ariaLabel:r(`plugins.kindFilter`),value:h,onChange:_,items:[`all`,`provider`,`middleware`,`agent`].map(e=>({value:e,label:`${r(e===`all`?`plugins.kind.all`:Y[e])} ${k(e)}`}))})]}),j?(0,J.jsxs)(J.Fragment,{children:[v.isLoading&&(0,J.jsx)(s,{lines:3}),v.data?.length===0&&(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(u,{icon:(0,J.jsx)(I,{className:`size-6`}),title:r(`plugins.noResults`)})}),v.data&&v.data.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:v.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:x(e.spec,e.name),onInstall:()=>void S(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)(s,{lines:4}),c.isError&&(0,J.jsx)(A,{tone:`danger`,title:r(`common.error`),children:N(c.error)}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:O.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:x(e.package,e.package),onInstall:()=>void S(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:a,detail:o,tags:s,installed:c,onInstall:l}){let{t:u}=n();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:[a,(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:o??``}),(0,J.jsxs)(`div`,{className:`mt-auto flex items-center gap-1.5`,children:[s.filter(Boolean).map(e=>(0,J.jsx)(i,{children:e},e)),(0,J.jsx)(`span`,{className:`flex-1`}),c?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-[var(--success)]`,children:[(0,J.jsx)(ie,{className:`size-3.5`}),u(`plugins.installed`)]}):(0,J.jsx)(r,{size:`sm`,variant:`primary`,onClick:l,children:u(`plugins.install`)})]})]})}function Se({onJob:e}){let{t,locale:a}=n(),{toast:s}=P(),l=E(),u=T(),d=o(),f=l.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`}),f&&(0,J.jsx)(i,{tone:f.path?`green`:`neutral`,children:f.path?t(`plugins.bunReady`):t(`plugins.bunMissing`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.bunDetail`)}),f&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[f.path&&(0,J.jsx)(c,{label:t(`plugins.bunPath`),mono:!0,children:f.path}),f.version&&(0,J.jsx)(c,{label:t(`plugins.bunVersion`),mono:!0,children:f.version}),(0,J.jsx)(c,{label:t(`plugins.bunTarget`),mono:!0,children:f.target??t(`plugins.bunNoBuild`)})]}),f?.error&&(0,J.jsx)(A,{tone:`danger`,title:t(`plugins.bunFailed`),children:f.error}),f&&!f.path&&(0,J.jsx)(`div`,{children:(0,J.jsx)(r,{variant:`primary`,disabled:f.downloading||d.isPending||!f.target,onClick:()=>d.mutate(void 0,{onSuccess:t=>e(t.id),onError:e=>s(N(e),`error`)}),children:f.downloading?t(`plugins.bunDownloading`):t(`plugins.bunDownload`,{version:f.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`)}),u.data&&(0,J.jsx)(i,{tone:u.data.running?`green`:`neutral`,children:u.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`)}),u.data?.startError&&(0,J.jsx)(A,{tone:`danger`,title:t(`plugins.hostStartFailed`),children:u.data.startError}),u.data?.goneReason&&(0,J.jsx)(A,{tone:`warning`,title:t(`plugins.hostGone`),children:u.data.goneReason}),u.data&&u.data.plugins.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:u.data.plugins.map(e=>(0,J.jsx)(c,{label:e.spec,mono:!0,children:e.error?t(`plugins.hostPluginError`,{error:e.error}):e.provides.join(`, `)||`—`},e.spec))}),u.data?.recent&&u.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`)}),u.data.recent.map((e,t)=>(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-[12px]`,children:[(0,J.jsx)(i,{tone:e.variant===`error`?`red`:e.variant===`warning`?`orange`:e.variant===`success`?`green`:`neutral`,children:D(e.at,a)}),(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{he as PluginsPage};