@aidotnet/server-win32-x64 0.14.3110 → 0.14.3112
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.exe +2 -2
- package/bin/wwwroot/assets/ClientsPage-CE9QdKbh.js +11 -0
- package/bin/wwwroot/assets/KeyPage-Db9tYWgA.js +1 -0
- package/bin/wwwroot/assets/LibraryPage-Djro5zZa.js +2 -0
- package/bin/wwwroot/assets/McpPage-BJ7D5vt6.js +9 -0
- package/bin/wwwroot/assets/ModelDetailPage-DuyD1_Ei.js +1 -0
- package/bin/wwwroot/assets/ModelsPage-Dc1KK7-3.js +1 -0
- package/bin/wwwroot/assets/PluginsPage-Dn1IYmlm.js +2 -0
- package/bin/wwwroot/assets/PrivacyPage-Dsaaw5Ko.js +1 -0
- package/bin/wwwroot/assets/ProviderDetailPage-C5YbB46r.js +3 -0
- package/bin/wwwroot/assets/ProvidersPage-BzICHtxh.js +3 -0
- package/bin/wwwroot/assets/RoutingGroupsPage-B-7FNn_B.js +3 -0
- package/bin/wwwroot/assets/SettingsPage-CCOHxf9s.js +2 -0
- package/bin/wwwroot/assets/SkillsPage-BdZSd_hw.js +1 -0
- package/bin/wwwroot/assets/SmartRoutingPage-DIkU4HND.js +2 -0
- package/bin/wwwroot/assets/TokenDetailPage-DA6q9gbd.js +1 -0
- package/bin/wwwroot/assets/TokenPoolEditor-CISTyNzC.js +1 -0
- package/bin/wwwroot/assets/TokensPage-CUJXAz7I.js +1 -0
- package/bin/wwwroot/assets/ToolsPage-DOHJoH86.js +1 -0
- package/bin/wwwroot/assets/TracesPage-f3hY7JcZ.js +8 -0
- package/bin/wwwroot/assets/{TrayPanelPage-CackS8OH.js → TrayPanelPage-HGV5ST-e.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelView-Cj0Pwm7y.js → TrayPanelView-BhyK24F_.js} +1 -1
- package/bin/wwwroot/assets/TrayTitleSource-DN10ruw2.js +41 -0
- package/bin/wwwroot/assets/{checkbox-DFbPH3ZB.js → checkbox-CZ-rG7I2.js} +1 -1
- package/bin/wwwroot/assets/clientNames-Bskc9G1M.js +1 -0
- package/bin/wwwroot/assets/{confirm-morph-Cu1awcrW.js → confirm-morph-Cakq9Lho.js} +1 -1
- package/bin/wwwroot/assets/file-up-BZh1Gcck.js +1 -0
- package/bin/wwwroot/assets/flame-BPbKoD7V.js +1 -0
- package/bin/wwwroot/assets/format-CmXxTS5M.js +15 -0
- package/bin/wwwroot/assets/index-BW8keTkg.js +124 -0
- package/bin/wwwroot/assets/index-WJKZ_ywJ.css +1 -0
- package/bin/wwwroot/assets/layers-lBgMUT4n.js +1 -0
- package/bin/wwwroot/assets/library-BUD1zsIb.js +1 -0
- package/bin/wwwroot/assets/{radio-cards-C0nGl7Px.js → radio-cards-BTn8kpAx.js} +1 -1
- package/bin/wwwroot/assets/{sortable.esm-KYAcfdq_.js → sortable.esm-Cj5-STJU.js} +1 -1
- package/bin/wwwroot/assets/use-transform-BcmlojQJ.js +1 -0
- package/bin/wwwroot/assets/wrench-gp64nTHm.js +1 -0
- package/bin/wwwroot/index.html +8 -5
- package/package.json +1 -1
- package/bin/wwwroot/assets/ClientsPage-DF3rflag.js +0 -9
- package/bin/wwwroot/assets/KeyPage-B7_1Yr16.js +0 -1
- package/bin/wwwroot/assets/McpPage-CvN5NYlZ.js +0 -9
- package/bin/wwwroot/assets/ModelDetailPage-CyE8Xpqg.js +0 -1
- package/bin/wwwroot/assets/ModelsPage-Cct68Oc8.js +0 -1
- package/bin/wwwroot/assets/PluginsPage-DiMYLnBv.js +0 -2
- package/bin/wwwroot/assets/PrivacyPage-Bdyo4YN_.js +0 -1
- package/bin/wwwroot/assets/ProviderDetailPage-CZLD3Mo2.js +0 -3
- package/bin/wwwroot/assets/ProvidersPage-DhvpZLqS.js +0 -3
- package/bin/wwwroot/assets/SettingsPage-QVURVf8n.js +0 -2
- package/bin/wwwroot/assets/SkillsPage-DUAhBBjy.js +0 -1
- package/bin/wwwroot/assets/SmartRoutingPage-yxPbwM3u.js +0 -2
- package/bin/wwwroot/assets/TokenDetailPage-jvkJ9wIf.js +0 -1
- package/bin/wwwroot/assets/TokenPoolEditor-eWoOGd9t.js +0 -1
- package/bin/wwwroot/assets/TokensPage-BTnINKwi.js +0 -1
- package/bin/wwwroot/assets/TracesPage-CGAcVl3u.js +0 -8
- package/bin/wwwroot/assets/TrayTitleSource-EINzpQeQ.js +0 -41
- package/bin/wwwroot/assets/file-up-mqWdjdlX.js +0 -1
- package/bin/wwwroot/assets/flame-DLlSOIlR.js +0 -1
- package/bin/wwwroot/assets/format-Bw-mDeuE.js +0 -15
- package/bin/wwwroot/assets/index-D2hgi2oA.js +0 -122
- package/bin/wwwroot/assets/index-D74BlcEH.css +0 -1
- package/bin/wwwroot/assets/layers-Dzm_l0k4.js +0 -1
- package/bin/wwwroot/assets/library-CQ0z7xCA.js +0 -1
- package/bin/wwwroot/assets/use-transform-BEsJGrlr.js +0 -1
- package/bin/wwwroot/assets/wrench-DVonHu-a.js +0 -1
package/bin/astra-server.exe
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/bin/astra-server.exe
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 84733440 bytes
|
|
4
|
+
sha256: 0e8fc372d06eaf31b57db703c1c545f149adf820008006888fac735f5eea9f2d
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{$i as n,Ai as r,B as i,Bi as a,Ct as o,D as s,F as c,Gn as l,H as u,Hn as d,I as f,M as p,N as m,O as h,P as g,Qr as _,Qs as v,Qt as y,S as b,U as x,W as S,Wo as C,Wt as w,Xt as T,Za as E,Zn as ee,Zs as te,Zt as ne,aa as re,ca as ie,ci as D,d as O,da as ae,dt as k,go as A,hi as oe,kn as j,la as M,ln as se,nn as ce,o as N,r as le,s as P,si as ue,sn as de,tn as fe,ui as pe,un as F,w as I,wa as L,z as R}from"./format-CmXxTS5M.js";import{B as me,H as z,L as he,R as B,U as V,V as H,W as U}from"./TrayTitleSource-DN10ruw2.js";import{t as ge}from"./archive-CiVf7slo.js";import{t as W}from"./check-DKfsh0bQ.js";import{t as G}from"./chevron-right-Bgtn3ze-.js";import{t as _e}from"./circle-arrow-up-x7NR55Yx.js";import{t as ve}from"./copy-48gwhhDO.js";import{t as K}from"./ellipsis-CidyZaW2.js";import{t as ye}from"./external-link-D6jQM2CZ.js";import{t as be}from"./folder-open-z1RXMZa1.js";import{t as xe}from"./grip-vertical-DFI2_ajd.js";import{t as Se}from"./key-round-m9ps8ZDi.js";import{t as Ce}from"./layers-lBgMUT4n.js";import{t as we}from"./loader-circle-D-RkwQwX.js";import{t as Te}from"./plus-c3HzV6VX.js";import{t as Ee}from"./refresh-cw-CoLAai2c.js";import{t as De}from"./rotate-ccw-fsXoCwyv.js";import{t as q}from"./scroll-text-DjXe21uH.js";import{t as J}from"./shield-alert-psW-CN8y.js";import{t as Oe}from"./trash-BHBJn5GS.js";import{t as ke}from"./x-AFrW8zH7.js";import{a as Ae,c as je,d as Me,f as Ne,i as Pe,l as Fe,n as Ie,o as Le,r as Re,s as ze,t as Be,u as Ve}from"./sortable.esm-Cj5-STJU.js";import{B as He,C as Ue,G as We,H as Ge,T as Y,W as Ke,i as qe,o as Je,v as Ye,w as Xe,x as Ze}from"./index-BW8keTkg.js";import{n as Qe}from"./ProvidersPage-BzICHtxh.js";var X=e(t(),1),Z=v(),$e=`astra claude`;function et(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 tt=e=>e.status===`active`&&e.enabled;function nt(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return tt(e)?n:`${n} · ${t}`}function rt({enabled:e,gatewayEnabled:t}){let{t:n}=I(),{toast:r}=U(),i=Ke(),a=fe(e),o=re(),[s,l]=(0,X.useState)(null),d=a.data?.mode??`gateway`,f=a.data?.accounts??[],p=a.data?.accountId??null??f.find(tt)?.id??null,g=f.find(e=>e.id===p),_=d===`direct`,v=t&&(_||a.data!=null),y=_&&g?.telemetryEnabled===!0,C=ce(y?g?.id:null,y),w=o.isPending,T=e=>o.mutate(e,{onError:e=>r(V(e),`error`)});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(c,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Z.jsx)(R,{label:n(`clients.claudeDirect.mode`),detail:n(_?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Z.jsx)(u,{ariaLabel:n(`clients.claudeDirect.mode`),value:d,onChange:e=>{if(e===d||w||!a.data)return;let t=p??f.find(tt)?.id??null;if(e===`direct`&&!t){r(n(`clients.claudeDirect.needAccountToast`),`error`);return}T({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)(x,{lines:3}),a.isError&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(b,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:V(a.error)})}),v&&(0,Z.jsx)(`div`,{className:`mb-5`,children:(0,Z.jsx)(b,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),a.data&&(0,Z.jsx)(c,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:f.length===0?(0,Z.jsx)(m,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Z.jsx)(h,{variant:`primary`,onClick:()=>i(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Z.jsx)(R,{label:n(`clients.claudeDirect.account`),children:(0,Z.jsx)(H,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:p,onChange:e=>{w||e===p||T({mode:d,accountId:e})},options:f.map(e=>({value:e.id,label:nt(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!tt(e)}))})})}),a.data&&_&&g&&(0,Z.jsx)(c,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Z.jsx)(it,{command:$e,copied:s,onCopy:async e=>{await B.copy(e)&&(l(e),r(n(`common.copied`)))}})}),a.data&&_&&g&&(0,Z.jsxs)(c,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Z.jsx)(R,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Z.jsx)(S,{label:n(`clients.claudeDirect.statsConsent`),checked:g.telemetryEnabled,disabled:w,onChange:e=>{g&&!w&&T({mode:d,accountId:g.id,telemetryEnabled:e})}})}),y&&(0,Z.jsx)(at,{requests:C})]})]})}function it({command:e,copied:t,onCopy:n}){let{t:r}=I();return(0,Z.jsx)(R,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Z.jsx)(h,{size:`sm`,icon:(0,Z.jsx)(ve,{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 at({requests:e}){let{t,locale:n}=I(),r=e.data??[],i=et(r);return e.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(x,{lines:3})}):e.isError?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(b,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:V(e.error)})}):r.length===0?(0,Z.jsx)(m,{icon:(0,Z.jsx)(Se,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R,{label:t(`clients.claudeDirect.statsTotals`,{count:O(i.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:O(i.totalInputTokens),cache:O(r.reduce((e,t)=>e+t.cacheReadTokens,0)),output:O(i.outputTokens)})}),(0,Z.jsx)(R,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:P(r.some(e=>e.estimatedCostNanoUsd!=null)?i.estimatedCostNanoUsd:null)})}),i.failed>0&&(0,Z.jsx)(R,{label:t(`clients.claudeDirect.statsFailedCount`,{count:O(i.failed)}),children:(0,Z.jsx)(s,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),r.map(e=>(0,Z.jsx)(R,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.model}),e.status===`error`?(0,Z.jsx)(s,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Z.jsx)(s,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Z.jsx)(`span`,{className:`num`,children:[le(e.occurredAtUtc,n),t(`clients.claudeDirect.tokensDetail`,{input:O(e.inputTokens),output:O(e.outputTokens)}),e.durationMs==null?null:N(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Z.jsx)(`span`,{className:`num text-[13px]`,children:P(e.estimatedCostNanoUsd)})},e.id))]})}function ot({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=I(),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)(c,{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)(R,{label:n,detail:r,children:[e.type===`bool`&&(0,Z.jsx)(S,{label:n,checked:o===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(0,Z.jsx)(f,{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)(H,{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 st=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],ct=e=>typeof e==`string`&&st.includes(e);function lt(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))ct(r)&&(n[e]=r);return n}function ut(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(ct):[]})}return n}function dt(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var ft=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
|
|
2
|
+
`),pt=`auto`,mt=e=>Qe.find(t=>t.value===e)?.label??e;function ht({models:e,supported:t,values:n,onChange:r,enabled:i}){let{t:a}=I(),o=(e,t)=>{let i={...n};t===pt?delete i[e]:i[e]=t,r(i)};return(0,Z.jsx)(c,{title:a(`clients.protocols.title`),footer:a(i?`clients.protocols.footerEnabled`:`clients.protocols.footer`),children:e.map(e=>{let r=dt(e,t),i=e.native.filter(e=>t.includes(e));return(0,Z.jsx)(R,{label:e.name,detail:i.length>0?a(`clients.protocols.native`,{protocols:i.map(mt).join(` · `)}):a(`clients.protocols.noNative`),children:(0,Z.jsx)(H,{ariaLabel:e.name,className:`w-60`,value:n[e.id]&&t.includes(n[e.id])?n[e.id]:pt,onChange:t=>o(e.id,t),options:[{value:pt,label:a(r.translated?`clients.protocols.autoTranslated`:`clients.protocols.auto`,{protocol:mt(r.protocol)})},...t.map(e=>({value:e,label:mt(e)}))]})},e.id)})})}function gt(e){let t=e?.modelShortlist;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function _t({client:e}){let{t}=I(),{toast:n}=U(),r=se(e.kind,!0,!0),a=ae(),o=gt(e.extras),s=o.join(`
|
|
3
|
+
`),[l,u]=(0,X.useState)(o),[d,f]=(0,X.useState)(``);(0,X.useEffect)(()=>u(gt(e.extras)),[e.kind,s]);let p=(0,X.useMemo)(()=>r.data??[],[r.data]),m=(0,X.useMemo)(()=>[...p,...l.filter(e=>!p.includes(e))],[p,l]),g=m.filter(e=>e.toLowerCase().includes(d.trim().toLowerCase())),_=l.join(`
|
|
4
|
+
`)!==s,v=(e,t)=>u(n=>t?[...n,e]:n.filter(t=>t!==e)),y=r=>a.mutate({kind:e.kind,models:r},{onSuccess:()=>n(t(`common.saved`),`success`),onError:e=>n(V(e),`error`)});return(0,Z.jsxs)(c,{title:t(`clients.shortlist.title`),footer:e.enabled?t(`clients.shortlist.footerEnabled`):t(`clients.shortlist.footer`),children:[(0,Z.jsxs)(R,{label:l.length===0?t(`clients.shortlist.empty`):t(`clients.shortlist.summary`,{count:l.length,total:m.length}),children:[l.length>0&&(0,Z.jsx)(h,{size:`sm`,onClick:()=>u([]),children:t(`clients.shortlist.clear`)}),_&&(0,Z.jsx)(h,{size:`sm`,variant:`primary`,loading:a.isPending,onClick:()=>y(l),children:t(`common.apply`)})]}),r.isLoading&&(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(x,{lines:2})}),m.length>8&&(0,Z.jsx)(`div`,{className:`px-4 py-2`,children:(0,Z.jsx)(i,{value:d,onChange:f,placeholder:t(`clients.shortlist.filter`)})}),(0,Z.jsx)(`div`,{className:`max-h-[320px] overflow-y-auto`,children:g.map(e=>(0,Z.jsx)(R,{label:(0,Z.jsx)(`span`,{className:`font-mono text-[12px]`,children:e}),detail:p.includes(e)?void 0:t(`clients.shortlist.missing`),children:(0,Z.jsx)(S,{checked:l.includes(e),onChange:t=>v(e,t),label:e})},e))})]})}var vt={enable:`green`,update:`accent`,disable:`orange`,store:`neutral`,unchanged:`neutral`,skipped:`orange`,failed:`red`};function yt(){let{t:e}=I(),{toast:t,confirm:r}=U(),i=D(),a=n(),o=A(),c=j(),l=i.data??[],u=l.find(e=>e.active),[d,p]=(0,X.useState)(``),m=l.find(e=>e.id===d)??u??l[0],[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),x=()=>{if(!_)return;let n=_.name.trim();if(!n)return;let r=n=>{v(null),p(n.id),t(e(`profiles.saved`,{name:n.name}),`success`)};_.id===null?a.mutate(n,{onSuccess:r,onError:e=>t(V(e),`error`)}):o.mutate({id:_.id,name:n},{onSuccess:r,onError:e=>t(V(e),`error`)})},S=async n=>{await r({title:e(`profiles.overwriteConfirm`,{name:n.name}),confirmLabel:e(`profiles.overwrite`)})&&o.mutate({id:n.id,overwrite:!0},{onSuccess:()=>t(e(`profiles.saved`,{name:n.name}),`success`),onError:e=>t(V(e),`error`)})},C=async n=>{await r({title:e(`profiles.deleteConfirm`,{name:n.name}),confirmLabel:e(`profiles.delete`),destructive:!0})&&c.mutate(n.id,{onSuccess:()=>p(``),onError:e=>t(V(e),`error`)})};return(0,Z.jsxs)(`div`,{className:`card mb-4 flex flex-wrap items-center gap-3 px-4 py-2.5`,children:[(0,Z.jsx)(Ce,{className:`size-4 text-[var(--text-secondary)]`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`text-[13px] font-medium`,children:e(`profiles.title`)}),l.length===0?(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`profiles.none`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{className:`w-[220px]`,ariaLabel:e(`profiles.pick`),value:m?.id??``,onChange:p,options:l.map(t=>({value:t.id,label:t.name,detail:e(`profiles.clientCount`,{count:t.clients.length})}))}),m?.active&&!m.drifted&&(0,Z.jsx)(s,{tone:`green`,children:e(`profiles.active`)}),m?.active&&m.drifted&&(0,Z.jsxs)(s,{tone:`orange`,title:e(`profiles.driftedHint`),children:[e(`profiles.active`),` · `,e(`profiles.drifted`)]})]}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[m&&(0,Z.jsx)(h,{variant:`primary`,size:`sm`,onClick:()=>b(m.id),children:e(`profiles.apply`)}),(0,Z.jsx)(h,{size:`sm`,onClick:()=>v({id:null,name:``}),children:e(`profiles.save`)}),m&&(0,Z.jsx)(me,{label:e(`profiles.title`),icon:(0,Z.jsx)(K,{className:`size-4`}),iconOnly:!0,items:[{id:`overwrite`,label:e(`profiles.overwrite`),onSelect:()=>void S(m)},{id:`rename`,label:e(`profiles.rename`),onSelect:()=>v({id:m.id,name:m.name})},{id:`delete`,label:e(`profiles.delete`),destructive:!0,separatorBefore:!0,onSelect:()=>void C(m)}]})]}),(0,Z.jsx)(z,{open:_!==null,onOpenChange:e=>!e&&v(null),width:420,title:_?.id===null?e(`profiles.saveTitle`):e(`profiles.rename`),description:_?.id===null?e(`profiles.subtitle`):void 0,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{onClick:()=>v(null),children:e(`common.cancel`)}),(0,Z.jsx)(h,{variant:`primary`,disabled:!_?.name.trim(),loading:a.isPending||o.isPending,onClick:x,children:e(`common.save`)})]}),children:(0,Z.jsx)(g,{label:e(`profiles.name`),children:(0,Z.jsx)(f,{autoFocus:!0,maxLength:64,value:_?.name??``,onChange:e=>v(t=>t&&{...t,name:e.target.value}),onKeyDown:e=>e.key===`Enter`&&x()})})}),(0,Z.jsx)(St,{profile:l.find(e=>e.id===y)??null,onClose:()=>b(null)})]})}function bt(e,t){let n=[];e.reason&&n.push(e.action===`failed`?e.reason:t(`profiles.reason.${e.reason}`)),e.changes.length>0&&n.push(e.changes.map(e=>e.keyPath).join(`, `));for(let r of e.notes)n.push(r.startsWith(`drifted:`)?t(`profiles.drift`,{key:r.slice(8)}):r);return n.join(` · `)}function xt(e,t){let n=e.what===`provider`?t(`profiles.drop.provider.${e.reason}`,{id:e.id}):t(`profiles.drop.${e.what}`,{id:e.id});return`${e.kind}: ${n}`}function St({profile:e,onClose:t}){let{t:n}=I(),{toast:r}=U(),i=ue(e?.id,e!==null),a=w(),o=(i.data?.steps??[]).filter(e=>e.action!==`unchanged`);return(0,Z.jsxs)(z,{open:e!==null,onOpenChange:e=>!e&&t(),width:620,title:n(`profiles.previewTitle`,{name:e?.name??``}),description:n(`profiles.previewDetail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{onClick:t,children:n(`common.cancel`)}),(0,Z.jsx)(h,{variant:`primary`,disabled:!i.data,loading:a.isPending,onClick:()=>{e&&a.mutate(e.id,{onSuccess:i=>{let a=i.steps.filter(e=>e.action===`skipped`||e.action===`failed`).length;r(a>0?n(`profiles.appliedPartial`,{name:e.name,count:a}):n(`profiles.applied`,{name:e.name}),a>0?void 0:`success`),t()},onError:e=>r(V(e),`error`)})},children:n(`profiles.apply`)})]}),children:[i.isPending&&(0,Z.jsx)(x,{lines:4}),i.isError&&(0,Z.jsx)(b,{tone:`danger`,title:n(`common.error`),children:V(i.error)}),i.data&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.length===0&&(0,Z.jsx)(b,{tone:`info`,title:n(`profiles.nothing`)}),(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:o.map(e=>(0,Z.jsx)(R,{label:e.name,detail:bt(e,n)||void 0,children:(0,Z.jsx)(s,{tone:vt[e.action],children:n(`profiles.action.${e.action}`)})},e.kind))}),i.data.dropped.length>0&&(0,Z.jsx)(b,{tone:`warning`,title:n(`profiles.dropped`),children:i.data.dropped.map((e,t)=>(0,Z.jsx)(`span`,{className:`block break-all`,children:xt(e,n)},t))})]})]})}function Ct(e,t){if(!(e instanceof C)||e.status!==409)return null;let n=e.details;return n?.providerName?{title:t(`clients.providerDisabledTitle`,{name:n.providerName}),hint:t(n.pluginOff?`clients.providerDisabledPluginHint`:`clients.providerDisabledHint`)}:null}function wt(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 Tt=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
|
|
5
|
+
`),Et=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`CLAUDE_CODE_SUBAGENT_MODEL`];function Dt(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of Et){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var Ot=e=>Et.map(t=>e[t]??``).join(`
|
|
6
|
+
`),Q=[`sonnet`,`opus`,`haiku`];function kt(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(`
|
|
7
|
+
`),At=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function jt(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!At.test(e))??e[0],r=e.find(e=>At.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function Mt(){let{t:e}=I(),t=Ke(),{toast:n}=U(),r=We(),i=F(),a=y(),o=(0,X.useMemo)(()=>new Map((i.data??[]).map(e=>[e.kind,e])),[i.data]),s=Pt(i.data).includes(r.kind)?r.kind:`codex`,c=o.get(s);return(0,X.useEffect)(()=>a.mutate(!1),[]),(0,Z.jsx)(Ye,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Z.jsx)(h,{icon:(0,Z.jsx)(Ee,{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(V(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Z.jsxs)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:[(0,Z.jsx)(yt,{}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Z.jsx)(zt,{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)(x,{lines:4}),i.isError&&(0,Z.jsx)(b,{tone:`danger`,title:e(`common.error`),children:V(i.error)}),c&&(0,Z.jsx)(Ut,{client:c}),c&&(0,Z.jsxs)(`div`,{className:`mt-6`,children:[(0,Z.jsx)(qe,{menu:`client.row`,args:{clientKind:c.kind}}),(0,Z.jsx)(Je,{name:`client.detail.sections`,params:{clientKind:c.kind}})]})]})]})]})})}var Nt=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.openchamber.deveco-code.stepcode.aside.omo.prime-agent.mu.mothx.penguin-harness.antigravity-cli.dim.command-code.fx.goose.zoo-code.jetbrains-air.air-ide.copilot-jetbrains.codebuddy.qoder.qoder-cn.t3code.pencil.openpencil.raycast.obsidian.reasonix.morph.jcode.vibe.empryo.nanobot.miniq.paimon.cline.grok-app.atomcode.snow.ante.craft-agents.tuanjie-cowork.liveagent.openmausbot.astrbot.qwenpaw.openclaw.openbot`.split(`.`));function Pt(e){let t=(e??[]).filter(e=>!Ze.includes(e.kind)).sort((e,t)=>e.name.localeCompare(t.name));return[...Ze,...t.map(e=>e.kind)]}var Ft=[`installed`,`notInstalled`,`comingSoon`],It=new Set([`notInstalled`]);function Lt(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function Rt(e){return e.install?.version??e.detection.version??null}function zt({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=I(),[a,o]=(0,X.useState)(new Set),s=new Map((e??[]).map(e=>[e.kind,e])),c=Ft.map(t=>({group:t,items:Pt(e).flatMap(e=>{let n=s.get(e);return n&&Lt(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)(x,{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=It.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)(G,{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}=I(),i=Lt(e)!==`installed`,a=Rt(e),o=e.install?.blocker===`shadowed`,c=e.install?.updateAvailable&&!o?e.install.latestVersion:null;return(0,Z.jsxs)(`button`,{type:`button`,"aria-label":Y(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)(Ue,{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:Y(e.kind,e.name)}),a&&(0,Z.jsxs)(`span`,{className:`hidden truncate text-[11px] text-[var(--text-secondary)] @3xl:block`,children:[a,c&&(0,Z.jsxs)(`span`,{className:`text-[var(--warning)]`,children:[` → `,c]})]})]}),e.install?.busy&&(0,Z.jsx)(Vt,{}),c&&!e.install?.busy&&(0,Z.jsx)(s,{tone:`orange`,title:r(`clients.updateTo`,{version:c}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Z.jsx)(s,{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)(p,{tone:`orange`})}):e.enabled?(0,Z.jsx)(W,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function Vt(){return(0,Z.jsx)(we,{className:`size-3.5 shrink-0 animate-spin text-[var(--text-secondary)] motion-reduce:animate-none`,"aria-hidden":!0})}function Ht(e,t){return e.availability===`coming_soon`?(0,Z.jsx)(s,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Z.jsx)(s,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Z.jsx)(s,{tone:`green`,children:t(`clients.enabled`)}):(0,Z.jsx)(s,{children:t(`clients.disabled`)})}function Ut({client:e}){let{t,locale:n}=I(),i=Ke(),{toast:a,confirm:o}=U(),l=oe(),u=ie(),f=d(),p=ee(),m=r(),g=E(),_=se(e.kind,!!e.providerId),[v,y]=(0,X.useState)(e.selectedModel??null),[S,C]=(0,X.useState)(e.accountId??``),w=e.tokenId??`default`,[T,te]=(0,X.useState)(w),ne=(g.data??[]).filter(e=>e.enabled||e.id===w).map(e=>({value:e.id,label:e.enabled?e.name:t(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[re,D]=(0,X.useState)(!1),[O,ae]=(0,X.useState)(!1),[k,A]=(0,X.useState)(null),j=e.availability===`coming_soon`,M=Y(e.kind,e.name),ce=(l.data??[]).filter(e=>e.enabled),N=e.detection.configPaths[0],P=ce.find(t=>t.id===e.providerId),ue=P?.authScheme===`oauth-subscription`||P?.authScheme===`plugin`,de=pe(P?.id,ue),F=e.kind===`claude-desktop`,L=e.kind===`claude-code`,me=fe(L),z=L&&me.data?.mode===`direct`,W=kt(e.extras),[G,_e]=(0,X.useState)(W),K=Q.some(e=>G[e]),ye=$(G)!==$(W),xe=Dt(e.extras),[Ce,we]=(0,X.useState)(xe),Te=(v??null)!==(e.selectedModel??null)||Ot(Ce)!==Ot(xe),Ee=L?Et.filter(e=>e!==`ANTHROPIC_MODEL`):[],De=L?e.enabled?t(`clients.modelSlotsFooterEnabled`):t(`clients.modelSlotsFooter`):e.enabled?t(`clients.modelFooterEnabled`):t(`clients.modelFooter`),q=e.options??[],J=wt(e.extras,q),[Oe,ke]=(0,X.useState)(J),Ae=Tt(Oe)!==Tt(J),je=e.protocols??[],Me=je.length>1?ut(e.extras):[],Ne=lt(e.extras),[Pe,Fe]=(0,X.useState)(Ne),Ie=ft(Pe)!==ft(Ne),Le=F?{...e.extras,roleMap:G}:L?{...e.extras,models:Ce,options:Oe}:q.length>0||je.length>1?{...e.extras,...q.length>0?{options:Oe}:{},...je.length>1?{protocolOverrides:Pe}:{}}:void 0;(0,X.useEffect)(()=>y(e.selectedModel??null),[e.kind,e.selectedModel]),(0,X.useEffect)(()=>C(e.accountId??``),[e.kind,e.providerId,e.accountId]),(0,X.useEffect)(()=>te(w),[e.kind,w]),(0,X.useEffect)(()=>_e(kt(e.extras)),[e.kind,$(W)]);let Re=(0,X.useRef)({});(0,X.useEffect)(()=>{if(!F||e.enabled||Q.some(e=>W[e]))return;let t=Re.current,n=jt(_.data??[]);Re.current=n,_e(e=>(!Q.some(t=>e[t])||$(e)===$(t))&&$(e)!==$(n)?n:e)},[e.kind,e.enabled,$(W),(_.data??[]).join(`
|
|
8
|
+
`)]),(0,X.useEffect)(()=>we(Dt(e.extras)),[e.kind,Ot(xe)]),(0,X.useEffect)(()=>ke(wt(e.extras,e.options)),[e.kind,Tt(J)]),(0,X.useEffect)(()=>Fe(lt(e.extras)),[e.kind,ft(Ne)]);let ze=()=>{e.providerId&&u.mutate({kind:e.kind,providerId:e.providerId,accountId:S},{onSuccess:()=>a(t(`common.saved`),`success`),onError:e=>a(V(e),`error`)})},Be=async()=>{await o({title:t(`clients.disableConfirm`,{name:M}),detail:t(`clients.disableDetail`),confirmLabel:t(`clients.disable`)})&&f.mutate(e.kind,{onSuccess:async n=>{if(n.drifted.length===0){a(t(`clients.disabledToast`,{name:M}),`success`);return}await o({title:t(`clients.driftTitle`),detail:t(`clients.driftDetail`,{keys:n.drifted.join(`, `)}),confirmLabel:t(`clients.forceRestore`),destructive:!0})&&p.mutate(e.kind,{onSuccess:()=>a(t(`clients.disabledToast`,{name:M}),`success`),onError:e=>a(V(e),`error`)})},onError:e=>a(V(e),`error`)})},Ve=async()=>{N&&(B.canOpenPaths?await B.openPath(he(N)):await B.copy(N)&&a(t(`common.copied`)))};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(c,{children:[(0,Z.jsxs)(R,{icon:(0,Z.jsx)(Ue,{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:M}),z?(0,Z.jsx)(s,{children:t(`clients.claudeDirect.direct`)}):Ht(e,t)]}),detail:j?e.availabilityReason??t(`clients.comingSoonDetail`):[Lt(e)===`installed`?t(`clients.detected`,{version:Rt(e)??``}):t(`clients.notDetected`),z?null:N].filter(Boolean).join(` · `),className:`py-3`,children:[!j&&(0,Z.jsx)(Yt,{client:e,onOpen:A}),z?(0,Z.jsx)(h,{variant:`primary`,onClick:()=>document.getElementById(Zt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.claudeDirect.configure`)}):e.enabled?(0,Z.jsx)(h,{onClick:()=>void Be(),loading:f.isPending,children:t(`clients.disableRestore`)}):(0,Z.jsx)(h,{variant:`primary`,disabled:j||!e.providerId||F&&!K,onClick:()=>D(!0),title:e.providerId?F&&!K?t(`clients.roleMapRequired`):void 0:t(`clients.pickProviderFirst`),children:t(`clients.enable`)})]}),!z&&e.appliedAt&&(0,Z.jsx)(R,{label:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`clients.appliedAt`,{time:le(e.appliedAt,n)})})})]}),!j&&!e.enabled&&F&&e.providerId&&!K&&(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Z.jsx)(b,{tone:`info`,className:`self-stretch`,title:t(`clients.roleMapHint`)}),(0,Z.jsx)(h,{onClick:()=>document.getElementById(Qt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`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)(b,{tone:`danger`,className:`self-stretch`,title:t(`clients.repair.title`,{name:M}),children:[e.repairs?.map(e=>(0,Z.jsxs)(`span`,{className:`block break-all`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.file}),` — `,t(`clients.repair.problem.${e.problem}`,{line:e.line})]},e.file)),(0,Z.jsx)(`span`,{className:`block`,children:t(`clients.repair.hint`)})]}),(0,Z.jsx)(h,{variant:`primary`,loading:m.isPending,onClick:()=>m.mutate(e.kind,{onSuccess:()=>a(t(`clients.repair.done`,{name:M}),`success`),onError:e=>a(V(e),`error`)}),children:t(`clients.repair.action`)})]}),!z&&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)(b,{tone:`warning`,title:e},t))}),!z&&(0,Z.jsx)(qt,{client:e,providers:l.data??[],loading:l.isLoading,soon:j}),!z&&ue&&(0,Z.jsx)(c,{title:t(`clients.accountTitle`),footer:t(`clients.accountFooter`),children:de.isLoading?(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(x,{lines:2})}):(0,Z.jsxs)(R,{label:t(`clients.account`),children:[(0,Z.jsx)(H,{className:`max-w-[300px]`,ariaLabel:t(`clients.account`),value:S,onChange:C,options:[{value:``,label:t(`clients.accountDefault`)},...(de.data??[]).map(e=>({value:e.id,label:(e.displayName||e.id)+(e.status===`active`?``:` · ${t(`providers.subscription.status.${e.status}`)}`)}))]}),S!==(e.accountId??``)&&(0,Z.jsx)(h,{size:`sm`,variant:`primary`,loading:u.isPending,onClick:ze,children:t(`common.apply`)})]})}),!j&&!z&&(0,Z.jsxs)(c,{title:t(`clients.tokenTitle`),footer:e.enabled?t(`clients.tokenFooterEnabled`):t(`clients.tokenFooter`),children:[(0,Z.jsxs)(R,{label:t(`clients.token`),children:[(0,Z.jsx)(H,{className:`max-w-[300px]`,ariaLabel:t(`clients.token`),value:T,onChange:te,options:ne}),e.enabled&&T!==w&&(0,Z.jsx)(h,{size:`sm`,variant:`primary`,onClick:()=>D(!0),children:t(`common.apply`)})]}),(0,Z.jsx)(R,{icon:(0,Z.jsx)(Se,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.manageTokens`),onClick:()=>i(`/tokens`)})]}),!j&&!z&&e.providerId&&F&&(0,Z.jsx)(`div`,{id:Qt,children:(0,Z.jsxs)(c,{title:t(`clients.roleMapTitle`),footer:e.enabled?t(`clients.roleMapFooterEnabled`):t(`clients.roleMapFooter`),children:[Q.map(e=>(0,Z.jsx)(R,{label:t(`clients.role.${e}`),children:(0,Z.jsx)(H,{ariaLabel:t(`clients.role.${e}`),value:G[e]??``,onChange:t=>_e(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(_.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&ye&&(0,Z.jsx)(R,{label:K?``:(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--warning)]`,children:t(`clients.roleMapRequired`)}),children:(0,Z.jsx)(h,{size:`sm`,variant:`primary`,disabled:!K,onClick:()=>D(!0),children:t(`common.apply`)})})]})}),!j&&!z&&e.providerId&&!F&&(0,Z.jsxs)(c,{title:t(`clients.modelTitle`),footer:De,children:[(0,Z.jsx)(R,{label:t(`clients.defaultModel`),children:(0,Z.jsx)(H,{value:v??``,onChange:e=>y(e||null),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(_.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})}),Ee.map(e=>(0,Z.jsx)(R,{label:t(`clients.modelSlot.${e}`),children:(0,Z.jsx)(H,{ariaLabel:t(`clients.modelSlot.${e}`),value:Ce[e]??``,onChange:t=>we(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(_.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&(L?Te:(v??null)!==(e.selectedModel??null))&&(0,Z.jsx)(R,{label:``,children:(0,Z.jsx)(h,{size:`sm`,variant:`primary`,onClick:()=>D(!0),children:t(`common.apply`)})})]}),!j&&!z&&e.providerId&&!F&&(0,Z.jsx)(_t,{client:e}),!j&&!z&&q.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ot,{descriptors:q,values:Oe,onChange:ke,enabled:e.enabled}),e.enabled&&Ae&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(h,{size:`sm`,variant:`primary`,onClick:()=>D(!0),children:t(`common.apply`)})})]}),!j&&Me.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ht,{models:Me,supported:je,values:Pe,onChange:Fe,enabled:e.enabled}),e.enabled&&Ie&&(0,Z.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Z.jsx)(h,{size:`sm`,variant:`primary`,onClick:()=>D(!0),children:t(`common.apply`)})})]}),!j&&e.install&&(0,Z.jsx)(en,{client:e,onShowLog:()=>A(`log`),onUninstall:()=>A(`uninstall`)}),L&&(0,Z.jsx)(`div`,{id:Zt,children:(0,Z.jsx)(rt,{enabled:L,gatewayEnabled:e.enabled})}),!j&&!z&&(0,Z.jsxs)(c,{title:t(`clients.maintenance`),children:[N&&(0,Z.jsx)(R,{icon:B.canOpenPaths?(0,Z.jsx)(be,{className:`size-4 text-[var(--text-secondary)]`}):(0,Z.jsx)(ve,{className:`size-4 text-[var(--text-secondary)]`}),label:B.canOpenPaths?t(`clients.openConfigDir`):t(`clients.copyConfigPath`),detail:N,onClick:()=>void Ve()}),(0,Z.jsx)(R,{icon:(0,Z.jsx)(ge,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.backups`),detail:t(`clients.backupsDetail`),onClick:()=>ae(!0)})]}),(0,Z.jsx)(nn,{open:re,onOpenChange:D,client:e,model:v,extras:Le,tokenId:T}),(0,Z.jsx)(on,{open:O,onOpenChange:ae,client:e}),(0,Z.jsx)(tn,{mode:k,onClose:()=>A(null),client:e})]})}var Wt={install:`clients.installTitle`,update:`clients.updateTitle`,uninstall:`clients.uninstallTitle`},Gt={install:`clients.installedToast`,update:`clients.updatedToast`,uninstall:`clients.uninstalledToast`};function Kt(e,t){return[e.priceKey??e.templateId,t(`providers.modelCount`,{count:e.modelCount}),e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `)}function qt({client:e,providers:t,loading:n,soon:r}){let{t:i}=I(),{toast:a}=U(),o=M(),s=(0,X.useMemo)(()=>e.bindings??(e.providerId?[{providerId:e.providerId,accountId:e.accountId}]:[]),[e.bindings,e.providerId,e.accountId]),[l,u]=(0,X.useState)(s);(0,X.useEffect)(()=>u(s),[s]);let d=(0,X.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),f=l.flatMap(e=>{let t=d.get(e.providerId);return t?[{binding:e,provider:t}]:[]}),p=t.filter(e=>e.enabled&&!l.some(t=>t.providerId===e.id)),g=Me(Ve(je,{activationConstraint:{distance:4}}),Ve(ze,{coordinateGetter:Re})),_=r||o.isPending,v=(t,n)=>{let r=l;u(t),o.mutate({kind:e.kind,bindings:t},{onSuccess:()=>a(Nt.has(e.kind)&&e.enabled?i(`clients.providersModelsSynced`,{client:Y(e.kind,e.name)}):n),onError:e=>{u(r),a(V(e),`error`)}})},y=({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||v(Ie(l,n,r),i(`clients.providerOrderSaved`))},b=e=>v([...l,{providerId:e.id}],i(`clients.providerAdded`,{provider:e.name})),S=e=>v(l.filter(t=>t.providerId!==e.id),i(`clients.providerRemoved`,{provider:e.name})),C=p.map(e=>(0,Z.jsx)(R,{icon:(0,Z.jsx)(Xe,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24}),label:e.name,detail:Kt(e,i),onClick:_?void 0:()=>b(e),children:!r&&(0,Z.jsx)(Te,{className:`size-4 text-[var(--text-secondary)]`,"aria-label":i(`common.add`)})},e.id));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(c,{title:i(`clients.providerTitle`),footer:i(`clients.providerFooter`),children:[n&&(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(x,{lines:2})}),!n&&f.length===0&&p.length===0&&(0,Z.jsx)(m,{title:i(`clients.noProviders`),detail:i(`clients.noProvidersDetail`),action:(0,Z.jsx)(Ge,{to:`/providers?new=1`,children:(0,Z.jsx)(h,{variant:`primary`,icon:(0,Z.jsx)(Te,{className:`size-3.5`}),children:i(`providers.add`)})})}),f.length>0&&(0,Z.jsx)(Le,{sensors:g,collisionDetection:Fe,onDragEnd:y,children:(0,Z.jsx)(Be,{items:f.map(e=>e.provider.id),strategy:Ae,children:f.map(({provider:e},t)=>(0,Z.jsx)(Jt,{provider:e,primary:t===0,disabled:_,onRemove:f.length>1?()=>S(e):void 0},e.id))})}),!n&&f.length===0&&C]}),f.length>0&&p.length>0&&(0,Z.jsx)(c,{title:i(`clients.moreProvidersTitle`),children:C})]})}function Jt({provider:e,primary:t,disabled:n,onRemove:r}){let{t:i}=I(),{attributes:a,listeners:o,setNodeRef:c,setActivatorNodeRef:l,transform:u,transition:d,isDragging:f}=Pe({id:e.id,disabled:n});return(0,Z.jsx)(`div`,{ref:c,style:{transform:Ne.Transform.toString(u),transition:d},className:k(f&&`relative z-10 bg-[var(--surface)] shadow-lg`),children:(0,Z.jsx)(R,{icon:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`button`,{ref:l,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)(xe,{className:`size-4`})}),(0,Z.jsx)(Xe,{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)(s,{tone:`accent`,children:i(`clients.primaryProvider`)}),!e.enabled&&(0,Z.jsx)(s,{tone:`orange`,children:i(`clients.providerDisabledBadge`)})]}),detail:Kt(e,i),children:r&&(0,Z.jsx)(h,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(ke,{className:`size-3.5`}),"aria-label":i(`clients.removeProvider`,{provider:e.name}),title:i(`clients.removeProvider`,{provider:e.name}),disabled:n,onClick:r})})})}function Yt({client:e,onOpen:t}){let{t:n}=I(),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)(J,{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)(h,{icon:(0,Z.jsx)(Vt,{}),onClick:()=>t(`log`),children:n(`clients.installRunning`)}):r.updateAvailable&&r.updateCommand&&r.latestVersion?(0,Z.jsxs)(h,{icon:(0,Z.jsx)(_e,{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)(h,{icon:(0,Z.jsx)(J,{className:`size-3.5`}),onClick:()=>document.getElementById(Xt)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:n(`clients.shadowedBadge`)}):!r.installed&&r.installCommand?(0,Z.jsxs)(h,{icon:(0,Z.jsx)(He,{className:`size-3.5`}),title:a,onClick:()=>t(`install`),children:[n(`clients.install`),i]}):!r.installed&&r.method===`manual`?(0,Z.jsx)(h,{icon:(0,Z.jsx)(ye,{className:`size-3.5`}),onClick:()=>window.open(r.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.download`)}):null}var Xt=`client-shadowed-alert`,Zt=`claude-direct-panel`,Qt=`client-role-map`;function $t(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 en({client:e,onShowLog:t,onUninstall:n}){let{t:r,locale:i}=I(),a=e.install,o=de(e.kind),l=(e,t=!1)=>(0,Z.jsx)(`span`,{className:k(`text-[13px] tabular-nums selectable`,t&&`text-[var(--text-secondary)]`),children:e}),u=a.blocker===`external-install`?r(`clients.blocker.external-install`,{path:a.executable??``}):a.blocker?r(`clients.blocker.${a.blocker}`):void 0,d=a.otherCopies??[],f=d.find(e=>e.newer);return(0,Z.jsxs)(Z.Fragment,{children:[f&&(0,Z.jsx)(`div`,{id:Xt,className:`mb-3`,children:(0,Z.jsx)(b,{tone:`warning`,title:r(`clients.shadowed.title`,{version:f.version}),children:r(`clients.shadowed.detail`,{path:a.executable??``,version:a.version??``,other:f.path,dir:he(f.path)})})}),!f&&a.notOnPath&&a.executable&&(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(b,{tone:`warning`,title:r(`clients.notOnPath.title`),children:r(`clients.notOnPath.detail`,{dir:he(a.executable)})})}),(0,Z.jsxs)(c,{title:r(`clients.versionTitle`),footer:u,children:[(0,Z.jsx)(R,{label:r(`clients.currentVersion`),detail:a.installed?a.executable:void 0,children:a.installed?l(a.version??r(`clients.versionUnknown`),!a.version):l(r(`clients.notInstalled`),!0)}),d.map(e=>(0,Z.jsxs)(R,{label:r(`clients.otherCopy`),detail:e.path,children:[e.newer&&(0,Z.jsx)(s,{tone:`orange`,children:r(`clients.otherCopyNewer`)}),l(e.version,!e.newer)]},e.path)),(a.method===`npm`||a.method===`script`)&&(0,Z.jsxs)(R,{label:r(`clients.latestVersion`),detail:a.latestError??(a.latestCheckedAt?r(`clients.checkedAt`,{time:le(a.latestCheckedAt,i)}):void 0),children:[a.updateAvailable&&(0,Z.jsx)(s,{tone:`orange`,children:r(`clients.updateBadge`)}),l(a.latestVersion??r(`clients.latestUnknown`),!a.latestVersion)]}),(0,Z.jsx)(R,{label:r(`clients.installMethod`),detail:r(`clients.method.${a.method}`,{package:a.package??``}),children:(0,Z.jsx)(h,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(ye,{className:`size-3`}),onClick:()=>window.open(a.homepageUrl,`_blank`,`noreferrer`),children:r(`clients.homepage`)})}),a.installed&&(0,Z.jsx)(R,{label:r(`clients.uninstall`),detail:a.uninstallCommand??$t(a,r),children:a.uninstallCommand&&(0,Z.jsx)(h,{size:`sm`,variant:`destructive`,icon:(0,Z.jsx)(Oe,{className:`size-3`}),disabled:a.busy,onClick:n,children:r(`clients.uninstall`)})}),o.data&&(0,Z.jsx)(R,{icon:(0,Z.jsx)(q,{className:`size-4 text-[var(--text-secondary)]`}),label:r(`clients.installLog`),detail:`${o.data.command} · ${r(`clients.job.${o.data.state}`)}`,onClick:t})]})]})}function tn({mode:e,onClose:t,client:n}){let{t:r}=I(),{toast:i}=U(),a=te(),s=e!==null,c=de(n.kind,s||!!n.install?.busy),l=L(),u=ne(),[d,f]=(0,X.useState)(!1),p=(0,X.useRef)(null),g=(0,X.useRef)(void 0),_=Y(n.kind,n.name),v=n.install,y=e===`log`?null:e,S=y===`install`?v?.installCommand:y===`update`?v?.updateCommand:y===`uninstall`?v?.uninstallCommand:null,C=y===`uninstall`,w=c.data,T=y!==null&&!d&&w?.state!==`running`,E=!!v?.needsAdmin,ee=!!v?.adminAvailable,re=w?.state===`failed`&&w.hint===`permission-denied`&&!w.elevated&ⅇ(0,X.useEffect)(()=>{s&&f(!1)},[s,e]),(0,X.useEffect)(()=>{let e=w?.state;g.current===`running`&&e&&e!==`running`&&(a.invalidateQueries({queryKey:o.clients}),e===`succeeded`&&w.hint?i(r(`clients.notEffectiveToast`,{name:_})):e===`succeeded`&&i(r(Gt[w.action],{name:_}),`success`)),g.current=e},[w?.state,w?.action,w?.hint,_,a,r,i]),(0,X.useEffect)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[w?.log.length]);let ie=(e,t)=>l.mutate({kind:n.kind,action:e,elevated:t},{onSuccess:()=>f(!0),onError:e=>i(V(e),`error`)}),D=async e=>{await B.copy(e)&&i(r(`common.copied`))},O=r(Wt[y??w?.action??`install`],{name:_}),ae={running:`info`,succeeded:`success`,failed:`danger`,cancelled:`warning`},A=`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`,oe=v?.adminFixCommand?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-secondary)]`,children:r(`clients.admin.fixTip`)}),(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`pre`,{className:k(A,`min-w-0 flex-1`),children:v.adminFixCommand}),(0,Z.jsx)(h,{size:`sm`,icon:(0,Z.jsx)(ve,{className:`size-3`}),"aria-label":r(`common.copy`),onClick:()=>void D(v.adminFixCommand)})]})]}):null;return(0,Z.jsx)(z,{open:s,onOpenChange:e=>!e&&t(),width:620,title:O,description:T?r(C?`clients.uninstallRunDetail`:`clients.installRunDetail`):void 0,footer:T?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{onClick:t,children:r(`common.cancel`)}),E&&!ee?(0,Z.jsx)(h,{variant:`primary`,icon:(0,Z.jsx)(ve,{className:`size-3.5`}),disabled:!S,onClick:()=>void D(`sudo ${S}`),children:r(`clients.admin.copyCommand`)}):(0,Z.jsx)(h,{variant:C?`destructive`:`primary`,icon:E?(0,Z.jsx)(J,{className:`size-3.5`}):void 0,disabled:!S,loading:l.isPending,onClick:()=>y&&ie(y,E),children:r(E?`clients.admin.start`:C?`clients.uninstall`:`clients.installStart`)})]}):w?.state===`running`?(0,Z.jsxs)(Z.Fragment,{children:[!w.elevated&&(0,Z.jsx)(h,{variant:`destructive`,loading:u.isPending,onClick:()=>u.mutate(n.kind,{onError:e=>i(V(e),`error`)}),children:r(`clients.installStop`)}),(0,Z.jsx)(h,{onClick:t,children:r(`common.close`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{onClick:t,children:r(`common.done`)}),re&&(0,Z.jsx)(h,{variant:`primary`,icon:(0,Z.jsx)(J,{className:`size-3.5`}),loading:l.isPending,onClick:()=>ie(w.action,!0),children:r(`clients.admin.retry`)})]}),children:T?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[C&&n.enabled&&(0,Z.jsx)(b,{tone:`warning`,title:r(`clients.uninstallRestoreTitle`),children:r(`clients.uninstallRestoreDetail`,{name:_})}),E&&(0,Z.jsx)(b,{tone:`warning`,title:r(`clients.admin.title`),children:r(ee?`clients.admin.prompt`:`clients.admin.manual`)}),S?(0,Z.jsx)(`pre`,{className:A,children:E?`sudo ${S}`:S}):(0,Z.jsx)(b,{tone:`warning`,title:r(`clients.installUnavailable`)}),C?(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`clients.uninstallKeepsData`)}):v?.method===`npm`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:r(`clients.installNpmNote`)}),E&&oe]}):w?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(b,{tone:w.state===`succeeded`&&w.hint?`warning`:ae[w.state],title:r(w.state===`succeeded`&&w.hint?`clients.job.notEffective`:`clients.job.${w.state}`),children:w.state===`running`&&w.elevated?r(`clients.admin.running`):w.hint?r(`clients.hint.${w.hint}`)+(re?r(`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:w.log.join(`
|
|
9
|
+
`)}),w.hint===`permission-denied`&&oe]}):c.isLoading?(0,Z.jsx)(x,{lines:4}):(0,Z.jsx)(m,{icon:(0,Z.jsx)(q,{className:`size-6`}),title:r(`clients.noInstallLog`)})})}function nn({open:e,onOpenChange:t,client:n,model:r,extras:i,tokenId:a}){let{t:o}=I(),{toast:s}=U(),c=_(),u=l(),d=Y(n.kind,n.name),f=i?{providerId:n.providerId,model:r,extras:i,tokenId:a}:{providerId:n.providerId,model:r,tokenId:a};(0,X.useEffect)(()=>{e&&c.mutate({kind:n.kind,req:f})},[e]);let p=()=>u.mutate({kind:n.kind,req:f},{onSuccess:e=>{t(!1),s(e.requiresRestart?o(`clients.enabledRestart`,{name:d}):o(`clients.enabledToast`,{name:d}),`success`)},onError:e=>{let t=Ct(e,o);s(t?`${t.title} · ${t.hint}`:V(e),`error`)}}),m=c.isError?Ct(c.error,o):null;return(0,Z.jsxs)(z,{open:e,onOpenChange:t,width:620,title:o(`clients.enableTitle`,{name:d}),description:o(`clients.enableDetail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{onClick:()=>t(!1),children:o(`common.cancel`)}),(0,Z.jsx)(h,{variant:`primary`,disabled:!c.data,loading:u.isPending,onClick:p,children:n.enabled?o(`common.apply`):o(`clients.enable`)})]}),children:[c.isPending&&(0,Z.jsx)(x,{lines:4}),m&&(0,Z.jsx)(b,{tone:`danger`,title:m.title,children:m.hint}),c.isError&&!m&&(0,Z.jsx)(b,{tone:`danger`,title:o(`common.error`),children:V(c.error)}),c.data&&(0,Z.jsx)(rn,{preview:c.data})]})}function rn({preview:e}){let{t}=I();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.warnings.map((e,t)=>(0,Z.jsx)(b,{tone:`warning`,title:e},t)),e.changes.length===0&&(0,Z.jsx)(b,{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)(an,{diff:e.unifiedDiff})]},e.file))]})}function an({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(`
|
|
10
|
+
`).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 on({open:e,onOpenChange:t,client:n}){let{t:r,locale:i}=I(),{toast:o,confirm:c}=U(),l=T(n.kind,e),u=a();return(0,Z.jsxs)(z,{open:e,onOpenChange:t,width:520,title:r(`clients.backups`),description:r(`clients.backupsDetail`),footer:(0,Z.jsx)(h,{onClick:()=>t(!1),children:r(`common.done`)}),children:[l.isLoading&&(0,Z.jsx)(x,{lines:3}),l.isError&&(0,Z.jsx)(b,{tone:`danger`,title:r(`common.error`),children:V(l.error)}),l.data?.length===0&&(0,Z.jsx)(m,{icon:(0,Z.jsx)(ge,{className:`size-6`}),title:r(`clients.noBackups`)}),(0,Z.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:l.data?.map(e=>(0,Z.jsx)(R,{label:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[le(e.createdAt,i),e.firstWrite&&(0,Z.jsx)(s,{tone:`accent`,children:r(`clients.firstWrite`)})]}),detail:e.files.join(`, `),children:(0,Z.jsx)(h,{size:`sm`,icon:(0,Z.jsx)(De,{className:`size-3`}),loading:u.isPending&&u.variables?.id===e.id,onClick:async()=>{await c({title:r(`clients.restoreConfirm`),detail:e.files.join(`
|
|
11
|
+
`),destructive:!0,confirmLabel:r(`clients.restore`)})&&u.mutate({kind:n.kind,id:e.id},{onSuccess:()=>o(r(`clients.restored`),`success`),onError:e=>o(V(e),`error`)})},children:r(`clients.restore`)})},e.id))})]})}export{Mt as ClientsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{D as n,H as r,O as i,Qs as a,S as o,St as s,bt as c,c as l,d as u,m as d,o as f,r as p,u as m,w as h,xt as g,yt as _}from"./format-CmXxTS5M.js";import{M as v,N as y,b}from"./index-BW8keTkg.js";var x=e(t(),1),S=a(),C=`astra.keyLookup`;function w(){try{return sessionStorage.getItem(C)??``}catch{return``}}function T(e){try{e?sessionStorage.setItem(C,e):sessionStorage.removeItem(C)}catch{}}function E(){let{t:e}=h(),[t,n]=(0,x.useState)(``),[r,a]=(0,x.useState)(null),[s,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),m=(0,x.useCallback)(async t=>{let n=t.trim();if(n){p(!0),d(null);try{a(await c(n)),l(n),T(n)}catch(t){a(null),T(null),d(t instanceof _&&t.status===401?e(`key.invalid`):e(`key.error`,{error:t.message}))}finally{p(!1)}}},[e]);return(0,x.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`key`);e&&window.history.replaceState(null,``,window.location.pathname);let t=e??w();t&&(n(t),m(t))},[]),(0,S.jsx)(`div`,{className:`wallpaper flex min-h-full justify-center overflow-y-auto p-4 sm:items-start sm:py-12`,children:(0,S.jsxs)(`div`,{className:`flex w-full max-w-[720px] flex-col gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(y,{className:`size-10 rounded-[12px]`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-[17px] font-medium`,children:e(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:e(`key.subtitle`)})]})]}),!r&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m(t)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(v,{label:e(`key.title`),placeholder:e(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:t,"aria-invalid":u?!0:void 0,onChange:e=>n(e.target.value)}),u&&(0,S.jsx)(o,{tone:`danger`,title:u}),(0,S.jsx)(i,{type:`submit`,variant:`primary`,loading:f,disabled:!t.trim(),children:e(`key.submit`)})]}),r&&(0,S.jsx)(D,{info:r,apiKey:s,onForget:()=>{T(null),a(null),n(``)}})]})})}function D({info:e,apiKey:t,onForget:a}){let{t:o,locale:s}=h(),[c,l]=(0,x.useState)(`overview`),f=e.allowedClients==null?o(`key.clientsAny`):e.allowedClients.length===0?o(`key.directOnly`):e.allowedClients.map(e=>b[e]?.name??e).join(`, `),m=[[o(`key.today`),e.usage.today],[o(`key.week`),e.usage.week],[o(`key.month`),e.usage.month],[o(`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)(n,{tone:`orange`,children:o(`key.disabled`)}),(0,S.jsx)(i,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:a,children:o(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[o(`key.clients`),`: `,f,` · `,o(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(r,{ariaLabel:o(`key.title`),value:c,onChange:l,items:[{value:`overview`,label:o(`key.tab.overview`)},{value:`stats`,label:o(`key.tab.stats`)},{value:`requests`,label:o(`key.tab.requests`)}]})]}),c===`stats`&&(0,S.jsx)(k,{apiKey:t}),c===`requests`&&(0,S.jsx)(M,{apiKey:t}),c===`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:o(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:o(`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`?d(t):u(t,!0),n=Math.max(0,Math.min(100,Math.round(e.usedPercent))),r=n>=90?`var(--danger)`:n>=70?`var(--warning)`:`var(--accent)`,i=`${o(`tokens.period.${e.period}`)} · ${o(`tokens.metric.${e.metric}`)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[12px]`,children:[(0,S.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:i}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":i,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${n}%`,background:r}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?o(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?o(`key.resets`,{time:p(e.resetsAt,s)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:o(`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:o(`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:o(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:o(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:o(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:m.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:d(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:o(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":o(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${d(e.costUsd)} · ${u(e.requests)} ${o(`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}=h(),[i,a]=(0,x.useState)(`7d`),[c,p]=(0,x.useState)(null),[m,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return g(null),s(e,i).then(e=>n&&p(e),e=>n&&g(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,i,t]);let _=c?.summary,v=Math.max(...(c?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(r,{ariaLabel:t(`overview.range`),value:i,onChange:a,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),m&&(0,S.jsx)(o,{tone:`danger`,title:m}),!c||!_?!m&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:`…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsx)(A,{label:t(`key.stats.requests`),value:u(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?l(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:d(_.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:f(_.avgTtftMs)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.trend`)}),(0,S.jsx)(`div`,{className:`flex h-20 items-end gap-[2px]`,role:`list`,"aria-label":t(`key.stats.trend`),children:c.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${u(e.requests)} ${t(`key.requests`)} · ${d(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${v>0?Math.max(2,e.requests/v*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:t(`key.stats.byModel`),rows:c.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:c.clients.map(e=>({name:e.client?b[e.client]?.name??e.client:t(`key.stats.direct`),...e}))}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.errors`)}),c.errors.length===0?(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`key.stats.noErrors`)}):(0,S.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:c.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(n,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,u(e.count)]})},e.category))})]}),c.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:c.retentionDays})})]})]})}function A({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`div`,{className:`num truncate text-[17px] font-semibold`,children:t})]})}function j({title:e,rows:t}){let{t:n}=h();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:u(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?l(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:d(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:a}=h(),[s,c]=(0,x.useState)(`all`),[l,_]=(0,x.useState)([]),[v,y]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),D=(0,x.useCallback)(async n=>{w(!0),E(null);try{let t=await g(e,{before:n,status:s===`failed`?N:void 0});_(e=>n?[...e,...t.items]:t.items),y(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,s,t]);return(0,x.useEffect)(()=>{D(null)},[D]),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(r,{ariaLabel:t(`key.requests.status`),value:s,onChange:c,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(o,{tone:`danger`,title:T}),l.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),l.length>0&&(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.time`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.model`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.client`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.status`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.latency`)})]})}),(0,S.jsx)(`tbody`,{children:l.map(e=>(0,S.jsxs)(`tr`,{className:`border-t border-[var(--border-subtle)]`,children:[(0,S.jsx)(`td`,{className:`py-1.5 whitespace-nowrap text-[var(--text-secondary)]`,title:p(e.time,a),children:m(e.time,a)}),(0,S.jsx)(`td`,{className:`max-w-[200px] truncate py-1.5 font-mono`,title:e.model??``,children:e.model??`—`}),(0,S.jsx)(`td`,{className:`py-1.5 text-[var(--text-secondary)]`,children:e.client?b[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(n,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(n,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[u(e.inputTokens,!0),` / `,u(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:d(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[f(e.ttftMs),` / `,f(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(i,{size:`sm`,loading:C,onClick:()=>void D(v),children:t(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{D as n,G as r,Gt as i,H as a,I as o,Mt as s,N as c,O as l,P as u,Pn as d,Qs as f,R as p,S as m,Si as h,U as g,W as _,hr as v,ta as y,w as b,z as x,zi as S}from"./format-CmXxTS5M.js";import{H as C,U as w,V as T,W as E}from"./TrayTitleSource-DN10ruw2.js";import{t as D}from"./folder-open-z1RXMZa1.js";import{t as O}from"./pencil-CpF9MxGZ.js";import{t as k}from"./plus-c3HzV6VX.js";import{t as A}from"./refresh-cw-CoLAai2c.js";import{t as j}from"./trash-BHBJn5GS.js";import{v as M}from"./index-BW8keTkg.js";import{t as N}from"./checkbox-CZ-rG7I2.js";import{t as P}from"./clientNames-Bskc9G1M.js";var F=e(t(),1),I=f();function L(){let{t:e}=b(),{toast:t,confirm:r}=E(),i=v(),a=s(),u=h(),[d,f]=(0,F.useState)(``),p=()=>a.mutate({path:d.trim()},{onSuccess:n=>{f(``),t(e(`library.projects.added`,{name:n.name}),`success`)},onError:e=>t(w(e),`error`)}),_=async(n,i)=>{await r({title:e(`library.projects.forget.title`,{name:i}),detail:e(`library.projects.forget.detail`),confirmLabel:e(`library.projects.forget`)})&&u.mutate(n,{onError:e=>t(w(e),`error`)})};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`mb-3 text-[12px] text-[var(--text-secondary)]`,children:e(`library.projects.hint`)}),(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,I.jsx)(o,{mono:!0,className:`flex-1`,value:d,placeholder:`/Users/me/code/app`,onChange:e=>f(e.target.value),"aria-label":e(`library.projects.path`)}),(0,I.jsx)(l,{variant:`primary`,icon:(0,I.jsx)(k,{className:`size-4`}),disabled:d.trim()===``,loading:a.isPending,onClick:p,children:e(`library.projects.add`)})]}),i.isError&&(0,I.jsx)(m,{tone:`danger`,title:w(i.error)}),i.isLoading&&(0,I.jsx)(g,{lines:2}),i.data&&i.data.length===0&&(0,I.jsx)(c,{icon:(0,I.jsx)(D,{className:`size-6`}),title:e(`library.projects.empty`)}),i.data&&i.data.length>0&&(0,I.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:i.data.map(t=>(0,I.jsx)(x,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:t.name}),!t.exists&&(0,I.jsx)(n,{tone:`orange`,children:e(`library.state.project-missing`)})]}),detail:(0,I.jsx)(`span`,{className:`font-mono text-[11px]`,children:t.path}),children:(0,I.jsx)(l,{size:`sm`,icon:(0,I.jsx)(j,{className:`size-3.5`}),"aria-label":e(`library.projects.forget`),onClick:()=>void _(t.path,t.name)})},t.path))})]})}var R={instructions:`instruction`,agents:`agent`,commands:`command`,hooks:`hook`,env:`env`},z=[`turn-end`,`after-tool`,`before-tool`,`prompt`,`session-start`],B={applied:`green`,drifted:`orange`,missing:`orange`,conflict:`red`,"project-missing":`orange`,unsupported:`neutral`,pending:`neutral`,off:`neutral`},V=e=>e.split(/[\\/]/).filter(Boolean).pop()??e;function H({segment:e}){let{t}=b(),{toast:n,confirm:r}=E(),a=R[e],o=S(e),s=i(e),u=d(e),[f,p]=(0,F.useState)(null),h=o.data,_=async(e,r)=>{try{await e(),r&&n(t(r),`success`)}catch(e){n(w(e),`error`)}},v=async(e,n)=>{(!n||await r({title:t(`library.confirm.force.title`,{name:e.name}),detail:t(`library.confirm.force.detail`),confirmLabel:t(`library.rewriteForce`),destructive:!0}))&&await _(()=>s.mutateAsync({id:e.id,force:n}),`library.toast.applied`)},y=async e=>{await r({title:t(`library.confirm.delete.title`,{name:e.name}),detail:t(`library.confirm.delete.detail`),confirmLabel:t(`common.delete`),destructive:!0})&&await _(async()=>{try{await u.mutateAsync({id:e.id})}catch(n){if(!await r({title:t(`library.confirm.deleteForce.title`,{name:e.name}),detail:`${w(n)}\n\n${t(`library.confirm.deleteForce.detail`)}`,confirmLabel:t(`common.delete`),destructive:!0}))return;await u.mutateAsync({id:e.id,force:!0})}},`library.toast.deleted`)};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-3`,children:[(0,I.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:t(`library.hint.${a}`)}),(0,I.jsx)(l,{variant:`primary`,icon:(0,I.jsx)(k,{className:`size-4`}),onClick:()=>p(`new`),disabled:h?.canWrite===!1,children:t(`library.add`)})]}),o.isError&&(0,I.jsx)(m,{tone:`danger`,title:`${t(`library.error.load`)}: ${w(o.error)}`}),o.isLoading&&(0,I.jsx)(g,{lines:3}),h&&h.canWrite===!1&&(0,I.jsx)(m,{tone:`info`,title:t(`library.localOnly`)}),h&&h.items.length===0&&(0,I.jsx)(c,{title:t(`library.empty.title`),detail:t(`library.empty.${a}`),action:h.canWrite?(0,I.jsx)(l,{variant:`primary`,onClick:()=>p(`new`),children:t(`library.add`)}):void 0}),h&&h.items.length>0&&(0,I.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:h.items.map(e=>(0,I.jsx)(U,{item:e,canWrite:h.canWrite,onEdit:()=>p(e),onDelete:()=>void y(e),onRewrite:t=>void v(e,t)},e.id))}),h&&(0,I.jsx)(G,{segment:e,library:h,item:f,onClose:()=>p(null)})]})}function U({item:e,canWrite:t,onEdit:r,onDelete:i,onRewrite:a}){let{t:o}=b(),s=e.targets.some(e=>e.state===`drifted`||e.state===`conflict`||e.state===`missing`),c=e.targets.some(e=>e.state===`drifted`||e.state===`conflict`),u=(e.kind===`hook`?`${e.event??``}${e.matcher?` · ${e.matcher}`:``} — `:``)+(e.description||e.body).split(`
|
|
2
|
+
`)[0];return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(x,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:e.name}),!e.enabled&&(0,I.jsx)(n,{children:o(`library.state.off`)})]}),detail:(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:u,children:u}),children:[s&&t&&(0,I.jsx)(l,{size:`sm`,icon:(0,I.jsx)(A,{className:`size-3.5`}),onClick:()=>a(!1),children:o(`library.rewrite`)}),c&&t&&(0,I.jsx)(l,{size:`sm`,onClick:()=>a(!0),children:o(`library.rewriteForce`)}),(0,I.jsx)(l,{size:`sm`,icon:(0,I.jsx)(O,{className:`size-3.5`}),"aria-label":o(`common.edit`),onClick:r,disabled:!t}),(0,I.jsx)(l,{size:`sm`,icon:(0,I.jsx)(j,{className:`size-3.5`}),"aria-label":o(`common.delete`),onClick:i,disabled:!t})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 px-4 pb-3`,children:[e.targets.map(t=>(0,I.jsx)(W,{target:t,error:e.lastError?.[t.project?`${t.client}@${t.project}`:t.client]},t.client+t.project)),e.targets.length===0&&(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:o(`library.noTargets`)})]})]})}function W({target:e,error:t}){let{t:r}=b(),i=t??e.message??void 0;return(0,I.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px]`,title:e.path??void 0,children:[P(e.client),e.project&&(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,title:e.project,children:V(e.project)}),(0,I.jsx)(n,{tone:B[e.state],children:r(`library.state.${e.state}`)})]}),i&&(0,I.jsx)(`span`,{className:`max-w-md whitespace-normal text-[11px] text-[var(--danger)]`,children:i})]})}function G({segment:e,library:t,item:i,onClose:a}){let{t:s}=b(),{toast:c}=E(),d=y(e),f=R[e],m=i&&i!==`new`?i:null,[h,g]=(0,F.useState)(``),[v,S]=(0,F.useState)(``),[D,O]=(0,F.useState)(``),[k,A]=(0,F.useState)(`turn-end`),[j,M]=(0,F.useState)(``),[L,B]=(0,F.useState)(null),[V,H]=(0,F.useState)(``),[U,W]=(0,F.useState)(!0),[G,K]=(0,F.useState)([]);(0,F.useEffect)(()=>{if(i===null)return;let e=i===`new`?null:i;g(e?.name??``),S(e?.description??``),O(e?.body??``),A(e?.event??`turn-end`),M(e?.matcher??``),B(e&&e.timeout>0?e.timeout:null),H(e?.model??``),W(e?.enabled??!0),K(e?e.targets.map(e=>({client:e.client,project:e.project})):[])},[i]);let q=(e,t)=>G.some(n=>n.client===e&&n.project===t),J=(e,t,n)=>K(r=>n?[...r.filter(n=>n.client!==e||n.project!==t),{client:e,project:t}]:r.filter(n=>n.client!==e||n.project!==t)),Y=f===`agent`,X=h.trim()!==``&&(f===`env`||D.trim()!==``)&&(!Y||v.trim()!==``),Z=k.includes(`:`),Q=f===`hook`&&(Z||k!==`turn-end`&&k!==`prompt`);return(0,I.jsx)(C,{open:i!==null,onOpenChange:e=>!e&&a(),width:580,title:m?s(`library.editTitle`,{name:m.name}):s(`library.addTitle.${f}`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(l,{onClick:a,children:s(`common.cancel`)}),(0,I.jsx)(l,{variant:`primary`,disabled:!X,loading:d.isPending,onClick:()=>{let e={name:h.trim(),body:D,enabled:U,targets:G};(f===`agent`||f===`command`||f===`hook`)&&(e.description=v.trim()),f===`agent`&&V.trim()!==``&&(e.model=V.trim()),f===`hook`&&(e.event=k,e.matcher=Q?j.trim():``,e.timeout=L??0),d.mutate({id:m?.id,body:e},{onSuccess:e=>{a(),e.targets.filter(e=>e.state===`conflict`||e.state===`drifted`).length>0||e.lastError&&Object.keys(e.lastError).length>0?c(s(`library.toast.savedWithProblems`),`error`):c(s(`library.toast.saved`,{name:e.name}),`success`)},onError:e=>c(w(e),`error`)})},children:s(`common.save`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(u,{label:s(`library.field.name`),hint:s(`library.nameHint.${f}`),children:(0,I.jsx)(o,{mono:!0,value:h,maxLength:64,onChange:e=>g(e.target.value)})}),(f===`agent`||f===`command`||f===`hook`)&&(0,I.jsx)(u,{label:s(`library.field.description`),children:(0,I.jsx)(o,{value:v,maxLength:200,onChange:e=>S(e.target.value)})}),f===`hook`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(u,{label:s(`library.field.event`),hint:s(`library.field.eventHint`),children:[(0,I.jsx)(T,{value:Z?`__own__`:k,onChange:e=>A(e===`__own__`?`claude-code:PermissionRequest`:e),options:[...z.map(e=>({value:e,label:s(`library.event.${e}`)})),{value:`__own__`,label:s(`library.event.own`)}]}),Z&&(0,I.jsx)(o,{mono:!0,className:`mt-2`,value:k,onChange:e=>A(e.target.value),placeholder:`claude-code:PermissionRequest`})]}),Q&&(0,I.jsx)(u,{label:s(`library.field.matcher`),hint:s(Z?`library.field.matcherOwn`:k===`session-start`?`library.field.matcherStarts`:`library.field.matcherTools`),children:k===`session-start`||Z?(0,I.jsx)(o,{mono:!0,value:j,placeholder:`startup|resume`,onChange:e=>M(e.target.value)}):(0,I.jsx)(T,{value:j,onChange:M,options:[{value:``,label:s(`library.matcher.all`)},{value:`shell`,label:s(`library.matcher.shell`)},{value:`edit`,label:s(`library.matcher.edit`)}]})}),(0,I.jsx)(u,{label:s(`library.field.timeout`),children:(0,I.jsx)(p,{value:L,onChange:B,min:0,step:1})})]}),(0,I.jsx)(u,{label:s(`library.field.body.${f}`),hint:f===`command`?s(`library.field.commandArgsHint`):void 0,children:f===`hook`||f===`env`?(0,I.jsx)(o,{mono:!0,value:D,onChange:e=>O(e.target.value)}):(0,I.jsx)(r,{mono:!0,rows:f===`instruction`?8:6,value:D,onChange:e=>O(e.target.value)})}),f===`agent`&&(0,I.jsx)(u,{label:s(`library.field.model`),hint:s(`library.field.modelHint`),children:(0,I.jsx)(o,{mono:!0,value:V,onChange:e=>H(e.target.value),placeholder:`gpt-5`})}),(0,I.jsx)(u,{label:s(`library.targets`),hint:s(t.projects.length>0?`library.targetsHint`:`library.targetsHintNoProjects`),children:(0,I.jsx)(`div`,{className:`grid gap-1`,children:t.clients.map(e=>(0,I.jsx)(x,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[P(e.kind),!e.detected&&(0,I.jsx)(n,{children:s(`library.undetected`)})]}),detail:e.path?(0,I.jsx)(`span`,{className:`font-mono text-[11px]`,title:e.path,children:e.path}):void 0,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-1`,children:[(0,I.jsx)(N,{label:s(`library.userWide`),checked:q(e.kind,``),onCheckedChange:t=>J(e.kind,``,t===!0)}),e.project&&t.projects.map(t=>(0,I.jsx)(N,{label:t.name,checked:q(e.kind,t.path),disabled:!t.exists,onCheckedChange:n=>J(e.kind,t.path,n===!0)},t.path))]})},e.kind))})}),(0,I.jsx)(x,{label:s(`library.enabled`),children:(0,I.jsx)(_,{checked:U,label:s(`library.enabled`),onChange:W})})]})})}function K(){let{t:e}=b(),[t,n]=(0,F.useState)(`instructions`);return(0,I.jsxs)(M,{title:e(`nav.library`),subtitle:e(`library.subtitle`),children:[(0,I.jsx)(`div`,{className:`mb-3`,children:(0,I.jsx)(a,{ariaLabel:e(`nav.library`),value:t,onChange:n,items:[{value:`instructions`,label:e(`library.tab.instruction`)},{value:`agents`,label:e(`library.tab.agent`)},{value:`commands`,label:e(`library.tab.command`)},{value:`hooks`,label:e(`library.tab.hook`)},{value:`env`,label:e(`library.tab.env`)},{value:`projects`,label:e(`library.tab.projects`)}]})}),t===`projects`?(0,I.jsx)(L,{}):(0,I.jsx)(H,{segment:t},t)]})}export{K as LibraryPage};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{Ba as n,D as r,En as i,Er as a,F as o,G as s,H as c,Ht as l,I as u,N as d,O as f,P as p,Qn as m,Qs as h,R as g,S as _,Ta as v,Tn as y,Tr as b,U as x,Ut as S,W as C,Za as w,br as T,cn as E,do as D,fo as O,hn as k,hr as A,mn as j,o as M,r as N,sr as P,uo as F,w as I,wr as L,xi as R,yr as z,z as B}from"./format-CmXxTS5M.js";import{B as ee,H as V,R as te,U as H,V as U,W}from"./TrayTitleSource-DN10ruw2.js";import{t as G}from"./copy-48gwhhDO.js";import{t as K}from"./ellipsis-CidyZaW2.js";import{t as ne}from"./key-round-m9ps8ZDi.js";import{t as q}from"./pencil-CpF9MxGZ.js";import{t as J}from"./plug-DKn7uRWT.js";import{t as Y}from"./plus-c3HzV6VX.js";import{t as re}from"./shield-check-CD30JqBi.js";import{t as ie}from"./terminal-B-mEYDi0.js";import{t as X}from"./trash-BHBJn5GS.js";import{t as ae}from"./zap-BiWUNaKt.js";import{B as oe,W as se,v as ce}from"./index-BW8keTkg.js";var Z=e(t(),1),Q=h(),le=[{kind:`claude-code`,name:`Claude Code`},{kind:`codex`,name:`Codex`}],ue={missing:`neutral`,applied:`green`,drifted:`orange`,conflict:`red`};function de(){let{t:e}=I(),t=E(),n=w(),r=(n.data??[]).filter(e=>e.enabled&&(e.mcpServers?.length??0)>0);return(0,Q.jsxs)(o,{title:e(`mcp.clients.title`),footer:e(`mcp.clients.stdio`),children:[(0,Q.jsx)(`p`,{className:`px-4 pt-3 text-[12px] text-[var(--text-muted)]`,children:e(`mcp.clients.hint`)}),t.isLoading&&(0,Q.jsx)(x,{lines:2}),t.data&&r.length===0&&n.data&&(0,Q.jsx)(`p`,{className:`px-4 py-2 text-[12px] text-[var(--text-muted)]`,children:e(`mcp.clients.noToken`)}),t.data&&le.map(e=>{let n=t.data.find(t=>t.kind===e.kind);return n?(0,Q.jsx)(fe,{name:e.name,entry:n,tokens:r.map(e=>({value:e.id,label:e.name}))},e.kind):null})]})}function fe({name:e,entry:t,tokens:n}){let{t:i}=I(),{toast:a,confirm:o}=W(),s=l(),c=R(),[u,d]=(0,Z.useState)(null),p=u??(n.some(e=>e.value===t.tokenId)?t.tokenId??null:n[0]?.value??null),m=s.isPending||c.isPending,h=t.state===`applied`||t.state===`drifted`,g=n=>{p&&s.mutate({kind:t.kind,tokenId:p,force:n},{onSuccess:()=>a(i(`mcp.clients.applied`,{client:e}),`success`),onError:e=>a(H(e),`error`)})},v=async n=>{(!n||await o({title:i(`mcp.clients.forceRemove`),detail:t.file,destructive:!0,confirmLabel:i(`mcp.clients.forceRemove`)}))&&c.mutate({kind:t.kind,force:n},{onSuccess:()=>a(i(`mcp.clients.removed`,{client:e}),`success`),onError:e=>a(H(e),`error`)})},y=(0,Q.jsxs)(`span`,{className:`block whitespace-normal`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:t.file,children:t.file}),t.state===`applied`&&t.tokenName&&(0,Q.jsx)(`span`,{className:`block`,children:i(`mcp.clients.usesToken`,{name:t.tokenName})}),t.error&&(0,Q.jsx)(`span`,{className:`block text-[var(--danger)]`,children:i(`mcp.clients.unreadable`,{error:t.error})})]});return(0,Q.jsxs)(`div`,{className:`border-t border-[var(--border)] first:border-t-0`,children:[(0,Q.jsxs)(B,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(0,Q.jsx)(r,{tone:ue[t.state],children:i(`mcp.clients.state.${t.state}`)})]}),detail:y,children:[n.length>0&&(0,Q.jsx)(U,{className:`w-44`,ariaLabel:`${e} ${i(`mcp.clients.token`)}`,placeholder:i(`mcp.clients.pickToken`),value:p,onChange:d,options:n,disabled:m}),(0,Q.jsx)(f,{variant:`primary`,disabled:m||!p||t.state===`conflict`,onClick:()=>g(!1),children:i(h?`mcp.clients.replace`:`mcp.clients.apply`)}),h&&(0,Q.jsx)(f,{disabled:m,onClick:()=>void v(t.state===`drifted`),children:t.state===`drifted`?i(`mcp.clients.forceRemove`):i(`mcp.clients.remove`)})]}),!t.gatewayEnabled&&t.state!==`missing`&&(0,Q.jsx)(_,{tone:`warning`,className:`mx-4 mb-3`,title:i(`mcp.clients.gatewayOff`)}),!t.gatewayEnabled&&t.state===`missing`&&(0,Q.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:i(`mcp.clients.gatewayOff`)}),t.state===`conflict`&&!t.error&&(0,Q.jsx)(_,{tone:`warning`,className:`mx-4 mb-3`,title:i(`mcp.clients.conflict`)}),t.state===`drifted`&&(0,Q.jsxs)(`div`,{className:`mx-4 mb-3 flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:i(`mcp.clients.drifted`)}),(0,Q.jsx)(f,{size:`sm`,disabled:m||!p,onClick:()=>g(!0),children:i(`mcp.clients.force`)})]})]})}var pe=[{kind:`claude-code`,name:`Claude Code`},{kind:`codex`,name:`Codex`},{kind:`gemini-cli`,name:`Gemini CLI`},{kind:`qwen-code`,name:`Qwen Code`},{kind:`opencode`,name:`OpenCode`},{kind:`droid`,name:`Droid`},{kind:`crush`,name:`Crush`},{kind:`copilot-cli`,name:`Copilot CLI`}],me=[`claude-code`,`codex`,`gemini-cli`,`qwen-code`,`opencode`,`droid`],he=[`claude-code`,`codex`,`gemini-cli`,`qwen-code`,`opencode`],ge={"project-missing":`orange`,missing:`neutral`,applied:`green`,drifted:`orange`,conflict:`red`},$=e=>pe.find(t=>t.kind===e)?.name??e,_e=e=>e.split(`
|
|
2
|
+
`).map(e=>e.replace(/\r$/,``)).filter(e=>e.trim()!==``);function ve(e){let t={};for(let n of e.split(`
|
|
3
|
+
`)){let e=n.replace(/\r$/,``);if(e.trim()===``)continue;let r=e.indexOf(`=`);if(r<=0)return null;t[e.slice(0,r).trim()]=e.slice(r+1)}return t}function ye(e){let t={};for(let n of e.split(`
|
|
4
|
+
`)){let e=n.replace(/\r$/,``);if(e.trim()===``)continue;let r=e.indexOf(`:`);if(r<=0)return null;t[e.slice(0,r).trim()]=e.slice(r+1).trim()}return t}function be(){let{t:e}=I(),{toast:t,confirm:n}=W(),r=T(),i=S(),a=y(),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),u=async r=>{await n({title:e(`mcp.local.deleteTitle`,{name:r.name}),detail:e(`mcp.local.deleteDetail`),destructive:!0,confirmLabel:e(`common.delete`)})&&a.mutate({id:r.id},{onSuccess:()=>t(e(`mcp.local.deleted`,{name:r.name}),`success`),onError:e=>t(H(e),`error`)})},p=(n,r)=>i.mutate({id:n.id,force:r},{onSuccess:()=>t(e(`mcp.local.applied`,{name:n.name}),`success`),onError:e=>t(H(e),`error`)});return(0,Q.jsxs)(`section`,{className:`mt-6`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 px-1`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-[13px] font-semibold`,children:e(`mcp.local.title`)}),(0,Q.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:e(`mcp.local.hint`)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(f,{icon:(0,Q.jsx)(oe,{className:`size-4`}),onClick:()=>l(!0),children:e(`mcp.local.import`)}),(0,Q.jsx)(f,{variant:`primary`,icon:(0,Q.jsx)(Y,{className:`size-4`}),onClick:()=>s(`new`),children:e(`mcp.local.add`)})]})]}),r.isLoading?(0,Q.jsx)(x,{}):!r.data||r.data.length===0?(0,Q.jsx)(d,{icon:(0,Q.jsx)(ie,{className:`size-6`}),title:e(`mcp.local.emptyTitle`),detail:e(`mcp.local.emptyDetail`)}):(0,Q.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:r.data.map(e=>(0,Q.jsx)(xe,{server:e,busy:i.isPending||a.isPending,onEdit:()=>s(e),onDelete:()=>void u(e),onRewrite:t=>p(e,t)},e.id))}),(0,Q.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:e(`mcp.local.footer`)}),(0,Q.jsx)(Ce,{server:o,onClose:()=>s(null)}),(0,Q.jsx)(we,{open:c,onClose:()=>l(!1)})]})}function xe({server:e,busy:t,onEdit:n,onDelete:i,onRewrite:a}){let{t:o}=I(),s=e.transport===`http`,c=s?e.url:[e.command,...e.args].join(` `),l=s?e.headerNames.length:e.envNames.length,u=e.placements.some(e=>e.wanted&&e.state!==`applied`);return(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsxs)(B,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.name}),!e.enabled&&(0,Q.jsx)(r,{tone:`neutral`,children:o(`mcp.local.off`)})]}),detail:(0,Q.jsxs)(`span`,{className:`block truncate font-mono text-[11px]`,title:c,children:[c,l>0&&(0,Q.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[` · `,o(s?`mcp.local.headerCount`:`mcp.local.envCount`,{count:l})]})]}),children:[u&&(0,Q.jsx)(f,{size:`sm`,disabled:t,onClick:()=>a(!1),children:o(`mcp.local.rewrite`)}),(0,Q.jsx)(f,{size:`sm`,icon:(0,Q.jsx)(q,{className:`size-3.5`}),onClick:n,"aria-label":o(`common.edit`)}),(0,Q.jsx)(f,{size:`sm`,icon:(0,Q.jsx)(X,{className:`size-3.5`}),disabled:t,onClick:i,"aria-label":o(`common.delete`)})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-3 px-4 pb-3`,children:e.placements.map(e=>(0,Q.jsx)(Se,{placement:e,onForce:()=>a(!0)},e.kind+(e.project??``)))})]})}function Se({placement:e,onForce:t}){let{t:n}=I();return!e.wanted&&e.state===`missing`?null:(0,Q.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px]`,title:e.file,children:[$(e.kind),e.project&&(0,Q.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.project.split(/[\\/]/).filter(Boolean).pop()}),(0,Q.jsx)(r,{tone:ge[e.state],children:n(`mcp.local.state.${e.state}`)}),e.state===`drifted`&&e.wanted&&(0,Q.jsx)(f,{size:`sm`,onClick:t,children:n(`mcp.clients.force`)})]}),e.error&&(0,Q.jsx)(`span`,{className:`max-w-md whitespace-normal text-[11px] text-[var(--danger)]`,children:e.error})]})}function Ce({server:e,onClose:t}){let{t:n}=I(),{toast:r}=W(),i=j(),a=F(),o=e&&e!==`new`?e:null,[l,d]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(`stdio`),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)([]),[M,N]=(0,Z.useState)([]),P=A().data??[],[L,R]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;d(t?.name??``),h(t?.command??``),v((t?.args??[]).join(`
|
|
5
|
+
`)),b(``),D(``),S(t?.transport??`stdio`),T(t?.url??``),k(t?.clients??he),N(t?.projects??[]),R(t?.enabled??!0)},[e]);let z=x===`http`,ee=o?.transport===`stdio`&&x===`stdio`&&o.envNames.length>0,te=o?.transport===`http`&&x===`http`&&o.headerNames.length>0,U=ve(y),G=ye(E),K=i.isPending||a.isPending,ne=l.trim()!==``&&(z?w.trim()!==``&&G!==null:m.trim()!==``&&U!==null),q=()=>{let e=z?{name:l.trim(),transport:x,url:w.trim(),enabled:L,clients:O,projects:M}:{name:l.trim(),transport:x,command:m.trim(),args:_e(g),enabled:L,clients:O,projects:M},s=o?.transport===x;z&&G&&(E.trim()!==``||!s)&&(e.headers=G),!z&&U&&(y.trim()!==``||!s)&&(e.env=U);let c={onSuccess:e=>{t(),r(n(o?`mcp.local.saved`:`mcp.local.created`,{name:e.name}),`success`)},onError:e=>r(H(e),`error`)};o?a.mutate({id:o.id,body:e},c):i.mutate(e,c)},J=(e,t)=>k(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e));return(0,Q.jsx)(V,{open:e!==null,onOpenChange:e=>!e&&t(),width:560,title:o?n(`mcp.local.editTitle`,{name:o.name}):n(`mcp.local.addTitle`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(f,{onClick:t,children:n(`common.cancel`)}),(0,Q.jsx)(f,{variant:`primary`,disabled:!ne,loading:K,onClick:q,children:n(`common.save`)})]}),children:(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsx)(p,{label:n(`mcp.local.name`),hint:n(`mcp.local.nameHint`),children:(0,Q.jsx)(u,{mono:!0,value:l,maxLength:32,placeholder:`filesystem`,onChange:e=>d(e.target.value)})}),(0,Q.jsx)(p,{label:n(`mcp.local.transport`),children:(0,Q.jsx)(c,{ariaLabel:n(`mcp.local.transport`),value:x,onChange:S,items:[{value:`stdio`,label:n(`mcp.local.transport.stdio`)},{value:`http`,label:n(`mcp.local.transport.http`)}]})}),z?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(p,{label:n(`mcp.local.url`),hint:n(`mcp.local.urlHint`),children:(0,Q.jsx)(u,{mono:!0,value:w,placeholder:`https://mcp.example.com/mcp`,onChange:e=>T(e.target.value)})}),(0,Q.jsx)(p,{label:n(`mcp.local.headers`),hint:te?n(`mcp.local.headersKept`,{names:o.headerNames.join(`, `)}):n(`mcp.local.headersHint`),children:(0,Q.jsx)(s,{mono:!0,rows:3,value:E,placeholder:`Authorization: Bearer ...`,onChange:e=>D(e.target.value)})}),G===null&&(0,Q.jsx)(_,{tone:`warning`,title:n(`mcp.local.headersInvalid`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(p,{label:n(`mcp.local.command`),children:(0,Q.jsx)(u,{mono:!0,value:m,placeholder:`npx`,onChange:e=>h(e.target.value)})}),(0,Q.jsx)(p,{label:n(`mcp.local.args`),hint:n(`mcp.local.argsHint`),children:(0,Q.jsx)(s,{mono:!0,rows:4,value:g,placeholder:`-y
|
|
6
|
+
@modelcontextprotocol/server-filesystem
|
|
7
|
+
/Users/me/docs`,onChange:e=>v(e.target.value)})}),(0,Q.jsx)(p,{label:n(`mcp.local.env`),hint:ee?n(`mcp.local.envKept`,{names:o.envNames.join(`, `)}):n(`mcp.local.envHint`),children:(0,Q.jsx)(s,{mono:!0,rows:3,value:y,placeholder:`API_KEY=...`,onChange:e=>b(e.target.value)})}),U===null&&(0,Q.jsx)(_,{tone:`warning`,title:n(`mcp.local.envInvalid`)})]}),(0,Q.jsx)(p,{label:n(`mcp.local.clients`),hint:n(`mcp.local.clientsHint`),children:(0,Q.jsx)(`div`,{className:`grid gap-1`,children:pe.map(e=>(0,Q.jsx)(B,{label:e.name,children:(0,Q.jsx)(C,{checked:O.includes(e.kind),label:e.name,onChange:t=>J(e.kind,t)})},e.kind))})}),(P.length>0||M.length>0)&&(0,Q.jsx)(p,{label:n(`mcp.local.projects`),hint:n(`mcp.local.projectsHint`,{clients:me.map($).join(`, `)}),children:(0,Q.jsx)(`div`,{className:`grid gap-1`,children:[...P.map(e=>e.path),...M.filter(e=>!P.some(t=>t.path===e))].map(e=>(0,Q.jsx)(B,{label:(0,Q.jsx)(`span`,{className:`font-mono text-[12px]`,children:e}),children:(0,Q.jsx)(C,{checked:M.includes(e),label:e,onChange:t=>N(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e))})},e))})}),(0,Q.jsx)(B,{label:n(`mcp.local.enabled`),children:(0,Q.jsx)(C,{checked:L,label:n(`mcp.local.enabled`),onChange:R})})]})})}function we({open:e,onClose:t}){let{t:n}=I(),{toast:i}=W(),a=z(e),o=P(),[s,c]=(0,Z.useState)(new Set),l=e=>`${e.kind}\u0000${e.name}`;(0,Z.useEffect)(()=>{e&&c(new Set)},[e]);let u=(a.data??[]).filter(e=>e.importable&&!e.taken),d=(e,t)=>c(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,Q.jsx)(V,{open:e,onOpenChange:e=>!e&&t(),width:560,title:n(`mcp.local.importTitle`),description:n(`mcp.local.importHint`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(f,{onClick:t,children:n(`common.cancel`)}),(0,Q.jsx)(f,{variant:`primary`,disabled:s.size===0,loading:o.isPending,onClick:()=>{let e=u.filter(e=>s.has(l(e))).map(e=>({kind:e.kind,name:e.name}));o.mutate(e,{onSuccess:e=>{let r=n(`mcp.local.importDone`,{count:e.imported.length});i(e.skipped.length>0?`${r} ${n(`mcp.local.importSkipped`,{count:e.skipped.length,reasons:[...new Set(e.skipped.map(e=>e.reason))].join(`; `)})}`:r,e.imported.length>0?`success`:`error`),t()},onError:e=>i(H(e),`error`)})},children:n(`mcp.local.importRun`)})]}),children:a.isLoading?(0,Q.jsx)(x,{}):!a.data||a.data.length===0?(0,Q.jsx)(`p`,{className:`text-[13px] text-[var(--text-muted)]`,children:n(`mcp.local.importEmpty`)}):(0,Q.jsxs)(`div`,{className:`grid gap-1`,children:[a.data.map(e=>{let t=l(e),i=!e.importable||e.taken;return(0,Q.jsx)(B,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.name}),(0,Q.jsx)(r,{tone:`neutral`,children:$(e.kind)})]}),detail:(0,Q.jsx)(`span`,{className:`block truncate font-mono text-[11px]`,title:e.summary,children:i?e.taken?n(`mcp.local.importTaken`):e.reason??``:e.summary}),children:(0,Q.jsx)(C,{checked:s.has(t),disabled:i,label:`${e.name} ${$(e.kind)}`,onChange:e=>d(t,e)})},t)}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--text-muted)]`,children:n(`mcp.local.importSecrets`)})]})})}var Te={unknown:`neutral`,ok:`green`,needs_auth:`orange`,auth_error:`red`,unreachable:`red`,version_unsupported:`red`};function Ee(){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(De,{}),(0,Q.jsx)(de,{}),(0,Q.jsx)(be,{}),(0,Q.jsx)(Oe,{}),(0,Q.jsx)(Me,{})]})}function De(){let{t:e}=I(),{toast:t}=W(),n=a(),r=O(),[i,c]=(0,Z.useState)(``),l=n.data?.allowedOrigins.join(`
|
|
8
|
+
`)??``;if((0,Z.useEffect)(()=>c(l),[l]),!n.data)return(0,Q.jsx)(x,{});let u=n.data,d=n=>r.mutate(n,{onSuccess:()=>t(e(`common.saved`),`success`),onError:e=>t(H(e),`error`)});return(0,Q.jsxs)(o,{title:e(`mcp.gateway.title`),children:[(0,Q.jsx)(B,{label:e(`mcp.gateway.enable`),detail:e(`mcp.gateway.enableHint`),children:(0,Q.jsx)(C,{checked:u.enabled,disabled:r.isPending,label:e(`mcp.gateway.enable`),onChange:e=>d({enabled:e})})}),(0,Q.jsx)(B,{label:e(`mcp.gateway.remoteAdmin`),detail:e(`mcp.gateway.remoteAdminHint`),children:(0,Q.jsx)(C,{checked:u.allowRemoteAdmin,disabled:r.isPending,label:e(`mcp.gateway.remoteAdmin`),onChange:e=>d({allowRemoteAdmin:e})})}),(0,Q.jsxs)(B,{label:e(`mcp.gateway.endpoint`),detail:(0,Q.jsx)(`span`,{className:`block whitespace-normal`,children:e(`mcp.gateway.endpointHint`)}),children:[(0,Q.jsx)(`code`,{className:`max-w-[22rem] truncate rounded bg-[var(--surface-muted,transparent)] px-1.5 py-0.5 font-mono text-[12px]`,title:u.endpoint,children:u.endpoint}),(0,Q.jsx)(f,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(G,{className:`size-3.5`}),"aria-label":e(`mcp.gateway.copyEndpoint`),onClick:()=>void te.copy(u.endpoint).then(n=>n&&t(e(`mcp.gateway.copied`),`success`))})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2 px-4 py-3`,children:[(0,Q.jsx)(p,{label:e(`mcp.gateway.origins`),hint:e(`mcp.gateway.originsHint`),children:(0,Q.jsx)(s,{mono:!0,rows:3,value:i,placeholder:`https://app.example.com`,onChange:e=>c(e.target.value)})}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(f,{size:`sm`,disabled:i.trim()===l.trim()||r.isPending,onClick:()=>d({allowedOrigins:i.split(`
|
|
9
|
+
`).map(e=>e.trim()).filter(Boolean)}),children:e(`mcp.gateway.originsSave`)})})]})]})}function Oe(){let{t:e}=I(),{toast:t,confirm:r}=W(),a=b(),o=n(),s=v(),c=m(),l=i(),[u,p]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),_=n=>o.mutate(n.id,{onSuccess:r=>{r.ok?g({server:n,result:r}):t(e(`mcp.server.testFailed`,{message:r.message??r.status}),`error`)},onError:e=>t(H(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(H(e),`error`)}),S=async n=>{await r({title:e(`mcp.server.forgetConfirm`,{name:n.name}),detail:e(`mcp.server.forgetDetail`),confirmLabel:e(`mcp.server.forget`),destructive:!0})&&c.mutate(n.id,{onSuccess:()=>t(e(`mcp.server.forgotten`),`success`),onError:e=>t(H(e),`error`)})},C=async n=>{await r({title:e(`mcp.server.deleteConfirm`,{name:n.name}),detail:e(`mcp.server.deleteDetail`),confirmLabel:e(`common.delete`),destructive:!0})&&l.mutate(n.id,{onSuccess:()=>t(e(`mcp.server.deleted`,{name:n.name}),`success`),onError:e=>t(H(e),`error`)})};return(0,Q.jsxs)(`section`,{className:`mb-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between px-1`,children:[(0,Q.jsx)(`h3`,{className:`text-[12px] font-medium text-[var(--text-secondary)]`,children:e(`mcp.servers.title`)}),(0,Q.jsx)(f,{size:`sm`,variant:`primary`,icon:(0,Q.jsx)(Y,{className:`size-3.5`}),onClick:()=>p(`new`),children:e(`mcp.servers.add`)})]}),a.data===void 0?(0,Q.jsx)(x,{}):a.data.length===0?(0,Q.jsx)(d,{icon:(0,Q.jsx)(J,{className:`size-6`}),title:e(`mcp.servers.emptyTitle`),detail:e(`mcp.servers.emptyDetail`)}):(0,Q.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:a.data.map(e=>(0,Q.jsx)(ke,{server:e,busy:o.isPending&&o.variables===e.id,onTest:()=>_(e),onEdit:()=>p(e),onAuthorize:()=>y(e),onForget:()=>void S(e),onDelete:()=>void C(e)},e.id))}),(0,Q.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:e(`mcp.servers.localOnly`)}),(0,Q.jsx)(je,{server:u,onClose:()=>p(null)}),(0,Q.jsx)(V,{open:h!==null,onOpenChange:e=>!e&&g(null),title:e(`mcp.server.testToolsTitle`,{name:h?.server.name??``}),description:h?e(`mcp.server.testOk`,{count:h.result.toolCount}):void 0,footer:(0,Q.jsx)(f,{onClick:()=>g(null),children:e(`common.close`)}),children:(0,Q.jsx)(`ul`,{className:`max-h-72 overflow-auto font-mono text-[12px] text-[var(--text-secondary)]`,children:h?.result.tools.map(e=>(0,Q.jsx)(`li`,{className:`truncate py-0.5`,children:e},e))})})]})}function ke({server:e,busy:t,onTest:n,onEdit:i,onAuthorize:a,onForget:o,onDelete:s}){let{t:c,locale:l}=I(),u=D(),d=e.id===`builtin-astra`,p=e.authType===`oauth`,m=e.oauth?.authorized===!0,h=[e.slug,e.protocolVersion?c(`mcp.server.protocol`,{version:e.protocolVersion}):null,c(`mcp.server.boundTokens`,{count:e.boundTokens}),e.checkedAt?N(e.checkedAt,l):null].filter(Boolean).join(` · `);return(0,Q.jsxs)(B,{label:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),d&&(0,Q.jsx)(r,{tone:`accent`,children:c(`mcp.server.builtIn`)}),(0,Q.jsx)(r,{tone:Te[e.status],title:e.statusMessage??void 0,children:c(`mcp.status.${e.status}`)}),!e.enabled&&(0,Q.jsx)(r,{children:c(`mcp.server.disabledBadge`)})]}),detail:(0,Q.jsxs)(`span`,{className:`block whitespace-normal`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.url}),(0,Q.jsx)(`span`,{className:`block`,children:h}),p&&m&&e.oauth?.issuer&&(0,Q.jsx)(`span`,{className:`block`,children:c(`mcp.server.authorizedBy`,{issuer:e.oauth.issuer})})]}),children:[d&&(0,Q.jsx)(Ae,{}),p&&(0,Q.jsx)(f,{size:`sm`,variant:m?`glass`:`primary`,icon:(0,Q.jsx)(re,{className:`size-3.5`}),onClick:a,children:c(m?`mcp.server.reauthorize`:`mcp.server.authorize`)}),!d&&(0,Q.jsx)(f,{size:`sm`,icon:(0,Q.jsx)(ae,{className:`size-3.5`}),loading:t,onClick:n,children:c(`mcp.server.test`)}),d?(0,Q.jsx)(C,{checked:e.enabled,label:e.name,onChange:t=>u.mutate({id:e.id,body:{enabled:t}})}):(0,Q.jsx)(ee,{label:e.name,iconOnly:!0,icon:(0,Q.jsx)(K,{className:`size-4`}),items:[{id:`edit`,label:c(`common.edit`),icon:(0,Q.jsx)(q,{className:`size-3.5`}),onSelect:i},...p&&m?[{id:`forget`,label:c(`mcp.server.forget`),icon:(0,Q.jsx)(ne,{className:`size-3.5`}),onSelect:o}]:[],{id:`delete`,label:c(`common.delete`),icon:(0,Q.jsx)(X,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:s}]})]})}function Ae(){let{t:e}=I(),t=se();return(0,Q.jsx)(f,{size:`sm`,onClick:()=>t(`/tools`),children:e(`mcp.server.builtInManage`)})}function je({server:e,onClose:t}){let{t:n}=I(),{toast:r}=W(),i=k(),a=D(),o=e&&e!==`new`?e:null,[s,l]=(0,Z.useState)(``),[d,m]=(0,Z.useState)(``),[h,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(`http`),[x,S]=(0,Z.useState)(`none`),[w,T]=(0,Z.useState)([]),[E,O]=(0,Z.useState)(60),[A,j]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{if(e===null)return;let t=e===`new`?null:e;l(t?.name??``),m(t?.slug??``),v(t?.url??``),b(t?.transport??`http`),S(t?.authType??`none`),T((t?.headerNames??[]).map(e=>({name:e,value:``,kept:!0}))),O(t?.timeoutSeconds??60),j(t?.enabled??!0)},[e]);let M=i.isPending||a.isPending,N=s.trim()!==``&&h.trim()!==``&&(x!==`header`||w.some(e=>e.name.trim()!==``&&(e.value!==``||e.kept))),P=()=>{let e={name:s.trim(),url:h.trim(),transport:y,authType:x,enabled:A,...E==null?{}:{timeoutSeconds:Math.floor(E)},...d.trim()?{slug:d.trim()}:{}};x===`header`&&(e.headers=Object.fromEntries(w.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.kept&&e.value===``?null:e.value])));let c={onSuccess:e=>{t(),r(n(o?`mcp.server.saved`:`mcp.server.created`,{name:e.name}),`success`)},onError:e=>r(H(e),`error`)};o?a.mutate({id:o.id,body:e},c):i.mutate(e,c)},F=(e,t)=>T(n=>n.map((n,r)=>r===e?{...n,...t}:n));return(0,Q.jsx)(V,{open:e!==null,onOpenChange:e=>!e&&t(),width:560,title:o?n(`mcp.server.editTitle`,{name:o.name}):n(`mcp.server.addTitle`),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(f,{onClick:t,children:n(`common.cancel`)}),(0,Q.jsx)(f,{variant:`primary`,disabled:!N,loading:M,onClick:P,children:n(`common.save`)})]}),children:(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsx)(p,{label:n(`mcp.server.name`),children:(0,Q.jsx)(u,{value:s,maxLength:64,onChange:e=>l(e.target.value)})}),(0,Q.jsx)(p,{label:n(`mcp.server.url`),hint:n(`mcp.server.urlHint`),children:(0,Q.jsx)(u,{mono:!0,value:h,placeholder:`https://mcp.example.com/mcp`,onChange:e=>v(e.target.value)})}),(0,Q.jsx)(p,{label:n(`mcp.server.transport`),hint:n(`mcp.server.transportHint`),children:(0,Q.jsx)(c,{ariaLabel:n(`mcp.server.transport`),value:y,onChange:b,items:[{value:`http`,label:n(`mcp.server.transport.http`)},{value:`sse`,label:n(`mcp.server.transport.sse`)}]})}),(0,Q.jsx)(p,{label:n(`mcp.server.auth`),children:(0,Q.jsx)(c,{ariaLabel:n(`mcp.server.auth`),value:x,onChange:S,items:[{value:`none`,label:n(`mcp.server.auth.none`)},{value:`header`,label:n(`mcp.server.auth.header`)},{value:`oauth`,label:n(`mcp.server.auth.oauth`)}]})}),x===`oauth`&&(0,Q.jsx)(_,{tone:`warning`,title:n(`mcp.server.oauthNote`)}),x===`header`&&(0,Q.jsx)(p,{label:n(`mcp.server.headers`),hint:n(`mcp.server.headersHint`),children:(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[w.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(u,{className:`w-40`,mono:!0,label:n(`mcp.server.headerName`),placeholder:`Authorization`,value:e.name,readOnly:e.kept&&o!==null,onChange:e=>F(t,{name:e.target.value})}),(0,Q.jsx)(u,{className:`flex-1`,mono:!0,type:`password`,label:n(`mcp.server.headerValue`),placeholder:e.kept?n(`mcp.server.headerKept`):`Bearer …`,value:e.value,onChange:e=>F(t,{value:e.target.value})}),(0,Q.jsx)(f,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(X,{className:`size-3.5`}),"aria-label":n(`mcp.server.removeHeader`),onClick:()=>T(e=>e.filter((e,n)=>n!==t))})]},t)),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(f,{size:`sm`,icon:(0,Q.jsx)(Y,{className:`size-3.5`}),onClick:()=>T(e=>[...e,{name:``,value:``,kept:!1}]),children:n(`mcp.server.addHeader`)})})]})}),(0,Q.jsx)(p,{label:n(`mcp.server.slug`),hint:n(`mcp.server.slugHint`),children:(0,Q.jsx)(u,{mono:!0,value:d,maxLength:32,placeholder:o?``:`github`,onChange:e=>m(e.target.value)})}),(0,Q.jsx)(p,{label:n(`mcp.server.timeout`),hint:n(`mcp.server.timeoutHint`),children:(0,Q.jsx)(g,{value:E,min:1,step:1,label:n(`mcp.server.timeout`),onChange:O})}),(0,Q.jsx)(B,{label:n(`mcp.server.enabled`),children:(0,Q.jsx)(C,{checked:A,label:n(`mcp.server.enabled`),onChange:j})})]})})}function Me(){let{t:e,locale:t}=I(),n=L(50);return(0,Q.jsx)(o,{title:e(`mcp.calls.title`),footer:e(`mcp.calls.hint`),children:n.data===void 0?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(x,{})}):n.data.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-6 text-center text-[12px] text-[var(--text-muted)]`,children:e(`mcp.calls.empty`)}):(0,Q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Q.jsxs)(`table`,{className:`w-full text-left text-[12px]`,children:[(0,Q.jsx)(`thead`,{className:`text-[var(--text-muted)]`,children:(0,Q.jsx)(`tr`,{children:[`time`,`token`,`tool`,`duration`,`result`].map(t=>(0,Q.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:e(`mcp.calls.${t}`)},t))})}),(0,Q.jsx)(`tbody`,{children:n.data.map(e=>(0,Q.jsx)(Ne,{call:e,locale:t},e.id))})]})})})}function Ne({call:e,locale:t}){let{t:n}=I();return(0,Q.jsxs)(`tr`,{className:`border-t border-[var(--border)]`,children:[(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-4 py-1.5 text-[var(--text-secondary)]`,children:N(e.at,t)}),(0,Q.jsx)(`td`,{className:`px-4 py-1.5`,children:e.tokenName??e.tokenId}),(0,Q.jsxs)(`td`,{className:`px-4 py-1.5 font-mono`,children:[e.serverSlug,(0,Q.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`/`}),e.tool,e.frontEra&&(0,Q.jsx)(`span`,{className:`ml-2 text-[10.5px] text-[var(--text-muted)]`,children:n(`mcp.calls.era.${e.frontEra}`)})]}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-4 py-1.5 tabular-nums text-[var(--text-secondary)]`,children:M(e.durationMs)}),(0,Q.jsx)(`td`,{className:`px-4 py-1.5`,children:e.ok?(0,Q.jsx)(r,{tone:`green`,children:n(`mcp.calls.ok`)}):(0,Q.jsx)(r,{tone:`red`,children:n(`mcp.calls.error.${e.errorCategory??`protocol`}`)})})]})}function Pe(){let{t:e}=I();return(0,Q.jsx)(ce,{title:e(`nav.mcp`),subtitle:e(`mcp.subtitle`),children:(0,Q.jsx)(Ee,{})})}export{Pe as McpPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{D as n,Dn as r,F as i,I as a,Ii as o,Io as s,O as c,On as l,P as u,Qs as d,R as f,S as p,U as m,V as h,W as g,kr as _,po as v,r as ee,ti as y,w as b,y as x,z as S}from"./format-CmXxTS5M.js";import{H as C,U as w,V as T,W as E}from"./TrayTitleSource-DN10ruw2.js";import{t as D}from"./arrow-left-DhPqlXf4.js";import{t as O}from"./pencil-CpF9MxGZ.js";import{t as k}from"./plus-c3HzV6VX.js";import{t as A}from"./rotate-ccw-fsXoCwyv.js";import{t as j}from"./trash-BHBJn5GS.js";import{G as M,H as N,W as te,l as P,s as ne,v as F}from"./index-BW8keTkg.js";import{t as I}from"./checkbox-CZ-rG7I2.js";import{t as L}from"./confirm-morph-Cakq9Lho.js";var R=e(t(),1),z=d(),B=[{key:`vision`,label:`cap.vision`},{key:`tools`,label:`cap.tools`},{key:`reasoning`,label:`cap.reasoning`},{key:`promptCache`,label:`cap.promptCache`},{key:`audio`,label:`cap.audio`},{key:`pdf`,label:`cap.pdf`},{key:`structuredOutput`,label:`cap.structuredOutput`}];function V(e){return{displayName:e.displayName,vendor:e.vendor,family:e.family??null,aliases:e.aliases,contextWindow:e.contextWindow??null,maxOutputTokens:e.maxOutputTokens??null,capabilities:e.capabilities,pricing:e.pricing??null,enabled:e.enabled}}function H(){let{t:e,locale:t}=b(),s=te(),{id:l=``}=M(),u=decodeURIComponent(l),d=_(u),y=v(u),C=o(u),T=r(),{toast:O}=E(),k=(0,R.useMemo)(()=>d.data?V(d.data):null,[d.data]),[j,L]=(0,R.useState)(k),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(k),G(k?.aliases?.join(`, `)??``)},[k]);let q=(0,z.jsx)(c,{variant:`glass`,icon:(0,z.jsx)(D,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>s(`/models`)});if(d.isError)return(0,z.jsx)(F,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(p,{tone:`danger`,title:e(`common.error`),children:w(d.error)})});let J=d.data;if(!J||!j)return(0,z.jsx)(F,{title:``,leading:q,children:(0,z.jsx)(m,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...j,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(k),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>y.mutate(X,{onSuccess:()=>O(e(`common.saved`),`success`),onError:e=>O(w(e),`error`)}),$=t=>re.has(t)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(n,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(c,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(A,{className:`size-3`}),title:e(`models.resetField`),"aria-label":e(`models.resetField`),onClick:()=>C.mutate(t,{onSuccess:()=>O(e(`models.fieldReset`)),onError:e=>O(w(e),`error`)})})]}):null;return(0,z.jsx)(F,{title:J.displayName,subtitle:`${J.id} · ${e(`models.source.${J.source}`)} · ${e(`models.updated`,{time:ee(J.updatedAt,t)})}`,leading:q,actions:(0,z.jsxs)(z.Fragment,{children:[J.source===`user`&&(0,z.jsx)(K,{label:e(`common.delete`),prompt:e(`models.deleteConfirm`,{id:J.id}),onConfirm:async()=>{await T.mutateAsync(J.id),s(`/models`)}}),Z&&(0,z.jsx)(c,{onClick:()=>{L(k),G(k?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(c,{variant:`primary`,disabled:!Z,loading:y.isPending,onClick:ie,children:e(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`mx-auto grid max-w-[1100px] gap-x-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(i,{title:e(`models.section.basic`),footer:Q?e(`models.modifiedFooter`):void 0,children:[(0,z.jsx)(U,{label:e(`models.field.displayName`),marker:$(`displayName`),children:(0,z.jsx)(a,{className:`w-60`,"aria-label":e(`models.field.displayName`),value:j.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.vendor`),children:(0,z.jsx)(a,{className:`w-60`,"aria-label":e(`models.field.vendor`),value:j.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(a,{className:`w-60`,"aria-label":e(`models.field.family`),value:j.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:e(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(a,{className:`w-60 font-mono`,"aria-label":e(`models.field.aliases`),value:H,onChange:e=>G(e.target.value),placeholder:`a, b, c`})}),(0,z.jsx)(U,{label:e(`models.field.contextWindow`),marker:$(`contextWindow`),children:(0,z.jsx)(f,{className:`w-36`,label:e(`models.field.contextWindow`),value:j.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:e(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(f,{className:`w-36`,label:e(`models.field.maxOutputTokens`),value:j.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:e(`common.enabled`),children:(0,z.jsx)(g,{checked:j.enabled??!0,label:e(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(i,{title:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e(`models.section.capabilities`),` `,$(`capabilities`)]}),children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 px-4 py-4`,children:B.map(t=>(0,z.jsx)(I,{label:e(t.label),checked:!!j.capabilities?.[t.key],onCheckedChange:e=>Y({capabilities:{...j.capabilities,[t.key]:e===!0}})},t.key))})}),(0,z.jsx)(W,{model:J}),J.providerOverrides.length>0&&(0,z.jsx)(i,{title:e(`models.section.overrides`),footer:e(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(S,{label:(0,z.jsx)(N,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${x(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(h,{action:$(`pricing`),children:e(`models.section.pricing`)}),(0,z.jsx)(`p`,{className:`mb-3 px-1 text-[12px] text-[var(--text-secondary)]`,children:e(`models.pricingHint`)}),(0,z.jsx)(`div`,{className:`card p-4`,children:(0,z.jsx)(P,{value:j.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(h,{children:e(`models.section.simulator`)}),(0,z.jsxs)(`div`,{className:`card p-4`,children:[(0,z.jsx)(ne,{modelId:Z?void 0:J.id,pricing:Z?X.pricing:null}),Z&&(0,z.jsx)(`p`,{className:`mt-3 text-[12px] text-[var(--text-muted)]`,children:e(`models.simulatorUnsaved`)})]})]})]})]})})}function U({label:e,marker:t,children:n}){return(0,z.jsx)(S,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=b(),r=l(e.id),[a,o]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(i,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(c,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{className:`size-3.5`}),onClick:()=>o(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(S,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(S,{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)(n,{tone:`orange`,children:t(`models.modified`)})]}),detail:[x(e.pricing),e.upstreamModelId,e.pricing.time_windows?.length?t(`models.hasTimeWindows`):null,e.pricing.context_tiers?.length?t(`models.hasTiers`):null].filter(Boolean).join(` · `),children:[(0,z.jsx)(c,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(O,{className:`size-3.5`}),"aria-label":t(`common.edit`),onClick:()=>o(e)}),(0,z.jsx)(K,{label:t(`common.delete`),prompt:t(`models.deletePrice`,{key:e.priceKey}),onConfirm:()=>r.mutateAsync(e.priceKey)})]},e.priceKey))]}),(0,z.jsx)(G,{model:e,editing:a,onClose:()=>o(null)})]})}function G({model:e,editing:t,onClose:n}){let{t:r}=b(),{toast:i}=E(),o=y(),l=s(e.id),d=t===`new`,[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(``),[g,_]=(0,R.useState)(null);(0,R.useEffect)(()=>{t&&(t===`new`?(p(``),h(``),_(e.pricing?structuredClone(e.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(p(t.priceKey),h(t.upstreamModelId??``),_(structuredClone(t.pricing))))},[t,e.pricing]);let v=new Set(e.providerPrices.map(e=>e.priceKey));return(0,z.jsx)(C,{open:t!==null,onOpenChange:e=>!e&&n(),width:680,title:d?r(`models.addPrice`):r(`models.editPrice`,{key:f}),description:r(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(c,{onClick:n,children:r(`common.cancel`)}),(0,z.jsx)(c,{variant:`primary`,disabled:!f||!g,loading:l.isPending,onClick:()=>l.mutate({priceKey:f,upstreamModelId:m||null,pricing:g},{onSuccess:()=>{i(r(`common.saved`),`success`),n()},onError:e=>i(w(e),`error`)}),children:r(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,z.jsx)(u,{label:r(`providers.priceKey`),children:d?(0,z.jsx)(T,{value:f,onChange:p,placeholder:r(`models.pickPriceKey`),options:(o.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:v.has(e.priceKey)}))}):(0,z.jsx)(a,{value:f,disabled:!0,className:`font-mono`})}),(0,z.jsx)(u,{label:r(`models.upstreamId`),hint:r(`models.upstreamIdHint`),children:(0,z.jsx)(a,{className:`font-mono`,value:m,onChange:e=>h(e.target.value),placeholder:e.id})})]}),d&&(0,z.jsx)(a,{className:`font-mono`,"aria-label":r(`models.customPriceKey`),placeholder:r(`models.customPriceKey`),value:f,onChange:e=>p(e.target.value.trim())}),(0,z.jsx)(P,{value:g,onChange:_})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:r}=b();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(j,{className:`size-4`}),prompt:t,confirmLabel:r(`common.delete`),cancelLabel:r(`common.cancel`),pendingLabel:r(`common.deleting`),doneLabel:r(`common.deleted`),errorLabel:r(`common.error`),retryLabel:r(`common.retry`),onConfirm:n})}export{H as ModelDetailPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{Ar as n,B as r,D as i,I as a,Ia as o,N as s,O as c,P as l,Pa as u,Qs as d,R as f,S as p,U as m,dt as h,gn as g,n as _,p as v,v as y,w as b}from"./format-CmXxTS5M.js";import{H as x,U as S,V as C,W as w}from"./TrayTitleSource-DN10ruw2.js";import{t as T}from"./boxes-BLn3utsF.js";import{t as E}from"./chevron-right-Bgtn3ze-.js";import{t as D}from"./cloud-download-l1GjuXcO.js";import{t as O}from"./plus-c3HzV6VX.js";import{A as k,F as A,I as j,W as M,v as N}from"./index-BW8keTkg.js";import{t as P}from"./checkbox-CZ-rG7I2.js";var F=e(t(),1),I=d();function L(){let{t:e}=b(),t=M(),[i,a]=(0,F.useState)(``),[o,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(!1),[f,h]=(0,F.useState)(!1),g=(0,F.useRef)(null),_=j(i),v=n(),y=n(_,o),x=(0,F.useMemo)(()=>[...new Set((v.data??[]).map(e=>e.vendor))].sort(),[v.data]);return A(e=>{e===`find`&&g.current?.focus()}),(0,I.jsxs)(N,{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)(r,{inputRef:g,className:`w-52`,value:i,onChange:a,placeholder:e(`models.search`)}),(0,I.jsx)(C,{value:o,onChange:l,options:[{value:``,label:e(`models.allVendors`)},...x.map(e=>({value:e,label:e}))]}),(0,I.jsx)(c,{icon:(0,I.jsx)(D,{className:`size-3.5`}),onClick:()=>h(!0),children:e(`models.sync`)}),(0,I.jsx)(c,{variant:`primary`,icon:(0,I.jsx)(O,{className:`size-3.5`}),onClick:()=>d(!0),children:e(`models.new`)})]}),children:[y.isLoading&&(0,I.jsx)(m,{lines:5}),y.isError&&(0,I.jsx)(p,{tone:`danger`,title:e(`common.error`),children:S(y.error)}),y.data?.length===0&&(0,I.jsx)(s,{icon:(0,I.jsx)(T,{className:`size-6`}),title:e(`models.empty`)}),y.data&&y.data.length>0&&(0,I.jsx)(k,{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=>t(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:u,onOpenChange:d,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:f,onOpenChange:h})]})}function R(e,t){return[{key:`name`,label:e(`models.col.model`),render:(n,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>t(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:h(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(i,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(i,{tone:`orange`,children:e(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:r.id})]})},{key:`vendor`,label:e(`models.col.vendor`),width:120},{key:`context`,label:e(`models.col.context`),numeric:!0,width:96,render:(e,t)=>_(t.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${v(n.input)} / ${v(n.output)}`:`—`}},{key:`providerPrices`,label:e(`models.col.providerPrices`),numeric:!0,width:130,render:(t,n)=>n.providerPrices?e(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:e,onOpenChange:t,onCreated:n}){let{t:r}=b(),{toast:i}=w(),o=g(),[s,u]=(0,F.useState)(``),[d,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[_,v]=(0,F.useState)(null),[y,C]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(x,{open:e,onOpenChange:t,title:r(`models.new`),description:r(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(c,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(c,{variant:`primary`,disabled:!s.trim()||!m.trim(),loading:o.isPending,onClick:()=>o.mutate({id:s.trim(),displayName:d.trim()||s.trim(),vendor:m.trim(),contextWindow:_,pricing:y!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:y,output:T}}:null},{onSuccess:e=>{t(!1),u(``),p(``),n(e.id)},onError:e=>i(S(e),`error`)}),children:r(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(l,{label:r(`models.field.id`),hint:r(`models.field.idHint`),children:(0,I.jsx)(a,{className:`font-mono`,value:s,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)(l,{label:r(`models.field.displayName`),children:(0,I.jsx)(a,{value:d,onChange:e=>p(e.target.value)})}),(0,I.jsx)(l,{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)(l,{label:r(`models.field.contextWindow`),children:(0,I.jsx)(f,{value:_,onChange:v})}),(0,I.jsx)(l,{label:r(`models.field.inputPrice`),children:(0,I.jsx)(f,{value:y,onChange:C})}),(0,I.jsx)(l,{label:r(`models.field.outputPrice`),children:(0,I.jsx)(f,{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}=b(),r=H(e,t),i=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${y(e)||`∅`}\n→\n${y(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),i>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:i})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:a}=b(),[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`},u=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},d=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),f=e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(i,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(i,{tone:`orange`,children:a(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),p=e.map(e=>e.id);return(0,I.jsx)(`div`,{className:`card max-h-[520px] overflow-auto`,children:(0,I.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,I.jsxs)(`li`,{className:`sticky top-0 z-10 flex items-center gap-3 bg-[var(--surface)] px-4 py-2`,children:[(0,I.jsx)(P,{checked:l(p),onCheckedChange:e=>u(p,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:p.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=>u(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:()=>d(e),children:[(0,I.jsx)(E,{className:h(`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&&f(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=>u([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),f(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:n}=b(),{toast:r}=w(),i=o(),a=u(),[s,l]=(0,F.useState)(new Set),d=()=>i.mutate(void 0,{onSuccess:e=>l(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),f=i.data?.changes??[];return(0,I.jsxs)(x,{open:e,onOpenChange:e=>{t(e),e&&!i.data&&d()},width:720,title:n(`models.sync`),description:n(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(c,{className:`mr-auto`,variant:`plain`,onClick:d,loading:i.isPending,children:n(`common.refresh`)}),(0,I.jsx)(c,{onClick:()=>t(!1),children:n(`common.cancel`)}),(0,I.jsx)(c,{variant:`primary`,disabled:s.size===0,loading:a.isPending,onClick:()=>a.mutate([...s],{onSuccess:e=>{r(n(`models.sync.applied`,{count:e.applied}),`success`),t(!1),i.reset()},onError:e=>r(S(e),`error`)}),children:n(`models.sync.apply`,{count:s.size})})]}),children:[e&&!i.data&&!i.isPending&&!i.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(c,{variant:`primary`,onClick:d,children:n(`models.sync.check`)})}),i.isPending&&(0,I.jsx)(m,{lines:4}),i.isError&&(0,I.jsx)(p,{tone:`danger`,title:n(`common.error`),children:S(i.error)}),i.data&&f.length===0&&(0,I.jsx)(p,{tone:`success`,title:n(`models.sync.none`)}),f.length>0&&(0,I.jsx)(K,{changes:f,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:s,onChange:l})]})}export{L as ModelsPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{B as n,Ci as r,Cr as i,D as a,G as o,H as s,Hr as c,I as l,Jr as u,L as d,Lr as f,N as p,Nt as m,O as h,P as g,Qs as _,Rr as v,S as y,Ti as b,U as x,W as S,Zr as C,cr as w,dt as T,fr as E,jr as D,k as O,mo as k,r as A,w as j,zr as ee}from"./format-CmXxTS5M.js";import{B as M,H as N,U as P,W as F}from"./TrayTitleSource-DN10ruw2.js";import{t as te}from"./app-window-C13qqwdi.js";import{t as I}from"./arrow-down-Def8Fl70.js";import{t as ne}from"./arrow-up-DE65OgjV.js";import{t as re}from"./check-DKfsh0bQ.js";import{t as ie}from"./ellipsis-CidyZaW2.js";import{t as ae}from"./external-link-D6jQM2CZ.js";import{t as oe}from"./plus-c3HzV6VX.js";import{t as L}from"./puzzle-Eesuewfj.js";import{t as R}from"./refresh-cw-CoLAai2c.js";import{t as se}from"./settings-2-CSrxJ7TH.js";import{t as ce}from"./shield-check-CD30JqBi.js";import{t as z}from"./trash-BHBJn5GS.js";import{B,D as V,E as H,G as U,K as W,L as le,O as ue,W as G,k as K,v as de,w as fe}from"./index-BW8keTkg.js";var q=e(t(),1),J=_(),pe=/^(?:(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*|github:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/,Y={provider:`plugins.kind.provider`,middleware:`plugins.kind.middleware`,agent:`plugins.kind.agent`,pi:`plugins.kind.pi`,v2:`plugins.kind.v2`,ui:`plugins.kind.ui`,hooks:`plugins.kind.hooks`},me={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`,v2:`accent`,ui:`neutral`,hooks:`accent`};function X({name:e,icon:t,kind:n,size:r=32}){let i=Math.round(r*.28);return t&&/^(https:|data:image\/)/i.test(t)?(0,J.jsx)(`img`,{src:t,alt:``,width:r,height:r,className:`shrink-0 object-contain`,style:{borderRadius:i},draggable:!1}):n===`middleware`||n===`agent`?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex shrink-0 items-center justify-center text-white`,style:{width:r,height:r,borderRadius:i,background:n===`middleware`?`#0a84ff`:`#30b0a0`},children:(0,J.jsx)(n===`middleware`?ce:te,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(fe,{name:e,icon:t,size:r})}function he(){let{t:e}=j(),t=G(),{tab:n}=U(),r=n===`market`||n===`runtime`?n:`installed`,i=u(),a=k(),{toast:o}=F(),[s,c]=(0,q.useState)(!1),[l,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null);return(0,J.jsxs)(de,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(h,{icon:(0,J.jsx)(R,{className:`size-3.5`}),onClick:()=>a.mutate(void 0,{onSuccess:e=>p(e.id),onError:e=>o(P(e),`error`)}),disabled:!i.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(h,{variant:`primary`,icon:(0,J.jsx)(oe,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[i.data?.off&&(0,J.jsx)(y,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(H,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(ue,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(K,{value:`installed`,children:[e(`plugins.tab.installed`),i.data&&i.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:i.data.plugins.length})]}),(0,J.jsx)(K,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(K,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(V,{value:`installed`,className:`pt-1`,children:[i.isLoading&&(0,J.jsx)(x,{lines:4}),i.isError&&(0,J.jsx)(y,{tone:`danger`,title:e(`common.error`),children:P(i.error)}),(0,J.jsx)(`div`,{className:`mb-4`,children:(0,J.jsx)(le,{onJob:p})}),i.data&&(0,J.jsx)(ge,{plugins:i.data.plugins.filter(e=>!e.kinds.includes(`v2`)),preferences:i.data.preferences,onJob:p,onBrowse:()=>t(`/plugins/market`),onImport:()=>d(!0)})]}),(0,J.jsx)(V,{value:`market`,className:`pt-1`,children:(0,J.jsx)(xe,{installed:i.data?.plugins??[],onJob:p})}),(0,J.jsx)(V,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Se,{onJob:p})})]})]}),(0,J.jsx)(ve,{open:s,onOpenChange:c,onJob:p}),(0,J.jsx)(ye,{open:l,onOpenChange:d,onJob:p}),(0,J.jsx)(be,{id:f,onClose:()=>p(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:r,onImport:a}){let{t:o}=j(),s=f(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),c=i(),l=b(),{toast:u}=F(),d=!!(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:o(`plugins.magpie.banner`,{count:c.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(h,{size:`sm`,icon:(0,J.jsx)(B,{className:`size-3.5`}),onClick:a,children:o(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(p,{icon:(0,J.jsx)(L,{className:`size-6`}),title:o(`plugins.empty`),detail:o(`plugins.emptyDetail`),action:(0,J.jsx)(h,{variant:`primary`,onClick:r,children:o(`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(P(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(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:o(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:n,onJob:i,onUp:o,onDown:s}){let{t:c}=j(),l=G(),{toast:u,confirm:d}=F(),f=D(),p=k(),m=r(),g=C(),[_,v]=(0,q.useState)(!1),b=t?.plugins.find(t=>t.spec===e.spec),x=e.middleware,w=e.kinds[0]??`provider`,E=async()=>{await d({title:c(`plugins.removeConfirm`,{name:e.shortName}),detail:c(`plugins.removeDetail`),confirmLabel:c(`common.delete`),destructive:!0})&&m.mutate(e.spec,{onSuccess:e=>i(e.id),onError:e=>u(P(e),`error`)})},O=[];return x&&!x.error&&O.push((0,J.jsxs)(Z,{label:c(`plugins.kind.middleware`),children:[c(`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:c(`plugins.mw.lastError`,{error:x.lastError})})]},`mw`)),e.notice===`hooks-unsupported`&&O.push((0,J.jsx)(Z,{label:c(`plugins.kind.hooks`),children:c(`plugins.hooksUnsupported`)},`notice`)),e.agent?.kind&&O.push((0,J.jsx)(Z,{label:c(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>l(`/clients/${e.agent.kind}`),children:c(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),b&&b.provides.length>0&&O.push((0,J.jsxs)(Z,{label:c(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:c(`plugins.provides`,{providers:b.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>l(`/providers`),children:c(`plugins.openProviders`)}),Object.entries(b.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[c(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(h,{size:`sm`,onClick:()=>g.mutate({spec:e.spec,provider:t},{onError:e=>u(P(e),`error`)}),children:c(`plugins.useFor`,{provider:t})})]},t)),b.provides.some(t=>n[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:c(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:T(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:T(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:w})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.shortName}),e.version&&(0,J.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:[`v`,e.version]}),e.kinds.map(e=>(0,J.jsx)(a,{tone:me[e],children:c(Y[e])},e)),e.isPath&&(0,J.jsx)(a,{tone:`orange`,children:c(`plugins.local`)})]}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:e.spec,children:e.spec})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[x&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(h,{size:`sm`,variant:`plain`,"aria-label":c(`plugins.moveUp`),title:c(`plugins.moveUp`),disabled:!o,onClick:o,icon:(0,J.jsx)(ne,{className:`size-3.5`})}),(0,J.jsx)(h,{size:`sm`,variant:`plain`,"aria-label":c(`plugins.moveDown`),title:c(`plugins.moveDown`),disabled:!s,onClick:s,icon:(0,J.jsx)(I,{className:`size-3.5`})})]}),(0,J.jsx)(S,{checked:e.enabled,label:c(`plugins.enabled`),onChange:t=>f.mutate({spec:e.spec,enabled:t},{onError:e=>u(P(e),`error`)})}),(0,J.jsx)(M,{label:c(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ie,{className:`size-4`}),items:[{id:`options`,label:c(`plugins.options`),icon:(0,J.jsx)(se,{className:`size-3.5`}),onSelect:()=>v(!0)},...e.isPath?[]:[{id:`update`,label:c(`plugins.update`),icon:(0,J.jsx)(R,{className:`size-3.5`}),onSelect:()=>p.mutate(e.spec,{onSuccess:e=>i(e.id),onError:e=>u(P(e),`error`)})}],{id:`remove`,label:c(`common.delete`),icon:(0,J.jsx)(z,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void E()}]})]})]}),e.error&&(0,J.jsx)(y,{tone:`danger`,title:c(`plugins.cantLoad`),children:e.error}),b?.error&&(0,J.jsx)(y,{tone:`danger`,title:c(`plugins.hostCantLoad`),children:b.error}),x?.error&&(0,J.jsx)(y,{tone:`danger`,title:c(`plugins.cantLoad`),children:c(`plugins.mw.error`,{error:x.error})}),e.agent?.error&&(0,J.jsx)(y,{tone:`danger`,title:c(`plugins.cantLoad`),children:c(`plugins.agent.error`,{error:e.agent.error})}),O.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:O})]}),(0,J.jsx)(Q,{plugin:e,open:_,onOpenChange:v})]})}function Z({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex gap-3 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[var(--text-muted)]`,children:e}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 text-[var(--text-secondary)]`,children:t})]})}function Q({plugin:e,open:t,onOpenChange:n}){let{t:r}=j(),{toast:i}=F(),a=D(),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(c(JSON.stringify(e.options??e.optionsExample??{},null,2)),u(null))},[t,e.options,e.optionsExample]);let d=t=>a.mutate({spec:e.spec,options:t},{onSuccess:()=>(i(r(`plugins.optionsSaved`)),n(!1)),onError:e=>i(P(e),`error`)});return(0,J.jsxs)(N,{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)(h,{onClick:()=>d(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(h,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(s||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(r(`plugins.optionsObject`));d(e)}catch(e){u(e instanceof Error?e.message:String(e))}},disabled:a.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(o,{mono:!0,rows:14,value:s,invalid:!!l,onChange:e=>(c(e.target.value),u(null)),label:r(`plugins.options`)}),l&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:l})]})}function ve({open:e,onOpenChange:t,onJob:n}){let{t:r}=j(),{toast:i}=F(),a=m(),[o,s]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&s(``)},[e]),(0,J.jsxs)(N,{open:e,onOpenChange:t,title:r(`plugins.addTitle`),description:r(`plugins.addDetail`),footer:(0,J.jsx)(h,{variant:`primary`,disabled:!o.trim()||a.isPending,onClick:()=>a.mutate({spec:o.trim()},{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(P(e),`error`)}),children:r(`plugins.install`)}),children:[(0,J.jsx)(g,{label:r(`plugins.spec`),hint:r(`plugins.specHint`),children:(0,J.jsx)(l,{mono:!0,value:o,onChange:e=>s(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(y,{tone:`warning`,title:r(`plugins.trustTitle`),className:`mt-4`,children:r(`plugins.trustDetail`)})]})}function ye({open:e,onOpenChange:t,onJob:n}){let{t:r}=j(),{toast:o}=F(),s=i(e),c=w(),[l,u]=(0,q.useState)(!1),d=s.data;return(0,J.jsxs)(N,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:d?.path,width:560,footer:(0,J.jsx)(h,{variant:`primary`,disabled:!d?.found||c.isPending,onClick:()=>c.mutate(l,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>o(P(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[s.isLoading&&(0,J.jsx)(x,{lines:3}),d?.error&&(0,J.jsx)(y,{tone:`danger`,title:r(`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)(a,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(a,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(a,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),d.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(S,{checked:l,onChange:u,label:r(`plugins.magpie.signIns`,{count:d.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`plugins.magpie.signInsDetail`)})]})]})]})}function be({id:e,onClose:t}){let{t:n}=j(),r=v(e).data;return(0,J.jsxs)(N,{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)(h,{onClick:t,children:n(`common.close`)}),children:[!r&&(0,J.jsx)(x,{lines:3}),r&&(0,J.jsx)(O,{language:`text`,children:r.log.length?r.log.join(`
|
|
2
|
+
`):`…`}),r?.state===`failed`&&r.error&&(0,J.jsx)(y,{tone:`danger`,title:n(`plugins.job.failedTitle`),className:`mt-3`,children:r.error})]})}function xe({installed:e,onJob:t}){let{t:r,locale:i}=j(),{toast:a,confirm:o}=F(),l=ee(),u=m(),[d,f]=(0,q.useState)(``),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>g(d.trim()),400);return()=>clearTimeout(e)},[d]);let b=c(h),S=(0,q.useMemo)(()=>new Set(e.map(e=>e.name)),[e]),C=(t,n)=>S.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`)})&&u.mutate({spec:e,source:n},{onSuccess:e=>t(e.id),onError:e=>a(P(e),`error`)})},[T,E]=W(),D=T.get(`install`),O=(0,q.useRef)(null);(0,q.useEffect)(()=>{D&&O.current!==D&&(O.current=D,E({},{replace:!0}),pe.test(D)?w(D,`market`):a(r(`plugins.linkInvalid`),`error`))},[D]);let k=(l.data??[]).filter(e=>_===`all`||e.kind===_),A=e=>(l.data??[]).filter(t=>e===`all`||t.kind===e).length,M=h.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)(n,{className:`min-w-[220px] flex-1`,value:d,onChange:f,placeholder:r(`plugins.searchPlaceholder`)}),!M&&(0,J.jsx)(s,{ariaLabel:r(`plugins.kindFilter`),value:_,onChange:v,items:[`all`,`provider`,`middleware`,`agent`].map(e=>({value:e,label:`${r(e===`all`?`plugins.kind.all`:Y[e])} ${A(e)}`}))})]}),M?(0,J.jsxs)(J.Fragment,{children:[b.isLoading&&(0,J.jsx)(x,{lines:3}),b.data?.length===0&&(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(p,{icon:(0,J.jsx)(L,{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:C(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:[l.isLoading&&(0,J.jsx)(x,{lines:4}),l.isError&&(0,J.jsx)(y,{tone:`danger`,title:r(`common.error`),children:P(l.error)}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:k.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:C(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:o,onInstall:s}){let{t:c}=j();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)(a,{children:e},e)),(0,J.jsx)(`span`,{className:`flex-1`}),o?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-[var(--success)]`,children:[(0,J.jsx)(re,{className:`size-3.5`}),c(`plugins.installed`)]}):(0,J.jsx)(h,{size:`sm`,variant:`primary`,onClick:s,children:c(`plugins.install`)})]})]})}function Se({onJob:e}){let{t,locale:n}=j(),{toast:r}=F(),i=u(),o=f(),s=E(),c=i.data?.runtime;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:`Bun`}),c&&(0,J.jsx)(a,{tone:c.path?`green`:`neutral`,children:c.path?t(`plugins.bunReady`):t(`plugins.bunMissing`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.bunDetail`)}),c&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c.path&&(0,J.jsx)(d,{label:t(`plugins.bunPath`),mono:!0,children:c.path}),c.version&&(0,J.jsx)(d,{label:t(`plugins.bunVersion`),mono:!0,children:c.version}),(0,J.jsx)(d,{label:t(`plugins.bunTarget`),mono:!0,children:c.target??t(`plugins.bunNoBuild`)})]}),c?.error&&(0,J.jsx)(y,{tone:`danger`,title:t(`plugins.bunFailed`),children:c.error}),c&&!c.path&&(0,J.jsx)(`div`,{children:(0,J.jsx)(h,{variant:`primary`,disabled:c.downloading||s.isPending||!c.target,onClick:()=>s.mutate(void 0,{onSuccess:t=>e(t.id),onError:e=>r(P(e),`error`)}),children:c.downloading?t(`plugins.bunDownloading`):t(`plugins.bunDownload`,{version:c.version??``})})})]}),(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:t(`plugins.host`)}),o.data&&(0,J.jsx)(a,{tone:o.data.running?`green`:`neutral`,children:o.data.running?t(`plugins.hostRunning`):t(`plugins.hostStopped`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.hostDetail`)}),o.data?.startError&&(0,J.jsx)(y,{tone:`danger`,title:t(`plugins.hostStartFailed`),children:o.data.startError}),o.data?.goneReason&&(0,J.jsx)(y,{tone:`warning`,title:t(`plugins.hostGone`),children:o.data.goneReason}),o.data&&o.data.plugins.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.data.plugins.map(e=>(0,J.jsx)(d,{label:e.spec,mono:!0,children:e.error?t(`plugins.hostPluginError`,{error:e.error}):e.provides.join(`, `)||`—`},e.spec))}),o.data?.recent&&o.data.recent.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-t border-[var(--border-subtle)] pt-3`,children:[(0,J.jsx)(`h4`,{className:`text-[12px] font-medium text-[var(--text-secondary)]`,children:t(`plugins.hostRecent`)}),o.data.recent.map((e,t)=>(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-[12px]`,children:[(0,J.jsx)(a,{tone:e.variant===`error`?`red`:e.variant===`warning`?`orange`:e.variant===`success`?`green`:`neutral`,children:A(e.at,n)}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.title&&(0,J.jsxs)(`span`,{className:`font-medium`,children:[e.title,` `]}),e.message]})]},t))]})]}),(0,J.jsxs)(`a`,{className:`flex items-center gap-1 px-1 text-[12px] text-[var(--text-muted)] hover:text-[var(--accent)] lg:col-span-2`,href:`https://github.com/astragate-community/astra-gate-plugins`,target:`_blank`,rel:`noreferrer`,children:[(0,J.jsx)(ae,{className:`size-3`}),` astragate-community/astra-gate-plugins`]})]})}export{he as PluginsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./createLucideIcon-7fjTeqBK.js";import{B as n,D as r,F as i,G as a,H as o,I as s,N as c,O as l,P as u,Qs as d,S as f,U as p,V as m,W as h,Z as g,ai as _,an as v,as as y,cs as b,d as x,ds as S,dt as C,ho as w,ii as T,ni as E,os as D,ri as O,ss as k,u as ee,un as te,us as A,w as j,z as M}from"./format-CmXxTS5M.js";import{H as N,U as P,V as F,W as I}from"./TrayTitleSource-DN10ruw2.js";import{t as L}from"./use-transform-BcmlojQJ.js";import{t as ne}from"./check-DKfsh0bQ.js";import{t as re}from"./chevron-left-EiWUqFxR.js";import{t as ie}from"./chevron-right-Bgtn3ze-.js";import{t as ae}from"./plus-c3HzV6VX.js";import{t as oe}from"./refresh-cw-CoLAai2c.js";import{t as R}from"./shield-check-CD30JqBi.js";import{t as se}from"./shield-off-rW5EHy29.js";import{t as z}from"./trash-BHBJn5GS.js";import{t as ce}from"./x-AFrW8zH7.js";import{A as le,D as B,E as V,G as ue,I as H,O as de,W as fe,b as pe,d as me,k as he,q as ge,r as _e,v as ve}from"./index-BW8keTkg.js";var U=e(t(),1),W={toolbar:`_toolbar_xx43h_1`,leading:`_leading_xx43h_3`,frame:`_frame_xx43h_7`,chips:`_chips_xx43h_9`,slot:`_slot_xx43h_13`,chip:`_chip_xx43h_9`,chipLabel:`_chipLabel_xx43h_19`,value:`_value_xx43h_21`,separator:`_separator_xx43h_23`,morphText:`_morphText_xx43h_25`,morphValue:`_morphValue_xx43h_27`,measure:`_measure_xx43h_29`,empty:`_empty_xx43h_35`,actions:`_actions_xx43h_37`,clear:`_clear_xx43h_39`,clearText:`_clearText_xx43h_41`,srOnly:`_srOnly_xx43h_45`,menu:`_menu_xx43h_53`,trigger:`_trigger_xx43h_57`,face:`_face_xx43h_61`,surface:`_surface_xx43h_67`,panel:`_panel_xx43h_83`,head:`_head_xx43h_89`,back:`_back_xx43h_93`,title:`_title_xx43h_97`,titleText:`_titleText_xx43h_99`,stage:`_stage_xx43h_101`,step:`_step_xx43h_103`,list:`_list_xx43h_105`,highlight:`_highlight_xx43h_107`,item:`_item_xx43h_109`,itemIcon:`_itemIcon_xx43h_113`,itemLabel:`_itemLabel_xx43h_115`,itemMeta:`_itemMeta_xx43h_117`,metaValue:`_metaValue_xx43h_119`,hint:`_hint_xx43h_121`,check:`_check_xx43h_123`,noOptions:`_noOptions_xx43h_127`},G=d(),K={duration:g.duration.standard,ease:[...g.ease.enter]},ye={duration:g.duration.instant,ease:[...g.ease.standard]},q={duration:0},be={duration:g.duration.instant,ease:[...g.ease.standard]},J=e=>`blur(${e}px)`,xe=e=>Math.min(1,Math.max(0,e)),Se=e=>typeof e==`string`?{value:e}:e,Ce=e=>e.label??e.value,we=e=>({initial:e?{opacity:0}:{opacity:0,y:`0.3em`,filter:J(g.blur.soft)},animate:{opacity:1,y:0,filter:J(0)},exit:e?{opacity:0,transition:q}:{opacity:0,y:`-0.3em`,filter:J(g.blur.subtle),transition:ye},transition:e?be:K});function Te({text:e}){let t=k()??!1,n=(0,U.useRef)(null),r=b(`auto`);return(0,U.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let i=null,a=new ResizeObserver(([n])=>{let a=Math.ceil(n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth),o=i!==null&&i!==e.textContent;i=e.textContent,o&&!t?D(r,a,g.spring.morph):r.jump(a)});return a.observe(e),()=>a.disconnect()},[t,r]),(0,G.jsxs)(y.span,{className:W.morphText,style:{width:r},children:[(0,G.jsx)(`span`,{ref:n,className:W.measure,"aria-hidden":`true`,children:e}),(0,G.jsx)(A,{mode:`popLayout`,initial:!1,children:(0,G.jsx)(y.span,{className:W.morphValue,...we(t),children:e},e)})]})}function Ee(e,t,n){let r=b(`auto`);return(0,U.useLayoutEffect)(()=>{let i=e.current;if(!i||typeof ResizeObserver>`u`)return;let a=!1,o=new ResizeObserver(()=>{let e=i.offsetHeight;if(!a||n||performance.now()>t.current){a=!0,r.jump(e);return}D(r,e,g.spring.smooth)});return o.observe(i),()=>o.disconnect()},[t,r,e,n]),r}function De(e,t,n){(0,U.useLayoutEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>`u`)return;let i=new Map,a=()=>{let e=performance.now();for(let a of Array.from(r.children)){let r=a.offsetLeft,o=a.offsetTop,s=i.get(a);if(!s){i.set(a,{x:r,y:o,dx:0,dy:0});continue}let c=s.x-r,l=s.y-o;if(s.x=r,s.y=o,n||e>t.current||Math.abs(l)<1&&Math.abs(c)<40)continue;s.stop?.();let u=s.dx+c,d=s.dy+l,f=e=>{s.dx=u*(1-e),s.dy=d*(1-e),a.style.translate=e>=1?``:`${s.dx}px ${s.dy}px`};f(0),s.stop=D(0,1,{...g.spring.smooth,onUpdate:f,onComplete:()=>f(1)}).stop}for(let e of i.keys())e.parentElement!==r&&i.delete(e)},o=new ResizeObserver(a),s=()=>{for(let e of Array.from(r.children))o.observe(e)},c=new MutationObserver(()=>{s(),a()});return o.observe(r),s(),c.observe(r,{childList:!0}),()=>{o.disconnect(),c.disconnect();for(let e of i.values())e.stop?.()}},[t,e,n])}var Y=e=>e.valueLabel??e.value,X=e=>Y(e)?`${e.label}: ${Y(e)}`:e.label,Oe={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${X(e)}`,added:e=>`Added ${X(e)}`,changed:e=>`Changed ${X(e)}`,removed:e=>`Removed ${X(e)}`};function ke(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 Ae({rows:e,labelledBy:t,onChoose:n,onBack:r,onLeave:i,radio:a,emptyMessage:o}){let s=k()??!1,c=S(),l=(0,U.useRef)(null),u=(0,U.useRef)(!1),d=(0,U.useRef)({text:``,at:0}),[f,p]=(0,U.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[m,h]=(0,U.useState)(null),_=()=>Array.from(l.current?.querySelectorAll(`[data-row]`)??[]),v=e=>{let t=l.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 b(t){let i=_(),a=i.indexOf(document.activeElement),o=e=>{t.preventDefault(),u.current=!1,v(i[e])};if(t.key===`ArrowDown`)return o(a<0?0:(a+1)%i.length);if(t.key===`ArrowUp`)return o(a<0?i.length-1:(a-1+i.length)%i.length);if(t.key===`Home`)return o(0);if(t.key===`End`)return o(i.length-1);if(t.key===`ArrowRight`&&a>=0&&e[a]?.drill){t.preventDefault(),n(e[a],!0);return}if(t.key===`ArrowLeft`&&r){t.preventDefault(),r(!0);return}if(t.key.length===1&&/\S/.test(t.key)&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let e=performance.now();d.current={text:e-d.current.at<700?d.current.text+t.key.toLowerCase():t.key.toLowerCase(),at:e};let n=[...i.slice(a+(d.current.text.length>1?0:1)),...i.slice(0,a+(d.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(d.current.text));n&&o(i.indexOf(n))}}function x(e){let t=e.target.closest(`[data-row]`);if(!t)return;p(_().indexOf(t));let n=u.current&&!s,r=!u.current&&t.matches(`:focus-visible`);h(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function C(e){l.current?.contains(e.relatedTarget)||h(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,G.jsxs)(`div`,{ref:l,className:W.list,role:`menu`,"aria-labelledby":t,"data-current":c?``:void 0,onKeyDown:b,onFocus:x,onBlur:C,onPointerLeave:()=>{u.current&&l.current?.contains(document.activeElement)&&i()},children:[(0,G.jsx)(y.span,{className:W.highlight,"data-ring":m?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:m?{y:m.top,height:m.height,opacity:+!!m.shown}:{opacity:0},transition:{default:m?.glide?g.spring.snappy:q,opacity:{duration:s?0:.08}}}),e.length===0?(0,G.jsx)(`p`,{className:W.noOptions,children:o}):null,e.map((e,t)=>(0,G.jsxs)(`button`,{type:`button`,className:W.item,role:a?`menuitemradio`:`menuitem`,"aria-checked":a?!!e.checked:void 0,tabIndex:t===f?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{u.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>n(e,t.detail===0),children:[e.icon?(0,G.jsx)(`span`,{className:W.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,G.jsx)(`span`,{className:W.itemLabel,children:e.label}),e.meta?(0,G.jsx)(`span`,{className:W.itemMeta,children:e.meta}):null]},e.key))]})}function je(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 Me({fields:e,onSelect:t,active:n=[],label:r=`Add filter`,align:i=`end`,messages:a}){let o={...Oe,...a},s=k()??!1,c=(0,U.useId)(),l=`${c}panel`,u=`${c}title`,d=(0,U.useRef)(null),f=(0,U.useRef)(null),p=(0,U.useRef)(null),m=(0,U.useRef)(`closed`),h=(0,U.useRef)(0),_=(0,U.useRef)(null),[v,x]=(0,U.useState)(`closed`),[S,C]=(0,U.useState)(null),[w,T]=(0,U.useState)(1),[E,O]=(0,U.useState)(!1),[ee,te]=(0,U.useState)(`100% 0`),j=b(`100%`),M=b(`100%`),N=b(0),P=b(0),F=L(()=>P.get()-N.get()),I=b(0),oe=b(0),R=L(()=>{let e=j.get(),t=I.get(),n=oe.get();return typeof e==`number`?n>t?xe((e-t)/(n-t)):1:0}),se=L(()=>xe(R.get()/.35)),z=L(()=>xe((R.get()-.4)/.5)),ce={opacity:L(()=>1-se.get()),scale:L(()=>1-se.get()*.04),filter:L(()=>se.get()?J(se.get()*g.blur.subtle):`none`)},le={opacity:z,transformOrigin:ee,scale:L(()=>.96+z.get()*.04),y:L(()=>(1-z.get())*(E?-6:6)),filter:L(()=>z.get()===1?`none`:J((1-z.get())*g.blur.soft))},B=v===`open`,V=e.find(e=>e.id===S)??null,ue=(0,U.useCallback)(e=>{let t=f.current,n=p.current;if(!t||!n)return;let r=t.getBoundingClientRect(),a=n.offsetWidth+2,o=n.offsetHeight+2,c=je(d.current??t),l=c.left+16-r.left,u=c.right-16-r.left-a,v=r.width-a,y=i===`end`?v>=l?v:0<=u?0:v:0<=u?0:v>=l?v:0;y=Math.round(Math.min(Math.max(y,l),Math.max(l,u)));let b=c.bottom-r.top,S=r.bottom-c.top,w=b<o+16&&S>b;m.current===`closed`&&(j.jump(r.width),M.jump(r.height),N.jump(0)),P.jump(y),I.jump(r.width),oe.jump(a),m.current=`open`,h.current+=1,_.current=e,x(`open`),O(w),C(null),T(-1),te(`${Math.round(r.width/2-y)}px ${w?`100%`:`0`}`);let E=s?q:g.spring.morph;D(N,y,E),D(j,a,E),D(M,o,E)},[i,I,M,N,s,P,oe,j]),H=(0,U.useCallback)(e=>{let t=f.current;if(m.current!==`open`||!t)return;m.current=`closing`;let n=h.current+=1;x(`closing`),e&&t.focus({preventScroll:!0,focusVisible:e===`keyboard`});let r=s?q:g.spring.snappy;D(N,0,r);let i=t.getBoundingClientRect();D(M,i.height,r),D(j,i.width,{...r,onComplete:()=>{n===h.current&&(m.current=`closed`,j.jump(`100%`),M.jump(`100%`),x(`closed`),C(null))}})},[M,N,s,j]);(0,U.useLayoutEffect)(()=>{let e=p.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{m.current===`open`&&D(M,e.offsetHeight+2,s?q:g.spring.smooth)});return t.observe(e),()=>t.disconnect()},[M,s]),(0,U.useLayoutEffect)(()=>{let e=_.current,t=p.current;if(!e||!t||v!==`open`)return;if(_.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})},[v,S]),(0,U.useEffect)(()=>{if(v!==`open`)return;let e=e=>{let t=d.current,n=e.target;!t||n&&t.contains(n)||(H(!1),n?.closest?.(`button, a[href], input, select, textarea, [tabindex], [contenteditable]`)||window.setTimeout(()=>{let e=document.activeElement;(!e||e===document.body||t.contains(e))&&f.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[H,v]);function de(e){if(e.defaultPrevented)return;let t=Array.from(p.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`&&V&&(e.preventDefault(),fe(!0))}function fe(e){V&&(_.current=e?{key:V.id}:`panel`,T(-1),C(null))}function pe(e,t){_.current=t?`checked`:`panel`,T(1),C(e.key)}function me(e,n){V&&(t({id:V.id,label:V.label,value:e.key,valueLabel:e.label},V),H(n?`keyboard`:`pointer`))}let he=e=>n.find(t=>t.id===e.id),ge=e.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,G.jsxs)(G.Fragment,{children:[he(e)?(0,G.jsx)(`span`,{className:W.metaValue,children:Y(he(e))}):null,(0,G.jsx)(ie,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),_e=V?V.options.map(Se).map(e=>{let t=Ce(e),n=he(V)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,G.jsxs)(G.Fragment,{children:[e.hint==null?null:(0,G.jsx)(`span`,{className:W.hint,children:e.hint}),(0,G.jsx)(`span`,{className:W.check,"data-on":n||void 0,children:(0,G.jsx)(ne,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],ve={enter:e=>s?{opacity:0}:{opacity:0,x:e*18,filter:J(g.blur.soft)},center:{opacity:1,x:0,filter:J(0),transition:s?be:{...K,x:g.spring.smooth}},exit:e=>s?{opacity:0,transition:q}:{opacity:0,x:e*-18,filter:J(g.blur.subtle),transition:ye}};return(0,G.jsxs)(`div`,{ref:d,className:W.menu,"data-state":v,"data-y":E?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&m.current===`open`&&(e.preventDefault(),e.stopPropagation(),H(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;m.current===`open`&&t&&!d.current?.contains(t)&&H(!1)},children:[(0,G.jsx)(`button`,{ref:f,type:`button`,className:W.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":B,"aria-controls":l,tabIndex:B?-1:void 0,onClick:e=>{m.current!==`open`&&ue(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),ue(e.key===`ArrowDown`?`first`:`last`))},children:(0,G.jsxs)(y.span,{className:W.face,style:ce,children:[(0,G.jsx)(ae,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),r]})}),(0,G.jsx)(y.div,{className:W.surface,style:{left:N,width:j,height:M},children:(0,G.jsx)(y.div,{ref:p,id:l,className:W.panel,role:`dialog`,"aria-labelledby":u,tabIndex:-1,inert:!B,style:{x:F},onKeyDown:de,children:(0,G.jsxs)(y.div,{style:le,children:[(0,G.jsxs)(`div`,{className:W.head,children:[(0,G.jsx)(A,{initial:!1,children:V?(0,G.jsx)(y.button,{type:`button`,className:W.back,"aria-label":o.back,onClick:e=>fe(e.detail===0),initial:s?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:s?{opacity:0,transition:q}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...g.spring.snappy,opacity:ye}},transition:s?be:{...g.spring.snappy,opacity:K},children:(0,G.jsx)(re,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,G.jsx)(`span`,{className:W.title,id:u,children:(0,G.jsx)(A,{mode:`popLayout`,initial:!1,children:(0,G.jsx)(y.span,{className:W.titleText,...we(s),children:V?V.label:r},V?.id??`fields`)})})]}),(0,G.jsx)(`div`,{className:W.stage,children:(0,G.jsx)(A,{mode:`popLayout`,initial:!1,custom:w,children:(0,G.jsx)(y.div,{className:W.step,custom:w,variants:ve,initial:`enter`,animate:`center`,exit:`exit`,children:V?(0,G.jsx)(Ae,{rows:_e,labelledBy:u,emptyMessage:o.noOptions,radio:!0,onChoose:me,onBack:fe,onLeave:()=>p.current?.focus({preventScroll:!0})}):(0,G.jsx)(Ae,{rows:ge,labelledBy:u,emptyMessage:o.noOptions,onChoose:pe,onLeave:()=>p.current?.focus({preventScroll:!0})})},V?.id??`fields`)})})]})})})]})}function Ne({filters:e,onRemove:t,onClearAll:n,leading:r,children:i,label:a=`Active filters`,addFilter:o,messages:s}){let c={...Oe,...s},l=k()??!1,u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(0),p=(0,U.useRef)(null),[m,h]=(0,U.useState)(e),[_,v]=(0,U.useState)(``);if(m!==e){h(e);let t=ke(m,e,c);t&&v(t)}let b=e.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,U.useLayoutEffect)(()=>{f.current=performance.now()+900},[b]);let x=Ee(d,f,l);De(d,f,l),(0,U.useLayoutEffect)(()=>{let t=p.current,n=u.current;if(t===null||!n)return;p.current=null;let r=e[Math.min(t,e.length-1)];(r?n.querySelector(`[data-chip-remove="${CSS.escape(r.id)}"]`):n.querySelector(`[data-filter-trigger]`))?.focus({preventScroll:!0})},[e]);let S={duration:0},C=e=>({initial:!l&&{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:l?{opacity:0,transition:S}:{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...g.spring.smooth,"--slot-moving":S}},transition:l?S:g.spring.smooth}),w={initial:!l&&{opacity:0,scale:.9,filter:J(g.blur.soft)},animate:{opacity:1,scale:1,filter:J(0)},exit:l?{opacity:0,transition:S}:{opacity:0,scale:.9,filter:J(g.blur.subtle),transition:ye},transition:l?S:{...K,scale:g.spring.snappy}},T=l?{...we(!0),initial:!1}:we(!1),E=l?T:{...T,transition:{...K,delay:g.duration.instant*.75}};return(0,G.jsxs)(`div`,{ref:u,className:W.toolbar,role:`group`,"aria-label":a,children:[r?(0,G.jsx)(`div`,{className:W.leading,children:r}):null,(0,G.jsx)(y.div,{className:W.frame,style:{height:x},children:(0,G.jsxs)(`div`,{ref:d,className:W.chips,children:[(0,G.jsx)(A,{initial:!1,children:e.map((e,n)=>(0,G.jsx)(y.span,{className:W.slot,...C(8),children:(0,G.jsxs)(y.span,{className:W.chip,...w,children:[(0,G.jsxs)(`span`,{className:W.chipLabel,title:X(e),children:[e.label,Y(e)?(0,G.jsxs)(`span`,{className:W.value,children:[(0,G.jsx)(`span`,{className:W.separator,children:` · `}),(0,G.jsx)(Te,{text:Y(e)})]}):null]}),(0,G.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":c.remove(e),onClick:r=>{document.activeElement===r.currentTarget&&(p.current=n),t(e.id)},children:(0,G.jsx)(ce,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,G.jsx)(A,{initial:!1,children:e.length?null:(0,G.jsx)(y.span,{className:W.empty,...E,children:c.empty},`empty`)})]})}),(0,G.jsxs)(`div`,{className:W.actions,children:[o?(0,G.jsx)(Me,{fields:o.fields,onSelect:o.onAdd,active:e,label:o.label,align:o.align,messages:c}):null,i,(0,G.jsx)(A,{initial:!1,children:e.length>0&&n?(0,G.jsx)(y.span,{className:W.slot,...C(12),children:(0,G.jsx)(`button`,{className:W.clear,type:`button`,onClick:()=>{p.current=-1,n?.()},children:(0,G.jsx)(y.span,{className:W.clearText,...T,children:c.clearAll})})},`clear`):null})]}),(0,G.jsx)(`span`,{className:W.srOnly,role:`status`,children:_})]})}var Pe={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`,passport:`settings.privacy.category.passport`,iban:`settings.privacy.category.iban`,mac:`settings.privacy.category.mac`,ip:`settings.privacy.category.ip`,birthday:`settings.privacy.category.birthday`,serial:`settings.privacy.category.serial`,home_user:`settings.privacy.category.home_user`,custom:`settings.privacy.category.custom`},Fe=[`ip`,`home_user`],Ie={warn:`settings.privacy.action.warn`,block:`settings.privacy.action.block`,redact:`settings.privacy.action.redact`};function Z(){let{t:e}=j();return t=>{let n=Pe[t];return n?e(n):t}}function Le({action:e}){let{t}=j();return(0,G.jsx)(r,{tone:e===`block`?`red`:e===`redact`?`orange`:`neutral`,children:t(Ie[e]??`settings.privacy.action.warn`)})}var Re=50,ze=[`block`,`redact`,`warn`];function Be(){let{t:e,locale:t}=j(),r=Z(),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)({client:``,category:``,action:``,blocked:``}),[u,d]=(0,U.useState)(1),[m,h]=(0,U.useState)(null),g=H(i),y=te(),b=E(),{toast:S,confirm:w}=I(),T=v(),D={model:g,...o,page:u,pageSize:Re},O=_(D,u===1),k=O.data,A=k?Math.max(1,Math.ceil(k.total/Re)):1,M=e=>e?pe[e]?.name??e:`—`,N=[...new Set((b.data?.rules??[]).map(e=>e.category))],F={client:(y.data??[]).map(e=>({value:e.kind,label:e.name})),category:N.map(e=>({value:e,label:r(e)})),action:ze.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`)}]},L={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},ne=Object.keys(F).map(e=>({id:e,label:L[e],options:F[e].map(e=>e.label)})),re=Object.keys(o).filter(e=>o[e]).map(e=>({id:e,label:L[e],value:F[e].find(t=>t.value===o[e])?.label??o[e]})),ie=(e,t)=>{s(n=>({...n,[e]:t})),d(1)},ae=(k?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:M(e.clientKind),model:e.requestedModel??``,outcome:Ve(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),R=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,n)=>(0,G.jsx)(`span`,{className:`num`,children:ee(n.e.startedAtUtc,t)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,G.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>h(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,G.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,G.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:M(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,G.jsx)(He,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,G.jsx)(Ue,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,G.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(n,{className:`w-52`,value:i,onChange:e=>{a(e),d(1)},placeholder:e(`requests.searchModel`)}),(0,G.jsx)(l,{variant:`plain`,icon:(0,G.jsx)(oe,{className:C(`size-4`,O.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void O.refetch()}),(0,G.jsx)(l,{variant:`plain`,className:`ml-auto`,icon:(0,G.jsx)(z,{className:`size-4`}),disabled:T.isPending||!k||k.total===0,onClick:async()=>{await w({title:e(`privacy.logs.clearConfirm`),detail:e(`privacy.logs.clearDetail`),confirmLabel:e(`privacy.logs.clear`),destructive:!0})&&T.mutate(void 0,{onSuccess:t=>{d(1),S(e(`privacy.logs.cleared`,{count:x(t.cleared)}),`success`)},onError:e=>S(P(e),`error`)})},children:e(`privacy.logs.clear`)})]}),(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(Ne,{label:e(`requests.filters`),filters:re,onRemove:e=>ie(e,``),onClearAll:()=>{s({client:``,category:``,action:``,blocked:``}),d(1)},addFilter:{fields:ne,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=F[t].find(t=>t.label===e.value)?.value;n&&ie(t,n)}}})}),O.isLoading&&(0,G.jsx)(p,{lines:4,className:`py-6`}),O.isError&&(0,G.jsx)(f,{tone:`danger`,title:e(`common.error`),children:P(O.error)}),k&&k.items.length===0&&(0,G.jsx)(c,{icon:(0,G.jsx)(se,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),k&&k.items.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:x(k.total)})}),(0,G.jsx)(le,{caption:e(`privacy.tab.logs`),rows:ae,columns:R,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),k&&A>1&&(0,G.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,G.jsx)(me,{page:u,pageCount:A,onPageChange:d,label:e(`requests.page`,{page:u,pages:A})})}),(0,G.jsx)(_e,{id:m,onClose:()=>h(null)})]})}function Ve(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function He({event:e}){let{t}=j();return e.blocked?(0,G.jsx)(r,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,G.jsx)(r,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,G.jsx)(r,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,G.jsx)(r,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function Ue({event:e}){let t=Z(),{t:n}=j();if(e.hits.length===0)return(0,G.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(Le,{action:e.action}),(0,G.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,G.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,G.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:n(`privacy.logs.moreHits`,{count:i})})]})}var Q={counter:`_counter_fc0qq_1`,label:`_label_fc0qq_3`,value:`_value_fc0qq_7`,column:`_column_fc0qq_11`,sizer:`_sizer_fc0qq_13`,glyph:`_glyph_fc0qq_15`,labelText:`_labelText_fc0qq_17`,labelSwap:`_labelSwap_fc0qq_19`,symbol:`_symbol_fc0qq_21`,srOnly:`_srOnly_fc0qq_23`},We=[0,1,2,3,4,5,6,7,8,9],Ge={hidden:{opacity:0,y:`0.3em`,filter:`blur(${g.blur.soft}px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:g.duration.standard,ease:[...g.ease.enter]}},gone:{opacity:0,y:`-0.3em`,filter:`blur(${g.blur.subtle}px)`,transition:{duration:g.duration.fast,ease:[...g.ease.standard]}}},Ke={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:g.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:g.duration.instant}}},qe={...g.spring.smooth,visualDuration:g.duration.considered};function Je(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 Ye({position:e,digit:t}){let n=L(e,e=>((t-e)%10+15)%10-5),r=L(n,e=>`${e}em`),i=L(n,e=>Math.max(0,1-Math.abs(e))),a=L(n,e=>Math.abs(e)>=1?`hidden`:`visible`),o=L(n,e=>Math.abs(e)<.02||Math.abs(e)>=1?`none`:`blur(${(Math.abs(e)*g.blur.subtle).toFixed(2)}px)`);return(0,G.jsx)(y.span,{className:Q.glyph,style:{y:r,opacity:i,filter:o,visibility:a},children:t})}var Xe={initial:{width:0,opacity:0},animate:{width:`auto`,opacity:1},exit:{width:0,opacity:0}};function Ze({digit:e,direction:t,armed:n,delay:r,reduceMotion:i}){let a=b(n?0:e),o=(0,U.useRef)({digit:n?0:e,target:n?0:e,revealed:!n});return(0,U.useEffect)(()=>{let s=o.current;if(n||s.digit===e){n||(s.revealed=!0);return}s.target+=t<0&&s.revealed?-((s.digit-e+10)%10):(e-s.digit+10)%10,s.digit=e,i?a.jump(s.target):D(a,s.target,s.revealed?g.spring.smooth:{...qe,delay:r}),s.revealed=!0},[n,r,e,t,a,i]),(0,G.jsxs)(y.span,{className:Q.column,...Xe,transition:i?{duration:0}:g.spring.morph,children:[(0,G.jsx)(`span`,{className:Q.sizer,children:`0`}),We.map(e=>(0,G.jsx)(Ye,{position:a,digit:e},e))]})}function Qe({value:e,label:t,prefix:n=``,suffix:r=``,decimals:i=0,animateOnView:a=!1,locale:o=`en-US`}){let s=(0,U.useRef)(null),c=ge(s,{once:!0,amount:.6}),l=!!k(),[u,d]=(0,U.useState)(e),[f,p]=(0,U.useState)(1);e!==u&&(d(e),p(e>u?1:-1));let m=Je(e,i,o),h=`${n}${m.map(e=>`text`in e?e.text:e.digit).join(``)}${r}`,_=a&&!c;return(0,G.jsxs)(`span`,{ref:s,className:Q.counter,children:[t&&(0,G.jsx)(`span`,{className:Q.label,children:(0,G.jsx)(`span`,{className:Q.labelSwap,children:(0,G.jsx)(A,{mode:`popLayout`,initial:!1,children:(0,G.jsx)(y.span,{className:Q.labelText,variants:l?Ke:Ge,initial:`hidden`,animate:`shown`,exit:`gone`,children:t},t)})})}),(0,G.jsx)(`span`,{className:Q.srOnly,children:h}),(0,G.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[n&&(0,G.jsx)(`span`,{className:Q.symbol,children:n}),(0,G.jsx)(A,{initial:!1,children:m.map(e=>`digit`in e?(0,G.jsx)(Ze,{digit:e.digit,direction:f,armed:_,delay:Math.min(e.order*g.stagger.item,.25),reduceMotion:l},e.key):(0,G.jsx)(y.span,{className:Q.symbol,...Xe,transition:l?{duration:0}:g.spring.morph,children:e.text},e.key))}),r&&(0,G.jsx)(`span`,{className:Q.symbol,children:r})]})]})}var $={card:`_card_m34o3_1`,top:`_top_m34o3_3`,swap:`_swap_m34o3_15`,swapBlock:`_swapBlock_m34o3_15`,text:`_text_m34o3_21`,sizer:`_sizer_m34o3_25`},$e={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${g.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:g.duration.standard,ease:[...g.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${g.blur.subtle}px)`,transition:{duration:g.duration.fast,ease:[...g.ease.standard]}})},et={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:g.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:g.duration.instant}}},tt=e=>Number(e.replace(/,/g,``).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN);function nt({text:e,morph:t=!1,block:n=!1}){let r=!!k(),i=(0,U.useRef)(null),a=b(`auto`),[o,s]=(0,U.useState)({text:e,direction:1});return o.text!==e&&s({text:e,direction:tt(e)<tt(o.text)?-1:1}),(0,U.useEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=null,n=new ResizeObserver(([n])=>{let i=n.borderBoxSize?.[0]?.inlineSize??e.offsetWidth;i&&t!==null&&t!==e.textContent&&!r?D(a,i,g.spring.morph):a.jump(i||`auto`),t=i?e.textContent:null});return n.observe(e),()=>n.disconnect()},[t,r,a]),(0,G.jsxs)(y.span,{className:n?$.swapBlock:$.swap,style:t?{width:a}:void 0,children:[t&&(0,G.jsx)(`span`,{ref:i,className:$.sizer,"aria-hidden":`true`,children:e}),(0,G.jsx)(A,{mode:`popLayout`,initial:!1,custom:o.direction,children:(0,G.jsx)(y.span,{className:$.text,custom:o.direction,variants:r?et:$e,initial:`hidden`,animate:`shown`,exit:`gone`,children:e},e)})]})}function rt({label:e,value:t,suffix:n,context:r,change:i}){let a=!!k();return(0,G.jsxs)(`article`,{className:$.card,children:[(0,G.jsxs)(`div`,{className:$.top,children:[(0,G.jsx)(`span`,{children:(0,G.jsx)(nt,{text:e,block:!0})}),(0,G.jsx)(A,{initial:!1,children:i&&(0,G.jsx)(y.small,{"data-trend":/^[+]/.test(i)?`up`:/^[-−]/.test(i)?`down`:void 0,initial:{opacity:0,scale:a?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:a?1:.96,transition:{duration:g.duration.fast,ease:[...g.ease.standard]}},transition:a?{duration:0}:g.spring.snappy,children:(0,G.jsx)(nt,{text:i,morph:!0})},`change`)})]}),(0,G.jsx)(Qe,{value:t,suffix:n,animateOnView:!0}),(0,G.jsx)(`p`,{children:(0,G.jsx)(nt,{text:r,block:!0})})]})}var it=[{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}`}],at=[`off`,`warn`,`block`,`redact`],ot=Ie;function st(){let{t:e}=j(),{toast:t}=I(),n=E(),r=w(),a=n.data?.settings,o=e=>{a&&r.mutate({...a,...e},{onError:e=>t(P(e),`error`)})},s=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])}));return(0,G.jsxs)(i,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,G.jsx)(p,{className:`my-4`}),n.isError&&(0,G.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:P(n.error)}),a&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(M,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,G.jsx)(h,{checked:a.enabled,label:e(`settings.privacy.enabled`),onChange:e=>o({enabled:e})})}),(0,G.jsx)(M,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,G.jsx)(h,{checked:a.dryRun,disabled:!a.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>o({dryRun:e})})}),(0,G.jsx)(M,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,G.jsx)(h,{checked:a.restoreResponses,disabled:!a.enabled,label:e(`settings.privacy.restore`),onChange:e=>o({restoreResponses:e})})}),(0,G.jsx)(M,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,G.jsx)(h,{checked:a.recordSamples,disabled:!a.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>o({recordSamples:e})})}),(0,G.jsx)(M,{label:e(`settings.privacy.recordFullSamples`),detail:e(`settings.privacy.recordFullSamplesHint`),children:(0,G.jsx)(h,{checked:a.recordFullSamples,disabled:!a.enabled||!a.recordSamples,label:e(`settings.privacy.recordFullSamples`),onChange:e=>o({recordFullSamples:e})})}),(0,G.jsx)(M,{label:e(`settings.privacy.defaultAction`),children:(0,G.jsx)(F,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:a.defaultAction,disabled:!a.enabled,onChange:e=>o({defaultAction:e}),options:s})})]})]})}function ct(){let{t:e}=j(),{toast:t}=I(),n=E(),a=w(),o=n.data?.settings,s=Z(),c=e=>{o&&a.mutate({...o,...e},{onError:e=>t(P(e),`error`)})},u=(e,t)=>c({categoryActions:{...o?.categoryActions,[e]:t}}),d=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])})),f=[...new Set((n.data?.rules??[]).map(e=>e.category))],m=e=>n.data?.rules.find(t=>t.category===e)?.description;return n.isLoading?(0,G.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,G.jsx)(p,{className:`my-4`})}):o?(0,G.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,G.jsx)(i,{title:e(`settings.privacy.categories`),children:f.map(t=>{let n=o.categoryActions[t]??(Fe.includes(t)?`off`:o.defaultAction),i=!o.enabled||n===`off`;return(0,G.jsxs)(M,{label:s(t),detail:m(t),children:[n===`off`?(0,G.jsx)(r,{children:e(`settings.privacy.action.off`)}):(0,G.jsx)(F,{className:`w-36`,ariaLabel:s(t),value:n,disabled:!o.enabled,onChange:e=>u(t,e),options:d.filter(e=>e.value!==`off`)}),i&&(0,G.jsx)(l,{size:`sm`,variant:`plain`,disabled:!o.enabled,onClick:()=>u(t,o.defaultAction===`off`?`warn`:o.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,G.jsx)(lt,{s:o,onPatch:c})]}):null}function lt({s:e,onPatch:t}){let{t:n}=j(),{confirm:r}=I(),[a,o]=(0,U.useState)(!1),s=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),c=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,G.jsxs)(i,{title:n(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,G.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:n(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,G.jsxs)(M,{label:t.name,detail:t.pattern,children:[(0,G.jsx)(h,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>s(t,e)}),(0,G.jsx)(l,{size:`sm`,variant:`plain`,icon:(0,G.jsx)(z,{className:`size-3.5`}),"aria-label":`${n(`common.delete`)} ${t.name}`,onClick:()=>void c(t)})]},t.id)),(0,G.jsx)(`div`,{className:`px-4 py-2`,children:(0,G.jsx)(l,{size:`sm`,icon:(0,G.jsx)(ae,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>o(!0),children:n(`settings.privacy.addRule`)})}),(0,G.jsx)(ut,{open:a,onOpenChange:o,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function ut({open:e,onOpenChange:t,onAdd:n}){let{t:r}=j(),{toast:i}=I(),[o,c]=(0,U.useState)(``),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(``);return(0,G.jsx)(N,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(l,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,G.jsx)(l,{variant:`primary`,disabled:!o.trim()||!d.trim(),onClick:()=>{if(o.trim()&&d.trim()){try{new RegExp(d)}catch(e){i(`${r(`settings.privacy.invalidPattern`)}: ${P(e)}`,`error`);return}n({id:`custom-${Date.now().toString(36)}`,name:o.trim(),pattern:d.trim(),enabled:!0}),c(``),f(``),m(``),t(!1)}},children:r(`common.create`)})]}),children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(u,{label:r(`settings.privacy.ruleTemplates`),hint:r(`settings.privacy.ruleTemplatesHint`),children:(0,G.jsx)(F,{ariaLabel:r(`settings.privacy.ruleTemplates`),value:p,onChange:e=>{m(e);let t=it.find(t=>t.id===e);t&&(c(r(t.nameKey)),f(t.pattern))},options:[{value:``,label:r(`settings.privacy.ruleTemplateNone`)},...it.map(e=>({value:e.id,label:r(e.nameKey)}))]})}),(0,G.jsx)(s,{label:r(`settings.privacy.ruleName`),value:o,onChange:e=>c(e.target.value),autoFocus:!0}),(0,G.jsx)(u,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,G.jsx)(a,{mono:!0,rows:3,value:d,onChange:e=>f(e.target.value)})})]})})}function dt(){let{t:e}=j(),{toast:t}=I(),n=Z(),o=E(),s=O(),[c,u]=(0,U.useState)(``),d=s.data,f=o.data?.settings.enabled??!1;return(0,G.jsx)(i,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,G.jsx)(a,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:c,onChange:e=>u(e.target.value)}),(0,G.jsx)(`div`,{children:(0,G.jsx)(l,{icon:(0,G.jsx)(R,{className:`size-3.5`}),disabled:!f||!c.trim(),loading:s.isPending,onClick:()=>s.mutate({text:c},{onError:e=>t(P(e),`error`)}),children:e(`settings.privacy.runTest`)})}),d&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d.blocked&&(0,G.jsx)(r,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),d.wouldRedact>0&&(0,G.jsx)(r,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:d.wouldRedact})}),!d.blocked&&d.wouldRedact===0&&(0,G.jsx)(r,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),d.maskedText&&(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:e(`settings.privacy.maskedText`)}),(0,G.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-all font-mono text-[11px]`,children:d.maskedText})]}),d.hits.length>0&&(0,G.jsx)(`ul`,{className:`mt-2 space-y-1`,children:d.hits.map(t=>(0,G.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(r,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(ot[t.action])}),(0,G.jsxs)(`span`,{children:[n(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:t.samples.join(` `)})]},`${t.ruleId}:${t.action}`))})]})]})})}var ft=[`today`,`7d`,`30d`,`all`];function pt(){let{t:e}=j(),t=Z(),[n,r]=(0,U.useState)(`7d`),i=T(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,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(m,{action:(0,G.jsx)(o,{ariaLabel:e(`overview.range`),value:n,onChange:r,items:ft.map(t=>({value:t,label:e(`range.${t}`)}))}),children:e(`privacy.stats`)}),i.isLoading&&(0,G.jsx)(p,{lines:3,className:`py-4`}),i.isError&&(0,G.jsx)(f,{tone:`danger`,title:e(`common.error`),children:P(i.error)}),a&&(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,G.jsx)(rt,{label:e(`privacy.stats.events`),value:a.events,context:e(`range.${n}`)}),(0,G.jsx)(rt,{label:e(`privacy.stats.blocked`),value:a.blocked,context:e(`range.${n}`)}),(0,G.jsx)(rt,{label:e(`privacy.stats.redactions`),value:a.redactions,context:e(`range.${n}`)}),(0,G.jsx)(rt,{label:e(`privacy.stats.dryRun`),value:a.dryRun,context:e(`range.${n}`)})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(m,{children:e(`privacy.stats.byCategory`)}),a&&a.categories.length===0&&(0,G.jsx)(`div`,{className:`card`,children:(0,G.jsx)(mt,{})}),a&&a.categories.length>0&&(0,G.jsx)(le,{caption:e(`privacy.stats.byCategory`),rows:c,columns:s,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,G.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,G.jsx)(st,{})})]})}function mt(){let{t:e}=j();return(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,G.jsx)(R,{className:`size-6 text-[var(--text-muted)]`}),(0,G.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,G.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.empty.detail`)})]})}var ht=[`overview`,`logs`,`rules`,`tester`];function gt(){let{t:e}=j(),{tab:t}=ue(),n=fe(),r=ht.includes(t)?t:`overview`;return(0,G.jsx)(ve,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,G.jsxs)(V,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,G.jsx)(de,{"aria-label":e(`nav.privacy`),children:ht.map(t=>(0,G.jsx)(he,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,G.jsx)(B,{value:`overview`,className:`pt-5`,children:(0,G.jsx)(pt,{})}),(0,G.jsx)(B,{value:`logs`,className:`pt-4`,children:(0,G.jsx)(Be,{})}),(0,G.jsx)(B,{value:`rules`,className:`pt-5`,children:(0,G.jsx)(ct,{})}),(0,G.jsx)(B,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,G.jsx)(dt,{})})]})})}export{gt as PrivacyPage};
|