@wrongstack/webui 0.302.0 → 0.302.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/assets/{AgentRosterView-PafACoYi.js → AgentRosterView-BwukmHoA.js} +1 -1
  2. package/dist/assets/{AnalyticsDashboard-D5lvkaiF.js → AnalyticsDashboard-C9aPEyov.js} +1 -1
  3. package/dist/assets/{AudienceMemoryPanel-DUXllPor.js → AudienceMemoryPanel-Bciki41o.js} +1 -1
  4. package/dist/assets/{ChangesView-CKLN6MLR.js → ChangesView-DumffowD.js} +1 -1
  5. package/dist/assets/{ChronicleDashboard-B8OyHq18.js → ChronicleDashboard-BYGV5twz.js} +1 -1
  6. package/dist/assets/CodeEditor-D2Dnax7e.js +1 -0
  7. package/dist/assets/{CodeMap-6L-z-L7d.js → CodeMap-DIKKs3Ux.js} +1 -1
  8. package/dist/assets/{ConfirmModal-B0BCqW4j.js → ConfirmModal-CdKg3EOQ.js} +1 -1
  9. package/dist/assets/{CronJobsPanel-B-rRYNgE.js → CronJobsPanel-CJ7Vc1Am.js} +1 -1
  10. package/dist/assets/{DeadCodeScanPanel-CDbBO9Ic.js → DeadCodeScanPanel-DaeHUzc5.js} +1 -1
  11. package/dist/assets/{DebugDashboard-RAxaJDNV.js → DebugDashboard-BI3EmXrM.js} +1 -1
  12. package/dist/assets/{DesignGalleryView-4kdGN1D5.js → DesignGalleryView-DMW6Ab__.js} +1 -1
  13. package/dist/assets/{GoalView-By18NfaK.js → GoalView-3291Hxnb.js} +1 -1
  14. package/dist/assets/KanbanView-CFE63A4a.js +3 -0
  15. package/dist/assets/{MailboxDetailView-BNyJNz-3.js → MailboxDetailView-CUTWkSyK.js} +1 -1
  16. package/dist/assets/MemoryDrawer-Dsy0AX6f.js +1 -0
  17. package/dist/assets/MemoryManager-D1kXeVE3.js +1 -0
  18. package/dist/assets/{ModelPicker-DwNrO_jw.js → ModelPicker-IOZSUnqM.js} +1 -1
  19. package/dist/assets/{OfficeMapPanel-Bo-cCLV7.js → OfficeMapPanel-Q81eioDB.js} +1 -1
  20. package/dist/assets/{ProcessMonitor-DPEMjjVq.js → ProcessMonitor-TGqyXxmB.js} +1 -1
  21. package/dist/assets/{QueuePanel-Dx9n4NZB.js → QueuePanel-5aMgQbHv.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-On6-vb92.js → RefreshDebugView-DfBYFPEF.js} +1 -1
  23. package/dist/assets/{RequirementIntakeView-DpnZRVDz.js → RequirementIntakeView-CNAFKiQ3.js} +1 -1
  24. package/dist/assets/SageTabs-olgLJfg_.js +2 -0
  25. package/dist/assets/{SddHub-BMedBDDs.js → SddHub-7Z55QY-M.js} +1 -1
  26. package/dist/assets/SessionInspectView-CytBw7Y9.js +1 -0
  27. package/dist/assets/{SessionList-SsEjoeJF.js → SessionList-C3ygQN8A.js} +1 -1
  28. package/dist/assets/{SessionsDashboard-DYw9vuIv.js → SessionsDashboard-CridPbkX.js} +1 -1
  29. package/dist/assets/{SetupScreen-Mr604Nx3.js → SetupScreen-BkVjdky4.js} +1 -1
  30. package/dist/assets/{SkillDetailView-gt-Nm_ZI.js → SkillDetailView-Cp-xEHww.js} +1 -1
  31. package/dist/assets/{SpecsView-CVVQSIZZ.js → SpecsView-DUx1sgtH.js} +1 -1
  32. package/dist/assets/{TechStackView-BNen0ZpH.js → TechStackView-CvUiAISX.js} +1 -1
  33. package/dist/assets/{TerminalPanel-BByD75cu.js → TerminalPanel-Dg5hqYTA.js} +1 -1
  34. package/dist/assets/{Toaster-Cz-_rtgo.js → Toaster-BgN2bRJx.js} +1 -1
  35. package/dist/assets/{activity-B0cam54R.js → activity-BLSyJfTr.js} +1 -1
  36. package/dist/assets/{activity-D7dMY0Jm.js → activity-BnTQWNPX.js} +1 -1
  37. package/dist/assets/{activity-jOHsoosT.js → activity-BwEBEQ51.js} +1 -1
  38. package/dist/assets/{activity-DmdoxMAj.js → activity-C-9I3_s4.js} +1 -1
  39. package/dist/assets/{activity-DXNwLcwn.js → activity-CRMLR4a3.js} +1 -1
  40. package/dist/assets/{activity-B3FDXYFE.js → activity-CZIixoel.js} +1 -1
  41. package/dist/assets/{activity-IZoezahu.js → activity-Xqrt9v4z.js} +1 -1
  42. package/dist/assets/{i18n-ags7mYPP.js → i18n-9T7iGYgW.js} +2 -2
  43. package/dist/assets/{index-Doa2aJ1A.js → index-FHt-sKVF.js} +4 -4
  44. package/dist/assets/{progress-ring-BxJsZCnD.js → progress-ring-B9pqitSa.js} +1 -1
  45. package/dist/assets/{stores-Bz5nhi7q.js → stores-vuG0AaKy.js} +2 -2
  46. package/dist/assets/{useWebSocket-BHzEXXna.js → useWebSocket-CZSpbA3M.js} +1 -1
  47. package/dist/index.html +8 -8
  48. package/dist/index.js +11450 -11404
  49. package/dist/stores/kanban-store.d.ts +12 -0
  50. package/package.json +8 -8
  51. package/dist/assets/CodeEditor-BtAkdKFs.js +0 -1
  52. package/dist/assets/KanbanView-dyfUjpC5.js +0 -3
  53. package/dist/assets/MemoryManager-BbZ-1pfr.js +0 -1
  54. package/dist/assets/SageTabs-D5CzIKGe.js +0 -2
  55. package/dist/assets/SessionInspectView-Crs1g_xM.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ws-client-TTMa0XaT.js","assets/rolldown-runtime-QTnfLwEv.js","assets/vendor-BuarzSSb.js","assets/monaco-BLUV5g0U.js","assets/monaco-Bowa0-zp.css","assets/markdown-sSmz-Ua_.js","assets/vendor-BMdWcCR4.css","assets/utils-B-9lSDIn.js","assets/session-store-Df7_hhe9.js","assets/ProcessMonitor-DPEMjjVq.js","assets/i18n-ags7mYPP.js","assets/activity-jOHsoosT.js","assets/chat-CdiY7G6Z.js","assets/commandPalette-DpaemFux.js","assets/common-COVxQ0FV.js","assets/settings-zIY9-ivF.js","assets/setup-BFcmn89w.js","assets/toasts-BL_8kH4B.js","assets/useWebSocket-BHzEXXna.js","assets/chat-store-DbxFVDwi.js","assets/codemap-activity-store-DQfjo7-j.js","assets/stores-Bz5nhi7q.js","assets/mailbox-store-C1mzoSqJ.js","assets/ui-store-CE4-TlwB.js","assets/view-navigation-DIDEcp4V.js","assets/codemap-index-store-COStDU-8.js","assets/Toaster-Cz-_rtgo.js","assets/dialog-ftgTihmF.js","assets/AnalyticsDashboard-D5lvkaiF.js","assets/AgentRosterView-PafACoYi.js","assets/ModelPicker-DwNrO_jw.js","assets/roster-ws-Da57e_sI.js","assets/ChangesView-CKLN6MLR.js","assets/empty-state-RRSqQaCk.js","assets/monaco-theme-DSeCDzQy.js","assets/ChronicleDashboard-B8OyHq18.js","assets/CodeEditor-BtAkdKFs.js","assets/CodeMap-6L-z-L7d.js","assets/DebugDashboard-RAxaJDNV.js","assets/DesignGalleryView-4kdGN1D5.js","assets/GoalView-By18NfaK.js","assets/button-Dcy288Mc.js","assets/ConfirmModal-B0BCqW4j.js","assets/input-fo9-BPBC.js","assets/KanbanView-dyfUjpC5.js","assets/progress-ring-BxJsZCnD.js","assets/MailboxDetailView-BNyJNz-3.js","assets/OfficeMapPanel-Bo-cCLV7.js","assets/OfficeMapPanel-D6yTfGIT.css","assets/RefreshDebugView-On6-vb92.js","assets/SageTabs-D5CzIKGe.js","assets/RequirementIntakeView-DpnZRVDz.js","assets/SddHub-BMedBDDs.js","assets/SpecsView-CVVQSIZZ.js","assets/SessionsDashboard-DYw9vuIv.js","assets/SessionList-SsEjoeJF.js","assets/SessionInspectView-Crs1g_xM.js","assets/SkillDetailView-gt-Nm_ZI.js","assets/TechStackView-BNen0ZpH.js","assets/DeadCodeScanPanel-CDbBO9Ic.js","assets/SetupScreen-Mr604Nx3.js","assets/TerminalPanel-BByD75cu.js","assets/xterm-DUBp1lnG.js","assets/xterm-BrP-ENHg.css","assets/CronJobsPanel-B-rRYNgE.js","assets/QueuePanel-Dx9n4NZB.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,r as n,t as r}from"./chat-store-DbxFVDwi.js";import{$ as i,$i as a,$n as o,$t as s,A as c,Ai as l,Ar as u,At as d,B as f,Br as p,Bt as m,C as h,Ca as g,Cn as _,Cr as v,D as y,Da as b,Di as x,Dn as S,Dr as C,Dt as w,E as T,En as E,Er as D,F as O,Fi as k,Fn as A,Ft as j,G as M,Gi as N,Gn as ee,Gr as te,Gt as ne,H as re,Hi as P,Hn as ie,Hr as ae,Ht as oe,I as se,Ii as ce,In as F,Ir as I,It as le,J as ue,Ji as de,Jn as fe,Jr as pe,Jt as me,K as he,Ki as ge,Kn as _e,Kt as ve,L as ye,La as L,Ln as be,Lr as xe,Lt as Se,M as Ce,Mn as we,Mr as Te,Mt as Ee,N as De,Na as Oe,Ni as ke,Nn as Ae,Nr as je,Nt as Me,O as Ne,Oa as Pe,On as Fe,Or as Ie,Ot as Le,P as Re,Pa as R,Pi as ze,Pn as Be,Pt as Ve,Q as He,Qi as Ue,Qn as We,Qr as Ge,Qt as Ke,R as qe,Ra as Je,Rr as Ye,Rt as Xe,Sa as Ze,Si as Qe,Sn as $e,Sr as et,St as tt,T as nt,Ti as rt,Tn as it,U as at,Ui as ot,Un as st,V as ct,Vn as lt,Vr as ut,W as dt,Wi as ft,Wn as pt,Wr as mt,Wt as ht,X as gt,Xi as _t,Xn as vt,Xr as yt,Y as bt,Yi as xt,Yn as St,Yr as Ct,Z as wt,Zi as Tt,Zn as Et,Zr as Dt,Zt as Ot,_a as kt,_i as At,_r as jt,_t as Mt,aa as Nt,ai as Pt,an as Ft,at as It,ba as Lt,bi as Rt,bn as zt,br as Bt,ci as Vt,da as Ht,di as Ut,dt as Wt,ea as Gt,ei as Kt,er as qt,et as Jt,fr as Yt,ft as Xt,gi as Zt,gn as Qt,gr as $t,gt as en,ha as tn,hn as nn,hr as rn,ht as an,ia as on,ii as sn,in as cn,ir as ln,it as un,j as dn,ja as fn,ji as pn,jr as mn,jt as hn,k as gn,kn as _n,kr as vn,kt as yn,la as bn,li as xn,ln as Sn,lr as Cn,lt as wn,mi as Tn,mn as En,mt as Dn,na as On,nn as kn,nr as An,nt as jn,oa as Mn,oi as Nn,or as Pn,ot as Fn,pa as In,pi as Ln,pn as Rn,pt as zn,q as Bn,qi as Vn,qn as Hn,qr as Un,ra as Wn,rn as Gn,rr as Kn,rt as qn,sa as Jn,sn as Yn,sr as Xn,st as Zn,ta as Qn,ti as $n,tn as er,tr,tt as nr,ui as rr,ur as ir,ut as ar,va as or,vi as sr,vn as cr,vr as lr,vt as ur,w as dr,wa as fr,wi as pr,wn as mr,wr as hr,wt as gr,xa as _r,xi as vr,xn as yr,xt as br,ya as xr,yi as Sr,yn as Cr,yr as wr,yt as Tr,z as Er,za as Dr,zi as Or,zn as kr,zt as Ar}from"./vendor-BuarzSSb.js";import{n as jr,t as z}from"./i18n-ags7mYPP.js";import{s as B}from"./monaco-BLUV5g0U.js";import{a as Mr,c as Nr,i as Pr,l as Fr,n as Ir,o as Lr,r as Rr,s as zr,t as Br,u as Vr}from"./useWebSocket-BHzEXXna.js";import{l as Hr,t as V}from"./ws-client-TTMa0XaT.js";import{t as H}from"./utils-B-9lSDIn.js";import{t as U}from"./session-store-Df7_hhe9.js";import{A as Ur,B as Wr,C as Gr,D as Kr,E as qr,H as Jr,I as W,L as Yr,M as Xr,N as Zr,O as Qr,P as $r,R as ei,S as ti,T as ni,U as ri,V as ii,_ as ai,b as oi,d as si,f as ci,g as li,h as ui,j as di,k as fi,l as pi,n as mi,o as hi,r as gi,t as _i,u as vi,w as yi,x as bi,y as xi,z as Si}from"./stores-Bz5nhi7q.js";import{n as Ci,r as wi,t as Ti}from"./mailbox-store-C1mzoSqJ.js";import{n as G,t as Ei}from"./ui-store-CE4-TlwB.js";import{a as Di,i as Oi,n as ki,o as K,r as Ai,t as ji}from"./view-navigation-DIDEcp4V.js";import{n as q,t as Mi}from"./Toaster-Cz-_rtgo.js";import{a as Ni,i as Pi,n as Fi,o as Ii,r as Li,t as Ri}from"./dialog-ftgTihmF.js";import{t as J}from"./button-Dcy288Mc.js";import{t as zi}from"./input-fo9-BPBC.js";import{i as Bi,n as Vi,r as Hi,t as Ui}from"./ConfirmModal-B0BCqW4j.js";import{d as Wi,p as Gi}from"./markdown-sSmz-Ua_.js";import{n as Ki,t as qi}from"./ModelPicker-DwNrO_jw.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Y=e(Dr(),1),Ji=e(Je(),1),Yi=new Set([`chat`,`settings`,`goal`,`kanban`,`sddhub`,`files`,`changes`,`sessions`,`setup`,`skill`,`officemap`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`]),Xi=new Set([`goal`,`fleet`,`work`,`worktrees`,`collab`]),Zi=new Set([`todos`,`tasks`,`plan`]);function Qi(){if(typeof window>`u`)return;let e=window.wrongstackDesktopHost;if(!e?.setPrefs)return;let t=z.getState();e.setPrefs({yolo:t.yolo,nextPrediction:t.nextPrediction,contextAutoCompact:t.contextAutoCompact})}function $i(e){typeof window>`u`||window.wrongstackDesktopHost?.setReady?.(e)}function ea(e,t,n){typeof window>`u`||typeof e!=`string`||window.wrongstackDesktopHost?.ackCommand?.(e,t,n)}var X=wn(),ta=qn,na=Zn,ra=Y.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,X.jsxs)(Fn,{ref:i,className:H(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent`,t&&`pl-8`,e),...r,children:[n,(0,X.jsx)(_t,{className:`ml-auto h-4 w-4`})]}));ra.displayName=Fn.displayName;var ia=Y.forwardRef(({className:e,...t},n)=>(0,X.jsx)(It,{ref:n,className:H(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));ia.displayName=It.displayName;var aa=Y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,X.jsx)(nr,{children:(0,X.jsx)(wt,{ref:r,sideOffset:t,className:H(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));aa.displayName=wt.displayName;var oa=Y.forwardRef(({className:e,inset:t,...n},r)=>(0,X.jsx)(He,{ref:r,className:H(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0`,t&&`pl-8`,e),...n}));oa.displayName=He.displayName;var sa=Y.forwardRef(({className:e,children:t,checked:n,...r},o)=>(0,X.jsxs)(gt,{ref:o,className:H(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,X.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,X.jsx)(i,{children:(0,X.jsx)(a,{className:`h-4 w-4`})})}),t]}));sa.displayName=gt.displayName;var ca=Y.forwardRef(({className:e,children:t,...n},r)=>(0,X.jsxs)(jn,{ref:r,className:H(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,X.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,X.jsx)(i,{children:(0,X.jsx)(k,{className:`h-2 w-2 fill-current`})})}),t]}));ca.displayName=jn.displayName;var la=Y.forwardRef(({className:e,inset:t,...n},r)=>(0,X.jsx)(Jt,{ref:r,className:H(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));la.displayName=Jt.displayName;var ua=Y.forwardRef(({className:e,...t},n)=>(0,X.jsx)(un,{ref:n,className:H(`-mx-1 my-1 h-px bg-muted`,e),...t}));ua.displayName=un.displayName;var da=({className:e,...t})=>(0,X.jsx)(`span`,{className:H(`ml-auto text-xs tracking-widest opacity-60`,e),...t});da.displayName=`DropdownMenuShortcut`;var fa=[{id:`chat`,icon:(0,X.jsx)(Hn,{size:16}),label:`Session`},{id:`files`,icon:(0,X.jsx)(mt,{size:16}),label:`Files`},{id:`changes`,icon:(0,X.jsx)(Te,{size:16}),label:`Changes`},{id:`mailbox`,icon:(0,X.jsx)(We,{size:16}),label:`Mailbox`},{id:`skills`,icon:(0,X.jsx)(ht,{size:16}),label:`Skills`},{id:`worktrees`,icon:(0,X.jsx)(je,{size:16}),label:`Worktrees`},{id:`design`,icon:(0,X.jsx)(F,{size:16}),label:`Design Studio`},{id:`officemap`,icon:(0,X.jsx)(on,{size:16}),label:`Office Map`}],pa=[{id:`settings`,icon:(0,X.jsx)(er,{size:16}),label:`Settings`},{id:`roster`,icon:(0,X.jsx)(bn,{size:16}),label:`Agent Roster`},{id:`sddhub`,icon:(0,X.jsx)(an,{size:16}),label:`SDD`},{id:`kanban`,icon:(0,X.jsx)(rt,{size:16}),label:`Kanban`},{id:`goal`,icon:(0,X.jsx)(nn,{size:16}),label:`Goal`},{id:`codemap`,icon:(0,X.jsx)(kr,{size:16}),label:`CodeMap`},{id:`techstack`,icon:(0,X.jsx)(Jn,{size:16}),label:`TechStack`},{id:`chronicle`,icon:(0,X.jsx)(Gt,{size:16}),label:`Chronicle`},{id:`intake`,icon:(0,X.jsx)(ke,{size:16}),label:`Requirements`},{id:`memory`,icon:(0,X.jsx)(Mn,{size:16}),label:`Memory`}],ma=[`chat`,`files`,`changes`,`mailbox`],ha=[...ma,`skills`,`worktrees`,`officemap`,`design`],ga=132,_a=38,va=165,ya=46;function ba(e,t){let n=fa.length+pa.length,r=Number.isFinite(e)?e:720,i=t?ga:va,a=t?_a:ya,o=Math.floor((r-i)/a);return Math.max(ma.length,Math.min(n,o))}function xa(e){let t=fa.length+pa.length,n=Math.max(ma.length,Math.min(t,Math.floor(e))),r=Math.min(fa.length,n),i=new Set(ha.slice(0,r)),a=fa.map(e=>e.id).filter(e=>i.has(e)),o=fa.map(e=>e.id).filter(e=>!i.has(e)),s=Math.max(0,n-a.length),c=pa.slice(0,s).map(e=>e.id),l=new Set(c);return{visiblePanelIds:a,overflowPanelIds:o,visibleViewIds:c,overflowViewIds:pa.map(e=>e.id).filter(e=>!l.has(e))}}var Sa=fa.map(e=>e.id);function Ca(){return typeof window>`u`?720:window.visualViewport?.height??window.innerHeight}function wa(e){let[t,n]=(0,Y.useState)(Ca);return(0,Y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>n(Ca());return e(),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e)}},[]),ba(t,e)}function Ta({desktopShell:e=!1}){let t=G(e=>e.activeActivity),n=G(e=>e.sidebarOpen),r=G(e=>e.currentView),i=U(e=>e.projectName),a=W(e=>e.wsConnected),{t:o}=R(),s=(e,t)=>o(`activity:nav.${e}`,t),c=wi(Ci),l=G(e=>e.inspectorOpen),u=wa(e),d=(0,Y.useMemo)(()=>xa(u),[u]),f=(0,Y.useMemo)(()=>new Set(d.visiblePanelIds),[d.visiblePanelIds]),p=(0,Y.useMemo)(()=>new Set(d.overflowPanelIds),[d.overflowPanelIds]),m=(0,Y.useMemo)(()=>new Set(d.visibleViewIds),[d.visibleViewIds]),h=(0,Y.useMemo)(()=>new Set(d.overflowViewIds),[d.overflowViewIds]),g=fa.filter(e=>f.has(e.id)),_=fa.filter(e=>p.has(e.id)),v=pa.filter(e=>m.has(e.id)),y=pa.filter(e=>h.has(e.id)),b=e=>{if(e===`mailbox`)return c||void 0};return(0,X.jsxs)(`div`,{className:H(`flex h-full min-h-0 shrink-0 flex-col border-r border-border/70 bg-card/75 backdrop-blur-xl`,e?`w-10`:`w-12`),children:[(0,X.jsx)(`div`,{className:`flex flex-col items-center shrink-0 border-b border-border/60`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>{K(`chat`)},title:i?o(`activity:brand.returnToChat`,{name:i}):o(`activity:brand.returnToChatDefault`),className:H(`relative flex items-center justify-center overflow-hidden bg-foreground transition-shadow hover:shadow-[0_3px_12px_-2px_hsl(var(--primary)/0.5)]`,e?`w-full h-8`:`w-full h-11`),children:(0,X.jsx)(`img`,{src:`/wrongstack.svg`,alt:``,"aria-hidden":`true`,draggable:!1,className:`ws-brand-logo h-full w-full`})})}),(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col items-center pt-2 pb-1`,children:[g.map(r=>(0,X.jsx)(Da,{compact:e,icon:r.icon,label:`${s(r.id,r.label)} (${Di(r.id)})`,active:n&&t===r.id,badge:b(r.id),onClick:()=>Oi(r.id)},r.id)),v.length>0&&(0,X.jsx)(`div`,{className:`my-1.5 h-px w-6 shrink-0 bg-border/70`}),v.map(t=>(0,X.jsx)(Da,{compact:e,icon:t.icon,label:s(t.id,t.label),active:r===t.id,onClick:()=>Ai(t.id)},t.id))]}),(0,X.jsx)(`div`,{role:`status`,"aria-label":a?o(`activity:connection.connected`,`Connected`):o(`activity:connection.disconnected`,`Disconnected`),className:`flex items-center justify-center py-1`,children:(0,X.jsx)(`span`,{className:H(`h-1.5 w-1.5 rounded-full`,a?`bg-success`:`bg-muted-foreground/40`),title:a?o(`activity:connection.connected`,`Connected`):o(`activity:connection.disconnected`,`Disconnected`)})}),(0,X.jsx)(`div`,{className:`flex flex-col items-center shrink-0 pt-1 pb-2 border-t border-border/60`,children:(0,X.jsx)(Ea,{compact:e,monitorOpen:l,overflowPanels:_,overflowViews:y})})]})}function Ea({compact:e=!1,monitorOpen:t,overflowPanels:n,overflowViews:r}){let{t:i}=R(),a=G(e=>e.activeActivity),o=G(e=>e.sidebarOpen),s=G(e=>e.currentView),c=G(e=>e.inspectorOpen),l=G(e=>e.inspectorTab),u=n.length+r.length,d=n.some(e=>o&&a===e.id),f=r.some(e=>s===e.id),p=d||f,m=e=>{let t=G.getState();t.inspectorOpen&&t.inspectorTab===e?t.setInspectorOpen(!1):(t.setInspectorTab(e),t.setInspectorOpen(!0))};return(0,X.jsxs)(ta,{children:[(0,X.jsx)(na,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"aria-label":u>0?i(`activity:menu.moreWithHidden`,{count:u}):i(`activity:menu.moreOptions`),title:e&&u>0?i(`activity:menu.moreCompactHidden`,{count:u}):i(e?`activity:menu.moreCompact`:`activity:menu.moreFull`),className:H(`ws-nav-button relative flex items-center justify-center rounded-md transition-colors`,e?`h-9 w-9`:`h-11 w-11`,`text-muted-foreground hover:border-border/70 hover:text-foreground hover:bg-muted/60`,`data-[state=open]:text-primary data-[state=open]:bg-primary/10 data-[state=open]:border-primary/30`,(t||p)&&`text-primary`),children:[(0,X.jsx)(`span`,{className:`h-5 w-5 flex items-center justify-center`,children:(0,X.jsx)(Tn,{size:16})}),u>0&&(0,X.jsx)(`span`,{className:H(`absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] flex items-center justify-center rounded px-1 text-[8px] font-bold leading-none tabular`,p?`bg-primary text-primary-foreground`:`bg-muted-foreground text-background`),children:u>9?`9+`:u}),t&&u===0&&(0,X.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-primary`})]})}),(0,X.jsxs)(aa,{side:`right`,align:`end`,sideOffset:8,className:`w-56`,children:[(0,X.jsxs)(oa,{onSelect:()=>G.getState().setPaletteOpen(!0),children:[(0,X.jsx)(pr,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:menu.commandPalette`)}),(0,X.jsx)(da,{children:`⌘K`})]}),(0,X.jsxs)(oa,{onSelect:()=>G.getState().setShortcutsOpen(!0),children:[(0,X.jsx)(jt,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:menu.keyboardShortcuts`)}),(0,X.jsx)(da,{children:`?`})]}),n.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ua,{}),(0,X.jsx)(la,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.panels`)}),n.map(e=>(0,X.jsxs)(oa,{onSelect:()=>K(e.id),children:[e.icon,(0,X.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),o&&a===e.id?(0,X.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,X.jsx)(da,{children:Di(e.id)})]},e.id))]}),r.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ua,{}),(0,X.jsx)(la,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.views`)}),r.map(e=>(0,X.jsxs)(oa,{onSelect:()=>Ai(e.id),children:[e.icon,(0,X.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),s===e.id&&(0,X.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`})]},e.id))]}),(0,X.jsx)(ua,{}),(0,X.jsx)(la,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:nav.settings`,`Settings`)}),(0,X.jsxs)(oa,{onSelect:()=>Ai(`settings`),children:[(0,X.jsx)(er,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:nav.settings`,`Settings`)}),(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:i(`settings:tabs.general`,`overview`)})]}),[{icon:(0,X.jsx)(F,{size:14}),label:`General`,tab:`general`},{icon:(0,X.jsx)(kr,{size:14}),label:`Provider`,tab:`provider`},{icon:(0,X.jsx)(bn,{size:14}),label:`Agent`,tab:`agent`},{icon:(0,X.jsx)(ar,{size:14}),label:`Execution`,tab:`execution`},{icon:(0,X.jsx)($t,{size:14}),label:`Fallbacks`,tab:`fallbacks`}].map(({icon:e,label:t,tab:n})=>(0,X.jsxs)(oa,{onSelect:()=>{G.getState().setSettingsActiveTab(n),Ai(`settings`)},children:[e,(0,X.jsx)(`span`,{children:i(`settings:tabs.${n}`,t)})]},n)),(0,X.jsx)(ua,{}),(0,X.jsx)(la,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.monitors`)}),(0,X.jsxs)(oa,{onSelect:()=>m(`fleet`),children:[(0,X.jsx)(rn,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:menu.fleetMonitor`)}),c&&l===`fleet`?(0,X.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,X.jsx)(da,{children:`⇧⌘M`})]}),(0,X.jsxs)(oa,{onSelect:()=>m(`sideEffects`),children:[(0,X.jsx)(ar,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:inspector.tabAudit`)}),c&&l===`sideEffects`?(0,X.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 rounded-full bg-primary`}):null]})]})]})}function Da({compact:e=!1,icon:t,label:n,active:r,badge:i,onClick:a}){return(0,X.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":n,title:n,className:H(`ws-nav-button relative flex shrink-0 items-center justify-center rounded-md transition-colors`,e?`h-9 w-9`:`h-11 w-11`,`text-muted-foreground hover:border-border/70 hover:text-foreground hover:bg-muted/60`,r&&`ws-nav-button-active`),children:[r&&(0,X.jsx)(`span`,{className:`absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-6 rounded-r-full bg-primary`}),(0,X.jsx)(`span`,{className:`h-5 w-5 shrink-0`,children:t}),i!==void 0&&i>0&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] flex items-center justify-center rounded bg-primary text-[8px] font-bold text-primary-foreground leading-none px-1 tabular`,children:i>99?`99+`:i})]})}var Oa=[{name:`/new`,category:`Session`,description:`Start a brand-new session (fresh on disk and in memory)`},{name:`/clear`,category:`Session`,description:`Wipe current context (keeps session id, disk record stays)`},{name:`/compact`,category:`Session`,description:`Shrink context — elide ancient tool output`},{name:`/compact!`,category:`Session`,description:`Aggressively shrink context now`},{name:`/repair`,category:`Session`,description:`Repair orphan tool-use / tool-result protocol blocks`},{name:`/save`,category:`Session`,description:`Force-flush the session (auto-saved already)`},{name:`/load`,category:`Session`,aliases:[`/resume`],description:`Resume a previous session from disk`},{name:`/export`,category:`Session`,description:`Download the current chat as markdown`},{name:`/debug`,category:`Inspect`,aliases:[`/context`],description:`Context size breakdown per section`},{name:`/tools`,category:`Inspect`,description:`List every registered tool the model can call`},{name:`/memory`,category:`Inspect`,description:`Manage memory: show, remember, forget, clear, stats`},{name:`/todos`,category:`Inspect`,description:`List current todos`},{name:`/stats`,category:`Inspect`,description:`Session stats: tokens, cost, elapsed`},{name:`/skill`,category:`Inspect`,aliases:[`/skills`],description:`List active skills`},{name:`/prompt`,category:`Inspect`,aliases:[`/prompts`],description:`Browse & insert prompts from the library`},{name:`/diag`,category:`Inspect`,description:`Runtime diagnostics (provider, tools, mode, usage)`},{name:`/agents`,category:`Inspect`,description:`Show status of spawned subagents`},{name:`/brain`,category:`Inspect`,description:`Brain status, risk ceiling (risk <level>), or decision support (ask <question>)`},{name:`/plan`,category:`Inspect`,description:`Strategic plan board: show, add, start, done, promote, clear`},{name:`/suggest`,category:`Inspect`,aliases:[`/next-steps`],description:`Ask the agent for concrete next steps`},{name:`/next`,category:`Inspect`,aliases:[`/enxt`],description:`Show or run numbered next-step suggestions`},{name:`/review`,category:`Agent`,aliases:[`/cr`],description:`Ask the agent to review the pending changes (optional focus)`},{name:`/fix`,category:`Agent`,description:`Diagnose and fix an error (paste it) or the latest failure`},{name:`/autonomy`,category:`Agent`,description:`Switch self-driving mode: off | suggest | auto | eternal | eternal-parallel`},{name:`/goal`,category:`Agent`,description:`Goal: start <title> | pause | resume | stop | status`},{name:`/goal-state`,category:`Agent`,description:`Show the current goal state (opens the Goal State dock chip)`},{name:`/fleet`,category:`Agent`,description:`Open the Fleet orchestration monitor`},{name:`/terminal`,category:`App`,aliases:[`/term`],description:"Open the integrated terminal (Ctrl+`)"},{name:`/collab`,category:`Agent`,description:`Open the live collaboration panel`},{name:`/worktree`,category:`Agent`,aliases:[`/worktrees`],description:`Open the worktree view`},{name:`/mode`,category:`Agent`,description:`Switch session mode (no arg lists available modes)`},{name:`/mcp`,category:`Agent`,description:`Open MCP server settings and refresh the server list`},{name:`/working-dir`,category:`Agent`,aliases:[`/cwd`],description:`Show or change the working directory`},{name:`/settings`,category:`Config`,aliases:[`/model`],description:`Open settings (provider/model/keys)`},{name:`/setup`,category:`Config`,description:`Open the provider setup screen to add or change API keys`},{name:`/doctor`,category:`Config`,description:`Check config defaults; use /doctor fix to repair and back up`},{name:`/enhance`,category:`Config`,description:`Toggle prompt refinement before sending`},{name:`/interrupt`,category:`Run`,aliases:[`/abort`,`/stop`,`/int`],description:`Stop the current run (abort the in-flight request)`},{name:`/help`,category:`App`,description:`Show every slash command and what it does`},{name:`/exit`,category:`App`,description:`Exit the session and close WebUI`},{name:`/f`,category:`App`,description:`Open F-key panels (F1–F12). Type /f for numbered options.`},{name:`/f1`,category:`App`,description:`Session panel`,hidden:!0},{name:`/f2`,category:`App`,description:`Fleet orchestration monitor`,hidden:!0},{name:`/f3`,category:`App`,description:`Agents live monitor`,hidden:!0},{name:`/f4`,category:`App`,description:`Worktree monitor`,hidden:!0},{name:`/f5`,category:`App`,description:`Plan panel`,hidden:!0},{name:`/f6`,category:`App`,description:`Todos monitor overlay`,hidden:!0},{name:`/f7`,category:`App`,description:`Queue panel`,hidden:!0},{name:`/f8`,category:`App`,description:`Process list overlay`,hidden:!0},{name:`/f9`,category:`App`,description:`Goal panel`,hidden:!0},{name:`/f10`,category:`App`,description:`Live sessions panel`,hidden:!0},{name:`/f11`,category:`App`,description:`Coordinator monitor`,hidden:!0},{name:`/f12`,category:`App`,description:`Status line picker`,hidden:!0}],ka=[`Run`,`Session`,`Inspect`,`Agent`,`Config`,`App`];function Aa(e){let t=e.toLowerCase();return t===`/`||t===``?Oa.filter(e=>!e.hidden):Oa.filter(e=>e.name.startsWith(t)||(e.aliases?.some(e=>e.startsWith(t))??!1))}function ja(e,n){let r=n-1;for(;r>=0;){let i=t(e[r]);if(i===`@`){let t=r>0?e[r-1]:``;return r===0||/\s/.test(t??``)?{start:r,query:e.slice(r+1,n)}:null}if(/\s/.test(i))return null;r--}return null}function Ma(e){let t=e.thinkingLog;if(!t)return``;if(t.replayed)return`replay`;let n=Math.max(.1,t.durationMs/1e3);return`${n.toFixed(+(n<10))}s`}function Na(e){let t=Math.max(3,...Array.from(e.matchAll(/`+/g),e=>e[0].length+1));return"`".repeat(t)}function Pa(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Fa(){let e=r.getState().messages,t=[],n=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),i=U.getState().projectName||`chat`,a=U.getState().session?.title||i;t.push(`# ${a} — chat export`),t.push(`*Exported: ${new Date().toISOString()}*`),t.push(``);for(let n of e)if(n.thinkingLog){let e=Na(n.thinkingLog.text),r=n.thinkingLog.text.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ws-client-TTMa0XaT.js","assets/rolldown-runtime-QTnfLwEv.js","assets/vendor-BuarzSSb.js","assets/monaco-BLUV5g0U.js","assets/monaco-Bowa0-zp.css","assets/markdown-sSmz-Ua_.js","assets/vendor-BMdWcCR4.css","assets/utils-B-9lSDIn.js","assets/session-store-Df7_hhe9.js","assets/ProcessMonitor-TGqyXxmB.js","assets/i18n-9T7iGYgW.js","assets/activity-BwEBEQ51.js","assets/chat-CdiY7G6Z.js","assets/commandPalette-DpaemFux.js","assets/common-COVxQ0FV.js","assets/settings-zIY9-ivF.js","assets/setup-BFcmn89w.js","assets/toasts-BL_8kH4B.js","assets/useWebSocket-CZSpbA3M.js","assets/chat-store-DbxFVDwi.js","assets/codemap-activity-store-DQfjo7-j.js","assets/stores-vuG0AaKy.js","assets/mailbox-store-C1mzoSqJ.js","assets/ui-store-CE4-TlwB.js","assets/view-navigation-DIDEcp4V.js","assets/codemap-index-store-COStDU-8.js","assets/Toaster-BgN2bRJx.js","assets/dialog-ftgTihmF.js","assets/AnalyticsDashboard-C9aPEyov.js","assets/AgentRosterView-BwukmHoA.js","assets/ModelPicker-IOZSUnqM.js","assets/roster-ws-Da57e_sI.js","assets/ChangesView-DumffowD.js","assets/empty-state-RRSqQaCk.js","assets/monaco-theme-DSeCDzQy.js","assets/ChronicleDashboard-BYGV5twz.js","assets/CodeEditor-D2Dnax7e.js","assets/MemoryDrawer-Dsy0AX6f.js","assets/button-Dcy288Mc.js","assets/shared-KAzksK0C.js","assets/CodeMap-DIKKs3Ux.js","assets/DebugDashboard-BI3EmXrM.js","assets/DesignGalleryView-DMW6Ab__.js","assets/GoalView-3291Hxnb.js","assets/ConfirmModal-CdKg3EOQ.js","assets/input-fo9-BPBC.js","assets/KanbanView-CFE63A4a.js","assets/progress-ring-B9pqitSa.js","assets/MailboxDetailView-CUTWkSyK.js","assets/OfficeMapPanel-Q81eioDB.js","assets/OfficeMapPanel-D6yTfGIT.css","assets/RefreshDebugView-DfBYFPEF.js","assets/SageTabs-olgLJfg_.js","assets/RequirementIntakeView-CNAFKiQ3.js","assets/SddHub-7Z55QY-M.js","assets/SpecsView-DUx1sgtH.js","assets/SessionsDashboard-CridPbkX.js","assets/SessionList-C3ygQN8A.js","assets/SessionInspectView-CytBw7Y9.js","assets/SkillDetailView-Cp-xEHww.js","assets/TechStackView-CvUiAISX.js","assets/DeadCodeScanPanel-DaeHUzc5.js","assets/SetupScreen-BkVjdky4.js","assets/TerminalPanel-Dg5hqYTA.js","assets/xterm-DUBp1lnG.js","assets/xterm-BrP-ENHg.css","assets/CronJobsPanel-CJ7Vc1Am.js","assets/QueuePanel-5aMgQbHv.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,r as n,t as r}from"./chat-store-DbxFVDwi.js";import{$ as i,$i as a,$n as o,$t as s,A as c,Ai as l,Ar as u,At as d,B as f,Br as p,Bt as m,C as h,Ca as g,Cn as _,Cr as v,D as y,Da as b,Di as x,Dn as S,Dr as C,Dt as w,E as T,En as E,Er as D,F as O,Fi as k,Fn as A,Ft as j,G as M,Gi as N,Gn as ee,Gr as te,Gt as ne,H as re,Hi as P,Hn as ie,Hr as ae,Ht as oe,I as se,Ii as ce,In as F,Ir as I,It as le,J as ue,Ji as de,Jn as fe,Jr as pe,Jt as me,K as he,Ki as ge,Kn as _e,Kt as ve,L as ye,La as L,Ln as be,Lr as xe,Lt as Se,M as Ce,Mn as we,Mr as Te,Mt as Ee,N as De,Na as Oe,Ni as ke,Nn as Ae,Nr as je,Nt as Me,O as Ne,Oa as Pe,On as Fe,Or as Ie,Ot as Le,P as Re,Pa as R,Pi as ze,Pn as Be,Pt as Ve,Q as He,Qi as Ue,Qn as We,Qr as Ge,Qt as Ke,R as qe,Ra as Je,Rr as Ye,Rt as Xe,Sa as Ze,Si as Qe,Sn as $e,Sr as et,St as tt,T as nt,Ti as rt,Tn as it,U as at,Ui as ot,Un as st,V as ct,Vn as lt,Vr as ut,W as dt,Wi as ft,Wn as pt,Wr as mt,Wt as ht,X as gt,Xi as _t,Xn as vt,Xr as yt,Y as bt,Yi as xt,Yn as St,Yr as Ct,Z as wt,Zi as Tt,Zn as Et,Zr as Dt,Zt as Ot,_a as kt,_i as At,_r as jt,_t as Mt,aa as Nt,ai as Pt,an as Ft,at as It,ba as Lt,bi as Rt,bn as zt,br as Bt,ci as Vt,da as Ht,di as Ut,dt as Wt,ea as Gt,ei as Kt,er as qt,et as Jt,fr as Yt,ft as Xt,gi as Zt,gn as Qt,gr as $t,gt as en,ha as tn,hn as nn,hr as rn,ht as an,ia as on,ii as sn,in as cn,ir as ln,it as un,j as dn,ja as fn,ji as pn,jr as mn,jt as hn,k as gn,kn as _n,kr as vn,kt as yn,la as bn,li as xn,ln as Sn,lr as Cn,lt as wn,mi as Tn,mn as En,mt as Dn,na as On,nn as kn,nr as An,nt as jn,oa as Mn,oi as Nn,or as Pn,ot as Fn,pa as In,pi as Ln,pn as Rn,pt as zn,q as Bn,qi as Vn,qn as Hn,qr as Un,ra as Wn,rn as Gn,rr as Kn,rt as qn,sa as Jn,sn as Yn,sr as Xn,st as Zn,ta as Qn,ti as $n,tn as er,tr,tt as nr,ui as rr,ur as ir,ut as ar,va as or,vi as sr,vn as cr,vr as lr,vt as ur,w as dr,wa as fr,wi as pr,wn as mr,wr as hr,wt as gr,xa as _r,xi as vr,xn as yr,xt as br,ya as xr,yi as Sr,yn as Cr,yr as wr,yt as Tr,z as Er,za as Dr,zi as Or,zn as kr,zt as Ar}from"./vendor-BuarzSSb.js";import{n as jr,t as z}from"./i18n-9T7iGYgW.js";import{s as B}from"./monaco-BLUV5g0U.js";import{a as Mr,c as Nr,i as Pr,l as Fr,n as Ir,o as Lr,r as Rr,s as zr,t as Br,u as Vr}from"./useWebSocket-CZSpbA3M.js";import{l as Hr,t as V}from"./ws-client-TTMa0XaT.js";import{t as H}from"./utils-B-9lSDIn.js";import{t as U}from"./session-store-Df7_hhe9.js";import{A as Ur,B as Wr,C as Gr,D as Kr,E as qr,H as Jr,I as W,L as Yr,M as Xr,N as Zr,O as Qr,P as $r,R as ei,S as ti,T as ni,U as ri,V as ii,_ as ai,b as oi,d as si,f as ci,g as li,h as ui,j as di,k as fi,l as pi,n as mi,o as hi,r as gi,t as _i,u as vi,w as yi,x as bi,y as xi,z as Si}from"./stores-vuG0AaKy.js";import{n as Ci,r as wi,t as Ti}from"./mailbox-store-C1mzoSqJ.js";import{n as G,t as Ei}from"./ui-store-CE4-TlwB.js";import{a as Di,i as Oi,n as ki,o as K,r as Ai,t as ji}from"./view-navigation-DIDEcp4V.js";import{n as q,t as Mi}from"./Toaster-BgN2bRJx.js";import{a as Ni,i as Pi,n as Fi,o as Ii,r as Li,t as Ri}from"./dialog-ftgTihmF.js";import{t as J}from"./button-Dcy288Mc.js";import{t as zi}from"./input-fo9-BPBC.js";import{i as Bi,n as Vi,r as Hi,t as Ui}from"./ConfirmModal-CdKg3EOQ.js";import{d as Wi,p as Gi}from"./markdown-sSmz-Ua_.js";import{n as Ki,t as qi}from"./ModelPicker-IOZSUnqM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Y=e(Dr(),1),Ji=e(Je(),1),Yi=new Set([`chat`,`settings`,`goal`,`kanban`,`sddhub`,`files`,`changes`,`sessions`,`setup`,`skill`,`officemap`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`]),Xi=new Set([`goal`,`fleet`,`work`,`worktrees`,`collab`]),Zi=new Set([`todos`,`tasks`,`plan`]);function Qi(){if(typeof window>`u`)return;let e=window.wrongstackDesktopHost;if(!e?.setPrefs)return;let t=z.getState();e.setPrefs({yolo:t.yolo,nextPrediction:t.nextPrediction,contextAutoCompact:t.contextAutoCompact})}function $i(e){typeof window>`u`||window.wrongstackDesktopHost?.setReady?.(e)}function ea(e,t,n){typeof window>`u`||typeof e!=`string`||window.wrongstackDesktopHost?.ackCommand?.(e,t,n)}var X=wn(),ta=qn,na=Zn,ra=Y.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,X.jsxs)(Fn,{ref:i,className:H(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent`,t&&`pl-8`,e),...r,children:[n,(0,X.jsx)(_t,{className:`ml-auto h-4 w-4`})]}));ra.displayName=Fn.displayName;var ia=Y.forwardRef(({className:e,...t},n)=>(0,X.jsx)(It,{ref:n,className:H(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));ia.displayName=It.displayName;var aa=Y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,X.jsx)(nr,{children:(0,X.jsx)(wt,{ref:r,sideOffset:t,className:H(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));aa.displayName=wt.displayName;var oa=Y.forwardRef(({className:e,inset:t,...n},r)=>(0,X.jsx)(He,{ref:r,className:H(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0`,t&&`pl-8`,e),...n}));oa.displayName=He.displayName;var sa=Y.forwardRef(({className:e,children:t,checked:n,...r},o)=>(0,X.jsxs)(gt,{ref:o,className:H(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,X.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,X.jsx)(i,{children:(0,X.jsx)(a,{className:`h-4 w-4`})})}),t]}));sa.displayName=gt.displayName;var ca=Y.forwardRef(({className:e,children:t,...n},r)=>(0,X.jsxs)(jn,{ref:r,className:H(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,X.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,X.jsx)(i,{children:(0,X.jsx)(k,{className:`h-2 w-2 fill-current`})})}),t]}));ca.displayName=jn.displayName;var la=Y.forwardRef(({className:e,inset:t,...n},r)=>(0,X.jsx)(Jt,{ref:r,className:H(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));la.displayName=Jt.displayName;var ua=Y.forwardRef(({className:e,...t},n)=>(0,X.jsx)(un,{ref:n,className:H(`-mx-1 my-1 h-px bg-muted`,e),...t}));ua.displayName=un.displayName;var da=({className:e,...t})=>(0,X.jsx)(`span`,{className:H(`ml-auto text-xs tracking-widest opacity-60`,e),...t});da.displayName=`DropdownMenuShortcut`;var fa=[{id:`chat`,icon:(0,X.jsx)(Hn,{size:16}),label:`Session`},{id:`files`,icon:(0,X.jsx)(mt,{size:16}),label:`Files`},{id:`changes`,icon:(0,X.jsx)(Te,{size:16}),label:`Changes`},{id:`mailbox`,icon:(0,X.jsx)(We,{size:16}),label:`Mailbox`},{id:`skills`,icon:(0,X.jsx)(ht,{size:16}),label:`Skills`},{id:`worktrees`,icon:(0,X.jsx)(je,{size:16}),label:`Worktrees`},{id:`design`,icon:(0,X.jsx)(F,{size:16}),label:`Design Studio`},{id:`officemap`,icon:(0,X.jsx)(on,{size:16}),label:`Office Map`}],pa=[{id:`settings`,icon:(0,X.jsx)(er,{size:16}),label:`Settings`},{id:`roster`,icon:(0,X.jsx)(bn,{size:16}),label:`Agent Roster`},{id:`sddhub`,icon:(0,X.jsx)(an,{size:16}),label:`SDD`},{id:`kanban`,icon:(0,X.jsx)(rt,{size:16}),label:`Kanban`},{id:`goal`,icon:(0,X.jsx)(nn,{size:16}),label:`Goal`},{id:`codemap`,icon:(0,X.jsx)(kr,{size:16}),label:`CodeMap`},{id:`techstack`,icon:(0,X.jsx)(Jn,{size:16}),label:`TechStack`},{id:`chronicle`,icon:(0,X.jsx)(Gt,{size:16}),label:`Chronicle`},{id:`intake`,icon:(0,X.jsx)(ke,{size:16}),label:`Requirements`},{id:`memory`,icon:(0,X.jsx)(Mn,{size:16}),label:`Memory`}],ma=[`chat`,`files`,`changes`,`mailbox`],ha=[...ma,`skills`,`worktrees`,`officemap`,`design`],ga=132,_a=38,va=165,ya=46;function ba(e,t){let n=fa.length+pa.length,r=Number.isFinite(e)?e:720,i=t?ga:va,a=t?_a:ya,o=Math.floor((r-i)/a);return Math.max(ma.length,Math.min(n,o))}function xa(e){let t=fa.length+pa.length,n=Math.max(ma.length,Math.min(t,Math.floor(e))),r=Math.min(fa.length,n),i=new Set(ha.slice(0,r)),a=fa.map(e=>e.id).filter(e=>i.has(e)),o=fa.map(e=>e.id).filter(e=>!i.has(e)),s=Math.max(0,n-a.length),c=pa.slice(0,s).map(e=>e.id),l=new Set(c);return{visiblePanelIds:a,overflowPanelIds:o,visibleViewIds:c,overflowViewIds:pa.map(e=>e.id).filter(e=>!l.has(e))}}var Sa=fa.map(e=>e.id);function Ca(){return typeof window>`u`?720:window.visualViewport?.height??window.innerHeight}function wa(e){let[t,n]=(0,Y.useState)(Ca);return(0,Y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>n(Ca());return e(),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e)}},[]),ba(t,e)}function Ta({desktopShell:e=!1}){let t=G(e=>e.activeActivity),n=G(e=>e.sidebarOpen),r=G(e=>e.currentView),i=U(e=>e.projectName),a=W(e=>e.wsConnected),{t:o}=R(),s=(e,t)=>o(`activity:nav.${e}`,t),c=wi(Ci),l=G(e=>e.inspectorOpen),u=wa(e),d=(0,Y.useMemo)(()=>xa(u),[u]),f=(0,Y.useMemo)(()=>new Set(d.visiblePanelIds),[d.visiblePanelIds]),p=(0,Y.useMemo)(()=>new Set(d.overflowPanelIds),[d.overflowPanelIds]),m=(0,Y.useMemo)(()=>new Set(d.visibleViewIds),[d.visibleViewIds]),h=(0,Y.useMemo)(()=>new Set(d.overflowViewIds),[d.overflowViewIds]),g=fa.filter(e=>f.has(e.id)),_=fa.filter(e=>p.has(e.id)),v=pa.filter(e=>m.has(e.id)),y=pa.filter(e=>h.has(e.id)),b=e=>{if(e===`mailbox`)return c||void 0};return(0,X.jsxs)(`div`,{className:H(`flex h-full min-h-0 shrink-0 flex-col border-r border-border/70 bg-card/75 backdrop-blur-xl`,e?`w-10`:`w-12`),children:[(0,X.jsx)(`div`,{className:`flex flex-col items-center shrink-0 border-b border-border/60`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>{K(`chat`)},title:i?o(`activity:brand.returnToChat`,{name:i}):o(`activity:brand.returnToChatDefault`),className:H(`relative flex items-center justify-center overflow-hidden bg-foreground transition-shadow hover:shadow-[0_3px_12px_-2px_hsl(var(--primary)/0.5)]`,e?`w-full h-8`:`w-full h-11`),children:(0,X.jsx)(`img`,{src:`/wrongstack.svg`,alt:``,"aria-hidden":`true`,draggable:!1,className:`ws-brand-logo h-full w-full`})})}),(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col items-center pt-2 pb-1`,children:[g.map(r=>(0,X.jsx)(Da,{compact:e,icon:r.icon,label:`${s(r.id,r.label)} (${Di(r.id)})`,active:n&&t===r.id,badge:b(r.id),onClick:()=>Oi(r.id)},r.id)),v.length>0&&(0,X.jsx)(`div`,{className:`my-1.5 h-px w-6 shrink-0 bg-border/70`}),v.map(t=>(0,X.jsx)(Da,{compact:e,icon:t.icon,label:s(t.id,t.label),active:r===t.id,onClick:()=>Ai(t.id)},t.id))]}),(0,X.jsx)(`div`,{role:`status`,"aria-label":a?o(`activity:connection.connected`,`Connected`):o(`activity:connection.disconnected`,`Disconnected`),className:`flex items-center justify-center py-1`,children:(0,X.jsx)(`span`,{className:H(`h-1.5 w-1.5 rounded-full`,a?`bg-success`:`bg-muted-foreground/40`),title:a?o(`activity:connection.connected`,`Connected`):o(`activity:connection.disconnected`,`Disconnected`)})}),(0,X.jsx)(`div`,{className:`flex flex-col items-center shrink-0 pt-1 pb-2 border-t border-border/60`,children:(0,X.jsx)(Ea,{compact:e,monitorOpen:l,overflowPanels:_,overflowViews:y})})]})}function Ea({compact:e=!1,monitorOpen:t,overflowPanels:n,overflowViews:r}){let{t:i}=R(),a=G(e=>e.activeActivity),o=G(e=>e.sidebarOpen),s=G(e=>e.currentView),c=G(e=>e.inspectorOpen),l=G(e=>e.inspectorTab),u=n.length+r.length,d=n.some(e=>o&&a===e.id),f=r.some(e=>s===e.id),p=d||f,m=e=>{let t=G.getState();t.inspectorOpen&&t.inspectorTab===e?t.setInspectorOpen(!1):(t.setInspectorTab(e),t.setInspectorOpen(!0))};return(0,X.jsxs)(ta,{children:[(0,X.jsx)(na,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"aria-label":u>0?i(`activity:menu.moreWithHidden`,{count:u}):i(`activity:menu.moreOptions`),title:e&&u>0?i(`activity:menu.moreCompactHidden`,{count:u}):i(e?`activity:menu.moreCompact`:`activity:menu.moreFull`),className:H(`ws-nav-button relative flex items-center justify-center rounded-md transition-colors`,e?`h-9 w-9`:`h-11 w-11`,`text-muted-foreground hover:border-border/70 hover:text-foreground hover:bg-muted/60`,`data-[state=open]:text-primary data-[state=open]:bg-primary/10 data-[state=open]:border-primary/30`,(t||p)&&`text-primary`),children:[(0,X.jsx)(`span`,{className:`h-5 w-5 flex items-center justify-center`,children:(0,X.jsx)(Tn,{size:16})}),u>0&&(0,X.jsx)(`span`,{className:H(`absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] flex items-center justify-center rounded px-1 text-[8px] font-bold leading-none tabular`,p?`bg-primary text-primary-foreground`:`bg-muted-foreground text-background`),children:u>9?`9+`:u}),t&&u===0&&(0,X.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-primary`})]})}),(0,X.jsxs)(aa,{side:`right`,align:`end`,sideOffset:8,className:`w-56`,children:[(0,X.jsxs)(oa,{onSelect:()=>G.getState().setPaletteOpen(!0),children:[(0,X.jsx)(pr,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:menu.commandPalette`)}),(0,X.jsx)(da,{children:`⌘K`})]}),(0,X.jsxs)(oa,{onSelect:()=>G.getState().setShortcutsOpen(!0),children:[(0,X.jsx)(jt,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:menu.keyboardShortcuts`)}),(0,X.jsx)(da,{children:`?`})]}),n.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ua,{}),(0,X.jsx)(la,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.panels`)}),n.map(e=>(0,X.jsxs)(oa,{onSelect:()=>K(e.id),children:[e.icon,(0,X.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),o&&a===e.id?(0,X.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,X.jsx)(da,{children:Di(e.id)})]},e.id))]}),r.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ua,{}),(0,X.jsx)(la,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.views`)}),r.map(e=>(0,X.jsxs)(oa,{onSelect:()=>Ai(e.id),children:[e.icon,(0,X.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),s===e.id&&(0,X.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`})]},e.id))]}),(0,X.jsx)(ua,{}),(0,X.jsx)(la,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:nav.settings`,`Settings`)}),(0,X.jsxs)(oa,{onSelect:()=>Ai(`settings`),children:[(0,X.jsx)(er,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:nav.settings`,`Settings`)}),(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:i(`settings:tabs.general`,`overview`)})]}),[{icon:(0,X.jsx)(F,{size:14}),label:`General`,tab:`general`},{icon:(0,X.jsx)(kr,{size:14}),label:`Provider`,tab:`provider`},{icon:(0,X.jsx)(bn,{size:14}),label:`Agent`,tab:`agent`},{icon:(0,X.jsx)(ar,{size:14}),label:`Execution`,tab:`execution`},{icon:(0,X.jsx)($t,{size:14}),label:`Fallbacks`,tab:`fallbacks`}].map(({icon:e,label:t,tab:n})=>(0,X.jsxs)(oa,{onSelect:()=>{G.getState().setSettingsActiveTab(n),Ai(`settings`)},children:[e,(0,X.jsx)(`span`,{children:i(`settings:tabs.${n}`,t)})]},n)),(0,X.jsx)(ua,{}),(0,X.jsx)(la,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.monitors`)}),(0,X.jsxs)(oa,{onSelect:()=>m(`fleet`),children:[(0,X.jsx)(rn,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:menu.fleetMonitor`)}),c&&l===`fleet`?(0,X.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,X.jsx)(da,{children:`⇧⌘M`})]}),(0,X.jsxs)(oa,{onSelect:()=>m(`sideEffects`),children:[(0,X.jsx)(ar,{size:16}),(0,X.jsx)(`span`,{children:i(`activity:inspector.tabAudit`)}),c&&l===`sideEffects`?(0,X.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 rounded-full bg-primary`}):null]})]})]})}function Da({compact:e=!1,icon:t,label:n,active:r,badge:i,onClick:a}){return(0,X.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":n,title:n,className:H(`ws-nav-button relative flex shrink-0 items-center justify-center rounded-md transition-colors`,e?`h-9 w-9`:`h-11 w-11`,`text-muted-foreground hover:border-border/70 hover:text-foreground hover:bg-muted/60`,r&&`ws-nav-button-active`),children:[r&&(0,X.jsx)(`span`,{className:`absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-6 rounded-r-full bg-primary`}),(0,X.jsx)(`span`,{className:`h-5 w-5 shrink-0`,children:t}),i!==void 0&&i>0&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] flex items-center justify-center rounded bg-primary text-[8px] font-bold text-primary-foreground leading-none px-1 tabular`,children:i>99?`99+`:i})]})}var Oa=[{name:`/new`,category:`Session`,description:`Start a brand-new session (fresh on disk and in memory)`},{name:`/clear`,category:`Session`,description:`Wipe current context (keeps session id, disk record stays)`},{name:`/compact`,category:`Session`,description:`Shrink context — elide ancient tool output`},{name:`/compact!`,category:`Session`,description:`Aggressively shrink context now`},{name:`/repair`,category:`Session`,description:`Repair orphan tool-use / tool-result protocol blocks`},{name:`/save`,category:`Session`,description:`Force-flush the session (auto-saved already)`},{name:`/load`,category:`Session`,aliases:[`/resume`],description:`Resume a previous session from disk`},{name:`/export`,category:`Session`,description:`Download the current chat as markdown`},{name:`/debug`,category:`Inspect`,aliases:[`/context`],description:`Context size breakdown per section`},{name:`/tools`,category:`Inspect`,description:`List every registered tool the model can call`},{name:`/memory`,category:`Inspect`,description:`Manage memory: show, remember, forget, clear, stats`},{name:`/todos`,category:`Inspect`,description:`List current todos`},{name:`/stats`,category:`Inspect`,description:`Session stats: tokens, cost, elapsed`},{name:`/skill`,category:`Inspect`,aliases:[`/skills`],description:`List active skills`},{name:`/prompt`,category:`Inspect`,aliases:[`/prompts`],description:`Browse & insert prompts from the library`},{name:`/diag`,category:`Inspect`,description:`Runtime diagnostics (provider, tools, mode, usage)`},{name:`/agents`,category:`Inspect`,description:`Show status of spawned subagents`},{name:`/brain`,category:`Inspect`,description:`Brain status, risk ceiling (risk <level>), or decision support (ask <question>)`},{name:`/plan`,category:`Inspect`,description:`Strategic plan board: show, add, start, done, promote, clear`},{name:`/suggest`,category:`Inspect`,aliases:[`/next-steps`],description:`Ask the agent for concrete next steps`},{name:`/next`,category:`Inspect`,aliases:[`/enxt`],description:`Show or run numbered next-step suggestions`},{name:`/review`,category:`Agent`,aliases:[`/cr`],description:`Ask the agent to review the pending changes (optional focus)`},{name:`/fix`,category:`Agent`,description:`Diagnose and fix an error (paste it) or the latest failure`},{name:`/autonomy`,category:`Agent`,description:`Switch self-driving mode: off | suggest | auto | eternal | eternal-parallel`},{name:`/goal`,category:`Agent`,description:`Goal: start <title> | pause | resume | stop | status`},{name:`/goal-state`,category:`Agent`,description:`Show the current goal state (opens the Goal State dock chip)`},{name:`/fleet`,category:`Agent`,description:`Open the Fleet orchestration monitor`},{name:`/terminal`,category:`App`,aliases:[`/term`],description:"Open the integrated terminal (Ctrl+`)"},{name:`/collab`,category:`Agent`,description:`Open the live collaboration panel`},{name:`/worktree`,category:`Agent`,aliases:[`/worktrees`],description:`Open the worktree view`},{name:`/mode`,category:`Agent`,description:`Switch session mode (no arg lists available modes)`},{name:`/mcp`,category:`Agent`,description:`Open MCP server settings and refresh the server list`},{name:`/working-dir`,category:`Agent`,aliases:[`/cwd`],description:`Show or change the working directory`},{name:`/settings`,category:`Config`,aliases:[`/model`],description:`Open settings (provider/model/keys)`},{name:`/setup`,category:`Config`,description:`Open the provider setup screen to add or change API keys`},{name:`/doctor`,category:`Config`,description:`Check config defaults; use /doctor fix to repair and back up`},{name:`/enhance`,category:`Config`,description:`Toggle prompt refinement before sending`},{name:`/interrupt`,category:`Run`,aliases:[`/abort`,`/stop`,`/int`],description:`Stop the current run (abort the in-flight request)`},{name:`/help`,category:`App`,description:`Show every slash command and what it does`},{name:`/exit`,category:`App`,description:`Exit the session and close WebUI`},{name:`/f`,category:`App`,description:`Open F-key panels (F1–F12). Type /f for numbered options.`},{name:`/f1`,category:`App`,description:`Session panel`,hidden:!0},{name:`/f2`,category:`App`,description:`Fleet orchestration monitor`,hidden:!0},{name:`/f3`,category:`App`,description:`Agents live monitor`,hidden:!0},{name:`/f4`,category:`App`,description:`Worktree monitor`,hidden:!0},{name:`/f5`,category:`App`,description:`Plan panel`,hidden:!0},{name:`/f6`,category:`App`,description:`Todos monitor overlay`,hidden:!0},{name:`/f7`,category:`App`,description:`Queue panel`,hidden:!0},{name:`/f8`,category:`App`,description:`Process list overlay`,hidden:!0},{name:`/f9`,category:`App`,description:`Goal panel`,hidden:!0},{name:`/f10`,category:`App`,description:`Live sessions panel`,hidden:!0},{name:`/f11`,category:`App`,description:`Coordinator monitor`,hidden:!0},{name:`/f12`,category:`App`,description:`Status line picker`,hidden:!0}],ka=[`Run`,`Session`,`Inspect`,`Agent`,`Config`,`App`];function Aa(e){let t=e.toLowerCase();return t===`/`||t===``?Oa.filter(e=>!e.hidden):Oa.filter(e=>e.name.startsWith(t)||(e.aliases?.some(e=>e.startsWith(t))??!1))}function ja(e,n){let r=n-1;for(;r>=0;){let i=t(e[r]);if(i===`@`){let t=r>0?e[r-1]:``;return r===0||/\s/.test(t??``)?{start:r,query:e.slice(r+1,n)}:null}if(/\s/.test(i))return null;r--}return null}function Ma(e){let t=e.thinkingLog;if(!t)return``;if(t.replayed)return`replay`;let n=Math.max(.1,t.durationMs/1e3);return`${n.toFixed(+(n<10))}s`}function Na(e){let t=Math.max(3,...Array.from(e.matchAll(/`+/g),e=>e[0].length+1));return"`".repeat(t)}function Pa(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Fa(){let e=r.getState().messages,t=[],n=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),i=U.getState().projectName||`chat`,a=U.getState().session?.title||i;t.push(`# ${a} — chat export`),t.push(`*Exported: ${new Date().toISOString()}*`),t.push(``);for(let n of e)if(n.thinkingLog){let e=Na(n.thinkingLog.text),r=n.thinkingLog.text.split(`
3
3
  `).length;t.push(`### 🧠 Thinking process — iteration ${n.thinkingLog.iteration}`),t.push(``),t.push(`_${Ma(n)} · ${r} line${r===1?``:`s`}_`),t.push(``),t.push(`<details><summary>Log</summary>`),t.push(``),t.push(`${e}text`),t.push(n.thinkingLog.text),t.push(e),t.push(``),t.push(`</details>`),t.push(``)}else if(n.role===`user`)t.push(`## 👤 User`),t.push(``),t.push(n.content),t.push(``);else if(n.role===`assistant`)t.push(`## 🤖 Assistant`),t.push(``),t.push(n.content),t.push(``);else if(n.role===`tool`){let e=n.isError?`❌`:n.toolResult===void 0?`⏳`:`✅`;t.push(`### 🔧 Tool: \`${n.toolName??`unknown`}\` ${e}`),n.toolInput!==void 0&&(t.push("```json"),t.push(JSON.stringify(n.toolInput,null,2)),t.push("```")),n.toolResult&&(t.push(`<details><summary>Output</summary>`),t.push(``),t.push("```"),t.push(n.toolResult),t.push("```"),t.push(`</details>`)),t.push(``)}let o=new Blob([t.join(`
4
4
  `)],{type:`text/markdown`}),s=URL.createObjectURL(o),c=document.createElement(`a`);c.href=s,c.download=`${i.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}-chat-${n}.md`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(s)}function Ia(){let e=r.getState().messages,t=U.getState(),n=t.projectName||`chat`,i=Pa(t.session?.title||n),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),o=e.map(e=>{if(e.thinkingLog){let t=e.thinkingLog.text.split(`
5
5
  `).length;return`
@@ -120,7 +120,7 @@ Type while the agent is running to queue messages; they are sent automatically w
120
120
  `):e.role===`tool`?[e.toolName??``,e.toolResult??``,JSON.stringify(e.toolInput??``)].join(`
121
121
  `):e.content}function Hd(){let{t:e}=R(),t=G(e=>e.searchOpen),n=G(e=>e.setSearchOpen),i=G(e=>e.searchQuery),a=G(e=>e.setSearchQuery),o=r(e=>e.messages),s=G(e=>e.requestScrollToMessage),c=G(e=>e.setSearchActiveMessageId),l=(0,Y.useRef)(null),[u,d]=(0,Y.useState)(0),[f,p]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{t&&requestAnimationFrame(()=>l.current?.focus())},[t]);let m=()=>{n(!1),requestAnimationFrame(()=>document.querySelector(`textarea`)?.focus())};(0,Y.useEffect)(()=>{let e=document.createElement(`style`);return e.textContent=Bd,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[]);let h=(0,Y.useMemo)(()=>{let e=i.trim().toLowerCase();return e?o.filter(t=>Vd(t).toLowerCase().includes(e)).map(e=>e.id):[]},[o,i]);(0,Y.useEffect)(()=>{u>=h.length&&d(0)},[h,u]),(0,Y.useEffect)(()=>{c(t&&i.trim()?h[u]??null:null)},[t,i,h,u,c]),(0,Y.useEffect)(()=>{let e=window,n=e.CSS?.highlights,r=e.Highlight;if(!n||!r)return;let a=()=>{n.delete(`chat-search`),n.delete(`chat-search-active`)},o=i.trim();if(!o||!t){a();return}let s=o.toLowerCase(),c=[],l=[],d=h[u];for(let e of document.querySelectorAll(`[data-message-id]`)){let t=e.dataset.messageId===d,n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=n.nextNode();for(;r;){let e=r.nodeValue??``;if(e.length>0){let n=e.toLowerCase(),i=0;for(;i<=n.length-s.length;){let e=n.indexOf(s,i);if(e===-1)break;let a=document.createRange();a.setStart(r,e),a.setEnd(r,e+s.length),c.push(a),t&&l.push(a),i=e+s.length}}r=n.nextNode()}}return c.length>0?n.set(`chat-search`,new r(...c)):n.delete(`chat-search`),l.length>0?n.set(`chat-search-active`,new r(...l)):n.delete(`chat-search-active`),a},[i,h,u,t,f]);let g=h[u];if((0,Y.useEffect)(()=>{if(!g)return;s(g);let e=0,t=requestAnimationFrame(function n(){p(e=>e+1),++e<3&&(t=requestAnimationFrame(n))});return()=>cancelAnimationFrame(t)},[g,s]),!t)return null;let _=e=>{h.length!==0&&d(t=>(t+e+h.length)%h.length)};return(0,X.jsx)(`div`,{className:`absolute top-2 right-4 z-30 w-[28rem] max-w-[calc(100%-2rem)] rounded-lg border bg-popover shadow-xl`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,X.jsx)(Ft,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,X.jsx)(`input`,{ref:l,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),m()):e.key===`Enter`?(e.preventDefault(),_(e.shiftKey?-1:1)):e.key===`ArrowDown`?(e.preventDefault(),_(1)):e.key===`ArrowUp`&&(e.preventDefault(),_(-1))},placeholder:e(`activity:search.placeholder`),className:`flex-1 bg-transparent outline-none text-sm placeholder:text-muted-foreground`}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums shrink-0`,children:h.length===0?i?`0`:``:`${u+1} / ${h.length}`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>_(-1),disabled:h.length===0,className:H(`p-1 rounded hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed`),title:e(`activity:search.prevHit`),"aria-label":e(`activity:search.prevHit`),children:(0,X.jsx)(tn,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>_(1),disabled:h.length===0,className:H(`p-1 rounded hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed`),title:e(`activity:search.nextHit`),"aria-label":e(`activity:search.nextHit`),children:(0,X.jsx)(Ze,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:m,className:`p-1 rounded hover:bg-muted text-muted-foreground`,title:e(`activity:search.close`),"aria-label":e(`activity:search.close`),children:(0,X.jsx)(Wt,{className:`h-3.5 w-3.5`})})]})})}function Ud(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(e<1e4?2:1)}s`:`${Math.floor(e/6e4)}m${Math.floor(e%6e4/1e3)}s`}var Wd=(0,Y.memo)(function({tools:e,defaultOpen:n=!1,isContinuation:r=!1}){let{t:i}=R(),[a,o]=(0,Y.useState)(n);if(e.length===1)return(0,X.jsx)(kd,{message:t(e[0]),isFirst:!0,isContinuation:r});let s=e.filter(e=>e.toolResult===void 0).length,c=e.filter(e=>e.isError).length,l=e.reduce((e,t)=>e+(t.toolDurationMs??0),0),u=Array.from(new Set(e.map(e=>e.toolName).filter(Boolean))),d=u.slice(0,3).join(`, `),f=u.length>3?` +${u.length-3}`:``;return(0,X.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[r?(0,X.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8`,"aria-hidden":!0}):(0,X.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-secondary text-secondary-foreground ring-2 ring-offset-2 ring-offset-background ring-secondary/20`,children:(0,X.jsx)(Me,{className:`h-4 w-4`})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] flex-1 min-w-0`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:H(`flex items-center gap-2 text-sm font-medium cursor-pointer select-none`,`hover:bg-muted/50 rounded-lg px-2 py-1.5 -mx-2 transition-colors`,`border border-border/40 bg-muted/30`),children:[a?(0,X.jsx)(Ue,{className:`h-3.5 w-3.5 text-muted-foreground`}):(0,X.jsx)(_t,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(Me,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`font-mono text-xs`,children:i(`activity:toolGroup.toolCalls`,{count:e.length})}),s>0?(0,X.jsx)(ln,{className:`h-3 w-3 animate-spin text-warning`}):c>0?(0,X.jsx)(ce,{className:`h-3 w-3 text-destructive`}):(0,X.jsx)(ft,{className:`h-3 w-3 text-success`}),l>0&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums font-normal`,children:Ud(l)}),d&&(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 font-mono truncate`,children:[`· `,d,f]})]}),a&&(0,X.jsx)(`div`,{className:`space-y-2 pl-3 border-l-2 border-border/40 ml-2 tool-details`,children:e.map(e=>(0,X.jsx)(kd,{message:e,isFirst:!1},e.id))})]})]})});function Gd(){let{t:e}=R(),{projectName:t,cwd:n}=U(fn(e=>({projectName:e.projectName,cwd:e.cwd}))),{provider:r,model:i}=W(fn(e=>({provider:e.provider,model:e.model}))),a=W(e=>e.wsConnected),o=W(e=>e.wsUrl),[s,c]=(0,Y.useState)(void 0);return(0,Y.useEffect)(()=>{if(!a)return;let e=V(o),t=e.on(`providers.saved`,e=>{let t=e.payload;c(t.providers?.length??0)});return e.listSavedProviders(),()=>{t()}},[a,o]),(0,X.jsxs)(`div`,{className:`flex flex-col gap-5 py-5 sm:py-7 max-w-6xl mx-auto w-full`,children:[(0,X.jsxs)(`div`,{className:`ws-surface relative overflow-hidden rounded-xl p-5 sm:p-6`,children:[(0,X.jsx)(`div`,{className:`absolute -top-24 -right-24 w-72 h-72 rounded-full bg-gradient-to-br from-primary/8 via-primary/5 to-transparent blur-3xl pointer-events-none`}),(0,X.jsx)(`div`,{className:`absolute -bottom-12 -left-12 w-48 h-48 rounded-full bg-gradient-to-tr from-accent/8 to-transparent blur-3xl pointer-events-none`}),(0,X.jsxs)(`div`,{className:`relative flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`img`,{src:`/wrongstack.svg`,alt:`WrongStack`,draggable:!1,className:`ws-brand-logo h-16 w-16 shrink-0 border border-border/70 shadow-sm shadow-primary/20 sm:h-20 sm:w-20`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:t?e(`setup:welcome.heroTitleInProject`,{name:t}):e(`setup:welcome.heroTitle`)}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground leading-relaxed`,children:e(`setup:welcome.heroSubtitle`)})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 pl-[76px] sm:pl-[92px]`,children:[r&&i&&(0,X.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground/80 font-mono`,children:[r,` / `,i]}),n&&(0,X.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground/75 font-mono`,title:n,children:e(`setup:welcome.workingDirectory`,{cwd:n})})]})]})]}),a&&s===0&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>Ai(`settings`),className:H(`group rounded-xl border bg-gradient-to-r from-warning/5 to-warning/[0.02]`,`border-warning/30 hover:border-warning/50 transition-all duration-200 shadow-sm`,`p-5 flex items-center gap-4 text-left animate-message`),children:[(0,X.jsx)(`span`,{className:`flex items-center justify-center w-11 h-11 rounded-lg bg-gradient-to-br from-warning/20 to-warning/10 text-warning shrink-0 shadow-sm shadow-warning/10`,children:(0,X.jsx)(wr,{className:`h-6 w-6`})}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`h3`,{className:`text-base font-semibold mb-1`,children:e(`setup:welcome.noKeyTitle`)}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:e(`setup:welcome.noKeyBody`)})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-warning font-medium shrink-0 group-hover:translate-x-0.5 transition-transform`,children:[e(`setup:welcome.openSettings`),` `,(0,X.jsx)(xr,{className:`h-3.5 w-3.5`})]})]})]})}function Kd(){let{t:e}=R(),t=r(e=>e.thinkingBuffer);if(!t)return null;let n=t.split(`
122
122
  `).slice(-6).join(`
123
- `).trim();return(0,X.jsxs)(`div`,{className:`flex gap-3 animate-message thinking-bubble`,"aria-live":`polite`,children:[(0,X.jsxs)(`div`,{className:`thinking-orb flex-shrink-0`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{className:`thinking-orb__ring`}),(0,X.jsx)(`span`,{className:`thinking-orb__ring thinking-orb__ring--delay`}),(0,X.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--one`}),(0,X.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--two`}),(0,X.jsx)(Nt,{className:`thinking-orb__icon h-4 w-4`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0`,children:[(0,X.jsxs)(`span`,{className:`thinking-label text-xs font-medium text-primary px-1`,children:[(0,X.jsx)(`span`,{children:e(`chat:thinking`)}),(0,X.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]})]}),(0,X.jsxs)(`div`,{className:`thinking-panel rounded-2xl rounded-bl-md px-3 py-2 border text-foreground/80`,children:[(0,X.jsxs)(`div`,{className:`thinking-wave`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]}),(0,X.jsx)(`pre`,{className:`thinking-text whitespace-pre-wrap break-words font-sans text-xs leading-relaxed italic max-h-32 overflow-hidden`,children:n||`…`})]})]})]})}function qd(e){let{hasMessages:t,autoCollapseInput:n,sessionChanged:r,prevHadMessages:i,prevAutoCollapse:a}=e;return n&&t&&(r||!i||!a)}function Jd({label:e,value:t,onChange:n}){return(0,X.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":t,onClick:n,className:`inline-flex items-center gap-1.5 text-[11px] text-muted-foreground/75 hover:text-foreground/80 transition-colors select-none`,children:[(0,X.jsx)(`span`,{className:H(`relative inline-block h-3.5 w-6 rounded-full border transition-colors shrink-0`,t?`bg-primary border-primary/60`:`bg-muted/70 border-border/60`),children:(0,X.jsx)(`span`,{className:H(`absolute top-[1px] left-[1px] h-2.5 w-2.5 rounded-full bg-background shadow transition-transform`,t&&`translate-x-2.5`)})}),(0,X.jsx)(`span`,{children:e})]})}var Yd=(0,Y.lazy)(()=>B(()=>import(`./ProcessMonitor-DPEMjjVq.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([9,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27]))),Xd=(0,Y.memo)(function({row:e,isLoading:t,compactMode:n,isFirstRow:r,groupToolCalls:i}){let a=H(`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6`,r&&`pt-4`,n?`pb-3`:`pb-6`);return e.kind===`day`?(0,X.jsx)(`div`,{className:a,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3 py-1 text-[11px] text-muted-foreground/70 uppercase tracking-wider font-medium`,children:[(0,X.jsx)(`div`,{className:`flex-1 h-px bg-border/50`}),(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(`div`,{className:`flex-1 h-px bg-border/50`})]})}):e.kind===`user`?(0,X.jsx)(`div`,{className:a,children:(0,X.jsx)(kd,{message:e.message,isFirst:!0})}):(0,X.jsx)(`div`,{className:a,children:(0,X.jsx)(`div`,{className:H(`chat-turn`,n?`space-y-1`:`space-y-1.5`),children:e.items.flatMap(n=>{if(n.kind===`msg`)return[(0,X.jsx)(kd,{message:n.message,isFirst:n.isFirst,isContinuation:n.isContinuation},n.key)];if(i){let r=e.isLastTurn&&n.isLastGroup&&t&&n.hasRunningTool;return[(0,X.jsx)(Wd,{tools:n.tools,defaultOpen:r,isContinuation:n.isContinuation},n.key)]}return n.tools.map(e=>(0,X.jsx)(kd,{message:e,isFirst:!1,isContinuation:n.isContinuation},e.id))})})})});function Zd(){let{t:e}=R(),t=r(e=>e.messages),n=r(e=>e.isLoading),i=G(e=>e.sidebarOpen),a=G(e=>e.toggleSidebar),o=G(e=>e.compactMode),{totalTokens:s,startTime:c,lastInputTokens:l,maxContext:u,contextLimitWarning:d,iteration:f}=U(fn(e=>({totalTokens:e.totalTokens,startTime:e.startTime,lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,contextLimitWarning:e.contextLimitWarning,iteration:e.iteration}))),p=U(e=>e.session),m=p?.id,h=G(e=>m?e.sessionNicknames[m]:void 0),g=G(e=>e.setSessionNickname),_=p?.title,[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(``),C=ui(e=>e.entries),[w,T]=(0,Y.useState)(!1),E=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!w)return;let e=e=>{E.current?.contains(e.target)||T(!1)},t=e=>{e.key===`Escape`&&T(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[w]);let{provider:O,model:k}=W(fn(e=>({provider:e.provider,model:e.model}))),A=(0,Y.useRef)(null),j=(0,Y.useMemo)(()=>bo(t),[t]),M=(0,Y.useRef)(0);M.current=j.length+1;let N=(0,Y.useMemo)(()=>{let e=new Map;return j.forEach((t,n)=>{if(t.kind===`user`)e.set(t.message.id,n);else if(t.kind===`agent`)for(let r of t.items)if(r.kind===`msg`)e.set(r.message.id,n);else for(let t of r.tools)e.set(t.id,n)}),e},[j]),ee=G(e=>e.scrollTarget),te=z(e=>e.autonomy),ne=z(e=>e.showThinkingLogs),re=z(e=>e.groupToolCalls),P=z(e=>e.autoCollapseInput),ie=(0,Y.useCallback)(e=>{z.getState().set({autonomy:e}),V()?.send?.({type:`autonomy.switch`,payload:{mode:e}})},[]),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[F,I]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(t.length>0&&P),de=(0,Y.useRef)(n),fe=(0,Y.useRef)(t.length>0),pe=(0,Y.useRef)(m),me=(0,Y.useRef)(P),[he,ge]=(0,Y.useState)(!1),[_e,ve]=(0,Y.useState)(!1),ye=Mr(e=>Object.values(e.contextMemories).filter(e=>e.state!==`exited`).length);(0,Y.useEffect)(()=>{let e=()=>I(!0);return window.addEventListener(`open:memory-panel`,e),()=>window.removeEventListener(`open:memory-panel`,e)},[]),(0,Y.useEffect)(()=>{let e=()=>ge(!0);return document.addEventListener(`open:context-breakdown`,e),()=>document.removeEventListener(`open:context-breakdown`,e)},[]),(0,Y.useEffect)(()=>{let e=()=>ve(!0);return document.addEventListener(`open:context-editor`,e),()=>document.removeEventListener(`open:context-editor`,e)},[]),(0,Y.useEffect)(()=>{let e=()=>ue(!1);return document.addEventListener(`chat:session-end`,e),document.addEventListener(`chat:next-step-countdown`,e),()=>{document.removeEventListener(`chat:session-end`,e),document.removeEventListener(`chat:next-step-countdown`,e)}},[]),(0,Y.useEffect)(()=>{de.current&&!n&&ue(!1),de.current=n},[n,ue]),(0,Y.useEffect)(()=>{let e=t.length>0,r=m!=null&&m!==pe.current;!n&&qd({hasMessages:e,autoCollapseInput:P,sessionChanged:r,prevHadMessages:fe.current,prevAutoCollapse:me.current})&&ue(!0),pe.current=m,fe.current=e,me.current=P},[t.length,P,m,n,ue]);let L=(0,Y.useCallback)(()=>{let e=!z.getState().autoCollapseInput;z.getState().set({autoCollapseInput:e}),e||ue(!1)},[ue]),be=u>0&&l>0?Math.min(100,Math.round(l/u*100)):0,[xe,Se]=(0,Y.useState)(!0),[we,Te]=(0,Y.useState)(0),[Ee,De]=(0,Y.useState)(!1),Oe=(0,Y.useRef)(t.length),ke=(0,Y.useCallback)(()=>{let e=A.current;if(!e)return;let t=e.scrollSize-e.scrollOffset-e.viewportSize<120;Se(t),t&&(Te(0),Oe.current=r.getState().messages.length),De(e.scrollOffset>e.viewportSize&&e.scrollSize>e.viewportSize*2.5)},[]),Ae=(0,Y.useCallback)(e=>{V()?.resumeSession?.(e),T(!1)},[]);(0,Y.useEffect)(()=>{let e=A.current;if(e)if(xe)e.scrollToIndex(M.current-1,{align:`end`}),Oe.current=t.length;else{let e=t.length-Oe.current;e>0&&Te(e)}},[t,xe]),(0,Y.useEffect)(()=>{Se(!0),Te(0),Oe.current=r.getState().messages.length,requestAnimationFrame(()=>{A.current?.scrollToIndex(M.current-1,{align:`end`})})},[m]),(0,Y.useEffect)(()=>{if(!ee)return;let e=N.get(ee.id);e!==void 0&&A.current?.scrollToIndex(e,{align:`center`,smooth:!0})},[ee,N]);let je=(0,Y.useCallback)(()=>{A.current?.scrollToIndex(M.current-1,{align:`end`,smooth:!0}),Se(!0),Te(0),Oe.current=r.getState().messages.length},[]),Ne=(0,Y.useCallback)(()=>{A.current?.scrollToIndex(0,{align:`start`,smooth:!0})},[]),[Fe,Ie]=(0,Y.useState)(null),[Re,ze]=(0,Y.useState)(()=>Date.now()),Ve=(0,Y.useRef)(null),He=(0,Y.useMemo)(()=>{let n=t[t.length-1],r=t.filter(e=>e.role===`tool`&&e.toolResult===void 0),i=e(`activity:chatView.thinking`);if(r.length>0){let t=Array.from(new Set(r.map(e=>e.toolName).filter(Boolean))),n=t.slice(0,2).join(`, `),a=t.length>2?` +${t.length-2}`:``;i=r.length===1?e(`activity:chatView.runningTool`,{tool:n||e(`activity:chatView.toolWord`)}):e(`activity:chatView.runningTools`,{count:r.length,preview:`${n}${a}`})}else n?.role===`assistant`&&n.content?i=e(`activity:chatView.writingReply`):n?.role===`tool`&&n.toolResult!==void 0&&(i=e(`activity:chatView.thinkingNextStep`));let a=Fe?Math.max(0,Math.floor((Re-Fe)/1e3)):0,o=a<60?`${a}s`:`${Math.floor(a/60)}m ${a%60}s`,s=``,c=n?.role===`assistant`&&n.streaming&&n.content?n:null;if(c){let e=Ve.current;if(!e||e.id!==c.id)Ve.current={id:c.id,at:Date.now(),len:c.content.length};else{let t=Math.max(1,Re-e.at),n=Math.max(0,c.content.length-e.len);if(t>500&&n>0){let e=n*1e3/t;s=e>=1e3?`${(e/1e3).toFixed(1)}k ch/s`:`${Math.round(e)} ch/s`}}}else Ve.current&&=null;return{label:i,elapsed:o,speedLabel:s}},[t,Re,Fe]);(0,Y.useEffect)(()=>{n&&Fe===null&&Ie(Date.now()),!n&&Fe!==null&&Ie(null)},[n,Fe]),(0,Y.useEffect)(()=>{if(!n)return;let e=setInterval(()=>ze(Date.now()),500);return()=>clearInterval(e)},[n]);let We=e=>{if(!e)return`--`;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`},Ge=(()=>{if(!n)return`idle`;let e=t[t.length-1];return e?.role===`assistant`&&e.content&&e.streaming?`streaming`:`thinking`})(),Ke=Ge===`idle`?`bg-muted text-muted-foreground`:Ge===`streaming`?`bg-primary/10 text-primary`:`bg-warning/10 text-warning`,qe=u>0&&l>0||s.input>0||!!c;return(0,X.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 bg-[hsl(var(--surface-2)/0.45)]`,children:[(0,X.jsxs)(`header`,{className:`flex flex-col border-b border-border/70 bg-card/90 backdrop-blur-xl supports-[backdrop-filter]:bg-card/80 shrink-0 sticky top-0 z-20 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-2 sm:px-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_18rem] items-center gap-1.5 overflow-hidden`,children:[!i&&(0,X.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:a,title:e(`chat:header.openSidebarTitle`),children:(0,X.jsx)(Be,{className:`h-4 w-4`})}),!i&&(0,X.jsx)(`div`,{className:`flex items-center gap-1.5 shrink-0 mr-1`,children:(0,X.jsx)(`div`,{className:`w-5 h-5 rounded-md bg-primary flex items-center justify-center`,children:(0,X.jsx)(ar,{className:`h-3 w-3 text-primary-foreground`})})}),(0,X.jsxs)(`span`,{className:H(`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[11px] font-medium shrink-0 tabular-nums`,Ke),title:`Agent state: ${Ge}`,children:[Ge!==`idle`&&(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-current animate-pulse`}),(0,X.jsx)(`span`,{children:Ge})]}),m&&(v?(0,X.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),onBlur:()=>{b.trim()&&g(m,b),y(!1)},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),b.trim()&&g(m,b),y(!1)):e.key===`Escape`&&(e.preventDefault(),y(!1))},placeholder:e(`chat:sessionNamePlaceholder`),className:`h-6 px-1.5 text-[11px] bg-background border border-primary/40 rounded-md focus:outline-none focus:ring-1 focus:ring-ring shrink-0 w-36`}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{x(h||_||``),y(!0)},className:`flex items-center gap-1 text-[11px] font-medium text-foreground/80 hover:text-foreground truncate max-w-[12rem] shrink-0 px-1 -mx-1 rounded-md hover:bg-muted/50 transition-colors`,title:e(`chat:header.renameTitle`),children:[(0,X.jsx)(S,{className:`h-2.5 w-2.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:h||_||e(`chat:header.untitled`)})]}))]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-[0_1_auto] flex-wrap items-center justify-end gap-1.5`,children:[C.length>1&&(0,X.jsxs)(`div`,{ref:E,className:`relative shrink-0`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>T(e=>!e),className:`flex items-center gap-0.5 px-1 py-0.5 rounded-md text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors`,title:e(`chat:switchSession`),children:[(0,X.jsx)(D,{className:`h-3 w-3`}),(0,X.jsx)(Ue,{className:`h-2.5 w-2.5`})]}),w&&(0,X.jsx)(`div`,{className:`absolute left-0 top-full mt-1 z-40 w-64 rounded-md border border-border/70 bg-popover shadow-xl p-1 max-h-60 overflow-y-auto`,children:C.slice(0,15).map(t=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>Ae(t.id),className:H(`w-full text-left px-2 py-1.5 rounded text-xs hover:bg-accent transition-colors`,t.isCurrent&&`bg-primary/10`),children:[(0,X.jsx)(`div`,{className:`font-medium truncate`,children:t.title||e(`chat:empty`)}),(0,X.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono truncate`,children:[t.provider,`/`,t.model,` · `,t.tokenTotal.toLocaleString(),` tok`]})]},t.id))})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>G.getState().setModelSwitcherOpen(!0),className:`group hidden sm:flex items-center gap-1 px-2 py-0.5 rounded-md border border-border/70 bg-background/60 hover:bg-accent/70 hover:border-primary/40 transition-colors text-[11px] min-w-0 shrink-0`,title:e(`chat:header.changeModelTitle`),children:[(0,X.jsx)(Rt,{className:`h-3 w-3 text-muted-foreground group-hover:text-foreground shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono truncate max-w-[9rem] xl:max-w-[16rem]`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:O||e(`chat:header.noProvider`)}),(0,X.jsx)(`span`,{className:`text-muted-foreground/65 mx-0.5`,children:`/`}),(0,X.jsx)(`span`,{className:`font-medium`,children:k||e(`chat:header.noModel`)})]})]}),(0,X.jsxs)(`div`,{className:`hidden md:flex items-center gap-1.5 shrink-0`,children:[(0,X.jsx)(Ad,{}),(0,X.jsx)(Ou,{})]}),f&&(0,X.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[11px] font-medium bg-primary/10 text-primary shrink-0 hover:bg-primary/20 transition-colors cursor-pointer`,title:e(`chat:header.iterationTitle`),onClick:()=>document.getElementById(`chat-activity`)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:[(0,X.jsx)(Pe,{className:`h-3 w-3 animate-pulse`}),`iter `,f.index,f.max>0?`/${f.max}`:``]}),(0,X.jsx)(Fl,{value:te,onChange:ie,compact:!0})]}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 shrink-0`,children:[(0,X.jsxs)(J,{variant:F?`secondary`:`ghost`,size:`icon`,className:H(`h-7 w-7 relative`,F&&`bg-primary/10 text-primary`),onClick:()=>I(e=>!e),title:e(`chat:header.memoryContextTitle`,`Memory context`),children:[(0,X.jsx)(Nt,{className:`h-4 w-4`}),ye>0&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-3.5 h-3.5 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold flex items-center justify-center tabular-nums`,children:ye}),F&&(0,X.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-primary`})]}),(0,X.jsxs)(J,{variant:ae?`secondary`:`ghost`,size:`icon`,className:H(`h-7 w-7 relative`,ae&&`bg-warning/10 text-warning`),onClick:()=>oe(e=>!e),title:e(`chat:header.runningProcessesTitle`),children:[(0,X.jsx)(Me,{className:`h-4 w-4`}),ae&&(0,X.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-warning`})]}),(0,X.jsxs)(J,{variant:se?`secondary`:`ghost`,size:`icon`,className:H(`h-7 w-7 relative`,se&&`bg-primary/10 text-primary`),onClick:()=>ce(e=>!e),title:e(`chat:header.checkpointsTitle`),children:[(0,X.jsx)(D,{className:`h-4 w-4`}),se&&(0,X.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-primary`})]})]})]}),qe&&(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 overflow-x-auto border-t border-border/60 bg-muted/20 px-3 py-1 text-[11px] text-muted-foreground sm:px-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-max items-center gap-3 tabular-nums`,children:[l>0&&(0,X.jsx)(Ao,{pct:be,tokens:l,maxTokens:u>0?u:void 0,onClick:()=>ge(!0)}),d&&(0,X.jsxs)(`span`,{role:`status`,className:`inline-flex items-center gap-1 rounded-md border border-warning/40 bg-warning/10 px-2 py-0.5 font-medium text-warning`,title:e(`activity:chatView.providerLimitDecreased`,{previous:d.previousMaxContext.toLocaleString(),current:d.maxContext.toLocaleString()}),children:[(0,X.jsx)(Le,{className:`h-3 w-3`}),e(`activity:chatView.providerLimit`,{limit:_o(d.maxContext)})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ve(!0),className:`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[11px] text-muted-foreground/70 hover:text-foreground hover:bg-accent transition-colors shrink-0`,title:e(`activity:chatView.editContextWindow`),children:[(0,X.jsx)(an,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:e(`activity:chatView.edit`)})]}),s.input>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:_o(s.input)}),(0,X.jsx)(`span`,{children:`in`})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:_o(s.output)}),(0,X.jsx)(`span`,{children:`out`})]}),s.cacheRead&&s.cacheRead>0&&(()=>{let e=(s.cacheRead??0)+s.input,t=e>0?Math.round((s.cacheRead??0)/e*100):0;return(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,title:`Cache hit ratio: ${t}%`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:_o(s.cacheRead)}),(0,X.jsxs)(`span`,{children:[`cache (`,t,`%)`]})]})})(),(0,X.jsx)(ku,{})]})]}),c&&(0,X.jsx)(`span`,{className:`text-muted-foreground/70 tabular-nums shrink-0`,children:We(c)})]})]}),(0,X.jsxs)(`div`,{className:`relative mx-2 mt-2 min-h-0 min-w-0 flex-1 overflow-hidden rounded-xl border border-border/70 bg-card/55 shadow-sm sm:mx-3 lg:mx-4 lg:mt-3`,children:[(0,X.jsx)(Hd,{}),!xe&&(0,X.jsxs)(`button`,{type:`button`,onClick:je,className:H(`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 jump-bottom`,`flex items-center gap-2 px-4 py-2 rounded-md shadow-lg`,`bg-primary text-primary-foreground text-xs font-medium`,`hover:bg-primary/90 transition-colors animate-message`),children:[(0,X.jsx)(Ze,{className:`h-3.5 w-3.5`}),we>0?`${we} new message${we===1?``:`s`}`:`Jump to latest`]}),Ee&&(0,X.jsxs)(`button`,{type:`button`,onClick:Ne,title:e(`chat:header.scrollTopTitle`),className:H(`absolute top-3 right-3 z-10`,`flex items-center gap-1 px-2.5 py-1 rounded-md shadow-md border`,`bg-background/90 backdrop-blur-sm text-[11px] text-muted-foreground`,`hover:text-foreground hover:bg-background transition-colors animate-message`),children:[(0,X.jsx)(tn,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:e(`activity:chatView.top`)})]}),j.length===0&&!n?(0,X.jsx)(`div`,{className:`h-full overflow-y-auto overscroll-contain`,children:(0,X.jsx)(`div`,{className:`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6 pt-4 pb-8`,children:(0,X.jsx)(Gd,{})})}):(0,X.jsxs)(Ce,{ref:A,className:`h-full`,onScroll:ke,role:`log`,"aria-label":e(`activity:chatView.chatTranscript`),"aria-live":`polite`,children:[j.map((e,t)=>(0,X.jsx)(Xd,{row:e,isLoading:n,compactMode:o,isFirstRow:t===0,groupToolCalls:re},e.key)),(0,X.jsxs)(`div`,{id:`chat-activity`,className:H(`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6`,o?`pb-3`:`pb-8`),children:[(0,X.jsx)(Kd,{}),n&&(0,X.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,X.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,X.jsx)(bn,{className:`h-4 w-4`})}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,X.jsx)(`div`,{className:`rounded-lg px-4 py-3 bg-card border border-border/70 text-foreground shadow-sm`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.3s]`}),(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.15s]`}),(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce`})]}),(0,X.jsx)(`span`,{className:`text-foreground/90`,children:He.label}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:He.elapsed}),f&&(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`· iter `,f.index,f.max>0?`/${f.max}`:``]}),He.speedLabel&&(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 tabular-nums`,children:[`· `,He.speedLabel]})]})})})]})]},`__live`)]})]}),(0,X.jsx)(`div`,{className:`shrink-0 bg-[hsl(var(--surface-2)/0.45)] px-2 pb-2 pt-2 sm:px-3 lg:px-4 lg:pb-3`,children:le&&t.length>0?(0,X.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/60 bg-card/40 px-3 py-1.5 hover:bg-card/70 hover:border-border/80 transition-colors`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ue(!1),className:`flex flex-1 items-center gap-2 text-xs text-muted-foreground/60 hover:text-foreground/80 transition-colors`,children:[(0,X.jsx)(xt,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{children:e(`chat:input.expandInput`,`Expand input`)}),j.length>0&&(0,X.jsxs)(`span`,{className:`ml-auto tabular-nums text-[10px] text-muted-foreground/40`,children:[j.length,` msgs · `,_o(s.input+s.output)]})]}),(0,X.jsx)(Jd,{label:e(`activity:chatView.autoCollapse`),value:P,onChange:L})]}):(0,X.jsxs)(X.Fragment,{children:[t.length>0&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ue(!0),className:`mb-1 flex w-full items-center gap-1.5 rounded px-2 py-0.5 text-[10px] text-muted-foreground/50 hover:text-muted-foreground/80 transition-colors`,children:[(0,X.jsx)(Ue,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:e(`chat:input.collapseInput`,`Collapse`)})]}),(0,X.jsx)(zd,{}),(0,X.jsxs)(`div`,{className:`ws-display-toggles flex max-w-6xl mx-auto px-2 pb-1.5 items-center gap-3 text-[11px] text-muted-foreground/75 select-none overflow-x-auto min-h-[1.75rem]`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,X.jsx)(Jd,{label:e(`activity:chatView.reasoning`),value:ne,onChange:()=>{z.getState().set({showThinkingLogs:!z.getState().showThinkingLogs})}}),(0,X.jsx)(`span`,{className:`opacity-30`,children:`|`}),(0,X.jsx)(Jd,{label:e(`activity:chatView.groupTools`),value:re,onChange:()=>{z.getState().set({groupToolCalls:!z.getState().groupToolCalls})}}),(0,X.jsx)(`span`,{className:`opacity-30`,children:`|`}),(0,X.jsx)(Jd,{label:e(`activity:chatView.compact`),value:o,onChange:()=>G.getState().toggleCompactMode()}),(0,X.jsx)(`span`,{className:`opacity-30`,children:`|`}),(0,X.jsx)(Jd,{label:e(`activity:chatView.autoCollapse`),value:P,onChange:L})]}),qe&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`opacity-20 grow min-w-[1rem]`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 tabular-nums text-[10px] text-muted-foreground/70 shrink-0`,children:[s.input>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,title:`${s.input.toLocaleString()} tokens in`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground/80`,children:_o(s.input)}),(0,X.jsx)(`span`,{className:`text-[9px]`,children:`in`})]}),s.output>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,title:`${s.output.toLocaleString()} tokens out`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground/80`,children:_o(s.output)}),(0,X.jsx)(`span`,{className:`text-[9px]`,children:`out`})]}),j.length>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,title:e(`activity:chatView.messages`),children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground/80`,children:j.length}),(0,X.jsx)(`span`,{className:`text-[9px]`,children:`msgs`})]}),f?.index&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-primary/70`,title:e(`activity:chatView.currentIteration`),children:[(0,X.jsx)(`span`,{className:`font-medium`,children:f.index}),(0,X.jsx)(`span`,{className:`text-[9px]`,children:`iter`})]}),c&&(0,X.jsx)(`span`,{className:`tabular-nums text-muted-foreground/50`,children:We(c)})]})]}),(0,X.jsx)(`span`,{className:`opacity-20 ml-2 text-[9px] shrink-0`,children:(0,X.jsx)(`kbd`,{className:`font-mono text-[9px] border rounded px-1 py-0.5 bg-muted/40`,children:`?`})})]}),(0,X.jsx)(`div`,{className:`ws-chat-input-wrap p-0`,children:(0,X.jsx)(`div`,{className:`max-w-6xl mx-auto`,children:(0,X.jsx)(Tu,{onOpenBreakdown:()=>ge(!0)})})})]})}),(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Yd,{open:ae,onClose:()=>oe(!1)})}),(0,X.jsx)(Du,{open:se,onClose:()=>ce(!1)}),(0,X.jsx)(Ds,{open:he,onClose:()=>ge(!1)}),(0,X.jsx)(Wu,{open:_e,onClose:()=>ve(!1)}),(0,X.jsx)(Nl,{open:F,onClose:()=>I(!1)})]})}function Qd(e,t=!0){let n=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let i=requestAnimationFrame(()=>{let t=G.getState().scrollPositions[e];typeof t==`number`&&t>0&&(r.scrollTop=t)});return()=>cancelAnimationFrame(i)},[]),(0,Y.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let{setScrollPosition:i}=G.getState();return()=>{i(e,r.scrollTop)}},[e]),n}function $d(){let{t:e}=R(),t=Mr(e=>e.contextMemories),n=Mr(e=>e.transitions),r=Object.values(t).sort((e,t)=>t.lastSeenAt.localeCompare(e.lastSeenAt)),i=r.filter(e=>e.state===`active`),a=r.filter(e=>e.state===`injected`),o=r.filter(e=>e.state===`exited`);return(0,X.jsxs)(`section`,{className:`rounded-md border border-primary/20 bg-primary/[0.025]`,"aria-label":e(`activity:ctxMonitor.contextMemoryMonitor`),children:[(0,X.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2`,children:[(0,X.jsx)(Mn,{className:`size-4 text-primary`}),(0,X.jsx)(`h2`,{className:`text-xs font-semibold`,children:e(`activity:ctxMonitor.contextMemoryMonitor`)}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`activity:ctxMonitor.exactProviderBoundPresence`)}),(0,X.jsxs)(`div`,{className:`ml-auto flex gap-2 font-mono text-[10px]`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[i.length,` ctx`]}),(0,X.jsxs)(`span`,{className:`text-warning`,children:[a.length,` pending`]}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[o.length,` left`]})]})]}),r.length===0?(0,X.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:e(`activity:ctxMonitor.noSageHasEnteredThisSession`)}):(0,X.jsxs)(`div`,{className:`grid gap-3 p-3 xl:grid-cols-[minmax(0,2fr)_minmax(260px,1fr)]`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wide text-muted-foreground`,children:e(`activity:ctxMonitor.memoryPresence`)}),r.slice(0,20).map(e=>(0,X.jsxs)(`article`,{className:H(`border px-3 py-2 text-[10px]`,e.state===`exited`?`border-border/50 bg-muted/20 opacity-65`:`border-primary/25 bg-background/55`),children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:H(`border px-1.5 py-0.5 font-bold uppercase`,e.state===`exited`?`border-border text-muted-foreground`:e.state===`active`?`border-success/35 text-success`:`border-warning/35 text-warning`),children:e.state}),(0,X.jsx)(`span`,{className:`font-mono font-bold text-primary`,children:e.id}),(0,X.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[e.kind,` · `,e.persistence]}),(0,X.jsxs)(`span`,{className:`ml-auto font-mono text-muted-foreground`,children:[`score `,e.score.toFixed(2),` · conf `,e.confidence.toFixed(2),` · fresh`,` `,e.freshness.toFixed(2)]})]}),(0,X.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-foreground`,children:e.text}),(0,X.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`why: `,e.activationReasons.join(` · `)||`context snapshot`]}),(e.anchors.length>0||e.tags.length>0)&&(0,X.jsx)(`p`,{className:`mt-1 truncate font-mono text-muted-foreground`,title:[...e.anchors,...e.tags.map(e=>`#${e}`)].join(` · `),children:[...e.anchors,...e.tags.map(e=>`#${e}`)].join(` · `)})]},e.id))]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wide text-muted-foreground`,children:e(`activity:ctxMonitor.cameWent`)}),n.slice(0,30).map(e=>(0,X.jsxs)(`div`,{className:`flex gap-2 border-b border-border/40 py-1.5 text-[10px] last:border-b-0`,children:[e.action===`exited`?(0,X.jsx)(kt,{className:`mt-0.5 size-3 shrink-0 text-muted-foreground`}):(0,X.jsx)(g,{className:`mt-0.5 size-3 shrink-0 text-success`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`p`,{className:`font-mono`,children:[(0,X.jsx)(`span`,{className:e.action===`exited`?`text-muted-foreground`:`text-success`,children:e.action}),` `,e.memoryId]}),(0,X.jsx)(`p`,{className:`truncate text-muted-foreground`,children:e.reason})]}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-muted-foreground`,children:[(0,X.jsx)(pn,{className:`size-2.5`}),` `,new Date(e.at).toLocaleTimeString()]})]},e.id))]})]})]})}function ef(){let{t:e}=R(),t=Pr(e=>e.items),n=Pr(e=>e.clear);return(0,X.jsxs)(`section`,{className:`shrink-0 border-b border-border/60 bg-info/[0.025]`,"aria-label":e(`activity:memoryManager.lifecycleAria`),children:[(0,X.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-4`,children:[(0,X.jsx)(Pe,{className:`size-3.5 text-info`}),(0,X.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wide text-info`,children:e(`activity:memoryManager.lifecycleHeading`)}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:t.length===0?e(`activity:memoryManager.statusWaiting`):e(`activity:memoryManager.statusLive`,{count:t.length})}),t.length>0&&(0,X.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,className:`ml-auto h-6 px-2 text-[10px]`,onClick:n,children:[(0,X.jsx)(hn,{className:`size-3`}),` `,e(`common:action.clear`)]})]}),t.length>0?(0,X.jsx)(`div`,{className:`max-h-20 overflow-y-auto border-t border-border/40`,children:t.slice(0,8).map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/30 px-4 py-1 text-[10px] last:border-b-0`,children:[(0,X.jsx)(tf,{action:e.action}),(0,X.jsx)(`span`,{className:H(`font-mono font-semibold`,nf(e.action)),children:e.label}),e.detail&&(0,X.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,title:e.detail,children:e.detail}),(0,X.jsx)(`time`,{className:`ml-auto shrink-0 text-muted-foreground`,children:new Date(e.at).toLocaleTimeString()})]},e.id))}):null]})}function tf({action:e}){let t=H(`size-3 shrink-0`,nf(e));return e===`entered`||e===`recovered`?(0,X.jsx)(Kn,{className:t}):e===`exited`?(0,X.jsx)(tr,{className:t}):e===`related`?(0,X.jsx)(je,{className:t}):(0,X.jsx)(cr,{className:t})}function nf(e){return e===`entered`||e===`recovered`?`text-success`:e===`exited`?`text-destructive`:e===`related`?`text-primary`:`text-info`}var rf=[{labelKey:`activity:ctxDash.zoneSafe`,emoji:`🟢`,color:`text-success`,bg:`bg-success/10`,text:`text-success`,cssColor:`hsl(var(--success))`,from:0,to:60,descKey:`activity:ctxDash.zoneSafeDesc`},{labelKey:`activity:ctxDash.zoneWarning`,emoji:`🟡`,color:`text-warning`,bg:`bg-warning/10`,text:`text-warning`,cssColor:`hsl(var(--warning))`,from:60,to:85,descKey:`activity:ctxDash.zoneWarningDesc`},{labelKey:`activity:ctxDash.zoneCritical`,emoji:`🔴`,color:`text-destructive`,bg:`bg-destructive/10`,text:`text-destructive`,cssColor:`hsl(var(--destructive))`,from:85,to:95,descKey:`activity:ctxDash.zoneCriticalDesc`},{labelKey:`activity:ctxDash.zoneDanger`,emoji:`⚫`,color:`text-brand-orange`,bg:`bg-brand-orange/15`,text:`text-brand-orange`,cssColor:`hsl(var(--brand-orange))`,from:95,to:100,descKey:`activity:ctxDash.zoneDangerDesc`}];function af(e){return e>95?rf[3]:e>85?rf[2]:e>60?rf[1]:rf[0]}function of(e){if(!e)return`—`;let t=Date.now()-e,n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),i=Math.floor(t%6e4/1e3);return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}function sf({title:e,icon:t,children:n,className:r,accent:i}){let a=i===`danger`?`text-destructive`:i===`warning`?`text-warning`:i===`success`?`text-success`:`text-muted-foreground`,o=i===`danger`?`bg-destructive/5`:i===`warning`?`bg-warning/5`:i===`success`?`bg-success/5`:``;return(0,X.jsxs)(`div`,{className:H(`rounded-xl border bg-card/80 backdrop-blur-sm p-4 space-y-3`,`shadow-sm transition-shadow hover:shadow-md`,`ring-1 ring-border/40`,o,r),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-bold tracking-tight text-foreground`,children:[(0,X.jsx)(`span`,{className:H(`flex items-center justify-center h-6 w-6 rounded-lg`,o,i!=="default"&&`ring-1 ring-inset`),children:(0,X.jsx)(t,{className:H(`h-3.5 w-3.5`,a)})}),e]}),n]})}function cf({label:e,value:t,color:n}){return(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,X.jsx)(`span`,{className:H(`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded`,n??`text-foreground`),children:t})]})}function lf({pct:e,size:t=96,strokeWidth:n=10}){let r=Math.max(0,Math.min(100,e)),i=(t-n)/2,a=2*Math.PI*i,o=r/100*a,s=af(r).cssColor;return(0,X.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:`drop-shadow-lg`,children:[(0,X.jsxs)(`title`,{children:[`Context usage: `,r.toFixed(0),`%`]}),(0,X.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:`hsl(var(--muted))`,strokeWidth:n,opacity:.3}),(0,X.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:s,strokeWidth:n,strokeLinecap:`round`,strokeDasharray:`${o} ${a-o}`,strokeDashoffset:0,className:`transition-all duration-1000 ease-out`,style:{transformOrigin:`center`,transform:`rotate(-90deg)`}}),(0,X.jsx)(`circle`,{cx:t/2,cy:t/2,r:i-n/2+2,fill:`hsl(var(--card))`,className:`drop-shadow-sm`}),(0,X.jsxs)(`text`,{x:t/2,y:t/2,textAnchor:`middle`,dominantBaseline:`central`,fill:s,className:`text-lg font-bold font-mono tabular-nums`,style:{fontSize:t*.16},children:[r.toFixed(0),`%`]})]})}function uf({value:e,suffix:t=``,duration:n=800}){let[r,i]=(0,Y.useState)(0),a=(0,Y.useRef)(0),o=(0,Y.useRef)(void 0);return(0,Y.useEffect)(()=>{let t=a.current,r=performance.now(),s=e-t;if(Math.abs(s)<1){i(e),a.current=e;return}let c=l=>{let u=l-r,d=Math.min(1,u/n),f=1-(1-d)**3;i(Math.round(t+s*f)),d<1?o.current=requestAnimationFrame(c):a.current=e};return o.current=requestAnimationFrame(c),()=>{o.current&&cancelAnimationFrame(o.current)}},[e,n]),(0,X.jsxs)(X.Fragment,{children:[r.toLocaleString(),t]})}function df({pct:e,tokens:t,maxTokens:n}){let{t:r}=R(),i=af(e),a=e>85?`danger`:e>60?`warning`:`success`;return(0,X.jsxs)(sf,{title:r(`activity:ctxDash.contextPressure`),icon:xe,accent:a,children:[(0,X.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center gap-4`,children:[(0,X.jsx)(`div`,{className:H(`shrink-0 transition-all duration-500`,e>85&&`animate-[pulse_2s_ease-in-out_infinite] drop-shadow-[0_0_12px_hsl(var(--destructive)/0.35)]`),children:(0,X.jsx)(lf,{pct:e,size:96,strokeWidth:10})}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 w-full`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-xl`,children:i.emoji}),(0,X.jsx)(`div`,{className:`flex-1`,children:(0,X.jsx)(ko,{pct:Math.round(e),tokens:t,maxTokens:n,segments:10,variant:`iridescent`})})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-1 text-[10px] font-mono tabular-nums`,children:[(0,X.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.used`)}),(0,X.jsx)(`span`,{className:H(`font-bold`,i.color),children:(0,X.jsx)(uf,{value:t})})]}),(0,X.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.free`)}),(0,X.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,X.jsx)(uf,{value:Math.max(0,n-t)})})]}),(0,X.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.capacity`)}),(0,X.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,X.jsx)(uf,{value:n})})]})]})]})]}),(0,X.jsxs)(`div`,{className:`relative h-4 mt-1`,children:[(0,X.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-2 rounded-full overflow-hidden flex`,children:rf.map(e=>(0,X.jsx)(`div`,{className:`h-full first:rounded-l-full last:rounded-r-full opacity-60`,style:{width:`${(e.to-e.from)/100*100}%`,backgroundColor:e.cssColor}},r(e.labelKey)))}),(0,X.jsxs)(`div`,{className:`absolute top-3 text-[10px] text-muted-foreground flex w-full`,children:[(0,X.jsx)(`span`,{children:`0%`}),(0,X.jsx)(`span`,{className:`ml-[56%]`,children:`soft`}),(0,X.jsx)(`span`,{className:`ml-[12%]`,children:`hard`}),(0,X.jsx)(`span`,{className:`ml-[8%]`,children:`max`}),(0,X.jsx)(`span`,{className:`ml-auto`,children:`100%`})]})]}),(0,X.jsx)(`div`,{className:`relative h-5 mt-1`,children:(0,X.jsx)(`div`,{className:`absolute top-0 -translate-x-1/2 flex flex-col items-center transition-all duration-500`,style:{left:`${Math.min(95,e)}%`},children:(0,X.jsxs)(`span`,{className:H(`text-[9px] font-mono px-1.5 py-0.5 rounded border transition-colors`,i.bg,i.text,`border-current/30`),children:[`◀ `,e.toFixed(0),`%`]})})})]})}function ff({data:e,loading:t}){let{t:n}=R();if(t)return(0,X.jsx)(sf,{title:n(`activity:ctxDash.contextComposition`),icon:$t,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground py-2`,children:[(0,X.jsx)(cr,{className:`h-3 w-3 animate-spin`}),n(`activity:ctxDash.fetchingCompositionData`)]})});if(!e||e.total<=0)return(0,X.jsx)(sf,{title:n(`activity:ctxDash.contextComposition`),icon:$t,children:(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:n(`activity:ctxDash.noCompositionDataAvailableYetRun`)})});let r=[{icon:yt,label:n(`activity:ctxDash.systemPrompt`),value:e.systemPrompt,className:`bg-info`},{icon:Xt,label:n(`activity:ctxDash.tools`),value:e.tools.total,className:`bg-warning`},{icon:Hn,label:n(`activity:ctxDash.messages`),value:e.messages.total,className:`bg-success`}];return(0,X.jsxs)(sf,{title:n(`activity:ctxDash.contextComposition`),icon:$t,children:[(0,X.jsx)(`div`,{className:`h-3 w-full overflow-hidden rounded-full bg-muted flex`,children:r.map(t=>{let n=t.value/e.total*100;return n<=0?null:(0,X.jsx)(`span`,{className:H(`h-full first:rounded-l-full last:rounded-r-full transition-all`,t.className),style:{width:`${n}%`}},t.label)})}),(0,X.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>{let n=(t.value/e.total*100).toFixed(1);return(0,X.jsx)(cf,{label:`${t.label}`,value:`${Ro(t.value)} (${n}%)`},t.label)})}),e.tools.breakdown.length>0&&(0,X.jsxs)(`div`,{className:`pt-1 border-t border-border/50`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-semibold`,children:n(`activity:ctxDash.toolBreakdown`)}),(0,X.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:e.tools.breakdown.slice(0,5).map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,X.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.name}),(0,X.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:Ro(e.tokens)})]},e.name))})]})]})}function pf({pct:e}){let{t}=R();return(0,X.jsxs)(sf,{title:t(`activity:ctxDash.thresholdMap`),icon:Le,children:[(0,X.jsx)(`div`,{className:`flex h-2 rounded-full overflow-hidden`,children:rf.map(e=>(0,X.jsx)(`div`,{className:`h-full first:rounded-l-full last:rounded-r-full opacity-80`,style:{width:`${(e.to-e.from)/100*100}%`,backgroundColor:e.cssColor}},t(e.labelKey)))}),(0,X.jsx)(`div`,{className:`space-y-0.5 text-xs`,children:rf.map(n=>{let r=e>=n.from&&e<n.to;return(0,X.jsxs)(`div`,{className:H(`flex items-center px-2 py-1 rounded`,r?n.bg:``),children:[(0,X.jsx)(`span`,{className:`w-5`,children:n.emoji}),(0,X.jsx)(`span`,{className:H(`w-20 font-medium`,r?n.text:`text-muted-foreground`),children:t(n.labelKey)}),(0,X.jsxs)(`span`,{className:`w-16 text-muted-foreground`,children:[n.from,`%–`,n.to,`%`]}),(0,X.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:t(n.descKey)}),r&&(0,X.jsx)(`span`,{className:`text-xs font-mono`,children:`◀`})]},t(n.labelKey))})}),(0,X.jsx)(cf,{label:t(`activity:ctxDash.currentPosition`),value:`${e.toFixed(1)}% → ${af(e).emoji} ${t(af(e).labelKey)}`,color:af(e).color}),(0,X.jsx)(cf,{label:t(`activity:ctxDash.compactTrigger`),value:`85%`}),(0,X.jsx)(cf,{label:t(`activity:ctxDash.hardLimit`),value:`100%`})]})}function mf({pct:e,maxTokens:t}){let{t:n}=R(),r=Math.round(t*.18),i=Math.round(t*.85),a=e>65,o=t>0?e/100:0;return(0,X.jsx)(sf,{title:n(`activity:ctxDash.compactionEngine`),icon:Ie,accent:a?`warning`:`success`,children:(0,X.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.strategy`)}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground/90`,children:`hybrid`}),(0,X.jsx)(`span`,{className:`text-success bg-success/10 px-1.5 rounded text-[9px] font-semibold`,children:n(`activity:ctxDash.auto`)})]}),(0,X.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:n(`activity:ctxDash.current`)}),(0,X.jsxs)(`span`,{children:[`Trigger (`,Ro(i),`)`]})]}),(0,X.jsxs)(`div`,{className:`relative h-2 w-full overflow-hidden rounded-full bg-muted/50 ring-1 ring-inset ring-border/20`,children:[(0,X.jsx)(`span`,{className:H(`absolute inset-y-0 left-0 rounded-full transition-all duration-700`,a?`bg-warning`:`bg-success`),style:{width:`${Math.max(2,o*100)}%`}}),(0,X.jsx)(`span`,{className:`absolute top-0 bottom-0 w-0.5 bg-destructive/60`,style:{left:`85%`}})]}),(0,X.jsxs)(`div`,{className:`flex justify-between text-[9px] text-foreground/70`,children:[(0,X.jsx)(`span`,{children:Ro(Math.round(t*o))}),(0,X.jsx)(`span`,{className:`text-destructive/70`,children:Ro(i)})]})]}),(0,X.jsx)(cf,{label:n(`activity:ctxDash.nextTrigger`),value:`${Ro(i)} (85%)`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.estRecovery`)}),(0,X.jsxs)(`span`,{className:`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded text-success bg-success/10`,children:[`~`,Ro(r)]})]}),(0,X.jsx)(cf,{label:n(`activity:ctxDash.recommendation`),value:a?`⚠️ Compact now`:`✅ No compaction needed`,color:a?`text-warning`:`text-success`}),a&&(0,X.jsxs)(`div`,{className:`bg-warning/5 border border-warning/20 rounded p-2 text-[10px] text-warning/90 mt-1`,children:[`Context at `,e.toFixed(1),`% — compacting recovers ~`,Ro(r),` tokens.`]})]})})}function hf({agents:e}){let{t}=R(),n=e.filter(e=>e.ctxPct!=null&&e.ctxPct>0);return n.length===0?null:(0,X.jsx)(sf,{title:t(`activity:ctxDash.perAgentFootprint`),icon:Tr,children:(0,X.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=af(e.ctxPct),n=e.name||e.id;return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`w-4`,children:e.id===`__leader__`?`👑`:` `}),(0,X.jsx)(`span`,{className:`w-24 truncate font-mono text-muted-foreground`,title:n,children:n}),(0,X.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,X.jsx)(Ao,{pct:Math.round(e.ctxPct),tokens:e.ctxTokens,maxTokens:e.maxContext,showTokens:!1})}),(0,X.jsxs)(`span`,{className:H(`tabular-nums w-10 text-right`,t.color),children:[Math.round(e.ctxPct),`%`]})]},e.id)})})})}function gf({tokens:e,maxTokens:t,pct:n,model:r,provider:i,mode:a,uptime:o,iteration:s,contextMode:c}){let{t:l}=R(),u=t-e,d=t>0?(u/t*100).toFixed(1):`0.0`;return(0,X.jsx)(sf,{title:l(`activity:ctxDash.tokenMetrics`),icon:Qn,children:(0,X.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,X.jsx)(cf,{label:l(`activity:ctxDash.used`),value:Ro(e)}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.free`),value:`${Ro(u)} (${d}%)`}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.capacity`),value:Ro(t)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:l(`activity:ctxDash.utilization`)}),(0,X.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,X.jsx)(Ao,{pct:Math.round(n),tokens:e,maxTokens:t})})]}),(0,X.jsx)(`div`,{className:`border-t border-border/50 pt-1 mt-1`}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.model`),value:`${r} · ${i}`}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.mode`),value:a}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.contextMode`),value:c}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.iteration`),value:s}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.uptime`),value:o})]})})}function _f({model:e,provider:t,mode:n,uptime:r,projectName:i,cwd:a,contextMode:o}){let{t:s}=R();return(0,X.jsx)(sf,{title:s(`activity:ctxDash.session`),icon:Rt,children:(0,X.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,X.jsx)(cf,{label:s(`activity:ctxDash.provider`),value:t}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.model`),value:e}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.mode`),value:n}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.contextMode`),value:o}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.project`),value:i||a}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.uptime`),value:r})]})})}function vf(){let{t:e}=R(),t=G(e=>e.setCurrentView),{lastInputTokens:n,maxContext:r,mode:i,contextMode:a,startTime:o,session:s,iteration:c,projectName:l,cwd:u}=U(fn(e=>({lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,mode:e.mode,contextMode:e.contextMode,startTime:e.startTime,session:e.session,iteration:e.iteration,projectName:e.projectName,cwd:e.cwd}))),d=ni(fn(e=>[...e.agents.values()])),f=W(e=>e.wsUrl),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null),y=(0,Y.useRef)(0),b=(0,Y.useRef)(null),x=()=>{b.current?.(),b.current=null;let e=V(f);if(!e?.send){v(`WebSocket not connected`);return}let t=++y.current;g(!0),v(null),e.send({type:`context.debug`},{echoToChat:!1});let n=!1,r,i=e.on(`context.debug`,e=>{n||e.type===`context.debug`&&y.current===t&&(n=!0,r!==void 0&&clearTimeout(r),m(e.payload),g(!1),i())});b.current=i,r=setTimeout(()=>{n||(n=!0,y.current===t&&(g(!1),v(`No response from server`),i()))},5e3)};(0,Y.useEffect)(()=>(x(),()=>{y.current++,b.current?.(),b.current=null}),[f]);let S=s?.model??`—`,C=s?.provider??`—`,w=r>0?Math.min(100,n/r*100):0,T=of(o),E=c?`${c.index} / ${c.max}`:`—`,D=af(w),O=e=>({animation:`fadeInUp 0.4s ease-out ${e*.08}s both`});return(0,X.jsxs)(`div`,{ref:Qd(`context`),className:`flex-1 min-h-0 overflow-y-auto overscroll-contain`,children:[(0,X.jsx)(`style`,{children:`
123
+ `).trim();return(0,X.jsxs)(`div`,{className:`flex gap-3 animate-message thinking-bubble`,"aria-live":`polite`,children:[(0,X.jsxs)(`div`,{className:`thinking-orb flex-shrink-0`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{className:`thinking-orb__ring`}),(0,X.jsx)(`span`,{className:`thinking-orb__ring thinking-orb__ring--delay`}),(0,X.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--one`}),(0,X.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--two`}),(0,X.jsx)(Nt,{className:`thinking-orb__icon h-4 w-4`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0`,children:[(0,X.jsxs)(`span`,{className:`thinking-label text-xs font-medium text-primary px-1`,children:[(0,X.jsx)(`span`,{children:e(`chat:thinking`)}),(0,X.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]})]}),(0,X.jsxs)(`div`,{className:`thinking-panel rounded-2xl rounded-bl-md px-3 py-2 border text-foreground/80`,children:[(0,X.jsxs)(`div`,{className:`thinking-wave`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]}),(0,X.jsx)(`pre`,{className:`thinking-text whitespace-pre-wrap break-words font-sans text-xs leading-relaxed italic max-h-32 overflow-hidden`,children:n||`…`})]})]})]})}function qd(e){let{hasMessages:t,autoCollapseInput:n,sessionChanged:r,prevHadMessages:i,prevAutoCollapse:a}=e;return n&&t&&(r||!i||!a)}function Jd({label:e,value:t,onChange:n}){return(0,X.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":t,onClick:n,className:`inline-flex items-center gap-1.5 text-[11px] text-muted-foreground/75 hover:text-foreground/80 transition-colors select-none`,children:[(0,X.jsx)(`span`,{className:H(`relative inline-block h-3.5 w-6 rounded-full border transition-colors shrink-0`,t?`bg-primary border-primary/60`:`bg-muted/70 border-border/60`),children:(0,X.jsx)(`span`,{className:H(`absolute top-[1px] left-[1px] h-2.5 w-2.5 rounded-full bg-background shadow transition-transform`,t&&`translate-x-2.5`)})}),(0,X.jsx)(`span`,{children:e})]})}var Yd=(0,Y.lazy)(()=>B(()=>import(`./ProcessMonitor-TGqyXxmB.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([9,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27]))),Xd=(0,Y.memo)(function({row:e,isLoading:t,compactMode:n,isFirstRow:r,groupToolCalls:i}){let a=H(`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6`,r&&`pt-4`,n?`pb-3`:`pb-6`);return e.kind===`day`?(0,X.jsx)(`div`,{className:a,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3 py-1 text-[11px] text-muted-foreground/70 uppercase tracking-wider font-medium`,children:[(0,X.jsx)(`div`,{className:`flex-1 h-px bg-border/50`}),(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(`div`,{className:`flex-1 h-px bg-border/50`})]})}):e.kind===`user`?(0,X.jsx)(`div`,{className:a,children:(0,X.jsx)(kd,{message:e.message,isFirst:!0})}):(0,X.jsx)(`div`,{className:a,children:(0,X.jsx)(`div`,{className:H(`chat-turn`,n?`space-y-1`:`space-y-1.5`),children:e.items.flatMap(n=>{if(n.kind===`msg`)return[(0,X.jsx)(kd,{message:n.message,isFirst:n.isFirst,isContinuation:n.isContinuation},n.key)];if(i){let r=e.isLastTurn&&n.isLastGroup&&t&&n.hasRunningTool;return[(0,X.jsx)(Wd,{tools:n.tools,defaultOpen:r,isContinuation:n.isContinuation},n.key)]}return n.tools.map(e=>(0,X.jsx)(kd,{message:e,isFirst:!1,isContinuation:n.isContinuation},e.id))})})})});function Zd(){let{t:e}=R(),t=r(e=>e.messages),n=r(e=>e.isLoading),i=G(e=>e.sidebarOpen),a=G(e=>e.toggleSidebar),o=G(e=>e.compactMode),{totalTokens:s,startTime:c,lastInputTokens:l,maxContext:u,contextLimitWarning:d,iteration:f}=U(fn(e=>({totalTokens:e.totalTokens,startTime:e.startTime,lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,contextLimitWarning:e.contextLimitWarning,iteration:e.iteration}))),p=U(e=>e.session),m=p?.id,h=G(e=>m?e.sessionNicknames[m]:void 0),g=G(e=>e.setSessionNickname),_=p?.title,[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(``),C=ui(e=>e.entries),[w,T]=(0,Y.useState)(!1),E=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!w)return;let e=e=>{E.current?.contains(e.target)||T(!1)},t=e=>{e.key===`Escape`&&T(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[w]);let{provider:O,model:k}=W(fn(e=>({provider:e.provider,model:e.model}))),A=(0,Y.useRef)(null),j=(0,Y.useMemo)(()=>bo(t),[t]),M=(0,Y.useRef)(0);M.current=j.length+1;let N=(0,Y.useMemo)(()=>{let e=new Map;return j.forEach((t,n)=>{if(t.kind===`user`)e.set(t.message.id,n);else if(t.kind===`agent`)for(let r of t.items)if(r.kind===`msg`)e.set(r.message.id,n);else for(let t of r.tools)e.set(t.id,n)}),e},[j]),ee=G(e=>e.scrollTarget),te=z(e=>e.autonomy),ne=z(e=>e.showThinkingLogs),re=z(e=>e.groupToolCalls),P=z(e=>e.autoCollapseInput),ie=(0,Y.useCallback)(e=>{z.getState().set({autonomy:e}),V()?.send?.({type:`autonomy.switch`,payload:{mode:e}})},[]),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[F,I]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(t.length>0&&P),de=(0,Y.useRef)(n),fe=(0,Y.useRef)(t.length>0),pe=(0,Y.useRef)(m),me=(0,Y.useRef)(P),[he,ge]=(0,Y.useState)(!1),[_e,ve]=(0,Y.useState)(!1),ye=Mr(e=>Object.values(e.contextMemories).filter(e=>e.state!==`exited`).length);(0,Y.useEffect)(()=>{let e=()=>I(!0);return window.addEventListener(`open:memory-panel`,e),()=>window.removeEventListener(`open:memory-panel`,e)},[]),(0,Y.useEffect)(()=>{let e=()=>ge(!0);return document.addEventListener(`open:context-breakdown`,e),()=>document.removeEventListener(`open:context-breakdown`,e)},[]),(0,Y.useEffect)(()=>{let e=()=>ve(!0);return document.addEventListener(`open:context-editor`,e),()=>document.removeEventListener(`open:context-editor`,e)},[]),(0,Y.useEffect)(()=>{let e=()=>ue(!1);return document.addEventListener(`chat:session-end`,e),document.addEventListener(`chat:next-step-countdown`,e),()=>{document.removeEventListener(`chat:session-end`,e),document.removeEventListener(`chat:next-step-countdown`,e)}},[]),(0,Y.useEffect)(()=>{de.current&&!n&&ue(!1),de.current=n},[n,ue]),(0,Y.useEffect)(()=>{let e=t.length>0,r=m!=null&&m!==pe.current;!n&&qd({hasMessages:e,autoCollapseInput:P,sessionChanged:r,prevHadMessages:fe.current,prevAutoCollapse:me.current})&&ue(!0),pe.current=m,fe.current=e,me.current=P},[t.length,P,m,n,ue]);let L=(0,Y.useCallback)(()=>{let e=!z.getState().autoCollapseInput;z.getState().set({autoCollapseInput:e}),e||ue(!1)},[ue]),be=u>0&&l>0?Math.min(100,Math.round(l/u*100)):0,[xe,Se]=(0,Y.useState)(!0),[we,Te]=(0,Y.useState)(0),[Ee,De]=(0,Y.useState)(!1),Oe=(0,Y.useRef)(t.length),ke=(0,Y.useCallback)(()=>{let e=A.current;if(!e)return;let t=e.scrollSize-e.scrollOffset-e.viewportSize<120;Se(t),t&&(Te(0),Oe.current=r.getState().messages.length),De(e.scrollOffset>e.viewportSize&&e.scrollSize>e.viewportSize*2.5)},[]),Ae=(0,Y.useCallback)(e=>{V()?.resumeSession?.(e),T(!1)},[]);(0,Y.useEffect)(()=>{let e=A.current;if(e)if(xe)e.scrollToIndex(M.current-1,{align:`end`}),Oe.current=t.length;else{let e=t.length-Oe.current;e>0&&Te(e)}},[t,xe]),(0,Y.useEffect)(()=>{Se(!0),Te(0),Oe.current=r.getState().messages.length,requestAnimationFrame(()=>{A.current?.scrollToIndex(M.current-1,{align:`end`})})},[m]),(0,Y.useEffect)(()=>{if(!ee)return;let e=N.get(ee.id);e!==void 0&&A.current?.scrollToIndex(e,{align:`center`,smooth:!0})},[ee,N]);let je=(0,Y.useCallback)(()=>{A.current?.scrollToIndex(M.current-1,{align:`end`,smooth:!0}),Se(!0),Te(0),Oe.current=r.getState().messages.length},[]),Ne=(0,Y.useCallback)(()=>{A.current?.scrollToIndex(0,{align:`start`,smooth:!0})},[]),[Fe,Ie]=(0,Y.useState)(null),[Re,ze]=(0,Y.useState)(()=>Date.now()),Ve=(0,Y.useRef)(null),He=(0,Y.useMemo)(()=>{let n=t[t.length-1],r=t.filter(e=>e.role===`tool`&&e.toolResult===void 0),i=e(`activity:chatView.thinking`);if(r.length>0){let t=Array.from(new Set(r.map(e=>e.toolName).filter(Boolean))),n=t.slice(0,2).join(`, `),a=t.length>2?` +${t.length-2}`:``;i=r.length===1?e(`activity:chatView.runningTool`,{tool:n||e(`activity:chatView.toolWord`)}):e(`activity:chatView.runningTools`,{count:r.length,preview:`${n}${a}`})}else n?.role===`assistant`&&n.content?i=e(`activity:chatView.writingReply`):n?.role===`tool`&&n.toolResult!==void 0&&(i=e(`activity:chatView.thinkingNextStep`));let a=Fe?Math.max(0,Math.floor((Re-Fe)/1e3)):0,o=a<60?`${a}s`:`${Math.floor(a/60)}m ${a%60}s`,s=``,c=n?.role===`assistant`&&n.streaming&&n.content?n:null;if(c){let e=Ve.current;if(!e||e.id!==c.id)Ve.current={id:c.id,at:Date.now(),len:c.content.length};else{let t=Math.max(1,Re-e.at),n=Math.max(0,c.content.length-e.len);if(t>500&&n>0){let e=n*1e3/t;s=e>=1e3?`${(e/1e3).toFixed(1)}k ch/s`:`${Math.round(e)} ch/s`}}}else Ve.current&&=null;return{label:i,elapsed:o,speedLabel:s}},[t,Re,Fe]);(0,Y.useEffect)(()=>{n&&Fe===null&&Ie(Date.now()),!n&&Fe!==null&&Ie(null)},[n,Fe]),(0,Y.useEffect)(()=>{if(!n)return;let e=setInterval(()=>ze(Date.now()),500);return()=>clearInterval(e)},[n]);let We=e=>{if(!e)return`--`;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`},Ge=(()=>{if(!n)return`idle`;let e=t[t.length-1];return e?.role===`assistant`&&e.content&&e.streaming?`streaming`:`thinking`})(),Ke=Ge===`idle`?`bg-muted text-muted-foreground`:Ge===`streaming`?`bg-primary/10 text-primary`:`bg-warning/10 text-warning`,qe=u>0&&l>0||s.input>0||!!c;return(0,X.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 bg-[hsl(var(--surface-2)/0.45)]`,children:[(0,X.jsxs)(`header`,{className:`flex flex-col border-b border-border/70 bg-card/90 backdrop-blur-xl supports-[backdrop-filter]:bg-card/80 shrink-0 sticky top-0 z-20 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-2 sm:px-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_18rem] items-center gap-1.5 overflow-hidden`,children:[!i&&(0,X.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:a,title:e(`chat:header.openSidebarTitle`),children:(0,X.jsx)(Be,{className:`h-4 w-4`})}),!i&&(0,X.jsx)(`div`,{className:`flex items-center gap-1.5 shrink-0 mr-1`,children:(0,X.jsx)(`div`,{className:`w-5 h-5 rounded-md bg-primary flex items-center justify-center`,children:(0,X.jsx)(ar,{className:`h-3 w-3 text-primary-foreground`})})}),(0,X.jsxs)(`span`,{className:H(`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[11px] font-medium shrink-0 tabular-nums`,Ke),title:`Agent state: ${Ge}`,children:[Ge!==`idle`&&(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-current animate-pulse`}),(0,X.jsx)(`span`,{children:Ge})]}),m&&(v?(0,X.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),onBlur:()=>{b.trim()&&g(m,b),y(!1)},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),b.trim()&&g(m,b),y(!1)):e.key===`Escape`&&(e.preventDefault(),y(!1))},placeholder:e(`chat:sessionNamePlaceholder`),className:`h-6 px-1.5 text-[11px] bg-background border border-primary/40 rounded-md focus:outline-none focus:ring-1 focus:ring-ring shrink-0 w-36`}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{x(h||_||``),y(!0)},className:`flex items-center gap-1 text-[11px] font-medium text-foreground/80 hover:text-foreground truncate max-w-[12rem] shrink-0 px-1 -mx-1 rounded-md hover:bg-muted/50 transition-colors`,title:e(`chat:header.renameTitle`),children:[(0,X.jsx)(S,{className:`h-2.5 w-2.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:h||_||e(`chat:header.untitled`)})]}))]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-[0_1_auto] flex-wrap items-center justify-end gap-1.5`,children:[C.length>1&&(0,X.jsxs)(`div`,{ref:E,className:`relative shrink-0`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>T(e=>!e),className:`flex items-center gap-0.5 px-1 py-0.5 rounded-md text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors`,title:e(`chat:switchSession`),children:[(0,X.jsx)(D,{className:`h-3 w-3`}),(0,X.jsx)(Ue,{className:`h-2.5 w-2.5`})]}),w&&(0,X.jsx)(`div`,{className:`absolute left-0 top-full mt-1 z-40 w-64 rounded-md border border-border/70 bg-popover shadow-xl p-1 max-h-60 overflow-y-auto`,children:C.slice(0,15).map(t=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>Ae(t.id),className:H(`w-full text-left px-2 py-1.5 rounded text-xs hover:bg-accent transition-colors`,t.isCurrent&&`bg-primary/10`),children:[(0,X.jsx)(`div`,{className:`font-medium truncate`,children:t.title||e(`chat:empty`)}),(0,X.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono truncate`,children:[t.provider,`/`,t.model,` · `,t.tokenTotal.toLocaleString(),` tok`]})]},t.id))})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>G.getState().setModelSwitcherOpen(!0),className:`group hidden sm:flex items-center gap-1 px-2 py-0.5 rounded-md border border-border/70 bg-background/60 hover:bg-accent/70 hover:border-primary/40 transition-colors text-[11px] min-w-0 shrink-0`,title:e(`chat:header.changeModelTitle`),children:[(0,X.jsx)(Rt,{className:`h-3 w-3 text-muted-foreground group-hover:text-foreground shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono truncate max-w-[9rem] xl:max-w-[16rem]`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:O||e(`chat:header.noProvider`)}),(0,X.jsx)(`span`,{className:`text-muted-foreground/65 mx-0.5`,children:`/`}),(0,X.jsx)(`span`,{className:`font-medium`,children:k||e(`chat:header.noModel`)})]})]}),(0,X.jsxs)(`div`,{className:`hidden md:flex items-center gap-1.5 shrink-0`,children:[(0,X.jsx)(Ad,{}),(0,X.jsx)(Ou,{})]}),f&&(0,X.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[11px] font-medium bg-primary/10 text-primary shrink-0 hover:bg-primary/20 transition-colors cursor-pointer`,title:e(`chat:header.iterationTitle`),onClick:()=>document.getElementById(`chat-activity`)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:[(0,X.jsx)(Pe,{className:`h-3 w-3 animate-pulse`}),`iter `,f.index,f.max>0?`/${f.max}`:``]}),(0,X.jsx)(Fl,{value:te,onChange:ie,compact:!0})]}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 shrink-0`,children:[(0,X.jsxs)(J,{variant:F?`secondary`:`ghost`,size:`icon`,className:H(`h-7 w-7 relative`,F&&`bg-primary/10 text-primary`),onClick:()=>I(e=>!e),title:e(`chat:header.memoryContextTitle`,`Memory context`),children:[(0,X.jsx)(Nt,{className:`h-4 w-4`}),ye>0&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-3.5 h-3.5 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold flex items-center justify-center tabular-nums`,children:ye}),F&&(0,X.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-primary`})]}),(0,X.jsxs)(J,{variant:ae?`secondary`:`ghost`,size:`icon`,className:H(`h-7 w-7 relative`,ae&&`bg-warning/10 text-warning`),onClick:()=>oe(e=>!e),title:e(`chat:header.runningProcessesTitle`),children:[(0,X.jsx)(Me,{className:`h-4 w-4`}),ae&&(0,X.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-warning`})]}),(0,X.jsxs)(J,{variant:se?`secondary`:`ghost`,size:`icon`,className:H(`h-7 w-7 relative`,se&&`bg-primary/10 text-primary`),onClick:()=>ce(e=>!e),title:e(`chat:header.checkpointsTitle`),children:[(0,X.jsx)(D,{className:`h-4 w-4`}),se&&(0,X.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-primary`})]})]})]}),qe&&(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 overflow-x-auto border-t border-border/60 bg-muted/20 px-3 py-1 text-[11px] text-muted-foreground sm:px-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-max items-center gap-3 tabular-nums`,children:[l>0&&(0,X.jsx)(Ao,{pct:be,tokens:l,maxTokens:u>0?u:void 0,onClick:()=>ge(!0)}),d&&(0,X.jsxs)(`span`,{role:`status`,className:`inline-flex items-center gap-1 rounded-md border border-warning/40 bg-warning/10 px-2 py-0.5 font-medium text-warning`,title:e(`activity:chatView.providerLimitDecreased`,{previous:d.previousMaxContext.toLocaleString(),current:d.maxContext.toLocaleString()}),children:[(0,X.jsx)(Le,{className:`h-3 w-3`}),e(`activity:chatView.providerLimit`,{limit:_o(d.maxContext)})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ve(!0),className:`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[11px] text-muted-foreground/70 hover:text-foreground hover:bg-accent transition-colors shrink-0`,title:e(`activity:chatView.editContextWindow`),children:[(0,X.jsx)(an,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:e(`activity:chatView.edit`)})]}),s.input>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:_o(s.input)}),(0,X.jsx)(`span`,{children:`in`})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:_o(s.output)}),(0,X.jsx)(`span`,{children:`out`})]}),s.cacheRead&&s.cacheRead>0&&(()=>{let e=(s.cacheRead??0)+s.input,t=e>0?Math.round((s.cacheRead??0)/e*100):0;return(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,title:`Cache hit ratio: ${t}%`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:_o(s.cacheRead)}),(0,X.jsxs)(`span`,{children:[`cache (`,t,`%)`]})]})})(),(0,X.jsx)(ku,{})]})]}),c&&(0,X.jsx)(`span`,{className:`text-muted-foreground/70 tabular-nums shrink-0`,children:We(c)})]})]}),(0,X.jsxs)(`div`,{className:`relative mx-2 mt-2 min-h-0 min-w-0 flex-1 overflow-hidden rounded-xl border border-border/70 bg-card/55 shadow-sm sm:mx-3 lg:mx-4 lg:mt-3`,children:[(0,X.jsx)(Hd,{}),!xe&&(0,X.jsxs)(`button`,{type:`button`,onClick:je,className:H(`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 jump-bottom`,`flex items-center gap-2 px-4 py-2 rounded-md shadow-lg`,`bg-primary text-primary-foreground text-xs font-medium`,`hover:bg-primary/90 transition-colors animate-message`),children:[(0,X.jsx)(Ze,{className:`h-3.5 w-3.5`}),we>0?`${we} new message${we===1?``:`s`}`:`Jump to latest`]}),Ee&&(0,X.jsxs)(`button`,{type:`button`,onClick:Ne,title:e(`chat:header.scrollTopTitle`),className:H(`absolute top-3 right-3 z-10`,`flex items-center gap-1 px-2.5 py-1 rounded-md shadow-md border`,`bg-background/90 backdrop-blur-sm text-[11px] text-muted-foreground`,`hover:text-foreground hover:bg-background transition-colors animate-message`),children:[(0,X.jsx)(tn,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:e(`activity:chatView.top`)})]}),j.length===0&&!n?(0,X.jsx)(`div`,{className:`h-full overflow-y-auto overscroll-contain`,children:(0,X.jsx)(`div`,{className:`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6 pt-4 pb-8`,children:(0,X.jsx)(Gd,{})})}):(0,X.jsxs)(Ce,{ref:A,className:`h-full`,onScroll:ke,role:`log`,"aria-label":e(`activity:chatView.chatTranscript`),"aria-live":`polite`,children:[j.map((e,t)=>(0,X.jsx)(Xd,{row:e,isLoading:n,compactMode:o,isFirstRow:t===0,groupToolCalls:re},e.key)),(0,X.jsxs)(`div`,{id:`chat-activity`,className:H(`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6`,o?`pb-3`:`pb-8`),children:[(0,X.jsx)(Kd,{}),n&&(0,X.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,X.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,X.jsx)(bn,{className:`h-4 w-4`})}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,X.jsx)(`div`,{className:`rounded-lg px-4 py-3 bg-card border border-border/70 text-foreground shadow-sm`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,X.jsxs)(`span`,{className:`flex gap-1`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.3s]`}),(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.15s]`}),(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce`})]}),(0,X.jsx)(`span`,{className:`text-foreground/90`,children:He.label}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:He.elapsed}),f&&(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`· iter `,f.index,f.max>0?`/${f.max}`:``]}),He.speedLabel&&(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 tabular-nums`,children:[`· `,He.speedLabel]})]})})})]})]},`__live`)]})]}),(0,X.jsx)(`div`,{className:`shrink-0 bg-[hsl(var(--surface-2)/0.45)] px-2 pb-2 pt-2 sm:px-3 lg:px-4 lg:pb-3`,children:le&&t.length>0?(0,X.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/60 bg-card/40 px-3 py-1.5 hover:bg-card/70 hover:border-border/80 transition-colors`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ue(!1),className:`flex flex-1 items-center gap-2 text-xs text-muted-foreground/60 hover:text-foreground/80 transition-colors`,children:[(0,X.jsx)(xt,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{children:e(`chat:input.expandInput`,`Expand input`)}),j.length>0&&(0,X.jsxs)(`span`,{className:`ml-auto tabular-nums text-[10px] text-muted-foreground/40`,children:[j.length,` msgs · `,_o(s.input+s.output)]})]}),(0,X.jsx)(Jd,{label:e(`activity:chatView.autoCollapse`),value:P,onChange:L})]}):(0,X.jsxs)(X.Fragment,{children:[t.length>0&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ue(!0),className:`mb-1 flex w-full items-center gap-1.5 rounded px-2 py-0.5 text-[10px] text-muted-foreground/50 hover:text-muted-foreground/80 transition-colors`,children:[(0,X.jsx)(Ue,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:e(`chat:input.collapseInput`,`Collapse`)})]}),(0,X.jsx)(zd,{}),(0,X.jsxs)(`div`,{className:`ws-display-toggles flex max-w-6xl mx-auto px-2 pb-1.5 items-center gap-3 text-[11px] text-muted-foreground/75 select-none overflow-x-auto min-h-[1.75rem]`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,X.jsx)(Jd,{label:e(`activity:chatView.reasoning`),value:ne,onChange:()=>{z.getState().set({showThinkingLogs:!z.getState().showThinkingLogs})}}),(0,X.jsx)(`span`,{className:`opacity-30`,children:`|`}),(0,X.jsx)(Jd,{label:e(`activity:chatView.groupTools`),value:re,onChange:()=>{z.getState().set({groupToolCalls:!z.getState().groupToolCalls})}}),(0,X.jsx)(`span`,{className:`opacity-30`,children:`|`}),(0,X.jsx)(Jd,{label:e(`activity:chatView.compact`),value:o,onChange:()=>G.getState().toggleCompactMode()}),(0,X.jsx)(`span`,{className:`opacity-30`,children:`|`}),(0,X.jsx)(Jd,{label:e(`activity:chatView.autoCollapse`),value:P,onChange:L})]}),qe&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`opacity-20 grow min-w-[1rem]`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 tabular-nums text-[10px] text-muted-foreground/70 shrink-0`,children:[s.input>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,title:`${s.input.toLocaleString()} tokens in`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground/80`,children:_o(s.input)}),(0,X.jsx)(`span`,{className:`text-[9px]`,children:`in`})]}),s.output>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,title:`${s.output.toLocaleString()} tokens out`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground/80`,children:_o(s.output)}),(0,X.jsx)(`span`,{className:`text-[9px]`,children:`out`})]}),j.length>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,title:e(`activity:chatView.messages`),children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground/80`,children:j.length}),(0,X.jsx)(`span`,{className:`text-[9px]`,children:`msgs`})]}),f?.index&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-primary/70`,title:e(`activity:chatView.currentIteration`),children:[(0,X.jsx)(`span`,{className:`font-medium`,children:f.index}),(0,X.jsx)(`span`,{className:`text-[9px]`,children:`iter`})]}),c&&(0,X.jsx)(`span`,{className:`tabular-nums text-muted-foreground/50`,children:We(c)})]})]}),(0,X.jsx)(`span`,{className:`opacity-20 ml-2 text-[9px] shrink-0`,children:(0,X.jsx)(`kbd`,{className:`font-mono text-[9px] border rounded px-1 py-0.5 bg-muted/40`,children:`?`})})]}),(0,X.jsx)(`div`,{className:`ws-chat-input-wrap p-0`,children:(0,X.jsx)(`div`,{className:`max-w-6xl mx-auto`,children:(0,X.jsx)(Tu,{onOpenBreakdown:()=>ge(!0)})})})]})}),(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Yd,{open:ae,onClose:()=>oe(!1)})}),(0,X.jsx)(Du,{open:se,onClose:()=>ce(!1)}),(0,X.jsx)(Ds,{open:he,onClose:()=>ge(!1)}),(0,X.jsx)(Wu,{open:_e,onClose:()=>ve(!1)}),(0,X.jsx)(Nl,{open:F,onClose:()=>I(!1)})]})}function Qd(e,t=!0){let n=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let i=requestAnimationFrame(()=>{let t=G.getState().scrollPositions[e];typeof t==`number`&&t>0&&(r.scrollTop=t)});return()=>cancelAnimationFrame(i)},[]),(0,Y.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let{setScrollPosition:i}=G.getState();return()=>{i(e,r.scrollTop)}},[e]),n}function $d(){let{t:e}=R(),t=Mr(e=>e.contextMemories),n=Mr(e=>e.transitions),r=Object.values(t).sort((e,t)=>t.lastSeenAt.localeCompare(e.lastSeenAt)),i=r.filter(e=>e.state===`active`),a=r.filter(e=>e.state===`injected`),o=r.filter(e=>e.state===`exited`);return(0,X.jsxs)(`section`,{className:`rounded-md border border-primary/20 bg-primary/[0.025]`,"aria-label":e(`activity:ctxMonitor.contextMemoryMonitor`),children:[(0,X.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2`,children:[(0,X.jsx)(Mn,{className:`size-4 text-primary`}),(0,X.jsx)(`h2`,{className:`text-xs font-semibold`,children:e(`activity:ctxMonitor.contextMemoryMonitor`)}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`activity:ctxMonitor.exactProviderBoundPresence`)}),(0,X.jsxs)(`div`,{className:`ml-auto flex gap-2 font-mono text-[10px]`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[i.length,` ctx`]}),(0,X.jsxs)(`span`,{className:`text-warning`,children:[a.length,` pending`]}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[o.length,` left`]})]})]}),r.length===0?(0,X.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:e(`activity:ctxMonitor.noSageHasEnteredThisSession`)}):(0,X.jsxs)(`div`,{className:`grid gap-3 p-3 xl:grid-cols-[minmax(0,2fr)_minmax(260px,1fr)]`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wide text-muted-foreground`,children:e(`activity:ctxMonitor.memoryPresence`)}),r.slice(0,20).map(e=>(0,X.jsxs)(`article`,{className:H(`border px-3 py-2 text-[10px]`,e.state===`exited`?`border-border/50 bg-muted/20 opacity-65`:`border-primary/25 bg-background/55`),children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:H(`border px-1.5 py-0.5 font-bold uppercase`,e.state===`exited`?`border-border text-muted-foreground`:e.state===`active`?`border-success/35 text-success`:`border-warning/35 text-warning`),children:e.state}),(0,X.jsx)(`span`,{className:`font-mono font-bold text-primary`,children:e.id}),(0,X.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[e.kind,` · `,e.persistence]}),(0,X.jsxs)(`span`,{className:`ml-auto font-mono text-muted-foreground`,children:[`score `,e.score.toFixed(2),` · conf `,e.confidence.toFixed(2),` · fresh`,` `,e.freshness.toFixed(2)]})]}),(0,X.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-foreground`,children:e.text}),(0,X.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`why: `,e.activationReasons.join(` · `)||`context snapshot`]}),(e.anchors.length>0||e.tags.length>0)&&(0,X.jsx)(`p`,{className:`mt-1 truncate font-mono text-muted-foreground`,title:[...e.anchors,...e.tags.map(e=>`#${e}`)].join(` · `),children:[...e.anchors,...e.tags.map(e=>`#${e}`)].join(` · `)})]},e.id))]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wide text-muted-foreground`,children:e(`activity:ctxMonitor.cameWent`)}),n.slice(0,30).map(e=>(0,X.jsxs)(`div`,{className:`flex gap-2 border-b border-border/40 py-1.5 text-[10px] last:border-b-0`,children:[e.action===`exited`?(0,X.jsx)(kt,{className:`mt-0.5 size-3 shrink-0 text-muted-foreground`}):(0,X.jsx)(g,{className:`mt-0.5 size-3 shrink-0 text-success`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`p`,{className:`font-mono`,children:[(0,X.jsx)(`span`,{className:e.action===`exited`?`text-muted-foreground`:`text-success`,children:e.action}),` `,e.memoryId]}),(0,X.jsx)(`p`,{className:`truncate text-muted-foreground`,children:e.reason})]}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-muted-foreground`,children:[(0,X.jsx)(pn,{className:`size-2.5`}),` `,new Date(e.at).toLocaleTimeString()]})]},e.id))]})]})]})}function ef(){let{t:e}=R(),t=Pr(e=>e.items),n=Pr(e=>e.clear);return(0,X.jsxs)(`section`,{className:`shrink-0 border-b border-border/60 bg-info/[0.025]`,"aria-label":e(`activity:memoryManager.lifecycleAria`),children:[(0,X.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-4`,children:[(0,X.jsx)(Pe,{className:`size-3.5 text-info`}),(0,X.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wide text-info`,children:e(`activity:memoryManager.lifecycleHeading`)}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:t.length===0?e(`activity:memoryManager.statusWaiting`):e(`activity:memoryManager.statusLive`,{count:t.length})}),t.length>0&&(0,X.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,className:`ml-auto h-6 px-2 text-[10px]`,onClick:n,children:[(0,X.jsx)(hn,{className:`size-3`}),` `,e(`common:action.clear`)]})]}),t.length>0?(0,X.jsx)(`div`,{className:`max-h-20 overflow-y-auto border-t border-border/40`,children:t.slice(0,8).map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/30 px-4 py-1 text-[10px] last:border-b-0`,children:[(0,X.jsx)(tf,{action:e.action}),(0,X.jsx)(`span`,{className:H(`font-mono font-semibold`,nf(e.action)),children:e.label}),e.detail&&(0,X.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,title:e.detail,children:e.detail}),(0,X.jsx)(`time`,{className:`ml-auto shrink-0 text-muted-foreground`,children:new Date(e.at).toLocaleTimeString()})]},e.id))}):null]})}function tf({action:e}){let t=H(`size-3 shrink-0`,nf(e));return e===`entered`||e===`recovered`?(0,X.jsx)(Kn,{className:t}):e===`exited`?(0,X.jsx)(tr,{className:t}):e===`related`?(0,X.jsx)(je,{className:t}):(0,X.jsx)(cr,{className:t})}function nf(e){return e===`entered`||e===`recovered`?`text-success`:e===`exited`?`text-destructive`:e===`related`?`text-primary`:`text-info`}var rf=[{labelKey:`activity:ctxDash.zoneSafe`,emoji:`🟢`,color:`text-success`,bg:`bg-success/10`,text:`text-success`,cssColor:`hsl(var(--success))`,from:0,to:60,descKey:`activity:ctxDash.zoneSafeDesc`},{labelKey:`activity:ctxDash.zoneWarning`,emoji:`🟡`,color:`text-warning`,bg:`bg-warning/10`,text:`text-warning`,cssColor:`hsl(var(--warning))`,from:60,to:85,descKey:`activity:ctxDash.zoneWarningDesc`},{labelKey:`activity:ctxDash.zoneCritical`,emoji:`🔴`,color:`text-destructive`,bg:`bg-destructive/10`,text:`text-destructive`,cssColor:`hsl(var(--destructive))`,from:85,to:95,descKey:`activity:ctxDash.zoneCriticalDesc`},{labelKey:`activity:ctxDash.zoneDanger`,emoji:`⚫`,color:`text-brand-orange`,bg:`bg-brand-orange/15`,text:`text-brand-orange`,cssColor:`hsl(var(--brand-orange))`,from:95,to:100,descKey:`activity:ctxDash.zoneDangerDesc`}];function af(e){return e>95?rf[3]:e>85?rf[2]:e>60?rf[1]:rf[0]}function of(e){if(!e)return`—`;let t=Date.now()-e,n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),i=Math.floor(t%6e4/1e3);return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}function sf({title:e,icon:t,children:n,className:r,accent:i}){let a=i===`danger`?`text-destructive`:i===`warning`?`text-warning`:i===`success`?`text-success`:`text-muted-foreground`,o=i===`danger`?`bg-destructive/5`:i===`warning`?`bg-warning/5`:i===`success`?`bg-success/5`:``;return(0,X.jsxs)(`div`,{className:H(`rounded-xl border bg-card/80 backdrop-blur-sm p-4 space-y-3`,`shadow-sm transition-shadow hover:shadow-md`,`ring-1 ring-border/40`,o,r),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-bold tracking-tight text-foreground`,children:[(0,X.jsx)(`span`,{className:H(`flex items-center justify-center h-6 w-6 rounded-lg`,o,i!=="default"&&`ring-1 ring-inset`),children:(0,X.jsx)(t,{className:H(`h-3.5 w-3.5`,a)})}),e]}),n]})}function cf({label:e,value:t,color:n}){return(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,X.jsx)(`span`,{className:H(`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded`,n??`text-foreground`),children:t})]})}function lf({pct:e,size:t=96,strokeWidth:n=10}){let r=Math.max(0,Math.min(100,e)),i=(t-n)/2,a=2*Math.PI*i,o=r/100*a,s=af(r).cssColor;return(0,X.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:`drop-shadow-lg`,children:[(0,X.jsxs)(`title`,{children:[`Context usage: `,r.toFixed(0),`%`]}),(0,X.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:`hsl(var(--muted))`,strokeWidth:n,opacity:.3}),(0,X.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:s,strokeWidth:n,strokeLinecap:`round`,strokeDasharray:`${o} ${a-o}`,strokeDashoffset:0,className:`transition-all duration-1000 ease-out`,style:{transformOrigin:`center`,transform:`rotate(-90deg)`}}),(0,X.jsx)(`circle`,{cx:t/2,cy:t/2,r:i-n/2+2,fill:`hsl(var(--card))`,className:`drop-shadow-sm`}),(0,X.jsxs)(`text`,{x:t/2,y:t/2,textAnchor:`middle`,dominantBaseline:`central`,fill:s,className:`text-lg font-bold font-mono tabular-nums`,style:{fontSize:t*.16},children:[r.toFixed(0),`%`]})]})}function uf({value:e,suffix:t=``,duration:n=800}){let[r,i]=(0,Y.useState)(0),a=(0,Y.useRef)(0),o=(0,Y.useRef)(void 0);return(0,Y.useEffect)(()=>{let t=a.current,r=performance.now(),s=e-t;if(Math.abs(s)<1){i(e),a.current=e;return}let c=l=>{let u=l-r,d=Math.min(1,u/n),f=1-(1-d)**3;i(Math.round(t+s*f)),d<1?o.current=requestAnimationFrame(c):a.current=e};return o.current=requestAnimationFrame(c),()=>{o.current&&cancelAnimationFrame(o.current)}},[e,n]),(0,X.jsxs)(X.Fragment,{children:[r.toLocaleString(),t]})}function df({pct:e,tokens:t,maxTokens:n}){let{t:r}=R(),i=af(e),a=e>85?`danger`:e>60?`warning`:`success`;return(0,X.jsxs)(sf,{title:r(`activity:ctxDash.contextPressure`),icon:xe,accent:a,children:[(0,X.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center gap-4`,children:[(0,X.jsx)(`div`,{className:H(`shrink-0 transition-all duration-500`,e>85&&`animate-[pulse_2s_ease-in-out_infinite] drop-shadow-[0_0_12px_hsl(var(--destructive)/0.35)]`),children:(0,X.jsx)(lf,{pct:e,size:96,strokeWidth:10})}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 w-full`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-xl`,children:i.emoji}),(0,X.jsx)(`div`,{className:`flex-1`,children:(0,X.jsx)(ko,{pct:Math.round(e),tokens:t,maxTokens:n,segments:10,variant:`iridescent`})})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-1 text-[10px] font-mono tabular-nums`,children:[(0,X.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.used`)}),(0,X.jsx)(`span`,{className:H(`font-bold`,i.color),children:(0,X.jsx)(uf,{value:t})})]}),(0,X.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.free`)}),(0,X.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,X.jsx)(uf,{value:Math.max(0,n-t)})})]}),(0,X.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.capacity`)}),(0,X.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,X.jsx)(uf,{value:n})})]})]})]})]}),(0,X.jsxs)(`div`,{className:`relative h-4 mt-1`,children:[(0,X.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-2 rounded-full overflow-hidden flex`,children:rf.map(e=>(0,X.jsx)(`div`,{className:`h-full first:rounded-l-full last:rounded-r-full opacity-60`,style:{width:`${(e.to-e.from)/100*100}%`,backgroundColor:e.cssColor}},r(e.labelKey)))}),(0,X.jsxs)(`div`,{className:`absolute top-3 text-[10px] text-muted-foreground flex w-full`,children:[(0,X.jsx)(`span`,{children:`0%`}),(0,X.jsx)(`span`,{className:`ml-[56%]`,children:`soft`}),(0,X.jsx)(`span`,{className:`ml-[12%]`,children:`hard`}),(0,X.jsx)(`span`,{className:`ml-[8%]`,children:`max`}),(0,X.jsx)(`span`,{className:`ml-auto`,children:`100%`})]})]}),(0,X.jsx)(`div`,{className:`relative h-5 mt-1`,children:(0,X.jsx)(`div`,{className:`absolute top-0 -translate-x-1/2 flex flex-col items-center transition-all duration-500`,style:{left:`${Math.min(95,e)}%`},children:(0,X.jsxs)(`span`,{className:H(`text-[9px] font-mono px-1.5 py-0.5 rounded border transition-colors`,i.bg,i.text,`border-current/30`),children:[`◀ `,e.toFixed(0),`%`]})})})]})}function ff({data:e,loading:t}){let{t:n}=R();if(t)return(0,X.jsx)(sf,{title:n(`activity:ctxDash.contextComposition`),icon:$t,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground py-2`,children:[(0,X.jsx)(cr,{className:`h-3 w-3 animate-spin`}),n(`activity:ctxDash.fetchingCompositionData`)]})});if(!e||e.total<=0)return(0,X.jsx)(sf,{title:n(`activity:ctxDash.contextComposition`),icon:$t,children:(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:n(`activity:ctxDash.noCompositionDataAvailableYetRun`)})});let r=[{icon:yt,label:n(`activity:ctxDash.systemPrompt`),value:e.systemPrompt,className:`bg-info`},{icon:Xt,label:n(`activity:ctxDash.tools`),value:e.tools.total,className:`bg-warning`},{icon:Hn,label:n(`activity:ctxDash.messages`),value:e.messages.total,className:`bg-success`}];return(0,X.jsxs)(sf,{title:n(`activity:ctxDash.contextComposition`),icon:$t,children:[(0,X.jsx)(`div`,{className:`h-3 w-full overflow-hidden rounded-full bg-muted flex`,children:r.map(t=>{let n=t.value/e.total*100;return n<=0?null:(0,X.jsx)(`span`,{className:H(`h-full first:rounded-l-full last:rounded-r-full transition-all`,t.className),style:{width:`${n}%`}},t.label)})}),(0,X.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>{let n=(t.value/e.total*100).toFixed(1);return(0,X.jsx)(cf,{label:`${t.label}`,value:`${Ro(t.value)} (${n}%)`},t.label)})}),e.tools.breakdown.length>0&&(0,X.jsxs)(`div`,{className:`pt-1 border-t border-border/50`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-semibold`,children:n(`activity:ctxDash.toolBreakdown`)}),(0,X.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:e.tools.breakdown.slice(0,5).map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,X.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.name}),(0,X.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:Ro(e.tokens)})]},e.name))})]})]})}function pf({pct:e}){let{t}=R();return(0,X.jsxs)(sf,{title:t(`activity:ctxDash.thresholdMap`),icon:Le,children:[(0,X.jsx)(`div`,{className:`flex h-2 rounded-full overflow-hidden`,children:rf.map(e=>(0,X.jsx)(`div`,{className:`h-full first:rounded-l-full last:rounded-r-full opacity-80`,style:{width:`${(e.to-e.from)/100*100}%`,backgroundColor:e.cssColor}},t(e.labelKey)))}),(0,X.jsx)(`div`,{className:`space-y-0.5 text-xs`,children:rf.map(n=>{let r=e>=n.from&&e<n.to;return(0,X.jsxs)(`div`,{className:H(`flex items-center px-2 py-1 rounded`,r?n.bg:``),children:[(0,X.jsx)(`span`,{className:`w-5`,children:n.emoji}),(0,X.jsx)(`span`,{className:H(`w-20 font-medium`,r?n.text:`text-muted-foreground`),children:t(n.labelKey)}),(0,X.jsxs)(`span`,{className:`w-16 text-muted-foreground`,children:[n.from,`%–`,n.to,`%`]}),(0,X.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:t(n.descKey)}),r&&(0,X.jsx)(`span`,{className:`text-xs font-mono`,children:`◀`})]},t(n.labelKey))})}),(0,X.jsx)(cf,{label:t(`activity:ctxDash.currentPosition`),value:`${e.toFixed(1)}% → ${af(e).emoji} ${t(af(e).labelKey)}`,color:af(e).color}),(0,X.jsx)(cf,{label:t(`activity:ctxDash.compactTrigger`),value:`85%`}),(0,X.jsx)(cf,{label:t(`activity:ctxDash.hardLimit`),value:`100%`})]})}function mf({pct:e,maxTokens:t}){let{t:n}=R(),r=Math.round(t*.18),i=Math.round(t*.85),a=e>65,o=t>0?e/100:0;return(0,X.jsx)(sf,{title:n(`activity:ctxDash.compactionEngine`),icon:Ie,accent:a?`warning`:`success`,children:(0,X.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.strategy`)}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground/90`,children:`hybrid`}),(0,X.jsx)(`span`,{className:`text-success bg-success/10 px-1.5 rounded text-[9px] font-semibold`,children:n(`activity:ctxDash.auto`)})]}),(0,X.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:n(`activity:ctxDash.current`)}),(0,X.jsxs)(`span`,{children:[`Trigger (`,Ro(i),`)`]})]}),(0,X.jsxs)(`div`,{className:`relative h-2 w-full overflow-hidden rounded-full bg-muted/50 ring-1 ring-inset ring-border/20`,children:[(0,X.jsx)(`span`,{className:H(`absolute inset-y-0 left-0 rounded-full transition-all duration-700`,a?`bg-warning`:`bg-success`),style:{width:`${Math.max(2,o*100)}%`}}),(0,X.jsx)(`span`,{className:`absolute top-0 bottom-0 w-0.5 bg-destructive/60`,style:{left:`85%`}})]}),(0,X.jsxs)(`div`,{className:`flex justify-between text-[9px] text-foreground/70`,children:[(0,X.jsx)(`span`,{children:Ro(Math.round(t*o))}),(0,X.jsx)(`span`,{className:`text-destructive/70`,children:Ro(i)})]})]}),(0,X.jsx)(cf,{label:n(`activity:ctxDash.nextTrigger`),value:`${Ro(i)} (85%)`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.estRecovery`)}),(0,X.jsxs)(`span`,{className:`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded text-success bg-success/10`,children:[`~`,Ro(r)]})]}),(0,X.jsx)(cf,{label:n(`activity:ctxDash.recommendation`),value:a?`⚠️ Compact now`:`✅ No compaction needed`,color:a?`text-warning`:`text-success`}),a&&(0,X.jsxs)(`div`,{className:`bg-warning/5 border border-warning/20 rounded p-2 text-[10px] text-warning/90 mt-1`,children:[`Context at `,e.toFixed(1),`% — compacting recovers ~`,Ro(r),` tokens.`]})]})})}function hf({agents:e}){let{t}=R(),n=e.filter(e=>e.ctxPct!=null&&e.ctxPct>0);return n.length===0?null:(0,X.jsx)(sf,{title:t(`activity:ctxDash.perAgentFootprint`),icon:Tr,children:(0,X.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=af(e.ctxPct),n=e.name||e.id;return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`w-4`,children:e.id===`__leader__`?`👑`:` `}),(0,X.jsx)(`span`,{className:`w-24 truncate font-mono text-muted-foreground`,title:n,children:n}),(0,X.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,X.jsx)(Ao,{pct:Math.round(e.ctxPct),tokens:e.ctxTokens,maxTokens:e.maxContext,showTokens:!1})}),(0,X.jsxs)(`span`,{className:H(`tabular-nums w-10 text-right`,t.color),children:[Math.round(e.ctxPct),`%`]})]},e.id)})})})}function gf({tokens:e,maxTokens:t,pct:n,model:r,provider:i,mode:a,uptime:o,iteration:s,contextMode:c}){let{t:l}=R(),u=t-e,d=t>0?(u/t*100).toFixed(1):`0.0`;return(0,X.jsx)(sf,{title:l(`activity:ctxDash.tokenMetrics`),icon:Qn,children:(0,X.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,X.jsx)(cf,{label:l(`activity:ctxDash.used`),value:Ro(e)}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.free`),value:`${Ro(u)} (${d}%)`}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.capacity`),value:Ro(t)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:l(`activity:ctxDash.utilization`)}),(0,X.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,X.jsx)(Ao,{pct:Math.round(n),tokens:e,maxTokens:t})})]}),(0,X.jsx)(`div`,{className:`border-t border-border/50 pt-1 mt-1`}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.model`),value:`${r} · ${i}`}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.mode`),value:a}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.contextMode`),value:c}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.iteration`),value:s}),(0,X.jsx)(cf,{label:l(`activity:ctxDash.uptime`),value:o})]})})}function _f({model:e,provider:t,mode:n,uptime:r,projectName:i,cwd:a,contextMode:o}){let{t:s}=R();return(0,X.jsx)(sf,{title:s(`activity:ctxDash.session`),icon:Rt,children:(0,X.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,X.jsx)(cf,{label:s(`activity:ctxDash.provider`),value:t}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.model`),value:e}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.mode`),value:n}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.contextMode`),value:o}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.project`),value:i||a}),(0,X.jsx)(cf,{label:s(`activity:ctxDash.uptime`),value:r})]})})}function vf(){let{t:e}=R(),t=G(e=>e.setCurrentView),{lastInputTokens:n,maxContext:r,mode:i,contextMode:a,startTime:o,session:s,iteration:c,projectName:l,cwd:u}=U(fn(e=>({lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,mode:e.mode,contextMode:e.contextMode,startTime:e.startTime,session:e.session,iteration:e.iteration,projectName:e.projectName,cwd:e.cwd}))),d=ni(fn(e=>[...e.agents.values()])),f=W(e=>e.wsUrl),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null),y=(0,Y.useRef)(0),b=(0,Y.useRef)(null),x=()=>{b.current?.(),b.current=null;let e=V(f);if(!e?.send){v(`WebSocket not connected`);return}let t=++y.current;g(!0),v(null),e.send({type:`context.debug`},{echoToChat:!1});let n=!1,r,i=e.on(`context.debug`,e=>{n||e.type===`context.debug`&&y.current===t&&(n=!0,r!==void 0&&clearTimeout(r),m(e.payload),g(!1),i())});b.current=i,r=setTimeout(()=>{n||(n=!0,y.current===t&&(g(!1),v(`No response from server`),i()))},5e3)};(0,Y.useEffect)(()=>(x(),()=>{y.current++,b.current?.(),b.current=null}),[f]);let S=s?.model??`—`,C=s?.provider??`—`,w=r>0?Math.min(100,n/r*100):0,T=of(o),E=c?`${c.index} / ${c.max}`:`—`,D=af(w),O=e=>({animation:`fadeInUp 0.4s ease-out ${e*.08}s both`});return(0,X.jsxs)(`div`,{ref:Qd(`context`),className:`flex-1 min-h-0 overflow-y-auto overscroll-contain`,children:[(0,X.jsx)(`style`,{children:`
124
124
  @keyframes fadeInUp {
125
125
  from { opacity: 0; transform: translateY(12px); }
126
126
  to { opacity: 1; transform: translateY(0); }
@@ -129,4 +129,4 @@ Type while the agent is running to queue messages; they are sent automatically w
129
129
  `):``),y(n.url??``)):i?(s(i.name),l(i.transport),d(i.description??``),x(!0),C(i.lazy??!1),p(i.command??``),h(i.args?.join(` `)??``),_(i.env?Object.entries(i.env).map(([e,t])=>`${e}=${t}`).join(`
130
130
  `):``),y(i.url??``)):(s(``),l(`stdio`),d(``),x(!0),C(!1),p(``),h(``),_(``),y(``)))},[n,i,e]);let w=()=>{if(!o.trim()){q.error(a(`settings:mcp.serverNameRequired`));return}let e={};if(g.trim())for(let t of g.trim().split(`
131
131
  `)){let n=t.indexOf(`=`);n>0&&(e[t.slice(0,n).trim()]=t.slice(n+1).trim())}r({name:o.trim(),transport:c,description:u.trim()||void 0,enabled:b,command:f.trim()||void 0,args:m.trim()?m.trim().split(/\s+/):void 0,env:Object.keys(e).length>0?e:void 0,url:v.trim()||void 0,lazy:S}),t(!1)},T=!!n,E=!!i;return(0,X.jsx)(Ri,{open:e,onOpenChange:t,children:(0,X.jsxs)(Fi,{children:[(0,X.jsx)(Ni,{children:(0,X.jsx)(Ii,{children:a(T?`settings:mcp.dialogTitleEdit`:E?`settings:mcp.dialogTitleAdd`:`settings:mcp.dialogTitleAddCustom`)})}),(0,X.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldName`)}),(0,X.jsx)(zi,{value:o,onChange:e=>s(e.target.value),placeholder:a(`settings:mcp.fieldNamePlaceholder`),disabled:T||E})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldTransport`)}),(0,X.jsxs)(`select`,{className:`w-full h-10 px-3 rounded-md border border-input bg-background text-sm`,value:c,onChange:e=>l(e.target.value),disabled:E,children:[(0,X.jsx)(`option`,{value:`stdio`,children:`stdio`}),(0,X.jsx)(`option`,{value:`sse`,children:`sse`}),(0,X.jsx)(`option`,{value:`streamable-http`,children:`streamable-http`}),(0,X.jsx)(`option`,{value:`http`,children:`http`})]})]}),(c===`streamable-http`||c===`sse`||c===`http`)&&(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldUrl`)}),(0,X.jsx)(zi,{value:v,onChange:e=>y(e.target.value),placeholder:a(`activity:mCPSection.httpsMcpExampleComMcp`),disabled:E})]}),c===`stdio`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldCommand`)}),(0,X.jsx)(zi,{value:f,onChange:e=>p(e.target.value),placeholder:a(`settings:mcp.fieldCommandPlaceholder`),disabled:E})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldArgs`),` `,(0,X.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldArgsHint`)})]}),(0,X.jsx)(zi,{value:m,onChange:e=>h(e.target.value),placeholder:a(`settings:mcp.fieldArgsPlaceholder`),disabled:E})]})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldEnv`),` `,(0,X.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldEnvHint`)})]}),(0,X.jsx)(`textarea`,{className:`w-full h-20 px-3 py-2 rounded-md border border-input bg-background text-sm font-mono resize-none`,value:g,onChange:e=>_(e.target.value),placeholder:`GITHUB_TOKEN=ghp_...
132
- AWS_REGION=us-east-1`})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldDescription`)}),(0,X.jsx)(zi,{value:u,onChange:e=>d(e.target.value),placeholder:a(`settings:mcp.fieldDescriptionPlaceholder`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,id:`server-enabled`,checked:b,onChange:e=>x(e.target.checked),className:`rounded`}),(0,X.jsx)(`label`,{htmlFor:`server-enabled`,className:`text-sm`,children:a(`settings:mcp.enableServer`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,id:`server-lazy`,checked:S,onChange:e=>C(e.target.checked),className:`rounded`}),(0,X.jsxs)(`label`,{htmlFor:`server-lazy`,className:`text-sm`,children:[a(`settings:mcp.lazyConnect`),` `,(0,X.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.lazyConnectHint`)})]})]})]}),(0,X.jsxs)(Pi,{children:[(0,X.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,X.jsx)(J,{onClick:w,children:a(T?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function np({server:e,isAdded:t,onAdd:n}){let{t:r}=R();return(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),e.badge&&(0,X.jsx)(Yf,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-xs shrink-0`,children:e.transport})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description}),e.requiresEnvVars&&e.requiresEnvVars.length>0&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:r(`settings:mcp.requires`,{vars:e.requiresEnvVars.join(`, `)})})]}),(0,X.jsx)(`div`,{className:`shrink-0`,children:t?(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,disabled:!0,children:[(0,X.jsx)(a,{className:`w-4 h-4 mr-1`}),r(`settings:mcp.added`)]}):(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:n,children:[(0,X.jsx)(_,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function rp(){let e=Br(),{t}=R(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(`list`),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(),[g,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!e.client)return;let t=e=>{if(e.type===`mcp.list`){let t=e.payload;r(t.servers??[]),a(!1)}},n=e=>{if(e.type===`mcp.server.added`){let t=e.payload;r(e=>[...e.filter(e=>e.name!==t.server.name),t.server]),q.success(L.t(`settings:mcp.toastAdded`,{name:t.server.name}))}},i=e=>{if(e.type===`mcp.server.removed`){let t=e.payload;r(e=>e.filter(e=>e.name!==t.name)),q.success(L.t(`settings:mcp.toastRemoved`,{name:t.name}))}},o=e=>{if(e.type===`mcp.server.updated`){let t=e.payload;r(e=>e.map(e=>e.name===t.server.name?t.server:e))}},s=e=>{if(e.type===`mcp.server.discovered`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`,tools:t.tools}:e)),v(null),q.success(L.t(`settings:mcp.toastDiscovered`,{count:t.tools.length,name:t.name}))}},c=e=>{if(e.type===`mcp.server.sleeping`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`}:e)),v(null),q.info(L.t(`settings:mcp.toastSleeping`,{name:t.name}))}},l=e=>{if(e.type===`mcp.server.waking`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connecting`}:e))}},u=e=>{if(e.type===`mcp.server.connected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,pid:t.pid,error:void 0,lastError:void 0}:e)),v(null),q.success(L.t(`settings:mcp.toastConnected`,{name:t.name}))}},d=e=>{if(e.type===`mcp.server.reconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,error:void 0,lastError:void 0}:e)),v(null),q.success(L.t(`settings:mcp.toastReconnected`,{name:t.name}))}},f=e=>{if(e.type===`mcp.server.disconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.reason,lastError:t.reason,pid:void 0}:e)),v(null),q.warn(L.t(`settings:mcp.toastDisconnected`,{name:t.name,reason:t.reason}))}},p=e=>{if(e.type===`mcp.server.error`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.error}:e)),v(null),q.error(L.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},m=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||q.error(t.message),v(null)}},h=e.client.on(`mcp.list`,t),g=e.client.on(`mcp.server.added`,n),_=e.client.on(`mcp.server.removed`,i),y=e.client.on(`mcp.server.updated`,o),b=e.client.on(`mcp.server.discovered`,s),x=e.client.on(`mcp.server.sleeping`,c),S=e.client.on(`mcp.server.waking`,l),C=e.client.on(`mcp.server.connected`,u),w=e.client.on(`mcp.server.error`,p),T=e.client.on(`mcp.operation_result`,m),E=e.client.on(`mcp.server.reconnected`,d),D=e.client.on(`mcp.server.disconnected`,f);return a(!0),e.client?.listMcpServers(),()=>{h?.(),g?.(),_?.(),y?.(),b?.(),x?.(),S?.(),C?.(),w?.(),T?.(),E?.(),D?.()}},[e.client]);let y=(0,Y.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),b=(0,Y.useCallback)(e=>{h(Zf(e,!1)),p(!0)},[]),x=(0,Y.useCallback)(n=>{Hi({title:t(`settings:mcp.removeConfirmTitle`,{name:n}),message:t(`settings:mcp.removeConfirmBody`),confirmLabel:t(`common:action.remove`),danger:!0}).then(t=>{t&&e.client?.removeMcpServer(n)})},[e]),S=(0,Y.useCallback)(e=>{l(e),h(void 0),d(!0)},[]),C=(0,Y.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),w=(0,Y.useCallback)(t=>{v(t),e.client?.wakeMcpServer(t)},[e]),T=(0,Y.useCallback)(t=>{v(t),e.client?.sleepMcpServer(t)},[e]),E=(0,Y.useCallback)(t=>{v(t),e.client?.discoverMcpServer(t)},[e]),D=(0,Y.useCallback)(()=>{a(!0),e.client?.listMcpServers()},[e]),O=n.filter(e=>e.status===`connected`).length,k=n.filter(e=>e.status===`sleeping`).length,A=new Set(n.map(e=>e.name));return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Gn,{className:`h-5 w-5`})}),(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`settings:mcp.heading`)}),n.length>0&&(0,X.jsx)(`span`,{className:`rounded-md border border-border/60 bg-muted/30 px-2 py-1 text-xs text-muted-foreground`,children:t(`settings:mcp.summary`,{connected:O,sleeping:k,total:n.length})})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(J,{variant:`outline`,size:`sm`,onClick:D,disabled:i,children:[i?(0,X.jsx)(ln,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,X.jsxs)(J,{size:`sm`,onClick:()=>{h(void 0),p(!0)},children:[(0,X.jsx)(_,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,X.jsxs)(Ya,{value:o,onValueChange:e=>s(e),children:[(0,X.jsxs)(Xa,{children:[(0,X.jsxs)(Za,{value:`recommended`,children:[(0,X.jsx)(Ar,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,X.jsx)(Za,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,X.jsx)(Za,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,X.jsxs)(Qa,{value:`recommended`,className:`space-y-3`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.recommendedBody`)}),(0,X.jsx)(`div`,{className:`grid gap-2`,children:Xf.map(e=>(0,X.jsx)(np,{server:e,isAdded:A.has(e.name),onAdd:()=>b(e)},e.name))})]}),(0,X.jsx)(Qa,{value:`list`,className:`space-y-3`,children:i&&n.length===0?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:[(0,X.jsx)(ln,{className:`w-5 h-5 animate-spin mr-2`}),t(`settings:mcp.loadingServers`)]}):n.length===0?(0,X.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,X.jsx)(Gn,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,X.jsx)(`p`,{children:t(`settings:mcp.noServers`)}),(0,X.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.noServersHint`)})]}):n.map(e=>(0,X.jsx)(ep,{server:e,onWake:()=>w(e.name),onSleep:()=>T(e.name),onDiscover:()=>E(e.name),onEdit:()=>S(e),onRemove:()=>x(e.name)},e.name))}),(0,X.jsx)(Qa,{value:`add`,children:(0,X.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,X.jsx)(`p`,{children:t(`settings:mcp.addCustomBody`)}),(0,X.jsx)(`p`,{className:`mt-1`,children:t(`settings:mcp.addCustomBodyHint`)})]})})]}),(0,X.jsx)(tp,{open:f,onOpenChange:e=>{e||(p(!1),h(void 0))},prefillConfig:m,onSave:y}),(0,X.jsx)(tp,{open:u,onOpenChange:d,server:c,onSave:C})]})}function ip({syncPref:e}){let{t}=R(),n=z();return(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Gn,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.hqHeading`)})})]}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)($,{label:t(`settings:integrations.hqPublishingLabel`),hint:t(`settings:integrations.hqPublishingHint`),value:n.hqEnabled,onChange:()=>e(`hqEnabled`,!n.hqEnabled)}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqUrlLabel`)}),(0,X.jsx)(zi,{value:n.hqUrl,placeholder:t(`activity:integrationsSection.httpHost3499`),onChange:t=>e(`hqUrl`,t.target.value)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.hqUrlHint`)})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqTokenLabel`)}),(0,X.jsx)(zi,{type:`password`,value:n.hqToken,placeholder:t(`activity:integrationsSection.clientTokenFromWstackHq`),onChange:t=>e(`hqToken`,t.target.value)})]}),(0,X.jsx)($,{label:t(`settings:integrations.hqRawContentLabel`),hint:t(`settings:integrations.hqRawContentHint`),value:n.hqRawContent,onChange:()=>e(`hqRawContent`,!n.hqRawContent)})]})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Gn,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`activity:integrationsSection.mcpServers`)})})]}),n.featureMcp?(0,X.jsx)(rp,{}):(0,X.jsxs)(`div`,{className:`text-center py-6 text-muted-foreground`,children:[(0,X.jsx)(Gn,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,X.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.disabled`)}),(0,X.jsx)(`p`,{className:`text-xs mt-1`,children:t(`settings:integrations.disabledHint`)})]})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(cn,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.telegramHeading`)})})]}),n.tgConfigured?(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)($,{label:t(`settings:integrations.telegramSessionEndLabel`),hint:t(`settings:integrations.telegramSessionEndHint`),value:n.tgSessionEnd,onChange:()=>e(`tgSessionEnd`,!n.tgSessionEnd)}),(0,X.jsx)($,{label:t(`settings:integrations.telegramDelegateLabel`),hint:t(`settings:integrations.telegramDelegateHint`),value:n.tgDelegate,onChange:()=>e(`tgDelegate`,!n.tgDelegate)}),(0,X.jsx)($,{label:t(`settings:integrations.telegramLongToolLabel`),hint:t(`settings:integrations.telegramLongToolHint`,{ms:n.tgLongToolMs}),value:n.tgLongToolMs>0,onChange:()=>e(`tgLongToolMs`,n.tgLongToolMs>0?0:3e4)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramChangesApply`)})]}):(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramNotConfigured`)})]})]})}function ap({provider:e,catalogModels:t,currentCatalogProvider:n,isLoadingModels:r,isSwitching:i,setIsLoadingModels:a,onModelSelect:o,refreshModels:s}){let c=W(e=>e.model),{t:l}=R();return(0,X.jsx)(`div`,{className:`space-y-4`,children:e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:n?.name||e}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>{a(!0),s(e)},children:(0,X.jsx)(cr,{className:H(`h-4 w-4`,r&&`animate-spin`)})})]}),r&&!t[e]?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,X.jsx)(ln,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,X.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:l(`settings:model.loading`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Sf,{options:(t[e]||[]).map(e=>({id:e.id,label:e.name||e.id,badges:e.capabilities,detail:[e.contextWindow?`${Math.round(e.contextWindow/1e3)}k`:``,e.inputCost==null?``:`${e.inputCost}/${e.outputCost}`].filter(Boolean).join(` · `),detailHighlight:!0})),selectedId:c,onSelect:o,disabled:i,emptyMessage:l(`settings:model.notFound`)}),i?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`settings:toast.switching`)}):null]})]}):(0,X.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,X.jsx)(Rt,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,X.jsx)(`p`,{children:l(`settings:model.selectProviderFirst`)})]})})}var op=Object.freeze([{name:`wstack-prompts`,risk:`medium`,summary:`Prompt library and prompt authoring commands.`,defaultState:`active`,canDisable:!0},{name:`wstack-sync`,risk:`medium`,summary:`Cloud sync commands for prompts, skills, settings, memory, and history.`,defaultState:`active`,canDisable:!0},{name:`wstack-cloud-config-sync`,risk:`medium`,summary:`my.wrongstack.com config synchronization over the namespaced sync API.`,defaultState:`active`,canDisable:!0},{name:`wstack-chimera`,risk:`medium`,summary:`Spawns a post-session code review subagent when explicitly enabled.`,defaultState:`inactive`,canDisable:!0},{name:`wstack-auto-review`,risk:`medium`,summary:`Tracks changed files and requests bounded mid-session Chimera reviews.`,defaultState:`inactive`,canDisable:!0},{name:`wstack-skills`,risk:`medium`,summary:`Skill library, authoring, install, update, and uninstall commands.`,defaultState:`active`,canDisable:!0},{name:`@wrongstack/plug-lsp`,risk:`medium`,summary:`Language Server Protocol tools and slash commands.`,defaultState:`inactive`,canDisable:!0},{name:`telegram`,risk:`medium`,summary:`Telegram bridge for messages, approvals, and notifications.`,defaultState:`inactive`,canDisable:!0},{name:`agent-handoff`,risk:`medium`,summary:`Listens for subagent.done events and posts structured handoff notes to the project mailbox`,defaultState:`inactive`,canDisable:!0},{name:`cost-tracker`,risk:`low`,summary:`Tracks LLM token usage and estimated cost per session with per-model breakdown`,defaultState:`active`,canDisable:!0},{name:`file-watcher`,risk:`medium`,summary:`Watches project files and emits events when changes occur (add, change, delete)`,defaultState:`inactive`,canDisable:!0},{name:`git-autocommit`,risk:`high`,summary:`AI-powered git staging and conventional commit message generation`,defaultState:`inactive`,canDisable:!0},{name:`auto-doc`,risk:`medium`,summary:`Auto-generates JSDoc/TSDoc comments for functions, classes, types, and interfaces`,defaultState:`inactive`,canDisable:!0},{name:`shell-check`,risk:`low`,summary:`Runs shellcheck analysis on bash/shell scripts and surfaces issues with severity levels`,defaultState:`inactive`,canDisable:!0},{name:`cron`,risk:`medium`,summary:`Schedules recurring tasks using beforeIteration/afterIteration extension hooks`,defaultState:`inactive`,canDisable:!0},{name:`template-engine`,risk:`medium`,summary:`Expands file templates with variable substitution, conditionals, and loops`,defaultState:`inactive`,canDisable:!0},{name:`semver-bump`,risk:`high`,summary:`Conventional-commit-driven semver version bumps with changelog generation`,defaultState:`inactive`,canDisable:!0},{name:`secret-scanner`,risk:`high`,summary:`Pre-tool hook that blocks (or optionally redacts) tools whose arguments contain plaintext credentials`,defaultState:`active`,canDisable:!0},{name:`todo-tracker`,risk:`low`,summary:`Persistent, project-scoped todo backlog that survives across sessions`,defaultState:`active`,canDisable:!0},{name:`token-budget`,risk:`medium`,summary:`Enforces a per-session token budget — warns at a threshold and stops the agent loop when the limit is hit`,defaultState:`active`,canDisable:!0},{name:`lint-gate`,risk:`medium`,summary:`Pre-tool hook that runs biome/eslint on would-be file content before write or edit commits`,defaultState:`inactive`,canDisable:!0},{name:`branch-guard`,risk:`high`,summary:`Pre-tool hook that blocks commits, pushes, and merges to protected branches (default: main, master)`,defaultState:`inactive`,canDisable:!0},{name:`diff-summary`,risk:`low`,summary:`PostToolUse hook that injects a compact git diff into the LLM context after every write or edit`,defaultState:`active`,canDisable:!0},{name:`commit-validator`,risk:`medium`,summary:`PreToolUse hook that validates conventional-commit format before git_autocommit or bash git commit runs`,defaultState:`inactive`,canDisable:!0},{name:`format-on-save`,risk:`medium`,summary:`PostToolUse hook that runs biome format --write on the file after every write or edit`,defaultState:`inactive`,canDisable:!0},{name:`test-runner-gate`,risk:`medium`,summary:`PostToolUse hook that runs the relevant test file after every write or edit to a source file`,defaultState:`inactive`,canDisable:!0},{name:`import-organizer`,risk:`medium`,summary:`PostToolUse hook that re-sorts and de-duplicates imports in a file after every write or edit`,defaultState:`inactive`,canDisable:!0},{name:`knowledge-graph`,risk:`low`,summary:`Accumulates structured (subject, relation, object) facts about the project and queries them across sessions`,defaultState:`active`,canDisable:!0},{name:`todo-listener`,risk:`low`,summary:"PostToolUse hook on `todo` tool — broadcasts a status update to the project mailbox so other agents can see what this one is working on",defaultState:`inactive`,canDisable:!0},{name:`session-recap`,risk:`low`,summary:`Stop hook that posts a one-page session summary (tokens, tools, commits, last activity) to the project mailbox`,defaultState:`inactive`,canDisable:!0},{name:`spec-linker`,risk:`low`,summary:"Markdown link auditor for plugin references. PostToolUse surfaces unlinked references; PreToolUse on `write` (autoFix) wraps them in markdown links via modifiedInput.",defaultState:`inactive`,canDisable:!0},{name:`loop-breaker`,risk:`low`,summary:`Detects runaway tool-call loops (identical repeats and A-B-A-B oscillation) — warns the model, then blocks`,defaultState:`active`,canDisable:!0},{name:`path-guard`,risk:`medium`,summary:`Blocks or warns about writes, edits, and destructive shell commands touching protected paths (lockfiles, .env, .git, migrations)`,defaultState:`inactive`,canDisable:!0},{name:`process-guard`,risk:`high`,summary:`Blocks kill commands (taskkill, Stop-Process, kill, pkill, wmic) that target active WrongStack processes or their host terminals.`,defaultState:`active`,canDisable:!0},{name:`context-pins`,risk:`low`,summary:`Pin durable facts into the system prompt (pin_add/pin_remove/pin_list) — pins survive compaction and persist across sessions`,defaultState:`active`,canDisable:!0},{name:`checkpoint`,risk:`medium`,summary:`In-session file snapshots: auto-captures content before every write/edit and restores any pre-edit state on demand`,defaultState:`inactive`,canDisable:!0},{name:`error-lens`,risk:`low`,summary:`Distills failed command output into a compact digest (error line + project stack frames) and flags repeated failures`,defaultState:`active`,canDisable:!0},{name:`dep-guard`,risk:`medium`,summary:`Supervises dependency installs: blocks deny-listed packages, flags typosquat lookalikes, and optionally warns on unpinned versions`,defaultState:`active`,canDisable:!0},{name:`config-validator`,risk:`low`,summary:`Validates JSON/JSONC/YAML/TOML files right after write/edit and reports syntax problems in the same turn`,defaultState:`active`,canDisable:!0},{name:`notify-hub`,risk:`medium`,summary:`POSTs session events (stop, tool errors, budget thresholds) and ad-hoc notify_send messages to a configurable webhook`,defaultState:`inactive`,canDisable:!0},{name:`changelog-writer`,risk:`low`,summary:`Collects session work (commits, edits, manual notes) and writes Keep-a-Changelog entries under [Unreleased] on demand`,defaultState:`inactive`,canDisable:!0},{name:`injection-shield`,risk:`low`,summary:`Scans tool output (fetched pages, files) for prompt-injection patterns and warns the model that content is data, not instructions`,defaultState:`active`,canDisable:!0},{name:`llm-cache`,risk:`medium`,summary:`Caches identical provider requests and short-circuits the provider call on a hit (wrapProviderRunner). Opt-in; deterministic-only by default.`,defaultState:`inactive`,canDisable:!0},{name:`model-router`,risk:`medium`,summary:`Routes each provider call to a different model by declarative size/tool rules (wrapProviderRunner). Opt-in; dry-run by default; routes within the active provider only.`,defaultState:`inactive`,canDisable:!0},{name:`pr-drafter`,risk:`low`,summary:`Collects session work (commits, edited files, diff) and drafts a pull-request description`,defaultState:`inactive`,canDisable:!0},{name:`prompt-firewall`,risk:`high`,summary:`Scans the provider wire for credential leaks before context reaches the LLM API (wrapProviderRunner); redact/warn/block. Opt-in; redact by default.`,defaultState:`inactive`,canDisable:!0},{name:`auto-escalate`,risk:`medium`,summary:`On retryable provider errors, retries the turn with the next model in an escalation ladder (onError). Opt-in; defers to default recovery otherwise.`,defaultState:`inactive`,canDisable:!0},{name:`test-coverage-gate`,risk:`medium`,summary:`PostToolUse hook that detects test coverage regressions after source-file edits`,defaultState:`inactive`,canDisable:!0},{name:`type-gate`,risk:`medium`,summary:`PostToolUse hook that runs TypeScript type-checking after every write or edit to a source file`,defaultState:`inactive`,canDisable:!0},{name:`token-throttle`,risk:`medium`,summary:`Rolling-window tokens/min budget that delays provider calls to stay under a rate limit (wrapProviderRunner). Opt-in; delay capped by maxDelayMs.`,defaultState:`inactive`,canDisable:!0},{name:`plugin-stack-observer`,risk:`low`,summary:`Observes the wrapProviderRunner stack and exposes it to operators (plugin_stack_status) and, optionally, to the LLM (system-prompt contributor).`,defaultState:`inactive`,canDisable:!0},{name:`dependency-vulnerability-gate`,risk:`high`,summary:`PostToolUse hook that runs npm/pnpm audit after dependency installs and blocks or warns on vulnerabilities above a severity threshold`,defaultState:`inactive`,canDisable:!0},{name:`migration-planner`,risk:`low`,summary:`Builds evidence-backed migration checklists with optional Council-reviewed risk analysis`,defaultState:`inactive`,canDisable:!0},{name:`semantic-search-indexer`,risk:`low`,summary:`Builds an in-memory keyword index over project source files and answers ranked search queries`,defaultState:`inactive`,canDisable:!0},{name:`auto-i18n-extractor`,risk:`low`,summary:`Detects hardcoded user-facing strings in UI source files and suggests translation keys`,defaultState:`inactive`,canDisable:!0},{name:`doc-sync-guard`,risk:`low`,summary:`PostToolUse hook that tracks changed public source files and warns when README/docs edits omit them`,defaultState:`inactive`,canDisable:!0},{name:`api-compatibility-gate`,risk:`medium`,summary:`PostToolUse hook that detects breaking API changes (removed exports) in entry-point files after writes or edits`,defaultState:`inactive`,canDisable:!0},{name:`performance-regression-gate`,risk:`medium`,summary:`Compares benchmark results to detect performance regressions and reports metrics that increased beyond the configured threshold`,defaultState:`inactive`,canDisable:!0},{name:`test-flake-detector`,risk:`medium`,summary:`Runs a test command multiple times and reports tests that fail non-deterministically`,defaultState:`inactive`,canDisable:!0},{name:`schema-evolution-guard`,risk:`high`,summary:`PostToolUse hook that guards database/API schema changes by detecting destructive patterns in schema files`,defaultState:`inactive`,canDisable:!0},{name:`license-audit-gate`,risk:`high`,summary:`PostToolUse hook that audits dependency licenses after package-manager install/add commands and blocks disallowed licenses`,defaultState:`inactive`,canDisable:!0},{name:`accessibility-auditor`,risk:`medium`,summary:`Audits .tsx/.jsx/.html/.vue files for common accessibility issues and reports findings after writes/edits`,defaultState:`inactive`,canDisable:!0},{name:`security-hotspot-scanner`,risk:`high`,summary:`Scans source code for security anti-patterns and warns after writes/edits that introduce new hotspots`,defaultState:`inactive`,canDisable:!0},{name:`dead-code-detector`,risk:`low`,summary:`Lightweight regex-based scan for exported identifiers that appear unused anywhere in the project`,defaultState:`inactive`,canDisable:!0},{name:`duplicate-code-detector`,risk:`low`,summary:`Finds duplicated code blocks across source files using normalized-line fingerprinting`,defaultState:`inactive`,canDisable:!0},{name:`code-metrics`,risk:`low`,summary:`Computes per-file line counts, function counts, and cyclomatic-complexity-like scores`,defaultState:`inactive`,canDisable:!0},{name:`refactor-suggester`,risk:`low`,summary:`Suggests refactoring opportunities using regex-based smell detection`,defaultState:`inactive`,canDisable:!0},{name:`test-generator`,risk:`low`,summary:`Generates framework-correct test skeletons with optional host-routed LLM test authoring`,defaultState:`inactive`,canDisable:!0},{name:`release-notes-generator`,risk:`low`,summary:`Generates traceable release notes from conventional commits with optional LLM polishing`,defaultState:`inactive`,canDisable:!0},{name:`smart-rename`,risk:`medium`,summary:`Whole-word identifier rename inside a single source file`,defaultState:`inactive`,canDisable:!0},{name:`feature-flag-tracker`,risk:`low`,summary:`Scans source files for feature-flag-like expressions and reports usages`,defaultState:`inactive`,canDisable:!0},{name:`interface-contract-guard`,risk:`medium`,summary:`Checks TypeScript interfaces for visible implementers and warns about contract drift`,defaultState:`inactive`,canDisable:!0}]),sp={"wstack-chimera":`settings:context.pluginChimera`,"wstack-skills":`settings:context.pluginSkills`,"wstack-prompts":`settings:context.pluginPrompts`,"cost-tracker":`settings:context.pluginCostTracker`,telegram:`settings:context.pluginTelegram`,"knowledge-graph":`settings:context.pluginKnowledgeGraph`,"error-lens":`settings:context.pluginErrorLens`,"todo-tracker":`settings:context.pluginTodoTracker`,"secret-scanner":`settings:context.pluginSecretScanner`,"lint-gate":`settings:context.pluginLintGate`,"diff-summary":`settings:context.pluginDiffSummary`,"dep-guard":`settings:context.pluginDepGuard`,"type-gate":`settings:context.pluginTypeGate`,"injection-shield":`settings:context.pluginInjectionShield`,"prompt-firewall":`settings:context.pluginPromptFirewall`,"token-budget":`settings:context.pluginTokenBudget`,"loop-breaker":`settings:context.pluginLoopBreaker`};function cp(e){return e.replace(/^@wrongstack\//,``).replace(/^wstack-/,``).split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var lp=[...op].sort((e,t)=>cp(e.name).localeCompare(cp(t.name)));function up(){let{t:e}=R(),t=z();return(0,X.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,X.jsx)(zt,{className:`h-4 w-4 text-muted-foreground`}),e(`settings:context.pluginsPerPluginHeading`)]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:e(`settings:context.pluginsPerPluginHint`)}),lp.map(n=>{let r=sp[n.name],i=r?e(r):cp(n.name),a=t.pluginsEnabled?.[n.name]??n.defaultState===`active`;return(0,X.jsx)($,{label:i,hint:n.summary,value:a,disabled:!n.canDisable,onChange:()=>{let e={...t.pluginsEnabled,[n.name]:!a};t.set({pluginsEnabled:e})}},n.name)})]})}function dp({maskedKey:e,className:t}){let{t:n}=R(),[r,i]=(0,Y.useState)(!1),o=(0,Y.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),1500)})},[e]);return(0,X.jsxs)(`div`,{className:H(`group flex items-center gap-1.5 rounded-md border border-border/50 bg-background/50 px-2 py-1 font-mono text-xs text-muted-foreground`,t),children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate tracking-wide`,children:e}),(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-all hover:text-foreground group-hover:opacity-100 focus:opacity-100`,title:r?`Copied`:`Copy key preview`,"aria-label":n(`activity:apikeydisplay.copyApiKeyToClipboard`),children:r?(0,X.jsx)(a,{className:`h-3 w-3 text-success`}):(0,X.jsx)(Qe,{className:`h-3 w-3`})})]})}function fp(){let e=(0,Y.useRef)([]);return{setFieldRef:(0,Y.useCallback)(t=>n=>{e.current[t]=n},[]),handleKeyDown:(0,Y.useCallback)((t,n,r)=>{if(t.key===`ArrowDown`){t.preventDefault();for(let t=n+1;t<e.current.length;t++){let n=e.current[t];if(n&&!n.hasAttribute(`disabled`)&&n.getAttribute(`aria-disabled`)!==`true`){if(n.focus(),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){let e=n.value.length;n.setSelectionRange(e,e)}return}}return}if(t.key===`ArrowUp`){t.preventDefault();for(let t=n-1;t>=0;t--){let n=e.current[t];if(n&&!n.hasAttribute(`disabled`)&&n.getAttribute(`aria-disabled`)!==`true`){n.focus(),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&n.setSelectionRange(n.value.length,n.value.length);return}}return}t.key===`Enter`&&r&&(t.preventDefault(),r())},[])}}var pp={openrouter:{id:`openrouter`,name:`OpenRouter (Metered)`,family:`openai-compatible`,baseUrl:`https://openrouter.ai/api/v1`,envVars:[`OPENROUTER_API_KEY`],models:[`openai/gpt-4o`,`openai/gpt-4o-mini`,`anthropic/claude-sonnet-4-20250514`,`google/gemini-2.0-flash-001`,`meta-llama/llama-4-scout`,`deepseek/deepseek-chat`],usage:`metered-api`,docsUrl:`https://openrouter.ai/docs/quickstart`,autoDiscover:!0,requestPolicy:`openrouter`,catalog:{description:`All models via one key`,icon:`🔀`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`sk-or-...`}},"kimi-for-coding":{id:`kimi-for-coding`,name:`Kimi Code (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.kimi.com/coding/v1`,envVars:[`KIMI_API_KEY`],models:[`kimi-for-coding`,`kimi-for-coding-highspeed`],quirks:{thinkingParam:`kimi-toggle`},usage:`subscription-interactive`,docsUrl:`https://www.kimi.com/code/docs/en/third-party-tools/other-coding-agents.html`,requestPolicy:`kimi`,catalog:{description:`Personal interactive coding with the Kimi Code subscription key. Generate the API key at kimi.com/code/console.`,icon:`🌙`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`sk-...`}},moonshotai:{id:`moonshotai`,name:`Moonshot Platform (Metered)`,family:`openai-compatible`,baseUrl:`https://api.moonshot.ai/v1`,envVars:[`MOONSHOT_API_KEY`],models:[`kimi-k2.7-code`,`kimi-k2.7-code-highspeed`],quirks:{thinkingParam:`always-on`},usage:`metered-api`,docsUrl:`https://platform.kimi.ai/docs/api/overview`,requestPolicy:`kimi`,catalog:{description:`Metered Moonshot Platform API — pay-as-you-go for automation, background work, and commercial use.`,icon:`🌑`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`sk-...`}},"zai-coding-plan":{id:`zai-coding-plan`,name:`Z.AI Coding Plan (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.z.ai/api/coding/paas/v4`,envVars:[`ZHIPU_API_KEY`],models:[`glm-5.2`,`glm-5-turbo`,`glm-4.7`],quirks:{thinkingParam:`zai-glm`},usage:`subscription-interactive`,docsUrl:`https://docs.z.ai/devpack/quick-start`,requestPolicy:`zai`,catalog:{description:`Use your Z.AI Coding Plan subscription. Generate an API key from your Z.AI dashboard.`,icon:`🔷`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`...`}},zai:{id:`zai`,name:`Z.AI API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.z.ai/api/paas/v4`,envVars:[`ZHIPU_API_KEY`],models:[`glm-4.7`,`glm-5-turbo`,`glm-5.2`],quirks:{thinkingParam:`zai-glm`},usage:`metered-api`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,requestPolicy:`zai`,catalog:{description:`Pay-as-you-go Z.AI GLM access for automation and commercial use.`,icon:`🔷`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`...`,referral:{code:`JQZ7TPPRA6`,reward:`Limited-time deal for GLM Coding Plan subscription`,url:`https://z.ai/subscribe?ic=JQZ7TPPRA6`}}},minimax:{id:`minimax`,name:`MiniMax Token Plan (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.minimax.io/v1`,envVars:[`MINIMAX_API_KEY`],models:[`MiniMax-M3`,`MiniMax-M2.7`,`MiniMax-M2.5`,`MiniMax-M2`],usage:`subscription-interactive`,docsUrl:`https://platform.minimax.io/docs/api-reference/text-chat-openai`,catalog:{description:`Subscribe to one plan and unlock frontier coding, 1M context, and native multimodality.`,icon:`🔮`,color:`from-destructive/10 to-destructive/5 border-destructive/25 hover:border-destructive/45`,keyPlaceholder:`eyJ...`,referral:{code:`JrA4R9QAEn`,reward:`Friends get 10% off + Builder benefits. Referrers earn 10% cashback + community perks.`,url:`https://platform.minimax.io/subscribe/token-plan?code=JrA4R9QAEn&source=link`}}},mistral:{id:`mistral`,name:`Mistral AI API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.mistral.ai/v1`,envVars:[`MISTRAL_API_KEY`],models:[`mistral-large-latest`,`codestral-latest`,`ministral-8b-latest`],usage:`metered-api`,docsUrl:`https://docs.mistral.ai/`,catalog:{description:`Mistral Large, Codestral, and Ministral — open-weight frontier models.`,icon:`🌬️`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`Vz8d...`}},deepseek:{id:`deepseek`,name:`DeepSeek API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.deepseek.com`,envVars:[`DEEPSEEK_API_KEY`],models:[`deepseek-v4-flash`,`deepseek-v4-pro`],usage:`metered-api`,docsUrl:`https://api-docs.deepseek.com/`,requestPolicy:`deepseek`,catalog:{description:`High-performance reasoning at low cost`,icon:`🐋`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`sk-...`}},groq:{id:`groq`,name:`GroqCloud (Metered)`,family:`openai-compatible`,baseUrl:`https://api.groq.com/openai/v1`,envVars:[`GROQ_API_KEY`],models:[`llama-3.3-70b-versatile`,`llama-3.1-8b-instant`,`mixtral-8x7b-32768`,`gemma2-9b-it`],usage:`metered-api`,docsUrl:`https://console.groq.com/docs/api-reference`,requestPolicy:`groq`,catalog:{description:`Ultra-fast inference via LPU hardware — Llama, Mixtral, Gemma, and Qwen models.`,icon:`⚡`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`gsk_...`}},perplexity:{id:`perplexity`,name:`Perplexity Sonar API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.perplexity.ai`,envVars:[`PERPLEXITY_API_KEY`],models:[`sonar-pro`,`sonar`,`sonar-reasoning-pro`,`sonar-reasoning`],usage:`metered-api`,docsUrl:`https://docs.perplexity.ai/`,requestPolicy:`perplexity`,catalog:{description:`Web-augmented chat models with built-in search and citations.`,icon:`🔍`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`pplx-...`}},"alibaba-token-plan":{id:`alibaba-token-plan`,name:`Alibaba Token Plan (Personal Edition)`,family:`openai-compatible`,baseUrl:`https://dashscope.aliyuncs.com/compatible-mode/v1`,envVars:[`ALIBABA_API_KEY`,`DASHSCOPE_API_KEY`],models:[`qwen3.8-max-preview`,`qwen3.7-max`,`qwen3.7-plus`,`qwen3.6-flash`,`glm-5.2`,`deepseek-v4-pro`,`wan2.7-image`,`wan2.7-image-pro`,`happyhorse-1.1-t2v`,`happyhorse-1.1-i2v`,`happyhorse-1.1-r2v`],customModels:{"qwen3.8-max-preview":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.7-max":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.7-plus":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.6-flash":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"glm-5.2":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"deepseek-v4-pro":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!1,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"wan2.7-image":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"wan2.7-image-pro":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-t2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-i2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-r2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}}},usage:`subscription-interactive`,docsUrl:`https://www.alibabacloud.com/help/en/model-studio/token-plan-personal-overview`,requestPolicy:`alibaba`,catalog:{description:`Monthly Credits subscription for Qwen, DeepSeek, GLM, Wanx image, and HappyHorse video models.`,icon:`☁️`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`sk-...`}}};Object.keys(pp);var mp=[{id:`openai`,name:`OpenAI`,family:`openai`,envVars:[`OPENAI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://platform.openai.com/api-keys`,catalog:{description:`GPT, o-series, and Codex models`,icon:`🤖`,color:`from-success/12 to-success/5 border-success/30 hover:border-success/50`,keyPlaceholder:`sk-...`}},{id:`anthropic`,name:`Anthropic`,family:`anthropic`,envVars:[`ANTHROPIC_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://console.anthropic.com/settings/keys`,catalog:{description:`Claude model access`,icon:`🧠`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`sk-ant-...`}},{id:`google`,name:`Google`,family:`google`,envVars:[`GOOGLE_GENERATIVE_AI_API_KEY`,`GEMINI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://aistudio.google.com/apikey`,catalog:{description:`Gemini Pro, Flash, and Nano`,icon:`✨`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`AIza...`}},{id:`openai-codex`,name:`OpenAI Codex OAuth`,family:`openai-codex`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://developers.openai.com/codex/`},{id:`anthropic-oauth`,name:`Anthropic OAuth`,family:`anthropic-oauth`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://docs.anthropic.com/`},{id:`github-copilot`,name:`GitHub Copilot`,family:`github-copilot`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://docs.github.com/en/copilot`},{id:`opencode-go`,name:`OpenCode Go`,family:`openai-compatible`,baseUrl:`https://opencode.ai/zen/go/v1`,envVars:[`OPENCODE_API_KEY`],models:[],usage:`subscription-interactive`,docsUrl:`https://opencode.ai/go?ref=6VZAER87H4`,catalog:{description:`Global hosted API for 75+ LLM providers — stable access from US, EU, and Singapore`,icon:`🌍`,color:`from-success/12 to-success/5 border-success/30 hover:border-success/50`,keyPlaceholder:`oc-...`,referral:{code:`6VZAER87H4`,reward:`Support the project by signing up with this referral link`,url:`https://opencode.ai/go?ref=6VZAER87H4`}}},{id:`xai`,name:`xAI`,family:`openai-compatible`,baseUrl:`https://api.x.ai/v1`,envVars:[`XAI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://docs.x.ai/`,requestPolicy:`xai`},{id:`ai-gateway`,name:`Vercel AI Gateway`,family:`openai-compatible`,baseUrl:`https://ai-gateway.vercel.sh/v1`,discoveryOnlyBaseUrl:!0,envVars:[`AI_GATEWAY_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://vercel.com/docs/ai-gateway`,autoDiscover:!0,catalog:{description:`Every model behind one key — routed by Vercel AI Gateway`,icon:`▲`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`vck_...`}}],hp=[{id:`omniroute`,name:`OmniRoute`,family:`openai-compatible`,baseUrl:`http://localhost:20128/v1`,envVars:[],models:[],usage:`local`,quirks:{stripThinkTags:!0},autoDiscover:!0,local:{noAuth:!0,hint:`WrongStack local gateway · port 20128 · no key · auto-discovers models`}},{id:`ollama`,name:`Ollama`,family:`openai-compatible`,baseUrl:`http://localhost:11434/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://ollama.com`,local:{noAuth:!0,hint:`ollama.com · port 11434 · no key`}},{id:`vllm`,name:`vLLM`,family:`openai-compatible`,baseUrl:`http://localhost:8000/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://docs.vllm.ai`,local:{noAuth:!1,hint:`docs.vllm.ai · port 8000 · optional key`}},{id:`lmstudio`,name:`LM Studio`,family:`openai-compatible`,baseUrl:`http://localhost:1234/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://lmstudio.ai`,local:{noAuth:!1,hint:`lmstudio.ai · port 1234 · optional key`}}],gp=Object.fromEntries([...mp,...Object.values(pp),...hp].map(e=>[e.id,e]));function _p(){return hp.map(e=>{if(!e.baseUrl||!e.local)throw Error(`Local provider definition is incomplete: ${e.id}`);return{id:e.id,label:e.name,defaultBaseUrl:e.baseUrl,noAuth:e.local.noAuth,hint:e.local.hint}})}function vp(){return Object.values(gp).filter(e=>e.catalog!==void 0).map(e=>({id:e.id,name:e.name,family:e.family,description:e.catalog.description,icon:e.catalog.icon,color:e.catalog.color,keyPlaceholder:e.catalog.keyPlaceholder,...e.docsUrl?{docsUrl:e.docsUrl}:{},...e.catalog.referral?{referral:{...e.catalog.referral}}:{}}))}var yp=`openai-compatible`,bp=_p();function xp({models:e,onChange:t}){let{t:n}=R(),[r,i]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(``),g=(0,Y.useRef)(void 0),v=(0,Y.useRef)(null),y=W(e=>e.wsUrl),b=(0,Y.useCallback)(e=>{if(!e.trim()){l([]);return}d(!0);let t=V(y),n=t.on(`provider.models.search_result`,t=>{let n=t.payload;!n||n.query!==e.trim()||(l(n.matches??[]),d(!1))});t.searchProviderModels(e.trim(),8),setTimeout(()=>{n?.(),d(!1)},5e3)},[y]);(0,Y.useEffect)(()=>{if(g.current&&clearTimeout(g.current),!o.trim()){l([]);return}return g.current=setTimeout(()=>b(o),250),()=>{g.current&&clearTimeout(g.current)}},[o,b]);let x=(0,Y.useCallback)((n,r)=>{if(!n||e.some(e=>e.id===n))return;let a={id:n,name:r?.name??r?.modelId??n,...r?.maxOutput?{maxOutput:r.maxOutput}:{},capabilities:{...r?.contextWindow?{maxContext:r.contextWindow}:{},...r?.capabilities.includes(`tools`)?{tools:!0}:{},...r?.capabilities.includes(`vision`)?{vision:!0}:{},...r?.capabilities.includes(`reasoning`)?{reasoning:!0}:{}}};t([...e,a]),s(``),l([]),i(!1)},[e,t]),S=(0,Y.useCallback)(n=>{t(e.filter(e=>e.id!==n))},[e,t]),C=(0,Y.useCallback)(()=>{let e=m.trim();e&&(x(e),h(``),p(!1))},[m,x]);return(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:n(`setup:screen.custom.models`)}),e.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,X.jsxs)(`div`,{className:H(`group inline-flex items-center gap-1 px-2 py-1 text-xs rounded`,`bg-accent/10 text-accent border border-accent/20`),title:e.name&&e.name!==e.id?`${e.name}\n${e.capabilities?.maxContext?`maxContext: ${e.capabilities.maxContext}`:``}${e.maxOutput?`\nmaxOutput: ${e.maxOutput}`:``}`:void 0,children:[(0,X.jsx)(`span`,{className:`truncate max-w-[120px]`,children:e.name&&e.name!==e.id?e.name:e.id}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>S(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive`,children:(0,X.jsx)(Wt,{className:`h-3 w-3`})})]},e.id))}),r?(0,X.jsxs)(`div`,{className:`space-y-2 p-3 rounded border border-border/60 bg-muted/20`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(Ft,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(zi,{placeholder:n(`setup:screen.custom.modelSearchPlaceholder`),value:o,onChange:e=>s(e.target.value),className:`text-sm pl-8`,autoFocus:!0}),u&&(0,X.jsx)(ln,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),c.length>0&&(0,X.jsx)(`div`,{className:`space-y-1 max-h-40 overflow-y-auto`,children:c.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>x(e.modelId,e),className:H(`w-full flex items-start gap-2 p-2 text-left text-xs rounded transition-colors`,`hover:bg-accent/10 border border-transparent hover:border-accent/30`),children:[(0,X.jsx)(a,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`font-medium block truncate`,children:e.name}),(0,X.jsxs)(`span`,{className:`text-muted-foreground block`,children:[e.providerName,` · `,e.modelId,e.contextWindow?` · ${(e.contextWindow/1e3).toFixed(0)}K ctx`:``,e.maxOutput?` · ${e.maxOutput.toLocaleString()} out`:``]})]})]},`${e.providerId}\u0000${e.modelId}`))}),!u&&o.trim()&&c.length===0&&(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center py-2`,children:[n(`setup:screen.custom.noCatalogMatch`),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{p(!0),setTimeout(()=>v.current?.focus(),50)},className:`ml-1 text-accent underline underline-offset-2 hover:text-accent/80`,children:n(`setup:screen.custom.useCustomId`)})]}),f&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(zi,{ref:v,placeholder:n(`setup:screen.custom.customModelIdPlaceholder`),value:m,onChange:e=>h(e.target.value),className:`text-sm flex-1`,onKeyDown:e=>{e.key===`Enter`&&C()}}),(0,X.jsxs)(J,{type:`button`,size:`sm`,onClick:C,disabled:!m.trim(),children:[(0,X.jsx)(a,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.add`)]})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-2 pt-1`,children:(0,X.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{i(!1),s(``),l([]),p(!1),h(``)},className:`text-xs`,children:n(`setup:screen.custom.cancel`)})})]}):(0,X.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(!0),className:`text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.addModel`)]}),e.length>0&&(0,X.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.length,` `,e.length===1?n(`setup:screen.custom.modelSingular`):n(`setup:screen.custom.modelPlural`)]})]})}var Sp=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,X.jsx)(ht,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,X.jsx)(bn,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,X.jsx)(x,{className:`h-5 w-5`})}],Cp=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function wp({ws:e,savedByKind:t}){let{t:n}=R(),[r,i]=(0,Y.useState)({chatgpt:{phase:`idle`},claude:{phase:`idle`},copilot:{phase:`idle`}}),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let t=e.on(`auth.oauth.status`,e=>{if(e.type!==`auth.oauth.status`)return;let t=e.payload;i(e=>({...e,[t.kind]:{...t}})),t.phase===`success`?(q.success(t.message??L.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),c(null),o(``),u(null),f(``)):t.phase===`error`&&q.error(t.message??L.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let h=(0,Y.useCallback)(t=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),g=(0,Y.useCallback)((t,n)=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n)},[e]),v=(0,Y.useCallback)(t=>{let n=d.trim();n&&(i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n),u(null),f(``))},[e,d]),y=(0,Y.useCallback)(t=>{e.cancelOAuth(t),i(e=>({...e,[t]:{phase:`idle`}})),c(null)},[e]),b=(0,Y.useCallback)(t=>{let n=a.trim();n&&(e.submitOAuthCode(t,n),i(e=>({...e,[t]:{...e[t],phase:`exchanging`}})))},[a,e]),x=t??{};return(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-3`,children:(0,X.jsx)(`p`,{className:`text-xs leading-5 text-warning`,children:n(`settings:oauth.termsWarning`)})}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-3`,children:Sp.map(e=>{let t=r[e.kind],i=Cp.includes(t.phase),S=x[e.kind],C=S?.length??0,w=p===e.kind;return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/70 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 lg:flex-col lg:items-stretch`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,X.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subtitle})]})]}),i?(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>y(e.kind),className:`shrink-0 lg:w-full`,children:n(`common:action.cancel`)}):(0,X.jsx)(J,{size:`sm`,onClick:()=>h(e.kind),className:`shrink-0 lg:w-full`,children:n(`settings:oauth.signIn`)})]}),t.phase===`awaiting_browser`&&(0,X.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(ln,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,X.jsx)(`span`,{children:n(`settings:oauth.waitingBrowser`)})]}),t.authorizeUrl&&(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.authorizeUrl,`_blank`,`noopener,noreferrer`),children:[(0,X.jsx)(Ut,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openSignIn`)]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline`,onClick:()=>c(s===e.kind?null:e.kind),children:t.bound===!1?n(`settings:oauth.pasteLoopbackBusy`):n(`settings:oauth.pasteCantReach`)}),s===e.kind&&(0,X.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,X.jsx)(zi,{placeholder:n(`activity:oauth.httpLocalhostCallbackCode`),value:a,onChange:e=>o(e.target.value),className:`font-mono text-xs`,onKeyDown:t=>{t.key===`Enter`&&b(e.kind)}}),(0,X.jsx)(J,{size:`sm`,onClick:()=>b(e.kind),disabled:!a.trim(),children:n(`settings:oauth.submit`)})]})]})]}),t.phase===`awaiting_code`&&(0,X.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`settings:oauth.enterCode`)}),(0,X.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-widest`,children:t.userCode??`…`}),t.verificationUri&&(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,X.jsx)(Ut,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openVerification`)]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(ln,{className:`h-3.5 w-3.5 animate-spin`}),(0,X.jsx)(`span`,{children:n(`settings:oauth.waitingCode`)})]})]}),(t.phase===`exchanging`||t.phase===`fetching_models`)&&(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm`,children:[(0,X.jsx)(ln,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,X.jsx)(`span`,{children:t.phase===`exchanging`?n(`settings:oauth.exchanging`):n(`settings:oauth.fetchingModels`)})]}),t.phase===`success`&&(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-success`,children:[(0,X.jsx)(ft,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{children:t.message??n(`settings:oauth.signedIn`)})]}),t.phase===`error`&&t.message&&(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-destructive`,children:[(0,X.jsx)(ce,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{children:t.message})]}),C>0&&!i&&(0,X.jsxs)(`div`,{className:`mt-3 border-t pt-3`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>m(w?null:e.kind),className:`flex w-full items-center justify-between text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(br,{className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{children:n(`settings:oauth.accountCount`,{count:C})})]}),(0,X.jsx)(`span`,{className:`text-[10px]`,children:w?`▲`:`▼`})]}),w&&S&&(0,X.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[S.map(t=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border/60 bg-muted/20 px-2.5 py-1.5`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t.id}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[t.hasActiveKey?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-success`,children:[(0,X.jsx)(ft,{className:`h-3 w-3`}),n(`settings:oauth.active`)]}):(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n(`settings:oauth.inactive`)}),(0,X.jsxs)(J,{size:`sm`,variant:`ghost`,onClick:()=>g(e.kind,t.id),className:`h-6 px-1.5 text-[11px]`,title:n(`settings:oauth.retryLogin`),children:[(0,X.jsx)(cr,{className:`h-3 w-3 mr-0.5`}),n(`settings:oauth.retry`)]})]})]},t.id)),(0,X.jsx)(`div`,{className:`pt-1`,children:l===e.kind?(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(zi,{autoFocus:!0,placeholder:n(`settings:oauth.aliasPlaceholder`,{default:e.kind===`chatgpt`?`openai-codex-1`:`${e.kind}-2`}),value:d,onChange:e=>f(e.target.value),className:`text-xs font-mono`,onKeyDown:t=>{t.key===`Enter`&&v(e.kind)}}),(0,X.jsx)(J,{size:`sm`,onClick:()=>v(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]})]}),C===0&&!i&&(0,X.jsx)(`div`,{className:`mt-3 border-t pt-3`,children:l===e.kind?(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(zi,{autoFocus:!0,placeholder:n(`settings:oauth.aliasPlaceholder`,{default:e.kind===`chatgpt`?`openai-codex-1`:`${e.kind}-2`}),value:d,onChange:e=>f(e.target.value),className:`text-xs font-mono`,onKeyDown:t=>{t.key===`Enter`&&v(e.kind)}}),(0,X.jsx)(J,{size:`sm`,onClick:()=>v(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]},e.kind)})})]})}function Tp({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,Y.useRef)(null),{t:o}=R();return(0,Y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Enter`?(e.preventDefault(),r()):e.key===`Escape`&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,t),a.current?.focus(),()=>window.removeEventListener(`keydown`,t)},[e,r,i]),(0,X.jsx)(Ri,{open:e,onOpenChange:e=>{e||i()},children:(0,X.jsxs)(Fi,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,X.jsxs)(Ni,{children:[(0,X.jsxs)(Ii,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Le,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,X.jsx)(Li,{children:o(`settings:allowlist.body`,{count:n,provider:t})})]}),(0,X.jsx)(`div`,{className:`rounded-md bg-muted/50 border border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:o(`settings:allowlist.undoHint`)}),(0,X.jsxs)(Pi,{className:`gap-2 sm:gap-2 flex-wrap`,children:[(0,X.jsxs)(J,{variant:`outline`,size:`sm`,onClick:i,title:o(`settings:allowlist.keepTitle`),"data-action":`cancel`,children:[o(`common:action.cancel`),` `,(0,X.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`Esc`})]}),(0,X.jsxs)(J,{variant:`destructive`,size:`sm`,onClick:r,title:o(`settings:allowlist.clearTitle`),"data-action":`confirm`,children:[o(`settings:allowlist.clear`),` `,(0,X.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`↵`})]})]})]})})}function Ep(){return{inFlight:!1,last:null,picked:null}}function Dp(e){return{providerId:e.providerId,ok:e.ok,status:e.status,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.elapsedMs===void 0?{}:{elapsedMs:e.elapsedMs},...e.modelCount===void 0?{}:{modelCount:e.modelCount},...e.modelIds===void 0?{}:{modelIds:e.modelIds},...e.detail===void 0?{}:{detail:e.detail}}}function Op(e){if(e.inFlight)return{text:`Checking model endpoint...`,tone:`muted`};let t=e.last;if(!t)return{text:`Saved model list shown`,tone:`muted`};let n=t.elapsedMs===void 0?``:` (${t.elapsedMs}ms)`;switch(t.status){case`ok`:{let e=t.modelCount??t.modelIds?.length??0;return{text:`Server returned ${e} model${e===1?``:`s`}${n}`,tone:`success`}}case`unreachable`:return{text:`server unreachable${t.detail?` — ${t.detail}`:``}`,tone:`error`};case`timeout`:return{text:`timed out${t.detail?` — ${t.detail}`:``}`,tone:`error`};case`http_error`:return{text:`got${t.httpStatus===void 0?``:` HTTP ${t.httpStatus}`}${t.detail?` — ${t.detail}`:``}`,tone:`warning`};case`invalid_response`:return{text:t.detail?`unexpected response — ${t.detail}`:`unexpected response shape`,tone:`warning`};case`no_provider`:return{text:`Provider is no longer saved`,tone:`error`};case`no_base_url`:return{text:`No model endpoint configured`,tone:`warning`}}}function kp(e){return(e?.length??0)>0}function Ap(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function jp(e){return e.length>0}function Mp({ws:e,onSelect:t,onClose:n}){let{t:r}=R(),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(null),d=(0,Y.useRef)(``);(0,Y.useEffect)(()=>e.on(`provider.models.search_result`,e=>{if(e.type!==`provider.models.search_result`)return;let t=e.payload;t.query!==void 0&&t.query!==d.current||(s(t.matches??[]),l(!1))}),[e]);let f=(0,Y.useCallback)(t=>{if(!t.trim()){s([]),d.current=``;return}d.current=t,l(!0),e.searchProviderModels(t,8)},[e]);(0,Y.useEffect)(()=>(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>f(i),300),()=>{u.current&&clearTimeout(u.current)}),[i,f]);let p=(0,Y.useCallback)(e=>{let n={name:e.name,...e.description?{description:e.description}:{},...e.releaseDate?{release_date:e.releaseDate}:{},...e.contextWindow||e.maxOutput?{limit:{...e.contextWindow?{context:e.contextWindow}:{},...e.maxOutput?{output:e.maxOutput}:{}}}:{},...e.inputCost||e.outputCost?{cost:{...e.inputCost?{input:e.inputCost}:{},...e.outputCost?{output:e.outputCost}:{}}}:{},...e.capabilities.length>0?{tool_call:e.capabilities.includes(`tools`),reasoning:e.capabilities.includes(`reasoning`),...e.capabilities.includes(`vision`)?{modalities:{input:[`text`,`image`]}}:{}}:{}};t(e.modelId,n)},[t]);return(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,X.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:n,"aria-label":r(`common:action.close`)}),(0,X.jsxs)(`div`,{className:`relative max-h-[80vh] w-full max-w-xl overflow-y-auto rounded-lg border border-border bg-background p-4 shadow-lg`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings:providerModels.catalogSearchTitle`)}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(Wt,{className:`h-4 w-4`})})]}),(0,X.jsxs)(`div`,{className:`relative mb-3`,children:[(0,X.jsx)(Ft,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/60`}),(0,X.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:r(`settings:providerModels.catalogSearchPlaceholder`),className:`h-10 w-full rounded-md border border-border bg-background pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),c?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,X.jsx)(ln,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):o.length>0?(0,X.jsx)(`div`,{className:`space-y-1.5`,children:o.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>p(e),className:`block w-full rounded-md border border-border/60 p-2.5 text-left transition-colors hover:border-primary/40 hover:bg-primary/5`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`font-mono text-sm font-medium text-foreground`,children:e.modelId}),e.name!==e.modelId&&(0,X.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.name})]}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.providerName})]}),e.description&&(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:[e.contextWindow?(0,X.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e.contextWindow>=1e6?`${(e.contextWindow/1e6).toFixed(1)}M ctx`:`${Math.round(e.contextWindow/1e3)}K ctx`}):null,e.capabilities.map(e=>(0,X.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary`,children:e},e))]})]},`${e.providerId}:${e.modelId}`))}):i.trim()?(0,X.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.noResults`)}):(0,X.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.typeToSearch`)})]})]})}var Np=new Set([`__proto__`,`constructor`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]),Pp=[`text`,`image`,`audio`,`video`,`pdf`],Fp=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Ip=Ne().int().nonnegative(),Lp=Ne().finite(),Rp=y({context:Ip.optional(),output:Ip.optional(),input:Ip.optional()}),zp=y({input:Lp.optional(),output:Lp.optional(),cache_read:Lp.optional(),cache_write:Lp.optional(),cache_write_5m:Lp.optional(),cache_write_1h:Lp.optional(),context_over_200k:Lp.optional(),reasoning:Lp.optional(),input_audio:Lp.optional(),output_audio:Lp.optional()}),Bp=y({input:dr(c().min(1)).optional(),output:dr(c().min(1)).optional()}),Vp=dn([y({type:T(`toggle`)}),y({type:T(`effort`),values:dr(h(Fp)).optional()}),y({type:T(`budget_tokens`),min:Ne().optional(),max:Ne().optional()})]),Hp=e=>({message:`${e} id is a forbidden prototype-pollution key`}),Up=y({id:c().min(1).refine(e=>!Np.has(e),Hp(`Model`)),name:c().min(1),description:c().optional(),family:c().optional(),attachment:nt().optional(),reasoning:nt().optional(),reasoning_options:dn([Vp,dr(Vp)]).optional(),interleaved:dn([nt(),y({field:c().optional()})]).optional(),tool_call:nt().optional(),structured_output:nt().optional(),temperature:nt().optional(),knowledge:c().optional(),release_date:c().optional(),last_updated:c().optional(),open_weights:nt().optional(),modalities:Bp.optional(),cost:zp.optional(),limit:Rp.optional(),status:c().optional(),experimental:nt().optional()}),Wp=y({id:c().min(1).refine(e=>!Np.has(e),Hp(`Provider`)),name:c().min(1),env:dr(c()).optional(),npm:c().optional(),api:c().optional(),doc:c().optional(),models:gn(c(),Up)});gn(c(),Wp);function Gp(e,t){let n=t.limit,r=t.cost,i=t.modalities;return{id:e,name:t.name??``,description:t.description??``,family:t.family??``,limitContext:n?.context==null?``:String(n.context),limitOutput:n?.output==null?``:String(n.output),limitInput:n?.input==null?``:String(n.input),costInput:r?.input==null?``:String(r.input),costOutput:r?.output==null?``:String(r.output),inputModalities:Array.isArray(i?.input)?i.input:[],outputModalities:Array.isArray(i?.output)?i.output:[],toolCall:t.tool_call===!0,reasoning:t.reasoning===!0,temperature:t.temperature===!0,attachment:t.attachment===!0,structuredOutput:t.structured_output===!0,openWeights:t.open_weights===!0,releaseDate:t.release_date??``,lastUpdated:t.last_updated??``,knowledge:t.knowledge??``}}function Kp(e,t){let n={...t};e.name&&(n.name=e.name),e.description&&(n.description=e.description),e.family&&(n.family=e.family),e.knowledge&&(n.knowledge=e.knowledge);let r={};if(e.limitContext){let t=Number(e.limitContext);Number.isFinite(t)&&t>=0&&(r.context=t)}if(e.limitOutput){let t=Number(e.limitOutput);Number.isFinite(t)&&t>=0&&(r.output=t)}if(e.limitInput){let t=Number(e.limitInput);Number.isFinite(t)&&t>=0&&(r.input=t)}Object.keys(r).length>0&&(n.limit={...t.limit??{},...r});let i={};if(e.costInput){let t=Number(e.costInput);Number.isFinite(t)&&t>=0&&(i.input=t)}if(e.costOutput){let t=Number(e.costOutput);Number.isFinite(t)&&t>=0&&(i.output=t)}Object.keys(i).length>0&&(n.cost={...t.cost??{},...i});let a={};e.inputModalities.length>0&&(a.input=e.inputModalities),e.outputModalities.length>0&&(a.output=e.outputModalities),Object.keys(a).length>0&&(n.modalities={...t.modalities??{},...a});for(let[r,i]of[[`toolCall`,`tool_call`],[`reasoning`,`reasoning`],[`temperature`,`temperature`],[`attachment`,`attachment`],[`structuredOutput`,`structured_output`],[`openWeights`,`open_weights`]]){let a=t[i]===!0;e[r]!==a&&(n[i]=e[r])}return e.releaseDate&&(n.release_date=e.releaseDate),e.lastUpdated&&(n.last_updated=e.lastUpdated),n}var qp=[{key:`toolCall`,labelKey:`settings:modelSchema.capToolCall`},{key:`reasoning`,labelKey:`settings:modelSchema.capReasoning`},{key:`temperature`,labelKey:`settings:modelSchema.capTemperature`},{key:`attachment`,labelKey:`settings:modelSchema.capAttachment`},{key:`structuredOutput`,labelKey:`settings:modelSchema.capStructuredOutput`},{key:`openWeights`,labelKey:`settings:modelSchema.capOpenWeights`}];function Jp({providerId:e,modelId:t,initialModelsDev:n,onSave:r,onCancel:i}){let{t:o}=R(),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(()=>Gp(t,n)),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)(JSON.stringify({...n,...t?{id:t}:{}},null,2)),[h,g]=(0,Y.useState)(null),_=(0,Y.useCallback)((e,t)=>{u(n=>({...n,[e]:t}))},[]),v=(0,Y.useCallback)((e,t)=>{u(n=>{let r=n[e];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),y=(0,Y.useCallback)(()=>{let e=Kp(l,n),i=Up.safeParse({...e,id:l.id||t});if(!i.success){f(i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`));return}f([]),r(l.id||t,e)},[l,n,t,r]),b=(0,Y.useCallback)(()=>{try{let e=JSON.parse(p),n=Up.safeParse({...e,id:t||e.id});if(!n.success){g(n.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `));return}let{id:i,...a}=n.data;g(null),r(t||n.data.id,a)}catch(e){g(e instanceof Error?e.message:String(e))}},[p,t,r]),x=`h-8 w-full rounded-md border border-border bg-background px-2.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`,S=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-muted-foreground`;return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex gap-1 border-b border-border/50`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:H(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,s?`border-transparent text-muted-foreground hover:text-foreground`:`border-primary text-primary`),children:o(`settings:providerModels.tabForm`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:H(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,s?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`),children:o(`settings:providerModels.tabRawJson`)})]}),s?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:16,className:`w-full rounded-md border border-border bg-muted/20 p-2 font-mono text-xs`,spellCheck:!1}),h&&(0,X.jsx)(`p`,{className:`text-xs text-destructive`,children:h})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionIdentity`)}),!t&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-id`,children:`ID`}),(0,X.jsx)(`input`,{id:`mse-id`,className:x,value:l.id,onChange:e=>_(`id`,e.target.value),placeholder:o(`activity:modelSchema.modelId`)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-name`,children:o(`settings:providerModels.fieldName`)}),(0,X.jsx)(`input`,{id:`mse-name`,className:x,value:l.name,onChange:e=>_(`name`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-desc`,children:o(`settings:providerModels.fieldDescription`)}),(0,X.jsx)(`input`,{id:`mse-desc`,className:x,value:l.description,onChange:e=>_(`description`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-family`,children:o(`settings:providerModels.fieldFamily`)}),(0,X.jsx)(`input`,{id:`mse-family`,className:x,value:l.family,onChange:e=>_(`family`,e.target.value)})]})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionLimits`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-ctx`,children:o(`settings:providerModels.fieldContext`)}),(0,X.jsx)(`input`,{id:`mse-ctx`,type:`number`,className:x,value:l.limitContext,onChange:e=>_(`limitContext`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-out`,children:o(`settings:providerModels.fieldOutput`)}),(0,X.jsx)(`input`,{id:`mse-out`,type:`number`,className:x,value:l.limitOutput,onChange:e=>_(`limitOutput`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-inlim`,children:o(`settings:providerModels.fieldInputLimit`)}),(0,X.jsx)(`input`,{id:`mse-inlim`,type:`number`,className:x,value:l.limitInput,onChange:e=>_(`limitInput`,e.target.value)})]})]})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionPricing`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-costin`,children:o(`settings:providerModels.fieldCostInput`)}),(0,X.jsx)(`input`,{id:`mse-costin`,type:`number`,step:`0.01`,className:x,value:l.costInput,onChange:e=>_(`costInput`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-costout`,children:o(`settings:providerModels.fieldCostOutput`)}),(0,X.jsx)(`input`,{id:`mse-costout`,type:`number`,step:`0.01`,className:x,value:l.costOutput,onChange:e=>_(`costOutput`,e.target.value)})]})]})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionModalities`)}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:S,children:o(`settings:providerModels.fieldInputModalities`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Pp.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>v(`inputModalities`,e),className:H(`rounded-md border px-2 py-1 text-xs transition-colors`,l.inputModalities.includes(e)?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`in-mod-${e}`))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:S,children:o(`settings:providerModels.fieldOutputModalities`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Pp.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>v(`outputModalities`,e),className:H(`rounded-md border px-2 py-1 text-xs transition-colors`,l.outputModalities.includes(e)?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`out-mod-${e}`))})]})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionCapabilities`)}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:qp.map(({key:e,labelKey:t})=>(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 rounded border-border`,checked:l[e],onChange:t=>_(e,t.target.checked)}),o(t)]},String(e)))})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionDates`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-release`,children:o(`settings:providerModels.fieldReleaseDate`)}),(0,X.jsx)(`input`,{id:`mse-release`,type:`date`,className:x,value:l.releaseDate,onChange:e=>_(`releaseDate`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-updated`,children:o(`settings:providerModels.fieldLastUpdated`)}),(0,X.jsx)(`input`,{id:`mse-updated`,type:`date`,className:x,value:l.lastUpdated,onChange:e=>_(`lastUpdated`,e.target.value)})]})]})]}),d.length>0&&(0,X.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-2`,children:(0,X.jsx)(`ul`,{className:`space-y-0.5 text-xs text-destructive`,children:d.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border/50 pt-3`,children:[(0,X.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,className:`h-8 gap-1.5 text-xs`,children:[(0,X.jsx)(Wt,{className:`h-3.5 w-3.5`}),o(`common:action.cancel`)]}),(0,X.jsxs)(J,{type:`button`,size:`sm`,onClick:s?b:y,className:`h-8 gap-1.5 text-xs`,children:[(0,X.jsx)(a,{className:`h-3.5 w-3.5`}),o(`common:action.save`)]})]})]})}function Yp(e,t){return e.map(e=>{let n=t?.[e],r=n?.modelsDev,i=!!(n&&(n.name||n.maxOutput||n.capabilities||r));return{modelId:e,name:r?.name??n?.name??e,modelsDev:r,maxOutput:n?.maxOutput??r?.limit?.output,capabilities:n?.capabilities,source:i?`overridden`:`catalog`}})}function Xp(e){let t=e?.limit?.context;if(typeof t==`number`&&t>0)return t>=1e6?`${(t/1e6).toFixed(1)}M`:`${Math.round(t/1e3)}K`}function Zp(e){let t=e?.cost,n=e=>typeof e==`number`&&e>=0?`$${e}`:void 0;return{input:n(t?.input),output:n(t?.output)}}function Qp(e){let t=e?.modalities;return{input:Array.isArray(t?.input)?t.input:[],output:Array.isArray(t?.output)?t.output:[]}}var $p={text:yt,image:et,audio:_e,video:ur,pdf:yt};function em({providerId:e,models:t,customModels:n,ws:r,pickedModelId:i,onPickModel:o}){let{t:s}=R(),[c,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(``),v=(0,Y.useMemo)(()=>Yp(t,n),[t,n]),y=(0,Y.useMemo)(()=>{let e=h.trim().toLowerCase();return e?v.filter(t=>t.modelId.toLowerCase().includes(e)||(t.name?.toLowerCase().includes(e)??!1)):v},[v,h]),b=(0,Y.useCallback)(t=>{r.removeCustomModel(e,t),q.success(s(`settings:providerModels.modelRemoved`,{model:t}))},[r,e,s]),x=(0,Y.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),u(null),q.success(s(`settings:providerModels.modelSaved`,{model:t}))},[r,e,s]),C=(0,Y.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),f(!1),q.success(s(`settings:providerModels.modelAdded`,{model:t}))},[r,e,s]);return(0,X.jsxs)(`div`,{className:`space-y-3`,"data-model-list-editor":e,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>f(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),s(`settings:providerModels.addFromCatalog`)]}),(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:()=>m(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),s(`settings:providerModels.addCustom`)]})]}),v.length>0&&(0,X.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/70`,children:[v.length>8&&(0,X.jsxs)(`div`,{className:`relative border-b border-border/40 bg-muted/10`,children:[(0,X.jsx)(Ft,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/60`}),(0,X.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:s(`settings:providerModels.filterPlaceholder`),"aria-label":s(`settings:providerModels.filterPlaceholder`),className:`h-8 w-full bg-transparent pl-9 pr-3 text-xs text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,X.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:(0,X.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-border/70 bg-muted/30 text-left text-[11px] uppercase tracking-wide text-muted-foreground`,children:[(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colModel`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colContext`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colOutput`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colCost`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colModalities`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colCaps`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colSource`)}),(0,X.jsx)(`th`,{className:`px-3 py-2`,"aria-label":s(`settings:providerModels.colActions`)})]})}),(0,X.jsx)(`tbody`,{children:y.map(t=>{let n=Xp(t.modelsDev),r=t.maxOutput??t.modelsDev?.limit?.output,d=typeof r==`number`?r.toLocaleString():void 0,f=Zp(t.modelsDev),p=Qp(t.modelsDev),m=t.capabilities,h=c===t.modelId;return(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`tr`,{className:`border-b border-border/40 transition-colors hover:bg-muted/20`,children:[(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`font-mono text-xs font-medium text-foreground`,children:t.modelId}),t.name&&t.name!==t.modelId&&(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t.name})]})}),(0,X.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(l,{className:`h-3 w-3`}),n]}):(0,X.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,X.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:d?(0,X.jsx)(`span`,{children:d}):(0,X.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,X.jsx)(`td`,{className:`px-3 py-2 text-xs`,children:f.input||f.output?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,X.jsx)(At,{className:`h-3 w-3`}),f.input&&f.output?`${f.input}/${f.output}`:f.input??f.output]}):(0,X.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[p.input.map(e=>{let t=$p[e]??yt;return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-primary/10 px-1 py-0.5 text-[10px] text-primary`,title:`input: ${e}`,children:[(0,X.jsx)(t,{className:`h-2.5 w-2.5`}),e]},`in-${e}`)}),p.output.map(e=>(0,X.jsx)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-secondary/20 px-1 py-0.5 text-[10px] text-secondary-foreground`,title:`output: ${e}`,children:e},`out-${e}`))]})}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[m?.tools&&(0,X.jsx)(Xt,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":s(`activity:modelListEditor.tools`)}),m?.reasoning&&(0,X.jsx)(Nt,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":s(`activity:modelListEditor.reasoning`)}),m?.vision&&(0,X.jsx)(xn,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":s(`activity:modelListEditor.vision`)})]})}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsx)(`span`,{className:H(`inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium`,t.source===`custom`&&`bg-warning/10 text-warning`,t.source===`catalog`&&`bg-info/10 text-info`,t.source===`overridden`&&`bg-primary/10 text-primary`),children:t.source})}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[o&&(t.modelId===i?(0,X.jsx)(`span`,{className:`inline-flex items-center rounded p-1 text-primary`,title:s(`settings:providerModels.usingModel`,{model:t.modelId}),role:`img`,"aria-label":s(`settings:providerModels.usingModel`,{model:t.modelId}),children:(0,X.jsx)(a,{className:`h-3.5 w-3.5`})}):(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(e,t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":s(`settings:providerModels.useModel`,{model:t.modelId}),title:s(`settings:providerModels.useModel`,{model:t.modelId}),children:(0,X.jsx)(a,{className:`h-3.5 w-3.5`})})),(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(h?null:t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":s(`settings:providerModels.editModel`,{model:t.modelId}),children:(0,X.jsx)(S,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>b(t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,"aria-label":s(`settings:providerModels.removeModel`,{model:t.modelId}),children:(0,X.jsx)(hn,{className:`h-3.5 w-3.5`})})]})})]}),h&&(0,X.jsx)(`tr`,{className:`border-b border-border/40 bg-muted/10`,children:(0,X.jsx)(`td`,{colSpan:8,className:`p-3`,children:(0,X.jsx)(Jp,{providerId:e,modelId:t.modelId,initialModelsDev:t.modelsDev??{},onSave:x,onCancel:()=>u(null)})})},`${t.modelId}-edit`)]},t.modelId)})})]})})]}),v.length===0&&(0,X.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/50 p-8 text-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`settings:providerModels.emptyState`)})}),d&&(0,X.jsx)(Mp,{ws:r,onSelect:C,onClose:()=>f(!1)}),p&&(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,X.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:()=>m(!1),"aria-label":s(`common:action.close`)}),(0,X.jsxs)(`div`,{className:`relative max-h-[80vh] w-full max-w-2xl overflow-y-auto rounded-lg border border-border bg-background p-4 shadow-lg`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:s(`settings:providerModels.addCustomTitle`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(!1),className:`text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(Wt,{className:`h-4 w-4`})})]}),(0,X.jsx)(Jp,{providerId:e,modelId:``,initialModelsDev:{},onSave:x,onCancel:()=>m(!1)})]})]})]})}function tm(e){return e.previousModels.length===0?{kind:`skip`}:e.onUndoClear?{kind:`callback`,providerId:e.providerId,previousModels:e.previousModels}:{kind:`ws-default`,providerId:e.providerId,previousModels:e.previousModels}}var nm=3e3;function rm({providerId:e,savedPickedModelId:t,savedModels:n,savedCustomModels:r,ws:i,onPickModel:a,onClearModels:o,onUndoClear:s}){let[c,l]=(0,Y.useState)(()=>Ep()),{t:u}=R(),[d,f]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>i.on(`provider.probe`,t=>{t.type===`provider.probe`&&t.payload.providerId===e&&l(e=>({...e,inFlight:!1,last:Dp(t.payload)}))}),[i,e]);let p=(0,Y.useCallback)(()=>{l(e=>({...e,inFlight:!0})),i.probeProvider(e,nm)},[i,e]),m=(0,Y.useCallback)((e,t)=>{l(e=>({...e,picked:t})),a?.(e,t)},[a]),h=(0,Y.useCallback)(()=>{f(!0)},[]),g=(0,Y.useCallback)(()=>{f(!1)},[]),_=(0,Y.useCallback)(()=>{f(!1);let t=n?[...n]:[];l(e=>({...e,picked:null,last:null})),o?o(e):i.clearProviderModels(e),jp(t)&&q.undoable(Ap(e,t.length),()=>{let n=tm({providerId:e,previousModels:t,onUndoClear:s});switch(n.kind){case`skip`:return;case`callback`:s?.(n.providerId,n.previousModels);return;case`ws-default`:i.undoProviderClear(n.providerId,n.previousModels);return}})},[o,s,i,e,n]),v=(0,Y.useMemo)(()=>c.picked??t??n?.[0]??``,[c.picked,t,n]),y=(0,Y.useMemo)(()=>Op(c),[c]),b=(0,Y.useMemo)(()=>kp(n),[n]);return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,"data-provider-models-panel":e,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,X.jsx)(ir,{className:`h-3.5 w-3.5`}),u(`activity:providerModels.allowlistTitle`)]}),n&&n.length>0&&(0,X.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground`,children:u(`activity:providerModels.modelCount`,{count:n.length})})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u(`activity:providerModels.using`)}),v?(0,X.jsx)(`span`,{className:`max-w-full truncate rounded-md bg-primary/10 px-2 py-0.5 font-mono text-xs text-primary`,children:v}):(0,X.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:u(`activity:providerModels.noModelPicked`)})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:justify-end`,children:[(0,X.jsxs)(J,{variant:`outline`,size:`sm`,onClick:p,disabled:c.inFlight,"aria-label":u(`activity:providerModels.refreshAria`,{provider:e}),className:`h-8 px-2 text-xs`,children:[c.inFlight?(0,X.jsx)(ln,{className:`h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(cr,{className:`h-3.5 w-3.5`}),c.inFlight?u(`activity:providerModels.probing`):u(`activity:providerModels.refresh`)]}),b&&(0,X.jsx)(J,{variant:`ghost`,size:`sm`,onClick:h,"aria-label":u(`activity:providerModels.clearAllowlistAria`,{provider:e}),"data-action":`clear-models`,className:`h-8 px-2 text-xs`,children:u(`activity:providerModels.clearAllowlist`)})]})]}),(0,X.jsx)(im,{formatted:y}),(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(em,{providerId:e,models:n??[],customModels:r,ws:i,pickedModelId:v??void 0,onPickModel:m})}),(0,X.jsx)(Tp,{open:d,providerId:e,modelCount:n?.length??0,onConfirm:_,onCancel:g})]})}function im({formatted:e}){let t=e.tone===`success`?`text-success`:e.tone===`warning`?`text-warning`:e.tone===`error`?`text-destructive`:`text-muted-foreground`,n=e.tone===`success`?`bg-success`:e.tone===`warning`?`bg-warning`:e.tone===`error`?`bg-destructive`:`bg-muted-foreground/60`;return(0,X.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs ${t}`,"data-probe-tone":e.tone,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${n}`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}var am=[`anthropic`,`openai`,`google`,`openai-compatible`];function om({activeProvider:e,catalogProviders:t,isLoadingCatalog:n,savedProviders:r,isLoadingSaved:i,providerTab:a,setProviderTab:o,onSelectProvider:s,onAddKey:c,onDeleteKey:l,onSetActiveKey:d,onAddProvider:f,onRemoveProvider:p,onPickProviderModel:m,ws:h,catalogQuery:g,setCatalogQuery:v}){let{t:y}=R(),[b,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(``),[w,T]=(0,Y.useState)(``),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(``),[M,N]=(0,Y.useState)(`openai-compatible`),[ee,te]=(0,Y.useState)(``),[ne,re]=(0,Y.useState)(``),[P,ie]=(0,Y.useState)([]),ae=fp(),oe=fp(),se=(0,Y.useCallback)(e=>{!S.trim()||!w.trim()||(c(e,S.trim(),w.trim()),C(``),T(``),x(null))},[c,S,w]),F=(0,Y.useCallback)(()=>{A.trim()&&(f(A.trim(),M,ee||void 0,ne||void 0,P.length>0?P.map(e=>e.id):void 0,P.length>0?Object.fromEntries(P.filter(e=>e.name||e.maxOutput||e.capabilities&&Object.keys(e.capabilities).length>0).map(e=>[e.id,{...e.name&&e.name!==e.id?{name:e.name}:{},...e.maxOutput?{maxOutput:e.maxOutput}:{},...e.capabilities&&Object.keys(e.capabilities).length>0?{capabilities:e.capabilities}:{}}])):void 0),j(``),N(`openai-compatible`),te(``),re(``),ie([]),k(!1))},[f,A,M,ee,ne,P]),I=(0,Y.useCallback)(e=>{j(e.id),N(yp),te(e.defaultBaseUrl),e.noAuth&&re(``),ie([])},[]),[le,ue]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(``),[pe,me]=(0,Y.useState)(!1),[he,ge]=(0,Y.useState)({}),_e=(0,Y.useMemo)(()=>new Set(r.map(e=>e.id)),[r]),ve=(0,Y.useMemo)(()=>({keys:r.reduce((e,t)=>e+t.apiKeys.length,0),activeKeys:r.reduce((e,t)=>e+t.apiKeys.filter(e=>e.isActive).length,0),models:r.reduce((e,t)=>e+(t.models?.length??0),0)}),[r]);(0,Y.useEffect)(()=>{let e=h.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;t.status===`no_base_url`||t.status===`no_provider`||ge(e=>({...e,[t.providerId]:{ok:t.ok,status:t.status,detail:t.detail}}))});return()=>e?.()},[h]);let ye=(0,Y.useCallback)(e=>{let t=de.trim();t&&(_e.has(e.id)?c(e.id,`default`,t):f(e.id,e.family,e.apiBase??void 0,t),fe(``),ue(null),me(!1),q.success(y(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>h.probeProvider(e.id,6e3),700))},[de,_e,c,f,h]),L=g.trim()?t.filter(e=>{let t=g.trim().toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.family.toLowerCase().includes(t)}):t,be=L.reduce((e,t)=>(e[t.family]||(e[t.family]=[]),e[t.family]?.push(t),e),{});return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,X.jsx)(lr,{className:`h-4 w-4 text-muted-foreground`}),y(`settings:provider.subscriptionHeading`)]}),(0,X.jsx)(wp,{ws:h,savedByKind:{chatgpt:r.filter(e=>e.id===`openai-codex`||e.id.startsWith(`openai-codex-`)).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)})),claude:r.filter(e=>e.id===`anthropic-oauth`||e.id.startsWith(`anthropic-oauth-`)).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)})),copilot:r.filter(e=>e.id===`github-copilot`).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)}))}})]}),(0,X.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold mb-1 flex items-center gap-2`,children:[(0,X.jsx)(u,{className:`h-4 w-4 text-muted-foreground`}),y(`settings:provider.apiKeysHeading`)]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:y(`settings:provider.apiKeysBody`)})]}),(0,X.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,X.jsxs)(J,{variant:a===`catalog`?`default`:`outline`,size:`sm`,onClick:()=>o(`catalog`),children:[(0,X.jsx)(u,{className:`h-4 w-4 mr-1`}),y(`settings:provider.tabCatalog`)]}),(0,X.jsxs)(J,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>o(`saved`),children:[(0,X.jsx)(lr,{className:`h-4 w-4 mr-1`}),y(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(zi,{placeholder:y(`settings:provider.searchPlaceholder`,{count:t.length}),value:g,onChange:e=>v(e.target.value),className:`text-sm`}),n&&t.length===0?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,X.jsx)(ln,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,X.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:y(`settings:provider.loadingCatalog`)})]}):L.length===0&&g?(0,X.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:y(`settings:provider.noMatch`,{query:g})}):am.map(t=>{let n=be[t];return n?.length?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider`,children:t}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:n.map(t=>{let n=he[t.id],r=e===t.id;return(0,X.jsxs)(`div`,{className:H(`rounded-lg border transition-all`,r?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border`),children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>s(t.id),className:H(`flex w-full flex-col items-start p-3 text-left rounded-lg`,!r&&`hover:bg-muted`),children:[(0,X.jsxs)(`div`,{className:`flex w-full justify-between items-start`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:t.name}),(0,X.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.hasApiKey&&(0,X.jsxs)(`span`,{className:`text-xs bg-success/10 text-success px-2 py-0.5 rounded`,children:[(0,X.jsx)(lr,{className:`h-3 w-3 inline mr-1`}),y(`settings:provider.configured`)]}),n&&(0,X.jsxs)(`span`,{className:H(`text-xs px-2 py-0.5 rounded inline-flex items-center gap-1`,n.ok?`bg-success/10 text-success`:`bg-destructive/10 text-destructive`),title:n.detail??n.status,children:[n.ok?(0,X.jsx)(ft,{className:`h-3 w-3`}):(0,X.jsx)(ce,{className:`h-3 w-3`}),n.ok?y(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:y(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,X.jsx)(ft,{className:`h-4 w-4 text-primary`})]})]}),(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[y(`settings:provider.modelCount`,{count:t.modelCount}),t.apiBase&&` · ${t.apiBase}`]})]}),r&&!t.hasApiKey&&(0,X.jsx)(`div`,{className:`px-3 pb-3 -mt-1 space-y-2`,children:le===t.id?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(zi,{autoFocus:!0,type:pe?`text`:`password`,placeholder:y(`settings:provider.keyPlaceholder`,{name:t.name}),value:de,onChange:e=>fe(e.target.value),className:`text-sm`,onKeyDown:e=>{e.key===`Enter`&&ye(t)}}),(0,X.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>me(e=>!e),children:pe?(0,X.jsx)(rr,{className:`h-4 w-4`}):(0,X.jsx)(xn,{className:`h-4 w-4`})}),(0,X.jsx)(J,{size:`sm`,onClick:()=>ye(t),disabled:!de.trim(),children:y(`common:action.save`)})]}),t.envVars[0]&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:y(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>{ue(t.id),fe(``)},children:[(0,X.jsx)(lr,{className:`h-3.5 w-3.5 mr-1`}),y(`settings:provider.addApiKey`)]})})]},t.id)})})]},t):null})]}),a===`saved`&&(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:y(`settings:provider.manageKeys`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,X.jsx)(Gn,{className:`h-3.5 w-3.5`}),y(`settings:provider.savedProviderCount`,{count:r.length})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,X.jsx)(lr,{className:`h-3.5 w-3.5`}),y(`settings:provider.keyCount`,{count:ve.keys})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,X.jsx)(Ot,{className:`h-3.5 w-3.5`}),y(`settings:provider.activeKeyCount`,{count:ve.activeKeys})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,X.jsx)(Rt,{className:`h-3.5 w-3.5`}),y(`settings:provider.modelCount`,{count:ve.models})]})]})]}),(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>k(!O),children:[(0,X.jsx)(_,{className:`h-4 w-4 mr-1`}),y(`settings:provider.addProvider`)]})]}),O&&(0,X.jsxs)(`div`,{className:`p-4 border rounded-lg space-y-3 bg-muted/50`,children:[(0,X.jsx)(`h4`,{className:`font-medium`,children:y(`settings:provider.addCustomHeading`)}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:y(`settings:provider.localServers`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:bp.map(e=>(0,X.jsx)(J,{type:`button`,size:`sm`,variant:A===e.id?`default`:`outline`,onClick:()=>I(e),title:e.hint,children:e.label},e.id))})]}),(0,X.jsx)(zi,{placeholder:y(`settings:provider.providerIdPlaceholder`),value:A,onChange:e=>j(e.target.value),ref:ae.setFieldRef(0),onKeyDown:e=>ae.handleKeyDown(e,0)}),(0,X.jsxs)(`select`,{className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:M,onChange:e=>N(e.target.value),ref:ae.setFieldRef(1),onKeyDown:e=>ae.handleKeyDown(e,1),children:[(0,X.jsx)(`option`,{value:`anthropic`,children:y(`activity:provider.anthropic`)}),(0,X.jsx)(`option`,{value:`openai`,children:y(`activity:provider.openai`)}),(0,X.jsx)(`option`,{value:`openai-compatible`,children:y(`activity:provider.openaiCompatible`)}),(0,X.jsx)(`option`,{value:`google`,children:y(`activity:provider.google`)})]}),(0,X.jsx)(zi,{placeholder:y(`activity:provider.baseUrlOptionalEGHttpLocalhost11434V1`),value:ee,onChange:e=>te(e.target.value),ref:ae.setFieldRef(2),onKeyDown:e=>ae.handleKeyDown(e,2)}),(0,X.jsx)(zi,{type:`password`,placeholder:y(`settings:provider.apiKeyOptionalPlaceholder`),value:ne,onChange:e=>re(e.target.value),ref:ae.setFieldRef(3),onKeyDown:e=>ae.handleKeyDown(e,3)}),(0,X.jsx)(xp,{models:P,onChange:ie}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(J,{size:`sm`,onClick:F,disabled:!A.trim(),ref:ae.setFieldRef(4),onKeyDown:e=>ae.handleKeyDown(e,4,F),children:y(`common:action.add`)}),(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>k(!1),ref:ae.setFieldRef(5),onKeyDown:e=>ae.handleKeyDown(e,5),children:y(`common:action.cancel`)})]})]}),i?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,X.jsx)(ln,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r.length===0?(0,X.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,X.jsx)(lr,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,X.jsx)(`p`,{children:y(`settings:provider.noSaved`)}),(0,X.jsx)(`p`,{className:`text-sm`,children:y(`settings:provider.noSavedHint`)})]}):r.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/80 bg-card/70 p-4 shadow-sm shadow-black/[0.02]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h4`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-foreground`,children:e.id}),e.family&&(0,X.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:e.family}),e.apiKeys.some(e=>e.isActive)&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:[(0,X.jsx)(Ot,{className:`h-3 w-3`}),y(`settings:provider.active`)]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[e.baseUrl&&(0,X.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,X.jsx)(u,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.baseUrl})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,X.jsx)(Rt,{className:`h-3.5 w-3.5`}),y(`settings:provider.modelCount`,{count:e.models?.length??0})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,X.jsx)(lr,{className:`h-3.5 w-3.5`}),y(`settings:provider.keyCount`,{count:e.apiKeys.length})]})]})]}),(0,X.jsx)(`div`,{className:`flex gap-2 sm:justify-end`,children:(0,X.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>p(e.id),"aria-label":`Remove provider ${e.id}`,title:`Remove provider ${e.id}`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,X.jsx)(hn,{className:`h-4 w-4 text-destructive`})})})]}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.85fr)]`,children:[(0,X.jsx)(rm,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,savedCustomModels:e.customModels,ws:h,onPickModel:m}),(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold`,children:y(`settings:provider.apiKeysLabel`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:y(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,X.jsxs)(J,{size:`sm`,variant:`ghost`,onClick:()=>x(b===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),y(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!b&&(0,X.jsx)(`p`,{className:`mt-3 rounded-md border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:y(`settings:provider.noKeys`)}),e.apiKeys.length>0&&(0,X.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.apiKeys.map(t=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/70 bg-muted/20 p-2.5 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background text-muted-foreground`,children:(0,X.jsx)(lr,{className:`h-3.5 w-3.5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),t.isActive&&(0,X.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:y(`settings:provider.active`)})]}),(0,X.jsx)(`div`,{className:`mt-0.5`,children:(0,X.jsx)(dp,{maskedKey:t.maskedKey})})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!t.isActive&&(0,X.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>d(e.id,t.label),className:`h-8 px-2 text-xs`,children:y(`settings:provider.setActive`)}),(0,X.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>l(e.id,t.label),"aria-label":`Delete key ${t.label}`,title:`Delete key ${t.label}`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,X.jsx)(hn,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),b===e.id&&(0,X.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-border/70 bg-background p-3`,children:[(0,X.jsx)(zi,{placeholder:y(`settings:provider.keyLabelPlaceholder`),value:S,onChange:e=>C(e.target.value),ref:oe.setFieldRef(0),onKeyDown:e=>oe.handleKeyDown(e,0)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(zi,{type:E?`text`:`password`,placeholder:y(`settings:provider.apiKeyPlaceholder`),value:w,onChange:e=>T(e.target.value),ref:oe.setFieldRef(1),onKeyDown:e=>oe.handleKeyDown(e,1)}),(0,X.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>D(!E),children:E?(0,X.jsx)(rr,{className:`h-4 w-4`}):(0,X.jsx)(xn,{className:`h-4 w-4`})})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(J,{size:`sm`,onClick:()=>se(e.id),disabled:!S.trim()||!w.trim(),ref:oe.setFieldRef(2),onKeyDown:t=>oe.handleKeyDown(t,2,()=>se(e.id)),children:y(`settings:provider.saveKey`)}),(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{x(null),C(``),T(``)},ref:oe.setFieldRef(3),onKeyDown:e=>oe.handleKeyDown(e,3),children:y(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var sm=Object.entries({discovery:[[`explore`,`Explore`],[`search`,`Search`],[`research`,`Research`]],planning:[[`analyst`,`Analyst`],[`planner`,`Planner`],[`architect`,`Architect`],[`critic`,`Critic`],[`refactor-planner`,`Refactor Planner`]],build:[[`executor`,`Executor`],[`refactor`,`Refactor`],[`simplifier`,`Simplifier`],[`migration`,`Migration`],[`vision`,`Vision`],[`debugger`,`Debugger`],[`tracer`,`Tracer`],[`concurrency`,`Concurrency`]],verify:[[`realtime`,`Realtime`],[`resilience-engineer`,`Resilience Engineer`],[`chaos-engineer`,`Chaos Engineer`],[`verifier`,`Verifier`],[`test`,`Test`],[`e2e`,`E2E`],[`browser`,`Browser`],[`performance`,`Performance`],[`chaos`,`Chaos`],[`security-scanner`,`Security Scanner`],[`bug-hunter`,`Bug Hunter`],[`audit-log`,`Audit Log`]],review:[[`threat-modeler`,`Threat Modeler`],[`secure-coding-coach`,`Secure Coding Coach`],[`compliance-auditor`,`Compliance Auditor`],[`privacy-engineer`,`Privacy Engineer`],[`reviewer`,`Reviewer`],[`code-reviewer`,`Code Reviewer`],[`security-reviewer`,`Security Reviewer`],[`accessibility`,`Accessibility`],[`compliance`,`Compliance`]],domain:[[`android`,`Android`],[`desktop`,`Desktop`],[`distributed-systems`,`Distributed Systems`],[`database`,`Database`],[`api`,`API`],[`auth`,`Auth`],[`data`,`Data`],[`frontend`,`Frontend`],[`backend`,`Backend`],[`designer`,`Designer`],[`ios`,`iOS`],[`payments`,`Payments`],[`messaging`,`Messaging`],[`search-relevance`,`Search Relevance`],[`storage`,`Storage`],[`ml-engineer`,`ML Engineer`],[`data-governance`,`Data Governance`]],knowledge:[[`document`,`Document`],[`uml`,`UML`],[`i18n`,`I18n`],[`prompt`,`Prompt`]],delivery:[[`platform-engineer`,`Platform Engineer`],[`git`,`Git`],[`release`,`Release`],[`devops`,`DevOps`],[`observability`,`Observability`],[`dependency`,`Dependency`]],meta:[[`skill-manage`,`Skill Manager`],[`self-improving`,`Self-Improving`],[`context`,`Context`],[`cost`,`Cost`],[`tech-stack`,`Tech Stack Validator`],[`plugin-author`,`Plugin Author`],[`tool-author`,`Tool Author`],[`prompt-evaluator`,`Prompt Evaluator`],[`benchmark-engineer`,`Benchmark Engineer`],[`memory-curator`,`Memory Curator`],[`fleet-coordinator`,`Fleet Coordinator`]]}).map(([e,t])=>({phase:e,label:`${e.charAt(0).toUpperCase()}${e.slice(1)}`,roles:t.map(([e,t])=>({role:e,name:t}))})),cm=sm.map(e=>e.phase),lm=sm.flatMap(e=>[...e.roles]),um=lm.map(e=>e.role),dm=[`*`,...cm,...um];function fm(e){if(e===`*`)return`Default (*)`;let t=sm.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=lm.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var pm=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],mm=[{value:``,label:`effort: inherit`},{value:`none`,label:`effort: none`},{value:`minimal`,label:`effort: minimal`},{value:`low`,label:`effort: low`},{value:`medium`,label:`effort: medium`},{value:`high`,label:`effort: high`},{value:`xhigh`,label:`effort: xhigh`},{value:`max`,label:`effort: max`}],hm=[{value:``,label:`preserve: inherit`},{value:`on`,label:`preserve: on`},{value:`off`,label:`preserve: off`}],gm=new Set(dm);function _m(e,t,n){let r={};return e&&(r.mode=e),t&&(r.effort=t),n&&(r.preserve=n===`on`),Object.keys(r).length>0?{reasoning:r}:void 0}function vm(e){return e?[e.mode?`mode:${e.mode}`:``,e.effort?`effort:${e.effort}`:``,e.preserve===void 0?``:`preserve:${e.preserve?`on`:`off`}`].filter(Boolean):[]}function ym({syncPref:e,candidates:t}){let n=z(),{t:r}=R(),[i,a]=(0,Y.useState)(`*`),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),m=(0,Y.useCallback)(t=>e(`modelMatrix`,t),[e]),h=(0,Y.useCallback)(()=>{let e=i.trim(),t=o.trim(),r=_m(c,u,f);if(!e||!t&&!r)return;let a=t?n.fallbackProfiles[t]?{fallbackProfile:t}:t.includes(`/`)?{provider:t.slice(0,t.indexOf(`/`)),model:t.slice(t.indexOf(`/`)+1)}:{model:t}:{},h=n.modelMatrix[e]?.modelRuntime;r?a.modelRuntime=r:h&&(a.modelRuntime=h),m({...n.modelMatrix,[e]:a}),s(``),l(``),d(``),p(``)},[n.fallbackProfiles,n.modelMatrix,i,f,u,c,o,m]),g=(0,Y.useCallback)(e=>{let{[e]:t,...r}=n.modelMatrix;m(r)},[n.modelMatrix,m]),_=(0,Y.useCallback)((e,t,r)=>{let i={...n.modelMatrix},a={...i[e]??{}},o={...a.modelRuntime??{}},s={...o.reasoning??{}};t===`mode`?r?s.mode=r:delete s.mode:t===`effort`?r?s.effort=r:delete s.effort:r?s.preserve=r===`on`:delete s.preserve,Object.keys(s).length>0?o.reasoning=s:delete o.reasoning,Object.keys(o).length>0?a.modelRuntime=o:delete a.modelRuntime,a.model||a.fallbackProfile||a.modelRuntime?i[e]=a:delete i[e],m(i)},[n.modelMatrix,m]),v=e=>{let t=e.provider&&e.model?`${e.provider}/${e.model}`:e.model,n=e.modelRuntime?.reasoning;return[t??(!e.fallbackProfile&&n?r(`settings:agent.leaderModel`):``),e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...vm(n)].filter(Boolean).join(` + `)},y=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!gm.has(e)))).sort((e,t)=>e.localeCompare(t));return(0,X.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,X.jsx)($t,{className:`h-4 w-4 text-muted-foreground`}),r(`settings:agent.routingHeading`)]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,180px)_1fr_auto]`,children:[(0,X.jsxs)(`select`,{"aria-label":r(`settings:agent.routingRouteKey`),value:i,onChange:e=>a(e.target.value),className:`h-9 min-w-0 rounded-md border bg-background px-3 font-mono text-sm`,children:[(0,X.jsx)(`option`,{value:`*`,children:fm(`*`)}),(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:sm.map(e=>(0,X.jsx)(`option`,{value:e.phase,children:fm(e.phase)},e.phase))}),sm.map(e=>(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingRolesGroup`,{label:e.label}),children:e.roles.map(e=>(0,X.jsx)(`option`,{value:e.role,children:fm(e.role)},e.role))},e.phase)),y.length>0?(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingCustomGroup`),children:y.map(e=>(0,X.jsx)(`option`,{value:e,children:fm(e)},e))}):null]}),(0,X.jsxs)(`select`,{"aria-label":r(`settings:agent.routingTargetAria`),value:o,onChange:e=>s(e.target.value),className:`h-9 min-w-0 rounded-md border bg-background px-3 font-mono text-sm`,children:[(0,X.jsx)(`option`,{value:``,children:r(`settings:agent.routingTargetEmpty`)}),Object.keys(n.fallbackProfiles).length>0&&(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetProfilesGroup`),children:Object.keys(n.fallbackProfiles).map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))}),t&&t.length>0&&(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetModelsGroup`),children:t.map(e=>(0,X.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.provider,`/`,e.model]},`${e.provider}/${e.model}`))})]}),(0,X.jsx)(J,{type:`button`,variant:`outline`,onClick:h,children:r(`settings:agent.routingSet`)})]}),(0,X.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeAria`),value:c,onChange:e=>l(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:pm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortAria`),value:u,onChange:e=>d(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:mm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningPreserveAria`),value:f,onChange:e=>p(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:hm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]}),(0,X.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:Object.keys(n.modelMatrix).length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings:agent.noRoutes`)}):Object.entries(n.modelMatrix).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,X.jsxs)(`div`,{className:`rounded-md border border-border bg-muted px-2 py-1.5 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-40 shrink-0 truncate font-mono text-muted-foreground`,title:e,children:fm(e)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:v(t)}),(0,X.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>g(e),children:r(`common:action.remove`)})]}),(0,X.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeFor`,{key:e}),value:t.modelRuntime?.reasoning?.mode??``,onChange:t=>_(e,`mode`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:pm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortFor`,{key:e}),value:t.modelRuntime?.reasoning?.effort??``,onChange:t=>_(e,`effort`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:mm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningPreserveFor`,{key:e}),value:t.modelRuntime?.reasoning?.preserve===void 0?``:t.modelRuntime.reasoning.preserve?`on`:`off`,onChange:t=>_(e,`preserve`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:hm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}var bm=[`off`,`low`,`medium`,`high`,`all`],xm={off:`bg-muted-foreground`,low:`bg-success`,medium:`bg-warning`,high:`bg-warning ring-2 ring-warning/25`,all:`bg-destructive`},Sm={off:`settings:brain.riskCopy.off`,low:`settings:brain.riskCopy.low`,medium:`settings:brain.riskCopy.medium`,high:`settings:brain.riskCopy.high`,all:`settings:brain.riskCopy.all`},Cm=[`executor`,`skeptic`,`auditor`];function wm(e){return e&&e.length>0?e.map(e=>({id:e.id,name:e.name,description:e.description})):Cm.map(e=>({id:e,name:e}))}var Tm=[{value:`default`,labelKey:`settings:brainOpt.default15s`},{value:`5000`,label:`5s`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Em=[{value:`off`,labelKey:`settings:brainOpt.waitForever`},{value:`30000`,label:`30s`},{value:`60000`,label:`1m`},{value:`120000`,label:`2m`},{value:`300000`,label:`5m`}],Dm=[{value:`default`,labelKey:`settings:brainOpt.defaultHalf`},{value:`0.34`,label:`1/3`},{value:`0.5`,label:`1/2`},{value:`0.67`,label:`2/3`},{value:`0.75`,label:`3/4`},{value:`1`,labelKey:`settings:brainOpt.all`}],Om=[{value:`100`,label:`100`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],km=[{value:`0`,labelKey:`settings:brainOpt.offDefault`},{value:`0.3`,label:`0.3`},{value:`0.5`,label:`0.5`},{value:`0.7`,label:`0.7`},{value:`0.9`,label:`0.9`}],Am=[{value:`10`,label:`10`},{value:`20`,labelKey:`settings:brainOpt.n20Default`},{value:`50`,label:`50`},{value:`100`,label:`100`}],jm=[{value:`60000`,label:`1m`},{value:`300000`,labelKey:`settings:brainOpt.m5Default`},{value:`900000`,label:`15m`},{value:`3600000`,label:`1h`}],Mm=[{value:`50`,label:`50`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`}],Nm=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Pm=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.oneSerial`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],Fm=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`2000`,label:`2000`},{value:`4000`,label:`4000`},{value:`8000`,label:`8000`}],Im=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`200`,label:`200`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Lm=[{value:`default`,labelKey:`settings:brainOpt.default500`},{value:`100`,label:`100`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`5000`,label:`5000`}],Rm=[{value:`default`,labelKey:`settings:brainOpt.default10m`},{value:`120000`,label:`2m`},{value:`600000`,label:`10m`},{value:`1800000`,label:`30m`},{value:`3600000`,label:`1h`}];function zm(e,t){return e.some(e=>e.value===t)?e:[...e,{value:t,label:t}]}function Bm(e,t){return e.map(e=>({value:e.value,label:e.labelKey?t(e.labelKey):e.label??e.value}))}function Vm(e){return e===void 0?`default`:String(e)}function Hm({level:e}){return(0,X.jsx)(`span`,{className:H(`inline-block h-2.5 w-2.5 rounded-full`,xm[e])})}function Um(e){return e.provider?`${e.provider}/${e.model}`:e.model}var Wm={pool:{title:`settings:brain.pickPoolTitle`,hint:`settings:brain.pickPoolHint`},voter:{title:`settings:brain.pickVoterTitle`,hint:`settings:brain.pickVoterHint`},judge:{title:`settings:brain.pickJudgeTitle`,hint:`settings:brain.pickJudgeHint`}};function Gm(){let{t:e}=R(),{client:t}=Br(),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)([]),[o,s]=(0,Y.useState)(!0),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{t.send({type:`brain.status`}),t.send({type:`brain.config.get`})},[t]),(0,Y.useEffect)(()=>{let n=t.on(`brain.status`,e=>{let t=e.payload,n=Date.now();a(t.log.slice(-10).map(e=>{let t=Math.max(0,Math.round((n-e.at)/1e3)),r=t<60?`${t}s`:t<3600?`${Math.round(t/60)}m`:`${Math.round(t/3600)}h`;return{kind:e.kind,question:e.question,outcome:e.outcome,age:r}})),s(!1)}),i=t.on(`brain.config`,t=>{let n=t.payload;r(n.config),d(n.persisted?null:n.error??e(`settings:brain.persistError`)),l(!1),s(!1)});return()=>{n(),i()}},[t,e]);let m=(0,Y.useCallback)(e=>{l(!0),t.send({type:`brain.config.set`,payload:{patch:e}})},[t]),h=(0,Y.useCallback)(e=>{r(t=>t&&{...t,maxAutoRisk:e}),m({maxAutoRisk:e})},[m]),g=(0,Y.useMemo)(()=>n?.council.voters??[],[n]),v=(0,Y.useCallback)(e=>{m({council:{voters:e.length>0?e:null}})},[m]),y=(0,Y.useMemo)(()=>wm(n?.personaCatalog),[n?.personaCatalog]),b=bm.includes(n?.maxAutoRisk??``)?n?.maxAutoRisk??`medium`:`medium`,x=(0,Y.useCallback)(e=>{if(!n||!f)return;let t=`${e.provider}/${e.model}`;if(f===`pool`){m({models:[...n.models.map(Um),t]});return}if(f===`judge`){m({council:{judge:t}});return}return v([...g,{provider:e.provider,model:e.model,persona:y[g.length%y.length]?.id??`executor`}]),!0},[n,y,f,m,v,g]);return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(Cf,{open:f!==null,mode:`provider-model`,title:f?e(Wm[f].title):``,hint:f?e(Wm[f].hint):void 0,onPick:e=>{if(e.type===`provider-model`)return x(e)},onClose:()=>p(null)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Nt,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`settings:brain.heading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.headingHint`)})]}),(o||c)&&(0,X.jsx)(ln,{className:`ml-auto h-4 w-4 animate-spin text-muted-foreground`})]}),u&&(0,X.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:u}),(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.riskHeading`)}),(0,X.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:bm.map(e=>(0,X.jsxs)(J,{variant:b===e?`default`:`outline`,size:`sm`,className:H(`gap-1.5 text-xs`,b===e&&`shadow-sm`),disabled:c,onClick:()=>h(e),children:[(0,X.jsx)(Hm,{level:e}),e.toUpperCase()]},e))}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(Sm[b])})]}),n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.escalationHeading`)}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationModeLabel`),hint:e(`settings:brain.escalationModeHint`),value:n.mode,options:[{value:`interactive`,label:e(`settings:brain.optInteractive`)},{value:`headless`,label:e(`settings:brain.optHeadless`)}],onChange:e=>m({mode:e}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationDecisionTimeoutLabel`),hint:e(`settings:brain.escalationDecisionTimeoutHint`),value:n.decisionTimeoutMs?String(n.decisionTimeoutMs):`default`,options:Bm(Tm,e),onChange:e=>m({decisionTimeoutMs:e==="default"?null:Number(e)}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationHumanTimeoutLabel`),hint:e(`settings:brain.escalationHumanTimeoutHint`),value:n.humanTimeoutMs?String(n.humanTimeoutMs):`off`,options:Bm(Em,e),onChange:e=>m({humanTimeoutMs:e===`off`?null:Number(e)}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationTerminalPolicyLabel`),hint:e(`settings:brain.escalationTerminalPolicyHint`),value:n.terminalPolicy,options:[{value:`conservative`,label:e(`settings:brain.optConservative`)},{value:`deny-all`,label:e(`settings:brain.optDenyAll`)},{value:`continue-on-recommended`,label:e(`settings:brain.optContinueRecommended`)}],onChange:e=>m({terminalPolicy:e}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationDecisionLogSizeLabel`),hint:e(`settings:brain.escalationDecisionLogSizeHint`),value:String(n.decisionLogMaxEntries),options:Bm(zm(Am,String(n.decisionLogMaxEntries)),e),onChange:e=>m({decisionLogMaxEntries:Number(e)}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.rulesHeading`)}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.rulesConfigured`,{count:n.rules.length})})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.rulesBody`)}),n.rules.length>0&&(0,X.jsx)(`div`,{className:`space-y-1`,children:n.rules.map((t,n)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[n+1,`.`]}),(0,X.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:t.id}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px] shrink-0`,children:t.then.action}),t.enabled===!1&&(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px] shrink-0`,children:e(`settings:brain.rulesOff`)})]},`${t.id}-${n}`))}),n.ruleErrors.length>0&&(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-warning`,children:e(`settings:brain.rulesDropped`,{count:n.ruleErrors.length})}),n.ruleErrors.map(e=>(0,X.jsx)(`p`,{className:`text-xs text-warning`,children:e},e))]})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.heuristicsHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsBody`)}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsLowRiskLabel`),hint:e(`settings:brain.heuristicsLowRiskHint`),value:n.heuristics.lowRiskAutoAnswer,onChange:()=>m({heuristics:{lowRiskAutoAnswer:!n.heuristics.lowRiskAutoAnswer}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsBlockedLabel`),hint:e(`settings:brain.heuristicsBlockedHint`),value:n.heuristics.blockedResolved,onChange:()=>m({heuristics:{blockedResolved:!n.heuristics.blockedResolved}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsDeadlockLabel`),hint:e(`settings:brain.heuristicsDeadlockHint`),value:n.heuristics.deadlockSkip,onChange:()=>m({heuristics:{deadlockSkip:!n.heuristics.deadlockSkip}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsRetryLabel`),hint:e(`settings:brain.heuristicsRetryHint`),value:n.heuristics.retryExhausted,onChange:()=>m({heuristics:{retryExhausted:!n.heuristics.retryExhausted}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsPingLabel`),hint:e(`settings:brain.heuristicsPingHint`),value:n.heuristics.continuePing,onChange:()=>m({heuristics:{continuePing:!n.heuristics.continuePing}}),disabled:c}),n.heuristics.blockedResolvedMarkers&&n.heuristics.blockedResolvedMarkers.length>0&&(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsMarkers`,{markers:n.heuristics.blockedResolvedMarkers.join(`, `)})})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.qualityHeading`)}),n.circuit&&(0,X.jsx)(Yf,{variant:n.circuit.state===`closed`?`outline`:`default`,className:`text-[10px]`,children:e(`settings:brain.qualityCircuit`,{state:n.circuit.state,count:n.circuit.consecutiveFailures})})]}),(0,X.jsx)(Q,{label:e(`settings:brain.qualityResponseBudgetLabel`),hint:e(`settings:brain.qualityResponseBudgetHint`),value:String(n.llm.maxTokens),options:Bm(zm(Om,String(n.llm.maxTokens)),e),onChange:e=>m({llm:{maxTokens:Number(e)}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.qualityRejectLabel`),hint:e(`settings:brain.qualityRejectHint`),value:n.llm.rejectUncertain,onChange:()=>m({llm:{rejectUncertain:!n.llm.rejectUncertain}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.qualityMinConfidenceLabel`),hint:e(`settings:brain.qualityMinConfidenceHint`),value:String(n.llm.minConfidence),options:Bm(zm(km,String(n.llm.minConfidence)),e),onChange:e=>m({llm:{minConfidence:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.qualityDenyTerminalLabel`),hint:e(`settings:brain.qualityDenyTerminalHint`),value:n.llm.denyIsTerminal,options:[{value:`never`,label:e(`settings:brain.optNeverDefault`)},{value:`when-decided`,label:e(`settings:brain.optWhenDecided`)},{value:`always`,label:e(`settings:brain.optAlways`)}],onChange:e=>m({llm:{denyIsTerminal:e}}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.traceHeading`)}),(0,X.jsx)($,{label:e(`settings:brain.traceRecordLabel`),hint:e(`settings:brain.traceRecordHint`),value:n.trace.enabled,onChange:()=>m({trace:{enabled:!n.trace.enabled}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.traceContentLabel`),hint:e(`settings:brain.traceContentHint`),value:n.trace.content,options:[{value:`full`,label:e(`settings:brain.optFullDefault`)},{value:`redacted`,label:e(`settings:brain.optRedacted`)},{value:`none`,label:e(`settings:brain.optMetadataOnly`)}],onChange:e=>m({trace:{content:e}}),disabled:c}),n.trace.path&&(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.trace.path})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.cacheHeading`)}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.cacheStats`,{hits:n.cache.hits,misses:n.cache.misses,size:n.cache.size})})]}),(0,X.jsx)($,{label:e(`settings:brain.cacheReplayLabel`),hint:e(`settings:brain.cacheReplayHint`),value:n.cache.enabled,onChange:()=>m({cache:{enabled:!n.cache.enabled}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.cacheLifetimeLabel`),hint:e(`settings:brain.cacheLifetimeHint`),value:String(n.cache.ttlMs),options:Bm(zm(jm,String(n.cache.ttlMs)),e),onChange:e=>m({cache:{ttlMs:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.cacheMaxEntriesLabel`),hint:e(`settings:brain.cacheMaxEntriesHint`),value:String(n.cache.maxEntries),options:Bm(zm(Mm,String(n.cache.maxEntries)),e),onChange:e=>m({cache:{maxEntries:Number(e)}}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.monitorHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.monitorBody`)}),(0,X.jsx)($,{label:e(`settings:brain.monitorWatchLabel`),hint:e(`settings:brain.monitorWatchHint`),value:n.monitor.enabled!==!1,onChange:()=>m({monitor:{enabled:n.monitor.enabled===!1}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.monitorPolicyLabel`),hint:e(`settings:brain.monitorPolicyHint`),value:n.monitor.policy??`llm`,options:[{value:`llm`,label:e(`settings:brain.optConsultBrain`)},{value:`steer`,label:e(`settings:brain.optAlwaysSteer`)},{value:`observe`,label:e(`settings:brain.optObserveOnly`)}],onChange:e=>m({monitor:{policy:e}}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.modelsHeading`)}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px]`,children:n.usingSessionModel?e(`settings:brain.modelsSessionBadge`):e(`settings:brain.modelsResolvedBadge`,{resolved:n.poolLabels.length,total:n.models.length})})]}),(0,X.jsx)($,{label:e(`settings:brain.modelsUseSessionLabel`),hint:e(`settings:brain.modelsUseSessionHint`),value:n.usingSessionModel,onChange:()=>{n.usingSessionModel||m({models:null})},disabled:c}),n.models.length>0&&(0,X.jsx)(`div`,{className:`space-y-1`,children:n.models.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[t+1,`.`]}),(0,X.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:Um(e)}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===0,onClick:()=>{let e=n.models.map(Um),r=e.splice(t,1)[0];r&&e.splice(t-1,0,r),m({models:e})},children:(0,X.jsx)(tn,{className:`h-3 w-3`})}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===n.models.length-1,onClick:()=>{let e=n.models.map(Um),r=e.splice(t,1)[0];r&&e.splice(t+1,0,r),m({models:e})},children:(0,X.jsx)(Ze,{className:`h-3 w-3`})}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>{let e=n.models.map(Um).filter((e,n)=>n!==t);m({models:e.length>0?e:null})},children:(0,X.jsx)(Wt,{className:`h-3 w-3`})})]},`${Um(e)}-${t}`))}),(0,X.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`pool`),children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.modelsAddModel`)]}),n.models.length>1&&(0,X.jsx)(Q,{label:e(`settings:brain.modelsPoolStrategyLabel`),hint:e(`settings:brain.modelsPoolStrategyHint`),value:n.strategy,options:[{value:`fallback`,label:e(`settings:brain.optFallback`)},{value:`round-robin`,label:e(`settings:brain.optRoundRobin`)}],onChange:e=>m({strategy:e}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.councilHeading`)}),(0,X.jsx)(Yf,{variant:n.council.enabled?`default`:`outline`,className:`text-[10px]`,children:n.council.enabled?e(`settings:brain.councilConvened`):e(`settings:brain.councilDisabled`)})]}),(0,X.jsx)($,{label:e(`settings:brain.councilEnableLabel`),hint:e(`settings:brain.councilEnableHint`),value:n.council.enabled,onChange:()=>m({council:{enabled:!n.council.enabled}}),disabled:c}),n.council.enabled&&n.councilLabels.length>0&&g.length===0&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.councilSeatsDerived`,{seats:n.councilLabels.join(`, `)})}),g.length>0&&(0,X.jsx)(`div`,{className:`space-y-1`,children:g.map((t,n)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,X.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:Um(t)}),(0,X.jsxs)(`select`,{value:t.persona??y[n%y.length]?.id??``,onChange:e=>v(g.map((t,r)=>r===n?{...t,persona:e.target.value}:t)),className:`h-6 rounded border bg-background px-1 text-[10px]`,title:y.find(e=>e.id===t.persona)?.description??e(`settings:brain.councilCustomLens`),children:[y.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id)),t.persona&&!y.some(e=>e.id===t.persona)&&(0,X.jsx)(`option`,{value:t.persona,children:e(`settings:brain.councilCustomOption`,{persona:t.persona})})]}),(0,X.jsx)(J,{variant:t.veto?`default`:`outline`,size:`sm`,className:`h-6 px-1.5 text-[10px]`,disabled:c,onClick:()=>v(g.map((e,t)=>t===n?{...e,veto:!e.veto}:e)),children:e(`settings:brain.councilVeto`)}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>v(g.filter((e,t)=>t!==n)),children:(0,X.jsx)(Wt,{className:`h-3 w-3`})})]},`${Um(t)}-${n}`))}),(0,X.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`voter`),children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.councilAddVoter`)]}),(0,X.jsx)(Q,{label:e(`settings:brain.councilRiskFloorLabel`),hint:e(`settings:brain.councilRiskFloorHint`),value:n.council.minRisk,options:[{value:`medium`,label:e(`settings:brain.optMediumPlus`)},{value:`high`,label:e(`settings:brain.optHighPlus`)},{value:`critical`,label:e(`settings:brain.optCriticalOnly`)}],onChange:e=>m({council:{minRisk:e}}),disabled:c}),(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium`,children:e(`settings:brain.councilJudge`)}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`settings:brain.councilJudgeDesc`)}),!n.council.judge&&n.judgeLabel&&(0,X.jsxs)(`div`,{className:`mt-0.5 font-mono text-xs text-muted-foreground`,children:[e(`settings:brain.councilResolved`,{model:n.judgeLabel}),n.judgeIsVoter&&(0,X.jsx)(`span`,{className:`ml-1 font-sans text-warning`,children:e(`settings:brain.councilAlsoVoter`)})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`max-w-[180px] truncate font-mono text-xs`,children:n.council.judge?Um(n.council.judge):e(`settings:brain.councilAuto`)}),(0,X.jsx)(J,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>p(`judge`),children:e(`settings:brain.councilPick`)}),n.council.judge&&(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>m({council:{judge:null}}),children:e(`settings:brain.councilAutoReset`)})]})]}),(0,X.jsx)(Q,{label:e(`settings:brain.councilQuorumLabel`),hint:e(`settings:brain.councilQuorumHint`),value:n.council.quorum===void 0?`default`:String(n.council.quorum),options:Bm(Dm,e),onChange:e=>m({council:{quorum:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilApprovalLabel`),hint:e(`settings:brain.councilApprovalHint`),value:n.council.approval===void 0?`default`:String(n.council.approval),options:Bm(Dm,e),onChange:e=>m({council:{approval:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilPerSeatTimeoutLabel`),hint:e(`settings:brain.councilPerSeatTimeoutHint`),value:Vm(n.council.perCallTimeoutMs),options:Bm(zm(Nm,Vm(n.council.perCallTimeoutMs)),e),onChange:e=>m({council:{perCallTimeoutMs:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilMaxConcurrencyLabel`),hint:e(`settings:brain.councilMaxConcurrencyHint`),value:Vm(n.council.maxConcurrency),options:Bm(zm(Pm,Vm(n.council.maxConcurrency)),e),onChange:e=>m({council:{maxConcurrency:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilDistinctnessLabel`),hint:e(`settings:brain.councilDistinctnessHint`),value:n.council.distinctness,options:[{value:`none`,label:e(`settings:brain.optNoneDefault`)},{value:`model`,label:e(`settings:brain.optDistinctModels`)},{value:`provider`,label:e(`settings:brain.optDistinctProviders`)}],onChange:e=>m({council:{distinctness:e}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilVoterBudgetLabel`),hint:e(`settings:brain.councilVoterBudgetHint`),value:Vm(n.council.voterMaxTokens),options:Bm(zm(Fm,Vm(n.council.voterMaxTokens)),e),onChange:e=>m({council:{voterMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilJudgeBudgetLabel`),hint:e(`settings:brain.councilJudgeBudgetHint`),value:Vm(n.council.judgeMaxTokens),options:Bm(zm(Im,Vm(n.council.judgeMaxTokens)),e),onChange:e=>m({council:{judgeMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),n.council.seats.length>0&&(0,X.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[e(`settings:brain.councilSeatTemplate`),` `,n.council.seats.map(t=>t.veto?`${t.persona} (${e(`settings:brain.councilVeto`)})`:t.persona).join(`, `)]})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.ledgerHeading`)}),(0,X.jsx)($,{label:e(`settings:brain.ledgerRecordLabel`),hint:e(`settings:brain.ledgerRecordHint`),value:n.ledger.enabled,onChange:()=>m({ledger:{enabled:!n.ledger.enabled}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.ledgerAutoDenyLabel`),hint:e(`settings:brain.ledgerAutoDenyHint`),value:n.ledger.autoDenyAfterFailures===void 0?`default`:String(n.ledger.autoDenyAfterFailures),options:[{value:`default`,label:e(`settings:brain.optDefault3`)},{value:`0`,label:e(`settings:brain.optOff`)},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],onChange:e=>m({ledger:{autoDenyAfterFailures:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.ledgerMemoryEntriesLabel`),hint:e(`settings:brain.ledgerMemoryEntriesHint`),value:Vm(n.ledger.maxMemoryEntries),options:Bm(zm(Lm,Vm(n.ledger.maxMemoryEntries)),e),onChange:e=>m({ledger:{maxMemoryEntries:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.ledgerRetryWindowLabel`),hint:e(`settings:brain.ledgerRetryWindowHint`),value:Vm(n.ledger.interventionRetryWindowMs),options:Bm(zm(Rm,Vm(n.ledger.interventionRetryWindowMs)),e),onChange:e=>m({ledger:{interventionRetryWindowMs:e==="default"?null:Number(e)}}),disabled:c}),n.ledger.path&&(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.ledger.path})]})]}),(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.recentHeading`,{count:i.length})}),(0,X.jsx)(`div`,{className:`space-y-1 max-h-[300px] overflow-y-auto`,children:i.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground py-2`,children:e(`settings:brain.recentEmpty`)}):i.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-8`,children:e.age}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px] shrink-0`,children:e.kind}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.question}),e.outcome&&(0,X.jsx)(`span`,{className:`text-muted-foreground shrink-0 italic`,children:e.outcome})]},`${e.age}-${e.kind}-${e.question.slice(0,32)}`))})]})]})}function Km(){let{t:e}=R();return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(xn,{className:`h-5 w-5 text-info`}),(0,X.jsx)(`h3`,{className:`text-lg font-semibold`,children:e(`activity:shadow.shadowAgent`)})]}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`activity:shadow.theShadowAgentMonitorsAllFleet`)}),(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Start and stop it from the chat with`,` `,(0,X.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow start`}),` and`,` `,(0,X.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow stop`}),`. This panel cannot control it yet.`]})]})}function qm({disabled:e,mutating:t}){return(0,X.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full ${e?`bg-muted-foreground`:t?`bg-warning`:`bg-success`}`,title:e?`disabled`:t?`mutating`:`read-only`})}function Jm({tool:e,onToggle:t,busy:n}){let{t:r}=R(),[i,a]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,X.jsx)(qm,{disabled:e.disabled,mutating:e.mutating}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`code`,{className:`block truncate text-sm font-mono font-semibold`,title:e.name,children:e.name}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(Yf,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,X.jsx)(Yf,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:e.owner,children:e.owner})]})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[(0,X.jsxs)(J,{variant:e.disabled?`default`:`secondary`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:t,disabled:n,children:[n?(0,X.jsx)(ln,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,X.jsx)($e,{className:`h-3 w-3`}):(0,X.jsx)(yr,{className:`h-3 w-3`}),e.disabled?`Enable`:`Disable`]}),(0,X.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>a(!i),"aria-label":i?`Collapse`:`Expand`,children:(0,X.jsx)(Ue,{className:`h-4 w-4 transition-transform ${i?`rotate-180`:``}`})})]})]}),i&&(0,X.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2 text-xs text-muted-foreground sm:ml-4`,children:[(0,X.jsx)(`p`,{children:e.description}),e.params.length>0&&(0,X.jsxs)(`p`,{children:[r(`activity:toolsSec.params`),` `,(0,X.jsx)(`code`,{className:`break-all font-mono`,children:e.params.join(`, `)})]})]})]})}function Ym(){let{t:e}=R(),{client:t}=Br(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{let e=t.on(`tools.list`,e=>{let t=e.payload;r(t.tools),a(!1)}),n=e=>{if(e.type===`tool.disabled`||e.type===`tool.enabled`){let n=e.payload;l(e=>{let t=new Set(e);return t.delete(n.name),t}),n.ok?t.send({type:`tools.list`},{echoToChat:!1}):q.error(`Tool "${n.name}" ${e.type===`tool.disabled`?`disable`:`enable`} failed.`)}},i=t.on(`tool.disabled`,n),o=t.on(`tool.enabled`,n);return()=>{e(),i(),o()}},[t]),(0,Y.useEffect)(()=>{t.send({type:`tools.list`},{echoToChat:!1})},[t]);let u=(0,Y.useCallback)((e,n)=>{l(t=>new Set(t).add(e)),t.send({type:n?`tool.enable`:`tool.disable`,payload:{name:e}})},[t]),d=o?n.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())||e.owner.toLowerCase().includes(o.toLowerCase())):n,f=n.filter(e=>!e.disabled).length,p=n.filter(e=>e.disabled).length;return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Xt,{className:`h-5 w-5`})}),(0,X.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`activity:toolsSec.tools`)})]}),!i&&(0,X.jsxs)(`span`,{className:`rounded-md border border-border/60 bg-muted/30 px-2 py-1 text-xs text-muted-foreground sm:ml-auto`,children:[f,` active · `,p,` disabled · `,n.length,` total`]})]}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(Ft,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,X.jsx)(zi,{placeholder:e(`activity:toolsSec.filterToolsByNameOrOwner`),value:o,onChange:e=>s(e.target.value),className:`pl-8 h-9 text-sm`})]}),i?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground gap-2`,children:[(0,X.jsx)(ln,{className:`h-4 w-4 animate-spin`}),e(`activity:toolsSec.loadingTools`)]}):d.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:o?`No tools matching "${o}".`:`No tools registered.`}):(0,X.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border/70 bg-background/35 shadow-inner`,children:[(0,X.jsx)(`ul`,{className:`max-h-[min(58dvh,660px)] space-y-2 overflow-y-scroll p-2 pr-3 [scrollbar-gutter:stable]`,"aria-label":e(`activity:toolsSec.toolsList`),children:d.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Jm,{tool:e,onToggle:()=>u(e.name,e.disabled),busy:c.has(e.name)})},e.name))}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-4 bg-gradient-to-b from-background/90 to-transparent`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-background/95 to-transparent`})]})]})}function Xm(){let{t:e}=R();return(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(xn,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.brainHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.brainHint`)})]})]}),(0,X.jsx)(Gm,{})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(xn,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.shadowHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.shadowHint`)})]})]}),(0,X.jsx)(Km,{})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(xn,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.toolsHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.toolsHint`)})]})]}),(0,X.jsx)(Ym,{})]})]})}var Zm=[{id:`general`,icon:(0,X.jsx)(F,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.general`,descKey:`settings:tabs.generalDesc`},{id:`provider`,icon:(0,X.jsx)(kr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.provider`,descKey:`settings:tabs.providerDesc`},{id:`connection`,icon:(0,X.jsx)(u,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.connection`,descKey:`settings:tabs.connectionDesc`},{id:`agent`,icon:(0,X.jsx)(bn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.agent`,descKey:`settings:tabs.agentDesc`},{id:`execution`,icon:(0,X.jsx)(ar,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.execution`,descKey:`settings:tabs.executionDesc`},{id:`fallbacks`,icon:(0,X.jsx)($t,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fallbacks`,descKey:`settings:tabs.fallbacksDesc`},{id:`routing`,icon:(0,X.jsx)(Xn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.routing`,descKey:`settings:tabs.routingDesc`},{id:`fleet`,icon:(0,X.jsx)(Cr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fleet`,descKey:`settings:tabs.fleetDesc`},{id:`integrations`,icon:(0,X.jsx)(zt,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.integrations`,descKey:`settings:tabs.integrationsDesc`},{id:`chimera`,icon:(0,X.jsx)(Nt,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.chimera`,descKey:`settings:tabs.chimeraDesc`},{id:`context`,icon:(0,X.jsx)(yt,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.context`,descKey:`settings:tabs.contextDesc`},{id:`logs`,icon:(0,X.jsx)(Wn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.logs`,descKey:`settings:tabs.logsDesc`},{id:`security`,icon:(0,X.jsx)(me,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.security`,descKey:`settings:tabs.securityDesc`},{id:`display`,icon:(0,X.jsx)(F,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.display`,descKey:`settings:tabs.displayDesc`}];function Qm(){let{settingsActiveTab:e,setSettingsActiveTab:t}=G(fn(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),n=Qd(`settings`),r=(0,Y.useRef)(!1),[i,a]=(0,Y.useState)(!1),{provider:o,model:s,setProvider:c,setModel:l,wsConnected:u}=W(fn(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),d=Br(),f=d.client,{updatePrefs:p,switchAutonomy:m}=d,h=z(),{t:g}=R(),_=Ki(!0),v=(0,Y.useCallback)((e,t)=>{h.set({[e]:t}),p({[e]:t})},[h,p]),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)({}),[C,w]=(0,Y.useState)([]),[T,E]=(0,Y.useState)(!1),[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(`catalog`),[N,ee]=(0,Y.useState)(``),[te,ne]=(0,Y.useState)(!1),[re,P]=(0,Y.useState)(!1),ie=(0,Y.useCallback)(()=>{h.reset(),P(!1),window.location.reload()},[h]),ae=y.find(e=>e.id===o),oe=Zm.find(t=>t.id===e);(0,Y.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;b(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),E(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;S(e=>({...e,[t.provider]:t.models})),O(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));w(t),A(!1),t.length>0&&M(`saved`)}};if(!u||!f)return;let r=f.on(`provider.catalog`,e),i=f.on(`provider.models`,t),a=f.on(`providers.saved`,n);return E(!0),A(!0),f.listProviders(),f.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[u,f]);let se=(0,Y.useCallback)(e=>{c(e),x[e]||(O(!0),d.listProviderModels?.(e))},[x,c,d]),ce=(0,Y.useCallback)(async e=>{if(r.current)return;let t=W.getState().model,n=W.getState().provider;if(!(!n||e===t)){r.current=!0,a(!0),l(e);try{q.info(L.t(`settings:toast.switchingTo`,{provider:n,model:e}));let r=await d.switchModel?.(n,e);r?.success?q.success(L.t(r.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${n} / ${t}`,to:`${n} / ${e}`})):(l(t),q.error(r?.message??L.t(`settings:toast.modelSwitchTimeout`)))}finally{r.current=!1,a(!1)}}},[l,d]),F=(0,Y.useCallback)((e,t,n)=>{d.addKey?.(e,t,n)},[d]),I=(0,Y.useCallback)((e,t)=>{d.deleteKey?.(e,t)},[d]),le=(0,Y.useCallback)((e,t)=>{d.setActiveKey?.(e,t)},[d]),ue=(0,Y.useCallback)((e,t,n,r,i,a)=>{d.addProvider?.(e,t,n,r,i,a)},[d]),de=(0,Y.useCallback)(e=>{d.removeProvider?.(e)},[d]),fe=(0,Y.useCallback)((e,t)=>{d.client.updateProvider({id:e,models:[t]}),e===W.getState().provider&&l(t)},[l,d.client]);return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-gradient-to-b from-background/90 via-background/60 to-background/80`,children:[(0,X.jsxs)(`header`,{className:`flex items-center justify-between px-4 py-3 border-b border-border/60 bg-card/60 backdrop-blur-xl shrink-0 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(kn,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`text-lg font-semibold bg-gradient-to-r from-foreground to-foreground/70 bg-clip-text text-transparent`,children:g(`settings:title`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:o&&s?`${o} / ${s}`:g(`settings:subtitle`)})]})]}),(0,X.jsx)(J,{variant:`ghost`,size:`icon`,onClick:()=>K(`chat`),children:(0,X.jsx)(Wt,{className:`h-4 w-4`})}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>P(!0),children:g(`settings:resetLabel`)})]}),(0,X.jsx)(qa,{className:`min-h-0 flex-1`,ref:n,children:(0,X.jsx)(`div`,{className:`mx-auto max-w-7xl p-4 sm:p-6`,children:(0,X.jsxs)(Ya,{value:e,onValueChange:t,className:`grid min-h-[calc(100dvh-9rem)] gap-3 lg:grid-cols-[13.5rem_minmax(0,1fr)] lg:gap-5`,children:[(0,X.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,X.jsx)(Xa,{className:`flex h-auto w-full justify-start gap-0.5 overflow-x-scroll rounded-lg border border-border/60 bg-card/60 p-1.5 shadow-sm [scrollbar-gutter:stable] lg:sticky lg:top-4 lg:flex-col lg:overflow-visible lg:rounded-xl lg:bg-card/60 lg:p-2`,children:Zm.map(e=>(0,X.jsxs)(Za,{value:e.id,className:`h-9 shrink-0 gap-2.5 rounded-md px-3 text-xs scroll-mt-2 data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-sm lg:w-full lg:justify-start lg:px-3`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:e.icon}),(0,X.jsx)(`span`,{className:`truncate`,children:g(e.labelKey)})]},e.id))}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 left-0 z-10 w-8 rounded-l-lg bg-gradient-to-r from-background via-background/90 to-transparent lg:hidden`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 right-0 z-10 w-8 rounded-r-lg bg-gradient-to-l from-background via-background/90 to-transparent lg:hidden`})]}),(0,X.jsxs)(`div`,{className:`min-w-0 space-y-0`,children:[oe?.descKey&&(0,X.jsxs)(`div`,{className:`mb-4 flex items-start gap-3 rounded-xl border border-border/60 bg-card/50 px-4 py-3`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:oe.icon}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-sm font-semibold`,children:g(oe.labelKey)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:g(oe.descKey)})]})]}),(0,X.jsx)(Qa,{value:`general`,className:`mt-0`,children:(0,X.jsx)(Pf,{})}),(0,X.jsxs)(Qa,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,X.jsx)(om,{activeProvider:o,catalogProviders:y,isLoadingCatalog:T,savedProviders:C,isLoadingSaved:k,providerTab:j,setProviderTab:M,onSelectProvider:se,onAddKey:F,onDeleteKey:I,onSetActiveKey:le,onAddProvider:ue,onRemoveProvider:de,onPickProviderModel:fe,ws:d.client,catalogQuery:N,setCatalogQuery:ee}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold mb-4 flex items-center gap-2`,children:[(0,X.jsx)(Rt,{className:`h-4 w-4 text-muted-foreground`}),g(`settings:model.heading`)]}),(0,X.jsx)(ap,{provider:o,catalogModels:x,currentCatalogProvider:ae,isLoadingModels:D,setIsLoadingModels:O,onModelSelect:ce,isSwitching:i,refreshModels:e=>d.listProviderModels?.(e)})]})]}),(0,X.jsx)(Qa,{value:`connection`,className:`mt-0`,children:(0,X.jsx)(Nf,{})}),(0,X.jsxs)(Qa,{value:`agent`,className:`mt-0 space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Pe,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:agent.autonomyHeading`)})})]}),(0,X.jsx)(Q,{label:g(`settings:agent.autonomyModeLabel`),hint:g(`settings:agent.autonomyModeHint`),value:h.autonomy,options:[{value:`off`,label:g(`settings:agent.autonomyModeOff`)},{value:`suggest`,label:g(`settings:agent.autonomyModeSuggest`)},{value:`auto`,label:g(`settings:agent.autonomyModeAuto`)},{value:`eternal`,label:g(`settings:agent.autonomyModeEternal`)},{value:`eternal-parallel`,label:g(`settings:agent.autonomyModeEternalParallel`)}],onChange:e=>{h.set({autonomy:e}),m(e)}}),(0,X.jsx)(Mf,{label:g(`settings:agent.autonomyDelayMsLabel`),hint:g(`settings:agent.autonomyDelayMsHint`),value:h.autonomyDelayMs,min:0,max:1e4,step:500,unit:`ms`,onChange:e=>v(`autonomyDelayMs`,e)}),(0,X.jsx)($,{label:g(`settings:agent.yoloLabel`),hint:g(`settings:agent.yoloHint`),value:h.yolo,onChange:()=>v(`yolo`,!h.yolo)})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(ar,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:agent.refineHeading`)})})]}),(0,X.jsx)($,{label:g(`settings:agent.enableRefineLabel`),hint:g(`settings:agent.enableRefineHint`),value:h.enhanceEnabled,onChange:()=>v(`enhanceEnabled`,!h.enhanceEnabled)}),(0,X.jsx)(Mf,{label:g(`settings:agent.refineDelayLabel`),hint:g(`settings:agent.refineDelayHint`),value:h.enhanceDelayMs,min:3e4,max:12e4,step:15e3,unit:`ms`,onChange:e=>v(`enhanceDelayMs`,e)}),(0,X.jsx)(Mf,{label:g(`settings:agent.refineCountdownLabel`),hint:g(`settings:agent.refineCountdownHint`),value:h.enhanceCountdownMs,min:1e3,max:1e4,step:1e3,unit:`ms`,onChange:e=>v(`enhanceCountdownMs`,e)}),(0,X.jsx)(Q,{label:g(`settings:agent.refineLanguageLabel`),hint:g(`settings:agent.refineLanguageHint`),value:h.enhanceLanguage,options:[{value:`original`,label:g(`settings:agent.refineLanguageOriginal`)},{value:`english`,label:g(`settings:agent.refineLanguageEnglish`)}],onChange:e=>v(`enhanceLanguage`,e)}),(0,X.jsxs)(`div`,{className:`pt-3`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium mb-2`,children:g(`settings:agent.refineHeading`)}),(0,X.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 rounded-lg border border-border p-3 text-left cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>ne(!0),children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:h.refinerFallbackProfile?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`text-xs font-mono text-primary bg-primary/10 px-1.5 py-0.5 rounded`,children:h.refinerFallbackProfile}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(h.fallbackProfiles[h.refinerFallbackProfile]??[]).slice(0,2).join(` → `),(h.fallbackProfiles[h.refinerFallbackProfile]??[]).length>2?` …`:``]})]}):h.refinerProvider&&h.refinerModel?(0,X.jsxs)(`span`,{className:`text-xs font-mono`,children:[h.refinerProvider,`/`,h.refinerModel]}):h.refinerProvider?(0,X.jsxs)(`span`,{className:`text-xs font-mono`,children:[h.refinerProvider,` /`,` `,(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:g(`activity:index.sessionModel`)})]}):(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(`settings:agent.refinerProviderDefault`)})}),(0,X.jsx)(Rt,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]})]}),te&&(0,X.jsx)(Cf,{open:te,mode:`both`,title:g(`settings:agent.refineHeading`),hint:g(`settings:agent.refinerProviderHint`),fallbackProfiles:h.fallbackProfiles,clearLabel:g(`common:action.clear`),onPick:e=>{e.type===`clear`?(v(`refinerProvider`,``),v(`refinerModel`,``),v(`refinerFallbackProfile`,``)):e.type===`provider-model`?(v(`refinerProvider`,e.provider),v(`refinerModel`,e.model),v(`refinerFallbackProfile`,``)):e.type===`fallback-profile`&&(v(`refinerProvider`,``),v(`refinerModel`,``),v(`refinerFallbackProfile`,e.name)),ne(!1)},onClose:()=>ne(!1)})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Rt,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:agent.reasoningHeading`)})})]}),(0,X.jsx)(Q,{label:g(`settings:agent.reasoningModeLabel`),hint:g(`settings:agent.reasoningModeHint`),value:h.reasoningMode,options:[{value:`auto`,label:g(`settings:agent.reasoningModeAuto`)},{value:`on`,label:g(`settings:agent.reasoningModeOn`)},{value:`off`,label:g(`settings:agent.reasoningModeOff`)}],onChange:e=>v(`reasoningMode`,e)}),(0,X.jsx)(Q,{label:g(`settings:agent.reasoningEffortLabel`),hint:g(`settings:agent.reasoningEffortHint`),value:h.reasoningEffort,options:[{value:`none`,label:g(`settings:agent.reasoningEffortNone`)},{value:`minimal`,label:g(`settings:agent.reasoningEffortMinimal`)},{value:`low`,label:g(`settings:agent.reasoningEffortLow`)},{value:`medium`,label:g(`settings:agent.reasoningEffortMedium`)},{value:`high`,label:g(`settings:agent.reasoningEffortHigh`)},{value:`xhigh`,label:g(`settings:agent.reasoningEffortXhigh`)},{value:`max`,label:g(`settings:agent.reasoningEffortMax`)}],onChange:e=>v(`reasoningEffort`,e)}),(0,X.jsx)($,{label:g(`settings:agent.preserveThinkingLabel`),hint:g(`settings:agent.preserveThinkingHint`),value:h.reasoningPreserve,onChange:()=>v(`reasoningPreserve`,!h.reasoningPreserve)}),(0,X.jsx)(Q,{label:g(`settings:agent.cacheTtlLabel`),hint:g(`settings:agent.cacheTtlHint`),value:h.cacheTtl,options:[{value:`default`,label:g(`settings:agent.cacheTtlDefault`)},{value:`5m`,label:g(`settings:agent.cacheTtl5m`)},{value:`1h`,label:g(`settings:agent.cacheTtl1h`)}],onChange:e=>v(`cacheTtl`,e)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:g(`settings:agent.capsHint`)})]})]}),(0,X.jsxs)(Qa,{value:`execution`,className:`mt-0 space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(ar,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:execution.heading`)})})]}),(0,X.jsx)(Mf,{label:g(`settings:execution.maxIterationsLabel`),hint:g(`settings:execution.maxIterationsHint`),value:h.maxIterations,min:10,max:2e3,step:10,onChange:e=>v(`maxIterations`,e)}),(0,X.jsx)(Mf,{label:g(`settings:execution.autoProceedMaxIterationsLabel`),hint:g(`settings:execution.autoProceedMaxIterationsHint`),value:h.autoProceedMaxIterations,min:0,max:250,step:5,onChange:e=>v(`autoProceedMaxIterations`,e)}),(0,X.jsx)($,{label:g(`settings:execution.confirmExitLabel`),hint:g(`settings:execution.confirmExitHint`),value:h.confirmExit,onChange:()=>v(`confirmExit`,!h.confirmExit)}),(0,X.jsx)($,{label:g(`settings:execution.chimeLabel`),hint:g(`settings:execution.chimeHint`),value:h.chime,onChange:()=>v(`chime`,!h.chime)})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-warning/20 bg-warning/10 text-warning`,children:(0,X.jsx)(me,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:execution.breakerLabel`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:g(`settings:execution.breakerHint`)})]})]}),(0,X.jsx)($,{label:g(`settings:execution.breakerLabel`),hint:g(`settings:execution.breakerHint`),value:h.breakerEnabled,onChange:()=>v(`breakerEnabled`,!h.breakerEnabled)}),(0,X.jsx)(Mf,{label:g(`settings:execution.breakerTimeoutLabel`),hint:g(`settings:execution.breakerTimeoutHint`),value:h.breakerAutoKillResetMs,min:0,max:6e4,step:1e3,unit:`ms`,onChange:e=>v(`breakerAutoKillResetMs`,e)})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(On,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:execution.availabilityHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:g(`settings:execution.availabilityHint`)})]})]}),(0,X.jsx)(xf,{value:h.modelAvailabilitySchedule,candidates:_,onChange:e=>v(`modelAvailabilitySchedule`,e)})]})]}),(0,X.jsx)(Qa,{value:`fallbacks`,className:`mt-0`,children:(0,X.jsx)(Kf,{syncPref:v,candidates:_,provider:o,activeModel:s,setProvider:c,setModel:l,switchModel:d.switchModel})}),(0,X.jsx)(Qa,{value:`routing`,className:`mt-0`,children:(0,X.jsx)(ym,{syncPref:v,candidates:_})}),(0,X.jsx)(Qa,{value:`fleet`,className:`mt-0`,children:(0,X.jsx)(qf,{syncPref:v})}),(0,X.jsx)(Qa,{value:`integrations`,className:`mt-0`,children:(0,X.jsx)(ip,{syncPref:v})}),(0,X.jsx)(Qa,{value:`chimera`,className:`mt-0 space-y-6`,children:(0,X.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:(0,X.jsx)(Ff,{syncPref:v,sessionProvider:o,sessionModel:s})})}),(0,X.jsxs)(Qa,{value:`context`,className:`mt-0 space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(yt,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:context.flagsHeading`)})})]}),(0,X.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-2`,children:[(0,X.jsx)($,{label:g(`settings:context.mcpLabel`),hint:g(`settings:context.mcpHint`),value:h.featureMcp,onChange:()=>v(`featureMcp`,!h.featureMcp)}),(0,X.jsx)($,{label:g(`settings:context.pluginsLabel`),hint:g(`settings:context.pluginsHint`),value:h.featurePlugins,onChange:()=>v(`featurePlugins`,!h.featurePlugins)}),(0,X.jsx)($,{label:g(`settings:context.memoryLabel`),hint:g(`settings:context.memoryHint`),value:h.featureMemory,onChange:()=>v(`featureMemory`,!h.featureMemory)}),(0,X.jsx)($,{label:g(`settings:context.skillsLabel`),hint:g(`settings:context.skillsHint`),value:h.featureSkills,onChange:()=>v(`featureSkills`,!h.featureSkills)}),(0,X.jsx)($,{label:g(`settings:context.modelsRegistryLabel`),hint:g(`settings:context.modelsRegistryHint`),value:h.featureModelsRegistry,onChange:()=>v(`featureModelsRegistry`,!h.featureModelsRegistry)}),(0,X.jsx)($,{label:g(`settings:context.indexOnStartLabel`),hint:g(`settings:context.indexOnStartHint`),value:h.indexOnStart,onChange:()=>v(`indexOnStart`,!h.indexOnStart)})]})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(yt,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:context.compactorStrategyLabel`)})})]}),(0,X.jsx)($,{label:g(`settings:context.autoCompactLabel`),hint:g(`settings:context.autoCompactHint`),value:h.contextAutoCompact,onChange:()=>v(`contextAutoCompact`,!h.contextAutoCompact)}),(0,X.jsx)(Q,{label:g(`settings:context.compactorStrategyLabel`),hint:g(`settings:context.compactorStrategyHint`),value:h.contextStrategy,options:[{value:`hybrid`,label:g(`settings:context.compactorStrategyHybrid`)},{value:`intelligent`,label:g(`settings:context.compactorStrategyIntelligent`)},{value:`selective`,label:g(`settings:context.compactorStrategySelective`)}],onChange:e=>v(`contextStrategy`,e)}),(0,X.jsx)(Q,{label:g(`settings:context.contextModeLabel`),hint:g(`settings:context.contextModeHint`),value:h.contextMode,options:[{value:`balanced`,label:g(`settings:context.contextModeBalanced`)},{value:`frugal`,label:g(`settings:context.contextModeFrugal`)},{value:`deep`,label:g(`settings:context.contextModeDeep`)}],onChange:e=>v(`contextMode`,e)}),(0,X.jsx)(Q,{label:g(`settings:context.tokenSavingLabel`),hint:g(`settings:context.tokenSavingHint`),value:h.tokenSavingTier,options:[{value:`off`,label:g(`settings:context.tokenSavingOff`)},{value:`minimal`,label:g(`settings:context.tokenSavingMinimal`)},{value:`light`,label:g(`settings:context.tokenSavingLight`)},{value:`medium`,label:g(`settings:context.tokenSavingMedium`)},{value:`aggressive`,label:g(`settings:context.tokenSavingAggressive`)}],onChange:e=>v(`tokenSavingTier`,e)})]}),(0,X.jsx)(up,{})]}),(0,X.jsx)(Qa,{value:`logs`,className:`mt-0 space-y-6`,children:(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Wn,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:logs.heading`)})})]}),(0,X.jsx)(Q,{label:g(`settings:logs.logLevelLabel`),hint:g(`settings:logs.logLevelHint`),value:h.logLevel,options:[{value:`debug`,label:g(`settings:logs.logLevelDebug`)},{value:`info`,label:g(`settings:logs.logLevelInfo`)},{value:`warn`,label:g(`settings:logs.logLevelWarn`)},{value:`error`,label:g(`settings:logs.logLevelError`)}],onChange:e=>v(`logLevel`,e)}),(0,X.jsx)(Q,{label:g(`settings:logs.auditLevelLabel`),hint:g(`settings:logs.auditLevelHint`),value:h.auditLevel,options:[{value:`minimal`,label:g(`settings:logs.auditLevelMinimal`)},{value:`standard`,label:g(`settings:logs.auditLevelStandard`)},{value:`full`,label:g(`settings:logs.auditLevelFull`)}],onChange:e=>v(`auditLevel`,e)}),(0,X.jsx)(Q,{label:g(`settings:logs.fsAccessLabel`),hint:g(`settings:logs.fsAccessHint`),value:h.fsAccess,options:[{value:`unrestricted`,label:g(`settings:logs.fsAccessUnrestricted`)},{value:`project`,label:g(`settings:logs.fsAccessProject`)}],onChange:e=>v(`fsAccess`,e)}),(0,X.jsx)($,{label:g(`settings:logs.debugStreamLabel`),hint:g(`settings:logs.debugStreamHint`),value:h.debugStream,onChange:()=>v(`debugStream`,!h.debugStream)})]})}),(0,X.jsx)(Qa,{value:`security`,className:`mt-0`,children:(0,X.jsx)(Xm,{})}),(0,X.jsx)(Qa,{value:`display`,className:`mt-0`,children:(0,X.jsx)(Bf,{syncPref:v})})]})]})})}),(0,X.jsx)(Ri,{open:re,onOpenChange:P,children:(0,X.jsxs)(Fi,{showCloseButton:!1,children:[(0,X.jsxs)(Ni,{children:[(0,X.jsx)(Ii,{children:g(`settings:resetConfirmTitle`)}),(0,X.jsx)(Li,{children:g(`settings:resetConfirmBody`)})]}),(0,X.jsxs)(Pi,{className:`gap-2 sm:gap-0`,children:[(0,X.jsx)(J,{variant:`outline`,onClick:()=>P(!1),children:g(`settings:cancel`)}),(0,X.jsx)(J,{variant:`destructive`,onClick:ie,children:g(`settings:resetConfirmAction`)})]})]})})]})}var $m=(0,Y.lazy)(()=>B(()=>import(`./AnalyticsDashboard-D5lvkaiF.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([28,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23]))),eh=(0,Y.lazy)(()=>B(()=>import(`./AgentRosterView-PafACoYi.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([29,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,0,8,21,20,22,23,24,26,30,18,25,31]))),th=(0,Y.lazy)(()=>B(()=>import(`./ChangesView-CKLN6MLR.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([32,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,33,34]))),nh=(0,Y.lazy)(()=>B(()=>import(`./ChronicleDashboard-B8OyHq18.js`).then(e=>({default:e.ChronicleDashboard})),__vite__mapDeps([35,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8]))),rh=(0,Y.lazy)(()=>B(()=>import(`./CodeEditor-BtAkdKFs.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([36,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,20,21,19,22,23,24,33,34]))),ih=(0,Y.lazy)(()=>B(()=>import(`./CodeMap-6L-z-L7d.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([37,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,20,25]))),ah=(0,Y.lazy)(()=>B(()=>import(`./DebugDashboard-RAxaJDNV.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([38,1,2,3,4,5,6,10,11,12,13,14,15,16,17]))),oh=(0,Y.lazy)(()=>B(()=>import(`./DesignGalleryView-4kdGN1D5.js`).then(e=>({default:e.DesignGalleryView})),__vite__mapDeps([39,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26]))),sh=(0,Y.lazy)(()=>B(()=>import(`./GoalView-By18NfaK.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([40,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,18,0,8,20,21,22,23,24,25,26,41,42,27,43]))),ch=(0,Y.lazy)(()=>B(()=>import(`./KanbanView-dyfUjpC5.js`).then(e=>({default:e.KanbanView})),__vite__mapDeps([44,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,30,18,24,25,26,45]))),lh=(0,Y.lazy)(()=>B(()=>import(`./MailboxDetailView-BNyJNz-3.js`).then(e=>({default:e.MailboxDetailView})),__vite__mapDeps([46,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,22,23,24,33]))),uh=(0,Y.lazy)(()=>B(()=>import(`./OfficeMapPanel-Bo-cCLV7.js`).then(e=>({default:e.OfficeMapPanel})),__vite__mapDeps([47,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,48]))),dh=(0,Y.lazy)(()=>B(()=>import(`./RefreshDebugView-On6-vb92.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([49,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,8,23]))),fh=(0,Y.lazy)(()=>B(()=>import(`./SageTabs-D5CzIKGe.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([50,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7]))),ph=(0,Y.lazy)(()=>B(()=>import(`./RequirementIntakeView-DpnZRVDz.js`).then(e=>({default:e.RequirementIntakeView})),__vite__mapDeps([51,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,41,43]))),mh=(0,Y.lazy)(()=>B(()=>import(`./SddHub-BMedBDDs.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([52,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,41,30,45,53]))),hh=(0,Y.lazy)(()=>B(()=>import(`./SessionsDashboard-DYw9vuIv.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([54,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,55,42,27,41,43]))),gh=(0,Y.lazy)(()=>B(()=>import(`./SessionInspectView-Crs1g_xM.js`).then(e=>({default:e.SessionInspectView})),__vite__mapDeps([56,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,55,42,27,41,43]))),_h=(0,Y.lazy)(()=>B(()=>import(`./SkillDetailView-gt-Nm_ZI.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([57,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,33]))),vh=(0,Y.lazy)(()=>B(()=>import(`./TechStackView-BNen0ZpH.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([58,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,21,19,0,8,20,22,23,41,43]))),yh=(0,Y.lazy)(()=>B(()=>import(`./DeadCodeScanPanel-CDbBO9Ic.js`).then(e=>({default:e.DeadCodeScanPanel})),__vite__mapDeps([59,1,2,3,4,5,6,10,11,12,13,14,15,16,17])));function bh({sessionId:e,desktopShell:t}){let{t:n}=R(),{currentView:r,terminalOpen:i,setTerminalOpen:a}=G(fn(e=>({currentView:e.currentView,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen})));return(0,X.jsxs)(X.Fragment,{children:[r===`chat`&&(0,X.jsxs)(X.Fragment,{children:[e&&(0,X.jsx)(`div`,{className:`ws-workspace-dock-wrap shrink-0 px-3 pt-2 sm:px-4`,children:(0,X.jsx)(Tl,{})}),(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.chat`),children:(0,X.jsx)(Zd,{})})]}),r===`settings`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.settings`),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(Qm,{})})}),r===`memory`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.sageMemory`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sageMemory`)})}),children:(0,X.jsx)(fh,{})})}),r===`roster`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.agentRoster`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.agentRoster`)})}),children:(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,X.jsx)(eh,{})})})}),r===`context`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.contextDashboard`),children:(0,X.jsx)(vf,{})}),r===`setup`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.setup`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(xh,{})})})}),r===`goal`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.goal`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(sh,{onClose:()=>K(`chat`)})})})}),r===`sddhub`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.sddHub`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(mh,{})})})}),r===`kanban`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.kanban`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(ch,{onClose:()=>K(`chat`)})})})}),r===`sessions`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.sessions`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(hh,{})})})}),r===`session-inspect`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.sessionInspect`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sessionInspect`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(gh,{})})})}),r===`chronicle`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.chronicle`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(nh,{})})})}),r===`intake`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.requirementsIntake`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(ph,{})})})}),r===`debug`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.debugDashboard`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(ah,{})})})}),r===`refresh-debug`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.refreshDebug`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(dh,{})})})}),r===`files`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.editor`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.editor`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(rh,{})})})}),r===`changes`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.changes`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.changes`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(th,{className:`h-full min-h-0`})})})}),r===`mailbox`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.mailbox`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(lh,{className:`h-full min-h-0`})})})}),r===`design-gallery`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.designGallery`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(oh,{className:`h-full`})})})}),r===`skill`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.skill`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(_h,{className:`h-full`})})})}),r===`officemap`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.officeMap`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.officeMap`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(uh,{})})})}),r===`analytics`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.analytics`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)($m,{})})})}),r===`codemap`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.codemap`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.codemap`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(ih,{})})})}),r===`techstack`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.techstack`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.techstack`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(vh,{})})})}),r===`deadcode`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.deadcode`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.deadcode`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto`,children:(0,X.jsx)(yh,{})})})}),i&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.terminal`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.terminal`)})}),children:(0,X.jsx)(Sh,{desktopShell:t,onClose:()=>a(!1)})})})]})}var xh=(0,Y.lazy)(()=>B(()=>import(`./SetupScreen-Mr604Nx3.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([60,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,41,43]))),Sh=(0,Y.lazy)(()=>B(()=>import(`./TerminalPanel-BByD75cu.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([61,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,62,63])));(0,Y.lazy)(()=>B(()=>import(`./AnalyticsDashboard-D5lvkaiF.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([28,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23]))),(0,Y.lazy)(()=>B(()=>import(`./CodeMap-6L-z-L7d.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([37,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,20,25]))),(0,Y.lazy)(()=>B(()=>import(`./ChronicleDashboard-B8OyHq18.js`).then(e=>({default:e.ChronicleDashboard})),__vite__mapDeps([35,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8]))),(0,Y.lazy)(()=>B(()=>import(`./GoalView-By18NfaK.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([40,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,18,0,8,20,21,22,23,24,25,26,41,42,27,43]))),(0,Y.lazy)(()=>B(()=>import(`./ChangesView-CKLN6MLR.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([32,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,33,34])));var Ch=(0,Y.lazy)(()=>B(()=>import(`./CronJobsPanel-B-rRYNgE.js`).then(e=>({default:e.CronJobsPanel})),__vite__mapDeps([64,1,2,3,4,5,6,10,11,12,13,14,15,16,17,21,19,7,0,8,20,22,23,27])));(0,Y.lazy)(()=>B(()=>import(`./CodeEditor-BtAkdKFs.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([36,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,20,21,19,22,23,24,33,34]))),(0,Y.lazy)(()=>B(()=>import(`./DebugDashboard-RAxaJDNV.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([38,1,2,3,4,5,6,10,11,12,13,14,15,16,17]))),(0,Y.lazy)(()=>B(()=>import(`./DesignGalleryView-4kdGN1D5.js`).then(e=>({default:e.DesignGalleryView})),__vite__mapDeps([39,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26]))),(0,Y.lazy)(()=>B(()=>import(`./MailboxDetailView-BNyJNz-3.js`).then(e=>({default:e.MailboxDetailView})),__vite__mapDeps([46,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,22,23,24,33]))),(0,Y.lazy)(()=>B(()=>import(`./SageTabs-D5CzIKGe.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([50,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7]))),(0,Y.lazy)(()=>B(()=>import(`./AgentRosterView-PafACoYi.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([29,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,0,8,21,20,22,23,24,26,30,18,25,31]))),(0,Y.lazy)(()=>B(()=>import(`./KanbanView-dyfUjpC5.js`).then(e=>({default:e.KanbanView})),__vite__mapDeps([44,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,30,18,24,25,26,45]))),(0,Y.lazy)(()=>B(()=>import(`./OfficeMapPanel-Bo-cCLV7.js`).then(e=>({default:e.OfficeMapPanel})),__vite__mapDeps([47,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,48])));var wh=(0,Y.lazy)(()=>B(()=>import(`./ProcessMonitor-DPEMjjVq.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([9,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27]))),Th=(0,Y.lazy)(()=>B(()=>import(`./QueuePanel-Dx9n4NZB.js`).then(e=>({default:e.QueuePanel})),__vite__mapDeps([65,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,21,0,8,20,22,23,27])));(0,Y.lazy)(()=>B(()=>import(`./RefreshDebugView-On6-vb92.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([49,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,8,23]))),(0,Y.lazy)(()=>B(()=>import(`./SddHub-BMedBDDs.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([52,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,41,30,45,53]))),(0,Y.lazy)(()=>B(()=>import(`./SessionsDashboard-DYw9vuIv.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([54,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,55,42,27,41,43]))),(0,Y.lazy)(()=>B(()=>import(`./SetupScreen-Mr604Nx3.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([60,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,41,43]))),(0,Y.lazy)(()=>B(()=>import(`./SkillDetailView-gt-Nm_ZI.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([57,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,33]))),(0,Y.lazy)(()=>B(()=>import(`./SpecsView-CVVQSIZZ.js`).then(e=>({default:e.SpecsView})),__vite__mapDeps([53,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,41]))),(0,Y.lazy)(()=>B(()=>import(`./TechStackView-BNen0ZpH.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([58,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,21,19,0,8,20,22,23,41,43]))),(0,Y.lazy)(()=>B(()=>import(`./TerminalPanel-BByD75cu.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([61,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,62,63])));function Eh(){let{t:e}=R(),{theme:t}=Ga(),n=Vr(),{currentView:i,sidebarOpen:a,toggleSidebar:o,setSearchOpen:s,setSidebarOpen:c,setInspectorTab:l,setPaletteOpen:u,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,toggleInspector:m,setFleetMonitorOpen:h,setAgentsMonitorOpen:g,processMonitorOpen:_,setProcessMonitorOpen:v,queuePanelOpen:y,setQueuePanelOpen:b,cronJobsOpen:x,setCronJobsOpen:S,setTerminalOpen:C}=G(fn(e=>({currentView:e.currentView,sidebarOpen:e.sidebarOpen,toggleSidebar:e.toggleSidebar,setSearchOpen:e.setSearchOpen,setSidebarOpen:e.setSidebarOpen,setInspectorTab:e.setInspectorTab,setPaletteOpen:e.setPaletteOpen,setShortcutsOpen:e.setShortcutsOpen,setModelSwitcherOpen:e.setModelSwitcherOpen,setPromptLibraryOpen:e.setPromptLibraryOpen,toggleInspector:e.toggleInspector,setFleetMonitorOpen:e.setFleetMonitorOpen,setAgentsMonitorOpen:e.setAgentsMonitorOpen,processMonitorOpen:e.processMonitorOpen,setProcessMonitorOpen:e.setProcessMonitorOpen,queuePanelOpen:e.queuePanelOpen,setQueuePanelOpen:e.setQueuePanelOpen,cronJobsOpen:e.cronJobsOpen,setCronJobsOpen:e.setCronJobsOpen,setTerminalOpen:e.setTerminalOpen}))),w=r(e=>e.isLoading),T=U(e=>e.iteration),E=U(e=>e.projectName),D=U(e=>e.session?.title),O=U(e=>e.session?.id),k=G(e=>O?e.sessionNicknames[O]:void 0),A=G(e=>e.sideContextBreakdownOpen),j=G(e=>e.setSideContextBreakdownOpen);ni(e=>e.agents),Ba({setPaletteOpen:u,setSearchOpen:s,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,setFleetMonitorOpen:h,setAgentsMonitorOpen:g,setProcessMonitorOpen:v,setQueuePanelOpen:b,setCronJobsOpen:S,setTerminalOpen:C}),(0,Y.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?ki(`debug`):window.location.pathname===`/analytics`?ki(`analytics`):window.location.pathname===`/refresh-debug`&&ki(`refresh-debug`))},[]),(0,Y.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=V(W.getState().wsUrl);n&&n.send({type:`files.read`,payload:{filePath:t}})};return window.addEventListener(`wrongstack:open-file`,e),()=>window.removeEventListener(`wrongstack:open-file`,e)},[]),(0,Y.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=di.getState().openFiles.find(e=>e.path===t);if(!n)return;let r=V(W.getState().wsUrl);r&&r.send({type:`files.write`,payload:{filePath:t,content:n.content}})};return window.addEventListener(`wrongstack:save-file`,e),()=>window.removeEventListener(`wrongstack:save-file`,e)},[]);let{isMobile:M}=Rr();(0,Y.useEffect)(()=>{M&&G.getState().sidebarOpen&&c(!1)},[M,c]);let N=M&&a;return Ir(),Va(),(0,Y.useEffect)(()=>{let e=[];if(w){let t=T?` iter ${T.index}${T.max?`/${T.max}`:``}`:``;e.push(`●${t}`)}let t=k?.trim()||D?.trim(),n=E?.trim();t&&e.push(t),n&&e.push(n),e.length===0&&e.push(n||`AI Agent`);let r=e.filter(Boolean).join(` · `);return document.title=r,()=>{document.title=E||`AI Agent`}},[w,T,E,D,k]),Ha({toggleSidebar:o,setSearchOpen:s,toggleInspector:m,setInspectorTab:l}),(0,X.jsxs)(`div`,{"data-shell":n?`desktop`:`browser`,className:H(`ws-app-root flex min-h-0 min-w-0 overflow-hidden`,n&&`ws-desktop-shell`,t),children:[(0,X.jsx)(`a`,{href:`#main-content`,className:`sr-only focus:not-sr-only focus:absolute focus:top-2 focus:left-2 focus:z-[100] focus:rounded-md focus:bg-background focus:px-3 focus:py-1.5 focus:text-sm focus:font-medium focus:shadow-lg focus:ring-2 focus:ring-primary`,children:e(`activity:app.skipToContent`)}),i!==`setup`&&(0,X.jsx)(Ta,{desktopShell:n}),a&&i!==`setup`&&(0,X.jsx)(Uc,{desktopShell:n}),(0,X.jsxs)(`main`,{id:`main-content`,className:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden bg-background/70`,...N?{inert:!0}:{},children:[i!==`setup`&&(0,X.jsx)(fs,{currentView:i,projectName:E,sessionLabel:k||D||O||void 0,isLoading:w,iteration:T??null,onPalette:()=>u(!0),onSearch:()=>s(!0),onModel:()=>f(!0),onSettings:()=>Ai(`settings`)}),i!==`setup`&&(0,X.jsx)(Cs,{}),i!==`setup`&&(0,X.jsx)(ws,{}),(0,X.jsx)(bh,{sessionId:O??null,desktopShell:n})]}),i!==`setup`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.inspector`),children:(0,X.jsx)(as,{})}),O&&i===`chat`&&(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.workspaceInspector`),children:(0,X.jsx)(Dl,{sessionId:O})})]}),_&&(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.processMonitor`),children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(wh,{open:_,onClose:()=>v(!1)})})}),y&&(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.queue`),children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Th,{open:y,onClose:()=>b(!1)})})}),x&&(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.cronJobs`),children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Ch,{open:x,onClose:()=>S(!1)})})}),(0,X.jsx)(Ms,{}),A&&(0,X.jsx)(Ds,{open:A,onClose:()=>j(!1)}),(0,X.jsx)(Ss,{}),(0,X.jsx)(Ui,{}),(0,X.jsx)(Vi,{}),(0,X.jsx)(Ra,{}),(0,X.jsx)(Rs,{}),(0,X.jsx)(Ps,{}),(0,X.jsx)(Fs,{}),(0,X.jsx)(Mi,{})]})}function Dh(){return(0,X.jsx)(Z,{children:(0,X.jsx)(Wa,{defaultTheme:`system`,children:(0,X.jsx)(Eh,{})})})}Ji.createRoot(t(document.getElementById(`root`))).render((0,X.jsx)(Y.StrictMode,{children:(0,X.jsx)(Dh,{})}));export{Ya as C,qa as D,Za as E,Ga as O,Po as S,Xa as T,qs as _,fp as a,Ko as b,Qd as c,Ju as d,Ku as f,Xs as g,ml as h,vp as i,Td as l,vl as m,yp as n,Yf as o,bl as p,bp as r,Gf as s,xp as t,Xu as u,_s as v,Qa as w,Go as x,hs as y};
132
+ AWS_REGION=us-east-1`})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldDescription`)}),(0,X.jsx)(zi,{value:u,onChange:e=>d(e.target.value),placeholder:a(`settings:mcp.fieldDescriptionPlaceholder`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,id:`server-enabled`,checked:b,onChange:e=>x(e.target.checked),className:`rounded`}),(0,X.jsx)(`label`,{htmlFor:`server-enabled`,className:`text-sm`,children:a(`settings:mcp.enableServer`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,id:`server-lazy`,checked:S,onChange:e=>C(e.target.checked),className:`rounded`}),(0,X.jsxs)(`label`,{htmlFor:`server-lazy`,className:`text-sm`,children:[a(`settings:mcp.lazyConnect`),` `,(0,X.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.lazyConnectHint`)})]})]})]}),(0,X.jsxs)(Pi,{children:[(0,X.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,X.jsx)(J,{onClick:w,children:a(T?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function np({server:e,isAdded:t,onAdd:n}){let{t:r}=R();return(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),e.badge&&(0,X.jsx)(Yf,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-xs shrink-0`,children:e.transport})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description}),e.requiresEnvVars&&e.requiresEnvVars.length>0&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:r(`settings:mcp.requires`,{vars:e.requiresEnvVars.join(`, `)})})]}),(0,X.jsx)(`div`,{className:`shrink-0`,children:t?(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,disabled:!0,children:[(0,X.jsx)(a,{className:`w-4 h-4 mr-1`}),r(`settings:mcp.added`)]}):(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:n,children:[(0,X.jsx)(_,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function rp(){let e=Br(),{t}=R(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(`list`),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(),[g,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!e.client)return;let t=e=>{if(e.type===`mcp.list`){let t=e.payload;r(t.servers??[]),a(!1)}},n=e=>{if(e.type===`mcp.server.added`){let t=e.payload;r(e=>[...e.filter(e=>e.name!==t.server.name),t.server]),q.success(L.t(`settings:mcp.toastAdded`,{name:t.server.name}))}},i=e=>{if(e.type===`mcp.server.removed`){let t=e.payload;r(e=>e.filter(e=>e.name!==t.name)),q.success(L.t(`settings:mcp.toastRemoved`,{name:t.name}))}},o=e=>{if(e.type===`mcp.server.updated`){let t=e.payload;r(e=>e.map(e=>e.name===t.server.name?t.server:e))}},s=e=>{if(e.type===`mcp.server.discovered`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`,tools:t.tools}:e)),v(null),q.success(L.t(`settings:mcp.toastDiscovered`,{count:t.tools.length,name:t.name}))}},c=e=>{if(e.type===`mcp.server.sleeping`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`}:e)),v(null),q.info(L.t(`settings:mcp.toastSleeping`,{name:t.name}))}},l=e=>{if(e.type===`mcp.server.waking`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connecting`}:e))}},u=e=>{if(e.type===`mcp.server.connected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,pid:t.pid,error:void 0,lastError:void 0}:e)),v(null),q.success(L.t(`settings:mcp.toastConnected`,{name:t.name}))}},d=e=>{if(e.type===`mcp.server.reconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,error:void 0,lastError:void 0}:e)),v(null),q.success(L.t(`settings:mcp.toastReconnected`,{name:t.name}))}},f=e=>{if(e.type===`mcp.server.disconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.reason,lastError:t.reason,pid:void 0}:e)),v(null),q.warn(L.t(`settings:mcp.toastDisconnected`,{name:t.name,reason:t.reason}))}},p=e=>{if(e.type===`mcp.server.error`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.error}:e)),v(null),q.error(L.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},m=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||q.error(t.message),v(null)}},h=e.client.on(`mcp.list`,t),g=e.client.on(`mcp.server.added`,n),_=e.client.on(`mcp.server.removed`,i),y=e.client.on(`mcp.server.updated`,o),b=e.client.on(`mcp.server.discovered`,s),x=e.client.on(`mcp.server.sleeping`,c),S=e.client.on(`mcp.server.waking`,l),C=e.client.on(`mcp.server.connected`,u),w=e.client.on(`mcp.server.error`,p),T=e.client.on(`mcp.operation_result`,m),E=e.client.on(`mcp.server.reconnected`,d),D=e.client.on(`mcp.server.disconnected`,f);return a(!0),e.client?.listMcpServers(),()=>{h?.(),g?.(),_?.(),y?.(),b?.(),x?.(),S?.(),C?.(),w?.(),T?.(),E?.(),D?.()}},[e.client]);let y=(0,Y.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),b=(0,Y.useCallback)(e=>{h(Zf(e,!1)),p(!0)},[]),x=(0,Y.useCallback)(n=>{Hi({title:t(`settings:mcp.removeConfirmTitle`,{name:n}),message:t(`settings:mcp.removeConfirmBody`),confirmLabel:t(`common:action.remove`),danger:!0}).then(t=>{t&&e.client?.removeMcpServer(n)})},[e]),S=(0,Y.useCallback)(e=>{l(e),h(void 0),d(!0)},[]),C=(0,Y.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),w=(0,Y.useCallback)(t=>{v(t),e.client?.wakeMcpServer(t)},[e]),T=(0,Y.useCallback)(t=>{v(t),e.client?.sleepMcpServer(t)},[e]),E=(0,Y.useCallback)(t=>{v(t),e.client?.discoverMcpServer(t)},[e]),D=(0,Y.useCallback)(()=>{a(!0),e.client?.listMcpServers()},[e]),O=n.filter(e=>e.status===`connected`).length,k=n.filter(e=>e.status===`sleeping`).length,A=new Set(n.map(e=>e.name));return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Gn,{className:`h-5 w-5`})}),(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`settings:mcp.heading`)}),n.length>0&&(0,X.jsx)(`span`,{className:`rounded-md border border-border/60 bg-muted/30 px-2 py-1 text-xs text-muted-foreground`,children:t(`settings:mcp.summary`,{connected:O,sleeping:k,total:n.length})})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(J,{variant:`outline`,size:`sm`,onClick:D,disabled:i,children:[i?(0,X.jsx)(ln,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,X.jsxs)(J,{size:`sm`,onClick:()=>{h(void 0),p(!0)},children:[(0,X.jsx)(_,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,X.jsxs)(Ya,{value:o,onValueChange:e=>s(e),children:[(0,X.jsxs)(Xa,{children:[(0,X.jsxs)(Za,{value:`recommended`,children:[(0,X.jsx)(Ar,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,X.jsx)(Za,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,X.jsx)(Za,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,X.jsxs)(Qa,{value:`recommended`,className:`space-y-3`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.recommendedBody`)}),(0,X.jsx)(`div`,{className:`grid gap-2`,children:Xf.map(e=>(0,X.jsx)(np,{server:e,isAdded:A.has(e.name),onAdd:()=>b(e)},e.name))})]}),(0,X.jsx)(Qa,{value:`list`,className:`space-y-3`,children:i&&n.length===0?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:[(0,X.jsx)(ln,{className:`w-5 h-5 animate-spin mr-2`}),t(`settings:mcp.loadingServers`)]}):n.length===0?(0,X.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,X.jsx)(Gn,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,X.jsx)(`p`,{children:t(`settings:mcp.noServers`)}),(0,X.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.noServersHint`)})]}):n.map(e=>(0,X.jsx)(ep,{server:e,onWake:()=>w(e.name),onSleep:()=>T(e.name),onDiscover:()=>E(e.name),onEdit:()=>S(e),onRemove:()=>x(e.name)},e.name))}),(0,X.jsx)(Qa,{value:`add`,children:(0,X.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,X.jsx)(`p`,{children:t(`settings:mcp.addCustomBody`)}),(0,X.jsx)(`p`,{className:`mt-1`,children:t(`settings:mcp.addCustomBodyHint`)})]})})]}),(0,X.jsx)(tp,{open:f,onOpenChange:e=>{e||(p(!1),h(void 0))},prefillConfig:m,onSave:y}),(0,X.jsx)(tp,{open:u,onOpenChange:d,server:c,onSave:C})]})}function ip({syncPref:e}){let{t}=R(),n=z();return(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Gn,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.hqHeading`)})})]}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)($,{label:t(`settings:integrations.hqPublishingLabel`),hint:t(`settings:integrations.hqPublishingHint`),value:n.hqEnabled,onChange:()=>e(`hqEnabled`,!n.hqEnabled)}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqUrlLabel`)}),(0,X.jsx)(zi,{value:n.hqUrl,placeholder:t(`activity:integrationsSection.httpHost3499`),onChange:t=>e(`hqUrl`,t.target.value)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.hqUrlHint`)})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqTokenLabel`)}),(0,X.jsx)(zi,{type:`password`,value:n.hqToken,placeholder:t(`activity:integrationsSection.clientTokenFromWstackHq`),onChange:t=>e(`hqToken`,t.target.value)})]}),(0,X.jsx)($,{label:t(`settings:integrations.hqRawContentLabel`),hint:t(`settings:integrations.hqRawContentHint`),value:n.hqRawContent,onChange:()=>e(`hqRawContent`,!n.hqRawContent)})]})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Gn,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`activity:integrationsSection.mcpServers`)})})]}),n.featureMcp?(0,X.jsx)(rp,{}):(0,X.jsxs)(`div`,{className:`text-center py-6 text-muted-foreground`,children:[(0,X.jsx)(Gn,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,X.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.disabled`)}),(0,X.jsx)(`p`,{className:`text-xs mt-1`,children:t(`settings:integrations.disabledHint`)})]})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(cn,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.telegramHeading`)})})]}),n.tgConfigured?(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)($,{label:t(`settings:integrations.telegramSessionEndLabel`),hint:t(`settings:integrations.telegramSessionEndHint`),value:n.tgSessionEnd,onChange:()=>e(`tgSessionEnd`,!n.tgSessionEnd)}),(0,X.jsx)($,{label:t(`settings:integrations.telegramDelegateLabel`),hint:t(`settings:integrations.telegramDelegateHint`),value:n.tgDelegate,onChange:()=>e(`tgDelegate`,!n.tgDelegate)}),(0,X.jsx)($,{label:t(`settings:integrations.telegramLongToolLabel`),hint:t(`settings:integrations.telegramLongToolHint`,{ms:n.tgLongToolMs}),value:n.tgLongToolMs>0,onChange:()=>e(`tgLongToolMs`,n.tgLongToolMs>0?0:3e4)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramChangesApply`)})]}):(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramNotConfigured`)})]})]})}function ap({provider:e,catalogModels:t,currentCatalogProvider:n,isLoadingModels:r,isSwitching:i,setIsLoadingModels:a,onModelSelect:o,refreshModels:s}){let c=W(e=>e.model),{t:l}=R();return(0,X.jsx)(`div`,{className:`space-y-4`,children:e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:n?.name||e}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>{a(!0),s(e)},children:(0,X.jsx)(cr,{className:H(`h-4 w-4`,r&&`animate-spin`)})})]}),r&&!t[e]?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,X.jsx)(ln,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,X.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:l(`settings:model.loading`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Sf,{options:(t[e]||[]).map(e=>({id:e.id,label:e.name||e.id,badges:e.capabilities,detail:[e.contextWindow?`${Math.round(e.contextWindow/1e3)}k`:``,e.inputCost==null?``:`${e.inputCost}/${e.outputCost}`].filter(Boolean).join(` · `),detailHighlight:!0})),selectedId:c,onSelect:o,disabled:i,emptyMessage:l(`settings:model.notFound`)}),i?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`settings:toast.switching`)}):null]})]}):(0,X.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,X.jsx)(Rt,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,X.jsx)(`p`,{children:l(`settings:model.selectProviderFirst`)})]})})}var op=Object.freeze([{name:`wstack-prompts`,risk:`medium`,summary:`Prompt library and prompt authoring commands.`,defaultState:`active`,canDisable:!0},{name:`wstack-sync`,risk:`medium`,summary:`Cloud sync commands for prompts, skills, settings, memory, and history.`,defaultState:`active`,canDisable:!0},{name:`wstack-cloud-config-sync`,risk:`medium`,summary:`my.wrongstack.com config synchronization over the namespaced sync API.`,defaultState:`active`,canDisable:!0},{name:`wstack-chimera`,risk:`medium`,summary:`Spawns a post-session code review subagent when explicitly enabled.`,defaultState:`inactive`,canDisable:!0},{name:`wstack-auto-review`,risk:`medium`,summary:`Tracks changed files and requests bounded mid-session Chimera reviews.`,defaultState:`inactive`,canDisable:!0},{name:`wstack-skills`,risk:`medium`,summary:`Skill library, authoring, install, update, and uninstall commands.`,defaultState:`active`,canDisable:!0},{name:`@wrongstack/plug-lsp`,risk:`medium`,summary:`Language Server Protocol tools and slash commands.`,defaultState:`inactive`,canDisable:!0},{name:`telegram`,risk:`medium`,summary:`Telegram bridge for messages, approvals, and notifications.`,defaultState:`inactive`,canDisable:!0},{name:`agent-handoff`,risk:`medium`,summary:`Listens for subagent.done events and posts structured handoff notes to the project mailbox`,defaultState:`inactive`,canDisable:!0},{name:`cost-tracker`,risk:`low`,summary:`Tracks LLM token usage and estimated cost per session with per-model breakdown`,defaultState:`active`,canDisable:!0},{name:`file-watcher`,risk:`medium`,summary:`Watches project files and emits events when changes occur (add, change, delete)`,defaultState:`inactive`,canDisable:!0},{name:`git-autocommit`,risk:`high`,summary:`AI-powered git staging and conventional commit message generation`,defaultState:`inactive`,canDisable:!0},{name:`auto-doc`,risk:`medium`,summary:`Auto-generates JSDoc/TSDoc comments for functions, classes, types, and interfaces`,defaultState:`inactive`,canDisable:!0},{name:`shell-check`,risk:`low`,summary:`Runs shellcheck analysis on bash/shell scripts and surfaces issues with severity levels`,defaultState:`inactive`,canDisable:!0},{name:`cron`,risk:`medium`,summary:`Schedules recurring tasks using beforeIteration/afterIteration extension hooks`,defaultState:`inactive`,canDisable:!0},{name:`template-engine`,risk:`medium`,summary:`Expands file templates with variable substitution, conditionals, and loops`,defaultState:`inactive`,canDisable:!0},{name:`semver-bump`,risk:`high`,summary:`Conventional-commit-driven semver version bumps with changelog generation`,defaultState:`inactive`,canDisable:!0},{name:`secret-scanner`,risk:`high`,summary:`Pre-tool hook that blocks (or optionally redacts) tools whose arguments contain plaintext credentials`,defaultState:`active`,canDisable:!0},{name:`todo-tracker`,risk:`low`,summary:`Persistent, project-scoped todo backlog that survives across sessions`,defaultState:`active`,canDisable:!0},{name:`token-budget`,risk:`medium`,summary:`Enforces a per-session token budget — warns at a threshold and stops the agent loop when the limit is hit`,defaultState:`active`,canDisable:!0},{name:`lint-gate`,risk:`medium`,summary:`Pre-tool hook that runs biome/eslint on would-be file content before write or edit commits`,defaultState:`inactive`,canDisable:!0},{name:`branch-guard`,risk:`high`,summary:`Pre-tool hook that blocks commits, pushes, and merges to protected branches (default: main, master)`,defaultState:`inactive`,canDisable:!0},{name:`diff-summary`,risk:`low`,summary:`PostToolUse hook that injects a compact git diff into the LLM context after every write or edit`,defaultState:`active`,canDisable:!0},{name:`commit-validator`,risk:`medium`,summary:`PreToolUse hook that validates conventional-commit format before git_autocommit or bash git commit runs`,defaultState:`inactive`,canDisable:!0},{name:`format-on-save`,risk:`medium`,summary:`PostToolUse hook that runs biome format --write on the file after every write or edit`,defaultState:`inactive`,canDisable:!0},{name:`test-runner-gate`,risk:`medium`,summary:`PostToolUse hook that runs the relevant test file after every write or edit to a source file`,defaultState:`inactive`,canDisable:!0},{name:`import-organizer`,risk:`medium`,summary:`PostToolUse hook that re-sorts and de-duplicates imports in a file after every write or edit`,defaultState:`inactive`,canDisable:!0},{name:`knowledge-graph`,risk:`low`,summary:`Accumulates structured (subject, relation, object) facts about the project and queries them across sessions`,defaultState:`active`,canDisable:!0},{name:`todo-listener`,risk:`low`,summary:"PostToolUse hook on `todo` tool — broadcasts a status update to the project mailbox so other agents can see what this one is working on",defaultState:`inactive`,canDisable:!0},{name:`session-recap`,risk:`low`,summary:`Stop hook that posts a one-page session summary (tokens, tools, commits, last activity) to the project mailbox`,defaultState:`inactive`,canDisable:!0},{name:`spec-linker`,risk:`low`,summary:"Markdown link auditor for plugin references. PostToolUse surfaces unlinked references; PreToolUse on `write` (autoFix) wraps them in markdown links via modifiedInput.",defaultState:`inactive`,canDisable:!0},{name:`loop-breaker`,risk:`low`,summary:`Detects runaway tool-call loops (identical repeats and A-B-A-B oscillation) — warns the model, then blocks`,defaultState:`active`,canDisable:!0},{name:`path-guard`,risk:`medium`,summary:`Blocks or warns about writes, edits, and destructive shell commands touching protected paths (lockfiles, .env, .git, migrations)`,defaultState:`inactive`,canDisable:!0},{name:`process-guard`,risk:`high`,summary:`Blocks kill commands (taskkill, Stop-Process, kill, pkill, wmic) that target active WrongStack processes or their host terminals.`,defaultState:`active`,canDisable:!0},{name:`context-pins`,risk:`low`,summary:`Pin durable facts into the system prompt (pin_add/pin_remove/pin_list) — pins survive compaction and persist across sessions`,defaultState:`active`,canDisable:!0},{name:`checkpoint`,risk:`medium`,summary:`In-session file snapshots: auto-captures content before every write/edit and restores any pre-edit state on demand`,defaultState:`inactive`,canDisable:!0},{name:`error-lens`,risk:`low`,summary:`Distills failed command output into a compact digest (error line + project stack frames) and flags repeated failures`,defaultState:`active`,canDisable:!0},{name:`dep-guard`,risk:`medium`,summary:`Supervises dependency installs: blocks deny-listed packages, flags typosquat lookalikes, and optionally warns on unpinned versions`,defaultState:`active`,canDisable:!0},{name:`config-validator`,risk:`low`,summary:`Validates JSON/JSONC/YAML/TOML files right after write/edit and reports syntax problems in the same turn`,defaultState:`active`,canDisable:!0},{name:`notify-hub`,risk:`medium`,summary:`POSTs session events (stop, tool errors, budget thresholds) and ad-hoc notify_send messages to a configurable webhook`,defaultState:`inactive`,canDisable:!0},{name:`changelog-writer`,risk:`low`,summary:`Collects session work (commits, edits, manual notes) and writes Keep-a-Changelog entries under [Unreleased] on demand`,defaultState:`inactive`,canDisable:!0},{name:`injection-shield`,risk:`low`,summary:`Scans tool output (fetched pages, files) for prompt-injection patterns and warns the model that content is data, not instructions`,defaultState:`active`,canDisable:!0},{name:`llm-cache`,risk:`medium`,summary:`Caches identical provider requests and short-circuits the provider call on a hit (wrapProviderRunner). Opt-in; deterministic-only by default.`,defaultState:`inactive`,canDisable:!0},{name:`model-router`,risk:`medium`,summary:`Routes each provider call to a different model by declarative size/tool rules (wrapProviderRunner). Opt-in; dry-run by default; routes within the active provider only.`,defaultState:`inactive`,canDisable:!0},{name:`pr-drafter`,risk:`low`,summary:`Collects session work (commits, edited files, diff) and drafts a pull-request description`,defaultState:`inactive`,canDisable:!0},{name:`prompt-firewall`,risk:`high`,summary:`Scans the provider wire for credential leaks before context reaches the LLM API (wrapProviderRunner); redact/warn/block. Opt-in; redact by default.`,defaultState:`inactive`,canDisable:!0},{name:`auto-escalate`,risk:`medium`,summary:`On retryable provider errors, retries the turn with the next model in an escalation ladder (onError). Opt-in; defers to default recovery otherwise.`,defaultState:`inactive`,canDisable:!0},{name:`test-coverage-gate`,risk:`medium`,summary:`PostToolUse hook that detects test coverage regressions after source-file edits`,defaultState:`inactive`,canDisable:!0},{name:`type-gate`,risk:`medium`,summary:`PostToolUse hook that runs TypeScript type-checking after every write or edit to a source file`,defaultState:`inactive`,canDisable:!0},{name:`token-throttle`,risk:`medium`,summary:`Rolling-window tokens/min budget that delays provider calls to stay under a rate limit (wrapProviderRunner). Opt-in; delay capped by maxDelayMs.`,defaultState:`inactive`,canDisable:!0},{name:`plugin-stack-observer`,risk:`low`,summary:`Observes the wrapProviderRunner stack and exposes it to operators (plugin_stack_status) and, optionally, to the LLM (system-prompt contributor).`,defaultState:`inactive`,canDisable:!0},{name:`dependency-vulnerability-gate`,risk:`high`,summary:`PostToolUse hook that runs npm/pnpm audit after dependency installs and blocks or warns on vulnerabilities above a severity threshold`,defaultState:`inactive`,canDisable:!0},{name:`migration-planner`,risk:`low`,summary:`Builds evidence-backed migration checklists with optional Council-reviewed risk analysis`,defaultState:`inactive`,canDisable:!0},{name:`semantic-search-indexer`,risk:`low`,summary:`Builds an in-memory keyword index over project source files and answers ranked search queries`,defaultState:`inactive`,canDisable:!0},{name:`auto-i18n-extractor`,risk:`low`,summary:`Detects hardcoded user-facing strings in UI source files and suggests translation keys`,defaultState:`inactive`,canDisable:!0},{name:`doc-sync-guard`,risk:`low`,summary:`PostToolUse hook that tracks changed public source files and warns when README/docs edits omit them`,defaultState:`inactive`,canDisable:!0},{name:`api-compatibility-gate`,risk:`medium`,summary:`PostToolUse hook that detects breaking API changes (removed exports) in entry-point files after writes or edits`,defaultState:`inactive`,canDisable:!0},{name:`performance-regression-gate`,risk:`medium`,summary:`Compares benchmark results to detect performance regressions and reports metrics that increased beyond the configured threshold`,defaultState:`inactive`,canDisable:!0},{name:`test-flake-detector`,risk:`medium`,summary:`Runs a test command multiple times and reports tests that fail non-deterministically`,defaultState:`inactive`,canDisable:!0},{name:`schema-evolution-guard`,risk:`high`,summary:`PostToolUse hook that guards database/API schema changes by detecting destructive patterns in schema files`,defaultState:`inactive`,canDisable:!0},{name:`license-audit-gate`,risk:`high`,summary:`PostToolUse hook that audits dependency licenses after package-manager install/add commands and blocks disallowed licenses`,defaultState:`inactive`,canDisable:!0},{name:`accessibility-auditor`,risk:`medium`,summary:`Audits .tsx/.jsx/.html/.vue files for common accessibility issues and reports findings after writes/edits`,defaultState:`inactive`,canDisable:!0},{name:`security-hotspot-scanner`,risk:`high`,summary:`Scans source code for security anti-patterns and warns after writes/edits that introduce new hotspots`,defaultState:`inactive`,canDisable:!0},{name:`dead-code-detector`,risk:`low`,summary:`Lightweight regex-based scan for exported identifiers that appear unused anywhere in the project`,defaultState:`inactive`,canDisable:!0},{name:`duplicate-code-detector`,risk:`low`,summary:`Finds duplicated code blocks across source files using normalized-line fingerprinting`,defaultState:`inactive`,canDisable:!0},{name:`code-metrics`,risk:`low`,summary:`Computes per-file line counts, function counts, and cyclomatic-complexity-like scores`,defaultState:`inactive`,canDisable:!0},{name:`refactor-suggester`,risk:`low`,summary:`Suggests refactoring opportunities using regex-based smell detection`,defaultState:`inactive`,canDisable:!0},{name:`test-generator`,risk:`low`,summary:`Generates framework-correct test skeletons with optional host-routed LLM test authoring`,defaultState:`inactive`,canDisable:!0},{name:`release-notes-generator`,risk:`low`,summary:`Generates traceable release notes from conventional commits with optional LLM polishing`,defaultState:`inactive`,canDisable:!0},{name:`smart-rename`,risk:`medium`,summary:`Whole-word identifier rename inside a single source file`,defaultState:`inactive`,canDisable:!0},{name:`feature-flag-tracker`,risk:`low`,summary:`Scans source files for feature-flag-like expressions and reports usages`,defaultState:`inactive`,canDisable:!0},{name:`interface-contract-guard`,risk:`medium`,summary:`Checks TypeScript interfaces for visible implementers and warns about contract drift`,defaultState:`inactive`,canDisable:!0}]),sp={"wstack-chimera":`settings:context.pluginChimera`,"wstack-skills":`settings:context.pluginSkills`,"wstack-prompts":`settings:context.pluginPrompts`,"cost-tracker":`settings:context.pluginCostTracker`,telegram:`settings:context.pluginTelegram`,"knowledge-graph":`settings:context.pluginKnowledgeGraph`,"error-lens":`settings:context.pluginErrorLens`,"todo-tracker":`settings:context.pluginTodoTracker`,"secret-scanner":`settings:context.pluginSecretScanner`,"lint-gate":`settings:context.pluginLintGate`,"diff-summary":`settings:context.pluginDiffSummary`,"dep-guard":`settings:context.pluginDepGuard`,"type-gate":`settings:context.pluginTypeGate`,"injection-shield":`settings:context.pluginInjectionShield`,"prompt-firewall":`settings:context.pluginPromptFirewall`,"token-budget":`settings:context.pluginTokenBudget`,"loop-breaker":`settings:context.pluginLoopBreaker`};function cp(e){return e.replace(/^@wrongstack\//,``).replace(/^wstack-/,``).split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var lp=[...op].sort((e,t)=>cp(e.name).localeCompare(cp(t.name)));function up(){let{t:e}=R(),t=z();return(0,X.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,X.jsx)(zt,{className:`h-4 w-4 text-muted-foreground`}),e(`settings:context.pluginsPerPluginHeading`)]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:e(`settings:context.pluginsPerPluginHint`)}),lp.map(n=>{let r=sp[n.name],i=r?e(r):cp(n.name),a=t.pluginsEnabled?.[n.name]??n.defaultState===`active`;return(0,X.jsx)($,{label:i,hint:n.summary,value:a,disabled:!n.canDisable,onChange:()=>{let e={...t.pluginsEnabled,[n.name]:!a};t.set({pluginsEnabled:e})}},n.name)})]})}function dp({maskedKey:e,className:t}){let{t:n}=R(),[r,i]=(0,Y.useState)(!1),o=(0,Y.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),1500)})},[e]);return(0,X.jsxs)(`div`,{className:H(`group flex items-center gap-1.5 rounded-md border border-border/50 bg-background/50 px-2 py-1 font-mono text-xs text-muted-foreground`,t),children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate tracking-wide`,children:e}),(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-all hover:text-foreground group-hover:opacity-100 focus:opacity-100`,title:r?`Copied`:`Copy key preview`,"aria-label":n(`activity:apikeydisplay.copyApiKeyToClipboard`),children:r?(0,X.jsx)(a,{className:`h-3 w-3 text-success`}):(0,X.jsx)(Qe,{className:`h-3 w-3`})})]})}function fp(){let e=(0,Y.useRef)([]);return{setFieldRef:(0,Y.useCallback)(t=>n=>{e.current[t]=n},[]),handleKeyDown:(0,Y.useCallback)((t,n,r)=>{if(t.key===`ArrowDown`){t.preventDefault();for(let t=n+1;t<e.current.length;t++){let n=e.current[t];if(n&&!n.hasAttribute(`disabled`)&&n.getAttribute(`aria-disabled`)!==`true`){if(n.focus(),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){let e=n.value.length;n.setSelectionRange(e,e)}return}}return}if(t.key===`ArrowUp`){t.preventDefault();for(let t=n-1;t>=0;t--){let n=e.current[t];if(n&&!n.hasAttribute(`disabled`)&&n.getAttribute(`aria-disabled`)!==`true`){n.focus(),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&n.setSelectionRange(n.value.length,n.value.length);return}}return}t.key===`Enter`&&r&&(t.preventDefault(),r())},[])}}var pp={openrouter:{id:`openrouter`,name:`OpenRouter (Metered)`,family:`openai-compatible`,baseUrl:`https://openrouter.ai/api/v1`,envVars:[`OPENROUTER_API_KEY`],models:[`openai/gpt-4o`,`openai/gpt-4o-mini`,`anthropic/claude-sonnet-4-20250514`,`google/gemini-2.0-flash-001`,`meta-llama/llama-4-scout`,`deepseek/deepseek-chat`],usage:`metered-api`,docsUrl:`https://openrouter.ai/docs/quickstart`,autoDiscover:!0,requestPolicy:`openrouter`,catalog:{description:`All models via one key`,icon:`🔀`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`sk-or-...`}},"kimi-for-coding":{id:`kimi-for-coding`,name:`Kimi Code (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.kimi.com/coding/v1`,envVars:[`KIMI_API_KEY`],models:[`kimi-for-coding`,`kimi-for-coding-highspeed`],quirks:{thinkingParam:`kimi-toggle`},usage:`subscription-interactive`,docsUrl:`https://www.kimi.com/code/docs/en/third-party-tools/other-coding-agents.html`,requestPolicy:`kimi`,catalog:{description:`Personal interactive coding with the Kimi Code subscription key. Generate the API key at kimi.com/code/console.`,icon:`🌙`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`sk-...`}},moonshotai:{id:`moonshotai`,name:`Moonshot Platform (Metered)`,family:`openai-compatible`,baseUrl:`https://api.moonshot.ai/v1`,envVars:[`MOONSHOT_API_KEY`],models:[`kimi-k2.7-code`,`kimi-k2.7-code-highspeed`],quirks:{thinkingParam:`always-on`},usage:`metered-api`,docsUrl:`https://platform.kimi.ai/docs/api/overview`,requestPolicy:`kimi`,catalog:{description:`Metered Moonshot Platform API — pay-as-you-go for automation, background work, and commercial use.`,icon:`🌑`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`sk-...`}},"zai-coding-plan":{id:`zai-coding-plan`,name:`Z.AI Coding Plan (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.z.ai/api/coding/paas/v4`,envVars:[`ZHIPU_API_KEY`],models:[`glm-5.2`,`glm-5-turbo`,`glm-4.7`],quirks:{thinkingParam:`zai-glm`},usage:`subscription-interactive`,docsUrl:`https://docs.z.ai/devpack/quick-start`,requestPolicy:`zai`,catalog:{description:`Use your Z.AI Coding Plan subscription. Generate an API key from your Z.AI dashboard.`,icon:`🔷`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`...`}},zai:{id:`zai`,name:`Z.AI API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.z.ai/api/paas/v4`,envVars:[`ZHIPU_API_KEY`],models:[`glm-4.7`,`glm-5-turbo`,`glm-5.2`],quirks:{thinkingParam:`zai-glm`},usage:`metered-api`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,requestPolicy:`zai`,catalog:{description:`Pay-as-you-go Z.AI GLM access for automation and commercial use.`,icon:`🔷`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`...`,referral:{code:`JQZ7TPPRA6`,reward:`Limited-time deal for GLM Coding Plan subscription`,url:`https://z.ai/subscribe?ic=JQZ7TPPRA6`}}},minimax:{id:`minimax`,name:`MiniMax Token Plan (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.minimax.io/v1`,envVars:[`MINIMAX_API_KEY`],models:[`MiniMax-M3`,`MiniMax-M2.7`,`MiniMax-M2.5`,`MiniMax-M2`],usage:`subscription-interactive`,docsUrl:`https://platform.minimax.io/docs/api-reference/text-chat-openai`,catalog:{description:`Subscribe to one plan and unlock frontier coding, 1M context, and native multimodality.`,icon:`🔮`,color:`from-destructive/10 to-destructive/5 border-destructive/25 hover:border-destructive/45`,keyPlaceholder:`eyJ...`,referral:{code:`JrA4R9QAEn`,reward:`Friends get 10% off + Builder benefits. Referrers earn 10% cashback + community perks.`,url:`https://platform.minimax.io/subscribe/token-plan?code=JrA4R9QAEn&source=link`}}},mistral:{id:`mistral`,name:`Mistral AI API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.mistral.ai/v1`,envVars:[`MISTRAL_API_KEY`],models:[`mistral-large-latest`,`codestral-latest`,`ministral-8b-latest`],usage:`metered-api`,docsUrl:`https://docs.mistral.ai/`,catalog:{description:`Mistral Large, Codestral, and Ministral — open-weight frontier models.`,icon:`🌬️`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`Vz8d...`}},deepseek:{id:`deepseek`,name:`DeepSeek API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.deepseek.com`,envVars:[`DEEPSEEK_API_KEY`],models:[`deepseek-v4-flash`,`deepseek-v4-pro`],usage:`metered-api`,docsUrl:`https://api-docs.deepseek.com/`,requestPolicy:`deepseek`,catalog:{description:`High-performance reasoning at low cost`,icon:`🐋`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`sk-...`}},groq:{id:`groq`,name:`GroqCloud (Metered)`,family:`openai-compatible`,baseUrl:`https://api.groq.com/openai/v1`,envVars:[`GROQ_API_KEY`],models:[`llama-3.3-70b-versatile`,`llama-3.1-8b-instant`,`mixtral-8x7b-32768`,`gemma2-9b-it`],usage:`metered-api`,docsUrl:`https://console.groq.com/docs/api-reference`,requestPolicy:`groq`,catalog:{description:`Ultra-fast inference via LPU hardware — Llama, Mixtral, Gemma, and Qwen models.`,icon:`⚡`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`gsk_...`}},perplexity:{id:`perplexity`,name:`Perplexity Sonar API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.perplexity.ai`,envVars:[`PERPLEXITY_API_KEY`],models:[`sonar-pro`,`sonar`,`sonar-reasoning-pro`,`sonar-reasoning`],usage:`metered-api`,docsUrl:`https://docs.perplexity.ai/`,requestPolicy:`perplexity`,catalog:{description:`Web-augmented chat models with built-in search and citations.`,icon:`🔍`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`pplx-...`}},"alibaba-token-plan":{id:`alibaba-token-plan`,name:`Alibaba Token Plan (Personal Edition)`,family:`openai-compatible`,baseUrl:`https://dashscope.aliyuncs.com/compatible-mode/v1`,envVars:[`ALIBABA_API_KEY`,`DASHSCOPE_API_KEY`],models:[`qwen3.8-max-preview`,`qwen3.7-max`,`qwen3.7-plus`,`qwen3.6-flash`,`glm-5.2`,`deepseek-v4-pro`,`wan2.7-image`,`wan2.7-image-pro`,`happyhorse-1.1-t2v`,`happyhorse-1.1-i2v`,`happyhorse-1.1-r2v`],customModels:{"qwen3.8-max-preview":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.7-max":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.7-plus":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.6-flash":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"glm-5.2":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"deepseek-v4-pro":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!1,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"wan2.7-image":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"wan2.7-image-pro":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-t2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-i2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-r2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}}},usage:`subscription-interactive`,docsUrl:`https://www.alibabacloud.com/help/en/model-studio/token-plan-personal-overview`,requestPolicy:`alibaba`,catalog:{description:`Monthly Credits subscription for Qwen, DeepSeek, GLM, Wanx image, and HappyHorse video models.`,icon:`☁️`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`sk-...`}}};Object.keys(pp);var mp=[{id:`openai`,name:`OpenAI`,family:`openai`,envVars:[`OPENAI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://platform.openai.com/api-keys`,catalog:{description:`GPT, o-series, and Codex models`,icon:`🤖`,color:`from-success/12 to-success/5 border-success/30 hover:border-success/50`,keyPlaceholder:`sk-...`}},{id:`anthropic`,name:`Anthropic`,family:`anthropic`,envVars:[`ANTHROPIC_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://console.anthropic.com/settings/keys`,catalog:{description:`Claude model access`,icon:`🧠`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`sk-ant-...`}},{id:`google`,name:`Google`,family:`google`,envVars:[`GOOGLE_GENERATIVE_AI_API_KEY`,`GEMINI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://aistudio.google.com/apikey`,catalog:{description:`Gemini Pro, Flash, and Nano`,icon:`✨`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`AIza...`}},{id:`openai-codex`,name:`OpenAI Codex OAuth`,family:`openai-codex`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://developers.openai.com/codex/`},{id:`anthropic-oauth`,name:`Anthropic OAuth`,family:`anthropic-oauth`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://docs.anthropic.com/`},{id:`github-copilot`,name:`GitHub Copilot`,family:`github-copilot`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://docs.github.com/en/copilot`},{id:`opencode-go`,name:`OpenCode Go`,family:`openai-compatible`,baseUrl:`https://opencode.ai/zen/go/v1`,envVars:[`OPENCODE_API_KEY`],models:[],usage:`subscription-interactive`,docsUrl:`https://opencode.ai/go?ref=6VZAER87H4`,catalog:{description:`Global hosted API for 75+ LLM providers — stable access from US, EU, and Singapore`,icon:`🌍`,color:`from-success/12 to-success/5 border-success/30 hover:border-success/50`,keyPlaceholder:`oc-...`,referral:{code:`6VZAER87H4`,reward:`Support the project by signing up with this referral link`,url:`https://opencode.ai/go?ref=6VZAER87H4`}}},{id:`xai`,name:`xAI`,family:`openai-compatible`,baseUrl:`https://api.x.ai/v1`,envVars:[`XAI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://docs.x.ai/`,requestPolicy:`xai`},{id:`ai-gateway`,name:`Vercel AI Gateway`,family:`openai-compatible`,baseUrl:`https://ai-gateway.vercel.sh/v1`,discoveryOnlyBaseUrl:!0,envVars:[`AI_GATEWAY_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://vercel.com/docs/ai-gateway`,autoDiscover:!0,catalog:{description:`Every model behind one key — routed by Vercel AI Gateway`,icon:`▲`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`vck_...`}}],hp=[{id:`omniroute`,name:`OmniRoute`,family:`openai-compatible`,baseUrl:`http://localhost:20128/v1`,envVars:[],models:[],usage:`local`,quirks:{stripThinkTags:!0},autoDiscover:!0,local:{noAuth:!0,hint:`WrongStack local gateway · port 20128 · no key · auto-discovers models`}},{id:`ollama`,name:`Ollama`,family:`openai-compatible`,baseUrl:`http://localhost:11434/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://ollama.com`,local:{noAuth:!0,hint:`ollama.com · port 11434 · no key`}},{id:`vllm`,name:`vLLM`,family:`openai-compatible`,baseUrl:`http://localhost:8000/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://docs.vllm.ai`,local:{noAuth:!1,hint:`docs.vllm.ai · port 8000 · optional key`}},{id:`lmstudio`,name:`LM Studio`,family:`openai-compatible`,baseUrl:`http://localhost:1234/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://lmstudio.ai`,local:{noAuth:!1,hint:`lmstudio.ai · port 1234 · optional key`}}],gp=Object.fromEntries([...mp,...Object.values(pp),...hp].map(e=>[e.id,e]));function _p(){return hp.map(e=>{if(!e.baseUrl||!e.local)throw Error(`Local provider definition is incomplete: ${e.id}`);return{id:e.id,label:e.name,defaultBaseUrl:e.baseUrl,noAuth:e.local.noAuth,hint:e.local.hint}})}function vp(){return Object.values(gp).filter(e=>e.catalog!==void 0).map(e=>({id:e.id,name:e.name,family:e.family,description:e.catalog.description,icon:e.catalog.icon,color:e.catalog.color,keyPlaceholder:e.catalog.keyPlaceholder,...e.docsUrl?{docsUrl:e.docsUrl}:{},...e.catalog.referral?{referral:{...e.catalog.referral}}:{}}))}var yp=`openai-compatible`,bp=_p();function xp({models:e,onChange:t}){let{t:n}=R(),[r,i]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(``),g=(0,Y.useRef)(void 0),v=(0,Y.useRef)(null),y=W(e=>e.wsUrl),b=(0,Y.useCallback)(e=>{if(!e.trim()){l([]);return}d(!0);let t=V(y),n=t.on(`provider.models.search_result`,t=>{let n=t.payload;!n||n.query!==e.trim()||(l(n.matches??[]),d(!1))});t.searchProviderModels(e.trim(),8),setTimeout(()=>{n?.(),d(!1)},5e3)},[y]);(0,Y.useEffect)(()=>{if(g.current&&clearTimeout(g.current),!o.trim()){l([]);return}return g.current=setTimeout(()=>b(o),250),()=>{g.current&&clearTimeout(g.current)}},[o,b]);let x=(0,Y.useCallback)((n,r)=>{if(!n||e.some(e=>e.id===n))return;let a={id:n,name:r?.name??r?.modelId??n,...r?.maxOutput?{maxOutput:r.maxOutput}:{},capabilities:{...r?.contextWindow?{maxContext:r.contextWindow}:{},...r?.capabilities.includes(`tools`)?{tools:!0}:{},...r?.capabilities.includes(`vision`)?{vision:!0}:{},...r?.capabilities.includes(`reasoning`)?{reasoning:!0}:{}}};t([...e,a]),s(``),l([]),i(!1)},[e,t]),S=(0,Y.useCallback)(n=>{t(e.filter(e=>e.id!==n))},[e,t]),C=(0,Y.useCallback)(()=>{let e=m.trim();e&&(x(e),h(``),p(!1))},[m,x]);return(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:n(`setup:screen.custom.models`)}),e.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,X.jsxs)(`div`,{className:H(`group inline-flex items-center gap-1 px-2 py-1 text-xs rounded`,`bg-accent/10 text-accent border border-accent/20`),title:e.name&&e.name!==e.id?`${e.name}\n${e.capabilities?.maxContext?`maxContext: ${e.capabilities.maxContext}`:``}${e.maxOutput?`\nmaxOutput: ${e.maxOutput}`:``}`:void 0,children:[(0,X.jsx)(`span`,{className:`truncate max-w-[120px]`,children:e.name&&e.name!==e.id?e.name:e.id}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>S(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive`,children:(0,X.jsx)(Wt,{className:`h-3 w-3`})})]},e.id))}),r?(0,X.jsxs)(`div`,{className:`space-y-2 p-3 rounded border border-border/60 bg-muted/20`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(Ft,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(zi,{placeholder:n(`setup:screen.custom.modelSearchPlaceholder`),value:o,onChange:e=>s(e.target.value),className:`text-sm pl-8`,autoFocus:!0}),u&&(0,X.jsx)(ln,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),c.length>0&&(0,X.jsx)(`div`,{className:`space-y-1 max-h-40 overflow-y-auto`,children:c.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>x(e.modelId,e),className:H(`w-full flex items-start gap-2 p-2 text-left text-xs rounded transition-colors`,`hover:bg-accent/10 border border-transparent hover:border-accent/30`),children:[(0,X.jsx)(a,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`font-medium block truncate`,children:e.name}),(0,X.jsxs)(`span`,{className:`text-muted-foreground block`,children:[e.providerName,` · `,e.modelId,e.contextWindow?` · ${(e.contextWindow/1e3).toFixed(0)}K ctx`:``,e.maxOutput?` · ${e.maxOutput.toLocaleString()} out`:``]})]})]},`${e.providerId}\u0000${e.modelId}`))}),!u&&o.trim()&&c.length===0&&(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center py-2`,children:[n(`setup:screen.custom.noCatalogMatch`),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{p(!0),setTimeout(()=>v.current?.focus(),50)},className:`ml-1 text-accent underline underline-offset-2 hover:text-accent/80`,children:n(`setup:screen.custom.useCustomId`)})]}),f&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(zi,{ref:v,placeholder:n(`setup:screen.custom.customModelIdPlaceholder`),value:m,onChange:e=>h(e.target.value),className:`text-sm flex-1`,onKeyDown:e=>{e.key===`Enter`&&C()}}),(0,X.jsxs)(J,{type:`button`,size:`sm`,onClick:C,disabled:!m.trim(),children:[(0,X.jsx)(a,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.add`)]})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-2 pt-1`,children:(0,X.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{i(!1),s(``),l([]),p(!1),h(``)},className:`text-xs`,children:n(`setup:screen.custom.cancel`)})})]}):(0,X.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(!0),className:`text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.addModel`)]}),e.length>0&&(0,X.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.length,` `,e.length===1?n(`setup:screen.custom.modelSingular`):n(`setup:screen.custom.modelPlural`)]})]})}var Sp=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,X.jsx)(ht,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,X.jsx)(bn,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,X.jsx)(x,{className:`h-5 w-5`})}],Cp=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function wp({ws:e,savedByKind:t}){let{t:n}=R(),[r,i]=(0,Y.useState)({chatgpt:{phase:`idle`},claude:{phase:`idle`},copilot:{phase:`idle`}}),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let t=e.on(`auth.oauth.status`,e=>{if(e.type!==`auth.oauth.status`)return;let t=e.payload;i(e=>({...e,[t.kind]:{...t}})),t.phase===`success`?(q.success(t.message??L.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),c(null),o(``),u(null),f(``)):t.phase===`error`&&q.error(t.message??L.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let h=(0,Y.useCallback)(t=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),g=(0,Y.useCallback)((t,n)=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n)},[e]),v=(0,Y.useCallback)(t=>{let n=d.trim();n&&(i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n),u(null),f(``))},[e,d]),y=(0,Y.useCallback)(t=>{e.cancelOAuth(t),i(e=>({...e,[t]:{phase:`idle`}})),c(null)},[e]),b=(0,Y.useCallback)(t=>{let n=a.trim();n&&(e.submitOAuthCode(t,n),i(e=>({...e,[t]:{...e[t],phase:`exchanging`}})))},[a,e]),x=t??{};return(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-3`,children:(0,X.jsx)(`p`,{className:`text-xs leading-5 text-warning`,children:n(`settings:oauth.termsWarning`)})}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-3`,children:Sp.map(e=>{let t=r[e.kind],i=Cp.includes(t.phase),S=x[e.kind],C=S?.length??0,w=p===e.kind;return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/70 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 lg:flex-col lg:items-stretch`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,X.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subtitle})]})]}),i?(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>y(e.kind),className:`shrink-0 lg:w-full`,children:n(`common:action.cancel`)}):(0,X.jsx)(J,{size:`sm`,onClick:()=>h(e.kind),className:`shrink-0 lg:w-full`,children:n(`settings:oauth.signIn`)})]}),t.phase===`awaiting_browser`&&(0,X.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(ln,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,X.jsx)(`span`,{children:n(`settings:oauth.waitingBrowser`)})]}),t.authorizeUrl&&(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.authorizeUrl,`_blank`,`noopener,noreferrer`),children:[(0,X.jsx)(Ut,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openSignIn`)]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline`,onClick:()=>c(s===e.kind?null:e.kind),children:t.bound===!1?n(`settings:oauth.pasteLoopbackBusy`):n(`settings:oauth.pasteCantReach`)}),s===e.kind&&(0,X.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,X.jsx)(zi,{placeholder:n(`activity:oauth.httpLocalhostCallbackCode`),value:a,onChange:e=>o(e.target.value),className:`font-mono text-xs`,onKeyDown:t=>{t.key===`Enter`&&b(e.kind)}}),(0,X.jsx)(J,{size:`sm`,onClick:()=>b(e.kind),disabled:!a.trim(),children:n(`settings:oauth.submit`)})]})]})]}),t.phase===`awaiting_code`&&(0,X.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`settings:oauth.enterCode`)}),(0,X.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-widest`,children:t.userCode??`…`}),t.verificationUri&&(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,X.jsx)(Ut,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openVerification`)]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(ln,{className:`h-3.5 w-3.5 animate-spin`}),(0,X.jsx)(`span`,{children:n(`settings:oauth.waitingCode`)})]})]}),(t.phase===`exchanging`||t.phase===`fetching_models`)&&(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm`,children:[(0,X.jsx)(ln,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,X.jsx)(`span`,{children:t.phase===`exchanging`?n(`settings:oauth.exchanging`):n(`settings:oauth.fetchingModels`)})]}),t.phase===`success`&&(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-success`,children:[(0,X.jsx)(ft,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{children:t.message??n(`settings:oauth.signedIn`)})]}),t.phase===`error`&&t.message&&(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-destructive`,children:[(0,X.jsx)(ce,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{children:t.message})]}),C>0&&!i&&(0,X.jsxs)(`div`,{className:`mt-3 border-t pt-3`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>m(w?null:e.kind),className:`flex w-full items-center justify-between text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(br,{className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{children:n(`settings:oauth.accountCount`,{count:C})})]}),(0,X.jsx)(`span`,{className:`text-[10px]`,children:w?`▲`:`▼`})]}),w&&S&&(0,X.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[S.map(t=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border/60 bg-muted/20 px-2.5 py-1.5`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t.id}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[t.hasActiveKey?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-success`,children:[(0,X.jsx)(ft,{className:`h-3 w-3`}),n(`settings:oauth.active`)]}):(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n(`settings:oauth.inactive`)}),(0,X.jsxs)(J,{size:`sm`,variant:`ghost`,onClick:()=>g(e.kind,t.id),className:`h-6 px-1.5 text-[11px]`,title:n(`settings:oauth.retryLogin`),children:[(0,X.jsx)(cr,{className:`h-3 w-3 mr-0.5`}),n(`settings:oauth.retry`)]})]})]},t.id)),(0,X.jsx)(`div`,{className:`pt-1`,children:l===e.kind?(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(zi,{autoFocus:!0,placeholder:n(`settings:oauth.aliasPlaceholder`,{default:e.kind===`chatgpt`?`openai-codex-1`:`${e.kind}-2`}),value:d,onChange:e=>f(e.target.value),className:`text-xs font-mono`,onKeyDown:t=>{t.key===`Enter`&&v(e.kind)}}),(0,X.jsx)(J,{size:`sm`,onClick:()=>v(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]})]}),C===0&&!i&&(0,X.jsx)(`div`,{className:`mt-3 border-t pt-3`,children:l===e.kind?(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(zi,{autoFocus:!0,placeholder:n(`settings:oauth.aliasPlaceholder`,{default:e.kind===`chatgpt`?`openai-codex-1`:`${e.kind}-2`}),value:d,onChange:e=>f(e.target.value),className:`text-xs font-mono`,onKeyDown:t=>{t.key===`Enter`&&v(e.kind)}}),(0,X.jsx)(J,{size:`sm`,onClick:()=>v(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]},e.kind)})})]})}function Tp({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,Y.useRef)(null),{t:o}=R();return(0,Y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Enter`?(e.preventDefault(),r()):e.key===`Escape`&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,t),a.current?.focus(),()=>window.removeEventListener(`keydown`,t)},[e,r,i]),(0,X.jsx)(Ri,{open:e,onOpenChange:e=>{e||i()},children:(0,X.jsxs)(Fi,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,X.jsxs)(Ni,{children:[(0,X.jsxs)(Ii,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Le,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,X.jsx)(Li,{children:o(`settings:allowlist.body`,{count:n,provider:t})})]}),(0,X.jsx)(`div`,{className:`rounded-md bg-muted/50 border border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:o(`settings:allowlist.undoHint`)}),(0,X.jsxs)(Pi,{className:`gap-2 sm:gap-2 flex-wrap`,children:[(0,X.jsxs)(J,{variant:`outline`,size:`sm`,onClick:i,title:o(`settings:allowlist.keepTitle`),"data-action":`cancel`,children:[o(`common:action.cancel`),` `,(0,X.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`Esc`})]}),(0,X.jsxs)(J,{variant:`destructive`,size:`sm`,onClick:r,title:o(`settings:allowlist.clearTitle`),"data-action":`confirm`,children:[o(`settings:allowlist.clear`),` `,(0,X.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`↵`})]})]})]})})}function Ep(){return{inFlight:!1,last:null,picked:null}}function Dp(e){return{providerId:e.providerId,ok:e.ok,status:e.status,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.elapsedMs===void 0?{}:{elapsedMs:e.elapsedMs},...e.modelCount===void 0?{}:{modelCount:e.modelCount},...e.modelIds===void 0?{}:{modelIds:e.modelIds},...e.detail===void 0?{}:{detail:e.detail}}}function Op(e){if(e.inFlight)return{text:`Checking model endpoint...`,tone:`muted`};let t=e.last;if(!t)return{text:`Saved model list shown`,tone:`muted`};let n=t.elapsedMs===void 0?``:` (${t.elapsedMs}ms)`;switch(t.status){case`ok`:{let e=t.modelCount??t.modelIds?.length??0;return{text:`Server returned ${e} model${e===1?``:`s`}${n}`,tone:`success`}}case`unreachable`:return{text:`server unreachable${t.detail?` — ${t.detail}`:``}`,tone:`error`};case`timeout`:return{text:`timed out${t.detail?` — ${t.detail}`:``}`,tone:`error`};case`http_error`:return{text:`got${t.httpStatus===void 0?``:` HTTP ${t.httpStatus}`}${t.detail?` — ${t.detail}`:``}`,tone:`warning`};case`invalid_response`:return{text:t.detail?`unexpected response — ${t.detail}`:`unexpected response shape`,tone:`warning`};case`no_provider`:return{text:`Provider is no longer saved`,tone:`error`};case`no_base_url`:return{text:`No model endpoint configured`,tone:`warning`}}}function kp(e){return(e?.length??0)>0}function Ap(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function jp(e){return e.length>0}function Mp({ws:e,onSelect:t,onClose:n}){let{t:r}=R(),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(null),d=(0,Y.useRef)(``);(0,Y.useEffect)(()=>e.on(`provider.models.search_result`,e=>{if(e.type!==`provider.models.search_result`)return;let t=e.payload;t.query!==void 0&&t.query!==d.current||(s(t.matches??[]),l(!1))}),[e]);let f=(0,Y.useCallback)(t=>{if(!t.trim()){s([]),d.current=``;return}d.current=t,l(!0),e.searchProviderModels(t,8)},[e]);(0,Y.useEffect)(()=>(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>f(i),300),()=>{u.current&&clearTimeout(u.current)}),[i,f]);let p=(0,Y.useCallback)(e=>{let n={name:e.name,...e.description?{description:e.description}:{},...e.releaseDate?{release_date:e.releaseDate}:{},...e.contextWindow||e.maxOutput?{limit:{...e.contextWindow?{context:e.contextWindow}:{},...e.maxOutput?{output:e.maxOutput}:{}}}:{},...e.inputCost||e.outputCost?{cost:{...e.inputCost?{input:e.inputCost}:{},...e.outputCost?{output:e.outputCost}:{}}}:{},...e.capabilities.length>0?{tool_call:e.capabilities.includes(`tools`),reasoning:e.capabilities.includes(`reasoning`),...e.capabilities.includes(`vision`)?{modalities:{input:[`text`,`image`]}}:{}}:{}};t(e.modelId,n)},[t]);return(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,X.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:n,"aria-label":r(`common:action.close`)}),(0,X.jsxs)(`div`,{className:`relative max-h-[80vh] w-full max-w-xl overflow-y-auto rounded-lg border border-border bg-background p-4 shadow-lg`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings:providerModels.catalogSearchTitle`)}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(Wt,{className:`h-4 w-4`})})]}),(0,X.jsxs)(`div`,{className:`relative mb-3`,children:[(0,X.jsx)(Ft,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/60`}),(0,X.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:r(`settings:providerModels.catalogSearchPlaceholder`),className:`h-10 w-full rounded-md border border-border bg-background pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),c?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,X.jsx)(ln,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):o.length>0?(0,X.jsx)(`div`,{className:`space-y-1.5`,children:o.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>p(e),className:`block w-full rounded-md border border-border/60 p-2.5 text-left transition-colors hover:border-primary/40 hover:bg-primary/5`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`font-mono text-sm font-medium text-foreground`,children:e.modelId}),e.name!==e.modelId&&(0,X.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.name})]}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.providerName})]}),e.description&&(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:[e.contextWindow?(0,X.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e.contextWindow>=1e6?`${(e.contextWindow/1e6).toFixed(1)}M ctx`:`${Math.round(e.contextWindow/1e3)}K ctx`}):null,e.capabilities.map(e=>(0,X.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary`,children:e},e))]})]},`${e.providerId}:${e.modelId}`))}):i.trim()?(0,X.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.noResults`)}):(0,X.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.typeToSearch`)})]})]})}var Np=new Set([`__proto__`,`constructor`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]),Pp=[`text`,`image`,`audio`,`video`,`pdf`],Fp=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Ip=Ne().int().nonnegative(),Lp=Ne().finite(),Rp=y({context:Ip.optional(),output:Ip.optional(),input:Ip.optional()}),zp=y({input:Lp.optional(),output:Lp.optional(),cache_read:Lp.optional(),cache_write:Lp.optional(),cache_write_5m:Lp.optional(),cache_write_1h:Lp.optional(),context_over_200k:Lp.optional(),reasoning:Lp.optional(),input_audio:Lp.optional(),output_audio:Lp.optional()}),Bp=y({input:dr(c().min(1)).optional(),output:dr(c().min(1)).optional()}),Vp=dn([y({type:T(`toggle`)}),y({type:T(`effort`),values:dr(h(Fp)).optional()}),y({type:T(`budget_tokens`),min:Ne().optional(),max:Ne().optional()})]),Hp=e=>({message:`${e} id is a forbidden prototype-pollution key`}),Up=y({id:c().min(1).refine(e=>!Np.has(e),Hp(`Model`)),name:c().min(1),description:c().optional(),family:c().optional(),attachment:nt().optional(),reasoning:nt().optional(),reasoning_options:dn([Vp,dr(Vp)]).optional(),interleaved:dn([nt(),y({field:c().optional()})]).optional(),tool_call:nt().optional(),structured_output:nt().optional(),temperature:nt().optional(),knowledge:c().optional(),release_date:c().optional(),last_updated:c().optional(),open_weights:nt().optional(),modalities:Bp.optional(),cost:zp.optional(),limit:Rp.optional(),status:c().optional(),experimental:nt().optional()}),Wp=y({id:c().min(1).refine(e=>!Np.has(e),Hp(`Provider`)),name:c().min(1),env:dr(c()).optional(),npm:c().optional(),api:c().optional(),doc:c().optional(),models:gn(c(),Up)});gn(c(),Wp);function Gp(e,t){let n=t.limit,r=t.cost,i=t.modalities;return{id:e,name:t.name??``,description:t.description??``,family:t.family??``,limitContext:n?.context==null?``:String(n.context),limitOutput:n?.output==null?``:String(n.output),limitInput:n?.input==null?``:String(n.input),costInput:r?.input==null?``:String(r.input),costOutput:r?.output==null?``:String(r.output),inputModalities:Array.isArray(i?.input)?i.input:[],outputModalities:Array.isArray(i?.output)?i.output:[],toolCall:t.tool_call===!0,reasoning:t.reasoning===!0,temperature:t.temperature===!0,attachment:t.attachment===!0,structuredOutput:t.structured_output===!0,openWeights:t.open_weights===!0,releaseDate:t.release_date??``,lastUpdated:t.last_updated??``,knowledge:t.knowledge??``}}function Kp(e,t){let n={...t};e.name&&(n.name=e.name),e.description&&(n.description=e.description),e.family&&(n.family=e.family),e.knowledge&&(n.knowledge=e.knowledge);let r={};if(e.limitContext){let t=Number(e.limitContext);Number.isFinite(t)&&t>=0&&(r.context=t)}if(e.limitOutput){let t=Number(e.limitOutput);Number.isFinite(t)&&t>=0&&(r.output=t)}if(e.limitInput){let t=Number(e.limitInput);Number.isFinite(t)&&t>=0&&(r.input=t)}Object.keys(r).length>0&&(n.limit={...t.limit??{},...r});let i={};if(e.costInput){let t=Number(e.costInput);Number.isFinite(t)&&t>=0&&(i.input=t)}if(e.costOutput){let t=Number(e.costOutput);Number.isFinite(t)&&t>=0&&(i.output=t)}Object.keys(i).length>0&&(n.cost={...t.cost??{},...i});let a={};e.inputModalities.length>0&&(a.input=e.inputModalities),e.outputModalities.length>0&&(a.output=e.outputModalities),Object.keys(a).length>0&&(n.modalities={...t.modalities??{},...a});for(let[r,i]of[[`toolCall`,`tool_call`],[`reasoning`,`reasoning`],[`temperature`,`temperature`],[`attachment`,`attachment`],[`structuredOutput`,`structured_output`],[`openWeights`,`open_weights`]]){let a=t[i]===!0;e[r]!==a&&(n[i]=e[r])}return e.releaseDate&&(n.release_date=e.releaseDate),e.lastUpdated&&(n.last_updated=e.lastUpdated),n}var qp=[{key:`toolCall`,labelKey:`settings:modelSchema.capToolCall`},{key:`reasoning`,labelKey:`settings:modelSchema.capReasoning`},{key:`temperature`,labelKey:`settings:modelSchema.capTemperature`},{key:`attachment`,labelKey:`settings:modelSchema.capAttachment`},{key:`structuredOutput`,labelKey:`settings:modelSchema.capStructuredOutput`},{key:`openWeights`,labelKey:`settings:modelSchema.capOpenWeights`}];function Jp({providerId:e,modelId:t,initialModelsDev:n,onSave:r,onCancel:i}){let{t:o}=R(),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(()=>Gp(t,n)),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)(JSON.stringify({...n,...t?{id:t}:{}},null,2)),[h,g]=(0,Y.useState)(null),_=(0,Y.useCallback)((e,t)=>{u(n=>({...n,[e]:t}))},[]),v=(0,Y.useCallback)((e,t)=>{u(n=>{let r=n[e];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),y=(0,Y.useCallback)(()=>{let e=Kp(l,n),i=Up.safeParse({...e,id:l.id||t});if(!i.success){f(i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`));return}f([]),r(l.id||t,e)},[l,n,t,r]),b=(0,Y.useCallback)(()=>{try{let e=JSON.parse(p),n=Up.safeParse({...e,id:t||e.id});if(!n.success){g(n.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `));return}let{id:i,...a}=n.data;g(null),r(t||n.data.id,a)}catch(e){g(e instanceof Error?e.message:String(e))}},[p,t,r]),x=`h-8 w-full rounded-md border border-border bg-background px-2.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`,S=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-muted-foreground`;return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex gap-1 border-b border-border/50`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:H(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,s?`border-transparent text-muted-foreground hover:text-foreground`:`border-primary text-primary`),children:o(`settings:providerModels.tabForm`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:H(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,s?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`),children:o(`settings:providerModels.tabRawJson`)})]}),s?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:16,className:`w-full rounded-md border border-border bg-muted/20 p-2 font-mono text-xs`,spellCheck:!1}),h&&(0,X.jsx)(`p`,{className:`text-xs text-destructive`,children:h})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionIdentity`)}),!t&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-id`,children:`ID`}),(0,X.jsx)(`input`,{id:`mse-id`,className:x,value:l.id,onChange:e=>_(`id`,e.target.value),placeholder:o(`activity:modelSchema.modelId`)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-name`,children:o(`settings:providerModels.fieldName`)}),(0,X.jsx)(`input`,{id:`mse-name`,className:x,value:l.name,onChange:e=>_(`name`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-desc`,children:o(`settings:providerModels.fieldDescription`)}),(0,X.jsx)(`input`,{id:`mse-desc`,className:x,value:l.description,onChange:e=>_(`description`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-family`,children:o(`settings:providerModels.fieldFamily`)}),(0,X.jsx)(`input`,{id:`mse-family`,className:x,value:l.family,onChange:e=>_(`family`,e.target.value)})]})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionLimits`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-ctx`,children:o(`settings:providerModels.fieldContext`)}),(0,X.jsx)(`input`,{id:`mse-ctx`,type:`number`,className:x,value:l.limitContext,onChange:e=>_(`limitContext`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-out`,children:o(`settings:providerModels.fieldOutput`)}),(0,X.jsx)(`input`,{id:`mse-out`,type:`number`,className:x,value:l.limitOutput,onChange:e=>_(`limitOutput`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-inlim`,children:o(`settings:providerModels.fieldInputLimit`)}),(0,X.jsx)(`input`,{id:`mse-inlim`,type:`number`,className:x,value:l.limitInput,onChange:e=>_(`limitInput`,e.target.value)})]})]})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionPricing`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-costin`,children:o(`settings:providerModels.fieldCostInput`)}),(0,X.jsx)(`input`,{id:`mse-costin`,type:`number`,step:`0.01`,className:x,value:l.costInput,onChange:e=>_(`costInput`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-costout`,children:o(`settings:providerModels.fieldCostOutput`)}),(0,X.jsx)(`input`,{id:`mse-costout`,type:`number`,step:`0.01`,className:x,value:l.costOutput,onChange:e=>_(`costOutput`,e.target.value)})]})]})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionModalities`)}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:S,children:o(`settings:providerModels.fieldInputModalities`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Pp.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>v(`inputModalities`,e),className:H(`rounded-md border px-2 py-1 text-xs transition-colors`,l.inputModalities.includes(e)?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`in-mod-${e}`))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:S,children:o(`settings:providerModels.fieldOutputModalities`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Pp.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>v(`outputModalities`,e),className:H(`rounded-md border px-2 py-1 text-xs transition-colors`,l.outputModalities.includes(e)?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`out-mod-${e}`))})]})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionCapabilities`)}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:qp.map(({key:e,labelKey:t})=>(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 rounded border-border`,checked:l[e],onChange:t=>_(e,t.target.checked)}),o(t)]},String(e)))})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:o(`settings:providerModels.sectionDates`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-release`,children:o(`settings:providerModels.fieldReleaseDate`)}),(0,X.jsx)(`input`,{id:`mse-release`,type:`date`,className:x,value:l.releaseDate,onChange:e=>_(`releaseDate`,e.target.value)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:S,htmlFor:`mse-updated`,children:o(`settings:providerModels.fieldLastUpdated`)}),(0,X.jsx)(`input`,{id:`mse-updated`,type:`date`,className:x,value:l.lastUpdated,onChange:e=>_(`lastUpdated`,e.target.value)})]})]})]}),d.length>0&&(0,X.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-2`,children:(0,X.jsx)(`ul`,{className:`space-y-0.5 text-xs text-destructive`,children:d.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border/50 pt-3`,children:[(0,X.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,className:`h-8 gap-1.5 text-xs`,children:[(0,X.jsx)(Wt,{className:`h-3.5 w-3.5`}),o(`common:action.cancel`)]}),(0,X.jsxs)(J,{type:`button`,size:`sm`,onClick:s?b:y,className:`h-8 gap-1.5 text-xs`,children:[(0,X.jsx)(a,{className:`h-3.5 w-3.5`}),o(`common:action.save`)]})]})]})}function Yp(e,t){return e.map(e=>{let n=t?.[e],r=n?.modelsDev,i=!!(n&&(n.name||n.maxOutput||n.capabilities||r));return{modelId:e,name:r?.name??n?.name??e,modelsDev:r,maxOutput:n?.maxOutput??r?.limit?.output,capabilities:n?.capabilities,source:i?`overridden`:`catalog`}})}function Xp(e){let t=e?.limit?.context;if(typeof t==`number`&&t>0)return t>=1e6?`${(t/1e6).toFixed(1)}M`:`${Math.round(t/1e3)}K`}function Zp(e){let t=e?.cost,n=e=>typeof e==`number`&&e>=0?`$${e}`:void 0;return{input:n(t?.input),output:n(t?.output)}}function Qp(e){let t=e?.modalities;return{input:Array.isArray(t?.input)?t.input:[],output:Array.isArray(t?.output)?t.output:[]}}var $p={text:yt,image:et,audio:_e,video:ur,pdf:yt};function em({providerId:e,models:t,customModels:n,ws:r,pickedModelId:i,onPickModel:o}){let{t:s}=R(),[c,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(``),v=(0,Y.useMemo)(()=>Yp(t,n),[t,n]),y=(0,Y.useMemo)(()=>{let e=h.trim().toLowerCase();return e?v.filter(t=>t.modelId.toLowerCase().includes(e)||(t.name?.toLowerCase().includes(e)??!1)):v},[v,h]),b=(0,Y.useCallback)(t=>{r.removeCustomModel(e,t),q.success(s(`settings:providerModels.modelRemoved`,{model:t}))},[r,e,s]),x=(0,Y.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),u(null),q.success(s(`settings:providerModels.modelSaved`,{model:t}))},[r,e,s]),C=(0,Y.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),f(!1),q.success(s(`settings:providerModels.modelAdded`,{model:t}))},[r,e,s]);return(0,X.jsxs)(`div`,{className:`space-y-3`,"data-model-list-editor":e,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>f(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),s(`settings:providerModels.addFromCatalog`)]}),(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:()=>m(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),s(`settings:providerModels.addCustom`)]})]}),v.length>0&&(0,X.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/70`,children:[v.length>8&&(0,X.jsxs)(`div`,{className:`relative border-b border-border/40 bg-muted/10`,children:[(0,X.jsx)(Ft,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/60`}),(0,X.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:s(`settings:providerModels.filterPlaceholder`),"aria-label":s(`settings:providerModels.filterPlaceholder`),className:`h-8 w-full bg-transparent pl-9 pr-3 text-xs text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,X.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:(0,X.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-border/70 bg-muted/30 text-left text-[11px] uppercase tracking-wide text-muted-foreground`,children:[(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colModel`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colContext`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colOutput`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colCost`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colModalities`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colCaps`)}),(0,X.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:s(`settings:providerModels.colSource`)}),(0,X.jsx)(`th`,{className:`px-3 py-2`,"aria-label":s(`settings:providerModels.colActions`)})]})}),(0,X.jsx)(`tbody`,{children:y.map(t=>{let n=Xp(t.modelsDev),r=t.maxOutput??t.modelsDev?.limit?.output,d=typeof r==`number`?r.toLocaleString():void 0,f=Zp(t.modelsDev),p=Qp(t.modelsDev),m=t.capabilities,h=c===t.modelId;return(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsxs)(`tr`,{className:`border-b border-border/40 transition-colors hover:bg-muted/20`,children:[(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`font-mono text-xs font-medium text-foreground`,children:t.modelId}),t.name&&t.name!==t.modelId&&(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t.name})]})}),(0,X.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(l,{className:`h-3 w-3`}),n]}):(0,X.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,X.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:d?(0,X.jsx)(`span`,{children:d}):(0,X.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,X.jsx)(`td`,{className:`px-3 py-2 text-xs`,children:f.input||f.output?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,X.jsx)(At,{className:`h-3 w-3`}),f.input&&f.output?`${f.input}/${f.output}`:f.input??f.output]}):(0,X.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[p.input.map(e=>{let t=$p[e]??yt;return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-primary/10 px-1 py-0.5 text-[10px] text-primary`,title:`input: ${e}`,children:[(0,X.jsx)(t,{className:`h-2.5 w-2.5`}),e]},`in-${e}`)}),p.output.map(e=>(0,X.jsx)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-secondary/20 px-1 py-0.5 text-[10px] text-secondary-foreground`,title:`output: ${e}`,children:e},`out-${e}`))]})}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[m?.tools&&(0,X.jsx)(Xt,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":s(`activity:modelListEditor.tools`)}),m?.reasoning&&(0,X.jsx)(Nt,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":s(`activity:modelListEditor.reasoning`)}),m?.vision&&(0,X.jsx)(xn,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":s(`activity:modelListEditor.vision`)})]})}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsx)(`span`,{className:H(`inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium`,t.source===`custom`&&`bg-warning/10 text-warning`,t.source===`catalog`&&`bg-info/10 text-info`,t.source===`overridden`&&`bg-primary/10 text-primary`),children:t.source})}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[o&&(t.modelId===i?(0,X.jsx)(`span`,{className:`inline-flex items-center rounded p-1 text-primary`,title:s(`settings:providerModels.usingModel`,{model:t.modelId}),role:`img`,"aria-label":s(`settings:providerModels.usingModel`,{model:t.modelId}),children:(0,X.jsx)(a,{className:`h-3.5 w-3.5`})}):(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(e,t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":s(`settings:providerModels.useModel`,{model:t.modelId}),title:s(`settings:providerModels.useModel`,{model:t.modelId}),children:(0,X.jsx)(a,{className:`h-3.5 w-3.5`})})),(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(h?null:t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":s(`settings:providerModels.editModel`,{model:t.modelId}),children:(0,X.jsx)(S,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>b(t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,"aria-label":s(`settings:providerModels.removeModel`,{model:t.modelId}),children:(0,X.jsx)(hn,{className:`h-3.5 w-3.5`})})]})})]}),h&&(0,X.jsx)(`tr`,{className:`border-b border-border/40 bg-muted/10`,children:(0,X.jsx)(`td`,{colSpan:8,className:`p-3`,children:(0,X.jsx)(Jp,{providerId:e,modelId:t.modelId,initialModelsDev:t.modelsDev??{},onSave:x,onCancel:()=>u(null)})})},`${t.modelId}-edit`)]},t.modelId)})})]})})]}),v.length===0&&(0,X.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/50 p-8 text-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`settings:providerModels.emptyState`)})}),d&&(0,X.jsx)(Mp,{ws:r,onSelect:C,onClose:()=>f(!1)}),p&&(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,X.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:()=>m(!1),"aria-label":s(`common:action.close`)}),(0,X.jsxs)(`div`,{className:`relative max-h-[80vh] w-full max-w-2xl overflow-y-auto rounded-lg border border-border bg-background p-4 shadow-lg`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:s(`settings:providerModels.addCustomTitle`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(!1),className:`text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(Wt,{className:`h-4 w-4`})})]}),(0,X.jsx)(Jp,{providerId:e,modelId:``,initialModelsDev:{},onSave:x,onCancel:()=>m(!1)})]})]})]})}function tm(e){return e.previousModels.length===0?{kind:`skip`}:e.onUndoClear?{kind:`callback`,providerId:e.providerId,previousModels:e.previousModels}:{kind:`ws-default`,providerId:e.providerId,previousModels:e.previousModels}}var nm=3e3;function rm({providerId:e,savedPickedModelId:t,savedModels:n,savedCustomModels:r,ws:i,onPickModel:a,onClearModels:o,onUndoClear:s}){let[c,l]=(0,Y.useState)(()=>Ep()),{t:u}=R(),[d,f]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>i.on(`provider.probe`,t=>{t.type===`provider.probe`&&t.payload.providerId===e&&l(e=>({...e,inFlight:!1,last:Dp(t.payload)}))}),[i,e]);let p=(0,Y.useCallback)(()=>{l(e=>({...e,inFlight:!0})),i.probeProvider(e,nm)},[i,e]),m=(0,Y.useCallback)((e,t)=>{l(e=>({...e,picked:t})),a?.(e,t)},[a]),h=(0,Y.useCallback)(()=>{f(!0)},[]),g=(0,Y.useCallback)(()=>{f(!1)},[]),_=(0,Y.useCallback)(()=>{f(!1);let t=n?[...n]:[];l(e=>({...e,picked:null,last:null})),o?o(e):i.clearProviderModels(e),jp(t)&&q.undoable(Ap(e,t.length),()=>{let n=tm({providerId:e,previousModels:t,onUndoClear:s});switch(n.kind){case`skip`:return;case`callback`:s?.(n.providerId,n.previousModels);return;case`ws-default`:i.undoProviderClear(n.providerId,n.previousModels);return}})},[o,s,i,e,n]),v=(0,Y.useMemo)(()=>c.picked??t??n?.[0]??``,[c.picked,t,n]),y=(0,Y.useMemo)(()=>Op(c),[c]),b=(0,Y.useMemo)(()=>kp(n),[n]);return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,"data-provider-models-panel":e,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,X.jsx)(ir,{className:`h-3.5 w-3.5`}),u(`activity:providerModels.allowlistTitle`)]}),n&&n.length>0&&(0,X.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground`,children:u(`activity:providerModels.modelCount`,{count:n.length})})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u(`activity:providerModels.using`)}),v?(0,X.jsx)(`span`,{className:`max-w-full truncate rounded-md bg-primary/10 px-2 py-0.5 font-mono text-xs text-primary`,children:v}):(0,X.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:u(`activity:providerModels.noModelPicked`)})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:justify-end`,children:[(0,X.jsxs)(J,{variant:`outline`,size:`sm`,onClick:p,disabled:c.inFlight,"aria-label":u(`activity:providerModels.refreshAria`,{provider:e}),className:`h-8 px-2 text-xs`,children:[c.inFlight?(0,X.jsx)(ln,{className:`h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(cr,{className:`h-3.5 w-3.5`}),c.inFlight?u(`activity:providerModels.probing`):u(`activity:providerModels.refresh`)]}),b&&(0,X.jsx)(J,{variant:`ghost`,size:`sm`,onClick:h,"aria-label":u(`activity:providerModels.clearAllowlistAria`,{provider:e}),"data-action":`clear-models`,className:`h-8 px-2 text-xs`,children:u(`activity:providerModels.clearAllowlist`)})]})]}),(0,X.jsx)(im,{formatted:y}),(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(em,{providerId:e,models:n??[],customModels:r,ws:i,pickedModelId:v??void 0,onPickModel:m})}),(0,X.jsx)(Tp,{open:d,providerId:e,modelCount:n?.length??0,onConfirm:_,onCancel:g})]})}function im({formatted:e}){let t=e.tone===`success`?`text-success`:e.tone===`warning`?`text-warning`:e.tone===`error`?`text-destructive`:`text-muted-foreground`,n=e.tone===`success`?`bg-success`:e.tone===`warning`?`bg-warning`:e.tone===`error`?`bg-destructive`:`bg-muted-foreground/60`;return(0,X.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs ${t}`,"data-probe-tone":e.tone,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${n}`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}var am=[`anthropic`,`openai`,`google`,`openai-compatible`];function om({activeProvider:e,catalogProviders:t,isLoadingCatalog:n,savedProviders:r,isLoadingSaved:i,providerTab:a,setProviderTab:o,onSelectProvider:s,onAddKey:c,onDeleteKey:l,onSetActiveKey:d,onAddProvider:f,onRemoveProvider:p,onPickProviderModel:m,ws:h,catalogQuery:g,setCatalogQuery:v}){let{t:y}=R(),[b,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(``),[w,T]=(0,Y.useState)(``),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(``),[M,N]=(0,Y.useState)(`openai-compatible`),[ee,te]=(0,Y.useState)(``),[ne,re]=(0,Y.useState)(``),[P,ie]=(0,Y.useState)([]),ae=fp(),oe=fp(),se=(0,Y.useCallback)(e=>{!S.trim()||!w.trim()||(c(e,S.trim(),w.trim()),C(``),T(``),x(null))},[c,S,w]),F=(0,Y.useCallback)(()=>{A.trim()&&(f(A.trim(),M,ee||void 0,ne||void 0,P.length>0?P.map(e=>e.id):void 0,P.length>0?Object.fromEntries(P.filter(e=>e.name||e.maxOutput||e.capabilities&&Object.keys(e.capabilities).length>0).map(e=>[e.id,{...e.name&&e.name!==e.id?{name:e.name}:{},...e.maxOutput?{maxOutput:e.maxOutput}:{},...e.capabilities&&Object.keys(e.capabilities).length>0?{capabilities:e.capabilities}:{}}])):void 0),j(``),N(`openai-compatible`),te(``),re(``),ie([]),k(!1))},[f,A,M,ee,ne,P]),I=(0,Y.useCallback)(e=>{j(e.id),N(yp),te(e.defaultBaseUrl),e.noAuth&&re(``),ie([])},[]),[le,ue]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(``),[pe,me]=(0,Y.useState)(!1),[he,ge]=(0,Y.useState)({}),_e=(0,Y.useMemo)(()=>new Set(r.map(e=>e.id)),[r]),ve=(0,Y.useMemo)(()=>({keys:r.reduce((e,t)=>e+t.apiKeys.length,0),activeKeys:r.reduce((e,t)=>e+t.apiKeys.filter(e=>e.isActive).length,0),models:r.reduce((e,t)=>e+(t.models?.length??0),0)}),[r]);(0,Y.useEffect)(()=>{let e=h.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;t.status===`no_base_url`||t.status===`no_provider`||ge(e=>({...e,[t.providerId]:{ok:t.ok,status:t.status,detail:t.detail}}))});return()=>e?.()},[h]);let ye=(0,Y.useCallback)(e=>{let t=de.trim();t&&(_e.has(e.id)?c(e.id,`default`,t):f(e.id,e.family,e.apiBase??void 0,t),fe(``),ue(null),me(!1),q.success(y(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>h.probeProvider(e.id,6e3),700))},[de,_e,c,f,h]),L=g.trim()?t.filter(e=>{let t=g.trim().toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.family.toLowerCase().includes(t)}):t,be=L.reduce((e,t)=>(e[t.family]||(e[t.family]=[]),e[t.family]?.push(t),e),{});return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,X.jsx)(lr,{className:`h-4 w-4 text-muted-foreground`}),y(`settings:provider.subscriptionHeading`)]}),(0,X.jsx)(wp,{ws:h,savedByKind:{chatgpt:r.filter(e=>e.id===`openai-codex`||e.id.startsWith(`openai-codex-`)).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)})),claude:r.filter(e=>e.id===`anthropic-oauth`||e.id.startsWith(`anthropic-oauth-`)).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)})),copilot:r.filter(e=>e.id===`github-copilot`).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)}))}})]}),(0,X.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold mb-1 flex items-center gap-2`,children:[(0,X.jsx)(u,{className:`h-4 w-4 text-muted-foreground`}),y(`settings:provider.apiKeysHeading`)]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:y(`settings:provider.apiKeysBody`)})]}),(0,X.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,X.jsxs)(J,{variant:a===`catalog`?`default`:`outline`,size:`sm`,onClick:()=>o(`catalog`),children:[(0,X.jsx)(u,{className:`h-4 w-4 mr-1`}),y(`settings:provider.tabCatalog`)]}),(0,X.jsxs)(J,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>o(`saved`),children:[(0,X.jsx)(lr,{className:`h-4 w-4 mr-1`}),y(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(zi,{placeholder:y(`settings:provider.searchPlaceholder`,{count:t.length}),value:g,onChange:e=>v(e.target.value),className:`text-sm`}),n&&t.length===0?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,X.jsx)(ln,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,X.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:y(`settings:provider.loadingCatalog`)})]}):L.length===0&&g?(0,X.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:y(`settings:provider.noMatch`,{query:g})}):am.map(t=>{let n=be[t];return n?.length?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider`,children:t}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:n.map(t=>{let n=he[t.id],r=e===t.id;return(0,X.jsxs)(`div`,{className:H(`rounded-lg border transition-all`,r?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border`),children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>s(t.id),className:H(`flex w-full flex-col items-start p-3 text-left rounded-lg`,!r&&`hover:bg-muted`),children:[(0,X.jsxs)(`div`,{className:`flex w-full justify-between items-start`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:t.name}),(0,X.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.hasApiKey&&(0,X.jsxs)(`span`,{className:`text-xs bg-success/10 text-success px-2 py-0.5 rounded`,children:[(0,X.jsx)(lr,{className:`h-3 w-3 inline mr-1`}),y(`settings:provider.configured`)]}),n&&(0,X.jsxs)(`span`,{className:H(`text-xs px-2 py-0.5 rounded inline-flex items-center gap-1`,n.ok?`bg-success/10 text-success`:`bg-destructive/10 text-destructive`),title:n.detail??n.status,children:[n.ok?(0,X.jsx)(ft,{className:`h-3 w-3`}):(0,X.jsx)(ce,{className:`h-3 w-3`}),n.ok?y(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:y(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,X.jsx)(ft,{className:`h-4 w-4 text-primary`})]})]}),(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[y(`settings:provider.modelCount`,{count:t.modelCount}),t.apiBase&&` · ${t.apiBase}`]})]}),r&&!t.hasApiKey&&(0,X.jsx)(`div`,{className:`px-3 pb-3 -mt-1 space-y-2`,children:le===t.id?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(zi,{autoFocus:!0,type:pe?`text`:`password`,placeholder:y(`settings:provider.keyPlaceholder`,{name:t.name}),value:de,onChange:e=>fe(e.target.value),className:`text-sm`,onKeyDown:e=>{e.key===`Enter`&&ye(t)}}),(0,X.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>me(e=>!e),children:pe?(0,X.jsx)(rr,{className:`h-4 w-4`}):(0,X.jsx)(xn,{className:`h-4 w-4`})}),(0,X.jsx)(J,{size:`sm`,onClick:()=>ye(t),disabled:!de.trim(),children:y(`common:action.save`)})]}),t.envVars[0]&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:y(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>{ue(t.id),fe(``)},children:[(0,X.jsx)(lr,{className:`h-3.5 w-3.5 mr-1`}),y(`settings:provider.addApiKey`)]})})]},t.id)})})]},t):null})]}),a===`saved`&&(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:y(`settings:provider.manageKeys`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,X.jsx)(Gn,{className:`h-3.5 w-3.5`}),y(`settings:provider.savedProviderCount`,{count:r.length})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,X.jsx)(lr,{className:`h-3.5 w-3.5`}),y(`settings:provider.keyCount`,{count:ve.keys})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,X.jsx)(Ot,{className:`h-3.5 w-3.5`}),y(`settings:provider.activeKeyCount`,{count:ve.activeKeys})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,X.jsx)(Rt,{className:`h-3.5 w-3.5`}),y(`settings:provider.modelCount`,{count:ve.models})]})]})]}),(0,X.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>k(!O),children:[(0,X.jsx)(_,{className:`h-4 w-4 mr-1`}),y(`settings:provider.addProvider`)]})]}),O&&(0,X.jsxs)(`div`,{className:`p-4 border rounded-lg space-y-3 bg-muted/50`,children:[(0,X.jsx)(`h4`,{className:`font-medium`,children:y(`settings:provider.addCustomHeading`)}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:y(`settings:provider.localServers`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:bp.map(e=>(0,X.jsx)(J,{type:`button`,size:`sm`,variant:A===e.id?`default`:`outline`,onClick:()=>I(e),title:e.hint,children:e.label},e.id))})]}),(0,X.jsx)(zi,{placeholder:y(`settings:provider.providerIdPlaceholder`),value:A,onChange:e=>j(e.target.value),ref:ae.setFieldRef(0),onKeyDown:e=>ae.handleKeyDown(e,0)}),(0,X.jsxs)(`select`,{className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:M,onChange:e=>N(e.target.value),ref:ae.setFieldRef(1),onKeyDown:e=>ae.handleKeyDown(e,1),children:[(0,X.jsx)(`option`,{value:`anthropic`,children:y(`activity:provider.anthropic`)}),(0,X.jsx)(`option`,{value:`openai`,children:y(`activity:provider.openai`)}),(0,X.jsx)(`option`,{value:`openai-compatible`,children:y(`activity:provider.openaiCompatible`)}),(0,X.jsx)(`option`,{value:`google`,children:y(`activity:provider.google`)})]}),(0,X.jsx)(zi,{placeholder:y(`activity:provider.baseUrlOptionalEGHttpLocalhost11434V1`),value:ee,onChange:e=>te(e.target.value),ref:ae.setFieldRef(2),onKeyDown:e=>ae.handleKeyDown(e,2)}),(0,X.jsx)(zi,{type:`password`,placeholder:y(`settings:provider.apiKeyOptionalPlaceholder`),value:ne,onChange:e=>re(e.target.value),ref:ae.setFieldRef(3),onKeyDown:e=>ae.handleKeyDown(e,3)}),(0,X.jsx)(xp,{models:P,onChange:ie}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(J,{size:`sm`,onClick:F,disabled:!A.trim(),ref:ae.setFieldRef(4),onKeyDown:e=>ae.handleKeyDown(e,4,F),children:y(`common:action.add`)}),(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>k(!1),ref:ae.setFieldRef(5),onKeyDown:e=>ae.handleKeyDown(e,5),children:y(`common:action.cancel`)})]})]}),i?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,X.jsx)(ln,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r.length===0?(0,X.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,X.jsx)(lr,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,X.jsx)(`p`,{children:y(`settings:provider.noSaved`)}),(0,X.jsx)(`p`,{className:`text-sm`,children:y(`settings:provider.noSavedHint`)})]}):r.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/80 bg-card/70 p-4 shadow-sm shadow-black/[0.02]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h4`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-foreground`,children:e.id}),e.family&&(0,X.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:e.family}),e.apiKeys.some(e=>e.isActive)&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:[(0,X.jsx)(Ot,{className:`h-3 w-3`}),y(`settings:provider.active`)]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[e.baseUrl&&(0,X.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,X.jsx)(u,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.baseUrl})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,X.jsx)(Rt,{className:`h-3.5 w-3.5`}),y(`settings:provider.modelCount`,{count:e.models?.length??0})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,X.jsx)(lr,{className:`h-3.5 w-3.5`}),y(`settings:provider.keyCount`,{count:e.apiKeys.length})]})]})]}),(0,X.jsx)(`div`,{className:`flex gap-2 sm:justify-end`,children:(0,X.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>p(e.id),"aria-label":`Remove provider ${e.id}`,title:`Remove provider ${e.id}`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,X.jsx)(hn,{className:`h-4 w-4 text-destructive`})})})]}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.85fr)]`,children:[(0,X.jsx)(rm,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,savedCustomModels:e.customModels,ws:h,onPickModel:m}),(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold`,children:y(`settings:provider.apiKeysLabel`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:y(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,X.jsxs)(J,{size:`sm`,variant:`ghost`,onClick:()=>x(b===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),y(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!b&&(0,X.jsx)(`p`,{className:`mt-3 rounded-md border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:y(`settings:provider.noKeys`)}),e.apiKeys.length>0&&(0,X.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.apiKeys.map(t=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/70 bg-muted/20 p-2.5 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background text-muted-foreground`,children:(0,X.jsx)(lr,{className:`h-3.5 w-3.5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),t.isActive&&(0,X.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:y(`settings:provider.active`)})]}),(0,X.jsx)(`div`,{className:`mt-0.5`,children:(0,X.jsx)(dp,{maskedKey:t.maskedKey})})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!t.isActive&&(0,X.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>d(e.id,t.label),className:`h-8 px-2 text-xs`,children:y(`settings:provider.setActive`)}),(0,X.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>l(e.id,t.label),"aria-label":`Delete key ${t.label}`,title:`Delete key ${t.label}`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,X.jsx)(hn,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),b===e.id&&(0,X.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-border/70 bg-background p-3`,children:[(0,X.jsx)(zi,{placeholder:y(`settings:provider.keyLabelPlaceholder`),value:S,onChange:e=>C(e.target.value),ref:oe.setFieldRef(0),onKeyDown:e=>oe.handleKeyDown(e,0)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(zi,{type:E?`text`:`password`,placeholder:y(`settings:provider.apiKeyPlaceholder`),value:w,onChange:e=>T(e.target.value),ref:oe.setFieldRef(1),onKeyDown:e=>oe.handleKeyDown(e,1)}),(0,X.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>D(!E),children:E?(0,X.jsx)(rr,{className:`h-4 w-4`}):(0,X.jsx)(xn,{className:`h-4 w-4`})})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(J,{size:`sm`,onClick:()=>se(e.id),disabled:!S.trim()||!w.trim(),ref:oe.setFieldRef(2),onKeyDown:t=>oe.handleKeyDown(t,2,()=>se(e.id)),children:y(`settings:provider.saveKey`)}),(0,X.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{x(null),C(``),T(``)},ref:oe.setFieldRef(3),onKeyDown:e=>oe.handleKeyDown(e,3),children:y(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var sm=Object.entries({discovery:[[`explore`,`Explore`],[`search`,`Search`],[`research`,`Research`]],planning:[[`analyst`,`Analyst`],[`planner`,`Planner`],[`architect`,`Architect`],[`critic`,`Critic`],[`refactor-planner`,`Refactor Planner`]],build:[[`executor`,`Executor`],[`refactor`,`Refactor`],[`simplifier`,`Simplifier`],[`migration`,`Migration`],[`vision`,`Vision`],[`debugger`,`Debugger`],[`tracer`,`Tracer`],[`concurrency`,`Concurrency`]],verify:[[`realtime`,`Realtime`],[`resilience-engineer`,`Resilience Engineer`],[`chaos-engineer`,`Chaos Engineer`],[`verifier`,`Verifier`],[`test`,`Test`],[`e2e`,`E2E`],[`browser`,`Browser`],[`performance`,`Performance`],[`chaos`,`Chaos`],[`security-scanner`,`Security Scanner`],[`bug-hunter`,`Bug Hunter`],[`audit-log`,`Audit Log`]],review:[[`threat-modeler`,`Threat Modeler`],[`secure-coding-coach`,`Secure Coding Coach`],[`compliance-auditor`,`Compliance Auditor`],[`privacy-engineer`,`Privacy Engineer`],[`reviewer`,`Reviewer`],[`code-reviewer`,`Code Reviewer`],[`security-reviewer`,`Security Reviewer`],[`accessibility`,`Accessibility`],[`compliance`,`Compliance`]],domain:[[`android`,`Android`],[`desktop`,`Desktop`],[`distributed-systems`,`Distributed Systems`],[`database`,`Database`],[`api`,`API`],[`auth`,`Auth`],[`data`,`Data`],[`frontend`,`Frontend`],[`backend`,`Backend`],[`designer`,`Designer`],[`ios`,`iOS`],[`payments`,`Payments`],[`messaging`,`Messaging`],[`search-relevance`,`Search Relevance`],[`storage`,`Storage`],[`ml-engineer`,`ML Engineer`],[`data-governance`,`Data Governance`]],knowledge:[[`document`,`Document`],[`uml`,`UML`],[`i18n`,`I18n`],[`prompt`,`Prompt`]],delivery:[[`platform-engineer`,`Platform Engineer`],[`git`,`Git`],[`release`,`Release`],[`devops`,`DevOps`],[`observability`,`Observability`],[`dependency`,`Dependency`]],meta:[[`skill-manage`,`Skill Manager`],[`self-improving`,`Self-Improving`],[`context`,`Context`],[`cost`,`Cost`],[`tech-stack`,`Tech Stack Validator`],[`plugin-author`,`Plugin Author`],[`tool-author`,`Tool Author`],[`prompt-evaluator`,`Prompt Evaluator`],[`benchmark-engineer`,`Benchmark Engineer`],[`memory-curator`,`Memory Curator`],[`fleet-coordinator`,`Fleet Coordinator`]]}).map(([e,t])=>({phase:e,label:`${e.charAt(0).toUpperCase()}${e.slice(1)}`,roles:t.map(([e,t])=>({role:e,name:t}))})),cm=sm.map(e=>e.phase),lm=sm.flatMap(e=>[...e.roles]),um=lm.map(e=>e.role),dm=[`*`,...cm,...um];function fm(e){if(e===`*`)return`Default (*)`;let t=sm.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=lm.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var pm=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],mm=[{value:``,label:`effort: inherit`},{value:`none`,label:`effort: none`},{value:`minimal`,label:`effort: minimal`},{value:`low`,label:`effort: low`},{value:`medium`,label:`effort: medium`},{value:`high`,label:`effort: high`},{value:`xhigh`,label:`effort: xhigh`},{value:`max`,label:`effort: max`}],hm=[{value:``,label:`preserve: inherit`},{value:`on`,label:`preserve: on`},{value:`off`,label:`preserve: off`}],gm=new Set(dm);function _m(e,t,n){let r={};return e&&(r.mode=e),t&&(r.effort=t),n&&(r.preserve=n===`on`),Object.keys(r).length>0?{reasoning:r}:void 0}function vm(e){return e?[e.mode?`mode:${e.mode}`:``,e.effort?`effort:${e.effort}`:``,e.preserve===void 0?``:`preserve:${e.preserve?`on`:`off`}`].filter(Boolean):[]}function ym({syncPref:e,candidates:t}){let n=z(),{t:r}=R(),[i,a]=(0,Y.useState)(`*`),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),m=(0,Y.useCallback)(t=>e(`modelMatrix`,t),[e]),h=(0,Y.useCallback)(()=>{let e=i.trim(),t=o.trim(),r=_m(c,u,f);if(!e||!t&&!r)return;let a=t?n.fallbackProfiles[t]?{fallbackProfile:t}:t.includes(`/`)?{provider:t.slice(0,t.indexOf(`/`)),model:t.slice(t.indexOf(`/`)+1)}:{model:t}:{},h=n.modelMatrix[e]?.modelRuntime;r?a.modelRuntime=r:h&&(a.modelRuntime=h),m({...n.modelMatrix,[e]:a}),s(``),l(``),d(``),p(``)},[n.fallbackProfiles,n.modelMatrix,i,f,u,c,o,m]),g=(0,Y.useCallback)(e=>{let{[e]:t,...r}=n.modelMatrix;m(r)},[n.modelMatrix,m]),_=(0,Y.useCallback)((e,t,r)=>{let i={...n.modelMatrix},a={...i[e]??{}},o={...a.modelRuntime??{}},s={...o.reasoning??{}};t===`mode`?r?s.mode=r:delete s.mode:t===`effort`?r?s.effort=r:delete s.effort:r?s.preserve=r===`on`:delete s.preserve,Object.keys(s).length>0?o.reasoning=s:delete o.reasoning,Object.keys(o).length>0?a.modelRuntime=o:delete a.modelRuntime,a.model||a.fallbackProfile||a.modelRuntime?i[e]=a:delete i[e],m(i)},[n.modelMatrix,m]),v=e=>{let t=e.provider&&e.model?`${e.provider}/${e.model}`:e.model,n=e.modelRuntime?.reasoning;return[t??(!e.fallbackProfile&&n?r(`settings:agent.leaderModel`):``),e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...vm(n)].filter(Boolean).join(` + `)},y=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!gm.has(e)))).sort((e,t)=>e.localeCompare(t));return(0,X.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,X.jsx)($t,{className:`h-4 w-4 text-muted-foreground`}),r(`settings:agent.routingHeading`)]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,180px)_1fr_auto]`,children:[(0,X.jsxs)(`select`,{"aria-label":r(`settings:agent.routingRouteKey`),value:i,onChange:e=>a(e.target.value),className:`h-9 min-w-0 rounded-md border bg-background px-3 font-mono text-sm`,children:[(0,X.jsx)(`option`,{value:`*`,children:fm(`*`)}),(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:sm.map(e=>(0,X.jsx)(`option`,{value:e.phase,children:fm(e.phase)},e.phase))}),sm.map(e=>(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingRolesGroup`,{label:e.label}),children:e.roles.map(e=>(0,X.jsx)(`option`,{value:e.role,children:fm(e.role)},e.role))},e.phase)),y.length>0?(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingCustomGroup`),children:y.map(e=>(0,X.jsx)(`option`,{value:e,children:fm(e)},e))}):null]}),(0,X.jsxs)(`select`,{"aria-label":r(`settings:agent.routingTargetAria`),value:o,onChange:e=>s(e.target.value),className:`h-9 min-w-0 rounded-md border bg-background px-3 font-mono text-sm`,children:[(0,X.jsx)(`option`,{value:``,children:r(`settings:agent.routingTargetEmpty`)}),Object.keys(n.fallbackProfiles).length>0&&(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetProfilesGroup`),children:Object.keys(n.fallbackProfiles).map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))}),t&&t.length>0&&(0,X.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetModelsGroup`),children:t.map(e=>(0,X.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.provider,`/`,e.model]},`${e.provider}/${e.model}`))})]}),(0,X.jsx)(J,{type:`button`,variant:`outline`,onClick:h,children:r(`settings:agent.routingSet`)})]}),(0,X.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeAria`),value:c,onChange:e=>l(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:pm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortAria`),value:u,onChange:e=>d(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:mm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningPreserveAria`),value:f,onChange:e=>p(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:hm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]}),(0,X.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:Object.keys(n.modelMatrix).length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings:agent.noRoutes`)}):Object.entries(n.modelMatrix).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,X.jsxs)(`div`,{className:`rounded-md border border-border bg-muted px-2 py-1.5 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-40 shrink-0 truncate font-mono text-muted-foreground`,title:e,children:fm(e)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:v(t)}),(0,X.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>g(e),children:r(`common:action.remove`)})]}),(0,X.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeFor`,{key:e}),value:t.modelRuntime?.reasoning?.mode??``,onChange:t=>_(e,`mode`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:pm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortFor`,{key:e}),value:t.modelRuntime?.reasoning?.effort??``,onChange:t=>_(e,`effort`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:mm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,X.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningPreserveFor`,{key:e}),value:t.modelRuntime?.reasoning?.preserve===void 0?``:t.modelRuntime.reasoning.preserve?`on`:`off`,onChange:t=>_(e,`preserve`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:hm.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}var bm=[`off`,`low`,`medium`,`high`,`all`],xm={off:`bg-muted-foreground`,low:`bg-success`,medium:`bg-warning`,high:`bg-warning ring-2 ring-warning/25`,all:`bg-destructive`},Sm={off:`settings:brain.riskCopy.off`,low:`settings:brain.riskCopy.low`,medium:`settings:brain.riskCopy.medium`,high:`settings:brain.riskCopy.high`,all:`settings:brain.riskCopy.all`},Cm=[`executor`,`skeptic`,`auditor`];function wm(e){return e&&e.length>0?e.map(e=>({id:e.id,name:e.name,description:e.description})):Cm.map(e=>({id:e,name:e}))}var Tm=[{value:`default`,labelKey:`settings:brainOpt.default15s`},{value:`5000`,label:`5s`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Em=[{value:`off`,labelKey:`settings:brainOpt.waitForever`},{value:`30000`,label:`30s`},{value:`60000`,label:`1m`},{value:`120000`,label:`2m`},{value:`300000`,label:`5m`}],Dm=[{value:`default`,labelKey:`settings:brainOpt.defaultHalf`},{value:`0.34`,label:`1/3`},{value:`0.5`,label:`1/2`},{value:`0.67`,label:`2/3`},{value:`0.75`,label:`3/4`},{value:`1`,labelKey:`settings:brainOpt.all`}],Om=[{value:`100`,label:`100`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],km=[{value:`0`,labelKey:`settings:brainOpt.offDefault`},{value:`0.3`,label:`0.3`},{value:`0.5`,label:`0.5`},{value:`0.7`,label:`0.7`},{value:`0.9`,label:`0.9`}],Am=[{value:`10`,label:`10`},{value:`20`,labelKey:`settings:brainOpt.n20Default`},{value:`50`,label:`50`},{value:`100`,label:`100`}],jm=[{value:`60000`,label:`1m`},{value:`300000`,labelKey:`settings:brainOpt.m5Default`},{value:`900000`,label:`15m`},{value:`3600000`,label:`1h`}],Mm=[{value:`50`,label:`50`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`}],Nm=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Pm=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.oneSerial`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],Fm=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`2000`,label:`2000`},{value:`4000`,label:`4000`},{value:`8000`,label:`8000`}],Im=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`200`,label:`200`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Lm=[{value:`default`,labelKey:`settings:brainOpt.default500`},{value:`100`,label:`100`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`5000`,label:`5000`}],Rm=[{value:`default`,labelKey:`settings:brainOpt.default10m`},{value:`120000`,label:`2m`},{value:`600000`,label:`10m`},{value:`1800000`,label:`30m`},{value:`3600000`,label:`1h`}];function zm(e,t){return e.some(e=>e.value===t)?e:[...e,{value:t,label:t}]}function Bm(e,t){return e.map(e=>({value:e.value,label:e.labelKey?t(e.labelKey):e.label??e.value}))}function Vm(e){return e===void 0?`default`:String(e)}function Hm({level:e}){return(0,X.jsx)(`span`,{className:H(`inline-block h-2.5 w-2.5 rounded-full`,xm[e])})}function Um(e){return e.provider?`${e.provider}/${e.model}`:e.model}var Wm={pool:{title:`settings:brain.pickPoolTitle`,hint:`settings:brain.pickPoolHint`},voter:{title:`settings:brain.pickVoterTitle`,hint:`settings:brain.pickVoterHint`},judge:{title:`settings:brain.pickJudgeTitle`,hint:`settings:brain.pickJudgeHint`}};function Gm(){let{t:e}=R(),{client:t}=Br(),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)([]),[o,s]=(0,Y.useState)(!0),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{t.send({type:`brain.status`}),t.send({type:`brain.config.get`})},[t]),(0,Y.useEffect)(()=>{let n=t.on(`brain.status`,e=>{let t=e.payload,n=Date.now();a(t.log.slice(-10).map(e=>{let t=Math.max(0,Math.round((n-e.at)/1e3)),r=t<60?`${t}s`:t<3600?`${Math.round(t/60)}m`:`${Math.round(t/3600)}h`;return{kind:e.kind,question:e.question,outcome:e.outcome,age:r}})),s(!1)}),i=t.on(`brain.config`,t=>{let n=t.payload;r(n.config),d(n.persisted?null:n.error??e(`settings:brain.persistError`)),l(!1),s(!1)});return()=>{n(),i()}},[t,e]);let m=(0,Y.useCallback)(e=>{l(!0),t.send({type:`brain.config.set`,payload:{patch:e}})},[t]),h=(0,Y.useCallback)(e=>{r(t=>t&&{...t,maxAutoRisk:e}),m({maxAutoRisk:e})},[m]),g=(0,Y.useMemo)(()=>n?.council.voters??[],[n]),v=(0,Y.useCallback)(e=>{m({council:{voters:e.length>0?e:null}})},[m]),y=(0,Y.useMemo)(()=>wm(n?.personaCatalog),[n?.personaCatalog]),b=bm.includes(n?.maxAutoRisk??``)?n?.maxAutoRisk??`medium`:`medium`,x=(0,Y.useCallback)(e=>{if(!n||!f)return;let t=`${e.provider}/${e.model}`;if(f===`pool`){m({models:[...n.models.map(Um),t]});return}if(f===`judge`){m({council:{judge:t}});return}return v([...g,{provider:e.provider,model:e.model,persona:y[g.length%y.length]?.id??`executor`}]),!0},[n,y,f,m,v,g]);return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(Cf,{open:f!==null,mode:`provider-model`,title:f?e(Wm[f].title):``,hint:f?e(Wm[f].hint):void 0,onPick:e=>{if(e.type===`provider-model`)return x(e)},onClose:()=>p(null)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Nt,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`settings:brain.heading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.headingHint`)})]}),(o||c)&&(0,X.jsx)(ln,{className:`ml-auto h-4 w-4 animate-spin text-muted-foreground`})]}),u&&(0,X.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:u}),(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.riskHeading`)}),(0,X.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:bm.map(e=>(0,X.jsxs)(J,{variant:b===e?`default`:`outline`,size:`sm`,className:H(`gap-1.5 text-xs`,b===e&&`shadow-sm`),disabled:c,onClick:()=>h(e),children:[(0,X.jsx)(Hm,{level:e}),e.toUpperCase()]},e))}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(Sm[b])})]}),n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.escalationHeading`)}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationModeLabel`),hint:e(`settings:brain.escalationModeHint`),value:n.mode,options:[{value:`interactive`,label:e(`settings:brain.optInteractive`)},{value:`headless`,label:e(`settings:brain.optHeadless`)}],onChange:e=>m({mode:e}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationDecisionTimeoutLabel`),hint:e(`settings:brain.escalationDecisionTimeoutHint`),value:n.decisionTimeoutMs?String(n.decisionTimeoutMs):`default`,options:Bm(Tm,e),onChange:e=>m({decisionTimeoutMs:e==="default"?null:Number(e)}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationHumanTimeoutLabel`),hint:e(`settings:brain.escalationHumanTimeoutHint`),value:n.humanTimeoutMs?String(n.humanTimeoutMs):`off`,options:Bm(Em,e),onChange:e=>m({humanTimeoutMs:e===`off`?null:Number(e)}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationTerminalPolicyLabel`),hint:e(`settings:brain.escalationTerminalPolicyHint`),value:n.terminalPolicy,options:[{value:`conservative`,label:e(`settings:brain.optConservative`)},{value:`deny-all`,label:e(`settings:brain.optDenyAll`)},{value:`continue-on-recommended`,label:e(`settings:brain.optContinueRecommended`)}],onChange:e=>m({terminalPolicy:e}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.escalationDecisionLogSizeLabel`),hint:e(`settings:brain.escalationDecisionLogSizeHint`),value:String(n.decisionLogMaxEntries),options:Bm(zm(Am,String(n.decisionLogMaxEntries)),e),onChange:e=>m({decisionLogMaxEntries:Number(e)}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.rulesHeading`)}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.rulesConfigured`,{count:n.rules.length})})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.rulesBody`)}),n.rules.length>0&&(0,X.jsx)(`div`,{className:`space-y-1`,children:n.rules.map((t,n)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[n+1,`.`]}),(0,X.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:t.id}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px] shrink-0`,children:t.then.action}),t.enabled===!1&&(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px] shrink-0`,children:e(`settings:brain.rulesOff`)})]},`${t.id}-${n}`))}),n.ruleErrors.length>0&&(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-warning`,children:e(`settings:brain.rulesDropped`,{count:n.ruleErrors.length})}),n.ruleErrors.map(e=>(0,X.jsx)(`p`,{className:`text-xs text-warning`,children:e},e))]})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.heuristicsHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsBody`)}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsLowRiskLabel`),hint:e(`settings:brain.heuristicsLowRiskHint`),value:n.heuristics.lowRiskAutoAnswer,onChange:()=>m({heuristics:{lowRiskAutoAnswer:!n.heuristics.lowRiskAutoAnswer}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsBlockedLabel`),hint:e(`settings:brain.heuristicsBlockedHint`),value:n.heuristics.blockedResolved,onChange:()=>m({heuristics:{blockedResolved:!n.heuristics.blockedResolved}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsDeadlockLabel`),hint:e(`settings:brain.heuristicsDeadlockHint`),value:n.heuristics.deadlockSkip,onChange:()=>m({heuristics:{deadlockSkip:!n.heuristics.deadlockSkip}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsRetryLabel`),hint:e(`settings:brain.heuristicsRetryHint`),value:n.heuristics.retryExhausted,onChange:()=>m({heuristics:{retryExhausted:!n.heuristics.retryExhausted}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.heuristicsPingLabel`),hint:e(`settings:brain.heuristicsPingHint`),value:n.heuristics.continuePing,onChange:()=>m({heuristics:{continuePing:!n.heuristics.continuePing}}),disabled:c}),n.heuristics.blockedResolvedMarkers&&n.heuristics.blockedResolvedMarkers.length>0&&(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsMarkers`,{markers:n.heuristics.blockedResolvedMarkers.join(`, `)})})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.qualityHeading`)}),n.circuit&&(0,X.jsx)(Yf,{variant:n.circuit.state===`closed`?`outline`:`default`,className:`text-[10px]`,children:e(`settings:brain.qualityCircuit`,{state:n.circuit.state,count:n.circuit.consecutiveFailures})})]}),(0,X.jsx)(Q,{label:e(`settings:brain.qualityResponseBudgetLabel`),hint:e(`settings:brain.qualityResponseBudgetHint`),value:String(n.llm.maxTokens),options:Bm(zm(Om,String(n.llm.maxTokens)),e),onChange:e=>m({llm:{maxTokens:Number(e)}}),disabled:c}),(0,X.jsx)($,{label:e(`settings:brain.qualityRejectLabel`),hint:e(`settings:brain.qualityRejectHint`),value:n.llm.rejectUncertain,onChange:()=>m({llm:{rejectUncertain:!n.llm.rejectUncertain}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.qualityMinConfidenceLabel`),hint:e(`settings:brain.qualityMinConfidenceHint`),value:String(n.llm.minConfidence),options:Bm(zm(km,String(n.llm.minConfidence)),e),onChange:e=>m({llm:{minConfidence:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.qualityDenyTerminalLabel`),hint:e(`settings:brain.qualityDenyTerminalHint`),value:n.llm.denyIsTerminal,options:[{value:`never`,label:e(`settings:brain.optNeverDefault`)},{value:`when-decided`,label:e(`settings:brain.optWhenDecided`)},{value:`always`,label:e(`settings:brain.optAlways`)}],onChange:e=>m({llm:{denyIsTerminal:e}}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.traceHeading`)}),(0,X.jsx)($,{label:e(`settings:brain.traceRecordLabel`),hint:e(`settings:brain.traceRecordHint`),value:n.trace.enabled,onChange:()=>m({trace:{enabled:!n.trace.enabled}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.traceContentLabel`),hint:e(`settings:brain.traceContentHint`),value:n.trace.content,options:[{value:`full`,label:e(`settings:brain.optFullDefault`)},{value:`redacted`,label:e(`settings:brain.optRedacted`)},{value:`none`,label:e(`settings:brain.optMetadataOnly`)}],onChange:e=>m({trace:{content:e}}),disabled:c}),n.trace.path&&(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.trace.path})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.cacheHeading`)}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.cacheStats`,{hits:n.cache.hits,misses:n.cache.misses,size:n.cache.size})})]}),(0,X.jsx)($,{label:e(`settings:brain.cacheReplayLabel`),hint:e(`settings:brain.cacheReplayHint`),value:n.cache.enabled,onChange:()=>m({cache:{enabled:!n.cache.enabled}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.cacheLifetimeLabel`),hint:e(`settings:brain.cacheLifetimeHint`),value:String(n.cache.ttlMs),options:Bm(zm(jm,String(n.cache.ttlMs)),e),onChange:e=>m({cache:{ttlMs:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.cacheMaxEntriesLabel`),hint:e(`settings:brain.cacheMaxEntriesHint`),value:String(n.cache.maxEntries),options:Bm(zm(Mm,String(n.cache.maxEntries)),e),onChange:e=>m({cache:{maxEntries:Number(e)}}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.monitorHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.monitorBody`)}),(0,X.jsx)($,{label:e(`settings:brain.monitorWatchLabel`),hint:e(`settings:brain.monitorWatchHint`),value:n.monitor.enabled!==!1,onChange:()=>m({monitor:{enabled:n.monitor.enabled===!1}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.monitorPolicyLabel`),hint:e(`settings:brain.monitorPolicyHint`),value:n.monitor.policy??`llm`,options:[{value:`llm`,label:e(`settings:brain.optConsultBrain`)},{value:`steer`,label:e(`settings:brain.optAlwaysSteer`)},{value:`observe`,label:e(`settings:brain.optObserveOnly`)}],onChange:e=>m({monitor:{policy:e}}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.modelsHeading`)}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px]`,children:n.usingSessionModel?e(`settings:brain.modelsSessionBadge`):e(`settings:brain.modelsResolvedBadge`,{resolved:n.poolLabels.length,total:n.models.length})})]}),(0,X.jsx)($,{label:e(`settings:brain.modelsUseSessionLabel`),hint:e(`settings:brain.modelsUseSessionHint`),value:n.usingSessionModel,onChange:()=>{n.usingSessionModel||m({models:null})},disabled:c}),n.models.length>0&&(0,X.jsx)(`div`,{className:`space-y-1`,children:n.models.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[t+1,`.`]}),(0,X.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:Um(e)}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===0,onClick:()=>{let e=n.models.map(Um),r=e.splice(t,1)[0];r&&e.splice(t-1,0,r),m({models:e})},children:(0,X.jsx)(tn,{className:`h-3 w-3`})}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===n.models.length-1,onClick:()=>{let e=n.models.map(Um),r=e.splice(t,1)[0];r&&e.splice(t+1,0,r),m({models:e})},children:(0,X.jsx)(Ze,{className:`h-3 w-3`})}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>{let e=n.models.map(Um).filter((e,n)=>n!==t);m({models:e.length>0?e:null})},children:(0,X.jsx)(Wt,{className:`h-3 w-3`})})]},`${Um(e)}-${t}`))}),(0,X.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`pool`),children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.modelsAddModel`)]}),n.models.length>1&&(0,X.jsx)(Q,{label:e(`settings:brain.modelsPoolStrategyLabel`),hint:e(`settings:brain.modelsPoolStrategyHint`),value:n.strategy,options:[{value:`fallback`,label:e(`settings:brain.optFallback`)},{value:`round-robin`,label:e(`settings:brain.optRoundRobin`)}],onChange:e=>m({strategy:e}),disabled:c})]}),(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.councilHeading`)}),(0,X.jsx)(Yf,{variant:n.council.enabled?`default`:`outline`,className:`text-[10px]`,children:n.council.enabled?e(`settings:brain.councilConvened`):e(`settings:brain.councilDisabled`)})]}),(0,X.jsx)($,{label:e(`settings:brain.councilEnableLabel`),hint:e(`settings:brain.councilEnableHint`),value:n.council.enabled,onChange:()=>m({council:{enabled:!n.council.enabled}}),disabled:c}),n.council.enabled&&n.councilLabels.length>0&&g.length===0&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.councilSeatsDerived`,{seats:n.councilLabels.join(`, `)})}),g.length>0&&(0,X.jsx)(`div`,{className:`space-y-1`,children:g.map((t,n)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,X.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:Um(t)}),(0,X.jsxs)(`select`,{value:t.persona??y[n%y.length]?.id??``,onChange:e=>v(g.map((t,r)=>r===n?{...t,persona:e.target.value}:t)),className:`h-6 rounded border bg-background px-1 text-[10px]`,title:y.find(e=>e.id===t.persona)?.description??e(`settings:brain.councilCustomLens`),children:[y.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id)),t.persona&&!y.some(e=>e.id===t.persona)&&(0,X.jsx)(`option`,{value:t.persona,children:e(`settings:brain.councilCustomOption`,{persona:t.persona})})]}),(0,X.jsx)(J,{variant:t.veto?`default`:`outline`,size:`sm`,className:`h-6 px-1.5 text-[10px]`,disabled:c,onClick:()=>v(g.map((e,t)=>t===n?{...e,veto:!e.veto}:e)),children:e(`settings:brain.councilVeto`)}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>v(g.filter((e,t)=>t!==n)),children:(0,X.jsx)(Wt,{className:`h-3 w-3`})})]},`${Um(t)}-${n}`))}),(0,X.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`voter`),children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.councilAddVoter`)]}),(0,X.jsx)(Q,{label:e(`settings:brain.councilRiskFloorLabel`),hint:e(`settings:brain.councilRiskFloorHint`),value:n.council.minRisk,options:[{value:`medium`,label:e(`settings:brain.optMediumPlus`)},{value:`high`,label:e(`settings:brain.optHighPlus`)},{value:`critical`,label:e(`settings:brain.optCriticalOnly`)}],onChange:e=>m({council:{minRisk:e}}),disabled:c}),(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium`,children:e(`settings:brain.councilJudge`)}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`settings:brain.councilJudgeDesc`)}),!n.council.judge&&n.judgeLabel&&(0,X.jsxs)(`div`,{className:`mt-0.5 font-mono text-xs text-muted-foreground`,children:[e(`settings:brain.councilResolved`,{model:n.judgeLabel}),n.judgeIsVoter&&(0,X.jsx)(`span`,{className:`ml-1 font-sans text-warning`,children:e(`settings:brain.councilAlsoVoter`)})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`max-w-[180px] truncate font-mono text-xs`,children:n.council.judge?Um(n.council.judge):e(`settings:brain.councilAuto`)}),(0,X.jsx)(J,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>p(`judge`),children:e(`settings:brain.councilPick`)}),n.council.judge&&(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>m({council:{judge:null}}),children:e(`settings:brain.councilAutoReset`)})]})]}),(0,X.jsx)(Q,{label:e(`settings:brain.councilQuorumLabel`),hint:e(`settings:brain.councilQuorumHint`),value:n.council.quorum===void 0?`default`:String(n.council.quorum),options:Bm(Dm,e),onChange:e=>m({council:{quorum:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilApprovalLabel`),hint:e(`settings:brain.councilApprovalHint`),value:n.council.approval===void 0?`default`:String(n.council.approval),options:Bm(Dm,e),onChange:e=>m({council:{approval:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilPerSeatTimeoutLabel`),hint:e(`settings:brain.councilPerSeatTimeoutHint`),value:Vm(n.council.perCallTimeoutMs),options:Bm(zm(Nm,Vm(n.council.perCallTimeoutMs)),e),onChange:e=>m({council:{perCallTimeoutMs:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilMaxConcurrencyLabel`),hint:e(`settings:brain.councilMaxConcurrencyHint`),value:Vm(n.council.maxConcurrency),options:Bm(zm(Pm,Vm(n.council.maxConcurrency)),e),onChange:e=>m({council:{maxConcurrency:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilDistinctnessLabel`),hint:e(`settings:brain.councilDistinctnessHint`),value:n.council.distinctness,options:[{value:`none`,label:e(`settings:brain.optNoneDefault`)},{value:`model`,label:e(`settings:brain.optDistinctModels`)},{value:`provider`,label:e(`settings:brain.optDistinctProviders`)}],onChange:e=>m({council:{distinctness:e}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilVoterBudgetLabel`),hint:e(`settings:brain.councilVoterBudgetHint`),value:Vm(n.council.voterMaxTokens),options:Bm(zm(Fm,Vm(n.council.voterMaxTokens)),e),onChange:e=>m({council:{voterMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.councilJudgeBudgetLabel`),hint:e(`settings:brain.councilJudgeBudgetHint`),value:Vm(n.council.judgeMaxTokens),options:Bm(zm(Im,Vm(n.council.judgeMaxTokens)),e),onChange:e=>m({council:{judgeMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),n.council.seats.length>0&&(0,X.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[e(`settings:brain.councilSeatTemplate`),` `,n.council.seats.map(t=>t.veto?`${t.persona} (${e(`settings:brain.councilVeto`)})`:t.persona).join(`, `)]})]}),(0,X.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.ledgerHeading`)}),(0,X.jsx)($,{label:e(`settings:brain.ledgerRecordLabel`),hint:e(`settings:brain.ledgerRecordHint`),value:n.ledger.enabled,onChange:()=>m({ledger:{enabled:!n.ledger.enabled}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.ledgerAutoDenyLabel`),hint:e(`settings:brain.ledgerAutoDenyHint`),value:n.ledger.autoDenyAfterFailures===void 0?`default`:String(n.ledger.autoDenyAfterFailures),options:[{value:`default`,label:e(`settings:brain.optDefault3`)},{value:`0`,label:e(`settings:brain.optOff`)},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],onChange:e=>m({ledger:{autoDenyAfterFailures:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.ledgerMemoryEntriesLabel`),hint:e(`settings:brain.ledgerMemoryEntriesHint`),value:Vm(n.ledger.maxMemoryEntries),options:Bm(zm(Lm,Vm(n.ledger.maxMemoryEntries)),e),onChange:e=>m({ledger:{maxMemoryEntries:e==="default"?null:Number(e)}}),disabled:c}),(0,X.jsx)(Q,{label:e(`settings:brain.ledgerRetryWindowLabel`),hint:e(`settings:brain.ledgerRetryWindowHint`),value:Vm(n.ledger.interventionRetryWindowMs),options:Bm(zm(Rm,Vm(n.ledger.interventionRetryWindowMs)),e),onChange:e=>m({ledger:{interventionRetryWindowMs:e==="default"?null:Number(e)}}),disabled:c}),n.ledger.path&&(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.ledger.path})]})]}),(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.recentHeading`,{count:i.length})}),(0,X.jsx)(`div`,{className:`space-y-1 max-h-[300px] overflow-y-auto`,children:i.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground py-2`,children:e(`settings:brain.recentEmpty`)}):i.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-8`,children:e.age}),(0,X.jsx)(Yf,{variant:`outline`,className:`text-[10px] shrink-0`,children:e.kind}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.question}),e.outcome&&(0,X.jsx)(`span`,{className:`text-muted-foreground shrink-0 italic`,children:e.outcome})]},`${e.age}-${e.kind}-${e.question.slice(0,32)}`))})]})]})}function Km(){let{t:e}=R();return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(xn,{className:`h-5 w-5 text-info`}),(0,X.jsx)(`h3`,{className:`text-lg font-semibold`,children:e(`activity:shadow.shadowAgent`)})]}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`activity:shadow.theShadowAgentMonitorsAllFleet`)}),(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Start and stop it from the chat with`,` `,(0,X.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow start`}),` and`,` `,(0,X.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow stop`}),`. This panel cannot control it yet.`]})]})}function qm({disabled:e,mutating:t}){return(0,X.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full ${e?`bg-muted-foreground`:t?`bg-warning`:`bg-success`}`,title:e?`disabled`:t?`mutating`:`read-only`})}function Jm({tool:e,onToggle:t,busy:n}){let{t:r}=R(),[i,a]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,X.jsx)(qm,{disabled:e.disabled,mutating:e.mutating}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`code`,{className:`block truncate text-sm font-mono font-semibold`,title:e.name,children:e.name}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(Yf,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,X.jsx)(Yf,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:e.owner,children:e.owner})]})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[(0,X.jsxs)(J,{variant:e.disabled?`default`:`secondary`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:t,disabled:n,children:[n?(0,X.jsx)(ln,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,X.jsx)($e,{className:`h-3 w-3`}):(0,X.jsx)(yr,{className:`h-3 w-3`}),e.disabled?`Enable`:`Disable`]}),(0,X.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>a(!i),"aria-label":i?`Collapse`:`Expand`,children:(0,X.jsx)(Ue,{className:`h-4 w-4 transition-transform ${i?`rotate-180`:``}`})})]})]}),i&&(0,X.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2 text-xs text-muted-foreground sm:ml-4`,children:[(0,X.jsx)(`p`,{children:e.description}),e.params.length>0&&(0,X.jsxs)(`p`,{children:[r(`activity:toolsSec.params`),` `,(0,X.jsx)(`code`,{className:`break-all font-mono`,children:e.params.join(`, `)})]})]})]})}function Ym(){let{t:e}=R(),{client:t}=Br(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{let e=t.on(`tools.list`,e=>{let t=e.payload;r(t.tools),a(!1)}),n=e=>{if(e.type===`tool.disabled`||e.type===`tool.enabled`){let n=e.payload;l(e=>{let t=new Set(e);return t.delete(n.name),t}),n.ok?t.send({type:`tools.list`},{echoToChat:!1}):q.error(`Tool "${n.name}" ${e.type===`tool.disabled`?`disable`:`enable`} failed.`)}},i=t.on(`tool.disabled`,n),o=t.on(`tool.enabled`,n);return()=>{e(),i(),o()}},[t]),(0,Y.useEffect)(()=>{t.send({type:`tools.list`},{echoToChat:!1})},[t]);let u=(0,Y.useCallback)((e,n)=>{l(t=>new Set(t).add(e)),t.send({type:n?`tool.enable`:`tool.disable`,payload:{name:e}})},[t]),d=o?n.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())||e.owner.toLowerCase().includes(o.toLowerCase())):n,f=n.filter(e=>!e.disabled).length,p=n.filter(e=>e.disabled).length;return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Xt,{className:`h-5 w-5`})}),(0,X.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`activity:toolsSec.tools`)})]}),!i&&(0,X.jsxs)(`span`,{className:`rounded-md border border-border/60 bg-muted/30 px-2 py-1 text-xs text-muted-foreground sm:ml-auto`,children:[f,` active · `,p,` disabled · `,n.length,` total`]})]}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(Ft,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,X.jsx)(zi,{placeholder:e(`activity:toolsSec.filterToolsByNameOrOwner`),value:o,onChange:e=>s(e.target.value),className:`pl-8 h-9 text-sm`})]}),i?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground gap-2`,children:[(0,X.jsx)(ln,{className:`h-4 w-4 animate-spin`}),e(`activity:toolsSec.loadingTools`)]}):d.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:o?`No tools matching "${o}".`:`No tools registered.`}):(0,X.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border/70 bg-background/35 shadow-inner`,children:[(0,X.jsx)(`ul`,{className:`max-h-[min(58dvh,660px)] space-y-2 overflow-y-scroll p-2 pr-3 [scrollbar-gutter:stable]`,"aria-label":e(`activity:toolsSec.toolsList`),children:d.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Jm,{tool:e,onToggle:()=>u(e.name,e.disabled),busy:c.has(e.name)})},e.name))}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-4 bg-gradient-to-b from-background/90 to-transparent`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-background/95 to-transparent`})]})]})}function Xm(){let{t:e}=R();return(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(xn,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.brainHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.brainHint`)})]})]}),(0,X.jsx)(Gm,{})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(xn,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.shadowHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.shadowHint`)})]})]}),(0,X.jsx)(Km,{})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(xn,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.toolsHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.toolsHint`)})]})]}),(0,X.jsx)(Ym,{})]})]})}var Zm=[{id:`general`,icon:(0,X.jsx)(F,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.general`,descKey:`settings:tabs.generalDesc`},{id:`provider`,icon:(0,X.jsx)(kr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.provider`,descKey:`settings:tabs.providerDesc`},{id:`connection`,icon:(0,X.jsx)(u,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.connection`,descKey:`settings:tabs.connectionDesc`},{id:`agent`,icon:(0,X.jsx)(bn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.agent`,descKey:`settings:tabs.agentDesc`},{id:`execution`,icon:(0,X.jsx)(ar,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.execution`,descKey:`settings:tabs.executionDesc`},{id:`fallbacks`,icon:(0,X.jsx)($t,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fallbacks`,descKey:`settings:tabs.fallbacksDesc`},{id:`routing`,icon:(0,X.jsx)(Xn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.routing`,descKey:`settings:tabs.routingDesc`},{id:`fleet`,icon:(0,X.jsx)(Cr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fleet`,descKey:`settings:tabs.fleetDesc`},{id:`integrations`,icon:(0,X.jsx)(zt,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.integrations`,descKey:`settings:tabs.integrationsDesc`},{id:`chimera`,icon:(0,X.jsx)(Nt,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.chimera`,descKey:`settings:tabs.chimeraDesc`},{id:`context`,icon:(0,X.jsx)(yt,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.context`,descKey:`settings:tabs.contextDesc`},{id:`logs`,icon:(0,X.jsx)(Wn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.logs`,descKey:`settings:tabs.logsDesc`},{id:`security`,icon:(0,X.jsx)(me,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.security`,descKey:`settings:tabs.securityDesc`},{id:`display`,icon:(0,X.jsx)(F,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.display`,descKey:`settings:tabs.displayDesc`}];function Qm(){let{settingsActiveTab:e,setSettingsActiveTab:t}=G(fn(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),n=Qd(`settings`),r=(0,Y.useRef)(!1),[i,a]=(0,Y.useState)(!1),{provider:o,model:s,setProvider:c,setModel:l,wsConnected:u}=W(fn(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),d=Br(),f=d.client,{updatePrefs:p,switchAutonomy:m}=d,h=z(),{t:g}=R(),_=Ki(!0),v=(0,Y.useCallback)((e,t)=>{h.set({[e]:t}),p({[e]:t})},[h,p]),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)({}),[C,w]=(0,Y.useState)([]),[T,E]=(0,Y.useState)(!1),[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(`catalog`),[N,ee]=(0,Y.useState)(``),[te,ne]=(0,Y.useState)(!1),[re,P]=(0,Y.useState)(!1),ie=(0,Y.useCallback)(()=>{h.reset(),P(!1),window.location.reload()},[h]),ae=y.find(e=>e.id===o),oe=Zm.find(t=>t.id===e);(0,Y.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;b(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),E(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;S(e=>({...e,[t.provider]:t.models})),O(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));w(t),A(!1),t.length>0&&M(`saved`)}};if(!u||!f)return;let r=f.on(`provider.catalog`,e),i=f.on(`provider.models`,t),a=f.on(`providers.saved`,n);return E(!0),A(!0),f.listProviders(),f.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[u,f]);let se=(0,Y.useCallback)(e=>{c(e),x[e]||(O(!0),d.listProviderModels?.(e))},[x,c,d]),ce=(0,Y.useCallback)(async e=>{if(r.current)return;let t=W.getState().model,n=W.getState().provider;if(!(!n||e===t)){r.current=!0,a(!0),l(e);try{q.info(L.t(`settings:toast.switchingTo`,{provider:n,model:e}));let r=await d.switchModel?.(n,e);r?.success?q.success(L.t(r.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${n} / ${t}`,to:`${n} / ${e}`})):(l(t),q.error(r?.message??L.t(`settings:toast.modelSwitchTimeout`)))}finally{r.current=!1,a(!1)}}},[l,d]),F=(0,Y.useCallback)((e,t,n)=>{d.addKey?.(e,t,n)},[d]),I=(0,Y.useCallback)((e,t)=>{d.deleteKey?.(e,t)},[d]),le=(0,Y.useCallback)((e,t)=>{d.setActiveKey?.(e,t)},[d]),ue=(0,Y.useCallback)((e,t,n,r,i,a)=>{d.addProvider?.(e,t,n,r,i,a)},[d]),de=(0,Y.useCallback)(e=>{d.removeProvider?.(e)},[d]),fe=(0,Y.useCallback)((e,t)=>{d.client.updateProvider({id:e,models:[t]}),e===W.getState().provider&&l(t)},[l,d.client]);return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-gradient-to-b from-background/90 via-background/60 to-background/80`,children:[(0,X.jsxs)(`header`,{className:`flex items-center justify-between px-4 py-3 border-b border-border/60 bg-card/60 backdrop-blur-xl shrink-0 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(kn,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`text-lg font-semibold bg-gradient-to-r from-foreground to-foreground/70 bg-clip-text text-transparent`,children:g(`settings:title`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:o&&s?`${o} / ${s}`:g(`settings:subtitle`)})]})]}),(0,X.jsx)(J,{variant:`ghost`,size:`icon`,onClick:()=>K(`chat`),children:(0,X.jsx)(Wt,{className:`h-4 w-4`})}),(0,X.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>P(!0),children:g(`settings:resetLabel`)})]}),(0,X.jsx)(qa,{className:`min-h-0 flex-1`,ref:n,children:(0,X.jsx)(`div`,{className:`mx-auto max-w-7xl p-4 sm:p-6`,children:(0,X.jsxs)(Ya,{value:e,onValueChange:t,className:`grid min-h-[calc(100dvh-9rem)] gap-3 lg:grid-cols-[13.5rem_minmax(0,1fr)] lg:gap-5`,children:[(0,X.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,X.jsx)(Xa,{className:`flex h-auto w-full justify-start gap-0.5 overflow-x-scroll rounded-lg border border-border/60 bg-card/60 p-1.5 shadow-sm [scrollbar-gutter:stable] lg:sticky lg:top-4 lg:flex-col lg:overflow-visible lg:rounded-xl lg:bg-card/60 lg:p-2`,children:Zm.map(e=>(0,X.jsxs)(Za,{value:e.id,className:`h-9 shrink-0 gap-2.5 rounded-md px-3 text-xs scroll-mt-2 data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-sm lg:w-full lg:justify-start lg:px-3`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:e.icon}),(0,X.jsx)(`span`,{className:`truncate`,children:g(e.labelKey)})]},e.id))}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 left-0 z-10 w-8 rounded-l-lg bg-gradient-to-r from-background via-background/90 to-transparent lg:hidden`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 right-0 z-10 w-8 rounded-r-lg bg-gradient-to-l from-background via-background/90 to-transparent lg:hidden`})]}),(0,X.jsxs)(`div`,{className:`min-w-0 space-y-0`,children:[oe?.descKey&&(0,X.jsxs)(`div`,{className:`mb-4 flex items-start gap-3 rounded-xl border border-border/60 bg-card/50 px-4 py-3`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:oe.icon}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-sm font-semibold`,children:g(oe.labelKey)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:g(oe.descKey)})]})]}),(0,X.jsx)(Qa,{value:`general`,className:`mt-0`,children:(0,X.jsx)(Pf,{})}),(0,X.jsxs)(Qa,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,X.jsx)(om,{activeProvider:o,catalogProviders:y,isLoadingCatalog:T,savedProviders:C,isLoadingSaved:k,providerTab:j,setProviderTab:M,onSelectProvider:se,onAddKey:F,onDeleteKey:I,onSetActiveKey:le,onAddProvider:ue,onRemoveProvider:de,onPickProviderModel:fe,ws:d.client,catalogQuery:N,setCatalogQuery:ee}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-semibold mb-4 flex items-center gap-2`,children:[(0,X.jsx)(Rt,{className:`h-4 w-4 text-muted-foreground`}),g(`settings:model.heading`)]}),(0,X.jsx)(ap,{provider:o,catalogModels:x,currentCatalogProvider:ae,isLoadingModels:D,setIsLoadingModels:O,onModelSelect:ce,isSwitching:i,refreshModels:e=>d.listProviderModels?.(e)})]})]}),(0,X.jsx)(Qa,{value:`connection`,className:`mt-0`,children:(0,X.jsx)(Nf,{})}),(0,X.jsxs)(Qa,{value:`agent`,className:`mt-0 space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Pe,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:agent.autonomyHeading`)})})]}),(0,X.jsx)(Q,{label:g(`settings:agent.autonomyModeLabel`),hint:g(`settings:agent.autonomyModeHint`),value:h.autonomy,options:[{value:`off`,label:g(`settings:agent.autonomyModeOff`)},{value:`suggest`,label:g(`settings:agent.autonomyModeSuggest`)},{value:`auto`,label:g(`settings:agent.autonomyModeAuto`)},{value:`eternal`,label:g(`settings:agent.autonomyModeEternal`)},{value:`eternal-parallel`,label:g(`settings:agent.autonomyModeEternalParallel`)}],onChange:e=>{h.set({autonomy:e}),m(e)}}),(0,X.jsx)(Mf,{label:g(`settings:agent.autonomyDelayMsLabel`),hint:g(`settings:agent.autonomyDelayMsHint`),value:h.autonomyDelayMs,min:0,max:1e4,step:500,unit:`ms`,onChange:e=>v(`autonomyDelayMs`,e)}),(0,X.jsx)($,{label:g(`settings:agent.yoloLabel`),hint:g(`settings:agent.yoloHint`),value:h.yolo,onChange:()=>v(`yolo`,!h.yolo)})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(ar,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:agent.refineHeading`)})})]}),(0,X.jsx)($,{label:g(`settings:agent.enableRefineLabel`),hint:g(`settings:agent.enableRefineHint`),value:h.enhanceEnabled,onChange:()=>v(`enhanceEnabled`,!h.enhanceEnabled)}),(0,X.jsx)(Mf,{label:g(`settings:agent.refineDelayLabel`),hint:g(`settings:agent.refineDelayHint`),value:h.enhanceDelayMs,min:3e4,max:12e4,step:15e3,unit:`ms`,onChange:e=>v(`enhanceDelayMs`,e)}),(0,X.jsx)(Mf,{label:g(`settings:agent.refineCountdownLabel`),hint:g(`settings:agent.refineCountdownHint`),value:h.enhanceCountdownMs,min:1e3,max:1e4,step:1e3,unit:`ms`,onChange:e=>v(`enhanceCountdownMs`,e)}),(0,X.jsx)(Q,{label:g(`settings:agent.refineLanguageLabel`),hint:g(`settings:agent.refineLanguageHint`),value:h.enhanceLanguage,options:[{value:`original`,label:g(`settings:agent.refineLanguageOriginal`)},{value:`english`,label:g(`settings:agent.refineLanguageEnglish`)}],onChange:e=>v(`enhanceLanguage`,e)}),(0,X.jsxs)(`div`,{className:`pt-3`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium mb-2`,children:g(`settings:agent.refineHeading`)}),(0,X.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 rounded-lg border border-border p-3 text-left cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>ne(!0),children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:h.refinerFallbackProfile?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`text-xs font-mono text-primary bg-primary/10 px-1.5 py-0.5 rounded`,children:h.refinerFallbackProfile}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(h.fallbackProfiles[h.refinerFallbackProfile]??[]).slice(0,2).join(` → `),(h.fallbackProfiles[h.refinerFallbackProfile]??[]).length>2?` …`:``]})]}):h.refinerProvider&&h.refinerModel?(0,X.jsxs)(`span`,{className:`text-xs font-mono`,children:[h.refinerProvider,`/`,h.refinerModel]}):h.refinerProvider?(0,X.jsxs)(`span`,{className:`text-xs font-mono`,children:[h.refinerProvider,` /`,` `,(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:g(`activity:index.sessionModel`)})]}):(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(`settings:agent.refinerProviderDefault`)})}),(0,X.jsx)(Rt,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]})]}),te&&(0,X.jsx)(Cf,{open:te,mode:`both`,title:g(`settings:agent.refineHeading`),hint:g(`settings:agent.refinerProviderHint`),fallbackProfiles:h.fallbackProfiles,clearLabel:g(`common:action.clear`),onPick:e=>{e.type===`clear`?(v(`refinerProvider`,``),v(`refinerModel`,``),v(`refinerFallbackProfile`,``)):e.type===`provider-model`?(v(`refinerProvider`,e.provider),v(`refinerModel`,e.model),v(`refinerFallbackProfile`,``)):e.type===`fallback-profile`&&(v(`refinerProvider`,``),v(`refinerModel`,``),v(`refinerFallbackProfile`,e.name)),ne(!1)},onClose:()=>ne(!1)})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Rt,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:agent.reasoningHeading`)})})]}),(0,X.jsx)(Q,{label:g(`settings:agent.reasoningModeLabel`),hint:g(`settings:agent.reasoningModeHint`),value:h.reasoningMode,options:[{value:`auto`,label:g(`settings:agent.reasoningModeAuto`)},{value:`on`,label:g(`settings:agent.reasoningModeOn`)},{value:`off`,label:g(`settings:agent.reasoningModeOff`)}],onChange:e=>v(`reasoningMode`,e)}),(0,X.jsx)(Q,{label:g(`settings:agent.reasoningEffortLabel`),hint:g(`settings:agent.reasoningEffortHint`),value:h.reasoningEffort,options:[{value:`none`,label:g(`settings:agent.reasoningEffortNone`)},{value:`minimal`,label:g(`settings:agent.reasoningEffortMinimal`)},{value:`low`,label:g(`settings:agent.reasoningEffortLow`)},{value:`medium`,label:g(`settings:agent.reasoningEffortMedium`)},{value:`high`,label:g(`settings:agent.reasoningEffortHigh`)},{value:`xhigh`,label:g(`settings:agent.reasoningEffortXhigh`)},{value:`max`,label:g(`settings:agent.reasoningEffortMax`)}],onChange:e=>v(`reasoningEffort`,e)}),(0,X.jsx)($,{label:g(`settings:agent.preserveThinkingLabel`),hint:g(`settings:agent.preserveThinkingHint`),value:h.reasoningPreserve,onChange:()=>v(`reasoningPreserve`,!h.reasoningPreserve)}),(0,X.jsx)(Q,{label:g(`settings:agent.cacheTtlLabel`),hint:g(`settings:agent.cacheTtlHint`),value:h.cacheTtl,options:[{value:`default`,label:g(`settings:agent.cacheTtlDefault`)},{value:`5m`,label:g(`settings:agent.cacheTtl5m`)},{value:`1h`,label:g(`settings:agent.cacheTtl1h`)}],onChange:e=>v(`cacheTtl`,e)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:g(`settings:agent.capsHint`)})]})]}),(0,X.jsxs)(Qa,{value:`execution`,className:`mt-0 space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(ar,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:execution.heading`)})})]}),(0,X.jsx)(Mf,{label:g(`settings:execution.maxIterationsLabel`),hint:g(`settings:execution.maxIterationsHint`),value:h.maxIterations,min:10,max:2e3,step:10,onChange:e=>v(`maxIterations`,e)}),(0,X.jsx)(Mf,{label:g(`settings:execution.autoProceedMaxIterationsLabel`),hint:g(`settings:execution.autoProceedMaxIterationsHint`),value:h.autoProceedMaxIterations,min:0,max:250,step:5,onChange:e=>v(`autoProceedMaxIterations`,e)}),(0,X.jsx)($,{label:g(`settings:execution.confirmExitLabel`),hint:g(`settings:execution.confirmExitHint`),value:h.confirmExit,onChange:()=>v(`confirmExit`,!h.confirmExit)}),(0,X.jsx)($,{label:g(`settings:execution.chimeLabel`),hint:g(`settings:execution.chimeHint`),value:h.chime,onChange:()=>v(`chime`,!h.chime)})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-warning/20 bg-warning/10 text-warning`,children:(0,X.jsx)(me,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:execution.breakerLabel`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:g(`settings:execution.breakerHint`)})]})]}),(0,X.jsx)($,{label:g(`settings:execution.breakerLabel`),hint:g(`settings:execution.breakerHint`),value:h.breakerEnabled,onChange:()=>v(`breakerEnabled`,!h.breakerEnabled)}),(0,X.jsx)(Mf,{label:g(`settings:execution.breakerTimeoutLabel`),hint:g(`settings:execution.breakerTimeoutHint`),value:h.breakerAutoKillResetMs,min:0,max:6e4,step:1e3,unit:`ms`,onChange:e=>v(`breakerAutoKillResetMs`,e)})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(On,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:execution.availabilityHeading`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:g(`settings:execution.availabilityHint`)})]})]}),(0,X.jsx)(xf,{value:h.modelAvailabilitySchedule,candidates:_,onChange:e=>v(`modelAvailabilitySchedule`,e)})]})]}),(0,X.jsx)(Qa,{value:`fallbacks`,className:`mt-0`,children:(0,X.jsx)(Kf,{syncPref:v,candidates:_,provider:o,activeModel:s,setProvider:c,setModel:l,switchModel:d.switchModel})}),(0,X.jsx)(Qa,{value:`routing`,className:`mt-0`,children:(0,X.jsx)(ym,{syncPref:v,candidates:_})}),(0,X.jsx)(Qa,{value:`fleet`,className:`mt-0`,children:(0,X.jsx)(qf,{syncPref:v})}),(0,X.jsx)(Qa,{value:`integrations`,className:`mt-0`,children:(0,X.jsx)(ip,{syncPref:v})}),(0,X.jsx)(Qa,{value:`chimera`,className:`mt-0 space-y-6`,children:(0,X.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:(0,X.jsx)(Ff,{syncPref:v,sessionProvider:o,sessionModel:s})})}),(0,X.jsxs)(Qa,{value:`context`,className:`mt-0 space-y-6`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(yt,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:context.flagsHeading`)})})]}),(0,X.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-2`,children:[(0,X.jsx)($,{label:g(`settings:context.mcpLabel`),hint:g(`settings:context.mcpHint`),value:h.featureMcp,onChange:()=>v(`featureMcp`,!h.featureMcp)}),(0,X.jsx)($,{label:g(`settings:context.pluginsLabel`),hint:g(`settings:context.pluginsHint`),value:h.featurePlugins,onChange:()=>v(`featurePlugins`,!h.featurePlugins)}),(0,X.jsx)($,{label:g(`settings:context.memoryLabel`),hint:g(`settings:context.memoryHint`),value:h.featureMemory,onChange:()=>v(`featureMemory`,!h.featureMemory)}),(0,X.jsx)($,{label:g(`settings:context.skillsLabel`),hint:g(`settings:context.skillsHint`),value:h.featureSkills,onChange:()=>v(`featureSkills`,!h.featureSkills)}),(0,X.jsx)($,{label:g(`settings:context.modelsRegistryLabel`),hint:g(`settings:context.modelsRegistryHint`),value:h.featureModelsRegistry,onChange:()=>v(`featureModelsRegistry`,!h.featureModelsRegistry)}),(0,X.jsx)($,{label:g(`settings:context.indexOnStartLabel`),hint:g(`settings:context.indexOnStartHint`),value:h.indexOnStart,onChange:()=>v(`indexOnStart`,!h.indexOnStart)})]})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(yt,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:context.compactorStrategyLabel`)})})]}),(0,X.jsx)($,{label:g(`settings:context.autoCompactLabel`),hint:g(`settings:context.autoCompactHint`),value:h.contextAutoCompact,onChange:()=>v(`contextAutoCompact`,!h.contextAutoCompact)}),(0,X.jsx)(Q,{label:g(`settings:context.compactorStrategyLabel`),hint:g(`settings:context.compactorStrategyHint`),value:h.contextStrategy,options:[{value:`hybrid`,label:g(`settings:context.compactorStrategyHybrid`)},{value:`intelligent`,label:g(`settings:context.compactorStrategyIntelligent`)},{value:`selective`,label:g(`settings:context.compactorStrategySelective`)}],onChange:e=>v(`contextStrategy`,e)}),(0,X.jsx)(Q,{label:g(`settings:context.contextModeLabel`),hint:g(`settings:context.contextModeHint`),value:h.contextMode,options:[{value:`balanced`,label:g(`settings:context.contextModeBalanced`)},{value:`frugal`,label:g(`settings:context.contextModeFrugal`)},{value:`deep`,label:g(`settings:context.contextModeDeep`)}],onChange:e=>v(`contextMode`,e)}),(0,X.jsx)(Q,{label:g(`settings:context.tokenSavingLabel`),hint:g(`settings:context.tokenSavingHint`),value:h.tokenSavingTier,options:[{value:`off`,label:g(`settings:context.tokenSavingOff`)},{value:`minimal`,label:g(`settings:context.tokenSavingMinimal`)},{value:`light`,label:g(`settings:context.tokenSavingLight`)},{value:`medium`,label:g(`settings:context.tokenSavingMedium`)},{value:`aggressive`,label:g(`settings:context.tokenSavingAggressive`)}],onChange:e=>v(`tokenSavingTier`,e)})]}),(0,X.jsx)(up,{})]}),(0,X.jsx)(Qa,{value:`logs`,className:`mt-0 space-y-6`,children:(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,X.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,X.jsx)(Wn,{className:`h-5 w-5`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`settings:logs.heading`)})})]}),(0,X.jsx)(Q,{label:g(`settings:logs.logLevelLabel`),hint:g(`settings:logs.logLevelHint`),value:h.logLevel,options:[{value:`debug`,label:g(`settings:logs.logLevelDebug`)},{value:`info`,label:g(`settings:logs.logLevelInfo`)},{value:`warn`,label:g(`settings:logs.logLevelWarn`)},{value:`error`,label:g(`settings:logs.logLevelError`)}],onChange:e=>v(`logLevel`,e)}),(0,X.jsx)(Q,{label:g(`settings:logs.auditLevelLabel`),hint:g(`settings:logs.auditLevelHint`),value:h.auditLevel,options:[{value:`minimal`,label:g(`settings:logs.auditLevelMinimal`)},{value:`standard`,label:g(`settings:logs.auditLevelStandard`)},{value:`full`,label:g(`settings:logs.auditLevelFull`)}],onChange:e=>v(`auditLevel`,e)}),(0,X.jsx)(Q,{label:g(`settings:logs.fsAccessLabel`),hint:g(`settings:logs.fsAccessHint`),value:h.fsAccess,options:[{value:`unrestricted`,label:g(`settings:logs.fsAccessUnrestricted`)},{value:`project`,label:g(`settings:logs.fsAccessProject`)}],onChange:e=>v(`fsAccess`,e)}),(0,X.jsx)($,{label:g(`settings:logs.debugStreamLabel`),hint:g(`settings:logs.debugStreamHint`),value:h.debugStream,onChange:()=>v(`debugStream`,!h.debugStream)})]})}),(0,X.jsx)(Qa,{value:`security`,className:`mt-0`,children:(0,X.jsx)(Xm,{})}),(0,X.jsx)(Qa,{value:`display`,className:`mt-0`,children:(0,X.jsx)(Bf,{syncPref:v})})]})]})})}),(0,X.jsx)(Ri,{open:re,onOpenChange:P,children:(0,X.jsxs)(Fi,{showCloseButton:!1,children:[(0,X.jsxs)(Ni,{children:[(0,X.jsx)(Ii,{children:g(`settings:resetConfirmTitle`)}),(0,X.jsx)(Li,{children:g(`settings:resetConfirmBody`)})]}),(0,X.jsxs)(Pi,{className:`gap-2 sm:gap-0`,children:[(0,X.jsx)(J,{variant:`outline`,onClick:()=>P(!1),children:g(`settings:cancel`)}),(0,X.jsx)(J,{variant:`destructive`,onClick:ie,children:g(`settings:resetConfirmAction`)})]})]})})]})}var $m=(0,Y.lazy)(()=>B(()=>import(`./AnalyticsDashboard-C9aPEyov.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([28,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23]))),eh=(0,Y.lazy)(()=>B(()=>import(`./AgentRosterView-BwukmHoA.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([29,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,0,8,21,20,22,23,24,26,30,18,25,31]))),th=(0,Y.lazy)(()=>B(()=>import(`./ChangesView-DumffowD.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([32,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,33,34]))),nh=(0,Y.lazy)(()=>B(()=>import(`./ChronicleDashboard-BYGV5twz.js`).then(e=>({default:e.ChronicleDashboard})),__vite__mapDeps([35,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8]))),rh=(0,Y.lazy)(()=>B(()=>import(`./CodeEditor-D2Dnax7e.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([36,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,20,21,19,22,23,24,33,34,37,38,39]))),ih=(0,Y.lazy)(()=>B(()=>import(`./CodeMap-DIKKs3Ux.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([40,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,20,25]))),ah=(0,Y.lazy)(()=>B(()=>import(`./DebugDashboard-BI3EmXrM.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([41,1,2,3,4,5,6,10,11,12,13,14,15,16,17]))),oh=(0,Y.lazy)(()=>B(()=>import(`./DesignGalleryView-DMW6Ab__.js`).then(e=>({default:e.DesignGalleryView})),__vite__mapDeps([42,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26]))),sh=(0,Y.lazy)(()=>B(()=>import(`./GoalView-3291Hxnb.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([43,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,18,0,8,20,21,22,23,24,25,26,38,44,27,45]))),ch=(0,Y.lazy)(()=>B(()=>import(`./KanbanView-CFE63A4a.js`).then(e=>({default:e.KanbanView})),__vite__mapDeps([46,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,30,18,24,25,26,47]))),lh=(0,Y.lazy)(()=>B(()=>import(`./MailboxDetailView-CUTWkSyK.js`).then(e=>({default:e.MailboxDetailView})),__vite__mapDeps([48,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,22,23,24,33]))),uh=(0,Y.lazy)(()=>B(()=>import(`./OfficeMapPanel-Q81eioDB.js`).then(e=>({default:e.OfficeMapPanel})),__vite__mapDeps([49,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,50]))),dh=(0,Y.lazy)(()=>B(()=>import(`./RefreshDebugView-DfBYFPEF.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([51,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,8,23]))),fh=(0,Y.lazy)(()=>B(()=>import(`./SageTabs-olgLJfg_.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([52,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7]))),ph=(0,Y.lazy)(()=>B(()=>import(`./RequirementIntakeView-CNAFKiQ3.js`).then(e=>({default:e.RequirementIntakeView})),__vite__mapDeps([53,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,38,45]))),mh=(0,Y.lazy)(()=>B(()=>import(`./SddHub-7Z55QY-M.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([54,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,38,30,47,55]))),hh=(0,Y.lazy)(()=>B(()=>import(`./SessionsDashboard-CridPbkX.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([56,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,57,44,27,38,45]))),gh=(0,Y.lazy)(()=>B(()=>import(`./SessionInspectView-CytBw7Y9.js`).then(e=>({default:e.SessionInspectView})),__vite__mapDeps([58,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,57,44,27,38,45]))),_h=(0,Y.lazy)(()=>B(()=>import(`./SkillDetailView-Cp-xEHww.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([59,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,33]))),vh=(0,Y.lazy)(()=>B(()=>import(`./TechStackView-CvUiAISX.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([60,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,21,19,0,8,20,22,23,38,45]))),yh=(0,Y.lazy)(()=>B(()=>import(`./DeadCodeScanPanel-DaeHUzc5.js`).then(e=>({default:e.DeadCodeScanPanel})),__vite__mapDeps([61,1,2,3,4,5,6,10,11,12,13,14,15,16,17])));function bh({sessionId:e,desktopShell:t}){let{t:n}=R(),{currentView:r,terminalOpen:i,setTerminalOpen:a}=G(fn(e=>({currentView:e.currentView,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen})));return(0,X.jsxs)(X.Fragment,{children:[r===`chat`&&(0,X.jsxs)(X.Fragment,{children:[e&&(0,X.jsx)(`div`,{className:`ws-workspace-dock-wrap shrink-0 px-3 pt-2 sm:px-4`,children:(0,X.jsx)(Tl,{})}),(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.chat`),children:(0,X.jsx)(Zd,{})})]}),r===`settings`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.settings`),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(Qm,{})})}),r===`memory`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.sageMemory`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sageMemory`)})}),children:(0,X.jsx)(fh,{})})}),r===`roster`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.agentRoster`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.agentRoster`)})}),children:(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,X.jsx)(eh,{})})})}),r===`context`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.contextDashboard`),children:(0,X.jsx)(vf,{})}),r===`setup`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.setup`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(xh,{})})})}),r===`goal`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.goal`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(sh,{onClose:()=>K(`chat`)})})})}),r===`sddhub`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.sddHub`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(mh,{})})})}),r===`kanban`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.kanban`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(ch,{onClose:()=>K(`chat`)})})})}),r===`sessions`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.sessions`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(hh,{})})})}),r===`session-inspect`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.sessionInspect`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sessionInspect`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(gh,{})})})}),r===`chronicle`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.chronicle`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(nh,{})})})}),r===`intake`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.requirementsIntake`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(ph,{})})})}),r===`debug`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.debugDashboard`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(ah,{})})})}),r===`refresh-debug`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.refreshDebug`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(dh,{})})})}),r===`files`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.editor`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.editor`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(rh,{})})})}),r===`changes`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.changes`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.changes`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(th,{className:`h-full min-h-0`})})})}),r===`mailbox`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.mailbox`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(lh,{className:`h-full min-h-0`})})})}),r===`design-gallery`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.designGallery`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(oh,{className:`h-full`})})})}),r===`skill`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.skill`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(_h,{className:`h-full`})})})}),r===`officemap`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.officeMap`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.officeMap`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(uh,{})})})}),r===`analytics`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.analytics`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)($m,{})})})}),r===`codemap`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.codemap`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.codemap`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(ih,{})})})}),r===`techstack`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.techstack`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.techstack`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,X.jsx)(vh,{})})})}),r===`deadcode`&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.deadcode`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.deadcode`)})}),children:(0,X.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto`,children:(0,X.jsx)(yh,{})})})}),i&&(0,X.jsx)(Z,{level:`panel`,name:n(`activity:panels.terminal`),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(yf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.terminal`)})}),children:(0,X.jsx)(Sh,{desktopShell:t,onClose:()=>a(!1)})})})]})}var xh=(0,Y.lazy)(()=>B(()=>import(`./SetupScreen-BkVjdky4.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([62,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,38,45]))),Sh=(0,Y.lazy)(()=>B(()=>import(`./TerminalPanel-Dg5hqYTA.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([63,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,64,65])));(0,Y.lazy)(()=>B(()=>import(`./AnalyticsDashboard-C9aPEyov.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([28,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23]))),(0,Y.lazy)(()=>B(()=>import(`./CodeMap-DIKKs3Ux.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([40,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,20,25]))),(0,Y.lazy)(()=>B(()=>import(`./ChronicleDashboard-BYGV5twz.js`).then(e=>({default:e.ChronicleDashboard})),__vite__mapDeps([35,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8]))),(0,Y.lazy)(()=>B(()=>import(`./GoalView-3291Hxnb.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([43,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,18,0,8,20,21,22,23,24,25,26,38,44,27,45]))),(0,Y.lazy)(()=>B(()=>import(`./ChangesView-DumffowD.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([32,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,33,34])));var Ch=(0,Y.lazy)(()=>B(()=>import(`./CronJobsPanel-CJ7Vc1Am.js`).then(e=>({default:e.CronJobsPanel})),__vite__mapDeps([66,1,2,3,4,5,6,10,11,12,13,14,15,16,17,21,19,7,0,8,20,22,23,27])));(0,Y.lazy)(()=>B(()=>import(`./CodeEditor-D2Dnax7e.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([36,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,20,21,19,22,23,24,33,34,37,38,39]))),(0,Y.lazy)(()=>B(()=>import(`./DebugDashboard-BI3EmXrM.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([41,1,2,3,4,5,6,10,11,12,13,14,15,16,17]))),(0,Y.lazy)(()=>B(()=>import(`./DesignGalleryView-DMW6Ab__.js`).then(e=>({default:e.DesignGalleryView})),__vite__mapDeps([42,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26]))),(0,Y.lazy)(()=>B(()=>import(`./MailboxDetailView-CUTWkSyK.js`).then(e=>({default:e.MailboxDetailView})),__vite__mapDeps([48,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,22,23,24,33]))),(0,Y.lazy)(()=>B(()=>import(`./SageTabs-olgLJfg_.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([52,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7]))),(0,Y.lazy)(()=>B(()=>import(`./AgentRosterView-BwukmHoA.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([29,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,0,8,21,20,22,23,24,26,30,18,25,31]))),(0,Y.lazy)(()=>B(()=>import(`./KanbanView-CFE63A4a.js`).then(e=>({default:e.KanbanView})),__vite__mapDeps([46,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,30,18,24,25,26,47]))),(0,Y.lazy)(()=>B(()=>import(`./OfficeMapPanel-Q81eioDB.js`).then(e=>({default:e.OfficeMapPanel})),__vite__mapDeps([49,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,50])));var wh=(0,Y.lazy)(()=>B(()=>import(`./ProcessMonitor-TGqyXxmB.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([9,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27]))),Th=(0,Y.lazy)(()=>B(()=>import(`./QueuePanel-5aMgQbHv.js`).then(e=>({default:e.QueuePanel})),__vite__mapDeps([67,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,21,0,8,20,22,23,27])));(0,Y.lazy)(()=>B(()=>import(`./RefreshDebugView-DfBYFPEF.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([51,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,8,23]))),(0,Y.lazy)(()=>B(()=>import(`./SddHub-7Z55QY-M.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([54,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,38,30,47,55]))),(0,Y.lazy)(()=>B(()=>import(`./SessionsDashboard-CridPbkX.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([56,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,57,44,27,38,45]))),(0,Y.lazy)(()=>B(()=>import(`./SetupScreen-BkVjdky4.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([62,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,38,45]))),(0,Y.lazy)(()=>B(()=>import(`./SkillDetailView-Cp-xEHww.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([59,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,27,33]))),(0,Y.lazy)(()=>B(()=>import(`./SpecsView-DUx1sgtH.js`).then(e=>({default:e.SpecsView})),__vite__mapDeps([55,1,2,3,4,5,6,10,11,12,13,14,15,16,17,18,19,7,0,8,20,21,22,23,24,25,26,38]))),(0,Y.lazy)(()=>B(()=>import(`./TechStackView-CvUiAISX.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([60,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,21,19,0,8,20,22,23,38,45]))),(0,Y.lazy)(()=>B(()=>import(`./TerminalPanel-Dg5hqYTA.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([63,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,64,65])));function Eh(){let{t:e}=R(),{theme:t}=Ga(),n=Vr(),{currentView:i,sidebarOpen:a,toggleSidebar:o,setSearchOpen:s,setSidebarOpen:c,setInspectorTab:l,setPaletteOpen:u,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,toggleInspector:m,setFleetMonitorOpen:h,setAgentsMonitorOpen:g,processMonitorOpen:_,setProcessMonitorOpen:v,queuePanelOpen:y,setQueuePanelOpen:b,cronJobsOpen:x,setCronJobsOpen:S,setTerminalOpen:C}=G(fn(e=>({currentView:e.currentView,sidebarOpen:e.sidebarOpen,toggleSidebar:e.toggleSidebar,setSearchOpen:e.setSearchOpen,setSidebarOpen:e.setSidebarOpen,setInspectorTab:e.setInspectorTab,setPaletteOpen:e.setPaletteOpen,setShortcutsOpen:e.setShortcutsOpen,setModelSwitcherOpen:e.setModelSwitcherOpen,setPromptLibraryOpen:e.setPromptLibraryOpen,toggleInspector:e.toggleInspector,setFleetMonitorOpen:e.setFleetMonitorOpen,setAgentsMonitorOpen:e.setAgentsMonitorOpen,processMonitorOpen:e.processMonitorOpen,setProcessMonitorOpen:e.setProcessMonitorOpen,queuePanelOpen:e.queuePanelOpen,setQueuePanelOpen:e.setQueuePanelOpen,cronJobsOpen:e.cronJobsOpen,setCronJobsOpen:e.setCronJobsOpen,setTerminalOpen:e.setTerminalOpen}))),w=r(e=>e.isLoading),T=U(e=>e.iteration),E=U(e=>e.projectName),D=U(e=>e.session?.title),O=U(e=>e.session?.id),k=G(e=>O?e.sessionNicknames[O]:void 0),A=G(e=>e.sideContextBreakdownOpen),j=G(e=>e.setSideContextBreakdownOpen);ni(e=>e.agents),Ba({setPaletteOpen:u,setSearchOpen:s,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,setFleetMonitorOpen:h,setAgentsMonitorOpen:g,setProcessMonitorOpen:v,setQueuePanelOpen:b,setCronJobsOpen:S,setTerminalOpen:C}),(0,Y.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?ki(`debug`):window.location.pathname===`/analytics`?ki(`analytics`):window.location.pathname===`/refresh-debug`&&ki(`refresh-debug`))},[]),(0,Y.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=V(W.getState().wsUrl);n&&n.send({type:`files.read`,payload:{filePath:t}})};return window.addEventListener(`wrongstack:open-file`,e),()=>window.removeEventListener(`wrongstack:open-file`,e)},[]),(0,Y.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=di.getState().openFiles.find(e=>e.path===t);if(!n)return;let r=V(W.getState().wsUrl);r&&r.send({type:`files.write`,payload:{filePath:t,content:n.content}})};return window.addEventListener(`wrongstack:save-file`,e),()=>window.removeEventListener(`wrongstack:save-file`,e)},[]);let{isMobile:M}=Rr();(0,Y.useEffect)(()=>{M&&G.getState().sidebarOpen&&c(!1)},[M,c]);let N=M&&a;return Ir(),Va(),(0,Y.useEffect)(()=>{let e=[];if(w){let t=T?` iter ${T.index}${T.max?`/${T.max}`:``}`:``;e.push(`●${t}`)}let t=k?.trim()||D?.trim(),n=E?.trim();t&&e.push(t),n&&e.push(n),e.length===0&&e.push(n||`AI Agent`);let r=e.filter(Boolean).join(` · `);return document.title=r,()=>{document.title=E||`AI Agent`}},[w,T,E,D,k]),Ha({toggleSidebar:o,setSearchOpen:s,toggleInspector:m,setInspectorTab:l}),(0,X.jsxs)(`div`,{"data-shell":n?`desktop`:`browser`,className:H(`ws-app-root flex min-h-0 min-w-0 overflow-hidden`,n&&`ws-desktop-shell`,t),children:[(0,X.jsx)(`a`,{href:`#main-content`,className:`sr-only focus:not-sr-only focus:absolute focus:top-2 focus:left-2 focus:z-[100] focus:rounded-md focus:bg-background focus:px-3 focus:py-1.5 focus:text-sm focus:font-medium focus:shadow-lg focus:ring-2 focus:ring-primary`,children:e(`activity:app.skipToContent`)}),i!==`setup`&&(0,X.jsx)(Ta,{desktopShell:n}),a&&i!==`setup`&&(0,X.jsx)(Uc,{desktopShell:n}),(0,X.jsxs)(`main`,{id:`main-content`,className:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden bg-background/70`,...N?{inert:!0}:{},children:[i!==`setup`&&(0,X.jsx)(fs,{currentView:i,projectName:E,sessionLabel:k||D||O||void 0,isLoading:w,iteration:T??null,onPalette:()=>u(!0),onSearch:()=>s(!0),onModel:()=>f(!0),onSettings:()=>Ai(`settings`)}),i!==`setup`&&(0,X.jsx)(Cs,{}),i!==`setup`&&(0,X.jsx)(ws,{}),(0,X.jsx)(bh,{sessionId:O??null,desktopShell:n})]}),i!==`setup`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.inspector`),children:(0,X.jsx)(as,{})}),O&&i===`chat`&&(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.workspaceInspector`),children:(0,X.jsx)(Dl,{sessionId:O})})]}),_&&(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.processMonitor`),children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(wh,{open:_,onClose:()=>v(!1)})})}),y&&(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.queue`),children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Th,{open:y,onClose:()=>b(!1)})})}),x&&(0,X.jsx)(Z,{level:`panel`,name:e(`activity:panels.cronJobs`),children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Ch,{open:x,onClose:()=>S(!1)})})}),(0,X.jsx)(Ms,{}),A&&(0,X.jsx)(Ds,{open:A,onClose:()=>j(!1)}),(0,X.jsx)(Ss,{}),(0,X.jsx)(Ui,{}),(0,X.jsx)(Vi,{}),(0,X.jsx)(Ra,{}),(0,X.jsx)(Rs,{}),(0,X.jsx)(Ps,{}),(0,X.jsx)(Fs,{}),(0,X.jsx)(Mi,{})]})}function Dh(){return(0,X.jsx)(Z,{children:(0,X.jsx)(Wa,{defaultTheme:`system`,children:(0,X.jsx)(Eh,{})})})}Ji.createRoot(t(document.getElementById(`root`))).render((0,X.jsx)(Y.StrictMode,{children:(0,X.jsx)(Dh,{})}));export{Ya as C,qa as D,Za as E,Ga as O,Po as S,Xa as T,qs as _,fp as a,Ko as b,Qd as c,Ju as d,Ku as f,Xs as g,ml as h,vp as i,Td as l,vl as m,yp as n,Yf as o,bl as p,bp as r,Gf as s,xp as t,Xu as u,_s as v,Qa as w,Go as x,hs as y};