@wrongstack/webui 0.307.0 → 0.308.0

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 (65) hide show
  1. package/dist/assets/{AgentRosterView-DYAdqgOi.js → AgentRosterView-CIUKmLsb.js} +1 -1
  2. package/dist/assets/{AnalyticsDashboard-BnRP4jRR.js → AnalyticsDashboard-B5nVNt6L.js} +1 -1
  3. package/dist/assets/{AudienceMemoryPanel-CLHvzRH_.js → AudienceMemoryPanel-8nS326Uh.js} +1 -1
  4. package/dist/assets/{ChangesView-35TNNOyK.js → ChangesView-mapTz0_T.js} +1 -1
  5. package/dist/assets/{ChronicleDashboard-BkAPjMg8.js → ChronicleDashboard-DUzceZNb.js} +1 -1
  6. package/dist/assets/{CodeEditor-CJdcj7Lh.js → CodeEditor-OjU9rotb.js} +1 -1
  7. package/dist/assets/{CodeMap-BNfs5wrd.js → CodeMap-BB1WETLd.js} +1 -1
  8. package/dist/assets/{ConfirmModal-D0FaeNr8.js → ConfirmModal-LBZaZgsG.js} +1 -1
  9. package/dist/assets/{CronJobsPanel-DK10t9ty.js → CronJobsPanel-DJaiJw1W.js} +1 -1
  10. package/dist/assets/{DeadCodeScanPanel-CwpRRLLW.js → DeadCodeScanPanel-nlQ9nL3Y.js} +1 -1
  11. package/dist/assets/{DebugDashboard-BvQrhE38.js → DebugDashboard-BwSbR59I.js} +1 -1
  12. package/dist/assets/{DesignGalleryView-DSYCeZWp.js → DesignGalleryView-DLKWmyVp.js} +1 -1
  13. package/dist/assets/{GoalView-DjrhT9dw.js → GoalView-BtSGdftD.js} +1 -1
  14. package/dist/assets/{KanbanView-oxhKdDA1.js → KanbanView-CyVG4DQu.js} +1 -1
  15. package/dist/assets/{MailboxDetailView-DVwTJlVk.js → MailboxDetailView-2NJVLrjb.js} +1 -1
  16. package/dist/assets/{MemoryDrawer-DL8ORfEs.js → MemoryDrawer-n3cwB9m3.js} +1 -1
  17. package/dist/assets/{MemoryManager-CfbOPMAN.js → MemoryManager-CetsTR6O.js} +1 -1
  18. package/dist/assets/{ModelPicker-BfnL3Y17.js → ModelPicker-B21-QbDB.js} +1 -1
  19. package/dist/assets/{OfficeMapPanel-PO-Ziqir.js → OfficeMapPanel-BKHjEIu9.js} +1 -1
  20. package/dist/assets/{ProcessMonitor-C5kib2h4.js → ProcessMonitor-9TOnqT6l.js} +1 -1
  21. package/dist/assets/PromptJournalView-0F-HTGHg.js +1 -0
  22. package/dist/assets/{QueuePanel-Cgo0AeCj.js → QueuePanel--PTd2-7z.js} +1 -1
  23. package/dist/assets/{RefreshDebugView-B_doTjkD.js → RefreshDebugView-CuKbgI-T.js} +1 -1
  24. package/dist/assets/{RequirementIntakeView-BPXI8cu2.js → RequirementIntakeView-DnNSLw78.js} +1 -1
  25. package/dist/assets/{SageTabs-DWdF_2PE.js → SageTabs-B-m4WBoA.js} +2 -2
  26. package/dist/assets/{SddFlowGraph-Ck97BG1F.js → SddFlowGraph-DdYgCVM_.js} +1 -1
  27. package/dist/assets/{SddHub-BcqPr8Hj.js → SddHub-DZCKF3Gw.js} +1 -1
  28. package/dist/assets/{SessionInspectView-TFuvc8uU.js → SessionInspectView-Cf4ypYKn.js} +1 -1
  29. package/dist/assets/{SessionList-CwVI8eZL.js → SessionList-D4D2Cai9.js} +1 -1
  30. package/dist/assets/{SessionsDashboard-Bc1iSTBm.js → SessionsDashboard-DoAbZStd.js} +1 -1
  31. package/dist/assets/{SetupScreen-DT4PMl9C.js → SetupScreen-CMrLwoo9.js} +1 -1
  32. package/dist/assets/{SkillDetailView-DoXu60GN.js → SkillDetailView-sVjQG3qG.js} +1 -1
  33. package/dist/assets/{SpecsView-CoL5_ZKF.js → SpecsView-B53AUOo3.js} +1 -1
  34. package/dist/assets/{TechStackView-CTf7eM_K.js → TechStackView-iONTty84.js} +1 -1
  35. package/dist/assets/{TerminalPanel-BowAkbec.js → TerminalPanel-1mqoe2_8.js} +1 -1
  36. package/dist/assets/{Toaster-Dnn83kq_.js → Toaster-wXvKXbbS.js} +1 -1
  37. package/dist/assets/{activity-DGss9yYZ.js → activity-C0qPnCbW.js} +1 -1
  38. package/dist/assets/{activity-DWf-x6Rd.js → activity-DTSVEiLK.js} +1 -1
  39. package/dist/assets/{activity-Chofrfz8.js → activity-DWHlYL9x.js} +1 -1
  40. package/dist/assets/{activity-BAmXZRX5.js → activity-DjnYvN9C.js} +1 -1
  41. package/dist/assets/{activity-5tPFRU1U.js → activity-fdbTRXeg.js} +2 -2
  42. package/dist/assets/{activity-B7udcp0S.js → activity-jL8-j1D0.js} +1 -1
  43. package/dist/assets/{activity-BrRl22KD.js → activity-phJuGuf4.js} +1 -1
  44. package/dist/assets/{i18n-O7wMOn8G.js → i18n-CDoHRskt.js} +2 -2
  45. package/dist/assets/{index-C7U_T9PB.css → index-BRs425Ir.css} +1 -1
  46. package/dist/assets/{index-CzVjuusy.js → index-BUQkH6BW.js} +5 -5
  47. package/dist/assets/{roster-ws-LJR_IyEw.js → roster-ws-Cinqwkgb.js} +1 -1
  48. package/dist/assets/{stores-CmkcHezT.js → stores-B0SETQK4.js} +1 -1
  49. package/dist/assets/ui-store-xx1NssJI.js +1 -0
  50. package/dist/assets/{useWebSocket-7Vm7doHG.js → useWebSocket-DCx7NrvL.js} +1 -1
  51. package/dist/assets/vector-memory-panel-D1zQSMIW.js +1 -0
  52. package/dist/assets/{view-navigation-BiljGQYK.js → view-navigation-CZKugncK.js} +1 -1
  53. package/dist/assets/ws-client-C2ppA8xa.js +1 -0
  54. package/dist/components/PromptJournalView.d.ts +2 -0
  55. package/dist/components/vector-memory-panel/index.d.ts +7 -0
  56. package/dist/components/vector-memory-panel/model.d.ts +37 -0
  57. package/dist/index.html +12 -12
  58. package/dist/index.js +3315 -2528
  59. package/dist/lib/view-navigation.d.ts +1 -1
  60. package/dist/stores/ui-store.d.ts +3 -3
  61. package/dist/types/client-message.d.ts +11 -0
  62. package/dist/types/server-message.d.ts +32 -0
  63. package/package.json +8 -8
  64. package/dist/assets/ui-store-tCiy1eTu.js +0 -1
  65. package/dist/assets/ws-client-C4OHn-_g.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ws-client-C4OHn-_g.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-C_zEzV4N.js","assets/monaco-BCqJp2xW.js","assets/monaco-Bowa0-zp.css","assets/markdown-CIRD7kOg.js","assets/vendor-BMdWcCR4.css","assets/utils-tsZEnrBH.js","assets/session-store-BgiP4PnQ.js","assets/ProcessMonitor-C5kib2h4.js","assets/i18n-O7wMOn8G.js","assets/activity-5tPFRU1U.js","assets/chat-CzaGXz_W.js","assets/commandPalette-BovBiPec.js","assets/common-BBHmIHQW.js","assets/settings-CbtB0i7o.js","assets/setup-DfcCCvUO.js","assets/toasts-DOfXc7Rt.js","assets/useWebSocket-7Vm7doHG.js","assets/chat-store-c0pGYczr.js","assets/codemap-activity-store-BH7Mh4k9.js","assets/stores-CmkcHezT.js","assets/mailbox-store-bF96Ih2G.js","assets/ui-store-tCiy1eTu.js","assets/view-navigation-BiljGQYK.js","assets/codemap-index-store-BFm1TzVW.js","assets/Toaster-Dnn83kq_.js","assets/dialog-BJjDUqb3.js","assets/AnalyticsDashboard-BnRP4jRR.js","assets/AgentRosterView-DYAdqgOi.js","assets/ModelPicker-BfnL3Y17.js","assets/roster-ws-LJR_IyEw.js","assets/ChangesView-35TNNOyK.js","assets/empty-state-Cefmzojx.js","assets/monaco-theme-CR1QvFi2.js","assets/ChronicleDashboard-BkAPjMg8.js","assets/CodeEditor-CJdcj7Lh.js","assets/MemoryDrawer-DL8ORfEs.js","assets/button-DvpRpKkt.js","assets/shared-B3czc2Dj.js","assets/CodeMap-BNfs5wrd.js","assets/DebugDashboard-BvQrhE38.js","assets/DesignGalleryView-DSYCeZWp.js","assets/GoalView-DjrhT9dw.js","assets/ConfirmModal-D0FaeNr8.js","assets/input-BtoHcCl9.js","assets/KanbanView-oxhKdDA1.js","assets/SddFlowGraph-Ck97BG1F.js","assets/MailboxDetailView-DVwTJlVk.js","assets/OfficeMapPanel-PO-Ziqir.js","assets/OfficeMapPanel-D6yTfGIT.css","assets/RefreshDebugView-B_doTjkD.js","assets/SageTabs-DWdF_2PE.js","assets/RequirementIntakeView-BPXI8cu2.js","assets/SddHub-BcqPr8Hj.js","assets/SpecsView-CoL5_ZKF.js","assets/SessionsDashboard-Bc1iSTBm.js","assets/SessionList-CwVI8eZL.js","assets/SessionInspectView-TFuvc8uU.js","assets/SkillDetailView-DoXu60GN.js","assets/TechStackView-CTf7eM_K.js","assets/DeadCodeScanPanel-CwpRRLLW.js","assets/SetupScreen-DT4PMl9C.js","assets/TerminalPanel-BowAkbec.js","assets/xterm-BWzBEEhg.js","assets/xterm-BrP-ENHg.css","assets/CronJobsPanel-DK10t9ty.js","assets/QueuePanel-Cgo0AeCj.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t,r as n,t as r}from"./chat-store-c0pGYczr.js";import{$ as i,$i as a,$n as o,$r as s,$t as c,A as l,Aa as u,An as d,Ar as f,At as p,B as m,Ba as h,Bt as g,C as _,Ca as v,Ci as y,Cn as b,D as x,Da as S,Di as C,Dn as w,Dt as T,E,Ea as D,En as O,Er as k,F as A,Fn as j,Ft as M,G as ee,Ga as N,Gn as te,Gr as P,Gt as F,H as I,Hr as ne,Ht as re,I as ie,Ii as L,In as ae,It as oe,J as se,Ji as R,Jn as ce,K as le,Ki as ue,Kn as de,Kr as fe,Kt as pe,L as me,La as he,Li as ge,Ln as _e,Lr as ve,Lt as ye,M as be,Mi as xe,Mr as Se,Mt as Ce,N as we,Na as Te,Ni as Ee,Nr as De,Nt as Oe,O as ke,Oa as Ae,Oi as je,On as Me,Or as Ne,Ot as Pe,P as Fe,Pa as Ie,Pi as Le,Pn as Re,Pr as ze,Pt as Be,Q as Ve,Qi as He,Qn as Ue,Qr as We,Qt as Ge,R as Ke,Ri as qe,Rn 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,Ta as rt,Ti as it,Tn as at,Tr as ot,U as st,Ua as z,Ui as ct,Un as lt,Ur as ut,V as dt,Vn as ft,Vr as pt,W as mt,Wa as ht,Wn as gt,Wt as _t,X as vt,Xi as yt,Xn as bt,Xr as xt,Y as St,Yi as Ct,Yn as wt,Yr as Tt,Z as Et,Zi as Dt,Zn as Ot,Zr as kt,Zt as At,_i as jt,_r as Mt,_t as Nt,aa as Pt,an as Ft,ar as It,at as Lt,ba as Rt,bi as zt,bn as Bt,br as Vt,ca as Ht,ci as Ut,cr as Wt,da as Gt,di as Kt,dr as qt,dt as Jt,ea as Yt,ei as Xt,er as Zt,et as Qt,fa as $t,fi as en,fr as tn,ft as nn,ga as rn,gi as an,gn as on,gt as sn,hn as cn,ht as ln,ii as un,in as dn,ir as fn,it as pn,j as mn,jn as hn,jr as gn,jt as _n,k as vn,ka as yn,kn as bn,kr as xn,kt as Sn,la as Cn,li as wn,ln as Tn,lr as En,lt as Dn,ma as On,mi as kn,mn as An,mr as jn,mt as Mn,na as Nn,nn as Pn,nr as Fn,nt as In,oa as Ln,or as Rn,ot as zn,pi as Bn,pn as Vn,pt as Hn,q as Un,qi as Wn,qn as Gn,qr as Kn,qt as qn,ra as Jn,ri as Yn,rn as Xn,rr as Zn,rt as Qn,sa as $n,si as er,sn as tr,st as nr,ta as rr,ti as ir,tn as ar,tr as or,tt as sr,ua as cr,ut as lr,va as ur,vn as dr,vr as fr,vt as pr,w as mr,wa as hr,wi as gr,wn as _r,wr as vr,wt as yr,xi as br,xr,xt as Sr,yi as Cr,yn as wr,yr as Tr,yt as Er,z as Dr,za as Or,zi as kr,zn as Ar,zr as jr,zt as Mr}from"./vendor-C_zEzV4N.js";import{n as Nr,t as B}from"./i18n-O7wMOn8G.js";import{s as V}from"./monaco-BCqJp2xW.js";import{a as Pr,c as Fr,i as Ir,l as Lr,n as Rr,o as zr,r as Br,s as Vr,t as Hr,u as Ur}from"./useWebSocket-7Vm7doHG.js";import{l as Wr,t as H}from"./ws-client-C4OHn-_g.js";import{t as U}from"./utils-tsZEnrBH.js";import{t as W}from"./session-store-BgiP4PnQ.js";import{A as Gr,B as Kr,C as qr,D as Jr,E as Yr,H as Xr,I as G,L as Zr,M as Qr,N as $r,O as ei,P as ti,R as ni,S as ri,T as ii,U as ai,V as oi,_ as si,b as ci,d as li,f as ui,g as di,h as fi,j as pi,k as mi,l as hi,n as gi,o as _i,r as vi,t as yi,u as bi,w as xi,x as Si,y as Ci,z as wi}from"./stores-CmkcHezT.js";import{n as Ti,r as Ei,t as Di}from"./mailbox-store-bF96Ih2G.js";import{n as K,t as Oi}from"./ui-store-tCiy1eTu.js";import{a as ki,i as Ai,n as ji,o as q,r as Mi,t as Ni}from"./view-navigation-BiljGQYK.js";import{n as J,t as Pi}from"./Toaster-Dnn83kq_.js";import{a as Fi,i as Ii,n as Li,o as Ri,r as zi,t as Bi}from"./dialog-BJjDUqb3.js";import{t as Y}from"./button-DvpRpKkt.js";import{t as Vi}from"./input-BtoHcCl9.js";import{i as Hi,n as Ui,o as Wi,r as Gi,t as Ki}from"./ConfirmModal-D0FaeNr8.js";import{d as qi,p as Ji}from"./markdown-CIRD7kOg.js";import{n as Yi,t as Xi}from"./ModelPicker-BfnL3Y17.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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var X=e(N(),1),Zi=e(ht(),1),Qi=new Set([`chat`,`settings`,`goal`,`kanban`,`sddhub`,`files`,`changes`,`sessions`,`setup`,`skill`,`officemap`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`]),$i=new Set([`goal`,`fleet`,`work`,`worktrees`,`collab`]),ea=new Set([`todos`,`tasks`,`plan`]);function ta(){if(typeof window>`u`)return;let e=window.wrongstackDesktopHost;if(!e?.setPrefs)return;let t=B.getState();e.setPrefs({yolo:t.yolo,nextPrediction:t.nextPrediction,contextAutoCompact:t.contextAutoCompact})}function na(e){typeof window>`u`||window.wrongstackDesktopHost?.setReady?.(e)}function ra(e,t,n){typeof window>`u`||typeof e!=`string`||window.wrongstackDesktopHost?.ackCommand?.(e,t,n)}var Z=Dn(),ia=Qn,aa=nr,oa=X.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Z.jsxs)(zn,{ref:i,className:U(`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,Z.jsx)(Yt,{className:`ml-auto h-4 w-4`})]}));oa.displayName=zn.displayName;var sa=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Lt,{ref:n,className:U(`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}));sa.displayName=Lt.displayName;var ca=X.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Z.jsx)(sr,{children:(0,Z.jsx)(Et,{ref:r,sideOffset:t,className:U(`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})}));ca.displayName=Et.displayName;var la=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(Ve,{ref:r,className:U(`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}));la.displayName=Ve.displayName;var ua=X.forwardRef(({className:e,children:t,checked:n,...r},a)=>(0,Z.jsxs)(vt,{ref:a,className:U(`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,Z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Z.jsx)(i,{children:(0,Z.jsx)(Jn,{className:`h-4 w-4`})})}),t]}));ua.displayName=vt.displayName;var da=X.forwardRef(({className:e,children:t,...n},r)=>(0,Z.jsxs)(In,{ref:r,className:U(`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,Z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Z.jsx)(i,{children:(0,Z.jsx)(qe,{className:`h-2 w-2 fill-current`})})}),t]}));da.displayName=In.displayName;var fa=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(Qt,{ref:r,className:U(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));fa.displayName=Qt.displayName;var pa=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(pn,{ref:n,className:U(`-mx-1 my-1 h-px bg-muted`,e),...t}));pa.displayName=pn.displayName;var ma=({className:e,...t})=>(0,Z.jsx)(`span`,{className:U(`ml-auto text-xs tracking-widest opacity-60`,e),...t});ma.displayName=`DropdownMenuShortcut`;var ha=[{id:`chat`,icon:(0,Z.jsx)(wt,{size:16}),label:`Session`},{id:`files`,icon:(0,Z.jsx)(fe,{size:16}),label:`Files`},{id:`changes`,icon:(0,Z.jsx)(De,{size:16}),label:`Changes`},{id:`mailbox`,icon:(0,Z.jsx)(Zt,{size:16}),label:`Mailbox`},{id:`skills`,icon:(0,Z.jsx)(_t,{size:16}),label:`Skills`},{id:`worktrees`,icon:(0,Z.jsx)(ze,{size:16}),label:`Worktrees`},{id:`design`,icon:(0,Z.jsx)(Je,{size:16}),label:`Design Studio`},{id:`officemap`,icon:(0,Z.jsx)(Ht,{size:16}),label:`Office Map`}],ga=[{id:`settings`,icon:(0,Z.jsx)(ar,{size:16}),label:`Settings`},{id:`roster`,icon:(0,Z.jsx)(On,{size:16}),label:`Agent Roster`},{id:`sddhub`,icon:(0,Z.jsx)(ln,{size:16}),label:`SDD`},{id:`kanban`,icon:(0,Z.jsx)(je,{size:16}),label:`Kanban`},{id:`goal`,icon:(0,Z.jsx)(on,{size:16}),label:`Goal`},{id:`codemap`,icon:(0,Z.jsx)(ft,{size:16}),label:`CodeMap`},{id:`techstack`,icon:(0,Z.jsx)($t,{size:16}),label:`TechStack`},{id:`chronicle`,icon:(0,Z.jsx)(Pt,{size:16}),label:`Chronicle`},{id:`intake`,icon:(0,Z.jsx)(L,{size:16}),label:`Requirements`},{id:`memory`,icon:(0,Z.jsx)(Gt,{size:16}),label:`Memory`}],_a=[`chat`,`files`,`changes`,`mailbox`],va=[..._a,`skills`,`worktrees`,`officemap`,`design`],ya=132,ba=38,xa=165,Sa=46;function Ca(e,t){let n=ha.length+ga.length,r=Number.isFinite(e)?e:720,i=t?ya:xa,a=t?ba:Sa,o=Math.floor((r-i)/a);return Math.max(_a.length,Math.min(n,o))}function wa(e){let t=ha.length+ga.length,n=Math.max(_a.length,Math.min(t,Math.floor(e))),r=Math.min(ha.length,n),i=new Set(va.slice(0,r)),a=ha.map(e=>e.id).filter(e=>i.has(e)),o=ha.map(e=>e.id).filter(e=>!i.has(e)),s=Math.max(0,n-a.length),c=ga.slice(0,s).map(e=>e.id),l=new Set(c);return{visiblePanelIds:a,overflowPanelIds:o,visibleViewIds:c,overflowViewIds:ga.map(e=>e.id).filter(e=>!l.has(e))}}var Ta=ha.map(e=>e.id);function Ea(){return typeof window>`u`?720:window.visualViewport?.height??window.innerHeight}function Da(e){let[t,n]=(0,X.useState)(Ea);return(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>n(Ea());return e(),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e)}},[]),Ca(t,e)}function Oa({desktopShell:e=!1}){let t=K(e=>e.activeActivity),n=K(e=>e.sidebarOpen),r=K(e=>e.currentView),i=W(e=>e.projectName),a=G(e=>e.wsConnected),{t:o}=h(),s=(e,t)=>o(`activity:nav.${e}`,t),c=Ei(Ti),l=K(e=>e.inspectorOpen),u=Da(e),d=(0,X.useMemo)(()=>wa(u),[u]),f=(0,X.useMemo)(()=>new Set(d.visiblePanelIds),[d.visiblePanelIds]),p=(0,X.useMemo)(()=>new Set(d.overflowPanelIds),[d.overflowPanelIds]),m=(0,X.useMemo)(()=>new Set(d.visibleViewIds),[d.visibleViewIds]),g=(0,X.useMemo)(()=>new Set(d.overflowViewIds),[d.overflowViewIds]),_=ha.filter(e=>f.has(e.id)),v=ha.filter(e=>p.has(e.id)),y=ga.filter(e=>m.has(e.id)),b=ga.filter(e=>g.has(e.id)),x=e=>{if(e===`mailbox`)return c||void 0};return(0,Z.jsxs)(`div`,{className:U(`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,Z.jsx)(`div`,{className:`flex flex-col items-center shrink-0 border-b border-border/60`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{q(`chat`)},title:i?o(`activity:brand.returnToChat`,{name:i}):o(`activity:brand.returnToChatDefault`),className:U(`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,Z.jsx)(`img`,{src:`/wrongstack.svg`,alt:``,"aria-hidden":`true`,draggable:!1,className:`ws-brand-logo h-full w-full`})})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col items-center pt-2 pb-1`,children:[_.map(r=>(0,Z.jsx)(Aa,{compact:e,icon:r.icon,label:`${s(r.id,r.label)} (${ki(r.id)})`,active:n&&t===r.id,badge:x(r.id),onClick:()=>Ai(r.id)},r.id)),y.length>0&&(0,Z.jsx)(`div`,{className:`my-1.5 h-px w-6 shrink-0 bg-border/70`}),y.map(t=>(0,Z.jsx)(Aa,{compact:e,icon:t.icon,label:s(t.id,t.label),active:r===t.id,onClick:()=>Mi(t.id)},t.id))]}),(0,Z.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,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`div`,{className:`flex flex-col items-center shrink-0 pt-1 pb-2 border-t border-border/60`,children:(0,Z.jsx)(ka,{compact:e,monitorOpen:l,overflowPanels:v,overflowViews:b})})]})}function ka({compact:e=!1,monitorOpen:t,overflowPanels:n,overflowViews:r}){let{t:i}=h(),a=K(e=>e.activeActivity),o=K(e=>e.sidebarOpen),s=K(e=>e.currentView),c=K(e=>e.inspectorOpen),l=K(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=K.getState();t.inspectorOpen&&t.inspectorTab===e?t.setInspectorOpen(!1):(t.setInspectorTab(e),t.setInspectorOpen(!0))};return(0,Z.jsxs)(ia,{children:[(0,Z.jsx)(aa,{asChild:!0,children:(0,Z.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:U(`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,Z.jsx)(`span`,{className:`h-5 w-5 flex items-center justify-center`,children:(0,Z.jsx)(jt,{size:16})}),u>0&&(0,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-primary`})]})}),(0,Z.jsxs)(ca,{side:`right`,align:`end`,sideOffset:8,className:`w-56`,children:[(0,Z.jsxs)(la,{onSelect:()=>K.getState().setPaletteOpen(!0),children:[(0,Z.jsx)(C,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.commandPalette`)}),(0,Z.jsx)(ma,{children:`⌘K`})]}),(0,Z.jsxs)(la,{onSelect:()=>K.getState().setShortcutsOpen(!0),children:[(0,Z.jsx)(Tr,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.keyboardShortcuts`)}),(0,Z.jsx)(ma,{children:`?`})]}),n.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pa,{}),(0,Z.jsx)(fa,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.panels`)}),n.map(e=>(0,Z.jsxs)(la,{onSelect:()=>q(e.id),children:[e.icon,(0,Z.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),o&&a===e.id?(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Z.jsx)(ma,{children:ki(e.id)})]},e.id))]}),r.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pa,{}),(0,Z.jsx)(fa,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.views`)}),r.map(e=>(0,Z.jsxs)(la,{onSelect:()=>Mi(e.id),children:[e.icon,(0,Z.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),s===e.id&&(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`})]},e.id))]}),(0,Z.jsx)(pa,{}),(0,Z.jsx)(fa,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:nav.settings`,`Settings`)}),(0,Z.jsxs)(la,{onSelect:()=>Mi(`settings`),children:[(0,Z.jsx)(ar,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:nav.settings`,`Settings`)}),(0,Z.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:i(`settings:tabs.general`,`overview`)})]}),[{icon:(0,Z.jsx)(Je,{size:14}),label:`General`,tab:`general`},{icon:(0,Z.jsx)(ft,{size:14}),label:`Provider`,tab:`provider`},{icon:(0,Z.jsx)(On,{size:14}),label:`Agent`,tab:`agent`},{icon:(0,Z.jsx)(lr,{size:14}),label:`Execution`,tab:`execution`},{icon:(0,Z.jsx)(fr,{size:14}),label:`Fallbacks`,tab:`fallbacks`}].map(({icon:e,label:t,tab:n})=>(0,Z.jsxs)(la,{onSelect:()=>{K.getState().setSettingsActiveTab(n),Mi(`settings`)},children:[e,(0,Z.jsx)(`span`,{children:i(`settings:tabs.${n}`,t)})]},n)),(0,Z.jsx)(pa,{}),(0,Z.jsx)(fa,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.monitors`)}),(0,Z.jsxs)(la,{onSelect:()=>m(`fleet`),children:[(0,Z.jsx)(Mt,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.fleetMonitor`)}),c&&l===`fleet`?(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Z.jsx)(ma,{children:`⇧⌘M`})]}),(0,Z.jsxs)(la,{onSelect:()=>m(`sideEffects`),children:[(0,Z.jsx)(lr,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:inspector.tabAudit`)}),c&&l===`sideEffects`?(0,Z.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 rounded-full bg-primary`}):null]})]})]})}function Aa({compact:e=!1,icon:t,label:n,active:r,badge:i,onClick:a}){return(0,Z.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":n,title:n,className:U(`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,Z.jsx)(`span`,{className:`absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-6 rounded-r-full bg-primary`}),(0,Z.jsx)(`span`,{className:`h-5 w-5 shrink-0`,children:t}),i!==void 0&&i>0&&(0,Z.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 ja=[{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}],Ma=[`Run`,`Session`,`Inspect`,`Agent`,`Config`,`App`];function Na(e){let t=e.toLowerCase();return t===`/`||t===``?ja.filter(e=>!e.hidden):ja.filter(e=>e.name.startsWith(t)||(e.aliases?.some(e=>e.startsWith(t))??!1))}function Pa(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 Fa(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 Ia(e){let t=Math.max(3,...Array.from(e.matchAll(/`+/g),e=>e[0].length+1));return"`".repeat(t)}function La(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Ra(){let e=r.getState().messages,t=[],n=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),i=W.getState().projectName||`chat`,a=W.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=Ia(n.thinkingLog.text),r=n.thinkingLog.text.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ws-client-C2ppA8xa.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-C_zEzV4N.js","assets/monaco-BCqJp2xW.js","assets/monaco-Bowa0-zp.css","assets/markdown-CIRD7kOg.js","assets/vendor-BMdWcCR4.css","assets/utils-tsZEnrBH.js","assets/session-store-BgiP4PnQ.js","assets/ProcessMonitor-9TOnqT6l.js","assets/i18n-CDoHRskt.js","assets/activity-fdbTRXeg.js","assets/chat-CzaGXz_W.js","assets/commandPalette-BovBiPec.js","assets/common-BBHmIHQW.js","assets/settings-CbtB0i7o.js","assets/setup-DfcCCvUO.js","assets/toasts-DOfXc7Rt.js","assets/useWebSocket-DCx7NrvL.js","assets/chat-store-c0pGYczr.js","assets/codemap-activity-store-BH7Mh4k9.js","assets/stores-B0SETQK4.js","assets/mailbox-store-bF96Ih2G.js","assets/ui-store-xx1NssJI.js","assets/view-navigation-CZKugncK.js","assets/codemap-index-store-BFm1TzVW.js","assets/Toaster-wXvKXbbS.js","assets/dialog-BJjDUqb3.js","assets/AnalyticsDashboard-B5nVNt6L.js","assets/AgentRosterView-CIUKmLsb.js","assets/ModelPicker-B21-QbDB.js","assets/roster-ws-Cinqwkgb.js","assets/ChangesView-mapTz0_T.js","assets/empty-state-Cefmzojx.js","assets/monaco-theme-CR1QvFi2.js","assets/ChronicleDashboard-DUzceZNb.js","assets/CodeEditor-OjU9rotb.js","assets/MemoryDrawer-n3cwB9m3.js","assets/button-DvpRpKkt.js","assets/shared-B3czc2Dj.js","assets/CodeMap-BB1WETLd.js","assets/DebugDashboard-BwSbR59I.js","assets/DesignGalleryView-DLKWmyVp.js","assets/GoalView-BtSGdftD.js","assets/ConfirmModal-LBZaZgsG.js","assets/input-BtoHcCl9.js","assets/KanbanView-CyVG4DQu.js","assets/SddFlowGraph-DdYgCVM_.js","assets/MailboxDetailView-2NJVLrjb.js","assets/OfficeMapPanel-BKHjEIu9.js","assets/OfficeMapPanel-D6yTfGIT.css","assets/PromptJournalView-0F-HTGHg.js","assets/RefreshDebugView-CuKbgI-T.js","assets/SageTabs-B-m4WBoA.js","assets/RequirementIntakeView-DnNSLw78.js","assets/SddHub-DZCKF3Gw.js","assets/SpecsView-B53AUOo3.js","assets/SessionsDashboard-DoAbZStd.js","assets/SessionList-D4D2Cai9.js","assets/SessionInspectView-Cf4ypYKn.js","assets/SkillDetailView-sVjQG3qG.js","assets/TechStackView-iONTty84.js","assets/DeadCodeScanPanel-nlQ9nL3Y.js","assets/vector-memory-panel-D1zQSMIW.js","assets/SetupScreen-CMrLwoo9.js","assets/TerminalPanel-1mqoe2_8.js","assets/xterm-BWzBEEhg.js","assets/xterm-BrP-ENHg.css","assets/CronJobsPanel-DJaiJw1W.js","assets/QueuePanel--PTd2-7z.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t,r as n,t as r}from"./chat-store-c0pGYczr.js";import{$ as i,$i as a,$n as o,$r as s,$t as c,A as l,Aa as u,An as d,Ar as f,At as p,B as m,Ba as h,Bt as g,C as _,Ca as v,Ci as y,Cn as b,D as x,Da as S,Di as C,Dn as w,Dt as T,E,Ea as D,En as O,Er as k,F as A,Fn as j,Ft as M,G as ee,Ga as N,Gn as te,Gr as P,Gt as F,H as I,Hr as ne,Ht as re,I as ie,Ii as L,In as ae,It as oe,J as se,Ji as R,Jn as ce,K as le,Ki as ue,Kn as de,Kr as fe,Kt as pe,L as me,La as he,Li as ge,Ln as _e,Lr as ve,Lt as ye,M as be,Mi as xe,Mr as Se,Mt as Ce,N as we,Na as Te,Ni as Ee,Nr as De,Nt as Oe,O as ke,Oa as Ae,Oi as je,On as Me,Or as Ne,Ot as Pe,P as Fe,Pa as Ie,Pi as Le,Pn as Re,Pr as ze,Pt as Be,Q as Ve,Qi as He,Qn as Ue,Qr as We,Qt as Ge,R as Ke,Ri as qe,Rn 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,Ta as rt,Ti as it,Tn as at,Tr as ot,U as st,Ua as z,Ui as ct,Un as lt,Ur as ut,V as dt,Vn as ft,Vr as pt,W as mt,Wa as ht,Wn as gt,Wt as _t,X as vt,Xi as yt,Xn as bt,Xr as xt,Y as St,Yi as Ct,Yn as wt,Yr as Tt,Z as Et,Zi as Dt,Zn as Ot,Zr as kt,Zt as At,_i as jt,_r as Mt,_t as Nt,aa as Pt,an as Ft,ar as It,at as Lt,ba as Rt,bi as zt,bn as Bt,br as Vt,ca as Ht,ci as Ut,cr as Wt,da as Gt,di as Kt,dr as qt,dt as Jt,ea as Yt,ei as Xt,er as Zt,et as Qt,fa as $t,fi as en,fr as tn,ft as nn,ga as rn,gi as an,gn as on,gt as sn,hn as cn,ht as ln,ii as un,in as dn,ir as fn,it as pn,j as mn,jn as hn,jr as gn,jt as _n,k as vn,ka as yn,kn as bn,kr as xn,kt as Sn,la as Cn,li as wn,ln as Tn,lr as En,lt as Dn,ma as On,mi as kn,mn as An,mr as jn,mt as Mn,na as Nn,nn as Pn,nr as Fn,nt as In,oa as Ln,or as Rn,ot as zn,pi as Bn,pn as Vn,pt as Hn,q as Un,qi as Wn,qn as Gn,qr as Kn,qt as qn,ra as Jn,ri as Yn,rn as Xn,rr as Zn,rt as Qn,sa as $n,si as er,sn as tr,st as nr,ta as rr,ti as ir,tn as ar,tr as or,tt as sr,ua as cr,ut as lr,va as ur,vn as dr,vr as fr,vt as pr,w as mr,wa as hr,wi as gr,wn as _r,wr as vr,wt as yr,xi as br,xr,xt as Sr,yi as Cr,yn as wr,yr as Tr,yt as Er,z as Dr,za as Or,zi as kr,zn as Ar,zr as jr,zt as Mr}from"./vendor-C_zEzV4N.js";import{n as Nr,t as B}from"./i18n-CDoHRskt.js";import{s as V}from"./monaco-BCqJp2xW.js";import{a as Pr,c as Fr,i as Ir,l as Lr,n as Rr,o as zr,r as Br,s as Vr,t as Hr,u as Ur}from"./useWebSocket-DCx7NrvL.js";import{l as Wr,t as H}from"./ws-client-C2ppA8xa.js";import{t as U}from"./utils-tsZEnrBH.js";import{t as W}from"./session-store-BgiP4PnQ.js";import{A as Gr,B as Kr,C as qr,D as Jr,E as Yr,H as Xr,I as G,L as Zr,M as Qr,N as $r,O as ei,P as ti,R as ni,S as ri,T as ii,U as ai,V as oi,_ as si,b as ci,d as li,f as ui,g as di,h as fi,j as pi,k as mi,l as hi,n as gi,o as _i,r as vi,t as yi,u as bi,w as xi,x as Si,y as Ci,z as wi}from"./stores-B0SETQK4.js";import{n as Ti,r as Ei,t as Di}from"./mailbox-store-bF96Ih2G.js";import{n as K,t as Oi}from"./ui-store-xx1NssJI.js";import{a as ki,i as Ai,n as ji,o as q,r as Mi,t as Ni}from"./view-navigation-CZKugncK.js";import{n as J,t as Pi}from"./Toaster-wXvKXbbS.js";import{a as Fi,i as Ii,n as Li,o as Ri,r as zi,t as Bi}from"./dialog-BJjDUqb3.js";import{t as Y}from"./button-DvpRpKkt.js";import{t as Vi}from"./input-BtoHcCl9.js";import{i as Hi,n as Ui,o as Wi,r as Gi,t as Ki}from"./ConfirmModal-LBZaZgsG.js";import{d as qi,p as Ji}from"./markdown-CIRD7kOg.js";import{n as Yi,t as Xi}from"./ModelPicker-B21-QbDB.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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var X=e(N(),1),Zi=e(ht(),1),Qi=new Set([`chat`,`settings`,`goal`,`kanban`,`sddhub`,`files`,`changes`,`sessions`,`setup`,`skill`,`officemap`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`]),$i=new Set([`goal`,`fleet`,`work`,`worktrees`,`collab`]),ea=new Set([`todos`,`tasks`,`plan`]);function ta(){if(typeof window>`u`)return;let e=window.wrongstackDesktopHost;if(!e?.setPrefs)return;let t=B.getState();e.setPrefs({yolo:t.yolo,nextPrediction:t.nextPrediction,contextAutoCompact:t.contextAutoCompact})}function na(e){typeof window>`u`||window.wrongstackDesktopHost?.setReady?.(e)}function ra(e,t,n){typeof window>`u`||typeof e!=`string`||window.wrongstackDesktopHost?.ackCommand?.(e,t,n)}var Z=Dn(),ia=Qn,aa=nr,oa=X.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Z.jsxs)(zn,{ref:i,className:U(`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,Z.jsx)(Yt,{className:`ml-auto h-4 w-4`})]}));oa.displayName=zn.displayName;var sa=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Lt,{ref:n,className:U(`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}));sa.displayName=Lt.displayName;var ca=X.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Z.jsx)(sr,{children:(0,Z.jsx)(Et,{ref:r,sideOffset:t,className:U(`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})}));ca.displayName=Et.displayName;var la=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(Ve,{ref:r,className:U(`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}));la.displayName=Ve.displayName;var ua=X.forwardRef(({className:e,children:t,checked:n,...r},a)=>(0,Z.jsxs)(vt,{ref:a,className:U(`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,Z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Z.jsx)(i,{children:(0,Z.jsx)(Jn,{className:`h-4 w-4`})})}),t]}));ua.displayName=vt.displayName;var da=X.forwardRef(({className:e,children:t,...n},r)=>(0,Z.jsxs)(In,{ref:r,className:U(`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,Z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Z.jsx)(i,{children:(0,Z.jsx)(qe,{className:`h-2 w-2 fill-current`})})}),t]}));da.displayName=In.displayName;var fa=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(Qt,{ref:r,className:U(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));fa.displayName=Qt.displayName;var pa=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(pn,{ref:n,className:U(`-mx-1 my-1 h-px bg-muted`,e),...t}));pa.displayName=pn.displayName;var ma=({className:e,...t})=>(0,Z.jsx)(`span`,{className:U(`ml-auto text-xs tracking-widest opacity-60`,e),...t});ma.displayName=`DropdownMenuShortcut`;var ha=[{id:`chat`,icon:(0,Z.jsx)(wt,{size:16}),label:`Session`},{id:`files`,icon:(0,Z.jsx)(fe,{size:16}),label:`Files`},{id:`changes`,icon:(0,Z.jsx)(De,{size:16}),label:`Changes`},{id:`mailbox`,icon:(0,Z.jsx)(Zt,{size:16}),label:`Mailbox`},{id:`skills`,icon:(0,Z.jsx)(_t,{size:16}),label:`Skills`},{id:`worktrees`,icon:(0,Z.jsx)(ze,{size:16}),label:`Worktrees`},{id:`design`,icon:(0,Z.jsx)(Je,{size:16}),label:`Design Studio`},{id:`officemap`,icon:(0,Z.jsx)(Ht,{size:16}),label:`Office Map`}],ga=[{id:`settings`,icon:(0,Z.jsx)(ar,{size:16}),label:`Settings`},{id:`roster`,icon:(0,Z.jsx)(On,{size:16}),label:`Agent Roster`},{id:`sddhub`,icon:(0,Z.jsx)(ln,{size:16}),label:`SDD`},{id:`kanban`,icon:(0,Z.jsx)(je,{size:16}),label:`Kanban`},{id:`goal`,icon:(0,Z.jsx)(on,{size:16}),label:`Goal`},{id:`codemap`,icon:(0,Z.jsx)(ft,{size:16}),label:`CodeMap`},{id:`techstack`,icon:(0,Z.jsx)($t,{size:16}),label:`TechStack`},{id:`chronicle`,icon:(0,Z.jsx)(Pt,{size:16}),label:`Chronicle`},{id:`prompts`,icon:(0,Z.jsx)(tr,{size:16}),label:`Prompt Journal`},{id:`intake`,icon:(0,Z.jsx)(L,{size:16}),label:`Requirements`},{id:`memory`,icon:(0,Z.jsx)(Gt,{size:16}),label:`Memory`}],_a=[`chat`,`files`,`changes`,`mailbox`],va=[..._a,`skills`,`worktrees`,`officemap`,`design`],ya=132,ba=38,xa=165,Sa=46;function Ca(e,t){let n=ha.length+ga.length,r=Number.isFinite(e)?e:720,i=t?ya:xa,a=t?ba:Sa,o=Math.floor((r-i)/a);return Math.max(_a.length,Math.min(n,o))}function wa(e){let t=ha.length+ga.length,n=Math.max(_a.length,Math.min(t,Math.floor(e))),r=Math.min(ha.length,n),i=new Set(va.slice(0,r)),a=ha.map(e=>e.id).filter(e=>i.has(e)),o=ha.map(e=>e.id).filter(e=>!i.has(e)),s=Math.max(0,n-a.length),c=ga.slice(0,s).map(e=>e.id),l=new Set(c);return{visiblePanelIds:a,overflowPanelIds:o,visibleViewIds:c,overflowViewIds:ga.map(e=>e.id).filter(e=>!l.has(e))}}var Ta=ha.map(e=>e.id);function Ea(){return typeof window>`u`?720:window.visualViewport?.height??window.innerHeight}function Da(e){let[t,n]=(0,X.useState)(Ea);return(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>n(Ea());return e(),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e)}},[]),Ca(t,e)}function Oa({desktopShell:e=!1}){let t=K(e=>e.activeActivity),n=K(e=>e.sidebarOpen),r=K(e=>e.currentView),i=W(e=>e.projectName),a=G(e=>e.wsConnected),{t:o}=h(),s=(e,t)=>o(`activity:nav.${e}`,t),c=Ei(Ti),l=K(e=>e.inspectorOpen),u=Da(e),d=(0,X.useMemo)(()=>wa(u),[u]),f=(0,X.useMemo)(()=>new Set(d.visiblePanelIds),[d.visiblePanelIds]),p=(0,X.useMemo)(()=>new Set(d.overflowPanelIds),[d.overflowPanelIds]),m=(0,X.useMemo)(()=>new Set(d.visibleViewIds),[d.visibleViewIds]),g=(0,X.useMemo)(()=>new Set(d.overflowViewIds),[d.overflowViewIds]),_=ha.filter(e=>f.has(e.id)),v=ha.filter(e=>p.has(e.id)),y=ga.filter(e=>m.has(e.id)),b=ga.filter(e=>g.has(e.id)),x=e=>{if(e===`mailbox`)return c||void 0};return(0,Z.jsxs)(`div`,{className:U(`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,Z.jsx)(`div`,{className:`flex flex-col items-center shrink-0 border-b border-border/60`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{q(`chat`)},title:i?o(`activity:brand.returnToChat`,{name:i}):o(`activity:brand.returnToChatDefault`),className:U(`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,Z.jsx)(`img`,{src:`/wrongstack.svg`,alt:``,"aria-hidden":`true`,draggable:!1,className:`ws-brand-logo h-full w-full`})})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col items-center pt-2 pb-1`,children:[_.map(r=>(0,Z.jsx)(Aa,{compact:e,icon:r.icon,label:`${s(r.id,r.label)} (${ki(r.id)})`,active:n&&t===r.id,badge:x(r.id),onClick:()=>Ai(r.id)},r.id)),y.length>0&&(0,Z.jsx)(`div`,{className:`my-1.5 h-px w-6 shrink-0 bg-border/70`}),y.map(t=>(0,Z.jsx)(Aa,{compact:e,icon:t.icon,label:s(t.id,t.label),active:r===t.id,onClick:()=>Mi(t.id)},t.id))]}),(0,Z.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,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`div`,{className:`flex flex-col items-center shrink-0 pt-1 pb-2 border-t border-border/60`,children:(0,Z.jsx)(ka,{compact:e,monitorOpen:l,overflowPanels:v,overflowViews:b})})]})}function ka({compact:e=!1,monitorOpen:t,overflowPanels:n,overflowViews:r}){let{t:i}=h(),a=K(e=>e.activeActivity),o=K(e=>e.sidebarOpen),s=K(e=>e.currentView),c=K(e=>e.inspectorOpen),l=K(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=K.getState();t.inspectorOpen&&t.inspectorTab===e?t.setInspectorOpen(!1):(t.setInspectorTab(e),t.setInspectorOpen(!0))};return(0,Z.jsxs)(ia,{children:[(0,Z.jsx)(aa,{asChild:!0,children:(0,Z.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:U(`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,Z.jsx)(`span`,{className:`h-5 w-5 flex items-center justify-center`,children:(0,Z.jsx)(jt,{size:16})}),u>0&&(0,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-primary`})]})}),(0,Z.jsxs)(ca,{side:`right`,align:`end`,sideOffset:8,className:`w-56`,children:[(0,Z.jsxs)(la,{onSelect:()=>K.getState().setPaletteOpen(!0),children:[(0,Z.jsx)(C,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.commandPalette`)}),(0,Z.jsx)(ma,{children:`⌘K`})]}),(0,Z.jsxs)(la,{onSelect:()=>K.getState().setShortcutsOpen(!0),children:[(0,Z.jsx)(Tr,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.keyboardShortcuts`)}),(0,Z.jsx)(ma,{children:`?`})]}),n.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pa,{}),(0,Z.jsx)(fa,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.panels`)}),n.map(e=>(0,Z.jsxs)(la,{onSelect:()=>q(e.id),children:[e.icon,(0,Z.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),o&&a===e.id?(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Z.jsx)(ma,{children:ki(e.id)})]},e.id))]}),r.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pa,{}),(0,Z.jsx)(fa,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.views`)}),r.map(e=>(0,Z.jsxs)(la,{onSelect:()=>Mi(e.id),children:[e.icon,(0,Z.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),s===e.id&&(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`})]},e.id))]}),(0,Z.jsx)(pa,{}),(0,Z.jsx)(fa,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:nav.settings`,`Settings`)}),(0,Z.jsxs)(la,{onSelect:()=>Mi(`settings`),children:[(0,Z.jsx)(ar,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:nav.settings`,`Settings`)}),(0,Z.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:i(`settings:tabs.general`,`overview`)})]}),[{icon:(0,Z.jsx)(Je,{size:14}),label:`General`,tab:`general`},{icon:(0,Z.jsx)(ft,{size:14}),label:`Provider`,tab:`provider`},{icon:(0,Z.jsx)(On,{size:14}),label:`Agent`,tab:`agent`},{icon:(0,Z.jsx)(lr,{size:14}),label:`Execution`,tab:`execution`},{icon:(0,Z.jsx)(fr,{size:14}),label:`Fallbacks`,tab:`fallbacks`}].map(({icon:e,label:t,tab:n})=>(0,Z.jsxs)(la,{onSelect:()=>{K.getState().setSettingsActiveTab(n),Mi(`settings`)},children:[e,(0,Z.jsx)(`span`,{children:i(`settings:tabs.${n}`,t)})]},n)),(0,Z.jsx)(pa,{}),(0,Z.jsx)(fa,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.monitors`)}),(0,Z.jsxs)(la,{onSelect:()=>m(`fleet`),children:[(0,Z.jsx)(Mt,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.fleetMonitor`)}),c&&l===`fleet`?(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Z.jsx)(ma,{children:`⇧⌘M`})]}),(0,Z.jsxs)(la,{onSelect:()=>m(`sideEffects`),children:[(0,Z.jsx)(lr,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:inspector.tabAudit`)}),c&&l===`sideEffects`?(0,Z.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 rounded-full bg-primary`}):null]})]})]})}function Aa({compact:e=!1,icon:t,label:n,active:r,badge:i,onClick:a}){return(0,Z.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":n,title:n,className:U(`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,Z.jsx)(`span`,{className:`absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-6 rounded-r-full bg-primary`}),(0,Z.jsx)(`span`,{className:`h-5 w-5 shrink-0`,children:t}),i!==void 0&&i>0&&(0,Z.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 ja=[{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}],Ma=[`Run`,`Session`,`Inspect`,`Agent`,`Config`,`App`];function Na(e){let t=e.toLowerCase();return t===`/`||t===``?ja.filter(e=>!e.hidden):ja.filter(e=>e.name.startsWith(t)||(e.aliases?.some(e=>e.startsWith(t))??!1))}function Pa(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 Fa(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 Ia(e){let t=Math.max(3,...Array.from(e.matchAll(/`+/g),e=>e[0].length+1));return"`".repeat(t)}function La(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Ra(){let e=r.getState().messages,t=[],n=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),i=W.getState().projectName||`chat`,a=W.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=Ia(n.thinkingLog.text),r=n.thinkingLog.text.split(`
3
3
  `).length;t.push(`### 🧠 Thinking process — iteration ${n.thinkingLog.iteration}`),t.push(``),t.push(`_${Fa(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 za(){let e=r.getState().messages,t=W.getState(),n=t.projectName||`chat`,i=La(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`
@@ -65,7 +65,7 @@ Type while the agent is running to queue messages; they are sent automatically w
65
65
  `)}),!0;let r=K.getState();return q(`chat`),r.setDockCustomizeOpen(!1),t===`sessionPanel`?(q(`chat`),!0):t===`fleetMonitor`?(r.setFleetMonitorOpen(!0),!0):t===`agentsMonitor`?(r.setAgentsMonitorOpen(!0),!0):t===`worktreeMonitor`?(q(`worktrees`),r.setDockSection(`worktrees`),!0):t===`planPanel`?(f.getPlan(),r.setDockSection(`work`),r.setWorkDashboardTab(`plan`),!0):t===`todosMonitor`?(r.setDockSection(`work`),r.setWorkDashboardTab(`todos`),!0):t===`queuePanel`?(r.setQueuePanelOpen(!0),!0):t===`processList`?(r.setProcessMonitorOpen(!0),!0):t===`goalPanel`?(i?.send?.({type:`goal.get`}),q(`chat`),r.setDockSection(`goal-state`),!0):t===`sessionsPanel`?(f.listSessions(50),q(`chat`),!0):t===`coordinatorMonitor`?(q(`officemap`),!0):t!==`statuslinePicker`||(q(`chat`),r.setDockSection(`work`),r.setDockCustomizeOpen(!0),!0)}default:return!1}}function Va(){let e=K(e=>e.paletteOpen),t=K(e=>e.setPaletteOpen),n=G(e=>e.setTheme),i=fi(e=>e.entries),{addMessage:a,clearMessages:s}=r(he(e=>({addMessage:e.addMessage,clearMessages:e.clearMessages}))),c=Hr(),{t:l}=h(),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(0),m=(0,X.useRef)(null);(0,X.useEffect)(()=>{e&&(d(``),p(0),requestAnimationFrame(()=>m.current?.focus()))},[e]),(0,X.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t(!K.getState().paletteOpen))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let _=(0,X.useMemo)(()=>{let e=[{id:`help`,category:`Command`,label:l(`commandPalette:cmd.help`),icon:Ne,keywords:[`help`,`commands`,`?`],run:()=>{a({role:`assistant`,content:"Type `/` in the message box to see every slash command."})}},{id:`tools`,category:`Command`,label:l(`commandPalette:cmd.tools`),icon:nn,keywords:[`tools`,`list`],run:()=>c.listTools()},{id:`memory`,category:`Command`,label:l(`commandPalette:cmd.memory`),icon:cr,keywords:[`memory`,`remember`,`notes`,`Sage`],run:()=>Mi(`memory`)},{id:`context`,category:`Command`,label:l(`activity:panels.contextDashboard`),icon:Ln,keywords:[`context`,`window`,`tokens`,`pressure`,`telemetry`],run:()=>K.getState().setCurrentView(`context`)},{id:`skills`,category:`Command`,label:l(`commandPalette:cmd.skills`),icon:_t,keywords:[`skills`],run:()=>c.listSkills()},{id:`diag`,category:`Command`,label:l(`commandPalette:cmd.diag`),icon:Xe,keywords:[`diag`,`diagnostics`,`debug`],run:()=>c.getDiag()},{id:`stats`,category:`Command`,label:l(`commandPalette:cmd.stats`),icon:Ln,keywords:[`stats`,`tokens`,`cost`,`cache`],run:()=>c.getStats()},{id:`clear`,category:`Session`,label:l(`commandPalette:cmd.clear`),hint:l(`commandPalette:cmd.clearHint`),icon:_n,keywords:[`clear`,`reset`,`wipe`],run:()=>{Wr.dropAll(),s(),c.client?.clearContext?.()}},{id:`new`,category:`Session`,label:l(`commandPalette:cmd.new`),hint:l(`commandPalette:cmd.newHint`),icon:An,keywords:[`new`,`fresh`,`session`],run:()=>{c.client?.newSession?.(),q(`chat`)}},{id:`compact`,category:`Session`,label:l(`commandPalette:cmd.compact`),icon:br,keywords:[`compact`,`shrink`,`context`],run:()=>c.client?.compactContext?.()},{id:`repair-context`,category:`Session`,label:l(`commandPalette:cmd.repairContext`),hint:l(`commandPalette:cmd.repairContextHint`),icon:nn,keywords:[`repair`,`context`,`tool_use`,`tool_result`],run:()=>c.client?.repairContext?.()},{id:`export`,category:`Session`,label:l(`commandPalette:cmd.export`),icon:Cr,keywords:[`export`,`save`,`markdown`,`download`],run:()=>Ra()},{id:`export-html`,category:`Session`,label:l(`commandPalette:cmd.exportHtml`),hint:l(`commandPalette:cmd.exportHtmlHint`),icon:Cr,keywords:[`export`,`html`,`download`,`archive`],run:()=>za()},{id:`history`,category:`Command`,label:l(`commandPalette:cmd.history`),icon:cn,keywords:[`history`,`sessions`],run:()=>{q(`chat`)}},{id:`settings`,category:`Command`,label:l(`commandPalette:cmd.settings`),icon:ar,keywords:[`settings`,`config`],run:()=>Mi(`settings`)},{id:`model`,category:`Command`,label:l(`commandPalette:cmd.model`),icon:y,keywords:[`model`,`provider`,`change`],run:()=>K.getState().setModelSwitcherOpen(!0)},{id:`theme-light`,category:`Theme`,label:l(`commandPalette:cmd.themeLight`),icon:ye,keywords:[`theme`,`light`,`mode`],run:()=>n(`light`)},{id:`theme-dark`,category:`Theme`,label:l(`commandPalette:cmd.themeDark`),icon:gt,keywords:[`theme`,`dark`,`mode`],run:()=>n(`dark`)},{id:`theme-system`,category:`Theme`,label:l(`commandPalette:cmd.themeSystem`),icon:te,keywords:[`theme`,`system`,`auto`],run:()=>n(`system`)},{id:`compact-toggle`,category:`Command`,label:l(`commandPalette:cmd.compactToggle`),icon:o,hint:`Ctrl+Shift+D`,keywords:[`compact`,`dense`,`density`,`size`],run:()=>K.getState().toggleCompactMode()},{id:`sound-toggle`,category:`Command`,label:G.getState().soundOnComplete?l(`commandPalette:cmd.soundOn`):l(`commandPalette:cmd.soundOff`),icon:G.getState().soundOnComplete?Nt:sn,hint:l(`commandPalette:cmd.soundHint`),keywords:[`sound`,`audio`,`chime`,`notify`,`beep`],run:()=>{let e=!G.getState().soundOnComplete;G.getState().setSoundOnComplete(e),e&&zr()}},{id:`goal-open`,category:`Command`,label:l(`commandPalette:cmd.goalOpen`),icon:on,keywords:[`goal`,`autonomous`,`phases`,`rocket`],run:()=>Mi(`goal`)},{id:`goal-toggle`,category:`Command`,label:si.getState().autonomous?l(`commandPalette:cmd.autoOn`):l(`commandPalette:cmd.autoOff`),icon:si.getState().autonomous?hn:O,hint:l(`commandPalette:cmd.autoHint`),keywords:[`autonomous`,`goal`,`auto`,`pause`,`resume`],run:()=>{let e=!si.getState().autonomous;c.toggleGoalAutonomous(e)}},{id:`goal-stop`,category:`Command`,label:l(`commandPalette:cmd.goalStop`),icon:g,keywords:[`goal`,`stop`,`autonomous`,`end`],run:()=>c.stopGoal()}],t=e=>{let t=r.getState(),n=K.getState();return{raw:e,addMessage:a,clearMessages:s,client:c.client,queue:t.queue,sendAbort:c.sendAbort,sendMsg:e=>{if(t.isLoading){t.enqueue(e);return}t.addMessage({role:`user`,content:e}),c.sendMessage(e)&&t.setLoading(!0)},setLoading:t.setLoading,setCurrentView:e=>ji(e),toggleRefineEnabled:n.toggleRefineEnabled,setProcessMonitorOpen:n.setProcessMonitorOpen,setQueuePanelOpen:n.setQueuePanelOpen,ws:c,onOpenBreakdown:()=>ji(`debug`),handleNextList:()=>!1,handleNextSelect:()=>!1}};for(let n of ja)n.hidden||e.push({id:`slash-${n.name}`,category:`Slash`,label:n.name,hint:n.description,icon:Ne,keywords:[`slash`,n.name.replace(`/`,``),...(n.aliases??[]).map(e=>e.replace(`/`,``))],run:()=>{Ba(t(n.name))}});for(let t of i.slice(0,10))t.isCurrent||e.push({id:`resume-${t.id}`,category:`Session`,label:l(`commandPalette:cmd.resume`,{title:t.title||l(`commandPalette:cmd.emptyTitle`)}),hint:`${t.provider}/${t.model}`,icon:Te,keywords:[`resume`,t.title,t.id,t.provider,t.model],run:()=>c.resumeSession(t.id)});return e},[i,c,n,a,s,l]),v=(0,X.useMemo)(()=>{let e=u.toLowerCase().trim();return e?_.filter(t=>[t.label,t.hint??``,t.category,...t.keywords??[]].join(` `).toLowerCase().includes(e)):_},[_,u]);(0,X.useEffect)(()=>{f>=v.length&&p(0)},[v.length,f]);let b=e=>{e&&(t(!1),e.run())};return(0,Z.jsx)(Bi,{open:e,onOpenChange:e=>{e||t(!1)},children:(0,Z.jsxs)(Li,{className:`max-w-2xl gap-0 p-0 overflow-hidden pt-[14dvh]`,showCloseButton:!1,onOpenAutoFocus:e=>{e.preventDefault(),m.current?.focus()},children:[(0,Z.jsx)(Ri,{className:`sr-only`,children:l(`commandPalette:title`)}),(0,Z.jsx)(zi,{className:`sr-only`,children:l(`commandPalette:placeholder`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b`,children:[(0,Z.jsx)(Ft,{className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(`input`,{ref:m,value:u,onChange:e=>d(e.target.value),placeholder:l(`commandPalette:placeholder`),"aria-label":l(`commandPalette:placeholder`),className:`flex-1 bg-transparent outline-none text-sm placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),p(e=>(e+1)%Math.max(1,v.length))):e.key===`ArrowUp`?(e.preventDefault(),p(e=>(e-1+Math.max(1,v.length))%Math.max(1,v.length))):e.key===`Enter`&&(e.preventDefault(),b(v[f]))}}),(0,Z.jsx)(`kbd`,{className:`text-[10px] text-muted-foreground border rounded px-1.5 py-0.5`,children:`Esc`})]}),(0,Z.jsx)(`div`,{className:`max-h-[60dvh] overflow-y-auto`,children:v.length===0?(0,Z.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:l(`commandPalette:noMatches`,{query:u})}):Ha(v,f,b,p)}),(0,Z.jsxs)(`div`,{className:`border-t px-4 py-2 text-[10px] uppercase tracking-wider text-muted-foreground flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{children:l(`commandPalette:footer.navigate`)}),(0,Z.jsx)(`span`,{children:l(`commandPalette:footer.select`)}),(0,Z.jsx)(`span`,{children:l(`commandPalette:footer.dismiss`)})]})]})})}function Ha(e,t,n,r){let i={};return e.forEach((e,t)=>{i[e.category]||(i[e.category]=[]),i[e.category]?.push({item:e,globalIdx:t})}),(0,Z.jsx)(`div`,{className:`p-1`,children:Object.entries(i).map(([e,i])=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:z.t(`commandPalette:cat.${e}`,{defaultValue:e})}),i.map(({item:e,globalIdx:i})=>{let a=e.icon,o=i===t;return(0,Z.jsxs)(`button`,{type:`button`,onMouseEnter:()=>r(i),onClick:()=>n(e),className:U(`w-full flex items-center gap-3 px-3 py-2 rounded text-left text-sm transition-colors`,o?`bg-accent text-accent-foreground`:`hover:bg-accent/40`),children:[(0,Z.jsx)(a,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate`,children:e.label}),e.hint&&(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.hint})]}),o&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`↵`})]},e.id)})]},e))})}function Ua(e){let{setPaletteOpen:t,setSearchOpen:n,setShortcutsOpen:i,setModelSwitcherOpen:a,setPromptLibraryOpen:o,setFleetMonitorOpen:s,setAgentsMonitorOpen:c,setProcessMonitorOpen:l,setQueuePanelOpen:u,setTerminalOpen:d}=e,f=Ur();(0,X.useEffect)(()=>{f&&Oi({sidebarOpen:!1})},[f]),(0,X.useEffect)(()=>(ta(),B.subscribe((e,t)=>{(e.yolo!==t.yolo||e.nextPrediction!==t.nextPrediction||e.contextAutoCompact!==t.contextAutoCompact)&&ta()})),[]),(0,X.useEffect)(()=>{let e=e=>{let f=e&&typeof e==`object`&&!Array.isArray(e)?e:{},p=K.getState(),m=H(G.getState().wsUrl),h=!1,g=e=>{ji(e),e===`sessions`&&m?.listSessions?.(50)},_=f.activity;typeof _==`string`&&Ta.includes(_)&&(q(_),h=!0);let v=f.view;typeof v==`string`&&Qi.has(v)&&(g(v),h=!0);let y=f.action;y===`new-session`?(m?.newSession?.(),q(`chat`),h=!0):y===`clear-context`?(Wr.dropAll(),r.getState().clearMessages(),m?.clearContext?.(),q(`chat`),h=!0):y===`compact-context`?(m?.compactContext?.(),q(`chat`),h=!0):y===`repair-context`?(m?.repairContext?.(),q(`chat`),h=!0):y===`download-chat`?(Ra(),h=!0):y===`focus-chat`?(q(`chat`),window.requestAnimationFrame(()=>document.querySelector(`textarea`)?.focus()),h=!0):y===`open-command-palette`?(t(!0),h=!0):y===`open-shortcuts`?(i(!0),h=!0):y===`search-chat`?(n(!0),h=!0):y===`open-model-switcher`?(a(!0),h=!0):y===`open-prompt-library`&&(o(!0),h=!0);let b=f.dockSection;if(typeof b==`string`&&$i.has(b)){let e=b;if(p.showDockChip(e),p.setDockCustomizeOpen(!1),h=!0,b===`goal`)return Mi(`goal`),p.setDockSection(null),h;q(`chat`),p.setDockSection(e),b===`goal`&&m?.send?.({type:`goal.get`})}let x=f.workTab;typeof x==`string`&&ea.has(x)&&(p.showDockChip(`work`),p.setDockCustomizeOpen(!1),q(`chat`),p.setDockSection(`work`),p.setWorkDashboardTab(x),h=!0,x===`plan`&&m?.getPlan?.());let S=f.overlay;S===`fleet`?(s(!0),h=!0):S===`agents-monitor`?(c(!0),h=!0):S===`processes`?(l(!0),h=!0):S===`queue`&&(u(!0),h=!0),f.terminal===`toggle`?(p.toggleTerminal(),h=!0):f.terminal===`new`?(p.terminalOpen?p.requestTerminalCreate():d(!0),h=!0):f.terminal===!0?(d(!0),h=!0):f.terminal===!1&&(d(!1),h=!0);let C=f.pref;if(C&&typeof C==`object`&&!Array.isArray(C)){let e=C,t=e.key;if(t===`yolo`||t===`nextPrediction`||t===`contextAutoCompact`){let n=B.getState(),r=e.toggle===!0?!n[t]:e.value;if(typeof r==`boolean`){let e={[t]:r};n.set(e),m?.updatePrefs?.(e),t===`yolo`&&J.info(`YOLO ${r?`enabled`:`disabled`}`),h=!0}}}return h},f=new Set,p=[],m=e=>{for(f.add(e),p.push(e);p.length>120;){let e=p.shift();e&&f.delete(e)}},h=t=>{let n=(t&&typeof t==`object`&&!Array.isArray(t)?t:{}).requestId;if(typeof n==`string`&&f.has(n)){ra(n,!0);return}try{let r=e(t);r&&typeof n==`string`&&m(n),ra(n,r)}catch(e){ra(n,!1,e instanceof Error?e.message:String(e)),console.error(e)}},g=window.wrongstackDesktopCommands?.subscribe?.(e=>{h(e)})??null,_=e=>{h(e.detail)};return window.addEventListener(`wrongstack:desktop-command`,_),window.__wrongstackDesktopReady=!0,na(!0),()=>{window.__wrongstackDesktopReady=!1,na(!1),g&&g(),window.removeEventListener(`wrongstack:desktop-command`,_)}},[c,s,a,t,o,l,u,n,i,d])}function Wa(){(0,X.useEffect)(()=>{let e=()=>{try{let e=[W,r,K,G];for(let t of e){let e=t.persist;e&&typeof e.flush==`function`&&e.flush()}}catch{}};return window.addEventListener(`pagehide`,e),window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`beforeunload`,e)}},[]),(0,X.useEffect)(()=>{if(typeof window>`u`||window.location.pathname===`/debug`||window.location.pathname===`/analytics`||window.location.pathname===`/refresh-debug`)return;let e=K.getState().currentView;(e===`debug`||e===`analytics`||e===`design-gallery`||e===`setup`)&&q(`chat`)},[])}function Ga(e){let{toggleSidebar:n,setSearchOpen:i,toggleInspector:a,setInspectorTab:o}=e;(0,X.useEffect)(()=>{let e=e=>{let s=e.target,c=s?.tagName?.toLowerCase(),l=c===`input`||c===`textarea`||s?.isContentEditable,u=e.ctrlKey||e.metaKey;if(u&&e.key===`\\`){e.preventDefault(),n();return}if(u&&e.key==="`"){e.preventDefault(),K.getState().toggleTerminal();return}if(u&&!e.shiftKey&&!e.altKey&&Object.hasOwn(Ni,e.key)){let t=Ni[e.key];if(t){e.preventDefault(),Ai(t);return}}if(u&&e.key===`9`&&!e.shiftKey&&!e.altKey){e.preventDefault(),Mi(`settings`);return}if(u&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()===`w`){e.preventDefault(),Ai(`worktrees`);return}if(!l&&!u&&!e.altKey&&/^F([1-9]|1[0-2])$/.test(e.key)){e.preventDefault();let t=K.getState(),n=H(G.getState().wsUrl),r=Number(e.key.slice(1));switch(t.setDockCustomizeOpen(!1),r){case 1:Ai(`chat`);return;case 2:t.setFleetMonitorOpen(!0);return;case 3:t.setAgentsMonitorOpen(!0);return;case 4:q(`worktrees`),t.setDockSection(`worktrees`);return;case 5:n?.getPlan?.(),q(`chat`),t.setDockSection(`work`),t.setWorkDashboardTab(`plan`);return;case 6:q(`chat`),t.setDockSection(`work`),t.setWorkDashboardTab(`todos`);return;case 7:t.setQueuePanelOpen(!0);return;case 8:t.setProcessMonitorOpen(!0);return;case 9:n?.send?.({type:`goal-state.get`}),q(`chat`),t.setDockSection(`goal-state`);return;case 10:n?.listSessions?.(200),q(`chat`);return;case 11:q(`officemap`);return;case 12:q(`chat`),t.setDockSection(`work`),t.setDockCustomizeOpen(!0);return}}if(u&&e.key.toLowerCase()===`f`){e.preventDefault(),i(!0);return}if(u&&e.key.toLowerCase()===`/`){e.preventDefault(),document.querySelector(`textarea`)?.focus();return}if(u&&!l&&(e.key.toLowerCase()===`l`?(e.preventDefault(),Wr.dropAll(),r.getState().clearMessages(),H(G.getState().wsUrl)?.clearContext?.()):e.key.toLowerCase()===`n`?(e.preventDefault(),H(G.getState().wsUrl)?.newSession?.(),q(`chat`)):e.key.toLowerCase()===`e`&&(e.preventDefault(),Ra())),u&&e.shiftKey&&e.key.toLowerCase()===`d`&&(e.preventDefault(),K.getState().toggleCompactMode()),u&&e.shiftKey&&e.key.toLowerCase()===`m`){e.preventDefault();let t=K.getState();t.inspectorOpen&&t.inspectorTab===`fleet`?a():(o(`fleet`),t.inspectorOpen||a())}if(u&&e.shiftKey&&e.key.toLowerCase()===`a`){e.preventDefault();let t=K.getState();t.inspectorOpen&&t.inspectorTab===`agents`?a():(o(`agents`),t.inspectorOpen||a())}if(u&&e.shiftKey&&e.key.toLowerCase()===`g`&&(e.preventDefault(),ji(`debug`)),u&&e.shiftKey&&e.key.toLowerCase()===`k`){e.preventDefault(),Mi(`memory`);return}if(e.key===`Escape`&&!u&&K.getState().inspectorOpen&&K.getState().setInspectorOpen(!1),e.key===`Escape`&&!u&&!l){let e=K.getState(),t=e.inspectorOpen||e.searchOpen||e.paletteOpen||e.shortcutsOpen||e.modelSwitcherOpen||e.promptLibraryOpen,n=document.querySelector(`[data-message-id][data-focused="true"]`);!t&&!n&&r.getState().isLoading&&H(G.getState().wsUrl).sendAbort()}if(!l&&!u&&!e.altKey){let n=Array.from(document.querySelectorAll(`[data-message-id]`));if(n.length===0)return;let r=document.querySelector(`[data-message-id][data-focused="true"]`),i=r?n.indexOf(r):-1,a=e=>{for(let e of n)e.removeAttribute(`data-focused`);e.setAttribute(`data-focused`,`true`),e.scrollIntoView({behavior:`smooth`,block:`center`})};if(e.key===`j`||e.key===`ArrowDown`){let t=n[Math.min(n.length-1,Math.max(0,i+1))];t&&(e.preventDefault(),a(t));return}if(e.key===`k`||e.key===`ArrowUp`){let t=n[Math.max(0,i<=0?0:i-1)];t&&(e.preventDefault(),a(t));return}if(e.key===`g`&&!e.shiftKey){e.preventDefault(),a(t(n[0]));return}if(e.key===`G`||e.key===`g`&&e.shiftKey){e.preventDefault(),a(t(n[n.length-1]));return}if(e.key===`Escape`&&r){e.preventDefault(),r.removeAttribute(`data-focused`);return}if(e.key===`c`&&r){let t=r.querySelector(`.markdown-content`)?.innerText??r.innerText;t&&(navigator.clipboard?.writeText(t).catch(()=>{}),e.preventDefault());return}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,i])}var Ka=(0,X.createContext)(void 0);function qa({children:e,defaultTheme:t=`system`,storageKey:n=`wrongstack-theme`,defaultPalette:r=Zr,paletteStorageKey:i=wi}){let a=G(e=>e.setTheme),o=G(e=>e.setPalette),[s,c]=(0,X.useState)(()=>typeof window<`u`&&localStorage.getItem(n)||t),[l,u]=(0,X.useState)(()=>ai(i,r));(0,X.useEffect)(()=>{let e=window.document.documentElement;if(e.classList.remove(`light`,`dark`),s===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t)}else e.classList.add(s)},[s]),(0,X.useEffect)(()=>{Kr(window.document.documentElement,l)},[l]),(0,X.useEffect)(()=>{let e=e=>{e.key===i&&Xr(e.newValue)&&(u(e.newValue),o(e.newValue))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[i,o]);let d={theme:s,setTheme:e=>{localStorage.setItem(n,e),c(e),a(e)},palette:l,setPalette:e=>{try{localStorage.setItem(i,e)}catch{}u(e),o(e)}};return(0,Z.jsx)(Ka.Provider,{value:d,children:e})}function Ja(){let e=(0,X.useContext)(Ka);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e}function Ya(){let e=ti(e=>e.snapshot),t=K(e=>e.setCronJobsOpen),n=e?.jobs??[],r=n.filter(e=>e.overdue).length,i=n.filter(e=>e.enabled&&!e.overdue).length,a=n.length;return a===0?null:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:U(`relative inline-flex h-8 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,r>0?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/15`:`border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`),title:`${a} cron job${a===1?``:`s`}${r>0?`, ${r} overdue`:``}`,children:[(0,Z.jsx)(Vn,{className:`h-3.5 w-3.5`}),(0,Z.jsxs)(`span`,{className:`hidden lg:inline`,children:[i,`/`,a]}),r>0?(0,Z.jsx)(`span`,{className:`min-w-4 bg-destructive/15 px-1 text-[10px] font-semibold tabular-nums text-destructive`,children:r>99?`99+`:r}):null]})}var Xa=X.forwardRef(({className:e,children:t,...n},r)=>(0,Z.jsxs)(Ke,{ref:r,className:U(`relative overflow-hidden`,e),...n,children:[(0,Z.jsx)(dt,{className:`h-full w-full rounded-[inherit]`,children:t}),(0,Z.jsx)(Za,{}),(0,Z.jsx)(me,{})]}));Xa.displayName=Ke.displayName;var Za=X.forwardRef(({className:e,orientation:t=`vertical`,...n},r)=>(0,Z.jsx)(Dr,{ref:r,orientation:t,className:U(`flex touch-none select-none transition-colors`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent p-[1px]`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent p-[1px]`,e),...n,children:(0,Z.jsx)(m,{className:`relative flex-1 rounded-full bg-border`})}));Za.displayName=Dr.displayName;var Qa=A,$a=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Fe,{ref:n,className:U(`inline-flex min-h-10 items-center justify-center rounded-md border border-border/60 bg-muted/55 p-1 text-muted-foreground shadow-sm`,e),...t}));$a.displayName=Fe.displayName;var eo=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(ie,{ref:n,className:U(`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border/60`,e),...t}));eo.displayName=ie.displayName;var to=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(we,{ref:n,className:U(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));to.displayName=we.displayName;var no=[` `,`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],ro=12;function io(e,t){return t===0?0:Math.min(8,Math.round(e/t*8))}function ao({bins:e,className:t}){let{t:n}=h(),r=Array.from({length:ro},(t,n)=>e.at(-(ro-n))??0),i=Math.max(...r,1);return i===1&&r.every(e=>e===0)?(0,Z.jsx)(`span`,{role:`img`,className:t,"aria-label":n(`common:sparkline.noActivity`),title:n(`common:sparkline.noActivityYet`),children:`—`}):(0,Z.jsx)(`span`,{role:`img`,className:t,"aria-label":n(`common:sparkline.activityMax`,{count:i}),title:n(`common:sparkline.activityPeak`,{count:i}),children:r.map((e,t)=>{let n=io(e,i),r=no[n];return(0,Z.jsx)(`span`,{style:{color:n>=7?`hsl(var(--success))`:`hsl(var(--muted-foreground))`,opacity:n>0?void 0:.3},children:r},t)})})}function oo({current:e,max:t,className:n,showLabel:r=!0}){let i=Math.min(e,t),a=Math.max(0,t-i),o=t>0?i/t*100:0,s=o>=90?`text-destructive`:o>=70?`text-warning`:`text-success`;return(0,Z.jsxs)(`span`,{className:n,title:`Fleet concurrency: ${e}/${t}`,children:[(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`font-mono text-[10px] tracking-tight`,children:[`[`,(0,Z.jsx)(`span`,{className:s,children:`█`.repeat(i)}),(0,Z.jsx)(`span`,{className:`text-[hsl(var(--muted))]`,children:`░`.repeat(a)}),`]`]}),r&&(0,Z.jsxs)(`span`,{className:`ml-1.5 tabular-nums text-[10px] text-muted-foreground font-mono`,children:[e,`/`,t]})]})}function so(e){let t=Date.now()-e;return t<5e3?z.t(`common:time.justNow`):t<6e4?z.t(`common:time.compactSecondsAgo`,{count:Math.floor(t/1e3)}):t<36e5?z.t(`common:time.compactMinutesAgo`,{count:Math.floor(t/6e4)}):z.t(`common:time.compactHoursAgo`,{count:Math.floor(t/36e5)})}var co={spawned:`🚀`,task_started:`▶`,tool_executed:`⚡`,iteration_summary:`🔄`,budget_warning:`!`,budget_extended:`⚡`,task_completed:`✅`,ctx_pct:`💬`,leader_updated:`👑`};function lo({events:e,max:t=20,className:n}){let{t:r}=h(),i=e.slice(0,t);return i.length===0?(0,Z.jsx)(`div`,{className:`py-4 text-center text-xs text-muted-foreground ${n??``}`,children:r(`activity:timeline.noEvents`)}):(0,Z.jsx)(`div`,{className:`space-y-0.5 overflow-y-auto max-h-48 ${n??``}`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 text-[10px] leading-tight py-0.5 px-1 rounded hover:bg-accent/50 transition-colors`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 w-5 text-center`,"aria-hidden":`true`,children:co[e.kind]??`·`}),(0,Z.jsx)(`span`,{className:`shrink-0 w-12 text-right text-muted-foreground font-mono tabular-nums`,children:so(e.timestamp)}),(0,Z.jsx)(`span`,{className:`truncate text-foreground/90`,children:e.message}),e.value!==void 0&&e.kind===`tool_executed`&&(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground font-mono`,children:e.value>=1e3?`${(e.value/1e3).toFixed(1)}s`:`${e.value}ms`}),e.value!==void 0&&e.kind===`ctx_pct`&&(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground font-mono`,children:[e.value,`%`]})]},e.id))})}var uo=st,fo=mt,po=se,mo=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Un,{ref:n,className:U(`ws-sheet-overlay fixed inset-0 z-50 bg-black/50 backdrop-blur-sm`,e),...t}));mo.displayName=Un.displayName;var ho=I(`ws-sheet-content fixed z-50 gap-4 bg-card shadow-2xl`,{variants:{side:{top:`inset-x-0 top-0 border-b`,bottom:`inset-x-0 bottom-0 border-t`,left:`inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-md`,right:`inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-md`}},defaultVariants:{side:`right`}}),go=X.forwardRef(({side:e=`right`,className:t,children:n,showOverlay:r=!0,showCloseButton:i=!0,...a},o)=>(0,Z.jsxs)(po,{children:[r?(0,Z.jsx)(mo,{}):null,(0,Z.jsxs)(ee,{ref:o,"data-side":e,className:U(ho({side:e}),t),...a,children:[n,i?(0,Z.jsxs)(mt,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none`,children:[(0,Z.jsx)(Jt,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Close`})]}):null]})]}));go.displayName=ee.displayName;var _o=({className:e,...t})=>(0,Z.jsx)(`div`,{className:U(`flex flex-col space-y-1.5 text-left p-4 border-b`,e),...t});_o.displayName=`SheetHeader`;var vo=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(St,{ref:n,className:U(`text-base font-semibold leading-none`,e),...t}));vo.displayName=St.displayName;var yo=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(le,{ref:n,className:U(`text-xs text-muted-foreground`,e),...t}));yo.displayName=le.displayName;function bo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}var xo=e=>{let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`};function So(e,t){let n=new Date(e),r=new Date(t),i=new Date(t-864e5);return xo(e)===xo(r.getTime())?`Today`:xo(e)===xo(i.getTime())?`Yesterday`:n.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:n.getFullYear()===r.getFullYear()?void 0:`numeric`})}function Co(e,n=Date.now()){let r=[];for(let n=0;n<e.length;n++){let i=t(e[n]);if(i.role===`tool`){let e=r[r.length-1];e&&e.kind===`tools`?e.tools.push(i):r.push({kind:`tools`,tools:[i],key:i.id})}else{let t=e[n-1];r.push({kind:`msg`,message:i,isFirst:!t||t.role!==i.role})}}let i=[];for(let e of r){if(e.kind===`msg`&&e.message.role===`user`){i.push({kind:`user`,message:e.message,key:e.message.id});continue}let t=i[i.length-1];if(t&&t.kind===`agent`)t.items.push(e);else{let t=e.kind===`msg`?e.message.id:e.key;i.push({kind:`agent`,items:[e],key:t})}}let a=e=>{if(e.kind===`user`)return e.message.timestamp;let n=t(e.items[0]);return n.kind===`msg`?n.message.timestamp:n.tools[0]?.timestamp??0},o=[],s=null;for(let e=0;e<i.length;e++){let r=t(i[e]),c=a(r),l=xo(c);if(l!==s&&(o.push({kind:`day`,key:`day-${l}-${e}`,label:So(c,n)}),s=l),r.kind===`user`){o.push({kind:`user`,key:r.key,message:r.message});continue}let u=e===i.length-1,d=r.items.map((e,t)=>{let n=t>0;return e.kind===`msg`?{kind:`msg`,key:e.message.id,message:e.message,isFirst:!n&&e.isFirst,isContinuation:n}:{kind:`tools`,key:e.key,tools:e.tools,isContinuation:n,isLastGroup:t===r.items.length-1,hasRunningTool:e.tools.some(e=>e.toolResult===void 0)}});o.push({kind:`agent`,key:r.key,items:d,isLastTurn:u})}return o}var wo={0:``,1:`▏`,2:`▎`,3:`▍`,4:`▌`,5:`▋`,6:`▊`,7:`▉`,8:`█`};function To(e){return e>=85?`bg-destructive`:e>=60?`bg-warning`:`bg-success`}function Eo(e){return e>=85?`text-destructive`:e>=60?`text-warning`:`text-success`}function Do(e){return e>=85?`shadow-[0_0_8px_-1px_hsl(var(--destructive)/0.5)] ring-1 ring-destructive/30`:e>=60?`shadow-[0_0_6px_-2px_hsl(var(--warning)/0.4)]`:``}function Oo(e){return e>=85?Pe:e>=60?lr:Ye}function ko(e){let t=jo(e),n=[[0,142],[45,125],[60,78],[72,35],[85,0],[100,-40]];for(let e=0;e<n.length-1;e++){let[r,i]=n[e],[a,o]=n[e+1];if(t<=a){let e=(t-r)/(a-r||1);return Math.round(i+e*(o-i))}}return-40}function Ao(e,t=55,n=75){return`hsl(${ko(e)}, ${n}%, ${t}%)`}function jo(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function Mo({pct:e,tokens:t,maxTokens:n,cache:r,segments:i=10,showTokens:a=!0,className:o,onClick:s,variant:c=`solid`}){let{t:l}=h(),u=jo(e),d=Math.round(u/100*i*8),f=u>=85,p=u>=60&&u<85,m=Oo(u),g=c===`iridescent`,_=!!r&&r.readTokens+r.writeTokens>0,v=[],y=d;for(let e=0;e<i;e++){let t=Math.min(8,y),n=(e+.5)/i*100;v.push({fill:t,positionPct:n}),y-=t}let b=`${Math.round(u)}%`,x=a&&t!==void 0&&n!==void 0&&n>0?` ${bo(t)}/${bo(n)}`:``;return(0,Z.jsxs)(s?`button`:`span`,{role:`progressbar`,"aria-valuenow":Math.round(u),"aria-valuemin":0,"aria-valuemax":100,"aria-valuetext":`${Math.round(u)}%`,className:U(`inline-flex items-center gap-1.5 px-2 py-1 rounded-lg text-[11px] font-mono font-medium shrink-0 transition-all duration-300`,s&&`cursor-pointer hover:scale-[1.02] hover:ring-1 hover:ring-ring`,Eo(u),f?`bg-destructive/10`:p?`bg-warning/10`:`bg-success/10`,Do(u),f&&`animate-pulse`,o),title:(t!==void 0&&n!==void 0?l(`activity:context.barWithTokens`,{tokens:t.toLocaleString(),max:n.toLocaleString(),pct:b}):l(`activity:context.barPct`,{pct:b}))+(s?l(`activity:context.barClick`):``),onClick:s?e=>{e.stopPropagation(),s()}:void 0,type:s?`button`:void 0,children:[(0,Z.jsx)(m,{className:U(`h-3 w-3 shrink-0`,Eo(u))}),(0,Z.jsx)(`span`,{className:`inline-flex font-mono text-[10px] leading-none tracking-tight`,children:v.map((e,t)=>(0,Z.jsx)(`span`,{className:U(`tabular-nums w-[0.55em] text-center transition-colors duration-300`,!g&&(e.fill>0?Eo(u):`text-muted-foreground/40`)),style:g&&e.fill>0?{color:Ao(e.positionPct,58,80)}:g?{color:`hsl(var(--muted-foreground) / 0.4)`}:void 0,children:wo[e.fill]??` `},t))}),(0,Z.jsx)(`span`,{className:`font-bold tracking-tight`,children:b}),x&&(0,Z.jsx)(`span`,{className:`tabular-nums opacity-80`,children:x}),_&&r?(0,Z.jsxs)(`span`,{className:`ml-1 inline-flex items-center gap-1 text-[10px] font-mono tabular-nums text-success`,title:r.coverageTokens>0&&n!==void 0&&n>0?`Cache covers ${r.coverageTokens.toLocaleString()} of ${n.toLocaleString()} tokens`:`Prompt cache: ${(r.hitRatio*100).toFixed(1)}% hit`,children:[`· `,(r.hitRatio*100).toFixed(1),`% hit`,r.coverageTokens>0&&n!==void 0&&n>0?` · covers ${bo(r.coverageTokens)}`:``]}):null]})}function No({pct:e,tokens:t,maxTokens:n,cache:r,showTokens:i=!0,className:a,onClick:o}){let{t:s}=h(),c=jo(e),l=`${Math.round(c)}%`,u=i&&t!==void 0&&n!==void 0&&n>0?` ${bo(t)}/${bo(n)}`:``,d=!!r&&r.readTokens+r.writeTokens>0,f=c>=85,p=c>=60&&c<85,m=Oo(c);return(0,Z.jsxs)(o?`button`:`span`,{role:`progressbar`,"aria-valuenow":Math.round(c),"aria-valuemin":0,"aria-valuemax":100,"aria-valuetext":`${Math.round(c)}%`,className:U(`inline-flex items-center gap-2 group`,o&&`cursor-pointer hover:opacity-90 transition-opacity`,a),title:(t!==void 0&&n!==void 0?s(`activity:context.barWithTokens`,{tokens:t.toLocaleString(),max:n.toLocaleString(),pct:l}):s(`activity:context.barPct`,{pct:l}))+(o?s(`activity:context.barClick`):``),onClick:o?e=>{e.stopPropagation(),o()}:void 0,type:o?`button`:void 0,children:[(0,Z.jsx)(`span`,{className:U(`relative h-2 w-20 overflow-hidden rounded-full shrink-0 transition-shadow duration-300`,`bg-muted/60 ring-1 ring-inset ring-border/30`,f&&`ring-destructive/30`),children:(0,Z.jsx)(`span`,{className:U(`h-full rounded-full transition-all duration-500 ease-out`,To(c),f&&`animate-pulse`),style:{width:`${Math.max(3,c)}%`,background:f?`linear-gradient(90deg, hsl(var(--destructive)) 0%, hsl(var(--destructive) / 0.72) 100%)`:p?`linear-gradient(90deg, hsl(var(--warning)) 0%, hsl(var(--warning) / 0.72) 100%)`:`linear-gradient(90deg, hsl(var(--success)) 0%, hsl(var(--success) / 0.72) 100%)`},children:(0,Z.jsx)(`span`,{className:U(`absolute inset-0 opacity-30 bg-gradient-to-r from-transparent via-white/40 to-transparent`,`animate-[shimmer_2s_ease-in-out_infinite]`)})})}),(0,Z.jsx)(m,{className:U(`h-3 w-3 shrink-0 transition-colors`,Eo(c))}),(0,Z.jsx)(`span`,{className:U(`text-[11px] font-mono tabular-nums font-bold tracking-tight transition-colors`,Eo(c)),children:l}),u&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:u}),d&&r?(0,Z.jsxs)(`span`,{className:`text-[10px] font-mono tabular-nums text-success`,title:r.coverageTokens>0&&n!==void 0&&n>0?`Cache covers ${r.coverageTokens.toLocaleString()} of ${n.toLocaleString()} tokens`:`Prompt cache: ${(r.hitRatio*100).toFixed(1)}% hit`,children:[`· `,(r.hitRatio*100).toFixed(1),`% hit`,r.coverageTokens>0&&n!==void 0&&n>0?` · covers ${bo(r.coverageTokens)}`:``]}):null]})}var Po={text:{labelKey:`kindAssistant`,icon:Ot,tone:`text-primary`,bubble:`border-border bg-card`},thinking:{labelKey:`kindThinking`,icon:cr,tone:`text-primary`,bubble:`border-primary/20 bg-primary/5`},tool_use:{labelKey:`kindToolCall`,icon:nn,tone:`text-warning`,bubble:`border-warning/20 bg-warning/5`},tool_result:{labelKey:`kindToolResult`,icon:Jn,tone:`text-success`,bubble:`border-success/20 bg-success/5`},error:{labelKey:`kindError`,icon:yt,tone:`text-destructive`,bubble:`border-destructive/25 bg-destructive/5`},status:{labelKey:`kindStatus`,icon:et,tone:`text-muted-foreground`,bubble:`border-border bg-muted/25`},system:{labelKey:`kindSystem`,icon:Wn,tone:`text-muted-foreground`,bubble:`border-border bg-muted/25`}};function Fo(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}function Io(e){return e.map(e=>{let t=Po[e.kind]??Po.status,n=Fo(e.ts),r=e.toolName?` [${e.toolName}]`:``;return`[${n}] ${e.agentName} · ${z.t(`activity:transcript.${t.labelKey}`)}${r}\n${e.content}`}).join(`
66
66
 
67
67
  `)}function Lo({entries:e,agentName:t,className:n,compact:r=!1,maxHeightClassName:i,title:a,showHeader:o=!0}){let{t:s}=h(),[c,l]=(0,X.useState)(!1),u=(0,X.useMemo)(()=>Io(e),[e]),d=(0,X.useCallback)(async()=>{if(u)try{await navigator.clipboard.writeText(u),l(!0),setTimeout(()=>l(!1),1600)}catch{}},[u]);return(0,Z.jsxs)(`div`,{className:U(`rounded-lg border bg-card`,n),children:[o&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b bg-muted/25 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(On,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,Z.jsx)(`span`,{className:`truncate text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:a??s(`activity:transcript.title`)}),t&&(0,Z.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,children:t}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground`,children:e.length})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:d,disabled:e.length===0,className:`flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,title:s(`activity:transcript.copyTitle`),children:[c?(0,Z.jsx)(Jn,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(it,{className:`h-3 w-3`}),s(c?`common:action.copied`:`common:action.copy`)]})]}),(0,Z.jsx)(`div`,{className:U(`space-y-2 overflow-y-auto p-2`,i??(r?`max-h-72`:`max-h-[32rem]`)),children:e.length===0?(0,Z.jsx)(`div`,{className:`rounded-md border border-dashed border-border p-3 text-center text-xs text-muted-foreground`,children:s(`activity:transcript.empty`)}):e.map(e=>{let t=Po[e.kind]??Po.status,n=t.icon;return(0,Z.jsxs)(`div`,{className:U(`rounded-md border px-3 py-2`,t.bubble,r?`space-y-1`:`space-y-1.5`),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(n,{className:U(`h-3.5 w-3.5 shrink-0`,t.tone)}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:s(`activity:transcript.${t.labelKey}`)}),e.toolName&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate rounded bg-background/70 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:e.toolName}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] tabular-nums text-muted-foreground`,children:Fo(e.ts)})]}),(0,Z.jsx)(`pre`,{className:U(`whitespace-pre-wrap break-words font-mono text-foreground/85`,r?`text-[10px] leading-relaxed`:`text-xs leading-relaxed`),children:e.content})]},e.id)})})]})}var Ro={running:{led:`bg-success`,pulse:!0,badge:`bg-success/15 text-success`},completed:{led:`bg-success`,pulse:!1,badge:`bg-muted text-muted-foreground`},failed:{led:`bg-destructive`,pulse:!1,badge:`bg-destructive/15 text-destructive`},timeout:{led:`bg-warning`,pulse:!1,badge:`bg-warning/15 text-warning`},stopped:{led:`bg-muted-foreground`,pulse:!1,badge:`bg-muted text-muted-foreground`}};function zo({agent:e,isLeader:t}){let n=Ro[e.status],{t:r}=h(),i=e.status===`running`,[a,o]=(0,X.useState)(Date.now());(0,X.useEffect)(()=>{if(e.status!==`running`)return;o(Date.now());let t=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(t)},[e.status]);let s=Jr(e,a),c=ii(t=>t.agentTranscripts.get(e.id)??Si),l=[...e.toolLog.slice(0,8)].reverse();return(0,Z.jsxs)(`div`,{className:U(`rounded-xl border p-4 space-y-3`,i?`border-primary/20 bg-primary/[0.02]`:`border-border bg-card`,t&&`ring-2 ring-warning/30`),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:U(`led`,n.led,n.pulse&&`led-pulse`,`mt-0.5`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:e.name}),t&&(0,Z.jsx)(Qe,{className:`h-3.5 w-3.5 text-warning`,"aria-label":r(`activity:fleet.leader`)}),e.extensions>0&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full bg-warning/15 text-[10px] text-warning font-medium`,children:[(0,Z.jsx)(lr,{className:`h-2.5 w-2.5`}),`×`,e.extensions]})]}),(0,Z.jsx)(`span`,{className:U(`inline-block mt-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium`,n.badge),children:r(`activity:fleet.status.${e.status}`)})]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:t&&(0,Z.jsx)(`span`,{className:`text-[9px] bg-warning/15 text-warning px-1.5 py-0.5 rounded`,children:r(`activity:agentsMonitor.leaderBadge`)})})]}),e.description&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:e.description}),e.budgetWarning&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-warning/10 border border-warning/25 text-xs`,children:[(0,Z.jsx)(lr,{className:`h-3.5 w-3.5 text-warning shrink-0`}),(0,Z.jsx)(`span`,{className:`text-warning`,children:r(`activity:fleet.hittingLimitTitle`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit})})]}),e.failureReason&&(0,Z.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-destructive/10 border border-destructive/20 text-xs`,children:(0,Z.jsxs)(`span`,{className:`text-destructive font-medium`,children:[`✗ `,e.failureReason]})}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentsMonitor.iters`)}),(0,Z.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:e.iteration})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentsMonitor.tools`)}),(0,Z.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:e.toolCalls})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.cost`)}),(0,Z.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:s.cost})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.elapsed`)}),(0,Z.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:s.elapsed})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentsMonitor.activityBins`)}),(0,Z.jsx)(ao,{bins:e.sparklineBins,className:`font-mono text-[9px]`})]}),(0,Z.jsx)(Mo,{pct:e.ctxPct,tokens:e.ctxTokens,maxTokens:e.maxContext})]}),(e.provider||e.model)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(y,{className:`h-3 w-3`}),(0,Z.jsxs)(`span`,{className:`font-mono`,children:[e.provider??`?`,`/`,e.model??`?`]})]}),(e.currentTool||e.lastTool)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(nn,{className:U(`h-3 w-3`,i&&`animate-pulse text-primary`)}),(0,Z.jsx)(`span`,{className:`font-mono`,children:e.currentTool??e.lastTool}),i&&(0,Z.jsx)(Rn,{className:`h-3 w-3 animate-spin`})]}),(0,Z.jsx)(Lo,{entries:c,agentName:e.name,compact:!0,maxHeightClassName:`max-h-80`}),e.partialText&&i&&(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-2`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider mb-1`,children:r(`activity:agentsMonitor.streamingOutput`)}),(0,Z.jsx)(`pre`,{className:`text-[10px] font-mono text-foreground/80 whitespace-pre-wrap line-clamp-3 leading-relaxed`,children:e.partialText})]}),l.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentsMonitor.recentTools`)}),(0,Z.jsx)(`div`,{className:`space-y-0.5`,children:l.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-mono`,children:[(0,Z.jsx)(`span`,{className:U(`shrink-0`,e.ok?`text-success`:`text-destructive`),children:e.ok?`✓`:`✗`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e.name}),(0,Z.jsx)(`span`,{className:`ml-auto tabular-nums text-muted-foreground shrink-0`,children:e.durationMs>=1e3?`${(e.durationMs/1e3).toFixed(1)}s`:`${e.durationMs}ms`})]},`${e.name}-${e.at}`))})]}),e.finalText&&!i&&(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-2`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider mb-1`,children:r(`activity:agentsMonitor.finalOutput`)}),(0,Z.jsx)(`pre`,{className:`text-[10px] font-mono text-foreground/80 whitespace-pre-wrap line-clamp-4 leading-relaxed`,children:e.finalText})]})]})}function Bo(e){return e==null||!Number.isFinite(e)||e<0?`$0.0000`:e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function Vo(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function Ho(e){if(e==null||!Number.isFinite(e)||e<0)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}var Uo={running:{led:`bg-success`,labelKey:`statusRunning`,pulse:!0,color:`text-success`},completed:{led:`bg-success`,labelKey:`statusDone`,pulse:!1,color:`text-success`},failed:{led:`bg-destructive`,labelKey:`statusFailed`,pulse:!1,color:`text-destructive`},timeout:{led:`bg-warning`,labelKey:`statusTimeout`,pulse:!1,color:`text-warning`},stopped:{led:`bg-muted-foreground`,labelKey:`statusStopped`,pulse:!1,color:`text-muted-foreground`}};function Wo({agent:e,isSelected:t,isLeader:n,onClick:r}){let{t:i}=h(),a=Uo[e.status],o=e.status===`running`,s=Math.min(100,Math.max(0,e.ctxPct));return(0,Z.jsxs)(`button`,{type:`button`,onClick:r,className:U(`min-w-[650px] w-full text-left grid grid-cols-[140px_60px_1fr_60px_60px_60px_60px_50px_50px] items-center gap-x-2 px-3 py-1.5 rounded-md text-xs transition-colors`,t?`bg-primary/15 ring-1 ring-primary/40`:`hover:bg-accent/50`,o&&!t&&`bg-muted/30`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,Z.jsx)(`span`,{className:U(`led shrink-0`,a.led,a.pulse&&`led-pulse`)}),(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),n&&(0,Z.jsx)(Qe,{className:`h-3 w-3 shrink-0 text-warning`,"aria-label":i(`activity:fleet.leader`)})]}),(0,Z.jsx)(`span`,{className:U(`text-[10px] tabular-nums`,o?`text-success`:`text-muted-foreground`),children:i(`activity:fleet.${a.labelKey}`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,Z.jsx)(ao,{bins:e.sparklineBins,className:`font-mono text-[9px]`}),e.budgetWarning&&(0,Z.jsx)(`span`,{title:i(`activity:fleet.hittingLimitTitle`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit}),children:(0,Z.jsx)(lr,{className:`h-3 w-3 shrink-0 text-warning`,"aria-label":i(`common:status.budgetWarning`)})})]}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground text-[10px]`,children:[e.iteration,`it`]}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground text-[10px]`,children:[e.toolCalls,`tc`]}),(0,Z.jsx)(`span`,{className:`tabular-nums font-mono text-[10px]`,children:Bo(e.costUsd)}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-muted overflow-hidden`,children:(0,Z.jsx)(`div`,{className:U(`h-full rounded-full transition-all`,s>=85?`bg-destructive`:s>=70?`bg-warning`:`bg-success`),style:{width:`${s}%`}})}),(0,Z.jsx)(`span`,{className:`text-[9px] tabular-nums text-muted-foreground font-mono leading-none`,children:e.maxContext>0?`${s}%`:`—`})]}),(0,Z.jsx)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:e.extensions>0?`\u26A1\u00D7${e.extensions}`:`—`}),(0,Z.jsx)(`span`,{className:`text-[9px] text-destructive truncate`,title:e.failureReason,children:e.failureReason??``})]})}function Go(){let{t:e}=h(),t=vi(e=>e.panels),n=vi(e=>e.clear);return t.length===0?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-6 text-center`,children:[(0,Z.jsx)(Tn,{className:`h-6 w-6 text-muted-foreground/60`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:inspector.councilEmpty`,{defaultValue:`No council has convened yet in this session.`})}),(0,Z.jsx)(`p`,{className:`max-w-[22rem] text-[11px] text-muted-foreground/70`,children:e(`activity:inspector.councilEmptyHint`,{defaultValue:`The Brain convenes a multi-model panel for questions at or above its council risk floor. Configure it under Settings › Brain › Council.`})})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/60 px-3 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:inspector.councilCount`,{defaultValue:`{{count}} panel(s)`,count:t.length})}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`rounded px-1.5 py-0.5 text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:e(`activity:inspector.councilClear`,{defaultValue:`Clear`})})]}),(0,Z.jsx)(`ul`,{className:`flex min-h-0 flex-col divide-y divide-border/50`,children:t.map(e=>(0,Z.jsx)(Ko,{panel:e},e.requestId))})]})}function Ko({panel:e}){let{t}=h(),n=e.phase===`voting`,r=!n&&(e.validVoteCount??0)>1&&(e.distinctTargetCount??0)<(e.validVoteCount??0);return(0,Z.jsx)(`li`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Tn,{className:U(`mt-0.5 h-3.5 w-3.5 shrink-0`,n?`animate-pulse text-primary`:e.status===`denied`?`text-destructive`:`text-muted-foreground`)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:U(`truncate text-[11px] font-medium`,n?`text-primary`:`text-foreground`),children:gi(e)}),e.judgeUsed?(0,Z.jsx)(ve,{className:`h-3 w-3 shrink-0 text-info`,"aria-label":t(`activity:councilLogTimeline.judgeUsed`)}):null,r?(0,Z.jsx)(Pe,{className:`h-3 w-3 shrink-0 text-warning`,"aria-label":t(`activity:councilLogTimeline.panelNotDiverse`)}):null]}),e.question?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-muted-foreground`,children:e.question}):null,(0,Z.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.seats.map(e=>(0,Z.jsx)(qo,{seat:e},e.seatId))}),e.reason&&e.status!==`decided`?(0,Z.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:e.reason}):null,(e.warnings??[]).map(e=>(0,Z.jsxs)(`p`,{className:`mt-1 flex items-start gap-1 text-[10px] text-warning`,children:[(0,Z.jsx)(Pe,{className:`mt-px h-3 w-3 shrink-0`}),(0,Z.jsx)(`span`,{children:e})]},e))]})]})})}function qo({seat:e}){let{t}=h(),n=e.status!==`valid`,r=n?e.error??e.status:e.optionId??e.stance??`stance`;return(0,Z.jsxs)(`li`,{className:`flex items-baseline gap-1.5 font-mono text-[10px]`,children:[(0,Z.jsx)(`span`,{className:n?`text-destructive`:`text-muted-foreground/70`,children:n?`×`:`•`}),(0,Z.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.persona}),e.veto?(0,Z.jsx)(Ge,{className:`h-2.5 w-2.5 shrink-0 text-warning`,"aria-label":t(`activity:councilLogTimeline.veto`)}):null,(0,Z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`→`}),(0,Z.jsx)(`span`,{className:U(`truncate`,n?`text-destructive`:`text-foreground`),children:r}),e.model?(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-muted-foreground/60`,children:e.model}):null]})}function Jo(e,t=20,n){let[r,i]=(0,X.useState)(1),a=e.length,o=Math.max(1,Math.ceil(a/t));return(0,X.useEffect)(()=>{i(e=>Math.min(e,o))},[o]),(0,X.useEffect)(()=>{i(1)},[n]),{page:r,pageSize:t,totalItems:a,pageItems:(0,X.useMemo)(()=>Array.from(e.slice((r-1)*t,r*t)),[e,r,t]),setPage:i}}function Yo({page:e,pageSize:t,totalItems:n,onPageChange:r,className:i,compact:a=!1,itemLabel:o=`items`}){let{t:s}=h(),c=Math.max(1,Math.ceil(n/t)),l=Math.min(Math.max(1,e),c);if(n<=t)return null;let u=(l-1)*t+1,d=Math.min(n,l*t);return(0,Z.jsxs)(`nav`,{"aria-label":`${o} pagination`,className:U(`flex shrink-0 items-center justify-between gap-2 border-t border-border/75 bg-card/80 px-2 py-2`,i),children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":s(`activity:pagination.previousPage`),disabled:l<=1,onClick:()=>r(l-1),className:`inline-flex h-8 items-center gap-1 border border-border/75 px-2 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35`,children:[(0,Z.jsx)(rr,{className:`h-3.5 w-3.5`}),!a&&(0,Z.jsx)(`span`,{children:s(`activity:pagination.previous`)})]}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-center font-mono text-[10px] tabular-nums text-muted-foreground`,children:a?`${l} / ${c}`:`${u}–${d} of ${n} ${o}`}),(0,Z.jsxs)(`button`,{type:`button`,"aria-label":s(`activity:pagination.nextPage`),disabled:l>=c,onClick:()=>r(l+1),className:`inline-flex h-8 items-center gap-1 border border-border/75 px-2 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35`,children:[!a&&(0,Z.jsx)(`span`,{children:s(`activity:pagination.next`)}),(0,Z.jsx)(Yt,{className:`h-3.5 w-3.5`})]})]})}var Xo={shell:Oe,package:Ar,network:gn,"fs.write":Ie,config:Ie},Zo={shell:`text-warning`,package:`text-info`,network:`text-success`,"fs.write":`text-primary`,config:`text-muted-foreground`},Qo=[`all`,`shell`,`package`,`network`,`fs.write`,`config`];function $o(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return e.slice(11,19)}}function es(e){if(e.input.command)return String(e.input.command).slice(0,80);if(e.input.url)return String(e.input.url).slice(0,80);if(e.input.packages){let t=e.input.packages;return Array.isArray(t)?t.join(`, `).slice(0,80):String(t).slice(0,80)}return JSON.stringify(e.input).slice(0,80)}function ts(e){return/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function ns(e){let t=[`timestamp,tool,risk,detail,outcome`,...e.map(e=>{let t=e.input.command??e.input.url??e.input.packages??JSON.stringify(e.input);return[ts(e.ts),ts(e.toolName),ts(e.risk),ts(String(t)),ts(e.outcome??``)].join(`,`)})].join(`
68
- `),n=new Blob([t],{type:`text/csv;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`side-effects-${new Date().toISOString().slice(0,19).replace(/[:.]/g,`-`)}.csv`,i.click(),URL.revokeObjectURL(r)}function rs(){let e=_i(e=>e.sideEffects),t=_i(e=>e.loading),{t:n}=h(),[r,i]=(0,X.useState)(`all`),[o,s]=(0,X.useState)(`time`),[c,l]=(0,X.useState)(`desc`);(0,X.useEffect)(()=>{_i.getState().setLoading(!0),V(async()=>{let{getWSClient:e}=await import(`./ws-client-C4OHn-_g.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`})})},[]);let u=()=>{_i.getState().setLoading(!0),V(async()=>{let{getWSClient:e}=await import(`./ws-client-C4OHn-_g.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`})})},d=e=>{o===e?l(c===`asc`?`desc`:`asc`):(s(e),l(e===`time`?`desc`:`asc`))},f=(0,X.useMemo)(()=>{let t=r===`all`?[...e]:e.filter(e=>e.risk===r);return t.sort((e,t)=>{let n=0;return o===`time`?n=e.ts.localeCompare(t.ts):o===`tool`?n=e.toolName.localeCompare(t.toolName):o===`risk`&&(n=e.risk.localeCompare(t.risk)),c===`asc`?n:-n}),t},[e,r,o,c]),p=Jo(f,20,`${r}:${o}:${c}`);if(e.length===0&&!t)return(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-8 text-muted-foreground`,children:[(0,Z.jsx)(Ie,{className:`h-8 w-8 opacity-40`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:n(`activity:sideEffects.empty`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground/75`,children:n(`activity:sideEffects.emptyHint`)})]});let m=({column:e})=>o===e?c===`asc`?(0,Z.jsx)(a,{className:`inline h-3 w-3`}):(0,Z.jsx)(Nn,{className:`inline h-3 w-3`}):(0,Z.jsx)(`span`,{className:`opacity-30`,children:`↕`});return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/70 px-3 py-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:[n(`activity:sideEffects.heading`),` (`,f.length,r===`all`?``:`/${e.length}`,`)`]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>ns(f),disabled:f.length===0,className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30`,title:n(`activity:sideEffects.exportTitle`),children:[(0,Z.jsx)(Cr,{className:`h-3 w-3`}),`CSV`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:u,className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,Z.jsx)(wr,{className:U(`h-3 w-3`,t&&`animate-spin`)}),n(`common:action.refresh`)]})]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/60 bg-muted/20 px-2 py-1`,children:Qo.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:U(`rounded-md px-2 py-0.5 text-[10px] font-medium uppercase transition-colors`,r===e?`bg-primary/10 text-primary ring-1 ring-primary/20`:`text-muted-foreground hover:bg-muted/70 hover:text-foreground`),children:e===`all`?n(`activity:sideEffects.all`):e},e))}),(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Z.jsx)(`thead`,{className:`sticky top-0 bg-card/95 text-muted-foreground backdrop-blur`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`time`),children:[n(`activity:sideEffects.colTime`),` `,(0,Z.jsx)(m,{column:`time`})]}),(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`tool`),children:[n(`activity:sideEffects.colTool`),` `,(0,Z.jsx)(m,{column:`tool`})]}),(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`risk`),children:[n(`activity:sideEffects.colRisk`),` `,(0,Z.jsx)(m,{column:`risk`})]}),(0,Z.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colDetail`)}),(0,Z.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colOutcome`)})]})}),(0,Z.jsx)(`tbody`,{children:p.pageItems.map((e,t)=>{let n=Xo[e.risk]??Ie,r=Zo[e.risk]??`text-muted-foreground`;return(0,Z.jsxs)(`tr`,{className:`border-b border-border/45 hover:bg-muted/45`,children:[(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:$o(e.ts)}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 font-medium text-foreground`,children:e.toolName}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5`,children:(0,Z.jsxs)(`span`,{className:U(`flex items-center gap-1`,r),children:[(0,Z.jsx)(n,{className:`h-3 w-3`}),e.risk]})}),(0,Z.jsx)(`td`,{className:`max-w-xs truncate px-2 py-1.5 font-mono text-muted-foreground`,children:es(e)}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:e.outcome??``})]},`${e.toolUseId}-${t}`)})})]})}),(0,Z.jsx)(Yo,{page:p.page,pageSize:p.pageSize,totalItems:p.totalItems,onPageChange:p.setPage,itemLabel:`side effects`})]})}function is(e){return e<=0?`$0`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(5)}`.replace(/0+$/,``).replace(/\.$/,``)}function as(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function os(e,t){let n=Array.from(e.values());return n.sort((e,n)=>{if(e.id===t)return-1;if(n.id===t)return 1;let r=e.status===`running`?0:1,i=n.status===`running`?0:1;return r===i?e.startedAt-n.startedAt:r-i}),n}function ss(){let{t:e}=h(),t=K(e=>e.sidebarOpen),n=K(e=>e.activeActivity),r=t&&n===`agents`,i=ii(e=>Array.from(e.agents.values()).filter(e=>e.status===`running`).length);return(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`inspector-trigger`,"aria-expanded":r,"aria-label":e(`activity:inspector.openAgentsPanel`),onClick:()=>Ai(`agents`),className:U(`relative inline-flex h-8 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,r?`border-primary/40 bg-primary/10 text-primary`:`border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`),title:e(`activity:inspector.openAgentsPanel`),children:[(0,Z.jsx)(On,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{className:`hidden lg:inline`,children:e(`activity:nav.agents`)}),i>0?(0,Z.jsx)(`span`,{className:`min-w-4 bg-primary/15 px-1 text-[10px] font-semibold tabular-nums text-primary`,children:i>99?`99+`:i}):null]})}function cs(){let e=K(e=>e.inspectorOpen),t=K(e=>e.inspectorTab),n=K(e=>e.setInspectorOpen),r=K(e=>e.setInspectorTab),i=K(e=>e.inspectorFocusedAgentId),a=K(e=>e.setInspectorFocusedAgentId),{t:o}=h(),s=ii(e=>e.agents),c=ii(e=>e.leaderId),l=ii(e=>e.fleetTokensIn),u=ii(e=>e.fleetTokensOut),d=ii(e=>e.eventTimeline),f=(0,X.useMemo)(()=>os(s,c),[s,c]),p=f.filter(e=>e.status===`running`).length,m=f.reduce((e,t)=>e+t.costUsd,0),g=f.length,[_,v]=(0,X.useState)(null),y=(0,X.useMemo)(()=>_?s.get(_)??f[0]??null:f[0]??null,[_,f,s]),b=_i(e=>e.sideEffects.length),x=vi(e=>e.panels.length),S=vi(e=>e.panels.filter(e=>e.phase===`voting`).length);return(0,X.useEffect)(()=>{i&&e&&(v(i),r(`agents`),a(null))},[i,e,r,a]),(0,Z.jsx)(uo,{open:e,onOpenChange:n,modal:!1,children:(0,Z.jsxs)(go,{id:`workbench-inspector`,"data-testid":`inspector-drawer`,side:`right`,showOverlay:!1,showCloseButton:!1,onPointerDownOutside:e=>e.preventDefault(),onFocusOutside:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-testid="inspector-trigger"]`)?.focus()},className:`flex w-[calc(100vw-3rem)] max-w-none flex-col gap-0 overflow-hidden border-l border-border/80 bg-card/96 p-0 shadow-[-24px_0_64px_-36px_hsl(var(--shadow-color)/0.65)] backdrop-blur-xl sm:w-[min(680px,48vw)] sm:max-w-[680px]`,children:[(0,Z.jsxs)(_o,{className:`relative gap-1 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Z.jsxs)(vo,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(Re,{className:`h-4 w-4 text-primary`}),o(`activity:inspector.label`)]}),(0,Z.jsx)(yo,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:g>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:U(`h-1.5 w-1.5 rounded-full`,p>0?`bg-success animate-pulse`:`bg-muted-foreground/50`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[p,`/`,g]})]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`↓`,as(l),` ↑`,as(u),` · `,is(m)]})]}):(0,Z.jsx)(`span`,{children:o(`activity:inspector.agentsAppearHint`)})}),(0,Z.jsx)(fo,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`inspector-close`,className:`absolute right-3 top-3 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":o(`activity:inspector.collapseAria`),title:o(`activity:inspector.collapseTitle`),children:(0,Z.jsx)(Jt,{className:`h-4 w-4`})})})]}),(0,Z.jsxs)(Qa,{value:t,onValueChange:e=>r(e),className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsxs)($a,{className:`flex h-10 min-h-10 shrink-0 justify-start gap-1 border-x-0 border-t-0 border-b border-border/70 bg-muted/30 p-2 shadow-none`,"aria-label":o(`activity:inspector.label`),children:[(0,Z.jsx)(ls,{value:`fleet`,icon:(0,Z.jsx)(On,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabFleet`),count:g,running:p}),(0,Z.jsx)(ls,{value:`agents`,icon:(0,Z.jsx)(Er,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabAgents`),count:g}),(0,Z.jsx)(ls,{value:`sideEffects`,icon:(0,Z.jsx)(Ie,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabAudit`),count:b}),(0,Z.jsx)(ls,{value:`council`,icon:(0,Z.jsx)(Tn,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabCouncil`,{defaultValue:`Council`}),count:x,running:S})]}),(0,Z.jsx)(to,{value:`fleet`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(us,{fleetList:f,leaderId:c,selectedAgentId:_,eventTimeline:d,onSelectAgent:e=>{v(e.id),r(`agents`)}})}),(0,Z.jsx)(to,{value:`agents`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(ds,{fleetList:f,selectedAgent:y,leaderId:c,selectedAgentId:y?.id??null,onSelectAgent:v})}),(0,Z.jsx)(to,{value:`sideEffects`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(rs,{})}),(0,Z.jsx)(to,{value:`council`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(Go,{})})]})]})})}function ls({value:e,icon:t,label:n,count:r,running:i}){return(0,Z.jsxs)(eo,{value:e,className:U(`flex h-6 items-center gap-1.5 rounded-md px-2.5 py-0 text-[11px] font-medium text-muted-foreground shadow-none transition-colors scroll-mt-12`,`hover:bg-background/60 hover:text-foreground data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border`),children:[t,n,r>0&&(0,Z.jsx)(`span`,{className:U(`tabular-nums text-[10px] px-1 rounded-full`,i&&i>0?`bg-success/15 text-success`:`bg-muted text-muted-foreground`),children:i===void 0?r:`${i}/${r}`})]})}function us({fleetList:e,leaderId:t,selectedAgentId:n,eventTimeline:r,onSelectAgent:i}){let{t:a}=h();return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[e.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Er,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:a(`activity:inspector.noAgentsActive`)}),(0,Z.jsx)(`p`,{className:`text-[11px] mt-0.5`,children:a(`activity:inspector.agentsAppearHint`)})]}):(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-1.5`,children:e.map(e=>(0,Z.jsx)(Wo,{agent:e,isSelected:n===e.id,isLeader:e.id===t,onClick:()=>i(e)},e.id))}),r.length>0&&(0,Z.jsx)(`div`,{className:`border-t px-3 py-1.5 shrink-0`,children:(0,Z.jsx)(lo,{events:r,max:4})})]})}function ds({fleetList:e,selectedAgent:t,leaderId:n,selectedAgentId:r,onSelectAgent:i}){let{t:a}=h();if(e.length===0)return(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(On,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:a(`activity:inspector.noAgentsActive`)})]});if(!t)return null;let o=Math.max(0,e.findIndex(e=>e.id===r));return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:(0,Z.jsx)(`div`,{className:`max-w-2xl mx-auto`,children:(0,Z.jsx)(zo,{agent:t,isLeader:t.id===n})})}),(0,Z.jsx)(`div`,{className:`border-t px-2 py-1.5 shrink-0`,children:(0,Z.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto pb-0.5`,children:e.map((e,n)=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:U(`shrink-0 flex items-center gap-1.5 px-2 py-1 rounded-md text-[10px] transition-colors`,e.id===t?.id?`bg-primary/15 text-primary ring-1 ring-primary/40`:`hover:bg-accent text-muted-foreground`),title:n===o?a(`activity:inspector.selected`,{name:e.name}):e.name,children:[(0,Z.jsx)(`span`,{className:U(`h-1.5 w-1.5 rounded-full shrink-0`,e.status===`running`?`bg-success animate-pulse`:e.status===`failed`?`bg-destructive`:`bg-muted-foreground/50`)}),(0,Z.jsx)(`span`,{className:`truncate max-w-[8rem]`,children:e.name})]},e.id))})})]})}function fs(e){return e.split(`-`).map(e=>e.slice(0,1).toUpperCase()+e.slice(1)).join(` `)}function ps(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${Math.round(e)} B`}function ms(){let[e,t]=(0,X.useState)(null);return(0,X.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await fetch(`/debug/system`,{cache:`no-store`});if(!n.ok)return;let r=await n.json();!e&&Number.isFinite(r.memoryUsage?.rss)&&t(r)}catch{}};n();let r=window.setInterval(()=>void n(),5e3);return()=>{e=!0,window.clearInterval(r)}},[]),e}function hs({currentView:e,projectName:t,sessionLabel:n,isLoading:r,iteration:i,onPalette:a,onSearch:o,onModel:s,onSettings:c}){let{t:l}=h(),{theme:u,setTheme:d,palette:f,setPalette:p}=Ja(),m=G(e=>e.wsConnected),g=W(e=>e.appVersion),_=W(e=>e.latestVersion),v=W(e=>e.updateAvailable),b=W(e=>e.droppedTools),x=u===`system`?typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:u,S=(0,X.useCallback)(()=>{d(x===`dark`?`light`:`dark`)},[x,d]),w=ms(),T=w?w.memoryUsage.heapUsed/w.heapLimit:0,E=w?.codebaseIndexServer,D=E?.health,O=D?.server;return(0,Z.jsx)(`div`,{className:`hidden shrink-0 border-b border-border/70 bg-card/85 px-3 py-2 shadow-sm backdrop-blur-xl md:block`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:t||`WrongStack`}),g?(0,Z.jsxs)(`span`,{className:U(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,v&&_&&_!==g?`border-warning/40 bg-warning/10 text-warning`:`border-border/70 bg-muted/50 text-muted-foreground`),title:v&&_&&_!==g?`Update available: v${g} → v${_} — run wstack update`:`WrongStack v${g}`,children:[`v`,g,v&&_&&_!==g?(0,Z.jsxs)(`span`,{className:`text-[10px] opacity-80`,children:[`→ v`,_]}):null]}):null,(0,Z.jsx)(`span`,{className:`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:fs(e)}),(0,Z.jsxs)(`span`,{className:U(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium`,r?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`),children:[r?(0,Z.jsx)(On,{className:`h-3 w-3 animate-pulse`}):(0,Z.jsx)(_t,{className:`h-3 w-3`}),r?`Running`:`Ready`,i?(0,Z.jsxs)(`span`,{className:`tabular`,children:[i.index,i.max>0?`/${i.max}`:``]}):null]}),w?(0,Z.jsxs)(`span`,{className:U(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,T>=.85?`text-destructive`:T>=.6?`text-warning`:`text-success`),title:`WebUI server PID ${w.pid} · heap ${ps(w.memoryUsage.heapUsed)} / ${ps(w.heapLimit)}`,children:[`RAM `,ps(w.memoryUsage.rss)]}):null,E?(0,Z.jsxs)(`span`,{className:U(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,E.status===`connected`?`text-success`:E.status===`unresponsive`||E.status===`error`?`text-destructive`:E.status===`degraded`||E.status===`connecting`||E.status===`stopping`?`text-warning`:`text-muted-foreground`),title:[`Codebase index: ${D?.status??E.status}`,E.pid?`PID ${E.pid}`:null,D?.latencyMs==null?null:`RTT ${D.latencyMs}ms`,O?`RAM ${ps(O.memory.rss)}`:null,D?.missedHeartbeats?`missed ${D.missedHeartbeats}`:null].filter(Boolean).join(` · `),children:[`Index `,D?.status??E.status]}):null,b>0?(0,Z.jsxs)(`span`,{className:`rounded-md border border-warning/40 bg-warning/10 px-1.5 py-0.5 text-[11px] font-medium tabular-nums text-warning`,title:`${b} tool(s) dropped from provider requests due to maxTools limit`,children:[`-`,b,` tools`]}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:n||`No named session`})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:l(`activity:topbar.searchChat`),children:[(0,Z.jsx)(Ft,{className:`h-3.5 w-3.5`}),l(`activity:topbar.search`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:l(`activity:topbar.commandPalette`),children:[(0,Z.jsx)(C,{className:`h-3.5 w-3.5`}),l(`activity:topbar.command`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:s,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:l(`activity:topbar.switchModel`),children:[(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),l(`activity:topbar.model`)]}),(0,Z.jsx)(`button`,{type:`button`,onClick:S,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:x===`dark`?`Switch to light theme`:`Switch to dark theme`,children:x===`dark`?(0,Z.jsx)(ye,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(gt,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(ia,{children:[(0,Z.jsx)(aa,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`${l(`settings:general.paletteSwitcherTitle`)}: ${l(oi(f).labelKey)}`,"aria-label":`${l(`settings:general.paletteSwitcherTitle`)}: ${l(oi(f).labelKey)}`,children:(0,Z.jsx)(Je,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(ca,{align:`end`,className:`w-56`,children:[(0,Z.jsx)(fa,{children:l(`settings:general.paletteHeading`)}),ni.map(e=>(0,Z.jsxs)(la,{onSelect:()=>p(e.id),className:`gap-2`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 rounded-[3px] border border-border/70`,style:{background:`linear-gradient(90deg, ${e.swatch} 0 50%, ${e.swatchSecondary} 50% 100%)`}}),(0,Z.jsx)(`span`,{className:`flex-1`,children:l(e.labelKey)}),f===e.id?(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5 text-primary`,"aria-hidden":!0}):null]},e.id))]})]}),(0,Z.jsx)(ss,{}),(0,Z.jsx)(Ya,{}),(0,Z.jsx)(`span`,{role:`status`,"aria-label":m?`Connected`:`Disconnected`,className:U(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60`,m?`text-success`:`text-warning`),title:m?`Connected`:`Disconnected`,children:m?(0,Z.jsx)(Hn,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(Mn,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:l(`activity:topbar.settings`),children:(0,Z.jsx)(ar,{className:`h-3.5 w-3.5`})})]})]})})}function gs(e){if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`)||t.startsWith(`[`))try{let e=JSON.parse(t);if(e&&typeof e==`object`)return e}catch{return null}return null}return e&&typeof e==`object`?e:null}function _s(e,t){if(!e)return null;let n=gs(t);if(!n)return null;let r=e.toLowerCase(),i=String(n.file_path??n.path??``);switch(r){case`edit`:case`str_replace`:case`edit_file`:case`multi_edit`:{let e=typeof n.old_string==`string`?n.old_string:``,t=typeof n.new_string==`string`?n.new_string:``;return!e&&!t?null:{mode:`lcs`,oldText:e,newText:t,caption:`edit ${i}`.trim()}}case`write`:case`write_file`:case`create_file`:{let e=typeof n.content==`string`?n.content:``;return e?{mode:`lcs`,oldText:``,newText:e,caption:`write ${i} (new)`.trim()}:null}case`patch`:{let e=typeof n.patch==`string`?n.patch:``;return e.trim()?{mode:`unified`,patchText:e,caption:i?`patch ${i}`:`patch`}:null}default:return null}}function vs(e,t){let n=e.split(`
68
+ `),n=new Blob([t],{type:`text/csv;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`side-effects-${new Date().toISOString().slice(0,19).replace(/[:.]/g,`-`)}.csv`,i.click(),URL.revokeObjectURL(r)}function rs(){let e=_i(e=>e.sideEffects),t=_i(e=>e.loading),{t:n}=h(),[r,i]=(0,X.useState)(`all`),[o,s]=(0,X.useState)(`time`),[c,l]=(0,X.useState)(`desc`);(0,X.useEffect)(()=>{_i.getState().setLoading(!0),V(async()=>{let{getWSClient:e}=await import(`./ws-client-C2ppA8xa.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`})})},[]);let u=()=>{_i.getState().setLoading(!0),V(async()=>{let{getWSClient:e}=await import(`./ws-client-C2ppA8xa.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`})})},d=e=>{o===e?l(c===`asc`?`desc`:`asc`):(s(e),l(e===`time`?`desc`:`asc`))},f=(0,X.useMemo)(()=>{let t=r===`all`?[...e]:e.filter(e=>e.risk===r);return t.sort((e,t)=>{let n=0;return o===`time`?n=e.ts.localeCompare(t.ts):o===`tool`?n=e.toolName.localeCompare(t.toolName):o===`risk`&&(n=e.risk.localeCompare(t.risk)),c===`asc`?n:-n}),t},[e,r,o,c]),p=Jo(f,20,`${r}:${o}:${c}`);if(e.length===0&&!t)return(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-8 text-muted-foreground`,children:[(0,Z.jsx)(Ie,{className:`h-8 w-8 opacity-40`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:n(`activity:sideEffects.empty`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground/75`,children:n(`activity:sideEffects.emptyHint`)})]});let m=({column:e})=>o===e?c===`asc`?(0,Z.jsx)(a,{className:`inline h-3 w-3`}):(0,Z.jsx)(Nn,{className:`inline h-3 w-3`}):(0,Z.jsx)(`span`,{className:`opacity-30`,children:`↕`});return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/70 px-3 py-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:[n(`activity:sideEffects.heading`),` (`,f.length,r===`all`?``:`/${e.length}`,`)`]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>ns(f),disabled:f.length===0,className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30`,title:n(`activity:sideEffects.exportTitle`),children:[(0,Z.jsx)(Cr,{className:`h-3 w-3`}),`CSV`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:u,className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,Z.jsx)(wr,{className:U(`h-3 w-3`,t&&`animate-spin`)}),n(`common:action.refresh`)]})]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/60 bg-muted/20 px-2 py-1`,children:Qo.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:U(`rounded-md px-2 py-0.5 text-[10px] font-medium uppercase transition-colors`,r===e?`bg-primary/10 text-primary ring-1 ring-primary/20`:`text-muted-foreground hover:bg-muted/70 hover:text-foreground`),children:e===`all`?n(`activity:sideEffects.all`):e},e))}),(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Z.jsx)(`thead`,{className:`sticky top-0 bg-card/95 text-muted-foreground backdrop-blur`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`time`),children:[n(`activity:sideEffects.colTime`),` `,(0,Z.jsx)(m,{column:`time`})]}),(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`tool`),children:[n(`activity:sideEffects.colTool`),` `,(0,Z.jsx)(m,{column:`tool`})]}),(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`risk`),children:[n(`activity:sideEffects.colRisk`),` `,(0,Z.jsx)(m,{column:`risk`})]}),(0,Z.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colDetail`)}),(0,Z.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colOutcome`)})]})}),(0,Z.jsx)(`tbody`,{children:p.pageItems.map((e,t)=>{let n=Xo[e.risk]??Ie,r=Zo[e.risk]??`text-muted-foreground`;return(0,Z.jsxs)(`tr`,{className:`border-b border-border/45 hover:bg-muted/45`,children:[(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:$o(e.ts)}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 font-medium text-foreground`,children:e.toolName}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5`,children:(0,Z.jsxs)(`span`,{className:U(`flex items-center gap-1`,r),children:[(0,Z.jsx)(n,{className:`h-3 w-3`}),e.risk]})}),(0,Z.jsx)(`td`,{className:`max-w-xs truncate px-2 py-1.5 font-mono text-muted-foreground`,children:es(e)}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:e.outcome??``})]},`${e.toolUseId}-${t}`)})})]})}),(0,Z.jsx)(Yo,{page:p.page,pageSize:p.pageSize,totalItems:p.totalItems,onPageChange:p.setPage,itemLabel:`side effects`})]})}function is(e){return e<=0?`$0`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(5)}`.replace(/0+$/,``).replace(/\.$/,``)}function as(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function os(e,t){let n=Array.from(e.values());return n.sort((e,n)=>{if(e.id===t)return-1;if(n.id===t)return 1;let r=e.status===`running`?0:1,i=n.status===`running`?0:1;return r===i?e.startedAt-n.startedAt:r-i}),n}function ss(){let{t:e}=h(),t=K(e=>e.sidebarOpen),n=K(e=>e.activeActivity),r=t&&n===`agents`,i=ii(e=>Array.from(e.agents.values()).filter(e=>e.status===`running`).length);return(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`inspector-trigger`,"aria-expanded":r,"aria-label":e(`activity:inspector.openAgentsPanel`),onClick:()=>Ai(`agents`),className:U(`relative inline-flex h-8 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,r?`border-primary/40 bg-primary/10 text-primary`:`border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`),title:e(`activity:inspector.openAgentsPanel`),children:[(0,Z.jsx)(On,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{className:`hidden lg:inline`,children:e(`activity:nav.agents`)}),i>0?(0,Z.jsx)(`span`,{className:`min-w-4 bg-primary/15 px-1 text-[10px] font-semibold tabular-nums text-primary`,children:i>99?`99+`:i}):null]})}function cs(){let e=K(e=>e.inspectorOpen),t=K(e=>e.inspectorTab),n=K(e=>e.setInspectorOpen),r=K(e=>e.setInspectorTab),i=K(e=>e.inspectorFocusedAgentId),a=K(e=>e.setInspectorFocusedAgentId),{t:o}=h(),s=ii(e=>e.agents),c=ii(e=>e.leaderId),l=ii(e=>e.fleetTokensIn),u=ii(e=>e.fleetTokensOut),d=ii(e=>e.eventTimeline),f=(0,X.useMemo)(()=>os(s,c),[s,c]),p=f.filter(e=>e.status===`running`).length,m=f.reduce((e,t)=>e+t.costUsd,0),g=f.length,[_,v]=(0,X.useState)(null),y=(0,X.useMemo)(()=>_?s.get(_)??f[0]??null:f[0]??null,[_,f,s]),b=_i(e=>e.sideEffects.length),x=vi(e=>e.panels.length),S=vi(e=>e.panels.filter(e=>e.phase===`voting`).length);return(0,X.useEffect)(()=>{i&&e&&(v(i),r(`agents`),a(null))},[i,e,r,a]),(0,Z.jsx)(uo,{open:e,onOpenChange:n,modal:!1,children:(0,Z.jsxs)(go,{id:`workbench-inspector`,"data-testid":`inspector-drawer`,side:`right`,showOverlay:!1,showCloseButton:!1,onPointerDownOutside:e=>e.preventDefault(),onFocusOutside:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-testid="inspector-trigger"]`)?.focus()},className:`flex w-[calc(100vw-3rem)] max-w-none flex-col gap-0 overflow-hidden border-l border-border/80 bg-card/96 p-0 shadow-[-24px_0_64px_-36px_hsl(var(--shadow-color)/0.65)] backdrop-blur-xl sm:w-[min(680px,48vw)] sm:max-w-[680px]`,children:[(0,Z.jsxs)(_o,{className:`relative gap-1 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Z.jsxs)(vo,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(Re,{className:`h-4 w-4 text-primary`}),o(`activity:inspector.label`)]}),(0,Z.jsx)(yo,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:g>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:U(`h-1.5 w-1.5 rounded-full`,p>0?`bg-success animate-pulse`:`bg-muted-foreground/50`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[p,`/`,g]})]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`↓`,as(l),` ↑`,as(u),` · `,is(m)]})]}):(0,Z.jsx)(`span`,{children:o(`activity:inspector.agentsAppearHint`)})}),(0,Z.jsx)(fo,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`inspector-close`,className:`absolute right-3 top-3 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":o(`activity:inspector.collapseAria`),title:o(`activity:inspector.collapseTitle`),children:(0,Z.jsx)(Jt,{className:`h-4 w-4`})})})]}),(0,Z.jsxs)(Qa,{value:t,onValueChange:e=>r(e),className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsxs)($a,{className:`flex h-10 min-h-10 shrink-0 justify-start gap-1 border-x-0 border-t-0 border-b border-border/70 bg-muted/30 p-2 shadow-none`,"aria-label":o(`activity:inspector.label`),children:[(0,Z.jsx)(ls,{value:`fleet`,icon:(0,Z.jsx)(On,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabFleet`),count:g,running:p}),(0,Z.jsx)(ls,{value:`agents`,icon:(0,Z.jsx)(Er,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabAgents`),count:g}),(0,Z.jsx)(ls,{value:`sideEffects`,icon:(0,Z.jsx)(Ie,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabAudit`),count:b}),(0,Z.jsx)(ls,{value:`council`,icon:(0,Z.jsx)(Tn,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabCouncil`,{defaultValue:`Council`}),count:x,running:S})]}),(0,Z.jsx)(to,{value:`fleet`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(us,{fleetList:f,leaderId:c,selectedAgentId:_,eventTimeline:d,onSelectAgent:e=>{v(e.id),r(`agents`)}})}),(0,Z.jsx)(to,{value:`agents`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(ds,{fleetList:f,selectedAgent:y,leaderId:c,selectedAgentId:y?.id??null,onSelectAgent:v})}),(0,Z.jsx)(to,{value:`sideEffects`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(rs,{})}),(0,Z.jsx)(to,{value:`council`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(Go,{})})]})]})})}function ls({value:e,icon:t,label:n,count:r,running:i}){return(0,Z.jsxs)(eo,{value:e,className:U(`flex h-6 items-center gap-1.5 rounded-md px-2.5 py-0 text-[11px] font-medium text-muted-foreground shadow-none transition-colors scroll-mt-12`,`hover:bg-background/60 hover:text-foreground data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border`),children:[t,n,r>0&&(0,Z.jsx)(`span`,{className:U(`tabular-nums text-[10px] px-1 rounded-full`,i&&i>0?`bg-success/15 text-success`:`bg-muted text-muted-foreground`),children:i===void 0?r:`${i}/${r}`})]})}function us({fleetList:e,leaderId:t,selectedAgentId:n,eventTimeline:r,onSelectAgent:i}){let{t:a}=h();return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[e.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Er,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:a(`activity:inspector.noAgentsActive`)}),(0,Z.jsx)(`p`,{className:`text-[11px] mt-0.5`,children:a(`activity:inspector.agentsAppearHint`)})]}):(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-1.5`,children:e.map(e=>(0,Z.jsx)(Wo,{agent:e,isSelected:n===e.id,isLeader:e.id===t,onClick:()=>i(e)},e.id))}),r.length>0&&(0,Z.jsx)(`div`,{className:`border-t px-3 py-1.5 shrink-0`,children:(0,Z.jsx)(lo,{events:r,max:4})})]})}function ds({fleetList:e,selectedAgent:t,leaderId:n,selectedAgentId:r,onSelectAgent:i}){let{t:a}=h();if(e.length===0)return(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(On,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:a(`activity:inspector.noAgentsActive`)})]});if(!t)return null;let o=Math.max(0,e.findIndex(e=>e.id===r));return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:(0,Z.jsx)(`div`,{className:`max-w-2xl mx-auto`,children:(0,Z.jsx)(zo,{agent:t,isLeader:t.id===n})})}),(0,Z.jsx)(`div`,{className:`border-t px-2 py-1.5 shrink-0`,children:(0,Z.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto pb-0.5`,children:e.map((e,n)=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:U(`shrink-0 flex items-center gap-1.5 px-2 py-1 rounded-md text-[10px] transition-colors`,e.id===t?.id?`bg-primary/15 text-primary ring-1 ring-primary/40`:`hover:bg-accent text-muted-foreground`),title:n===o?a(`activity:inspector.selected`,{name:e.name}):e.name,children:[(0,Z.jsx)(`span`,{className:U(`h-1.5 w-1.5 rounded-full shrink-0`,e.status===`running`?`bg-success animate-pulse`:e.status===`failed`?`bg-destructive`:`bg-muted-foreground/50`)}),(0,Z.jsx)(`span`,{className:`truncate max-w-[8rem]`,children:e.name})]},e.id))})})]})}function fs(e){return e.split(`-`).map(e=>e.slice(0,1).toUpperCase()+e.slice(1)).join(` `)}function ps(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${Math.round(e)} B`}function ms(){let[e,t]=(0,X.useState)(null);return(0,X.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await fetch(`/debug/system`,{cache:`no-store`});if(!n.ok)return;let r=await n.json();!e&&Number.isFinite(r.memoryUsage?.rss)&&t(r)}catch{}};n();let r=window.setInterval(()=>void n(),5e3);return()=>{e=!0,window.clearInterval(r)}},[]),e}function hs({currentView:e,projectName:t,sessionLabel:n,isLoading:r,iteration:i,onPalette:a,onSearch:o,onModel:s,onSettings:c}){let{t:l}=h(),{theme:u,setTheme:d,palette:f,setPalette:p}=Ja(),m=G(e=>e.wsConnected),g=W(e=>e.appVersion),_=W(e=>e.latestVersion),v=W(e=>e.updateAvailable),b=W(e=>e.droppedTools),x=u===`system`?typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:u,S=(0,X.useCallback)(()=>{d(x===`dark`?`light`:`dark`)},[x,d]),w=ms(),T=w?w.memoryUsage.heapUsed/w.heapLimit:0,E=w?.codebaseIndexServer,D=E?.health,O=D?.server;return(0,Z.jsx)(`div`,{className:`hidden shrink-0 border-b border-border/70 bg-card/85 px-3 py-2 shadow-sm backdrop-blur-xl md:block`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:t||`WrongStack`}),g?(0,Z.jsxs)(`span`,{className:U(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,v&&_&&_!==g?`border-warning/40 bg-warning/10 text-warning`:`border-border/70 bg-muted/50 text-muted-foreground`),title:v&&_&&_!==g?`Update available: v${g} → v${_} — run wstack update`:`WrongStack v${g}`,children:[`v`,g,v&&_&&_!==g?(0,Z.jsxs)(`span`,{className:`text-[10px] opacity-80`,children:[`→ v`,_]}):null]}):null,(0,Z.jsx)(`span`,{className:`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:fs(e)}),(0,Z.jsxs)(`span`,{className:U(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium`,r?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`),children:[r?(0,Z.jsx)(On,{className:`h-3 w-3 animate-pulse`}):(0,Z.jsx)(_t,{className:`h-3 w-3`}),r?`Running`:`Ready`,i?(0,Z.jsxs)(`span`,{className:`tabular`,children:[i.index,i.max>0?`/${i.max}`:``]}):null]}),w?(0,Z.jsxs)(`span`,{className:U(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,T>=.85?`text-destructive`:T>=.6?`text-warning`:`text-success`),title:`WebUI server PID ${w.pid} · heap ${ps(w.memoryUsage.heapUsed)} / ${ps(w.heapLimit)}`,children:[`RAM `,ps(w.memoryUsage.rss)]}):null,E?(0,Z.jsxs)(`span`,{className:U(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,E.status===`connected`?`text-success`:E.status===`unresponsive`||E.status===`error`?`text-destructive`:E.status===`degraded`||E.status===`connecting`||E.status===`stopping`?`text-warning`:`text-muted-foreground`),title:[`Codebase index: ${D?.status??E.status}`,E.pid?`PID ${E.pid}`:null,D?.latencyMs==null?null:`RTT ${D.latencyMs}ms`,O?`RAM ${ps(O.memory.rss)}`:null,D?.missedHeartbeats?`missed ${D.missedHeartbeats}`:null].filter(Boolean).join(` · `),children:[`Index `,D?.status??E.status]}):null,b>0?(0,Z.jsxs)(`span`,{className:`rounded-md border border-warning/40 bg-warning/10 px-1.5 py-0.5 text-[11px] font-medium tabular-nums text-warning`,title:`${b} tool(s) dropped from provider requests due to maxTools limit`,children:[`-`,b,` tools`]}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:n||`No named session`})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:l(`activity:topbar.searchChat`),children:[(0,Z.jsx)(Ft,{className:`h-3.5 w-3.5`}),l(`activity:topbar.search`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:l(`activity:topbar.commandPalette`),children:[(0,Z.jsx)(C,{className:`h-3.5 w-3.5`}),l(`activity:topbar.command`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:s,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:l(`activity:topbar.switchModel`),children:[(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),l(`activity:topbar.model`)]}),(0,Z.jsx)(`button`,{type:`button`,onClick:S,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:x===`dark`?`Switch to light theme`:`Switch to dark theme`,children:x===`dark`?(0,Z.jsx)(ye,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(gt,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(ia,{children:[(0,Z.jsx)(aa,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`${l(`settings:general.paletteSwitcherTitle`)}: ${l(oi(f).labelKey)}`,"aria-label":`${l(`settings:general.paletteSwitcherTitle`)}: ${l(oi(f).labelKey)}`,children:(0,Z.jsx)(Je,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(ca,{align:`end`,className:`w-56`,children:[(0,Z.jsx)(fa,{children:l(`settings:general.paletteHeading`)}),ni.map(e=>(0,Z.jsxs)(la,{onSelect:()=>p(e.id),className:`gap-2`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 rounded-[3px] border border-border/70`,style:{background:`linear-gradient(90deg, ${e.swatch} 0 50%, ${e.swatchSecondary} 50% 100%)`}}),(0,Z.jsx)(`span`,{className:`flex-1`,children:l(e.labelKey)}),f===e.id?(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5 text-primary`,"aria-hidden":!0}):null]},e.id))]})]}),(0,Z.jsx)(ss,{}),(0,Z.jsx)(Ya,{}),(0,Z.jsx)(`span`,{role:`status`,"aria-label":m?`Connected`:`Disconnected`,className:U(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60`,m?`text-success`:`text-warning`),title:m?`Connected`:`Disconnected`,children:m?(0,Z.jsx)(Hn,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(Mn,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:l(`activity:topbar.settings`),children:(0,Z.jsx)(ar,{className:`h-3.5 w-3.5`})})]})]})})}function gs(e){if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`)||t.startsWith(`[`))try{let e=JSON.parse(t);if(e&&typeof e==`object`)return e}catch{return null}return null}return e&&typeof e==`object`?e:null}function _s(e,t){if(!e)return null;let n=gs(t);if(!n)return null;let r=e.toLowerCase(),i=String(n.file_path??n.path??``);switch(r){case`edit`:case`str_replace`:case`edit_file`:case`multi_edit`:{let e=typeof n.old_string==`string`?n.old_string:``,t=typeof n.new_string==`string`?n.new_string:``;return!e&&!t?null:{mode:`lcs`,oldText:e,newText:t,caption:`edit ${i}`.trim()}}case`write`:case`write_file`:case`create_file`:{let e=typeof n.content==`string`?n.content:``;return e?{mode:`lcs`,oldText:``,newText:e,caption:`write ${i} (new)`.trim()}:null}case`patch`:{let e=typeof n.patch==`string`?n.patch:``;return e.trim()?{mode:`unified`,patchText:e,caption:i?`patch ${i}`:`patch`}:null}default:return null}}function vs(e,t){let n=e.split(`
69
69
  `),r=t.split(`
70
70
  `);if(n.length>5e3||r.length>5e3)return null;let i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=i-1;e>=0;e--)for(let t=a-1;t>=0;t--)o[e][t]=n[e]===r[t]?o[e+1][t+1]+1:Math.max(o[e+1][t],o[e][t+1]);let s=[],c=0,l=0;for(;c<i&&l<a;)n[c]===r[l]?(s.push({kind:`ctx`,text:n[c]}),c++,l++):o[c+1][l]>=o[c][l+1]?(s.push({kind:`del`,text:n[c]}),c++):(s.push({kind:`add`,text:r[l]}),l++);for(;c<i;)s.push({kind:`del`,text:n[c++]});for(;l<a;)s.push({kind:`add`,text:r[l++]});return s}function ys(e){let t=[],n=e.split(`
71
71
  `);for(let e of n)e.startsWith(`@@`)||e.startsWith(`--- `)||e.startsWith(`+++ `)||e.startsWith(`diff `)||e.startsWith(`index `)||e.startsWith(`\\ `)?t.push({kind:`meta`,text:e}):e.startsWith(`+`)?t.push({kind:`add`,text:e.slice(1)}):e.startsWith(`-`)?t.push({kind:`del`,text:e.slice(1)}):t.push({kind:`ctx`,text:e.startsWith(` `)?e.slice(1):e});return t.length>0&&t[t.length-1].kind===`ctx`&&t[t.length-1].text===``&&t.pop(),t}[`var DIFF_MAX_LINES = 5000;`,`function __diffObj(input){`,` if(typeof input==="string"){ var s=input.trim(); if(s.charAt(0)==="{"||s.charAt(0)==="["){ try{ var p=JSON.parse(s); if(p&&typeof p==="object") return p; }catch(_e){} } return null; }`,` if(input&&typeof input==="object") return input; return null;`,`}`,`function diffFromToolInput(name, input){`,` if(!name) return null;`,` var obj=__diffObj(input); if(!obj) return null;`,` var n=String(name).toLowerCase();`,` var fp=String(obj.file_path!=null?obj.file_path:(obj.path!=null?obj.path:""));`,` if(n==="edit"||n==="str_replace"||n==="edit_file"||n==="multi_edit"){`,` var oldT=typeof obj.old_string==="string"?obj.old_string:"";`,` var newT=typeof obj.new_string==="string"?obj.new_string:"";`,` if(!oldT&&!newT) return null;`,` return { mode:"lcs", oldText:oldT, newText:newT, caption:("edit "+fp).replace(/\\s+$/,"") };`,` }`,` if(n==="write"||n==="write_file"||n==="create_file"){`,` var c=typeof obj.content==="string"?obj.content:"";`,` if(!c) return null;`,` return { mode:"lcs", oldText:"", newText:c, caption:("write "+fp+" (new)").replace(/\\s+/g," ").replace(/\\s+$/,"") };`,` }`,` if(n==="patch"){`,` var pt=typeof obj.patch==="string"?obj.patch:"";`,` if(!pt.replace(/\\s/g,"")) return null;`,` return { mode:"unified", patchText:pt, caption: fp ? ("patch "+fp) : "patch" };`,` }`,` return null;`,`}`,`function computeLineDiff(oldText, newText){`,` var a=oldText.split("\\n"), b=newText.split("\\n");`,` if(a.length>DIFF_MAX_LINES||b.length>DIFF_MAX_LINES) return null;`,` var nn=a.length, mm=b.length, i, j;`,` var dp=new Array(nn+1); for(i=0;i<=nn;i++){ dp[i]=new Array(mm+1); for(j=0;j<=mm;j++) dp[i][j]=0; }`,` for(i=nn-1;i>=0;i--){ for(j=mm-1;j>=0;j--){ dp[i][j]= a[i]===b[j] ? dp[i+1][j+1]+1 : Math.max(dp[i+1][j], dp[i][j+1]); } }`,` var rows=[]; i=0; j=0;`,` while(i<nn&&j<mm){ if(a[i]===b[j]){ rows.push({kind:"ctx",text:a[i]}); i++; j++; } else if(dp[i+1][j]>=dp[i][j+1]){ rows.push({kind:"del",text:a[i]}); i++; } else { rows.push({kind:"add",text:b[j]}); j++; } }`,` while(i<nn){ rows.push({kind:"del",text:a[i]}); i++; }`,` while(j<mm){ rows.push({kind:"add",text:b[j]}); j++; }`,` return rows;`,`}`,`function parseUnifiedDiff(patchText){`,` var rows=[], lines=patchText.split("\\n"), k, raw;`,` for(k=0;k<lines.length;k++){ raw=lines[k];`,` if(raw.indexOf("@@")===0||raw.indexOf("--- ")===0||raw.indexOf("+++ ")===0||raw.indexOf("diff ")===0||raw.indexOf("index ")===0||raw.indexOf("\\\\ ")===0){ rows.push({kind:"meta",text:raw}); }`,` else if(raw.charAt(0)==="+"){ rows.push({kind:"add",text:raw.slice(1)}); }`,` else if(raw.charAt(0)==="-"){ rows.push({kind:"del",text:raw.slice(1)}); }`,` else { rows.push({kind:"ctx",text: raw.charAt(0)===" " ? raw.slice(1) : raw}); }`,` }`,` if(rows.length>0 && rows[rows.length-1].kind==="ctx" && rows[rows.length-1].text===""){ rows.pop(); }`,` return rows;`,`}`,`function diffRowsFromToolInput(name, input){`,` var d=diffFromToolInput(name, input); if(!d) return null;`,` if(d.mode==="unified") return { caption:d.caption, rows:parseUnifiedDiff(d.patchText) };`,` return { caption:d.caption, rows:computeLineDiff(d.oldText, d.newText) };`,`}`].join(`
@@ -121,7 +121,7 @@ Type while the agent is running to queue messages; they are sent automatically w
121
121
  `).slice(-4).join(`
122
122
  `).trim();return(0,Z.jsxs)(`div`,{className:`ws-reasoning min-w-0 max-w-full py-0.5 sm:max-w-[720px]`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex w-full flex-wrap items-center gap-x-2 gap-y-0.5 text-left font-mono text-xs`,"aria-expanded":o,children:[(0,Z.jsx)(`span`,{className:`ws-reasoning__mark text-sm leading-none`,"aria-hidden":!0,children:`✦`}),(0,Z.jsx)(`span`,{className:`font-semibold uppercase tracking-wide text-primary`,children:a(`activity:message.thinkingProcess`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:a(`activity:message.thinkingMeta`,{iter:t.iteration,dur:i,lines:a(`activity:message.linesSuffix`,{count:n})})}),(0,Z.jsx)(`span`,{className:`ml-auto text-muted-foreground/60`,children:o?(0,Z.jsx)(Nn,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(Yt,{className:`h-3.5 w-3.5`})})]}),(0,Z.jsx)(`pre`,{className:U(`mt-1.5 whitespace-pre-wrap break-words font-mono text-xs italic leading-relaxed text-foreground/65`,o?`max-h-[32rem] overflow-auto`:`max-h-24 overflow-hidden`),children:o?t.text:c||t.text}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,Z.jsx)(kd,{text:t.text,label:a(`activity:message.copyLog`),className:`text-[10px] text-muted-foreground/60 opacity-70 transition-opacity hover:opacity-100`}),!o&&n>4&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`text-[10px] text-muted-foreground/70 transition-colors hover:text-foreground`,children:a(`activity:message.showFullLog`)})]})]})})():(()=>{if(oe)return null;let t=e.content,n=!!e.attachments&&e.attachments.length>0;return(0,Z.jsxs)(`div`,{className:U(`text-sm leading-relaxed markdown-content`,e.streaming&&`streaming-cursor`),children:[n&&(0,Z.jsx)(Od,{attachments:e.attachments??[],notRetainedLabel:a(`activity:message.imageNotRetained`)}),t?f&&e.role===`assistant`?(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-foreground/90 max-h-[40rem] overflow-auto`,children:e.content}):e.role===`assistant`&&e.isError?(0,Z.jsx)(jd,{text:e.content}):e.streaming?(0,Z.jsx)(Id,{text:t}):(0,Z.jsx)(Nd,{remarkPlugins:[qi],rehypePlugins:Js,components:Zs,children:t}):e.streaming?(0,Z.jsx)(`span`,{className:`inline-block animate-pulse text-muted-foreground`,children:a(`activity:message.typing`)}):n||le.length>0?null:(0,Z.jsx)(`span`,{className:`text-muted-foreground italic`,children:a(`activity:message.noContent`)})]})})()}),m&&e.status===`failed`&&(0,Z.jsx)(`span`,{className:`text-[10px] font-medium text-destructive flex items-center gap-1 px-1`,children:a(`activity:message.failedToSend`)}),ce&&!C&&le.length>0&&(0,Z.jsx)(gu,{steps:le,yoloMode:F,autoMode:P===`auto`,autoDelayMs:te.autonomyDelayMs,onAutoSubmit:se,canAutoSubmit:ae,onBatchSubmit:R,isLatest:ce,sessionEndAutoFill:!0}),(0,Z.jsxs)(`div`,{className:U(`flex max-w-full flex-wrap items-center gap-2 px-1`,m?`flex-row-reverse`:`flex-row`),children:[!oe&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),(0,Z.jsx)(`span`,{className:`w-px h-3 bg-border/60 shrink-0`,"aria-hidden":!0})]}),e.runSummary&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/75 font-mono tabular-nums`,title:[a(`activity:message.rsIterations`,{n:e.runSummary.iterations}),a(`activity:message.rsTools`,{n:e.runSummary.tools}),a(`activity:message.rsElapsed`,{s:`${(e.runSummary.durationMs/1e3).toFixed(2)}s`}),e.runSummary.costDelta>0?a(`activity:message.rsCost`,{c:e.runSummary.costDelta.toFixed(4)}):``].filter(Boolean).join(` · `),children:[e.runSummary.iterations,` iter`,e.runSummary.tools>0?` · ${e.runSummary.tools} tool${e.runSummary.tools===1?``:`s`}`:``,` `,`·`,` `,e.runSummary.durationMs<6e4?`${(e.runSummary.durationMs/1e3).toFixed(1)}s`:`${Math.floor(e.runSummary.durationMs/6e4)}m ${Math.floor(e.runSummary.durationMs%6e4/1e3)}s`,e.runSummary.costDelta>0?` · ${e.runSummary.costDelta>=.01?e.runSummary.costDelta.toFixed(4):e.runSummary.costDelta.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}`:``]}),e.usage&&(e.usage.input>0||e.usage.output>0)&&(()=>{let t=e.usage,n=(t.input*M+t.output*ee+(t.cacheRead??0)*N)/1e6,r=M>0||ee>0,i=n>=.01?`${n.toFixed(4)}`:n>0?`${n.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}`:``;return(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/75 font-mono tabular-nums`,title:[a(`activity:message.useInput`,{n:t.input.toLocaleString()}),a(`activity:message.useOutput`,{n:t.output.toLocaleString()}),t.cacheRead?a(`activity:message.useCacheRead`,{n:t.cacheRead.toLocaleString()}):``,r?a(`activity:message.useCost`,{c:i}):``].filter(Boolean).join(` · `),children:[t.input.toLocaleString(),`→`,t.output.toLocaleString(),t.cacheRead?` · ${t.cacheRead.toLocaleString()} ↺`:``,r&&i?` · ${i}`:``]})})(),!g&&e.content&&!e.streaming&&(0,Z.jsx)(kd,{text:e.content,label:a(`common:action.copy`),className:`opacity-50 hover:opacity-100 transition-opacity`}),e.role===`assistant`&&e.content&&!e.streaming&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(e=>!e),title:a(f?`activity:message.showRenderedTitle`:`activity:message.showRawTitle`),className:U(`text-xs inline-flex items-center gap-1 transition-opacity`,f?`text-primary hover:text-primary/80 opacity-100`:`opacity-50 hover:opacity-100 text-muted-foreground hover:text-foreground`),children:[(0,Z.jsx)(wn,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:a(f?`activity:message.renderedLabel`:`activity:message.rawLabel`)})]}),m&&!c&&!C&&(0,Z.jsxs)(Z.Fragment,{children:[e.status===`failed`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:de,title:a(`activity:message.retryLabel`,`Retry`),className:`opacity-75 hover:opacity-100 transition-opacity text-xs text-destructive hover:text-destructive/80 inline-flex items-center gap-1 font-medium`,children:[(0,Z.jsx)(An,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:a(`activity:message.retryLabel`,`Retry`)})]}),e.content&&(0,Z.jsxs)(`button`,{type:`button`,onClick:pe,title:a(`activity:message.editTitle`),className:`opacity-50 hover:opacity-100 transition-opacity text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,Z.jsx)(bn,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:a(`activity:message.editLabel`)})]})]}),e.role===`assistant`&&e.content&&!e.streaming&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>D(e.id),title:a(j?`activity:message.unpinTitle`:`activity:message.pinTitle`),className:U(`text-xs inline-flex items-center gap-1 transition-opacity`,j?`text-warning hover:text-warning/85 opacity-100`:`opacity-50 hover:opacity-100 text-muted-foreground hover:text-foreground`),children:[j?(0,Z.jsx)(Me,{className:`h-3 w-3`}):(0,Z.jsx)(w,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:a(j?`activity:message.pinnedLabel`:`activity:message.pinLabel`)})]}),(ce||e.isError)&&e.content&&!e.streaming&&!C&&(0,Z.jsxs)(`button`,{type:`button`,onClick:fe,title:a(`activity:message.regenerateTitle`),className:`opacity-50 hover:opacity-100 transition-opacity text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,Z.jsx)(An,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:a(`activity:message.retryLabel`)})]})]})]})]})});function mf(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 hf=(0,X.memo)(function({tools:e,defaultOpen:n=!1,isContinuation:r=!1}){let{t:i}=h(),[a,o]=(0,X.useState)(n);if(e.length===1)return(0,Z.jsx)(pf,{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,Z.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[r?(0,Z.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8`,"aria-hidden":!0}):(0,Z.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,Z.jsx)(Oe,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] flex-1 min-w-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:U(`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,Z.jsx)(Nn,{className:`h-3.5 w-3.5 text-muted-foreground`}):(0,Z.jsx)(Yt,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(Oe,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`font-mono text-xs`,children:i(`activity:toolGroup.toolCalls`,{count:e.length})}),s>0?(0,Z.jsx)(Rn,{className:`h-3 w-3 animate-spin text-warning`}):c>0?(0,Z.jsx)(kr,{className:`h-3 w-3 text-destructive`}):(0,Z.jsx)(R,{className:`h-3 w-3 text-success`}),l>0&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums font-normal`,children:mf(l)}),d&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 font-mono truncate`,children:[`· `,d,f]})]}),a&&(0,Z.jsx)(`div`,{className:`space-y-2 pl-3 border-l-2 border-border/40 ml-2 tool-details`,children:e.map(e=>(0,Z.jsx)(pf,{message:e,isFirst:!1},e.id))})]})]})}),gf=(0,X.memo)(function({row:e,isLoading:t,compactMode:n,isFirstRow:r,groupToolCalls:i}){let a=U(`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,Z.jsx)(`div`,{className:a,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 py-1 text-[11px] text-muted-foreground/70 uppercase tracking-wider font-medium`,children:[(0,Z.jsx)(`div`,{className:`flex-1 h-px bg-border/50`}),(0,Z.jsx)(`span`,{children:e.label}),(0,Z.jsx)(`div`,{className:`flex-1 h-px bg-border/50`})]})}):e.kind===`user`?(0,Z.jsx)(`div`,{className:a,children:(0,Z.jsx)(pf,{message:e.message,isFirst:!0})}):(0,Z.jsx)(`div`,{className:a,children:(0,Z.jsx)(`div`,{className:U(`chat-turn`,n?`space-y-1`:`space-y-1.5`),children:e.items.flatMap(n=>{if(n.kind===`msg`)return[(0,Z.jsx)(pf,{message:n.message,isFirst:n.isFirst,isContinuation:n.isContinuation},n.key)];if(i){let r=e.isLastTurn&&n.isLastGroup&&t&&n.hasRunningTool;return[(0,Z.jsx)(hf,{tools:n.tools,defaultOpen:r,isContinuation:n.isContinuation},n.key)]}return n.tools.map(e=>(0,Z.jsx)(pf,{message:e,isFirst:!1,isContinuation:n.isContinuation},e.id))})})})});function _f(){let{t:e}=h(),t=r(e=>e.thinkingBuffer);if(!t)return null;let n=t.split(`
123
123
  `).slice(-6).join(`
124
- `).trim();return(0,Z.jsxs)(`div`,{className:`flex gap-3 animate-message thinking-bubble`,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`thinking-orb flex-shrink-0`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{className:`thinking-orb__ring`}),(0,Z.jsx)(`span`,{className:`thinking-orb__ring thinking-orb__ring--delay`}),(0,Z.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--one`}),(0,Z.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--two`}),(0,Z.jsx)(cr,{className:`thinking-orb__icon h-4 w-4`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`thinking-label text-xs font-medium text-primary px-1`,children:[(0,Z.jsx)(`span`,{children:e(`chat:thinking`)}),(0,Z.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{})]})]}),(0,Z.jsxs)(`div`,{className:`thinking-panel rounded-2xl rounded-bl-md px-3 py-2 border text-foreground/80`,children:[(0,Z.jsxs)(`div`,{className:`thinking-wave`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{})]}),(0,Z.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 vf(e){let{hasMessages:t,autoCollapseInput:n,sessionChanged:r,prevHadMessages:i,prevAutoCollapse:a}=e;return n&&t&&(r||!i||!a)}function yf(){let{t:e}=h(),t=r(e=>e.messages),n=r(e=>e.isLoading),i=K(e=>e.sidebarOpen),a=K(e=>e.toggleSidebar),o=K(e=>e.compactMode),{totalTokens:s,startTime:c,lastInputTokens:l,maxContext:u,contextLimitWarning:d,cacheStats:f,iteration:p}=W(he(e=>({totalTokens:e.totalTokens,startTime:e.startTime,lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,contextLimitWarning:e.contextLimitWarning,cacheStats:e.cacheStats,iteration:e.iteration}))),m=W(e=>e.session),g=m?.id,_=K(e=>g?e.sessionNicknames[g]:void 0),v=K(e=>e.setSessionNickname),y=m?.title,[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(``),w=fi(e=>e.entries),[T,E]=(0,X.useState)(!1),D=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!T)return;let e=e=>{D.current?.contains(e.target)||E(!1)},t=e=>{e.key===`Escape`&&E(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[T]);let{provider:O,model:k}=G(he(e=>({provider:e.provider,model:e.model}))),A=(0,X.useRef)(null),j=(0,X.useMemo)(()=>Co(t),[t]),M=(0,X.useRef)(0);M.current=j.length+1;let ee=(0,X.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]),N=K(e=>e.scrollTarget),te=B(e=>e.autonomy),P=B(e=>e.groupToolCalls),F=B(e=>e.autoCollapseInput),I=(0,X.useCallback)(e=>{B.getState().set({autonomy:e}),H()?.send?.({type:`autonomy.switch`,payload:{mode:e}})},[]),[ne,re]=(0,X.useState)(!1),[ie,L]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!1),[se,R]=(0,X.useState)(t.length>0&&F),ce=(0,X.useRef)(n),le=(0,X.useRef)(t.length>0),ue=(0,X.useRef)(g),de=(0,X.useRef)(F),[fe,pe]=(0,X.useState)(!1),[me,ge]=(0,X.useState)(!1),_e=Pr(e=>Object.values(e.contextMemories).filter(e=>e.state!==`exited`).length);(0,X.useEffect)(()=>{let e=()=>oe(!0);return window.addEventListener(`open:memory-panel`,e),()=>window.removeEventListener(`open:memory-panel`,e)},[]),(0,X.useEffect)(()=>{let e=()=>pe(!0);return document.addEventListener(`open:context-breakdown`,e),()=>document.removeEventListener(`open:context-breakdown`,e)},[]),(0,X.useEffect)(()=>{let e=()=>ge(!0);return document.addEventListener(`open:context-editor`,e),()=>document.removeEventListener(`open:context-editor`,e)},[]),(0,X.useEffect)(()=>{let e=()=>R(!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,X.useEffect)(()=>{ce.current&&!n&&R(!1),ce.current=n},[n]),(0,X.useEffect)(()=>{let e=t.length>0,r=g!=null&&g!==ue.current;!n&&vf({hasMessages:e,autoCollapseInput:F,sessionChanged:r,prevHadMessages:le.current,prevAutoCollapse:de.current})&&R(!0),ue.current=g,le.current=e,de.current=F},[t.length,F,g,n]);let ve=(0,X.useCallback)(()=>{let e=!B.getState().autoCollapseInput;B.getState().set({autoCollapseInput:e}),e||R(!1)},[]),ye=u>0&&l>0?Math.min(100,Math.round(l/u*100)):0,[be,xe]=(0,X.useState)(!0),[Se,Ce]=(0,X.useState)(0),[we,Te]=(0,X.useState)(!1),Ee=(0,X.useRef)(t.length),De=(0,X.useCallback)(()=>{let e=A.current;if(!e)return;let t=e.scrollSize-e.scrollOffset-e.viewportSize<120;xe(t),t&&(Ce(0),Ee.current=r.getState().messages.length),Te(e.scrollOffset>e.viewportSize&&e.scrollSize>e.viewportSize*2.5)},[]),Oe=(0,X.useCallback)(e=>{H()?.resumeSession?.(e),E(!1)},[]);(0,X.useEffect)(()=>{let e=A.current;if(e){if(be)e.scrollToIndex(M.current-1,{align:`end`}),Ee.current=t.length;else{let e=t.length-Ee.current;e>0&&Ce(e)}}},[t,be]),(0,X.useEffect)(()=>{xe(!0),Ce(0),Ee.current=r.getState().messages.length,requestAnimationFrame(()=>{A.current?.scrollToIndex(M.current-1,{align:`end`})})},[g]),(0,X.useEffect)(()=>{if(!N)return;let e=ee.get(N.id);e!==void 0&&A.current?.scrollToIndex(e,{align:`center`,smooth:!0})},[N,ee]);let ke=(0,X.useCallback)(()=>{A.current?.scrollToIndex(M.current-1,{align:`end`,smooth:!0}),xe(!0),Ce(0),Ee.current=r.getState().messages.length},[]),Ae=(0,X.useCallback)(()=>{A.current?.scrollToIndex(0,{align:`start`,smooth:!0})},[]),[je,Me]=(0,X.useState)(null),[Ne,Pe]=(0,X.useState)(()=>Date.now()),Fe=(0,X.useRef)(null),Ie=(0,X.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=je?Math.max(0,Math.floor((Ne-je)/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=Fe.current;if(!e||e.id!==c.id)Fe.current={id:c.id,at:Date.now(),len:c.content.length};else{let t=Math.max(1,Ne-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 Fe.current&&=null;return{label:i,elapsed:o,speedLabel:s}},[t,Ne,je,e]);(0,X.useEffect)(()=>{n&&je===null&&Me(Date.now()),!n&&je!==null&&Me(null)},[n,je]),(0,X.useEffect)(()=>{if(!n)return;let e=setInterval(()=>Pe(Date.now()),500);return()=>clearInterval(e)},[n]);let Le=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`},Re=(()=>{if(!n)return`idle`;let e=t[t.length-1];return e?.role===`assistant`&&e.content&&e.streaming?`streaming`:`thinking`})();return{messages:t,isLoading:n,sidebarOpen:i,toggleSidebar:a,compactMode:o,totalTokens:s,startTime:c,lastInputTokens:l,maxContext:u,contextLimitWarning:d,cacheStats:f,iteration:p,sessionId:g,nickname:_,sessionTitle:y,renamingTitle:b,setRenamingTitle:x,titleDraft:S,setTitleDraft:C,setSessionNickname:v,historyEntries:w,switcherOpen:T,setSwitcherOpen:E,switcherRef:D,handleHistorySelect:Oe,provider:O,model:k,vlistRef:A,rows:j,autonomy:te,groupToolCallsPref:P,autoCollapseInput:F,handleAutonomyChange:I,processOpen:ne,setProcessOpen:re,checkpointOpen:ie,setCheckpointOpen:L,memoryPanelOpen:ae,setMemoryPanelOpen:oe,inputCollapsed:se,setInputCollapsed:R,breakdownOpen:fe,setBreakdownOpen:pe,editorOpen:me,setEditorOpen:ge,activeMemoryCount:_e,handleToggleAutoCollapse:ve,ctxPct:ye,pinnedToBottom:be,unreadCount:Se,scrolledDeep:we,handleScroll:De,scrollToBottom:ke,scrollToTop:Ae,runningStatus:Ie,formatDuration:Le,agentState:Re,stateTone:Re===`idle`?`bg-muted text-muted-foreground`:Re===`streaming`?`bg-primary/10 text-primary`:`bg-warning/10 text-warning`,hasStatusContent:u>0&&l>0||s.input>0||!!c}}var bf=(0,X.lazy)(()=>V(()=>import(`./ProcessMonitor-C5kib2h4.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])));function xf(){let{t:e}=h(),t=yf();return(0,Z.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 bg-[hsl(var(--surface-2)/0.45)]`,children:[(0,Z.jsx)(Dd,{sidebarOpen:t.sidebarOpen,toggleSidebar:t.toggleSidebar,agentState:t.agentState,stateTone:t.stateTone,sessionId:t.sessionId,renamingTitle:t.renamingTitle,setRenamingTitle:t.setRenamingTitle,titleDraft:t.titleDraft,setTitleDraft:t.setTitleDraft,nickname:t.nickname,sessionTitle:t.sessionTitle,setSessionNickname:t.setSessionNickname,historyEntries:t.historyEntries,switcherRef:t.switcherRef,switcherOpen:t.switcherOpen,setSwitcherOpen:t.setSwitcherOpen,handleHistorySelect:t.handleHistorySelect,provider:t.provider,model:t.model,iteration:t.iteration,autonomy:t.autonomy,handleAutonomyChange:t.handleAutonomyChange,memoryPanelOpen:t.memoryPanelOpen,setMemoryPanelOpen:t.setMemoryPanelOpen,activeMemoryCount:t.activeMemoryCount,processOpen:t.processOpen,setProcessOpen:t.setProcessOpen,checkpointOpen:t.checkpointOpen,setCheckpointOpen:t.setCheckpointOpen,hasStatusContent:t.hasStatusContent,lastInputTokens:t.lastInputTokens,ctxPct:t.ctxPct,maxContext:t.maxContext,cacheStats:t.cacheStats,setBreakdownOpen:t.setBreakdownOpen,contextLimitWarning:t.contextLimitWarning,setEditorOpen:t.setEditorOpen,totalTokens:t.totalTokens,startTime:t.startTime,formatDuration:t.formatDuration}),(0,Z.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,Z.jsx)(vd,{}),!t.pinnedToBottom&&(0,Z.jsxs)(`button`,{type:`button`,onClick:t.scrollToBottom,className:U(`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,Z.jsx)(S,{className:`h-3.5 w-3.5`}),t.unreadCount>0?`${t.unreadCount} new message${t.unreadCount===1?``:`s`}`:`Jump to latest`]}),t.scrolledDeep&&(0,Z.jsxs)(`button`,{type:`button`,onClick:t.scrollToTop,title:e(`chat:header.scrollTopTitle`),className:U(`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,Z.jsx)(Rt,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`activity:chatView.top`)})]}),t.rows.length===0&&!t.isLoading?(0,Z.jsx)(`div`,{className:`h-full overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6 pt-4 pb-8`,children:(0,Z.jsx)(yd,{})})}):(0,Z.jsxs)(be,{ref:t.vlistRef,className:`h-full`,onScroll:t.handleScroll,role:`log`,"aria-label":e(`activity:chatView.chatTranscript`),"aria-live":`polite`,children:[t.rows.map((e,n)=>(0,Z.jsx)(gf,{row:e,isLoading:t.isLoading,compactMode:t.compactMode,isFirstRow:n===0,groupToolCalls:t.groupToolCallsPref},e.key)),(0,Z.jsxs)(`div`,{id:`chat-activity`,className:U(`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6`,t.compactMode?`pb-3`:`pb-8`),children:[(0,Z.jsx)(_f,{}),t.isLoading&&(0,Z.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Z.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,Z.jsx)(On,{className:`h-4 w-4`})}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,Z.jsx)(`div`,{className:`rounded-lg px-4 py-3 bg-card border border-border/70 text-foreground shadow-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,Z.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.3s]`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.15s]`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce`})]}),(0,Z.jsx)(`span`,{className:`text-foreground/90`,children:t.runningStatus.label}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t.runningStatus.elapsed}),t.iteration&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`· iter `,t.iteration.index,t.iteration.max>0?`/${t.iteration.max}`:``]}),t.runningStatus.speedLabel&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 tabular-nums`,children:[`· `,t.runningStatus.speedLabel]})]})})})]})]},`__live`)]})]}),(0,Z.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:t.inputCollapsed&&t.messages.length>0?(0,Z.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,Z.jsxs)(`button`,{type:`button`,onClick:()=>t.setInputCollapsed(!1),className:`flex flex-1 items-center gap-2 text-xs text-muted-foreground/60 hover:text-foreground/80 transition-colors`,children:[(0,Z.jsx)(a,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{children:e(`chat:input.expandInput`,`Expand input`)}),t.rows.length>0&&(0,Z.jsxs)(`span`,{className:`ml-auto tabular-nums text-[10px] text-muted-foreground/40`,children:[t.rows.length,` msgs · `,bo(t.totalTokens.input+t.totalTokens.output)]})]}),(0,Z.jsx)(bd,{label:e(`activity:chatView.autoCollapse`),value:t.autoCollapseInput,onChange:t.handleToggleAutoCollapse})]}):(0,Z.jsxs)(Z.Fragment,{children:[t.messages.length>0&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t.setInputCollapsed(!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,Z.jsx)(Nn,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`chat:input.collapseInput`,`Collapse`)})]}),(0,Z.jsx)(hd,{}),(0,Z.jsx)(xd,{hasStatusContent:t.hasStatusContent,totalTokens:t.totalTokens,rowsCount:t.rows.length,iteration:t.iteration,startTime:t.startTime,formatDuration:t.formatDuration,onToggleAutoCollapse:t.handleToggleAutoCollapse}),(0,Z.jsx)(`div`,{className:`ws-chat-input-wrap p-0`,children:(0,Z.jsx)(`div`,{className:`max-w-6xl mx-auto`,children:(0,Z.jsx)(Uu,{onOpenBreakdown:()=>t.setBreakdownOpen(!0)})})})]})}),(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(bf,{open:t.processOpen,onClose:()=>t.setProcessOpen(!1)})}),(0,Z.jsx)(Gu,{open:t.checkpointOpen,onClose:()=>t.setCheckpointOpen(!1)}),(0,Z.jsx)(As,{open:t.breakdownOpen,onClose:()=>t.setBreakdownOpen(!1)}),(0,Z.jsx)(od,{open:t.editorOpen,onClose:()=>t.setEditorOpen(!1)}),(0,Z.jsx)(Kl,{open:t.memoryPanelOpen,onClose:()=>t.setMemoryPanelOpen(!1)})]})}function Sf(e,t=!0){let n=(0,X.useRef)(null);return(0,X.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let i=requestAnimationFrame(()=>{let t=K.getState().scrollPositions[e];typeof t==`number`&&t>0&&(r.scrollTop=t)});return()=>cancelAnimationFrame(i)},[]),(0,X.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let{setScrollPosition:i}=K.getState();return()=>{i(e,r.scrollTop)}},[e]),n}function Cf(){let{t:e}=h(),t=Pr(e=>e.contextMemories),n=Pr(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,Z.jsxs)(`section`,{className:`rounded-md border border-primary/20 bg-primary/[0.025]`,"aria-label":e(`activity:ctxMonitor.contextMemoryMonitor`),children:[(0,Z.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2`,children:[(0,Z.jsx)(Gt,{className:`size-4 text-primary`}),(0,Z.jsx)(`h2`,{className:`text-xs font-semibold`,children:e(`activity:ctxMonitor.contextMemoryMonitor`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`activity:ctxMonitor.exactProviderBoundPresence`)}),(0,Z.jsxs)(`div`,{className:`ml-auto flex gap-2 font-mono text-[10px]`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[i.length,` ctx`]}),(0,Z.jsxs)(`span`,{className:`text-warning`,children:[a.length,` pending`]}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[o.length,` left`]})]})]}),r.length===0?(0,Z.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:e(`activity:ctxMonitor.noSageHasEnteredThisSession`)}):(0,Z.jsxs)(`div`,{className:`grid gap-3 p-3 xl:grid-cols-[minmax(0,2fr)_minmax(260px,1fr)]`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.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,Z.jsxs)(`article`,{className:U(`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,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`span`,{className:`font-mono font-bold text-primary`,children:e.id}),(0,Z.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[e.kind,` · `,e.persistence]}),(0,Z.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,Z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-foreground`,children:e.text}),(0,Z.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`why: `,e.activationReasons.join(` · `)||`context snapshot`]}),(e.anchors.length>0||e.tags.length>0)&&(0,Z.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,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.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,Z.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,Z.jsx)(Ze,{className:`mt-0.5 size-3 shrink-0 text-muted-foreground`}):(0,Z.jsx)(yn,{className:`mt-0.5 size-3 shrink-0 text-success`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`p`,{className:`font-mono`,children:[(0,Z.jsx)(`span`,{className:e.action===`exited`?`text-muted-foreground`:`text-success`,children:e.action}),` `,e.memoryId]}),(0,Z.jsx)(`p`,{className:`truncate text-muted-foreground`,children:e.reason})]}),(0,Z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(Le,{className:`size-2.5`}),` `,new Date(e.at).toLocaleTimeString()]})]},e.id))]})]})]})}function wf(){let{t:e}=h(),t=Ir(e=>e.items),n=Ir(e=>e.clear);return(0,Z.jsxs)(`section`,{className:`shrink-0 border-b border-border/60 bg-info/[0.025]`,"aria-label":e(`activity:memoryManager.lifecycleAria`),children:[(0,Z.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-4`,children:[(0,Z.jsx)(Ie,{className:`size-3.5 text-info`}),(0,Z.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wide text-info`,children:e(`activity:memoryManager.lifecycleHeading`)}),(0,Z.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,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`ml-auto h-6 px-2 text-[10px]`,onClick:n,children:[(0,Z.jsx)(_n,{className:`size-3`}),` `,e(`common:action.clear`)]})]}),t.length>0?(0,Z.jsx)(`div`,{className:`max-h-20 overflow-y-auto border-t border-border/40`,children:t.slice(0,8).map(e=>(0,Z.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,Z.jsx)(Tf,{action:e.action}),(0,Z.jsx)(`span`,{className:U(`font-mono font-semibold`,Ef(e.action)),children:e.label}),e.detail&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,title:e.detail,children:e.detail}),(0,Z.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=U(`size-3 shrink-0`,Ef(e));return e===`entered`||e===`recovered`?(0,Z.jsx)(Zn,{className:t}):e===`exited`?(0,Z.jsx)(fn,{className:t}):e===`related`?(0,Z.jsx)(ze,{className:t}):(0,Z.jsx)(wr,{className:t})}function Ef(e){return e===`entered`||e===`recovered`?`text-success`:e===`exited`?`text-destructive`:e===`related`?`text-primary`:`text-info`}var Df=[{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 Of(e){return e>95?Df[3]:e>85?Df[2]:e>60?Df[1]:Df[0]}function kf(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 Af({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,Z.jsxs)(`div`,{className:U(`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,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-bold tracking-tight text-foreground`,children:[(0,Z.jsx)(`span`,{className:U(`flex items-center justify-center h-6 w-6 rounded-lg`,o,i!=="default"&&`ring-1 ring-inset`),children:(0,Z.jsx)(t,{className:U(`h-3.5 w-3.5`,a)})}),e]}),n]})}function jf({label:e,value:t,color:n}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:U(`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded`,n??`text-foreground`),children:t})]})}function Mf({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=Of(r).cssColor;return(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:`drop-shadow-lg`,children:[(0,Z.jsxs)(`title`,{children:[`Context usage: `,r.toFixed(0),`%`]}),(0,Z.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:`hsl(var(--muted))`,strokeWidth:n,opacity:.3}),(0,Z.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,Z.jsx)(`circle`,{cx:t/2,cy:t/2,r:i-n/2+2,fill:`hsl(var(--card))`,className:`drop-shadow-sm`}),(0,Z.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 Nf({value:e,suffix:t=``,duration:n=800}){let[r,i]=(0,X.useState)(0),a=(0,X.useRef)(0),o=(0,X.useRef)(void 0);return(0,X.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,Z.jsxs)(Z.Fragment,{children:[r.toLocaleString(),t]})}function Pf({pct:e,tokens:t,maxTokens:n}){let{t:r}=h(),i=Of(e),a=e>85?`danger`:e>60?`warning`:`success`;return(0,Z.jsxs)(Af,{title:r(`activity:ctxDash.contextPressure`),icon:Ye,accent:a,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:U(`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,Z.jsx)(Mf,{pct:e,size:96,strokeWidth:10})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 w-full`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-xl`,children:i.emoji}),(0,Z.jsx)(`div`,{className:`flex-1`,children:(0,Z.jsx)(Mo,{pct:Math.round(e),tokens:t,maxTokens:n,segments:10,variant:`iridescent`})})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-1 text-[10px] font-mono tabular-nums`,children:[(0,Z.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.used`)}),(0,Z.jsx)(`span`,{className:U(`font-bold`,i.color),children:(0,Z.jsx)(Nf,{value:t})})]}),(0,Z.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.free`)}),(0,Z.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,Z.jsx)(Nf,{value:Math.max(0,n-t)})})]}),(0,Z.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.capacity`)}),(0,Z.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,Z.jsx)(Nf,{value:n})})]})]})]})]}),(0,Z.jsxs)(`div`,{className:`relative h-4 mt-1`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-2 rounded-full overflow-hidden flex`,children:Df.map(e=>{let t=(e.to-e.from)/100*100;return(0,Z.jsx)(`div`,{className:`h-full first:rounded-l-full last:rounded-r-full opacity-60`,style:{width:`${t}%`,backgroundColor:e.cssColor}},r(e.labelKey))})}),(0,Z.jsxs)(`div`,{className:`absolute top-3 text-[10px] text-muted-foreground flex w-full`,children:[(0,Z.jsx)(`span`,{children:`0%`}),(0,Z.jsx)(`span`,{className:`ml-[56%]`,children:`soft`}),(0,Z.jsx)(`span`,{className:`ml-[12%]`,children:`hard`}),(0,Z.jsx)(`span`,{className:`ml-[8%]`,children:`max`}),(0,Z.jsx)(`span`,{className:`ml-auto`,children:`100%`})]})]}),(0,Z.jsx)(`div`,{className:`relative h-5 mt-1`,children:(0,Z.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,Z.jsxs)(`span`,{className:U(`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}=h();if(t)return(0,Z.jsx)(Af,{title:n(`activity:ctxDash.contextComposition`),icon:fr,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground py-2`,children:[(0,Z.jsx)(wr,{className:`h-3 w-3 animate-spin`}),n(`activity:ctxDash.fetchingCompositionData`)]})});if(!e||e.total<=0)return(0,Z.jsx)(Af,{title:n(`activity:ctxDash.contextComposition`),icon:fr,children:(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:n(`activity:ctxDash.noCompositionDataAvailableYetRun`)})});let r=[{icon:We,label:n(`activity:ctxDash.systemPrompt`),value:e.systemPrompt,className:`bg-info`},{icon:nn,label:n(`activity:ctxDash.tools`),value:e.tools.total,className:`bg-warning`},{icon:wt,label:n(`activity:ctxDash.messages`),value:e.messages.total,className:`bg-success`}];return(0,Z.jsxs)(Af,{title:n(`activity:ctxDash.contextComposition`),icon:fr,children:[(0,Z.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,Z.jsx)(`span`,{className:U(`h-full first:rounded-l-full last:rounded-r-full transition-all`,t.className),style:{width:`${n}%`}},t.label)})}),(0,Z.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>{let n=(t.value/e.total*100).toFixed(1);return(0,Z.jsx)(jf,{label:`${t.label}`,value:`${Vo(t.value)} (${n}%)`},t.label)})}),e.tools.breakdown.length>0&&(0,Z.jsxs)(`div`,{className:`pt-1 border-t border-border/50`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-semibold`,children:n(`activity:ctxDash.toolBreakdown`)}),(0,Z.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:e.tools.breakdown.slice(0,5).map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.name}),(0,Z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:Vo(e.tokens)})]},e.name))})]})]})}function If({pct:e}){let{t}=h();return(0,Z.jsxs)(Af,{title:t(`activity:ctxDash.thresholdMap`),icon:Pe,children:[(0,Z.jsx)(`div`,{className:`flex h-2 rounded-full overflow-hidden`,children:Df.map(e=>(0,Z.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,Z.jsx)(`div`,{className:`space-y-0.5 text-xs`,children:Df.map(n=>{let r=e>=n.from&&e<n.to;return(0,Z.jsxs)(`div`,{className:U(`flex items-center px-2 py-1 rounded`,r?n.bg:``),children:[(0,Z.jsx)(`span`,{className:`w-5`,children:n.emoji}),(0,Z.jsx)(`span`,{className:U(`w-20 font-medium`,r?n.text:`text-muted-foreground`),children:t(n.labelKey)}),(0,Z.jsxs)(`span`,{className:`w-16 text-muted-foreground`,children:[n.from,`%–`,n.to,`%`]}),(0,Z.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:t(n.descKey)}),r&&(0,Z.jsx)(`span`,{className:`text-xs font-mono`,children:`◀`})]},t(n.labelKey))})}),(0,Z.jsx)(jf,{label:t(`activity:ctxDash.currentPosition`),value:`${e.toFixed(1)}% → ${Of(e).emoji} ${t(Of(e).labelKey)}`,color:Of(e).color}),(0,Z.jsx)(jf,{label:t(`activity:ctxDash.compactTrigger`),value:`85%`}),(0,Z.jsx)(jf,{label:t(`activity:ctxDash.hardLimit`),value:`100%`})]})}function Lf({pct:e,maxTokens:t}){let{t:n}=h(),r=Math.round(t*.18),i=Math.round(t*.85),a=e>65,o=t>0?e/100:0;return(0,Z.jsx)(Af,{title:n(`activity:ctxDash.compactionEngine`),icon:xn,accent:a?`warning`:`success`,children:(0,Z.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.strategy`)}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground/90`,children:`hybrid`}),(0,Z.jsx)(`span`,{className:`text-success bg-success/10 px-1.5 rounded text-[9px] font-semibold`,children:n(`activity:ctxDash.auto`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:n(`activity:ctxDash.current`)}),(0,Z.jsxs)(`span`,{children:[`Trigger (`,Vo(i),`)`]})]}),(0,Z.jsxs)(`div`,{className:`relative h-2 w-full overflow-hidden rounded-full bg-muted/50 ring-1 ring-inset ring-border/20`,children:[(0,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`span`,{className:`absolute top-0 bottom-0 w-0.5 bg-destructive/60`,style:{left:`85%`}})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-foreground/70`,children:[(0,Z.jsx)(`span`,{children:Vo(Math.round(t*o))}),(0,Z.jsx)(`span`,{className:`text-destructive/70`,children:Vo(i)})]})]}),(0,Z.jsx)(jf,{label:n(`activity:ctxDash.nextTrigger`),value:`${Vo(i)} (85%)`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.estRecovery`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded text-success bg-success/10`,children:[`~`,Vo(r)]})]}),(0,Z.jsx)(jf,{label:n(`activity:ctxDash.recommendation`),value:a?`⚠️ Compact now`:`✅ No compaction needed`,color:a?`text-warning`:`text-success`}),a&&(0,Z.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 ~`,Vo(r),` tokens.`]})]})})}function Rf({agents:e}){let{t}=h(),n=e.filter(e=>e.ctxPct!=null&&e.ctxPct>0);return n.length===0?null:(0,Z.jsx)(Af,{title:t(`activity:ctxDash.perAgentFootprint`),icon:Er,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=Of(e.ctxPct),n=e.name||e.id,r=e.id===`__leader__`;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`span`,{className:`w-4`,children:r?`👑`:` `}),(0,Z.jsx)(`span`,{className:`w-24 truncate font-mono text-muted-foreground`,title:n,children:n}),(0,Z.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,Z.jsx)(No,{pct:Math.round(e.ctxPct),tokens:e.ctxTokens,maxTokens:e.maxContext,showTokens:!1})}),(0,Z.jsxs)(`span`,{className:U(`tabular-nums w-10 text-right`,t.color),children:[Math.round(e.ctxPct),`%`]})]},e.id)})})})}function zf({tokens:e,maxTokens:t,pct:n,model:r,provider:i,mode:a,uptime:o,iteration:s,contextMode:c}){let{t:l}=h(),u=t-e,d=t>0?(u/t*100).toFixed(1):`0.0`;return(0,Z.jsx)(Af,{title:l(`activity:ctxDash.tokenMetrics`),icon:Ln,children:(0,Z.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Z.jsx)(jf,{label:l(`activity:ctxDash.used`),value:Vo(e)}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.free`),value:`${Vo(u)} (${d}%)`}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.capacity`),value:Vo(t)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:l(`activity:ctxDash.utilization`)}),(0,Z.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,Z.jsx)(No,{pct:Math.round(n),tokens:e,maxTokens:t})})]}),(0,Z.jsx)(`div`,{className:`border-t border-border/50 pt-1 mt-1`}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.model`),value:`${r} · ${i}`}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.mode`),value:a}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.contextMode`),value:c}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.iteration`),value:s}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.uptime`),value:o})]})})}function Bf({model:e,provider:t,mode:n,uptime:r,projectName:i,cwd:a,contextMode:o}){let{t:s}=h();return(0,Z.jsx)(Af,{title:s(`activity:ctxDash.session`),icon:y,children:(0,Z.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Z.jsx)(jf,{label:s(`activity:ctxDash.provider`),value:t}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.model`),value:e}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.mode`),value:n}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.contextMode`),value:o}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.project`),value:i||a}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.uptime`),value:r})]})})}function Vf(){let{t:e}=h(),t=K(e=>e.setCurrentView),{lastInputTokens:n,maxContext:r,mode:i,contextMode:a,startTime:o,session:s,iteration:c,projectName:l,cwd:u}=W(he(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=ii(he(e=>[...e.agents.values()])),f=G(e=>e.wsUrl),[p,m]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(null),b=(0,X.useRef)(0),x=(0,X.useRef)(null),S=()=>{x.current?.(),x.current=null;let e=H(f);if(!e?.send){y(`WebSocket not connected`);return}let t=++b.current;_(!0),y(null),e.send({type:`context.debug`},{echoToChat:!1});let n=!1,r,i=e.on(`context.debug`,e=>{n||e.type===`context.debug`&&b.current===t&&(n=!0,r!==void 0&&clearTimeout(r),m(e.payload),_(!1),i())});x.current=i,r=setTimeout(()=>{n||(n=!0,b.current===t&&(_(!1),y(`No response from server`),i()))},5e3)};(0,X.useEffect)(()=>(S(),()=>{b.current++,x.current?.(),x.current=null}),[f]);let C=s?.model??`—`,w=s?.provider??`—`,T=r>0?Math.min(100,n/r*100):0,E=kf(o),O=c?`${c.index} / ${c.max}`:`—`,k=Of(T),A=e=>({animation:`fadeInUp 0.4s ease-out ${e*.08}s both`});return(0,Z.jsxs)(`div`,{ref:Sf(`context`),className:`flex-1 min-h-0 overflow-y-auto overscroll-contain`,children:[(0,Z.jsx)(`style`,{children:`
124
+ `).trim();return(0,Z.jsxs)(`div`,{className:`flex gap-3 animate-message thinking-bubble`,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`thinking-orb flex-shrink-0`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{className:`thinking-orb__ring`}),(0,Z.jsx)(`span`,{className:`thinking-orb__ring thinking-orb__ring--delay`}),(0,Z.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--one`}),(0,Z.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--two`}),(0,Z.jsx)(cr,{className:`thinking-orb__icon h-4 w-4`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`thinking-label text-xs font-medium text-primary px-1`,children:[(0,Z.jsx)(`span`,{children:e(`chat:thinking`)}),(0,Z.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{})]})]}),(0,Z.jsxs)(`div`,{className:`thinking-panel rounded-2xl rounded-bl-md px-3 py-2 border text-foreground/80`,children:[(0,Z.jsxs)(`div`,{className:`thinking-wave`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{})]}),(0,Z.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 vf(e){let{hasMessages:t,autoCollapseInput:n,sessionChanged:r,prevHadMessages:i,prevAutoCollapse:a}=e;return n&&t&&(r||!i||!a)}function yf(){let{t:e}=h(),t=r(e=>e.messages),n=r(e=>e.isLoading),i=K(e=>e.sidebarOpen),a=K(e=>e.toggleSidebar),o=K(e=>e.compactMode),{totalTokens:s,startTime:c,lastInputTokens:l,maxContext:u,contextLimitWarning:d,cacheStats:f,iteration:p}=W(he(e=>({totalTokens:e.totalTokens,startTime:e.startTime,lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,contextLimitWarning:e.contextLimitWarning,cacheStats:e.cacheStats,iteration:e.iteration}))),m=W(e=>e.session),g=m?.id,_=K(e=>g?e.sessionNicknames[g]:void 0),v=K(e=>e.setSessionNickname),y=m?.title,[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(``),w=fi(e=>e.entries),[T,E]=(0,X.useState)(!1),D=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!T)return;let e=e=>{D.current?.contains(e.target)||E(!1)},t=e=>{e.key===`Escape`&&E(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[T]);let{provider:O,model:k}=G(he(e=>({provider:e.provider,model:e.model}))),A=(0,X.useRef)(null),j=(0,X.useMemo)(()=>Co(t),[t]),M=(0,X.useRef)(0);M.current=j.length+1;let ee=(0,X.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]),N=K(e=>e.scrollTarget),te=B(e=>e.autonomy),P=B(e=>e.groupToolCalls),F=B(e=>e.autoCollapseInput),I=(0,X.useCallback)(e=>{B.getState().set({autonomy:e}),H()?.send?.({type:`autonomy.switch`,payload:{mode:e}})},[]),[ne,re]=(0,X.useState)(!1),[ie,L]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!1),[se,R]=(0,X.useState)(t.length>0&&F),ce=(0,X.useRef)(n),le=(0,X.useRef)(t.length>0),ue=(0,X.useRef)(g),de=(0,X.useRef)(F),[fe,pe]=(0,X.useState)(!1),[me,ge]=(0,X.useState)(!1),_e=Pr(e=>Object.values(e.contextMemories).filter(e=>e.state!==`exited`).length);(0,X.useEffect)(()=>{let e=()=>oe(!0);return window.addEventListener(`open:memory-panel`,e),()=>window.removeEventListener(`open:memory-panel`,e)},[]),(0,X.useEffect)(()=>{let e=()=>pe(!0);return document.addEventListener(`open:context-breakdown`,e),()=>document.removeEventListener(`open:context-breakdown`,e)},[]),(0,X.useEffect)(()=>{let e=()=>ge(!0);return document.addEventListener(`open:context-editor`,e),()=>document.removeEventListener(`open:context-editor`,e)},[]),(0,X.useEffect)(()=>{let e=()=>R(!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,X.useEffect)(()=>{ce.current&&!n&&R(!1),ce.current=n},[n]),(0,X.useEffect)(()=>{let e=t.length>0,r=g!=null&&g!==ue.current;!n&&vf({hasMessages:e,autoCollapseInput:F,sessionChanged:r,prevHadMessages:le.current,prevAutoCollapse:de.current})&&R(!0),ue.current=g,le.current=e,de.current=F},[t.length,F,g,n]);let ve=(0,X.useCallback)(()=>{let e=!B.getState().autoCollapseInput;B.getState().set({autoCollapseInput:e}),e||R(!1)},[]),ye=u>0&&l>0?Math.min(100,Math.round(l/u*100)):0,[be,xe]=(0,X.useState)(!0),[Se,Ce]=(0,X.useState)(0),[we,Te]=(0,X.useState)(!1),Ee=(0,X.useRef)(t.length),De=(0,X.useCallback)(()=>{let e=A.current;if(!e)return;let t=e.scrollSize-e.scrollOffset-e.viewportSize<120;xe(t),t&&(Ce(0),Ee.current=r.getState().messages.length),Te(e.scrollOffset>e.viewportSize&&e.scrollSize>e.viewportSize*2.5)},[]),Oe=(0,X.useCallback)(e=>{H()?.resumeSession?.(e),E(!1)},[]);(0,X.useEffect)(()=>{let e=A.current;if(e){if(be)e.scrollToIndex(M.current-1,{align:`end`}),Ee.current=t.length;else{let e=t.length-Ee.current;e>0&&Ce(e)}}},[t,be]),(0,X.useEffect)(()=>{xe(!0),Ce(0),Ee.current=r.getState().messages.length,requestAnimationFrame(()=>{A.current?.scrollToIndex(M.current-1,{align:`end`})})},[g]),(0,X.useEffect)(()=>{if(!N)return;let e=ee.get(N.id);e!==void 0&&A.current?.scrollToIndex(e,{align:`center`,smooth:!0})},[N,ee]);let ke=(0,X.useCallback)(()=>{A.current?.scrollToIndex(M.current-1,{align:`end`,smooth:!0}),xe(!0),Ce(0),Ee.current=r.getState().messages.length},[]),Ae=(0,X.useCallback)(()=>{A.current?.scrollToIndex(0,{align:`start`,smooth:!0})},[]),[je,Me]=(0,X.useState)(null),[Ne,Pe]=(0,X.useState)(()=>Date.now()),Fe=(0,X.useRef)(null),Ie=(0,X.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=je?Math.max(0,Math.floor((Ne-je)/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=Fe.current;if(!e||e.id!==c.id)Fe.current={id:c.id,at:Date.now(),len:c.content.length};else{let t=Math.max(1,Ne-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 Fe.current&&=null;return{label:i,elapsed:o,speedLabel:s}},[t,Ne,je,e]);(0,X.useEffect)(()=>{n&&je===null&&Me(Date.now()),!n&&je!==null&&Me(null)},[n,je]),(0,X.useEffect)(()=>{if(!n)return;let e=setInterval(()=>Pe(Date.now()),500);return()=>clearInterval(e)},[n]);let Le=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`},Re=(()=>{if(!n)return`idle`;let e=t[t.length-1];return e?.role===`assistant`&&e.content&&e.streaming?`streaming`:`thinking`})();return{messages:t,isLoading:n,sidebarOpen:i,toggleSidebar:a,compactMode:o,totalTokens:s,startTime:c,lastInputTokens:l,maxContext:u,contextLimitWarning:d,cacheStats:f,iteration:p,sessionId:g,nickname:_,sessionTitle:y,renamingTitle:b,setRenamingTitle:x,titleDraft:S,setTitleDraft:C,setSessionNickname:v,historyEntries:w,switcherOpen:T,setSwitcherOpen:E,switcherRef:D,handleHistorySelect:Oe,provider:O,model:k,vlistRef:A,rows:j,autonomy:te,groupToolCallsPref:P,autoCollapseInput:F,handleAutonomyChange:I,processOpen:ne,setProcessOpen:re,checkpointOpen:ie,setCheckpointOpen:L,memoryPanelOpen:ae,setMemoryPanelOpen:oe,inputCollapsed:se,setInputCollapsed:R,breakdownOpen:fe,setBreakdownOpen:pe,editorOpen:me,setEditorOpen:ge,activeMemoryCount:_e,handleToggleAutoCollapse:ve,ctxPct:ye,pinnedToBottom:be,unreadCount:Se,scrolledDeep:we,handleScroll:De,scrollToBottom:ke,scrollToTop:Ae,runningStatus:Ie,formatDuration:Le,agentState:Re,stateTone:Re===`idle`?`bg-muted text-muted-foreground`:Re===`streaming`?`bg-primary/10 text-primary`:`bg-warning/10 text-warning`,hasStatusContent:u>0&&l>0||s.input>0||!!c}}var bf=(0,X.lazy)(()=>V(()=>import(`./ProcessMonitor-9TOnqT6l.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])));function xf(){let{t:e}=h(),t=yf();return(0,Z.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 bg-[hsl(var(--surface-2)/0.45)]`,children:[(0,Z.jsx)(Dd,{sidebarOpen:t.sidebarOpen,toggleSidebar:t.toggleSidebar,agentState:t.agentState,stateTone:t.stateTone,sessionId:t.sessionId,renamingTitle:t.renamingTitle,setRenamingTitle:t.setRenamingTitle,titleDraft:t.titleDraft,setTitleDraft:t.setTitleDraft,nickname:t.nickname,sessionTitle:t.sessionTitle,setSessionNickname:t.setSessionNickname,historyEntries:t.historyEntries,switcherRef:t.switcherRef,switcherOpen:t.switcherOpen,setSwitcherOpen:t.setSwitcherOpen,handleHistorySelect:t.handleHistorySelect,provider:t.provider,model:t.model,iteration:t.iteration,autonomy:t.autonomy,handleAutonomyChange:t.handleAutonomyChange,memoryPanelOpen:t.memoryPanelOpen,setMemoryPanelOpen:t.setMemoryPanelOpen,activeMemoryCount:t.activeMemoryCount,processOpen:t.processOpen,setProcessOpen:t.setProcessOpen,checkpointOpen:t.checkpointOpen,setCheckpointOpen:t.setCheckpointOpen,hasStatusContent:t.hasStatusContent,lastInputTokens:t.lastInputTokens,ctxPct:t.ctxPct,maxContext:t.maxContext,cacheStats:t.cacheStats,setBreakdownOpen:t.setBreakdownOpen,contextLimitWarning:t.contextLimitWarning,setEditorOpen:t.setEditorOpen,totalTokens:t.totalTokens,startTime:t.startTime,formatDuration:t.formatDuration}),(0,Z.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,Z.jsx)(vd,{}),!t.pinnedToBottom&&(0,Z.jsxs)(`button`,{type:`button`,onClick:t.scrollToBottom,className:U(`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,Z.jsx)(S,{className:`h-3.5 w-3.5`}),t.unreadCount>0?`${t.unreadCount} new message${t.unreadCount===1?``:`s`}`:`Jump to latest`]}),t.scrolledDeep&&(0,Z.jsxs)(`button`,{type:`button`,onClick:t.scrollToTop,title:e(`chat:header.scrollTopTitle`),className:U(`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,Z.jsx)(Rt,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`activity:chatView.top`)})]}),t.rows.length===0&&!t.isLoading?(0,Z.jsx)(`div`,{className:`h-full overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6 pt-4 pb-8`,children:(0,Z.jsx)(yd,{})})}):(0,Z.jsxs)(be,{ref:t.vlistRef,className:`h-full`,onScroll:t.handleScroll,role:`log`,"aria-label":e(`activity:chatView.chatTranscript`),"aria-live":`polite`,children:[t.rows.map((e,n)=>(0,Z.jsx)(gf,{row:e,isLoading:t.isLoading,compactMode:t.compactMode,isFirstRow:n===0,groupToolCalls:t.groupToolCallsPref},e.key)),(0,Z.jsxs)(`div`,{id:`chat-activity`,className:U(`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6`,t.compactMode?`pb-3`:`pb-8`),children:[(0,Z.jsx)(_f,{}),t.isLoading&&(0,Z.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Z.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,Z.jsx)(On,{className:`h-4 w-4`})}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,Z.jsx)(`div`,{className:`rounded-lg px-4 py-3 bg-card border border-border/70 text-foreground shadow-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,Z.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.3s]`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.15s]`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce`})]}),(0,Z.jsx)(`span`,{className:`text-foreground/90`,children:t.runningStatus.label}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t.runningStatus.elapsed}),t.iteration&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`· iter `,t.iteration.index,t.iteration.max>0?`/${t.iteration.max}`:``]}),t.runningStatus.speedLabel&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 tabular-nums`,children:[`· `,t.runningStatus.speedLabel]})]})})})]})]},`__live`)]})]}),(0,Z.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:t.inputCollapsed&&t.messages.length>0?(0,Z.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,Z.jsxs)(`button`,{type:`button`,onClick:()=>t.setInputCollapsed(!1),className:`flex flex-1 items-center gap-2 text-xs text-muted-foreground/60 hover:text-foreground/80 transition-colors`,children:[(0,Z.jsx)(a,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{children:e(`chat:input.expandInput`,`Expand input`)}),t.rows.length>0&&(0,Z.jsxs)(`span`,{className:`ml-auto tabular-nums text-[10px] text-muted-foreground/40`,children:[t.rows.length,` msgs · `,bo(t.totalTokens.input+t.totalTokens.output)]})]}),(0,Z.jsx)(bd,{label:e(`activity:chatView.autoCollapse`),value:t.autoCollapseInput,onChange:t.handleToggleAutoCollapse})]}):(0,Z.jsxs)(Z.Fragment,{children:[t.messages.length>0&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t.setInputCollapsed(!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,Z.jsx)(Nn,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`chat:input.collapseInput`,`Collapse`)})]}),(0,Z.jsx)(hd,{}),(0,Z.jsx)(xd,{hasStatusContent:t.hasStatusContent,totalTokens:t.totalTokens,rowsCount:t.rows.length,iteration:t.iteration,startTime:t.startTime,formatDuration:t.formatDuration,onToggleAutoCollapse:t.handleToggleAutoCollapse}),(0,Z.jsx)(`div`,{className:`ws-chat-input-wrap p-0`,children:(0,Z.jsx)(`div`,{className:`max-w-6xl mx-auto`,children:(0,Z.jsx)(Uu,{onOpenBreakdown:()=>t.setBreakdownOpen(!0)})})})]})}),(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(bf,{open:t.processOpen,onClose:()=>t.setProcessOpen(!1)})}),(0,Z.jsx)(Gu,{open:t.checkpointOpen,onClose:()=>t.setCheckpointOpen(!1)}),(0,Z.jsx)(As,{open:t.breakdownOpen,onClose:()=>t.setBreakdownOpen(!1)}),(0,Z.jsx)(od,{open:t.editorOpen,onClose:()=>t.setEditorOpen(!1)}),(0,Z.jsx)(Kl,{open:t.memoryPanelOpen,onClose:()=>t.setMemoryPanelOpen(!1)})]})}function Sf(e,t=!0){let n=(0,X.useRef)(null);return(0,X.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let i=requestAnimationFrame(()=>{let t=K.getState().scrollPositions[e];typeof t==`number`&&t>0&&(r.scrollTop=t)});return()=>cancelAnimationFrame(i)},[]),(0,X.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let{setScrollPosition:i}=K.getState();return()=>{i(e,r.scrollTop)}},[e]),n}function Cf(){let{t:e}=h(),t=Pr(e=>e.contextMemories),n=Pr(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,Z.jsxs)(`section`,{className:`rounded-md border border-primary/20 bg-primary/[0.025]`,"aria-label":e(`activity:ctxMonitor.contextMemoryMonitor`),children:[(0,Z.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2`,children:[(0,Z.jsx)(Gt,{className:`size-4 text-primary`}),(0,Z.jsx)(`h2`,{className:`text-xs font-semibold`,children:e(`activity:ctxMonitor.contextMemoryMonitor`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`activity:ctxMonitor.exactProviderBoundPresence`)}),(0,Z.jsxs)(`div`,{className:`ml-auto flex gap-2 font-mono text-[10px]`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[i.length,` ctx`]}),(0,Z.jsxs)(`span`,{className:`text-warning`,children:[a.length,` pending`]}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[o.length,` left`]})]})]}),r.length===0?(0,Z.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:e(`activity:ctxMonitor.noSageHasEnteredThisSession`)}):(0,Z.jsxs)(`div`,{className:`grid gap-3 p-3 xl:grid-cols-[minmax(0,2fr)_minmax(260px,1fr)]`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.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,Z.jsxs)(`article`,{className:U(`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,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`span`,{className:`font-mono font-bold text-primary`,children:e.id}),(0,Z.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[e.kind,` · `,e.persistence]}),(0,Z.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,Z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-foreground`,children:e.text}),(0,Z.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`why: `,e.activationReasons.join(` · `)||`context snapshot`]}),(e.anchors.length>0||e.tags.length>0)&&(0,Z.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,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.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,Z.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,Z.jsx)(Ze,{className:`mt-0.5 size-3 shrink-0 text-muted-foreground`}):(0,Z.jsx)(yn,{className:`mt-0.5 size-3 shrink-0 text-success`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`p`,{className:`font-mono`,children:[(0,Z.jsx)(`span`,{className:e.action===`exited`?`text-muted-foreground`:`text-success`,children:e.action}),` `,e.memoryId]}),(0,Z.jsx)(`p`,{className:`truncate text-muted-foreground`,children:e.reason})]}),(0,Z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(Le,{className:`size-2.5`}),` `,new Date(e.at).toLocaleTimeString()]})]},e.id))]})]})]})}function wf(){let{t:e}=h(),t=Ir(e=>e.items),n=Ir(e=>e.clear);return(0,Z.jsxs)(`section`,{className:`shrink-0 border-b border-border/60 bg-info/[0.025]`,"aria-label":e(`activity:memoryManager.lifecycleAria`),children:[(0,Z.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-4`,children:[(0,Z.jsx)(Ie,{className:`size-3.5 text-info`}),(0,Z.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wide text-info`,children:e(`activity:memoryManager.lifecycleHeading`)}),(0,Z.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,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`ml-auto h-6 px-2 text-[10px]`,onClick:n,children:[(0,Z.jsx)(_n,{className:`size-3`}),` `,e(`common:action.clear`)]})]}),t.length>0?(0,Z.jsx)(`div`,{className:`max-h-20 overflow-y-auto border-t border-border/40`,children:t.slice(0,8).map(e=>(0,Z.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,Z.jsx)(Tf,{action:e.action}),(0,Z.jsx)(`span`,{className:U(`font-mono font-semibold`,Ef(e.action)),children:e.label}),e.detail&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,title:e.detail,children:e.detail}),(0,Z.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=U(`size-3 shrink-0`,Ef(e));return e===`entered`||e===`recovered`?(0,Z.jsx)(Zn,{className:t}):e===`exited`?(0,Z.jsx)(fn,{className:t}):e===`related`?(0,Z.jsx)(ze,{className:t}):(0,Z.jsx)(wr,{className:t})}function Ef(e){return e===`entered`||e===`recovered`?`text-success`:e===`exited`?`text-destructive`:e===`related`?`text-primary`:`text-info`}var Df=[{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 Of(e){return e>95?Df[3]:e>85?Df[2]:e>60?Df[1]:Df[0]}function kf(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 Af({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,Z.jsxs)(`div`,{className:U(`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,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-bold tracking-tight text-foreground`,children:[(0,Z.jsx)(`span`,{className:U(`flex items-center justify-center h-6 w-6 rounded-lg`,o,i!=="default"&&`ring-1 ring-inset`),children:(0,Z.jsx)(t,{className:U(`h-3.5 w-3.5`,a)})}),e]}),n]})}function jf({label:e,value:t,color:n}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:U(`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded`,n??`text-foreground`),children:t})]})}function Mf({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=Of(r).cssColor;return(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:`drop-shadow-lg`,children:[(0,Z.jsxs)(`title`,{children:[`Context usage: `,r.toFixed(0),`%`]}),(0,Z.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:`hsl(var(--muted))`,strokeWidth:n,opacity:.3}),(0,Z.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,Z.jsx)(`circle`,{cx:t/2,cy:t/2,r:i-n/2+2,fill:`hsl(var(--card))`,className:`drop-shadow-sm`}),(0,Z.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 Nf({value:e,suffix:t=``,duration:n=800}){let[r,i]=(0,X.useState)(0),a=(0,X.useRef)(0),o=(0,X.useRef)(void 0);return(0,X.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,Z.jsxs)(Z.Fragment,{children:[r.toLocaleString(),t]})}function Pf({pct:e,tokens:t,maxTokens:n}){let{t:r}=h(),i=Of(e),a=e>85?`danger`:e>60?`warning`:`success`;return(0,Z.jsxs)(Af,{title:r(`activity:ctxDash.contextPressure`),icon:Ye,accent:a,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:U(`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,Z.jsx)(Mf,{pct:e,size:96,strokeWidth:10})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 w-full`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-xl`,children:i.emoji}),(0,Z.jsx)(`div`,{className:`flex-1`,children:(0,Z.jsx)(Mo,{pct:Math.round(e),tokens:t,maxTokens:n,segments:10,variant:`iridescent`})})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-1 text-[10px] font-mono tabular-nums`,children:[(0,Z.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.used`)}),(0,Z.jsx)(`span`,{className:U(`font-bold`,i.color),children:(0,Z.jsx)(Nf,{value:t})})]}),(0,Z.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.free`)}),(0,Z.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,Z.jsx)(Nf,{value:Math.max(0,n-t)})})]}),(0,Z.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.capacity`)}),(0,Z.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,Z.jsx)(Nf,{value:n})})]})]})]})]}),(0,Z.jsxs)(`div`,{className:`relative h-4 mt-1`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-2 rounded-full overflow-hidden flex`,children:Df.map(e=>{let t=(e.to-e.from)/100*100;return(0,Z.jsx)(`div`,{className:`h-full first:rounded-l-full last:rounded-r-full opacity-60`,style:{width:`${t}%`,backgroundColor:e.cssColor}},r(e.labelKey))})}),(0,Z.jsxs)(`div`,{className:`absolute top-3 text-[10px] text-muted-foreground flex w-full`,children:[(0,Z.jsx)(`span`,{children:`0%`}),(0,Z.jsx)(`span`,{className:`ml-[56%]`,children:`soft`}),(0,Z.jsx)(`span`,{className:`ml-[12%]`,children:`hard`}),(0,Z.jsx)(`span`,{className:`ml-[8%]`,children:`max`}),(0,Z.jsx)(`span`,{className:`ml-auto`,children:`100%`})]})]}),(0,Z.jsx)(`div`,{className:`relative h-5 mt-1`,children:(0,Z.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,Z.jsxs)(`span`,{className:U(`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}=h();if(t)return(0,Z.jsx)(Af,{title:n(`activity:ctxDash.contextComposition`),icon:fr,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground py-2`,children:[(0,Z.jsx)(wr,{className:`h-3 w-3 animate-spin`}),n(`activity:ctxDash.fetchingCompositionData`)]})});if(!e||e.total<=0)return(0,Z.jsx)(Af,{title:n(`activity:ctxDash.contextComposition`),icon:fr,children:(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:n(`activity:ctxDash.noCompositionDataAvailableYetRun`)})});let r=[{icon:We,label:n(`activity:ctxDash.systemPrompt`),value:e.systemPrompt,className:`bg-info`},{icon:nn,label:n(`activity:ctxDash.tools`),value:e.tools.total,className:`bg-warning`},{icon:wt,label:n(`activity:ctxDash.messages`),value:e.messages.total,className:`bg-success`}];return(0,Z.jsxs)(Af,{title:n(`activity:ctxDash.contextComposition`),icon:fr,children:[(0,Z.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,Z.jsx)(`span`,{className:U(`h-full first:rounded-l-full last:rounded-r-full transition-all`,t.className),style:{width:`${n}%`}},t.label)})}),(0,Z.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>{let n=(t.value/e.total*100).toFixed(1);return(0,Z.jsx)(jf,{label:`${t.label}`,value:`${Vo(t.value)} (${n}%)`},t.label)})}),e.tools.breakdown.length>0&&(0,Z.jsxs)(`div`,{className:`pt-1 border-t border-border/50`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-semibold`,children:n(`activity:ctxDash.toolBreakdown`)}),(0,Z.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:e.tools.breakdown.slice(0,5).map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.name}),(0,Z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:Vo(e.tokens)})]},e.name))})]})]})}function If({pct:e}){let{t}=h();return(0,Z.jsxs)(Af,{title:t(`activity:ctxDash.thresholdMap`),icon:Pe,children:[(0,Z.jsx)(`div`,{className:`flex h-2 rounded-full overflow-hidden`,children:Df.map(e=>(0,Z.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,Z.jsx)(`div`,{className:`space-y-0.5 text-xs`,children:Df.map(n=>{let r=e>=n.from&&e<n.to;return(0,Z.jsxs)(`div`,{className:U(`flex items-center px-2 py-1 rounded`,r?n.bg:``),children:[(0,Z.jsx)(`span`,{className:`w-5`,children:n.emoji}),(0,Z.jsx)(`span`,{className:U(`w-20 font-medium`,r?n.text:`text-muted-foreground`),children:t(n.labelKey)}),(0,Z.jsxs)(`span`,{className:`w-16 text-muted-foreground`,children:[n.from,`%–`,n.to,`%`]}),(0,Z.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:t(n.descKey)}),r&&(0,Z.jsx)(`span`,{className:`text-xs font-mono`,children:`◀`})]},t(n.labelKey))})}),(0,Z.jsx)(jf,{label:t(`activity:ctxDash.currentPosition`),value:`${e.toFixed(1)}% → ${Of(e).emoji} ${t(Of(e).labelKey)}`,color:Of(e).color}),(0,Z.jsx)(jf,{label:t(`activity:ctxDash.compactTrigger`),value:`85%`}),(0,Z.jsx)(jf,{label:t(`activity:ctxDash.hardLimit`),value:`100%`})]})}function Lf({pct:e,maxTokens:t}){let{t:n}=h(),r=Math.round(t*.18),i=Math.round(t*.85),a=e>65,o=t>0?e/100:0;return(0,Z.jsx)(Af,{title:n(`activity:ctxDash.compactionEngine`),icon:xn,accent:a?`warning`:`success`,children:(0,Z.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.strategy`)}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground/90`,children:`hybrid`}),(0,Z.jsx)(`span`,{className:`text-success bg-success/10 px-1.5 rounded text-[9px] font-semibold`,children:n(`activity:ctxDash.auto`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:n(`activity:ctxDash.current`)}),(0,Z.jsxs)(`span`,{children:[`Trigger (`,Vo(i),`)`]})]}),(0,Z.jsxs)(`div`,{className:`relative h-2 w-full overflow-hidden rounded-full bg-muted/50 ring-1 ring-inset ring-border/20`,children:[(0,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`span`,{className:`absolute top-0 bottom-0 w-0.5 bg-destructive/60`,style:{left:`85%`}})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-foreground/70`,children:[(0,Z.jsx)(`span`,{children:Vo(Math.round(t*o))}),(0,Z.jsx)(`span`,{className:`text-destructive/70`,children:Vo(i)})]})]}),(0,Z.jsx)(jf,{label:n(`activity:ctxDash.nextTrigger`),value:`${Vo(i)} (85%)`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.estRecovery`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded text-success bg-success/10`,children:[`~`,Vo(r)]})]}),(0,Z.jsx)(jf,{label:n(`activity:ctxDash.recommendation`),value:a?`⚠️ Compact now`:`✅ No compaction needed`,color:a?`text-warning`:`text-success`}),a&&(0,Z.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 ~`,Vo(r),` tokens.`]})]})})}function Rf({agents:e}){let{t}=h(),n=e.filter(e=>e.ctxPct!=null&&e.ctxPct>0);return n.length===0?null:(0,Z.jsx)(Af,{title:t(`activity:ctxDash.perAgentFootprint`),icon:Er,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=Of(e.ctxPct),n=e.name||e.id,r=e.id===`__leader__`;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`span`,{className:`w-4`,children:r?`👑`:` `}),(0,Z.jsx)(`span`,{className:`w-24 truncate font-mono text-muted-foreground`,title:n,children:n}),(0,Z.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,Z.jsx)(No,{pct:Math.round(e.ctxPct),tokens:e.ctxTokens,maxTokens:e.maxContext,showTokens:!1})}),(0,Z.jsxs)(`span`,{className:U(`tabular-nums w-10 text-right`,t.color),children:[Math.round(e.ctxPct),`%`]})]},e.id)})})})}function zf({tokens:e,maxTokens:t,pct:n,model:r,provider:i,mode:a,uptime:o,iteration:s,contextMode:c}){let{t:l}=h(),u=t-e,d=t>0?(u/t*100).toFixed(1):`0.0`;return(0,Z.jsx)(Af,{title:l(`activity:ctxDash.tokenMetrics`),icon:Ln,children:(0,Z.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Z.jsx)(jf,{label:l(`activity:ctxDash.used`),value:Vo(e)}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.free`),value:`${Vo(u)} (${d}%)`}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.capacity`),value:Vo(t)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:l(`activity:ctxDash.utilization`)}),(0,Z.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,Z.jsx)(No,{pct:Math.round(n),tokens:e,maxTokens:t})})]}),(0,Z.jsx)(`div`,{className:`border-t border-border/50 pt-1 mt-1`}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.model`),value:`${r} · ${i}`}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.mode`),value:a}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.contextMode`),value:c}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.iteration`),value:s}),(0,Z.jsx)(jf,{label:l(`activity:ctxDash.uptime`),value:o})]})})}function Bf({model:e,provider:t,mode:n,uptime:r,projectName:i,cwd:a,contextMode:o}){let{t:s}=h();return(0,Z.jsx)(Af,{title:s(`activity:ctxDash.session`),icon:y,children:(0,Z.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Z.jsx)(jf,{label:s(`activity:ctxDash.provider`),value:t}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.model`),value:e}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.mode`),value:n}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.contextMode`),value:o}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.project`),value:i||a}),(0,Z.jsx)(jf,{label:s(`activity:ctxDash.uptime`),value:r})]})})}function Vf(){let{t:e}=h(),t=K(e=>e.setCurrentView),{lastInputTokens:n,maxContext:r,mode:i,contextMode:a,startTime:o,session:s,iteration:c,projectName:l,cwd:u}=W(he(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=ii(he(e=>[...e.agents.values()])),f=G(e=>e.wsUrl),[p,m]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(null),b=(0,X.useRef)(0),x=(0,X.useRef)(null),S=()=>{x.current?.(),x.current=null;let e=H(f);if(!e?.send){y(`WebSocket not connected`);return}let t=++b.current;_(!0),y(null),e.send({type:`context.debug`},{echoToChat:!1});let n=!1,r,i=e.on(`context.debug`,e=>{n||e.type===`context.debug`&&b.current===t&&(n=!0,r!==void 0&&clearTimeout(r),m(e.payload),_(!1),i())});x.current=i,r=setTimeout(()=>{n||(n=!0,b.current===t&&(_(!1),y(`No response from server`),i()))},5e3)};(0,X.useEffect)(()=>(S(),()=>{b.current++,x.current?.(),x.current=null}),[f]);let C=s?.model??`—`,w=s?.provider??`—`,T=r>0?Math.min(100,n/r*100):0,E=kf(o),O=c?`${c.index} / ${c.max}`:`—`,k=Of(T),A=e=>({animation:`fadeInUp 0.4s ease-out ${e*.08}s both`});return(0,Z.jsxs)(`div`,{ref:Sf(`context`),className:`flex-1 min-h-0 overflow-y-auto overscroll-contain`,children:[(0,Z.jsx)(`style`,{children:`
125
125
  @keyframes fadeInUp {
126
126
  from { opacity: 0; transform: translateY(12px); }
127
127
  to { opacity: 1; transform: translateY(0); }
@@ -130,4 +130,4 @@ Type while the agent is running to queue messages; they are sent automatically w
130
130
  `):``),b(n.url??``)):i?(s(i.name),l(i.transport),d(i.description??``),S(!0),w(i.lazy??!1),p(i.command??``),g(i.args?.join(` `)??``),v(i.env?Object.entries(i.env).map(([e,t])=>`${e}=${t}`).join(`
131
131
  `):``),b(i.url??``)):(s(``),l(`stdio`),d(``),S(!0),w(!1),p(``),g(``),v(``),b(``)))},[n,i,e]);let T=()=>{if(!o.trim()){J.error(a(`settings:mcp.serverNameRequired`));return}let e={};if(_.trim())for(let t of _.trim().split(`
132
132
  `)){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:x,command:f.trim()||void 0,args:m.trim()?m.trim().split(/\s+/):void 0,env:Object.keys(e).length>0?e:void 0,url:y.trim()||void 0,lazy:C}),t(!1)},E=!!n,D=!!i;return(0,Z.jsx)(Bi,{open:e,onOpenChange:t,children:(0,Z.jsxs)(Li,{children:[(0,Z.jsx)(Fi,{children:(0,Z.jsx)(Ri,{children:a(E?`settings:mcp.dialogTitleEdit`:D?`settings:mcp.dialogTitleAdd`:`settings:mcp.dialogTitleAddCustom`)})}),(0,Z.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldName`)}),(0,Z.jsx)(Vi,{value:o,onChange:e=>s(e.target.value),placeholder:a(`settings:mcp.fieldNamePlaceholder`),disabled:E||D})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldTransport`)}),(0,Z.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:D,children:[(0,Z.jsx)(`option`,{value:`stdio`,children:`stdio`}),(0,Z.jsx)(`option`,{value:`sse`,children:`sse`}),(0,Z.jsx)(`option`,{value:`streamable-http`,children:`streamable-http`}),(0,Z.jsx)(`option`,{value:`http`,children:`http`})]})]}),(c===`streamable-http`||c===`sse`||c===`http`)&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldUrl`)}),(0,Z.jsx)(Vi,{value:y,onChange:e=>b(e.target.value),placeholder:a(`activity:mCPSection.httpsMcpExampleComMcp`),disabled:D})]}),c===`stdio`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldCommand`)}),(0,Z.jsx)(Vi,{value:f,onChange:e=>p(e.target.value),placeholder:a(`settings:mcp.fieldCommandPlaceholder`),disabled:D})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldArgs`),` `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldArgsHint`)})]}),(0,Z.jsx)(Vi,{value:m,onChange:e=>g(e.target.value),placeholder:a(`settings:mcp.fieldArgsPlaceholder`),disabled:D})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldEnv`),` `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldEnvHint`)})]}),(0,Z.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:_,onChange:e=>v(e.target.value),placeholder:`GITHUB_TOKEN=ghp_...
133
- AWS_REGION=us-east-1`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldDescription`)}),(0,Z.jsx)(Vi,{value:u,onChange:e=>d(e.target.value),placeholder:a(`settings:mcp.fieldDescriptionPlaceholder`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`server-enabled`,checked:x,onChange:e=>S(e.target.checked),className:`rounded`}),(0,Z.jsx)(`label`,{htmlFor:`server-enabled`,className:`text-sm`,children:a(`settings:mcp.enableServer`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`server-lazy`,checked:C,onChange:e=>w(e.target.checked),className:`rounded`}),(0,Z.jsxs)(`label`,{htmlFor:`server-lazy`,className:`text-sm`,children:[a(`settings:mcp.lazyConnect`),` `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.lazyConnectHint`)})]})]})]}),(0,Z.jsxs)(Ii,{children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Z.jsx)(Y,{onClick:T,children:a(E?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function Np({server:e,isAdded:t,onAdd:n}){let{t:r}=h();return(0,Z.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,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),e.badge&&(0,Z.jsx)(Ep,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-xs shrink-0`,children:e.transport})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description}),e.requiresEnvVars&&e.requiresEnvVars.length>0&&(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:r(`settings:mcp.requires`,{vars:e.requiresEnvVars.join(`, `)})})]}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:t?(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,disabled:!0,children:[(0,Z.jsx)(Jn,{className:`w-4 h-4 mr-1`}),r(`settings:mcp.added`)]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:n,children:[(0,Z.jsx)(at,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function Pp(){let e=Hr(),{t}=h(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(`list`),[c,l]=(0,X.useState)(),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,g]=(0,X.useState)(),[_,v]=(0,X.useState)(null);(0,X.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]),J.success(z.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)),J.success(z.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),J.success(z.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),J.info(z.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),J.success(z.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),J.success(z.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),J.warn(z.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),J.error(z.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},m=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||J.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,X.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),b=(0,X.useCallback)(e=>{g(Op(e,!1)),p(!0)},[]),x=(0,X.useCallback)(n=>{Gi({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,X.useCallback)(e=>{l(e),g(void 0),d(!0)},[]),C=(0,X.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),w=(0,X.useCallback)(t=>{v(t),e.client?.wakeMcpServer(t)},[e]),T=(0,X.useCallback)(t=>{v(t),e.client?.sleepMcpServer(t)},[e]),E=(0,X.useCallback)(t=>{v(t),e.client?.discoverMcpServer(t)},[e]),D=(0,X.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,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.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,Z.jsx)(Pn,{className:`h-5 w-5`})}),(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`settings:mcp.heading`)}),n.length>0&&(0,Z.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,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:D,disabled:i,children:[i?(0,Z.jsx)(Rn,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,Z.jsxs)(Y,{size:`sm`,onClick:()=>{g(void 0),p(!0)},children:[(0,Z.jsx)(at,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,Z.jsxs)(Qa,{value:o,onValueChange:e=>s(e),children:[(0,Z.jsxs)($a,{children:[(0,Z.jsxs)(eo,{value:`recommended`,children:[(0,Z.jsx)(Mr,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,Z.jsx)(eo,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,Z.jsx)(eo,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,Z.jsxs)(to,{value:`recommended`,className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.recommendedBody`)}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:Dp.map(e=>(0,Z.jsx)(Np,{server:e,isAdded:A.has(e.name),onAdd:()=>b(e)},e.name))})]}),(0,Z.jsx)(to,{value:`list`,className:`space-y-3`,children:i&&n.length===0?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Rn,{className:`w-5 h-5 animate-spin mr-2`}),t(`settings:mcp.loadingServers`)]}):n.length===0?(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Pn,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:t(`settings:mcp.noServers`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.noServersHint`)})]}):n.map(e=>(0,Z.jsx)(jp,{server:e,onWake:()=>w(e.name),onSleep:()=>T(e.name),onDiscover:()=>E(e.name),onEdit:()=>S(e),onRemove:()=>x(e.name)},e.name))}),(0,Z.jsx)(to,{value:`add`,children:(0,Z.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,Z.jsx)(`p`,{children:t(`settings:mcp.addCustomBody`)}),(0,Z.jsx)(`p`,{className:`mt-1`,children:t(`settings:mcp.addCustomBodyHint`)})]})})]}),(0,Z.jsx)(Mp,{open:f,onOpenChange:e=>{e||(p(!1),g(void 0))},prefillConfig:m,onSave:y}),(0,Z.jsx)(Mp,{open:u,onOpenChange:d,server:c,onSave:C})]})}function Fp({syncPref:e}){let{t}=h(),n=B();return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.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,Z.jsx)(Pn,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.hqHeading`)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.hqPublishingLabel`),hint:t(`settings:integrations.hqPublishingHint`),value:n.hqEnabled,onChange:()=>e(`hqEnabled`,!n.hqEnabled)}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqUrlLabel`)}),(0,Z.jsx)(Vi,{value:n.hqUrl,placeholder:t(`activity:integrationsSection.httpHost3499`),onChange:t=>e(`hqUrl`,t.target.value)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.hqUrlHint`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqTokenLabel`)}),(0,Z.jsx)(Vi,{type:`password`,value:n.hqToken,placeholder:t(`activity:integrationsSection.clientTokenFromWstackHq`),onChange:t=>e(`hqToken`,t.target.value)})]}),(0,Z.jsx)($,{label:t(`settings:integrations.hqRawContentLabel`),hint:t(`settings:integrations.hqRawContentHint`),value:n.hqRawContent,onChange:()=>e(`hqRawContent`,!n.hqRawContent)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.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,Z.jsx)(Pn,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`activity:integrationsSection.mcpServers`)})})]}),n.featureMcp?(0,Z.jsx)(Pp,{}):(0,Z.jsxs)(`div`,{className:`text-center py-6 text-muted-foreground`,children:[(0,Z.jsx)(Pn,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.disabled`)}),(0,Z.jsx)(`p`,{className:`text-xs mt-1`,children:t(`settings:integrations.disabledHint`)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.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,Z.jsx)(dn,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.telegramHeading`)})})]}),n.tgConfigured?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.telegramSessionEndLabel`),hint:t(`settings:integrations.telegramSessionEndHint`),value:n.tgSessionEnd,onChange:()=>e(`tgSessionEnd`,!n.tgSessionEnd)}),(0,Z.jsx)($,{label:t(`settings:integrations.telegramDelegateLabel`),hint:t(`settings:integrations.telegramDelegateHint`),value:n.tgDelegate,onChange:()=>e(`tgDelegate`,!n.tgDelegate)}),(0,Z.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,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramChangesApply`)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramNotConfigured`)})]})]})}function Ip({syncPref:e}){let{t}=h(),n=B();return(0,Z.jsx)(`div`,{className:`space-y-6`,children:(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.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,Z.jsx)(Cn,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:logs.heading`)})})]}),(0,Z.jsx)(Q,{label:t(`settings:logs.logLevelLabel`),hint:t(`settings:logs.logLevelHint`),value:n.logLevel,options:[{value:`debug`,label:t(`settings:logs.logLevelDebug`)},{value:`info`,label:t(`settings:logs.logLevelInfo`)},{value:`warn`,label:t(`settings:logs.logLevelWarn`)},{value:`error`,label:t(`settings:logs.logLevelError`)}],onChange:t=>e(`logLevel`,t)}),(0,Z.jsx)(Q,{label:t(`settings:logs.auditLevelLabel`),hint:t(`settings:logs.auditLevelHint`),value:n.auditLevel,options:[{value:`minimal`,label:t(`settings:logs.auditLevelMinimal`)},{value:`standard`,label:t(`settings:logs.auditLevelStandard`)},{value:`full`,label:t(`settings:logs.auditLevelFull`)}],onChange:t=>e(`auditLevel`,t)}),(0,Z.jsx)(Q,{label:t(`settings:logs.fsAccessLabel`),hint:t(`settings:logs.fsAccessHint`),value:n.fsAccess,options:[{value:`unrestricted`,label:t(`settings:logs.fsAccessUnrestricted`)},{value:`project`,label:t(`settings:logs.fsAccessProject`)}],onChange:t=>e(`fsAccess`,t)}),(0,Z.jsx)($,{label:t(`settings:logs.debugStreamLabel`),hint:t(`settings:logs.debugStreamHint`),value:n.debugStream,onChange:()=>e(`debugStream`,!n.debugStream)})]})})}function Lp({provider:e,catalogModels:t,currentCatalogProvider:n,isLoadingModels:r,isSwitching:i,setIsLoadingModels:a,onModelSelect:o,refreshModels:s}){let c=G(e=>e.model),{t:l}=h();return(0,Z.jsx)(`div`,{className:`space-y-4`,children:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:n?.name||e}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{a(!0),s(e)},children:(0,Z.jsx)(wr,{className:U(`h-4 w-4`,r&&`animate-spin`)})})]}),r&&!t[e]?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(Rn,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:l(`settings:model.loading`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Uf,{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,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`settings:toast.switching`)}):null]})]}):(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(y,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:l(`settings:model.selectProviderFirst`)})]})})}function Rp({maskedKey:e,className:t}){let{t:n}=h(),[r,i]=(0,X.useState)(!1),a=(0,X.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),1500)})},[e]);return(0,Z.jsxs)(`div`,{className:U(`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,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate tracking-wide`,children:e}),(0,Z.jsx)(`button`,{type:`button`,onClick:a,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,Z.jsx)(Jn,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(it,{className:`h-3 w-3`})})]})}function zp(){let e=(0,X.useRef)([]);return{setFieldRef:(0,X.useCallback)(t=>n=>{e.current[t]=n},[]),handleKeyDown:(0,X.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 Bp={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(Bp);var Vp=[{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`}}],Up=Object.fromEntries([...Vp,...Object.values(Bp),...Hp].map(e=>[e.id,e]));function Wp(){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 Gp(){return Object.values(Up).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 Kp=`openai-compatible`,qp=Wp();function Jp({models:e,onChange:t}){let{t:n}=h(),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),g=(0,X.useRef)(void 0),_=(0,X.useRef)(null),v=G(e=>e.wsUrl),y=(0,X.useCallback)(e=>{if(!e.trim()){c([]);return}u(!0);let t=H(v),n=t.on(`provider.models.search_result`,t=>{let n=t.payload;!n||n.query!==e.trim()||(c(n.matches??[]),u(!1))});t.searchProviderModels(e.trim(),8),setTimeout(()=>{n?.(),u(!1)},5e3)},[v]);(0,X.useEffect)(()=>{if(g.current&&clearTimeout(g.current),!a.trim()){c([]);return}return g.current=setTimeout(()=>y(a),250),()=>{g.current&&clearTimeout(g.current)}},[a,y]);let b=(0,X.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]),o(``),c([]),i(!1)},[e,t]),x=(0,X.useCallback)(n=>{t(e.filter(e=>e.id!==n))},[e,t]),S=(0,X.useCallback)(()=>{let e=p.trim();e&&(b(e),m(``),f(!1))},[p,b]);return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:n(`setup:screen.custom.models`)}),e.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:U(`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,Z.jsx)(`span`,{className:`truncate max-w-[120px]`,children:e.name&&e.name!==e.id?e.name:e.id}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>x(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive`,children:(0,Z.jsx)(Jt,{className:`h-3 w-3`})})]},e.id))}),r?(0,Z.jsxs)(`div`,{className:`space-y-2 p-3 rounded border border-border/60 bg-muted/20`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(Ft,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(Vi,{placeholder:n(`setup:screen.custom.modelSearchPlaceholder`),value:a,onChange:e=>o(e.target.value),className:`text-sm pl-8`,autoFocus:!0}),l&&(0,Z.jsx)(Rn,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),s.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1 max-h-40 overflow-y-auto`,children:s.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>b(e.modelId,e),className:U(`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,Z.jsx)(Jn,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`font-medium block truncate`,children:e.name}),(0,Z.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}`))}),!l&&a.trim()&&s.length===0&&(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center py-2`,children:[n(`setup:screen.custom.noCatalogMatch`),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{f(!0),setTimeout(()=>_.current?.focus(),50)},className:`ml-1 text-accent underline underline-offset-2 hover:text-accent/80`,children:n(`setup:screen.custom.useCustomId`)})]}),d&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Vi,{ref:_,placeholder:n(`setup:screen.custom.customModelIdPlaceholder`),value:p,onChange:e=>m(e.target.value),className:`text-sm flex-1`,onKeyDown:e=>{e.key===`Enter`&&S()}}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:S,disabled:!p.trim(),children:[(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.add`)]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2 pt-1`,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{i(!1),o(``),c([]),f(!1),m(``)},className:`text-xs`,children:n(`setup:screen.custom.cancel`)})})]}):(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(!0),className:`text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.addModel`)]}),e.length>0&&(0,Z.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 Yp=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,Z.jsx)(_t,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,Z.jsx)(On,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,Z.jsx)(xe,{className:`h-5 w-5`})}],Xp=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function Zp({ws:e,savedByKind:t}){let{t:n}=h(),[r,i]=(0,X.useState)({chatgpt:{phase:`idle`},claude:{phase:`idle`},copilot:{phase:`idle`}}),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(null);(0,X.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`?(J.success(t.message??z.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),c(null),o(``),u(null),f(``)):t.phase===`error`&&J.error(t.message??z.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let g=(0,X.useCallback)(t=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),_=(0,X.useCallback)((t,n)=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n)},[e]),v=(0,X.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,X.useCallback)(t=>{e.cancelOAuth(t),i(e=>({...e,[t]:{phase:`idle`}})),c(null)},[e]),b=(0,X.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,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-3`,children:(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-warning`,children:n(`settings:oauth.termsWarning`)})}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-3`,children:Yp.map(e=>{let t=r[e.kind],i=Xp.includes(t.phase),h=x[e.kind],S=h?.length??0,C=p===e.kind;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/70 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 lg:flex-col lg:items-stretch`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subtitle})]})]}),i?(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>y(e.kind),className:`shrink-0 lg:w-full`,children:n(`common:action.cancel`)}):(0,Z.jsx)(Y,{size:`sm`,onClick:()=>g(e.kind),className:`shrink-0 lg:w-full`,children:n(`settings:oauth.signIn`)})]}),t.phase===`awaiting_browser`&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(Rn,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.waitingBrowser`)})]}),t.authorizeUrl&&(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.authorizeUrl,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(kn,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openSignIn`)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.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,Z.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Z.jsx)(Vi,{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,Z.jsx)(Y,{size:`sm`,onClick:()=>b(e.kind),disabled:!a.trim(),children:n(`settings:oauth.submit`)})]})]})]}),t.phase===`awaiting_code`&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`settings:oauth.enterCode`)}),(0,Z.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-widest`,children:t.userCode??`…`}),t.verificationUri&&(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(kn,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openVerification`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Rn,{className:`h-3.5 w-3.5 animate-spin`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.waitingCode`)})]})]}),(t.phase===`exchanging`||t.phase===`fetching_models`)&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm`,children:[(0,Z.jsx)(Rn,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{children:t.phase===`exchanging`?n(`settings:oauth.exchanging`):n(`settings:oauth.fetchingModels`)})]}),t.phase===`success`&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-success`,children:[(0,Z.jsx)(R,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:t.message??n(`settings:oauth.signedIn`)})]}),t.phase===`error`&&t.message&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-destructive`,children:[(0,Z.jsx)(kr,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:t.message})]}),S>0&&!i&&(0,Z.jsxs)(`div`,{className:`mt-3 border-t pt-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>m(C?null:e.kind),className:`flex w-full items-center justify-between text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(Sr,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.accountCount`,{count:S})})]}),(0,Z.jsx)(`span`,{className:`text-[10px]`,children:C?`▲`:`▼`})]}),C&&h&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[h.map(t=>(0,Z.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,Z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t.id}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[t.hasActiveKey?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-success`,children:[(0,Z.jsx)(R,{className:`h-3 w-3`}),n(`settings:oauth.active`)]}):(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n(`settings:oauth.inactive`)}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>_(e.kind,t.id),className:`h-6 px-1.5 text-[11px]`,title:n(`settings:oauth.retryLogin`),children:[(0,Z.jsx)(wr,{className:`h-3 w-3 mr-0.5`}),n(`settings:oauth.retry`)]})]})]},t.id)),(0,Z.jsx)(`div`,{className:`pt-1`,children:l===e.kind?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Vi,{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,Z.jsx)(Y,{size:`sm`,onClick:()=>v(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]})]}),S===0&&!i&&(0,Z.jsx)(`div`,{className:`mt-3 border-t pt-3`,children:l===e.kind?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Vi,{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,Z.jsx)(Y,{size:`sm`,onClick:()=>v(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]},e.kind)})})]})}function Qp({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,X.useRef)(null),{t:o}=h();return(0,X.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,Z.jsx)(Bi,{open:e,onOpenChange:e=>{e||i()},children:(0,Z.jsxs)(Li,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,Z.jsxs)(Fi,{children:[(0,Z.jsxs)(Ri,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Pe,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,Z.jsx)(zi,{children:o(`settings:allowlist.body`,{count:n,provider:t})})]}),(0,Z.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,Z.jsxs)(Ii,{className:`gap-2 sm:gap-2 flex-wrap`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:i,title:o(`settings:allowlist.keepTitle`),"data-action":`cancel`,children:[o(`common:action.cancel`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`Esc`})]}),(0,Z.jsxs)(Y,{variant:`destructive`,size:`sm`,onClick:r,title:o(`settings:allowlist.clearTitle`),"data-action":`confirm`,children:[o(`settings:allowlist.clear`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`↵`})]})]})]})})}function $p(){return{inFlight:!1,last:null,picked:null}}function em(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 tm(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 nm(e){return(e?.length??0)>0}function rm(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function im(e){return e.length>0}function am({ws:e,onSelect:t,onClose:n}){let{t:r}=h(),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(null),d=(0,X.useRef)(``);(0,X.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,X.useCallback)(t=>{if(!t.trim()){s([]),d.current=``;return}d.current=t,l(!0),e.searchProviderModels(t,8)},[e]);(0,X.useEffect)(()=>(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>f(i),300),()=>{u.current&&clearTimeout(u.current)}),[i,f]);let p=(0,X.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,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:n,"aria-label":r(`common:action.close`)}),(0,Z.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,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings:providerModels.catalogSearchTitle`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(Jt,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`relative mb-3`,children:[(0,Z.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,Z.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,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(Rn,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):o.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:o.map(e=>(0,Z.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,Z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-sm font-medium text-foreground`,children:e.modelId}),e.name!==e.modelId&&(0,Z.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.name})]}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.providerName})]}),e.description&&(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:[e.contextWindow?(0,Z.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,Z.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,Z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.noResults`)}):(0,Z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.typeToSearch`)})]})]})}var om=new Set([`__proto__`,`constructor`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]),sm=[`text`,`image`,`audio`,`video`,`pdf`],cm=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],lm=ke().int().nonnegative(),um=ke().finite(),dm=x({context:lm.optional(),output:lm.optional(),input:lm.optional()}),fm=x({input:um.optional(),output:um.optional(),cache_read:um.optional(),cache_write:um.optional(),cache_write_5m:um.optional(),cache_write_1h:um.optional(),context_over_200k:um.optional(),reasoning:um.optional(),input_audio:um.optional(),output_audio:um.optional()}),pm=x({input:mr(l().min(1)).optional(),output:mr(l().min(1)).optional()}),mm=mn([x({type:E(`toggle`)}),x({type:E(`effort`),values:mr(_(cm)).optional()}),x({type:E(`budget_tokens`),min:ke().optional(),max:ke().optional()})]),hm=e=>({message:`${e} id is a forbidden prototype-pollution key`}),gm=x({id:l().min(1).refine(e=>!om.has(e),hm(`Model`)),name:l().min(1),description:l().optional(),family:l().optional(),attachment:nt().optional(),reasoning:nt().optional(),reasoning_options:mn([mm,mr(mm)]).optional(),interleaved:mn([nt(),x({field:l().optional()})]).optional(),tool_call:nt().optional(),structured_output:nt().optional(),temperature:nt().optional(),knowledge:l().optional(),release_date:l().optional(),last_updated:l().optional(),open_weights:nt().optional(),modalities:pm.optional(),cost:fm.optional(),limit:dm.optional(),status:l().optional(),experimental:nt().optional()}),_m=x({id:l().min(1).refine(e=>!om.has(e),hm(`Provider`)),name:l().min(1),env:mr(l()).optional(),npm:l().optional(),api:l().optional(),doc:l().optional(),models:vn(l(),gm)});vn(l(),_m);function vm(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 ym(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 bm=[{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 xm({providerId:e,modelId:t,initialModelsDev:n,onSave:r,onCancel:i}){let{t:a}=h(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(()=>vm(t,n)),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(JSON.stringify({...n,...t?{id:t}:{}},null,2)),[m,g]=(0,X.useState)(null),_=(0,X.useCallback)((e,t)=>{l(n=>({...n,[e]:t}))},[]),v=(0,X.useCallback)((e,t)=>{l(n=>{let r=n[e];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),y=(0,X.useCallback)(()=>{let e=ym(c,n),i=gm.safeParse({...e,id:c.id||t});if(!i.success){d(i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`));return}d([]),r(c.id||t,e)},[c,n,t,r]),b=(0,X.useCallback)(()=>{try{let e=JSON.parse(f),n=gm.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))}},[f,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,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 border-b border-border/50`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:U(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,o?`border-transparent text-muted-foreground hover:text-foreground`:`border-primary text-primary`),children:a(`settings:providerModels.tabForm`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:U(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,o?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`),children:a(`settings:providerModels.tabRawJson`)})]}),o?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),rows:16,className:`w-full rounded-md border border-border bg-muted/20 p-2 font-mono text-xs`,spellCheck:!1}),m&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:m})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionIdentity`)}),!t&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-id`,children:`ID`}),(0,Z.jsx)(`input`,{id:`mse-id`,className:x,value:c.id,onChange:e=>_(`id`,e.target.value),placeholder:a(`activity:modelSchema.modelId`)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-name`,children:a(`settings:providerModels.fieldName`)}),(0,Z.jsx)(`input`,{id:`mse-name`,className:x,value:c.name,onChange:e=>_(`name`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-desc`,children:a(`settings:providerModels.fieldDescription`)}),(0,Z.jsx)(`input`,{id:`mse-desc`,className:x,value:c.description,onChange:e=>_(`description`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-family`,children:a(`settings:providerModels.fieldFamily`)}),(0,Z.jsx)(`input`,{id:`mse-family`,className:x,value:c.family,onChange:e=>_(`family`,e.target.value)})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionLimits`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-ctx`,children:a(`settings:providerModels.fieldContext`)}),(0,Z.jsx)(`input`,{id:`mse-ctx`,type:`number`,className:x,value:c.limitContext,onChange:e=>_(`limitContext`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-out`,children:a(`settings:providerModels.fieldOutput`)}),(0,Z.jsx)(`input`,{id:`mse-out`,type:`number`,className:x,value:c.limitOutput,onChange:e=>_(`limitOutput`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-inlim`,children:a(`settings:providerModels.fieldInputLimit`)}),(0,Z.jsx)(`input`,{id:`mse-inlim`,type:`number`,className:x,value:c.limitInput,onChange:e=>_(`limitInput`,e.target.value)})]})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionPricing`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-costin`,children:a(`settings:providerModels.fieldCostInput`)}),(0,Z.jsx)(`input`,{id:`mse-costin`,type:`number`,step:`0.01`,className:x,value:c.costInput,onChange:e=>_(`costInput`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-costout`,children:a(`settings:providerModels.fieldCostOutput`)}),(0,Z.jsx)(`input`,{id:`mse-costout`,type:`number`,step:`0.01`,className:x,value:c.costOutput,onChange:e=>_(`costOutput`,e.target.value)})]})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionModalities`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:S,children:a(`settings:providerModels.fieldInputModalities`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:sm.map(e=>{let t=c.inputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(`inputModalities`,e),className:U(`rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`in-mod-${e}`)})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:S,children:a(`settings:providerModels.fieldOutputModalities`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:sm.map(e=>{let t=c.outputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(`outputModalities`,e),className:U(`rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`out-mod-${e}`)})})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionCapabilities`)}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:bm.map(({key:e,labelKey:t})=>(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 rounded border-border`,checked:c[e],onChange:t=>_(e,t.target.checked)}),a(t)]},String(e)))})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionDates`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-release`,children:a(`settings:providerModels.fieldReleaseDate`)}),(0,Z.jsx)(`input`,{id:`mse-release`,type:`date`,className:x,value:c.releaseDate,onChange:e=>_(`releaseDate`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-updated`,children:a(`settings:providerModels.fieldLastUpdated`)}),(0,Z.jsx)(`input`,{id:`mse-updated`,type:`date`,className:x,value:c.lastUpdated,onChange:e=>_(`lastUpdated`,e.target.value)})]})]})]}),u.length>0&&(0,Z.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-2`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5 text-xs text-destructive`,children:u.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border/50 pt-3`,children:[(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(Jt,{className:`h-3.5 w-3.5`}),a(`common:action.cancel`)]}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:o?b:y,className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`}),a(`common:action.save`)]})]})]})}function Sm(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 Cm(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 wm(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 Tm(e){let t=e?.modalities;return{input:Array.isArray(t?.input)?t.input:[],output:Array.isArray(t?.output)?t.output:[]}}var Em={text:We,image:vr,audio:ce,video:pr,pdf:We};function Dm({providerId:e,models:t,customModels:n,ws:r,pickedModelId:i,onPickModel:a}){let{t:o}=h(),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),g=(0,X.useMemo)(()=>Sm(t,n),[t,n]),_=(0,X.useMemo)(()=>{let e=p.trim().toLowerCase();return e?g.filter(t=>t.modelId.toLowerCase().includes(e)||(t.name?.toLowerCase().includes(e)??!1)):g},[g,p]),v=(0,X.useCallback)(t=>{r.removeCustomModel(e,t),J.success(o(`settings:providerModels.modelRemoved`,{model:t}))},[r,e,o]),y=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),c(null),J.success(o(`settings:providerModels.modelSaved`,{model:t}))},[r,e,o]),b=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),u(!1),J.success(o(`settings:providerModels.modelAdded`,{model:t}))},[r,e,o]);return(0,Z.jsxs)(`div`,{className:`space-y-3`,"data-model-list-editor":e,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>u(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addFromCatalog`)]}),(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>f(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addCustom`)]})]}),g.length>0&&(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/70`,children:[g.length>8&&(0,Z.jsxs)(`div`,{className:`relative border-b border-border/40 bg-muted/10`,children:[(0,Z.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,Z.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:o(`settings:providerModels.filterPlaceholder`),"aria-label":o(`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,Z.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:(0,Z.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-border/70 bg-muted/30 text-left text-[11px] uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colModel`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colContext`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colOutput`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colCost`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colModalities`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colCaps`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colSource`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2`,"aria-label":o(`settings:providerModels.colActions`)})]})}),(0,Z.jsx)(`tbody`,{children:_.map(t=>{let n=Cm(t.modelsDev),r=t.maxOutput??t.modelsDev?.limit?.output,l=typeof r==`number`?r.toLocaleString():void 0,u=wm(t.modelsDev),d=Tm(t.modelsDev),f=t.capabilities,p=s===t.modelId;return(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsxs)(`tr`,{className:`border-b border-border/40 transition-colors hover:bg-muted/20`,children:[(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs font-medium text-foreground`,children:t.modelId}),t.name&&t.name!==t.modelId&&(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t.name})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(Ee,{className:`h-3 w-3`}),n]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:l?(0,Z.jsx)(`span`,{children:l}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs`,children:u.input||u.output?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(zt,{className:`h-3 w-3`}),u.input&&u.output?`${u.input}/${u.output}`:u.input??u.output]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[d.input.map(e=>{let t=Em[e]??We;return(0,Z.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,Z.jsx)(t,{className:`h-2.5 w-2.5`}),e]},`in-${e}`)}),d.output.map(e=>(0,Z.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,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[f?.tools&&(0,Z.jsx)(nn,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.tools`)}),f?.reasoning&&(0,Z.jsx)(cr,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.reasoning`)}),f?.vision&&(0,Z.jsx)(en,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.vision`)})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[a&&(t.modelId===i?(0,Z.jsx)(`span`,{className:`inline-flex items-center rounded p-1 text-primary`,title:o(`settings:providerModels.usingModel`,{model:t.modelId}),role:`img`,"aria-label":o(`settings:providerModels.usingModel`,{model:t.modelId}),children:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`})}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>a(e,t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":o(`settings:providerModels.useModel`,{model:t.modelId}),title:o(`settings:providerModels.useModel`,{model:t.modelId}),children:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`})})),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(p?null:t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":o(`settings:providerModels.editModel`,{model:t.modelId}),children:(0,Z.jsx)(bn,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,"aria-label":o(`settings:providerModels.removeModel`,{model:t.modelId}),children:(0,Z.jsx)(_n,{className:`h-3.5 w-3.5`})})]})})]}),p&&(0,Z.jsx)(`tr`,{className:`border-b border-border/40 bg-muted/10`,children:(0,Z.jsx)(`td`,{colSpan:8,className:`p-3`,children:(0,Z.jsx)(xm,{providerId:e,modelId:t.modelId,initialModelsDev:t.modelsDev??{},onSave:y,onCancel:()=>c(null)})})},`${t.modelId}-edit`)]},t.modelId)})})]})})]}),g.length===0&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/50 p-8 text-center`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`settings:providerModels.emptyState`)})}),l&&(0,Z.jsx)(am,{ws:r,onSelect:b,onClose:()=>u(!1)}),d&&(0,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:()=>f(!1),"aria-label":o(`common:action.close`)}),(0,Z.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,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:o(`settings:providerModels.addCustomTitle`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>f(!1),className:`text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(Jt,{className:`h-4 w-4`})})]}),(0,Z.jsx)(xm,{providerId:e,modelId:``,initialModelsDev:{},onSave:y,onCancel:()=>f(!1)})]})]})]})}function Om(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 km=3e3;function Am({providerId:e,savedPickedModelId:t,savedModels:n,savedCustomModels:r,ws:i,onPickModel:a,onClearModels:o,onUndoClear:s}){let[c,l]=(0,X.useState)(()=>$p()),{t:u}=h(),[d,f]=(0,X.useState)(!1);(0,X.useEffect)(()=>i.on(`provider.probe`,t=>{t.type===`provider.probe`&&t.payload.providerId===e&&l(e=>({...e,inFlight:!1,last:em(t.payload)}))}),[i,e]);let p=(0,X.useCallback)(()=>{l(e=>({...e,inFlight:!0})),i.probeProvider(e,km)},[i,e]),m=(0,X.useCallback)((e,t)=>{l(e=>({...e,picked:t})),a?.(e,t)},[a]),g=(0,X.useCallback)(()=>{f(!0)},[]),_=(0,X.useCallback)(()=>{f(!1)},[]),v=(0,X.useCallback)(()=>{f(!1);let t=n?[...n]:[];l(e=>({...e,picked:null,last:null})),o?o(e):i.clearProviderModels(e),im(t)&&J.undoable(rm(e,t.length),()=>{let n=Om({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]),y=(0,X.useMemo)(()=>c.picked??t??n?.[0]??``,[c.picked,t,n]),b=(0,X.useMemo)(()=>tm(c),[c]),x=(0,X.useMemo)(()=>nm(n),[n]);return(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(tn,{className:`h-3.5 w-3.5`}),u(`activity:providerModels.allowlistTitle`)]}),n&&n.length>0&&(0,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u(`activity:providerModels.using`)}),y?(0,Z.jsx)(`span`,{className:`max-w-full truncate rounded-md bg-primary/10 px-2 py-0.5 font-mono text-xs text-primary`,children:y}):(0,Z.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:u(`activity:providerModels.noModelPicked`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:justify-end`,children:[(0,Z.jsxs)(Y,{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,Z.jsx)(Rn,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(wr,{className:`h-3.5 w-3.5`}),c.inFlight?u(`activity:providerModels.probing`):u(`activity:providerModels.refresh`)]}),x&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:g,"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,Z.jsx)(jm,{formatted:b}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(Dm,{providerId:e,models:n??[],customModels:r,ws:i,pickedModelId:y??void 0,onPickModel:m})}),(0,Z.jsx)(Qp,{open:d,providerId:e,modelCount:n?.length??0,onConfirm:v,onCancel:_})]})}function jm({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,Z.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs ${t}`,"data-probe-tone":e.tone,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${n}`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}var Mm=[`anthropic`,`openai`,`google`,`openai-compatible`];function Nm({activeProvider:e,catalogProviders:t,isLoadingCatalog:n,savedProviders:r,isLoadingSaved:i,providerTab:a,setProviderTab:o,onSelectProvider:s,onAddKey:c,onDeleteKey:l,onSetActiveKey:u,onAddProvider:d,onRemoveProvider:f,onPickProviderModel:p,ws:m,catalogQuery:g,setCatalogQuery:_}){let{t:v}=h(),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(``),[w,T]=(0,X.useState)(``),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(``),[M,ee]=(0,X.useState)(`openai-compatible`),[N,te]=(0,X.useState)(``),[P,F]=(0,X.useState)(``),[I,ne]=(0,X.useState)([]),re=zp(),ie=zp(),L=(0,X.useCallback)(e=>{!S.trim()||!w.trim()||(c(e,S.trim(),w.trim()),C(``),T(``),x(null))},[c,S,w]),ae=(0,X.useCallback)(()=>{A.trim()&&(d(A.trim(),M,N||void 0,P||void 0,I.length>0?I.map(e=>e.id):void 0,I.length>0?Object.fromEntries(I.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(``),ee(`openai-compatible`),te(``),F(``),ne([]),k(!1))},[d,A,M,N,P,I]),oe=(0,X.useCallback)(e=>{j(e.id),ee(Kp),te(e.defaultBaseUrl),e.noAuth&&F(``),ne([])},[]),[se,ce]=(0,X.useState)(null),[le,ue]=(0,X.useState)(``),[de,fe]=(0,X.useState)(!1),[pe,me]=(0,X.useState)({}),he=(0,X.useMemo)(()=>new Set(r.map(e=>e.id)),[r]),ge=(0,X.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,X.useEffect)(()=>{let e=m.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;t.status!==`no_base_url`&&t.status!==`no_provider`&&me(e=>({...e,[t.providerId]:{ok:t.ok,status:t.status,detail:t.detail}}))});return()=>e?.()},[m]);let _e=(0,X.useCallback)(e=>{let t=le.trim();t&&(he.has(e.id)?c(e.id,`default`,t):d(e.id,e.family,e.apiBase??void 0,t),ue(``),ce(null),fe(!1),J.success(v(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>m.probeProvider(e.id,6e3),700))},[le,he,c,d,m]),ve=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,ye=ve.reduce((e,t)=>(e[t.family]||(e[t.family]=[]),e[t.family]?.push(t),e),{});return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Z.jsx)(Vt,{className:`h-4 w-4 text-muted-foreground`}),v(`settings:provider.subscriptionHeading`)]}),(0,Z.jsx)(Zp,{ws:m,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,Z.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-1 flex items-center gap-2`,children:[(0,Z.jsx)(gn,{className:`h-4 w-4 text-muted-foreground`}),v(`settings:provider.apiKeysHeading`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:v(`settings:provider.apiKeysBody`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,Z.jsxs)(Y,{variant:a===`catalog`?`default`:`outline`,size:`sm`,onClick:()=>o(`catalog`),children:[(0,Z.jsx)(gn,{className:`h-4 w-4 mr-1`}),v(`settings:provider.tabCatalog`)]}),(0,Z.jsxs)(Y,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>o(`saved`),children:[(0,Z.jsx)(Vt,{className:`h-4 w-4 mr-1`}),v(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Vi,{placeholder:v(`settings:provider.searchPlaceholder`,{count:t.length}),value:g,onChange:e=>_(e.target.value),className:`text-sm`}),n&&t.length===0?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(Rn,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:v(`settings:provider.loadingCatalog`)})]}):ve.length===0&&g?(0,Z.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:v(`settings:provider.noMatch`,{query:g})}):Mm.map(t=>{let n=ye[t];return n?.length?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider`,children:t}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:n.map(t=>{let n=pe[t.id],r=e===t.id;return(0,Z.jsxs)(`div`,{className:U(`rounded-lg border transition-all`,r?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border`),children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(t.id),className:U(`flex w-full flex-col items-start p-3 text-left rounded-lg`,!r&&`hover:bg-muted`),children:[(0,Z.jsxs)(`div`,{className:`flex w-full justify-between items-start`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.name}),(0,Z.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.hasApiKey&&(0,Z.jsxs)(`span`,{className:`text-xs bg-success/10 text-success px-2 py-0.5 rounded`,children:[(0,Z.jsx)(Vt,{className:`h-3 w-3 inline mr-1`}),v(`settings:provider.configured`)]}),n&&(0,Z.jsxs)(`span`,{className:U(`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,Z.jsx)(R,{className:`h-3 w-3`}):(0,Z.jsx)(kr,{className:`h-3 w-3`}),n.ok?v(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,Z.jsx)(R,{className:`h-4 w-4 text-primary`})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[v(`settings:provider.modelCount`,{count:t.modelCount}),t.apiBase&&` · ${t.apiBase}`]})]}),r&&!t.hasApiKey&&(0,Z.jsx)(`div`,{className:`px-3 pb-3 -mt-1 space-y-2`,children:se===t.id?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Vi,{autoFocus:!0,type:de?`text`:`password`,placeholder:v(`settings:provider.keyPlaceholder`,{name:t.name}),value:le,onChange:e=>ue(e.target.value),className:`text-sm`,onKeyDown:e=>{e.key===`Enter`&&_e(t)}}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>fe(e=>!e),children:de?(0,Z.jsx)(Bn,{className:`h-4 w-4`}):(0,Z.jsx)(en,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>_e(t),disabled:!le.trim(),children:v(`common:action.save`)})]}),t.envVars[0]&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>{ce(t.id),ue(``)},children:[(0,Z.jsx)(Vt,{className:`h-3.5 w-3.5 mr-1`}),v(`settings:provider.addApiKey`)]})})]},t.id)})})]},t):null})]}),a===`saved`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:v(`settings:provider.manageKeys`)}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(Pn,{className:`h-3.5 w-3.5`}),v(`settings:provider.savedProviderCount`,{count:r.length})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(Vt,{className:`h-3.5 w-3.5`}),v(`settings:provider.keyCount`,{count:ge.keys})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(At,{className:`h-3.5 w-3.5`}),v(`settings:provider.activeKeyCount`,{count:ge.activeKeys})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),v(`settings:provider.modelCount`,{count:ge.models})]})]})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>k(!O),children:[(0,Z.jsx)(at,{className:`h-4 w-4 mr-1`}),v(`settings:provider.addProvider`)]})]}),O&&(0,Z.jsxs)(`div`,{className:`p-4 border rounded-lg space-y-3 bg-muted/50`,children:[(0,Z.jsx)(`h4`,{className:`font-medium`,children:v(`settings:provider.addCustomHeading`)}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.localServers`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:qp.map(e=>(0,Z.jsx)(Y,{type:`button`,size:`sm`,variant:A===e.id?`default`:`outline`,onClick:()=>oe(e),title:e.hint,children:e.label},e.id))})]}),(0,Z.jsx)(Vi,{placeholder:v(`settings:provider.providerIdPlaceholder`),value:A,onChange:e=>j(e.target.value),ref:re.setFieldRef(0),onKeyDown:e=>re.handleKeyDown(e,0)}),(0,Z.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=>ee(e.target.value),ref:re.setFieldRef(1),onKeyDown:e=>re.handleKeyDown(e,1),children:[(0,Z.jsx)(`option`,{value:`anthropic`,children:v(`activity:provider.anthropic`)}),(0,Z.jsx)(`option`,{value:`openai`,children:v(`activity:provider.openai`)}),(0,Z.jsx)(`option`,{value:`openai-compatible`,children:v(`activity:provider.openaiCompatible`)}),(0,Z.jsx)(`option`,{value:`google`,children:v(`activity:provider.google`)})]}),(0,Z.jsx)(Vi,{placeholder:v(`activity:provider.baseUrlOptionalEGHttpLocalhost11434V1`),value:N,onChange:e=>te(e.target.value),ref:re.setFieldRef(2),onKeyDown:e=>re.handleKeyDown(e,2)}),(0,Z.jsx)(Vi,{type:`password`,placeholder:v(`settings:provider.apiKeyOptionalPlaceholder`),value:P,onChange:e=>F(e.target.value),ref:re.setFieldRef(3),onKeyDown:e=>re.handleKeyDown(e,3)}),(0,Z.jsx)(Jp,{models:I,onChange:ne}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:ae,disabled:!A.trim(),ref:re.setFieldRef(4),onKeyDown:e=>re.handleKeyDown(e,4,ae),children:v(`common:action.add`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>k(!1),ref:re.setFieldRef(5),onKeyDown:e=>re.handleKeyDown(e,5),children:v(`common:action.cancel`)})]})]}),i?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(Rn,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r.length===0?(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Vt,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:v(`settings:provider.noSaved`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:v(`settings:provider.noSavedHint`)})]}):r.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/80 bg-card/70 p-4 shadow-sm shadow-black/[0.02]`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-foreground`,children:e.id}),e.family&&(0,Z.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,Z.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,Z.jsx)(At,{className:`h-3 w-3`}),v(`settings:provider.active`)]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[e.baseUrl&&(0,Z.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,Z.jsx)(gn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.baseUrl})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),v(`settings:provider.modelCount`,{count:e.models?.length??0})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Z.jsx)(Vt,{className:`h-3.5 w-3.5`}),v(`settings:provider.keyCount`,{count:e.apiKeys.length})]})]})]}),(0,Z.jsx)(`div`,{className:`flex gap-2 sm:justify-end`,children:(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>f(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,Z.jsx)(_n,{className:`h-4 w-4 text-destructive`})})})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.85fr)]`,children:[(0,Z.jsx)(Am,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,savedCustomModels:e.customModels,ws:m,onPickModel:p}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:v(`settings:provider.apiKeysLabel`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>x(b===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),v(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!b&&(0,Z.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:v(`settings:provider.noKeys`)}),e.apiKeys.length>0&&(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.apiKeys.map(t=>(0,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Z.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,Z.jsx)(Vt,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),t.isActive&&(0,Z.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:v(`settings:provider.active`)})]}),(0,Z.jsx)(`div`,{className:`mt-0.5`,children:(0,Z.jsx)(Rp,{maskedKey:t.maskedKey})})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!t.isActive&&(0,Z.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.id,t.label),className:`h-8 px-2 text-xs`,children:v(`settings:provider.setActive`)}),(0,Z.jsx)(Y,{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,Z.jsx)(_n,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),b===e.id&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-border/70 bg-background p-3`,children:[(0,Z.jsx)(Vi,{placeholder:v(`settings:provider.keyLabelPlaceholder`),value:S,onChange:e=>C(e.target.value),ref:ie.setFieldRef(0),onKeyDown:e=>ie.handleKeyDown(e,0)}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Vi,{type:E?`text`:`password`,placeholder:v(`settings:provider.apiKeyPlaceholder`),value:w,onChange:e=>T(e.target.value),ref:ie.setFieldRef(1),onKeyDown:e=>ie.handleKeyDown(e,1)}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>D(!E),children:E?(0,Z.jsx)(Bn,{className:`h-4 w-4`}):(0,Z.jsx)(en,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:()=>L(e.id),disabled:!S.trim()||!w.trim(),ref:ie.setFieldRef(2),onKeyDown:t=>ie.handleKeyDown(t,2,()=>L(e.id)),children:v(`settings:provider.saveKey`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{x(null),C(``),T(``)},ref:ie.setFieldRef(3),onKeyDown:e=>ie.handleKeyDown(e,3),children:v(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var Pm=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}))})),Fm=Pm.map(e=>e.phase),Im=Pm.flatMap(e=>[...e.roles]),Lm=Im.map(e=>e.role),Rm=[`*`,...Fm,...Lm];function zm(e){if(e===`*`)return`Default (*)`;let t=Pm.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=Im.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var Bm=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],Vm=[{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`}],Um=new Set(Rm);function Wm(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 Gm(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 Km({syncPref:e,candidates:t}){let n=B(),{t:r}=h(),[i,a]=(0,X.useState)(`*`),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(``),m=(0,X.useCallback)(t=>e(`modelMatrix`,t),[e]),g=(0,X.useCallback)(()=>{let e=i.trim(),t=o.trim(),r=Wm(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]),_=(0,X.useCallback)(e=>{let{[e]:t,...r}=n.modelMatrix;m(r)},[n.modelMatrix,m]),v=(0,X.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]),y=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}`:``,...Gm(n)].filter(Boolean).join(` + `)},b=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!Um.has(e)))).sort((e,t)=>e.localeCompare(t));return(0,Z.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Z.jsx)(fr,{className:`h-4 w-4 text-muted-foreground`}),r(`settings:agent.routingHeading`)]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,180px)_1fr_auto]`,children:[(0,Z.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,Z.jsx)(`option`,{value:`*`,children:zm(`*`)}),(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:Pm.map(e=>(0,Z.jsx)(`option`,{value:e.phase,children:zm(e.phase)},e.phase))}),Pm.map(e=>(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingRolesGroup`,{label:e.label}),children:e.roles.map(e=>(0,Z.jsx)(`option`,{value:e.role,children:zm(e.role)},e.role))},e.phase)),b.length>0?(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingCustomGroup`),children:b.map(e=>(0,Z.jsx)(`option`,{value:e,children:zm(e)},e))}):null]}),(0,Z.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,Z.jsx)(`option`,{value:``,children:r(`settings:agent.routingTargetEmpty`)}),Object.keys(n.fallbackProfiles).length>0&&(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetProfilesGroup`),children:Object.keys(n.fallbackProfiles).map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),t&&t.length>0&&(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetModelsGroup`),children:t.map(e=>(0,Z.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.provider,`/`,e.model]},`${e.provider}/${e.model}`))})]}),(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:g,children:r(`settings:agent.routingSet`)})]}),(0,Z.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Z.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:Bm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Vm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:Object.keys(n.modelMatrix).length===0?(0,Z.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,Z.jsxs)(`div`,{className:`rounded-md border border-border bg-muted px-2 py-1.5 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-40 shrink-0 truncate font-mono text-muted-foreground`,title:e,children:zm(e)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:y(t)}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>_(e),children:r(`common:action.remove`)})]}),(0,Z.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeFor`,{key:e}),value:t.modelRuntime?.reasoning?.mode??``,onChange:t=>v(e,`mode`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:Bm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortFor`,{key:e}),value:t.modelRuntime?.reasoning?.effort??``,onChange:t=>v(e,`effort`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:Vm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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=>v(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,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}var qm=[`off`,`low`,`medium`,`high`,`all`],Jm={off:`bg-muted-foreground`,low:`bg-success`,medium:`bg-warning`,high:`bg-warning ring-2 ring-warning/25`,all:`bg-destructive`},Ym={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`},Xm=[`executor`,`skeptic`,`auditor`];function Zm(e){return e&&e.length>0?e.map(e=>({id:e.id,name:e.name,description:e.description})):Xm.map(e=>({id:e,name:e}))}var Qm=[{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`}],$m=[{value:`off`,labelKey:`settings:brainOpt.waitForever`},{value:`30000`,label:`30s`},{value:`60000`,label:`1m`},{value:`120000`,label:`2m`},{value:`300000`,label:`5m`}],eh=[{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`}],th=[{value:`100`,label:`100`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],nh=[{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`}],rh=[{value:`10`,label:`10`},{value:`20`,labelKey:`settings:brainOpt.n20Default`},{value:`50`,label:`50`},{value:`100`,label:`100`}],ih=[{value:`60000`,label:`1m`},{value:`300000`,labelKey:`settings:brainOpt.m5Default`},{value:`900000`,label:`15m`},{value:`3600000`,label:`1h`}],ah=[{value:`50`,label:`50`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`}],oh=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],sh=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.oneSerial`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],ch=[{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`}],lh=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`200`,label:`200`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],uh=[{value:`default`,labelKey:`settings:brainOpt.default500`},{value:`100`,label:`100`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`5000`,label:`5000`}],dh=[{value:`default`,labelKey:`settings:brainOpt.default10m`},{value:`120000`,label:`2m`},{value:`600000`,label:`10m`},{value:`1800000`,label:`30m`},{value:`3600000`,label:`1h`}];function fh(e,t){return e.some(e=>e.value===t)?e:[...e,{value:t,label:t}]}function ph(e,t){return e.map(e=>({value:e.value,label:e.labelKey?t(e.labelKey):e.label??e.value}))}function mh(e){return e===void 0?`default`:String(e)}function hh({level:e}){return(0,Z.jsx)(`span`,{className:U(`inline-block h-2.5 w-2.5 rounded-full`,Jm[e])})}function gh(e){return e.provider?`${e.provider}/${e.model}`:e.model}var _h={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 vh(){let{t:e}=h(),{client:t}=Hr(),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!0),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null);(0,X.useEffect)(()=>{t.send({type:`brain.status`}),t.send({type:`brain.config.get`})},[t]),(0,X.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,X.useCallback)(e=>{l(!0),t.send({type:`brain.config.set`,payload:{patch:e}})},[t]),g=(0,X.useCallback)(e=>{r(t=>t&&{...t,maxAutoRisk:e}),m({maxAutoRisk:e})},[m]),_=(0,X.useMemo)(()=>n?.council.voters??[],[n]),v=(0,X.useCallback)(e=>{m({council:{voters:e.length>0?e:null}})},[m]),y=(0,X.useMemo)(()=>Zm(n?.personaCatalog),[n?.personaCatalog]),b=qm.includes(n?.maxAutoRisk??``)?n?.maxAutoRisk??`medium`:`medium`,x=(0,X.useCallback)(e=>{if(!n||!f)return;let t=`${e.provider}/${e.model}`;if(f===`pool`){m({models:[...n.models.map(gh),t]});return}if(f===`judge`){m({council:{judge:t}});return}return v([..._,{provider:e.provider,model:e.model,persona:y[_.length%y.length]?.id??`executor`}]),!0},[n,y,f,m,v,_]);return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Wf,{open:f!==null,mode:`provider-model`,title:f?e(_h[f].title):``,hint:f?e(_h[f].hint):void 0,onPick:e=>{if(e.type===`provider-model`)return x(e)},onClose:()=>p(null)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.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,Z.jsx)(cr,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`settings:brain.heading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.headingHint`)})]}),(o||c)&&(0,Z.jsx)(Rn,{className:`ml-auto h-4 w-4 animate-spin text-muted-foreground`})]}),u&&(0,Z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:u}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.riskHeading`)}),(0,Z.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:qm.map(e=>(0,Z.jsxs)(Y,{variant:b===e?`default`:`outline`,size:`sm`,className:U(`gap-1.5 text-xs`,b===e&&`shadow-sm`),disabled:c,onClick:()=>g(e),children:[(0,Z.jsx)(hh,{level:e}),e.toUpperCase()]},e))}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(Ym[b])})]}),n&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.escalationHeading`)}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.escalationDecisionTimeoutLabel`),hint:e(`settings:brain.escalationDecisionTimeoutHint`),value:n.decisionTimeoutMs?String(n.decisionTimeoutMs):`default`,options:ph(Qm,e),onChange:e=>m({decisionTimeoutMs:e==="default"?null:Number(e)}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationHumanTimeoutLabel`),hint:e(`settings:brain.escalationHumanTimeoutHint`),value:n.humanTimeoutMs?String(n.humanTimeoutMs):`off`,options:ph($m,e),onChange:e=>m({humanTimeoutMs:e===`off`?null:Number(e)}),disabled:c}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.escalationDecisionLogSizeLabel`),hint:e(`settings:brain.escalationDecisionLogSizeHint`),value:String(n.decisionLogMaxEntries),options:ph(fh(rh,String(n.decisionLogMaxEntries)),e),onChange:e=>m({decisionLogMaxEntries:Number(e)}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.rulesHeading`)}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.rulesConfigured`,{count:n.rules.length})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.rulesBody`)}),n.rules.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:n.rules.map((t,n)=>(0,Z.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,Z.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[n+1,`.`]}),(0,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:t.id}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px] shrink-0`,children:t.then.action}),t.enabled===!1&&(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px] shrink-0`,children:e(`settings:brain.rulesOff`)})]},`${t.id}-${n}`))}),n.ruleErrors.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-warning`,children:e(`settings:brain.rulesDropped`,{count:n.ruleErrors.length})}),n.ruleErrors.map(e=>(0,Z.jsx)(`p`,{className:`text-xs text-warning`,children:e},e))]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.heuristicsHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsBody`)}),(0,Z.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,Z.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,Z.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,Z.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,Z.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,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsMarkers`,{markers:n.heuristics.blockedResolvedMarkers.join(`, `)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.qualityHeading`)}),n.circuit&&(0,Z.jsx)(Ep,{variant:n.circuit.state===`closed`?`outline`:`default`,className:`text-[10px]`,children:e(`settings:brain.qualityCircuit`,{state:n.circuit.state,count:n.circuit.consecutiveFailures})})]}),(0,Z.jsx)(Q,{label:e(`settings:brain.qualityResponseBudgetLabel`),hint:e(`settings:brain.qualityResponseBudgetHint`),value:String(n.llm.maxTokens),options:ph(fh(th,String(n.llm.maxTokens)),e),onChange:e=>m({llm:{maxTokens:Number(e)}}),disabled:c}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.qualityMinConfidenceLabel`),hint:e(`settings:brain.qualityMinConfidenceHint`),value:String(n.llm.minConfidence),options:ph(fh(nh,String(n.llm.minConfidence)),e),onChange:e=>m({llm:{minConfidence:Number(e)}}),disabled:c}),(0,Z.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,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.traceHeading`)}),(0,Z.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,Z.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,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.trace.path})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.cacheHeading`)}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.cacheStats`,{hits:n.cache.hits,misses:n.cache.misses,size:n.cache.size})})]}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.cacheLifetimeLabel`),hint:e(`settings:brain.cacheLifetimeHint`),value:String(n.cache.ttlMs),options:ph(fh(ih,String(n.cache.ttlMs)),e),onChange:e=>m({cache:{ttlMs:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.cacheMaxEntriesLabel`),hint:e(`settings:brain.cacheMaxEntriesHint`),value:String(n.cache.maxEntries),options:ph(fh(ah,String(n.cache.maxEntries)),e),onChange:e=>m({cache:{maxEntries:Number(e)}}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.monitorHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.monitorBody`)}),(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.modelsHeading`)}),(0,Z.jsx)(Ep,{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,Z.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,Z.jsx)(`div`,{className:`space-y-1`,children:n.models.map((e,t)=>(0,Z.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,Z.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[t+1,`.`]}),(0,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:gh(e)}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===0,onClick:()=>{let e=n.models.map(gh),r=e.splice(t,1)[0];r&&e.splice(t-1,0,r),m({models:e})},children:(0,Z.jsx)(Rt,{className:`h-3 w-3`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===n.models.length-1,onClick:()=>{let e=n.models.map(gh),r=e.splice(t,1)[0];r&&e.splice(t+1,0,r),m({models:e})},children:(0,Z.jsx)(S,{className:`h-3 w-3`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>{let e=n.models.map(gh).filter((e,n)=>n!==t);m({models:e.length>0?e:null})},children:(0,Z.jsx)(Jt,{className:`h-3 w-3`})})]},`${gh(e)}-${t}`))}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`pool`),children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.modelsAddModel`)]}),n.models.length>1&&(0,Z.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,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.councilHeading`)}),(0,Z.jsx)(Ep,{variant:n.council.enabled?`default`:`outline`,className:`text-[10px]`,children:n.council.enabled?e(`settings:brain.councilConvened`):e(`settings:brain.councilDisabled`)})]}),(0,Z.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&&_.length===0&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.councilSeatsDerived`,{seats:n.councilLabels.join(`, `)})}),_.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:_.map((t,n)=>(0,Z.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,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:gh(t)}),(0,Z.jsxs)(`select`,{value:t.persona??y[n%y.length]?.id??``,onChange:e=>v(_.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,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)),t.persona&&!y.some(e=>e.id===t.persona)&&(0,Z.jsx)(`option`,{value:t.persona,children:e(`settings:brain.councilCustomOption`,{persona:t.persona})})]}),(0,Z.jsx)(Y,{variant:t.veto?`default`:`outline`,size:`sm`,className:`h-6 px-1.5 text-[10px]`,disabled:c,onClick:()=>v(_.map((e,t)=>t===n?{...e,veto:!e.veto}:e)),children:e(`settings:brain.councilVeto`)}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>v(_.filter((e,t)=>t!==n)),children:(0,Z.jsx)(Jt,{className:`h-3 w-3`})})]},`${gh(t)}-${n}`))}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`voter`),children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.councilAddVoter`)]}),(0,Z.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,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium`,children:e(`settings:brain.councilJudge`)}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`settings:brain.councilJudgeDesc`)}),!n.council.judge&&n.judgeLabel&&(0,Z.jsxs)(`div`,{className:`mt-0.5 font-mono text-xs text-muted-foreground`,children:[e(`settings:brain.councilResolved`,{model:n.judgeLabel}),n.judgeIsVoter&&(0,Z.jsx)(`span`,{className:`ml-1 font-sans text-warning`,children:e(`settings:brain.councilAlsoVoter`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`max-w-[180px] truncate font-mono text-xs`,children:n.council.judge?gh(n.council.judge):e(`settings:brain.councilAuto`)}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>p(`judge`),children:e(`settings:brain.councilPick`)}),n.council.judge&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>m({council:{judge:null}}),children:e(`settings:brain.councilAutoReset`)})]})]}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilQuorumLabel`),hint:e(`settings:brain.councilQuorumHint`),value:n.council.quorum===void 0?`default`:String(n.council.quorum),options:ph(eh,e),onChange:e=>m({council:{quorum:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilApprovalLabel`),hint:e(`settings:brain.councilApprovalHint`),value:n.council.approval===void 0?`default`:String(n.council.approval),options:ph(eh,e),onChange:e=>m({council:{approval:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilPerSeatTimeoutLabel`),hint:e(`settings:brain.councilPerSeatTimeoutHint`),value:mh(n.council.perCallTimeoutMs),options:ph(fh(oh,mh(n.council.perCallTimeoutMs)),e),onChange:e=>m({council:{perCallTimeoutMs:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilMaxConcurrencyLabel`),hint:e(`settings:brain.councilMaxConcurrencyHint`),value:mh(n.council.maxConcurrency),options:ph(fh(sh,mh(n.council.maxConcurrency)),e),onChange:e=>m({council:{maxConcurrency:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.councilVoterBudgetLabel`),hint:e(`settings:brain.councilVoterBudgetHint`),value:mh(n.council.voterMaxTokens),options:ph(fh(ch,mh(n.council.voterMaxTokens)),e),onChange:e=>m({council:{voterMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilJudgeBudgetLabel`),hint:e(`settings:brain.councilJudgeBudgetHint`),value:mh(n.council.judgeMaxTokens),options:ph(fh(lh,mh(n.council.judgeMaxTokens)),e),onChange:e=>m({council:{judgeMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),n.council.seats.length>0&&(0,Z.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,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.ledgerHeading`)}),(0,Z.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,Z.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,Z.jsx)(Q,{label:e(`settings:brain.ledgerMemoryEntriesLabel`),hint:e(`settings:brain.ledgerMemoryEntriesHint`),value:mh(n.ledger.maxMemoryEntries),options:ph(fh(uh,mh(n.ledger.maxMemoryEntries)),e),onChange:e=>m({ledger:{maxMemoryEntries:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.ledgerRetryWindowLabel`),hint:e(`settings:brain.ledgerRetryWindowHint`),value:mh(n.ledger.interventionRetryWindowMs),options:ph(fh(dh,mh(n.ledger.interventionRetryWindowMs)),e),onChange:e=>m({ledger:{interventionRetryWindowMs:e==="default"?null:Number(e)}}),disabled:c}),n.ledger.path&&(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.ledger.path})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.recentHeading`,{count:i.length})}),(0,Z.jsx)(`div`,{className:`space-y-1 max-h-[300px] overflow-y-auto`,children:i.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground py-2`,children:e(`settings:brain.recentEmpty`)}):i.map(e=>(0,Z.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,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-8`,children:e.age}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px] shrink-0`,children:e.kind}),(0,Z.jsx)(`span`,{className:`flex-1 truncate`,children:e.question}),e.outcome&&(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 italic`,children:e.outcome})]},`${e.age}-${e.kind}-${e.question.slice(0,32)}`))})]})]})}function yh(){let{t:e}=h();return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(en,{className:`h-5 w-5 text-info`}),(0,Z.jsx)(`h3`,{className:`text-lg font-semibold`,children:e(`activity:shadow.shadowAgent`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`activity:shadow.theShadowAgentMonitorsAllFleet`)}),(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Start and stop it from the chat with`,` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow start`}),` and`,` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow stop`}),`. This panel cannot control it yet.`]})]})}function bh({disabled:e,direct:t}){let n=e?`bg-muted-foreground`:t?`bg-success`:`bg-info`,r=e?`disabled`:t?`direct provider tool`:`lazy catalog tool`;return(0,Z.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full ${n}`,title:r})}function xh({tool:e,onToggle:t,busy:n}){let{t:r}=h(),[i,a]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,Z.jsx)(bh,{disabled:e.disabled,direct:e.direct}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`code`,{className:`block truncate text-sm font-mono font-semibold`,title:e.name,children:e.name}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(Ep,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,Z.jsx)(Ep,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,Z.jsx)(Ep,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.disabled?`disabled`:e.direct?`direct`:`lazy`}),(0,Z.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:e.owner,children:e.owner})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[(0,Z.jsxs)(Y,{variant:e.disabled?`default`:`secondary`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:t,disabled:n,children:[n?(0,Z.jsx)(Rn,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,Z.jsx)(_r,{className:`h-3 w-3`}):(0,Z.jsx)(b,{className:`h-3 w-3`}),e.disabled?`Enable`:`Disable`]}),(0,Z.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,Z.jsx)(Nn,{className:`h-4 w-4 transition-transform ${i?`rotate-180`:``}`})})]})]}),i&&(0,Z.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2 text-xs text-muted-foreground sm:ml-4`,children:[(0,Z.jsx)(`p`,{children:e.description}),e.params.length>0&&(0,Z.jsxs)(`p`,{children:[r(`activity:toolsSec.params`),` `,(0,Z.jsx)(`code`,{className:`break-all font-mono`,children:e.params.join(`, `)})]})]})]})}function Sh(){let{t:e}=h(),{client:t}=Hr(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(new Set);(0,X.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}):J.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,X.useEffect)(()=>{t.send({type:`tools.list`},{echoToChat:!1})},[t]);let u=(0,X.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&&e.direct).length,p=n.filter(e=>!e.disabled&&!e.direct).length,m=n.filter(e=>e.disabled).length;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.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,Z.jsx)(nn,{className:`h-5 w-5`})}),(0,Z.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`activity:toolsSec.tools`)})]}),!i&&(0,Z.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,` direct · `,p,` lazy · `,m,` disabled · `,n.length,` `,`total`]})]}),(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(Ft,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Vi,{placeholder:e(`activity:toolsSec.filterToolsByNameOrOwner`),value:o,onChange:e=>s(e.target.value),className:`pl-8 h-9 text-sm`})]}),i?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground gap-2`,children:[(0,Z.jsx)(Rn,{className:`h-4 w-4 animate-spin`}),e(`activity:toolsSec.loadingTools`)]}):d.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:o?`No tools matching "${o}".`:`No tools registered.`}):(0,Z.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border/70 bg-background/35 shadow-inner`,children:[(0,Z.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,Z.jsx)(`li`,{children:(0,Z.jsx)(xh,{tool:e,onToggle:()=>u(e.name,e.disabled),busy:c.has(e.name)})},e.name))}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-4 bg-gradient-to-b from-background/90 to-transparent`}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-background/95 to-transparent`})]})]})}function Ch(){let{t:e}=h();return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.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,Z.jsx)(en,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.brainHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.brainHint`)})]})]}),(0,Z.jsx)(vh,{})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.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,Z.jsx)(en,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.shadowHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.shadowHint`)})]})]}),(0,Z.jsx)(yh,{})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.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,Z.jsx)(en,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.toolsHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.toolsHint`)})]})]}),(0,Z.jsx)(Sh,{})]})]})}var wh=[{id:`general`,icon:(0,Z.jsx)(Je,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.general`,descKey:`settings:tabs.generalDesc`},{id:`provider`,icon:(0,Z.jsx)(ft,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.provider`,descKey:`settings:tabs.providerDesc`},{id:`connection`,icon:(0,Z.jsx)(gn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.connection`,descKey:`settings:tabs.connectionDesc`},{id:`agent`,icon:(0,Z.jsx)(On,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.agent`,descKey:`settings:tabs.agentDesc`},{id:`execution`,icon:(0,Z.jsx)(lr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.execution`,descKey:`settings:tabs.executionDesc`},{id:`fallbacks`,icon:(0,Z.jsx)(fr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fallbacks`,descKey:`settings:tabs.fallbacksDesc`},{id:`routing`,icon:(0,Z.jsx)(En,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.routing`,descKey:`settings:tabs.routingDesc`},{id:`fleet`,icon:(0,Z.jsx)(Bt,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fleet`,descKey:`settings:tabs.fleetDesc`},{id:`integrations`,icon:(0,Z.jsx)($e,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.integrations`,descKey:`settings:tabs.integrationsDesc`},{id:`chimera`,icon:(0,Z.jsx)(cr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.chimera`,descKey:`settings:tabs.chimeraDesc`},{id:`context`,icon:(0,Z.jsx)(We,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.context`,descKey:`settings:tabs.contextDesc`},{id:`logs`,icon:(0,Z.jsx)(Cn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.logs`,descKey:`settings:tabs.logsDesc`},{id:`security`,icon:(0,Z.jsx)(qn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.security`,descKey:`settings:tabs.securityDesc`},{id:`display`,icon:(0,Z.jsx)(Je,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.display`,descKey:`settings:tabs.displayDesc`}];function Th(){let{settingsActiveTab:e,setSettingsActiveTab:t}=K(he(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),n=Sf(`settings`),r=(0,X.useRef)(!1),[i,a]=(0,X.useState)(!1),{provider:o,model:s,setProvider:c,setModel:l,wsConnected:u}=G(he(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),d=Hr(),f=d.client,{updatePrefs:p,switchAutonomy:m}=d,g=B(),{t:_}=h(),v=Yi(!0),b=(0,X.useCallback)((e,t)=>{g.set({[e]:t}),p({[e]:t})},[g,p]),[x,S]=(0,X.useState)([]),[C,w]=(0,X.useState)({}),[T,E]=(0,X.useState)([]),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[ee,N]=(0,X.useState)(`catalog`),[te,P]=(0,X.useState)(``),[F,I]=(0,X.useState)(!1),ne=(0,X.useCallback)(()=>{g.reset(),I(!1),window.location.reload()},[g]),re=x.find(e=>e.id===o),ie=wh.find(t=>t.id===e);(0,X.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;S(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),O(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;w(e=>({...e,[t.provider]:t.models})),A(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));E(t),M(!1),t.length>0&&N(`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 O(!0),M(!0),f.listProviders(),f.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[u,f]);let L=(0,X.useCallback)(e=>{c(e),C[e]||(A(!0),d.listProviderModels?.(e))},[C,c,d]),ae=(0,X.useCallback)(async e=>{if(r.current)return;let t=G.getState().model,n=G.getState().provider;if(!(!n||e===t)){r.current=!0,a(!0),l(e);try{J.info(z.t(`settings:toast.switchingTo`,{provider:n,model:e}));let r=await d.switchModel?.(n,e);r?.success?J.success(z.t(r.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${n} / ${t}`,to:`${n} / ${e}`})):(l(t),J.error(r?.message??z.t(`settings:toast.modelSwitchTimeout`)))}finally{r.current=!1,a(!1)}}},[l,d]),oe=(0,X.useCallback)((e,t,n)=>{d.addKey?.(e,t,n)},[d]),se=(0,X.useCallback)((e,t)=>{d.deleteKey?.(e,t)},[d]),R=(0,X.useCallback)((e,t)=>{d.setActiveKey?.(e,t)},[d]),ce=(0,X.useCallback)((e,t,n,r,i,a)=>{d.addProvider?.(e,t,n,r,i,a)},[d]),le=(0,X.useCallback)(e=>{d.removeProvider?.(e)},[d]),ue=(0,X.useCallback)((e,t)=>{d.client.updateProvider({id:e,models:[t]}),e===G.getState().provider&&l(t)},[l,d.client]);return(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.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,Z.jsx)(Xn,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold bg-gradient-to-r from-foreground to-foreground/70 bg-clip-text text-transparent`,children:_(`settings:title`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:o&&s?`${o} / ${s}`:_(`settings:subtitle`)})]})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:()=>q(`chat`),children:(0,Z.jsx)(Jt,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>I(!0),children:_(`settings:resetLabel`)})]}),(0,Z.jsx)(Xa,{className:`min-h-0 flex-1`,ref:n,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-7xl p-4 sm:p-6`,children:(0,Z.jsxs)(Qa,{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,Z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Z.jsx)($a,{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:wh.map(e=>(0,Z.jsxs)(eo,{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,Z.jsx)(`span`,{className:`shrink-0`,children:e.icon}),(0,Z.jsx)(`span`,{className:`truncate`,children:_(e.labelKey)})]},e.id))}),(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`min-w-0 space-y-0`,children:[ie?.descKey&&(0,Z.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,Z.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:ie.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold`,children:_(ie.labelKey)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:_(ie.descKey)})]})]}),(0,Z.jsx)(to,{value:`general`,className:`mt-0`,children:(0,Z.jsx)(np,{})}),(0,Z.jsxs)(to,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,Z.jsx)(Nm,{activeProvider:o,catalogProviders:x,isLoadingCatalog:D,savedProviders:T,isLoadingSaved:j,providerTab:ee,setProviderTab:N,onSelectProvider:L,onAddKey:oe,onDeleteKey:se,onSetActiveKey:R,onAddProvider:ce,onRemoveProvider:le,onPickProviderModel:ue,ws:d.client,catalogQuery:te,setCatalogQuery:P}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-4 flex items-center gap-2`,children:[(0,Z.jsx)(y,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:model.heading`)]}),(0,Z.jsx)(Lp,{provider:o,catalogModels:C,currentCatalogProvider:re,isLoadingModels:k,setIsLoadingModels:A,onModelSelect:ae,isSwitching:i,refreshModels:e=>d.listProviderModels?.(e)})]})]}),(0,Z.jsx)(to,{value:`connection`,className:`mt-0`,children:(0,Z.jsx)(tp,{})}),(0,Z.jsx)(to,{value:`agent`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Kf,{syncPref:b,switchAutonomy:m})}),(0,Z.jsx)(to,{value:`execution`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(_p,{syncPref:b,fallbackCandidates:v})}),(0,Z.jsx)(to,{value:`fallbacks`,className:`mt-0`,children:(0,Z.jsx)(Cp,{syncPref:b,candidates:v,provider:o,activeModel:s,setProvider:c,setModel:l,switchModel:d.switchModel})}),(0,Z.jsx)(to,{value:`routing`,className:`mt-0`,children:(0,Z.jsx)(Km,{syncPref:b,candidates:v})}),(0,Z.jsx)(to,{value:`fleet`,className:`mt-0`,children:(0,Z.jsx)(wp,{syncPref:b})}),(0,Z.jsx)(to,{value:`integrations`,className:`mt-0`,children:(0,Z.jsx)(Fp,{syncPref:b})}),(0,Z.jsx)(to,{value:`chimera`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:(0,Z.jsx)(rp,{syncPref:b,sessionProvider:o,sessionModel:s})})}),(0,Z.jsx)(to,{value:`context`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(lp,{syncPref:b})}),(0,Z.jsx)(to,{value:`logs`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Ip,{syncPref:b})}),(0,Z.jsx)(to,{value:`security`,className:`mt-0`,children:(0,Z.jsx)(Ch,{})}),(0,Z.jsx)(to,{value:`display`,className:`mt-0`,children:(0,Z.jsx)(mp,{syncPref:b})})]})]})})}),(0,Z.jsx)(Bi,{open:F,onOpenChange:I,children:(0,Z.jsxs)(Li,{showCloseButton:!1,children:[(0,Z.jsxs)(Fi,{children:[(0,Z.jsx)(Ri,{children:_(`settings:resetConfirmTitle`)}),(0,Z.jsx)(zi,{children:_(`settings:resetConfirmBody`)})]}),(0,Z.jsxs)(Ii,{className:`gap-2 sm:gap-0`,children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>I(!1),children:_(`settings:cancel`)}),(0,Z.jsx)(Y,{variant:`destructive`,onClick:ne,children:_(`settings:resetConfirmAction`)})]})]})})]})}var Eh=(0,X.lazy)(()=>V(()=>import(`./AnalyticsDashboard-BnRP4jRR.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]))),Dh=(0,X.lazy)(()=>V(()=>import(`./AgentRosterView-DYAdqgOi.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]))),Oh=(0,X.lazy)(()=>V(()=>import(`./ChangesView-35TNNOyK.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]))),kh=(0,X.lazy)(()=>V(()=>import(`./ChronicleDashboard-BkAPjMg8.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]))),Ah=(0,X.lazy)(()=>V(()=>import(`./CodeEditor-CJdcj7Lh.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]))),jh=(0,X.lazy)(()=>V(()=>import(`./CodeMap-BNfs5wrd.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]))),Mh=(0,X.lazy)(()=>V(()=>import(`./DebugDashboard-BvQrhE38.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([41,1,2,3,4,5,6,10,11,12,13,14,15,16,17]))),Nh=(0,X.lazy)(()=>V(()=>import(`./DesignGalleryView-DSYCeZWp.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]))),Ph=(0,X.lazy)(()=>V(()=>import(`./GoalView-DjrhT9dw.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]))),Fh=(0,X.lazy)(()=>V(()=>import(`./KanbanView-oxhKdDA1.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,27,30,18,24,25,26,47]))),Ih=(0,X.lazy)(()=>V(()=>import(`./MailboxDetailView-DVwTJlVk.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]))),Lh=(0,X.lazy)(()=>V(()=>import(`./OfficeMapPanel-PO-Ziqir.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]))),Rh=(0,X.lazy)(()=>V(()=>import(`./RefreshDebugView-B_doTjkD.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]))),zh=(0,X.lazy)(()=>V(()=>import(`./SageTabs-DWdF_2PE.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([52,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7]))),Bh=(0,X.lazy)(()=>V(()=>import(`./RequirementIntakeView-BPXI8cu2.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]))),Vh=(0,X.lazy)(()=>V(()=>import(`./SddHub-BcqPr8Hj.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,X.lazy)(()=>V(()=>import(`./SessionsDashboard-Bc1iSTBm.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]))),Uh=(0,X.lazy)(()=>V(()=>import(`./SessionInspectView-TFuvc8uU.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]))),Wh=(0,X.lazy)(()=>V(()=>import(`./SkillDetailView-DoXu60GN.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]))),Gh=(0,X.lazy)(()=>V(()=>import(`./TechStackView-CTf7eM_K.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]))),Kh=(0,X.lazy)(()=>V(()=>import(`./DeadCodeScanPanel-CwpRRLLW.js`).then(e=>({default:e.DeadCodeScanPanel})),__vite__mapDeps([61,1,2,3,4,5,6,10,11,12,13,14,15,16,17])));function qh({sessionId:e,desktopShell:t}){let{t:n}=h(),{currentView:r,terminalOpen:i,setTerminalOpen:a}=K(he(e=>({currentView:e.currentView,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen})));return(0,Z.jsxs)(Z.Fragment,{children:[r===`chat`&&(0,Z.jsxs)(Z.Fragment,{children:[e&&(0,Z.jsx)(`div`,{className:`ws-workspace-dock-wrap shrink-0 px-3 pt-2 sm:px-4`,children:(0,Z.jsx)(Rl,{})}),(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.chat`),children:(0,Z.jsx)(xf,{})})]}),r===`settings`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.settings`),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Th,{})})}),r===`memory`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.sageMemory`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sageMemory`)})}),children:(0,Z.jsx)(zh,{})})}),r===`roster`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.agentRoster`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.agentRoster`)})}),children:(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(Dh,{})})})}),r===`context`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.contextDashboard`),children:(0,Z.jsx)(Vf,{})}),r===`setup`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.setup`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Jh,{})})})}),r===`goal`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.goal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Ph,{onClose:()=>q(`chat`)})})})}),r===`sddhub`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.sddHub`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Vh,{})})})}),r===`kanban`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.kanban`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Fh,{onClose:()=>q(`chat`)})})})}),r===`sessions`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.sessions`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Hh,{})})})}),r===`session-inspect`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.sessionInspect`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sessionInspect`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Uh,{})})})}),r===`chronicle`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.chronicle`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(kh,{})})})}),r===`intake`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.requirementsIntake`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Bh,{})})})}),r===`debug`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.debugDashboard`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Mh,{})})})}),r===`refresh-debug`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.refreshDebug`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Rh,{})})})}),r===`files`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.editor`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.editor`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Ah,{})})})}),r===`changes`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.changes`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.changes`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Oh,{className:`h-full min-h-0`})})})}),r===`mailbox`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.mailbox`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Ih,{className:`h-full min-h-0`})})})}),r===`design-gallery`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.designGallery`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Nh,{className:`h-full`})})})}),r===`skill`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.skill`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Wh,{className:`h-full`})})})}),r===`officemap`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.officeMap`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.officeMap`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Lh,{})})})}),r===`analytics`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.analytics`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Eh,{})})})}),r===`codemap`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.codemap`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.codemap`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(jh,{})})})}),r===`techstack`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.techstack`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.techstack`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Gh,{})})})}),r===`deadcode`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.deadcode`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.deadcode`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto`,children:(0,Z.jsx)(Kh,{})})})}),i&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.terminal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.terminal`)})}),children:(0,Z.jsx)(Yh,{desktopShell:t,onClose:()=>a(!1)})})})]})}var Jh=(0,X.lazy)(()=>V(()=>import(`./SetupScreen-DT4PMl9C.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]))),Yh=(0,X.lazy)(()=>V(()=>import(`./TerminalPanel-BowAkbec.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,X.lazy)(()=>V(()=>import(`./AnalyticsDashboard-BnRP4jRR.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,X.lazy)(()=>V(()=>import(`./CodeMap-BNfs5wrd.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,X.lazy)(()=>V(()=>import(`./ChronicleDashboard-BkAPjMg8.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,X.lazy)(()=>V(()=>import(`./GoalView-DjrhT9dw.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,X.lazy)(()=>V(()=>import(`./ChangesView-35TNNOyK.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 Xh=(0,X.lazy)(()=>V(()=>import(`./CronJobsPanel-DK10t9ty.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,X.lazy)(()=>V(()=>import(`./CodeEditor-CJdcj7Lh.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,X.lazy)(()=>V(()=>import(`./DebugDashboard-BvQrhE38.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([41,1,2,3,4,5,6,10,11,12,13,14,15,16,17]))),(0,X.lazy)(()=>V(()=>import(`./DesignGalleryView-DSYCeZWp.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,X.lazy)(()=>V(()=>import(`./MailboxDetailView-DVwTJlVk.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,X.lazy)(()=>V(()=>import(`./SageTabs-DWdF_2PE.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,X.lazy)(()=>V(()=>import(`./AgentRosterView-DYAdqgOi.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,X.lazy)(()=>V(()=>import(`./KanbanView-oxhKdDA1.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,27,30,18,24,25,26,47]))),(0,X.lazy)(()=>V(()=>import(`./OfficeMapPanel-PO-Ziqir.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 Zh=(0,X.lazy)(()=>V(()=>import(`./ProcessMonitor-C5kib2h4.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]))),Qh=(0,X.lazy)(()=>V(()=>import(`./QueuePanel-Cgo0AeCj.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,X.lazy)(()=>V(()=>import(`./RefreshDebugView-B_doTjkD.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,X.lazy)(()=>V(()=>import(`./SddHub-BcqPr8Hj.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,X.lazy)(()=>V(()=>import(`./SessionsDashboard-Bc1iSTBm.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,X.lazy)(()=>V(()=>import(`./SetupScreen-DT4PMl9C.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,X.lazy)(()=>V(()=>import(`./SkillDetailView-DoXu60GN.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,X.lazy)(()=>V(()=>import(`./SpecsView-CoL5_ZKF.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,X.lazy)(()=>V(()=>import(`./TechStackView-CTf7eM_K.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,X.lazy)(()=>V(()=>import(`./TerminalPanel-BowAkbec.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 $h(){let{t:e}=h(),{theme:t}=Ja(),n=Ur(),{currentView:i,sidebarOpen:a,toggleSidebar:o,setSearchOpen:s,setSidebarOpen:c,setInspectorTab:l,setPaletteOpen:u,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,toggleInspector:m,setFleetMonitorOpen:g,setAgentsMonitorOpen:_,processMonitorOpen:v,setProcessMonitorOpen:y,queuePanelOpen:b,setQueuePanelOpen:x,cronJobsOpen:S,setCronJobsOpen:C,setTerminalOpen:w}=K(he(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}))),T=r(e=>e.isLoading),E=W(e=>e.iteration),D=W(e=>e.projectName),O=W(e=>e.session?.title),k=W(e=>e.session?.id),A=K(e=>k?e.sessionNicknames[k]:void 0),j=K(e=>e.sideContextBreakdownOpen),M=K(e=>e.setSideContextBreakdownOpen);ii(e=>e.agents),Ua({setPaletteOpen:u,setSearchOpen:s,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,setFleetMonitorOpen:g,setAgentsMonitorOpen:_,setProcessMonitorOpen:y,setQueuePanelOpen:x,setCronJobsOpen:C,setTerminalOpen:w}),(0,X.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?ji(`debug`):window.location.pathname===`/analytics`?ji(`analytics`):window.location.pathname===`/refresh-debug`&&ji(`refresh-debug`))},[]),(0,X.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=H(G.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,X.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=pi.getState().openFiles.find(e=>e.path===t);if(!n)return;let r=H(G.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:ee}=Br();(0,X.useEffect)(()=>{ee&&K.getState().sidebarOpen&&c(!1)},[ee,c]);let N=ee&&a;return Rr(),Wa(),(0,X.useEffect)(()=>{let e=[];if(T){let t=E?` iter ${E.index}${E.max?`/${E.max}`:``}`:``;e.push(`●${t}`)}let t=A?.trim()||O?.trim(),n=D?.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=D||`AI Agent`}},[T,E,D,O,A]),Ga({toggleSidebar:o,setSearchOpen:s,toggleInspector:m,setInspectorTab:l}),(0,Z.jsxs)(`div`,{"data-shell":n?`desktop`:`browser`,className:U(`ws-app-root flex min-h-0 min-w-0 overflow-hidden`,n&&`ws-desktop-shell`,t),children:[(0,Z.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,Z.jsx)(Oa,{desktopShell:n}),a&&i!==`setup`&&(0,Z.jsx)(nl,{desktopShell:n}),(0,Z.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,Z.jsx)(hs,{currentView:i,projectName:D,sessionLabel:A||O||k||void 0,isLoading:T,iteration:E??null,onPalette:()=>u(!0),onSearch:()=>s(!0),onModel:()=>f(!0),onSettings:()=>Mi(`settings`)}),i!==`setup`&&(0,Z.jsx)(Es,{}),i!==`setup`&&(0,Z.jsx)(Ds,{}),(0,Z.jsx)(qh,{sessionId:k??null,desktopShell:n})]}),i!==`setup`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.inspector`),children:(0,Z.jsx)(cs,{})}),k&&i===`chat`&&(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.workspaceInspector`),children:(0,Z.jsx)(Bl,{sessionId:k})})]}),v&&(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.processMonitor`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Zh,{open:v,onClose:()=>y(!1)})})}),b&&(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.queue`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Qh,{open:b,onClose:()=>x(!1)})})}),S&&(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.cronJobs`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Xh,{open:S,onClose:()=>C(!1)})})}),(0,Z.jsx)(Is,{}),j&&(0,Z.jsx)(As,{open:j,onClose:()=>M(!1)}),(0,Z.jsx)(Ts,{}),(0,Z.jsx)(Ki,{}),(0,Z.jsx)(Ui,{}),(0,Z.jsx)(Va,{}),(0,Z.jsx)(Hs,{}),(0,Z.jsx)(Rs,{}),(0,Z.jsx)(zs,{}),(0,Z.jsx)(Pi,{})]})}function eg(){return(0,Z.jsx)(Ms,{children:(0,Z.jsx)(qa,{defaultTheme:`system`,children:(0,Z.jsx)($h,{})})})}Zi.createRoot(t(document.getElementById(`root`))).render((0,Z.jsx)(X.StrictMode,{children:(0,Z.jsx)(eg,{})}));export{ca as A,Qa as C,Xa as D,eo as E,aa as M,Ja as O,Lo as S,$a as T,Js as _,zp as a,Yo as b,Sf as c,jd as d,kd as f,Zs as g,Dl as h,Gp as i,la as j,ia as k,lf as l,jl as m,Kp as n,Ep as o,Nl as p,qp as r,Sp as s,Jp as t,Nd as u,bs as v,to as w,Jo as x,vs as y};
133
+ AWS_REGION=us-east-1`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldDescription`)}),(0,Z.jsx)(Vi,{value:u,onChange:e=>d(e.target.value),placeholder:a(`settings:mcp.fieldDescriptionPlaceholder`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`server-enabled`,checked:x,onChange:e=>S(e.target.checked),className:`rounded`}),(0,Z.jsx)(`label`,{htmlFor:`server-enabled`,className:`text-sm`,children:a(`settings:mcp.enableServer`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`server-lazy`,checked:C,onChange:e=>w(e.target.checked),className:`rounded`}),(0,Z.jsxs)(`label`,{htmlFor:`server-lazy`,className:`text-sm`,children:[a(`settings:mcp.lazyConnect`),` `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.lazyConnectHint`)})]})]})]}),(0,Z.jsxs)(Ii,{children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Z.jsx)(Y,{onClick:T,children:a(E?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function Np({server:e,isAdded:t,onAdd:n}){let{t:r}=h();return(0,Z.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,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),e.badge&&(0,Z.jsx)(Ep,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-xs shrink-0`,children:e.transport})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description}),e.requiresEnvVars&&e.requiresEnvVars.length>0&&(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:r(`settings:mcp.requires`,{vars:e.requiresEnvVars.join(`, `)})})]}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:t?(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,disabled:!0,children:[(0,Z.jsx)(Jn,{className:`w-4 h-4 mr-1`}),r(`settings:mcp.added`)]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:n,children:[(0,Z.jsx)(at,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function Pp(){let e=Hr(),{t}=h(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(`list`),[c,l]=(0,X.useState)(),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,g]=(0,X.useState)(),[_,v]=(0,X.useState)(null);(0,X.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]),J.success(z.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)),J.success(z.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),J.success(z.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),J.info(z.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),J.success(z.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),J.success(z.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),J.warn(z.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),J.error(z.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},m=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||J.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,X.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),b=(0,X.useCallback)(e=>{g(Op(e,!1)),p(!0)},[]),x=(0,X.useCallback)(n=>{Gi({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,X.useCallback)(e=>{l(e),g(void 0),d(!0)},[]),C=(0,X.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),w=(0,X.useCallback)(t=>{v(t),e.client?.wakeMcpServer(t)},[e]),T=(0,X.useCallback)(t=>{v(t),e.client?.sleepMcpServer(t)},[e]),E=(0,X.useCallback)(t=>{v(t),e.client?.discoverMcpServer(t)},[e]),D=(0,X.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,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.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,Z.jsx)(Pn,{className:`h-5 w-5`})}),(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`settings:mcp.heading`)}),n.length>0&&(0,Z.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,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:D,disabled:i,children:[i?(0,Z.jsx)(Rn,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,Z.jsxs)(Y,{size:`sm`,onClick:()=>{g(void 0),p(!0)},children:[(0,Z.jsx)(at,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,Z.jsxs)(Qa,{value:o,onValueChange:e=>s(e),children:[(0,Z.jsxs)($a,{children:[(0,Z.jsxs)(eo,{value:`recommended`,children:[(0,Z.jsx)(Mr,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,Z.jsx)(eo,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,Z.jsx)(eo,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,Z.jsxs)(to,{value:`recommended`,className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.recommendedBody`)}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:Dp.map(e=>(0,Z.jsx)(Np,{server:e,isAdded:A.has(e.name),onAdd:()=>b(e)},e.name))})]}),(0,Z.jsx)(to,{value:`list`,className:`space-y-3`,children:i&&n.length===0?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Rn,{className:`w-5 h-5 animate-spin mr-2`}),t(`settings:mcp.loadingServers`)]}):n.length===0?(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Pn,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:t(`settings:mcp.noServers`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.noServersHint`)})]}):n.map(e=>(0,Z.jsx)(jp,{server:e,onWake:()=>w(e.name),onSleep:()=>T(e.name),onDiscover:()=>E(e.name),onEdit:()=>S(e),onRemove:()=>x(e.name)},e.name))}),(0,Z.jsx)(to,{value:`add`,children:(0,Z.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,Z.jsx)(`p`,{children:t(`settings:mcp.addCustomBody`)}),(0,Z.jsx)(`p`,{className:`mt-1`,children:t(`settings:mcp.addCustomBodyHint`)})]})})]}),(0,Z.jsx)(Mp,{open:f,onOpenChange:e=>{e||(p(!1),g(void 0))},prefillConfig:m,onSave:y}),(0,Z.jsx)(Mp,{open:u,onOpenChange:d,server:c,onSave:C})]})}function Fp({syncPref:e}){let{t}=h(),n=B();return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.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,Z.jsx)(Pn,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.hqHeading`)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.hqPublishingLabel`),hint:t(`settings:integrations.hqPublishingHint`),value:n.hqEnabled,onChange:()=>e(`hqEnabled`,!n.hqEnabled)}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqUrlLabel`)}),(0,Z.jsx)(Vi,{value:n.hqUrl,placeholder:t(`activity:integrationsSection.httpHost3499`),onChange:t=>e(`hqUrl`,t.target.value)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.hqUrlHint`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqTokenLabel`)}),(0,Z.jsx)(Vi,{type:`password`,value:n.hqToken,placeholder:t(`activity:integrationsSection.clientTokenFromWstackHq`),onChange:t=>e(`hqToken`,t.target.value)})]}),(0,Z.jsx)($,{label:t(`settings:integrations.hqRawContentLabel`),hint:t(`settings:integrations.hqRawContentHint`),value:n.hqRawContent,onChange:()=>e(`hqRawContent`,!n.hqRawContent)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.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,Z.jsx)(Pn,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`activity:integrationsSection.mcpServers`)})})]}),n.featureMcp?(0,Z.jsx)(Pp,{}):(0,Z.jsxs)(`div`,{className:`text-center py-6 text-muted-foreground`,children:[(0,Z.jsx)(Pn,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.disabled`)}),(0,Z.jsx)(`p`,{className:`text-xs mt-1`,children:t(`settings:integrations.disabledHint`)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.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,Z.jsx)(dn,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.telegramHeading`)})})]}),n.tgConfigured?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.telegramSessionEndLabel`),hint:t(`settings:integrations.telegramSessionEndHint`),value:n.tgSessionEnd,onChange:()=>e(`tgSessionEnd`,!n.tgSessionEnd)}),(0,Z.jsx)($,{label:t(`settings:integrations.telegramDelegateLabel`),hint:t(`settings:integrations.telegramDelegateHint`),value:n.tgDelegate,onChange:()=>e(`tgDelegate`,!n.tgDelegate)}),(0,Z.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,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramChangesApply`)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramNotConfigured`)})]})]})}function Ip({syncPref:e}){let{t}=h(),n=B();return(0,Z.jsx)(`div`,{className:`space-y-6`,children:(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.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,Z.jsx)(Cn,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:logs.heading`)})})]}),(0,Z.jsx)(Q,{label:t(`settings:logs.logLevelLabel`),hint:t(`settings:logs.logLevelHint`),value:n.logLevel,options:[{value:`debug`,label:t(`settings:logs.logLevelDebug`)},{value:`info`,label:t(`settings:logs.logLevelInfo`)},{value:`warn`,label:t(`settings:logs.logLevelWarn`)},{value:`error`,label:t(`settings:logs.logLevelError`)}],onChange:t=>e(`logLevel`,t)}),(0,Z.jsx)(Q,{label:t(`settings:logs.auditLevelLabel`),hint:t(`settings:logs.auditLevelHint`),value:n.auditLevel,options:[{value:`minimal`,label:t(`settings:logs.auditLevelMinimal`)},{value:`standard`,label:t(`settings:logs.auditLevelStandard`)},{value:`full`,label:t(`settings:logs.auditLevelFull`)}],onChange:t=>e(`auditLevel`,t)}),(0,Z.jsx)(Q,{label:t(`settings:logs.fsAccessLabel`),hint:t(`settings:logs.fsAccessHint`),value:n.fsAccess,options:[{value:`unrestricted`,label:t(`settings:logs.fsAccessUnrestricted`)},{value:`project`,label:t(`settings:logs.fsAccessProject`)}],onChange:t=>e(`fsAccess`,t)}),(0,Z.jsx)($,{label:t(`settings:logs.debugStreamLabel`),hint:t(`settings:logs.debugStreamHint`),value:n.debugStream,onChange:()=>e(`debugStream`,!n.debugStream)})]})})}function Lp({provider:e,catalogModels:t,currentCatalogProvider:n,isLoadingModels:r,isSwitching:i,setIsLoadingModels:a,onModelSelect:o,refreshModels:s}){let c=G(e=>e.model),{t:l}=h();return(0,Z.jsx)(`div`,{className:`space-y-4`,children:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:n?.name||e}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{a(!0),s(e)},children:(0,Z.jsx)(wr,{className:U(`h-4 w-4`,r&&`animate-spin`)})})]}),r&&!t[e]?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(Rn,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:l(`settings:model.loading`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Uf,{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,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`settings:toast.switching`)}):null]})]}):(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(y,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:l(`settings:model.selectProviderFirst`)})]})})}function Rp({maskedKey:e,className:t}){let{t:n}=h(),[r,i]=(0,X.useState)(!1),a=(0,X.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),1500)})},[e]);return(0,Z.jsxs)(`div`,{className:U(`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,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate tracking-wide`,children:e}),(0,Z.jsx)(`button`,{type:`button`,onClick:a,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,Z.jsx)(Jn,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(it,{className:`h-3 w-3`})})]})}function zp(){let e=(0,X.useRef)([]);return{setFieldRef:(0,X.useCallback)(t=>n=>{e.current[t]=n},[]),handleKeyDown:(0,X.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 Bp={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(Bp);var Vp=[{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`}}],Up=Object.fromEntries([...Vp,...Object.values(Bp),...Hp].map(e=>[e.id,e]));function Wp(){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 Gp(){return Object.values(Up).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 Kp=`openai-compatible`,qp=Wp();function Jp({models:e,onChange:t}){let{t:n}=h(),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),g=(0,X.useRef)(void 0),_=(0,X.useRef)(null),v=G(e=>e.wsUrl),y=(0,X.useCallback)(e=>{if(!e.trim()){c([]);return}u(!0);let t=H(v),n=t.on(`provider.models.search_result`,t=>{let n=t.payload;!n||n.query!==e.trim()||(c(n.matches??[]),u(!1))});t.searchProviderModels(e.trim(),8),setTimeout(()=>{n?.(),u(!1)},5e3)},[v]);(0,X.useEffect)(()=>{if(g.current&&clearTimeout(g.current),!a.trim()){c([]);return}return g.current=setTimeout(()=>y(a),250),()=>{g.current&&clearTimeout(g.current)}},[a,y]);let b=(0,X.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]),o(``),c([]),i(!1)},[e,t]),x=(0,X.useCallback)(n=>{t(e.filter(e=>e.id!==n))},[e,t]),S=(0,X.useCallback)(()=>{let e=p.trim();e&&(b(e),m(``),f(!1))},[p,b]);return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:n(`setup:screen.custom.models`)}),e.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:U(`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,Z.jsx)(`span`,{className:`truncate max-w-[120px]`,children:e.name&&e.name!==e.id?e.name:e.id}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>x(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive`,children:(0,Z.jsx)(Jt,{className:`h-3 w-3`})})]},e.id))}),r?(0,Z.jsxs)(`div`,{className:`space-y-2 p-3 rounded border border-border/60 bg-muted/20`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(Ft,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(Vi,{placeholder:n(`setup:screen.custom.modelSearchPlaceholder`),value:a,onChange:e=>o(e.target.value),className:`text-sm pl-8`,autoFocus:!0}),l&&(0,Z.jsx)(Rn,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),s.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1 max-h-40 overflow-y-auto`,children:s.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>b(e.modelId,e),className:U(`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,Z.jsx)(Jn,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`font-medium block truncate`,children:e.name}),(0,Z.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}`))}),!l&&a.trim()&&s.length===0&&(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center py-2`,children:[n(`setup:screen.custom.noCatalogMatch`),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{f(!0),setTimeout(()=>_.current?.focus(),50)},className:`ml-1 text-accent underline underline-offset-2 hover:text-accent/80`,children:n(`setup:screen.custom.useCustomId`)})]}),d&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Vi,{ref:_,placeholder:n(`setup:screen.custom.customModelIdPlaceholder`),value:p,onChange:e=>m(e.target.value),className:`text-sm flex-1`,onKeyDown:e=>{e.key===`Enter`&&S()}}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:S,disabled:!p.trim(),children:[(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.add`)]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2 pt-1`,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{i(!1),o(``),c([]),f(!1),m(``)},className:`text-xs`,children:n(`setup:screen.custom.cancel`)})})]}):(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(!0),className:`text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.addModel`)]}),e.length>0&&(0,Z.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 Yp=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,Z.jsx)(_t,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,Z.jsx)(On,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,Z.jsx)(xe,{className:`h-5 w-5`})}],Xp=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function Zp({ws:e,savedByKind:t}){let{t:n}=h(),[r,i]=(0,X.useState)({chatgpt:{phase:`idle`},claude:{phase:`idle`},copilot:{phase:`idle`}}),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(null);(0,X.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`?(J.success(t.message??z.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),c(null),o(``),u(null),f(``)):t.phase===`error`&&J.error(t.message??z.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let g=(0,X.useCallback)(t=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),_=(0,X.useCallback)((t,n)=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n)},[e]),v=(0,X.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,X.useCallback)(t=>{e.cancelOAuth(t),i(e=>({...e,[t]:{phase:`idle`}})),c(null)},[e]),b=(0,X.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,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-3`,children:(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-warning`,children:n(`settings:oauth.termsWarning`)})}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-3`,children:Yp.map(e=>{let t=r[e.kind],i=Xp.includes(t.phase),h=x[e.kind],S=h?.length??0,C=p===e.kind;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/70 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 lg:flex-col lg:items-stretch`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subtitle})]})]}),i?(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>y(e.kind),className:`shrink-0 lg:w-full`,children:n(`common:action.cancel`)}):(0,Z.jsx)(Y,{size:`sm`,onClick:()=>g(e.kind),className:`shrink-0 lg:w-full`,children:n(`settings:oauth.signIn`)})]}),t.phase===`awaiting_browser`&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(Rn,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.waitingBrowser`)})]}),t.authorizeUrl&&(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.authorizeUrl,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(kn,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openSignIn`)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.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,Z.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Z.jsx)(Vi,{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,Z.jsx)(Y,{size:`sm`,onClick:()=>b(e.kind),disabled:!a.trim(),children:n(`settings:oauth.submit`)})]})]})]}),t.phase===`awaiting_code`&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`settings:oauth.enterCode`)}),(0,Z.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-widest`,children:t.userCode??`…`}),t.verificationUri&&(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(kn,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openVerification`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Rn,{className:`h-3.5 w-3.5 animate-spin`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.waitingCode`)})]})]}),(t.phase===`exchanging`||t.phase===`fetching_models`)&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm`,children:[(0,Z.jsx)(Rn,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{children:t.phase===`exchanging`?n(`settings:oauth.exchanging`):n(`settings:oauth.fetchingModels`)})]}),t.phase===`success`&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-success`,children:[(0,Z.jsx)(R,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:t.message??n(`settings:oauth.signedIn`)})]}),t.phase===`error`&&t.message&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-destructive`,children:[(0,Z.jsx)(kr,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:t.message})]}),S>0&&!i&&(0,Z.jsxs)(`div`,{className:`mt-3 border-t pt-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>m(C?null:e.kind),className:`flex w-full items-center justify-between text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(Sr,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.accountCount`,{count:S})})]}),(0,Z.jsx)(`span`,{className:`text-[10px]`,children:C?`▲`:`▼`})]}),C&&h&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[h.map(t=>(0,Z.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,Z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t.id}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[t.hasActiveKey?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-success`,children:[(0,Z.jsx)(R,{className:`h-3 w-3`}),n(`settings:oauth.active`)]}):(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n(`settings:oauth.inactive`)}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>_(e.kind,t.id),className:`h-6 px-1.5 text-[11px]`,title:n(`settings:oauth.retryLogin`),children:[(0,Z.jsx)(wr,{className:`h-3 w-3 mr-0.5`}),n(`settings:oauth.retry`)]})]})]},t.id)),(0,Z.jsx)(`div`,{className:`pt-1`,children:l===e.kind?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Vi,{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,Z.jsx)(Y,{size:`sm`,onClick:()=>v(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]})]}),S===0&&!i&&(0,Z.jsx)(`div`,{className:`mt-3 border-t pt-3`,children:l===e.kind?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Vi,{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,Z.jsx)(Y,{size:`sm`,onClick:()=>v(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]},e.kind)})})]})}function Qp({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,X.useRef)(null),{t:o}=h();return(0,X.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,Z.jsx)(Bi,{open:e,onOpenChange:e=>{e||i()},children:(0,Z.jsxs)(Li,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,Z.jsxs)(Fi,{children:[(0,Z.jsxs)(Ri,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Pe,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,Z.jsx)(zi,{children:o(`settings:allowlist.body`,{count:n,provider:t})})]}),(0,Z.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,Z.jsxs)(Ii,{className:`gap-2 sm:gap-2 flex-wrap`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:i,title:o(`settings:allowlist.keepTitle`),"data-action":`cancel`,children:[o(`common:action.cancel`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`Esc`})]}),(0,Z.jsxs)(Y,{variant:`destructive`,size:`sm`,onClick:r,title:o(`settings:allowlist.clearTitle`),"data-action":`confirm`,children:[o(`settings:allowlist.clear`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`↵`})]})]})]})})}function $p(){return{inFlight:!1,last:null,picked:null}}function em(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 tm(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 nm(e){return(e?.length??0)>0}function rm(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function im(e){return e.length>0}function am({ws:e,onSelect:t,onClose:n}){let{t:r}=h(),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(null),d=(0,X.useRef)(``);(0,X.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,X.useCallback)(t=>{if(!t.trim()){s([]),d.current=``;return}d.current=t,l(!0),e.searchProviderModels(t,8)},[e]);(0,X.useEffect)(()=>(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>f(i),300),()=>{u.current&&clearTimeout(u.current)}),[i,f]);let p=(0,X.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,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:n,"aria-label":r(`common:action.close`)}),(0,Z.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,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings:providerModels.catalogSearchTitle`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(Jt,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`relative mb-3`,children:[(0,Z.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,Z.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,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(Rn,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):o.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:o.map(e=>(0,Z.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,Z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-sm font-medium text-foreground`,children:e.modelId}),e.name!==e.modelId&&(0,Z.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.name})]}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.providerName})]}),e.description&&(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:[e.contextWindow?(0,Z.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,Z.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,Z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.noResults`)}):(0,Z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.typeToSearch`)})]})]})}var om=new Set([`__proto__`,`constructor`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]),sm=[`text`,`image`,`audio`,`video`,`pdf`],cm=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],lm=ke().int().nonnegative(),um=ke().finite(),dm=x({context:lm.optional(),output:lm.optional(),input:lm.optional()}),fm=x({input:um.optional(),output:um.optional(),cache_read:um.optional(),cache_write:um.optional(),cache_write_5m:um.optional(),cache_write_1h:um.optional(),context_over_200k:um.optional(),reasoning:um.optional(),input_audio:um.optional(),output_audio:um.optional()}),pm=x({input:mr(l().min(1)).optional(),output:mr(l().min(1)).optional()}),mm=mn([x({type:E(`toggle`)}),x({type:E(`effort`),values:mr(_(cm)).optional()}),x({type:E(`budget_tokens`),min:ke().optional(),max:ke().optional()})]),hm=e=>({message:`${e} id is a forbidden prototype-pollution key`}),gm=x({id:l().min(1).refine(e=>!om.has(e),hm(`Model`)),name:l().min(1),description:l().optional(),family:l().optional(),attachment:nt().optional(),reasoning:nt().optional(),reasoning_options:mn([mm,mr(mm)]).optional(),interleaved:mn([nt(),x({field:l().optional()})]).optional(),tool_call:nt().optional(),structured_output:nt().optional(),temperature:nt().optional(),knowledge:l().optional(),release_date:l().optional(),last_updated:l().optional(),open_weights:nt().optional(),modalities:pm.optional(),cost:fm.optional(),limit:dm.optional(),status:l().optional(),experimental:nt().optional()}),_m=x({id:l().min(1).refine(e=>!om.has(e),hm(`Provider`)),name:l().min(1),env:mr(l()).optional(),npm:l().optional(),api:l().optional(),doc:l().optional(),models:vn(l(),gm)});vn(l(),_m);function vm(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 ym(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 bm=[{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 xm({providerId:e,modelId:t,initialModelsDev:n,onSave:r,onCancel:i}){let{t:a}=h(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(()=>vm(t,n)),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(JSON.stringify({...n,...t?{id:t}:{}},null,2)),[m,g]=(0,X.useState)(null),_=(0,X.useCallback)((e,t)=>{l(n=>({...n,[e]:t}))},[]),v=(0,X.useCallback)((e,t)=>{l(n=>{let r=n[e];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),y=(0,X.useCallback)(()=>{let e=ym(c,n),i=gm.safeParse({...e,id:c.id||t});if(!i.success){d(i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`));return}d([]),r(c.id||t,e)},[c,n,t,r]),b=(0,X.useCallback)(()=>{try{let e=JSON.parse(f),n=gm.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))}},[f,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,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 border-b border-border/50`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:U(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,o?`border-transparent text-muted-foreground hover:text-foreground`:`border-primary text-primary`),children:a(`settings:providerModels.tabForm`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:U(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,o?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`),children:a(`settings:providerModels.tabRawJson`)})]}),o?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),rows:16,className:`w-full rounded-md border border-border bg-muted/20 p-2 font-mono text-xs`,spellCheck:!1}),m&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:m})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionIdentity`)}),!t&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-id`,children:`ID`}),(0,Z.jsx)(`input`,{id:`mse-id`,className:x,value:c.id,onChange:e=>_(`id`,e.target.value),placeholder:a(`activity:modelSchema.modelId`)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-name`,children:a(`settings:providerModels.fieldName`)}),(0,Z.jsx)(`input`,{id:`mse-name`,className:x,value:c.name,onChange:e=>_(`name`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-desc`,children:a(`settings:providerModels.fieldDescription`)}),(0,Z.jsx)(`input`,{id:`mse-desc`,className:x,value:c.description,onChange:e=>_(`description`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-family`,children:a(`settings:providerModels.fieldFamily`)}),(0,Z.jsx)(`input`,{id:`mse-family`,className:x,value:c.family,onChange:e=>_(`family`,e.target.value)})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionLimits`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-ctx`,children:a(`settings:providerModels.fieldContext`)}),(0,Z.jsx)(`input`,{id:`mse-ctx`,type:`number`,className:x,value:c.limitContext,onChange:e=>_(`limitContext`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-out`,children:a(`settings:providerModels.fieldOutput`)}),(0,Z.jsx)(`input`,{id:`mse-out`,type:`number`,className:x,value:c.limitOutput,onChange:e=>_(`limitOutput`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-inlim`,children:a(`settings:providerModels.fieldInputLimit`)}),(0,Z.jsx)(`input`,{id:`mse-inlim`,type:`number`,className:x,value:c.limitInput,onChange:e=>_(`limitInput`,e.target.value)})]})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionPricing`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-costin`,children:a(`settings:providerModels.fieldCostInput`)}),(0,Z.jsx)(`input`,{id:`mse-costin`,type:`number`,step:`0.01`,className:x,value:c.costInput,onChange:e=>_(`costInput`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-costout`,children:a(`settings:providerModels.fieldCostOutput`)}),(0,Z.jsx)(`input`,{id:`mse-costout`,type:`number`,step:`0.01`,className:x,value:c.costOutput,onChange:e=>_(`costOutput`,e.target.value)})]})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionModalities`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:S,children:a(`settings:providerModels.fieldInputModalities`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:sm.map(e=>{let t=c.inputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(`inputModalities`,e),className:U(`rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`in-mod-${e}`)})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:S,children:a(`settings:providerModels.fieldOutputModalities`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:sm.map(e=>{let t=c.outputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(`outputModalities`,e),className:U(`rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`out-mod-${e}`)})})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionCapabilities`)}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:bm.map(({key:e,labelKey:t})=>(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 rounded border-border`,checked:c[e],onChange:t=>_(e,t.target.checked)}),a(t)]},String(e)))})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionDates`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-release`,children:a(`settings:providerModels.fieldReleaseDate`)}),(0,Z.jsx)(`input`,{id:`mse-release`,type:`date`,className:x,value:c.releaseDate,onChange:e=>_(`releaseDate`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:S,htmlFor:`mse-updated`,children:a(`settings:providerModels.fieldLastUpdated`)}),(0,Z.jsx)(`input`,{id:`mse-updated`,type:`date`,className:x,value:c.lastUpdated,onChange:e=>_(`lastUpdated`,e.target.value)})]})]})]}),u.length>0&&(0,Z.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-2`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5 text-xs text-destructive`,children:u.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border/50 pt-3`,children:[(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(Jt,{className:`h-3.5 w-3.5`}),a(`common:action.cancel`)]}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:o?b:y,className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`}),a(`common:action.save`)]})]})]})}function Sm(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 Cm(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 wm(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 Tm(e){let t=e?.modalities;return{input:Array.isArray(t?.input)?t.input:[],output:Array.isArray(t?.output)?t.output:[]}}var Em={text:We,image:vr,audio:ce,video:pr,pdf:We};function Dm({providerId:e,models:t,customModels:n,ws:r,pickedModelId:i,onPickModel:a}){let{t:o}=h(),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),g=(0,X.useMemo)(()=>Sm(t,n),[t,n]),_=(0,X.useMemo)(()=>{let e=p.trim().toLowerCase();return e?g.filter(t=>t.modelId.toLowerCase().includes(e)||(t.name?.toLowerCase().includes(e)??!1)):g},[g,p]),v=(0,X.useCallback)(t=>{r.removeCustomModel(e,t),J.success(o(`settings:providerModels.modelRemoved`,{model:t}))},[r,e,o]),y=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),c(null),J.success(o(`settings:providerModels.modelSaved`,{model:t}))},[r,e,o]),b=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),u(!1),J.success(o(`settings:providerModels.modelAdded`,{model:t}))},[r,e,o]);return(0,Z.jsxs)(`div`,{className:`space-y-3`,"data-model-list-editor":e,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>u(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addFromCatalog`)]}),(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>f(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addCustom`)]})]}),g.length>0&&(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/70`,children:[g.length>8&&(0,Z.jsxs)(`div`,{className:`relative border-b border-border/40 bg-muted/10`,children:[(0,Z.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,Z.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:o(`settings:providerModels.filterPlaceholder`),"aria-label":o(`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,Z.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:(0,Z.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-border/70 bg-muted/30 text-left text-[11px] uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colModel`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colContext`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colOutput`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colCost`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colModalities`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colCaps`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colSource`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2`,"aria-label":o(`settings:providerModels.colActions`)})]})}),(0,Z.jsx)(`tbody`,{children:_.map(t=>{let n=Cm(t.modelsDev),r=t.maxOutput??t.modelsDev?.limit?.output,l=typeof r==`number`?r.toLocaleString():void 0,u=wm(t.modelsDev),d=Tm(t.modelsDev),f=t.capabilities,p=s===t.modelId;return(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsxs)(`tr`,{className:`border-b border-border/40 transition-colors hover:bg-muted/20`,children:[(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs font-medium text-foreground`,children:t.modelId}),t.name&&t.name!==t.modelId&&(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t.name})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(Ee,{className:`h-3 w-3`}),n]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:l?(0,Z.jsx)(`span`,{children:l}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs`,children:u.input||u.output?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(zt,{className:`h-3 w-3`}),u.input&&u.output?`${u.input}/${u.output}`:u.input??u.output]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[d.input.map(e=>{let t=Em[e]??We;return(0,Z.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,Z.jsx)(t,{className:`h-2.5 w-2.5`}),e]},`in-${e}`)}),d.output.map(e=>(0,Z.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,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[f?.tools&&(0,Z.jsx)(nn,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.tools`)}),f?.reasoning&&(0,Z.jsx)(cr,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.reasoning`)}),f?.vision&&(0,Z.jsx)(en,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.vision`)})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsx)(`span`,{className:U(`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,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[a&&(t.modelId===i?(0,Z.jsx)(`span`,{className:`inline-flex items-center rounded p-1 text-primary`,title:o(`settings:providerModels.usingModel`,{model:t.modelId}),role:`img`,"aria-label":o(`settings:providerModels.usingModel`,{model:t.modelId}),children:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`})}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>a(e,t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":o(`settings:providerModels.useModel`,{model:t.modelId}),title:o(`settings:providerModels.useModel`,{model:t.modelId}),children:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`})})),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(p?null:t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":o(`settings:providerModels.editModel`,{model:t.modelId}),children:(0,Z.jsx)(bn,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,"aria-label":o(`settings:providerModels.removeModel`,{model:t.modelId}),children:(0,Z.jsx)(_n,{className:`h-3.5 w-3.5`})})]})})]}),p&&(0,Z.jsx)(`tr`,{className:`border-b border-border/40 bg-muted/10`,children:(0,Z.jsx)(`td`,{colSpan:8,className:`p-3`,children:(0,Z.jsx)(xm,{providerId:e,modelId:t.modelId,initialModelsDev:t.modelsDev??{},onSave:y,onCancel:()=>c(null)})})},`${t.modelId}-edit`)]},t.modelId)})})]})})]}),g.length===0&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/50 p-8 text-center`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`settings:providerModels.emptyState`)})}),l&&(0,Z.jsx)(am,{ws:r,onSelect:b,onClose:()=>u(!1)}),d&&(0,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:()=>f(!1),"aria-label":o(`common:action.close`)}),(0,Z.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,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:o(`settings:providerModels.addCustomTitle`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>f(!1),className:`text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(Jt,{className:`h-4 w-4`})})]}),(0,Z.jsx)(xm,{providerId:e,modelId:``,initialModelsDev:{},onSave:y,onCancel:()=>f(!1)})]})]})]})}function Om(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 km=3e3;function Am({providerId:e,savedPickedModelId:t,savedModels:n,savedCustomModels:r,ws:i,onPickModel:a,onClearModels:o,onUndoClear:s}){let[c,l]=(0,X.useState)(()=>$p()),{t:u}=h(),[d,f]=(0,X.useState)(!1);(0,X.useEffect)(()=>i.on(`provider.probe`,t=>{t.type===`provider.probe`&&t.payload.providerId===e&&l(e=>({...e,inFlight:!1,last:em(t.payload)}))}),[i,e]);let p=(0,X.useCallback)(()=>{l(e=>({...e,inFlight:!0})),i.probeProvider(e,km)},[i,e]),m=(0,X.useCallback)((e,t)=>{l(e=>({...e,picked:t})),a?.(e,t)},[a]),g=(0,X.useCallback)(()=>{f(!0)},[]),_=(0,X.useCallback)(()=>{f(!1)},[]),v=(0,X.useCallback)(()=>{f(!1);let t=n?[...n]:[];l(e=>({...e,picked:null,last:null})),o?o(e):i.clearProviderModels(e),im(t)&&J.undoable(rm(e,t.length),()=>{let n=Om({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]),y=(0,X.useMemo)(()=>c.picked??t??n?.[0]??``,[c.picked,t,n]),b=(0,X.useMemo)(()=>tm(c),[c]),x=(0,X.useMemo)(()=>nm(n),[n]);return(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(tn,{className:`h-3.5 w-3.5`}),u(`activity:providerModels.allowlistTitle`)]}),n&&n.length>0&&(0,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u(`activity:providerModels.using`)}),y?(0,Z.jsx)(`span`,{className:`max-w-full truncate rounded-md bg-primary/10 px-2 py-0.5 font-mono text-xs text-primary`,children:y}):(0,Z.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:u(`activity:providerModels.noModelPicked`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:justify-end`,children:[(0,Z.jsxs)(Y,{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,Z.jsx)(Rn,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(wr,{className:`h-3.5 w-3.5`}),c.inFlight?u(`activity:providerModels.probing`):u(`activity:providerModels.refresh`)]}),x&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:g,"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,Z.jsx)(jm,{formatted:b}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(Dm,{providerId:e,models:n??[],customModels:r,ws:i,pickedModelId:y??void 0,onPickModel:m})}),(0,Z.jsx)(Qp,{open:d,providerId:e,modelCount:n?.length??0,onConfirm:v,onCancel:_})]})}function jm({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,Z.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs ${t}`,"data-probe-tone":e.tone,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${n}`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}var Mm=[`anthropic`,`openai`,`google`,`openai-compatible`];function Nm({activeProvider:e,catalogProviders:t,isLoadingCatalog:n,savedProviders:r,isLoadingSaved:i,providerTab:a,setProviderTab:o,onSelectProvider:s,onAddKey:c,onDeleteKey:l,onSetActiveKey:u,onAddProvider:d,onRemoveProvider:f,onPickProviderModel:p,ws:m,catalogQuery:g,setCatalogQuery:_}){let{t:v}=h(),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(``),[w,T]=(0,X.useState)(``),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(``),[M,ee]=(0,X.useState)(`openai-compatible`),[N,te]=(0,X.useState)(``),[P,F]=(0,X.useState)(``),[I,ne]=(0,X.useState)([]),re=zp(),ie=zp(),L=(0,X.useCallback)(e=>{!S.trim()||!w.trim()||(c(e,S.trim(),w.trim()),C(``),T(``),x(null))},[c,S,w]),ae=(0,X.useCallback)(()=>{A.trim()&&(d(A.trim(),M,N||void 0,P||void 0,I.length>0?I.map(e=>e.id):void 0,I.length>0?Object.fromEntries(I.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(``),ee(`openai-compatible`),te(``),F(``),ne([]),k(!1))},[d,A,M,N,P,I]),oe=(0,X.useCallback)(e=>{j(e.id),ee(Kp),te(e.defaultBaseUrl),e.noAuth&&F(``),ne([])},[]),[se,ce]=(0,X.useState)(null),[le,ue]=(0,X.useState)(``),[de,fe]=(0,X.useState)(!1),[pe,me]=(0,X.useState)({}),he=(0,X.useMemo)(()=>new Set(r.map(e=>e.id)),[r]),ge=(0,X.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,X.useEffect)(()=>{let e=m.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;t.status!==`no_base_url`&&t.status!==`no_provider`&&me(e=>({...e,[t.providerId]:{ok:t.ok,status:t.status,detail:t.detail}}))});return()=>e?.()},[m]);let _e=(0,X.useCallback)(e=>{let t=le.trim();t&&(he.has(e.id)?c(e.id,`default`,t):d(e.id,e.family,e.apiBase??void 0,t),ue(``),ce(null),fe(!1),J.success(v(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>m.probeProvider(e.id,6e3),700))},[le,he,c,d,m]),ve=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,ye=ve.reduce((e,t)=>(e[t.family]||(e[t.family]=[]),e[t.family]?.push(t),e),{});return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Z.jsx)(Vt,{className:`h-4 w-4 text-muted-foreground`}),v(`settings:provider.subscriptionHeading`)]}),(0,Z.jsx)(Zp,{ws:m,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,Z.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-1 flex items-center gap-2`,children:[(0,Z.jsx)(gn,{className:`h-4 w-4 text-muted-foreground`}),v(`settings:provider.apiKeysHeading`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:v(`settings:provider.apiKeysBody`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,Z.jsxs)(Y,{variant:a===`catalog`?`default`:`outline`,size:`sm`,onClick:()=>o(`catalog`),children:[(0,Z.jsx)(gn,{className:`h-4 w-4 mr-1`}),v(`settings:provider.tabCatalog`)]}),(0,Z.jsxs)(Y,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>o(`saved`),children:[(0,Z.jsx)(Vt,{className:`h-4 w-4 mr-1`}),v(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Vi,{placeholder:v(`settings:provider.searchPlaceholder`,{count:t.length}),value:g,onChange:e=>_(e.target.value),className:`text-sm`}),n&&t.length===0?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(Rn,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:v(`settings:provider.loadingCatalog`)})]}):ve.length===0&&g?(0,Z.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:v(`settings:provider.noMatch`,{query:g})}):Mm.map(t=>{let n=ye[t];return n?.length?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider`,children:t}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:n.map(t=>{let n=pe[t.id],r=e===t.id;return(0,Z.jsxs)(`div`,{className:U(`rounded-lg border transition-all`,r?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border`),children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(t.id),className:U(`flex w-full flex-col items-start p-3 text-left rounded-lg`,!r&&`hover:bg-muted`),children:[(0,Z.jsxs)(`div`,{className:`flex w-full justify-between items-start`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.name}),(0,Z.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.hasApiKey&&(0,Z.jsxs)(`span`,{className:`text-xs bg-success/10 text-success px-2 py-0.5 rounded`,children:[(0,Z.jsx)(Vt,{className:`h-3 w-3 inline mr-1`}),v(`settings:provider.configured`)]}),n&&(0,Z.jsxs)(`span`,{className:U(`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,Z.jsx)(R,{className:`h-3 w-3`}):(0,Z.jsx)(kr,{className:`h-3 w-3`}),n.ok?v(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,Z.jsx)(R,{className:`h-4 w-4 text-primary`})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[v(`settings:provider.modelCount`,{count:t.modelCount}),t.apiBase&&` · ${t.apiBase}`]})]}),r&&!t.hasApiKey&&(0,Z.jsx)(`div`,{className:`px-3 pb-3 -mt-1 space-y-2`,children:se===t.id?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Vi,{autoFocus:!0,type:de?`text`:`password`,placeholder:v(`settings:provider.keyPlaceholder`,{name:t.name}),value:le,onChange:e=>ue(e.target.value),className:`text-sm`,onKeyDown:e=>{e.key===`Enter`&&_e(t)}}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>fe(e=>!e),children:de?(0,Z.jsx)(Bn,{className:`h-4 w-4`}):(0,Z.jsx)(en,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>_e(t),disabled:!le.trim(),children:v(`common:action.save`)})]}),t.envVars[0]&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>{ce(t.id),ue(``)},children:[(0,Z.jsx)(Vt,{className:`h-3.5 w-3.5 mr-1`}),v(`settings:provider.addApiKey`)]})})]},t.id)})})]},t):null})]}),a===`saved`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:v(`settings:provider.manageKeys`)}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(Pn,{className:`h-3.5 w-3.5`}),v(`settings:provider.savedProviderCount`,{count:r.length})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(Vt,{className:`h-3.5 w-3.5`}),v(`settings:provider.keyCount`,{count:ge.keys})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(At,{className:`h-3.5 w-3.5`}),v(`settings:provider.activeKeyCount`,{count:ge.activeKeys})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),v(`settings:provider.modelCount`,{count:ge.models})]})]})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>k(!O),children:[(0,Z.jsx)(at,{className:`h-4 w-4 mr-1`}),v(`settings:provider.addProvider`)]})]}),O&&(0,Z.jsxs)(`div`,{className:`p-4 border rounded-lg space-y-3 bg-muted/50`,children:[(0,Z.jsx)(`h4`,{className:`font-medium`,children:v(`settings:provider.addCustomHeading`)}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.localServers`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:qp.map(e=>(0,Z.jsx)(Y,{type:`button`,size:`sm`,variant:A===e.id?`default`:`outline`,onClick:()=>oe(e),title:e.hint,children:e.label},e.id))})]}),(0,Z.jsx)(Vi,{placeholder:v(`settings:provider.providerIdPlaceholder`),value:A,onChange:e=>j(e.target.value),ref:re.setFieldRef(0),onKeyDown:e=>re.handleKeyDown(e,0)}),(0,Z.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=>ee(e.target.value),ref:re.setFieldRef(1),onKeyDown:e=>re.handleKeyDown(e,1),children:[(0,Z.jsx)(`option`,{value:`anthropic`,children:v(`activity:provider.anthropic`)}),(0,Z.jsx)(`option`,{value:`openai`,children:v(`activity:provider.openai`)}),(0,Z.jsx)(`option`,{value:`openai-compatible`,children:v(`activity:provider.openaiCompatible`)}),(0,Z.jsx)(`option`,{value:`google`,children:v(`activity:provider.google`)})]}),(0,Z.jsx)(Vi,{placeholder:v(`activity:provider.baseUrlOptionalEGHttpLocalhost11434V1`),value:N,onChange:e=>te(e.target.value),ref:re.setFieldRef(2),onKeyDown:e=>re.handleKeyDown(e,2)}),(0,Z.jsx)(Vi,{type:`password`,placeholder:v(`settings:provider.apiKeyOptionalPlaceholder`),value:P,onChange:e=>F(e.target.value),ref:re.setFieldRef(3),onKeyDown:e=>re.handleKeyDown(e,3)}),(0,Z.jsx)(Jp,{models:I,onChange:ne}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:ae,disabled:!A.trim(),ref:re.setFieldRef(4),onKeyDown:e=>re.handleKeyDown(e,4,ae),children:v(`common:action.add`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>k(!1),ref:re.setFieldRef(5),onKeyDown:e=>re.handleKeyDown(e,5),children:v(`common:action.cancel`)})]})]}),i?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(Rn,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r.length===0?(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Vt,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:v(`settings:provider.noSaved`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:v(`settings:provider.noSavedHint`)})]}):r.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/80 bg-card/70 p-4 shadow-sm shadow-black/[0.02]`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-foreground`,children:e.id}),e.family&&(0,Z.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,Z.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,Z.jsx)(At,{className:`h-3 w-3`}),v(`settings:provider.active`)]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[e.baseUrl&&(0,Z.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,Z.jsx)(gn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.baseUrl})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),v(`settings:provider.modelCount`,{count:e.models?.length??0})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Z.jsx)(Vt,{className:`h-3.5 w-3.5`}),v(`settings:provider.keyCount`,{count:e.apiKeys.length})]})]})]}),(0,Z.jsx)(`div`,{className:`flex gap-2 sm:justify-end`,children:(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>f(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,Z.jsx)(_n,{className:`h-4 w-4 text-destructive`})})})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.85fr)]`,children:[(0,Z.jsx)(Am,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,savedCustomModels:e.customModels,ws:m,onPickModel:p}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:v(`settings:provider.apiKeysLabel`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>x(b===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),v(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!b&&(0,Z.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:v(`settings:provider.noKeys`)}),e.apiKeys.length>0&&(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.apiKeys.map(t=>(0,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Z.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,Z.jsx)(Vt,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),t.isActive&&(0,Z.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:v(`settings:provider.active`)})]}),(0,Z.jsx)(`div`,{className:`mt-0.5`,children:(0,Z.jsx)(Rp,{maskedKey:t.maskedKey})})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!t.isActive&&(0,Z.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.id,t.label),className:`h-8 px-2 text-xs`,children:v(`settings:provider.setActive`)}),(0,Z.jsx)(Y,{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,Z.jsx)(_n,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),b===e.id&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-border/70 bg-background p-3`,children:[(0,Z.jsx)(Vi,{placeholder:v(`settings:provider.keyLabelPlaceholder`),value:S,onChange:e=>C(e.target.value),ref:ie.setFieldRef(0),onKeyDown:e=>ie.handleKeyDown(e,0)}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Vi,{type:E?`text`:`password`,placeholder:v(`settings:provider.apiKeyPlaceholder`),value:w,onChange:e=>T(e.target.value),ref:ie.setFieldRef(1),onKeyDown:e=>ie.handleKeyDown(e,1)}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>D(!E),children:E?(0,Z.jsx)(Bn,{className:`h-4 w-4`}):(0,Z.jsx)(en,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:()=>L(e.id),disabled:!S.trim()||!w.trim(),ref:ie.setFieldRef(2),onKeyDown:t=>ie.handleKeyDown(t,2,()=>L(e.id)),children:v(`settings:provider.saveKey`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{x(null),C(``),T(``)},ref:ie.setFieldRef(3),onKeyDown:e=>ie.handleKeyDown(e,3),children:v(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var Pm=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}))})),Fm=Pm.map(e=>e.phase),Im=Pm.flatMap(e=>[...e.roles]),Lm=Im.map(e=>e.role),Rm=[`*`,...Fm,...Lm];function zm(e){if(e===`*`)return`Default (*)`;let t=Pm.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=Im.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var Bm=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],Vm=[{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`}],Um=new Set(Rm);function Wm(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 Gm(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 Km({syncPref:e,candidates:t}){let n=B(),{t:r}=h(),[i,a]=(0,X.useState)(`*`),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(``),m=(0,X.useCallback)(t=>e(`modelMatrix`,t),[e]),g=(0,X.useCallback)(()=>{let e=i.trim(),t=o.trim(),r=Wm(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]),_=(0,X.useCallback)(e=>{let{[e]:t,...r}=n.modelMatrix;m(r)},[n.modelMatrix,m]),v=(0,X.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]),y=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}`:``,...Gm(n)].filter(Boolean).join(` + `)},b=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!Um.has(e)))).sort((e,t)=>e.localeCompare(t));return(0,Z.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Z.jsx)(fr,{className:`h-4 w-4 text-muted-foreground`}),r(`settings:agent.routingHeading`)]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,180px)_1fr_auto]`,children:[(0,Z.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,Z.jsx)(`option`,{value:`*`,children:zm(`*`)}),(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:Pm.map(e=>(0,Z.jsx)(`option`,{value:e.phase,children:zm(e.phase)},e.phase))}),Pm.map(e=>(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingRolesGroup`,{label:e.label}),children:e.roles.map(e=>(0,Z.jsx)(`option`,{value:e.role,children:zm(e.role)},e.role))},e.phase)),b.length>0?(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingCustomGroup`),children:b.map(e=>(0,Z.jsx)(`option`,{value:e,children:zm(e)},e))}):null]}),(0,Z.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,Z.jsx)(`option`,{value:``,children:r(`settings:agent.routingTargetEmpty`)}),Object.keys(n.fallbackProfiles).length>0&&(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetProfilesGroup`),children:Object.keys(n.fallbackProfiles).map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),t&&t.length>0&&(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetModelsGroup`),children:t.map(e=>(0,Z.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.provider,`/`,e.model]},`${e.provider}/${e.model}`))})]}),(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:g,children:r(`settings:agent.routingSet`)})]}),(0,Z.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Z.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:Bm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Vm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:Object.keys(n.modelMatrix).length===0?(0,Z.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,Z.jsxs)(`div`,{className:`rounded-md border border-border bg-muted px-2 py-1.5 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-40 shrink-0 truncate font-mono text-muted-foreground`,title:e,children:zm(e)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:y(t)}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>_(e),children:r(`common:action.remove`)})]}),(0,Z.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeFor`,{key:e}),value:t.modelRuntime?.reasoning?.mode??``,onChange:t=>v(e,`mode`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:Bm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortFor`,{key:e}),value:t.modelRuntime?.reasoning?.effort??``,onChange:t=>v(e,`effort`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:Vm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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=>v(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,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}var qm=[`off`,`low`,`medium`,`high`,`all`],Jm={off:`bg-muted-foreground`,low:`bg-success`,medium:`bg-warning`,high:`bg-warning ring-2 ring-warning/25`,all:`bg-destructive`},Ym={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`},Xm=[`executor`,`skeptic`,`auditor`];function Zm(e){return e&&e.length>0?e.map(e=>({id:e.id,name:e.name,description:e.description})):Xm.map(e=>({id:e,name:e}))}var Qm=[{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`}],$m=[{value:`off`,labelKey:`settings:brainOpt.waitForever`},{value:`30000`,label:`30s`},{value:`60000`,label:`1m`},{value:`120000`,label:`2m`},{value:`300000`,label:`5m`}],eh=[{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`}],th=[{value:`100`,label:`100`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],nh=[{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`}],rh=[{value:`10`,label:`10`},{value:`20`,labelKey:`settings:brainOpt.n20Default`},{value:`50`,label:`50`},{value:`100`,label:`100`}],ih=[{value:`60000`,label:`1m`},{value:`300000`,labelKey:`settings:brainOpt.m5Default`},{value:`900000`,label:`15m`},{value:`3600000`,label:`1h`}],ah=[{value:`50`,label:`50`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`}],oh=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],sh=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.oneSerial`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],ch=[{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`}],lh=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`200`,label:`200`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],uh=[{value:`default`,labelKey:`settings:brainOpt.default500`},{value:`100`,label:`100`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`5000`,label:`5000`}],dh=[{value:`default`,labelKey:`settings:brainOpt.default10m`},{value:`120000`,label:`2m`},{value:`600000`,label:`10m`},{value:`1800000`,label:`30m`},{value:`3600000`,label:`1h`}];function fh(e,t){return e.some(e=>e.value===t)?e:[...e,{value:t,label:t}]}function ph(e,t){return e.map(e=>({value:e.value,label:e.labelKey?t(e.labelKey):e.label??e.value}))}function mh(e){return e===void 0?`default`:String(e)}function hh({level:e}){return(0,Z.jsx)(`span`,{className:U(`inline-block h-2.5 w-2.5 rounded-full`,Jm[e])})}function gh(e){return e.provider?`${e.provider}/${e.model}`:e.model}var _h={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 vh(){let{t:e}=h(),{client:t}=Hr(),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!0),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null);(0,X.useEffect)(()=>{t.send({type:`brain.status`}),t.send({type:`brain.config.get`})},[t]),(0,X.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,X.useCallback)(e=>{l(!0),t.send({type:`brain.config.set`,payload:{patch:e}})},[t]),g=(0,X.useCallback)(e=>{r(t=>t&&{...t,maxAutoRisk:e}),m({maxAutoRisk:e})},[m]),_=(0,X.useMemo)(()=>n?.council.voters??[],[n]),v=(0,X.useCallback)(e=>{m({council:{voters:e.length>0?e:null}})},[m]),y=(0,X.useMemo)(()=>Zm(n?.personaCatalog),[n?.personaCatalog]),b=qm.includes(n?.maxAutoRisk??``)?n?.maxAutoRisk??`medium`:`medium`,x=(0,X.useCallback)(e=>{if(!n||!f)return;let t=`${e.provider}/${e.model}`;if(f===`pool`){m({models:[...n.models.map(gh),t]});return}if(f===`judge`){m({council:{judge:t}});return}return v([..._,{provider:e.provider,model:e.model,persona:y[_.length%y.length]?.id??`executor`}]),!0},[n,y,f,m,v,_]);return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Wf,{open:f!==null,mode:`provider-model`,title:f?e(_h[f].title):``,hint:f?e(_h[f].hint):void 0,onPick:e=>{if(e.type===`provider-model`)return x(e)},onClose:()=>p(null)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.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,Z.jsx)(cr,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`settings:brain.heading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.headingHint`)})]}),(o||c)&&(0,Z.jsx)(Rn,{className:`ml-auto h-4 w-4 animate-spin text-muted-foreground`})]}),u&&(0,Z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:u}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.riskHeading`)}),(0,Z.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:qm.map(e=>(0,Z.jsxs)(Y,{variant:b===e?`default`:`outline`,size:`sm`,className:U(`gap-1.5 text-xs`,b===e&&`shadow-sm`),disabled:c,onClick:()=>g(e),children:[(0,Z.jsx)(hh,{level:e}),e.toUpperCase()]},e))}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(Ym[b])})]}),n&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.escalationHeading`)}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.escalationDecisionTimeoutLabel`),hint:e(`settings:brain.escalationDecisionTimeoutHint`),value:n.decisionTimeoutMs?String(n.decisionTimeoutMs):`default`,options:ph(Qm,e),onChange:e=>m({decisionTimeoutMs:e==="default"?null:Number(e)}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationHumanTimeoutLabel`),hint:e(`settings:brain.escalationHumanTimeoutHint`),value:n.humanTimeoutMs?String(n.humanTimeoutMs):`off`,options:ph($m,e),onChange:e=>m({humanTimeoutMs:e===`off`?null:Number(e)}),disabled:c}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.escalationDecisionLogSizeLabel`),hint:e(`settings:brain.escalationDecisionLogSizeHint`),value:String(n.decisionLogMaxEntries),options:ph(fh(rh,String(n.decisionLogMaxEntries)),e),onChange:e=>m({decisionLogMaxEntries:Number(e)}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.rulesHeading`)}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.rulesConfigured`,{count:n.rules.length})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.rulesBody`)}),n.rules.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:n.rules.map((t,n)=>(0,Z.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,Z.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[n+1,`.`]}),(0,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:t.id}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px] shrink-0`,children:t.then.action}),t.enabled===!1&&(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px] shrink-0`,children:e(`settings:brain.rulesOff`)})]},`${t.id}-${n}`))}),n.ruleErrors.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-warning`,children:e(`settings:brain.rulesDropped`,{count:n.ruleErrors.length})}),n.ruleErrors.map(e=>(0,Z.jsx)(`p`,{className:`text-xs text-warning`,children:e},e))]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.heuristicsHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsBody`)}),(0,Z.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,Z.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,Z.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,Z.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,Z.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,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsMarkers`,{markers:n.heuristics.blockedResolvedMarkers.join(`, `)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.qualityHeading`)}),n.circuit&&(0,Z.jsx)(Ep,{variant:n.circuit.state===`closed`?`outline`:`default`,className:`text-[10px]`,children:e(`settings:brain.qualityCircuit`,{state:n.circuit.state,count:n.circuit.consecutiveFailures})})]}),(0,Z.jsx)(Q,{label:e(`settings:brain.qualityResponseBudgetLabel`),hint:e(`settings:brain.qualityResponseBudgetHint`),value:String(n.llm.maxTokens),options:ph(fh(th,String(n.llm.maxTokens)),e),onChange:e=>m({llm:{maxTokens:Number(e)}}),disabled:c}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.qualityMinConfidenceLabel`),hint:e(`settings:brain.qualityMinConfidenceHint`),value:String(n.llm.minConfidence),options:ph(fh(nh,String(n.llm.minConfidence)),e),onChange:e=>m({llm:{minConfidence:Number(e)}}),disabled:c}),(0,Z.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,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.traceHeading`)}),(0,Z.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,Z.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,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.trace.path})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.cacheHeading`)}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.cacheStats`,{hits:n.cache.hits,misses:n.cache.misses,size:n.cache.size})})]}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.cacheLifetimeLabel`),hint:e(`settings:brain.cacheLifetimeHint`),value:String(n.cache.ttlMs),options:ph(fh(ih,String(n.cache.ttlMs)),e),onChange:e=>m({cache:{ttlMs:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.cacheMaxEntriesLabel`),hint:e(`settings:brain.cacheMaxEntriesHint`),value:String(n.cache.maxEntries),options:ph(fh(ah,String(n.cache.maxEntries)),e),onChange:e=>m({cache:{maxEntries:Number(e)}}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.monitorHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.monitorBody`)}),(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.modelsHeading`)}),(0,Z.jsx)(Ep,{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,Z.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,Z.jsx)(`div`,{className:`space-y-1`,children:n.models.map((e,t)=>(0,Z.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,Z.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[t+1,`.`]}),(0,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:gh(e)}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===0,onClick:()=>{let e=n.models.map(gh),r=e.splice(t,1)[0];r&&e.splice(t-1,0,r),m({models:e})},children:(0,Z.jsx)(Rt,{className:`h-3 w-3`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===n.models.length-1,onClick:()=>{let e=n.models.map(gh),r=e.splice(t,1)[0];r&&e.splice(t+1,0,r),m({models:e})},children:(0,Z.jsx)(S,{className:`h-3 w-3`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>{let e=n.models.map(gh).filter((e,n)=>n!==t);m({models:e.length>0?e:null})},children:(0,Z.jsx)(Jt,{className:`h-3 w-3`})})]},`${gh(e)}-${t}`))}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`pool`),children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.modelsAddModel`)]}),n.models.length>1&&(0,Z.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,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.councilHeading`)}),(0,Z.jsx)(Ep,{variant:n.council.enabled?`default`:`outline`,className:`text-[10px]`,children:n.council.enabled?e(`settings:brain.councilConvened`):e(`settings:brain.councilDisabled`)})]}),(0,Z.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&&_.length===0&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.councilSeatsDerived`,{seats:n.councilLabels.join(`, `)})}),_.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:_.map((t,n)=>(0,Z.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,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:gh(t)}),(0,Z.jsxs)(`select`,{value:t.persona??y[n%y.length]?.id??``,onChange:e=>v(_.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,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)),t.persona&&!y.some(e=>e.id===t.persona)&&(0,Z.jsx)(`option`,{value:t.persona,children:e(`settings:brain.councilCustomOption`,{persona:t.persona})})]}),(0,Z.jsx)(Y,{variant:t.veto?`default`:`outline`,size:`sm`,className:`h-6 px-1.5 text-[10px]`,disabled:c,onClick:()=>v(_.map((e,t)=>t===n?{...e,veto:!e.veto}:e)),children:e(`settings:brain.councilVeto`)}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>v(_.filter((e,t)=>t!==n)),children:(0,Z.jsx)(Jt,{className:`h-3 w-3`})})]},`${gh(t)}-${n}`))}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`voter`),children:[(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.councilAddVoter`)]}),(0,Z.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,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium`,children:e(`settings:brain.councilJudge`)}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`settings:brain.councilJudgeDesc`)}),!n.council.judge&&n.judgeLabel&&(0,Z.jsxs)(`div`,{className:`mt-0.5 font-mono text-xs text-muted-foreground`,children:[e(`settings:brain.councilResolved`,{model:n.judgeLabel}),n.judgeIsVoter&&(0,Z.jsx)(`span`,{className:`ml-1 font-sans text-warning`,children:e(`settings:brain.councilAlsoVoter`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`max-w-[180px] truncate font-mono text-xs`,children:n.council.judge?gh(n.council.judge):e(`settings:brain.councilAuto`)}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>p(`judge`),children:e(`settings:brain.councilPick`)}),n.council.judge&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>m({council:{judge:null}}),children:e(`settings:brain.councilAutoReset`)})]})]}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilQuorumLabel`),hint:e(`settings:brain.councilQuorumHint`),value:n.council.quorum===void 0?`default`:String(n.council.quorum),options:ph(eh,e),onChange:e=>m({council:{quorum:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilApprovalLabel`),hint:e(`settings:brain.councilApprovalHint`),value:n.council.approval===void 0?`default`:String(n.council.approval),options:ph(eh,e),onChange:e=>m({council:{approval:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilPerSeatTimeoutLabel`),hint:e(`settings:brain.councilPerSeatTimeoutHint`),value:mh(n.council.perCallTimeoutMs),options:ph(fh(oh,mh(n.council.perCallTimeoutMs)),e),onChange:e=>m({council:{perCallTimeoutMs:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilMaxConcurrencyLabel`),hint:e(`settings:brain.councilMaxConcurrencyHint`),value:mh(n.council.maxConcurrency),options:ph(fh(sh,mh(n.council.maxConcurrency)),e),onChange:e=>m({council:{maxConcurrency:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.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,Z.jsx)(Q,{label:e(`settings:brain.councilVoterBudgetLabel`),hint:e(`settings:brain.councilVoterBudgetHint`),value:mh(n.council.voterMaxTokens),options:ph(fh(ch,mh(n.council.voterMaxTokens)),e),onChange:e=>m({council:{voterMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilJudgeBudgetLabel`),hint:e(`settings:brain.councilJudgeBudgetHint`),value:mh(n.council.judgeMaxTokens),options:ph(fh(lh,mh(n.council.judgeMaxTokens)),e),onChange:e=>m({council:{judgeMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),n.council.seats.length>0&&(0,Z.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,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.ledgerHeading`)}),(0,Z.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,Z.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,Z.jsx)(Q,{label:e(`settings:brain.ledgerMemoryEntriesLabel`),hint:e(`settings:brain.ledgerMemoryEntriesHint`),value:mh(n.ledger.maxMemoryEntries),options:ph(fh(uh,mh(n.ledger.maxMemoryEntries)),e),onChange:e=>m({ledger:{maxMemoryEntries:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.ledgerRetryWindowLabel`),hint:e(`settings:brain.ledgerRetryWindowHint`),value:mh(n.ledger.interventionRetryWindowMs),options:ph(fh(dh,mh(n.ledger.interventionRetryWindowMs)),e),onChange:e=>m({ledger:{interventionRetryWindowMs:e==="default"?null:Number(e)}}),disabled:c}),n.ledger.path&&(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.ledger.path})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.recentHeading`,{count:i.length})}),(0,Z.jsx)(`div`,{className:`space-y-1 max-h-[300px] overflow-y-auto`,children:i.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground py-2`,children:e(`settings:brain.recentEmpty`)}):i.map(e=>(0,Z.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,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-8`,children:e.age}),(0,Z.jsx)(Ep,{variant:`outline`,className:`text-[10px] shrink-0`,children:e.kind}),(0,Z.jsx)(`span`,{className:`flex-1 truncate`,children:e.question}),e.outcome&&(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 italic`,children:e.outcome})]},`${e.age}-${e.kind}-${e.question.slice(0,32)}`))})]})]})}function yh(){let{t:e}=h();return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(en,{className:`h-5 w-5 text-info`}),(0,Z.jsx)(`h3`,{className:`text-lg font-semibold`,children:e(`activity:shadow.shadowAgent`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`activity:shadow.theShadowAgentMonitorsAllFleet`)}),(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Start and stop it from the chat with`,` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow start`}),` and`,` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow stop`}),`. This panel cannot control it yet.`]})]})}function bh({disabled:e,direct:t}){let n=e?`bg-muted-foreground`:t?`bg-success`:`bg-info`,r=e?`disabled`:t?`direct provider tool`:`lazy catalog tool`;return(0,Z.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full ${n}`,title:r})}function xh({tool:e,onToggle:t,busy:n}){let{t:r}=h(),[i,a]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,Z.jsx)(bh,{disabled:e.disabled,direct:e.direct}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`code`,{className:`block truncate text-sm font-mono font-semibold`,title:e.name,children:e.name}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(Ep,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,Z.jsx)(Ep,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,Z.jsx)(Ep,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.disabled?`disabled`:e.direct?`direct`:`lazy`}),(0,Z.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:e.owner,children:e.owner})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[(0,Z.jsxs)(Y,{variant:e.disabled?`default`:`secondary`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:t,disabled:n,children:[n?(0,Z.jsx)(Rn,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,Z.jsx)(_r,{className:`h-3 w-3`}):(0,Z.jsx)(b,{className:`h-3 w-3`}),e.disabled?`Enable`:`Disable`]}),(0,Z.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,Z.jsx)(Nn,{className:`h-4 w-4 transition-transform ${i?`rotate-180`:``}`})})]})]}),i&&(0,Z.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2 text-xs text-muted-foreground sm:ml-4`,children:[(0,Z.jsx)(`p`,{children:e.description}),e.params.length>0&&(0,Z.jsxs)(`p`,{children:[r(`activity:toolsSec.params`),` `,(0,Z.jsx)(`code`,{className:`break-all font-mono`,children:e.params.join(`, `)})]})]})]})}function Sh(){let{t:e}=h(),{client:t}=Hr(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(new Set);(0,X.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}):J.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,X.useEffect)(()=>{t.send({type:`tools.list`},{echoToChat:!1})},[t]);let u=(0,X.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&&e.direct).length,p=n.filter(e=>!e.disabled&&!e.direct).length,m=n.filter(e=>e.disabled).length;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.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,Z.jsx)(nn,{className:`h-5 w-5`})}),(0,Z.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`activity:toolsSec.tools`)})]}),!i&&(0,Z.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,` direct · `,p,` lazy · `,m,` disabled · `,n.length,` `,`total`]})]}),(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(Ft,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Vi,{placeholder:e(`activity:toolsSec.filterToolsByNameOrOwner`),value:o,onChange:e=>s(e.target.value),className:`pl-8 h-9 text-sm`})]}),i?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground gap-2`,children:[(0,Z.jsx)(Rn,{className:`h-4 w-4 animate-spin`}),e(`activity:toolsSec.loadingTools`)]}):d.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:o?`No tools matching "${o}".`:`No tools registered.`}):(0,Z.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border/70 bg-background/35 shadow-inner`,children:[(0,Z.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,Z.jsx)(`li`,{children:(0,Z.jsx)(xh,{tool:e,onToggle:()=>u(e.name,e.disabled),busy:c.has(e.name)})},e.name))}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-4 bg-gradient-to-b from-background/90 to-transparent`}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-background/95 to-transparent`})]})]})}function Ch(){let{t:e}=h();return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.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,Z.jsx)(en,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.brainHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.brainHint`)})]})]}),(0,Z.jsx)(vh,{})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.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,Z.jsx)(en,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.shadowHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.shadowHint`)})]})]}),(0,Z.jsx)(yh,{})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.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,Z.jsx)(en,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.toolsHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.toolsHint`)})]})]}),(0,Z.jsx)(Sh,{})]})]})}var wh=[{id:`general`,icon:(0,Z.jsx)(Je,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.general`,descKey:`settings:tabs.generalDesc`},{id:`provider`,icon:(0,Z.jsx)(ft,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.provider`,descKey:`settings:tabs.providerDesc`},{id:`connection`,icon:(0,Z.jsx)(gn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.connection`,descKey:`settings:tabs.connectionDesc`},{id:`agent`,icon:(0,Z.jsx)(On,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.agent`,descKey:`settings:tabs.agentDesc`},{id:`execution`,icon:(0,Z.jsx)(lr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.execution`,descKey:`settings:tabs.executionDesc`},{id:`fallbacks`,icon:(0,Z.jsx)(fr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fallbacks`,descKey:`settings:tabs.fallbacksDesc`},{id:`routing`,icon:(0,Z.jsx)(En,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.routing`,descKey:`settings:tabs.routingDesc`},{id:`fleet`,icon:(0,Z.jsx)(Bt,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fleet`,descKey:`settings:tabs.fleetDesc`},{id:`integrations`,icon:(0,Z.jsx)($e,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.integrations`,descKey:`settings:tabs.integrationsDesc`},{id:`chimera`,icon:(0,Z.jsx)(cr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.chimera`,descKey:`settings:tabs.chimeraDesc`},{id:`context`,icon:(0,Z.jsx)(We,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.context`,descKey:`settings:tabs.contextDesc`},{id:`logs`,icon:(0,Z.jsx)(Cn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.logs`,descKey:`settings:tabs.logsDesc`},{id:`security`,icon:(0,Z.jsx)(qn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.security`,descKey:`settings:tabs.securityDesc`},{id:`display`,icon:(0,Z.jsx)(Je,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.display`,descKey:`settings:tabs.displayDesc`}];function Th(){let{settingsActiveTab:e,setSettingsActiveTab:t}=K(he(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),n=Sf(`settings`),r=(0,X.useRef)(!1),[i,a]=(0,X.useState)(!1),{provider:o,model:s,setProvider:c,setModel:l,wsConnected:u}=G(he(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),d=Hr(),f=d.client,{updatePrefs:p,switchAutonomy:m}=d,g=B(),{t:_}=h(),v=Yi(!0),b=(0,X.useCallback)((e,t)=>{g.set({[e]:t}),p({[e]:t})},[g,p]),[x,S]=(0,X.useState)([]),[C,w]=(0,X.useState)({}),[T,E]=(0,X.useState)([]),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[ee,N]=(0,X.useState)(`catalog`),[te,P]=(0,X.useState)(``),[F,I]=(0,X.useState)(!1),ne=(0,X.useCallback)(()=>{g.reset(),I(!1),window.location.reload()},[g]),re=x.find(e=>e.id===o),ie=wh.find(t=>t.id===e);(0,X.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;S(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),O(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;w(e=>({...e,[t.provider]:t.models})),A(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));E(t),M(!1),t.length>0&&N(`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 O(!0),M(!0),f.listProviders(),f.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[u,f]);let L=(0,X.useCallback)(e=>{c(e),C[e]||(A(!0),d.listProviderModels?.(e))},[C,c,d]),ae=(0,X.useCallback)(async e=>{if(r.current)return;let t=G.getState().model,n=G.getState().provider;if(!(!n||e===t)){r.current=!0,a(!0),l(e);try{J.info(z.t(`settings:toast.switchingTo`,{provider:n,model:e}));let r=await d.switchModel?.(n,e);r?.success?J.success(z.t(r.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${n} / ${t}`,to:`${n} / ${e}`})):(l(t),J.error(r?.message??z.t(`settings:toast.modelSwitchTimeout`)))}finally{r.current=!1,a(!1)}}},[l,d]),oe=(0,X.useCallback)((e,t,n)=>{d.addKey?.(e,t,n)},[d]),se=(0,X.useCallback)((e,t)=>{d.deleteKey?.(e,t)},[d]),R=(0,X.useCallback)((e,t)=>{d.setActiveKey?.(e,t)},[d]),ce=(0,X.useCallback)((e,t,n,r,i,a)=>{d.addProvider?.(e,t,n,r,i,a)},[d]),le=(0,X.useCallback)(e=>{d.removeProvider?.(e)},[d]),ue=(0,X.useCallback)((e,t)=>{d.client.updateProvider({id:e,models:[t]}),e===G.getState().provider&&l(t)},[l,d.client]);return(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.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,Z.jsx)(Xn,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold bg-gradient-to-r from-foreground to-foreground/70 bg-clip-text text-transparent`,children:_(`settings:title`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:o&&s?`${o} / ${s}`:_(`settings:subtitle`)})]})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:()=>q(`chat`),children:(0,Z.jsx)(Jt,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>I(!0),children:_(`settings:resetLabel`)})]}),(0,Z.jsx)(Xa,{className:`min-h-0 flex-1`,ref:n,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-7xl p-4 sm:p-6`,children:(0,Z.jsxs)(Qa,{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,Z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Z.jsx)($a,{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:wh.map(e=>(0,Z.jsxs)(eo,{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,Z.jsx)(`span`,{className:`shrink-0`,children:e.icon}),(0,Z.jsx)(`span`,{className:`truncate`,children:_(e.labelKey)})]},e.id))}),(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`min-w-0 space-y-0`,children:[ie?.descKey&&(0,Z.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,Z.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:ie.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold`,children:_(ie.labelKey)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:_(ie.descKey)})]})]}),(0,Z.jsx)(to,{value:`general`,className:`mt-0`,children:(0,Z.jsx)(np,{})}),(0,Z.jsxs)(to,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,Z.jsx)(Nm,{activeProvider:o,catalogProviders:x,isLoadingCatalog:D,savedProviders:T,isLoadingSaved:j,providerTab:ee,setProviderTab:N,onSelectProvider:L,onAddKey:oe,onDeleteKey:se,onSetActiveKey:R,onAddProvider:ce,onRemoveProvider:le,onPickProviderModel:ue,ws:d.client,catalogQuery:te,setCatalogQuery:P}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-4 flex items-center gap-2`,children:[(0,Z.jsx)(y,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:model.heading`)]}),(0,Z.jsx)(Lp,{provider:o,catalogModels:C,currentCatalogProvider:re,isLoadingModels:k,setIsLoadingModels:A,onModelSelect:ae,isSwitching:i,refreshModels:e=>d.listProviderModels?.(e)})]})]}),(0,Z.jsx)(to,{value:`connection`,className:`mt-0`,children:(0,Z.jsx)(tp,{})}),(0,Z.jsx)(to,{value:`agent`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Kf,{syncPref:b,switchAutonomy:m})}),(0,Z.jsx)(to,{value:`execution`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(_p,{syncPref:b,fallbackCandidates:v})}),(0,Z.jsx)(to,{value:`fallbacks`,className:`mt-0`,children:(0,Z.jsx)(Cp,{syncPref:b,candidates:v,provider:o,activeModel:s,setProvider:c,setModel:l,switchModel:d.switchModel})}),(0,Z.jsx)(to,{value:`routing`,className:`mt-0`,children:(0,Z.jsx)(Km,{syncPref:b,candidates:v})}),(0,Z.jsx)(to,{value:`fleet`,className:`mt-0`,children:(0,Z.jsx)(wp,{syncPref:b})}),(0,Z.jsx)(to,{value:`integrations`,className:`mt-0`,children:(0,Z.jsx)(Fp,{syncPref:b})}),(0,Z.jsx)(to,{value:`chimera`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:(0,Z.jsx)(rp,{syncPref:b,sessionProvider:o,sessionModel:s})})}),(0,Z.jsx)(to,{value:`context`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(lp,{syncPref:b})}),(0,Z.jsx)(to,{value:`logs`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Ip,{syncPref:b})}),(0,Z.jsx)(to,{value:`security`,className:`mt-0`,children:(0,Z.jsx)(Ch,{})}),(0,Z.jsx)(to,{value:`display`,className:`mt-0`,children:(0,Z.jsx)(mp,{syncPref:b})})]})]})})}),(0,Z.jsx)(Bi,{open:F,onOpenChange:I,children:(0,Z.jsxs)(Li,{showCloseButton:!1,children:[(0,Z.jsxs)(Fi,{children:[(0,Z.jsx)(Ri,{children:_(`settings:resetConfirmTitle`)}),(0,Z.jsx)(zi,{children:_(`settings:resetConfirmBody`)})]}),(0,Z.jsxs)(Ii,{className:`gap-2 sm:gap-0`,children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>I(!1),children:_(`settings:cancel`)}),(0,Z.jsx)(Y,{variant:`destructive`,onClick:ne,children:_(`settings:resetConfirmAction`)})]})]})})]})}var Eh=(0,X.lazy)(()=>V(()=>import(`./AnalyticsDashboard-B5nVNt6L.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]))),Dh=(0,X.lazy)(()=>V(()=>import(`./AgentRosterView-CIUKmLsb.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]))),Oh=(0,X.lazy)(()=>V(()=>import(`./ChangesView-mapTz0_T.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]))),kh=(0,X.lazy)(()=>V(()=>import(`./ChronicleDashboard-DUzceZNb.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]))),Ah=(0,X.lazy)(()=>V(()=>import(`./CodeEditor-OjU9rotb.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]))),jh=(0,X.lazy)(()=>V(()=>import(`./CodeMap-BB1WETLd.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]))),Mh=(0,X.lazy)(()=>V(()=>import(`./DebugDashboard-BwSbR59I.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([41,1,2,3,4,5,6,10,11,12,13,14,15,16,17]))),Nh=(0,X.lazy)(()=>V(()=>import(`./DesignGalleryView-DLKWmyVp.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]))),Ph=(0,X.lazy)(()=>V(()=>import(`./GoalView-BtSGdftD.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]))),Fh=(0,X.lazy)(()=>V(()=>import(`./KanbanView-CyVG4DQu.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,27,30,18,24,25,26,47]))),Ih=(0,X.lazy)(()=>V(()=>import(`./MailboxDetailView-2NJVLrjb.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]))),Lh=(0,X.lazy)(()=>V(()=>import(`./OfficeMapPanel-BKHjEIu9.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]))),Rh=(0,X.lazy)(()=>V(()=>import(`./PromptJournalView-0F-HTGHg.js`).then(e=>({default:e.PromptJournalView})),__vite__mapDeps([51,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8]))),zh=(0,X.lazy)(()=>V(()=>import(`./RefreshDebugView-CuKbgI-T.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([52,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,8,23]))),Bh=(0,X.lazy)(()=>V(()=>import(`./SageTabs-B-m4WBoA.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([53,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7]))),Vh=(0,X.lazy)(()=>V(()=>import(`./RequirementIntakeView-DnNSLw78.js`).then(e=>({default:e.RequirementIntakeView})),__vite__mapDeps([54,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,38,45]))),Hh=(0,X.lazy)(()=>V(()=>import(`./SddHub-DZCKF3Gw.js`).then(e=>({default:e.SddHub})),__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,27,38,30,47,56]))),Uh=(0,X.lazy)(()=>V(()=>import(`./SessionsDashboard-DoAbZStd.js`).then(e=>({default:e.SessionsDashboard})),__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,58,44,27,38,45]))),Wh=(0,X.lazy)(()=>V(()=>import(`./SessionInspectView-Cf4ypYKn.js`).then(e=>({default:e.SessionInspectView})),__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,58,44,27,38,45]))),Gh=(0,X.lazy)(()=>V(()=>import(`./SkillDetailView-sVjQG3qG.js`).then(e=>({default:e.SkillDetailView})),__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,33]))),Kh=(0,X.lazy)(()=>V(()=>import(`./TechStackView-iONTty84.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([61,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7,21,19,0,8,20,22,23,38,45]))),qh=(0,X.lazy)(()=>V(()=>import(`./DeadCodeScanPanel-nlQ9nL3Y.js`).then(e=>({default:e.DeadCodeScanPanel})),__vite__mapDeps([62,1,2,3,4,5,6,10,11,12,13,14,15,16,17]))),Jh=(0,X.lazy)(()=>V(()=>import(`./vector-memory-panel-D1zQSMIW.js`).then(e=>({default:e.VectorMemoryPanel})),__vite__mapDeps([63,1,2,3,4,5,6])));function Yh({sessionId:e,desktopShell:t}){let{t:n}=h(),{currentView:r,terminalOpen:i,setTerminalOpen:a}=K(he(e=>({currentView:e.currentView,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen})));return(0,Z.jsxs)(Z.Fragment,{children:[r===`chat`&&(0,Z.jsxs)(Z.Fragment,{children:[e&&(0,Z.jsx)(`div`,{className:`ws-workspace-dock-wrap shrink-0 px-3 pt-2 sm:px-4`,children:(0,Z.jsx)(Rl,{})}),(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.chat`),children:(0,Z.jsx)(xf,{})})]}),r===`settings`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.settings`),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Th,{})})}),r===`memory`&&(0,Z.jsxs)(Ms,{level:`panel`,name:n(`activity:panels.sageMemory`),children:[(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sageMemory`)})}),children:(0,Z.jsx)(Bh,{})}),(0,Z.jsx)(Jh,{})]}),r===`roster`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.agentRoster`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.agentRoster`)})}),children:(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(Dh,{})})})}),r===`context`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.contextDashboard`),children:(0,Z.jsx)(Vf,{})}),r===`setup`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.setup`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Xh,{})})})}),r===`goal`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.goal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Ph,{onClose:()=>q(`chat`)})})})}),r===`sddhub`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.sddHub`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Hh,{})})})}),r===`kanban`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.kanban`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Fh,{onClose:()=>q(`chat`)})})})}),r===`sessions`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.sessions`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Uh,{})})})}),r===`session-inspect`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.sessionInspect`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sessionInspect`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Wh,{})})})}),r===`chronicle`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.chronicle`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(kh,{})})})}),r===`intake`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.requirementsIntake`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Vh,{})})})}),r===`prompts`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:nav.prompts`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:nav.prompts`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Rh,{})})})}),r===`debug`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.debugDashboard`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Mh,{})})})}),r===`refresh-debug`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.refreshDebug`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(zh,{})})})}),r===`files`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.editor`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.editor`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Ah,{})})})}),r===`changes`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.changes`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.changes`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Oh,{className:`h-full min-h-0`})})})}),r===`mailbox`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.mailbox`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Ih,{className:`h-full min-h-0`})})})}),r===`design-gallery`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.designGallery`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Nh,{className:`h-full`})})})}),r===`skill`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.skill`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Gh,{className:`h-full`})})})}),r===`officemap`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.officeMap`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.officeMap`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Lh,{})})})}),r===`analytics`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.analytics`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Eh,{})})})}),r===`codemap`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.codemap`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.codemap`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(jh,{})})})}),r===`techstack`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.techstack`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.techstack`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Kh,{})})})}),r===`deadcode`&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.deadcode`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.deadcode`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto`,children:(0,Z.jsx)(qh,{})})})}),i&&(0,Z.jsx)(Ms,{level:`panel`,name:n(`activity:panels.terminal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Hf,{label:n(`common:loadingNamed`,{name:n(`activity:panels.terminal`)})}),children:(0,Z.jsx)(Zh,{desktopShell:t,onClose:()=>a(!1)})})})]})}var Xh=(0,X.lazy)(()=>V(()=>import(`./SetupScreen-CMrLwoo9.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([64,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]))),Zh=(0,X.lazy)(()=>V(()=>import(`./TerminalPanel-1mqoe2_8.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([65,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,66,67])));(0,X.lazy)(()=>V(()=>import(`./AnalyticsDashboard-B5nVNt6L.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,X.lazy)(()=>V(()=>import(`./CodeMap-BB1WETLd.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,X.lazy)(()=>V(()=>import(`./ChronicleDashboard-DUzceZNb.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,X.lazy)(()=>V(()=>import(`./GoalView-BtSGdftD.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,X.lazy)(()=>V(()=>import(`./ChangesView-mapTz0_T.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 Qh=(0,X.lazy)(()=>V(()=>import(`./CronJobsPanel-DJaiJw1W.js`).then(e=>({default:e.CronJobsPanel})),__vite__mapDeps([68,1,2,3,4,5,6,10,11,12,13,14,15,16,17,21,19,7,0,8,20,22,23,27])));(0,X.lazy)(()=>V(()=>import(`./CodeEditor-OjU9rotb.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,X.lazy)(()=>V(()=>import(`./DebugDashboard-BwSbR59I.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([41,1,2,3,4,5,6,10,11,12,13,14,15,16,17]))),(0,X.lazy)(()=>V(()=>import(`./DesignGalleryView-DLKWmyVp.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,X.lazy)(()=>V(()=>import(`./MailboxDetailView-2NJVLrjb.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,X.lazy)(()=>V(()=>import(`./SageTabs-B-m4WBoA.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([53,1,2,3,4,5,6,10,11,12,13,14,15,16,17,7]))),(0,X.lazy)(()=>V(()=>import(`./AgentRosterView-CIUKmLsb.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,X.lazy)(()=>V(()=>import(`./KanbanView-CyVG4DQu.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,27,30,18,24,25,26,47]))),(0,X.lazy)(()=>V(()=>import(`./OfficeMapPanel-BKHjEIu9.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 $h=(0,X.lazy)(()=>V(()=>import(`./ProcessMonitor-9TOnqT6l.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]))),eg=(0,X.lazy)(()=>V(()=>import(`./QueuePanel--PTd2-7z.js`).then(e=>({default:e.QueuePanel})),__vite__mapDeps([69,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,21,0,8,20,22,23,27])));(0,X.lazy)(()=>V(()=>import(`./RefreshDebugView-CuKbgI-T.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([52,1,19,2,3,4,5,6,7,10,11,12,13,14,15,16,17,8,23]))),(0,X.lazy)(()=>V(()=>import(`./SddHub-DZCKF3Gw.js`).then(e=>({default:e.SddHub})),__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,27,38,30,47,56]))),(0,X.lazy)(()=>V(()=>import(`./SessionsDashboard-DoAbZStd.js`).then(e=>({default:e.SessionsDashboard})),__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,58,44,27,38,45]))),(0,X.lazy)(()=>V(()=>import(`./SetupScreen-CMrLwoo9.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([64,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,X.lazy)(()=>V(()=>import(`./SkillDetailView-sVjQG3qG.js`).then(e=>({default:e.SkillDetailView})),__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,33]))),(0,X.lazy)(()=>V(()=>import(`./SpecsView-B53AUOo3.js`).then(e=>({default:e.SpecsView})),__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,38]))),(0,X.lazy)(()=>V(()=>import(`./TechStackView-iONTty84.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([61,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,X.lazy)(()=>V(()=>import(`./TerminalPanel-1mqoe2_8.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([65,1,2,3,4,5,6,10,11,12,13,14,15,16,17,0,7,8,21,19,20,22,23,66,67])));function tg(){let{t:e}=h(),{theme:t}=Ja(),n=Ur(),{currentView:i,sidebarOpen:a,toggleSidebar:o,setSearchOpen:s,setSidebarOpen:c,setInspectorTab:l,setPaletteOpen:u,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,toggleInspector:m,setFleetMonitorOpen:g,setAgentsMonitorOpen:_,processMonitorOpen:v,setProcessMonitorOpen:y,queuePanelOpen:b,setQueuePanelOpen:x,cronJobsOpen:S,setCronJobsOpen:C,setTerminalOpen:w}=K(he(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}))),T=r(e=>e.isLoading),E=W(e=>e.iteration),D=W(e=>e.projectName),O=W(e=>e.session?.title),k=W(e=>e.session?.id),A=K(e=>k?e.sessionNicknames[k]:void 0),j=K(e=>e.sideContextBreakdownOpen),M=K(e=>e.setSideContextBreakdownOpen);ii(e=>e.agents),Ua({setPaletteOpen:u,setSearchOpen:s,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,setFleetMonitorOpen:g,setAgentsMonitorOpen:_,setProcessMonitorOpen:y,setQueuePanelOpen:x,setCronJobsOpen:C,setTerminalOpen:w}),(0,X.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?ji(`debug`):window.location.pathname===`/analytics`?ji(`analytics`):window.location.pathname===`/refresh-debug`&&ji(`refresh-debug`))},[]),(0,X.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=H(G.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,X.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=pi.getState().openFiles.find(e=>e.path===t);if(!n)return;let r=H(G.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:ee}=Br();(0,X.useEffect)(()=>{ee&&K.getState().sidebarOpen&&c(!1)},[ee,c]);let N=ee&&a;return Rr(),Wa(),(0,X.useEffect)(()=>{let e=[];if(T){let t=E?` iter ${E.index}${E.max?`/${E.max}`:``}`:``;e.push(`●${t}`)}let t=A?.trim()||O?.trim(),n=D?.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=D||`AI Agent`}},[T,E,D,O,A]),Ga({toggleSidebar:o,setSearchOpen:s,toggleInspector:m,setInspectorTab:l}),(0,Z.jsxs)(`div`,{"data-shell":n?`desktop`:`browser`,className:U(`ws-app-root flex min-h-0 min-w-0 overflow-hidden`,n&&`ws-desktop-shell`,t),children:[(0,Z.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,Z.jsx)(Oa,{desktopShell:n}),a&&i!==`setup`&&(0,Z.jsx)(nl,{desktopShell:n}),(0,Z.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,Z.jsx)(hs,{currentView:i,projectName:D,sessionLabel:A||O||k||void 0,isLoading:T,iteration:E??null,onPalette:()=>u(!0),onSearch:()=>s(!0),onModel:()=>f(!0),onSettings:()=>Mi(`settings`)}),i!==`setup`&&(0,Z.jsx)(Es,{}),i!==`setup`&&(0,Z.jsx)(Ds,{}),(0,Z.jsx)(Yh,{sessionId:k??null,desktopShell:n})]}),i!==`setup`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.inspector`),children:(0,Z.jsx)(cs,{})}),k&&i===`chat`&&(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.workspaceInspector`),children:(0,Z.jsx)(Bl,{sessionId:k})})]}),v&&(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.processMonitor`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)($h,{open:v,onClose:()=>y(!1)})})}),b&&(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.queue`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(eg,{open:b,onClose:()=>x(!1)})})}),S&&(0,Z.jsx)(Ms,{level:`panel`,name:e(`activity:panels.cronJobs`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Qh,{open:S,onClose:()=>C(!1)})})}),(0,Z.jsx)(Is,{}),j&&(0,Z.jsx)(As,{open:j,onClose:()=>M(!1)}),(0,Z.jsx)(Ts,{}),(0,Z.jsx)(Ki,{}),(0,Z.jsx)(Ui,{}),(0,Z.jsx)(Va,{}),(0,Z.jsx)(Hs,{}),(0,Z.jsx)(Rs,{}),(0,Z.jsx)(zs,{}),(0,Z.jsx)(Pi,{})]})}function ng(){return(0,Z.jsx)(Ms,{children:(0,Z.jsx)(qa,{defaultTheme:`system`,children:(0,Z.jsx)(tg,{})})})}Zi.createRoot(t(document.getElementById(`root`))).render((0,Z.jsx)(X.StrictMode,{children:(0,Z.jsx)(ng,{})}));export{ca as A,Qa as C,Xa as D,eo as E,aa as M,Ja as O,Lo as S,$a as T,Js as _,zp as a,Yo as b,Sf as c,jd as d,kd as f,Zs as g,Dl as h,Gp as i,la as j,ia as k,lf as l,jl as m,Kp as n,Ep as o,Nl as p,qp as r,Sp as s,Jp as t,Nd as u,bs as v,to as w,Jo as x,vs as y};