@aidotnet/server-darwin-arm64 0.14.3101 → 0.14.3103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/astra-server +2 -2
- package/bin/wwwroot/assets/ClientsPage-CbisrdvY.js +9 -0
- package/bin/wwwroot/assets/KeyPage-BJkqoRws.js +1 -0
- package/bin/wwwroot/assets/McpPage-lDbAQFBD.js +3 -0
- package/bin/wwwroot/assets/ModelDetailPage-2SDue3md.js +1 -0
- package/bin/wwwroot/assets/ModelsPage-Djwi1_69.js +1 -0
- package/bin/wwwroot/assets/PluginsPage-Cr3_QueY.js +2 -0
- package/bin/wwwroot/assets/PrivacyPage-K20lHsrR.js +1 -0
- package/bin/wwwroot/assets/ProviderDetailPage-dCLgz9IA.js +3 -0
- package/bin/wwwroot/assets/ProvidersPage-B3UD_FXO.js +3 -0
- package/bin/wwwroot/assets/SettingsPage-BOv88_uQ.js +2 -0
- package/bin/wwwroot/assets/SmartRoutingPage-DUdAF-mO.js +2 -0
- package/bin/wwwroot/assets/TokenDetailPage-DAFuMypb.js +1 -0
- package/bin/wwwroot/assets/{TokenPoolEditor-DfmDnnxw.js → TokenPoolEditor-CGc4q0xj.js} +1 -1
- package/bin/wwwroot/assets/TokensPage-BAszgNt-.js +1 -0
- package/bin/wwwroot/assets/TracesPage-zR4Nhppl.js +8 -0
- package/bin/wwwroot/assets/{TrayPanelPage-xke1V9tu.js → TrayPanelPage-BzWJbHrV.js} +1 -1
- package/bin/wwwroot/assets/TrayPanelView-C8TTq4KZ.js +1 -0
- package/bin/wwwroot/assets/alert-BKRTQ9va.js +15 -0
- package/bin/wwwroot/assets/{arrow-down-DeIGdMUk.js → arrow-down-4QyszMPK.js} +1 -1
- package/bin/wwwroot/assets/{arrow-left-DX1c-nYY.js → arrow-left-CgusYKe5.js} +1 -1
- package/bin/wwwroot/assets/{arrow-up-right-D--u8dK5.js → arrow-up-right-CgKLuRMO.js} +1 -1
- package/bin/wwwroot/assets/{chart-column-zt3ZRFLH.js → chart-column-DrO0zSNb.js} +1 -1
- package/bin/wwwroot/assets/{checkbox-BJe8ekJy.js → checkbox-JghCvxwP.js} +1 -1
- package/bin/wwwroot/assets/{cloud-download-DWw6s5ag.js → cloud-download-Cq6X58YR.js} +1 -1
- package/bin/wwwroot/assets/confirm-morph-bdMiffHC.js +1 -0
- package/bin/wwwroot/assets/{ellipsis-BH_FL485.js → ellipsis-C09AxsS6.js} +1 -1
- package/bin/wwwroot/assets/{external-link-Bb6sx3jt.js → external-link-B54WZqyE.js} +1 -1
- package/bin/wwwroot/assets/{folder-open-Bcx5mAII.js → folder-open-DbnPnrzj.js} +1 -1
- package/bin/wwwroot/assets/index-8z9hfQDF.css +1 -0
- package/bin/wwwroot/assets/index-Cj8lNw6g.js +120 -0
- package/bin/wwwroot/assets/{log-out-Ch09k2bC.js → log-out-ZnLW7wzx.js} +1 -1
- package/bin/wwwroot/assets/minus-DosBdkUl.js +1 -0
- package/bin/wwwroot/assets/overlays-CizKmvVN.js +41 -0
- package/bin/wwwroot/assets/{pencil-fY6CohHT.js → pencil-BuVygJ9-.js} +1 -1
- package/bin/wwwroot/assets/{power-B9MMcl6Y.js → power-CfEiSxDi.js} +1 -1
- package/bin/wwwroot/assets/radio-cards-6WsHN05O.js +1 -0
- package/bin/wwwroot/assets/{rotate-ccw-DsmSscuv.js → rotate-ccw-BhDSBCvo.js} +1 -1
- package/bin/wwwroot/assets/{sortable.esm-CO34h2h7.js → sortable.esm-4hCCGHPl.js} +1 -1
- package/bin/wwwroot/index.html +4 -4
- package/package.json +1 -1
- package/bin/wwwroot/assets/ClientsPage-BsCvaS4d.js +0 -9
- package/bin/wwwroot/assets/KeyPage-bkK0B_mk.js +0 -1
- package/bin/wwwroot/assets/ModelDetailPage-BEVSPYM6.js +0 -1
- package/bin/wwwroot/assets/ModelsPage-BGij6zvC.js +0 -1
- package/bin/wwwroot/assets/PluginsPage-dVUvE8Lf.js +0 -2
- package/bin/wwwroot/assets/PrivacyPage-B-YBfQ6J.js +0 -1
- package/bin/wwwroot/assets/ProviderDetailPage-CQQdpDSf.js +0 -3
- package/bin/wwwroot/assets/ProvidersPage-BwigLnKs.js +0 -3
- package/bin/wwwroot/assets/SettingsPage-CvpROKS2.js +0 -2
- package/bin/wwwroot/assets/SmartRoutingPage-CYh7mRot.js +0 -2
- package/bin/wwwroot/assets/TokenDetailPage-GwSz8QI6.js +0 -1
- package/bin/wwwroot/assets/TokensPage-0hOOzLVU.js +0 -1
- package/bin/wwwroot/assets/TracesPage-A45sREZP.js +0 -8
- package/bin/wwwroot/assets/TrayPanelView-CHh9-E76.js +0 -1
- package/bin/wwwroot/assets/alert-CuKAE1Sv.js +0 -15
- package/bin/wwwroot/assets/confirm-morph-DGAHV4QP.js +0 -1
- package/bin/wwwroot/assets/download-DR9BLMVt.js +0 -1
- package/bin/wwwroot/assets/index-CKrvKDIJ.js +0 -17
- package/bin/wwwroot/assets/index-CpGX4nAj.css +0 -1
- package/bin/wwwroot/assets/minus-UfPYsFrp.js +0 -1
- package/bin/wwwroot/assets/overlays-DeHu6TU_.js +0 -41
- package/bin/wwwroot/assets/radio-cards-Rq9vGqnw.js +0 -1
package/bin/astra-server
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/bin/astra-server
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 60165424 bytes
|
|
4
|
+
sha256: 1c2b6fbae2669a6296bc4f09b4087bbba23fa467219a11eb25600a6f0f29d8bf
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{$r as e,Cr as t,Dn as n,Et as r,G as i,H as a,Hr as o,Ht as s,K as c,Kt as l,Nr as u,Qr as d,Qt as f,Sn as p,Ti as m,Ut as h,Wt as g,Y as _,Yr as v,Yt as y,Zt as b,_ as x,bn as S,bt as ee,c as C,co as te,ct as w,d as T,dr as E,dt as ne,gt as re,ii as ie,lo as ae,m as D,n as O,ot as k,po as oe,qt as se,r as A,s as ce,t as j,u as M,uo as le,v as N,xt as P,y as F,yr as ue}from"./alert-BKRTQ9va.js";import{a as I,ct as L,i as de,o as R,r as z,st as fe}from"./overlays-CizKmvVN.js";import{l as pe,n as B}from"./ProvidersPage-B3UD_FXO.js";import{t as me}from"./external-link-B54WZqyE.js";import{t as he}from"./folder-open-DbnPnrzj.js";import{a as ge,c as _e,d as V,f as H,i as ve,l as U,n as W,o as ye,p as be,r as G,s as xe,t as Se,u as Ce}from"./sortable.esm-4hCCGHPl.js";import{t as we}from"./rotate-ccw-BhDSBCvo.js";import{$ as Te,B as Ee,G as De,H as K,P as Oe,R as q,S as J,U as ke,W as Ae,b as je,h as Me,nt as Ne,tt as Pe,v as Fe,x as Ie,z as Le}from"./index-Cj8lNw6g.js";var Re={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Re.node;var ze=P(Re),Be={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};Be.node;var Y=P(Be),X=oe(le(),1),Z=ae(),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}=w(),{toast:r}=R(),i=Pe(),a=l(e),o=v(),[s,c]=(0,X.useState)(null),u=a.data?.mode??`gateway`,d=a.data?.accounts??[],f=a.data?.accountId??null??d.find(Ue)?.id??null,p=d.find(e=>e.id===f),m=u===`direct`,h=t&&(m||a.data!=null),g=m&&p?.telemetryEnabled===!0,_=se(g?p?.id:null,g),y=o.isPending,b=e=>o.mutate(e,{onError:e=>r(I(e),`error`)});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(M,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Z.jsx)(D,{label:n(`clients.claudeDirect.mode`),detail:n(m?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Z.jsx)(x,{ariaLabel:n(`clients.claudeDirect.mode`),value:u,onChange:e=>{if(e===u||y||!a.data)return;let t=f??d.find(Ue)?.id??null;if(e===`direct`&&!t){r(n(`clients.claudeDirect.needAccountToast`),`error`);return}b({mode:e,accountId:t})},items:[{value:`gateway`,label:n(`clients.claudeDirect.gateway`)},{value:`direct`,label:n(`clients.claudeDirect.direct`)}]})}),(0,Z.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:n(`clients.claudeDirect.modeNote`)})]}),a.isLoading&&(0,Z.jsx)(N,{lines:3}),a.isError&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(j,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:I(a.error)})}),h&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(j,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),a.data&&(0,Z.jsx)(M,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:d.length===0?(0,Z.jsx)(C,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Z.jsx)(A,{variant:`primary`,onClick:()=>i(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Z.jsx)(D,{label:n(`clients.claudeDirect.account`),children:(0,Z.jsx)(z,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:f,onChange:e=>{y||e===f||b({mode:u,accountId:e})},options:d.map(e=>({value:e.id,label:We(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!Ue(e)}))})})}),a.data&&m&&p&&(0,Z.jsx)(M,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Z.jsx)(Ke,{command:Ve,copied:s,onCopy:async e=>{await L.copy(e)&&(c(e),r(n(`common.copied`)))}})}),a.data&&m&&p&&(0,Z.jsxs)(M,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Z.jsx)(D,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Z.jsx)(F,{label:n(`clients.claudeDirect.statsConsent`),checked:p.telemetryEnabled,disabled:y,onChange:e=>{p&&!y&&b({mode:u,accountId:p.id,telemetryEnabled:e})}})}),g&&(0,Z.jsx)(qe,{requests:_})]})]})}function Ke({command:e,copied:t,onCopy:n}){let{t:r}=w();return(0,Z.jsx)(D,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Z.jsx)(A,{size:`sm`,icon:(0,Z.jsx)(re,{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}=w(),r=e.data??[],o=He(r);return e.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(N,{lines:3})}):e.isError?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(j,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:I(e.error)})}):r.length===0?(0,Z.jsx)(C,{icon:(0,Z.jsx)(ke,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(D,{label:t(`clients.claudeDirect.statsTotals`,{count:_(o.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:_(o.totalInputTokens),cache:_(r.reduce((e,t)=>e+t.cacheReadTokens,0)),output:_(o.outputTokens)})}),(0,Z.jsx)(D,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:c(r.some(e=>e.estimatedCostNanoUsd!=null)?o.estimatedCostNanoUsd:null)})}),o.failed>0&&(0,Z.jsx)(D,{label:t(`clients.claudeDirect.statsFailedCount`,{count:_(o.failed)}),children:(0,Z.jsx)(O,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),r.map(e=>(0,Z.jsx)(D,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.model}),e.status===`error`?(0,Z.jsx)(O,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Z.jsx)(O,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Z.jsx)(`span`,{className:`num`,children:[a(e.occurredAtUtc,n),t(`clients.claudeDirect.tokensDetail`,{input:_(e.inputTokens),output:_(e.outputTokens)}),e.durationMs==null?null:i(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:c(e.estimatedCostNanoUsd)})},e.id))]})}function Je({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=w(),a=(e,r)=>{let i={...t};r===void 0||r===!1||r===0||r==="default"||r===``?delete i[e]:i[e]=r,n(i)};return(0,Z.jsx)(M,{title:i(`clients.options.title`),footer:i(r?`clients.options.footerEnabled`:`clients.options.footer`),children:e.map(e=>{let n=i(`clients.option.${e.key}`),r=i(`clients.option.${e.key}.hint`),o=t[e.key];return(0,Z.jsxs)(D,{label:n,detail:r,children:[e.type===`bool`&&(0,Z.jsx)(F,{label:n,checked:o===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(0,Z.jsx)(T,{className:`w-36`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof o==`number`?String(o):``,onChange:t=>{let n=Number.parseInt(t.target.value.replace(/\D/g,``),10);a(e.key,Number.isFinite(n)?n:void 0)}}),e.type===`enum`&&(0,Z.jsx)(z,{ariaLabel:n,value:typeof o==`string`?o:`default`,onChange:t=>a(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-36`})]},e.key)})})}var 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
|
+
`),tt=`auto`,nt=e=>B.find(t=>t.value===e)?.label??e;function rt({models:e,supported:t,values:n,onChange:r,enabled:i}){let{t:a}=w(),o=(e,t)=>{let i={...n};t===tt?delete i[e]:i[e]=t,r(i)};return(0,Z.jsx)(M,{title:a(`clients.protocols.title`),footer:a(i?`clients.protocols.footerEnabled`:`clients.protocols.footer`),children:e.map(e=>{let r=$e(e,t),i=e.native.filter(e=>t.includes(e));return(0,Z.jsx)(D,{label:e.name,detail:i.length>0?a(`clients.protocols.native`,{protocols:i.map(nt).join(` · `)}):a(`clients.protocols.noNative`),children:(0,Z.jsx)(z,{ariaLabel:e.name,className:`w-60`,value:n[e.id]&&t.includes(n[e.id])?n[e.id]:tt,onChange:t=>o(e.id,t),options:[{value:tt,label:a(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){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 at=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
|
|
3
|
+
`),ot=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`];function st(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of ot){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var ct=e=>ot.map(t=>e[t]??``).join(`
|
|
4
|
+
`),Q=[`sonnet`,`opus`,`haiku`];function lt(e){let t=e?.roleMap,n={};if(!t||typeof t!=`object`)return n;for(let e of Q){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var $=e=>Q.map(t=>e[t]??``).join(`
|
|
5
|
+
`),ut=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function dt(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!ut.test(e))??e[0],r=e.find(e=>ut.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function ft(){let{t:e}=w(),t=Pe(),{toast:n}=R(),r=Ne(),i=f(),a=g(),o=(0,X.useMemo)(()=>new Map((i.data??[]).map(e=>[e.kind,e])),[i.data]),s=mt(i.data).includes(r.kind)?r.kind:`codex`,c=o.get(s);return(0,X.useEffect)(()=>a.mutate(!1),[]),(0,Z.jsx)(Me,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Z.jsx)(A,{icon:(0,Z.jsx)(Le,{className:`size-3.5`}),loading:a.isPending,onClick:()=>a.mutate(!0,{onSuccess:t=>{let r=t.filter(e=>e.install?.updateAvailable&&e.install.blocker!==`shadowed`).length;n(r>0?e(`clients.updatesFound`,{count:r}):e(`clients.allUpToDate`),r>0?void 0:`success`)},onError:e=>n(I(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Z.jsx)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Z.jsx)(yt,{clients:i.data,loading:i.isLoading,selected:s,onSelect:e=>t(`/clients/${e}`,{replace:!0})}),(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-[760px] min-w-0 flex-1`,children:[i.isLoading&&(0,Z.jsx)(N,{lines:4}),i.isError&&(0,Z.jsx)(j,{tone:`danger`,title:e(`common.error`),children:I(i.error)}),c&&(0,Z.jsx)(Ct,{client:c})]})]})})})}var pt=new Set([`opencode`,`pi`,`minimax-code`,`copilot-cli`,`vscode-copilot`,`crush`,`qwen-code`,`droid`,`kimi-code`,`zed`,`vscode-insiders`,`vscodium`,`omp`,`mimo-code`,`deepseek-harness`,`workbuddy`,`workbuddy-ai`,`nextcowork`,`paseo`,`zcode`,`tkcode`,`muse-code`,`codex`,`grok-build`,`hermes-agent`]);function mt(e){let t=(e??[]).filter(e=>!Fe.includes(e.kind)).sort((e,t)=>e.name.localeCompare(t.name));return[...Fe,...t.map(e=>e.kind)]}var ht=[`installed`,`notInstalled`,`comingSoon`],gt=new Set([`notInstalled`]);function _t(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function vt(e){return e.install?.version??e.detection.version??null}function yt({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=w(),[a,o]=(0,X.useState)(new Set),s=new Map((e??[]).map(e=>[e.kind,e])),c=ht.map(t=>({group:t,items:mt(e).flatMap(e=>{let n=s.get(e);return n&&_t(n)===t?[n]:[]})})).filter(e=>e.items.length>0);return(0,Z.jsxs)(`nav`,{"aria-label":i(`nav.clients`),className:`card shrink-0 p-1.5 @3xl:sticky @3xl:top-0 @3xl:w-[232px]`,children:[t&&(0,Z.jsx)(N,{lines:6,className:`p-2`}),(0,Z.jsx)(`div`,{className:`flex gap-1 overflow-x-auto @3xl:flex-col @3xl:gap-0 @3xl:overflow-visible`,children:c.map(({group:e,items:t})=>{let s=gt.has(e),c=!s||a.has(e)||t.some(e=>e.kind===n),l=`${i(`clients.group.${e}`)} · ${t.length}`;return(0,Z.jsxs)(`div`,{className:`contents @3xl:block`,children:[s?(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":c,"aria-label":i(c?`clients.group.collapse`:`clients.group.expand`,{group:l}),onClick:()=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),className:`flex shrink-0 items-center gap-1 rounded-[var(--radius-control)] px-2.5 py-1.5 text-[11px] font-medium whitespace-nowrap text-[var(--text-muted)] hover:bg-[var(--surface-muted)] @3xl:w-full @3xl:pt-2 @3xl:pb-1`,children:[(0,Z.jsx)(De,{size:12,className:k(`transition-transform`,c&&`rotate-90`)}),l]}):(0,Z.jsx)(`h3`,{className:`hidden px-2.5 pt-2 pb-1 text-[11px] font-medium text-[var(--text-muted)] @3xl:block`,children:l}),c&&t.map(e=>(0,Z.jsx)(bt,{client:e,active:e.kind===n,onSelect:()=>r(e.kind)},e.kind))]},e)})})]})}function bt({client:e,active:t,onSelect:n}){let{t:r}=w(),i=_t(e)!==`installed`,a=vt(e),o=e.install?.blocker===`shadowed`,s=e.install?.updateAvailable&&!o?e.install.latestVersion:null;return(0,Z.jsxs)(`button`,{type:`button`,"aria-label":J(e.kind,e.name),"aria-current":t?`page`:void 0,onClick:n,className:k(`flex shrink-0 items-center gap-2.5 rounded-[var(--radius-control)] px-2.5 py-1.5 text-left transition-colors @3xl:w-full`,t?`bg-[var(--accent-subtle)]`:`hover:bg-[var(--surface-muted)]`),children:[(0,Z.jsx)(`span`,{className:k(`inline-flex`,i&&!t&&`opacity-60`),children:(0,Z.jsx)(je,{kind:e.kind,size:24})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:k(`block truncate text-[13px] whitespace-nowrap`,t&&`font-medium`),children:J(e.kind,e.name)}),a&&(0,Z.jsxs)(`span`,{className:`hidden truncate text-[11px] text-[var(--text-secondary)] @3xl:block`,children:[a,s&&(0,Z.jsxs)(`span`,{className:`text-[var(--warning)]`,children:[` → `,s]})]})]}),e.install?.busy&&(0,Z.jsx)(xt,{}),s&&!e.install?.busy&&(0,Z.jsx)(O,{tone:`orange`,title:r(`clients.updateTo`,{version:s}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Z.jsx)(O,{tone:`orange`,title:r(`clients.shadowed.title`,{version:e.install?.latestVersion??``}),children:r(`clients.shadowedBadge`)}),e.status===`drifted`?(0,Z.jsx)(`span`,{title:r(`clients.drifted`),"aria-label":r(`clients.drifted`),className:`inline-flex`,children:(0,Z.jsx)(ce,{tone:`orange`})}):e.enabled?(0,Z.jsx)(ee,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function xt(){return(0,Z.jsx)(K,{className:`size-3.5 shrink-0 animate-spin text-[var(--text-secondary)] motion-reduce:animate-none`,"aria-hidden":!0})}function St(e,t){return e.availability===`coming_soon`?(0,Z.jsx)(O,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Z.jsx)(O,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Z.jsx)(O,{tone:`green`,children:t(`clients.enabled`)}):(0,Z.jsx)(O,{children:t(`clients.disabled`)})}function Ct({client:e}){let{t:r,locale:i}=w(),o=Pe(),{toast:s,confirm:c}=R(),f=t(),p=d(),h=S(),g=n(),_=u(),v=m(),y=b(e.kind,!!e.providerId),[x,ee]=(0,X.useState)(e.selectedModel??null),[C,te]=(0,X.useState)(e.accountId??``),T=e.tokenId??`default`,[E,ne]=(0,X.useState)(T),ie=(v.data??[]).filter(e=>e.enabled||e.id===T).map(e=>({value:e.id,label:e.enabled?e.name:r(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[ae,k]=(0,X.useState)(!1),[oe,se]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(null),P=e.availability===`coming_soon`,F=J(e.kind,e.name),de=(f.data??[]).filter(e=>e.enabled),B=e.detection.configPaths[0],me=de.find(t=>t.id===e.providerId),ge=me?.authScheme===`oauth-subscription`||me?.authScheme===`plugin`,_e=ue(me?.id,ge),V=e.kind===`claude-desktop`,H=e.kind===`claude-code`,ve=l(H),U=H&&ve.data?.mode===`direct`,W=lt(e.extras),[ye,be]=(0,X.useState)(W),G=Q.some(e=>ye[e]),xe=$(ye)!==$(W),Se=st(e.extras),[Ce,we]=(0,X.useState)(Se),Te=(x??null)!==(e.selectedModel??null)||ct(Ce)!==ct(Se),Ee=H?ot.filter(e=>e!==`ANTHROPIC_MODEL`):[],De=H?e.enabled?r(`clients.modelSlotsFooterEnabled`):r(`clients.modelSlotsFooter`):e.enabled?r(`clients.modelFooterEnabled`):r(`clients.modelFooter`),K=e.options??[],Oe=it(e.extras,K),[q,Ae]=(0,X.useState)(Oe),Me=at(q)!==at(Oe),Ne=e.protocols??[],Fe=Ne.length>1?Qe(e.extras):[],Ie=Ze(e.extras),[Le,Re]=(0,X.useState)(Ie),ze=et(Le)!==et(Ie),Be=V?{...e.extras,roleMap:ye}:H?{...e.extras,models:Ce,options:q}:K.length>0||Ne.length>1?{...e.extras,...K.length>0?{options:q}:{},...Ne.length>1?{protocolOverrides:Le}:{}}:void 0;(0,X.useEffect)(()=>ee(e.selectedModel??null),[e.kind,e.selectedModel]),(0,X.useEffect)(()=>te(e.accountId??``),[e.kind,e.providerId,e.accountId]),(0,X.useEffect)(()=>ne(T),[e.kind,T]),(0,X.useEffect)(()=>be(lt(e.extras)),[e.kind,$(W)]);let Y=(0,X.useRef)({});(0,X.useEffect)(()=>{if(!V||e.enabled||Q.some(e=>W[e]))return;let t=Y.current,n=dt(y.data??[]);Y.current=n,be(e=>(!Q.some(t=>e[t])||$(e)===$(t))&&$(e)!==$(n)?n:e)},[e.kind,e.enabled,$(W),(y.data??[]).join(`
|
|
6
|
+
`)]),(0,X.useEffect)(()=>we(st(e.extras)),[e.kind,ct(Se)]),(0,X.useEffect)(()=>Ae(it(e.extras,e.options)),[e.kind,at(Oe)]),(0,X.useEffect)(()=>Re(Ze(e.extras)),[e.kind,et(Ie)]);let Ve=()=>{e.providerId&&p.mutate({kind:e.kind,providerId:e.providerId,accountId:C},{onSuccess:()=>s(r(`common.saved`),`success`),onError:e=>s(I(e),`error`)})},He=async()=>{await c({title:r(`clients.disableConfirm`,{name:F}),detail:r(`clients.disableDetail`),confirmLabel:r(`clients.disable`)})&&h.mutate(e.kind,{onSuccess:async t=>{if(t.drifted.length===0){s(r(`clients.disabledToast`,{name:F}),`success`);return}await c({title:r(`clients.driftTitle`),detail:r(`clients.driftDetail`,{keys:t.drifted.join(`, `)}),confirmLabel:r(`clients.forceRestore`),destructive:!0})&&g.mutate(e.kind,{onSuccess:()=>s(r(`clients.disabledToast`,{name:F}),`success`),onError:e=>s(I(e),`error`)})},onError:e=>s(I(e),`error`)})},Ue=async()=>{B&&(L.canOpenPaths?await L.openPath(fe(B)):await L.copy(B)&&s(r(`common.copied`)))};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(M,{children:[(0,Z.jsxs)(D,{icon:(0,Z.jsx)(je,{kind:e.kind,size:36}),label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[15px] font-medium`,children:F}),U?(0,Z.jsx)(O,{children:r(`clients.claudeDirect.direct`)}):St(e,r)]}),detail:P?e.availabilityReason??r(`clients.comingSoonDetail`):[_t(e)===`installed`?r(`clients.detected`,{version:vt(e)??``}):r(`clients.notDetected`),U?null:B].filter(Boolean).join(` · `),className:`py-3`,children:[!P&&(0,Z.jsx)(kt,{client:e,onOpen:le}),U?(0,Z.jsx)(A,{variant:`primary`,onClick:()=>document.getElementById(jt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:r(`clients.claudeDirect.configure`)}):e.enabled?(0,Z.jsx)(A,{onClick:()=>void He(),loading:h.isPending,children:r(`clients.disableRestore`)}):(0,Z.jsx)(A,{variant:`primary`,disabled:P||!e.providerId||V&&!G,onClick:()=>k(!0),title:e.providerId?V&&!G?r(`clients.roleMapRequired`):void 0:r(`clients.pickProviderFirst`),children:r(`clients.enable`)})]}),!U&&e.appliedAt&&(0,Z.jsx)(D,{label:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`clients.appliedAt`,{time:a(e.appliedAt,i)})})})]}),!P&&!e.enabled&&V&&e.providerId&&!G&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsx)(j,{tone:`info`,className:`self-stretch`,title:r(`clients.roleMapHint`)}),(0,Z.jsx)(A,{onClick:()=>document.getElementById(Mt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:r(`clients.roleMapGoto`)})]}),(e.repairs?.length??0)>0&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsxs)(j,{tone:`danger`,className:`self-stretch`,title:r(`clients.repair.title`,{name:F}),children:[e.repairs?.map(e=>(0,Z.jsxs)(`span`,{className:`block break-all`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.file}),` — `,r(`clients.repair.problem.${e.problem}`,{line:e.line})]},e.file)),(0,Z.jsx)(`span`,{className:`block`,children:r(`clients.repair.hint`)})]}),(0,Z.jsx)(A,{variant:`primary`,loading:_.isPending,onClick:()=>_.mutate(e.kind,{onSuccess:()=>s(r(`clients.repair.done`,{name:F}),`success`),onError:e=>s(I(e),`error`)}),children:r(`clients.repair.action`)})]}),!U&&e.warnings.length>0&&(0,Z.jsx)(`div`,{className:`mb-5 flex flex-col gap-2`,children:e.warnings.map((e,t)=>(0,Z.jsx)(j,{tone:`warning`,title:e},t))}),!U&&(0,Z.jsx)(Dt,{client:e,providers:f.data??[],loading:f.isLoading,soon:P}),!U&&ge&&(0,Z.jsx)(M,{title:r(`clients.accountTitle`),footer:r(`clients.accountFooter`),children:_e.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(N,{lines:2})}):(0,Z.jsxs)(D,{label:r(`clients.account`),children:[(0,Z.jsx)(z,{className:`max-w-[300px]`,ariaLabel:r(`clients.account`),value:C,onChange:te,options:[{value:``,label:r(`clients.accountDefault`)},...(_e.data??[]).map(e=>({value:e.id,label:(e.displayName||e.id)+(e.status===`active`?``:` · ${r(`providers.subscription.status.${e.status}`)}`)}))]}),C!==(e.accountId??``)&&(0,Z.jsx)(A,{size:`sm`,variant:`primary`,loading:p.isPending,onClick:Ve,children:r(`common.apply`)})]})}),!P&&!U&&(0,Z.jsxs)(M,{title:r(`clients.tokenTitle`),footer:e.enabled?r(`clients.tokenFooterEnabled`):r(`clients.tokenFooter`),children:[(0,Z.jsxs)(D,{label:r(`clients.token`),children:[(0,Z.jsx)(z,{className:`max-w-[300px]`,ariaLabel:r(`clients.token`),value:E,onChange:ne,options:ie}),e.enabled&&E!==T&&(0,Z.jsx)(A,{size:`sm`,variant:`primary`,onClick:()=>k(!0),children:r(`common.apply`)})]}),(0,Z.jsx)(D,{icon:(0,Z.jsx)(ke,{className:`size-4 text-[var(--text-secondary)]`}),label:r(`clients.manageTokens`),onClick:()=>o(`/tokens`)})]}),!P&&!U&&e.providerId&&V&&(0,Z.jsx)(`div`,{id:Mt,children:(0,Z.jsxs)(M,{title:r(`clients.roleMapTitle`),footer:e.enabled?r(`clients.roleMapFooterEnabled`):r(`clients.roleMapFooter`),children:[Q.map(e=>(0,Z.jsx)(D,{label:r(`clients.role.${e}`),children:(0,Z.jsx)(z,{ariaLabel:r(`clients.role.${e}`),value:ye[e]??``,onChange:t=>be(n=>({...n,[e]:t||void 0})),placeholder:r(`clients.modelPlaceholder`),options:[{value:``,label:r(`clients.modelUnset`)},...(y.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&xe&&(0,Z.jsx)(D,{label:G?``:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--warning)]`,children:r(`clients.roleMapRequired`)}),children:(0,Z.jsx)(A,{size:`sm`,variant:`primary`,disabled:!G,onClick:()=>k(!0),children:r(`common.apply`)})})]})}),!P&&!U&&e.providerId&&!V&&(0,Z.jsxs)(M,{title:r(`clients.modelTitle`),footer:De,children:[(0,Z.jsx)(D,{label:r(`clients.defaultModel`),children:(0,Z.jsx)(z,{value:x??``,onChange:e=>ee(e||null),placeholder:r(`clients.modelPlaceholder`),options:[{value:``,label:r(`clients.modelUnset`)},...(y.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})}),Ee.map(e=>(0,Z.jsx)(D,{label:r(`clients.modelSlot.${e}`),children:(0,Z.jsx)(z,{ariaLabel:r(`clients.modelSlot.${e}`),value:Ce[e]??``,onChange:t=>we(n=>({...n,[e]:t||void 0})),placeholder:r(`clients.modelPlaceholder`),options:[{value:``,label:r(`clients.modelUnset`)},...(y.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&(H?Te:(x??null)!==(e.selectedModel??null))&&(0,Z.jsx)(D,{label:``,children:(0,Z.jsx)(A,{size:`sm`,variant:`primary`,onClick:()=>k(!0),children:r(`common.apply`)})})]}),!P&&!U&&K.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Je,{descriptors:K,values:q,onChange:Ae,enabled:e.enabled}),e.enabled&&Me&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(A,{size:`sm`,variant:`primary`,onClick:()=>k(!0),children:r(`common.apply`)})})]}),!P&&Fe.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(rt,{models:Fe,supported:Ne,values:Le,onChange:Re,enabled:e.enabled}),e.enabled&&ze&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(A,{size:`sm`,variant:`primary`,onClick:()=>k(!0),children:r(`common.apply`)})})]}),!P&&e.install&&(0,Z.jsx)(Pt,{client:e,onShowLog:()=>le(`log`),onUninstall:()=>le(`uninstall`)}),H&&(0,Z.jsx)(`div`,{id:jt,children:(0,Z.jsx)(Ge,{enabled:H,gatewayEnabled:e.enabled})}),!P&&!U&&(0,Z.jsxs)(M,{title:r(`clients.maintenance`),children:[B&&(0,Z.jsx)(D,{icon:L.canOpenPaths?(0,Z.jsx)(he,{className:`size-4 text-[var(--text-secondary)]`}):(0,Z.jsx)(re,{className:`size-4 text-[var(--text-secondary)]`}),label:L.canOpenPaths?r(`clients.openConfigDir`):r(`clients.copyConfigPath`),detail:B,onClick:()=>void Ue()}),(0,Z.jsx)(D,{icon:(0,Z.jsx)(pe,{className:`size-4 text-[var(--text-secondary)]`}),label:r(`clients.backups`),detail:r(`clients.backupsDetail`),onClick:()=>se(!0)})]}),(0,Z.jsx)(It,{open:ae,onOpenChange:k,client:e,model:x,extras:Be,tokenId:E}),(0,Z.jsx)(zt,{open:oe,onOpenChange:se,client:e}),(0,Z.jsx)(Ft,{mode:ce,onClose:()=>le(null),client:e})]})}var wt={install:`clients.installTitle`,update:`clients.updateTitle`,uninstall:`clients.uninstallTitle`},Tt={install:`clients.installedToast`,update:`clients.updatedToast`,uninstall:`clients.uninstalledToast`};function Et(e,t){return[e.priceKey??e.templateId,t(`providers.modelCount`,{count:e.modelCount}),e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `)}function Dt({client:t,providers:n,loading:r,soon:i}){let{t:a}=w(),{toast:o}=R(),s=e(),c=(0,X.useMemo)(()=>t.bindings??(t.providerId?[{providerId:t.providerId,accountId:t.accountId}]:[]),[t.bindings,t.providerId,t.accountId]),[l,u]=(0,X.useState)(c);(0,X.useEffect)(()=>u(c),[c]);let d=(0,X.useMemo)(()=>new Map(n.map(e=>[e.id,e])),[n]),f=l.flatMap(e=>{let t=d.get(e.providerId);return t?[{binding:e,provider:t}]:[]}),p=n.filter(e=>e.enabled&&!l.some(t=>t.providerId===e.id)),m=V(Ce(_e,{activationConstraint:{distance:4}}),Ce(xe,{coordinateGetter:G})),h=i||s.isPending,g=(e,n)=>{let r=l;u(e),s.mutate({kind:t.kind,bindings:e},{onSuccess:()=>o(pt.has(t.kind)&&t.enabled?a(`clients.providersModelsSynced`,{client:J(t.kind,t.name)}):n),onError:e=>{u(r),o(I(e),`error`)}})},_=({active:e,over:t})=>{if(!t||e.id===t.id)return;let n=l.findIndex(t=>t.providerId===e.id),r=l.findIndex(e=>e.providerId===t.id);n<0||r<0||g(W(l,n,r),a(`clients.providerOrderSaved`))},v=e=>g([...l,{providerId:e.id}],a(`clients.providerAdded`,{provider:e.name})),y=e=>g(l.filter(t=>t.providerId!==e.id),a(`clients.providerRemoved`,{provider:e.name})),b=p.map(e=>(0,Z.jsx)(D,{icon:(0,Z.jsx)(Ie,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24}),label:e.name,detail:Et(e,a),onClick:h?void 0:()=>v(e),children:!i&&(0,Z.jsx)(Ee,{className:`size-4 text-[var(--text-secondary)]`,"aria-label":a(`common.add`)})},e.id));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(M,{title:a(`clients.providerTitle`),footer:a(`clients.providerFooter`),children:[r&&(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(N,{lines:2})}),!r&&f.length===0&&p.length===0&&(0,Z.jsx)(C,{title:a(`clients.noProviders`),detail:a(`clients.noProvidersDetail`),action:(0,Z.jsx)(Te,{to:`/providers?new=1`,children:(0,Z.jsx)(A,{variant:`primary`,icon:(0,Z.jsx)(Ee,{className:`size-3.5`}),children:a(`providers.add`)})})}),f.length>0&&(0,Z.jsx)(ye,{sensors:m,collisionDetection:U,onDragEnd:_,children:(0,Z.jsx)(Se,{items:f.map(e=>e.provider.id),strategy:ge,children:f.map(({provider:e},t)=>(0,Z.jsx)(Ot,{provider:e,primary:t===0,disabled:h,onRemove:f.length>1?()=>y(e):void 0},e.id))})}),!r&&f.length===0&&b]}),f.length>0&&p.length>0&&(0,Z.jsx)(M,{title:a(`clients.moreProvidersTitle`),children:b})]})}function Ot({provider:e,primary:t,disabled:n,onRemove:r}){let{t:i}=w(),{attributes:a,listeners:o,setNodeRef:s,setActivatorNodeRef:c,transform:l,transition:u,isDragging:d}=ve({id:e.id,disabled:n});return(0,Z.jsx)(`div`,{ref:s,style:{transform:H.Transform.toString(l),transition:u},className:k(d&&`relative z-10 bg-[var(--surface)] shadow-lg`),children:(0,Z.jsx)(D,{icon:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`button`,{ref:c,type:`button`,"aria-label":i(`clients.dragToReorder`,{provider:e.name}),title:i(`clients.dragToReorder`,{provider:e.name}),className:`-ml-1 inline-flex cursor-grab touch-none text-[var(--text-muted)] hover:text-[var(--text-secondary)] active:cursor-grabbing disabled:cursor-default disabled:opacity-50`,...a,...o,children:(0,Z.jsx)(be,{className:`size-4`})}),(0,Z.jsx)(Ie,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24})]}),label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),t&&(0,Z.jsx)(O,{tone:`accent`,children:i(`clients.primaryProvider`)}),!e.enabled&&(0,Z.jsx)(O,{tone:`orange`,children:i(`clients.providerDisabledBadge`)})]}),detail:Et(e,i),children:r&&(0,Z.jsx)(A,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(ne,{className:`size-3.5`}),"aria-label":i(`clients.removeProvider`,{provider:e.name}),title:i(`clients.removeProvider`,{provider:e.name}),disabled:n,onClick:r})})})}function kt({client:e,onOpen:t}){let{t:n}=w(),r=e.install;if(!r)return null;let i=r.needsAdmin?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-[var(--warning)]`,children:[(0,Z.jsx)(Y,{className:`size-3`,"aria-hidden":!0}),n(`clients.admin.badge`)]}):null,a=r.needsAdmin?n(r.adminAvailable?`clients.admin.tip`:`clients.admin.tipManual`):void 0;return r.busy?(0,Z.jsx)(A,{icon:(0,Z.jsx)(xt,{}),onClick:()=>t(`log`),children:n(`clients.installRunning`)}):r.updateAvailable&&r.updateCommand&&r.latestVersion?(0,Z.jsxs)(A,{icon:(0,Z.jsx)(ze,{className:`size-3.5`}),title:a,onClick:()=>t(`update`),children:[n(`clients.updateTo`,{version:r.latestVersion}),i]}):r.updateAvailable&&r.blocker===`shadowed`?(0,Z.jsx)(A,{icon:(0,Z.jsx)(Y,{className:`size-3.5`}),onClick:()=>document.getElementById(At)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:n(`clients.shadowedBadge`)}):!r.installed&&r.installCommand?(0,Z.jsxs)(A,{icon:(0,Z.jsx)(Ae,{className:`size-3.5`}),title:a,onClick:()=>t(`install`),children:[n(`clients.install`),i]}):!r.installed&&r.method===`manual`?(0,Z.jsx)(A,{icon:(0,Z.jsx)(me,{className:`size-3.5`}),onClick:()=>window.open(r.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.download`)}):null}var At=`client-shadowed-alert`,jt=`claude-direct-panel`,Mt=`client-role-map`;function Nt(e,t){return!e.installed||e.uninstallCommand?null:e.method===`npm`?t(`clients.uninstallExternal`,{path:e.executable??``}):e.method===`vscode-extension`?t(`clients.uninstallBuiltIn`):t(`clients.uninstallManual`)}function Pt({client:e,onShowLog:t,onUninstall:n}){let{t:r,locale:i}=w(),o=e.install,s=y(e.kind),c=(e,t=!1)=>(0,Z.jsx)(`span`,{className:k(`text-[13px] tabular-nums selectable`,t&&`text-[var(--text-secondary)]`),children:e}),l=o.blocker===`external-install`?r(`clients.blocker.external-install`,{path:o.executable??``}):o.blocker?r(`clients.blocker.${o.blocker}`):void 0,u=o.otherCopies??[],d=u.find(e=>e.newer);return(0,Z.jsxs)(Z.Fragment,{children:[d&&(0,Z.jsx)(`div`,{id:At,className:`mb-3`,children:(0,Z.jsx)(j,{tone:`warning`,title:r(`clients.shadowed.title`,{version:d.version}),children:r(`clients.shadowed.detail`,{path:o.executable??``,version:o.version??``,other:d.path,dir:fe(d.path)})})}),!d&&o.notOnPath&&o.executable&&(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(j,{tone:`warning`,title:r(`clients.notOnPath.title`),children:r(`clients.notOnPath.detail`,{dir:fe(o.executable)})})}),(0,Z.jsxs)(M,{title:r(`clients.versionTitle`),footer:l,children:[(0,Z.jsx)(D,{label:r(`clients.currentVersion`),detail:o.installed?o.executable:void 0,children:o.installed?c(o.version??r(`clients.versionUnknown`),!o.version):c(r(`clients.notInstalled`),!0)}),u.map(e=>(0,Z.jsxs)(D,{label:r(`clients.otherCopy`),detail:e.path,children:[e.newer&&(0,Z.jsx)(O,{tone:`orange`,children:r(`clients.otherCopyNewer`)}),c(e.version,!e.newer)]},e.path)),(o.method===`npm`||o.method===`script`)&&(0,Z.jsxs)(D,{label:r(`clients.latestVersion`),detail:o.latestError??(o.latestCheckedAt?r(`clients.checkedAt`,{time:a(o.latestCheckedAt,i)}):void 0),children:[o.updateAvailable&&(0,Z.jsx)(O,{tone:`orange`,children:r(`clients.updateBadge`)}),c(o.latestVersion??r(`clients.latestUnknown`),!o.latestVersion)]}),(0,Z.jsx)(D,{label:r(`clients.installMethod`),detail:r(`clients.method.${o.method}`,{package:o.package??``}),children:(0,Z.jsx)(A,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(me,{className:`size-3`}),onClick:()=>window.open(o.homepageUrl,`_blank`,`noreferrer`),children:r(`clients.homepage`)})}),o.installed&&(0,Z.jsx)(D,{label:r(`clients.uninstall`),detail:o.uninstallCommand??Nt(o,r),children:o.uninstallCommand&&(0,Z.jsx)(A,{size:`sm`,variant:`destructive`,icon:(0,Z.jsx)(Oe,{className:`size-3`}),disabled:o.busy,onClick:n,children:r(`clients.uninstall`)})}),s.data&&(0,Z.jsx)(D,{icon:(0,Z.jsx)(q,{className:`size-4 text-[var(--text-secondary)]`}),label:r(`clients.installLog`),detail:`${s.data.command} · ${r(`clients.job.${s.data.state}`)}`,onClick:t})]})]})}function Ft({mode:e,onClose:t,client:n}){let{t:i}=w(),{toast:a}=R(),o=te(),s=e!==null,c=y(n.kind,s||!!n.install?.busy),l=ie(),u=h(),[d,f]=(0,X.useState)(!1),p=(0,X.useRef)(null),m=(0,X.useRef)(void 0),g=J(n.kind,n.name),_=n.install,v=e===`log`?null:e,b=v===`install`?_?.installCommand:v===`update`?_?.updateCommand:v===`uninstall`?_?.uninstallCommand:null,x=v===`uninstall`,S=c.data,ee=v!==null&&!d&&S?.state!==`running`,T=!!_?.needsAdmin,E=!!_?.adminAvailable,ne=S?.state===`failed`&&S.hint===`permission-denied`&&!S.elevated&&E;(0,X.useEffect)(()=>{s&&f(!1)},[s,e]),(0,X.useEffect)(()=>{let e=S?.state;m.current===`running`&&e&&e!==`running`&&(o.invalidateQueries({queryKey:r.clients}),e===`succeeded`&&S.hint?a(i(`clients.notEffectiveToast`,{name:g})):e===`succeeded`&&a(i(Tt[S.action],{name:g}),`success`)),m.current=e},[S?.state,S?.action,S?.hint,g,o,i,a]),(0,X.useEffect)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[S?.log.length]);let ae=(e,t)=>l.mutate({kind:n.kind,action:e,elevated:t},{onSuccess:()=>f(!0),onError:e=>a(I(e),`error`)}),D=async e=>{await L.copy(e)&&a(i(`common.copied`))},O=i(wt[v??S?.action??`install`],{name:g}),oe={running:`info`,succeeded:`success`,failed:`danger`,cancelled:`warning`},se=`rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[12px] break-all whitespace-pre-wrap selectable`,ce=_?.adminFixCommand?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-secondary)]`,children:i(`clients.admin.fixTip`)}),(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`pre`,{className:k(se,`min-w-0 flex-1`),children:_.adminFixCommand}),(0,Z.jsx)(A,{size:`sm`,icon:(0,Z.jsx)(re,{className:`size-3`}),"aria-label":i(`common.copy`),onClick:()=>void D(_.adminFixCommand)})]})]}):null;return(0,Z.jsx)(de,{open:s,onOpenChange:e=>!e&&t(),width:620,title:O,description:ee?i(x?`clients.uninstallRunDetail`:`clients.installRunDetail`):void 0,footer:ee?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{onClick:t,children:i(`common.cancel`)}),T&&!E?(0,Z.jsx)(A,{variant:`primary`,icon:(0,Z.jsx)(re,{className:`size-3.5`}),disabled:!b,onClick:()=>void D(`sudo ${b}`),children:i(`clients.admin.copyCommand`)}):(0,Z.jsx)(A,{variant:x?`destructive`:`primary`,icon:T?(0,Z.jsx)(Y,{className:`size-3.5`}):void 0,disabled:!b,loading:l.isPending,onClick:()=>v&&ae(v,T),children:i(T?`clients.admin.start`:x?`clients.uninstall`:`clients.installStart`)})]}):S?.state===`running`?(0,Z.jsxs)(Z.Fragment,{children:[!S.elevated&&(0,Z.jsx)(A,{variant:`destructive`,loading:u.isPending,onClick:()=>u.mutate(n.kind,{onError:e=>a(I(e),`error`)}),children:i(`clients.installStop`)}),(0,Z.jsx)(A,{onClick:t,children:i(`common.close`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{onClick:t,children:i(`common.done`)}),ne&&(0,Z.jsx)(A,{variant:`primary`,icon:(0,Z.jsx)(Y,{className:`size-3.5`}),loading:l.isPending,onClick:()=>ae(S.action,!0),children:i(`clients.admin.retry`)})]}),children:ee?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[x&&n.enabled&&(0,Z.jsx)(j,{tone:`warning`,title:i(`clients.uninstallRestoreTitle`),children:i(`clients.uninstallRestoreDetail`,{name:g})}),T&&(0,Z.jsx)(j,{tone:`warning`,title:i(`clients.admin.title`),children:i(E?`clients.admin.prompt`:`clients.admin.manual`)}),b?(0,Z.jsx)(`pre`,{className:se,children:T?`sudo ${b}`:b}):(0,Z.jsx)(j,{tone:`warning`,title:i(`clients.installUnavailable`)}),x?(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`clients.uninstallKeepsData`)}):_?.method===`npm`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`clients.installNpmNote`)}),T&&ce]}):S?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(j,{tone:S.state===`succeeded`&&S.hint?`warning`:oe[S.state],title:i(S.state===`succeeded`&&S.hint?`clients.job.notEffective`:`clients.job.${S.state}`),children:S.state===`running`&&S.elevated?i(`clients.admin.running`):S.hint?i(`clients.hint.${S.hint}`)+(ne?i(`clients.admin.retryHint`):``):void 0}),(0,Z.jsx)(`pre`,{ref:p,className:`scroll max-h-[340px] min-h-[160px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[11px] leading-relaxed break-all whitespace-pre-wrap selectable`,children:S.log.join(`
|
|
7
|
+
`)}),S.hint===`permission-denied`&&ce]}):c.isLoading?(0,Z.jsx)(N,{lines:4}):(0,Z.jsx)(C,{icon:(0,Z.jsx)(q,{className:`size-6`}),title:i(`clients.noInstallLog`)})})}function It({open:e,onOpenChange:t,client:n,model:r,extras:i,tokenId:a}){let{t:o}=w(),{toast:s}=R(),c=E(),l=p(),u=J(n.kind,n.name),d=i?{providerId:n.providerId,model:r,extras:i,tokenId:a}:{providerId:n.providerId,model:r,tokenId:a};return(0,X.useEffect)(()=>{e&&c.mutate({kind:n.kind,req:d})},[e]),(0,Z.jsxs)(de,{open:e,onOpenChange:t,width:620,title:o(`clients.enableTitle`,{name:u}),description:o(`clients.enableDetail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{onClick:()=>t(!1),children:o(`common.cancel`)}),(0,Z.jsx)(A,{variant:`primary`,disabled:!c.data,loading:l.isPending,onClick:()=>l.mutate({kind:n.kind,req:d},{onSuccess:e=>{t(!1),s(e.requiresRestart?o(`clients.enabledRestart`,{name:u}):o(`clients.enabledToast`,{name:u}),`success`)},onError:e=>s(I(e),`error`)}),children:n.enabled?o(`common.apply`):o(`clients.enable`)})]}),children:[c.isPending&&(0,Z.jsx)(N,{lines:4}),c.isError&&(0,Z.jsx)(j,{tone:`danger`,title:o(`common.error`),children:I(c.error)}),c.data&&(0,Z.jsx)(Lt,{preview:c.data})]})}function Lt({preview:e}){let{t}=w();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.warnings.map((e,t)=>(0,Z.jsx)(j,{tone:`warning`,title:e},t)),e.changes.length===0&&(0,Z.jsx)(j,{tone:`info`,title:t(`clients.noChanges`)}),e.diffs.map(e=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`mb-2 font-mono text-[11px] text-[var(--text-secondary)]`,children:e.file}),(0,Z.jsx)(Rt,{diff:e.unifiedDiff})]},e.file))]})}function Rt({diff:e}){return(0,Z.jsx)(`pre`,{className:`scroll max-h-[300px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] py-2 font-mono text-[11px] leading-relaxed selectable`,children:e.split(`
|
|
8
|
+
`).map((e,t)=>(0,Z.jsx)(`div`,{className:k(`px-3 whitespace-pre-wrap break-all`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-[color-mix(in_oklab,var(--success)_12%,transparent)] text-[var(--success)]`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-[color-mix(in_oklab,var(--danger)_10%,transparent)] text-[var(--danger)]`,e.startsWith(`@@`)&&`text-[var(--text-muted)]`),children:e||` `},t))})}function zt({open:e,onOpenChange:t,client:n}){let{t:r,locale:i}=w(),{toast:c,confirm:l}=R(),u=s(n.kind,e),d=o();return(0,Z.jsxs)(de,{open:e,onOpenChange:t,width:520,title:r(`clients.backups`),description:r(`clients.backupsDetail`),footer:(0,Z.jsx)(A,{onClick:()=>t(!1),children:r(`common.done`)}),children:[u.isLoading&&(0,Z.jsx)(N,{lines:3}),u.isError&&(0,Z.jsx)(j,{tone:`danger`,title:r(`common.error`),children:I(u.error)}),u.data?.length===0&&(0,Z.jsx)(C,{icon:(0,Z.jsx)(pe,{className:`size-6`}),title:r(`clients.noBackups`)}),(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:u.data?.map(e=>(0,Z.jsx)(D,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[a(e.createdAt,i),e.firstWrite&&(0,Z.jsx)(O,{tone:`accent`,children:r(`clients.firstWrite`)})]}),detail:e.files.join(`, `),children:(0,Z.jsx)(A,{size:`sm`,icon:(0,Z.jsx)(we,{className:`size-3`}),loading:d.isPending&&d.variables?.id===e.id,onClick:async()=>{await l({title:r(`clients.restoreConfirm`),detail:e.files.join(`
|
|
9
|
+
`),destructive:!0,confirmLabel:r(`clients.restore`)})&&d.mutate({kind:n.kind,id:e.id},{onSuccess:()=>c(r(`clients.restored`),`success`),onError:e=>c(I(e),`error`)})},children:r(`clients.restore`)})},e.id))})]})}export{ft as ClientsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ct as e,G as t,H as n,J as r,Q as i,St as a,Tt as o,Y as s,_ as c,ct as l,lo as u,n as d,po as f,q as p,r as m,t as h,uo as g,wt as _}from"./alert-BKRTQ9va.js";import{_ as v,j as y,k as b}from"./index-Cj8lNw6g.js";var x=f(g(),1),S=u(),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}=l(),[n,r]=(0,x.useState)(``),[i,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(``),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),g=(0,x.useCallback)(async n=>{let r=n.trim();if(r){p(!0),d(null);try{o(await e(r)),c(r),T(r)}catch(e){o(null),T(null),d(e instanceof a&&e.status===401?t(`key.invalid`):t(`key.error`,{error:e.message}))}finally{p(!1)}}},[t]);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&&(r(t),g(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:t(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:t(`key.subtitle`)})]})]}),!i&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g(n)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(b,{label:t(`key.title`),placeholder:t(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:n,"aria-invalid":u?!0:void 0,onChange:e=>r(e.target.value)}),u&&(0,S.jsx)(h,{tone:`danger`,title:u}),(0,S.jsx)(m,{type:`submit`,variant:`primary`,loading:f,disabled:!n.trim(),children:t(`key.submit`)})]}),i&&(0,S.jsx)(D,{info:i,apiKey:s,onForget:()=>{T(null),o(null),r(``)}})]})})}function D({info:e,apiKey:t,onForget:r}){let{t:a,locale:o}=l(),[u,f]=(0,x.useState)(`overview`),p=e.allowedClients==null?a(`key.clientsAny`):e.allowedClients.length===0?a(`key.directOnly`):e.allowedClients.map(e=>v[e]?.name??e).join(`, `),h=[[a(`key.today`),e.usage.today],[a(`key.week`),e.usage.week],[a(`key.month`),e.usage.month],[a(`key.total`),e.usage.total]],g=Math.max(...e.daily.map(e=>e.costUsd),0);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium`,children:e.name}),(0,S.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)]`,children:e.keyPrefix}),!e.enabled&&(0,S.jsx)(d,{tone:`orange`,children:a(`key.disabled`)}),(0,S.jsx)(m,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:r,children:a(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[a(`key.clients`),`: `,p,` · `,a(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(c,{ariaLabel:a(`key.title`),value:u,onChange:f,items:[{value:`overview`,label:a(`key.tab.overview`)},{value:`stats`,label:a(`key.tab.stats`)},{value:`requests`,label:a(`key.tab.requests`)}]})]}),u===`stats`&&(0,S.jsx)(k,{apiKey:t}),u===`requests`&&(0,S.jsx)(M,{apiKey:t}),u===`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:a(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:a(`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`?i(t):s(t,!0),r=Math.max(0,Math.min(100,Math.round(e.usedPercent))),c=r>=90?`var(--danger)`:r>=70?`var(--warning)`:`var(--accent)`,l=`${a(`tokens.period.${e.period}`)} · ${a(`tokens.metric.${e.metric}`)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[12px]`,children:[(0,S.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:l}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":l,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${r}%`,background:c}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?a(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?a(`key.resets`,{time:n(e.resetsAt,o)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:a(`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:a(`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:a(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:a(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:a(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:h.map(([e,t])=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`py-1 text-left font-medium text-[var(--text-secondary)]`,children:e}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:i(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:s(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:s(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:a(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":a(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${i(e.costUsd)} · ${s(e.requests)} ${a(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${g>0?Math.max(2,e.costUsd/g*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t:n}=l(),[r,a]=(0,x.useState)(`7d`),[u,f]=(0,x.useState)(null),[m,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{let t=!0;return g(null),o(e,r).then(e=>t&&f(e),e=>t&&g(n(`key.error`,{error:e.message}))),()=>{t=!1}},[e,r,n]);let _=u?.summary,y=Math.max(...(u?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(c,{ariaLabel:n(`overview.range`),value:r,onChange:a,items:O.map(e=>({value:e,label:n(`range.${e}`)}))}),m&&(0,S.jsx)(h,{tone:`danger`,title:m}),!u||!_?!m&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:`…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsx)(A,{label:n(`key.stats.requests`),value:s(_.requests)}),(0,S.jsx)(A,{label:n(`key.stats.successRate`),value:_.requests?p(_.successRate):`—`}),(0,S.jsx)(A,{label:n(`key.cost`),value:i(_.costUsd)}),(0,S.jsx)(A,{label:n(`key.stats.avgTtft`),value:t(_.avgTtftMs)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:n(`key.stats.trend`)}),(0,S.jsx)(`div`,{className:`flex h-20 items-end gap-[2px]`,role:`list`,"aria-label":n(`key.stats.trend`),children:u.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${s(e.requests)} ${n(`key.requests`)} · ${i(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${y>0?Math.max(2,e.requests/y*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:n(`key.stats.byModel`),rows:u.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:n(`key.stats.byClient`),rows:u.clients.map(e=>({name:e.client?v[e.client]?.name??e.client:n(`key.stats.direct`),...e}))}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:n(`key.stats.errors`)}),u.errors.length===0?(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:n(`key.stats.noErrors`)}):(0,S.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:u.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(d,{tone:`orange`,children:[n(`key.category.${e.category}`),` · `,s(e.count)]})},e.category))})]}),u.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`key.stats.retention`,{days:u.retentionDays})})]})]})}function A({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`div`,{className:`num truncate text-[17px] font-semibold`,children:t})]})}function j({title:e,rows:t}){let{t:n}=l();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:n(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`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:s(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?p(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:s(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:i(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t:a,locale:o}=l(),[u,f]=(0,x.useState)(`all`),[p,g]=(0,x.useState)([]),[y,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),D=(0,x.useCallback)(async t=>{w(!0),E(null);try{let n=await _(e,{before:t,status:u===`failed`?N:void 0});g(e=>t?[...e,...n.items]:n.items),b(n.nextBefore??null)}catch(e){E(a(`key.error`,{error:e.message}))}finally{w(!1)}},[e,u,a]);return(0,x.useEffect)(()=>{D(null)},[D]),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(c,{ariaLabel:a(`key.requests.status`),value:u,onChange:f,items:[{value:`all`,label:a(`key.requests.all`)},{value:`failed`,label:a(`key.requests.failed`)}]}),T&&(0,S.jsx)(h,{tone:`danger`,title:T}),p.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:a(`key.requests.empty`)}),p.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:a(`key.requests.time`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:a(`key.requests.model`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:a(`key.requests.client`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:a(`key.requests.status`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:a(`key.requests.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:a(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:a(`key.requests.latency`)})]})}),(0,S.jsx)(`tbody`,{children:p.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:n(e.time,o),children:r(e.time,o)}),(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?v[e.client]?.name??e.client:a(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(d,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:a(`key.category.${e.errorCategory}`)}):(0,S.jsx)(d,{tone:`green`,children:a(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[s(e.inputTokens,!0),` / `,s(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:i(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[t(e.ttftMs),` / `,t(e.totalMs)]})]},e.id))})]})}),y&&(0,S.jsx)(`div`,{children:(0,S.jsx)(m,{size:`sm`,loading:C,onClick:()=>void D(y),children:a(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{Fi as e,G as t,Gn as n,H as r,Ii as i,Kn as a,On as o,Rt as s,Ti as c,Xt as l,_ as u,ai as d,b as f,c as p,ct as m,d as h,gi as g,gt as _,kr as v,l as y,lo as b,m as x,n as S,nn as ee,p as C,po as w,qn as T,r as E,t as D,u as O,un as k,uo as A,v as j,xt as M,y as N}from"./alert-BKRTQ9va.js";import{a as P,ct as F,i as I,n as L,o as R,r as z}from"./overlays-CizKmvVN.js";import{t as B}from"./ellipsis-C09AxsS6.js";import{t as V}from"./pencil-BuVygJ9-.js";import{B as H,I as U,P as W,U as G,V as K,h as q}from"./index-Cj8lNw6g.js";var J={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};J.node;var Y=M(J),X=w(A(),1),Z=b(),Q=[{kind:`claude-code`,name:`Claude Code`},{kind:`codex`,name:`Codex`}],te={missing:`neutral`,applied:`green`,drifted:`orange`,conflict:`red`};function ne(){let{t:e}=m(),t=l(),n=c(),r=(n.data??[]).filter(e=>e.enabled&&(e.mcpServers?.length??0)>0);return(0,Z.jsxs)(O,{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)(j,{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&&Q.map(e=>{let n=t.data.find(t=>t.kind===e.kind);return n?(0,Z.jsx)(re,{name:e.name,entry:n,tokens:r.map(e=>({value:e.id,label:e.name}))},e.kind):null})]})}function re({name:e,entry:t,tokens:n}){let{t:r}=m(),{toast:i,confirm:a}=R(),o=s(),c=v(),[l,u]=(0,X.useState)(null),d=l??(n.some(e=>e.value===t.tokenId)?t.tokenId??null:n[0]?.value??null),f=o.isPending||c.isPending,p=t.state===`applied`||t.state===`drifted`,h=n=>{d&&o.mutate({kind:t.kind,tokenId:d,force:n},{onSuccess:()=>i(r(`mcp.clients.applied`,{client:e}),`success`),onError:e=>i(P(e),`error`)})},g=async n=>{(!n||await a({title:r(`mcp.clients.forceRemove`),detail:t.file,destructive:!0,confirmLabel:r(`mcp.clients.forceRemove`)}))&&c.mutate({kind:t.kind,force:n},{onSuccess:()=>i(r(`mcp.clients.removed`,{client:e}),`success`),onError:e=>i(P(e),`error`)})},_=(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)(x,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(0,Z.jsx)(S,{tone:te[t.state],children:r(`mcp.clients.state.${t.state}`)})]}),detail:_,children:[n.length>0&&(0,Z.jsx)(z,{className:`w-44`,ariaLabel:`${e} ${r(`mcp.clients.token`)}`,placeholder:r(`mcp.clients.pickToken`),value:d,onChange:u,options:n,disabled:f}),(0,Z.jsx)(E,{variant:`primary`,disabled:f||!d||t.state===`conflict`,onClick:()=>h(!1),children:r(p?`mcp.clients.replace`:`mcp.clients.apply`)}),p&&(0,Z.jsx)(E,{disabled:f,onClick:()=>void g(t.state===`drifted`),children:t.state===`drifted`?r(`mcp.clients.forceRemove`):r(`mcp.clients.remove`)})]}),!t.gatewayEnabled&&t.state!==`missing`&&(0,Z.jsx)(D,{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)(D,{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)(E,{size:`sm`,disabled:f||!d,onClick:()=>h(!0),children:r(`mcp.clients.force`)})]})]})}var $={unknown:`neutral`,ok:`green`,needs_auth:`orange`,auth_error:`red`,unreachable:`red`,version_unsupported:`red`};function ie(){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ae,{}),(0,Z.jsx)(ne,{}),(0,Z.jsx)(oe,{}),(0,Z.jsx)(le,{})]})}function ae(){let{t:e}=m(),{toast:t}=R(),n=T(),r=i(),[a,o]=(0,X.useState)(``),s=n.data?.allowedOrigins.join(`
|
|
2
|
+
`)??``;if((0,X.useEffect)(()=>o(s),[s]),!n.data)return(0,Z.jsx)(j,{});let c=n.data,l=n=>r.mutate(n,{onSuccess:()=>t(e(`common.saved`),`success`),onError:e=>t(P(e),`error`)});return(0,Z.jsxs)(O,{title:e(`mcp.gateway.title`),children:[(0,Z.jsx)(x,{label:e(`mcp.gateway.enable`),detail:e(`mcp.gateway.enableHint`),children:(0,Z.jsx)(N,{checked:c.enabled,disabled:r.isPending,label:e(`mcp.gateway.enable`),onChange:e=>l({enabled:e})})}),(0,Z.jsxs)(x,{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:c.endpoint,children:c.endpoint}),(0,Z.jsx)(E,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(_,{className:`size-3.5`}),"aria-label":e(`mcp.gateway.copyEndpoint`),onClick:()=>void F.copy(c.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)(y,{label:e(`mcp.gateway.origins`),hint:e(`mcp.gateway.originsHint`),children:(0,Z.jsx)(f,{mono:!0,rows:3,value:a,placeholder:`https://app.example.com`,onChange:e=>o(e.target.value)})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(E,{size:`sm`,disabled:a.trim()===s.trim()||r.isPending,onClick:()=>l({allowedOrigins:a.split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean)}),children:e(`mcp.gateway.originsSave`)})})]})]})}function oe(){let{t:e}=m(),{toast:t,confirm:n}=R(),r=a(),i=g(),s=d(),c=o(),l=k(),[u,f]=(0,X.useState)(null),[h,_]=(0,X.useState)(null),v=n=>i.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(P(e),`error`)}),y=n=>s.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(P(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})&&c.mutate(r.id,{onSuccess:()=>t(e(`mcp.server.forgotten`),`success`),onError:e=>t(P(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})&&l.mutate(r.id,{onSuccess:()=>t(e(`mcp.server.deleted`,{name:r.name}),`success`),onError:e=>t(P(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)(E,{size:`sm`,variant:`primary`,icon:(0,Z.jsx)(H,{className:`size-3.5`}),onClick:()=>f(`new`),children:e(`mcp.servers.add`)})]}),r.data===void 0?(0,Z.jsx)(j,{}):r.data.length===0?(0,Z.jsx)(p,{icon:(0,Z.jsx)(K,{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)(se,{server:e,busy:i.isPending&&i.variables===e.id,onTest:()=>v(e),onEdit:()=>f(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)(ce,{server:u,onClose:()=>f(null)}),(0,Z.jsx)(I,{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)(E,{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 se({server:e,busy:t,onTest:n,onEdit:i,onAuthorize:a,onForget:o,onDelete:s}){let{t:c,locale:l}=m(),u=e.authType===`oauth`,d=e.oauth?.authorized===!0,f=[e.slug,e.protocolVersion?c(`mcp.server.protocol`,{version:e.protocolVersion}):null,c(`mcp.server.boundTokens`,{count:e.boundTokens}),e.checkedAt?r(e.checkedAt,l):null].filter(Boolean).join(` · `);return(0,Z.jsxs)(x,{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:$[e.status],title:e.statusMessage??void 0,children:c(`mcp.status.${e.status}`)}),!e.enabled&&(0,Z.jsx)(S,{children:c(`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:f}),u&&d&&e.oauth?.issuer&&(0,Z.jsx)(`span`,{className:`block`,children:c(`mcp.server.authorizedBy`,{issuer:e.oauth.issuer})})]}),children:[u&&(0,Z.jsx)(E,{size:`sm`,variant:d?`glass`:`primary`,icon:(0,Z.jsx)(U,{className:`size-3.5`}),onClick:a,children:c(d?`mcp.server.reauthorize`:`mcp.server.authorize`)}),(0,Z.jsx)(E,{size:`sm`,icon:(0,Z.jsx)(Y,{className:`size-3.5`}),loading:t,onClick:n,children:c(`mcp.server.test`)}),(0,Z.jsx)(L,{label:e.name,iconOnly:!0,icon:(0,Z.jsx)(B,{className:`size-4`}),items:[{id:`edit`,label:c(`common.edit`),icon:(0,Z.jsx)(V,{className:`size-3.5`}),onSelect:i},...u&&d?[{id:`forget`,label:c(`mcp.server.forget`),icon:(0,Z.jsx)(G,{className:`size-3.5`}),onSelect:o}]:[],{id:`delete`,label:c(`common.delete`),icon:(0,Z.jsx)(W,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:s}]})]})}function ce({server:t,onClose:n}){let{t:r}=m(),{toast:i}=R(),a=ee(),o=e(),s=t&&t!==`new`?t:null,[c,l]=(0,X.useState)(``),[d,f]=(0,X.useState)(``),[p,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(`http`),[b,S]=(0,X.useState)(`none`),[w,T]=(0,X.useState)([]),[O,k]=(0,X.useState)(60),[A,j]=(0,X.useState)(!0);(0,X.useEffect)(()=>{if(t===null)return;let e=t===`new`?null:t;l(e?.name??``),f(e?.slug??``),g(e?.url??``),v(e?.transport??`http`),S(e?.authType??`none`),T((e?.headerNames??[]).map(e=>({name:e,value:``,kept:!0}))),k(e?.timeoutSeconds??60),j(e?.enabled??!0)},[t]);let M=a.isPending||o.isPending,F=c.trim()!==``&&p.trim()!==``&&(b!==`header`||w.some(e=>e.name.trim()!==``&&(e.value!==``||e.kept))),L=()=>{let e={name:c.trim(),url:p.trim(),transport:_,authType:b,enabled:A,...O==null?{}:{timeoutSeconds:Math.floor(O)},...d.trim()?{slug:d.trim()}:{}};b===`header`&&(e.headers=Object.fromEntries(w.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.kept&&e.value===``?null:e.value])));let t={onSuccess:e=>{n(),i(r(s?`mcp.server.saved`:`mcp.server.created`,{name:e.name}),`success`)},onError:e=>i(P(e),`error`)};s?o.mutate({id:s.id,body:e},t):a.mutate(e,t)},z=(e,t)=>T(n=>n.map((n,r)=>r===e?{...n,...t}:n));return(0,Z.jsx)(I,{open:t!==null,onOpenChange:e=>!e&&n(),width:560,title:s?r(`mcp.server.editTitle`,{name:s.name}):r(`mcp.server.addTitle`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(E,{onClick:n,children:r(`common.cancel`)}),(0,Z.jsx)(E,{variant:`primary`,disabled:!F,loading:M,onClick:L,children:r(`common.save`)})]}),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(y,{label:r(`mcp.server.name`),children:(0,Z.jsx)(h,{value:c,maxLength:64,onChange:e=>l(e.target.value)})}),(0,Z.jsx)(y,{label:r(`mcp.server.url`),hint:r(`mcp.server.urlHint`),children:(0,Z.jsx)(h,{mono:!0,value:p,placeholder:`https://mcp.example.com/mcp`,onChange:e=>g(e.target.value)})}),(0,Z.jsx)(y,{label:r(`mcp.server.transport`),hint:r(`mcp.server.transportHint`),children:(0,Z.jsx)(u,{ariaLabel:r(`mcp.server.transport`),value:_,onChange:v,items:[{value:`http`,label:r(`mcp.server.transport.http`)},{value:`sse`,label:r(`mcp.server.transport.sse`)}]})}),(0,Z.jsx)(y,{label:r(`mcp.server.auth`),children:(0,Z.jsx)(u,{ariaLabel:r(`mcp.server.auth`),value:b,onChange:S,items:[{value:`none`,label:r(`mcp.server.auth.none`)},{value:`header`,label:r(`mcp.server.auth.header`)},{value:`oauth`,label:r(`mcp.server.auth.oauth`)}]})}),b===`oauth`&&(0,Z.jsx)(D,{tone:`warning`,title:r(`mcp.server.oauthNote`)}),b===`header`&&(0,Z.jsx)(y,{label:r(`mcp.server.headers`),hint:r(`mcp.server.headersHint`),children:(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[w.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(h,{className:`w-40`,mono:!0,label:r(`mcp.server.headerName`),placeholder:`Authorization`,value:e.name,readOnly:e.kept&&s!==null,onChange:e=>z(t,{name:e.target.value})}),(0,Z.jsx)(h,{className:`flex-1`,mono:!0,type:`password`,label:r(`mcp.server.headerValue`),placeholder:e.kept?r(`mcp.server.headerKept`):`Bearer …`,value:e.value,onChange:e=>z(t,{value:e.target.value})}),(0,Z.jsx)(E,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(W,{className:`size-3.5`}),"aria-label":r(`mcp.server.removeHeader`),onClick:()=>T(e=>e.filter((e,n)=>n!==t))})]},t)),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(E,{size:`sm`,icon:(0,Z.jsx)(H,{className:`size-3.5`}),onClick:()=>T(e=>[...e,{name:``,value:``,kept:!1}]),children:r(`mcp.server.addHeader`)})})]})}),(0,Z.jsx)(y,{label:r(`mcp.server.slug`),hint:r(`mcp.server.slugHint`),children:(0,Z.jsx)(h,{mono:!0,value:d,maxLength:32,placeholder:s?``:`github`,onChange:e=>f(e.target.value)})}),(0,Z.jsx)(y,{label:r(`mcp.server.timeout`),hint:r(`mcp.server.timeoutHint`),children:(0,Z.jsx)(C,{value:O,min:1,step:1,label:r(`mcp.server.timeout`),onChange:k})}),(0,Z.jsx)(x,{label:r(`mcp.server.enabled`),children:(0,Z.jsx)(N,{checked:A,label:r(`mcp.server.enabled`),onChange:j})})]})})}function le(){let{t:e,locale:t}=m(),r=n(50);return(0,Z.jsx)(O,{title:e(`mcp.calls.title`),footer:e(`mcp.calls.hint`),children:r.data===void 0?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(j,{})}):r.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:r.data.map(e=>(0,Z.jsx)(ue,{call:e,locale:t},e.id))})]})})})}function ue({call:e,locale:n}){let{t:i}=m();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:r(e.at,n)}),(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:i(`mcp.calls.era.${e.frontEra}`)})]}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-4 py-1.5 tabular-nums text-[var(--text-secondary)]`,children:t(e.durationMs)}),(0,Z.jsx)(`td`,{className:`px-4 py-1.5`,children:e.ok?(0,Z.jsx)(S,{tone:`green`,children:i(`mcp.calls.ok`)}):(0,Z.jsx)(S,{tone:`red`,children:i(`mcp.calls.error.${e.errorCategory??`protocol`}`)})})]})}function de(){let{t:e}=m();return(0,Z.jsx)(q,{title:e(`nav.mcp`),subtitle:e(`mcp.subtitle`),children:(0,Z.jsx)(ie,{})})}export{de as McpPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e,Jn as t,Li as n,Zi as r,ct as i,d as a,dn as o,fn as s,g as c,l,lo as u,m as d,n as f,p,po as m,pr as h,r as g,rt as _,t as v,u as y,uo as b,v as x,y as S,zr as C}from"./alert-BKRTQ9va.js";import{a as w,i as T,o as E,r as D}from"./overlays-CizKmvVN.js";import{t as O}from"./arrow-left-CgusYKe5.js";import{t as k}from"./pencil-BuVygJ9-.js";import{t as A}from"./rotate-ccw-BhDSBCvo.js";import{$ as j,B as M,P as N,h as P,i as ee,nt as te,o as F,tt as ne}from"./index-Cj8lNw6g.js";import{t as I}from"./checkbox-JghCvxwP.js";import{t as L}from"./confirm-morph-bdMiffHC.js";var R=m(b(),1),z=u(),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:r,locale:s}=i(),l=ne(),{id:u=``}=te(),m=decodeURIComponent(u),h=t(m),b=n(m),T=C(m),D=o(),{toast:k}=E(),M=(0,R.useMemo)(()=>h.data?V(h.data):null,[h.data]),[N,L]=(0,R.useState)(M),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(M),G(M?.aliases?.join(`, `)??``)},[M]);let q=(0,z.jsx)(g,{variant:`glass`,icon:(0,z.jsx)(O,{className:`size-4`}),"aria-label":r(`common.back`),onClick:()=>l(`/models`)});if(h.isError)return(0,z.jsx)(P,{title:r(`nav.models`),leading:q,children:(0,z.jsx)(v,{tone:`danger`,title:r(`common.error`),children:w(h.error)})});let J=h.data;if(!J||!N)return(0,z.jsx)(P,{title:``,leading:q,children:(0,z.jsx)(x,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...N,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(M),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>b.mutate(X,{onSuccess:()=>k(r(`common.saved`),`success`),onError:e=>k(w(e),`error`)}),$=e=>re.has(e)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(f,{tone:`orange`,children:r(`models.modified`)}),Q&&(0,z.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(A,{className:`size-3`}),title:r(`models.resetField`),"aria-label":r(`models.resetField`),onClick:()=>T.mutate(e,{onSuccess:()=>k(r(`models.fieldReset`)),onError:e=>k(w(e),`error`)})})]}):null;return(0,z.jsx)(P,{title:J.displayName,subtitle:`${J.id} · ${r(`models.source.${J.source}`)} · ${r(`models.updated`,{time:e(J.updatedAt,s)})}`,leading:q,actions:(0,z.jsxs)(z.Fragment,{children:[J.source===`user`&&(0,z.jsx)(K,{label:r(`common.delete`),prompt:r(`models.deleteConfirm`,{id:J.id}),onConfirm:async()=>{await D.mutateAsync(J.id),l(`/models`)}}),Z&&(0,z.jsx)(g,{onClick:()=>{L(M),G(M?.aliases?.join(`, `)??``)},children:r(`common.revert`)}),(0,z.jsx)(g,{variant:`primary`,disabled:!Z,loading:b.isPending,onClick:ie,children:r(`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)(y,{title:r(`models.section.basic`),footer:Q?r(`models.modifiedFooter`):void 0,children:[(0,z.jsx)(U,{label:r(`models.field.displayName`),marker:$(`displayName`),children:(0,z.jsx)(a,{className:`w-60`,"aria-label":r(`models.field.displayName`),value:N.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:r(`models.field.vendor`),children:(0,z.jsx)(a,{className:`w-60`,"aria-label":r(`models.field.vendor`),value:N.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:r(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(a,{className:`w-60`,"aria-label":r(`models.field.family`),value:N.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:r(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(a,{className:`w-60 font-mono`,"aria-label":r(`models.field.aliases`),value:H,onChange:e=>G(e.target.value),placeholder:`a, b, c`})}),(0,z.jsx)(U,{label:r(`models.field.contextWindow`),marker:$(`contextWindow`),children:(0,z.jsx)(p,{className:`w-36`,label:r(`models.field.contextWindow`),value:N.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:r(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(p,{className:`w-36`,label:r(`models.field.maxOutputTokens`),value:N.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:r(`common.enabled`),children:(0,z.jsx)(S,{checked:N.enabled??!0,label:r(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(y,{title:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[r(`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(e=>(0,z.jsx)(I,{label:r(e.label),checked:!!N.capabilities?.[e.key],onCheckedChange:t=>Y({capabilities:{...N.capabilities,[e.key]:t===!0}})},e.key))})}),(0,z.jsx)(W,{model:J}),J.providerOverrides.length>0&&(0,z.jsx)(y,{title:r(`models.section.overrides`),footer:r(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(d,{label:(0,z.jsx)(j,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${_(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(c,{action:$(`pricing`),children:r(`models.section.pricing`)}),(0,z.jsx)(`p`,{className:`mb-3 px-1 text-[12px] text-[var(--text-secondary)]`,children:r(`models.pricingHint`)}),(0,z.jsx)(`div`,{className:`card p-4`,children:(0,z.jsx)(F,{value:N.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(c,{children:r(`models.section.simulator`)}),(0,z.jsxs)(`div`,{className:`card p-4`,children:[(0,z.jsx)(ee,{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:r(`models.simulatorUnsaved`)})]})]})]})]})})}function U({label:e,marker:t,children:n}){return(0,z.jsx)(d,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=i(),n=s(e.id),[r,a]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(y,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(M,{className:`size-3.5`}),onClick:()=>a(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(d,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(d,{label:(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:e.priceKey}),e.userModified&&(0,z.jsx)(f,{tone:`orange`,children:t(`models.modified`)})]}),detail:[_(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)(g,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{className:`size-3.5`}),"aria-label":t(`common.edit`),onClick:()=>a(e)}),(0,z.jsx)(K,{label:t(`common.delete`),prompt:t(`models.deletePrice`,{key:e.priceKey}),onConfirm:()=>n.mutateAsync(e.priceKey)})]},e.priceKey))]}),(0,z.jsx)(G,{model:e,editing:r,onClose:()=>a(null)})]})}function G({model:e,editing:t,onClose:n}){let{t:o}=i(),{toast:s}=E(),c=h(),u=r(e.id),d=t===`new`,[f,p]=(0,R.useState)(``),[m,_]=(0,R.useState)(``),[v,y]=(0,R.useState)(null);(0,R.useEffect)(()=>{t&&(t===`new`?(p(``),_(``),y(e.pricing?structuredClone(e.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(p(t.priceKey),_(t.upstreamModelId??``),y(structuredClone(t.pricing))))},[t,e.pricing]);let b=new Set(e.providerPrices.map(e=>e.priceKey));return(0,z.jsx)(T,{open:t!==null,onOpenChange:e=>!e&&n(),width:680,title:d?o(`models.addPrice`):o(`models.editPrice`,{key:f}),description:o(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(g,{onClick:n,children:o(`common.cancel`)}),(0,z.jsx)(g,{variant:`primary`,disabled:!f||!v,loading:u.isPending,onClick:()=>u.mutate({priceKey:f,upstreamModelId:m||null,pricing:v},{onSuccess:()=>{s(o(`common.saved`),`success`),n()},onError:e=>s(w(e),`error`)}),children:o(`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)(l,{label:o(`providers.priceKey`),children:d?(0,z.jsx)(D,{value:f,onChange:p,placeholder:o(`models.pickPriceKey`),options:(c.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:b.has(e.priceKey)}))}):(0,z.jsx)(a,{value:f,disabled:!0,className:`font-mono`})}),(0,z.jsx)(l,{label:o(`models.upstreamId`),hint:o(`models.upstreamIdHint`),children:(0,z.jsx)(a,{className:`font-mono`,value:m,onChange:e=>_(e.target.value),placeholder:e.id})})]}),d&&(0,z.jsx)(a,{className:`font-mono`,"aria-label":o(`models.customPriceKey`),placeholder:o(`models.customPriceKey`),value:f,onChange:e=>p(e.target.value.trim())}),(0,z.jsx)(F,{value:v,onChange:y})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:r}=i();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(N,{className:`size-4`}),prompt:t,confirmLabel:r(`common.delete`),cancelLabel:r(`common.cancel`),pendingLabel:r(`common.deleting`),doneLabel:r(`common.deleted`),errorLabel:r(`common.error`),retryLabel:r(`common.retry`),onConfirm:n})}export{H as ModelDetailPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{V as e,Yn as t,Z as n,c as r,ct as i,d as a,fi as o,h as s,l as c,lo as l,n as u,nt as d,ot as f,p,pi as m,po as h,r as g,rn as _,t as v,uo as y,v as b}from"./alert-BKRTQ9va.js";import{a as x,i as S,o as C,r as w}from"./overlays-CizKmvVN.js";import{t as T}from"./cloud-download-Cq6X58YR.js";import{B as E,D,G as O,M as k,N as A,h as j,q as M,tt as N}from"./index-Cj8lNw6g.js";import{t as P}from"./checkbox-JghCvxwP.js";var F=h(y(),1),I=l();function L(){let{t:e}=i(),n=N(),[a,o]=(0,F.useState)(``),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),m=(0,F.useRef)(null),h=A(a),_=t(),y=t(h,c),S=(0,F.useMemo)(()=>[...new Set((_.data??[]).map(e=>e.vendor))].sort(),[_.data]);return k(e=>{e===`find`&&m.current?.focus()}),(0,I.jsxs)(j,{title:e(`nav.models`),subtitle:y.data?e(`models.count`,{count:y.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(s,{inputRef:m,className:`w-52`,value:a,onChange:o,placeholder:e(`models.search`)}),(0,I.jsx)(w,{value:c,onChange:l,options:[{value:``,label:e(`models.allVendors`)},...S.map(e=>({value:e,label:e}))]}),(0,I.jsx)(g,{icon:(0,I.jsx)(T,{className:`size-3.5`}),onClick:()=>p(!0),children:e(`models.sync`)}),(0,I.jsx)(g,{variant:`primary`,icon:(0,I.jsx)(E,{className:`size-3.5`}),onClick:()=>d(!0),children:e(`models.new`)})]}),children:[y.isLoading&&(0,I.jsx)(b,{lines:5}),y.isError&&(0,I.jsx)(v,{tone:`danger`,title:e(`common.error`),children:x(y.error)}),y.data?.length===0&&(0,I.jsx)(r,{icon:(0,I.jsx)(M,{className:`size-6`}),title:e(`models.empty`)}),y.data&&y.data.length>0&&(0,I.jsx)(D,{caption:e(`nav.models`),rowKey:`id`,rows:y.data.map(e=>({id:e.id,name:e.displayName,vendor:e.vendor,context:e.contextWindow??0,input:e.pricing?.base.input??0,providerPrices:e.providerPriceKeys.length,m:e})),columns:R(e,e=>n(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:u,onOpenChange:d,onCreated:e=>n(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:f,onOpenChange:p})]})}function R(t,r){return[{key:`name`,label:t(`models.col.model`),render:(e,n)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>r(n.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:f(`truncate font-medium hover:text-[var(--accent)]`,!n.m.enabled&&`text-[var(--text-muted)]`),children:n.name}),n.m.source===`user`&&(0,I.jsx)(u,{tone:`accent`,children:t(`models.source.user`)}),n.m.userModifiedFields.length>0&&(0,I.jsx)(u,{tone:`orange`,children:t(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:n.id})]})},{key:`vendor`,label:t(`models.col.vendor`),width:120},{key:`context`,label:t(`models.col.context`),numeric:!0,width:96,render:(t,n)=>e(n.m.contextWindow)},{key:`input`,label:t(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let r=t.m.pricing?.base;return r?`${n(r.input)} / ${n(r.output)}`:`—`}},{key:`providerPrices`,label:t(`models.col.providerPrices`),numeric:!0,width:130,render:(e,n)=>n.providerPrices?t(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:e,onOpenChange:t,onCreated:n}){let{t:r}=i(),{toast:o}=C(),s=_(),[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[v,y]=(0,F.useState)(null),[b,w]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(S,{open:e,onOpenChange:t,title:r(`models.new`),description:r(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(g,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(g,{variant:`primary`,disabled:!l.trim()||!m.trim(),loading:s.isPending,onClick:()=>s.mutate({id:l.trim(),displayName:d.trim()||l.trim(),vendor:m.trim(),contextWindow:v,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{t(!1),u(``),f(``),n(e.id)},onError:e=>o(x(e),`error`)}),children:r(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(c,{label:r(`models.field.id`),hint:r(`models.field.idHint`),children:(0,I.jsx)(a,{className:`font-mono`,value:l,onChange:e=>u(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(c,{label:r(`models.field.displayName`),children:(0,I.jsx)(a,{value:d,onChange:e=>f(e.target.value)})}),(0,I.jsx)(c,{label:r(`models.field.vendor`),children:(0,I.jsx)(a,{value:m,onChange:e=>h(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(c,{label:r(`models.field.contextWindow`),children:(0,I.jsx)(p,{value:v,onChange:y})}),(0,I.jsx)(c,{label:r(`models.field.inputPrice`),children:(0,I.jsx)(p,{value:b,onChange:w})}),(0,I.jsx)(c,{label:r(`models.field.outputPrice`),children:(0,I.jsx)(p,{value:T,onChange:E})})]})]})})}var B=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V(e,t=``,n=new Map){if(B(e)&&Object.keys(e).length>0)for(let[r,i]of Object.entries(e))V(i,t?`${t}.${r}`:r,n);else e!=null&&n.set(t,e);return n}function H(e,t){let n=V(e),r=V(t);return[...r.keys(),...[...n.keys()].filter(e=>!r.has(e))].filter(e=>JSON.stringify(n.get(e))!==JSON.stringify(r.get(e))).map(e=>({path:e.replace(/^pricing\./,``),before:n.get(e),after:r.get(e)}))}var U=e=>typeof e==`string`?e:JSON.stringify(e),W=4;function G({before:e,after:t}){let{t:n}=i(),r=H(e,t),a=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${d(e)||`∅`}\n→\n${d(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),a>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:a})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:a}=i(),[o,s]=(0,F.useState)(new Set),c=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),l=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},d=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},p=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),m=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)(u,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(u,{tone:`orange`,children:a(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),h=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:l(h),onCheckedChange:e=>d(h,e!==!1),"aria-label":a(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`models.sync.selectedOf`,{n:n.size,total:h.length,models:c.length})})]}),c.map(([e,r])=>{let i=r.map(e=>e.id),s=r.length===1?r[0]:void 0,c=!o.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:l(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:[s?(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}):(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1 text-left`,"aria-expanded":c,onClick:()=>p(e),children:[(0,I.jsx)(O,{className:f(`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:a(`models.sync.groupCount`,{n:r.length})})]}),s&&m(s)]})]}),!s&&c&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:r.map(r=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:n.has(r.id),onCheckedChange:e=>d([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),m(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:n}=i(),{toast:r}=C(),a=m(),s=o(),[c,l]=(0,F.useState)(new Set),u=()=>a.mutate(void 0,{onSuccess:e=>l(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),d=a.data?.changes??[];return(0,I.jsxs)(S,{open:e,onOpenChange:e=>{t(e),e&&!a.data&&u()},width:720,title:n(`models.sync`),description:n(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(g,{className:`mr-auto`,variant:`plain`,onClick:u,loading:a.isPending,children:n(`common.refresh`)}),(0,I.jsx)(g,{onClick:()=>t(!1),children:n(`common.cancel`)}),(0,I.jsx)(g,{variant:`primary`,disabled:c.size===0,loading:s.isPending,onClick:()=>s.mutate([...c],{onSuccess:e=>{r(n(`models.sync.applied`,{count:e.applied}),`success`),t(!1),a.reset()},onError:e=>r(x(e),`error`)}),children:n(`models.sync.apply`,{count:c.size})})]}),children:[e&&!a.data&&!a.isPending&&!a.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(g,{variant:`primary`,onClick:u,children:n(`models.sync.check`)})}),a.isPending&&(0,I.jsx)(b,{lines:4}),a.isError&&(0,I.jsx)(v,{tone:`danger`,title:n(`common.error`),children:x(a.error)}),a.data&&d.length===0&&(0,I.jsx)(v,{tone:`success`,title:n(`models.sync.none`)}),d.length>0&&(0,I.jsx)(K,{changes:d,label:e=>e.kind===`new_model`?n(`models.sync.newModel`):e.kind===`price`?n(`models.sync.price`,{key:e.priceKey??``}):n(`models.sync.field`,{field:e.field??``}),checked:c,onChange:l})]})}export{L as ModelsPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Ar as e,H as t,Nt as n,Pn as r,Ri as i,Rn as a,Wn as o,Xn as s,_ as c,b as l,bt as u,c as d,cr as f,ct as p,d as m,er as h,f as g,h as _,i as v,ir as y,jr as b,l as x,lo as S,mt as C,n as w,nr as T,ot as E,po as D,r as O,t as k,tr as A,uo as j,ur as M,v as N,xt as P,y as F}from"./alert-BKRTQ9va.js";import{a as I,i as L,n as ee,o as R}from"./overlays-CizKmvVN.js";import{t as te}from"./arrow-down-4QyszMPK.js";import{t as ne}from"./ellipsis-C09AxsS6.js";import{t as re}from"./external-link-B54WZqyE.js";import{B as ie,C as ae,E as z,I as oe,P as se,T as ce,W as le,Y as ue,Z as B,h as V,nt as H,rt as de,tt as U,w as W,x as fe,z as G}from"./index-Cj8lNw6g.js";var K={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};K.node;var pe=P(K),q=D(j(),1),J=S(),me=/^(?:(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*|github:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/,Y={provider:`plugins.kind.provider`,middleware:`plugins.kind.middleware`,agent:`plugins.kind.agent`,pi:`plugins.kind.pi`},he={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`};function X({name:e,icon:t,kind:n,size:r=32}){let i=Math.round(r*.28);return t&&/^(https:|data:image\/)/i.test(t)?(0,J.jsx)(`img`,{src:t,alt:``,width:r,height:r,className:`shrink-0 object-contain`,style:{borderRadius:i},draggable:!1}):n===`middleware`||n===`agent`?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex shrink-0 items-center justify-center text-white`,style:{width:r,height:r,borderRadius:i,background:n===`middleware`?`#0a84ff`:`#30b0a0`},children:(0,J.jsx)(n===`middleware`?oe:B,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(fe,{name:e,icon:t,size:r})}function Z(){let{t:e}=p(),t=U(),{tab:n}=H(),r=n===`market`||n===`runtime`?n:`installed`,a=f(),o=i(),{toast:s}=R(),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[m,h]=(0,q.useState)(null);return(0,J.jsxs)(V,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(O,{icon:(0,J.jsx)(G,{className:`size-3.5`}),onClick:()=>o.mutate(void 0,{onSuccess:e=>h(e.id),onError:e=>s(I(e),`error`)}),disabled:!a.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(O,{variant:`primary`,icon:(0,J.jsx)(ie,{className:`size-3.5`}),onClick:()=>l(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[a.data?.off&&(0,J.jsx)(k,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(ae,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(ce,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(z,{value:`installed`,children:[e(`plugins.tab.installed`),a.data&&a.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:a.data.plugins.length})]}),(0,J.jsx)(z,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(z,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(W,{value:`installed`,className:`pt-1`,children:[a.isLoading&&(0,J.jsx)(N,{lines:4}),a.isError&&(0,J.jsx)(k,{tone:`danger`,title:e(`common.error`),children:I(a.error)}),a.data&&(0,J.jsx)(ge,{plugins:a.data.plugins,preferences:a.data.preferences,onJob:h,onBrowse:()=>t(`/plugins/market`),onImport:()=>d(!0)})]}),(0,J.jsx)(W,{value:`market`,className:`pt-1`,children:(0,J.jsx)(Se,{installed:a.data?.plugins??[],onJob:h})}),(0,J.jsx)(W,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Ce,{onJob:h})})]})]}),(0,J.jsx)(ye,{open:c,onOpenChange:l,onJob:h}),(0,J.jsx)(be,{open:u,onOpenChange:d,onJob:h}),(0,J.jsx)(xe,{id:m,onClose:()=>h(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:r,onImport:i}){let{t:a}=p(),s=h(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),c=o(),l=b(),{toast:u}=R(),f=!!(c.data?.found&&c.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:a(`plugins.magpie.banner`,{count:c.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(O,{size:`sm`,icon:(0,J.jsx)(le,{className:`size-3.5`}),onClick:i,children:a(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(d,{icon:(0,J.jsx)(C,{className:`size-6`}),title:a(`plugins.empty`),detail:a(`plugins.emptyDetail`),action:(0,J.jsx)(O,{variant:`primary`,onClick:r,children:a(`plugins.browseMarket`)})})})]});let m=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),l.mutate(r,{onError:e=>u(I(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((r,i)=>(0,J.jsx)(_e,{plugin:r,host:s.data,preferences:t,onJob:n,onUp:i>0?()=>m(i,-1):void 0,onDown:i<e.length-1?()=>m(i,1):void 0},r.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`plugins.orderHint`)})]})}function _e({plugin:t,host:n,preferences:r,onJob:a,onUp:o,onDown:c}){let{t:l}=p(),u=U(),{toast:d,confirm:f}=R(),m=s(),h=i(),g=e(),_=M(),[v,y]=(0,q.useState)(!1),b=n?.plugins.find(e=>e.spec===t.spec),x=t.middleware,S=t.kinds[0]??`provider`,C=async()=>{await f({title:l(`plugins.removeConfirm`,{name:t.shortName}),detail:l(`plugins.removeDetail`),confirmLabel:l(`common.delete`),destructive:!0})&&g.mutate(t.spec,{onSuccess:e=>a(e.id),onError:e=>d(I(e),`error`)})},T=[];return x&&!x.error&&T.push((0,J.jsxs)(Q,{label:l(`plugins.kind.middleware`),children:[l(`plugins.mw.stats`,{hooks:x.hooks.join(`, `),calls:x.calls,micros:x.avgMicros.toFixed(1),failures:x.failures}),x.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:l(`plugins.mw.lastError`,{error:x.lastError})})]},`mw`)),t.agent?.kind&&T.push((0,J.jsx)(Q,{label:l(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>u(`/clients/${t.agent.kind}`),children:l(`plugins.agent.adds`,{name:t.agent.name??t.agent.id??``})})},`agent`)),b&&b.provides.length>0&&T.push((0,J.jsxs)(Q,{label:l(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:l(`plugins.provides`,{providers:b.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>u(`/providers`),children:l(`plugins.openProviders`)}),Object.entries(b.servedBy).map(([e,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[l(`plugins.servedBy`,{provider:e,other:n}),(0,J.jsx)(O,{size:`sm`,onClick:()=>_.mutate({spec:t.spec,provider:e},{onError:e=>d(I(e),`error`)}),children:l(`plugins.useFor`,{provider:e})})]},e)),b.provides.some(e=>r[e]===t.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:l(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:E(`flex gap-3 px-4 py-3.5`,!t.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:E(`pt-0.5`,!t.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:t.shortName,icon:t.icon,kind:S})}),(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:t.shortName}),t.version&&(0,J.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:[`v`,t.version]}),t.kinds.map(e=>(0,J.jsx)(w,{tone:he[e],children:l(Y[e])},e)),t.isPath&&(0,J.jsx)(w,{tone:`orange`,children:l(`plugins.local`)})]}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:t.spec,children:t.spec})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[x&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(O,{size:`sm`,variant:`plain`,"aria-label":l(`plugins.moveUp`),title:l(`plugins.moveUp`),disabled:!o,onClick:o,icon:(0,J.jsx)(ue,{className:`size-3.5`})}),(0,J.jsx)(O,{size:`sm`,variant:`plain`,"aria-label":l(`plugins.moveDown`),title:l(`plugins.moveDown`),disabled:!c,onClick:c,icon:(0,J.jsx)(te,{className:`size-3.5`})})]}),(0,J.jsx)(F,{checked:t.enabled,label:l(`plugins.enabled`),onChange:e=>m.mutate({spec:t.spec,enabled:e},{onError:e=>d(I(e),`error`)})}),(0,J.jsx)(ee,{label:l(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ne,{className:`size-4`}),items:[{id:`options`,label:l(`plugins.options`),icon:(0,J.jsx)(pe,{className:`size-3.5`}),onSelect:()=>y(!0)},...t.isPath?[]:[{id:`update`,label:l(`plugins.update`),icon:(0,J.jsx)(G,{className:`size-3.5`}),onSelect:()=>h.mutate(t.spec,{onSuccess:e=>a(e.id),onError:e=>d(I(e),`error`)})}],{id:`remove`,label:l(`common.delete`),icon:(0,J.jsx)(se,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void C()}]})]})]}),t.error&&(0,J.jsx)(k,{tone:`danger`,title:l(`plugins.cantLoad`),children:t.error}),b?.error&&(0,J.jsx)(k,{tone:`danger`,title:l(`plugins.hostCantLoad`),children:b.error}),x?.error&&(0,J.jsx)(k,{tone:`danger`,title:l(`plugins.cantLoad`),children:l(`plugins.mw.error`,{error:x.error})}),t.agent?.error&&(0,J.jsx)(k,{tone:`danger`,title:l(`plugins.cantLoad`),children:l(`plugins.agent.error`,{error:t.agent.error})}),T.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:T})]}),(0,J.jsx)(ve,{plugin:t,open:v,onOpenChange:y})]})}function Q({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex gap-3 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[var(--text-muted)]`,children:e}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 text-[var(--text-secondary)]`,children:t})]})}function ve({plugin:e,open:t,onOpenChange:n}){let{t:r}=p(),{toast:i}=R(),a=s(),[o,c]=(0,q.useState)(``),[u,d]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(c(JSON.stringify(e.options??e.optionsExample??{},null,2)),d(null))},[t,e.options,e.optionsExample]);let f=t=>a.mutate({spec:e.spec,options:t},{onSuccess:()=>(i(r(`plugins.optionsSaved`)),n(!1)),onError:e=>i(I(e),`error`)});return(0,J.jsxs)(L,{open:t,onOpenChange:n,title:r(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?r(`plugins.optionsExample`):r(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(O,{onClick:()=>f(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(O,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(o||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(r(`plugins.optionsObject`));f(e)}catch(e){d(e instanceof Error?e.message:String(e))}},disabled:a.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(l,{mono:!0,rows:14,value:o,invalid:!!u,onChange:e=>(c(e.target.value),d(null)),label:r(`plugins.options`)}),u&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:u})]})}function ye({open:e,onOpenChange:t,onJob:r}){let{t:i}=p(),{toast:a}=R(),o=n(),[s,c]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&c(``)},[e]),(0,J.jsxs)(L,{open:e,onOpenChange:t,title:i(`plugins.addTitle`),description:i(`plugins.addDetail`),footer:(0,J.jsx)(O,{variant:`primary`,disabled:!s.trim()||o.isPending,onClick:()=>o.mutate({spec:s.trim()},{onSuccess:e=>(r(e.id),t(!1)),onError:e=>a(I(e),`error`)}),children:i(`plugins.install`)}),children:[(0,J.jsx)(x,{label:i(`plugins.spec`),hint:i(`plugins.specHint`),children:(0,J.jsx)(m,{mono:!0,value:s,onChange:e=>c(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(k,{tone:`warning`,title:i(`plugins.trustTitle`),className:`mt-4`,children:i(`plugins.trustDetail`)})]})}function be({open:e,onOpenChange:t,onJob:n}){let{t:i}=p(),{toast:a}=R(),s=o(e),c=r(),[l,u]=(0,q.useState)(!1),d=s.data;return(0,J.jsxs)(L,{open:e,onOpenChange:t,title:i(`plugins.magpie.title`),description:d?.path,width:560,footer:(0,J.jsx)(O,{variant:`primary`,disabled:!d?.found||c.isPending,onClick:()=>c.mutate(l,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>a(I(e),`error`)}),children:i(`plugins.magpie.import`)}),children:[s.isLoading&&(0,J.jsx)(N,{lines:3}),d?.error&&(0,J.jsx)(k,{tone:`danger`,title:i(`common.error`),children:d.error}),d&&(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:d.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)(w,{children:i(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(w,{tone:`accent`,children:i(`plugins.options`)}),e.installed&&(0,J.jsx)(w,{tone:`green`,children:i(`plugins.installed`)})]},e.spec))}),d.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(F,{checked:l,onChange:u,label:i(`plugins.magpie.signIns`,{count:d.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:i(`plugins.magpie.signInsDetail`)})]})]})]})}function xe({id:e,onClose:t}){let{t:n}=p(),r=A(e).data;return(0,J.jsxs)(L,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:r?n(r.state===`running`?`plugins.job.running`:r.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:r.target}):void 0,width:620,footer:(0,J.jsx)(O,{onClick:t,children:n(`common.close`)}),children:[!r&&(0,J.jsx)(N,{lines:3}),r&&(0,J.jsx)(v,{language:`text`,children:r.log.length?r.log.join(`
|
|
2
|
+
`):`…`}),r?.state===`failed`&&r.error&&(0,J.jsx)(k,{tone:`danger`,title:n(`plugins.job.failedTitle`),className:`mt-3`,children:r.error})]})}function Se({installed:e,onJob:t}){let{t:r,locale:i}=p(),{toast:a,confirm:o}=R(),s=T(),l=n(),[u,f]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[g,v]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>h(u.trim()),400);return()=>clearTimeout(e)},[u]);let b=y(m),x=(0,q.useMemo)(()=>new Set(e.map(e=>e.name)),[e]),S=(t,n)=>x.has(n)||e.some(e=>e.spec===t),w=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(I(e),`error`)})},[E,D]=de(),O=E.get(`install`),A=(0,q.useRef)(null);(0,q.useEffect)(()=>{O&&A.current!==O&&(A.current=O,D({},{replace:!0}),me.test(O)?w(O,`market`):a(r(`plugins.linkInvalid`),`error`))},[O]);let j=(s.data??[]).filter(e=>g===`all`||e.kind===g),M=e=>(s.data??[]).filter(t=>e===`all`||t.kind===e).length,P=m.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)(_,{className:`min-w-[220px] flex-1`,value:u,onChange:f,placeholder:r(`plugins.searchPlaceholder`)}),!P&&(0,J.jsx)(c,{ariaLabel:r(`plugins.kindFilter`),value:g,onChange:v,items:[`all`,`provider`,`middleware`,`agent`].map(e=>({value:e,label:`${r(e===`all`?`plugins.kind.all`:Y[e])} ${M(e)}`}))})]}),P?(0,J.jsxs)(J.Fragment,{children:[b.isLoading&&(0,J.jsx)(N,{lines:3}),b.data?.length===0&&(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(d,{icon:(0,J.jsx)(C,{className:`size-6`}),title:r(`plugins.noResults`)})}),b.data&&b.data.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:b.data.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.spec,icon:(0,J.jsx)(X,{name:e.name,kind:e.kind}),detail:e.description??void 0,tags:[r(Y[e.kind]),e.source===`github`?`★ ${e.stars}`:e.version?`v${e.version}`:``,e.source===`astra`?r(`plugins.origin.astra`):``],installed:S(e.spec,e.name),onInstall:()=>void w(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:[s.isLoading&&(0,J.jsx)(N,{lines:4}),s.isError&&(0,J.jsx)(k,{tone:`danger`,title:r(`common.error`),children:I(s.error)}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:j.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.package,icon:(0,J.jsx)(X,{name:e.name,icon:e.icon,kind:e.kind}),detail:e.summary[i]??e.summary.en??e.description??void 0,tags:[r(Y[e.kind]),e.latest?`v${e.latest}`:``,e.origin===`astra`?r(`plugins.origin.astra`):``,e.minAstraVersion?r(`plugins.minVersion`,{version:e.minAstraVersion}):``].filter(Boolean),installed:S(e.package,e.package),onInstall:()=>void w(e.package,`market`)},e.package))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:r(`plugins.marketNote`)})]})]})}function $({title:e,subtitle:t,icon:n,detail:r,tags:i,installed:a,onInstall:o}){let{t:s}=p();return(0,J.jsxs)(`div`,{className:`card flex flex-col gap-3 p-4 transition-colors hover:border-[var(--border)]`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[n,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e,children:e}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:t,children:t})]})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 min-h-[2lh] text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:r??``}),(0,J.jsxs)(`div`,{className:`mt-auto flex items-center gap-1.5`,children:[i.filter(Boolean).map(e=>(0,J.jsx)(w,{children:e},e)),(0,J.jsx)(`span`,{className:`flex-1`}),a?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-[var(--success)]`,children:[(0,J.jsx)(u,{className:`size-3.5`}),s(`plugins.installed`)]}):(0,J.jsx)(O,{size:`sm`,variant:`primary`,onClick:o,children:s(`plugins.install`)})]})]})}function Ce({onJob:e}){let{t:n,locale:r}=p(),{toast:i}=R(),o=f(),s=h(),c=a(),l=o.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`}),l&&(0,J.jsx)(w,{tone:l.path?`green`:`neutral`,children:l.path?n(`plugins.bunReady`):n(`plugins.bunMissing`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:n(`plugins.bunDetail`)}),l&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l.path&&(0,J.jsx)(g,{label:n(`plugins.bunPath`),mono:!0,children:l.path}),l.version&&(0,J.jsx)(g,{label:n(`plugins.bunVersion`),mono:!0,children:l.version}),(0,J.jsx)(g,{label:n(`plugins.bunTarget`),mono:!0,children:l.target??n(`plugins.bunNoBuild`)})]}),l?.error&&(0,J.jsx)(k,{tone:`danger`,title:n(`plugins.bunFailed`),children:l.error}),l&&!l.path&&(0,J.jsx)(`div`,{children:(0,J.jsx)(O,{variant:`primary`,disabled:l.downloading||c.isPending||!l.target,onClick:()=>c.mutate(void 0,{onSuccess:t=>e(t.id),onError:e=>i(I(e),`error`)}),children:l.downloading?n(`plugins.bunDownloading`):n(`plugins.bunDownload`,{version:l.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:n(`plugins.host`)}),s.data&&(0,J.jsx)(w,{tone:s.data.running?`green`:`neutral`,children:s.data.running?n(`plugins.hostRunning`):n(`plugins.hostStopped`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:n(`plugins.hostDetail`)}),s.data?.startError&&(0,J.jsx)(k,{tone:`danger`,title:n(`plugins.hostStartFailed`),children:s.data.startError}),s.data?.goneReason&&(0,J.jsx)(k,{tone:`warning`,title:n(`plugins.hostGone`),children:s.data.goneReason}),s.data&&s.data.plugins.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:s.data.plugins.map(e=>(0,J.jsx)(g,{label:e.spec,mono:!0,children:e.error?n(`plugins.hostPluginError`,{error:e.error}):e.provides.join(`, `)||`—`},e.spec))}),s.data?.recent&&s.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:n(`plugins.hostRecent`)}),s.data.recent.map((e,n)=>(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-[12px]`,children:[(0,J.jsx)(w,{tone:e.variant===`error`?`red`:e.variant===`warning`?`orange`:e.variant===`success`?`green`:`neutral`,children:t(e.at,r)}),(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]})]},n))]})]}),(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)(re,{className:`size-3`}),` astragate-community/astra-gate-plugins`]})]})}export{Z as PluginsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,J as t,Jt as n,Qt as r,Sa as i,Y as a,_ as o,_a as s,_r as c,b as l,bt as u,c as d,ct as f,d as p,dt as m,g as h,ga as g,gr as _,h as v,hr as y,l as b,lo as x,m as S,mr as C,n as w,ot as T,po as E,r as D,t as ee,u as O,uo as k,v as A,va as j,xa as M,xt as N,y as P,ya as F,zi as I}from"./alert-BKRTQ9va.js";import{a as L,i as te,o as R,r as z}from"./overlays-CizKmvVN.js";import{B as ne,C as B,D as V,E as re,G as ie,I as ae,K as oe,N as se,P as H,T as ce,_ as U,at as W,c as le,h as ue,it as de,nt as fe,r as pe,tt as me,w as G,z as he}from"./index-Cj8lNw6g.js";var ge={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};ge.node;var _e=N(ge),K=E(k(),1),q={toolbar:`_toolbar_1p5c5_1`,leading:`_leading_1p5c5_2`,frame:`_frame_1p5c5_4`,chips:`_chips_1p5c5_5`,slot:`_slot_1p5c5_7`,chip:`_chip_1p5c5_5`,chipLabel:`_chipLabel_1p5c5_10`,value:`_value_1p5c5_11`,separator:`_separator_1p5c5_12`,morphText:`_morphText_1p5c5_13`,morphValue:`_morphValue_1p5c5_14`,measure:`_measure_1p5c5_15`,empty:`_empty_1p5c5_18`,actions:`_actions_1p5c5_19`,clear:`_clear_1p5c5_20`,clearText:`_clearText_1p5c5_21`,srOnly:`_srOnly_1p5c5_23`,menu:`_menu_1p5c5_27`,trigger:`_trigger_1p5c5_29`,face:`_face_1p5c5_31`,surface:`_surface_1p5c5_34`,panel:`_panel_1p5c5_42`,head:`_head_1p5c5_45`,back:`_back_1p5c5_47`,title:`_title_1p5c5_49`,titleText:`_titleText_1p5c5_50`,stage:`_stage_1p5c5_51`,step:`_step_1p5c5_52`,list:`_list_1p5c5_53`,highlight:`_highlight_1p5c5_54`,item:`_item_1p5c5_55`,itemIcon:`_itemIcon_1p5c5_57`,itemLabel:`_itemLabel_1p5c5_58`,itemMeta:`_itemMeta_1p5c5_59`,metaValue:`_metaValue_1p5c5_60`,hint:`_hint_1p5c5_61`,check:`_check_1p5c5_62`,noOptions:`_noOptions_1p5c5_64`},J=x(),Y={duration:e.duration.standard,ease:[...e.ease.enter]},ve={duration:e.duration.instant,ease:[...e.ease.standard]},X={duration:0},ye={duration:e.duration.instant,ease:[...e.ease.standard]},Z=e=>`blur(${e}px)`,be=e=>Math.min(1,Math.max(0,e)),xe=e=>typeof e==`string`?{value:e}:e,Se=e=>e.label??e.value,Ce=t=>({initial:t?{opacity:0}:{opacity:0,y:`0.3em`,filter:Z(e.blur.soft)},animate:{opacity:1,y:0,filter:Z(0)},exit:t?{opacity:0,transition:X}:{opacity:0,y:`-0.3em`,filter:Z(e.blur.subtle),transition:ve},transition:t?ye:Y});function we({text:t}){let n=j()??!1,r=(0,K.useRef)(null),i=F(`auto`);return(0,K.useLayoutEffect)(()=>{let t=r.current;if(!t||typeof ResizeObserver>`u`)return;let a=null,o=new ResizeObserver(([r])=>{let o=Math.ceil(r.borderBoxSize?.[0]?.inlineSize??t.offsetWidth),c=a!==null&&a!==t.textContent;a=t.textContent,c&&!n?s(i,o,e.spring.morph):i.jump(o)});return o.observe(t),()=>o.disconnect()},[n,i]),(0,J.jsxs)(g.span,{className:q.morphText,style:{width:i},children:[(0,J.jsx)(`span`,{ref:r,className:q.measure,"aria-hidden":`true`,children:t}),(0,J.jsx)(M,{mode:`popLayout`,initial:!1,children:(0,J.jsx)(g.span,{className:q.morphValue,...Ce(n),children:t},t)})]})}function Te(t,n,r){let i=F(`auto`);return(0,K.useLayoutEffect)(()=>{let a=t.current;if(!a||typeof ResizeObserver>`u`)return;let o=!1,c=new ResizeObserver(()=>{let t=a.offsetHeight;if(!o||r||performance.now()>n.current){o=!0,i.jump(t);return}s(i,t,e.spring.smooth)});return c.observe(a),()=>c.disconnect()},[n,i,t,r]),i}function Ee(t,n,r){(0,K.useLayoutEffect)(()=>{let i=t.current;if(!i||typeof ResizeObserver>`u`)return;let a=new Map,o=()=>{let t=performance.now();for(let o of Array.from(i.children)){let i=o.offsetLeft,c=o.offsetTop,l=a.get(o);if(!l){a.set(o,{x:i,y:c,dx:0,dy:0});continue}let u=l.x-i,d=l.y-c;if(l.x=i,l.y=c,r||t>n.current||Math.abs(d)<1&&Math.abs(u)<40)continue;l.stop?.();let f=l.dx+u,p=l.dy+d,m=e=>{l.dx=f*(1-e),l.dy=p*(1-e),o.style.translate=e>=1?``:`${l.dx}px ${l.dy}px`};m(0),l.stop=s(0,1,{...e.spring.smooth,onUpdate:m,onComplete:()=>m(1)}).stop}for(let e of a.keys())e.parentElement!==i&&a.delete(e)},c=new ResizeObserver(o),l=()=>{for(let e of Array.from(i.children))c.observe(e)},u=new MutationObserver(()=>{l(),o()});return c.observe(i),l(),u.observe(i,{childList:!0}),()=>{c.disconnect(),u.disconnect();for(let e of a.values())e.stop?.()}},[n,t,r])}var De=e=>e.valueLabel??e.value,Oe=e=>De(e)?`${e.label}: ${De(e)}`:e.label,ke={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${Oe(e)}`,added:e=>`Added ${Oe(e)}`,changed:e=>`Changed ${Oe(e)}`,removed:e=>`Removed ${Oe(e)}`};function Ae(e,t,n){let r=e.filter(e=>!t.some(t=>t.id===e.id));if(!t.length&&r.length>1)return n.cleared;let i=t.filter(t=>!e.some(e=>e.id===t.id)),a=t.filter(t=>e.some(e=>e.id===t.id&&e.value!==t.value));return[...i.map(n.added),...a.map(n.changed),...r.map(n.removed)].join(`. `)}function je({rows:t,labelledBy:n,onChoose:r,onBack:a,onLeave:o,radio:s,emptyMessage:c}){let l=j()??!1,u=i(),d=(0,K.useRef)(null),f=(0,K.useRef)(!1),p=(0,K.useRef)({text:``,at:0}),[m,h]=(0,K.useState)(()=>Math.max(0,t.findIndex(e=>e.checked))),[_,v]=(0,K.useState)(null),y=()=>Array.from(d.current?.querySelectorAll(`[data-row]`)??[]),b=e=>{let t=d.current;e&&t&&(e.focus({preventScroll:!0}),e.offsetTop<t.scrollTop?t.scrollTop=e.offsetTop:e.offsetTop+e.offsetHeight>t.scrollTop+t.clientHeight&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight))};function x(e){let n=y(),i=n.indexOf(document.activeElement),o=t=>{e.preventDefault(),f.current=!1,b(n[t])};if(e.key===`ArrowDown`)return o(i<0?0:(i+1)%n.length);if(e.key===`ArrowUp`)return o(i<0?n.length-1:(i-1+n.length)%n.length);if(e.key===`Home`)return o(0);if(e.key===`End`)return o(n.length-1);if(e.key===`ArrowRight`&&i>=0&&t[i]?.drill){e.preventDefault(),r(t[i],!0);return}if(e.key===`ArrowLeft`&&a){e.preventDefault(),a(!0);return}if(e.key.length===1&&/\S/.test(e.key)&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let t=performance.now();p.current={text:t-p.current.at<700?p.current.text+e.key.toLowerCase():e.key.toLowerCase(),at:t};let r=[...n.slice(i+(p.current.text.length>1?0:1)),...n.slice(0,i+(p.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(p.current.text));r&&o(n.indexOf(r))}}function S(e){let t=e.target.closest(`[data-row]`);if(!t)return;h(y().indexOf(t));let n=f.current&&!l,r=!f.current&&t.matches(`:focus-visible`);v(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function C(e){d.current?.contains(e.relatedTarget)||v(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,J.jsxs)(`div`,{ref:d,className:q.list,role:`menu`,"aria-labelledby":n,"data-current":u?``:void 0,onKeyDown:x,onFocus:S,onBlur:C,onPointerLeave:()=>{f.current&&d.current?.contains(document.activeElement)&&o()},children:[(0,J.jsx)(g.span,{className:q.highlight,"data-ring":_?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:_?{y:_.top,height:_.height,opacity:+!!_.shown}:{opacity:0},transition:{default:_?.glide?e.spring.snappy:X,opacity:{duration:l?0:.08}}}),t.length===0?(0,J.jsx)(`p`,{className:q.noOptions,children:c}):null,t.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:q.item,role:s?`menuitemradio`:`menuitem`,"aria-checked":s?!!e.checked:void 0,tabIndex:t===m?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{f.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>r(e,t.detail===0),children:[e.icon?(0,J.jsx)(`span`,{className:q.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,J.jsx)(`span`,{className:q.itemLabel,children:e.label}),e.meta?(0,J.jsx)(`span`,{className:q.itemMeta,children:e.meta}):null]},e.key))]})}function Me(e){let t={left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight};for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){let e=getComputedStyle(n);if(e.overflowX===`visible`&&e.overflowY===`visible`)continue;let r=n.getBoundingClientRect();e.overflowX!==`visible`&&(t.left=Math.max(t.left,r.left),t.right=Math.min(t.right,r.right)),e.overflowY!==`visible`&&(t.top=Math.max(t.top,r.top),t.bottom=Math.min(t.bottom,r.bottom))}return t}function Ne({fields:t,onSelect:n,active:r=[],label:i=`Add filter`,align:a=`end`,messages:o}){let c={...ke,...o},l=j()??!1,d=(0,K.useId)(),f=`${d}panel`,p=`${d}title`,m=(0,K.useRef)(null),h=(0,K.useRef)(null),_=(0,K.useRef)(null),v=(0,K.useRef)(`closed`),y=(0,K.useRef)(0),b=(0,K.useRef)(null),[x,S]=(0,K.useState)(`closed`),[C,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(1),[D,ee]=(0,K.useState)(!1),[O,k]=(0,K.useState)(`100% 0`),A=F(`100%`),N=F(`100%`),P=F(0),I=F(0),L=W(()=>I.get()-P.get()),te=F(0),R=F(0),z=W(()=>{let e=A.get(),t=te.get(),n=R.get();return typeof e==`number`?n>t?be((e-t)/(n-t)):1:0}),B=W(()=>be(z.get()/.35)),V=W(()=>be((z.get()-.4)/.5)),re={opacity:W(()=>1-B.get()),scale:W(()=>1-B.get()*.04),filter:W(()=>B.get()?Z(B.get()*e.blur.subtle):`none`)},ae={opacity:V,transformOrigin:O,scale:W(()=>.96+V.get()*.04),y:W(()=>(1-V.get())*(D?-6:6)),filter:W(()=>V.get()===1?`none`:Z((1-V.get())*e.blur.soft))},se=x===`open`,H=t.find(e=>e.id===C)??null,ce=(0,K.useCallback)(t=>{let n=h.current,r=_.current;if(!n||!r)return;let i=n.getBoundingClientRect(),o=r.offsetWidth+2,c=r.offsetHeight+2,u=Me(m.current??n),d=u.left+16-i.left,f=u.right-16-i.left-o,p=i.width-o,g=a===`end`?p>=d?p:0<=f?0:p:0<=f?0:p>=d?p:0;g=Math.round(Math.min(Math.max(g,d),Math.max(d,f)));let x=u.bottom-i.top,C=i.bottom-u.top,T=x<c+16&&C>x;v.current===`closed`&&(A.jump(i.width),N.jump(i.height),P.jump(0)),I.jump(g),te.jump(i.width),R.jump(o),v.current=`open`,y.current+=1,b.current=t,S(`open`),ee(T),w(null),E(-1),k(`${Math.round(i.width/2-g)}px ${T?`100%`:`0`}`);let D=l?X:e.spring.morph;s(P,g,D),s(A,o,D),s(N,c,D)},[a,te,N,P,l,I,R,A]),U=(0,K.useCallback)(t=>{let n=h.current;if(v.current!==`open`||!n)return;v.current=`closing`;let r=y.current+=1;S(`closing`),t&&n.focus({preventScroll:!0,focusVisible:t===`keyboard`});let i=l?X:e.spring.snappy;s(P,0,i);let a=n.getBoundingClientRect();s(N,a.height,i),s(A,a.width,{...i,onComplete:()=>{r===y.current&&(v.current=`closed`,A.jump(`100%`),N.jump(`100%`),S(`closed`),w(null))}})},[N,P,l,A]);(0,K.useLayoutEffect)(()=>{let t=_.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>{v.current===`open`&&s(N,t.offsetHeight+2,l?X:e.spring.smooth)});return n.observe(t),()=>n.disconnect()},[N,l]),(0,K.useLayoutEffect)(()=>{let e=b.current,t=_.current;if(!e||!t||x!==`open`)return;if(b.current=null,e===`panel`){t.focus({preventScroll:!0});return}let n=Array.from(t.querySelectorAll(`[data-current] [data-row]`));(e===`first`?n[0]:e===`last`?n.at(-1):e===`checked`?n.find(e=>e.getAttribute(`aria-checked`)===`true`)??n[0]:n.find(t=>t.dataset.row===e.key)??n[0])?.focus({preventScroll:!0})},[x,C]),(0,K.useEffect)(()=>{if(x!==`open`)return;let e=e=>{let t=m.current,n=e.target;!t||n&&t.contains(n)||(U(!1),n?.closest?.(`button, a[href], input, select, textarea, [tabindex], [contenteditable]`)||window.setTimeout(()=>{let e=document.activeElement;(!e||e===document.body||t.contains(e))&&h.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[U,x]);function le(e){if(e.defaultPrevented)return;let t=Array.from(_.current?.querySelectorAll(`[data-current] [data-row]`)??[]);(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),(e.key===`ArrowDown`?t[0]:t.at(-1))?.focus({preventScroll:!0})),e.key===`ArrowLeft`&&H&&(e.preventDefault(),ue(!0))}function ue(e){H&&(b.current=e?{key:H.id}:`panel`,E(-1),w(null))}function de(e,t){b.current=t?`checked`:`panel`,E(1),w(e.key)}function fe(e,t){H&&(n({id:H.id,label:H.label,value:e.key,valueLabel:e.label},H),U(t?`keyboard`:`pointer`))}let pe=e=>r.find(t=>t.id===e.id),me=t.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,J.jsxs)(J.Fragment,{children:[pe(e)?(0,J.jsx)(`span`,{className:q.metaValue,children:De(pe(e))}):null,(0,J.jsx)(ie,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),G=H?H.options.map(xe).map(e=>{let t=Se(e),n=pe(H)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,J.jsxs)(J.Fragment,{children:[e.hint==null?null:(0,J.jsx)(`span`,{className:q.hint,children:e.hint}),(0,J.jsx)(`span`,{className:q.check,"data-on":n||void 0,children:(0,J.jsx)(u,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],he={enter:t=>l?{opacity:0}:{opacity:0,x:t*18,filter:Z(e.blur.soft)},center:{opacity:1,x:0,filter:Z(0),transition:l?ye:{...Y,x:e.spring.smooth}},exit:t=>l?{opacity:0,transition:X}:{opacity:0,x:t*-18,filter:Z(e.blur.subtle),transition:ve}};return(0,J.jsxs)(`div`,{ref:m,className:q.menu,"data-state":x,"data-y":D?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&v.current===`open`&&(e.preventDefault(),e.stopPropagation(),U(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;v.current===`open`&&t&&!m.current?.contains(t)&&U(!1)},children:[(0,J.jsx)(`button`,{ref:h,type:`button`,className:q.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":se,"aria-controls":f,tabIndex:se?-1:void 0,onClick:e=>{v.current!==`open`&&ce(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),ce(e.key===`ArrowDown`?`first`:`last`))},children:(0,J.jsxs)(g.span,{className:q.face,style:re,children:[(0,J.jsx)(ne,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),i]})}),(0,J.jsx)(g.div,{className:q.surface,style:{left:P,width:A,height:N},children:(0,J.jsx)(g.div,{ref:_,id:f,className:q.panel,role:`dialog`,"aria-labelledby":p,tabIndex:-1,inert:!se,style:{x:L},onKeyDown:le,children:(0,J.jsxs)(g.div,{style:ae,children:[(0,J.jsxs)(`div`,{className:q.head,children:[(0,J.jsx)(M,{initial:!1,children:H?(0,J.jsx)(g.button,{type:`button`,className:q.back,"aria-label":c.back,onClick:e=>ue(e.detail===0),initial:l?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:l?{opacity:0,transition:X}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...e.spring.snappy,opacity:ve}},transition:l?ye:{...e.spring.snappy,opacity:Y},children:(0,J.jsx)(oe,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,J.jsx)(`span`,{className:q.title,id:p,children:(0,J.jsx)(M,{mode:`popLayout`,initial:!1,children:(0,J.jsx)(g.span,{className:q.titleText,...Ce(l),children:H?H.label:i},H?.id??`fields`)})})]}),(0,J.jsx)(`div`,{className:q.stage,children:(0,J.jsx)(M,{mode:`popLayout`,initial:!1,custom:T,children:(0,J.jsx)(g.div,{className:q.step,custom:T,variants:he,initial:`enter`,animate:`center`,exit:`exit`,children:H?(0,J.jsx)(je,{rows:G,labelledBy:p,emptyMessage:c.noOptions,radio:!0,onChoose:fe,onBack:ue,onLeave:()=>_.current?.focus({preventScroll:!0})}):(0,J.jsx)(je,{rows:me,labelledBy:p,emptyMessage:c.noOptions,onChoose:de,onLeave:()=>_.current?.focus({preventScroll:!0})})},H?.id??`fields`)})})]})})})]})}function Pe({filters:t,onRemove:n,onClearAll:r,leading:i,children:a,label:o=`Active filters`,addFilter:s,messages:c}){let l={...ke,...c},u=j()??!1,d=(0,K.useRef)(null),f=(0,K.useRef)(null),p=(0,K.useRef)(0),h=(0,K.useRef)(null),[_,v]=(0,K.useState)(t),[y,b]=(0,K.useState)(``);if(_!==t){v(t);let e=Ae(_,t,l);e&&b(e)}let x=t.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,K.useLayoutEffect)(()=>{p.current=performance.now()+900},[x]);let S=Te(f,p,u);Ee(f,p,u),(0,K.useLayoutEffect)(()=>{let e=h.current,n=d.current;if(e===null||!n)return;h.current=null;let r=t[Math.min(e,t.length-1)];(r?n.querySelector(`[data-chip-remove="${CSS.escape(r.id)}"]`):n.querySelector(`[data-filter-trigger]`))?.focus({preventScroll:!0})},[t]);let C={duration:0},w=t=>({initial:!u&&{width:0,marginRight:-t,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:u?{opacity:0,transition:C}:{width:0,marginRight:-t,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...e.spring.smooth,"--slot-moving":C}},transition:u?C:e.spring.smooth}),T={initial:!u&&{opacity:0,scale:.9,filter:Z(e.blur.soft)},animate:{opacity:1,scale:1,filter:Z(0)},exit:u?{opacity:0,transition:C}:{opacity:0,scale:.9,filter:Z(e.blur.subtle),transition:ve},transition:u?C:{...Y,scale:e.spring.snappy}},E=u?{...Ce(!0),initial:!1}:Ce(!1),D=u?E:{...E,transition:{...Y,delay:e.duration.instant*.75}};return(0,J.jsxs)(`div`,{ref:d,className:q.toolbar,role:`group`,"aria-label":o,children:[i?(0,J.jsx)(`div`,{className:q.leading,children:i}):null,(0,J.jsx)(g.div,{className:q.frame,style:{height:S},children:(0,J.jsxs)(`div`,{ref:f,className:q.chips,children:[(0,J.jsx)(M,{initial:!1,children:t.map((e,t)=>(0,J.jsx)(g.span,{className:q.slot,...w(8),children:(0,J.jsxs)(g.span,{className:q.chip,...T,children:[(0,J.jsxs)(`span`,{className:q.chipLabel,title:Oe(e),children:[e.label,De(e)?(0,J.jsxs)(`span`,{className:q.value,children:[(0,J.jsx)(`span`,{className:q.separator,children:` · `}),(0,J.jsx)(we,{text:De(e)})]}):null]}),(0,J.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":l.remove(e),onClick:r=>{document.activeElement===r.currentTarget&&(h.current=t),n(e.id)},children:(0,J.jsx)(m,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,J.jsx)(M,{initial:!1,children:t.length?null:(0,J.jsx)(g.span,{className:q.empty,...D,children:l.empty},`empty`)})]})}),(0,J.jsxs)(`div`,{className:q.actions,children:[s?(0,J.jsx)(Ne,{fields:s.fields,onSelect:s.onAdd,active:t,label:s.label,align:s.align,messages:l}):null,a,(0,J.jsx)(M,{initial:!1,children:t.length>0&&r?(0,J.jsx)(g.span,{className:q.slot,...w(12),children:(0,J.jsx)(`button`,{className:q.clear,type:`button`,onClick:()=>{h.current=-1,r?.()},children:(0,J.jsx)(g.span,{className:q.clearText,...E,children:l.clearAll})})},`clear`):null})]}),(0,J.jsx)(`span`,{className:q.srOnly,role:`status`,children:y})]})}var Fe={api_key:`settings.privacy.category.api_key`,aws_key:`settings.privacy.category.aws_key`,jwt:`settings.privacy.category.jwt`,private_key:`settings.privacy.category.private_key`,email:`settings.privacy.category.email`,phone:`settings.privacy.category.phone`,intranet:`settings.privacy.category.intranet`,credit_card:`settings.privacy.category.credit_card`,national_id:`settings.privacy.category.national_id`,credential:`settings.privacy.category.credential`,custom:`settings.privacy.category.custom`},Ie={warn:`settings.privacy.action.warn`,block:`settings.privacy.action.block`,redact:`settings.privacy.action.redact`};function Le(){let{t:e}=f();return t=>{let n=Fe[t];return n?e(n):t}}function Re({action:e}){let{t}=f();return(0,J.jsx)(w,{tone:e===`block`?`red`:e===`redact`?`orange`:`neutral`,children:t(Ie[e]??`settings.privacy.action.warn`)})}var ze=50,Be=[`block`,`redact`,`warn`];function Ve(){let{t:e,locale:i}=f(),o=Le(),[s,l]=(0,K.useState)(``),[u,p]=(0,K.useState)({client:``,category:``,action:``,blocked:``}),[m,h]=(0,K.useState)(1),[g,_]=(0,K.useState)(null),y=se(s),b=r(),x=C(),{toast:S,confirm:w}=R(),E=n(),O={model:y,...u,page:m,pageSize:ze},k=c(O,m===1),j=k.data,M=j?Math.max(1,Math.ceil(j.total/ze)):1,N=e=>e?U[e]?.name??e:`—`,P=[...new Set((x.data?.rules??[]).map(e=>e.category))],F={client:(b.data??[]).map(e=>({value:e.kind,label:e.name})),category:P.map(e=>({value:e,label:o(e)})),action:Be.map(t=>({value:t,label:e(`settings.privacy.action.${t}`)})),blocked:[{value:`true`,label:e(`privacy.logs.blockedOnly`)},{value:`false`,label:e(`privacy.logs.passedOnly`)}]},I={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},te=Object.keys(F).map(e=>({id:e,label:I[e],options:F[e].map(e=>e.label)})),z=Object.keys(u).filter(e=>u[e]).map(e=>({id:e,label:I[e],value:F[e].find(t=>t.value===u[e])?.label??u[e]})),ne=(e,t)=>{p(n=>({...n,[e]:t})),h(1)},B=(j?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:N(e.clientKind),model:e.requestedModel??``,outcome:He(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),re=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,n)=>(0,J.jsx)(`span`,{className:`num`,children:t(n.e.startedAtUtc,i)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,J.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>_(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,J.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,J.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:N(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,J.jsx)(Ue,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,J.jsx)(We,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,J.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,J.jsx)(v,{className:`w-52`,value:s,onChange:e=>{l(e),h(1)},placeholder:e(`requests.searchModel`)}),(0,J.jsx)(D,{variant:`plain`,icon:(0,J.jsx)(he,{className:T(`size-4`,k.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void k.refetch()}),(0,J.jsx)(D,{variant:`plain`,className:`ml-auto`,icon:(0,J.jsx)(H,{className:`size-4`}),disabled:E.isPending||!j||j.total===0,onClick:async()=>{await w({title:e(`privacy.logs.clearConfirm`),detail:e(`privacy.logs.clearDetail`),confirmLabel:e(`privacy.logs.clear`),destructive:!0})&&E.mutate(void 0,{onSuccess:t=>{h(1),S(e(`privacy.logs.cleared`,{count:a(t.cleared)}),`success`)},onError:e=>S(L(e),`error`)})},children:e(`privacy.logs.clear`)})]}),(0,J.jsx)(`div`,{className:`mb-3`,children:(0,J.jsx)(Pe,{label:e(`requests.filters`),filters:z,onRemove:e=>ne(e,``),onClearAll:()=>{p({client:``,category:``,action:``,blocked:``}),h(1)},addFilter:{fields:te,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=F[t].find(t=>t.label===e.value)?.value;n&&ne(t,n)}}})}),k.isLoading&&(0,J.jsx)(A,{lines:4,className:`py-6`}),k.isError&&(0,J.jsx)(ee,{tone:`danger`,title:e(`common.error`),children:L(k.error)}),j&&j.items.length===0&&(0,J.jsx)(d,{icon:(0,J.jsx)(_e,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),j&&j.items.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:a(j.total)})}),(0,J.jsx)(V,{caption:e(`privacy.tab.logs`),rows:B,columns:re,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),j&&M>1&&(0,J.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,J.jsx)(le,{page:m,pageCount:M,onPageChange:h,label:e(`requests.page`,{page:m,pages:M})})}),(0,J.jsx)(pe,{id:g,onClose:()=>_(null)})]})}function He(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function Ue({event:e}){let{t}=f();return e.blocked?(0,J.jsx)(w,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,J.jsx)(w,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,J.jsx)(w,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,J.jsx)(w,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function We({event:e}){let t=Le(),{t:n}=f();if(e.hits.length===0)return(0,J.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,J.jsx)(Re,{action:e.action}),(0,J.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,J.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.samples.slice(0,2).join(` `)})]},`${e.ruleId}:${e.action}`)),i>0&&(0,J.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:n(`privacy.logs.moreHits`,{count:i})})]})}var Q={counter:`_counter_dnoch_1`,label:`_label_dnoch_2`,value:`_value_dnoch_4`,column:`_column_dnoch_6`,sizer:`_sizer_dnoch_7`,glyph:`_glyph_dnoch_8`,labelText:`_labelText_dnoch_9`,labelSwap:`_labelSwap_dnoch_10`,symbol:`_symbol_dnoch_11`,srOnly:`_srOnly_dnoch_12`},Ge=[0,1,2,3,4,5,6,7,8,9],Ke={hidden:{opacity:0,y:`0.3em`,filter:`blur(${e.blur.soft}px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:e.duration.standard,ease:[...e.ease.enter]}},gone:{opacity:0,y:`-0.3em`,filter:`blur(${e.blur.subtle}px)`,transition:{duration:e.duration.fast,ease:[...e.ease.standard]}}},qe={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:e.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:e.duration.instant}}},Je={...e.spring.smooth,visualDuration:e.duration.considered};function Ye(e,t,n){let r=new Intl.NumberFormat(n,{minimumFractionDigits:t,maximumFractionDigits:t,numberingSystem:`latn`}).formatToParts(e),i=r.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),a=0,o=0;return r.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--i}`,digit:Number(e),order:o++})):e.type===`fraction`?[...e.value].map(e=>({key:`f${a++}`,digit:Number(e),order:o++})):[{key:e.type===`group`?`g${i}`:e.type===`decimal`?`d`:`${e.type}${t}`,text:e.value}])}function Xe({position:t,digit:n}){let r=W(t,e=>((n-e)%10+15)%10-5),i=W(r,e=>`${e}em`),a=W(r,e=>Math.max(0,1-Math.abs(e))),o=W(r,e=>Math.abs(e)>=1?`hidden`:`visible`),s=W(r,t=>Math.abs(t)<.02||Math.abs(t)>=1?`none`:`blur(${(Math.abs(t)*e.blur.subtle).toFixed(2)}px)`);return(0,J.jsx)(g.span,{className:Q.glyph,style:{y:i,opacity:a,filter:s,visibility:o},children:n})}var Ze={initial:{width:0,opacity:0},animate:{width:`auto`,opacity:1},exit:{width:0,opacity:0}};function Qe({digit:t,direction:n,armed:r,delay:i,reduceMotion:a}){let o=F(r?0:t),c=(0,K.useRef)({digit:r?0:t,target:r?0:t,revealed:!r});return(0,K.useEffect)(()=>{let l=c.current;if(r||l.digit===t){r||(l.revealed=!0);return}l.target+=n<0&&l.revealed?-((l.digit-t+10)%10):(t-l.digit+10)%10,l.digit=t,a?o.jump(l.target):s(o,l.target,l.revealed?e.spring.smooth:{...Je,delay:i}),l.revealed=!0},[r,i,t,n,o,a]),(0,J.jsxs)(g.span,{className:Q.column,...Ze,transition:a?{duration:0}:e.spring.morph,children:[(0,J.jsx)(`span`,{className:Q.sizer,children:`0`}),Ge.map(e=>(0,J.jsx)(Xe,{position:o,digit:e},e))]})}function $e({value:t,label:n,prefix:r=``,suffix:i=``,decimals:a=0,animateOnView:o=!1,locale:s=`en-US`}){let c=(0,K.useRef)(null),l=de(c,{once:!0,amount:.6}),u=!!j(),[d,f]=(0,K.useState)(t),[p,m]=(0,K.useState)(1);t!==d&&(f(t),m(t>d?1:-1));let h=Ye(t,a,s),_=`${r}${h.map(e=>`text`in e?e.text:e.digit).join(``)}${i}`,v=o&&!l;return(0,J.jsxs)(`span`,{ref:c,className:Q.counter,children:[n&&(0,J.jsx)(`span`,{className:Q.label,children:(0,J.jsx)(`span`,{className:Q.labelSwap,children:(0,J.jsx)(M,{mode:`popLayout`,initial:!1,children:(0,J.jsx)(g.span,{className:Q.labelText,variants:u?qe:Ke,initial:`hidden`,animate:`shown`,exit:`gone`,children:n},n)})})}),(0,J.jsx)(`span`,{className:Q.srOnly,children:_}),(0,J.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[r&&(0,J.jsx)(`span`,{className:Q.symbol,children:r}),(0,J.jsx)(M,{initial:!1,children:h.map(t=>`digit`in t?(0,J.jsx)(Qe,{digit:t.digit,direction:p,armed:v,delay:Math.min(t.order*e.stagger.item,.25),reduceMotion:u},t.key):(0,J.jsx)(g.span,{className:Q.symbol,...Ze,transition:u?{duration:0}:e.spring.morph,children:t.text},t.key))}),i&&(0,J.jsx)(`span`,{className:Q.symbol,children:i})]})]})}var $={card:`_card_1r6t9_1`,top:`_top_1r6t9_2`,swap:`_swap_1r6t9_8`,swapBlock:`_swapBlock_1r6t9_8`,text:`_text_1r6t9_11`,sizer:`_sizer_1r6t9_13`},et={hidden:t=>({opacity:0,y:`${.3*t}em`,filter:`blur(${e.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:e.duration.standard,ease:[...e.ease.enter]}},gone:t=>({opacity:0,y:`${-.3*t}em`,filter:`blur(${e.blur.subtle}px)`,transition:{duration:e.duration.fast,ease:[...e.ease.standard]}})},tt={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:e.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:e.duration.instant}}},nt=e=>Number(e.replace(/,/g,``).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN);function rt({text:t,morph:n=!1,block:r=!1}){let i=!!j(),a=(0,K.useRef)(null),o=F(`auto`),[c,l]=(0,K.useState)({text:t,direction:1});return c.text!==t&&l({text:t,direction:nt(t)<nt(c.text)?-1:1}),(0,K.useEffect)(()=>{let t=a.current;if(!t||typeof ResizeObserver>`u`)return;let n=null,r=new ResizeObserver(([r])=>{let a=r.borderBoxSize?.[0]?.inlineSize??t.offsetWidth;a&&n!==null&&n!==t.textContent&&!i?s(o,a,e.spring.morph):o.jump(a||`auto`),n=a?t.textContent:null});return r.observe(t),()=>r.disconnect()},[n,i,o]),(0,J.jsxs)(g.span,{className:r?$.swapBlock:$.swap,style:n?{width:o}:void 0,children:[n&&(0,J.jsx)(`span`,{ref:a,className:$.sizer,"aria-hidden":`true`,children:t}),(0,J.jsx)(M,{mode:`popLayout`,initial:!1,custom:c.direction,children:(0,J.jsx)(g.span,{className:$.text,custom:c.direction,variants:i?tt:et,initial:`hidden`,animate:`shown`,exit:`gone`,children:t},t)})]})}function it({label:t,value:n,suffix:r,context:i,change:a}){let o=!!j();return(0,J.jsxs)(`article`,{className:$.card,children:[(0,J.jsxs)(`div`,{className:$.top,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(rt,{text:t,block:!0})}),(0,J.jsx)(M,{initial:!1,children:a&&(0,J.jsx)(g.small,{"data-trend":/^[+]/.test(a)?`up`:/^[-−]/.test(a)?`down`:void 0,initial:{opacity:0,scale:o?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:o?1:.96,transition:{duration:e.duration.fast,ease:[...e.ease.standard]}},transition:o?{duration:0}:e.spring.snappy,children:(0,J.jsx)(rt,{text:a,morph:!0})},`change`)})]}),(0,J.jsx)($e,{value:n,suffix:r,animateOnView:!0}),(0,J.jsx)(`p`,{children:(0,J.jsx)(rt,{text:i,block:!0})})]})}var at=[{id:`ipv4-all`,nameKey:`settings.privacy.template.ipv4All`,hintKey:`settings.privacy.template.ipv4AllHint`,pattern:String.raw`(?<![\d.])(?:\d{1,3}\.){3}\d{1,3}(?![\d.])`},{id:`landline`,nameKey:`settings.privacy.template.landline`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<!\d)0\d{2,3}[- ]?\d{7,8}(?!\d)`},{id:`license-plate`,nameKey:`settings.privacy.template.licensePlate`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]`},{id:`passport-cn`,nameKey:`settings.privacy.template.passportCn`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])[EG]\d{8}(?!\d)`},{id:`uscc`,nameKey:`settings.privacy.template.uscc`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-HJ-NPQRTUWXY])[0-9A-HJ-NPQRTUWXY]{18}(?![0-9A-HJ-NPQRTUWXY])`},{id:`long-token`,nameKey:`settings.privacy.template.longToken`,hintKey:`settings.privacy.template.longTokenHint`,pattern:String.raw`(?<![A-Za-z0-9])[A-Za-z0-9_\-]{32,}(?![A-Za-z0-9])`},{id:`mac-address`,nameKey:`settings.privacy.template.macAddress`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-Fa-f:])(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}(?![0-9A-Fa-f:])`},{id:`unix-home`,nameKey:`settings.privacy.template.unixHome`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`/(?:Users|home)/[A-Za-z0-9_.\-]+`},{id:`windows-profile`,nameKey:`settings.privacy.template.windowsProfile`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`[A-Za-z]:\\+Users\\+[A-Za-z0-9_.\-]+`},{id:`cloud-accesskey`,nameKey:`settings.privacy.template.cloudAccessKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:LTAI[A-Za-z0-9]{12,20}|AKID[A-Za-z0-9]{13,40})(?![A-Za-z0-9])`},{id:`aws-secret-key`,nameKey:`settings.privacy.template.awsSecretKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9/+=])[A-Za-z0-9/+=]{40}(?![A-Za-z0-9/+=])`},{id:`im-webhook`,nameKey:`settings.privacy.template.imWebhook`,hintKey:`settings.privacy.template.imWebhookHint`,pattern:String.raw`oapi\.dingtalk\.com/robot/send\?access_token=[0-9a-f]{64}|qyapi\.weixin\.qq\.com/cgi-bin/webhook/send\?key=[0-9a-f]{32}|open\.feishu\.cn/open-apis/bot/v2/hook/[0-9a-f\-]{20,}|hooks\.slack\.com/services/T[A-Za-z0-9]+/B[A-Za-z0-9]+/[A-Za-z0-9]+`},{id:`internal-service`,nameKey:`settings.privacy.template.internalService`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:gitlab|jenkins|jira|confluence|wiki|nexus|harbor|grafana|kibana|sonarqube|oa|sso)\.[A-Za-z0-9\-]+(?:\.[A-Za-z0-9\-]+)+`},{id:`jdbc-conn`,nameKey:`settings.privacy.template.jdbcConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`jdbc:[A-Za-z0-9]+:[^\s"']*(?:[Uu]ser(?:[ _]?[Ii][Dd])?|[Pp]assword)=[^\s"&';]+`},{id:`smtp-conn`,nameKey:`settings.privacy.template.smtpConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`(?:smtp|imap|pop3)s?://[^\s:@/]+:[^\s@]+@[^\s]+`},{id:`key-file-ref`,nameKey:`settings.privacy.template.keyFileRef`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[A-Za-z0-9_\-./\\]+\.(?:pem|key|pfx|p12|jks|keystore)\b`},{id:`confidential-marker`,nameKey:`settings.privacy.template.confidentialMarker`,hintKey:`settings.privacy.template.confidentialHint`,pattern:String.raw`(?:绝密|机密|商业秘密|内部资料|内部公开|仅限内部|请勿外传|Confidential|Internal Use Only|Internal Only|Company Private)`},{id:`employee-id`,nameKey:`settings.privacy.template.employeeId`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:[Ee][Mm][Pp]|工号)[::\- ]?\d{4,10}(?!\d)`},{id:`labeled-number`,nameKey:`settings.privacy.template.labeledNumber`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:合同|订单|采购单|工单|项目)编号[::]?\s*[A-Za-z0-9_\-]{4,32}`}],ot=[`off`,`warn`,`block`,`redact`],st=Ie;function ct(){let{t:e}=f(),{toast:t}=R(),n=C(),r=I(),i=n.data?.settings,a=e=>{i&&r.mutate({...i,...e},{onError:e=>t(L(e),`error`)})},o=ot.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:st[t])}));return(0,J.jsxs)(O,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,J.jsx)(A,{className:`my-4`}),n.isError&&(0,J.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:L(n.error)}),i&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(S,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,J.jsx)(P,{checked:i.enabled,label:e(`settings.privacy.enabled`),onChange:e=>a({enabled:e})})}),(0,J.jsx)(S,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,J.jsx)(P,{checked:i.dryRun,disabled:!i.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>a({dryRun:e})})}),(0,J.jsx)(S,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,J.jsx)(P,{checked:i.restoreResponses,disabled:!i.enabled,label:e(`settings.privacy.restore`),onChange:e=>a({restoreResponses:e})})}),(0,J.jsx)(S,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,J.jsx)(P,{checked:i.recordSamples,disabled:!i.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>a({recordSamples:e})})}),(0,J.jsx)(S,{label:e(`settings.privacy.recordFullSamples`),detail:e(`settings.privacy.recordFullSamplesHint`),children:(0,J.jsx)(P,{checked:i.recordFullSamples,disabled:!i.enabled||!i.recordSamples,label:e(`settings.privacy.recordFullSamples`),onChange:e=>a({recordFullSamples:e})})}),(0,J.jsx)(S,{label:e(`settings.privacy.defaultAction`),children:(0,J.jsx)(z,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:i.defaultAction,disabled:!i.enabled,onChange:e=>a({defaultAction:e}),options:o})})]})]})}function lt(){let{t:e}=f(),{toast:t}=R(),n=C(),r=I(),i=n.data?.settings,a=Le(),o=e=>{i&&r.mutate({...i,...e},{onError:e=>t(L(e),`error`)})},s=(e,t)=>o({categoryActions:{...i?.categoryActions,[e]:t}}),c=ot.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:st[t])})),l=[...new Set((n.data?.rules??[]).map(e=>e.category))],u=e=>n.data?.rules.find(t=>t.category===e)?.description;return n.isLoading?(0,J.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,J.jsx)(A,{className:`my-4`})}):i?(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,J.jsx)(O,{title:e(`settings.privacy.categories`),children:l.map(t=>{let n=i.categoryActions[t]??i.defaultAction,r=!i.enabled||n===`off`;return(0,J.jsxs)(S,{label:a(t),detail:u(t),children:[n===`off`?(0,J.jsx)(w,{children:e(`settings.privacy.action.off`)}):(0,J.jsx)(z,{className:`w-36`,ariaLabel:a(t),value:n,disabled:!i.enabled,onChange:e=>s(t,e),options:c.filter(e=>e.value!==`off`)}),r&&(0,J.jsx)(D,{size:`sm`,variant:`plain`,disabled:!i.enabled,onClick:()=>s(t,i.categoryActions[t]??i.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,J.jsx)(ut,{s:i,onPatch:o})]}):null}function ut({s:e,onPatch:t}){let{t:n}=f(),{confirm:r}=R(),[i,a]=(0,K.useState)(!1),o=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),s=async i=>{await r({title:n(`settings.privacy.deleteRuleConfirm`,{name:i.name}),destructive:!0,confirmLabel:n(`common.delete`)})&&t({customRules:e.customRules.filter(e=>e.id!==i.id)})};return(0,J.jsxs)(O,{title:n(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,J.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:n(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,J.jsxs)(S,{label:t.name,detail:t.pattern,children:[(0,J.jsx)(P,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>o(t,e)}),(0,J.jsx)(D,{size:`sm`,variant:`plain`,icon:(0,J.jsx)(H,{className:`size-3.5`}),"aria-label":`${n(`common.delete`)} ${t.name}`,onClick:()=>void s(t)})]},t.id)),(0,J.jsx)(`div`,{className:`px-4 py-2`,children:(0,J.jsx)(D,{size:`sm`,icon:(0,J.jsx)(ne,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>a(!0),children:n(`settings.privacy.addRule`)})}),(0,J.jsx)(dt,{open:i,onOpenChange:a,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function dt({open:e,onOpenChange:t,onAdd:n}){let{t:r}=f(),{toast:i}=R(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[u,d]=(0,K.useState)(``);return(0,J.jsx)(te,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(D,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,J.jsx)(D,{variant:`primary`,disabled:!a.trim()||!s.trim(),onClick:()=>{if(a.trim()&&s.trim()){try{new RegExp(s)}catch(e){i(`${r(`settings.privacy.invalidPattern`)}: ${L(e)}`,`error`);return}n({id:`custom-${Date.now().toString(36)}`,name:a.trim(),pattern:s.trim(),enabled:!0}),o(``),c(``),d(``),t(!1)}},children:r(`common.create`)})]}),children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(b,{label:r(`settings.privacy.ruleTemplates`),hint:r(`settings.privacy.ruleTemplatesHint`),children:(0,J.jsx)(z,{ariaLabel:r(`settings.privacy.ruleTemplates`),value:u,onChange:e=>{d(e);let t=at.find(t=>t.id===e);t&&(o(r(t.nameKey)),c(t.pattern))},options:[{value:``,label:r(`settings.privacy.ruleTemplateNone`)},...at.map(e=>({value:e.id,label:r(e.nameKey)}))]})}),(0,J.jsx)(p,{label:r(`settings.privacy.ruleName`),value:a,onChange:e=>o(e.target.value),autoFocus:!0}),(0,J.jsx)(b,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,J.jsx)(l,{mono:!0,rows:3,value:s,onChange:e=>c(e.target.value)})})]})})}function ft(){let{t:e}=f(),{toast:t}=R(),n=Le(),r=C(),i=y(),[a,o]=(0,K.useState)(``),s=i.data,c=r.data?.settings.enabled??!1;return(0,J.jsx)(O,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,J.jsx)(l,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:a,onChange:e=>o(e.target.value)}),(0,J.jsx)(`div`,{children:(0,J.jsx)(D,{icon:(0,J.jsx)(ae,{className:`size-3.5`}),disabled:!c||!a.trim(),loading:i.isPending,onClick:()=>i.mutate({text:a},{onError:e=>t(L(e),`error`)}),children:e(`settings.privacy.runTest`)})}),s&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s.blocked&&(0,J.jsx)(w,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),s.wouldRedact>0&&(0,J.jsx)(w,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:s.wouldRedact})}),!s.blocked&&s.wouldRedact===0&&(0,J.jsx)(w,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),s.hits.length>0&&(0,J.jsx)(`ul`,{className:`mt-2 space-y-1`,children:s.hits.map(t=>(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(w,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(st[t.action])}),(0,J.jsxs)(`span`,{children:[n(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,J.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:t.samples.join(` `)})]},`${t.ruleId}:${t.action}`))})]})]})})}var pt=[`today`,`7d`,`30d`,`all`];function mt(){let{t:e}=f(),t=Le(),[n,r]=(0,K.useState)(`7d`),i=_(n),a=i.data,s=[{key:`category`,label:e(`privacy.stats.col.category`),render:e=>t(String(e))},{key:`requests`,label:e(`privacy.stats.col.requests`),numeric:!0,width:110},{key:`hits`,label:e(`privacy.stats.col.hits`),numeric:!0,width:96},{key:`warnHits`,label:e(`privacy.stats.col.warn`),numeric:!0,width:84},{key:`blockHits`,label:e(`privacy.stats.col.block`),numeric:!0,width:84},{key:`redactHits`,label:e(`privacy.stats.col.redact`),numeric:!0,width:84}],c=(a?.categories??[]).map(e=>({...e}));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`section`,{children:[(0,J.jsx)(h,{action:(0,J.jsx)(o,{ariaLabel:e(`overview.range`),value:n,onChange:r,items:pt.map(t=>({value:t,label:e(`range.${t}`)}))}),children:e(`privacy.stats`)}),i.isLoading&&(0,J.jsx)(A,{lines:3,className:`py-4`}),i.isError&&(0,J.jsx)(ee,{tone:`danger`,title:e(`common.error`),children:L(i.error)}),a&&(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,J.jsx)(it,{label:e(`privacy.stats.events`),value:a.events,context:e(`range.${n}`)}),(0,J.jsx)(it,{label:e(`privacy.stats.blocked`),value:a.blocked,context:e(`range.${n}`)}),(0,J.jsx)(it,{label:e(`privacy.stats.redactions`),value:a.redactions,context:e(`range.${n}`)}),(0,J.jsx)(it,{label:e(`privacy.stats.dryRun`),value:a.dryRun,context:e(`range.${n}`)})]})]}),(0,J.jsxs)(`section`,{children:[(0,J.jsx)(h,{children:e(`privacy.stats.byCategory`)}),a&&a.categories.length===0&&(0,J.jsx)(`div`,{className:`card`,children:(0,J.jsx)(ht,{})}),a&&a.categories.length>0&&(0,J.jsx)(V,{caption:e(`privacy.stats.byCategory`),rows:c,columns:s,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,J.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,J.jsx)(ct,{})})]})}function ht(){let{t:e}=f();return(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,J.jsx)(ae,{className:`size-6 text-[var(--text-muted)]`}),(0,J.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,J.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.empty.detail`)})]})}var gt=[`overview`,`logs`,`rules`,`tester`];function _t(){let{t:e}=f(),{tab:t}=fe(),n=me(),r=gt.includes(t)?t:`overview`;return(0,J.jsx)(ue,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,J.jsxs)(B,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,J.jsx)(ce,{"aria-label":e(`nav.privacy`),children:gt.map(t=>(0,J.jsx)(re,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,J.jsx)(G,{value:`overview`,className:`pt-5`,children:(0,J.jsx)(mt,{})}),(0,J.jsx)(G,{value:`logs`,className:`pt-4`,children:(0,J.jsx)(Ve,{})}),(0,J.jsx)(G,{value:`rules`,className:`pt-5`,children:(0,J.jsx)(lt,{})}),(0,J.jsx)(G,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,J.jsx)(ft,{})})]})})}export{_t as PrivacyPage};
|